amaticmg.c: figured out encryption [Andreas Naive]

This commit is contained in:
Michaël Banaan Ananas 2012-04-21 00:25:21 +00:00
parent 685bfe7ed6
commit 2d07e5aa47

View File

@ -737,7 +737,9 @@ ROM_END
ROM_START( am_mg24 )
ROM_REGION( 0x40000, "maincpu", 0 ) /* encrypted program ROM...*/
ROM_REGION( 0x40000, "maincpu", ROMREGION_ERASE00 )
ROM_REGION( 0x40000, "mainprg", 0 ) /* encrypted program ROM...*/
ROM_LOAD( "mgi_vger_3.9-i-8201.i6.bin", 0x00000, 0x40000, CRC(9ce159f7) SHA1(101c277d579a69cb03f879288b2cecf838cf1741) )
ROM_REGION( 0x180000, "gfx1", 0 )
@ -751,7 +753,9 @@ ROM_START( am_mg24 )
ROM_END
ROM_START( am_mg3 )
ROM_REGION( 0x40000, "maincpu", 0 ) /* encrypted program ROM...*/
ROM_REGION( 0x40000, "maincpu", ROMREGION_ERASE00 )
ROM_REGION( 0x40000, "mainprg", 0 ) /* encrypted program ROM...*/
ROM_LOAD( "mg_iii_vger_3.5-i-8205.bin", 0x00000, 0x40000, CRC(21d64029) SHA1(d5c3fde02833a96dd7a43481a489bfc4a5c9609d) )
ROM_REGION( 0x180000, "gfx1", 0 )
@ -768,11 +772,43 @@ ROM_END
* Driver Initialization *
************************************/
static void encf(UINT8 ciphertext, int address, UINT8& plaintext, int& newaddress)
{
int aux = address & 0xfff;
aux = aux ^ (aux>>6);
aux = ((aux<<6) | (aux>>6)) & 0xfff;
UINT8 aux2 = BITSWAP8(aux, 9,10,4,1,6,0,7,3);
aux2 ^= aux2>>4;
aux2 = (aux2<<4) | (aux2>>4);
ciphertext ^= ciphertext<<4;
plaintext = (ciphertext<<4) | (ciphertext>>4);
plaintext ^= aux2;
newaddress = (address & ~0xfff) | aux;
}
static DRIVER_INIT( amaticmg )
{
}
static DRIVER_INIT( amaticmg3 )
{
const int key1 = 0x426;
const int key2 = 0x55;
UINT8 plaintext;
int newaddress;
UINT8 *src = machine.root_device().memregion("mainprg")->base();
UINT8 *dest = machine.root_device().memregion("maincpu")->base();
int len = machine.root_device().memregion("mainprg")->bytes();
for (int i = 0; i < len; i++)
{
encf(src[i], i, plaintext, newaddress);
dest[newaddress^key1] = plaintext^key2;
}
}
/************************************
* Game Drivers *
@ -780,5 +816,5 @@ static DRIVER_INIT( amaticmg )
/* YEAR NAME PARENT MACHINE INPUT INIT ROT COMPANY FULLNAME FLAGS */
GAME( 1996, am_uslot, 0, amaticmg, amaticmg, amaticmg, ROT0, "Amatic Trading GmbH", "Amatic Unknown Slots Game", GAME_IMPERFECT_GRAPHICS | GAME_WRONG_COLORS | GAME_UNEMULATED_PROTECTION | GAME_NO_SOUND | GAME_NOT_WORKING )
GAME( 2000, am_mg24, 0, amaticmg3, amaticmg, amaticmg, ROT0, "Amatic Trading GmbH", "Multi Game I (V.Ger 2.4)", GAME_IMPERFECT_GRAPHICS | GAME_WRONG_COLORS | GAME_UNEMULATED_PROTECTION | GAME_NO_SOUND | GAME_NOT_WORKING )
GAME( 2000, am_mg3, 0, amaticmg3, amaticmg, amaticmg, ROT0, "Amatic Trading GmbH", "Multi Game III (V.Ger 3.5)", GAME_IMPERFECT_GRAPHICS | GAME_WRONG_COLORS | GAME_UNEMULATED_PROTECTION | GAME_NO_SOUND | GAME_NOT_WORKING )
GAME( 2000, am_mg24, 0, amaticmg3, amaticmg, amaticmg3, ROT0, "Amatic Trading GmbH", "Multi Game I (V.Ger 2.4)", GAME_IMPERFECT_GRAPHICS | GAME_WRONG_COLORS | GAME_UNEMULATED_PROTECTION | GAME_NO_SOUND | GAME_NOT_WORKING )
GAME( 2000, am_mg3, 0, amaticmg3, amaticmg, amaticmg3, ROT0, "Amatic Trading GmbH", "Multi Game III (V.Ger 3.5)", GAME_IMPERFECT_GRAPHICS | GAME_WRONG_COLORS | GAME_UNEMULATED_PROTECTION | GAME_NO_SOUND | GAME_NOT_WORKING )