Clean up initialization, timer usage, memory management in several

drivers.
This commit is contained in:
Aaron Giles 2009-12-18 17:56:25 +00:00
parent 0baad6db2c
commit 21a522e0ee
12 changed files with 153 additions and 123 deletions

View File

@ -96,6 +96,22 @@ WRITE8_HANDLER( cinemat_sound_control_w )
*
*************************************/
static MACHINE_START( generic )
{
/* register for save states */
state_save_register_global(machine, sound_control);
state_save_register_global(machine, current_shift);
state_save_register_global(machine, last_shift);
state_save_register_global(machine, last_shift2);
state_save_register_global(machine, current_pitch);
state_save_register_global(machine, last_frame);
state_save_register_global_array(machine, sound_fifo);
state_save_register_global(machine, sound_fifo_in);
state_save_register_global(machine, sound_fifo_out);
state_save_register_global(machine, last_portb_write);
}
static void generic_init(running_machine *machine, void (*callback)(running_machine *,UINT8, UINT8))
{
/* call the standard init */
@ -117,18 +133,6 @@ static void generic_init(running_machine *machine, void (*callback)(running_mach
/* reset Star Castle pitch */
current_pitch = 0x10000;
/* register for save states */
state_save_register_global(machine, sound_control);
state_save_register_global(machine, current_shift);
state_save_register_global(machine, last_shift);
state_save_register_global(machine, last_shift2);
state_save_register_global(machine, current_pitch);
state_save_register_global(machine, last_frame);
state_save_register_global_array(machine, sound_fifo);
state_save_register_global(machine, sound_fifo_in);
state_save_register_global(machine, sound_fifo_out);
state_save_register_global(machine, last_portb_write);
}
@ -206,6 +210,7 @@ static MACHINE_RESET( spacewar )
}
MACHINE_DRIVER_START( spacewar_sound )
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(spacewar)
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -261,6 +266,7 @@ static MACHINE_RESET( barrier )
}
MACHINE_DRIVER_START( barrier_sound )
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(barrier)
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -321,6 +327,7 @@ static MACHINE_RESET( speedfrk )
}
MACHINE_DRIVER_START( speedfrk_sound )
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(speedfrk)
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -397,6 +404,7 @@ static MACHINE_RESET( starhawk )
}
MACHINE_DRIVER_START( starhawk_sound )
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(starhawk)
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -467,6 +475,7 @@ static MACHINE_RESET( sundance )
}
MACHINE_DRIVER_START( sundance_sound )
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(sundance)
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -556,6 +565,7 @@ static MACHINE_RESET( tailg )
}
MACHINE_DRIVER_START( tailg_sound )
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(tailg)
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -625,6 +635,7 @@ static MACHINE_RESET( warrior )
}
MACHINE_DRIVER_START( warrior_sound )
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(warrior)
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -720,6 +731,7 @@ static MACHINE_RESET( armora )
}
MACHINE_DRIVER_START( armora_sound )
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(armora)
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -812,6 +824,7 @@ static MACHINE_RESET( ripoff )
}
MACHINE_DRIVER_START( ripoff_sound )
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(ripoff)
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -925,6 +938,7 @@ static MACHINE_RESET( starcas )
}
MACHINE_DRIVER_START( starcas_sound )
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(starcas)
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -1061,6 +1075,7 @@ static MACHINE_RESET( solarq )
}
MACHINE_DRIVER_START( solarq_sound )
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(solarq)
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -1196,6 +1211,7 @@ static MACHINE_RESET( boxingb )
}
MACHINE_DRIVER_START( boxingb_sound )
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(boxingb)
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -1309,6 +1325,7 @@ static MACHINE_RESET( wotw )
}
MACHINE_DRIVER_START( wotw_sound )
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(wotw)
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -1422,6 +1439,7 @@ static MACHINE_RESET( wotwc )
}
MACHINE_DRIVER_START( wotwc_sound )
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(wotwc)
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -1577,6 +1595,7 @@ MACHINE_DRIVER_START( demon_sound )
MDRV_Z80CTC_ADD("ctc", 3579545 /* same as "audiocpu" */, demon_z80ctc_interface)
MDRV_MACHINE_START(generic)
MDRV_MACHINE_RESET(demon_sound)
/* sound hardware */

View File

@ -31,7 +31,7 @@ static UINT8 portA_in,portA_out,ddrA;
static UINT8 portB_in,portB_out,ddrB;
static UINT8 portC_in,portC_out,ddrC;
static UINT8 tdr,tcr;
static emu_timer *mcu_timer;
static const device_config *mcu_timer;
/* Port A:
0 (in) DSW
@ -147,14 +147,14 @@ static WRITE8_HANDLER( mcu_portC_ddr_w )
ddrC = data;
}
static TIMER_CALLBACK( mcu_timer_proc )
static TIMER_DEVICE_CALLBACK( mcu_timer_proc )
{
if ( --tdr == 0x00 )
{
if ( (tcr & 0x40) == 0 )
{
//timer interrupt!
generic_pulse_irq_line(cputag_get_cpu(machine, "mcu"), M68705_INT_TIMER);
generic_pulse_irq_line(cputag_get_cpu(timer->machine, "mcu"), M68705_INT_TIMER);
}
}
}
@ -202,7 +202,7 @@ static WRITE8_HANDLER( mcu_tcr_w )
}
period = attotime_mul(ATTOTIME_IN_HZ(3579545), divider);
timer_adjust_periodic( mcu_timer, period, 0, period);
timer_device_adjust_periodic( mcu_timer, period, 0, period);
}
}
@ -212,7 +212,7 @@ static MACHINE_RESET(supervisor_board)
portB_in = portB_out = ddrB = 0;
portC_in = portC_out = ddrC = 0;
tdr = tcr = 0;
mcu_timer = timer_alloc(machine, mcu_timer_proc , NULL);
mcu_timer = devtag_get_device(machine, "mcu_timer");
output_set_lamp_value(0, 0);
output_set_lamp_value(1, 0);
@ -437,6 +437,7 @@ static MACHINE_DRIVER_START( a600xl )
MDRV_CPU_PROGRAM_MAP(mcu_mem)
MDRV_PIA6821_ADD("pia", atarixl_pia_interface)
MDRV_TIMER_ADD("mcu_timer", mcu_timer_proc)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)

View File

@ -163,10 +163,10 @@ static int megadrive_region_pal;
static int megadrive_max_hposition;
static emu_timer* frame_timer;
static emu_timer* scanline_timer;
static emu_timer* irq6_on_timer;
static emu_timer* irq4_on_timer;
static const device_config* frame_timer;
static const device_config* scanline_timer;
static const device_config* irq6_on_timer;
static const device_config* irq4_on_timer;
static bitmap_t* render_bitmap;
//emu_timer* vblankirq_off_timer;
@ -3838,7 +3838,7 @@ VIDEO_UPDATE(megadriv)
// int xxx;
/* reference */
// time_elapsed_since_crap = timer_timeelapsed(frame_timer);
// time_elapsed_since_crap = timer_device_timeelapsed(frame_timer);
// xxx = cputag_attotime_to_clocks(screen->machine, "maincpu", time_elapsed_since_crap);
// mame_printf_debug("update cycles %d, %08x %08x\n",xxx, (UINT32)(time_elapsed_since_crap.attoseconds>>32),(UINT32)(time_elapsed_since_crap.attoseconds&0xffffffff));
@ -3847,7 +3847,7 @@ VIDEO_UPDATE(megadriv)
static TIMER_CALLBACK( frame_timer_callback )
static TIMER_DEVICE_CALLBACK( frame_timer_callback )
{
/* callback */
}
@ -5383,7 +5383,7 @@ INLINE UINT16 get_hposition(void)
attotime time_elapsed_since_scanline_timer;
UINT16 value4;
time_elapsed_since_scanline_timer = timer_timeelapsed(scanline_timer);
time_elapsed_since_scanline_timer = timer_device_timeelapsed(scanline_timer);
if (time_elapsed_since_scanline_timer.attoseconds<(ATTOSECONDS_PER_SECOND/megadriv_framerate /megadrive_total_scanlines))
{
@ -5671,24 +5671,24 @@ INLINE UINT16 get_hposition(void)
static int irq4counter;
static emu_timer* render_timer;
static const device_config* render_timer;
static TIMER_CALLBACK( render_timer_callback )
static TIMER_DEVICE_CALLBACK( render_timer_callback )
{
if (genesis_scanline_counter>=0 && genesis_scanline_counter<megadrive_visible_scanlines)
{
genesis_render_scanline(machine, genesis_scanline_counter);
genesis_render_scanline(timer->machine, genesis_scanline_counter);
}
}
static TIMER_CALLBACK( scanline_timer_callback )
static TIMER_DEVICE_CALLBACK( scanline_timer_callback )
{
/* This function is called at the very start of every scanline starting at the very
top-left of the screen. The first scanline is scanline 0 (we set scanline to -1 in
VIDEO_EOF) */
timer_call_after_resynch(machine, NULL, 0, 0);
timer_call_after_resynch(timer->machine, NULL, 0, 0);
/* Compensate for some rounding errors
When the counter reaches 261 we should have reached the end of the frame, however due
@ -5700,13 +5700,13 @@ static TIMER_CALLBACK( scanline_timer_callback )
{
genesis_scanline_counter++;
// mame_printf_debug("scanline %d\n",genesis_scanline_counter);
timer_adjust_oneshot(scanline_timer, attotime_div(ATTOTIME_IN_HZ(megadriv_framerate), megadrive_total_scanlines), 0);
timer_adjust_oneshot(render_timer, ATTOTIME_IN_USEC(1), 0);
timer_device_adjust_oneshot(scanline_timer, attotime_div(ATTOTIME_IN_HZ(megadriv_framerate), megadrive_total_scanlines), 0);
timer_device_adjust_oneshot(render_timer, ATTOTIME_IN_USEC(1), 0);
if (genesis_scanline_counter==megadrive_irq6_scanline )
{
// mame_printf_debug("x %d",genesis_scanline_counter);
timer_adjust_oneshot(irq6_on_timer, ATTOTIME_IN_USEC(6), 0);
timer_device_adjust_oneshot(irq6_on_timer, ATTOTIME_IN_USEC(6), 0);
megadrive_irq6_pending = 1;
megadrive_vblank_flag = 1;
@ -5743,7 +5743,7 @@ static TIMER_CALLBACK( scanline_timer_callback )
if (MEGADRIVE_REG0_IRQ4_ENABLE)
{
timer_adjust_oneshot(irq4_on_timer, ATTOTIME_IN_USEC(1), 0);
timer_device_adjust_oneshot(irq4_on_timer, ATTOTIME_IN_USEC(1), 0);
//mame_printf_debug("irq4 on scanline %d reload %d\n",genesis_scanline_counter,MEGADRIVE_REG0A_HINT_VALUE);
}
}
@ -5754,21 +5754,21 @@ static TIMER_CALLBACK( scanline_timer_callback )
else irq4counter=MEGADRIVE_REG0A_HINT_VALUE;
}
//if (genesis_scanline_counter==0) timer_adjust_oneshot(irq4_on_timer, ATTOTIME_IN_USEC(2), 0);
//if (genesis_scanline_counter==0) timer_device_adjust_oneshot(irq4_on_timer, ATTOTIME_IN_USEC(2), 0);
if (cputag_get_cpu(machine, "genesis_snd_z80") != NULL)
if (cputag_get_cpu(timer->machine, "genesis_snd_z80") != NULL)
{
if (genesis_scanline_counter == megadrive_z80irq_scanline)
{
if ((genz80.z80_has_bus == 1) && (genz80.z80_is_reset == 0))
cputag_set_input_line(machine, "genesis_snd_z80", 0, HOLD_LINE);
cputag_set_input_line(timer->machine, "genesis_snd_z80", 0, HOLD_LINE);
}
if (genesis_scanline_counter == megadrive_z80irq_scanline + 1)
{
cputag_set_input_line(machine, "genesis_snd_z80", 0, CLEAR_LINE);
cputag_set_input_line(timer->machine, "genesis_snd_z80", 0, CLEAR_LINE);
}
}
@ -5780,21 +5780,21 @@ static TIMER_CALLBACK( scanline_timer_callback )
}
static TIMER_CALLBACK( irq6_on_callback )
static TIMER_DEVICE_CALLBACK( irq6_on_callback )
{
//mame_printf_debug("irq6 active on %d\n",genesis_scanline_counter);
{
// megadrive_irq6_pending = 1;
if (MEGADRIVE_REG01_IRQ6_ENABLE || genesis_always_irq6)
cputag_set_input_line(machine, "maincpu", 6, HOLD_LINE);
cputag_set_input_line(timer->machine, "maincpu", 6, HOLD_LINE);
}
}
static TIMER_CALLBACK( irq4_on_callback )
static TIMER_DEVICE_CALLBACK( irq4_on_callback )
{
//mame_printf_debug("irq4 active on %d\n",genesis_scanline_counter);
cputag_set_input_line(machine, "maincpu", 4, HOLD_LINE);
cputag_set_input_line(timer->machine, "maincpu", 4, HOLD_LINE);
}
/*****************************************************************************************/
@ -5855,15 +5855,15 @@ MACHINE_RESET( megadriv )
megadrive_init_io(machine);
frame_timer = timer_alloc(machine, frame_timer_callback, NULL);
scanline_timer = timer_alloc(machine, scanline_timer_callback, NULL);
render_timer = timer_alloc(machine, render_timer_callback, NULL);
frame_timer = devtag_get_device(machine, "frame_timer");
scanline_timer = devtag_get_device(machine, "scanline_timer");
render_timer = devtag_get_device(machine, "render_timer");
irq6_on_timer = timer_alloc(machine, irq6_on_callback, NULL);
irq4_on_timer = timer_alloc(machine, irq4_on_callback, NULL);
irq6_on_timer = devtag_get_device(machine, "irq6_timer");
irq4_on_timer = devtag_get_device(machine, "irq4_timer");
timer_adjust_oneshot(frame_timer, attotime_zero, 0);
timer_adjust_oneshot(scanline_timer, attotime_zero, 0);
timer_device_adjust_oneshot(frame_timer, attotime_zero, 0);
timer_device_adjust_oneshot(scanline_timer, attotime_zero, 0);
if (genesis_other_hacks)
{
@ -5902,7 +5902,7 @@ MACHINE_RESET( megadriv )
void megadriv_stop_scanline_timer(void)
{
timer_adjust_oneshot(scanline_timer, attotime_never, 0);
timer_device_adjust_oneshot(scanline_timer, attotime_never, 0);
}
/*
@ -6014,14 +6014,14 @@ int megadrive_z80irq_hpos = 320;
// /* reference */
frametime = ATTOSECONDS_PER_SECOND/megadriv_framerate;
//time_elapsed_since_crap = timer_timeelapsed(frame_timer);
//time_elapsed_since_crap = timer_device_timeelapsed(frame_timer);
//xxx = cputag_attotime_to_clocks(machine, "maincpu",time_elapsed_since_crap);
//mame_printf_debug("---------- cycles %d, %08x %08x\n",xxx, (UINT32)(time_elapsed_since_crap.attoseconds>>32),(UINT32)(time_elapsed_since_crap.attoseconds&0xffffffff));
//mame_printf_debug("---------- framet %d, %08x %08x\n",xxx, (UINT32)(frametime>>32),(UINT32)(frametime&0xffffffff));
timer_adjust_oneshot(frame_timer, attotime_zero, 0);
timer_device_adjust_oneshot(frame_timer, attotime_zero, 0);
}
timer_adjust_oneshot(scanline_timer, attotime_zero, 0);
timer_device_adjust_oneshot(scanline_timer, attotime_zero, 0);
}
@ -6066,6 +6066,12 @@ MACHINE_DRIVER_START( megadriv )
MDRV_MACHINE_RESET(megadriv)
MDRV_TIMER_ADD("frame_timer", frame_timer_callback)
MDRV_TIMER_ADD("scanline_timer", scanline_timer_callback)
MDRV_TIMER_ADD("render_timer", render_timer_callback)
MDRV_TIMER_ADD("irq6_timer", irq6_on_callback)
MDRV_TIMER_ADD("irq4_timer", irq4_on_callback)
MDRV_SCREEN_ADD("megadriv", RASTER)
MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB15)
MDRV_SCREEN_REFRESH_RATE(60)
@ -6110,6 +6116,12 @@ MACHINE_DRIVER_START( megadpal )
MDRV_MACHINE_RESET(megadriv)
MDRV_TIMER_ADD("frame_timer", frame_timer_callback)
MDRV_TIMER_ADD("scanline_timer", scanline_timer_callback)
MDRV_TIMER_ADD("render_timer", render_timer_callback)
MDRV_TIMER_ADD("irq6_timer", irq6_on_callback)
MDRV_TIMER_ADD("irq4_timer", irq4_on_callback)
MDRV_SCREEN_ADD("megadriv", RASTER)
MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB15)
MDRV_SCREEN_REFRESH_RATE(50)

View File

@ -1601,7 +1601,7 @@ static WRITE8_HANDLER( mt_sms_standard_rom_bank_w )
}
else
{
memory_install_read_bank(space, 0x0000, 0xbfff, 0, 0, "bank5");
memory_install_rom(space, 0x0000, 0xbfff, 0, 0, sms_rom);
memory_unmap_write(space, 0x0000, 0xbfff, 0, 0);
}
@ -1674,15 +1674,13 @@ void megatech_set_genz80_as_sms_standard_map(running_machine *machine, const cha
megatech_set_genz80_as_sms_standard_ports(machine, tag);
/* fixed rom bank area */
sms_rom = memory_install_rom(cputag_get_address_space(machine, tag, ADDRESS_SPACE_PROGRAM), 0x0000, 0xbfff, 0, 0, NULL);
memcpy(sms_rom, memory_region(machine, "maincpu"), 0xc000);
if (mapper == MAPPER_STANDARD )
{
/* fixed rom bank area */
sms_rom = auto_alloc_array(machine, UINT8, 0x400000);
memory_install_read_bank(cputag_get_address_space(machine, tag, ADDRESS_SPACE_PROGRAM), 0x0000, 0xbfff, 0, 0, "bank5");
memory_unmap_write(cputag_get_address_space(machine, tag, ADDRESS_SPACE_PROGRAM), 0x0000, 0xbfff, 0, 0);
memory_set_bankptr(machine, "bank5", sms_rom );
memcpy(sms_rom, memory_region(machine, "maincpu"), 0x400000);
memory_install_write8_handler(cputag_get_address_space(machine, tag, ADDRESS_SPACE_PROGRAM), 0xfffc, 0xffff, 0, 0, mt_sms_standard_rom_bank_w);
@ -1690,14 +1688,6 @@ void megatech_set_genz80_as_sms_standard_map(running_machine *machine, const cha
}
else if (mapper == MAPPER_CODEMASTERS )
{
/* fixed rom bank area */
sms_rom = auto_alloc_array(machine, UINT8, 0xc000);
memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, 0xbfff, 0, 0, "bank5");
memory_unmap_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, 0xbfff, 0, 0);
memory_set_bankptr(machine, "bank5", sms_rom );
memcpy(sms_rom, memory_region(machine, "maincpu"), 0xc000);
memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, 0x0000, 0, 0, codemasters_rom_bank_0000_w);
memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x4000, 0x4000, 0, 0, codemasters_rom_bank_4000_w);
memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0x8000, 0, 0, codemasters_rom_bank_8000_w);

View File

@ -790,24 +790,24 @@ static UINT16 irq_timera;
static UINT8 irq_timerb;
static UINT8 irq_allow0, irq_allow1;
static int irq_timer_pend0, irq_timer_pend1, irq_yms, irq_vblank, irq_sprite;
static emu_timer *irq_timer, *irq_timer_clear;
static const device_config *irq_timer, *irq_timer_clear;
static TIMER_CALLBACK( irq_timer_cb )
static TIMER_DEVICE_CALLBACK( irq_timer_cb )
{
irq_timer_pend0 = irq_timer_pend1 = 1;
if(irq_allow0 & (1 << IRQ_TIMER))
cputag_set_input_line(machine, "maincpu", IRQ_TIMER+1, ASSERT_LINE);
cputag_set_input_line(timer->machine, "maincpu", IRQ_TIMER+1, ASSERT_LINE);
if(irq_allow1 & (1 << IRQ_TIMER))
cputag_set_input_line(machine, "sub", IRQ_TIMER+1, ASSERT_LINE);
cputag_set_input_line(timer->machine, "sub", IRQ_TIMER+1, ASSERT_LINE);
}
static TIMER_CALLBACK( irq_timer_clear_cb )
static TIMER_DEVICE_CALLBACK( irq_timer_clear_cb )
{
irq_sprite = irq_vblank = 0;
cputag_set_input_line(machine, "maincpu", IRQ_VBLANK+1, CLEAR_LINE);
cputag_set_input_line(machine, "maincpu", IRQ_SPRITE+1, CLEAR_LINE);
cputag_set_input_line(machine, "sub", IRQ_VBLANK+1, CLEAR_LINE);
cputag_set_input_line(machine, "sub", IRQ_SPRITE+1, CLEAR_LINE);
cputag_set_input_line(timer->machine, "maincpu", IRQ_VBLANK+1, CLEAR_LINE);
cputag_set_input_line(timer->machine, "maincpu", IRQ_SPRITE+1, CLEAR_LINE);
cputag_set_input_line(timer->machine, "sub", IRQ_VBLANK+1, CLEAR_LINE);
cputag_set_input_line(timer->machine, "sub", IRQ_SPRITE+1, CLEAR_LINE);
}
static void irq_init(running_machine *machine)
@ -820,8 +820,8 @@ static void irq_init(running_machine *machine)
irq_timer_pend1 = 0;
irq_vblank = 0;
irq_sprite = 0;
irq_timer = timer_alloc(machine, irq_timer_cb, NULL);
irq_timer_clear = timer_alloc(machine, irq_timer_clear_cb, NULL);
irq_timer = devtag_get_device(machine, "irq_timer");
irq_timer_clear = devtag_get_device(machine, "irq_timer_clear");
}
static void irq_timer_reset(void)
@ -829,7 +829,7 @@ static void irq_timer_reset(void)
int freq = (irq_timerb << 12) | irq_timera;
freq &= 0x1fff;
timer_adjust_periodic(irq_timer, ATTOTIME_IN_HZ(freq), 0, ATTOTIME_IN_HZ(freq));
timer_device_adjust_periodic(irq_timer, ATTOTIME_IN_HZ(freq), 0, ATTOTIME_IN_HZ(freq));
logerror("New timer frequency: %0d [%02x %04x]\n", freq, irq_timerb, irq_timera);
}
@ -916,7 +916,7 @@ static INTERRUPT_GEN(irq_vbl)
irq_vblank = 1;
}
timer_adjust_oneshot(irq_timer_clear, ATTOTIME_IN_HZ(VIDEO_CLOCK/2/656.0), 0);
timer_device_adjust_oneshot(irq_timer_clear, ATTOTIME_IN_HZ(VIDEO_CLOCK/2/656.0), 0);
mask = 1 << irq;
@ -1787,6 +1787,9 @@ static MACHINE_DRIVER_START( system24 )
MDRV_MACHINE_START(system24)
MDRV_MACHINE_RESET(system24)
MDRV_TIMER_ADD("irq_timer", irq_timer_cb)
MDRV_TIMER_ADD("irq_timer_clear", irq_timer_clear_cb)
MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK)
MDRV_SCREEN_ADD("screen", RASTER)

View File

@ -376,7 +376,7 @@ static UINT8 *z80_shared_ram;
/* V60 interrupt controller */
static UINT8 v60_irq_control[0x10];
static emu_timer *v60_irq_timer[2];
static const device_config *v60_irq_timer[2];
/* sound interrupt controller */
static UINT8 sound_irq_control[4];
@ -403,7 +403,6 @@ static void (*system32_prot_vblank)(const device_config *device);
*************************************/
static void signal_v60_irq(running_machine *machine, int data);
static TIMER_CALLBACK( signal_v60_irq_callback );
static void signal_sound_irq(running_machine *machine, int which);
@ -420,8 +419,8 @@ static MACHINE_RESET( system32 )
memset(v60_irq_control, 0xff, sizeof(v60_irq_control));
/* allocate timers */
v60_irq_timer[0] = timer_alloc(machine, signal_v60_irq_callback, NULL);
v60_irq_timer[1] = timer_alloc(machine, signal_v60_irq_callback, NULL);
v60_irq_timer[0] = devtag_get_device(machine, "v60_irq0");
v60_irq_timer[1] = devtag_get_device(machine, "v60_irq1");
/* clear IRQ lines */
cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE);
@ -467,9 +466,9 @@ static void signal_v60_irq(running_machine *machine, int which)
}
static TIMER_CALLBACK( signal_v60_irq_callback )
static TIMER_DEVICE_CALLBACK( signal_v60_irq_callback )
{
signal_v60_irq(machine, param);
signal_v60_irq(timer->machine, param);
}
@ -509,7 +508,7 @@ static void int_control_w(const address_space *space, int offset, UINT8 data)
if (duration)
{
attotime period = attotime_make(0, attotime_to_attoseconds(ATTOTIME_IN_HZ(TIMER_0_CLOCK)) * duration);
timer_adjust_oneshot(v60_irq_timer[0], period, MAIN_IRQ_TIMER0);
timer_device_adjust_oneshot(v60_irq_timer[0], period, MAIN_IRQ_TIMER0);
}
break;
@ -520,7 +519,7 @@ static void int_control_w(const address_space *space, int offset, UINT8 data)
if (duration)
{
attotime period = attotime_make(0, attotime_to_attoseconds(ATTOTIME_IN_HZ(TIMER_1_CLOCK)) * duration);
timer_adjust_oneshot(v60_irq_timer[1], period, MAIN_IRQ_TIMER1);
timer_device_adjust_oneshot(v60_irq_timer[1], period, MAIN_IRQ_TIMER1);
}
break;
@ -2190,6 +2189,9 @@ static MACHINE_DRIVER_START( system32 )
MDRV_MACHINE_RESET(system32)
MDRV_NVRAM_HANDLER(system32)
MDRV_TIMER_ADD("v60_irq0", signal_v60_irq_callback)
MDRV_TIMER_ADD("v60_irq1", signal_v60_irq_callback)
/* video hardware */
MDRV_GFXDECODE(segas32)
MDRV_PALETTE_LENGTH(0x4000)

View File

@ -55,7 +55,7 @@ static UINT8 timer_irq_state;
static UINT16 *backupram;
static emu_timer *interrupt_timer;
static const device_config *interrupt_timer;
@ -133,7 +133,7 @@ static void update_main_irqs(running_machine *machine)
static int irq2_scanline = 170;
static TIMER_CALLBACK( scanline_callback )
static TIMER_DEVICE_CALLBACK( scanline_callback )
{
int scanline = param;
@ -166,10 +166,10 @@ static TIMER_CALLBACK( scanline_callback )
}
/* update IRQs on the main CPU */
update_main_irqs(machine);
update_main_irqs(timer->machine);
/* come back at the next appropriate scanline */
timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline);
timer_device_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0), scanline);
#if TWEAK_IRQ2_SCANLINE
if (scanline == 223)
@ -177,10 +177,10 @@ static TIMER_CALLBACK( scanline_callback )
int old = irq2_scanline;
/* Q = -10 scanlines, W = -1 scanline, E = +1 scanline, R = +10 scanlines */
if (input_code_pressed(machine, KEYCODE_Q)) { while (input_code_pressed(machine, KEYCODE_Q)) ; irq2_scanline -= 10; }
if (input_code_pressed(machine, KEYCODE_W)) { while (input_code_pressed(machine, KEYCODE_W)) ; irq2_scanline -= 1; }
if (input_code_pressed(machine, KEYCODE_E)) { while (input_code_pressed(machine, KEYCODE_E)) ; irq2_scanline += 1; }
if (input_code_pressed(machine, KEYCODE_R)) { while (input_code_pressed(machine, KEYCODE_R)) ; irq2_scanline += 10; }
if (input_code_pressed(timer->machine, KEYCODE_Q)) { while (input_code_pressed(timer->machine, KEYCODE_Q)) ; irq2_scanline -= 10; }
if (input_code_pressed(timer->machine, KEYCODE_W)) { while (input_code_pressed(timer->machine, KEYCODE_W)) ; irq2_scanline -= 1; }
if (input_code_pressed(timer->machine, KEYCODE_E)) { while (input_code_pressed(timer->machine, KEYCODE_E)) ; irq2_scanline += 1; }
if (input_code_pressed(timer->machine, KEYCODE_R)) { while (input_code_pressed(timer->machine, KEYCODE_R)) ; irq2_scanline += 10; }
if (old != irq2_scanline)
popmessage("scanline = %d", irq2_scanline);
}
@ -188,11 +188,8 @@ static TIMER_CALLBACK( scanline_callback )
}
static MACHINE_RESET( yboard )
static MACHINE_START( yboard )
{
interrupt_timer = timer_alloc(machine, scanline_callback, NULL);
timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 223, 0), 223);
state_save_register_global_array(machine, misc_io_data);
state_save_register_global_array(machine, analog_data);
state_save_register_global(machine, vblank_irq_state);
@ -200,6 +197,13 @@ static MACHINE_RESET( yboard )
}
static MACHINE_RESET( yboard )
{
interrupt_timer = devtag_get_device(machine, "int_timer");
timer_device_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 223, 0), 223);
}
/*************************************
*
@ -980,10 +984,13 @@ static MACHINE_DRIVER_START( yboard )
MDRV_CPU_PROGRAM_MAP(sound_map)
MDRV_CPU_IO_MAP(sound_portmap)
MDRV_MACHINE_START(yboard)
MDRV_MACHINE_RESET(yboard)
MDRV_NVRAM_HANDLER(yboard)
MDRV_QUANTUM_TIME(HZ(6000))
MDRV_TIMER_ADD("int_timer", scanline_callback)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)

View File

@ -284,9 +284,8 @@ Stephh's notes (based on the games M6502 code and some tests) :
/* binary counter (1.4MHz update) */
static UINT8 sasuke_counter;
static emu_timer *sasuke_timer;
static TIMER_CALLBACK( sasuke_update_counter )
static TIMER_DEVICE_CALLBACK( sasuke_update_counter )
{
sasuke_counter += 0x10;
}
@ -294,9 +293,6 @@ static TIMER_CALLBACK( sasuke_update_counter )
static void sasuke_start_counter(running_machine *machine)
{
sasuke_counter = 0;
sasuke_timer = timer_alloc(machine, sasuke_update_counter, NULL);
timer_adjust_periodic(sasuke_timer, attotime_zero, 0, ATTOTIME_IN_HZ(MASTER_CLOCK / 8)); // 1.4 MHz
}
@ -847,6 +843,8 @@ static MACHINE_DRIVER_START( sasuke )
MDRV_MC6845_ADD("crtc", MC6845, MASTER_CLOCK / 16, mc6845_intf)
MDRV_TIMER_ADD_PERIODIC("sasuke_timer", sasuke_update_counter, HZ(MASTER_CLOCK / 8)) // 1.4 MHz
// sound hardware
MDRV_SPEAKER_STANDARD_MONO("mono")

View File

@ -276,7 +276,6 @@ static UINT8 color_ram[0x0400];
static UINT16 p1, p2;
static UINT8 t0_latch;
static UINT16 n_offs;
static emu_timer *t1_timer;
static UINT8 vp_sound_p2;
static UINT8 p24_data;
@ -856,7 +855,7 @@ static WRITE8_DEVICE_HANDLER(baby_sound_p3_w)
}
static TIMER_CALLBACK(sound_t1_callback)
static TIMER_DEVICE_CALLBACK(sound_t1_callback)
{
if (te_40103 == 1)
{
@ -864,7 +863,7 @@ static TIMER_CALLBACK(sound_t1_callback)
if (dc_40103 == 0)
{
cputag_set_input_line(machine, "soundcpu", 0, ASSERT_LINE);
cputag_set_input_line(timer->machine, "soundcpu", 0, ASSERT_LINE);
}
}
}
@ -1136,8 +1135,6 @@ static MACHINE_START(videopkr)
p1 = 0xff;
ant_cio = 0;
count0 = 0;
t1_timer = timer_alloc(machine, sound_t1_callback, NULL);
timer_adjust_periodic(t1_timer, attotime_zero, 0, ATTOTIME_IN_HZ(50)); /* 50Hz. */
}
static const ay8910_interface ay8910_config =
@ -1170,6 +1167,8 @@ static MACHINE_DRIVER_START( videopkr )
MDRV_MACHINE_START(videopkr)
MDRV_NVRAM_HANDLER(videopkr)
MDRV_TIMER_ADD_PERIODIC("t1_timer", sound_t1_callback, HZ(50))
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)

View File

@ -1336,6 +1336,7 @@ static TIMER_CALLBACK(dc_rtc_increment)
MACHINE_START( dc )
{
dc_rtc_timer = timer_alloc(machine, dc_rtc_increment, 0);
}
MACHINE_RESET( dc )
@ -1348,7 +1349,6 @@ MACHINE_RESET( dc )
memset(dc_rtcregister, 0, sizeof(dc_rtcregister));
memset(dc_coin_counts, 0, sizeof(dc_coin_counts));
dc_rtc_timer = timer_alloc(machine, dc_rtc_increment, 0);
timer_adjust_periodic(dc_rtc_timer, attotime_zero, 0, ATTOTIME_IN_SEC(1));
dc_sysctrl_regs[SB_SBREV] = 0x0b;

View File

@ -2001,6 +2001,8 @@ MACHINE_START( n64 )
rspdrc_add_imem(cputag_get_cpu(machine, "rsp"), rsp_imem);
rspdrc_add_dmem(cputag_get_cpu(machine, "rsp"), rsp_dmem);
rspdrc_flush_drc_cache(cputag_get_cpu(machine, "rsp"));
audio_timer = timer_alloc(machine, audio_timer_callback, NULL);
}
MACHINE_RESET( n64 )
@ -2060,7 +2062,6 @@ MACHINE_RESET( n64 )
cic_status = 0;
audio_timer = timer_alloc(machine, audio_timer_callback, NULL);
timer_adjust_oneshot(audio_timer, attotime_never, 0);
cputag_set_input_line(machine, "rsp", INPUT_LINE_HALT, ASSERT_LINE);

View File

@ -837,16 +837,7 @@ MallocSceneNode( running_machine *machine )
}
else
{
#define SCENE_NODE_POOL_SIZE 64
struct SceneNode *pSceneNodePool = auto_alloc_array(machine, struct SceneNode, SCENE_NODE_POOL_SIZE);
{
int i;
for( i=0; i<SCENE_NODE_POOL_SIZE; i++ )
{
FreeSceneNode( &pSceneNodePool[i] );
}
return MallocSceneNode(machine);
}
node = alloc_or_die(struct SceneNode);
}
memset( node, 0, sizeof(*node) );
return node;
@ -2208,6 +2199,13 @@ static void namcos22_reset(running_machine *machine)
static void namcos22_exit(running_machine *machine)
{
while (mpFreeSceneNode != NULL)
{
struct SceneNode *node = mpFreeSceneNode;
mpFreeSceneNode = node->nextInBucket;
free(node);
}
poly_free(poly);
}