Startup/status message tweaks

This commit is contained in:
Jeff Parsons 2016-05-03 12:44:22 -07:00
commit db5db398fb
7 changed files with 58 additions and 44 deletions

View file

@ -9,7 +9,7 @@
<rom id="romF" addr="0x1000" size="0x0800" file="/devices/pc8080/rom/invaders/INVADERS-F.json"/> <rom id="romF" addr="0x1000" size="0x0800" file="/devices/pc8080/rom/invaders/INVADERS-F.json"/>
<rom id="romE" addr="0x1800" size="0x0800" file="/devices/pc8080/rom/invaders/INVADERS-E.json"/> <rom id="romE" addr="0x1800" size="0x0800" file="/devices/pc8080/rom/invaders/INVADERS-E.json"/>
<ram id="ram" addr="0x2000" size="0x0400"/> <ram id="ram" addr="0x2000" size="0x0400"/>
<video id="video" screenWidth="896" screenHeight="1024" screenRotate="90" smoothing="false" bufferAddr="0x2400" bufferCols="256" bufferRows="224" bufferBits="1" bufferLeft="0" interruptRate="120" width="40%" pos="left" padding="8px"> <video id="video" screenWidth="896" screenHeight="1024" bufferRotate="-90" smoothing="false" bufferAddr="0x2400" bufferCols="256" bufferRows="224" bufferBits="1" bufferLeft="0" interruptRate="120" width="40%" pos="left" padding="8px">
<menu> <menu>
<title>224x256 Screen (Rotated)</title> <title>224x256 Screen (Rotated)</title>
<control type="container" pos="right"> <control type="container" pos="right">

View file

@ -290,49 +290,53 @@ Bus.prototype.powerUp = function(data, fRepower)
*/ */
Bus.prototype.addMemory = function(addr, size, type) Bus.prototype.addMemory = function(addr, size, type)
{ {
var iBlock = addr >>> this.nBlockShift; var addrNext = addr;
while (size > 0 && iBlock < this.aMemBlocks.length) { var sizeLeft = size;
var iBlock = addrNext >>> this.nBlockShift;
while (sizeLeft > 0 && iBlock < this.aMemBlocks.length) {
var block = this.aMemBlocks[iBlock]; var block = this.aMemBlocks[iBlock];
var addrBlock = iBlock * this.nBlockSize; var addrBlock = iBlock * this.nBlockSize;
var sizeBlock = this.nBlockSize - (addr - addrBlock); var sizeBlock = this.nBlockSize - (addrNext - addrBlock);
if (sizeBlock > size) sizeBlock = size; if (sizeBlock > sizeLeft) sizeBlock = sizeLeft;
if (block && block.size) { if (block && block.size) {
if (block.type == type) { if (block.type == type) {
/* /*
* Where there is already a similar block with a non-zero size, we allow the allocation only if: * Where there is already a similar block with a non-zero size, we allow the allocation only if:
* *
* 1) addr + size <= block.addr (the request precedes the used portion of the current block), or * 1) addrNext + sizeLeft <= block.addr (the request precedes the used portion of the current block), or
* 2) addr >= block.addr + block.used (the request follows the used portion of the current block) * 2) addrNext >= block.addr + block.used (the request follows the used portion of the current block)
*/ */
if (addr + size <= block.addr) { if (addrNext + sizeLeft <= block.addr) {
block.used += (block.addr - addr); block.used += (block.addr - addrNext);
block.addr = addr; block.addr = addrNext;
return true; return true;
} }
if (addr >= block.addr + block.used) { if (addrNext >= block.addr + block.used) {
var sizeAvail = block.size - (addr - addrBlock); var sizeAvail = block.size - (addrNext - addrBlock);
if (sizeAvail > size) sizeAvail = size; if (sizeAvail > sizeLeft) sizeAvail = sizeLeft;
block.used = addr - block.addr + sizeAvail; block.used = addrNext - block.addr + sizeAvail;
addr = addrBlock + this.nBlockSize; addrNext = addrBlock + this.nBlockSize;
size -= sizeAvail; sizeLeft -= sizeAvail;
iBlock++; iBlock++;
continue; continue;
} }
} }
return this.reportError(Bus.ERROR.ADD_MEM_INUSE, addr, size); return this.reportError(Bus.ERROR.ADD_MEM_INUSE, addrNext, sizeLeft);
} }
var blockNew = new Memory(addr, sizeBlock, this.nBlockSize, type); var blockNew = new Memory(addrNext, sizeBlock, this.nBlockSize, type);
blockNew.copyBreakpoints(this.dbg, block); blockNew.copyBreakpoints(this.dbg, block);
this.aMemBlocks[iBlock++] = blockNew; this.aMemBlocks[iBlock++] = blockNew;
addr = addrBlock + this.nBlockSize; addrNext = addrBlock + this.nBlockSize;
size -= sizeBlock; sizeLeft -= sizeBlock;
} }
if (size <= 0) { if (sizeLeft <= 0) {
this.status(Math.floor(size / 1024) + "Kb " + Memory.TYPE.NAMES[type] + " at " + str.toHexWord(addr));
return true; return true;
} }

View file

@ -189,6 +189,8 @@ function Computer(parmsComputer, parmsMachine, fSuspended) {
} }
} }
this.println(Computer.APPNAME + " v" + Computer.APPVERSION + "\n" + Computer.COPYRIGHT + "\n" + Computer.LICENSE);
if (DEBUG && this.messageEnabled()) this.printMessage("TYPEDARRAYS: " + TYPEDARRAYS); if (DEBUG && this.messageEnabled()) this.printMessage("TYPEDARRAYS: " + TYPEDARRAYS);
/* /*
@ -743,15 +745,11 @@ Computer.prototype.donePowerOn = function(aParms)
this.printMessage("Computer.donePowerOn(): redundant"); this.printMessage("Computer.donePowerOn(): redundant");
} }
this.fInitialized = true;
this.flags.fPowered = true; this.flags.fPowered = true;
var controlPower = this.bindings["power"]; var controlPower = this.bindings["power"];
if (controlPower) controlPower.textContent = "Shutdown"; if (controlPower) controlPower.textContent = "Shutdown";
if (!this.fInitialized) {
this.println(Computer.APPNAME + " v" + Computer.APPVERSION + "\n" + Computer.COPYRIGHT + "\n" + Computer.LICENSE);
this.fInitialized = true;
}
/* /*
* Once we get to this point, we're guaranteed that all components are ready, so it's safe to power the CPU; * Once we get to this point, we're guaranteed that all components are ready, so it's safe to power the CPU;
* the CPU should begin executing immediately, unless a debugger is attached. * the CPU should begin executing immediately, unless a debugger is attached.

View file

@ -193,8 +193,8 @@ Memory.TYPE = {
ROM: 2, ROM: 2,
VIDEO: 3, VIDEO: 3,
CTRL: 4, CTRL: 4,
NAMES: ["NONE", "RAM", "ROM", "VIDEO", "H/W"], COLORS: ["black", "blue", "green", "cyan"],
COLORS: ["black", "blue", "green", "cyan"] NAMES: ["N/A", "RAM", "ROM", "VID", "H/W"]
}; };
/* /*

View file

@ -136,7 +136,6 @@ RAM.prototype.reset = function()
if (!this.fAllocated && this.sizeRAM) { if (!this.fAllocated && this.sizeRAM) {
if (this.bus.addMemory(this.addrRAM, this.sizeRAM, Memory.TYPE.RAM)) { if (this.bus.addMemory(this.addrRAM, this.sizeRAM, Memory.TYPE.RAM)) {
this.fAllocated = true; this.fAllocated = true;
this.status(Math.floor(this.sizeRAM / 1024) + "Kb allocated");
} }
} }
if (!this.fAllocated) { if (!this.fAllocated) {

View file

@ -50,14 +50,14 @@ if (NODE) {
* screenWidth: width of the screen canvas, in pixels * screenWidth: width of the screen canvas, in pixels
* screenHeight: height of the screen canvas, in pixels * screenHeight: height of the screen canvas, in pixels
* screenColor: background color of the screen canvas (default is black) * screenColor: background color of the screen canvas (default is black)
* screenRotate: the amount of counter-clockwise screen rotation required (eg, 90) * screenRotate: the amount of counter-clockwise screen rotation required (eg, -90 or 270)
* aspectRatio (eg, 1.33) * aspectRatio (eg, 1.33)
* bufferAddr: the starting address of the frame buffer (eg, 0x2400) * bufferAddr: the starting address of the frame buffer (eg, 0x2400)
* bufferCols: the width of a single frame buffer row, in pixels (eg, 256) * bufferCols: the width of a single frame buffer row, in pixels (eg, 256)
* bufferRows: the number of frame buffer rows (eg, 224) * bufferRows: the number of frame buffer rows (eg, 224)
* bufferBits: the number of bits per column (default is 1) * bufferBits: the number of bits per column (default is 1)
* bufferLeft: the bit position of the left-most pixel in a byte (default is 0; CGA uses 7) * bufferLeft: the bit position of the left-most pixel in a byte (default is 0; CGA uses 7)
* bufferRotate: the amount of counter-clockwise buffer rotation required (eg, 90) * bufferRotate: the amount of counter-clockwise buffer rotation required (eg, -90 or 270)
* interruptRate: normally the same as (or some multiple of) refreshRate (eg, 120) * interruptRate: normally the same as (or some multiple of) refreshRate (eg, 120)
* refreshRate: how many times updateScreen() should be performed per second (eg, 60) * refreshRate: how many times updateScreen() should be performed per second (eg, 60)
* *
@ -72,10 +72,10 @@ if (NODE) {
* been redrawn), so we need an interrupt rate of 120Hz. We pass the higher rate on to the CPU, so that * been redrawn), so we need an interrupt rate of 120Hz. We pass the higher rate on to the CPU, so that
* it will call updateScreen() more frequently, but we still limit our screen updates to every *other* call. * it will call updateScreen() more frequently, but we still limit our screen updates to every *other* call.
* *
* bufferRotate is an alternative to screenRotate; you may set one or the other (but not both) to 90 to * bufferRotate is an alternative to screenRotate; you may set one or the other (but not both) to -90 to
* enable different approaches to 90-degree image rotation. screenRotate uses canvas transformation methods * enable different approaches to counter-clockwise 90-degree image rotation. screenRotate uses canvas
* (ie, translate(), rotate(), and scale()), while bufferRotate inverts the dimensions of the off-screen * transformation methods (translate(), rotate(), and scale()), while bufferRotate inverts the dimensions
* buffer and then relies on setPixel() to rotate the data into it. * of the off-screen buffer and then relies on setPixel() to rotate the data into it.
* *
* @constructor * @constructor
* @extends Component * @extends Component
@ -102,6 +102,14 @@ function Video(parmsVideo, canvas, context, textarea, container)
this.nBitsPerPixel = parmsVideo['bufferBits'] || 1; this.nBitsPerPixel = parmsVideo['bufferBits'] || 1;
this.iBitFirstPixel = parmsVideo['bufferLeft'] || 0; this.iBitFirstPixel = parmsVideo['bufferLeft'] || 0;
this.rotateBuffer = parmsVideo['bufferRotate']; this.rotateBuffer = parmsVideo['bufferRotate'];
if (this.rotateBuffer) {
this.rotateBuffer = this.rotateBuffer % 360;
if (this.rotateBuffer > 0) this.rotateBuffer -= 360;
if (this.rotateBuffer != -90) {
this.notice("unsupported buffer rotation: " + this.rotateBuffer);
this.rotateBuffer = 0;
}
}
this.interruptRate = parmsVideo['interruptRate']; this.interruptRate = parmsVideo['interruptRate'];
this.refreshRate = parmsVideo['refreshRate'] || 60; this.refreshRate = parmsVideo['refreshRate'] || 60;
@ -134,10 +142,17 @@ function Video(parmsVideo, canvas, context, textarea, container)
} }
this.rotateScreen = parmsVideo['screenRotate']; this.rotateScreen = parmsVideo['screenRotate'];
if (this.rotateScreen == 90) { if (this.rotateScreen) {
this.contextScreen.translate(0, this.cyScreen); this.rotateScreen = this.rotateScreen % 360;
this.contextScreen.rotate((-this.rotateScreen * Math.PI)/180); if (this.rotateScreen > 0) this.rotateScreen -= 360;
this.contextScreen.scale(this.cyScreen/this.cxScreen, this.cxScreen/this.cyScreen); if (this.rotateScreen != -90) {
this.notice("unsupported screen rotation: " + this.rotateScreen);
this.rotateScreen = 0;
} else {
this.contextScreen.translate(0, this.cyScreen);
this.contextScreen.rotate((this.rotateScreen * Math.PI)/180);
this.contextScreen.scale(this.cyScreen/this.cxScreen, this.cxScreen/this.cyScreen);
}
} }
this.initColors(); this.initColors();

View file

@ -218,6 +218,8 @@ function Computer(parmsComputer, parmsMachine, fSuspended) {
} }
} }
this.println(Computer.APPNAME + " v" + Computer.APPVERSION + "\n" + Computer.COPYRIGHT + "\n" + Computer.LICENSE);
if (DEBUG && this.messageEnabled()) this.printMessage("PREFETCH: " + PREFETCH + ", TYPEDARRAYS: " + TYPEDARRAYS); if (DEBUG && this.messageEnabled()) this.printMessage("PREFETCH: " + PREFETCH + ", TYPEDARRAYS: " + TYPEDARRAYS);
/* /*
@ -778,15 +780,11 @@ Computer.prototype.donePowerOn = function(aParms)
this.printMessage("Computer.donePowerOn(): redundant"); this.printMessage("Computer.donePowerOn(): redundant");
} }
this.fInitialized = true;
this.flags.fPowered = true; this.flags.fPowered = true;
var controlPower = this.bindings["power"]; var controlPower = this.bindings["power"];
if (controlPower) controlPower.textContent = "Shutdown"; if (controlPower) controlPower.textContent = "Shutdown";
if (!this.fInitialized) {
this.println(Computer.APPNAME + " v" + Computer.APPVERSION + "\n" + Computer.COPYRIGHT + "\n" + Computer.LICENSE);
this.fInitialized = true;
}
/* /*
* Once we get to this point, we're guaranteed that all components are ready, so it's safe to power the CPU; * Once we get to this point, we're guaranteed that all components are ready, so it's safe to power the CPU;
* the CPU should begin executing immediately, unless a debugger is attached. * the CPU should begin executing immediately, unless a debugger is attached.