mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-01-24 19:33:17 +00:00
fix VCS hanging up when loading rom when paused; also fixed same bug in AnimationTimer
This commit is contained in:
parent
3c9560f273
commit
c157f4b071
13
index.html
13
index.html
@ -278,17 +278,14 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
|||||||
<link rel="stylesheet" href="codemirror/addon/dialog/dialog.css">
|
<link rel="stylesheet" href="codemirror/addon/dialog/dialog.css">
|
||||||
|
|
||||||
<script src="javatari.js/release/javatari/javatari.js"></script>
|
<script src="javatari.js/release/javatari/javatari.js"></script>
|
||||||
|
<!--
|
||||||
|
<script src="javatari.js/src/main/Javatari.js"></script>
|
||||||
|
<script src="javatari.js/temp/javatari.part.concat.js"></script>
|
||||||
|
-->
|
||||||
<script src="src/cpu/z80fast.js"></script>
|
<script src="src/cpu/z80fast.js"></script>
|
||||||
<script src="jsnes/jsnes.min.js"></script>
|
<script src="jsnes/jsnes.min.js"></script>
|
||||||
<!--<script src="src/cpu/6809.js"></script>-->
|
<!--<script src="src/cpu/6809.js"></script>-->
|
||||||
<!--
|
<!--<script src="jsnes/lib/dynamicaudio-min.js" type="text/javascript" charset="utf-8"></script>-->
|
||||||
<script src="jsnes/lib/dynamicaudio-min.js" type="text/javascript" charset="utf-8"></script>
|
|
||||||
-->
|
|
||||||
<!--
|
|
||||||
<script src="local/williams/defender.js"></script>
|
|
||||||
<script src="local/williams/robotron.js"></script>
|
|
||||||
<script src="local/atarivec/gravitar/gravitar.js"></script>
|
|
||||||
-->
|
|
||||||
<script src="FileSaver.js/FileSaver.min.js"></script>
|
<script src="FileSaver.js/FileSaver.min.js"></script>
|
||||||
<script src="localForage/dist/localforage.nopromises.js"></script>
|
<script src="localForage/dist/localforage.nopromises.js"></script>
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 8f5767e4ca9a759d759e9a09677d649d58f6aff7
|
Subproject commit 7e246e74bd56c76acf8b7e05334f0221e1783977
|
10
src/emu.ts
10
src/emu.ts
@ -176,7 +176,8 @@ export class RAM {
|
|||||||
|
|
||||||
export var AnimationTimer = function(frequencyHz:number, callback:() => void) {
|
export var AnimationTimer = function(frequencyHz:number, callback:() => void) {
|
||||||
var intervalMsec = 1000.0 / frequencyHz;
|
var intervalMsec = 1000.0 / frequencyHz;
|
||||||
var running;
|
var running : boolean = false;
|
||||||
|
var pulsing : boolean = false;
|
||||||
var lastts = 0;
|
var lastts = 0;
|
||||||
var useReqAnimFrame = false; //window.requestAnimationFrame ? (frequencyHz>40) : false;
|
var useReqAnimFrame = false; //window.requestAnimationFrame ? (frequencyHz>40) : false;
|
||||||
var nframes, startts; // for FPS calc
|
var nframes, startts; // for FPS calc
|
||||||
@ -197,6 +198,8 @@ export var AnimationTimer = function(frequencyHz:number, callback:() => void) {
|
|||||||
}
|
}
|
||||||
if (running) {
|
if (running) {
|
||||||
scheduleFrame(lastts - ts);
|
scheduleFrame(lastts - ts);
|
||||||
|
} else {
|
||||||
|
pulsing = false;
|
||||||
}
|
}
|
||||||
if (!useReqAnimFrame || lastts - ts > intervalMsec/2) {
|
if (!useReqAnimFrame || lastts - ts > intervalMsec/2) {
|
||||||
if (running) {
|
if (running) {
|
||||||
@ -221,7 +224,10 @@ export var AnimationTimer = function(frequencyHz:number, callback:() => void) {
|
|||||||
running = true;
|
running = true;
|
||||||
lastts = 0;
|
lastts = 0;
|
||||||
nframes = 0;
|
nframes = 0;
|
||||||
scheduleFrame(0);
|
if (!pulsing) {
|
||||||
|
scheduleFrame(0);
|
||||||
|
pulsing = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.stop = function() {
|
this.stop = function() {
|
||||||
|
@ -50,7 +50,6 @@ Javatari.AUDIO_BUFFER_SIZE = 256;
|
|||||||
class VCSPlatform {
|
class VCSPlatform {
|
||||||
|
|
||||||
recorder : EmuRecorder;
|
recorder : EmuRecorder;
|
||||||
paused : boolean = true;
|
|
||||||
|
|
||||||
getPresets() { return VCS_PRESETS; }
|
getPresets() { return VCS_PRESETS; }
|
||||||
|
|
||||||
@ -64,11 +63,12 @@ class VCSPlatform {
|
|||||||
self.updateRecorder();
|
self.updateRecorder();
|
||||||
this.oldClockPulse();
|
this.oldClockPulse();
|
||||||
}
|
}
|
||||||
this.paused = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadROM(title, data) {
|
loadROM(title, data) {
|
||||||
|
var wasrunning = this.isRunning();
|
||||||
Javatari.loadROM(title, data);
|
Javatari.loadROM(title, data);
|
||||||
|
if (!wasrunning) this.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
getOpcodeMetadata(opcode, offset) {
|
getOpcodeMetadata(opcode, offset) {
|
||||||
@ -86,23 +86,16 @@ class VCSPlatform {
|
|||||||
|
|
||||||
// TODO: Clock changes this on event, so it may not be current
|
// TODO: Clock changes this on event, so it may not be current
|
||||||
isRunning() {
|
isRunning() {
|
||||||
|
//console.log(Javatari.room.console.isRunning(), Javatari.room.console.isPowerOn);
|
||||||
return Javatari.room && Javatari.room.console.isRunning();
|
return Javatari.room && Javatari.room.console.isRunning();
|
||||||
}
|
}
|
||||||
pause() {
|
pause() {
|
||||||
//console.log('pause', this.paused, this.isRunning());
|
Javatari.room.console.pause();
|
||||||
if (!this.paused) {
|
Javatari.room.speaker.mute();
|
||||||
this.paused = true;
|
|
||||||
Javatari.room.console.pause();
|
|
||||||
Javatari.room.speaker.mute();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
resume() {
|
resume() {
|
||||||
//console.log('resume', this.paused, this.isRunning());
|
Javatari.room.console.go();
|
||||||
if (this.paused) {
|
Javatari.room.speaker.play();
|
||||||
this.paused = false;
|
|
||||||
Javatari.room.console.go();
|
|
||||||
Javatari.room.speaker.play();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
advance() {
|
advance() {
|
||||||
Javatari.room.console.clockPulse();
|
Javatari.room.console.clockPulse();
|
||||||
@ -118,7 +111,8 @@ class VCSPlatform {
|
|||||||
|
|
||||||
setupDebug(callback) {
|
setupDebug(callback) {
|
||||||
Javatari.room.console.onBreakpointHit = (state) => {
|
Javatari.room.console.onBreakpointHit = (state) => {
|
||||||
this.paused = true;
|
Javatari.room.console.pause();
|
||||||
|
Javatari.room.speaker.mute();
|
||||||
callback(state);
|
callback(state);
|
||||||
}
|
}
|
||||||
Javatari.room.speaker.mute();
|
Javatari.room.speaker.mute();
|
||||||
@ -233,7 +227,7 @@ class VCSPlatform {
|
|||||||
}
|
}
|
||||||
updateRecorder() {
|
updateRecorder() {
|
||||||
// are we recording and do we need to save a frame?
|
// are we recording and do we need to save a frame?
|
||||||
if (this.recorder && !this.paused && this.isRunning() && this.recorder.frameRequested()) {
|
if (this.recorder && this.isRunning() && this.recorder.frameRequested()) {
|
||||||
this.recorder.recordFrame(this.saveState());
|
this.recorder.recordFrame(this.saveState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user