Previous 199869 Revisions Next

r29601 Sunday 13th April, 2014 at 13:12:39 UTC by Fabio Priuli
updated adc1038 to use delegates and inline configs. nw.
[src/emu/machine]adc1038.c adc1038.h
[src/mame/drivers]gticlub.c

trunk/src/mame/drivers/gticlub.c
r29600r29601
248248      m_dsp2(*this, "dsp2"),
249249      m_k056800(*this, "k056800"),
250250      m_adc1038(*this, "adc1038"),
251      m_analog0(*this, "AN0"),
252      m_analog1(*this, "AN1"),
253      m_analog2(*this, "AN2"),
254      m_analog3(*this, "AN3"),
251255      m_eeprom(*this, "eeprom"),
252256      m_palette(*this, "palette")  { }
253257
r29600r29601
261265   optional_device<cpu_device> m_dsp2;
262266   required_device<k056800_device> m_k056800;
263267   required_device<adc1038_device> m_adc1038;
268   required_ioport m_analog0, m_analog1, m_analog2, m_analog3;
264269   required_device<eeprom_serial_93cxx_device> m_eeprom;
265270   required_device<palette_device> m_palette;
266271
r29600r29601
293298   INTERRUPT_GEN_MEMBER(gticlub_vblank);
294299   TIMER_CALLBACK_MEMBER(sound_irq);
295300
301   ADC1038_INPUT_CB(adc1038_input_callback);
302
296303   UINT32 screen_update_gticlub(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
297304   UINT32 screen_update_hangplt(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
298305
r29600r29601
750757}
751758
752759
753static int adc1038_input_callback( device_t *device, int input )
760ADC1038_INPUT_CB(gticlub_state::adc1038_input_callback)
754761{
755762   int value = 0;
756763   switch (input)
757764   {
758   case 0: value = device->machine().root_device().ioport("AN0")->read(); break;
759   case 1: value = device->machine().root_device().ioport("AN1")->read(); break;
760   case 2: value = device->machine().root_device().ioport("AN2")->read(); break;
761   case 3: value = device->machine().root_device().ioport("AN3")->read(); break;
765   case 0: value = m_analog0->read(); break;
766   case 1: value = m_analog1->read(); break;
767   case 2: value = m_analog2->read(); break;
768   case 3: value = m_analog3->read(); break;
762769   case 4: value = 0x000; break;
763770   case 5: value = 0x000; break;
764771   case 6: value = 0x000; break;
r29600r29601
768775   return value;
769776}
770777
771static const adc1038_interface gticlub_adc1038_intf =
772{
773   1,
774   adc1038_input_callback
775};
776
777static const adc1038_interface thunderh_adc1038_intf =
778{
779   0,
780   adc1038_input_callback
781};
782
783
784778MACHINE_RESET_MEMBER(gticlub_state,gticlub)
785779{
786780   m_dsp->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
r29600r29601
926920   MCFG_MACHINE_START_OVERRIDE(gticlub_state,gticlub)
927921   MCFG_MACHINE_RESET_OVERRIDE(gticlub_state,gticlub)
928922
929   MCFG_ADC1038_ADD("adc1038", gticlub_adc1038_intf)
923   MCFG_DEVICE_ADD("adc1038", ADC1038, 0)
924   MCFG_ADC1038_INPUT_CB(gticlub_state, adc1038_input_callback)
925   MCFG_ADC1038_GTIHACK(1)
930926
931927   MCFG_DEVICE_ADD("k056230", K056230, 0)
932928   MCFG_K056230_CPU("maincpu")
r29600r29601
966962static MACHINE_CONFIG_DERIVED( thunderh, gticlub )
967963
968964   MCFG_DEVICE_REMOVE("adc1038")
969   MCFG_ADC1038_ADD("adc1038", thunderh_adc1038_intf)
965   MCFG_DEVICE_ADD("adc1038", ADC1038, 0)
966   MCFG_ADC1038_INPUT_CB(gticlub_state, adc1038_input_callback)
970967
971968   MCFG_DEVICE_REMOVE("k056230")
972969   MCFG_DEVICE_ADD("k056230", K056230, 0)
r29600r29601
977974static MACHINE_CONFIG_DERIVED( slrasslt, gticlub )
978975
979976   MCFG_DEVICE_REMOVE("adc1038")
980   MCFG_ADC1038_ADD("adc1038", thunderh_adc1038_intf)
977   MCFG_DEVICE_ADD("adc1038", ADC1038, 0)
978   MCFG_ADC1038_INPUT_CB(gticlub_state, adc1038_input_callback)
981979
982980   MCFG_DEVICE_REMOVE("k001604_1")
983981   MCFG_DEVICE_ADD("k001604_1", K001604, 0)
r29600r29601
10441042   MCFG_MACHINE_START_OVERRIDE(gticlub_state,gticlub)
10451043   MCFG_MACHINE_RESET_OVERRIDE(gticlub_state,hangplt)
10461044
1047   MCFG_ADC1038_ADD("adc1038", thunderh_adc1038_intf)
1045   MCFG_DEVICE_ADD("adc1038", ADC1038, 0)
1046   MCFG_ADC1038_INPUT_CB(gticlub_state, adc1038_input_callback)
10481047
10491048   MCFG_DEVICE_ADD("k056230", K056230, 0)
10501049   MCFG_K056230_CPU("maincpu")
trunk/src/emu/machine/adc1038.c
r29600r29601
1414const device_type ADC1038 = &device_creator<adc1038_device>;
1515
1616adc1038_device::adc1038_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
17   : device_t(mconfig, ADC1038, "ADC1038", tag, owner, clock, "adc1038", __FILE__)
17   : device_t(mconfig, ADC1038, "ADC1038", tag, owner, clock, "adc1038", __FILE__),
18      m_gticlub_hack(0)
1819{
1920}
2021
2122//-------------------------------------------------
22//  device_config_complete - perform any
23//  operations now that the configuration is
24//  complete
25//-------------------------------------------------
26
27void adc1038_device::device_config_complete()
28{
29   // inherit a copy of the static data
30   const adc1038_interface *intf = reinterpret_cast<const adc1038_interface *>(static_config());
31   if (intf != NULL)
32      *static_cast<adc1038_interface *>(this) = *intf;
33
34   // or initialize to defaults if none provided
35   else
36   {
37      input_callback_r = NULL;
38   }
39}
40
41//-------------------------------------------------
4223//  device_start - device-specific startup
4324//-------------------------------------------------
4425
4526void adc1038_device::device_start()
4627{
47   m_input_callback_r_func = input_callback_r;
28   m_input_cb.bind_relative_to(*owner());
4829
4930   save_item(NAME(m_cycle));
5031   save_item(NAME(m_clk));
r29600r29601
9879         m_cycle = 0;
9980
10081         /* notice that m_adr is always < 7! */
101         m_adc_data = m_input_callback_r_func(this, m_adr);
82         m_adc_data = m_input_cb(m_adr);
10283      }
10384   }
10485
r29600r29601
131112   m_cycle = 0;
132113
133114   /* notice that m_adr is always < 7! */
134   m_adc_data = m_input_callback_r_func(this, m_adr);
115   m_adc_data = m_input_cb(m_adr);
135116
136117   m_sars ^= 1;
137118   return m_sars;
trunk/src/emu/machine/adc1038.h
r29600r29601
1010#ifndef __ADC1038_H__
1111#define __ADC1038_H__
1212
13
14
1513/***************************************************************************
1614    TYPE DEFINITIONS
1715***************************************************************************/
1816
19typedef int (*adc1038_input_read_func)(device_t *device, int input);
17typedef device_delegate<int (int input)> adc1038_input_delegate;
18#define ADC1038_INPUT_CB(name)  int name(int input)
2019
21struct adc1038_interface
22{
23   int m_gticlub_hack;
24   adc1038_input_read_func input_callback_r;
25};
26
27
2820/***************************************************************************
2921    MACROS / CONSTANTS
3022***************************************************************************/
3123
32class adc1038_device : public device_t,
33                              public adc1038_interface
24class adc1038_device : public device_t
3425{
3526public:
3627   adc1038_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
3728   ~adc1038_device() {}
3829
30   static void set_input_callback(device_t &device, adc1038_input_delegate callback) { downcast<adc1038_device &>(device).m_input_cb = callback; }
31   static void set_gti_club_hack(device_t &device, int hack) { downcast<adc1038_device &>(device).m_gticlub_hack = hack; }
32
3933   DECLARE_READ_LINE_MEMBER( do_read );
4034   DECLARE_READ_LINE_MEMBER( sars_read );
4135   DECLARE_WRITE_LINE_MEMBER( di_write );
r29600r29601
4337
4438protected:
4539   // device-level overrides
46   virtual void device_config_complete();
4740   virtual void device_start();
4841   virtual void device_reset();
4942
50   adc1038_input_read_func           m_input_callback_r_func;
51
52   private:
43private:
5344   // internal state
5445   int m_cycle;
5546   int m_clk;
r29600r29601
5849   int m_data_out;
5950   int m_adc_data;
6051   int m_sars;
52   
53   int m_gticlub_hack;
54   adc1038_input_delegate       m_input_cb;
6155};
6256
6357extern const device_type ADC1038;
6458
6559
66#define MCFG_ADC1038_ADD(_tag, _config) \
67   MCFG_DEVICE_ADD(_tag, ADC1038, 0) \
68   MCFG_DEVICE_CONFIG(_config)
60#define MCFG_ADC1038_INPUT_CB(_class, _method) \
61   adc1038_device::set_input_callback(*device, adc1038_input_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
6962
63#define MCFG_ADC1038_GTIHACK(_hack) \
64   adc1038_device::set_gti_club_hack(*device, _hack);
7065
66
7167#endif  /* __ADC1038_H__ */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team