INERTIA for MSX

I.N.E.R.T.I.A. is a small game presented to the MSXDEV'06 programming contest. You may

The I.N.E.R.T.I.A. Howto

Or: how to install sdcc compiler, additional tools and files, I.N.E.R.T.I.A. source code, and how to compile it. Instructions are for Windows, but similar steps could be done on Linux machines. Please also note that I need some feedback from you to know if suggested steps effectively work! Thanks in advance.

1. install sdcc

Download the SDCC executable from here. If you have "limited user" privileges under Windows, you may prefer to install it in a user-space directory created by yourself (example: "yourhomedir/msx/sdcc") instead of the usual "Program Files" folder, so you'll have full write access to the sdcc tree. I know it's not very good style, but it's a bit easier to manage and customize.

2. install split

You'll also need to add to the sdcc/bin directory the free GNU utility named split, version for Windows. SDCC builds a binary image of 64KB, but the 16KB ROM code lies in the 2nd quarter of the image. So we'll split file in four chunks and retrieve the second one, naming it "inertia.rom".

I found a Windows version of GNU split searching on Google for "UnxUtils"; you can download the binaries at this link.

Note: any file utility allowing to "cut" a binary file could be used there; a good alternative may be the (more general) dd file manipulation utility, which requires a bit of commandline options: input and output file name, block size, offset... both dd and split are available in the UnxUtils package.

3. replace crt0.o

When you build an executable with a C compiler, it usually adds module crt0.o as a header to the linked executable file. You'll have to replace standard lib/z80/crt0.o with one explicitly designed to work as an MSX ROM header. Original author of this file is the Japanese MSX user Boukichi, I just added at bottom the standard initrleblock routine, I think it's needed for sdcc to handle correctly static strings and arrays of strings.

Warning: crt0.o contains the hardcoded value of 0x4000 as starting address for the ROM. If you want to build for instance ROMS starting at 0x8000, you'll need to change that hardcoded value accordingly.

 4. add sdcc-msx.bat startup file

It's easier to start work with sdcc by simply clicking an icon. I wrote my simple batch startup file and put it in main sdcc directory, you may use it too. Just remember to change the full sdcc/binpathname according to your installing path. To check a correct startup file, you could type sdcc on command line (you should see the help screen for options).

5. extract I.N.E.R.T.I.A. sources

Go to sdcc main directory and simply unpack the source tree from zip file. Your sdcc tree should now be something like this:

6. compile!

If previous steps were successful, you could now start sdcc, go into sdcc/msx/inertia directory, and compile. You may also want to have a look at the contents of make.bat, to see what options were passed to the compiler and how the final ROM image was obtained.

Type make buildall to build and link all files (a lot of warnings are generated, as my code contains some Z80 machine code).

If you already made buildall and you are only changing main.c, type make main to compile only main.c file and build inertia.rom; main.c has no Z80 machine code, no warnings should appear for it.

A make clean command is also available. It deletes all intermediate files and inertia.rom (so be careful).

Hope you enjoy and build without too much pain. Please drop me a line to confirm that everything works as expected, thanks in advance.

Andrea