Prev: BECA Up: Map Next: BF25
BEE0: 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 BEE0 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.
BEE1 AND $07
BEE3 OR A
BEE4 JR Z,$BEE8
BEE6 SET 1,D
Convert the screen buffer address to the attribute buffer address.
Unused_Convert_To_Attribute BEE8 LD A,H Rotate H right three times, mask with 03 and OR with C to form the attribute buffer high byte.
BEE9 RRCA
BEEA RRCA
BEEB RRCA
BEEC AND $03
BEEE OR C
BEEF LD H,A
BEF0 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.
BEF2 DEFB $28,$1F
BEF4 LD A,(HL) Read *HL, mask off the existing INK with F8 OR in E and write back.
BEF5 AND $F8
BEF7 OR E
BEF8 LD (HL),A
BEF9 INC L Advance to the next column, read, mask, OR and write back.
BEFA LD A,(HL)
BEFB AND $F8
BEFD OR E
BEFE LD (HL),A
BEFF DEC L Move back to the first column.
BF00 BIT 1,D Return if bit 1 of D is clear (no row straddling).
BF02 RET Z
Sprite straddles two character rows: write the INK colour to the next row as well.
BF03 LD BC,$0020 Add 0020 to HL to advance to the next attribute row.
BF06 ADD HL,BC
BF07 LD A,(HL) Read, mask with F8 OR in E and write back.
BF08 AND $F8
BF0A OR E
BF0B LD (HL),A
BF0C INC L Advance to the next column, read, mask, OR and write back.
BF0D LD A,(HL)
BF0E AND $F8
BF10 OR E
BF11 LD (HL),A
BF12 RET Return.
One column wide: write the INK colour to a single attribute cell.
Unused_Write_1Wide_Attribute BF13 LD A,(HL) Read *HL, mask with F8 OR in E and write back.
BF14 AND $F8
Unused_Write_1Wide_Attribute_Loop BF16 OR E
BF17 LD (HL),A
BF18 BIT 1,D Return if bit 1 of D is clear (no row straddling).
BF1A RET Z
BF1B LD BC,$0020 Add 0020 to HL to advance to the next attribute row.
BF1E ADD HL,BC
BF1F LD A,(HL) Read, mask with F8 OR in E and write back.
BF20 AND $F8
BF22 OR E
BF23 LD (HL),A
BF24 RET Return.
Prev: BECA Up: Map Next: BF25