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…

* * * * *