Prev: BC37 Up: Map Next: BC74
BC52: Apply Sprite Attributes (3-Wide)
Used by the routine at Draw_Sprites.
Applies colour attributes to a sprite's screen position. First writes the sprite's own colour attribute, then writes the background colour (02 RED ink) on top. The sprite occupies a 3x2 or 3x3 character cell area depending on alignment.
Input
HL Screen buffer address of the sprite
IX Pointer to the sprite state data
ApplySpriteAttributes3Wide BC52 LD C,$58 Set the attribute base to 58 (i.e. the attribute buffer at 5800).
BC54 LD D,$00 D=00.
Check if the sprite's X position is on a character boundary. If not, set bit 0 of D to indicate an extra column is needed.
BC56 LD A,(IX+$00) Load A with the sprite X position from *IX+00.
BC59 AND %00000111 Keep only bits 0-2 (sub-character X offset).
BC5B JR Z,ApplySpriteAttributes3Wide_SpriteColour Jump to ApplySpriteAttributes3Wide_SpriteColour if X-aligned.
BC5D SET 0,D Set bit 0 of D (not X-aligned, need extra column).
First pass: write the sprite's own colour attribute to the attribute file. Skip if the attribute is FF (transparent).
ApplySpriteAttributes3Wide_SpriteColour BC5F LD E,(IX+$02) Load E with the sprite colour attribute from *IX+02.
BC62 LD A,E Jump to ApplySpriteAttributes3Wide_Background if the attribute byte is transparent (FF).
BC63 CP $FF
BC65 JR Z,ApplySpriteAttributes3Wide_Background
BC67 PUSH HL Stash the screen buffer address on the stack.
BC68 CALL WriteAttributeBlock3Wide Call WriteAttributeBlock3Wide to write the sprite attribute.
BC6B 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).
ApplySpriteAttributes3Wide_Background BC6C LD C,$F8 C=F8.
BC6E LD E,$02 E=RED.
BC70 CALL WriteAttributeBlock3Wide Call WriteAttributeBlock3Wide to write the background attribute.
BC73 RET Return.
Prev: BC37 Up: Map Next: BC74