From 8e3ec32737d399e304e715da75e7782b374e1a30 Mon Sep 17 00:00:00 2001 From: DavidHaywood <28625134+DavidHaywood@users.noreply.github.com> Date: Thu, 21 Nov 2019 21:07:10 +0000 Subject: [PATCH] hook up victnine mcu, tested that it boots at least --- scripts/target/mame/arcade.lua | 1 - src/mame/drivers/flstory.cpp | 34 ++++++---- src/mame/includes/flstory.h | 8 +-- src/mame/machine/flstory.cpp | 110 --------------------------------- 4 files changed, 25 insertions(+), 128 deletions(-) delete mode 100644 src/mame/machine/flstory.cpp diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua index db7a4a86bed..4567d6b0b60 100644 --- a/scripts/target/mame/arcade.lua +++ b/scripts/target/mame/arcade.lua @@ -3876,7 +3876,6 @@ files { MAME_DIR .. "src/mame/video/fgoal.cpp", MAME_DIR .. "src/mame/drivers/flstory.cpp", MAME_DIR .. "src/mame/includes/flstory.h", - MAME_DIR .. "src/mame/machine/flstory.cpp", MAME_DIR .. "src/mame/video/flstory.cpp", MAME_DIR .. "src/mame/drivers/galastrm.cpp", MAME_DIR .. "src/mame/includes/galastrm.h", diff --git a/src/mame/drivers/flstory.cpp b/src/mame/drivers/flstory.cpp index effb7c703a9..cbf52f91079 100644 --- a/src/mame/drivers/flstory.cpp +++ b/src/mame/drivers/flstory.cpp @@ -7,7 +7,6 @@ added Victorious Nine by BUT TODO: - - hook up m68705 dump for Victorious Nine - TA7630 emulation needs filter support (bass sounds from MSM5232 should be about 2 times louder) ***************************************************************************/ @@ -33,6 +32,23 @@ WRITE8_MEMBER(flstory_state::snd_reset_w) m_audiocpu->set_input_line(INPUT_LINE_RESET, (data & 1 ) ? ASSERT_LINE : CLEAR_LINE); } +READ8_MEMBER(flstory_state::flstory_mcu_status_r) +{ + // bit 0 = when 1, MCU is ready to receive data from main CPU + // bit 1 = when 1, MCU has sent data to the main CPU + return + ((CLEAR_LINE == m_bmcu->host_semaphore_r()) ? 0x01 : 0x00) | + ((CLEAR_LINE != m_bmcu->mcu_semaphore_r()) ? 0x02 : 0x00); +} + + +READ8_MEMBER(flstory_state::victnine_mcu_status_r) +{ + uint8_t ret = flstory_mcu_status_r(space, offset) & 0x03; + ret |= m_extraio1->read() & 0xfc; + return ret; +} + void flstory_state::base_map(address_map &map) { map(0x0000, 0xbfff).rom(); @@ -93,19 +109,12 @@ void flstory_state::onna34ro_mcu_map(address_map &map) map(0xd805, 0xd805).r(FUNC(flstory_state::flstory_mcu_status_r)); } -CUSTOM_INPUT_MEMBER(flstory_state::victnine_mcu_status_bit01_r) -{ - address_space &space = m_maincpu->space(AS_PROGRAM); - - return (victnine_mcu_status_r(space, 0) & 3); -} - void flstory_state::victnine_map(address_map &map) { base_map(map); - map(0xd000, 0xd000).rw(FUNC(flstory_state::victnine_mcu_r), FUNC(flstory_state::victnine_mcu_w)); + map(0xd000, 0xd000).rw(m_bmcu, FUNC(taito68705_mcu_device::data_r), FUNC(taito68705_mcu_device::data_w)); - map(0xd805, 0xd805).portr("EXTRA_P1"); /* also mcu */ + map(0xd805, 0xd805).r(FUNC(flstory_state::victnine_mcu_status_r)); map(0xd807, 0xd807).portr("EXTRA_P2"); // map(0xda00, 0xda00).writeonly(); map(0xdce0, 0xdce0).rw(FUNC(flstory_state::victnine_gfxctrl_r), FUNC(flstory_state::victnine_gfxctrl_w)); @@ -507,7 +516,6 @@ static INPUT_PORTS_START( victnine ) /* bits 0,1 are MCU related: - bit 0: mcu is ready to receive data from main cpu - bit 1: mcu has sent data to the main cpu */ - PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_CUSTOM_MEMBER(flstory_state, victnine_mcu_status_bit01_r) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) @@ -831,6 +839,8 @@ void flstory_state::victnine(machine_config &config) m_maincpu->set_clock(XTAL(8'000'000)/2); /* 4 MHz */ m_maincpu->set_addrmap(AS_PROGRAM, &flstory_state::victnine_map); + TAITO68705_MCU(config, m_bmcu, XTAL(18'432'000)/6); + MCFG_MACHINE_RESET_OVERRIDE(flstory_state,flstory) /* video hardware */ @@ -1154,5 +1164,5 @@ GAME( 1985, flstory, 0, flstory, flstory, flstory_state, empty_in GAME( 1985, flstoryj, flstory, flstory, flstory, flstory_state, empty_init, ROT180, "Taito", "The FairyLand Story (Japan)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) GAME( 1985, onna34ro, 0, onna34ro_mcu, onna34ro, flstory_state, empty_init, ROT0, "Taito", "Onna Sanshirou - Typhoon Gal", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) GAME( 1985, onna34roa, onna34ro, onna34ro, onna34ro, flstory_state, empty_init, ROT0, "Taito", "Onna Sanshirou - Typhoon Gal (bootleg)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) -GAME( 1984, victnine, 0, victnine, victnine, flstory_state, empty_init, ROT0, "Taito", "Victorious Nine", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) // MCU still simulated +GAME( 1984, victnine, 0, victnine, victnine, flstory_state, empty_init, ROT0, "Taito", "Victorious Nine", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) GAME( 1984, rumba, 0, rumba, rumba, flstory_state, empty_init, ROT270, "Taito", "Rumba Lumber", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/includes/flstory.h b/src/mame/includes/flstory.h index c1a101d43e2..59663673b3b 100644 --- a/src/mame/includes/flstory.h +++ b/src/mame/includes/flstory.h @@ -33,7 +33,8 @@ public: m_palette(*this, "palette"), m_soundlatch(*this, "soundlatch"), m_soundlatch2(*this, "soundlatch2"), - m_soundnmi(*this, "soundnmi") + m_soundnmi(*this, "soundnmi"), + m_extraio1(*this, "EXTRA_P1") { } void common(machine_config &config); @@ -43,8 +44,6 @@ public: void victnine(machine_config &config); void onna34ro_mcu(machine_config &config); - DECLARE_CUSTOM_INPUT_MEMBER(victnine_mcu_status_bit01_r); - protected: virtual void machine_start() override; @@ -85,12 +84,11 @@ private: required_device m_soundlatch; required_device m_soundlatch2; required_device m_soundnmi; + optional_ioport m_extraio1; DECLARE_READ8_MEMBER(snd_flag_r); DECLARE_WRITE8_MEMBER(snd_reset_w); DECLARE_READ8_MEMBER(flstory_mcu_status_r); - DECLARE_WRITE8_MEMBER(victnine_mcu_w); - DECLARE_READ8_MEMBER(victnine_mcu_r); DECLARE_READ8_MEMBER(victnine_mcu_status_r); DECLARE_WRITE8_MEMBER(flstory_videoram_w); DECLARE_WRITE8_MEMBER(flstory_palette_w); diff --git a/src/mame/machine/flstory.cpp b/src/mame/machine/flstory.cpp deleted file mode 100644 index 5370ca8d67f..00000000000 --- a/src/mame/machine/flstory.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria -/*************************************************************************** - - machine.c - - Functions to emulate general aspects of the machine (RAM, ROM, interrupts, - I/O ports) - -***************************************************************************/ - -#include "emu.h" -#include "includes/flstory.h" - -READ8_MEMBER(flstory_state::flstory_mcu_status_r) -{ - // bit 0 = when 1, MCU is ready to receive data from main CPU - // bit 1 = when 1, MCU has sent data to the main CPU - return - ((CLEAR_LINE == m_bmcu->host_semaphore_r()) ? 0x01 : 0x00) | - ((CLEAR_LINE != m_bmcu->mcu_semaphore_r()) ? 0x02 : 0x00); -} - -#define VICTNINE_MCU_SEED (m_workram[0x685]) - -static const uint8_t victnine_mcu_data[0x100] = -{ - 0x3e, 0x08, 0xdd, 0x29, 0xcb, 0x14, 0xfd, 0x29, - 0xcb, 0x15, 0xd9, 0x29, 0xd9, 0x30, 0x0d, 0xd9, - 0x19, 0xd9, 0xdd, 0x09, 0x30, 0x01, 0x24, 0xfd, - 0x19, 0x30, 0x01, 0x2c, 0x3d, 0x20, 0xe3, 0xc9, - 0x11, 0x14, 0x00, 0x19, 0x7e, 0x32, 0xed, 0xe4, - 0x2a, 0x52, 0xe5, 0x22, 0xe9, 0xe4, 0x2a, 0x54, - 0xe5, 0x22, 0xeb, 0xe4, 0x21, 0x2a, 0xe6, 0xfe, - 0x06, 0x38, 0x02, 0xcb, 0xc6, 0xcb, 0xce, 0xc9, - 0x06, 0x00, 0x3a, 0xaa, 0xe4, 0x07, 0x07, 0x07, - 0xb0, 0x47, 0x3a, 0xab, 0xe4, 0x07, 0x07, 0xb0, - 0x47, 0x3a, 0xac, 0xe4, 0xe6, 0x03, 0xb0, 0x21, - 0xe3, 0xe6, 0xc9, 0x38, 0xe1, 0x29, 0x07, 0xc9, - 0x23, 0x7e, 0x47, 0xe6, 0x1f, 0x32, 0x0c, 0xe6, - 0x78, 0xe6, 0xe0, 0x07, 0x07, 0x47, 0xe6, 0x03, - 0x28, 0x06, 0xcb, 0x7a, 0x28, 0x02, 0xc6, 0x02, - 0x32, 0x0a, 0xe6, 0x78, 0xe6, 0x80, 0xc9, 0x3a, - 0x21, 0x29, 0xe5, 0x7e, 0xe6, 0xf8, 0xf6, 0x01, - 0x77, 0x23, 0x3a, 0x0a, 0xe6, 0x77, 0x21, 0x08, - 0xe6, 0xcb, 0xc6, 0xcb, 0x8e, 0x3a, 0x2b, 0xe5, - 0x21, 0xff, 0xe5, 0xfe, 0x02, 0xc9, 0x1f, 0xc6, - 0x47, 0x3a, 0xaa, 0xe4, 0xa7, 0x21, 0x00, 0xe5, - 0x28, 0x03, 0x21, 0x1b, 0xe5, 0x70, 0x3a, 0xaa, - 0xe4, 0xee, 0x01, 0x32, 0xaa, 0xe4, 0x21, 0xb0, - 0xe4, 0x34, 0x23, 0x36, 0x00, 0xc9, 0x2b, 0xb2, - 0xaf, 0x77, 0x12, 0x23, 0x13, 0x3c, 0xfe, 0x09, - 0x20, 0xf7, 0x3e, 0x01, 0x32, 0xad, 0xe4, 0x21, - 0x48, 0xe5, 0xcb, 0xfe, 0xc9, 0x32, 0xe5, 0xaa, - 0x21, 0x00, 0x13, 0xe4, 0x47, 0x1b, 0xa1, 0xc9, - 0x00, 0x08, 0x04, 0x0c, 0x05, 0x0d, 0x06, 0x0e, - 0x22, 0x66, 0xaa, 0x22, 0x33, 0x01, 0x11, 0x88, - 0x06, 0x05, 0x03, 0x04, 0x08, 0x01, 0x03, 0x02, - 0x06, 0x07, 0x02, 0x03, 0x15, 0x17, 0x11, 0x13 -}; - -WRITE8_MEMBER(flstory_state::victnine_mcu_w) -{ - uint8_t seed = VICTNINE_MCU_SEED; - - if (!seed && (data & 0x37) == 0x37) - { - m_from_mcu = 0xa6; - logerror("mcu initialize (%02x)\n", data); - } - else - { - data += seed; - - if ((data & ~0x1f) == 0xa0) - { - m_mcu_select = data & 0x1f; - //logerror("mcu select: 0x%02x\n", m_mcu_select); - } - else if (data < 0x20) - { - int offset = m_mcu_select * 8 + data; - - //logerror("mcu fetch: 0x%02x\n", offset); - m_from_mcu = victnine_mcu_data[offset]; - } - else if (data >= 0x38 && data <= 0x3a) - { - m_from_mcu = m_workram[0x691 - 0x38 + data]; - } - else - { - //logerror("mcu: 0x%02x: unknown command\n", data); - } - } -} - -READ8_MEMBER(flstory_state::victnine_mcu_r) -{ - //logerror("%04x: mcu read (0x%02x)\n", m_maincpu->pcbase(), m_from_mcu); - - return m_from_mcu - VICTNINE_MCU_SEED; -} - -READ8_MEMBER(flstory_state::victnine_mcu_status_r) -{ - int res = 3; - - return res; -}