![]() |
Routines |
Prev: 25167 | Up: Map |
Used by the routine at 24576.
|
|||||||
25399 | LD A,(31841) | Decrement the sprite movement timer. | |||||
25402 | DEC A | ||||||
25403 | LD (31841),A | ||||||
25406 | RET NZ | Return unless it's zero. | |||||
25407 | LD A,(31842) | Reset the sprite movement timer to the value of the game speed parameter. | |||||
25410 | LD (31841),A | ||||||
25413 | LD A,(31865) | Pick up the tunnel timer. | |||||
25416 | AND A | Is Horace in a tunnel at the moment? | |||||
25417 | JR NZ,25535 | Jump if so. | |||||
25419 | LD A,(31856) | Pick up Horace's animation frame. | |||||
25422 | LD HL,(31851) | Pick up Horace's current location. | |||||
25425 | CALL 27842 | Check the tiles in front of Horace. | |||||
25428 | CP 0 | Is there anything in front of Horace? | |||||
25430 | JR Z,25515 | Jump if not. | |||||
25432 | CP 1 | Is Horace facing a tunnel entrance? | |||||
25434 | JR Z,25450 | Jump if so. | |||||
25436 | CP 2 | Is Horace facing a maze exit or entrance? | |||||
25438 | JR NZ,25529 | Jump if not. | |||||
25440 | LD A,(31856) | Pick up Horace's animation frame. | |||||
25443 | CP 1 | Is Horace facing right? | |||||
25445 | JP Z,27166 | Jump if so (Horace is leaving the maze). | |||||
25448 | JR 25529 | ||||||
Horace is about to enter a tunnel.
|
|||||||
25450 | LD A,90 | Initialise the tunnel timer. | |||||
25452 | LD (31865),A | ||||||
25455 | LD BC,(28623) | Pick up the tunnel offset for the current maze. | |||||
25459 | LD HL,(31851) | Pick up Horace's location. | |||||
25462 | LD A,(31856) | Pick up Horace's animation frame. | |||||
25465 | AND A | Is Horace going up? | |||||
25466 | JR Z,25472 | Jump if so. | |||||
25468 | SBC HL,BC | Subtract the tunnel offset from Horace's location. | |||||
25470 | JR 25473 | ||||||
25472 | ADD HL,BC | Add the tunnel offset to Horace's location. | |||||
25473 | PUSH HL | Save HL (which holds Horace's new location) temporarily. | |||||
25474 | LD HL,31849 | Pick up the sound on/off indicator. | |||||
25477 | LD C,16 | Initialise C for the loop that follows. | |||||
25479 | PUSH BC | Save the loop counter (unnecessarily). | |||||
25480 | LD B,C | Set B and E equal to 8*C. This value determines the pitch. | |||||
25481 | SLA B | ||||||
25483 | SLA B | ||||||
25485 | SLA B | ||||||
25487 | LD E,B | ||||||
25488 | LD D,8 | This value determines the duration. | |||||
25490 | LD B,E | Produce a sound (if the sound on/off indicator is on) with pitch and duration determined by E and D. | |||||
25491 | LD A,31 | ||||||
25493 | AND (HL) | ||||||
25494 | OUT (254),A | ||||||
25496 | DJNZ 25496 | ||||||
25498 | LD A,7 | ||||||
25500 | OUT (254),A | ||||||
25502 | LD B,E | ||||||
25503 | DJNZ 25503 | ||||||
25505 | DEC D | ||||||
25506 | JR NZ,25490 | ||||||
25508 | POP BC | Restore the loop counter to C (unnecessarily). | |||||
25509 | DEC C | Finished yet? | |||||
25510 | JR NZ,25479 | Jump back if not. | |||||
25512 | POP HL | Restore Horace's new location to HL. | |||||
25513 | JR 25524 | ||||||
There's nothing in front of Horace, so he can move one space forward.
|
|||||||
25515 | LD HL,(31851) | Pick up Horace's current location. | |||||
25518 | LD A,(31856) | Pick up Horace's animation frame. | |||||
25521 | CALL 27927 | Get the location of the spot one space in front of Horace. | |||||
25524 | LD (31853),HL | Update Horace's location. | |||||
25527 | JR 25535 | ||||||
Horace is facing a wall or the maze entrance, and so cannot move forward.
|
|||||||
25529 | LD HL,(31851) | Pick up Horace's current location. | |||||
25532 | LD (31853),HL | Set Horace's new location. | |||||
Now it's time to move the guards.
|
|||||||
25535 | LD HL,28070 | Point HL at the first of the guard countdown timers. | |||||
25538 | LD B,4 | There are four guards to consider. | |||||
25540 | PUSH BC | Save the guard counter. | |||||
25541 | LD A,(HL) | Set the zero flag if this guard is in play. | |||||
25542 | INC HL | ||||||
25543 | OR (HL) | ||||||
25544 | INC HL | Point HL at the next guard's countdown timer. | |||||
25545 | PUSH HL | Save the guard countdown timer pointer. | |||||
25546 | JR NZ,25557 | Jump if this guard is not in play at the moment. | |||||
25548 | CALL 27199 | Copy the guard's buffer into the temporary location (28088). | |||||
25551 | CALL 25562 | Move the guard. | |||||
25554 | CALL 27242 | Copy the guard's buffer back to the original location. | |||||
25557 | POP HL | Restore the guard countdown timer pointer to HL. | |||||
25558 | POP BC | Restore the guard counter to B. | |||||
25559 | DJNZ 25540 | Jump back to handle the next guard. | |||||
25561 | RET |
Prev: 25167 | Up: Map |