![]() |
Routines |
| Prev: A817 | Up: Map | Next: A86E |
|
Used by the routine at DrawRoom.
Writes a sprite into the room buffer, starting from sprite ID A with width E and height D. Clone of WriteGameSpriteBuffer.
|
||||||||||||||||
| WriteSpriteBuffer | A83F | PUSH AF | Stash the registers this tile walk uses. | |||||||||||||
| A840 | PUSH BC | |||||||||||||||
| A841 | PUSH DE | |||||||||||||||
| A842 | PUSH HL | |||||||||||||||
| A843 | DEC A | Start one ID before the first tile so the increment lands on it. | ||||||||||||||
| A844 | LD ($BAA2),A | Write the tile ID to *DrawSpriteID. | ||||||||||||||
| A847 | LD A,E | Remember the remaining width in *DrawSpriteWidth. | ||||||||||||||
| A848 | LD ($BAA3),A | |||||||||||||||
| WriteSpriteBuffer_NextRow | A84B | LD A,($BAA3) | Reload the remaining width. | |||||||||||||
| A84E | LD E,A | |||||||||||||||
| A84F | PUSH BC | Stash the position and size. | ||||||||||||||
| A850 | PUSH DE | |||||||||||||||
| A851 | CALL ConvertDrawCoordinate | Convert this tile into a room-buffer offset. | ||||||||||||||
| A854 | POP DE | Restore the position and size. | ||||||||||||||
| A855 | POP BC | |||||||||||||||
| WriteSpriteBuffer_NextTile | A856 | LD A,($BAA2) | Advance *DrawSpriteID to the next tile ID. | |||||||||||||
| A859 | INC A | |||||||||||||||
| A85A | LD ($BAA2),A | |||||||||||||||
| A85D | CALL PopulateRoomBuffer | Write that tile into the room buffer. | ||||||||||||||
| A860 | DEC E | Move one column across. | ||||||||||||||
| A861 | JR NZ,WriteSpriteBuffer_NextTile | Jump to WriteSpriteBuffer_NextTile until this row is complete. | ||||||||||||||
| A863 | DEC D | Move on to the next row of tiles. | ||||||||||||||
| A864 | JR Z,WriteSpriteBuffer_Done | Jump to WriteSpriteBuffer_Done if every row is written. | ||||||||||||||
| A866 | DEC B | Move one row up. | ||||||||||||||
| A867 | JR WriteSpriteBuffer_NextRow | Jump to WriteSpriteBuffer_NextRow. | ||||||||||||||
| WriteSpriteBuffer_Done | A869 | POP HL | Restore HL, DE, BC and AF from the stack. | |||||||||||||
| A86A | POP DE | |||||||||||||||
| A86B | POP BC | |||||||||||||||
| A86C | POP AF | |||||||||||||||
| A86D | RET | Return. | ||||||||||||||
| Prev: A817 | Up: Map | Next: A86E |