Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

Commit

Permalink
Added ability to edit ROMs of calculator devices
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpar committed Jun 8, 2019
1 parent a43a2cd commit 5841d1d
Show file tree
Hide file tree
Showing 21 changed files with 117 additions and 50 deletions.
4 changes: 2 additions & 2 deletions _data/machines.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"leds": {
"name": "LEDs",
"class": "leds",
"version": "1.20",
"version": "1.21",
"defines": [
"COMPILED",
"DEBUG",
Expand Down Expand Up @@ -306,7 +306,7 @@
"ti57": {
"name": "TI57",
"class": "ti57",
"version": "1.20",
"version": "1.21",
"defines": [
"COMPILED",
"DEBUG",
Expand Down
2 changes: 1 addition & 1 deletion _posts/2019-06-02-wordstar-for-the-ibm-pc-circa-1982.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ including:
{% include gallery-begin.html %}
{% include gallery-image.html src="https://demo-disks.pcjs.org/pcx86/apps/other/wordstar/3.20/WS320-ORIG.png" width="320" height="320" title="WordStar 3.20 Disk 1" link="/disks/pcx86/apps/other/wordstar/3.20/" %}
{% include gallery-image.html src="https://demo-disks.pcjs.org/pcx86/apps/other/wordstar/3.20/MM320-ORIG.png" width="320" height="320" title="WordStar 3.20 Disk 2" link="/disks/pcx86/apps/other/wordstar/3.20/" %}
{% include gallery-image.html src="/disks/pcx86/apps/other/wordstar/3.20/WordStar32-Binder.png" width="320" height="460" title="WordStar 3.0 Training Guide" link="https://1drv.ms/u/s!ArcO_mFRe1Z9gqlTMVtF-s8OxtSNpA" %}
{% include gallery-image.html src="/disks/pcx86/apps/other/wordstar/3.20/WordStar32-Binder.png" width="320" height="460" title="WordStar Binder" link="https://1drv.ms/u/s!ArcO_mFRe1Z9gqlTMVtF-s8OxtSNpA" %}
{% include gallery-image.html src="/disks/pcx86/apps/other/wordstar/3.20/WordStar30-Training-Guide.png" width="320" height="460" title="WordStar 3.0 Training Guide" link="https://1drv.ms/b/s!ArcO_mFRe1Z9gqlYINZ_GQ3Y6NVSUA?e=cUZyft" %}
{% include gallery-image.html src="/disks/pcx86/apps/other/wordstar/3.20/WordStar32-General-Information.png" width="320" height="460" title="WordStar 3.2 General Information" link="https://1drv.ms/b/s!ArcO_mFRe1Z9gqkVkrQ_SzATTmls_Q?e=D3kVDU" %}
{% include gallery-image.html src="/disks/pcx86/apps/other/wordstar/3.20/WordStar32-Reference-Manual.png" width="320" height="460" title="WordStar 3.2 Reference Manual" link="https://1drv.ms/b/s!ArcO_mFRe1Z9gqkWhsTCHW7gkQ2W7A?e=VLlYyf" %}
Expand Down
2 changes: 1 addition & 1 deletion devices/leds/life/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ There is also a ["Game of Life" Color Demo](colors/) that allows you to change L
</div>
<div id="diagsLife">
<div>
<textarea id="printLife" cols="78" rows="16"></textarea>
<textarea id="printLife" cols="78" rows="16" spellcheck="false"></textarea>
</div>
</div>
2 changes: 1 addition & 1 deletion devices/leds/life/colors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ Using [PCjs Devices](/modules/devices/), here's a simple demo of
</div>
<div id="diagsLife">
<div>
<textarea id="printLife" cols="78" rows="16"></textarea>
<textarea id="printLife" cols="78" rows="16" spellcheck="false"></textarea>
</div>
</div>
2 changes: 1 addition & 1 deletion devices/leds/litebrite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ color codes (B, G, V, R, O, P, Y, and W).
</div>
<div id="diagsLB">
<div>
<textarea id="printLB" cols="78" rows="16"></textarea>
<textarea id="printLB" cols="78" rows="16" spellcheck="false"></textarea>
</div>
<button id="runLB">Run</button>
<button id="stepLB">Step</button>
Expand Down
2 changes: 1 addition & 1 deletion devices/leds/scroller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ You can enter new messages in the Diagnostics window using the `s` command (eg,
</div>
<div class="diags">
<div>
<textarea id="printScroll" class="print" cols="78" rows="16"></textarea>
<textarea id="printScroll" class="print" cols="78" rows="16" spellcheck="false"></textarea>
</div>
<button id="runScroll">Run</button>
<button id="stepScroll">Step</button>
Expand Down
2 changes: 1 addition & 1 deletion devices/leds/symbols/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ This page helps you build new LED symbols by displaying characters underneath th
</div>
<div class="diags">
<div>
<textarea id="printSymbol" class="print" cols="78" rows="16"></textarea>
<textarea id="printSymbol" class="print" cols="78" rows="16" spellcheck="false"></textarea>
</div>
Symbol: <input id="inputSymbol" type="text" value="A"/>
<button id="saveSymbol">Save</button>
Expand Down
2 changes: 1 addition & 1 deletion devices/ti42/machine/diags/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ The window also accepts a few debugging commands. Use '?' for help.
<div class="diagsTI42">
<div>
<p>Diagnostics</p>
<textarea id="printTI42" cols="74" rows="16"></textarea>
<textarea id="printTI42" cols="74" rows="16" spellcheck="false"></textarea>
</div>
<button id="runTI42">Run</button>
<button id="stepTI42">Step</button><span id="speedTI42">Stopped</span>
Expand Down
2 changes: 1 addition & 1 deletion devices/ti55/machine/diags/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The window also accepts a few debugging commands. Use '?' for help.
<div class="diagsTI55">
<div>
<p>Diagnostics</p>
<textarea id="printTI55" cols="74" rows="16"></textarea>
<textarea id="printTI55" cols="74" rows="16" spellcheck="false"></textarea>
</div>
<button id="runTI55">Run</button>
<button id="stepTI55">Step</button><span id="speedTI55">Stopped</span>
Expand Down
2 changes: 1 addition & 1 deletion devices/ti57/machine/rev0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ The window also accepts a few debugging commands. Use '?' for help.
<div class="diagsTI57">
<div>
<p>Diagnostics</p>
<textarea id="printTI57" cols="74" rows="16"></textarea>
<textarea id="printTI57" cols="74" rows="16" spellcheck="false"></textarea>
</div>
<button id="runTI57">Run</button>
<button id="stepTI57">Step</button><span id="speedTI57">Stopped</span>
Expand Down
2 changes: 1 addition & 1 deletion devices/ti57/machine/rev1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The window also accepts a few debugging commands. Use '?' for help.
<div class="diagsTI57">
<div>
<p>Diagnostics</p>
<textarea id="printTI57" cols="74" rows="16"></textarea>
<textarea id="printTI57" cols="74" rows="16" spellcheck="false"></textarea>
</div>
<button id="runTI57">Run</button>
<button id="stepTI57">Step</button><span id="speedTI57">Stopped</span>
Expand Down
2 changes: 1 addition & 1 deletion modules/devices/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var MACHINE = "Machine";
/**
* @define {string}
*/
var VERSION = "";
var VERSION = "1.21";

/**
* The following properties are the standard set of properties a Device's config object may contain.
Expand Down
2 changes: 1 addition & 1 deletion modules/devices/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,4 +753,4 @@ Input.KEYCODE = { // keyCode from keydown/keyup events

Input.BUTTON_DELAY = 50; // minimum number of milliseconds to ensure between button presses and releases

Input.VERSION = +VERSION || 1.20;
Input.VERSION = +VERSION || 1.00;
2 changes: 1 addition & 1 deletion modules/devices/led.js
Original file line number Diff line number Diff line change
Expand Up @@ -1293,4 +1293,4 @@ LED.SYMBOL_SEGMENTS = {
'.': ['P']
};

LED.VERSION = +VERSION || 1.20;
LED.VERSION = +VERSION || 1.00;
2 changes: 1 addition & 1 deletion modules/devices/ledctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,6 @@ Chip.FONTS = {
}
};

Chip.VERSION = +VERSION || 1.20;
Chip.VERSION = +VERSION || 1.00;

MACHINE = "LEDs";
24 changes: 11 additions & 13 deletions modules/devices/lib/stdio.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,13 @@ class StdIO {
} else {
arg = args[args.length-1];
}
} else {
width = +width || 0;
}
width = +width || 0;
let precision = aParts[iPart+3];
precision = precision? +precision.substr(1) : -1;
// let length = aParts[iPart+4]; // eg, 'h', 'l' or 'L' (all currently ignored)
let hash = flags.indexOf('#') >= 0;
let ach = null, s, radix = 0, p, prefix = ""
let ach = null, s, radix = 0, prefix = ""

switch(type) {
case 'd':
Expand Down Expand Up @@ -325,7 +324,7 @@ class StdIO {
* the caller is providing an Object that should be rendered as JSON. If a width is included
* (eg, "%2j"), it's used as an indentation value; otherwise, no whitespace is added.
*/
buffer += JSON.stringify(arg, null, width || null);
buffer += JSON.stringify(arg, null, width || undefined);
break;

case 'c':
Expand Down Expand Up @@ -381,22 +380,21 @@ class StdIO {
*/
arg = Number.parseInt(arg, arg.match(/(^0x|[a-f])/i)? 16 : 10);
}
p = width? "" : prefix;
width -= prefix.length;
do {
let d = arg & (radix - 1);
arg >>>= (radix == 16? 4 : 3);
if (flags.indexOf('0') >= 0 || s == "" || d || arg) {
if (flags.indexOf('0') >= 0 || !s || d || arg) {
s = ach[d] + s;
} else if (width) {
if (!prefix) {
s = ' ' + s;
} else {
s = prefix.slice(-1) + s;
prefix = prefix.slice(0, -1);
} else {
if (prefix) {
s = prefix + s;
prefix = "";
}
if (width > 0) s = ' ' + s;
}
} while (--width > 0 || arg);
buffer += p + s;
buffer += prefix + s;
break;

case '%':
Expand Down
2 changes: 1 addition & 1 deletion modules/devices/machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,6 @@ Machine.CLASSORDER = [
Machine.COPYRIGHT = "Copyright © 2012-2019 Jeff Parsons <[email protected]>";
Machine.LICENSE = "License: GPL version 3 or later <http://gnu.org/licenses/gpl.html>";

Machine.VERSION = +VERSION || 1.20;
Machine.VERSION = +VERSION || 1.00;

window[MACHINE] = Machine;
62 changes: 57 additions & 5 deletions modules/devices/rom.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,49 @@ class ROM extends Device {
*/
loadState(state)
{
let length, success = true;
let buffer = state.shift();
if (buffer && this.ledArray) {
this.assert(this.ledArray.buffer.length == buffer.length);
if (this.ledArray.buffer.length == buffer.length) {
length = buffer.length;
this.assert(this.ledArray.buffer.length == length);
if (this.ledArray.buffer.length == length) {
this.ledArray.buffer = buffer;
this.ledArray.drawBuffer(true);
return true;
} else {
this.printf("inconsistent saved LED state (%d), unable to load\n", length);
success = false;
}
}
return false;
/*
* Version 1.21 and up also saves the ROM contents, since our "mini-debugger" has been updated
* with an edit command ("e") to enable ROM patching. However, we prefer to detect improvements
* in saved state based on the length of the array, not the version number.
*/
if (state.length) {
let data = state.shift();
let length = data && data.length || -1;
if (this.data.length == length) {
this.data = data;
} else {
this.printf("inconsistent saved ROM state (%d), unable to load\n", length);
success = false;
}
}
return success;
}

/**
* reset()
*
* Called by the Chip (eg, TMS1500) onReset() handler. Originally, there was no need for this
* handler, until we added the min-debugger's ability to edit ROM locations via setData(). So this
* gives the user the ability to revert back to the original ROM if they want to undo any modifications.
*
* @this {ROM}
*/
reset()
{
this.data = this.config['values'];
}

/**
Expand All @@ -218,6 +251,7 @@ class ROM extends Device {
{
if (this.ledArray) {
state.push(this.ledArray.buffer);
state.push(this.data);
}
}

Expand All @@ -231,11 +265,29 @@ class ROM extends Device {
{
this.chip = chip;
}

/**
* setData(addr, value)
*
* @this {ROM}
* @param {number} addr
* @param {number} value
* @return {number|undefined} (previous value, if available)
*/
setData(addr, value)
{
let prev;
if (addr >= 0 && addr < this.data.length) {
prev = this.data[addr];
this.data[addr] = value;
}
return prev;
}
}

ROM.BINDING = {
ARRAY: "array",
CELLDESC: "cellDesc"
};

ROM.VERSION = +VERSION || 1.20;
ROM.VERSION = +VERSION || 1.00;
2 changes: 1 addition & 1 deletion modules/devices/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -1107,4 +1107,4 @@ Time.BINDING = {
Time.YIELDS_PER_SECOND = 120;
Time.YIELDS_PER_UPDATE = 60;

Time.VERSION = +VERSION || 1.20;
Time.VERSION = +VERSION || 1.00;
Loading

0 comments on commit 5841d1d

Please sign in to comment.