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

Commit

Permalink
Merge branch 'next-release'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpar committed Aug 17, 2016
2 parents 4ca7334 + 00e4a49 commit 2e39746
Show file tree
Hide file tree
Showing 8 changed files with 218 additions and 209 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ one of several JavaScript Machines in the [PCjs Project](https://github.com/jeff
includes:

* [PCx86](/docs/pcx86/), an x86-based IBM PC and PC-compatible emulator
* [PC8080](/modules/pc8080/), a 8080-based machine emulator (e.g., [Space Invaders](/devices/pc8080/machine/invaders/), [VT100](/devices/pc8080/machine/vt100/))
* [PC8080](/modules/pc8080/), a 8080-based machine emulator (e.g., [Space Invaders](/devices/pc8080/machine/invaders/), [VT100 Terminal](/devices/pc8080/machine/vt100/))
* [C1Pjs](/docs/c1pjs/), a 6502-based emulation of the Ohio Scientific [Challenger 1P](/devices/c1p/)

All PCjs computer simulations are written entirely in [JavaScript](/modules/). No Flash, Java or other plugins are
Expand Down
2 changes: 1 addition & 1 deletion devices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Device Configurations
All PCjs machines are built from the following sets of devices:

* [6502-based Devices](c1p/) (e.g., [Challenger 1P](c1p/machine/))
* [8080-based Devices](pc8080/) (e.g., [Space Invaders](pc8080/machine/invaders/), [VT100](pc8080/machine/vt100/))
* [8080-based Devices](pc8080/) (e.g., [Space Invaders](pc8080/machine/invaders/), [VT100 Terminal](pc8080/machine/vt100/))
* [8086-based Devices](pcx86/) (e.g., [IBM PC and compatibles](pcx86/machine/))

These devices are user-installable components that you would typically find in a real personal computer,
Expand Down
4 changes: 2 additions & 2 deletions devices/pc8080/machine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PC8080 Machine Configurations
The following 8080-based machines are currently available:

* [8080 Exerciser](exerciser/)
* [Space Invaders (1978)](invaders/) (with [Debugger](invaders/debugger/))
* [DEC VT100 Terminal](vt100/) (with [Debugger](vt100/debugger/))
* [Space Invaders (1978)](invaders/) ([Debugger](invaders/debugger/))
* [DEC VT100 Terminal](vt100/) ([Debugger](vt100/debugger/))

Check out the [Dual VT100 Terminals](vt100/dual/) for a demo of two PCjs machines communicating over a *virtual* serial connection.
2 changes: 1 addition & 1 deletion devices/pc8080/machine/vt100/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ machines:
DEC VT100 Terminal
------------------

This is a PCjs work-in-progress emulation of another 8080-based machine: the VT100 Terminal.
This is a PCjs emulation of another 8080-based machine: the VT100 Terminal.

Unlike other VT100 emulators, it is not simply an emulation of VT100 protocols. It is a simulation of the original VT100
machine, running the [VT100 Firmware](/devices/pc8080/rom/vt100/) inside the [PC8080](/modules/pc8080/) CPU emulator.
Expand Down
6 changes: 3 additions & 3 deletions devices/pc8080/machine/vt100/dual/debugger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ machines:
type: pc8080
debugger: true
autoStart: true
messages: serial|mem|port
messages: mem|port
config: /devices/pc8080/machine/vt100/debugger/machine.xml
connection: serialPort=vt100b.serialPort
- id: vt100b
type: pc8080
debugger: true
autoStart: true
messages: serial|mem|port
messages: mem|port
config: /devices/pc8080/machine/vt100/debugger/machine.xml
connection: serialPort=vt100a.serialPort
---

Dual VT100 Terminals with Debuggers
-----------------------------------

[Dual VT100 Terminals](../) with Debuggers attached.
Here are [Dual VT100 Terminals](../) with the PCjs Debugger attached to each.

{% include machine.html id="vt100a" %}

Expand Down
40 changes: 24 additions & 16 deletions modules/pc8080/lib/serialport.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,14 @@ function SerialPort(parmsSerial) {
/*
* No connection until initBus() invokes initConnection().
*/
this.connection = this.sendByte = null;
this.sDataReceived = "";
this.connection = this.sendData = null;

/*
* Export all functions required by initConnection(); currently, this is the bare minimum, with no flow control.
*/
this['exports'] = {
'receiveByte': this.receiveByte
'receiveData': this.receiveData
};
}

Expand Down Expand Up @@ -329,8 +330,7 @@ SerialPort.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
*/
sValue = sValue.replace(/\\n/g, "\n").replace(/\\r/g, "\r");
control.onclick = function onClickTest(event) {
serial.sDataReceived = sValue;
serial.receiveData();
serial.receiveData(sValue);
/*
* Give focus back to the machine (since clicking the button takes focus away).
*/
Expand Down Expand Up @@ -362,11 +362,9 @@ SerialPort.prototype.initBus = function(cmp, bus, cpu, dbg)

var serial = this;
this.timerReceiveNext = this.cpu.addTimer(function() {
serial.printMessage("timerReceiveNext()");
serial.receiveData();
});
this.timerTransmitNext = this.cpu.addTimer(function() {
serial.printMessage("timerTransmitNext()");
serial.transmitData();
});

Expand All @@ -388,7 +386,7 @@ SerialPort.prototype.initBus = function(cmp, bus, cpu, dbg)
*
* If the target component is found, then verify that it has exported functions with the following names:
*
* receiveByte(b): called by us when we have a byte to transmit; aliased internally to sendByte(b)
* receiveData(data): called when we have data to transmit; aliased internally to sendData(data)
*
* For now, we're not going to worry about communication in the other direction, because when the target component
* performs its own initConnection(), it will find our receiveByte(b) function, at which point communication in both
Expand All @@ -409,7 +407,7 @@ SerialPort.prototype.initConnection = function()
if (this.connection) {
var exports = this.connection['exports'];
if (exports) {
this.sendByte = exports['receiveByte'];
this.sendData = exports['receiveData'];
}
}
}
Expand Down Expand Up @@ -560,29 +558,37 @@ SerialPort.prototype.getBaudTimeout = function(maskRate)
*/
SerialPort.prototype.receiveByte = function(b)
{
this.printMessage("receiveByte(" + str.toHexByte(b) + "): " + str.toHexByte(this.bStatus));
this.printMessage("receiveByte(" + str.toHexByte(b) + "), status=" + str.toHexByte(this.bStatus));
if (!(this.bStatus & SerialPort.UART8251.STATUS.RECV_FULL)) {
this.bDataIn = b;
this.bStatus |= SerialPort.UART8251.STATUS.RECV_FULL;
this.printMessage("receiveByte(" + str.toHexByte(b) + "): " + str.toHexByte(this.bStatus) + " (requesting interrupt)");
this.cpu.requestINTR(this.nIRQ);
return true;
}
return false;
};

/**
* receiveData()
* receiveData(data)
*
* Helper for clocking received data at the expected RECV_RATE.
*
* Currently, this is only use for test data that we "cram" down the terminal's throat, ensuring that we don't
* cram it too rapidly.
* When we're cramming test data down the terminal's throat, that data will typically be in the form
* of a string. When we're called by another component, data will typically be a number (ie, byte). If no
* data is specified at all, then all we do is "clock" any remaining data into the receiver.
*
* @this {SerialPort}
* @param {number|string|undefined} [data]
*/
SerialPort.prototype.receiveData = function()
SerialPort.prototype.receiveData = function(data)
{
if (data != null) {
if (typeof data != "number") {
this.sDataReceived = data;
} else {
this.sDataReceived += String.fromCharCode(data);
}
}
if (this.sDataReceived) {
if (this.receiveByte(this.sDataReceived.charCodeAt(0))) {
this.sDataReceived = this.sDataReceived.substr(1);
Expand All @@ -604,8 +610,10 @@ SerialPort.prototype.transmitByte = function(b)
{
var fTransmitted = false;

if (this.sendByte) {
if (this.sendByte.call(this.connection, b)) {
this.printMessage("transmitByte(" + str.toHexByte(b) + ")");

if (this.sendData) {
if (this.sendData.call(this.connection, b)) {
fTransmitted = true;
}
}
Expand Down
Loading

0 comments on commit 2e39746

Please sign in to comment.