diff --git a/src/mame/igs/igs_m027.cpp b/src/mame/igs/igs_m027.cpp index 543b32968b0..81ffd359fee 100644 --- a/src/mame/igs/igs_m027.cpp +++ b/src/mame/igs/igs_m027.cpp @@ -63,6 +63,8 @@ public: void init_amazonia(); void init_amazoni2(); void init_qlgs(); + void init_mgzz(); + void init_mgcs3(); protected: virtual void video_start() override; @@ -1188,6 +1190,19 @@ void igs_m027_state::init_qlgs() pgm_create_dummy_internal_arm_region(); } +void igs_m027_state::init_mgzz() +{ + mgzz_decrypt(machine()); + //qlgs_gfx_decrypt(machine()); + pgm_create_dummy_internal_arm_region(); +} + +void igs_m027_state::init_mgcs3() +{ + mgcs3_decrypt(machine()); + //qlgs_gfx_decrypt(machine()); + pgm_create_dummy_internal_arm_region(); +} } // anonymous namespace @@ -1216,5 +1231,5 @@ GAME( 2002, chessc2, 0, igs_mahjong, sdwx, igs_m027_state, init_che GAME( 200?, haunthig, 0, igs_mahjong, sdwx, igs_m027_state, init_hauntedh, ROT0, "IGS", "Haunted House (IGS)", MACHINE_IS_SKELETON ) GAME( 200?, extradrw, 0, igs_mahjong, sdwx, igs_m027_state, init_qlgs, ROT0, "IGS", "Extra Draw", MACHINE_IS_SKELETON ) GAME( 200?, crzybugs, 0, igs_mahjong, sdwx, igs_m027_state, init_qlgs, ROT0, "IGS", "Crazy Bugs (V103JP)", MACHINE_IS_SKELETON ) // 2006 according to some sources -GAME( 2003, mgzz, 0, igs_mahjong, sdwx, igs_m027_state, init_qlgs, ROT0, "IGS", "Man Guan Zhi Zun (V100CN)", MACHINE_IS_SKELETON ) -GAME( 200?, mgcs3, 0, igs_mahjong, sdwx, igs_m027_state, init_qlgs, ROT0, "IGS", "Man Guan Caishen 3 (V101CN)", MACHINE_IS_SKELETON ) +GAME( 2003, mgzz, 0, igs_mahjong, sdwx, igs_m027_state, init_mgzz, ROT0, "IGS", "Man Guan Zhi Zun (V100CN)", MACHINE_IS_SKELETON ) +GAME( 2007, mgcs3, 0, igs_mahjong, sdwx, igs_m027_state, init_mgcs3, ROT0, "IGS", "Man Guan Caishen 3 (V101CN)", MACHINE_IS_SKELETON ) diff --git a/src/mame/igs/pgmcrypt.cpp b/src/mame/igs/pgmcrypt.cpp index 5e42952f5d8..8694e5118ce 100644 --- a/src/mame/igs/pgmcrypt.cpp +++ b/src/mame/igs/pgmcrypt.cpp @@ -1,5 +1,6 @@ // license:BSD-3-Clause -// copyright-holders:David Haywood, ElSemi +// copyright-holders: David Haywood, ElSemi + /* IGS 027 Encryptions the IGS027 chips are typically used with encrypted ROMs. @@ -19,7 +20,7 @@ #include "pgmcrypt.h" // a common set of these are used, selectable in the real scheme by an uploaded bitfield -// some may be duplicates simply due to differing rom sizes +// some may be duplicates simply due to differing ROM sizes #define IGS27_CRYPT1 \ if ((i & 0x040480) != 0x000080) x ^= 0x0001; @@ -86,12 +87,12 @@ static const uint8_t kov_tab[256] = { void pgm_kov_decrypt(running_machine &machine) { - int i; - uint16_t *src = (uint16_t *) (machine.root_device().memregion("maincpu")->base()+0x100000); + auto const src = reinterpret_cast(machine.root_device().memregion("maincpu")->base() + 0x100000); - int rom_size = 0x400000; + int const rom_size = 0x400000; - for(i=0; ibase()+0x100000); + auto const src = reinterpret_cast(machine.root_device().memregion("maincpu")->base() + 0x100000); - int rom_size = 0x400000; + int const rom_size = 0x400000; - for(i=0; ibase()+0x100000); + auto const src = reinterpret_cast(machine.root_device().memregion("maincpu")->base() + 0x100000); - int rom_size = 0x400000; + int const rom_size = 0x400000; - for(i=0; ibase()+0x100000); + auto const src = reinterpret_cast(machine.root_device().memregion("maincpu")->base() + 0x100000); - int rom_size = 0x100000; + int const rom_size = 0x100000; - for(i=0; ibase()); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x400000; + int const rom_size = 0x400000; - for(i=0; ibase()); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x200000; + int const rom_size = 0x200000; - for(i=0; ibase()); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x200000; + int const rom_size = 0x200000; - for(i=0; ibase()); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x200000; + int const rom_size = 0x200000; - for(i=0; ibase()); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x200000; + int const rom_size = 0x200000; - for(i=0; ibase()+0x100000); + auto const src = reinterpret_cast(machine.root_device().memregion("maincpu")->base() + 0x100000); - int rom_size = 0x100000; + int const rom_size = 0x100000; - for(i=0; ibase()); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x200000; + int const rom_size = 0x200000; - for(i=0; ibase()+0x100000); + auto const src = reinterpret_cast(machine.root_device().memregion("maincpu")->base() + 0x100000); - int rom_size = 0x400000; + int const rom_size = 0x400000; - for(i=0; ibase()+0x100000); + auto const src = reinterpret_cast(machine.root_device().memregion("maincpu")->base() + 0x100000); - int rom_size = 0x400000; + int const rom_size = 0x400000; - for(i=0; ibase()); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x200000; + int const rom_size = 0x200000; - for(i=0; ibase()); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x800000; + int const rom_size = 0x800000; - for(i=0; ibase()); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x800000; + int const rom_size = 0x800000; - for (i = 0; i < rom_size/2; i++) { + for (int i = 0; i < rom_size / 2; i++) + { uint16_t x = src[i]; IGS27_CRYPT1_ALT; // ok? @@ -777,12 +778,11 @@ static const uint8_t py2k2_tab[256] = { void pgm_py2k2_decrypt(running_machine &machine) // and ddpdoj/ddpdojbl { - int i; - uint16_t *src = (uint16_t *) (machine.root_device().memregion("maincpu")->base()+0x100000); + auto const src = reinterpret_cast(machine.root_device().memregion("maincpu")->base() + 0x100000); - int rom_size = 0x400000; + int const rom_size = 0x400000; - for(i=0; ibase()); + auto const src = reinterpret_cast(machine.root_device().memregion("maincpu")->base()); - int rom_size = 0x400000; + int const rom_size = 0x400000; - for(i=0; ibase()); + auto const src = reinterpret_cast(machine.root_device().memregion("maincpu")->base()); - int rom_size = 0x400000; + int const rom_size = 0x400000; - for(i=0; ibase()); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x400000; + int const rom_size = 0x400000; - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x80000; + int const rom_size = 0x80000; - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x080000; + int const rom_size = 0x080000; - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x80000; + int const rom_size = 0x80000; - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x80000; + int const rom_size = 0x80000; - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x80000; + int const rom_size = 0x80000; - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x80000; + int const rom_size = 0x80000; - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x80000; + int const rom_size = 0x80000; - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x80000; + int const rom_size = 0x80000; - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x80000; + int const rom_size = 0x80000; - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x80000; + int const rom_size = 0x80000; - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x80000; + int const rom_size = 0x80000; - for(i=0; ibase()+0x100000); + auto const src = reinterpret_cast(machine.root_device().memregion("maincpu")->base() + 0x100000); - int rom_size = 0x400000; + int const rom_size = 0x400000; - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x200000; + int const rom_size = 0x200000; - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x80000; + int const rom_size = 0x80000; // not 100% verified - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x80000; + int const rom_size = 0x80000; - for(i=0; ibase(); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x80000; + int const rom_size = 0x80000; - for(i=0; ibase()); + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); - int rom_size = 0x80000; + int const rom_size = 0x80000; - for(int i=0; i(machine.root_device().memregion("user1")->base()); + + int const rom_size = 0x80000; + + for (int i = 0; i < rom_size / 2; i++) + { + uint16_t x = src[i]; + + // TODO: probably needs work + IGS27_CRYPT1 + IGS27_CRYPT2 + IGS27_CRYPT3_ALT2 + IGS27_CRYPT4 + IGS27_CRYPT5 + IGS27_CRYPT6 + IGS27_CRYPT7_ALT + IGS27_CRYPT8 + + x ^= mgcs3_tab[(i >> 1) & 0xff] << 8; + + src[i] = x; + } +} + +// IGS FOR V100CN 02-12-12 in the ROM + +static const uint8_t mgzz_tab[0x100] = { + 0x49, 0x47, 0x53, 0x30, 0x30, 0x38, 0x33, 0x52, 0x44, 0x34, 0x30, 0x32, 0x31, 0x32, 0x31, 0x32, // IGS0083RD4021212 + 0x82, 0x6b, 0xca, 0xbe, 0x9b, 0x9f, 0xc3, 0xa5, 0x8f, 0x2a, 0x9f, 0x0e, 0x26, 0x28, 0x4a, 0x9d, + 0xa2, 0x57, 0xfc, 0x43, 0xf3, 0x34, 0x05, 0x72, 0x1e, 0x59, 0xd9, 0xa0, 0xe7, 0x16, 0x5b, 0xff, + 0xc6, 0x4f, 0x6e, 0x7a, 0x09, 0x96, 0xba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c9, 0x4c, 0x26, 0x7f, + 0xd2, 0x4f, 0x40, 0x32, 0x74, 0xb2, 0xe6, 0x6b, 0x90, 0xcf, 0x7f, 0x56, 0x3a, 0xe5, 0xd7, 0x8f +}; + +void mgzz_decrypt(running_machine &machine) +{ + auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); + + int const rom_size = 0x80000; + + for (int i = 0; i < rom_size / 2; i++) + { + int x = src[i]; + + // TODO: probably needs work + IGS27_CRYPT1_ALT + IGS27_CRYPT2 + IGS27_CRYPT3_ALT2 + IGS27_CRYPT4 + IGS27_CRYPT5_ALT + IGS27_CRYPT6 + IGS27_CRYPT7 + IGS27_CRYPT8 + + x ^= mgzz_tab[(i >> 1) & 0xff] << 8; + + src[i] = x; + } +} diff --git a/src/mame/igs/pgmcrypt.h b/src/mame/igs/pgmcrypt.h index f5893113a25..32262898c59 100644 --- a/src/mame/igs/pgmcrypt.h +++ b/src/mame/igs/pgmcrypt.h @@ -1,6 +1,6 @@ // license:BSD-3-Clause -// copyright-holders:David Haywood, ElSemi -/* IGS 027 Encryptions */ +// copyright-holders: David Haywood, ElSemi +// IGS 027 Encryptions void pgm_kov_decrypt(running_machine &machine); void pgm_kovsh_decrypt(running_machine &machine); @@ -39,3 +39,5 @@ void slqz3_decrypt(running_machine &machine); void fruitpar_decrypt(running_machine &machine); void amazonia_decrypt(running_machine &machine); void amazoni2_decrypt(running_machine &machine); +void mgzz_decrypt(running_machine &machine); +void mgcs3_decrypt(running_machine &machine);