From 61ccf0d8016e03997cad0926301b15eb3da06e62 Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Thu, 13 Apr 2017 18:30:47 +0200 Subject: [PATCH] more anonymous timers work (nw) --- src/mame/drivers/gunbustr.cpp | 8 +++++--- src/mame/drivers/midzeus.cpp | 10 ++++++---- src/mame/drivers/nightgal.cpp | 5 ++++- src/mame/drivers/opwolf.cpp | 4 +++- src/mame/drivers/othunder.cpp | 4 +++- src/mame/drivers/policetr.cpp | 6 +++++- src/mame/drivers/rollerg.cpp | 4 +++- src/mame/drivers/tehkanwc.cpp | 4 +++- src/mame/drivers/thunderx.cpp | 24 ++++++++++++++---------- src/mame/drivers/trucocl.cpp | 4 +++- src/mame/includes/gunbustr.h | 1 + src/mame/includes/midzeus.h | 2 ++ src/mame/includes/opwolf.h | 2 ++ src/mame/includes/othunder.h | 1 + src/mame/includes/policetr.h | 2 ++ src/mame/includes/rollerg.h | 1 + src/mame/includes/tehkanwc.h | 1 + src/mame/includes/thunderx.h | 2 ++ src/mame/includes/trucocl.h | 2 ++ src/mame/machine/opwolf.cpp | 2 +- 20 files changed, 64 insertions(+), 25 deletions(-) diff --git a/src/mame/drivers/gunbustr.cpp b/src/mame/drivers/gunbustr.cpp index 5fa812e813f..e8fe44a9b02 100644 --- a/src/mame/drivers/gunbustr.cpp +++ b/src/mame/drivers/gunbustr.cpp @@ -36,7 +36,7 @@ Todo: - FLIPX support in taitoic.c is not quite correct - the Taito logo is wrong, + FLIPX support in the video chips is not quite correct - the Taito logo is wrong, and the floor in the Doom levels has horizontal scrolling where it shouldn't. No networked machine support @@ -69,7 +69,7 @@ void gunbustr_state::device_timer(emu_timer &timer, device_timer_id id, int para INTERRUPT_GEN_MEMBER(gunbustr_state::gunbustr_interrupt) { - timer_set(downcast(&device)->cycles_to_attotime(200000-500), TIMER_GUNBUSTR_INTERRUPT5); + m_interrupt5_timer->adjust(m_maincpu->cycles_to_attotime(200000-500)); device.execute().set_input_line(4, HOLD_LINE); } @@ -140,7 +140,7 @@ READ32_MEMBER(gunbustr_state::gunbustr_gun_r) WRITE32_MEMBER(gunbustr_state::gunbustr_gun_w) { /* 10000 cycle delay is arbitrary */ - timer_set(downcast(&space.device())->cycles_to_attotime(10000), TIMER_GUNBUSTR_INTERRUPT5); + m_interrupt5_timer->adjust(m_maincpu->cycles_to_attotime(10000)); } @@ -428,6 +428,8 @@ DRIVER_INIT_MEMBER(gunbustr_state,gunbustr) { /* Speedup handler */ m_maincpu->space(AS_PROGRAM).install_read_handler(0x203acc, 0x203acf, read32_delegate(FUNC(gunbustr_state::main_cycle_r),this)); + + m_interrupt5_timer = timer_alloc(TIMER_GUNBUSTR_INTERRUPT5); } DRIVER_INIT_MEMBER(gunbustr_state,gunbustrj) diff --git a/src/mame/drivers/midzeus.cpp b/src/mame/drivers/midzeus.cpp index 7e05ec50d03..a01338ebdc3 100644 --- a/src/mame/drivers/midzeus.cpp +++ b/src/mame/drivers/midzeus.cpp @@ -88,8 +88,10 @@ MACHINE_START_MEMBER(midzeus_state,midzeus) timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate()); timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate()); - gun_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(midzeus_state::invasn_gun_callback),this)); - gun_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(midzeus_state::invasn_gun_callback),this)); + gun_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(midzeus_state::invasn_gun_callback), this)); + gun_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(midzeus_state::invasn_gun_callback), this)); + + m_display_irq_off_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(midzeus_state::display_irq_off), this)); save_item(NAME(gun_control)); save_item(NAME(gun_irq_state)); @@ -125,7 +127,7 @@ TIMER_CALLBACK_MEMBER(midzeus_state::display_irq_off) INTERRUPT_GEN_MEMBER(midzeus_state::display_irq) { device.execute().set_input_line(0, ASSERT_LINE); - machine().scheduler().timer_set(attotime::from_hz(30000000), timer_expired_delegate(FUNC(midzeus_state::display_irq_off),this)); + m_display_irq_off_timer->adjust(attotime::from_hz(30000000)); } WRITE_LINE_MEMBER(midzeus2_state::zeus_irq) @@ -1109,7 +1111,7 @@ static MACHINE_CONFIG_START( midzeus, midzeus_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", TMS32032, CPU_CLOCK) MCFG_CPU_PROGRAM_MAP(zeus_map) - MCFG_CPU_VBLANK_INT_DRIVER("screen", midzeus_state, display_irq) + MCFG_CPU_VBLANK_INT_DRIVER("screen", midzeus_state, display_irq) MCFG_MACHINE_START_OVERRIDE(midzeus_state,midzeus) MCFG_MACHINE_RESET_OVERRIDE(midzeus_state,midzeus) diff --git a/src/mame/drivers/nightgal.cpp b/src/mame/drivers/nightgal.cpp index 1d1186222a9..c2308b13ce9 100644 --- a/src/mame/drivers/nightgal.cpp +++ b/src/mame/drivers/nightgal.cpp @@ -67,6 +67,7 @@ public: uint8_t m_nsc_latch; uint8_t m_z80_latch; uint8_t m_mux_data; + emu_timer *m_z80_wait_ack_timer; required_shared_ptr m_comms_ram; @@ -235,7 +236,7 @@ void nightgal_state::z80_wait_assert_cb() // Note: cycles_to_attotime requires z80 context to work, calling for example m_subcpu as context gives a x4 cycle boost in z80 terms (reads execute_cycles_to_clocks() from NCS?) even if they runs at same speed basically. // TODO: needs a getter that tells a given CPU how many cycles requires an executing opcode for the r/w operation, which stacks with wait state penalty for accessing this specific area. - machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(4), timer_expired_delegate(FUNC(nightgal_state::z80_wait_ack_cb),this)); + m_z80_wait_ack_timer->adjust(m_maincpu->cycles_to_attotime(4)); } READ8_MEMBER(nightgal_state::royalqn_comm_r) @@ -634,6 +635,8 @@ INPUT_PORTS_END void nightgal_state::machine_start() { + m_z80_wait_ack_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(nightgal_state::z80_wait_ack_cb), this)); + save_item(NAME(m_nsc_latch)); save_item(NAME(m_z80_latch)); save_item(NAME(m_mux_data)); diff --git a/src/mame/drivers/opwolf.cpp b/src/mame/drivers/opwolf.cpp index 2041f3529a9..c33baaebc5d 100644 --- a/src/mame/drivers/opwolf.cpp +++ b/src/mame/drivers/opwolf.cpp @@ -246,7 +246,7 @@ Stephh's notes (based on the game M68000 code and some tests) : * all reference to TAITO and "Operation Wolf" have been changed or "blanked" * "(c) 1988 BEAR CORPORATION KOREA" / "ALL RIGHTS RESERVED" * ROM check test "noped" (code at 0x00bb72) - - Notes on bootleg c-chip (similar to what is in machine/opwolf.c) : + - Notes on bootleg c-chip (similar to what is in machine/opwolf.cpp) : * always Engish language (thus the Dip Switch change to "Unused") * round 4 in "demo mode" instead of round 5 * "service" button doesn't add credits (it works in the "test mode" though) @@ -439,6 +439,8 @@ ADDRESS_MAP_END void opwolf_state::machine_start() { + m_opwolf_timer = timer_alloc(TIMER_OPWOLF); + save_item(NAME(m_sprite_ctrl)); save_item(NAME(m_sprites_flipscreen)); diff --git a/src/mame/drivers/othunder.cpp b/src/mame/drivers/othunder.cpp index 8efd0b53ac8..220a6cd735f 100644 --- a/src/mame/drivers/othunder.cpp +++ b/src/mame/drivers/othunder.cpp @@ -423,7 +423,7 @@ WRITE16_MEMBER(othunder_state::othunder_lightgun_w) The ADC60808 clock is 512kHz. Conversion takes between 0 and 8 clock cycles, so would end in a maximum of 15.625us. We'll use 10. */ - timer_set(attotime::from_usec(10), TIMER_AD_INTERRUPT); + m_ad_interrupt_timer->adjust(attotime::from_usec(10)); } @@ -662,6 +662,8 @@ void othunder_state::machine_start() { membank("z80bank")->configure_entries(0, 4, memregion("audiocpu")->base(), 0x4000); + m_ad_interrupt_timer = timer_alloc(TIMER_AD_INTERRUPT); + save_item(NAME(m_vblank_irq)); save_item(NAME(m_ad_irq)); save_item(NAME(m_pan)); diff --git a/src/mame/drivers/policetr.cpp b/src/mame/drivers/policetr.cpp index 4b5a7f55f37..998076fb28c 100644 --- a/src/mame/drivers/policetr.cpp +++ b/src/mame/drivers/policetr.cpp @@ -121,7 +121,7 @@ void policetr_state::device_timer(emu_timer &timer, device_timer_id id, int para INTERRUPT_GEN_MEMBER(policetr_state::irq4_gen) { device.execute().set_input_line(R3000_IRQ4, ASSERT_LINE); - timer_set(m_screen->time_until_pos(0), TIMER_IRQ5_GEN); + m_irq5_gen_timer->adjust(m_screen->time_until_pos(0)); } @@ -386,6 +386,10 @@ static INPUT_PORTS_START( sshoot11 ) INPUT_PORTS_END +void policetr_state::machine_start() +{ + m_irq5_gen_timer = timer_alloc(TIMER_IRQ5_GEN); +} /************************************* * diff --git a/src/mame/drivers/rollerg.cpp b/src/mame/drivers/rollerg.cpp index 343b58fd5c6..668d261795e 100644 --- a/src/mame/drivers/rollerg.cpp +++ b/src/mame/drivers/rollerg.cpp @@ -69,7 +69,7 @@ void rollerg_state::device_timer(emu_timer &timer, device_timer_id id, int param WRITE8_MEMBER(rollerg_state::sound_arm_nmi_w) { m_audiocpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); - timer_set(attotime::from_usec(50), TIMER_NMI); /* kludge until the K053260 is emulated correctly */ + m_nmi_timer->adjust(attotime::from_usec(50)); /* kludge until the K053260 is emulated correctly */ } READ8_MEMBER(rollerg_state::pip_r) @@ -226,6 +226,8 @@ void rollerg_state::machine_start() membank("bank1")->configure_entries(6, 2, &ROM[0x10000], 0x4000); membank("bank1")->set_entry(0); + m_nmi_timer = timer_alloc(TIMER_NMI); + save_item(NAME(m_readzoomroms)); } diff --git a/src/mame/drivers/tehkanwc.cpp b/src/mame/drivers/tehkanwc.cpp index 9c6eba4621d..d6a168d509c 100644 --- a/src/mame/drivers/tehkanwc.cpp +++ b/src/mame/drivers/tehkanwc.cpp @@ -102,6 +102,8 @@ TO DO : void tehkanwc_state::machine_start() { + m_reset_timer = timer_alloc(TIMER_RESET); + save_item(NAME(m_track0)); save_item(NAME(m_track1)); save_item(NAME(m_msm_data_offs)); @@ -175,7 +177,7 @@ WRITE8_MEMBER(tehkanwc_state::sound_answer_w) /* in Gridiron, the sound CPU goes in a tight loop after the self test, */ /* probably waiting to be reset by a watchdog */ - if (space.device().safe_pc() == 0x08bc) timer_set(attotime::from_seconds(1), TIMER_RESET); + if (space.device().safe_pc() == 0x08bc) m_reset_timer->adjust(attotime::from_seconds(1)); } diff --git a/src/mame/drivers/thunderx.cpp b/src/mame/drivers/thunderx.cpp index b384a0b94cc..f7f4549e148 100644 --- a/src/mame/drivers/thunderx.cpp +++ b/src/mame/drivers/thunderx.cpp @@ -313,7 +313,7 @@ WRITE8_MEMBER(thunderx_state::thunderx_1f98_w) calculate_collisions(); /* 100 cycle delay is arbitrary */ - timer_set(downcast(&space.device())->cycles_to_attotime(100), TIMER_THUNDERX_FIRQ); + m_thunderx_firq_timer->adjust(m_maincpu->cycles_to_attotime(100)); } m_1f98_latch = data; @@ -1034,15 +1034,19 @@ ROM_START( crazycop ) ROM_END +DRIVER_INIT_MEMBER(thunderx_state, thunderx) +{ + m_thunderx_firq_timer = timer_alloc(TIMER_THUNDERX_FIRQ); +} /***************************************************************************/ -GAME( 1988, scontra, 0, scontra, scontra, driver_device, 0, ROT90, "Konami", "Super Contra", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, scontraj, scontra, scontra, scontra, driver_device, 0, ROT90, "Konami", "Super Contra (Japan)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, thunderx, 0, thunderx, thunderx, driver_device, 0, ROT0, "Konami", "Thunder Cross (set 1)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, thunderxa, thunderx, thunderx, thunderx, driver_device, 0, ROT0, "Konami", "Thunder Cross (set 2)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, thunderxb, thunderx, thunderx, thunderx, driver_device, 0, ROT0, "Konami", "Thunder Cross (set 3)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, thunderxj, thunderx, thunderx, thnderxj, driver_device, 0, ROT0, "Konami", "Thunder Cross (Japan)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, gbusters, 0, gbusters, gbusters, driver_device, 0, ROT90, "Konami", "Gang Busters (set 1)", MACHINE_SUPPORTS_SAVE ) /* N02 & J03 program roms */ -GAME( 1988, gbustersa, gbusters, gbusters, gbusters, driver_device, 0, ROT90, "Konami", "Gang Busters (set 2)", MACHINE_SUPPORTS_SAVE ) /* unknown region program roms */ -GAME( 1988, crazycop, gbusters, gbusters, gbusters, driver_device, 0, ROT90, "Konami", "Crazy Cop (Japan)", MACHINE_SUPPORTS_SAVE ) /* M02 & J03 program roms */ +GAME( 1988, scontra, 0, scontra, scontra, driver_device, 0, ROT90, "Konami", "Super Contra", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, scontraj, scontra, scontra, scontra, driver_device, 0, ROT90, "Konami", "Super Contra (Japan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, thunderx, 0, thunderx, thunderx, thunderx_state, thunderx, ROT0, "Konami", "Thunder Cross (set 1)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, thunderxa, thunderx, thunderx, thunderx, thunderx_state, thunderx, ROT0, "Konami", "Thunder Cross (set 2)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, thunderxb, thunderx, thunderx, thunderx, thunderx_state, thunderx, ROT0, "Konami", "Thunder Cross (set 3)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, thunderxj, thunderx, thunderx, thnderxj, thunderx_state, thunderx, ROT0, "Konami", "Thunder Cross (Japan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, gbusters, 0, gbusters, gbusters, driver_device, 0, ROT90, "Konami", "Gang Busters (set 1)", MACHINE_SUPPORTS_SAVE ) /* N02 & J03 program roms */ +GAME( 1988, gbustersa, gbusters, gbusters, gbusters, driver_device, 0, ROT90, "Konami", "Gang Busters (set 2)", MACHINE_SUPPORTS_SAVE ) /* unknown region program roms */ +GAME( 1988, crazycop, gbusters, gbusters, gbusters, driver_device, 0, ROT90, "Konami", "Crazy Cop (Japan)", MACHINE_SUPPORTS_SAVE ) /* M02 & J03 program roms */ diff --git a/src/mame/drivers/trucocl.cpp b/src/mame/drivers/trucocl.cpp index 6f3d262d701..7c61b84aaf5 100644 --- a/src/mame/drivers/trucocl.cpp +++ b/src/mame/drivers/trucocl.cpp @@ -89,7 +89,7 @@ WRITE8_MEMBER(trucocl_state::audio_dac_w) m_dac->write(rom[dac_address+m_cur_dac_address_index]); - timer_set( attotime::from_hz( 16000 ), TIMER_DAC_IRQ); + m_dac_irq_timer->adjust(attotime::from_hz( 16000 )); } static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, trucocl_state ) @@ -200,6 +200,8 @@ DRIVER_INIT_MEMBER(trucocl_state,trucocl) { m_cur_dac_address = -1; m_cur_dac_address_index = 0; + + m_dac_irq_timer = timer_alloc(TIMER_DAC_IRQ); } diff --git a/src/mame/includes/gunbustr.h b/src/mame/includes/gunbustr.h index 565cdec6120..85ae503643e 100644 --- a/src/mame/includes/gunbustr.h +++ b/src/mame/includes/gunbustr.h @@ -49,6 +49,7 @@ public: uint16_t m_coin_word; std::unique_ptr m_spritelist; uint32_t m_mem[2]; + emu_timer *m_interrupt5_timer; DECLARE_WRITE32_MEMBER(gunbustr_input_w); DECLARE_WRITE32_MEMBER(motor_control_w); diff --git a/src/mame/includes/midzeus.h b/src/mame/includes/midzeus.h index 4a66ad27f18..8f1880b4870 100644 --- a/src/mame/includes/midzeus.h +++ b/src/mame/includes/midzeus.h @@ -36,6 +36,8 @@ public: required_device m_screen; optional_device m_palette; + emu_timer *m_display_irq_off_timer; + DECLARE_WRITE32_MEMBER(cmos_w); DECLARE_READ32_MEMBER(cmos_r); DECLARE_WRITE32_MEMBER(cmos_protect_w); diff --git a/src/mame/includes/opwolf.h b/src/mame/includes/opwolf.h index 886518bbddb..93043860950 100644 --- a/src/mame/includes/opwolf.h +++ b/src/mame/includes/opwolf.h @@ -45,6 +45,8 @@ public: int m_opwolf_gun_xoffs; int m_opwolf_gun_yoffs; + emu_timer *m_opwolf_timer; + /* c-chip */ emu_timer *m_cchip_timer; diff --git a/src/mame/includes/othunder.h b/src/mame/includes/othunder.h index 78e285c3d76..ca08f6606c3 100644 --- a/src/mame/includes/othunder.h +++ b/src/mame/includes/othunder.h @@ -62,6 +62,7 @@ public: int m_vblank_irq; int m_ad_irq; int m_pan[4]; + emu_timer *m_ad_interrupt_timer; /* devices */ required_device m_maincpu; diff --git a/src/mame/includes/policetr.h b/src/mame/includes/policetr.h index 3d578794db5..8b8b6c090ce 100644 --- a/src/mame/includes/policetr.h +++ b/src/mame/includes/policetr.h @@ -44,6 +44,7 @@ public: uint16_t m_dst_yoffs; uint8_t m_video_latch; uint32_t m_srcbitmap_height_mask; + emu_timer *m_irq5_gen_timer; DECLARE_WRITE32_MEMBER(control_w); DECLARE_WRITE32_MEMBER(policetr_bsmt2000_reg_w); DECLARE_WRITE32_MEMBER(policetr_bsmt2000_data_w); @@ -58,6 +59,7 @@ public: DECLARE_DRIVER_INIT(policetr); DECLARE_DRIVER_INIT(sshooter); DECLARE_DRIVER_INIT(plctr13b); + virtual void machine_start() override; virtual void video_start() override; uint32_t screen_update_policetr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); INTERRUPT_GEN_MEMBER(irq4_gen); diff --git a/src/mame/includes/rollerg.h b/src/mame/includes/rollerg.h index ed7d4f53576..f1d65e83757 100644 --- a/src/mame/includes/rollerg.h +++ b/src/mame/includes/rollerg.h @@ -29,6 +29,7 @@ public: /* misc */ int m_readzoomroms; + emu_timer *m_nmi_timer; /* devices */ required_device m_maincpu; diff --git a/src/mame/includes/tehkanwc.h b/src/mame/includes/tehkanwc.h index a4d5b229dae..4c5baed9f20 100644 --- a/src/mame/includes/tehkanwc.h +++ b/src/mame/includes/tehkanwc.h @@ -50,6 +50,7 @@ public: uint8_t m_led1; tilemap_t *m_bg_tilemap; tilemap_t *m_fg_tilemap; + emu_timer *m_reset_timer; DECLARE_WRITE8_MEMBER(sub_cpu_halt_w); DECLARE_READ8_MEMBER(track_0_r); diff --git a/src/mame/includes/thunderx.h b/src/mame/includes/thunderx.h index e9ee6df35c1..a667b3cf27a 100644 --- a/src/mame/includes/thunderx.h +++ b/src/mame/includes/thunderx.h @@ -48,6 +48,7 @@ public: /* misc */ int m_priority; uint8_t m_1f98_latch; + emu_timer *m_thunderx_firq_timer; DECLARE_WRITE8_MEMBER(scontra_bankswitch_w); DECLARE_WRITE8_MEMBER(thunderx_videobank_w); @@ -65,6 +66,7 @@ public: virtual void machine_start() override; virtual void machine_reset() override; virtual void video_start() override; + DECLARE_DRIVER_INIT(thunderx); uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); INTERRUPT_GEN_MEMBER(vblank_interrupt); diff --git a/src/mame/includes/trucocl.h b/src/mame/includes/trucocl.h index 96e91d58038..ee6ad2a7228 100644 --- a/src/mame/includes/trucocl.h +++ b/src/mame/includes/trucocl.h @@ -25,6 +25,8 @@ public: tilemap_t *m_bg_tilemap; uint8_t m_irq_mask; + emu_timer *m_dac_irq_timer; + DECLARE_WRITE8_MEMBER(irq_enable_w); DECLARE_WRITE8_MEMBER(trucocl_videoram_w); DECLARE_WRITE8_MEMBER(trucocl_colorram_w); diff --git a/src/mame/machine/opwolf.cpp b/src/mame/machine/opwolf.cpp index 30728cdbe61..ea96ed46616 100644 --- a/src/mame/machine/opwolf.cpp +++ b/src/mame/machine/opwolf.cpp @@ -1070,7 +1070,7 @@ TIMER_CALLBACK_MEMBER(opwolf_state::cchip_timer) { // Simulate time for command to execute (exact timing unknown, this is close) m_current_cmd = 0xf5; - timer_set(m_maincpu->cycles_to_attotime(80000), TIMER_OPWOLF); + m_opwolf_timer->adjust(m_maincpu->cycles_to_attotime(80000)); } m_cchip_last_7a = m_cchip_ram[0x7a];