Prev: 24210 Up: Map Next: 24264
24234: Command 2: Draw Repeated Tile
Used by the routine at PopulateRoomBuffer.
Command 2: draw the same tile repeatedly. The following two bytes specify the repeat count and the tile ID to draw.
Input
DE Tile counter
HL Pointer to the room data
Command02_RepeatedTile 24234 INC HL Increment the room data pointer by one.
24235 LD A,(HL) Fetch the repeat count from *HL and store it in B.
24236 LD B,A
24237 INC HL Increment the room data pointer by one.
24238 LD A,(HL) Fetch the tile ID from *HL.
24239 INC HL Increment the room data pointer past the command bytes.
RepeatedTile_Loop 24240 PUSH AF Stash the tile ID, repeat counter, tile counter and room data pointer on the stack.
24241 PUSH BC
24242 PUSH DE
24243 PUSH HL
24244 LD D,0 D=0 (flag: draw tile to room buffer).
24246 CALL Draw_Room_Tile Call Draw_Room_Tile.
24249 POP HL Restore the room data pointer, tile counter, repeat counter and tile ID from the stack.
24250 POP DE
24251 POP BC
24252 POP AF
24253 EX AF,AF' Switch to shadow AF to preserve the tile ID.
24254 DEC DE Decrease the tile counter by one.
24255 LD A,E Jump back to PopulateRoomBuffer_Error if the tile counter is zero.
24256 OR D
24257 JR Z,PopulateRoomBuffer_Error
24259 EX AF,AF' Switch back to main AF to retrieve the tile ID.
24260 DJNZ RepeatedTile_Loop Decrease the repeat counter by one and loop back to RepeatedTile_Loop until all tiles are drawn.
24262 JR PopulateRoomBuffer_ParseByte Jump to PopulateRoomBuffer_ParseByte to continue parsing.
Prev: 24210 Up: Map Next: 24264