![]() |
Routines |
| Prev: BBAA | Up: Map | Next: BE0F |
|
Used by the routine at ENTRY.
Entered from ENTRY. The first of the game's three protection checks: FRAMES' middle byte must still be $63, as the tape's last block left it, or the RET goes back to BASIC -- the loader's PRINT USR is what called it. A copy that loads the code some other way, without that block, or lets the interrupts run on for a few seconds before starting it, gets no further. Then the stack is put below the game, the variables and all 23 object records are cleared, and the set-up of a new game follows (NEW_GAME).
This is the only place SP is set. GAME_OVER is jumped into from routines that were called, and leaves by jumping to NEW_GAME or MAIN_LOOP, so every game over leaves two bytes on the stack and every ending four. The stack creeps down through the BASIC program towards the system variables, and after 156 game overs in one sitting it has overwritten NMIADD: the next game's first update jumps into the screen and the machine crashes. Measured: 156 games started and ended at once in the simulator left SP at the menu two bytes lower after each, until after the 156th NMIADD held part of a return address; the 157th game ran off into the screen and the printer buffer (the loader's code ran again) and hung.
|
||||
| START | BDFE | LD A,(FRAMES_MIDDLE) | protection check 1: back to BASIC unless FRAMES' middle byte is $63 | |
| BE01 | CP $63 | |||
| BE03 | RET NZ | |||
| BE04 | LD SP,ENTRY | the stack below the game, growing into the BASIC program | ||
| BE07 | LD HL,RANDOM | clear all 596 bytes from RANDOM to the last monster's record, and join the new game | ||
| BE0A | LD BC,$0254 | |||
| BE0D | JR NEW_GAME_0 | |||
| Prev: BBAA | Up: Map | Next: BE0F |