![]() |
Routines |
| Prev: 41731 | Up: Map | Next: 42399 |
|
Used by the routine at DrawSprites.
Finds the address in the buffer at 63488 of the top left of a sprite in the rectangle that is being drawn by DrawSprites.
|
||||||||||||||
| FindBufferAddress | 42366 | LD A,(23596) | Fetch the left of the rectangle. | |||||||||||
| 42369 | LD C,A | Store it in C. | ||||||||||||
| 42370 | LD A,L | Fetch the horizontal position. | ||||||||||||
| 42371 | SUB C | Subtract the left of the rectangle. | ||||||||||||
| 42372 | SRL A | Divide it by eight to get the number of bytes across. | ||||||||||||
| 42374 | SRL A | |||||||||||||
| 42376 | SRL A | |||||||||||||
| 42378 | LD L,A | Store it in L. | ||||||||||||
| 42379 | LD A,(23597) | Fetch the bottom of the rectangle. | ||||||||||||
| 42382 | SUB H | Subtract the vertical position to get the number of rows up. | ||||||||||||
| 42383 | JR Z,FindBufferAddress_Page | Jump to FindBufferAddress_Page if the sprite is at the bottom. | ||||||||||||
| 42385 | LD C,A | Store the number of rows in C. | ||||||||||||
| 42386 | LD A,(52789) | Fetch the number of bytes in a row. | ||||||||||||
| 42389 | LD H,A | Store it in H. | ||||||||||||
| FindBufferAddress_Row | 42390 | LD A,L | Fetch the offset. | |||||||||||
| 42391 | ADD A,H | Add the number of bytes in a row. | ||||||||||||
| 42392 | LD L,A | Store the offset. | ||||||||||||
| 42393 | DEC C | Count the rows. | ||||||||||||
| 42394 | JR NZ,FindBufferAddress_Row | Loop back to FindBufferAddress_Row for each row. | ||||||||||||
| FindBufferAddress_Page | 42396 | LD H,248 | Use the buffer. | |||||||||||
| 42398 | RET | Return. | ||||||||||||
| Prev: 41731 | Up: Map | Next: 42399 |