Prev: 24000 Up: Map Next: 24178
24100: Populate Room Buffer
Fetch the current room number and set up the default tile and attribute data pointers.
PopulateRoomBuffer 24100 LD A,(24517) Load A with *CurrentRoom.
Initialise the room pointer/ default tile set.
24103 LD HL,33705 Write Room01 to *PointerRoomData.
24106 LD (24515),HL
24109 LD HL,39850 Write TileSet_Default to *PointerActiveTileSet.
24112 LD (24513),HL
If this is not room 0 look up the correct room data pointer.
24115 OR A Call FindRoomData if this is not room 0.
24116 CALL NZ,FindRoomData
Clear the screen buffer at RoomBuffer.
24119 LD HL,49152 Clear 6143 bytes from RoomBuffer onwards.
24122 LD DE,49153
24125 LD (HL),0
24127 LD BC,6143
24130 LDIR
Initialise drawing state variables.
24132 LD A,255 Write 255 to *RespawnFlag.
24134 LD (24507),A
24137 LD HL,255 Write 0255 to *RoomDrawPosition.
24140 LD (24505),HL
24143 LD DE,705 DE=705.
The main room data parsing loop. Reads a command byte from the room data and dispatches to the appropriate handler based on its value.
24146 LD HL,(24515) Fetch the *PointerRoomData and store it in HL.
PopulateRoomBuffer_ParseByte 24149 LD A,(HL) Fetch the room data byte from the pointer.
24150 OR A Jump to Command00_Skip if the room data byte is 0.
24151 JR Z,Command00_Skip
24153 CP 1 Jump to Command01_SkipTiles if the room data byte is 1.
24155 JR Z,Command01_SkipTiles
24157 CP 2 Jump to Command02_RepeatedTile if the room data byte is 2.
24159 JR Z,Command02_RepeatedTile
24161 CP 3 Jump to Command03_FillAttributes if the room data byte is 3.
24163 JR Z,Command03_FillAttributes
24165 CP 4 Jump to Command04_SwitchTileSet if the room data byte is 4.
24167 JR Z,Command04_SwitchTileSet
24169 CP 8 Jump to Command08Plus_SingleTile if the room data byte is 8 or higher.
24171 JR NC,Command08Plus_SingleTile
If none of the above matched, trigger an error (with an arbitrary error code).
PopulateRoomBuffer_Error 24173 RST 8 Run the ERROR_1 routine: RST 8.
24174 DEFB 4 Error code: 4 ("Out of memory").
Command 0: no-op. Skip this byte and continue parsing.
Command00_Skip 24175 INC HL Increment the room data pointer by one.
24176 JR PopulateRoomBuffer_ParseByte Jump to PopulateRoomBuffer_ParseByte.
Prev: 24000 Up: Map Next: 24178