Prev: 48842 Up: Map Next: 48933
48864: Unused: Write Sprite Attribute Cells
Unused routine to write INK colour to attribute cells for a sprite. Converts the screen buffer address to an attribute address, then writes the colour to one or two cells depending on the sprite width, handling character row boundaries if the sprite straddles two rows.
Input
C Attribute buffer base high byte
D Bit 0: width flag, Bit 1: set if straddling two character rows
E Attribute INK colour
HL Screen buffer address
Unused_Write_Attribute_Cells 48864 LD A,H Check if the sprite straddles two character rows by testing bits 0-2 of H; if non-zero, set bit 1 of D.
48865 AND 7
48867 OR A
48868 JR Z,48872
48870 SET 1,D
Convert the screen buffer address to the attribute buffer address.
Unused_Convert_To_Attribute 48872 LD A,H Rotate H right three times, mask with 3 and OR with C to form the attribute buffer high byte.
48873 RRCA
48874 RRCA
48875 RRCA
48876 AND 3
48878 OR C
48879 LD H,A
48880 BIT 0,D Jump to Unused_Write_1Wide_Attribute if bit 0 of D is clear (one column wide).
Two columns wide: write the INK colour to two adjacent attribute cells.
48882 DEFB 40,31
48884 LD A,(HL) Read *HL, mask off the existing INK with 248 OR in E and write back.
48885 AND 248
48887 OR E
48888 LD (HL),A
48889 INC L Advance to the next column, read, mask, OR and write back.
48890 LD A,(HL)
48891 AND 248
48893 OR E
48894 LD (HL),A
48895 DEC L Move back to the first column.
48896 BIT 1,D Return if bit 1 of D is clear (no row straddling).
48898 RET Z
Sprite straddles two character rows: write the INK colour to the next row as well.
48899 LD BC,32 Add 0032 to HL to advance to the next attribute row.
48902 ADD HL,BC
48903 LD A,(HL) Read, mask with 248 OR in E and write back.
48904 AND 248
48906 OR E
48907 LD (HL),A
48908 INC L Advance to the next column, read, mask, OR and write back.
48909 LD A,(HL)
48910 AND 248
48912 OR E
48913 LD (HL),A
48914 RET Return.
One column wide: write the INK colour to a single attribute cell.
Unused_Write_1Wide_Attribute 48915 LD A,(HL) Read *HL, mask with 248 OR in E and write back.
48916 AND 248
Unused_Write_1Wide_Attribute_Loop 48918 OR E
48919 LD (HL),A
48920 BIT 1,D Return if bit 1 of D is clear (no row straddling).
48922 RET Z
48923 LD BC,32 Add 0032 to HL to advance to the next attribute row.
48926 ADD HL,BC
48927 LD A,(HL) Read, mask with 248 OR in E and write back.
48928 AND 248
48930 OR E
48931 LD (HL),A
48932 RET Return.
Prev: 48842 Up: Map Next: 48933