Prev: 40820 Up: Map Next: 41956
41884: 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 41884 EX DE,HL Copy the pixel coordinate to DE.
41885 LD A,D Fetch the Y coordinate.
41886 AND %00000111 Keep only bits 0-2.
41888 LD (41966),A Write the Y offset to *Pixel_Y_Offset.
41891 CPL Invert the Y offset.
41892 AND %00000111 Keep only bits 0-2.
41894 INC A Increment the row count by one.
41895 PUSH AF Stash the row count on the stack.
41896 LD B,E Store the X coordinate in B.
41897 LD A,E Fetch the X coordinate.
41898 RRA Rotate the X coordinate right by three.
41899 RRA
41900 RRA
41901 AND %00011111 Keep only bits 0-4.
41903 LD C,A Store the column in C.
41904 SET 7,D Set bit 7 of the Y coordinate.
41906 LD A,7 A=7.
41908 LD H,D Copy the Y coordinate to H.
41909 SCF Build the high byte of the screen address.
41910 RR H
41912 RRA
41913 RR H
41915 RRA
41916 RR H
41918 RRA
41919 OR C Merge in the column.
41920 LD L,A Store the low byte of the screen address.
41921 LD A,D Fetch the Y coordinate.
41922 ADD A,A Double the Y coordinate.
41923 LD D,113 Set the attribute address high byte to 113.
41925 ADD A,A Double the Y coordinate.
41926 RL D Rotate the attribute address high byte left.
41928 AND %11100000 Keep only bits 5-7.
41930 OR C Merge in the column.
41931 LD E,A Store the low byte of the attribute address.
41932 LD (61145),DE Write the attribute address to *Attribute_Address.
41936 EX DE,HL Swap the attribute address with the screen address.
41937 LD A,B Fetch the X coordinate.
41938 AND %00000111 Keep only bits 0-2.
41940 LD (41964),A Write the X offset to *Pixel_X_Offset.
41943 LD HL,41956 Point HL at Pixel_Bit_Masks.
41946 ADD A,L Point HL at the bit mask for this column.
41947 LD L,A
41948 LD C,(HL) Fetch the pixel bit mask.
41949 LD HL,32 Set the attribute stride to 32 in HL.
41952 EX DE,HL Swap the attribute stride into DE.
41953 POP AF Restore the row count from the stack.
41954 LD B,A Store the row count in B.
41955 RET Return.
Prev: 40820 Up: Map Next: 41956