Previous 199869 Revisions Next

r29591 Sunday 13th April, 2014 at 07:31:12 UTC by Fabio Priuli
f3853: converted to use delegates. nw.
[src/emu/machine]f3853.c f3853.h
[src/mess/drivers]mk1.c vidbrain.c
[src/mess/includes]vidbrain.h

trunk/src/emu/machine/f3853.c
r29590r29591
5252{
5353}
5454
55
5655//-------------------------------------------------
57//  device_config_complete - perform any
58//  operations now that the configuration is
59//  complete
60//-------------------------------------------------
61
62void f3853_device::device_config_complete()
63{
64   // inherit a copy of the static data
65   const f3853_interface *intf = reinterpret_cast<const f3853_interface *>(static_config());
66   if (intf != NULL)
67   {
68      *static_cast<f3853_interface *>(this) = *intf;
69   }
70
71   // or initialize to defaults if none provided
72   else
73   {
74      memset(&m_interrupt_request, 0, sizeof(m_interrupt_request));
75   }
76}
77
78
79//-------------------------------------------------
8056//  device_start - device-specific startup
8157//-------------------------------------------------
8258
r29590r29591
9167      INT32 o3 = (reg & 0x08) ? TRUE : FALSE;
9268      m_value_to_cycle[reg] = i;
9369      reg <<= 1;
94      if(!((o7 != o5) != (o4 != o3)))
70      if (!((o7 != o5) != (o4 != o3)))
9571      {
9672         reg |= 1;
9773      }
r29590r29591
127103}
128104
129105
130void f3853_device::f3853_set_interrupt_request_line()
106void f3853_device::set_interrupt_request_line()
131107{
132   if(!m_interrupt_request)
133   {
108   if (m_interrupt_req_cb.isnull())
134109      return;
135   }
136110
137   if(m_external_enable && !m_priority_line)
138   {
139      m_interrupt_request(this, INTERRUPT_VECTOR(TRUE), TRUE);
140   }
141   else if( m_timer_enable && !m_priority_line && m_request_flipflop)
142   {
143      m_interrupt_request(this, INTERRUPT_VECTOR(FALSE), TRUE);
144   }
111   if (m_external_enable && !m_priority_line)
112      m_interrupt_req_cb(INTERRUPT_VECTOR(TRUE), TRUE);
113   else if (m_timer_enable && !m_priority_line && m_request_flipflop)
114      m_interrupt_req_cb(INTERRUPT_VECTOR(FALSE), TRUE);
145115   else
146   {
147      m_interrupt_request(this, 0, FALSE);
148   }
116      m_interrupt_req_cb(0, FALSE);
149117}
150118
151119
152void f3853_device::f3853_timer_start(UINT8 value)
120void f3853_device::timer_start(UINT8 value)
153121{
154122   attotime period = (value != 0xff) ? attotime::from_hz(clock()) * (m_value_to_cycle[value]*31) : attotime::never;
155123
r29590r29591
159127
160128TIMER_CALLBACK( f3853_device::f3853_timer_callback )
161129{
162   reinterpret_cast<f3853_device*>(ptr)->f3853_timer();
130   reinterpret_cast<f3853_device*>(ptr)->timer();
163131}
164132
165void f3853_device::f3853_timer()
133void f3853_device::timer()
166134{
167135   if(m_timer_enable)
168136   {
169137      m_request_flipflop = TRUE;
170      f3853_set_interrupt_request_line();
138      set_interrupt_request_line();
171139   }
172   f3853_timer_start(0xfe);
140   timer_start(0xfe);
173141}
174142
175void f3853_device::f3853_set_external_interrupt_in_line(int level)
143void f3853_device::set_external_interrupt_in_line(int level)
176144{
177145   if(m_external_interrupt_line && !level && m_external_enable)
178146   {
179147      m_request_flipflop = TRUE;
180148   }
181149   m_external_interrupt_line = level;
182   f3853_set_interrupt_request_line();
150   set_interrupt_request_line();
183151}
184152
185void f3853_device::f3853_set_priority_in_line(int level)
153void f3853_device::set_priority_in_line(int level)
186154{
187155   m_priority_line = level;
188   f3853_set_interrupt_request_line();
156   set_interrupt_request_line();
189157}
190158
191159
192READ8_MEMBER(f3853_device::f3853_r)
160READ8_MEMBER(f3853_device::read)
193161{
194162   UINT8 data = 0;
195163
r29590r29591
212180}
213181
214182
215WRITE8_MEMBER(f3853_device::f3853_w)
183WRITE8_MEMBER(f3853_device::write)
216184{
217185   switch(offset)
218186   {
r29590r29591
227195   case 2: //interrupt control
228196      m_external_enable = ((data & 3) == 1);
229197      m_timer_enable = ((data & 3) == 3);
230      f3853_set_interrupt_request_line();
198      set_interrupt_request_line();
231199      break;
232200
233201   case 3: //timer
234202      m_request_flipflop = FALSE;
235      f3853_set_interrupt_request_line();
236      f3853_timer_start(data);
203      set_interrupt_request_line();
204      timer_start(data);
237205      break;
238206   }
239207}
trunk/src/emu/machine/f3853.h
r29590r29591
3838
3939#include "emu.h"
4040
41
42
43
4441//**************************************************************************
4542//  INTERFACE CONFIGURATION MACROS
4643//**************************************************************************
4744
48#define MCFG_F3853_ADD(_tag, _clock, _intrf) \
49   MCFG_DEVICE_ADD(_tag, F3853, _clock) \
50   MCFG_DEVICE_CONFIG(_intrf)
45#define MCFG_F3853_EXT_INPUT_CB(_class, _method) \
46   f3853_device::set_interrupt_req_callback(*device, f3853_interrupt_req_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
5147
52
53
5448/***************************************************************************
5549    TYPE DEFINITIONS
5650***************************************************************************/
5751
52typedef device_delegate<void (UINT16 addr, int level)> f3853_interrupt_req_delegate;
5853
59// ======================> f3853_interface
54#define F3853_INTERRUPT_REQ_CB(_name) void _name(UINT16 addr, int level)
6055
61struct f3853_interface
62{
63   void (*m_interrupt_request)(device_t *device, UINT16 addr, int level);
64};
6556
66
6757// ======================> f3853_device
6858
69class f3853_device :  public device_t,
70                  public f3853_interface
59class f3853_device :  public device_t
7160{
7261public:
7362   // construction/destruction
7463   f3853_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
7564
76   DECLARE_READ8_MEMBER( f3853_r );
77   DECLARE_WRITE8_MEMBER( f3853_w );
65   static void set_interrupt_req_callback(device_t &device, f3853_interrupt_req_delegate callback) { downcast<f3853_device &>(device).m_interrupt_req_cb = callback; }
7866
79   void f3853_set_external_interrupt_in_line(int level);
80   void f3853_set_priority_in_line(int level);
67   DECLARE_READ8_MEMBER(read);
68   DECLARE_WRITE8_MEMBER(write);
8169
70   void set_external_interrupt_in_line(int level);
71   void set_priority_in_line(int level);
72
8273protected:
8374   // device-level overrides
84   virtual void device_config_complete();
8575   virtual void device_start();
8676   virtual void device_reset();
8777   virtual void device_post_load() { }
r29590r29591
9181
9282private:
9383
94   void f3853_set_interrupt_request_line();
95   void f3853_timer_start(UINT8 value);
96   void f3853_timer();
84   void set_interrupt_request_line();
85   void timer_start(UINT8 value);
86   void timer();
9787
88   f3853_interrupt_req_delegate m_interrupt_req_cb;
9889   UINT8 m_high;
9990   UINT8 m_low; // Bit 7 is set to 0 for timer interrupts, 1 for external interrupts
10091   INT32 m_external_enable;
trunk/src/mess/drivers/mk1.c
r29590r29591
5858   UINT8 m_led[4];
5959   virtual void machine_start();
6060   TIMER_DEVICE_CALLBACK_MEMBER(mk1_update_leds);
61   F3853_INTERRUPT_REQ_CB(mk1_interrupt);
6162   required_device<cpu_device> m_maincpu;
6263};
6364
r29590r29591
109110
110111static ADDRESS_MAP_START( mk1_io, AS_IO, 8, mk1_state )
111112   AM_RANGE( 0x0, 0x1 ) AM_READWRITE( mk1_f8_r, mk1_f8_w )
112   AM_RANGE( 0xc, 0xf ) AM_DEVREADWRITE("f3853", f3853_device, f3853_r, f3853_w )
113   AM_RANGE( 0xc, 0xf ) AM_DEVREADWRITE("f3853", f3853_device, read, write )
113114ADDRESS_MAP_END
114115
115116
r29590r29591
151152
152153TIMER_DEVICE_CALLBACK_MEMBER(mk1_state::mk1_update_leds)
153154{
154   UINT8 i;
155
156   for ( i = 0; i < 4; i++ )
155   for (int i = 0; i < 4; i++)
157156   {
158      output_set_digit_value( i, m_led[i] >> 1 );
159      output_set_led_value( i, m_led[i] & 0x01 );
157      output_set_digit_value(i, m_led[i] >> 1);
158      output_set_led_value(i, m_led[i] & 0x01);
160159      m_led[i] = 0;
161160   }
162161}
r29590r29591
167166}
168167
169168
170static void mk1_interrupt( device_t *device, UINT16 addr, int level )
169F3853_INTERRUPT_REQ_CB(mk1_state::mk1_interrupt)
171170{
172   mk1_state *drvstate = device->machine().driver_data<mk1_state>();
173   drvstate->m_maincpu->set_input_line_vector(F8_INPUT_LINE_INT_REQ, addr );
174
175   drvstate->m_maincpu->set_input_line(F8_INPUT_LINE_INT_REQ, level ? ASSERT_LINE : CLEAR_LINE );
171   m_maincpu->set_input_line_vector(F8_INPUT_LINE_INT_REQ, addr);
172   m_maincpu->set_input_line(F8_INPUT_LINE_INT_REQ, level ? ASSERT_LINE : CLEAR_LINE);
176173}
177174
178
179static const f3853_interface mk1_config =
180{
181   mk1_interrupt
182};
183
184
185175static MACHINE_CONFIG_START( mk1, mk1_state )
186176   /* basic machine hardware */
187177   MCFG_CPU_ADD( "maincpu", F8, MAIN_CLOCK )        /* MK3850 */
188   MCFG_CPU_PROGRAM_MAP( mk1_mem)
189   MCFG_CPU_IO_MAP( mk1_io)
178   MCFG_CPU_PROGRAM_MAP(mk1_mem)
179   MCFG_CPU_IO_MAP(mk1_io)
190180   MCFG_QUANTUM_TIME(attotime::from_hz(60))
191181
192182
193   MCFG_F3853_ADD( "f3853", MAIN_CLOCK, mk1_config )
183   MCFG_DEVICE_ADD("f3853", F3853, MAIN_CLOCK)
184   MCFG_F3853_EXT_INPUT_CB(mk1_state, mk1_interrupt)
194185
195186   /* video hardware */
196   MCFG_DEFAULT_LAYOUT( layout_mk1 )
187   MCFG_DEFAULT_LAYOUT(layout_mk1)
197188
198189   MCFG_TIMER_DRIVER_ADD_PERIODIC("led_timer", mk1_state, mk1_update_leds, attotime::from_hz(30))
199190MACHINE_CONFIG_END
trunk/src/mess/drivers/vidbrain.c
r29590r29591
255255   AM_RANGE(0x00, 0x00) AM_WRITE(keyboard_w)
256256   AM_RANGE(0x01, 0x01) AM_READWRITE(keyboard_r, sound_w)
257257   AM_RANGE(0x0c, 0x0f) AM_WRITE(f3853_w)
258//  AM_RANGE(0x0c, 0x0f) AM_DEVREADWRITE(F3853_TAG, f3853_device, f3853_r, f3853_w)
258//  AM_RANGE(0x0c, 0x0f) AM_DEVREADWRITE(F3853_TAG, f3853_device, read, write)
259259ADDRESS_MAP_END
260260
261261
r29590r29591
397397//**************************************************************************
398398
399399//-------------------------------------------------
400//  f3853_interface smi_intf
400//  f3853 interrupt request callback
401401//-------------------------------------------------
402402
403static void f3853_int_req_w(device_t *device, UINT16 addr, int level)
403F3853_INTERRUPT_REQ_CB(vidbrain_state::f3853_int_req_w)
404404{
405   vidbrain_state *state = device->machine().driver_data<vidbrain_state>();
406
407   state->m_vector = addr;
408   state->m_maincpu->set_input_line(F8_INPUT_LINE_INT_REQ, level);
405   m_vector = addr;
406   m_maincpu->set_input_line(F8_INPUT_LINE_INT_REQ, level);
409407}
410408
411static const f3853_interface smi_intf =
412{
413   f3853_int_req_w
414};
415
416
417409//-------------------------------------------------
418410//  UV201_INTERFACE( uv_intf )
419411//-------------------------------------------------
r29590r29591
567559   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
568560
569561   // devices
570   MCFG_F3853_ADD(F3853_TAG, XTAL_4MHz/2, smi_intf)
562   MCFG_DEVICE_ADD(F3853_TAG, F3853, XTAL_4MHz/2)
563   MCFG_F3853_EXT_INPUT_CB(vidbrain_state, f3853_int_req_w)
571564
572565   // cartridge
573566   MCFG_VIDEOBRAIN_EXPANSION_SLOT_ADD(VIDEOBRAIN_EXPANSION_SLOT_TAG, vidbrain_expansion_cards, NULL)
trunk/src/mess/includes/vidbrain.h
r29590r29591
9797   DECLARE_WRITE_LINE_MEMBER( hblank_w );
9898   DECLARE_READ8_MEMBER(memory_read_byte);
9999
100   F3853_INTERRUPT_REQ_CB(f3853_int_req_w);
100101
101102   IRQ_CALLBACK_MEMBER(vidbrain_int_ack);
102103

Previous 199869 Revisions Next


© 1997-2024 The MAME Team