![]() |
Routines |
| Prev: 56100 | Up: Map | Next: 56265 |
|
Used by the routines at Handler_Player and Handler_Actors.
Reverses the actor at a destination. On a player hit, copies the actor deltas onto Player.
|
||||||||
|
Reverse at the destination when cell-aligned.
|
||||||||
| Test_ActorCollision | 56127 | LD A,(IY+8) | Jump to Test_ActorCollision_Column if the horizontal delta is set. | |||||
| 56130 | OR A | |||||||
| 56131 | JR NZ,Test_ActorCollision_Column | |||||||
|
Test the destination row.
|
||||||||
| 56133 | LD A,7 | Jump to Test_ActorCollision_Bounds unless the fine-Y is 7. | ||||||
| 56135 | CP (IY+3) | |||||||
| 56138 | JR NZ,Test_ActorCollision_Bounds | |||||||
| 56140 | LD A,(IY+1) | Call Actor_Reverse if the row matches the destination. | ||||||
| 56143 | CP (IY+6) | |||||||
| 56146 | CALL Z,Actor_Reverse | |||||||
| 56149 | JR Test_ActorCollision_Bounds | Jump to Test_ActorCollision_Bounds. | ||||||
|
Test the destination column.
|
||||||||
| Test_ActorCollision_Column | 56151 | LD A,7 | Jump to Test_ActorCollision_Bounds unless the fine-X is 7. | |||||
| 56153 | CP (IY+2) | |||||||
| 56156 | JR NZ,Test_ActorCollision_Bounds | |||||||
| 56158 | LD A,(IY+0) | Call Actor_Reverse if the column matches the destination. | ||||||
| 56161 | CP (IY+5) | |||||||
| 56164 | CALL Z,Actor_Reverse | |||||||
|
Skip the hit test while jumping or falling.
|
||||||||
| Test_ActorCollision_Bounds | 56167 | LD A,(25616) | Return if *Player_JumpTimer is set. | |||||
| 56170 | OR A | |||||||
| 56171 | RET NZ | |||||||
|
Require a close vertical overlap.
|
||||||||
| 56172 | LD A,(IY+1) | Convert the actor row and fine-Y into a pixel row. | ||||||
| 56175 | ADD A,A | |||||||
| 56176 | ADD A,A | |||||||
| 56177 | ADD A,A | |||||||
| 56178 | ADD A,(IY+3) | |||||||
| 56181 | LD C,A | |||||||
|
Convert the player row the same way.
|
||||||||
| 56182 | LD A,(25767) | Convert the player row and fine-Y into a pixel row. | ||||||
| 56185 | LD B,A | |||||||
| 56186 | LD A,(25765) | |||||||
| 56189 | SUB 3 | |||||||
| 56191 | ADD A,A | |||||||
| 56192 | ADD A,A | |||||||
| 56193 | ADD A,A | |||||||
| 56194 | ADD A,B | |||||||
| 56195 | SUB C | Return unless the difference is less than 4. | ||||||
| 56196 | CP 4 | |||||||
| 56198 | RET NC | |||||||
|
Keep the gap and convert the actor column.
|
||||||||
| 56199 | LD D,A | Keep the vertical gap in D. | ||||||
| 56200 | LD A,(IY+0) | Convert the actor column and fine-X into a pixel column. | ||||||
| 56203 | DEC A | |||||||
| 56204 | DEC A | |||||||
| 56205 | ADD A,A | |||||||
| 56206 | ADD A,A | |||||||
| 56207 | ADD A,A | |||||||
| 56208 | ADD A,(IY+2) | |||||||
| 56211 | LD B,A | |||||||
|
Build the overlap limit.
|
||||||||
| 56212 | LD A,(25673) | Copy the footprint offset into C. | ||||||
| 56215 | LD C,A | |||||||
| 56216 | LD A,(IY+4) | Write the actor pixel width plus that offset into *56237. | ||||||
| 56219 | ADD A,A | |||||||
| 56220 | ADD A,A | |||||||
| 56221 | ADD A,A | |||||||
| 56222 | ADD A,C | |||||||
| 56223 | DEC A | |||||||
| 56224 | LD (56237),A | |||||||
|
Test the player width against the actor column.
|
||||||||
| 56227 | SUB C | Restore the actor pixel width in C. | ||||||
| 56228 | LD C,A | |||||||
| 56229 | INC C | |||||||
| 56230 | LD A,(25672) | Return unless the ranges overlap. | ||||||
| 56233 | ADD A,C | |||||||
| 56234 | SUB B | |||||||
| 56235 | DEC A | |||||||
| 56236 | CP 200 | |||||||
| 56238 | RET NC | |||||||
|
Copy the actor movement onto the player.
|
||||||||
| 56239 | LD A,(IY+8) | Write the horizontal delta to *Player_HorizontalDelta. | ||||||
| 56242 | LD (25772),A | |||||||
| 56245 | LD A,3 | Write 3 to *CollisionState. | ||||||
| 56247 | LD (25652),A | |||||||
|
Adjust the vertical delta by the gap.
|
||||||||
| 56250 | LD A,(IY+9) | Jump to Test_ActorCollision_Store if the vertical delta is zero. | ||||||
| 56253 | OR A | |||||||
| 56254 | JR Z,Test_ActorCollision_Store | |||||||
| 56256 | SUB D | Subtract the vertical gap. | ||||||
|
Store the vertical delta and the actor.
|
||||||||
| Test_ActorCollision_Store | 56257 | LD (25773),A | Write the vertical delta to *Player_VerticalDelta. | |||||
| 56260 | LD (25675),IY | Write the actor pointer to *Pointer_CollidedActor. | ||||||
| 56264 | RET | Return. | ||||||
| Prev: 56100 | Up: Map | Next: 56265 |