![]() |
Routines |
| Prev: 9BC1 | Up: Map | Next: 9BEA |
|
Used by the routines at MenuWriteText, FlashScore, GetGraphicAttributeDetails, SetEntityAttributes, PrintStringColour and DrawSidePanelAttrs.
Converts the pixel position of a point into the address in the attribute buffer of the character cell that holds it.
|
||||||||||||||
| AttributeAddress | 9BD2 | PUSH BC | Stash BC on the stack. | |||||||||||
| 9BD3 | LD A,L | Fetch the X position. | ||||||||||||
| 9BD4 | RRCA | Rotate right three times, which divides the X position by 08. | ||||||||||||
| 9BD5 | RRCA | |||||||||||||
| 9BD6 | RRCA | |||||||||||||
| 9BD7 | AND %00011111 | Keep only bits 0-4 (the column). | ||||||||||||
| 9BD9 | LD L,A | Keep the column in L. | ||||||||||||
| 9BDA | LD A,H | Fetch the Y position. | ||||||||||||
| 9BDB | RLCA | Rotate left twice. | ||||||||||||
| 9BDC | RLCA | |||||||||||||
| 9BDD | LD C,A | Keep the Y position, rotated, in C. | ||||||||||||
| 9BDE | AND %11100000 | Keep only bits 5-7 (the character row within the third of the screen). | ||||||||||||
| 9BE0 | OR L | Combine it with the column. | ||||||||||||
| 9BE1 | LD L,A | Keep the low byte of the attribute buffer address in L. | ||||||||||||
| 9BE2 | LD A,C | Fetch the Y position, rotated. | ||||||||||||
| 9BE3 | AND %00000011 | Keep only bits 0-1 (the third of the screen). | ||||||||||||
| 9BE5 | OR %01011000 | Set bits 3-4 and 6, so the address is in the attribute buffer (58). | ||||||||||||
| 9BE7 | LD H,A | Keep the high byte of the attribute buffer address in H. | ||||||||||||
| 9BE8 | POP BC | Restore BC from the stack. | ||||||||||||
| 9BE9 | RET | Return. | ||||||||||||
|
View the equivalent code in;
|
||||||||||||||
| Prev: 9BC1 | Up: Map | Next: 9BEA |