Author Archives: admin

Maya Grab [Day 3] – Peeking into memory

Today I was busy taking screenshots of all the rooms and their states in the game. The complete solution for the game can be found here. Oh, did I say that the game is in german only? But no worries, I’ll make an english version too. Anyways, 46 screenshots of rooms and states are waiting for conversion back to C64 character graphics. It has to be done manually, or with a image to PETSCII tool, since the program is protected and can’t be listed. But that’s ok, I want to do it manually so I can practice a little bit creating graphics like this.

Having a solution for the game is fine, but there are surely more possibilities for writing commands to the interpreter and since, like mentioned before, the program is protected, there is only one thing left to try out – make a memory dump of the C64 and hope that the commands aren’t crunched or somehow hidden or crypted. Almost every emulator (I’m using VICE) has a built in Monitor, a powerful tool which you can use to write machine code or look into and alter specific memory addresses. So I’ve started the game, did a soft reset and started the tool. With the command “I” you can output a memory part, for example “I 0000 FFFF” will output all 64kb. I’ve mentioned before that the BASIC program is starting at address $0801 and there is also a 4kb upper RAM at $C000 which in this case was empty. What I’ve found out is that all the commands are stored from $2080 to $23A0. There are 35 verbs, 40 adverbs and 66 nouns for use. By looking further from $5000 to $7AA8, there were more strings which show up in the game, mixed with some other data or code probably for interpreting the commands.

Since I know now all the words that can be used I can, more or less, guess how the interpreter works. If you look at the solution you’ll notice that all the commands are build up verb + noun. Obviously, the adverbs, that come usually between those two words, are completely optional or just ignored. One more interesting thing is that the words are shortened to 5 or 6 characters. The word “schluessel” (“key” on german) is shortened to “schlu”. Basically you can write: “nimm schlu” to take the key. It’s valid and the interpreter understands it… like this also: “nimm schluabcdefghijklmn”. I assume that this is done for speeding up the interpreter, since there is enough memory to store whole words. You can also take an item more then once, the interpreter will say every time “OK”.

* * * * *

Maya Grab [Day 2] – Doing some research

It’s the second day since the project got started, and I was thinking about to do some research on the C64 – it’s been a while since I worked last time on that machine. If I only had internet and all this documentation thirty years ago. There is no actual plan what to do first because the project isn’t so big. I’ll stick with the most dumb strategy ever: do whatever I’m currently in the mood for doing, and try to waste as less time as possible. Also I’ll try to explain most of the stuff I’m doing with lots of code snippets, both BASIC and later machine code – therefore I’ve done some extra CSS for code syntax and highlighting.

The Commodore 64 is a very nice built 8bit machine with 64kb of memory (addressed from $0000 to $FFFF). Not all 64kb are available as RAM; a nice overview, how the machine is organized, can be found here. There are 38911 bytes available for BASIC programs (addressed from $0801 to $9999) and additional 4096 bytes of upper RAM (addressed from $C000 to $CFFF) reserved for machine code or data; of course no one is stopping you to write everything in machine code – most of the games are written like this and they have only one BASIC line for calling the actual machine code program. A detailed documentation about the complete memory map of the C64 (RAM, ROM, I/O, KERNAL) can be found here.

So, as decided earlier, the main program will be written in BASIC. In BASIC all lines of code must be manually preceded by a line number, and on the C64 the line numbers are limited from 0 to 63999 (it doesn’t matter how you organize the numbering between those limits, as long as you have free memory for the complete program). In modern languages you can organize your code into packages, files or classes; on the C64 though everything is in just one text “file”, which you can’t edit easily or scroll up and down like in a normal text editor. No, you have to list a line or a range of lines to see the actual code and overwrite the line to make a simple code change. Also, you can’t just put code between another two lines of code if your are out of line numbers between them – you will have to rearrange everything. Yes, welcome to the 80’s!

Knowing all this I’ve made a rough code organization for my game:

00001 – 00999 REMARKS
        bunch of comments and credits everyone likes to write
01000 – 04999 DATA INITIALIZATION
        initialization of constants, arrays and variables for the game
05000 – 09999 MAIN GAME LOOP
        main game loop
10000 – 19999 SUBROUTINES
        subroutines and helper methods for game handling and rendering
20000 – 29999 INTERPRETER
        interpreter which translates user input and takes actions
30000 – 49999 ROOMS
        room data and rendering
50000 – 54999 SPRITE HANDLING
        sprite data and rendering
55000 – 59999 SOUND HANDLING
        sound data and playing
60000 – 63999 MACHINE CODE
        reserved space for potential machine code data

* * * * *

Maya Grab [Day 1] – Introduction

Watch your health. No seriously, watch your health! Only when you’re sick and lying in bed you can get these crazy ideas to fire up your 30 years old home computer and check out a couple of games you’ve played a long time ago, before most of the people who are actually reading this were even born. That’s exactly what happened to me. I said to myself, now is the time… you’re off from work for a week. Now is the time to turn that Commodore 64 (emulator) and go through all of these digital Input-64 magazines again. In one of these magazine issues, there was this game, that I’ve tried thousand times to recreate (it’s a little bit hard, when you are 7 years old). Maybe now, thirty years later it’s going to work?

So it’s a text adventure, how hard it can be? I always wanted to do a text adventure because I find it very interesting how the command interpreters work; and I’ll have the opportunity to play a little bit with PETSCII graphics. Last time I’ve wrote a Commodore 64 BASIC program was over twenty years ago. The C64 has the BASIC V2, which has approx. 70 different commands and 38911 bytes free for your masterpiece program. I’m going to write the whole game in BASIC, and maybe later port some of the code (mostly the rendering) to C64 assembler.

Let’s fire up this emulator and do some high-tech code:

How I’ve only got into this mess…

* * * * *

Maya Grab Remake – Project started

Maya Grab is a text adventure game for the Commodore 64 released in 1986, and we’re going to remake it for the C64! You can follow the development journal here. The complete source code will be published when the game is finished.

* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *