From 2e27b0d2bb14779b6454275fb0352b9cd73882d6 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Thu, 9 Jul 2020 07:03:09 -0500 Subject: [PATCH] show >8 bit arrays in debug, check for non-typed arrays in state, fix embed iframe --- doc/notes.txt | 1 + embed.html | 2 +- jsnes | 2 +- src/common/emu.ts | 12 +++++++----- src/common/recorder.ts | 1 + src/ide/views.ts | 5 +++-- src/machine/apple2.ts | 5 +++-- test/cli/testplatforms.js | 13 +++++++++++++ 8 files changed, 30 insertions(+), 11 deletions(-) diff --git a/doc/notes.txt b/doc/notes.txt index f7cc5a88..15a96465 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -192,6 +192,7 @@ TODO: - copy to gen/ directory (allowJs is weird) - can we debug first frame via replay? - ca65 line numbers are not aligned with source code + - segments not read properly - Debug Browser - hex viewer - show 16/32 typed arrays diff --git a/embed.html b/embed.html index d8e664b5..e72a007f 100644 --- a/embed.html +++ b/embed.html @@ -17,7 +17,7 @@ flex-grow: 1; } .emuvideo { - width:90%; + width: calc(100% - 70px); border-radius:20px; border: 4px solid #222; outline-color: #666; diff --git a/jsnes b/jsnes index 03614b82..a6a026b6 160000 --- a/jsnes +++ b/jsnes @@ -1 +1 @@ -Subproject commit 03614b82158dabc4fc78c728be0b6a847538b957 +Subproject commit a6a026b698f9a68372cc94b46182e3abedc26672 diff --git a/src/common/emu.ts b/src/common/emu.ts index 4be86303..ed05ca06 100644 --- a/src/common/emu.ts +++ b/src/common/emu.ts @@ -305,15 +305,17 @@ export class AnimationTimer { // TODO: move to util? -export function dumpRAM(ram:Uint8Array|number[], ramofs:number, ramlen:number) : string { +export function dumpRAM(ram:ArrayLike, ramofs:number, ramlen:number) : string { var s = ""; + var bpel = ram['BYTES_PER_ELEMENT'] || 1; + var perline = Math.ceil(16 / bpel); // TODO: show scrollable RAM for other platforms - for (var ofs=0; ofs { + if (entry[1] instanceof Array && entry[1].length > 200) { + if (typeof entry[1][0] == 'number' && entry[1].buffer == null) + throw new Error("array in save state not typed: " + path + '/' + entry[0]); + } + checkForBigNonTypedArrays(entry[1], path + '/' + entry[0]); + }); +} + async function testPlatform(platid, romname, maxframes, callback) { var platform = new emu.PLATFORMS[platid](emudiv); await platform.start(); @@ -127,6 +138,7 @@ async function testPlatform(platid, romname, maxframes, callback) { rom = new Uint8Array(rom); platform.loadROM("ROM", rom); var state0a = platform.saveState(); + checkForBigNonTypedArrays(state0a); platform.reset(); // reset again var state0b = platform.saveState(); //TODO: vcs fails assert.deepEqual(state0a, state0b); @@ -152,6 +164,7 @@ async function testPlatform(platid, romname, maxframes, callback) { assert.equal(maxframes, rec.loadFrame(maxframes)); var state2 = platform.saveState(); assert.deepEqual(state1, state2); + checkForBigNonTypedArrays(state2); // test memory reads not clearing stuff for (var i=0; i<=0xffff; i++) if (platform.readAddress) platform.readAddress(i);