1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-22 12:30:01 +00:00

nes runToVsync; debug info changes

This commit is contained in:
Steven Hugg 2018-08-02 17:47:10 -04:00
parent 108dedd909
commit 7880602e81
3 changed files with 28 additions and 9 deletions

View File

@ -1,4 +1,4 @@

.include "hvsync_generator.v" .include "hvsync_generator.v"
.include "font_cp437_8x8.v" .include "font_cp437_8x8.v"
.include "ram.v" .include "ram.v"

View File

@ -59,6 +59,7 @@ var JSNESPlatform = function(mainElement) {
var rom; var rom;
var video, audio, timer; var video, audio, timer;
var audioFrequency = 44100; var audioFrequency = 44100;
var frameindex = 0;
this.getPresets = function() { return JSNES_PRESETS; } this.getPresets = function() { return JSNES_PRESETS; }
@ -73,8 +74,12 @@ var JSNESPlatform = function(mainElement) {
idata[i] = frameBuffer[i] | 0xff000000; idata[i] = frameBuffer[i] | 0xff000000;
video.updateFrame(); video.updateFrame();
self.restartDebugState(); self.restartDebugState();
frameindex++;
}, },
onAudioSample: function(left, right) { onAudioSample: function(left, right) {
if (frameindex < 10)
audio.feedSample(0, 1); // avoid popping at powerup
else
audio.feedSample(left+right, 1); audio.feedSample(left+right, 1);
}, },
onStatusUpdate: function(s) { onStatusUpdate: function(s) {
@ -132,6 +137,11 @@ var JSNESPlatform = function(mainElement) {
audio.start(); audio.start();
} }
this.runToVsync = function() {
var frame0 = frameindex;
platform.runEval(function(c) { return frameindex>frame0; });
}
this.getCPUState = function() { this.getCPUState = function() {
var c = nes.cpu.toJSON(); var c = nes.cpu.toJSON();
this.copy6502REGvars(c); this.copy6502REGvars(c);
@ -185,10 +195,10 @@ var JSNESPlatform = function(mainElement) {
switch (category) { switch (category) {
case 'CPU': return cpuStateToLongString_6502(state.c); case 'CPU': return cpuStateToLongString_6502(state.c);
case 'ZPRAM': return dumpRAM(state.cpu.mem, 0, 0x100); case 'ZPRAM': return dumpRAM(state.cpu.mem, 0, 0x100);
case 'PPU': return this.ppuStateToLongString(state.ppu); case 'PPU': return this.ppuStateToLongString(state.ppu, state.cpu.mem);
} }
} }
this.ppuStateToLongString = function(ppu) { this.ppuStateToLongString = function(ppu, mem) {
var s = ''; var s = '';
var PPUFLAGS = [ var PPUFLAGS = [
["f_nmiOnVblank","NMI_ON_VBLANK"], ["f_nmiOnVblank","NMI_ON_VBLANK"],
@ -203,6 +213,10 @@ var JSNESPlatform = function(mainElement) {
s += (ppu[flag[0]] ? flag[1] : "-") + " "; s += (ppu[flag[0]] ? flag[1] : "-") + " ";
if (i==2 || i==5) s += "\n"; if (i==2 || i==5) s += "\n";
} }
var status = mem[0x2002];
s += "\n Status ";
s += (status & 0x80) ? "VBLANK " : "- ";
s += (status & 0x40) ? "SPRITE0HIT " : "- ";
s += "\n"; s += "\n";
s += "BgColor " + ['black','blue','green','red'][ppu.f_color] + "\n"; s += "BgColor " + ['black','blue','green','red'][ppu.f_color] + "\n";
if (ppu.f_spVisibility) { if (ppu.f_spVisibility) {
@ -214,19 +228,23 @@ var JSNESPlatform = function(mainElement) {
s += " NTBase $" + hex(ppu.f_nTblAddress*0x400+0x2000) + "\n"; s += " NTBase $" + hex(ppu.f_nTblAddress*0x400+0x2000) + "\n";
s += "AddrInc " + (ppu.f_addrInc ? "32" : "1") + "\n"; s += "AddrInc " + (ppu.f_addrInc ? "32" : "1") + "\n";
} }
var scrollX = ppu.regFH + ppu.regHT*8;
var scrollY = ppu.regFV + ppu.regVT*8;
s += "ScrollX $" + hex(scrollX) + " (" + ppu.regHT + " * 8 + " + ppu.regFH + " = " + scrollX + ")\n";
s += "ScrollY $" + hex(scrollY) + " (" + ppu.regVT + " * 8 + " + ppu.regFV + " = " + scrollY + ")\n";
s += " Vstart $" + hex(ppu.vramTmpAddress,4) + "\n";
s += "\n";
s += " Scan Y: " + ppu.scanline + " X: " + ppu.curX + "\n";
s += " VRAM " + (ppu.firstWrite?"@":"?") + " $" + hex(ppu.vramAddress,4) + "\n"; s += " VRAM " + (ppu.firstWrite?"@":"?") + " $" + hex(ppu.vramAddress,4) + "\n";
/*
var PPUREGS = [ var PPUREGS = [
'cntFV', 'cntFV',
'cntV', 'cntV',
'cntH', 'cntH',
'cntVT', 'cntVT',
'cntHT', 'cntHT',
'regFV',
'regV', 'regV',
'regH', 'regH',
'regVT',
'regHT',
'regFH',
'regS', 'regS',
]; ];
s += "\n"; s += "\n";
@ -234,6 +252,7 @@ var JSNESPlatform = function(mainElement) {
var reg = PPUREGS[i]; var reg = PPUREGS[i];
s += lpad(reg.toUpperCase(),7) + " $" + hex(ppu[reg]) + " (" + ppu[reg] + ")\n"; s += lpad(reg.toUpperCase(),7) + " $" + hex(ppu[reg]) + " (" + ppu[reg] + ")\n";
} }
*/
return s; return s;
} }
} }

View File

@ -196,7 +196,7 @@ describe('Worker', function() {
assert.ok(fn); assert.ok(fn);
done(err, msg); done(err, msg);
}; };
doBuild(msgs, done2, 1996909, 0, 0); doBuild(msgs, done2, 1997627, 0, 0);
}); });
it('should NOT preprocess SDCC', function(done) { it('should NOT preprocess SDCC', function(done) {
compile('sdcc', 'int x=0\n#bah\n', 'mw8080bw', done, 0, 0, 1); compile('sdcc', 'int x=0\n#bah\n', 'mw8080bw', done, 0, 0, 1);