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

Commit

Permalink
Allow any of the new Device modules to coexist on the same page
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpar committed Nov 11, 2019
1 parent 1e37dd5 commit c8e8541
Show file tree
Hide file tree
Showing 48 changed files with 25,516 additions and 25,285 deletions.
38 changes: 21 additions & 17 deletions _data/machines.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
"./modules/devices/main/input.js",
"./modules/devices/main/led.js",
"./modules/devices/main/time.js",
"./modules/devices/cpu/ledctrl.js",
"./modules/devices/cpu/cpu.js",
"./modules/devices/cpu/cpuleds.js",
"./modules/devices/main/machine.js"
],
"styles": [],
Expand Down Expand Up @@ -340,13 +341,14 @@
"./modules/devices/lib/stdio.js",
"./modules/devices/lib/webio.js",
"./modules/devices/main/device.js",
"./modules/devices/bus/bus.js",
"./modules/devices/bus/memory.js",
"./modules/devices/bus/rom.js",
"./modules/devices/main/input.js",
"./modules/devices/main/led.js",
"./modules/devices/main/time.js",
"./modules/devices/cpu/tms1500.js",
"./modules/devices/bus/bus.js",
"./modules/devices/bus/memory.js",
"./modules/devices/bus/rom.js",
"./modules/devices/cpu/cpu.js",
"./modules/devices/cpu/cpu1500.js",
"./modules/devices/main/machine.js"
],
"styles": [],
Expand All @@ -369,19 +371,20 @@
"./modules/devices/lib/stdio.js",
"./modules/devices/lib/webio.js",
"./modules/devices/main/device.js",
"./modules/devices/main/input.js",
"./modules/devices/main/led.js",
"./modules/devices/main/monitor.js",
"./modules/devices/main/time.js",
"./modules/devices/bus/bus.js",
"./modules/devices/bus/memory.js",
"./modules/devices/bus/ports.js",
"./modules/devices/bus/ram.js",
"./modules/devices/bus/rom.js",
"./modules/devices/main/input.js",
"./modules/devices/main/led.js",
"./modules/devices/main/monitor.js",
"./modules/devices/main/time.js",
"./modules/devices/invaders/chips.js",
"./modules/devices/invaders/ports.js",
"./modules/devices/invaders/video.js",
"./modules/devices/cpu/cpu.js",
"./modules/devices/cpu/cpu8080.js",
"./modules/devices/cpu/dbgio.js",
"./modules/devices/cpu/debugger.js",
"./modules/devices/cpu/dbg8080.js",
"./modules/devices/main/machine.js"
],
Expand All @@ -405,21 +408,22 @@
"./modules/devices/lib/stdio.js",
"./modules/devices/lib/webio.js",
"./modules/devices/main/device.js",
"./modules/devices/main/input.js",
"./modules/devices/main/led.js",
"./modules/devices/main/monitor.js",
"./modules/devices/main/time.js",
"./modules/devices/bus/bus.js",
"./modules/devices/bus/memory.js",
"./modules/devices/bus/ports.js",
"./modules/devices/bus/ram.js",
"./modules/devices/bus/rom.js",
"./modules/devices/main/input.js",
"./modules/devices/main/led.js",
"./modules/devices/main/monitor.js",
"./modules/devices/main/time.js",
"./modules/devices/vt100/chips.js",
"./modules/devices/vt100/kbdio.js",
"./modules/devices/vt100/keyboard.js",
"./modules/devices/vt100/serial.js",
"./modules/devices/vt100/video.js",
"./modules/devices/cpu/cpu.js",
"./modules/devices/cpu/cpu8080.js",
"./modules/devices/cpu/dbgio.js",
"./modules/devices/cpu/debugger.js",
"./modules/devices/cpu/dbg8080.js",
"./modules/devices/main/machine.js"
],
Expand Down
2 changes: 1 addition & 1 deletion devices/leds/life/colors/life.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"drag": true
},
"lifeCPU": {
"class": "CPU",
"class": "CPULEDS",
"rule": "B3/S23",
"pattern": "gliderGun",
"patterns": {
Expand Down
2 changes: 1 addition & 1 deletion devices/leds/life/life.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"drag": true
},
"lifeCPU": {
"class": "CPU",
"class": "CPULEDS",
"rule": "B3/S23",
"pattern": "gliderGun",
"patterns": {
Expand Down
2 changes: 1 addition & 1 deletion devices/leds/litebrite/litebrite.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"drag": true
},
"lbCPU": {
"class": "CPU",
"class": "CPULEDS",
"rule": "A4",
"toggleColor": true,
"bindings": {
Expand Down
2 changes: 1 addition & 1 deletion devices/leds/scroller/ATT4425.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"drag": true
},
"scrollCPU": {
"class": "CPU",
"class": "CPULEDS",
"font": "ATT4425",
"message": "Happy New Year!$c$30b$30o$30b$30o$90s",
"rule": "L1",
Expand Down
2 changes: 1 addition & 1 deletion devices/leds/scroller/helvetica.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"drag": true
},
"scrollCPU": {
"class": "CPU",
"class": "CPULEDS",
"font": "Helvetica",
"message": "Happy New Year!$c$30b$30o$30b$30o$90s",
"rule": "L1",
Expand Down
2 changes: 1 addition & 1 deletion devices/leds/symbols/symbols.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"drag": true
},
"symbolCPU": {
"class": "CPU",
"class": "CPULEDS",
"bindings": {
"save": "saveSymbol",
"symbolInput": "inputSymbol",
Expand Down
2 changes: 1 addition & 1 deletion devices/pc8080/machine/invaders/new/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ styles:
Space Invaders (New)
--------------------

{% include machine.html id="invaders" config="json" %}
{% include machine.html id="invaders" %}

<div id="invaders" class="pcjsContainer">
<div class="pcjsControlsRight">
Expand Down
10 changes: 5 additions & 5 deletions devices/pc8080/machine/invaders/new/invaders.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"dataWidth": 8
},
"cpu": {
"class": "CPU",
"class": "CPU8080",
"busIO": "busIO",
"busMemory": "busMemory"
},
Expand Down Expand Up @@ -83,8 +83,8 @@
}
}
},
"chips": {
"class": "Chips",
"ports": {
"class": "InvadersPorts",
"bus": "busIO",
"addr": 0,
"size": 256,
Expand Down Expand Up @@ -652,7 +652,7 @@
]
},
"video": {
"class": "Video",
"class": "InvadersVideo",
"bus": "busMemory",
"monitorWidth": 896,
"monitorHeight": 1024,
Expand All @@ -677,7 +677,7 @@
]
},
"debugger": {
"class": "Debugger",
"class": "Dbg8080",
"_JSONDoc": [
"It's best to initialize the Debugger last, so that it can find any device it wants -- at the very least, the CPU."
]
Expand Down
12 changes: 6 additions & 6 deletions devices/pc8080/machine/vt100/new/vt100.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"dataWidth": 8
},
"cpu": {
"class": "CPU",
"class": "CPU8080",
"busIO": "busIO",
"busMemory": "busMemory"
},
Expand Down Expand Up @@ -888,18 +888,18 @@
"releaseDelay": 50
},
"chips": {
"class": "Chips"
"class": "VT100Chips"
},
"keyboard": {
"class": "KbdIO",
"class": "VT100Keyboard",
"leds": ["ledLocal", "ledLocked", "led1", "led2", "led3", "led4"],
"bindings": ["keySetup", "keyLineFeed", "keyTab", "keyEsc", "keyBreak", "keyShiftLock", "keyCtrlLock", "keyCtrlC", "keyCapsLock"]
},
"serialPort": {
"class": "Serial"
"class": "VT100Serial"
},
"video": {
"class": "Video",
"class": "VT100Video",
"bus": "busMemory",
"monitorWidth": 1600,
"monitorHeight": 960,
Expand Down Expand Up @@ -1054,7 +1054,7 @@
]
},
"debugger": {
"class": "Debugger",
"class": "Dbg8080",
"_JSONDoc": [
"It's best to initialize the Debugger last, so that it can find any device it wants -- at the very least, the CPU."
]
Expand Down
2 changes: 1 addition & 1 deletion devices/ti42/machine/diags/ti42.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
]
},
"cpu": {
"class": "CPU",
"class": "CPU1500",
"type": "TMS-1502",
"input": "buttons",
"output": "display",
Expand Down
2 changes: 1 addition & 1 deletion devices/ti55/machine/diags/ti55.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
]
},
"cpu": {
"class": "CPU",
"class": "CPU1500",
"type": "TMS-1503",
"input": "buttons",
"output": "display",
Expand Down
2 changes: 1 addition & 1 deletion devices/ti57/machine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Visit the [TI-57 Resources](../) page for more options.

The TI-57 Emulator is also available as a [Web Application](webapp/).

{% include machine.html id="ti57" config="json" %}
{% include machine.html id="ti57" %}

<div id="ti57">
<img id="imageTI57" src="/devices/ti57/images/ti57.png" alt="TI-57 Calculator"/>
Expand Down
2 changes: 1 addition & 1 deletion devices/ti57/machine/rev0/ti57.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
]
},
"cpu": {
"class": "CPU",
"class": "CPU1500",
"type": "TMS-1501",
"input": "buttons",
"output": "display",
Expand Down
2 changes: 1 addition & 1 deletion devices/ti57/machine/rev1/ti57.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
]
},
"cpu": {
"class": "CPU",
"class": "CPU1500",
"type": "TMS-1501",
"input": "buttons",
"output": "display",
Expand Down
24 changes: 15 additions & 9 deletions modules/devices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ along with one of the following "CPU" classes:

* [8080 CPU](cpu/cpu8080.js) (with [8080 Debugger](cpu/dbg8080.js) and [Debugger I/O](cpu/dbgio.js))
* [LED Controller "CPU"](cpu/ledctrl.js)
* [TMS-1500 Calculator CPU](cpu/tms1500.js) (with built-in "mini-debugger")
* [TMS-1500 Calculator CPU](cpu/cpu1500.js) (with built-in "mini-debugger")

a "Machine" class that manages the entire machine:

Expand Down Expand Up @@ -175,19 +175,25 @@ Next, add some HTML markup at the desired page location, such as:

Finally, you embed the machine with a simple *include* template:

{% include machine.html id="ti57" config="json" %}
{% include machine.html id="ti57" %}

which automatically adds all the necessary scripts, as listed in
[machines.json](https://github.com/jeffpar/pcjs/blob/master/_data/machines.json):

<script src="/modules/devices/lib/defs.js"></script>
<script src="/modules/devices/lib/numio.js"></script>
<script src="/modules/devices/lib/stdio.js"></script>
<script src="/modules/devices/device.js"></script>
<script src="/modules/devices/input.js"></script>
<script src="/modules/devices/led.js"></script>
<script src="/modules/devices/rom.js"></script>
<script src="/modules/devices/time.js"></script>
<script src="/modules/devices/tms1500.js"></script>
<script src="/modules/devices/machine.js"></script>
<script src="/modules/devices/lib/webio.js"></script>
<script src="/modules/devices/main/device.js"></script>
<script src="/modules/devices/main/input.js"></script>
<script src="/modules/devices/main/led.js"></script>
<script src="/modules/devices/main/time.js"></script>
<script src="/modules/devices/bus/bus.js"></script>
<script src="/modules/devices/bus/memory.js"></script>
<script src="/modules/devices/bus/rom.js"></script>
<script src="/modules/devices/cpu/cpu.js"></script>
<script src="/modules/devices/cpu/cpu1500.js"></script>
<script src="/modules/devices/main/machine.js"></script>

and then creates the machine with:

Expand Down
2 changes: 1 addition & 1 deletion modules/devices/bus/rom.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class ROM extends Memory {
onPower(on)
{
/*
* We only care about the first power event, because it's a safe point to query the CPU.
* We only care about the first power event, because it's a safe opportunity to find the CPU.
*/
if (this.cpu === undefined) {
this.cpu = /** @type {CPU} */ (this.findDeviceByClass("CPU"));
Expand Down
51 changes: 51 additions & 0 deletions modules/devices/cpu/cpu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @fileoverview CPU base class
* @author <a href="mailto:[email protected]">Jeff Parsons</a>
* @copyright © 2012-2019 Jeff Parsons
*
* This file is part of PCjs, a computer emulation software project at <https://www.pcjs.org>.
*
* PCjs is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCjs. If not,
* see <http://www.gnu.org/licenses/gpl.html>.
*
* You are required to include the above copyright notice in every modified copy of this work
* and to display that copyright notice when the software starts running; see COPYRIGHT in
* <https://www.pcjs.org/modules/devices/machine.js>.
*
* Some PCjs files also attempt to load external resource files, such as character-image files,
* ROM files, and disk image files. Those external resource files are not considered part of PCjs
* for purposes of the GNU General Public License, and the author does not claim any copyright
* as to their contents.
*/

"use strict";

/**
* @class {CPU}
* @unrestricted
*/
class CPU extends Device {
/**
* CPU(idMachine, idDevice, config)
*
* @this {CPU}
* @param {string} idMachine
* @param {string} idDevice
* @param {Config} [config]
*/
constructor(idMachine, idDevice, config)
{
config['class'] = "CPU";
super(idMachine, idDevice, config);
}
}

// Defs.CLASSES["CPU"] = CPU;
Loading

0 comments on commit c8e8541

Please sign in to comment.