lsasquad.cpp: Soundlatch modernization (nw)

This commit is contained in:
AJR 2017-08-17 22:49:34 -04:00
parent f5e0d05fb1
commit 5a5136079a
3 changed files with 38 additions and 90 deletions

View File

@ -186,7 +186,8 @@ static ADDRESS_MAP_START( lsasquad_map, AS_PROGRAM, 8, lsasquad_state )
AM_RANGE(0xe806, 0xe806) AM_READ_PORT("START")
AM_RANGE(0xe807, 0xe807) AM_READ_PORT("SERVICE")
AM_RANGE(0xea00, 0xea00) AM_WRITE(lsasquad_bankswitch_w)
AM_RANGE(0xec00, 0xec00) AM_READWRITE(lsasquad_sound_result_r,lsasquad_sound_command_w)
AM_RANGE(0xec00, 0xec00) AM_DEVREAD("soundlatch2", generic_latch_8_device, read)
AM_RANGE(0xec00, 0xec00) AM_DEVWRITE("soundlatch", generic_latch_8_device, write)
AM_RANGE(0xec01, 0xec01) AM_READ(lsasquad_sound_status_r)
AM_RANGE(0xee00, 0xee00) AM_DEVREADWRITE("bmcu", taito68705_mcu_device, data_r, data_w)
ADDRESS_MAP_END
@ -196,7 +197,8 @@ static ADDRESS_MAP_START( lsasquad_sound_map, AS_PROGRAM, 8, lsasquad_state )
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0xa000, 0xa001) AM_DEVREADWRITE("ymsnd", ym2203_device, read, write)
AM_RANGE(0xc000, 0xc001) AM_DEVWRITE("aysnd", ay8910_device, address_data_w)
AM_RANGE(0xd000, 0xd000) AM_READWRITE(lsasquad_sh_sound_command_r, lsasquad_sh_result_w)
AM_RANGE(0xd000, 0xd000) AM_DEVREAD("soundlatch", generic_latch_8_device, read)
AM_RANGE(0xd000, 0xd000) AM_DEVWRITE("soundlatch2", generic_latch_8_device, write)
AM_RANGE(0xd400, 0xd400) AM_WRITE(lsasquad_sh_nmi_disable_w)
AM_RANGE(0xd800, 0xd800) AM_WRITE(lsasquad_sh_nmi_enable_w)
AM_RANGE(0xd800, 0xd800) AM_READ(lsasquad_sound_status_r)
@ -221,7 +223,8 @@ static ADDRESS_MAP_START( storming_map, AS_PROGRAM, 8, lsasquad_state )
AM_RANGE(0xe806, 0xe806) AM_READ_PORT("START")
AM_RANGE(0xe807, 0xe807) AM_READ_PORT("SERVICE")
AM_RANGE(0xea00, 0xea00) AM_WRITE(lsasquad_bankswitch_w)
AM_RANGE(0xec00, 0xec00) AM_READWRITE(lsasquad_sound_result_r,lsasquad_sound_command_w)
AM_RANGE(0xec00, 0xec00) AM_DEVREAD("soundlatch2", generic_latch_8_device, read)
AM_RANGE(0xec00, 0xec00) AM_DEVWRITE("soundlatch", generic_latch_8_device, write)
AM_RANGE(0xec01, 0xec01) AM_READ(lsasquad_sound_status_r)
ADDRESS_MAP_END
@ -383,8 +386,7 @@ static ADDRESS_MAP_START( daikaiju_map, AS_PROGRAM, 8, lsasquad_state )
AM_RANGE(0xe806, 0xe806) AM_READ_PORT("START")
AM_RANGE(0xe807, 0xe807) AM_READ_PORT("SERVICE")
AM_RANGE(0xea00, 0xea00) AM_WRITE(lsasquad_bankswitch_w)
AM_RANGE(0xec00, 0xec00) AM_WRITE(lsasquad_sound_command_w)
AM_RANGE(0xec01, 0xec01) AM_READ(lsasquad_sound_status_r)
AM_RANGE(0xec00, 0xec00) AM_DEVWRITE("soundlatch", generic_latch_8_device, write)
AM_RANGE(0xee00, 0xee00) AM_DEVREADWRITE("bmcu", taito68705_mcu_device, data_r, data_w)
ADDRESS_MAP_END
@ -393,9 +395,9 @@ static ADDRESS_MAP_START( daikaiju_sound_map, AS_PROGRAM, 8, lsasquad_state )
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0xa000, 0xa001) AM_DEVREADWRITE("ymsnd", ym2203_device, read, write)
AM_RANGE(0xc000, 0xc001) AM_DEVWRITE("aysnd", ay8910_device, address_data_w)
AM_RANGE(0xd000, 0xd000) AM_READ(daikaiju_sh_sound_command_r)
AM_RANGE(0xd400, 0xd400) AM_WRITENOP
AM_RANGE(0xd800, 0xd800) AM_READ(daikaiju_sound_status_r) AM_WRITENOP
AM_RANGE(0xd000, 0xd000) AM_DEVREAD("soundlatch", generic_latch_8_device, read)
AM_RANGE(0xd400, 0xd400) AM_WRITE(lsasquad_sh_nmi_disable_w)
AM_RANGE(0xd800, 0xd800) AM_READWRITE(daikaiju_sound_status_r, lsasquad_sh_nmi_enable_w)
AM_RANGE(0xdc00, 0xdc00) AM_WRITENOP
AM_RANGE(0xe000, 0xefff) AM_ROM /* space for diagnostic ROM? */
ADDRESS_MAP_END
@ -541,22 +543,10 @@ MACHINE_START_MEMBER(lsasquad_state,lsasquad)
uint8_t *ROM = memregion("maincpu")->base();
membank("bank1")->configure_entries(0, 8, &ROM[0x10000], 0x2000);
save_item(NAME(m_sound_pending));
save_item(NAME(m_sound_nmi_enable));
save_item(NAME(m_pending_nmi));
save_item(NAME(m_sound_cmd));
save_item(NAME(m_sound_result));
}
MACHINE_RESET_MEMBER(lsasquad_state,lsasquad)
{
m_sound_pending = 0;
m_sound_nmi_enable = 0;
m_pending_nmi = 0;
m_sound_cmd = 0;
m_sound_result = 0;
}
/* Note: lsasquad clock values are not verified */
@ -580,6 +570,14 @@ static MACHINE_CONFIG_START( lsasquad )
MCFG_MACHINE_START_OVERRIDE(lsasquad_state,lsasquad)
MCFG_MACHINE_RESET_OVERRIDE(lsasquad_state,lsasquad)
MCFG_GENERIC_LATCH_8_ADD("soundlatch")
MCFG_GENERIC_LATCH_DATA_PENDING_CB(DEVWRITELINE("soundnmi", input_merger_device, in_w<0>))
MCFG_INPUT_MERGER_ALL_HIGH("soundnmi")
MCFG_INPUT_MERGER_OUTPUT_HANDLER(INPUTLINE("audiocpu", INPUT_LINE_NMI))
MCFG_GENERIC_LATCH_8_ADD("soundlatch2")
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_REFRESH_RATE(60)
@ -639,6 +637,12 @@ static MACHINE_CONFIG_START( daikaiju )
MCFG_MACHINE_START_OVERRIDE(lsasquad_state,lsasquad)
MCFG_MACHINE_RESET_OVERRIDE(lsasquad_state,lsasquad)
MCFG_GENERIC_LATCH_8_ADD("soundlatch")
MCFG_GENERIC_LATCH_DATA_PENDING_CB(DEVWRITELINE("soundnmi", input_merger_device, in_w<0>))
MCFG_INPUT_MERGER_ALL_HIGH("soundnmi")
MCFG_INPUT_MERGER_OUTPUT_HANDLER(INPUTLINE("audiocpu", INPUT_LINE_NMI))
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_REFRESH_RATE(60)

View File

@ -1,5 +1,8 @@
// license:BSD-3-Clause
// copyright-holders:Nicola Salmoria
#include "machine/gen_latch.h"
#include "machine/input_merger.h"
#include "machine/taito68705interface.h"
class lsasquad_state : public driver_device
@ -13,6 +16,9 @@ public:
m_priority_prom(*this, "prio_prom"),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_soundlatch(*this, "soundlatch"),
m_soundlatch2(*this, "soundlatch2"),
m_soundnmi(*this, "soundnmi"),
m_bmcu(*this, "bmcu"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette") { }
@ -23,17 +29,12 @@ public:
required_shared_ptr<uint8_t> m_spriteram;
required_region_ptr<uint8_t> m_priority_prom;
/* misc */
int m_sound_pending;
int m_sound_nmi_enable;
int m_pending_nmi;
int m_sound_cmd;
int m_sound_result;
/* devices */
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<generic_latch_8_device> m_soundlatch;
optional_device<generic_latch_8_device> m_soundlatch2;
optional_device<input_merger_device> m_soundnmi;
optional_device<taito68705_mcu_device> m_bmcu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
@ -41,12 +42,7 @@ public:
DECLARE_WRITE8_MEMBER(lsasquad_bankswitch_w);
DECLARE_WRITE8_MEMBER(lsasquad_sh_nmi_disable_w);
DECLARE_WRITE8_MEMBER(lsasquad_sh_nmi_enable_w);
DECLARE_WRITE8_MEMBER(lsasquad_sound_command_w);
DECLARE_READ8_MEMBER(lsasquad_sh_sound_command_r);
DECLARE_WRITE8_MEMBER(lsasquad_sh_result_w);
DECLARE_READ8_MEMBER(lsasquad_sound_result_r);
DECLARE_READ8_MEMBER(lsasquad_sound_status_r);
DECLARE_READ8_MEMBER(daikaiju_sh_sound_command_r);
DECLARE_READ8_MEMBER(daikaiju_sound_status_r);
DECLARE_READ8_MEMBER(lsasquad_mcu_status_r);

View File

@ -10,80 +10,29 @@
***************************************************************************/
TIMER_CALLBACK_MEMBER(lsasquad_state::nmi_callback)
{
if (m_sound_nmi_enable)
m_audiocpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
else
m_pending_nmi = 1;
}
WRITE8_MEMBER(lsasquad_state::lsasquad_sh_nmi_disable_w)
{
m_sound_nmi_enable = 0;
m_soundnmi->in_w<1>(0);
}
WRITE8_MEMBER(lsasquad_state::lsasquad_sh_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;
}
}
WRITE8_MEMBER(lsasquad_state::lsasquad_sound_command_w)
{
m_sound_pending |= 0x01;
m_sound_cmd = data;
//logerror("%04x: sound cmd %02x\n", space.device().safe_pc(), data);
machine().scheduler().synchronize(timer_expired_delegate(FUNC(lsasquad_state::nmi_callback),this), data);
}
READ8_MEMBER(lsasquad_state::lsasquad_sh_sound_command_r)
{
m_sound_pending &= ~0x01;
//logerror("%04x: read sound cmd %02x\n", space.device().safe_pc(), m_sound_cmd);
return m_sound_cmd;
}
WRITE8_MEMBER(lsasquad_state::lsasquad_sh_result_w)
{
m_sound_pending |= 0x02;
//logerror("%04x: sound res %02x\n", space.device().safe_pc(), data);
m_sound_result = data;
}
READ8_MEMBER(lsasquad_state::lsasquad_sound_result_r)
{
m_sound_pending &= ~0x02;
//logerror("%04x: read sound res %02x\n", space.device().safe_pc(), m_sound_result);
return m_sound_result;
m_soundnmi->in_w<1>(1);
}
READ8_MEMBER(lsasquad_state::lsasquad_sound_status_r)
{
/* bit 0: message pending for sound cpu */
/* bit 1: message pending for main cpu */
return m_sound_pending;
return (m_soundlatch->pending_r() ? 1 : 0) | (m_soundlatch2->pending_r() ? 2 : 0);
}
READ8_MEMBER(lsasquad_state::daikaiju_sh_sound_command_r)
{
m_sound_pending &= ~0x01;
m_sound_pending |= 0x02;
//logerror("%04x: read sound cmd %02x\n", space.device().safe_pc(), m_sound_cmd);
return m_sound_cmd;
}
READ8_MEMBER(lsasquad_state::daikaiju_sound_status_r)
{
/* bit 0: message pending for sound cpu */
/* bit 1: message pending for main cpu */
return m_sound_pending ^ 3;
return (m_soundlatch->pending_r() ? 2 : 1);
}
READ8_MEMBER(lsasquad_state::lsasquad_mcu_status_r)
@ -119,7 +68,6 @@ READ8_MEMBER(lsasquad_state::daikaiju_mcu_status_r)
res |= 0x02;
}
res |= ((m_sound_pending & 0x02) ^ 2) << 3; //inverted flag
m_sound_pending &= ~0x02;
res |= ((m_soundlatch->pending_r() & 0x02) ^ 2) << 3; //inverted flag
return res;
}