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();
print!("{}{}", cursor::Hide, clear::All,);
'main: loop {
loop {
screen.draw();
if let Some(Ok(key)) = stdin.next() {
keyboard.read_keys(key);
match key {
Key::Char('q') => {
break 'main;
break;
}
Key::Char(' ') => cpu_controller.toggle(),
Key::Char('`') => cpu_controller.toggle(),
Key::Char('\n') => cpu_controller.cycle(),
Key::Char('i') => cpu_controller.irq(),
_ => keyboard.read_keys(key),
_ => {}
}
} else {
keyboard.clear_keys();
}
sleep(Duration::from_millis(16));
}

View File

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

Binary file not shown.

View File

@ -10,39 +10,31 @@ reset:
sei
ldx #0; initialize data stack pointer
; initdisplay:
; lda #0
; ldy #0
initdisplay:
lda #0
ldy #0
; cleardisplay:
; sta $6000,y
; sta $6100,y
; sta $6200,y
; sta $6300,y
; sta $6400,y
; sta $6500,y
; sta $6600,y
; sta $6700,y ; this goes slightly over but it's fine
; iny
; bne cleardisplay
cli
cleardisplay:
sta $6000,y
sta $6100,y
sta $6200,y
sta $6300,y
sta $6400,y
sta $6500,y
sta $6600,y
sta $6700,y ; this goes slightly over but it's fine
iny
bne cleardisplay
; cli
main:
jsr test
; lda key_buffer
jsr read_keys
lda key_buffer
sta $6000
; lda $4400
; sta $6000
nop
nop
nop
jmp main
test:
nop
nop
nop
rts
; 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
; 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
irq:
lda $4400
sta $6000
rts
isr: ; interrupt service routine