diff --git a/.gitattributes b/.gitattributes index ee49db9a5a6..bccca406234 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3688,6 +3688,8 @@ src/mame/machine/stvcd.h svneol=native#text/plain src/mame/machine/stvprot.c svneol=native#text/plain src/mame/machine/stvprot.h svneol=native#text/plain src/mame/machine/subs.c svneol=native#text/plain +src/mame/machine/subsino.c svneol=native#text/plain +src/mame/machine/subsino.h svneol=native#text/plain src/mame/machine/tait8741.c svneol=native#text/plain src/mame/machine/tait8741.h svneol=native#text/plain src/mame/machine/taitoio.c svneol=native#text/plain diff --git a/src/mame/drivers/subsino.c b/src/mame/drivers/subsino.c index f5d98ad5cbe..589581113b3 100644 --- a/src/mame/drivers/subsino.c +++ b/src/mame/drivers/subsino.c @@ -213,9 +213,11 @@ #include "emu.h" #include "cpu/z180/z180.h" #include "machine/8255ppi.h" +#include "machine/subsino.h" #include "sound/okim6295.h" #include "sound/2413intf.h" #include "sound/3812intf.h" + #include "victor5.lh" #include "victor21.lh" #include "crsbingo.lh" @@ -3475,100 +3477,6 @@ ROM_END * Driver Init / Decryption * ***************************************************************************/ -#if 0 -void dump_decrypted(running_machine& machine, UINT8* decrypt) -{ - FILE *fp; - char filename[256]; - sprintf(filename,"dat_%s", machine.system().name); - fp=fopen(filename, "w+b"); - if (fp) - { - fwrite(decrypt, 0x10000, 1, fp); - fclose(fp); - } -} -#endif - -static const unsigned char victor5_xors[8] = { 0x99, 0x99, 0x33, 0x44, 0xbb, 0x88, 0x88, 0xbb }; -static const unsigned char victor21_xors[8] = { 0x44, 0xbb, 0x66, 0x44, 0xaa, 0x55, 0x88, 0x22 }; -static const unsigned char crsbingo_xors[8] = { 0xbb, 0xcc, 0xcc, 0xdd, 0xaa, 0x11, 0x44, 0xee }; -static const unsigned char sharkpy_xors[8] = { 0xcc, 0xaa, 0x66, 0xaa, 0xee, 0x33, 0xff, 0xff }; - - -static void victor5_bitswaps(UINT8* decrypt, int i) -{ - if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0); - if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i],7,6,5,0,3,2,1,4); - if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4); - if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4); - if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,0,7,6,5,4); - if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i],7,6,5,0,3,2,1,4); - if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i],3,6,1,0,7,2,5,4); - if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,4,3,6,5,0); -} - - -static void victor21_bitswaps(UINT8* decrypt, int i) -{ - if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4); - if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i],3,6,1,4,7,2,5,0); - if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,4,7,6,5,0); - if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0); - if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0); - if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i],3,6,5,0,7,2,1,4); - if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i],7,6,5,4,3,2,1,0); - if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,4,7,6,5,0); -} - -static void crsbingo_bitswaps(UINT8* decrypt, int i) -{ - if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0); - if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4); - if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i],3,2,5,0,7,6,1,4); - if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,0,3,6,1,4); - if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i],7,6,5,0,3,2,1,4); - if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,4,3,6,5,0); - if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4); - if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,0,7,6,5,4); -} - -static void sharkpy_bitswaps(UINT8* decrypt, int i) -{ - if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,0,7,6,5,4); - if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0); - if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,4,3,6,5,0); - if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i],3,6,1,0,7,2,5,4); - if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0); - if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i],3,2,5,4,7,6,1,0); - if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i],7,6,1,4,3,2,5,0); - if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i],3,6,1,4,7,2,5,0); -} - -static void subsino_decrypt(running_machine& machine, void (*bitswaps)(UINT8* decrypt, int i), const UINT8* xors, int size) -{ - int i; - UINT8 *decrypt = auto_alloc_array(machine, UINT8, 0x10000); - UINT8* region = machine.region("maincpu")->base(); - - for (i=0;i<0x10000;i++) - { - if (ibase(); - - for (i=0;i<0x10000;i++) - { - if (ibase(); + rom[0x0d79] = 0x18; + rom[0xc1cf] = 0x18; + rom[0xc2a9] = 0x18; + rom[0xc2d7] = 0x18; +} + +GAME( 1996, mtrain, 0, mtrain, mtrain, mtrain, ROT0, "Subsino", "Magic Train (Ver. 1.31)", 0 ) +GAME( 1996, wtrnymph, 0, mtrain, wtrnymph, wtrnymph, ROT0, "Subsino", "Water-Nymph (Ver. 1.4)", 0 ) +GAME( 1998, expcard, 0, expcard, expcard, expcard, ROT0, "American Alpha", "Express Card / Top Card (Ver. 1.5)", 0 ) +GAME( 1998, saklove, 0, saklove, saklove, saklove, ROT0, "Subsino", "Ying Hua Lian 2.0 (China, Ver. 1.02)", 0 ) +GAME( 1999, xtrain, 0, xtrain, xtrain, xtrain, ROT0, "Subsino", "X-Train (Ver. 1.3)", 0 ) +GAME( 1999, bishjan, 0, bishjan, bishjan, bishjan, ROT0, "Subsino", "Bishou Jan (Japan, Ver. 2.03)", GAME_NO_SOUND ) +GAME( 2006, xplan, 0, xplan, xplan, xplan, ROT0, "Subsino", "X-Plan (Ver. 1.01)", 0 ) diff --git a/src/mame/machine/subsino.c b/src/mame/machine/subsino.c new file mode 100644 index 00000000000..a99c9c841b1 --- /dev/null +++ b/src/mame/machine/subsino.c @@ -0,0 +1,104 @@ +/*************************************************************************** + +Subsino XOR + Bitswap Encryption +by David Haywood + +***************************************************************************/ + +#include "emu.h" + +// XORs: + +extern const UINT8 crsbingo_xors[8] = { 0xbb, 0xcc, 0xcc, 0xdd, 0xaa, 0x11, 0x44, 0xee }; +extern const UINT8 sharkpy_xors [8] = { 0xcc, 0xaa, 0x66, 0xaa, 0xee, 0x33, 0xff, 0xff }; +extern const UINT8 victor5_xors [8] = { 0x99, 0x99, 0x33, 0x44, 0xbb, 0x88, 0x88, 0xbb }; +extern const UINT8 victor21_xors[8] = { 0x44, 0xbb, 0x66, 0x44, 0xaa, 0x55, 0x88, 0x22 }; + +// Bitswaps: + +void crsbingo_bitswaps(UINT8 *decrypt, int i) +{ + if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,4,3,6,1,0 ); + if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,0,3,6,5,4 ); + if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i], 3,2,5,0,7,6,1,4 ); + if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,0,3,6,1,4 ); + if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i], 7,6,5,0,3,2,1,4 ); + if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,4,3,6,5,0 ); + if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,0,3,6,5,4 ); + if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i], 3,2,1,0,7,6,5,4 ); +} + +void sharkpy_bitswaps(UINT8 *decrypt, int i) +{ + if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i], 3,2,1,0,7,6,5,4 ); + if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,4,3,6,1,0 ); + if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,4,3,6,5,0 ); + if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i], 3,6,1,0,7,2,5,4 ); + if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,4,3,6,1,0 ); + if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i], 3,2,5,4,7,6,1,0 ); + if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i], 7,6,1,4,3,2,5,0 ); + if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i], 3,6,1,4,7,2,5,0 ); +} + +void victor5_bitswaps(UINT8 *decrypt, int i) +{ + if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,4,3,6,1,0 ); + if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i], 7,6,5,0,3,2,1,4 ); + if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,0,3,6,5,4 ); + if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,0,3,6,5,4 ); + if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i], 3,2,1,0,7,6,5,4 ); + if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i], 7,6,5,0,3,2,1,4 ); + if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i], 3,6,1,0,7,2,5,4 ); + if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,4,3,6,5,0 ); +} + +void victor21_bitswaps(UINT8 *decrypt, int i) +{ + if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,0,3,6,5,4 ); + if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i], 3,6,1,4,7,2,5,0 ); + if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i], 3,2,1,4,7,6,5,0 ); + if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,4,3,6,1,0 ); + if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,4,3,6,1,0 ); + if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i], 3,6,5,0,7,2,1,4 ); + if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i], 7,6,5,4,3,2,1,0 ); + if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i], 3,2,1,4,7,6,5,0 ); +} + +// Decrypt: + +#if 0 +void dump_decrypted(running_machine& machine, UINT8* decrypt) +{ + FILE *fp; + char filename[256]; + sprintf(filename,"dat_%s", machine.system().name); + fp=fopen(filename, "w+b"); + if (fp) + { + fwrite(decrypt, 0x10000, 1, fp); + fclose(fp); + } +} +#endif + +void subsino_decrypt(running_machine& machine, void (*bitswaps)(UINT8 *decrypt, int i), const UINT8 *xors, int size) +{ + int i; + UINT8 *decrypt = auto_alloc_array(machine, UINT8, 0x10000); + UINT8* region = machine.region("maincpu")->base(); + + for (i=0;i<0x10000;i++) + { + if (i