Prev: 754A Up: Map Next: 7584
7557: Prepare Old Sprite
Used by the routines at DisplayEntity and RemoveEntity.
Gets everything ready to draw (or erase) the sprite at the position which was last recorded by StoreEntity. Sprites are drawn using the exclusive OR operation, so drawing a sprite for a second time erases it.
Output
C 00
DE Address of the first row of sprite data to draw
HL Screen address of the bottom row of the sprite
PrepareOldSprite 7557 CALL FetchSprite Fetch the address of the recorded sprite using FetchSprite.
PrepareOldSprite_Position 755A LD HL,($5F14) Fetch the recorded position (OldSprite_X).
755D LD A,L Fetch the horizontal co-ordinate.
755E DEC A Decrease A by one.
755F RLCA Multiply by 02.
7560 AND %00001110 Keep only bits 1-3.
7562 CP $0E Jump to PrepareOldSprite_Shift if this is not the maximum offset.
7564 JR NZ,PrepareOldSprite_Shift
7566 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 767A.
PrepareOldSprite_Shift 7568 LD ($767B),A Write the offset to 767B.
756B CALL ClipSprite Clip the sprite using ClipSprite.
756E CALL ScreenAddress Convert the position into a screen address using ScreenAddress.
7571 LD A,(DE) Fetch the height of the sprite.
7572 SUB C Subtract the number of rows which are not visible.
7573 JR NC,PrepareOldSprite_Rows Jump to PrepareOldSprite_Rows if there are any rows to draw.
7575 XOR A There are no rows to draw.
PrepareOldSprite_Rows 7576 LD ($5F19),A Set the number of rows of the old sprite to draw (OldSprite_RowsRemaining).
7579 SLA C Multiply the number of hidden rows by 02 (as there are two bytes in each row).
757B LD B,$00 B=00.
757D EX DE,HL Skip the hidden rows in the sprite data.
757E ADD HL,BC
757F EX DE,HL
This entry point is used by the routine at PrepareActorSprite.
PrepareSprite_Finish 7580 LD C,$00 C=00.
7582 INC DE Move past the height byte.
7583 RET Return.
View the equivalent code in;
The number of rows which can be drawn is written to OldSprite_RowsRemaining. The shifting routine at DrawOldSpriteRow is set up to move the sprite right by the horizontal co-ordinate MOD 08 pixels.
Prev: 754A Up: Map Next: 7584