diff options
author | 2012-09-24 14:43:01 +0000 | |
---|---|---|
committer | 2012-09-24 14:43:01 +0000 | |
commit | 3679f744c291a75d83085fe049f91ddc94b1419a (patch) | |
tree | a6938e296a70ab61e00fbf787dbdc6ebc358c903 /src/mess/machine | |
parent | ef6f5d0a52b1cbbc1418a248da72122e6958a958 (diff) |
modernization or timer callbacks part 2 (no whatsnew)
Diffstat (limited to 'src/mess/machine')
59 files changed, 1129 insertions, 1229 deletions
diff --git a/src/mess/machine/aim65.c b/src/mess/machine/aim65.c index fa65a95df30..2c5f651d016 100644 --- a/src/mess/machine/aim65.c +++ b/src/mess/machine/aim65.c @@ -300,42 +300,41 @@ DRIVER_MEMBER(aim65_state, aim65_printer_on), // out CB2 */ -static TIMER_CALLBACK(aim65_printer_timer) +TIMER_CALLBACK_MEMBER(aim65_state::aim65_printer_timer) { - aim65_state *state = machine.driver_data<aim65_state>(); - via6522_device *via_0 = machine.device<via6522_device>("via6522_0"); + via6522_device *via_0 = machine().device<via6522_device>("via6522_0"); - via_0->write_cb1(state->m_printer_level); - via_0->write_cb1(!state->m_printer_level); - state->m_printer_level ^= 1; + via_0->write_cb1(m_printer_level); + via_0->write_cb1(!m_printer_level); + m_printer_level ^= 1; - if (state->m_printer_dir) + if (m_printer_dir) { - if (state->m_printer_x > 0) - state->m_printer_x--; + if (m_printer_x > 0) + m_printer_x--; else { - state->m_printer_dir = 0; - state->m_printer_x++; - state->m_printer_y++; + m_printer_dir = 0; + m_printer_x++; + m_printer_y++; } } else { - if (state->m_printer_x < 9) - state->m_printer_x++; + if (m_printer_x < 9) + m_printer_x++; else { - state->m_printer_dir = 1; - state->m_printer_x--; - state->m_printer_y++; + m_printer_dir = 1; + m_printer_x--; + m_printer_y++; } } - if (state->m_printer_y > 500) state->m_printer_y = 0; + if (m_printer_y > 500) m_printer_y = 0; - state->m_flag_a=0; - state->m_flag_b=0; + m_flag_a=0; + m_flag_b=0; } @@ -369,7 +368,7 @@ WRITE8_MEMBER( aim65_state::aim65_pa_w ) VIDEO_START_MEMBER(aim65_state,aim65) { - m_print_timer = machine().scheduler().timer_alloc(FUNC(aim65_printer_timer)); + m_print_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(aim65_state::aim65_printer_timer),this)); m_printerRAM = auto_alloc_array(machine(), UINT16, (600 * 10 * 2) / 2); memset(m_printerRAM, 0, videoram_size); VIDEO_START_CALL_MEMBER(generic); diff --git a/src/mess/machine/amstrad.c b/src/mess/machine/amstrad.c index 8a6066b441d..f0497f37588 100644 --- a/src/mess/machine/amstrad.c +++ b/src/mess/machine/amstrad.c @@ -227,10 +227,9 @@ WRITE_LINE_DEVICE_HANDLER( aleste_interrupt ) /* Some games set the 8255 to mode 1 and expect a strobe signal */ /* on PC2. Apparently PC2 is always low on the CPC. ?!? */ -static TIMER_CALLBACK(amstrad_pc2_low) +TIMER_CALLBACK_MEMBER(amstrad_state::amstrad_pc2_low) { - amstrad_state *state = machine.driver_data<amstrad_state>(); - state->m_ppi->pc2_w(0); + m_ppi->pc2_w(0); } @@ -578,12 +577,12 @@ static void amstrad_plus_handle_dma(running_machine &machine) amstrad_plus_dma_parse( machine, 2 ); } -static TIMER_CALLBACK(amstrad_video_update_timer) +TIMER_CALLBACK_MEMBER(amstrad_state::amstrad_video_update_timer) { if(param == 1) - amstrad_plus_update_video(machine); + amstrad_plus_update_video(machine()); else - amstrad_update_video(machine); + amstrad_update_video(machine()); } /* Set the new colour from the GateArray */ @@ -594,7 +593,7 @@ static void amstrad_vh_update_colour(running_machine &machine, int PenIndex, UIN { int val; - machine.scheduler().timer_set( attotime::from_usec(0), FUNC(amstrad_video_update_timer),1); + machine.scheduler().timer_set( attotime::from_usec(0), timer_expired_delegate(FUNC(amstrad_state::amstrad_video_update_timer),state),1); /* CPC+/GX4000 - normal palette changes through the Gate Array also makes the corresponding change in the ASIC palette */ val = (amstrad_palette[hw_colour_index] & 0xf00000) >> 16; /* red */ @@ -605,7 +604,7 @@ static void amstrad_vh_update_colour(running_machine &machine, int PenIndex, UIN } else { - machine.scheduler().timer_set( attotime::from_usec(0), FUNC(amstrad_video_update_timer),0); + machine.scheduler().timer_set( attotime::from_usec(0), timer_expired_delegate(FUNC(amstrad_state::amstrad_video_update_timer),state),0); } state->m_GateArray_render_colours[PenIndex] = hw_colour_index; } @@ -614,7 +613,7 @@ static void amstrad_vh_update_colour(running_machine &machine, int PenIndex, UIN static void aleste_vh_update_colour(running_machine &machine, int PenIndex, UINT16 hw_colour_index) { amstrad_state *state = machine.driver_data<amstrad_state>(); - machine.scheduler().timer_set( attotime::from_usec(0), FUNC(amstrad_video_update_timer),0); + machine.scheduler().timer_set( attotime::from_usec(0), timer_expired_delegate(FUNC(amstrad_state::amstrad_video_update_timer),state),0); state->m_GateArray_render_colours[PenIndex] = hw_colour_index+32; } @@ -969,7 +968,7 @@ static WRITE_LINE_DEVICE_HANDLER( amstrad_vsync_changed ) drvstate->m_gate_array.vsync = state ? 1 : 0; /* Schedule a write to PC2 */ - device->machine().scheduler().timer_set( attotime::zero, FUNC(amstrad_pc2_low)); + device->machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(amstrad_state::amstrad_pc2_low),drvstate)); } @@ -992,7 +991,7 @@ static WRITE_LINE_DEVICE_HANDLER( amstrad_plus_vsync_changed ) drvstate->m_gate_array.vsync = state ? 1 : 0; /* Schedule a write to PC2 */ - device->machine().scheduler().timer_set( attotime::zero, FUNC(amstrad_pc2_low)); + device->machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(amstrad_state::amstrad_pc2_low),drvstate)); } @@ -2041,9 +2040,9 @@ WRITE8_MEMBER(amstrad_state::amstrad_cpc_io_w) break; case 0x01: /* Write to selected internal 6845 register Write Only */ if ( m_system_type == SYSTEM_PLUS || m_system_type == SYSTEM_GX4000 ) - machine().scheduler().timer_set( attotime::from_usec(0), FUNC(amstrad_video_update_timer),1); + machine().scheduler().timer_set( attotime::from_usec(0), timer_expired_delegate(FUNC(amstrad_state::amstrad_video_update_timer),this),1); else - machine().scheduler().timer_set( attotime::from_usec(0), FUNC(amstrad_video_update_timer),0); + machine().scheduler().timer_set( attotime::from_usec(0), timer_expired_delegate(FUNC(amstrad_state::amstrad_video_update_timer),this),0); mc6845->register_w( space, 0, data ); /* printer port bit 8 */ @@ -2582,7 +2581,7 @@ READ8_DEVICE_HANDLER (amstrad_ppi_portb_r) logerror("amstrad_ppi_portb_r\n"); /* Schedule a write to PC2 */ - space.machine().scheduler().timer_set( attotime::zero, FUNC(amstrad_pc2_low)); + space.machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(amstrad_state::amstrad_pc2_low),state)); return data; } @@ -2912,15 +2911,14 @@ static void amstrad_common_init(running_machine &machine) state->m_maincpu->set_irq_acknowledge_callback(amstrad_cpu_acknowledge_int); } -static TIMER_CALLBACK( cb_set_resolution ) +TIMER_CALLBACK_MEMBER(amstrad_state::cb_set_resolution) { - amstrad_state *state = machine.driver_data<amstrad_state>(); -// screen_device *screen = downcast<screen_device *>(state->m_screen); +// screen_device *screen = downcast<screen_device *>(m_screen); rectangle visarea; attoseconds_t refresh; int height; - if ( machine.root_device().ioport( "solder_links" )->read() & 0x10 ) + if ( machine().root_device().ioport( "solder_links" )->read() & 0x10 ) { /* PAL */ visarea.set(0, 64 + 640 + 64 - 1, 34, 34 + 15 + 242 + 15 - 1); @@ -2933,7 +2931,7 @@ static TIMER_CALLBACK( cb_set_resolution ) height = 262; } refresh = HZ_TO_ATTOSECONDS( XTAL_16MHz ) * 1024 * height; - state->m_screen->configure( 1024, height, visarea, refresh ); + m_screen->configure( 1024, height, visarea, refresh ); } @@ -2963,7 +2961,7 @@ MACHINE_RESET_MEMBER(amstrad_state,amstrad) m_gate_array.hsync = 0; m_gate_array.vsync = 0; - machine().scheduler().timer_set( attotime::zero, FUNC(cb_set_resolution)); + machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(amstrad_state::cb_set_resolution),this)); } @@ -3015,7 +3013,7 @@ MACHINE_RESET_MEMBER(amstrad_state,plus) space.install_write_handler(0x6000, 0x7fff, write8_delegate(FUNC(amstrad_state::amstrad_plus_asic_6000_w),this)); // multiface_init(); - machine().scheduler().timer_set( attotime::zero, FUNC(cb_set_resolution)); + machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(amstrad_state::cb_set_resolution),this)); } MACHINE_START_MEMBER(amstrad_state,gx4000) @@ -3064,7 +3062,7 @@ MACHINE_RESET_MEMBER(amstrad_state,gx4000) space.install_write_handler(0x4000, 0x5fff, write8_delegate(FUNC(amstrad_state::amstrad_plus_asic_4000_w),this)); space.install_write_handler(0x6000, 0x7fff, write8_delegate(FUNC(amstrad_state::amstrad_plus_asic_6000_w),this)); - machine().scheduler().timer_set( attotime::zero, FUNC(cb_set_resolution)); + machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(amstrad_state::cb_set_resolution),this)); } MACHINE_START_MEMBER(amstrad_state,kccomp) @@ -3116,7 +3114,7 @@ MACHINE_RESET_MEMBER(amstrad_state,aleste) amstrad_common_init(machine()); amstrad_reset_machine(machine()); - machine().scheduler().timer_set( attotime::zero, FUNC(cb_set_resolution)); + machine().scheduler().timer_set( attotime::zero, timer_expired_delegate(FUNC(amstrad_state::cb_set_resolution),this)); } diff --git a/src/mess/machine/apple1.c b/src/mess/machine/apple1.c index f6424e3042f..65c16c7533f 100644 --- a/src/mess/machine/apple1.c +++ b/src/mess/machine/apple1.c @@ -51,15 +51,15 @@ #include "imagedev/cassette.h" #include "machine/ram.h" -static TIMER_CALLBACK(apple1_kbd_poll); -static TIMER_CALLBACK(apple1_kbd_strobe_end); + + static DECLARE_READ8_DEVICE_HANDLER( apple1_pia0_kbdin ); static DECLARE_WRITE8_DEVICE_HANDLER( apple1_pia0_dspout ); static DECLARE_WRITE8_DEVICE_HANDLER( apple1_pia0_dsp_write_signal ); -static TIMER_CALLBACK(apple1_dsp_ready_start); -static TIMER_CALLBACK(apple1_dsp_ready_end); + + /***************************************************************************** ** Structures @@ -158,7 +158,7 @@ DRIVER_INIT_MEMBER(apple1_state,apple1) A 120-Hz poll rate seems to be fast enough to ensure no keystrokes are missed. */ - machine().scheduler().timer_pulse(attotime::from_hz(120), FUNC(apple1_kbd_poll)); + machine().scheduler().timer_pulse(attotime::from_hz(120), timer_expired_delegate(FUNC(apple1_state::apple1_kbd_poll),this)); } @@ -277,13 +277,12 @@ SNAPSHOT_LOAD(apple1) ** If multiple newly-pressed keys are found, the one closest to the ** end of the input ports list is counted; the others are ignored. *****************************************************************************/ -static TIMER_CALLBACK(apple1_kbd_poll) +TIMER_CALLBACK_MEMBER(apple1_state::apple1_kbd_poll) { - apple1_state *state = machine.driver_data<apple1_state>(); int port, bit; int key_pressed; UINT32 shiftkeys, ctrlkeys; - pia6821_device *pia = machine.device<pia6821_device>("pia"); + pia6821_device *pia = machine().device<pia6821_device>("pia"); static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3" }; /* This holds the values of all the input ports for ordinary keys @@ -292,56 +291,56 @@ static TIMER_CALLBACK(apple1_kbd_poll) /* First we check the RESET and CLEAR SCREEN pushbutton switches. */ /* The RESET switch resets the CPU and the 6820 PIA. */ - if (machine.root_device().ioport("KEY5")->read() & 0x0001) + if (machine().root_device().ioport("KEY5")->read() & 0x0001) { - if (!state->m_reset_flag) { - state->m_reset_flag = 1; + if (!m_reset_flag) { + m_reset_flag = 1; /* using PULSE_LINE does not allow us to press and hold key */ - machine.device("maincpu")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE); + machine().device("maincpu")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE); pia->reset(); } } - else if (state->m_reset_flag) { + else if (m_reset_flag) { /* RESET released--allow the processor to continue. */ - state->m_reset_flag = 0; - machine.device("maincpu")->execute().set_input_line(INPUT_LINE_RESET, CLEAR_LINE); + m_reset_flag = 0; + machine().device("maincpu")->execute().set_input_line(INPUT_LINE_RESET, CLEAR_LINE); } /* The CLEAR SCREEN switch clears the video hardware. */ - if (machine.root_device().ioport("KEY5")->read() & 0x0002) + if (machine().root_device().ioport("KEY5")->read() & 0x0002) { - if (!state->m_vh_clrscrn_pressed) + if (!m_vh_clrscrn_pressed) { /* Ignore further video writes, and clear the screen. */ - state->m_vh_clrscrn_pressed = 1; - apple1_vh_dsp_clr(machine); + m_vh_clrscrn_pressed = 1; + apple1_vh_dsp_clr(machine()); } } - else if (state->m_vh_clrscrn_pressed) + else if (m_vh_clrscrn_pressed) { /* CLEAR SCREEN released--pay attention to video writes again. */ - state->m_vh_clrscrn_pressed = 0; + m_vh_clrscrn_pressed = 0; } /* Now we scan all the input ports for ordinary keys, recording new keypresses while ignoring keys that were already pressed in the last scan. */ - state->m_kbd_data = 0; + m_kbd_data = 0; key_pressed = 0; /* The keyboard strobe line should always be low when a scan starts. */ pia->ca1_w(0); - shiftkeys = machine.root_device().ioport("KEY4")->read() & 0x0003; - ctrlkeys = machine.root_device().ioport("KEY4")->read() & 0x000c; + shiftkeys = machine().root_device().ioport("KEY4")->read() & 0x0003; + ctrlkeys = machine().root_device().ioport("KEY4")->read() & 0x000c; for (port = 0; port < 4; port++) { UINT32 portval, newkeys; - portval = machine.root_device().ioport(keynames[port])->read(); - newkeys = portval & ~(state->m_kbd_last_scan[port]); + portval = machine().root_device().ioport(keynames[port])->read(); + newkeys = portval & ~(m_kbd_last_scan[port]); if (newkeys) { @@ -349,7 +348,7 @@ static TIMER_CALLBACK(apple1_kbd_poll) for (bit = 0; bit < 16; bit++) { if (newkeys & 1) { - state->m_kbd_data = (ctrlkeys) + m_kbd_data = (ctrlkeys) ? apple1_control_keymap[port*16 + bit] : (shiftkeys) ? apple1_shifted_keymap[port*16 + bit] @@ -358,7 +357,7 @@ static TIMER_CALLBACK(apple1_kbd_poll) newkeys >>= 1; } } - state->m_kbd_last_scan[port] = portval; + m_kbd_last_scan[port] = portval; } if (key_pressed) @@ -366,13 +365,13 @@ static TIMER_CALLBACK(apple1_kbd_poll) /* The keyboard will pulse its strobe line when a key is pressed. A 10-usec pulse is typical. */ pia->ca1_w(1); - machine.scheduler().timer_set(attotime::from_usec(10), FUNC(apple1_kbd_strobe_end)); + machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(apple1_state::apple1_kbd_strobe_end),this)); } } -static TIMER_CALLBACK(apple1_kbd_strobe_end) +TIMER_CALLBACK_MEMBER(apple1_state::apple1_kbd_strobe_end) { - pia6821_device *pia = machine.device<pia6821_device>("pia"); + pia6821_device *pia = machine().device<pia6821_device>("pia"); /* End of the keyboard strobe pulse. */ pia->ca1_w(0); @@ -412,25 +411,26 @@ static WRITE8_DEVICE_HANDLER( apple1_pia0_dsp_write_signal ) Only then will it assert \RDA to signal readiness for another write. Thus the write delay depends on the cursor position and where the display is in the refresh cycle. */ + apple1_state *state = space.machine().driver_data<apple1_state>(); if (!data) - space.machine().scheduler().timer_set(apple1_vh_dsp_time_to_ready(space.machine()), FUNC(apple1_dsp_ready_start)); + space.machine().scheduler().timer_set(apple1_vh_dsp_time_to_ready(space.machine()), timer_expired_delegate(FUNC(apple1_state::apple1_dsp_ready_start),state)); } -static TIMER_CALLBACK(apple1_dsp_ready_start) +TIMER_CALLBACK_MEMBER(apple1_state::apple1_dsp_ready_start) { - pia6821_device *pia = machine.device<pia6821_device>("pia"); + pia6821_device *pia = machine().device<pia6821_device>("pia"); /* When the display asserts \RDA to signal it is ready, it triggers a 74123 one-shot to send a 3.5-usec low pulse to PIA input CB1. The end of this pulse will tell the PIA that the display is ready for another write. */ pia->cb1_w(0); - machine.scheduler().timer_set(attotime::from_nsec(3500), FUNC(apple1_dsp_ready_end)); + machine().scheduler().timer_set(attotime::from_nsec(3500), timer_expired_delegate(FUNC(apple1_state::apple1_dsp_ready_end),this)); } -static TIMER_CALLBACK(apple1_dsp_ready_end) +TIMER_CALLBACK_MEMBER(apple1_state::apple1_dsp_ready_end) { - pia6821_device *pia = machine.device<pia6821_device>("pia"); + pia6821_device *pia = machine().device<pia6821_device>("pia"); /* The one-shot pulse has ended; return CB1 to high, so we can do another display write. */ diff --git a/src/mess/machine/apple2gs.c b/src/mess/machine/apple2gs.c index ec88a568215..d79ac46b44b 100644 --- a/src/mess/machine/apple2gs.c +++ b/src/mess/machine/apple2gs.c @@ -294,25 +294,23 @@ void apple2gs_doc_irq(device_t *device, int state) /* Clock interrupt */ -static TIMER_CALLBACK( apple2gs_clock_tick ) +TIMER_CALLBACK_MEMBER(apple2gs_state::apple2gs_clock_tick) { - apple2gs_state *state = machine.driver_data<apple2gs_state>(); - if ((state->m_vgcint & 0x04) && !(state->m_vgcint & 0x40)) + if ((m_vgcint & 0x04) && !(m_vgcint & 0x40)) { - state->m_vgcint |= 0xc0; - apple2gs_add_irq(machine, IRQ_VGC_SECOND); + m_vgcint |= 0xc0; + apple2gs_add_irq(machine(), IRQ_VGC_SECOND); } } /* Quarter-second interrupt */ -static TIMER_CALLBACK( apple2gs_qsecond_tick ) +TIMER_CALLBACK_MEMBER(apple2gs_state::apple2gs_qsecond_tick) { - apple2gs_state *state = machine.driver_data<apple2gs_state>(); - if ((state->m_inten & 0x10) && !(state->m_intflag & 0x10)) + if ((m_inten & 0x10) && !(m_intflag & 0x10)) { - state->m_intflag |= 0x10; - apple2gs_add_irq(machine, IRQ_INTEN_QSECOND); + m_intflag |= 0x10; + apple2gs_add_irq(machine(), IRQ_INTEN_QSECOND); } } @@ -736,31 +734,30 @@ static void apple2gs_set_scanint(running_machine &machine, UINT8 data) } -static TIMER_CALLBACK(apple2gs_scanline_tick) +TIMER_CALLBACK_MEMBER(apple2gs_state::apple2gs_scanline_tick) { - apple2gs_state *state = machine.driver_data<apple2gs_state>(); int scanline; - scanline = machine.primary_screen->vpos(); - machine.primary_screen->update_partial(scanline); + scanline = machine().primary_screen->vpos(); + machine().primary_screen->update_partial(scanline); /* check scanline interrupt bits if we're in super hi-res and the current scanline is within the active display area */ - if ((state->m_newvideo & 0x80) && (scanline >= (BORDER_TOP-1)) && (scanline < (200+BORDER_TOP-1))) + if ((m_newvideo & 0x80) && (scanline >= (BORDER_TOP-1)) && (scanline < (200+BORDER_TOP-1))) { UINT8 scb; - scb = state->m_slowmem[0x19D00 + scanline - BORDER_TOP + 1]; + scb = m_slowmem[0x19D00 + scanline - BORDER_TOP + 1]; if (scb & 0x40) { // scanline int flag is set even when the actual interrupt is disabled - state->m_vgcint |= 0x20; + m_vgcint |= 0x20; // see if the interrupt is also enabled and trigger it if so - if (state->m_vgcint & 0x02) + if (m_vgcint & 0x02) { - state->m_vgcint |= 0x80; - apple2gs_add_irq(machine, IRQ_VGC_SCANLINE); + m_vgcint |= 0x80; + apple2gs_add_irq(machine(), IRQ_VGC_SCANLINE); } } } @@ -768,28 +765,28 @@ static TIMER_CALLBACK(apple2gs_scanline_tick) if (scanline == (192+BORDER_TOP)) { /* VBL interrupt */ - if ((state->m_inten & 0x08) && !(state->m_intflag & 0x08)) + if ((m_inten & 0x08) && !(m_intflag & 0x08)) { - state->m_intflag |= 0x08; - apple2gs_add_irq(machine, IRQ_INTEN_VBL); + m_intflag |= 0x08; + apple2gs_add_irq(machine(), IRQ_INTEN_VBL); } } /* check the mouse status */ if ((scanline % 8) == 0) { - adb_check_mouse(machine); + adb_check_mouse(machine()); /* call Apple II interrupt handler */ - if ((machine.primary_screen->vpos() % 8) == 7) + if ((machine().primary_screen->vpos() % 8) == 7) { - //apple2_interrupt(machine.device("maincpu")); + //apple2_interrupt(machine().device("maincpu")); /* TODO: check me! */ - machine.primary_screen->update_partial(machine.primary_screen->vpos()); + machine().primary_screen->update_partial(machine().primary_screen->vpos()); } } - state->m_scanline_timer->adjust(machine.primary_screen->time_until_pos((scanline+1)%262, 0)); + m_scanline_timer->adjust(machine().primary_screen->time_until_pos((scanline+1)%262, 0)); } @@ -1993,13 +1990,13 @@ MACHINE_START_MEMBER(apple2gs_state,apple2gscommon) state_save_register_item(machine(), "ECHOBANK", NULL,0, m_echo_bank); - m_clock_timer = machine().scheduler().timer_alloc(FUNC(apple2gs_clock_tick)); + m_clock_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(apple2gs_state::apple2gs_clock_tick),this)); m_clock_timer->adjust(attotime::from_seconds(1), 0, attotime::from_seconds(1)); - m_qsecond_timer = machine().scheduler().timer_alloc(FUNC(apple2gs_qsecond_tick)); + m_qsecond_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(apple2gs_state::apple2gs_qsecond_tick),this)); m_qsecond_timer->adjust(attotime::from_usec(266700), 0, attotime::from_usec(266700)); - m_scanline_timer = machine().scheduler().timer_alloc(FUNC(apple2gs_scanline_tick)); + m_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(apple2gs_state::apple2gs_scanline_tick),this)); m_scanline_timer->adjust(attotime::never); // fire on scanline zero diff --git a/src/mess/machine/bbc.c b/src/mess/machine/bbc.c index d692a118179..a913baa2f73 100644 --- a/src/mess/machine/bbc.c +++ b/src/mess/machine/bbc.c @@ -1314,63 +1314,62 @@ static void MC6850_Receive_Clock(running_machine &machine, int new_clock) state->m_mc6850_clock = new_clock; } -static TIMER_CALLBACK(bbc_tape_timer_cb) +TIMER_CALLBACK_MEMBER(bbc_state::bbc_tape_timer_cb) { - bbc_state *state = machine.driver_data<bbc_state>(); double dev_val; - dev_val=machine.device<cassette_image_device>(CASSETTE_TAG)->input(); + dev_val=machine().device<cassette_image_device>(CASSETTE_TAG)->input(); // look for rising edges on the cassette wave - if (((dev_val>=0.0) && (state->m_last_dev_val<0.0)) || ((dev_val<0.0) && (state->m_last_dev_val>=0.0))) + if (((dev_val>=0.0) && (m_last_dev_val<0.0)) || ((dev_val<0.0) && (m_last_dev_val>=0.0))) { - if (state->m_wav_len>(9*3)) + if (m_wav_len>(9*3)) { //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. - logerror ("Cassette length %d\n",state->m_wav_len); - state->m_len0=0; - state->m_len1=0; - state->m_len2=0; - state->m_len3=0; - state->m_wav_len=0; + logerror ("Cassette length %d\n",m_wav_len); + m_len0=0; + m_len1=0; + m_len2=0; + m_len3=0; + m_wav_len=0; } - state->m_len3=state->m_len2; - state->m_len2=state->m_len1; - state->m_len1=state->m_len0; - state->m_len0=state->m_wav_len; + m_len3=m_len2; + m_len2=m_len1; + m_len1=m_len0; + m_len0=m_wav_len; - state->m_wav_len=0; - logerror ("cassette %d %d %d %d\n",state->m_len3,state->m_len2,state->m_len1,state->m_len0); + m_wav_len=0; + logerror ("cassette %d %d %d %d\n",m_len3,m_len2,m_len1,m_len0); - if ((state->m_len0+state->m_len1)>=(18+18-5)) + if ((m_len0+m_len1)>=(18+18-5)) { /* Clock a 0 onto the serial line */ logerror("Serial value 0\n"); - MC6850_Receive_Clock(machine, 0); - state->m_len0=0; - state->m_len1=0; - state->m_len2=0; - state->m_len3=0; + MC6850_Receive_Clock(machine(), 0); + m_len0=0; + m_len1=0; + m_len2=0; + m_len3=0; } - if (((state->m_len0+state->m_len1+state->m_len2+state->m_len3)<=41) && (state->m_len3!=0)) + if (((m_len0+m_len1+m_len2+m_len3)<=41) && (m_len3!=0)) { /* Clock a 1 onto the serial line */ logerror("Serial value 1\n"); - MC6850_Receive_Clock(machine, 1); - state->m_len0=0; - state->m_len1=0; - state->m_len2=0; - state->m_len3=0; + MC6850_Receive_Clock(machine(), 1); + m_len0=0; + m_len1=0; + m_len2=0; + m_len3=0; } } - state->m_wav_len++; - state->m_last_dev_val=dev_val; + m_wav_len++; + m_last_dev_val=dev_val; } @@ -1987,12 +1986,12 @@ DEVICE_IMAGE_LOAD( bbcb_cart ) DRIVER_INIT_MEMBER(bbc_state,bbc) { m_Master=0; - m_tape_timer = machine().scheduler().timer_alloc(FUNC(bbc_tape_timer_cb)); + m_tape_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(bbc_state::bbc_tape_timer_cb),this)); } DRIVER_INIT_MEMBER(bbc_state,bbcm) { m_Master=1; - m_tape_timer = machine().scheduler().timer_alloc(FUNC(bbc_tape_timer_cb)); + m_tape_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(bbc_state::bbc_tape_timer_cb),this)); } MACHINE_START_MEMBER(bbc_state,bbca) diff --git a/src/mess/machine/bebox.c b/src/mess/machine/bebox.c index 0dc6f6b5428..44f2bed740a 100644 --- a/src/mess/machine/bebox.c +++ b/src/mess/machine/bebox.c @@ -968,12 +968,11 @@ void scsi53c810_pci_write(device_t *busdevice, device_t *device, int function, i } -static TIMER_CALLBACK( bebox_get_devices ) { - bebox_state *state = machine.driver_data<bebox_state>(); - state->m_devices.pic8259_master = machine.device("pic8259_master"); - state->m_devices.pic8259_slave = machine.device("pic8259_slave"); - state->m_devices.dma8237_1 = machine.device("dma8237_1"); - state->m_devices.dma8237_2 = machine.device("dma8237_2"); +TIMER_CALLBACK_MEMBER(bebox_state::bebox_get_devices){ + m_devices.pic8259_master = machine().device("pic8259_master"); + m_devices.pic8259_slave = machine().device("pic8259_slave"); + m_devices.dma8237_1 = machine().device("dma8237_1"); + m_devices.dma8237_2 = machine().device("dma8237_2"); } @@ -990,7 +989,7 @@ void bebox_state::machine_reset() m_devices.dma8237_1 = NULL; m_devices.dma8237_2 = NULL; - machine().scheduler().timer_set(attotime::zero, FUNC(bebox_get_devices)); + machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(bebox_state::bebox_get_devices),this)); machine().device("ppc1")->execute().set_input_line(INPUT_LINE_RESET, CLEAR_LINE); machine().device("ppc2")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE); diff --git a/src/mess/machine/bk.c b/src/mess/machine/bk.c index d1a943af6de..8249a34eccf 100644 --- a/src/mess/machine/bk.c +++ b/src/mess/machine/bk.c @@ -13,9 +13,8 @@ #include "includes/bk.h" -static TIMER_CALLBACK(keyboard_callback) +TIMER_CALLBACK_MEMBER(bk_state::keyboard_callback) { - bk_state *state = machine.driver_data<bk_state>(); UINT8 code, i, j; static const char *const keynames[] = { "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", @@ -24,42 +23,42 @@ static TIMER_CALLBACK(keyboard_callback) for(i = 1; i < 12; i++) { - code = machine.root_device().ioport(keynames[i-1])->read(); + code = machine().root_device().ioport(keynames[i-1])->read(); if (code != 0) { for(j = 0; j < 8; j++) { if (code == (1 << j)) { - state->m_key_code = j + i*8; + m_key_code = j + i*8; break; } } - if ((machine.root_device().ioport("LINE0")->read() & 4) == 4) + if ((machine().root_device().ioport("LINE0")->read() & 4) == 4) { if (i==6 || i==7) { - state->m_key_code -= 16; + m_key_code -= 16; } } - if ((machine.root_device().ioport("LINE0")->read() & 4) == 4) + if ((machine().root_device().ioport("LINE0")->read() & 4) == 4) { if (i>=8 && i<=11) { - state->m_key_code += 32; + m_key_code += 32; } } - state->m_key_pressed = 0x40; - if ((machine.root_device().ioport("LINE0")->read() & 2) == 0) + m_key_pressed = 0x40; + if ((machine().root_device().ioport("LINE0")->read() & 2) == 0) { - state->m_key_irq_vector = 0x30; + m_key_irq_vector = 0x30; } else { - state->m_key_irq_vector = 0xBC; + m_key_irq_vector = 0xBC; } - machine.device("maincpu")->execute().set_input_line(0, ASSERT_LINE); + machine().device("maincpu")->execute().set_input_line(0, ASSERT_LINE); break; } } @@ -68,7 +67,7 @@ static TIMER_CALLBACK(keyboard_callback) void bk_state::machine_start() { - machine().scheduler().timer_pulse(attotime::from_hz(2400), FUNC(keyboard_callback)); + machine().scheduler().timer_pulse(attotime::from_hz(2400), timer_expired_delegate(FUNC(bk_state::keyboard_callback),this)); } static IRQ_CALLBACK(bk0010_irq_callback) diff --git a/src/mess/machine/cgenie.c b/src/mess/machine/cgenie.c index e0d5cd76770..6356d72fa38 100644 --- a/src/mess/machine/cgenie.c +++ b/src/mess/machine/cgenie.c @@ -32,15 +32,14 @@ -static TIMER_CALLBACK( handle_cassette_input ) +TIMER_CALLBACK_MEMBER(cgenie_state::handle_cassette_input) { - cgenie_state *state = machine.driver_data<cgenie_state>(); - UINT8 new_level = ( (machine.device<cassette_image_device>(CASSETTE_TAG)->input()) > 0.0 ) ? 1 : 0; + UINT8 new_level = ( (machine().device<cassette_image_device>(CASSETTE_TAG)->input()) > 0.0 ) ? 1 : 0; - if ( new_level != state->m_cass_level ) + if ( new_level != m_cass_level ) { - state->m_cass_level = new_level; - state->m_cass_bit ^= 1; + m_cass_level = new_level; + m_cass_bit ^= 1; } } @@ -151,7 +150,7 @@ void cgenie_state::machine_start() space.install_legacy_write_handler(0x4000, 0x4000 + machine().device<ram_device>(RAM_TAG)->size() - 1, FUNC(cgenie_videoram_w)); m_videoram = machine().device<ram_device>(RAM_TAG)->pointer(); membank("bank1")->set_base(machine().device<ram_device>(RAM_TAG)->pointer()); - machine().scheduler().timer_pulse(attotime::from_hz(11025), FUNC(handle_cassette_input)); + machine().scheduler().timer_pulse(attotime::from_hz(11025), timer_expired_delegate(FUNC(cgenie_state::handle_cassette_input),this)); } /************************************* diff --git a/src/mess/machine/compis.c b/src/mess/machine/compis.c index 8883de1f273..c9b64de3411 100644 --- a/src/mess/machine/compis.c +++ b/src/mess/machine/compis.c @@ -596,11 +596,10 @@ void compis_state::handle_eoi(int data) * *************************************/ -static TIMER_CALLBACK(internal_timer_int) +TIMER_CALLBACK_MEMBER(compis_state::internal_timer_int) { - compis_state *state = machine.driver_data<compis_state>(); int which = param; - struct timer_state *t = &state->m_i186.timer[which]; + struct timer_state *t = &m_i186.timer[which]; if (LOG_TIMER) logerror("Hit interrupt callback for timer %d\n", which); @@ -610,8 +609,8 @@ static TIMER_CALLBACK(internal_timer_int) /* request an interrupt */ if (t->control & 0x2000) { - state->m_i186.intr.status |= 0x01 << which; - update_interrupt_state(machine); + m_i186.intr.status |= 0x01 << which; + update_interrupt_state(machine()); if (LOG_TIMER) logerror(" Generating timer interrupt\n"); } @@ -781,11 +780,10 @@ void compis_state::internal_timer_update(int which, int new_count, int new_maxA, * *************************************/ -static TIMER_CALLBACK(dma_timer_callback) +TIMER_CALLBACK_MEMBER(compis_state::dma_timer_callback) { - compis_state *state = machine.driver_data<compis_state>(); int which = param; - struct dma_state *d = &state->m_i186.dma[which]; + struct dma_state *d = &m_i186.dma[which]; /* force an update and see if we're really done */ //stream_update(dma_stream, 0); @@ -799,8 +797,8 @@ static TIMER_CALLBACK(dma_timer_callback) if (d->control & 0x0100) { if (LOG_DMA) logerror("DMA%d timer callback - requesting interrupt: count = %04X, source = %04X\n", which, d->count, d->source); - state->m_i186.intr.request |= 0x04 << which; - update_interrupt_state(machine); + m_i186.intr.request |= 0x04 << which; + update_interrupt_state(machine()); } } @@ -1301,14 +1299,14 @@ static void compis_cpu_init(running_machine &machine) { compis_state *state = machine.driver_data<compis_state>(); /* create timers here so they stick around */ - state->m_i186.timer[0].int_timer = machine.scheduler().timer_alloc(FUNC(internal_timer_int)); - state->m_i186.timer[1].int_timer = machine.scheduler().timer_alloc(FUNC(internal_timer_int)); - state->m_i186.timer[2].int_timer = machine.scheduler().timer_alloc(FUNC(internal_timer_int)); - state->m_i186.timer[0].time_timer = machine.scheduler().timer_alloc(FUNC_NULL); - state->m_i186.timer[1].time_timer = machine.scheduler().timer_alloc(FUNC_NULL); - state->m_i186.timer[2].time_timer = machine.scheduler().timer_alloc(FUNC_NULL); - state->m_i186.dma[0].finish_timer = machine.scheduler().timer_alloc(FUNC(dma_timer_callback)); - state->m_i186.dma[1].finish_timer = machine.scheduler().timer_alloc(FUNC(dma_timer_callback)); + state->m_i186.timer[0].int_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(compis_state::internal_timer_int),state)); + state->m_i186.timer[1].int_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(compis_state::internal_timer_int),state)); + state->m_i186.timer[2].int_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(compis_state::internal_timer_int),state)); + state->m_i186.timer[0].time_timer = machine.scheduler().timer_alloc(timer_expired_delegate()); + state->m_i186.timer[1].time_timer = machine.scheduler().timer_alloc(timer_expired_delegate()); + state->m_i186.timer[2].time_timer = machine.scheduler().timer_alloc(timer_expired_delegate()); + state->m_i186.dma[0].finish_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(compis_state::dma_timer_callback),state)); + state->m_i186.dma[1].finish_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(compis_state::dma_timer_callback),state)); } /*-------------------------------------------------------------------------*/ diff --git a/src/mess/machine/dai.c b/src/mess/machine/dai.c index 7a069090de6..7d8ddb05455 100644 --- a/src/mess/machine/dai.c +++ b/src/mess/machine/dai.c @@ -34,9 +34,9 @@ static void dai_update_memory(running_machine &machine, int dai_rom_bank) state->membank("bank2")->set_entry(dai_rom_bank); } -static TIMER_CALLBACK(dai_bootstrap_callback) +TIMER_CALLBACK_MEMBER(dai_state::dai_bootstrap_callback) { - machine.device("maincpu")->state().set_pc(0xc000); + machine().device("maincpu")->state().set_pc(0xc000); } @@ -105,18 +105,17 @@ const struct pit8253_config dai_pit8253_intf = } }; -static TIMER_CALLBACK( dai_timer ) +TIMER_CALLBACK_MEMBER(dai_state::dai_timer) { - dai_state *state = machine.driver_data<dai_state>(); - state->m_tms5501->set_pio_bit_7((state->ioport("IN8")->read() & 0x04) ? 1:0); + m_tms5501->set_pio_bit_7((ioport("IN8")->read() & 0x04) ? 1:0); } void dai_state::machine_start() { membank("bank2")->configure_entries(0, 4, memregion("maincpu")->base() + 0x010000, 0x1000); - machine().scheduler().timer_set(attotime::zero, FUNC(dai_bootstrap_callback)); - machine().scheduler().timer_pulse(attotime::from_hz(100), FUNC(dai_timer)); /* timer for tms5501 */ + machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(dai_state::dai_bootstrap_callback),this)); + machine().scheduler().timer_pulse(attotime::from_hz(100), timer_expired_delegate(FUNC(dai_state::dai_timer),this)); /* timer for tms5501 */ memset(machine().device<ram_device>(RAM_TAG)->pointer(), 0, machine().device<ram_device>(RAM_TAG)->size()); } diff --git a/src/mess/machine/electron.c b/src/mess/machine/electron.c index 8f920490b5f..570b5ea4e6e 100644 --- a/src/mess/machine/electron.c +++ b/src/mess/machine/electron.c @@ -41,75 +41,74 @@ void electron_state::electron_tape_stop() #define TAPE_LOW 0x00; #define TAPE_HIGH 0xFF; -static TIMER_CALLBACK(electron_tape_timer_handler) +TIMER_CALLBACK_MEMBER(electron_state::electron_tape_timer_handler) { - electron_state *state = machine.driver_data<electron_state>(); - if ( state->m_ula.cassette_motor_mode ) + if ( m_ula.cassette_motor_mode ) { double tap_val; - tap_val = cassette_device_image(machine)->input(); + tap_val = cassette_device_image(machine())->input(); if ( tap_val < -0.5 ) { - state->m_ula.tape_value = ( state->m_ula.tape_value << 8 ) | TAPE_LOW; - state->m_ula.tape_steps++; + m_ula.tape_value = ( m_ula.tape_value << 8 ) | TAPE_LOW; + m_ula.tape_steps++; } else if ( tap_val > 0.5 ) { - state->m_ula.tape_value = ( state->m_ula.tape_value << 8 ) | TAPE_HIGH; - state->m_ula.tape_steps++; + m_ula.tape_value = ( m_ula.tape_value << 8 ) | TAPE_HIGH; + m_ula.tape_steps++; } else { - state->m_ula.tape_steps = 0; - state->m_ula.bit_count = 0; - state->m_ula.high_tone_set = 0; - state->m_ula.tape_value = 0x80808080; + m_ula.tape_steps = 0; + m_ula.bit_count = 0; + m_ula.high_tone_set = 0; + m_ula.tape_value = 0x80808080; } - if ( state->m_ula.tape_steps > 2 && ( state->m_ula.tape_value == 0x0000FFFF || state->m_ula.tape_value == 0x00FF00FF ) ) + if ( m_ula.tape_steps > 2 && ( m_ula.tape_value == 0x0000FFFF || m_ula.tape_value == 0x00FF00FF ) ) { - state->m_ula.tape_steps = 0; - switch( state->m_ula.bit_count ) + m_ula.tape_steps = 0; + switch( m_ula.bit_count ) { case 0: /* start bit */ - state->m_ula.start_bit = ( ( state->m_ula.tape_value == 0x0000FFFF ) ? 0 : 1 ); - //logerror( "++ Read start bit: %d\n", state->m_ula.start_bit ); - if ( state->m_ula.start_bit ) + m_ula.start_bit = ( ( m_ula.tape_value == 0x0000FFFF ) ? 0 : 1 ); + //logerror( "++ Read start bit: %d\n", m_ula.start_bit ); + if ( m_ula.start_bit ) { - if ( state->m_ula.high_tone_set ) + if ( m_ula.high_tone_set ) { - state->m_ula.bit_count--; + m_ula.bit_count--; } } else { - state->m_ula.high_tone_set = 0; + m_ula.high_tone_set = 0; } break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: - //logerror( "++ Read regular bit: %d\n", state->m_ula.tape_value == 0x0000FFFF ? 0 : 1 ); - state->m_ula.tape_byte = ( state->m_ula.tape_byte >> 1 ) | ( state->m_ula.tape_value == 0x0000FFFF ? 0 : 0x80 ); + //logerror( "++ Read regular bit: %d\n", m_ula.tape_value == 0x0000FFFF ? 0 : 1 ); + m_ula.tape_byte = ( m_ula.tape_byte >> 1 ) | ( m_ula.tape_value == 0x0000FFFF ? 0 : 0x80 ); break; case 9: /* stop bit */ - state->m_ula.stop_bit = ( ( state->m_ula.tape_value == 0x0000FFFF ) ? 0 : 1 ); - //logerror( "++ Read stop bit: %d\n", state->m_ula.stop_bit ); - if ( state->m_ula.start_bit && state->m_ula.stop_bit && state->m_ula.tape_byte == 0xFF && ! state->m_ula.high_tone_set ) + m_ula.stop_bit = ( ( m_ula.tape_value == 0x0000FFFF ) ? 0 : 1 ); + //logerror( "++ Read stop bit: %d\n", m_ula.stop_bit ); + if ( m_ula.start_bit && m_ula.stop_bit && m_ula.tape_byte == 0xFF && ! m_ula.high_tone_set ) { - electron_interrupt_handler( machine, INT_SET, INT_HIGH_TONE ); - state->m_ula.high_tone_set = 1; + electron_interrupt_handler( machine(), INT_SET, INT_HIGH_TONE ); + m_ula.high_tone_set = 1; } - else if ( ! state->m_ula.start_bit && state->m_ula.stop_bit ) + else if ( ! m_ula.start_bit && m_ula.stop_bit ) { - //logerror( "-- Byte read from tape: %02x\n", state->m_ula.tape_byte ); - electron_interrupt_handler( machine, INT_SET, INT_RECEIVE_FULL ); + //logerror( "-- Byte read from tape: %02x\n", m_ula.tape_byte ); + electron_interrupt_handler( machine(), INT_SET, INT_RECEIVE_FULL ); } else { - logerror( "Invalid start/stop bit combination detected: %d,%d\n", state->m_ula.start_bit, state->m_ula.stop_bit ); + logerror( "Invalid start/stop bit combination detected: %d,%d\n", m_ula.start_bit, m_ula.stop_bit ); } break; } - state->m_ula.bit_count = ( state->m_ula.bit_count + 1 ) % 10; + m_ula.bit_count = ( m_ula.bit_count + 1 ) % 10; } } } @@ -315,9 +314,9 @@ void electron_interrupt_handler(running_machine &machine, int mode, int interrup Machine Initialisation functions ***************************************/ -static TIMER_CALLBACK(setup_beep) +TIMER_CALLBACK_MEMBER(electron_state::setup_beep) { - device_t *speaker = machine.device(BEEPER_TAG); + device_t *speaker = machine().device(BEEPER_TAG); beep_set_state( speaker, 0 ); beep_set_frequency( speaker, 300 ); } @@ -346,8 +345,8 @@ void electron_state::machine_start() m_ula.interrupt_status = 0x82; m_ula.interrupt_control = 0x00; - machine().scheduler().timer_set(attotime::zero, FUNC(setup_beep)); - m_tape_timer = machine().scheduler().timer_alloc(FUNC(electron_tape_timer_handler)); + machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(electron_state::setup_beep),this)); + m_tape_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(electron_state::electron_tape_timer_handler),this)); machine().add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(electron_reset),&machine())); } diff --git a/src/mess/machine/gamecom.c b/src/mess/machine/gamecom.c index a4be8c572c6..670d8f308ba 100644 --- a/src/mess/machine/gamecom.c +++ b/src/mess/machine/gamecom.c @@ -5,12 +5,12 @@ static const int gamecom_timer_limit[8] = { 2, 1024, 2048, 4096, 8192, 16384, 32768, 65536 }; -static TIMER_CALLBACK(gamecom_clock_timer_callback) +TIMER_CALLBACK_MEMBER(gamecom_state::gamecom_clock_timer_callback) { - UINT8 * RAM = machine.root_device().memregion("maincpu")->base(); + UINT8 * RAM = machine().root_device().memregion("maincpu")->base(); UINT8 val = ( ( RAM[SM8521_CLKT] & 0x3F ) + 1 ) & 0x3F; RAM[SM8521_CLKT] = ( RAM[SM8521_CLKT] & 0xC0 ) | val; - machine.device("maincpu")->execute().set_input_line(CK_INT, ASSERT_LINE ); + machine().device("maincpu")->execute().set_input_line(CK_INT, ASSERT_LINE ); } void gamecom_state::machine_reset() @@ -536,7 +536,7 @@ void gamecom_update_timers( device_t *device, int cycles ) DRIVER_INIT_MEMBER(gamecom_state,gamecom) { - m_clock_timer = machine().scheduler().timer_alloc(FUNC(gamecom_clock_timer_callback)); + m_clock_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gamecom_state::gamecom_clock_timer_callback),this)); m_p_ram = memregion("maincpu")->base(); // required here because pio_w gets called before machine_reset } diff --git a/src/mess/machine/gb.c b/src/mess/machine/gb.c index 34d10a6d08f..ba18534f6ac 100644 --- a/src/mess/machine/gb.c +++ b/src/mess/machine/gb.c @@ -80,7 +80,7 @@ enum { Prototypes */ -static TIMER_CALLBACK(gb_serial_timer_proc); + static void gb_machine_stop(running_machine &machine); @@ -250,7 +250,7 @@ MACHINE_START_MEMBER(gb_state,gb) machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(gb_machine_stop),&machine())); /* Allocate the serial timer, and disable it */ - m_gb_serial_timer = machine().scheduler().timer_alloc(FUNC(gb_serial_timer_proc)); + m_gb_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gb_state::gb_serial_timer_proc),this)); m_gb_serial_timer->enable( 0 ); MACHINE_START_CALL_MEMBER( gb_video ); @@ -261,7 +261,7 @@ MACHINE_START_MEMBER(gb_state,gbc) machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(gb_machine_stop),&machine())); /* Allocate the serial timer, and disable it */ - m_gb_serial_timer = machine().scheduler().timer_alloc(FUNC(gb_serial_timer_proc)); + m_gb_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gb_state::gb_serial_timer_proc),this)); m_gb_serial_timer->enable( 0 ); MACHINE_START_CALL_MEMBER( gbc_video ); @@ -291,7 +291,7 @@ MACHINE_START_MEMBER(gb_state,sgb) machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(gb_machine_stop),&machine())); /* Allocate the serial timer, and disable it */ - m_gb_serial_timer = machine().scheduler().timer_alloc(FUNC(gb_serial_timer_proc)); + m_gb_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gb_state::gb_serial_timer_proc),this)); m_gb_serial_timer->enable( 0 ); MACHINE_START_CALL_MEMBER( gb_video ); @@ -1896,19 +1896,18 @@ INTERRUPT_GEN_MEMBER(gb_state::gb_scanline_interrupt) { } -static TIMER_CALLBACK(gb_serial_timer_proc) +TIMER_CALLBACK_MEMBER(gb_state::gb_serial_timer_proc) { - gb_state *state = machine.driver_data<gb_state>(); /* Shift in a received bit */ - state->SIODATA = (state->SIODATA << 1) | 0x01; + SIODATA = (SIODATA << 1) | 0x01; /* Decrement number of handled bits */ - state->m_SIOCount--; + m_SIOCount--; /* If all bits done, stop timer and trigger interrupt */ - if ( ! state->m_SIOCount ) + if ( ! m_SIOCount ) { - state->SIOCONT &= 0x7F; - state->m_gb_serial_timer->enable( 0 ); - machine.device("maincpu")->execute().set_input_line(SIO_INT, ASSERT_LINE); + SIOCONT &= 0x7F; + m_gb_serial_timer->enable( 0 ); + machine().device("maincpu")->execute().set_input_line(SIO_INT, ASSERT_LINE); } } @@ -2017,7 +2016,7 @@ READ8_MEMBER(gb_state::gbc_io2_r) MACHINE_START_MEMBER(gb_state,megaduck) { /* Allocate the serial timer, and disable it */ - m_gb_serial_timer = machine().scheduler().timer_alloc(FUNC(gb_serial_timer_proc)); + m_gb_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gb_state::gb_serial_timer_proc),this)); m_gb_serial_timer->enable( 0 ); MACHINE_START_CALL_MEMBER( gb_video ); diff --git a/src/mess/machine/hec2hrp.c b/src/mess/machine/hec2hrp.c index e9c589de947..e00554b2d50 100644 --- a/src/mess/machine/hec2hrp.c +++ b/src/mess/machine/hec2hrp.c @@ -100,11 +100,10 @@ return ((strncmp(machine.system().name , "hec2mdhrx", 9)==0) || } /* Cassette timer*/ -static TIMER_CALLBACK( Callback_CK ) +TIMER_CALLBACK_MEMBER(hec2hrp_state::Callback_CK) { - hec2hrp_state *state = machine.driver_data<hec2hrp_state>(); /* To generate the CK signal (K7)*/ - state->m_CK_signal++; + m_CK_signal++; } void hector_minidisc_init(running_machine &machine) @@ -891,7 +890,7 @@ void hector_init(running_machine &machine) state->m_pot0 = state->m_pot1 = 0x40; /* For Cassette synchro*/ - state->m_Cassette_timer = machine.scheduler().timer_alloc(FUNC(Callback_CK)); + state->m_Cassette_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(hec2hrp_state::Callback_CK),state)); state->m_Cassette_timer->adjust(attotime::from_msec(100), 0, attotime::from_usec(64));/* => real synchro scan speed for 15,624Khz*/ /* Sound sn76477*/ diff --git a/src/mess/machine/hp48.c b/src/mess/machine/hp48.c index e7bd484c109..f2548951d2d 100644 --- a/src/mess/machine/hp48.c +++ b/src/mess/machine/hp48.c @@ -95,21 +95,20 @@ static void hp48_pulse_irq( running_machine &machine, int irq_line) #define RS232_DELAY attotime::from_usec( 300 ) /* end of receive event */ -static TIMER_CALLBACK( hp48_rs232_byte_recv_cb ) +TIMER_CALLBACK_MEMBER(hp48_state::hp48_rs232_byte_recv_cb) { - hp48_state *state = machine.driver_data<hp48_state>(); LOG_SERIAL(( "%f hp48_rs232_byte_recv_cb: end of receive, data=%02x\n", - machine.time().as_double(), param )); + machine().time().as_double(), param )); - state->m_io[0x14] = param & 0xf; /* receive zone */ - state->m_io[0x15] = param >> 4; - state->m_io[0x11] &= ~2; /* clear byte receiving */ - state->m_io[0x11] |= 1; /* set byte received */ + m_io[0x14] = param & 0xf; /* receive zone */ + m_io[0x15] = param >> 4; + m_io[0x11] &= ~2; /* clear byte receiving */ + m_io[0x11] |= 1; /* set byte received */ /* interrupt */ - if ( state->m_io[0x10] & 2 ) + if ( m_io[0x10] & 2 ) { - hp48_pulse_irq( machine, SATURN_IRQ_LINE ); + hp48_pulse_irq( machine(), SATURN_IRQ_LINE ); } } @@ -129,33 +128,32 @@ void hp48_rs232_start_recv_byte( running_machine &machine, UINT8 data ) } /* schedule end of reception */ - machine.scheduler().timer_set( RS232_DELAY, FUNC(hp48_rs232_byte_recv_cb), data); + machine.scheduler().timer_set( RS232_DELAY, timer_expired_delegate(FUNC(hp48_state::hp48_rs232_byte_recv_cb),state), data); } /* end of send event */ -static TIMER_CALLBACK( hp48_rs232_byte_sent_cb ) +TIMER_CALLBACK_MEMBER(hp48_state::hp48_rs232_byte_sent_cb) { - hp48_state *state = machine.driver_data<hp48_state>(); - //device_image_interface *xmodem = dynamic_cast<device_image_interface *>(machine.device("rs232_x")); - //device_image_interface *kermit = dynamic_cast<device_image_interface *>(machine.device("rs232_k")); + //device_image_interface *xmodem = dynamic_cast<device_image_interface *>(machine().device("rs232_x")); + //device_image_interface *kermit = dynamic_cast<device_image_interface *>(machine().device("rs232_k")); LOG_SERIAL(( "%f hp48_rs232_byte_sent_cb: end of send, data=%02x\n", - machine.time().as_double(), param )); + machine().time().as_double(), param )); - state->m_io[0x12] &= ~3; /* clear byte sending and buffer full */ + m_io[0x12] &= ~3; /* clear byte sending and buffer full */ /* interrupt */ - if ( state->m_io[0x10] & 4 ) + if ( m_io[0x10] & 4 ) { - hp48_pulse_irq( machine, SATURN_IRQ_LINE ); + hp48_pulse_irq( machine(), SATURN_IRQ_LINE ); } /* protocol action */ //if ( xmodem && xmodem->exists() ) xmodem_receive_byte( &xmodem->device(), param ); //else if ( kermit && kermit->exists() ) kermit_receive_byte( &kermit->device(), param ); //#ifdef CHARDEV -// else chardev_out( state->m_chardev, param ); +// else chardev_out( m_chardev, param ); //#endif } @@ -172,29 +170,28 @@ static void hp48_rs232_send_byte( running_machine &machine ) state->m_io[0x12] |= 3; /* schedule transmission */ - machine.scheduler().timer_set( RS232_DELAY, FUNC(hp48_rs232_byte_sent_cb), data); + machine.scheduler().timer_set( RS232_DELAY, timer_expired_delegate(FUNC(hp48_state::hp48_rs232_byte_sent_cb),state), data); } #ifdef CHARDEV -static TIMER_CALLBACK( hp48_chardev_byte_recv_cb ) +TIMER_CALLBACK_MEMBER(hp48_state::hp48_chardev_byte_recv_cb) { - hp48_state *state = machine.driver_data<hp48_state>(); - UINT8 data = chardev_in( state->m_chardev ); + UINT8 data = chardev_in( m_chardev ); LOG_SERIAL(( "%f hp48_chardev_byte_recv_cb: end of receive, data=%02x\n", - machine.time().as_double(), data )); + machine().time().as_double(), data )); - state->m_io[0x14] = data & 0xf; /* receive zone */ - state->m_io[0x15] = data >> 4; - state->m_io[0x11] &= ~2; /* clear byte receiving */ - state->m_io[0x11] |= 1; /* set byte received */ + m_io[0x14] = data & 0xf; /* receive zone */ + m_io[0x15] = data >> 4; + m_io[0x11] &= ~2; /* clear byte receiving */ + m_io[0x11] |= 1; /* set byte received */ /* interrupt */ - if ( state->m_io[0x10] & 2 ) + if ( m_io[0x10] & 2 ) { - hp48_pulse_irq( machine, SATURN_IRQ_LINE ); + hp48_pulse_irq( machine(), SATURN_IRQ_LINE ); } } @@ -215,7 +212,7 @@ static void hp48_chardev_start_recv_byte( running_machine &machine, chardev_err } /* schedule end of reception */ - machine.scheduler().timer_set( RS232_DELAY, FUNC(hp48_chardev_byte_recv_cb)); + machine.scheduler().timer_set( RS232_DELAY, timer_expired_delegate(FUNC(hp48_state::hp48_chardev_byte_recv_cb),this)); } static void hp48_chardev_ready_to_send( running_machine &machine ) @@ -305,22 +302,21 @@ static void hp48_update_kdn( running_machine &machine ) } /* periodic keyboard polling, generates an interrupt */ -static TIMER_CALLBACK( hp48_kbd_cb ) +TIMER_CALLBACK_MEMBER(hp48_state::hp48_kbd_cb) { - hp48_state *state = machine.driver_data<hp48_state>(); /* NMI for ON key */ - if ( machine.root_device().ioport( "ON" )->read() ) + if ( machine().root_device().ioport( "ON" )->read() ) { LOG(( "%f hp48_kbd_cb: keyboard interrupt, on key\n", - machine.time().as_double() )); - state->m_io[0x19] |= 8; /* set service request */ - hp48_pulse_irq( machine, SATURN_WAKEUP_LINE ); - hp48_pulse_irq( machine, SATURN_NMI_LINE ); + machine().time().as_double() )); + m_io[0x19] |= 8; /* set service request */ + hp48_pulse_irq( machine(), SATURN_WAKEUP_LINE ); + hp48_pulse_irq( machine(), SATURN_NMI_LINE ); return; } /* regular keys */ - hp48_update_kdn( machine ); + hp48_update_kdn( machine() ); } /* RSI opcode */ @@ -611,53 +607,51 @@ READ8_MEMBER(hp48_state::hp48_bank_r) /* ---------------- timers --------------- */ -static TIMER_CALLBACK( hp48_timer1_cb ) +TIMER_CALLBACK_MEMBER(hp48_state::hp48_timer1_cb) { - hp48_state *state = machine.driver_data<hp48_state>(); - if ( !(state->m_io[0x2f] & 1) ) return; /* timer enable */ + if ( !(m_io[0x2f] & 1) ) return; /* timer enable */ - state->m_timer1 = (state->m_timer1 - 1) & 0xf; + m_timer1 = (m_timer1 - 1) & 0xf; /* wake-up on carry */ - if ( (state->m_io[0x2e] & 4) && (state->m_timer1 == 0xf) ) + if ( (m_io[0x2e] & 4) && (m_timer1 == 0xf) ) { LOG(( "wake-up on timer1\n" )); - state->m_io[0x2e] |= 8; /* set service request */ - state->m_io[0x18] |= 4; /* set service request */ - hp48_pulse_irq( machine, SATURN_WAKEUP_LINE ); + m_io[0x2e] |= 8; /* set service request */ + m_io[0x18] |= 4; /* set service request */ + hp48_pulse_irq( machine(), SATURN_WAKEUP_LINE ); } /* interrupt on carry */ - if ( (state->m_io[0x2e] & 2) && (state->m_timer1 == 0xf) ) + if ( (m_io[0x2e] & 2) && (m_timer1 == 0xf) ) { LOG(( "generate timer1 interrupt\n" )); - state->m_io[0x2e] |= 8; /* set service request */ - state->m_io[0x18] |= 4; /* set service request */ - hp48_pulse_irq( machine, SATURN_NMI_LINE ); + m_io[0x2e] |= 8; /* set service request */ + m_io[0x18] |= 4; /* set service request */ + hp48_pulse_irq( machine(), SATURN_NMI_LINE ); } } -static TIMER_CALLBACK( hp48_timer2_cb ) +TIMER_CALLBACK_MEMBER(hp48_state::hp48_timer2_cb) { - hp48_state *state = machine.driver_data<hp48_state>(); - if ( !(state->m_io[0x2f] & 1) ) return; /* timer enable */ + if ( !(m_io[0x2f] & 1) ) return; /* timer enable */ - state->m_timer2 = (state->m_timer2 - 1) & 0xffffffff; + m_timer2 = (m_timer2 - 1) & 0xffffffff; /* wake-up on carry */ - if ( (state->m_io[0x2f] & 4) && (state->m_timer2 == 0xffffffff) ) + if ( (m_io[0x2f] & 4) && (m_timer2 == 0xffffffff) ) { LOG(( "wake-up on timer2\n" )); - state->m_io[0x2f] |= 8; /* set service request */ - state->m_io[0x18] |= 4; /* set service request */ - hp48_pulse_irq( machine, SATURN_WAKEUP_LINE ); + m_io[0x2f] |= 8; /* set service request */ + m_io[0x18] |= 4; /* set service request */ + hp48_pulse_irq( machine(), SATURN_WAKEUP_LINE ); } /* interrupt on carry */ - if ( (state->m_io[0x2f] & 2) && (state->m_timer2 == 0xffffffff) ) + if ( (m_io[0x2f] & 2) && (m_timer2 == 0xffffffff) ) { LOG(( "generate timer2 interrupt\n" )); - state->m_io[0x2f] |= 8; /* set service request */ - state->m_io[0x18] |= 4; /* set service request */ - hp48_pulse_irq( machine, SATURN_NMI_LINE ); + m_io[0x2f] |= 8; /* set service request */ + m_io[0x18] |= 4; /* set service request */ + hp48_pulse_irq( machine(), SATURN_NMI_LINE ); } } @@ -1171,11 +1165,11 @@ void hp48_state::hp48_machine_start( hp48_models model ) m_modules[5].data = rom; /* timers */ - machine().scheduler().timer_pulse(attotime::from_hz( 16 ), FUNC(hp48_timer1_cb)); - machine().scheduler().timer_pulse(attotime::from_hz( 8192 ), FUNC(hp48_timer2_cb)); + machine().scheduler().timer_pulse(attotime::from_hz( 16 ), timer_expired_delegate(FUNC(hp48_state::hp48_timer1_cb),this)); + machine().scheduler().timer_pulse(attotime::from_hz( 8192 ), timer_expired_delegate(FUNC(hp48_state::hp48_timer2_cb),this)); /* 1ms keyboard polling */ - machine().scheduler().timer_pulse(attotime::from_msec( 1 ), FUNC(hp48_kbd_cb)); + machine().scheduler().timer_pulse(attotime::from_msec( 1 ), timer_expired_delegate(FUNC(hp48_state::hp48_kbd_cb),this)); /* save state */ save_item(NAME(m_out) ); diff --git a/src/mess/machine/intv.c b/src/mess/machine/intv.c index a355a1fc6b4..2a455159b91 100644 --- a/src/mess/machine/intv.c +++ b/src/mess/machine/intv.c @@ -650,25 +650,23 @@ MACHINE_RESET_MEMBER(intv_state,intvecs) } -static TIMER_CALLBACK(intv_interrupt_complete) +TIMER_CALLBACK_MEMBER(intv_state::intv_interrupt_complete) { - intv_state *state = machine.driver_data<intv_state>(); - machine.device("maincpu")->execute().set_input_line(CP1610_INT_INTRM, CLEAR_LINE); - state->m_bus_copy_mode = 0; + machine().device("maincpu")->execute().set_input_line(CP1610_INT_INTRM, CLEAR_LINE); + m_bus_copy_mode = 0; } -static TIMER_CALLBACK(intv_btb_fill) +TIMER_CALLBACK_MEMBER(intv_state::intv_btb_fill) { - intv_state *state = machine.driver_data<intv_state>(); UINT8 column; - UINT8 row = state->m_backtab_row; - //machine.device("maincpu")->execute().adjust_icount(-STIC_ROW_FETCH); + UINT8 row = m_backtab_row; + //machine().device("maincpu")->execute().adjust_icount(-STIC_ROW_FETCH); for(column=0; column < STIC_BACKTAB_WIDTH; column++) { - state->m_backtab_buffer[row][column] = state->m_ram16[column + row * STIC_BACKTAB_WIDTH]; + m_backtab_buffer[row][column] = m_ram16[column + row * STIC_BACKTAB_WIDTH]; } - state->m_backtab_row += 1; + m_backtab_row += 1; } INTERRUPT_GEN_MEMBER(intv_state::intv_interrupt) @@ -680,11 +678,11 @@ INTERRUPT_GEN_MEMBER(intv_state::intv_interrupt) UINT8 row; machine().device("maincpu")->execute().adjust_icount(-(12*STIC_ROW_BUSRQ+STIC_FRAME_BUSRQ)); // Account for stic cycle stealing machine().scheduler().timer_set(machine().device<cpu_device>("maincpu") - ->cycles_to_attotime(STIC_VBLANK_END), FUNC(intv_interrupt_complete)); + ->cycles_to_attotime(STIC_VBLANK_END), timer_expired_delegate(FUNC(intv_state::intv_interrupt_complete),this)); for (row=0; row < STIC_BACKTAB_HEIGHT; row++) { machine().scheduler().timer_set(machine().device<cpu_device>("maincpu") - ->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)); + ->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)); } if (m_row_delay == 0) diff --git a/src/mess/machine/irisha.c b/src/mess/machine/irisha.c index e83e558da24..c1ad27efdf0 100644 --- a/src/mess/machine/irisha.c +++ b/src/mess/machine/irisha.c @@ -18,16 +18,15 @@ DRIVER_INIT_MEMBER(irisha_state,irisha) -static TIMER_CALLBACK( irisha_key ) +TIMER_CALLBACK_MEMBER(irisha_state::irisha_key) { - irisha_state *state = machine.driver_data<irisha_state>(); - state->m_keypressed = 1; - state->m_keyboard_cnt = 0; + m_keypressed = 1; + m_keyboard_cnt = 0; } void irisha_state::machine_start() { - machine().scheduler().timer_pulse(attotime::from_msec(30), FUNC(irisha_key)); + machine().scheduler().timer_pulse(attotime::from_msec(30), timer_expired_delegate(FUNC(irisha_state::irisha_key),this)); } void irisha_state::machine_reset() diff --git a/src/mess/machine/kaypro.c b/src/mess/machine/kaypro.c index a60b37b77ff..4f75ec0ec8b 100644 --- a/src/mess/machine/kaypro.c +++ b/src/mess/machine/kaypro.c @@ -278,16 +278,16 @@ WRITE8_DEVICE_HANDLER( kaypro_sio_w ) *************************************************************************************/ -static TIMER_CALLBACK( kaypro_timer_callback ) +TIMER_CALLBACK_MEMBER(kaypro_state::kaypro_timer_callback) { - if (machine.device("maincpu")->state().state_int(Z80_HALT)) - machine.device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, ASSERT_LINE); + if (machine().device("maincpu")->state().state_int(Z80_HALT)) + machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, ASSERT_LINE); } WRITE_LINE_MEMBER( kaypro_state::kaypro_fdc_intrq_w ) { if (state) - machine().scheduler().timer_set(attotime::from_usec(25), FUNC(kaypro_timer_callback)); + machine().scheduler().timer_set(attotime::from_usec(25), timer_expired_delegate(FUNC(kaypro_state::kaypro_timer_callback),this)); else machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, CLEAR_LINE); } @@ -295,7 +295,7 @@ WRITE_LINE_MEMBER( kaypro_state::kaypro_fdc_intrq_w ) WRITE_LINE_MEMBER( kaypro_state::kaypro_fdc_drq_w ) { if (state) - machine().scheduler().timer_set(attotime::from_usec(25), FUNC(kaypro_timer_callback)); + machine().scheduler().timer_set(attotime::from_usec(25), timer_expired_delegate(FUNC(kaypro_state::kaypro_timer_callback),this)); else machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, CLEAR_LINE); diff --git a/src/mess/machine/kc.c b/src/mess/machine/kc.c index b683b9b8355..f2aedb7fe0d 100644 --- a/src/mess/machine/kc.c +++ b/src/mess/machine/kc.c @@ -210,30 +210,28 @@ void kc_state::update_cassette(int state) } } -static TIMER_CALLBACK(kc_cassette_oneshot_timer) +TIMER_CALLBACK_MEMBER(kc_state::kc_cassette_oneshot_timer) { - kc_state *state = machine.driver_data<kc_state>(); - state->update_cassette(0); + update_cassette(0); - state->m_cassette_oneshot_timer->reset(); + m_cassette_oneshot_timer->reset(); } // timer used for polling data from cassette input // enabled only when cassette motor is on -static TIMER_CALLBACK(kc_cassette_timer_callback) +TIMER_CALLBACK_MEMBER(kc_state::kc_cassette_timer_callback) { - kc_state *state = machine.driver_data<kc_state>(); // read cassette data - int bit = (state->m_cassette->input() > 0.0038) ? 1 : 0; + int bit = (m_cassette->input() > 0.0038) ? 1 : 0; // generates a pulse when the cassette input changes state - if (bit ^ state->m_cassette_in) + if (bit ^ m_cassette_in) { - state->update_cassette(1); - state->m_cassette_in = bit; - state->m_cassette_oneshot_timer->adjust(attotime::from_double(TIME_OF_74LS123(RES_K(10), CAP_N(1)))); + update_cassette(1); + m_cassette_in = bit; + m_cassette_oneshot_timer->adjust(attotime::from_double(TIME_OF_74LS123(RES_K(10), CAP_N(1)))); } } @@ -759,8 +757,8 @@ WRITE_LINE_MEMBER( kc_state::keyboard_cb ) void kc_state::machine_start() { - m_cassette_timer = machine().scheduler().timer_alloc(FUNC(kc_cassette_timer_callback)); - m_cassette_oneshot_timer = machine().scheduler().timer_alloc(FUNC(kc_cassette_oneshot_timer)); + m_cassette_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(kc_state::kc_cassette_timer_callback),this)); + m_cassette_oneshot_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(kc_state::kc_cassette_oneshot_timer),this)); m_ram_base = m_ram->pointer(); diff --git a/src/mess/machine/lisa.c b/src/mess/machine/lisa.c index 47f93882f90..02187e9c095 100644 --- a/src/mess/machine/lisa.c +++ b/src/mess/machine/lisa.c @@ -340,24 +340,23 @@ static void scan_keyboard(running_machine &machine) /* handle mouse moves */ /* shamelessly stolen from machine/mac.c :-) */ -static TIMER_CALLBACK(handle_mouse) +TIMER_CALLBACK_MEMBER(lisa_state::handle_mouse) { - lisa_state *state = machine.driver_data<lisa_state>(); int diff_x = 0, diff_y = 0; int new_mx, new_my; #if 0 - if (state->m_COPS_force_unplug) + if (m_COPS_force_unplug) return; /* ???? */ #endif - new_mx = machine.root_device().ioport("MOUSE_X")->read(); - new_my = machine.root_device().ioport("MOUSE_Y")->read(); + new_mx = machine().root_device().ioport("MOUSE_X")->read(); + new_my = machine().root_device().ioport("MOUSE_Y")->read(); /* see if it moved in the x coord */ - if (new_mx != state->m_last_mx) + if (new_mx != m_last_mx) { - diff_x = new_mx - state->m_last_mx; + diff_x = new_mx - m_last_mx; /* check for wrap */ if (diff_x > 0x80) @@ -365,12 +364,12 @@ static TIMER_CALLBACK(handle_mouse) if (diff_x < -0x80) diff_x = -0x100-diff_x; - state->m_last_mx = new_mx; + m_last_mx = new_mx; } /* see if it moved in the y coord */ - if (new_my != state->m_last_my) + if (new_my != m_last_my) { - diff_y = new_my - state->m_last_my; + diff_y = new_my - m_last_my; /* check for wrap */ if (diff_y > 0x80) @@ -378,43 +377,43 @@ static TIMER_CALLBACK(handle_mouse) if (diff_y < -0x80) diff_y = -0x100-diff_y; - state->m_last_my = new_my; + m_last_my = new_my; } /* update any remaining count and then return */ if (diff_x || diff_y) { - if (state->m_mouse_data_offset != -1) + if (m_mouse_data_offset != -1) { - state->m_fifo_data[state->m_mouse_data_offset] += diff_x; - state->m_fifo_data[(state->m_mouse_data_offset+1) & 0x7] += diff_y; + m_fifo_data[m_mouse_data_offset] += diff_x; + m_fifo_data[(m_mouse_data_offset+1) & 0x7] += diff_y; } else { #if 0 - if (state->m_fifo_size <= 5) + if (m_fifo_size <= 5) #else /* trash old data */ - while (state->m_fifo_size > 5) + while (m_fifo_size > 5) { - state->m_fifo_head = (state->m_fifo_head+1) & 0x7; - state->m_fifo_size--; + m_fifo_head = (m_fifo_head+1) & 0x7; + m_fifo_size--; } #endif { /*logerror("Adding 3 bytes of mouse data to FIFO\n");*/ - state->m_fifo_data[state->m_fifo_tail] = 0; - state->m_mouse_data_offset = state->m_fifo_tail = (state->m_fifo_tail+1) & 0x7; - state->m_fifo_data[state->m_fifo_tail] = diff_x; - state->m_fifo_tail = (state->m_fifo_tail+1) & 0x7; - state->m_fifo_data[state->m_fifo_tail] = diff_y; - state->m_fifo_tail = (state->m_fifo_tail+1) & 0x7; - state->m_fifo_size += 3; + m_fifo_data[m_fifo_tail] = 0; + m_mouse_data_offset = m_fifo_tail = (m_fifo_tail+1) & 0x7; + m_fifo_data[m_fifo_tail] = diff_x; + m_fifo_tail = (m_fifo_tail+1) & 0x7; + m_fifo_data[m_fifo_tail] = diff_y; + m_fifo_tail = (m_fifo_tail+1) & 0x7; + m_fifo_size += 3; /*logerror("handle_mouse : trying to send data to VIA\n");*/ - COPS_send_data_if_possible(machine); + COPS_send_data_if_possible(machine()); } /* else, mouse data is lost forever (correct ??) */ } @@ -422,20 +421,19 @@ static TIMER_CALLBACK(handle_mouse) } /* read command from the VIA port A */ -static TIMER_CALLBACK(read_COPS_command) +TIMER_CALLBACK_MEMBER(lisa_state::read_COPS_command) { - lisa_state *state = machine.driver_data<lisa_state>(); int command; - via6522_device *via_0 = machine.device<via6522_device>("via6522_0"); - address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); + via6522_device *via_0 = machine().device<via6522_device>("via6522_0"); + address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); - state->m_COPS_Ready = 0; + m_COPS_Ready = 0; /*logerror("read_COPS_command : trying to send data to VIA\n");*/ - COPS_send_data_if_possible(machine); + COPS_send_data_if_possible(machine()); /* some pull-ups allow the COPS to read 1s when the VIA port is not set as output */ - command = (state->m_COPS_command | (~ via_0->read(space, VIA_DDRA))) & 0xff; + command = (m_COPS_command | (~ via_0->read(space, VIA_DDRA))) & 0xff; // printf("Dropping Ready, command = %02x\n", command); @@ -449,9 +447,9 @@ static TIMER_CALLBACK(read_COPS_command) switch ((command & 0xF0) >> 4) { case 0x1: /* write clock data */ - if (state->m_clock_regs.clock_write_ptr != -1) + if (m_clock_regs.clock_write_ptr != -1) { - switch (state->m_clock_regs.clock_write_ptr) + switch (m_clock_regs.clock_write_ptr) { case 0: case 1: @@ -459,57 +457,57 @@ static TIMER_CALLBACK(read_COPS_command) case 3: case 4: /* alarm */ - state->m_clock_regs.alarm &= ~ (0xf << (4 * (4 - state->m_clock_regs.clock_write_ptr))); - state->m_clock_regs.alarm |= immediate << (4 * (4 - state->m_clock_regs.clock_write_ptr)); + m_clock_regs.alarm &= ~ (0xf << (4 * (4 - m_clock_regs.clock_write_ptr))); + m_clock_regs.alarm |= immediate << (4 * (4 - m_clock_regs.clock_write_ptr)); break; case 5: /* year */ - state->m_clock_regs.years = immediate; + m_clock_regs.years = immediate; break; case 6: /* day */ - state->m_clock_regs.days1 = immediate; + m_clock_regs.days1 = immediate; break; case 7: /* day */ - state->m_clock_regs.days2 = immediate; + m_clock_regs.days2 = immediate; break; case 8: /* day */ - state->m_clock_regs.days3 = immediate; + m_clock_regs.days3 = immediate; break; case 9: /* hours */ - state->m_clock_regs.hours1 = immediate; + m_clock_regs.hours1 = immediate; break; case 10: /* hours */ - state->m_clock_regs.hours2 = immediate; + m_clock_regs.hours2 = immediate; break; case 11: /* minutes */ - state->m_clock_regs.minutes1 = immediate; + m_clock_regs.minutes1 = immediate; break; case 12: /* minutes */ - state->m_clock_regs.minutes1 = immediate; + m_clock_regs.minutes1 = immediate; break; case 13: /* seconds */ - state->m_clock_regs.seconds1 = immediate; + m_clock_regs.seconds1 = immediate; break; case 14: /* seconds */ - state->m_clock_regs.seconds2 = immediate; + m_clock_regs.seconds2 = immediate; break; case 15: /* tenth */ - state->m_clock_regs.tenths = immediate; + m_clock_regs.tenths = immediate; break; } - state->m_clock_regs.clock_write_ptr++; - if (state->m_clock_regs.clock_write_ptr == 16) - state->m_clock_regs.clock_write_ptr = -1; + m_clock_regs.clock_write_ptr++; + if (m_clock_regs.clock_write_ptr == 16) + m_clock_regs.clock_write_ptr = -1; } break; @@ -517,11 +515,11 @@ static TIMER_CALLBACK(read_COPS_command) case 0x2: /* set clock mode */ if (immediate & 0x8) { /* start setting the clock */ - state->m_clock_regs.clock_write_ptr = 0; + m_clock_regs.clock_write_ptr = 0; } else { /* clock write disabled */ - state->m_clock_regs.clock_write_ptr = -1; + m_clock_regs.clock_write_ptr = -1; } if (! (immediate & 0x4)) @@ -533,7 +531,7 @@ static TIMER_CALLBACK(read_COPS_command) /* should never happen */ } - state->m_clock_regs.clock_mode = (clock_mode_t)(immediate & 0x3); + m_clock_regs.clock_mode = (clock_mode_t)(immediate & 0x3); break; #if 0 @@ -548,18 +546,18 @@ static TIMER_CALLBACK(read_COPS_command) #endif case 0x5: /* set high nibble of NMI character to nnnn */ - state->m_NMIcode = (state->m_NMIcode & 0x0f) | (immediate << 4); + m_NMIcode = (m_NMIcode & 0x0f) | (immediate << 4); break; case 0x6: /* set low nibble of NMI character to nnnn */ - state->m_NMIcode = (state->m_NMIcode & 0xf0) | immediate; + m_NMIcode = (m_NMIcode & 0xf0) | immediate; break; case 0x7: /* send mouse command */ if (immediate & 0x8) - state->m_mouse_timer->adjust(attotime::zero, 0, attotime::from_msec((immediate & 0x7)*4)); /* enable mouse */ + m_mouse_timer->adjust(attotime::zero, 0, attotime::from_msec((immediate & 0x7)*4)); /* enable mouse */ else - state->m_mouse_timer->reset(); + m_mouse_timer->reset(); break; } } @@ -582,14 +580,14 @@ static TIMER_CALLBACK(read_COPS_command) UINT8 reply[7]; reply[0] = 0x80; - reply[1] = 0xE0 | state->m_clock_regs.years; - reply[2] = (state->m_clock_regs.days1 << 4) | state->m_clock_regs.days2; - reply[3] = (state->m_clock_regs.days3 << 4) | state->m_clock_regs.hours1; - reply[4] = (state->m_clock_regs.hours2 << 4) | state->m_clock_regs.minutes1; - reply[5] = (state->m_clock_regs.minutes2 << 4) | state->m_clock_regs.seconds1; - reply[6] = (state->m_clock_regs.seconds2 << 4) | state->m_clock_regs.tenths; - - COPS_queue_data(machine, reply, 7); + reply[1] = 0xE0 | m_clock_regs.years; + reply[2] = (m_clock_regs.days1 << 4) | m_clock_regs.days2; + reply[3] = (m_clock_regs.days3 << 4) | m_clock_regs.hours1; + reply[4] = (m_clock_regs.hours2 << 4) | m_clock_regs.minutes1; + reply[5] = (m_clock_regs.minutes2 << 4) | m_clock_regs.seconds1; + reply[6] = (m_clock_regs.seconds2 << 4) | m_clock_regs.tenths; + + COPS_queue_data(machine(), reply, 7); } break; } @@ -597,13 +595,12 @@ static TIMER_CALLBACK(read_COPS_command) } /* this timer callback raises the COPS Ready line, which tells the COPS is about to read a command */ -static TIMER_CALLBACK(set_COPS_ready) +TIMER_CALLBACK_MEMBER(lisa_state::set_COPS_ready) { - lisa_state *state = machine.driver_data<lisa_state>(); - state->m_COPS_Ready = 1; + m_COPS_Ready = 1; /* impulsion width : +/- 20us */ - machine.scheduler().timer_set(attotime::from_usec(20), FUNC(read_COPS_command)); + machine().scheduler().timer_set(attotime::from_usec(20), timer_expired_delegate(FUNC(lisa_state::read_COPS_command),this)); } static void reset_COPS(lisa_state *state) @@ -1031,10 +1028,10 @@ DRIVER_INIT_MEMBER(lisa_state,mac_xl) void lisa_state::machine_start() { - m_mouse_timer = machine().scheduler().timer_alloc(FUNC(handle_mouse)); + m_mouse_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(lisa_state::handle_mouse),this)); /* read command every ms (don't know the real value) */ - machine().scheduler().timer_pulse(attotime::from_msec(1), FUNC(set_COPS_ready)); + machine().scheduler().timer_pulse(attotime::from_msec(1), timer_expired_delegate(FUNC(lisa_state::set_COPS_ready),this)); } void lisa_state::machine_reset() diff --git a/src/mess/machine/lviv.c b/src/mess/machine/lviv.c index 3bbb7f2f6f5..e0131555e78 100644 --- a/src/mess/machine/lviv.c +++ b/src/mess/machine/lviv.c @@ -41,15 +41,15 @@ static void lviv_update_memory (running_machine &machine) } } -static TIMER_CALLBACK( lviv_reset ) +TIMER_CALLBACK_MEMBER(lviv_state::lviv_reset) { - machine.schedule_soft_reset(); + machine().schedule_soft_reset(); } DIRECT_UPDATE_MEMBER(lviv_state::lviv_directoverride) { if (ioport("RESET")->read() & 0x01) - machine().scheduler().timer_set(attotime::from_usec(10), FUNC(lviv_reset)); + machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(lviv_state::lviv_reset),this)); return address; } diff --git a/src/mess/machine/lynx.c b/src/mess/machine/lynx.c index 8c0d4d3f918..c94d1b8ea53 100644 --- a/src/mess/machine/lynx.c +++ b/src/mess/machine/lynx.c @@ -600,11 +600,10 @@ static void lynx_blit_lines(lynx_state *state) } } -static TIMER_CALLBACK(lynx_blitter_timer) +TIMER_CALLBACK_MEMBER(lynx_state::lynx_blitter_timer) { - lynx_state *state = machine.driver_data<lynx_state>(); - state->m_blitter.busy=0; // blitter finished - machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE); + m_blitter.busy=0; // blitter finished + machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE); } /* @@ -805,7 +804,7 @@ static void lynx_blitter(running_machine &machine) } } - machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(state->m_blitter.memory_accesses), FUNC(lynx_blitter_timer)); + 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)); } @@ -1394,13 +1393,13 @@ TIM_BORROWOUT EQU %00000001 #define NR_LYNX_TIMERS 8 -static TIMER_CALLBACK(lynx_timer_shot); + static void lynx_timer_init(running_machine &machine, int which) { lynx_state *state = machine.driver_data<lynx_state>(); memset( &state->m_timer[which], 0, sizeof(LYNX_TIMER) ); - state->m_timer[which].timer = machine.scheduler().timer_alloc(FUNC(lynx_timer_shot)); + state->m_timer[which].timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(lynx_state::lynx_timer_shot),state)); } static void lynx_timer_signal_irq(running_machine &machine, int which) @@ -1506,19 +1505,18 @@ static UINT32 lynx_time_factor(int val) } } -static TIMER_CALLBACK(lynx_timer_shot) +TIMER_CALLBACK_MEMBER(lynx_state::lynx_timer_shot) { - lynx_state *state = machine.driver_data<lynx_state>(); - lynx_timer_signal_irq( machine, param ); - if ( ! ( state->m_timer[param].cntrl1 & 0x10 ) ) // if reload not enabled + lynx_timer_signal_irq( machine(), param ); + if ( ! ( m_timer[param].cntrl1 & 0x10 ) ) // if reload not enabled { - state->m_timer[param].timer_active = 0; - state->m_timer[param].cntrl2 |= 8; // set timer done + m_timer[param].timer_active = 0; + m_timer[param].cntrl2 |= 8; // set timer done } else { - attotime t = (attotime::from_hz(lynx_time_factor(state->m_timer[param].cntrl1 & 0x07)) * (state->m_timer[param].bakup + 1)); - state->m_timer[param].timer->adjust(t, param); + attotime t = (attotime::from_hz(lynx_time_factor(m_timer[param].cntrl1 & 0x07)) * (m_timer[param].bakup + 1)); + m_timer[param].timer->adjust(t, param); } } @@ -1616,40 +1614,38 @@ static void lynx_uart_reset(lynx_state *state) memset(&state->m_uart, 0, sizeof(state->m_uart)); } -static TIMER_CALLBACK(lynx_uart_loopback_timer) +TIMER_CALLBACK_MEMBER(lynx_state::lynx_uart_loopback_timer) { - lynx_state *state = machine.driver_data<lynx_state>(); - state->m_uart.received = FALSE; + m_uart.received = FALSE; } -static TIMER_CALLBACK(lynx_uart_timer) +TIMER_CALLBACK_MEMBER(lynx_state::lynx_uart_timer) { - lynx_state *state = machine.driver_data<lynx_state>(); - if (state->m_uart.buffer_loaded) + if (m_uart.buffer_loaded) { - state->m_uart.data_to_send = state->m_uart.buffer; - state->m_uart.buffer_loaded = FALSE; - machine.scheduler().timer_set(attotime::from_usec(11*16), FUNC(lynx_uart_timer)); + m_uart.data_to_send = m_uart.buffer; + m_uart.buffer_loaded = FALSE; + machine().scheduler().timer_set(attotime::from_usec(11*16), timer_expired_delegate(FUNC(lynx_state::lynx_uart_timer),this)); } else { - state->m_uart.sending = FALSE; - state->m_uart.received = TRUE; - state->m_uart.data_received = state->m_uart.data_to_send; - machine.scheduler().timer_set(attotime::from_usec(11*16), FUNC(lynx_uart_loopback_timer)); - if (state->m_uart.serctl & 0x40) + m_uart.sending = FALSE; + m_uart.received = TRUE; + m_uart.data_received = m_uart.data_to_send; + machine().scheduler().timer_set(attotime::from_usec(11*16), timer_expired_delegate(FUNC(lynx_state::lynx_uart_loopback_timer),this)); + if (m_uart.serctl & 0x40) { - state->m_mikey.data[0x81] |= 0x10; - machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE); - machine.device("maincpu")->execute().set_input_line(M65SC02_IRQ_LINE, ASSERT_LINE); + m_mikey.data[0x81] |= 0x10; + machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE); + machine().device("maincpu")->execute().set_input_line(M65SC02_IRQ_LINE, ASSERT_LINE); } } - if (state->m_uart.serctl & 0x80) + if (m_uart.serctl & 0x80) { - state->m_mikey.data[0x81] |= 0x10; - machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE); - machine.device("maincpu")->execute().set_input_line(M65SC02_IRQ_LINE, ASSERT_LINE); + m_mikey.data[0x81] |= 0x10; + machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE); + machine().device("maincpu")->execute().set_input_line(M65SC02_IRQ_LINE, ASSERT_LINE); } } @@ -1696,7 +1692,7 @@ WRITE8_MEMBER(lynx_state::lynx_uart_w) m_uart.sending = TRUE; m_uart.data_to_send = data; // timing not accurate, baude rate should be calculated from timer 4 backup value and clock rate - machine().scheduler().timer_set(attotime::from_usec(11*16), FUNC(lynx_uart_timer)); + machine().scheduler().timer_set(attotime::from_usec(11*16), timer_expired_delegate(FUNC(lynx_state::lynx_uart_timer),this)); } break; } diff --git a/src/mess/machine/mac.c b/src/mess/machine/mac.c index c8be804ce16..10d918af75b 100644 --- a/src/mess/machine/mac.c +++ b/src/mess/machine/mac.c @@ -127,10 +127,10 @@ extern TIMER_CALLBACK(mac_adb_tick); // macadb.c extern TIMER_CALLBACK(mac_pmu_tick); // macadb.c -static TIMER_CALLBACK(mac_scanline_tick); -static TIMER_CALLBACK(mac_6015_tick); + + static int scan_keyboard(running_machine &machine); -static TIMER_CALLBACK(inquiry_timeout_func); + static void keyboard_receive(running_machine &machine, int val); static DECLARE_READ8_DEVICE_HANDLER(mac_via_in_a); static DECLARE_READ8_DEVICE_HANDLER(mac_via_in_b); @@ -695,32 +695,31 @@ static void keyboard_init(mac_state *mac) /******************* Keyboard <-> VIA communication ***********************/ -static TIMER_CALLBACK(kbd_clock) +TIMER_CALLBACK_MEMBER(mac_state::kbd_clock) { int i; - mac_state *mac = machine.driver_data<mac_state>(); - if (mac->m_kbd_comm == TRUE) + if (m_kbd_comm == TRUE) { for (i=0; i<8; i++) { /* Put data on CB2 if we are sending*/ - if (mac->m_kbd_receive == FALSE) - mac->m_via1->write_cb2(mac->m_kbd_shift_reg&0x80?1:0); - mac->m_kbd_shift_reg <<= 1; - mac->m_via1->write_cb1(0); - mac->m_via1->write_cb1(1); + if (m_kbd_receive == FALSE) + m_via1->write_cb2(m_kbd_shift_reg&0x80?1:0); + m_kbd_shift_reg <<= 1; + m_via1->write_cb1(0); + m_via1->write_cb1(1); } - if (mac->m_kbd_receive == TRUE) + if (m_kbd_receive == TRUE) { - mac->m_kbd_receive = FALSE; + m_kbd_receive = FALSE; /* Process the command received from mac */ - keyboard_receive(machine, mac->m_kbd_shift_reg & 0xff); + keyboard_receive(machine(), m_kbd_shift_reg & 0xff); } else { /* Communication is over */ - mac->m_kbd_comm = FALSE; + m_kbd_comm = FALSE; } } } @@ -732,7 +731,7 @@ static void kbd_shift_out(running_machine &machine, int data) if (mac->m_kbd_comm == TRUE) { mac->m_kbd_shift_reg = data; - machine.scheduler().timer_set(attotime::from_msec(1), FUNC(kbd_clock)); + machine.scheduler().timer_set(attotime::from_msec(1), timer_expired_delegate(FUNC(mac_state::kbd_clock),mac)); } } @@ -745,7 +744,7 @@ static WRITE8_DEVICE_HANDLER(mac_via_out_cb2) /* Mac pulls CB2 down to initiate communication */ mac->m_kbd_comm = TRUE; mac->m_kbd_receive = TRUE; - space.machine().scheduler().timer_set(attotime::from_usec(100), FUNC(kbd_clock)); + space.machine().scheduler().timer_set(attotime::from_usec(100), timer_expired_delegate(FUNC(mac_state::kbd_clock),mac)); } if (mac->m_kbd_comm == TRUE && mac->m_kbd_receive == TRUE) { @@ -757,11 +756,11 @@ static WRITE8_DEVICE_HANDLER(mac_via_out_cb2) /* called when inquiry times out (1/4s) */ -static TIMER_CALLBACK(inquiry_timeout_func) +TIMER_CALLBACK_MEMBER(mac_state::inquiry_timeout_func) { if (LOG_KEYBOARD) logerror("keyboard enquiry timeout\n"); - kbd_shift_out(machine, 0x7B); /* always send NULL */ + kbd_shift_out(machine(), 0x7B); /* always send NULL */ } /* @@ -1770,12 +1769,10 @@ static WRITE8_DEVICE_HANDLER(mac_via2_out_b) } // This signal is generated internally on RBV, V8, Sonora, VASP, Eagle, etc. -static TIMER_CALLBACK(mac_6015_tick) +TIMER_CALLBACK_MEMBER(mac_state::mac_6015_tick) { - mac_state *mac = machine.driver_data<mac_state>(); - - mac->m_via1->write_ca1(0); - mac->m_via1->write_ca1(1); + m_via1->write_ca1(0); + m_via1->write_ca1(1); } /* ************************************************************************* @@ -1798,10 +1795,10 @@ void mac_state::machine_start() } } - this->m_scanline_timer = machine().scheduler().timer_alloc(FUNC(mac_scanline_tick)); + this->m_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mac_state::mac_scanline_tick),this)); this->m_scanline_timer->adjust(machine().primary_screen->time_until_pos(0, 0)); - m_6015_timer = machine().scheduler().timer_alloc(FUNC(mac_6015_tick)); + m_6015_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mac_state::mac_6015_tick),this)); m_6015_timer->adjust(attotime::never); } @@ -2105,7 +2102,7 @@ static void mac_driver_init(running_machine &machine, model_t model) /* setup keyboard */ keyboard_init(mac); - mac->m_inquiry_timeout = machine.scheduler().timer_alloc(FUNC(inquiry_timeout_func)); + mac->m_inquiry_timeout = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(mac_state::inquiry_timeout_func),mac)); /* save state stuff */ machine.save().register_postload(save_prepost_delegate(FUNC(mac_state_load), mac)); @@ -2251,39 +2248,38 @@ void mac_state::vblank_irq() } } -static TIMER_CALLBACK(mac_scanline_tick) +TIMER_CALLBACK_MEMBER(mac_state::mac_scanline_tick) { int scanline; - mac_state *mac = machine.driver_data<mac_state>(); - if (machine.device("custom") != NULL) + if (machine().device("custom") != NULL) { - mac_sh_updatebuffer(machine.device("custom")); + mac_sh_updatebuffer(machine().device("custom")); } - if (mac->m_rbv_vbltime > 0) + if (m_rbv_vbltime > 0) { - mac->m_rbv_vbltime--; + m_rbv_vbltime--; - if (mac->m_rbv_vbltime == 0) + if (m_rbv_vbltime == 0) { - mac->m_rbv_regs[2] |= 0x40; - mac->rbv_recalc_irqs(); + m_rbv_regs[2] |= 0x40; + rbv_recalc_irqs(); } } - scanline = machine.primary_screen->vpos(); + scanline = machine().primary_screen->vpos(); if (scanline == MAC_V_VIS) - mac->vblank_irq(); + vblank_irq(); /* check for mouse changes at 10 irqs per frame */ - if (mac->m_model <= MODEL_MAC_PLUS) + if (m_model <= MODEL_MAC_PLUS) { if (!(scanline % 10)) - mac->mouse_callback(); + mouse_callback(); } - mac->m_scanline_timer->adjust(machine.primary_screen->time_until_pos((scanline+1) % MAC_V_TOTAL, 0)); + m_scanline_timer->adjust(machine().primary_screen->time_until_pos((scanline+1) % MAC_V_TOTAL, 0)); } WRITE_LINE_MEMBER(mac_state::nubus_irq_9_w) diff --git a/src/mess/machine/macpci.c b/src/mess/machine/macpci.c index 0f2d2eaa79a..ab9073b8c24 100644 --- a/src/mess/machine/macpci.c +++ b/src/mess/machine/macpci.c @@ -22,7 +22,7 @@ #define LOG_ADB 0 #define LOG_VIA 0 -static TIMER_CALLBACK(mac_6015_tick); + /* VIA1 Handlers */ @@ -144,7 +144,7 @@ static WRITE8_DEVICE_HANDLER(mac_adb_via_out_cb2) void macpci_state::machine_start() { - m_6015_timer = machine().scheduler().timer_alloc(FUNC(mac_6015_tick)); + m_6015_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(macpci_state::mac_6015_tick),this)); m_6015_timer->adjust(attotime::never); } @@ -250,7 +250,6 @@ WRITE_LINE_MEMBER(macpci_state::drq_539x_1_w) { } -static TIMER_CALLBACK(mac_6015_tick) +TIMER_CALLBACK_MEMBER(macpci_state::mac_6015_tick) { -// macpci_state *mac = machine.driver_data<macpci_state>(); } diff --git a/src/mess/machine/mbc55x.c b/src/mess/machine/mbc55x.c index ddc01a9956f..a3764259c33 100644 --- a/src/mess/machine/mbc55x.c +++ b/src/mess/machine/mbc55x.c @@ -285,9 +285,9 @@ static void scan_keyboard(running_machine &machine) } } -static TIMER_CALLBACK(keyscan_callback) +TIMER_CALLBACK_MEMBER(mbc55x_state::keyscan_callback) { - scan_keyboard(machine); + scan_keyboard(machine()); } /* i8251 serial */ @@ -409,7 +409,7 @@ void mbc55x_state::machine_start() m_debug_machine=DEBUG_NONE; // Allocate keyscan timer - m_keyboard.keyscan_timer=machine().scheduler().timer_alloc(FUNC(keyscan_callback)); + m_keyboard.keyscan_timer=machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mbc55x_state::keyscan_callback),this)); } diff --git a/src/mess/machine/mbee.c b/src/mess/machine/mbee.c index 175e7663e08..ac8c69d9cf5 100644 --- a/src/mess/machine/mbee.c +++ b/src/mess/machine/mbee.c @@ -129,9 +129,8 @@ WRITE8_MEMBER( mbee_state::mbee_fdc_motor_w ) ************************************************************/ -static TIMER_CALLBACK( mbee256_kbd ) +TIMER_CALLBACK_MEMBER(mbee_state::mbee256_kbd) { - mbee_state *state = machine.driver_data<mbee_state>(); /* Keyboard scanner is a Mostek M3870 chip. Its speed of operation is determined by a 15k resistor on pin 2 (XTL2) and is therefore unknown. If a key change is detected (up or down), the /strobe line activates, sending a high to bit 1 of port 2 (one of the pio input lines). The next read of @@ -152,31 +151,31 @@ static TIMER_CALLBACK( mbee256_kbd ) for (i = 0; i < 15; i++) { sprintf(kbdrow,"X%d",i); - pressed[i] = (machine.root_device().ioport(kbdrow)->read()); + pressed[i] = (machine().root_device().ioport(kbdrow)->read()); } /* find what has changed */ for (i = 0; i < 15; i++) { - if (pressed[i] != state->m_mbee256_was_pressed[i]) + if (pressed[i] != m_mbee256_was_pressed[i]) { /* get scankey value */ for (j = 0; j < 8; j++) { - if (BIT(pressed[i]^state->m_mbee256_was_pressed[i], j)) + if (BIT(pressed[i]^m_mbee256_was_pressed[i], j)) { /* put it in the queue */ - state->m_mbee256_q[state->m_mbee256_q_pos] = (i << 3) | j | (BIT(pressed[i], j) ? 0x80 : 0); - if (state->m_mbee256_q_pos < 19) state->m_mbee256_q_pos++; + m_mbee256_q[m_mbee256_q_pos] = (i << 3) | j | (BIT(pressed[i], j) ? 0x80 : 0); + if (m_mbee256_q_pos < 19) m_mbee256_q_pos++; } } - state->m_mbee256_was_pressed[i] = pressed[i]; + m_mbee256_was_pressed[i] = pressed[i]; } } /* if anything queued, cause an interrupt */ - if (state->m_mbee256_q_pos) - state->m_mbee256_key_available = 2; // set irq + if (m_mbee256_q_pos) + m_mbee256_key_available = 2; // set irq } READ8_MEMBER( mbee_state::mbee256_18_r ) @@ -238,12 +237,11 @@ READ8_MEMBER( mbee_state::mbee_07_r ) // read return machine().device<mc146818_device>("rtc")->read(mem, 1); } -static TIMER_CALLBACK( mbee_rtc_irq ) +TIMER_CALLBACK_MEMBER(mbee_state::mbee_rtc_irq) { - mbee_state *state = machine.driver_data<mbee_state>(); - address_space &mem = machine.device("maincpu")->memory().space(AS_IO); - UINT8 data = machine.device<mc146818_device>("rtc")->read(mem, 12); - if (data) state->m_clock_pulse = 0x80; + address_space &mem = machine().device("maincpu")->memory().space(AS_IO); + UINT8 data = machine().device<mc146818_device>("rtc")->read(mem, 12); + if (data) m_clock_pulse = 0x80; } @@ -495,10 +493,9 @@ READ8_MEMBER( mbee_state::mbeepc_telcom_high_r ) /* after the first 4 bytes have been read from ROM, switch the ram back in */ -static TIMER_CALLBACK( mbee_reset ) +TIMER_CALLBACK_MEMBER(mbee_state::mbee_reset) { - mbee_state *state = machine.driver_data<mbee_state>(); - state->membank("boot")->set_entry(0); + membank("boot")->set_entry(0); } static void machine_reset_common_disk(running_machine &machine) @@ -512,14 +509,14 @@ static void machine_reset_common_disk(running_machine &machine) MACHINE_RESET_MEMBER(mbee_state,mbee) { membank("boot")->set_entry(1); - machine().scheduler().timer_set(attotime::from_usec(4), FUNC(mbee_reset)); + machine().scheduler().timer_set(attotime::from_usec(4), timer_expired_delegate(FUNC(mbee_state::mbee_reset),this)); } MACHINE_RESET_MEMBER(mbee_state,mbee56) { machine_reset_common_disk(machine()); membank("boot")->set_entry(1); - machine().scheduler().timer_set(attotime::from_usec(4), FUNC(mbee_reset)); + machine().scheduler().timer_set(attotime::from_usec(4), timer_expired_delegate(FUNC(mbee_state::mbee_reset),this)); } MACHINE_RESET_MEMBER(mbee_state,mbee64) @@ -547,7 +544,7 @@ MACHINE_RESET_MEMBER(mbee_state,mbee256) m_mbee256_q_pos = 0; mbee256_50_w(mem,0,0); // set banks to default membank("boot")->set_entry(8); // boot time - machine().scheduler().timer_set(attotime::from_usec(4), FUNC(mbee_reset)); + machine().scheduler().timer_set(attotime::from_usec(4), timer_expired_delegate(FUNC(mbee_state::mbee_reset),this)); } MACHINE_RESET_MEMBER(mbee_state,mbeett) @@ -556,7 +553,7 @@ MACHINE_RESET_MEMBER(mbee_state,mbeett) for (i = 0; i < 15; i++) m_mbee256_was_pressed[i] = 0; m_mbee256_q_pos = 0; membank("boot")->set_entry(1); - machine().scheduler().timer_set(attotime::from_usec(4), FUNC(mbee_reset)); + machine().scheduler().timer_set(attotime::from_usec(4), timer_expired_delegate(FUNC(mbee_state::mbee_reset),this)); } INTERRUPT_GEN_MEMBER(mbee_state::mbee_interrupt) @@ -713,8 +710,8 @@ DRIVER_INIT_MEMBER(mbee_state,mbee256) membank("bank8l")->configure_entry(0, &RAM[0x0000]); // rom membank("bank8h")->configure_entry(0, &RAM[0x0800]); // rom - machine().scheduler().timer_pulse(attotime::from_hz(1), FUNC(mbee_rtc_irq)); /* timer for rtc */ - machine().scheduler().timer_pulse(attotime::from_hz(25), FUNC(mbee256_kbd)); /* timer for kbd */ + machine().scheduler().timer_pulse(attotime::from_hz(1), timer_expired_delegate(FUNC(mbee_state::mbee_rtc_irq),this)); /* timer for rtc */ + machine().scheduler().timer_pulse(attotime::from_hz(25), timer_expired_delegate(FUNC(mbee_state::mbee256_kbd),this)); /* timer for kbd */ m_size = 0x8000; } @@ -733,8 +730,8 @@ DRIVER_INIT_MEMBER(mbee_state,mbeett) membank("pak")->set_entry(5); membank("telcom")->set_entry(0); - machine().scheduler().timer_pulse(attotime::from_hz(1), FUNC(mbee_rtc_irq)); /* timer for rtc */ - machine().scheduler().timer_pulse(attotime::from_hz(25), FUNC(mbee256_kbd)); /* timer for kbd */ + machine().scheduler().timer_pulse(attotime::from_hz(1), timer_expired_delegate(FUNC(mbee_state::mbee_rtc_irq),this)); /* timer for rtc */ + machine().scheduler().timer_pulse(attotime::from_hz(25), timer_expired_delegate(FUNC(mbee_state::mbee256_kbd),this)); /* timer for kbd */ m_size = 0x8000; } diff --git a/src/mess/machine/microtan.c b/src/mess/machine/microtan.c index afefea20f85..c0326543380 100644 --- a/src/mess/machine/microtan.c +++ b/src/mess/machine/microtan.c @@ -333,10 +333,10 @@ const via6522_interface microtan_via6522_1 = DEVCB_LINE(via_1_irq) }; -static TIMER_CALLBACK(microtan_read_cassette) +TIMER_CALLBACK_MEMBER(microtan_state::microtan_read_cassette) { - double level = (cassette_device_image(machine))->input(); - via6522_device *via_0 = machine.device<via6522_device>("via6522_0"); + double level = (cassette_device_image(machine()))->input(); + via6522_device *via_0 = machine().device<via6522_device>("via6522_0"); LOG(("microtan_read_cassette: %g\n", level)); if (level < -0.07) @@ -382,9 +382,9 @@ READ8_MEMBER(microtan_state::microtan_bffx_r) /* This callback is called one clock cycle after BFF2 is written (delayed nmi) */ -static TIMER_CALLBACK(microtan_pulse_nmi) +TIMER_CALLBACK_MEMBER(microtan_state::microtan_pulse_nmi) { - machine.device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE); + machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE); } WRITE8_MEMBER(microtan_state::microtan_bffx_w) @@ -400,7 +400,7 @@ WRITE8_MEMBER(microtan_state::microtan_bffx_w) break; case 1: /* BFF1: write delayed NMI */ LOG(("microtan_bff1_w: %d <- %02x (delayed NMI)\n", offset, data)); - machine().scheduler().timer_set(machine().device<cpu_device>("maincpu")->cycles_to_attotime(8), FUNC(microtan_pulse_nmi)); + machine().scheduler().timer_set(machine().device<cpu_device>("maincpu")->cycles_to_attotime(8), timer_expired_delegate(FUNC(microtan_state::microtan_pulse_nmi),this)); break; case 2: /* BFF2: write keypad column write (what is this meant for?) */ LOG(("microtan_bff2_w: %d <- %02x (keypad column)\n", offset, data)); @@ -566,7 +566,7 @@ DRIVER_INIT_MEMBER(microtan_state,microtan) break; } - m_timer = machine().scheduler().timer_alloc(FUNC(microtan_read_cassette)); + m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(microtan_state::microtan_read_cassette),this)); } void microtan_state::machine_reset() diff --git a/src/mess/machine/mikro80.c b/src/mess/machine/mikro80.c index a8321064c0f..9cf46e44016 100644 --- a/src/mess/machine/mikro80.c +++ b/src/mess/machine/mikro80.c @@ -69,15 +69,14 @@ I8255_INTERFACE( mikro80_ppi8255_interface ) }; -static TIMER_CALLBACK( mikro80_reset ) +TIMER_CALLBACK_MEMBER(mikro80_state::mikro80_reset) { - mikro80_state *state = machine.driver_data<mikro80_state>(); - state->membank("bank1")->set_entry(0); + membank("bank1")->set_entry(0); } void mikro80_state::machine_reset() { - machine().scheduler().timer_set(attotime::from_usec(10), FUNC(mikro80_reset)); + machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(mikro80_state::mikro80_reset),this)); membank("bank1")->set_entry(1); m_keyboard_mask = 0; } diff --git a/src/mess/machine/nes.c b/src/mess/machine/nes.c index 3448f29430c..3b0ceb9ba15 100644 --- a/src/mess/machine/nes.c +++ b/src/mess/machine/nes.c @@ -216,11 +216,10 @@ void nes_state::machine_reset() machine().device("maincpu")->reset(); } -static TIMER_CALLBACK( nes_irq_callback ) +TIMER_CALLBACK_MEMBER(nes_state::nes_irq_callback) { - nes_state *state = machine.driver_data<nes_state>(); - state->m_maincpu->set_input_line(M6502_IRQ_LINE, HOLD_LINE); - state->m_irq_timer->adjust(attotime::never); + m_maincpu->set_input_line(M6502_IRQ_LINE, HOLD_LINE); + m_irq_timer->adjust(attotime::never); } static void nes_banks_restore(nes_state *state) @@ -309,7 +308,7 @@ void nes_state::machine_start() } } - m_irq_timer = machine().scheduler().timer_alloc(FUNC(nes_irq_callback)); + m_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(nes_state::nes_irq_callback),this)); nes_state_register(machine()); } @@ -524,28 +523,28 @@ static void nes_read_input_device( running_machine &machine, int cfg, nes_input } -static TIMER_CALLBACK( lightgun_tick ) +TIMER_CALLBACK_MEMBER(nes_state::lightgun_tick) { - if ((machine.root_device().ioport("CTRLSEL")->read() & 0x000f) == 0x0002) + if ((machine().root_device().ioport("CTRLSEL")->read() & 0x000f) == 0x0002) { /* enable lightpen crosshair */ - crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL); + crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_ALL); } else { /* disable lightpen crosshair */ - crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE); + crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_NONE); } - if ((machine.root_device().ioport("CTRLSEL")->read() & 0x00f0) == 0x0030) + if ((machine().root_device().ioport("CTRLSEL")->read() & 0x00f0) == 0x0030) { /* enable lightpen crosshair */ - crosshair_set_screen(machine, 1, CROSSHAIR_SCREEN_ALL); + crosshair_set_screen(machine(), 1, CROSSHAIR_SCREEN_ALL); } else { /* disable lightpen crosshair */ - crosshair_set_screen(machine, 1, CROSSHAIR_SCREEN_NONE); + crosshair_set_screen(machine(), 1, CROSSHAIR_SCREEN_NONE); } } @@ -554,7 +553,7 @@ WRITE8_MEMBER(nes_state::nes_IN0_w) int cfg = ioport("CTRLSEL")->read(); /* Check if lightgun has been chosen as input: if so, enable crosshair */ - machine().scheduler().timer_set(attotime::zero, FUNC(lightgun_tick)); + machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(nes_state::lightgun_tick),this)); if ((cfg & 0x000f) >= 0x08) // for now we treat the FC keyboard separately from other inputs! { diff --git a/src/mess/machine/ondra.c b/src/mess/machine/ondra.c index 9a80117200c..f51bd814a35 100644 --- a/src/mess/machine/ondra.c +++ b/src/mess/machine/ondra.c @@ -75,11 +75,11 @@ WRITE8_MEMBER(ondra_state::ondra_port_0a_w) { } -static TIMER_CALLBACK(nmi_check_callback) +TIMER_CALLBACK_MEMBER(ondra_state::nmi_check_callback) { - if ((machine.root_device().ioport("NMI")->read() & 1) == 1) + if ((machine().root_device().ioport("NMI")->read() & 1) == 1) { - machine.device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE); + machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE); } } @@ -92,5 +92,5 @@ void ondra_state::machine_reset() void ondra_state::machine_start() { - machine().scheduler().timer_pulse(attotime::from_hz(10), FUNC(nmi_check_callback)); + machine().scheduler().timer_pulse(attotime::from_hz(10), timer_expired_delegate(FUNC(ondra_state::nmi_check_callback),this)); } diff --git a/src/mess/machine/oric.c b/src/mess/machine/oric.c index 875dc372cf0..f694af217c9 100644 --- a/src/mess/machine/oric.c +++ b/src/mess/machine/oric.c @@ -254,15 +254,15 @@ static cassette_image_device *cassette_device_image(running_machine &machine) /* not called yet - this will update the via with the state of the tape data. This allows the via to trigger on bit changes and issue interrupts */ -static TIMER_CALLBACK(oric_refresh_tape) +TIMER_CALLBACK_MEMBER(oric_state::oric_refresh_tape) { int data; int input_port_9; - via6522_device *via_0 = machine.device<via6522_device>("via6522_0"); + via6522_device *via_0 = machine().device<via6522_device>("via6522_0"); data = 0; - if ((cassette_device_image(machine))->input() > 0.0038) + if ((cassette_device_image(machine()))->input() > 0.0038) data |= 1; /* "A simple cable to catch the vertical retrace signal ! @@ -270,7 +270,7 @@ static TIMER_CALLBACK(oric_refresh_tape) to the via cb1 input. Interrupts can be generated from the vertical sync, and flicker free games can be produced */ - input_port_9 = machine.root_device().ioport("FLOPPY")->read(); + input_port_9 = machine().root_device().ioport("FLOPPY")->read(); /* cable is enabled? */ if ((input_port_9 & 0x08)!=0) { @@ -1048,7 +1048,7 @@ static void oric_common_init_machine(running_machine &machine) state->m_port_314_r = 0; state->m_port_318_r = 0; state->m_port_314_w = 0; - machine.scheduler().timer_pulse(attotime::from_hz(4800), FUNC(oric_refresh_tape)); + machine.scheduler().timer_pulse(attotime::from_hz(4800), timer_expired_delegate(FUNC(oric_state::oric_refresh_tape),state)); } void oric_state::machine_start() diff --git a/src/mess/machine/osborne1.c b/src/mess/machine/osborne1.c index 2953ab25a61..b84c43ccbe8 100644 --- a/src/mess/machine/osborne1.c +++ b/src/mess/machine/osborne1.c @@ -331,10 +331,9 @@ const pia6821_interface osborne1_video_pia_config = //}; -static TIMER_CALLBACK(osborne1_video_callback) +TIMER_CALLBACK_MEMBER(osborne1_state::osborne1_video_callback) { - osborne1_state *state = machine.driver_data<osborne1_state>(); - int y = machine.primary_screen->vpos(); + int y = machine().primary_screen->vpos(); UINT8 ra=0,chr,gfx,dim; UINT16 x,ma; @@ -342,29 +341,29 @@ static TIMER_CALLBACK(osborne1_video_callback) if ( y == 0 ) { /* Clear CA1 on video PIA */ - state->m_pia1->ca1_w(0); + m_pia1->ca1_w(0); } if ( y == 240 ) { /* Set CA1 on video PIA */ - state->m_pia1->ca1_w(1); + m_pia1->ca1_w(1); } if ( y < 240 ) { ra = y % 10; /* Draw a line of the display */ - ma = (state->m_new_start_y + (y/10)) * 128 + state->m_new_start_x; - UINT16 *p = &state->m_bitmap.pix16(y); + ma = (m_new_start_y + (y/10)) * 128 + m_new_start_x; + UINT16 *p = &m_bitmap.pix16(y); for ( x = 0; x < 52; x++ ) { - chr = machine.device<ram_device>(RAM_TAG)->pointer()[ 0xF000 + ( (ma+x) & 0xFFF ) ]; - dim = machine.device<ram_device>(RAM_TAG)->pointer()[ 0x10000 + ( (ma+x) & 0xFFF ) ] & 0x80; + chr = machine().device<ram_device>(RAM_TAG)->pointer()[ 0xF000 + ( (ma+x) & 0xFFF ) ]; + dim = machine().device<ram_device>(RAM_TAG)->pointer()[ 0x10000 + ( (ma+x) & 0xFFF ) ] & 0x80; if ( (chr & 0x80) && (ra == 9) ) gfx = 0xFF; else - gfx = state->m_p_chargen[ (ra << 7) | ( chr & 0x7F ) ]; + gfx = m_p_chargen[ (ra << 7) | ( chr & 0x7F ) ]; /* Display a scanline of a character */ *p++ = BIT(gfx, 7) ? ( dim ? 1 : 2 ) : 0; @@ -380,22 +379,21 @@ static TIMER_CALLBACK(osborne1_video_callback) if ( (ra==2) || (ra== 6) ) { - beep_set_state( state->m_beep, state->m_beep_state ); + beep_set_state( m_beep, m_beep_state ); } else { - beep_set_state( state->m_beep, 0 ); + beep_set_state( m_beep, 0 ); } - state->m_video_timer->adjust(machine.primary_screen->time_until_pos(y + 1, 0 )); + m_video_timer->adjust(machine().primary_screen->time_until_pos(y + 1, 0 )); } -static TIMER_CALLBACK( setup_osborne1 ) +TIMER_CALLBACK_MEMBER(osborne1_state::setup_osborne1) { - osborne1_state *state = machine.driver_data<osborne1_state>(); - beep_set_state( state->m_beep, 0 ); - beep_set_frequency( state->m_beep, 300 /* 60 * 240 / 2 */ ); - state->m_pia1->ca1_w(0); + beep_set_state( m_beep, 0 ); + beep_set_frequency( m_beep, 300 /* 60 * 240 / 2 */ ); + m_pia1->ca1_w(0); } static void osborne1_load_proc(device_image_interface &image) @@ -453,10 +451,10 @@ DRIVER_INIT_MEMBER(osborne1_state,osborne1) /* Configure the 6850 ACIA */ // acia6850_config( 0, &osborne1_6850_config ); - m_video_timer = machine().scheduler().timer_alloc(FUNC(osborne1_video_callback)); + m_video_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(osborne1_state::osborne1_video_callback),this)); m_video_timer->adjust(machine().primary_screen->time_until_pos(1, 0 )); - machine().scheduler().timer_set(attotime::zero, FUNC(setup_osborne1)); + machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(osborne1_state::setup_osborne1),this)); } diff --git a/src/mess/machine/pc.c b/src/mess/machine/pc.c index e98ab658f6e..ba5147e65da 100644 --- a/src/mess/machine/pc.c +++ b/src/mess/machine/pc.c @@ -291,9 +291,9 @@ const struct pic8259_interface ibm5150_pic8259_config = static emu_timer *pc_int_delay_timer; -static TIMER_CALLBACK( pcjr_delayed_pic8259_irq ) +TIMER_CALLBACK_MEMBER(pc_state::pcjr_delayed_pic8259_irq) { - machine.firstcpu->set_input_line(0, param ? ASSERT_LINE : CLEAR_LINE); + machine().firstcpu->set_input_line(0, param ? ASSERT_LINE : CLEAR_LINE); } static WRITE_LINE_DEVICE_HANDLER( pcjr_pic8259_set_int_line ) @@ -594,7 +594,7 @@ READ8_MEMBER(pc_state::pcjr_nmi_enable_r) } -static TIMER_CALLBACK( pcjr_keyb_signal_callback ) +TIMER_CALLBACK_MEMBER(pc_state::pcjr_keyb_signal_callback) { pcjr_keyb.raw_keyb_data = pcjr_keyb.raw_keyb_data >> 1; pcjr_keyb.signal_count--; @@ -922,25 +922,24 @@ static struct { /* check if any keys are pressed, raise IRQ1 if so */ -static TIMER_CALLBACK( mc1502_keyb_signal_callback ) +TIMER_CALLBACK_MEMBER(pc_state::mc1502_keyb_signal_callback) { - pc_state *st = machine.driver_data<pc_state>(); UINT8 key = 0; - key |= machine.root_device().ioport("Y1")->read(); - key |= machine.root_device().ioport("Y2")->read(); - key |= machine.root_device().ioport("Y3")->read(); - key |= machine.root_device().ioport("Y4")->read(); - key |= machine.root_device().ioport("Y5")->read(); - key |= machine.root_device().ioport("Y6")->read(); - key |= machine.root_device().ioport("Y7")->read(); - key |= machine.root_device().ioport("Y8")->read(); - key |= machine.root_device().ioport("Y9")->read(); - key |= machine.root_device().ioport("Y10")->read(); - key |= machine.root_device().ioport("Y11")->read(); - key |= machine.root_device().ioport("Y12")->read(); - DBG_LOG(1,"mc1502_k_s_c",("= %02X (%d) %s\n", key, mc1502_keyb.pulsing, - (key || mc1502_keyb.pulsing) ? " will IRQ" : "")); + key |= machine().root_device().ioport("Y1")->read(); + key |= machine().root_device().ioport("Y2")->read(); + key |= machine().root_device().ioport("Y3")->read(); + key |= machine().root_device().ioport("Y4")->read(); + key |= machine().root_device().ioport("Y5")->read(); + key |= machine().root_device().ioport("Y6")->read(); + key |= machine().root_device().ioport("Y7")->read(); + key |= machine().root_device().ioport("Y8")->read(); + key |= machine().root_device().ioport("Y9")->read(); + key |= machine().root_device().ioport("Y10")->read(); + key |= machine().root_device().ioport("Y11")->read(); + key |= machine().root_device().ioport("Y12")->read(); +// DBG_LOG(1,"mc1502_k_s_c",("= %02X (%d) %s\n", key, mc1502_keyb.pulsing, +// (key || mc1502_keyb.pulsing) ? " will IRQ" : "")); /* If a key is pressed and we're not pulsing yet, start pulsing the IRQ1; @@ -954,7 +953,7 @@ static TIMER_CALLBACK( mc1502_keyb_signal_callback ) } if (mc1502_keyb.pulsing) { - pic8259_ir1_w(st->m_pic8259, (mc1502_keyb.pulsing & 1)); + pic8259_ir1_w(m_pic8259, (mc1502_keyb.pulsing & 1)); mc1502_keyb.pulsing--; } } @@ -1486,7 +1485,7 @@ MACHINE_START_MEMBER(pc_state,mc1502) */ pic8259_ir1_w(m_pic8259, 1); memset(&mc1502_keyb, 0, sizeof(mc1502_keyb)); - mc1502_keyb.keyb_signal_timer = machine().scheduler().timer_alloc(FUNC(mc1502_keyb_signal_callback)); + mc1502_keyb.keyb_signal_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pc_state::mc1502_keyb_signal_callback),this)); mc1502_keyb.keyb_signal_timer->adjust( attotime::from_msec(20), 0, attotime::from_msec(20) ); } @@ -1494,8 +1493,8 @@ MACHINE_START_MEMBER(pc_state,mc1502) MACHINE_START_MEMBER(pc_state,pcjr) { pc_fdc_init( machine(), &pcjr_fdc_interface_nc ); - pcjr_keyb.keyb_signal_timer = machine().scheduler().timer_alloc(FUNC(pcjr_keyb_signal_callback)); - pc_int_delay_timer = machine().scheduler().timer_alloc(FUNC(pcjr_delayed_pic8259_irq)); + pcjr_keyb.keyb_signal_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pc_state::pcjr_keyb_signal_callback),this)); + pc_int_delay_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pc_state::pcjr_delayed_pic8259_irq),this)); m_maincpu = machine().device<cpu_device>("maincpu" ); m_maincpu->set_irq_acknowledge_callback(pc_irq_callback); @@ -1679,7 +1678,7 @@ static struct { emu_timer *timer; } pc_rtc; -static TIMER_CALLBACK(pc_rtc_timer) +TIMER_CALLBACK_MEMBER(pc_state::pc_rtc_timer) { int year; if (++pc_rtc.data[2]>=60) { @@ -1704,8 +1703,9 @@ static TIMER_CALLBACK(pc_rtc_timer) void pc_rtc_init(running_machine &machine) { + pc_state *state = machine.driver_data<pc_state>(); memset(&pc_rtc,0,sizeof(pc_rtc)); - pc_rtc.timer = machine.scheduler().timer_alloc(FUNC(pc_rtc_timer)); + pc_rtc.timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pc_state::pc_rtc_timer),state)); pc_rtc.timer->adjust(attotime::zero, 0, attotime(1,0)); } diff --git a/src/mess/machine/pc1251.c b/src/mess/machine/pc1251.c index 7d7841d6ec3..aa7dcace9fa 100644 --- a/src/mess/machine/pc1251.c +++ b/src/mess/machine/pc1251.c @@ -100,10 +100,9 @@ MACHINE_START( pc1251 ) machine.device<nvram_device>("ram_nvram")->set_base(ram, 0x4800); } -static TIMER_CALLBACK(pc1251_power_up) +TIMER_CALLBACK_MEMBER(pc1251_state::pc1251_power_up) { - pc1251_state *state = machine.driver_data<pc1251_state>(); - state->m_power = 0; + m_power = 0; } DRIVER_INIT_MEMBER(pc1251_state,pc1251) @@ -113,6 +112,6 @@ DRIVER_INIT_MEMBER(pc1251_state,pc1251) for (i=0; i<128; i++) gfx[i]=i; m_power = 1; - machine().scheduler().timer_set(attotime::from_seconds(1), FUNC(pc1251_power_up)); + machine().scheduler().timer_set(attotime::from_seconds(1), timer_expired_delegate(FUNC(pc1251_state::pc1251_power_up),this)); } diff --git a/src/mess/machine/pc1350.c b/src/mess/machine/pc1350.c index bae1d82cfa5..46e1f8e66b8 100644 --- a/src/mess/machine/pc1350.c +++ b/src/mess/machine/pc1350.c @@ -90,10 +90,9 @@ int pc1350_brk(device_t *device) return (device->machine().root_device().ioport("EXTRA")->read() & 0x01); } -static TIMER_CALLBACK(pc1350_power_up) +TIMER_CALLBACK_MEMBER(pc1350_state::pc1350_power_up) { - pc1350_state *state = machine.driver_data<pc1350_state>(); - state->m_power=0; + m_power=0; } MACHINE_START( pc1350 ) @@ -102,7 +101,7 @@ MACHINE_START( pc1350 ) address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); state->m_power = 1; - machine.scheduler().timer_set(attotime::from_seconds(1), FUNC(pc1350_power_up)); + machine.scheduler().timer_set(attotime::from_seconds(1), timer_expired_delegate(FUNC(pc1350_state::pc1350_power_up),state)); space.install_readwrite_bank(0x6000, 0x6fff, "bank1"); state->membank("bank1")->set_base(&machine.device<ram_device>(RAM_TAG)->pointer()[0x0000]); diff --git a/src/mess/machine/pc1401.c b/src/mess/machine/pc1401.c index f8305f56895..a230c53d3f4 100644 --- a/src/mess/machine/pc1401.c +++ b/src/mess/machine/pc1401.c @@ -124,10 +124,9 @@ MACHINE_START( pc1401 ) machine.device<nvram_device>("ram_nvram")->set_base(ram, 0x2800); } -static TIMER_CALLBACK(pc1401_power_up) +TIMER_CALLBACK_MEMBER(pc1401_state::pc1401_power_up) { - pc1401_state *state = machine.driver_data<pc1401_state>(); - state->m_power = 0; + m_power = 0; } DRIVER_INIT_MEMBER(pc1401_state,pc1401) @@ -234,5 +233,5 @@ DRIVER_INIT_MEMBER(pc1401_state,pc1401) gfx[i]=i; m_power = 1; - machine().scheduler().timer_set(attotime::from_seconds(1), FUNC(pc1401_power_up)); + machine().scheduler().timer_set(attotime::from_seconds(1), timer_expired_delegate(FUNC(pc1401_state::pc1401_power_up),this)); } diff --git a/src/mess/machine/pc1403.c b/src/mess/machine/pc1403.c index 0411bb50f66..afae6b76249 100644 --- a/src/mess/machine/pc1403.c +++ b/src/mess/machine/pc1403.c @@ -152,10 +152,9 @@ MACHINE_START( pc1403 ) machine.device<nvram_device>("ram_nvram")->set_base(ram, 0x8000); } -static TIMER_CALLBACK(pc1403_power_up) +TIMER_CALLBACK_MEMBER(pc1403_state::pc1403_power_up) { - pc1403_state *state = machine.driver_data<pc1403_state>(); - state->m_power=0; + m_power=0; } DRIVER_INIT_MEMBER(pc1403_state,pc1403) @@ -166,7 +165,7 @@ DRIVER_INIT_MEMBER(pc1403_state,pc1403) for (i=0; i<128; i++) gfx[i]=i; m_power = 1; - machine().scheduler().timer_set(attotime::from_seconds(1), FUNC(pc1403_power_up)); + machine().scheduler().timer_set(attotime::from_seconds(1), timer_expired_delegate(FUNC(pc1403_state::pc1403_power_up),this)); membank("bank1")->set_base(memregion("user1")->base()); } diff --git a/src/mess/machine/pce.c b/src/mess/machine/pce.c index 3232533a03f..8fa2ad0054d 100644 --- a/src/mess/machine/pce.c +++ b/src/mess/machine/pce.c @@ -103,11 +103,11 @@ const msm5205_interface pce_cd_msm5205_interface = { /* prototypes */ static void pce_cd_init( running_machine &machine ); static void pce_cd_set_irq_line( running_machine &machine, int num, int state ); -static TIMER_CALLBACK( pce_cd_adpcm_dma_timer_callback ); -static TIMER_CALLBACK( pce_cd_cdda_fadeout_callback ); -static TIMER_CALLBACK( pce_cd_cdda_fadein_callback ); -static TIMER_CALLBACK( pce_cd_adpcm_fadeout_callback ); -static TIMER_CALLBACK( pce_cd_adpcm_fadein_callback ); + + + + + WRITE8_MEMBER(pce_state::pce_sf2_banking_w) { @@ -1118,10 +1118,9 @@ static void pce_cd_set_irq_line( running_machine &machine, int num, int state ) } } -static TIMER_CALLBACK( pce_cd_data_timer_callback ) +TIMER_CALLBACK_MEMBER(pce_state::pce_cd_data_timer_callback) { - pce_state *state = machine.driver_data<pce_state>(); - pce_cd_t &pce_cd = state->m_cd; + pce_cd_t &pce_cd = m_cd; if ( pce_cd.data_buffer_index == pce_cd.data_buffer_size ) { /* Read next data sector */ @@ -1208,19 +1207,19 @@ static void pce_cd_init( running_machine &machine ) } } - pce_cd.data_timer = machine.scheduler().timer_alloc(FUNC(pce_cd_data_timer_callback)); + pce_cd.data_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pce_state::pce_cd_data_timer_callback),state)); pce_cd.data_timer->adjust(attotime::never); - pce_cd.adpcm_dma_timer = machine.scheduler().timer_alloc(FUNC(pce_cd_adpcm_dma_timer_callback)); + pce_cd.adpcm_dma_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pce_state::pce_cd_adpcm_dma_timer_callback),state)); pce_cd.adpcm_dma_timer->adjust(attotime::never); - pce_cd.cdda_fadeout_timer = machine.scheduler().timer_alloc(FUNC(pce_cd_cdda_fadeout_callback)); + pce_cd.cdda_fadeout_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pce_state::pce_cd_cdda_fadeout_callback),state)); pce_cd.cdda_fadeout_timer->adjust(attotime::never); - pce_cd.cdda_fadein_timer = machine.scheduler().timer_alloc(FUNC(pce_cd_cdda_fadein_callback)); + pce_cd.cdda_fadein_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pce_state::pce_cd_cdda_fadein_callback),state)); pce_cd.cdda_fadein_timer->adjust(attotime::never); - pce_cd.adpcm_fadeout_timer = machine.scheduler().timer_alloc(FUNC(pce_cd_adpcm_fadeout_callback)); + pce_cd.adpcm_fadeout_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pce_state::pce_cd_adpcm_fadeout_callback),state)); pce_cd.adpcm_fadeout_timer->adjust(attotime::never); - pce_cd.adpcm_fadein_timer = machine.scheduler().timer_alloc(FUNC(pce_cd_adpcm_fadein_callback)); + pce_cd.adpcm_fadein_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pce_state::pce_cd_adpcm_fadein_callback),state)); pce_cd.adpcm_fadein_timer->adjust(attotime::never); } @@ -1249,78 +1248,74 @@ static void pce_cd_set_adpcm_ram_byte(running_machine &machine, UINT8 val) } } -static TIMER_CALLBACK( pce_cd_cdda_fadeout_callback ) +TIMER_CALLBACK_MEMBER(pce_state::pce_cd_cdda_fadeout_callback) { - pce_state *state = machine.driver_data<pce_state>(); - pce_cd_t &pce_cd = state->m_cd; + pce_cd_t &pce_cd = m_cd; pce_cd.cdda_volume-= 0.1; if(pce_cd.cdda_volume <= 0) { pce_cd.cdda_volume = 0.0; - cdda_set_volume(machine.device("cdda"), 0.0); + cdda_set_volume(machine().device("cdda"), 0.0); pce_cd.cdda_fadeout_timer->adjust(attotime::never); } else { - cdda_set_volume(machine.device("cdda"), pce_cd.cdda_volume); + cdda_set_volume(machine().device("cdda"), pce_cd.cdda_volume); pce_cd.cdda_fadeout_timer->adjust(attotime::from_usec(param), param); } } -static TIMER_CALLBACK( pce_cd_cdda_fadein_callback ) +TIMER_CALLBACK_MEMBER(pce_state::pce_cd_cdda_fadein_callback) { - pce_state *state = machine.driver_data<pce_state>(); - pce_cd_t &pce_cd = state->m_cd; + pce_cd_t &pce_cd = m_cd; pce_cd.cdda_volume+= 0.1; if(pce_cd.cdda_volume >= 100.0) { pce_cd.cdda_volume = 100.0; - cdda_set_volume(machine.device("cdda"), 100.0); + cdda_set_volume(machine().device("cdda"), 100.0); pce_cd.cdda_fadein_timer->adjust(attotime::never); } else { - cdda_set_volume(machine.device("cdda"), pce_cd.cdda_volume); + cdda_set_volume(machine().device("cdda"), pce_cd.cdda_volume); pce_cd.cdda_fadein_timer->adjust(attotime::from_usec(param), param); } } -static TIMER_CALLBACK( pce_cd_adpcm_fadeout_callback ) +TIMER_CALLBACK_MEMBER(pce_state::pce_cd_adpcm_fadeout_callback) { - pce_state *state = machine.driver_data<pce_state>(); - pce_cd_t &pce_cd = state->m_cd; + pce_cd_t &pce_cd = m_cd; pce_cd.adpcm_volume-= 0.1; if(pce_cd.adpcm_volume <= 0) { pce_cd.adpcm_volume = 0.0; - msm5205_set_volume(machine.device("msm5205"), 0.0); + msm5205_set_volume(machine().device("msm5205"), 0.0); pce_cd.adpcm_fadeout_timer->adjust(attotime::never); } else { - msm5205_set_volume(machine.device("msm5205"), pce_cd.adpcm_volume); + msm5205_set_volume(machine().device("msm5205"), pce_cd.adpcm_volume); pce_cd.adpcm_fadeout_timer->adjust(attotime::from_usec(param), param); } } -static TIMER_CALLBACK( pce_cd_adpcm_fadein_callback ) +TIMER_CALLBACK_MEMBER(pce_state::pce_cd_adpcm_fadein_callback) { - pce_state *state = machine.driver_data<pce_state>(); - pce_cd_t &pce_cd = state->m_cd; + pce_cd_t &pce_cd = m_cd; pce_cd.adpcm_volume+= 0.1; if(pce_cd.adpcm_volume >= 100.0) { pce_cd.adpcm_volume = 100.0; - msm5205_set_volume(machine.device("msm5205"), 100.0); + msm5205_set_volume(machine().device("msm5205"), 100.0); pce_cd.adpcm_fadein_timer->adjust(attotime::never); } else { - msm5205_set_volume(machine.device("msm5205"), pce_cd.adpcm_volume); + msm5205_set_volume(machine().device("msm5205"), pce_cd.adpcm_volume); pce_cd.adpcm_fadein_timer->adjust(attotime::from_usec(param), param); } } @@ -1515,13 +1510,12 @@ WRITE8_MEMBER(pce_state::pce_cd_intf_w) pce_cd_update(machine()); } -static TIMER_CALLBACK( pce_cd_clear_ack ) +TIMER_CALLBACK_MEMBER(pce_state::pce_cd_clear_ack) { - pce_state *state = machine.driver_data<pce_state>(); - pce_cd_t &pce_cd = state->m_cd; - pce_cd_update(machine); + pce_cd_t &pce_cd = m_cd; + pce_cd_update(machine()); pce_cd.scsi_ACK = 0; - pce_cd_update(machine); + pce_cd_update(machine()); if ( pce_cd.scsi_CD ) { pce_cd.regs[0x0B] &= 0xFE; @@ -1538,20 +1532,19 @@ static UINT8 pce_cd_get_cd_data_byte(running_machine &machine) if ( pce_cd.scsi_IO ) { pce_cd.scsi_ACK = 1; - machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(15), FUNC(pce_cd_clear_ack)); + machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(15), timer_expired_delegate(FUNC(pce_state::pce_cd_clear_ack),state)); } } return data; } -static TIMER_CALLBACK( pce_cd_adpcm_dma_timer_callback ) +TIMER_CALLBACK_MEMBER(pce_state::pce_cd_adpcm_dma_timer_callback) { - pce_state *state = machine.driver_data<pce_state>(); - pce_cd_t &pce_cd = state->m_cd; + pce_cd_t &pce_cd = m_cd; if ( pce_cd.scsi_REQ && ! pce_cd.scsi_ACK && ! pce_cd.scsi_CD && pce_cd.scsi_IO ) { - pce_cd.adpcm_ram[pce_cd.adpcm_write_ptr] = pce_cd_get_cd_data_byte(machine); + pce_cd.adpcm_ram[pce_cd.adpcm_write_ptr] = pce_cd_get_cd_data_byte(machine()); pce_cd.adpcm_write_ptr = ( pce_cd.adpcm_write_ptr + 1 ) & 0xFFFF; pce_cd.regs[0x0c] &= ~4; diff --git a/src/mess/machine/pecom.c b/src/mess/machine/pecom.c index 25ec32d87c8..7bc636af9e7 100644 --- a/src/mess/machine/pecom.c +++ b/src/mess/machine/pecom.c @@ -12,16 +12,15 @@ #include "machine/ram.h" #include "includes/pecom.h" -static TIMER_CALLBACK( reset_tick ) +TIMER_CALLBACK_MEMBER(pecom_state::reset_tick) { - pecom_state *state = machine.driver_data<pecom_state>(); - state->m_reset = 1; + m_reset = 1; } void pecom_state::machine_start() { - m_reset_timer = machine().scheduler().timer_alloc(FUNC(reset_tick)); + m_reset_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pecom_state::reset_tick),this)); } void pecom_state::machine_reset() diff --git a/src/mess/machine/pet.c b/src/mess/machine/pet.c index 497d9045761..e263e555b49 100644 --- a/src/mess/machine/pet.c +++ b/src/mess/machine/pet.c @@ -618,29 +618,28 @@ WRITE8_HANDLER( superpet_w ) } } -static TIMER_CALLBACK( pet_interrupt ) +TIMER_CALLBACK_MEMBER(pet_state::pet_interrupt) { - pet_state *state = machine.driver_data<pet_state>(); - pia6821_device *pia_0 = machine.device<pia6821_device>("pia_0"); + pia6821_device *pia_0 = machine().device<pia6821_device>("pia_0"); - pia_0->cb1_w(state->m_pia_level); - state->m_pia_level = !state->m_pia_level; + pia_0->cb1_w(m_pia_level); + m_pia_level = !m_pia_level; } -static TIMER_CALLBACK( pet_tape1_timer ) +TIMER_CALLBACK_MEMBER(pet_state::pet_tape1_timer) { - pia6821_device *pia_0 = machine.device<pia6821_device>("pia_0"); + pia6821_device *pia_0 = machine().device<pia6821_device>("pia_0"); // cassette 1 - UINT8 data = (machine.device<cassette_image_device>(CASSETTE_TAG)->input() > +0.0) ? 1 : 0; + UINT8 data = (machine().device<cassette_image_device>(CASSETTE_TAG)->input() > +0.0) ? 1 : 0; pia_0->ca1_w(data); } -static TIMER_CALLBACK( pet_tape2_timer ) +TIMER_CALLBACK_MEMBER(pet_state::pet_tape2_timer) { - via6522_device *via_0 = machine.device<via6522_device>("via6522_0"); + via6522_device *via_0 = machine().device<via6522_device>("via6522_0"); // cassette 2 - UINT8 data = (machine.device<cassette_image_device>(CASSETTE2_TAG)->input() > +0.0) ? 1 : 0; + UINT8 data = (machine().device<cassette_image_device>(CASSETTE2_TAG)->input() > +0.0) ? 1 : 0; via_0->write_cb1(data); } @@ -671,11 +670,11 @@ static void pet_common_driver_init( running_machine &machine ) } /* pet clock */ - machine.scheduler().timer_pulse(attotime::from_msec(10), FUNC(pet_interrupt)); + machine.scheduler().timer_pulse(attotime::from_msec(10), timer_expired_delegate(FUNC(pet_state::pet_interrupt),state)); /* datasette */ - state->m_datasette1_timer = machine.scheduler().timer_alloc(FUNC(pet_tape1_timer)); - state->m_datasette2_timer = machine.scheduler().timer_alloc(FUNC(pet_tape2_timer)); + state->m_datasette1_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pet_state::pet_tape1_timer),state)); + state->m_datasette2_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pet_state::pet_tape2_timer),state)); } diff --git a/src/mess/machine/pmd85.c b/src/mess/machine/pmd85.c index 987f0596b87..dc85dacc954 100644 --- a/src/mess/machine/pmd85.c +++ b/src/mess/machine/pmd85.c @@ -787,39 +787,38 @@ I8255_INTERFACE( mato_ppi8255_interface ) }; -static TIMER_CALLBACK(pmd85_cassette_timer_callback) +TIMER_CALLBACK_MEMBER(pmd85_state::pmd85_cassette_timer_callback) { - pmd85_state *state = machine.driver_data<pmd85_state>(); - i8251_device *uart = machine.device<i8251_device>("uart"); - serial_source_device *ser = machine.device<serial_source_device>("sercas"); + i8251_device *uart = machine().device<i8251_device>("uart"); + serial_source_device *ser = machine().device<serial_source_device>("sercas"); int data; int current_level; - if (!(machine.root_device().ioport("DSW0")->read() & 0x02)) /* V.24 / Tape Switch */ + if (!(machine().root_device().ioport("DSW0")->read() & 0x02)) /* V.24 / Tape Switch */ { /* tape reading */ - if (machine.device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_PLAY) + if (machine().device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_PLAY) { - switch (state->m_model) + switch (m_model) { case PMD85_1: - if (state->m_clk_level_tape) + if (m_clk_level_tape) { - state->m_previous_level = ((machine.device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0; - state->m_clk_level_tape = 0; + m_previous_level = ((machine().device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0; + m_clk_level_tape = 0; } else { - current_level = ((machine.device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0; + current_level = ((machine().device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0; - if (state->m_previous_level!=current_level) + if (m_previous_level!=current_level) { - data = (!state->m_previous_level && current_level) ? 1 : 0; + data = (!m_previous_level && current_level) ? 1 : 0; ser->send_bit(data); uart->receive_clock(); - state->m_clk_level_tape = 1; + m_clk_level_tape = 1; } } return; @@ -834,37 +833,37 @@ static TIMER_CALLBACK(pmd85_cassette_timer_callback) } /* tape writing */ - if (machine.device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_RECORD) + if (machine().device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_RECORD) { data = ser->get_in_data_bit(); - data ^= state->m_clk_level_tape; - machine.device<cassette_image_device>(CASSETTE_TAG)->output(data&0x01 ? 1 : -1); + data ^= m_clk_level_tape; + machine().device<cassette_image_device>(CASSETTE_TAG)->output(data&0x01 ? 1 : -1); - if (!state->m_clk_level_tape) + if (!m_clk_level_tape) uart->transmit_clock(); - state->m_clk_level_tape = state->m_clk_level_tape ? 0 : 1; + m_clk_level_tape = m_clk_level_tape ? 0 : 1; return; } - state->m_clk_level_tape = 1; + m_clk_level_tape = 1; - if (!state->m_clk_level) + if (!m_clk_level) uart->transmit_clock(); - state->m_clk_level = state->m_clk_level ? 0 : 1; + m_clk_level = m_clk_level ? 0 : 1; } } -static TIMER_CALLBACK( pmd_reset ) +TIMER_CALLBACK_MEMBER(pmd85_state::pmd_reset) { - machine.schedule_soft_reset(); + machine().schedule_soft_reset(); } DIRECT_UPDATE_MEMBER(pmd85_state::pmd85_opbaseoverride) { if (ioport("RESET")->read() & 0x01) - machine().scheduler().timer_set(attotime::from_usec(10), FUNC(pmd_reset)); + machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(pmd85_state::pmd_reset),this)); return address; } @@ -873,7 +872,7 @@ static void pmd85_common_driver_init (running_machine &machine) pmd85_state *state = machine.driver_data<pmd85_state>(); state->m_previous_level = 0; state->m_clk_level = state->m_clk_level_tape = 1; - state->m_cassette_timer = machine.scheduler().timer_alloc(FUNC(pmd85_cassette_timer_callback)); + state->m_cassette_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(pmd85_state::pmd85_cassette_timer_callback),state)); state->m_cassette_timer->adjust(attotime::zero, 0, attotime::from_hz(2400)); } @@ -918,13 +917,12 @@ DRIVER_INIT_MEMBER(pmd85_state,c2717) pmd85_common_driver_init(machine()); } -static TIMER_CALLBACK( setup_machine_state ) +TIMER_CALLBACK_MEMBER(pmd85_state::setup_machine_state) { - pmd85_state *state = machine.driver_data<pmd85_state>(); - if (state->m_model != MATO) + if (m_model != MATO) { - i8251_device *uart = machine.device<i8251_device>("uart"); - serial_source_device *ser = machine.device<serial_source_device>("sercas"); + i8251_device *uart = machine().device<i8251_device>("uart"); + serial_source_device *ser = machine().device<serial_source_device>("sercas"); uart->connect(ser); } } @@ -958,7 +956,7 @@ void pmd85_state::machine_reset() m_startup_mem_map = 1; update_memory(machine()); - machine().scheduler().timer_set(attotime::zero, FUNC(setup_machine_state)); + machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(pmd85_state::setup_machine_state),this)); machine().device("maincpu")->memory().space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(pmd85_state::pmd85_opbaseoverride), this)); } diff --git a/src/mess/machine/pokemini.c b/src/mess/machine/pokemini.c index 49eb2a84b66..e83aadae405 100644 --- a/src/mess/machine/pokemini.c +++ b/src/mess/machine/pokemini.c @@ -189,202 +189,194 @@ static void pokemini_update_sound( running_machine &machine ) } -static TIMER_CALLBACK(pokemini_seconds_timer_callback) +TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_seconds_timer_callback) { - pokemini_state *state = machine.driver_data<pokemini_state>(); - if ( state->m_pm_reg[0x08] & 0x01 ) + if ( m_pm_reg[0x08] & 0x01 ) { - state->m_pm_reg[0x09] += 1; - if ( ! state->m_pm_reg[0x09] ) + m_pm_reg[0x09] += 1; + if ( ! m_pm_reg[0x09] ) { - state->m_pm_reg[0x0A] += 1; - if ( ! state->m_pm_reg[0x0A] ) + m_pm_reg[0x0A] += 1; + if ( ! m_pm_reg[0x0A] ) { - state->m_pm_reg[0x0B] += 1; + m_pm_reg[0x0B] += 1; } } } } -static TIMER_CALLBACK(pokemini_256hz_timer_callback) +TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_256hz_timer_callback) { - pokemini_state *state = machine.driver_data<pokemini_state>(); - if ( state->m_pm_reg[0x40] & 0x01 ) + if ( m_pm_reg[0x40] & 0x01 ) { - state->m_pm_reg[0x41] += 1; + m_pm_reg[0x41] += 1; /* Check if the 32Hz IRQ should be triggered */ - if ( ! ( state->m_pm_reg[0x41] & 0x07 ) ) + if ( ! ( m_pm_reg[0x41] & 0x07 ) ) { - state->m_pm_reg[0x28] |= 0x20; + m_pm_reg[0x28] |= 0x20; /* Check if the 8Hz IRQ should be triggered */ - if ( ! ( state->m_pm_reg[0x41] & 0x1F ) ) + if ( ! ( m_pm_reg[0x41] & 0x1F ) ) { - state->m_pm_reg[0x28] |= 0x10; + m_pm_reg[0x28] |= 0x10; /* Check if the 2Hz IRQ should be triggered */ - if ( ! ( state->m_pm_reg[0x41] & 0x7F ) ) + if ( ! ( m_pm_reg[0x41] & 0x7F ) ) { - state->m_pm_reg[0x28] |= 0x08; + m_pm_reg[0x28] |= 0x08; /* Check if the 1Hz IRQ should be triggered */ - if ( ! state->m_pm_reg[0x41] ) + if ( ! m_pm_reg[0x41] ) { - state->m_pm_reg[0x28] |= 0x04; + m_pm_reg[0x28] |= 0x04; } } } - pokemini_check_irqs( machine ); + pokemini_check_irqs( machine() ); } } } -static TIMER_CALLBACK(pokemini_timer1_callback) +TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer1_callback) { - pokemini_state *state = machine.driver_data<pokemini_state>(); - state->m_pm_reg[0x36] -= 1; + m_pm_reg[0x36] -= 1; /* Check for underflow of timer */ - if ( state->m_pm_reg[0x36] == 0xFF ) + if ( m_pm_reg[0x36] == 0xFF ) { /* Check if timer1 is running in 16bit mode */ - if ( state->m_pm_reg[0x30] & 0x80 ) + if ( m_pm_reg[0x30] & 0x80 ) { - state->m_pm_reg[0x37] -= 1; - if ( state->m_pm_reg[0x37] == 0xFF ) + m_pm_reg[0x37] -= 1; + if ( m_pm_reg[0x37] == 0xFF ) { - state->m_pm_reg[0x27] |= 0x08; - pokemini_check_irqs( machine ); - state->m_pm_reg[0x36] = state->m_pm_reg[0x32]; - state->m_pm_reg[0x37] = state->m_pm_reg[0x33]; + m_pm_reg[0x27] |= 0x08; + pokemini_check_irqs( machine() ); + m_pm_reg[0x36] = m_pm_reg[0x32]; + m_pm_reg[0x37] = m_pm_reg[0x33]; } } else { - state->m_pm_reg[0x27] |= 0x04; - pokemini_check_irqs( machine ); - state->m_pm_reg[0x36] = state->m_pm_reg[0x32]; + m_pm_reg[0x27] |= 0x04; + pokemini_check_irqs( machine() ); + m_pm_reg[0x36] = m_pm_reg[0x32]; } } } -static TIMER_CALLBACK(pokemini_timer1_hi_callback) +TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer1_hi_callback) { - pokemini_state *state = machine.driver_data<pokemini_state>(); - state->m_pm_reg[0x37] -= 1; + m_pm_reg[0x37] -= 1; /* Check for underflow of timer */ - if ( state->m_pm_reg[0x37] == 0xFF ) + if ( m_pm_reg[0x37] == 0xFF ) { - state->m_pm_reg[0x27] |= 0x08; - pokemini_check_irqs( machine ); - state->m_pm_reg[0x37] = state->m_pm_reg[0x33]; + m_pm_reg[0x27] |= 0x08; + pokemini_check_irqs( machine() ); + m_pm_reg[0x37] = m_pm_reg[0x33]; } } -static TIMER_CALLBACK(pokemini_timer2_callback) +TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer2_callback) { - pokemini_state *state = machine.driver_data<pokemini_state>(); - state->m_pm_reg[0x3E] -= 1; + m_pm_reg[0x3E] -= 1; /* Check for underflow of timer */ - if ( state->m_pm_reg[0x3E] == 0xFF ) + if ( m_pm_reg[0x3E] == 0xFF ) { /* Check if timer2 is running in 16bit mode */ - if ( state->m_pm_reg[0x38] & 0x80 ) + if ( m_pm_reg[0x38] & 0x80 ) { - state->m_pm_reg[0x3F] -= 1; - if ( state->m_pm_reg[0x3F] == 0xFF ) + m_pm_reg[0x3F] -= 1; + if ( m_pm_reg[0x3F] == 0xFF ) { - state->m_pm_reg[0x27] |= 0x20; - pokemini_check_irqs( machine ); - state->m_pm_reg[0x3E] = state->m_pm_reg[0x3A]; - state->m_pm_reg[0x3F] = state->m_pm_reg[0x3B]; + m_pm_reg[0x27] |= 0x20; + pokemini_check_irqs( machine() ); + m_pm_reg[0x3E] = m_pm_reg[0x3A]; + m_pm_reg[0x3F] = m_pm_reg[0x3B]; } } else { - state->m_pm_reg[0x27] |= 0x10; - pokemini_check_irqs( machine ); - state->m_pm_reg[0x3E] = state->m_pm_reg[0x3A]; + m_pm_reg[0x27] |= 0x10; + pokemini_check_irqs( machine() ); + m_pm_reg[0x3E] = m_pm_reg[0x3A]; } } } -static TIMER_CALLBACK(pokemini_timer2_hi_callback) +TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer2_hi_callback) { - pokemini_state *state = machine.driver_data<pokemini_state>(); - state->m_pm_reg[0x3F] -= 1; + m_pm_reg[0x3F] -= 1; /* Check for underfow of timer */ - if ( state->m_pm_reg[0x3F] == 0xFF ) + if ( m_pm_reg[0x3F] == 0xFF ) { - state->m_pm_reg[0x27] |= 0x20; - pokemini_check_irqs( machine ); - state->m_pm_reg[0x3F] = state->m_pm_reg[0x3B]; + m_pm_reg[0x27] |= 0x20; + pokemini_check_irqs( machine() ); + m_pm_reg[0x3F] = m_pm_reg[0x3B]; } } -static TIMER_CALLBACK(pokemini_timer3_callback) +TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer3_callback) { - pokemini_state *state = machine.driver_data<pokemini_state>(); - state->m_pm_reg[0x4E] -= 1; + m_pm_reg[0x4E] -= 1; /* Check for underflow of timer */ - if ( state->m_pm_reg[0x4E] == 0xFF ) + if ( m_pm_reg[0x4E] == 0xFF ) { /* Check if timer3 is running in 16bit mode */ - if ( state->m_pm_reg[0x48] & 0x80 ) + if ( m_pm_reg[0x48] & 0x80 ) { - state->m_pm_reg[0x4F] -= 1; - if ( state->m_pm_reg[0x4F] == 0xFF ) + m_pm_reg[0x4F] -= 1; + if ( m_pm_reg[0x4F] == 0xFF ) { - state->m_pm_reg[0x27] |= 0x02; - pokemini_check_irqs( machine ); - state->m_pm_reg[0x4E] = state->m_pm_reg[0x4A]; - state->m_pm_reg[0x4F] = state->m_pm_reg[0x4B]; + m_pm_reg[0x27] |= 0x02; + pokemini_check_irqs( machine() ); + m_pm_reg[0x4E] = m_pm_reg[0x4A]; + m_pm_reg[0x4F] = m_pm_reg[0x4B]; } } else { - state->m_pm_reg[0x4E] = state->m_pm_reg[0x4A]; + m_pm_reg[0x4E] = m_pm_reg[0x4A]; } } - if ( state->m_pm_reg[0x48] & 0x80 ) + if ( m_pm_reg[0x48] & 0x80 ) { - if ( ( state->m_pm_reg[0x4E] == state->m_pm_reg[0x4C] ) && ( state->m_pm_reg[0x4F] == state->m_pm_reg[0x4D] ) ) + if ( ( m_pm_reg[0x4E] == m_pm_reg[0x4C] ) && ( m_pm_reg[0x4F] == m_pm_reg[0x4D] ) ) { - state->m_pm_reg[0x27] |= 0x01; - pokemini_check_irqs( machine ); + m_pm_reg[0x27] |= 0x01; + pokemini_check_irqs( machine() ); } - pokemini_update_sound( machine ); + pokemini_update_sound( machine() ); } } -static TIMER_CALLBACK(pokemini_timer3_hi_callback) +TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer3_hi_callback) { - pokemini_state *state = machine.driver_data<pokemini_state>(); - state->m_pm_reg[0x4F] -= 1; + m_pm_reg[0x4F] -= 1; /* Check for underflow of timer */ - if ( state->m_pm_reg[0x4F] == 0xFF ) + if ( m_pm_reg[0x4F] == 0xFF ) { - state->m_pm_reg[0x27] |= 0x02; - pokemini_check_irqs( machine ); - state->m_pm_reg[0x4F] = state->m_pm_reg[0x4B]; + m_pm_reg[0x27] |= 0x02; + pokemini_check_irqs( machine() ); + m_pm_reg[0x4F] = m_pm_reg[0x4B]; } - if ( ! ( state->m_pm_reg[0x48] & 0x80 ) ) + if ( ! ( m_pm_reg[0x48] & 0x80 ) ) { - if( state->m_pm_reg[0x4F] == state->m_pm_reg[0x4D] ) + if( m_pm_reg[0x4F] == m_pm_reg[0x4D] ) { - state->m_pm_reg[0x27] |= 0x01; - pokemini_check_irqs( machine ); + m_pm_reg[0x27] |= 0x01; + pokemini_check_irqs( machine() ); } - pokemini_update_sound( machine ); + pokemini_update_sound( machine() ); } } @@ -1413,55 +1405,54 @@ DEVICE_IMAGE_LOAD( pokemini_cart ) } -static TIMER_CALLBACK( pokemini_prc_counter_callback ) +TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_prc_counter_callback) { - pokemini_state *state = machine.driver_data<pokemini_state>(); - address_space &space = machine.device( "maincpu")->memory().space( AS_PROGRAM ); - state->m_prc.count++; + address_space &space = machine().device( "maincpu")->memory().space( AS_PROGRAM ); + m_prc.count++; /* Check for overflow */ - if ( state->m_prc.count >= 0x42 ) + if ( m_prc.count >= 0x42 ) { - state->m_prc.count = 0; - state->m_prc.frame_count++; + m_prc.count = 0; + m_prc.frame_count++; } else { - if ( state->m_prc.count == 0x18 && state->m_prc.frame_count >= state->m_prc.max_frame_count ) + if ( m_prc.count == 0x18 && m_prc.frame_count >= m_prc.max_frame_count ) { - state->m_prc.frame_count = 0; + m_prc.frame_count = 0; /* Check if the background should be drawn */ - if ( state->m_prc.background_enabled ) + if ( m_prc.background_enabled ) { int x, y; for ( y = 0; y < 8; y++ ) { for ( x = 0; x < 12; x++ ) { - UINT8 tile = state->m_p_ram[ 0x360 + ( y * state->m_prc.map_size_x ) + x ]; + UINT8 tile = m_p_ram[ 0x360 + ( y * m_prc.map_size_x ) + x ]; int i; for( i = 0; i < 8; i++ ) { - state->m_p_ram[ ( y * 96 ) + ( x * 8 ) + i ] = space.read_byte( state->m_prc.bg_tiles + ( tile * 8 ) + i ); + m_p_ram[ ( y * 96 ) + ( x * 8 ) + i ] = space.read_byte( m_prc.bg_tiles + ( tile * 8 ) + i ); } } } } /* Check if the sprites should be drawn */ - if ( state->m_prc.sprites_enabled ) + if ( m_prc.sprites_enabled ) { UINT16 spr; for ( spr = 0x35C; spr >= 0x300; spr -= 4 ) { - int spr_x = ( state->m_p_ram[ spr + 0 ] & 0x7F ) - 16; - int spr_y = ( state->m_p_ram[ spr + 1 ] & 0x7F ) - 16; - UINT8 spr_tile = state->m_p_ram[ spr + 2 ]; - UINT8 spr_flag = state->m_p_ram[ spr + 3 ]; + int spr_x = ( m_p_ram[ spr + 0 ] & 0x7F ) - 16; + int spr_y = ( m_p_ram[ spr + 1 ] & 0x7F ) - 16; + UINT8 spr_tile = m_p_ram[ spr + 2 ]; + UINT8 spr_flag = m_p_ram[ spr + 3 ]; if ( spr_flag & 0x08 ) { UINT16 gfx, mask; - UINT32 spr_base = state->m_prc.spr_tiles + spr_tile * 64; + UINT32 spr_base = m_prc.spr_tiles + spr_tile * 64; int i, j; for ( i = 0; i < 16; i++ ) @@ -1490,10 +1481,10 @@ static TIMER_CALLBACK( pokemini_prc_counter_callback ) { if ( mask & 0x8000 ) { - state->m_p_ram[ ram_addr ] &= ~ ( 1 << ( ( spr_y + j ) & 0x07 ) ); + m_p_ram[ ram_addr ] &= ~ ( 1 << ( ( spr_y + j ) & 0x07 ) ); if ( gfx & 0x8000 ) { - state->m_p_ram[ ram_addr ] |= ( 1 << ( ( spr_y + j ) & 0x07 ) ); + m_p_ram[ ram_addr ] |= ( 1 << ( ( spr_y + j ) & 0x07 ) ); } } mask <<= 1; @@ -1503,10 +1494,10 @@ static TIMER_CALLBACK( pokemini_prc_counter_callback ) { if ( mask & 0x0001 ) { - state->m_p_ram[ ram_addr ] &= ~ ( 1 << ( ( spr_y + j ) & 0x07 ) ); + m_p_ram[ ram_addr ] &= ~ ( 1 << ( ( spr_y + j ) & 0x07 ) ); if ( gfx & 0x0001 ) { - state->m_p_ram[ ram_addr ] |= ( 1 << ( ( spr_y + j ) & 0x07 ) ); + m_p_ram[ ram_addr ] |= ( 1 << ( ( spr_y + j ) & 0x07 ) ); } } mask >>= 1; @@ -1521,37 +1512,37 @@ static TIMER_CALLBACK( pokemini_prc_counter_callback ) } /* Set PRC Render interrupt */ - state->m_pm_reg[0x27] |= 0x40; - pokemini_check_irqs( machine ); + m_pm_reg[0x27] |= 0x40; + pokemini_check_irqs( machine() ); /* Check if the rendered data should be copied to the LCD */ - if ( state->m_prc.copy_enabled ) + if ( m_prc.copy_enabled ) { int x, y; for( y = 0; y < 64; y += 8 ) { for( x = 0; x < 96; x++ ) { - UINT8 data = state->m_p_ram[ ( y * 12 ) + x ]; - - state->m_bitmap.pix16(y + 0, x) = ( data & 0x01 ) ? 3 : 0; - state->m_bitmap.pix16(y + 1, x) = ( data & 0x02 ) ? 3 : 0; - state->m_bitmap.pix16(y + 2, x) = ( data & 0x04 ) ? 3 : 0; - state->m_bitmap.pix16(y + 3, x) = ( data & 0x08 ) ? 3 : 0; - state->m_bitmap.pix16(y + 4, x) = ( data & 0x10 ) ? 3 : 0; - state->m_bitmap.pix16(y + 5, x) = ( data & 0x20 ) ? 3 : 0; - state->m_bitmap.pix16(y + 6, x) = ( data & 0x40 ) ? 3 : 0; - state->m_bitmap.pix16(y + 7, x) = ( data & 0x80 ) ? 3 : 0; + UINT8 data = m_p_ram[ ( y * 12 ) + x ]; + + m_bitmap.pix16(y + 0, x) = ( data & 0x01 ) ? 3 : 0; + m_bitmap.pix16(y + 1, x) = ( data & 0x02 ) ? 3 : 0; + m_bitmap.pix16(y + 2, x) = ( data & 0x04 ) ? 3 : 0; + m_bitmap.pix16(y + 3, x) = ( data & 0x08 ) ? 3 : 0; + m_bitmap.pix16(y + 4, x) = ( data & 0x10 ) ? 3 : 0; + m_bitmap.pix16(y + 5, x) = ( data & 0x20 ) ? 3 : 0; + m_bitmap.pix16(y + 6, x) = ( data & 0x40 ) ? 3 : 0; + m_bitmap.pix16(y + 7, x) = ( data & 0x80 ) ? 3 : 0; } } /* Set PRC Copy interrupt */ - state->m_pm_reg[0x27] |= 0x80; - pokemini_check_irqs( machine ); + m_pm_reg[0x27] |= 0x80; + pokemini_check_irqs( machine() ); } } /* Set possible input irqs */ - state->m_pm_reg[0x29] |= ~ machine.root_device().ioport( "INPUTS" )->read(); + m_pm_reg[0x29] |= ~ machine().root_device().ioport( "INPUTS" )->read(); } } @@ -1564,22 +1555,22 @@ void pokemini_state::machine_start() memset( m_pm_reg, 0, sizeof(m_pm_reg) ); /* Set up timers */ - m_timers.seconds_timer = machine().scheduler().timer_alloc(FUNC(pokemini_seconds_timer_callback)); + m_timers.seconds_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_seconds_timer_callback),this)); m_timers.seconds_timer->adjust( attotime::zero, 0, attotime::from_seconds( 1 ) ); - m_timers.hz256_timer = machine().scheduler().timer_alloc(FUNC(pokemini_256hz_timer_callback)); + m_timers.hz256_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_256hz_timer_callback),this)); m_timers.hz256_timer->adjust( attotime::zero, 0, attotime::from_hz( 256 ) ); - m_timers.timer1 = machine().scheduler().timer_alloc(FUNC(pokemini_timer1_callback)); - m_timers.timer1_hi = machine().scheduler().timer_alloc(FUNC(pokemini_timer1_hi_callback)); - m_timers.timer2 = machine().scheduler().timer_alloc(FUNC(pokemini_timer2_callback)); - m_timers.timer2_hi = machine().scheduler().timer_alloc(FUNC(pokemini_timer2_hi_callback)); - m_timers.timer3 = machine().scheduler().timer_alloc(FUNC(pokemini_timer3_callback)); - m_timers.timer3_hi = machine().scheduler().timer_alloc(FUNC(pokemini_timer3_hi_callback)); + m_timers.timer1 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_timer1_callback),this)); + m_timers.timer1_hi = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_timer1_hi_callback),this)); + m_timers.timer2 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_timer2_callback),this)); + m_timers.timer2_hi = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_timer2_hi_callback),this)); + m_timers.timer3 = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_timer3_callback),this)); + m_timers.timer3_hi = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_timer3_hi_callback),this)); /* Set up the PRC */ m_prc.max_frame_count = 2; - m_prc.count_timer = machine().scheduler().timer_alloc(FUNC(pokemini_prc_counter_callback)); + m_prc.count_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pokemini_state::pokemini_prc_counter_callback),this)); m_prc.count_timer->adjust( attotime::zero, 0, m_maincpu->cycles_to_attotime(55640 / 65) ); } diff --git a/src/mess/machine/poly88.c b/src/mess/machine/poly88.c index 0c40bd43f73..251fddb70b3 100644 --- a/src/mess/machine/poly88.c +++ b/src/mess/machine/poly88.c @@ -12,17 +12,16 @@ #include "includes/poly88.h" -static TIMER_CALLBACK(poly88_usart_timer_callback) +TIMER_CALLBACK_MEMBER(poly88_state::poly88_usart_timer_callback) { - poly88_state *state = machine.driver_data<poly88_state>(); - state->m_int_vector = 0xe7; - machine.device("maincpu")->execute().set_input_line(0, HOLD_LINE); + m_int_vector = 0xe7; + machine().device("maincpu")->execute().set_input_line(0, HOLD_LINE); } WRITE8_MEMBER(poly88_state::poly88_baud_rate_w) { logerror("poly88_baud_rate_w %02x\n",data); - m_usart_timer = machine().scheduler().timer_alloc(FUNC(poly88_usart_timer_callback)); + m_usart_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(poly88_state::poly88_usart_timer_callback),this)); m_usart_timer->adjust(attotime::zero, 0, attotime::from_hz(300)); } @@ -39,21 +38,20 @@ static UINT8 row_number(UINT8 code) { return 0; } -static TIMER_CALLBACK(keyboard_callback) +TIMER_CALLBACK_MEMBER(poly88_state::keyboard_callback) { - poly88_state *state = machine.driver_data<poly88_state>(); static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6" }; int i; UINT8 code; UINT8 key_code = 0; - UINT8 shift = machine.root_device().ioport("LINEC")->read() & 0x02 ? 1 : 0; - UINT8 ctrl = machine.root_device().ioport("LINEC")->read() & 0x01 ? 1 : 0; + UINT8 shift = machine().root_device().ioport("LINEC")->read() & 0x02 ? 1 : 0; + UINT8 ctrl = machine().root_device().ioport("LINEC")->read() & 0x01 ? 1 : 0; for(i = 0; i < 7; i++) { - code = machine.root_device().ioport(keynames[i])->read(); + code = machine().root_device().ioport(keynames[i])->read(); if (code != 0) { if (i==0 && shift==0) { @@ -117,11 +115,11 @@ static TIMER_CALLBACK(keyboard_callback) } } } - if (key_code==0 && state->m_last_code !=0){ - state->m_int_vector = 0xef; - machine.device("maincpu")->execute().set_input_line(0, HOLD_LINE); + if (key_code==0 && m_last_code !=0){ + m_int_vector = 0xef; + machine().device("maincpu")->execute().set_input_line(0, HOLD_LINE); } else { - state->m_last_code = key_code; + m_last_code = key_code; } } @@ -131,69 +129,67 @@ static IRQ_CALLBACK (poly88_irq_callback) return state->m_int_vector; } -static TIMER_CALLBACK(poly88_cassette_timer_callback) +TIMER_CALLBACK_MEMBER(poly88_state::poly88_cassette_timer_callback) { - poly88_state *state = machine.driver_data<poly88_state>(); int data; int current_level; - i8251_device *uart = machine.device<i8251_device>("uart"); - serial_source_device *ser = machine.device<serial_source_device>("sercas"); + i8251_device *uart = machine().device<i8251_device>("uart"); + serial_source_device *ser = machine().device<serial_source_device>("sercas"); -// if (!(machine.root_device().ioport("DSW0")->read() & 0x02)) /* V.24 / Tape Switch */ +// if (!(machine().root_device().ioport("DSW0")->read() & 0x02)) /* V.24 / Tape Switch */ //{ /* tape reading */ - if (machine.device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_PLAY) + if (machine().device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_PLAY) { - if (state->m_clk_level_tape) + if (m_clk_level_tape) { - state->m_previous_level = ((machine.device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0; - state->m_clk_level_tape = 0; + m_previous_level = ((machine().device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0; + m_clk_level_tape = 0; } else { - current_level = ((machine.device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0; + current_level = ((machine().device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0; - if (state->m_previous_level!=current_level) + if (m_previous_level!=current_level) { - data = (!state->m_previous_level && current_level) ? 1 : 0; + data = (!m_previous_level && current_level) ? 1 : 0; //data = current_level; ser->send_bit(data); uart->receive_clock(); - state->m_clk_level_tape = 1; + m_clk_level_tape = 1; } } } /* tape writing */ - if (machine.device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_RECORD) + if (machine().device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_RECORD) { data = ser->get_in_data_bit(); - data ^= state->m_clk_level_tape; - machine.device<cassette_image_device>(CASSETTE_TAG)->output(data&0x01 ? 1 : -1); + data ^= m_clk_level_tape; + machine().device<cassette_image_device>(CASSETTE_TAG)->output(data&0x01 ? 1 : -1); - if (!state->m_clk_level_tape) + if (!m_clk_level_tape) uart->transmit_clock(); - state->m_clk_level_tape = state->m_clk_level_tape ? 0 : 1; + m_clk_level_tape = m_clk_level_tape ? 0 : 1; return; } - state->m_clk_level_tape = 1; + m_clk_level_tape = 1; - if (!state->m_clk_level) + if (!m_clk_level) uart->transmit_clock(); - state->m_clk_level = state->m_clk_level ? 0 : 1; + m_clk_level = m_clk_level ? 0 : 1; // } } -static TIMER_CALLBACK( setup_machine_state ) +TIMER_CALLBACK_MEMBER(poly88_state::setup_machine_state) { -// poly88_state *state = machine.driver_data<poly88_state>(); - i8251_device *uart = machine.device<i8251_device>("uart"); - serial_source_device *ser = machine.device<serial_source_device>("sercas"); + i8251_device *uart = machine().device<i8251_device>("uart"); + serial_source_device *ser = machine().device<serial_source_device>("sercas"); uart->connect(ser); } @@ -201,10 +197,10 @@ DRIVER_INIT_MEMBER(poly88_state,poly88) { m_previous_level = 0; m_clk_level = m_clk_level_tape = 1; - m_cassette_timer = machine().scheduler().timer_alloc(FUNC(poly88_cassette_timer_callback)); + m_cassette_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(poly88_state::poly88_cassette_timer_callback),this)); m_cassette_timer->adjust(attotime::zero, 0, attotime::from_hz(600)); - machine().scheduler().timer_pulse(attotime::from_hz(24000), FUNC(keyboard_callback)); + machine().scheduler().timer_pulse(attotime::from_hz(24000), timer_expired_delegate(FUNC(poly88_state::keyboard_callback),this)); } void poly88_state::machine_reset() @@ -213,7 +209,7 @@ void poly88_state::machine_reset() m_intr = 0; m_last_code = 0; - machine().scheduler().timer_set(attotime::zero, FUNC(setup_machine_state)); + machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(poly88_state::setup_machine_state),this)); } INTERRUPT_GEN_MEMBER(poly88_state::poly88_interrupt) diff --git a/src/mess/machine/radio86.c b/src/mess/machine/radio86.c index 0e7e9c7d65b..3fdcb6b5fdc 100644 --- a/src/mess/machine/radio86.c +++ b/src/mess/machine/radio86.c @@ -154,10 +154,9 @@ I8257_INTERFACE( radio86_dma ) { DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_HANDLER("i8275", i8275_dack_w), DEVCB_NULL } }; -static TIMER_CALLBACK( radio86_reset ) +TIMER_CALLBACK_MEMBER(radio86_state::radio86_reset) { - radio86_state *state = machine.driver_data<radio86_state>(); - state->membank("bank1")->set_entry(0); + membank("bank1")->set_entry(0); } @@ -178,7 +177,7 @@ WRITE8_MEMBER(radio86_state::radio_io_w) MACHINE_RESET_MEMBER(radio86_state,radio86) { - machine().scheduler().timer_set(attotime::from_usec(10), FUNC(radio86_reset)); + machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(radio86_state::radio86_reset),this)); membank("bank1")->set_entry(1); m_keyboard_mask = 0; diff --git a/src/mess/machine/rm380z.c b/src/mess/machine/rm380z.c index a936f713f35..79c0157b4e6 100644 --- a/src/mess/machine/rm380z.c +++ b/src/mess/machine/rm380z.c @@ -158,33 +158,32 @@ WRITE8_MEMBER( rm380z_state::rm380z_porthi_w ) // for about 4.5 milliseconds every 20 milliseconds" // -static TIMER_CALLBACK(static_vblank_timer) +TIMER_CALLBACK_MEMBER(rm380z_state::static_vblank_timer) { - //printf("timer callback called at [%f]\n",machine.time().as_double()); + //printf("timer callback called at [%f]\n",machine().time().as_double()); - rm380z_state *state = machine.driver_data<rm380z_state>(); - state->m_rasterlineCtr++; - state->m_rasterlineCtr%=(HORZ_LINES*LINE_SUBDIVISION); + m_rasterlineCtr++; + m_rasterlineCtr%=(HORZ_LINES*LINE_SUBDIVISION); // frame blanking - if (state->m_rasterlineCtr>=((HORZ_LINES-22)*LINE_SUBDIVISION)) + if (m_rasterlineCtr>=((HORZ_LINES-22)*LINE_SUBDIVISION)) { - state->m_port1|=0x40; + m_port1|=0x40; } else { - state->m_port1&=~0x40; + m_port1&=~0x40; } // line blanking - if ((state->m_rasterlineCtr%LINE_SUBDIVISION)>80) + if ((m_rasterlineCtr%LINE_SUBDIVISION)>80) { - state->m_port1|=0x80; + m_port1|=0x80; } else { - state->m_port1&=~0x80; + m_port1&=~0x80; } } @@ -249,7 +248,7 @@ WRITE8_MEMBER( rm380z_state::disk_0_control ) void rm380z_state::machine_start() { - machine().scheduler().timer_pulse(attotime::from_hz(TIMER_SPEED), FUNC(static_vblank_timer)); + machine().scheduler().timer_pulse(attotime::from_hz(TIMER_SPEED), timer_expired_delegate(FUNC(rm380z_state::static_vblank_timer),this)); } void rm380z_state::machine_reset() diff --git a/src/mess/machine/rmnimbus.c b/src/mess/machine/rmnimbus.c index 94aca444667..7121b415a28 100644 --- a/src/mess/machine/rmnimbus.c +++ b/src/mess/machine/rmnimbus.c @@ -177,14 +177,14 @@ static void hdc_post_rw(running_machine &machine); static void hdc_drq(running_machine &machine); static void keyboard_reset(running_machine &machine); -static TIMER_CALLBACK(keyscan_callback); + static void pc8031_reset(running_machine &machine); static void iou_reset(running_machine &machine); static void rmni_sound_reset(running_machine &machine); static void mouse_js_reset(running_machine &machine); -static TIMER_CALLBACK(mouse_callback); + /************************************* @@ -458,11 +458,10 @@ static void nimbus_recalculate_ints(running_machine &machine) * *************************************/ -static TIMER_CALLBACK(internal_timer_int) +TIMER_CALLBACK_MEMBER(rmnimbus_state::internal_timer_int) { - rmnimbus_state *state = machine.driver_data<rmnimbus_state>(); int which = param; - struct timer_state *t = &state->m_i186.timer[which]; + struct timer_state *t = &m_i186.timer[which]; if (LOG_TIMER) logerror("Hit interrupt callback for timer %d\n", which); @@ -472,8 +471,8 @@ static TIMER_CALLBACK(internal_timer_int) /* request an interrupt */ if (t->control & 0x2000) { - state->m_i186.intr.status |= 0x01 << which; - update_interrupt_state(machine); + m_i186.intr.status |= 0x01 << which; + update_interrupt_state(machine()); if (LOG_TIMER) logerror(" Generating timer interrupt\n"); } @@ -654,11 +653,10 @@ static void internal_timer_update(running_machine &machine, * *************************************/ -static TIMER_CALLBACK(dma_timer_callback) +TIMER_CALLBACK_MEMBER(rmnimbus_state::dma_timer_callback) { - rmnimbus_state *state = machine.driver_data<rmnimbus_state>(); int which = param; - struct dma_state *d = &state->m_i186.dma[which]; + struct dma_state *d = &m_i186.dma[which]; /* complete the status update */ d->control &= ~0x0002; @@ -669,8 +667,8 @@ static TIMER_CALLBACK(dma_timer_callback) if (d->control & 0x0100) { if (LOG_DMA>1) logerror("DMA%d timer callback - requesting interrupt: count = %04X, source = %04X\n", which, d->count, d->source); - state->m_i186.intr.request |= 0x04 << which; - update_interrupt_state(machine); + m_i186.intr.request |= 0x04 << which; + update_interrupt_state(machine()); } } @@ -806,14 +804,14 @@ static void nimbus_cpu_init(running_machine &machine) logerror("Machine reset\n"); /* create timers here so they stick around */ - state->m_i186.timer[0].int_timer = machine.scheduler().timer_alloc(FUNC(internal_timer_int)); - state->m_i186.timer[1].int_timer = machine.scheduler().timer_alloc(FUNC(internal_timer_int)); - state->m_i186.timer[2].int_timer = machine.scheduler().timer_alloc(FUNC(internal_timer_int)); + state->m_i186.timer[0].int_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::internal_timer_int),state)); + state->m_i186.timer[1].int_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::internal_timer_int),state)); + state->m_i186.timer[2].int_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::internal_timer_int),state)); state->m_i186.timer[0].time_timer = machine.scheduler().timer_alloc(FUNC_NULL); state->m_i186.timer[1].time_timer = machine.scheduler().timer_alloc(FUNC_NULL); state->m_i186.timer[2].time_timer = machine.scheduler().timer_alloc(FUNC_NULL); - state->m_i186.dma[0].finish_timer = machine.scheduler().timer_alloc(FUNC(dma_timer_callback)); - state->m_i186.dma[1].finish_timer = machine.scheduler().timer_alloc(FUNC(dma_timer_callback)); + state->m_i186.dma[0].finish_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::dma_timer_callback),state)); + state->m_i186.dma[1].finish_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::dma_timer_callback),state)); } static void nimbus_cpu_reset(running_machine &machine) @@ -1262,8 +1260,8 @@ void rmnimbus_state::machine_start() /* init cpu */ nimbus_cpu_init(machine()); - m_keyboard.keyscan_timer=machine().scheduler().timer_alloc(FUNC(keyscan_callback)); - m_nimbus_mouse.m_mouse_timer=machine().scheduler().timer_alloc(FUNC(mouse_callback)); + m_keyboard.keyscan_timer=machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::keyscan_callback),this)); + m_nimbus_mouse.m_mouse_timer=machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::mouse_callback),this)); /* setup debug commands */ if (machine().debug_flags & DEBUG_FLAG_ENABLED) @@ -2171,9 +2169,9 @@ static void scan_keyboard(running_machine &machine) } } -static TIMER_CALLBACK(keyscan_callback) +TIMER_CALLBACK_MEMBER(rmnimbus_state::keyscan_callback) { - scan_keyboard(machine); + scan_keyboard(machine()); } /* @@ -2836,24 +2834,23 @@ static void mouse_js_reset(running_machine &machine) state->m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(1000)); } -static TIMER_CALLBACK(mouse_callback) +TIMER_CALLBACK_MEMBER(rmnimbus_state::mouse_callback) { - rmnimbus_state *drvstate = machine.driver_data<rmnimbus_state>(); UINT8 x = 0; UINT8 y = 0; -// int pc=machine.device(MAINCPU_TAG)->safe_pc(); +// int pc=machine().device(MAINCPU_TAG)->safe_pc(); UINT8 intstate_x; UINT8 intstate_y; int xint; int yint; - mouse_joy_state *state = &drvstate->m_nimbus_mouse; + mouse_joy_state *state = &m_nimbus_mouse; - state->m_reg0a4 = machine.root_device().ioport(MOUSE_BUTTON_TAG)->read() | 0xC0; - x = machine.root_device().ioport(MOUSEX_TAG)->read(); - y = machine.root_device().ioport(MOUSEY_TAG)->read(); + state->m_reg0a4 = machine().root_device().ioport(MOUSE_BUTTON_TAG)->read() | 0xC0; + x = machine().root_device().ioport(MOUSEX_TAG)->read(); + y = machine().root_device().ioport(MOUSEY_TAG)->read(); UINT8 mxa; UINT8 mxb; @@ -2923,10 +2920,10 @@ static TIMER_CALLBACK(mouse_callback) // mxb,mxa, (mxb ^ mxa) , (state->m_ay8910_a & 0xC0), (mxb ^ mxa) ^ ((state->m_ay8910_a & 0x40) >> 6)); } - intstate_x = (mxb ^ mxa) ^ ((drvstate->m_ay8910_a & 0x40) >> 6); - intstate_y = (myb ^ mya) ^ ((drvstate->m_ay8910_a & 0x80) >> 7); + intstate_x = (mxb ^ mxa) ^ ((m_ay8910_a & 0x40) >> 6); + intstate_y = (myb ^ mya) ^ ((m_ay8910_a & 0x80) >> 7); - if (MOUSE_INT_ENABLED(drvstate)) + if (MOUSE_INT_ENABLED(this)) { if ((intstate_x==1) && (state->m_intstate_x==0)) // if (intstate_x!=state->m_intstate_x) @@ -2934,7 +2931,7 @@ static TIMER_CALLBACK(mouse_callback) xint=mxa ? EXTERNAL_INT_MOUSE_XR : EXTERNAL_INT_MOUSE_XL; - external_int(machine,0,xint); + external_int(machine(),0,xint); // logerror("Xint:%02X, mxb=%02X\n",xint,mxb); } @@ -2944,7 +2941,7 @@ static TIMER_CALLBACK(mouse_callback) { yint=myb ? EXTERNAL_INT_MOUSE_YU : EXTERNAL_INT_MOUSE_YD; - external_int(machine,0,yint); + external_int(machine(),0,yint); // logerror("Yint:%02X, myb=%02X\n",yint,myb); } } diff --git a/src/mess/machine/samcoupe.c b/src/mess/machine/samcoupe.c index da60cfcf0c0..19ecabf6a09 100644 --- a/src/mess/machine/samcoupe.c +++ b/src/mess/machine/samcoupe.c @@ -178,10 +178,9 @@ static WRITE8_DEVICE_HANDLER( samcoupe_rtc_w ) MOUSE ***************************************************************************/ -static TIMER_CALLBACK( samcoupe_mouse_reset ) +TIMER_CALLBACK_MEMBER(samcoupe_state::samcoupe_mouse_reset) { - samcoupe_state *state = machine.driver_data<samcoupe_state>(); - state->m_mouse_index = 0; + m_mouse_index = 0; } UINT8 samcoupe_mouse_r(running_machine &machine) @@ -231,10 +230,10 @@ UINT8 samcoupe_mouse_r(running_machine &machine) void samcoupe_state::machine_start() { - m_mouse_reset = machine().scheduler().timer_alloc(FUNC(samcoupe_mouse_reset)); + m_mouse_reset = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(samcoupe_state::samcoupe_mouse_reset),this)); /* schedule our video updates */ - m_video_update_timer = machine().scheduler().timer_alloc(FUNC(sam_video_update_callback)); + m_video_update_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(samcoupe_state::sam_video_update_callback),this)); m_video_update_timer->adjust(machine().primary_screen->time_until_pos(0, 0)); } diff --git a/src/mess/machine/sms.c b/src/mess/machine/sms.c index 9a2dd235466..7c8f40aed6e 100644 --- a/src/mess/machine/sms.c +++ b/src/mess/machine/sms.c @@ -30,11 +30,10 @@ static void setup_rom(address_space &space); -static TIMER_CALLBACK( rapid_fire_callback ) +TIMER_CALLBACK_MEMBER(sms_state::rapid_fire_callback) { - sms_state *state = machine.driver_data<sms_state>(); - state->m_rapid_fire_state_1 ^= 0xff; - state->m_rapid_fire_state_2 ^= 0xff; + m_rapid_fire_state_1 ^= 0xff; + m_rapid_fire_state_2 ^= 0xff; } @@ -487,49 +486,48 @@ static void lphaser2_sensor_check( running_machine &machine ) // at each input port read we check if lightguns are enabled in one of the ports: // if so, we turn on crosshair and the lightgun timer -static TIMER_CALLBACK( lightgun_tick ) +TIMER_CALLBACK_MEMBER(sms_state::lightgun_tick) { - sms_state *state = machine.driver_data<sms_state>(); - if ((state->ioport("CTRLSEL")->read_safe(0x00) & 0x0f) == 0x01) + if ((ioport("CTRLSEL")->read_safe(0x00) & 0x0f) == 0x01) { /* enable crosshair */ - crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL); - if (!state->m_lphaser_1_timer->enabled()) - lphaser1_sensor_check(machine); + crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_ALL); + if (!m_lphaser_1_timer->enabled()) + lphaser1_sensor_check(machine()); } else { /* disable crosshair */ - crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE); - state->m_lphaser_1_timer->enable(0); + crosshair_set_screen(machine(), 0, CROSSHAIR_SCREEN_NONE); + m_lphaser_1_timer->enable(0); } - if ((state->ioport("CTRLSEL")->read_safe(0x00) & 0xf0) == 0x10) + if ((ioport("CTRLSEL")->read_safe(0x00) & 0xf0) == 0x10) { /* enable crosshair */ - crosshair_set_screen(machine, 1, CROSSHAIR_SCREEN_ALL); - if (!state->m_lphaser_2_timer->enabled()) - lphaser2_sensor_check(machine); + crosshair_set_screen(machine(), 1, CROSSHAIR_SCREEN_ALL); + if (!m_lphaser_2_timer->enabled()) + lphaser2_sensor_check(machine()); } else { /* disable crosshair */ - crosshair_set_screen(machine, 1, CROSSHAIR_SCREEN_NONE); - state->m_lphaser_2_timer->enable(0); + crosshair_set_screen(machine(), 1, CROSSHAIR_SCREEN_NONE); + m_lphaser_2_timer->enable(0); } } -static TIMER_CALLBACK( lphaser_1_callback ) +TIMER_CALLBACK_MEMBER(sms_state::lphaser_1_callback) { - lphaser1_sensor_check(machine); + lphaser1_sensor_check(machine()); } -static TIMER_CALLBACK( lphaser_2_callback ) +TIMER_CALLBACK_MEMBER(sms_state::lphaser_2_callback) { - lphaser2_sensor_check(machine); + lphaser2_sensor_check(machine()); } @@ -571,7 +569,7 @@ static void sms_get_inputs( address_space &space ) } /* Check if lightgun has been chosen as input: if so, enable crosshair */ - machine.scheduler().timer_set(attotime::zero, FUNC(lightgun_tick)); + machine.scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(sms_state::lightgun_tick),state)); /* Player 1 */ switch (machine.root_device().ioport("CTRLSEL")->read_safe(0x00) & 0x0f) @@ -1926,11 +1924,11 @@ MACHINE_START_MEMBER(sms_state,sms) { machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(sms_machine_stop),&machine())); - m_rapid_fire_timer = machine().scheduler().timer_alloc(FUNC(rapid_fire_callback)); + m_rapid_fire_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sms_state::rapid_fire_callback),this)); m_rapid_fire_timer->adjust(attotime::from_hz(10), 0, attotime::from_hz(10)); - m_lphaser_1_timer = machine().scheduler().timer_alloc(FUNC(lphaser_1_callback)); - m_lphaser_2_timer = machine().scheduler().timer_alloc(FUNC(lphaser_2_callback)); + m_lphaser_1_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sms_state::lphaser_1_callback),this)); + m_lphaser_2_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sms_state::lphaser_2_callback),this)); m_main_cpu = machine().device("maincpu"); m_control_cpu = machine().device("control"); @@ -1943,7 +1941,7 @@ MACHINE_START_MEMBER(sms_state,sms) m_space = &machine().device("maincpu")->memory().space(AS_PROGRAM); /* Check if lightgun has been chosen as input: if so, enable crosshair */ - machine().scheduler().timer_set(attotime::zero, FUNC(lightgun_tick)); + machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(sms_state::lightgun_tick),this)); } MACHINE_RESET_MEMBER(sms_state,sms) diff --git a/src/mess/machine/sorcerer.c b/src/mess/machine/sorcerer.c index b9398db100d..61c5741bf56 100644 --- a/src/mess/machine/sorcerer.c +++ b/src/mess/machine/sorcerer.c @@ -12,14 +12,13 @@ /* timer for sorcerer serial chip transmit and receive */ -static TIMER_CALLBACK(sorcerer_serial_tc) +TIMER_CALLBACK_MEMBER(sorcerer_state::sorcerer_serial_tc) { - sorcerer_state *state = machine.driver_data<sorcerer_state>(); /* if rs232 is enabled, uart is connected to clock defined by bit6 of port fe. Transmit and receive clocks are connected to the same clock */ /* if rs232 is disabled, receive clock is linked to cassette hardware */ - if (state->m_fe & 0x80) + if (m_fe & 0x80) { /* connect to rs232 */ } @@ -41,89 +40,88 @@ static cassette_image_device *cassette_device_image(running_machine &machine) -static TIMER_CALLBACK(sorcerer_cassette_tc) +TIMER_CALLBACK_MEMBER(sorcerer_state::sorcerer_cassette_tc) { - sorcerer_state *state = machine.driver_data<sorcerer_state>(); UINT8 cass_ws = 0; - switch (state->m_fe & 0xc0) /*/ bit 7 low indicates cassette */ + switch (m_fe & 0xc0) /*/ bit 7 low indicates cassette */ { case 0x00: /* Cassette 300 baud */ /* loading a tape - this is basically the same as the super80. We convert the 1200/2400 Hz signal to a 0 or 1, and send it to the uart. */ - state->m_cass_data.input.length++; + m_cass_data.input.length++; - cass_ws = ((cassette_device_image(machine))->input() > +0.02) ? 1 : 0; + cass_ws = ((cassette_device_image(machine()))->input() > +0.02) ? 1 : 0; - if (cass_ws != state->m_cass_data.input.level) + if (cass_ws != m_cass_data.input.level) { - state->m_cass_data.input.level = cass_ws; - state->m_cass_data.input.bit = ((state->m_cass_data.input.length < 0x6) || (state->m_cass_data.input.length > 0x20)) ? 1 : 0; - state->m_cass_data.input.length = 0; - ay31015_set_input_pin( state->m_uart, AY31015_SI, state->m_cass_data.input.bit ); + m_cass_data.input.level = cass_ws; + m_cass_data.input.bit = ((m_cass_data.input.length < 0x6) || (m_cass_data.input.length > 0x20)) ? 1 : 0; + m_cass_data.input.length = 0; + ay31015_set_input_pin( m_uart, AY31015_SI, m_cass_data.input.bit ); } /* saving a tape - convert the serial stream from the uart, into 1200 and 2400 Hz frequencies. Synchronisation of the frequency pulses to the uart is extremely important. */ - state->m_cass_data.output.length++; - if (!(state->m_cass_data.output.length & 0x1f)) + m_cass_data.output.length++; + if (!(m_cass_data.output.length & 0x1f)) { - cass_ws = ay31015_get_output_pin( state->m_uart, AY31015_SO ); - if (cass_ws != state->m_cass_data.output.bit) + cass_ws = ay31015_get_output_pin( m_uart, AY31015_SO ); + if (cass_ws != m_cass_data.output.bit) { - state->m_cass_data.output.bit = cass_ws; - state->m_cass_data.output.length = 0; + m_cass_data.output.bit = cass_ws; + m_cass_data.output.length = 0; } } - if (!(state->m_cass_data.output.length & 3)) + if (!(m_cass_data.output.length & 3)) { - if (!((state->m_cass_data.output.bit == 0) && (state->m_cass_data.output.length & 4))) + if (!((m_cass_data.output.bit == 0) && (m_cass_data.output.length & 4))) { - state->m_cass_data.output.level ^= 1; // toggle output state, except on 2nd half of low bit - cassette_device_image(machine)->output(state->m_cass_data.output.level ? -1.0 : +1.0); + m_cass_data.output.level ^= 1; // toggle output this, except on 2nd half of low bit + cassette_device_image(machine())->output(m_cass_data.output.level ? -1.0 : +1.0); } } return; case 0x40: /* Cassette 1200 baud */ /* loading a tape */ - state->m_cass_data.input.length++; + m_cass_data.input.length++; - cass_ws = ((cassette_device_image(machine))->input() > +0.02) ? 1 : 0; + cass_ws = ((cassette_device_image(machine()))->input() > +0.02) ? 1 : 0; - if (cass_ws != state->m_cass_data.input.level || state->m_cass_data.input.length == 10) + if (cass_ws != m_cass_data.input.level || m_cass_data.input.length == 10) { - state->m_cass_data.input.bit = ((state->m_cass_data.input.length < 10) || (state->m_cass_data.input.length > 0x20)) ? 1 : 0; - if ( cass_ws != state->m_cass_data.input.level ) + m_cass_data.input.bit = ((m_cass_data.input.length < 10) || (m_cass_data.input.length > 0x20)) ? 1 : 0; + if ( cass_ws != m_cass_data.input.level ) { - state->m_cass_data.input.length = 0; - state->m_cass_data.input.level = cass_ws; + m_cass_data.input.length = 0; + m_cass_data.input.level = cass_ws; } - ay31015_set_input_pin( state->m_uart, AY31015_SI, state->m_cass_data.input.bit ); + ay31015_set_input_pin( m_uart, AY31015_SI, m_cass_data.input.bit ); } /* saving a tape - convert the serial stream from the uart, into 600 and 1200 Hz frequencies. */ - state->m_cass_data.output.length++; - if (!(state->m_cass_data.output.length & 7)) + m_cass_data.output.length++; + if (!(m_cass_data.output.length & 7)) { - cass_ws = ay31015_get_output_pin( state->m_uart, AY31015_SO ); - if (cass_ws != state->m_cass_data.output.bit) + cass_ws = ay31015_get_output_pin( m_uart, AY31015_SO ); + if (cass_ws != m_cass_data.output.bit) { - state->m_cass_data.output.bit = cass_ws; - state->m_cass_data.output.length = 0; + m_cass_data.output.bit = cass_ws; + m_cass_data.output.length = 0; } } - if (!(state->m_cass_data.output.length & 7)) + if (!(m_cass_data.output.length & 7)) { - if (!((state->m_cass_data.output.bit == 0) && (state->m_cass_data.output.length & 8))) + if (!((m_cass_data.output.bit == 0) && (m_cass_data.output.length & 8))) { - state->m_cass_data.output.level ^= 1; // toggle output state, except on 2nd half of low bit - cassette_device_image(machine)->output(state->m_cass_data.output.level ? -1.0 : +1.0); + m_cass_data.output.level ^= 1; // toggle output this, except on 2nd half of low bit + cassette_device_image(machine())->output(m_cass_data.output.level ? -1.0 : +1.0); } } return; @@ -132,10 +130,9 @@ static TIMER_CALLBACK(sorcerer_cassette_tc) /* after the first 4 bytes have been read from ROM, switch the ram back in */ -static TIMER_CALLBACK( sorcerer_reset ) +TIMER_CALLBACK_MEMBER(sorcerer_state::sorcerer_reset) { - sorcerer_state *state = machine.driver_data<sorcerer_state>(); - state->membank("boot")->set_entry(0); + membank("boot")->set_entry(0); } WRITE8_MEMBER(sorcerer_state::sorcerer_fc_w) @@ -353,9 +350,9 @@ SNAPSHOT_LOAD(sorcerer) void sorcerer_state::machine_start() { - m_cassette_timer = machine().scheduler().timer_alloc(FUNC(sorcerer_cassette_tc)); + m_cassette_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sorcerer_state::sorcerer_cassette_tc),this)); #if SORCERER_USING_RS232 - m_serial_timer = machine().scheduler().timer_alloc(FUNC(sorcerer_serial_tc)); + m_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sorcerer_state::sorcerer_serial_tc),this)); #endif UINT16 endmem = 0xbfff; @@ -380,9 +377,9 @@ void sorcerer_state::machine_start() MACHINE_START_MEMBER(sorcerer_state,sorcererd) { - m_cassette_timer = machine().scheduler().timer_alloc(FUNC(sorcerer_cassette_tc)); + m_cassette_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sorcerer_state::sorcerer_cassette_tc),this)); #if SORCERER_USING_RS232 - m_serial_timer = machine().scheduler().timer_alloc(FUNC(sorcerer_serial_tc)); + m_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sorcerer_state::sorcerer_serial_tc),this)); #endif UINT16 endmem = 0xbbff; @@ -419,5 +416,5 @@ void sorcerer_state::machine_reset() sorcerer_fe_w(space, 0, 0, 0xff); membank("boot")->set_entry(1); - machine().scheduler().timer_set(attotime::from_usec(10), FUNC(sorcerer_reset)); + machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(sorcerer_state::sorcerer_reset),this)); } diff --git a/src/mess/machine/special.c b/src/mess/machine/special.c index 49b238e34d3..c4a31e700f7 100644 --- a/src/mess/machine/special.c +++ b/src/mess/machine/special.c @@ -101,16 +101,15 @@ I8255_INTERFACE( specialist_ppi8255_interface ) DEVCB_DRIVER_MEMBER(special_state, specialist_8255_portc_w) }; -static TIMER_CALLBACK( special_reset ) +TIMER_CALLBACK_MEMBER(special_state::special_reset) { - special_state *state = machine.driver_data<special_state>(); - state->membank("bank1")->set_entry(0); + membank("bank1")->set_entry(0); } MACHINE_RESET_MEMBER(special_state,special) { - machine().scheduler().timer_set(attotime::from_usec(10), FUNC(special_reset)); + machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(special_state::special_reset),this)); membank("bank1")->set_entry(1); } @@ -224,9 +223,9 @@ MACHINE_START_MEMBER(special_state,specimx) m_specimx_audio = machine().device("custom"); } -static TIMER_CALLBACK( setup_pit8253_gates ) +TIMER_CALLBACK_MEMBER(special_state::setup_pit8253_gates) { - device_t *pit8253 = machine.device("pit8253"); + device_t *pit8253 = machine().device("pit8253"); pit8253_gate0_w(pit8253, 0); pit8253_gate1_w(pit8253, 0); @@ -237,7 +236,7 @@ MACHINE_RESET_MEMBER(special_state,specimx) { specimx_set_bank(2, 0); // Initiali load ROM disk m_specimx_color = 0x70; - machine().scheduler().timer_set(attotime::zero, FUNC(setup_pit8253_gates)); + machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(special_state::setup_pit8253_gates),this)); device_t *fdc = machine().device("wd1793"); wd17xx_set_pause_time(fdc,12); wd17xx_dden_w(fdc, 0); diff --git a/src/mess/machine/super80.c b/src/mess/machine/super80.c index 4992be0b30d..15b6a41284f 100644 --- a/src/mess/machine/super80.c +++ b/src/mess/machine/super80.c @@ -78,58 +78,55 @@ static void super80_cassette_motor( running_machine &machine, UINT8 data ) bit 1 = MDS fast system bit 2 = CA3140 */ -static TIMER_CALLBACK( super80_timer ) +TIMER_CALLBACK_MEMBER(super80_state::super80_timer) { - super80_state *state = machine.driver_data<super80_state>(); UINT8 cass_ws=0; - state->m_cass_data[1]++; - cass_ws = ((state->m_cass)->input() > +0.03) ? 4 : 0; + m_cass_data[1]++; + cass_ws = ((m_cass)->input() > +0.03) ? 4 : 0; - if (cass_ws != state->m_cass_data[0]) + if (cass_ws != m_cass_data[0]) { - if (cass_ws) state->m_cass_data[3] ^= 2; // the MDS flipflop - state->m_cass_data[0] = cass_ws; - state->m_cass_data[2] = ((state->m_cass_data[1] < 0x40) ? 1 : 0) | cass_ws | state->m_cass_data[3]; - state->m_cass_data[1] = 0; + if (cass_ws) m_cass_data[3] ^= 2; // the MDS flipflop + m_cass_data[0] = cass_ws; + m_cass_data[2] = ((m_cass_data[1] < 0x40) ? 1 : 0) | cass_ws | m_cass_data[3]; + m_cass_data[1] = 0; } - state->m_pio->port_b_write(pio_port_b_r(state->m_pio,state->generic_space(),0,0xff)); + m_pio->port_b_write(pio_port_b_r(m_pio,generic_space(),0,0xff)); } /* after the first 4 bytes have been read from ROM, switch the ram back in */ -static TIMER_CALLBACK( super80_reset ) +TIMER_CALLBACK_MEMBER(super80_state::super80_reset) { - super80_state *state = machine.driver_data<super80_state>(); - state->membank("boot")->set_entry(0); + membank("boot")->set_entry(0); } -static TIMER_CALLBACK( super80_halfspeed ) +TIMER_CALLBACK_MEMBER(super80_state::super80_halfspeed) { UINT8 go_fast = 0; - super80_state *state = machine.driver_data<super80_state>(); - 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 */ + 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 */ go_fast++; /* code to slow down computer to 1 MHz by halting cpu on every second frame */ if (!go_fast) { - if (!state->m_int_sw) - machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE); // if going, stop it + if (!m_int_sw) + machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE); // if going, stop it - state->m_int_sw++; - if (state->m_int_sw > 1) + m_int_sw++; + if (m_int_sw > 1) { - machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE); // if stopped, start it - state->m_int_sw = 0; + machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE); // if stopped, start it + m_int_sw = 0; } } else { - if (state->m_int_sw < 8) // @2MHz, reset just once + if (m_int_sw < 8) // @2MHz, reset just once { - machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE); - state->m_int_sw = 8; // ...not every time + machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE); + m_int_sw = 8; // ...not every time } } } @@ -202,7 +199,7 @@ WRITE8_MEMBER( super80_state::super80r_f0_w ) void super80_state::machine_reset() { m_shared=0xff; - machine().scheduler().timer_set(attotime::from_usec(10), FUNC(super80_reset)); + machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(super80_state::super80_reset),this)); membank("boot")->set_entry(1); } @@ -211,12 +208,12 @@ static void driver_init_common( running_machine &machine ) super80_state *state = machine.driver_data<super80_state>(); UINT8 *RAM = state->memregion("maincpu")->base(); state->membank("boot")->configure_entries(0, 2, &RAM[0x0000], 0xc000); - machine.scheduler().timer_pulse(attotime::from_hz(200000), FUNC(super80_timer)); /* timer for keyboard and cassette */ + machine.scheduler().timer_pulse(attotime::from_hz(200000), timer_expired_delegate(FUNC(super80_state::super80_timer),state)); /* timer for keyboard and cassette */ } DRIVER_INIT_MEMBER(super80_state,super80) { - machine().scheduler().timer_pulse(attotime::from_hz(100), FUNC(super80_halfspeed)); /* timer for 1MHz slowdown */ + machine().scheduler().timer_pulse(attotime::from_hz(100), timer_expired_delegate(FUNC(super80_state::super80_halfspeed),this)); /* timer for 1MHz slowdown */ driver_init_common(machine()); } diff --git a/src/mess/machine/sym1.c b/src/mess/machine/sym1.c index a9ea947507b..ea5b1fae1d2 100644 --- a/src/mess/machine/sym1.c +++ b/src/mess/machine/sym1.c @@ -73,10 +73,9 @@ static WRITE_LINE_DEVICE_HANDLER( sym1_74145_output_5_w ) } -static TIMER_CALLBACK( led_refresh ) +TIMER_CALLBACK_MEMBER(sym1_state::led_refresh) { - sym1_state *state = machine.driver_data<sym1_state>(); - output_set_digit_value(param, state->m_riot_port_a); + output_set_digit_value(param, m_riot_port_a); } @@ -294,7 +293,7 @@ DRIVER_INIT_MEMBER(sym1_state,sym1) } /* allocate a timer to refresh the led display */ - m_led_update = machine().scheduler().timer_alloc(FUNC(led_refresh)); + m_led_update = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(sym1_state::led_refresh),this)); } diff --git a/src/mess/machine/ti85.c b/src/mess/machine/ti85.c index e8e25839cb0..9277bf584f2 100644 --- a/src/mess/machine/ti85.c +++ b/src/mess/machine/ti85.c @@ -15,26 +15,25 @@ #define TI86_SNAPSHOT_SIZE 131284 -static TIMER_CALLBACK(ti85_timer_callback) +TIMER_CALLBACK_MEMBER(ti85_state::ti85_timer_callback) { - ti85_state *state = machine.driver_data<ti85_state>(); - if (machine.root_device().ioport("ON")->read() & 0x01) + if (machine().root_device().ioport("ON")->read() & 0x01) { - if (state->m_ON_interrupt_mask && !state->m_ON_pressed) + if (m_ON_interrupt_mask && !m_ON_pressed) { - state->m_maincpu->set_input_line(0, HOLD_LINE); - state->m_ON_interrupt_status = 1; - if (!state->m_timer_interrupt_mask) state->m_timer_interrupt_mask = 1; + m_maincpu->set_input_line(0, HOLD_LINE); + m_ON_interrupt_status = 1; + if (!m_timer_interrupt_mask) m_timer_interrupt_mask = 1; } - state->m_ON_pressed = 1; + m_ON_pressed = 1; return; } else - state->m_ON_pressed = 0; - if (state->m_timer_interrupt_mask) + m_ON_pressed = 0; + if (m_timer_interrupt_mask) { - state->m_maincpu->set_input_line(0, HOLD_LINE); - state->m_timer_interrupt_status = 1; + m_maincpu->set_input_line(0, HOLD_LINE); + m_timer_interrupt_status = 1; } } @@ -131,7 +130,7 @@ void ti85_state::machine_start() m_port4_bit0 = 0; m_ti81_port_7_data = 0; - machine().scheduler().timer_pulse(attotime::from_hz(200), FUNC(ti85_timer_callback)); + machine().scheduler().timer_pulse(attotime::from_hz(200), timer_expired_delegate(FUNC(ti85_state::ti85_timer_callback),this)); space.unmap_write(0x0000, 0x3fff); space.unmap_write(0x4000, 0x7fff); @@ -180,7 +179,7 @@ MACHINE_START_MEMBER(ti85_state,ti83p) membank("bank3")->set_base(m_bios); membank("bank4")->set_base(m_ti8x_ram); - machine().scheduler().timer_pulse(attotime::from_hz(200), FUNC(ti85_timer_callback)); + machine().scheduler().timer_pulse(attotime::from_hz(200), timer_expired_delegate(FUNC(ti85_state::ti85_timer_callback),this)); } @@ -216,7 +215,7 @@ MACHINE_START_MEMBER(ti85_state,ti86) membank("bank4")->set_base(m_ti8x_ram); - machine().scheduler().timer_pulse(attotime::from_hz(200), FUNC(ti85_timer_callback)); + machine().scheduler().timer_pulse(attotime::from_hz(200), timer_expired_delegate(FUNC(ti85_state::ti85_timer_callback),this)); } diff --git a/src/mess/machine/trs80.c b/src/mess/machine/trs80.c index c0e17389c14..cf8cba92e0a 100644 --- a/src/mess/machine/trs80.c +++ b/src/mess/machine/trs80.c @@ -22,37 +22,36 @@ MAX_SECTORS 5 and granules of sectors #define MODEL4_MASTER_CLOCK 20275200 -static TIMER_CALLBACK( cassette_data_callback ) +TIMER_CALLBACK_MEMBER(trs80_state::cassette_data_callback) { - trs80_state *state = machine.driver_data<trs80_state>(); /* This does all baud rates. 250 baud (trs80), and 500 baud (all others) set bit 7 of "cassette_data". 1500 baud (trs80m3, trs80m4) is interrupt-driven and uses bit 0 of "cassette_data" */ - double new_val = (state->m_cass->input()); + double new_val = (m_cass->input()); /* Check for HI-LO transition */ - if ( state->m_old_cassette_val > -0.2 && new_val < -0.2 ) + if ( m_old_cassette_val > -0.2 && new_val < -0.2 ) { - state->m_cassette_data |= 0x80; /* 500 baud */ - if (state->m_mask & CASS_FALL) /* see if 1500 baud */ + m_cassette_data |= 0x80; /* 500 baud */ + if (m_mask & CASS_FALL) /* see if 1500 baud */ { - state->m_cassette_data = 0; - state->m_irq |= CASS_FALL; - machine.device("maincpu")->execute().set_input_line(0, HOLD_LINE); + m_cassette_data = 0; + m_irq |= CASS_FALL; + machine().device("maincpu")->execute().set_input_line(0, HOLD_LINE); } } else - if ( state->m_old_cassette_val < -0.2 && new_val > -0.2 ) + if ( m_old_cassette_val < -0.2 && new_val > -0.2 ) { - if (state->m_mask & CASS_RISE) /* 1500 baud */ + if (m_mask & CASS_RISE) /* 1500 baud */ { - state->m_cassette_data = 1; - state->m_irq |= CASS_RISE; - machine.device("maincpu")->execute().set_input_line(0, HOLD_LINE); + m_cassette_data = 1; + m_irq |= CASS_RISE; + machine().device("maincpu")->execute().set_input_line(0, HOLD_LINE); } } - state->m_old_cassette_val = new_val; + m_old_cassette_val = new_val; } @@ -852,7 +851,7 @@ void trs80_state::machine_start() m_reg_load=1; m_nmi_data=0xff; - m_cassette_data_timer = machine().scheduler().timer_alloc(FUNC(cassette_data_callback)); + m_cassette_data_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(trs80_state::cassette_data_callback),this)); m_cassette_data_timer->adjust( attotime::zero, 0, attotime::from_hz(11025) ); } diff --git a/src/mess/machine/ut88.c b/src/mess/machine/ut88.c index 0e258b9b326..b9d4628a0cc 100644 --- a/src/mess/machine/ut88.c +++ b/src/mess/machine/ut88.c @@ -60,15 +60,14 @@ I8255A_INTERFACE( ut88_ppi8255_interface ) DEVCB_NULL, }; -static TIMER_CALLBACK( ut88_reset ) +TIMER_CALLBACK_MEMBER(ut88_state::ut88_reset) { - ut88_state *state = machine.driver_data<ut88_state>(); - state->membank("bank1")->set_entry(0); + membank("bank1")->set_entry(0); } MACHINE_RESET_MEMBER(ut88_state,ut88) { - machine().scheduler().timer_set(attotime::from_usec(10), FUNC(ut88_reset)); + machine().scheduler().timer_set(attotime::from_usec(10), timer_expired_delegate(FUNC(ut88_state::ut88_reset),this)); membank("bank1")->set_entry(1); m_keyboard_mask = 0; } @@ -148,12 +147,11 @@ static const UINT8 hex_to_7seg[16] = 0x39, 0x5e, 0x79, 0x71 }; -static TIMER_CALLBACK( update_display ) +TIMER_CALLBACK_MEMBER(ut88_state::update_display) { - ut88_state *state = machine.driver_data<ut88_state>(); int i; for (i=0;i<6;i++) - output_set_digit_value(i, hex_to_7seg[state->m_lcd_digit[i]]); + output_set_digit_value(i, hex_to_7seg[m_lcd_digit[i]]); } @@ -163,7 +161,7 @@ DRIVER_INIT_MEMBER(ut88_state,ut88mini) MACHINE_START_MEMBER(ut88_state,ut88mini) { - machine().scheduler().timer_pulse(attotime::from_hz(60), FUNC(update_display)); + machine().scheduler().timer_pulse(attotime::from_hz(60), timer_expired_delegate(FUNC(ut88_state::update_display),this)); } MACHINE_RESET_MEMBER(ut88_state,ut88mini) diff --git a/src/mess/machine/vector06.c b/src/mess/machine/vector06.c index d798137f848..f2e2fb17cc9 100644 --- a/src/mess/machine/vector06.c +++ b/src/mess/machine/vector06.c @@ -136,21 +136,20 @@ static IRQ_CALLBACK( vector06_irq_callback ) return 0xff; } -static TIMER_CALLBACK( reset_check_callback ) +TIMER_CALLBACK_MEMBER(vector06_state::reset_check_callback) { - vector06_state *state = machine.driver_data<vector06_state>(); - UINT8 val = machine.root_device().ioport("RESET")->read(); + UINT8 val = machine().root_device().ioport("RESET")->read(); if (BIT(val, 0)) { - state->membank("bank1")->set_base(machine.root_device().memregion("maincpu")->base() + 0x10000); - machine.device("maincpu")->reset(); + membank("bank1")->set_base(machine().root_device().memregion("maincpu")->base() + 0x10000); + machine().device("maincpu")->reset(); } if (BIT(val, 1)) { - state->membank("bank1")->set_base(machine.device<ram_device>(RAM_TAG)->pointer() + 0x0000); - machine.device("maincpu")->reset(); + membank("bank1")->set_base(machine().device<ram_device>(RAM_TAG)->pointer() + 0x0000); + machine().device("maincpu")->reset(); } } @@ -164,7 +163,7 @@ WRITE8_MEMBER( vector06_state::vector06_disc_w ) void vector06_state::machine_start() { - machine().scheduler().timer_pulse(attotime::from_hz(50), FUNC(reset_check_callback)); + machine().scheduler().timer_pulse(attotime::from_hz(50), timer_expired_delegate(FUNC(vector06_state::reset_check_callback),this)); } void vector06_state::machine_reset() diff --git a/src/mess/machine/wswan.c b/src/mess/machine/wswan.c index c5ec6785771..27736cfa0bd 100644 --- a/src/mess/machine/wswan.c +++ b/src/mess/machine/wswan.c @@ -24,7 +24,7 @@ enum enum_sram { SRAM_NONE=0, SRAM_64K, SRAM_256K, SRAM_512K, SRAM_1M, SRAM_2M, static const char *const wswan_sram_str[] = { "none", "64Kbit SRAM", "256Kbit SRAM", "512Kbit SRAM", "1Mbit SRAM", "2Mbit SRAM", "1Kbit EEPROM", "16Kbit EEPROM", "8Kbit EEPROM", "Unknown" }; static 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 }; -static TIMER_CALLBACK(wswan_scanline_interrupt); + static const UINT8 ws_portram_init[256] = @@ -123,47 +123,46 @@ void wswan_state::wswan_clear_irq_line(int irq) wswan_handle_irqs( machine() ); } -static TIMER_CALLBACK(wswan_rtc_callback) +TIMER_CALLBACK_MEMBER(wswan_state::wswan_rtc_callback) { - wswan_state *state = machine.driver_data<wswan_state>(); /* A second passed */ - state->m_rtc.second = state->m_rtc.second + 1; - if ( ( state->m_rtc.second & 0x0F ) > 9 ) + m_rtc.second = m_rtc.second + 1; + if ( ( m_rtc.second & 0x0F ) > 9 ) { - state->m_rtc.second = ( state->m_rtc.second & 0xF0 ) + 0x10; + m_rtc.second = ( m_rtc.second & 0xF0 ) + 0x10; } /* Check for minute passed */ - if ( state->m_rtc.second >= 0x60 ) + if ( m_rtc.second >= 0x60 ) { - state->m_rtc.second = 0; - state->m_rtc.minute = state->m_rtc.minute + 1; - if ( ( state->m_rtc.minute & 0x0F ) > 9 ) + m_rtc.second = 0; + m_rtc.minute = m_rtc.minute + 1; + if ( ( m_rtc.minute & 0x0F ) > 9 ) { - state->m_rtc.minute = ( state->m_rtc.minute & 0xF0 ) + 0x10; + m_rtc.minute = ( m_rtc.minute & 0xF0 ) + 0x10; } } /* Check for hour passed */ - if ( state->m_rtc.minute >= 0x60 ) + if ( m_rtc.minute >= 0x60 ) { - state->m_rtc.minute = 0; - state->m_rtc.hour = state->m_rtc.hour + 1; - if ( ( state->m_rtc.hour & 0x0F ) > 9 ) + m_rtc.minute = 0; + m_rtc.hour = m_rtc.hour + 1; + if ( ( m_rtc.hour & 0x0F ) > 9 ) { - state->m_rtc.hour = ( state->m_rtc.hour & 0xF0 ) + 0x10; + m_rtc.hour = ( m_rtc.hour & 0xF0 ) + 0x10; } - if ( state->m_rtc.hour == 0x12 ) + if ( m_rtc.hour == 0x12 ) { - state->m_rtc.hour |= 0x80; + m_rtc.hour |= 0x80; } } /* Check for day passed */ - if ( state->m_rtc.hour >= 0x24 ) + if ( m_rtc.hour >= 0x24 ) { - state->m_rtc.hour = 0; - state->m_rtc.day = state->m_rtc.day + 1; + m_rtc.hour = 0; + m_rtc.day = m_rtc.day + 1; } } @@ -192,14 +191,14 @@ void wswan_state::machine_start() m_ws_bios_bank = NULL; m_system_type = TYPE_WSWAN; machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(wswan_machine_stop),&machine())); - m_vdp.timer = machine().scheduler().timer_alloc(FUNC(wswan_scanline_interrupt), &m_vdp ); + m_vdp.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(wswan_state::wswan_scanline_interrupt),this), &m_vdp ); m_vdp.timer->adjust( attotime::from_ticks( 256, 3072000 ), 0, attotime::from_ticks( 256, 3072000 ) ); wswan_setup_bios(machine()); /* Set up RTC timer */ if ( m_rtc.present ) - machine().scheduler().timer_pulse(attotime::from_seconds(1), FUNC(wswan_rtc_callback)); + machine().scheduler().timer_pulse(attotime::from_seconds(1), timer_expired_delegate(FUNC(wswan_state::wswan_rtc_callback),this)); machine().device<nvram_device>("nvram")->set_base(m_internal_eeprom, INTERNAL_EEPROM_SIZE); } @@ -209,14 +208,14 @@ MACHINE_START_MEMBER(wswan_state,wscolor) m_ws_bios_bank = NULL; m_system_type = TYPE_WSC; machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(wswan_machine_stop),&machine())); - m_vdp.timer = machine().scheduler().timer_alloc(FUNC(wswan_scanline_interrupt), &m_vdp ); + m_vdp.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(wswan_state::wswan_scanline_interrupt),this), &m_vdp ); m_vdp.timer->adjust( attotime::from_ticks( 256, 3072000 ), 0, attotime::from_ticks( 256, 3072000 ) ); wswan_setup_bios(machine()); /* Set up RTC timer */ if ( m_rtc.present ) - machine().scheduler().timer_pulse(attotime::from_seconds(1), FUNC(wswan_rtc_callback)); + machine().scheduler().timer_pulse(attotime::from_seconds(1), timer_expired_delegate(FUNC(wswan_state::wswan_rtc_callback),this)); machine().device<nvram_device>("nvram")->set_base(m_internal_eeprom, INTERNAL_EEPROM_SIZE); } @@ -1428,88 +1427,87 @@ DEVICE_IMAGE_LOAD(wswan_cart) return IMAGE_INIT_PASS; } -static TIMER_CALLBACK(wswan_scanline_interrupt) +TIMER_CALLBACK_MEMBER(wswan_state::wswan_scanline_interrupt) { - wswan_state *state = machine.driver_data<wswan_state>(); - if( state->m_vdp.current_line < 144 ) + if( m_vdp.current_line < 144 ) { - wswan_refresh_scanline(machine); + wswan_refresh_scanline(machine()); } /* Decrement 12kHz (HBlank) counter */ - if ( state->m_vdp.timer_hblank_enable && state->m_vdp.timer_hblank_reload != 0 ) + if ( m_vdp.timer_hblank_enable && m_vdp.timer_hblank_reload != 0 ) { - state->m_vdp.timer_hblank_count--; - logerror( "timer_hblank_count: %X\n", state->m_vdp.timer_hblank_count ); - if ( state->m_vdp.timer_hblank_count == 0 ) + m_vdp.timer_hblank_count--; + logerror( "timer_hblank_count: %X\n", m_vdp.timer_hblank_count ); + if ( m_vdp.timer_hblank_count == 0 ) { - if ( state->m_vdp.timer_hblank_mode ) + if ( m_vdp.timer_hblank_mode ) { - state->m_vdp.timer_hblank_count = state->m_vdp.timer_hblank_reload; + m_vdp.timer_hblank_count = m_vdp.timer_hblank_reload; } else { - state->m_vdp.timer_hblank_reload = 0; + m_vdp.timer_hblank_reload = 0; } logerror( "trigerring hbltmr interrupt\n" ); - wswan_set_irq_line( machine, WSWAN_IFLAG_HBLTMR ); + wswan_set_irq_line( machine(), WSWAN_IFLAG_HBLTMR ); } } /* Handle Sound DMA */ - if ( ( state->m_sound_dma.enable & 0x88 ) == 0x80 ) + if ( ( m_sound_dma.enable & 0x88 ) == 0x80 ) { - address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM ); + address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM ); /* TODO: Output sound DMA byte */ - state->wswan_port_w( space, 0x89, space.read_byte(state->m_sound_dma.source ) ); - state->m_sound_dma.size--; - state->m_sound_dma.source = ( state->m_sound_dma.source + 1 ) & 0x0FFFFF; - if ( state->m_sound_dma.size == 0 ) + wswan_port_w( space, 0x89, space.read_byte(m_sound_dma.source ) ); + m_sound_dma.size--; + m_sound_dma.source = ( m_sound_dma.source + 1 ) & 0x0FFFFF; + if ( m_sound_dma.size == 0 ) { - state->m_sound_dma.enable &= 0x7F; + m_sound_dma.enable &= 0x7F; } } -// state->m_vdp.current_line = (state->m_vdp.current_line + 1) % 159; +// m_vdp.current_line = (m_vdp.current_line + 1) % 159; - if( state->m_vdp.current_line == 144 ) // buffer sprite table + if( m_vdp.current_line == 144 ) // buffer sprite table { - memcpy(state->m_vdp.sprite_table_buffer, &state->m_vdp.vram[state->m_vdp.sprite_table_address], 512); - state->m_vdp.sprite_count = state->m_ws_portram[0x06]; - state->m_vdp.sprite_first = state->m_ws_portram[0x05]; // always zero? + memcpy(m_vdp.sprite_table_buffer, &m_vdp.vram[m_vdp.sprite_table_address], 512); + m_vdp.sprite_count = m_ws_portram[0x06]; + m_vdp.sprite_first = m_ws_portram[0x05]; // always zero? } - if( state->m_vdp.current_line == 144 ) + if( m_vdp.current_line == 144 ) { - wswan_set_irq_line( machine, WSWAN_IFLAG_VBL ); + wswan_set_irq_line( machine(), WSWAN_IFLAG_VBL ); /* Decrement 75Hz (VBlank) counter */ - if ( state->m_vdp.timer_vblank_enable && state->m_vdp.timer_vblank_reload != 0 ) + if ( m_vdp.timer_vblank_enable && m_vdp.timer_vblank_reload != 0 ) { - state->m_vdp.timer_vblank_count--; - logerror( "timer_vblank_count: %X\n", state->m_vdp.timer_vblank_count ); - if ( state->m_vdp.timer_vblank_count == 0 ) + m_vdp.timer_vblank_count--; + logerror( "timer_vblank_count: %X\n", m_vdp.timer_vblank_count ); + if ( m_vdp.timer_vblank_count == 0 ) { - if ( state->m_vdp.timer_vblank_mode ) + if ( m_vdp.timer_vblank_mode ) { - state->m_vdp.timer_vblank_count = state->m_vdp.timer_vblank_reload; + m_vdp.timer_vblank_count = m_vdp.timer_vblank_reload; } else { - state->m_vdp.timer_vblank_reload = 0; + m_vdp.timer_vblank_reload = 0; } logerror( "triggering vbltmr interrupt\n" ); - wswan_set_irq_line( machine, WSWAN_IFLAG_VBLTMR ); + wswan_set_irq_line( machine(), WSWAN_IFLAG_VBLTMR ); } } } -// state->m_vdp.current_line = (state->m_vdp.current_line + 1) % 159; +// m_vdp.current_line = (m_vdp.current_line + 1) % 159; - if ( state->m_vdp.current_line == state->m_vdp.line_compare ) + if ( m_vdp.current_line == m_vdp.line_compare ) { - wswan_set_irq_line( machine, WSWAN_IFLAG_LCMP ); + wswan_set_irq_line( machine(), WSWAN_IFLAG_LCMP ); } - state->m_vdp.current_line = (state->m_vdp.current_line + 1) % 159; + m_vdp.current_line = (m_vdp.current_line + 1) % 159; } diff --git a/src/mess/machine/z80ne.c b/src/mess/machine/z80ne.c index fb81ed5fd9e..ae52d4d2089 100644 --- a/src/mess/machine/z80ne.c +++ b/src/mess/machine/z80ne.c @@ -39,39 +39,38 @@ static cassette_image_device *cassette_device_image(running_machine &machine) return machine.device<cassette_image_device>(CASSETTE_TAG); } -static TIMER_CALLBACK(z80ne_cassette_tc) +TIMER_CALLBACK_MEMBER(z80ne_state::z80ne_cassette_tc) { - z80ne_state *state = machine.driver_data<z80ne_state>(); UINT8 cass_ws = 0; - state->m_cass_data.input.length++; + m_cass_data.input.length++; - cass_ws = ((cassette_device_image(machine))->input() > +0.02) ? 1 : 0; + cass_ws = ((cassette_device_image(machine()))->input() > +0.02) ? 1 : 0; - if ((cass_ws ^ state->m_cass_data.input.level) & cass_ws) + if ((cass_ws ^ m_cass_data.input.level) & cass_ws) { - state->m_cass_data.input.level = cass_ws; - 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; - state->m_cass_data.input.length = 0; - ay31015_set_input_pin( state->m_ay31015, AY31015_SI, state->m_cass_data.input.bit ); + m_cass_data.input.level = cass_ws; + m_cass_data.input.bit = ((m_cass_data.input.length < m_cass_data.wave_filter) || (m_cass_data.input.length > 0x20)) ? 1 : 0; + m_cass_data.input.length = 0; + ay31015_set_input_pin( m_ay31015, AY31015_SI, m_cass_data.input.bit ); } - state->m_cass_data.input.level = cass_ws; + m_cass_data.input.level = cass_ws; /* saving a tape - convert the serial stream from the uart */ - state->m_cass_data.output.length--; + m_cass_data.output.length--; - if (!(state->m_cass_data.output.length)) + if (!(m_cass_data.output.length)) { - if (state->m_cass_data.output.level) - state->m_cass_data.output.level = 0; + if (m_cass_data.output.level) + m_cass_data.output.level = 0; else { - state->m_cass_data.output.level=1; - cass_ws = ay31015_get_output_pin( state->m_ay31015, AY31015_SO ); - state->m_cass_data.wave_length = cass_ws ? state->m_cass_data.wave_short : state->m_cass_data.wave_long; + m_cass_data.output.level=1; + cass_ws = ay31015_get_output_pin( m_ay31015, AY31015_SO ); + m_cass_data.wave_length = cass_ws ? m_cass_data.wave_short : m_cass_data.wave_long; } - cassette_device_image(machine)->output(state->m_cass_data.output.level ? -1.0 : +1.0); - state->m_cass_data.output.length = state->m_cass_data.wave_length; + cassette_device_image(machine())->output(m_cass_data.output.level ? -1.0 : +1.0); + m_cass_data.output.length = m_cass_data.wave_length; } } @@ -114,9 +113,8 @@ DRIVER_INIT_MEMBER(z80ne_state,z80netf) } -static TIMER_CALLBACK( z80ne_kbd_scan ) +TIMER_CALLBACK_MEMBER(z80ne_state::z80ne_kbd_scan) { - z80ne_state *state = machine.driver_data<z80ne_state>(); /* * NE555 is connected to a 74LS93 binary counter * 74LS93 output: @@ -141,19 +139,19 @@ static TIMER_CALLBACK( z80ne_kbd_scan ) UINT8 i; /* 4-bit counter */ - --state->m_lx383_scan_counter; - state->m_lx383_scan_counter &= 0x0f; + --m_lx383_scan_counter; + m_lx383_scan_counter &= 0x0f; - if ( --state->m_lx383_downsampler == 0 ) + if ( --m_lx383_downsampler == 0 ) { - state->m_lx383_downsampler = LX383_DOWNSAMPLING; - key_bits = (machine.root_device().ioport("ROW1")->read() << 8) | machine.root_device().ioport("ROW0")->read(); -// rst = machine.root_device().ioport("RST")->read(); - ctrl = machine.root_device().ioport("CTRL")->read(); + m_lx383_downsampler = LX383_DOWNSAMPLING; + key_bits = (machine().root_device().ioport("ROW1")->read() << 8) | machine().root_device().ioport("ROW0")->read(); +// rst = machine().root_device().ioport("RST")->read(); + ctrl = machine().root_device().ioport("CTRL")->read(); for ( i = 0; i<LX383_KEYS; i++) { - state->m_lx383_key[i] = ( i | (key_bits & 0x01 ? 0x80 : 0x00) | ~ctrl); + m_lx383_key[i] = ( i | (key_bits & 0x01 ? 0x80 : 0x00) | ~ctrl); key_bits >>= 1; } } @@ -399,8 +397,8 @@ MACHINE_START_MEMBER(z80ne_state,z80ne) state_save_register_item( machine(), "z80ne", NULL, 0, m_lx383_downsampler ); state_save_register_item_array( machine(), "z80ne", NULL, 0, m_lx383_key ); state_save_register_item( machine(), "z80ne", NULL, 0, m_nmi_delay_counter ); - m_cassette_timer = machine().scheduler().timer_alloc(FUNC(z80ne_cassette_tc)); - machine().scheduler().timer_pulse( attotime::from_hz(1000), FUNC(z80ne_kbd_scan)); + m_cassette_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(z80ne_state::z80ne_cassette_tc),this)); + machine().scheduler().timer_pulse( attotime::from_hz(1000), timer_expired_delegate(FUNC(z80ne_state::z80ne_kbd_scan),this)); } MACHINE_START_MEMBER(z80ne_state,z80net) diff --git a/src/mess/machine/zx.c b/src/mess/machine/zx.c index c4246ad570b..8bbe45459e8 100644 --- a/src/mess/machine/zx.c +++ b/src/mess/machine/zx.c @@ -90,10 +90,9 @@ MACHINE_RESET_MEMBER(zx_state,pc8300) m_tape_bit = 0x80; } -static TIMER_CALLBACK(zx_tape_pulse) +TIMER_CALLBACK_MEMBER(zx_state::zx_tape_pulse) { - zx_state *state = machine.driver_data<zx_state>(); - state->m_tape_bit = 0x80; + m_tape_bit = 0x80; } READ8_MEMBER( zx_state::zx80_io_r ) @@ -138,7 +137,7 @@ READ8_MEMBER( zx_state::zx80_io_r ) if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit) { m_tape_bit = 0x00; - machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse)); + machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this)); } data &= ~m_tape_bit; @@ -195,7 +194,7 @@ READ8_MEMBER( zx_state::zx81_io_r ) if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit) { m_tape_bit = 0x00; - machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse)); + machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this)); } data &= ~m_tape_bit; @@ -259,7 +258,7 @@ READ8_MEMBER( zx_state::pc8300_io_r ) if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit) { m_tape_bit = 0x00; - machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse)); + machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this)); } data &= ~m_tape_bit; @@ -328,7 +327,7 @@ READ8_MEMBER( zx_state::pow3000_io_r ) if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit) { m_tape_bit = 0x00; - machine().scheduler().timer_set(attotime::from_usec(362), FUNC(zx_tape_pulse)); + machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this)); } data &= ~m_tape_bit; |