Previous 199869 Revisions Next

r18115 Monday 24th September, 2012 at 15:01:45 UTC by Miodrag Milanović
modernization or timer callbacks part 3 - final (no whatsnew)
[src/mame/drivers]2mindril.c 39in1.c acefruit.c aces1.c alg.c aristmk4.c aristmk5.c astinvad.c beaminv.c berzerk.c boxer.c cball.c clayshoo.c cliffhgr.c crystal.c cubeqst.c destroyr.c enigma2.c esh.c famibox.c firebeat.c flyball.c gpworld.c gticlub.c guab.c halleys.c hornet.c jangou.c jpmsys5.c kinst.c ksys573.c lgp.c mazerbla.c mgolf.c missile.c mjsister.c mlanding.c mpu3.c multigam.c namcos23.c nwk-tr.c peplus.c pipeline.c rabbit.c sbrkout.c seattle.c sothello.c ssfindo.c taitogn.c thayers.c tickee.c tmmjprd.c tugboat.c vegas.c viper.c zn.c zr107.c
[src/mess/drivers]a2600.c a7000.c alphatro.c amico2k.c argo.c c10.c cat.c craft.c dectalk.c h19.c ip20.c ip22.c jr200.c mekd2.c ng_aes.c ngp.c okean240.c osbexec.c pb1000.c pc6001.c pc8801.c pc88va.c pcfx.c plan80.c pockstat.c psx.c ptcsol.c pv1000.c px4.c scv.c socrates.c supercon.c supracan.c sys2900.c tec1.c tutor.c vg5k.c vii.c vk100.c zrt80.c

trunk/src/mame/drivers/beaminv.c
r18114r18115
8080   virtual void machine_start();
8181   virtual void machine_reset();
8282   UINT32 screen_update_beaminv(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
83   TIMER_CALLBACK_MEMBER(interrupt_callback);
8384};
8485
8586
r18114r18115
9798static const int interrupt_lines[INTERRUPTS_PER_FRAME] = { 0x00, 0x80 };
9899
99100
100static TIMER_CALLBACK( interrupt_callback )
101TIMER_CALLBACK_MEMBER(beaminv_state::interrupt_callback)
101102{
102   beaminv_state *state = machine.driver_data<beaminv_state>();
103103   int interrupt_number = param;
104104   int next_interrupt_number;
105105   int next_vpos;
106106
107   state->m_maincpu->set_input_line(0, HOLD_LINE);
107   m_maincpu->set_input_line(0, HOLD_LINE);
108108
109109   /* set up for next interrupt */
110110   next_interrupt_number = (interrupt_number + 1) % INTERRUPTS_PER_FRAME;
111111   next_vpos = interrupt_lines[next_interrupt_number];
112112
113   state->m_interrupt_timer->adjust(machine.primary_screen->time_until_pos(next_vpos), next_interrupt_number);
113   m_interrupt_timer->adjust(machine().primary_screen->time_until_pos(next_vpos), next_interrupt_number);
114114}
115115
116116
117117static void create_interrupt_timer( running_machine &machine )
118118{
119119   beaminv_state *state = machine.driver_data<beaminv_state>();
120   state->m_interrupt_timer = machine.scheduler().timer_alloc(FUNC(interrupt_callback));
120   state->m_interrupt_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(beaminv_state::interrupt_callback),state));
121121}
122122
123123
trunk/src/mame/drivers/kinst.c
r18114r18115
164164   virtual void machine_reset();
165165   UINT32 screen_update_kinst(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
166166   INTERRUPT_GEN_MEMBER(irq0_start);
167   TIMER_CALLBACK_MEMBER(irq0_stop);
167168};
168169
169170
r18114r18115
276277 *
277278 *************************************/
278279
279static TIMER_CALLBACK( irq0_stop )
280TIMER_CALLBACK_MEMBER(kinst_state::irq0_stop)
280281{
281   machine.device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
282   machine().device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
282283}
283284
284285
285286INTERRUPT_GEN_MEMBER(kinst_state::irq0_start)
286287{
287288   device.execute().set_input_line(0, ASSERT_LINE);
288   machine().scheduler().timer_set(attotime::from_usec(50), FUNC(irq0_stop));
289   machine().scheduler().timer_set(attotime::from_usec(50), timer_expired_delegate(FUNC(kinst_state::irq0_stop),this));
289290}
290291
291292
trunk/src/mame/drivers/2mindril.c
r18114r18115
6565   DECLARE_MACHINE_RESET(drill);
6666   INTERRUPT_GEN_MEMBER(drill_vblank_irq);
6767   //INTERRUPT_GEN_MEMBER(drill_device_irq);
68   TIMER_CALLBACK_MEMBER(shutter_req);
69   TIMER_CALLBACK_MEMBER(defender_req);
6870};
6971
7072
r18114r18115
132134    PORT_DIPSETTING(      0x0800, DEF_STR( On ) )
133135*/
134136#ifdef UNUSED_FUNCTION
135static TIMER_CALLBACK( shutter_req )
137TIMER_CALLBACK_MEMBER(_2mindril_state::shutter_req)
136138{
137   _2mindril_state *state = machine.driver_data<_2mindril_state>();
138   state->m_shutter_sensor = param;
139   m_shutter_sensor = param;
139140}
140141
141static TIMER_CALLBACK( defender_req )
142TIMER_CALLBACK_MEMBER(_2mindril_state::defender_req)
142143{
143   _2mindril_state *state = machine.driver_data<_2mindril_state>();
144   state->m_defender_sensor = param;
144   m_defender_sensor = param;
145145}
146146#endif
147147
trunk/src/mame/drivers/cubeqst.c
r18114r18115
5858   virtual void palette_init();
5959   UINT32 screen_update_cubeqst(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
6060   INTERRUPT_GEN_MEMBER(vblank);
61   TIMER_CALLBACK_MEMBER(delayed_bank_swap);
6162};
6263
6364
r18114r18115
256257 *
257258 *************************************/
258259
259static TIMER_CALLBACK( delayed_bank_swap )
260TIMER_CALLBACK_MEMBER(cubeqst_state::delayed_bank_swap)
260261{
261   cubeqcpu_swap_line_banks(machine.device("line_cpu"));
262   cubeqcpu_swap_line_banks(machine().device("line_cpu"));
262263
263264   /* TODO: This is a little dubious */
264   cubeqcpu_clear_stack(machine.device("line_cpu"));
265   cubeqcpu_clear_stack(machine().device("line_cpu"));
265266}
266267
267268
268269static void swap_linecpu_banks(running_machine &machine)
269270{
271   cubeqst_state *state = machine.driver_data<cubeqst_state>();
270272   /* Best sync up before we switch banks around */
271   machine.scheduler().synchronize(FUNC(delayed_bank_swap));
273   machine.scheduler().synchronize(timer_expired_delegate(FUNC(cubeqst_state::delayed_bank_swap),state));
272274}
273275
274276
trunk/src/mame/drivers/boxer.c
r18114r18115
5050   virtual void machine_reset();
5151   virtual void palette_init();
5252   UINT32 screen_update_boxer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
53   TIMER_CALLBACK_MEMBER(pot_interrupt);
54   TIMER_CALLBACK_MEMBER(periodic_callback);
5355};
5456
5557/*************************************
r18114r18115
5860 *
5961 *************************************/
6062
61static TIMER_CALLBACK( pot_interrupt )
63TIMER_CALLBACK_MEMBER(boxer_state::pot_interrupt)
6264{
63   boxer_state *state = machine.driver_data<boxer_state>();
6465   int mask = param;
6566
66   if (state->m_pot_latch & mask)
67      state->m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
67   if (m_pot_latch & mask)
68      m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
6869
69   state->m_pot_state |= mask;
70   m_pot_state |= mask;
7071}
7172
7273
73static TIMER_CALLBACK( periodic_callback )
74TIMER_CALLBACK_MEMBER(boxer_state::periodic_callback)
7475{
75   boxer_state *state = machine.driver_data<boxer_state>();
7676   int scanline = param;
7777
78   state->m_maincpu->set_input_line(0, ASSERT_LINE);
78   m_maincpu->set_input_line(0, ASSERT_LINE);
7979
8080   if (scanline == 0)
8181   {
r18114r18115
8585
8686      memset(mask, 0, sizeof mask);
8787
88      mask[state->ioport("STICK0_X")->read()] |= 0x01;
89      mask[state->ioport("STICK0_Y")->read()] |= 0x02;
90      mask[state->ioport("PADDLE0")->read()]  |= 0x04;
91      mask[state->ioport("STICK1_X")->read()] |= 0x08;
92      mask[state->ioport("STICK1_Y")->read()] |= 0x10;
93      mask[state->ioport("PADDLE1")->read()]  |= 0x20;
88      mask[ioport("STICK0_X")->read()] |= 0x01;
89      mask[ioport("STICK0_Y")->read()] |= 0x02;
90      mask[ioport("PADDLE0")->read()]  |= 0x04;
91      mask[ioport("STICK1_X")->read()] |= 0x08;
92      mask[ioport("STICK1_Y")->read()] |= 0x10;
93      mask[ioport("PADDLE1")->read()]  |= 0x20;
9494
9595      for (i = 1; i < 256; i++)
9696         if (mask[i] != 0)
97            machine.scheduler().timer_set(machine.primary_screen->time_until_pos(i), FUNC(pot_interrupt), mask[i]);
97            machine().scheduler().timer_set(machine().primary_screen->time_until_pos(i), timer_expired_delegate(FUNC(boxer_state::pot_interrupt),this), mask[i]);
9898
99      state->m_pot_state = 0;
99      m_pot_state = 0;
100100   }
101101
102102   scanline += 64;
r18114r18115
104104   if (scanline >= 262)
105105      scanline = 0;
106106
107   machine.scheduler().timer_set(machine.primary_screen->time_until_pos(scanline), FUNC(periodic_callback), scanline);
107   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(scanline), timer_expired_delegate(FUNC(boxer_state::periodic_callback),this), scanline);
108108}
109109
110110
r18114r18115
436436
437437void boxer_state::machine_reset()
438438{
439   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(0), FUNC(periodic_callback));
439   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(0), timer_expired_delegate(FUNC(boxer_state::periodic_callback),this));
440440
441441   m_pot_state = 0;
442442   m_pot_latch = 0;
trunk/src/mame/drivers/aristmk5.c
r18114r18115
8383   DECLARE_DRIVER_INIT(aristmk5);
8484   virtual void machine_start();
8585   virtual void machine_reset();
86   TIMER_CALLBACK_MEMBER(mk5_VSYNC_callback);
87   TIMER_CALLBACK_MEMBER(mk5_2KHz_callback);
8688};
8789
8890
89static TIMER_CALLBACK( mk5_VSYNC_callback )
91TIMER_CALLBACK_MEMBER(aristmk5_state::mk5_VSYNC_callback)
9092{
91   aristmk5_state *state = machine.driver_data<aristmk5_state>();
92    state->m_ioc_regs[IRQ_STATUS_A] |= 0x08; //turn vsync bit on
93   state->m_mk5_VSYNC_timer->adjust(attotime::never);
93    m_ioc_regs[IRQ_STATUS_A] |= 0x08; //turn vsync bit on
94   m_mk5_VSYNC_timer->adjust(attotime::never);
9495}
9596
9697WRITE32_MEMBER(aristmk5_state::Ns5w48)
r18114r18115
152153    }
153154}
154155
155static TIMER_CALLBACK( mk5_2KHz_callback )
156TIMER_CALLBACK_MEMBER(aristmk5_state::mk5_2KHz_callback)
156157{
157   aristmk5_state *state = machine.driver_data<aristmk5_state>();
158   state->m_ioc_regs[IRQ_STATUS_A] |= 0x01;
159   state->m_mk5_2KHz_timer->adjust(attotime::never);
158   m_ioc_regs[IRQ_STATUS_A] |= 0x01;
159   m_mk5_2KHz_timer->adjust(attotime::never);
160160
161161}
162162
r18114r18115
379379   // reset the DAC to centerline
380380   //machine().device<dac_device>("dac")->write_signed8(0x80);
381381
382   m_mk5_2KHz_timer = machine().scheduler().timer_alloc(FUNC(mk5_2KHz_callback));
383   m_mk5_VSYNC_timer = machine().scheduler().timer_alloc(FUNC(mk5_VSYNC_callback));
382   m_mk5_2KHz_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(aristmk5_state::mk5_2KHz_callback),this));
383   m_mk5_VSYNC_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(aristmk5_state::mk5_VSYNC_callback),this));
384384}
385385
386386void aristmk5_state::machine_reset()
trunk/src/mame/drivers/crystal.c
r18114r18115
193193   UINT32 screen_update_crystal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
194194   void screen_eof_crystal(screen_device &screen, bool state);
195195   INTERRUPT_GEN_MEMBER(crystal_interrupt);
196   TIMER_CALLBACK_MEMBER(Timercb);
196197};
197198
198199static void IntReq( running_machine &machine, int num )
r18114r18115
300301      membank("bank1")->set_base(machine().root_device().memregion("user2")->base());
301302}
302303
303static TIMER_CALLBACK( Timercb )
304TIMER_CALLBACK_MEMBER(crystal_state::Timercb)
304305{
305   crystal_state *state = machine.driver_data<crystal_state>();
306306   int which = (int)(FPTR)ptr;
307307   static const int num[] = { 0, 1, 9, 10 };
308308
309   if (!(state->m_Timerctrl[which] & 2))
310      state->m_Timerctrl[which] &= ~1;
309   if (!(m_Timerctrl[which] & 2))
310      m_Timerctrl[which] &= ~1;
311311
312   IntReq(machine, num[which]);
312   IntReq(machine(), num[which]);
313313}
314314
315315INLINE void Timer_w( address_space &space, int which, UINT32 data, UINT32 mem_mask )
r18114r18115
589589
590590   machine().device("maincpu")->execute().set_irq_acknowledge_callback(icallback);
591591   for (i = 0; i < 4; i++)
592      m_Timer[i] = machine().scheduler().timer_alloc(FUNC(Timercb), (void*)(FPTR)i);
592      m_Timer[i] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(crystal_state::Timercb),this), (void*)(FPTR)i);
593593
594594   PatchReset(machine());
595595
trunk/src/mame/drivers/famibox.c
r18114r18115
110110   virtual void video_start();
111111   virtual void palette_init();
112112   UINT32 screen_update_famibox(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
113   TIMER_CALLBACK_MEMBER(famicombox_attract_timer_callback);
114   TIMER_CALLBACK_MEMBER(famicombox_gameplay_timer_callback);
113115};
114116
115117/******************************************************
r18114r18115
282284   machine.device("maincpu")->reset();
283285}
284286
285static TIMER_CALLBACK(famicombox_attract_timer_callback)
287TIMER_CALLBACK_MEMBER(famibox_state::famicombox_attract_timer_callback)
286288{
287   famibox_state *state = machine.driver_data<famibox_state>();
288289
289   state->m_attract_timer->adjust(attotime::never, 0, attotime::never);
290   if ( BIT(state->m_exception_mask,1) )
290   m_attract_timer->adjust(attotime::never, 0, attotime::never);
291   if ( BIT(m_exception_mask,1) )
291292   {
292      state->m_exception_cause &= ~0x02;
293      famicombox_reset(machine);
293      m_exception_cause &= ~0x02;
294      famicombox_reset(machine());
294295   }
295296}
296297
297static TIMER_CALLBACK(famicombox_gameplay_timer_callback)
298TIMER_CALLBACK_MEMBER(famibox_state::famicombox_gameplay_timer_callback)
298299{
299   famibox_state *state = machine.driver_data<famibox_state>();
300300
301   if (state->m_coins > 0)
302      state->m_coins--;
301   if (m_coins > 0)
302      m_coins--;
303303
304   if (state->m_coins == 0)
304   if (m_coins == 0)
305305   {
306      state->m_gameplay_timer->adjust(attotime::never, 0, attotime::never);
307      if ( BIT(state->m_exception_mask,4) )
306      m_gameplay_timer->adjust(attotime::never, 0, attotime::never);
307      if ( BIT(m_exception_mask,4) )
308308      {
309         state->m_exception_cause &= ~0x10;
310         famicombox_reset(machine);
309         m_exception_cause &= ~0x10;
310         famicombox_reset(machine());
311311      }
312312   }
313313}
r18114r18115
570570   famicombox_bankswitch(machine(), 0);
571571
572572
573   m_attract_timer = machine().scheduler().timer_alloc(FUNC(famicombox_attract_timer_callback));
574   m_gameplay_timer = machine().scheduler().timer_alloc(FUNC(famicombox_gameplay_timer_callback));
573   m_attract_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(famibox_state::famicombox_attract_timer_callback),this));
574   m_gameplay_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(famibox_state::famicombox_gameplay_timer_callback),this));
575575   m_exception_cause = 0xff;
576576   m_exception_mask = 0;
577577   m_attract_timer_period = 0;
trunk/src/mame/drivers/zn.c
r18114r18115
118118   DECLARE_MACHINE_RESET(coh1002v);
119119   DECLARE_MACHINE_RESET(coh1002m);
120120   INTERRUPT_GEN_MEMBER(qsound_interrupt);
121   TIMER_CALLBACK_MEMBER(dip_timer_fired);
121122};
122123
123124INLINE void ATTR_PRINTF(3,4) verboselog( running_machine &machine, int n_level, const char *s_fmt, ... )
r18114r18115
420421   verboselog( machine(), 2, "znsecsel_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
421422}
422423
423static TIMER_CALLBACK( dip_timer_fired )
424TIMER_CALLBACK_MEMBER(zn_state::dip_timer_fired)
424425{
425   zn_state *state = machine.driver_data<zn_state>();
426   psx_sio_input( machine, 0, PSX_SIO_IN_DSR, param * PSX_SIO_IN_DSR );
426   psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, param * PSX_SIO_IN_DSR );
427427
428428   if( param )
429429   {
430      state->m_dip_timer->adjust( machine.device<cpu_device>( "maincpu" )->cycles_to_attotime(50 ) );
430      m_dip_timer->adjust( machine().device<cpu_device>( "maincpu" )->cycles_to_attotime(50 ) );
431431   }
432432}
433433
r18114r18115
531531      n_game++;
532532   }
533533
534   state->m_dip_timer = machine.scheduler().timer_alloc( FUNC(dip_timer_fired), NULL );
534   state->m_dip_timer = machine.scheduler().timer_alloc( timer_expired_delegate(FUNC(zn_state::dip_timer_fired),state), NULL );
535535}
536536
537537static void psx_spu_irq(device_t *device, UINT32 data)
trunk/src/mame/drivers/tmmjprd.c
r18114r18115
6969   virtual void video_start();
7070   UINT32 screen_update_tmmjprd_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7171   UINT32 screen_update_tmmjprd_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
72   TIMER_CALLBACK_MEMBER(tmmjprd_blit_done);
7273};
7374
7475
r18114r18115
378379#define BLITLOG 0
379380
380381#if 0
381static TIMER_CALLBACK( tmmjprd_blit_done )
382TIMER_CALLBACK_MEMBER(tmmjprd_state::tmmjprd_blit_done)
382383{
383   machine.device("maincpu")->execute().set_input_line(3, HOLD_LINE);
384   machine().device("maincpu")->execute().set_input_line(3, HOLD_LINE);
384385}
385386
386387static void tmmjprd_do_blit(running_machine &machine)
r18114r18115
428429            if (!blt_amount)
429430            {
430431               if(BLITLOG) mame_printf_debug("end of blit list\n");
431               machine.scheduler().timer_set(attotime::from_usec(500), FUNC(tmmjprd_blit_done));
432               machine.scheduler().timer_set(attotime::from_usec(500), timer_expired_delegate(FUNC(tmmjprd_state::tmmjprd_blit_done),this));
432433               return;
433434            }
434435
trunk/src/mame/drivers/enigma2.c
r18114r18115
9191   virtual void machine_reset();
9292   UINT32 screen_update_enigma2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
9393   UINT32 screen_update_enigma2a(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
94   TIMER_CALLBACK_MEMBER(interrupt_clear_callback);
95   TIMER_CALLBACK_MEMBER(interrupt_assert_callback);
9496};
9597
9698
r18114r18115
113115}
114116
115117
116static TIMER_CALLBACK( interrupt_clear_callback )
118TIMER_CALLBACK_MEMBER(enigma2_state::interrupt_clear_callback)
117119{
118   enigma2_state *state = machine.driver_data<enigma2_state>();
119   state->m_maincpu->set_input_line(0, CLEAR_LINE);
120   m_maincpu->set_input_line(0, CLEAR_LINE);
120121}
121122
122123
123static TIMER_CALLBACK( interrupt_assert_callback )
124TIMER_CALLBACK_MEMBER(enigma2_state::interrupt_assert_callback)
124125{
125   enigma2_state *state = machine.driver_data<enigma2_state>();
126126   UINT16 next_counter;
127127   int next_vpos;
128128
129129   /* compute vector and set the interrupt line */
130   int vpos = machine.primary_screen->vpos();
130   int vpos = machine().primary_screen->vpos();
131131   UINT16 counter = vpos_to_vysnc_chain_counter(vpos);
132132   UINT8 vector = 0xc7 | ((counter & 0x80) >> 3) | ((~counter & 0x80) >> 4);
133   state->m_maincpu->set_input_line_and_vector(0, ASSERT_LINE, vector);
133   m_maincpu->set_input_line_and_vector(0, ASSERT_LINE, vector);
134134
135135   /* set up for next interrupt */
136136   if (counter == INT_TRIGGER_COUNT_1)
r18114r18115
139139      next_counter = INT_TRIGGER_COUNT_1;
140140
141141   next_vpos = vysnc_chain_counter_to_vpos(next_counter);
142   state->m_interrupt_assert_timer->adjust(machine.primary_screen->time_until_pos(next_vpos));
143   state->m_interrupt_clear_timer->adjust(machine.primary_screen->time_until_pos(vpos + 1));
142   m_interrupt_assert_timer->adjust(machine().primary_screen->time_until_pos(next_vpos));
143   m_interrupt_clear_timer->adjust(machine().primary_screen->time_until_pos(vpos + 1));
144144}
145145
146146
147147static void create_interrupt_timers( running_machine &machine )
148148{
149149   enigma2_state *state = machine.driver_data<enigma2_state>();
150   state->m_interrupt_clear_timer = machine.scheduler().timer_alloc(FUNC(interrupt_clear_callback));
151   state->m_interrupt_assert_timer = machine.scheduler().timer_alloc(FUNC(interrupt_assert_callback));
150   state->m_interrupt_clear_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(enigma2_state::interrupt_clear_callback),state));
151   state->m_interrupt_assert_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(enigma2_state::interrupt_assert_callback),state));
152152}
153153
154154
trunk/src/mame/drivers/gticlub.c
r18114r18115
264264   DECLARE_MACHINE_RESET(gticlub);
265265   DECLARE_MACHINE_RESET(hangplt);
266266   INTERRUPT_GEN_MEMBER(gticlub_vblank);
267   TIMER_CALLBACK_MEMBER(irq_off);
267268};
268269
269270
r18114r18115
707708};
708709
709710
710static TIMER_CALLBACK( irq_off )
711TIMER_CALLBACK_MEMBER(gticlub_state::irq_off)
711712{
712   machine.device("audiocpu")->execute().set_input_line(param, CLEAR_LINE);
713   machine().device("audiocpu")->execute().set_input_line(param, CLEAR_LINE);
713714}
714715
715716static void sound_irq_callback( running_machine &machine, int irq )
716717{
718   gticlub_state *state = machine.driver_data<gticlub_state>();
717719   int line = (irq == 0) ? INPUT_LINE_IRQ1 : INPUT_LINE_IRQ2;
718720
719721   machine.device("audiocpu")->execute().set_input_line(line, ASSERT_LINE);
720   machine.scheduler().timer_set(attotime::from_usec(1), FUNC(irq_off), line);
722   machine.scheduler().timer_set(attotime::from_usec(1), timer_expired_delegate(FUNC(gticlub_state::irq_off),state), line);
721723}
722724
723725static const k056800_interface gticlub_k056800_interface =
trunk/src/mame/drivers/guab.c
r18114r18115
9999   virtual void machine_reset();
100100   virtual void video_start();
101101   UINT32 screen_update_guab(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
102   TIMER_CALLBACK_MEMBER(fdc_data_callback);
102103};
103104
104105
r18114r18115
324325};
325326
326327
327static TIMER_CALLBACK( fdc_data_callback )
328TIMER_CALLBACK_MEMBER(guab_state::fdc_data_callback)
328329{
329   guab_state *state = machine.driver_data<guab_state>();
330   struct wd1770 &fdc = state->m_fdc;
331   UINT8* disk = (UINT8*)state->memregion("user1")->base();
330   struct wd1770 &fdc = m_fdc;
331   UINT8* disk = (UINT8*)memregion("user1")->base();
332332   int more_data = 0;
333333
334334   /*
r18114r18115
374374
375375   if (more_data)
376376   {
377      state->m_fdc_timer->adjust(attotime::from_usec(USEC_DELAY));
377      m_fdc_timer->adjust(attotime::from_usec(USEC_DELAY));
378378   }
379379   else
380380   {
r18114r18115
384384   }
385385
386386   fdc.status |= DATA_REQUEST;
387   machine.device("maincpu")->execute().set_input_line(INT_FLOPPYCTRL, ASSERT_LINE);
387   machine().device("maincpu")->execute().set_input_line(INT_FLOPPYCTRL, ASSERT_LINE);
388388}
389389
390390
r18114r18115
805805
806806void guab_state::machine_start()
807807{
808   m_fdc_timer = machine().scheduler().timer_alloc(FUNC(fdc_data_callback));
808   m_fdc_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(guab_state::fdc_data_callback),this));
809809}
810810
811811void guab_state::machine_reset()
trunk/src/mame/drivers/berzerk.c
r18114r18115
5959   virtual void machine_reset();
6060   virtual void video_start();
6161   UINT32 screen_update_berzerk(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
62   TIMER_CALLBACK_MEMBER(irq_callback);
63   TIMER_CALLBACK_MEMBER(nmi_callback);
6264};
6365
6466
r18114r18115
181183}
182184
183185
184static TIMER_CALLBACK( irq_callback )
186TIMER_CALLBACK_MEMBER(berzerk_state::irq_callback)
185187{
186   berzerk_state *state = machine.driver_data<berzerk_state>();
187188   int irq_number = param;
188189   UINT8 next_counter;
189190   UINT8 next_v256;
r18114r18115
191192   int next_irq_number;
192193
193194   /* set the IRQ line if enabled */
194   if (state->m_irq_enabled)
195      machine.device("maincpu")->execute().set_input_line_and_vector(0, HOLD_LINE, 0xfc);
195   if (m_irq_enabled)
196      machine().device("maincpu")->execute().set_input_line_and_vector(0, HOLD_LINE, 0xfc);
196197
197198   /* set up for next interrupt */
198199   next_irq_number = (irq_number + 1) % IRQS_PER_FRAME;
r18114r18115
200201   next_v256 = irq_trigger_v256s[next_irq_number];
201202
202203   next_vpos = vsync_chain_counter_to_vpos(next_counter, next_v256);
203   state->m_irq_timer->adjust(machine.primary_screen->time_until_pos(next_vpos), next_irq_number);
204   m_irq_timer->adjust(machine().primary_screen->time_until_pos(next_vpos), next_irq_number);
204205}
205206
206207
207208static void create_irq_timer(running_machine &machine)
208209{
209210   berzerk_state *state = machine.driver_data<berzerk_state>();
210   state->m_irq_timer = machine.scheduler().timer_alloc(FUNC(irq_callback));
211   state->m_irq_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(berzerk_state::irq_callback),state));
211212}
212213
213214
r18114r18115
261262}
262263
263264
264static TIMER_CALLBACK( nmi_callback )
265TIMER_CALLBACK_MEMBER(berzerk_state::nmi_callback)
265266{
266   berzerk_state *state = machine.driver_data<berzerk_state>();
267267   int nmi_number = param;
268268   UINT8 next_counter;
269269   UINT8 next_v256;
r18114r18115
271271   int next_nmi_number;
272272
273273   /* pulse the NMI line if enabled */
274   if (state->m_nmi_enabled)
275      machine.device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
274   if (m_nmi_enabled)
275      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
276276
277277   /* set up for next interrupt */
278278   next_nmi_number = (nmi_number + 1) % NMIS_PER_FRAME;
r18114r18115
280280   next_v256 = nmi_trigger_v256s[next_nmi_number];
281281
282282   next_vpos = vsync_chain_counter_to_vpos(next_counter, next_v256);
283   state->m_nmi_timer->adjust(machine.primary_screen->time_until_pos(next_vpos), next_nmi_number);
283   m_nmi_timer->adjust(machine().primary_screen->time_until_pos(next_vpos), next_nmi_number);
284284}
285285
286286
287287static void create_nmi_timer(running_machine &machine)
288288{
289289   berzerk_state *state = machine.driver_data<berzerk_state>();
290   state->m_nmi_timer = machine.scheduler().timer_alloc(FUNC(nmi_callback));
290   state->m_nmi_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(berzerk_state::nmi_callback),state));
291291}
292292
293293
trunk/src/mame/drivers/seattle.c
r18114r18115
494494   virtual void machine_start();
495495   virtual void machine_reset();
496496   UINT32 screen_update_seattle(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
497   TIMER_CALLBACK_MEMBER(galileo_timer_callback);
497498};
498499
499500
r18114r18115
506507static void vblank_assert(device_t *device, int state);
507508static void update_vblank_irq(running_machine &machine);
508509static void galileo_reset(running_machine &machine);
509static TIMER_CALLBACK( galileo_timer_callback );
510
510511static void galileo_perform_dma(address_space &space, int which);
511512static void voodoo_stall(device_t *device, int stall);
512513static void widget_reset(running_machine &machine);
r18114r18115
540541   m_voodoo = machine().device("voodoo");
541542
542543   /* allocate timers for the galileo */
543   m_galileo.timer[0].timer = machine().scheduler().timer_alloc(FUNC(galileo_timer_callback));
544   m_galileo.timer[1].timer = machine().scheduler().timer_alloc(FUNC(galileo_timer_callback));
545   m_galileo.timer[2].timer = machine().scheduler().timer_alloc(FUNC(galileo_timer_callback));
546   m_galileo.timer[3].timer = machine().scheduler().timer_alloc(FUNC(galileo_timer_callback));
544   m_galileo.timer[0].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(seattle_state::galileo_timer_callback),this));
545   m_galileo.timer[1].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(seattle_state::galileo_timer_callback),this));
546   m_galileo.timer[2].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(seattle_state::galileo_timer_callback),this));
547   m_galileo.timer[3].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(seattle_state::galileo_timer_callback),this));
547548
548549   /* set the fastest DRC options, but strict verification */
549550   mips3drc_set_options(machine().device("maincpu"), MIPS3DRC_FASTEST_OPTIONS + MIPS3DRC_STRICT_VERIFY);
r18114r18115
940941}
941942
942943
943static TIMER_CALLBACK( galileo_timer_callback )
944TIMER_CALLBACK_MEMBER(seattle_state::galileo_timer_callback)
944945{
945   seattle_state *state = machine.driver_data<seattle_state>();
946946   int which = param;
947   galileo_timer *timer = &state->m_galileo.timer[which];
947   galileo_timer *timer = &m_galileo.timer[which];
948948
949949   if (LOG_TIMERS)
950950      logerror("timer %d fired\n", which);
951951
952952   /* copy the start value from the registers */
953   timer->count = state->m_galileo.reg[GREG_TIMER0_COUNT + which];
953   timer->count = m_galileo.reg[GREG_TIMER0_COUNT + which];
954954   if (which != 0)
955955      timer->count &= 0xffffff;
956956
957957   /* if we're a timer, adjust the timer to fire again */
958   if (state->m_galileo.reg[GREG_TIMER_CONTROL] & (2 << (2 * which)))
958   if (m_galileo.reg[GREG_TIMER_CONTROL] & (2 << (2 * which)))
959959      timer->timer->adjust(TIMER_PERIOD * timer->count, which);
960960   else
961961      timer->active = timer->count = 0;
962962
963963   /* trigger the interrupt */
964   state->m_galileo.reg[GREG_INT_STATE] |= 1 << (GINT_T0EXP_SHIFT + which);
965   update_galileo_irqs(machine);
964   m_galileo.reg[GREG_INT_STATE] |= 1 << (GINT_T0EXP_SHIFT + which);
965   update_galileo_irqs(machine());
966966}
967967
968968
trunk/src/mame/drivers/flyball.c
r18114r18115
6161   virtual void video_start();
6262   virtual void palette_init();
6363   UINT32 screen_update_flyball(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
64   TIMER_CALLBACK_MEMBER(flyball_joystick_callback);
65   TIMER_CALLBACK_MEMBER(flyball_quarter_callback);
6466};
6567
6668
r18114r18115
129131}
130132
131133
132static TIMER_CALLBACK( flyball_joystick_callback )
134TIMER_CALLBACK_MEMBER(flyball_state::flyball_joystick_callback)
133135{
134   flyball_state *state = machine.driver_data<flyball_state>();
135136   int potsense = param;
136137
137   if (potsense & ~state->m_potmask)
138      generic_pulse_irq_line(state->m_maincpu, 0, 1);
138   if (potsense & ~m_potmask)
139      generic_pulse_irq_line(*m_maincpu, 0, 1);
139140
140   state->m_potsense |= potsense;
141   m_potsense |= potsense;
141142}
142143
143144
144static TIMER_CALLBACK( flyball_quarter_callback   )
145TIMER_CALLBACK_MEMBER(flyball_state::flyball_quarter_callback)
145146{
146   flyball_state *state = machine.driver_data<flyball_state>();
147147   int scanline = param;
148148   int potsense[64], i;
149149
150150   memset(potsense, 0, sizeof potsense);
151151
152   potsense[state->ioport("STICK1_Y")->read()] |= 1;
153   potsense[state->ioport("STICK1_X")->read()] |= 2;
154   potsense[state->ioport("STICK0_Y")->read()] |= 4;
155   potsense[state->ioport("STICK0_X")->read()] |= 8;
152   potsense[ioport("STICK1_Y")->read()] |= 1;
153   potsense[ioport("STICK1_X")->read()] |= 2;
154   potsense[ioport("STICK0_Y")->read()] |= 4;
155   potsense[ioport("STICK0_X")->read()] |= 8;
156156
157157   for (i = 0; i < 64; i++)
158158      if (potsense[i] != 0)
159         machine.scheduler().timer_set(machine.primary_screen->time_until_pos(scanline + i), FUNC(flyball_joystick_callback), potsense[i]);
159         machine().scheduler().timer_set(machine().primary_screen->time_until_pos(scanline + i), timer_expired_delegate(FUNC(flyball_state::flyball_joystick_callback),this), potsense[i]);
160160
161161   scanline += 0x40;
162162   scanline &= 0xff;
163163
164   machine.scheduler().timer_set(machine.primary_screen->time_until_pos(scanline), FUNC(flyball_quarter_callback), scanline);
164   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(scanline), timer_expired_delegate(FUNC(flyball_state::flyball_quarter_callback),this), scanline);
165165
166   state->m_potsense = 0;
167   state->m_potmask = 0;
166   m_potsense = 0;
167   m_potmask = 0;
168168}
169169
170170
r18114r18115
398398
399399   machine().device("maincpu")->reset();
400400
401   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(0), FUNC(flyball_quarter_callback));
401   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(0), timer_expired_delegate(FUNC(flyball_state::flyball_quarter_callback),this));
402402
403403   m_pitcher_vert = 0;
404404   m_pitcher_horz = 0;
trunk/src/mame/drivers/pipeline.c
r18114r18115
102102   virtual void video_start();
103103   virtual void palette_init();
104104   UINT32 screen_update_pipeline(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
105   TIMER_CALLBACK_MEMBER(protection_deferred_w);
105106};
106107
107108
r18114r18115
178179   return m_fromMCU;
179180}
180181
181static TIMER_CALLBACK( protection_deferred_w )
182TIMER_CALLBACK_MEMBER(pipeline_state::protection_deferred_w)
182183{
183   pipeline_state *state = machine.driver_data<pipeline_state>();
184   state->m_toMCU = param;
184   m_toMCU = param;
185185}
186186
187187WRITE8_MEMBER(pipeline_state::protection_w)
188188{
189   machine().scheduler().synchronize(FUNC(protection_deferred_w), data);
189   machine().scheduler().synchronize(timer_expired_delegate(FUNC(pipeline_state::protection_deferred_w),this), data);
190190   machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(100));
191191}
192192
trunk/src/mame/drivers/39in1.c
r18114r18115
7676   virtual void machine_start();
7777   UINT32 screen_update_39in1(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
7878   INTERRUPT_GEN_MEMBER(pxa255_vblank_start);
79   TIMER_CALLBACK_MEMBER(pxa255_dma_dma_end);
80   TIMER_CALLBACK_MEMBER(pxa255_ostimer_match);
81   TIMER_CALLBACK_MEMBER(pxa255_lcd_dma_eof);
7982};
8083
8184
r18114r18115
8790
8891
8992static void pxa255_ostimer_irq_check(running_machine& machine);
90static TIMER_CALLBACK( pxa255_ostimer_match );
9193
9294
9395
96
9497static void pxa255_update_interrupts(running_machine& machine);
9598static void pxa255_set_irq_line(running_machine& machine, UINT32 line, int state);
9699
r18114r18115
308311   dma_regs->dcsr[channel] &= ~PXA255_DCSR_STOPSTATE;
309312}
310313
311static TIMER_CALLBACK( pxa255_dma_dma_end )
314TIMER_CALLBACK_MEMBER(_39in1_state::pxa255_dma_dma_end)
312315{
313   _39in1_state *state = machine.driver_data<_39in1_state>();
314   PXA255_DMA_Regs *dma_regs = &state->m_dma_regs;
316   PXA255_DMA_Regs *dma_regs = &m_dma_regs;
315317   UINT32 sadr = dma_regs->dsadr[param];
316318   UINT32 tadr = dma_regs->dtadr[param];
317319   UINT32 count = dma_regs->dcmd[param] & 0x00001fff;
r18114r18115
320322   UINT16 temp16;
321323   UINT32 temp32;
322324
323   address_space &space = machine.device<pxa255_device>("maincpu")->space(AS_PROGRAM);
325   address_space &space = machine().device<pxa255_device>("maincpu")->space(AS_PROGRAM);
324326   switch(param)
325327   {
326328      case 3:
327329         for(index = 0; index < count; index += 4)
328330         {
329            state->m_words[index >> 2] = space.read_dword(sadr);
330            state->m_samples[(index >> 1) + 0] = (INT16)(state->m_words[index >> 2] >> 16);
331            state->m_samples[(index >> 1) + 1] = (INT16)(state->m_words[index >> 2] & 0xffff);
331            m_words[index >> 2] = space.read_dword(sadr);
332            m_samples[(index >> 1) + 0] = (INT16)(m_words[index >> 2] >> 16);
333            m_samples[(index >> 1) + 1] = (INT16)(m_words[index >> 2] & 0xffff);
332334            sadr += 4;
333335         }
334         dmadac_transfer(&state->m_dmadac[0], 2, 2, 2, count/4, state->m_samples);
336         dmadac_transfer(&m_dmadac[0], 2, 2, 2, count/4, m_samples);
335337         break;
336338      default:
337339         for(index = 0; index < count;)
r18114r18115
403405   {
404406      if(dma_regs->dcsr[param] & PXA255_DCSR_RUN)
405407      {
406         pxa255_dma_load_descriptor_and_start(machine, param);
408         pxa255_dma_load_descriptor_and_start(machine(), param);
407409      }
408410      else
409411      {
r18114r18115
416418      dma_regs->dcsr[param] &= ~PXA255_DCSR_RUN;
417419      dma_regs->dcsr[param] |= PXA255_DCSR_STOPSTATE;
418420   }
419   pxa255_dma_irq_check(machine);
421   pxa255_dma_irq_check(machine());
420422}
421423
422424READ32_MEMBER(_39in1_state::pxa255_dma_r)
r18114r18115
579581   //pxa255_set_irq_line(machine, PXA255_INT_OSTIMER3, (ostimer_regs->oier & PXA255_OIER_E3) ? ((ostimer_regs->ossr & PXA255_OSSR_M3) ? 1 : 0) : 0);
580582}
581583
582static TIMER_CALLBACK( pxa255_ostimer_match )
584TIMER_CALLBACK_MEMBER(_39in1_state::pxa255_ostimer_match)
583585{
584   _39in1_state *state = machine.driver_data<_39in1_state>();
585   PXA255_OSTMR_Regs *ostimer_regs = &state->m_ostimer_regs;
586   PXA255_OSTMR_Regs *ostimer_regs = &m_ostimer_regs;
586587
587   if (0) verboselog(machine, 3, "pxa255_ostimer_match channel %d\n", param);
588   if (0) verboselog(machine(), 3, "pxa255_ostimer_match channel %d\n", param);
588589   ostimer_regs->ossr |= (1 << param);
589590   ostimer_regs->oscr = ostimer_regs->osmr[param];
590   pxa255_ostimer_irq_check(machine);
591   pxa255_ostimer_irq_check(machine());
591592}
592593
593594READ32_MEMBER(_39in1_state::pxa255_ostimer_r)
r18114r18115
11661167   }
11671168}
11681169
1169static TIMER_CALLBACK( pxa255_lcd_dma_eof )
1170TIMER_CALLBACK_MEMBER(_39in1_state::pxa255_lcd_dma_eof)
11701171{
1171   _39in1_state *state = machine.driver_data<_39in1_state>();
1172   PXA255_LCD_Regs *lcd_regs = &state->m_lcd_regs;
1172   PXA255_LCD_Regs *lcd_regs = &m_lcd_regs;
11731173
1174   if (0) verboselog( machine, 3, "End of frame callback\n" );
1174   if (0) verboselog( machine(), 3, "End of frame callback\n" );
11751175   if(lcd_regs->dma[param].ldcmd & PXA255_LDCMD_EOFINT)
11761176   {
11771177      lcd_regs->liidr = lcd_regs->dma[param].fidr;
11781178      lcd_regs->lcsr |= PXA255_LCSR_EOF;
11791179   }
1180   pxa255_lcd_check_load_next_branch(machine, param);
1181   pxa255_lcd_irq_check(machine);
1180   pxa255_lcd_check_load_next_branch(machine(), param);
1181   pxa255_lcd_irq_check(machine());
11821182}
11831183
11841184READ32_MEMBER(_39in1_state::pxa255_lcd_r)
r18114r18115
15481548   for(index = 0; index < 16; index++)
15491549   {
15501550      state->m_dma_regs.dcsr[index] = 0x00000008;
1551      state->m_dma_regs.timer[index] = machine.scheduler().timer_alloc(FUNC(pxa255_dma_dma_end));
1551      state->m_dma_regs.timer[index] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(_39in1_state::pxa255_dma_dma_end),state));
15521552   }
15531553
15541554   memset(&state->m_ostimer_regs, 0, sizeof(state->m_ostimer_regs));
15551555   for(index = 0; index < 4; index++)
15561556   {
15571557      state->m_ostimer_regs.osmr[index] = 0;
1558      state->m_ostimer_regs.timer[index] = machine.scheduler().timer_alloc(FUNC(pxa255_ostimer_match));
1558      state->m_ostimer_regs.timer[index] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(_39in1_state::pxa255_ostimer_match),state));
15591559   }
15601560
15611561   memset(&state->m_intc_regs, 0, sizeof(state->m_intc_regs));
15621562
15631563   memset(&state->m_lcd_regs, 0, sizeof(state->m_lcd_regs));
1564   state->m_lcd_regs.dma[0].eof = machine.scheduler().timer_alloc(FUNC(pxa255_lcd_dma_eof));
1565   state->m_lcd_regs.dma[1].eof = machine.scheduler().timer_alloc(FUNC(pxa255_lcd_dma_eof));
1564   state->m_lcd_regs.dma[0].eof = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(_39in1_state::pxa255_lcd_dma_eof),state));
1565   state->m_lcd_regs.dma[1].eof = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(_39in1_state::pxa255_lcd_dma_eof),state));
15661566   state->m_lcd_regs.trgbr = 0x00aa5500;
15671567   state->m_lcd_regs.tcr = 0x0000754f;
15681568
trunk/src/mame/drivers/mpu3.c
r18114r18115
185185   DECLARE_DRIVER_INIT(m3hprvpr);
186186   virtual void machine_start();
187187   virtual void machine_reset();
188   TIMER_CALLBACK_MEMBER(ic21_timeout);
188189};
189190
190191#define DISPLAY_PORT 0
191192#define METER_PORT 1
192193#define BWB_FUNCTIONALITY 2
193static TIMER_CALLBACK( ic21_timeout );
194194
195
195196static void update_triacs(running_machine &machine)
196197{
197198   mpu3_state *state = machine.driver_data<mpu3_state>();
r18114r18115
353354   }
354355}
355356
356static TIMER_CALLBACK( ic21_timeout )
357TIMER_CALLBACK_MEMBER(mpu3_state::ic21_timeout)
357358{
358   mpu3_state *state = machine.driver_data<mpu3_state>();
359   state->m_ic11_active=0;
360   ic21_output(state,0);
359   m_ic11_active=0;
360   ic21_output(this,0);
361361}
362362
363363READ8_MEMBER(mpu3_state::pia_ic3_porta_r)
r18114r18115
785785static void mpu3_config_common(running_machine &machine)
786786{
787787   mpu3_state *state = machine.driver_data<mpu3_state>();
788   state->m_ic21_timer = machine.scheduler().timer_alloc(FUNC(ic21_timeout));
788   state->m_ic21_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(mpu3_state::ic21_timeout),state));
789789}
790790
791791void mpu3_state::machine_start()
trunk/src/mame/drivers/peplus.c
r18114r18115
267267   virtual void video_start();
268268   virtual void palette_init();
269269   UINT32 screen_update_peplus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
270   TIMER_CALLBACK_MEMBER(assert_lp_cb);
270271};
271272
272273static const UINT8  id_022[8] = { 0x00, 0x01, 0x04, 0x09, 0x13, 0x16, 0x18, 0x00 };
r18114r18115
372373   /* Reset timing logic */
373374}
374375
375static TIMER_CALLBACK(assert_lp_cb)
376TIMER_CALLBACK_MEMBER(peplus_state::assert_lp_cb)
376377{
377378   downcast<mc6845_device *>((device_t*)ptr)->assert_light_pen_input();
378379}
379380
380381static void handle_lightpen( device_t *device )
381382{
383   peplus_state *state = device->machine().driver_data<peplus_state>();
382384    int x_val = device->machine().root_device().ioport("TOUCH_X")->read_safe(0x00);
383385    int y_val = device->machine().root_device().ioport("TOUCH_Y")->read_safe(0x00);
384386    const rectangle &vis_area = device->machine().primary_screen->visible_area();
r18114r18115
387389    xt = x_val * vis_area.width() / 1024 + vis_area.min_x;
388390    yt = y_val * vis_area.height() / 1024 + vis_area.min_y;
389391
390     device->machine().scheduler().timer_set(device->machine().primary_screen->time_until_pos(yt, xt), FUNC(assert_lp_cb), 0, device);
392     device->machine().scheduler().timer_set(device->machine().primary_screen->time_until_pos(yt, xt), timer_expired_delegate(FUNC(peplus_state::assert_lp_cb),state), 0, device);
391393}
392394
393395WRITE_LINE_MEMBER(peplus_state::crtc_vsync)
trunk/src/mame/drivers/thayers.c
r18114r18115
8282   DECLARE_CUSTOM_INPUT_MEMBER(laserdisc_ready_r);
8383   virtual void machine_start();
8484   virtual void machine_reset();
85   TIMER_CALLBACK_MEMBER(intrq_tick);
86   TIMER_CALLBACK_MEMBER(ssi263_phoneme_tick);
8587};
8688
8789
r18114r18115
106108   }
107109}
108110
109static TIMER_CALLBACK( intrq_tick )
111TIMER_CALLBACK_MEMBER(thayers_state::intrq_tick)
110112{
111   machine.device("maincpu")->execute().set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE);
113   machine().device("maincpu")->execute().set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE);
112114}
113115
114116WRITE8_MEMBER(thayers_state::intrq_w)
r18114r18115
117119
118120   machine().device("maincpu")->execute().set_input_line(INPUT_LINE_IRQ0, HOLD_LINE);
119121
120   machine().scheduler().timer_set(attotime::from_usec(8250), FUNC(intrq_tick));
122   machine().scheduler().timer_set(attotime::from_usec(8250), timer_expired_delegate(FUNC(thayers_state::intrq_tick),this));
121123}
122124
123125READ8_MEMBER(thayers_state::irqstate_r)
r18114r18115
470472   "L", "L1", "LF", "W", "B", "D", "KV", "P", "T", "K", "HV", "HVC", "HF", "HFC", "HN", "Z", "S", "J", "SCH", "V", "F", "THV", "TH", "M", "N", "NG", ":A", ":OH", ":U", ":UH", "E2", "LB"
471473};
472474
473static TIMER_CALLBACK( ssi263_phoneme_tick )
475TIMER_CALLBACK_MEMBER(thayers_state::ssi263_phoneme_tick)
474476{
475   thayers_state *state = machine.driver_data<thayers_state>();
476   state->m_ssi_data_request = 0;
477   check_interrupt(machine);
477   m_ssi_data_request = 0;
478   check_interrupt(machine());
478479}
479480
480481WRITE8_MEMBER(thayers_state::ssi263_register_w)
r18114r18115
499500      case 0:
500501      case 1:
501502         // phoneme timing response
502         machine().scheduler().timer_set(attotime::from_usec(phoneme_time), FUNC(ssi263_phoneme_tick));
503         machine().scheduler().timer_set(attotime::from_usec(phoneme_time), timer_expired_delegate(FUNC(thayers_state::ssi263_phoneme_tick),this));
503504         break;
504505      case 2:
505506         // frame timing response
506         machine().scheduler().timer_set(attotime::from_usec(frame_time), FUNC(ssi263_phoneme_tick));
507         machine().scheduler().timer_set(attotime::from_usec(frame_time), timer_expired_delegate(FUNC(thayers_state::ssi263_phoneme_tick),this));
507508         break;
508509      case 3:
509510         // disable A/_R output
trunk/src/mame/drivers/nwk-tr.c
r18114r18115
255255   virtual void machine_start();
256256   virtual void machine_reset();
257257   UINT32 screen_update_nwktr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
258   TIMER_CALLBACK_MEMBER(irq_off);
258259};
259260
260261
r18114r18115
510511
511512/*****************************************************************************/
512513
513static TIMER_CALLBACK( irq_off )
514TIMER_CALLBACK_MEMBER(nwktr_state::irq_off)
514515{
515   machine.device("audiocpu")->execute().set_input_line(param, CLEAR_LINE);
516   machine().device("audiocpu")->execute().set_input_line(param, CLEAR_LINE);
516517}
517518
518519void nwktr_state::machine_start()
r18114r18115
523524   /* configure fast RAM regions for DRC */
524525   ppcdrc_add_fastram(machine().device("maincpu"), 0x00000000, 0x003fffff, FALSE, m_work_ram);
525526
526   m_sound_irq_timer = machine().scheduler().timer_alloc(FUNC(irq_off));
527   m_sound_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(nwktr_state::irq_off),this));
527528}
528529
529530static ADDRESS_MAP_START( nwktr_map, AS_PROGRAM, 32, nwktr_state )
trunk/src/mame/drivers/namcos23.c
r18114r18115
14391439   DECLARE_MACHINE_RESET(gmen);
14401440   UINT32 screen_update_ss23(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
14411441   INTERRUPT_GEN_MEMBER(s23_interrupt);
1442   TIMER_CALLBACK_MEMBER(c361_timer_cb);
14421443};
14431444
14441445
r18114r18115
17491750}
17501751
17511752// raster timer.  TC2 indicates it's probably one-shot since it resets it each VBL...
1752static TIMER_CALLBACK( c361_timer_cb )
1753TIMER_CALLBACK_MEMBER(namcos23_state::c361_timer_cb)
17531754{
1754   namcos23_state *state = machine.driver_data<namcos23_state>();
1755   c361_t &c361 = state->m_c361;
1755   c361_t &c361 = m_c361;
17561756
17571757   if (c361.scanline != 511)
17581758   {
1759      machine.device("maincpu")->execute().set_input_line(MIPS3_IRQ1, ASSERT_LINE);
1759      machine().device("maincpu")->execute().set_input_line(MIPS3_IRQ1, ASSERT_LINE);
17601760      c361.timer->adjust(attotime::never);
17611761   }
17621762}
r18114r18115
24522452MACHINE_START_MEMBER(namcos23_state,s23)
24532453{
24542454   c361_t &c361 = m_c361;
2455   c361.timer = machine().scheduler().timer_alloc(FUNC(c361_timer_cb));
2455   c361.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(namcos23_state::c361_timer_cb),this));
24562456   c361.timer->adjust(attotime::never);
24572457}
24582458
trunk/src/mame/drivers/ksys573.c
r18114r18115
583583   DECLARE_DRIVER_INIT(ddrdigital);
584584   DECLARE_DRIVER_INIT(konami573);
585585   DECLARE_MACHINE_RESET(konami573);
586   TIMER_CALLBACK_MEMBER(atapi_xfer_end);
586587};
587588
588589INLINE void ATTR_PRINTF(3,4) verboselog( running_machine &machine, int n_level, const char *s_fmt, ... )
r18114r18115
693694   }
694695}
695696
696static TIMER_CALLBACK( atapi_xfer_end )
697TIMER_CALLBACK_MEMBER(ksys573_state::atapi_xfer_end)
697698{
698   ksys573_state *state = machine.driver_data<ksys573_state>();
699   UINT32 *p_n_psxram = state->m_p_n_psxram;
700   UINT8 *atapi_regs = state->m_atapi_regs;
701   int i, n_this;
699   UINT32 *p_n_psxram = m_p_n_psxram;
700   UINT8 *atapi_regs = m_atapi_regs;
701   int i, n_state;
702702   UINT8 sector_buffer[ 4096 ];
703703
704   state->m_atapi_timer->adjust(attotime::never);
704   m_atapi_timer->adjust(attotime::never);
705705
706//  verboselog( machine, 2, "atapi_xfer_end( %d ) atapi_xferlen = %d, atapi_xfermod=%d\n", x, atapi_xfermod, atapi_xferlen );
706//  verboselog( machine(), 2, "atapi_xfer_end( %d ) atapi_xferlen = %d, atapi_xfermod=%d\n", x, atapi_xfermod, atapi_xferlen );
707707
708708//  mame_printf_debug("ATAPI: xfer_end.  xferlen = %d, atapi_xfermod = %d\n", atapi_xferlen, atapi_xfermod);
709709
710   while( state->m_atapi_xferlen > 0 )
710   while( m_atapi_xferlen > 0 )
711711   {
712712      // get a sector from the SCSI device
713      state->m_inserted_cdrom->ReadData( sector_buffer, 2048 );
713      m_inserted_cdrom->ReadData( sector_buffer, 2048 );
714714
715      state->m_atapi_xferlen -= 2048;
715      m_atapi_xferlen -= 2048;
716716
717717      i = 0;
718      n_this = 2048 / 4;
719      while( n_this > 0 )
718      n_state = 2048 / 4;
719      while( n_state > 0 )
720720      {
721         p_n_psxram[ state->m_atapi_xferbase / 4 ] =
721         p_n_psxram[ m_atapi_xferbase / 4 ] =
722722            ( sector_buffer[ i + 0 ] << 0 ) |
723723            ( sector_buffer[ i + 1 ] << 8 ) |
724724            ( sector_buffer[ i + 2 ] << 16 ) |
725725            ( sector_buffer[ i + 3 ] << 24 );
726         state->m_atapi_xferbase += 4;
726         m_atapi_xferbase += 4;
727727         i += 4;
728         n_this--;
728         n_state--;
729729      }
730730   }
731731
732   if (state->m_atapi_xfermod > MAX_TRANSFER_SIZE)
732   if (m_atapi_xfermod > MAX_TRANSFER_SIZE)
733733   {
734      state->m_atapi_xferlen = MAX_TRANSFER_SIZE;
735      state->m_atapi_xfermod = state->m_atapi_xfermod - MAX_TRANSFER_SIZE;
734      m_atapi_xferlen = MAX_TRANSFER_SIZE;
735      m_atapi_xfermod = m_atapi_xfermod - MAX_TRANSFER_SIZE;
736736   }
737737   else
738738   {
739      state->m_atapi_xferlen = state->m_atapi_xfermod;
740      state->m_atapi_xfermod = 0;
739      m_atapi_xferlen = m_atapi_xfermod;
740      m_atapi_xfermod = 0;
741741   }
742742
743743
744   if (state->m_atapi_xferlen > 0)
744   if (m_atapi_xferlen > 0)
745745   {
746746      //mame_printf_debug("ATAPI: starting next piece of multi-part transfer\n");
747      atapi_regs[ATAPI_REG_COUNTLOW] = state->m_atapi_xferlen & 0xff;
748      atapi_regs[ATAPI_REG_COUNTHIGH] = (state->m_atapi_xferlen>>8)&0xff;
747      atapi_regs[ATAPI_REG_COUNTLOW] = m_atapi_xferlen & 0xff;
748      atapi_regs[ATAPI_REG_COUNTHIGH] = (m_atapi_xferlen>>8)&0xff;
749749
750      state->m_atapi_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime((ATAPI_CYCLES_PER_SECTOR * (state->m_atapi_xferlen/2048))));
750      m_atapi_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime((ATAPI_CYCLES_PER_SECTOR * (m_atapi_xferlen/2048))));
751751   }
752752   else
753753   {
r18114r18115
756756      atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO | ATAPI_INTREASON_COMMAND;
757757   }
758758
759   psx_irq_set(machine, 0x400);
759   psx_irq_set(machine(), 0x400);
760760
761   verboselog( machine, 2, "atapi_xfer_end: %d %d\n", state->m_atapi_xferlen, state->m_atapi_xfermod );
761   verboselog( machine(), 2, "atapi_xfer_end: %d %d\n", m_atapi_xferlen, m_atapi_xfermod );
762762}
763763
764764READ32_MEMBER(ksys573_state::atapi_r)
r18114r18115
11311131   state->m_atapi_data_len = 0;
11321132   state->m_atapi_cdata_wait = 0;
11331133
1134   state->m_atapi_timer = machine.scheduler().timer_alloc(FUNC(atapi_xfer_end));
1134   state->m_atapi_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(ksys573_state::atapi_xfer_end),state));
11351135   state->m_atapi_timer->adjust(attotime::never);
11361136
11371137   state->m_available_cdroms[ 0 ] = machine.device<scsidev_device>( ":cdrom0" );
trunk/src/mame/drivers/sbrkout.c
r18114r18115
6767   virtual void machine_reset();
6868   virtual void video_start();
6969   UINT32 screen_update_sbrkout(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
70   TIMER_CALLBACK_MEMBER(scanline_callback);
71   TIMER_CALLBACK_MEMBER(pot_trigger_callback);
7072};
7173
7274
r18114r18115
8991 *
9092 *************************************/
9193
92static TIMER_CALLBACK( scanline_callback );
93static TIMER_CALLBACK( pot_trigger_callback );
9494
9595
9696
97
98
9799/*************************************
98100 *
99101 *  Machine setup
r18114r18115
104106{
105107   UINT8 *videoram = m_videoram;
106108   membank("bank1")->set_base(&videoram[0x380]);
107   m_scanline_timer = machine().scheduler().timer_alloc(FUNC(scanline_callback));
108   m_pot_timer = machine().scheduler().timer_alloc(FUNC(pot_trigger_callback));
109   m_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sbrkout_state::scanline_callback),this));
110   m_pot_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sbrkout_state::pot_trigger_callback),this));
109111
110112   save_item(NAME(m_sync2_value));
111113   save_item(NAME(m_pot_mask));
r18114r18115
126128 *
127129 *************************************/
128130
129static TIMER_CALLBACK( scanline_callback )
131TIMER_CALLBACK_MEMBER(sbrkout_state::scanline_callback)
130132{
131   sbrkout_state *state = machine.driver_data<sbrkout_state>();
132   UINT8 *videoram = state->m_videoram;
133   UINT8 *videoram = m_videoram;
133134   int scanline = param;
134135
135136   /* force a partial update before anything happens */
136   machine.primary_screen->update_partial(scanline);
137   machine().primary_screen->update_partial(scanline);
137138
138139   /* if this is a rising edge of 16V, assert the CPU interrupt */
139140   if (scanline % 32 == 16)
140      machine.device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
141      machine().device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
141142
142143   /* update the DAC state */
143   machine.device<dac_device>("dac")->write_unsigned8((videoram[0x380 + 0x11] & (scanline >> 2)) ? 255 : 0);
144   machine().device<dac_device>("dac")->write_unsigned8((videoram[0x380 + 0x11] & (scanline >> 2)) ? 255 : 0);
144145
145146   /* on the VBLANK, read the pot and schedule an interrupt time for it */
146   if (scanline == machine.primary_screen->visible_area().max_y + 1)
147   if (scanline == machine().primary_screen->visible_area().max_y + 1)
147148   {
148      UINT8 potvalue = state->ioport("PADDLE")->read();
149      state->m_pot_timer->adjust(machine.primary_screen->time_until_pos(56 + (potvalue / 2), (potvalue % 2) * 128));
149      UINT8 potvalue = ioport("PADDLE")->read();
150      m_pot_timer->adjust(machine().primary_screen->time_until_pos(56 + (potvalue / 2), (potvalue % 2) * 128));
150151   }
151152
152153   /* call us back in 4 scanlines */
153154   scanline += 4;
154   if (scanline >= machine.primary_screen->height())
155   if (scanline >= machine().primary_screen->height())
155156      scanline = 0;
156   state->m_scanline_timer->adjust(machine.primary_screen->time_until_pos(scanline), scanline);
157   m_scanline_timer->adjust(machine().primary_screen->time_until_pos(scanline), scanline);
157158}
158159
159160
r18114r18115
210211}
211212
212213
213static TIMER_CALLBACK( pot_trigger_callback )
214TIMER_CALLBACK_MEMBER(sbrkout_state::pot_trigger_callback)
214215{
215   sbrkout_state *state = machine.driver_data<sbrkout_state>();
216   state->m_pot_trigger[param] = 1;
217   update_nmi_state(machine);
216   m_pot_trigger[param] = 1;
217   update_nmi_state(machine());
218218}
219219
220220
trunk/src/mame/drivers/aces1.c
r18114r18115
146146   DECLARE_DRIVER_INIT(aces1);
147147   virtual void machine_start();
148148   virtual void machine_reset();
149   TIMER_CALLBACK_MEMBER(m_aces1_irq_timer_callback);
150   TIMER_CALLBACK_MEMBER(m_aces1_nmi_timer_callback);
149151};
150152
151153
152154
153155
154156
155static TIMER_CALLBACK( m_aces1_irq_timer_callback )
157TIMER_CALLBACK_MEMBER(aces1_state::m_aces1_irq_timer_callback)
156158{
157   aces1_state *state = machine.driver_data<aces1_state>();
158159//  printf("irq\n");
159   state->m_maincpu->set_input_line(INPUT_LINE_IRQ0, HOLD_LINE);
160   state->aces1_reset_irq_timer();
160   m_maincpu->set_input_line(INPUT_LINE_IRQ0, HOLD_LINE);
161   aces1_reset_irq_timer();
161162}
162163
163static TIMER_CALLBACK( m_aces1_nmi_timer_callback )
164TIMER_CALLBACK_MEMBER(aces1_state::m_aces1_nmi_timer_callback)
164165{
165   aces1_state *state = machine.driver_data<aces1_state>();
166166//  printf("nmi\n");
167   state->m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
168   state->aces1_reset_nmi_timer();
167   m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
168   aces1_reset_nmi_timer();
169169}
170170
171171static void aces1_create_timers(running_machine &machine)
172172{
173173   aces1_state *state = machine.driver_data<aces1_state>();
174174
175   state->m_aces1_irq_timer = machine.scheduler().timer_alloc(FUNC(m_aces1_irq_timer_callback), 0);
176   state->m_aces1_nmi_timer = machine.scheduler().timer_alloc(FUNC(m_aces1_nmi_timer_callback), 0);
175   state->m_aces1_irq_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(aces1_state::m_aces1_irq_timer_callback),state), 0);
176   state->m_aces1_nmi_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(aces1_state::m_aces1_nmi_timer_callback),state), 0);
177177}
178178
179179void aces1_state::machine_start()
trunk/src/mame/drivers/mjsister.c
r18114r18115
6161   virtual void machine_reset();
6262   virtual void video_start();
6363   UINT32 screen_update_mjsister(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
64   TIMER_CALLBACK_MEMBER(dac_callback);
6465};
6566
6667
r18114r18115
165166 *
166167 *************************************/
167168
168static TIMER_CALLBACK( dac_callback )
169TIMER_CALLBACK_MEMBER(mjsister_state::dac_callback)
169170{
170   mjsister_state *state = machine.driver_data<mjsister_state>();
171   UINT8 *DACROM = state->memregion("samples")->base();
171   UINT8 *DACROM = memregion("samples")->base();
172172
173   state->m_dac->write_unsigned8(DACROM[(state->m_dac_bank * 0x10000 + state->m_dac_adr++) & 0x1ffff]);
173   m_dac->write_unsigned8(DACROM[(m_dac_bank * 0x10000 + m_dac_adr++) & 0x1ffff]);
174174
175   if (((state->m_dac_adr & 0xff00 ) >> 8) !=  state->m_dac_adr_e)
176      machine.scheduler().timer_set(attotime::from_hz(MCLK) * 1024, FUNC(dac_callback));
175   if (((m_dac_adr & 0xff00 ) >> 8) !=  m_dac_adr_e)
176      machine().scheduler().timer_set(attotime::from_hz(MCLK) * 1024, timer_expired_delegate(FUNC(mjsister_state::dac_callback),this));
177177   else
178      state->m_dac_busy = 0;
178      m_dac_busy = 0;
179179}
180180
181181WRITE8_MEMBER(mjsister_state::mjsister_dac_adr_s_w)
r18114r18115
189189   m_dac_adr = m_dac_adr_s << 8;
190190
191191   if (m_dac_busy == 0)
192      machine().scheduler().synchronize(FUNC(dac_callback));
192      machine().scheduler().synchronize(timer_expired_delegate(FUNC(mjsister_state::dac_callback),this));
193193
194194   m_dac_busy = 1;
195195}
trunk/src/mame/drivers/vegas.c
r18114r18115
502502   virtual void machine_start();
503503   virtual void machine_reset();
504504   UINT32 screen_update_vegas(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
505   TIMER_CALLBACK_MEMBER(nile_timer_callback);
505506};
506507
507508
r18114r18115
512513 *
513514 *************************************/
514515
515static TIMER_CALLBACK( nile_timer_callback );
516
516517static void ide_interrupt(device_t *device, int state);
517518static void remap_dynamic_addresses(running_machine &machine);
518519
r18114r18115
543544   /* allocate timers for the NILE */
544545   m_timer[0] = machine().scheduler().timer_alloc(FUNC_NULL);
545546   m_timer[1] = machine().scheduler().timer_alloc(FUNC_NULL);
546   m_timer[2] = machine().scheduler().timer_alloc(FUNC(nile_timer_callback));
547   m_timer[3] = machine().scheduler().timer_alloc(FUNC(nile_timer_callback));
547   m_timer[2] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vegas_state::nile_timer_callback),this));
548   m_timer[3] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vegas_state::nile_timer_callback),this));
548549
549550   /* identify our sound board */
550551   if (machine().device("dsio") != NULL)
r18114r18115
918919}
919920
920921
921static TIMER_CALLBACK( nile_timer_callback )
922TIMER_CALLBACK_MEMBER(vegas_state::nile_timer_callback)
922923{
923   vegas_state *state = machine.driver_data<vegas_state>();
924924   int which = param;
925   UINT32 *regs = &state->m_nile_regs[NREG_T0CTRL + which * 4];
925   UINT32 *regs = &m_nile_regs[NREG_T0CTRL + which * 4];
926926   if (LOG_TIMERS) logerror("timer %d fired\n", which);
927927
928928   /* adjust the timer to fire again */
r18114r18115
931931      if (regs[1] & 2)
932932         logerror("Unexpected value: timer %d is prescaled\n", which);
933933      if (scale != 0)
934         state->m_timer[which]->adjust(TIMER_PERIOD * scale, which);
934         m_timer[which]->adjust(TIMER_PERIOD * scale, which);
935935   }
936936
937937   /* trigger the interrupt */
938938   if (which == 2)
939      state->m_nile_irq_state |= 1 << 6;
939      m_nile_irq_state |= 1 << 6;
940940   if (which == 3)
941      state->m_nile_irq_state |= 1 << 5;
941      m_nile_irq_state |= 1 << 5;
942942
943   update_nile_irqs(machine);
943   update_nile_irqs(machine());
944944}
945945
946946
trunk/src/mame/drivers/rabbit.c
r18114r18115
139139   virtual void video_start();
140140   UINT32 screen_update_rabbit(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
141141   INTERRUPT_GEN_MEMBER(rabbit_vblank_interrupt);
142   TIMER_CALLBACK_MEMBER(rabbit_blit_done);
142143};
143144
144145
r18114r18115
558559#define BLITCMDLOG 0
559560#define BLITLOG 0
560561
561static TIMER_CALLBACK( rabbit_blit_done )
562TIMER_CALLBACK_MEMBER(rabbit_state::rabbit_blit_done)
562563{
563   rabbit_state *state = machine.driver_data<rabbit_state>();
564   machine.device("maincpu")->execute().set_input_line(state->m_bltirqlevel, HOLD_LINE);
564   machine().device("maincpu")->execute().set_input_line(m_bltirqlevel, HOLD_LINE);
565565}
566566
567567static void rabbit_do_blit(running_machine &machine)
r18114r18115
609609            if (!blt_amount)
610610            {
611611               if(BLITLOG) mame_printf_debug("end of blit list\n");
612               machine.scheduler().timer_set(attotime::from_usec(500), FUNC(rabbit_blit_done));
612               machine.scheduler().timer_set(attotime::from_usec(500), timer_expired_delegate(FUNC(rabbit_state::rabbit_blit_done),state));
613613               return;
614614            }
615615
trunk/src/mame/drivers/taitogn.c
r18114r18115
388388   DECLARE_DRIVER_INIT(coh3002t_mp);
389389   DECLARE_DRIVER_INIT(coh3002t);
390390   DECLARE_MACHINE_RESET(coh3002t);
391   TIMER_CALLBACK_MEMBER(dip_timer_fired);
391392};
392393
393394
r18114r18115
782783        }
783784}
784785
785static TIMER_CALLBACK( dip_timer_fired )
786TIMER_CALLBACK_MEMBER(taitogn_state::dip_timer_fired)
786787{
787   taitogn_state *state = machine.driver_data<taitogn_state>();
788788
789   psx_sio_input( machine, 0, PSX_SIO_IN_DSR, param * PSX_SIO_IN_DSR );
789   psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, param * PSX_SIO_IN_DSR );
790790
791791   if( param )
792792   {
793      state->m_dip_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(50));
793      m_dip_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(50));
794794   }
795795}
796796
r18114r18115
868868   znsec_init(0, tt10);
869869   znsec_init(1, tt16);
870870   psx_sio_install_handler(machine(), 0, sio_pad_handler);
871   m_dip_timer = machine().scheduler().timer_alloc( FUNC(dip_timer_fired), NULL );
871   m_dip_timer = machine().scheduler().timer_alloc( timer_expired_delegate(FUNC(taitogn_state::dip_timer_fired),this), NULL );
872872
873873   UINT32 metalength;
874874   memset(m_cis, 0xff, 512);
trunk/src/mame/drivers/ssfindo.c
r18114r18115
248248   virtual void machine_reset();
249249   UINT32 screen_update_ssfindo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
250250   INTERRUPT_GEN_MEMBER(ssfindo_interrupt);
251   TIMER_CALLBACK_MEMBER(PS7500_Timer0_callback);
252   TIMER_CALLBACK_MEMBER(PS7500_Timer1_callback);
251253};
252254
253255
r18114r18115
290292      m_PS7500_FIFO[1]++; //autoinc
291293   }
292294}
293static TIMER_CALLBACK( PS7500_Timer0_callback )
295TIMER_CALLBACK_MEMBER(ssfindo_state::PS7500_Timer0_callback)
294296{
295   ssfindo_state *state = machine.driver_data<ssfindo_state>();
296   state->m_PS7500_IO[IRQSTA]|=0x20;
297   if(state->m_PS7500_IO[IRQMSKA]&0x20)
297   m_PS7500_IO[IRQSTA]|=0x20;
298   if(m_PS7500_IO[IRQMSKA]&0x20)
298299   {
299      generic_pulse_irq_line(machine.device("maincpu"), ARM7_IRQ_LINE, 1);
300      generic_pulse_irq_line(machine().device("maincpu")->execute(), ARM7_IRQ_LINE, 1);
300301   }
301302}
302303
r18114r18115
311312      state->m_PS7500timer0->adjust(attotime::from_usec(val ), 0, attotime::from_usec(val ));
312313}
313314
314static TIMER_CALLBACK( PS7500_Timer1_callback )
315TIMER_CALLBACK_MEMBER(ssfindo_state::PS7500_Timer1_callback)
315316{
316   ssfindo_state *state = machine.driver_data<ssfindo_state>();
317   state->m_PS7500_IO[IRQSTA]|=0x40;
318   if(state->m_PS7500_IO[IRQMSKA]&0x40)
317   m_PS7500_IO[IRQSTA]|=0x40;
318   if(m_PS7500_IO[IRQMSKA]&0x40)
319319   {
320      generic_pulse_irq_line(machine.device("maincpu"), ARM7_IRQ_LINE, 1);
320      generic_pulse_irq_line(machine().device("maincpu")->execute(), ARM7_IRQ_LINE, 1);
321321   }
322322}
323323
r18114r18115
857857DRIVER_INIT_MEMBER(ssfindo_state,common)
858858{
859859   ssfindo_speedup = 0;
860   m_PS7500timer0 = machine().scheduler().timer_alloc(FUNC(PS7500_Timer0_callback));
861   m_PS7500timer1 = machine().scheduler().timer_alloc(FUNC(PS7500_Timer1_callback));
860   m_PS7500timer0 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ssfindo_state::PS7500_Timer0_callback),this));
861   m_PS7500timer1 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ssfindo_state::PS7500_Timer1_callback),this));
862862
863863}
864864
trunk/src/mame/drivers/hornet.c
r18114r18115
371371   DECLARE_MACHINE_RESET(hornet_2board);
372372   UINT32 screen_update_hornet(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
373373   UINT32 screen_update_hornet_2board(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
374   TIMER_CALLBACK_MEMBER(irq_off);
374375};
375376
376377
r18114r18115
880881    NMI:    SCI
881882
882883*/
883static TIMER_CALLBACK( irq_off );
884884
885
885886void hornet_state::machine_start()
886887{
887888   m_jvs_sdata_ptr = 0;
r18114r18115
898899   state_save_register_global_pointer(machine(), m_jvs_sdata, 1024);
899900   state_save_register_global(machine(), m_jvs_sdata_ptr);
900901
901   m_sound_irq_timer = machine().scheduler().timer_alloc(FUNC(irq_off));
902   m_sound_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(hornet_state::irq_off),this));
902903}
903904
904905void hornet_state::machine_reset()
r18114r18115
933934   adc12138_input_callback
934935};
935936
936static TIMER_CALLBACK( irq_off )
937TIMER_CALLBACK_MEMBER(hornet_state::irq_off)
937938{
938   machine.device("audiocpu")->execute().set_input_line(param, CLEAR_LINE);
939   machine().device("audiocpu")->execute().set_input_line(param, CLEAR_LINE);
939940}
940941
941942static void sound_irq_callback( running_machine &machine, int irq )
trunk/src/mame/drivers/gpworld.c
r18114r18115
7373   virtual void machine_start();
7474   UINT32 screen_update_gpworld(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
7575   INTERRUPT_GEN_MEMBER(vblank_callback_gpworld);
76   TIMER_CALLBACK_MEMBER(irq_stop);
7677};
7778
7879
r18114r18115
425426   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
426427INPUT_PORTS_END
427428
428static TIMER_CALLBACK( irq_stop )
429TIMER_CALLBACK_MEMBER(gpworld_state::irq_stop)
429430{
430   machine.device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
431   machine().device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
431432}
432433
433434INTERRUPT_GEN_MEMBER(gpworld_state::vblank_callback_gpworld)
r18114r18115
442443
443444   /* The time the IRQ line stays high is set just long enough to happen after the NMI - hacky? */
444445   device.execute().set_input_line(0, ASSERT_LINE);
445   machine().scheduler().timer_set(attotime::from_usec(100), FUNC(irq_stop));
446   machine().scheduler().timer_set(attotime::from_usec(100), timer_expired_delegate(FUNC(gpworld_state::irq_stop),this));
446447}
447448
448449static const gfx_layout gpworld_tile_layout =
trunk/src/mame/drivers/jpmsys5.c
r18114r18115
107107   DECLARE_MACHINE_START(jpmsys5);
108108   DECLARE_MACHINE_RESET(jpmsys5);
109109   UINT32 screen_update_jpmsys5v(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
110   TIMER_CALLBACK_MEMBER(touch_cb);
110111};
111112
112113
r18114r18115
409410 *************************************/
410411
411412/* Serial bit transmission callback */
412static TIMER_CALLBACK( touch_cb )
413TIMER_CALLBACK_MEMBER(jpmsys5_state::touch_cb)
413414{
414   jpmsys5_state *state = machine.driver_data<jpmsys5_state>();
415   switch (state->m_touch_state)
415   switch (m_touch_state)
416416   {
417417      case IDLE:
418418      {
r18114r18115
420420      }
421421      case START:
422422      {
423         state->m_touch_shift_cnt = 0;
424         state->m_a2_data_in = 0;
425         state->m_touch_state = DATA;
423         m_touch_shift_cnt = 0;
424         m_a2_data_in = 0;
425         m_touch_state = DATA;
426426         break;
427427      }
428428      case DATA:
429429      {
430         state->m_a2_data_in = (state->m_touch_data[state->m_touch_data_count] >> (state->m_touch_shift_cnt)) & 1;
430         m_a2_data_in = (m_touch_data[m_touch_data_count] >> (m_touch_shift_cnt)) & 1;
431431
432         if (++state->m_touch_shift_cnt == 8)
433            state->m_touch_state = STOP1;
432         if (++m_touch_shift_cnt == 8)
433            m_touch_state = STOP1;
434434
435435         break;
436436      }
437437      case STOP1:
438438      {
439         state->m_a2_data_in = 1;
440         state->m_touch_state = STOP2;
439         m_a2_data_in = 1;
440         m_touch_state = STOP2;
441441         break;
442442      }
443443      case STOP2:
444444      {
445         state->m_a2_data_in = 1;
445         m_a2_data_in = 1;
446446
447         if (++state->m_touch_data_count == 3)
447         if (++m_touch_data_count == 3)
448448         {
449            state->m_touch_timer->reset();
450            state->m_touch_state = IDLE;
449            m_touch_timer->reset();
450            m_touch_state = IDLE;
451451         }
452452         else
453453         {
454            state->m_touch_state = START;
454            m_touch_state = START;
455455         }
456456
457457         break;
r18114r18115
690690MACHINE_START_MEMBER(jpmsys5_state,jpmsys5v)
691691{
692692   membank("bank1")->set_base(memregion("maincpu")->base()+0x20000);
693   m_touch_timer = machine().scheduler().timer_alloc(FUNC(touch_cb));
693   m_touch_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(jpmsys5_state::touch_cb),this));
694694}
695695
696696MACHINE_RESET_MEMBER(jpmsys5_state,jpmsys5v)
trunk/src/mame/drivers/esh.c
r18114r18115
5151   virtual void palette_init();
5252   UINT32 screen_update_esh(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
5353   INTERRUPT_GEN_MEMBER(vblank_callback_esh);
54   TIMER_CALLBACK_MEMBER(irq_stop);
5455};
5556
5657
r18114r18115
279280   GFXDECODE_ENTRY("gfx1", 0, esh_gfx_layout, 0x0, 0x20)
280281GFXDECODE_END
281282
282static TIMER_CALLBACK( irq_stop )
283TIMER_CALLBACK_MEMBER(esh_state::irq_stop)
283284{
284   machine.device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
285   machine().device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
285286}
286287
287288INTERRUPT_GEN_MEMBER(esh_state::vblank_callback_esh)
288289{
289290   // IRQ
290291   device.execute().set_input_line(0, ASSERT_LINE);
291   machine().scheduler().timer_set(attotime::from_usec(50), FUNC(irq_stop));
292   machine().scheduler().timer_set(attotime::from_usec(50), timer_expired_delegate(FUNC(esh_state::irq_stop),this));
292293}
293294
294295void esh_state::machine_start()
trunk/src/mame/drivers/aristmk4.c
r18114r18115
322322   virtual void palette_init();
323323   DECLARE_PALETTE_INIT(lions);
324324   UINT32 screen_update_aristmk4(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
325   TIMER_CALLBACK_MEMBER(note_input_reset);
326   TIMER_CALLBACK_MEMBER(coin_input_reset);
327   TIMER_CALLBACK_MEMBER(hopper_reset);
325328};
326329
327330/* Partial Cashcade protocol */
r18114r18115
484487
485488}
486489
487static TIMER_CALLBACK(note_input_reset)
490TIMER_CALLBACK_MEMBER(aristmk4_state::note_input_reset)
488491{
489   aristmk4_state *state = machine.driver_data<aristmk4_state>();
490   state->m_insnote=0; //reset note input after 150msec
492   m_insnote=0; //reset note input after 150msec
491493}
492494
493495READ8_MEMBER(aristmk4_state::bv_p0)
r18114r18115
504506   case 0x02:
505507      bv_p0_ret=0x89;
506508      m_insnote++;
507      machine().scheduler().timer_set(attotime::from_msec(150), FUNC(note_input_reset));
509      machine().scheduler().timer_set(attotime::from_msec(150), timer_expired_delegate(FUNC(aristmk4_state::note_input_reset),this));
508510      break;
509511   default:
510512      break; //timer will reset the input
r18114r18115
630632
631633******************************************************************************/
632634
633static TIMER_CALLBACK(coin_input_reset)
635TIMER_CALLBACK_MEMBER(aristmk4_state::coin_input_reset)
634636{
635   aristmk4_state *state = machine.driver_data<aristmk4_state>();
636   state->m_inscrd=0; //reset credit input after 150msec
637   m_inscrd=0; //reset credit input after 150msec
637638}
638639
639static TIMER_CALLBACK(hopper_reset)
640TIMER_CALLBACK_MEMBER(aristmk4_state::hopper_reset)
640641{
641   aristmk4_state *state = machine.driver_data<aristmk4_state>();
642   state->m_hopper_motor=0x01;
642   m_hopper_motor=0x01;
643643}
644644
645645// Port A read (SW1)
r18114r18115
686686   case 0x02:
687687      ret=ret^0x20;
688688      m_inscrd++;
689      machine().scheduler().timer_set(attotime::from_msec(150), FUNC(coin_input_reset));
689      machine().scheduler().timer_set(attotime::from_msec(150), timer_expired_delegate(FUNC(aristmk4_state::coin_input_reset),this));
690690      break;
691691   default:
692692      break; //timer will reset the input
r18114r18115
698698   {
699699   case 0x00:
700700      ret=ret^0x40;
701      machine().scheduler().timer_set(attotime::from_msec(175), FUNC(hopper_reset));
701      machine().scheduler().timer_set(attotime::from_msec(175), timer_expired_delegate(FUNC(aristmk4_state::hopper_reset),this));
702702      m_hopper_motor=0x02;
703703      break;
704704   case 0x01:
trunk/src/mame/drivers/sothello.c
r18114r18115
6666   DECLARE_READ8_MEMBER(subcpu_status_r);
6767   DECLARE_WRITE8_MEMBER(msm_cfg_w);
6868   virtual void machine_reset();
69   TIMER_CALLBACK_MEMBER(subcpu_suspend);
70   TIMER_CALLBACK_MEMBER(subcpu_resume);
6971};
7072
7173
r18114r18115
9496    membank("bank1")->set_base(&RAM[bank*0x4000+0x10000]);
9597}
9698
97static TIMER_CALLBACK( subcpu_suspend )
99TIMER_CALLBACK_MEMBER(sothello_state::subcpu_suspend)
98100{
99    machine.device<cpu_device>("sub")->suspend(SUSPEND_REASON_HALT, 1);
101    machine().device<cpu_device>("sub")->suspend(SUSPEND_REASON_HALT, 1);
100102}
101103
102static TIMER_CALLBACK( subcpu_resume )
104TIMER_CALLBACK_MEMBER(sothello_state::subcpu_resume)
103105{
104    machine.device<cpu_device>("sub")->resume(SUSPEND_REASON_HALT);
105    machine.device("sub")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
106    machine().device<cpu_device>("sub")->resume(SUSPEND_REASON_HALT);
107    machine().device("sub")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
106108}
107109
108110READ8_MEMBER(sothello_state::subcpu_halt_set)
109111{
110    machine().scheduler().synchronize(FUNC(subcpu_suspend));
112    machine().scheduler().synchronize(timer_expired_delegate(FUNC(sothello_state::subcpu_suspend),this));
111113    m_subcpu_status|=2;
112114    return 0;
113115}
114116
115117READ8_MEMBER(sothello_state::subcpu_halt_clear)
116118{
117    machine().scheduler().synchronize(FUNC(subcpu_resume));
119    machine().scheduler().synchronize(timer_expired_delegate(FUNC(sothello_state::subcpu_resume),this));
118120    m_subcpu_status&=~1;
119121    m_subcpu_status&=~2;
120122    return 0;
trunk/src/mame/drivers/astinvad.c
r18114r18115
8383   DECLARE_VIDEO_START(spaceint);
8484   UINT32 screen_update_astinvad(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
8585   UINT32 screen_update_spaceint(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
86   TIMER_CALLBACK_MEMBER(kamikaze_int_off);
87   TIMER_CALLBACK_MEMBER(kamizake_int_gen);
8688};
8789
8890
r18114r18115
219221 *
220222 *************************************/
221223
222static TIMER_CALLBACK( kamikaze_int_off )
224TIMER_CALLBACK_MEMBER(astinvad_state::kamikaze_int_off)
223225{
224   astinvad_state *state = machine.driver_data<astinvad_state>();
225   state->m_maincpu->set_input_line(0, CLEAR_LINE);
226   m_maincpu->set_input_line(0, CLEAR_LINE);
226227}
227228
228229
229static TIMER_CALLBACK( kamizake_int_gen )
230TIMER_CALLBACK_MEMBER(astinvad_state::kamizake_int_gen)
230231{
231   astinvad_state *state = machine.driver_data<astinvad_state>();
232232   /* interrupts are asserted on every state change of the 128V line */
233   state->m_maincpu->set_input_line(0, ASSERT_LINE);
233   m_maincpu->set_input_line(0, ASSERT_LINE);
234234   param ^= 128;
235   state->m_int_timer->adjust(machine.primary_screen->time_until_pos(param), param);
235   m_int_timer->adjust(machine().primary_screen->time_until_pos(param), param);
236236
237237   /* an RC circuit turns the interrupt off after a short amount of time */
238   machine.scheduler().timer_set(attotime::from_double(300 * 0.1e-6), FUNC(kamikaze_int_off));
238   machine().scheduler().timer_set(attotime::from_double(300 * 0.1e-6), timer_expired_delegate(FUNC(astinvad_state::kamikaze_int_off),this));
239239}
240240
241241
r18114r18115
244244
245245   m_samples = machine().device<samples_device>("samples");
246246
247   m_int_timer = machine().scheduler().timer_alloc(FUNC(kamizake_int_gen));
247   m_int_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(astinvad_state::kamizake_int_gen),this));
248248   m_int_timer->adjust(machine().primary_screen->time_until_pos(128), 128);
249249
250250   save_item(NAME(m_screen_flip));
trunk/src/mame/drivers/destroyr.c
r18114r18115
5252   virtual void machine_reset();
5353   virtual void palette_init();
5454   UINT32 screen_update_destroyr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
55   TIMER_CALLBACK_MEMBER(destroyr_dial_callback);
56   TIMER_CALLBACK_MEMBER(destroyr_frame_callback);
5557};
5658
5759
r18114r18115
121123   return 0;
122124}
123125
124static TIMER_CALLBACK( destroyr_dial_callback )
126TIMER_CALLBACK_MEMBER(destroyr_state::destroyr_dial_callback)
125127{
126   destroyr_state *state = machine.driver_data<destroyr_state>();
127128   int dial = param;
128129
129130   /* Analog inputs come from the player's depth control potentiometer.
r18114r18115
133134       computer then reads the VSYNC data functions to tell where the
134135       cursor should be located. */
135136
136   state->m_potsense[dial] = 1;
137   m_potsense[dial] = 1;
137138
138   if (state->m_potmask[dial])
139   if (m_potmask[dial])
139140   {
140      state->m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
141      m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
141142   }
142143}
143144
144145
145static TIMER_CALLBACK( destroyr_frame_callback )
146TIMER_CALLBACK_MEMBER(destroyr_state::destroyr_frame_callback)
146147{
147   destroyr_state *state = machine.driver_data<destroyr_state>();
148   state->m_potsense[0] = 0;
149   state->m_potsense[1] = 0;
148   m_potsense[0] = 0;
149   m_potsense[1] = 0;
150150
151151   /* PCB supports two dials, but cab has only got one */
152   machine.scheduler().timer_set(machine.primary_screen->time_until_pos(state->ioport("PADDLE")->read()), FUNC(destroyr_dial_callback));
153   machine.scheduler().timer_set(machine.primary_screen->time_until_pos(0), FUNC(destroyr_frame_callback));
152   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(ioport("PADDLE")->read()), timer_expired_delegate(FUNC(destroyr_state::destroyr_dial_callback),this));
153   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(0), timer_expired_delegate(FUNC(destroyr_state::destroyr_frame_callback),this));
154154}
155155
156156
157157void destroyr_state::machine_reset()
158158{
159159
160   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(0), FUNC(destroyr_frame_callback));
160   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(0), timer_expired_delegate(FUNC(destroyr_state::destroyr_frame_callback),this));
161161
162162   m_cursor = 0;
163163   m_wavemod = 0;
trunk/src/mame/drivers/multigam.c
r18114r18115
145145   DECLARE_MACHINE_RESET(multigm3);
146146   DECLARE_MACHINE_START(supergm3);
147147   UINT32 screen_update_multigam(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
148   TIMER_CALLBACK_MEMBER(mmc1_resync_callback);
148149};
149150
150151
r18114r18115
693694*******************************************************/
694695
695696
696static TIMER_CALLBACK( mmc1_resync_callback )
697TIMER_CALLBACK_MEMBER(multigam_state::mmc1_resync_callback)
697698{
698   multigam_state *state = machine.driver_data<multigam_state>();
699   state->m_mmc1_reg_write_enable = 1;
699   m_mmc1_reg_write_enable = 1;
700700}
701701
702702WRITE8_MEMBER(multigam_state::mmc1_rom_switch_w)
r18114r18115
710710   else
711711   {
712712      m_mmc1_reg_write_enable = 0;
713      machine().scheduler().synchronize(FUNC(mmc1_resync_callback));
713      machine().scheduler().synchronize(timer_expired_delegate(FUNC(multigam_state::mmc1_resync_callback),this));
714714   }
715715
716716   int reg = (offset >> 13);
trunk/src/mame/drivers/jangou.c
r18114r18115
9090   DECLARE_MACHINE_START(common);
9191   DECLARE_MACHINE_RESET(common);
9292   UINT32 screen_update_jangou(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
93   TIMER_CALLBACK_MEMBER(cvsd_bit_timer_callback);
9394};
9495
9596
r18114r18115
328329   m_cvsd_shiftreg = data;
329330}
330331
331static TIMER_CALLBACK( cvsd_bit_timer_callback )
332TIMER_CALLBACK_MEMBER(jangou_state::cvsd_bit_timer_callback)
332333{
333   jangou_state *state = machine.driver_data<jangou_state>();
334334
335335   /* Data is shifted out at the MSB */
336   hc55516_digit_w(state->m_cvsd, (state->m_cvsd_shiftreg >> 7) & 1);
337   state->m_cvsd_shiftreg <<= 1;
336   hc55516_digit_w(m_cvsd, (m_cvsd_shiftreg >> 7) & 1);
337   m_cvsd_shiftreg <<= 1;
338338
339339   /* Trigger an IRQ for every 8 shifted bits */
340   if ((++state->m_cvsd_shift_cnt & 7) == 0)
341      state->m_cpu_1->execute().set_input_line(0, HOLD_LINE);
340   if ((++m_cvsd_shift_cnt & 7) == 0)
341      m_cpu_1->execute().set_input_line(0, HOLD_LINE);
342342}
343343
344344
r18114r18115
907907   jangou_state *state = machine.driver_data<jangou_state>();
908908
909909   /* Create a timer to feed the CVSD DAC with sample bits */
910   state->m_cvsd_bit_timer = machine.scheduler().timer_alloc(FUNC(cvsd_bit_timer_callback));
910   state->m_cvsd_bit_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(jangou_state::cvsd_bit_timer_callback),state));
911911   state->m_cvsd_bit_timer->adjust(attotime::from_hz(MASTER_CLOCK / 1024), 0, attotime::from_hz(MASTER_CLOCK / 1024));
912912}
913913
trunk/src/mame/drivers/lgp.c
r18114r18115
8888   virtual void machine_start();
8989   UINT32 screen_update_lgp(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
9090   INTERRUPT_GEN_MEMBER(vblank_callback_lgp);
91   TIMER_CALLBACK_MEMBER(irq_stop);
9192};
9293
9394
r18114r18115
332333   GFXDECODE_ENTRY("gfx4", 0, lgp_gfx_layout_16x32, 0x0, 0x100)
333334GFXDECODE_END
334335
335static TIMER_CALLBACK( irq_stop )
336TIMER_CALLBACK_MEMBER(lgp_state::irq_stop)
336337{
337   machine.device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
338   machine().device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
338339}
339340
340341INTERRUPT_GEN_MEMBER(lgp_state::vblank_callback_lgp)
r18114r18115
350351
351352void lgp_state::machine_start()
352353{
353   m_irq_timer = machine().scheduler().timer_alloc(FUNC(irq_stop));
354   m_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(lgp_state::irq_stop),this));
354355}
355356
356357
trunk/src/mame/drivers/zr107.c
r18114r18115
208208   UINT32 screen_update_zr107(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
209209   UINT32 screen_update_jetwave(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
210210   INTERRUPT_GEN_MEMBER(zr107_vblank);
211   TIMER_CALLBACK_MEMBER(irq_off);
211212};
212213
213214
r18114r18115
677678};
678679
679680
680static TIMER_CALLBACK( irq_off )
681TIMER_CALLBACK_MEMBER(zr107_state::irq_off)
681682{
682   machine.device("audiocpu")->execute().set_input_line(param, CLEAR_LINE);
683   machine().device("audiocpu")->execute().set_input_line(param, CLEAR_LINE);
683684}
684685
685686static void sound_irq_callback( running_machine &machine, int irq )
686687{
688   zr107_state *state = machine.driver_data<zr107_state>();
687689   int line = (irq == 0) ? INPUT_LINE_IRQ1 : INPUT_LINE_IRQ2;
688690
689691   machine.device("audiocpu")->execute().set_input_line(line, ASSERT_LINE);
690   machine.scheduler().timer_set(attotime::from_usec(1), FUNC(irq_off), line);
692   machine.scheduler().timer_set(attotime::from_usec(1), timer_expired_delegate(FUNC(zr107_state::irq_off),state), line);
691693}
692694
693695static const k056800_interface zr107_k056800_interface =
trunk/src/mame/drivers/cliffhgr.c
r18114r18115
112112   DECLARE_DRIVER_INIT(cliff);
113113   virtual void machine_start();
114114   virtual void machine_reset();
115   TIMER_CALLBACK_MEMBER(cliff_irq_callback);
115116};
116117
117118
r18114r18115
186187
187188/********************************************************/
188189
189static TIMER_CALLBACK( cliff_irq_callback )
190TIMER_CALLBACK_MEMBER(cliffhgr_state::cliff_irq_callback)
190191{
191   cliffhgr_state *state = machine.driver_data<cliffhgr_state>();
192   state->m_phillips_code = 0;
192   m_phillips_code = 0;
193193
194194   switch (param)
195195   {
196196      case 17:
197         state->m_phillips_code = state->m_laserdisc->get_field_code(LASERDISC_CODE_LINE17, true);
197         m_phillips_code = m_laserdisc->get_field_code(LASERDISC_CODE_LINE17, true);
198198         param = 18;
199199         break;
200200
201201      case 18:
202         state->m_phillips_code = state->m_laserdisc->get_field_code(LASERDISC_CODE_LINE18, true);
202         m_phillips_code = m_laserdisc->get_field_code(LASERDISC_CODE_LINE18, true);
203203         param = 17;
204204         break;
205205   }
206206
207207   /* if we have a valid code, trigger an IRQ */
208   if (state->m_phillips_code & 0x800000)
208   if (m_phillips_code & 0x800000)
209209   {
210210//      printf("%2d:code = %06X\n", param, phillips_code);
211      machine.device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
211      machine().device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
212212   }
213213
214   state->m_irq_timer->adjust(machine.primary_screen->time_until_pos(param * 2), param);
214   m_irq_timer->adjust(machine().primary_screen->time_until_pos(param * 2), param);
215215}
216216
217217WRITE_LINE_MEMBER(cliffhgr_state::vdp_interrupt)
r18114r18115
223223
224224void cliffhgr_state::machine_start()
225225{
226   m_irq_timer = machine().scheduler().timer_alloc(FUNC(cliff_irq_callback));
226   m_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cliffhgr_state::cliff_irq_callback),this));
227227}
228228
229229void cliffhgr_state::machine_reset()
trunk/src/mame/drivers/mazerbla.c
r18114r18115
146146   UINT32 screen_update_mazerbla(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
147147   UINT32 screen_update_test_vcu(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
148148   INTERRUPT_GEN_MEMBER(sound_interrupt);
149   TIMER_CALLBACK_MEMBER(deferred_ls670_0_w);
150   TIMER_CALLBACK_MEMBER(deferred_ls670_1_w);
151   TIMER_CALLBACK_MEMBER(delayed_sound_w);
149152};
150153
151154
r18114r18115
790793   return m_ls670_0[offset];
791794}
792795
793static TIMER_CALLBACK( deferred_ls670_0_w )
796TIMER_CALLBACK_MEMBER(mazerbla_state::deferred_ls670_0_w)
794797{
795   mazerbla_state *state = machine.driver_data<mazerbla_state>();
796798   int offset = (param >> 8) & 255;
797799   int data = param & 255;
798800
799   state->m_ls670_0[offset] = data;
801   m_ls670_0[offset] = data;
800802}
801803
802804WRITE8_MEMBER(mazerbla_state::ls670_0_w)
803805{
804806   /* do this on a timer to let the CPUs synchronize */
805   machine().scheduler().synchronize(FUNC(deferred_ls670_0_w), (offset << 8) | data);
807   machine().scheduler().synchronize(timer_expired_delegate(FUNC(mazerbla_state::deferred_ls670_0_w),this), (offset << 8) | data);
806808}
807809
808810READ8_MEMBER(mazerbla_state::ls670_1_r)
r18114r18115
814816   return m_ls670_1[offset];
815817}
816818
817static TIMER_CALLBACK( deferred_ls670_1_w )
819TIMER_CALLBACK_MEMBER(mazerbla_state::deferred_ls670_1_w)
818820{
819   mazerbla_state *state = machine.driver_data<mazerbla_state>();
820821   int offset = (param >> 8) & 255;
821822   int data = param & 255;
822823
823   state->m_ls670_1[offset] = data;
824   m_ls670_1[offset] = data;
824825}
825826
826827WRITE8_MEMBER(mazerbla_state::ls670_1_w)
827828{
828829   /* do this on a timer to let the CPUs synchronize */
829   machine().scheduler().synchronize(FUNC(deferred_ls670_1_w), (offset << 8) | data);
830   machine().scheduler().synchronize(timer_expired_delegate(FUNC(mazerbla_state::deferred_ls670_1_w),this), (offset << 8) | data);
830831}
831832
832833
r18114r18115
955956   return m_soundlatch;
956957}
957958
958static TIMER_CALLBACK( delayed_sound_w )
959TIMER_CALLBACK_MEMBER(mazerbla_state::delayed_sound_w)
959960{
960   mazerbla_state *state = machine.driver_data<mazerbla_state>();
961   state->m_soundlatch = param;
961   m_soundlatch = param;
962962
963963   /* cause NMI on sound CPU */
964   state->m_subcpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
964   m_subcpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
965965}
966966
967967WRITE8_MEMBER(mazerbla_state::main_sound_w)
968968{
969   machine().scheduler().synchronize(FUNC(delayed_sound_w), data & 0xff);
969   machine().scheduler().synchronize(timer_expired_delegate(FUNC(mazerbla_state::delayed_sound_w),this), data & 0xff);
970970}
971971
972972WRITE8_MEMBER(mazerbla_state::sound_int_clear_w)
trunk/src/mame/drivers/acefruit.c
r18114r18115
4141   virtual void palette_init();
4242   UINT32 screen_update_acefruit(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4343   INTERRUPT_GEN_MEMBER(acefruit_vblank);
44   TIMER_CALLBACK_MEMBER(acefruit_refresh);
4445};
4546
4647
r18114r18115
6667}
6768
6869
69static TIMER_CALLBACK( acefruit_refresh )
70TIMER_CALLBACK_MEMBER(acefruit_state::acefruit_refresh)
7071{
71   acefruit_state *state = machine.driver_data<acefruit_state>();
72   int vpos = machine.primary_screen->vpos();
72   int vpos = machine().primary_screen->vpos();
7373
74   machine.primary_screen->update_partial(vpos );
75   acefruit_update_irq(machine, vpos );
74   machine().primary_screen->update_partial(vpos );
75   acefruit_update_irq(machine(), vpos );
7676
7777   vpos = ( ( vpos / 8 ) + 1 ) * 8;
7878
79   state->m_refresh_timer->adjust( machine.primary_screen->time_until_pos(vpos) );
79   m_refresh_timer->adjust( machine().primary_screen->time_until_pos(vpos) );
8080}
8181
8282void acefruit_state::video_start()
8383{
84   m_refresh_timer = machine().scheduler().timer_alloc(FUNC(acefruit_refresh));
84   m_refresh_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(acefruit_state::acefruit_refresh),this));
8585}
8686
8787INTERRUPT_GEN_MEMBER(acefruit_state::acefruit_vblank)
trunk/src/mame/drivers/cball.c
r18114r18115
3333   virtual void video_start();
3434   virtual void palette_init();
3535   UINT32 screen_update_cball(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
36   TIMER_CALLBACK_MEMBER(interrupt_callback);
3637};
3738
3839
r18114r18115
7475}
7576
7677
77static TIMER_CALLBACK( interrupt_callback )
78TIMER_CALLBACK_MEMBER(cball_state::interrupt_callback)
7879{
79   cball_state *state = machine.driver_data<cball_state>();
8080   int scanline = param;
8181
82   generic_pulse_irq_line(state->m_maincpu, 0, 1);
82   generic_pulse_irq_line(*m_maincpu, 0, 1);
8383
8484   scanline = scanline + 32;
8585
8686   if (scanline >= 262)
8787      scanline = 16;
8888
89   machine.scheduler().timer_set(machine.primary_screen->time_until_pos(scanline), FUNC(interrupt_callback), scanline);
89   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(scanline), timer_expired_delegate(FUNC(cball_state::interrupt_callback),this), scanline);
9090}
9191
9292
r18114r18115
9797
9898void cball_state::machine_reset()
9999{
100   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(16), FUNC(interrupt_callback), 16);
100   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(16), timer_expired_delegate(FUNC(cball_state::interrupt_callback),this), 16);
101101}
102102
103103
trunk/src/mame/drivers/mgolf.c
r18114r18115
3939   virtual void video_start();
4040   virtual void palette_init();
4141   UINT32 screen_update_mgolf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
42   TIMER_CALLBACK_MEMBER(interrupt_callback);
4243};
4344
4445
r18114r18115
113114}
114115
115116
116static TIMER_CALLBACK( interrupt_callback )
117TIMER_CALLBACK_MEMBER(mgolf_state::interrupt_callback)
117118{
118   mgolf_state *state = machine.driver_data<mgolf_state>();
119119   int scanline = param;
120120
121   update_plunger(machine);
121   update_plunger(machine());
122122
123   generic_pulse_irq_line(state->m_maincpu, 0, 1);
123   generic_pulse_irq_line(*m_maincpu, 0, 1);
124124
125125   scanline = scanline + 32;
126126
127127   if (scanline >= 262)
128128      scanline = 16;
129129
130   machine.scheduler().timer_set(machine.primary_screen->time_until_pos(scanline), FUNC(interrupt_callback), scanline);
130   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(scanline), timer_expired_delegate(FUNC(mgolf_state::interrupt_callback),this), scanline);
131131}
132132
133133
r18114r18115
316316
317317void mgolf_state::machine_reset()
318318{
319   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(16), FUNC(interrupt_callback), 16);
319   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(16), timer_expired_delegate(FUNC(mgolf_state::interrupt_callback),this), 16);
320320
321321   m_mask = 0;
322322   m_prev = 0;
trunk/src/mame/drivers/mlanding.c
r18114r18115
7878   virtual void machine_reset();
7979   virtual void video_start();
8080   UINT32 screen_update_mlanding(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
81   TIMER_CALLBACK_MEMBER(dma_complete);
8182};
8283
8384
r18114r18115
312313   }
313314}
314315
315static TIMER_CALLBACK( dma_complete )
316TIMER_CALLBACK_MEMBER(mlanding_state::dma_complete)
316317{
317   mlanding_state *state = machine.driver_data<mlanding_state>();
318   state->m_dma_active = 0;
318   m_dma_active = 0;
319319}
320320
321321/* TODO: this uses many bits */
r18114r18115
329329   if (pixels)
330330   {
331331      m_dma_active = 1;
332      machine().scheduler().timer_set(attotime::from_msec(20), FUNC(dma_complete));
332      machine().scheduler().timer_set(attotime::from_msec(20), timer_expired_delegate(FUNC(mlanding_state::dma_complete),this));
333333   }
334334
335335   if(!(data & 0x40)) // unknown line used
trunk/src/mame/drivers/missile.c
r18114r18115
382382   virtual void machine_start();
383383   virtual void machine_reset();
384384   UINT32 screen_update_missile(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
385   TIMER_CALLBACK_MEMBER(clock_irq);
386   TIMER_CALLBACK_MEMBER(adjust_cpu_speed);
385387};
386388
387389
r18114r18115
436438}
437439
438440
439static TIMER_CALLBACK( clock_irq )
441TIMER_CALLBACK_MEMBER(missile_state::clock_irq)
440442{
441   missile_state *state = machine.driver_data<missile_state>();
442443   int curv = param;
443444
444445   /* assert the IRQ if not already asserted */
445   state->m_irq_state = (~curv >> 5) & 1;
446   state->m_maincpu->set_input_line(0, state->m_irq_state ? ASSERT_LINE : CLEAR_LINE);
446   m_irq_state = (~curv >> 5) & 1;
447   m_maincpu->set_input_line(0, m_irq_state ? ASSERT_LINE : CLEAR_LINE);
447448
448449   /* force an update while we're here */
449   machine.primary_screen->update_partial(v_to_scanline(state, curv));
450   machine().primary_screen->update_partial(v_to_scanline(this, curv));
450451
451452   /* find the next edge */
452   schedule_next_irq(machine, curv);
453   schedule_next_irq(machine(), curv);
453454}
454455
455456
r18114r18115
468469 *
469470 *************************************/
470471
471static TIMER_CALLBACK( adjust_cpu_speed )
472TIMER_CALLBACK_MEMBER(missile_state::adjust_cpu_speed)
472473{
473   missile_state *state = machine.driver_data<missile_state>();
474474   int curv = param;
475475
476476   /* starting at scanline 224, the CPU runs at half speed */
477477   if (curv == 224)
478      state->m_maincpu->set_unscaled_clock(MASTER_CLOCK/16);
478      m_maincpu->set_unscaled_clock(MASTER_CLOCK/16);
479479   else
480      state->m_maincpu->set_unscaled_clock(MASTER_CLOCK/8);
480      m_maincpu->set_unscaled_clock(MASTER_CLOCK/8);
481481
482482   /* scanline for the next run */
483483   curv ^= 224;
484   state->m_cpu_timer->adjust(machine.primary_screen->time_until_pos(v_to_scanline(state, curv)), curv);
484   m_cpu_timer->adjust(machine().primary_screen->time_until_pos(v_to_scanline(this, curv)), curv);
485485}
486486
487487
r18114r18115
522522   space.set_direct_update_handler(direct_update_delegate(FUNC(missile_state::missile_direct_handler), this));
523523
524524   /* create a timer to speed/slow the CPU */
525   m_cpu_timer = machine().scheduler().timer_alloc(FUNC(adjust_cpu_speed));
525   m_cpu_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(missile_state::adjust_cpu_speed),this));
526526   m_cpu_timer->adjust(machine().primary_screen->time_until_pos(v_to_scanline(this, 0), 0));
527527
528528   /* create a timer for IRQs and set up the first callback */
529   m_irq_timer = machine().scheduler().timer_alloc(FUNC(clock_irq));
529   m_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(missile_state::clock_irq),this));
530530   m_irq_state = 0;
531531   schedule_next_irq(machine(), -32);
532532
trunk/src/mame/drivers/tickee.c
r18114r18115
5656   DECLARE_MACHINE_RESET(tickee);
5757   DECLARE_VIDEO_START(tickee);
5858   DECLARE_MACHINE_RESET(rapidfir);
59   TIMER_CALLBACK_MEMBER(trigger_gun_interrupt);
60   TIMER_CALLBACK_MEMBER(clear_gun_interrupt);
61   TIMER_CALLBACK_MEMBER(setup_gun_interrupts);
5962};
6063
6164
r18114r18115
8689 *
8790 *************************************/
8891
89static TIMER_CALLBACK( trigger_gun_interrupt )
92TIMER_CALLBACK_MEMBER(tickee_state::trigger_gun_interrupt)
9093{
91   tickee_state *state = machine.driver_data<tickee_state>();
9294   int which = param & 1;
93   int beamx = (machine.primary_screen->hpos()/2)-58;
95   int beamx = (machine().primary_screen->hpos()/2)-58;
9496
9597   /* once we're ready to fire, set the X coordinate and assert the line */
96   state->m_gunx[which] = beamx;
98   m_gunx[which] = beamx;
9799
98100   /* fire the IRQ at the correct moment */
99   machine.device("maincpu")->execute().set_input_line(param, ASSERT_LINE);
101   machine().device("maincpu")->execute().set_input_line(param, ASSERT_LINE);
100102}
101103
102104
103static TIMER_CALLBACK( clear_gun_interrupt )
105TIMER_CALLBACK_MEMBER(tickee_state::clear_gun_interrupt)
104106{
105107   /* clear the IRQ on the next scanline? */
106   machine.device("maincpu")->execute().set_input_line(param, CLEAR_LINE);
108   machine().device("maincpu")->execute().set_input_line(param, CLEAR_LINE);
107109}
108110
109111
110static TIMER_CALLBACK( setup_gun_interrupts )
112TIMER_CALLBACK_MEMBER(tickee_state::setup_gun_interrupts)
111113{
112   tickee_state *state = machine.driver_data<tickee_state>();
113114   int beamx, beamy;
114115
115116   /* set a timer to do this again next frame */
116   state->m_setup_gun_timer->adjust(machine.primary_screen->time_until_pos(0));
117   m_setup_gun_timer->adjust(machine().primary_screen->time_until_pos(0));
117118
118119   /* only do work if the palette is flashed */
119   if (state->m_control)
120      if (!state->m_control[2])
120   if (m_control)
121      if (!m_control[2])
121122         return;
122123
123124   /* generate interrupts for player 1's gun */
124   get_crosshair_xy(machine, 0, &beamx, &beamy);
125   machine.scheduler().timer_set(machine.primary_screen->time_until_pos(beamy + state->m_beamyadd, beamx + state->m_beamxadd), FUNC(trigger_gun_interrupt), 0);
126   machine.scheduler().timer_set(machine.primary_screen->time_until_pos(beamy + state->m_beamyadd + 1, beamx + state->m_beamxadd), FUNC(clear_gun_interrupt), 0);
125   get_crosshair_xy(machine(), 0, &beamx, &beamy);
126   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(beamy + m_beamyadd, beamx + m_beamxadd), timer_expired_delegate(FUNC(tickee_state::trigger_gun_interrupt),this), 0);
127   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(beamy + m_beamyadd + 1, beamx + m_beamxadd), timer_expired_delegate(FUNC(tickee_state::clear_gun_interrupt),this), 0);
127128
128129   /* generate interrupts for player 2's gun */
129   get_crosshair_xy(machine, 1, &beamx, &beamy);
130   machine.scheduler().timer_set(machine.primary_screen->time_until_pos(beamy + state->m_beamyadd, beamx + state->m_beamxadd), FUNC(trigger_gun_interrupt), 1);
131   machine.scheduler().timer_set(machine.primary_screen->time_until_pos(beamy + state->m_beamyadd + 1, beamx + state->m_beamxadd), FUNC(clear_gun_interrupt), 1);
130   get_crosshair_xy(machine(), 1, &beamx, &beamy);
131   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(beamy + m_beamyadd, beamx + m_beamxadd), timer_expired_delegate(FUNC(tickee_state::trigger_gun_interrupt),this), 1);
132   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(beamy + m_beamyadd + 1, beamx + m_beamxadd), timer_expired_delegate(FUNC(tickee_state::clear_gun_interrupt),this), 1);
132133}
133134
134135
r18114r18115
142143VIDEO_START_MEMBER(tickee_state,tickee)
143144{
144145   /* start a timer going on the first scanline of every frame */
145   m_setup_gun_timer = machine().scheduler().timer_alloc(FUNC(setup_gun_interrupts));
146   m_setup_gun_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(tickee_state::setup_gun_interrupts),this));
146147   m_setup_gun_timer->adjust(machine().primary_screen->time_until_pos(0));
147148}
148149
trunk/src/mame/drivers/alg.c
r18114r18115
5959   DECLARE_MACHINE_START(alg);
6060   DECLARE_MACHINE_RESET(alg);
6161   DECLARE_VIDEO_START(alg);
62   TIMER_CALLBACK_MEMBER(response_timer);
6263};
6364
64static TIMER_CALLBACK( response_timer );
6565
6666
6767
68
6869/*************************************
6970 *
7071 *  Lightgun reading
r18114r18115
115116MACHINE_START_MEMBER(alg_state,alg)
116117{
117118
118   m_serial_timer = machine().scheduler().timer_alloc(FUNC(response_timer));
119   m_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(alg_state::response_timer),this));
119120   m_serial_timer_active = FALSE;
120121}
121122
r18114r18115
133134 *
134135 *************************************/
135136
136static TIMER_CALLBACK( response_timer )
137TIMER_CALLBACK_MEMBER(alg_state::response_timer)
137138{
138   alg_state *state = machine.driver_data<alg_state>();
139139
140140   /* if we still have data to send, do it now */
141   if (state->m_laserdisc->data_available_r() == ASSERT_LINE)
141   if (m_laserdisc->data_available_r() == ASSERT_LINE)
142142   {
143      UINT8 data = state->m_laserdisc->data_r();
143      UINT8 data = m_laserdisc->data_r();
144144      if (data != 0x0a)
145145         mame_printf_debug("Sending serial data = %02X\n", data);
146      amiga_serial_in_w(machine, data);
146      amiga_serial_in_w(machine(), data);
147147   }
148148
149149   /* if there's more to come, set another timer */
150   if (state->m_laserdisc->data_available_r() == ASSERT_LINE)
151      state->m_serial_timer->adjust(amiga_get_serial_char_period(machine));
150   if (m_laserdisc->data_available_r() == ASSERT_LINE)
151      m_serial_timer->adjust(amiga_get_serial_char_period(machine()));
152152   else
153      state->m_serial_timer_active = FALSE;
153      m_serial_timer_active = FALSE;
154154}
155155
156156
trunk/src/mame/drivers/clayshoo.c
r18114r18115
4141   virtual void machine_start();
4242   virtual void machine_reset();
4343   UINT32 screen_update_clayshoo(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
44   TIMER_CALLBACK_MEMBER(reset_analog_bit);
4445};
4546
4647
r18114r18115
100101 *
101102 *************************************/
102103
103static TIMER_CALLBACK( reset_analog_bit )
104TIMER_CALLBACK_MEMBER(clayshoo_state::reset_analog_bit)
104105{
105   clayshoo_state *state = machine.driver_data<clayshoo_state>();
106   state->m_analog_port_val &= ~param;
106   m_analog_port_val &= ~param;
107107}
108108
109109
r18114r18115
137137static void create_analog_timers( running_machine &machine )
138138{
139139   clayshoo_state *state = machine.driver_data<clayshoo_state>();
140   state->m_analog_timer_1 = machine.scheduler().timer_alloc(FUNC(reset_analog_bit));
141   state->m_analog_timer_2 = machine.scheduler().timer_alloc(FUNC(reset_analog_bit));
140   state->m_analog_timer_1 = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(clayshoo_state::reset_analog_bit),state));
141   state->m_analog_timer_2 = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(clayshoo_state::reset_analog_bit),state));
142142}
143143
144144
trunk/src/mame/drivers/firebeat.c
r18114r18115
218218   DECLARE_READ32_MEMBER(ppc_spu_share_r);
219219   DECLARE_WRITE32_MEMBER(ppc_spu_share_w);
220220   DECLARE_READ16_MEMBER(spu_unk_r);   
221   TIMER_CALLBACK_MEMBER(keyboard_timer_callback);
221222};
222223
223224
r18114r18115
14751476   0x53,   // B2
14761477};
14771478
1478static TIMER_CALLBACK( keyboard_timer_callback )
1479TIMER_CALLBACK_MEMBER(firebeat_state::keyboard_timer_callback)
14791480{
1480   firebeat_state *state = machine.driver_data<firebeat_state>();
14811481   static const int kb_uart_channel[2] = { 1, 0 };
14821482   static const char *const keynames[] = { "KEYBOARD_P1", "KEYBOARD_P2" };
14831483   int keyboard;
r18114r18115
14851485
14861486   for (keyboard=0; keyboard < 2; keyboard++)
14871487   {
1488      UINT32 kbstate = machine.root_device().ioport(keynames[keyboard])->read();
1488      UINT32 kbstate = machine().root_device().ioport(keynames[keyboard])->read();
14891489      int uart_channel = kb_uart_channel[keyboard];
14901490
1491      if (kbstate != state->m_keyboard_state[keyboard])
1491      if (kbstate != m_keyboard_state[keyboard])
14921492      {
14931493         for (i=0; i < 24; i++)
14941494         {
14951495            int kbnote = keyboard_notes[i];
14961496
1497            if ((state->m_keyboard_state[keyboard] & (1 << i)) != 0 && (kbstate & (1 << i)) == 0)
1497            if ((m_keyboard_state[keyboard] & (1 << i)) != 0 && (kbstate & (1 << i)) == 0)
14981498            {
14991499               // key was on, now off -> send Note Off message
1500               pc16552d_rx_data(machine, 1, uart_channel, 0x80);
1501               pc16552d_rx_data(machine, 1, uart_channel, kbnote);
1502               pc16552d_rx_data(machine, 1, uart_channel, 0x7f);
1500               pc16552d_rx_data(machine(), 1, uart_channel, 0x80);
1501               pc16552d_rx_data(machine(), 1, uart_channel, kbnote);
1502               pc16552d_rx_data(machine(), 1, uart_channel, 0x7f);
15031503            }
1504            else if ((state->m_keyboard_state[keyboard] & (1 << i)) == 0 && (kbstate & (1 << i)) != 0)
1504            else if ((m_keyboard_state[keyboard] & (1 << i)) == 0 && (kbstate & (1 << i)) != 0)
15051505            {
15061506               // key was off, now on -> send Note On message
1507               pc16552d_rx_data(machine, 1, uart_channel, 0x90);
1508               pc16552d_rx_data(machine, 1, uart_channel, kbnote);
1509               pc16552d_rx_data(machine, 1, uart_channel, 0x7f);
1507               pc16552d_rx_data(machine(), 1, uart_channel, 0x90);
1508               pc16552d_rx_data(machine(), 1, uart_channel, kbnote);
1509               pc16552d_rx_data(machine(), 1, uart_channel, 0x7f);
15101510            }
15111511         }
15121512      }
15131513      else
15141514      {
15151515         // no messages, send Active Sense message instead
1516         pc16552d_rx_data(machine, 1, uart_channel, 0xfe);
1516         pc16552d_rx_data(machine(), 1, uart_channel, 0xfe);
15171517      }
15181518
1519      state->m_keyboard_state[keyboard] = kbstate;
1519      m_keyboard_state[keyboard] = kbstate;
15201520   }
15211521}
15221522
r18114r18115
22872287{
22882288   firebeat_state *state = machine.driver_data<firebeat_state>();
22892289   // set keyboard timer
2290   state->m_keyboard_timer = machine.scheduler().timer_alloc(FUNC(keyboard_timer_callback));
2290   state->m_keyboard_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(firebeat_state::keyboard_timer_callback),state));
22912291   state->m_keyboard_timer->adjust(attotime::from_msec(10), 0, attotime::from_msec(10));
22922292}
22932293
trunk/src/mame/drivers/tugboat.c
r18114r18115
5050   virtual void machine_reset();
5151   virtual void palette_init();
5252   UINT32 screen_update_tugboat(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
53   TIMER_CALLBACK_MEMBER(interrupt_gen);
5354};
5455
5556
r18114r18115
202203   DEVCB_NULL      /* IRQB */
203204};
204205
205static TIMER_CALLBACK( interrupt_gen )
206TIMER_CALLBACK_MEMBER(tugboat_state::interrupt_gen)
206207{
207   machine.device("maincpu")->execute().set_input_line(0, HOLD_LINE);
208   machine.scheduler().timer_set(machine.primary_screen->frame_period(), FUNC(interrupt_gen));
208   machine().device("maincpu")->execute().set_input_line(0, HOLD_LINE);
209   machine().scheduler().timer_set(machine().primary_screen->frame_period(), timer_expired_delegate(FUNC(tugboat_state::interrupt_gen),this));
209210}
210211
211212void tugboat_state::machine_reset()
212213{
213   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(30*8+4), FUNC(interrupt_gen));
214   machine().scheduler().timer_set(machine().primary_screen->time_until_pos(30*8+4), timer_expired_delegate(FUNC(tugboat_state::interrupt_gen),this));
214215}
215216
216217
trunk/src/mame/drivers/viper.c
r18114r18115
350350   virtual void machine_reset();
351351   UINT32 screen_update_viper(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
352352   INTERRUPT_GEN_MEMBER(viper_vblank);
353   TIMER_CALLBACK_MEMBER(epic_global_timer_callback);
354   TIMER_CALLBACK_MEMBER(ds2430_timer_callback);
353355};
354356
355357UINT32 viper_state::screen_update_viper(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
r18114r18115
609611}
610612#endif
611613
612static TIMER_CALLBACK(epic_global_timer_callback)
614TIMER_CALLBACK_MEMBER(viper_state::epic_global_timer_callback)
613615{
614616   int timer_num = param;
615617
r18114r18115
627629      epic.global_timer[timer_num].timer->reset();
628630   }
629631
630   mpc8240_interrupt(machine, MPC8240_GTIMER0_IRQ + timer_num);
632   mpc8240_interrupt(machine(), MPC8240_GTIMER0_IRQ + timer_num);
631633}
632634
633635
r18114r18115
11721174
11731175static void mpc8240_epic_init(running_machine &machine)
11741176{
1175   epic.global_timer[0].timer = machine.scheduler().timer_alloc(FUNC(epic_global_timer_callback));
1176   epic.global_timer[1].timer = machine.scheduler().timer_alloc(FUNC(epic_global_timer_callback));
1177   epic.global_timer[2].timer = machine.scheduler().timer_alloc(FUNC(epic_global_timer_callback));
1178   epic.global_timer[3].timer = machine.scheduler().timer_alloc(FUNC(epic_global_timer_callback));
1177   viper_state *state = machine.driver_data<viper_state>();
1178   epic.global_timer[0].timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(viper_state::epic_global_timer_callback),state));
1179   epic.global_timer[1].timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(viper_state::epic_global_timer_callback),state));
1180   epic.global_timer[2].timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(viper_state::epic_global_timer_callback),state));
1181   epic.global_timer[3].timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(viper_state::epic_global_timer_callback),state));
11791182}
11801183
11811184static void mpc8240_epic_reset(void)
r18114r18115
16061609static UINT8 ds2430_addr;
16071610
16081611
1609static TIMER_CALLBACK(ds2430_timer_callback)
1612TIMER_CALLBACK_MEMBER(viper_state::ds2430_timer_callback)
16101613{
16111614   printf("DS2430 timer callback\n");
16121615
r18114r18115
19651968
19661969void viper_state::machine_start()
19671970{
1968   ds2430_timer = machine().scheduler().timer_alloc(FUNC(ds2430_timer_callback));
1971   ds2430_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(viper_state::ds2430_timer_callback),this));
19691972   ds2430_bit_timer = machine().device<timer_device>("ds2430_timer2");
19701973   mpc8240_epic_init(machine());
19711974
trunk/src/mame/drivers/halleys.c
r18114r18115
266266   virtual void palette_init();
267267   UINT32 screen_update_halleys(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
268268   UINT32 screen_update_benberob(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
269   TIMER_CALLBACK_MEMBER(blitter_reset);
269270};
270271
271272
r18114r18115
10401041}
10411042
10421043
1043static TIMER_CALLBACK( blitter_reset )
1044TIMER_CALLBACK_MEMBER(halleys_state::blitter_reset)
10441045{
1045   halleys_state *state = machine.driver_data<halleys_state>();
1046   state->m_blitter_busy = 0;
1046   m_blitter_busy = 0;
10471047}
10481048
10491049
r18114r18115
22382238
22392239   init_common(machine());
22402240
2241   m_blitter_reset_timer = machine().scheduler().timer_alloc(FUNC(blitter_reset));
2241   m_blitter_reset_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(halleys_state::blitter_reset),this));
22422242}
22432243
22442244
trunk/src/mess/drivers/ip20.c
r18114r18115
6363   virtual void machine_start();
6464   virtual void video_start();
6565   UINT32 screen_update_ip204415(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
66   TIMER_CALLBACK_MEMBER(ip20_timer);
6667};
6768
6869
r18114r18115
495496{
496497}
497498
498static TIMER_CALLBACK(ip20_timer)
499TIMER_CALLBACK_MEMBER(ip20_state::ip20_timer)
499500{
500   ip20_state *state = machine.driver_data<ip20_state>();
501   ip20_state *state = machine().driver_data<ip20_state>();
501502
502503   // update RTC every 10 milliseconds
503   state->m_RTC.nTemp++;
504   if (state->m_RTC.nTemp >= 10)
504   m_RTC.nTemp++;
505   if (m_RTC.nTemp >= 10)
505506   {
506      state->m_RTC.nTemp = 0;
507      m_RTC.nTemp = 0;
507508      RTC_HUNDREDTH++;
508509
509510      if( ( RTC_HUNDREDTH & 0x0f ) == 0x0a )
r18114r18115
551552      }
552553   }
553554
554   machine.scheduler().timer_set(attotime::from_msec(1), FUNC(ip20_timer));
555   machine().scheduler().timer_set(attotime::from_msec(1), timer_expired_delegate(FUNC(ip20_state::ip20_timer),this));
555556}
556557
557558void ip20_state::machine_start()
r18114r18115
568569
569570   m_RTC.nTemp = 0;
570571
571   machine().scheduler().timer_set(attotime::from_msec(1), FUNC(ip20_timer));
572   machine().scheduler().timer_set(attotime::from_msec(1), timer_expired_delegate(FUNC(ip20_state::ip20_timer),this));
572573}
573574
574575static INPUT_PORTS_START( ip204415 )
trunk/src/mess/drivers/argo.c
r18114r18115
4949   virtual void video_start();
5050   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5151   DECLARE_DRIVER_INIT(argo);
52   TIMER_CALLBACK_MEMBER(argo_boot);
5253};
5354
5455// write to videoram if following 'out b9,61' otherwise write to the unknown 'extra' ram
r18114r18115
249250
250251
251252/* after the first 4 bytes have been read from ROM, switch the ram back in */
252static TIMER_CALLBACK( argo_boot )
253TIMER_CALLBACK_MEMBER(argo_state::argo_boot)
253254{
254   argo_state *state = machine.driver_data<argo_state>();
255   state->membank("boot")->set_entry(0);
255   membank("boot")->set_entry(0);
256256}
257257
258258void argo_state::machine_reset()
259259{
260260   membank("boot")->set_entry(1);
261   machine().scheduler().timer_set(attotime::from_usec(5), FUNC(argo_boot));
261   machine().scheduler().timer_set(attotime::from_usec(5), timer_expired_delegate(FUNC(argo_state::argo_boot),this));
262262}
263263
264264DRIVER_INIT_MEMBER(argo_state,argo)
trunk/src/mess/drivers/scv.c
r18114r18115
3838   virtual void machine_reset();
3939   virtual void palette_init();
4040   UINT32 screen_update_scv(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
41   TIMER_CALLBACK_MEMBER(scv_vb_callback);
4142};
4243
4344
r18114r18115
407408}
408409
409410
410static TIMER_CALLBACK( scv_vb_callback )
411TIMER_CALLBACK_MEMBER(scv_state::scv_vb_callback)
411412{
412   scv_state *state = machine.driver_data<scv_state>();
413   int vpos = machine.primary_screen->vpos();
413   int vpos = machine().primary_screen->vpos();
414414
415415   switch( vpos )
416416   {
417417   case 240:
418      machine.device("maincpu")->execute().set_input_line(UPD7810_INTF2, ASSERT_LINE);
418      machine().device("maincpu")->execute().set_input_line(UPD7810_INTF2, ASSERT_LINE);
419419      break;
420420   case 0:
421      machine.device("maincpu")->execute().set_input_line(UPD7810_INTF2, CLEAR_LINE);
421      machine().device("maincpu")->execute().set_input_line(UPD7810_INTF2, CLEAR_LINE);
422422      break;
423423   }
424424
425   state->m_vb_timer->adjust( machine.primary_screen->time_until_pos(( vpos + 1 ) % 262, 0 ) );
425   m_vb_timer->adjust( machine().primary_screen->time_until_pos(( vpos + 1 ) % 262, 0 ) );
426426}
427427
428428
r18114r18115
751751void scv_state::machine_start()
752752{
753753
754   m_vb_timer = machine().scheduler().timer_alloc(FUNC(scv_vb_callback));
754   m_vb_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(scv_state::scv_vb_callback),this));
755755}
756756
757757
trunk/src/mess/drivers/h19.c
r18114r18115
6666   UINT8 m_term_data;
6767   virtual void machine_reset();
6868   virtual void video_start();
69   TIMER_CALLBACK_MEMBER(h19_beepoff);
6970};
7071
7172
72static TIMER_CALLBACK( h19_beepoff )
73TIMER_CALLBACK_MEMBER(h19_state::h19_beepoff)
7374{
74   h19_state *state = machine.driver_data<h19_state>();
75   beep_set_state(state->m_beep, 0);
75   beep_set_state(m_beep, 0);
7676}
7777
7878READ8_MEMBER( h19_state::h19_80_r )
r18114r18115
9999
100100   UINT8 length = (offset & 0x20) ? 200 : 4;
101101   beep_set_state(m_beep, 1);
102   machine().scheduler().timer_set(attotime::from_msec(length), FUNC(h19_beepoff));
102   machine().scheduler().timer_set(attotime::from_msec(length), timer_expired_delegate(FUNC(h19_state::h19_beepoff),this));
103103}
104104
105105static ADDRESS_MAP_START(h19_mem, AS_PROGRAM, 8, h19_state)
trunk/src/mess/drivers/tec1.c
r18114r18115
108108   UINT8 tec1_convert_col_to_bin( UINT8 col, UINT8 row );
109109   virtual void machine_reset();
110110   virtual void machine_start();
111   TIMER_CALLBACK_MEMBER(tec1_kbd_callback);
111112};
112113
113114
r18114r18115
209210   return data;
210211}
211212
212static TIMER_CALLBACK( tec1_kbd_callback )
213TIMER_CALLBACK_MEMBER(tec1_state::tec1_kbd_callback)
213214{
214215   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3" };
215   tec1_state *state = machine.driver_data<tec1_state>();
216216   UINT8 i;
217217
218218    // Display the digits. Blank any digits that haven't been refreshed for a while.
219219    // This will fix the problem reported by a user.
220220   for (i = 0; i < 6; i++)
221221   {
222      if (BIT(state->m_digit, i))
222      if (BIT(m_digit, i))
223223      {
224         state->m_refresh[i] = 1;
225         output_set_digit_value(i, state->m_segment);
224         m_refresh[i] = 1;
225         output_set_digit_value(i, m_segment);
226226      }
227227      else
228      if (state->m_refresh[i] == 0x80)
228      if (m_refresh[i] == 0x80)
229229      {
230230         output_set_digit_value(i, 0);
231         state->m_refresh[i] = 0;
231         m_refresh[i] = 0;
232232      }
233233      else
234      if (state->m_refresh[i])
235         state->m_refresh[i]++;
234      if (m_refresh[i])
235         m_refresh[i]++;
236236   }
237237
238238    // 74C923 4 by 5 key encoder.
239239    // if previous key is still held, bail out
240   if (machine.root_device().ioport(keynames[state->m_kbd_row])->read())
241      if (state->tec1_convert_col_to_bin(machine.root_device().ioport(keynames[state->m_kbd_row])->read(), state->m_kbd_row) == state->m_kbd)
240   if (machine().root_device().ioport(keynames[m_kbd_row])->read())
241      if (tec1_convert_col_to_bin(machine().root_device().ioport(keynames[m_kbd_row])->read(), m_kbd_row) == m_kbd)
242242         return;
243243
244   state->m_kbd_row++;
245   state->m_kbd_row &= 3;
244   m_kbd_row++;
245   m_kbd_row &= 3;
246246
247247   /* see if a key pressed */
248   if (machine.root_device().ioport(keynames[state->m_kbd_row])->read())
248   if (machine().root_device().ioport(keynames[m_kbd_row])->read())
249249   {
250      state->m_kbd = state->tec1_convert_col_to_bin(machine.root_device().ioport(keynames[state->m_kbd_row])->read(), state->m_kbd_row);
251      machine.device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, HOLD_LINE);
252      state->m_key_pressed = TRUE;
250      m_kbd = tec1_convert_col_to_bin(machine().root_device().ioport(keynames[m_kbd_row])->read(), m_kbd_row);
251      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, HOLD_LINE);
252      m_key_pressed = TRUE;
253253   }
254254   else
255      state->m_key_pressed = FALSE;
255      m_key_pressed = FALSE;
256256}
257257
258258
r18114r18115
264264
265265void tec1_state::machine_start()
266266{
267   m_kbd_timer = machine().scheduler().timer_alloc(FUNC(tec1_kbd_callback));
267   m_kbd_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(tec1_state::tec1_kbd_callback),this));
268268   m_kbd_timer->adjust( attotime::zero, 0, attotime::from_hz(500) );
269269}
270270
trunk/src/mess/drivers/okean240.c
r18114r18115
8080   virtual void video_start();
8181   DECLARE_DRIVER_INIT(okean240);
8282   UINT32 screen_update_okean240(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
83   TIMER_CALLBACK_MEMBER(okean240_boot);
8384};
8485
8586// okean240 requires bit 4 to change
r18114r18115
356357
357358
358359/* after the first 6 bytes have been read from ROM, switch the ram back in */
359static TIMER_CALLBACK( okean240_boot )
360TIMER_CALLBACK_MEMBER(okean240_state::okean240_boot)
360361{
361   okean240_state *state = machine.driver_data<okean240_state>();
362   state->membank("boot")->set_entry(0);
362   membank("boot")->set_entry(0);
363363}
364364
365365void okean240_state::machine_reset()
366366{
367   machine().scheduler().timer_set(attotime::from_usec(10), FUNC(okean240_boot));
367   machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(okean240_state::okean240_boot),this));
368368   membank("boot")->set_entry(1);
369369   m_term_data = 0;
370370   m_j = 0;
trunk/src/mess/drivers/amico2k.c
r18114r18115
5252
5353   // timers
5454   emu_timer *m_led_refresh_timer;
55   TIMER_CALLBACK_MEMBER(led_refresh);
5556};
5657
5758
r18114r18115
9798   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
9899INPUT_PORTS_END
99100
100static TIMER_CALLBACK( led_refresh )
101TIMER_CALLBACK_MEMBER(amico2k_state::led_refresh)
101102{
102   amico2k_state *state = machine.driver_data<amico2k_state>();
103103
104   if (state->m_ls145_p > 3)
104   if (m_ls145_p > 3)
105105   {
106      output_set_digit_value(state->m_ls145_p - 4, state->m_segment);
106      output_set_digit_value(m_ls145_p - 4, m_segment);
107107   }
108108}
109109
r18114r18115
206206
207207void amico2k_state::machine_start()
208208{
209   m_led_refresh_timer = machine().scheduler().timer_alloc(FUNC(led_refresh));
209   m_led_refresh_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(amico2k_state::led_refresh),this));
210210
211211   // state saving
212212   save_item(NAME(m_ls145_p));
trunk/src/mess/drivers/a2600.c
r18114r18115
114114   virtual void machine_reset();
115115   DECLARE_MACHINE_START(a2600);
116116   DECLARE_MACHINE_START(a2600p);
117   TIMER_CALLBACK_MEMBER(modeDPC_timer_callback);
117118};
118119
119120
r18114r18115
959960   modeDPC_check_flag(data_fetcher );
960961}
961962
962static TIMER_CALLBACK(modeDPC_timer_callback)
963TIMER_CALLBACK_MEMBER(a2600_state::modeDPC_timer_callback)
963964{
964   a2600_state *state = machine.driver_data<a2600_state>();
965965   int data_fetcher;
966966   for( data_fetcher = 5; data_fetcher < 8; data_fetcher++ )
967967   {
968      if ( state->m_dpc.df[data_fetcher].osc_clk )
968      if ( m_dpc.df[data_fetcher].osc_clk )
969969      {
970         state->modeDPC_decrement_counter(data_fetcher );
970         modeDPC_decrement_counter(data_fetcher );
971971      }
972972   }
973973}
r18114r18115
15921592   state->m_extra_RAM = machine.memory().region_alloc("user2", 0x8600, 1, ENDIANNESS_LITTLE);
15931593   memset( state->m_riot_ram, 0x00, 0x80 );
15941594   state->m_current_reset_bank_counter = 0xFF;
1595   state->m_dpc.oscillator = machine.scheduler().timer_alloc(FUNC(modeDPC_timer_callback));
1595   state->m_dpc.oscillator = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(a2600_state::modeDPC_timer_callback),state));
15961596}
15971597
15981598MACHINE_START_MEMBER(a2600_state,a2600)
trunk/src/mess/drivers/ng_aes.c
r18114r18115
9393   DECLARE_MACHINE_RESET(neogeo);
9494   DECLARE_CUSTOM_INPUT_MEMBER(get_memcard_status);
9595
96   TIMER_CALLBACK_MEMBER(display_position_interrupt_callback);
97   TIMER_CALLBACK_MEMBER(display_position_vblank_callback);
98   TIMER_CALLBACK_MEMBER(vblank_interrupt_callback);
9699};
97100
98101
r18114r18115
171174}
172175
173176
174static TIMER_CALLBACK( display_position_interrupt_callback )
177TIMER_CALLBACK_MEMBER(ng_aes_state::display_position_interrupt_callback)
175178{
176   neogeo_state *state = machine.driver_data<neogeo_state>();
177179
178   if (LOG_VIDEO_SYSTEM) logerror("--- Scanline @ %d,%d\n", machine.primary_screen->vpos(), machine.primary_screen->hpos());
180   if (LOG_VIDEO_SYSTEM) logerror("--- Scanline @ %d,%d\n", machine().primary_screen->vpos(), machine().primary_screen->hpos());
179181
180   if (state->m_display_position_interrupt_control & IRQ2CTRL_ENABLE)
182   if (m_display_position_interrupt_control & IRQ2CTRL_ENABLE)
181183   {
182      if (LOG_VIDEO_SYSTEM) logerror("*** Scanline interrupt (IRQ2) ***  y: %02x  x: %02x\n", machine.primary_screen->vpos(), machine.primary_screen->hpos());
183      state->m_display_position_interrupt_pending = 1;
184      if (LOG_VIDEO_SYSTEM) logerror("*** Scanline interrupt (IRQ2) ***  y: %02x  x: %02x\n", machine().primary_screen->vpos(), machine().primary_screen->hpos());
185      m_display_position_interrupt_pending = 1;
184186
185      update_interrupts(machine);
187      update_interrupts(machine());
186188   }
187189
188   if (state->m_display_position_interrupt_control & IRQ2CTRL_AUTOLOAD_REPEAT)
190   if (m_display_position_interrupt_control & IRQ2CTRL_AUTOLOAD_REPEAT)
189191   {
190192      if (LOG_VIDEO_SYSTEM) logerror("AUTOLOAD_REPEAT ");
191      adjust_display_position_interrupt_timer(machine);
193      adjust_display_position_interrupt_timer(machine());
192194   }
193195}
194196
195197
196static TIMER_CALLBACK( display_position_vblank_callback )
198TIMER_CALLBACK_MEMBER(ng_aes_state::display_position_vblank_callback)
197199{
198   neogeo_state *state = machine.driver_data<neogeo_state>();
199200
200   if (state->m_display_position_interrupt_control & IRQ2CTRL_AUTOLOAD_VBLANK)
201   if (m_display_position_interrupt_control & IRQ2CTRL_AUTOLOAD_VBLANK)
201202   {
202203      if (LOG_VIDEO_SYSTEM) logerror("AUTOLOAD_VBLANK ");
203      adjust_display_position_interrupt_timer(machine);
204      adjust_display_position_interrupt_timer(machine());
204205   }
205206
206207   /* set timer for next screen */
207   state->m_display_position_vblank_timer->adjust(machine.primary_screen->time_until_pos(NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS));
208   m_display_position_vblank_timer->adjust(machine().primary_screen->time_until_pos(NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS));
208209}
209210
210211
211static TIMER_CALLBACK( vblank_interrupt_callback )
212TIMER_CALLBACK_MEMBER(ng_aes_state::vblank_interrupt_callback)
212213{
213   neogeo_state *state = machine.driver_data<neogeo_state>();
214214
215   if (LOG_VIDEO_SYSTEM) logerror("+++ VBLANK @ %d,%d\n", machine.primary_screen->vpos(), machine.primary_screen->hpos());
215   if (LOG_VIDEO_SYSTEM) logerror("+++ VBLANK @ %d,%d\n", machine().primary_screen->vpos(), machine().primary_screen->hpos());
216216
217217   /* add a timer tick to the pd4990a */
218   upd4990a_addretrace(state->m_upd4990a);
218   upd4990a_addretrace(m_upd4990a);
219219
220   state->m_vblank_interrupt_pending = 1;
220   m_vblank_interrupt_pending = 1;
221221
222   update_interrupts(machine);
222   update_interrupts(machine());
223223
224224   /* set timer for next screen */
225   state->m_vblank_interrupt_timer->adjust(machine.primary_screen->time_until_pos(NEOGEO_VBSTART, 0));
225   m_vblank_interrupt_timer->adjust(machine().primary_screen->time_until_pos(NEOGEO_VBSTART, 0));
226226}
227227
228228
229229static void create_interrupt_timers( running_machine &machine )
230230{
231   neogeo_state *state = machine.driver_data<neogeo_state>();
232   state->m_display_position_interrupt_timer = machine.scheduler().timer_alloc(FUNC(display_position_interrupt_callback));
233   state->m_display_position_vblank_timer = machine.scheduler().timer_alloc(FUNC(display_position_vblank_callback));
234   state->m_vblank_interrupt_timer = machine.scheduler().timer_alloc(FUNC(vblank_interrupt_callback));
231   ng_aes_state *state = machine.driver_data<ng_aes_state>();
232   state->m_display_position_interrupt_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(ng_aes_state::display_position_interrupt_callback),state));
233   state->m_display_position_vblank_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(ng_aes_state::display_position_vblank_callback),state));
234   state->m_vblank_interrupt_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(ng_aes_state::vblank_interrupt_callback),state));
235235}
236236
237237
trunk/src/mess/drivers/mekd2.c
r18114r18115
6565   UINT8 m_segment;
6666   UINT8 m_digit;
6767   UINT8 m_keydata;
68   TIMER_CALLBACK_MEMBER(mekd2_trace);
6869};
6970
7071
r18114r18115
159160
160161************************************************************/
161162
162static TIMER_CALLBACK( mekd2_trace )
163TIMER_CALLBACK_MEMBER(mekd2_state::mekd2_trace)
163164{
164   machine.device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
165   machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
165166}
166167
167168WRITE_LINE_MEMBER( mekd2_state::mekd2_nmi_w )
r18114r18115
169170   if (state)
170171      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
171172   else
172      machine().scheduler().timer_set(attotime::from_usec(18), FUNC(mekd2_trace));
173      machine().scheduler().timer_set(attotime::from_usec(18), timer_expired_delegate(FUNC(mekd2_state::mekd2_trace),this));
173174}
174175
175176
trunk/src/mess/drivers/a7000.c
r18114r18115
5555   virtual void machine_start();
5656
5757   UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
58   TIMER_CALLBACK_MEMBER(IOMD_timer0_callback);
59   TIMER_CALLBACK_MEMBER(IOMD_timer1_callback);
60   TIMER_CALLBACK_MEMBER(flyback_timer_callback);
5861};
5962
6063
r18114r18115
568571      m_IOMD_timer[timer]->adjust(attotime::from_usec(val), 0, attotime::from_usec(val));
569572}
570573
571static TIMER_CALLBACK( IOMD_timer0_callback )
574TIMER_CALLBACK_MEMBER(a7000_state::IOMD_timer0_callback)
572575{
573   a7000_state *state = machine.driver_data<a7000_state>();
574   state->m_IRQ_status_A|=0x20;
575   if(state->m_IRQ_mask_A&0x20)
576   m_IRQ_status_A|=0x20;
577   if(m_IRQ_mask_A&0x20)
576578   {
577      generic_pulse_irq_line(machine.device("maincpu"), ARM7_IRQ_LINE,1);
579      generic_pulse_irq_line(machine().device("maincpu")->execute(), ARM7_IRQ_LINE,1);
578580   }
579581}
580582
581static TIMER_CALLBACK( IOMD_timer1_callback )
583TIMER_CALLBACK_MEMBER(a7000_state::IOMD_timer1_callback)
582584{
583   a7000_state *state = machine.driver_data<a7000_state>();
584   state->m_IRQ_status_A|=0x40;
585   if(state->m_IRQ_mask_A&0x40)
585   m_IRQ_status_A|=0x40;
586   if(m_IRQ_mask_A&0x40)
586587   {
587      generic_pulse_irq_line(machine.device("maincpu"), ARM7_IRQ_LINE,1);
588      generic_pulse_irq_line(machine().device("maincpu")->execute(), ARM7_IRQ_LINE,1);
588589   }
589590}
590591
591static TIMER_CALLBACK( flyback_timer_callback )
592TIMER_CALLBACK_MEMBER(a7000_state::flyback_timer_callback)
592593{
593   a7000_state *state = machine.driver_data<a7000_state>();
594   state->m_IRQ_status_A|=0x08;
595   if(state->m_IRQ_mask_A&0x08)
594   m_IRQ_status_A|=0x08;
595   if(m_IRQ_mask_A&0x08)
596596   {
597      generic_pulse_irq_line(machine.device("maincpu"), ARM7_IRQ_LINE,1);
597      generic_pulse_irq_line(machine().device("maincpu")->execute(), ARM7_IRQ_LINE,1);
598598   }
599599
600   state->m_flyback_timer->adjust(machine.primary_screen->time_until_pos(state->m_vidc20_vert_reg[VDER]));
600   m_flyback_timer->adjust(machine().primary_screen->time_until_pos(m_vidc20_vert_reg[VDER]));
601601}
602602
603603void a7000_state::viddma_transfer_start()
r18114r18115
766766
767767void a7000_state::machine_start()
768768{
769   m_IOMD_timer[0] = machine().scheduler().timer_alloc(FUNC(IOMD_timer0_callback));
770   m_IOMD_timer[1] = machine().scheduler().timer_alloc(FUNC(IOMD_timer1_callback));
771   m_flyback_timer = machine().scheduler().timer_alloc(FUNC(flyback_timer_callback));
769   m_IOMD_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(a7000_state::IOMD_timer0_callback),this));
770   m_IOMD_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(a7000_state::IOMD_timer1_callback),this));
771   m_flyback_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(a7000_state::flyback_timer_callback),this));
772772
773773   m_io_id = 0xd4e7;
774774}
trunk/src/mess/drivers/ip22.c
r18114r18115
132132   virtual void machine_start();
133133   virtual void machine_reset();
134134   INTERRUPT_GEN_MEMBER(ip22_vbl);
135   TIMER_CALLBACK_MEMBER(ip22_dma);
136   TIMER_CALLBACK_MEMBER(ip22_timer);
135137};
136138
137139
r18114r18115
10731075#define PBUS_DMADESC_BC         0x00003fff
10741076
10751077
1076static TIMER_CALLBACK(ip22_dma)
1078TIMER_CALLBACK_MEMBER(ip22_state::ip22_dma)
10771079{
1078   //ip22_state *state = machine.driver_data<ip22_state>();
1079   machine.scheduler().timer_set(attotime::never, FUNC(ip22_dma));
1080   machine().scheduler().timer_set(attotime::never, timer_expired_delegate(FUNC(ip22_state::ip22_dma),this));
10801081#if 0
1081   if( state->m_PBUS_DMA.nActive )
1082   if( m_PBUS_DMA.nActive )
10821083   {
1083      UINT16 temp16 = ( state->m_mainram[(state->m_PBUS_DMA.nCurPtr - 0x08000000)/4] & 0xffff0000 ) >> 16;
1084      UINT16 temp16 = ( m_mainram[(m_PBUS_DMA.nCurPtr - 0x08000000)/4] & 0xffff0000 ) >> 16;
10841085      INT16 stemp16 = (INT16)((temp16 >> 8) | (temp16 << 8));
10851086
1086      machine.device<dac_device>("dac")->write_signed16(stemp16 ^ 0x8000);
1087      machine().device<dac_device>("dac")->write_signed16(stemp16 ^ 0x8000);
10871088
1088      state->m_PBUS_DMA.nCurPtr += 4;
1089      m_PBUS_DMA.nCurPtr += 4;
10891090
1090      state->m_PBUS_DMA.nWordsLeft -= 4;
1091      if( state->m_PBUS_DMA.nWordsLeft == 0 )
1091      m_PBUS_DMA.nWordsLeft -= 4;
1092      if( m_PBUS_DMA.nWordsLeft == 0 )
10921093      {
1093         if( state->m_PBUS_DMA.nNextPtr != 0 )
1094         if( m_PBUS_DMA.nNextPtr != 0 )
10941095         {
1095            state->m_PBUS_DMA.nDescPtr = state->m_PBUS_DMA.nNextPtr;
1096            state->m_PBUS_DMA.nCurPtr = state->m_mainram[(state->m_PBUS_DMA.nDescPtr - 0x08000000)/4];
1097            state->m_PBUS_DMA.nWordsLeft = state->m_mainram[(state->m_PBUS_DMA.nDescPtr - 0x08000000)/4+1];
1098            state->m_PBUS_DMA.nNextPtr = state->m_mainram[(state->m_PBUS_DMA.nDescPtr - 0x08000000)/4+2];
1096            m_PBUS_DMA.nDescPtr = m_PBUS_DMA.nNextPtr;
1097            m_PBUS_DMA.nCurPtr = m_mainram[(m_PBUS_DMA.nDescPtr - 0x08000000)/4];
1098            m_PBUS_DMA.nWordsLeft = m_mainram[(m_PBUS_DMA.nDescPtr - 0x08000000)/4+1];
1099            m_PBUS_DMA.nNextPtr = m_mainram[(m_PBUS_DMA.nDescPtr - 0x08000000)/4+2];
10991100         }
11001101         else
11011102         {
1102            state->m_PBUS_DMA.nActive = 0;
1103            m_PBUS_DMA.nActive = 0;
11031104            return;
11041105         }
11051106      }
1106      machine.scheduler().timer_set(attotime::from_hz(44100), FUNC(ip22_dma));
1107      machine().scheduler().timer_set(attotime::from_hz(44100), timer_expired_delegate(FUNC(ip22_state::ip22_dma),this));
11071108   }
11081109#endif
11091110}
r18114r18115
11731174      //verboselog((machine, 0, "    FIFO End: Rowe %04x\n", ( data & PBUS_CTRL_FIFO_END ) >> 24 );
11741175      if( ( data & PBUS_CTRL_DMASTART ) || ( data & PBUS_CTRL_LOAD_EN ) )
11751176      {
1176         machine().scheduler().timer_set(attotime::from_hz(44100), FUNC(ip22_dma));
1177         machine().scheduler().timer_set(attotime::from_hz(44100), timer_expired_delegate(FUNC(ip22_state::ip22_dma),this));
11771178         m_PBUS_DMA.nActive = 1;
11781179      }
11791180      return;
r18114r18115
12161217ADDRESS_MAP_END
12171218
12181219
1219static TIMER_CALLBACK(ip22_timer)
1220TIMER_CALLBACK_MEMBER(ip22_state::ip22_timer)
12201221{
1221   machine.scheduler().timer_set(attotime::from_msec(1), FUNC(ip22_timer));
1222   machine().scheduler().timer_set(attotime::from_msec(1), timer_expired_delegate(FUNC(ip22_state::ip22_timer),this));
12221223}
12231224
12241225void ip22_state::machine_reset()
r18114r18115
12301231   RTC_REGISTERB = 0x08;
12311232   RTC_REGISTERD = 0x80;
12321233
1233   machine().scheduler().timer_set(attotime::from_msec(1), FUNC(ip22_timer));
1234   machine().scheduler().timer_set(attotime::from_msec(1), timer_expired_delegate(FUNC(ip22_state::ip22_timer),this));
12341235
12351236   // set up low RAM mirror
12361237   membank("bank1")->set_base(m_mainram);
trunk/src/mess/drivers/socrates.c
r18114r18115
129129   virtual void palette_init();
130130   UINT32 screen_update_socrates(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
131131   INTERRUPT_GEN_MEMBER(assert_irq);
132   TIMER_CALLBACK_MEMBER(clear_speech_cb);
133   TIMER_CALLBACK_MEMBER(clear_irq_cb);
132134};
133135
134136
r18114r18115
331333   logerror("read from i/o 0x4x of %x\n", temp);
332334   return temp;
333335}
334static TIMER_CALLBACK( clear_speech_cb )
336TIMER_CALLBACK_MEMBER(socrates_state::clear_speech_cb)
335337{
336   socrates_state *state = machine.driver_data<socrates_state>();
337   state->m_speech_running = 0;
338   state->m_speech_load_address_count = 0; // should this be here or in the write functuon subpart which is speak command?
339   state->m_speech_load_settings_count = 0;
338   m_speech_running = 0;
339   m_speech_load_address_count = 0; // should this be here or in the write functuon subpart which is speak command?
340   m_speech_load_settings_count = 0;
340341}
341342
342343WRITE8_MEMBER(socrates_state::speech_command)// write 0x4x, some sort of bitfield; speech chip is probably hitachi hd38880 related but not exact, w/4 bit interface
r18114r18115
399400         {
400401            /* write me: start talking */
401402            m_speech_running = 1;
402            machine().scheduler().timer_set(attotime::from_seconds(4), FUNC(clear_speech_cb)); // hack
403            machine().scheduler().timer_set(attotime::from_seconds(4), timer_expired_delegate(FUNC(socrates_state::clear_speech_cb),this)); // hack
403404         }
404405         break;
405406      case 0x90: // unknown, one of these is probably read and branch
r18114r18115
423424         if ((data&0xF) == 0) // speak
424425         {
425426            m_speech_running = 1;
426            machine().scheduler().timer_set(attotime::from_seconds(4), FUNC(clear_speech_cb)); // hack
427            machine().scheduler().timer_set(attotime::from_seconds(4), timer_expired_delegate(FUNC(socrates_state::clear_speech_cb),this)); // hack
427428         }
428429         else if ((data&0xF) == 8) // reset
429430         {
r18114r18115
903904/******************************************************************************
904905 Machine Drivers
905906******************************************************************************/
906static TIMER_CALLBACK( clear_irq_cb )
907TIMER_CALLBACK_MEMBER(socrates_state::clear_irq_cb)
907908{
908   socrates_state *state = machine.driver_data<socrates_state>();
909   machine.device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
910   state->m_vblankstate = 0;
909   machine().device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
910   m_vblankstate = 0;
911911}
912912
913913INTERRUPT_GEN_MEMBER(socrates_state::assert_irq)
914914{
915915   device.execute().set_input_line(0, ASSERT_LINE);
916   machine().scheduler().timer_set(downcast<cpu_device *>(&device)->cycles_to_attotime(44), FUNC(clear_irq_cb));
916   machine().scheduler().timer_set(downcast<cpu_device *>(&device)->cycles_to_attotime(44), timer_expired_delegate(FUNC(socrates_state::clear_irq_cb),this));
917917// 44 is a complete and total guess, need to properly measure how many clocks/microseconds the int line is high for.
918918   m_vblankstate = 1;
919919   m_kbmcu_rscount = 0; // clear the mcu poke count
trunk/src/mess/drivers/vii.c
r18114r18115
141141   virtual void video_start();
142142   UINT32 screen_update_vii(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
143143   INTERRUPT_GEN_MEMBER(vii_vblank);
144   TIMER_CALLBACK_MEMBER(tmb1_tick);
145   TIMER_CALLBACK_MEMBER(tmb2_tick);
144146};
145147
146148enum
r18114r18115
979981   return IMAGE_INIT_PASS;
980982}
981983
982static TIMER_CALLBACK( tmb1_tick )
984TIMER_CALLBACK_MEMBER(vii_state::tmb1_tick)
983985{
984   vii_state *state = machine.driver_data<vii_state>();
985   state->m_io_regs[0x22] |= 1;
986   m_io_regs[0x22] |= 1;
986987}
987988
988static TIMER_CALLBACK( tmb2_tick )
989TIMER_CALLBACK_MEMBER(vii_state::tmb2_tick)
989990{
990   vii_state *state = machine.driver_data<vii_state>();
991   state->m_io_regs[0x22] |= 2;
991   m_io_regs[0x22] |= 2;
992992}
993993
994994void vii_state::machine_start()
r18114r18115
10121012   m_video_regs[0x36] = 0xffff;
10131013   m_video_regs[0x37] = 0xffff;
10141014
1015   m_tmb1 = machine().scheduler().timer_alloc(FUNC(tmb1_tick));
1016   m_tmb2 = machine().scheduler().timer_alloc(FUNC(tmb2_tick));
1015   m_tmb1 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vii_state::tmb1_tick),this));
1016   m_tmb2 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vii_state::tmb2_tick),this));
10171017   m_tmb1->reset();
10181018   m_tmb2->reset();
10191019}
trunk/src/mess/drivers/supracan.c
r18114r18115
203203   UINT32 screen_update_supracan(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
204204   INTERRUPT_GEN_MEMBER(supracan_irq);
205205   INTERRUPT_GEN_MEMBER(supracan_sound_irq);
206   TIMER_CALLBACK_MEMBER(supracan_hbl_callback);
207   TIMER_CALLBACK_MEMBER(supracan_line_on_callback);
208   TIMER_CALLBACK_MEMBER(supracan_line_off_callback);
209   TIMER_CALLBACK_MEMBER(supracan_video_callback);
206210};
207211
208212
r18114r18115
14881492   return data;
14891493}
14901494
1491static TIMER_CALLBACK( supracan_hbl_callback )
1495TIMER_CALLBACK_MEMBER(supracan_state::supracan_hbl_callback)
14921496{
1493   supracan_state *state = machine.driver_data<supracan_state>();
14941497
1495   state->m_maincpu->set_input_line(3, HOLD_LINE);
1498   m_maincpu->set_input_line(3, HOLD_LINE);
14961499
1497   state->m_hbl_timer->adjust(attotime::never);
1500   m_hbl_timer->adjust(attotime::never);
14981501}
14991502
1500static TIMER_CALLBACK( supracan_line_on_callback )
1503TIMER_CALLBACK_MEMBER(supracan_state::supracan_line_on_callback)
15011504{
1502   supracan_state *state = machine.driver_data<supracan_state>();
15031505
1504   state->m_maincpu->set_input_line(5, HOLD_LINE);
1506   m_maincpu->set_input_line(5, HOLD_LINE);
15051507
1506   state->m_line_on_timer->adjust(attotime::never);
1508   m_line_on_timer->adjust(attotime::never);
15071509}
15081510
1509static TIMER_CALLBACK( supracan_line_off_callback )
1511TIMER_CALLBACK_MEMBER(supracan_state::supracan_line_off_callback)
15101512{
1511   supracan_state *state = machine.driver_data<supracan_state>();
15121513
1513   state->m_maincpu->set_input_line(5, CLEAR_LINE);
1514   m_maincpu->set_input_line(5, CLEAR_LINE);
15141515
1515   state->m_line_on_timer->adjust(attotime::never);
1516   m_line_on_timer->adjust(attotime::never);
15161517}
15171518
1518static TIMER_CALLBACK( supracan_video_callback )
1519TIMER_CALLBACK_MEMBER(supracan_state::supracan_video_callback)
15191520{
1520   supracan_state *state = machine.driver_data<supracan_state>();
1521   int vpos = machine.primary_screen->vpos();
1521   int vpos = machine().primary_screen->vpos();
15221522
1523   state->m_video_regs[0] &= ~0x0002;
1523   m_video_regs[0] &= ~0x0002;
15241524
15251525   switch( vpos )
15261526   {
15271527   case 0:
1528      state->m_video_regs[0] &= 0x7fff;
1528      m_video_regs[0] &= 0x7fff;
15291529
15301530      // we really need better management of this
1531      mark_active_tilemap_all_dirty(machine, 0);
1532      mark_active_tilemap_all_dirty(machine, 1);
1533      mark_active_tilemap_all_dirty(machine, 2);
1534      mark_active_tilemap_all_dirty(machine, 3);
1531      mark_active_tilemap_all_dirty(machine(), 0);
1532      mark_active_tilemap_all_dirty(machine(), 1);
1533      mark_active_tilemap_all_dirty(machine(), 2);
1534      mark_active_tilemap_all_dirty(machine(), 3);
15351535
15361536
15371537      break;
15381538
15391539   case 224://FIXME: Son of Evil is pretty picky about this one, a timing of 240 makes it to crash
1540      state->m_video_regs[0] |= 0x8000;
1540      m_video_regs[0] |= 0x8000;
15411541      break;
15421542
15431543   case 240:
1544      if(state->m_irq_mask & 1)
1544      if(m_irq_mask & 1)
15451545      {
1546         verboselog("maincpu", machine, 0, "Triggering VBL IRQ\n\n");
1547         state->m_maincpu->set_input_line(7, HOLD_LINE);
1546         verboselog("maincpu", machine(), 0, "Triggering VBL IRQ\n\n");
1547         m_maincpu->set_input_line(7, HOLD_LINE);
15481548      }
15491549      break;
15501550   }
15511551
1552   state->m_video_regs[1] = machine.primary_screen->vpos()-16; // for son of evil, wants vblank active around 224 instead...
1552   m_video_regs[1] = machine().primary_screen->vpos()-16; // for son of evil, wants vblank active around 224 instead...
15531553
1554   state->m_hbl_timer->adjust( machine.primary_screen->time_until_pos( vpos, 320 ) );
1555   state->m_video_timer->adjust( machine.primary_screen->time_until_pos( ( vpos + 1 ) % 256, 0 ) );
1554   m_hbl_timer->adjust( machine().primary_screen->time_until_pos( vpos, 320 ) );
1555   m_video_timer->adjust( machine().primary_screen->time_until_pos( ( vpos + 1 ) % 256, 0 ) );
15561556}
15571557
15581558WRITE16_MEMBER( supracan_state::supracan_video_w )
r18114r18115
17741774void supracan_state::machine_start()
17751775{
17761776
1777   m_video_timer = machine().scheduler().timer_alloc(FUNC(supracan_video_callback));
1778   m_hbl_timer = machine().scheduler().timer_alloc(FUNC(supracan_hbl_callback));
1779   m_line_on_timer = machine().scheduler().timer_alloc(FUNC(supracan_line_on_callback));
1780   m_line_off_timer = machine().scheduler().timer_alloc(FUNC(supracan_line_off_callback));
1777   m_video_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(supracan_state::supracan_video_callback),this));
1778   m_hbl_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(supracan_state::supracan_hbl_callback),this));
1779   m_line_on_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(supracan_state::supracan_line_on_callback),this));
1780   m_line_off_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(supracan_state::supracan_line_off_callback),this));
17811781}
17821782
17831783
trunk/src/mess/drivers/tutor.c
r18114r18115
206206   DECLARE_DRIVER_INIT(pyuuta);
207207   virtual void machine_start();
208208   virtual void machine_reset();
209   TIMER_CALLBACK_MEMBER(tape_interrupt_handler);
209210};
210211
211212
212213/* mapper state */
213214
214215/* tape interface state */
215static TIMER_CALLBACK(tape_interrupt_handler);
216216
217217
218
218219/* parallel interface state */
219220
220221enum
r18114r18115
226227
227228DRIVER_INIT_MEMBER(tutor_state,tutor)
228229{
229   m_tape_interrupt_timer = machine().scheduler().timer_alloc(FUNC(tape_interrupt_handler));
230   m_tape_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(tutor_state::tape_interrupt_handler),this));
230231
231232   membank("bank1")->configure_entry(0, machine().root_device().memregion("maincpu")->base() + basic_base);
232233   membank("bank1")->configure_entry(1, memregion("maincpu")->base() + cartridge_base);
r18114r18115
400401    know their exact meaning.
401402*/
402403
403static TIMER_CALLBACK(tape_interrupt_handler)
404TIMER_CALLBACK_MEMBER(tutor_state::tape_interrupt_handler)
404405{
405   tutor_state *state = machine.driver_data<tutor_state>();
406   //assert(state->m_tape_interrupt_enable);
407   machine.device("maincpu")->execute().set_input_line(1, (state->m_cass->input() > 0.0) ? ASSERT_LINE : CLEAR_LINE);
406   //assert(m_tape_interrupt_enable);
407   machine().device("maincpu")->execute().set_input_line(1, (m_cass->input() > 0.0) ? ASSERT_LINE : CLEAR_LINE);
408408}
409409
410410/* CRU handler */
trunk/src/mess/drivers/pv1000.c
r18114r18115
100100   virtual void machine_reset();
101101   virtual void palette_init();
102102   UINT32 screen_update_pv1000(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
103   TIMER_CALLBACK_MEMBER(d65010_irq_on_cb);
104   TIMER_CALLBACK_MEMBER(d65010_irq_off_cb);
103105};
104106
105107
r18114r18115
345347
346348/* Interrupt is triggering 16 times during vblank. */
347349/* we have chosen to trigger on scanlines 195, 199, 203, 207, 211, 215, 219, 223, 227, 231, 235, 239, 243, 247, 251, 255 */
348static TIMER_CALLBACK( d65010_irq_on_cb )
350TIMER_CALLBACK_MEMBER(pv1000_state::d65010_irq_on_cb)
349351{
350   pv1000_state *state = machine.driver_data<pv1000_state>();
351   int vpos = state->m_screen->vpos();
352   int vpos = m_screen->vpos();
352353   int next_vpos = vpos + 12;
353354
354355   /* Set IRQ line and schedule release of IRQ line */
355   state->m_maincpu->set_input_line(0, ASSERT_LINE );
356   state->m_irq_off_timer->adjust( state->m_screen->time_until_pos(vpos, 380/2 ) );
356   m_maincpu->set_input_line(0, ASSERT_LINE );
357   m_irq_off_timer->adjust( m_screen->time_until_pos(vpos, 380/2 ) );
357358
358359   /* Schedule next IRQ trigger */
359360   if ( vpos >= 255 )
360361   {
361362      next_vpos = 195;
362363   }
363   state->m_irq_on_timer->adjust( state->m_screen->time_until_pos(next_vpos, 0 ) );
364   m_irq_on_timer->adjust( m_screen->time_until_pos(next_vpos, 0 ) );
364365}
365366
366367
367static TIMER_CALLBACK( d65010_irq_off_cb )
368TIMER_CALLBACK_MEMBER(pv1000_state::d65010_irq_off_cb)
368369{
369   pv1000_state *state = machine.driver_data<pv1000_state>();
370370
371   state->m_maincpu->set_input_line(0, CLEAR_LINE );
371   m_maincpu->set_input_line(0, CLEAR_LINE );
372372}
373373
374374
375375void pv1000_state::machine_start()
376376{
377377
378   m_irq_on_timer = machine().scheduler().timer_alloc(FUNC(d65010_irq_on_cb));
379   m_irq_off_timer = machine().scheduler().timer_alloc(FUNC(d65010_irq_off_cb));
378   m_irq_on_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pv1000_state::d65010_irq_on_cb),this));
379   m_irq_off_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pv1000_state::d65010_irq_off_cb),this));
380380}
381381
382382
trunk/src/mess/drivers/sys2900.c
r18114r18115
4747   virtual void machine_reset();
4848   virtual void video_start();
4949   UINT32 screen_update_sys2900(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
50   TIMER_CALLBACK_MEMBER(sys2900_boot);
5051};
5152
5253
r18114r18115
6970
7071
7172/* after the first 4 bytes have been read from ROM, switch the ram back in */
72static TIMER_CALLBACK( sys2900_boot )
73TIMER_CALLBACK_MEMBER(sys2900_state::sys2900_boot)
7374{
74   sys2900_state *state = machine.driver_data<sys2900_state>();
75   state->membank("boot")->set_entry(0);
75   membank("boot")->set_entry(0);
7676}
7777
7878void sys2900_state::machine_reset()
7979{
8080   membank("boot")->set_entry(1);
81   machine().scheduler().timer_set(attotime::from_usec(5), FUNC(sys2900_boot));
81   machine().scheduler().timer_set(attotime::from_usec(5), timer_expired_delegate(FUNC(sys2900_state::sys2900_boot),this));
8282}
8383
8484DRIVER_INIT_MEMBER(sys2900_state,sys2900)
trunk/src/mess/drivers/cat.c
r18114r18115
7171   DECLARE_VIDEO_START(swyft);
7272   UINT32 screen_update_cat(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7373   UINT32 screen_update_swyft(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
74   TIMER_CALLBACK_MEMBER(keyboard_callback);
75   TIMER_CALLBACK_MEMBER(swyft_reset);
7476};
7577
7678WRITE16_MEMBER( cat_state::cat_video_status_w )
r18114r18115
297299INPUT_PORTS_END
298300
299301
300static TIMER_CALLBACK(keyboard_callback)
302TIMER_CALLBACK_MEMBER(cat_state::keyboard_callback)
301303{
302   machine.device("maincpu")->execute().set_input_line(M68K_IRQ_1, ASSERT_LINE);
304   machine().device("maincpu")->execute().set_input_line(M68K_IRQ_1, ASSERT_LINE);
303305}
304306
305307static IRQ_CALLBACK(cat_int_ack)
r18114r18115
312314{
313315
314316   m_duart_inp = 0x0e;
315   m_keyboard_timer = machine().scheduler().timer_alloc(FUNC(keyboard_callback));
317   m_keyboard_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cat_state::keyboard_callback),this));
316318   machine().device<nvram_device>("nvram")->set_base(m_p_sram, 0x4000);
317319}
318320
r18114r18115
353355   return 0;
354356}
355357
356static TIMER_CALLBACK( swyft_reset )
358TIMER_CALLBACK_MEMBER(cat_state::swyft_reset)
357359{
358   memset(machine.device("maincpu")->memory().space(AS_PROGRAM).get_read_ptr(0xe2341), 0xff, 1);
360   memset(machine().device("maincpu")->memory().space(AS_PROGRAM).get_read_ptr(0xe2341), 0xff, 1);
359361}
360362
361363MACHINE_START_MEMBER(cat_state,swyft)
r18114r18115
364366
365367MACHINE_RESET_MEMBER(cat_state,swyft)
366368{
367   machine().scheduler().timer_set(attotime::from_usec(10), FUNC(swyft_reset));
369   machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(cat_state::swyft_reset),this));
368370}
369371
370372VIDEO_START_MEMBER(cat_state,swyft)
trunk/src/mess/drivers/supercon.c
r18114r18115
7171   virtual void machine_reset();
7272   DECLARE_DRIVER_INIT(supercon);
7373   virtual void machine_start();
74   TIMER_CALLBACK_MEMBER(mouse_click);
75   TIMER_CALLBACK_MEMBER(update_irq);
7476};
7577
7678
r18114r18115
503505      beep_set_state(m_beep ,0);
504506}
505507
506static TIMER_CALLBACK( mouse_click )
508TIMER_CALLBACK_MEMBER(supercon_state::mouse_click)
507509{
508   supercon_state *state = machine.driver_data<supercon_state>();
509510
510   if (state->ioport("BUTTON_L")->read_safe(0) )            /* wait for mouse release */
511      state->m_timer_mouse_click->adjust(state->m_wait_time, 0);
511   if (ioport("BUTTON_L")->read_safe(0) )            /* wait for mouse release */
512      m_timer_mouse_click->adjust(m_wait_time, 0);
512513   else
513      state->m_selecting=FALSE;
514      m_selecting=FALSE;
514515}
515516
516517static TIMER_DEVICE_CALLBACK( update_artwork )
r18114r18115
518519   mouse_update(timer.machine());
519520}
520521
521static TIMER_CALLBACK( update_irq )
522TIMER_CALLBACK_MEMBER(supercon_state::update_irq)
522523{
523   machine.device("maincpu")->execute().set_input_line(M6502_IRQ_LINE, ASSERT_LINE);
524   machine.device("maincpu")->execute().set_input_line(M6502_IRQ_LINE, CLEAR_LINE);
524   machine().device("maincpu")->execute().set_input_line(M6502_IRQ_LINE, ASSERT_LINE);
525   machine().device("maincpu")->execute().set_input_line(M6502_IRQ_LINE, CLEAR_LINE);
525526}
526527
527528/* Save state call backs */
r18114r18115
544545
545546void supercon_state::machine_start()
546547{
547   m_timer_update_irq = machine().scheduler().timer_alloc(FUNC(update_irq));
548   m_timer_update_irq = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(supercon_state::update_irq),this));
548549   m_timer_update_irq->adjust( attotime::zero, 0, attotime::from_hz(1000) );
549   m_timer_mouse_click =  machine().scheduler().timer_alloc(FUNC(mouse_click),NULL);
550   m_timer_mouse_click =  machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(supercon_state::mouse_click),this),NULL);
550551   save_item(NAME(m_save_board));
551552   machine().save().register_postload(save_prepost_delegate(FUNC(board_postload),this));
552553   machine().save().register_presave(save_prepost_delegate(FUNC(board_presave),this));
trunk/src/mess/drivers/alphatro.c
r18114r18115
7171   static const device_timer_id SERIAL_TIMER = 1;
7272   UINT8 m_timer_bit;
7373   virtual void palette_init();
74   TIMER_CALLBACK_MEMBER(alphatro_beepoff);
7475};
7576
76static TIMER_CALLBACK( alphatro_beepoff )
77TIMER_CALLBACK_MEMBER(alphatro_state::alphatro_beepoff)
7778{
78   alphatro_state *state = machine.driver_data<alphatro_state>();
79   beep_set_state(state->m_beep, 0);
79   beep_set_state(m_beep, 0);
8080}
8181
8282READ8_MEMBER( alphatro_state::port10_r )
r18114r18115
101101
102102   if (length)
103103   {
104      machine().scheduler().timer_set(attotime::from_msec(length), FUNC(alphatro_beepoff));
104      machine().scheduler().timer_set(attotime::from_msec(length), timer_expired_delegate(FUNC(alphatro_state::alphatro_beepoff),this));
105105      beep_set_state(m_beep, 1);
106106   }
107107
trunk/src/mess/drivers/pc8801.c
r18114r18115
452452   DECLARE_MACHINE_RESET(pc8801_dic);
453453   DECLARE_MACHINE_RESET(pc8801_cdrom);
454454   INTERRUPT_GEN_MEMBER(pc8801_vrtc_irq);
455   TIMER_CALLBACK_MEMBER(pc8801fd_upd765_tc_to_zero);
455456};
456457
457458
r18114r18115
18771878   AM_RANGE(0x4000, 0x7fff) AM_RAM
18781879ADDRESS_MAP_END
18791880
1880static TIMER_CALLBACK( pc8801fd_upd765_tc_to_zero )
1881TIMER_CALLBACK_MEMBER(pc8801_state::pc8801fd_upd765_tc_to_zero)
18811882{
1882//  pc8801_state *state = machine.driver_data<pc8801_state>();
18831883
18841884   //printf("0\n");
1885   upd765_tc_w(machine.device("upd765"), 0);
1885   upd765_tc_w(machine().device("upd765"), 0);
18861886}
18871887
18881888WRITE8_MEMBER(pc8801_state::upd765_mc_w)
r18114r18115
18991899
19001900   upd765_tc_w(machine().device("upd765"), 1);
19011901    //TODO: I'm not convinced that this works correctly with current hook-up ... 1000 usec is needed by Aploon, a bigger value breaks Alpha.
1902   machine().scheduler().timer_set(attotime::from_usec(750), FUNC(pc8801fd_upd765_tc_to_zero));
1902   machine().scheduler().timer_set(attotime::from_usec(750), timer_expired_delegate(FUNC(pc8801_state::pc8801fd_upd765_tc_to_zero),this));
19031903   return 0xff; // value is meaningless
19041904}
19051905
trunk/src/mess/drivers/psx.c
r18114r18115
5555   DECLARE_DIRECT_UPDATE_MEMBER(psx_setopbase);
5656   DECLARE_DRIVER_INIT(psx);
5757   DECLARE_MACHINE_RESET(psx);
58   TIMER_CALLBACK_MEMBER(psx_pad_ack);
5859};
5960
6061
r18114r18115
493494#define PAD_DATA_OK   ( 0x5a ) /* Z */
494495#define PAD_DATA_IDLE ( 0xff )
495496
496static TIMER_CALLBACK(psx_pad_ack)
497TIMER_CALLBACK_MEMBER(psx1_state::psx_pad_ack)
497498{
498   psx1_state *state = machine.driver_data<psx1_state>();
499499   int n_port = param;
500   pad_t *pad = &state->m_pad[ n_port ];
500   pad_t *pad = &m_pad[ n_port ];
501501
502502   if( pad->n_state != PAD_STATE_IDLE )
503503   {
504      psx_sio_input( machine, 0, PSX_SIO_IN_DSR, pad->b_ack * PSX_SIO_IN_DSR );
504      psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, pad->b_ack * PSX_SIO_IN_DSR );
505505      if( !pad->b_ack )
506506      {
507507         pad->b_ack = 1;
508         machine.scheduler().timer_set(attotime::from_usec( 2 ), FUNC(psx_pad_ack) , n_port);
508         machine().scheduler().timer_set(attotime::from_usec( 2 ), timer_expired_delegate(FUNC(psx1_state::psx_pad_ack),this) , n_port);
509509      }
510510   }
511511}
r18114r18115
650650   if( b_ack )
651651   {
652652      pad->b_ack = 0;
653      machine.scheduler().timer_set(attotime::from_usec( 10 ), FUNC(psx_pad_ack), n_port);
653      machine.scheduler().timer_set(attotime::from_usec( 10 ), timer_expired_delegate(FUNC(psx1_state::psx_pad_ack),state), n_port);
654654   }
655655}
656656
trunk/src/mess/drivers/c10.c
r18114r18115
2929   virtual void video_start();
3030   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3131   DECLARE_DRIVER_INIT(c10);
32   TIMER_CALLBACK_MEMBER(c10_reset);
3233};
3334
3435
r18114r18115
5152INPUT_PORTS_END
5253
5354/* after the first 4 bytes have been read from ROM, switch the ram back in */
54static TIMER_CALLBACK( c10_reset )
55TIMER_CALLBACK_MEMBER(c10_state::c10_reset)
5556{
56   c10_state *state = machine.driver_data<c10_state>();
57   state->membank("boot")->set_entry(0);
57   membank("boot")->set_entry(0);
5858}
5959
6060void c10_state::machine_reset()
6161{
6262   membank("boot")->set_entry(1);
63   machine().scheduler().timer_set(attotime::from_usec(4), FUNC(c10_reset));
63   machine().scheduler().timer_set(attotime::from_usec(4), timer_expired_delegate(FUNC(c10_state::c10_reset),this));
6464}
6565
6666void c10_state::video_start()
trunk/src/mess/drivers/jr200.c
r18114r18115
5353   virtual void video_start();
5454   virtual void palette_init();
5555   UINT32 screen_update_jr200(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
56   TIMER_CALLBACK_MEMBER(timer_d_callback);
5657};
5758
5859
r18114r18115
283284}
284285
285286
286static TIMER_CALLBACK(timer_d_callback)
287TIMER_CALLBACK_MEMBER(jr200_state::timer_d_callback)
287288{
288   machine.firstcpu->set_input_line(0, HOLD_LINE);
289   machine().firstcpu->set_input_line(0, HOLD_LINE);
289290}
290291
291292READ8_MEMBER(jr200_state::mn1271_io_r)
r18114r18115
484485{
485486   beep_set_frequency(machine().device(BEEPER_TAG),0);
486487   beep_set_state(machine().device(BEEPER_TAG),0);
487   m_timer_d = machine().scheduler().timer_alloc(FUNC(timer_d_callback));
488   m_timer_d = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(jr200_state::timer_d_callback),this));
488489}
489490
490491void jr200_state::machine_reset()
trunk/src/mess/drivers/dectalk.c
r18114r18115
194194   DECLARE_READ16_MEMBER(spc_semaphore_r);
195195   DECLARE_DRIVER_INIT(dectalk);
196196   virtual void machine_reset();
197   TIMER_CALLBACK_MEMBER(outfifo_read_cb);
197198};
198199
199200
r18114r18115
697698/******************************************************************************
698699 Machine Drivers
699700******************************************************************************/
700static TIMER_CALLBACK( outfifo_read_cb )
701TIMER_CALLBACK_MEMBER(dectalk_state::outfifo_read_cb)
701702{
702703   UINT16 data;
703   dac_device *speaker = machine.device<dac_device>("dac");
704   data = dectalk_outfifo_r(machine);
704   dac_device *speaker = machine().device<dac_device>("dac");
705   data = dectalk_outfifo_r(machine());
705706#ifdef VERBOSE
706707   if (data!= 0x8000) logerror("sample output: %04X\n", data);
707708#endif
708   machine.scheduler().timer_set(attotime::from_hz(10000), FUNC(outfifo_read_cb));
709   machine().scheduler().timer_set(attotime::from_hz(10000), timer_expired_delegate(FUNC(dectalk_state::outfifo_read_cb),this));
709710   speaker->write_signed16(data);
710711}
711712
r18114r18115
714715{
715716   dectalk_clear_all_fifos(machine());
716717   m_simulate_outfifo_error = 0;
717   machine().scheduler().timer_set(attotime::from_hz(10000), FUNC(outfifo_read_cb));
718   machine().scheduler().timer_set(attotime::from_hz(10000), timer_expired_delegate(FUNC(dectalk_state::outfifo_read_cb),this));
718719}
719720
720721static WRITE8_DEVICE_HANDLER( dectalk_kbd_put )
trunk/src/mess/drivers/osbexec.c
r18114r18115
110110   DECLARE_DRIVER_INIT(osbexec);
111111   virtual void machine_reset();
112112   virtual void palette_init();
113   TIMER_CALLBACK_MEMBER(osbexec_video_callback);
113114};
114115
115116
r18114r18115
551552};
552553
553554
554static TIMER_CALLBACK( osbexec_video_callback )
555TIMER_CALLBACK_MEMBER(osbexec_state::osbexec_video_callback)
555556{
556   osbexec_state *state = machine.driver_data<osbexec_state>();
557   int y = machine.primary_screen->vpos();
557   int y = machine().primary_screen->vpos();
558558
559559   /* Start of frame */
560560   if ( y == 0 )
561561   {
562562      /* Clear CB1 on PIA @ UD12 */
563      state->m_pia_0->cb1_w(0);
563      m_pia_0->cb1_w(0);
564564   }
565565   else if ( y == 240 )
566566   {
567567      /* Set CB1 on PIA @ UD12 */
568      state->m_pia_0->cb1_w(1);
569      state->m_rtc++;
568      m_pia_0->cb1_w(1);
569      m_rtc++;
570570   }
571571   if ( y < 240 )
572572   {
573573      UINT16 row_addr = ( y / 10 ) * 128;
574      UINT16 *p = &state->m_bitmap.pix16(y);
574      UINT16 *p = &m_bitmap.pix16(y);
575575      UINT8 char_line = y % 10;
576576
577577      for ( int x = 0; x < 80; x++ )
578578      {
579         UINT8 ch = state->m_vram[ row_addr + x ];
580         UINT8 attr = state->m_vram[ 0x1000 + row_addr + x ];
579         UINT8 ch = m_vram[ row_addr + x ];
580         UINT8 attr = m_vram[ 0x1000 + row_addr + x ];
581581         UINT8 fg_col = ( attr & 0x80 ) ? 1 : 2;
582         UINT8 font_bits = state->m_fontram[ ( ( attr & 0x10 ) ? 0x800 : 0 ) + ( ch & 0x7f ) * 16 + char_line ];
582         UINT8 font_bits = m_fontram[ ( ( attr & 0x10 ) ? 0x800 : 0 ) + ( ch & 0x7f ) * 16 + char_line ];
583583
584584         /* Check for underline */
585585         if ( ( attr & 0x40 ) && char_line == 9 )
586586            font_bits = 0xFF;
587587
588588         /* Check for blink */
589         if ( ( attr & 0x20 ) && ( state->m_rtc & 0x10 ) )
589         if ( ( attr & 0x20 ) && ( m_rtc & 0x10 ) )
590590            font_bits = 0;
591591
592592         /* Check for inverse video */
r18114r18115
601601      }
602602   }
603603
604   state->m_video_timer->adjust( machine.primary_screen->time_until_pos( y + 1, 0 ) );
604   m_video_timer->adjust( machine().primary_screen->time_until_pos( y + 1, 0 ) );
605605}
606606
607607
r18114r18115
617617   memset( m_fontram, 0x00, 0x1000 );
618618   memset( m_vram, 0x00, 0x2000 );
619619
620   m_video_timer = machine().scheduler().timer_alloc(FUNC(osbexec_video_callback));
620   m_video_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(osbexec_state::osbexec_video_callback),this));
621621}
622622
623623
trunk/src/mess/drivers/craft.c
r18114r18115
3737* I/O devices                                        *
3838\****************************************************/
3939
40static TIMER_CALLBACK( avr8_timer0_tick );
41static TIMER_CALLBACK( avr8_timer1_tick );
42static TIMER_CALLBACK( avr8_timer2_tick );
4340
41
42
43
4444class craft_state : public driver_device
4545{
4646public:
r18114r18115
7474   DECLARE_DRIVER_INIT(craft);
7575   virtual void machine_reset();
7676   UINT32 screen_update_craft(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
77   TIMER_CALLBACK_MEMBER(avr8_timer0_tick);
78   TIMER_CALLBACK_MEMBER(avr8_timer1_tick);
79   TIMER_CALLBACK_MEMBER(avr8_timer2_tick);
7780};
7881
7982void craft_state::machine_start()
8083{
81   m_timer0_timer = machine().scheduler().timer_alloc(FUNC(avr8_timer0_tick));
82   m_timer1_timer = machine().scheduler().timer_alloc(FUNC(avr8_timer1_tick));
83   m_timer2_timer = machine().scheduler().timer_alloc(FUNC(avr8_timer2_tick));
84   m_timer0_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(craft_state::avr8_timer0_tick),this));
85   m_timer1_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(craft_state::avr8_timer1_tick),this));
86   m_timer2_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(craft_state::avr8_timer2_tick),this));
8487}
8588enum
8689{
r18114r18115
9295
9396static const char avr8_reg_name[4] = { 'A', 'B', 'C', 'D' };
9497
95static TIMER_CALLBACK( avr8_timer0_tick )
98TIMER_CALLBACK_MEMBER(craft_state::avr8_timer0_tick)
9699{
97100   // TODO
98101}
99102
100static TIMER_CALLBACK( avr8_timer1_tick )
103TIMER_CALLBACK_MEMBER(craft_state::avr8_timer1_tick)
101104{
102105    /* TODO: Handle comparison, setting OC1x pins, detection of BOTTOM and TOP
103106
104    craft_state *state = machine.driver_data<craft_state>();
105107    UINT16 count = AVR8_TCNT1;
106    count += state->m_timer1_increment;
108    count += m_timer1_increment;
107109
108110    for(INT32 reg = AVR8_REG_A; reg <= AVR8_REG_B; reg++)
109111    {
r18114r18115
111113        switch(mode)
112114        {
113115            case 0:
114                //verboselog(machine, 0, "avr8_update_timer1_compare_mode: Normal port operation (OC1 disconnected)\n");
116                //verboselog(machine(), 0, "avr8_update_timer1_compare_mode: Normal port operation (OC1 disconnected)\n");
115117                break;
116118
117119            case 1:
r18114r18115
128130                    case Avr8::WGM1_PWM_10_PC:
129131                    case Avr8::WGM1_PWM_PFC_ICR:
130132                    case Avr8::WGM1_PWM_PC_ICR:
131                        //verboselog(machine, 0, "avr8_update_timer1_compare_mode: Normal port operation (OC1 disconnected)\n");
133                        //verboselog(machine(), 0, "avr8_update_timer1_compare_mode: Normal port operation (OC1 disconnected)\n");
132134                        break;
133135
134136                    case Avr8::WGM1_FAST_PWM_ICR:
135137                    case Avr8::WGM1_FAST_PWM_OCR:
136138                    case Avr8::WGM1_PWM_PFC_OCR:
137139                    case Avr8::WGM1_PWM_PC_OCR:
138                        //verboselog(machine, 0, "avr8_update_timer1_compare_mode: Toggle OC1A on compare match, OC1B disconnected\n");
140                        //verboselog(machine(), 0, "avr8_update_timer1_compare_mode: Toggle OC1A on compare match, OC1B disconnected\n");
139141                        break;
140142                }
141143                break;
r18114r18115
146148                    case Avr8::WGM1_NORMAL:
147149                    case Avr8::WGM1_CTC_OCR:
148150                    case Avr8::WGM1_CTC_ICR:
149                        //verboselog(machine, 0, "avr8_update_timer1_compare_mode: Clear OC1%c on compare match\n", avr8_reg_name[reg]);
151                        //verboselog(machine(), 0, "avr8_update_timer1_compare_mode: Clear OC1%c on compare match\n", avr8_reg_name[reg]);
150152                        break;
151153
152154                    case Avr8::WGM1_PWM_8_PC:
r18114r18115
156158                    case Avr8::WGM1_PWM_PC_ICR:
157159                    case Avr8::WGM1_PWM_PFC_OCR:
158160                    case Avr8::WGM1_PWM_PC_OCR:
159                        //verboselog(machine, 0, "avr8_update_timer1_compare_mode: Clear OC1%c on match when up-counting, set when down-counting\n", avr8_reg_name[reg]);
161                        //verboselog(machine(), 0, "avr8_update_timer1_compare_mode: Clear OC1%c on match when up-counting, set when down-counting\n", avr8_reg_name[reg]);
160162                        break;
161163
162164                    case Avr8::WGM1_FAST_PWM_8:
r18114r18115
164166                    case Avr8::WGM1_FAST_PWM_10:
165167                    case Avr8::WGM1_FAST_PWM_ICR:
166168                    case Avr8::WGM1_FAST_PWM_OCR:
167                        //verboselog(machine, 0, "avr8_update_timer1_compare_mode: Clear OC1%c on compare match, set at BOTTOM\n", avr8_reg_name[reg]);
169                        //verboselog(machine(), 0, "avr8_update_timer1_compare_mode: Clear OC1%c on compare match, set at BOTTOM\n", avr8_reg_name[reg]);
168170                        break;
169171                }
170172                break;
r18114r18115
175177                    case Avr8::WGM1_NORMAL:
176178                    case Avr8::WGM1_CTC_OCR:
177179                    case Avr8::WGM1_CTC_ICR:
178                        //verboselog(machine, 0, "avr8_update_timer1_compare_mode: Set OC1%c on compare match\n", avr8_reg_name[reg]);
180                        //verboselog(machine(), 0, "avr8_update_timer1_compare_mode: Set OC1%c on compare match\n", avr8_reg_name[reg]);
179181                        break;
180182
181183                    case Avr8::WGM1_PWM_8_PC:
r18114r18115
185187                    case Avr8::WGM1_PWM_PC_ICR:
186188                    case Avr8::WGM1_PWM_PFC_OCR:
187189                    case Avr8::WGM1_PWM_PC_OCR:
188                        //verboselog(machine, 0, "avr8_update_timer1_compare_mode: Set OC1%c on match when up-counting, clear on match when down-counting\n", avr8_reg_name[reg]);
190                        //verboselog(machine(), 0, "avr8_update_timer1_compare_mode: Set OC1%c on match when up-counting, clear on match when down-counting\n", avr8_reg_name[reg]);
189191                        break;
190192
191193                    case Avr8::WGM1_FAST_PWM_8:
r18114r18115
193195                    case Avr8::WGM1_FAST_PWM_10:
194196                    case Avr8::WGM1_FAST_PWM_ICR:
195197                    case Avr8::WGM1_FAST_PWM_OCR:
196                        //verboselog(machine, 0, "avr8_update_timer1_compare_mode: Set OC1%c on compare match, clear at BOTTOM\n", avr8_reg_name[reg]);
198                        //verboselog(machine(), 0, "avr8_update_timer1_compare_mode: Set OC1%c on compare match, clear at BOTTOM\n", avr8_reg_name[reg]);
197199                        break;
198200                }
199201                break;
200202            default:
201                verboselog(machine, 0, "avr8_update_timer1_compare_mode: Unknown COM1%c mode setting (%d)\n", avr8_reg_name[reg], mode);
203                verboselog(machine(), 0, "avr8_update_timer1_compare_mode: Unknown COM1%c mode setting (%d)\n", avr8_reg_name[reg], mode);
202204                break;
203205        }
204206    }
r18114r18115
544546   verboselog(machine, 0, "avr8_update_timer1_input_edge_select: TODO; Clocking edge is %s\n", "test");
545547}
546548
547static TIMER_CALLBACK( avr8_timer2_tick )
549TIMER_CALLBACK_MEMBER(craft_state::avr8_timer2_tick)
548550{
549551    /* TODO: Handle comparison, setting OC2x pins, detection of BOTTOM and TOP
550552
551    craft_state *state = machine.driver_data<craft_state>();
552553    UINT16 count = AVR8_TCNT2;
553    count += state->m_timer1_increment;
554    count += m_timer1_increment;
554555    for(INT32 reg = AVR8_REG_A; reg <= AVR8_REG_B; reg++)
555556    {
556557        UINT8 mode = (reg == AVR8_REG_A) ? AVR8_TCCR2A_COM2A : AVR8_TCCR2A_COM2B;
r18114r18115
558559        if(!mode)
559560        {
560561            // Normal port operation, OC2n disconnected
561            //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; OC2%c disconnected, normal port operation\n", avr8_reg_name[reg]);
562            //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; OC2%c disconnected, normal port operation\n", avr8_reg_name[reg]);
562563            return;
563564        }
564565
r18114r18115
569570                switch(mode)
570571                {
571572                    case 1: // Toggle OC2n on Compare Match
572                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; Toggle OC2%c on Compare Match\n", avr8_reg_name[reg]);
573                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; Toggle OC2%c on Compare Match\n", avr8_reg_name[reg]);
573574                        break;
574575                    case 2: // Clear OC2n on Compare Match
575                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; Clear OC2%c on Compare Match\n", avr8_reg_name[reg]);
576                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; Clear OC2%c on Compare Match\n", avr8_reg_name[reg]);
576577                        break;
577578                    case 3: // Set OC2n on Compare Match
578                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; Set OC2%c on Compare Match\n", avr8_reg_name[reg]);
579                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; Set OC2%c on Compare Match\n", avr8_reg_name[reg]);
579580                        break;
580581                }
581582                break;
r18114r18115
584585                switch(mode)
585586                {
586587                    case 1: // Normal port operation, OC2n disconnected
587                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; OC2%c disconnected, normal port operation\n", avr8_reg_name[reg]);
588                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; OC2%c disconnected, normal port operation\n", avr8_reg_name[reg]);
588589                        break;
589590                    case 2: // Clear OC2n on match when up-counting, set when down-counting
590                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; Clear OC2%c on match when up-counting, set when down-counting\n", avr8_reg_name[reg]);
591                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; Clear OC2%c on match when up-counting, set when down-counting\n", avr8_reg_name[reg]);
591592                        break;
592593                    case 3: // Set OC2n on match when up-counting, clear when down-counting
593                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; Set OC2%c on match when up-counting, clear when down-counting\n", avr8_reg_name[reg]);
594                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; Set OC2%c on match when up-counting, clear when down-counting\n", avr8_reg_name[reg]);
594595                        break;
595596                }
596597                break;
r18114r18115
599600                switch(mode)
600601                {
601602                    case 1: // Toggle OC2n on compare match
602                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; Toggle OC2%c on compare match\n", avr8_reg_name[reg]);
603                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; Toggle OC2%c on compare match\n", avr8_reg_name[reg]);
603604                        break;
604605                    case 2: // Clear OC2n on match when up-counting, set when down-counting
605                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; Clear OC2%c on match when up-counting, set when down-counting\n", avr8_reg_name[reg]);
606                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; Clear OC2%c on match when up-counting, set when down-counting\n", avr8_reg_name[reg]);
606607                        break;
607608                    case 3: // Set OC2n on match when up-counting, clear when down-counting
608                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; Set OC2%c on match when up-counting, clear when down-counting\n", avr8_reg_name[reg]);
609                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; Set OC2%c on match when up-counting, clear when down-counting\n", avr8_reg_name[reg]);
609610                        break;
610611                }
611612                break;
r18114r18115
615616                switch(mode)
616617                {
617618                    case 1: // Normal port operation, OC2n disconnected
618                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; OC2%c disconnected, normal port operation\n", avr8_reg_name[reg]);
619                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; OC2%c disconnected, normal port operation\n", avr8_reg_name[reg]);
619620                        break;
620621                    case 2: // Clear OC2n on match, set at BOTTOM
621                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; Clear OC2%c on match, set at BOTTOM\n", avr8_reg_name[reg]);
622                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; Clear OC2%c on match, set at BOTTOM\n", avr8_reg_name[reg]);
622623                        break;
623624                    case 3: // Set OC2n on match, clear at BOTTOM
624                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; Set OC2%c on match, clear at BOTTOM\n", avr8_reg_name[reg]);
625                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; Set OC2%c on match, clear at BOTTOM\n", avr8_reg_name[reg]);
625626                        break;
626627                }
627628                break;
r18114r18115
630631                switch(mode)
631632                {
632633                    case 1: // Toggle OC2n on compare match
633                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; Toggle OC2%c on compare match\n", avr8_reg_name[reg]);
634                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; Toggle OC2%c on compare match\n", avr8_reg_name[reg]);
634635                        break;
635636                    case 2: // Clear OC2n on match, set at BOTTOM
636                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; Clear OC2%c on match, set at BOTTOM\n", avr8_reg_name[reg]);
637                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; Clear OC2%c on match, set at BOTTOM\n", avr8_reg_name[reg]);
637638                        break;
638639                    case 3: // Set OC2n on match, clear at BOTTOM
639                        //verboselog(machine, 0, "avr8_update_timer2_compare_mode: TODO; Set OC2%c on match, clear at BOTTOM\n", avr8_reg_name[reg]);
640                        //verboselog(machine(), 0, "avr8_update_timer2_compare_mode: TODO; Set OC2%c on match, clear at BOTTOM\n", avr8_reg_name[reg]);
640641                        break;
641642                }
642643                break;
trunk/src/mess/drivers/vk100.c
r18114r18115
192192   DECLARE_DRIVER_INIT(vk100);
193193   virtual void machine_reset();
194194   virtual void video_start();
195   TIMER_CALLBACK_MEMBER(execute_vg);
195196};
196197
197198// vram access functions:
r18114r18115
250251   state->m_vram[(EA<<1)] = (block&0xFF00)>>8; // ''
251252}
252253
253static TIMER_CALLBACK( execute_vg )
254TIMER_CALLBACK_MEMBER(vk100_state::execute_vg)
254255{
255   vk100_state *state = machine.driver_data<vk100_state>();
256   UINT8 thisNyb = vram_read(machine); // read in the nybble
256   UINT8 thisNyb = vram_read(machine()); // read in the nybble
257257   // pattern rom addressing is a complex mess. see the pattern rom def later in this file.
258   UINT8 newNyb = state->m_pattern[((state->m_vgPAT&state->m_vgPAT_Mask)?0x200:0)|((state->VG_WOPS&7)<<6)|((state->m_vgX&3)<<4)|thisNyb]; // calculate new nybble based on pattern rom
258   UINT8 newNyb = m_pattern[((m_vgPAT&m_vgPAT_Mask)?0x200:0)|((VG_WOPS&7)<<6)|((m_vgX&3)<<4)|thisNyb]; // calculate new nybble based on pattern rom
259259   // finally write the block back to ram depending on the VG_MODE (sort of a hack until we get the vector and synd and dir roms all hooked up)
260   switch (state->m_VG_MODE)
260   switch (m_VG_MODE)
261261   {
262262      case 0: // move; adjusts the x and y but doesn't write anything. do nothing
263263         break;
264264      case 1: // dot: only write the LAST pixel in the chain? TODO: some fallthrough magic here?
265         if ((state->m_vgDownCount) == 0x00)
265         if ((m_vgDownCount) == 0x00)
266266         {
267            vram_write(machine, newNyb); // write out the modified nybble
267            vram_write(machine(), newNyb); // write out the modified nybble
268268         }
269269         break;
270270      case 2: // vec: draw the vector
271            vram_write(machine, newNyb); // write out the modified nybble
271            vram_write(machine(), newNyb); // write out the modified nybble
272272         break;
273273      case 3: // er: erase: special case here: wipe the entire screen (except for color/attrib?) and then set done.
274274         for (int i = 0; i < 0x8000; i++)
275275         {
276276            if (!(i&1)) // avoid stomping attribute
277               state->m_vram[i] = state->m_vram[i]&0xF0;
277               m_vram[i] = m_vram[i]&0xF0;
278278            else // (i&1)
279               state->m_vram[i] = 0;
279               m_vram[i] = 0;
280280         }
281         state->m_vgGO = 0; // done
281         m_vgGO = 0; // done
282282         break;
283283   }
284284    /* this is the "DIRECTION ROM"  == mb6309 (256x8, 82s135)
r18114r18115
305305     *            \--------- UNUSED, always 0
306306     * The VT125 prom @ E41 is literally identical to this, the same exact part: 23-059B1
307307     */
308   //UINT8 direction_rom = state->m_dir[];
308   //UINT8 direction_rom = m_dir[];
309309   // HACK: we need the proper direction rom dump for this!
310   switch(state->VG_DIR&0x7)
310   switch(VG_DIR&0x7)
311311   {
312312      case 0:
313         state->m_vgX++;
313         m_vgX++;
314314         break;
315315      case 7:
316         state->m_vgX++;
317         state->m_vgY++;
316         m_vgX++;
317         m_vgY++;
318318         break;
319319      case 6:
320         state->m_vgY++;
320         m_vgY++;
321321         break;
322322      case 5:
323         state->m_vgX--;
324         state->m_vgY++;
323         m_vgX--;
324         m_vgY++;
325325         break;
326326      case 4:
327         state->m_vgX--;
327         m_vgX--;
328328         break;
329329      case 3:
330         state->m_vgX--;
331         state->m_vgY--;
330         m_vgX--;
331         m_vgY--;
332332         break;
333333      case 2:
334         state->m_vgY--;
334         m_vgY--;
335335         break;
336336      case 1:
337         state->m_vgX++;
338         state->m_vgY--;
337         m_vgX++;
338         m_vgY--;
339339         break;
340340   }
341   state->m_vgDownCount--; // decrement the down counter
342   if ((state->m_vgDownCount) == 0x00) state->m_vgGO = 0; // check if the down counter hit terminal count (0), if so we're done.
343   if (((++state->m_vgPMUL_Count)&0xF)==0) // if pattern multiplier counter overflowed
341   m_vgDownCount--; // decrement the down counter
342   if ((m_vgDownCount) == 0x00) m_vgGO = 0; // check if the down counter hit terminal count (0), if so we're done.
343   if (((++m_vgPMUL_Count)&0xF)==0) // if pattern multiplier counter overflowed
344344   {
345      state->m_vgPMUL_Count = state->m_vgPMUL; // reload counter
346      state->m_vgPAT_Mask >>= 1; // shift the mask
347      if (state->m_vgPAT_Mask == 0) state->m_vgPAT_Mask = 0x80; // reset mask if it hits 0
345      m_vgPMUL_Count = m_vgPMUL; // reload counter
346      m_vgPAT_Mask >>= 1; // shift the mask
347      if (m_vgPAT_Mask == 0) m_vgPAT_Mask = 0x80; // reset mask if it hits 0
348348   }
349   if (state->m_vgGO) machine.scheduler().timer_set(attotime::from_hz(XTAL_45_6192Mhz/3/12/2), FUNC(execute_vg)); // /3/12/2 is correct. the sync counter is clocked by the dot clock, despite the error on figure 5-21
349   if (m_vgGO) machine().scheduler().timer_set(attotime::from_hz(XTAL_45_6192Mhz/3/12/2), timer_expired_delegate(FUNC(vk100_state::execute_vg),this)); // /3/12/2 is correct. the sync counter is clocked by the dot clock, despite the error on figure 5-21
350350}
351351
352352/* ports 0x40 and 0x41: load low and high bytes of vector gen X register */
r18114r18115
459459   m_vgDownCount = VG_DU; // set down counter to length of major vector
460460   m_VG_MODE = offset&3;
461461   m_vgGO = 1;
462   machine().scheduler().timer_set(attotime::zero, FUNC(execute_vg));
462   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(vk100_state::execute_vg),this));
463463}
464464
465465
trunk/src/mess/drivers/ptcsol.c
r18114r18115
180180   emu_timer *m_cassette_timer;
181181public:
182182   DECLARE_DRIVER_INIT(sol20);
183   TIMER_CALLBACK_MEMBER(sol20_cassette_tc);
184   TIMER_CALLBACK_MEMBER(sol20_boot);
183185};
184186
185187
r18114r18115
197199
198200
199201// identical to sorcerer
200static TIMER_CALLBACK(sol20_cassette_tc)
202TIMER_CALLBACK_MEMBER(sol20_state::sol20_cassette_tc)
201203{
202   sol20_state *state = machine.driver_data<sol20_state>();
203204   UINT8 cass_ws = 0;
204   switch (state->m_sol20_fa & 0x20)
205   switch (m_sol20_fa & 0x20)
205206   {
206207      case 0x20:            /* Cassette 300 baud */
207208
208209         /* loading a tape - this is basically the same as the super80.
209210                           We convert the 1200/2400 Hz signal to a 0 or 1, and send it to the uart. */
210211
211         state->m_cass_data.input.length++;
212         m_cass_data.input.length++;
212213
213         cass_ws = ((cassette_device_image(machine))->input() > +0.02) ? 1 : 0;
214         cass_ws = ((cassette_device_image(machine()))->input() > +0.02) ? 1 : 0;
214215
215         if (cass_ws != state->m_cass_data.input.level)
216         if (cass_ws != m_cass_data.input.level)
216217         {
217            state->m_cass_data.input.level = cass_ws;
218            state->m_cass_data.input.bit = ((state->m_cass_data.input.length < 0x6) || (state->m_cass_data.input.length > 0x20)) ? 1 : 0;
219            state->m_cass_data.input.length = 0;
220            ay31015_set_input_pin( state->m_uart, AY31015_SI, state->m_cass_data.input.bit );
218            m_cass_data.input.level = cass_ws;
219            m_cass_data.input.bit = ((m_cass_data.input.length < 0x6) || (m_cass_data.input.length > 0x20)) ? 1 : 0;
220            m_cass_data.input.length = 0;
221            ay31015_set_input_pin( m_uart, AY31015_SI, m_cass_data.input.bit );
221222         }
222223
223224         /* saving a tape - convert the serial stream from the uart, into 1200 and 2400 Hz frequencies.
224225                           Synchronisation of the frequency pulses to the uart is extremely important. */
225226
226         state->m_cass_data.output.length++;
227         if (!(state->m_cass_data.output.length & 0x1f))
227         m_cass_data.output.length++;
228         if (!(m_cass_data.output.length & 0x1f))
228229         {
229            cass_ws = ay31015_get_output_pin( state->m_uart, AY31015_SO );
230            if (cass_ws != state->m_cass_data.output.bit)
230            cass_ws = ay31015_get_output_pin( m_uart, AY31015_SO );
231            if (cass_ws != m_cass_data.output.bit)
231232            {
232               state->m_cass_data.output.bit = cass_ws;
233               state->m_cass_data.output.length = 0;
233               m_cass_data.output.bit = cass_ws;
234               m_cass_data.output.length = 0;
234235            }
235236         }
236237
237         if (!(state->m_cass_data.output.length & 3))
238         if (!(m_cass_data.output.length & 3))
238239         {
239            if (!((state->m_cass_data.output.bit == 0) && (state->m_cass_data.output.length & 4)))
240            if (!((m_cass_data.output.bit == 0) && (m_cass_data.output.length & 4)))
240241            {
241               state->m_cass_data.output.level ^= 1;         // toggle output state, except on 2nd half of low bit
242               cassette_device_image(machine)->output(state->m_cass_data.output.level ? -1.0 : +1.0);
242               m_cass_data.output.level ^= 1;         // toggle output this, except on 2nd half of low bit
243               cassette_device_image(machine())->output(m_cass_data.output.level ? -1.0 : +1.0);
243244            }
244245         }
245246         return;
246247
247248      case 0x00:         /* Cassette 1200 baud */
248249         /* loading a tape */
249         state->m_cass_data.input.length++;
250         m_cass_data.input.length++;
250251
251         cass_ws = ((cassette_device_image(machine))->input() > +0.02) ? 1 : 0;
252         cass_ws = ((cassette_device_image(machine()))->input() > +0.02) ? 1 : 0;
252253
253         if (cass_ws != state->m_cass_data.input.level || state->m_cass_data.input.length == 10)
254         if (cass_ws != m_cass_data.input.level || m_cass_data.input.length == 10)
254255         {
255            state->m_cass_data.input.bit = ((state->m_cass_data.input.length < 10) || (state->m_cass_data.input.length > 0x20)) ? 1 : 0;
256            if ( cass_ws != state->m_cass_data.input.level )
256            m_cass_data.input.bit = ((m_cass_data.input.length < 10) || (m_cass_data.input.length > 0x20)) ? 1 : 0;
257            if ( cass_ws != m_cass_data.input.level )
257258            {
258               state->m_cass_data.input.length = 0;
259               state->m_cass_data.input.level = cass_ws;
259               m_cass_data.input.length = 0;
260               m_cass_data.input.level = cass_ws;
260261            }
261            ay31015_set_input_pin( state->m_uart, AY31015_SI, state->m_cass_data.input.bit );
262            ay31015_set_input_pin( m_uart, AY31015_SI, m_cass_data.input.bit );
262263         }
263264
264265         /* saving a tape - convert the serial stream from the uart, into 600 and 1200 Hz frequencies. */
265266
266         state->m_cass_data.output.length++;
267         if (!(state->m_cass_data.output.length & 7))
267         m_cass_data.output.length++;
268         if (!(m_cass_data.output.length & 7))
268269         {
269            cass_ws = ay31015_get_output_pin( state->m_uart, AY31015_SO );
270            if (cass_ws != state->m_cass_data.output.bit)
270            cass_ws = ay31015_get_output_pin( m_uart, AY31015_SO );
271            if (cass_ws != m_cass_data.output.bit)
271272            {
272               state->m_cass_data.output.bit = cass_ws;
273               state->m_cass_data.output.length = 0;
273               m_cass_data.output.bit = cass_ws;
274               m_cass_data.output.length = 0;
274275            }
275276         }
276277
277         if (!(state->m_cass_data.output.length & 7))
278         if (!(m_cass_data.output.length & 7))
278279         {
279            if (!((state->m_cass_data.output.bit == 0) && (state->m_cass_data.output.length & 8)))
280            if (!((m_cass_data.output.bit == 0) && (m_cass_data.output.length & 8)))
280281            {
281               state->m_cass_data.output.level ^= 1;         // toggle output state, except on 2nd half of low bit
282               cassette_device_image(machine)->output(state->m_cass_data.output.level ? -1.0 : +1.0);
282               m_cass_data.output.level ^= 1;         // toggle output this, except on 2nd half of low bit
283               cassette_device_image(machine())->output(m_cass_data.output.level ? -1.0 : +1.0);
283284            }
284285         }
285286         return;
r18114r18115
538539};
539540
540541/* after the first 4 bytes have been read from ROM, switch the ram back in */
541static TIMER_CALLBACK( sol20_boot )
542TIMER_CALLBACK_MEMBER(sol20_state::sol20_boot)
542543{
543   sol20_state *state = machine.driver_data<sol20_state>();
544   state->membank("boot")->set_entry(0);
544   membank("boot")->set_entry(0);
545545}
546546
547547void sol20_state::machine_start()
548548{
549   m_cassette_timer = machine().scheduler().timer_alloc(FUNC(sol20_cassette_tc));
549   m_cassette_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sol20_state::sol20_cassette_tc),this));
550550}
551551
552552void sol20_state::machine_reset()
r18114r18115
598598
599599   // boot-bank
600600   membank("boot")->set_entry(1);
601   machine().scheduler().timer_set(attotime::from_usec(9), FUNC(sol20_boot));
601   machine().scheduler().timer_set(attotime::from_usec(9), timer_expired_delegate(FUNC(sol20_state::sol20_boot),this));
602602}
603603
604604DRIVER_INIT_MEMBER(sol20_state,sol20)
trunk/src/mess/drivers/ngp.c
r18114r18115
166166   DECLARE_WRITE8_MEMBER( ngp_tlcs900_to3 );
167167   UINT32 screen_update_ngp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
168168   DECLARE_INPUT_CHANGED_MEMBER(power_callback);
169   TIMER_CALLBACK_MEMBER(ngp_seconds_callback);
169170};
170171
171172
172static TIMER_CALLBACK( ngp_seconds_callback )
173TIMER_CALLBACK_MEMBER(ngp_state::ngp_seconds_callback)
173174{
174   ngp_state *state = machine.driver_data<ngp_state>();
175175
176   state->m_io_reg[0x16] += 1;
177   if ( ( state->m_io_reg[0x16] & 0x0f ) == 0x0a )
176   m_io_reg[0x16] += 1;
177   if ( ( m_io_reg[0x16] & 0x0f ) == 0x0a )
178178   {
179      state->m_io_reg[0x16] += 0x06;
179      m_io_reg[0x16] += 0x06;
180180   }
181181
182   if ( state->m_io_reg[0x16] >= 0x60 )
182   if ( m_io_reg[0x16] >= 0x60 )
183183   {
184      state->m_io_reg[0x16] = 0;
185      state->m_io_reg[0x15] += 1;
186      if ( ( state->m_io_reg[0x15] & 0x0f ) == 0x0a ) {
187         state->m_io_reg[0x15] += 0x06;
184      m_io_reg[0x16] = 0;
185      m_io_reg[0x15] += 1;
186      if ( ( m_io_reg[0x15] & 0x0f ) == 0x0a ) {
187         m_io_reg[0x15] += 0x06;
188188      }
189189
190      if ( state->m_io_reg[0x15] >= 0x60 )
190      if ( m_io_reg[0x15] >= 0x60 )
191191      {
192         state->m_io_reg[0x15] = 0;
193         state->m_io_reg[0x14] += 1;
194         if ( ( state->m_io_reg[0x14] & 0x0f ) == 0x0a ) {
195            state->m_io_reg[0x14] += 0x06;
192         m_io_reg[0x15] = 0;
193         m_io_reg[0x14] += 1;
194         if ( ( m_io_reg[0x14] & 0x0f ) == 0x0a ) {
195            m_io_reg[0x14] += 0x06;
196196         }
197197
198         if ( state->m_io_reg[0x14] == 0x24 )
198         if ( m_io_reg[0x14] == 0x24 )
199199         {
200            state->m_io_reg[0x14] = 0;
200            m_io_reg[0x14] = 0;
201201         }
202202      }
203203   }
r18114r18115
603603
604604void ngp_state::machine_start()
605605{
606   m_seconds_timer = machine().scheduler().timer_alloc(FUNC(ngp_seconds_callback));
606   m_seconds_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ngp_state::ngp_seconds_callback),this));
607607   m_seconds_timer->adjust( attotime::from_seconds(1), 0, attotime::from_seconds(1) );
608608}
609609
trunk/src/mess/drivers/plan80.c
r18114r18115
4444   virtual void video_start();
4545   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4646   DECLARE_DRIVER_INIT(plan80);
47   TIMER_CALLBACK_MEMBER(plan80_boot);
4748};
4849
4950READ8_MEMBER( plan80_state::plan80_04_r )
r18114r18115
140141
141142
142143/* after the first 4 bytes have been read from ROM, switch the ram back in */
143static TIMER_CALLBACK( plan80_boot )
144TIMER_CALLBACK_MEMBER(plan80_state::plan80_boot)
144145{
145   plan80_state *state = machine.driver_data<plan80_state>();
146   state->membank("boot")->set_entry(0);
146   membank("boot")->set_entry(0);
147147}
148148
149149void plan80_state::machine_reset()
150150{
151151   membank("boot")->set_entry(1);
152   machine().scheduler().timer_set(attotime::from_usec(10), FUNC(plan80_boot));
152   machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(plan80_state::plan80_boot),this));
153153}
154154
155155DRIVER_INIT_MEMBER(plan80_state,plan80)
trunk/src/mess/drivers/pb1000.c
r18114r18115
5151   void kb_matrix_w(running_machine &machine, UINT8 matrix);
5252   UINT16 read_touchscreen(running_machine &machine, UINT8 line);
5353   virtual void palette_init();
54   TIMER_CALLBACK_MEMBER(keyboard_timer);
5455};
5556
5657static ADDRESS_MAP_START(pb1000_mem, AS_PROGRAM, 16, pb1000_state)
r18114r18115
482483   port_w                 //8 bit port  write
483484};
484485
485static TIMER_CALLBACK( keyboard_timer )
486TIMER_CALLBACK_MEMBER(pb1000_state::keyboard_timer)
486487{
487   machine.device("maincpu")->execute().set_input_line(HD61700_KEY_INT, ASSERT_LINE);
488   machine.device("maincpu")->execute().set_input_line(HD61700_KEY_INT, CLEAR_LINE);
488   machine().device("maincpu")->execute().set_input_line(HD61700_KEY_INT, ASSERT_LINE);
489   machine().device("maincpu")->execute().set_input_line(HD61700_KEY_INT, CLEAR_LINE);
489490}
490491
491492void pb1000_state::machine_start()
492493{
493494   membank("bank1")->set_base(machine().root_device().memregion("rom")->base());
494495
495   m_kb_timer = machine().scheduler().timer_alloc(FUNC(keyboard_timer));
496   m_kb_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pb1000_state::keyboard_timer),this));
496497   m_kb_timer->adjust(attotime::from_hz(192), 0, attotime::from_hz(192));
497498}
498499
trunk/src/mess/drivers/zrt80.c
r18114r18115
4646   const UINT8 *m_p_chargen;
4747   virtual void machine_reset();
4848   virtual void video_start();
49   TIMER_CALLBACK_MEMBER(zrt80_beepoff);
4950};
5051
5152READ8_MEMBER( zrt80_state::zrt80_10_r )
r18114r18115
5556   return ret;
5657}
5758
58static TIMER_CALLBACK( zrt80_beepoff )
59TIMER_CALLBACK_MEMBER(zrt80_state::zrt80_beepoff)
5960{
60   zrt80_state *state = machine.driver_data<zrt80_state>();
61   beep_set_state(state->m_beep, 0);
61   beep_set_state(m_beep, 0);
6262}
6363
6464WRITE8_MEMBER(zrt80_state::zrt80_30_w)
6565{
66   machine().scheduler().timer_set(attotime::from_msec(100), FUNC(zrt80_beepoff));
66   machine().scheduler().timer_set(attotime::from_msec(100), timer_expired_delegate(FUNC(zrt80_state::zrt80_beepoff),this));
6767   beep_set_state(m_beep, 1);
6868}
6969
7070WRITE8_MEMBER(zrt80_state::zrt80_38_w)
7171{
72   machine().scheduler().timer_set(attotime::from_msec(400), FUNC(zrt80_beepoff));
72   machine().scheduler().timer_set(attotime::from_msec(400), timer_expired_delegate(FUNC(zrt80_state::zrt80_beepoff),this));
7373   beep_set_state(m_beep, 1);
7474}
7575
trunk/src/mess/drivers/pc88va.c
r18114r18115
103103   virtual void video_start();
104104   UINT32 screen_update_pc88va(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
105105   INTERRUPT_GEN_MEMBER(pc88va_vrtc_irq);
106   TIMER_CALLBACK_MEMBER(pc8801fd_upd765_tc_to_zero);
107   TIMER_CALLBACK_MEMBER(t3_mouse_callback);
106108};
107109
108110
r18114r18115
944946   floppy_drive_set_ready_state(floppy_get_device(machine(), 1), (data & 2), 0);
945947}
946948
947static TIMER_CALLBACK( pc8801fd_upd765_tc_to_zero )
949TIMER_CALLBACK_MEMBER(pc88va_state::pc8801fd_upd765_tc_to_zero)
948950{
949//  pc88va_state *state = machine.driver_data<pc88va_state>();
950951
951   upd765_tc_w(machine.device("upd765"), 0);
952   upd765_tc_w(machine().device("upd765"), 0);
952953}
953954
954955READ8_MEMBER(pc88va_state::upd765_tc_r)
955956{
956957
957958   upd765_tc_w(machine().device("upd765"), 1);
958   machine().scheduler().timer_set(attotime::from_usec(500), FUNC(pc8801fd_upd765_tc_to_zero));
959   machine().scheduler().timer_set(attotime::from_usec(500), timer_expired_delegate(FUNC(pc88va_state::pc8801fd_upd765_tc_to_zero),this));
959960   return 0;
960961}
961962
r18114r18115
10381039   m_screen_ctrl_reg = data;
10391040}
10401041
1041static TIMER_CALLBACK( t3_mouse_callback )
1042TIMER_CALLBACK_MEMBER(pc88va_state::t3_mouse_callback)
10421043{
1043   pc88va_state *state = machine.driver_data<pc88va_state>();
1044   if(state->m_timer3_io_reg & 0x80)
1044   if(m_timer3_io_reg & 0x80)
10451045   {
1046      pic8259_ir5_w(machine.device("pic8259_slave"), 1);
1047      state->m_t3_mouse_timer->adjust(attotime::from_hz(120 >> (state->m_timer3_io_reg & 3)));
1046      pic8259_ir5_w(machine().device("pic8259_slave"), 1);
1047      m_t3_mouse_timer->adjust(attotime::from_hz(120 >> (m_timer3_io_reg & 3)));
10481048   }
10491049}
10501050
r18114r18115
15331533{
15341534   machine().device("maincpu")->execute().set_irq_acknowledge_callback(pc88va_irq_callback);
15351535
1536   m_t3_mouse_timer = machine().scheduler().timer_alloc(FUNC(t3_mouse_callback));
1536   m_t3_mouse_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pc88va_state::t3_mouse_callback),this));
15371537   m_t3_mouse_timer->adjust(attotime::never);
15381538}
15391539
trunk/src/mess/drivers/pc6001.c
r18114r18115
235235   UINT32 screen_update_pc6001sr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
236236   INTERRUPT_GEN_MEMBER(pc6001_interrupt);
237237   INTERRUPT_GEN_MEMBER(pc6001sr_interrupt);
238   TIMER_CALLBACK_MEMBER(audio_callback);
238239};
239240
240241
r18114r18115
13571358   m_timer_irq_mask2 = data & 4;
13581359}
13591360
1360static TIMER_CALLBACK(audio_callback)
1361TIMER_CALLBACK_MEMBER(pc6001_state::audio_callback)
13611362{
1362   pc6001_state *state = machine.driver_data<pc6001_state>();
1363   if(state->m_cas_switch == 0 && ((state->m_timer_irq_mask == 0) || (state->m_timer_irq_mask2 == 0)))
1363   if(m_cas_switch == 0 && ((m_timer_irq_mask == 0) || (m_timer_irq_mask2 == 0)))
13641364   {
1365      if(IRQ_LOG) printf("Timer IRQ called %02x\n",state->m_timer_irq_vector);
1366      state->m_irq_vector = state->m_timer_irq_vector;
1367      machine.device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
1365      if(IRQ_LOG) printf("Timer IRQ called %02x\n",m_timer_irq_vector);
1366      m_irq_vector = m_timer_irq_vector;
1367      machine().device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
13681368   }
13691369}
13701370
r18114r18115
21062106   m_timer_hz_div = 3;
21072107   {
21082108      attotime period = attotime::from_hz((487.5*4)/(m_timer_hz_div+1));
2109      m_timer_irq_timer = machine().scheduler().timer_alloc(FUNC(audio_callback));
2109      m_timer_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pc6001_state::audio_callback),this));
21102110      m_timer_irq_timer->adjust(period,  0, period);
21112111   }
21122112}
trunk/src/mess/drivers/px4.c
r18114r18115
167167   DECLARE_PALETTE_INIT(px4p);
168168   UINT32 screen_update_px4(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
169169   DECLARE_INPUT_CHANGED_MEMBER(key_callback);
170   TIMER_CALLBACK_MEMBER(ext_cassette_read);
171   TIMER_CALLBACK_MEMBER(transmit_data);
172   TIMER_CALLBACK_MEMBER(receive_data);
170173};
171174
172175
r18114r18115
303306}
304307
305308/* external cassette or barcode reader input */
306static TIMER_CALLBACK( ext_cassette_read )
309TIMER_CALLBACK_MEMBER(px4_state::ext_cassette_read)
307310{
308   px4_state *px4 = machine.driver_data<px4_state>();
309311   UINT8 result;
310312   int trigger = 0;
311313
312314   /* sample input state */
313   result = (px4->m_ext_cas->input() > 0) ? 1 : 0;
315   result = (m_ext_cas->input() > 0) ? 1 : 0;
314316
315317   /* detect transition */
316   switch ((px4->m_ctrl1 >> 1) & 0x03)
318   switch ((m_ctrl1 >> 1) & 0x03)
317319   {
318320   case 0: /* trigger inhibit */
319321      trigger = 0;
320322      break;
321323   case 1: /* falling edge trigger */
322      trigger = px4->m_ear_last_state == 1 && result == 0;
324      trigger = m_ear_last_state == 1 && result == 0;
323325      break;
324326   case 2: /* rising edge trigger */
325      trigger = px4->m_ear_last_state == 0 && result == 1;
327      trigger = m_ear_last_state == 0 && result == 1;
326328      break;
327329   case 3: /* rising/falling edge trigger */
328      trigger = px4->m_ear_last_state != result;
330      trigger = m_ear_last_state != result;
329331      break;
330332   }
331333
332334   /* generate an interrupt if we need to trigger */
333335   if (trigger)
334336   {
335      px4->m_icrb = px4->m_frc_value;
336      px4->m_isr |= INT2_ICF;
337      gapnit_interrupt(machine);
337      m_icrb = m_frc_value;
338      m_isr |= INT2_ICF;
339      gapnit_interrupt(machine());
338340   }
339341
340342   /* save last state */
341   px4->m_ear_last_state = result;
343   m_ear_last_state = result;
342344}
343345
344346/* free running counter */
r18114r18115
747749    GAPNIO
748750***************************************************************************/
749751
750static TIMER_CALLBACK( transmit_data )
752TIMER_CALLBACK_MEMBER(px4_state::transmit_data)
751753{
752   px4_state *px4 = machine.driver_data<px4_state>();
753754
754   if (BIT(px4->m_artcr, 0))// ART_TX_ENABLED
755   if (BIT(m_artcr, 0))// ART_TX_ENABLED
755756   {
756757
757758   }
758759}
759760
760static TIMER_CALLBACK( receive_data )
761TIMER_CALLBACK_MEMBER(px4_state::receive_data)
761762{
762   px4_state *px4 = machine.driver_data<px4_state>();
763   px4_state *px4 = machine().driver_data<px4_state>();
763764
764765   if (ART_RX_ENABLED)
765766   {
r18114r18115
10871088   m_alarm_int_enabled = TRUE;
10881089
10891090   /* art */
1090   m_receive_timer = machine().scheduler().timer_alloc(FUNC(receive_data));
1091   m_transmit_timer = machine().scheduler().timer_alloc(FUNC(transmit_data));
1091   m_receive_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(px4_state::receive_data),this));
1092   m_transmit_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(px4_state::transmit_data),this));
10921093
10931094   /* printer */
10941095   m_centronics = machine().device<centronics_device>("centronics");
10951096
10961097   /* external cassette or barcode reader */
1097   m_ext_cas_timer = machine().scheduler().timer_alloc(FUNC(ext_cassette_read));
1098   m_ext_cas_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(px4_state::ext_cassette_read),this));
10981099   m_ext_cas = machine().device<cassette_image_device>("extcas");
10991100   m_ear_last_state = 0;
11001101
trunk/src/mess/drivers/vg5k.c
r18114r18115
8888   DECLARE_READ8_MEMBER ( cassette_r );
8989   DECLARE_WRITE8_MEMBER ( cassette_w );
9090   DECLARE_DRIVER_INIT(vg5k);
91   TIMER_CALLBACK_MEMBER(z80_irq_clear);
9192};
9293
9394
r18114r18115
274275INPUT_PORTS_END
275276
276277
277static TIMER_CALLBACK( z80_irq_clear )
278TIMER_CALLBACK_MEMBER(vg5k_state::z80_irq_clear)
278279{
279   machine.device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
280   machine().device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
280281}
281282
282283
283284static TIMER_DEVICE_CALLBACK( z80_irq )
284285{
286   vg5k_state *state = timer.machine().driver_data<vg5k_state>();
285287   timer.machine().device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
286288
287   timer.machine().scheduler().timer_set(attotime::from_usec(100), FUNC(z80_irq_clear));
289   timer.machine().scheduler().timer_set(attotime::from_usec(100), timer_expired_delegate(FUNC(vg5k_state::z80_irq_clear),state));
288290}
289291
290292static TIMER_DEVICE_CALLBACK( vg5k_scanline )
trunk/src/mess/drivers/pcfx.c
r18114r18115
6060   DECLARE_WRITE_LINE_MEMBER( irq13_w );
6161   DECLARE_WRITE_LINE_MEMBER( irq14_w );
6262   DECLARE_WRITE_LINE_MEMBER( irq15_w );
63   TIMER_CALLBACK_MEMBER(pad_func);
6364};
6465
6566
r18114r18115
117118   return res;
118119}
119120
120static TIMER_CALLBACK(pad_func)
121TIMER_CALLBACK_MEMBER(pcfx_state::pad_func)
121122{
122   pcfx_state *state = machine.driver_data<pcfx_state>();
123123   const char *const padnames[] = { "P1", "P2" };
124124
125   state->m_pad.latch[param] = machine.root_device().ioport(padnames[param])->read();
126   state->m_pad.status[param] |= 8;
127   state->m_pad.ctrl[param] &= ~1; // ack TX line
125   m_pad.latch[param] = machine().root_device().ioport(padnames[param])->read();
126   m_pad.status[param] |= 8;
127   m_pad.ctrl[param] &= ~1; // ack TX line
128128   // TODO: pad IRQ
129//  state->set_irq_line(11, 1);
129//  set_irq_line(11, 1);
130130}
131131
132132WRITE16_MEMBER( pcfx_state::pad_w )
r18114r18115
143143        */
144144      if(data & 1 && (!(m_pad.ctrl[port_type] & 1)))
145145      {
146         machine().scheduler().timer_set(attotime::from_msec(1), FUNC(pad_func), port_type); // TODO: time
146         machine().scheduler().timer_set(attotime::from_msec(1), timer_expired_delegate(FUNC(pcfx_state::pad_func),this), port_type); // TODO: time
147147      }
148148
149149      m_pad.ctrl[port_type] = data & 7;
trunk/src/mess/drivers/pockstat.c
r18114r18115
124124   virtual void machine_reset();
125125   UINT32 screen_update_pockstat(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
126126   DECLARE_INPUT_CHANGED_MEMBER(input_update);
127   TIMER_CALLBACK_MEMBER(timer_tick);
128   TIMER_CALLBACK_MEMBER(rtc_tick);
127129};
128130
129131
r18114r18115
182184
183185
184186// Timers
185static TIMER_CALLBACK( timer_tick );
187
186188static void ps_timer_start(running_machine &machine, int index);
187189
188190
r18114r18115
192194
193195
194196// RTC
195static TIMER_CALLBACK( rtc_tick );
196197
197198
198199
200
199201#define PS_INT_BTN_ACTION      0x00000001 // "Action button"
200202#define PS_INT_BTN_RIGHT      0x00000002 // "Right button"
201203#define PS_INT_BTN_LEFT         0x00000004 // "Left button"
r18114r18115
422424   }
423425}
424426
425static TIMER_CALLBACK( timer_tick )
427TIMER_CALLBACK_MEMBER(pockstat_state::timer_tick)
426428{
427   pockstat_state *state = machine.driver_data<pockstat_state>();
428   ps_intc_set_interrupt_line(machine, param == 2 ? PS_INT_TIMER2 : (param == 1 ? PS_INT_TIMER1 : PS_INT_TIMER0), 1);
429   ps_intc_set_interrupt_line(machine(), param == 2 ? PS_INT_TIMER2 : (param == 1 ? PS_INT_TIMER1 : PS_INT_TIMER0), 1);
429430   //printf( "Timer %d is calling back\n", param );
430   state->m_timer_regs.timer[param].count = state->m_timer_regs.timer[param].period;
431   ps_timer_start(machine, param);
431   m_timer_regs.timer[param].count = m_timer_regs.timer[param].period;
432   ps_timer_start(machine(), param);
432433}
433434
434435static void ps_timer_start(running_machine &machine, int index)
r18114r18115
561562   }
562563}
563564
564static TIMER_CALLBACK( rtc_tick )
565TIMER_CALLBACK_MEMBER(pockstat_state::rtc_tick)
565566{
566   pockstat_state *state = machine.driver_data<pockstat_state>();
567567   //printf( "RTC is calling back\n" );
568   ps_intc_set_interrupt_line(machine, PS_INT_RTC, ps_intc_get_interrupt_line(machine, PS_INT_RTC) ? 0 : 1);
569   if(!(state->m_rtc_regs.mode & 1))
568   ps_intc_set_interrupt_line(machine(), PS_INT_RTC, ps_intc_get_interrupt_line(machine(), PS_INT_RTC) ? 0 : 1);
569   if(!(m_rtc_regs.mode & 1))
570570   {
571      state->m_rtc_regs.time++;
572      if((state->m_rtc_regs.time & 0x0000000f) == 0x0000000a)
571      m_rtc_regs.time++;
572      if((m_rtc_regs.time & 0x0000000f) == 0x0000000a)
573573      {
574         state->m_rtc_regs.time &= 0xfffffff0;
575         state->m_rtc_regs.time += 0x00000010;
576         if((state->m_rtc_regs.time & 0x000000ff) == 0x00000060)
574         m_rtc_regs.time &= 0xfffffff0;
575         m_rtc_regs.time += 0x00000010;
576         if((m_rtc_regs.time & 0x000000ff) == 0x00000060)
577577         {
578            state->m_rtc_regs.time &= 0xffffff00;
579            state->m_rtc_regs.time += 0x00000100;
580            if((state->m_rtc_regs.time & 0x00000f00) == 0x00000a00)
578            m_rtc_regs.time &= 0xffffff00;
579            m_rtc_regs.time += 0x00000100;
580            if((m_rtc_regs.time & 0x00000f00) == 0x00000a00)
581581            {
582               state->m_rtc_regs.time &= 0xfffff0ff;
583               state->m_rtc_regs.time += 0x00001000;
584               if((state->m_rtc_regs.time & 0x0000ff00) == 0x00006000)
582               m_rtc_regs.time &= 0xfffff0ff;
583               m_rtc_regs.time += 0x00001000;
584               if((m_rtc_regs.time & 0x0000ff00) == 0x00006000)
585585               {
586                  state->m_rtc_regs.time &= 0xffff00ff;
587                  state->m_rtc_regs.time += 0x00010000;
588                  if((state->m_rtc_regs.time & 0x00ff0000) == 0x00240000)
586                  m_rtc_regs.time &= 0xffff00ff;
587                  m_rtc_regs.time += 0x00010000;
588                  if((m_rtc_regs.time & 0x00ff0000) == 0x00240000)
589589                  {
590                     state->m_rtc_regs.time &= 0xff00ffff;
591                     state->m_rtc_regs.time += 0x01000000;
592                     if((state->m_rtc_regs.time & 0x0f000000) == 0x08000000)
590                     m_rtc_regs.time &= 0xff00ffff;
591                     m_rtc_regs.time += 0x01000000;
592                     if((m_rtc_regs.time & 0x0f000000) == 0x08000000)
593593                     {
594                        state->m_rtc_regs.time &= 0xf0ffffff;
595                        state->m_rtc_regs.time |= 0x01000000;
594                        m_rtc_regs.time &= 0xf0ffffff;
595                        m_rtc_regs.time |= 0x01000000;
596596                     }
597597                  }
598                  else if((state->m_rtc_regs.time & 0x000f0000) == 0x000a0000)
598                  else if((m_rtc_regs.time & 0x000f0000) == 0x000a0000)
599599                  {
600                     state->m_rtc_regs.time &= 0xfff0ffff;
601                     state->m_rtc_regs.time += 0x00100000;
600                     m_rtc_regs.time &= 0xfff0ffff;
601                     m_rtc_regs.time += 0x00100000;
602602                  }
603603               }
604604            }
605605         }
606606      }
607607   }
608   state->m_rtc_regs.timer->adjust(attotime::from_hz(1));
608   m_rtc_regs.timer->adjust(attotime::from_hz(1));
609609}
610610
611611READ32_MEMBER(pockstat_state::ps_rtc_r)
r18114r18115
875875   int index = 0;
876876   for(index = 0; index < 3; index++)
877877   {
878      m_timer_regs.timer[index].timer = machine().scheduler().timer_alloc(FUNC(timer_tick));
878      m_timer_regs.timer[index].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pockstat_state::timer_tick),this));
879879      m_timer_regs.timer[index].timer->adjust(attotime::never, index);
880880   }
881881
882882   m_rtc_regs.time = 0x01000000;
883883   m_rtc_regs.date = 0x19990101;
884884
885   m_rtc_regs.timer = machine().scheduler().timer_alloc(FUNC(rtc_tick));
885   m_rtc_regs.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pockstat_state::rtc_tick),this));
886886   m_rtc_regs.timer->adjust(attotime::from_hz(1), index);
887887
888888   save_item(NAME(m_ftlb_regs.control));

Previous 199869 Revisions Next


© 1997-2024 The MAME Team