Prev: 34823 Up: Map Next: 34961
34854: Fetch And Draw
Look up the actor sprite, clip it against the left and right screen edges, and cache its graphic pointer and screen address on the actor.
Input
IX Actor slot
Look up the actor sprite and test whether it is on-screen.
FetchAndDraw 34854 CALL FetchActorSprite Call FetchActorSprite.
34857 LD L,(IX+2) Fetch the actor's world X position.
34860 LD H,(IX+3)
34863 LD BC,(24698) Subtract the scroll position at Jetman_Position.
34867 AND A
34868 SBC HL,BC
34870 LD BC,104 Add the 0104 draw offset.
34873 ADD HL,BC
34874 LD A,H Fetch the high byte of the screen column.
34875 AND %00011111 Keep only bits 0-4.
34877 JR Z,ReadSpriteHeader Jump to ReadSpriteHeader if the actor is on-screen.
34879 ADD A,225 Jump to ClearSpriteCache if the column is not 31.
34881 JR NZ,ClearSpriteCache
Clip a sprite that straddles the left edge.
34883 LD A,L Arithmetic-shift the column down by three.
34884 SRA A
34886 SRA A
34888 SRA A
34890 JP P,ClearSpriteCache Jump to ClearSpriteCache if the result is positive.
34893 LD B,A Store the shifted column.
34894 AND %00001111 Keep only bits 0-3.
34896 LD (34798),A Write the skip to 34798 and *IX+9.
34899 LD (IX+9),A
Work out how much of the sprite width is visible and cache the visible width and height.
34902 LD A,(DE) Fetch the sprite width and add the shifted column.
34903 INC DE
34904 LD C,A
34905 ADD A,B
34906 JP M,ClearSpriteCache Jump to ClearSpriteCache if that sum is zero or negative.
34909 JR Z,ClearSpriteCache
34911 LD B,A Copy the visible width into B.
34912 LD (24151),A Write the visible width to SpriteWidth and *IX+11.
34915 LD (IX+11),A
34918 LD A,(DE) Copy the next header byte into SpriteRowsLeft, SpriteHeight and *IX+10.
34919 INC DE
34920 LD (24153),A
34923 LD (24152),A
34926 LD (IX+10),A
Skip the graphic bytes hidden off the left edge.
34929 LD A,C A=width-visible width (the bytes hidden on the left).
34930 SUB B
FetchAndDraw_Loop 34931 INC DE Skip graphic bytes until the visible strip starts.
34932 DEC A
34933 JR NZ,FetchAndDraw_Loop
34935 LD L,0 Set the screen column to 0.
Cache the visible strip and draw it.
FetchAndDraw_StoreColumn 34937 LD (IX+1),L Store the screen column.
34940 LD H,(IX+4) Fetch the actor Y.
34943 CALL ScreenAddress Call ScreenAddress.
34946 LD (IX+12),E Cache the graphic pointer and screen address on the actor.
34949 LD (IX+13),D
34952 LD (IX+14),L
34955 LD (IX+15),H
34958 LD C,0 Clear the row counter.
34960 RET Return.
Prev: 34823 Up: Map Next: 34961