![]() |
Routines |
| Prev: DB24 | Up: Map | Next: DBC9 |
|
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 | DB3F | LD A,(IY+$08) | Jump to Test_ActorCollision_Column if the horizontal delta is set. | |||||
| DB42 | OR A | |||||||
| DB43 | JR NZ,Test_ActorCollision_Column | |||||||
|
Test the destination row.
|
||||||||
| DB45 | LD A,$07 | Jump to Test_ActorCollision_Bounds unless the fine-Y is 07. | ||||||
| DB47 | CP (IY+$03) | |||||||
| DB4A | JR NZ,Test_ActorCollision_Bounds | |||||||
| DB4C | LD A,(IY+$01) | Call Actor_Reverse if the row matches the destination. | ||||||
| DB4F | CP (IY+$06) | |||||||
| DB52 | CALL Z,Actor_Reverse | |||||||
| DB55 | JR Test_ActorCollision_Bounds | Jump to Test_ActorCollision_Bounds. | ||||||
|
Test the destination column.
|
||||||||
| Test_ActorCollision_Column | DB57 | LD A,$07 | Jump to Test_ActorCollision_Bounds unless the fine-X is 07. | |||||
| DB59 | CP (IY+$02) | |||||||
| DB5C | JR NZ,Test_ActorCollision_Bounds | |||||||
| DB5E | LD A,(IY+$00) | Call Actor_Reverse if the column matches the destination. | ||||||
| DB61 | CP (IY+$05) | |||||||
| DB64 | CALL Z,Actor_Reverse | |||||||
|
Skip the hit test while jumping or falling.
|
||||||||
| Test_ActorCollision_Bounds | DB67 | LD A,($6410) | Return if *Player_JumpTimer is set. | |||||
| DB6A | OR A | |||||||
| DB6B | RET NZ | |||||||
|
Require a close vertical overlap.
|
||||||||
| DB6C | LD A,(IY+$01) | Convert the actor row and fine-Y into a pixel row. | ||||||
| DB6F | ADD A,A | |||||||
| DB70 | ADD A,A | |||||||
| DB71 | ADD A,A | |||||||
| DB72 | ADD A,(IY+$03) | |||||||
| DB75 | LD C,A | |||||||
|
Convert the player row the same way.
|
||||||||
| DB76 | LD A,($64A7) | Convert the player row and fine-Y into a pixel row. | ||||||
| DB79 | LD B,A | |||||||
| DB7A | LD A,($64A5) | |||||||
| DB7D | SUB $03 | |||||||
| DB7F | ADD A,A | |||||||
| DB80 | ADD A,A | |||||||
| DB81 | ADD A,A | |||||||
| DB82 | ADD A,B | |||||||
| DB83 | SUB C | Return unless the difference is less than 04. | ||||||
| DB84 | CP $04 | |||||||
| DB86 | RET NC | |||||||
|
Keep the gap and convert the actor column.
|
||||||||
| DB87 | LD D,A | Keep the vertical gap in D. | ||||||
| DB88 | LD A,(IY+$00) | Convert the actor column and fine-X into a pixel column. | ||||||
| DB8B | DEC A | |||||||
| DB8C | DEC A | |||||||
| DB8D | ADD A,A | |||||||
| DB8E | ADD A,A | |||||||
| DB8F | ADD A,A | |||||||
| DB90 | ADD A,(IY+$02) | |||||||
| DB93 | LD B,A | |||||||
|
Build the overlap limit.
|
||||||||
| DB94 | LD A,($6449) | Copy the footprint offset into C. | ||||||
| DB97 | LD C,A | |||||||
| DB98 | LD A,(IY+$04) | Write the actor pixel width plus that offset into *DBAD. | ||||||
| DB9B | ADD A,A | |||||||
| DB9C | ADD A,A | |||||||
| DB9D | ADD A,A | |||||||
| DB9E | ADD A,C | |||||||
| DB9F | DEC A | |||||||
| DBA0 | LD ($DBAD),A | |||||||
|
Test the player width against the actor column.
|
||||||||
| DBA3 | SUB C | Restore the actor pixel width in C. | ||||||
| DBA4 | LD C,A | |||||||
| DBA5 | INC C | |||||||
| DBA6 | LD A,($6448) | Return unless the ranges overlap. | ||||||
| DBA9 | ADD A,C | |||||||
| DBAA | SUB B | |||||||
| DBAB | DEC A | |||||||
| DBAC | CP $C8 | |||||||
| DBAE | RET NC | |||||||
|
Copy the actor movement onto the player.
|
||||||||
| DBAF | LD A,(IY+$08) | Write the horizontal delta to *Player_HorizontalDelta. | ||||||
| DBB2 | LD ($64AC),A | |||||||
| DBB5 | LD A,$03 | Write 03 to *CollisionState. | ||||||
| DBB7 | LD ($6434),A | |||||||
|
Adjust the vertical delta by the gap.
|
||||||||
| DBBA | LD A,(IY+$09) | Jump to Test_ActorCollision_Store if the vertical delta is zero. | ||||||
| DBBD | OR A | |||||||
| DBBE | JR Z,Test_ActorCollision_Store | |||||||
| DBC0 | SUB D | Subtract the vertical gap. | ||||||
|
Store the vertical delta and the actor.
|
||||||||
| Test_ActorCollision_Store | DBC1 | LD ($64AD),A | Write the vertical delta to *Player_VerticalDelta. | |||||
| DBC4 | LD ($644B),IY | Write the actor pointer to *Pointer_CollidedActor. | ||||||
| DBC8 | RET | Return. | ||||||
| Prev: DB24 | Up: Map | Next: DBC9 |