mirror of
https://github.com/transistorfet/moa.git
synced 2025-01-03 13:30:57 +00:00
Minor tweaks to the update loop to keep it more realtime
This commit is contained in:
parent
d26e80ffaa
commit
cd89a4c57d
@ -14,6 +14,11 @@
|
||||
<input type="button" id="reset" value="Reset" />
|
||||
<input type="button" id="power" value="Power" />
|
||||
<input type="text" id="speed" value="4.0" />
|
||||
<select id="scale">
|
||||
<option value="1">320 x 224</option>
|
||||
<option value="2">640 x 448</option>
|
||||
<option value="3">960 x 672</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div id="metrics">
|
||||
|
@ -1,6 +1,40 @@
|
||||
|
||||
import * as Emulator from './moa-genesis.js';
|
||||
|
||||
function initialize_emulator() {
|
||||
let host = Emulator.new_host();
|
||||
let system = Emulator.load_system(host, Emulator.get_load_system_fn());
|
||||
|
||||
let last_update = performance.now();
|
||||
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);
|
||||
}
|
||||
|
||||
window.addEventListener("load", () => {
|
||||
Emulator.default();
|
||||
});
|
||||
|
||||
// Load a new ROM file
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = function (e) {
|
||||
var data = new Uint8Array(reader.result);
|
||||
@ -15,36 +49,8 @@ file_input.addEventListener("change", e => {
|
||||
reader.readAsArrayBuffer(file_input.files[0])
|
||||
});
|
||||
|
||||
function initialize_emulator() {
|
||||
let host = Emulator.new_host();
|
||||
let system = Emulator.load_system(host, Emulator.get_load_system_fn());
|
||||
|
||||
let last_update = performance.now();
|
||||
setTimeout(function refreshFrame() {
|
||||
let current = performance.now();
|
||||
let diff = Math.min(current - last_update, 100);
|
||||
let remaining = Math.max((16 * Emulator.get_speed()) - diff, 0);
|
||||
//console.log(diff, remaining);
|
||||
last_update = current;
|
||||
|
||||
Emulator.run_system_for(system, diff * 1_000_000);
|
||||
if (Emulator.is_running()) {
|
||||
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);
|
||||
}
|
||||
|
||||
document.getElementById("reset").addEventListener("click", () => {
|
||||
Emulator.request_stop();
|
||||
//start();
|
||||
});
|
||||
|
||||
document.getElementById("power").addEventListener("click", () => {
|
||||
@ -58,12 +64,9 @@ document.getElementById("speed").addEventListener("change", (e) => {
|
||||
Emulator.set_speed(e.target.value);
|
||||
});
|
||||
|
||||
var file_input = document.getElementById("rom-file");
|
||||
// Update the frame rate display
|
||||
var frame_rate_el = document.getElementById("frame-rate");
|
||||
var frame_rate = setInterval(function () {
|
||||
frame_rate_el.value = Emulator.get_frames_since();
|
||||
}, 1000);
|
||||
|
||||
window.addEventListener("load", () => {
|
||||
Emulator.default();
|
||||
});
|
||||
|
@ -116,14 +116,15 @@ pub fn create_window<T>(event_loop: &EventLoop<T>) -> Rc<Window> {
|
||||
WindowBuilder::new()
|
||||
.with_canvas(Some(canvas))
|
||||
.with_title("Hello Pixels + Web")
|
||||
.with_inner_size(size)
|
||||
.with_min_inner_size(size)
|
||||
//.with_inner_size(size)
|
||||
//.with_min_inner_size(size)
|
||||
.build(event_loop)
|
||||
.expect("WindowBuilder error")
|
||||
};
|
||||
|
||||
let window = Rc::new(window);
|
||||
|
||||
/*
|
||||
// Retrieve current width and height dimensions of browser client window
|
||||
let get_window_size = || {
|
||||
let client_window = web_sys::window().unwrap();
|
||||
@ -133,10 +134,9 @@ pub fn create_window<T>(event_loop: &EventLoop<T>) -> Rc<Window> {
|
||||
)
|
||||
};
|
||||
|
||||
let window = Rc::clone(&window);
|
||||
|
||||
// Initialize winit window with current dimensions of browser client
|
||||
window.set_inner_size(get_window_size());
|
||||
*/
|
||||
|
||||
let client_window = web_sys::window().unwrap();
|
||||
|
||||
@ -155,6 +155,7 @@ pub fn create_window<T>(event_loop: &EventLoop<T>) -> Rc<Window> {
|
||||
.expect("couldn't append canvas to document body");
|
||||
*/
|
||||
|
||||
/*
|
||||
{
|
||||
let window = window.clone();
|
||||
// Listen for resize event on browser client. Adjust winit window dimensions
|
||||
@ -168,6 +169,7 @@ pub fn create_window<T>(event_loop: &EventLoop<T>) -> Rc<Window> {
|
||||
.unwrap();
|
||||
closure.forget();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
let mut update_timer = Instant::now();
|
||||
|
28
todo.txt
28
todo.txt
@ -21,15 +21,12 @@
|
||||
* can you make the debugger more accessible, so a web interface could access the data and display it, in light of the fact that println isn't available in wasm
|
||||
|
||||
Web Assembly:
|
||||
* the frame rate is pretty bad. It's definitely faster with a smaller window
|
||||
* can you make the web interface nicer with like... a picture of a genesis or something
|
||||
* would a different pixel format help at all?
|
||||
|
||||
* can you limit the size of the window that pixels generates?
|
||||
* can you automatically adjust the speed based on the calculated framerate (if you moved that to Rust)
|
||||
* can you limit the frame rate in pixels so that you if it were to run too fast, it would limit it to 60Hz
|
||||
* the system run is taking 40 to 50ms per frame in web assembly. Can you cut that by 4 times?
|
||||
|
||||
* add sound to web assembly
|
||||
* add run/stop and ability to change speed through the web interface
|
||||
* can you make the web interface nicer with like... a picture of a genesis or something
|
||||
* enable sound in web assembly
|
||||
|
||||
|
||||
* add ability to disable one or the other audio chips in the genesis
|
||||
@ -38,11 +35,7 @@ Web Assembly:
|
||||
* should you have a separate attenuation value for each input in the mixer so that you can make one chip quieter (the sn76489 is pretty loud, and I added a fixed offset to the attenuation for now)
|
||||
|
||||
|
||||
* I need some better function for dealing with memory, like a function that copies data with a loop, or allows offset reading of
|
||||
a fixed piece of data..., the trick is what function are the most common. You can use generics
|
||||
|
||||
* there is an issue with Mortal Kombat 2 where it will crash randomly at the start of a fight. The code is actually swapping
|
||||
stacks a bunch of times, and at some point, the stack is corrupted or something and it `rts`s to the wrong address...
|
||||
|
||||
|
||||
Audio:
|
||||
@ -89,12 +82,11 @@ Debugger:
|
||||
|
||||
Genesis/Mega Drive:
|
||||
|
||||
* there is an issue with Mortal Kombat 2 where it will crash randomly at the start of a fight. The code is actually swapping
|
||||
stacks a bunch of times, and at some point, the stack is corrupted or something and it `rts`s to the wrong address...
|
||||
|
||||
* implement sn76489 and ym2612 for audio
|
||||
* in some games the controller doesn't seem to work at all (Earthworm Jim, and Mortal Kombat)
|
||||
* refactor to print line by line, so that colour palette changes have an effect
|
||||
* there's a bug when Sonic 2 goes to the demo screen, it's all corrupted (could it be a dma copy error)
|
||||
* colours are still broken in Sonic1
|
||||
* sonic3 needs some kind of nvram to run
|
||||
|
||||
* the 68000/Z80 bank switching is probably buggy
|
||||
* the H/V counters are not accurate because it seems to count at different speeds in the blanking period (time vs return value numbers don't divide properly)
|
||||
@ -111,8 +103,6 @@ Macintosh:
|
||||
|
||||
68000:
|
||||
|
||||
* check all instructions in the docs
|
||||
|
||||
* unimplemented: BFFFO, BFINS, NBCD, RTD
|
||||
* >=MC68020 undecoded & unimplemented: BKPT, CALLM, CAS, CAS2, CHK2, CMP2, RTM, PACK, TRAPcc, UNPK
|
||||
|
||||
@ -120,15 +110,11 @@ Macintosh:
|
||||
* add support for FPU
|
||||
* Coprocessor instructions: cpBcc, cpDBcc, cpGEN, cpScc, cpTRAPcc
|
||||
|
||||
* add more m68k tests and try to test against a working impl (m68k-test-suite project)
|
||||
|
||||
|
||||
Z80:
|
||||
* add instruction timings to Z80
|
||||
* unimplemented: CPD, CPDR, CPI, CPIR, DAA, IND, INDR, INI, INIR, INic, INx, OTDR, OTIR, OUTD, OUTI, OUTic, OUTx, RETI, RETN, RLD, RRD
|
||||
|
||||
|
||||
* work on mac128/512
|
||||
* work on sega genesis
|
||||
* can you eventually make the system connections all configurable via a config file?
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user