Prev: A851 Up: Map Next: A86F
A862: 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
00 00 5800
00 08 5820
00 10 5840
08 00 5808
08 08 5828
08 10 5848
10 00 5810
10 08 5830
10 10 5850
18 00 5818
18 08 5838
18 10 5858
20 00 5820
20 08 5840
20 10 5860
CalculateAttributeBuffer A862 LD A,L Store the X position in A for now.
A863 LD L,H Move the Y position into L.
A864 LD H,$03 Set the high byte of HL to 03.
A866 ADD HL,HL Multiply HL by 04.
A867 ADD HL,HL
Small correction.
A868 DEC H Decrease H by one.
A869 ADD HL,HL Multiply HL by 08.
A86A ADD HL,HL
A86B ADD HL,HL
A86C ADD A,L Add the original X position for the low byte of the attribute buffer memory location.
A86D LD L,A
A86E RET Return.
Prev: A851 Up: Map Next: A86F