Prev: 53557 Up: Map Next: 53620
53591: Calculate Attribute Address
Finds the address in the attribute file of the character square that holds a pixel. The pixel y position is from the bottom of the screen.
Input
H The pixel y position
L The pixel x position
Output
DE The address of the attribute
Work out the square from the position.
CalculateAttributeAddress 53591 PUSH HL Stash HL on the stack.
53592 LD A,H Fetch H, invert it and copy it to H.
53593 CPL
53594 LD H,A
53595 SRL H Shift H right four times.
53597 SRL H
53599 SRL H
53601 SRL H
53603 RR L Rotate L right.
53605 SRL H Shift the next bit into L.
53607 RR L
53609 SRL H Shift the next bit into L.
53611 RR L
53613 LD DE,22272 Point DE at 22272.
53616 ADD HL,DE Add DE to HL.
53617 EX DE,HL Exchange DE and HL.
53618 POP HL Restore HL from the stack.
53619 RET Return.
View the equivalent code in;
Prev: 53557 Up: Map Next: 53620