summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2018-02-17 22:06:15 -0500
committer AJR <ajrhacker@users.noreply.github.com>2018-02-17 22:06:15 -0500
commit576d271bf759d5ab1e14612a4bfd7cbbd2f0abad (patch)
treee1c6c577d8a5e8d967abd5df3be6b604d851c0a9
parent782a5466d6efb188690fb451df42c96c13ed2045 (diff)
40love.cpp: Soundlatch modernization (nw)
-rw-r--r--src/mame/drivers/40love.cpp93
-rw-r--r--src/mame/includes/40love.h22
2 files changed, 29 insertions, 86 deletions
diff --git a/src/mame/drivers/40love.cpp b/src/mame/drivers/40love.cpp
index 04942d08bea..de75f20cb3d 100644
--- a/src/mame/drivers/40love.cpp
+++ b/src/mame/drivers/40love.cpp
@@ -226,50 +226,13 @@ Notes - Has jumper setting for 122HZ or 61HZ)
#include "cpu/m6805/m6805.h"
#include "cpu/z80/z80.h"
+#include "machine/input_merger.h"
#include "sound/dac.h"
#include "sound/volt_reg.h"
#include "screen.h"
#include "speaker.h"
-void fortyl_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch(id)
- {
- case TIMER_NMI_CALLBACK:
- if (m_sound_nmi_enable)
- m_audiocpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
- else
- m_pending_nmi = 1;
- break;
- default:
- assert_always(false, "Unknown id in fortyl_state::device_timer");
- }
-}
-
-WRITE8_MEMBER(fortyl_state::sound_command_w)
-{
- m_soundlatch->write(space, 0, data);
- synchronize(TIMER_NMI_CALLBACK, data);
-}
-
-WRITE8_MEMBER(fortyl_state::nmi_disable_w)
-{
- m_sound_nmi_enable = 0;
-}
-
-WRITE8_MEMBER(fortyl_state::nmi_enable_w)
-{
- m_sound_nmi_enable = 1;
- if (m_pending_nmi)
- {
- m_audiocpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
- m_pending_nmi = 0;
- }
-}
-
-
-
#if 0
WRITE8_MEMBER(fortyl_state::fortyl_coin_counter_w)
{
@@ -379,21 +342,9 @@ DRIVER_INIT_MEMBER(fortyl_state,40love)
/***************************************************************************/
-READ8_MEMBER(fortyl_state::from_snd_r)
-{
- m_snd_flag = 0;
- return m_snd_data;
-}
-
READ8_MEMBER(fortyl_state::snd_flag_r)
{
- return m_snd_flag | 0xfd;
-}
-
-WRITE8_MEMBER(fortyl_state::to_main_w)
-{
- m_snd_data = data;
- m_snd_flag = 2;
+ return (m_soundlatch2->pending_r() ? 2 : 0) | 0xfd;
}
/***************************************************************************/
@@ -405,7 +356,8 @@ ADDRESS_MAP_START(fortyl_state::_40love_map)
AM_RANGE(0x8801, 0x8801) AM_READWRITE(fortyl_mcu_status_r, pix1_mcu_w) //pixel layer related
AM_RANGE(0x8802, 0x8802) AM_WRITE(bank_select_w)
AM_RANGE(0x8803, 0x8803) AM_READWRITE(pix2_r, pix2_w) //pixel layer related
- AM_RANGE(0x8804, 0x8804) AM_READWRITE(from_snd_r, sound_command_w)
+ AM_RANGE(0x8804, 0x8804) AM_DEVREAD("soundlatch2", generic_latch_8_device, read)
+ AM_RANGE(0x8804, 0x8804) AM_DEVWRITE("soundlatch", generic_latch_8_device, write)
AM_RANGE(0x8805, 0x8805) AM_READ(snd_flag_r) AM_WRITENOP /*sound_reset*/ //????
AM_RANGE(0x8807, 0x8807) AM_READNOP /* unknown */
AM_RANGE(0x8808, 0x8808) AM_READ_PORT("DSW3")
@@ -432,7 +384,8 @@ ADDRESS_MAP_START(fortyl_state::undoukai_map)
AM_RANGE(0xa801, 0xa801) AM_READWRITE(fortyl_mcu_status_r, pix1_w) //pixel layer related
AM_RANGE(0xa802, 0xa802) AM_WRITE(bank_select_w)
AM_RANGE(0xa803, 0xa803) AM_READWRITE(pix2_r, pix2_w) //pixel layer related
- AM_RANGE(0xa804, 0xa804) AM_READWRITE(from_snd_r, sound_command_w)
+ AM_RANGE(0xa804, 0xa804) AM_DEVREAD("soundlatch2", generic_latch_8_device, read)
+ AM_RANGE(0xa804, 0xa804) AM_DEVWRITE("soundlatch", generic_latch_8_device, write)
AM_RANGE(0xa805, 0xa805) AM_READ(snd_flag_r) AM_WRITENOP /*sound_reset*/ //????
AM_RANGE(0xa807, 0xa807) AM_READNOP AM_WRITENOP /* unknown */
AM_RANGE(0xa808, 0xa808) AM_READ_PORT("DSW3")
@@ -498,9 +451,11 @@ ADDRESS_MAP_START(fortyl_state::sound_map)
AM_RANGE(0xca00, 0xca0d) AM_DEVWRITE("msm", msm5232_device, write)
AM_RANGE(0xcc00, 0xcc00) AM_WRITE(sound_control_0_w)
AM_RANGE(0xce00, 0xce00) AM_WRITE(sound_control_1_w)
- AM_RANGE(0xd800, 0xd800) AM_DEVREAD("soundlatch", generic_latch_8_device, read) AM_WRITE(to_main_w)
- AM_RANGE(0xda00, 0xda00) AM_READNOP AM_WRITE(nmi_enable_w) /* unknown read */
- AM_RANGE(0xdc00, 0xdc00) AM_WRITE(nmi_disable_w)
+ AM_RANGE(0xd800, 0xd800) AM_DEVREAD("soundlatch", generic_latch_8_device, read)
+ AM_RANGE(0xd800, 0xd800) AM_DEVWRITE("soundlatch2", generic_latch_8_device, write)
+ AM_RANGE(0xda00, 0xda00) AM_READNOP // unknown read
+ AM_RANGE(0xda00, 0xda00) AM_DEVWRITE("soundnmi", input_merger_device, in_set<1>) // enable NMI
+ AM_RANGE(0xdc00, 0xdc00) AM_DEVWRITE("soundnmi", input_merger_device, in_clear<1>) // disable NMI
AM_RANGE(0xde00, 0xde00) AM_READNOP AM_DEVWRITE("dac", dac_byte_interface, write) /* signed 8-bit DAC - unknown read */
AM_RANGE(0xe000, 0xefff) AM_ROM /* space for diagnostics ROM */
ADDRESS_MAP_END
@@ -714,10 +669,6 @@ MACHINE_START_MEMBER(fortyl_state,40love)
save_item(NAME(m_color_bank));
save_item(NAME(m_screen_disable));
/* sound */
- save_item(NAME(m_sound_nmi_enable));
- save_item(NAME(m_pending_nmi));
- save_item(NAME(m_snd_data));
- save_item(NAME(m_snd_flag));
save_item(NAME(m_vol_ctrl));
save_item(NAME(m_snd_ctrl0));
save_item(NAME(m_snd_ctrl1));
@@ -737,10 +688,6 @@ MACHINE_RESET_MEMBER(fortyl_state,common)
m_color_bank = false;
/* sound */
- m_sound_nmi_enable = 0;
- m_pending_nmi = 0;
- m_snd_data = 0;
- m_snd_flag = 0;
m_snd_ctrl0 = 0;
m_snd_ctrl1 = 0;
m_snd_ctrl2 = 0;
@@ -763,6 +710,14 @@ MACHINE_CONFIG_START(fortyl_state::_40love)
MCFG_CPU_PROGRAM_MAP(sound_map)
MCFG_CPU_PERIODIC_INT_DRIVER(fortyl_state, irq0_line_hold, 2*60) /* source/number of IRQs is unknown */
+ MCFG_GENERIC_LATCH_8_ADD("soundlatch")
+ MCFG_GENERIC_LATCH_DATA_PENDING_CB(DEVWRITELINE("soundnmi", input_merger_device, in_w<0>))
+
+ MCFG_GENERIC_LATCH_8_ADD("soundlatch2")
+
+ MCFG_INPUT_MERGER_ALL_HIGH("soundnmi")
+ MCFG_INPUT_MERGER_OUTPUT_HANDLER(INPUTLINE("audiocpu", INPUT_LINE_NMI))
+
MCFG_DEVICE_ADD("bmcu", TAITO68705_MCU, 18432000/6) /* OK */
MCFG_QUANTUM_TIME(attotime::from_hz(6000)) /* high interleave to ensure proper synchronization of CPUs */
@@ -784,7 +739,6 @@ MACHINE_CONFIG_START(fortyl_state::_40love)
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("speaker")
- MCFG_GENERIC_LATCH_8_ADD("soundlatch")
MCFG_TA7630_ADD("ta7630")
MCFG_SOUND_ADD("aysnd", AY8910, 2000000)
@@ -822,6 +776,14 @@ MACHINE_CONFIG_START(fortyl_state::undoukai)
MCFG_CPU_PROGRAM_MAP(sound_map)
MCFG_CPU_PERIODIC_INT_DRIVER(fortyl_state, irq0_line_hold, 2*60) /* source/number of IRQs is unknown */
+ MCFG_GENERIC_LATCH_8_ADD("soundlatch")
+ MCFG_GENERIC_LATCH_DATA_PENDING_CB(DEVWRITELINE("soundnmi", input_merger_device, in_w<0>))
+
+ MCFG_GENERIC_LATCH_8_ADD("soundlatch2")
+
+ MCFG_INPUT_MERGER_ALL_HIGH("soundnmi")
+ MCFG_INPUT_MERGER_OUTPUT_HANDLER(INPUTLINE("audiocpu", INPUT_LINE_NMI))
+
MCFG_DEVICE_ADD("bmcu", TAITO68705_MCU, 18432000/6)
MCFG_QUANTUM_TIME(attotime::from_hz(6000))
@@ -843,7 +805,6 @@ MACHINE_CONFIG_START(fortyl_state::undoukai)
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("speaker")
- MCFG_GENERIC_LATCH_8_ADD("soundlatch")
MCFG_TA7630_ADD("ta7630")
MCFG_SOUND_ADD("aysnd", AY8910, 2000000)
diff --git a/src/mame/includes/40love.h b/src/mame/includes/40love.h
index 87f175c6deb..48161b23d29 100644
--- a/src/mame/includes/40love.h
+++ b/src/mame/includes/40love.h
@@ -26,7 +26,7 @@ public:
m_ta7630(*this,"ta7630"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
- m_soundlatch(*this, "soundlatch") { }
+ m_soundlatch2(*this, "soundlatch2") { }
/* memory pointers */
required_shared_ptr<uint8_t> m_videoram;
@@ -51,16 +51,10 @@ public:
bool m_color_bank;
bool m_screen_disable;
- /* sound-related */
- int m_sound_nmi_enable;
- int m_pending_nmi;
-
/* misc */
int m_pix_color[4];
uint8_t m_pix1;
uint8_t m_pix2[2];
- uint8_t m_snd_data;
- uint8_t m_snd_flag;
int m_vol_ctrl[16];
uint8_t m_snd_ctrl0;
uint8_t m_snd_ctrl1;
@@ -76,18 +70,13 @@ public:
required_device<ta7630_device> m_ta7630;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
- required_device<generic_latch_8_device> m_soundlatch;
+ required_device<generic_latch_8_device> m_soundlatch2;
- DECLARE_WRITE8_MEMBER(sound_command_w);
- DECLARE_WRITE8_MEMBER(nmi_disable_w);
- DECLARE_WRITE8_MEMBER(nmi_enable_w);
DECLARE_WRITE8_MEMBER(bank_select_w);
DECLARE_WRITE8_MEMBER(pix1_w);
DECLARE_WRITE8_MEMBER(pix2_w);
DECLARE_READ8_MEMBER(pix2_r);
- DECLARE_READ8_MEMBER(from_snd_r);
DECLARE_READ8_MEMBER(snd_flag_r);
- DECLARE_WRITE8_MEMBER(to_main_w);
DECLARE_READ8_MEMBER(fortyl_mcu_status_r);
DECLARE_WRITE8_MEMBER(fortyl_pixram_sel_w);
DECLARE_READ8_MEMBER(fortyl_pixram_r);
@@ -115,16 +104,9 @@ public:
void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
void draw_pixram( bitmap_ind16 &bitmap, const rectangle &cliprect );
- enum
- {
- TIMER_NMI_CALLBACK
- };
-
void undoukai(machine_config &config);
void _40love(machine_config &config);
void _40love_map(address_map &map);
void sound_map(address_map &map);
void undoukai_map(address_map &map);
-protected:
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
};