Prev: 43089 Up: Map Next: 43119
43106: Calculate Attribute Buffer
Input
H Source Y position
L Source X position
Output
HL Attribute buffer location
Example inputs/ outputs:
X Position Y Position Output
0 0 22528
0 8 22560
0 16 22592
8 0 22536
8 8 22568
8 16 22600
16 0 22544
16 8 22576
16 16 22608
24 0 22552
24 8 22584
24 16 22616
32 0 22560
32 8 22592
32 16 22624
CalculateAttributeBuffer 43106 LD A,L Store the X position in A for now.
43107 LD L,H Move the Y position into L.
43108 LD H,3 Set the high byte of HL to 3.
43110 ADD HL,HL Multiply HL by 4.
43111 ADD HL,HL
Small correction.
43112 DEC H Decrease H by one.
43113 ADD HL,HL Multiply HL by 8.
43114 ADD HL,HL
43115 ADD HL,HL
43116 ADD A,L Add the original X position for the low byte of the attribute buffer memory location.
43117 LD L,A
43118 RET Return.
Prev: 43089 Up: Map Next: 43119