This works in release but not regular builds

This commit is contained in:
2022-05-01 18:12:01 -05:00
parent f63344089a
commit c3bd98b8c9
5 changed files with 138 additions and 118 deletions
Binary file not shown.
-8
View File
@@ -42,14 +42,7 @@ fn main() {
let memory = Memory::from(rng);
let mut cpu = CPU::new(memory);
display::reset(&mut cpu);
// for n in 0..128 {
// cpu.poke(Word::from(0x10000 + 128 * n), 0b11100000);
// cpu.poke(Word::from(0x10000 + n), 0xff);
// cpu.poke(Word::from(0x10000 + 128 * n + 127), 0b00000011);
// cpu.poke(Word::from(0x10000 + 128 * 127 + n), 0b00011100);
// }
let code = assemble_snippet(include_str!("typewriter.asm").lines()).expect("Assemble error");
//cpu.poke_slice(Word::from(0x400), include_bytes!("gfx_test.rom"));
cpu.poke_slice(0x400.into(), code.as_slice());
cpu.start();
window_loop(event_loop, window, pixels, cpu)
@@ -85,7 +78,6 @@ fn window_loop(event_loop: EventLoop<()>, window: Window, mut pixels: Pixels, mu
if state == ElementState::Pressed { 1 } else { 0 },
0,
]);
println!("Saw: {:#4x}", u32::from(word));
interrupt_events.push_back((5, Some(word)))
}
}
+32 -18
View File
@@ -66,15 +66,12 @@ on_key:
setint 1 ; this can be reentrant, doesn't hurt anything
call is_press ; check for press
#if
; if is alpha, look up in map and print
dup
call is_alpha
#if
call to_alpha_char
call putc
#else
brnz @putc
call is_punc
brnz @putc
pop
#end
ret
#else
; TODO:
; if is punc, look up in punc map and print
@@ -94,27 +91,43 @@ is_press: ; ( event -- key bool )
and 0xff00
ret
is_alpha: ; ( key -- bool )
is_ret: ; ( key -- 1 ) or ( key -- key 0 )
dup
sub 0x28
brnz @+3
pop
ret 1
ret 0
is_alpha: ; ( key -- ch 1 ) or ( key -- key 0 )
dup
dup
gt 0x03
swap
lt 0x27
lt 0x28
and
ret
#if
sub 0x04
add alpha_table
load
ret 1
#end
ret 0
is_punc: ; ( key -- bool )
is_punc: ; ( key -- ch 1 ) or (key -- key 0 )
dup
dup
gt 0x2b
swap
lt 0x39
and
ret
to_alpha_char: ; ( key -- ch )
sub 0x04
add alpha_table
#if
sub 0x2c
add punc_table
load
ret
ret 1
#end
ret 0
putc: ; ( ch -- ) (also modifies cursor)
loadw cursor
@@ -128,4 +141,5 @@ putc: ; ( ch -- ) (also modifies cursor)
cursor: .db screen + 40
msg: .db "Type something:\0"
alpha_table: .db "abcdefghijklmnopqrstuvwxyz1234567890"
alpha_table: .db "abcdefghijklmnopqrstuvwxyz1234567890"
punc_table: .db " -=[]\\?;'`,./"