Rooms
The game has 48 rooms, from 00 to 2F. There are six levels, each with eight rooms that wrap around each other. The bottom rooms with the river are 00-07; the top ones are 28-2F. Room 2B is the starting room; room 1B is the room with the safe.
There is therefore no need for a "next room" array as it can be automatically calculated. However, if you try to use a "large jump" cheat on one of the top rooms and jump above the screen, the game will crash!
Each room contains 12 bytes of basic information in an array starting at 69E6. This is referenced when a new room is entered at the routine in CBBD. The structure is :
00 - 01 Pointer to list of static UDGs
02 - 03 Location of a test tube in the room, if any
04 Various bit fields.
05 - 06 The x and y co-ordinates to draw the food item
07 - 08 Pointer to list of moving objects
09 - 0A Location of dynamite in the room, if any
0B If bits 0, 1 or 2 are set, this prints a bank card, an aerosol, or an oxygen tank in the room respectively. (F3EC) If bit 7 is set, this room has been visited.
The bit fields in offset 4 are:
00 - 02 An index (0 - 7) of a food item.
03 If set, food is in the room.
04 If set, a test tube is in the room.
05 If set, dynamite is in the room.
06 - 07 An index (0-3) into an array at 6C26 containing two custom attribute bytes that represent floors (in addition to a hard-coded six more) ie: can be stood on, followed by 6 bytes of attributes that represent walls ie: cannot be walked through.
UDG format
UDGs are referenced in the game by ID. This is translated by a lookup buffer at 6C46, where the ID is an index into an array of pointers to the actual data. This lookup is done in the routines at F3D3 and ED00 / ED06
The UDG data then contains two bytes containing the width (in bytes) and length (in 8 line blocks). Where a UDG's length is greater than 1 block, the graphic data appears in reverse order ie: the bottom width x 8 block comes first.
The graphic data contains all the pixel data, followed by all the attribute data. The attributes are either set individually for each 8x8 square, or contains a sequence of 00, nn where nn is the attribute to set for all squares.
UDG lists
Each room contains a list of several UDGs. These are pointed to by the first two bytes in each room data, and printed by the routine at ED00 / ED06.
The first two bytes are the co-ordinates of a UDG, followed by one byte for its ID. There is then an optional sequence of :
(The last two types, FC and FB are mostly used for staircases).
The structure then repeats.
Food
There are 8 types of food. The graphics are stored in an array at 65DA. The entry there points to UDG data of the food.
The array at 65EA contains the attribute of the food.
Sprites
Each room's sprite buffer is pointed to by offsets 7+8 in the room data. A room can have up to two different types of horizontal and veritical moving sprites each. A sprite is assigned an ID, which is an index into an array of pointers at AE60. The lookup is done at the routine in D669.
The first byte of sprite data holds two values. Bits 0 - 1 contain the sprite's width in bytes; bits 2 - 7 hold the number of lines for one frame. Multiplied together, this gives a size of a frame, which is temporarily stored in D675.
The sprite buffer starts with a 5-byte header. The format is:
00 ID of first vertical sprite
01 ID of second vertical sprite
02 ID of first horizontal sprite
03 ID of second horizontal sprite
04 - 05 Four 4-bit numbers containing the number of objects each of the four types defined above
The number of objects are copied as four bytes starting from E540. If any of the bytes are 0, the sprite is not drawn.
Following the header are a series of 8-byte structures, each dealing with animation and movement for each of the sprites defined. The total number of records is the sum of the item count from E540 - E543. The fields are:
00 Current x co-ordinate (horizontal) or y co-ordinate (vertical)
01 Fixed y co-ordinate (horizontal) or x co-ordinate (veritcal)
02 Minimum x (horizontal) or y (vertical) co-ordinate
03 Maximum x (horizontal) or y (vertical) co-ordinate
04 Bitfield of flags. If bit 6 is set, Dan collided with the object and it should not be drawn.
05 Attribute to colour the sprite in
06 Current frame number
07 Total number of frames
Make sure that field 2 is always lower than field 3, otherwise undefined behaviour will result!