| Chase H.Q. | Routines |
| Prev: ED4D | Up: Map | Next: EDD6 |
|
Waits for an unambiguous key press, rejects it if that key is already in use, stores it in temp_keydefs, then looks the key's two-character name up in key_names and draws it at DE. The screen address is advanced by one character row on the way out, and by two when B is 4, which is the gap in the middle of the printed list.
Used by the routine at redefine_keys_48k.
|
||||||||||||||||
| define_a_key | ED6D | PUSH DE | Preserve DE, BC | |||||||||||||
| ED6E | PUSH BC | |||||||||||||||
| dak_loop1 | ED6F | CALL play_music_48k | Call play_music_48k | |||||||||||||
| ED72 | CALL redefine_keyscan | Call redefine_keyscan | ||||||||||||||
| ED75 | JR NZ,dak_loop1 | Loop while the scan was ambiguous | ||||||||||||||
| ED77 | INC D | Loop while no key at all was down ($FF) | ||||||||||||||
| ED78 | JR Z,dak_loop1 | |||||||||||||||
| ED7A | DEC D | D-- | ||||||||||||||
| ED7B | LD A,D | A = D | ||||||||||||||
| ED7C | POP BC | Retrieve index in C | ||||||||||||||
| ED7D | PUSH BC | |||||||||||||||
| ED7E | LD HL,$EE38 | Point HL at temp_keydefs | ||||||||||||||
| ED81 | LD B,C | B = C - 1 | ||||||||||||||
| ED82 | DEC B | |||||||||||||||
| ED83 | JR Z,dak_store | Jump if zero -- can't be used | ||||||||||||||
|
Checking for existing uses of that key.
|
||||||||||||||||
| dak_check_used | ED85 | CP (HL) | ||||||||||||||
| ED86 | JR Z,dak_loop1 | Already used - try again | ||||||||||||||
| ED88 | INC HL | HL++ | ||||||||||||||
| ED89 | DJNZ dak_check_used | Loop while B > 0 | ||||||||||||||
| dak_store | ED8B | POP BC | Retrieve index in C | |||||||||||||
| ED8C | PUSH BC | |||||||||||||||
| ED8D | LD HL,$EE37 | Point at temp_keydefs (1-indexed) | ||||||||||||||
| ED90 | LD B,$00 | BC = C to widen the index | ||||||||||||||
| ED92 | ADD HL,BC | Write byte | ||||||||||||||
| ED93 | LD (HL),A | |||||||||||||||
| ED94 | LD HL,$EDD6 | Point at key names (two chars per key) | ||||||||||||||
| ED97 | LD D,$00 | D = 0 | ||||||||||||||
| ED99 | LD B,A | B = A | ||||||||||||||
| ED9A | AND $07 | A &= 7 -- half row | ||||||||||||||
| ED9C | LD C,A | A *= 5 -- multiply half row by 5 | ||||||||||||||
| ED9D | ADD A,A | |||||||||||||||
| ED9E | ADD A,A | |||||||||||||||
| ED9F | ADD A,C | |||||||||||||||
| EDA0 | SRL B | B >>= 3 -- key | ||||||||||||||
| EDA2 | SRL B | |||||||||||||||
| EDA4 | SRL B | |||||||||||||||
| EDA6 | ADD A,B | A += B | ||||||||||||||
| EDA7 | ADD A,A | A += A | ||||||||||||||
| EDA8 | LD E,A | DE = A (D is zero) | ||||||||||||||
| EDA9 | ADD HL,DE | HL += DE | ||||||||||||||
| EDAA | POP BC | Retrieve the index (BC) and the screen address (DE), stacking them again with DE on top | ||||||||||||||
| EDAB | POP DE | |||||||||||||||
| EDAC | PUSH BC | |||||||||||||||
| EDAD | PUSH DE | |||||||||||||||
| EDAE | LD ($EADD),DE | Poke screen address into key string | ||||||||||||||
| EDB2 | LD A,(HL) | A = *HL -- read a byte of key name | ||||||||||||||
| EDB3 | LD ($EADF),A | Poke first byte of key name | ||||||||||||||
| EDB6 | INC HL | HL++ | ||||||||||||||
| EDB7 | LD A,(HL) | A = *HL -- read another byte of key name | ||||||||||||||
| EDB8 | SET 7,A | Terminate the second byte | ||||||||||||||
| EDBA | LD ($EAE0),A | Poke into key string | ||||||||||||||
| EDBD | LD HL,$EADC | Draw the key string | ||||||||||||||
| EDC0 | CALL menu_draw_string | |||||||||||||||
| EDC3 | POP DE | |||||||||||||||
| EDC4 | CALL dak_move_down | Move DE down one character row | ||||||||||||||
| EDC7 | POP BC | |||||||||||||||
| EDC8 | LD A,B | Return if B != 4 | ||||||||||||||
| EDC9 | CP $04 | |||||||||||||||
| EDCB | RET NZ | |||||||||||||||
| dak_move_down | EDCC | LD A,E | E += 32 | |||||||||||||
| EDCD | ADD A,$20 | |||||||||||||||
| EDCF | LD E,A | |||||||||||||||
| EDD0 | RET NC | |||||||||||||||
| EDD1 | LD A,D | D += 8 | ||||||||||||||
| EDD2 | ADD A,$08 | |||||||||||||||
| EDD4 | LD D,A | |||||||||||||||
| EDD5 | RET | Return | ||||||||||||||
| Prev: ED4D | Up: Map | Next: EDD6 |