Prev: 36059 Up: Map Next: 36418
36249: Game Settings - Redefine Keys
Used by the routine at Game_Configs_Controls.
Game_Configs_Keys 36249 CALL Clear_Screen Call Clear_Screen.
Displays the "for each direction ... press key" banner.
36252 LD DE,36715 Point to Text_Change_1 and call Print_String.
36255 LD HL,301
36258 CALL Print_String
36261 LD DE,36745 Point to Text_Change_2 and call Print_String.
36264 LD HL,310
36267 CALL Print_String
36270 LD DE,36775 Point to Text_Change_3 and call Print_String.
36273 LD HL,319
36276 CALL Print_String
Set that this player should use the "redefined keys" for their input.
36279 LD HL,(36457) Fetch the current player from Temp_Player, and set it in both DE and HL.
36282 LD DE,(36457)
36286 INC DE Increase DE by two to point to the beginning of that players redefined keys map.
36287 INC DE
36288 LD (HL),E Stores either Player_1_Up or Player_2_Up at the address for the player control method.
36289 INC HL
36290 LD (HL),D
Go through each key and process.
36291 LD HL,36795 Point to Text_Up and call Print_Key_Loop.
36294 CALL Print_Key_Loop
36297 LD HL,36798 Point to Text_Up_Right and call Print_Key_Loop.
36300 CALL Print_Key_Loop
36303 LD HL,36807 Point to Text_Right and call Print_Key_Loop.
36306 CALL Print_Key_Loop
36309 LD HL,36813 Point to Text_Down_Right and call Print_Key_Loop.
36312 CALL Print_Key_Loop
36315 LD HL,36824 Point to Text_Down and call Print_Key_Loop.
36318 CALL Print_Key_Loop
36321 LD HL,36829 Point to Text_Down_Left and call Print_Key_Loop.
36324 CALL Print_Key_Loop
36327 LD HL,36839 Point to Text_Left and call Print_Key_Loop.
36330 CALL Print_Key_Loop
36333 LD HL,36844 Point to Text_Up_Left and call Print_Key_Loop.
36336 CALL Print_Key_Loop
36339 LD HL,36852 Point to Text_Fire and call Print_Key_Loop.
36342 CALL Print_Key_Loop
36345 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 36348 PUSH DE Stash the current key mapping address on the stack.
36349 EX DE,HL Use Print_String to show the message for which key to press.
36350 LD HL,1372
36353 CALL Print_String
36356 POP DE Fetch the current key mapping address from the stack.
36357 PUSH DE Stash it again for later.
36358 CALL Get_Key Call Get_Key.
36361 POP DE Fetch the current key mapping address from the stack.
36362 EX DE,HL Writes the port number and key byte to the current key mapping address.
36363 LD (HL),E
36364 INC HL
36365 LD (HL),D
36366 INC HL
36367 EX DE,HL
36368 PUSH DE Stash the next key mapping address on the stack.
36369 LD DE,36864 Blank out the "press key" message with whitespace.
36372 LD HL,1372
36375 CALL Print_String
36378 CALL Configs_Delay Delay (for debounce) twice Configs_Delay.
36381 CALL Configs_Delay
36384 POP DE Restores the current key location off the stack.
36385 RET Return.
Detect the key press.
Get_Key 36386 LD DE,36410 DE=Key_Data.
36389 LD B,8 Set a counter B=8.
Get_Key_Loop 36391 LD A,(DE) Using the current port, read the keyboard.
36392 IN A,(254)
36394 CPL Is a key being pressed?
36395 AND 31
36397 JP NZ,Store_Key Yes - jump to Store_Key.
36400 INC DE Increase DE by one.
36401 DJNZ Get_Key_Loop Decrease counter by one and loop back to Get_Key_Loop until counter is zero.
36403 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 36406 LD L,A Store the key byte as the LSB of HL.
36407 LD A,(DE) Store the port number from DE as the MSB of HL.
36408 LD H,A
36409 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
253 A S D F G
251 Q W E R T
247 1 2 3 4 5
239 0 9 8 7 6
223 P O I U Y
191 ENTER L K J H
127 SPACE FULL-STOP M N B
Key_Data 36410 DEFB 254,253,251,247,239,223,191,127 Key Data
Prev: 36059 Up: Map Next: 36418