| Chase H.Q. | Routines |
| Prev: ECF3 | Up: Map | Next: ED6D |
|
Used by the routine at define_a_key.
|
||||||||||
| keyscan_all | ED4D | LD DE,$FF2F | D = flag/counter? (255 to start), E = initial key and row counters (47 to start) | |||||||
| ED50 | LD BC,$FEFE | Set B to $FE (initial keyboard half-row selector) and C to $FE (keyboard port number) | ||||||||
|
Start loop.
|
||||||||||
| ka_loop | ED53 | IN A,(C) | Read port $<BC> | |||||||
| ED55 | CPL | Complement the value returned to change it from active-low to active-high | ||||||||
| ED56 | AND $1F | Discard any non-key flags | ||||||||
| ED58 | JR Z,keyscan_all_1 | Jump to next iteration if no keys were pressed | ||||||||
|
Keys were pressed.
|
||||||||||
| ED5A | INC D | ?If D's 255 here we're okay. anything else causes an exit | ||||||||
| ED5B | RET NZ | Return if D is non-zero | ||||||||
| ED5C | LD H,A | Copy key flags to H | ||||||||
| ED5D | LD A,E | Copy key and row counters to A | ||||||||
| keyscan_all_0 | ED5E | SUB $08 | Decrement key counter bitfield in A | |||||||
| ED60 | SRL H | Shift a key bit out of H into the carry flag | ||||||||
| ED62 | JR NC,keyscan_all_0 | Loop until we hit a set bit (at least one must be set since the zero case is handled earlier) | ||||||||
| ED64 | RET NZ | Return if additional bits are set | ||||||||
| ED65 | LD D,A | Set return value in D | ||||||||
| keyscan_all_1 | ED66 | DEC E | Decrement E | |||||||
| ED67 | RLC B | Rotate the half-row selector ($FE -> $FD -> $FB -> .. -> $7F) | ||||||||
| ED69 | JR C,ka_loop | ...loop until the zero bit shifts out (eight iterations) | ||||||||
| ED6B | CP A | Set Z | ||||||||
| ED6C | RET | |||||||||
| Prev: ECF3 | Up: Map | Next: ED6D |