![]() |
Routines |
| Prev: 45972 | Up: Map | Next: 46035 |
|
Used by the routines at DisplayObjectsCarried and PrintText.
Finds the address in the attribute file of the colour square that holds a pixel. The y co-ordinate counts up from the bottom of the screen. The result is based on 22272 rather than 22528 as the lowest eight character rows are below the screen.
|
||||||||||||||
|
Turn the pixel position into a character offset.
|
||||||||||||||
| CalculateAttributeAddress | 46006 | PUSH HL | Stash HL on the stack. | |||||||||||
| 46007 | LD A,H | Invert the y co-ordinate. | ||||||||||||
| 46008 | CPL | |||||||||||||
| 46009 | LD H,A | |||||||||||||
| 46010 | SRL H | Shift the inverted y co-ordinate right four times. | ||||||||||||
| 46012 | SRL H | |||||||||||||
| 46014 | SRL H | |||||||||||||
| 46016 | SRL H | |||||||||||||
| 46018 | RR L | Rotate the last bit shifted out into the top of L, shifting the x co-ordinate right by one. | ||||||||||||
| 46020 | SRL H | Shift H again, and rotate the bit shifted out into L. | ||||||||||||
| 46022 | RR L | |||||||||||||
| 46024 | SRL H | Shift H once more, and rotate the bit shifted out into L. This leaves HL as the character row times 32 plus the column. | ||||||||||||
| 46026 | RR L | |||||||||||||
|
Add the attribute file base.
|
||||||||||||||
| 46028 | LD DE,22272 | Set DE to 22272, the base of the attribute file less 256. | ||||||||||||
| 46031 | ADD HL,DE | Add the offset to get the address of the attribute. | ||||||||||||
| 46032 | EX DE,HL | Keep the attribute address. | ||||||||||||
| 46033 | POP HL | Restore HL from the stack. | ||||||||||||
| 46034 | RET | Return. | ||||||||||||
|
View the equivalent code in;
|
||||||||||||||
| Prev: 45972 | Up: Map | Next: 46035 |