1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-06-06 09:29:33 +00:00

VCS replay buffer

This commit is contained in:
Steven Hugg 2018-08-22 10:09:07 -04:00
parent b386d2e87a
commit d9c41ca9d7
5 changed files with 54 additions and 13 deletions

View File

@ -295,5 +295,4 @@ div.replaydiv {
bottom:0;
width:50%;
background-color: #666;
margin-top: 20px auto 0;
}

@ -1 +1 @@
Subproject commit 4cd5b798f534336d09a80e8a1fa962959f401359
Subproject commit 500c33f4e8b854ddacaa588c47c23983feb27c24

View File

@ -172,6 +172,7 @@ var JSNESPlatform = function(mainElement) {
this.copy6502REGvars(c);
return c;
}
// TODO don't need to save ROM?
this.saveState = function() {
//var s = $.extend(true, {}, nes);
var s = nes.toJSON();

View File

@ -1,6 +1,6 @@
"use strict";
import { Platform, cpuStateToLongString_6502, BaseMAMEPlatform } from "../baseplatform";
import { Platform, cpuStateToLongString_6502, BaseMAMEPlatform, EmuRecorder } from "../baseplatform";
import { PLATFORMS, RAM, newAddressDecoder, dumpRAM } from "../emu";
import { hex, lpad, tobin, byte2signed } from "../util";
import { CodeAnalyzer_vcs } from "../analysis";
@ -49,12 +49,20 @@ Javatari.AUDIO_BUFFER_SIZE = 256;
var VCSPlatform = function() {
var self = this;
this.paused = true;
this.getPresets = function() { return VCS_PRESETS; }
this.start = function() {
$("#javatari-div").show();
Javatari.start();
// intercept clockPulse function
Javatari.room.console.oldClockPulse = Javatari.room.console.clockPulse;
Javatari.room.console.clockPulse = function() {
this.oldClockPulse();
self.updateRecorder();
}
this.paused = false;
}
this.loadROM = function(title, data) {
@ -75,15 +83,39 @@ var VCSPlatform = function() {
return {x:xpos, y:ypos};
}
this.isRunning = function() { return Javatari.room && Javatari.room.console.isRunning(); }
this.pause = function() { Javatari.room.console.pause(); Javatari.room.speaker.mute(); }
this.resume = function() { Javatari.room.console.go(); Javatari.room.speaker.play(); }
// TODO: Clock changes this on event, so it may not be current
this.isRunning = function() {
return Javatari.room && Javatari.room.console.isRunning();
}
this.pause = function() {
//console.log('pause', this.paused, this.isRunning());
if (!this.paused) {
this.paused = true;
Javatari.room.console.pause();
Javatari.room.speaker.mute();
}
}
this.resume = function() {
//console.log('resume', this.paused, this.isRunning());
if (this.paused) {
this.paused = false;
Javatari.room.console.go();
Javatari.room.speaker.play();
}
}
this.advance = function() {
Javatari.room.console.clockPulse();
}
this.step = function() { Javatari.room.console.debugSingleStepCPUClock(); }
this.stepBack = function() { Javatari.room.console.debugStepBackInstruction(); }
this.runEval = function(evalfunc) { Javatari.room.console.debugEval(evalfunc); }
this.setupDebug = function(callback) {
Javatari.room.console.onBreakpointHit = callback;
Javatari.room.console.onBreakpointHit = function(state) {
self.paused = true;
callback(state);
}
Javatari.room.speaker.mute();
}
this.clearDebug = function() {
@ -91,6 +123,7 @@ var VCSPlatform = function() {
Javatari.room.console.onBreakpointHit = null;
if (this.isRunning()) Javatari.room.speaker.play();
}
this.reset = function() {
Javatari.room.console.powerOff();
Javatari.room.console.resetDebug();
@ -103,14 +136,12 @@ var VCSPlatform = function() {
this.newCodeAnalyzer = function() {
return new CodeAnalyzer_vcs(this);
}
/*
this.saveState = function() {
return Javatari.room.console.saveState(); // TODO
return Javatari.room.console.saveState();
}
this.loadState = function(state) {
return Javatari.room.console.loadState(state); // TODO
return Javatari.room.console.loadState(state);
}
*/
this.readAddress = function(addr) {
return this.current_output[addr & 0xfff]; // TODO: use bus to read
}
@ -182,6 +213,16 @@ var VCSPlatform = function() {
s += "Ball"+ lpad(t['bco'],11) + lpad(nonegstr(t['bsc']),5) + lpad(t['bss'],6) + "\n";
return s;
}
this.setRecorder = function(recorder : EmuRecorder) : void {
this.recorder = recorder;
}
this.updateRecorder = function() {
// are we recording and do we need to save a frame?
if (this.recorder && !this.paused && this.isRunning() && this.recorder.frameRequested()) {
this.recorder.recordFrame(this, this.saveState());
}
}
};
function nonegstr(n) {
@ -226,6 +267,7 @@ var VCSMAMEPlatform = function(mainElement) {
return Javatari.getOpcodeMetadata(opcode, offset);
}
*/
}
////////////////

View File

@ -544,7 +544,6 @@ function runStepBackwards() {
}
function clearBreakpoint() {
_disableRecording();
lastDebugState = null;
if (platform.clearDebug) platform.clearDebug();
showDebugInfo();