So, it was time i got back to some Z80 on the Sam Coupe.  Im still sorting out the SamOnline code for the Trinity interface, but that requires im infront of the hardware with an internet connection.  I wanted something i could do while on holiday and away from the office etc.

I was going to do R-Type but i recently found someone else was working on it and didnt want to step on any toes, plus i wanted to start with something a little easier.  The Sam Coupe is always a bit of a pain for scrolling so i decided to go for a flip screen game.  Looking to my favourites there were a few to choose from, one was a game that was supposed to be out on the Sam but never made it.  That game was Treasure Island Dizzy.

The first stage i decided to tackle was to see about ripping apart the spectrum version.  Hopefully that would give me the graphics and maps i needed to start the Sam version with.  I booted up the spectrum version, ripped apart the loader and pulled out the main game binary.  Stick that into a disassembler and away i went.  One good thing with emulators these days is you can ‘nop’ out various calls to see what is then missing etc, poke memory and have a good look what various things do.  Combine this with a good disassembler so you can label things and you can soon get a good idea of whats going on.

To pull the graphics out i used a copy of SGE (Spectrum Graphics Editor) to locate where a graphic block was in memory.  Having got the memory address for this it was a case of putting a memory read breakpoint on that address.  As soon as the debugger stops you know you are at a routine that is likely to be drawing the graphics.  From that point it doesnt take long to reverse engineer the routines back to find a map drawing routine.

Once i had a function for the drawing of the levels, i quickly knocked up a c# program to pull out the graphic blocks to separate png files.


I followed this up by ripping all the screens into png just to make sure i have the full map format.

You may realise that the blocks are in black/white but the map is coloured.  The block data does not store the colours, its the map format that does.  In Dizzy it is possible for them to use the same graphic but change its colour.  The spectrum map format is made up of 4 bytes per item.

  1. The block number
  2. X Position (divided by 4)
  3. Y Position
  4. Attributes

Now the attributes is clever.  The bottom 3 bits is the colour of the block.  The next 2 bits define how the graphic is drawn to the screen.  00 means copy the data to the screen, 01 is XOR the data to the screen, 10 is OR to the screen.  Bit 7 is the Half Bright bit, this always works as collision (more later).  Bit 8 is the horizontal flip bit.

As mentioned the half bright bit is also used for collision, this was something i had never noticed while i played the game.  If you look carefully the spectrum levels are created so that you can only walk on anything that didnt have the half bright bit set.  Anything that did have it set was ignored by the collision system.  You can see this at work if you pick up the crate.  When its sitting waiting to be picked up its bright – ie. you can walk over it.  Its only when you drop it where it is supposed to be that it goes to darker colours and you can stand on it… Has anyone else noticed you cant pick it back up once its in the right place, every other time you can 😉

I carried on disassembling the spectrum version, pulling out extra data that i would need, working out how they handle the movement and collision etc.  Once i had all this i was at a point i felt i was ready to start coding up a Sam Coupe version….