Routines |
Prev: F408 | Up: Map | Next: F43D |
This scans for keys that select an input device.
Used by the routine at check_menu_keys.
|
||||||||
menu_keyscan | F41C | LD BC,$F7FE | Set BC to port_KEYBOARD_12345 | |||||
F41F | LD E,$00 | Initialise a counter | ||||||
F421 | IN A,(C) | Read the port | ||||||
F423 | CPL | Invert the bits to turn active low into active high | ||||||
F424 | AND $0F | Mask off bits for 1,2,3,4 | ||||||
F426 | JR Z,mk_check_for_0 | If none were pressed then check for zero | ||||||
Which key was pressed?
|
||||||||
F428 | LD B,$04 | Set B for 4 iterations | ||||||
Start loop
|
||||||||
mk_loop | F42A | RRA | Shift out a bit | |||||
F42B | INC E | Increment the counter | ||||||
F42C | JR C,mk_found | Did a bit carry out? Jump if so | ||||||
F42E | DJNZ mk_loop | ...loop | ||||||
mk_found | F430 | LD A,E | Return 1..4 | |||||
F431 | RET | |||||||
mk_check_for_0 | F432 | LD B,$EF | Set BC to port_KEYBOARD_09876 | |||||
F434 | IN A,(C) | Read the port | ||||||
F436 | AND $01 | Was 0 pressed? (note active low) | ||||||
F438 | LD A,E | Return 0 if so | ||||||
F439 | RET Z | |||||||
F43A | LD A,$FF | Otherwise return $FF | ||||||
F43C | RET |
Prev: F408 | Up: Map | Next: F43D |