Routines |
Prev: 59951 | Up: Map | Next: 60214 |
Used by the routine at Game_Loop.
|
||||||||||||||||||||
|
||||||||||||||||||||
Handler_MainMenu | 59978 | LD DE,55412 | DE=Score_Digit_01. | |||||||||||||||||
59981 | LD HL,55407 | HL=HighScore. | ||||||||||||||||||
59984 | LD A,(DE) | Load the first byte of the current score. | ||||||||||||||||||
59985 | SUB (HL) | Compare it with the first byte of the high score. | ||||||||||||||||||
59986 | JP M,Print_Score/HighScore | Jump to Print_Score/HighScore if the current score digit is less than the high score digit. | ||||||||||||||||||
It's a new high score! Update what's stored.
|
||||||||||||||||||||
59989 | LD A,(DE) | Write the first score digit to the first highscore digit. | ||||||||||||||||||
59990 | LD (HL),A | |||||||||||||||||||
59991 | INC DE | Increment the current score pointer by one. | ||||||||||||||||||
59992 | INC HL | Increment the high score pointer by one. | ||||||||||||||||||
59993 | JR NZ,UpdateHighScore | Jump to UpdateHighScore until the score digit is zero. | ||||||||||||||||||
59995 | LD A,(DE) | Load the second byte of the current score. | ||||||||||||||||||
59996 | SUB (HL) | Compare it with the second byte of the high score. | ||||||||||||||||||
59997 | JP M,Print_Score/HighScore | Jump to Print_Score/HighScore if the current score digit is less than the high score digit. | ||||||||||||||||||
UpdateHighScore | 60000 | LD A,(DE) | Write the second score digit to the second highscore digit. | |||||||||||||||||
60001 | LD (HL),A | |||||||||||||||||||
Print the score of the last game and the high score.
|
||||||||||||||||||||
Print_Score/HighScore | 60002 | LD B,19 | Set the X co-ordinate for the score display. | |||||||||||||||||
60004 | LD C,14 | Set the Y co-ordinate for the score display. | ||||||||||||||||||
60006 | LD DE,55412 | DE=Score_Digit_01. | ||||||||||||||||||
60009 | LD A,6 | Set the number of digits to print in A. | ||||||||||||||||||
60011 | CALL Print_Numbers | Call Print_Numbers. | ||||||||||||||||||
60014 | LD B,21 | Set the X co-ordinate for the high score display. | ||||||||||||||||||
60016 | LD C,14 | Set the Y co-ordinate for the high score display. | ||||||||||||||||||
60018 | LD DE,55407 | DE=HighScore. | ||||||||||||||||||
60021 | LD A,6 | Set the number of digits to print in A. | ||||||||||||||||||
60023 | CALL Print_Numbers | Call Print_Numbers. | ||||||||||||||||||
Initialise the cursor/ pointer which highlights the currently selected menu item.
|
||||||||||||||||||||
60026 | LD IX,(55415) | IX=*SelectedMenuItem_ScreenPosition. | ||||||||||||||||||
60030 | LD HL,60216 | HL=SelectedMenuItem. | ||||||||||||||||||
60033 | JR HighlightSelectedMenuItem | Jump to HighlightSelectedMenuItem. | ||||||||||||||||||
Maybe a debounce loop?
|
||||||||||||||||||||
Debounce_Loop | 60035 | XOR A | Get the player input from ALL half-rows (i.e. all the keys). | |||||||||||||||||
60036 | IN A,(254) | |||||||||||||||||||
60038 | CPL | Invert the bits in A. | ||||||||||||||||||
60039 | AND %00011111 | Keep only bits 0-4. | ||||||||||||||||||
60041 | JR NZ,Debounce_Loop | Jump to Debounce_Loop if HL is not zero. | ||||||||||||||||||
Get the player input.
|
||||||||||||||||||||
MainMenuInput_Loop | 60043 | LD A,247 | Read from the keyboard;
|
|||||||||||||||||
60045 | IN A,(254) | |||||||||||||||||||
60047 | CPL | Invert the bits in A. | ||||||||||||||||||
60048 | AND %00011111 | Mask for the key bits. | ||||||||||||||||||
60050 | JR Z,MainMenuInput_Loop | Jump back to MainMenuInput_Loop if no keys are being pressed. | ||||||||||||||||||
Check which key was pressed and handle accordingly.
Handle "KEYBOARD" being selected.
|
||||||||||||||||||||
60052 | RRA | Jump to MainMenuInput_Kempston if "1" was not pressed. | ||||||||||||||||||
60053 | JR NC,MainMenuInput_Kempston | |||||||||||||||||||
60055 | LD A,1 | Jump back to Debounce_Loop if this menu item is already selected. | ||||||||||||||||||
60057 | CP (HL) | |||||||||||||||||||
60058 | JR Z,Debounce_Loop | |||||||||||||||||||
60060 | CALL ClearSelectedMenuItem | Call ClearSelectedMenuItem. | ||||||||||||||||||
60063 | LD IX,22595 | Set the screen position for this option in IX. | ||||||||||||||||||
60067 | LD DE,60260 | Set the address of the input control routine for this option in DE (InputHandler_Keyboard). | ||||||||||||||||||
60070 | JR UpdateMenuSelection | Jump to UpdateMenuSelection. | ||||||||||||||||||
Handle "KEMPSTON" being selected.
|
||||||||||||||||||||
MainMenuInput_Kempston | 60072 | RRA | Jump to MainMenuInput_Cursor if "2" was not pressed. | |||||||||||||||||
60073 | JR NC,MainMenuInput_Cursor | |||||||||||||||||||
60075 | LD A,2 | Jump back to Debounce_Loop if this menu item is already selected. | ||||||||||||||||||
60077 | CP (HL) | |||||||||||||||||||
60078 | JR Z,Debounce_Loop | |||||||||||||||||||
60080 | CALL ClearSelectedMenuItem | Call ClearSelectedMenuItem. | ||||||||||||||||||
60083 | LD IX,22691 | Set the screen position for this option in IX. | ||||||||||||||||||
60087 | LD DE,60312 | Set the address of the input control routine for this option in DE (InputHandler_Kempston). | ||||||||||||||||||
60090 | JR UpdateMenuSelection | Jump to UpdateMenuSelection. | ||||||||||||||||||
Handle "CURSOR" being selected.
|
||||||||||||||||||||
MainMenuInput_Cursor | 60092 | RRA | Jump to MainMenuInput_Sinclair if "3" was not pressed. | |||||||||||||||||
60093 | JR NC,MainMenuInput_Sinclair | |||||||||||||||||||
60095 | LD A,3 | Jump back to Debounce_Loop if this menu item is already selected. | ||||||||||||||||||
60097 | CP (HL) | |||||||||||||||||||
60098 | JR Z,Debounce_Loop | |||||||||||||||||||
60100 | CALL ClearSelectedMenuItem | Call ClearSelectedMenuItem. | ||||||||||||||||||
60103 | LD IX,22787 | Set the screen position for this option in IX. | ||||||||||||||||||
60107 | LD DE,60318 | Set the address of the input control routine for this option in DE (InputHandler_Cursor). | ||||||||||||||||||
60110 | JR UpdateMenuSelection | Jump to UpdateMenuSelection. | ||||||||||||||||||
Handle "SINCLAIR" being selected.
|
||||||||||||||||||||
MainMenuInput_Sinclair | 60112 | RRA | Jump to MainMenuInput_StartGame if "4" was not pressed. | |||||||||||||||||
60113 | JR NC,MainMenuInput_StartGame | |||||||||||||||||||
60115 | LD A,4 | Jump back to Debounce_Loop if this menu item is already selected. | ||||||||||||||||||
60117 | CP (HL) | |||||||||||||||||||
60118 | JR Z,Debounce_Loop | |||||||||||||||||||
60120 | CALL ClearSelectedMenuItem | Call ClearSelectedMenuItem. | ||||||||||||||||||
60123 | LD IX,22883 | Set the screen position for this option in IX. | ||||||||||||||||||
60127 | LD DE,60365 | Set the address of the input control routine for this option in DE (InputHandler_Sinclair). | ||||||||||||||||||
Update menu selection.
|
||||||||||||||||||||
UpdateMenuSelection | 60130 | LD (HL),A | Write the selected menu item to *SelectedMenuItem. | |||||||||||||||||
60131 | LD (60214),DE | Write the address of the input control routine to *Pointer_InputControl. | ||||||||||||||||||
Point to selected menu item.
|
||||||||||||||||||||
HighlightSelectedMenuItem | 60135 | LD (IX+0),69 | Write INK:
CYAN,
PAPER:
BLACK
(BRIGHT)
to:
|
|||||||||||||||||
60139 | LD (IX+1),69 | |||||||||||||||||||
60143 | LD (IX+32),5 | Write INK:
CYAN,
PAPER:
BLACK
to:
|
||||||||||||||||||
60147 | LD (IX+33),5 | |||||||||||||||||||
60151 | LD (55415),IX | Write IX to SelectedMenuItem_ScreenPosition. | ||||||||||||||||||
60155 | JR Debounce_Loop | Jump to Debounce_Loop. | ||||||||||||||||||
Clear previous selected menu item.
|
||||||||||||||||||||
ClearSelectedMenuItem | 60157 | LD (IX+0),0 | Write INK:
BLACK,
PAPER:
BLACK
to:
|
|||||||||||||||||
60161 | LD (IX+1),0 | |||||||||||||||||||
60165 | LD (IX+32),0 | |||||||||||||||||||
60169 | LD (IX+33),0 | |||||||||||||||||||
60173 | RET | Return. | ||||||||||||||||||
Note; there's no need for the "not pressed" check, as there are only five options.
Handle "START GAME" being selected.
Uncover the "Good Luck" messaging (it's already present, just black on black).
|
||||||||||||||||||||
MainMenuInput_StartGame | 60174 | LD HL,23094 | HL=23094 (attribute buffer location). | |||||||||||||||||
60177 | LD DE,32 | DE=0032. | ||||||||||||||||||
60180 | LD B,4 | Set a counter in B for the number of rows to process. | ||||||||||||||||||
GoodLuck_OuterLoop | 60182 | PUSH BC | Stash the row counter on the stack. | |||||||||||||||||
60183 | LD B,8 | Set a counter in B for the width of the messaging. | ||||||||||||||||||
60185 | PUSH HL | Stash the starting position in the attribute buffer on the stack. | ||||||||||||||||||
GoodLuck_InnerLoop | 60186 | LD (HL),71 | Write INK: WHITE, PAPER: BLACK (BRIGHT) to *HL. | |||||||||||||||||
60188 | INC HL | Increment attribute buffer screen position by one. | ||||||||||||||||||
60189 | DJNZ GoodLuck_InnerLoop | Decrease width counter by one and loop back to GoodLuck_InnerLoop until all the width has been coloured. | ||||||||||||||||||
60191 | POP HL | Restore the attribute buffer starting position from the stack. | ||||||||||||||||||
60192 | ADD HL,DE | HL+=0032 (move down one row). | ||||||||||||||||||
60193 | POP BC | Restore the row counter from the stack. | ||||||||||||||||||
60194 | DJNZ GoodLuck_OuterLoop | Decrease the row counter by one and loop back to GoodLuck_OuterLoop until the row counter is zero. | ||||||||||||||||||
60196 | LD HL,60217 | Write 1 to 60217. | ||||||||||||||||||
60199 | LD (HL),1 | |||||||||||||||||||
60201 | PUSH HL | Stash 60217 on the stack. | ||||||||||||||||||
60202 | LD HL,60218 | HL=60218. | ||||||||||||||||||
60205 | LD B,14 | B=14. | ||||||||||||||||||
60207 | CALL 61258 | Call 61258. | ||||||||||||||||||
60210 | POP HL | Restore HL from the stack. | ||||||||||||||||||
60211 | LD (HL),0 | Write 0 to *HL. | ||||||||||||||||||
60213 | RET | Return. |
Prev: 59951 | Up: Map | Next: 60214 |