From f758c3abd5afa07360609421d9bf120e49f58cc6 Mon Sep 17 00:00:00 2001 From: AJR Date: Mon, 7 Aug 2017 12:22:08 -0400 Subject: [PATCH] rpunch.cpp: Soundlatch modernization (nw) --- src/mame/drivers/rpunch.cpp | 60 ++++++++++--------------------------- src/mame/includes/rpunch.h | 12 ++++---- 2 files changed, 21 insertions(+), 51 deletions(-) diff --git a/src/mame/drivers/rpunch.cpp b/src/mame/drivers/rpunch.cpp index ea193b518b8..e9e3f94bc40 100644 --- a/src/mame/drivers/rpunch.cpp +++ b/src/mame/drivers/rpunch.cpp @@ -112,6 +112,7 @@ #include "cpu/m68000/m68000.h" #include "cpu/m6809/m6809.h" #include "cpu/z80/z80.h" +#include "machine/input_merger.h" #include "sound/ym2151.h" #include "speaker.h" @@ -128,9 +129,6 @@ void rpunch_state::machine_start() { - save_item(NAME(m_sound_data)); - save_item(NAME(m_sound_busy)); - save_item(NAME(m_ym2151_irq)); save_item(NAME(m_upd_rom_bank)); save_item(NAME(m_sprite_xoffs)); save_item(NAME(m_videoflags)); @@ -138,19 +136,6 @@ void rpunch_state::machine_start() save_item(NAME(m_gins)); } -/************************************* - * - * Interrupt handling - * - *************************************/ - -WRITE_LINE_MEMBER(rpunch_state::ym2151_irq_gen) -{ - m_ym2151_irq = state; - m_audiocpu->set_input_line(0, (m_ym2151_irq | m_sound_busy) ? ASSERT_LINE : CLEAR_LINE); -} - - void rpunch_state::machine_reset() { uint8_t *snd = memregion("upd")->base(); @@ -177,32 +162,9 @@ CUSTOM_INPUT_MEMBER(rpunch_state::hi_bits_r) * *************************************/ -TIMER_CALLBACK_MEMBER(rpunch_state::sound_command_w_callback) -{ - m_sound_busy = 1; - m_sound_data = param; - m_audiocpu->set_input_line(0, (m_ym2151_irq | m_sound_busy) ? ASSERT_LINE : CLEAR_LINE); -} - - -WRITE16_MEMBER(rpunch_state::sound_command_w) -{ - if (ACCESSING_BITS_0_7) - machine().scheduler().synchronize(timer_expired_delegate(FUNC(rpunch_state::sound_command_w_callback),this), data & 0xff); -} - - -READ8_MEMBER(rpunch_state::sound_command_r) -{ - m_sound_busy = 0; - m_audiocpu->set_input_line(0, (m_ym2151_irq | m_sound_busy) ? ASSERT_LINE : CLEAR_LINE); - return m_sound_data; -} - - READ16_MEMBER(rpunch_state::sound_busy_r) { - return m_sound_busy; + return m_soundlatch->pending_r(); } @@ -250,7 +212,7 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 16, rpunch_state ) AM_RANGE(0x0c0000, 0x0c0007) AM_WRITE(rpunch_scrollreg_w) AM_RANGE(0x0c0008, 0x0c0009) AM_SELECT(0x20) AM_WRITE8(rpunch_gga_w, 0x00ff) AM_RANGE(0x0c000c, 0x0c000d) AM_WRITE(rpunch_videoreg_w) - AM_RANGE(0x0c000e, 0x0c000f) AM_WRITE(sound_command_w) + AM_RANGE(0x0c000e, 0x0c000f) AM_DEVWRITE8("soundlatch", generic_latch_8_device, write, 0x00ff) AM_RANGE(0x0c0010, 0x0c0013) AM_WRITE(rpunch_ins_w) AM_RANGE(0x0c0018, 0x0c0019) AM_READ_PORT("P1") AM_RANGE(0x0c001a, 0x0c001b) AM_READ_PORT("P2") @@ -270,7 +232,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, rpunch_state ) AM_RANGE(0x0000, 0xefff) AM_ROM AM_RANGE(0xf000, 0xf001) AM_DEVREADWRITE("ymsnd", ym2151_device, read, write) - AM_RANGE(0xf200, 0xf200) AM_READ(sound_command_r) + AM_RANGE(0xf200, 0xf200) AM_DEVREAD("soundlatch", generic_latch_8_device, read) AM_RANGE(0xf400, 0xf400) AM_WRITE(upd_control_w) AM_RANGE(0xf600, 0xf600) AM_WRITE(upd_data_w) AM_RANGE(0xf800, 0xffff) AM_RAM @@ -502,6 +464,11 @@ static MACHINE_CONFIG_START( rpunch ) MCFG_CPU_ADD("audiocpu", Z80, MASTER_CLOCK/4) MCFG_CPU_PROGRAM_MAP(sound_map) + MCFG_GENERIC_LATCH_8_ADD("soundlatch") + MCFG_GENERIC_LATCH_DATA_PENDING_CB(DEVWRITELINE("soundirq", input_merger_device, in_w<0>)) + + MCFG_INPUT_MERGER_ANY_HIGH("soundirq") + MCFG_INPUT_MERGER_OUTPUT_HANDLER(INPUTLINE("audiocpu", 0)) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) @@ -524,7 +491,7 @@ static MACHINE_CONFIG_START( rpunch ) MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_YM2151_ADD("ymsnd", MASTER_CLOCK/4) - MCFG_YM2151_IRQ_HANDLER(WRITELINE(rpunch_state,ym2151_irq_gen)) + MCFG_YM2151_IRQ_HANDLER(DEVWRITELINE("soundirq", input_merger_device, in_w<1>)) MCFG_SOUND_ROUTE(0, "mono", 0.50) MCFG_SOUND_ROUTE(1, "mono", 0.50) @@ -547,6 +514,11 @@ static MACHINE_CONFIG_START( svolleybl ) MCFG_CPU_ADD("audiocpu", Z80, MASTER_CLOCK/4) MCFG_CPU_PROGRAM_MAP(sound_map) + MCFG_GENERIC_LATCH_8_ADD("soundlatch") + MCFG_GENERIC_LATCH_DATA_PENDING_CB(DEVWRITELINE("soundirq", input_merger_device, in_w<0>)) + + MCFG_INPUT_MERGER_ANY_HIGH("soundirq") + MCFG_INPUT_MERGER_OUTPUT_HANDLER(INPUTLINE("audiocpu", 0)) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) @@ -570,7 +542,7 @@ static MACHINE_CONFIG_START( svolleybl ) MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_YM2151_ADD("ymsnd", MASTER_CLOCK/4) - MCFG_YM2151_IRQ_HANDLER(WRITELINE(rpunch_state,ym2151_irq_gen)) + MCFG_YM2151_IRQ_HANDLER(DEVWRITELINE("soundirq", input_merger_device, in_w<1>)) MCFG_SOUND_ROUTE(0, "mono", 0.50) MCFG_SOUND_ROUTE(1, "mono", 0.50) diff --git a/src/mame/includes/rpunch.h b/src/mame/includes/rpunch.h index 20b88d8887e..a67e0f56fc6 100644 --- a/src/mame/includes/rpunch.h +++ b/src/mame/includes/rpunch.h @@ -1,5 +1,7 @@ // license:BSD-3-Clause // copyright-holders:Aaron Giles + +#include "machine/gen_latch.h" #include "sound/upd7759.h" #include "video/vsystem_gga.h" #include "screen.h" @@ -11,6 +13,7 @@ public: : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), + m_soundlatch(*this, "soundlatch"), m_upd7759(*this, "upd"), m_gfxdecode(*this, "gfxdecode"), m_screen(*this, "screen"), @@ -22,6 +25,7 @@ public: required_device m_maincpu; required_device m_audiocpu; + required_device m_soundlatch; required_device m_upd7759; required_device m_gfxdecode; required_device m_screen; @@ -32,9 +36,6 @@ public: required_shared_ptr m_bitmapram; required_shared_ptr m_spriteram; - uint8_t m_sound_data; - uint8_t m_sound_busy; - uint8_t m_ym2151_irq; uint8_t m_upd_rom_bank; int m_sprite_palette; int m_sprite_xoffs; @@ -43,9 +44,7 @@ public: uint8_t m_gins; tilemap_t *m_background[2]; emu_timer *m_crtc_timer; - DECLARE_WRITE_LINE_MEMBER(ym2151_irq_gen); - DECLARE_WRITE16_MEMBER(sound_command_w); - DECLARE_READ8_MEMBER(sound_command_r); + DECLARE_READ16_MEMBER(sound_busy_r); DECLARE_WRITE16_MEMBER(rpunch_videoram_w); DECLARE_WRITE16_MEMBER(rpunch_videoreg_w); @@ -68,7 +67,6 @@ public: uint32_t screen_update_rpunch(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - TIMER_CALLBACK_MEMBER(sound_command_w_callback); TIMER_CALLBACK_MEMBER(crtc_interrupt_gen); void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int start, int stop); void draw_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect);