![]() |
Routines |
| Prev: 30039 | Up: Map | Next: 30144 |
|
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.
|
||||||||||||||||
| PrepareActorSprite | 30084 | CALL FetchActorSprite | Fetch the address of the actor sprite using FetchActorSprite. | |||||||||||||
| PrepareActorSprite_Position | 30087 | LD L,(IX+1) | Fetch the horizontal co-ordinate of the actor. | |||||||||||||
| 30090 | LD H,(IX+2) | Fetch the vertical co-ordinate of the actor. | ||||||||||||||
| 30093 | LD A,L | Fetch the horizontal co-ordinate. | ||||||||||||||
| 30094 | DEC A | Decrease A by one. | ||||||||||||||
| 30095 | RLCA | Multiply by 2. | ||||||||||||||
| 30096 | AND %00001110 | Keep only bits 1-3. | ||||||||||||||
| 30098 | CP 14 | Jump to PrepareActorSprite_Shift if this is not the maximum offset. | ||||||||||||||
| 30100 | JR NZ,PrepareActorSprite_Shift | |||||||||||||||
| 30102 | 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 30392.
|
||||||||||||||||
| PrepareActorSprite_Shift | 30104 | LD (30393),A | Write the offset to the JR command at 30393. | |||||||||||||
|
A sprite which is aligned to a character cell is two cells wide, otherwise it is three cells wide.
|
||||||||||||||||
| 30107 | LD A,2 | Set the width to 2. | ||||||||||||||
| 30109 | JR Z,PrepareActorSprite_Width | Jump to PrepareActorSprite_Width if the sprite is aligned to a character cell. | ||||||||||||||
| 30111 | INC A | Set the width to 3. | ||||||||||||||
| PrepareActorSprite_Width | 30112 | LD (24344),A | Write the width to the actor sprite width (ActorSprite_Width). | |||||||||||||
| 30115 | CALL ClipSprite | Clip the sprite using ClipSprite. | ||||||||||||||
| 30118 | LD (24351),HL | Save the position of the actor sprite (ActorSprite_Position). | ||||||||||||||
| 30121 | CALL ScreenAddress | Convert the position into a screen address using ScreenAddress. | ||||||||||||||
| 30124 | LD A,(DE) | Fetch the height of the sprite. | ||||||||||||||
| 30125 | SUB C | Subtract the number of rows which are not visible. | ||||||||||||||
| 30126 | JR NC,PrepareActorSprite_Rows | Jump to PrepareActorSprite_Rows if there are any rows to draw. | ||||||||||||||
| 30128 | XOR A | There are no rows to draw. | ||||||||||||||
| PrepareActorSprite_Rows | 30129 | LD (24346),A | Set the number of rows of the actor sprite to draw (ActorSprite_RowsRemaining). | |||||||||||||
| 30132 | LD (24343),A | Set the number of rows of the actor sprite on the screen (ActorSprite_Rows). | ||||||||||||||
| 30135 | LD B,0 | Set the high byte of the offset to 0. | ||||||||||||||
| 30137 | SLA C | Multiply the number of hidden rows by 2. | ||||||||||||||
| 30139 | EX DE,HL | Skip the hidden rows in the sprite data. | ||||||||||||||
| 30140 | ADD HL,BC | |||||||||||||||
| 30141 | EX DE,HL | |||||||||||||||
| 30142 | JR PrepareSprite_Finish | Jump to PrepareSprite_Finish to finish. | ||||||||||||||
|
View the equivalent code in;
|
||||||||||||||||
| Prev: 30039 | Up: Map | Next: 30144 |