Previous 199869 Revisions Next

r18114 Monday 24th September, 2012 at 14:43:01 UTC by Miodrag Milanović
modernization or timer callbacks part 2 (no whatsnew)
[src/mess/drivers]atarist.c beta.c coleco.c cxhumax.c fm7.c fmtowns.c gba.c gp32.c intv.c mpf1.c nc.c osi.c pcw.c pdp1.c samcoupe.c sg1000.c studio2.c svision.c tmc1800.c tx0.c x07.c x1.c x68k.c xerox820.c
[src/mess/includes]aim65.h amstrad.h apple1.h apple2gs.h atarist.h bbc.h bebox.h beta.h bk.h cgenie.h coleco.h compis.h cxhumax.h dai.h electron.h fm7.h fmtowns.h galaxy.h gamecom.h gb.h gba.h gp32.h hec2hrp.h hp48.h intv.h irisha.h kaypro.h kc.h lisa.h lviv.h lynx.h mac.h macpci.h mbc55x.h mbee.h microtan.h mikro80.h mpf1.h nc.h nes.h odyssey2.h ondra.h oric.h osborne1.h osi.h pc.h pc1251.h pc1350.h pc1401.h pc1403.h pce.h pcw.h pdp1.h pecom.h pet.h pmd85.h pokemini.h poly88.h radio86.h rm380z.h rmnimbus.h samcoupe.h sg1000.h sms.h sorcerer.h special.h studio2.h super80.h svision.h sym1.h ti85.h tmc1800.h trs80.h tx0.h ut88.h vector06.h wswan.h x07.h x1.h x68k.h xerox820.h z80ne.h zx.h
[src/mess/machine]aim65.c amstrad.c apple1.c apple2gs.c bbc.c bebox.c bk.c cgenie.c compis.c dai.c electron.c gamecom.c gb.c hec2hrp.c hp48.c intv.c irisha.c kaypro.c kc.c lisa.c lviv.c lynx.c mac.c macpci.c mbc55x.c mbee.c microtan.c mikro80.c nes.c ondra.c oric.c osborne1.c pc.c pc1251.c pc1350.c pc1401.c pc1403.c pce.c pecom.c pet.c pmd85.c pokemini.c poly88.c radio86.c rm380z.c rmnimbus.c samcoupe.c sms.c sorcerer.c special.c super80.c sym1.c ti85.c trs80.c ut88.c vector06.c wswan.c z80ne.c zx.c
[src/mess/video]atarist.c electron.c fm7.c fmtowns.c galaxy.c gamecom.c gb.c mac.c odyssey2.c oric.c samcoupe.c x68k.c zx.c

trunk/src/mess/machine/cgenie.c
r18113r18114
3232
3333
3434
35static TIMER_CALLBACK( handle_cassette_input )
35TIMER_CALLBACK_MEMBER(cgenie_state::handle_cassette_input)
3636{
37   cgenie_state *state = machine.driver_data<cgenie_state>();
38   UINT8 new_level = ( (machine.device<cassette_image_device>(CASSETTE_TAG)->input()) > 0.0 ) ? 1 : 0;
37   UINT8 new_level = ( (machine().device<cassette_image_device>(CASSETTE_TAG)->input()) > 0.0 ) ? 1 : 0;
3938
40   if ( new_level != state->m_cass_level )
39   if ( new_level != m_cass_level )
4140   {
42      state->m_cass_level = new_level;
43      state->m_cass_bit ^= 1;
41      m_cass_level = new_level;
42      m_cass_bit ^= 1;
4443   }
4544}
4645
r18113r18114
151150   space.install_legacy_write_handler(0x4000, 0x4000 + machine().device<ram_device>(RAM_TAG)->size() - 1, FUNC(cgenie_videoram_w));
152151   m_videoram = machine().device<ram_device>(RAM_TAG)->pointer();
153152   membank("bank1")->set_base(machine().device<ram_device>(RAM_TAG)->pointer());
154   machine().scheduler().timer_pulse(attotime::from_hz(11025), FUNC(handle_cassette_input));
153   machine().scheduler().timer_pulse(attotime::from_hz(11025), timer_expired_delegate(FUNC(cgenie_state::handle_cassette_input),this));
155154}
156155
157156/*************************************
trunk/src/mess/machine/sms.c
r18113r18114
3030static void setup_rom(address_space &space);
3131
3232
33static TIMER_CALLBACK( rapid_fire_callback )
33TIMER_CALLBACK_MEMBER(sms_state::rapid_fire_callback)
3434{
35   sms_state *state = machine.driver_data<sms_state>();
36   state->m_rapid_fire_state_1 ^= 0xff;
37   state->m_rapid_fire_state_2 ^= 0xff;
35   m_rapid_fire_state_1 ^= 0xff;
36   m_rapid_fire_state_2 ^= 0xff;
3837}
3938
4039
r18113r18114
487486
488487// at each input port read we check if lightguns are enabled in one of the ports:
489488// if so, we turn on crosshair and the lightgun timer
490static TIMER_CALLBACK( lightgun_tick )
489TIMER_CALLBACK_MEMBER(sms_state::lightgun_tick)
491490{
492   sms_state *state = machine.driver_data<sms_state>();
493491
494   if ((state->ioport("CTRLSEL")->read_safe(0x00) & 0x0f) == 0x01)
492   if ((ioport("CTRLSEL")->read_safe(0x00) & 0x0f) == 0x01)
495493   {
496494      /* enable crosshair */
497      crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL);
498      if (!state->m_lphaser_1_timer->enabled())
499         lphaser1_sensor_check(machine);
495      crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_ALL);
496      if (!m_lphaser_1_timer->enabled())
497         lphaser1_sensor_check(machine());
500498   }
501499   else
502500   {
503501      /* disable crosshair */
504      crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE);
505      state->m_lphaser_1_timer->enable(0);
502      crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_NONE);
503      m_lphaser_1_timer->enable(0);
506504   }
507505
508   if ((state->ioport("CTRLSEL")->read_safe(0x00) & 0xf0) == 0x10)
506   if ((ioport("CTRLSEL")->read_safe(0x00) & 0xf0) == 0x10)
509507   {
510508      /* enable crosshair */
511      crosshair_set_screen(machine, 1, CROSSHAIR_SCREEN_ALL);
512      if (!state->m_lphaser_2_timer->enabled())
513         lphaser2_sensor_check(machine);
509      crosshair_set_screen(machine(), 1, CROSSHAIR_SCREEN_ALL);
510      if (!m_lphaser_2_timer->enabled())
511         lphaser2_sensor_check(machine());
514512   }
515513   else
516514   {
517515      /* disable crosshair */
518      crosshair_set_screen(machine, 1, CROSSHAIR_SCREEN_NONE);
519      state->m_lphaser_2_timer->enable(0);
516      crosshair_set_screen(machine(), 1, CROSSHAIR_SCREEN_NONE);
517      m_lphaser_2_timer->enable(0);
520518   }
521519}
522520
523521
524static TIMER_CALLBACK( lphaser_1_callback )
522TIMER_CALLBACK_MEMBER(sms_state::lphaser_1_callback)
525523{
526   lphaser1_sensor_check(machine);
524   lphaser1_sensor_check(machine());
527525}
528526
529527
530static TIMER_CALLBACK( lphaser_2_callback )
528TIMER_CALLBACK_MEMBER(sms_state::lphaser_2_callback)
531529{
532   lphaser2_sensor_check(machine);
530   lphaser2_sensor_check(machine());
533531}
534532
535533
r18113r18114
571569   }
572570
573571   /* Check if lightgun has been chosen as input: if so, enable crosshair */
574   machine.scheduler().timer_set(attotime::zero, FUNC(lightgun_tick));
572   machine.scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(sms_state::lightgun_tick),state));
575573
576574   /* Player 1 */
577575   switch (machine.root_device().ioport("CTRLSEL")->read_safe(0x00) & 0x0f)
r18113r18114
19261924{
19271925
19281926   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(sms_machine_stop),&machine()));
1929   m_rapid_fire_timer = machine().scheduler().timer_alloc(FUNC(rapid_fire_callback));
1927   m_rapid_fire_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sms_state::rapid_fire_callback),this));
19301928   m_rapid_fire_timer->adjust(attotime::from_hz(10), 0, attotime::from_hz(10));
19311929
1932   m_lphaser_1_timer = machine().scheduler().timer_alloc(FUNC(lphaser_1_callback));
1933   m_lphaser_2_timer = machine().scheduler().timer_alloc(FUNC(lphaser_2_callback));
1930   m_lphaser_1_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sms_state::lphaser_1_callback),this));
1931   m_lphaser_2_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sms_state::lphaser_2_callback),this));
19341932
19351933   m_main_cpu = machine().device("maincpu");
19361934   m_control_cpu = machine().device("control");
r18113r18114
19431941   m_space = &machine().device("maincpu")->memory().space(AS_PROGRAM);
19441942
19451943   /* Check if lightgun has been chosen as input: if so, enable crosshair */
1946   machine().scheduler().timer_set(attotime::zero, FUNC(lightgun_tick));
1944   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(sms_state::lightgun_tick),this));
19471945}
19481946
19491947MACHINE_RESET_MEMBER(sms_state,sms)
trunk/src/mess/machine/radio86.c
r18113r18114
154154   { DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_HANDLER("i8275", i8275_dack_w), DEVCB_NULL }
155155};
156156
157static TIMER_CALLBACK( radio86_reset )
157TIMER_CALLBACK_MEMBER(radio86_state::radio86_reset)
158158{
159   radio86_state *state = machine.driver_data<radio86_state>();
160   state->membank("bank1")->set_entry(0);
159   membank("bank1")->set_entry(0);
161160}
162161
163162
r18113r18114
178177
179178MACHINE_RESET_MEMBER(radio86_state,radio86)
180179{
181   machine().scheduler().timer_set(attotime::from_usec(10), FUNC(radio86_reset));
180   machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(radio86_state::radio86_reset),this));
182181   membank("bank1")->set_entry(1);
183182
184183   m_keyboard_mask = 0;
trunk/src/mess/machine/intv.c
r18113r18114
650650}
651651
652652
653static TIMER_CALLBACK(intv_interrupt_complete)
653TIMER_CALLBACK_MEMBER(intv_state::intv_interrupt_complete)
654654{
655   intv_state *state = machine.driver_data<intv_state>();
656   machine.device("maincpu")->execute().set_input_line(CP1610_INT_INTRM, CLEAR_LINE);
657   state->m_bus_copy_mode = 0;
655   machine().device("maincpu")->execute().set_input_line(CP1610_INT_INTRM, CLEAR_LINE);
656   m_bus_copy_mode = 0;
658657}
659658
660static TIMER_CALLBACK(intv_btb_fill)
659TIMER_CALLBACK_MEMBER(intv_state::intv_btb_fill)
661660{
662   intv_state *state = machine.driver_data<intv_state>();
663661   UINT8 column;
664   UINT8 row = state->m_backtab_row;
665   //machine.device("maincpu")->execute().adjust_icount(-STIC_ROW_FETCH);
662   UINT8 row = m_backtab_row;
663   //machine().device("maincpu")->execute().adjust_icount(-STIC_ROW_FETCH);
666664   for(column=0; column < STIC_BACKTAB_WIDTH; column++)
667665   {
668      state->m_backtab_buffer[row][column] = state->m_ram16[column + row * STIC_BACKTAB_WIDTH];
666      m_backtab_buffer[row][column] = m_ram16[column + row * STIC_BACKTAB_WIDTH];
669667   }
670668
671   state->m_backtab_row += 1;
669   m_backtab_row += 1;
672670}
673671
674672INTERRUPT_GEN_MEMBER(intv_state::intv_interrupt)
r18113r18114
680678   UINT8 row;
681679   machine().device("maincpu")->execute().adjust_icount(-(12*STIC_ROW_BUSRQ+STIC_FRAME_BUSRQ)); // Account for stic cycle stealing
682680   machine().scheduler().timer_set(machine().device<cpu_device>("maincpu")
683      ->cycles_to_attotime(STIC_VBLANK_END), FUNC(intv_interrupt_complete));
681      ->cycles_to_attotime(STIC_VBLANK_END), timer_expired_delegate(FUNC(intv_state::intv_interrupt_complete),this));
684682   for (row=0; row < STIC_BACKTAB_HEIGHT; row++)
685683   {
686684      machine().scheduler().timer_set(machine().device<cpu_device>("maincpu")
687         ->cycles_to_attotime(STIC_FIRST_FETCH-STIC_FRAME_BUSRQ+STIC_CYCLES_PER_SCANLINE*STIC_Y_SCALE*m_row_delay + (STIC_CYCLES_PER_SCANLINE*STIC_Y_SCALE*STIC_CARD_HEIGHT - STIC_ROW_BUSRQ)*row), FUNC(intv_btb_fill));
685         ->cycles_to_attotime(STIC_FIRST_FETCH-STIC_FRAME_BUSRQ+STIC_CYCLES_PER_SCANLINE*STIC_Y_SCALE*m_row_delay + (STIC_CYCLES_PER_SCANLINE*STIC_Y_SCALE*STIC_CARD_HEIGHT - STIC_ROW_BUSRQ)*row), timer_expired_delegate(FUNC(intv_state::intv_btb_fill),this));
688686   }
689687
690688   if (m_row_delay == 0)
trunk/src/mess/machine/kc.c
r18113r18114
210210   }
211211}
212212
213static TIMER_CALLBACK(kc_cassette_oneshot_timer)
213TIMER_CALLBACK_MEMBER(kc_state::kc_cassette_oneshot_timer)
214214{
215   kc_state *state = machine.driver_data<kc_state>();
216215
217   state->update_cassette(0);
216   update_cassette(0);
218217
219   state->m_cassette_oneshot_timer->reset();
218   m_cassette_oneshot_timer->reset();
220219}
221220
222221// timer used for polling data from cassette input
223222// enabled only when cassette motor is on
224static TIMER_CALLBACK(kc_cassette_timer_callback)
223TIMER_CALLBACK_MEMBER(kc_state::kc_cassette_timer_callback)
225224{
226   kc_state *state = machine.driver_data<kc_state>();
227225
228226   // read cassette data
229   int bit = (state->m_cassette->input() > 0.0038) ? 1 : 0;
227   int bit = (m_cassette->input() > 0.0038) ? 1 : 0;
230228
231229   // generates a pulse when the cassette input changes state
232   if (bit ^ state->m_cassette_in)
230   if (bit ^ m_cassette_in)
233231   {
234      state->update_cassette(1);
235      state->m_cassette_in = bit;
236      state->m_cassette_oneshot_timer->adjust(attotime::from_double(TIME_OF_74LS123(RES_K(10), CAP_N(1))));
232      update_cassette(1);
233      m_cassette_in = bit;
234      m_cassette_oneshot_timer->adjust(attotime::from_double(TIME_OF_74LS123(RES_K(10), CAP_N(1))));
237235   }
238236}
239237
r18113r18114
759757
760758void kc_state::machine_start()
761759{
762   m_cassette_timer = machine().scheduler().timer_alloc(FUNC(kc_cassette_timer_callback));
763   m_cassette_oneshot_timer = machine().scheduler().timer_alloc(FUNC(kc_cassette_oneshot_timer));
760   m_cassette_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(kc_state::kc_cassette_timer_callback),this));
761   m_cassette_oneshot_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(kc_state::kc_cassette_oneshot_timer),this));
764762
765763   m_ram_base = m_ram->pointer();
766764
trunk/src/mess/machine/mbc55x.c
r18113r18114
285285   }
286286}
287287
288static TIMER_CALLBACK(keyscan_callback)
288TIMER_CALLBACK_MEMBER(mbc55x_state::keyscan_callback)
289289{
290   scan_keyboard(machine);
290   scan_keyboard(machine());
291291}
292292
293293/* i8251 serial */
r18113r18114
409409   m_debug_machine=DEBUG_NONE;
410410
411411   // Allocate keyscan timer
412   m_keyboard.keyscan_timer=machine().scheduler().timer_alloc(FUNC(keyscan_callback));
412   m_keyboard.keyscan_timer=machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mbc55x_state::keyscan_callback),this));
413413}
414414
415415
trunk/src/mess/machine/ut88.c
r18113r18114
6060   DEVCB_NULL,
6161};
6262
63static TIMER_CALLBACK( ut88_reset )
63TIMER_CALLBACK_MEMBER(ut88_state::ut88_reset)
6464{
65   ut88_state *state = machine.driver_data<ut88_state>();
66   state->membank("bank1")->set_entry(0);
65   membank("bank1")->set_entry(0);
6766}
6867
6968MACHINE_RESET_MEMBER(ut88_state,ut88)
7069{
71   machine().scheduler().timer_set(attotime::from_usec(10), FUNC(ut88_reset));
70   machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(ut88_state::ut88_reset),this));
7271   membank("bank1")->set_entry(1);
7372   m_keyboard_mask = 0;
7473}
r18113r18114
148147    0x39, 0x5e, 0x79, 0x71
149148};
150149
151static TIMER_CALLBACK( update_display )
150TIMER_CALLBACK_MEMBER(ut88_state::update_display)
152151{
153   ut88_state *state = machine.driver_data<ut88_state>();
154152   int i;
155153   for (i=0;i<6;i++)
156      output_set_digit_value(i, hex_to_7seg[state->m_lcd_digit[i]]);
154      output_set_digit_value(i, hex_to_7seg[m_lcd_digit[i]]);
157155}
158156
159157
r18113r18114
163161
164162MACHINE_START_MEMBER(ut88_state,ut88mini)
165163{
166   machine().scheduler().timer_pulse(attotime::from_hz(60), FUNC(update_display));
164   machine().scheduler().timer_pulse(attotime::from_hz(60), timer_expired_delegate(FUNC(ut88_state::update_display),this));
167165}
168166
169167MACHINE_RESET_MEMBER(ut88_state,ut88mini)
trunk/src/mess/machine/pc1403.c
r18113r18114
152152   machine.device<nvram_device>("ram_nvram")->set_base(ram, 0x8000);
153153}
154154
155static TIMER_CALLBACK(pc1403_power_up)
155TIMER_CALLBACK_MEMBER(pc1403_state::pc1403_power_up)
156156{
157   pc1403_state *state = machine.driver_data<pc1403_state>();
158   state->m_power=0;
157   m_power=0;
159158}
160159
161160DRIVER_INIT_MEMBER(pc1403_state,pc1403)
r18113r18114
166165   for (i=0; i<128; i++) gfx[i]=i;
167166
168167   m_power = 1;
169   machine().scheduler().timer_set(attotime::from_seconds(1), FUNC(pc1403_power_up));
168   machine().scheduler().timer_set(attotime::from_seconds(1), timer_expired_delegate(FUNC(pc1403_state::pc1403_power_up),this));
170169
171170   membank("bank1")->set_base(memregion("user1")->base());
172171}
trunk/src/mess/machine/apple1.c
r18113r18114
5151#include "imagedev/cassette.h"
5252#include "machine/ram.h"
5353
54static TIMER_CALLBACK(apple1_kbd_poll);
55static TIMER_CALLBACK(apple1_kbd_strobe_end);
5654
55
56
5757static DECLARE_READ8_DEVICE_HANDLER( apple1_pia0_kbdin );
5858static DECLARE_WRITE8_DEVICE_HANDLER( apple1_pia0_dspout );
5959static DECLARE_WRITE8_DEVICE_HANDLER( apple1_pia0_dsp_write_signal );
6060
61static TIMER_CALLBACK(apple1_dsp_ready_start);
62static TIMER_CALLBACK(apple1_dsp_ready_end);
6361
62
63
6464/*****************************************************************************
6565**  Structures
6666*****************************************************************************/
r18113r18114
158158
159159       A 120-Hz poll rate seems to be fast enough to ensure no
160160       keystrokes are missed. */
161   machine().scheduler().timer_pulse(attotime::from_hz(120), FUNC(apple1_kbd_poll));
161   machine().scheduler().timer_pulse(attotime::from_hz(120), timer_expired_delegate(FUNC(apple1_state::apple1_kbd_poll),this));
162162}
163163
164164
r18113r18114
277277**  If multiple newly-pressed keys are found, the one closest to the
278278**  end of the input ports list is counted; the others are ignored.
279279*****************************************************************************/
280static TIMER_CALLBACK(apple1_kbd_poll)
280TIMER_CALLBACK_MEMBER(apple1_state::apple1_kbd_poll)
281281{
282   apple1_state *state = machine.driver_data<apple1_state>();
283282   int port, bit;
284283   int key_pressed;
285284   UINT32 shiftkeys, ctrlkeys;
286   pia6821_device *pia = machine.device<pia6821_device>("pia");
285   pia6821_device *pia = machine().device<pia6821_device>("pia");
287286   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3" };
288287
289288   /* This holds the values of all the input ports for ordinary keys
r18113r18114
292291   /* First we check the RESET and CLEAR SCREEN pushbutton switches. */
293292
294293   /* The RESET switch resets the CPU and the 6820 PIA. */
295   if (machine.root_device().ioport("KEY5")->read() & 0x0001)
294   if (machine().root_device().ioport("KEY5")->read() & 0x0001)
296295   {
297      if (!state->m_reset_flag) {
298         state->m_reset_flag = 1;
296      if (!m_reset_flag) {
297         m_reset_flag = 1;
299298         /* using PULSE_LINE does not allow us to press and hold key */
300         machine.device("maincpu")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
299         machine().device("maincpu")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
301300         pia->reset();
302301      }
303302   }
304   else if (state->m_reset_flag) {
303   else if (m_reset_flag) {
305304      /* RESET released--allow the processor to continue. */
306      state->m_reset_flag = 0;
307      machine.device("maincpu")->execute().set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
305      m_reset_flag = 0;
306      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
308307   }
309308
310309   /* The CLEAR SCREEN switch clears the video hardware. */
311   if (machine.root_device().ioport("KEY5")->read() & 0x0002)
310   if (machine().root_device().ioport("KEY5")->read() & 0x0002)
312311   {
313      if (!state->m_vh_clrscrn_pressed)
312      if (!m_vh_clrscrn_pressed)
314313      {
315314         /* Ignore further video writes, and clear the screen. */
316         state->m_vh_clrscrn_pressed = 1;
317         apple1_vh_dsp_clr(machine);
315         m_vh_clrscrn_pressed = 1;
316         apple1_vh_dsp_clr(machine());
318317      }
319318   }
320   else if (state->m_vh_clrscrn_pressed)
319   else if (m_vh_clrscrn_pressed)
321320   {
322321      /* CLEAR SCREEN released--pay attention to video writes again. */
323      state->m_vh_clrscrn_pressed = 0;
322      m_vh_clrscrn_pressed = 0;
324323   }
325324
326325   /* Now we scan all the input ports for ordinary keys, recording
327326       new keypresses while ignoring keys that were already pressed in
328327       the last scan. */
329328
330   state->m_kbd_data = 0;
329   m_kbd_data = 0;
331330   key_pressed = 0;
332331
333332   /* The keyboard strobe line should always be low when a scan starts. */
334333   pia->ca1_w(0);
335334
336   shiftkeys = machine.root_device().ioport("KEY4")->read() & 0x0003;
337   ctrlkeys = machine.root_device().ioport("KEY4")->read() & 0x000c;
335   shiftkeys = machine().root_device().ioport("KEY4")->read() & 0x0003;
336   ctrlkeys = machine().root_device().ioport("KEY4")->read() & 0x000c;
338337
339338   for (port = 0; port < 4; port++)
340339   {
341340      UINT32 portval, newkeys;
342341
343      portval = machine.root_device().ioport(keynames[port])->read();
344      newkeys = portval & ~(state->m_kbd_last_scan[port]);
342      portval = machine().root_device().ioport(keynames[port])->read();
343      newkeys = portval & ~(m_kbd_last_scan[port]);
345344
346345      if (newkeys)
347346      {
r18113r18114
349348         for (bit = 0; bit < 16; bit++) {
350349            if (newkeys & 1)
351350            {
352               state->m_kbd_data = (ctrlkeys)
351               m_kbd_data = (ctrlkeys)
353352                 ? apple1_control_keymap[port*16 + bit]
354353                 : (shiftkeys)
355354                 ? apple1_shifted_keymap[port*16 + bit]
r18113r18114
358357            newkeys >>= 1;
359358         }
360359      }
361      state->m_kbd_last_scan[port] = portval;
360      m_kbd_last_scan[port] = portval;
362361   }
363362
364363   if (key_pressed)
r18113r18114
366365      /* The keyboard will pulse its strobe line when a key is
367366           pressed.  A 10-usec pulse is typical. */
368367      pia->ca1_w(1);
369      machine.scheduler().timer_set(attotime::from_usec(10), FUNC(apple1_kbd_strobe_end));
368      machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(apple1_state::apple1_kbd_strobe_end),this));
370369   }
371370}
372371
373static TIMER_CALLBACK(apple1_kbd_strobe_end)
372TIMER_CALLBACK_MEMBER(apple1_state::apple1_kbd_strobe_end)
374373{
375   pia6821_device *pia = machine.device<pia6821_device>("pia");
374   pia6821_device *pia = machine().device<pia6821_device>("pia");
376375
377376   /* End of the keyboard strobe pulse. */
378377   pia->ca1_w(0);
r18113r18114
412411       Only then will it assert \RDA to signal readiness for another
413412       write.  Thus the write delay depends on the cursor position and
414413       where the display is in the refresh cycle. */
414   apple1_state *state = space.machine().driver_data<apple1_state>();     
415415   if (!data)
416      space.machine().scheduler().timer_set(apple1_vh_dsp_time_to_ready(space.machine()), FUNC(apple1_dsp_ready_start));
416      space.machine().scheduler().timer_set(apple1_vh_dsp_time_to_ready(space.machine()), timer_expired_delegate(FUNC(apple1_state::apple1_dsp_ready_start),state));
417417}
418418
419static TIMER_CALLBACK(apple1_dsp_ready_start)
419TIMER_CALLBACK_MEMBER(apple1_state::apple1_dsp_ready_start)
420420{
421   pia6821_device *pia = machine.device<pia6821_device>("pia");
421   pia6821_device *pia = machine().device<pia6821_device>("pia");
422422
423423   /* When the display asserts \RDA to signal it is ready, it
424424       triggers a 74123 one-shot to send a 3.5-usec low pulse to PIA
425425       input CB1.  The end of this pulse will tell the PIA that the
426426       display is ready for another write. */
427427   pia->cb1_w(0);
428   machine.scheduler().timer_set(attotime::from_nsec(3500), FUNC(apple1_dsp_ready_end));
428   machine().scheduler().timer_set(attotime::from_nsec(3500), timer_expired_delegate(FUNC(apple1_state::apple1_dsp_ready_end),this));
429429}
430430
431static TIMER_CALLBACK(apple1_dsp_ready_end)
431TIMER_CALLBACK_MEMBER(apple1_state::apple1_dsp_ready_end)
432432{
433   pia6821_device *pia = machine.device<pia6821_device>("pia");
433   pia6821_device *pia = machine().device<pia6821_device>("pia");
434434
435435   /* The one-shot pulse has ended; return CB1 to high, so we can do
436436       another display write. */
trunk/src/mess/machine/trs80.c
r18113r18114
2222#define MODEL4_MASTER_CLOCK 20275200
2323
2424
25static TIMER_CALLBACK( cassette_data_callback )
25TIMER_CALLBACK_MEMBER(trs80_state::cassette_data_callback)
2626{
27   trs80_state *state = machine.driver_data<trs80_state>();
2827/* This does all baud rates. 250 baud (trs80), and 500 baud (all others) set bit 7 of "cassette_data".
2928    1500 baud (trs80m3, trs80m4) is interrupt-driven and uses bit 0 of "cassette_data" */
3029
31   double new_val = (state->m_cass->input());
30   double new_val = (m_cass->input());
3231
3332   /* Check for HI-LO transition */
34   if ( state->m_old_cassette_val > -0.2 && new_val < -0.2 )
33   if ( m_old_cassette_val > -0.2 && new_val < -0.2 )
3534   {
36      state->m_cassette_data |= 0x80;      /* 500 baud */
37      if (state->m_mask & CASS_FALL)   /* see if 1500 baud */
35      m_cassette_data |= 0x80;      /* 500 baud */
36      if (m_mask & CASS_FALL)   /* see if 1500 baud */
3837      {
39         state->m_cassette_data = 0;
40         state->m_irq |= CASS_FALL;
41         machine.device("maincpu")->execute().set_input_line(0, HOLD_LINE);
38         m_cassette_data = 0;
39         m_irq |= CASS_FALL;
40         machine().device("maincpu")->execute().set_input_line(0, HOLD_LINE);
4241      }
4342   }
4443   else
45   if ( state->m_old_cassette_val < -0.2 && new_val > -0.2 )
44   if ( m_old_cassette_val < -0.2 && new_val > -0.2 )
4645   {
47      if (state->m_mask & CASS_RISE)   /* 1500 baud */
46      if (m_mask & CASS_RISE)   /* 1500 baud */
4847      {
49         state->m_cassette_data = 1;
50         state->m_irq |= CASS_RISE;
51         machine.device("maincpu")->execute().set_input_line(0, HOLD_LINE);
48         m_cassette_data = 1;
49         m_irq |= CASS_RISE;
50         machine().device("maincpu")->execute().set_input_line(0, HOLD_LINE);
5251      }
5352   }
5453
55   state->m_old_cassette_val = new_val;
54   m_old_cassette_val = new_val;
5655}
5756
5857
r18113r18114
852851   m_reg_load=1;
853852   m_nmi_data=0xff;
854853
855   m_cassette_data_timer = machine().scheduler().timer_alloc(FUNC(cassette_data_callback));
854   m_cassette_data_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(trs80_state::cassette_data_callback),this));
856855   m_cassette_data_timer->adjust( attotime::zero, 0, attotime::from_hz(11025) );
857856}
858857
trunk/src/mess/machine/mac.c
r18113r18114
127127
128128extern TIMER_CALLBACK(mac_adb_tick);   // macadb.c
129129extern TIMER_CALLBACK(mac_pmu_tick);   // macadb.c
130static TIMER_CALLBACK(mac_scanline_tick);
131static TIMER_CALLBACK(mac_6015_tick);
130
131
132132static int scan_keyboard(running_machine &machine);
133static TIMER_CALLBACK(inquiry_timeout_func);
133
134134static void keyboard_receive(running_machine &machine, int val);
135135static DECLARE_READ8_DEVICE_HANDLER(mac_via_in_a);
136136static DECLARE_READ8_DEVICE_HANDLER(mac_via_in_b);
r18113r18114
695695
696696/******************* Keyboard <-> VIA communication ***********************/
697697
698static TIMER_CALLBACK(kbd_clock)
698TIMER_CALLBACK_MEMBER(mac_state::kbd_clock)
699699{
700700   int i;
701   mac_state *mac = machine.driver_data<mac_state>();
702701
703   if (mac->m_kbd_comm == TRUE)
702   if (m_kbd_comm == TRUE)
704703   {
705704      for (i=0; i<8; i++)
706705      {
707706         /* Put data on CB2 if we are sending*/
708         if (mac->m_kbd_receive == FALSE)
709            mac->m_via1->write_cb2(mac->m_kbd_shift_reg&0x80?1:0);
710         mac->m_kbd_shift_reg <<= 1;
711         mac->m_via1->write_cb1(0);
712         mac->m_via1->write_cb1(1);
707         if (m_kbd_receive == FALSE)
708            m_via1->write_cb2(m_kbd_shift_reg&0x80?1:0);
709         m_kbd_shift_reg <<= 1;
710         m_via1->write_cb1(0);
711         m_via1->write_cb1(1);
713712      }
714      if (mac->m_kbd_receive == TRUE)
713      if (m_kbd_receive == TRUE)
715714      {
716         mac->m_kbd_receive = FALSE;
715         m_kbd_receive = FALSE;
717716         /* Process the command received from mac */
718         keyboard_receive(machine, mac->m_kbd_shift_reg & 0xff);
717         keyboard_receive(machine(), m_kbd_shift_reg & 0xff);
719718      }
720719      else
721720      {
722721         /* Communication is over */
723         mac->m_kbd_comm = FALSE;
722         m_kbd_comm = FALSE;
724723      }
725724   }
726725}
r18113r18114
732731   if (mac->m_kbd_comm == TRUE)
733732   {
734733      mac->m_kbd_shift_reg = data;
735      machine.scheduler().timer_set(attotime::from_msec(1), FUNC(kbd_clock));
734      machine.scheduler().timer_set(attotime::from_msec(1), timer_expired_delegate(FUNC(mac_state::kbd_clock),mac));
736735   }
737736}
738737
r18113r18114
745744      /* Mac pulls CB2 down to initiate communication */
746745      mac->m_kbd_comm = TRUE;
747746      mac->m_kbd_receive = TRUE;
748      space.machine().scheduler().timer_set(attotime::from_usec(100), FUNC(kbd_clock));
747      space.machine().scheduler().timer_set(attotime::from_usec(100), timer_expired_delegate(FUNC(mac_state::kbd_clock),mac));
749748   }
750749   if (mac->m_kbd_comm == TRUE && mac->m_kbd_receive == TRUE)
751750   {
r18113r18114
757756/*
758757    called when inquiry times out (1/4s)
759758*/
760static TIMER_CALLBACK(inquiry_timeout_func)
759TIMER_CALLBACK_MEMBER(mac_state::inquiry_timeout_func)
761760{
762761   if (LOG_KEYBOARD)
763762      logerror("keyboard enquiry timeout\n");
764   kbd_shift_out(machine, 0x7B);   /* always send NULL */
763   kbd_shift_out(machine(), 0x7B);   /* always send NULL */
765764}
766765
767766/*
r18113r18114
17701769}
17711770
17721771// This signal is generated internally on RBV, V8, Sonora, VASP, Eagle, etc.
1773static TIMER_CALLBACK(mac_6015_tick)
1772TIMER_CALLBACK_MEMBER(mac_state::mac_6015_tick)
17741773{
1775   mac_state *mac = machine.driver_data<mac_state>();
1776
1777   mac->m_via1->write_ca1(0);
1778   mac->m_via1->write_ca1(1);
1774   m_via1->write_ca1(0);
1775   m_via1->write_ca1(1);
17791776}
17801777
17811778/* *************************************************************************
r18113r18114
17981795      }
17991796
18001797   }
1801   this->m_scanline_timer = machine().scheduler().timer_alloc(FUNC(mac_scanline_tick));
1798   this->m_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mac_state::mac_scanline_tick),this));
18021799   this->m_scanline_timer->adjust(machine().primary_screen->time_until_pos(0, 0));
18031800
1804   m_6015_timer = machine().scheduler().timer_alloc(FUNC(mac_6015_tick));
1801   m_6015_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mac_state::mac_6015_tick),this));
18051802   m_6015_timer->adjust(attotime::never);
18061803}
18071804
r18113r18114
21052102   /* setup keyboard */
21062103   keyboard_init(mac);
21072104
2108   mac->m_inquiry_timeout = machine.scheduler().timer_alloc(FUNC(inquiry_timeout_func));
2105   mac->m_inquiry_timeout = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(mac_state::inquiry_timeout_func),mac));
21092106
21102107   /* save state stuff */
21112108   machine.save().register_postload(save_prepost_delegate(FUNC(mac_state_load), mac));
r18113r18114
22512248   }
22522249}
22532250
2254static TIMER_CALLBACK(mac_scanline_tick)
2251TIMER_CALLBACK_MEMBER(mac_state::mac_scanline_tick)
22552252{
22562253   int scanline;
2257   mac_state *mac = machine.driver_data<mac_state>();
22582254
2259   if (machine.device("custom") != NULL)
2255   if (machine().device("custom") != NULL)
22602256   {
2261      mac_sh_updatebuffer(machine.device("custom"));
2257      mac_sh_updatebuffer(machine().device("custom"));
22622258   }
22632259
2264   if (mac->m_rbv_vbltime > 0)
2260   if (m_rbv_vbltime > 0)
22652261   {
2266      mac->m_rbv_vbltime--;
2262      m_rbv_vbltime--;
22672263
2268      if (mac->m_rbv_vbltime == 0)
2264      if (m_rbv_vbltime == 0)
22692265      {
2270         mac->m_rbv_regs[2] |= 0x40;
2271         mac->rbv_recalc_irqs();
2266         m_rbv_regs[2] |= 0x40;
2267         rbv_recalc_irqs();
22722268      }
22732269   }
22742270
2275   scanline = machine.primary_screen->vpos();
2271   scanline = machine().primary_screen->vpos();
22762272   if (scanline == MAC_V_VIS)
2277      mac->vblank_irq();
2273      vblank_irq();
22782274
22792275   /* check for mouse changes at 10 irqs per frame */
2280   if (mac->m_model <= MODEL_MAC_PLUS)
2276   if (m_model <= MODEL_MAC_PLUS)
22812277   {
22822278      if (!(scanline % 10))
2283         mac->mouse_callback();
2279         mouse_callback();
22842280   }
22852281
2286   mac->m_scanline_timer->adjust(machine.primary_screen->time_until_pos((scanline+1) % MAC_V_TOTAL, 0));
2282   m_scanline_timer->adjust(machine().primary_screen->time_until_pos((scanline+1) % MAC_V_TOTAL, 0));
22872283}
22882284
22892285WRITE_LINE_MEMBER(mac_state::nubus_irq_9_w)
trunk/src/mess/machine/hp48.c
r18113r18114
9595#define RS232_DELAY attotime::from_usec( 300 )
9696
9797/* end of receive event */
98static TIMER_CALLBACK( hp48_rs232_byte_recv_cb )
98TIMER_CALLBACK_MEMBER(hp48_state::hp48_rs232_byte_recv_cb)
9999{
100   hp48_state *state = machine.driver_data<hp48_state>();
101100   LOG_SERIAL(( "%f hp48_rs232_byte_recv_cb: end of receive, data=%02x\n",
102           machine.time().as_double(), param ));
101           machine().time().as_double(), param ));
103102
104   state->m_io[0x14] = param & 0xf; /* receive zone */
105   state->m_io[0x15] = param >> 4;
106   state->m_io[0x11] &= ~2; /* clear byte receiving */
107   state->m_io[0x11] |= 1;  /* set byte received */
103   m_io[0x14] = param & 0xf; /* receive zone */
104   m_io[0x15] = param >> 4;
105   m_io[0x11] &= ~2; /* clear byte receiving */
106   m_io[0x11] |= 1;  /* set byte received */
108107
109108   /* interrupt */
110   if ( state->m_io[0x10] & 2 )
109   if ( m_io[0x10] & 2 )
111110   {
112      hp48_pulse_irq( machine, SATURN_IRQ_LINE );
111      hp48_pulse_irq( machine(), SATURN_IRQ_LINE );
113112   }
114113}
115114
r18113r18114
129128   }
130129
131130   /* schedule end of reception */
132   machine.scheduler().timer_set( RS232_DELAY, FUNC(hp48_rs232_byte_recv_cb), data);
131   machine.scheduler().timer_set( RS232_DELAY, timer_expired_delegate(FUNC(hp48_state::hp48_rs232_byte_recv_cb),state), data);
133132}
134133
135134
136135/* end of send event */
137static TIMER_CALLBACK( hp48_rs232_byte_sent_cb )
136TIMER_CALLBACK_MEMBER(hp48_state::hp48_rs232_byte_sent_cb)
138137{
139   hp48_state *state = machine.driver_data<hp48_state>();
140   //device_image_interface *xmodem = dynamic_cast<device_image_interface *>(machine.device("rs232_x"));
141   //device_image_interface *kermit = dynamic_cast<device_image_interface *>(machine.device("rs232_k"));
138   //device_image_interface *xmodem = dynamic_cast<device_image_interface *>(machine().device("rs232_x"));
139   //device_image_interface *kermit = dynamic_cast<device_image_interface *>(machine().device("rs232_k"));
142140
143141   LOG_SERIAL(( "%f hp48_rs232_byte_sent_cb: end of send, data=%02x\n",
144           machine.time().as_double(), param ));
142           machine().time().as_double(), param ));
145143
146   state->m_io[0x12] &= ~3; /* clear byte sending and buffer full */
144   m_io[0x12] &= ~3; /* clear byte sending and buffer full */
147145
148146   /* interrupt */
149   if ( state->m_io[0x10] & 4 )
147   if ( m_io[0x10] & 4 )
150148   {
151      hp48_pulse_irq( machine, SATURN_IRQ_LINE );
149      hp48_pulse_irq( machine(), SATURN_IRQ_LINE );
152150   }
153151
154152   /* protocol action */
155153   //if ( xmodem && xmodem->exists() ) xmodem_receive_byte( &xmodem->device(), param );
156154   //else if ( kermit && kermit->exists() ) kermit_receive_byte( &kermit->device(), param );
157155//#ifdef CHARDEV
158//  else chardev_out( state->m_chardev, param );
156//  else chardev_out( m_chardev, param );
159157//#endif
160158}
161159
r18113r18114
172170   state->m_io[0x12] |= 3;
173171
174172   /* schedule transmission */
175   machine.scheduler().timer_set( RS232_DELAY, FUNC(hp48_rs232_byte_sent_cb), data);
173   machine.scheduler().timer_set( RS232_DELAY, timer_expired_delegate(FUNC(hp48_state::hp48_rs232_byte_sent_cb),state), data);
176174}
177175
178176
179177#ifdef CHARDEV
180178
181static TIMER_CALLBACK( hp48_chardev_byte_recv_cb )
179TIMER_CALLBACK_MEMBER(hp48_state::hp48_chardev_byte_recv_cb)
182180{
183   hp48_state *state = machine.driver_data<hp48_state>();
184   UINT8 data = chardev_in( state->m_chardev );
181   UINT8 data = chardev_in( m_chardev );
185182
186183   LOG_SERIAL(( "%f hp48_chardev_byte_recv_cb: end of receive, data=%02x\n",
187           machine.time().as_double(), data ));
184           machine().time().as_double(), data ));
188185
189   state->m_io[0x14] = data & 0xf; /* receive zone */
190   state->m_io[0x15] = data >> 4;
191   state->m_io[0x11] &= ~2; /* clear byte receiving */
192   state->m_io[0x11] |= 1;  /* set byte received */
186   m_io[0x14] = data & 0xf; /* receive zone */
187   m_io[0x15] = data >> 4;
188   m_io[0x11] &= ~2; /* clear byte receiving */
189   m_io[0x11] |= 1;  /* set byte received */
193190
194191   /* interrupt */
195   if ( state->m_io[0x10] & 2 )
192   if ( m_io[0x10] & 2 )
196193   {
197      hp48_pulse_irq( machine, SATURN_IRQ_LINE );
194      hp48_pulse_irq( machine(), SATURN_IRQ_LINE );
198195   }
199196}
200197
r18113r18114
215212   }
216213
217214   /* schedule end of reception */
218   machine.scheduler().timer_set( RS232_DELAY, FUNC(hp48_chardev_byte_recv_cb));
215   machine.scheduler().timer_set( RS232_DELAY, timer_expired_delegate(FUNC(hp48_state::hp48_chardev_byte_recv_cb),this));
219216}
220217
221218static void hp48_chardev_ready_to_send( running_machine &machine )
r18113r18114
305302}
306303
307304/* periodic keyboard polling, generates an interrupt */
308static TIMER_CALLBACK( hp48_kbd_cb )
305TIMER_CALLBACK_MEMBER(hp48_state::hp48_kbd_cb)
309306{
310   hp48_state *state = machine.driver_data<hp48_state>();
311307   /* NMI for ON key */
312   if ( machine.root_device().ioport( "ON" )->read() )
308   if ( machine().root_device().ioport( "ON" )->read() )
313309   {
314310      LOG(( "%f hp48_kbd_cb: keyboard interrupt, on key\n",
315            machine.time().as_double() ));
316      state->m_io[0x19] |= 8;                                          /* set service request */
317      hp48_pulse_irq( machine, SATURN_WAKEUP_LINE );
318      hp48_pulse_irq( machine, SATURN_NMI_LINE );
311            machine().time().as_double() ));
312      m_io[0x19] |= 8;                                          /* set service request */
313      hp48_pulse_irq( machine(), SATURN_WAKEUP_LINE );
314      hp48_pulse_irq( machine(), SATURN_NMI_LINE );
319315      return;
320316   }
321317
322318   /* regular keys */
323   hp48_update_kdn( machine );
319   hp48_update_kdn( machine() );
324320}
325321
326322/* RSI opcode */
r18113r18114
611607
612608/* ---------------- timers --------------- */
613609
614static TIMER_CALLBACK( hp48_timer1_cb )
610TIMER_CALLBACK_MEMBER(hp48_state::hp48_timer1_cb)
615611{
616   hp48_state *state = machine.driver_data<hp48_state>();
617   if ( !(state->m_io[0x2f] & 1) ) return; /* timer enable */
612   if ( !(m_io[0x2f] & 1) ) return; /* timer enable */
618613
619   state->m_timer1 = (state->m_timer1 - 1) & 0xf;
614   m_timer1 = (m_timer1 - 1) & 0xf;
620615
621616   /* wake-up on carry */
622   if ( (state->m_io[0x2e] & 4) && (state->m_timer1 == 0xf) )
617   if ( (m_io[0x2e] & 4) && (m_timer1 == 0xf) )
623618   {
624619      LOG(( "wake-up on timer1\n" ));
625      state->m_io[0x2e] |= 8;                                      /* set service request */
626      state->m_io[0x18] |= 4;                                      /* set service request */
627      hp48_pulse_irq( machine, SATURN_WAKEUP_LINE );
620      m_io[0x2e] |= 8;                                      /* set service request */
621      m_io[0x18] |= 4;                                      /* set service request */
622      hp48_pulse_irq( machine(), SATURN_WAKEUP_LINE );
628623   }
629624   /* interrupt on carry */
630   if ( (state->m_io[0x2e] & 2) && (state->m_timer1 == 0xf) )
625   if ( (m_io[0x2e] & 2) && (m_timer1 == 0xf) )
631626   {
632627      LOG(( "generate timer1 interrupt\n" ));
633      state->m_io[0x2e] |= 8; /* set service request */
634      state->m_io[0x18] |= 4; /* set service request */
635      hp48_pulse_irq( machine, SATURN_NMI_LINE );
628      m_io[0x2e] |= 8; /* set service request */
629      m_io[0x18] |= 4; /* set service request */
630      hp48_pulse_irq( machine(), SATURN_NMI_LINE );
636631   }
637632}
638633
639static TIMER_CALLBACK( hp48_timer2_cb )
634TIMER_CALLBACK_MEMBER(hp48_state::hp48_timer2_cb)
640635{
641   hp48_state *state = machine.driver_data<hp48_state>();
642   if ( !(state->m_io[0x2f] & 1) ) return; /* timer enable */
636   if ( !(m_io[0x2f] & 1) ) return; /* timer enable */
643637
644   state->m_timer2 = (state->m_timer2 - 1) & 0xffffffff;
638   m_timer2 = (m_timer2 - 1) & 0xffffffff;
645639
646640   /* wake-up on carry */
647   if ( (state->m_io[0x2f] & 4) && (state->m_timer2 == 0xffffffff) )
641   if ( (m_io[0x2f] & 4) && (m_timer2 == 0xffffffff) )
648642   {
649643      LOG(( "wake-up on timer2\n" ));
650      state->m_io[0x2f] |= 8;                                      /* set service request */
651      state->m_io[0x18] |= 4;                                      /* set service request */
652      hp48_pulse_irq( machine, SATURN_WAKEUP_LINE );
644      m_io[0x2f] |= 8;                                      /* set service request */
645      m_io[0x18] |= 4;                                      /* set service request */
646      hp48_pulse_irq( machine(), SATURN_WAKEUP_LINE );
653647   }
654648   /* interrupt on carry */
655   if ( (state->m_io[0x2f] & 2) && (state->m_timer2 == 0xffffffff) )
649   if ( (m_io[0x2f] & 2) && (m_timer2 == 0xffffffff) )
656650   {
657651      LOG(( "generate timer2 interrupt\n" ));
658      state->m_io[0x2f] |= 8;                                      /* set service request */
659      state->m_io[0x18] |= 4;                                      /* set service request */
660      hp48_pulse_irq( machine, SATURN_NMI_LINE );
652      m_io[0x2f] |= 8;                                      /* set service request */
653      m_io[0x18] |= 4;                                      /* set service request */
654      hp48_pulse_irq( machine(), SATURN_NMI_LINE );
661655   }
662656}
663657
r18113r18114
11711165   m_modules[5].data     = rom;
11721166
11731167   /* timers */
1174   machine().scheduler().timer_pulse(attotime::from_hz( 16 ), FUNC(hp48_timer1_cb));
1175   machine().scheduler().timer_pulse(attotime::from_hz( 8192 ), FUNC(hp48_timer2_cb));
1168   machine().scheduler().timer_pulse(attotime::from_hz( 16 ), timer_expired_delegate(FUNC(hp48_state::hp48_timer1_cb),this));
1169   machine().scheduler().timer_pulse(attotime::from_hz( 8192 ), timer_expired_delegate(FUNC(hp48_state::hp48_timer2_cb),this));
11761170
11771171   /* 1ms keyboard polling */
1178   machine().scheduler().timer_pulse(attotime::from_msec( 1 ), FUNC(hp48_kbd_cb));
1172   machine().scheduler().timer_pulse(attotime::from_msec( 1 ), timer_expired_delegate(FUNC(hp48_state::hp48_kbd_cb),this));
11791173
11801174   /* save state */
11811175   save_item(NAME(m_out) );
trunk/src/mess/machine/amstrad.c
r18113r18114
227227
228228/* Some games set the 8255 to mode 1 and expect a strobe signal */
229229/* on PC2. Apparently PC2 is always low on the CPC. ?!? */
230static TIMER_CALLBACK(amstrad_pc2_low)
230TIMER_CALLBACK_MEMBER(amstrad_state::amstrad_pc2_low)
231231{
232   amstrad_state *state = machine.driver_data<amstrad_state>();
233   state->m_ppi->pc2_w(0);
232   m_ppi->pc2_w(0);
234233}
235234
236235
r18113r18114
578577      amstrad_plus_dma_parse( machine, 2 );
579578}
580579
581static TIMER_CALLBACK(amstrad_video_update_timer)
580TIMER_CALLBACK_MEMBER(amstrad_state::amstrad_video_update_timer)
582581{
583582   if(param == 1)
584      amstrad_plus_update_video(machine);
583      amstrad_plus_update_video(machine());
585584   else
586      amstrad_update_video(machine);
585      amstrad_update_video(machine());
587586}
588587
589588/* Set the new colour from the GateArray */
r18113r18114
594593   {
595594      int val;
596595
597      machine.scheduler().timer_set( attotime::from_usec(0), FUNC(amstrad_video_update_timer),1);
596      machine.scheduler().timer_set( attotime::from_usec(0), timer_expired_delegate(FUNC(amstrad_state::amstrad_video_update_timer),state),1);
598597
599598      /* CPC+/GX4000 - normal palette changes through the Gate Array also makes the corresponding change in the ASIC palette */
600599      val = (amstrad_palette[hw_colour_index] & 0xf00000) >> 16; /* red */
r18113r18114
605604   }
606605   else
607606   {
608      machine.scheduler().timer_set( attotime::from_usec(0), FUNC(amstrad_video_update_timer),0);
607      machine.scheduler().timer_set( attotime::from_usec(0), timer_expired_delegate(FUNC(amstrad_state::amstrad_video_update_timer),state),0);
609608   }
610609   state->m_GateArray_render_colours[PenIndex] = hw_colour_index;
611610}
r18113r18114
614613static void aleste_vh_update_colour(running_machine &machine, int PenIndex, UINT16 hw_colour_index)
615614{
616615   amstrad_state *state = machine.driver_data<amstrad_state>();
617   machine.scheduler().timer_set( attotime::from_usec(0), FUNC(amstrad_video_update_timer),0);
616   machine.scheduler().timer_set( attotime::from_usec(0), timer_expired_delegate(FUNC(amstrad_state::amstrad_video_update_timer),state),0);
618617   state->m_GateArray_render_colours[PenIndex] = hw_colour_index+32;
619618}
620619
r18113r18114
969968   drvstate->m_gate_array.vsync = state ? 1 : 0;
970969
971970   /* Schedule a write to PC2 */
972   device->machine().scheduler().timer_set( attotime::zero, FUNC(amstrad_pc2_low));
971   device->machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(amstrad_state::amstrad_pc2_low),drvstate));
973972}
974973
975974
r18113r18114
992991   drvstate->m_gate_array.vsync = state ? 1 : 0;
993992
994993   /* Schedule a write to PC2 */
995   device->machine().scheduler().timer_set( attotime::zero, FUNC(amstrad_pc2_low));
994   device->machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(amstrad_state::amstrad_pc2_low),drvstate));
996995}
997996
998997
r18113r18114
20412040         break;
20422041      case 0x01:      /* Write to selected internal 6845 register Write Only */
20432042         if ( m_system_type == SYSTEM_PLUS || m_system_type == SYSTEM_GX4000 )
2044            machine().scheduler().timer_set( attotime::from_usec(0), FUNC(amstrad_video_update_timer),1);
2043            machine().scheduler().timer_set( attotime::from_usec(0), timer_expired_delegate(FUNC(amstrad_state::amstrad_video_update_timer),this),1);
20452044         else
2046            machine().scheduler().timer_set( attotime::from_usec(0), FUNC(amstrad_video_update_timer),0);
2045            machine().scheduler().timer_set( attotime::from_usec(0), timer_expired_delegate(FUNC(amstrad_state::amstrad_video_update_timer),this),0);
20472046         mc6845->register_w( space, 0, data );
20482047
20492048         /* printer port bit 8 */
r18113r18114
25822581
25832582logerror("amstrad_ppi_portb_r\n");
25842583   /* Schedule a write to PC2 */
2585   space.machine().scheduler().timer_set( attotime::zero, FUNC(amstrad_pc2_low));
2584   space.machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(amstrad_state::amstrad_pc2_low),state));
25862585
25872586   return data;
25882587}
r18113r18114
29122911   state->m_maincpu->set_irq_acknowledge_callback(amstrad_cpu_acknowledge_int);
29132912}
29142913
2915static TIMER_CALLBACK( cb_set_resolution )
2914TIMER_CALLBACK_MEMBER(amstrad_state::cb_set_resolution)
29162915{
2917   amstrad_state *state = machine.driver_data<amstrad_state>();
2918//  screen_device *screen = downcast<screen_device *>(state->m_screen);
2916//  screen_device *screen = downcast<screen_device *>(m_screen);
29192917   rectangle visarea;
29202918   attoseconds_t refresh;
29212919   int height;
29222920
2923   if ( machine.root_device().ioport( "solder_links" )->read() & 0x10 )
2921   if ( machine().root_device().ioport( "solder_links" )->read() & 0x10 )
29242922   {
29252923      /* PAL */
29262924      visarea.set(0, 64 + 640 + 64 - 1, 34, 34 + 15 + 242 + 15 - 1);
r18113r18114
29332931      height = 262;
29342932   }
29352933   refresh = HZ_TO_ATTOSECONDS( XTAL_16MHz ) * 1024 * height;
2936   state->m_screen->configure( 1024, height, visarea, refresh );
2934   m_screen->configure( 1024, height, visarea, refresh );
29372935}
29382936
29392937
r18113r18114
29632961   m_gate_array.hsync = 0;
29642962   m_gate_array.vsync = 0;
29652963
2966   machine().scheduler().timer_set( attotime::zero, FUNC(cb_set_resolution));
2964   machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(amstrad_state::cb_set_resolution),this));
29672965}
29682966
29692967
r18113r18114
30153013   space.install_write_handler(0x6000, 0x7fff, write8_delegate(FUNC(amstrad_state::amstrad_plus_asic_6000_w),this));
30163014
30173015   //  multiface_init();
3018   machine().scheduler().timer_set( attotime::zero, FUNC(cb_set_resolution));
3016   machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(amstrad_state::cb_set_resolution),this));
30193017}
30203018
30213019MACHINE_START_MEMBER(amstrad_state,gx4000)
r18113r18114
30643062   space.install_write_handler(0x4000, 0x5fff, write8_delegate(FUNC(amstrad_state::amstrad_plus_asic_4000_w),this));
30653063   space.install_write_handler(0x6000, 0x7fff, write8_delegate(FUNC(amstrad_state::amstrad_plus_asic_6000_w),this));
30663064
3067   machine().scheduler().timer_set( attotime::zero, FUNC(cb_set_resolution));
3065   machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(amstrad_state::cb_set_resolution),this));
30683066}
30693067
30703068MACHINE_START_MEMBER(amstrad_state,kccomp)
r18113r18114
31163114   amstrad_common_init(machine());
31173115   amstrad_reset_machine(machine());
31183116
3119   machine().scheduler().timer_set( attotime::zero, FUNC(cb_set_resolution));
3117   machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(amstrad_state::cb_set_resolution),this));
31203118}
31213119
31223120
trunk/src/mess/machine/wswan.c
r18113r18114
2424static const char *const wswan_sram_str[] = { "none", "64Kbit SRAM", "256Kbit SRAM", "512Kbit SRAM", "1Mbit SRAM", "2Mbit SRAM", "1Kbit EEPROM", "16Kbit EEPROM", "8Kbit EEPROM", "Unknown" };
2525static const int wswan_sram_size[] = { 0, 64*1024/8, 256*1024/8, 512*1024/8, 1024*1024/8, 2*1024*1024/8,  1024/8, 16*1024/8, 8*1024/8, 0 };
2626
27static TIMER_CALLBACK(wswan_scanline_interrupt);
2827
2928
29
3030static const UINT8 ws_portram_init[256] =
3131{
3232   0x00, 0x00, 0x00/*?*/, 0xbb, 0x00, 0x00, 0x00, 0x26, 0xfe, 0xde, 0xf9, 0xfb, 0xdb, 0xd7, 0x7f, 0xf5,
r18113r18114
123123   wswan_handle_irqs( machine() );
124124}
125125
126static TIMER_CALLBACK(wswan_rtc_callback)
126TIMER_CALLBACK_MEMBER(wswan_state::wswan_rtc_callback)
127127{
128   wswan_state *state = machine.driver_data<wswan_state>();
129128   /* A second passed */
130   state->m_rtc.second = state->m_rtc.second + 1;
131   if ( ( state->m_rtc.second & 0x0F ) > 9 )
129   m_rtc.second = m_rtc.second + 1;
130   if ( ( m_rtc.second & 0x0F ) > 9 )
132131   {
133      state->m_rtc.second = ( state->m_rtc.second & 0xF0 ) + 0x10;
132      m_rtc.second = ( m_rtc.second & 0xF0 ) + 0x10;
134133   }
135134
136135   /* Check for minute passed */
137   if ( state->m_rtc.second >= 0x60 )
136   if ( m_rtc.second >= 0x60 )
138137   {
139      state->m_rtc.second = 0;
140      state->m_rtc.minute = state->m_rtc.minute + 1;
141      if ( ( state->m_rtc.minute & 0x0F ) > 9 )
138      m_rtc.second = 0;
139      m_rtc.minute = m_rtc.minute + 1;
140      if ( ( m_rtc.minute & 0x0F ) > 9 )
142141      {
143         state->m_rtc.minute = ( state->m_rtc.minute & 0xF0 ) + 0x10;
142         m_rtc.minute = ( m_rtc.minute & 0xF0 ) + 0x10;
144143      }
145144   }
146145
147146   /* Check for hour passed */
148   if ( state->m_rtc.minute >= 0x60 )
147   if ( m_rtc.minute >= 0x60 )
149148   {
150      state->m_rtc.minute = 0;
151      state->m_rtc.hour = state->m_rtc.hour + 1;
152      if ( ( state->m_rtc.hour & 0x0F ) > 9 )
149      m_rtc.minute = 0;
150      m_rtc.hour = m_rtc.hour + 1;
151      if ( ( m_rtc.hour & 0x0F ) > 9 )
153152      {
154         state->m_rtc.hour = ( state->m_rtc.hour & 0xF0 ) + 0x10;
153         m_rtc.hour = ( m_rtc.hour & 0xF0 ) + 0x10;
155154      }
156      if ( state->m_rtc.hour == 0x12 )
155      if ( m_rtc.hour == 0x12 )
157156      {
158         state->m_rtc.hour |= 0x80;
157         m_rtc.hour |= 0x80;
159158      }
160159   }
161160
162161   /* Check for day passed */
163   if ( state->m_rtc.hour >= 0x24 )
162   if ( m_rtc.hour >= 0x24 )
164163   {
165      state->m_rtc.hour = 0;
166      state->m_rtc.day = state->m_rtc.day + 1;
164      m_rtc.hour = 0;
165      m_rtc.day = m_rtc.day + 1;
167166   }
168167}
169168
r18113r18114
192191   m_ws_bios_bank = NULL;
193192   m_system_type = TYPE_WSWAN;
194193   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(wswan_machine_stop),&machine()));
195   m_vdp.timer = machine().scheduler().timer_alloc(FUNC(wswan_scanline_interrupt), &m_vdp );
194   m_vdp.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(wswan_state::wswan_scanline_interrupt),this), &m_vdp );
196195   m_vdp.timer->adjust( attotime::from_ticks( 256, 3072000 ), 0, attotime::from_ticks( 256, 3072000 ) );
197196
198197   wswan_setup_bios(machine());
199198
200199   /* Set up RTC timer */
201200   if ( m_rtc.present )
202      machine().scheduler().timer_pulse(attotime::from_seconds(1), FUNC(wswan_rtc_callback));
201      machine().scheduler().timer_pulse(attotime::from_seconds(1), timer_expired_delegate(FUNC(wswan_state::wswan_rtc_callback),this));
203202
204203   machine().device<nvram_device>("nvram")->set_base(m_internal_eeprom, INTERNAL_EEPROM_SIZE);
205204}
r18113r18114
209208   m_ws_bios_bank = NULL;
210209   m_system_type = TYPE_WSC;
211210   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(wswan_machine_stop),&machine()));
212   m_vdp.timer = machine().scheduler().timer_alloc(FUNC(wswan_scanline_interrupt), &m_vdp );
211   m_vdp.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(wswan_state::wswan_scanline_interrupt),this), &m_vdp );
213212   m_vdp.timer->adjust( attotime::from_ticks( 256, 3072000 ), 0, attotime::from_ticks( 256, 3072000 ) );
214213
215214   wswan_setup_bios(machine());
216215
217216   /* Set up RTC timer */
218217   if ( m_rtc.present )
219      machine().scheduler().timer_pulse(attotime::from_seconds(1), FUNC(wswan_rtc_callback));
218      machine().scheduler().timer_pulse(attotime::from_seconds(1), timer_expired_delegate(FUNC(wswan_state::wswan_rtc_callback),this));
220219
221220   machine().device<nvram_device>("nvram")->set_base(m_internal_eeprom, INTERNAL_EEPROM_SIZE);
222221}
r18113r18114
14281427   return IMAGE_INIT_PASS;
14291428}
14301429
1431static TIMER_CALLBACK(wswan_scanline_interrupt)
1430TIMER_CALLBACK_MEMBER(wswan_state::wswan_scanline_interrupt)
14321431{
1433   wswan_state *state = machine.driver_data<wswan_state>();
1434   if( state->m_vdp.current_line < 144 )
1432   if( m_vdp.current_line < 144 )
14351433   {
1436      wswan_refresh_scanline(machine);
1434      wswan_refresh_scanline(machine());
14371435   }
14381436
14391437   /* Decrement 12kHz (HBlank) counter */
1440   if ( state->m_vdp.timer_hblank_enable && state->m_vdp.timer_hblank_reload != 0 )
1438   if ( m_vdp.timer_hblank_enable && m_vdp.timer_hblank_reload != 0 )
14411439   {
1442      state->m_vdp.timer_hblank_count--;
1443      logerror( "timer_hblank_count: %X\n", state->m_vdp.timer_hblank_count );
1444      if ( state->m_vdp.timer_hblank_count == 0 )
1440      m_vdp.timer_hblank_count--;
1441      logerror( "timer_hblank_count: %X\n", m_vdp.timer_hblank_count );
1442      if ( m_vdp.timer_hblank_count == 0 )
14451443      {
1446         if ( state->m_vdp.timer_hblank_mode )
1444         if ( m_vdp.timer_hblank_mode )
14471445         {
1448            state->m_vdp.timer_hblank_count = state->m_vdp.timer_hblank_reload;
1446            m_vdp.timer_hblank_count = m_vdp.timer_hblank_reload;
14491447         }
14501448         else
14511449         {
1452            state->m_vdp.timer_hblank_reload = 0;
1450            m_vdp.timer_hblank_reload = 0;
14531451         }
14541452         logerror( "trigerring hbltmr interrupt\n" );
1455         wswan_set_irq_line( machine, WSWAN_IFLAG_HBLTMR );
1453         wswan_set_irq_line( machine(), WSWAN_IFLAG_HBLTMR );
14561454      }
14571455   }
14581456
14591457   /* Handle Sound DMA */
1460   if ( ( state->m_sound_dma.enable & 0x88 ) == 0x80 )
1458   if ( ( m_sound_dma.enable & 0x88 ) == 0x80 )
14611459   {
1462      address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM );
1460      address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM );
14631461      /* TODO: Output sound DMA byte */
1464      state->wswan_port_w( space, 0x89, space.read_byte(state->m_sound_dma.source ) );
1465      state->m_sound_dma.size--;
1466      state->m_sound_dma.source = ( state->m_sound_dma.source + 1 ) & 0x0FFFFF;
1467      if ( state->m_sound_dma.size == 0 )
1462      wswan_port_w( space, 0x89, space.read_byte(m_sound_dma.source ) );
1463      m_sound_dma.size--;
1464      m_sound_dma.source = ( m_sound_dma.source + 1 ) & 0x0FFFFF;
1465      if ( m_sound_dma.size == 0 )
14681466      {
1469         state->m_sound_dma.enable &= 0x7F;
1467         m_sound_dma.enable &= 0x7F;
14701468      }
14711469   }
14721470
1473//  state->m_vdp.current_line = (state->m_vdp.current_line + 1) % 159;
1471//  m_vdp.current_line = (m_vdp.current_line + 1) % 159;
14741472
1475   if( state->m_vdp.current_line == 144 ) // buffer sprite table
1473   if( m_vdp.current_line == 144 ) // buffer sprite table
14761474   {
1477      memcpy(state->m_vdp.sprite_table_buffer, &state->m_vdp.vram[state->m_vdp.sprite_table_address], 512);
1478      state->m_vdp.sprite_count = state->m_ws_portram[0x06];
1479      state->m_vdp.sprite_first = state->m_ws_portram[0x05]; // always zero?
1475      memcpy(m_vdp.sprite_table_buffer, &m_vdp.vram[m_vdp.sprite_table_address], 512);
1476      m_vdp.sprite_count = m_ws_portram[0x06];
1477      m_vdp.sprite_first = m_ws_portram[0x05]; // always zero?
14801478   }
14811479
1482   if( state->m_vdp.current_line == 144 )
1480   if( m_vdp.current_line == 144 )
14831481   {
1484      wswan_set_irq_line( machine, WSWAN_IFLAG_VBL );
1482      wswan_set_irq_line( machine(), WSWAN_IFLAG_VBL );
14851483      /* Decrement 75Hz (VBlank) counter */
1486      if ( state->m_vdp.timer_vblank_enable && state->m_vdp.timer_vblank_reload != 0 )
1484      if ( m_vdp.timer_vblank_enable && m_vdp.timer_vblank_reload != 0 )
14871485      {
1488         state->m_vdp.timer_vblank_count--;
1489         logerror( "timer_vblank_count: %X\n", state->m_vdp.timer_vblank_count );
1490         if ( state->m_vdp.timer_vblank_count == 0 )
1486         m_vdp.timer_vblank_count--;
1487         logerror( "timer_vblank_count: %X\n", m_vdp.timer_vblank_count );
1488         if ( m_vdp.timer_vblank_count == 0 )
14911489         {
1492            if ( state->m_vdp.timer_vblank_mode )
1490            if ( m_vdp.timer_vblank_mode )
14931491            {
1494               state->m_vdp.timer_vblank_count = state->m_vdp.timer_vblank_reload;
1492               m_vdp.timer_vblank_count = m_vdp.timer_vblank_reload;
14951493            }
14961494            else
14971495            {
1498               state->m_vdp.timer_vblank_reload = 0;
1496               m_vdp.timer_vblank_reload = 0;
14991497            }
15001498            logerror( "triggering vbltmr interrupt\n" );
1501            wswan_set_irq_line( machine, WSWAN_IFLAG_VBLTMR );
1499            wswan_set_irq_line( machine(), WSWAN_IFLAG_VBLTMR );
15021500         }
15031501      }
15041502   }
15051503
1506//  state->m_vdp.current_line = (state->m_vdp.current_line + 1) % 159;
1504//  m_vdp.current_line = (m_vdp.current_line + 1) % 159;
15071505
1508   if ( state->m_vdp.current_line == state->m_vdp.line_compare )
1506   if ( m_vdp.current_line == m_vdp.line_compare )
15091507   {
1510      wswan_set_irq_line( machine, WSWAN_IFLAG_LCMP );
1508      wswan_set_irq_line( machine(), WSWAN_IFLAG_LCMP );
15111509   }
15121510
1513   state->m_vdp.current_line = (state->m_vdp.current_line + 1) % 159;
1511   m_vdp.current_line = (m_vdp.current_line + 1) % 159;
15141512}
15151513
trunk/src/mess/machine/z80ne.c
r18113r18114
3939      return machine.device<cassette_image_device>(CASSETTE_TAG);
4040}
4141
42static TIMER_CALLBACK(z80ne_cassette_tc)
42TIMER_CALLBACK_MEMBER(z80ne_state::z80ne_cassette_tc)
4343{
44   z80ne_state *state = machine.driver_data<z80ne_state>();
4544   UINT8 cass_ws = 0;
46   state->m_cass_data.input.length++;
45   m_cass_data.input.length++;
4746
48   cass_ws = ((cassette_device_image(machine))->input() > +0.02) ? 1 : 0;
47   cass_ws = ((cassette_device_image(machine()))->input() > +0.02) ? 1 : 0;
4948
50   if ((cass_ws ^ state->m_cass_data.input.level) & cass_ws)
49   if ((cass_ws ^ m_cass_data.input.level) & cass_ws)
5150   {
52      state->m_cass_data.input.level = cass_ws;
53      state->m_cass_data.input.bit = ((state->m_cass_data.input.length < state->m_cass_data.wave_filter) || (state->m_cass_data.input.length > 0x20)) ? 1 : 0;
54      state->m_cass_data.input.length = 0;
55      ay31015_set_input_pin( state->m_ay31015, AY31015_SI, state->m_cass_data.input.bit );
51      m_cass_data.input.level = cass_ws;
52      m_cass_data.input.bit = ((m_cass_data.input.length < m_cass_data.wave_filter) || (m_cass_data.input.length > 0x20)) ? 1 : 0;
53      m_cass_data.input.length = 0;
54      ay31015_set_input_pin( m_ay31015, AY31015_SI, m_cass_data.input.bit );
5655   }
57   state->m_cass_data.input.level = cass_ws;
56   m_cass_data.input.level = cass_ws;
5857
5958   /* saving a tape - convert the serial stream from the uart */
6059
61   state->m_cass_data.output.length--;
60   m_cass_data.output.length--;
6261
63   if (!(state->m_cass_data.output.length))
62   if (!(m_cass_data.output.length))
6463   {
65      if (state->m_cass_data.output.level)
66         state->m_cass_data.output.level = 0;
64      if (m_cass_data.output.level)
65         m_cass_data.output.level = 0;
6766      else
6867      {
69         state->m_cass_data.output.level=1;
70         cass_ws = ay31015_get_output_pin( state->m_ay31015, AY31015_SO );
71         state->m_cass_data.wave_length = cass_ws ? state->m_cass_data.wave_short : state->m_cass_data.wave_long;
68         m_cass_data.output.level=1;
69         cass_ws = ay31015_get_output_pin( m_ay31015, AY31015_SO );
70         m_cass_data.wave_length = cass_ws ? m_cass_data.wave_short : m_cass_data.wave_long;
7271      }
73      cassette_device_image(machine)->output(state->m_cass_data.output.level ? -1.0 : +1.0);
74      state->m_cass_data.output.length = state->m_cass_data.wave_length;
72      cassette_device_image(machine())->output(m_cass_data.output.level ? -1.0 : +1.0);
73      m_cass_data.output.length = m_cass_data.wave_length;
7574   }
7675}
7776
r18113r18114
114113
115114}
116115
117static TIMER_CALLBACK( z80ne_kbd_scan )
116TIMER_CALLBACK_MEMBER(z80ne_state::z80ne_kbd_scan)
118117{
119   z80ne_state *state = machine.driver_data<z80ne_state>();
120118   /*
121119     * NE555 is connected to a 74LS93 binary counter
122120     * 74LS93 output:
r18113r18114
141139   UINT8 i;
142140
143141   /* 4-bit counter */
144   --state->m_lx383_scan_counter;
145   state->m_lx383_scan_counter &= 0x0f;
142   --m_lx383_scan_counter;
143   m_lx383_scan_counter &= 0x0f;
146144
147   if ( --state->m_lx383_downsampler == 0 )
145   if ( --m_lx383_downsampler == 0 )
148146   {
149      state->m_lx383_downsampler = LX383_DOWNSAMPLING;
150      key_bits = (machine.root_device().ioport("ROW1")->read() << 8) | machine.root_device().ioport("ROW0")->read();
151//      rst = machine.root_device().ioport("RST")->read();
152      ctrl = machine.root_device().ioport("CTRL")->read();
147      m_lx383_downsampler = LX383_DOWNSAMPLING;
148      key_bits = (machine().root_device().ioport("ROW1")->read() << 8) | machine().root_device().ioport("ROW0")->read();
149//      rst = machine().root_device().ioport("RST")->read();
150      ctrl = machine().root_device().ioport("CTRL")->read();
153151
154152      for ( i = 0; i<LX383_KEYS; i++)
155153      {
156         state->m_lx383_key[i] = ( i | (key_bits & 0x01 ? 0x80 : 0x00) | ~ctrl);
154         m_lx383_key[i] = ( i | (key_bits & 0x01 ? 0x80 : 0x00) | ~ctrl);
157155         key_bits >>= 1;
158156      }
159157   }
r18113r18114
399397   state_save_register_item( machine(), "z80ne", NULL, 0, m_lx383_downsampler );
400398   state_save_register_item_array( machine(), "z80ne", NULL, 0, m_lx383_key );
401399   state_save_register_item( machine(), "z80ne", NULL, 0, m_nmi_delay_counter );
402   m_cassette_timer = machine().scheduler().timer_alloc(FUNC(z80ne_cassette_tc));
403   machine().scheduler().timer_pulse( attotime::from_hz(1000), FUNC(z80ne_kbd_scan));
400   m_cassette_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(z80ne_state::z80ne_cassette_tc),this));
401   machine().scheduler().timer_pulse( attotime::from_hz(1000), timer_expired_delegate(FUNC(z80ne_state::z80ne_kbd_scan),this));
404402}
405403
406404MACHINE_START_MEMBER(z80ne_state,z80net)
trunk/src/mess/machine/pc1251.c
r18113r18114
100100   machine.device<nvram_device>("ram_nvram")->set_base(ram, 0x4800);
101101}
102102
103static TIMER_CALLBACK(pc1251_power_up)
103TIMER_CALLBACK_MEMBER(pc1251_state::pc1251_power_up)
104104{
105   pc1251_state *state = machine.driver_data<pc1251_state>();
106   state->m_power = 0;
105   m_power = 0;
107106}
108107
109108DRIVER_INIT_MEMBER(pc1251_state,pc1251)
r18113r18114
113112   for (i=0; i<128; i++) gfx[i]=i;
114113
115114   m_power = 1;
116   machine().scheduler().timer_set(attotime::from_seconds(1), FUNC(pc1251_power_up));
115   machine().scheduler().timer_set(attotime::from_seconds(1), timer_expired_delegate(FUNC(pc1251_state::pc1251_power_up),this));
117116}
118117
trunk/src/mess/machine/pc1350.c
r18113r18114
9090   return (device->machine().root_device().ioport("EXTRA")->read() & 0x01);
9191}
9292
93static TIMER_CALLBACK(pc1350_power_up)
93TIMER_CALLBACK_MEMBER(pc1350_state::pc1350_power_up)
9494{
95   pc1350_state *state = machine.driver_data<pc1350_state>();
96   state->m_power=0;
95   m_power=0;
9796}
9897
9998MACHINE_START( pc1350 )
r18113r18114
102101   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
103102
104103   state->m_power = 1;
105   machine.scheduler().timer_set(attotime::from_seconds(1), FUNC(pc1350_power_up));
104   machine.scheduler().timer_set(attotime::from_seconds(1), timer_expired_delegate(FUNC(pc1350_state::pc1350_power_up),state));
106105
107106   space.install_readwrite_bank(0x6000, 0x6fff, "bank1");
108107   state->membank("bank1")->set_base(&machine.device<ram_device>(RAM_TAG)->pointer()[0x0000]);
trunk/src/mess/machine/oric.c
r18113r18114
254254
255255/* not called yet - this will update the via with the state of the tape data.
256256This allows the via to trigger on bit changes and issue interrupts */
257static TIMER_CALLBACK(oric_refresh_tape)
257TIMER_CALLBACK_MEMBER(oric_state::oric_refresh_tape)
258258{
259259   int data;
260260   int input_port_9;
261   via6522_device *via_0 = machine.device<via6522_device>("via6522_0");
261   via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
262262
263263   data = 0;
264264
265   if ((cassette_device_image(machine))->input() > 0.0038)
265   if ((cassette_device_image(machine()))->input() > 0.0038)
266266      data |= 1;
267267
268268   /* "A simple cable to catch the vertical retrace signal !
r18113r18114
270270    to the via cb1 input. Interrupts can be generated from the vertical
271271    sync, and flicker free games can be produced */
272272
273   input_port_9 = machine.root_device().ioport("FLOPPY")->read();
273   input_port_9 = machine().root_device().ioport("FLOPPY")->read();
274274   /* cable is enabled? */
275275   if ((input_port_9 & 0x08)!=0)
276276   {
r18113r18114
10481048   state->m_port_314_r = 0;
10491049   state->m_port_318_r = 0;
10501050   state->m_port_314_w = 0;
1051   machine.scheduler().timer_pulse(attotime::from_hz(4800), FUNC(oric_refresh_tape));
1051   machine.scheduler().timer_pulse(attotime::from_hz(4800), timer_expired_delegate(FUNC(oric_state::oric_refresh_tape),state));
10521052}
10531053
10541054void oric_state::machine_start()
trunk/src/mess/machine/ondra.c
r18113r18114
7575{
7676}
7777
78static TIMER_CALLBACK(nmi_check_callback)
78TIMER_CALLBACK_MEMBER(ondra_state::nmi_check_callback)
7979{
80   if ((machine.root_device().ioport("NMI")->read() & 1) == 1)
80   if ((machine().root_device().ioport("NMI")->read() & 1) == 1)
8181   {
82      machine.device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
82      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
8383   }
8484}
8585
r18113r18114
9292
9393void ondra_state::machine_start()
9494{
95   machine().scheduler().timer_pulse(attotime::from_hz(10), FUNC(nmi_check_callback));
95   machine().scheduler().timer_pulse(attotime::from_hz(10), timer_expired_delegate(FUNC(ondra_state::nmi_check_callback),this));
9696}
trunk/src/mess/machine/bebox.c
r18113r18114
968968}
969969
970970
971static TIMER_CALLBACK( bebox_get_devices ) {
972   bebox_state *state = machine.driver_data<bebox_state>();
973   state->m_devices.pic8259_master = machine.device("pic8259_master");
974   state->m_devices.pic8259_slave = machine.device("pic8259_slave");
975   state->m_devices.dma8237_1 = machine.device("dma8237_1");
976   state->m_devices.dma8237_2 = machine.device("dma8237_2");
971TIMER_CALLBACK_MEMBER(bebox_state::bebox_get_devices){
972   m_devices.pic8259_master = machine().device("pic8259_master");
973   m_devices.pic8259_slave = machine().device("pic8259_slave");
974   m_devices.dma8237_1 = machine().device("dma8237_1");
975   m_devices.dma8237_2 = machine().device("dma8237_2");
977976}
978977
979978
r18113r18114
990989   m_devices.dma8237_1 = NULL;
991990   m_devices.dma8237_2 = NULL;
992991
993   machine().scheduler().timer_set(attotime::zero, FUNC(bebox_get_devices));
992   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(bebox_state::bebox_get_devices),this));
994993
995994   machine().device("ppc1")->execute().set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
996995   machine().device("ppc2")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
trunk/src/mess/machine/super80.c
r18113r18114
7878    bit 1 = MDS fast system
7979    bit 2 = CA3140 */
8080
81static TIMER_CALLBACK( super80_timer )
81TIMER_CALLBACK_MEMBER(super80_state::super80_timer)
8282{
83   super80_state *state = machine.driver_data<super80_state>();
8483   UINT8 cass_ws=0;
8584
86   state->m_cass_data[1]++;
87   cass_ws = ((state->m_cass)->input() > +0.03) ? 4 : 0;
85   m_cass_data[1]++;
86   cass_ws = ((m_cass)->input() > +0.03) ? 4 : 0;
8887
89   if (cass_ws != state->m_cass_data[0])
88   if (cass_ws != m_cass_data[0])
9089   {
91      if (cass_ws) state->m_cass_data[3] ^= 2;      // the MDS flipflop
92      state->m_cass_data[0] = cass_ws;
93      state->m_cass_data[2] = ((state->m_cass_data[1] < 0x40) ? 1 : 0) | cass_ws | state->m_cass_data[3];
94      state->m_cass_data[1] = 0;
90      if (cass_ws) m_cass_data[3] ^= 2;      // the MDS flipflop
91      m_cass_data[0] = cass_ws;
92      m_cass_data[2] = ((m_cass_data[1] < 0x40) ? 1 : 0) | cass_ws | m_cass_data[3];
93      m_cass_data[1] = 0;
9594   }
9695
97   state->m_pio->port_b_write(pio_port_b_r(state->m_pio,state->generic_space(),0,0xff));
96   m_pio->port_b_write(pio_port_b_r(m_pio,generic_space(),0,0xff));
9897}
9998
10099/* after the first 4 bytes have been read from ROM, switch the ram back in */
101static TIMER_CALLBACK( super80_reset )
100TIMER_CALLBACK_MEMBER(super80_state::super80_reset)
102101{
103   super80_state *state = machine.driver_data<super80_state>();
104   state->membank("boot")->set_entry(0);
102   membank("boot")->set_entry(0);
105103}
106104
107static TIMER_CALLBACK( super80_halfspeed )
105TIMER_CALLBACK_MEMBER(super80_state::super80_halfspeed)
108106{
109107   UINT8 go_fast = 0;
110   super80_state *state = machine.driver_data<super80_state>();
111   if ( (!BIT(state->m_shared, 2)) | (!BIT(machine.root_device().ioport("CONFIG")->read(), 1)) )   /* bit 2 of port F0 is low, OR user turned on config switch */
108   if ( (!BIT(m_shared, 2)) | (!BIT(machine().root_device().ioport("CONFIG")->read(), 1)) )   /* bit 2 of port F0 is low, OR user turned on config switch */
112109      go_fast++;
113110
114111   /* code to slow down computer to 1 MHz by halting cpu on every second frame */
115112   if (!go_fast)
116113   {
117      if (!state->m_int_sw)
118         machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);   // if going, stop it
114      if (!m_int_sw)
115         machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);   // if going, stop it
119116
120      state->m_int_sw++;
121      if (state->m_int_sw > 1)
117      m_int_sw++;
118      if (m_int_sw > 1)
122119      {
123         machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);      // if stopped, start it
124         state->m_int_sw = 0;
120         machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);      // if stopped, start it
121         m_int_sw = 0;
125122      }
126123   }
127124   else
128125   {
129      if (state->m_int_sw < 8)                        // @2MHz, reset just once
126      if (m_int_sw < 8)                        // @2MHz, reset just once
130127      {
131         machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
132         state->m_int_sw = 8;                     // ...not every time
128         machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
129         m_int_sw = 8;                     // ...not every time
133130      }
134131   }
135132}
r18113r18114
202199void super80_state::machine_reset()
203200{
204201   m_shared=0xff;
205   machine().scheduler().timer_set(attotime::from_usec(10), FUNC(super80_reset));
202   machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(super80_state::super80_reset),this));
206203   membank("boot")->set_entry(1);
207204}
208205
r18113r18114
211208   super80_state *state = machine.driver_data<super80_state>();
212209   UINT8 *RAM = state->memregion("maincpu")->base();
213210   state->membank("boot")->configure_entries(0, 2, &RAM[0x0000], 0xc000);
214   machine.scheduler().timer_pulse(attotime::from_hz(200000), FUNC(super80_timer));   /* timer for keyboard and cassette */
211   machine.scheduler().timer_pulse(attotime::from_hz(200000), timer_expired_delegate(FUNC(super80_state::super80_timer),state));   /* timer for keyboard and cassette */
215212}
216213
217214DRIVER_INIT_MEMBER(super80_state,super80)
218215{
219   machine().scheduler().timer_pulse(attotime::from_hz(100), FUNC(super80_halfspeed));   /* timer for 1MHz slowdown */
216   machine().scheduler().timer_pulse(attotime::from_hz(100), timer_expired_delegate(FUNC(super80_state::super80_halfspeed),this));   /* timer for 1MHz slowdown */
220217   driver_init_common(machine());
221218}
222219
trunk/src/mess/machine/irisha.c
r18113r18114
1818
1919
2020
21static TIMER_CALLBACK( irisha_key )
21TIMER_CALLBACK_MEMBER(irisha_state::irisha_key)
2222{
23   irisha_state *state = machine.driver_data<irisha_state>();
24   state->m_keypressed = 1;
25   state->m_keyboard_cnt = 0;
23   m_keypressed = 1;
24   m_keyboard_cnt = 0;
2625}
2726
2827void irisha_state::machine_start()
2928{
30   machine().scheduler().timer_pulse(attotime::from_msec(30), FUNC(irisha_key));
29   machine().scheduler().timer_pulse(attotime::from_msec(30), timer_expired_delegate(FUNC(irisha_state::irisha_key),this));
3130}
3231
3332void irisha_state::machine_reset()
trunk/src/mess/machine/ti85.c
r18113r18114
1515#define TI86_SNAPSHOT_SIZE   131284
1616
1717
18static TIMER_CALLBACK(ti85_timer_callback)
18TIMER_CALLBACK_MEMBER(ti85_state::ti85_timer_callback)
1919{
20   ti85_state *state = machine.driver_data<ti85_state>();
21   if (machine.root_device().ioport("ON")->read() & 0x01)
20   if (machine().root_device().ioport("ON")->read() & 0x01)
2221   {
23      if (state->m_ON_interrupt_mask && !state->m_ON_pressed)
22      if (m_ON_interrupt_mask && !m_ON_pressed)
2423      {
25         state->m_maincpu->set_input_line(0, HOLD_LINE);
26         state->m_ON_interrupt_status = 1;
27         if (!state->m_timer_interrupt_mask) state->m_timer_interrupt_mask = 1;
24         m_maincpu->set_input_line(0, HOLD_LINE);
25         m_ON_interrupt_status = 1;
26         if (!m_timer_interrupt_mask) m_timer_interrupt_mask = 1;
2827      }
29      state->m_ON_pressed = 1;
28      m_ON_pressed = 1;
3029      return;
3130   }
3231   else
33      state->m_ON_pressed = 0;
34   if (state->m_timer_interrupt_mask)
32      m_ON_pressed = 0;
33   if (m_timer_interrupt_mask)
3534   {
36      state->m_maincpu->set_input_line(0, HOLD_LINE);
37      state->m_timer_interrupt_status = 1;
35      m_maincpu->set_input_line(0, HOLD_LINE);
36      m_timer_interrupt_status = 1;
3837   }
3938}
4039
r18113r18114
131130   m_port4_bit0 = 0;
132131   m_ti81_port_7_data = 0;
133132
134   machine().scheduler().timer_pulse(attotime::from_hz(200), FUNC(ti85_timer_callback));
133   machine().scheduler().timer_pulse(attotime::from_hz(200), timer_expired_delegate(FUNC(ti85_state::ti85_timer_callback),this));
135134
136135   space.unmap_write(0x0000, 0x3fff);
137136   space.unmap_write(0x4000, 0x7fff);
r18113r18114
180179   membank("bank3")->set_base(m_bios);
181180   membank("bank4")->set_base(m_ti8x_ram);
182181
183   machine().scheduler().timer_pulse(attotime::from_hz(200), FUNC(ti85_timer_callback));
182   machine().scheduler().timer_pulse(attotime::from_hz(200), timer_expired_delegate(FUNC(ti85_state::ti85_timer_callback),this));
184183
185184}
186185
r18113r18114
216215
217216   membank("bank4")->set_base(m_ti8x_ram);
218217
219   machine().scheduler().timer_pulse(attotime::from_hz(200), FUNC(ti85_timer_callback));
218   machine().scheduler().timer_pulse(attotime::from_hz(200), timer_expired_delegate(FUNC(ti85_state::ti85_timer_callback),this));
220219}
221220
222221
trunk/src/mess/machine/dai.c
r18113r18114
3434   state->membank("bank2")->set_entry(dai_rom_bank);
3535}
3636
37static TIMER_CALLBACK(dai_bootstrap_callback)
37TIMER_CALLBACK_MEMBER(dai_state::dai_bootstrap_callback)
3838{
39   machine.device("maincpu")->state().set_pc(0xc000);
39   machine().device("maincpu")->state().set_pc(0xc000);
4040}
4141
4242
r18113r18114
105105   }
106106};
107107
108static TIMER_CALLBACK( dai_timer )
108TIMER_CALLBACK_MEMBER(dai_state::dai_timer)
109109{
110   dai_state *state = machine.driver_data<dai_state>();
111   state->m_tms5501->set_pio_bit_7((state->ioport("IN8")->read() & 0x04) ? 1:0);
110   m_tms5501->set_pio_bit_7((ioport("IN8")->read() & 0x04) ? 1:0);
112111}
113112
114113void dai_state::machine_start()
115114{
116115
117116   membank("bank2")->configure_entries(0, 4, memregion("maincpu")->base() + 0x010000, 0x1000);
118   machine().scheduler().timer_set(attotime::zero, FUNC(dai_bootstrap_callback));
119   machine().scheduler().timer_pulse(attotime::from_hz(100), FUNC(dai_timer));   /* timer for tms5501 */
117   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(dai_state::dai_bootstrap_callback),this));
118   machine().scheduler().timer_pulse(attotime::from_hz(100), timer_expired_delegate(FUNC(dai_state::dai_timer),this));   /* timer for tms5501 */
120119
121120   memset(machine().device<ram_device>(RAM_TAG)->pointer(), 0, machine().device<ram_device>(RAM_TAG)->size());
122121}
trunk/src/mess/machine/pecom.c
r18113r18114
1212#include "machine/ram.h"
1313#include "includes/pecom.h"
1414
15static TIMER_CALLBACK( reset_tick )
15TIMER_CALLBACK_MEMBER(pecom_state::reset_tick)
1616{
17   pecom_state *state = machine.driver_data<pecom_state>();
1817
19   state->m_reset = 1;
18   m_reset = 1;
2019}
2120
2221void pecom_state::machine_start()
2322{
24   m_reset_timer = machine().scheduler().timer_alloc(FUNC(reset_tick));
23   m_reset_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pecom_state::reset_tick),this));
2524}
2625
2726void pecom_state::machine_reset()
trunk/src/mess/machine/poly88.c
r18113r18114
1212#include "includes/poly88.h"
1313
1414
15static TIMER_CALLBACK(poly88_usart_timer_callback)
15TIMER_CALLBACK_MEMBER(poly88_state::poly88_usart_timer_callback)
1616{
17   poly88_state *state = machine.driver_data<poly88_state>();
18   state->m_int_vector = 0xe7;
19   machine.device("maincpu")->execute().set_input_line(0, HOLD_LINE);
17   m_int_vector = 0xe7;
18   machine().device("maincpu")->execute().set_input_line(0, HOLD_LINE);
2019}
2120
2221WRITE8_MEMBER(poly88_state::poly88_baud_rate_w)
2322{
2423   logerror("poly88_baud_rate_w %02x\n",data);
25   m_usart_timer = machine().scheduler().timer_alloc(FUNC(poly88_usart_timer_callback));
24   m_usart_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(poly88_state::poly88_usart_timer_callback),this));
2625   m_usart_timer->adjust(attotime::zero, 0, attotime::from_hz(300));
2726
2827}
r18113r18114
3938   return 0;
4039}
4140
42static TIMER_CALLBACK(keyboard_callback)
41TIMER_CALLBACK_MEMBER(poly88_state::keyboard_callback)
4342{
44   poly88_state *state = machine.driver_data<poly88_state>();
4543   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6" };
4644
4745   int i;
4846   UINT8 code;
4947   UINT8 key_code = 0;
50   UINT8 shift = machine.root_device().ioport("LINEC")->read() & 0x02 ? 1 : 0;
51   UINT8 ctrl =  machine.root_device().ioport("LINEC")->read() & 0x01 ? 1 : 0;
48   UINT8 shift = machine().root_device().ioport("LINEC")->read() & 0x02 ? 1 : 0;
49   UINT8 ctrl =  machine().root_device().ioport("LINEC")->read() & 0x01 ? 1 : 0;
5250
5351   for(i = 0; i < 7; i++)
5452   {
5553
56      code =   machine.root_device().ioport(keynames[i])->read();
54      code =   machine().root_device().ioport(keynames[i])->read();
5755      if (code != 0)
5856      {
5957         if (i==0 && shift==0) {
r18113r18114
117115         }
118116      }
119117   }
120   if (key_code==0 && state->m_last_code !=0){
121      state->m_int_vector = 0xef;
122      machine.device("maincpu")->execute().set_input_line(0, HOLD_LINE);
118   if (key_code==0 && m_last_code !=0){
119      m_int_vector = 0xef;
120      machine().device("maincpu")->execute().set_input_line(0, HOLD_LINE);
123121   } else {
124      state->m_last_code = key_code;
122      m_last_code = key_code;
125123   }
126124}
127125
r18113r18114
131129   return state->m_int_vector;
132130}
133131
134static TIMER_CALLBACK(poly88_cassette_timer_callback)
132TIMER_CALLBACK_MEMBER(poly88_state::poly88_cassette_timer_callback)
135133{
136   poly88_state *state = machine.driver_data<poly88_state>();
137134   int data;
138135   int current_level;
139   i8251_device *uart = machine.device<i8251_device>("uart");
140   serial_source_device *ser = machine.device<serial_source_device>("sercas");
136   i8251_device *uart = machine().device<i8251_device>("uart");
137   serial_source_device *ser = machine().device<serial_source_device>("sercas");
141138
142//  if (!(machine.root_device().ioport("DSW0")->read() & 0x02)) /* V.24 / Tape Switch */
139//  if (!(machine().root_device().ioport("DSW0")->read() & 0x02)) /* V.24 / Tape Switch */
143140   //{
144141      /* tape reading */
145      if (machine.device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_PLAY)
142      if (machine().device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_PLAY)
146143      {
147               if (state->m_clk_level_tape)
144               if (m_clk_level_tape)
148145               {
149                  state->m_previous_level = ((machine.device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0;
150                  state->m_clk_level_tape = 0;
146                  m_previous_level = ((machine().device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0;
147                  m_clk_level_tape = 0;
151148               }
152149               else
153150               {
154                  current_level = ((machine.device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0;
151                  current_level = ((machine().device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0;
155152
156                  if (state->m_previous_level!=current_level)
153                  if (m_previous_level!=current_level)
157154                  {
158                     data = (!state->m_previous_level && current_level) ? 1 : 0;
155                     data = (!m_previous_level && current_level) ? 1 : 0;
159156//data = current_level;
160157                     ser->send_bit(data);
161158                     uart->receive_clock();
162159
163                     state->m_clk_level_tape = 1;
160                     m_clk_level_tape = 1;
164161                  }
165162               }
166163      }
167164
168165      /* tape writing */
169      if (machine.device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_RECORD)
166      if (machine().device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_RECORD)
170167      {
171168         data = ser->get_in_data_bit();
172         data ^= state->m_clk_level_tape;
173         machine.device<cassette_image_device>(CASSETTE_TAG)->output(data&0x01 ? 1 : -1);
169         data ^= m_clk_level_tape;
170         machine().device<cassette_image_device>(CASSETTE_TAG)->output(data&0x01 ? 1 : -1);
174171
175         if (!state->m_clk_level_tape)
172         if (!m_clk_level_tape)
176173            uart->transmit_clock();
177174
178         state->m_clk_level_tape = state->m_clk_level_tape ? 0 : 1;
175         m_clk_level_tape = m_clk_level_tape ? 0 : 1;
179176
180177         return;
181178      }
182179
183      state->m_clk_level_tape = 1;
180      m_clk_level_tape = 1;
184181
185      if (!state->m_clk_level)
182      if (!m_clk_level)
186183         uart->transmit_clock();
187      state->m_clk_level = state->m_clk_level ? 0 : 1;
184      m_clk_level = m_clk_level ? 0 : 1;
188185//  }
189186}
190187
191188
192static TIMER_CALLBACK( setup_machine_state )
189TIMER_CALLBACK_MEMBER(poly88_state::setup_machine_state)
193190{
194//  poly88_state *state = machine.driver_data<poly88_state>();
195   i8251_device *uart = machine.device<i8251_device>("uart");
196   serial_source_device *ser = machine.device<serial_source_device>("sercas");
191   i8251_device *uart = machine().device<i8251_device>("uart");
192   serial_source_device *ser = machine().device<serial_source_device>("sercas");
197193   uart->connect(ser);
198194}
199195
r18113r18114
201197{
202198   m_previous_level = 0;
203199   m_clk_level = m_clk_level_tape = 1;
204   m_cassette_timer = machine().scheduler().timer_alloc(FUNC(poly88_cassette_timer_callback));
200   m_cassette_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(poly88_state::poly88_cassette_timer_callback),this));
205201   m_cassette_timer->adjust(attotime::zero, 0, attotime::from_hz(600));
206202
207   machine().scheduler().timer_pulse(attotime::from_hz(24000), FUNC(keyboard_callback));
203   machine().scheduler().timer_pulse(attotime::from_hz(24000), timer_expired_delegate(FUNC(poly88_state::keyboard_callback),this));
208204}
209205
210206void poly88_state::machine_reset()
r18113r18114
213209   m_intr = 0;
214210   m_last_code = 0;
215211
216   machine().scheduler().timer_set(attotime::zero, FUNC(setup_machine_state));
212   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(poly88_state::setup_machine_state),this));
217213}
218214
219215INTERRUPT_GEN_MEMBER(poly88_state::poly88_interrupt)
trunk/src/mess/machine/vector06.c
r18113r18114
136136   return 0xff;
137137}
138138
139static TIMER_CALLBACK( reset_check_callback )
139TIMER_CALLBACK_MEMBER(vector06_state::reset_check_callback)
140140{
141   vector06_state *state = machine.driver_data<vector06_state>();
142   UINT8 val = machine.root_device().ioport("RESET")->read();
141   UINT8 val = machine().root_device().ioport("RESET")->read();
143142
144143   if (BIT(val, 0))
145144   {
146      state->membank("bank1")->set_base(machine.root_device().memregion("maincpu")->base() + 0x10000);
147      machine.device("maincpu")->reset();
145      membank("bank1")->set_base(machine().root_device().memregion("maincpu")->base() + 0x10000);
146      machine().device("maincpu")->reset();
148147   }
149148
150149   if (BIT(val, 1))
151150   {
152      state->membank("bank1")->set_base(machine.device<ram_device>(RAM_TAG)->pointer() + 0x0000);
153      machine.device("maincpu")->reset();
151      membank("bank1")->set_base(machine().device<ram_device>(RAM_TAG)->pointer() + 0x0000);
152      machine().device("maincpu")->reset();
154153   }
155154}
156155
r18113r18114
164163
165164void vector06_state::machine_start()
166165{
167   machine().scheduler().timer_pulse(attotime::from_hz(50), FUNC(reset_check_callback));
166   machine().scheduler().timer_pulse(attotime::from_hz(50), timer_expired_delegate(FUNC(vector06_state::reset_check_callback),this));
168167}
169168
170169void vector06_state::machine_reset()
trunk/src/mess/machine/special.c
r18113r18114
101101   DEVCB_DRIVER_MEMBER(special_state, specialist_8255_portc_w)
102102};
103103
104static TIMER_CALLBACK( special_reset )
104TIMER_CALLBACK_MEMBER(special_state::special_reset)
105105{
106   special_state *state = machine.driver_data<special_state>();
107   state->membank("bank1")->set_entry(0);
106   membank("bank1")->set_entry(0);
108107}
109108
110109
111110MACHINE_RESET_MEMBER(special_state,special)
112111{
113   machine().scheduler().timer_set(attotime::from_usec(10), FUNC(special_reset));
112   machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(special_state::special_reset),this));
114113   membank("bank1")->set_entry(1);
115114}
116115
r18113r18114
224223   m_specimx_audio = machine().device("custom");
225224}
226225
227static TIMER_CALLBACK( setup_pit8253_gates )
226TIMER_CALLBACK_MEMBER(special_state::setup_pit8253_gates)
228227{
229   device_t *pit8253 = machine.device("pit8253");
228   device_t *pit8253 = machine().device("pit8253");
230229
231230   pit8253_gate0_w(pit8253, 0);
232231   pit8253_gate1_w(pit8253, 0);
r18113r18114
237236{
238237   specimx_set_bank(2, 0); // Initiali load ROM disk
239238   m_specimx_color = 0x70;
240   machine().scheduler().timer_set(attotime::zero, FUNC(setup_pit8253_gates));
239   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(special_state::setup_pit8253_gates),this));
241240   device_t *fdc = machine().device("wd1793");
242241   wd17xx_set_pause_time(fdc,12);
243242   wd17xx_dden_w(fdc, 0);
trunk/src/mess/machine/sorcerer.c
r18113r18114
1212
1313/* timer for sorcerer serial chip transmit and receive */
1414
15static TIMER_CALLBACK(sorcerer_serial_tc)
15TIMER_CALLBACK_MEMBER(sorcerer_state::sorcerer_serial_tc)
1616{
17   sorcerer_state *state = machine.driver_data<sorcerer_state>();
1817   /* if rs232 is enabled, uart is connected to clock defined by bit6 of port fe.
1918    Transmit and receive clocks are connected to the same clock */
2019
2120   /* if rs232 is disabled, receive clock is linked to cassette hardware */
22   if (state->m_fe & 0x80)
21   if (m_fe & 0x80)
2322   {
2423      /* connect to rs232 */
2524   }
r18113r18114
4140
4241
4342
44static TIMER_CALLBACK(sorcerer_cassette_tc)
43TIMER_CALLBACK_MEMBER(sorcerer_state::sorcerer_cassette_tc)
4544{
46   sorcerer_state *state = machine.driver_data<sorcerer_state>();
4745   UINT8 cass_ws = 0;
48   switch (state->m_fe & 0xc0)      /*/ bit 7 low indicates cassette */
46   switch (m_fe & 0xc0)      /*/ bit 7 low indicates cassette */
4947   {
5048      case 0x00:            /* Cassette 300 baud */
5149
5250         /* loading a tape - this is basically the same as the super80.
5351                           We convert the 1200/2400 Hz signal to a 0 or 1, and send it to the uart. */
5452
55         state->m_cass_data.input.length++;
53         m_cass_data.input.length++;
5654
57         cass_ws = ((cassette_device_image(machine))->input() > +0.02) ? 1 : 0;
55         cass_ws = ((cassette_device_image(machine()))->input() > +0.02) ? 1 : 0;
5856
59         if (cass_ws != state->m_cass_data.input.level)
57         if (cass_ws != m_cass_data.input.level)
6058         {
61            state->m_cass_data.input.level = cass_ws;
62            state->m_cass_data.input.bit = ((state->m_cass_data.input.length < 0x6) || (state->m_cass_data.input.length > 0x20)) ? 1 : 0;
63            state->m_cass_data.input.length = 0;
64            ay31015_set_input_pin( state->m_uart, AY31015_SI, state->m_cass_data.input.bit );
59            m_cass_data.input.level = cass_ws;
60            m_cass_data.input.bit = ((m_cass_data.input.length < 0x6) || (m_cass_data.input.length > 0x20)) ? 1 : 0;
61            m_cass_data.input.length = 0;
62            ay31015_set_input_pin( m_uart, AY31015_SI, m_cass_data.input.bit );
6563         }
6664
6765         /* saving a tape - convert the serial stream from the uart, into 1200 and 2400 Hz frequencies.
6866                           Synchronisation of the frequency pulses to the uart is extremely important. */
6967
70         state->m_cass_data.output.length++;
71         if (!(state->m_cass_data.output.length & 0x1f))
68         m_cass_data.output.length++;
69         if (!(m_cass_data.output.length & 0x1f))
7270         {
73            cass_ws = ay31015_get_output_pin( state->m_uart, AY31015_SO );
74            if (cass_ws != state->m_cass_data.output.bit)
71            cass_ws = ay31015_get_output_pin( m_uart, AY31015_SO );
72            if (cass_ws != m_cass_data.output.bit)
7573            {
76               state->m_cass_data.output.bit = cass_ws;
77               state->m_cass_data.output.length = 0;
74               m_cass_data.output.bit = cass_ws;
75               m_cass_data.output.length = 0;
7876            }
7977         }
8078
81         if (!(state->m_cass_data.output.length & 3))
79         if (!(m_cass_data.output.length & 3))
8280         {
83            if (!((state->m_cass_data.output.bit == 0) && (state->m_cass_data.output.length & 4)))
81            if (!((m_cass_data.output.bit == 0) && (m_cass_data.output.length & 4)))
8482            {
85               state->m_cass_data.output.level ^= 1;         // toggle output state, except on 2nd half of low bit
86               cassette_device_image(machine)->output(state->m_cass_data.output.level ? -1.0 : +1.0);
83               m_cass_data.output.level ^= 1;         // toggle output this, except on 2nd half of low bit
84               cassette_device_image(machine())->output(m_cass_data.output.level ? -1.0 : +1.0);
8785            }
8886         }
8987         return;
9088
9189      case 0x40:         /* Cassette 1200 baud */
9290         /* loading a tape */
93         state->m_cass_data.input.length++;
91         m_cass_data.input.length++;
9492
95         cass_ws = ((cassette_device_image(machine))->input() > +0.02) ? 1 : 0;
93         cass_ws = ((cassette_device_image(machine()))->input() > +0.02) ? 1 : 0;
9694
97         if (cass_ws != state->m_cass_data.input.level || state->m_cass_data.input.length == 10)
95         if (cass_ws != m_cass_data.input.level || m_cass_data.input.length == 10)
9896         {
99            state->m_cass_data.input.bit = ((state->m_cass_data.input.length < 10) || (state->m_cass_data.input.length > 0x20)) ? 1 : 0;
100            if ( cass_ws != state->m_cass_data.input.level )
97            m_cass_data.input.bit = ((m_cass_data.input.length < 10) || (m_cass_data.input.length > 0x20)) ? 1 : 0;
98            if ( cass_ws != m_cass_data.input.level )
10199            {
102               state->m_cass_data.input.length = 0;
103               state->m_cass_data.input.level = cass_ws;
100               m_cass_data.input.length = 0;
101               m_cass_data.input.level = cass_ws;
104102            }
105            ay31015_set_input_pin( state->m_uart, AY31015_SI, state->m_cass_data.input.bit );
103            ay31015_set_input_pin( m_uart, AY31015_SI, m_cass_data.input.bit );
106104         }
107105
108106         /* saving a tape - convert the serial stream from the uart, into 600 and 1200 Hz frequencies. */
109107
110         state->m_cass_data.output.length++;
111         if (!(state->m_cass_data.output.length & 7))
108         m_cass_data.output.length++;
109         if (!(m_cass_data.output.length & 7))
112110         {
113            cass_ws = ay31015_get_output_pin( state->m_uart, AY31015_SO );
114            if (cass_ws != state->m_cass_data.output.bit)
111            cass_ws = ay31015_get_output_pin( m_uart, AY31015_SO );
112            if (cass_ws != m_cass_data.output.bit)
115113            {
116               state->m_cass_data.output.bit = cass_ws;
117               state->m_cass_data.output.length = 0;
114               m_cass_data.output.bit = cass_ws;
115               m_cass_data.output.length = 0;
118116            }
119117         }
120118
121         if (!(state->m_cass_data.output.length & 7))
119         if (!(m_cass_data.output.length & 7))
122120         {
123            if (!((state->m_cass_data.output.bit == 0) && (state->m_cass_data.output.length & 8)))
121            if (!((m_cass_data.output.bit == 0) && (m_cass_data.output.length & 8)))
124122            {
125               state->m_cass_data.output.level ^= 1;         // toggle output state, except on 2nd half of low bit
126               cassette_device_image(machine)->output(state->m_cass_data.output.level ? -1.0 : +1.0);
123               m_cass_data.output.level ^= 1;         // toggle output this, except on 2nd half of low bit
124               cassette_device_image(machine())->output(m_cass_data.output.level ? -1.0 : +1.0);
127125            }
128126         }
129127         return;
r18113r18114
132130
133131
134132/* after the first 4 bytes have been read from ROM, switch the ram back in */
135static TIMER_CALLBACK( sorcerer_reset )
133TIMER_CALLBACK_MEMBER(sorcerer_state::sorcerer_reset)
136134{
137   sorcerer_state *state = machine.driver_data<sorcerer_state>();
138   state->membank("boot")->set_entry(0);
135   membank("boot")->set_entry(0);
139136}
140137
141138WRITE8_MEMBER(sorcerer_state::sorcerer_fc_w)
r18113r18114
353350
354351void sorcerer_state::machine_start()
355352{
356   m_cassette_timer = machine().scheduler().timer_alloc(FUNC(sorcerer_cassette_tc));
353   m_cassette_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sorcerer_state::sorcerer_cassette_tc),this));
357354#if SORCERER_USING_RS232
358   m_serial_timer = machine().scheduler().timer_alloc(FUNC(sorcerer_serial_tc));
355   m_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sorcerer_state::sorcerer_serial_tc),this));
359356#endif
360357
361358   UINT16 endmem = 0xbfff;
r18113r18114
380377
381378MACHINE_START_MEMBER(sorcerer_state,sorcererd)
382379{
383   m_cassette_timer = machine().scheduler().timer_alloc(FUNC(sorcerer_cassette_tc));
380   m_cassette_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sorcerer_state::sorcerer_cassette_tc),this));
384381#if SORCERER_USING_RS232
385   m_serial_timer = machine().scheduler().timer_alloc(FUNC(sorcerer_serial_tc));
382   m_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sorcerer_state::sorcerer_serial_tc),this));
386383#endif
387384
388385   UINT16 endmem = 0xbbff;
r18113r18114
419416   sorcerer_fe_w(space, 0, 0, 0xff);
420417
421418   membank("boot")->set_entry(1);
422   machine().scheduler().timer_set(attotime::from_usec(10), FUNC(sorcerer_reset));
419   machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(sorcerer_state::sorcerer_reset),this));
423420}
trunk/src/mess/machine/osborne1.c
r18113r18114
331331//};
332332
333333
334static TIMER_CALLBACK(osborne1_video_callback)
334TIMER_CALLBACK_MEMBER(osborne1_state::osborne1_video_callback)
335335{
336   osborne1_state *state = machine.driver_data<osborne1_state>();
337   int y = machine.primary_screen->vpos();
336   int y = machine().primary_screen->vpos();
338337   UINT8 ra=0,chr,gfx,dim;
339338   UINT16 x,ma;
340339
r18113r18114
342341   if ( y == 0 )
343342   {
344343      /* Clear CA1 on video PIA */
345      state->m_pia1->ca1_w(0);
344      m_pia1->ca1_w(0);
346345   }
347346   if ( y == 240 )
348347   {
349348      /* Set CA1 on video PIA */
350      state->m_pia1->ca1_w(1);
349      m_pia1->ca1_w(1);
351350   }
352351   if ( y < 240 )
353352   {
354353      ra = y % 10;
355354      /* Draw a line of the display */
356      ma = (state->m_new_start_y + (y/10)) * 128 + state->m_new_start_x;
357      UINT16 *p = &state->m_bitmap.pix16(y);
355      ma = (m_new_start_y + (y/10)) * 128 + m_new_start_x;
356      UINT16 *p = &m_bitmap.pix16(y);
358357
359358      for ( x = 0; x < 52; x++ )
360359      {
361         chr = machine.device<ram_device>(RAM_TAG)->pointer()[ 0xF000 + ( (ma+x) & 0xFFF ) ];
362         dim = machine.device<ram_device>(RAM_TAG)->pointer()[ 0x10000 + ( (ma+x) & 0xFFF ) ] & 0x80;
360         chr = machine().device<ram_device>(RAM_TAG)->pointer()[ 0xF000 + ( (ma+x) & 0xFFF ) ];
361         dim = machine().device<ram_device>(RAM_TAG)->pointer()[ 0x10000 + ( (ma+x) & 0xFFF ) ] & 0x80;
363362
364363         if ( (chr & 0x80) && (ra == 9) )
365364            gfx = 0xFF;
366365         else
367            gfx = state->m_p_chargen[ (ra << 7) | ( chr & 0x7F ) ];
366            gfx = m_p_chargen[ (ra << 7) | ( chr & 0x7F ) ];
368367
369368         /* Display a scanline of a character */
370369         *p++ = BIT(gfx, 7) ? ( dim ? 1 : 2 ) : 0;
r18113r18114
380379
381380   if ( (ra==2) || (ra== 6) )
382381   {
383      beep_set_state( state->m_beep, state->m_beep_state );
382      beep_set_state( m_beep, m_beep_state );
384383   }
385384   else
386385   {
387      beep_set_state( state->m_beep, 0 );
386      beep_set_state( m_beep, 0 );
388387   }
389388
390   state->m_video_timer->adjust(machine.primary_screen->time_until_pos(y + 1, 0 ));
389   m_video_timer->adjust(machine().primary_screen->time_until_pos(y + 1, 0 ));
391390}
392391
393static TIMER_CALLBACK( setup_osborne1 )
392TIMER_CALLBACK_MEMBER(osborne1_state::setup_osborne1)
394393{
395   osborne1_state *state = machine.driver_data<osborne1_state>();
396   beep_set_state( state->m_beep, 0 );
397   beep_set_frequency( state->m_beep, 300 /* 60 * 240 / 2 */ );
398   state->m_pia1->ca1_w(0);
394   beep_set_state( m_beep, 0 );
395   beep_set_frequency( m_beep, 300 /* 60 * 240 / 2 */ );
396   m_pia1->ca1_w(0);
399397}
400398
401399static void osborne1_load_proc(device_image_interface &image)
r18113r18114
453451
454452   /* Configure the 6850 ACIA */
455453//  acia6850_config( 0, &osborne1_6850_config );
456   m_video_timer = machine().scheduler().timer_alloc(FUNC(osborne1_video_callback));
454   m_video_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(osborne1_state::osborne1_video_callback),this));
457455   m_video_timer->adjust(machine().primary_screen->time_until_pos(1, 0 ));
458456
459   machine().scheduler().timer_set(attotime::zero, FUNC(setup_osborne1));
457   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(osborne1_state::setup_osborne1),this));
460458}
461459
462460
trunk/src/mess/machine/lisa.c
r18113r18114
340340
341341/* handle mouse moves */
342342/* shamelessly stolen from machine/mac.c :-) */
343static TIMER_CALLBACK(handle_mouse)
343TIMER_CALLBACK_MEMBER(lisa_state::handle_mouse)
344344{
345   lisa_state *state = machine.driver_data<lisa_state>();
346345   int diff_x = 0, diff_y = 0;
347346   int new_mx, new_my;
348347
349348#if 0
350   if (state->m_COPS_force_unplug)
349   if (m_COPS_force_unplug)
351350      return;   /* ???? */
352351#endif
353352
354   new_mx = machine.root_device().ioport("MOUSE_X")->read();
355   new_my = machine.root_device().ioport("MOUSE_Y")->read();
353   new_mx = machine().root_device().ioport("MOUSE_X")->read();
354   new_my = machine().root_device().ioport("MOUSE_Y")->read();
356355
357356   /* see if it moved in the x coord */
358   if (new_mx != state->m_last_mx)
357   if (new_mx != m_last_mx)
359358   {
360      diff_x = new_mx - state->m_last_mx;
359      diff_x = new_mx - m_last_mx;
361360
362361      /* check for wrap */
363362      if (diff_x > 0x80)
r18113r18114
365364      if  (diff_x < -0x80)
366365         diff_x = -0x100-diff_x;
367366
368      state->m_last_mx = new_mx;
367      m_last_mx = new_mx;
369368   }
370369   /* see if it moved in the y coord */
371   if (new_my != state->m_last_my)
370   if (new_my != m_last_my)
372371   {
373      diff_y = new_my - state->m_last_my;
372      diff_y = new_my - m_last_my;
374373
375374      /* check for wrap */
376375      if (diff_y > 0x80)
r18113r18114
378377      if  (diff_y < -0x80)
379378         diff_y = -0x100-diff_y;
380379
381      state->m_last_my = new_my;
380      m_last_my = new_my;
382381   }
383382
384383   /* update any remaining count and then return */
385384   if (diff_x || diff_y)
386385   {
387      if (state->m_mouse_data_offset != -1)
386      if (m_mouse_data_offset != -1)
388387      {
389         state->m_fifo_data[state->m_mouse_data_offset] += diff_x;
390         state->m_fifo_data[(state->m_mouse_data_offset+1) & 0x7] += diff_y;
388         m_fifo_data[m_mouse_data_offset] += diff_x;
389         m_fifo_data[(m_mouse_data_offset+1) & 0x7] += diff_y;
391390      }
392391      else
393392      {
394393#if 0
395         if (state->m_fifo_size <= 5)
394         if (m_fifo_size <= 5)
396395#else
397396         /* trash old data */
398         while (state->m_fifo_size > 5)
397         while (m_fifo_size > 5)
399398         {
400            state->m_fifo_head = (state->m_fifo_head+1) & 0x7;
401            state->m_fifo_size--;
399            m_fifo_head = (m_fifo_head+1) & 0x7;
400            m_fifo_size--;
402401         }
403402#endif
404403
405404         {
406405            /*logerror("Adding 3 bytes of mouse data to FIFO\n");*/
407406
408            state->m_fifo_data[state->m_fifo_tail] = 0;
409            state->m_mouse_data_offset = state->m_fifo_tail = (state->m_fifo_tail+1) & 0x7;
410            state->m_fifo_data[state->m_fifo_tail] = diff_x;
411            state->m_fifo_tail = (state->m_fifo_tail+1) & 0x7;
412            state->m_fifo_data[state->m_fifo_tail] = diff_y;
413            state->m_fifo_tail = (state->m_fifo_tail+1) & 0x7;
414            state->m_fifo_size += 3;
407            m_fifo_data[m_fifo_tail] = 0;
408            m_mouse_data_offset = m_fifo_tail = (m_fifo_tail+1) & 0x7;
409            m_fifo_data[m_fifo_tail] = diff_x;
410            m_fifo_tail = (m_fifo_tail+1) & 0x7;
411            m_fifo_data[m_fifo_tail] = diff_y;
412            m_fifo_tail = (m_fifo_tail+1) & 0x7;
413            m_fifo_size += 3;
415414
416415            /*logerror("handle_mouse : trying to send data to VIA\n");*/
417            COPS_send_data_if_possible(machine);
416            COPS_send_data_if_possible(machine());
418417         }
419418         /* else, mouse data is lost forever (correct ??) */
420419      }
r18113r18114
422421}
423422
424423/* read command from the VIA port A */
425static TIMER_CALLBACK(read_COPS_command)
424TIMER_CALLBACK_MEMBER(lisa_state::read_COPS_command)
426425{
427   lisa_state *state = machine.driver_data<lisa_state>();
428426   int command;
429   via6522_device *via_0 = machine.device<via6522_device>("via6522_0");
430   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
427   via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
428   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
431429
432   state->m_COPS_Ready = 0;
430   m_COPS_Ready = 0;
433431
434432   /*logerror("read_COPS_command : trying to send data to VIA\n");*/
435   COPS_send_data_if_possible(machine);
433   COPS_send_data_if_possible(machine());
436434
437435   /* some pull-ups allow the COPS to read 1s when the VIA port is not set as output */
438   command = (state->m_COPS_command | (~ via_0->read(space, VIA_DDRA))) & 0xff;
436   command = (m_COPS_command | (~ via_0->read(space, VIA_DDRA))) & 0xff;
439437
440438//    printf("Dropping Ready, command = %02x\n", command);
441439
r18113r18114
449447      switch ((command & 0xF0) >> 4)
450448      {
451449      case 0x1:   /* write clock data */
452         if (state->m_clock_regs.clock_write_ptr != -1)
450         if (m_clock_regs.clock_write_ptr != -1)
453451         {
454            switch (state->m_clock_regs.clock_write_ptr)
452            switch (m_clock_regs.clock_write_ptr)
455453            {
456454            case 0:
457455            case 1:
r18113r18114
459457            case 3:
460458            case 4:
461459               /* alarm */
462               state->m_clock_regs.alarm &= ~ (0xf << (4 * (4 - state->m_clock_regs.clock_write_ptr)));
463               state->m_clock_regs.alarm |= immediate << (4 * (4 - state->m_clock_regs.clock_write_ptr));
460               m_clock_regs.alarm &= ~ (0xf << (4 * (4 - m_clock_regs.clock_write_ptr)));
461               m_clock_regs.alarm |= immediate << (4 * (4 - m_clock_regs.clock_write_ptr));
464462               break;
465463            case 5:
466464               /* year */
467               state->m_clock_regs.years = immediate;
465               m_clock_regs.years = immediate;
468466               break;
469467            case 6:
470468               /* day */
471               state->m_clock_regs.days1 = immediate;
469               m_clock_regs.days1 = immediate;
472470               break;
473471            case 7:
474472               /* day */
475               state->m_clock_regs.days2 = immediate;
473               m_clock_regs.days2 = immediate;
476474               break;
477475            case 8:
478476               /* day */
479               state->m_clock_regs.days3 = immediate;
477               m_clock_regs.days3 = immediate;
480478               break;
481479            case 9:
482480               /* hours */
483               state->m_clock_regs.hours1 = immediate;
481               m_clock_regs.hours1 = immediate;
484482               break;
485483            case 10:
486484               /* hours */
487               state->m_clock_regs.hours2 = immediate;
485               m_clock_regs.hours2 = immediate;
488486               break;
489487            case 11:
490488               /* minutes */
491               state->m_clock_regs.minutes1 = immediate;
489               m_clock_regs.minutes1 = immediate;
492490               break;
493491            case 12:
494492               /* minutes */
495               state->m_clock_regs.minutes1 = immediate;
493               m_clock_regs.minutes1 = immediate;
496494               break;
497495            case 13:
498496               /* seconds */
499               state->m_clock_regs.seconds1 = immediate;
497               m_clock_regs.seconds1 = immediate;
500498               break;
501499            case 14:
502500               /* seconds */
503               state->m_clock_regs.seconds2 = immediate;
501               m_clock_regs.seconds2 = immediate;
504502               break;
505503            case 15:
506504               /* tenth */
507               state->m_clock_regs.tenths = immediate;
505               m_clock_regs.tenths = immediate;
508506               break;
509507            }
510            state->m_clock_regs.clock_write_ptr++;
511            if (state->m_clock_regs.clock_write_ptr == 16)
512               state->m_clock_regs.clock_write_ptr = -1;
508            m_clock_regs.clock_write_ptr++;
509            if (m_clock_regs.clock_write_ptr == 16)
510               m_clock_regs.clock_write_ptr = -1;
513511         }
514512
515513         break;
r18113r18114
517515      case 0x2:   /* set clock mode */
518516         if (immediate & 0x8)
519517         {   /* start setting the clock */
520            state->m_clock_regs.clock_write_ptr = 0;
518            m_clock_regs.clock_write_ptr = 0;
521519         }
522520         else
523521         {   /* clock write disabled */
524            state->m_clock_regs.clock_write_ptr = -1;
522            m_clock_regs.clock_write_ptr = -1;
525523         }
526524
527525         if (! (immediate & 0x4))
r18113r18114
533531            /* should never happen */
534532         }
535533
536         state->m_clock_regs.clock_mode = (clock_mode_t)(immediate & 0x3);
534         m_clock_regs.clock_mode = (clock_mode_t)(immediate & 0x3);
537535         break;
538536
539537#if 0
r18113r18114
548546#endif
549547
550548      case 0x5:   /* set high nibble of NMI character to nnnn */
551         state->m_NMIcode = (state->m_NMIcode & 0x0f) | (immediate << 4);
549         m_NMIcode = (m_NMIcode & 0x0f) | (immediate << 4);
552550         break;
553551
554552      case 0x6:   /* set low nibble of NMI character to nnnn */
555         state->m_NMIcode = (state->m_NMIcode & 0xf0) | immediate;
553         m_NMIcode = (m_NMIcode & 0xf0) | immediate;
556554         break;
557555
558556      case 0x7:   /* send mouse command */
559557         if (immediate & 0x8)
560            state->m_mouse_timer->adjust(attotime::zero, 0, attotime::from_msec((immediate & 0x7)*4)); /* enable mouse */
558            m_mouse_timer->adjust(attotime::zero, 0, attotime::from_msec((immediate & 0x7)*4)); /* enable mouse */
561559         else
562            state->m_mouse_timer->reset();
560            m_mouse_timer->reset();
563561         break;
564562      }
565563   }
r18113r18114
582580            UINT8 reply[7];
583581
584582            reply[0] = 0x80;
585            reply[1] = 0xE0 | state->m_clock_regs.years;
586            reply[2] = (state->m_clock_regs.days1 << 4) | state->m_clock_regs.days2;
587            reply[3] = (state->m_clock_regs.days3 << 4) | state->m_clock_regs.hours1;
588            reply[4] = (state->m_clock_regs.hours2 << 4) | state->m_clock_regs.minutes1;
589            reply[5] = (state->m_clock_regs.minutes2 << 4) | state->m_clock_regs.seconds1;
590            reply[6] = (state->m_clock_regs.seconds2 << 4) | state->m_clock_regs.tenths;
583            reply[1] = 0xE0 | m_clock_regs.years;
584            reply[2] = (m_clock_regs.days1 << 4) | m_clock_regs.days2;
585            reply[3] = (m_clock_regs.days3 << 4) | m_clock_regs.hours1;
586            reply[4] = (m_clock_regs.hours2 << 4) | m_clock_regs.minutes1;
587            reply[5] = (m_clock_regs.minutes2 << 4) | m_clock_regs.seconds1;
588            reply[6] = (m_clock_regs.seconds2 << 4) | m_clock_regs.tenths;
591589
592            COPS_queue_data(machine, reply, 7);
590            COPS_queue_data(machine(), reply, 7);
593591         }
594592         break;
595593      }
r18113r18114
597595}
598596
599597/* this timer callback raises the COPS Ready line, which tells the COPS is about to read a command */
600static TIMER_CALLBACK(set_COPS_ready)
598TIMER_CALLBACK_MEMBER(lisa_state::set_COPS_ready)
601599{
602   lisa_state *state = machine.driver_data<lisa_state>();
603   state->m_COPS_Ready = 1;
600   m_COPS_Ready = 1;
604601
605602   /* impulsion width : +/- 20us */
606   machine.scheduler().timer_set(attotime::from_usec(20), FUNC(read_COPS_command));
603   machine().scheduler().timer_set(attotime::from_usec(20), timer_expired_delegate(FUNC(lisa_state::read_COPS_command),this));
607604}
608605
609606static void reset_COPS(lisa_state *state)
r18113r18114
10311028
10321029void lisa_state::machine_start()
10331030{
1034   m_mouse_timer = machine().scheduler().timer_alloc(FUNC(handle_mouse));
1031   m_mouse_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(lisa_state::handle_mouse),this));
10351032
10361033   /* read command every ms (don't know the real value) */
1037   machine().scheduler().timer_pulse(attotime::from_msec(1), FUNC(set_COPS_ready));
1034   machine().scheduler().timer_pulse(attotime::from_msec(1), timer_expired_delegate(FUNC(lisa_state::set_COPS_ready),this));
10381035}
10391036
10401037void lisa_state::machine_reset()
trunk/src/mess/machine/lynx.c
r18113r18114
600600   }
601601}
602602
603static TIMER_CALLBACK(lynx_blitter_timer)
603TIMER_CALLBACK_MEMBER(lynx_state::lynx_blitter_timer)
604604{
605   lynx_state *state = machine.driver_data<lynx_state>();
606   state->m_blitter.busy=0; // blitter finished
607   machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
605   m_blitter.busy=0; // blitter finished
606   machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
608607}
609608
610609/*
r18113r18114
805804      }
806805   }
807806
808   machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(state->m_blitter.memory_accesses), FUNC(lynx_blitter_timer));
807   machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(state->m_blitter.memory_accesses), timer_expired_delegate(FUNC(lynx_state::lynx_blitter_timer),state));
809808}
810809
811810
r18113r18114
13941393#define NR_LYNX_TIMERS   8
13951394
13961395
1397static TIMER_CALLBACK(lynx_timer_shot);
13981396
1397
13991398static void lynx_timer_init(running_machine &machine, int which)
14001399{
14011400   lynx_state *state = machine.driver_data<lynx_state>();
14021401   memset( &state->m_timer[which], 0, sizeof(LYNX_TIMER) );
1403   state->m_timer[which].timer = machine.scheduler().timer_alloc(FUNC(lynx_timer_shot));
1402   state->m_timer[which].timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(lynx_state::lynx_timer_shot),state));
14041403}
14051404
14061405static void lynx_timer_signal_irq(running_machine &machine, int which)
r18113r18114
15061505   }
15071506}
15081507
1509static TIMER_CALLBACK(lynx_timer_shot)
1508TIMER_CALLBACK_MEMBER(lynx_state::lynx_timer_shot)
15101509{
1511   lynx_state *state = machine.driver_data<lynx_state>();
1512   lynx_timer_signal_irq( machine, param );
1513   if ( ! ( state->m_timer[param].cntrl1 & 0x10 ) ) // if reload not enabled
1510   lynx_timer_signal_irq( machine(), param );
1511   if ( ! ( m_timer[param].cntrl1 & 0x10 ) ) // if reload not enabled
15141512   {
1515      state->m_timer[param].timer_active = 0;
1516      state->m_timer[param].cntrl2 |= 8; // set timer done
1513      m_timer[param].timer_active = 0;
1514      m_timer[param].cntrl2 |= 8; // set timer done
15171515   }
15181516   else
15191517   {
1520      attotime t = (attotime::from_hz(lynx_time_factor(state->m_timer[param].cntrl1 & 0x07)) * (state->m_timer[param].bakup + 1));
1521      state->m_timer[param].timer->adjust(t, param);
1518      attotime t = (attotime::from_hz(lynx_time_factor(m_timer[param].cntrl1 & 0x07)) * (m_timer[param].bakup + 1));
1519      m_timer[param].timer->adjust(t, param);
15221520   }
15231521}
15241522
r18113r18114
16161614   memset(&state->m_uart, 0, sizeof(state->m_uart));
16171615}
16181616
1619static TIMER_CALLBACK(lynx_uart_loopback_timer)
1617TIMER_CALLBACK_MEMBER(lynx_state::lynx_uart_loopback_timer)
16201618{
1621   lynx_state *state = machine.driver_data<lynx_state>();
1622   state->m_uart.received = FALSE;
1619   m_uart.received = FALSE;
16231620}
16241621
1625static TIMER_CALLBACK(lynx_uart_timer)
1622TIMER_CALLBACK_MEMBER(lynx_state::lynx_uart_timer)
16261623{
1627   lynx_state *state = machine.driver_data<lynx_state>();
1628   if (state->m_uart.buffer_loaded)
1624   if (m_uart.buffer_loaded)
16291625   {
1630      state->m_uart.data_to_send = state->m_uart.buffer;
1631      state->m_uart.buffer_loaded = FALSE;
1632      machine.scheduler().timer_set(attotime::from_usec(11*16), FUNC(lynx_uart_timer));
1626      m_uart.data_to_send = m_uart.buffer;
1627      m_uart.buffer_loaded = FALSE;
1628      machine().scheduler().timer_set(attotime::from_usec(11*16), timer_expired_delegate(FUNC(lynx_state::lynx_uart_timer),this));
16331629   }
16341630   else
16351631   {
1636      state->m_uart.sending = FALSE;
1637      state->m_uart.received = TRUE;
1638      state->m_uart.data_received = state->m_uart.data_to_send;
1639      machine.scheduler().timer_set(attotime::from_usec(11*16), FUNC(lynx_uart_loopback_timer));
1640      if (state->m_uart.serctl & 0x40)
1632      m_uart.sending = FALSE;
1633      m_uart.received = TRUE;
1634      m_uart.data_received = m_uart.data_to_send;
1635      machine().scheduler().timer_set(attotime::from_usec(11*16), timer_expired_delegate(FUNC(lynx_state::lynx_uart_loopback_timer),this));
1636      if (m_uart.serctl & 0x40)
16411637      {
1642         state->m_mikey.data[0x81] |= 0x10;
1643         machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
1644         machine.device("maincpu")->execute().set_input_line(M65SC02_IRQ_LINE, ASSERT_LINE);
1638         m_mikey.data[0x81] |= 0x10;
1639         machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
1640         machine().device("maincpu")->execute().set_input_line(M65SC02_IRQ_LINE, ASSERT_LINE);
16451641      }
16461642   }
16471643
1648   if (state->m_uart.serctl & 0x80)
1644   if (m_uart.serctl & 0x80)
16491645   {
1650      state->m_mikey.data[0x81] |= 0x10;
1651      machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
1652      machine.device("maincpu")->execute().set_input_line(M65SC02_IRQ_LINE, ASSERT_LINE);
1646      m_mikey.data[0x81] |= 0x10;
1647      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
1648      machine().device("maincpu")->execute().set_input_line(M65SC02_IRQ_LINE, ASSERT_LINE);
16531649   }
16541650}
16551651
r18113r18114
16961692            m_uart.sending = TRUE;
16971693            m_uart.data_to_send = data;
16981694            // timing not accurate, baude rate should be calculated from timer 4 backup value and clock rate
1699            machine().scheduler().timer_set(attotime::from_usec(11*16), FUNC(lynx_uart_timer));
1695            machine().scheduler().timer_set(attotime::from_usec(11*16), timer_expired_delegate(FUNC(lynx_state::lynx_uart_timer),this));
17001696         }
17011697         break;
17021698   }
trunk/src/mess/machine/lviv.c
r18113r18114
4141   }
4242}
4343
44static TIMER_CALLBACK( lviv_reset )
44TIMER_CALLBACK_MEMBER(lviv_state::lviv_reset)
4545{
46   machine.schedule_soft_reset();
46   machine().schedule_soft_reset();
4747}
4848
4949DIRECT_UPDATE_MEMBER(lviv_state::lviv_directoverride)
5050{
5151   if (ioport("RESET")->read() & 0x01)
52      machine().scheduler().timer_set(attotime::from_usec(10), FUNC(lviv_reset));
52      machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(lviv_state::lviv_reset),this));
5353   return address;
5454}
5555
trunk/src/mess/machine/aim65.c
r18113r18114
300300*/
301301
302302
303static TIMER_CALLBACK(aim65_printer_timer)
303TIMER_CALLBACK_MEMBER(aim65_state::aim65_printer_timer)
304304{
305   aim65_state *state = machine.driver_data<aim65_state>();
306   via6522_device *via_0 = machine.device<via6522_device>("via6522_0");
305   via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
307306
308   via_0->write_cb1(state->m_printer_level);
309   via_0->write_cb1(!state->m_printer_level);
310   state->m_printer_level ^= 1;
307   via_0->write_cb1(m_printer_level);
308   via_0->write_cb1(!m_printer_level);
309   m_printer_level ^= 1;
311310
312   if (state->m_printer_dir)
311   if (m_printer_dir)
313312   {
314      if (state->m_printer_x > 0)
315         state->m_printer_x--;
313      if (m_printer_x > 0)
314         m_printer_x--;
316315      else
317316      {
318         state->m_printer_dir = 0;
319         state->m_printer_x++;
320         state->m_printer_y++;
317         m_printer_dir = 0;
318         m_printer_x++;
319         m_printer_y++;
321320      }
322321   }
323322   else
324323   {
325      if (state->m_printer_x < 9)
326         state->m_printer_x++;
324      if (m_printer_x < 9)
325         m_printer_x++;
327326      else
328327      {
329         state->m_printer_dir = 1;
330         state->m_printer_x--;
331         state->m_printer_y++;
328         m_printer_dir = 1;
329         m_printer_x--;
330         m_printer_y++;
332331      }
333332   }
334333
335   if (state->m_printer_y > 500) state->m_printer_y = 0;
334   if (m_printer_y > 500) m_printer_y = 0;
336335
337   state->m_flag_a=0;
338   state->m_flag_b=0;
336   m_flag_a=0;
337   m_flag_b=0;
339338}
340339
341340
r18113r18114
369368
370369VIDEO_START_MEMBER(aim65_state,aim65)
371370{
372   m_print_timer = machine().scheduler().timer_alloc(FUNC(aim65_printer_timer));
371   m_print_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(aim65_state::aim65_printer_timer),this));
373372   m_printerRAM = auto_alloc_array(machine(), UINT16, (600 * 10 * 2) / 2);
374373   memset(m_printerRAM, 0, videoram_size);
375374   VIDEO_START_CALL_MEMBER(generic);
trunk/src/mess/machine/pc.c
r18113r18114
291291
292292static emu_timer   *pc_int_delay_timer;
293293
294static TIMER_CALLBACK( pcjr_delayed_pic8259_irq )
294TIMER_CALLBACK_MEMBER(pc_state::pcjr_delayed_pic8259_irq)
295295{
296    machine.firstcpu->set_input_line(0, param ? ASSERT_LINE : CLEAR_LINE);
296    machine().firstcpu->set_input_line(0, param ? ASSERT_LINE : CLEAR_LINE);
297297}
298298
299299static WRITE_LINE_DEVICE_HANDLER( pcjr_pic8259_set_int_line )
r18113r18114
594594}
595595
596596
597static TIMER_CALLBACK( pcjr_keyb_signal_callback )
597TIMER_CALLBACK_MEMBER(pc_state::pcjr_keyb_signal_callback)
598598{
599599   pcjr_keyb.raw_keyb_data = pcjr_keyb.raw_keyb_data >> 1;
600600   pcjr_keyb.signal_count--;
r18113r18114
922922
923923/* check if any keys are pressed, raise IRQ1 if so */
924924
925static TIMER_CALLBACK( mc1502_keyb_signal_callback )
925TIMER_CALLBACK_MEMBER(pc_state::mc1502_keyb_signal_callback)
926926{
927   pc_state *st = machine.driver_data<pc_state>();
928927   UINT8 key = 0;
929928
930   key |= machine.root_device().ioport("Y1")->read();
931   key |= machine.root_device().ioport("Y2")->read();
932   key |= machine.root_device().ioport("Y3")->read();
933   key |= machine.root_device().ioport("Y4")->read();
934   key |= machine.root_device().ioport("Y5")->read();
935   key |= machine.root_device().ioport("Y6")->read();
936   key |= machine.root_device().ioport("Y7")->read();
937   key |= machine.root_device().ioport("Y8")->read();
938   key |= machine.root_device().ioport("Y9")->read();
939   key |= machine.root_device().ioport("Y10")->read();
940   key |= machine.root_device().ioport("Y11")->read();
941   key |= machine.root_device().ioport("Y12")->read();
942   DBG_LOG(1,"mc1502_k_s_c",("= %02X (%d) %s\n", key, mc1502_keyb.pulsing,
943      (key || mc1502_keyb.pulsing) ? " will IRQ" : ""));
929   key |= machine().root_device().ioport("Y1")->read();
930   key |= machine().root_device().ioport("Y2")->read();
931   key |= machine().root_device().ioport("Y3")->read();
932   key |= machine().root_device().ioport("Y4")->read();
933   key |= machine().root_device().ioport("Y5")->read();
934   key |= machine().root_device().ioport("Y6")->read();
935   key |= machine().root_device().ioport("Y7")->read();
936   key |= machine().root_device().ioport("Y8")->read();
937   key |= machine().root_device().ioport("Y9")->read();
938   key |= machine().root_device().ioport("Y10")->read();
939   key |= machine().root_device().ioport("Y11")->read();
940   key |= machine().root_device().ioport("Y12")->read();
941//   DBG_LOG(1,"mc1502_k_s_c",("= %02X (%d) %s\n", key, mc1502_keyb.pulsing,
942//      (key || mc1502_keyb.pulsing) ? " will IRQ" : ""));
944943
945944   /*
946945       If a key is pressed and we're not pulsing yet, start pulsing the IRQ1;
r18113r18114
954953   }
955954
956955   if (mc1502_keyb.pulsing) {
957      pic8259_ir1_w(st->m_pic8259, (mc1502_keyb.pulsing & 1));
956      pic8259_ir1_w(m_pic8259, (mc1502_keyb.pulsing & 1));
958957      mc1502_keyb.pulsing--;
959958   }
960959}
r18113r18114
14861485     */
14871486   pic8259_ir1_w(m_pic8259, 1);
14881487   memset(&mc1502_keyb, 0, sizeof(mc1502_keyb));
1489   mc1502_keyb.keyb_signal_timer = machine().scheduler().timer_alloc(FUNC(mc1502_keyb_signal_callback));
1488   mc1502_keyb.keyb_signal_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pc_state::mc1502_keyb_signal_callback),this));
14901489   mc1502_keyb.keyb_signal_timer->adjust( attotime::from_msec(20), 0, attotime::from_msec(20) );
14911490}
14921491
r18113r18114
14941493MACHINE_START_MEMBER(pc_state,pcjr)
14951494{
14961495   pc_fdc_init( machine(), &pcjr_fdc_interface_nc );
1497   pcjr_keyb.keyb_signal_timer = machine().scheduler().timer_alloc(FUNC(pcjr_keyb_signal_callback));
1498   pc_int_delay_timer = machine().scheduler().timer_alloc(FUNC(pcjr_delayed_pic8259_irq));
1496   pcjr_keyb.keyb_signal_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pc_state::pcjr_keyb_signal_callback),this));
1497   pc_int_delay_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pc_state::pcjr_delayed_pic8259_irq),this));
14991498   m_maincpu = machine().device<cpu_device>("maincpu" );
15001499   m_maincpu->set_irq_acknowledge_callback(pc_irq_callback);
15011500
r18113r18114
16791678   emu_timer *timer;
16801679} pc_rtc;
16811680
1682static TIMER_CALLBACK(pc_rtc_timer)
1681TIMER_CALLBACK_MEMBER(pc_state::pc_rtc_timer)
16831682{
16841683   int year;
16851684   if (++pc_rtc.data[2]>=60) {
r18113r18114
17041703
17051704void pc_rtc_init(running_machine &machine)
17061705{
1706   pc_state *state = machine.driver_data<pc_state>();
17071707   memset(&pc_rtc,0,sizeof(pc_rtc));
1708   pc_rtc.timer = machine.scheduler().timer_alloc(FUNC(pc_rtc_timer));
1708   pc_rtc.timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pc_state::pc_rtc_timer),state));
17091709   pc_rtc.timer->adjust(attotime::zero, 0, attotime(1,0));
17101710}
17111711
trunk/src/mess/machine/kaypro.c
r18113r18114
278278
279279*************************************************************************************/
280280
281static TIMER_CALLBACK( kaypro_timer_callback )
281TIMER_CALLBACK_MEMBER(kaypro_state::kaypro_timer_callback)
282282{
283   if (machine.device("maincpu")->state().state_int(Z80_HALT))
284      machine.device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
283   if (machine().device("maincpu")->state().state_int(Z80_HALT))
284      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
285285}
286286
287287WRITE_LINE_MEMBER( kaypro_state::kaypro_fdc_intrq_w )
288288{
289289   if (state)
290      machine().scheduler().timer_set(attotime::from_usec(25), FUNC(kaypro_timer_callback));
290      machine().scheduler().timer_set(attotime::from_usec(25), timer_expired_delegate(FUNC(kaypro_state::kaypro_timer_callback),this));
291291   else
292292      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
293293}
r18113r18114
295295WRITE_LINE_MEMBER( kaypro_state::kaypro_fdc_drq_w )
296296{
297297   if (state)
298      machine().scheduler().timer_set(attotime::from_usec(25), FUNC(kaypro_timer_callback));
298      machine().scheduler().timer_set(attotime::from_usec(25), timer_expired_delegate(FUNC(kaypro_state::kaypro_timer_callback),this));
299299   else
300300      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
301301
trunk/src/mess/machine/gamecom.c
r18113r18114
55
66static const int gamecom_timer_limit[8] = { 2, 1024, 2048, 4096, 8192, 16384, 32768, 65536 };
77
8static TIMER_CALLBACK(gamecom_clock_timer_callback)
8TIMER_CALLBACK_MEMBER(gamecom_state::gamecom_clock_timer_callback)
99{
10   UINT8 * RAM = machine.root_device().memregion("maincpu")->base();
10   UINT8 * RAM = machine().root_device().memregion("maincpu")->base();
1111   UINT8 val = ( ( RAM[SM8521_CLKT] & 0x3F ) + 1 ) & 0x3F;
1212   RAM[SM8521_CLKT] = ( RAM[SM8521_CLKT] & 0xC0 ) | val;
13   machine.device("maincpu")->execute().set_input_line(CK_INT, ASSERT_LINE );
13   machine().device("maincpu")->execute().set_input_line(CK_INT, ASSERT_LINE );
1414}
1515
1616void gamecom_state::machine_reset()
r18113r18114
536536
537537DRIVER_INIT_MEMBER(gamecom_state,gamecom)
538538{
539   m_clock_timer = machine().scheduler().timer_alloc(FUNC(gamecom_clock_timer_callback));
539   m_clock_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gamecom_state::gamecom_clock_timer_callback),this));
540540   m_p_ram = memregion("maincpu")->base(); // required here because pio_w gets called before machine_reset
541541}
542542
trunk/src/mess/machine/gb.c
r18113r18114
8080  Prototypes
8181*/
8282
83static TIMER_CALLBACK(gb_serial_timer_proc);
83
8484static void gb_machine_stop(running_machine &machine);
8585
8686
r18113r18114
250250   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(gb_machine_stop),&machine()));
251251
252252   /* Allocate the serial timer, and disable it */
253   m_gb_serial_timer = machine().scheduler().timer_alloc(FUNC(gb_serial_timer_proc));
253   m_gb_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gb_state::gb_serial_timer_proc),this));
254254   m_gb_serial_timer->enable( 0 );
255255
256256   MACHINE_START_CALL_MEMBER( gb_video );
r18113r18114
261261   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(gb_machine_stop),&machine()));
262262
263263   /* Allocate the serial timer, and disable it */
264   m_gb_serial_timer = machine().scheduler().timer_alloc(FUNC(gb_serial_timer_proc));
264   m_gb_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gb_state::gb_serial_timer_proc),this));
265265   m_gb_serial_timer->enable( 0 );
266266
267267   MACHINE_START_CALL_MEMBER( gbc_video );
r18113r18114
291291   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(gb_machine_stop),&machine()));
292292
293293   /* Allocate the serial timer, and disable it */
294   m_gb_serial_timer = machine().scheduler().timer_alloc(FUNC(gb_serial_timer_proc));
294   m_gb_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gb_state::gb_serial_timer_proc),this));
295295   m_gb_serial_timer->enable( 0 );
296296
297297   MACHINE_START_CALL_MEMBER( gb_video );
r18113r18114
18961896{
18971897}
18981898
1899static TIMER_CALLBACK(gb_serial_timer_proc)
1899TIMER_CALLBACK_MEMBER(gb_state::gb_serial_timer_proc)
19001900{
1901   gb_state *state = machine.driver_data<gb_state>();
19021901   /* Shift in a received bit */
1903   state->SIODATA = (state->SIODATA << 1) | 0x01;
1902   SIODATA = (SIODATA << 1) | 0x01;
19041903   /* Decrement number of handled bits */
1905   state->m_SIOCount--;
1904   m_SIOCount--;
19061905   /* If all bits done, stop timer and trigger interrupt */
1907   if ( ! state->m_SIOCount )
1906   if ( ! m_SIOCount )
19081907   {
1909      state->SIOCONT &= 0x7F;
1910      state->m_gb_serial_timer->enable( 0 );
1911      machine.device("maincpu")->execute().set_input_line(SIO_INT, ASSERT_LINE);
1908      SIOCONT &= 0x7F;
1909      m_gb_serial_timer->enable( 0 );
1910      machine().device("maincpu")->execute().set_input_line(SIO_INT, ASSERT_LINE);
19121911   }
19131912}
19141913
r18113r18114
20172016MACHINE_START_MEMBER(gb_state,megaduck)
20182017{
20192018   /* Allocate the serial timer, and disable it */
2020   m_gb_serial_timer = machine().scheduler().timer_alloc(FUNC(gb_serial_timer_proc));
2019   m_gb_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gb_state::gb_serial_timer_proc),this));
20212020   m_gb_serial_timer->enable( 0 );
20222021
20232022   MACHINE_START_CALL_MEMBER( gb_video );
trunk/src/mess/machine/nes.c
r18113r18114
216216   machine().device("maincpu")->reset();
217217}
218218
219static TIMER_CALLBACK( nes_irq_callback )
219TIMER_CALLBACK_MEMBER(nes_state::nes_irq_callback)
220220{
221   nes_state *state = machine.driver_data<nes_state>();
222   state->m_maincpu->set_input_line(M6502_IRQ_LINE, HOLD_LINE);
223   state->m_irq_timer->adjust(attotime::never);
221   m_maincpu->set_input_line(M6502_IRQ_LINE, HOLD_LINE);
222   m_irq_timer->adjust(attotime::never);
224223}
225224
226225static void nes_banks_restore(nes_state *state)
r18113r18114
309308      }
310309   }
311310
312   m_irq_timer = machine().scheduler().timer_alloc(FUNC(nes_irq_callback));
311   m_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(nes_state::nes_irq_callback),this));
313312   nes_state_register(machine());
314313}
315314
r18113r18114
524523}
525524
526525
527static TIMER_CALLBACK( lightgun_tick )
526TIMER_CALLBACK_MEMBER(nes_state::lightgun_tick)
528527{
529   if ((machine.root_device().ioport("CTRLSEL")->read() & 0x000f) == 0x0002)
528   if ((machine().root_device().ioport("CTRLSEL")->read() & 0x000f) == 0x0002)
530529   {
531530      /* enable lightpen crosshair */
532      crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL);
531      crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_ALL);
533532   }
534533   else
535534   {
536535      /* disable lightpen crosshair */
537      crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE);
536      crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_NONE);
538537   }
539538
540   if ((machine.root_device().ioport("CTRLSEL")->read() & 0x00f0) == 0x0030)
539   if ((machine().root_device().ioport("CTRLSEL")->read() & 0x00f0) == 0x0030)
541540   {
542541      /* enable lightpen crosshair */
543      crosshair_set_screen(machine, 1, CROSSHAIR_SCREEN_ALL);
542      crosshair_set_screen(machine(), 1, CROSSHAIR_SCREEN_ALL);
544543   }
545544   else
546545   {
547546      /* disable lightpen crosshair */
548      crosshair_set_screen(machine, 1, CROSSHAIR_SCREEN_NONE);
547      crosshair_set_screen(machine(), 1, CROSSHAIR_SCREEN_NONE);
549548   }
550549}
551550
r18113r18114
554553   int cfg = ioport("CTRLSEL")->read();
555554
556555   /* Check if lightgun has been chosen as input: if so, enable crosshair */
557   machine().scheduler().timer_set(attotime::zero, FUNC(lightgun_tick));
556   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(nes_state::lightgun_tick),this));
558557
559558   if ((cfg & 0x000f) >= 0x08)   // for now we treat the FC keyboard separately from other inputs!
560559   {
trunk/src/mess/machine/mbee.c
r18113r18114
129129************************************************************/
130130
131131
132static TIMER_CALLBACK( mbee256_kbd )
132TIMER_CALLBACK_MEMBER(mbee_state::mbee256_kbd)
133133{
134   mbee_state *state = machine.driver_data<mbee_state>();
135134    /* Keyboard scanner is a Mostek M3870 chip. Its speed of operation is determined by a 15k resistor on
136135    pin 2 (XTL2) and is therefore unknown. If a key change is detected (up or down), the /strobe
137136    line activates, sending a high to bit 1 of port 2 (one of the pio input lines). The next read of
r18113r18114
152151   for (i = 0; i < 15; i++)
153152   {
154153      sprintf(kbdrow,"X%d",i);
155      pressed[i] = (machine.root_device().ioport(kbdrow)->read());
154      pressed[i] = (machine().root_device().ioport(kbdrow)->read());
156155   }
157156
158157   /* find what has changed */
159158   for (i = 0; i < 15; i++)
160159   {
161      if (pressed[i] != state->m_mbee256_was_pressed[i])
160      if (pressed[i] != m_mbee256_was_pressed[i])
162161      {
163162         /* get scankey value */
164163         for (j = 0; j < 8; j++)
165164         {
166            if (BIT(pressed[i]^state->m_mbee256_was_pressed[i], j))
165            if (BIT(pressed[i]^m_mbee256_was_pressed[i], j))
167166            {
168167               /* put it in the queue */
169               state->m_mbee256_q[state->m_mbee256_q_pos] = (i << 3) | j | (BIT(pressed[i], j) ? 0x80 : 0);
170               if (state->m_mbee256_q_pos < 19) state->m_mbee256_q_pos++;
168               m_mbee256_q[m_mbee256_q_pos] = (i << 3) | j | (BIT(pressed[i], j) ? 0x80 : 0);
169               if (m_mbee256_q_pos < 19) m_mbee256_q_pos++;
171170            }
172171         }
173         state->m_mbee256_was_pressed[i] = pressed[i];
172         m_mbee256_was_pressed[i] = pressed[i];
174173      }
175174   }
176175
177176   /* if anything queued, cause an interrupt */
178   if (state->m_mbee256_q_pos)
179      state->m_mbee256_key_available = 2; // set irq
177   if (m_mbee256_q_pos)
178      m_mbee256_key_available = 2; // set irq
180179}
181180
182181READ8_MEMBER( mbee_state::mbee256_18_r )
r18113r18114
238237   return machine().device<mc146818_device>("rtc")->read(mem, 1);
239238}
240239
241static TIMER_CALLBACK( mbee_rtc_irq )
240TIMER_CALLBACK_MEMBER(mbee_state::mbee_rtc_irq)
242241{
243   mbee_state *state = machine.driver_data<mbee_state>();
244   address_space &mem = machine.device("maincpu")->memory().space(AS_IO);
245   UINT8 data = machine.device<mc146818_device>("rtc")->read(mem, 12);
246   if (data) state->m_clock_pulse = 0x80;
242   address_space &mem = machine().device("maincpu")->memory().space(AS_IO);
243   UINT8 data = machine().device<mc146818_device>("rtc")->read(mem, 12);
244   if (data) m_clock_pulse = 0x80;
247245}
248246
249247
r18113r18114
495493
496494
497495/* after the first 4 bytes have been read from ROM, switch the ram back in */
498static TIMER_CALLBACK( mbee_reset )
496TIMER_CALLBACK_MEMBER(mbee_state::mbee_reset)
499497{
500   mbee_state *state = machine.driver_data<mbee_state>();
501   state->membank("boot")->set_entry(0);
498   membank("boot")->set_entry(0);
502499}
503500
504501static void machine_reset_common_disk(running_machine &machine)
r18113r18114
512509MACHINE_RESET_MEMBER(mbee_state,mbee)
513510{
514511   membank("boot")->set_entry(1);
515   machine().scheduler().timer_set(attotime::from_usec(4), FUNC(mbee_reset));
512   machine().scheduler().timer_set(attotime::from_usec(4), timer_expired_delegate(FUNC(mbee_state::mbee_reset),this));
516513}
517514
518515MACHINE_RESET_MEMBER(mbee_state,mbee56)
519516{
520517   machine_reset_common_disk(machine());
521518   membank("boot")->set_entry(1);
522   machine().scheduler().timer_set(attotime::from_usec(4), FUNC(mbee_reset));
519   machine().scheduler().timer_set(attotime::from_usec(4), timer_expired_delegate(FUNC(mbee_state::mbee_reset),this));
523520}
524521
525522MACHINE_RESET_MEMBER(mbee_state,mbee64)
r18113r18114
547544   m_mbee256_q_pos = 0;
548545   mbee256_50_w(mem,0,0); // set banks to default
549546   membank("boot")->set_entry(8); // boot time
550   machine().scheduler().timer_set(attotime::from_usec(4), FUNC(mbee_reset));
547   machine().scheduler().timer_set(attotime::from_usec(4), timer_expired_delegate(FUNC(mbee_state::mbee_reset),this));
551548}
552549
553550MACHINE_RESET_MEMBER(mbee_state,mbeett)
r18113r18114
556553   for (i = 0; i < 15; i++) m_mbee256_was_pressed[i] = 0;
557554   m_mbee256_q_pos = 0;
558555   membank("boot")->set_entry(1);
559   machine().scheduler().timer_set(attotime::from_usec(4), FUNC(mbee_reset));
556   machine().scheduler().timer_set(attotime::from_usec(4), timer_expired_delegate(FUNC(mbee_state::mbee_reset),this));
560557}
561558
562559INTERRUPT_GEN_MEMBER(mbee_state::mbee_interrupt)
r18113r18114
713710   membank("bank8l")->configure_entry(0, &RAM[0x0000]); // rom
714711   membank("bank8h")->configure_entry(0, &RAM[0x0800]); // rom
715712
716   machine().scheduler().timer_pulse(attotime::from_hz(1), FUNC(mbee_rtc_irq));   /* timer for rtc */
717   machine().scheduler().timer_pulse(attotime::from_hz(25), FUNC(mbee256_kbd));   /* timer for kbd */
713   machine().scheduler().timer_pulse(attotime::from_hz(1), timer_expired_delegate(FUNC(mbee_state::mbee_rtc_irq),this));   /* timer for rtc */
714   machine().scheduler().timer_pulse(attotime::from_hz(25), timer_expired_delegate(FUNC(mbee_state::mbee256_kbd),this));   /* timer for kbd */
718715
719716   m_size = 0x8000;
720717}
r18113r18114
733730   membank("pak")->set_entry(5);
734731   membank("telcom")->set_entry(0);
735732
736   machine().scheduler().timer_pulse(attotime::from_hz(1), FUNC(mbee_rtc_irq));   /* timer for rtc */
737   machine().scheduler().timer_pulse(attotime::from_hz(25), FUNC(mbee256_kbd));   /* timer for kbd */
733   machine().scheduler().timer_pulse(attotime::from_hz(1), timer_expired_delegate(FUNC(mbee_state::mbee_rtc_irq),this));   /* timer for rtc */
734   machine().scheduler().timer_pulse(attotime::from_hz(25), timer_expired_delegate(FUNC(mbee_state::mbee256_kbd),this));   /* timer for kbd */
738735
739736   m_size = 0x8000;
740737}
trunk/src/mess/machine/rmnimbus.c
r18113r18114
177177static void hdc_drq(running_machine &machine);
178178
179179static void keyboard_reset(running_machine &machine);
180static TIMER_CALLBACK(keyscan_callback);
181180
181
182182static void pc8031_reset(running_machine &machine);
183183static void iou_reset(running_machine &machine);
184184static void rmni_sound_reset(running_machine &machine);
185185
186186static void mouse_js_reset(running_machine &machine);
187static TIMER_CALLBACK(mouse_callback);
188187
189188
189
190190/*************************************
191191 *
192192 *  80186 interrupt controller
r18113r18114
458458 *
459459 *************************************/
460460
461static TIMER_CALLBACK(internal_timer_int)
461TIMER_CALLBACK_MEMBER(rmnimbus_state::internal_timer_int)
462462{
463   rmnimbus_state *state = machine.driver_data<rmnimbus_state>();
464463   int which = param;
465   struct timer_state *t = &state->m_i186.timer[which];
464   struct timer_state *t = &m_i186.timer[which];
466465
467466   if (LOG_TIMER) logerror("Hit interrupt callback for timer %d\n", which);
468467
r18113r18114
472471   /* request an interrupt */
473472   if (t->control & 0x2000)
474473   {
475      state->m_i186.intr.status |= 0x01 << which;
476      update_interrupt_state(machine);
474      m_i186.intr.status |= 0x01 << which;
475      update_interrupt_state(machine());
477476      if (LOG_TIMER) logerror("  Generating timer interrupt\n");
478477   }
479478
r18113r18114
654653 *
655654 *************************************/
656655
657static TIMER_CALLBACK(dma_timer_callback)
656TIMER_CALLBACK_MEMBER(rmnimbus_state::dma_timer_callback)
658657{
659   rmnimbus_state *state = machine.driver_data<rmnimbus_state>();
660658   int which = param;
661   struct dma_state *d = &state->m_i186.dma[which];
659   struct dma_state *d = &m_i186.dma[which];
662660
663661   /* complete the status update */
664662   d->control &= ~0x0002;
r18113r18114
669667   if (d->control & 0x0100)
670668   {
671669      if (LOG_DMA>1) logerror("DMA%d timer callback - requesting interrupt: count = %04X, source = %04X\n", which, d->count, d->source);
672      state->m_i186.intr.request |= 0x04 << which;
673      update_interrupt_state(machine);
670      m_i186.intr.request |= 0x04 << which;
671      update_interrupt_state(machine());
674672   }
675673}
676674
r18113r18114
806804   logerror("Machine reset\n");
807805
808806   /* create timers here so they stick around */
809   state->m_i186.timer[0].int_timer = machine.scheduler().timer_alloc(FUNC(internal_timer_int));
810   state->m_i186.timer[1].int_timer = machine.scheduler().timer_alloc(FUNC(internal_timer_int));
811   state->m_i186.timer[2].int_timer = machine.scheduler().timer_alloc(FUNC(internal_timer_int));
807   state->m_i186.timer[0].int_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::internal_timer_int),state));
808   state->m_i186.timer[1].int_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::internal_timer_int),state));
809   state->m_i186.timer[2].int_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::internal_timer_int),state));
812810   state->m_i186.timer[0].time_timer = machine.scheduler().timer_alloc(FUNC_NULL);
813811   state->m_i186.timer[1].time_timer = machine.scheduler().timer_alloc(FUNC_NULL);
814812   state->m_i186.timer[2].time_timer = machine.scheduler().timer_alloc(FUNC_NULL);
815   state->m_i186.dma[0].finish_timer = machine.scheduler().timer_alloc(FUNC(dma_timer_callback));
816   state->m_i186.dma[1].finish_timer = machine.scheduler().timer_alloc(FUNC(dma_timer_callback));
813   state->m_i186.dma[0].finish_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::dma_timer_callback),state));
814   state->m_i186.dma[1].finish_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::dma_timer_callback),state));
817815}
818816
819817static void nimbus_cpu_reset(running_machine &machine)
r18113r18114
12621260   /* init cpu */
12631261   nimbus_cpu_init(machine());
12641262
1265   m_keyboard.keyscan_timer=machine().scheduler().timer_alloc(FUNC(keyscan_callback));
1266   m_nimbus_mouse.m_mouse_timer=machine().scheduler().timer_alloc(FUNC(mouse_callback));
1263   m_keyboard.keyscan_timer=machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::keyscan_callback),this));
1264   m_nimbus_mouse.m_mouse_timer=machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::mouse_callback),this));
12671265
12681266   /* setup debug commands */
12691267   if (machine().debug_flags & DEBUG_FLAG_ENABLED)
r18113r18114
21712169    }
21722170}
21732171
2174static TIMER_CALLBACK(keyscan_callback)
2172TIMER_CALLBACK_MEMBER(rmnimbus_state::keyscan_callback)
21752173{
2176    scan_keyboard(machine);
2174    scan_keyboard(machine());
21772175}
21782176
21792177/*
r18113r18114
28362834    state->m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(1000));
28372835}
28382836
2839static TIMER_CALLBACK(mouse_callback)
2837TIMER_CALLBACK_MEMBER(rmnimbus_state::mouse_callback)
28402838{
2841   rmnimbus_state *drvstate = machine.driver_data<rmnimbus_state>();
28422839    UINT8   x = 0;
28432840    UINT8   y = 0;
2844//  int     pc=machine.device(MAINCPU_TAG)->safe_pc();
2841//  int     pc=machine().device(MAINCPU_TAG)->safe_pc();
28452842
28462843    UINT8   intstate_x;
28472844    UINT8   intstate_y;
28482845    int     xint;
28492846    int     yint;
28502847
2851    mouse_joy_state *state = &drvstate->m_nimbus_mouse;
2848    mouse_joy_state *state = &m_nimbus_mouse;
28522849
28532850
2854   state->m_reg0a4 = machine.root_device().ioport(MOUSE_BUTTON_TAG)->read() | 0xC0;
2855   x = machine.root_device().ioport(MOUSEX_TAG)->read();
2856    y = machine.root_device().ioport(MOUSEY_TAG)->read();
2851   state->m_reg0a4 = machine().root_device().ioport(MOUSE_BUTTON_TAG)->read() | 0xC0;
2852   x = machine().root_device().ioport(MOUSEX_TAG)->read();
2853    y = machine().root_device().ioport(MOUSEY_TAG)->read();
28572854
28582855    UINT8   mxa;
28592856    UINT8   mxb;
r18113r18114
29232920//              mxb,mxa, (mxb ^ mxa) , (state->m_ay8910_a & 0xC0), (mxb ^ mxa) ^ ((state->m_ay8910_a & 0x40) >> 6));
29242921    }
29252922
2926    intstate_x = (mxb ^ mxa) ^ ((drvstate->m_ay8910_a & 0x40) >> 6);
2927    intstate_y = (myb ^ mya) ^ ((drvstate->m_ay8910_a & 0x80) >> 7);
2923    intstate_x = (mxb ^ mxa) ^ ((m_ay8910_a & 0x40) >> 6);
2924    intstate_y = (myb ^ mya) ^ ((m_ay8910_a & 0x80) >> 7);
29282925
2929    if (MOUSE_INT_ENABLED(drvstate))
2926    if (MOUSE_INT_ENABLED(this))
29302927    {
29312928        if ((intstate_x==1) && (state->m_intstate_x==0))
29322929//        if (intstate_x!=state->m_intstate_x)
r18113r18114
29342931
29352932            xint=mxa ? EXTERNAL_INT_MOUSE_XR : EXTERNAL_INT_MOUSE_XL;
29362933
2937            external_int(machine,0,xint);
2934            external_int(machine(),0,xint);
29382935
29392936//            logerror("Xint:%02X, mxb=%02X\n",xint,mxb);
29402937        }
r18113r18114
29442941        {
29452942            yint=myb ? EXTERNAL_INT_MOUSE_YU : EXTERNAL_INT_MOUSE_YD;
29462943
2947            external_int(machine,0,yint);
2944            external_int(machine(),0,yint);
29482945//            logerror("Yint:%02X, myb=%02X\n",yint,myb);
29492946        }
29502947    }
trunk/src/mess/machine/macpci.c
r18113r18114
2222#define LOG_ADB         0
2323#define LOG_VIA         0
2424
25static TIMER_CALLBACK(mac_6015_tick);
2625
26
2727/* VIA1 Handlers */
2828
2929static DECLARE_READ8_DEVICE_HANDLER(mac_via_in_a);
r18113r18114
144144
145145void macpci_state::machine_start()
146146{
147   m_6015_timer = machine().scheduler().timer_alloc(FUNC(mac_6015_tick));
147   m_6015_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(macpci_state::mac_6015_tick),this));
148148   m_6015_timer->adjust(attotime::never);
149149}
150150
r18113r18114
250250{
251251}
252252
253static TIMER_CALLBACK(mac_6015_tick)
253TIMER_CALLBACK_MEMBER(macpci_state::mac_6015_tick)
254254{
255//  macpci_state *mac = machine.driver_data<macpci_state>();
256255}
trunk/src/mess/machine/bk.c
r18113r18114
1313#include "includes/bk.h"
1414
1515
16static TIMER_CALLBACK(keyboard_callback)
16TIMER_CALLBACK_MEMBER(bk_state::keyboard_callback)
1717{
18   bk_state *state = machine.driver_data<bk_state>();
1918   UINT8 code, i, j;
2019   static const char *const keynames[] = {
2120      "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6",
r18113r18114
2423
2524   for(i = 1; i < 12; i++)
2625   {
27      code =   machine.root_device().ioport(keynames[i-1])->read();
26      code =   machine().root_device().ioport(keynames[i-1])->read();
2827      if (code != 0)
2928      {
3029         for(j = 0; j < 8; j++)
3130         {
3231            if (code == (1 << j))
3332            {
34               state->m_key_code = j + i*8;
33               m_key_code = j + i*8;
3534               break;
3635            }
3736         }
38         if ((machine.root_device().ioport("LINE0")->read() & 4) == 4)
37         if ((machine().root_device().ioport("LINE0")->read() & 4) == 4)
3938         {
4039            if (i==6 || i==7)
4140            {
42               state->m_key_code -= 16;
41               m_key_code -= 16;
4342            }
4443
4544         }
46         if ((machine.root_device().ioport("LINE0")->read() & 4) == 4)
45         if ((machine().root_device().ioport("LINE0")->read() & 4) == 4)
4746         {
4847            if (i>=8 && i<=11)
4948            {
50               state->m_key_code += 32;
49               m_key_code += 32;
5150            }
5251         }
53         state->m_key_pressed = 0x40;
54         if ((machine.root_device().ioport("LINE0")->read() & 2) == 0)
52         m_key_pressed = 0x40;
53         if ((machine().root_device().ioport("LINE0")->read() & 2) == 0)
5554         {
56            state->m_key_irq_vector = 0x30;
55            m_key_irq_vector = 0x30;
5756         }
5857         else
5958         {
60            state->m_key_irq_vector = 0xBC;
59            m_key_irq_vector = 0xBC;
6160         }
62         machine.device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
61         machine().device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
6362         break;
6463      }
6564   }
r18113r18114
6867
6968void bk_state::machine_start()
7069{
71   machine().scheduler().timer_pulse(attotime::from_hz(2400), FUNC(keyboard_callback));
70   machine().scheduler().timer_pulse(attotime::from_hz(2400), timer_expired_delegate(FUNC(bk_state::keyboard_callback),this));
7271}
7372
7473static IRQ_CALLBACK(bk0010_irq_callback)
trunk/src/mess/machine/rm380z.c
r18113r18114
158158// for about 4.5 milliseconds every 20 milliseconds"
159159//
160160
161static TIMER_CALLBACK(static_vblank_timer)
161TIMER_CALLBACK_MEMBER(rm380z_state::static_vblank_timer)
162162{
163   //printf("timer callback called at [%f]\n",machine.time().as_double());
163   //printf("timer callback called at [%f]\n",machine().time().as_double());
164164
165   rm380z_state *state = machine.driver_data<rm380z_state>();
166165
167   state->m_rasterlineCtr++;
168   state->m_rasterlineCtr%=(HORZ_LINES*LINE_SUBDIVISION);
166   m_rasterlineCtr++;
167   m_rasterlineCtr%=(HORZ_LINES*LINE_SUBDIVISION);
169168
170169   // frame blanking
171   if (state->m_rasterlineCtr>=((HORZ_LINES-22)*LINE_SUBDIVISION))
170   if (m_rasterlineCtr>=((HORZ_LINES-22)*LINE_SUBDIVISION))
172171   {
173      state->m_port1|=0x40;
172      m_port1|=0x40;
174173   }
175174   else
176175   {
177      state->m_port1&=~0x40;
176      m_port1&=~0x40;
178177   }
179178
180179   // line blanking
181   if ((state->m_rasterlineCtr%LINE_SUBDIVISION)>80)
180   if ((m_rasterlineCtr%LINE_SUBDIVISION)>80)
182181   {
183      state->m_port1|=0x80;
182      m_port1|=0x80;
184183   }
185184   else
186185   {
187      state->m_port1&=~0x80;
186      m_port1&=~0x80;
188187   }
189188}
190189
r18113r18114
249248
250249void rm380z_state::machine_start()
251250{
252   machine().scheduler().timer_pulse(attotime::from_hz(TIMER_SPEED), FUNC(static_vblank_timer));
251   machine().scheduler().timer_pulse(attotime::from_hz(TIMER_SPEED), timer_expired_delegate(FUNC(rm380z_state::static_vblank_timer),this));
253252}
254253
255254void rm380z_state::machine_reset()
trunk/src/mess/machine/pokemini.c
r18113r18114
189189}
190190
191191
192static TIMER_CALLBACK(pokemini_seconds_timer_callback)
192TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_seconds_timer_callback)
193193{
194   pokemini_state *state = machine.driver_data<pokemini_state>();
195   if ( state->m_pm_reg[0x08] & 0x01 )
194   if ( m_pm_reg[0x08] & 0x01 )
196195   {
197      state->m_pm_reg[0x09] += 1;
198      if ( ! state->m_pm_reg[0x09] )
196      m_pm_reg[0x09] += 1;
197      if ( ! m_pm_reg[0x09] )
199198      {
200         state->m_pm_reg[0x0A] += 1;
201         if ( ! state->m_pm_reg[0x0A] )
199         m_pm_reg[0x0A] += 1;
200         if ( ! m_pm_reg[0x0A] )
202201         {
203            state->m_pm_reg[0x0B] += 1;
202            m_pm_reg[0x0B] += 1;
204203         }
205204      }
206205   }
207206}
208207
209208
210static TIMER_CALLBACK(pokemini_256hz_timer_callback)
209TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_256hz_timer_callback)
211210{
212   pokemini_state *state = machine.driver_data<pokemini_state>();
213   if ( state->m_pm_reg[0x40] & 0x01 )
211   if ( m_pm_reg[0x40] & 0x01 )
214212   {
215      state->m_pm_reg[0x41] += 1;
213      m_pm_reg[0x41] += 1;
216214      /* Check if the 32Hz IRQ should be triggered */
217      if ( ! ( state->m_pm_reg[0x41] & 0x07 ) )
215      if ( ! ( m_pm_reg[0x41] & 0x07 ) )
218216      {
219         state->m_pm_reg[0x28] |= 0x20;
217         m_pm_reg[0x28] |= 0x20;
220218
221219         /* Check if the 8Hz IRQ should be triggered */
222         if ( ! ( state->m_pm_reg[0x41] & 0x1F ) )
220         if ( ! ( m_pm_reg[0x41] & 0x1F ) )
223221         {
224            state->m_pm_reg[0x28] |= 0x10;
222            m_pm_reg[0x28] |= 0x10;
225223
226224            /* Check if the 2Hz IRQ should be triggered */
227            if ( ! ( state->m_pm_reg[0x41] & 0x7F ) )
225            if ( ! ( m_pm_reg[0x41] & 0x7F ) )
228226            {
229               state->m_pm_reg[0x28] |= 0x08;
227               m_pm_reg[0x28] |= 0x08;
230228
231229               /* Check if the 1Hz IRQ should be triggered */
232               if ( ! state->m_pm_reg[0x41] )
230               if ( ! m_pm_reg[0x41] )
233231               {
234                  state->m_pm_reg[0x28] |= 0x04;
232                  m_pm_reg[0x28] |= 0x04;
235233               }
236234            }
237235         }
238236
239         pokemini_check_irqs( machine );
237         pokemini_check_irqs( machine() );
240238      }
241239   }
242240}
243241
244242
245static TIMER_CALLBACK(pokemini_timer1_callback)
243TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer1_callback)
246244{
247   pokemini_state *state = machine.driver_data<pokemini_state>();
248   state->m_pm_reg[0x36] -= 1;
245   m_pm_reg[0x36] -= 1;
249246   /* Check for underflow of timer */
250   if ( state->m_pm_reg[0x36] == 0xFF )
247   if ( m_pm_reg[0x36] == 0xFF )
251248   {
252249      /* Check if timer1 is running in 16bit mode */
253      if ( state->m_pm_reg[0x30] & 0x80 )
250      if ( m_pm_reg[0x30] & 0x80 )
254251      {
255         state->m_pm_reg[0x37] -= 1;
256         if ( state->m_pm_reg[0x37] == 0xFF )
252         m_pm_reg[0x37] -= 1;
253         if ( m_pm_reg[0x37] == 0xFF )
257254         {
258            state->m_pm_reg[0x27] |= 0x08;
259            pokemini_check_irqs( machine );
260            state->m_pm_reg[0x36] = state->m_pm_reg[0x32];
261            state->m_pm_reg[0x37] = state->m_pm_reg[0x33];
255            m_pm_reg[0x27] |= 0x08;
256            pokemini_check_irqs( machine() );
257            m_pm_reg[0x36] = m_pm_reg[0x32];
258            m_pm_reg[0x37] = m_pm_reg[0x33];
262259         }
263260      }
264261      else
265262      {
266         state->m_pm_reg[0x27] |= 0x04;
267         pokemini_check_irqs( machine );
268         state->m_pm_reg[0x36] = state->m_pm_reg[0x32];
263         m_pm_reg[0x27] |= 0x04;
264         pokemini_check_irqs( machine() );
265         m_pm_reg[0x36] = m_pm_reg[0x32];
269266      }
270267   }
271268}
272269
273270
274static TIMER_CALLBACK(pokemini_timer1_hi_callback)
271TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer1_hi_callback)
275272{
276   pokemini_state *state = machine.driver_data<pokemini_state>();
277   state->m_pm_reg[0x37] -= 1;
273   m_pm_reg[0x37] -= 1;
278274   /* Check for underflow of timer */
279   if ( state->m_pm_reg[0x37] == 0xFF )
275   if ( m_pm_reg[0x37] == 0xFF )
280276   {
281      state->m_pm_reg[0x27] |= 0x08;
282      pokemini_check_irqs( machine );
283      state->m_pm_reg[0x37] = state->m_pm_reg[0x33];
277      m_pm_reg[0x27] |= 0x08;
278      pokemini_check_irqs( machine() );
279      m_pm_reg[0x37] = m_pm_reg[0x33];
284280   }
285281}
286282
287283
288static TIMER_CALLBACK(pokemini_timer2_callback)
284TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer2_callback)
289285{
290   pokemini_state *state = machine.driver_data<pokemini_state>();
291   state->m_pm_reg[0x3E] -= 1;
286   m_pm_reg[0x3E] -= 1;
292287   /* Check for underflow of timer */
293   if ( state->m_pm_reg[0x3E] == 0xFF )
288   if ( m_pm_reg[0x3E] == 0xFF )
294289   {
295290      /* Check if timer2 is running in 16bit mode */
296      if ( state->m_pm_reg[0x38] & 0x80 )
291      if ( m_pm_reg[0x38] & 0x80 )
297292      {
298         state->m_pm_reg[0x3F] -= 1;
299         if ( state->m_pm_reg[0x3F] == 0xFF )
293         m_pm_reg[0x3F] -= 1;
294         if ( m_pm_reg[0x3F] == 0xFF )
300295         {
301            state->m_pm_reg[0x27] |= 0x20;
302            pokemini_check_irqs( machine );
303            state->m_pm_reg[0x3E] = state->m_pm_reg[0x3A];
304            state->m_pm_reg[0x3F] = state->m_pm_reg[0x3B];
296            m_pm_reg[0x27] |= 0x20;
297            pokemini_check_irqs( machine() );
298            m_pm_reg[0x3E] = m_pm_reg[0x3A];
299            m_pm_reg[0x3F] = m_pm_reg[0x3B];
305300         }
306301      }
307302      else
308303      {
309         state->m_pm_reg[0x27] |= 0x10;
310         pokemini_check_irqs( machine );
311         state->m_pm_reg[0x3E] = state->m_pm_reg[0x3A];
304         m_pm_reg[0x27] |= 0x10;
305         pokemini_check_irqs( machine() );
306         m_pm_reg[0x3E] = m_pm_reg[0x3A];
312307      }
313308   }
314309}
315310
316311
317static TIMER_CALLBACK(pokemini_timer2_hi_callback)
312TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer2_hi_callback)
318313{
319   pokemini_state *state = machine.driver_data<pokemini_state>();
320   state->m_pm_reg[0x3F] -= 1;
314   m_pm_reg[0x3F] -= 1;
321315   /* Check for underfow of timer */
322   if ( state->m_pm_reg[0x3F] == 0xFF )
316   if ( m_pm_reg[0x3F] == 0xFF )
323317   {
324      state->m_pm_reg[0x27] |= 0x20;
325      pokemini_check_irqs( machine );
326      state->m_pm_reg[0x3F] = state->m_pm_reg[0x3B];
318      m_pm_reg[0x27] |= 0x20;
319      pokemini_check_irqs( machine() );
320      m_pm_reg[0x3F] = m_pm_reg[0x3B];
327321   }
328322}
329323
330324
331static TIMER_CALLBACK(pokemini_timer3_callback)
325TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer3_callback)
332326{
333   pokemini_state *state = machine.driver_data<pokemini_state>();
334   state->m_pm_reg[0x4E] -= 1;
327   m_pm_reg[0x4E] -= 1;
335328   /* Check for underflow of timer */
336   if ( state->m_pm_reg[0x4E] == 0xFF )
329   if ( m_pm_reg[0x4E] == 0xFF )
337330   {
338331      /* Check if timer3 is running in 16bit mode */
339      if ( state->m_pm_reg[0x48] & 0x80 )
332      if ( m_pm_reg[0x48] & 0x80 )
340333      {
341         state->m_pm_reg[0x4F] -= 1;
342         if ( state->m_pm_reg[0x4F] == 0xFF )
334         m_pm_reg[0x4F] -= 1;
335         if ( m_pm_reg[0x4F] == 0xFF )
343336         {
344            state->m_pm_reg[0x27] |= 0x02;
345            pokemini_check_irqs( machine );
346            state->m_pm_reg[0x4E] = state->m_pm_reg[0x4A];
347            state->m_pm_reg[0x4F] = state->m_pm_reg[0x4B];
337            m_pm_reg[0x27] |= 0x02;
338            pokemini_check_irqs( machine() );
339            m_pm_reg[0x4E] = m_pm_reg[0x4A];
340            m_pm_reg[0x4F] = m_pm_reg[0x4B];
348341         }
349342      }
350343      else
351344      {
352         state->m_pm_reg[0x4E] = state->m_pm_reg[0x4A];
345         m_pm_reg[0x4E] = m_pm_reg[0x4A];
353346      }
354347   }
355348
356   if ( state->m_pm_reg[0x48] & 0x80 )
349   if ( m_pm_reg[0x48] & 0x80 )
357350   {
358      if (  ( state->m_pm_reg[0x4E] == state->m_pm_reg[0x4C] ) && ( state->m_pm_reg[0x4F] == state->m_pm_reg[0x4D] ) )
351      if (  ( m_pm_reg[0x4E] == m_pm_reg[0x4C] ) && ( m_pm_reg[0x4F] == m_pm_reg[0x4D] ) )
359352      {
360         state->m_pm_reg[0x27] |= 0x01;
361         pokemini_check_irqs( machine );
353         m_pm_reg[0x27] |= 0x01;
354         pokemini_check_irqs( machine() );
362355      }
363      pokemini_update_sound( machine );
356      pokemini_update_sound( machine() );
364357   }
365358}
366359
367360
368static TIMER_CALLBACK(pokemini_timer3_hi_callback)
361TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer3_hi_callback)
369362{
370   pokemini_state *state = machine.driver_data<pokemini_state>();
371   state->m_pm_reg[0x4F] -= 1;
363   m_pm_reg[0x4F] -= 1;
372364   /* Check for underflow of timer */
373   if ( state->m_pm_reg[0x4F] == 0xFF )
365   if ( m_pm_reg[0x4F] == 0xFF )
374366   {
375      state->m_pm_reg[0x27] |= 0x02;
376      pokemini_check_irqs( machine );
377      state->m_pm_reg[0x4F] = state->m_pm_reg[0x4B];
367      m_pm_reg[0x27] |= 0x02;
368      pokemini_check_irqs( machine() );
369      m_pm_reg[0x4F] = m_pm_reg[0x4B];
378370   }
379371
380   if ( ! ( state->m_pm_reg[0x48] & 0x80 ) )
372   if ( ! ( m_pm_reg[0x48] & 0x80 ) )
381373   {
382      if( state->m_pm_reg[0x4F] == state->m_pm_reg[0x4D] )
374      if( m_pm_reg[0x4F] == m_pm_reg[0x4D] )
383375      {
384         state->m_pm_reg[0x27] |= 0x01;
385         pokemini_check_irqs( machine );
376         m_pm_reg[0x27] |= 0x01;
377         pokemini_check_irqs( machine() );
386378      }
387      pokemini_update_sound( machine );
379      pokemini_update_sound( machine() );
388380   }
389381}
390382
r18113r18114
14131405}
14141406
14151407
1416static TIMER_CALLBACK( pokemini_prc_counter_callback )
1408TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_prc_counter_callback)
14171409{
1418   pokemini_state *state = machine.driver_data<pokemini_state>();
1419   address_space &space = machine.device( "maincpu")->memory().space( AS_PROGRAM );
1420   state->m_prc.count++;
1410   address_space &space = machine().device( "maincpu")->memory().space( AS_PROGRAM );
1411   m_prc.count++;
14211412
14221413   /* Check for overflow */
1423   if ( state->m_prc.count >= 0x42 )
1414   if ( m_prc.count >= 0x42 )
14241415   {
1425      state->m_prc.count = 0;
1426      state->m_prc.frame_count++;
1416      m_prc.count = 0;
1417      m_prc.frame_count++;
14271418   }
14281419   else
14291420   {
1430      if ( state->m_prc.count == 0x18 && state->m_prc.frame_count >= state->m_prc.max_frame_count )
1421      if ( m_prc.count == 0x18 && m_prc.frame_count >= m_prc.max_frame_count )
14311422      {
1432         state->m_prc.frame_count = 0;
1423         m_prc.frame_count = 0;
14331424
14341425         /* Check if the background should be drawn */
1435         if ( state->m_prc.background_enabled )
1426         if ( m_prc.background_enabled )
14361427         {
14371428            int x, y;
14381429            for ( y = 0; y < 8; y++ ) {
14391430               for ( x = 0; x < 12; x++ ) {
1440                  UINT8 tile = state->m_p_ram[ 0x360 + ( y * state->m_prc.map_size_x ) + x ];
1431                  UINT8 tile = m_p_ram[ 0x360 + ( y * m_prc.map_size_x ) + x ];
14411432                  int i;
14421433                  for( i = 0; i < 8; i++ ) {
1443                     state->m_p_ram[ ( y * 96 ) + ( x * 8 ) + i ] = space.read_byte( state->m_prc.bg_tiles + ( tile * 8 ) + i );
1434                     m_p_ram[ ( y * 96 ) + ( x * 8 ) + i ] = space.read_byte( m_prc.bg_tiles + ( tile * 8 ) + i );
14441435                  }
14451436               }
14461437            }
14471438         }
14481439
14491440         /* Check if the sprites should be drawn */
1450         if ( state->m_prc.sprites_enabled )
1441         if ( m_prc.sprites_enabled )
14511442         {
14521443            UINT16   spr;
14531444
14541445            for ( spr = 0x35C; spr >= 0x300; spr -= 4 )
14551446            {
1456               int      spr_x = ( state->m_p_ram[ spr + 0 ] & 0x7F ) - 16;
1457               int      spr_y = ( state->m_p_ram[ spr + 1 ] & 0x7F ) - 16;
1458               UINT8   spr_tile = state->m_p_ram[ spr + 2 ];
1459               UINT8   spr_flag = state->m_p_ram[ spr + 3 ];
1447               int      spr_x = ( m_p_ram[ spr + 0 ] & 0x7F ) - 16;
1448               int      spr_y = ( m_p_ram[ spr + 1 ] & 0x7F ) - 16;
1449               UINT8   spr_tile = m_p_ram[ spr + 2 ];
1450               UINT8   spr_flag = m_p_ram[ spr + 3 ];
14601451
14611452               if ( spr_flag & 0x08 )
14621453               {
14631454                  UINT16   gfx, mask;
1464                  UINT32   spr_base = state->m_prc.spr_tiles + spr_tile * 64;
1455                  UINT32   spr_base = m_prc.spr_tiles + spr_tile * 64;
14651456                  int      i, j;
14661457
14671458                  for ( i = 0; i < 16; i++ )
r18113r18114
14901481                              {
14911482                                 if ( mask & 0x8000 )
14921483                                 {
1493                                    state->m_p_ram[ ram_addr ] &= ~ ( 1 << ( ( spr_y + j ) & 0x07 ) );
1484                                    m_p_ram[ ram_addr ] &= ~ ( 1 << ( ( spr_y + j ) & 0x07 ) );
14941485                                    if ( gfx & 0x8000 )
14951486                                    {
1496                                       state->m_p_ram[ ram_addr ] |= ( 1 << ( ( spr_y + j ) & 0x07 ) );
1487                                       m_p_ram[ ram_addr ] |= ( 1 << ( ( spr_y + j ) & 0x07 ) );
14971488                                    }
14981489                                 }
14991490                                 mask <<= 1;
r18113r18114
15031494                              {
15041495                                 if ( mask & 0x0001 )
15051496                                 {
1506                                    state->m_p_ram[ ram_addr ] &= ~ ( 1 << ( ( spr_y + j ) & 0x07 ) );
1497                                    m_p_ram[ ram_addr ] &= ~ ( 1 << ( ( spr_y + j ) & 0x07 ) );
15071498                                    if ( gfx & 0x0001 )
15081499                                    {
1509                                       state->m_p_ram[ ram_addr ] |= ( 1 << ( ( spr_y + j ) & 0x07 ) );
1500                                       m_p_ram[ ram_addr ] |= ( 1 << ( ( spr_y + j ) & 0x07 ) );
15101501                                    }
15111502                                 }
15121503                                 mask >>= 1;
r18113r18114
15211512         }
15221513
15231514         /* Set PRC Render interrupt */
1524         state->m_pm_reg[0x27] |= 0x40;
1525         pokemini_check_irqs( machine );
1515         m_pm_reg[0x27] |= 0x40;
1516         pokemini_check_irqs( machine() );
15261517
15271518         /* Check if the rendered data should be copied to the LCD */
1528         if ( state->m_prc.copy_enabled )
1519         if ( m_prc.copy_enabled )
15291520         {
15301521            int   x, y;
15311522
15321523            for( y = 0; y < 64; y += 8 ) {
15331524               for( x = 0; x < 96; x++ ) {
1534                  UINT8 data = state->m_p_ram[ ( y * 12 ) + x ];
1525                  UINT8 data = m_p_ram[ ( y * 12 ) + x ];
15351526
1536                  state->m_bitmap.pix16(y + 0, x) = ( data & 0x01 ) ? 3 : 0;
1537                  state->m_bitmap.pix16(y + 1, x) = ( data & 0x02 ) ? 3 : 0;
1538                  state->m_bitmap.pix16(y + 2, x) = ( data & 0x04 ) ? 3 : 0;
1539                  state->m_bitmap.pix16(y + 3, x) = ( data & 0x08 ) ? 3 : 0;
1540                  state->m_bitmap.pix16(y + 4, x) = ( data & 0x10 ) ? 3 : 0;
1541                  state->m_bitmap.pix16(y + 5, x) = ( data & 0x20 ) ? 3 : 0;
1542                  state->m_bitmap.pix16(y + 6, x) = ( data & 0x40 ) ? 3 : 0;
1543                  state->m_bitmap.pix16(y + 7, x) = ( data & 0x80 ) ? 3 : 0;
1527                  m_bitmap.pix16(y + 0, x) = ( data & 0x01 ) ? 3 : 0;
1528                  m_bitmap.pix16(y + 1, x) = ( data & 0x02 ) ? 3 : 0;
1529                  m_bitmap.pix16(y + 2, x) = ( data & 0x04 ) ? 3 : 0;
1530                  m_bitmap.pix16(y + 3, x) = ( data & 0x08 ) ? 3 : 0;
1531                  m_bitmap.pix16(y + 4, x) = ( data & 0x10 ) ? 3 : 0;
1532                  m_bitmap.pix16(y + 5, x) = ( data & 0x20 ) ? 3 : 0;
1533                  m_bitmap.pix16(y + 6, x) = ( data & 0x40 ) ? 3 : 0;
1534                  m_bitmap.pix16(y + 7, x) = ( data & 0x80 ) ? 3 : 0;
15441535               }
15451536            }
15461537
15471538            /* Set PRC Copy interrupt */
1548            state->m_pm_reg[0x27] |= 0x80;
1549            pokemini_check_irqs( machine );
1539            m_pm_reg[0x27] |= 0x80;
1540            pokemini_check_irqs( machine() );
15501541         }
15511542      }
15521543
15531544      /* Set possible input irqs */
1554      state->m_pm_reg[0x29] |= ~ machine.root_device().ioport( "INPUTS" )->read();
1545      m_pm_reg[0x29] |= ~ machine().root_device().ioport( "INPUTS" )->read();
15551546   }
15561547}
15571548
r18113r18114
15641555   memset( m_pm_reg, 0, sizeof(m_pm_reg) );
15651556
15661557   /* Set up timers */
1567   m_timers.seconds_timer = machine().scheduler().timer_alloc(FUNC(pokemini_seconds_timer_callback));
1558   m_timers.seconds_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_seconds_timer_callback),this));
15681559   m_timers.seconds_timer->adjust( attotime::zero, 0, attotime::from_seconds( 1 ) );
15691560
1570   m_timers.hz256_timer = machine().scheduler().timer_alloc(FUNC(pokemini_256hz_timer_callback));
1561   m_timers.hz256_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_256hz_timer_callback),this));
15711562   m_timers.hz256_timer->adjust( attotime::zero, 0, attotime::from_hz( 256 ) );
15721563
1573   m_timers.timer1 = machine().scheduler().timer_alloc(FUNC(pokemini_timer1_callback));
1574   m_timers.timer1_hi = machine().scheduler().timer_alloc(FUNC(pokemini_timer1_hi_callback));
1575   m_timers.timer2 = machine().scheduler().timer_alloc(FUNC(pokemini_timer2_callback));
1576   m_timers.timer2_hi = machine().scheduler().timer_alloc(FUNC(pokemini_timer2_hi_callback));
1577   m_timers.timer3 = machine().scheduler().timer_alloc(FUNC(pokemini_timer3_callback));
1578   m_timers.timer3_hi = machine().scheduler().timer_alloc(FUNC(pokemini_timer3_hi_callback));
1564   m_timers.timer1 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_timer1_callback),this));
1565   m_timers.timer1_hi = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_timer1_hi_callback),this));
1566   m_timers.timer2 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_timer2_callback),this));
1567   m_timers.timer2_hi = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_timer2_hi_callback),this));
1568   m_timers.timer3 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_timer3_callback),this));
1569   m_timers.timer3_hi = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_timer3_hi_callback),this));
15791570
15801571   /* Set up the PRC */
15811572   m_prc.max_frame_count = 2;
1582   m_prc.count_timer = machine().scheduler().timer_alloc(FUNC(pokemini_prc_counter_callback));
1573   m_prc.count_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_prc_counter_callback),this));
15831574   m_prc.count_timer->adjust( attotime::zero, 0, m_maincpu->cycles_to_attotime(55640 / 65) );
15841575}
15851576
trunk/src/mess/machine/zx.c
r18113r18114
9090   m_tape_bit = 0x80;
9191}
9292
93static TIMER_CALLBACK(zx_tape_pulse)
93TIMER_CALLBACK_MEMBER(zx_state::zx_tape_pulse)
9494{
95   zx_state *state = machine.driver_data<zx_state>();
96   state->m_tape_bit = 0x80;
95   m_tape_bit = 0x80;
9796}
9897
9998READ8_MEMBER( zx_state::zx80_io_r )
r18113r18114
138137         if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit)
139138         {
140139            m_tape_bit = 0x00;
141            machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse));
140            machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this));
142141         }
143142
144143         data &= ~m_tape_bit;
r18113r18114
195194         if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit)
196195         {
197196            m_tape_bit = 0x00;
198            machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse));
197            machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this));
199198         }
200199
201200         data &= ~m_tape_bit;
r18113r18114
259258         if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit)
260259         {
261260            m_tape_bit = 0x00;
262            machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse));
261            machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this));
263262         }
264263
265264         data &= ~m_tape_bit;
r18113r18114
328327         if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit)
329328         {
330329            m_tape_bit = 0x00;
331            machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse));
330            machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this));
332331         }
333332
334333         data &= ~m_tape_bit;
trunk/src/mess/machine/pce.c
r18113r18114
103103/* prototypes */
104104static void pce_cd_init( running_machine &machine );
105105static void pce_cd_set_irq_line( running_machine &machine, int num, int state );
106static TIMER_CALLBACK( pce_cd_adpcm_dma_timer_callback );
107static TIMER_CALLBACK( pce_cd_cdda_fadeout_callback );
108static TIMER_CALLBACK( pce_cd_cdda_fadein_callback );
109static TIMER_CALLBACK( pce_cd_adpcm_fadeout_callback );
110static TIMER_CALLBACK( pce_cd_adpcm_fadein_callback );
111106
107
108
109
110
111
112112WRITE8_MEMBER(pce_state::pce_sf2_banking_w)
113113{
114114   membank( "bank2" )->set_base( memregion("user1")->base() + offset * 0x080000 + 0x080000 );
r18113r18114
11181118   }
11191119}
11201120
1121static TIMER_CALLBACK( pce_cd_data_timer_callback )
1121TIMER_CALLBACK_MEMBER(pce_state::pce_cd_data_timer_callback)
11221122{
1123   pce_state *state = machine.driver_data<pce_state>();
1124   pce_cd_t &pce_cd = state->m_cd;
1123   pce_cd_t &pce_cd = m_cd;
11251124   if ( pce_cd.data_buffer_index == pce_cd.data_buffer_size )
11261125   {
11271126      /* Read next data sector */
r18113r18114
12081207      }
12091208   }
12101209
1211   pce_cd.data_timer = machine.scheduler().timer_alloc(FUNC(pce_cd_data_timer_callback));
1210   pce_cd.data_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pce_state::pce_cd_data_timer_callback),state));
12121211   pce_cd.data_timer->adjust(attotime::never);
1213   pce_cd.adpcm_dma_timer = machine.scheduler().timer_alloc(FUNC(pce_cd_adpcm_dma_timer_callback));
1212   pce_cd.adpcm_dma_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pce_state::pce_cd_adpcm_dma_timer_callback),state));
12141213   pce_cd.adpcm_dma_timer->adjust(attotime::never);
12151214
1216   pce_cd.cdda_fadeout_timer = machine.scheduler().timer_alloc(FUNC(pce_cd_cdda_fadeout_callback));
1215   pce_cd.cdda_fadeout_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pce_state::pce_cd_cdda_fadeout_callback),state));
12171216   pce_cd.cdda_fadeout_timer->adjust(attotime::never);
1218   pce_cd.cdda_fadein_timer = machine.scheduler().timer_alloc(FUNC(pce_cd_cdda_fadein_callback));
1217   pce_cd.cdda_fadein_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pce_state::pce_cd_cdda_fadein_callback),state));
12191218   pce_cd.cdda_fadein_timer->adjust(attotime::never);
12201219
1221   pce_cd.adpcm_fadeout_timer = machine.scheduler().timer_alloc(FUNC(pce_cd_adpcm_fadeout_callback));
1220   pce_cd.adpcm_fadeout_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pce_state::pce_cd_adpcm_fadeout_callback),state));
12221221   pce_cd.adpcm_fadeout_timer->adjust(attotime::never);
1223   pce_cd.adpcm_fadein_timer = machine.scheduler().timer_alloc(FUNC(pce_cd_adpcm_fadein_callback));
1222   pce_cd.adpcm_fadein_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pce_state::pce_cd_adpcm_fadein_callback),state));
12241223   pce_cd.adpcm_fadein_timer->adjust(attotime::never);
12251224}
12261225
r18113r18114
12491248   }
12501249}
12511250
1252static TIMER_CALLBACK( pce_cd_cdda_fadeout_callback )
1251TIMER_CALLBACK_MEMBER(pce_state::pce_cd_cdda_fadeout_callback)
12531252{
1254   pce_state *state = machine.driver_data<pce_state>();
1255   pce_cd_t &pce_cd = state->m_cd;
1253   pce_cd_t &pce_cd = m_cd;
12561254   pce_cd.cdda_volume-= 0.1;
12571255
12581256   if(pce_cd.cdda_volume <= 0)
12591257   {
12601258      pce_cd.cdda_volume = 0.0;
1261      cdda_set_volume(machine.device("cdda"), 0.0);
1259      cdda_set_volume(machine().device("cdda"), 0.0);
12621260      pce_cd.cdda_fadeout_timer->adjust(attotime::never);
12631261   }
12641262   else
12651263   {
1266      cdda_set_volume(machine.device("cdda"), pce_cd.cdda_volume);
1264      cdda_set_volume(machine().device("cdda"), pce_cd.cdda_volume);
12671265      pce_cd.cdda_fadeout_timer->adjust(attotime::from_usec(param), param);
12681266   }
12691267}
12701268
1271static TIMER_CALLBACK( pce_cd_cdda_fadein_callback )
1269TIMER_CALLBACK_MEMBER(pce_state::pce_cd_cdda_fadein_callback)
12721270{
1273   pce_state *state = machine.driver_data<pce_state>();
1274   pce_cd_t &pce_cd = state->m_cd;
1271   pce_cd_t &pce_cd = m_cd;
12751272   pce_cd.cdda_volume+= 0.1;
12761273
12771274   if(pce_cd.cdda_volume >= 100.0)
12781275   {
12791276      pce_cd.cdda_volume = 100.0;
1280      cdda_set_volume(machine.device("cdda"), 100.0);
1277      cdda_set_volume(machine().device("cdda"), 100.0);
12811278      pce_cd.cdda_fadein_timer->adjust(attotime::never);
12821279   }
12831280   else
12841281   {
1285      cdda_set_volume(machine.device("cdda"), pce_cd.cdda_volume);
1282      cdda_set_volume(machine().device("cdda"), pce_cd.cdda_volume);
12861283      pce_cd.cdda_fadein_timer->adjust(attotime::from_usec(param), param);
12871284   }
12881285}
12891286
1290static TIMER_CALLBACK( pce_cd_adpcm_fadeout_callback )
1287TIMER_CALLBACK_MEMBER(pce_state::pce_cd_adpcm_fadeout_callback)
12911288{
1292   pce_state *state = machine.driver_data<pce_state>();
1293   pce_cd_t &pce_cd = state->m_cd;
1289   pce_cd_t &pce_cd = m_cd;
12941290   pce_cd.adpcm_volume-= 0.1;
12951291
12961292   if(pce_cd.adpcm_volume <= 0)
12971293   {
12981294      pce_cd.adpcm_volume = 0.0;
1299      msm5205_set_volume(machine.device("msm5205"), 0.0);
1295      msm5205_set_volume(machine().device("msm5205"), 0.0);
13001296      pce_cd.adpcm_fadeout_timer->adjust(attotime::never);
13011297   }
13021298   else
13031299   {
1304      msm5205_set_volume(machine.device("msm5205"), pce_cd.adpcm_volume);
1300      msm5205_set_volume(machine().device("msm5205"), pce_cd.adpcm_volume);
13051301      pce_cd.adpcm_fadeout_timer->adjust(attotime::from_usec(param), param);
13061302   }
13071303}
13081304
1309static TIMER_CALLBACK( pce_cd_adpcm_fadein_callback )
1305TIMER_CALLBACK_MEMBER(pce_state::pce_cd_adpcm_fadein_callback)
13101306{
1311   pce_state *state = machine.driver_data<pce_state>();
1312   pce_cd_t &pce_cd = state->m_cd;
1307   pce_cd_t &pce_cd = m_cd;
13131308   pce_cd.adpcm_volume+= 0.1;
13141309
13151310   if(pce_cd.adpcm_volume >= 100.0)
13161311   {
13171312      pce_cd.adpcm_volume = 100.0;
1318      msm5205_set_volume(machine.device("msm5205"), 100.0);
1313      msm5205_set_volume(machine().device("msm5205"), 100.0);
13191314      pce_cd.adpcm_fadein_timer->adjust(attotime::never);
13201315   }
13211316   else
13221317   {
1323      msm5205_set_volume(machine.device("msm5205"), pce_cd.adpcm_volume);
1318      msm5205_set_volume(machine().device("msm5205"), pce_cd.adpcm_volume);
13241319      pce_cd.adpcm_fadein_timer->adjust(attotime::from_usec(param), param);
13251320   }
13261321}
r18113r18114
15151510   pce_cd_update(machine());
15161511}
15171512
1518static TIMER_CALLBACK( pce_cd_clear_ack )
1513TIMER_CALLBACK_MEMBER(pce_state::pce_cd_clear_ack)
15191514{
1520   pce_state *state = machine.driver_data<pce_state>();
1521   pce_cd_t &pce_cd = state->m_cd;
1522   pce_cd_update(machine);
1515   pce_cd_t &pce_cd = m_cd;
1516   pce_cd_update(machine());
15231517   pce_cd.scsi_ACK = 0;
1524   pce_cd_update(machine);
1518   pce_cd_update(machine());
15251519   if ( pce_cd.scsi_CD )
15261520   {
15271521      pce_cd.regs[0x0B] &= 0xFE;
r18113r18114
15381532      if ( pce_cd.scsi_IO )
15391533      {
15401534         pce_cd.scsi_ACK = 1;
1541         machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(15), FUNC(pce_cd_clear_ack));
1535         machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(15), timer_expired_delegate(FUNC(pce_state::pce_cd_clear_ack),state));
15421536      }
15431537   }
15441538   return data;
15451539}
15461540
15471541
1548static TIMER_CALLBACK( pce_cd_adpcm_dma_timer_callback )
1542TIMER_CALLBACK_MEMBER(pce_state::pce_cd_adpcm_dma_timer_callback)
15491543{
1550   pce_state *state = machine.driver_data<pce_state>();
1551   pce_cd_t &pce_cd = state->m_cd;
1544   pce_cd_t &pce_cd = m_cd;
15521545   if ( pce_cd.scsi_REQ && ! pce_cd.scsi_ACK && ! pce_cd.scsi_CD && pce_cd.scsi_IO  )
15531546   {
1554      pce_cd.adpcm_ram[pce_cd.adpcm_write_ptr] = pce_cd_get_cd_data_byte(machine);
1547      pce_cd.adpcm_ram[pce_cd.adpcm_write_ptr] = pce_cd_get_cd_data_byte(machine());
15551548      pce_cd.adpcm_write_ptr = ( pce_cd.adpcm_write_ptr + 1 ) & 0xFFFF;
15561549
15571550      pce_cd.regs[0x0c] &= ~4;
trunk/src/mess/machine/bbc.c
r18113r18114
13141314   state->m_mc6850_clock = new_clock;
13151315}
13161316
1317static TIMER_CALLBACK(bbc_tape_timer_cb)
1317TIMER_CALLBACK_MEMBER(bbc_state::bbc_tape_timer_cb)
13181318{
1319   bbc_state *state = machine.driver_data<bbc_state>();
13201319
13211320   double dev_val;
1322   dev_val=machine.device<cassette_image_device>(CASSETTE_TAG)->input();
1321   dev_val=machine().device<cassette_image_device>(CASSETTE_TAG)->input();
13231322
13241323   // look for rising edges on the cassette wave
1325   if (((dev_val>=0.0) && (state->m_last_dev_val<0.0)) || ((dev_val<0.0) && (state->m_last_dev_val>=0.0)))
1324   if (((dev_val>=0.0) && (m_last_dev_val<0.0)) || ((dev_val<0.0) && (m_last_dev_val>=0.0)))
13261325   {
1327      if (state->m_wav_len>(9*3))
1326      if (m_wav_len>(9*3))
13281327      {
13291328         //this is to long to recive anything so reset the serial IC. This is a hack, this should be done as a timer in the MC6850 code.
1330         logerror ("Cassette length %d\n",state->m_wav_len);
1331         state->m_len0=0;
1332         state->m_len1=0;
1333         state->m_len2=0;
1334         state->m_len3=0;
1335         state->m_wav_len=0;
1329         logerror ("Cassette length %d\n",m_wav_len);
1330         m_len0=0;
1331         m_len1=0;
1332         m_len2=0;
1333         m_len3=0;
1334         m_wav_len=0;
13361335
13371336      }
13381337
1339      state->m_len3=state->m_len2;
1340      state->m_len2=state->m_len1;
1341      state->m_len1=state->m_len0;
1342      state->m_len0=state->m_wav_len;
1338      m_len3=m_len2;
1339      m_len2=m_len1;
1340      m_len1=m_len0;
1341      m_len0=m_wav_len;
13431342
1344      state->m_wav_len=0;
1345      logerror ("cassette  %d  %d  %d  %d\n",state->m_len3,state->m_len2,state->m_len1,state->m_len0);
1343      m_wav_len=0;
1344      logerror ("cassette  %d  %d  %d  %d\n",m_len3,m_len2,m_len1,m_len0);
13461345
1347      if ((state->m_len0+state->m_len1)>=(18+18-5))
1346      if ((m_len0+m_len1)>=(18+18-5))
13481347      {
13491348         /* Clock a 0 onto the serial line */
13501349         logerror("Serial value 0\n");
1351         MC6850_Receive_Clock(machine, 0);
1352         state->m_len0=0;
1353         state->m_len1=0;
1354         state->m_len2=0;
1355         state->m_len3=0;
1350         MC6850_Receive_Clock(machine(), 0);
1351         m_len0=0;
1352         m_len1=0;
1353         m_len2=0;
1354         m_len3=0;
13561355      }
13571356
1358      if (((state->m_len0+state->m_len1+state->m_len2+state->m_len3)<=41) && (state->m_len3!=0))
1357      if (((m_len0+m_len1+m_len2+m_len3)<=41) && (m_len3!=0))
13591358      {
13601359         /* Clock a 1 onto the serial line */
13611360         logerror("Serial value 1\n");
1362         MC6850_Receive_Clock(machine, 1);
1363         state->m_len0=0;
1364         state->m_len1=0;
1365         state->m_len2=0;
1366         state->m_len3=0;
1361         MC6850_Receive_Clock(machine(), 1);
1362         m_len0=0;
1363         m_len1=0;
1364         m_len2=0;
1365         m_len3=0;
13671366      }
13681367
13691368
13701369   }
13711370
1372   state->m_wav_len++;
1373   state->m_last_dev_val=dev_val;
1371   m_wav_len++;
1372   m_last_dev_val=dev_val;
13741373
13751374}
13761375
r18113r18114
19871986DRIVER_INIT_MEMBER(bbc_state,bbc)
19881987{
19891988   m_Master=0;
1990   m_tape_timer = machine().scheduler().timer_alloc(FUNC(bbc_tape_timer_cb));
1989   m_tape_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(bbc_state::bbc_tape_timer_cb),this));
19911990}
19921991DRIVER_INIT_MEMBER(bbc_state,bbcm)
19931992{
19941993   m_Master=1;
1995   m_tape_timer = machine().scheduler().timer_alloc(FUNC(bbc_tape_timer_cb));
1994   m_tape_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(bbc_state::bbc_tape_timer_cb),this));
19961995}
19971996
19981997MACHINE_START_MEMBER(bbc_state,bbca)
trunk/src/mess/machine/hec2hrp.c
r18113r18114
100100}
101101
102102/* Cassette timer*/
103static TIMER_CALLBACK( Callback_CK )
103TIMER_CALLBACK_MEMBER(hec2hrp_state::Callback_CK)
104104{
105   hec2hrp_state *state = machine.driver_data<hec2hrp_state>();
106105/* To generate the CK signal (K7)*/
107   state->m_CK_signal++;
106   m_CK_signal++;
108107}
109108
110109void hector_minidisc_init(running_machine &machine)
r18113r18114
891890   state->m_pot0 = state->m_pot1 = 0x40;
892891
893892   /* For Cassette synchro*/
894   state->m_Cassette_timer = machine.scheduler().timer_alloc(FUNC(Callback_CK));
893   state->m_Cassette_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(hec2hrp_state::Callback_CK),state));
895894   state->m_Cassette_timer->adjust(attotime::from_msec(100), 0, attotime::from_usec(64));/* => real synchro scan speed for 15,624Khz*/
896895
897896   /* Sound sn76477*/
trunk/src/mess/machine/electron.c
r18113r18114
4141#define TAPE_LOW   0x00;
4242#define TAPE_HIGH   0xFF;
4343
44static TIMER_CALLBACK(electron_tape_timer_handler)
44TIMER_CALLBACK_MEMBER(electron_state::electron_tape_timer_handler)
4545{
46   electron_state *state = machine.driver_data<electron_state>();
47   if ( state->m_ula.cassette_motor_mode )
46   if ( m_ula.cassette_motor_mode )
4847   {
4948      double tap_val;
50      tap_val = cassette_device_image(machine)->input();
49      tap_val = cassette_device_image(machine())->input();
5150      if ( tap_val < -0.5 )
5251      {
53         state->m_ula.tape_value = ( state->m_ula.tape_value << 8 ) | TAPE_LOW;
54         state->m_ula.tape_steps++;
52         m_ula.tape_value = ( m_ula.tape_value << 8 ) | TAPE_LOW;
53         m_ula.tape_steps++;
5554      }
5655      else if ( tap_val > 0.5 )
5756      {
58         state->m_ula.tape_value = ( state->m_ula.tape_value << 8 ) | TAPE_HIGH;
59         state->m_ula.tape_steps++;
57         m_ula.tape_value = ( m_ula.tape_value << 8 ) | TAPE_HIGH;
58         m_ula.tape_steps++;
6059      }
6160      else
6261      {
63         state->m_ula.tape_steps = 0;
64         state->m_ula.bit_count = 0;
65         state->m_ula.high_tone_set = 0;
66         state->m_ula.tape_value = 0x80808080;
62         m_ula.tape_steps = 0;
63         m_ula.bit_count = 0;
64         m_ula.high_tone_set = 0;
65         m_ula.tape_value = 0x80808080;
6766      }
68      if ( state->m_ula.tape_steps > 2 && ( state->m_ula.tape_value == 0x0000FFFF || state->m_ula.tape_value == 0x00FF00FF ) )
67      if ( m_ula.tape_steps > 2 && ( m_ula.tape_value == 0x0000FFFF || m_ula.tape_value == 0x00FF00FF ) )
6968      {
70         state->m_ula.tape_steps = 0;
71         switch( state->m_ula.bit_count )
69         m_ula.tape_steps = 0;
70         switch( m_ula.bit_count )
7271         {
7372         case 0:   /* start bit */
74            state->m_ula.start_bit = ( ( state->m_ula.tape_value == 0x0000FFFF ) ? 0 : 1 );
75            //logerror( "++ Read start bit: %d\n", state->m_ula.start_bit );
76            if ( state->m_ula.start_bit )
73            m_ula.start_bit = ( ( m_ula.tape_value == 0x0000FFFF ) ? 0 : 1 );
74            //logerror( "++ Read start bit: %d\n", m_ula.start_bit );
75            if ( m_ula.start_bit )
7776            {
78               if ( state->m_ula.high_tone_set )
77               if ( m_ula.high_tone_set )
7978               {
80                  state->m_ula.bit_count--;
79                  m_ula.bit_count--;
8180               }
8281            }
8382            else
8483            {
85               state->m_ula.high_tone_set = 0;
84               m_ula.high_tone_set = 0;
8685            }
8786            break;
8887         case 1: case 2: case 3: case 4:
8988         case 5: case 6: case 7: case 8:
90            //logerror( "++ Read regular bit: %d\n", state->m_ula.tape_value == 0x0000FFFF ? 0 : 1 );
91            state->m_ula.tape_byte = ( state->m_ula.tape_byte >> 1 ) | ( state->m_ula.tape_value == 0x0000FFFF ? 0 : 0x80 );
89            //logerror( "++ Read regular bit: %d\n", m_ula.tape_value == 0x0000FFFF ? 0 : 1 );
90            m_ula.tape_byte = ( m_ula.tape_byte >> 1 ) | ( m_ula.tape_value == 0x0000FFFF ? 0 : 0x80 );
9291            break;
9392         case 9: /* stop bit */
94            state->m_ula.stop_bit = ( ( state->m_ula.tape_value == 0x0000FFFF ) ? 0 : 1 );
95            //logerror( "++ Read stop bit: %d\n", state->m_ula.stop_bit );
96            if ( state->m_ula.start_bit && state->m_ula.stop_bit && state->m_ula.tape_byte == 0xFF && ! state->m_ula.high_tone_set )
93            m_ula.stop_bit = ( ( m_ula.tape_value == 0x0000FFFF ) ? 0 : 1 );
94            //logerror( "++ Read stop bit: %d\n", m_ula.stop_bit );
95            if ( m_ula.start_bit && m_ula.stop_bit && m_ula.tape_byte == 0xFF && ! m_ula.high_tone_set )
9796            {
98               electron_interrupt_handler( machine, INT_SET, INT_HIGH_TONE );
99               state->m_ula.high_tone_set = 1;
97               electron_interrupt_handler( machine(), INT_SET, INT_HIGH_TONE );
98               m_ula.high_tone_set = 1;
10099            }
101            else if ( ! state->m_ula.start_bit && state->m_ula.stop_bit )
100            else if ( ! m_ula.start_bit && m_ula.stop_bit )
102101            {
103               //logerror( "-- Byte read from tape: %02x\n", state->m_ula.tape_byte );
104               electron_interrupt_handler( machine, INT_SET, INT_RECEIVE_FULL );
102               //logerror( "-- Byte read from tape: %02x\n", m_ula.tape_byte );
103               electron_interrupt_handler( machine(), INT_SET, INT_RECEIVE_FULL );
105104            }
106105            else
107106            {
108               logerror( "Invalid start/stop bit combination detected: %d,%d\n", state->m_ula.start_bit, state->m_ula.stop_bit );
107               logerror( "Invalid start/stop bit combination detected: %d,%d\n", m_ula.start_bit, m_ula.stop_bit );
109108            }
110109            break;
111110         }
112         state->m_ula.bit_count = ( state->m_ula.bit_count + 1 ) % 10;
111         m_ula.bit_count = ( m_ula.bit_count + 1 ) % 10;
113112      }
114113   }
115114}
r18113r18114
315314   Machine Initialisation functions
316315***************************************/
317316
318static TIMER_CALLBACK(setup_beep)
317TIMER_CALLBACK_MEMBER(electron_state::setup_beep)
319318{
320   device_t *speaker = machine.device(BEEPER_TAG);
319   device_t *speaker = machine().device(BEEPER_TAG);
321320   beep_set_state( speaker, 0 );
322321   beep_set_frequency( speaker, 300 );
323322}
r18113r18114
346345
347346   m_ula.interrupt_status = 0x82;
348347   m_ula.interrupt_control = 0x00;
349   machine().scheduler().timer_set(attotime::zero, FUNC(setup_beep));
350   m_tape_timer = machine().scheduler().timer_alloc(FUNC(electron_tape_timer_handler));
348   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(electron_state::setup_beep),this));
349   m_tape_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(electron_state::electron_tape_timer_handler),this));
351350   machine().add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(electron_reset),&machine()));
352351}
353352
trunk/src/mess/machine/mikro80.c
r18113r18114
6969};
7070
7171
72static TIMER_CALLBACK( mikro80_reset )
72TIMER_CALLBACK_MEMBER(mikro80_state::mikro80_reset)
7373{
74   mikro80_state *state = machine.driver_data<mikro80_state>();
75   state->membank("bank1")->set_entry(0);
74   membank("bank1")->set_entry(0);
7675}
7776
7877void mikro80_state::machine_reset()
7978{
80   machine().scheduler().timer_set(attotime::from_usec(10), FUNC(mikro80_reset));
79   machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(mikro80_state::mikro80_reset),this));
8180   membank("bank1")->set_entry(1);
8281   m_keyboard_mask = 0;
8382}
trunk/src/mess/machine/microtan.c
r18113r18114
333333   DEVCB_LINE(via_1_irq)
334334};
335335
336static TIMER_CALLBACK(microtan_read_cassette)
336TIMER_CALLBACK_MEMBER(microtan_state::microtan_read_cassette)
337337{
338   double level = (cassette_device_image(machine))->input();
339   via6522_device *via_0 = machine.device<via6522_device>("via6522_0");
338   double level = (cassette_device_image(machine()))->input();
339   via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
340340
341341   LOG(("microtan_read_cassette: %g\n", level));
342342   if (level < -0.07)
r18113r18114
382382
383383
384384/* This callback is called one clock cycle after BFF2 is written (delayed nmi) */
385static TIMER_CALLBACK(microtan_pulse_nmi)
385TIMER_CALLBACK_MEMBER(microtan_state::microtan_pulse_nmi)
386386{
387    machine.device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
387    machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
388388}
389389
390390WRITE8_MEMBER(microtan_state::microtan_bffx_w)
r18113r18114
400400        break;
401401    case 1: /* BFF1: write delayed NMI */
402402        LOG(("microtan_bff1_w: %d <- %02x (delayed NMI)\n", offset, data));
403        machine().scheduler().timer_set(machine().device<cpu_device>("maincpu")->cycles_to_attotime(8), FUNC(microtan_pulse_nmi));
403        machine().scheduler().timer_set(machine().device<cpu_device>("maincpu")->cycles_to_attotime(8), timer_expired_delegate(FUNC(microtan_state::microtan_pulse_nmi),this));
404404        break;
405405    case 2: /* BFF2: write keypad column write (what is this meant for?) */
406406        LOG(("microtan_bff2_w: %d <- %02x (keypad column)\n", offset, data));
r18113r18114
566566            break;
567567    }
568568
569   m_timer = machine().scheduler().timer_alloc(FUNC(microtan_read_cassette));
569   m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(microtan_state::microtan_read_cassette),this));
570570}
571571
572572void microtan_state::machine_reset()
trunk/src/mess/machine/compis.c
r18113r18114
596596 *
597597 *************************************/
598598
599static TIMER_CALLBACK(internal_timer_int)
599TIMER_CALLBACK_MEMBER(compis_state::internal_timer_int)
600600{
601   compis_state *state = machine.driver_data<compis_state>();
602601   int which = param;
603   struct timer_state *t = &state->m_i186.timer[which];
602   struct timer_state *t = &m_i186.timer[which];
604603
605604   if (LOG_TIMER) logerror("Hit interrupt callback for timer %d\n", which);
606605
r18113r18114
610609   /* request an interrupt */
611610   if (t->control & 0x2000)
612611   {
613      state->m_i186.intr.status |= 0x01 << which;
614      update_interrupt_state(machine);
612      m_i186.intr.status |= 0x01 << which;
613      update_interrupt_state(machine());
615614      if (LOG_TIMER) logerror("  Generating timer interrupt\n");
616615   }
617616
r18113r18114
781780 *
782781 *************************************/
783782
784static TIMER_CALLBACK(dma_timer_callback)
783TIMER_CALLBACK_MEMBER(compis_state::dma_timer_callback)
785784{
786   compis_state *state = machine.driver_data<compis_state>();
787785   int which = param;
788   struct dma_state *d = &state->m_i186.dma[which];
786   struct dma_state *d = &m_i186.dma[which];
789787
790788   /* force an update and see if we're really done */
791789   //stream_update(dma_stream, 0);
r18113r18114
799797   if (d->control & 0x0100)
800798   {
801799      if (LOG_DMA) logerror("DMA%d timer callback - requesting interrupt: count = %04X, source = %04X\n", which, d->count, d->source);
802      state->m_i186.intr.request |= 0x04 << which;
803      update_interrupt_state(machine);
800      m_i186.intr.request |= 0x04 << which;
801      update_interrupt_state(machine());
804802   }
805803}
806804
r18113r18114
13011299{
13021300   compis_state *state = machine.driver_data<compis_state>();
13031301   /* create timers here so they stick around */
1304   state->m_i186.timer[0].int_timer = machine.scheduler().timer_alloc(FUNC(internal_timer_int));
1305   state->m_i186.timer[1].int_timer = machine.scheduler().timer_alloc(FUNC(internal_timer_int));
1306   state->m_i186.timer[2].int_timer = machine.scheduler().timer_alloc(FUNC(internal_timer_int));
1307   state->m_i186.timer[0].time_timer = machine.scheduler().timer_alloc(FUNC_NULL);
1308   state->m_i186.timer[1].time_timer = machine.scheduler().timer_alloc(FUNC_NULL);
1309   state->m_i186.timer[2].time_timer = machine.scheduler().timer_alloc(FUNC_NULL);
1310   state->m_i186.dma[0].finish_timer = machine.scheduler().timer_alloc(FUNC(dma_timer_callback));
1311   state->m_i186.dma[1].finish_timer = machine.scheduler().timer_alloc(FUNC(dma_timer_callback));
1302   state->m_i186.timer[0].int_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(compis_state::internal_timer_int),state));
1303   state->m_i186.timer[1].int_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(compis_state::internal_timer_int),state));
1304   state->m_i186.timer[2].int_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(compis_state::internal_timer_int),state));
1305   state->m_i186.timer[0].time_timer = machine.scheduler().timer_alloc(timer_expired_delegate());
1306   state->m_i186.timer[1].time_timer = machine.scheduler().timer_alloc(timer_expired_delegate());
1307   state->m_i186.timer[2].time_timer = machine.scheduler().timer_alloc(timer_expired_delegate());
1308   state->m_i186.dma[0].finish_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(compis_state::dma_timer_callback),state));
1309   state->m_i186.dma[1].finish_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(compis_state::dma_timer_callback),state));
13121310}
13131311
13141312/*-------------------------------------------------------------------------*/
trunk/src/mess/machine/pc1401.c
r18113r18114
124124   machine.device<nvram_device>("ram_nvram")->set_base(ram, 0x2800);
125125}
126126
127static TIMER_CALLBACK(pc1401_power_up)
127TIMER_CALLBACK_MEMBER(pc1401_state::pc1401_power_up)
128128{
129   pc1401_state *state = machine.driver_data<pc1401_state>();
130   state->m_power = 0;
129   m_power = 0;
131130}
132131
133132DRIVER_INIT_MEMBER(pc1401_state,pc1401)
r18113r18114
234233      gfx[i]=i;
235234
236235   m_power = 1;
237   machine().scheduler().timer_set(attotime::from_seconds(1), FUNC(pc1401_power_up));
236   machine().scheduler().timer_set(attotime::from_seconds(1), timer_expired_delegate(FUNC(pc1401_state::pc1401_power_up),this));
238237}
trunk/src/mess/machine/samcoupe.c
r18113r18114
178178    MOUSE
179179***************************************************************************/
180180
181static TIMER_CALLBACK( samcoupe_mouse_reset )
181TIMER_CALLBACK_MEMBER(samcoupe_state::samcoupe_mouse_reset)
182182{
183   samcoupe_state *state = machine.driver_data<samcoupe_state>();
184   state->m_mouse_index = 0;
183   m_mouse_index = 0;
185184}
186185
187186UINT8 samcoupe_mouse_r(running_machine &machine)
r18113r18114
231230
232231void samcoupe_state::machine_start()
233232{
234   m_mouse_reset = machine().scheduler().timer_alloc(FUNC(samcoupe_mouse_reset));
233   m_mouse_reset = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(samcoupe_state::samcoupe_mouse_reset),this));
235234
236235   /* schedule our video updates */
237   m_video_update_timer = machine().scheduler().timer_alloc(FUNC(sam_video_update_callback));
236   m_video_update_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(samcoupe_state::sam_video_update_callback),this));
238237   m_video_update_timer->adjust(machine().primary_screen->time_until_pos(0, 0));
239238}
240239
trunk/src/mess/machine/pet.c
r18113r18114
618618   }
619619}
620620
621static TIMER_CALLBACK( pet_interrupt )
621TIMER_CALLBACK_MEMBER(pet_state::pet_interrupt)
622622{
623   pet_state *state = machine.driver_data<pet_state>();
624   pia6821_device *pia_0 = machine.device<pia6821_device>("pia_0");
623   pia6821_device *pia_0 = machine().device<pia6821_device>("pia_0");
625624
626   pia_0->cb1_w(state->m_pia_level);
627   state->m_pia_level = !state->m_pia_level;
625   pia_0->cb1_w(m_pia_level);
626   m_pia_level = !m_pia_level;
628627}
629628
630629
631static TIMER_CALLBACK( pet_tape1_timer )
630TIMER_CALLBACK_MEMBER(pet_state::pet_tape1_timer)
632631{
633   pia6821_device *pia_0 = machine.device<pia6821_device>("pia_0");
632   pia6821_device *pia_0 = machine().device<pia6821_device>("pia_0");
634633//  cassette 1
635   UINT8 data = (machine.device<cassette_image_device>(CASSETTE_TAG)->input() > +0.0) ? 1 : 0;
634   UINT8 data = (machine().device<cassette_image_device>(CASSETTE_TAG)->input() > +0.0) ? 1 : 0;
636635   pia_0->ca1_w(data);
637636}
638637
639static TIMER_CALLBACK( pet_tape2_timer )
638TIMER_CALLBACK_MEMBER(pet_state::pet_tape2_timer)
640639{
641   via6522_device *via_0 = machine.device<via6522_device>("via6522_0");
640   via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
642641//  cassette 2
643   UINT8 data = (machine.device<cassette_image_device>(CASSETTE2_TAG)->input() > +0.0) ? 1 : 0;
642   UINT8 data = (machine().device<cassette_image_device>(CASSETTE2_TAG)->input() > +0.0) ? 1 : 0;
644643   via_0->write_cb1(data);
645644}
646645
r18113r18114
671670   }
672671
673672   /* pet clock */
674   machine.scheduler().timer_pulse(attotime::from_msec(10), FUNC(pet_interrupt));
673   machine.scheduler().timer_pulse(attotime::from_msec(10), timer_expired_delegate(FUNC(pet_state::pet_interrupt),state));
675674
676675   /* datasette */
677   state->m_datasette1_timer = machine.scheduler().timer_alloc(FUNC(pet_tape1_timer));
678   state->m_datasette2_timer = machine.scheduler().timer_alloc(FUNC(pet_tape2_timer));
676   state->m_datasette1_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pet_state::pet_tape1_timer),state));
677   state->m_datasette2_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pet_state::pet_tape2_timer),state));
679678}
680679
681680
trunk/src/mess/machine/sym1.c
r18113r18114
7373}
7474
7575
76static TIMER_CALLBACK( led_refresh )
76TIMER_CALLBACK_MEMBER(sym1_state::led_refresh)
7777{
78   sym1_state *state = machine.driver_data<sym1_state>();
79   output_set_digit_value(param, state->m_riot_port_a);
78   output_set_digit_value(param, m_riot_port_a);
8079}
8180
8281
r18113r18114
294293   }
295294
296295   /* allocate a timer to refresh the led display */
297   m_led_update = machine().scheduler().timer_alloc(FUNC(led_refresh));
296   m_led_update = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sym1_state::led_refresh),this));
298297}
299298
300299
trunk/src/mess/machine/pmd85.c
r18113r18114
787787};
788788
789789
790static TIMER_CALLBACK(pmd85_cassette_timer_callback)
790TIMER_CALLBACK_MEMBER(pmd85_state::pmd85_cassette_timer_callback)
791791{
792   pmd85_state *state = machine.driver_data<pmd85_state>();
793   i8251_device *uart = machine.device<i8251_device>("uart");
794   serial_source_device *ser = machine.device<serial_source_device>("sercas");
792   i8251_device *uart = machine().device<i8251_device>("uart");
793   serial_source_device *ser = machine().device<serial_source_device>("sercas");
795794   int data;
796795   int current_level;
797796
798   if (!(machine.root_device().ioport("DSW0")->read() & 0x02))   /* V.24 / Tape Switch */
797   if (!(machine().root_device().ioport("DSW0")->read() & 0x02))   /* V.24 / Tape Switch */
799798   {
800799      /* tape reading */
801      if (machine.device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_PLAY)
800      if (machine().device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_PLAY)
802801      {
803         switch (state->m_model)
802         switch (m_model)
804803         {
805804            case PMD85_1:
806               if (state->m_clk_level_tape)
805               if (m_clk_level_tape)
807806               {
808                  state->m_previous_level = ((machine.device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0;
809                  state->m_clk_level_tape = 0;
807                  m_previous_level = ((machine().device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0;
808                  m_clk_level_tape = 0;
810809               }
811810               else
812811               {
813                  current_level = ((machine.device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0;
812                  current_level = ((machine().device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0;
814813
815                  if (state->m_previous_level!=current_level)
814                  if (m_previous_level!=current_level)
816815                  {
817                     data = (!state->m_previous_level && current_level) ? 1 : 0;
816                     data = (!m_previous_level && current_level) ? 1 : 0;
818817
819818                     ser->send_bit(data);
820819                     uart->receive_clock();
821820
822                     state->m_clk_level_tape = 1;
821                     m_clk_level_tape = 1;
823822                  }
824823               }
825824               return;
r18113r18114
834833      }
835834
836835      /* tape writing */
837      if (machine.device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_RECORD)
836      if (machine().device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_RECORD)
838837      {
839838         data = ser->get_in_data_bit();
840         data ^= state->m_clk_level_tape;
841         machine.device<cassette_image_device>(CASSETTE_TAG)->output(data&0x01 ? 1 : -1);
839         data ^= m_clk_level_tape;
840         machine().device<cassette_image_device>(CASSETTE_TAG)->output(data&0x01 ? 1 : -1);
842841
843         if (!state->m_clk_level_tape)
842         if (!m_clk_level_tape)
844843            uart->transmit_clock();
845844
846         state->m_clk_level_tape = state->m_clk_level_tape ? 0 : 1;
845         m_clk_level_tape = m_clk_level_tape ? 0 : 1;
847846
848847         return;
849848      }
850849
851      state->m_clk_level_tape = 1;
850      m_clk_level_tape = 1;
852851
853      if (!state->m_clk_level)
852      if (!m_clk_level)
854853         uart->transmit_clock();
855      state->m_clk_level = state->m_clk_level ? 0 : 1;
854      m_clk_level = m_clk_level ? 0 : 1;
856855   }
857856}
858857
859static TIMER_CALLBACK( pmd_reset )
858TIMER_CALLBACK_MEMBER(pmd85_state::pmd_reset)
860859{
861   machine.schedule_soft_reset();
860   machine().schedule_soft_reset();
862861}
863862
864863DIRECT_UPDATE_MEMBER(pmd85_state::pmd85_opbaseoverride)
865864{
866865   if (ioport("RESET")->read() & 0x01)
867      machine().scheduler().timer_set(attotime::from_usec(10), FUNC(pmd_reset));
866      machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(pmd85_state::pmd_reset),this));
868867   return address;
869868}
870869
r18113r18114
873872   pmd85_state *state = machine.driver_data<pmd85_state>();
874873   state->m_previous_level = 0;
875874   state->m_clk_level = state->m_clk_level_tape = 1;
876   state->m_cassette_timer = machine.scheduler().timer_alloc(FUNC(pmd85_cassette_timer_callback));
875   state->m_cassette_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pmd85_state::pmd85_cassette_timer_callback),state));
877876   state->m_cassette_timer->adjust(attotime::zero, 0, attotime::from_hz(2400));
878877}
879878
r18113r18114
918917   pmd85_common_driver_init(machine());
919918}
920919
921static TIMER_CALLBACK( setup_machine_state )
920TIMER_CALLBACK_MEMBER(pmd85_state::setup_machine_state)
922921{
923   pmd85_state *state = machine.driver_data<pmd85_state>();
924   if (state->m_model != MATO)
922   if (m_model != MATO)
925923   {
926      i8251_device *uart = machine.device<i8251_device>("uart");
927      serial_source_device *ser = machine.device<serial_source_device>("sercas");
924      i8251_device *uart = machine().device<i8251_device>("uart");
925      serial_source_device *ser = machine().device<serial_source_device>("sercas");
928926      uart->connect(ser);
929927   }
930928}
r18113r18114
958956   m_startup_mem_map = 1;
959957   update_memory(machine());
960958
961   machine().scheduler().timer_set(attotime::zero, FUNC(setup_machine_state));
959   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(pmd85_state::setup_machine_state),this));
962960
963961   machine().device("maincpu")->memory().space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(pmd85_state::pmd85_opbaseoverride), this));
964962}
trunk/src/mess/machine/apple2gs.c
r18113r18114
294294
295295
296296/* Clock interrupt */
297static TIMER_CALLBACK( apple2gs_clock_tick )
297TIMER_CALLBACK_MEMBER(apple2gs_state::apple2gs_clock_tick)
298298{
299   apple2gs_state *state = machine.driver_data<apple2gs_state>();
300   if ((state->m_vgcint & 0x04) && !(state->m_vgcint & 0x40))
299   if ((m_vgcint & 0x04) && !(m_vgcint & 0x40))
301300   {
302      state->m_vgcint |= 0xc0;
303      apple2gs_add_irq(machine, IRQ_VGC_SECOND);
301      m_vgcint |= 0xc0;
302      apple2gs_add_irq(machine(), IRQ_VGC_SECOND);
304303   }
305304}
306305
307306
308307/* Quarter-second interrupt */
309static TIMER_CALLBACK( apple2gs_qsecond_tick )
308TIMER_CALLBACK_MEMBER(apple2gs_state::apple2gs_qsecond_tick)
310309{
311   apple2gs_state *state = machine.driver_data<apple2gs_state>();
312   if ((state->m_inten & 0x10) && !(state->m_intflag & 0x10))
310   if ((m_inten & 0x10) && !(m_intflag & 0x10))
313311   {
314      state->m_intflag |= 0x10;
315      apple2gs_add_irq(machine, IRQ_INTEN_QSECOND);
312      m_intflag |= 0x10;
313      apple2gs_add_irq(machine(), IRQ_INTEN_QSECOND);
316314   }
317315}
318316
r18113r18114
736734}
737735
738736
739static TIMER_CALLBACK(apple2gs_scanline_tick)
737TIMER_CALLBACK_MEMBER(apple2gs_state::apple2gs_scanline_tick)
740738{
741   apple2gs_state *state = machine.driver_data<apple2gs_state>();
742739   int scanline;
743740
744   scanline = machine.primary_screen->vpos();
745   machine.primary_screen->update_partial(scanline);
741   scanline = machine().primary_screen->vpos();
742   machine().primary_screen->update_partial(scanline);
746743
747744   /* check scanline interrupt bits if we're in super hi-res and the current scanline is within the active display area */
748   if ((state->m_newvideo & 0x80) && (scanline >= (BORDER_TOP-1)) && (scanline < (200+BORDER_TOP-1)))
745   if ((m_newvideo & 0x80) && (scanline >= (BORDER_TOP-1)) && (scanline < (200+BORDER_TOP-1)))
749746   {
750747      UINT8 scb;
751748
752      scb = state->m_slowmem[0x19D00 + scanline - BORDER_TOP + 1];
749      scb = m_slowmem[0x19D00 + scanline - BORDER_TOP + 1];
753750
754751      if (scb & 0x40)
755752      {
756753         // scanline int flag is set even when the actual interrupt is disabled
757         state->m_vgcint |= 0x20;
754         m_vgcint |= 0x20;
758755
759756         // see if the interrupt is also enabled and trigger it if so
760         if (state->m_vgcint & 0x02)
757         if (m_vgcint & 0x02)
761758         {
762            state->m_vgcint |= 0x80;
763            apple2gs_add_irq(machine, IRQ_VGC_SCANLINE);
759            m_vgcint |= 0x80;
760            apple2gs_add_irq(machine(), IRQ_VGC_SCANLINE);
764761         }
765762      }
766763   }
r18113r18114
768765   if (scanline == (192+BORDER_TOP))
769766   {
770767      /* VBL interrupt */
771      if ((state->m_inten & 0x08) && !(state->m_intflag & 0x08))
768      if ((m_inten & 0x08) && !(m_intflag & 0x08))
772769      {
773         state->m_intflag |= 0x08;
774         apple2gs_add_irq(machine, IRQ_INTEN_VBL);
770         m_intflag |= 0x08;
771         apple2gs_add_irq(machine(), IRQ_INTEN_VBL);
775772      }
776773   }
777774
778775   /* check the mouse status */
779776   if ((scanline % 8) == 0)
780777   {
781      adb_check_mouse(machine);
778      adb_check_mouse(machine());
782779
783780      /* call Apple II interrupt handler */
784      if ((machine.primary_screen->vpos() % 8) == 7)
781      if ((machine().primary_screen->vpos() % 8) == 7)
785782      {
786         //apple2_interrupt(machine.device("maincpu"));
783         //apple2_interrupt(machine().device("maincpu"));
787784         /* TODO: check me! */
788         machine.primary_screen->update_partial(machine.primary_screen->vpos());
785         machine().primary_screen->update_partial(machine().primary_screen->vpos());
789786      }
790787   }
791788
792   state->m_scanline_timer->adjust(machine.primary_screen->time_until_pos((scanline+1)%262, 0));
789   m_scanline_timer->adjust(machine().primary_screen->time_until_pos((scanline+1)%262, 0));
793790}
794791
795792
r18113r18114
19931990
19941991   state_save_register_item(machine(), "ECHOBANK", NULL,0, m_echo_bank);
19951992
1996   m_clock_timer = machine().scheduler().timer_alloc(FUNC(apple2gs_clock_tick));
1993   m_clock_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(apple2gs_state::apple2gs_clock_tick),this));
19971994   m_clock_timer->adjust(attotime::from_seconds(1), 0, attotime::from_seconds(1));
19981995
1999   m_qsecond_timer = machine().scheduler().timer_alloc(FUNC(apple2gs_qsecond_tick));
1996   m_qsecond_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(apple2gs_state::apple2gs_qsecond_tick),this));
20001997   m_qsecond_timer->adjust(attotime::from_usec(266700), 0, attotime::from_usec(266700));
20011998
2002   m_scanline_timer = machine().scheduler().timer_alloc(FUNC(apple2gs_scanline_tick));
1999   m_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(apple2gs_state::apple2gs_scanline_tick),this));
20032000   m_scanline_timer->adjust(attotime::never);
20042001
20052002   // fire on scanline zero
trunk/src/mess/includes/hp48.h
r18113r18114
7878   DECLARE_WRITE8_MEMBER(hp48_io_w);
7979   DECLARE_READ8_MEMBER(hp48_io_r);
8080   DECLARE_READ8_MEMBER(hp48_bank_r);
81   TIMER_CALLBACK_MEMBER(hp48_rs232_byte_recv_cb);
82   TIMER_CALLBACK_MEMBER(hp48_rs232_byte_sent_cb);
83   TIMER_CALLBACK_MEMBER(hp48_chardev_byte_recv_cb);
84   TIMER_CALLBACK_MEMBER(hp48_kbd_cb);
85   TIMER_CALLBACK_MEMBER(hp48_timer1_cb);
86   TIMER_CALLBACK_MEMBER(hp48_timer2_cb);
8187};
8288
8389
trunk/src/mess/includes/sorcerer.h
r18113r18114
8686   virtual void machine_start();
8787   virtual void machine_reset();
8888   DECLARE_MACHINE_START(sorcererd);
89   TIMER_CALLBACK_MEMBER(sorcerer_serial_tc);
90   TIMER_CALLBACK_MEMBER(sorcerer_cassette_tc);
91   TIMER_CALLBACK_MEMBER(sorcerer_reset);
8992};
9093
9194
trunk/src/mess/includes/pet.h
r18113r18114
5757   DECLARE_VIDEO_START(pet_crtc);
5858   UINT32 screen_update_pet(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5959   INTERRUPT_GEN_MEMBER(pet_frame_interrupt);
60   TIMER_CALLBACK_MEMBER(pet_interrupt);
61   TIMER_CALLBACK_MEMBER(pet_tape1_timer);
62   TIMER_CALLBACK_MEMBER(pet_tape2_timer);
6063};
6164
6265/*----------- defined in video/pet.c -----------*/
trunk/src/mess/includes/pcw.h
r18113r18114
101101   virtual void palette_init();
102102   UINT32 screen_update_pcw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
103103   UINT32 screen_update_pcw_printer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
104   TIMER_CALLBACK_MEMBER(pcw_timer_pulse);
105   TIMER_CALLBACK_MEMBER(pcw_stepper_callback);
106   TIMER_CALLBACK_MEMBER(pcw_pins_callback);
107   TIMER_CALLBACK_MEMBER(setup_beep);
104108};
105109
106110#endif /* PCW_H_ */
trunk/src/mess/includes/cgenie.h
r18113r18114
7373   UINT32 screen_update_cgenie(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7474   INTERRUPT_GEN_MEMBER(cgenie_timer_interrupt);
7575   INTERRUPT_GEN_MEMBER(cgenie_frame_interrupt);
76   TIMER_CALLBACK_MEMBER(handle_cassette_input);
7677};
7778
7879
trunk/src/mess/includes/osi.h
r18113r18114
6464
6565   /* floppy state */
6666   int m_fdc_index;
67   TIMER_CALLBACK_MEMBER(setup_beep);
6768};
6869
6970class c1p_state : public sb2m600_state
trunk/src/mess/includes/pc.h
r18113r18114
8686   DECLARE_MACHINE_START(pcjr);
8787   DECLARE_MACHINE_RESET(pcjr);
8888   DECLARE_MACHINE_START(mc1502);
89   TIMER_CALLBACK_MEMBER(pcjr_delayed_pic8259_irq);
90   TIMER_CALLBACK_MEMBER(pcjr_keyb_signal_callback);
91   TIMER_CALLBACK_MEMBER(mc1502_keyb_signal_callback);
92   TIMER_CALLBACK_MEMBER(pc_rtc_timer);
8993};
9094
9195/*----------- defined in machine/pc.c -----------*/
trunk/src/mess/includes/kaypro.h
r18113r18114
7979   UINT32 screen_update_kaypro2x(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
8080   UINT32 screen_update_omni2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8181   INTERRUPT_GEN_MEMBER(kay_kbd_interrupt);
82   TIMER_CALLBACK_MEMBER(kaypro_timer_callback);
8283};
8384
8485
trunk/src/mess/includes/mbee.h
r18113r18114
142142   DECLARE_MACHINE_RESET(mbeett);
143143   UINT32 screen_update_mbee(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
144144   INTERRUPT_GEN_MEMBER(mbee_interrupt);
145   TIMER_CALLBACK_MEMBER(mbee256_kbd);
146   TIMER_CALLBACK_MEMBER(mbee_rtc_irq);
147   TIMER_CALLBACK_MEMBER(mbee_reset);
145148};
146149
147150
trunk/src/mess/includes/sg1000.h
r18113r18114
7272
7373   /* TV Draw state */
7474   UINT8 m_tvdraw_data;
75   TIMER_CALLBACK_MEMBER(lightgun_tick);
7576};
7677
7778class sc3000_state : public sg1000_state
trunk/src/mess/includes/microtan.h
r18113r18114
5353   virtual void video_start();
5454   UINT32 screen_update_microtan(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5555   INTERRUPT_GEN_MEMBER(microtan_interrupt);
56   TIMER_CALLBACK_MEMBER(microtan_read_cassette);
57   TIMER_CALLBACK_MEMBER(microtan_pulse_nmi);
5658};
5759
5860
trunk/src/mess/includes/trs80.h
r18113r18114
124124   UINT32 screen_update_meritum(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
125125   INTERRUPT_GEN_MEMBER(trs80_rtc_interrupt);
126126   INTERRUPT_GEN_MEMBER(trs80_fdc_interrupt);
127   TIMER_CALLBACK_MEMBER(cassette_data_callback);
127128};
128129
129130
trunk/src/mess/includes/osborne1.h
r18113r18114
8282   DECLARE_DRIVER_INIT(osborne1);
8383   virtual void machine_reset();
8484   virtual void palette_init();
85   TIMER_CALLBACK_MEMBER(osborne1_video_callback);
86   TIMER_CALLBACK_MEMBER(setup_osborne1);
8587};
8688
8789
trunk/src/mess/includes/rmnimbus.h
r18113r18114
228228   virtual void palette_init();
229229   UINT32 screen_update_nimbus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
230230   void screen_eof_nimbus(screen_device &screen, bool state);
231   TIMER_CALLBACK_MEMBER(internal_timer_int);
232   TIMER_CALLBACK_MEMBER(dma_timer_callback);
233   TIMER_CALLBACK_MEMBER(keyscan_callback);
234   TIMER_CALLBACK_MEMBER(mouse_callback);
231235};
232236
233237
trunk/src/mess/includes/kc.h
r18113r18114
146146
147147   kcexp_slot_device *   m_expansions[3];
148148   DECLARE_PALETTE_INIT(kc85);
149   TIMER_CALLBACK_MEMBER(kc_cassette_oneshot_timer);
150   TIMER_CALLBACK_MEMBER(kc_cassette_timer_callback);
149151};
150152
151153
trunk/src/mess/includes/zx.h
r18113r18114
5858   DECLARE_MACHINE_RESET(pc8300);
5959   DECLARE_MACHINE_RESET(pow3000);
6060   void screen_eof_zx(screen_device &screen, bool state);
61   TIMER_CALLBACK_MEMBER(zx_tape_pulse);
62   TIMER_CALLBACK_MEMBER(zx_ula_nmi);
63   TIMER_CALLBACK_MEMBER(zx_ula_irq);
6164};
6265/*----------- defined in video/zx.c -----------*/
6366
trunk/src/mess/includes/pecom.h
r18113r18114
4040   virtual void machine_reset();
4141   DECLARE_VIDEO_START(pecom);
4242   DECLARE_INPUT_CHANGED_MEMBER(ef_w);
43   TIMER_CALLBACK_MEMBER(reset_tick);
4344};
4445
4546/*----------- defined in machine/pecom.c -----------*/
trunk/src/mess/includes/mbc55x.h
r18113r18114
157157   virtual void video_reset();
158158   virtual void palette_init();
159159   void screen_eof_mbc55x(screen_device &screen, bool state);
160   TIMER_CALLBACK_MEMBER(keyscan_callback);
160161};
161162
162163/* IO chips */
trunk/src/mess/includes/coleco.h
r18113r18114
4343   int m_joy_d7_state[2];
4444   UINT8 m_joy_analog_state[2];
4545   UINT8 m_joy_analog_reload[2];
46   TIMER_CALLBACK_MEMBER(paddle_d7reset_callback);
47   TIMER_CALLBACK_MEMBER(paddle_irqreset_callback);
48   TIMER_CALLBACK_MEMBER(paddle_pulse_callback);
4649};
4750
4851#endif
trunk/src/mess/includes/pc1403.h
r18113r18114
3030
3131   DECLARE_DRIVER_INIT(pc1403);
3232   UINT32 screen_update_pc1403(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
33   TIMER_CALLBACK_MEMBER(pc1403_power_up);
3334};
3435
3536
trunk/src/mess/includes/samcoupe.h
r18113r18114
8383   virtual void machine_reset();
8484   virtual void palette_init();
8585   INTERRUPT_GEN_MEMBER(samcoupe_frame_interrupt);
86   TIMER_CALLBACK_MEMBER(irq_off);
87   TIMER_CALLBACK_MEMBER(samcoupe_mouse_reset);
88   TIMER_CALLBACK_MEMBER(sam_video_update_callback);
8689};
8790
8891
trunk/src/mess/includes/irisha.h
r18113r18114
4747   virtual void machine_reset();
4848   virtual void video_start();
4949   UINT32 screen_update_irisha(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
50   TIMER_CALLBACK_MEMBER(irisha_key);
5051};
5152
5253
trunk/src/mess/includes/odyssey2.h
r18113r18114
115115   virtual void video_start();
116116   virtual void palette_init();
117117   UINT32 screen_update_odyssey2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
118   TIMER_CALLBACK_MEMBER(i824x_scanline_callback);
119   TIMER_CALLBACK_MEMBER(i824x_hblank_callback);
118120};
119121
120122
trunk/src/mess/includes/apple1.h
r18113r18114
4848   virtual void machine_reset();
4949   virtual void video_start();
5050   UINT32 screen_update_apple1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
51   TIMER_CALLBACK_MEMBER(apple1_kbd_poll);
52   TIMER_CALLBACK_MEMBER(apple1_kbd_strobe_end);
53   TIMER_CALLBACK_MEMBER(apple1_dsp_ready_start);
54   TIMER_CALLBACK_MEMBER(apple1_dsp_ready_end);
5155};
5256
5357
trunk/src/mess/includes/lisa.h
r18113r18114
165165   virtual void video_start();
166166   UINT32 screen_update_lisa(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
167167   INTERRUPT_GEN_MEMBER(lisa_interrupt);
168   TIMER_CALLBACK_MEMBER(handle_mouse);
169   TIMER_CALLBACK_MEMBER(read_COPS_command);
170   TIMER_CALLBACK_MEMBER(set_COPS_ready);
168171};
169172
170173
trunk/src/mess/includes/sym1.h
r18113r18114
4141   emu_timer *m_led_update;
4242   DECLARE_DRIVER_INIT(sym1);
4343   virtual void machine_reset();
44   TIMER_CALLBACK_MEMBER(led_refresh);
4445};
4546
4647/*----------- defined in machine/sym1.c -----------*/
trunk/src/mess/includes/lynx.h
r18113r18114
140140   virtual void machine_start();
141141   virtual void machine_reset();
142142   virtual void palette_init();
143   TIMER_CALLBACK_MEMBER(lynx_blitter_timer);
144   TIMER_CALLBACK_MEMBER(lynx_timer_shot);
145   TIMER_CALLBACK_MEMBER(lynx_uart_loopback_timer);
146   TIMER_CALLBACK_MEMBER(lynx_uart_timer);
143147};
144148
145149
trunk/src/mess/includes/wswan.h
r18113r18114
157157   virtual void palette_init();
158158   DECLARE_MACHINE_START(wscolor);
159159   DECLARE_PALETTE_INIT(wscolor);
160   TIMER_CALLBACK_MEMBER(wswan_rtc_callback);
161   TIMER_CALLBACK_MEMBER(wswan_scanline_interrupt);
160162};
161163
162164
trunk/src/mess/includes/xerox820.h
r18113r18114
8282   int m_fdc_drq;                  /* data request */
8383   int m_8n5;                     /* 5.25" / 8" drive select */
8484   int m_dsdd;                     /* double sided disk detect */
85   TIMER_CALLBACK_MEMBER(bigboard_beepoff);
8586};
8687
8788class xerox820ii_state : public xerox820_state
trunk/src/mess/includes/x68k.h
r18113r18114
268268   DECLARE_PALETTE_INIT(x68000);
269269   UINT32 screen_update_x68000(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
270270   INTERRUPT_GEN_MEMBER(x68k_vsync_irq);
271   TIMER_CALLBACK_MEMBER(mfp_update_irq);
272   TIMER_CALLBACK_MEMBER(mfp_timer_a_callback);
273   TIMER_CALLBACK_MEMBER(mfp_timer_b_callback);
274   TIMER_CALLBACK_MEMBER(mfp_timer_c_callback);
275   TIMER_CALLBACK_MEMBER(mfp_timer_d_callback);
276   TIMER_CALLBACK_MEMBER(x68k_led_callback);
277   TIMER_CALLBACK_MEMBER(x68k_keyboard_poll);
278   TIMER_CALLBACK_MEMBER(x68k_scc_ack);
279   TIMER_CALLBACK_MEMBER(md_6button_port1_timeout);
280   TIMER_CALLBACK_MEMBER(md_6button_port2_timeout);
281   TIMER_CALLBACK_MEMBER(x68k_bus_error);
282   TIMER_CALLBACK_MEMBER(x68k_net_irq);
283   TIMER_CALLBACK_MEMBER(x68k_crtc_operation_end);
284   TIMER_CALLBACK_MEMBER(x68k_hsync);
285   TIMER_CALLBACK_MEMBER(x68k_crtc_raster_end);
286   TIMER_CALLBACK_MEMBER(x68k_crtc_raster_irq);
287   TIMER_CALLBACK_MEMBER(x68k_crtc_vblank_irq);
271288};
272289
273290
trunk/src/mess/includes/nc.h
r18113r18114
8080   DECLARE_MACHINE_START(nc200);
8181   DECLARE_MACHINE_RESET(nc200);
8282   UINT32 screen_update_nc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
83   TIMER_CALLBACK_MEMBER(nc_keyboard_timer_callback);
84   TIMER_CALLBACK_MEMBER(nc_serial_timer_callback);
8385};
8486
8587
trunk/src/mess/includes/sms.h
r18113r18114
186186   UINT32 screen_update_sms1(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
187187   DECLARE_INPUT_CHANGED_MEMBER(lgun1_changed);
188188   DECLARE_INPUT_CHANGED_MEMBER(lgun2_changed);
189   TIMER_CALLBACK_MEMBER(rapid_fire_callback);
190   TIMER_CALLBACK_MEMBER(lightgun_tick);
191   TIMER_CALLBACK_MEMBER(lphaser_1_callback);
192   TIMER_CALLBACK_MEMBER(lphaser_2_callback);
189193};
190194
191195
trunk/src/mess/includes/mpf1.h
r18113r18114
5555
5656   emu_timer *m_led_refresh_timer;
5757   DECLARE_DRIVER_INIT(mpf1);
58   TIMER_CALLBACK_MEMBER(led_refresh);
5859};
5960
6061#endif
trunk/src/mess/includes/z80ne.h
r18113r18114
106106   DECLARE_MACHINE_RESET(z80ne_base);
107107   DECLARE_INPUT_CHANGED_MEMBER(z80ne_reset);
108108   DECLARE_INPUT_CHANGED_MEMBER(z80ne_nmi);
109   TIMER_CALLBACK_MEMBER(z80ne_cassette_tc);
110   TIMER_CALLBACK_MEMBER(z80ne_kbd_scan);
109111};
110112
111113
trunk/src/mess/includes/gamecom.h
r18113r18114
244244   virtual void video_start();
245245   virtual void palette_init();
246246   INTERRUPT_GEN_MEMBER(gamecom_interrupt);
247   TIMER_CALLBACK_MEMBER(gamecom_clock_timer_callback);
248   TIMER_CALLBACK_MEMBER(gamecom_scanline);
247249};
248250
249251
trunk/src/mess/includes/beta.h
r18113r18114
4949   UINT8 m_segment;
5050
5151   emu_timer *m_led_refresh_timer;
52   TIMER_CALLBACK_MEMBER(led_refresh);
5253};
5354
5455#endif
trunk/src/mess/includes/radio86.h
r18113r18114
3939   DECLARE_MACHINE_RESET(radio86);
4040   DECLARE_PALETTE_INIT(radio86);
4141   UINT32 screen_update_radio86(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
42   TIMER_CALLBACK_MEMBER(radio86_reset);
4243};
4344
4445
trunk/src/mess/includes/cxhumax.h
r18113r18114
152152   virtual void machine_reset();
153153   virtual void video_start();
154154   UINT32 screen_update_cxhumax(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
155   TIMER_CALLBACK_MEMBER(timer_tick);
155156};
156157
157158#define INTDEST         0   // Interrupt destination (1=IRQ, 0=FIQ)
trunk/src/mess/includes/lviv.h
r18113r18114
2727   virtual void video_start();
2828   virtual void palette_init();
2929   UINT32 screen_update_lviv(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
30   TIMER_CALLBACK_MEMBER(lviv_reset);
3031};
3132
3233
trunk/src/mess/includes/gb.h
r18113r18114
246246   DECLARE_MACHINE_START(gb_video);
247247   DECLARE_MACHINE_START(gbc_video);
248248   INTERRUPT_GEN_MEMBER(gb_scanline_interrupt);
249   TIMER_CALLBACK_MEMBER(gb_serial_timer_proc);
250   TIMER_CALLBACK_MEMBER(gb_video_init_vbl);
251   TIMER_CALLBACK_MEMBER(gb_lcd_timer_proc);
252   TIMER_CALLBACK_MEMBER(gbc_lcd_timer_proc);
249253};
250254
251255
trunk/src/mess/includes/x1.h
r18113r18114
202202   UINT32 screen_update_x1(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
203203   DECLARE_INPUT_CHANGED_MEMBER(ipl_reset);
204204   DECLARE_INPUT_CHANGED_MEMBER(nmi_reset);
205   TIMER_CALLBACK_MEMBER(x1_rtc_increment);
205206};
206207
207208
trunk/src/mess/includes/oric.h
r18113r18114
108108   virtual void palette_init();
109109   DECLARE_MACHINE_START(telestrat);
110110   UINT32 screen_update_oric(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
111   TIMER_CALLBACK_MEMBER(oric_refresh_tape);
112   TIMER_CALLBACK_MEMBER(oric_vh_timer_callback);
111113};
112114
113115/*----------- defined in machine/oric.c -----------*/
trunk/src/mess/includes/poly88.h
r18113r18114
3535   virtual void video_start();
3636   UINT32 screen_update_poly88(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3737   INTERRUPT_GEN_MEMBER(poly88_interrupt);
38   TIMER_CALLBACK_MEMBER(poly88_usart_timer_callback);
39   TIMER_CALLBACK_MEMBER(keyboard_callback);
40   TIMER_CALLBACK_MEMBER(poly88_cassette_timer_callback);
41   TIMER_CALLBACK_MEMBER(setup_machine_state);
3842};
3943
4044
trunk/src/mess/includes/super80.h
r18113r18114
8686   UINT32 screen_update_super80e(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8787   UINT32 screen_update_super80m(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8888   void screen_eof_super80m(screen_device &screen, bool state);
89   TIMER_CALLBACK_MEMBER(super80_timer);
90   TIMER_CALLBACK_MEMBER(super80_reset);
91   TIMER_CALLBACK_MEMBER(super80_halfspeed);
8992};
9093
9194
trunk/src/mess/includes/atarist.h
r18113r18114
274274   floppy_image_device *floppy_devices[2];
275275
276276   static const floppy_format_type floppy_formats[];
277   TIMER_CALLBACK_MEMBER(st_mouse_tick);
278   TIMER_CALLBACK_MEMBER(atarist_shifter_tick);
279   TIMER_CALLBACK_MEMBER(atarist_glue_tick);
280   TIMER_CALLBACK_MEMBER(atarist_blitter_tick);
277281};
278282
279283class megast_state : public st_state
r18113r18114
327331
328332   DECLARE_READ8_MEMBER( mfp_gpio_r );
329333
334   TIMER_CALLBACK_MEMBER(atariste_dmasound_tick);
335   TIMER_CALLBACK_MEMBER(atariste_microwire_tick);
336   
330337   void dmasound_set_state(int level);
331338   void dmasound_tick();
332339   void microwire_shift();
trunk/src/mess/includes/pce.h
r18113r18114
142142   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
143143   DECLARE_MACHINE_START(pce);
144144   DECLARE_MACHINE_RESET(mess_pce);
145   TIMER_CALLBACK_MEMBER(pce_cd_data_timer_callback);
146   TIMER_CALLBACK_MEMBER(pce_cd_cdda_fadeout_callback);
147   TIMER_CALLBACK_MEMBER(pce_cd_cdda_fadein_callback);
148   TIMER_CALLBACK_MEMBER(pce_cd_adpcm_fadeout_callback);
149   TIMER_CALLBACK_MEMBER(pce_cd_adpcm_fadein_callback);
150   TIMER_CALLBACK_MEMBER(pce_cd_clear_ack);
151   TIMER_CALLBACK_MEMBER(pce_cd_adpcm_dma_timer_callback);
145152};
146153
147154
trunk/src/mess/includes/gp32.h
r18113r18114
164164   virtual void machine_start();
165165   virtual void machine_reset();
166166   UINT32 screen_update_gp32(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
167   TIMER_CALLBACK_MEMBER(s3c240x_lcd_timer_exp);
168   TIMER_CALLBACK_MEMBER(s3c240x_pwm_timer_exp);
169   TIMER_CALLBACK_MEMBER(s3c240x_dma_timer_exp);
170   TIMER_CALLBACK_MEMBER(s3c240x_iic_timer_exp);
171   TIMER_CALLBACK_MEMBER(s3c240x_iis_timer_exp);
167172};
168173
169174
trunk/src/mess/includes/apple2gs.h
r18113r18114
142142   DECLARE_MACHINE_START(apple2gsr1);
143143   DECLARE_MACHINE_START(apple2gscommon);
144144   UINT32 screen_update_apple2gs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
145   TIMER_CALLBACK_MEMBER(apple2gs_clock_tick);
146   TIMER_CALLBACK_MEMBER(apple2gs_qsecond_tick);
147   TIMER_CALLBACK_MEMBER(apple2gs_scanline_tick);
145148};
146149
147150
trunk/src/mess/includes/x07.h
r18113r18114
260260   UINT8 m_prn_buffer[0x100];
261261   UINT8 m_prn_size;
262262   virtual void palette_init();
263   TIMER_CALLBACK_MEMBER(cassette_tick);
264   TIMER_CALLBACK_MEMBER(cassette_poll);
265   TIMER_CALLBACK_MEMBER(rsta_clear);
266   TIMER_CALLBACK_MEMBER(rstb_clear);
267   TIMER_CALLBACK_MEMBER(beep_stop);
263268};
trunk/src/mess/includes/bbc.h
r18113r18114
285285   INTERRUPT_GEN_MEMBER(bbcb_vsync);
286286   INTERRUPT_GEN_MEMBER(bbcb_keyscan);
287287   INTERRUPT_GEN_MEMBER(bbcm_keyscan);
288   TIMER_CALLBACK_MEMBER(bbc_tape_timer_cb);
288289};
289290
290291
trunk/src/mess/includes/studio2.h
r18113r18114
4949   /* keyboard state */
5050   UINT8 m_keylatch;
5151   DECLARE_DRIVER_INIT(studio2);
52   TIMER_CALLBACK_MEMBER(setup_beep);
5253};
5354
5455class visicom_state : public studio2_state
trunk/src/mess/includes/gba.h
r18113r18114
240240   virtual void machine_start();
241241   virtual void machine_reset();
242242   virtual void palette_init();
243   TIMER_CALLBACK_MEMBER(dma_complete);
244   TIMER_CALLBACK_MEMBER(timer_expire);
245   TIMER_CALLBACK_MEMBER(handle_irq);
246   TIMER_CALLBACK_MEMBER(perform_hbl);
247   TIMER_CALLBACK_MEMBER(perform_scan);
243248};
244249
245250/*----------- defined in video/gba.c -----------*/
trunk/src/mess/includes/fm7.h
r18113r18114
239239   DECLARE_MACHINE_START(fm11);
240240   DECLARE_MACHINE_START(fm16);
241241   UINT32 screen_update_fm7(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
242   TIMER_CALLBACK_MEMBER(fm7_beeper_off);
243   TIMER_CALLBACK_MEMBER(fm77av_encoder_ack);
244   TIMER_CALLBACK_MEMBER(fm7_timer_irq);
245   TIMER_CALLBACK_MEMBER(fm7_subtimer_irq);
246   TIMER_CALLBACK_MEMBER(fm7_keyboard_poll);
247   TIMER_CALLBACK_MEMBER(fm77av_alu_task_end);
248   TIMER_CALLBACK_MEMBER(fm77av_vsync);
242249};
243250
244251/*----------- defined in video/fm7.c -----------*/
trunk/src/mess/includes/pc1251.h
r18113r18114
2727
2828   DECLARE_DRIVER_INIT(pc1251);
2929   UINT32 screen_update_pc1251(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
30   TIMER_CALLBACK_MEMBER(pc1251_power_up);
3031};
3132
3233
trunk/src/mess/includes/pokemini.h
r18113r18114
6464
6565   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6666   virtual void palette_init();
67   TIMER_CALLBACK_MEMBER(pokemini_seconds_timer_callback);
68   TIMER_CALLBACK_MEMBER(pokemini_256hz_timer_callback);
69   TIMER_CALLBACK_MEMBER(pokemini_timer1_callback);
70   TIMER_CALLBACK_MEMBER(pokemini_timer1_hi_callback);
71   TIMER_CALLBACK_MEMBER(pokemini_timer2_callback);
72   TIMER_CALLBACK_MEMBER(pokemini_timer2_hi_callback);
73   TIMER_CALLBACK_MEMBER(pokemini_timer3_callback);
74   TIMER_CALLBACK_MEMBER(pokemini_timer3_hi_callback);
75   TIMER_CALLBACK_MEMBER(pokemini_prc_counter_callback);
6776};
6877
6978
trunk/src/mess/includes/intv.h
r18113r18114
134134   UINT32 screen_update_intvkbd(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
135135   INTERRUPT_GEN_MEMBER(intv_interrupt2);
136136   INTERRUPT_GEN_MEMBER(intv_interrupt);
137   TIMER_CALLBACK_MEMBER(intv_interrupt2_complete);
138   TIMER_CALLBACK_MEMBER(intv_interrupt_complete);
139   TIMER_CALLBACK_MEMBER(intv_btb_fill);
137140};
138141
139142/*----------- defined in video/intv.c -----------*/
trunk/src/mess/includes/aim65.h
r18113r18114
5757   required_device<cassette_image_device> m_cass1;
5858   required_device<cassette_image_device> m_cass2;
5959   virtual void machine_start();
60   TIMER_CALLBACK_MEMBER(aim65_printer_timer);
6061};
6162
6263
trunk/src/mess/includes/galaxy.h
r18113r18114
3333   DECLARE_MACHINE_RESET(galaxyp);
3434   UINT32 screen_update_galaxy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3535   INTERRUPT_GEN_MEMBER(galaxy_interrupt);
36   TIMER_CALLBACK_MEMBER(gal_video);
3637};
3738
3839
trunk/src/mess/includes/compis.h
r18113r18114
188188   virtual void palette_init();
189189   UINT32 screen_update_compis2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
190190   INTERRUPT_GEN_MEMBER(compis_vblank_int);
191   TIMER_CALLBACK_MEMBER(internal_timer_int);
192   TIMER_CALLBACK_MEMBER(dma_timer_callback);
191193};
192194
193195
trunk/src/mess/includes/hec2hrp.h
r18113r18114
137137   DECLARE_MACHINE_START(hec2mdhrx);
138138   DECLARE_MACHINE_RESET(hec2mdhrx);
139139   UINT32 screen_update_hec2hrp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
140   TIMER_CALLBACK_MEMBER(Callback_CK);
140141};
141142
142143/*----------- defined in machine/hec2hrp.c -----------*/
trunk/src/mess/includes/tmc1800.h
r18113r18114
4949   /* keyboard state */
5050   int m_keylatch;         /* key latch */
5151   DECLARE_DRIVER_INIT(tmc1800);
52   TIMER_CALLBACK_MEMBER(setup_beep);
5253};
5354
5455class osc1000b_state : public driver_device
trunk/src/mess/includes/fmtowns.h
r18113r18114
276276   void wait_end();
277277public:   
278278   INTERRUPT_GEN_MEMBER(towns_vsync_irq);
279   TIMER_CALLBACK_MEMBER(towns_cd_status_ready);
280   TIMER_CALLBACK_MEMBER(towns_cdrom_read_byte);
281   TIMER_CALLBACK_MEMBER(towns_delay_cdda);
282   TIMER_CALLBACK_MEMBER(towns_sprite_done);
283   TIMER_CALLBACK_MEMBER(towns_vblank_end);
279284};
280285
281286class marty_state : public towns_state
trunk/src/mess/includes/dai.h
r18113r18114
8181   virtual void video_start();
8282   virtual void palette_init();
8383   UINT32 screen_update_dai(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
84   TIMER_CALLBACK_MEMBER(dai_bootstrap_callback);
85   TIMER_CALLBACK_MEMBER(dai_timer);
8486};
8587
8688
trunk/src/mess/includes/pmd85.h
r18113r18114
4040   virtual void video_start();
4141   virtual void palette_init();
4242   UINT32 screen_update_pmd85(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
43   TIMER_CALLBACK_MEMBER(pmd85_cassette_timer_callback);
44   TIMER_CALLBACK_MEMBER(pmd_reset);
45   TIMER_CALLBACK_MEMBER(setup_machine_state);
4346};
4447
4548
trunk/src/mess/includes/mac.h
r18113r18114
523523   UINT32 screen_update_macrbvvram(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
524524   UINT32 screen_update_macpbwd(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
525525   INTERRUPT_GEN_MEMBER(mac_rbv_vbl);
526   TIMER_CALLBACK_MEMBER(kbd_clock);
527   TIMER_CALLBACK_MEMBER(inquiry_timeout_func);
528   TIMER_CALLBACK_MEMBER(mac_6015_tick);
529   TIMER_CALLBACK_MEMBER(mac_scanline_tick);
530   TIMER_CALLBACK_MEMBER(dafb_vbl_tick);
531   TIMER_CALLBACK_MEMBER(dafb_cursor_tick);
526532};
527533
528534#endif /* MAC_H_ */
trunk/src/mess/includes/ondra.h
r18113r18114
2525   virtual void video_start();
2626   UINT32 screen_update_ondra(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
2727   INTERRUPT_GEN_MEMBER(ondra_interrupt);
28   TIMER_CALLBACK_MEMBER(nmi_check_callback);
2829};
2930
3031#endif
trunk/src/mess/includes/pc1401.h
r18113r18114
2727   UINT8 m_reg[0x100];
2828   DECLARE_DRIVER_INIT(pc1401);
2929   UINT32 screen_update_pc1401(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
30   TIMER_CALLBACK_MEMBER(pc1401_power_up);
3031};
3132
3233
trunk/src/mess/includes/ut88.h
r18113r18114
4848   DECLARE_MACHINE_START(ut88mini);
4949   DECLARE_MACHINE_RESET(ut88mini);
5050   UINT32 screen_update_ut88(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
51   TIMER_CALLBACK_MEMBER(ut88_reset);
52   TIMER_CALLBACK_MEMBER(update_display);
5153};
5254
5355
trunk/src/mess/includes/special.h
r18113r18114
9494   UINT32 screen_update_erik(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
9595   UINT32 screen_update_specialp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
9696   UINT32 screen_update_specimx(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
97   TIMER_CALLBACK_MEMBER(special_reset);
98   TIMER_CALLBACK_MEMBER(setup_pit8253_gates);
9799};
98100
99101
trunk/src/mess/includes/nes.h
r18113r18114
124124   virtual void video_start();
125125   virtual void palette_init();
126126   UINT32 screen_update_nes(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
127   TIMER_CALLBACK_MEMBER(nes_irq_callback);
128   TIMER_CALLBACK_MEMBER(lightgun_tick);
127129};
128130
129131/*----------- defined in machine/nes.c -----------*/
trunk/src/mess/includes/ti85.h
r18113r18114
102102   DECLARE_MACHINE_START(ti86);
103103   DECLARE_MACHINE_START(ti83p);
104104   UINT32 screen_update_ti85(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
105   TIMER_CALLBACK_MEMBER(ti85_timer_callback);
105106};
106107
107108
trunk/src/mess/includes/mikro80.h
r18113r18114
3434   virtual void machine_reset();
3535   virtual void video_start();
3636   UINT32 screen_update_mikro80(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
37   TIMER_CALLBACK_MEMBER(mikro80_reset);
3738};
3839
3940
trunk/src/mess/includes/amstrad.h
r18113r18114
170170   UINT32 screen_update_amstrad(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
171171   void screen_eof_amstrad(screen_device &screen, bool state);
172172   DECLARE_INPUT_CHANGED_MEMBER(cpc_monitor_changed);
173   TIMER_CALLBACK_MEMBER(amstrad_pc2_low);
174   TIMER_CALLBACK_MEMBER(amstrad_video_update_timer);
175   TIMER_CALLBACK_MEMBER(cb_set_resolution);
173176};
174177
175178
trunk/src/mess/includes/macpci.h
r18113r18114
158158public:
159159   emu_timer *m_scanline_timer;
160160   UINT32 screen_update_pippin(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
161   TIMER_CALLBACK_MEMBER(mac_6015_tick);
161162};
162163
163164#endif /* PCIMAC_H_ */
trunk/src/mess/includes/bk.h
r18113r18114
3737   virtual void machine_reset();
3838   virtual void video_start();
3939   UINT32 screen_update_bk0010(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
40   TIMER_CALLBACK_MEMBER(keyboard_callback);
4041};
4142
4243#endif /* BK_H_ */
trunk/src/mess/includes/rm380z.h
r18113r18114
125125   int keyboard_decode();
126126   void update_screen(bitmap_ind16 &bitmap);
127127   UINT32 screen_update_rm380z(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
128   TIMER_CALLBACK_MEMBER(static_vblank_timer);
128129};
129130
130131
trunk/src/mess/includes/pc1350.h
r18113r18114
2525   int m_power;
2626   UINT8 m_reg[0x1000];
2727   UINT32 screen_update_pc1350(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
28   TIMER_CALLBACK_MEMBER(pc1350_power_up);
2829};
2930
3031
trunk/src/mess/includes/svision.h
r18113r18114
5757   UINT32 screen_update_svision(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5858   UINT32 screen_update_tvlink(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
5959   INTERRUPT_GEN_MEMBER(svision_frame_int);
60   TIMER_CALLBACK_MEMBER(svision_pet_timer);
61   TIMER_CALLBACK_MEMBER(svision_timer);
6062};
6163
6264
trunk/src/mess/includes/bebox.h
r18113r18114
4141   DECLARE_DRIVER_INIT(bebox);
4242   virtual void machine_start();
4343   virtual void machine_reset();
44   TIMER_CALLBACK_MEMBER(bebox_get_devices);
4445};
4546
4647
trunk/src/mess/includes/pdp1.h
r18113r18114
262262   UINT32 screen_update_pdp1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
263263   void screen_eof_pdp1(screen_device &screen, bool state);
264264   INTERRUPT_GEN_MEMBER(pdp1_interrupt);
265   TIMER_CALLBACK_MEMBER(reader_callback);
266   TIMER_CALLBACK_MEMBER(puncher_callback);
267   TIMER_CALLBACK_MEMBER(tyo_callback);
268   TIMER_CALLBACK_MEMBER(dpy_callback);
269   TIMER_CALLBACK_MEMBER(il_timer_callback);
265270};
266271
267272/*----------- defined in video/pdp1.c -----------*/
trunk/src/mess/includes/vector06.h
r18113r18114
6565   virtual void palette_init();
6666   UINT32 screen_update_vector06(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6767   INTERRUPT_GEN_MEMBER(vector06_interrupt);
68   TIMER_CALLBACK_MEMBER(reset_check_callback);
6869};
6970
7071
trunk/src/mess/includes/electron.h
r18113r18114
7575   virtual void video_start();
7676   virtual void palette_init();
7777   UINT32 screen_update_electron(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
78   TIMER_CALLBACK_MEMBER(electron_tape_timer_handler);
79   TIMER_CALLBACK_MEMBER(setup_beep);
80   TIMER_CALLBACK_MEMBER(electron_scanline_interrupt);
7881};
7982
8083
trunk/src/mess/includes/tx0.h
r18113r18114
153153   UINT32 screen_update_tx0(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
154154   void screen_eof_tx0(screen_device &screen, bool state);
155155   INTERRUPT_GEN_MEMBER(tx0_interrupt);
156   TIMER_CALLBACK_MEMBER(reader_callback);
157   TIMER_CALLBACK_MEMBER(puncher_callback);
158   TIMER_CALLBACK_MEMBER(prt_callback);
159   TIMER_CALLBACK_MEMBER(dis_callback);
156160};
157161
158162
trunk/src/mess/video/electron.c
r18113r18114
3535
3636*/
3737
38static TIMER_CALLBACK( electron_scanline_interrupt );
3938
4039
40
4141void electron_state::video_start()
4242{
4343   int i;
r18113r18114
4545      m_map4[i] = ( ( i & 0x10 ) >> 3 ) | ( i & 0x01 );
4646      m_map16[i] = ( ( i & 0x40 ) >> 3 ) | ( ( i & 0x10 ) >> 2 ) | ( ( i & 0x04 ) >> 1 ) | ( i & 0x01 );
4747   }
48   m_scanline_timer = machine().scheduler().timer_alloc(FUNC(electron_scanline_interrupt));
48   m_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(electron_state::electron_scanline_interrupt),this));
4949   m_scanline_timer->adjust( machine().primary_screen->time_until_pos(0), 0, machine().primary_screen->scan_period() );
5050}
5151
r18113r18114
254254   return 0;
255255}
256256
257static TIMER_CALLBACK( electron_scanline_interrupt )
257TIMER_CALLBACK_MEMBER(electron_state::electron_scanline_interrupt)
258258{
259   electron_state *state = machine.driver_data<electron_state>();
260   switch (machine.primary_screen->vpos())
259   switch (machine().primary_screen->vpos())
261260   {
262261   case 43:
263      electron_interrupt_handler( machine, INT_SET, INT_RTC );
262      electron_interrupt_handler( machine(), INT_SET, INT_RTC );
264263      break;
265264   case 199:
266      electron_interrupt_handler( machine, INT_SET, INT_DISPLAY_END );
265      electron_interrupt_handler( machine(), INT_SET, INT_DISPLAY_END );
267266      break;
268267   case 0:
269      state->m_ula.screen_addr = state->m_ula.screen_start - state->m_ula.screen_base;
268      m_ula.screen_addr = m_ula.screen_start - m_ula.screen_base;
270269      break;
271270   }
272271}
trunk/src/mess/video/gb.c
r18113r18114
4747
4848
4949/* Prototypes */
50static TIMER_CALLBACK(gb_lcd_timer_proc);
51static TIMER_CALLBACK(gbc_lcd_timer_proc);
50
51
5252static void gb_lcd_switch_on( running_machine &machine );
5353
5454static const unsigned char palette[] =
r18113r18114
11941194   GB_LCD_STATE_LY00_M0
11951195};
11961196
1197static TIMER_CALLBACK( gb_video_init_vbl )
1197TIMER_CALLBACK_MEMBER(gb_state::gb_video_init_vbl)
11981198{
1199   machine.device("maincpu")->execute().set_input_line(VBL_INT, ASSERT_LINE );
1199   machine().device("maincpu")->execute().set_input_line(VBL_INT, ASSERT_LINE );
12001200}
12011201
12021202MACHINE_START_MEMBER(gb_state,gb_video)
12031203{
1204   m_lcd.lcd_timer = machine().scheduler().timer_alloc(FUNC(gb_lcd_timer_proc));
1204   m_lcd.lcd_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gb_state::gb_lcd_timer_proc),this));
12051205   machine().primary_screen->register_screen_bitmap(m_bitmap);
12061206}
12071207
12081208MACHINE_START_MEMBER(gb_state,gbc_video)
12091209{
1210   m_lcd.lcd_timer = machine().scheduler().timer_alloc(FUNC(gbc_lcd_timer_proc));
1210   m_lcd.lcd_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gb_state::gbc_lcd_timer_proc),this));
12111211   machine().primary_screen->register_screen_bitmap(m_bitmap);
12121212}
12131213
r18113r18114
12881288      memcpy( state->m_lcd.gb_oam->base(), mgb_oam_fingerprint, 0x100 );
12891289
12901290      /* Make sure the VBlank interrupt is set when the first instruction gets executed */
1291      machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(1), FUNC(gb_video_init_vbl));
1291      machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(1), timer_expired_delegate(FUNC(gb_state::gb_video_init_vbl),state));
12921292
12931293      /* Initialize some video registers */
12941294      state->gb_video_w( space, 0x0, 0x91 );    /* LCDCONT */
r18113r18114
13671367   }
13681368}
13691369
1370static TIMER_CALLBACK(gb_lcd_timer_proc)
1370TIMER_CALLBACK_MEMBER(gb_state::gb_lcd_timer_proc)
13711371{
1372   gb_state *state = machine.driver_data<gb_state>();
1372   gb_state *state = machine().driver_data<gb_state>();
13731373   static const int sprite_cycles[] = { 0, 8, 20, 32, 44, 52, 64, 76, 88, 96, 108 };
13741374
1375   state->m_lcd.state = param;
1375   m_lcd.state = param;
13761376
13771377   if ( LCDCONT & 0x80 )
13781378   {
1379      switch( state->m_lcd.state )
1379      switch( m_lcd.state )
13801380      {
13811381      case GB_LCD_STATE_LYXX_PRE_M0:   /* Just before switching to mode 0 */
1382         state->m_lcd.mode = 0;
1382         m_lcd.mode = 0;
13831383         if ( LCDSTAT & 0x08 )
13841384         {
1385            if ( ! state->m_lcd.mode_irq )
1385            if ( ! m_lcd.mode_irq )
13861386            {
1387               if ( ! state->m_lcd.line_irq && ! state->m_lcd.delayed_line_irq )
1387               if ( ! m_lcd.line_irq && ! m_lcd.delayed_line_irq )
13881388               {
1389                  state->m_lcd.mode_irq = 1;
1390                  machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1389                  m_lcd.mode_irq = 1;
1390                  machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
13911391               }
13921392            }
13931393            else
13941394            {
1395               state->m_lcd.mode_irq = 0;
1395               m_lcd.mode_irq = 0;
13961396            }
13971397         }
1398         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0);
1398         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0);
13991399         break;
14001400      case GB_LCD_STATE_LYXX_M0:      /* Switch to mode 0 */
14011401         /* update current scanline */
1402         (*state->update_scanline)( machine );
1402         (*update_scanline)( machine() );
14031403         /* Increment the number of window lines drawn if enabled */
1404         if ( state->m_lcd.layer[1].enabled )
1404         if ( m_lcd.layer[1].enabled )
14051405         {
1406            state->m_lcd.window_lines_drawn++;
1406            m_lcd.window_lines_drawn++;
14071407         }
1408         state->m_lcd.previous_line = state->m_lcd.current_line;
1408         m_lcd.previous_line = m_lcd.current_line;
14091409         /* Set Mode 0 lcdstate */
1410         state->m_lcd.mode = 0;
1410         m_lcd.mode = 0;
14111411         LCDSTAT &= 0xFC;
1412         state->m_lcd.oam_locked = UNLOCKED;
1413         state->m_lcd.vram_locked = UNLOCKED;
1412         m_lcd.oam_locked = UNLOCKED;
1413         m_lcd.vram_locked = UNLOCKED;
14141414         /*
14151415                There seems to a kind of feature in the Game Boy hardware when the lowest bits of the
14161416                SCROLLX register equals 3 or 7, then the delayed M0 irq is triggered 4 cycles later
r18113r18114
14191419            */
14201420         if ( ( SCROLLX & 0x03 ) == 0x03 )
14211421         {
1422            state->m_lcd.scrollx_adjust += 4;
1423            state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_SCX3);
1422            m_lcd.scrollx_adjust += 4;
1423            m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_SCX3);
14241424            break;
14251425         }
14261426      case GB_LCD_STATE_LYXX_M0_SCX3:
14271427         /* Generate lcd interrupt if requested */
1428         if ( ! state->m_lcd.mode_irq && ( LCDSTAT & 0x08 ) &&
1429              ( ( ! state->m_lcd.line_irq && state->m_lcd.delayed_line_irq ) || ! ( LCDSTAT & 0x40 ) ) )
1428         if ( ! m_lcd.mode_irq && ( LCDSTAT & 0x08 ) &&
1429              ( ( ! m_lcd.line_irq && m_lcd.delayed_line_irq ) || ! ( LCDSTAT & 0x40 ) ) )
14301430         {
1431            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1431            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
14321432         }
1433         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(196 - state->m_lcd.scrollx_adjust - state->m_lcd.sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC);
1433         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(196 - m_lcd.scrollx_adjust - m_lcd.sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC);
14341434         break;
14351435      case GB_LCD_STATE_LYXX_M0_PRE_INC:   /* Just before incrementing the line counter go to mode 2 internally */
14361436         if ( CURLINE < 143 )
14371437         {
1438            state->m_lcd.mode = 2;
1439            state->m_lcd.triggering_mode_irq = ( LCDSTAT & 0x20 ) ? 1 : 0;
1440            if ( state->m_lcd.triggering_mode_irq )
1438            m_lcd.mode = 2;
1439            m_lcd.triggering_mode_irq = ( LCDSTAT & 0x20 ) ? 1 : 0;
1440            if ( m_lcd.triggering_mode_irq )
14411441            {
1442               if ( ! state->m_lcd.mode_irq )
1442               if ( ! m_lcd.mode_irq )
14431443               {
1444                  if ( ! state->m_lcd.line_irq && ! state->m_lcd.delayed_line_irq )
1444                  if ( ! m_lcd.line_irq && ! m_lcd.delayed_line_irq )
14451445                  {
1446                     state->m_lcd.mode_irq = 1;
1447                     machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1446                     m_lcd.mode_irq = 1;
1447                     machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
14481448                  }
14491449               }
14501450               else
14511451               {
1452                  state->m_lcd.mode_irq = 0;
1452                  m_lcd.mode_irq = 0;
14531453               }
14541454            }
14551455         }
1456         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_INC);
1456         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_INC);
14571457         break;
14581458      case GB_LCD_STATE_LYXX_M0_INC:   /* Increment LY, stay in M0 for 4 more cycles */
1459         gb_increment_scanline(state);
1460         state->m_lcd.delayed_line_irq = state->m_lcd.line_irq;
1461         state->m_lcd.triggering_line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0;
1462         state->m_lcd.line_irq = 0;
1463         if ( ! state->m_lcd.mode_irq && ! state->m_lcd.delayed_line_irq && state->m_lcd.triggering_line_irq && ! state->m_lcd.triggering_mode_irq )
1459         gb_increment_scanline(this);
1460         m_lcd.delayed_line_irq = m_lcd.line_irq;
1461         m_lcd.triggering_line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0;
1462         m_lcd.line_irq = 0;
1463         if ( ! m_lcd.mode_irq && ! m_lcd.delayed_line_irq && m_lcd.triggering_line_irq && ! m_lcd.triggering_mode_irq )
14641464         {
1465            state->m_lcd.line_irq = state->m_lcd.triggering_line_irq;
1466            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1465            m_lcd.line_irq = m_lcd.triggering_line_irq;
1466            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
14671467         }
14681468         /* Reset LY==LYC STAT bit */
14691469         LCDSTAT &= 0xFB;
14701470         /* Check if we're going into VBlank next */
14711471         if ( CURLINE == 144 )
14721472         {
1473            state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1);
1473            m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1);
14741474         }
14751475         else
14761476         {
14771477            /* Internally switch to mode 2 */
1478            state->m_lcd.mode = 2;
1478            m_lcd.mode = 2;
14791479            /* Generate lcd interrupt if requested */
1480            if ( ! state->m_lcd.mode_irq && state->m_lcd.triggering_mode_irq &&
1481                ( ( ! state->m_lcd.triggering_line_irq && ! state->m_lcd.delayed_line_irq ) || ! ( LCDSTAT & 0x40 ) ) )
1480            if ( ! m_lcd.mode_irq && m_lcd.triggering_mode_irq &&
1481                ( ( ! m_lcd.triggering_line_irq && ! m_lcd.delayed_line_irq ) || ! ( LCDSTAT & 0x40 ) ) )
14821482            {
1483               state->m_lcd.mode_irq = 1;
1484               machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1483               m_lcd.mode_irq = 1;
1484               machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
14851485            }
1486            state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M2);
1486            m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M2);
14871487         }
14881488         break;
14891489      case GB_LCD_STATE_LY00_M2:      /* Switch to mode 2 on line #0 */
14901490         /* Set Mode 2 lcdstate */
1491         state->m_lcd.mode = 2;
1491         m_lcd.mode = 2;
14921492         LCDSTAT = ( LCDSTAT & 0xFC ) | 0x02;
1493         state->m_lcd.oam_locked = LOCKED;
1493         m_lcd.oam_locked = LOCKED;
14941494         /* Generate lcd interrupt if requested */
1495         if ( ( LCDSTAT & 0x20 ) && ! state->m_lcd.line_irq )
1495         if ( ( LCDSTAT & 0x20 ) && ! m_lcd.line_irq )
14961496         {
1497            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1497            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
14981498         }
14991499         /* Check for regular compensation of x-scroll register */
1500         state->m_lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0;
1500         m_lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0;
15011501         /* Mode 2 lasts approximately 80 clock cycles */
1502         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3);
1502         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3);
15031503         break;
15041504      case GB_LCD_STATE_LYXX_M2:      /* Switch to mode 2 */
15051505         /* Update STAT register to the correct state */
15061506         LCDSTAT = (LCDSTAT & 0xFC) | 0x02;
1507         state->m_lcd.oam_locked = LOCKED;
1507         m_lcd.oam_locked = LOCKED;
15081508         /* Generate lcd interrupt if requested */
1509         if ( ( state->m_lcd.delayed_line_irq && state->m_lcd.triggering_line_irq && ! ( LCDSTAT & 0x20 ) ) ||
1510             ( ! state->m_lcd.mode_irq && ! state->m_lcd.line_irq && ! state->m_lcd.delayed_line_irq && state->m_lcd.triggering_mode_irq ) )
1509         if ( ( m_lcd.delayed_line_irq && m_lcd.triggering_line_irq && ! ( LCDSTAT & 0x20 ) ) ||
1510             ( ! m_lcd.mode_irq && ! m_lcd.line_irq && ! m_lcd.delayed_line_irq && m_lcd.triggering_mode_irq ) )
15111511         {
1512            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1512            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
15131513         }
1514         state->m_lcd.line_irq = state->m_lcd.triggering_line_irq;
1515         state->m_lcd.triggering_mode_irq = 0;
1514         m_lcd.line_irq = m_lcd.triggering_line_irq;
1515         m_lcd.triggering_mode_irq = 0;
15161516         /* Check if LY==LYC STAT bit should be set */
15171517         if ( CURLINE == CMPLINE )
15181518         {
15191519            LCDSTAT |= 0x04;
15201520         }
15211521         /* Check for regular compensation of x-scroll register */
1522         state->m_lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0;
1522         m_lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0;
15231523         /* Mode 2 last for approximately 80 clock cycles */
1524         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3);
1524         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3);
15251525         break;
15261526      case GB_LCD_STATE_LYXX_M3:      /* Switch to mode 3 */
1527         gb_select_sprites(state);
1528         state->m_lcd.sprite_cycles = sprite_cycles[ state->m_lcd.sprCount ];
1527         gb_select_sprites(this);
1528         m_lcd.sprite_cycles = sprite_cycles[ m_lcd.sprCount ];
15291529         /* Set Mode 3 lcdstate */
1530         state->m_lcd.mode = 3;
1530         m_lcd.mode = 3;
15311531         LCDSTAT = (LCDSTAT & 0xFC) | 0x03;
1532         state->m_lcd.vram_locked = LOCKED;
1532         m_lcd.vram_locked = LOCKED;
15331533         /* Check for compensations of x-scroll register */
15341534         /* Mode 3 lasts for approximately 172+cycles needed to handle sprites clock cycles */
1535         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(168 + state->m_lcd.scrollx_adjust + state->m_lcd.sprite_cycles), GB_LCD_STATE_LYXX_PRE_M0);
1536         state->m_lcd.start_x = -1;
1535         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(168 + m_lcd.scrollx_adjust + m_lcd.sprite_cycles), GB_LCD_STATE_LYXX_PRE_M0);
1536         m_lcd.start_x = -1;
15371537         break;
15381538      case GB_LCD_STATE_LY9X_M1:      /* Switch to or stay in mode 1 */
15391539         if ( CURLINE == 144 )
15401540         {
15411541            /* Trigger VBlank interrupt */
1542            machine.device("maincpu")->execute().set_input_line(VBL_INT, ASSERT_LINE );
1542            machine().device("maincpu")->execute().set_input_line(VBL_INT, ASSERT_LINE );
15431543            /* Set VBlank lcdstate */
1544            state->m_lcd.mode = 1;
1544            m_lcd.mode = 1;
15451545            LCDSTAT = (LCDSTAT & 0xFC) | 0x01;
15461546            /* Trigger LCD interrupt if requested */
15471547            if ( LCDSTAT & 0x10 )
15481548            {
1549               machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1549               machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
15501550            }
15511551         }
15521552         /* Check if LY==LYC STAT bit should be set */
r18113r18114
15541554         {
15551555            LCDSTAT |= 0x04;
15561556         }
1557         if ( state->m_lcd.delayed_line_irq && state->m_lcd.triggering_line_irq )
1557         if ( m_lcd.delayed_line_irq && m_lcd.triggering_line_irq )
15581558         {
1559            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1559            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
15601560         }
1561         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(452), GB_LCD_STATE_LY9X_M1_INC);
1561         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(452), GB_LCD_STATE_LY9X_M1_INC);
15621562         break;
15631563      case GB_LCD_STATE_LY9X_M1_INC:      /* Increment scanline counter */
1564         gb_increment_scanline(state);
1565         state->m_lcd.delayed_line_irq = state->m_lcd.line_irq;
1566         state->m_lcd.triggering_line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0;
1567         state->m_lcd.line_irq = 0;
1568         if ( ! state->m_lcd.delayed_line_irq && state->m_lcd.triggering_line_irq )
1564         gb_increment_scanline(this);
1565         m_lcd.delayed_line_irq = m_lcd.line_irq;
1566         m_lcd.triggering_line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0;
1567         m_lcd.line_irq = 0;
1568         if ( ! m_lcd.delayed_line_irq && m_lcd.triggering_line_irq )
15691569         {
1570            state->m_lcd.line_irq = state->m_lcd.triggering_line_irq;
1571            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1570            m_lcd.line_irq = m_lcd.triggering_line_irq;
1571            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
15721572         }
15731573         /* Reset LY==LYC STAT bit */
15741574         LCDSTAT &= 0xFB;
1575         if ( state->m_lcd.current_line == 153 )
1575         if ( m_lcd.current_line == 153 )
15761576         {
1577            state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1);
1577            m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1);
15781578         }
15791579         else
15801580         {
1581            state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1);
1581            m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1);
15821582         }
15831583         break;
15841584      case GB_LCD_STATE_LY00_M1:      /* we stay in VBlank but current line counter should already be incremented */
15851585         /* Check LY=LYC for line #153 */
1586         if ( state->m_lcd.delayed_line_irq )
1586         if ( m_lcd.delayed_line_irq )
15871587         {
1588            if ( state->m_lcd.triggering_line_irq )
1588            if ( m_lcd.triggering_line_irq )
15891589            {
1590               machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1590               machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
15911591            }
15921592         }
1593         state->m_lcd.delayed_line_irq = state->m_lcd.delayed_line_irq | state->m_lcd.line_irq;
1593         m_lcd.delayed_line_irq = m_lcd.delayed_line_irq | m_lcd.line_irq;
15941594         if ( CURLINE == CMPLINE )
15951595         {
15961596            LCDSTAT |= 0x04;
15971597         }
1598         gb_increment_scanline(state);
1599         state->m_lcd.triggering_line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0;
1600         state->m_lcd.line_irq = 0;
1598         gb_increment_scanline(this);
1599         m_lcd.triggering_line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0;
1600         m_lcd.line_irq = 0;
16011601         LCDSTAT &= 0xFB;
1602         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4/*8*/), GB_LCD_STATE_LY00_M1_1);
1602         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4/*8*/), GB_LCD_STATE_LY00_M1_1);
16031603         break;
16041604      case GB_LCD_STATE_LY00_M1_1:
1605         if ( ! state->m_lcd.delayed_line_irq && state->m_lcd.triggering_line_irq )
1605         if ( ! m_lcd.delayed_line_irq && m_lcd.triggering_line_irq )
16061606         {
1607            state->m_lcd.line_irq = state->m_lcd.triggering_line_irq;
1608            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1607            m_lcd.line_irq = m_lcd.triggering_line_irq;
1608            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
16091609         }
1610         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_2);
1610         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_2);
16111611         break;
16121612      case GB_LCD_STATE_LY00_M1_2:   /* Rest of line #0 during VBlank */
1613         if ( state->m_lcd.delayed_line_irq && state->m_lcd.triggering_line_irq )
1613         if ( m_lcd.delayed_line_irq && m_lcd.triggering_line_irq )
16141614         {
1615            state->m_lcd.line_irq = state->m_lcd.triggering_line_irq;
1616            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1615            m_lcd.line_irq = m_lcd.triggering_line_irq;
1616            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
16171617         }
16181618         if ( CURLINE == CMPLINE )
16191619         {
16201620            LCDSTAT |= 0x04;
16211621         }
1622         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(444), GB_LCD_STATE_LY00_M0);
1622         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(444), GB_LCD_STATE_LY00_M0);
16231623         break;
16241624      case GB_LCD_STATE_LY00_M0:      /* The STAT register seems to go to 0 for about 4 cycles */
16251625         /* Set Mode 0 lcdstat */
1626         state->m_lcd.mode = 0;
1626         m_lcd.mode = 0;
16271627         LCDSTAT = ( LCDSTAT & 0xFC );
1628         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M2);
1628         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M2);
16291629         break;
16301630      }
16311631   }
16321632   else
16331633   {
1634      gb_increment_scanline(state);
1635      if ( state->m_lcd.current_line < 144 )
1634      gb_increment_scanline(this);
1635      if ( m_lcd.current_line < 144 )
16361636      {
1637         (*state->update_scanline)( machine );
1637         (*update_scanline)( machine() );
16381638      }
1639      state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(456));
1639      m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(456));
16401640   }
16411641}
16421642
1643static TIMER_CALLBACK(gbc_lcd_timer_proc)
1643TIMER_CALLBACK_MEMBER(gb_state::gbc_lcd_timer_proc)
16441644{
1645   gb_state *state = machine.driver_data<gb_state>();
1645   gb_state *state = machine().driver_data<gb_state>();
16461646   static const int sprite_cycles[] = { 0, 8, 20, 32, 44, 52, 64, 76, 88, 96, 108 };
16471647
1648   state->m_lcd.state = param;
1648   m_lcd.state = param;
16491649
16501650   if ( LCDCONT & 0x80 )
16511651   {
1652      switch( state->m_lcd.state )
1652      switch( m_lcd.state )
16531653      {
16541654      case GB_LCD_STATE_LYXX_PRE_M0:   /* Just before switching to mode 0 */
1655         state->m_lcd.mode = 0;
1655         m_lcd.mode = 0;
16561656         if ( LCDSTAT & 0x08 )
16571657         {
1658            if ( ! state->m_lcd.mode_irq )
1658            if ( ! m_lcd.mode_irq )
16591659            {
1660               if ( ! state->m_lcd.line_irq && ! state->m_lcd.delayed_line_irq )
1660               if ( ! m_lcd.line_irq && ! m_lcd.delayed_line_irq )
16611661               {
1662                  state->m_lcd.mode_irq = 1;
1663                  machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1662                  m_lcd.mode_irq = 1;
1663                  machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
16641664               }
16651665            }
16661666            else
16671667            {
1668               state->m_lcd.mode_irq = 0;
1668               m_lcd.mode_irq = 0;
16691669            }
16701670         }
1671         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0);
1671         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0);
16721672         break;
16731673      case GB_LCD_STATE_LYXX_M0:      /* Switch to mode 0 */
16741674         /* update current scanline */
1675         (*state->update_scanline)( machine );
1675         (*update_scanline)( machine() );
16761676         /* Increment the number of window lines drawn if enabled */
1677         if ( state->m_lcd.layer[1].enabled )
1677         if ( m_lcd.layer[1].enabled )
16781678         {
1679            state->m_lcd.window_lines_drawn++;
1679            m_lcd.window_lines_drawn++;
16801680         }
1681         state->m_lcd.previous_line = state->m_lcd.current_line;
1681         m_lcd.previous_line = m_lcd.current_line;
16821682         /* Set Mode 0 lcdstate */
1683         state->m_lcd.mode = 0;
1683         m_lcd.mode = 0;
16841684         LCDSTAT &= 0xFC;
1685         state->m_lcd.oam_locked = UNLOCKED;
1686         state->m_lcd.vram_locked = UNLOCKED;
1685         m_lcd.oam_locked = UNLOCKED;
1686         m_lcd.vram_locked = UNLOCKED;
16871687         /*
16881688                There seems to a kind of feature in the Game Boy hardware when the lowest bits of the
16891689                SCROLLX register equals 3 or 7, then the delayed M0 irq is triggered 4 cycles later
16901690                than usual.
16911691                The SGB probably has the same bug.
16921692            */
1693         state->m_lcd.triggering_mode_irq = ( LCDSTAT & 0x08 ) ? 1 : 0;
1693         m_lcd.triggering_mode_irq = ( LCDSTAT & 0x08 ) ? 1 : 0;
16941694         if ( ( SCROLLX & 0x03 ) == 0x03 )
16951695         {
1696            state->m_lcd.scrollx_adjust += 4;
1697            state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_SCX3);
1696            m_lcd.scrollx_adjust += 4;
1697            m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_SCX3);
16981698            break;
16991699         }
17001700      case GB_LCD_STATE_LYXX_M0_SCX3:
17011701         /* Generate lcd interrupt if requested */
1702         if ( ! state->m_lcd.mode_irq && state->m_lcd.triggering_mode_irq &&
1703              ( ( ! state->m_lcd.line_irq && state->m_lcd.delayed_line_irq ) || ! ( LCDSTAT & 0x40 ) ) )
1702         if ( ! m_lcd.mode_irq && m_lcd.triggering_mode_irq &&
1703              ( ( ! m_lcd.line_irq && m_lcd.delayed_line_irq ) || ! ( LCDSTAT & 0x40 ) ) )
17041704         {
1705            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1706            state->m_lcd.triggering_mode_irq = 0;
1705            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1706            m_lcd.triggering_mode_irq = 0;
17071707         }
17081708         if ( ( SCROLLX & 0x03 ) == 0x03 )
17091709         {
1710            state->m_lcd.pal_locked = UNLOCKED;
1710            m_lcd.pal_locked = UNLOCKED;
17111711         }
1712         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_GBC_PAL);
1712         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_GBC_PAL);
17131713         break;
17141714      case GB_LCD_STATE_LYXX_M0_GBC_PAL:
1715         state->m_lcd.pal_locked = UNLOCKED;
1715         m_lcd.pal_locked = UNLOCKED;
17161716            /* Check for HBLANK DMA */
1717         if( state->m_lcd.hdma_enabled )
1717         if( m_lcd.hdma_enabled )
17181718         {
1719            gbc_hdma(machine, 0x10);
1719            gbc_hdma(machine(), 0x10);
17201720//              cpunum_set_reg( 0, LR35902_DMA_CYCLES, 36 );
17211721         }
17221722         else
17231723         {
1724            state->m_lcd.hdma_possible = 1;
1724            m_lcd.hdma_possible = 1;
17251725         }
1726         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(192 - state->m_lcd.scrollx_adjust - state->m_lcd.sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC);
1726         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(192 - m_lcd.scrollx_adjust - m_lcd.sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC);
17271727         break;
17281728      case GB_LCD_STATE_LYXX_M0_PRE_INC:   /* Just before incrementing the line counter go to mode 2 internally */
1729         state->m_lcd.cmp_line = CMPLINE;
1729         m_lcd.cmp_line = CMPLINE;
17301730         if ( CURLINE < 143 )
17311731         {
1732            state->m_lcd.mode = 2;
1732            m_lcd.mode = 2;
17331733            if ( LCDSTAT & 0x20 )
17341734            {
1735               if ( ! state->m_lcd.mode_irq )
1735               if ( ! m_lcd.mode_irq )
17361736               {
1737                  if ( ! state->m_lcd.line_irq && ! state->m_lcd.delayed_line_irq )
1737                  if ( ! m_lcd.line_irq && ! m_lcd.delayed_line_irq )
17381738                  {
1739                     state->m_lcd.mode_irq = 1;
1740                     machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1739                     m_lcd.mode_irq = 1;
1740                     machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
17411741                  }
17421742               }
17431743               else
17441744               {
1745                  state->m_lcd.mode_irq = 0;
1745                  m_lcd.mode_irq = 0;
17461746               }
17471747            }
17481748         }
1749         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_INC);
1749         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_INC);
17501750         break;
17511751      case GB_LCD_STATE_LYXX_M0_INC:   /* Increment LY, stay in M0 for 4 more cycles */
1752         gb_increment_scanline(state);
1753         state->m_lcd.delayed_line_irq = state->m_lcd.line_irq;
1754         state->m_lcd.triggering_line_irq = ( ( state->m_lcd.cmp_line == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0;
1755         state->m_lcd.line_irq = 0;
1756         if ( ! state->m_lcd.mode_irq && ! state->m_lcd.delayed_line_irq && state->m_lcd.triggering_line_irq && ! ( LCDSTAT & 0x20 ) )
1752         gb_increment_scanline(this);
1753         m_lcd.delayed_line_irq = m_lcd.line_irq;
1754         m_lcd.triggering_line_irq = ( ( m_lcd.cmp_line == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0;
1755         m_lcd.line_irq = 0;
1756         if ( ! m_lcd.mode_irq && ! m_lcd.delayed_line_irq && m_lcd.triggering_line_irq && ! ( LCDSTAT & 0x20 ) )
17571757         {
1758            state->m_lcd.line_irq = state->m_lcd.triggering_line_irq;
1759            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1758            m_lcd.line_irq = m_lcd.triggering_line_irq;
1759            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
17601760         }
1761         state->m_lcd.hdma_possible = 0;
1761         m_lcd.hdma_possible = 0;
17621762         /* Check if we're going into VBlank next */
17631763         if ( CURLINE == 144 )
17641764         {
1765            state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1);
1765            m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1);
17661766         }
17671767         else
17681768         {
17691769            /* Internally switch to mode 2 */
1770            state->m_lcd.mode = 2;
1770            m_lcd.mode = 2;
17711771            /* Generate lcd interrupt if requested */
1772            if ( ! state->m_lcd.mode_irq && ( LCDSTAT & 0x20 ) &&
1773                ( ( ! state->m_lcd.triggering_line_irq && ! state->m_lcd.delayed_line_irq ) || ! ( LCDSTAT & 0x40 ) ) )
1772            if ( ! m_lcd.mode_irq && ( LCDSTAT & 0x20 ) &&
1773                ( ( ! m_lcd.triggering_line_irq && ! m_lcd.delayed_line_irq ) || ! ( LCDSTAT & 0x40 ) ) )
17741774            {
1775               state->m_lcd.mode_irq = 1;
1776               machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1775               m_lcd.mode_irq = 1;
1776               machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
17771777            }
1778            state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M2);
1778            m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M2);
17791779         }
17801780         break;
17811781      case GB_LCD_STATE_LY00_M2:      /* Switch to mode 2 on line #0 */
17821782         /* Set Mode 2 lcdstate */
1783         state->m_lcd.mode = 2;
1783         m_lcd.mode = 2;
17841784         LCDSTAT = ( LCDSTAT & 0xFC ) | 0x02;
1785         state->m_lcd.oam_locked = LOCKED;
1785         m_lcd.oam_locked = LOCKED;
17861786         /* Generate lcd interrupt if requested */
1787         if ( ( LCDSTAT & 0x20 ) && ! state->m_lcd.line_irq )
1787         if ( ( LCDSTAT & 0x20 ) && ! m_lcd.line_irq )
17881788         {
1789            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1789            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
17901790         }
17911791         /* Check for regular compensation of x-scroll register */
1792         state->m_lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0;
1792         m_lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0;
17931793         /* Mode 2 lasts approximately 80 clock cycles */
1794         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3);
1794         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3);
17951795         break;
17961796      case GB_LCD_STATE_LYXX_M2:      /* Switch to mode 2 */
17971797         /* Update STAT register to the correct state */
17981798         LCDSTAT = (LCDSTAT & 0xFC) | 0x02;
1799         state->m_lcd.oam_locked = LOCKED;
1799         m_lcd.oam_locked = LOCKED;
18001800         /* Generate lcd interrupt if requested */
1801         if ( ( state->m_lcd.delayed_line_irq && state->m_lcd.triggering_line_irq && ! ( LCDSTAT & 0x20 ) ) ||
1802             ( !state->m_lcd.mode_irq && ! state->m_lcd.line_irq && ! state->m_lcd.delayed_line_irq && ( LCDSTAT & 0x20 ) ) )
1801         if ( ( m_lcd.delayed_line_irq && m_lcd.triggering_line_irq && ! ( LCDSTAT & 0x20 ) ) ||
1802             ( !m_lcd.mode_irq && ! m_lcd.line_irq && ! m_lcd.delayed_line_irq && ( LCDSTAT & 0x20 ) ) )
18031803         {
1804            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1804            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
18051805         }
1806         state->m_lcd.line_irq = state->m_lcd.triggering_line_irq;
1806         m_lcd.line_irq = m_lcd.triggering_line_irq;
18071807         /* Check if LY==LYC STAT bit should be set */
18081808         if ( CURLINE == CMPLINE )
18091809         {
r18113r18114
18141814            LCDSTAT &= ~0x04;
18151815         }
18161816         /* Check for regular compensation of x-scroll register */
1817         state->m_lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0;
1817         m_lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0;
18181818         /* Mode 2 last for approximately 80 clock cycles */
1819         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3);
1819         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3);
18201820         break;
18211821      case GB_LCD_STATE_LYXX_M3:      /* Switch to mode 3 */
1822         gb_select_sprites(state);
1823         state->m_lcd.sprite_cycles = sprite_cycles[ state->m_lcd.sprCount ];
1822         gb_select_sprites(this);
1823         m_lcd.sprite_cycles = sprite_cycles[ m_lcd.sprCount ];
18241824         /* Set Mode 3 lcdstate */
1825         state->m_lcd.mode = 3;
1825         m_lcd.mode = 3;
18261826         LCDSTAT = (LCDSTAT & 0xFC) | 0x03;
1827         state->m_lcd.vram_locked = LOCKED;
1828         state->m_lcd.pal_locked = LOCKED;
1827         m_lcd.vram_locked = LOCKED;
1828         m_lcd.pal_locked = LOCKED;
18291829         /* Check for compensations of x-scroll register */
18301830         /* Mode 3 lasts for approximately 172+cycles needed to handle sprites clock cycles */
1831         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(168 + state->m_lcd.scrollx_adjust + state->m_lcd.sprite_cycles), GB_LCD_STATE_LYXX_PRE_M0);
1832         state->m_lcd.start_x = -1;
1831         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(168 + m_lcd.scrollx_adjust + m_lcd.sprite_cycles), GB_LCD_STATE_LYXX_PRE_M0);
1832         m_lcd.start_x = -1;
18331833         break;
18341834      case GB_LCD_STATE_LY9X_M1:      /* Switch to or stay in mode 1 */
18351835         if ( CURLINE == 144 )
18361836         {
18371837            /* Trigger VBlank interrupt */
1838            machine.device("maincpu")->execute().set_input_line(VBL_INT, ASSERT_LINE );
1838            machine().device("maincpu")->execute().set_input_line(VBL_INT, ASSERT_LINE );
18391839            /* Set VBlank lcdstate */
1840            state->m_lcd.mode = 1;
1840            m_lcd.mode = 1;
18411841            LCDSTAT = (LCDSTAT & 0xFC) | 0x01;
18421842            /* Trigger LCD interrupt if requested */
18431843            if ( LCDSTAT & 0x10 )
18441844            {
1845               machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1845               machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
18461846            }
18471847         }
18481848         /* Check if LY==LYC STAT bit should be set */
r18113r18114
18541854         {
18551855            LCDSTAT &= ~0x04;
18561856         }
1857         if ( state->m_lcd.delayed_line_irq && state->m_lcd.triggering_line_irq )
1857         if ( m_lcd.delayed_line_irq && m_lcd.triggering_line_irq )
18581858         {
1859            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1859            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
18601860         }
1861         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(452), GB_LCD_STATE_LY9X_M1_INC);
1861         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(452), GB_LCD_STATE_LY9X_M1_INC);
18621862         break;
18631863      case GB_LCD_STATE_LY9X_M1_INC:      /* Increment scanline counter */
1864         gb_increment_scanline(state);
1865         state->m_lcd.delayed_line_irq = state->m_lcd.line_irq;
1866         state->m_lcd.triggering_line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0;
1867         state->m_lcd.line_irq = 0;
1868         if ( ! state->m_lcd.delayed_line_irq && state->m_lcd.triggering_line_irq )
1864         gb_increment_scanline(this);
1865         m_lcd.delayed_line_irq = m_lcd.line_irq;
1866         m_lcd.triggering_line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0;
1867         m_lcd.line_irq = 0;
1868         if ( ! m_lcd.delayed_line_irq && m_lcd.triggering_line_irq )
18691869         {
1870            state->m_lcd.line_irq = state->m_lcd.triggering_line_irq;
1871            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1870            m_lcd.line_irq = m_lcd.triggering_line_irq;
1871            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
18721872         }
1873         if ( state->m_lcd.current_line == 153 )
1873         if ( m_lcd.current_line == 153 )
18741874         {
1875            state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1);
1875            m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1);
18761876         }
18771877         else
18781878         {
1879            state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1);
1879            m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1);
18801880         }
18811881         break;
18821882      case GB_LCD_STATE_LY00_M1:      /* we stay in VBlank but current line counter should already be incremented */
18831883         /* Check LY=LYC for line #153 */
1884         if ( state->m_lcd.delayed_line_irq )
1884         if ( m_lcd.delayed_line_irq )
18851885         {
1886            if ( state->m_lcd.triggering_line_irq )
1886            if ( m_lcd.triggering_line_irq )
18871887            {
1888               machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1888               machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
18891889            }
18901890         }
1891         state->m_lcd.delayed_line_irq = state->m_lcd.delayed_line_irq | state->m_lcd.line_irq;
1891         m_lcd.delayed_line_irq = m_lcd.delayed_line_irq | m_lcd.line_irq;
18921892         if ( CURLINE == CMPLINE )
18931893         {
18941894            LCDSTAT |= 0x04;
r18113r18114
18971897         {
18981898            LCDSTAT &= ~0x04;
18991899         }
1900         gb_increment_scanline(state);
1901         state->m_lcd.triggering_line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0;
1902         state->m_lcd.line_irq = 0;
1900         gb_increment_scanline(this);
1901         m_lcd.triggering_line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0;
1902         m_lcd.line_irq = 0;
19031903         LCDSTAT &= 0xFB;
1904         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_1);
1904         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_1);
19051905         break;
19061906      case GB_LCD_STATE_LY00_M1_1:
1907         if ( ! state->m_lcd.delayed_line_irq && state->m_lcd.triggering_line_irq )
1907         if ( ! m_lcd.delayed_line_irq && m_lcd.triggering_line_irq )
19081908         {
1909            state->m_lcd.line_irq = state->m_lcd.triggering_line_irq;
1910            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1909            m_lcd.line_irq = m_lcd.triggering_line_irq;
1910            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
19111911         }
1912         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_2);
1912         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_2);
19131913         break;
19141914      case GB_LCD_STATE_LY00_M1_2:   /* Rest of line #0 during VBlank */
1915         if ( state->m_lcd.delayed_line_irq && state->m_lcd.triggering_line_irq )
1915         if ( m_lcd.delayed_line_irq && m_lcd.triggering_line_irq )
19161916         {
1917            state->m_lcd.line_irq = state->m_lcd.triggering_line_irq;
1918            machine.device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
1917            m_lcd.line_irq = m_lcd.triggering_line_irq;
1918            machine().device("maincpu")->execute().set_input_line(LCD_INT, ASSERT_LINE );
19191919         }
19201920         if ( CURLINE == CMPLINE )
19211921         {
r18113r18114
19251925         {
19261926            LCDSTAT &= ~0x04;
19271927         }
1928         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(444), GB_LCD_STATE_LY00_M0);
1928         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(444), GB_LCD_STATE_LY00_M0);
19291929         break;
19301930      case GB_LCD_STATE_LY00_M0:      /* The STAT register seems to go to 0 for about 4 cycles */
19311931         /* Set Mode 0 lcdstat */
1932         state->m_lcd.mode = 0;
1933         state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M2);
1932         m_lcd.mode = 0;
1933         m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M2);
19341934         break;
19351935      }
19361936   }
19371937   else
19381938   {
1939      gb_increment_scanline(state);
1940      if ( state->m_lcd.current_line < 144 )
1939      gb_increment_scanline(this);
1940      if ( m_lcd.current_line < 144 )
19411941      {
1942         (*state->update_scanline)( machine );
1942         (*update_scanline)( machine() );
19431943      }
1944      state->m_lcd.lcd_timer->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(456));
1944      m_lcd.lcd_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(456));
19451945   }
19461946}
19471947
trunk/src/mess/video/fm7.c
r18113r18114
9494   m_video.vram_access = 0;
9595}
9696
97static TIMER_CALLBACK( fm77av_alu_task_end )
97TIMER_CALLBACK_MEMBER(fm7_state::fm77av_alu_task_end)
9898{
99   fm7_state *state = machine.driver_data<fm7_state>();
100   state->m_alu.busy = 0;
99   m_alu.busy = 0;
101100}
102101
103102static void fm7_alu_mask_write(fm7_state *state, UINT32 offset, int bank, UINT8 dat)
r18113r18114
628627
629628   // set timer to disable busy flag
630629   // 1/16 us for each byte changed
631   machine.scheduler().timer_set(attotime::from_usec(byte_count/16), FUNC(fm77av_alu_task_end));
630   machine.scheduler().timer_set(attotime::from_usec(byte_count/16), timer_expired_delegate(FUNC(fm7_state::fm77av_alu_task_end),state));
632631}
633632
634633READ8_MEMBER(fm7_state::fm7_vram_r)
r18113r18114
13501349   }
13511350}
13521351
1353TIMER_CALLBACK( fm77av_vsync )
1352TIMER_CALLBACK_MEMBER(fm7_state::fm77av_vsync)
13541353{
1355   fm7_state *state = machine.driver_data<fm7_state>();
13561354   if(param == 0)  // start of vsync
13571355   {
1358      state->m_video.vsync_flag = 1;
1359      state->m_fm77av_vsync_timer->adjust(attotime::from_usec(510),1);  // VSync length for 200 line modes = 0.51ms
1356      m_video.vsync_flag = 1;
1357      m_fm77av_vsync_timer->adjust(attotime::from_usec(510),1);  // VSync length for 200 line modes = 0.51ms
13601358   }
13611359   else
13621360   {
1363      state->m_video.vsync_flag = 0;
1364      state->m_fm77av_vsync_timer->adjust(machine.primary_screen->time_until_vblank_end());
1361      m_video.vsync_flag = 0;
1362      m_fm77av_vsync_timer->adjust(machine().primary_screen->time_until_vblank_end());
13651363   }
13661364}
13671365
trunk/src/mess/video/samcoupe.c
r18113r18114
125125   draw_mode12_block(state, state->m_bitmap, y, hpos, mask);
126126}
127127
128TIMER_CALLBACK( sam_video_update_callback )
128TIMER_CALLBACK_MEMBER(samcoupe_state::sam_video_update_callback)
129129{
130   samcoupe_state *state = machine.driver_data<samcoupe_state>();
131   int vpos = machine.primary_screen->vpos();
132   int hpos = machine.primary_screen->hpos();
130   int vpos = machine().primary_screen->vpos();
131   int hpos = machine().primary_screen->hpos();
133132
134133   int next_vpos = vpos;
135134   int next_hpos = hpos + SAM_BLOCK*2;
r18113r18114
142141   }
143142
144143   /* display disabled? (only in mode 3 or 4) */
145   if (BIT(state->m_vmpr, 6) && BIT(state->m_border, 7))
144   if (BIT(m_vmpr, 6) && BIT(m_border, 7))
146145   {
147      state->m_bitmap.plot_box(hpos, vpos, SAM_BLOCK*2, 1, 0);
146      m_bitmap.plot_box(hpos, vpos, SAM_BLOCK*2, 1, 0);
148147   }
149148   else
150149   {
151150      /* border area? */
152151      if (vpos < SAM_BORDER_TOP || vpos >= SAM_BORDER_TOP + SAM_SCREEN_HEIGHT || hpos < SAM_BORDER_LEFT || hpos >= SAM_BORDER_LEFT + SAM_SCREEN_WIDTH)
153152      {
154         state->m_attribute = 0xff;
155         state->m_bitmap.plot_box(hpos, vpos, SAM_BLOCK*2, 1, state->m_clut[BORDER_COLOR(state->m_border)]);
153         m_attribute = 0xff;
154         m_bitmap.plot_box(hpos, vpos, SAM_BLOCK*2, 1, m_clut[BORDER_COLOR(m_border)]);
156155      }
157156      else
158157      {
159158         /* main screen area */
160         switch ((state->m_vmpr & 0x60) >> 5)
159         switch ((m_vmpr & 0x60) >> 5)
161160         {
162         case 0:   draw_mode1_line(machine, vpos, hpos); break;
163         case 1:   draw_mode2_line(machine, vpos, hpos); break;
164         case 2:   draw_mode3_line(machine, vpos, hpos); break;
165         case 3:   draw_mode4_line(machine, vpos, hpos); break;
161         case 0:   draw_mode1_line(machine(), vpos, hpos); break;
162         case 1:   draw_mode2_line(machine(), vpos, hpos); break;
163         case 2:   draw_mode3_line(machine(), vpos, hpos); break;
164         case 3:   draw_mode4_line(machine(), vpos, hpos); break;
166165         }
167166      }
168167   }
169168
170169   /* do we need to trigger the scanline interrupt (interrupt happens at the start of the right border before the specified line)? */
171   if (state->m_line_int < SAM_SCREEN_HEIGHT && hpos == SAM_BORDER_LEFT + SAM_SCREEN_WIDTH && vpos == (state->m_line_int + SAM_BORDER_TOP - 1))
172      samcoupe_irq(machine.firstcpu, SAM_LINE_INT);
170   if (m_line_int < SAM_SCREEN_HEIGHT && hpos == SAM_BORDER_LEFT + SAM_SCREEN_WIDTH && vpos == (m_line_int + SAM_BORDER_TOP - 1))
171      samcoupe_irq(machine().firstcpu, SAM_LINE_INT);
173172
174173   /* schedule next update */
175   state->m_video_update_timer->adjust(machine.primary_screen->time_until_pos(next_vpos, next_hpos));
174   m_video_update_timer->adjust(machine().primary_screen->time_until_pos(next_vpos, next_hpos));
176175}
trunk/src/mess/video/odyssey2.c
r18113r18114
249249   return 0;
250250}
251251
252static TIMER_CALLBACK( i824x_scanline_callback )
252TIMER_CALLBACK_MEMBER(odyssey2_state::i824x_scanline_callback)
253253{
254   odyssey2_state *state = machine.driver_data<odyssey2_state>();
255254   UINT8   collision_map[160];
256   int      vpos = machine.primary_screen->vpos();
255   int      vpos = machine().primary_screen->vpos();
257256
258   if ( vpos < state->m_start_vpos )
257   if ( vpos < m_start_vpos )
259258      return;
260259
261   if ( vpos == state->m_start_vpos )
260   if ( vpos == m_start_vpos )
262261   {
263      state->m_control_status &= ~0x08;
262      m_control_status &= ~0x08;
264263   }
265264
266   if ( vpos < state->m_start_vblank )
265   if ( vpos < m_start_vblank )
267266   {
268267      rectangle rect;
269268      //static const int sprite_width[4] = { 8, 8, 8, 8 };
270269      int i;
271270
272      state->m_control_status &= ~ 0x01;
271      m_control_status &= ~ 0x01;
273272
274273      /* Draw a line */
275274      rect.set(I824X_START_ACTIVE_SCAN, I824X_END_ACTIVE_SCAN - 1, vpos, vpos);
276      state->m_tmp_bitmap.fill(( (state->m_o2_vdc.s.color >> 3) & 0x7 ) | ( ( state->m_lum << 3 ) ^ 0x08 ), rect );
275      m_tmp_bitmap.fill(( (m_o2_vdc.s.color >> 3) & 0x7 ) | ( ( m_lum << 3 ) ^ 0x08 ), rect );
277276
278277      /* Clear collision map */
279278      memset( collision_map, 0, sizeof( collision_map ) );
280279
281280      /* Display grid if enabled */
282      if ( state->m_o2_vdc.s.control & 0x08 )
281      if ( m_o2_vdc.s.control & 0x08 )
283282      {
284         UINT16   color = ( state->m_o2_vdc.s.color & 7 ) | ( ( state->m_o2_vdc.s.color >> 3 ) & 0x08 ) | ( ( state->m_lum << 3 ) ^ 0x08 );
283         UINT16   color = ( m_o2_vdc.s.color & 7 ) | ( ( m_o2_vdc.s.color >> 3 ) & 0x08 ) | ( ( m_lum << 3 ) ^ 0x08 );
285284         int      x_grid_offset = 8;
286285         int    y_grid_offset = 24;
287286         int      width = 16;
288287         int      height = 24;
289         int      w = ( state->m_o2_vdc.s.control & 0x80 ) ? width : 2;
288         int      w = ( m_o2_vdc.s.control & 0x80 ) ? width : 2;
290289         int      j, k, y;
291290
292291         /* Draw horizontal part of grid */
293292         for ( j = 1, y = 0; y < 9; y++, j <<= 1 )
294293         {
295            if ( y_grid_offset + y * height <= ( vpos - state->m_start_vpos ) && ( vpos - state->m_start_vpos ) < y_grid_offset + y * height + 3 )
294            if ( y_grid_offset + y * height <= ( vpos - m_start_vpos ) && ( vpos - m_start_vpos ) < y_grid_offset + y * height + 3 )
296295            {
297296               for ( i = 0; i < 9; i++ )
298297               {
299                  if ( ( state->m_o2_vdc.s.hgrid[0][i] & j ) || ( state->m_o2_vdc.s.hgrid[1][i] & ( j >> 8 ) ) )
298                  if ( ( m_o2_vdc.s.hgrid[0][i] & j ) || ( m_o2_vdc.s.hgrid[1][i] & ( j >> 8 ) ) )
300299                  {
301300                     for ( k = 0; k < width + 2; k++ )
302301                     {
303302                        int px = x_grid_offset + i * width + k;
304303                        collision_map[ px ] |= COLLISION_HORIZ_GRID_DOTS;
305                        state->m_tmp_bitmap.pix16(vpos, I824X_START_ACTIVE_SCAN + px ) = color;
304                        m_tmp_bitmap.pix16(vpos, I824X_START_ACTIVE_SCAN + px ) = color;
306305                     }
307306                  }
308307               }
r18113r18114
312311         /* Draw vertical part of grid */
313312         for( j = 1, y = 0; y < 8; y++, j <<= 1 )
314313         {
315            if ( y_grid_offset + y * height <= ( vpos - state->m_start_vpos ) && ( vpos - state->m_start_vpos ) < y_grid_offset + ( y + 1 ) * height )
314            if ( y_grid_offset + y * height <= ( vpos - m_start_vpos ) && ( vpos - m_start_vpos ) < y_grid_offset + ( y + 1 ) * height )
316315            {
317316               for ( i = 0; i < 10; i++ )
318317               {
319                  if ( state->m_o2_vdc.s.vgrid[i] & j )
318                  if ( m_o2_vdc.s.vgrid[i] & j )
320319                  {
321320                     for ( k = 0; k < w; k++ )
322321                     {
323322                        int px = x_grid_offset + i * width + k;
324323
325324                        /* Check if we collide with an already drawn source object */
326                        if ( collision_map[ px ] & state->m_o2_vdc.s.collision )
325                        if ( collision_map[ px ] & m_o2_vdc.s.collision )
327326                        {
328                           state->m_collision_status |= COLLISION_VERTICAL_GRID;
327                           m_collision_status |= COLLISION_VERTICAL_GRID;
329328                        }
330329                        /* Check if an already drawn object would collide with us */
331                        if ( COLLISION_VERTICAL_GRID & state->m_o2_vdc.s.collision && collision_map[ px ] )
330                        if ( COLLISION_VERTICAL_GRID & m_o2_vdc.s.collision && collision_map[ px ] )
332331                        {
333                           state->m_collision_status |= collision_map[ px ];
332                           m_collision_status |= collision_map[ px ];
334333                        }
335334                        collision_map[ px ] |= COLLISION_VERTICAL_GRID;
336                        state->m_tmp_bitmap.pix16(vpos, I824X_START_ACTIVE_SCAN + px ) = color;
335                        m_tmp_bitmap.pix16(vpos, I824X_START_ACTIVE_SCAN + px ) = color;
337336                     }
338337                  }
339338               }
r18113r18114
342341      }
343342
344343      /* Display objects if enabled */
345      if ( state->m_o2_vdc.s.control & 0x20 )
344      if ( m_o2_vdc.s.control & 0x20 )
346345      {
347346         /* Regular foreground objects */
348         for ( i = 0; i < ARRAY_LENGTH( state->m_o2_vdc.s.foreground ); i++ )
347         for ( i = 0; i < ARRAY_LENGTH( m_o2_vdc.s.foreground ); i++ )
349348         {
350            int   y = state->m_o2_vdc.s.foreground[i].y;
351            int   height = 8 - ( ( ( y >> 1 ) + state->m_o2_vdc.s.foreground[i].ptr ) & 7 );
349            int   y = m_o2_vdc.s.foreground[i].y;
350            int   height = 8 - ( ( ( y >> 1 ) + m_o2_vdc.s.foreground[i].ptr ) & 7 );
352351
353            if ( y <= ( vpos - state->m_start_vpos ) && ( vpos - state->m_start_vpos ) < y + height * 2 )
352            if ( y <= ( vpos - m_start_vpos ) && ( vpos - m_start_vpos ) < y + height * 2 )
354353            {
355               UINT16   color = 16 + ( ( state->m_o2_vdc.s.foreground[i].color & 0x0E ) >> 1 );
356               int      offset = ( state->m_o2_vdc.s.foreground[i].ptr | ( ( state->m_o2_vdc.s.foreground[i].color & 0x01 ) << 8 ) ) + ( y >> 1 ) + ( ( vpos - state->m_start_vpos - y ) >> 1 );
354               UINT16   color = 16 + ( ( m_o2_vdc.s.foreground[i].color & 0x0E ) >> 1 );
355               int      offset = ( m_o2_vdc.s.foreground[i].ptr | ( ( m_o2_vdc.s.foreground[i].color & 0x01 ) << 8 ) ) + ( y >> 1 ) + ( ( vpos - m_start_vpos - y ) >> 1 );
357356               UINT8   chr = ((char*)o2_shape)[ offset & 0x1FF ];
358               int      x = state->m_o2_vdc.s.foreground[i].x;
357               int      x = m_o2_vdc.s.foreground[i].x;
359358               UINT8   m;
360359
361360               for ( m = 0x80; m > 0; m >>= 1, x++ )
r18113r18114
365364                     if ( x >= 0 && x < 160 )
366365                     {
367366                        /* Check if we collide with an already drawn source object */
368                        if ( collision_map[ x ] & state->m_o2_vdc.s.collision )
367                        if ( collision_map[ x ] & m_o2_vdc.s.collision )
369368                        {
370                           state->m_collision_status |= COLLISION_CHARACTERS;
369                           m_collision_status |= COLLISION_CHARACTERS;
371370                        }
372371                        /* Check if an already drawn object would collide with us */
373                        if ( COLLISION_CHARACTERS & state->m_o2_vdc.s.collision && collision_map[ x ] )
372                        if ( COLLISION_CHARACTERS & m_o2_vdc.s.collision && collision_map[ x ] )
374373                        {
375                           state->m_collision_status |= collision_map[ x ];
374                           m_collision_status |= collision_map[ x ];
376375                        }
377376                        collision_map[ x ] |= COLLISION_CHARACTERS;
378                        state->m_tmp_bitmap.pix16(vpos, I824X_START_ACTIVE_SCAN + x ) = color;
377                        m_tmp_bitmap.pix16(vpos, I824X_START_ACTIVE_SCAN + x ) = color;
379378                     }
380379                  }
381380               }
r18113r18114
383382         }
384383
385384         /* Quad objects */
386         for ( i = 0; i < ARRAY_LENGTH( state->m_o2_vdc.s.quad ); i++ )
385         for ( i = 0; i < ARRAY_LENGTH( m_o2_vdc.s.quad ); i++ )
387386         {
388            int y = state->m_o2_vdc.s.quad[i].single[0].y;
387            int y = m_o2_vdc.s.quad[i].single[0].y;
389388            int height = 8;
390389
391            if ( y <= ( vpos - state->m_start_vpos ) && ( vpos - state->m_start_vpos ) < y + height * 2 )
390            if ( y <= ( vpos - m_start_vpos ) && ( vpos - m_start_vpos ) < y + height * 2 )
392391            {
393               int   x = state->m_o2_vdc.s.quad[i].single[0].x;
392               int   x = m_o2_vdc.s.quad[i].single[0].x;
394393               int j;
395394
396395               // Charaecter height is always determined by the height of the 4th character
397               int char_height = 8 - ( ( ( y >> 1 ) + state->m_o2_vdc.s.quad[i].single[3].ptr ) & 7 );
396               int char_height = 8 - ( ( ( y >> 1 ) + m_o2_vdc.s.quad[i].single[3].ptr ) & 7 );
398397
399               for ( j = 0; j < ARRAY_LENGTH( state->m_o2_vdc.s.quad[0].single ); j++, x += 8 )
398               for ( j = 0; j < ARRAY_LENGTH( m_o2_vdc.s.quad[0].single ); j++, x += 8 )
400399               {
401400
402401
403                  if ( y <= ( vpos - state->m_start_vpos ) && ( vpos - state->m_start_vpos ) < y + char_height * 2 )
402                  if ( y <= ( vpos - m_start_vpos ) && ( vpos - m_start_vpos ) < y + char_height * 2 )
404403                  {
405404
406                  UINT16 color = 16 + ( ( state->m_o2_vdc.s.quad[i].single[j].color & 0x0E ) >> 1 );
405                  UINT16 color = 16 + ( ( m_o2_vdc.s.quad[i].single[j].color & 0x0E ) >> 1 );
407406
408407
409                     int   offset = ( state->m_o2_vdc.s.quad[i].single[j].ptr | ( ( state->m_o2_vdc.s.quad[i].single[j].color & 0x01 ) << 8 ) ) + ( y >> 1 ) + ( ( vpos - state->m_start_vpos - y ) >> 1 );
408                     int   offset = ( m_o2_vdc.s.quad[i].single[j].ptr | ( ( m_o2_vdc.s.quad[i].single[j].color & 0x01 ) << 8 ) ) + ( y >> 1 ) + ( ( vpos - m_start_vpos - y ) >> 1 );
410409
411410                     UINT8   chr = ((char*)o2_shape)[ offset & 0x1FF ];
412411
r18113r18114
418417                           if ( x >= 0 && x < 160 )
419418                           {
420419                              /* Check if we collide with an already drawn source object */
421                              if ( collision_map[ x ] & state->m_o2_vdc.s.collision )
420                              if ( collision_map[ x ] & m_o2_vdc.s.collision )
422421                              {
423                                 state->m_collision_status |= COLLISION_CHARACTERS;
422                                 m_collision_status |= COLLISION_CHARACTERS;
424423                              }
425424                              /* Check if an already drawn object would collide with us */
426                              if ( COLLISION_CHARACTERS & state->m_o2_vdc.s.collision && collision_map[ x ] )
425                              if ( COLLISION_CHARACTERS & m_o2_vdc.s.collision && collision_map[ x ] )
427426                              {
428                                 state->m_collision_status |= collision_map[ x ];
427                                 m_collision_status |= collision_map[ x ];
429428                              }
430429                              collision_map[ x ] |= COLLISION_CHARACTERS;
431                              state->m_tmp_bitmap.pix16(vpos, I824X_START_ACTIVE_SCAN + x ) = color;
430                              m_tmp_bitmap.pix16(vpos, I824X_START_ACTIVE_SCAN + x ) = color;
432431                           }
433432                        }
434433                     }
r18113r18114
442441         }
443442
444443         /* Sprites */
445         for ( i = 0; i < ARRAY_LENGTH( state->m_o2_vdc.s.sprites ); i++ )
444         for ( i = 0; i < ARRAY_LENGTH( m_o2_vdc.s.sprites ); i++ )
446445         {
447            int y = state->m_o2_vdc.s.sprites[i].y;
446            int y = m_o2_vdc.s.sprites[i].y;
448447            int height = 8;
449            if ( state->m_o2_vdc.s.sprites[i].color & 4 )
448            if ( m_o2_vdc.s.sprites[i].color & 4 )
450449            {
451450               /* Zoomed sprite */
452451               //sprite_width[i] = 16;
453               if ( y <= ( vpos - state->m_start_vpos ) && ( vpos - state->m_start_vpos ) < y + height * 4 )
452               if ( y <= ( vpos - m_start_vpos ) && ( vpos - m_start_vpos ) < y + height * 4 )
454453               {
455                  UINT16 color = 16 + ( ( state->m_o2_vdc.s.sprites[i].color >> 3 ) & 0x07 );
456                  UINT8   chr = state->m_o2_vdc.s.shape[i][ ( ( vpos - state->m_start_vpos - y ) >> 2 ) ];
457                  int      x = state->m_o2_vdc.s.sprites[i].x;
454                  UINT16 color = 16 + ( ( m_o2_vdc.s.sprites[i].color >> 3 ) & 0x07 );
455                  UINT8   chr = m_o2_vdc.s.shape[i][ ( ( vpos - m_start_vpos - y ) >> 2 ) ];
456                  int      x = m_o2_vdc.s.sprites[i].x;
458457                  UINT8   m;
459458
460459                  for ( m = 0x01; m > 0; m <<= 1, x += 2 )
r18113r18114
464463                        if ( x >= 0 && x < 160 )
465464                        {
466465                           /* Check if we collide with an already drawn source object */
467                           if ( collision_map[ x ] & state->m_o2_vdc.s.collision )
466                           if ( collision_map[ x ] & m_o2_vdc.s.collision )
468467                           {
469                              state->m_collision_status |= ( 1 << i );
468                              m_collision_status |= ( 1 << i );
470469                           }
471470                           /* Check if an already drawn object would collide with us */
472                           if ( ( 1 << i ) & state->m_o2_vdc.s.collision && collision_map[ x ] )
471                           if ( ( 1 << i ) & m_o2_vdc.s.collision && collision_map[ x ] )
473472                           {
474                              state->m_collision_status |= collision_map[ x ];
473                              m_collision_status |= collision_map[ x ];
475474                           }
476475                           collision_map[ x ] |= ( 1 << i );
477                           state->m_tmp_bitmap.pix16(vpos, I824X_START_ACTIVE_SCAN + x ) = color;
476                           m_tmp_bitmap.pix16(vpos, I824X_START_ACTIVE_SCAN + x ) = color;
478477                        }
479478                        if ( x >= -1 && x < 159 )
480479                        {
481480                           /* Check if we collide with an already drawn source object */
482                           if ( collision_map[ x ] & state->m_o2_vdc.s.collision )
481                           if ( collision_map[ x ] & m_o2_vdc.s.collision )
483482                           {
484                              state->m_collision_status |= ( 1 << i );
483                              m_collision_status |= ( 1 << i );
485484                           }
486485                           /* Check if an already drawn object would collide with us */
487                           if ( ( 1 << i ) & state->m_o2_vdc.s.collision && collision_map[ x ] )
486                           if ( ( 1 << i ) & m_o2_vdc.s.collision && collision_map[ x ] )
488487                           {
489                              state->m_collision_status |= collision_map[ x ];
488                              m_collision_status |= collision_map[ x ];
490489                           }
491490                           collision_map[ x ] |= ( 1 << i );
492                           state->m_tmp_bitmap.pix16(vpos, I824X_START_ACTIVE_SCAN + x + 1 ) = color;
491                           m_tmp_bitmap.pix16(vpos, I824X_START_ACTIVE_SCAN + x + 1 ) = color;
493492                        }
494493                     }
495494                  }
r18113r18114
498497            else
499498            {
500499               /* Regular sprite */
501               if ( y <= ( vpos - state->m_start_vpos ) && ( vpos - state->m_start_vpos ) < y + height * 2 )
500               if ( y <= ( vpos - m_start_vpos ) && ( vpos - m_start_vpos ) < y + height * 2 )
502501               {
503                  UINT16 color = 16 + ( ( state->m_o2_vdc.s.sprites[i].color >> 3 ) & 0x07 );
504                  UINT8   chr = state->m_o2_vdc.s.shape[i][ ( ( vpos - state->m_start_vpos - y ) >> 1 ) ];
505                  int      x = state->m_o2_vdc.s.sprites[i].x;
502                  UINT16 color = 16 + ( ( m_o2_vdc.s.sprites[i].color >> 3 ) & 0x07 );
503                  UINT8   chr = m_o2_vdc.s.shape[i][ ( ( vpos - m_start_vpos - y ) >> 1 ) ];
504                  int      x = m_o2_vdc.s.sprites[i].x;
506505                  UINT8   m;
507506
508507                  for ( m = 0x01; m > 0; m <<= 1, x++ )
r18113r18114
512511                        if ( x >= 0 && x < 160 )
513512                        {
514513                           /* Check if we collide with an already drawn source object */
515                           if ( collision_map[ x ] & state->m_o2_vdc.s.collision )
514                           if ( collision_map[ x ] & m_o2_vdc.s.collision )
516515                           {
517                              state->m_collision_status |= ( 1 << i );
516                              m_collision_status |= ( 1 << i );
518517                           }
519518                           /* Check if an already drawn object would collide with us */
520                           if ( ( 1 << i ) & state->m_o2_vdc.s.collision && collision_map[ x ] )
519                           if ( ( 1 << i ) & m_o2_vdc.s.collision && collision_map[ x ] )
521520                           {
522                              state->m_collision_status |= collision_map[ x ];
521                              m_collision_status |= collision_map[ x ];
523522                           }
524523                           collision_map[ x ] |= ( 1 << i );
525                           state->m_tmp_bitmap.pix16(vpos, I824X_START_ACTIVE_SCAN + x ) = color;
524                           m_tmp_bitmap.pix16(vpos, I824X_START_ACTIVE_SCAN + x ) = color;
526525                        }
527526                     }
528527                  }
r18113r18114
533532   }
534533
535534   /* Check for start of VBlank */
536   if ( vpos == state->m_start_vblank )
535   if ( vpos == m_start_vblank )
537536   {
538      state->m_control_status |= 0x08;
539      if ( ! state->m_iff )
537      m_control_status |= 0x08;
538      if ( ! m_iff )
540539      {
541         machine.device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
542         state->m_iff = 1;
540         machine().device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
541         m_iff = 1;
543542      }
544543   }
545544}
546545
547static TIMER_CALLBACK( i824x_hblank_callback )
546TIMER_CALLBACK_MEMBER(odyssey2_state::i824x_hblank_callback)
548547{
549   odyssey2_state *state = machine.driver_data<odyssey2_state>();
550   int vpos = machine.primary_screen->vpos();
548   int vpos = machine().primary_screen->vpos();
551549
552   if ( vpos < state->m_start_vpos - 1 )
550   if ( vpos < m_start_vpos - 1 )
553551      return;
554552
555   if ( vpos < state->m_start_vblank - 1 )
553   if ( vpos < m_start_vblank - 1 )
556554   {
557      state->m_control_status |= 0x01;
555      m_control_status |= 0x01;
558556   }
559557}
560558
r18113r18114
590588
591589   screen->register_screen_bitmap(m_tmp_bitmap);
592590
593   m_i824x_line_timer = machine().scheduler().timer_alloc(FUNC(i824x_scanline_callback));
591   m_i824x_line_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(odyssey2_state::i824x_scanline_callback),this));
594592   m_i824x_line_timer->adjust( machine().primary_screen->time_until_pos(1, I824X_START_ACTIVE_SCAN ), 0,  machine().primary_screen->scan_period() );
595593
596   m_i824x_hblank_timer = machine().scheduler().timer_alloc(FUNC(i824x_hblank_callback));
594   m_i824x_hblank_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(odyssey2_state::i824x_hblank_callback),this));
597595   m_i824x_hblank_timer->adjust( machine().primary_screen->time_until_pos(1, I824X_END_ACTIVE_SCAN + 18 ), 0, machine().primary_screen->scan_period() );
598596}
599597
trunk/src/mess/video/mac.c
r18113r18114
651651   }
652652}
653653
654static TIMER_CALLBACK(dafb_vbl_tick)
654TIMER_CALLBACK_MEMBER(mac_state::dafb_vbl_tick)
655655{
656   mac_state *mac = machine.driver_data<mac_state>();
657656
658   mac->m_dafb_int_status |= 1;
659   dafb_recalc_ints(mac);
657   m_dafb_int_status |= 1;
658   dafb_recalc_ints(this);
660659
661   mac->m_vbl_timer->adjust(mac->m_screen->time_until_pos(480, 0), 0);
660   m_vbl_timer->adjust(m_screen->time_until_pos(480, 0), 0);
662661}
663662
664static TIMER_CALLBACK(dafb_cursor_tick)
663TIMER_CALLBACK_MEMBER(mac_state::dafb_cursor_tick)
665664{
666   mac_state *mac = machine.driver_data<mac_state>();
667665
668   mac->m_dafb_int_status |= 4;
669   dafb_recalc_ints(mac);
666   m_dafb_int_status |= 4;
667   dafb_recalc_ints(this);
670668
671   mac->m_cursor_timer->adjust(mac->m_screen->time_until_pos(mac->m_cursor_line, 0), 0);
669   m_cursor_timer->adjust(m_screen->time_until_pos(m_cursor_line, 0), 0);
672670}
673671
674672VIDEO_START_MEMBER(mac_state,macdafb)
675673{
676   m_vbl_timer = machine().scheduler().timer_alloc(FUNC(dafb_vbl_tick));
677   m_cursor_timer = machine().scheduler().timer_alloc(FUNC(dafb_cursor_tick));
674   m_vbl_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mac_state::dafb_vbl_tick),this));
675   m_cursor_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mac_state::dafb_cursor_tick),this));
678676
679677   m_vbl_timer->adjust(attotime::never);
680678   m_cursor_timer->adjust(attotime::never);
trunk/src/mess/video/gamecom.c
r18113r18114
44#define Y_PIXELS 200
55
66
7static TIMER_CALLBACK( gamecom_scanline )
7TIMER_CALLBACK_MEMBER(gamecom_state::gamecom_scanline)
88   {
9   gamecom_state *state = machine.driver_data<gamecom_state>();
109   // draw line
11   if ( state->m_scanline == 0 )
12      state->m_base_address = ( state->m_p_ram[SM8521_LCDC] & 0x40 ) ? 0x2000 : 0x0000;
10   if ( m_scanline == 0 )
11      m_base_address = ( m_p_ram[SM8521_LCDC] & 0x40 ) ? 0x2000 : 0x0000;
1312
14   if ( ~state->m_p_ram[SM8521_LCDC] & 0x80 )
13   if ( ~m_p_ram[SM8521_LCDC] & 0x80 )
1514   {
16      rectangle rec(0, Y_PIXELS - 1, state->m_scanline, state->m_scanline);
17      state->m_bitmap.fill(0, rec );
15      rectangle rec(0, Y_PIXELS - 1, m_scanline, m_scanline);
16      m_bitmap.fill(0, rec );
1817      return;
1918   }
2019   else
2120   {
22      UINT8 *line = &state->m_p_videoram[ state->m_base_address + 40 * state->m_scanline ];
21      UINT8 *line = &m_p_videoram[ m_base_address + 40 * m_scanline ];
2322      int   pal[4];
2423      int   i;
2524
26      switch( state->m_p_ram[SM8521_LCDC] & 0x30 )
25      switch( m_p_ram[SM8521_LCDC] & 0x30 )
2726      {
2827      case 0x00:
2928         pal[0] = 4;
r18113r18114
5352      for( i = 0; i < 40; i++ )
5453      {
5554         UINT8 p = line[i];
56         state->m_bitmap.pix16(i * 4 + 0, state->m_scanline) = pal[ ( p >> 6 ) & 3 ];
57         state->m_bitmap.pix16(i * 4 + 1, state->m_scanline) = pal[ ( p >> 4 ) & 3 ];
58         state->m_bitmap.pix16(i * 4 + 2, state->m_scanline) = pal[ ( p >> 2 ) & 3 ];
59         state->m_bitmap.pix16(i * 4 + 3, state->m_scanline) = pal[ ( p      ) & 3 ];
55         m_bitmap.pix16(i * 4 + 0, m_scanline) = pal[ ( p >> 6 ) & 3 ];
56         m_bitmap.pix16(i * 4 + 1, m_scanline) = pal[ ( p >> 4 ) & 3 ];
57         m_bitmap.pix16(i * 4 + 2, m_scanline) = pal[ ( p >> 2 ) & 3 ];
58         m_bitmap.pix16(i * 4 + 3, m_scanline) = pal[ ( p      ) & 3 ];
6059      }
6160   }
6261
63   state->m_scanline = ( state->m_scanline + 1 ) % Y_PIXELS;
62   m_scanline = ( m_scanline + 1 ) % Y_PIXELS;
6463}
6564
6665void gamecom_state::video_start()
6766{
68   m_scanline_timer = machine().scheduler().timer_alloc(FUNC(gamecom_scanline));
67   m_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gamecom_state::gamecom_scanline),this));
6968   m_scanline_timer->adjust( machine().primary_screen->time_until_pos(0 ), 0, machine().primary_screen->scan_period() );
7069   machine().primary_screen->register_screen_bitmap(m_bitmap);
7170}
trunk/src/mess/video/atarist.c
r18113r18114
166166//  TIMER_CALLBACK( atarist_shifter_tick )
167167//-------------------------------------------------
168168
169static TIMER_CALLBACK( atarist_shifter_tick )
169TIMER_CALLBACK_MEMBER(st_state::atarist_shifter_tick)
170170{
171   st_state *state = machine.driver_data<st_state>();
172171
173   state->shifter_tick();
172   shifter_tick();
174173}
175174
176175
r18113r18114
298297//  TIMER_CALLBACK( atarist_glue_tick )
299298//-------------------------------------------------
300299
301static TIMER_CALLBACK( atarist_glue_tick )
300TIMER_CALLBACK_MEMBER(st_state::atarist_glue_tick)
302301{
303   st_state *state = machine.driver_data<st_state>();
304302
305   state->glue_tick();
303   glue_tick();
306304}
307305
308306
r18113r18114
752750//  TIMER_CALLBACK( atarist_blitter_tick )
753751//-------------------------------------------------
754752
755static TIMER_CALLBACK( atarist_blitter_tick )
753TIMER_CALLBACK_MEMBER(st_state::atarist_blitter_tick)
756754{
757   st_state *state = machine.driver_data<st_state>();
758755
759   state->blitter_tick();
756   blitter_tick();
760757}
761758
762759
r18113r18114
10861083            m_mfp->i3_w(m_blitter_done);
10871084
10881085            int nops = BLITTER_NOPS[m_blitter_op][m_blitter_hop]; // each NOP takes 4 cycles
1089            machine().scheduler().timer_set(attotime::from_hz((Y2/4)/(4*nops)), FUNC(atarist_blitter_tick));
1086            machine().scheduler().timer_set(attotime::from_hz((Y2/4)/(4*nops)), timer_expired_delegate(FUNC(st_state::atarist_blitter_tick),this));
10901087         }
10911088      }
10921089   }
r18113r18114
11081105
11091106void st_state::video_start()
11101107{
1111   m_shifter_timer = machine().scheduler().timer_alloc(FUNC(atarist_shifter_tick));
1112   m_glue_timer = machine().scheduler().timer_alloc(FUNC(atarist_glue_tick));
1108   m_shifter_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(st_state::atarist_shifter_tick),this));
1109   m_glue_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(st_state::atarist_glue_tick),this));
11131110
11141111//  m_shifter_timer->adjust(machine().primary_screen->time_until_pos(0), 0, attotime::from_hz(Y2/4)); // 125 ns
11151112   m_glue_timer->adjust(machine().primary_screen->time_until_pos(0), 0, attotime::from_hz(Y2/16)); // 500 ns
trunk/src/mess/video/fmtowns.c
r18113r18114
17661766   }
17671767}
17681768
1769static TIMER_CALLBACK( towns_sprite_done )
1769TIMER_CALLBACK_MEMBER(towns_state::towns_sprite_done)
17701770{
17711771   // sprite drawing is complete, lower flag
1772   towns_state* state = machine.driver_data<towns_state>();
1773   state->m_video.towns_sprite_flag = 0;
1774   if(state->m_video.towns_sprite_page != 0)
1775      state->m_video.towns_crtc_reg[21] |= 0x8000;
1772   m_video.towns_sprite_flag = 0;
1773   if(m_video.towns_sprite_page != 0)
1774      m_video.towns_crtc_reg[21] |= 0x8000;
17761775   else
1777      state->m_video.towns_crtc_reg[21] &= ~0x8000;
1776      m_video.towns_crtc_reg[21] &= ~0x8000;
17781777}
17791778
1780static TIMER_CALLBACK( towns_vblank_end )
1779TIMER_CALLBACK_MEMBER(towns_state::towns_vblank_end)
17811780{
17821781   // here we'll clear the vsync signal, I presume it goes low on it's own eventually
1783   towns_state* state = machine.driver_data<towns_state>();
17841782   device_t* dev = (device_t*)ptr;
17851783   pic8259_ir3_w(dev, 0);  // IRQ11 = VSync
17861784   if(IRQ_LOG) logerror("PIC: IRQ11 (VSync) set low\n");
1787   state->m_video.towns_vblank_flag = 0;
1785   m_video.towns_vblank_flag = 0;
17881786}
17891787
17901788INTERRUPT_GEN_MEMBER(towns_state::towns_vsync_irq)
r18113r18114
17931791   pic8259_ir3_w(dev, 1);  // IRQ11 = VSync
17941792   if(IRQ_LOG) logerror("PIC: IRQ11 (VSync) set high\n");
17951793   m_video.towns_vblank_flag = 1;
1796   machine().scheduler().timer_set(machine().primary_screen->time_until_vblank_end(), FUNC(towns_vblank_end), 0, (void*)dev);
1794   machine().scheduler().timer_set(machine().primary_screen->time_until_vblank_end(), timer_expired_delegate(FUNC(towns_state::towns_vblank_end),this), 0, (void*)dev);
17971795   if(m_video.towns_tvram_enable)
17981796      draw_text_layer(dev->machine());
17991797   if(m_video.towns_sprite_reg[1] & 0x80)
r18113r18114
18041802{
18051803   m_video.towns_vram_wplane = 0x00;
18061804   m_video.towns_sprite_page = 0;
1807   m_video.sprite_timer = machine().scheduler().timer_alloc(FUNC(towns_sprite_done));
1805   m_video.sprite_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(towns_state::towns_sprite_done),this));
18081806}
18091807
18101808UINT32 towns_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
trunk/src/mess/video/x68k.c
r18113r18114
108108
109109}
110110
111static TIMER_CALLBACK(x68k_crtc_operation_end)
111TIMER_CALLBACK_MEMBER(x68k_state::x68k_crtc_operation_end)
112112{
113   x68k_state *state = machine.driver_data<x68k_state>();
114113   int bit = param;
115   state->m_crtc.operation &= ~bit;
114   m_crtc.operation &= ~bit;
116115}
117116
118117static void x68k_crtc_refresh_mode(running_machine &machine)
r18113r18114
174173   machine.primary_screen->configure(scr.max_x,scr.max_y,visiblescr,HZ_TO_ATTOSECONDS(55.45));
175174}
176175
177TIMER_CALLBACK(x68k_hsync)
176TIMER_CALLBACK_MEMBER(x68k_state::x68k_hsync)
178177{
179   x68k_state *state = machine.driver_data<x68k_state>();
180178   int hstate = param;
181179   attotime hsync_time;
182180
183   state->m_crtc.hblank = hstate;
184   state->m_mfpdev->i7_w(!state->m_crtc.hblank);
185   if(state->m_crtc.vmultiple == 2) // 256-line (doublescan)
181   m_crtc.hblank = hstate;
182   m_mfpdev->i7_w(!m_crtc.hblank);
183   if(m_crtc.vmultiple == 2) // 256-line (doublescan)
186184   {
187185      if(hstate == 1)
188186      {
189         if(state->m_oddscanline == 1)
187         if(m_oddscanline == 1)
190188         {
191            int scan = machine.primary_screen->vpos();
192            if(scan > state->m_crtc.vend)
193               scan = state->m_crtc.vbegin;
194            hsync_time = machine.primary_screen->time_until_pos(scan,(state->m_crtc.htotal + state->m_crtc.hend) / 2);
195            state->m_scanline_timer->adjust(hsync_time);
189            int scan = machine().primary_screen->vpos();
190            if(scan > m_crtc.vend)
191               scan = m_crtc.vbegin;
192            hsync_time = machine().primary_screen->time_until_pos(scan,(m_crtc.htotal + m_crtc.hend) / 2);
193            m_scanline_timer->adjust(hsync_time);
196194            if(scan != 0)
197195            {
198               if((machine.root_device().ioport("options")->read() & 0x04))
196               if((machine().root_device().ioport("options")->read() & 0x04))
199197               {
200                  machine.primary_screen->update_partial(scan);
198                  machine().primary_screen->update_partial(scan);
201199               }
202200            }
203201         }
204202         else
205203         {
206            int scan = machine.primary_screen->vpos();
207            if(scan > state->m_crtc.vend)
208               scan = state->m_crtc.vbegin;
209            hsync_time = machine.primary_screen->time_until_pos(scan,state->m_crtc.hend / 2);
210            state->m_scanline_timer->adjust(hsync_time);
204            int scan = machine().primary_screen->vpos();
205            if(scan > m_crtc.vend)
206               scan = m_crtc.vbegin;
207            hsync_time = machine().primary_screen->time_until_pos(scan,m_crtc.hend / 2);
208            m_scanline_timer->adjust(hsync_time);
211209            if(scan != 0)
212210            {
213               if((machine.root_device().ioport("options")->read() & 0x04))
211               if((machine().root_device().ioport("options")->read() & 0x04))
214212               {
215                  machine.primary_screen->update_partial(scan);
213                  machine().primary_screen->update_partial(scan);
216214               }
217215            }
218216         }
219217      }
220218      if(hstate == 0)
221219      {
222         if(state->m_oddscanline == 1)
220         if(m_oddscanline == 1)
223221         {
224            int scan = machine.primary_screen->vpos();
225            if(scan > state->m_crtc.vend)
226               scan = state->m_crtc.vbegin;
222            int scan = machine().primary_screen->vpos();
223            if(scan > m_crtc.vend)
224               scan = m_crtc.vbegin;
227225            else
228226               scan++;
229            hsync_time = machine.primary_screen->time_until_pos(scan,state->m_crtc.hbegin / 2);
230            state->m_scanline_timer->adjust(hsync_time, 1);
231            state->m_oddscanline = 0;
227            hsync_time = machine().primary_screen->time_until_pos(scan,m_crtc.hbegin / 2);
228            m_scanline_timer->adjust(hsync_time, 1);
229            m_oddscanline = 0;
232230         }
233231         else
234232         {
235            hsync_time = machine.primary_screen->time_until_pos(machine.primary_screen->vpos(),(state->m_crtc.htotal + state->m_crtc.hbegin) / 2);
236            state->m_scanline_timer->adjust(hsync_time, 1);
237            state->m_oddscanline = 1;
233            hsync_time = machine().primary_screen->time_until_pos(machine().primary_screen->vpos(),(m_crtc.htotal + m_crtc.hbegin) / 2);
234            m_scanline_timer->adjust(hsync_time, 1);
235            m_oddscanline = 1;
238236         }
239237      }
240238   }
r18113r18114
242240   {
243241      if(hstate == 1)
244242      {
245         int scan = machine.primary_screen->vpos();
246         if(scan > state->m_crtc.vend)
243         int scan = machine().primary_screen->vpos();
244         if(scan > m_crtc.vend)
247245            scan = 0;
248         hsync_time = machine.primary_screen->time_until_pos(scan,state->m_crtc.hend);
249         state->m_scanline_timer->adjust(hsync_time);
246         hsync_time = machine().primary_screen->time_until_pos(scan,m_crtc.hend);
247         m_scanline_timer->adjust(hsync_time);
250248         if(scan != 0)
251249         {
252            if((machine.root_device().ioport("options")->read() & 0x04))
250            if((machine().root_device().ioport("options")->read() & 0x04))
253251            {
254               machine.primary_screen->update_partial(scan);
252               machine().primary_screen->update_partial(scan);
255253            }
256254         }
257255      }
258256      if(hstate == 0)
259257      {
260         hsync_time = machine.primary_screen->time_until_pos(machine.primary_screen->vpos()+1,state->m_crtc.hbegin);
261         state->m_scanline_timer->adjust(hsync_time, 1);
262   //      if(!(state->m_mfp.gpio & 0x40))  // if GPIP6 is active, clear it
263   //          state->m_mfp.gpio |= 0x40;
258         hsync_time = machine().primary_screen->time_until_pos(machine().primary_screen->vpos()+1,m_crtc.hbegin);
259         m_scanline_timer->adjust(hsync_time, 1);
260   //      if(!(m_mfp.gpio & 0x40))  // if GPIP6 is active, clear it
261   //          m_mfp.gpio |= 0x40;
264262      }
265263   }
266264}
267265
268static TIMER_CALLBACK(x68k_crtc_raster_end)
266TIMER_CALLBACK_MEMBER(x68k_state::x68k_crtc_raster_end)
269267{
270   x68k_state *state = machine.driver_data<x68k_state>();
271   state->m_mfp.gpio |= 0x40;
272   state->m_mfpdev->i6_w(1);
268   m_mfp.gpio |= 0x40;
269   m_mfpdev->i6_w(1);
273270}
274271
275TIMER_CALLBACK(x68k_crtc_raster_irq)
272TIMER_CALLBACK_MEMBER(x68k_state::x68k_crtc_raster_irq)
276273{
277   x68k_state *state = machine.driver_data<x68k_state>();
278274   int scan = param;
279275   attotime irq_time;
280276   attotime end_time;
281277
282   if(scan <= state->m_crtc.vtotal)
278   if(scan <= m_crtc.vtotal)
283279   {
284      state->m_mfp.gpio &= ~0x40;  // GPIP6
285      state->m_mfpdev->i6_w(0);
286      machine.primary_screen->update_partial(scan);
287      irq_time = machine.primary_screen->time_until_pos(scan,state->m_crtc.hbegin);
280      m_mfp.gpio &= ~0x40;  // GPIP6
281      m_mfpdev->i6_w(0);
282      machine().primary_screen->update_partial(scan);
283      irq_time = machine().primary_screen->time_until_pos(scan,m_crtc.hbegin);
288284      // end of HBlank period clears GPIP6 also?
289      end_time = machine.primary_screen->time_until_pos(scan,state->m_crtc.hend);
290      state->m_raster_irq->adjust(irq_time, scan);
291      machine.scheduler().timer_set(end_time, FUNC(x68k_crtc_raster_end));
292      logerror("GPIP6: Raster triggered at line %i (%i)\n",scan,machine.primary_screen->vpos());
285      end_time = machine().primary_screen->time_until_pos(scan,m_crtc.hend);
286      m_raster_irq->adjust(irq_time, scan);
287      machine().scheduler().timer_set(end_time, timer_expired_delegate(FUNC(x68k_state::x68k_crtc_raster_end),this));
288      logerror("GPIP6: Raster triggered at line %i (%i)\n",scan,machine().primary_screen->vpos());
293289   }
294290}
295291
296TIMER_CALLBACK(x68k_crtc_vblank_irq)
292TIMER_CALLBACK_MEMBER(x68k_state::x68k_crtc_vblank_irq)
297293{
298   x68k_state *state = machine.driver_data<x68k_state>();
299   device_t *x68k_mfp = machine.device(MC68901_TAG);
294   device_t *x68k_mfp = machine().device(MC68901_TAG);
300295   int val = param;
301296   attotime irq_time;
302297   int vblank_line;
303298
304299   if(val == 1)  // V-DISP on
305300   {
306      state->m_crtc.vblank = 1;
307      vblank_line = state->m_crtc.vbegin;
308      irq_time = machine.primary_screen->time_until_pos(vblank_line,2);
309      state->m_vblank_irq->adjust(irq_time);
301      m_crtc.vblank = 1;
302      vblank_line = m_crtc.vbegin;
303      irq_time = machine().primary_screen->time_until_pos(vblank_line,2);
304      m_vblank_irq->adjust(irq_time);
310305      logerror("CRTC: VBlank on\n");
311306   }
312307   if(val == 0)  // V-DISP off
313308   {
314      state->m_crtc.vblank = 0;
315      vblank_line = state->m_crtc.vend;
316      if(vblank_line > state->m_crtc.vtotal)
317         vblank_line = state->m_crtc.vtotal;
318      irq_time = machine.primary_screen->time_until_pos(vblank_line,2);
319      state->m_vblank_irq->adjust(irq_time, 1);
309      m_crtc.vblank = 0;
310      vblank_line = m_crtc.vend;
311      if(vblank_line > m_crtc.vtotal)
312         vblank_line = m_crtc.vtotal;
313      irq_time = machine().primary_screen->time_until_pos(vblank_line,2);
314      m_vblank_irq->adjust(irq_time, 1);
320315      logerror("CRTC: VBlank off\n");
321316   }
322317
323318   if (x68k_mfp != NULL)
324319   {
325      state->m_mfpdev->tai_w(!state->m_crtc.vblank);
326      state->m_mfpdev->i4_w(!state->m_crtc.vblank);
320      m_mfpdev->tai_w(!m_crtc.vblank);
321      m_mfpdev->i4_w(!m_crtc.vblank);
327322   }
328323}
329324
r18113r18114
449444      if(data & 0x08)  // text screen raster copy
450445      {
451446         x68k_crtc_text_copy(state, (state->m_crtc.reg[22] & 0xff00) >> 8,(state->m_crtc.reg[22] & 0x00ff));
452         space.machine().scheduler().timer_set(attotime::from_msec(1), FUNC(x68k_crtc_operation_end), 0x02);  // time taken to do operation is a complete guess.
447         space.machine().scheduler().timer_set(attotime::from_msec(1), timer_expired_delegate(FUNC(x68k_state::x68k_crtc_operation_end),state), 0x02);  // time taken to do operation is a complete guess.
453448      }
454449      if(data & 0x02)  // high-speed graphic screen clear
455450      {
r18113r18114
457452            memset(state->m_gvram32,0,0x40000);
458453         else
459454            memset(state->m_gvram16,0,0x40000);
460         space.machine().scheduler().timer_set(attotime::from_msec(10), FUNC(x68k_crtc_operation_end), 0x02);  // time taken to do operation is a complete guess.
455         space.machine().scheduler().timer_set(attotime::from_msec(10), timer_expired_delegate(FUNC(x68k_state::x68k_crtc_operation_end),state), 0x02);  // time taken to do operation is a complete guess.
461456      }
462457      break;
463458   }
trunk/src/mess/video/galaxy.c
r18113r18114
1313#include "cpu/z80/z80.h"
1414
1515
16static TIMER_CALLBACK( gal_video )
16TIMER_CALLBACK_MEMBER(galaxy_state::gal_video)
1717{
18   galaxy_state *state = machine.driver_data<galaxy_state>();
19   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
18   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
2019   int y, x;
21   if (state->m_interrupts_enabled == TRUE)
20   if (m_interrupts_enabled == TRUE)
2221   {
23      UINT8 *gfx = state->memregion("gfx1")->base();
24      UINT8 dat = (state->m_latch_value & 0x3c) >> 2;
25      if ((state->m_gal_cnt >= 48 * 2) && (state->m_gal_cnt < 48 * 210))  // display on screen just state->m_first 208 lines
22      UINT8 *gfx = memregion("gfx1")->base();
23      UINT8 dat = (m_latch_value & 0x3c) >> 2;
24      if ((m_gal_cnt >= 48 * 2) && (m_gal_cnt < 48 * 210))  // display on screen just m_first 208 lines
2625      {
27         UINT8 mode = (state->m_latch_value >> 1) & 1; // bit 2 latch represents mode
28         UINT16 addr = (machine.device("maincpu")->state().state_int(Z80_I) << 8) | machine.device("maincpu")->state().state_int(Z80_R) | ((state->m_latch_value & 0x80) ^ 0x80);
26         UINT8 mode = (m_latch_value >> 1) & 1; // bit 2 latch represents mode
27         UINT16 addr = (machine().device("maincpu")->state().state_int(Z80_I) << 8) | machine().device("maincpu")->state().state_int(Z80_R) | ((m_latch_value & 0x80) ^ 0x80);
2928         if (mode == 0)
3029         {
3130            // Text mode
32            if (state->m_first == 0 && (machine.device("maincpu")->state().state_int(Z80_R) & 0x1f) == 0)
31            if (m_first == 0 && (machine().device("maincpu")->state().state_int(Z80_R) & 0x1f) == 0)
3332            {
3433               // Due to a fact that on real processor latch value is set at
3534               // the end of last cycle we need to skip dusplay of double
36               // state->m_first char in each row
37               state->m_code = 0x00;
38               state->m_first = 1;
35               // m_first char in each row
36               m_code = 0x00;
37               m_first = 1;
3938            }
4039            else
4140            {
42               state->m_code = space.read_byte(addr) & 0xbf;
43               state->m_code += (state->m_code & 0x80) >> 1;
44               state->m_code = gfx[(state->m_code & 0x7f) +(dat << 7 )] ^ 0xff;
45               state->m_first = 0;
41               m_code = space.read_byte(addr) & 0xbf;
42               m_code += (m_code & 0x80) >> 1;
43               m_code = gfx[(m_code & 0x7f) +(dat << 7 )] ^ 0xff;
44               m_first = 0;
4645            }
47            y = state->m_gal_cnt / 48 - 2;
48            x = (state->m_gal_cnt % 48) * 8;
46            y = m_gal_cnt / 48 - 2;
47            x = (m_gal_cnt % 48) * 8;
4948
50            state->m_bitmap.pix16(y, x ) = (state->m_code >> 0) & 1; x++;
51            state->m_bitmap.pix16(y, x ) = (state->m_code >> 1) & 1; x++;
52            state->m_bitmap.pix16(y, x ) = (state->m_code >> 2) & 1; x++;
53            state->m_bitmap.pix16(y, x ) = (state->m_code >> 3) & 1; x++;
54            state->m_bitmap.pix16(y, x ) = (state->m_code >> 4) & 1; x++;
55            state->m_bitmap.pix16(y, x ) = (state->m_code >> 5) & 1; x++;
56            state->m_bitmap.pix16(y, x ) = (state->m_code >> 6) & 1; x++;
57            state->m_bitmap.pix16(y, x ) = (state->m_code >> 7) & 1;
49            m_bitmap.pix16(y, x ) = (m_code >> 0) & 1; x++;
50            m_bitmap.pix16(y, x ) = (m_code >> 1) & 1; x++;
51            m_bitmap.pix16(y, x ) = (m_code >> 2) & 1; x++;
52            m_bitmap.pix16(y, x ) = (m_code >> 3) & 1; x++;
53            m_bitmap.pix16(y, x ) = (m_code >> 4) & 1; x++;
54            m_bitmap.pix16(y, x ) = (m_code >> 5) & 1; x++;
55            m_bitmap.pix16(y, x ) = (m_code >> 6) & 1; x++;
56            m_bitmap.pix16(y, x ) = (m_code >> 7) & 1;
5857         }
5958         else
6059         { // Graphics mode
61            if (state->m_first < 4 && (machine.device("maincpu")->state().state_int(Z80_R) & 0x1f) == 0)
60            if (m_first < 4 && (machine().device("maincpu")->state().state_int(Z80_R) & 0x1f) == 0)
6261            {
6362               // Due to a fact that on real processor latch value is set at
6463               // the end of last cycle we need to skip dusplay of 4 times
65               // state->m_first char in each row
66               state->m_code = 0x00;
67               state->m_first++;
64               // m_first char in each row
65               m_code = 0x00;
66               m_first++;
6867            }
6968            else
7069            {
71               state->m_code = space.read_byte(addr) ^ 0xff;
72               state->m_first = 0;
70               m_code = space.read_byte(addr) ^ 0xff;
71               m_first = 0;
7372            }
74            y = state->m_gal_cnt / 48 - 2;
75            x = (state->m_gal_cnt % 48) * 8;
73            y = m_gal_cnt / 48 - 2;
74            x = (m_gal_cnt % 48) * 8;
7675
7776            /* hack - until calc of R is fixed in Z80 */
7877            if (x == 11 * 8 && y == 0)
7978            {
80               state->m_start_addr = addr;
79               m_start_addr = addr;
8180            }
8281            if ((x / 8 >= 11) && (x / 8 < 44))
8382            {
84               state->m_code = space.read_byte(state->m_start_addr + y * 32 + (state->m_gal_cnt % 48) - 11) ^ 0xff;
83               m_code = space.read_byte(m_start_addr + y * 32 + (m_gal_cnt % 48) - 11) ^ 0xff;
8584            }
8685            else
8786            {
88               state->m_code = 0x00;
87               m_code = 0x00;
8988            }
9089            /* end of hack */
9190
92            state->m_bitmap.pix16(y, x ) = (state->m_code >> 0) & 1; x++;
93            state->m_bitmap.pix16(y, x ) = (state->m_code >> 1) & 1; x++;
94            state->m_bitmap.pix16(y, x ) = (state->m_code >> 2) & 1; x++;
95            state->m_bitmap.pix16(y, x ) = (state->m_code >> 3) & 1; x++;
96            state->m_bitmap.pix16(y, x ) = (state->m_code >> 4) & 1; x++;
97            state->m_bitmap.pix16(y, x ) = (state->m_code >> 5) & 1; x++;
98            state->m_bitmap.pix16(y, x ) = (state->m_code >> 6) & 1; x++;
99            state->m_bitmap.pix16(y, x ) = (state->m_code >> 7) & 1;
91            m_bitmap.pix16(y, x ) = (m_code >> 0) & 1; x++;
92            m_bitmap.pix16(y, x ) = (m_code >> 1) & 1; x++;
93            m_bitmap.pix16(y, x ) = (m_code >> 2) & 1; x++;
94            m_bitmap.pix16(y, x ) = (m_code >> 3) & 1; x++;
95            m_bitmap.pix16(y, x ) = (m_code >> 4) & 1; x++;
96            m_bitmap.pix16(y, x ) = (m_code >> 5) & 1; x++;
97            m_bitmap.pix16(y, x ) = (m_code >> 6) & 1; x++;
98            m_bitmap.pix16(y, x ) = (m_code >> 7) & 1;
10099         }
101100      }
102      state->m_gal_cnt++;
101      m_gal_cnt++;
103102   }
104103}
105104
r18113r18114
114113{
115114   m_gal_cnt = 0;
116115
117   m_gal_video_timer = machine().scheduler().timer_alloc(FUNC(gal_video));
116   m_gal_video_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(galaxy_state::gal_video),this));
118117   m_gal_video_timer->adjust(attotime::zero, 0, attotime::never);
119118
120119   machine().primary_screen->register_screen_bitmap(m_bitmap);
trunk/src/mess/video/oric.c
r18113r18114
1212
1313#include "includes/oric.h"
1414
15static TIMER_CALLBACK(oric_vh_timer_callback)
15TIMER_CALLBACK_MEMBER(oric_state::oric_vh_timer_callback)
1616{
17   oric_state *state = machine.driver_data<oric_state>();
1817   /* update flash count */
19   state->m_vh_state.flash_count++;
18   m_vh_state.flash_count++;
2019}
2120
2221static void oric_vh_update_flash(oric_state *state)
r18113r18114
299298   m_vh_state.char_base = 0;
300299   /* initialise flash timer */
301300   m_vh_state.flash_count = 0;
302   machine().scheduler().timer_pulse(attotime::from_hz(50), FUNC(oric_vh_timer_callback));
301   machine().scheduler().timer_pulse(attotime::from_hz(50), timer_expired_delegate(FUNC(oric_state::oric_vh_timer_callback),this));
303302   /* mode */
304303   oric_vh_update_attribute(machine(),(1<<3)|(1<<4));
305304}
trunk/src/mess/video/zx.c
r18113r18114
8484 *           32..223 192 visible lines
8585 *          224..233 vblank
8686 */
87static TIMER_CALLBACK(zx_ula_nmi)
87TIMER_CALLBACK_MEMBER(zx_state::zx_ula_nmi)
8888{
89   zx_state *state = machine.driver_data<zx_state>();
9089   /*
9190     * An NMI is issued on the ZX81 every 64us for the blanked
9291     * scanlines at the top and bottom of the display.
9392     */
94   screen_device *screen = machine.first_screen();
93   screen_device *screen = machine().first_screen();
9594   int height = screen->height();
9695   const rectangle& r1 = screen->visible_area();
9796   rectangle r;
9897
99   bitmap_ind16 &bitmap = state->m_bitmap;
100   r.set(r1.min_x, r1.max_x, state->m_ula_scanline_count, state->m_ula_scanline_count);
98   bitmap_ind16 &bitmap = m_bitmap;
99   r.set(r1.min_x, r1.max_x, m_ula_scanline_count, m_ula_scanline_count);
101100   bitmap.fill(1, r);
102//  logerror("ULA %3d[%d] NMI, R:$%02X, $%04x\n", machine.primary_screen->vpos(), ula_scancode_count, (unsigned) machine.device("maincpu")->state().state_int(Z80_R), (unsigned) machine.device("maincpu")->state().state_int(Z80_PC));
103   machine.device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
104   if (++state->m_ula_scanline_count == height)
105      state->m_ula_scanline_count = 0;
101//  logerror("ULA %3d[%d] NMI, R:$%02X, $%04x\n", machine().primary_screen->vpos(), ula_scancode_count, (unsigned) machine().device("maincpu")->state().state_int(Z80_R), (unsigned) machine().device("maincpu")->state().state_int(Z80_PC));
102   machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
103   if (++m_ula_scanline_count == height)
104      m_ula_scanline_count = 0;
106105}
107106
108static TIMER_CALLBACK(zx_ula_irq)
107TIMER_CALLBACK_MEMBER(zx_state::zx_ula_irq)
109108{
110   zx_state *state = machine.driver_data<zx_state>();
111109
112110   /*
113111     * An IRQ is issued on the ZX80/81 whenever the R registers
114112     * bit 6 goes low. In MESS this IRQ timed from the first read
115113     * from the copy of the DFILE in the upper 32K in zx_ula_r().
116114     */
117   if (state->m_ula_irq_active)
115   if (m_ula_irq_active)
118116   {
119//      logerror("ULA %3d[%d] IRQ, R:$%02X, $%04x\n", machine.primary_screen->vpos(), ula_scancode_count, (unsigned) machine.device("maincpu")->state().state_int(Z80_R), (unsigned) machine.device("maincpu")->state().state_int(Z80_PC));
117//      logerror("ULA %3d[%d] IRQ, R:$%02X, $%04x\n", machine().primary_screen->vpos(), ula_scancode_count, (unsigned) machine().device("maincpu")->state().state_int(Z80_R), (unsigned) machine().device("maincpu")->state().state_int(Z80_PC));
120118
121      state->m_ula_irq_active = 0;
122      machine.device("maincpu")->execute().set_input_line(0, HOLD_LINE);
119      m_ula_irq_active = 0;
120      machine().device("maincpu")->execute().set_input_line(0, HOLD_LINE);
123121   }
124122}
125123
r18113r18114
163161      for (y = state->m_charline_ptr; y < ARRAY_LENGTH(state->m_charline); y++)
164162         state->m_charline[y] = 0;
165163
166      machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(((32 - state->m_charline_ptr) << 2)), FUNC(zx_ula_irq));
164      machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(((32 - state->m_charline_ptr) << 2)), timer_expired_delegate(FUNC(zx_state::zx_ula_irq),state));
167165      state->m_ula_irq_active++;
168166
169167      scanline = &bitmap.pix16(state->m_ula_scanline_count);
r18113r18114
192190
193191void zx_state::video_start()
194192{
195   m_ula_nmi = machine().scheduler().timer_alloc(FUNC(zx_ula_nmi));
193   m_ula_nmi = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(zx_state::zx_ula_nmi),this));
196194   m_ula_irq_active = 0;
197195   machine().primary_screen->register_screen_bitmap(m_bitmap);
198196}
trunk/src/mess/drivers/sg1000.c
r18113r18114
10251025    TIMER_CALLBACK( lightgun_tick )
10261026-------------------------------------------------*/
10271027
1028static TIMER_CALLBACK( lightgun_tick )
1028TIMER_CALLBACK_MEMBER(sg1000_state::lightgun_tick)
10291029{
1030   UINT8 *rom = machine.root_device().memregion(Z80_TAG)->base();
1030   UINT8 *rom = machine().root_device().memregion(Z80_TAG)->base();
10311031
10321032   if (IS_CARTRIDGE_TV_DRAW(rom))
10331033   {
10341034      /* enable crosshair for TV Draw */
1035      crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL);
1035      crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_ALL);
10361036   }
10371037   else
10381038   {
10391039      /* disable crosshair for other cartridges */
1040      crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE);
1040      crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_NONE);
10411041   }
10421042}
10431043
r18113r18114
10481048void sg1000_state::machine_start()
10491049{
10501050   /* toggle light gun crosshair */
1051   machine().scheduler().timer_set(attotime::zero, FUNC(lightgun_tick));
1051   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(sg1000_state::lightgun_tick),this));
10521052
10531053   /* register for state saving */
10541054   save_item(NAME(m_tvdraw_data));
r18113r18114
10611061void sc3000_state::machine_start()
10621062{
10631063   /* toggle light gun crosshair */
1064   machine().scheduler().timer_set(attotime::zero, FUNC(lightgun_tick));
1064   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(sg1000_state::lightgun_tick),this));
10651065
10661066   /* register for state saving */
10671067   save_item(NAME(m_tvdraw_data));
trunk/src/mess/drivers/beta.c
r18113r18114
8484
8585/* M6532 Interface */
8686
87static TIMER_CALLBACK( led_refresh )
87TIMER_CALLBACK_MEMBER(beta_state::led_refresh)
8888{
89   beta_state *state = machine.driver_data<beta_state>();
9089
91   if (state->m_ls145_p < 6)
90   if (m_ls145_p < 6)
9291   {
93      output_set_digit_value(state->m_ls145_p, state->m_segment);
92      output_set_digit_value(m_ls145_p, m_segment);
9493   }
9594}
9695
r18113r18114
237236
238237void beta_state::machine_start()
239238{
240   m_led_refresh_timer = machine().scheduler().timer_alloc(FUNC(led_refresh));
239   m_led_refresh_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(beta_state::led_refresh),this));
241240
242241   /* register for state saving */
243242   save_item(NAME(m_eprom_oe));
trunk/src/mess/drivers/x07.c
r18113r18114
666666   m_cass_data = m_regs_w[7];
667667}
668668
669static TIMER_CALLBACK( cassette_tick )
669TIMER_CALLBACK_MEMBER(x07_state::cassette_tick)
670670{
671   x07_state *state = machine.driver_data<x07_state>();
672   state->m_cass_clk++;
671   m_cass_clk++;
673672}
674673
675static TIMER_CALLBACK( cassette_poll )
674TIMER_CALLBACK_MEMBER(x07_state::cassette_poll)
676675{
677   x07_state *state = machine.driver_data<x07_state>();
678676
679   if ((state->m_cassette->get_state() & 0x03) == CASSETTE_PLAY)
680      state->cassette_load();
681   else if ((state->m_cassette->get_state() & 0x03) == CASSETTE_RECORD)
682      state->cassette_save();
677   if ((m_cassette->get_state() & 0x03) == CASSETTE_PLAY)
678      cassette_load();
679   else if ((m_cassette->get_state() & 0x03) == CASSETTE_RECORD)
680      cassette_save();
683681}
684682
685683void x07_state::cassette_load()
r18113r18114
13671365   state->m_blink = !state->m_blink;
13681366}
13691367
1370static TIMER_CALLBACK( rsta_clear )
1368TIMER_CALLBACK_MEMBER(x07_state::rsta_clear)
13711369{
1372   x07_state *state = machine.driver_data<x07_state>();
1373   state->m_maincpu->set_input_line(NSC800_RSTA, CLEAR_LINE);
1370   m_maincpu->set_input_line(NSC800_RSTA, CLEAR_LINE);
13741371
1375   if (state->m_kb_size)
1376      state->kb_irq();
1372   if (m_kb_size)
1373      kb_irq();
13771374}
13781375
1379static TIMER_CALLBACK( rstb_clear )
1376TIMER_CALLBACK_MEMBER(x07_state::rstb_clear)
13801377{
1381   x07_state *state = machine.driver_data<x07_state>();
1382   state->m_maincpu->set_input_line(NSC800_RSTB, CLEAR_LINE);
1378   m_maincpu->set_input_line(NSC800_RSTB, CLEAR_LINE);
13831379}
13841380
1385static TIMER_CALLBACK( beep_stop )
1381TIMER_CALLBACK_MEMBER(x07_state::beep_stop)
13861382{
1387   x07_state *state = machine.driver_data<x07_state>();
13881383
1389   beep_set_state(state->m_beep, 0);
1384   beep_set_state(m_beep, 0);
13901385}
13911386
13921387static const gfx_layout x07_charlayout =
r18113r18114
14061401
14071402void x07_state::machine_start()
14081403{
1409   m_rsta_clear = machine().scheduler().timer_alloc(FUNC(rsta_clear));
1410   m_rstb_clear = machine().scheduler().timer_alloc(FUNC(rstb_clear));
1411   m_beep_stop = machine().scheduler().timer_alloc(FUNC(beep_stop));
1412   m_cass_poll = machine().scheduler().timer_alloc(FUNC(cassette_poll));
1413   m_cass_tick = machine().scheduler().timer_alloc(FUNC(cassette_tick));
1404   m_rsta_clear = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(x07_state::rsta_clear),this));
1405   m_rstb_clear = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(x07_state::rstb_clear),this));
1406   m_beep_stop = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(x07_state::beep_stop),this));
1407   m_cass_poll = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(x07_state::cassette_poll),this));
1408   m_cass_tick = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(x07_state::cassette_tick),this));
14141409
14151410   /* Save State */
14161411   save_item(NAME(m_sleep));
trunk/src/mess/drivers/fm7.c
r18113r18114
234234   return ret;
235235}
236236
237static TIMER_CALLBACK( fm7_beeper_off )
237TIMER_CALLBACK_MEMBER(fm7_state::fm7_beeper_off)
238238{
239   beep_set_state(machine.device(BEEPER_TAG),0);
239   beep_set_state(machine().device(BEEPER_TAG),0);
240240   logerror("timed beeper off\n");
241241}
242242
r18113r18114
264264      {
265265         beep_set_state(machine().device(BEEPER_TAG),1);
266266         logerror("timed beeper on\n");
267         machine().scheduler().timer_set(attotime::from_msec(205), FUNC(fm7_beeper_off));
267         machine().scheduler().timer_set(attotime::from_msec(205), timer_expired_delegate(FUNC(fm7_state::fm7_beeper_off),this));
268268      }
269269   }
270270   logerror("beeper state: %02x\n",data);
r18113r18114
281281   {
282282      beep_set_state(machine().device(BEEPER_TAG),1);
283283      logerror("timed beeper on\n");
284      machine().scheduler().timer_set(attotime::from_msec(205), FUNC(fm7_beeper_off));
284      machine().scheduler().timer_set(attotime::from_msec(205), timer_expired_delegate(FUNC(fm7_state::fm7_beeper_off),this));
285285   }
286286   return 0xff;
287287}
r18113r18114
628628   }
629629}
630630
631static TIMER_CALLBACK( fm77av_encoder_ack )
631TIMER_CALLBACK_MEMBER(fm7_state::fm77av_encoder_ack)
632632{
633   fm7_state *state = machine.driver_data<fm7_state>();
634   state->m_encoder.ack = 1;
633   m_encoder.ack = 1;
635634}
636635
637636void fm7_state::fm77av_encoder_handle_command()
r18113r18114
716715         fm77av_encoder_handle_command();
717716
718717      // wait 5us to set ACK flag
719      machine().scheduler().timer_set(attotime::from_usec(5), FUNC(fm77av_encoder_ack));
718      machine().scheduler().timer_set(attotime::from_usec(5), timer_expired_delegate(FUNC(fm7_state::fm77av_encoder_ack),this));
720719
721720      //logerror("ENC: write 0x%02x to data register, moved to pos %i\n",data,m_encoder.position);
722721   }
r18113r18114
12041203   }
12051204}
12061205
1207static TIMER_CALLBACK( fm7_timer_irq )
1206TIMER_CALLBACK_MEMBER(fm7_state::fm7_timer_irq)
12081207{
1209   fm7_state *state = machine.driver_data<fm7_state>();
1210   if(state->m_irq_mask & IRQ_FLAG_TIMER)
1208   if(m_irq_mask & IRQ_FLAG_TIMER)
12111209   {
1212      main_irq_set_flag(machine,IRQ_FLAG_TIMER);
1210      main_irq_set_flag(machine(),IRQ_FLAG_TIMER);
12131211   }
12141212}
12151213
1216static TIMER_CALLBACK( fm7_subtimer_irq )
1214TIMER_CALLBACK_MEMBER(fm7_state::fm7_subtimer_irq)
12171215{
1218   fm7_state *state = machine.driver_data<fm7_state>();
1219   if(state->m_video.nmi_mask == 0 && state->m_video.sub_halt == 0)
1220      machine.device("sub")->execute().set_input_line(INPUT_LINE_NMI,PULSE_LINE);
1216   if(m_video.nmi_mask == 0 && m_video.sub_halt == 0)
1217      machine().device("sub")->execute().set_input_line(INPUT_LINE_NMI,PULSE_LINE);
12211218}
12221219
12231220// When a key is pressed or released (in scan mode only), an IRQ is generated on the main CPU,
r18113r18114
12881285   state->m_mod_data = modifiers;
12891286}
12901287
1291static TIMER_CALLBACK( fm7_keyboard_poll )
1288TIMER_CALLBACK_MEMBER(fm7_state::fm7_keyboard_poll)
12921289{
1293   fm7_state *state = machine.driver_data<fm7_state>();
12941290   static const char *const portnames[3] = { "key1","key2","key3" };
12951291   int x,y;
12961292   int bit = 0;
12971293   int mod = 0;
12981294   UINT32 keys;
1299   UINT32 modifiers = machine.root_device().ioport("key_modifiers")->read();
1295   UINT32 modifiers = machine().root_device().ioport("key_modifiers")->read();
13001296
1301   if(machine.root_device().ioport("key3")->read() & 0x40000)
1297   if(machine().root_device().ioport("key3")->read() & 0x40000)
13021298   {
1303      state->m_break_flag = 1;
1304      machine.device("maincpu")->execute().set_input_line(M6809_FIRQ_LINE,ASSERT_LINE);
1299      m_break_flag = 1;
1300      machine().device("maincpu")->execute().set_input_line(M6809_FIRQ_LINE,ASSERT_LINE);
13051301   }
13061302   else
1307      state->m_break_flag = 0;
1303      m_break_flag = 0;
13081304
1309   if(state->m_key_scan_mode == KEY_MODE_SCAN)
1305   if(m_key_scan_mode == KEY_MODE_SCAN)
13101306   {
13111307      // handle scancode mode
1312      fm7_keyboard_poll_scan(machine);
1308      fm7_keyboard_poll_scan(machine());
13131309      return;
13141310   }
13151311
r18113r18114
13271323
13281324   for(x=0;x<3;x++)
13291325   {
1330      keys = machine.root_device().ioport(portnames[x])->read();
1326      keys = machine().root_device().ioport(portnames[x])->read();
13311327
13321328      for(y=0;y<32;y++)  // loop through each bit in the port
13331329      {
1334         if((keys & (1<<y)) != 0 && (state->m_key_data[x] & (1<<y)) == 0)
1330         if((keys & (1<<y)) != 0 && (m_key_data[x] & (1<<y)) == 0)
13351331         {
1336            key_press(machine,fm7_key_list[bit][mod]); // key press
1332            key_press(machine(),fm7_key_list[bit][mod]); // key press
13371333         }
13381334         bit++;
13391335      }
13401336
1341      state->m_key_data[x] = keys;
1337      m_key_data[x] = keys;
13421338   }
13431339}
13441340
r18113r18114
18341830{
18351831//  m_shared_ram = auto_alloc_array(machine(),UINT8,0x80);
18361832   m_video_ram = auto_alloc_array(machine(),UINT8,0x18000);  // 2 pages on some systems
1837   m_timer = machine().scheduler().timer_alloc(FUNC(fm7_timer_irq));
1838   m_subtimer = machine().scheduler().timer_alloc(FUNC(fm7_subtimer_irq));
1839   m_keyboard_timer = machine().scheduler().timer_alloc(FUNC(fm7_keyboard_poll));
1840   m_fm77av_vsync_timer = machine().scheduler().timer_alloc(FUNC(fm77av_vsync));
1833   m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(fm7_state::fm7_timer_irq),this));
1834   m_subtimer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(fm7_state::fm7_subtimer_irq),this));
1835   m_keyboard_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(fm7_state::fm7_keyboard_poll),this));
1836   m_fm77av_vsync_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(fm7_state::fm77av_vsync),this));
18411837   machine().device("maincpu")->execute().set_irq_acknowledge_callback(fm7_irq_ack);
18421838   machine().device("sub")->execute().set_irq_acknowledge_callback(fm7_sub_irq_ack);
18431839}
trunk/src/mess/drivers/gp32.c
r18113r18114
257257   }
258258}
259259
260static TIMER_CALLBACK( s3c240x_lcd_timer_exp )
260TIMER_CALLBACK_MEMBER(gp32_state::s3c240x_lcd_timer_exp)
261261{
262   gp32_state *state = machine.driver_data<gp32_state>();
263   screen_device *screen = machine.primary_screen;
264   verboselog( machine, 2, "LCD timer callback\n");
265   state->m_s3c240x_lcd.vpos = screen->vpos();
266   state->m_s3c240x_lcd.hpos = screen->hpos();
267   verboselog( machine, 3, "LCD - vpos %d hpos %d\n", state->m_s3c240x_lcd.vpos, state->m_s3c240x_lcd.hpos);
268   if (state->m_s3c240x_lcd.vramaddr_cur >= state->m_s3c240x_lcd.vramaddr_max)
262   screen_device *screen = machine().primary_screen;
263   verboselog( machine(), 2, "LCD timer callback\n");
264   m_s3c240x_lcd.vpos = screen->vpos();
265   m_s3c240x_lcd.hpos = screen->hpos();
266   verboselog( machine(), 3, "LCD - vpos %d hpos %d\n", m_s3c240x_lcd.vpos, m_s3c240x_lcd.hpos);
267   if (m_s3c240x_lcd.vramaddr_cur >= m_s3c240x_lcd.vramaddr_max)
269268   {
270      s3c240x_lcd_dma_reload( machine);
269      s3c240x_lcd_dma_reload( machine());
271270   }
272   verboselog( machine, 3, "LCD - vramaddr %08X\n", state->m_s3c240x_lcd.vramaddr_cur);
273   while (state->m_s3c240x_lcd.vramaddr_cur < state->m_s3c240x_lcd.vramaddr_max)
271   verboselog( machine(), 3, "LCD - vramaddr %08X\n", m_s3c240x_lcd.vramaddr_cur);
272   while (m_s3c240x_lcd.vramaddr_cur < m_s3c240x_lcd.vramaddr_max)
274273   {
275      switch (state->m_s3c240x_lcd.bppmode)
274      switch (m_s3c240x_lcd.bppmode)
276275      {
277         case BPPMODE_TFT_01 : s3c240x_lcd_render_01( machine); break;
278         case BPPMODE_TFT_02 : s3c240x_lcd_render_02( machine); break;
279         case BPPMODE_TFT_04 : s3c240x_lcd_render_04( machine); break;
280         case BPPMODE_TFT_08 : s3c240x_lcd_render_08( machine); break;
281         case BPPMODE_TFT_16 : s3c240x_lcd_render_16( machine); break;
282         default : verboselog( machine, 0, "s3c240x_lcd_timer_exp: bppmode %d not supported\n", state->m_s3c240x_lcd.bppmode); break;
276         case BPPMODE_TFT_01 : s3c240x_lcd_render_01( machine()); break;
277         case BPPMODE_TFT_02 : s3c240x_lcd_render_02( machine()); break;
278         case BPPMODE_TFT_04 : s3c240x_lcd_render_04( machine()); break;
279         case BPPMODE_TFT_08 : s3c240x_lcd_render_08( machine()); break;
280         case BPPMODE_TFT_16 : s3c240x_lcd_render_16( machine()); break;
281         default : verboselog( machine(), 0, "s3c240x_lcd_timer_exp: bppmode %d not supported\n", m_s3c240x_lcd.bppmode); break;
283282      }
284      if ((state->m_s3c240x_lcd.vpos == 0) && (state->m_s3c240x_lcd.hpos == 0)) break;
283      if ((m_s3c240x_lcd.vpos == 0) && (m_s3c240x_lcd.hpos == 0)) break;
285284   }
286   state->m_s3c240x_lcd_timer->adjust( screen->time_until_pos(state->m_s3c240x_lcd.vpos, state->m_s3c240x_lcd.hpos));
285   m_s3c240x_lcd_timer->adjust( screen->time_until_pos(m_s3c240x_lcd.vpos, m_s3c240x_lcd.hpos));
287286}
288287
289288void gp32_state::video_start()
r18113r18114
673672   }
674673}
675674
676static TIMER_CALLBACK( s3c240x_pwm_timer_exp )
675TIMER_CALLBACK_MEMBER(gp32_state::s3c240x_pwm_timer_exp)
677676{
678   gp32_state *state = machine.driver_data<gp32_state>();
679677   int ch = param;
680678   static const int ch_int[] = { INT_TIMER0, INT_TIMER1, INT_TIMER2, INT_TIMER3, INT_TIMER4 };
681   verboselog( machine, 2, "PWM %d timer callback\n", ch);
682   if (BITS( state->m_s3c240x_pwm_regs[1], 23, 20) == (ch + 1))
679   verboselog( machine(), 2, "PWM %d timer callback\n", ch);
680   if (BITS( m_s3c240x_pwm_regs[1], 23, 20) == (ch + 1))
683681   {
684      s3c240x_dma_request_pwm( machine);
682      s3c240x_dma_request_pwm( machine());
685683   }
686684   else
687685   {
688      s3c240x_request_irq( machine, ch_int[ch]);
686      s3c240x_request_irq( machine(), ch_int[ch]);
689687   }
690688}
691689
r18113r18114
911909   }
912910}
913911
914static TIMER_CALLBACK( s3c240x_dma_timer_exp )
912TIMER_CALLBACK_MEMBER(gp32_state::s3c240x_dma_timer_exp)
915913{
916914   int ch = param;
917   verboselog( machine, 2, "DMA %d timer callback\n", ch);
915   verboselog( machine(), 2, "DMA %d timer callback\n", ch);
918916}
919917
920918// SMARTMEDIA
r18113r18114
14391437   }
14401438}
14411439
1442static TIMER_CALLBACK( s3c240x_iic_timer_exp )
1440TIMER_CALLBACK_MEMBER(gp32_state::s3c240x_iic_timer_exp)
14431441{
1444   gp32_state *state = machine.driver_data<gp32_state>();
14451442   int enable_interrupt, mode_selection;
1446   verboselog( machine, 2, "IIC timer callback\n");
1447   mode_selection = BITS( state->m_s3c240x_iic_regs[1], 7, 6);
1443   verboselog( machine(), 2, "IIC timer callback\n");
1444   mode_selection = BITS( m_s3c240x_iic_regs[1], 7, 6);
14481445   switch (mode_selection)
14491446   {
14501447      // master receive mode
14511448      case 2 :
14521449      {
1453         if (state->m_s3c240x_iic.data_index == 0)
1450         if (m_s3c240x_iic.data_index == 0)
14541451         {
1455            UINT8 data_shift = state->m_s3c240x_iic_regs[3] & 0xFF;
1456            verboselog( machine, 5, "IIC write %02X\n", data_shift);
1452            UINT8 data_shift = m_s3c240x_iic_regs[3] & 0xFF;
1453            verboselog( machine(), 5, "IIC write %02X\n", data_shift);
14571454         }
14581455         else
14591456         {
1460            UINT8 data_shift = eeprom_read( machine, state->m_s3c240x_iic.address);
1461            verboselog( machine, 5, "IIC read %02X\n", data_shift);
1462            state->m_s3c240x_iic_regs[3] = (state->m_s3c240x_iic_regs[3] & ~0xFF) | data_shift;
1457            UINT8 data_shift = eeprom_read( machine(), m_s3c240x_iic.address);
1458            verboselog( machine(), 5, "IIC read %02X\n", data_shift);
1459            m_s3c240x_iic_regs[3] = (m_s3c240x_iic_regs[3] & ~0xFF) | data_shift;
14631460         }
1464         state->m_s3c240x_iic.data_index++;
1461         m_s3c240x_iic.data_index++;
14651462      }
14661463      break;
14671464      // master transmit mode
14681465      case 3 :
14691466      {
1470         UINT8 data_shift = state->m_s3c240x_iic_regs[3] & 0xFF;
1471         verboselog( machine, 5, "IIC write %02X\n", data_shift);
1472         state->m_s3c240x_iic.data[state->m_s3c240x_iic.data_index++] = data_shift;
1473         if (state->m_s3c240x_iic.data_index == 3)
1467         UINT8 data_shift = m_s3c240x_iic_regs[3] & 0xFF;
1468         verboselog( machine(), 5, "IIC write %02X\n", data_shift);
1469         m_s3c240x_iic.data[m_s3c240x_iic.data_index++] = data_shift;
1470         if (m_s3c240x_iic.data_index == 3)
14741471         {
1475            state->m_s3c240x_iic.address = (state->m_s3c240x_iic.data[1] << 8) | state->m_s3c240x_iic.data[2];
1472            m_s3c240x_iic.address = (m_s3c240x_iic.data[1] << 8) | m_s3c240x_iic.data[2];
14761473         }
1477         if ((state->m_s3c240x_iic.data_index == 4) && (state->m_s3c240x_iic.data[0] == 0xA0))
1474         if ((m_s3c240x_iic.data_index == 4) && (m_s3c240x_iic.data[0] == 0xA0))
14781475         {
1479            eeprom_write( machine, state->m_s3c240x_iic.address, data_shift);
1476            eeprom_write( machine(), m_s3c240x_iic.address, data_shift);
14801477         }
14811478      }
14821479      break;
14831480   }
1484   enable_interrupt = BIT( state->m_s3c240x_iic_regs[0], 5);
1481   enable_interrupt = BIT( m_s3c240x_iic_regs[0], 5);
14851482   if (enable_interrupt)
14861483   {
1487      s3c240x_request_irq( machine, INT_IIC);
1484      s3c240x_request_irq( machine(), INT_IIC);
14881485   }
14891486}
14901487
r18113r18114
15821579   }
15831580}
15841581
1585static TIMER_CALLBACK( s3c240x_iis_timer_exp )
1582TIMER_CALLBACK_MEMBER(gp32_state::s3c240x_iis_timer_exp)
15861583{
1587   verboselog( machine, 2, "IIS timer callback\n");
1588   s3c240x_dma_request_iis( machine);
1584   verboselog( machine(), 2, "IIS timer callback\n");
1585   s3c240x_dma_request_iis( machine());
15891586}
15901587
15911588// RTC
r18113r18114
16571654static void s3c240x_machine_start( running_machine &machine)
16581655{
16591656   gp32_state *state = machine.driver_data<gp32_state>();
1660   state->m_s3c240x_pwm_timer[0] = machine.scheduler().timer_alloc(FUNC(s3c240x_pwm_timer_exp), (void *)(FPTR)0);
1661   state->m_s3c240x_pwm_timer[1] = machine.scheduler().timer_alloc(FUNC(s3c240x_pwm_timer_exp), (void *)(FPTR)1);
1662   state->m_s3c240x_pwm_timer[2] = machine.scheduler().timer_alloc(FUNC(s3c240x_pwm_timer_exp), (void *)(FPTR)2);
1663   state->m_s3c240x_pwm_timer[3] = machine.scheduler().timer_alloc(FUNC(s3c240x_pwm_timer_exp), (void *)(FPTR)3);
1664   state->m_s3c240x_pwm_timer[4] = machine.scheduler().timer_alloc(FUNC(s3c240x_pwm_timer_exp), (void *)(FPTR)4);
1665   state->m_s3c240x_dma_timer[0] = machine.scheduler().timer_alloc(FUNC(s3c240x_dma_timer_exp), (void *)(FPTR)0);
1666   state->m_s3c240x_dma_timer[1] = machine.scheduler().timer_alloc(FUNC(s3c240x_dma_timer_exp), (void *)(FPTR)1);
1667   state->m_s3c240x_dma_timer[2] = machine.scheduler().timer_alloc(FUNC(s3c240x_dma_timer_exp), (void *)(FPTR)2);
1668   state->m_s3c240x_dma_timer[3] = machine.scheduler().timer_alloc(FUNC(s3c240x_dma_timer_exp), (void *)(FPTR)3);
1669   state->m_s3c240x_iic_timer = machine.scheduler().timer_alloc(FUNC(s3c240x_iic_timer_exp), (void *)(FPTR)0);
1670   state->m_s3c240x_iis_timer = machine.scheduler().timer_alloc(FUNC(s3c240x_iis_timer_exp), (void *)(FPTR)0);
1671   state->m_s3c240x_lcd_timer = machine.scheduler().timer_alloc(FUNC(s3c240x_lcd_timer_exp), (void *)(FPTR)0);
1657   state->m_s3c240x_pwm_timer[0] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),state), (void *)(FPTR)0);
1658   state->m_s3c240x_pwm_timer[1] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),state), (void *)(FPTR)1);
1659   state->m_s3c240x_pwm_timer[2] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),state), (void *)(FPTR)2);
1660   state->m_s3c240x_pwm_timer[3] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),state), (void *)(FPTR)3);
1661   state->m_s3c240x_pwm_timer[4] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_pwm_timer_exp),state), (void *)(FPTR)4);
1662   state->m_s3c240x_dma_timer[0] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_dma_timer_exp),state), (void *)(FPTR)0);
1663   state->m_s3c240x_dma_timer[1] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_dma_timer_exp),state), (void *)(FPTR)1);
1664   state->m_s3c240x_dma_timer[2] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_dma_timer_exp),state), (void *)(FPTR)2);
1665   state->m_s3c240x_dma_timer[3] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_dma_timer_exp),state), (void *)(FPTR)3);
1666   state->m_s3c240x_iic_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_iic_timer_exp),state), (void *)(FPTR)0);
1667   state->m_s3c240x_iis_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_iis_timer_exp),state), (void *)(FPTR)0);
1668   state->m_s3c240x_lcd_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(gp32_state::s3c240x_lcd_timer_exp),state), (void *)(FPTR)0);
16721669   state->m_eeprom_data = auto_alloc_array( machine, UINT8, 0x2000);
16731670   machine.device<nvram_device>("nvram")->set_base(state->m_eeprom_data, 0x2000);
16741671   smc_init( machine);
trunk/src/mess/drivers/intv.c
r18113r18114
796796/* This is needed because MAME core does not allow PULSE_LINE.
797797    The time interval is not critical, although it should be below 1000. */
798798
799static TIMER_CALLBACK(intv_interrupt2_complete)
799TIMER_CALLBACK_MEMBER(intv_state::intv_interrupt2_complete)
800800{
801   machine.device("keyboard")->execute().set_input_line(0, CLEAR_LINE);
801   machine().device("keyboard")->execute().set_input_line(0, CLEAR_LINE);
802802}
803803
804804INTERRUPT_GEN_MEMBER(intv_state::intv_interrupt2)
805805{
806806   machine().device("keyboard")->execute().set_input_line(0, ASSERT_LINE);
807   machine().scheduler().timer_set(machine().device<cpu_device>("keyboard")->cycles_to_attotime(100), FUNC(intv_interrupt2_complete));
807   machine().scheduler().timer_set(machine().device<cpu_device>("keyboard")->cycles_to_attotime(100), timer_expired_delegate(FUNC(intv_state::intv_interrupt2_complete),this));
808808}
809809
810810static MACHINE_CONFIG_START( intv, intv_state )
trunk/src/mess/drivers/cxhumax.c
r18113r18114
301301   COMBINE_DATA(&m_extdesc_regs[offset]);
302302}
303303
304static TIMER_CALLBACK( timer_tick )
304TIMER_CALLBACK_MEMBER(cxhumax_state::timer_tick)
305305{
306   cxhumax_state *state = machine.driver_data<cxhumax_state>();
307   state->m_timer_regs.timer[param].value++;
308   if(state->m_timer_regs.timer[param].value==state->m_timer_regs.timer[param].limit) {
306   m_timer_regs.timer[param].value++;
307   if(m_timer_regs.timer[param].value==m_timer_regs.timer[param].limit) {
309308      /* Reset counter when reaching limit and RESET_CNTR bit is cleared */
310      if(!(state->m_timer_regs.timer[param].mode & 2))
311         state->m_timer_regs.timer[param].value=0;
309      if(!(m_timer_regs.timer[param].mode & 2))
310         m_timer_regs.timer[param].value=0;
312311
313312      /* Indicate interrupt request if EN_INT bit is set */
314      if (state->m_timer_regs.timer[param].mode & 8) {
313      if (m_timer_regs.timer[param].mode & 8) {
315314         //printf( "IRQ on Timer %d\n", param );
316         verboselog( machine, 9, "(TIMER%d) Interrupt\n", param);
317         state->m_intctrl_regs[INTREG(INTGROUP2, INTIRQ)] |= INT_TIMER_BIT;     /* Timer interrupt */
318         state->m_intctrl_regs[INTREG(INTGROUP2, INTSTATCLR)] |= INT_TIMER_BIT; /* Timer interrupt */
319         state->m_intctrl_regs[INTREG(INTGROUP2, INTSTATSET)] |= INT_TIMER_BIT; /* Timer interrupt */
315         verboselog( machine(), 9, "(TIMER%d) Interrupt\n", param);
316         m_intctrl_regs[INTREG(INTGROUP2, INTIRQ)] |= INT_TIMER_BIT;     /* Timer interrupt */
317         m_intctrl_regs[INTREG(INTGROUP2, INTSTATCLR)] |= INT_TIMER_BIT; /* Timer interrupt */
318         m_intctrl_regs[INTREG(INTGROUP2, INTSTATSET)] |= INT_TIMER_BIT; /* Timer interrupt */
320319
321         state->m_timer_regs.timer_irq |= 1<<param; /* Indicate which timer interrupted */
320         m_timer_regs.timer_irq |= 1<<param; /* Indicate which timer interrupted */
322321
323322         /* Interrupt if Timer interrupt is not masked in ITC_INTENABLE_REG */
324         if (state->m_intctrl_regs[INTREG(INTGROUP2, INTENABLE)] & INT_TIMER_BIT)
325            machine.device("maincpu")->execute().set_input_line(ARM7_IRQ_LINE, ASSERT_LINE);
323         if (m_intctrl_regs[INTREG(INTGROUP2, INTENABLE)] & INT_TIMER_BIT)
324            machine().device("maincpu")->execute().set_input_line(ARM7_IRQ_LINE, ASSERT_LINE);
326325      }
327326   }
328   attotime period = attotime::from_hz(XTAL_54MHz)*state->m_timer_regs.timer[param].timebase;
329   state->m_timer_regs.timer[param].timer->adjust(period,param);
327   attotime period = attotime::from_hz(XTAL_54MHz)*m_timer_regs.timer[param].timebase;
328   m_timer_regs.timer[param].timer->adjust(period,param);
330329}
331330
332331READ32_MEMBER( cxhumax_state::cx_timers_r )
r18113r18114
983982   int index = 0;
984983   for(index = 0; index < MAX_CX_TIMERS; index++)
985984   {
986      m_timer_regs.timer[index].timer = machine().scheduler().timer_alloc(FUNC(timer_tick));
985      m_timer_regs.timer[index].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cxhumax_state::timer_tick),this));
987986      m_timer_regs.timer[index].timer->adjust(attotime::never, index);
988987   }
989988}
trunk/src/mess/drivers/xerox820.c
r18113r18114
386386   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("RIGHT CTRL") PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(RCONTROL))
387387INPUT_PORTS_END
388388
389static TIMER_CALLBACK( bigboard_beepoff )
389TIMER_CALLBACK_MEMBER(xerox820_state::bigboard_beepoff)
390390{
391   xerox820_state *state = machine.driver_data<xerox820_state>();
392   beep_set_state(state->m_beeper, 0);
391   beep_set_state(m_beeper, 0);
393392}
394393
395394/* Z80 PIO */
r18113r18114
461460   /* beeper on bigboard */
462461   if (BIT(data, 5) & (!m_bit5))
463462   {
464      machine().scheduler().timer_set(attotime::from_msec(40), FUNC(bigboard_beepoff));
463      machine().scheduler().timer_set(attotime::from_msec(40), timer_expired_delegate(FUNC(xerox820_state::bigboard_beepoff),this));
465464      beep_set_state(m_beeper, 1 );
466465   }
467466   m_bit5 = BIT(data, 5);
trunk/src/mess/drivers/pdp1.c
r18113r18114
383383
384384
385385static int tape_read(pdp1_state *state, UINT8 *reply);
386static TIMER_CALLBACK(reader_callback);
387static TIMER_CALLBACK(puncher_callback);
388static TIMER_CALLBACK(tyo_callback);
389static TIMER_CALLBACK(dpy_callback);
386
387
388
389
390390static void pdp1_machine_stop(running_machine &machine);
391391
392392static void pdp1_tape_read_binary(device_t *device);
r18113r18114
658658
659659   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(pdp1_machine_stop),&machine()));
660660
661   m_tape_reader.timer = machine().scheduler().timer_alloc(FUNC(reader_callback));
662   m_tape_puncher.timer = machine().scheduler().timer_alloc(FUNC(puncher_callback));
663   m_typewriter.tyo_timer = machine().scheduler().timer_alloc(FUNC(tyo_callback));
664   m_dpy_timer = machine().scheduler().timer_alloc(FUNC(dpy_callback));
661   m_tape_reader.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pdp1_state::reader_callback),this));
662   m_tape_puncher.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pdp1_state::puncher_callback),this));
663   m_typewriter.tyo_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pdp1_state::tyo_callback),this));
664   m_dpy_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pdp1_state::dpy_callback),this));
665665   m_tape_reader.timer->adjust(attotime::zero, 0, attotime::from_hz(2500));
666666   m_tape_reader.timer->enable(0);
667667}
r18113r18114
902902/*
903903    timer callback to simulate reader IO
904904*/
905static TIMER_CALLBACK(reader_callback)
905TIMER_CALLBACK_MEMBER(pdp1_state::reader_callback)
906906{
907   pdp1_state *state = machine.driver_data<pdp1_state>();
908907   int not_ready;
909908   UINT8 data;
910909
911   if (state->m_tape_reader.rc)
910   if (m_tape_reader.rc)
912911   {
913      not_ready = tape_read(state, & data);
912      not_ready = tape_read(this, & data);
914913      if (not_ready)
915914      {
916         state->m_tape_reader.motor_on = 0;   /* let us stop the motor */
915         m_tape_reader.motor_on = 0;   /* let us stop the motor */
917916      }
918917      else
919918      {
920         if ((! state->m_tape_reader.rby) || (data & 0200))
919         if ((! m_tape_reader.rby) || (data & 0200))
921920         {
922            state->m_tape_reader.rb |= (state->m_tape_reader.rby) ? (data & 077) : data;
921            m_tape_reader.rb |= (m_tape_reader.rby) ? (data & 077) : data;
923922
924            if (state->m_tape_reader.rc != 3)
923            if (m_tape_reader.rc != 3)
925924            {
926               state->m_tape_reader.rb <<= 6;
925               m_tape_reader.rb <<= 6;
927926            }
928927
929            state->m_tape_reader.rc = (state->m_tape_reader.rc+1) & 3;
928            m_tape_reader.rc = (m_tape_reader.rc+1) & 3;
930929
931            if (state->m_tape_reader.rc == 0)
930            if (m_tape_reader.rc == 0)
932931            {   /* IO complete */
933               state->m_tape_reader.rcl = 0;
934               if (state->m_tape_reader.rcp)
932               m_tape_reader.rcl = 0;
933               if (m_tape_reader.rcp)
935934               {
936                  machine.device("maincpu")->state().set_state_int(PDP1_IO, state->m_tape_reader.rb);   /* transfer reader buffer to IO */
937                  pdp1_pulse_iot_done(machine.device("maincpu"));
935                  machine().device("maincpu")->state().set_state_int(PDP1_IO, m_tape_reader.rb);   /* transfer reader buffer to IO */
936                  pdp1_pulse_iot_done(machine().device("maincpu"));
938937               }
939938               else
940                  state->m_io_status |= io_st_ptr;
939                  m_io_status |= io_st_ptr;
941940            }
942941         }
943942      }
944943   }
945944
946   if (state->m_tape_reader.motor_on && state->m_tape_reader.rcl)
945   if (m_tape_reader.motor_on && m_tape_reader.rcl)
947946   {
948      state->m_tape_reader.timer->enable(1);
947      m_tape_reader.timer->enable(1);
949948   }
950949   else
951950   {
952      state->m_tape_reader.timer->enable(0);
951      m_tape_reader.timer->enable(0);
953952   }
954953}
955954
r18113r18114
10801079/*
10811080    timer callback to generate punch completion pulse
10821081*/
1083static TIMER_CALLBACK(puncher_callback)
1082TIMER_CALLBACK_MEMBER(pdp1_state::puncher_callback)
10841083{
1085   pdp1_state *state = machine.driver_data<pdp1_state>();
10861084   int nac = param;
1087   state->m_io_status |= io_st_ptp;
1085   m_io_status |= io_st_ptp;
10881086   if (nac)
10891087   {
1090      pdp1_pulse_iot_done(machine.device("maincpu"));
1088      pdp1_pulse_iot_done(machine().device("maincpu"));
10911089   }
10921090}
10931091
r18113r18114
12901288/*
12911289    timer callback to generate typewriter completion pulse
12921290*/
1293static TIMER_CALLBACK(tyo_callback)
1291TIMER_CALLBACK_MEMBER(pdp1_state::tyo_callback)
12941292{
1295   pdp1_state *state = machine.driver_data<pdp1_state>();
12961293   int nac = param;
1297   state->m_io_status |= io_st_tyo;
1294   m_io_status |= io_st_tyo;
12981295   if (nac)
12991296   {
1300      pdp1_pulse_iot_done(machine.device("maincpu"));
1297      pdp1_pulse_iot_done(machine().device("maincpu"));
13011298   }
13021299}
13031300
r18113r18114
14131410/*
14141411    timer callback to generate crt completion pulse
14151412*/
1416static TIMER_CALLBACK(dpy_callback)
1413TIMER_CALLBACK_MEMBER(pdp1_state::dpy_callback)
14171414{
1418   pdp1_pulse_iot_done(machine.device("maincpu"));
1415   pdp1_pulse_iot_done(machine().device("maincpu"));
14191416}
14201417
14211418
r18113r18114
14781475}
14791476
14801477#ifdef UNUSED_FUNCTION
1481static TIMER_CALLBACK(il_timer_callback)
1478TIMER_CALLBACK_MEMBER(pdp1_state::il_timer_callback)
14821479{
1483   pdp1_state *state = machine.driver_data<pdp1_state>();
1484   if (state->m_parallel_drum.dba)
1480   if (m_parallel_drum.dba)
14851481   {
14861482      /* set break request and status bit 5 */
14871483      /* ... */
r18113r18114
14931489   state->m_parallel_drum.rotation_timer = machine.scheduler().timer_alloc();
14941490   state->m_parallel_drum.rotation_timer->adjust(PARALLEL_DRUM_ROTATION_TIME, 0, PARALLEL_DRUM_ROTATION_TIME);
14951491
1496   state->m_parallel_drum.il_timer = machine.scheduler().timer_alloc(FUNC(il_timer_callback));
1492   state->m_parallel_drum.il_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pdp1_state::il_timer_callback),this));
14971493   parallel_drum_set_il(0);
14981494}
14991495#endif
trunk/src/mess/drivers/nc.c
r18113r18114
296296   }
297297}
298298
299static TIMER_CALLBACK(nc_keyboard_timer_callback)
299TIMER_CALLBACK_MEMBER(nc_state::nc_keyboard_timer_callback)
300300{
301   nc_state *state = machine.driver_data<nc_state>();
302301      LOG(("keyboard int\n"));
303302
304303        /* set int */
305        state->m_irq_status |= (1<<3);
304        m_irq_status |= (1<<3);
306305
307306        /* update ints */
308        nc_update_interrupts(machine);
307        nc_update_interrupts(machine());
309308
310309        /* don't trigger again, but don't free it */
311        state->m_keyboard_timer->reset();
310        m_keyboard_timer->reset();
312311}
313312
314313
r18113r18114
539538   state->m_previous_inputport_10_state = inputport_10_state;
540539}
541540
542static TIMER_CALLBACK(nc_serial_timer_callback);
543541
542
544543static void nc_common_init_machine(running_machine &machine)
545544{
546545   nc_state *state = machine.driver_data<nc_state>();
r18113r18114
767766    19200
768767};
769768
770static TIMER_CALLBACK(nc_serial_timer_callback)
769TIMER_CALLBACK_MEMBER(nc_state::nc_serial_timer_callback)
771770{
772   i8251_device *uart = machine.device<i8251_device>("uart");
771   i8251_device *uart = machine().device<i8251_device>("uart");
773772
774773   uart->transmit_clock();
775774   uart->receive_clock();
r18113r18114
952951   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(nc100_machine_stop),&machine()));
953952
954953   /* keyboard timer */
955   m_keyboard_timer = machine().scheduler().timer_alloc(FUNC(nc_keyboard_timer_callback));
954   m_keyboard_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(nc_state::nc_keyboard_timer_callback),this));
956955   m_keyboard_timer->adjust(attotime::from_msec(10));
957956
958957   /* serial timer */
959   m_serial_timer = machine().scheduler().timer_alloc(FUNC(nc_serial_timer_callback));
958   m_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(nc_state::nc_serial_timer_callback),this));
960959}
961960
962961
r18113r18114
13421341   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(nc200_machine_stop),&machine()));
13431342
13441343   /* keyboard timer */
1345   m_keyboard_timer = machine().scheduler().timer_alloc(FUNC(nc_keyboard_timer_callback));
1344   m_keyboard_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(nc_state::nc_keyboard_timer_callback),this));
13461345   m_keyboard_timer->adjust(attotime::from_msec(10));
13471346
13481347   /* serial timer */
1349   m_serial_timer = machine().scheduler().timer_alloc(FUNC(nc_serial_timer_callback));
1348   m_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(nc_state::nc_serial_timer_callback),this));
13501349}
13511350
13521351/*
trunk/src/mess/drivers/svision.c
r18113r18114
2424#define YPOS state->m_reg[3]
2525#define BANK m_reg[0x26]
2626
27static TIMER_CALLBACK(svision_pet_timer)
27TIMER_CALLBACK_MEMBER(svision_state::svision_pet_timer)
2828{
29   svision_state *state = machine.driver_data<svision_state>();
30   switch (state->m_pet.state)
29   switch (m_pet.state)
3130   {
3231      case 0:
33         state->m_pet.input = machine.root_device().ioport("JOY2")->read();
32         m_pet.input = machine().root_device().ioport("JOY2")->read();
3433         /* fall through */
3534
3635      case 2: case 4: case 6: case 8:
3736      case 10: case 12: case 14:
38         state->m_pet.clock=state->m_pet.state&2;
39         state->m_pet.data=state->m_pet.input&1;
40         state->m_pet.input>>=1;
41         state->m_pet.state++;
37         m_pet.clock=m_pet.state&2;
38         m_pet.data=m_pet.input&1;
39         m_pet.input>>=1;
40         m_pet.state++;
4241         break;
4342
4443      case 16+15:
45         state->m_pet.state = 0;
44         m_pet.state = 0;
4645         break;
4746
4847      default:
49         state->m_pet.state++;
48         m_pet.state++;
5049         break;
5150   }
5251}
5352
5453static TIMER_DEVICE_CALLBACK(svision_pet_timer_dev)
5554{
56   svision_pet_timer(timer.machine(),ptr,param);
55   svision_state *state = timer.machine().driver_data<svision_state>();
56   state->svision_pet_timer(ptr,param);
5757}
5858
5959void svision_irq(running_machine &machine)
r18113r18114
6565   machine.device("maincpu")->execute().set_input_line(M6502_IRQ_LINE, irq ? ASSERT_LINE : CLEAR_LINE);
6666}
6767
68static TIMER_CALLBACK(svision_timer)
68TIMER_CALLBACK_MEMBER(svision_state::svision_timer)
6969{
70   svision_state *state = machine.driver_data<svision_state>();
71    state->m_svision.timer_shot = TRUE;
72    state->m_svision.timer1->enable(FALSE);
73    svision_irq( machine );
70    m_svision.timer_shot = TRUE;
71    m_svision.timer1->enable(FALSE);
72    svision_irq( machine() );
7473}
7574
7675READ8_MEMBER(svision_state::svision_r)
r18113r18114
424423
425424DRIVER_INIT_MEMBER(svision_state,svision)
426425{
427   m_svision.timer1 = machine().scheduler().timer_alloc(FUNC(svision_timer));
426   m_svision.timer1 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(svision_state::svision_timer),this));
428427   m_sound = machine().device("custom");
429428   m_dma_finished = svision_dma_finished(m_sound);
430429   m_pet.on = FALSE;
r18113r18114
433432
434433DRIVER_INIT_MEMBER(svision_state,svisions)
435434{
436   m_svision.timer1 = machine().scheduler().timer_alloc(FUNC(svision_timer));
435   m_svision.timer1 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(svision_state::svision_timer),this));
437436   m_sound = machine().device("custom");
438437   m_dma_finished = svision_dma_finished(m_sound);
439438   membank("bank2")->set_base(memregion("user1")->base() + 0x1c000);
440   m_svision.timer1 = machine().scheduler().timer_alloc(FUNC(svision_timer));
439   m_svision.timer1 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(svision_state::svision_timer),this));
441440   m_pet.on = TRUE;
442   m_pet.timer = machine().scheduler().timer_alloc(FUNC(svision_pet_timer));
441   m_pet.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(svision_state::svision_pet_timer),this));
443442}
444443
445444static DEVICE_IMAGE_LOAD( svision_cart )
trunk/src/mess/drivers/mpf1.c
r18113r18114
203203
204204/* Intel 8255A Interface */
205205
206static TIMER_CALLBACK( led_refresh )
206TIMER_CALLBACK_MEMBER(mpf1_state::led_refresh)
207207{
208   mpf1_state *state = machine.driver_data<mpf1_state>();
209208
210   if (BIT(state->m_lednum, 5)) output_set_digit_value(0, param);
211   if (BIT(state->m_lednum, 4)) output_set_digit_value(1, param);
212   if (BIT(state->m_lednum, 3)) output_set_digit_value(2, param);
213   if (BIT(state->m_lednum, 2)) output_set_digit_value(3, param);
214   if (BIT(state->m_lednum, 1)) output_set_digit_value(4, param);
215   if (BIT(state->m_lednum, 0)) output_set_digit_value(5, param);
209   if (BIT(m_lednum, 5)) output_set_digit_value(0, param);
210   if (BIT(m_lednum, 4)) output_set_digit_value(1, param);
211   if (BIT(m_lednum, 3)) output_set_digit_value(2, param);
212   if (BIT(m_lednum, 2)) output_set_digit_value(3, param);
213   if (BIT(m_lednum, 1)) output_set_digit_value(4, param);
214   if (BIT(m_lednum, 0)) output_set_digit_value(5, param);
216215}
217216
218217READ8_MEMBER( mpf1_state::ppi_pa_r )
r18113r18114
346345
347346void mpf1_state::machine_start()
348347{
349   m_led_refresh_timer = machine().scheduler().timer_alloc(FUNC(led_refresh));
348   m_led_refresh_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mpf1_state::led_refresh),this));
350349
351350   /* register for state saving */
352351   save_item(NAME(m_break));
trunk/src/mess/drivers/gba.c
r18113r18114
104104   }
105105}
106106
107static TIMER_CALLBACK( dma_complete )
107TIMER_CALLBACK_MEMBER(gba_state::dma_complete)
108108{
109109   int ctrl;
110110   FPTR ch;
111111   static const UINT32 ch_int[4] = { INT_DMA0, INT_DMA1, INT_DMA2, INT_DMA3 };
112   gba_state *state = machine.driver_data<gba_state>();
113112
114113   ch = param;
115114
116115//  printf("dma complete: ch %d\n", ch);
117116
118   state->m_dma_timer[ch]->adjust(attotime::never);
117   m_dma_timer[ch]->adjust(attotime::never);
119118
120   ctrl = state->m_dma_regs[(ch*3)+2] >> 16;
119   ctrl = m_dma_regs[(ch*3)+2] >> 16;
121120
122121   // IRQ
123122   if (ctrl & 0x4000)
124123   {
125      gba_request_irq(machine, ch_int[ch]);
124      gba_request_irq(machine(), ch_int[ch]);
126125   }
127126
128127   // if we're supposed to repeat, don't clear "active" and then the next vbl/hbl will retrigger us
r18113r18114
130129   if (!((ctrl>>9) & 1) || ((ctrl & 0x3000) == 0))
131130   {
132131//      printf("clear active for ch %d\n", ch);
133      state->m_dma_regs[(ch*3)+2] &= ~0x80000000;   // clear "active" bit
132      m_dma_regs[(ch*3)+2] &= ~0x80000000;   // clear "active" bit
134133   }
135134   else
136135   {
137136      // if repeat, reload the count
138137      if ((ctrl>>9) & 1)
139138      {
140         state->m_dma_cnt[ch] = state->m_dma_regs[(ch*3)+2]&0xffff;
139         m_dma_cnt[ch] = m_dma_regs[(ch*3)+2]&0xffff;
141140
142141         // if increment & reload mode, reload the destination
143142         if (((ctrl>>5)&3) == 3)
144143         {
145            state->m_dma_dst[ch] = state->m_dma_regs[(ch*3)+1];
144            m_dma_dst[ch] = m_dma_regs[(ch*3)+1];
146145         }
147146      }
148147   }
r18113r18114
278277
279278//  printf("settng DMA timer %d for %d cycs (tmr %x)\n", ch, cnt, (UINT32)state->m_dma_timer[ch]);
280279//  state->m_dma_timer[ch]->adjust(ATTOTIME_IN_CYCLES(0, cnt), ch);
281   dma_complete(machine, NULL, ch);
280   state->dma_complete(NULL, ch);
282281}
283282
284283static void audio_tick(running_machine &machine, int ref)
r18113r18114
371370   }
372371}
373372
374static TIMER_CALLBACK(timer_expire)
373TIMER_CALLBACK_MEMBER(gba_state::timer_expire)
375374{
376375   static const UINT32 tmr_ints[4] = { INT_TM0_OVERFLOW, INT_TM1_OVERFLOW, INT_TM2_OVERFLOW, INT_TM3_OVERFLOW };
377376   FPTR tmr = (FPTR) param;
378   gba_state *state = machine.driver_data<gba_state>();
379377
380//  printf("Timer %d expired, SOUNDCNT_H %04x\n", tmr, state->m_SOUNDCNT_H);
378//  printf("Timer %d expired, SOUNDCNT_H %04x\n", tmr, m_SOUNDCNT_H);
381379
382380   // "The reload value is copied into the counter only upon following two situations: Automatically upon timer overflows,"
383381   // "or when the timer start bit becomes changed from 0 to 1."
384   if (state->m_timer_recalc[tmr] != 0)
382   if (m_timer_recalc[tmr] != 0)
385383   {
386384      double rate, clocksel, final;
387385      attotime time;
388      state->m_timer_recalc[tmr] = 0;
389      state->m_timer_regs[tmr] = (state->m_timer_regs[tmr] & 0xFFFF0000) | (state->m_timer_reload[tmr] & 0x0000FFFF);
390      rate = 0x10000 - (state->m_timer_regs[tmr] & 0xffff);
391      clocksel = timer_clks[(state->m_timer_regs[tmr] >> 16) & 3];
386      m_timer_recalc[tmr] = 0;
387      m_timer_regs[tmr] = (m_timer_regs[tmr] & 0xFFFF0000) | (m_timer_reload[tmr] & 0x0000FFFF);
388      rate = 0x10000 - (m_timer_regs[tmr] & 0xffff);
389      clocksel = timer_clks[(m_timer_regs[tmr] >> 16) & 3];
392390      final = clocksel / rate;
393      state->m_timer_hz[tmr] = final;
391      m_timer_hz[tmr] = final;
394392      time = attotime::from_hz(final);
395393      GBA_ATTOTIME_NORMALIZE(time);
396      state->m_tmr_timer[tmr]->adjust(time, tmr, time);
394      m_tmr_timer[tmr]->adjust(time, tmr, time);
397395   }
398396
399397   // check if timers 0 or 1 are feeding directsound
400398   if (tmr == 0)
401399   {
402      if ((state->m_SOUNDCNT_H & 0x400) == 0)
400      if ((m_SOUNDCNT_H & 0x400) == 0)
403401      {
404         audio_tick(machine, 0);
402         audio_tick(machine(), 0);
405403      }
406404
407      if ((state->m_SOUNDCNT_H & 0x4000) == 0)
405      if ((m_SOUNDCNT_H & 0x4000) == 0)
408406      {
409         audio_tick(machine, 1);
407         audio_tick(machine(), 1);
410408      }
411409   }
412410
413411   if (tmr == 1)
414412   {
415      if ((state->m_SOUNDCNT_H & 0x400) == 0x400)
413      if ((m_SOUNDCNT_H & 0x400) == 0x400)
416414      {
417         audio_tick(machine, 0);
415         audio_tick(machine(), 0);
418416      }
419417
420      if ((state->m_SOUNDCNT_H & 0x4000) == 0x4000)
418      if ((m_SOUNDCNT_H & 0x4000) == 0x4000)
421419      {
422         audio_tick(machine, 1);
420         audio_tick(machine(), 1);
423421      }
424422   }
425423
r18113r18114
427425   switch (tmr)
428426   {
429427   case 0:
430      if (state->m_timer_regs[1] & 0x40000)
428      if (m_timer_regs[1] & 0x40000)
431429      {
432         state->m_timer_regs[1] = (( ( state->m_timer_regs[1] & 0x0000ffff ) + 1 ) & 0x0000ffff) | (state->m_timer_regs[1] & 0xffff0000);
433         if( ( state->m_timer_regs[1] & 0x0000ffff ) == 0 )
430         m_timer_regs[1] = (( ( m_timer_regs[1] & 0x0000ffff ) + 1 ) & 0x0000ffff) | (m_timer_regs[1] & 0xffff0000);
431         if( ( m_timer_regs[1] & 0x0000ffff ) == 0 )
434432         {
435            state->m_timer_regs[1] |= state->m_timer_reload[1];
436            if( ( state->m_timer_regs[1] & 0x400000 ) && ( state->m_IME != 0 ) )
433            m_timer_regs[1] |= m_timer_reload[1];
434            if( ( m_timer_regs[1] & 0x400000 ) && ( m_IME != 0 ) )
437435            {
438               gba_request_irq( machine, tmr_ints[1] );
436               gba_request_irq( machine(), tmr_ints[1] );
439437            }
440            if( ( state->m_timer_regs[2] & 0x40000 ) )
438            if( ( m_timer_regs[2] & 0x40000 ) )
441439            {
442               state->m_timer_regs[2] = (( ( state->m_timer_regs[2] & 0x0000ffff ) + 1 ) & 0x0000ffff) | (state->m_timer_regs[2] & 0xffff0000);
443               if( ( state->m_timer_regs[2] & 0x0000ffff ) == 0 )
440               m_timer_regs[2] = (( ( m_timer_regs[2] & 0x0000ffff ) + 1 ) & 0x0000ffff) | (m_timer_regs[2] & 0xffff0000);
441               if( ( m_timer_regs[2] & 0x0000ffff ) == 0 )
444442               {
445                  state->m_timer_regs[2] |= state->m_timer_reload[2];
446                  if( ( state->m_timer_regs[2] & 0x400000 ) && ( state->m_IME != 0 ) )
443                  m_timer_regs[2] |= m_timer_reload[2];
444                  if( ( m_timer_regs[2] & 0x400000 ) && ( m_IME != 0 ) )
447445                  {
448                     gba_request_irq( machine, tmr_ints[2] );
446                     gba_request_irq( machine(), tmr_ints[2] );
449447                  }
450                  if( ( state->m_timer_regs[3] & 0x40000 ) )
448                  if( ( m_timer_regs[3] & 0x40000 ) )
451449                  {
452                     state->m_timer_regs[3] = (( ( state->m_timer_regs[3] & 0x0000ffff ) + 1 ) & 0x0000ffff) | (state->m_timer_regs[3] & 0xffff0000);
453                     if( ( state->m_timer_regs[3] & 0x0000ffff ) == 0 )
450                     m_timer_regs[3] = (( ( m_timer_regs[3] & 0x0000ffff ) + 1 ) & 0x0000ffff) | (m_timer_regs[3] & 0xffff0000);
451                     if( ( m_timer_regs[3] & 0x0000ffff ) == 0 )
454452                     {
455                        state->m_timer_regs[3] |= state->m_timer_reload[3];
456                        if( ( state->m_timer_regs[3] & 0x400000 ) && ( state->m_IME != 0 ) )
453                        m_timer_regs[3] |= m_timer_reload[3];
454                        if( ( m_timer_regs[3] & 0x400000 ) && ( m_IME != 0 ) )
457455                        {
458                           gba_request_irq( machine, tmr_ints[3] );
456                           gba_request_irq( machine(), tmr_ints[3] );
459457                        }
460458                     }
461459                  }
r18113r18114
465463      }
466464      break;
467465   case 1:
468      if (state->m_timer_regs[2] & 0x40000)
466      if (m_timer_regs[2] & 0x40000)
469467      {
470         state->m_timer_regs[2] = (( ( state->m_timer_regs[2] & 0x0000ffff ) + 1 ) & 0x0000ffff) | (state->m_timer_regs[2] & 0xffff0000);
471         if( ( state->m_timer_regs[2] & 0x0000ffff ) == 0 )
468         m_timer_regs[2] = (( ( m_timer_regs[2] & 0x0000ffff ) + 1 ) & 0x0000ffff) | (m_timer_regs[2] & 0xffff0000);
469         if( ( m_timer_regs[2] & 0x0000ffff ) == 0 )
472470         {
473            state->m_timer_regs[2] |= state->m_timer_reload[2];
474            if( ( state->m_timer_regs[2] & 0x400000 ) && ( state->m_IME != 0 ) )
471            m_timer_regs[2] |= m_timer_reload[2];
472            if( ( m_timer_regs[2] & 0x400000 ) && ( m_IME != 0 ) )
475473            {
476               gba_request_irq( machine, tmr_ints[2] );
474               gba_request_irq( machine(), tmr_ints[2] );
477475            }
478            if( ( state->m_timer_regs[3] & 0x40000 ) )
476            if( ( m_timer_regs[3] & 0x40000 ) )
479477            {
480               state->m_timer_regs[3] = (( ( state->m_timer_regs[3] & 0x0000ffff ) + 1 ) & 0x0000ffff) | (state->m_timer_regs[3] & 0xffff0000);
481               if( ( state->m_timer_regs[3] & 0x0000ffff ) == 0 )
478               m_timer_regs[3] = (( ( m_timer_regs[3] & 0x0000ffff ) + 1 ) & 0x0000ffff) | (m_timer_regs[3] & 0xffff0000);
479               if( ( m_timer_regs[3] & 0x0000ffff ) == 0 )
482480               {
483                  state->m_timer_regs[3] |= state->m_timer_reload[3];
484                  if( ( state->m_timer_regs[3] & 0x400000 ) && ( state->m_IME != 0 ) )
481                  m_timer_regs[3] |= m_timer_reload[3];
482                  if( ( m_timer_regs[3] & 0x400000 ) && ( m_IME != 0 ) )
485483                  {
486                     gba_request_irq( machine, tmr_ints[3] );
484                     gba_request_irq( machine(), tmr_ints[3] );
487485                  }
488486               }
489487            }
r18113r18114
491489      }
492490      break;
493491   case 2:
494      if (state->m_timer_regs[3] & 0x40000)
492      if (m_timer_regs[3] & 0x40000)
495493      {
496         state->m_timer_regs[3] = (( ( state->m_timer_regs[3] & 0x0000ffff ) + 1 ) & 0x0000ffff) | (state->m_timer_regs[3] & 0xffff0000);
497         if( ( state->m_timer_regs[3] & 0x0000ffff ) == 0 )
494         m_timer_regs[3] = (( ( m_timer_regs[3] & 0x0000ffff ) + 1 ) & 0x0000ffff) | (m_timer_regs[3] & 0xffff0000);
495         if( ( m_timer_regs[3] & 0x0000ffff ) == 0 )
498496         {
499            state->m_timer_regs[3] |= state->m_timer_reload[3];
500            if( ( state->m_timer_regs[3] & 0x400000 ) && ( state->m_IME != 0 ) )
497            m_timer_regs[3] |= m_timer_reload[3];
498            if( ( m_timer_regs[3] & 0x400000 ) && ( m_IME != 0 ) )
501499            {
502               gba_request_irq( machine, tmr_ints[3] );
500               gba_request_irq( machine(), tmr_ints[3] );
503501            }
504502         }
505503      }
r18113r18114
507505   }
508506
509507   // are we supposed to IRQ?
510   if ((state->m_timer_regs[tmr] & 0x400000) && (state->m_IME != 0))
508   if ((m_timer_regs[tmr] & 0x400000) && (m_IME != 0))
511509   {
512      gba_request_irq(machine, tmr_ints[tmr]);
510      gba_request_irq(machine(), tmr_ints[tmr]);
513511   }
514512}
515513
516static TIMER_CALLBACK(handle_irq)
514TIMER_CALLBACK_MEMBER(gba_state::handle_irq)
517515{
518   gba_state *state = machine.driver_data<gba_state>();
519516
520   gba_request_irq(machine, state->m_IF);
517   gba_request_irq(machine(), m_IF);
521518
522   state->m_irq_timer->adjust(attotime::never);
519   m_irq_timer->adjust(attotime::never);
523520}
524521
525522READ32_MEMBER(gba_state::gba_io_r)
r18113r18114
20042001   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("A") PORT_PLAYER(1)   // A
20052002INPUT_PORTS_END
20062003
2007static TIMER_CALLBACK( perform_hbl )
2004TIMER_CALLBACK_MEMBER(gba_state::perform_hbl)
20082005{
20092006   int ch, ctrl;
2010   gba_state *state = machine.driver_data<gba_state>();
2011   int scanline = machine.primary_screen->vpos();
2007   int scanline = machine().primary_screen->vpos();
20122008
20132009   // draw only visible scanlines
20142010   if (scanline < 160)
20152011   {
2016      gba_draw_scanline(machine, scanline);
2012      gba_draw_scanline(machine(), scanline);
20172013   }
2018   state->m_DISPSTAT |= DISPSTAT_HBL;
2019   if ((state->m_DISPSTAT & DISPSTAT_HBL_IRQ_EN ) != 0)
2014   m_DISPSTAT |= DISPSTAT_HBL;
2015   if ((m_DISPSTAT & DISPSTAT_HBL_IRQ_EN ) != 0)
20202016   {
2021      gba_request_irq(machine, INT_HBL);
2017      gba_request_irq(machine(), INT_HBL);
20222018   }
20232019
20242020   for (ch = 0; ch < 4; ch++)
20252021   {
2026      ctrl = state->m_dma_regs[(ch*3)+2]>>16;
2022      ctrl = m_dma_regs[(ch*3)+2]>>16;
20272023
20282024      // HBL-triggered DMA?
20292025      if ((ctrl & 0x8000) && ((ctrl & 0x3000) == 0x2000))
20302026      {
2031         dma_exec(machine, ch);
2027         dma_exec(machine(), ch);
20322028      }
20332029   }
20342030
2035   state->m_hbl_timer->adjust(attotime::never);
2031   m_hbl_timer->adjust(attotime::never);
20362032}
20372033
2038static TIMER_CALLBACK( perform_scan )
2034TIMER_CALLBACK_MEMBER(gba_state::perform_scan)
20392035{
20402036   int scanline;
2041   gba_state *state = machine.driver_data<gba_state>();
20422037
20432038   // clear hblank and raster IRQ flags
2044   state->m_DISPSTAT &= ~(DISPSTAT_HBL|DISPSTAT_VCNT);
2039   m_DISPSTAT &= ~(DISPSTAT_HBL|DISPSTAT_VCNT);
20452040
2046   scanline = machine.primary_screen->vpos();
2041   scanline = machine().primary_screen->vpos();
20472042
20482043   // VBL is set for scanlines 160 through 226 (but not 227, which is the last line)
20492044   if (scanline >= 160 && scanline < 227)
20502045   {
2051      state->m_DISPSTAT |= DISPSTAT_VBL;
2046      m_DISPSTAT |= DISPSTAT_VBL;
20522047   }
20532048   else
20542049   {
2055      state->m_DISPSTAT &= ~DISPSTAT_VBL;
2050      m_DISPSTAT &= ~DISPSTAT_VBL;
20562051   }
20572052
20582053   // handle VCNT match interrupt/flag
2059   if (scanline == ((state->m_DISPSTAT >> 8) & 0xff))
2054   if (scanline == ((m_DISPSTAT >> 8) & 0xff))
20602055   {
2061      state->m_DISPSTAT |= DISPSTAT_VCNT;
2062      if (state->m_DISPSTAT & DISPSTAT_VCNT_IRQ_EN)
2056      m_DISPSTAT |= DISPSTAT_VCNT;
2057      if (m_DISPSTAT & DISPSTAT_VCNT_IRQ_EN)
20632058      {
2064         gba_request_irq(machine, INT_VCNT);
2059         gba_request_irq(machine(), INT_VCNT);
20652060      }
20662061   }
20672062
r18113r18114
20922087      // More work on IRQs is definitely necessary!
20932088      int ch, ctrl;
20942089
2095      if (state->m_DISPSTAT & DISPSTAT_VBL_IRQ_EN)
2090      if (m_DISPSTAT & DISPSTAT_VBL_IRQ_EN)
20962091      {
2097         gba_request_irq(machine, INT_VBL);
2092         gba_request_irq(machine(), INT_VBL);
20982093      }
20992094
21002095      for (ch = 0; ch < 4; ch++)
21012096      {
2102         ctrl = state->m_dma_regs[(ch*3)+2]>>16;
2097         ctrl = m_dma_regs[(ch*3)+2]>>16;
21032098
21042099         // VBL-triggered DMA?
21052100         if ((ctrl & 0x8000) && ((ctrl & 0x3000) == 0x1000))
21062101         {
2107            dma_exec(machine, ch);
2102            dma_exec(machine(), ch);
21082103         }
21092104      }
21102105   }
21112106
2112   state->m_hbl_timer->adjust(machine.primary_screen->time_until_pos(scanline, 240));
2113   state->m_scan_timer->adjust(machine.primary_screen->time_until_pos(( scanline + 1 ) % 228, 0));
2107   m_hbl_timer->adjust(machine().primary_screen->time_until_pos(scanline, 240));
2108   m_scan_timer->adjust(machine().primary_screen->time_until_pos(( scanline + 1 ) % 228, 0));
21142109}
21152110
21162111void gba_state::machine_reset()
r18113r18114
21792174   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(gba_machine_stop),&machine()));
21802175
21812176   /* create a timer to fire scanline functions */
2182   m_scan_timer = machine().scheduler().timer_alloc(FUNC(perform_scan));
2183   m_hbl_timer = machine().scheduler().timer_alloc(FUNC(perform_hbl));
2177   m_scan_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gba_state::perform_scan),this));
2178   m_hbl_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gba_state::perform_hbl),this));
21842179   m_scan_timer->adjust(machine().primary_screen->time_until_pos(0, 0));
21852180
21862181   /* and one for each DMA channel */
2187   m_dma_timer[0] = machine().scheduler().timer_alloc(FUNC(dma_complete));
2188   m_dma_timer[1] = machine().scheduler().timer_alloc(FUNC(dma_complete));
2189   m_dma_timer[2] = machine().scheduler().timer_alloc(FUNC(dma_complete));
2190   m_dma_timer[3] = machine().scheduler().timer_alloc(FUNC(dma_complete));
2182   m_dma_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gba_state::dma_complete),this));
2183   m_dma_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gba_state::dma_complete),this));
2184   m_dma_timer[2] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gba_state::dma_complete),this));
2185   m_dma_timer[3] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gba_state::dma_complete),this));
21912186   m_dma_timer[0]->adjust(attotime::never);
21922187   m_dma_timer[1]->adjust(attotime::never, 1);
21932188   m_dma_timer[2]->adjust(attotime::never, 2);
21942189   m_dma_timer[3]->adjust(attotime::never, 3);
21952190
21962191   /* also one for each timer (heh) */
2197   m_tmr_timer[0] = machine().scheduler().timer_alloc(FUNC(timer_expire));
2198   m_tmr_timer[1] = machine().scheduler().timer_alloc(FUNC(timer_expire));
2199   m_tmr_timer[2] = machine().scheduler().timer_alloc(FUNC(timer_expire));
2200   m_tmr_timer[3] = machine().scheduler().timer_alloc(FUNC(timer_expire));
2192   m_tmr_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gba_state::timer_expire),this));
2193   m_tmr_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gba_state::timer_expire),this));
2194   m_tmr_timer[2] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gba_state::timer_expire),this));
2195   m_tmr_timer[3] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gba_state::timer_expire),this));
22012196   m_tmr_timer[0]->adjust(attotime::never);
22022197   m_tmr_timer[1]->adjust(attotime::never, 1);
22032198   m_tmr_timer[2]->adjust(attotime::never, 2);
22042199   m_tmr_timer[3]->adjust(attotime::never, 3);
22052200
22062201   /* and an IRQ handling timer */
2207   m_irq_timer = machine().scheduler().timer_alloc(FUNC(handle_irq));
2202   m_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gba_state::handle_irq),this));
22082203   m_irq_timer->adjust(attotime::never);
22092204}
22102205
trunk/src/mess/drivers/coleco.c
r18113r18114
176176   drvstate->m_last_nmi_state = state;
177177}
178178
179static TIMER_CALLBACK( paddle_d7reset_callback )
179TIMER_CALLBACK_MEMBER(coleco_state::paddle_d7reset_callback)
180180{
181   coleco_state *state = machine.driver_data<coleco_state>();
182181
183   state->m_joy_d7_state[param] = 0;
184   state->m_joy_analog_state[param] = 0;
182   m_joy_d7_state[param] = 0;
183   m_joy_analog_state[param] = 0;
185184}
186185
187static TIMER_CALLBACK( paddle_irqreset_callback )
186TIMER_CALLBACK_MEMBER(coleco_state::paddle_irqreset_callback)
188187{
189   coleco_state *state = machine.driver_data<coleco_state>();
190188
191   state->m_joy_irq_state[param] = 0;
189   m_joy_irq_state[param] = 0;
192190
193   if (!state->m_joy_irq_state[param ^ 1])
194      state->m_maincpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE);
191   if (!m_joy_irq_state[param ^ 1])
192      m_maincpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE);
195193}
196194
197static TIMER_CALLBACK( paddle_pulse_callback )
195TIMER_CALLBACK_MEMBER(coleco_state::paddle_pulse_callback)
198196{
199   coleco_state *state = machine.driver_data<coleco_state>();
200197
201   if (state->m_joy_analog_reload[param])
198   if (m_joy_analog_reload[param])
202199   {
203      state->m_joy_analog_state[param] = state->m_joy_analog_reload[param];
200      m_joy_analog_state[param] = m_joy_analog_reload[param];
204201
205202      // on movement, controller port d7 is set for a short period and an irq is fired on d7 rising edge
206      state->m_joy_d7_state[param] = 0x80;
207      state->m_joy_d7_timer[param]->adjust(attotime::from_usec(500), param); // TODO: measure duration
203      m_joy_d7_state[param] = 0x80;
204      m_joy_d7_timer[param]->adjust(attotime::from_usec(500), param); // TODO: measure duration
208205
209206      // irq on rising edge, PULSE_LINE is not supported in this case, so clear it manually
210      state->m_maincpu->set_input_line(INPUT_LINE_IRQ0, ASSERT_LINE);
211      state->m_joy_irq_timer[param]->adjust(attotime::from_usec(11), param); // TODO: measure duration
212      state->m_joy_irq_state[param] = 1;
207      m_maincpu->set_input_line(INPUT_LINE_IRQ0, ASSERT_LINE);
208      m_joy_irq_timer[param]->adjust(attotime::from_usec(11), param); // TODO: measure duration
209      m_joy_irq_state[param] = 1;
213210
214211      // reload timer
215      state->m_joy_pulse_timer[param]->adjust(state->m_joy_pulse_reload[param], param);
212      m_joy_pulse_timer[param]->adjust(m_joy_pulse_reload[param], param);
216213   }
217214}
218215
r18113r18114
264261   // init paddles
265262   for (int port = 0; port < 2; port++)
266263   {
267      m_joy_pulse_timer[port] = machine().scheduler().timer_alloc(FUNC(paddle_pulse_callback));
268      m_joy_d7_timer[port] = machine().scheduler().timer_alloc(FUNC(paddle_d7reset_callback));
269      m_joy_irq_timer[port] = machine().scheduler().timer_alloc(FUNC(paddle_irqreset_callback));
264      m_joy_pulse_timer[port] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(coleco_state::paddle_pulse_callback),this));
265      m_joy_d7_timer[port] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(coleco_state::paddle_d7reset_callback),this));
266      m_joy_irq_timer[port] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(coleco_state::paddle_irqreset_callback),this));
270267
271268      m_joy_irq_state[port] = 0;
272269      m_joy_d7_state[port] = 0;
trunk/src/mess/drivers/samcoupe.c
r18113r18114
325325    INTERRUPTS
326326***************************************************************************/
327327
328static TIMER_CALLBACK( irq_off )
328TIMER_CALLBACK_MEMBER(samcoupe_state::irq_off)
329329{
330   samcoupe_state *state = machine.driver_data<samcoupe_state>();
331330   /* adjust STATUS register */
332   state->m_status |= param;
331   m_status |= param;
333332
334333   /* clear interrupt */
335   if ((state->m_status & 0x1f) == 0x1f)
336      machine.device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
334   if ((m_status & 0x1f) == 0x1f)
335      machine().device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
337336
338337}
339338
r18113r18114
343342
344343   /* assert irq and a timer to set it off again */
345344   device->execute().set_input_line(0, ASSERT_LINE);
346   device->machine().scheduler().timer_set(attotime::from_usec(20), FUNC(irq_off), src);
345   device->machine().scheduler().timer_set(attotime::from_usec(20), timer_expired_delegate(FUNC(samcoupe_state::irq_off),state), src);
347346
348347   /* adjust STATUS register */
349348   state->m_status &= ~src;
trunk/src/mess/drivers/atarist.c
r18113r18114
479479//  TIMER_CALLBACK( st_mouse_tick )
480480//-------------------------------------------------
481481
482static TIMER_CALLBACK( st_mouse_tick )
482TIMER_CALLBACK_MEMBER(st_state::st_mouse_tick)
483483{
484   st_state *state = machine.driver_data<st_state>();
485484
486   state->mouse_tick();
485   mouse_tick();
487486}
488487
489488
r18113r18114
776775//  TIMER_CALLBACK( atariste_dmasound_tick )
777776//-------------------------------------------------
778777
779static TIMER_CALLBACK( atariste_dmasound_tick )
778TIMER_CALLBACK_MEMBER(ste_state::atariste_dmasound_tick)
780779{
781   ste_state *state = machine.driver_data<ste_state>();
782780
783   state->dmasound_tick();
781   dmasound_tick();
784782}
785783
786784
r18113r18114
10271025//  TIMER_CALLBACK( atariste_microwire_tick )
10281026//-------------------------------------------------
10291027
1030static TIMER_CALLBACK( atariste_microwire_tick )
1028TIMER_CALLBACK_MEMBER(ste_state::atariste_microwire_tick)
10311029{
1032   ste_state *state = machine.driver_data<ste_state>();
10331030
1034   state->microwire_tick();
1031   microwire_tick();
10351032}
10361033
10371034
r18113r18114
22082205   m_maincpu->set_irq_acknowledge_callback(atarist_int_ack);
22092206
22102207   // allocate timers
2211   m_mouse_timer = machine().scheduler().timer_alloc(FUNC(st_mouse_tick));
2208   m_mouse_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(st_state::st_mouse_tick),this));
22122209   m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(500));
22132210
22142211   // register for state saving
r18113r18114
22652262   m_maincpu->set_irq_acknowledge_callback(atarist_int_ack);
22662263
22672264   /* allocate timers */
2268   m_dmasound_timer = machine().scheduler().timer_alloc(FUNC(atariste_dmasound_tick));
2269   m_microwire_timer = machine().scheduler().timer_alloc(FUNC(atariste_microwire_tick));
2265   m_dmasound_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ste_state::atariste_dmasound_tick),this));
2266   m_microwire_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ste_state::atariste_microwire_tick),this));
22702267
22712268   /* register for state saving */
22722269   state_save();
trunk/src/mess/drivers/tx0.c
r18113r18114
340340*/
341341
342342
343static TIMER_CALLBACK(reader_callback);
344static TIMER_CALLBACK(puncher_callback);
345static TIMER_CALLBACK(prt_callback);
346static TIMER_CALLBACK(dis_callback);
347343
348344
349345
r18113r18114
352348
353349
354350
351
352
353
354
355355/* crt display timer */
356356
357357
r18113r18114
383383
384384void tx0_state::machine_start()
385385{
386   m_tape_reader.timer = machine().scheduler().timer_alloc(FUNC(reader_callback));
387   m_tape_puncher.timer = machine().scheduler().timer_alloc(FUNC(puncher_callback));
388   m_typewriter.prt_timer = machine().scheduler().timer_alloc(FUNC(prt_callback));
389   m_dis_timer = machine().scheduler().timer_alloc(FUNC(dis_callback));
386   m_tape_reader.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(tx0_state::reader_callback),this));
387   m_tape_puncher.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(tx0_state::puncher_callback),this));
388   m_typewriter.prt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(tx0_state::prt_callback),this));
389   m_dis_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(tx0_state::dis_callback),this));
390390
391391   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(tx0_machine_stop),&machine()));
392392}
r18113r18114
631631/*
632632    timer callback to simulate reader IO
633633*/
634static TIMER_CALLBACK(reader_callback)
634TIMER_CALLBACK_MEMBER(tx0_state::reader_callback)
635635{
636   tx0_state *state = machine.driver_data<tx0_state>();
637636   int not_ready;
638637   UINT8 data;
639638   int ac;
640639
641   if (state->m_tape_reader.rc)
640   if (m_tape_reader.rc)
642641   {
643      not_ready = tape_read(state, & data);
642      not_ready = tape_read(this, & data);
644643      if (not_ready)
645644      {
646         state->m_tape_reader.motor_on = 0;   /* let us stop the motor */
645         m_tape_reader.motor_on = 0;   /* let us stop the motor */
647646      }
648647      else
649648      {
650649         if (data & 0100)
651650         {
652651            /* read current AC */
653            ac = machine.device("maincpu")->state().state_int(TX0_AC);
652            ac = machine().device("maincpu")->state().state_int(TX0_AC);
654653            /* cycle right */
655654            ac = (ac >> 1) | ((ac & 1) << 17);
656655            /* shuffle and insert data into AC */
657656            ac = (ac /*& 0333333*/) | ((data & 001) << 17) | ((data & 002) << 13) | ((data & 004) << 9) | ((data & 010) << 5) | ((data & 020) << 1) | ((data & 040) >> 3);
658657            /* write modified AC */
659            machine.device("maincpu")->state().set_state_int(TX0_AC, ac);
658            machine().device("maincpu")->state().set_state_int(TX0_AC, ac);
660659
661            state->m_tape_reader.rc = (state->m_tape_reader.rc+1) & 3;
660            m_tape_reader.rc = (m_tape_reader.rc+1) & 3;
662661
663            if (state->m_tape_reader.rc == 0)
662            if (m_tape_reader.rc == 0)
664663            {   /* IO complete */
665               state->m_tape_reader.rcl = 0;
666               machine.device("maincpu")->state().set_state_int(TX0_IO_COMPLETE, (UINT64)0);
664               m_tape_reader.rcl = 0;
665               machine().device("maincpu")->state().set_state_int(TX0_IO_COMPLETE, (UINT64)0);
667666            }
668667         }
669668      }
670669   }
671670
672   if (state->m_tape_reader.motor_on && state->m_tape_reader.rcl)
671   if (m_tape_reader.motor_on && m_tape_reader.rcl)
673672      /* delay is approximately 1/400s */
674      state->m_tape_reader.timer->adjust(attotime::from_usec(2500));
673      m_tape_reader.timer->adjust(attotime::from_usec(2500));
675674   else
676      state->m_tape_reader.timer->enable(0);
675      m_tape_reader.timer->enable(0);
677676}
678677
679678/*
r18113r18114
697696   state->m_tape_puncher.fd = NULL;
698697}
699698
700static TIMER_CALLBACK(puncher_callback)
699TIMER_CALLBACK_MEMBER(tx0_state::puncher_callback)
701700{
702   machine.device("maincpu")->state().set_state_int(TX0_IO_COMPLETE, (UINT64)0);
701   machine().device("maincpu")->state().set_state_int(TX0_IO_COMPLETE, (UINT64)0);
703702}
704703
705704/*
r18113r18114
792791/*
793792    timer callback to generate typewriter completion pulse
794793*/
795static TIMER_CALLBACK(prt_callback)
794TIMER_CALLBACK_MEMBER(tx0_state::prt_callback)
796795{
797   machine.device("maincpu")->state().set_state_int(TX0_IO_COMPLETE, (UINT64)0);
796   machine().device("maincpu")->state().set_state_int(TX0_IO_COMPLETE, (UINT64)0);
798797}
799798
800799/*
r18113r18114
819818/*
820819    timer callback to generate crt completion pulse
821820*/
822static TIMER_CALLBACK(dis_callback)
821TIMER_CALLBACK_MEMBER(tx0_state::dis_callback)
823822{
824   machine.device("maincpu")->state().set_state_int(TX0_IO_COMPLETE, (UINT64)0);
823   machine().device("maincpu")->state().set_state_int(TX0_IO_COMPLETE, (UINT64)0);
825824}
826825
827826/*
trunk/src/mess/drivers/studio2.c
r18113r18114
546546
547547/* Driver Initialization */
548548
549static TIMER_CALLBACK( setup_beep )
549TIMER_CALLBACK_MEMBER(studio2_state::setup_beep)
550550{
551   device_t *speaker = machine.device(BEEPER_TAG);
551   device_t *speaker = machine().device(BEEPER_TAG);
552552   beep_set_state(speaker, 0);
553553   beep_set_frequency(speaker, 300);
554554}
555555
556556DRIVER_INIT_MEMBER(studio2_state,studio2)
557557{
558   machine().scheduler().timer_set(attotime::zero, FUNC(setup_beep));
558   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(studio2_state::setup_beep),this));
559559}
560560
561561/* Game Drivers */
trunk/src/mess/drivers/pcw.c
r18113r18114
162162   machine.device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
163163}
164164
165static TIMER_CALLBACK(pcw_timer_pulse)
165TIMER_CALLBACK_MEMBER(pcw_state::pcw_timer_pulse)
166166{
167   pcw_state *state = machine.driver_data<pcw_state>();
168   state->m_timer_irq_flag = 0;
169   pcw_update_irqs(machine);
167   m_timer_irq_flag = 0;
168   pcw_update_irqs(machine());
170169}
171170
172171/* callback for 1/300ths of a second interrupt */
r18113r18114
177176
178177   state->m_timer_irq_flag = 1;
179178   pcw_update_irqs(timer.machine());
180   timer.machine().scheduler().timer_set(attotime::from_usec(100), FUNC(pcw_timer_pulse));
179   timer.machine().scheduler().timer_set(attotime::from_usec(100), timer_expired_delegate(FUNC(pcw_state::pcw_timer_pulse),state));
181180}
182181
183182/* fdc interrupt callback. set/clear fdc int */
r18113r18114
731730 * T0: Paper sensor (?)
732731 * T1: Print head location (1 if not at left margin)
733732 */
734static TIMER_CALLBACK(pcw_stepper_callback)
733TIMER_CALLBACK_MEMBER(pcw_state::pcw_stepper_callback)
735734{
736   pcw_state *state = machine.driver_data<pcw_state>();
737735
738   //popmessage("PRN: P2 bits %s %s %s\nSerial: %02x\nHeadpos: %i",state->m_printer_p2 & 0x40 ? " " : "6",state->m_printer_p2 & 0x20 ? " " : "5",state->m_printer_p2 & 0x10 ? " " : "4",state->m_printer_shift_output,state->m_printer_headpos);
739   if((state->m_printer_p2 & 0x10) == 0)  // print head motor active
736   //popmessage("PRN: P2 bits %s %s %s\nSerial: %02x\nHeadpos: %i",m_printer_p2 & 0x40 ? " " : "6",m_printer_p2 & 0x20 ? " " : "5",m_printer_p2 & 0x10 ? " " : "4",m_printer_shift_output,m_printer_headpos);
737   if((m_printer_p2 & 0x10) == 0)  // print head motor active
740738   {
741      UINT8 stepper_state = (state->m_printer_shift_output >> 4) & 0x0f;
742      if(stepper_state == full_step_table[(state->m_head_motor_state + 1) & 0x03])
739      UINT8 stepper_state = (m_printer_shift_output >> 4) & 0x0f;
740      if(stepper_state == full_step_table[(m_head_motor_state + 1) & 0x03])
743741      {
744         state->m_printer_headpos += 2;
745         state->m_head_motor_state++;
746         logerror("Printer head moved forward by 2 to %i\n",state->m_printer_headpos);
742         m_printer_headpos += 2;
743         m_head_motor_state++;
744         logerror("Printer head moved forward by 2 to %i\n",m_printer_headpos);
747745      }
748      if(stepper_state == half_step_table[(state->m_head_motor_state + 1) & 0x03])
746      if(stepper_state == half_step_table[(m_head_motor_state + 1) & 0x03])
749747      {
750         state->m_printer_headpos += 1;
751         state->m_head_motor_state++;
752         logerror("Printer head moved forward by 1 to %i\n",state->m_printer_headpos);
748         m_printer_headpos += 1;
749         m_head_motor_state++;
750         logerror("Printer head moved forward by 1 to %i\n",m_printer_headpos);
753751      }
754      if(stepper_state == full_step_table[(state->m_head_motor_state - 1) & 0x03])
752      if(stepper_state == full_step_table[(m_head_motor_state - 1) & 0x03])
755753      {
756         state->m_printer_headpos -= 2;
757         state->m_head_motor_state--;
758         logerror("Printer head moved back by 2 to %i\n",state->m_printer_headpos);
754         m_printer_headpos -= 2;
755         m_head_motor_state--;
756         logerror("Printer head moved back by 2 to %i\n",m_printer_headpos);
759757      }
760      if(stepper_state == half_step_table[(state->m_head_motor_state - 1) & 0x03])
758      if(stepper_state == half_step_table[(m_head_motor_state - 1) & 0x03])
761759      {
762         state->m_printer_headpos -= 1;
763         state->m_head_motor_state--;
764         logerror("Printer head moved back by 1 to %i\n",state->m_printer_headpos);
760         m_printer_headpos -= 1;
761         m_head_motor_state--;
762         logerror("Printer head moved back by 1 to %i\n",m_printer_headpos);
765763      }
766      if(state->m_printer_headpos < 0)
767         state->m_printer_headpos = 0;
768      if(state->m_printer_headpos > PCW_PRINTER_WIDTH)
769         state->m_printer_headpos = PCW_PRINTER_WIDTH;
770      state->m_head_motor_state &= 0x03;
771      state->m_printer_p2 |= 0x10;
764      if(m_printer_headpos < 0)
765         m_printer_headpos = 0;
766      if(m_printer_headpos > PCW_PRINTER_WIDTH)
767         m_printer_headpos = PCW_PRINTER_WIDTH;
768      m_head_motor_state &= 0x03;
769      m_printer_p2 |= 0x10;
772770   }
773   if((state->m_printer_p2 & 0x20) == 0)  // line feed motor active
771   if((m_printer_p2 & 0x20) == 0)  // line feed motor active
774772   {
775      UINT8 stepper_state = state->m_printer_shift_output & 0x0f;
776      if(stepper_state == full_step_table[(state->m_linefeed_motor_state + 1) & 0x03])
773      UINT8 stepper_state = m_printer_shift_output & 0x0f;
774      if(stepper_state == full_step_table[(m_linefeed_motor_state + 1) & 0x03])
777775      {
778         state->m_paper_feed++;
779         if(state->m_paper_feed > PCW_PRINTER_HEIGHT*2)
780            state->m_paper_feed = 0;
781         state->m_linefeed_motor_state++;
776         m_paper_feed++;
777         if(m_paper_feed > PCW_PRINTER_HEIGHT*2)
778            m_paper_feed = 0;
779         m_linefeed_motor_state++;
782780      }
783      if(stepper_state == half_step_table[(state->m_linefeed_motor_state + 1) & 0x03])
781      if(stepper_state == half_step_table[(m_linefeed_motor_state + 1) & 0x03])
784782      {
785         state->m_paper_feed++;
786         if(state->m_paper_feed > PCW_PRINTER_HEIGHT*2)
787            state->m_paper_feed = 0;
788         state->m_linefeed_motor_state++;
783         m_paper_feed++;
784         if(m_paper_feed > PCW_PRINTER_HEIGHT*2)
785            m_paper_feed = 0;
786         m_linefeed_motor_state++;
789787      }
790      state->m_linefeed_motor_state &= 0x03;
791      state->m_printer_p2 |= 0x20;
788      m_linefeed_motor_state &= 0x03;
789      m_printer_p2 |= 0x20;
792790   }
793791}
794792
795static TIMER_CALLBACK(pcw_pins_callback)
793TIMER_CALLBACK_MEMBER(pcw_state::pcw_pins_callback)
796794{
797   pcw_state *state = machine.driver_data<pcw_state>();
798795
799   pcw_printer_fire_pins(machine,state->m_printer_pins);
800   state->m_printer_p2 |= 0x40;
796   pcw_printer_fire_pins(machine(),m_printer_pins);
797   m_printer_p2 |= 0x40;
801798}
802799
803800READ8_MEMBER(pcw_state::mcu_printer_p1_r)
r18113r18114
10341031ADDRESS_MAP_END
10351032
10361033
1037static TIMER_CALLBACK(setup_beep)
1034TIMER_CALLBACK_MEMBER(pcw_state::setup_beep)
10381035{
1039   device_t *speaker = machine.device(BEEPER_TAG);
1036   device_t *speaker = machine().device(BEEPER_TAG);
10401037   beep_set_state(speaker, 0);
10411038   beep_set_frequency(speaker, 3750);
10421039}
r18113r18114
10961093   m_roller_ram_offset = 0;
10971094
10981095   /* timer interrupt */
1099   machine().scheduler().timer_set(attotime::zero, FUNC(setup_beep));
1096   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(pcw_state::setup_beep),this));
11001097
1101   m_prn_stepper = machine().scheduler().timer_alloc(FUNC(pcw_stepper_callback));
1102   m_prn_pins = machine().scheduler().timer_alloc(FUNC(pcw_pins_callback));
1098   m_prn_stepper = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pcw_state::pcw_stepper_callback),this));
1099   m_prn_pins = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pcw_state::pcw_pins_callback),this));
11031100}
11041101
11051102
trunk/src/mess/drivers/osi.c
r18113r18114
903903
904904/* Driver Initialization */
905905
906static TIMER_CALLBACK( setup_beep )
906TIMER_CALLBACK_MEMBER(sb2m600_state::setup_beep)
907907{
908   device_t *speaker = machine.device(BEEPER_TAG);
908   device_t *speaker = machine().device(BEEPER_TAG);
909909   beep_set_state(speaker, 0);
910910   beep_set_frequency(speaker, 300);
911911}
912912
913913DRIVER_INIT_MEMBER(c1p_state,c1p)
914914{
915   machine().scheduler().timer_set(attotime::zero, FUNC(setup_beep));
915   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(sb2m600_state::setup_beep),this));
916916}
917917
918918
trunk/src/mess/drivers/tmc1800.c
r18113r18114
900900
901901/* Driver Initialization */
902902
903static TIMER_CALLBACK(setup_beep)
903TIMER_CALLBACK_MEMBER(tmc1800_state::setup_beep)
904904{
905   device_t *speaker = machine.device(BEEPER_TAG);
905   device_t *speaker = machine().device(BEEPER_TAG);
906906   beep_set_state(speaker, 0);
907907   beep_set_frequency( speaker, 0 );
908908}
909909
910910DRIVER_INIT_MEMBER(tmc1800_state,tmc1800)
911911{
912   machine().scheduler().timer_set(attotime::zero, FUNC(setup_beep));
912   machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(tmc1800_state::setup_beep),this));
913913}
914914
915915/* System Drivers */
trunk/src/mess/drivers/fmtowns.c
r18113r18114
13051305   }
13061306}
13071307
1308static TIMER_CALLBACK( towns_cd_status_ready )
1308TIMER_CALLBACK_MEMBER(towns_state::towns_cd_status_ready)
13091309{
1310   towns_state* state = machine.driver_data<towns_state>();
1311   state->m_towns_cd.status |= 0x02;  // status read request
1312   state->m_towns_cd.status |= 0x01;  // ready
1313   state->m_towns_cd.cmd_status_ptr = 0;
1314   towns_cdrom_set_irq((running_machine&)machine,TOWNS_CD_IRQ_MPU,1);
1310   m_towns_cd.status |= 0x02;  // status read request
1311   m_towns_cd.status |= 0x01;  // ready
1312   m_towns_cd.cmd_status_ptr = 0;
1313   towns_cdrom_set_irq((running_machine&)machine(),TOWNS_CD_IRQ_MPU,1);
13151314}
13161315
13171316static void towns_cd_set_status(running_machine &machine, UINT8 st0, UINT8 st1, UINT8 st2, UINT8 st3)
r18113r18114
13221321   state->m_towns_cd.cmd_status[2] = st2;
13231322   state->m_towns_cd.cmd_status[3] = st3;
13241323   // wait a bit
1325   machine.scheduler().timer_set(attotime::from_msec(1), FUNC(towns_cd_status_ready), 0, &machine);
1324   machine.scheduler().timer_set(attotime::from_msec(1), timer_expired_delegate(FUNC(towns_state::towns_cd_status_ready),state), 0, &machine);
13261325}
13271326
13281327static UINT8 towns_cd_get_track(running_machine &machine)
r18113r18114
13411340   return track;
13421341}
13431342
1344static TIMER_CALLBACK( towns_cdrom_read_byte )
1343TIMER_CALLBACK_MEMBER(towns_state::towns_cdrom_read_byte)
13451344{
13461345   device_t* device = (device_t* )ptr;
1347   towns_state* state = machine.driver_data<towns_state>();
13481346   int masked;
13491347   // TODO: support software transfers, for now DMA is assumed.
13501348
1351   if(state->m_towns_cd.buffer_ptr < 0) // transfer has ended
1349   if(m_towns_cd.buffer_ptr < 0) // transfer has ended
13521350      return;
13531351
13541352   masked = upd71071_dmarq(device,param,3);  // CD-ROM controller uses DMA1 channel 3
1355//  logerror("DMARQ: param=%i ret=%i bufferptr=%i\n",param,masked,state->m_towns_cd.buffer_ptr);
1353//  logerror("DMARQ: param=%i ret=%i bufferptr=%i\n",param,masked,m_towns_cd.buffer_ptr);
13561354   if(param != 0)
13571355   {
1358      state->m_towns_cd.read_timer->adjust(attotime::from_hz(300000));
1356      m_towns_cd.read_timer->adjust(attotime::from_hz(300000));
13591357   }
13601358   else
13611359   {
13621360      if(masked != 0)  // check if the DMA channel is masked
13631361      {
1364         state->m_towns_cd.read_timer->adjust(attotime::from_hz(300000),1);
1362         m_towns_cd.read_timer->adjust(attotime::from_hz(300000),1);
13651363         return;
13661364      }
1367      if(state->m_towns_cd.buffer_ptr < 2048)
1368         state->m_towns_cd.read_timer->adjust(attotime::from_hz(300000),1);
1365      if(m_towns_cd.buffer_ptr < 2048)
1366         m_towns_cd.read_timer->adjust(attotime::from_hz(300000),1);
13691367      else
13701368      {  // end of transfer
1371         state->m_towns_cd.status &= ~0x10;  // no longer transferring by DMA
1372         state->m_towns_cd.status &= ~0x20;  // no longer transferring by software
1373         logerror("DMA1: end of transfer (LBA=%08x)\n",state->m_towns_cd.lba_current);
1374         if(state->m_towns_cd.lba_current >= state->m_towns_cd.lba_last)
1369         m_towns_cd.status &= ~0x10;  // no longer transferring by DMA
1370         m_towns_cd.status &= ~0x20;  // no longer transferring by software
1371         logerror("DMA1: end of transfer (LBA=%08x)\n",m_towns_cd.lba_current);
1372         if(m_towns_cd.lba_current >= m_towns_cd.lba_last)
13751373         {
1376            state->m_towns_cd.extra_status = 0;
1374            m_towns_cd.extra_status = 0;
13771375            towns_cd_set_status(device->machine(),0x06,0x00,0x00,0x00);
13781376            towns_cdrom_set_irq(device->machine(),TOWNS_CD_IRQ_DMA,1);
1379            state->m_towns_cd.buffer_ptr = -1;
1380            state->m_towns_cd.status |= 0x01;  // ready
1377            m_towns_cd.buffer_ptr = -1;
1378            m_towns_cd.status |= 0x01;  // ready
13811379         }
13821380         else
13831381         {
1384            state->m_towns_cd.extra_status = 0;
1382            m_towns_cd.extra_status = 0;
13851383            towns_cd_set_status(device->machine(),0x22,0x00,0x00,0x00);
13861384            towns_cdrom_set_irq(device->machine(),TOWNS_CD_IRQ_DMA,1);
1387            cdrom_read_data(state->m_cdrom->get_cdrom_file(),++state->m_towns_cd.lba_current,state->m_towns_cd.buffer,CD_TRACK_MODE1);
1388            state->m_towns_cd.read_timer->adjust(attotime::from_hz(300000),1);
1389            state->m_towns_cd.buffer_ptr = -1;
1385            cdrom_read_data(m_cdrom->get_cdrom_file(),++m_towns_cd.lba_current,m_towns_cd.buffer,CD_TRACK_MODE1);
1386            m_towns_cd.read_timer->adjust(attotime::from_hz(300000),1);
1387            m_towns_cd.buffer_ptr = -1;
13901388         }
13911389      }
13921390   }
r18113r18114
14821480   }
14831481}
14841482
1485static TIMER_CALLBACK(towns_delay_cdda)
1483TIMER_CALLBACK_MEMBER(towns_state::towns_delay_cdda)
14861484{
14871485   towns_cdrom_play_cdda((cdrom_image_device*)ptr);
14881486}
r18113r18114
15261524            break;
15271525         case 0x04:  // Play Audio Track
15281526            logerror("CD: Command 0x04: PLAY CD-DA\n");
1529            device->machine().scheduler().timer_set(attotime::from_msec(1), FUNC(towns_delay_cdda), 0, device);
1527            device->machine().scheduler().timer_set(attotime::from_msec(1), timer_expired_delegate(FUNC(towns_state::towns_delay_cdda),state), 0, device);
15301528            break;
15311529         case 0x05:  // Read TOC
15321530            logerror("CD: Command 0x05: READ TOC\n");
r18113r18114
24562454   m_towns_intervaltimer2 = timer_alloc(TIMER_INTERVAL2);
24572455
24582456   // CD-ROM init
2459   m_towns_cd.read_timer = machine().scheduler().timer_alloc(FUNC(towns_cdrom_read_byte), (void*)machine().device("dma_1"));
2457   m_towns_cd.read_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(towns_state::towns_cdrom_read_byte),this), (void*)machine().device("dma_1"));
24602458
24612459   machine().device("maincpu")->execute().set_irq_acknowledge_callback(towns_irq_callback);
24622460   machine().device("maincpu")->memory().space(AS_PROGRAM).install_ram(0x100000,machine().device<ram_device>(RAM_TAG)->size()-1,0xffffffff,0,NULL);
trunk/src/mess/drivers/x1.c
r18113r18114
24322432   }
24332433}
24342434
2435TIMER_CALLBACK(x1_rtc_increment)
2435TIMER_CALLBACK_MEMBER(x1_state::x1_rtc_increment)
24362436{
2437   x1_state *state = machine.driver_data<x1_state>();
24382437   static const UINT8 dpm[12] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 };
24392438
2440   state->m_rtc.sec++;
2439   m_rtc.sec++;
24412440
2442   if((state->m_rtc.sec & 0x0f) >= 0x0a)            { state->m_rtc.sec+=0x10; state->m_rtc.sec&=0xf0; }
2443   if((state->m_rtc.sec & 0xf0) >= 0x60)            { state->m_rtc.min++; state->m_rtc.sec = 0; }
2444   if((state->m_rtc.min & 0x0f) >= 0x0a)            { state->m_rtc.min+=0x10; state->m_rtc.min&=0xf0; }
2445   if((state->m_rtc.min & 0xf0) >= 0x60)            { state->m_rtc.hour++; state->m_rtc.min = 0; }
2446   if((state->m_rtc.hour & 0x0f) >= 0x0a)            { state->m_rtc.hour+=0x10; state->m_rtc.hour&=0xf0; }
2447   if((state->m_rtc.hour & 0xff) >= 0x24)            { state->m_rtc.day++; state->m_rtc.wday++; state->m_rtc.hour = 0; }
2448   if((state->m_rtc.wday & 0x0f) >= 0x07)            { state->m_rtc.wday = 0; }
2449   if((state->m_rtc.day & 0x0f) >= 0x0a)            { state->m_rtc.day+=0x10; state->m_rtc.day&=0xf0; }
2441   if((m_rtc.sec & 0x0f) >= 0x0a)            { m_rtc.sec+=0x10; m_rtc.sec&=0xf0; }
2442   if((m_rtc.sec & 0xf0) >= 0x60)            { m_rtc.min++; m_rtc.sec = 0; }
2443   if((m_rtc.min & 0x0f) >= 0x0a)            { m_rtc.min+=0x10; m_rtc.min&=0xf0; }
2444   if((m_rtc.min & 0xf0) >= 0x60)            { m_rtc.hour++; m_rtc.min = 0; }
2445   if((m_rtc.hour & 0x0f) >= 0x0a)            { m_rtc.hour+=0x10; m_rtc.hour&=0xf0; }
2446   if((m_rtc.hour & 0xff) >= 0x24)            { m_rtc.day++; m_rtc.wday++; m_rtc.hour = 0; }
2447   if((m_rtc.wday & 0x0f) >= 0x07)            { m_rtc.wday = 0; }
2448   if((m_rtc.day & 0x0f) >= 0x0a)            { m_rtc.day+=0x10; m_rtc.day&=0xf0; }
24502449   /* FIXME: very crude leap year support (i.e. it treats the RTC to be with a 2000-2099 timeline), dunno how the real x1 supports this,
24512450       maybe it just have a 1980-1999 timeline since year 0x00 shows as a XX on display */
2452   if(((state->m_rtc.year % 4) == 0) && state->m_rtc.month == 2)
2451   if(((m_rtc.year % 4) == 0) && m_rtc.month == 2)
24532452   {
2454      if((state->m_rtc.day & 0xff) >= dpm[state->m_rtc.month-1]+1+1)
2455         { state->m_rtc.month++; state->m_rtc.day = 0x01; }
2453      if((m_rtc.day & 0xff) >= dpm[m_rtc.month-1]+1+1)
2454         { m_rtc.month++; m_rtc.day = 0x01; }
24562455   }
2457   else if((state->m_rtc.day & 0xff) >= dpm[state->m_rtc.month-1]+1){ state->m_rtc.month++; state->m_rtc.day = 0x01; }
2458   if(state->m_rtc.month > 12)                     { state->m_rtc.year++;  state->m_rtc.month = 0x01; }
2459   if((state->m_rtc.year & 0x0f) >= 0x0a)            { state->m_rtc.year+=0x10; state->m_rtc.year&=0xf0; }
2460   if((state->m_rtc.year & 0xf0) >= 0xa0)            { state->m_rtc.year = 0; } //roll over
2456   else if((m_rtc.day & 0xff) >= dpm[m_rtc.month-1]+1){ m_rtc.month++; m_rtc.day = 0x01; }
2457   if(m_rtc.month > 12)                     { m_rtc.year++;  m_rtc.month = 0x01; }
2458   if((m_rtc.year & 0x0f) >= 0x0a)            { m_rtc.year+=0x10; m_rtc.year&=0xf0; }
2459   if((m_rtc.year & 0xf0) >= 0xa0)            { m_rtc.year = 0; } //roll over
24612460}
24622461
24632462MACHINE_RESET_MEMBER(x1_state,x1)
r18113r18114
25302529      m_rtc.min = ((systime.local_time.minute / 10)<<4) | ((systime.local_time.minute % 10) & 0xf);
25312530      m_rtc.sec = ((systime.local_time.second / 10)<<4) | ((systime.local_time.second % 10) & 0xf);
25322531
2533      m_rtc_timer = machine().scheduler().timer_alloc(FUNC(x1_rtc_increment));
2532      m_rtc_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(x1_state::x1_rtc_increment),this));
25342533   }
25352534}
25362535
trunk/src/mess/drivers/x68k.c
r18113r18114
177177   state->m_mfp.current_irq = -1;  // No current interrupt
178178
179179#if 0
180    mfp_timer[0] = machine.scheduler().timer_alloc(FUNC(mfp_timer_a_callback));
181    mfp_timer[1] = machine.scheduler().timer_alloc(FUNC(mfp_timer_b_callback));
182    mfp_timer[2] = machine.scheduler().timer_alloc(FUNC(mfp_timer_c_callback));
183    mfp_timer[3] = machine.scheduler().timer_alloc(FUNC(mfp_timer_d_callback));
184    mfp_irq = machine.scheduler().timer_alloc(FUNC(mfp_update_irq));
180    mfp_timer[0] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(x68k_state::mfp_timer_a_callback),this));
181    mfp_timer[1] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(x68k_state::mfp_timer_b_callback),this));
182    mfp_timer[2] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(x68k_state::mfp_timer_c_callback),this));
183    mfp_timer[3] = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(x68k_state::mfp_timer_d_callback),this));
184    mfp_irq = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(x68k_state::mfp_update_irq),this));
185185    mfp_irq->adjust(attotime::zero, 0, attotime::from_usec(32));
186186#endif
187187}
188188
189189#ifdef UNUSED_FUNCTION
190TIMER_CALLBACK(mfp_update_irq)
190TIMER_CALLBACK_MEMBER(x68k_state::mfp_update_irq)
191191{
192   x68k_state *state = machine.driver_data<x68k_state>();
193192    int x;
194193
195    if((state->m_ioc.irqstatus & 0xc0) != 0)
194    if((m_ioc.irqstatus & 0xc0) != 0)
196195        return;
197196
198197    // check for pending IRQs, in priority order
199    if(state->m_mfp.ipra != 0)
198    if(m_mfp.ipra != 0)
200199    {
201200        for(x=7;x>=0;x--)
202201        {
203            if((state->m_mfp.ipra & (1 << x)) && (state->m_mfp.imra & (1 << x)))
202            if((m_mfp.ipra & (1 << x)) && (m_mfp.imra & (1 << x)))
204203            {
205                state->m_current_irq_line = state->m_mfp.irqline;
206                state->m_mfp.current_irq = x + 8;
204                m_current_irq_line = m_mfp.irqline;
205                m_mfp.current_irq = x + 8;
207206                // assert IRQ line
208//              if(state->m_mfp.iera & (1 << x))
207//              if(m_mfp.iera & (1 << x))
209208                {
210                    state->m_current_vector[6] = (state->m_mfp.vr & 0xf0) | (x+8);
211                    machine.device("maincpu")->execute().set_input_line_and_vector(state->m_mfp.irqline,ASSERT_LINE,(state->m_mfp.vr & 0xf0) | (x + 8));
212//                  logerror("MFP: Sent IRQ vector 0x%02x (IRQ line %i)\n",(state->m_mfp.vr & 0xf0) | (x+8),state->m_mfp.irqline);
209                    m_current_vector[6] = (m_mfp.vr & 0xf0) | (x+8);
210                    machine().device("maincpu")->execute().set_input_line_and_vector(m_mfp.irqline,ASSERT_LINE,(m_mfp.vr & 0xf0) | (x + 8));
211//                  logerror("MFP: Sent IRQ vector 0x%02x (IRQ line %i)\n",(m_mfp.vr & 0xf0) | (x+8),m_mfp.irqline);
213212                    return;  // one at a time only
214213                }
215214            }
216215        }
217216    }
218    if(state->m_mfp.iprb != 0)
217    if(m_mfp.iprb != 0)
219218    {
220219        for(x=7;x>=0;x--)
221220        {
222            if((state->m_mfp.iprb & (1 << x)) && (state->m_mfp.imrb & (1 << x)))
221            if((m_mfp.iprb & (1 << x)) && (m_mfp.imrb & (1 << x)))
223222            {
224                state->m_current_irq_line = state->m_mfp.irqline;
225                state->m_mfp.current_irq = x;
223                m_current_irq_line = m_mfp.irqline;
224                m_mfp.current_irq = x;
226225                // assert IRQ line
227//              if(state->m_mfp.ierb & (1 << x))
226//              if(m_mfp.ierb & (1 << x))
228227                {
229                    state->m_current_vector[6] = (state->m_mfp.vr & 0xf0) | x;
230                    machine.device("maincpu")->execute().set_input_line_and_vector(state->m_mfp.irqline,ASSERT_LINE,(state->m_mfp.vr & 0xf0) | x);
231//                  logerror("MFP: Sent IRQ vector 0x%02x (IRQ line %i)\n",(state->m_mfp.vr & 0xf0) | x,state->m_mfp.irqline);
228                    m_current_vector[6] = (m_mfp.vr & 0xf0) | x;
229                    machine().device("maincpu")->execute().set_input_line_and_vector(m_mfp.irqline,ASSERT_LINE,(m_mfp.vr & 0xf0) | x);
230//                  logerror("MFP: Sent IRQ vector 0x%02x (IRQ line %i)\n",(m_mfp.vr & 0xf0) | x,m_mfp.irqline);
232231                    return;  // one at a time only
233232                }
234233            }
r18113r18114
262261
263262}
264263
265TIMER_CALLBACK(mfp_timer_a_callback)
264TIMER_CALLBACK_MEMBER(x68k_state::mfp_timer_a_callback)
266265{
267   x68k_state *state = machine.driver_data<x68k_state>();
268    state->m_mfp.timer[0].counter--;
269    if(state->m_mfp.timer[0].counter == 0)
266    m_mfp.timer[0].counter--;
267    if(m_mfp.timer[0].counter == 0)
270268    {
271        state->m_mfp.timer[0].counter = state->m_mfp.tadr;
269        m_mfp.timer[0].counter = m_mfp.tadr;
272270        mfp_trigger_irq(MFP_IRQ_TIMERA);
273271    }
274272}
275273
276TIMER_CALLBACK(mfp_timer_b_callback)
274TIMER_CALLBACK_MEMBER(x68k_state::mfp_timer_b_callback)
277275{
278   x68k_state *state = machine.driver_data<x68k_state>();
279    state->m_mfp.timer[1].counter--;
280    if(state->m_mfp.timer[1].counter == 0)
276    m_mfp.timer[1].counter--;
277    if(m_mfp.timer[1].counter == 0)
281278    {
282        state->m_mfp.timer[1].counter = state->m_mfp.tbdr;
279        m_mfp.timer[1].counter = m_mfp.tbdr;
283280            mfp_trigger_irq(MFP_IRQ_TIMERB);
284281    }
285282}
286283
287TIMER_CALLBACK(mfp_timer_c_callback)
284TIMER_CALLBACK_MEMBER(x68k_state::mfp_timer_c_callback)
288285{
289   x68k_state *state = machine.driver_data<x68k_state>();
290    state->m_mfp.timer[2].counter--;
291    if(state->m_mfp.timer[2].counter == 0)
286    m_mfp.timer[2].counter--;
287    if(m_mfp.timer[2].counter == 0)
292288    {
293        state->m_mfp.timer[2].counter = state->m_mfp.tcdr;
289        m_mfp.timer[2].counter = m_mfp.tcdr;
294290            mfp_trigger_irq(MFP_IRQ_TIMERC);
295291    }
296292}
297293
298TIMER_CALLBACK(mfp_timer_d_callback)
294TIMER_CALLBACK_MEMBER(x68k_state::mfp_timer_d_callback)
299295{
300   x68k_state *state = machine.driver_data<x68k_state>();
301    state->m_mfp.timer[3].counter--;
302    if(state->m_mfp.timer[3].counter == 0)
296    m_mfp.timer[3].counter--;
297    if(m_mfp.timer[3].counter == 0)
303298    {
304        state->m_mfp.timer[3].counter = state->m_mfp.tddr;
299        m_mfp.timer[3].counter = m_mfp.tddr;
305300            mfp_trigger_irq(MFP_IRQ_TIMERD);
306301    }
307302}
r18113r18114
322317#endif
323318
324319// LED timer callback
325static TIMER_CALLBACK( x68k_led_callback )
320TIMER_CALLBACK_MEMBER(x68k_state::x68k_led_callback)
326321{
327   x68k_state *state = machine.driver_data<x68k_state>();
328322   int drive;
329   if(state->m_led_state == 0)
330      state->m_led_state = 1;
323   if(m_led_state == 0)
324      m_led_state = 1;
331325   else
332      state->m_led_state = 0;
333   if(state->m_led_state == 1)
326      m_led_state = 0;
327   if(m_led_state == 1)
334328   {
335329      for(drive=0;drive<4;drive++)
336         output_set_indexed_value("ctrl_drv",drive,state->m_fdc.led_ctrl[drive] ? 0 : 1);
330         output_set_indexed_value("ctrl_drv",drive,m_fdc.led_ctrl[drive] ? 0 : 1);
337331   }
338332   else
339333   {
r18113r18114
470464   }
471465}
472466
473static TIMER_CALLBACK(x68k_keyboard_poll)
467TIMER_CALLBACK_MEMBER(x68k_state::x68k_keyboard_poll)
474468{
475   x68k_state *state = machine.driver_data<x68k_state>();
476469   int x;
477470   static const char *const keynames[] = { "key1", "key2", "key3", "key4" };
478471
479472   for(x=0;x<0x80;x++)
480473   {
481474      // adjust delay/repeat timers
482      if(state->m_keyboard.keytime[x] > 0)
475      if(m_keyboard.keytime[x] > 0)
483476      {
484         state->m_keyboard.keytime[x] -= 5;
477         m_keyboard.keytime[x] -= 5;
485478      }
486      if(!(machine.root_device().ioport(keynames[x / 32])->read() & (1 << (x % 32))))
479      if(!(machine().root_device().ioport(keynames[x / 32])->read() & (1 << (x % 32))))
487480      {
488         if(state->m_keyboard.keyon[x] != 0)
481         if(m_keyboard.keyon[x] != 0)
489482         {
490            x68k_keyboard_push_scancode(machine,0x80 + x);
491            state->m_keyboard.keytime[x] = 0;
492            state->m_keyboard.keyon[x] = 0;
493            state->m_keyboard.last_pressed = 0;
483            x68k_keyboard_push_scancode(machine(),0x80 + x);
484            m_keyboard.keytime[x] = 0;
485            m_keyboard.keyon[x] = 0;
486            m_keyboard.last_pressed = 0;
494487            logerror("KB: Released key 0x%02x\n",x);
495488         }
496489      }
497490      // check to see if a key is being held
498      if(state->m_keyboard.keyon[x] != 0 && state->m_keyboard.keytime[x] == 0 && state->m_keyboard.last_pressed == x)
491      if(m_keyboard.keyon[x] != 0 && m_keyboard.keytime[x] == 0 && m_keyboard.last_pressed == x)
499492      {
500         if(machine.root_device().ioport(keynames[state->m_keyboard.last_pressed / 32])->read() & (1 << (state->m_keyboard.last_pressed % 32)))
493         if(machine().root_device().ioport(keynames[m_keyboard.last_pressed / 32])->read() & (1 << (m_keyboard.last_pressed % 32)))
501494         {
502            x68k_keyboard_push_scancode(machine,state->m_keyboard.last_pressed);
503            state->m_keyboard.keytime[state->m_keyboard.last_pressed] = (state->m_keyboard.repeat^2)*5+30;
504            logerror("KB: Holding key 0x%02x\n",state->m_keyboard.last_pressed);
495            x68k_keyboard_push_scancode(machine(),m_keyboard.last_pressed);
496            m_keyboard.keytime[m_keyboard.last_pressed] = (m_keyboard.repeat^2)*5+30;
497            logerror("KB: Holding key 0x%02x\n",m_keyboard.last_pressed);
505498         }
506499      }
507      if((machine.root_device().ioport(keynames[x / 32])->read() & (1 << (x % 32))))
500      if((machine().root_device().ioport(keynames[x / 32])->read() & (1 << (x % 32))))
508501      {
509         if(state->m_keyboard.keyon[x] == 0)
502         if(m_keyboard.keyon[x] == 0)
510503         {
511            x68k_keyboard_push_scancode(machine,x);
512            state->m_keyboard.keytime[x] = state->m_keyboard.delay * 100 + 200;
513            state->m_keyboard.keyon[x] = 1;
514            state->m_keyboard.last_pressed = x;
504            x68k_keyboard_push_scancode(machine(),x);
505            m_keyboard.keytime[x] = m_keyboard.delay * 100 + 200;
506            m_keyboard.keyon[x] = 1;
507            m_keyboard.last_pressed = x;
515508            logerror("KB: Pushed key 0x%02x\n",x);
516509         }
517510      }
r18113r18114
634627   state->m_scc_prev = scc->get_reg_b(5) & 0x02;
635628}
636629
637static TIMER_CALLBACK(x68k_scc_ack)
630TIMER_CALLBACK_MEMBER(x68k_state::x68k_scc_ack)
638631{
639   x68k_state *state = machine.driver_data<x68k_state>();
640   scc8530_t *scc = machine.device<scc8530_t>("scc");
641   if(state->m_mouse.bufferempty != 0)  // nothing to do if the mouse data buffer is empty
632   scc8530_t *scc = machine().device<scc8530_t>("scc");
633   if(m_mouse.bufferempty != 0)  // nothing to do if the mouse data buffer is empty
642634      return;
643635
644//  if((state->m_ioc.irqstatus & 0xc0) != 0)
636//  if((m_ioc.irqstatus & 0xc0) != 0)
645637//      return;
646638
647639   // hard-code the IRQ vector for now, until the SCC code is more complete
r18113r18114
651643      {
652644         if(scc->get_reg_b(5) & 0x02)  // RTS signal
653645         {
654            state->m_mouse.irqactive = 1;
655            state->m_current_vector[5] = 0x54;
656            state->m_current_irq_line = 5;
657            machine.device("maincpu")->execute().set_input_line_and_vector(5,ASSERT_LINE,0x54);
646            m_mouse.irqactive = 1;
647            m_current_vector[5] = 0x54;
648            m_current_irq_line = 5;
649            machine().device("maincpu")->execute().set_input_line_and_vector(5,ASSERT_LINE,0x54);
658650         }
659651      }
660652   }
r18113r18114
725717}
726718
727719// Megadrive 6 button gamepad
728static TIMER_CALLBACK(md_6button_port1_timeout)
720TIMER_CALLBACK_MEMBER(x68k_state::md_6button_port1_timeout)
729721{
730   x68k_state *state = machine.driver_data<x68k_state>();
731   state->m_mdctrl.seq1 = 0;
722   m_mdctrl.seq1 = 0;
732723}
733724
734static TIMER_CALLBACK(md_6button_port2_timeout)
725TIMER_CALLBACK_MEMBER(x68k_state::md_6button_port2_timeout)
735726{
736   x68k_state *state = machine.driver_data<x68k_state>();
737   state->m_mdctrl.seq2 = 0;
727   m_mdctrl.seq2 = 0;
738728}
739729
740730static void md_6button_init(running_machine &machine)
741731{
742732   x68k_state *state = machine.driver_data<x68k_state>();
743   state->m_mdctrl.io_timeout1 = machine.scheduler().timer_alloc(FUNC(md_6button_port1_timeout));
744   state->m_mdctrl.io_timeout2 = machine.scheduler().timer_alloc(FUNC(md_6button_port2_timeout));
733   state->m_mdctrl.io_timeout1 = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(x68k_state::md_6button_port1_timeout),state));
734   state->m_mdctrl.io_timeout2 = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(x68k_state::md_6button_port2_timeout),state));
745735}
746736
747737static UINT8 md_6button_r(device_t* device, int port)
r18113r18114
16891679   logerror("SYS: Enhanced Supervisor area set (from %iMB): 0x%02x\n",(offset + 1) * 2,data & 0xff);
16901680}
16911681
1692static TIMER_CALLBACK(x68k_bus_error)
1682TIMER_CALLBACK_MEMBER(x68k_state::x68k_bus_error)
16931683{
16941684   int val = param;
16951685   int v;
1696   UINT8 *ram = machine.device<ram_device>(RAM_TAG)->pointer();
1686   UINT8 *ram = machine().device<ram_device>(RAM_TAG)->pointer();
16971687
1698   if(strcmp(machine.system().name,"x68030") == 0)
1688   if(strcmp(machine().system().name,"x68030") == 0)
16991689      v = 0x0b;
17001690   else
17011691      v = 0x09;
17021692   if(ram[v] != 0x02)  // normal vector for bus errors points to 02FF0540
17031693   {
1704      machine.device("maincpu")->execute().set_input_line(M68K_LINE_BUSERROR, ASSERT_LINE);
1705      machine.device("maincpu")->execute().set_input_line(M68K_LINE_BUSERROR, CLEAR_LINE);
1694      machine().device("maincpu")->execute().set_input_line(M68K_LINE_BUSERROR, ASSERT_LINE);
1695      machine().device("maincpu")->execute().set_input_line(M68K_LINE_BUSERROR, CLEAR_LINE);
17061696      popmessage("Bus error: Unused RAM access [%08x]", val);
17071697   }
17081698}
r18113r18114
17201710      offset *= 2;
17211711      if(ACCESSING_BITS_0_7)
17221712         offset++;
1723      space.machine().scheduler().timer_set(space.machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), FUNC(x68k_bus_error), 0xbffffc+offset);
1713      space.machine().scheduler().timer_set(space.machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), timer_expired_delegate(FUNC(x68k_state::x68k_bus_error),state), 0xbffffc+offset);
17241714   }
17251715   return 0xff;
17261716}
r18113r18114
17381728      offset *= 2;
17391729      if(ACCESSING_BITS_0_7)
17401730         offset++;
1741      space.machine().scheduler().timer_set(space.machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), FUNC(x68k_bus_error), 0xbffffc+offset);
1731      space.machine().scheduler().timer_set(space.machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), timer_expired_delegate(FUNC(x68k_state::x68k_bus_error),state), 0xbffffc+offset);
17421732   }
17431733}
17441734
r18113r18114
17551745      offset *= 2;
17561746      if(ACCESSING_BITS_0_7)
17571747         offset++;
1758      space.machine().scheduler().timer_set(space.machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), FUNC(x68k_bus_error), offset);
1748      space.machine().scheduler().timer_set(space.machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), timer_expired_delegate(FUNC(x68k_state::x68k_bus_error),state), offset);
17591749   }
17601750   return 0xff;
17611751}
r18113r18114
17731763      offset *= 2;
17741764      if(ACCESSING_BITS_0_7)
17751765         offset++;
1776      space.machine().scheduler().timer_set(space.machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), FUNC(x68k_bus_error), offset);
1766      space.machine().scheduler().timer_set(space.machine().device<cpu_device>("maincpu")->cycles_to_attotime(4), timer_expired_delegate(FUNC(x68k_state::x68k_bus_error),state), offset);
17771767   }
17781768}
17791769
r18113r18114
17881778      offset *= 2;
17891779      if(ACCESSING_BITS_0_7)
17901780         offset++;
1791      space.machine().scheduler().timer_set(space.machine().device<cpu_device>("maincpu")->cycles_to_attotime(16), FUNC(x68k_bus_error), 0xeafa00+offset);
1781      space.machine().scheduler().timer_set(space.machine().device<cpu_device>("maincpu")->cycles_to_attotime(16), timer_expired_delegate(FUNC(x68k_state::x68k_bus_error),state), 0xeafa00+offset);
17921782//      machine.device("maincpu")->execute().set_input_line_and_vector(2,ASSERT_LINE,state->m_current_vector[2]);
17931783   }
17941784   return 0xffff;
r18113r18114
18051795      offset *= 2;
18061796      if(ACCESSING_BITS_0_7)
18071797         offset++;
1808      space.machine().scheduler().timer_set(space.machine().device<cpu_device>("maincpu")->cycles_to_attotime(16), FUNC(x68k_bus_error), 0xeafa00+offset);
1798      space.machine().scheduler().timer_set(space.machine().device<cpu_device>("maincpu")->cycles_to_attotime(16), timer_expired_delegate(FUNC(x68k_state::x68k_bus_error),state), 0xeafa00+offset);
18091799//      machine.device("maincpu")->execute().set_input_line_and_vector(2,ASSERT_LINE,state->m_current_vector[2]);
18101800   }
18111801}
r18113r18114
24822472   state->m_fdc.disk_inserted[floppy_get_drive(&image.device())] = 0;
24832473}
24842474
2485static TIMER_CALLBACK( x68k_net_irq )
2475TIMER_CALLBACK_MEMBER(x68k_state::x68k_net_irq)
24862476{
2487   x68k_state *state = machine.driver_data<x68k_state>();
24882477
2489   state->m_current_vector[2] = 0xf9;
2490   state->m_current_irq_line = 2;
2491   machine.device("maincpu")->execute().set_input_line_and_vector(2,ASSERT_LINE,state->m_current_vector[2]);
2478   m_current_vector[2] = 0xf9;
2479   m_current_irq_line = 2;
2480   machine().device("maincpu")->execute().set_input_line_and_vector(2,ASSERT_LINE,m_current_vector[2]);
24922481}
24932482
24942483static void x68k_irq2_line(device_t* device,int state)
r18113r18114
27082697   // init keyboard
27092698   m_keyboard.delay = 500;  // 3*100+200
27102699   m_keyboard.repeat = 110;  // 4^2*5+30
2711   m_kb_timer = machine().scheduler().timer_alloc(FUNC(x68k_keyboard_poll));
2712   m_scanline_timer = machine().scheduler().timer_alloc(FUNC(x68k_hsync));
2713   m_raster_irq = machine().scheduler().timer_alloc(FUNC(x68k_crtc_raster_irq));
2714   m_vblank_irq = machine().scheduler().timer_alloc(FUNC(x68k_crtc_vblank_irq));
2715   m_mouse_timer = machine().scheduler().timer_alloc(FUNC(x68k_scc_ack));
2716   m_led_timer = machine().scheduler().timer_alloc(FUNC(x68k_led_callback));
2717   m_net_timer = machine().scheduler().timer_alloc(FUNC(x68k_net_irq));
2700   m_kb_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(x68k_state::x68k_keyboard_poll),this));
2701   m_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(x68k_state::x68k_hsync),this));
2702   m_raster_irq = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(x68k_state::x68k_crtc_raster_irq),this));
2703   m_vblank_irq = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(x68k_state::x68k_crtc_vblank_irq),this));
2704   m_mouse_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(x68k_state::x68k_scc_ack),this));
2705   m_led_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(x68k_state::x68k_led_callback),this));
2706   m_net_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(x68k_state::x68k_net_irq),this));
27182707
27192708   // Initialise timers for 6-button MD controllers
27202709   md_6button_init(machine());

Previous 199869 Revisions Next


© 1997-2024 The MAME Team