Prev: 8CDB Up: Map Next: 8E42
8D99: Game Settings - Redefine Keys
Used by the routine at Game_Configs_Controls.
Game_Configs_Keys 8D99 CALL Clear_Screen Call Clear_Screen.
Displays the "for each direction ... press key" banner.
8D9C LD DE,$8F6B Point to Text_Change_1 and call Print_String.
8D9F LD HL,$012D
8DA2 CALL Print_String
8DA5 LD DE,$8F89 Point to Text_Change_2 and call Print_String.
8DA8 LD HL,$0136
8DAB CALL Print_String
8DAE LD DE,$8FA7 Point to Text_Change_3 and call Print_String.
8DB1 LD HL,$013F
8DB4 CALL Print_String
Set that this player should use the "redefined keys" for their input.
8DB7 LD HL,($8E69) Fetch the current player from Temp_Player, and set it in both DE and HL.
8DBA LD DE,($8E69)
8DBE INC DE Increase DE by two to point to the beginning of that players redefined keys map.
8DBF INC DE
8DC0 LD (HL),E Stores either Player_1_Up or Player_2_Up at the address for the player control method.
8DC1 INC HL
8DC2 LD (HL),D
Go through each key and process.
8DC3 LD HL,$8FBB Point to Text_Up and call Print_Key_Loop.
8DC6 CALL Print_Key_Loop
8DC9 LD HL,$8FBE Point to Text_Up_Right and call Print_Key_Loop.
8DCC CALL Print_Key_Loop
8DCF LD HL,$8FC7 Point to Text_Right and call Print_Key_Loop.
8DD2 CALL Print_Key_Loop
8DD5 LD HL,$8FCD Point to Text_Down_Right and call Print_Key_Loop.
8DD8 CALL Print_Key_Loop
8DDB LD HL,$8FD8 Point to Text_Down and call Print_Key_Loop.
8DDE CALL Print_Key_Loop
8DE1 LD HL,$8FDD Point to Text_Down_Left and call Print_Key_Loop.
8DE4 CALL Print_Key_Loop
8DE7 LD HL,$8FE7 Point to Text_Left and call Print_Key_Loop.
8DEA CALL Print_Key_Loop
8DED LD HL,$8FEC Point to Text_Up_Left and call Print_Key_Loop.
8DF0 CALL Print_Key_Loop
8DF3 LD HL,$8FF4 Point to Text_Fire and call Print_Key_Loop.
8DF6 CALL Print_Key_Loop
8DF9 JP Game_Configs_Return Jump to Game_Configs_Return.
Print the message, get the key and write it to the mapping buffer for this player.
Print_Key_Loop 8DFC PUSH DE Stash the current key mapping address on the stack.
8DFD EX DE,HL Use Print_String to show the message for which key to press.
8DFE LD HL,$055C
8E01 CALL Print_String
8E04 POP DE Fetch the current key mapping address from the stack.
8E05 PUSH DE Stash it again for later.
8E06 CALL Get_Key Call Get_Key.
8E09 POP DE Fetch the current key mapping address from the stack.
8E0A EX DE,HL Writes the port number and key byte to the current key mapping address.
8E0B LD (HL),E
8E0C INC HL
8E0D LD (HL),D
8E0E INC HL
8E0F EX DE,HL
8E10 PUSH DE Stash the next key mapping address on the stack.
8E11 LD DE,$9000 Blank out the "press key" message with whitespace.
8E14 LD HL,$055C
8E17 CALL Print_String
8E1A CALL Configs_Delay Delay (for debounce) twice Configs_Delay.
8E1D CALL Configs_Delay
8E20 POP DE Restores the current key location off the stack.
8E21 RET Return.
Detect the key press.
Get_Key 8E22 LD DE,$8E3A DE=Key_Data.
8E25 LD B,$08 Set a counter B=08.
Get_Key_Loop 8E27 LD A,(DE) Using the current port, read the keyboard.
8E28 IN A,($FE)
8E2A CPL Is a key being pressed?
8E2B AND $1F
8E2D JP NZ,Store_Key Yes - jump to Store_Key.
8E30 INC DE Increase DE by one.
8E31 DJNZ Get_Key_Loop Decrease counter by one and loop back to Get_Key_Loop until counter is zero.
8E33 JP Get_Key Jump to Get_Key.
Stores the port number as the MSB of HL, and the key byte as the LSB.
Store_Key 8E36 LD L,A Store the key byte as the LSB of HL.
8E37 LD A,(DE) Store the port number from DE as the MSB of HL.
8E38 LD H,A
8E39 RET Return.
The keyboard is split into 8 sections - 4 'half rows' on each side, and each with a unique port number.
Port Number Bit
0 1 2 3 4
v$FE SHIFT Z X C V
FD A S D F G
FB Q W E R T
F7 1 2 3 4 5
EF 0 9 8 7 6
DF P O I U Y
BF ENTER L K J H
7F SPACE FULL-STOP M N B
Key_Data 8E3A DEFB $FE,$FD,$FB,$F7,$EF,$DF,$BF,$7F Key Data
Prev: 8CDB Up: Map Next: 8E42