summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/nsc810.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2017-05-07 23:18:47 +1000
committer Vas Crabb <vas@vastheman.com>2017-05-14 21:44:11 +1000
commit0f0d39ef81562c75e79176dd3bebb1e491ca39d5 (patch)
tree201cee7fdf55ee800f83859a92efd2cfe66cf2b3 /src/devices/machine/nsc810.cpp
parente6c4be2b4d71c7a6c95be0bae111eb416ff0f9e7 (diff)
Move static data out of devices into the device types. This is a significant change, so please pay attention.
The core changes are: * Short name, full name and source file are no longer members of device_t, they are part of the device type * MACHINE_COFIG_START no longer needs a driver class * MACHINE_CONFIG_DERIVED_CLASS is no longer necessary * Specify the state class you want in the GAME/COMP/CONS line * The compiler will work out the base class where the driver init member is declared * There is one static device type object per driver rather than one per machine configuration Use DECLARE_DEVICE_TYPE or DECLARE_DEVICE_TYPE_NS to declare device type. * DECLARE_DEVICE_TYPE forward-declares teh device type and class, and declares extern object finders. * DECLARE_DEVICE_TYPE_NS is for devices classes in namespaces - it doesn't forward-declare the device type. Use DEFINE_DEVICE_TYPE or DEFINE_DEVICE_TYPE_NS to define device types. * These macros declare storage for the static data, and instantiate the device type and device finder templates. The rest of the changes are mostly just moving stuff out of headers that shouldn't be there, renaming stuff for consistency, and scoping stuff down where appropriate. Things I've actually messed with substantially: * More descriptive names for a lot of devices * Untangled the fantasy sound from the driver state, which necessitates breaking up sound/flip writes * Changed DECO BSMT2000 ready callback into a device delegate * Untangled Microprose 3D noise from driver state * Used object finders for CoCo multipak, KC85 D002, and Irem sound subdevices * Started to get TI-99 stuff out of the TI-990 directory and arrange bus devices properly * Started to break out common parts of Samsung ARM SoC devices * Turned some of FM, SID, SCSP DSP, EPIC12 and Voodoo cores into something resmbling C++ * Tried to make Z180 table allocation/setup a bit safer * Converted generic keyboard/terminal to not use WRITE8 - space/offset aren't relevant * Dynamically allocate generic terminal buffer so derived devices (e.g. teleprinter) can specify size * Imporved encapsulation of Z80DART channels * Refactored the SPC7110 bit table generator loop to make it more readable * Added wrappers for SNES PPU operations so members can be made protected * Factored out some boilerplate for YM chips with PSG * toaplan2 gfx * stic/intv resolution * Video System video * Out Run/Y-board sprite alignment * GIC video hookup * Amstrad CPC ROM box members * IQ151 ROM cart region * MSX cart IRQ callback resolution time * SMS passthrough control devices starting subslots I've smoke-tested several drivers, but I've probably missed something. Things I've missed will likely blow up spectacularly with failure to bind errors and the like. Let me know if there's more subtle breakage (could have happened in FM or Voodoo). And can everyone please, please try to keep stuff clean. In particular, please stop polluting the global namespace. Keep things out of headers that don't need to be there, and use things that can be scoped down rather than macros. It feels like an uphill battle trying to get this stuff under control while more of it's added.
Diffstat (limited to 'src/devices/machine/nsc810.cpp')
-rw-r--r--src/devices/machine/nsc810.cpp90
1 files changed, 50 insertions, 40 deletions
diff --git a/src/devices/machine/nsc810.cpp b/src/devices/machine/nsc810.cpp
index a5314ecc3ab..bf06c34d9dc 100644
--- a/src/devices/machine/nsc810.cpp
+++ b/src/devices/machine/nsc810.cpp
@@ -15,18 +15,28 @@
#include "emu.h"
#include "nsc810.h"
+#define VERBOSE 1
+#include "logmacro.h"
+
+
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
-#define LOG (1)
-
-const device_type NSC810 = device_creator<nsc810_device>;
+DEFINE_DEVICE_TYPE(NSC810, nsc810_device, "nsc810", "National Semiconductor NSC810 RAM-I/O-Timer")
nsc810_device::nsc810_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- device_t(mconfig, NSC810, "National Semiconductor NSC810", tag, owner, clock, "nsc810", __FILE__), m_portA_latch(0), m_portB_latch(0), m_portC_latch(0),
- m_ddrA(0), m_ddrB(0), m_ddrC(0), m_mode(0), m_timer0(nullptr), m_timer1(nullptr), m_timer0_mode(0), m_timer1_mode(0), m_timer0_counter(0), m_timer1_counter(0),
- m_timer0_base(0), m_timer1_base(0), m_timer0_running(false), m_timer1_running(false), m_timer0_clock(0), m_timer1_clock(0), m_ramselect(false),
+ device_t(mconfig, NSC810, tag, owner, clock),
+ m_portA_latch(0), m_portB_latch(0), m_portC_latch(0),
+ m_ddrA(0), m_ddrB(0), m_ddrC(0),
+ m_mode(0),
+ m_timer0(nullptr), m_timer1(nullptr),
+ m_timer0_mode(0), m_timer1_mode(0),
+ m_timer0_counter(0), m_timer1_counter(0),
+ m_timer0_base(0), m_timer1_base(0),
+ m_timer0_running(false), m_timer1_running(false),
+ m_timer0_clock(0), m_timer1_clock(0),
+ m_ramselect(false),
m_portA_r(*this),
m_portB_r(*this),
m_portC_r(*this),
@@ -89,7 +99,7 @@ void nsc810_device::device_timer(emu_timer &timer, device_timer_id id, int param
{
m_timer0_out(ASSERT_LINE);
m_timer0_counter = m_timer0_base;
- if(LOG) logerror("NSC810 '%s': Timer 0 output set\n",tag());
+ LOG("NSC810: Timer 0 output set\n");
}
}
break;
@@ -101,7 +111,7 @@ void nsc810_device::device_timer(emu_timer &timer, device_timer_id id, int param
{
m_timer1_out(ASSERT_LINE);
m_timer1_counter = m_timer1_base;
- if(LOG) logerror("NSC810 '%s': Timer 1 output set\n",tag());
+ LOG("NSC810: Timer 1 output set\n");
}
}
break;
@@ -124,17 +134,17 @@ READ8_MEMBER(nsc810_device::read)
case REG_PORTA:
res = m_portA_latch &= m_ddrA;
res |= (m_portA_r() & ~m_ddrA);
- //if(LOG) logerror("NSC810 '%s': Port A data read %02x\n",tag(),res);
+ //LOG("NSC810: Port A data read %02x\n",res);
break;
case REG_PORTB:
res = m_portB_latch &= m_ddrB;
res |= (m_portB_r() & ~m_ddrB);
- //if(LOG) logerror("NSC810 '%s': Port B data read %02x\n",tag(),res);
+ //LOG("NSC810: Port B data read %02x\n",res);
break;
case REG_PORTC:
res = m_portC_latch &= m_ddrC;
res |= (m_portC_r() & ~m_ddrC);
- //if(LOG) logerror("NSC810 '%s': Port C data read %02x\n",tag(),res);
+ //LOG("NSC810: Port C data read %02x\n",res);
break;
case REG_MODE_TIMER0:
res = m_timer0_mode;
@@ -147,7 +157,7 @@ READ8_MEMBER(nsc810_device::read)
if((m_timer0_mode & 0x07) == 0x01 || (m_timer0_mode & 0x07) == 0x02)
{
m_timer0_out(CLEAR_LINE);
- if(LOG) logerror("NSC810 '%s': Timer 0 output reset\n",tag());
+ LOG("NSC810: Timer 0 output reset\n");
}
break;
case REG_TIMER0_HIGH:
@@ -155,7 +165,7 @@ READ8_MEMBER(nsc810_device::read)
if((m_timer0_mode & 0x07) == 0x01 || (m_timer0_mode & 0x07) == 0x02)
{
m_timer0_out(CLEAR_LINE);
- if(LOG) logerror("NSC810 '%s': Timer 0 output reset\n",tag());
+ LOG("NSC810: Timer 0 output reset\n");
}
break;
case REG_TIMER1_LOW:
@@ -163,7 +173,7 @@ READ8_MEMBER(nsc810_device::read)
if((m_timer1_mode & 0x07) == 0x01 || (m_timer1_mode & 0x07) == 0x02)
{
m_timer1_out(0);
- if(LOG) logerror("NSC810 '%s': Timer 1 output reset\n",tag());
+ LOG("NSC810: Timer 1 output reset\n");
}
break;
case REG_TIMER1_HIGH:
@@ -171,11 +181,11 @@ READ8_MEMBER(nsc810_device::read)
if((m_timer1_mode & 0x07) == 0x01 || (m_timer1_mode & 0x07) == 0x02)
{
m_timer1_out(0);
- if(LOG) logerror("NSC810 '%s': Timer 1 output reset\n",tag());
+ LOG("NSC810: Timer 1 output reset\n");
}
break;
default:
- if(LOG) logerror("NSC810 '%s': unused port %02x read\n",tag(),offset);
+ LOG("NSC810: unused port %02x read\n",offset);
}
}
return res;
@@ -197,75 +207,75 @@ WRITE8_MEMBER(nsc810_device::write)
case REG_PORTA:
m_portA_latch = data & ~m_ddrA;
m_portA_w((0xff & ~m_ddrA) | (data & m_ddrA));
- if(LOG) logerror("NSC810 '%s': Port A data write %02x\n",tag(),data);
+ LOG("NSC810: Port A data write %02x\n",data);
break;
case REG_PORTB:
m_portB_latch = data & ~m_ddrB;
m_portB_w((0xff & ~m_ddrB) | (data & m_ddrB));
- if(LOG) logerror("NSC810 '%s': Port B data write %02x\n",tag(),data);
+ LOG("NSC810: Port B data write %02x\n",data);
break;
case REG_PORTC:
m_portC_latch = data & ~m_ddrC;
m_portC_w((0xff & ~m_ddrC) | (data & m_ddrC));
- if(LOG) logerror("NSC810 '%s': Port C data write %02x\n",tag(),data);
+ LOG("NSC810: Port C data write %02x\n",data);
break;
case REG_DDRA:
m_ddrA = data;
- if(LOG) logerror("NSC810 '%s': Port A direction write %02x\n",tag(),data);
+ LOG("NSC810: Port A direction write %02x\n",data);
break;
case REG_DDRB:
m_ddrB = data;
- if(LOG) logerror("NSC810 '%s': Port B direction write %02x\n",tag(),data);
+ LOG("NSC810: Port B direction write %02x\n",data);
break;
case REG_DDRC:
m_ddrC = data;
- if(LOG) logerror("NSC810 '%s': Port C direction write %02x\n",tag(),data);
+ LOG("NSC810: Port C direction write %02x\n",data);
break;
case REG_MODE_DEF:
- if(LOG) logerror("NSC810 '%s': Mode Definition write %02x\n",tag(),data);
+ LOG("NSC810: Mode Definition write %02x\n",data);
break;
case REG_PORTA_BITCLR:
- if(LOG) logerror("NSC810 '%s': Port A bit-clear write %02x\n",tag(),data);
+ LOG("NSC810: Port A bit-clear write %02x\n",data);
break;
case REG_PORTB_BITCLR:
- if(LOG) logerror("NSC810 '%s': Port B bit-clear write %02x\n",tag(),data);
+ LOG("NSC810: Port B bit-clear write %02x\n",data);
break;
case REG_PORTC_BITCLR:
- if(LOG) logerror("NSC810 '%s': Port C bit-clear write %02x\n",tag(),data);
+ LOG("NSC810: Port C bit-clear write %02x\n",data);
break;
case REG_PORTA_BITSET:
- if(LOG) logerror("NSC810 '%s': Port A bit-set write %02x\n",tag(),data);
+ LOG("NSC810: Port A bit-set write %02x\n",data);
break;
case REG_PORTB_BITSET:
- if(LOG) logerror("NSC810 '%s': Port B bit-set write %02x\n",tag(),data);
+ LOG("NSC810: Port B bit-set write %02x\n",data);
break;
case REG_PORTC_BITSET:
- if(LOG) logerror("NSC810 '%s': Port C bit-set write %02x\n",tag(),data);
+ LOG("NSC810: Port C bit-set write %02x\n",data);
break;
case REG_TIMER0_LOW:
m_timer0_base = (m_timer0_base & 0xff00) | data;
m_timer0_counter = (m_timer0_counter & 0xff00) | data;
- if(LOG) logerror("NSC810 '%s': Timer 0 low-byte write %02x (base=%04x)\n",tag(),data,m_timer0_base);
+ LOG("NSC810: Timer 0 low-byte write %02x (base=%04x)\n",data,m_timer0_base);
break;
case REG_TIMER0_HIGH:
m_timer0_base = (m_timer0_base & 0x00ff) | (data << 8);
m_timer0_counter = (m_timer0_counter & 0x00ff) | (data << 8);
- if(LOG) logerror("NSC810 '%s': Timer 0 high-byte write %02x (base=%04x)\n",tag(),data,m_timer0_base);
+ LOG("NSC810: Timer 0 high-byte write %02x (base=%04x)\n",data,m_timer0_base);
break;
case REG_TIMER1_LOW:
m_timer1_base = (m_timer1_base & 0xff00) | data;
m_timer1_counter = (m_timer1_counter & 0xff00) | data;
- if(LOG) logerror("NSC810 '%s': Timer 1 low-byte write %02x (base=%04x)\n",tag(),data,m_timer1_base);
+ LOG("NSC810: Timer 1 low-byte write %02x (base=%04x)\n",data,m_timer1_base);
break;
case REG_TIMER1_HIGH:
m_timer1_base = (m_timer1_base & 0x00ff) | (data << 8);
m_timer1_counter = (m_timer1_counter & 0x00ff) | (data << 8);
- if(LOG) logerror("NSC810 '%s': Timer 1 high-byte write %02x (base=%04x)\n",tag(),data,m_timer1_base);
+ LOG("NSC810: Timer 1 high-byte write %02x (base=%04x)\n",data,m_timer1_base);
break;
case REG_TIMER0_STOP:
m_timer0_running = false;
m_timer0->reset();
- if(LOG) logerror("NSC810 '%s': Timer 0 Stop write %02x\n",tag(),data);
+ LOG("NSC810: Timer 0 Stop write %02x\n",tag(),data);
break;
case REG_TIMER0_START:
if((m_timer0_mode & 0x07) != 0x00 && (m_timer0_mode & 0x07) != 0x07)
@@ -280,12 +290,12 @@ WRITE8_MEMBER(nsc810_device::write)
rate = m_timer0_clock;
m_timer0->adjust(attotime::zero,0,attotime::from_hz(rate));
}
- if(LOG) logerror("NSC810 '%s': Timer 0 Start write %02x\n",tag(),data);
+ LOG("NSC810: Timer 0 Start write %02x\n",data);
break;
case REG_TIMER1_STOP:
m_timer1_running = false;
m_timer1->reset();
- if(LOG) logerror("NSC810 '%s': Timer 1 Stop write %02x\n",tag(),data);
+ LOG("NSC810: Timer 1 Stop write %02x\n",data);
break;
case REG_TIMER1_START:
if((m_timer1_mode & 0x07) != 0x00 && (m_timer1_mode & 0x07) != 0x07)
@@ -298,18 +308,18 @@ WRITE8_MEMBER(nsc810_device::write)
rate = m_timer0_clock;
m_timer1->adjust(attotime::zero,0,attotime::from_hz(rate));
}
- if(LOG) logerror("NSC810 '%s': Timer 1 Start write %02x\n",tag(),data);
+ LOG("NSC810: Timer 1 Start write %02x\n",data);
break;
case REG_MODE_TIMER0:
m_timer0_mode = data;
- if(LOG) logerror("NSC810 '%s': Timer 0 Mode write %02x\n",tag(),data);
+ LOG("NSC810: Timer 0 Mode write %02x\n",data);
break;
case REG_MODE_TIMER1:
m_timer1_mode = data;
- if(LOG) logerror("NSC810 '%s': Timer 1 Mode write %02x\n",tag(),data);
+ LOG("NSC810: Timer 1 Mode write %02x\n",data);
break;
default:
- logerror("NSC810 '%s': Unused register %02x write %02x\n",tag(),offset,data);
+ logerror("NSC810: Unused register %02x write %02x\n",offset,data);
}
}
}