![]() |
Routines |
| Prev: B453 | Up: Map | Next: B4B1 |
|
Used by the routine at DrawSprite.
Finds the address in the play window buffer of the byte that holds a given pixel position. The address is F400 plus 18 times (AF minus the y position) plus the x position divided by 08.
|
||||||||||||||
| GetBufferAddress | B48E | PUSH HL | Save HL. | |||||||||||
| B48F | PUSH BC | Save the x position. | ||||||||||||
| B490 | LD A,B | Take the y position, subtract 20 and flip the bits (which is the same as taking it away from 011F), then add 90 to give AF minus the y position. | ||||||||||||
| B491 | SUB $20 | |||||||||||||
| B493 | CPL | |||||||||||||
| B494 | ADD A,$90 | |||||||||||||
| B496 | LD L,A | Put the result in HL. | ||||||||||||
| B497 | XOR A | |||||||||||||
| B498 | LD H,A | |||||||||||||
| B499 | LD B,H | Copy it into BC. | ||||||||||||
| B49A | LD C,L | |||||||||||||
| B49B | ADD HL,HL | Multiply by 18: double it, add the original, then double three times. | ||||||||||||
| B49C | ADD HL,BC | |||||||||||||
| B49D | ADD HL,HL | |||||||||||||
| B49E | ADD HL,HL | |||||||||||||
| B49F | ADD HL,HL | |||||||||||||
| B4A0 | POP BC | Restore the x position into C. | ||||||||||||
| B4A1 | LD B,A | Clear the high byte of the x position. | ||||||||||||
| B4A2 | SRL C | Divide the x position by 08. | ||||||||||||
| B4A4 | SRL C | |||||||||||||
| B4A6 | SRL C | |||||||||||||
| B4A8 | ADD HL,BC | Add it to the offset. | ||||||||||||
| B4A9 | LD BC,$F400 | Add the base of the buffer. | ||||||||||||
| B4AC | ADD HL,BC | |||||||||||||
| B4AD | LD C,L | Put the address into BC. | ||||||||||||
| B4AE | LD B,H | |||||||||||||
| B4AF | POP HL | Restore HL. | ||||||||||||
| B4B0 | RET | Return. | ||||||||||||
| Prev: B453 | Up: Map | Next: B4B1 |