Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; KBSCAN will scan the keyboard for incoming data for about
- ; 105uS and returns with A=0 if no data was received.
- ; It does not decode anything, the non-zero value in A if data
- ; is ready is ambiguous. You must call KBGET or KBINPUT to
- ; get the keyboard data.
- ;
- kbscan: ldx #$05 ; timer: x = (cycles - 40)/13 (105-40)/13=5
- lda kbportddr ;
- and #$CF ; set clk to input (change if port bits change)
- sta kbportddr ;
- kbscan1: lda #clk ;
- bit kbportreg ;
- beq kbscan2 ; if clk goes low, data ready
- dex ; reduce timer
- bne kbscan1 ; wait while clk is high
- jsr kbdis ; timed out, no data, disable receiver
- lda #$00 ; set data not ready flag
- rts ; return
- kbscan2: jsr kbdis ; disable the receiver so other routines get it
- ; Three alternative exits if data is ready to be received: Either return or jmp to handler
- ; rts ; return (A<>0, A=clk bit mask value from kbdis)
- jmp kbinput ; if key pressed, decode it with KBINPUT
- ; jmp KBGET ; if key pressed, decode it with KBGET
- ;
- ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement