Scaffolding for VT100 ChipSet

This commit is contained in:
Jeff Parsons 2016-08-02 06:50:25 -07:00 committed by Jeff Parsons
commit 843d24c627
6 changed files with 124 additions and 69 deletions

View file

@ -16,7 +16,8 @@
</control>
</menu>
</video>
<chipset id="chipset" model="VT100"/>
<keyboard id="keyboard"/>
<panel ref="/devices/pc8080/panel/wide.xml"/>
<debugger id="debugger" messages="mem|halt" commands="s 8086"/>
<debugger id="debugger" messages="port|mem|halt" commands="s 8086"/>
</machine>

View file

@ -794,8 +794,10 @@ Bus.prototype.addPortInputNotify = function(start, end, fn)
Bus.prototype.addPortInputTable = function(component, table, offset)
{
if (offset === undefined) offset = 0;
for (var port in table) {
this.addPortInputNotify(+port + offset, +port + offset, table[port].bind(component));
if (table) {
for (var port in table) {
this.addPortInputNotify(+port + offset, +port + offset, table[port].bind(component));
}
}
};
@ -951,8 +953,10 @@ Bus.prototype.addPortOutputNotify = function(start, end, fn)
Bus.prototype.addPortOutputTable = function(component, table, offset)
{
if (offset === undefined) offset = 0;
for (var port in table) {
this.addPortOutputNotify(+port + offset, +port + offset, table[port].bind(component));
if (table) {
for (var port in table) {
this.addPortOutputNotify(+port + offset, +port + offset, table[port].bind(component));
}
}
};

View file

@ -67,7 +67,8 @@ function ChipSet(parmsChipSet)
Component.notice("Unrecognized ChipSet model: " + model);
}
this.model = ChipSet.MODELS[model] || ChipSet.SI_1978.MODEL;
this.config = ChipSet.MODELS[model] || ChipSet.SI1978;
this.model = this.config.MODEL;
this.bSwitches = this.parseDIPSwitches(parmsChipSet['swDIP']);
@ -104,9 +105,9 @@ function ChipSet(parmsChipSet)
Component.subclass(ChipSet);
ChipSet.SI_1978 = {
ChipSet.SI1978 = {
MODEL: 1978.1,
STATUS0: { // NOTE: STATUS0 not used by the SI_1978 ROMs; refer to STATUS1 instead
STATUS0: { // NOTE: STATUS0 not used by the SI1978 ROMs; refer to STATUS1 instead
PORT: 0,
DIP4: 0x01, // self-test request at power up?
FIRE: 0x10, // 1 = fire
@ -165,11 +166,22 @@ ChipSet.SI_1978 = {
}
};
ChipSet.VT100 = {
MODEL: 100.0,
BRIGHTNESS_LATCH: {
PORT: 0x42 // write-only
},
NVR_LATCH: {
PORT: 0x62 // write-only
}
};
/*
* Supported model strings
*/
ChipSet.MODELS = {
"SI1978": ChipSet.SI_1978.MODEL
"SI1978": ChipSet.SI1978,
"VT100": ChipSet.VT100
};
/**
@ -227,10 +239,8 @@ ChipSet.prototype.initBus = function(cmp, bus, cpu, dbg)
this.cpu = cpu;
this.dbg = dbg;
this.cmp = cmp;
if (this.model == ChipSet.SI_1978.MODEL) {
bus.addPortInputTable(this, ChipSet.aPortInput);
bus.addPortOutputTable(this, ChipSet.aPortOutput);
}
bus.addPortInputTable(this, this.config.portsInput);
bus.addPortOutputTable(this, this.config.portsOutput);
};
/**
@ -266,6 +276,21 @@ ChipSet.prototype.powerDown = function(fSave, fShutdown)
return fSave? this.save() : true;
};
ChipSet.SI1978.init = [
[
ChipSet.SI1978.STATUS0.ALWAYS_SET,
ChipSet.SI1978.STATUS1.ALWAYS_SET,
ChipSet.SI1978.STATUS2.ALWAYS_SET,
0, 0, 0, 0
]
];
ChipSet.VT100.init = [
[
0, 0
]
];
/**
* reset()
*
@ -273,12 +298,9 @@ ChipSet.prototype.powerDown = function(fSave, fShutdown)
*/
ChipSet.prototype.reset = function()
{
this.bStatus0 = ChipSet.SI_1978.STATUS0.ALWAYS_SET;
this.bStatus1 = ChipSet.SI_1978.STATUS1.ALWAYS_SET;
this.bStatus2 = ChipSet.SI_1978.STATUS2.ALWAYS_SET;
this.wShiftData = 0;
this.bShiftCount = 0;
this.bSound1 = this.bSound2 = 0;
if (!this.restore(this.config.init)) {
this.notice("reset error");
}
};
/**
@ -292,8 +314,13 @@ ChipSet.prototype.reset = function()
ChipSet.prototype.save = function()
{
var state = new State(this);
if (this.model == ChipSet.SI_1978.MODEL) {
switch(this.model) {
case ChipSet.SI1978.MODEL:
state.set(0, [this.bStatus0, this.bStatus1, this.bStatus2, this.wShiftData, this.bShiftCount, this.bSound1, this.bSound2]);
break;
case ChipSet.VT100.MODEL:
state.set(0, [this.bBrightnessLatch, this.bNVRLatch]);
break;
}
return state.data();
};
@ -309,18 +336,25 @@ ChipSet.prototype.save = function()
*/
ChipSet.prototype.restore = function(data)
{
var a, i;
a = data[0];
if (this.model == ChipSet.SI_1978.MODEL) {
this.bStatus0 = a[0];
this.bStatus1 = a[1];
this.bStatus2 = a[2];
this.wShiftData = a[3];
this.bShiftCount = a[4];
this.bSound1 = a[5];
this.bSound2 = a[6];
var a;
if (data && (a = data[0]) && a.length) {
switch(this.model) {
case ChipSet.SI1978.MODEL:
this.bStatus0 = a[0];
this.bStatus1 = a[1];
this.bStatus2 = a[2];
this.wShiftData = a[3];
this.bShiftCount = a[4];
this.bSound1 = a[5];
this.bSound2 = a[6];
return true;
case ChipSet.VT100.MODEL:
this.bBrightnessLatch = a[0];
this.bNVRLatch = a[1];
return true;
}
}
return true;
return false;
};
/**
@ -519,20 +553,45 @@ ChipSet.prototype.outSIWatchdog = function(port, b, addrFrom)
this.printMessageIO(port, b, addrFrom, "WATCHDOG", null, true);
};
/*
* Port input notification tables
/**
* outVT100BrightnessLatch(port, b, addrFrom)
*
* @this {ChipSet}
* @param {number} port (0x42)
* @param {number} b
* @param {number} [addrFrom] (not defined if the Debugger is trying to write the specified port)
*/
ChipSet.aPortInput = {
ChipSet.prototype.outVT100BrightnessLatch = function(port, b, addrFrom)
{
this.printMessageIO(port, b, addrFrom, "BRIGHTNESS.LATCH", null, true);
this.bBrightnessLatch = b;
};
/**
* outVT100BrightnessLatch(port, b, addrFrom)
*
* @this {ChipSet}
* @param {number} port (0x62)
* @param {number} b
* @param {number} [addrFrom] (not defined if the Debugger is trying to write the specified port)
*/
ChipSet.prototype.outVT100NVRLatch = function(port, b, addrFrom)
{
this.printMessageIO(port, b, addrFrom, "NVR.LATCH", null, true);
this.bNVRLatch = b;
};
/*
* Port notification tables
*/
ChipSet.SI1978.portsInput = {
0x00: ChipSet.prototype.inSIStatus0,
0x01: ChipSet.prototype.inSIStatus1,
0x02: ChipSet.prototype.inSIStatus2,
0x03: ChipSet.prototype.inSIShiftResult
};
/*
* Port output notification tables
*/
ChipSet.aPortOutput = {
ChipSet.SI1978.portsOutput = {
0x02: ChipSet.prototype.outSIShiftCount,
0x03: ChipSet.prototype.outSISound1,
0x04: ChipSet.prototype.outSIShiftData,
@ -540,6 +599,14 @@ ChipSet.aPortOutput = {
0x06: ChipSet.prototype.outSIWatchdog
};
ChipSet.VT100.portsInput = {
};
ChipSet.VT100.portsOutput = {
0x42: ChipSet.prototype.outVT100BrightnessLatch,
0x62: ChipSet.prototype.outVT100NVRLatch
};
/**
* ChipSet.init()
*

View file

@ -415,27 +415,27 @@ Keyboard.prototype.onSoftKeyDown = function(sSoftCode, fDown)
if (this.chipset) {
switch(sSoftCode) {
case '1p':
this.chipset.updateStatus1(ChipSet.SI_1978.STATUS1.P1, fDown);
this.chipset.updateStatus1(ChipSet.SI1978.STATUS1.P1, fDown);
break;
case '2p':
this.chipset.updateStatus1(ChipSet.SI_1978.STATUS1.P2, fDown);
this.chipset.updateStatus1(ChipSet.SI1978.STATUS1.P2, fDown);
break;
case 'coin':
this.chipset.updateStatus1(ChipSet.SI_1978.STATUS1.CREDIT, fDown);
this.chipset.updateStatus1(ChipSet.SI1978.STATUS1.CREDIT, fDown);
break;
case 'left':
this.chipset.updateStatus1(ChipSet.SI_1978.STATUS1.P1_LEFT, fDown);
this.chipset.updateStatus1(ChipSet.SI1978.STATUS1.P1_LEFT, fDown);
break;
case 'right':
this.chipset.updateStatus1(ChipSet.SI_1978.STATUS1.P1_RIGHT, fDown);
this.chipset.updateStatus1(ChipSet.SI1978.STATUS1.P1_RIGHT, fDown);
break;
case 'fire':
this.chipset.updateStatus1(ChipSet.SI_1978.STATUS1.P1_FIRE, fDown);
this.chipset.updateStatus1(ChipSet.SI1978.STATUS1.P1_FIRE, fDown);
break;
}
}

View file

@ -393,7 +393,7 @@ Video.prototype.initBus = function(cmp, bus, cpu, dbg)
if (!this.nFormat) {
this.chipset = cmp.getMachineComponent("ChipSet");
if (this.chipset && this.chipset.model == ChipSet.SI_1978.MODEL) {
if (this.chipset && this.chipset.model == ChipSet.SI1978.MODEL) {
this.nFormat = Video.FORMAT.SI1978;
}
}
@ -595,32 +595,15 @@ Video.prototype.powerUp = function(data, fRepower)
if (DEBUG && this.nFormat == Video.FORMAT.VT100) {
/*
* Build a test screen in the VT100 frame buffer; we'll mimic the "SET-UP A" screen, since it uses
* all the font variations.
* all the font variations. The process involves iterating over 0-based row numbers -2 (or -5 if 50Hz
* operation is selected) through 24, checking aLineData for a matching row number, and converting the
* corresponding string(s) to appropriate byte values. Negative row numbers correspond to "fill lines"
* and do not require a row entry. If multiple strings are present for a given row, we invert the
* default character attribute for subsequent strings. An empty array ends the screen build process.
*/
var aLineData = {
0: [Video.VT100.FONT.DHIGH, 'SET-UP A'],
2: [Video.VT100.FONT.DWIDE, 'TO EXIT PRESS "SET-UP"'],
/*
3: [Video.VT100.FONT.NORML, '4'],
4: [Video.VT100.FONT.NORML, '5'],
5: [Video.VT100.FONT.NORML, '6'],
6: [Video.VT100.FONT.NORML, '7'],
7: [Video.VT100.FONT.NORML, '8'],
8: [Video.VT100.FONT.NORML, '9'],
9: [Video.VT100.FONT.NORML, '10'],
10: [Video.VT100.FONT.NORML, '11'],
11: [Video.VT100.FONT.NORML, '12'],
12: [Video.VT100.FONT.NORML, '13'],
13: [Video.VT100.FONT.NORML, '14'],
14: [Video.VT100.FONT.NORML, '15'],
15: [Video.VT100.FONT.NORML, '16'],
16: [Video.VT100.FONT.NORML, '17'],
17: [Video.VT100.FONT.NORML, '18'],
18: [Video.VT100.FONT.NORML, '19'],
19: [Video.VT100.FONT.NORML, '20'],
20: [Video.VT100.FONT.NORML, '21'],
21: [Video.VT100.FONT.NORML, '22'],
*/
22: [Video.VT100.FONT.NORML, ' T T T T T T T T T'],
23: [Video.VT100.FONT.NORML, '1234567890', '1234567890', '1234567890', '1234567890', '1234567890', '1234567890', '1234567890', '1234567890'],
24: []

View file

@ -367,7 +367,7 @@ Component.notice = function(s, fPrintOnly, id)
if (DEBUG) {
Component.println(s, "notice", id);
}
if (!fPrintOnly) web.alertUser(s);
if (!fPrintOnly) web.alertUser((id? (id + ": ") : "") + s);
};
/**
@ -724,7 +724,7 @@ Component.prototype = {
* @param {string} [id]
*/
this.notice = function noticePanel(s, fPrintOnly, id) {
this.println(s, "notice", id);
this.println(s, this.idComponent);
};
}
return true;
@ -838,7 +838,7 @@ Component.prototype = {
* @param {string} [id] is the caller's ID, if any
*/
notice: function(s, fPrintOnly, id) {
Component.notice(s, fPrintOnly, id || this.id);
Component.notice(s, fPrintOnly, id || this.type);
},
/**
* setError(s)