![]() |
Routines |
| Prev: D233 | Up: Map | Next: D272 |
|
Used by the routines at HandleMenuBullet and DrawMenuSprite.
Finds the address on the screen of a pixel. The vertical position is measured from the bottom of the screen.
|
||||||||||||||
|
Stash DE, and copy the position to it.
|
||||||||||||||
| CalculateScreenAddress | D24F | PUSH DE | Stash DE on the stack. | |||||||||||
| D250 | EX DE,HL | Copy the position to DE. | ||||||||||||
|
Work out the column from the horizontal position.
|
||||||||||||||
| D251 | LD A,E | Divide the horizontal position by eight. | ||||||||||||
| D252 | RRCA | |||||||||||||
| D253 | RRCA | |||||||||||||
| D254 | RRCA | |||||||||||||
| D255 | AND %00011111 | Keep the column. | ||||||||||||
| D257 | LD L,A | Store it. | ||||||||||||
|
Work out the character row within a third of the screen.
|
||||||||||||||
| D258 | LD A,D | Invert the vertical position and multiply it by four. | ||||||||||||
| D259 | CPL | |||||||||||||
| D25A | RLCA | |||||||||||||
| D25B | RLCA | |||||||||||||
| D25C | AND %11100000 | Keep the character row within the third. | ||||||||||||
| D25E | OR L | Make the low byte of the address. | ||||||||||||
| D25F | LD L,A | |||||||||||||
|
Work out the third of the screen.
|
||||||||||||||
| D260 | LD A,D | Invert the vertical position and divide it by eight. | ||||||||||||
| D261 | CPL | |||||||||||||
| D262 | RRCA | |||||||||||||
| D263 | RRCA | |||||||||||||
| D264 | RRCA | |||||||||||||
| D265 | AND %00011000 | Keep the third. | ||||||||||||
| D267 | LD H,A | Start the high byte. | ||||||||||||
|
Work out the line within the character row, and make the high byte of the address.
|
||||||||||||||
| D268 | LD A,D | Invert the vertical position. | ||||||||||||
| D269 | CPL | |||||||||||||
| D26A | AND %00000111 | Keep the line within the character row. | ||||||||||||
| D26C | OR H | Combine it with the third, add 38 and set the high byte. | ||||||||||||
| D26D | ADD A,$38 | |||||||||||||
| D26F | LD H,A | |||||||||||||
| D270 | POP DE | Restore DE from the stack. | ||||||||||||
| D271 | RET | Return. | ||||||||||||
|
View the equivalent code in;
|
||||||||||||||
| Prev: D233 | Up: Map | Next: D272 |