summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/cpu/tms32031
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2011-04-27 05:11:18 +0000
committer Aaron Giles <aaron@aarongiles.com>2011-04-27 05:11:18 +0000
commit919913f118760c0ca41ab63512bd5c106f6fd840 (patch)
treecd6c115c8e9c5280ac4bd16eabfe69c7341151c2 /src/emu/cpu/tms32031
parent84f2c31f7d6f6c667427b1d60c83e6dc9f420d60 (diff)
Collapsed device_config and device_t into one class. Updated all
existing modern devices and the legacy wrappers to work in this environment. This in general greatly simplifies writing a modern device. [Aaron Giles] General notes: * some more cleanup probably needs to happen behind this change, but I needed to get it in before the next device modernization or import from MESS :) * new template function device_creator which automatically defines the static function that creates the device; use this instead of creating a static_alloc_device_config function * added device_stop() method which is called at around the time the previous device_t's destructor was called; if you auto_free anything, do it here because the machine is gone when the destructor is called * changed the static_set_* calls to pass a device_t & instead of a device_config * * for many devices, the static config structure member names over- lapped the device's names for devcb_* functions; in these cases the members in the interface were renamed to have a _cb suffix * changed the driver_enumerator to only cache 100 machine_configs because caching them all took a ton of memory; fortunately this implementation detail is completely hidden behind the driver_enumerator interface * got rid of the macros for creating derived classes; doing it manually is now clean enough that it isn't worth hiding the details in a macro
Diffstat (limited to 'src/emu/cpu/tms32031')
-rw-r--r--src/emu/cpu/tms32031/32031ops.c26
-rw-r--r--src/emu/cpu/tms32031/tms32031.c250
-rw-r--r--src/emu/cpu/tms32031/tms32031.h130
3 files changed, 144 insertions, 262 deletions
diff --git a/src/emu/cpu/tms32031/32031ops.c b/src/emu/cpu/tms32031/32031ops.c
index 31482d4a407..12f8a815f54 100644
--- a/src/emu/cpu/tms32031/32031ops.c
+++ b/src/emu/cpu/tms32031/32031ops.c
@@ -138,10 +138,10 @@ void tms3203x_device::update_special(int dreg)
}
else if (dreg == TMR_IOF)
{
- if (m_config.m_xf0_w != NULL && IREG(TMR_IOF) & 0x002)
- (*m_config.m_xf0_w)(*this, (IREG(TMR_IOF) >> 2) & 1);
- if (m_config.m_xf1_w != NULL && IREG(TMR_IOF) & 0x020)
- (*m_config.m_xf1_w)(*this, (IREG(TMR_IOF) >> 6) & 1);
+ if (m_xf0_w != NULL && IREG(TMR_IOF) & 0x002)
+ (*m_xf0_w)(*this, (IREG(TMR_IOF) >> 2) & 1);
+ if (m_xf1_w != NULL && IREG(TMR_IOF) & 0x020)
+ (*m_xf1_w)(*this, (IREG(TMR_IOF) >> 6) & 1);
}
else if (dreg == TMR_ST || dreg == TMR_IF || dreg == TMR_IE)
check_irqs();
@@ -3142,21 +3142,21 @@ void tms3203x_device::xor_imm(UINT32 op)
void tms3203x_device::iack_dir(UINT32 op)
{
offs_t addr = DIRECT(op);
- if (m_config.m_iack_w)
- (*m_config.m_iack_w)(*this, ASSERT_LINE, addr);
+ if (m_iack_w)
+ (*m_iack_w)(*this, ASSERT_LINE, addr);
RMEM(addr);
- if (m_config.m_iack_w)
- (*m_config.m_iack_w)(*this, CLEAR_LINE, addr);
+ if (m_iack_w)
+ (*m_iack_w)(*this, CLEAR_LINE, addr);
}
void tms3203x_device::iack_ind(UINT32 op)
{
offs_t addr = INDIRECT_D(op, op >> 8);
- if (m_config.m_iack_w)
- (*m_config.m_iack_w)(*this, ASSERT_LINE, addr);
+ if (m_iack_w)
+ (*m_iack_w)(*this, ASSERT_LINE, addr);
RMEM(addr);
- if (m_config.m_iack_w)
- (*m_config.m_iack_w)(*this, CLEAR_LINE, addr);
+ if (m_iack_w)
+ (*m_iack_w)(*this, CLEAR_LINE, addr);
}
/*-----------------------------------------------------*/
@@ -5671,7 +5671,7 @@ void tms3203x_device::trap(int trapnum)
{
WMEM(++IREG(TMR_SP), m_pc);
IREG(TMR_ST) &= ~GIEFLAG;
- if (m_config.m_chip_type == tms3203x_device_config::CHIP_TYPE_TMS32032)
+ if (m_chip_type == CHIP_TYPE_TMS32032)
m_pc = RMEM(((IREG(TMR_IF) >> 16) << 8) + trapnum);
else if (m_mcu_mode)
m_pc = 0x809fc0 + trapnum;
diff --git a/src/emu/cpu/tms32031/tms32031.c b/src/emu/cpu/tms32031/tms32031.c
index c56d0007022..227e52f5e77 100644
--- a/src/emu/cpu/tms32031/tms32031.c
+++ b/src/emu/cpu/tms32031/tms32031.c
@@ -115,9 +115,9 @@ const int GIEFLAG = 0x2000;
// GLOBAL VARIABLES
//**************************************************************************
-// device definitions
-const device_type TMS32031 = tms32031_device_config::static_alloc_device_config;
-const device_type TMS32032 = tms32032_device_config::static_alloc_device_config;
+// device type definition
+const device_type TMS32031 = &device_creator<tms32031_device>;
+const device_type TMS32032 = &device_creator<tms32032_device>;
// internal memory maps
static ADDRESS_MAP_START( internal_32031, AS_PROGRAM, 32 )
@@ -131,143 +131,6 @@ ADDRESS_MAP_END
//**************************************************************************
-// TMS3203X DEVICE CONFIG
-//**************************************************************************
-
-//-------------------------------------------------
-// tms3203x_device_config - constructor
-//-------------------------------------------------
-
-tms3203x_device_config::tms3203x_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 chiptype, address_map_constructor internal_map)
- : cpu_device_config(mconfig, type, name, tag, owner, clock),
- m_program_config("program", ENDIANNESS_LITTLE, 32, 24, -2, internal_map),
- m_chip_type(chiptype)
-{
- m_bootoffset = 0;
- m_xf0_w = NULL;
- m_xf1_w = NULL;
- m_iack_w = NULL;
-}
-
-tms32031_device_config::tms32031_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
- : tms3203x_device_config(mconfig, static_alloc_device_config, "TMS32031", tag, owner, clock, CHIP_TYPE_TMS32031, ADDRESS_MAP_NAME(internal_32031)) { }
-
-tms32032_device_config::tms32032_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
- : tms3203x_device_config(mconfig, static_alloc_device_config, "TMS32032", tag, owner, clock, CHIP_TYPE_TMS32032, ADDRESS_MAP_NAME(internal_32032)) { }
-
-
-//-------------------------------------------------
-// static_alloc_device_config - allocate a new
-// configuration object
-//-------------------------------------------------
-
-device_config *tms32031_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
-{
- return global_alloc(tms32031_device_config(mconfig, tag, owner, clock));
-}
-
-device_config *tms32032_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
-{
- return global_alloc(tms32032_device_config(mconfig, tag, owner, clock));
-}
-
-
-//-------------------------------------------------
-// alloc_device - allocate a new device object
-//-------------------------------------------------
-
-device_t *tms32031_device_config::alloc_device(running_machine &machine) const
-{
- return auto_alloc(machine, tms32031_device(machine, *this));
-}
-
-device_t *tms32032_device_config::alloc_device(running_machine &machine) const
-{
- return auto_alloc(machine, tms32032_device(machine, *this));
-}
-
-
-//-------------------------------------------------
-// static_set_config - set the configuration
-// structure
-//-------------------------------------------------
-
-void tms3203x_device_config::static_set_config(device_config *device, const tms3203x_config &config)
-{
- tms3203x_device_config *tms = downcast<tms3203x_device_config *>(device);
- *static_cast<tms3203x_config *>(tms) = config;
-}
-
-
-//-------------------------------------------------
-// execute_min_cycles - return minimum number of
-// cycles it takes for one instruction to execute
-//-------------------------------------------------
-
-UINT32 tms3203x_device_config::execute_min_cycles() const
-{
- return 1;
-}
-
-
-//-------------------------------------------------
-// execute_max_cycles - return maximum number of
-// cycles it takes for one instruction to execute
-//-------------------------------------------------
-
-UINT32 tms3203x_device_config::execute_max_cycles() const
-{
- return 4;
-}
-
-
-//-------------------------------------------------
-// execute_input_lines - return the number of
-// input/interrupt lines
-//-------------------------------------------------
-
-UINT32 tms3203x_device_config::execute_input_lines() const
-{
- return 11;
-}
-
-
-//-------------------------------------------------
-// memory_space_config - return the configuration
-// of the specified address space, or NULL if
-// the space doesn't exist
-//-------------------------------------------------
-
-const address_space_config *tms3203x_device_config::memory_space_config(address_spacenum spacenum) const
-{
- return (spacenum == AS_PROGRAM) ? &m_program_config : NULL;
-}
-
-
-//-------------------------------------------------
-// disasm_min_opcode_bytes - return the length
-// of the shortest instruction, in bytes
-//-------------------------------------------------
-
-UINT32 tms3203x_device_config::disasm_min_opcode_bytes() const
-{
- return 4;
-}
-
-
-//-------------------------------------------------
-// disasm_max_opcode_bytes - return the length
-// of the longest instruction, in bytes
-//-------------------------------------------------
-
-UINT32 tms3203x_device_config::disasm_max_opcode_bytes() const
-{
- return 4;
-}
-
-
-
-//**************************************************************************
// TMSREG REGISTER
//**************************************************************************
@@ -403,9 +266,10 @@ void tms3203x_device::tmsreg::from_double(double val)
// tms3203x_device - constructor
//-------------------------------------------------
-tms3203x_device::tms3203x_device(running_machine &_machine, const tms3203x_device_config &config)
- : cpu_device(_machine, config),
- m_config(config),
+tms3203x_device::tms3203x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 chiptype, address_map_constructor internal_map)
+ : cpu_device(mconfig, type, name, tag, owner, clock),
+ m_program_config("program", ENDIANNESS_LITTLE, 32, 24, -2, internal_map),
+ m_chip_type(chiptype),
m_pc(0),
m_bkmask(0),
m_irq_state(0),
@@ -418,6 +282,11 @@ tms3203x_device::tms3203x_device(running_machine &_machine, const tms3203x_devic
m_program(0),
m_direct(0)
{
+ m_bootoffset = 0;
+ m_xf0_w = NULL;
+ m_xf1_w = NULL;
+ m_iack_w = NULL;
+
// initialize remaining state
memset(&m_r, 0, sizeof(m_r));
@@ -429,11 +298,11 @@ tms3203x_device::tms3203x_device(running_machine &_machine, const tms3203x_devic
#endif
}
-tms32031_device::tms32031_device(running_machine &_machine, const tms32031_device_config &config)
- : tms3203x_device(_machine, config) { }
+tms32031_device::tms32031_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : tms3203x_device(mconfig, TMS32031, "TMS32031", tag, owner, clock, CHIP_TYPE_TMS32031, ADDRESS_MAP_NAME(internal_32031)) { }
-tms32032_device::tms32032_device(running_machine &_machine, const tms32032_device_config &config)
- : tms3203x_device(_machine, config) { }
+tms32032_device::tms32032_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : tms3203x_device(mconfig, TMS32032, "TMS32032", tag, owner, clock, CHIP_TYPE_TMS32032, ADDRESS_MAP_NAME(internal_32032)) { }
//-------------------------------------------------
@@ -451,6 +320,18 @@ tms3203x_device::~tms3203x_device()
//-------------------------------------------------
+// static_set_config - set the configuration
+// structure
+//-------------------------------------------------
+
+void tms3203x_device::static_set_config(device_t &device, const tms3203x_config &config)
+{
+ tms3203x_device &tms = downcast<tms3203x_device &>(device);
+ static_cast<tms3203x_config &>(tms) = config;
+}
+
+
+//-------------------------------------------------
// ROPCODE - fetch an opcode
//-------------------------------------------------
@@ -551,10 +432,10 @@ void tms3203x_device::device_start()
void tms3203x_device::device_reset()
{
// if we have a config struct, get the boot ROM address
- if (m_config.m_bootoffset != 0)
+ if (m_bootoffset != 0)
{
m_mcu_mode = true;
- m_pc = boot_loader(m_config.m_bootoffset);
+ m_pc = boot_loader(m_bootoffset);
}
else
{
@@ -574,6 +455,18 @@ void tms3203x_device::device_reset()
//-------------------------------------------------
+// memory_space_config - return the configuration
+// of the specified address space, or NULL if
+// the space doesn't exist
+//-------------------------------------------------
+
+const address_space_config *tms3203x_device::memory_space_config(address_spacenum spacenum) const
+{
+ return (spacenum == AS_PROGRAM) ? &m_program_config : NULL;
+}
+
+
+//-------------------------------------------------
// state_import - import state into the device,
// after it has been set
//-------------------------------------------------
@@ -664,6 +557,28 @@ void tms3203x_device::state_string_export(const device_state_entry &entry, astri
//-------------------------------------------------
+// disasm_min_opcode_bytes - return the length
+// of the shortest instruction, in bytes
+//-------------------------------------------------
+
+UINT32 tms3203x_device::disasm_min_opcode_bytes() const
+{
+ return 4;
+}
+
+
+//-------------------------------------------------
+// disasm_max_opcode_bytes - return the length
+// of the longest instruction, in bytes
+//-------------------------------------------------
+
+UINT32 tms3203x_device::disasm_max_opcode_bytes() const
+{
+ return 4;
+}
+
+
+//-------------------------------------------------
// disasm_disassemble - call the disassembly
// helper function
//-------------------------------------------------
@@ -766,7 +681,7 @@ void tms3203x_device::check_irqs()
// after auto-clearing the interrupt bit, we need to re-trigger
// level-sensitive interrupts
- if (m_config.m_chip_type == tms3203x_device_config::CHIP_TYPE_TMS32031 || (IREG(TMR_ST) & 0x4000) == 0)
+ if (m_chip_type == CHIP_TYPE_TMS32031 || (IREG(TMR_ST) & 0x4000) == 0)
IREG(TMR_IF) |= m_irq_state & 0x0f;
}
else
@@ -775,6 +690,39 @@ void tms3203x_device::check_irqs()
//-------------------------------------------------
+// execute_min_cycles - return minimum number of
+// cycles it takes for one instruction to execute
+//-------------------------------------------------
+
+UINT32 tms3203x_device::execute_min_cycles() const
+{
+ return 1;
+}
+
+
+//-------------------------------------------------
+// execute_max_cycles - return maximum number of
+// cycles it takes for one instruction to execute
+//-------------------------------------------------
+
+UINT32 tms3203x_device::execute_max_cycles() const
+{
+ return 4;
+}
+
+
+//-------------------------------------------------
+// execute_input_lines - return the number of
+// input/interrupt lines
+//-------------------------------------------------
+
+UINT32 tms3203x_device::execute_input_lines() const
+{
+ return 11;
+}
+
+
+//-------------------------------------------------
// execute_set_input - set input and IRQ lines
//-------------------------------------------------
@@ -797,7 +745,7 @@ void tms3203x_device::execute_set_input(int inputnum, int state)
// external interrupts are level-sensitive on the '31 and can be
// configured as such on the '32; in that case, if the external
// signal is high, we need to update the value in IF accordingly
- if (m_config.m_chip_type == tms3203x_device_config::CHIP_TYPE_TMS32031 || (IREG(TMR_ST) & 0x4000) == 0)
+ if (m_chip_type == CHIP_TYPE_TMS32031 || (IREG(TMR_ST) & 0x4000) == 0)
IREG(TMR_IF) |= m_irq_state & 0x0f;
}
diff --git a/src/emu/cpu/tms32031/tms32031.h b/src/emu/cpu/tms32031/tms32031.h
index 38c2ea277c0..d34a122b544 100644
--- a/src/emu/cpu/tms32031/tms32031.h
+++ b/src/emu/cpu/tms32031/tms32031.h
@@ -119,17 +119,7 @@ enum
//**************************************************************************
#define MCFG_TMS3203X_CONFIG(_config) \
- tms3203x_device_config::static_set_config(device, _config); \
-
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// device type definition
-extern const device_type TMS32031;
-extern const device_type TMS32032;
+ tms3203x_device::static_set_config(*device, _config); \
@@ -156,55 +146,11 @@ struct tms3203x_config
-// ======================> tms3203x_device_config
-
-class tms3203x_device_config : public cpu_device_config,
- public tms3203x_config
-{
- friend class tms3203x_device;
-
-protected:
- enum
- {
- CHIP_TYPE_TMS32031,
- CHIP_TYPE_TMS32032,
- };
-
- // construction/destruction
- tms3203x_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 chiptype, address_map_constructor internal_map);
-
-public:
- // inline configuration helpers
- static void static_set_config(device_config *device, const tms3203x_config &config);
-
-protected:
- // device_config_execute_interface overrides
- virtual UINT32 execute_min_cycles() const;
- virtual UINT32 execute_max_cycles() const;
- virtual UINT32 execute_input_lines() const;
-
- // device_config_memory_interface overrides
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
-
- // device_config_disasm_interface overrides
- virtual UINT32 disasm_min_opcode_bytes() const;
- virtual UINT32 disasm_max_opcode_bytes() const;
-
- // address spaces
- const address_space_config m_program_config;
-
- // internal state
- UINT32 m_chip_type;
-};
-
-
-
// ======================> tms3203x_device
-class tms3203x_device : public cpu_device
+class tms3203x_device : public cpu_device,
+ public tms3203x_config
{
- friend class tms3203x_device_config;
-
struct tmsreg
{
// constructors
@@ -230,11 +176,20 @@ class tms3203x_device : public cpu_device
};
protected:
+ enum
+ {
+ CHIP_TYPE_TMS32031,
+ CHIP_TYPE_TMS32032,
+ };
+
// construction/destruction
- tms3203x_device(running_machine &_machine, const tms3203x_device_config &config);
+ tms3203x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 chiptype, address_map_constructor internal_map);
virtual ~tms3203x_device();
public:
+ // inline configuration helpers
+ static void static_set_config(device_t &device, const tms3203x_config &config);
+
// public interfaces
static float fp_to_float(UINT32 floatdata);
static double fp_to_double(UINT32 floatdata);
@@ -247,15 +202,23 @@ protected:
virtual void device_reset();
// device_execute_interface overrides
+ virtual UINT32 execute_min_cycles() const;
+ virtual UINT32 execute_max_cycles() const;
+ virtual UINT32 execute_input_lines() const;
virtual void execute_run();
virtual void execute_set_input(int inputnum, int state);
+ // device_memory_interface overrides
+ virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
+
// device_state_interface overrides
virtual void state_import(const device_state_entry &entry);
virtual void state_export(const device_state_entry &entry);
virtual void state_string_export(const device_state_entry &entry, astring &string);
// device_disasm_interface overrides
+ virtual UINT32 disasm_min_opcode_bytes() const;
+ virtual UINT32 disasm_max_opcode_bytes() const;
virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
// memory helpers
@@ -816,7 +779,8 @@ protected:
void xor3sti(UINT32 op);
// configuration
- const tms3203x_device_config &m_config;
+ const address_space_config m_program_config;
+ UINT32 m_chip_type;
union int_double
{
@@ -855,60 +819,30 @@ protected:
};
-// ======================> tms32031_device_config
-
-class tms32031_device_config : public tms3203x_device_config
-{
- friend class tms32031_device;
-
- // construction/destruction
- tms32031_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
-
-public:
- // allocators
- static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
- virtual device_t *alloc_device(running_machine &machine) const;
-};
-
-
// ======================> tms32031_device
class tms32031_device : public tms3203x_device
{
- friend class tms32031_device_config;
-
+public:
// construction/destruction
- tms32031_device(running_machine &_machine, const tms32031_device_config &config);
+ tms32031_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
};
-// ======================> tms32032_device_config
+// ======================> tms32032_device
-class tms32032_device_config : public tms3203x_device_config
+class tms32032_device : public tms3203x_device
{
- friend class tms32032_device;
-
-protected:
- // construction/destruction
- tms32032_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
-
public:
- // allocators
- static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
- virtual device_t *alloc_device(running_machine &machine) const;
+ // construction/destruction
+ tms32032_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
};
-// ======================> tms32032_device
-
-class tms32032_device : public tms3203x_device
-{
- friend class tms32032_device_config;
+// device type definition
+extern const device_type TMS32031;
+extern const device_type TMS32032;
-protected:
- // construction/destruction
- tms32032_device(running_machine &_machine, const tms32032_device_config &config);
-};
#endif /* __TMS32031_H__ */