Prev: 9F74 Up: Map Next: A3E4
A39C: Screen Address
Used by the routines at Move_Slot_Table and Plot_Pixel.
Converts a pixel coordinate in HL into a screen address, an attribute address at Attribute_Address, and a bit mask in C.
Input
HL Pixel coordinate
Output
HL Screen address
C Pixel bit mask
Screen_Address A39C EX DE,HL Copy the pixel coordinate to DE.
A39D LD A,D Fetch the Y coordinate.
A39E AND %00000111 Keep only bits 0-2.
A3A0 LD ($A3EE),A Write the Y offset to *Pixel_Y_Offset.
A3A3 CPL Invert the Y offset.
A3A4 AND %00000111 Keep only bits 0-2.
A3A6 INC A Increment the row count by one.
A3A7 PUSH AF Stash the row count on the stack.
A3A8 LD B,E Store the X coordinate in B.
A3A9 LD A,E Fetch the X coordinate.
A3AA RRA Rotate the X coordinate right by three.
A3AB RRA
A3AC RRA
A3AD AND %00011111 Keep only bits 0-4.
A3AF LD C,A Store the column in C.
A3B0 SET 7,D Set bit 7 of the Y coordinate.
A3B2 LD A,$07 A=07.
A3B4 LD H,D Copy the Y coordinate to H.
A3B5 SCF Build the high byte of the screen address.
A3B6 RR H
A3B8 RRA
A3B9 RR H
A3BB RRA
A3BC RR H
A3BE RRA
A3BF OR C Merge in the column.
A3C0 LD L,A Store the low byte of the screen address.
A3C1 LD A,D Fetch the Y coordinate.
A3C2 ADD A,A Double the Y coordinate.
A3C3 LD D,$71 Set the attribute address high byte to 71.
A3C5 ADD A,A Double the Y coordinate.
A3C6 RL D Rotate the attribute address high byte left.
A3C8 AND %11100000 Keep only bits 5-7.
A3CA OR C Merge in the column.
A3CB LD E,A Store the low byte of the attribute address.
A3CC LD ($EED9),DE Write the attribute address to *Attribute_Address.
A3D0 EX DE,HL Swap the attribute address with the screen address.
A3D1 LD A,B Fetch the X coordinate.
A3D2 AND %00000111 Keep only bits 0-2.
A3D4 LD ($A3EC),A Write the X offset to *Pixel_X_Offset.
A3D7 LD HL,$A3E4 Point HL at Pixel_Bit_Masks.
A3DA ADD A,L Point HL at the bit mask for this column.
A3DB LD L,A
A3DC LD C,(HL) Fetch the pixel bit mask.
A3DD LD HL,$0020 Set the attribute stride to 20 in HL.
A3E0 EX DE,HL Swap the attribute stride into DE.
A3E1 POP AF Restore the row count from the stack.
A3E2 LD B,A Store the row count in B.
A3E3 RET Return.
Prev: 9F74 Up: Map Next: A3E4