Prev: 30026 Up: Map Next: 30084
30039: 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 0
DE Address of the first row of sprite data to draw
HL Screen address of the bottom row of the sprite
PrepareOldSprite 30039 CALL FetchSprite Fetch the address of the recorded sprite using FetchSprite.
PrepareOldSprite_Position 30042 LD HL,(24340) Fetch the recorded position (OldSprite_X).
30045 LD A,L Fetch the horizontal co-ordinate.
30046 DEC A Decrease A by one.
30047 RLCA Multiply by 2.
30048 AND %00001110 Keep only bits 1-3.
30050 CP 14 Jump to PrepareOldSprite_Shift if this is not the maximum offset.
30052 JR NZ,PrepareOldSprite_Shift
30054 LD A,241 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 30330.
PrepareOldSprite_Shift 30056 LD (30331),A Write the offset to 30331.
30059 CALL ClipSprite Clip the sprite using ClipSprite.
30062 CALL ScreenAddress Convert the position into a screen address using ScreenAddress.
30065 LD A,(DE) Fetch the height of the sprite.
30066 SUB C Subtract the number of rows which are not visible.
30067 JR NC,PrepareOldSprite_Rows Jump to PrepareOldSprite_Rows if there are any rows to draw.
30069 XOR A There are no rows to draw.
PrepareOldSprite_Rows 30070 LD (24345),A Set the number of rows of the old sprite to draw (OldSprite_RowsRemaining).
30073 SLA C Multiply the number of hidden rows by 2 (as there are two bytes in each row).
30075 LD B,0 B=0.
30077 EX DE,HL Skip the hidden rows in the sprite data.
30078 ADD HL,BC
30079 EX DE,HL
This entry point is used by the routine at PrepareActorSprite.
PrepareSprite_Finish 30080 LD C,0 C=0.
30082 INC DE Move past the height byte.
30083 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 8 pixels.
Prev: 30026 Up: Map Next: 30084