summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/tms9901.h
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/tms9901.h
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/tms9901.h')
-rw-r--r--src/devices/machine/tms9901.h141
1 files changed, 54 insertions, 87 deletions
diff --git a/src/devices/machine/tms9901.h b/src/devices/machine/tms9901.h
index 1ec5d3287c4..f83e8ad6e22 100644
--- a/src/devices/machine/tms9901.h
+++ b/src/devices/machine/tms9901.h
@@ -12,8 +12,8 @@
*****************************************************************************/
-#ifndef __TMS9901_H__
-#define __TMS9901_H__
+#ifndef MAME_MACHINE_TMS9901_H
+#define MAME_MACHINE_TMS9901_H
extern const device_type TMS9901;
@@ -22,32 +22,6 @@ extern const device_type TMS9901;
MACROS
***************************************************************************/
-// Masks for the interrupts levels available on TMS9901
-
-#define TMS9901_INT1 0x0002
-#define TMS9901_INT2 0x0004
-#define TMS9901_INT3 0x0008 // overridden by the timer interrupt
-#define TMS9901_INT4 0x0010
-#define TMS9901_INT5 0x0020
-#define TMS9901_INT6 0x0040
-#define TMS9901_INT7 0x0080
-#define TMS9901_INT8 0x0100
-#define TMS9901_INT9 0x0200
-#define TMS9901_INTA 0x0400
-#define TMS9901_INTB 0x0800
-#define TMS9901_INTC 0x1000
-#define TMS9901_INTD 0x2000
-#define TMS9901_INTE 0x4000
-#define TMS9901_INTF 0x8000
-
-enum
-{
- TMS9901_CB_INT7 = 0,
- TMS9901_INT8_INT15 = 1,
- TMS9901_P0_P7 = 2,
- TMS9901_P8_P15 = 3
-};
-
/***************************************************************************
CLASS DEFINITION
***************************************************************************/
@@ -55,6 +29,31 @@ enum
class tms9901_device : public device_t
{
public:
+ // Masks for the interrupts levels available on TMS9901
+ static constexpr int INT1 = 0x0002;
+ static constexpr int INT2 = 0x0004;
+ static constexpr int INT3 = 0x0008; // overridden by the timer interrupt
+ static constexpr int INT4 = 0x0010;
+ static constexpr int INT5 = 0x0020;
+ static constexpr int INT6 = 0x0040;
+ static constexpr int INT7 = 0x0080;
+ static constexpr int INT8 = 0x0100;
+ static constexpr int INT9 = 0x0200;
+ static constexpr int INTA = 0x0400;
+ static constexpr int INTB = 0x0800;
+ static constexpr int INTC = 0x1000;
+ static constexpr int INTD = 0x2000;
+ static constexpr int INTE = 0x4000;
+ static constexpr int INTF = 0x8000;
+
+ enum
+ {
+ CB_INT7 = 0,
+ INT8_INT15 = 1,
+ P0_P7 = 2,
+ P8_P15 = 3
+ };
+
tms9901_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
void set_single_int(int pin_number, int state);
@@ -64,37 +63,20 @@ public:
DECLARE_READ8_MEMBER( read );
DECLARE_WRITE8_MEMBER( write );
- template<class _Object> static devcb_base &static_set_readblock_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_read_block.set_callback(object); }
-
- template<class _Object> static devcb_base &static_set_p0_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p0.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p1_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p1.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p2_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p2.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p3_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p3.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p4_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p4.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p5_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p5.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p6_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p6.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p7_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p7.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p8_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p8.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p9_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p9.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p10_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p10.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p11_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p11.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p12_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p12.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p13_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p13.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p14_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p14.set_callback(object); }
- template<class _Object> static devcb_base &static_set_p15_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_write_p15.set_callback(object); }
-
- template<class _Object> static devcb_base &static_set_intlevel_callback(device_t &device, _Object object) { return downcast<tms9901_device &>(device).m_interrupt.set_callback(object); }
+ template <class Object> static devcb_base &static_set_readblock_callback(device_t &device, Object &&cb) { return downcast<tms9901_device &>(device).m_read_block.set_callback(std::forward<Object>(cb)); }
+ template <unsigned N, class Object> static devcb_base &static_set_p_callback(device_t &device, Object &&cb) { return downcast<tms9901_device &>(device).m_write_p[N].set_callback(std::forward<Object>(cb)); }
+ template <class Object> static devcb_base &static_set_intlevel_callback(device_t &device, Object &&cb) { return downcast<tms9901_device &>(device).m_interrupt.set_callback(std::forward<Object>(cb)); }
private:
- static const device_timer_id DECREMENTER = 0;
+ static constexpr device_timer_id DECREMENTER = 0;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
- void timer_reload(void);
- void field_interrupts(void);
+ void timer_reload();
+ void field_interrupts();
- void device_start(void) override;
- void device_stop(void) override;
- void device_reset(void) override;
+ void device_start() override;
+ void device_stop() override;
+ void device_reset() override;
// Common method for device_reset and rst1_line
void do_reset();
@@ -145,22 +127,7 @@ private:
devcb_read8 m_read_block;
// I/O lines, used for output. When used as inputs, the levels are delivered via the m_read_block
- devcb_write_line m_write_p0;
- devcb_write_line m_write_p1;
- devcb_write_line m_write_p2;
- devcb_write_line m_write_p3;
- devcb_write_line m_write_p4;
- devcb_write_line m_write_p5;
- devcb_write_line m_write_p6;
- devcb_write_line m_write_p7;
- devcb_write_line m_write_p8;
- devcb_write_line m_write_p9;
- devcb_write_line m_write_p10;
- devcb_write_line m_write_p11;
- devcb_write_line m_write_p12;
- devcb_write_line m_write_p13;
- devcb_write_line m_write_p14;
- devcb_write_line m_write_p15;
+ devcb_write_line m_write_p[16];
// The invocation corresponds to the INTREQ signal (with the level passed as data)
// and the address delivers the interrupt level (0-15)
@@ -175,54 +142,54 @@ private:
devcb = &tms9901_device::static_set_readblock_callback( *device, DEVCB_##_read );
#define MCFG_TMS9901_P0_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p0_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<0>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P1_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p1_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<1>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P2_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p2_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<2>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P3_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p3_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<3>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P4_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p4_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<4>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P5_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p5_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<5>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P6_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p6_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<6>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P7_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p7_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<7>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P8_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p8_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<8>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P9_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p9_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<9>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P10_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p10_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<10>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P11_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p11_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<11>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P12_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p12_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<12>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P13_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p13_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<13>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P14_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p14_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<14>( *device, DEVCB_##_write );
#define MCFG_TMS9901_P15_HANDLER( _write ) \
- devcb = &tms9901_device::static_set_p15_callback( *device, DEVCB_##_write );
+ devcb = &tms9901_device::static_set_p_callback<15>( *device, DEVCB_##_write );
#define MCFG_TMS9901_INTLEVEL_HANDLER( _intlevel ) \
devcb = &tms9901_device::static_set_intlevel_callback( *device, DEVCB_##_intlevel );
-#endif /* __TMS9901_H__ */
+#endif // MAME_MACHINE_TMS9901_H