From ec16cf78be8bfa1af91205d1d1eb1155b0f7330c Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Sat, 7 Nov 2015 09:52:54 -0800 Subject: [PATCH] Debugger (eg, "eb" or "ew") can now patch ROMs if a physical (%%) address is used --- .../compaq/deskpro386/1988-01-28/1988-01-28.nasm | 2 +- modules/pcjs/lib/computer.js | 4 +++- modules/pcjs/lib/debugger.js | 16 ++++++++++++++-- modules/textout/lib/textout.js | 1 + 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/devices/pc/bios/compaq/deskpro386/1988-01-28/1988-01-28.nasm b/devices/pc/bios/compaq/deskpro386/1988-01-28/1988-01-28.nasm index 043f04e59..3d47327ca 100644 --- a/devices/pc/bios/compaq/deskpro386/1988-01-28/1988-01-28.nasm +++ b/devices/pc/bios/compaq/deskpro386/1988-01-28/1988-01-28.nasm @@ -13906,7 +13906,7 @@ xffb3: pop ds ; 0000FFB3 1F '.' db 0x0000 ; 0000FFB8 0000 dw 0x0000 ; 0000FFBA 0000 dw 0x0000 ; 0000FFBC 0000 - dw 0x0003 ; 0000FFBE 0300 (replaced during ROM relocation with 0x03nn where nn is the CPU revision identifier) + dw 0x0003 ; 0000FFBE 0300 (replaced during ROM relocation with 0x03nn, where nn is the CPU revision identifier) times 29 db 0xFF ; 0000FFC0 - 0000FFDC diff --git a/modules/pcjs/lib/computer.js b/modules/pcjs/lib/computer.js index 3564f51bc..9782782c1 100644 --- a/modules/pcjs/lib/computer.js +++ b/modules/pcjs/lib/computer.js @@ -131,6 +131,7 @@ function Computer(parmsComputer, parmsMachine, fSuspended) { this.nBusWidth = parmsComputer['busWidth'] || parmsComputer['buswidth']; this.resume = Computer.RESUME_NONE; this.sStateData = null; + this.fStateData = false; // remembers if sStateData was loaded this.fServerState = false; this.url = parmsMachine? parmsMachine['url'] : null; @@ -331,6 +332,7 @@ Computer.prototype.onLoadSetReady = function(sStateFile, sStateData, nErrorCode) { if (!nErrorCode) { this.sStateData = sStateData; + this.fStateData = true; if (DEBUG && this.messageEnabled()) { this.printMessage("loaded state file " + sStateFile.replace(this.sUserID || "xxx", "xxx")); } @@ -609,7 +611,7 @@ Computer.prototype.powerRestore = function(component, stateComputer, fRepower, f * TODO: Considering doing this in ALL cases, not just in situations where a * 'state' exists but we're not actually resuming from it. */ - if (this.sStatePath && !this.sStateData) { + if (this.sStatePath && !this.fStateData) { stateComputer.clear(); this.resume = Computer.RESUME_NONE; web.reloadPage(); diff --git a/modules/pcjs/lib/debugger.js b/modules/pcjs/lib/debugger.js index dca24fd8b..136c21cf4 100644 --- a/modules/pcjs/lib/debugger.js +++ b/modules/pcjs/lib/debugger.js @@ -2104,6 +2104,8 @@ if (DEBUGGER) { /** * setByte(dbgAddr, b, inc) * + * NOTE: If you need to patch a ROM, you MUST use the ROM location's physical address. + * * WARNING: Be careful with the editing commands that use function, because we don't have a safe * counterpart to cpu.probeAddr(). * @@ -2116,7 +2118,11 @@ if (DEBUGGER) { { var addr = this.getAddr(dbgAddr, true, 1); if (addr !== X86.ADDR_INVALID) { - this.cpu.setByte(addr, b); + if (dbgAddr.type != Debugger.ADDRTYPE.PHYSICAL) { + this.cpu.setByte(addr, b); + } else { + this.bus.setByteDirect(addr, b); + } if (inc) this.incAddr(dbgAddr, inc); this.cpu.updateCPU(true); // we set fForce to true in case video memory was the target } @@ -2125,6 +2131,8 @@ if (DEBUGGER) { /** * setShort(dbgAddr, w, inc) * + * NOTE: If you need to patch a ROM, you MUST use the ROM location's physical address. + * * WARNING: Be careful with the editing commands that use function, because we don't have a safe * counterpart to cpu.probeAddr(). * @@ -2137,7 +2145,11 @@ if (DEBUGGER) { { var addr = this.getAddr(dbgAddr, true, 2); if (addr !== X86.ADDR_INVALID) { - this.cpu.setShort(addr, w); + if (dbgAddr.type != Debugger.ADDRTYPE.PHYSICAL) { + this.cpu.setShort(addr, w); + } else { + this.bus.setShortDirect(addr, w); + } if (inc) this.incAddr(dbgAddr, inc); this.cpu.updateCPU(true); // we set fForce to true in case video memory was the target } diff --git a/modules/textout/lib/textout.js b/modules/textout/lib/textout.js index f54728a65..3fba33249 100644 --- a/modules/textout/lib/textout.js +++ b/modules/textout/lib/textout.js @@ -35,6 +35,7 @@ var fs = require("fs"); var path = require("path"); var mkdirp = require("mkdirp"); +var defines = require("../../shared/lib/defines"); var net = require("../../shared/lib/netlib"); var proc = require("../../shared/lib/proclib"); var str = require("../../shared/lib/strlib");