Prev: 624F Up: Map Next: 63DA
6337: Move Horace and the guards
Called from the main loop at 6229.
6337 LD A,($7C61) Decrement the sprite movement timer.
633A DEC A
633B LD ($7C61),A
633E RET NZ Return unless it's zero.
633F LD A,($7C62) Reset the sprite movement timer to the value of the game speed parameter.
6342 LD ($7C61),A
6345 LD A,($7C79) Pick up the tunnel timer.
6348 AND A Is Horace in a tunnel at the moment?
6349 JR NZ,$63BF Jump if so.
634B LD A,($7C70) Pick up Horace's animation frame.
634E LD HL,($7C6B) Pick up Horace's current location.
6351 CALL $6CC2 Check the tiles in front of Horace.
6354 CP $00 Is there anything in front of Horace?
6356 JR Z,$63AB Jump if not.
6358 CP $01 Is Horace facing a tunnel entrance?
635A JR Z,$636A Jump if so.
635C CP $02 Is Horace facing a maze exit or entrance?
635E JR NZ,$63B9 Jump if not.
6360 LD A,($7C70) Pick up Horace's animation frame.
6363 CP $01 Is Horace facing right?
6365 JP Z,$6A1E Jump if so (Horace is leaving the maze).
6368 JR $63B9
Horace is about to enter a tunnel.
636A LD A,$5A Initialise the tunnel timer.
636C LD ($7C79),A
636F LD BC,($6FCF) Pick up the tunnel offset for the current maze.
6373 LD HL,($7C6B) Pick up Horace's location.
6376 LD A,($7C70) Pick up Horace's animation frame.
6379 AND A Is Horace going up?
637A JR Z,$6380 Jump if so.
637C SBC HL,BC Subtract the tunnel offset from Horace's location.
637E JR $6381
6380 ADD HL,BC Add the tunnel offset to Horace's location.
6381 PUSH HL Save HL (which holds Horace's new location) temporarily.
6382 LD HL,$7C69 Pick up the sound on/off indicator.
6385 LD C,$10 Initialise C for the loop that follows.
6387 PUSH BC Save the loop counter (unnecessarily).
6388 LD B,C Set B and E equal to 8*C. This value determines the pitch.
6389 SLA B
638B SLA B
638D SLA B
638F LD E,B
6390 LD D,$08 This value determines the duration.
6392 LD B,E Produce a sound (if the sound on/off indicator is on) with pitch and duration determined by E and D.
6393 LD A,$1F
6395 AND (HL)
6396 OUT ($FE),A
6398 DJNZ $6398
639A LD A,$07
639C OUT ($FE),A
639E LD B,E
639F DJNZ $639F
63A1 DEC D
63A2 JR NZ,$6392
63A4 POP BC Restore the loop counter to C (unnecessarily).
63A5 DEC C Finished yet?
63A6 JR NZ,$6387 Jump back if not.
63A8 POP HL Restore Horace's new location to HL.
63A9 JR $63B4
There's nothing in front of Horace, so he can move one space forward.
63AB LD HL,($7C6B) Pick up Horace's current location.
63AE LD A,($7C70) Pick up Horace's animation frame.
63B1 CALL $6D17 Get the location of the spot one space in front of Horace.
63B4 LD ($7C6D),HL Update Horace's location.
63B7 JR $63BF
Horace is facing a wall or the maze entrance, and so cannot move forward.
63B9 LD HL,($7C6B) Pick up Horace's current location.
63BC LD ($7C6D),HL Set Horace's new location.
Now it's time to move the guards.
63BF LD HL,$6DA6 Point HL at the first of the guard countdown timers.
63C2 LD B,$04 There are four guards to consider.
63C4 PUSH BC Save the guard counter.
63C5 LD A,(HL) Set the zero flag if this guard is in play.
63C6 INC HL
63C7 OR (HL)
63C8 INC HL Point HL at the next guard's countdown timer.
63C9 PUSH HL Save the guard countdown timer pointer.
63CA JR NZ,$63D5 Jump if this guard is not in play at the moment.
63CC CALL $6A3F Copy the guard's buffer into the temporary location (6DB8).
63CF CALL $63DA Move the guard.
63D2 CALL $6A6A Copy the guard's buffer back to the original location.
63D5 POP HL Restore the guard countdown timer pointer to HL.
63D6 POP BC Restore the guard counter to B.
63D7 DJNZ $63C4 Jump back to handle the next guard.
63D9 RET
Prev: 624F Up: Map Next: 63DA