Prev: 59100 Up: Map Next: 59234
59183: Write Game Sprite Buffer
Writes a sprite into the in-game room buffer. Clone of WriteSpriteBuffer.
Input
A Starting sprite ID
B Vertical position
C Horizontal position
D Height
E Width
WriteGameSpriteBuffer 59183 PUSH AF Stash the registers this tile walk uses.
59184 PUSH BC
59185 PUSH DE
59186 PUSH HL
59187 DEC A Start one ID before the first tile so the increment lands on it.
59188 LD (62262),A Write the tile ID to *ActiveSpriteID.
59191 LD A,E Remember the remaining width in *ActiveSpriteWidth.
59192 LD (62261),A
WriteGameSpriteBuffer_NextRow 59195 LD A,(62261) Reload the remaining width.
59198 LD E,A
59199 PUSH BC Stash the position and size.
59200 PUSH DE
59201 CALL ConvertCoordinateToBufferOffset Convert this tile into a room-buffer offset.
59204 POP DE Restore the position and size.
59205 POP BC
WriteGameSpriteBuffer_NextTile 59206 LD A,(62262) A=*ActiveSpriteID.
59209 INC A Advance to the next tile ID.
59210 CP 0 Jump to WriteGameSpriteBuffer_WriteTile if the tile ID wrapped.
59212 JR Z,WriteGameSpriteBuffer_WriteTile
59214 LD (62262),A Write it back to *ActiveSpriteID.
WriteGameSpriteBuffer_WriteTile 59217 CALL PopulateGameRoomBuffer Write that tile into the game room buffer.
59220 DEC E Move one column across.
59221 JR NZ,WriteGameSpriteBuffer_NextTile Jump to WriteGameSpriteBuffer_NextTile until this row is complete.
59223 DEC D Move on to the next row of tiles.
59224 JR Z,WriteGameSpriteBuffer_Done Jump to WriteGameSpriteBuffer_Done if every row is written.
59226 DEC B Move one row up.
59227 JR WriteGameSpriteBuffer_NextRow Jump to WriteGameSpriteBuffer_NextRow.
WriteGameSpriteBuffer_Done 59229 POP HL Restore HL, DE, BC and AF from the stack.
59230 POP DE
59231 POP BC
59232 POP AF
59233 RET Return.
Prev: 59100 Up: Map Next: 59234