| Routines

F8B4: Adjust the game mode

Used by the routines at 6900 (to prepare the shields and safe for a new game), 6DEF (when the last shield has just been flashed or unflashed) and F726 (when ERIC has opened the safe).
F8B4 | PUSH HL |
F8B5 | LD HL,$7FEB | 7FEB holds the shield counter
F8B8 | LD (HL),$0F | Restore the shield counter to 15
F8BA | DEC L | HL=7FEA (game mode indicator)
F8BB | INC (HL) | A=1 if the game has just started, 2 if the 15th shield was just flashed, 3 if the safe was just opened, or 4 if the 15th shield was just unflashed
F8BC | LD A,(HL)
F8BD | LD HL,($7FC4) | HL=score
F8C0 | CP $04 | Was the 15th shield just unflashed?
F8C2 | JR NZ,$F8D8 | Jump if not
ERIC has just hit the 15th shield and made it unflash.
F8C4 | LD DE,$01F4 | Add 5000 to the score and print it
F8C7 | ADD HL,DE
F8C8 | CALL $F4F1
F8CB | LD HL,$FEE0 | FEE0='WELL DONE! GO UP A YEAR'
F8CE | CALL $F9AF | Print this in the lesson box
F8D1 | LD A,$0C | Set the MSB of the lesson clock to 0x0C
F8D3 | LD ($7FF8),A
F8D6 | LD A,$01 | Ensure that the 'DEC A' below sets the zero flag
F8D8 | DEC A | Was the 15th shield just flashed or the safe just opened?
F8D9 | JR NZ,$F8E6 | Jump if so
Either the game has just started, or the 15th shield was just unflashed.
F8DB | CALL $F855 | Generate a new safe combination code, and a new random birth year for MR CREAK
F8DE | CALL $F70A | Unflash the safe and all the shields
F8E1 | CALL $7E90 | Play the theme tune
F8E4 | POP HL |
F8E5 | RET |
ERIC has just hit the 15th shield and made it flash (A=1), or just opened the safe (A=2).
F8E6 | LD DE,$0064 | Add 1000 to the score
F8E9 | ADD HL,DE
F8EA | DEC A | Was the safe just opened?
F8EB | JR NZ,$F8EE | Jump if so
F8ED | ADD HL,DE | Add 1000 more to the score if the 15th shield was hit
F8EE | CALL $F4F1 | Print the new score
F8F1 | CALL $7E96 | Play the 'Got all the shields' tune
F8F4 | POP HL |
F8F5 | RET |