Prev: 748F Up: Map Next: 751C
74A5: Set Up Previous Sprite
Used by the routine at DrawSprite.
Sprites are drawn by erasing the previous image and drawing the new one at the same time, a row at a time. The routines from here to DisplayEntity_Compare prepare the two images: the main registers hold one sprite and the shadow registers hold the other. Each is set up with the screen address in HL, the sprite width in B, a row count of zero in C and the sprite data pointer in DE.
This entry point finds the previous sprite from the temporary actor state at Actor, using PrepareOldSprite to get its graphic.
SetUpPreviousSprite 74A5 CALL PrepareOldSprite Call PrepareOldSprite.
This entry point is used by the routines at UpdateBloomingFlower, UpdateStreamer, UpdateLeaf and DrawSprite.
Sets up the previous sprite using the sprite data address in DE, rather than looking it up.
SetUpPreviousSprite_Address 74A8 LD HL,($5E0B) Fetch the previous X and Y position from Actor.
This entry point is used by the routine at AnimateExplosion.
The first byte of the sprite is a horizontal offset in pixels.
SetUpPreviousSprite_Offset 74AB LD A,(DE) Fetch the horizontal offset.
74AC INC DE Move onto the sprite width.
74AD ADD A,L Add the horizontal offset to the X position.
74AE LD L,A Store the result back in L.
74AF CALL ScreenAddress Convert the position into a screen address using ScreenAddress.
74B2 LD A,(DE) Fetch the sprite width.
74B3 LD B,A Set the width counter in B to the sprite width.
74B4 INC DE Move onto the sprite height.
74B5 LD A,(DE) Fetch the sprite height.
74B6 LD ($5E10),A Store it in 5E10 as the height of the previous sprite.
SetUpSprite_Finish 74B9 LD C,$00 Set the row count in C to 00 (no rows have been drawn yet).
74BB INC DE Move onto the first byte of the sprite graphic data.
74BC RET Return.
This entry point is used by the routine at DrawSprite.
Sets up the sprite of the actor in IX, using ActorMoveSprite to get its graphic.
SetUpSprite 74BD CALL ActorMoveSprite Call ActorMoveSprite.
This entry point is used by the routines at UpdateBloomingFlower, UpdateStreamer, UpdateLeaf and DrawSprite.
Sets up the sprite using the sprite data address in DE, at the position held in the actor object.
SetUpSprite_Address 74C0 LD L,(IX+$01) Fetch the X and Y position from *IX+01 and *IX+02.
74C3 LD H,(IX+$02)
This entry point is used by the routine at DrawCubbyHoleItem.
SetUpSprite_Offset 74C6 LD A,(DE) Fetch the horizontal offset.
74C7 INC DE Move onto the sprite width.
74C8 ADD A,L Add the horizontal offset to the X position.
74C9 LD L,A Store the result back in L.
74CA LD ($5E1A),HL Store the screen position in SpritePosition.
74CD CALL ScreenAddress Convert the position into a screen address using ScreenAddress.
74D0 LD A,(DE) Fetch the sprite width.
74D1 LD B,A Set the width counter in B to the sprite width.
74D2 LD ($5E0F),A Store it in NewSprite_Width.
74D5 INC DE Move onto the sprite height.
74D6 LD A,(DE) Fetch the sprite height.
74D7 LD ($5E11),A Store it in 5E11 as the height of the new sprite.
74DA LD ($5E0E),A Store it in 5E0E.
74DD JR SetUpSprite_Finish Jump to SetUpSprite_Finish.
This entry point is used by the routine at UpdateFlower.
Moves a sprite using the same sprite data in DE for both the previous image (erased) and the new image (drawn).
ReplaceSprite 74DF PUSH DE Stash the sprite data pointer on the stack.
74E0 CALL SetUpPreviousSprite_Address Set up the previous sprite using SetUpPreviousSprite_Address.
74E3 EXX Switch to the shadow registers.
74E4 POP DE Restore the sprite data pointer from the stack.
74E5 CALL SetUpSprite_Address Set up the new sprite using SetUpSprite_Address.
74E8 EXX Switch to the shadow registers.
74E9 JR DisplayEntity_Compare Jump to DisplayEntity_Compare.
This entry point is used by the routines at UpdateSprayCan, DrawObject and UpdateBonusItem.
Display Entity. Erases the previous sprite of the actor in IX and draws the new one.
Before After DisplayEntity After ColouriseSprite
move-sprite-before move-sprite-drawn move-sprite-coloured
DisplayEntity 74EB CALL SetUpSprite Set up the new sprite using SetUpSprite.
74EE EXX Switch to the shadow registers.
74EF CALL SetUpPreviousSprite Set up the previous sprite using SetUpPreviousSprite.
This entry point is used by the routines at UpdateBloomingFlower, UpdateStreamer and UpdateLeaf.
Work out how many rows of one sprite lie beyond the other.
DisplayEntity_Compare 74F2 LD A,($5E0C) Fetch the previous Y position from 5E0C.
74F5 SUB (IX+$02) Subtract the new Y position.
74F8 JP Z,MaskSprite_Finish_Previous Jump to MaskSprite_Finish_Previous if the two sprites start on the same row.
74FB JP M,DisplayEntity_NewLower Jump to DisplayEntity_NewLower if the new sprite starts lower down the screen.
74FE LD C,A Store the number of extra rows in C.
74FF LD A,($5E10) Fetch the height of the previous sprite from 5E10.
7502 CP C Compare it with the number of extra rows.
7503 JP C,MaskSprite_Finish_Previous Jump to MaskSprite_Finish_Previous if the sprites do not overlap.
7506 SUB C Subtract the extra rows from the height of the previous sprite.
7507 LD ($5E10),A Write it back to 5E10.
750A JP MaskSprite Jump to MaskSprite to erase the extra rows of the previous sprite first.
The new sprite starts lower down the screen, so its extra rows are drawn first.
DisplayEntity_NewLower 750D EXX Switch to the shadow registers.
750E NEG Make the number of extra rows positive.
7510 LD C,A Store the number of extra rows in C.
7511 LD A,($5E11) Fetch the height of the new sprite from 5E11.
7514 CP C Compare it with the number of extra rows.
7515 JP C,MaskSprite_Finish Jump to MaskSprite_Finish if the sprites do not overlap.
7518 SUB C Subtract the extra rows from the height of the new sprite.
7519 JP MaskSprite_Finish_ClearNew Jump to MaskSprite_Finish_ClearNew.
Prev: 748F Up: Map Next: 751C