Prev: 48372 Up: Map Next: 48409
48375: 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 48375 LD C,88 Set the attribute base to 88 (i.e. the attribute buffer at 22528).
48377 LD D,0 D=0.
Check if the sprite's X position is on a character boundary.
48379 LD A,(IX+0) Load A with the sprite X position from *IX+0.
48382 AND %00000111 Keep only bits 0-2 (sub-character X offset).
48384 JR Z,ApplySpriteAttributes2Wide_SpriteColour Jump to ApplySpriteAttributes2Wide_SpriteColour if X-aligned.
48386 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 255 (transparent).
ApplySpriteAttributes2Wide_SpriteColour 48388 LD E,(IX+2) Load E with the sprite colour attribute from *IX+2.
48391 LD A,E Jump to ApplySpriteAttributes2Wide_Background if the attribute byte is transparent (255).
48392 CP 255
48394 JR Z,ApplySpriteAttributes2Wide_Background
48396 PUSH HL Stash the screen buffer address on the stack.
48397 CALL WriteAttributeBlock2Wide Call WriteAttributeBlock2Wide to write the sprite attribute.
48400 POP HL Restore the screen buffer address from the stack.
Second pass: write the background attribute (2 RED ink) over the sprite area using the room attribute base (248 maps to RoomAttributeBuffer).
ApplySpriteAttributes2Wide_Background 48401 LD C,248 C=248.
48403 LD E,2 E=RED.
48405 CALL WriteAttributeBlock2Wide Call WriteAttributeBlock2Wide to write the background attribute.
48408 RET Return.
Prev: 48372 Up: Map Next: 48409