Prev: 6F94 Up: Map Next: 7049
6F9A: Collect User-Defined Keys
Used by the routine at TitleScreen_DefineKeysSelected.
CollectUserDefinedKeys 6F9A LD A,$01 Write 01 to *CurrentIndexUserDefinedKey.
6F9C LD ($7049),A
6F9F LD HL,$6F6D HL=KeyboardKeymap.
Blank the first entry of all five user-defined key sets.
6FA2 LD B,$05 B=05.
BlankUserDefinedKeys_Loop 6FA4 LD (HL),$00 Write 00 to *HL.
6FA6 INC HL Increment HL by two.
6FA7 INC HL
6FA8 DJNZ BlankUserDefinedKeys_Loop Decrease counter by one and loop back to BlankUserDefinedKeys_Loop until counter is zero.
Debounce Loop.
UserDefinedKeyDebounce_Loop 6FAA CALL $028E Call KEY_SCAN.
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.
6FAD INC E Increment E by one.
6FAE JR NZ,UserDefinedKeyDebounce_Loop Jump to UserDefinedKeyDebounce_Loop until E is zero (e.g. no keys are being pressed).
Get ready to collect keypresses.
6FB0 XOR A Write 00 to LAST-K (last key pressed).
6FB1 LD ($5C08),A
UserDefinedKeyCollectInput_Loop 6FB4 LD C,$05 C=INK: CYAN, PAPER: BLACK .
6FB6 CALL FindUserDefinedKeyAttribute Call FindUserDefinedKeyAttribute.
UserDefinedKeyCollectInput 6FB9 CALL $02BF Call KEYBOARD.
6FBC BIT 5,(IY+$01) Jump to UserDefinedKeyCollectInput if no key was pressed.
6FC0 JR Z,UserDefinedKeyCollectInput
6FC2 LD A,($5C08) A=*LAST-K (last key pressed).
6FC5 CP $0D Jump to FindExistingKeyboardKeymap if A is equal to 0D.
6FC7 JR Z,FindExistingKeyboardKeymap
6FC9 CP $20 Jump to FindExistingKeyboardKeymap if A is equal to 20.
6FCB JR Z,FindExistingKeyboardKeymap
6FCD CP $30 Jump to UserDefinedKeyCollectInput if A is lower than 30.
6FCF JR C,UserDefinedKeyCollectInput
6FD1 CP $5B Jump to UserDefinedKeyCollectInput if A is higher than 5B.
6FD3 JR NC,UserDefinedKeyCollectInput
6FD5 CP $41 Jump to FindExistingKeyboardKeymap if A is higher than 41.
6FD7 JR NC,FindExistingKeyboardKeymap
6FD9 CP $3A Jump to UserDefinedKeyCollectInput if A is higher than 3A.
6FDB JR NC,UserDefinedKeyCollectInput
Check if the key which has been pressed already exists for any other key.
FindExistingKeyboardKeymap 6FDD LD HL,$6F6D HL=KeyboardKeymap.
6FE0 LD D,A Store the keypress in D.
6FE1 LD B,$05 Set a counter in B as there are 05 keys to check in total.
FindExistingKeyboardKeymap_Loop 6FE3 LD A,(HL) Jump to UserDefinedKeyCollectInput if the current keypress already exists in the user-defined keymap table.
6FE4 CP D
6FE5 JR Z,UserDefinedKeyCollectInput
6FE7 INC HL Increment HL by two.
6FE8 INC HL
6FE9 DJNZ FindExistingKeyboardKeymap_Loop Decrease the keymap counter by one and loop back to FindExistingKeyboardKeymap_Loop until all keymaps have been checked.
The keypress is good, so find the keyboard keymap position we need to update.
6FEB LD A,($7049) Set a counter in B of *CurrentIndexUserDefinedKey.
6FEE LD B,A
6FEF LD HL,$6F6B HL=6F6B (e.g. KeyboardKeymap-02).
FindCurrentKeyboardKeymap_Loop 6FF2 INC HL Increment HL by two.
6FF3 INC HL
6FF4 DJNZ FindCurrentKeyboardKeymap_Loop Decrease counter by one and loop back to FindCurrentKeyboardKeymap_Loop until counter is zero.
6FF6 LD (HL),D Write the keypress to *HL and also stash it on the stack.
6FF7 PUSH DE
Calculate the screen co-ordinates.
B, the row, is a simple calculation of: 18-*CurrentIndexUserDefinedKey.
C, the column, will always be 0B.
6FF8 LD B,A Calculate the screen co-ordinates for the index currently in-focus and store them in BC.
6FF9 LD A,$18
6FFB SUB B
6FFC LD B,A
6FFD LD C,$0B
Convert the screen co-ordinates into a screen buffer location pointer.
6FFF CALL $0DE2 Call 0DE2 (CL_SET).
7002 POP DE Fetch the keypress from the stack and store it in A.
7003 LD A,D
Handle printing keywords for control keys (which are still valid as choose-able keys).
7004 CP $0D Jump to Print_Enter if "enter" is the keypress.
7006 JR Z,Print_Enter
7008 CP $20 Jump to Print_Space if "space" is the keypress.
700A JR Z,Print_Space
Else, it's a printable character so display it.
700C RST $10 Print the character to the screen.
PrintWhitespace 700D LD B,$04 Set a counter in B to print 04 ASCII spaces.
PrintWhitespace_Loop 700F LD A,$20 Print an ASCII space " ".
7011 RST $10
7012 DJNZ PrintWhitespace_Loop Decrease the space counter by one and loop back to PrintWhitespace_Loop until the counter is zero.
7014 LD C,$07 C=INK: WHITE, PAPER: BLACK .
7016 CALL FindUserDefinedKeyAttribute Call FindUserDefinedKeyAttribute.
Move to the next user-defined key index.
7019 LD A,($7049) A=*CurrentIndexUserDefinedKey.
701C INC A Increment A by one.
701D LD ($7049),A Write A to *CurrentIndexUserDefinedKey.
7020 CP $06 Keep jumping back to UserDefinedKeyCollectInput_Loop until all user-defined keys have been collected.
7022 JR NZ,UserDefinedKeyCollectInput_Loop
7024 RET Return.
Prints the word "SPACE".
Print_Space 7025 LD HL,$7A41 HL=Messaging_Space.
7028 CALL $187D Call OUT_LINE2.
702B JR PrintWhitespace Jump to PrintWhitespace.
Prints the word "ENTER".
Print_Enter 702D LD HL,$7A47 HL=Messaging_Enter.
7030 CALL $187D Call OUT_LINE2.
7033 JR PrintWhitespace Jump to PrintWhitespace.
580B+(20*CurrentIndexUserDefinedKey) to find the attribute buffer address for the user-defined key currently being processed.
FindUserDefinedKeyAttribute 7035 LD HL,$580B HL=580B (attribute buffer location).
7038 LD DE,$0020 DE=0020.
703B LD A,($7049) A=*CurrentIndexUserDefinedKey.
FindUserDefinedKeyAttribute_Loop 703E ADD HL,DE HL+=0020.
703F DEC A Decrease the index by one.
7040 JR NZ,FindUserDefinedKeyAttribute_Loop Keep jumping back to FindUserDefinedKeyAttribute_Loop until the index is zero.
HL now holds a pointer to the attribute line for the user-defined key currently being processed.
7042 LD B,$14 Set a counter in B for 14 character blocks to "paint".
SetUserDefinedKeyAttribute_Loop 7044 LD (HL),C Write the attribute byte held by C to *HL.
7045 INC HL Increment HL by one.
7046 DJNZ SetUserDefinedKeyAttribute_Loop Decrease counter by one and loop back to SetUserDefinedKeyAttribute_Loop until counter is zero.
7048 RET Return.
Prev: 6F94 Up: Map Next: 7049