Prev: 62903 Up: Map Next: 63156
62910: Prepare for a new game
Used by the routine at 63189. First of all, wipe the blackboards clean.
62910 LD H,135 The blackboards use UDGs 0-79 (0-15 for the Blue Room board, 16-31 for the Yellow Room, 32-47 for the top-floor room in the girls' skool, 48-63 for the Science Lab, and 64-79 for the middle-floor room in the girls' skool) with base page 128; wipe them clean by setting every byte of graphic data for these UDGs to 255
62912 LD C,8
62914 XOR A
62915 LD L,A
62916 LD B,80
62918 LD (HL),255
62920 INC L
62921 DJNZ 62918
62923 DEC H
62924 DEC C
62925 JR NZ,62915
Next, clean up the game status buffer.
62927 LD L,0 Clear the first 222 bytes of the game status buffer
62929 LD B,222
62931 LD (HL),A
62932 INC L
62933 DJNZ 62931
Reset various counters, flags and identifiers.
62935 LD L,224 Set the lesson descriptor at 32736 to 0 (for no good reason: it will be set again by the routine at 63309 when demo mode or a new game starts)
62937 LD (HL),A
62938 INC L Reset the number of mice caught at 32737
62939 LD (HL),A
62940 INC L Reset the number of kisses available from HAYLEY at 32738
62941 LD (HL),40
62943 INC L Set the lesson clock at 32739 to 1 (so the bell will ring straight away)
62944 LD (HL),1
62946 INC L
62947 LD (HL),A
62948 LD L,235 Reset the inventory flags at 32747
62950 LD (HL),A
62951 LD L,237 Clear the game status buffer from 32749 to 32763
62953 LD B,15
62955 LD (HL),A
62956 INC L
62957 DJNZ 62955
62959 LD (HL),214 32764 holds the number of the last character moved; set this to 214 so it immediately rewinds to 183 (little boy no. 1)
62961 LD L,255 HL=32767 (leftmost column of the play area on screen)
62963 LD (HL),A Set this to 0
62964 LD L,223 HL=32735 (current lesson number)
62966 LD A,(HL) Pick this up in A (192-255)
62967 OR 7 Make sure the first lesson of the new game will be PLAYTIME
62969 LD (HL),A
62970 CALL 27860 Prepare the doors, windows, cups and bike
62973 LD L,243 HL=32755 (ERIC's main action timer)
62975 LD (HL),1 Initialise this to 1
Set up the bike and storeroom combinations.
62977 LD C,8 4 numbers in each of the 2 combinations
62979 LD L,156 HL=32668 (combinations)
62981 CALL 25233 Generate new bike and Science Lab storeroom combinations
62984 LD B,A
62985 CALL 25233
62988 DJNZ 62985
62990 LD (HL),A
62991 INC L
62992 DEC C
62993 JR NZ,62981
62995 LD L,156 HL=32668 (combinations)
62997 LD B,4 There are 4 digits in the bike combination
62999 LD C,47 47+1=48 (ASCII code for '0')
63001 LD A,(HL) A=random number collected earlier
63002 INC C C=ASCII code of the number INT(A/26)
63003 SUB 26
63005 JR NC,63002
63007 LD (HL),C Put the bike combination digit in place
63008 INC L Point HL at the next digit slot
63009 DJNZ 62999 Jump back until all four digits are done
63011 LD B,4 There are 4 letters in the storeroom combination
63013 LD C,64 64+1=65 (ASCII code for 'A')
63015 LD A,(HL) A=random number collected earlier
63016 INC C C=ASCII code of the Nth letter of the alphabet (where N=1+INT(A/10))
63017 SUB 10
63019 JR NC,63016
63021 LD (HL),C Put the storeroom combination letter in place
63022 INC L Point HL at the next letter slot
63023 DJNZ 63013 Jump back until all four letters are done
63025 LD DE,32668 Set HL to 32668 and DE to 32676
63028 EX DE,HL
63029 LD C,8 Copy the bike combination to 32676 and the storeroom combination to 32680
63031 LDIR
Place the game characters in their initial positions.
63033 LD B,32 There are 32 game characters (183-214)
63035 LD H,183 183=little girl no. 1
63037 LD D,H
63038 PUSH BC
63039 LD L,32 Collect the initial animatory state and location of the character from bytes 32-34 of the character's buffer and copy them into bytes 0-2
63041 XOR A
63042 LD E,A
63043 LD BC,3
63046 LDIR
63048 EX DE,HL
63049 LD (HL),36 Place the address of the routine at 53796 (RET) into bytes 3 and 4 of the character's buffer (thus making it the character's primary command; this is useful only for the non-human characters, which do not use command lists and therefore need a default primary command)
63051 INC L
63052 LD (HL),210
63054 INC L L=5
63055 EX DE,HL
63056 LD B,24 Zero out bytes 5-28 of the character's buffer
63058 LD (DE),A
63059 INC E
63060 DJNZ 63058
63062 LDI Copy byte 35 into byte 29
63064 LD A,H A=character number (183-214)
63065 AND 15 Initialise the walking speed change delay counter at byte 30 of the character's buffer
63067 LD (DE),A
63068 POP BC
63069 INC H Next character
63070 DJNZ 63037 Jump back until all the characters have been initialised
Set up a free mouse.
63072 LD HL,31254 Routine at 31254: control mouse
63075 LD (54289),HL Place this uninterruptible subcommand routine address into bytes 17 and 18 of the mouse's buffer
63078 LD HL,257 Set bytes 20 and 21 of the mouse's buffer to 1; this has the effect of making the mouse hide initially
63081 LD (54292),HL
Clear the screen.
63084 LD HL,16384 Clear the display file
63087 LD (HL),L
63088 LD DE,16385
63091 LD BC,6144
63094 LDIR
63096 LD (HL),7 PAPER 0: INK 7
63098 LD B,3
63100 LDIR
Prepare the bottom three lines of the screen.
63102 LD HL,59176 The graphic data for the BTS logo is at 59176
63105 LD DE,23224 Point DE at the appropriate attribute file address
63108 CALL 27364 Print the BTS logo
63111 LD HL,58920 The graphic data for the score box is at 58920
63114 LD DE,23200 Point DE at the appropriate attribute file address
63117 CALL 27364 Print the Score/Lines/Hi-score box
63120 LD HL,(32745) Collect the hi-score from 32745 into DE
63123 EX DE,HL
63124 LD HL,20964 Point HL at the appropriate display file address
63127 CALL 29613 Print the hi-score
63130 XOR A Print the score (0)
63131 CALL 29621
63134 XOR A Print the lines total (0)
63135 CALL 29643
63138 LD A,88 When the game begins, the leftmost column of the play area on screen will be 88+32=120
63140 LD (32767),A
Scroll the play area onto the screen and play the theme tune.
63143 LD B,4 There are 4 quarters to scroll on
63145 PUSH BC
63146 CALL 25026 Scroll on a quarter
63149 POP BC
63150 DJNZ 63145 Jump back until all 4 quarters have been scrolled on
63152 CALL 24477 Play the theme tune
63155 RET
Prev: 62903 Up: Map Next: 63156