Prev: 8AE8 Up: Map Next: 8B52
8AF7: Position Mask Sprite
Convert the actor's world position into a screen column. If it is on screen, work out the pixel shift, the screen address and the sprite size, and cache them on the actor.
Input
IX Actor slot
PositionMaskSprite 8AF7 LD L,(IX+$02) Fetch the actor's world X position.
8AFA LD H,(IX+$03)
8AFD LD BC,($607A) Subtract the scroll position at Jetman_Position.
8B01 AND A
8B02 SBC HL,BC
8B04 LD BC,$0078 Add the 0078 draw offset.
8B07 ADD HL,BC
8B08 LD A,H Fetch the high byte of the screen column.
8B09 AND %00011111 Keep only bits 0-4.
8B0B JP NZ,ResetSpriteFields Jump to ResetSpriteFields if the actor is off-screen.
8B0E LD (IX+$01),L Store the screen column in *IX+01.
Look up the sprite graphic and work out the pixel shift from the screen column.
8B11 CALL FetchActorSprite Call FetchActorSprite.
8B14 LD L,(IX+$01) Fetch the screen column and actor Y.
8B17 LD H,(IX+$04)
8B1A LD A,L Build a pixel-shift index from the column.
8B1B DEC A
8B1C AND %00000111 Keep only bits 0-2.
8B1E CP $07 Jump to PositionMaskSprite_StoreShift if the shift is not 07.
8B20 JR NZ,PositionMaskSprite_StoreShift
8B22 LD A,$F2 Set the shift operand to F2.
PositionMaskSprite_StoreShift 8B24 LD ($8AD1),A Write the shift to 8AD1 and *IX+09.
8B27 LD (IX+$09),A
Choose the scratch width for the shift.
8B2A LD A,$01 Set the scratch width to 01.
8B2C JR Z,PositionMaskSprite_StoreWidth Jump to PositionMaskSprite_StoreWidth if the shift was 07.
8B2E INC A Widen the scratch width to 02.
PositionMaskSprite_StoreWidth 8B2F LD ($5E57),A Write the scratch width and cache the actor Y.
8B32 LD (IX+$0B),H
Work out the screen address, then cache the sprite size and pointers on the actor.
8B35 CALL ScreenAddress Call ScreenAddress.
8B38 LD A,(DE) Copy the sprite height into SpriteRowsLeft, SpriteHeight and *IX+0A.
8B39 INC DE
8B3A LD ($5E59),A
8B3D LD ($5E58),A
8B40 LD (IX+$0A),A
8B43 LD (IX+$0C),E Cache the graphic pointer and screen address on the actor.
8B46 LD (IX+$0D),D
8B49 LD (IX+$0E),L
8B4C LD (IX+$0F),H
8B4F LD C,$00 Clear the row counter.
8B51 RET Return.
Prev: 8AE8 Up: Map Next: 8B52