1
0
mirror of https://github.com/sethm/symon.git synced 2025-08-08 20:25:01 +00:00

move overrun detection and reset into the abstract superclass for ACIAs

This commit is contained in:
Maik Merten
2014-07-19 17:10:57 +02:00
parent cf36f731da
commit 4a37dd7463
2 changed files with 16 additions and 26 deletions

View File

@@ -108,11 +108,16 @@ public abstract class Acia extends Device {
public synchronized int rxRead() { public synchronized int rxRead() {
lastRxRead = System.nanoTime(); lastRxRead = System.nanoTime();
overrun = false;
rxFull = false; rxFull = false;
return rxChar; return rxChar;
} }
public synchronized void rxWrite(int data) { public synchronized void rxWrite(int data) {
if(rxFull) {
overrun = true;
}
rxFull = true; rxFull = true;
if (receiveIrqEnabled) { if (receiveIrqEnabled) {

View File

@@ -42,8 +42,8 @@ public class Acia6850 extends Acia {
public static final int ACIA_SIZE = 2; public static final int ACIA_SIZE = 2;
static final int STAT_REG = 0; // read-only static final int STAT_REG = 0; // read-only
static final int CTRL_REG = 0; // write-only static final int CTRL_REG = 0; // write-only
static final int RX_REG = 1; // read-only static final int RX_REG = 1; // read-only
static final int TX_REG = 1; // write-only static final int TX_REG = 1; // write-only
@@ -57,7 +57,7 @@ public class Acia6850 extends Acia {
public Acia6850(int address) throws MemoryRangeException { public Acia6850(int address) throws MemoryRangeException {
super(address, ACIA_SIZE, "ACIA6850"); super(address, ACIA_SIZE, "ACIA6850");
setBaudRate(2400); setBaudRate(2400);
} }
@Override @Override
@@ -87,28 +87,13 @@ public class Acia6850 extends Acia {
} }
} }
@Override
public synchronized int rxRead() {
overrun = false;
return super.rxRead();
}
@Override
public synchronized void rxWrite(int data) {
if(rxFull) {
overrun = true;
}
super.rxWrite(data);
}
private void setCommandRegister(int data) { private void setCommandRegister(int data) {
commandRegister = data; commandRegister = data;
// Bits 0 & 1 control the master reset // Bits 0 & 1 control the master reset
if((commandRegister & 0x01) != 0 && (commandRegister & 0x02) != 0) { if((commandRegister & 0x01) != 0 && (commandRegister & 0x02) != 0) {
reset(); reset();
} }
// Bit 7 controls receiver IRQ behavior // Bit 7 controls receiver IRQ behavior
receiveIrqEnabled = (commandRegister & 0x80) != 0; receiveIrqEnabled = (commandRegister & 0x80) != 0;
@@ -131,16 +116,16 @@ public class Acia6850 extends Acia {
if (txEmpty && System.nanoTime() >= (lastTxWrite + baudRateDelay)) { if (txEmpty && System.nanoTime() >= (lastTxWrite + baudRateDelay)) {
stat |= 0x02; stat |= 0x02;
} }
if (overrun) { if (overrun) {
stat |= 0x20; stat |= 0x20;
} }
return stat; return stat;
} }
private synchronized void reset() { private synchronized void reset() {
overrun = false; overrun = false;
rxFull = false; rxFull = false;
txEmpty = true; txEmpty = true;
} }