From 43355dec6f61b14a00ccf197bdb219632d073746 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Tue, 31 May 2016 09:59:19 -0700 Subject: [PATCH] Support for message buffering (PC8080 only; needs to be added to PCx86, too) --- modules/pc8080/lib/debugger.js | 16 ++++++++++++++++ modules/pc8080/lib/messages.js | 5 +++-- modules/pc8080/lib/video.js | 21 ++++++++++++++++++--- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/modules/pc8080/lib/debugger.js b/modules/pc8080/lib/debugger.js index a2fdbb4ff..18d6e86e6 100644 --- a/modules/pc8080/lib/debugger.js +++ b/modules/pc8080/lib/debugger.js @@ -696,7 +696,11 @@ if (DEBUGGER) { /* * Now we turn to message actions rather than message types; for example, setting "halt" * on or off doesn't enable "halt" messages, but rather halts the CPU on any message above. + * + * Similarly, "m buffer on" turns on message buffering, defering the display of all messages + * until "m buffer off" is issued. */ + "buffer": Messages.BUFFER, "halt": Messages.HALT }; @@ -1302,6 +1306,7 @@ if (DEBUGGER) { this.dbg = this; this.bitsMessage = this.bitsWarning = Messages.WARN; this.sMessagePrev = null; + this.aMessageBuffer = []; /* * Internally, we use "key" instead of "keys", since the latter is a method on JavasScript objects, * but externally, we allow the user to specify "keys"; "kbd" is also allowed as shorthand for "keyboard". @@ -1548,6 +1553,11 @@ if (DEBUGGER) { sMessage += " at " + this.toHexAddr(this.newAddr(this.cpu.getPC())); } + if (this.bitsMessage & Messages.BUFFER) { + this.aMessageBuffer.push(sMessage); + return; + } + if (this.sMessagePrev && sMessage == this.sMessagePrev) return; this.sMessagePrev = sMessage; @@ -3921,6 +3931,12 @@ if (DEBUGGER) { else if (asArgs[2] == "off") { this.bitsMessage &= ~bitsMessage; fCriteria = false; + if (bitsMessage == Messages.BUFFER) { + for (var i = 0; i < this.aMessageBuffer.length; i++) { + this.println(this.aMessageBuffer[i]); + } + this.aMessageBuffer = []; + } } } } diff --git a/modules/pc8080/lib/messages.js b/modules/pc8080/lib/messages.js index accd8f265..dc131b3fa 100644 --- a/modules/pc8080/lib/messages.js +++ b/modules/pc8080/lib/messages.js @@ -45,8 +45,9 @@ var Messages = { SERIAL: 0x00800000, SPEAKER: 0x02000000, COMPUTER: 0x04000000, - LOG: 0x20000000, - WARN: 0x40000000, + LOG: 0x10000000, + WARN: 0x20000000, + BUFFER: 0x40000000, HALT: 0x80000000|0 }; diff --git a/modules/pc8080/lib/video.js b/modules/pc8080/lib/video.js index 345b0c7a3..0bbda415e 100644 --- a/modules/pc8080/lib/video.js +++ b/modules/pc8080/lib/video.js @@ -206,6 +206,8 @@ function Video(parmsVideo, canvas, context, textarea, container) } } } + + if (DEBUG) this.nCyclesPrev = 0; } Component.subclass(Video); @@ -484,6 +486,9 @@ Video.prototype.setPixel = function(imageBuffer, x, y, bPixel) */ Video.prototype.updateScreen = function(n) { + var fClean; + var fUpdate = true; + if (n >= 0) { if (!(n & 1)) { /* @@ -497,17 +502,27 @@ Video.prototype.updateScreen = function(n) * update the bottom half of the frame buffer after acknowledging this interrupt. */ this.cpu.requestINTR(2); - return; + fUpdate = false; } /* * Since this is not a forced update, if our cell cache is valid AND the buffer is clean, then do nothing. */ - if (this.fCellCacheValid && this.bus.cleanMemory(this.addrBuffer, this.sizeBuffer)) { - return; + if (fUpdate && this.fCellCacheValid) { + if ((fClean = this.bus.cleanMemory(this.addrBuffer, this.sizeBuffer))) { + fUpdate = false; + } } } + if (DEBUG) { + var nCycles = this.cpu.getCycles(); + var nCyclesDelta = nCycles - this.nCyclesPrev; + this.nCyclesPrev = nCycles; + this.printMessage("updateScreen(" + n + "): clean=" + fClean + ", update=" + fUpdate + ", cycles=" + nCycles + ", delta=" + nCyclesDelta); + } + if (!fUpdate) return; + var addr = this.addrBuffer; var addrLimit = addr + this.sizeBuffer;