Prev: 90BB Up: Map Next: 913E
90D8: Controls: Get Input
Used by the routines at Messaging_Girl, MarkCards, InGameControls and HandlerRaising.
Controls 90D8 XOR A Write 00 to *LAST-K (last key pressed).
90D9 LD ($5C08),A
90DC LD A,($913E) Jump to Controls_ReadKeyboard if *UserDefinedKeys is not equal to 06.
90DF CP $06
90E1 JR NZ,Controls_ReadKeyboard
90E3 CALL Controls_ReadKempston Call Controls_ReadKempston.
90E6 LD A,C A=Player input.
90E7 INC C Jump to Controls_NoInput if no input was detected (FF for "no input was made").
90E8 JR Z,Controls_NoInput
90EA JR Controls_0 Jump to Controls_0.
Controls_ReadKeyboard 90EC CALL $02BF Call KEYBOARD.
90EF LD HL,$913E HL=UserDefinedKeys.
90F2 LD A,($5C08) A=*LAST-K (last key pressed).
90F5 CP $0E Jump to QuitGame if A is equal to 0E.
90F7 JP Z,QuitGame
Detect the keyboard input.
90FA LD B,$05 Set a counter of 05 for the number of controls to be read.
Controls_ReadKeyboard_Loop 90FC CP (HL) Jump to Controls_HandleKeyPress if the currently pressed key is equal to *HL.
90FD JR Z,Controls_HandleKeyPress
90FF INC HL Increment HL by two.
9100 INC HL
9101 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 FF.
Controls_NoInput 9103 LD A,$FF A=FF.
9105 RET Return.
A valid key press was detected, handle it.
Controls_HandleKeyPress 9106 INC HL Increment HL by one.
9107 LD A,(HL) A=*HL.
Controls_0 9108 PUSH AF Stash AF on the stack.
9109 LD A,($92C5) Jump to PlaySelectWaveSound if *92C5 is not zero.
910C OR A
910D JR NZ,PlaySelectWaveSound
910F LD A,($913E) Jump to DebounceLoop if *UserDefinedKeys is not equal to 06.
9112 CP $06
9114 JR NZ,DebounceLoop
Controls_1 9116 CALL Controls_ReadKempston Call Controls_ReadKempston.
9119 INC C Increment C by one.
911A JR NZ,Controls_1 Jump to Controls_1 if C is not zero.
911C JR PlaySelectWaveSound Jump to PlaySelectWaveSound.
Debounce the key press.
DebounceLoop 911E CALL $028E 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 +00 to +27 the value being different for each of the forty keys of the keyboard, or the value +FF for no-key.
9121 INC E Set the zero flag if no keys have been pressed.
9122 JR NZ,DebounceLoop Jump to DebounceLoop unless no keys are being pressed.
Play the "select" key wave sound.
PlaySelectWaveSound 9124 XOR A Write 00 to *92C5.
9125 LD ($92C5),A
9128 POP AF Restore AF from the stack.
9129 OR A Return if A is not zero.
912A RET NZ
912B DI Disable interrupts.
912C LD B,$C9 B=C9.
912E LD A,$FC A=FC.
SelectSoundLoop 9130 LD C,$32 C=32.
SelectSoundDurationLoop 9132 DEC C Decrease C by one.
9133 JR NZ,SelectSoundDurationLoop Jump to SelectSoundDurationLoop until C is zero.
9135 OUT ($FE),A Flip the speaker bit (bit 4), and send the result to the speaker.
9137 XOR %00010000
9139 DJNZ SelectSoundLoop Decrease counter by one and loop back to SelectSoundLoop until counter is zero.
913B XOR A A=00.
913C EI Enable interrupts.
913D RET Return.
Prev: 90BB Up: Map Next: 913E