Prev: 68D4 Up: Map Next: 697F
6900: Start a new game or enter demo mode
This section of code is entered at various points. The main entry point below is used by the startup routine at 5EE0.
6900 LD SP,$5CFE Put the stack pointer somewhere safe
6903 CALL $7E86 Play the theme tune
6906 JR $6916 Enter demo mode
This entry point is used by the routine at F9F6 when ERIC has been sent home (either for having mumps or for having over 10000 lines).
6908 CALL $7ED6 Remove the speech bubble
690B LD DE,($7FC4) DE=score
690F AND A Reset the carry flag ready for a subtraction
6910 SBC HL,DE Subtract the score from the high score...
6912 ADD HL,DE ...and add it back again
6913 JR NC,$6916 Jump unless we have a new high score
6915 EX DE,HL HL=new high score
6916 LD A,$FF 0xFF: demo mode
6918 JR $6921
This entry point is used by the routine at 7DFA when exiting demo mode.
691A CALL $EDE0 Ask for the input method, and change the character names (if desired)
691D LD HL,($7FC2) HL=high score
6920 XOR A 0x00: game mode (as opposed to demo mode)
6921 LD SP,$5CFE Put the stack pointer somewhere safe
6924 PUSH HL Save the high score
6925 LD E,A E=0xFF (demo mode) or 0x00
6926 LD A,($7FF9) Collect the current lesson number (0x00-0x3F) from 7FF9
6929 AND $30 Set A to 0x0F, 0x1F, 0x2F or 0x3F (lessons 0x00, 0x10, 0x20, and 0x30 are PLAYTIME)
692B ADD A,$0F
692D LD D,A D=new lesson number minus one
692E PUSH DE Save this for now
692F CALL $F70A Unflash the safe and all shields
6932 LD HL,$7FFD 7FFD holds the number (0x98-0xAB) of the last character moved
6935 LD (HL),$97 Reset this number so 0x98 (little boy no. 1) is moved next
6937 DEC L Blank out the rest of the game status buffer (except for the random number seed at 7FFE)
6938 LD (HL),$00
693A JR NZ,$6937
693C LD L,$E8 Initialise ERIC's main action timer at 7FE8
693E LD (HL),$11
6940 LD L,$F9 HL=7FF9 (which holds the lesson number, 0x00-0x3F)
6942 POP DE Restore the lesson number to D and game mode indicator (0x00 or 0xFF) to E
6943 LD (HL),D Set the lesson number
6944 LD L,$F7 Set the lesson clock (at 7FF7) to 1
6946 INC (HL)
6947 INC E If a new game is starting, prepare the shields and safe, and play the theme tune
6948 CALL NZ,$F8B4
694B POP HL Restore the high score to HL, and save it in 7FC2
694C LD ($7FC2),HL
The following loop sets the initial animatory state, location and character flags (byte 0x7A of the buffer) for each character (including ERIC).
694F LD H,$98 0x98=little boy no. 1
6951 LD DE,$DB00 The data table at DB00 holds the initial animatory states of the characters
6954 LD L,$60 Point HL at byte 0x60 of the character buffer
6956 LD A,(DE) Set the initial animatory state of the character
6957 LD (HL),A
6958 INC L L=0x61
6959 INC D The data table at DC00 holds the initial x-coordinates of the characters
695A LD (HL),$A9 All characters start on the bottom floor (y=169)
695C INC L L=0x62
695D LD A,(DE) Pick up the character's initial x-coordinate
695E INC D The data table at DD00 holds the character flags
695F LD (HL),A Set the character's initial x-coordinate
6960 LD A,(DE) Pick up the character flags (0x00=kid; 0x10=adult; 0x20=pellet)
6961 DEC D Point DE back at the table of initial animatory states
6962 DEC D
6963 INC E Next character
6964 LD B,$1D Blank out the remaining 29 bytes of the character's buffer
6966 INC L
6967 LD (HL),$00
6969 DJNZ $6966
696B LD L,$7A Place the character flags into byte 0x7A of the character's buffer
696D LD (HL),A
696E INC L
696F INC L L=0x7C
6970 LD (HL),$9F Place the address of the continual subcommand routine at 629F (RET) into bytes 0x7C and 0x7D of the character's buffer
6972 INC L
6973 LD (HL),$62
6975 INC H Next character
6976 INC A Have we done all the non-player characters?
6977 JR NZ,$6954 Jump back to do the next one if not
All that remains now is to print the logo, lesson box and score box, and bring the skool into view.
6979 CALL $6B0E Print the bottom 3 lines of the screen
697C JP $F918 Scroll the skool into view and enter the main loop
Prev: 68D4 Up: Map Next: 697F