Prev: 28878 Up: Map Next: 28929
28882: Prepare Actor Sprite
Used by the routines at DisplayEntity and DrawEntity.
Prepares to draw the sprite of an actor at its new position. Points DE to the sprite data and HL to the screen address, stores the pixel shift in NewSpriteShift, the width in bytes in WidthBytes and the number of lines to draw in HeightLines and HeightPixels.
Input
IX Actor entity
Output
DE Sprite data (after the height)
HL Screen address of the bottom left of the sprite
C 0
PrepareActorSprite 28882 CALL FetchActorSprite Call FetchActorSprite to fetch the sprite.
PrepareActorSprite_Position 28885 LD L,(IX+1) L=X position of the actor.
28888 LD H,(IX+2) H=Y position of the actor.
This entry point is used by the routines at DisplayCupsCollected and DisplayPlayerLives.
PrepareActorSprite_Shift 28891 LD A,L A=L.
28892 NEG Make A negative.
28894 AND %00000111 Keep only bits 0-2.
28896 LD (24129),A Write the pixel shift to NewSpriteShift.
28899 LD A,2 Set the width of the sprite in bytes, 2.
28901 JR Z,PrepareActorSprite_Width Jump to PrepareActorSprite_Width if the sprite is not shifted.
28903 INC A Increment A by one (a shifted sprite is one byte wider).
PrepareActorSprite_Width 28904 LD (24100),A Write the width to WidthBytes.
28907 LD (24103),HL Write the position to ActorScreenPosition.
28910 CALL GetVisibleHeight Work out how many lines can be drawn using GetVisibleHeight.
28913 CALL ScreenAddress Convert the position into a screen address using ScreenAddress.
28916 LD A,(DE) Fetch the height of the sprite.
28917 CP C Jump to PrepareActorSprite_Rows if the height is no more than the number of lines that can be drawn.
28918 JR C,PrepareActorSprite_Rows
28920 LD A,C Use the number of lines that can be drawn, as the sprite is too tall.
PrepareActorSprite_Rows 28921 LD (24102),A Write the number of lines to HeightLines.
28924 LD (24099),A Write the number of lines to HeightPixels.
28927 JR NextSprite Jump to NextSprite.
View the equivalent code in;
Prev: 28878 Up: Map Next: 28929