Prev: 867F Up: Map Next: 8701
86A1: Position Sprite
Convert the actor's world position into a screen column relative to Jetman_Position, then fetch its sprite.
Input
IX Actor slot
Convert the actor world X into a screen column.
PositionSprite 86A1 LD L,(IX+$02) Fetch the actor's world X position.
86A4 LD H,(IX+$03)
86A7 LD BC,$0078 Add the 0078 draw offset.
86AA ADD HL,BC
86AB LD BC,($607A) Fetch the scroll position from Jetman_Position.
86AF AND A Subtract the scroll position.
86B0 SBC HL,BC
86B2 LD A,H Fetch the high byte of the screen column.
86B3 AND %00011111 Keep only bits 0-4.
86B5 JR NZ,ResetSpriteFields Jump to ResetSpriteFields if the actor is off-screen.
86B7 LD A,L Jump to ResetSpriteFields if the column is at least F0.
86B8 CP $F0
86BA JR NC,ResetSpriteFields
Store the column and look up the actor sprite.
86BC LD (IX+$01),L Store the screen column in *IX+01.
86BF CALL FetchActorSprite Call FetchActorSprite.
Build the pixel-shift index from the column.
PositionSprite_Apply 86C2 LD L,(IX+$01) Fetch the screen column and actor Y.
86C5 LD H,(IX+$04)
86C8 LD A,L Build a pixel-shift index from the column.
86C9 DEC A
86CA RLCA
86CB AND %00001110 Keep only bits 1-3.
86CD CP $0E Jump to PositionSprite_StoreShift if the shift is not 0E.
86CF JR NZ,PositionSprite_StoreShift
86D1 LD A,$E8 Set the shift operand to E8.
Store the pixel shift for the sprite drawing code.
PositionSprite_StoreShift 86D3 LD ($861D),A Write the shift to 861D and *IX+09.
86D6 LD (IX+$09),A
Choose the scratch width from the shift.
86D9 LD A,$02 Set the scratch width to 02.
86DB JR Z,PositionSprite_StoreWidth Jump to PositionSprite_StoreWidth if the shift was 0E.
86DD INC A Widen the scratch width to 03.
PositionSprite_StoreWidth 86DE LD ($5E57),A Write the scratch width and cache the actor Y.
86E1 LD (IX+$0B),H
Work out the screen address, then cache the sprite details on the actor.
86E4 CALL ScreenAddress Call ScreenAddress.
86E7 LD A,(DE) Copy the sprite height into SpriteRowsLeft, SpriteHeight and *IX+0A.
86E8 INC DE
86E9 LD ($5E59),A
86EC LD ($5E58),A
86EF LD (IX+$0A),A
86F2 LD (IX+$0C),E Cache the graphic pointer and screen address on the actor.
86F5 LD (IX+$0D),D
86F8 LD (IX+$0E),L
86FB LD (IX+$0F),H
86FE LD C,$00 Clear the row counter.
8700 RET Return.
Prev: 867F Up: Map Next: 8701