Prev: BCF4 Up: Map Next: BD19
BCF7: Apply Sprite Attributes (2-Wide)
Used by the routine at Draw_Sprites.
Applies colour attributes to a smaller (2-wide) sprite's screen position. Works the same as ApplySpriteAttributes3Wide but for sprites that are only 2 character cells wide.
Input
HL Screen buffer address of the sprite
IX Pointer to the sprite state data
ApplySpriteAttributes2Wide BCF7 LD C,$58 Set the attribute base to 58 (i.e. the attribute buffer at 5800).
BCF9 LD D,$00 D=00.
Check if the sprite's X position is on a character boundary.
BCFB LD A,(IX+$00) Load A with the sprite X position from *IX+00.
BCFE AND %00000111 Keep only bits 0-2 (sub-character X offset).
BD00 JR Z,ApplySpriteAttributes2Wide_SpriteColour Jump to ApplySpriteAttributes2Wide_SpriteColour if X-aligned.
BD02 SET 0,D Set bit 0 of D (not X-aligned, need extra column).
First pass: write the sprite's own colour attribute. Skip if the attribute byte is FF (transparent).
ApplySpriteAttributes2Wide_SpriteColour BD04 LD E,(IX+$02) Load E with the sprite colour attribute from *IX+02.
BD07 LD A,E Jump to ApplySpriteAttributes2Wide_Background if the attribute byte is transparent (FF).
BD08 CP $FF
BD0A JR Z,ApplySpriteAttributes2Wide_Background
BD0C PUSH HL Stash the screen buffer address on the stack.
BD0D CALL WriteAttributeBlock2Wide Call WriteAttributeBlock2Wide to write the sprite attribute.
BD10 POP HL Restore the screen buffer address from the stack.
Second pass: write the background attribute (02 RED ink) over the sprite area using the room attribute base (F8 maps to RoomAttributeBuffer).
ApplySpriteAttributes2Wide_Background BD11 LD C,$F8 C=F8.
BD13 LD E,$02 E=RED.
BD15 CALL WriteAttributeBlock2Wide Call WriteAttributeBlock2Wide to write the background attribute.
BD18 RET Return.
Prev: BCF4 Up: Map Next: BD19