hehe the keyboard finally works

This commit is contained in:
august kline 2024-07-05 00:19:49 -04:00
parent dcaeece7fa
commit 07d40c05d5
4 changed files with 29 additions and 48 deletions

View File

@ -53,18 +53,21 @@ fn main() {
let mut stdin = async_stdin().keys(); let mut stdin = async_stdin().keys();
print!("{}{}", cursor::Hide, clear::All,); print!("{}{}", cursor::Hide, clear::All,);
'main: loop { loop {
screen.draw(); screen.draw();
if let Some(Ok(key)) = stdin.next() { if let Some(Ok(key)) = stdin.next() {
keyboard.read_keys(key);
match key { match key {
Key::Char('q') => { Key::Char('q') => {
break 'main; break;
} }
Key::Char(' ') => cpu_controller.toggle(), Key::Char('`') => cpu_controller.toggle(),
Key::Char('\n') => cpu_controller.cycle(), Key::Char('\n') => cpu_controller.cycle(),
Key::Char('i') => cpu_controller.irq(), Key::Char('i') => cpu_controller.irq(),
_ => keyboard.read_keys(key), _ => {}
} }
} else {
keyboard.clear_keys();
} }
sleep(Duration::from_millis(16)); sleep(Duration::from_millis(16));
} }

View File

@ -34,10 +34,10 @@ cleardisplay:
sta $6700,y ; this goes slightly over but it's fine sta $6700,y ; this goes slightly over but it's fine
iny iny
bne cleardisplay bne cleardisplay
; cli cli
main: main:
jsr printtext ; jsr printtext
; key_zero: ; key_zero:
; stz keyboard_cache, x ; stz keyboard_cache, x
; dex ; dex
@ -45,21 +45,9 @@ main:
; fim: ; fim:
; cli ; cli
; bra fim ; bra fim
jsr keyboard
jmp main jmp main
printtext:
ldx 0
loop:
lda text, x
beq end
sta $6000, x
inx
bra loop
end:
rts
text:
.asciiz "hi <3"
keyboard: keyboard:
ldy #0 ldy #0
@ -171,7 +159,7 @@ isr: ; interrupt service routine
pha pha
phx phx
phy phy
; jsr irq ; jsr keyboard
ply ply
plx plx
pla pla

Binary file not shown.

View File

@ -10,39 +10,31 @@ reset:
sei sei
ldx #0; initialize data stack pointer ldx #0; initialize data stack pointer
; initdisplay: initdisplay:
; lda #0 lda #0
; ldy #0 ldy #0
; cleardisplay: cleardisplay:
; sta $6000,y sta $6000,y
; sta $6100,y sta $6100,y
; sta $6200,y sta $6200,y
; sta $6300,y sta $6300,y
; sta $6400,y sta $6400,y
; sta $6500,y sta $6500,y
; sta $6600,y sta $6600,y
; sta $6700,y ; this goes slightly over but it's fine sta $6700,y ; this goes slightly over but it's fine
; iny iny
; bne cleardisplay bne cleardisplay
cli ; cli
main: main:
jsr test jsr read_keys
; lda key_buffer lda key_buffer
sta $6000
; lda $4400 ; lda $4400
; sta $6000 ; sta $6000
nop
nop
nop
jmp main jmp main
test:
nop
nop
nop
rts
; first, let's do the simplest case of just the letter a being pressed ; first, let's do the simplest case of just the letter a being pressed
; 1. check row 2 ($4402, where the a key is) for pressed keys ; 1. check row 2 ($4402, where the a key is) for pressed keys
; 2. if any keys are pressed, check if the key is a (bit 0) ; 2. if any keys are pressed, check if the key is a (bit 0)
@ -113,8 +105,6 @@ fill: ; fills an area from (x1, y1) to (x2, y2) will character c, (n1: c n2: x1
jsr get_char_address jsr get_char_address
irq: irq:
lda $4400
sta $6000
rts rts
isr: ; interrupt service routine isr: ; interrupt service routine