Prev: CB7B Up: Map Next: CC1D
CBAC: Start a new life when the knight's record is empty
Used by the routine at NEW_GAME.
Called every turn by NEW_GAME; it does nothing until the knight's legs' record is empty, which happens when a life ends and his vanishing (graphic 12) has run its four turns.
Then it checks its own code. The byte at TAKE_LIFE, the instruction that takes a life, must still be $35, DEC (HL); if it is anything else the game jumps to RESET (in STOCK_BUILDINGS), address 0, and the Spectrum starts again from its copyright message. So the obvious infinite-lives poke -- a NOP over that DEC -- resets the machine at the first death instead. It is the fourth of the game's protections, and the only one aimed at a player rather than a copier.
With lives left it plays the new-life tune (TUNE_NEW_LIFE), copies the start records (START_RECORDS) over the knight's two records -- at a new game NEW_GAME comes in at FIRST_LIFE, without the tune -- sets him appearing (ARRIVING) with three hits, and takes a life: with none to take, the game is over (GAME_OVER). Otherwise the monsters are cleared away (CLEAR_MONSTERS), his cell is marked visited (VISIT_CELL), and the lives are drawn on the panel: five places at character row 18 from column 5, a bright white knight for each life left and a blue one for each lost.
NEW_LIFE CBAC LD A,(KNIGHT) his legs' record still in use: nothing to do
CBAF AND A
CBB0 RET NZ
CBB1 LD A,(TAKE_LIFE) the check: DEC (HL) at TAKE_LIFE, or reset the machine
CBB4 CP $35
CBB6 JP NZ,RESET
CBB9 LD A,(LIVES) a life to come: the new-life tune
CBBC AND A
CBBD JR Z,FIRST_LIFE
CBBF LD DE,TUNE_NEW_LIFE
CBC2 CALL PLAY_TUNE
This entry point is used by the routine at NEW_GAME.
FIRST_LIFE CBC5 LD HL,START_RECORDS the start records over the knight's legs and top
CBC8 LD DE,KNIGHT
CBCB LD BC,$0020
CBCE LDIR
CBD0 LD A,$28 appearing: ARRIVING counts up from here to $70, when he is there
CBD2 LD (ARRIVING),A
CBD5 LD A,$03 three hits
CBD7 LD (HITS),A
CBDA LD HL,LIVES the lives
TAKE_LIFE CBDD DEC (HL) take one (the instruction the check reads)
CBDE JP M,GAME_OVER none left: game over
CBE1 CALL CLEAR_MONSTERS no monsters
CBE4 LD IX,KNIGHT his cell visited, with IX on his record
CBE8 CALL ENTER_CELL
CBEB LD HL,LIFE_CHARS the life picture's eight characters, 16 into PANEL_ICONS; bright white
CBEE LD (FONT_BASE),HL
CBF1 LD A,$47
CBF3 EX AF,AF'
CBF4 LD DE,LIFE_ICON_CODES codes 0-7; row 18, column 5
CBF7 LD HL,$5045
CBFA LD A,(LIVES) B = lives left, C = 5 - B lost
CBFD LD B,A
CBFE NEG
CC00 ADD A,$05
CC02 LD C,A
NEW_LIFE_0 CC03 LD A,B B white knights, two columns apart
CC04 AND A
CC05 JR Z,NEW_LIFE_1
CC07 CALL PRINT_LIFE_ICON
CC0A INC L
CC0B INC L
CC0C DJNZ NEW_LIFE_0
NEW_LIFE_1 CC0E LD A,$41 then blue
CC10 EX AF,AF'
CC11 LD A,C
CC12 AND A
CC13 RET Z
CC14 LD B,A for the C lost
NEW_LIFE_2 CC15 CALL PRINT_LIFE_ICON
CC18 INC L
CC19 INC L
CC1A DJNZ NEW_LIFE_2
CC1C RET
LIVES counts the lives besides the one being played. A new game sets it to 6, from the opcode of the JR at LIVES_BYTE (in NEW_GAME), and the first life takes one, so the panel starts with five.
Prev: CB7B Up: Map Next: CC1D