Prev: 9F80 Up: Map Next: 9FCA
9F9F: Prepare Draw 2 Byte Sprite
Used by the routines at DrawEntity and DisplayEntity.
Does the same as PrepDraw23 for the sprite of the entity in IX (the new sprite). As well as the screen address, it records the width of the sprite in bytes in SpriteWidth, the number of rows to draw in New_Sprite_Row_Count and its height in SpriteHeight. The shifting routine at DrawActorSpriteRow_Aligned is set up for it.
Input
IX The entity
Output
C 00
DE The address of the first row of sprite data to draw
HL The screen address of the bottom row of the sprite
PrepDraw2 9F9F CALL FetchActorSprite Fetch the address of the sprite of the entity with FetchActorSprite.
PrepDraw2_NoFetch 9FA2 LD L,(IX+$03) L=the entity X position, and H=the entity Y position.
9FA5 LD H,(IX+$04)
9FA8 LD A,L Fetch the X position.
9FA9 DEC A Decrease A by one.
9FAA RLCA Multiply by 02.
9FAB AND %00001110 Keep only bits 1-3.
9FAD CP $0E Jump to PrepDraw2_Shift if this is not the maximum offset.
9FAF JR NZ,PrepDraw2_Shift
9FB1 LD A,$E8 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 9F2A.
PrepDraw2_Shift 9FB3 LD ($9F2A),A Write the offset to 9F2A.
A sprite which is aligned to a character cell is two bytes wide, otherwise it is three bytes wide.
9FB6 LD A,$02 A=02.
9FB8 JR Z,PrepDraw2_Width Jump to PrepDraw2_Width if the offset was the maximum offset.
9FBA INC A A=03.
PrepDraw2_Width 9FBB LD ($5E10),A Write the width to SpriteWidth.
9FBE CALL ScreenAddress Call ScreenAddress to get the screen address of the position.
9FC1 LD A,(DE) Fetch the number of rows in the sprite (the first byte of the sprite data).
9FC2 LD ($5E19),A Write the number of rows to New_Sprite_Row_Count.
9FC5 LD ($5E11),A Write the number of rows to SpriteHeight.
9FC8 JR PrepDraw23_Finish Jump to PrepDraw23_Finish to finish preparing the sprite.
View the equivalent code in;
Prev: 9F80 Up: Map Next: 9FCA