Prev: 5E92 Up: Map Next: 5EC8
5EAA: Command 02: Draw Repeated Tile
Used by the routine at PopulateRoomBuffer.
Command 02: 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 5EAA INC HL Increment the room data pointer by one.
5EAB LD A,(HL) Fetch the repeat count from *HL and store it in B.
5EAC LD B,A
5EAD INC HL Increment the room data pointer by one.
5EAE LD A,(HL) Fetch the tile ID from *HL.
5EAF INC HL Increment the room data pointer past the command bytes.
RepeatedTile_Loop 5EB0 PUSH AF Stash the tile ID, repeat counter, tile counter and room data pointer on the stack.
5EB1 PUSH BC
5EB2 PUSH DE
5EB3 PUSH HL
5EB4 LD D,$00 D=00 (flag: draw tile to room buffer).
5EB6 CALL Draw_Room_Tile Call Draw_Room_Tile.
5EB9 POP HL Restore the room data pointer, tile counter, repeat counter and tile ID from the stack.
5EBA POP DE
5EBB POP BC
5EBC POP AF
5EBD EX AF,AF' Switch to shadow AF to preserve the tile ID.
5EBE DEC DE Decrease the tile counter by one.
5EBF LD A,E Jump back to PopulateRoomBuffer_Error if the tile counter is zero.
5EC0 OR D
5EC1 JR Z,PopulateRoomBuffer_Error
5EC3 EX AF,AF' Switch back to main AF to retrieve the tile ID.
5EC4 DJNZ RepeatedTile_Loop Decrease the repeat counter by one and loop back to RepeatedTile_Loop until all tiles are drawn.
5EC6 JR PopulateRoomBuffer_ParseByte Jump to PopulateRoomBuffer_ParseByte to continue parsing.
Prev: 5E92 Up: Map Next: 5EC8