COM1 2022-09-01 02:15
I want to save the player's inputted character name. How would I do that? I imagine I have to convert it to some value but do I need to do each char or can I save the whole string?
nathanielbabiak 2022-09-01 04:21 (Edited)
Also, you need to use the RAM at $E000 since that's the persistent area of memory.
was8bit 2022-09-01 05:58 (Edited)
Save each the ascii value of each text character .... for simplicity set the length of name to, say, 8, padding the name with blanks if it is less than the max...
Rem pad name
... this puts blanks at end to ensure the name length is always the same
For I=1 to max
Poke $E000+I, ASC(MID$(NAME$,I,1))
to save name to persist memory
For I= 1 to max
Should read the name from persist memory
... I am half asleep right now, so hopefully there are no errors in my code ;)
was8bit 2022-09-01 10:55
Just tested, works fine... here is a version with cleaned up code...
FOR I=1 TO NMAX
POKE $E000+I, ASC(MID$(NAME$,I,1))
FOR I= 1 TO NMAX
COM1 2022-09-01 16:32 (Edited)
Thank you all! Working with this system really gives me an appreciation for early games and their creative solutions to make the most of hardware limitations. I wouldn't have considered that I would need to fill the empty slots if the name is shorter so I really appreciate that and I will definitely peek and poke around that pascal string program.
Sorry not sure if I should make a second post to ask this question but I figured editing would be cleaner.
Wait, in the For Loop should I convert I to a HEX format like HEX(I)? I just want to make sure I would be using it all efficiently, because the memory addresses are expressed in a hex format right? Since the Persist Ram is 4kb, that would mean the last address would be $EF9F (or 3999) right? Sorry I have looked over the manual a couple times and just want to be thorough.
was8bit 2022-09-02 05:52
$E000 to $EFFF is the whole range :)
It’s entire size is $1000
was8bit 2022-09-02 06:05
Number formats can be confusing, but as far as storing into memory, format doesn’t matter.... I use $#### format to match the memory address format so I dont get confused... remembering that a single digit goes from 0 to f (f being 15)
As far as what you put in, PEEK and POKE is the simplest approach, as it’s range is 0 to 255, which exactly matches how many graphic characters you have, so it seems easier for me..
was8bit 2022-09-02 06:09
The only tricky thing to be careful about is ASCII code, which standardized text characters to a set of numbers... and these do not match up with the character editor numbers..
So swapping text to number back to text is easiest with ASC and CHR$...
Lowres memory doesn’t care about anything other than your limit per byte size is 0 to 255... how you use that number is up to you ;)
was8bit 2022-09-02 06:11
It gets trickier to access memory when using 2 or 4 bytes at a time..
You have to keep track of which bytes you are using for what...
was8bit 2022-09-02 06:21 (Edited)
.. an example
%01100100 = $64 = 100
LowresNX sees these as the same
... you are free to use any format at anytime you wish in your code :)
There are times when binary format is useful (when writting code to edit graphics in memory at a pixel level)
There are times when hex format is usefull (when accessing memory)
Most all other times, good old decimal format is best ;)
COM1 2022-09-05 01:34
Thank you so much for this complete answer! I will reference this as i work on my project.
was8bit 2022-09-05 03:33
Glad to be helpful :)