decrypt ms5pcb m1 rom, it uses a different bitswap in one of the stages [Andreas Naive]

This commit is contained in:
davidhay 2008-09-20 07:31:33 +00:00
parent 49c8293fd9
commit 9685c7cf7d
3 changed files with 54 additions and 7 deletions

View File

@ -5672,13 +5672,10 @@ ROM_START( ms5pcb ) /* Encrypted Set */
/* this contains both an ASIA and JAPAN bios, HARDDIP3 on the PCB selects which to use */
ROM_LOAD16_WORD_SWAP( "268-bios.bin", 0x00000, 0x80000, CRC(b4590283) SHA1(47047ed5b6062babc0a0bebcc30e4b3f021e115a) )
ROM_REGION( 0x50000, "audio", 0 )
/* Encrypted, we load it here for reference and replace with decrypted ROM */
/* Encrypted (slightly different encryption on this single board PCB) */
ROM_REGION( 0x80000, "audiocrypt", 0 )
ROM_LOAD( "268-m1.bin", 0x00000, 0x10000, CRC(58b107d0) SHA1(cc7fe66ff4f9c026cde4df06f86c848eb21f7af8) )
/* Decrypted */
ROM_LOAD( "268-m1_decrypted.bin", 0x00000, 0x10000, CRC(3c0655a7) SHA1(ae839d4c2b87a7aa3dd8e5caddc43eb75ee9b732) ) /* not a 100% match for encrypted version */
ROM_RELOAD( 0x10000, 0x10000 )
ROM_REGION( 0x90000, "audio", ROMREGION_ERASEFF )
ROM_Y_ZOOM
@ -7039,7 +7036,7 @@ static DRIVER_INIT( ms5pcb )
mslug5_decrypt_68k(machine);
svcpcb_gfx_decrypt(machine);
kof2000_neogeo_gfx_decrypt(machine, 0x19);
//neogeo_cmc50_m1_decrypt(machine, 0x1543); // wrong, or there is some extra address swap first
neogeo_ms5pcb_m1_decrypt(machine);
neogeo_fixed_layer_bank_type = 2;
svcpcb_s1data_decrypt(machine);

View File

@ -68,6 +68,7 @@ void neo_pcm2_snk_1999(running_machine *machine, int value);
void neo_pcm2_swap(running_machine *machine, int value);
void neogeo_cmc50_m1_decrypt(running_machine *machine, UINT16 key);
void neogeo_ms5pcb_m1_decrypt(running_machine *machine);
/*----------- defined in machine/neoprot.c -----------*/

View File

@ -1516,4 +1516,53 @@ void neogeo_cmc50_m1_decrypt(running_machine *machine, UINT16 key)
}
/* the ms5pcb encryption is slightly different, there are 2 possible approachs
we can take */
#if 1
// if using key 0x1543 (same as mslug5) we need a different bitswap here
int m1_alt_address_scramble(int address/*, UINT16 key*/)
{
int block;
int aux;
UINT16 key = 0x1543;
aux = address ^key;
aux = BITSWAP16(aux, 11,0,2,5,12,7,4,9,10,8,3,14,15,6,13,1); // only 1 64k block, so...
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);
return aux;
}
#else
// using key 0xa528, we can rearrange the rom first..
int m1_alt_address_scramble(int address/*, UINT16 key */)
{
UINT16 key = 0xa528;
address = BITSWAP16(address, 1,13,12,4,7,6,2,10,15,5,0,11,8,3,14,9);
return m1_address_scramble(address, key);
}
#endif
void neogeo_ms5pcb_m1_decrypt(running_machine *machine/*, UINT16 key*/)
{
UINT8* rom = memory_region(machine, "audiocrypt");
size_t rom_size = 0x80000;
UINT8* rom2 = memory_region(machine, "audio");
UINT8* buffer = malloc_or_die(rom_size);
UINT32 i;
for (i=0; i<rom_size; i++)
{
buffer[i] = rom[m1_alt_address_scramble(i)];
}
memcpy(rom,buffer,rom_size);
memcpy(rom2,rom,0x10000);
memcpy(rom2+0x10000,rom,0x80000);
}