Prev: 7DDA Up: Map Next: 8034
8000: Play the game (USR 32768)
The machine code's main loop, called from BASIC line 700 (to draw the city before "READY WHEN YOU ARE") and line 720 (to play). It runs GAME_FRAME, CHECK_RESCUED and CHECK_GAME_OVER over and over, returning to BASIC when 1 is pressed (back to the city gate, and "Have another go!") or when FRAMES_LEFT counts out.
FRAMES_LEFT is both the stop signal and a frame budget. BASIC pokes 2 into it before the first call, so that call draws two frames and returns; it is then 0, and the next call decrements that to $FF, which means "run until the game says stop" -- CHECK_GAME_OVER and CHECK_RESCUED stop it by storing a small count again.
PLAY 8000 DI
8001 LD HL,SPRITE_LIST_END Mark the end of SPRITE_LIST, one byte past its eighth entry.
8004 LD (HL),$FF
8006 CALL PRINT_COUNTERS Print the grenade count and both energies on the panel.
PLAY_0 8009 LD BC,$F7FE Key 1 (bit 0 of the 1-5 half-row, low when pressed)...
800C IN A,(C)
800E BIT 0,A
8010 JR NZ,PLAY_1
8012 EI ...goes straight back to BASIC.
8013 RET
PLAY_1 8014 CALL GAME_FRAME One frame of the game: move everything, draw the view.
8017 CALL CHECK_RESCUED Have both left the city?
801A CALL CHECK_GAME_OVER Out of time, or out of energy?
801D LD A,(FRAMES_LEFT) $FF: keep playing.
8020 CP $FF
8022 JP Z,PLAY_0
8025 DEC A Otherwise count a frame off, and stop at zero.
8026 LD (FRAMES_LEFT),A
8029 JP NZ,PLAY_0
802C LD A,(RANDOM_BITS) Leave the random number in SEED -- to no end: the RANDOMIZE in the BASIC's RANDOMIZE USR that calls this overwrites SEED with what the USR returns, and the BASIC has no RND (watched: the ROM's write at $1E5A replaces this one).
802F LD (SEED),A
8032 EI
8033 RET
Prev: 7DDA Up: Map Next: 8034