![]() |
Routines |
| Prev: 37051 | Up: Map | Next: 37182 |
|
|
||||
| Controls | 37080 | XOR A | Write 0 to *LAST-K (last key pressed). | |
| 37081 | LD (23560),A | |||
| 37084 | LD A,(37182) | Jump to Controls_ReadKeyboard if *UserDefinedKeys is not equal to 6. | ||
| 37087 | CP 6 | |||
| 37089 | JR NZ,Controls_ReadKeyboard | |||
| 37091 | CALL Controls_ReadKempston | Call Controls_ReadKempston. | ||
| 37094 | LD A,C | A=Player input. | ||
| 37095 | INC C | Jump to Controls_NoInput if no input was detected (255 for "no input was made"). | ||
| 37096 | JR Z,Controls_NoInput | |||
| 37098 | JR Controls_0 | Jump to Controls_0. | ||
| Controls_ReadKeyboard | 37100 | CALL 703 | Call KEYBOARD. | |
| 37103 | LD HL,37182 | HL=UserDefinedKeys. | ||
| 37106 | LD A,(23560) | A=*LAST-K (last key pressed). | ||
| 37109 | CP 14 | Jump to QuitGame if A is equal to 14. | ||
| 37111 | JP Z,QuitGame | |||
|
Detect the keyboard input.
|
||||
| 37114 | LD B,5 | Set a counter of 5 for the number of controls to be read. | ||
| Controls_ReadKeyboard_Loop | 37116 | CP (HL) | Jump to Controls_HandleKeyPress if the currently pressed key is equal to *HL. | |
| 37117 | JR Z,Controls_HandleKeyPress | |||
| 37119 | INC HL | Increment HL by two. | ||
| 37120 | INC HL | |||
| 37121 | DJNZ Controls_ReadKeyboard_Loop | Decrease counter by one and loop back to Controls_ReadKeyboard_Loop until counter is zero. | ||
|
No input was detected so return with 255.
|
||||
| Controls_NoInput | 37123 | LD A,255 | A=255. | |
| 37125 | RET | Return. | ||
|
A valid key press was detected, handle it.
|
||||
| Controls_HandleKeyPress | 37126 | INC HL | Increment HL by one. | |
| 37127 | LD A,(HL) | A=*HL. | ||
| Controls_0 | 37128 | PUSH AF | Stash AF on the stack. | |
| 37129 | LD A,(37573) | Jump to PlaySelectWaveSound if *37573 is not zero. | ||
| 37132 | OR A | |||
| 37133 | JR NZ,PlaySelectWaveSound | |||
| 37135 | LD A,(37182) | Jump to DebounceLoop if *UserDefinedKeys is not equal to 6. | ||
| 37138 | CP 6 | |||
| 37140 | JR NZ,DebounceLoop | |||
| Controls_1 | 37142 | CALL Controls_ReadKempston | Call Controls_ReadKempston. | |
| 37145 | INC C | Increment C by one. | ||
| 37146 | JR NZ,Controls_1 | Jump to Controls_1 if C is not zero. | ||
| 37148 | JR PlaySelectWaveSound | Jump to PlaySelectWaveSound. | ||
|
Debounce the key press.
|
||||
| DebounceLoop | 37150 | CALL 654 | Call KEY_SCAN. | |
|
Handle if no keys are being pressed, for reference:
In all instances the E register is returned with a value in the range of +0 to +39 the value being different for each of the forty keys of the keyboard, or the value +255 for no-key. |
||||
| 37153 | INC E | Set the zero flag if no keys have been pressed. | ||
| 37154 | JR NZ,DebounceLoop | Jump to DebounceLoop unless no keys are being pressed. | ||
|
Play the "select" key wave sound.
|
||||
| PlaySelectWaveSound | 37156 | XOR A | Write 0 to *37573. | |
| 37157 | LD (37573),A | |||
| 37160 | POP AF | Restore AF from the stack. | ||
| 37161 | OR A | Return if A is not zero. | ||
| 37162 | RET NZ | |||
| 37163 | DI | Disable interrupts. | ||
| 37164 | LD B,201 | B=201. | ||
| 37166 | LD A,252 | A=252. | ||
| SelectSoundLoop | 37168 | LD C,50 | C=50. | |
| SelectSoundDurationLoop | 37170 | DEC C | Decrease C by one. | |
| 37171 | JR NZ,SelectSoundDurationLoop | Jump to SelectSoundDurationLoop until C is zero. | ||
| 37173 | OUT (254),A | Flip the speaker bit (bit 4), and send the result to the speaker. | ||
| 37175 | XOR %00010000 | |||
| 37177 | DJNZ SelectSoundLoop | Decrease counter by one and loop back to SelectSoundLoop until counter is zero. | ||
| 37179 | XOR A | A=0. | ||
| 37180 | EI | Enable interrupts. | ||
| 37181 | RET | Return. | ||
| Prev: 37051 | Up: Map | Next: 37182 |