This commit is contained in:
matthias@arch 2023-12-22 12:10:54 +01:00
parent 288a89ad05
commit 5bf82ca844
2 changed files with 27 additions and 13 deletions

View File

@ -91,11 +91,11 @@ irq:
jsr spi_p::read
bra @irq_return
@irq_kb1:
PrintNC "<30>"
; PrintNC "<30>"
jsr $3000
bra @irq_return
@irq_kb2:
PrintNC "<31>"
; PrintNC "<31>"
jsr $3100
bra @irq_return
; @irq_dht:

View File

@ -82,6 +82,10 @@ CODE_START:
beq @l3
cmp #'A'
beq @lA
cmp #'B'
beq @lB
cmp #'C'
beq @lC
jsr lcd::print_char
bra @loop
@l1:
@ -105,6 +109,13 @@ CODE_START:
lda kb::KB_IO + IO::SR
jsr lcd::print_char
bra @loop
@lB:
Strf fmt_str, out_str, keycode
Print out_str
bra @loop
@lC:
jsr lcd::clear
bra @loop
kbinit:
@ -132,6 +143,9 @@ kbinit:
rts
;; @details
;; IO::SR has to be read before the next bit is shifted in, which happens ~75us after the irq
;; at 1MHz, handlings this interrupt takes about 50us (without any additional debug code), so it should work
irq_on_shift_reg:
; lda #'{'
; jsr lcd::print_char
@ -154,8 +168,8 @@ irq_on_shift_reg:
irq_on_timer:
lda #'<'
jsr lcd::print_char
; lda #'<'
; jsr lcd::print_char
lda kb::KB_IO + IO::SR
sta key_read + 1
@ -167,14 +181,10 @@ irq_on_timer:
; enable shift register interrupts
lda #(IO::IRQ::IRQ | IO::IRQ::SR)
sta kb::KB_IO + IO::IER
; load SR to reset
; reset SR
stz kb::KB_IO + IO::SR
; lda #'|'
lda key_read
jsr lcd::print_char
lda key_read + 1
jsr lcd::print_char
; rotate bit 2 (last bit of keycode) into the carry
ror
ror
@ -183,11 +193,13 @@ irq_on_timer:
rol ; rotate carry into byte, rotate startbit into carry
; TODO byte is inverted, maybe consider wasting 256 bytes for a bit reverse lookup table?
sta keycode
Strf fmt_str2, out_str, keycode, key_read, key_read+1
PrintNC out_str
stz key_read
stz key_read+1
Strf "kc:%x", out_str, keycode
PrintNC out_str
rts
key_read: .res 2
@ -204,10 +216,12 @@ kb_irq2:
; lda #'?'
; jsr lcd::print_char
jsr irq_on_timer
lda #';'
jsr lcd::print_char
; lda #';'
; jsr lcd::print_char
rts
.byte '@'
out_str: .res 40
fmt_str: .asciiz "kc%x;"
fmt_str2: .asciiz "kc%x-%x-%x; "