Maya Grab [Day 9] – More data initialization

Nothing interesting about the work for today. I’ve entered all the strings for room objects and directions and for the interpreter commands and messages. It was about 400 lines of code; very interesting typing all this manually, without copy/paste on a real C64. Regarding strings and localization, whats missing now is only the room messages, since I have to actually play the game and try out various things to see what specific messages are showing up in each room.

I’ve checked the free memory a couple of times while typing all the data; the interpreter strings took about 3kb, and the room strings another 2kb of memory. I’ve reduced the room objects and directions arrays from 6 to 4 per room, because there’s simply not enough space on screen to show 6 strings. Also I’m not sure if I’ll need 16 strings per room for messages, so I guess that could be also reduced to maybe 12 or even 8.

Next I wanted to check the execution time, and before entering any data it was about 1 second until the user input showed up; with data entered it’s 2 seconds, which is also pretty ok I guess. I don’t know if this depends on how I assigned strings to the arrays. Normally you would store a large amount of data with the DATA command, and then read it in a FOR NEXT loop with the READ command. The problem is, you only have one data pointer and you can’t control it, so all data must be read from start to the end (like a sequential file) and stored in appropriate variable types. You can’t read something from the end, then something from the start, and afterwards something from the middle of the whole data block. Only thing you can do is reset the pointer with the RESTORE command and read again everything from beginning. I could use this method because the data I want to initialize never changes, but it makes, for me at least, the code totally unreadable, and you have to be careful while changing the array sizes. So I’m initializing all arrays the dumb way, but fully optimized for maximum code beauty:


3600 IM$( 0)=“ICH SEHE  :”
3601 IM$( 1)=“WEGE NACH :”
3602 IM$( 2)=“WAS NUN ?”
3603 IM$( 3)=“WIE ???”
3604 IM$( 4)=“OK.”
3605 IM$( 5)=“KENNE ICH NICHT”
3606 IM$( 6)=“DAS GEHT JETZT NICHT !”
3607 IM$( 7)=“KANN ICH JETZT NICHT”
3608 IM$( 8)=“NEHMEN !”
3609 IM$( 9)=“HINGEHEN !”
3610 IM$(10)=“ANSEHEN !”
3611 IM$(11)=“OEFFNEN !”

Program size: 14101 bytes, on disk 11684 bytes or 46 blocks
Free BASIC memory: 24810 bytes
Used BASIC commands: –

Source code

* * * * *