From 857616904ee9a1e9413889a86bb1c1b4721da4bf Mon Sep 17 00:00:00 2001 From: grullosgo <42551661+grullosgo@users.noreply.github.com> Date: Sun, 1 Sep 2019 00:55:20 -0300 Subject: Added NEC D315-5136 device (#5577) Added NEC D315-5136 decrypt device for use on Lucky8k game (goldstar.cpp) --- src/mame/drivers/goldstar.cpp | 17 ++++++++++++--- src/mame/includes/goldstar.h | 3 ++- src/mame/machine/segacrp2_device.cpp | 42 ++++++++++++++++++++++++++++++++++++ src/mame/machine/segacrp2_device.h | 9 ++++++++ 4 files changed, 67 insertions(+), 4 deletions(-) diff --git a/src/mame/drivers/goldstar.cpp b/src/mame/drivers/goldstar.cpp index e365a07f8ab..242ac6b37c5 100644 --- a/src/mame/drivers/goldstar.cpp +++ b/src/mame/drivers/goldstar.cpp @@ -217,6 +217,7 @@ #include "cpu/z80/z80.h" #include "cpu/mcs51/mcs51.h" +#include "machine/segacrp2_device.h" #include "machine/nvram.h" #include "sound/ay8910.h" #include "sound/okim6295.h" @@ -940,7 +941,7 @@ void goldstar_state::lucky8_map(address_map &map) map(0xf800, 0xffff).ram(); } -void goldstar_state::lucky8f_decrypted_opcodes_map(address_map &map) +void goldstar_state::common_decrypted_opcodes_map(address_map &map) { map(0x0000, 0x7fff).rom().share("decrypted_opcodes"); } @@ -8971,7 +8972,17 @@ void wingco_state::lucky8f(machine_config &config) { lucky8(config); - m_maincpu->set_addrmap(AS_OPCODES, &wingco_state::lucky8f_decrypted_opcodes_map); + m_maincpu->set_addrmap(AS_OPCODES, &wingco_state::common_decrypted_opcodes_map); +} + +void wingco_state::lucky8k(machine_config &config) +{ + lucky8(config); + + nec_315_5136_device &maincpu(NEC_315_5136(config.replace(), m_maincpu, CPU_CLOCK)); + maincpu.set_addrmap(AS_PROGRAM, &wingco_state::lucky8_map); + maincpu.set_addrmap(AS_OPCODES, &wingco_state::common_decrypted_opcodes_map); + maincpu.set_decrypted_tag(m_decrypted_opcodes); } void wingco_state::bingowng(machine_config &config) @@ -17638,7 +17649,7 @@ GAMEL( 1989, lucky8g, lucky8, lucky8, lucky8, wingco_state, empty_init GAMEL( 1991, lucky8h, lucky8, lucky8, lucky8, wingco_state, empty_init, ROT0, "", "New Lucky 8 Lines Super Turbo (Hack)", 0, layout_lucky8 ) // 2 control sets... GAMEL( 1989, lucky8i, lucky8, lucky8, lucky8, wingco_state, empty_init, ROT0, "Eagle/Wing", "New Lucky 8 Lines (set 9, W-4, Eagle, licensed by Wing)", 0, layout_lucky8 ) // 2 control sets... GAMEL( 199?, lucky8j, lucky8, lucky8, lucky8, wingco_state, empty_init, ROT0, "", "New Lucky 8 Lines Crown Turbo (Hack)", MACHINE_NOT_WORKING, layout_lucky8 ) // 2 control sets... -GAMEL( 1989, lucky8k, lucky8, lucky8, lucky8, wingco_state, empty_init, ROT0, "Wing Co., Ltd.", "New Lucky 8 Lines (set 10, W-4, encrypted NEC D315-5136)", MACHINE_NOT_WORKING, layout_lucky8 ) // 2 control sets... +GAMEL( 1989, lucky8k, lucky8, lucky8k, lucky8, wingco_state, empty_init, ROT0, "Wing Co., Ltd.", "New Lucky 8 Lines (set 10, W-4, encrypted NEC D315-5136)", 0, layout_lucky8 ) // 2 control sets... GAMEL( 198?, ns8lines, 0, lucky8, lucky8b, wingco_state, empty_init, ROT0, "", "New Lucky 8 Lines / New Super 8 Lines (W-4)", 0, layout_lucky8p1 ) // only 1 control set... GAMEL( 1985, ns8linesa, ns8lines, lucky8, lucky8b, wingco_state, empty_init, ROT0, "Yamate (bootleg)", "New Lucky 8 Lines / New Super 8 Lines (W-4, Lucky97 HW)", 0, layout_lucky8p1 ) // only 1 control set... GAMEL( 198?, ns8linew, ns8lines, lucky8, ns8linew, wingco_state, empty_init, ROT0, "", "New Lucky 8 Lines / New Super 8 Lines (F-5, Witch Bonus)", 0, layout_lucky8 ) // 2 control sets... diff --git a/src/mame/includes/goldstar.h b/src/mame/includes/goldstar.h index 7358f98d951..da7fb724259 100644 --- a/src/mame/includes/goldstar.h +++ b/src/mame/includes/goldstar.h @@ -87,7 +87,7 @@ public: void ladylinr_map(address_map &map); void ladylinrb_decrypted_opcodes_map(address_map &map); void lucky8_map(address_map &map); - void lucky8f_decrypted_opcodes_map(address_map &map); + void common_decrypted_opcodes_map(address_map &map); void mbstar_map(address_map &map); void megaline_portmap(address_map &map); void ncb3_readwriteport(address_map &map); @@ -252,6 +252,7 @@ public: void flaming7(machine_config &config); void lucky8(machine_config &config); void lucky8f(machine_config &config); + void lucky8k(machine_config &config); void wcat3(machine_config &config); void magodds(machine_config &config); void flam7_w4(machine_config &config); diff --git a/src/mame/machine/segacrp2_device.cpp b/src/mame/machine/segacrp2_device.cpp index f570d937ddf..f811dddb668 100644 --- a/src/mame/machine/segacrp2_device.cpp +++ b/src/mame/machine/segacrp2_device.cpp @@ -24,6 +24,7 @@ List of encrypted games currently known: CPU Part # Game Comments + 315-5136 New Lucky 8 Lines (set 7, W-4, encrypted) 315-5162 4D Warriors & used I'm Sorry for k.p.a. Rafflesia & Wonder Boy (set 4) @@ -84,6 +85,7 @@ static void decode(uint8_t *rom, uint8_t *decrypted, } } +DEFINE_DEVICE_TYPE(NEC_315_5136, nec_315_5136_device, "nec_315_5179", "Nec 315-5136") DEFINE_DEVICE_TYPE(SEGA_315_5179, sega_315_5179_device, "sega_315_5179", "Sega 315-5179") DEFINE_DEVICE_TYPE(SEGA_315_5178, sega_315_5178_device, "sega_315_5178", "Sega 315-5178") DEFINE_DEVICE_TYPE(SEGA_315_5177, sega_315_5177_device, "sega_315_5177", "Sega 315-5177") // also seen as 317-5000 @@ -103,6 +105,46 @@ void segacrp2_z80_device::device_start() { z80_device::device_start(); decrypt() void segacrp2_z80_device::device_reset() { z80_device::device_reset(); } void segacrp2_z80_device::decrypt() { } +nec_315_5136_device::nec_315_5136_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : segacrp2_z80_device(mconfig, NEC_315_5136, tag, owner, clock) {} + +void nec_315_5136_device::decrypt() +{ + // 315-5136 + static const uint8_t xor_table[128] = + { + 0x00,0x40, 0x10,0x50, 0x04,0x44, 0x14,0x54, 0x01,0x41, 0x11,0x51, 0x05,0x45, 0x15,0x55, + 0x00,0x40, 0x10,0x50, 0x04,0x44, 0x14,0x54, 0x01,0x41, 0x11,0x51, 0x05,0x45, 0x15,0x55, + 0x00,0x40, 0x10,0x50, 0x04,0x44, 0x14,0x54, 0x01,0x41, 0x11,0x51, 0x05,0x45, 0x15,0x55, + 0x00,0x40, 0x10,0x50, 0x04,0x44, 0x14,0x54, 0x01,0x41, 0x11,0x51, 0x05,0x45, 0x15,0x55, + + 0x50,0x10, 0x44,0x04, 0x54,0x14, 0x41,0x01, 0x51,0x11, 0x45,0x05, 0x55,0x15, 0x40,0x00, + 0x50,0x10, 0x44,0x04, 0x54,0x14, 0x41,0x01, 0x51,0x11, 0x45,0x05, 0x55,0x15, 0x40,0x00, + 0x50,0x10, 0x44,0x04, 0x54,0x14, 0x41,0x01, 0x51,0x11, 0x45,0x05, 0x55,0x15, 0x40,0x00, + 0x50,0x10, 0x44,0x04, 0x54,0x14, 0x41,0x01, 0x51,0x11, 0x45,0x05, 0x55,0x15, 0x40,0x00 + }; + + static const int swap_table[128] = + { + 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14, + 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14, + 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, + 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, + 0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16, + 0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16, + 0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17, + 0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01, + 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, + 0x02,0x02,0x02,0x02,0x02,0x02,0x03,0x03, + 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, + 0x03,0x03,0x03,0x03,0x03,0x03,0x04,0x04 + }; + + decode(memregion(tag())->base(), m_decrypted, xor_table, swap_table); +} sega_315_5177_device::sega_315_5177_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : segacrp2_z80_device(mconfig, SEGA_315_5177, tag, owner, clock) {} diff --git a/src/mame/machine/segacrp2_device.h b/src/mame/machine/segacrp2_device.h index b1035f45182..4fe3875f511 100644 --- a/src/mame/machine/segacrp2_device.h +++ b/src/mame/machine/segacrp2_device.h @@ -27,6 +27,14 @@ protected: // actual encrypted CPUs +class nec_315_5136_device : public segacrp2_z80_device +{ +public: + nec_315_5136_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t); +protected: + virtual void decrypt() override; +}; + class sega_315_5179_device : public segacrp2_z80_device { public: @@ -103,6 +111,7 @@ protected: }; +DECLARE_DEVICE_TYPE(NEC_315_5136, nec_315_5136_device) DECLARE_DEVICE_TYPE(SEGA_315_5179, sega_315_5179_device) DECLARE_DEVICE_TYPE(SEGA_315_5178, sega_315_5178_device) DECLARE_DEVICE_TYPE(SEGA_315_5177, sega_315_5177_device) -- cgit v1.2.3