Prev: 66A4 Up: Map Next: 6821
673A: Lose a life
Used by the routine at 66A4.
673A LD A,($7C78) Decrement the number of lives.
673D DEC A
673E LD ($7C78),A
6741 XOR A Reset the tunnel timer.
6742 LD ($7C79),A
6745 LD ($6DBE),A Reset the current guard's return delay counter.
6748 LD HL,$4007 This is the display file address for the score.
674B CALL $6C0F Set HL' to the corresponding attribute file address (unnecessarily).
674E LD A,($7C78) Pick up the number of lives remaining.
6751 ADD A,"0" Convert it to the ASCII code of the digit.
6753 EX DE,HL Transfer the display file address to DE.
6754 CALL $6B4F Print the number of lives remaining.
The following loop produces the Horace-has-died colour-cycling effect. The accompanying sound effect varies depending on the current value of the address held at 7C67.
When that address is 0, it sounds like this:
6757 LD B,$2D Initialise the loop counter.
6759 PUSH BC Save the loop counter.
675A LD A,($7C71) Increment Horace's INK colour.
675D INC A
675E AND $07
6760 OR $38
6762 LD ($7C71),A
6765 PUSH AF Save the attribute byte briefly.
6766 CALL $6832 Draw Horace in this new colour.
6769 LD HL,$5800 This is the attribute file address for the 'P' of 'PASSES'.
676C LD B,$09 B will count the characters in 'PASSES n ' (where 'n' in the number of lives remaining).
676E POP AF Restore the attribute byte to A.
676F LD (HL),A Change the INK colour of the number of remaining lives to match that of Horace.
6770 INC HL
6771 DJNZ $676F
6773 LD C,$14 Initialise C for the loop that follows.
6775 LD A,$1F Flip the speaker off if the sound on/off indicator is on, or on otherwise.
6777 LD HL,$7C69
677A AND (HL)
677B OUT ($FE),A
677D CALL $6B12 Generate a pseudo-random number in A.
6780 OR $40 Set bit 6 to make sure it's in the range 64-255.
6782 LD B,A Use this value to produce a short delay.
6783 DJNZ $6783
6785 LD A,$07 Flip the speaker on.
6787 OUT ($FE),A
6789 CALL $6B12 Generate another pseudo-random number in the range 64-255.
678C OR $40
678E LD B,A Use this value to produce a short delay.
678F DJNZ $678F
6791 DEC C Finished yet?
6792 JR NZ,$6775 Jump back if not.
6794 POP BC Restore the loop counter to B.
6795 DJNZ $6759 Jump back for the next iteration.
Now that's done, reinitialise Horace and the guards.
6797 LD A,$38 Reset the INK colour of the number of remaining lives to black.
6799 LD HL,$5800
679C LD B,$08
679E LD (HL),A
679F INC HL
67A0 DJNZ $679E
67A2 LD A,$39 Reset Horace's attribute byte (INK 1: PAPER 7).
67A4 LD ($7C71),A
67A7 LD HL,$6DAC Point HL at the last of the four guard countdown timers.
67AA LD B,$01 B will count four guards (1, 2, 3, 4).
67AC PUSH BC Save the guard counter.
67AD LD A,(HL) Set the zero flag if this guard is in play.
67AE INC HL
67AF OR (HL)
67B0 DEC HL Point HL at the next guard's countdown timer.
67B1 DEC HL
67B2 DEC HL
67B3 PUSH HL Save the guard countdown timer pointer.
67B4 JR NZ,$67BF Jump if this guard is not in play yet.
67B6 CALL $6A3F Copy the guard's buffer into the temporary location (6DB8).
67B9 CALL $6568 Redraw the maze background tiles at this guard's location.
67BC CALL $6A6A Copy the guard's buffer back to the original location.
67BF POP HL Restore the guard countdown timer pointer to HL.
67C0 POP BC Restore the guard counter to B.
67C1 INC B Next guard.
67C2 LD A,B Copy the guard counter to A.
67C3 CP $05 Have we done all four guards yet?
67C5 JR NZ,$67AC If not, jump back to do the next one.
67C7 LD HL,($7C6B) Pick up Horace's current location.
67CA LD DE,$7F87 Point DE at the graphic data for the blank sprite.
67CD CALL $6C0F Set HL' to the attribute file address corresponding to Horace's location.
67D0 LD C,$3E This is the attribute byte for the blank sprite (INK 6: PAPER 7).
67D2 CALL $6BD6 Draw the blank sprite at Horace's location.
67D5 LD A,($7C78) Pick up the number of lives remaining.
67D8 AND A Is it zero?
67D9 JR Z,$67E9 Jump if so.
67DB POP HL Drop the return address from the stack.
67DC CALL $6A22 Initialise the guard countdown timers.
67DF LD A,($6B0B) Pick up the game mode indicator.
67E2 AND A Is it demo mode?
67E3 JP NZ,$61AA Jump if not.
67E6 JP $60E9 Otherwise move to the next maze.
Horace has just lost his last remaining life. This entry point is also used by the routine at 624F when a key is pressed in demo mode.
67E9 LD B,$14 This loop will have 20 iterations.
67EB PUSH BC Save the loop counter.
67EC CALL $6A77 Make a sound effect.
67EF LD HL,$5800 Change the INK colour of the entire screen to B mod 8.
67F2 LD DE,$5801
67F5 LD A,B
67F6 AND $07
67F8 ADD A,$38
67FA LD (HL),A
67FB LD BC,$02FF
67FE LDIR
6800 POP BC Restore the loop counter to B.
6801 DJNZ $67EB Jump back for the next iteration.
6803 POP HL Drop the return address from the stack.
6804 LD A,($6B0B) Pick up the game mode indicator.
6807 AND A Is it demo mode?
6808 JP Z,$601A Return to the title screen if so.
680B LD HL,($7C73) Pick up the current score.
680E LD BC,($7C75) Pick up the high score.
6812 XOR A Clear the carry flag for subtraction.
6813 SBC HL,BC Do we have a new high score?
6815 JP C,$601A Return to the title screen if not.
6818 LD HL,($7C73) Pick up the current score.
681B LD ($7C75),HL Make it the new high score.
681E JP $601A Return to the title screen.
Prev: 66A4 Up: Map Next: 6821