Routines |
Prev: AA97 | Up: Map | Next: AB44 |
This is similar to UnpackAllRooms, however instead of copying ALL the room data from the default room data into the rooms data buffer, this routine copies a single room from the room data buffers into the active room buffer. The reason for this is that the game opens with the default positions for everything held by the defaults but as the player moves around the game and interacts with doors/ keys/ items/ etc, the buffers keep track of what's been collected, and where the pirates were when the player left the room so when they're revisited, they can then retain those changes.
|
||||
In TableRoomData the pointers to the room data are stored backwards from 16-01.
|
||||
UnpackRoom | AAF4 | LD A,($5BD4) | Take 16-*TempCurrentRoomID then multiply by 02 (as it's an address we fetch, so is 16 bit) finally add TableRoomData to point to the correct room buffer data address in the room data table for the current room and store the pointer in HL. | |
AAF7 | LD E,A | |||
AAF8 | LD A,$16 | |||
AAFA | SUB E | |||
AAFB | LD E,A | |||
AAFC | SLA E | |||
AAFE | LD D,$00 | |||
AB00 | LD HL,$BAA9 | |||
AB03 | ADD HL,DE | |||
AB04 | LD E,(HL) | Fetch the room buffer data address for the requested room and store it in DE. | ||
AB05 | INC HL | |||
AB06 | LD D,(HL) | |||
AB07 | INC HL | Does nothing, HL is overwritten immediately below. | ||
Move the room buffer data address pointer to the room data itself (the first 08 bytes are colour data). There's no need to copy the colours again, as they don't vary between each game.
|
||||
AB08 | LD HL,$0008 | DE+=0008 (using the stack). | ||
AB0B | ADD HL,DE | |||
AB0C | PUSH HL | |||
AB0D | POP DE | |||
Now move onto actually copying the room data.
|
||||
AB0E | LD HL,$BAD7 | HL=BufferCurrentRoomData. | ||
Set up counters for copying data from the default state to the room buffer.
The counter length relates to the length of the data for each instance of the "thing" being copied (NOT the length of the data being copied). For an example; portholes are 03 bytes of data each, so B is 03 when calling CopyRoomData. How many portholes being copied just depends on when the loop reads a termination character (FF).
|
||||
AB11 | LD B,$03 | Handle copying the scaffolding data. | ||
AB13 | CALL CopyRoomData | |||
AB16 | LD B,$04 | Handle copying the doors data. | ||
AB18 | CALL CopyRoomData | |||
AB1B | LD B,$02 | Handle copying the ladders data. | ||
AB1D | CALL CopyRoomData | |||
AB20 | LD B,$06 | Handle copying the keys and locked doors data. | ||
AB22 | CALL CopyRoomData | |||
AB25 | LD B,$03 | Handle copying the porthole data. | ||
AB27 | CALL CopyRoomData | |||
AB2A | LD B,$10 | Handle copying the pirate data. | ||
AB2C | CALL CopyRoomData | |||
AB2F | LD B,$07 | Handle copying the items data. | ||
AB31 | CALL CopyRoomData | |||
AB34 | LD B,$04 | Handle copying the furniture data. | ||
AB36 | CALL CopyRoomData | |||
AB39 | LD B,$10 | Handle copying the lifts data. | ||
AB3B | CALL CopyRoomData | |||
AB3E | LD B,$06 | Handle copying the disappearing floors data. | ||
AB40 | CALL CopyRoomData | |||
AB43 | RET | Return. |
Prev: AA97 | Up: Map | Next: AB44 |