0 Members and 2 Guests are viewing this topic.
;------ GetCSC -----------------------------------------------------------------RawGetCSC:; Scans the keyboard matrix for any pressed key, returning the first it finds,; or 0 if none.; Inputs:; - None; Output:; - Code in A, or 0 if none; Destroys:; - BC ld bc, 07BFh_: ; Matrix scan loop ld a, c out (pKey), a rrca ld c, a pop af ; Probably should waste at least 20 cycles here. push af ; This is legal because F actually does have 8 bits in it. in a, (pKey) cp 0ffh jr nz, +_ ; Any key pressed? djnz -_ ; No keys pressed in any key group, so return 0. xor a ret_: ; Yay! Found a key, now form a scan code dec b sla b sla b sla b ; Get which bit in A is reset ld c, 0_: rrca inc c jr c, -_ ld a, c or b ret