Previous 199869 Revisions Next

r29193 Wednesday 2nd April, 2014 at 17:27:11 UTC by Osso
ins8154_device: converted to devcb2 (nw)
[src/emu/machine]ins8154.c ins8154.h
[src/mame/drivers]vega.c
[src/mess/drivers]acrnsys1.c mk14.c

trunk/src/emu/machine/ins8154.c
r29192r29193
4444//-------------------------------------------------
4545
4646ins8154_device::ins8154_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
47   : device_t(mconfig, INS8154, "INS8154", tag, owner, clock, "ins8154", __FILE__)
47   : device_t(mconfig, INS8154, "INS8154", tag, owner, clock, "ins8154", __FILE__),
48   m_in_a_cb(*this),
49   m_out_a_cb(*this),
50   m_in_b_cb(*this),
51   m_out_b_cb(*this),
52   m_out_irq_cb(*this)
4853{
4954}
5055
51
5256//-------------------------------------------------
53//  device_config_complete - perform any
54//  operations now that the configuration is
55//  complete
56//-------------------------------------------------
57
58void ins8154_device::device_config_complete()
59{
60   // inherit a copy of the static data
61   const ins8154_interface *intf = reinterpret_cast<const ins8154_interface *>(static_config());
62   if (intf != NULL)
63   {
64      *static_cast<ins8154_interface *>(this) = *intf;
65   }
66
67   // or initialize to defaults if none provided
68   else
69   {
70      memset(&m_in_a_cb, 0, sizeof(m_in_a_cb));
71      memset(&m_in_b_cb, 0, sizeof(m_in_b_cb));
72      memset(&m_out_a_cb, 0, sizeof(m_out_a_cb));
73      memset(&m_out_b_cb, 0, sizeof(m_out_b_cb));
74      memset(&m_out_irq_cb, 0, sizeof(m_out_irq_cb));
75   }
76}
77
78
79//-------------------------------------------------
8057//  device_start - device-specific startup
8158//-------------------------------------------------
8259
8360void ins8154_device::device_start()
8461{
8562   /* resolve callbacks */
86   m_in_a_func.resolve(m_in_a_cb, *this);
87   m_out_a_func.resolve(m_out_a_cb, *this);
88   m_in_b_func.resolve(m_in_b_cb, *this);
89   m_out_b_func.resolve(m_out_b_cb, *this);
90   m_out_irq_func.resolve(m_out_irq_cb, *this);
63   m_in_a_cb.resolve();
64   m_out_a_cb.resolve_safe();
65   m_in_b_cb.resolve();
66   m_out_b_cb.resolve_safe();
67   m_out_irq_cb.resolve_safe();
9168
9269   /* register for state saving */
9370   save_item(NAME(m_in_a));
r29192r29193
132109   switch (offset)
133110   {
134111   case 0x20:
135      if(!m_in_a_func.isnull())
112      if(!m_in_a_cb.isnull())
136113      {
137         val = m_in_a_func(0);
114         val = m_in_a_cb(0);
138115      }
139116      m_in_a = val;
140117      break;
141118
142119   case 0x21:
143      if(!m_in_b_func.isnull())
120      if(!m_in_b_cb.isnull())
144121      {
145         val = m_in_b_func(0);
122         val = m_in_b_cb(0);
146123      }
147124      m_in_b = val;
148125      break;
r29192r29193
150127   default:
151128      if (offset < 0x08)
152129      {
153         if(!m_in_a_func.isnull())
130         if(!m_in_a_cb.isnull())
154131         {
155            val = (m_in_a_func(0) << (8 - offset)) & 0x80;
132            val = (m_in_a_cb(0) << (8 - offset)) & 0x80;
156133         }
157134         m_in_a = val;
158135      }
159136      else
160137      {
161         if(!m_in_b_func.isnull())
138         if(!m_in_b_cb.isnull())
162139         {
163            val = (m_in_b_func(0) << (8 - (offset >> 4))) & 0x80;
140            val = (m_in_b_cb(0) << (8 - (offset >> 4))) & 0x80;
164141         }
165142         m_in_b = val;
166143      }
r29192r29193
177154   /* Test if any pins are set as outputs */
178155   if (m_odra)
179156   {
180      m_out_a_func(0, (data & m_odra) | (m_odra ^ 0xff));
157      m_out_a_cb((offs_t)0, (data & m_odra) | (m_odra ^ 0xff));
181158   }
182159}
183160
r29192r29193
188165   /* Test if any pins are set as outputs */
189166   if (m_odrb)
190167   {
191      m_out_b_func(0, (data & m_odrb) | (m_odrb ^ 0xff));
168      m_out_b_cb((offs_t)0, (data & m_odrb) | (m_odrb ^ 0xff));
192169   }
193170}
194171
trunk/src/emu/machine/ins8154.h
r29192r29193
4444    DEVICE CONFIGURATION MACROS
4545***************************************************************************/
4646
47#define MCFG_INS8154_ADD(_tag, _intrf) \
48   MCFG_DEVICE_ADD(_tag, INS8154, 0) \
49   MCFG_DEVICE_CONFIG(_intrf)
47#define MCFG_INS8154_IN_A_CB(_devcb) \
48   devcb = &ins8154_device::set_in_a_callback(*device, DEVCB2_##_devcb);
49   
50#define MCFG_INS8154_OUT_A_CB(_devcb) \
51   devcb = &ins8154_device::set_out_a_callback(*device, DEVCB2_##_devcb);
52   
53#define MCFG_INS8154_IN_B_CB(_devcb) \
54   devcb = &ins8154_device::set_in_b_callback(*device, DEVCB2_##_devcb);
55   
56#define MCFG_INS8154_OUT_B_CB(_devcb) \
57   devcb = &ins8154_device::set_out_b_callback(*device, DEVCB2_##_devcb);
5058
59#define MCFG_INS8154_OUT_IRQ_CB(_devcb) \
60   devcb = &ins8154_device::set_out_irq_callback(*device, DEVCB2_##_devcb); //currently unused
5161
5262/***************************************************************************
5363    TYPE DEFINITIONS
5464***************************************************************************/
5565
56
57// ======================> ins8154_interface
58
59struct ins8154_interface
60{
61   devcb_read8         m_in_a_cb;
62   devcb_write8        m_out_a_cb;
63   devcb_read8         m_in_b_cb;
64   devcb_write8        m_out_b_cb;
65   devcb_write_line    m_out_irq_cb;
66};
67
68
69
7066// ======================> ins8154_device
7167
72class ins8154_device :  public device_t,
73                  public ins8154_interface
68class ins8154_device :  public device_t
7469{
7570public:
7671   // construction/destruction
7772   ins8154_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
7873
74   template<class _Object> static devcb2_base &set_in_a_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_in_a_cb.set_callback(object); }
75   template<class _Object> static devcb2_base &set_out_a_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_out_a_cb.set_callback(object); }
76   template<class _Object> static devcb2_base &set_in_b_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_in_b_cb.set_callback(object); }
77   template<class _Object> static devcb2_base &set_out_b_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_out_b_cb.set_callback(object); }
78   template<class _Object> static devcb2_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<ins8154_device &>(device).m_out_irq_cb.set_callback(object); }
79   
7980   DECLARE_READ8_MEMBER( ins8154_r );
8081   DECLARE_WRITE8_MEMBER( ins8154_w );
8182
r29192r29193
8485
8586protected:
8687   // device-level overrides
87   virtual void device_config_complete();
8888   virtual void device_start();
8989   virtual void device_reset();
9090   virtual void device_post_load() { }
r29192r29193
9393private:
9494
9595   /* i/o lines */
96   devcb_resolved_read8 m_in_a_func;
97   devcb_resolved_write8 m_out_a_func;
98   devcb_resolved_read8 m_in_b_func;
99   devcb_resolved_write8 m_out_b_func;
100   devcb_resolved_write_line m_out_irq_func;
96   devcb2_read8         m_in_a_cb;
97   devcb2_write8        m_out_a_cb;
98   devcb2_read8         m_in_b_cb;
99   devcb2_write8        m_out_b_cb;
100   devcb2_write_line    m_out_irq_cb;
101101
102102   /* registers */
103103   UINT8 m_in_a;  /* Input Latch Port A */
trunk/src/mess/drivers/mk14.c
r29192r29193
134134{
135135}
136136
137static const ins8154_interface mk14_ins8154 =
138{
139   DEVCB_NULL,
140   DEVCB_NULL,
141   DEVCB_NULL,
142   DEVCB_NULL,
143   DEVCB_NULL
144};
145
146137static MACHINE_CONFIG_START( mk14, mk14_state )
147138   /* basic machine hardware */
148139   // IC1 1SP-8A/600 (8060) SC/MP Microprocessor
r29192r29193
154145   MCFG_DEFAULT_LAYOUT(layout_mk14)
155146
156147   /* devices */
157   MCFG_INS8154_ADD("ic8", mk14_ins8154)
148   MCFG_DEVICE_ADD("ic8", INS8154, 0)
158149MACHINE_CONFIG_END
159150
160151/* ROM definition */
trunk/src/mess/drivers/acrnsys1.c
r29192r29193
233233    MACHINE DRIVERS
234234***************************************************************************/
235235
236static const ins8154_interface ins8154_b1 =
237{
238   DEVCB_DRIVER_MEMBER(acrnsys1_state, ins8154_b1_port_a_r),
239   DEVCB_DRIVER_MEMBER(acrnsys1_state, ins8154_b1_port_a_w),
240   DEVCB_NULL,
241   DEVCB_DRIVER_MEMBER(acrnsys1_state, acrnsys1_led_segment_w),
242   DEVCB_NULL
243};
244
245236static MACHINE_CONFIG_START( acrnsys1, acrnsys1_state )
246237   /* basic machine hardware */
247238   MCFG_CPU_ADD("maincpu", M6502, 1008000)  /* 1.008 MHz */
r29192r29193
255246   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
256247
257248   /* devices */
258   MCFG_INS8154_ADD("b1", ins8154_b1)
249   MCFG_DEVICE_ADD("b1", INS8154, 0)
250   MCFG_INS8154_IN_A_CB(READ8(acrnsys1_state, ins8154_b1_port_a_r))
251   MCFG_INS8154_OUT_A_CB(WRITE8(acrnsys1_state, ins8154_b1_port_a_w))
252   MCFG_INS8154_OUT_B_CB(WRITE8(acrnsys1_state, acrnsys1_led_segment_w))
259253   MCFG_DEVICE_ADD("ic8_7445", TTL74145, 0)
260254   MCFG_CASSETTE_ADD( "cassette", default_cassette_interface )
261255   MCFG_TIMER_DRIVER_ADD_PERIODIC("acrnsys1_c", acrnsys1_state, acrnsys1_c, attotime::from_hz(4800))
trunk/src/mame/drivers/vega.c
r29192r29193
807807};
808808
809809
810static const ins8154_interface ins8154_intf =
811{
812   DEVCB_DRIVER_MEMBER(vega_state, ins8154_pa_r),
813   DEVCB_DRIVER_MEMBER(vega_state, ins8154_pa_w),
814   DEVCB_DRIVER_MEMBER(vega_state, ins8154_pb_r),
815   DEVCB_DRIVER_MEMBER(vega_state, ins8154_pb_w),
816   DEVCB_NULL
817};
818
819
820810static const ay8910_interface ay8910_inf =
821811{
822812   AY8910_LEGACY_OUTPUT,
r29192r29193
843833
844834
845835   MCFG_I8255A_ADD( "ppi8255", ppi8255_intf )
846   MCFG_INS8154_ADD( "ins8154", ins8154_intf)
836   MCFG_DEVICE_ADD( "ins8154", INS8154, 0 )
837   MCFG_INS8154_IN_A_CB(READ8(vega_state, ins8154_pa_r))
838   MCFG_INS8154_OUT_A_CB(WRITE8(vega_state, ins8154_pa_w))
839   MCFG_INS8154_IN_B_CB(READ8(vega_state, ins8154_pb_r))
840   MCFG_INS8154_OUT_B_CB(WRITE8(vega_state, ins8154_pb_w))
847841
848842   /* video hardware */
849843   MCFG_SCREEN_ADD("screen", RASTER)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team