mirror of
https://github.com/exoticorn/microw8.git
synced 2026-11-14 07:17:19 +01:00
Compare commits
6
Commits
v0.2.0-rc1
...
7cea4eebd3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cea4eebd3 | ||
|
|
3f67e92c5c | ||
|
|
a2714f25e4 | ||
|
|
7e203d93e6 | ||
|
|
e44c87d1f6 | ||
|
|
614b7cf358 |
No files matched your search
Generated
+1
-1
@@ -2637,7 +2637,7 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uw8"
|
name = "uw8"
|
||||||
version = "0.2.0-rc1"
|
version = "0.2.0-rc2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term",
|
"ansi_term",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "uw8"
|
name = "uw8"
|
||||||
version = "0.2.0-rc1"
|
version = "0.2.0-rc2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// port of cracklebass by pestis (originally on TIC-80)
|
||||||
|
|
||||||
|
include "../include/microw8-api.cwa"
|
||||||
|
|
||||||
|
const MUSIC_DATA = 0x20000;
|
||||||
|
|
||||||
|
export fn upd() {
|
||||||
|
let inline t = 32!32 * 6 / 100;
|
||||||
|
let inline p = t / 1024;
|
||||||
|
|
||||||
|
let channel:i32;
|
||||||
|
|
||||||
|
loop channels {
|
||||||
|
let inline e = t * channel?MUSIC_DATA / 8;
|
||||||
|
let lazy pattern = (8 * channel + p)?(MUSIC_DATA + 56);
|
||||||
|
let lazy n = !!pattern * (8 * pattern + e / 16 % 8)?MUSIC_DATA;
|
||||||
|
let inline prev_ctrl = (channel * 6)?80;
|
||||||
|
(channel * 6)?80 = if n {
|
||||||
|
let inline base_note = 12 + 12 * channel?(MUSIC_DATA + 4) + n;
|
||||||
|
let inline pitch_drop = e % 16 * channel?(MUSIC_DATA + 94);
|
||||||
|
let inline key_pattern = p?(MUSIC_DATA + 8*4 + 56);
|
||||||
|
let inline key = select(key_pattern, (8 * key_pattern + t / 128 % 8)?MUSIC_DATA, 1);
|
||||||
|
(channel * 6)?83 = base_note - pitch_drop / 4 + key;
|
||||||
|
prev_ctrl & 0xfc | (e / 8 & 2) | 1
|
||||||
|
} else {
|
||||||
|
prev_ctrl & 0xfe
|
||||||
|
};
|
||||||
|
|
||||||
|
branch_if (channel := channel + 1) < 4: channels;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data 80 {
|
||||||
|
i8(
|
||||||
|
0x44, 0, 0, 0, 0x50, 0x40,
|
||||||
|
0x4, 0x50, 0, 0, 0x80, 0x80,
|
||||||
|
0x40, 0x80, 0, 0, 0x40, 0x40,
|
||||||
|
0, 0, 0, 0, 0x50, 0x50
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
data MUSIC_DATA {
|
||||||
|
i8(
|
||||||
|
16, 2, 8, 8, 1, 2, 2, 3, 1, 0,
|
||||||
|
1,13,16, 0, 1, 8, 1, 0, 1,13,
|
||||||
|
16, 1, 1, 8, 1, 0, 8,13,13, 0,
|
||||||
|
16,13, 1, 0, 1, 0, 1, 0, 1, 1,
|
||||||
|
1, 0, 0, 0, 1, 0,13, 1, 1, 1,
|
||||||
|
6, 8, 1, 1, 6, 8, 1, 1, 2, 1,
|
||||||
|
2, 1, 2, 0, 0, 0, 0, 3, 3, 3,
|
||||||
|
5, 0, 0, 2, 1, 2, 1, 2, 1, 2,
|
||||||
|
0, 4, 4, 0, 4, 4, 4, 4, 0, 0,
|
||||||
|
0, 0, 6, 6, 0, 0, 0, 8
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -29,9 +29,23 @@ Examplers for older versions:
|
|||||||
|
|
||||||
## Versions
|
## Versions
|
||||||
|
|
||||||
|
### v0.2.0-rc2
|
||||||
|
|
||||||
|
* [Web runtime](v0.2.0-rc2)
|
||||||
|
* [Linux](https://github.com/exoticorn/microw8/releases/download/v0.2.0-rc2/microw8-0.2.0-rc2-linux.tgz)
|
||||||
|
* [MacOS](https://github.com/exoticorn/microw8/releases/download/v0.2.0-rc2/microw8-0.2.0-rc2-macos.tgz)
|
||||||
|
* [Windows](https://github.com/exoticorn/microw8/releases/download/v0.2.0-rc2/microw8-0.2.0-rc2-windows.zip)
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
* fix timing issues of sound playback, especially on systems with large sound buffers
|
||||||
|
|
||||||
### v0.2.0-rc1
|
### v0.2.0-rc1
|
||||||
|
|
||||||
* [Web runtime](v0.2.0-rc1)
|
* [Web runtime](v0.2.0-rc1)
|
||||||
|
* [Linux](https://github.com/exoticorn/microw8/releases/download/v0.2.0-rc1/microw8-0.2.0-rc1-linux.tgz)
|
||||||
|
* [MacOS](https://github.com/exoticorn/microw8/releases/download/v0.2.0-rc1/microw8-0.2.0-rc1-macos.tgz)
|
||||||
|
* [Windows](https://github.com/exoticorn/microw8/releases/download/v0.2.0-rc1/microw8-0.2.0-rc1-windows.zip)
|
||||||
|
|
||||||
Changes:
|
Changes:
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<!doctype html><html><head><meta charset="utf8"><title>MicroW8</title><link href="https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@500&display=swap" rel="stylesheet"><style>body,canvas,html{margin:0;padding:0}html{background-color:#202024;color:#808070;font-family:Josefin Sans,Verdana,Arial Black,sans-serif}body,html{height:100%}body{display:grid;grid-template-rows:1fr 0fr}#uw8{position:absolute}#uw8 a{font-size:130%}#centered{align-self:center;justify-self:center}a{color:#303630}a:hover{color:#405040}.screen{background-color:#202428;border:4px solid #303040;box-shadow:5px 5px 20px #000;height:240px;image-rendering:pixelated;margin-bottom:8px;width:320px}#screen{cursor:none}#start{font-size:150%}#timer:before{background-color:red;border-radius:6px;content:"";display:inline-block;height:12px;margin-right:3px;width:12px}#message{margin-bottom:8px}.error{color:#e04030}button{background-color:#303440;border:1px solid #404040;border-radius:4px;color:#808070;font-family:inherit;padding:4px}button:hover{background-color:#202010}button:active{background-color:#504450}@media (min-width:680px) and (min-height:620px){.screen{height:480px;width:640px}}@media (min-width:1000px) and (min-height:800px){.screen{height:720px;width:960px}}@media (width:640px) and (height:480px){.screen{border:0;height:480px;margin:0;width:640px}body{overflow:hidden}}</style></head><body> <div id="uw8"> <a href="https://exoticorn.github.io/microw8">MicroW8</a> 0.2.0-rc2 </div> <div id="centered"> <canvas class="screen" id="screen" width="320" height="240"> </canvas> <button class="screen" id="start" style="display:none">Click to start</button> <div id="timer" hidden></div> <div id="message"></div> <button id="cartButton" style="visibility:hidden">Load cart...</button> </div> <div id="footer"> <a href="http://unlicense.org/" ref="license">Unlicense</a> </div> </body><script type="module">function e(e){return e&&e.__esModule?e.default:e}class t extends AudioWorkletNode{constructor(e){super(e,"apu",{outputChannelCount:[2]})}}let a=(...e)=>new Uint8Array(...e),s=(...e)=>new Uint32Array(...e);let n=function(n,r={}){r.setMessage||(r.setMessage=(e,t)=>{t&&console.log("error: "+t)});let A,B,o,i,l,d,c,u,D=n.getContext("2d"),F=D.createImageData(320,240),f=r.devkitMode,w=0,g=null==r.keyboardElement?n:r.keyboardElement;if(g){let e=e=>{let t,a="keydown"==e.type;switch(e.code){case"ArrowUp":t=1;break;case"ArrowDown":t=2;break;case"ArrowLeft":t=4;break;case"ArrowRight":t=8;break;case"KeyZ":t=16;break;case"KeyX":t=32;break;case"KeyA":t=64;break;case"KeyS":t=128;break;case"KeyR":a&&m(B,!0);break;case"F9":a&&n.toBlob((e=>{C(e,".png")})),e.preventDefault();break;case"F10":a&&function(){if(l)return l.stop(),l=null,c.disconnect(u),c=null,void(u=null);let e=n.captureStream();u=o.createMediaStreamDestination(),c=i,i.connect(u),e.addTrack(u.stream.getAudioTracks()[0]),l=new MediaRecorder(e,{mimeType:"video/webm",videoBitsPerSecond:25e6});let t=[];l.ondataavailable=e=>{t.push(e.data)};let a=r.timerElement;a&&(a.hidden=!1,a.innerText="00:00");function s(){if(d){if(a){let e=Math.floor((Date.now()-d)/1e3);a.innerText=Math.floor(e/60).toString().padStart(2,"0")+":"+(e%60).toString().padStart(2,"0")}setTimeout(s,1e3)}}l.onstop=()=>{a&&(a.hidden=!0),C(new Blob(t,{type:"video/webm"}),".webm")},l.start(),d=Date.now(),setTimeout(s,1e3)}(),e.preventDefault()}a?w|=t:w&=~t};g.onkeydown=e,g.onkeyup=e}async function m(l,d){A&&(A(),A=null),o=new AudioContext({sampleRate:44100});let c=!0,u=new AbortController;A=()=>{o.close(),c=!1,u.abort()};let g=l.byteLength;if(r.setMessage(g),0==g)return;await o.audioWorklet.addModule(e("data:application/javascript,let%20e%3D%28...e%29%3D%3Enew%20Uint8Array%28...e%29%3Bclass%20s%20extends%20AudioWorkletProcessor%7Bconstructor%28%29%7Bsuper%28%29%2Cthis.sampleIndex%3D0%2Cthis.currentTime%3D0%2Cthis.isFirstMessage%3D%210%2Cthis.pendingUpdates%3D%5B%5D%2Cthis.port.onmessage%3De%3D%3E%7Bthis.memory%3F%28this.isFirstMessage%26%26%28this.currentTime%2B%3D%28e.data.t-this.currentTime%29%2F8%2Cthis.isFirstMessage%3D%211%29%2Cthis.pendingUpdates.push%28e.data%29%29%3Athis.load%28e.data%5B0%5D%2Ce.data%5B1%5D%29%7D%7Dasync%20load%28e%2Cs%29%7Blet%20t%3Dnew%20WebAssembly.Memory%28%7Binitial%3A4%2Cmaximum%3A4%7D%29%2Ci%3D%7Benv%3A%7Bmemory%3At%7D%7D%3Bfor%28let%20e%20of%5B%22acos%22%2C%22asin%22%2C%22atan%22%2C%22atan2%22%2C%22cos%22%2C%22exp%22%2C%22log%22%2C%22sin%22%2C%22tan%22%2C%22pow%22%5D%29i.env%5Be%5D%3DMath%5Be%5D%3Bfor%28let%20e%3D9%3Be%3C64%3B%2B%2Be%29i.env%5B%22reserved%22%2Be%5D%3D%28%29%3D%3E%7B%7D%3Bfor%28let%20e%3D0%3Be%3C16%3B%2B%2Be%29i.env%5B%22g_reserved%22%2Be%5D%3D0%3Blet%20r%3Dasync%20e%3D%3E%28await%20WebAssembly.instantiate%28e%2Ci%29%29.instance%2Cn%3Dawait%20r%28e%29%3Bfor%28let%20e%20in%20n.exports%29i.env%5Be%5D%3Dn.exports%5Be%5D%3Blet%20a%3Dawait%20r%28s%29%3Bthis.memory%3Dt%2Cthis.snd%3Da.exports.snd%7C%7Cn.exports.gesSnd%2Cthis.port.postMessage%282%29%7Dprocess%28s%2Ct%2Ci%29%7Bif%28this.isFirstMessage%3D%210%2CtLine truncated
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
<!doctype html><html><head><meta charset="utf8"><title>uw8-run</title><style>body,canvas,html{background-color:#202024;margin:0;padding:0}body,html{height:100%}body{display:grid;grid-template-rows:1fr}#screen{align-self:center;border:4px solid #303040;image-rendering:pixelated;justify-self:center}#message{background-color:rgba(0,0,0,.4);color:#c64;font:700 12pt sans-serif;padding:8px;position:absolute;width:calc(100% - 16px);z-index:2}@media (min-width:648px) and (min-height:488px){#screen{height:480px;width:640px}}@media (min-width:968px) and (min-height:728px){#screen{height:720px;width:960px}}</style></head><body> <canvas id="screen" width="320" height="240" tabindex="1"> </canvas> <div id="message"></div> </body><script type="module">function e(e){return e&&e.__esModule?e.default:e}class t extends AudioWorkletNode{constructor(e){super(e,"apu",{outputChannelCount:[2]})}}let A=(...e)=>new Uint8Array(...e),a=(...e)=>new Uint32Array(...e);let B=function(B,s={}){s.setMessage||(s.setMessage=(e,t)=>{t&&console.log("error: "+t)});let r,o,n,i,l,d,F,D,f=B.getContext("2d"),u=f.createImageData(320,240),c=s.devkitMode,w=0,g=null==s.keyboardElement?B:s.keyboardElement;if(g){let e=e=>{let t,A="keydown"==e.type;switch(e.code){case"ArrowUp":t=1;break;case"ArrowDown":t=2;break;case"ArrowLeft":t=4;break;case"ArrowRight":t=8;break;case"KeyZ":t=16;break;case"KeyX":t=32;break;case"KeyA":t=64;break;case"KeyS":t=128;break;case"KeyR":A&&m(o,!0);break;case"F9":A&&B.toBlob((e=>{C(e,".png")})),e.preventDefault();break;case"F10":A&&function(){if(l)return l.stop(),l=null,F.disconnect(D),F=null,void(D=null);let e=B.captureStream();D=n.createMediaStreamDestination(),F=i,i.connect(D),e.addTrack(D.stream.getAudioTracks()[0]),l=new MediaRecorder(e,{mimeType:"video/webm",videoBitsPerSecond:25e6});let t=[];l.ondataavailable=e=>{t.push(e.data)};let A=s.timerElement;A&&(A.hidden=!1,A.innerText="00:00");function a(){if(d){if(A){let e=Math.floor((Date.now()-d)/1e3);A.innerText=Math.floor(e/60).toString().padStart(2,"0")+":"+(e%60).toString().padStart(2,"0")}setTimeout(a,1e3)}}l.onstop=()=>{A&&(A.hidden=!0),C(new Blob(t,{type:"video/webm"}),".webm")},l.start(),d=Date.now(),setTimeout(a,1e3)}(),e.preventDefault()}A?w|=t:w&=~t};g.onkeydown=e,g.onkeyup=e}async function m(l,d){r&&(r(),r=null),n=new AudioContext({sampleRate:44100});let F=!0,D=new AbortController;r=()=>{n.close(),F=!1,D.abort()};let g=l.byteLength;if(s.setMessage(g),0==g)return;await n.audioWorklet.addModule(e("data:application/javascript,let%20e%3D%28...e%29%3D%3Enew%20Uint8Array%28...e%29%3Bclass%20t%20extends%20AudioWorkletProcessor%7Bconstructor%28%29%7Bsuper%28%29%2Cthis.sampleIndex%3D0%2Cthis.port.onmessage%3Dt%3D%3E%7Bthis.memory%3FisNaN%28t.data%29%3Fe%28this.memory.buffer%2C80%2C32%29.set%28e%28t.data%29%29%3Athis.startTime%3Dt.data%3Athis.load%28t.data%5B0%5D%2Ct.data%5B1%5D%29%7D%7Dasync%20load%28e%2Ct%29%7Blet%20s%3Dnew%20WebAssembly.Memory%28%7Binitial%3A4%2Cmaximum%3A4%7D%29%2Ca%3D%7Benv%3A%7Bmemory%3As%7D%7D%3Bfor%28let%20e%20of%5B%22acos%22%2C%22asin%22%2C%22atan%22%2C%22atan2%22%2C%22cos%22%2C%22exp%22%2C%22log%22%2C%22sin%22%2C%22tan%22%2C%22pow%22%5D%29a.env%5Be%5D%3DMath%5Be%5D%3Bfor%28let%20e%3D9%3Be%3C64%3B%2B%2Be%29a.env%5B%22reserved%22%2Be%5D%3D%28%29%3D%3E%7B%7D%3Bfor%28let%20e%3D0%3Be%3C16%3B%2B%2Be%29a.env%5B%22g_reserved%22%2Be%5D%3D0%3Blet%20r%3Dasync%20e%3D%3E%28await%20WebAssembly.instantiate%28e%2Ca%29%29.instance%2Ci%3Dawait%20r%28e%29%3Bfor%28let%20e%20in%20i.exports%29a.env%5Be%5D%3Di.exports%5Be%5D%3Blet%20n%3Dawait%20r%28t%29%3Bthis.memory%3Ds%2Cthis.snd%3Dn.exports.snd%7C%7Ci.exports.gesSnd%2Cthis.port.postMessage%282%29%7Dprocess%28e%2Ct%2Cs%29%7Bif%28this.snd%26%26this.startTime%29%7Bnew%20Uint32Array%28this.memory.buffer%29%5B16%5D%3DDate.now%28%29-this.startTime%3Blet%20e%3Dt%5B0%5D%2Cs%3Dthis.sampleIndex%2Ca%3De%5B0%5D.length%3Bfor%28let%20t%3D0%3Bt%3Ca%3B%2B%2Bt%29e%5B0%5D%5Bt%5D%3Dthis.snd%28s%2B%2B%29%2Ce%5B1%5D%5Bt%5D%3Dthis.snd%28s%2B%2B%29%3Bthis.sampleIndex%3D4294967295%26s%7Dreturn%210%7D%7DregisterProcessor%28%22apu%22%2Ct%29%3B")),i=new t(n);let C,Q=0,y=new Promise((e=>C=e)),E=e=>{Q|=e,3==Q&&C&&(C(!0),C=null)},I=()=>{"suspended"==n.state?(s.startButton&&(s.startButton.style="",B.style="display:none"),(s.startButton||B).onclick=()=>{n.resume()}):(s.startButton&&(s.startButton.style="display:none",B.style=""),E(1))};n.onstatechange=I,I(),o=l;let b=window.location.pathname;if(g<=1024&&!d){let e="";for(let t of A(l))e+=String.fromCharCode(t);b+="#"+btoa(e),b!=window.location.pathname+window.location.hash&&history.pushState(null,null,b)}B.width=B.width;try{let t={initial:4};c||(t.maximum=4);let B,r=new WebAssembly.Memory(t),d=A(r.buffer),C={env:{memory:r}},Q=e=>{if(B&&(!c||0!=A(e)[0])){d.set(A(e));let t=B.exports.load_uw8(e.byteLength);e=new ArrayBuffer(t),A(e).set(d.slice(0,t))}return e},I=async e=>(await WebAssembly.instantiate(e,C)).instance,b=async e=>Q(await(await fetch(e)).arrayBuffer());B=await I(await b(e("data:application/wasLine truncated
|
<!doctype html><html><head><meta charset="utf8"><title>uw8-run</title><style>html,body,canvas{background-color:#202024;margin:0;padding:0}html{height:100%}body{height:100%;grid-template-rows:1fr;display:grid}#screen{image-rendering:pixelated;border:4px solid #303040;place-self:center}#message{width:calc(100% - 16px);color:#c64;z-index:2;background-color:#0006;padding:8px;font:700 12pt sans-serif;position:absolute}@media (min-width:648px) and (min-height:488px){#screen{width:640px;height:480px}}@media (min-width:968px) and (min-height:728px){#screen{width:960px;height:720px}}</style></head><body> <canvas id="screen" width="320" height="240" tabindex="1"> </canvas> <div id="message"></div> </body><script type="module">function e(e){return e&&e.__esModule?e.default:e}class t extends AudioWorkletNode{constructor(e){super(e,"apu",{outputChannelCount:[2]})}}let A=(...e)=>new Uint8Array(...e),s=(...e)=>new Uint32Array(...e);let a=function(a,B={}){B.setMessage||(B.setMessage=(e,t)=>{t&&console.log("error: "+t)});let r,n,o,i,d,l,D,F,u=a.getContext("2d"),c=u.createImageData(320,240),f=B.devkitMode,g=0,w=null==B.keyboardElement?a:B.keyboardElement;if(w){let e=e=>{let t,A="keydown"==e.type;switch(e.code){case"ArrowUp":t=1;break;case"ArrowDown":t=2;break;case"ArrowLeft":t=4;break;case"ArrowRight":t=8;break;case"KeyZ":t=16;break;case"KeyX":t=32;break;case"KeyA":t=64;break;case"KeyS":t=128;break;case"KeyR":A&&C(n,!0);break;case"F9":A&&a.toBlob((e=>{m(e,".png")})),e.preventDefault();break;case"F10":A&&function(){if(d)return d.stop(),d=null,D.disconnect(F),D=null,void(F=null);let e=a.captureStream();F=o.createMediaStreamDestination(),D=i,i.connect(F),e.addTrack(F.stream.getAudioTracks()[0]),d=new MediaRecorder(e,{mimeType:"video/webm",videoBitsPerSecond:25e6});let t=[];d.ondataavailable=e=>{t.push(e.data)};let A=B.timerElement;A&&(A.hidden=!1,A.innerText="00:00");function s(){if(l){if(A){let e=Math.floor((Date.now()-l)/1e3);A.innerText=Math.floor(e/60).toString().padStart(2,"0")+":"+(e%60).toString().padStart(2,"0")}setTimeout(s,1e3)}}d.onstop=()=>{A&&(A.hidden=!0),m(new Blob(t,{type:"video/webm"}),".webm")},d.start(),l=Date.now(),setTimeout(s,1e3)}(),e.preventDefault()}A?g|=t:g&=~t};w.onkeydown=e,w.onkeyup=e}async function C(d,l){r&&(r(),r=null),o=new AudioContext({sampleRate:44100});let D=!0,F=new AbortController;r=()=>{o.close(),D=!1,F.abort()};let w=d.byteLength;if(B.setMessage(w),0==w)return;await o.audioWorklet.addModule(e("data:application/javascript,let%20e%3D%28...e%29%3D%3Enew%20Uint8Array%28...e%29%3Bclass%20s%20extends%20AudioWorkletProcessor%7Bconstructor%28%29%7Bsuper%28%29%2Cthis.sampleIndex%3D0%2Cthis.currentTime%3D0%2Cthis.isFirstMessage%3D%210%2Cthis.pendingUpdates%3D%5B%5D%2Cthis.port.onmessage%3De%3D%3E%7Bthis.memory%3F%28this.isFirstMessage%26%26%28this.currentTime%2B%3D%28e.data.t-this.currentTime%29%2F8%2Cthis.isFirstMessage%3D%211%29%2Cthis.pendingUpdates.push%28e.data%29%29%3Athis.load%28e.data%5B0%5D%2Ce.data%5B1%5D%29%7D%7Dasync%20load%28e%2Cs%29%7Blet%20t%3Dnew%20WebAssembly.Memory%28%7Binitial%3A4%2Cmaximum%3A4%7D%29%2Ci%3D%7Benv%3A%7Bmemory%3At%7D%7D%3Bfor%28let%20e%20of%5B%22acos%22%2C%22asin%22%2C%22atan%22%2C%22atan2%22%2C%22cos%22%2C%22exp%22%2C%22log%22%2C%22sin%22%2C%22tan%22%2C%22pow%22%5D%29i.env%5Be%5D%3DMath%5Be%5D%3Bfor%28let%20e%3D9%3Be%3C64%3B%2B%2Be%29i.env%5B%22reserved%22%2Be%5D%3D%28%29%3D%3E%7B%7D%3Bfor%28let%20e%3D0%3Be%3C16%3B%2B%2Be%29i.env%5B%22g_reserved%22%2Be%5D%3D0%3Blet%20r%3Dasync%20e%3D%3E%28await%20WebAssembly.instantiate%28e%2Ci%29%29.instance%2Cn%3Dawait%20r%28e%29%3Bfor%28let%20e%20in%20n.exports%29i.env%5Be%5D%3Dn.exports%5Be%5D%3Blet%20a%3Dawait%20r%28s%29%3Bthis.memory%3Dt%2Cthis.snd%3Da.exports.snd%7C%7Cn.exports.gesSnd%2Cthis.port.postMessage%282%29%7Dprocess%28s%2Ct%2Ci%29%7Bif%28this.isFirstMessage%3D%210%2Cthis.snd%29%7Bfor%28%3Bthis.pendingUpdates.length%3E0%26%26this.pendingUpdates%5B0%5D.t%3C%3Dthis.currentTime%3B%29e%28this.memory.buffer%2C80%2C32%29.set%28e%28this.pendingUpdates.shift%28%29.r%29%29%3Bnew%20Uint32Array%28this.memory.buffer%29%5B16%5D%3Dthis.currentTime%3Blet%20s%3Dt%5B0%5D%2Ci%3Dthis.sampleIndex%2Cr%3Ds%5B0%5D.length%3Bfor%28let%20e%3D0%3Be%3Cr%3B%2B%2Be%29s%5B0%5D%5Be%5D%3Dthis.snd%28i%2B%2B%29%2Cs%5B1%5D%5Be%5D%3Dthis.snd%28i%2B%2B%29%3Bthis.sampleIndex%3D4294967295%26i%2Cthis.currentTime%2B%3Dr%2F44.1%7Dreturn%210%7D%7DregisterProcessor%28%22apu%22%2Cs%29%3B")),i=new t(o);let m,Q=0,h=new Promise((e=>m=e)),y=e=>{Q|=e,3==Q&&m&&(m(!0),m=null)},E=()=>{"suspended"==o.state?(B.startButton&&(B.startButton.style="",a.style="display:none"),(B.startButton||a).onclick=()=>{o.resume()}):(B.startButton&&(B.startButton.style="display:none",a.style=""),y(1))};o.onstatechange=E,E(),n=d;let p=window.location.pathname;if(w<=1024&&!l){let e="";for(let t of A(d))e+=String.fromCharCode(t);p+="#"+btoa(e),p!=window.location.pathname+window.location.hash&&history.pushState(null,null,p)}a.width=a.width;try{let t={initial:4};f||(t.maximum=4);let a,r=new WLine truncated
|
||||||
+104
-54
@@ -37,6 +37,7 @@ struct UW8Instance {
|
|||||||
end_frame: TypedFunc<(), ()>,
|
end_frame: TypedFunc<(), ()>,
|
||||||
update: Option<TypedFunc<(), ()>>,
|
update: Option<TypedFunc<(), ()>>,
|
||||||
start_time: Instant,
|
start_time: Instant,
|
||||||
|
next_frame: Instant,
|
||||||
module: Vec<u8>,
|
module: Vec<u8>,
|
||||||
watchdog: Arc<Mutex<UW8WatchDog>>,
|
watchdog: Arc<Mutex<UW8WatchDog>>,
|
||||||
sound: Option<Uw8Sound>,
|
sound: Option<Uw8Sound>,
|
||||||
@@ -69,8 +70,7 @@ impl MicroW8 {
|
|||||||
resize: true,
|
resize: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let mut window = Window::new("MicroW8", 320, 240, options)?;
|
let window = Window::new("MicroW8", 320, 240, options)?;
|
||||||
window.limit_update_rate(Some(std::time::Duration::from_micros(16666)));
|
|
||||||
|
|
||||||
Ok(MicroW8 {
|
Ok(MicroW8 {
|
||||||
engine,
|
engine,
|
||||||
@@ -186,6 +186,7 @@ impl super::Runtime for MicroW8 {
|
|||||||
end_frame,
|
end_frame,
|
||||||
update,
|
update,
|
||||||
start_time: Instant::now(),
|
start_time: Instant::now(),
|
||||||
|
next_frame: Instant::now(),
|
||||||
module: module_data.into(),
|
module: module_data.into(),
|
||||||
watchdog,
|
watchdog,
|
||||||
sound,
|
sound,
|
||||||
@@ -198,7 +199,19 @@ impl super::Runtime for MicroW8 {
|
|||||||
let mut result = Ok(());
|
let mut result = Ok(());
|
||||||
if let Some(mut instance) = self.instance.take() {
|
if let Some(mut instance) = self.instance.take() {
|
||||||
{
|
{
|
||||||
let time = instance.start_time.elapsed().as_millis() as i32;
|
if let Some(sleep) = instance.next_frame.checked_duration_since(Instant::now()) {
|
||||||
|
std::thread::sleep(sleep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let now = Instant::now();
|
||||||
|
let time = (now - instance.start_time).as_millis() as i32;
|
||||||
|
{
|
||||||
|
let offset = ((time as u32 as i64 * 6) % 100 - 50) / 6;
|
||||||
|
instance.next_frame = now + Duration::from_millis((16 - offset) as u64);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
let mut gamepad: u32 = 0;
|
let mut gamepad: u32 = 0;
|
||||||
for key in self.window.get_keys() {
|
for key in self.window.get_keys() {
|
||||||
if let Some(index) = GAMEPAD_KEYS
|
if let Some(index) = GAMEPAD_KEYS
|
||||||
@@ -232,7 +245,10 @@ impl super::Runtime for MicroW8 {
|
|||||||
let mut sound_regs = [0u8; 32];
|
let mut sound_regs = [0u8; 32];
|
||||||
sound_regs.copy_from_slice(&memory[80..112]);
|
sound_regs.copy_from_slice(&memory[80..112]);
|
||||||
if let Some(ref sound) = instance.sound {
|
if let Some(ref sound) = instance.sound {
|
||||||
sound.tx.send(sound_regs)?;
|
sound.tx.send(RegisterUpdate {
|
||||||
|
time,
|
||||||
|
data: sound_regs,
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let framebuffer = &memory[120..(120 + 320 * 240)];
|
let framebuffer = &memory[120..(120 + 320 * 240)];
|
||||||
@@ -312,9 +328,14 @@ fn instantiate_platform(
|
|||||||
Ok(platform_instance)
|
Ok(platform_instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct RegisterUpdate {
|
||||||
|
time: i32,
|
||||||
|
data: [u8; 32],
|
||||||
|
}
|
||||||
|
|
||||||
struct Uw8Sound {
|
struct Uw8Sound {
|
||||||
stream: cpal::Stream,
|
stream: cpal::Stream,
|
||||||
tx: mpsc::SyncSender<[u8; 32]>,
|
tx: mpsc::SyncSender<RegisterUpdate>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_sound(
|
fn init_sound(
|
||||||
@@ -368,7 +389,7 @@ fn init_sound(
|
|||||||
let buffer_size = match *config.buffer_size() {
|
let buffer_size = match *config.buffer_size() {
|
||||||
cpal::SupportedBufferSize::Unknown => cpal::BufferSize::Default,
|
cpal::SupportedBufferSize::Unknown => cpal::BufferSize::Default,
|
||||||
cpal::SupportedBufferSize::Range { min, max } => {
|
cpal::SupportedBufferSize::Range { min, max } => {
|
||||||
cpal::BufferSize::Fixed(256.max(min).min(max))
|
cpal::BufferSize::Fixed(65536.max(min).min(max))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let config = cpal::StreamConfig {
|
let config = cpal::StreamConfig {
|
||||||
@@ -378,9 +399,7 @@ fn init_sound(
|
|||||||
|
|
||||||
let sample_rate = config.sample_rate.0 as usize;
|
let sample_rate = config.sample_rate.0 as usize;
|
||||||
|
|
||||||
let (tx, rx) = mpsc::sync_channel::<[u8; 32]>(1);
|
let (tx, rx) = mpsc::sync_channel::<RegisterUpdate>(30);
|
||||||
|
|
||||||
let start_time = Instant::now();
|
|
||||||
|
|
||||||
struct Resampler {
|
struct Resampler {
|
||||||
resampler: rubato::FftFixedIn<f32>,
|
resampler: rubato::FftFixedIn<f32>,
|
||||||
@@ -403,60 +422,91 @@ fn init_sound(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut sample_index = 0;
|
let mut sample_index = 0;
|
||||||
|
let mut pending_updates: Vec<RegisterUpdate> = Vec::with_capacity(30);
|
||||||
|
let mut current_time = 0;
|
||||||
let stream = device.build_output_stream(
|
let stream = device.build_output_stream(
|
||||||
&config,
|
&config,
|
||||||
move |mut buffer: &mut [f32], _| {
|
move |mut outer_buffer: &mut [f32], _| {
|
||||||
if let Ok(regs) = rx.try_recv() {
|
let mut first_update = true;
|
||||||
memory.write(&mut store, 80, ®s).unwrap();
|
while let Ok(update) = rx.try_recv() {
|
||||||
|
if first_update {
|
||||||
|
current_time += update.time.wrapping_sub(current_time) / 8;
|
||||||
|
first_update = false;
|
||||||
|
}
|
||||||
|
pending_updates.push(update);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
while !outer_buffer.is_empty() {
|
||||||
let time = start_time.elapsed().as_millis() as i32;
|
while pending_updates
|
||||||
let mem = memory.data_mut(&mut store);
|
.first()
|
||||||
mem[64..68].copy_from_slice(&time.to_le_bytes());
|
.into_iter()
|
||||||
}
|
.any(|u| u.time.wrapping_sub(current_time) <= 0)
|
||||||
|
{
|
||||||
|
let update = pending_updates.remove(0);
|
||||||
|
memory.write(&mut store, 80, &update.data).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(ref mut resampler) = resampler {
|
let duration = if let Some(update) = pending_updates.first() {
|
||||||
while !buffer.is_empty() {
|
((update.time.wrapping_sub(current_time) as usize) * sample_rate + 999) / 1000
|
||||||
let copy_size = resampler.output_buffers[0]
|
} else {
|
||||||
.len()
|
outer_buffer.len()
|
||||||
.saturating_sub(resampler.output_index)
|
};
|
||||||
.min(buffer.len() / 2);
|
let step_size = (duration.max(64) * 2).min(outer_buffer.len());
|
||||||
if copy_size == 0 {
|
|
||||||
resampler.input_buffers[0].clear();
|
|
||||||
resampler.input_buffers[1].clear();
|
|
||||||
for _ in 0..resampler.resampler.input_frames_next() {
|
|
||||||
resampler.input_buffers[0]
|
|
||||||
.push(snd.call(&mut store, (sample_index,)).unwrap_or(0.0));
|
|
||||||
resampler.input_buffers[1]
|
|
||||||
.push(snd.call(&mut store, (sample_index + 1,)).unwrap_or(0.0));
|
|
||||||
sample_index = sample_index.wrapping_add(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
resampler
|
let mut buffer = &mut outer_buffer[..step_size];
|
||||||
.resampler
|
|
||||||
.process_into_buffer(
|
{
|
||||||
&resampler.input_buffers,
|
let mem = memory.data_mut(&mut store);
|
||||||
&mut resampler.output_buffers,
|
mem[64..68].copy_from_slice(¤t_time.to_le_bytes());
|
||||||
None,
|
}
|
||||||
)
|
|
||||||
.unwrap();
|
if let Some(ref mut resampler) = resampler {
|
||||||
resampler.output_index = 0;
|
while !buffer.is_empty() {
|
||||||
} else {
|
let copy_size = resampler.output_buffers[0]
|
||||||
for i in 0..copy_size {
|
.len()
|
||||||
buffer[i * 2] = resampler.output_buffers[0][resampler.output_index + i];
|
.saturating_sub(resampler.output_index)
|
||||||
buffer[i * 2 + 1] =
|
.min(buffer.len() / 2);
|
||||||
resampler.output_buffers[1][resampler.output_index + i];
|
if copy_size == 0 {
|
||||||
|
resampler.input_buffers[0].clear();
|
||||||
|
resampler.input_buffers[1].clear();
|
||||||
|
for _ in 0..resampler.resampler.input_frames_next() {
|
||||||
|
resampler.input_buffers[0]
|
||||||
|
.push(snd.call(&mut store, (sample_index,)).unwrap_or(0.0));
|
||||||
|
resampler.input_buffers[1]
|
||||||
|
.push(snd.call(&mut store, (sample_index + 1,)).unwrap_or(0.0));
|
||||||
|
sample_index = sample_index.wrapping_add(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
resampler
|
||||||
|
.resampler
|
||||||
|
.process_into_buffer(
|
||||||
|
&resampler.input_buffers,
|
||||||
|
&mut resampler.output_buffers,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
resampler.output_index = 0;
|
||||||
|
} else {
|
||||||
|
for i in 0..copy_size {
|
||||||
|
buffer[i * 2] =
|
||||||
|
resampler.output_buffers[0][resampler.output_index + i];
|
||||||
|
buffer[i * 2 + 1] =
|
||||||
|
resampler.output_buffers[1][resampler.output_index + i];
|
||||||
|
}
|
||||||
|
resampler.output_index += copy_size;
|
||||||
|
buffer = &mut buffer[copy_size * 2..];
|
||||||
}
|
}
|
||||||
resampler.output_index += copy_size;
|
}
|
||||||
buffer = &mut buffer[copy_size * 2..];
|
} else {
|
||||||
|
for v in buffer {
|
||||||
|
*v = snd.call(&mut store, (sample_index,)).unwrap_or(0.0);
|
||||||
|
sample_index = sample_index.wrapping_add(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
for v in buffer {
|
outer_buffer = &mut outer_buffer[step_size..];
|
||||||
*v = snd.call(&mut store, (sample_index,)).unwrap_or(0.0);
|
current_time =
|
||||||
sample_index = sample_index.wrapping_add(1);
|
current_time.wrapping_add((step_size * 500 / sample_rate).max(1) as i32);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
move |err| {
|
move |err| {
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
include "../examples/include/microw8-api.cwa"
|
||||||
|
|
||||||
|
global mut pos = 0;
|
||||||
|
global mut next = 0;
|
||||||
|
|
||||||
|
export fn upd() {
|
||||||
|
let lazy t = 32!32;
|
||||||
|
let lazy tick = t * 6 / 100;
|
||||||
|
let lazy rel = t - tick * 100 / 6;
|
||||||
|
|
||||||
|
setBackgroundColor(select(tick == next, 0, select(tick < next, 0x35, 0x55)));
|
||||||
|
setCursorPosition(pos % 13 * 3, pos / 13 % 30);
|
||||||
|
if rel < 10 {
|
||||||
|
printChar(32);
|
||||||
|
}
|
||||||
|
printInt(rel);
|
||||||
|
|
||||||
|
pos = pos + 1;
|
||||||
|
next = tick + 1;
|
||||||
|
}
|
||||||
File renamed without changes.
+15
-6
@@ -3,13 +3,17 @@ class APU extends AudioWorkletProcessor {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.sampleIndex = 0;
|
this.sampleIndex = 0;
|
||||||
|
this.currentTime = 0;
|
||||||
|
this.isFirstMessage = true;
|
||||||
|
this.pendingUpdates = [];
|
||||||
this.port.onmessage = (ev) => {
|
this.port.onmessage = (ev) => {
|
||||||
if(this.memory) {
|
if(this.memory) {
|
||||||
if(isNaN(ev.data)) {
|
if(this.isFirstMessage)
|
||||||
U8(this.memory.buffer, 80, 32).set(U8(ev.data));
|
{
|
||||||
} else {
|
this.currentTime += (ev.data.t - this.currentTime) / 8;
|
||||||
this.startTime = ev.data;
|
this.isFirstMessage = false;
|
||||||
}
|
}
|
||||||
|
this.pendingUpdates.push(ev.data);
|
||||||
} else {
|
} else {
|
||||||
this.load(ev.data[0], ev.data[1]);
|
this.load(ev.data[0], ev.data[1]);
|
||||||
}
|
}
|
||||||
@@ -55,9 +59,13 @@ class APU extends AudioWorkletProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
process(inputs, outputs, parameters) {
|
process(inputs, outputs, parameters) {
|
||||||
if(this.snd && this.startTime) {
|
this.isFirstMessage = true;
|
||||||
|
if(this.snd) {
|
||||||
|
while(this.pendingUpdates.length > 0 && this.pendingUpdates[0].t <= this.currentTime) {
|
||||||
|
U8(this.memory.buffer, 80, 32).set(U8(this.pendingUpdates.shift().r));
|
||||||
|
}
|
||||||
let u32Mem = new Uint32Array(this.memory.buffer);
|
let u32Mem = new Uint32Array(this.memory.buffer);
|
||||||
u32Mem[16] = Date.now() - this.startTime;
|
u32Mem[16] = this.currentTime;
|
||||||
let channels = outputs[0];
|
let channels = outputs[0];
|
||||||
let index = this.sampleIndex;
|
let index = this.sampleIndex;
|
||||||
let numSamples = channels[0].length;
|
let numSamples = channels[0].length;
|
||||||
@@ -66,6 +74,7 @@ class APU extends AudioWorkletProcessor {
|
|||||||
channels[1][i] = this.snd(index++);
|
channels[1][i] = this.snd(index++);
|
||||||
}
|
}
|
||||||
this.sampleIndex = index & 0xffffffff;
|
this.sampleIndex = index & 0xffffffff;
|
||||||
|
this.currentTime += numSamples / 44.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="uw8">
|
<div id="uw8">
|
||||||
<a href="https://exoticorn.github.io/microw8">MicroW8</a> 0.2.0-rc1
|
<a href="https://exoticorn.github.io/microw8">MicroW8</a> 0.2.0-rc2
|
||||||
</div>
|
</div>
|
||||||
<div id="centered">
|
<div id="centered">
|
||||||
<canvas class="screen" id="screen" width="320" height="240">
|
<canvas class="screen" id="screen" width="320" height="240">
|
||||||
|
|||||||
+12
-8
@@ -107,7 +107,7 @@ export default function MicroW8(screen, config = {}) {
|
|||||||
audioContext.close();
|
audioContext.close();
|
||||||
keepRunning = false;
|
keepRunning = false;
|
||||||
abortController.abort();
|
abortController.abort();
|
||||||
}
|
};
|
||||||
|
|
||||||
let cartridgeSize = data.byteLength;
|
let cartridgeSize = data.byteLength;
|
||||||
|
|
||||||
@@ -232,7 +232,6 @@ export default function MicroW8(screen, config = {}) {
|
|||||||
let startTime = Date.now();
|
let startTime = Date.now();
|
||||||
|
|
||||||
const timePerFrame = 1000 / 60;
|
const timePerFrame = 1000 / 60;
|
||||||
let nextFrame = startTime;
|
|
||||||
|
|
||||||
audioNode.connect(audioContext.destination);
|
audioNode.connect(audioContext.destination);
|
||||||
|
|
||||||
@@ -244,12 +243,10 @@ export default function MicroW8(screen, config = {}) {
|
|||||||
isPaused = false;
|
isPaused = false;
|
||||||
audioContext.resume();
|
audioContext.resume();
|
||||||
startTime += now - pauseTime;
|
startTime += now - pauseTime;
|
||||||
audioNode.port.postMessage(startTime);
|
|
||||||
} else {
|
} else {
|
||||||
isPaused = true;
|
isPaused = true;
|
||||||
audioContext.suspend();
|
audioContext.suspend();
|
||||||
pauseTime = now;
|
pauseTime = now;
|
||||||
audioNode.port.postMessage(0);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.addEventListener('focus', () => updateVisibility(true), { signal: abortController.signal });
|
window.addEventListener('focus', () => updateVisibility(true), { signal: abortController.signal });
|
||||||
@@ -263,6 +260,7 @@ export default function MicroW8(screen, config = {}) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let restart = false;
|
let restart = false;
|
||||||
|
let thisFrame;
|
||||||
if (!isPaused) {
|
if (!isPaused) {
|
||||||
let gamepads = navigator.getGamepads();
|
let gamepads = navigator.getGamepads();
|
||||||
let gamepad = 0;
|
let gamepad = 0;
|
||||||
@@ -291,7 +289,8 @@ export default function MicroW8(screen, config = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let u32Mem = U32(memory.buffer);
|
let u32Mem = U32(memory.buffer);
|
||||||
u32Mem[16] = Date.now() - startTime;
|
let time = Date.now() - startTime;
|
||||||
|
u32Mem[16] = time;
|
||||||
u32Mem[17] = pad | gamepad;
|
u32Mem[17] = pad | gamepad;
|
||||||
if(instance.exports.upd) {
|
if(instance.exports.upd) {
|
||||||
instance.exports.upd();
|
instance.exports.upd();
|
||||||
@@ -300,21 +299,26 @@ export default function MicroW8(screen, config = {}) {
|
|||||||
|
|
||||||
let soundRegisters = new ArrayBuffer(32);
|
let soundRegisters = new ArrayBuffer(32);
|
||||||
U8(soundRegisters).set(U8(memory.buffer, 80, 32));
|
U8(soundRegisters).set(U8(memory.buffer, 80, 32));
|
||||||
audioNode.port.postMessage(soundRegisters, [soundRegisters]);
|
audioNode.port.postMessage({t: time, r: soundRegisters}, [soundRegisters]);
|
||||||
|
|
||||||
let palette = U32(memory.buffer, 0x13000, 1024);
|
let palette = U32(memory.buffer, 0x13000, 1024);
|
||||||
for (let i = 0; i < 320 * 240; ++i) {
|
for (let i = 0; i < 320 * 240; ++i) {
|
||||||
buffer[i] = palette[memU8[i + 120]] | 0xff000000;
|
buffer[i] = palette[memU8[i + 120]] | 0xff000000;
|
||||||
}
|
}
|
||||||
canvasCtx.putImageData(imageData, 0, 0);
|
canvasCtx.putImageData(imageData, 0, 0);
|
||||||
|
|
||||||
|
let timeOffset = ((time * 6) % 100 - 50) / 6;
|
||||||
|
thisFrame = startTime + time - timeOffset / 8;
|
||||||
|
} else {
|
||||||
|
thisFrame = Date.now();
|
||||||
}
|
}
|
||||||
let now = Date.now();
|
let now = Date.now();
|
||||||
nextFrame = Math.max(nextFrame + timePerFrame, now);
|
let nextFrame = Math.max(thisFrame + timePerFrame, now);
|
||||||
|
|
||||||
if (restart) {
|
if (restart) {
|
||||||
runModule(currentData);
|
runModule(currentData);
|
||||||
} else {
|
} else {
|
||||||
window.setTimeout(mainloop, Math.round(nextFrame - now))
|
window.setTimeout(mainloop, nextFrame - now)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
config.setMessage(cartridgeSize, err.toString());
|
config.setMessage(cartridgeSize, err.toString());
|
||||||
|
|||||||
Reference in new issue
Block a user