;GETKD/GETKDH ; Direct Input Routines for the 83/83+ ; ; By Joe Pemberton (joe@joepnet.com) ; ;GetKD will return b with the following bits reset (if the keys are down): ;bit 0 - down ;bit 1 - left ;bit 2 - right ;bit 3 - up ;bit 4 - 2nd ;bit 5 - mode ;bit 6 - clear ;bit 7 - enter ; ; GetKDH will do the same, but it will not repeat on 2nd, mode, clear or enter (i.e. ; if you press enter you must release it before GetKDH will detect it again) The arrow ; keys will always repeat. ; ; ;============= key equates for getkd(h) ============= KDB_DOWN = 0 KD_DOWN = %11111110 KDB_LEFT = 1 KD_LEFT = %11111101 KDB_RIGHT = 2 KD_RIGHT = %11111011 KDB_UP = 3 KD_UP = %11110111 KDB_2ND = 4 KD_2ND = %11101111 KDB_MODE = 5 KD_MODE = %11011111 KDB_CLEAR = 6 KD_CLEAR = %10111111 KDB_ENTER = 7 KD_ENTER = %01111111 KD_MASK = %11110000 ;do not repeat keys for bits 4-7 ;change this mask to make different keys repeat ================= routine =================== getkdh: call getkd ld hl,getkdflag ld a,b ld c,b or (hl) ld b,a ld a,c cpl and KD_MASK ld (hl),a ei halt ;to mimic _getcsc ret getkd: ld a,$ff ld b,a out (1),a ld a,$fe out (1),a in a,(1) and b ld b,a ;bits 0,1,2,3 are the arrows ld a,$ff out (1),a ld a,$fd out (1),a in a,(1) ;catch enter/clear keypress or %10111110 ;only get enter/clear keypress rrca ;enter keypress is in bit 7, clear in bit 5 bit 5,a jr nz,getkd2 xor %01100000 getkd2: and b ld b,a ;bit 7 is the enter key ld a,$ff out (1),a ld a,$bf out (1),a in a,(1) rra or %11001111 ;only get 2nd/mode and b ld b,a ret getkdflag: .db 0