vasm now supports files

This commit is contained in:
2022-06-01 16:11:34 -05:00
parent 3ca3a2eeac
commit 84230676cb
6 changed files with 85 additions and 55 deletions
+6 -4
View File
@@ -43,7 +43,7 @@ fn main() {
let memory = Memory::from(rng);
let mut cpu = CPU::new(memory);
display::reset(&mut cpu);
let code = assemble_snippet(include_str!("typewriter.asm").lines()).expect("Assemble error");
let code = assemble_snippet(include_str!("typewriter.asm").lines().map(String::from)).expect("Assemble error");
println!("ROM size: {} bytes", code.len());
cpu.poke_slice(0x400.into(), code.as_slice());
cpu.start();
@@ -103,12 +103,14 @@ fn window_loop(event_loop: EventLoop<()>, window: Window, mut pixels: Pixels, mu
let start = Instant::now();
draw(pixels.get_frame(), &mut cpu);
pixels.render().expect("Problem displaying framebuffer");
loop {
loop { // TODO: this will run the CPU at 100%, need to not spin while halted
if let Some((int, arg)) = interrupt_events.pop_front() {
cpu.interrupt(int, arg)
}
for _ in 1..1000 {
cpu.tick()
if cpu.running() {
for _ in 1..1000 {
cpu.tick()
}
}
if Instant::now() > start + Duration::from_millis(25) {
break;