Routines |
Prev: 25484 | Up: Map | Next: 25532 |
The address of this interruptible subcommand routine is placed into bytes 105 and 106 of a character's buffer by the routine at 25534 when the character has reached the top of a staircase he needs to descend to reach his destination.
|
||||||||
25488 | LD B,1 | Signal that the character is going down a staircase | ||||||
This entry point is used by the routine at 25484 with B=255.
|
||||||||
25490 | LD L,107 | Byte 107 of the character's buffer holds the number of movements remaining | ||||||
25492 | DEC (HL) | Has the character finished going up or down the stairs? | ||||||
25493 | JP Z,25252 | Terminate this interruptible subcommand if so | ||||||
25496 | PUSH BC | Save the direction indicator (in B) briefly | ||||||
25497 | CALL 25108 | Update the SRB for the character's current location | ||||||
25500 | POP BC | Restore the direction indicator to B | ||||||
25501 | LD C,A | C=character's current animatory state | ||||||
25502 | INC A | A=character's next animatory state | ||||||
25503 | BIT 0,A | Is the character midstride right now? | ||||||
25505 | JR Z,25515 | Jump if so | ||||||
The following four instructions calculate the character's next y-coordinate. The y-coordinate will be decremented if the character is going up the stairs and he's not midstride at the moment, incremented if he's going down the stairs and he is midstride at the moment, and otherwise unchanged.
|
||||||||
25507 | DEC D | |||||||
25508 | INC B | Is the character going up the stairs? | ||||||
25509 | JR Z,25512 | Jump if so | ||||||
25511 | INC D | |||||||
At this point A holds the character's new animatory state, and DE his new location.
|
||||||||
25512 | JP 25008 | Update the character's animatory state and location and update the SRB | ||||||
The character is midstride. Now we calculate his next x-coordinate.
|
||||||||
25515 | RLCA | Set the carry flag if the character is facing left | ||||||
25516 | CCF | |||||||
25517 | SBC A,A | A=0 (facing right) or -2 (facing left) | ||||||
25518 | ADD A,A | |||||||
25519 | ADD A,E | Set E equal to the character's new x-coordinate | ||||||
25520 | LD E,A | |||||||
25521 | INC E | |||||||
25522 | LD A,C | A=character's current animatory state | ||||||
25523 | INC A | A=character's next animatory state | ||||||
25524 | BIT 1,A | Will the character be standing (phase 3)? | ||||||
25526 | JR NZ,25508 | Jump if so | ||||||
25528 | SUB 4 | Adjust the animatory state to standing (phase 1) | ||||||
25530 | JR 25508 |
Prev: 25484 | Up: Map | Next: 25532 |