Prev: 7557 Up: Map Next: 75C0
7584: Prepare Actor Sprite
Used by the routines at DisplayEntity and DrawEntity.
Does the same as PrepareOldSprite for the sprite of the actor in IX. As well as the screen address, it records the address of the first attribute cell in ActorSprite_Position, the width in character cells in ActorSprite_Width and the number of rows to draw in ActorSprite_RowsRemaining and ActorSprite_Rows. This is set up for the shifting routine at DrawActorSpriteRow.
Input
IX Actor
Output
C 00
DE Address of the first row of sprite data to draw
HL Screen address of the bottom row of the sprite
PrepareActorSprite 7584 CALL FetchActorSprite Fetch the address of the actor sprite using FetchActorSprite.
PrepareActorSprite_Position 7587 LD L,(IX+$01) Fetch the horizontal co-ordinate of the actor.
758A LD H,(IX+$02) Fetch the vertical co-ordinate of the actor.
758D LD A,L Fetch the horizontal co-ordinate.
758E DEC A Decrease A by one.
758F RLCA Multiply by 02.
7590 AND %00001110 Keep only bits 1-3.
7592 CP $0E Jump to PrepareActorSprite_Shift if this is not the maximum offset.
7594 JR NZ,PrepareActorSprite_Shift
7596 LD A,$F1 Use the offset which jumps to the code for sprites which are aligned to a character cell.
Self modifying code; this updates the operand of the JR command at 76B8.
PrepareActorSprite_Shift 7598 LD ($76B9),A Write the offset to the JR command at 76B9.
A sprite which is aligned to a character cell is two cells wide, otherwise it is three cells wide.
759B LD A,$02 Set the width to 02.
759D JR Z,PrepareActorSprite_Width Jump to PrepareActorSprite_Width if the sprite is aligned to a character cell.
759F INC A Set the width to 03.
PrepareActorSprite_Width 75A0 LD ($5F18),A Write the width to the actor sprite width (ActorSprite_Width).
75A3 CALL ClipSprite Clip the sprite using ClipSprite.
75A6 LD ($5F1F),HL Save the position of the actor sprite (ActorSprite_Position).
75A9 CALL ScreenAddress Convert the position into a screen address using ScreenAddress.
75AC LD A,(DE) Fetch the height of the sprite.
75AD SUB C Subtract the number of rows which are not visible.
75AE JR NC,PrepareActorSprite_Rows Jump to PrepareActorSprite_Rows if there are any rows to draw.
75B0 XOR A There are no rows to draw.
PrepareActorSprite_Rows 75B1 LD ($5F1A),A Set the number of rows of the actor sprite to draw (ActorSprite_RowsRemaining).
75B4 LD ($5F17),A Set the number of rows of the actor sprite on the screen (ActorSprite_Rows).
75B7 LD B,$00 Set the high byte of the offset to 00.
75B9 SLA C Multiply the number of hidden rows by 02.
75BB EX DE,HL Skip the hidden rows in the sprite data.
75BC ADD HL,BC
75BD EX DE,HL
75BE JR PrepareSprite_Finish Jump to PrepareSprite_Finish to finish.
View the equivalent code in;
Prev: 7557 Up: Map Next: 75C0