summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/8530scc.cpp
diff options
context:
space:
mode:
author therealmogminer@gmail.com <therealmogminer@gmail.com>2016-06-19 17:49:28 +0200
committer therealmogminer@gmail.com <therealmogminer@gmail.com>2016-06-19 17:49:28 +0200
commitad030cc4f49180466ae0d702958b8e243ffdc041 (patch)
tree38e163365a4b0480cbbee299aad6ae1384641dc5 /src/devices/machine/8530scc.cpp
parent1905f52ac827e90fa887e954a597b0233fccb5b3 (diff)
Checkpoint
Diffstat (limited to 'src/devices/machine/8530scc.cpp')
-rw-r--r--src/devices/machine/8530scc.cpp162
1 files changed, 63 insertions, 99 deletions
diff --git a/src/devices/machine/8530scc.cpp b/src/devices/machine/8530scc.cpp
index c618fd57004..25484798b36 100644
--- a/src/devices/machine/8530scc.cpp
+++ b/src/devices/machine/8530scc.cpp
@@ -447,7 +447,7 @@ void scc8530_t::set_reg_a(int reg, UINT8 data)
/*-------------------------------------------------
- scc8530_set_reg_a
+ scc8530_set_reg_b
-------------------------------------------------*/
void scc8530_t::set_reg_b(int reg, UINT8 data)
@@ -457,46 +457,41 @@ void scc8530_t::set_reg_b(int reg, UINT8 data)
-/*-------------------------------------------------
- scc8530_r
--------------------------------------------------*/
+//-------------------------------------------------
+// reg_r - read handler, trampolines into normal
+// getter
+//-------------------------------------------------
-READ8_MEMBER( scc8530_t::reg_r)
+READ8_MEMBER(scc8530_t::reg_r)
{
- UINT8 result = 0;
+ return read_reg(offset & 3);
+}
- offset %= 4;
+
+//-------------------------------------------------
+// read_reg - reads either the control or data
+// port for either SCC channel.
+//-------------------------------------------------
+
+UINT8 scc8530_t::read_reg(int offset)
+{
switch(offset)
{
- case 0:
- /* Channel B (Printer Port) Control */
- if (mode == 1)
- mode = 0;
- else
- reg = 0;
-
- result = getbreg();
- break;
+ case 0: /* Channel B (Printer Port) Control */
+ case 1: /* Channel A (Modem Port) Control */
- case 1:
- /* Channel A (Modem Port) Control */
if (mode == 1)
mode = 0;
else
reg = 0;
- result = getareg();
- break;
-
- case 2:
- /* Channel B (Printer Port) Data */
- result = channel[1].rxData;
+ result = (offset == 0) ? getbreg(); : getareg()
break;
- case 3:
- /* Channel A (Modem Port) Data */
- result = channel[0].rxData;
+ case 2: /* Channel B (Printer Port) Data */
+ case 3:/* Channel A (Modem Port) Data */
+ result = channel[offset == 2 ? 1 : 0].rxData;
break;
}
return result;
@@ -504,116 +499,85 @@ READ8_MEMBER( scc8530_t::reg_r)
-/*-------------------------------------------------
- scc8530_w
--------------------------------------------------*/
+//-------------------------------------------------
+// reg_w - write handler, trampolines into normal
+// setter
+//-------------------------------------------------
WRITE8_MEMBER( scc8530_t::reg_w )
{
- Chan *pChan;
+ write_reg(offset & 3, data);
+}
+
- offset &= 3;
+
+//-------------------------------------------------
+// write_reg - writes either the control or data
+// port for either SCC channel.
+//-------------------------------------------------
+
+void scc8530_t::write_reg(int offset, UINT8 data)
+{
+ offset & 3;
// printf(" mode %d data %x offset %d \n", mode, data, offset);
+ Chan *pChan;
switch(offset)
{
- case 0:
- /* Channel B (Printer Port) Control */
- if (mode == 0)
- {
- if((data & 0xf0) == 0) // not a reset command
- {
- mode = 1;
- reg = data & 0x0f;
-// putbreg(data & 0xf0);
- }
- else if (data == 0x10)
- {
- pChan = &channel[1];
- // clear ext. interrupts
- pChan->extIRQPending = 0;
- pChan->baudIRQPending = 0;
- updateirqs();
- }
- }
- else
- {
- mode = 0;
- putreg(1, data);
- }
- break;
-
- case 1:
- /* Channel A (Modem Port) Control */
+ case 0: /* Channel B (Printer Port) Control */
+ case 1: /* Channel A (Modem Port) Control */
+ {
+ int chan = ((offset == 2) ? 1 : 0);
if (mode == 0)
{
if((data & 0xf0) == 0) // not a reset command
{
mode = 1;
reg = data & 0x0f;
-// putareg(data & 0xf0);
+// putbreg(data & 0xf0);
}
else if (data == 0x10)
{
- pChan = &channel[0];
// clear ext. interrupts
- pChan->extIRQPending = 0;
- pChan->baudIRQPending = 0;
+ channel[chan].extIRQPending = 0;
+ channel[chan].baudIRQPending = 0;
updateirqs();
}
}
else
{
mode = 0;
- putreg(0, data);
+ putreg(chan, data);
}
break;
+ }
- case 2:
- /* Channel B (Printer Port) Data */
- pChan = &channel[1];
-
- if (pChan->txEnable)
- {
- pChan->txData = data;
- // local loopback?
- if (pChan->reg_val[14] & 0x10)
- {
- pChan->rxData = data;
- pChan->reg_val[0] |= 0x01; // Rx character available
- }
- pChan->reg_val[1] |= 0x01; // All sent
- pChan->reg_val[0] |= 0x04; // Tx empty
- pChan->txUnderrun = 1;
- pChan->txIRQPending = 1;
- updateirqs();
- }
- break;
-
- case 3:
- /* Channel A (Modem Port) Data */
- pChan = &channel[0];
-
- if (pChan->txEnable)
+ case 2: /* Channel B (Printer Port) Data */
+ case 3: /* Channel A (Modem Port) Data */
+ {
+ int chan = ((offset == 2) ? 1 : 0);
+ if (channel[chan].txEnable)
{
- pChan->txData = data;
+ channel[chan].txData = data;
// local loopback?
- if (pChan->reg_val[14] & 0x10)
+ if (channel[chan].reg_val[14] & 0x10)
{
- pChan->rxData = data;
- pChan->reg_val[0] |= 0x01; // Rx character available
+ channel[chan].rxData = data;
+ channel[chan].reg_val[0] |= 0x01; // Rx character available
}
- pChan->reg_val[1] |= 0x01; // All sent
- pChan->reg_val[0] |= 0x04; // Tx empty
- pChan->txUnderrun = 1;
- pChan->txIRQPending = 1;
+ channel[chan].reg_val[1] |= 0x01; // All sent
+ channel[chan].reg_val[0] |= 0x04; // Tx empty
+ channel[chan].txUnderrun = 1;
+ channel[chan].txIRQPending = 1;
updateirqs();
}
break;
+ }
}
}
+
/*
AppleTalk check: