mirror of
https://github.com/holub/mame
synced 2025-06-06 12:53:46 +03:00
reworked neogeo m1 decryption a little [Andreas Naive]
This commit is contained in:
parent
acf1eb7cb8
commit
0ccf1e16da
@ -1364,48 +1364,47 @@ void neo_pcm2_swap(running_machine *machine, int value)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const UINT8 m1_address_8_15_xor[256] =
|
||||
{
|
||||
0xf5, 0x8d, 0x48, 0x50, 0x98, 0x21, 0xe2, 0x4e, 0x87, 0x3b, 0xb0, 0x4a, 0xb4, 0xe7, 0x89, 0x22,
|
||||
0xee, 0x1d, 0xc9, 0x5e, 0x7d, 0xfc, 0x67, 0x5f, 0xef, 0xa0, 0xc0, 0x29, 0xe0, 0x6f, 0x95, 0xf4,
|
||||
0x8f, 0x1f, 0x9b, 0x34, 0x60, 0xc7, 0x74, 0xac, 0xfb, 0x35, 0x07, 0x2f, 0xf8, 0x97, 0xa9, 0xcd,
|
||||
0x51, 0xe3, 0xd1, 0xb7, 0x9c, 0x6d, 0x65, 0x63, 0xbb, 0x7a, 0xbe, 0xbf, 0xf6, 0x3f, 0x37, 0x40,
|
||||
0x15, 0x44, 0x08, 0xd2, 0x66, 0xde, 0x09, 0x45, 0xea, 0x31, 0x54, 0x4f, 0xd5, 0x9f, 0x43, 0x0e,
|
||||
0x0f, 0x61, 0x2a, 0x68, 0x27, 0xb1, 0xeb, 0x62, 0xbd, 0xb2, 0xd3, 0xa3, 0xd4, 0x59, 0x1e, 0x58,
|
||||
0x10, 0xda, 0xcc, 0x85, 0x14, 0x18, 0xe4, 0x92, 0xb3, 0xad, 0xd9, 0x9d, 0x49, 0xca, 0x41, 0x7f,
|
||||
0xfe, 0x42, 0x02, 0xc8, 0x06, 0xb8, 0xaa, 0x8e, 0x4b, 0x0d, 0x00, 0xd8, 0x05, 0xdc, 0x36, 0x7c,
|
||||
0xe8, 0xc6, 0xec, 0xf2, 0x38, 0x79, 0xe9, 0x13, 0xb6, 0x90, 0x01, 0xcb, 0xfa, 0x70, 0xff, 0x19,
|
||||
0x5b, 0x25, 0x84, 0x3e, 0x0c, 0x0b, 0x26, 0x8a, 0xd7, 0x99, 0x78, 0x57, 0xba, 0x93, 0xdf, 0x16,
|
||||
0x88, 0x6c, 0x81, 0xc3, 0xe1, 0x8b, 0x0a, 0x73, 0xc1, 0x6b, 0x2b, 0x3d, 0xa5, 0xf9, 0xf1, 0x17,
|
||||
0xc2, 0x56, 0x4d, 0x1c, 0x1b, 0xdd, 0x30, 0xdb, 0x71, 0x94, 0x75, 0x72, 0x7b, 0xb5, 0x2d, 0x6e,
|
||||
0x77, 0x86, 0xa8, 0x5a, 0xf0, 0x32, 0x46, 0x53, 0xc4, 0x55, 0x4c, 0x2e, 0x11, 0xce, 0x7e, 0x83,
|
||||
0x28, 0x76, 0x2c, 0x69, 0xbc, 0x3a, 0x39, 0x3c, 0x96, 0x80, 0xb9, 0x20, 0xcf, 0xa4, 0x91, 0x1a,
|
||||
0xf7, 0x6a, 0x64, 0x04, 0x47, 0xa7, 0xf3, 0x9e, 0xaf, 0xa2, 0xc5, 0x5d, 0xd6, 0xed, 0x03, 0xae,
|
||||
0x82, 0xe5, 0xfd, 0x9a, 0xab, 0xa1, 0xe6, 0x33, 0x23, 0x24, 0x8c, 0x12, 0x52, 0xa6, 0xd0, 0x5c,
|
||||
0x0a, 0x72, 0xb7, 0xaf, 0x67, 0xde, 0x1d, 0xb1, 0x78, 0xc4, 0x4f, 0xb5, 0x4b, 0x18, 0x76, 0xdd,
|
||||
0x11, 0xe2, 0x36, 0xa1, 0x82, 0x03, 0x98, 0xa0, 0x10, 0x5f, 0x3f, 0xd6, 0x1f, 0x90, 0x6a, 0x0b,
|
||||
0x70, 0xe0, 0x64, 0xcb, 0x9f, 0x38, 0x8b, 0x53, 0x04, 0xca, 0xf8, 0xd0, 0x07, 0x68, 0x56, 0x32,
|
||||
0xae, 0x1c, 0x2e, 0x48, 0x63, 0x92, 0x9a, 0x9c, 0x44, 0x85, 0x41, 0x40, 0x09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x3a, 0xa2, 0x29, 0x12, 0xfc, 0x51,
|
||||
0x7d, 0x1a, 0x02, 0x65, 0x54, 0x5e, 0x19, 0xcc, 0xdc, 0xdb, 0x73, 0xed, 0xad, 0x59, 0x2f, 0xa3,
|
||||
};
|
||||
|
||||
static const UINT8 m1_address_0_7_xor[256] =
|
||||
{
|
||||
0x29, 0x2e, 0x10, 0x95, 0x34, 0xb1, 0xf4, 0x1e, 0x35, 0x55, 0xb0, 0xe5, 0x7d, 0xa3, 0x15, 0x89,
|
||||
0x5a, 0x14, 0x37, 0x4a, 0xe1, 0x4f, 0x4c, 0xfb, 0x36, 0xbc, 0x9f, 0x45, 0x98, 0x0c, 0x79, 0x3d,
|
||||
0xf0, 0x81, 0x76, 0x2a, 0x31, 0x60, 0x52, 0x06, 0x1b, 0x8e, 0xec, 0x70, 0x19, 0x01, 0xed, 0x88,
|
||||
0x3e, 0x5c, 0xe8, 0xf5, 0x9b, 0x49, 0xa8, 0xb3, 0xf3, 0x3f, 0x09, 0xd1, 0x4b, 0xf1, 0x7c, 0xa1,
|
||||
0x66, 0x1c, 0xbd, 0x07, 0x24, 0xce, 0x03, 0x68, 0xd8, 0xe2, 0x18, 0x38, 0x33, 0xae, 0xd2, 0x05,
|
||||
0x2d, 0xdf, 0x92, 0x87, 0x91, 0x1f, 0xd0, 0x8a, 0x71, 0xeb, 0x73, 0xb6, 0x12, 0x25, 0x82, 0x61,
|
||||
0xc3, 0x00, 0xa7, 0xba, 0x78, 0x21, 0x4d, 0xd5, 0x96, 0x46, 0x22, 0xc1, 0x97, 0xd9, 0xf9, 0x2f,
|
||||
0xca, 0x47, 0x40, 0xd4, 0x44, 0x6c, 0x58, 0x94, 0x9a, 0xe6, 0xdc, 0xf7, 0x2b, 0x04, 0x28, 0x1a,
|
||||
0x53, 0xc6, 0x7a, 0x51, 0xcd, 0xa0, 0x63, 0x32, 0x57, 0x83, 0x6a, 0x90, 0x77, 0xef, 0x8d, 0x54,
|
||||
0x0f, 0x2c, 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0xa5,
|
||||
0x76, 0xea, 0x5c, 0x82, 0x1a, 0x4f, 0xaa, 0xca, 0xe1, 0x0b, 0x4e, 0xcb, 0x6a, 0xef, 0xd1, 0xd6,
|
||||
};
|
||||
|
||||
// inverse function, used to encrypt instead
|
||||
|
||||
int m1_address_scramble_inv(int address, UINT16 key)
|
||||
{
|
||||
int block;
|
||||
@ -1438,6 +1437,24 @@ int m1_address_scramble_inv(int address, UINT16 key)
|
||||
return (block<<16)|aux;
|
||||
}
|
||||
|
||||
|
||||
/* The CMC50 hardware does a checksum of the first 64kb of the M1 rom,
|
||||
,and uses this checksum as the basis of the key with which to decrypt
|
||||
the rom */
|
||||
|
||||
static UINT16 generate_cs16(UINT8 *rom, int size)
|
||||
{
|
||||
UINT16 cs16;
|
||||
int i;
|
||||
cs16 = 0x0000;
|
||||
for (i=0;i<size;i++ )
|
||||
{
|
||||
cs16 += rom[i];
|
||||
}
|
||||
return cs16&0xFFFF;
|
||||
}
|
||||
|
||||
|
||||
int m1_address_scramble(int address, UINT16 key)
|
||||
{
|
||||
int block;
|
||||
@ -1457,13 +1474,13 @@ int m1_address_scramble(int address, UINT16 key)
|
||||
block = (address>>16)&7;
|
||||
aux = address&0xffff;
|
||||
|
||||
aux ^= key;
|
||||
aux ^= BITSWAP16(key,12,0,2,4,8,15,7,13,10,1,3,6,11,9,14,5);
|
||||
aux = BITSWAP16(aux,
|
||||
p1[block][15],p1[block][14],p1[block][13],p1[block][12],
|
||||
p1[block][11],p1[block][10],p1[block][9],p1[block][8],
|
||||
p1[block][7],p1[block][6],p1[block][5],p1[block][4],
|
||||
p1[block][3],p1[block][2],p1[block][1],p1[block][0]);
|
||||
aux ^= m1_address_0_7_xor[(aux>>8)&0xff];
|
||||
aux ^= m1_address_0_7_xor[(aux>>8)&0xff];
|
||||
aux ^= m1_address_8_15_xor[aux&0xff]<<8;
|
||||
aux = BITSWAP16(aux, 7,15,14,6,5,13,12,4,11,3,10,2,9,1,8,0);
|
||||
|
||||
@ -1471,22 +1488,6 @@ int m1_address_scramble(int address, UINT16 key)
|
||||
}
|
||||
|
||||
|
||||
/* The CMC50 hardware does a checksum of the first 64kb of the M1 rom,
|
||||
,and uses this checksum as the basis of the key with which to decrypt
|
||||
the rom */
|
||||
static UINT16 generate_cs16(UINT8 *rom, int size)
|
||||
{
|
||||
UINT16 cs16;
|
||||
int i;
|
||||
cs16 = 0x0000;
|
||||
for (i=0;i<size;i++ )
|
||||
{
|
||||
cs16 += rom[i];
|
||||
}
|
||||
return cs16&0xFFFF;
|
||||
}
|
||||
|
||||
|
||||
void neogeo_cmc50_m1_decrypt(running_machine *machine)
|
||||
{
|
||||
UINT8* rom = memory_region(machine, "audiocrypt");
|
||||
@ -1497,8 +1498,7 @@ void neogeo_cmc50_m1_decrypt(running_machine *machine)
|
||||
|
||||
UINT32 i;
|
||||
|
||||
UINT16 cs16=generate_cs16(rom,0x10000);
|
||||
UINT16 key = BITSWAP16(cs16,12,0,2,4,8,15,7,13,10,1,3,6,11,9,14,5)^0xffff;
|
||||
UINT16 key=generate_cs16(rom,0x10000);
|
||||
|
||||
//printf("key %04x\n",key);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user