stfight.cpp: fix ADPCM control

* Latch ADPCM counter on the correct edge
* Remove unused members, eliminate function statics, and fix up save state registration
* Reduce runtime tagmap lookups
This commit is contained in:
Vas Crabb 2017-01-17 15:56:55 +11:00
parent 234fa8890d
commit 7e96b08b15
4 changed files with 111 additions and 121 deletions

View File

@ -61,28 +61,23 @@ const device_type MSM6585 = &device_creator<msm6585_device>;
msm5205_device::msm5205_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, MSM5205, "MSM5205", tag, owner, clock, "msm5205", __FILE__),
device_sound_interface(mconfig, *this),
m_s1(false),
m_s2(false),
m_bitwidth(4),
m_vclk_cb(*this)
: msm5205_device(mconfig, MSM5205, "MSM5205", tag, owner, clock, "msm5205", __FILE__)
{
}
msm5205_device::msm5205_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, u32 clock, const char *shortname, const char *source)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_sound_interface(mconfig, *this),
m_s1(false),
m_s2(false),
m_bitwidth(4),
m_vclk_cb(*this)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_sound_interface(mconfig, *this),
m_s1(false),
m_s2(false),
m_bitwidth(4),
m_vclk_cb(*this)
{
}
msm6585_device::msm6585_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: msm5205_device(mconfig, MSM6585, "MSM6585", tag, owner, clock, "msm6585", __FILE__)
: msm5205_device(mconfig, MSM6585, "MSM6585", tag, owner, clock, "msm6585", __FILE__)
{
}

View File

@ -1055,13 +1055,13 @@ ROM_END
// Note: Marked MACHINE_IMPERFECT_SOUND due to YM2203 clock issue
GAME( 1986, empcity, 0, stfight, stfight, stfight_state, empcity, ROT0, "Seibu Kaihatsu", "Empire City: 1931 (bootleg?)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
GAME( 1986, empcityu, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Taito / Romstar license)", "Empire City: 1931 (US)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) // different title logo
GAME( 1986, empcityj, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Taito license)", "Empire City: 1931 (Japan)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
GAME( 1986, empcityi, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Eurobed license)", "Empire City: 1931 (Italy)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
GAME( 1986, stfight, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Tuning license)", "Street Fight (Germany)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
GAME( 1986, stfighta, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu", "Street Fight (bootleg?)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
GAME( 1986, stfightgb,empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Tuning license)", "Street Fight (Germany - Benelux)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
GAME( 1986, empcity, 0, stfight, stfight, stfight_state, empcity, ROT0, "Seibu Kaihatsu", "Empire City: 1931 (bootleg?)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
GAME( 1986, empcityu, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Taito / Romstar license)", "Empire City: 1931 (US)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) // different title logo
GAME( 1986, empcityj, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Taito license)", "Empire City: 1931 (Japan)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
GAME( 1986, empcityi, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Eurobed license)", "Empire City: 1931 (Italy)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
GAME( 1986, stfight, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Tuning license)", "Street Fight (Germany)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
GAME( 1986, stfighta, empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu", "Street Fight (bootleg?)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
GAME( 1986, stfightgb,empcity, stfight, stfight, stfight_state, stfight, ROT0, "Seibu Kaihatsu (Tuning license)", "Street Fight (Germany - Benelux)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
/* Cross Shooter uses the same base board, but different video board */
GAME( 1987, cshootert, airraid, cshooter, cshooter, stfight_state, cshooter, ROT270, "Seibu Kaihatsu (Taito license)", "Cross Shooter (2 PCB Stack)", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
// Cross Shooter uses the same base board, but different video board
GAME( 1987, cshootert,airraid, cshooter, cshooter, stfight_state, cshooter, ROT270, "Seibu Kaihatsu (Taito license)", "Cross Shooter (2 PCB Stack)", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )

View File

@ -13,37 +13,26 @@ public:
};
stfight_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_mcu(*this, "mcu"),
m_msm(*this, "msm"),
m_palette(*this, "palette"),
m_decrypted_opcodes(*this, "decrypted_opcodes"),
m_stfight_video(*this, "stfight_vid"),
m_airraid_video(*this, "airraid_vid")
{ }
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<cpu_device> m_mcu;
required_device<msm5205_device> m_msm;
required_device<palette_device> m_palette;
optional_shared_ptr<uint8_t> m_decrypted_opcodes;
optional_device<stfight_video_device> m_stfight_video;
optional_device<airraid_video_device> m_airraid_video;
uint8_t *m_decrypt;
uint8_t m_fm_data;
uint8_t m_cpu_to_mcu_data;
uint8_t m_cpu_to_mcu_empty;
uint16_t m_adpcm_data_offs;
uint8_t m_adpcm_nibble;
uint8_t m_adpcm_reset;
uint8_t m_coin_state;
: driver_device(mconfig, type, tag)
, m_coin_mech(*this, "COIN")
, m_maincpu(*this, "maincpu")
, m_audiocpu(*this, "audiocpu")
, m_mcu(*this, "mcu")
, m_msm(*this, "msm")
, m_main_bank(*this, "mainbank")
, m_samples(*this, "adpcm")
, m_decrypted_opcodes(*this, "decrypted_opcodes")
, m_coin_state(0)
, m_fm_data(0)
, m_cpu_to_mcu_empty(true)
, m_cpu_to_mcu_data(0x0f)
, m_port_a_out(0xff)
, m_port_c_out(0xff)
, m_vck2(false)
, m_adpcm_reset(true)
, m_adpcm_data_offs(0x0000)
{
}
DECLARE_WRITE_LINE_MEMBER(stfight_adpcm_int);
@ -59,13 +48,8 @@ public:
DECLARE_WRITE8_MEMBER(stfight_bank_w);
DECLARE_READ8_MEMBER(stfight_fm_r);
virtual void machine_start() override;
virtual void machine_reset() override;
INTERRUPT_GEN_MEMBER(stfight_vb_interrupt);
// MCU specifics
@ -74,8 +58,34 @@ public:
DECLARE_WRITE8_MEMBER(stfight_68705_port_b_w);
DECLARE_WRITE8_MEMBER(stfight_68705_port_c_w);
uint8_t m_portC_out;
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
required_ioport m_coin_mech;
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<cpu_device> m_mcu;
required_device<msm5205_device> m_msm;
required_memory_bank m_main_bank;
required_region_ptr<uint8_t> m_samples;
optional_shared_ptr<uint8_t> m_decrypted_opcodes;
uint8_t m_coin_state;
uint8_t m_fm_data;
bool m_cpu_to_mcu_empty;
uint8_t m_cpu_to_mcu_data;
uint8_t m_port_a_out;
uint8_t m_port_c_out;
bool m_vck2;
bool m_adpcm_reset;
uint16_t m_adpcm_data_offs;
};

View File

@ -10,11 +10,11 @@
***************************************************************************/
#include "emu.h"
#include "cpu/z80/z80.h"
#include "sound/msm5205.h"
#include "includes/stfight.h"
#include "cpu/m6805/m68705.h"
#include "cpu/z80/z80.h"
#include "sound/msm5205.h"
/*
@ -37,7 +37,7 @@ Encryption PAL 16R4 on CPU board
*/
DRIVER_INIT_MEMBER(stfight_state,empcity)
DRIVER_INIT_MEMBER(stfight_state, empcity)
{
uint8_t *rom = memregion("maincpu")->base();
@ -64,35 +64,40 @@ DRIVER_INIT_MEMBER(stfight_state,empcity)
}
DRIVER_INIT_MEMBER(stfight_state,stfight)
DRIVER_INIT_MEMBER(stfight_state, stfight)
{
DRIVER_INIT_CALL(empcity);
}
DRIVER_INIT_MEMBER(stfight_state,cshooter)
DRIVER_INIT_MEMBER(stfight_state, cshooter)
{
}
void stfight_state::machine_start()
{
membank("mainbank")->configure_entries(0, 4, memregion("maincpu")->base() + 0x10000, 0x4000);
membank("mainbank")->set_entry(0);
m_main_bank->configure_entries(0, 4, memregion("maincpu")->base() + 0x10000, 0x4000);
m_main_bank->set_entry(0);
save_item(NAME(m_coin_state));
save_item(NAME(m_fm_data));
save_item(NAME(m_cpu_to_mcu_empty));
save_item(NAME(m_adpcm_data_offs));
save_item(NAME(m_adpcm_nibble));
save_item(NAME(m_cpu_to_mcu_data));
save_item(NAME(m_port_a_out));
save_item(NAME(m_port_c_out));
save_item(NAME(m_vck2));
save_item(NAME(m_adpcm_reset));
save_item(NAME(m_coin_state));
save_item(NAME(m_portC_out));
save_item(NAME(m_adpcm_data_offs));
}
void stfight_state::machine_reset()
{
m_fm_data = 0;
m_adpcm_reset = 1;
m_cpu_to_mcu_empty = 1;
m_cpu_to_mcu_empty = true;
m_adpcm_reset = true;
// Coin signals are active low
m_coin_state = 3;
@ -102,15 +107,7 @@ void stfight_state::machine_reset()
// - in fact I don't even know how/where it's switched in!
WRITE8_MEMBER(stfight_state::stfight_bank_w)
{
uint8_t bank_num = 0;
if(data & 0x80)
bank_num |= 2;
if(data & 0x04)
bank_num |= 1;
membank("mainbank")->set_entry(bank_num);
m_main_bank->set_entry(bitswap(data, 7, 2));
}
/*
@ -169,26 +166,19 @@ WRITE8_MEMBER(stfight_state::stfight_coin_w)
WRITE_LINE_MEMBER(stfight_state::stfight_adpcm_int)
{
static int m_vck2 = 0;
// Falling edge triggered interrupt at half the rate of /VCK?
if (m_vck2)
m_mcu->set_input_line(0, HOLD_LINE);
m_vck2 ^= 1;
m_mcu->set_input_line(M68705_IRQ_LINE, m_vck2 ? ASSERT_LINE : CLEAR_LINE);
m_vck2 = !m_vck2;
if (!m_adpcm_reset)
{
const uint8_t *samples = memregion("adpcm")->base();
uint8_t adpcm_data = samples[m_adpcm_data_offs & 0x7fff];
uint8_t adpcm_data = m_samples[(m_adpcm_data_offs >> 1) & 0x7fff];
if (m_adpcm_nibble == 0)
if (!BIT(m_adpcm_data_offs, 0))
adpcm_data >>= 4;
else
++m_adpcm_data_offs;
++m_adpcm_data_offs;
m_msm->data_w(adpcm_data & 0x0f);
m_adpcm_nibble ^= 1;
}
}
@ -205,10 +195,11 @@ WRITE8_MEMBER(stfight_state::stfight_fm_w)
READ8_MEMBER(stfight_state::stfight_fm_r)
{
uint8_t data = m_fm_data;
uint8_t const data = m_fm_data;
// Acknowledge the command
m_fm_data &= ~0x80;
if (!space.debugger_access())
m_fm_data &= ~0x80;
return data;
}
@ -221,51 +212,45 @@ READ8_MEMBER(stfight_state::stfight_fm_r)
WRITE8_MEMBER(stfight_state::stfight_mcu_w)
{
m_cpu_to_mcu_data = data & 0x0f;
m_cpu_to_mcu_empty = 0;
m_cpu_to_mcu_empty = false;
}
WRITE8_MEMBER(stfight_state::stfight_68705_port_a_w)
{
m_adpcm_data_offs = data << 8;
m_port_a_out = data;
}
READ8_MEMBER(stfight_state::stfight_68705_port_b_r)
{
return (ioport("COIN")->read() << 6) | (m_cpu_to_mcu_empty << 4) | m_cpu_to_mcu_data;
return
(m_coin_mech->read() << 6) |
(m_cpu_to_mcu_empty ? 0x10 : 0x00) |
(m_cpu_to_mcu_data & 0x0f);
}
WRITE8_MEMBER(stfight_state::stfight_68705_port_b_w)
{
// Acknowledge Z80 command
if (BIT(mem_mask, 5) && !BIT(data, 5))
m_cpu_to_mcu_empty = 1;
if (!BIT(data, 5))
m_cpu_to_mcu_empty = true;
}
WRITE8_MEMBER(stfight_state::stfight_68705_port_c_w)
{
// Signal a valid coin on the falling edge
if (BIT(mem_mask, 0) && BIT(m_portC_out, 0) && !BIT(data, 0))
if (BIT(m_port_c_out, 0) && !BIT(data, 0))
m_coin_state &= ~1;
if (BIT(mem_mask, 1) && BIT(m_portC_out, 1) && !BIT(data, 1))
if (BIT(m_port_c_out, 1) && !BIT(data, 1))
m_coin_state &= ~2;
if (BIT(mem_mask, 2))
{
if (BIT(data, 2))
{
m_adpcm_reset = 1;
m_adpcm_nibble = 0;
m_msm->reset_w(1);
}
else
{
m_adpcm_reset = 0;
m_msm->reset_w(0);
}
}
// Latch ADPCM data address when dropping the reset line
m_adpcm_reset = BIT(data, 2);
if (!m_adpcm_reset && BIT(m_port_c_out, 2))
m_adpcm_data_offs = m_port_a_out << 9;
m_msm->reset_w(m_adpcm_reset ? ASSERT_LINE : CLEAR_LINE);
if (BIT(mem_mask, 3))
m_maincpu->set_input_line(INPUT_LINE_NMI, BIT(data, 3) ? CLEAR_LINE : ASSERT_LINE);
// Generate NMI on host CPU (used on handshake error or stuck coin)
m_maincpu->set_input_line(INPUT_LINE_NMI, BIT(data, 3) ? CLEAR_LINE : ASSERT_LINE);
m_portC_out = data;
m_port_c_out = data;
}