From ac042242b7d04fe690a79b55a3b49af711885bb8 Mon Sep 17 00:00:00 2001 From: David Haywood <28625134+DavidHaywood@users.noreply.github.com> Date: Wed, 15 Jun 2022 11:37:26 +0100 Subject: mpu4: move some crystal specifics into crystal state, remove some unneccessary parts of the bootleg chr emuation (#9932) --- src/mame/drivers/mpu4.cpp | 52 -------------------- src/mame/drivers/mpu4crystal.cpp | 63 +++++++++++++++++++++++++ src/mame/drivers/mpu4unsorted.cpp | 34 ++++++------- src/mame/includes/mpu4.h | 7 +-- src/mame/machine/mpu4_characteriser_bootleg.cpp | 4 +- src/mame/machine/mpu4_characteriser_bootleg.h | 15 +----- 6 files changed, 85 insertions(+), 90 deletions(-) diff --git a/src/mame/drivers/mpu4.cpp b/src/mame/drivers/mpu4.cpp index dd61303fc78..2be04458a11 100644 --- a/src/mame/drivers/mpu4.cpp +++ b/src/mame/drivers/mpu4.cpp @@ -2111,58 +2111,6 @@ void mpu4_state::init_m4default_big() } -uint8_t mpu4_state::crystal_sound_r() -{ - return machine().rand(); -} -//this may be a YMZ280B -void mpu4_state::crystal_sound_w(uint8_t data) -{ - logerror("crystal_sound_w %02x\n",data); -} - -void mpu4_state::init_m_frkstn() -{ - address_space &space = m_maincpu->space(AS_PROGRAM); - init_m4default(); - space.install_read_handler(0x0880, 0x0880, read8smo_delegate(*this, FUNC(mpu4_state::crystal_sound_r))); - space.install_write_handler(0x0881, 0x0881, write8smo_delegate(*this, FUNC(mpu4_state::crystal_sound_w))); -} - -// thanks to Project Amber for descramble information -static void descramble_crystal( uint8_t* region, int start, int end, uint8_t extra_xor) -{ - for (int i=start;i( x^0xca , 3,2,1,0,7,4,6,5 ); break; - case 0x10: x = bitswap<8>( x^0x30 , 3,0,4,6,1,5,7,2 ); break; - case 0x18: x = bitswap<8>( x^0x89 , 4,1,2,5,7,0,6,3 ); break; - case 0x40: x = bitswap<8>( x^0x14 , 6,1,4,3,2,5,0,7 ); break; - case 0x48: x = bitswap<8>( x^0x40 , 1,0,3,2,5,4,7,6 ); break; - case 0x50: x = bitswap<8>( x^0xcb , 3,2,1,0,7,6,5,4 ); break; - case 0x58: x = bitswap<8>( x^0xc0 , 2,3,6,0,5,1,7,4 ); break; - } - region[i] = x ^ extra_xor; - } -} - - -void mpu4_state::init_crystal() -{ - init_m_frkstn(); - descramble_crystal(memregion( "maincpu" )->base(), 0x0000, 0x10000, 0x00); -} - -void mpu4_state::init_crystali() -{ - init_m_frkstn(); - descramble_crystal(memregion( "maincpu" )->base(), 0x0000, 0x10000, 0xff); // invert after decrypt?! -} - /* generate a 50 Hz signal (based on an RC time) */ TIMER_DEVICE_CALLBACK_MEMBER(mpu4_state::gen_50hz) { diff --git a/src/mame/drivers/mpu4crystal.cpp b/src/mame/drivers/mpu4crystal.cpp index df07f00c1b6..47c42a99915 100644 --- a/src/mame/drivers/mpu4crystal.cpp +++ b/src/mame/drivers/mpu4crystal.cpp @@ -17,9 +17,72 @@ public: mpu4_state(mconfig, type, tag) { } + + void init_crystali(); + void init_crystal(); + void init_m_frkstn(); + +private: + uint8_t crystal_sound_r(); + void crystal_sound_w(uint8_t data); }; +uint8_t mpu4crystal_machines_state::crystal_sound_r() +{ + return machine().rand(); +} + +//this may be a YMZ280B +void mpu4crystal_machines_state::crystal_sound_w(uint8_t data) +{ + logerror("crystal_sound_w %02x\n",data); +} + +void mpu4crystal_machines_state::init_m_frkstn() +{ + address_space &space = m_maincpu->space(AS_PROGRAM); + init_m4default(); + space.install_read_handler(0x0880, 0x0880, read8smo_delegate(*this, FUNC(mpu4crystal_machines_state::crystal_sound_r))); + space.install_write_handler(0x0881, 0x0881, write8smo_delegate(*this, FUNC(mpu4crystal_machines_state::crystal_sound_w))); +} + +// thanks to Project Amber for descramble information +static void descramble_crystal(uint8_t* region, int start, int end, uint8_t extra_xor) +{ + for (int i=start;i( x^0xca , 3,2,1,0,7,4,6,5 ); break; + case 0x10: x = bitswap<8>( x^0x30 , 3,0,4,6,1,5,7,2 ); break; + case 0x18: x = bitswap<8>( x^0x89 , 4,1,2,5,7,0,6,3 ); break; + case 0x40: x = bitswap<8>( x^0x14 , 6,1,4,3,2,5,0,7 ); break; + case 0x48: x = bitswap<8>( x^0x40 , 1,0,3,2,5,4,7,6 ); break; + case 0x50: x = bitswap<8>( x^0xcb , 3,2,1,0,7,6,5,4 ); break; + case 0x58: x = bitswap<8>( x^0xc0 , 2,3,6,0,5,1,7,4 ); break; + } + region[i] = x ^ extra_xor; + } +} + + +void mpu4crystal_machines_state::init_crystal() +{ + init_m_frkstn(); + descramble_crystal(memregion( "maincpu" )->base(), 0x0000, 0x10000, 0x00); +} + +void mpu4crystal_machines_state::init_crystali() +{ + init_m_frkstn(); + descramble_crystal(memregion( "maincpu" )->base(), 0x0000, 0x10000, 0xff); // invert after decrypt?! +} + + + #define M4FRKSTN_SOUND \ ROM_REGION( 0x40000, "upd", 0 ) \ ROM_LOAD("fr1snd.bin", 0x00000, 0x40000, CRC(2d77bbde) SHA1(0397ede538e913dc2972e260589022564fcd8fe4) ) diff --git a/src/mame/drivers/mpu4unsorted.cpp b/src/mame/drivers/mpu4unsorted.cpp index e2cc15d7ea3..024bed06a94 100644 --- a/src/mame/drivers/mpu4unsorted.cpp +++ b/src/mame/drivers/mpu4unsorted.cpp @@ -2304,23 +2304,23 @@ GAME(199?, m4brnzeb, m4brnze, mod4oki, mpu4, mpu4unsorted_state, init_ /* *if* these are MPU4 they have a different sound system at least - The copyright strings in them are 'AET' tho (Ace?) - Could be related to the Crystal stuff? */ -GAME(199?, m4sbx, 0, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Super Bear X (MPU4?) (set 1)",GAME_FLAGS ) -GAME(199?, m4sbxa, m4sbx, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Super Bear X (MPU4?) (set 2)",GAME_FLAGS ) -GAME(199?, m4sbxb, m4sbx, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Super Bear X (MPU4?) (set 3)",GAME_FLAGS ) -GAME(199?, m4sbxc, m4sbx, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Super Bear X (MPU4?) (set 4)",GAME_FLAGS ) -GAME(199?, m4sbxd, m4sbx, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Super Bear X (MPU4?) (set 5)",GAME_FLAGS ) -GAME(199?, m4sbxe, m4sbx, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Super Bear X (MPU4?) (set 6)",GAME_FLAGS ) - -GAME(199?, m4bclimb, 0, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Bear Climber (MPU4?)",GAME_FLAGS ) -GAME(199?, m4captb, 0, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Captain Bear (MPU4?)",GAME_FLAGS ) -GAME(199?, m4jungj, 0, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Jungle Japes (MPU4?) (set 1)",GAME_FLAGS ) -GAME(199?, m4jungja, m4jungj, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Jungle Japes (MPU4?) (set 2)",GAME_FLAGS ) -GAME(199?, m4jungjb, m4jungj, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Jungle Japes (MPU4?) (set 3)",GAME_FLAGS ) -GAME(199?, m4jungjc, m4jungj, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Jungle Japes (MPU4?) (set 4)",GAME_FLAGS ) - -GAME(199?, m4fsx, 0, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Fun Spot X (MPU4?) (set 1)",GAME_FLAGS ) -GAME(199?, m4fsxa, m4fsx, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Fun Spot X (MPU4?) (set 2)",GAME_FLAGS ) -GAME(199?, m4fsxb, m4fsx, mpu4crys, mpu4, mpu4unsorted_state, init_m_frkstn, ROT0, "AET/Coinworld","Fun Spot X (MPU4?) (set 3)",GAME_FLAGS ) +GAME(199?, m4sbx, 0, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Super Bear X (MPU4?) (set 1)",GAME_FLAGS ) +GAME(199?, m4sbxa, m4sbx, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Super Bear X (MPU4?) (set 2)",GAME_FLAGS ) +GAME(199?, m4sbxb, m4sbx, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Super Bear X (MPU4?) (set 3)",GAME_FLAGS ) +GAME(199?, m4sbxc, m4sbx, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Super Bear X (MPU4?) (set 4)",GAME_FLAGS ) +GAME(199?, m4sbxd, m4sbx, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Super Bear X (MPU4?) (set 5)",GAME_FLAGS ) +GAME(199?, m4sbxe, m4sbx, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Super Bear X (MPU4?) (set 6)",GAME_FLAGS ) + +GAME(199?, m4bclimb, 0, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Bear Climber (MPU4?)",GAME_FLAGS ) +GAME(199?, m4captb, 0, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Captain Bear (MPU4?)",GAME_FLAGS ) +GAME(199?, m4jungj, 0, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Jungle Japes (MPU4?) (set 1)",GAME_FLAGS ) +GAME(199?, m4jungja, m4jungj, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Jungle Japes (MPU4?) (set 2)",GAME_FLAGS ) +GAME(199?, m4jungjb, m4jungj, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Jungle Japes (MPU4?) (set 3)",GAME_FLAGS ) +GAME(199?, m4jungjc, m4jungj, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Jungle Japes (MPU4?) (set 4)",GAME_FLAGS ) + +GAME(199?, m4fsx, 0, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Fun Spot X (MPU4?) (set 1)",GAME_FLAGS ) +GAME(199?, m4fsxa, m4fsx, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Fun Spot X (MPU4?) (set 2)",GAME_FLAGS ) +GAME(199?, m4fsxb, m4fsx, mpu4crys, mpu4, mpu4unsorted_state, init_m4default, ROT0, "AET/Coinworld","Fun Spot X (MPU4?) (set 3)",GAME_FLAGS ) // Error 42 then 52, 54 GAME(199?, m4ccop, 0, mod4oki_cheatchr, mpu4_cw, mpu4unsorted_state, init_m4default, ROT0, "Coinworld","Cash Cops (MPU4?) (set 1)",GAME_FLAGS ) diff --git a/src/mame/includes/mpu4.h b/src/mame/includes/mpu4.h index a3f208d3730..30a241d3764 100644 --- a/src/mame/includes/mpu4.h +++ b/src/mame/includes/mpu4.h @@ -145,10 +145,8 @@ public: void init_m4default_big_aux2inv(); void init_m4default_806prot(); - void init_crystali(); void init_m4tst2(); - void init_crystal(); - void init_m_frkstn(); + void init_m4default_banks(); void init_m4default_reels(); void init_m4_low_volt_alt(); @@ -405,8 +403,7 @@ protected: void mpu4_ym2413_w(offs_t offset, uint8_t data); uint8_t mpu4_ym2413_r(offs_t offset); - uint8_t crystal_sound_r(); - void crystal_sound_w(uint8_t data); + void ic3ss_w(offs_t offset, uint8_t data); DECLARE_WRITE_LINE_MEMBER(cpu0_irq); DECLARE_WRITE_LINE_MEMBER(ic2_o1_callback); diff --git a/src/mame/machine/mpu4_characteriser_bootleg.cpp b/src/mame/machine/mpu4_characteriser_bootleg.cpp index e26205b38dd..62dbb19e9bf 100644 --- a/src/mame/machine/mpu4_characteriser_bootleg.cpp +++ b/src/mame/machine/mpu4_characteriser_bootleg.cpp @@ -20,9 +20,7 @@ mpu4_characteriser_bl::mpu4_characteriser_bl(const machine_config &mconfig, cons } mpu4_characteriser_bl::mpu4_characteriser_bl(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, type, tag, owner, clock), - m_cpu(*this, finder_base::DUMMY_TAG), - m_allow_6809_cheat(false) + device_t(mconfig, type, tag, owner, clock) { } diff --git a/src/mame/machine/mpu4_characteriser_bootleg.h b/src/mame/machine/mpu4_characteriser_bootleg.h index 70402a4172b..85496f437ee 100644 --- a/src/mame/machine/mpu4_characteriser_bootleg.h +++ b/src/mame/machine/mpu4_characteriser_bootleg.h @@ -20,17 +20,6 @@ class mpu4_characteriser_bl : public device_t public: // construction/destruction mpu4_characteriser_bl(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - mpu4_characteriser_bl(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); - - template void set_cpu_tag(T&& tag) - { - m_cpu.set_tag(std::forward(tag)); - } - - void set_allow_6809_cheat(bool allow) - { - m_allow_6809_cheat = allow; - } void set_bl_fixed_return(uint8_t ret) { @@ -49,12 +38,12 @@ public: } protected: + mpu4_characteriser_bl(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); + virtual void device_start() override; virtual void device_reset() override; private: - optional_device m_cpu; // needed for some of the protection 'cheats' - bool m_allow_6809_cheat; uint8_t m_blfixedreturn = 0; }; -- cgit v1.2.3