Routines

62910: Prepare for a new game


Used by routine at 63189

62910 2687 LD H,135
62912 0E08 LD C,8
62914 AF XOR A
62915 6F LD L,A
62916 0650 LD B,80
62918 36FF LD (HL),255 255=blank byte for blackboard
62920 2C INC L
62921 10FB DJNZ 62918
62923 25 DEC H
62924 0D DEC C
62925 20F4 JR NZ,62915
62927 2E00 LD L,0 HL=32512
62929 06DE LD B,222
62931 77 LD (HL),A Zero out 32512 to 32733
62932 2C INC L
62933 10FC DJNZ 62931
62935 2EE0 LD L,224 HL=32736
62937 77 LD (HL),A Reset lesson identifier
62938 2C INC L HL=32737
62939 77 LD (HL),A Reset number of mice caught
62940 2C INC L HL=32738
62941 3628 LD (HL),40 Reset number of kisses available from HAYLEY
62943 2C INC L HL=32739
62944 3601 LD (HL),1 Set lesson time counter to 1 (so bell is rung straight away)
62946 2C INC L
62947 77 LD (HL),A
62948 2EEB LD L,235 HL=32747
62950 77 LD (HL),A Reset inventory flags
62951 2EED LD L,237 HL=32749
62953 060F LD B,15
62955 77 LD (HL),A Zero out 32749 to 32763
62956 2C INC L
62957 10FC DJNZ 62955
62959 36D6 LD (HL),214 HL=32764 (last character moved)
62961 2EFF LD L,255 HL=32767
62963 77 LD (HL),A Set leftmost column of screen to 0
62964 2EDF LD L,223 HL=32735
62966 7E LD A,(HL) A=lesson number (192-255)
62967 F607 OR 7 Make sure the first lesson of the new game will be PLAYTIME
62969 77 LD (HL),A
62970 CDD46C CALL 27860 Prepare doors, windows, cups and bike
62973 2EF3 LD L,243 HL=32755
62975 3601 LD (HL),1

Set up the bike and storeroom combinations.
62977 0E08 LD C,8
62979 2E9C LD L,156 HL=32668 (combinations)
62981 CD9162 CALL 25233 Fill 32668 to 32675 with random numbers
62984 47 LD B,A
62985 CD9162 CALL 25233
62988 10FB DJNZ 62985
62990 77 LD (HL),A
62991 2C INC L
62992 0D DEC C
62993 20F2 JR NZ,62981
62995 2E9C LD L,156 HL=32668 (combinations)
62997 0604 LD B,4 4 numbers for bike combination
62999 0E2F LD C,47
63001 7E LD A,(HL) A=random number collected earlier
63002 0C INC C Get a digit character code in C
63003 D61A SUB 26
63005 30FB JR NC,63002
63007 71 LD (HL),C Put the bike combination digit in place
63008 2C INC L
63009 10F4 DJNZ 62999 Jump back until all four digits are done
63011 0604 LD B,4 4 letters in storeroom combination
63013 0E40 LD C,64
63015 7E LD A,(HL)
63016 0C INC C Get a letter character code in C
63017 D60A SUB 10
63019 30FB JR NC,63016
63021 71 LD (HL),C Put the storeroom combination letter in place
63022 2C INC L
63023 10F4 DJNZ 63013 Jump back until all four letters are done
63025 119C7F LD DE,32668
63028 EB EX DE,HL
63029 0E08 LD C,8 Copy the bike combination into 32676-32679 and the storeroom combination into 32680-32683
63031 EDB0 LDIR

Place the game characters in their initial positions.
63033 0620 LD B,32 32 game characters (183-214)
63035 26B7 LD H,183 183=little girl no. 1
63037 54 LD D,H
63038 C5 PUSH BC
63039 2E20 LD L,32 Collect the initial animatory state and location of the character from bytes 32-34 of the buffer and place them in bytes 0-2
63041 AF XOR A
63042 5F LD E,A
63043 010300 LD BC,3
63046 EDB0 LDIR
63048 EB EX DE,HL
63049 3624 LD (HL),36 Place the address of the routine at 53796 into bytes 3 and 4 of the character's buffer
63051 2C INC L
63052 36D2 LD (HL),210
63054 2C INC L L=5
63055 EB EX DE,HL
63056 0618 LD B,24
63058 12 LD (DE),A Zero out bytes 5 to 28 of the character's buffer
63059 1C INC E
63060 10FC DJNZ 63058
63062 EDA0 LDI Copy byte 35 into byte 29
63064 7C LD A,H A=character number (183-214)
63065 E60F AND 15
63067 12 LD (DE),A E=30
63068 C1 POP BC
63069 24 INC H Next character
63070 10DD DJNZ 63037 Jump back until all characters have been initialised

Set up a free mouse.
63072 21167A LD HL,31254 Routine at 31254: control released mouse
63075 2211D4 LD (54289),HL Place this routine address into bytes 17 and 18 of buffer 212
63078 210101 LD HL,257 H=1, L=1
63081 2214D4 LD (54292),HL Place this in bytes 20 and 21 of the mouse's buffer

Clear the screen.
63084 210040 LD HL,16384
63087 75 LD (HL),L
63088 110140 LD DE,16385
63091 010018 LD BC,6144
63094 EDB0 LDIR
63096 3607 LD (HL),7
63098 0603 LD B,3
63100 EDB0 LDIR

Prepare the bottom three lines of the screen.
63102 2128E7 LD HL,59176
63105 11B85A LD DE,23224
63108 CDE46A CALL 27364 Print the BTS logo
63111 2128E6 LD HL,58920
63114 11A05A LD DE,23200
63117 CDE46A CALL 27364 Print the Score, Lines, Hi-score box
63120 2AE97F LD HL,(32745)
63123 EB EX DE,HL
63124 21E451 LD HL,20964
63127 CDAD73 CALL 29613 Print the hi-score
63130 AF XOR A
63131 CDB573 CALL 29621 Print the score (0)
63134 AF XOR A
63135 CDCB73 CALL 29643 Print lines (0)
63138 3E58 LD A,88 88=column of play area at far left of screen at start of game
63140 32FF7F LD (32767),A

Scroll the play area onto the screen and play the BTS theme tune.
63143 0604 LD B,4 4 quarters to scroll on
63145 C5 PUSH BC
63146 CDC261 CALL 25026 Scroll on a quarter
63149 C1 POP BC
63150 10F9 DJNZ 63145
63152 CD9D5F CALL 24477 Play the tune
63155 C9 RET