![]() |
Routines |
| Prev: ADD6 | Up: Map | Next: ADF8 |
|
Used by the routines at MenuWriteText, ColourEntity, Set_Area_Attributes, PrintStringColour, Draw_Ceiling_Picture, Draw_Left_Wall_Picture, Draw_Top_Left_Corner_Picture, Draw_Line, Handle_Stalactite and Handle_Rock_Formation.
Converts a pixel position into the address of the matching cell of the attribute buffer.
|
||||||||||||
| AttributeAddress | ADE0 | PUSH BC | Stash BC on the stack. | |||||||||
| ADE1 | LD A,L | Fetch the x position. | ||||||||||
| ADE2 | RRCA | Divide it by 08. | ||||||||||
| ADE3 | RRCA | |||||||||||
| ADE4 | RRCA | |||||||||||
| ADE5 | AND $1F | Keep only five bits. | ||||||||||
| ADE7 | LD L,A | Store the column in L. | ||||||||||
| ADE8 | LD A,H | Fetch the y position. | ||||||||||
| ADE9 | RLCA | Multiply it by 04. | ||||||||||
| ADEA | RLCA | |||||||||||
| ADEB | LD C,A | Store the result in C. | ||||||||||
| ADEC | AND $E0 | Keep only the bits that give the low part of the row. | ||||||||||
| ADEE | OR L | Combine them with the column. | ||||||||||
| ADEF | LD L,A | Store the low byte of the address in L. | ||||||||||
| ADF0 | LD A,C | Fetch the multiplied y position. | ||||||||||
| ADF1 | AND $03 | Keep only the bits that give the high part of the row. | ||||||||||
| ADF3 | OR $58 | Add the start of the attribute buffer. | ||||||||||
| ADF5 | LD H,A | Store the high byte of the address in H. | ||||||||||
| ADF6 | POP BC | Restore BC from the stack. | ||||||||||
| ADF7 | RET | Return. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: ADD6 | Up: Map | Next: ADF8 |