![]() |
Routines |
| Prev: 46163 | Up: Map | Next: 46257 |
|
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 62464 plus 24 times (175 minus the y position) plus the x position divided by 8.
|
||||||||||||||
| GetBufferAddress | 46222 | PUSH HL | Save HL. | |||||||||||
| 46223 | PUSH BC | Save the x position. | ||||||||||||
| 46224 | LD A,B | Take the y position, subtract 32 and flip the bits (which is the same as taking it away from 287), then add 144 to give 175 minus the y position. | ||||||||||||
| 46225 | SUB 32 | |||||||||||||
| 46227 | CPL | |||||||||||||
| 46228 | ADD A,144 | |||||||||||||
| 46230 | LD L,A | Put the result in HL. | ||||||||||||
| 46231 | XOR A | |||||||||||||
| 46232 | LD H,A | |||||||||||||
| 46233 | LD B,H | Copy it into BC. | ||||||||||||
| 46234 | LD C,L | |||||||||||||
| 46235 | ADD HL,HL | Multiply by 24: double it, add the original, then double three times. | ||||||||||||
| 46236 | ADD HL,BC | |||||||||||||
| 46237 | ADD HL,HL | |||||||||||||
| 46238 | ADD HL,HL | |||||||||||||
| 46239 | ADD HL,HL | |||||||||||||
| 46240 | POP BC | Restore the x position into C. | ||||||||||||
| 46241 | LD B,A | Clear the high byte of the x position. | ||||||||||||
| 46242 | SRL C | Divide the x position by 8. | ||||||||||||
| 46244 | SRL C | |||||||||||||
| 46246 | SRL C | |||||||||||||
| 46248 | ADD HL,BC | Add it to the offset. | ||||||||||||
| 46249 | LD BC,62464 | Add the base of the buffer. | ||||||||||||
| 46252 | ADD HL,BC | |||||||||||||
| 46253 | LD C,L | Put the address into BC. | ||||||||||||
| 46254 | LD B,H | |||||||||||||
| 46255 | POP HL | Restore HL. | ||||||||||||
| 46256 | RET | Return. | ||||||||||||
| Prev: 46163 | Up: Map | Next: 46257 |