summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar Andrew Gardner <andrew-gardner@users.noreply.github.com>2013-06-08 16:15:23 +0000
committerGravatarGravatar Andrew Gardner <andrew-gardner@users.noreply.github.com>2013-06-08 16:15:23 +0000
commitf5ed8617bafaf23d752c207f2fa0dfcdc828048a (patch) (github)
tree152d41554225084c180ccac38fd6ddd44c63416e
parent9eafc98ed9992e5d2067b2cbfaa53dae582976c8 (diff)
downloadmame-f5ed8617bafaf23d752c207f2fa0dfcdc828048a.tar.bz2
mame-f5ed8617bafaf23d752c207f2fa0dfcdc828048a.zip
Modernize adc1038 and adc12138 devices. [Osso]
-rw-r--r--src/emu/machine/adc1038.c210
-rw-r--r--src/emu/machine/adc1038.h36
-rw-r--r--src/emu/machine/adc1213x.c314
-rw-r--r--src/emu/machine/adc1213x.h69
-rw-r--r--src/mame/drivers/gticlub.c22
-rw-r--r--src/mame/drivers/hornet.c33
-rw-r--r--src/mame/drivers/nwk-tr.c24
-rw-r--r--src/mame/includes/flower.h2
-rw-r--r--src/mame/machine/nmk112.h2
9 files changed, 302 insertions, 410 deletions
diff --git a/src/emu/machine/adc1038.c b/src/emu/machine/adc1038.c
index 05675c3de89..d40614343d3 100644
--- a/src/emu/machine/adc1038.c
+++ b/src/emu/machine/adc1038.c
@@ -10,185 +10,129 @@
#include "emu.h"
#include "adc1038.h"
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-struct adc1038_state
+const device_type ADC1038 = &device_creator<adc1038_device>;
+
+adc1038_device::adc1038_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, ADC1038, "A/D Converters 1038", tag, owner, clock)
{
- int cycle;
- int clk;
- int adr;
- int data_in;
- int data_out;
- int adc_data;
- int sars;
- adc1038_input_read_func input_callback_r;
-
- int gticlub_hack;
-};
+}
-/*****************************************************************************
- INLINE FUNCTIONS
-*****************************************************************************/
+//-------------------------------------------------
+// device_config_complete - perform any
+// operations now that the configuration is
+// complete
+//-------------------------------------------------
-INLINE adc1038_state *adc1038_get_safe_token( device_t *device )
+void adc1038_device::device_config_complete()
{
- assert(device != NULL);
- assert(device->type() == ADC1038);
+ // inherit a copy of the static data
+ const adc1038_interface *intf = reinterpret_cast<const adc1038_interface *>(static_config());
+ if (intf != NULL)
+ *static_cast<adc1038_interface *>(this) = *intf;
- return (adc1038_state *)downcast<adc1038_device *>(device)->token();
+ // or initialize to defaults if none provided
+ else
+ {
+ input_callback_r = NULL;
+ }
}
-INLINE const adc1038_interface *adc1038_get_interface( device_t *device )
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void adc1038_device::device_start()
+{
+ m_input_callback_r_func = input_callback_r;
+
+ save_item(NAME(m_cycle));
+ save_item(NAME(m_clk));
+ save_item(NAME(m_adr));
+ save_item(NAME(m_data_in));
+ save_item(NAME(m_data_out));
+ save_item(NAME(m_adc_data));
+ save_item(NAME(m_sars));
+}
+
+//-------------------------------------------------
+// device_reset - device-specific reset
+//-------------------------------------------------
+
+void adc1038_device::device_reset()
{
- assert(device != NULL);
- assert((device->type() == ADC1038));
- return (const adc1038_interface *) device->static_config();
+ m_cycle = 0;
+ m_clk = 0;
+ m_adr = 0;
+ m_data_in = 0;
+ m_data_out = 0;
+ m_adc_data = 0;
+ m_sars = 1;
}
/*****************************************************************************
DEVICE HANDLERS
*****************************************************************************/
-READ_LINE_DEVICE_HANDLER( adc1038_do_read )
+READ_LINE_MEMBER( adc1038_device::do_read )
{
- adc1038_state *adc1038 = adc1038_get_safe_token(device);
-
- adc1038->data_out = (adc1038->adc_data & 0x200) ? 1 : 0;
- adc1038->adc_data <<= 1;
+ m_data_out = (m_adc_data & 0x200) ? 1 : 0;
+ m_adc_data <<= 1;
//printf("ADC DO\n");
- return adc1038->data_out;
+ return m_data_out;
}
-WRITE_LINE_DEVICE_HANDLER( adc1038_di_write )
+WRITE_LINE_MEMBER( adc1038_device::di_write )
{
- adc1038_state *adc1038 = adc1038_get_safe_token(device);
-
- adc1038->data_in = state;
+ m_data_in = state;
}
-WRITE_LINE_DEVICE_HANDLER( adc1038_clk_write )
+WRITE_LINE_MEMBER( adc1038_device::clk_write )
{
- adc1038_state *adc1038 = adc1038_get_safe_token(device);
-
// GTI Club doesn't sync on SARS
- if (adc1038->gticlub_hack)
+ if (m_gticlub_hack)
{
- if (adc1038->clk == 0 && state == 0)
+ if (m_clk == 0 && state == 0)
{
- adc1038->cycle = 0;
+ m_cycle = 0;
- /* notice that adc1038->adr is always < 7! */
- adc1038->adc_data = adc1038->input_callback_r(device, adc1038->adr);
+ /* notice that m_adr is always < 7! */
+ m_adc_data = m_input_callback_r_func(this, m_adr);
}
}
if (state == 1)
{
- //printf("ADC CLK, DI = %d, cycle = %d\n", adc1038->data_in, adc1038->cycle);
+ //printf("ADC CLK, DI = %d, cycle = %d\n", m_data_in, m_cycle);
- if (adc1038->cycle == 0) // A2
+ if (m_cycle == 0) // A2
{
- adc1038->adr = 0;
- adc1038->adr |= (adc1038->data_in << 2);
+ m_adr = 0;
+ m_adr |= (m_data_in << 2);
}
- else if (adc1038->cycle == 1) // A1
+ else if (m_cycle == 1) // A1
{
- adc1038->adr |= (adc1038->data_in << 1);
+ m_adr |= (m_data_in << 1);
}
- else if (adc1038->cycle == 2) // A0
+ else if (m_cycle == 2) // A0
{
- adc1038->adr |= (adc1038->data_in << 0);
+ m_adr |= (m_data_in << 0);
}
- adc1038->cycle++;
+ m_cycle++;
}
- adc1038->clk = state;
+ m_clk = state;
}
-READ_LINE_DEVICE_HANDLER( adc1038_sars_read )
+READ_LINE_MEMBER( adc1038_device::sars_read )
{
- adc1038_state *adc1038 = adc1038_get_safe_token(device);
+ m_cycle = 0;
- adc1038->cycle = 0;
+ /* notice that m_adr is always < 7! */
+ m_adc_data = m_input_callback_r_func(this, m_adr);
- /* notice that adc1038->adr is always < 7! */
- adc1038->adc_data = adc1038->input_callback_r(device, adc1038->adr);
-
- adc1038->sars ^= 1;
- return adc1038->sars;
-}
-
-
-/*****************************************************************************
- DEVICE INTERFACE
-*****************************************************************************/
-
-static DEVICE_START( adc1038 )
-{
- adc1038_state *adc1038 = adc1038_get_safe_token(device);
- const adc1038_interface *intf = adc1038_get_interface(device);
-
- adc1038->gticlub_hack = intf->gticlub_hack;
- adc1038->input_callback_r = intf->input_callback_r;
-
- device->save_item(NAME(adc1038->cycle));
- device->save_item(NAME(adc1038->clk));
- device->save_item(NAME(adc1038->adr));
- device->save_item(NAME(adc1038->data_in));
- device->save_item(NAME(adc1038->data_out));
- device->save_item(NAME(adc1038->adc_data));
- device->save_item(NAME(adc1038->sars));
-}
-
-static DEVICE_RESET( adc1038 )
-{
- adc1038_state *adc1038 = adc1038_get_safe_token(device);
-
- adc1038->cycle = 0;
- adc1038->clk = 0;
- adc1038->adr = 0;
- adc1038->data_in = 0;
- adc1038->data_out = 0;
- adc1038->adc_data = 0;
- adc1038->sars = 1;
-}
-
-const device_type ADC1038 = &device_creator<adc1038_device>;
-
-adc1038_device::adc1038_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, ADC1038, "A/D Converters 1038", tag, owner, clock)
-{
- m_token = global_alloc_clear(adc1038_state);
-}
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void adc1038_device::device_config_complete()
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void adc1038_device::device_start()
-{
- DEVICE_START_NAME( adc1038 )(this);
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void adc1038_device::device_reset()
-{
- DEVICE_RESET_NAME( adc1038 )(this);
+ m_sars ^= 1;
+ return m_sars;
}
diff --git a/src/emu/machine/adc1038.h b/src/emu/machine/adc1038.h
index 931b323a071..06ab61e3e7a 100644
--- a/src/emu/machine/adc1038.h
+++ b/src/emu/machine/adc1038.h
@@ -21,7 +21,7 @@ typedef int (*adc1038_input_read_func)(device_t *device, int input);
struct adc1038_interface
{
- int gticlub_hack;
+ int m_gticlub_hack;
adc1038_input_read_func input_callback_r;
};
@@ -30,22 +30,35 @@ struct adc1038_interface
MACROS / CONSTANTS
***************************************************************************/
-class adc1038_device : public device_t
+class adc1038_device : public device_t,
+ public adc1038_interface
{
public:
adc1038_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~adc1038_device() { global_free(m_token); }
+ ~adc1038_device() {}
+
+ DECLARE_READ_LINE_MEMBER( do_read );
+ DECLARE_READ_LINE_MEMBER( sars_read );
+ DECLARE_WRITE_LINE_MEMBER( di_write );
+ DECLARE_WRITE_LINE_MEMBER( clk_write );
- // access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
virtual void device_reset();
-private:
+
+ adc1038_input_read_func m_input_callback_r_func;
+
+ private:
// internal state
- void *m_token;
+ int m_cycle;
+ int m_clk;
+ int m_adr;
+ int m_data_in;
+ int m_data_out;
+ int m_adc_data;
+ int m_sars;
};
extern const device_type ADC1038;
@@ -56,13 +69,4 @@ extern const device_type ADC1038;
MCFG_DEVICE_CONFIG(_config)
-/***************************************************************************
- DEVICE I/O FUNCTIONS
-***************************************************************************/
-
-extern READ_LINE_DEVICE_HANDLER( adc1038_do_read );
-extern READ_LINE_DEVICE_HANDLER( adc1038_sars_read );
-extern WRITE_LINE_DEVICE_HANDLER( adc1038_di_write );
-extern WRITE_LINE_DEVICE_HANDLER( adc1038_clk_write );
-
#endif /* __ADC1038_H__ */
diff --git a/src/emu/machine/adc1213x.c b/src/emu/machine/adc1213x.c
index a87ea7aa991..45476999023 100644
--- a/src/emu/machine/adc1213x.c
+++ b/src/emu/machine/adc1213x.c
@@ -20,25 +20,6 @@
TYPE DEFINITIONS
***************************************************************************/
-struct adc12138_state
-{
- adc1213x_input_convert_func input_callback_r;
-
- int cycle;
- int data_out;
- int data_in;
- int conv_mode;
- int auto_cal;
- int auto_zero;
- int acq_time;
- int data_out_sign;
- int mode;
- int input_shift_reg;
- int output_shift_reg;
- int end_conv;
-};
-
-
#define ADC1213X_CONV_MODE_12_MSB_FIRST 0
#define ADC1213X_CONV_MODE_16_MSB_FIRST 1
#define ADC1213X_CONV_MODE_12_LSB_FIRST 2
@@ -49,46 +30,111 @@ struct adc12138_state
#define ADC1213X_ACQUISITION_TIME_18_CCLK 2
#define ADC1213X_ACQUISITION_TIME_34_CCLK 3
-/***************************************************************************
- INLINE FUNCTIONS
-***************************************************************************/
-INLINE adc12138_state *get_safe_token(device_t *device)
+
+const device_type ADC12130 = &device_creator<adc12130_device>;
+
+adc12130_device::adc12130_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : adc12138_device(mconfig, ADC12130, "A/D Converter 12130", tag, owner, clock)
+{
+}
+
+
+const device_type ADC12132 = &device_creator<adc12132_device>;
+
+adc12132_device::adc12132_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : adc12138_device(mconfig, ADC12132, "A/D Converter 12132", tag, owner, clock)
+{
+}
+
+
+const device_type ADC12138 = &device_creator<adc12138_device>;
+
+adc12138_device::adc12138_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, ADC12138, "A/D Converter 12138", tag, owner, clock)
+{
+}
+adc12138_device::adc12138_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, type, name, tag, owner, clock)
+{
+}
+
+//-------------------------------------------------
+// device_config_complete - perform any
+// operations now that the configuration is
+// complete
+//-------------------------------------------------
+
+void adc12138_device::device_config_complete()
{
- assert(device != NULL);
- assert((device->type() == ADC12130) || (device->type() == ADC12132) || (device->type() == ADC12138));
- return (adc12138_state *)downcast<adc12138_device *>(device)->token();
+ // inherit a copy of the static data
+ const adc12138_interface *intf = reinterpret_cast<const adc12138_interface *>(static_config());
+ if (intf != NULL)
+ *static_cast<adc12138_interface *>(this) = *intf;
+
+ // or initialize to defaults if none provided
+ else
+ {
+ input_callback_r = NULL;
+ }
}
-INLINE const adc12138_interface *get_interface(device_t *device)
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void adc12138_device::device_start()
{
- assert(device != NULL);
- assert((device->type() == ADC12130) || (device->type() == ADC12132) || (device->type() == ADC12138));
- return (const adc12138_interface *) device->static_config();
+ /* resolve callbacks */
+ m_input_callback_r_func = input_callback_r;
+
+ /* register for state saving */
+ save_item(NAME(m_cycle));
+ save_item(NAME(m_data_out));
+ save_item(NAME(m_data_in));
+ save_item(NAME(m_conv_mode));
+ save_item(NAME(m_auto_cal));
+ save_item(NAME(m_auto_zero));
+ save_item(NAME(m_acq_time));
+ save_item(NAME(m_data_out_sign));
+ save_item(NAME(m_mode));
+ save_item(NAME(m_input_shift_reg));
+ save_item(NAME(m_output_shift_reg));
+ save_item(NAME(m_end_conv));
}
+//-------------------------------------------------
+// device_reset - device-specific reset
+//-------------------------------------------------
+
+void adc12138_device::device_reset()
+{
+ m_conv_mode = ADC1213X_CONV_MODE_12_MSB_FIRST;
+ m_data_out_sign = 1;
+ m_auto_cal = 0;
+ m_auto_zero = 0;
+ m_acq_time = ADC1213X_ACQUISITION_TIME_10_CCLK;
+}
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
/*-------------------------------------------------
- adc1213x_di_w
+ di_w
-------------------------------------------------*/
-WRITE8_DEVICE_HANDLER( adc1213x_di_w )
+WRITE8_MEMBER( adc12138_device::di_w )
{
- adc12138_state *adc1213x = get_safe_token(device);
- adc1213x->data_in = data & 1;
+ m_data_in = data & 1;
}
/*-------------------------------------------------
- adc1213x_convert
+ convert
-------------------------------------------------*/
-static void adc1213x_convert(device_t *device, int channel, int bits16, int lsbfirst)
+void adc12138_device::convert(int channel, int bits16, int lsbfirst)
{
- adc12138_state *adc1213x = get_safe_token(device);
int i;
int bits;
int input_value;
@@ -104,42 +150,42 @@ static void adc1213x_convert(device_t *device, int channel, int bits16, int lsbf
{
case 0x8: // H L L L - CH0 (single-ended)
{
- input = adc1213x->input_callback_r(device, 0);
+ input = m_input_callback_r_func(this, 0);
break;
}
case 0xc: // H H L L - CH1 (single-ended)
{
- input = adc1213x->input_callback_r(device, 1);
+ input = m_input_callback_r_func(this, 1);
break;
}
case 0x9: // H L L H - CH2 (single-ended)
{
- input = adc1213x->input_callback_r(device, 2);
+ input = m_input_callback_r_func(this, 2);
break;
}
case 0xd: // H H L H - CH3 (single-ended)
{
- input = adc1213x->input_callback_r(device, 3);
+ input = m_input_callback_r_func(this, 3);
break;
}
case 0xa: // H L H L - CH4 (single-ended)
{
- input = adc1213x->input_callback_r(device, 4);
+ input = m_input_callback_r_func(this, 4);
break;
}
case 0xe: // H H H L - CH5 (single-ended)
{
- input = adc1213x->input_callback_r(device, 5);
+ input = m_input_callback_r_func(this, 5);
break;
}
case 0xb: // H L H H - CH6 (single-ended)
{
- input = adc1213x->input_callback_r(device, 6);
+ input = m_input_callback_r_func(this, 6);
break;
}
case 0xf: // H H H H - CH7 (single-ended)
{
- input = adc1213x->input_callback_r(device, 7);
+ input = m_input_callback_r_func(this, 7);
break;
}
default:
@@ -153,62 +199,60 @@ static void adc1213x_convert(device_t *device, int channel, int bits16, int lsbf
bits = 12;
// sign-extend if needed
- if (adc1213x->data_out_sign)
+ if (m_data_out_sign)
{
input_value = input_value | ((input_value & 0x800) << 1);
bits++;
}
- adc1213x->output_shift_reg = 0;
+ m_output_shift_reg = 0;
for (i=0; i < bits; i++)
{
if (input_value & (1 << ((bits-1) - i)))
{
- adc1213x->output_shift_reg |= (1 << i);
+ m_output_shift_reg |= (1 << i);
}
}
- adc1213x->data_out = adc1213x->output_shift_reg & 1;
- adc1213x->output_shift_reg >>= 1;
+ m_data_out = m_output_shift_reg & 1;
+ m_output_shift_reg >>= 1;
}
/*-------------------------------------------------
- adc1213x_cs_w
+ cs_w
-------------------------------------------------*/
-WRITE8_DEVICE_HANDLER( adc1213x_cs_w )
+WRITE8_MEMBER( adc12138_device::cs_w )
{
- adc12138_state *adc1213x = get_safe_token(device);
-
if (data)
{
//printf("ADC: CS\n");
- if (adc1213x->cycle >= 7)
+ if (m_cycle >= 7)
{
- int mode = adc1213x->input_shift_reg >> (adc1213x->cycle - 8);
+ int mode = m_input_shift_reg >> (m_cycle - 8);
switch (mode & 0xf)
{
case 0x0: // X X X X L L L L - 12 or 13 Bit MSB First conversion
{
- adc1213x_convert(device, (mode >> 4) & 0xf, 0, 0);
+ convert((mode >> 4) & 0xf, 0, 0);
break;
}
case 0x1: // X X X X L L L H - 16 or 17 Bit MSB First conversion
{
- adc1213x_convert(device, (mode >> 4) & 0xf, 1, 0);
+ convert((mode >> 4) & 0xf, 1, 0);
break;
}
case 0x4: // X X X X L H L L - 12 or 13 Bit LSB First conversion
{
- adc1213x_convert(device, (mode >> 4) & 0xf, 0, 1);
+ convert((mode >> 4) & 0xf, 0, 1);
break;
}
case 0x5: // X X X X L H L H - 16 or 17 Bit LSB First conversion
{
- adc1213x_convert(device, (mode >> 4) & 0xf, 1, 1);
+ convert((mode >> 4) & 0xf, 1, 1);
break;
}
@@ -218,19 +262,19 @@ WRITE8_DEVICE_HANDLER( adc1213x_cs_w )
{
case 0x08: // L L L L H L L L - Auto cal
{
- adc1213x->auto_cal = 1;
+ m_auto_cal = 1;
break;
}
case 0x0e: // L L L L H H H L - Acquisition time 6 CCLK cycles
{
- adc1213x->acq_time = ADC1213X_ACQUISITION_TIME_6_CCLK;
+ m_acq_time = ADC1213X_ACQUISITION_TIME_6_CCLK;
break;
}
case 0x8d: // H L L L H H L H - Data out with sign
{
- adc1213x->data_out_sign = 1;
+ m_data_out_sign = 1;
break;
}
@@ -249,163 +293,57 @@ WRITE8_DEVICE_HANDLER( adc1213x_cs_w )
}
}
- adc1213x->cycle = 0;
- adc1213x->input_shift_reg = 0;
+ m_cycle = 0;
+ m_input_shift_reg = 0;
- adc1213x->end_conv = 0;
+ m_end_conv = 0;
}
}
/*-------------------------------------------------
- adc1213x_sclk_w
+ sclk_w
-------------------------------------------------*/
-WRITE8_DEVICE_HANDLER( adc1213x_sclk_w )
+WRITE8_MEMBER( adc12138_device::sclk_w )
{
- adc12138_state *adc1213x = get_safe_token(device);
-
if (data)
{
//printf("ADC: cycle %d, DI = %d\n", adc1213x->cycle, adc1213x->data_in);
- adc1213x->input_shift_reg <<= 1;
- adc1213x->input_shift_reg |= adc1213x->data_in;
+ m_input_shift_reg <<= 1;
+ m_input_shift_reg |= m_data_in;
- adc1213x->data_out = adc1213x->output_shift_reg & 1;
- adc1213x->output_shift_reg >>= 1;
+ m_data_out = m_output_shift_reg & 1;
+ m_output_shift_reg >>= 1;
- adc1213x->cycle++;
+ m_cycle++;
}
}
/*-------------------------------------------------
- adc1213x_conv_w
+ conv_w
-------------------------------------------------*/
-WRITE8_DEVICE_HANDLER( adc1213x_conv_w )
+WRITE8_MEMBER( adc12138_device::conv_w )
{
- adc12138_state *adc1213x = get_safe_token(device);
- adc1213x->end_conv = 1;
+ m_end_conv = 1;
}
/*-------------------------------------------------
- adc1213x_do_r
+ do_r
-------------------------------------------------*/
-READ8_DEVICE_HANDLER( adc1213x_do_r )
+READ8_MEMBER( adc12138_device::do_r )
{
- adc12138_state *adc1213x = get_safe_token(device);
-
//printf("ADC: DO\n");
- return adc1213x->data_out;
-}
-
-/*-------------------------------------------------
- adc1213x_eoc_r
--------------------------------------------------*/
-
-READ8_DEVICE_HANDLER( adc1213x_eoc_r )
-{
- adc12138_state *adc1213x = get_safe_token(device);
- return adc1213x->end_conv;
+ return m_data_out;
}
/*-------------------------------------------------
- DEVICE_START( adc1213x )
+ eoc_r
-------------------------------------------------*/
-static DEVICE_START( adc12138 )
-{
- adc12138_state *adc1213x = get_safe_token(device);
- const adc12138_interface *intf = get_interface(device);
-
- /* resolve callbacks */
- adc1213x->input_callback_r = intf->input_callback_r;
-
- /* register for state saving */
- device->save_item(NAME(adc1213x->cycle));
- device->save_item(NAME(adc1213x->data_out));
- device->save_item(NAME(adc1213x->data_in));
- device->save_item(NAME(adc1213x->conv_mode));
- device->save_item(NAME(adc1213x->auto_cal));
- device->save_item(NAME(adc1213x->auto_zero));
- device->save_item(NAME(adc1213x->acq_time));
- device->save_item(NAME(adc1213x->data_out_sign));
- device->save_item(NAME(adc1213x->mode));
- device->save_item(NAME(adc1213x->input_shift_reg));
- device->save_item(NAME(adc1213x->output_shift_reg));
- device->save_item(NAME(adc1213x->end_conv));
-}
-
-
-/*-------------------------------------------------
- DEVICE_RESET( adc1213x )
--------------------------------------------------*/
-
-static DEVICE_RESET( adc12138 )
-{
- adc12138_state *adc1213x = get_safe_token(device);
-
- adc1213x->conv_mode = ADC1213X_CONV_MODE_12_MSB_FIRST;
- adc1213x->data_out_sign = 1;
- adc1213x->auto_cal = 0;
- adc1213x->auto_zero = 0;
- adc1213x->acq_time = ADC1213X_ACQUISITION_TIME_10_CCLK;
-}
-
-const device_type ADC12130 = &device_creator<adc12130_device>;
-
-adc12130_device::adc12130_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : adc12138_device(mconfig, ADC12130, "A/D Converter 12130", tag, owner, clock)
-{
-}
-
-
-const device_type ADC12132 = &device_creator<adc12132_device>;
-
-adc12132_device::adc12132_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : adc12138_device(mconfig, ADC12132, "A/D Converter 12132", tag, owner, clock)
-{
-}
-
-
-const device_type ADC12138 = &device_creator<adc12138_device>;
-
-adc12138_device::adc12138_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, ADC12138, "A/D Converter 12138", tag, owner, clock)
-{
- m_token = global_alloc_clear(adc12138_state);
-}
-adc12138_device::adc12138_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, type, name, tag, owner, clock)
-{
- m_token = global_alloc_clear(adc12138_state);
-}
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void adc12138_device::device_config_complete()
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void adc12138_device::device_start()
-{
- DEVICE_START_NAME( adc12138 )(this);
-}
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void adc12138_device::device_reset()
+READ8_MEMBER( adc12138_device::eoc_r )
{
- DEVICE_RESET_NAME( adc12138 )(this);
+ return m_end_conv;
}
diff --git a/src/emu/machine/adc1213x.h b/src/emu/machine/adc1213x.h
index bb12cddaca7..aa2209884fa 100644
--- a/src/emu/machine/adc1213x.h
+++ b/src/emu/machine/adc1213x.h
@@ -10,30 +10,61 @@
#ifndef __ADC1213X_H__
#define __ADC1213X_H__
-#include "devlegcy.h"
+/***************************************************************************
+ TYPE DEFINITIONS
+***************************************************************************/
+
+typedef double (*adc1213x_input_convert_func)(device_t *device, UINT8 input);
+
+struct adc12138_interface
+{
+ adc1213x_input_convert_func input_callback_r;
+};
/***************************************************************************
MACROS / CONSTANTS
***************************************************************************/
-class adc12138_device : public device_t
+class adc12138_device : public device_t,
+ public adc12138_interface
{
public:
adc12138_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
adc12138_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
- ~adc12138_device() { global_free(m_token); }
-
- // access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
+ ~adc12138_device() {}
+
+ DECLARE_WRITE8_MEMBER( di_w );
+ DECLARE_WRITE8_MEMBER( cs_w );
+ DECLARE_WRITE8_MEMBER( sclk_w );
+ DECLARE_WRITE8_MEMBER( conv_w );
+ DECLARE_READ8_MEMBER( do_r );
+ DECLARE_READ8_MEMBER( eoc_r );
+
protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
virtual void device_reset();
-private:
+
+ void convert(int channel, int bits16, int lsbfirst);
+
+ adc1213x_input_convert_func m_input_callback_r_func;
+
+ private:
// internal state
- void *m_token;
+ int m_cycle;
+ int m_data_out;
+ int m_data_in;
+ int m_conv_mode;
+ int m_auto_cal;
+ int m_auto_zero;
+ int m_acq_time;
+ int m_data_out_sign;
+ int m_mode;
+ int m_input_shift_reg;
+ int m_output_shift_reg;
+ int m_end_conv;
};
extern const device_type ADC12138;
@@ -67,26 +98,4 @@ extern const device_type ADC12132;
MCFG_DEVICE_CONFIG(_config)
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-typedef double (*adc1213x_input_convert_func)(device_t *device, UINT8 input);
-
-struct adc12138_interface
-{
- adc1213x_input_convert_func input_callback_r;
-};
-
-/***************************************************************************
- PROTOTYPES
-***************************************************************************/
-
-extern DECLARE_WRITE8_DEVICE_HANDLER( adc1213x_di_w );
-extern DECLARE_WRITE8_DEVICE_HANDLER( adc1213x_cs_w );
-extern DECLARE_WRITE8_DEVICE_HANDLER( adc1213x_sclk_w );
-extern DECLARE_WRITE8_DEVICE_HANDLER( adc1213x_conv_w );
-extern DECLARE_READ8_DEVICE_HANDLER( adc1213x_do_r );
-extern DECLARE_READ8_DEVICE_HANDLER( adc1213x_eoc_r );
-
#endif /* __ADC1213X_H__ */
diff --git a/src/mame/drivers/gticlub.c b/src/mame/drivers/gticlub.c
index cf1b9ad86e7..2310af04b82 100644
--- a/src/mame/drivers/gticlub.c
+++ b/src/mame/drivers/gticlub.c
@@ -250,9 +250,16 @@ public:
m_audiocpu(*this, "audiocpu"),
m_dsp(*this, "dsp"),
m_dsp2(*this, "dsp2"),
+ m_adc1038(*this, "adc1038"),
m_eeprom(*this, "eeprom") { }
required_shared_ptr<UINT32> m_work_ram;
+ required_device<cpu_device> m_maincpu;
+ required_device<cpu_device> m_audiocpu;
+ required_device<cpu_device> m_dsp;
+ optional_device<cpu_device> m_dsp2;
+ required_device<adc1038_device> m_adc1038;
+ required_device<eeprom_device> m_eeprom;
UINT32 *m_sharc_dataram_0;
UINT32 *m_sharc_dataram_1;
DECLARE_WRITE32_MEMBER(paletteram32_w);
@@ -278,11 +285,6 @@ public:
DECLARE_MACHINE_RESET(gticlub);
DECLARE_MACHINE_RESET(hangplt);
INTERRUPT_GEN_MEMBER(gticlub_vblank);
- required_device<cpu_device> m_maincpu;
- required_device<cpu_device> m_audiocpu;
- required_device<cpu_device> m_dsp;
- optional_device<cpu_device> m_dsp2;
- required_device<eeprom_device> m_eeprom;
protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
@@ -363,7 +365,6 @@ static const eeprom_interface eeprom_intf =
READ8_MEMBER(gticlub_state::sysreg_r)
{
static const char *const portnames[] = { "IN0", "IN1", "IN2", "IN3" };
- device_t *adc1038 = machine().device("adc1038");
switch (offset)
{
case 0:
@@ -372,7 +373,7 @@ READ8_MEMBER(gticlub_state::sysreg_r)
return ioport(portnames[offset])->read();
case 2:
- return adc1038_sars_read(adc1038) << 7;
+ return m_adc1038->sars_read() << 7;
case 4:
{
@@ -383,7 +384,7 @@ READ8_MEMBER(gticlub_state::sysreg_r)
// e = EEPROM data out
UINT32 eeprom_bit = (m_eeprom->read_bit() << 1);
- UINT32 adc_bit = (adc1038_do_read(adc1038) << 2);
+ UINT32 adc_bit = (m_adc1038->do_read() << 2);
return (eeprom_bit | adc_bit);
}
@@ -396,7 +397,6 @@ READ8_MEMBER(gticlub_state::sysreg_r)
WRITE8_MEMBER(gticlub_state::sysreg_w)
{
- device_t *adc1038 = machine().device("adc1038");
switch (offset)
{
case 0:
@@ -417,8 +417,8 @@ WRITE8_MEMBER(gticlub_state::sysreg_w)
if (data & 0x40) /* CG Board 0 IRQ Ack */
m_maincpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE);
- adc1038_di_write(adc1038, (data >> 0) & 1);
- adc1038_clk_write(adc1038, (data >> 1) & 1);
+ m_adc1038->di_write((data >> 0) & 1);
+ m_adc1038->clk_write((data >> 1) & 1);
set_cgboard_id((data >> 4) & 0x3);
break;
diff --git a/src/mame/drivers/hornet.c b/src/mame/drivers/hornet.c
index 9c94121b4fb..27cf26c50af 100644
--- a/src/mame/drivers/hornet.c
+++ b/src/mame/drivers/hornet.c
@@ -339,13 +339,23 @@ public:
m_dsp2(*this, "dsp2"),
m_eeprom(*this, "eeprom"),
m_k037122_1(*this, "k037122_1"),
- m_k037122_2(*this, "k037122_2" ) { }
+ m_k037122_2(*this, "k037122_2" ),
+ m_adc12138(*this, "adc12138") { }
UINT8 m_led_reg0;
UINT8 m_led_reg1;
required_shared_ptr<UINT32> m_workram;
required_shared_ptr<UINT32> m_sharc_dataram0;
optional_shared_ptr<UINT32> m_sharc_dataram1;
+ required_device<cpu_device> m_maincpu;
+ required_device<cpu_device> m_audiocpu;
+ optional_device<cpu_device> m_gn680;
+ required_device<cpu_device> m_dsp;
+ optional_device<cpu_device> m_dsp2;
+ required_device<eeprom_device> m_eeprom;
+ optional_device<k037122_device> m_k037122_1;
+ optional_device<k037122_device> m_k037122_2;
+ required_device<adc12138_device> m_adc12138;
UINT8 *m_jvs_sdata;
UINT32 m_jvs_sdata_ptr;
emu_timer *m_sound_irq_timer;
@@ -385,14 +395,6 @@ public:
int jvs_encode_data(UINT8 *in, int length);
int jvs_decode_data(UINT8 *in, UINT8 *out, int length);
void jamma_jvs_cmd_exec();
- required_device<cpu_device> m_maincpu;
- required_device<cpu_device> m_audiocpu;
- optional_device<cpu_device> m_gn680;
- required_device<cpu_device> m_dsp;
- optional_device<cpu_device> m_dsp2;
- required_device<eeprom_device> m_eeprom;
- optional_device<k037122_device> m_k037122_1;
- optional_device<k037122_device> m_k037122_2;
};
@@ -487,7 +489,6 @@ READ8_MEMBER(hornet_state::sysreg_r)
{
UINT8 r = 0;
static const char *const portnames[] = { "IN0", "IN1", "IN2" };
- device_t *adc12138 = machine().device("adc12138");
switch (offset)
{
case 0: /* I/O port 0 */
@@ -507,7 +508,7 @@ READ8_MEMBER(hornet_state::sysreg_r)
0x01 = ADDO (ADC DO)
*/
r = 0xf0 | (m_eeprom->read_bit() << 3);
- r |= adc1213x_do_r(adc12138, space, 0) | (adc1213x_eoc_r(adc12138, space, 0) << 2);
+ r |= m_adc12138->do_r(space, 0) | (m_adc12138->eoc_r(space, 0) << 2);
break;
case 4: /* I/O port 4 - DIP switches */
@@ -519,8 +520,6 @@ READ8_MEMBER(hornet_state::sysreg_r)
WRITE8_MEMBER(hornet_state::sysreg_w)
{
- device_t *adc12138 = machine().device("adc12138");
-
switch (offset)
{
case 0: /* LED Register 0 */
@@ -561,10 +560,10 @@ WRITE8_MEMBER(hornet_state::sysreg_w)
0x02 = ADDI (ADC DI)
0x01 = ADDSCLK (ADC SCLK)
*/
- adc1213x_cs_w(adc12138, space, 0, (data >> 3) & 0x1);
- adc1213x_conv_w(adc12138, space, 0, (data >> 2) & 0x1);
- adc1213x_di_w(adc12138, space, 0, (data >> 1) & 0x1);
- adc1213x_sclk_w(adc12138, space, 0, data & 0x1);
+ m_adc12138->cs_w(space, 0, (data >> 3) & 0x1);
+ m_adc12138->conv_w(space, 0, (data >> 2) & 0x1);
+ m_adc12138->di_w(space, 0, (data >> 1) & 0x1);
+ m_adc12138->sclk_w(space, 0, data & 0x1);
m_audiocpu->set_input_line(INPUT_LINE_RESET, (data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
mame_printf_debug("System register 1 = %02X\n", data);
diff --git a/src/mame/drivers/nwk-tr.c b/src/mame/drivers/nwk-tr.c
index 1cadd067891..83eea8ecc52 100644
--- a/src/mame/drivers/nwk-tr.c
+++ b/src/mame/drivers/nwk-tr.c
@@ -235,11 +235,17 @@ public:
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_dsp(*this, "dsp"),
- m_k001604(*this, "k001604") { }
+ m_k001604(*this, "k001604"),
+ m_adc12138(*this, "adc12138") { }
UINT8 m_led_reg0;
UINT8 m_led_reg1;
required_shared_ptr<UINT32> m_work_ram;
+ required_device<cpu_device> m_maincpu;
+ required_device<cpu_device> m_audiocpu;
+ required_device<cpu_device> m_dsp;
+ required_device<k001604_device> m_k001604;
+ required_device<adc12138_device> m_adc12138;
emu_timer *m_sound_irq_timer;
int m_fpga_uploaded;
int m_lanc2_ram_r;
@@ -262,10 +268,6 @@ public:
UINT32 screen_update_nwktr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
TIMER_CALLBACK_MEMBER(irq_off);
void lanc2_init();
- required_device<cpu_device> m_maincpu;
- required_device<cpu_device> m_audiocpu;
- required_device<cpu_device> m_dsp;
- required_device<k001604_device> m_k001604;
};
@@ -307,7 +309,6 @@ UINT32 nwktr_state::screen_update_nwktr(screen_device &screen, bitmap_rgb32 &bit
READ32_MEMBER(nwktr_state::sysreg_r)
{
- device_t *adc12138 = machine().device("adc12138");
UINT32 r = 0;
if (offset == 0)
{
@@ -325,7 +326,7 @@ READ32_MEMBER(nwktr_state::sysreg_r)
}
if (ACCESSING_BITS_0_7)
{
- r |= adc1213x_do_r(adc12138, space, 0) | (adc1213x_eoc_r(adc12138, space, 0) << 2);
+ r |= m_adc12138->do_r(space, 0) | (m_adc12138->eoc_r(space, 0) << 2);
}
}
else if (offset == 1)
@@ -340,7 +341,6 @@ READ32_MEMBER(nwktr_state::sysreg_r)
WRITE32_MEMBER(nwktr_state::sysreg_w)
{
- device_t *adc12138 = machine().device("adc12138");
if( offset == 0 )
{
if (ACCESSING_BITS_24_31)
@@ -362,10 +362,10 @@ WRITE32_MEMBER(nwktr_state::sysreg_w)
int di = (data >> 25) & 0x1;
int sclk = (data >> 24) & 0x1;
- adc1213x_cs_w(adc12138, space, 0, cs);
- adc1213x_conv_w(adc12138, space, 0, conv);
- adc1213x_di_w(adc12138, space, 0, di);
- adc1213x_sclk_w(adc12138, space, 0, sclk);
+ m_adc12138->cs_w(space, 0, cs);
+ m_adc12138->conv_w(space, 0, conv);
+ m_adc12138->di_w(space, 0, di);
+ m_adc12138->sclk_w(space, 0, sclk);
}
if (ACCESSING_BITS_0_7)
{
diff --git a/src/mame/includes/flower.h b/src/mame/includes/flower.h
index 1f3334b8d41..6b636a5b765 100644
--- a/src/mame/includes/flower.h
+++ b/src/mame/includes/flower.h
@@ -49,7 +49,7 @@ public:
};
-// ======================> gomoku_sound_device
+// ======================> flower_sound_device
/* this structure defines the parameters for a channel */
diff --git a/src/mame/machine/nmk112.h b/src/mame/machine/nmk112.h
index 00fd4508b79..ee19919c2ed 100644
--- a/src/mame/machine/nmk112.h
+++ b/src/mame/machine/nmk112.h
@@ -7,8 +7,6 @@
#ifndef __NMK112_H__
#define __NMK112_H__
-#include "devlegcy.h"
-
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/