This commit is contained in:
transistor 2022-10-13 20:22:29 -07:00
parent cd89a4c57d
commit ea2fc95905
3 changed files with 5 additions and 9 deletions

View File

@ -9,23 +9,15 @@ function initialize_emulator() {
setTimeout(function refreshFrame() {
let current = performance.now();
let diff = current - last_update;
let realdiff = current - last_update;
//let remaining = Math.max((16 * Emulator.get_speed()) - diff, 0);
last_update = current;
let runtime = Emulator.run_system_for(system, diff * 1_000_000);
if (Emulator.is_running()) {
let remaining = Math.max(diff - runtime - (diff * 0.1), 1);
console.log(realdiff, diff, runtime, remaining);
setTimeout(refreshFrame, remaining);
}
}, 0);
/*
setTimeout(function refreshFrame() {
let run_time = run_system_for(system, 66_000_000);
setTimeout(refreshFrame, 66 - run_time);
}, 0);
*/
Emulator.host_run_loop(host);
}

View File

@ -96,7 +96,7 @@ pub fn run_system_for(handle: &mut SystemHandle, nanos: u32) -> usize {
log::error!("{:?}", err);
}
let run_time = run_timer.elapsed().as_millis();
log::warn!("ran simulation for {:?}ms in {:?}ms", nanoseconds_per_frame / 1_000_000, run_time);
log::debug!("ran simulation for {:?}ms in {:?}ms", nanoseconds_per_frame / 1_000_000, run_time);
run_time as usize
}

View File

@ -1,4 +1,8 @@
* can you refactor the update timeout to put it in rust? Would that make it faster? (the tricky part is the closure)
* re-enable sound on webassembly, see if it works (it does not. Very lagged and jittery with what sounds like repeated frames)
* can you somehow speed up the memory accessing through the sim? The dyn Addressable is causing a fair amount of overhead
* can you somehow make devices have two step functions for running things at different times? (I'm thinking ym2612 audio gen vs timers)
* should you rename devices.rs traits.rs?