Wednesday, 11 November 2020

Lunchtime Coder #3 - Atic Atac Room and Object Viewer

Ultimates Atic Atac has always been one of my fave old skool 8-bit games, so I decided to have a bit of fun with it and see if I could use modern code to read from a ZX Spextrum memory dump of the game and get the rooms to draw/render correctly.

GOAL To create a program that reads a ZX spectrum Atic Atac .sna file and recreates the rooms from the original code.

DEV 001 Read the file and be able to draw the outline of a basic room.

So this is pretty straight forward. With the help of a few Atic Atac fan sites, I found that all of Atic Atac's 13 different types of room are stored in a table as X and Y data points to draw lines between. It should be a case of working out the memory offset for the first room, then adding additional offset to allow for the room type.

I had a false start.. My .sna file was 48 kB, but the ZX Spectrum memory paging includes the 16 kB rom so before I started, I needed to pad my .sna file with 16 kB of dummy data.

Once that was done, I found the room draw co-ordinates without issue and worked out how to whip them up into a recognisable room.

Bizarrely, Room Type 7 has a co-ordinates error in at that draws the staircase incorrectly. I say bizarrely because I had never noticed an incorrectly drawn room in the game. When I checked an on line Atic Atac map, I founf that room type 7 isn't used in the game, and hence why the error never appears in the game. See below:

DEV 002 Input a game location, and get the correct room type in the correct colour drawn.

So its all very well just stepping through the room draw area, but I wanted to take it back a step and access the actual game location table so that for any game location, I could get the correct room type drawn in the correct colour.

Tell the program what Game location you want to draw. The program will read what type of room and what colour that location is, and then jump to that type of room and draw it.

e.g. I am in Game Location 12. Game Location 12 is a type 3 left to right corridor style of room coloured green. Set colour to green and go to the room type table and draw a type 9 room.

DEV 003 Input a game location, and get the correct room type in the correct colour drawn and get the correct objects added to the room.

As most of the work is done, Its a case of looking at the object table for that game location and reading the object type, x and y position and orientation, and then drawing the bitmap into place.

And.. Goal Achieved. I s'pose that I could colourise the objects and occasionally the orientation is coming out incorrect on some objects but in general, job done.

Could be very handy for an Atic Atac remake, being able to take basic data from the original game itself to draw an updated version.

No comments:

Post a comment