mirror of
https://github.com/holub/mame
synced 2025-05-21 21:29:15 +03:00
changed kram3 to use a partially understood decryption algorithm and removed external tables.
This commit is contained in:
parent
6aabfb37cb
commit
b501279724
@ -225,6 +225,7 @@ Interrupts:
|
||||
#include "rendlay.h"
|
||||
#include "machine/6821pia.h"
|
||||
#include "qix.h"
|
||||
#include "cpu/m6809/m6809.h"
|
||||
|
||||
#include "elecyoyo.lh"
|
||||
|
||||
@ -542,6 +543,11 @@ INPUT_PORTS_END
|
||||
*
|
||||
*************************************/
|
||||
|
||||
static const m6809_config encryption_config =
|
||||
{
|
||||
TRUE, /* encrypt only the first byte in 10 xx and 11 xx opcodes */
|
||||
};
|
||||
|
||||
static MACHINE_DRIVER_START( qix )
|
||||
|
||||
MDRV_DRIVER_DATA(qix_state)
|
||||
@ -549,6 +555,7 @@ static MACHINE_DRIVER_START( qix )
|
||||
/* basic machine hardware */
|
||||
MDRV_CPU_ADD("main", M6809, MAIN_CLOCK_OSC/4/4) /* 1.25 MHz */
|
||||
MDRV_CPU_PROGRAM_MAP(main_map,0)
|
||||
MDRV_CPU_CONFIG(encryption_config) // for kram3
|
||||
|
||||
/* high interleave needed to ensure correct text in service mode */
|
||||
/* Zookeeper settings and high score table seem especially sensitive to this */
|
||||
@ -855,12 +862,6 @@ ROM_START( kram3 )
|
||||
|
||||
ROM_REGION( 0x10000, "audio", 0 )
|
||||
ROM_LOAD( "ks27", 0xf800, 0x0800, CRC(c46530c8) SHA1(d2df3f2228a5cff7d7b04b5bbbc4820d2fe84d8d) )
|
||||
|
||||
ROM_REGION( 0x5474, "user1", 0) /* decryption table */
|
||||
ROM_LOAD( "krampatch1.bin", 0, 0x5474, CRC(962dabc9) SHA1(0be692597aa895f298d8c7c6acbf84431ab1412a) )
|
||||
|
||||
ROM_REGION( 0x2764, "user2", 0) /* decryption table */
|
||||
ROM_LOAD( "krampatch2.bin", 0, 0x2764, CRC(ea26b72a) SHA1(c4f6aaf9c2ab22ef8305b57728c602e1d4d74980) )
|
||||
ROM_END
|
||||
|
||||
|
||||
@ -1025,6 +1026,202 @@ ROM_END
|
||||
*
|
||||
*************************************/
|
||||
|
||||
// 99 means the value is unknown
|
||||
static int xor1_table[] =
|
||||
{
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
12, 3,15, 7,12, 7,99, 7,12,11,11,11,12, 8, 7, 8, 3,13,11,11, 4,15, 8, 6,12,99, 3, 3, 0,12, 7,13,
|
||||
3,13, 3, 3,12, 7, 8,99,13,99,11, 3,99, 8, 7, 8,13,11,11, 3, 3,15, 8, 6,12, 3, 3, 3, 0,12, 7,13,
|
||||
13,10,10,10,13, 7, 8, 7, 2, 3,13, 3, 2, 8, 7, 8, 2, 2, 2, 2,13,15, 8, 6,13,10, 6, 0, 3,12, 7,13,
|
||||
13, 2, 2, 2, 2, 7, 8, 7,13, 0,14, 0,13, 8, 7, 8,13, 0, 6,10,13,15, 8, 6,12, 3, 3, 3,12,12, 7,13,
|
||||
13,11,11,11, 4, 7, 8, 7,12, 3, 3, 3,12, 8, 7, 8,13,11,11,11, 4,15, 8, 6, 4,11,11,11, 0,12, 7,13,
|
||||
3, 3,13, 3, 3, 7, 8, 7,13, 2, 2, 2,13, 8, 7, 8,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99, 3, 3,13, 2,99, 7,99, 6, 0,13, 0, 6,15, 8, 6,10,10,10,10,10,12, 7,13,
|
||||
10,14, 8,10,10, 7, 8, 7,14, 6, 6, 6,14, 8, 7, 8,14, 6, 6, 6,10,15, 8, 6,14, 6, 6, 6, 6,12, 7,13,
|
||||
14, 6, 6, 6,10, 7, 8, 7,14, 6, 6, 6, 6, 8, 7, 8,14, 6, 6, 6, 6,15, 8, 6,14, 6, 6, 6, 6, 8, 7, 8,
|
||||
14, 2, 2, 2,14, 7, 8, 7, 2, 6,14, 6, 2, 8, 7, 8, 2, 2, 2, 2,14,15, 8, 6,14, 2, 2,10, 6,12, 7,13,
|
||||
14, 2, 2, 2, 2, 7, 8, 7,14, 6,14, 6,14, 8, 7, 8,14,10, 2, 2,14,15, 8, 6,14, 6, 6, 6,14,12, 7,13,
|
||||
14, 6,99, 6,14, 7, 8, 7,14, 6, 6,14, 2, 8,99, 8,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
2, 3,99, 1, 7, 5, 4,10, 6, 2, 8,11, 0, 1,12, 6, 6,10,12, 7, 7, 6,99, 1,14,10,12, 0,99, 8, 1, 9,
|
||||
3,15,12, 4,99, 0,11, 3,13, 1, 9, 5,11,15,10, 2, 8, 5,15, 4, 2, 9, 3,14,13,11,12,15, 6,11, 5,13,
|
||||
2,15, 2, 1, 7, 4,12, 8, 6,11, 8,10, 0, 3, 7, 6, 6,10,12, 7, 7, 6, 9, 1,14,10,12, 0,14, 8, 5, 2,
|
||||
14,15,12, 4, 0, 0,11, 3,13, 1,14, 5,15,15,10, 2, 8, 5, 9, 4, 2, 8, 3,14,13,11,12,13, 6,11,13, 2,
|
||||
13, 9, 9,12,13,12, 9,12,12,15,15, 8, 8,15,12,12,13,15,14,15,14, 2,13,12, 2,14,14,13,14,14,14,14,
|
||||
2, 2, 6, 1,10, 6, 7, 6, 9,11, 5, 0, 5, 9, 0,10,11, 3, 0, 1,10, 6, 4, 7, 5, 9, 7, 7, 2, 0, 4,10,
|
||||
0, 5, 9, 5, 7, 6, 1, 3,11, 4, 2, 4,10, 3, 0,10, 6, 4, 7,11, 2, 1, 1, 9, 3,11, 8, 3, 3, 3, 3, 9,
|
||||
5, 5, 9, 5, 7, 6, 1, 3,11, 4, 2, 4,10, 3, 0,10, 6, 4, 7,11, 2, 1, 1, 9, 3,11, 8, 3, 3,99, 3,99,
|
||||
2, 3,99, 1, 6,99, 4, 5,10, 2, 8, 1, 2, 5,15, 0,11, 3, 4, 1, 6, 7, 4, 6,10,11, 8, 9, 6, 7,12, 8,
|
||||
2,13, 1, 6, 7, 4, 5,10,11,11,14,14, 7,13,12,13, 8, 3, 0, 1, 6, 8, 5, 9,10,11, 8, 9,14, 7, 4, 5,
|
||||
15, 8, 9,14,15,12,13, 2, 3, 3,15, 6, 8,11, 9,12, 0, 3, 0, 1,15, 7,10, 5,99,11, 0,13,14,15,12,13,
|
||||
15,12, 1,99, 7, 4, 5,10,11, 3, 0, 1, 6, 7, 4, 5, 8,13, 0, 1, 6, 7, 4, 5,10, 2, 6, 7, 4, 5,10,11,
|
||||
4, 3,99, 1,99, 7, 4, 5,10,10, 9,12,99,10, 9, 3,11,99,99, 1,14,99,99,13,99,15,12, 9,14,15,12,13,
|
||||
9, 3, 0,99, 6, 7, 4, 5,10, 1, 6, 7, 4, 5,10,11,11, 2, 3, 0, 1, 6,99, 4, 5, 2,10,11, 8, 9,14,15,
|
||||
14, 8, 9,14,15,12,13, 2, 3, 8, 9,14,15,12,13, 2, 0,11, 8, 9,14,15,12,13,99, 2,12,13, 2, 3, 0, 1,
|
||||
8,11, 8, 9,14,15,12,13, 2,10, 0, 1, 6, 7, 4, 5, 3, 9,14,15,12,13, 2, 3, 0, 2, 8, 9,14,15,12,13,
|
||||
11, 3, 0, 1, 5,99,12,13,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,13, 5,99,15,12,13,
|
||||
2,13,13, 9, 9,14, 2,15,15,15,14,12, 9, 2, 9, 3, 2, 3, 0, 1, 6, 7, 4, 5,10, 2, 8,12,14,12,12,13,
|
||||
14, 3, 0, 1, 6, 7, 4, 5,10, 2, 3, 0, 1, 6, 7, 4, 5,10, 2, 0, 1, 6, 7, 4, 5,10, 2, 8, 8, 8,13,15,
|
||||
11, 3, 0, 1, 6, 7, 4, 5,10, 2, 3, 0, 1, 6, 7, 4, 5,10, 2, 0, 1, 6, 7, 4, 5,10,99, 2, 2, 2, 3, 5,
|
||||
2, 3, 0, 1, 2,11, 2,13,99, 2, 2, 9,14,15,12,13, 2,99,99, 1, 2,14,99, 2,10,11, 2, 2,14,15,12,99,
|
||||
2, 2, 2, 2, 2, 8, 5,99, 2, 2, 2, 2, 2, 7, 4, 5,99,99,99,99,99, 6,99,99, 2, 2, 2, 2, 2, 7,99, 8,
|
||||
2,99, 2,99,99, 2, 2, 2,99,99,99,99,99,99,99,99, 4, 2, 2,99, 2, 2,99, 2, 2, 2, 3, 6, 8,11, 9,12,
|
||||
15,13, 2, 2, 2, 2,99, 2, 2, 2, 2,14, 7,13,12,13, 2, 2, 2, 2, 2, 2,99, 2, 2, 2, 8, 1, 2, 5,15, 0,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, 2, 8, 9,14,15,12,13, 2, 3, 0, 2,15, 2, 2, 2, 2,
|
||||
2, 2, 1, 6, 7, 4, 5,10,11, 8, 2, 2, 2, 9, 2, 2,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
};
|
||||
|
||||
static int xor2_table[] =
|
||||
{
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
9,99,15, 7,15, 7,99, 7, 5,10, 2,10, 5,99, 7, 8,14, 5, 6,14, 1, 7,10, 0, 1,14,14, 6, 8, 8, 5,15,
|
||||
14, 5,14, 6, 9, 7, 8,99, 5,99, 6, 6, 6, 8, 7, 8,13, 2, 2,10, 2, 7,10, 0, 1,14,14, 7,13, 8, 5,15,
|
||||
13, 2,10, 2,13, 7, 8, 7, 2,14, 5,14, 2, 8, 7, 8, 8, 6, 6,14, 1, 7,10, 0, 5,10,11, 0,14, 8,99,15,
|
||||
13, 6,14, 6,14, 7, 8, 7, 5,10, 2,10, 5, 8, 7, 8,13, 2, 2,10, 5, 7,10, 0, 1,14,14, 6, 9, 8, 5,15,
|
||||
13, 2,10, 2,10, 7, 8, 7, 1,14, 7, 8, 7, 8, 7, 8,13, 2, 3, 8, 6, 7,10, 0, 0,14,14, 6, 9, 8, 5,15,
|
||||
10, 2,13, 2,99, 7, 8, 7, 1,14,99,14, 1, 8, 7, 8,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,14,99,13, 2,99, 7,99,10, 2, 5,10, 2, 7,10, 0, 2,10,10, 2,10, 8, 5,15,
|
||||
10, 3, 8, 2,10, 7, 8, 7, 5,11, 3,11, 5, 8, 7, 8,13, 7, 7,15, 0, 7,10, 0, 5,14,14, 6,14, 8, 5,15,
|
||||
13, 6,14, 6, 9, 7, 8, 7, 5,15, 7,14, 6, 8, 7, 8,13, 3, 3,10, 2, 7,10, 0, 5,14,14, 7,13, 8, 7, 8,
|
||||
13, 3,11, 3,13, 7, 8, 7, 2,14, 5,14, 2, 8, 7, 8,12, 6, 6,14, 5, 7,10, 0, 5,11,11, 0,14, 8, 5,15,
|
||||
13, 6,14, 6,14, 7, 8, 7, 5,10, 3,10, 5, 8, 7, 8,13, 2, 3, 8, 5, 7,10, 0, 5,14,14, 6,13, 8, 5,15,
|
||||
13, 3,11, 3,11, 7, 8, 7, 5,99, 6,13, 6, 8, 7, 8,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
8,99, 9, 1, 1, 9, 1, 9, 9, 1,13, 1, 3,11,10,10, 5, 5,12,13, 4,12,12, 4,99,12, 3,12,11, 2, 2, 3,
|
||||
0,12, 0,13, 0, 5, 4,12, 4,13,10, 5,11,10, 2, 2, 4,12, 9, 4,13, 9, 5, 8, 8,13, 3, 0, 3, 2,10,13,
|
||||
8, 5,14, 8, 8, 8, 9, 8, 0, 8, 7, 0, 3, 3, 2,10,15,15, 6, 7,14, 6, 6,14,14, 6, 3, 6,11, 2, 3,11,
|
||||
1, 6, 0, 7, 0,15,14, 6,99, 7, 2,15, 3,10,10, 2,14, 6, 0,14, 7, 1,15, 8, 1, 7, 3, 7, 3, 2, 2, 2,
|
||||
8, 3,10, 3, 2, 6, 9, 9, 0, 9, 3, 8, 4, 0,10, 5, 7, 6, 2,10, 1, 8, 4,15, 8, 8,11,11, 7, 4, 4, 7,
|
||||
2, 8,12,14, 6, 6,14, 0, 6,14, 6, 5, 9, 9,12, 9, 2,10,10, 2,10,10, 2, 2,10,10,13, 1, 4, 9,14, 5,
|
||||
6,12,15,15, 7,15,13, 5, 7, 4,13, 7,15,12,15,12, 5,13, 4, 4, 7, 7, 4,12,15,13,14, 6, 6, 6, 6, 5,
|
||||
5, 0,99, 3,11, 3,99, 9,11, 8, 1,11, 3,99, 3, 0, 9,99, 8, 8,11,11, 8, 0, 3, 1, 2, 6, 6, 6, 6,99,
|
||||
99, 1,99, 1, 1, 1, 1, 1, 1, 4,99, 0, 6, 0, 1, 0, 1,11, 3,11,11,11,11, 2,11,11,11,11, 3, 3,11, 3,
|
||||
1, 0, 7, 7, 7, 7, 7, 7, 7, 9, 7, 0, 0, 7, 1, 1, 7,10,10,10,10, 2, 3, 3,10,10,10,10,10, 2, 2, 2,
|
||||
0, 6, 6, 6, 6, 6, 6, 7, 7, 9, 7, 0, 0, 0, 1, 7, 7, 3, 3, 3,11,10, 2,10,99, 3,11,10,99, 3, 3, 3,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5,15,15,15,15,15,15,15, 5,11, 9, 9, 9, 9, 9, 9, 9,10,13,13,13,13,13,13,
|
||||
99, 6,99, 6, 6, 6,99, 6, 6, 8, 7, 0,99, 0, 0, 0, 6,99,99, 2,99,99,99,99,11,10,10, 2, 2, 2, 2, 2,
|
||||
5, 4, 4, 4, 4, 4, 4, 4, 4,14,14,14,14,14,14,14, 4, 8, 8, 8, 8, 8, 8, 8, 8,99,12,12,12,12,12,12,
|
||||
5, 4, 4, 4, 4, 4, 4, 5, 5,14,14,14,14, 0,14,15, 5, 8, 8, 8, 8, 8, 8, 8, 9, 2,12,12,13,13,13,13,
|
||||
9,15,15,15,15,15,15,15,12,15,12,12,12,12,12,12,12, 9, 9, 9, 9, 9,14,14,14,11,13,13,13,13,13,13,
|
||||
99,11,11,11,99,14,99,14,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, 8,10,99, 8, 8, 8,99,
|
||||
2, 3, 2, 2, 0, 6, 3, 2,99, 0,99, 3, 6, 0,99, 6, 6, 2,99, 2, 2, 2, 2, 2, 2,10, 2, 0,99, 2, 6, 6,
|
||||
2, 3, 3, 3, 3, 3, 3, 3, 3,11, 0, 0, 0, 0, 0, 0, 0, 0, 8, 6, 6, 6, 6, 6, 6, 6,14, 3, 6, 0,99, 6,
|
||||
2, 7, 7, 7, 7, 7, 7, 7, 7,15, 1, 1, 1, 1, 1, 1, 1, 1, 9, 4, 4, 4, 4, 4, 4, 4,99, 7, 1, 4, 4,11,
|
||||
2, 2, 2, 2, 2, 2, 2, 5,99, 2, 2, 2,99, 2, 2,99, 3,99, 3,99,12,15, 2, 2, 3, 3,99, 2, 3, 3, 3,99,
|
||||
99, 2, 2,99, 2, 2, 3,99,99, 2, 2, 2, 2, 2, 2,99,99,99,99,99,99, 3,99, 2, 2, 2, 2, 2,99, 3, 2, 3,
|
||||
8,99,99, 2, 2,99, 2,99,99,99,99,99,99,99,99,99, 8,99, 2, 2,99, 2,99, 2, 2, 2, 8, 8, 8, 8, 9,15,
|
||||
8, 8, 2, 2, 2, 2, 2, 2, 2,99,99, 8, 8,15, 9, 9, 2, 2, 2, 2, 2, 2,99, 2, 2, 2, 9, 8,14, 8,99, 8,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, 2,12,12,12,12,12,12,13,13,13, 2,13, 2, 2, 2, 2,
|
||||
2, 2,13,13,13,13,13,13,13,13, 2, 2, 2,99, 2, 2,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,11, 6,99,
|
||||
};
|
||||
|
||||
static int kram3_permut1(int idx, int value)
|
||||
{
|
||||
switch (idx)
|
||||
{
|
||||
default:
|
||||
case 0: return BITSWAP8(value, 7,6,5,4, 3,2,1,0);
|
||||
case 1: return BITSWAP8(value, 7,6,5,4, 0,3,2,1);
|
||||
case 2: return BITSWAP8(value, 7,6,5,4, 1,0,3,2);
|
||||
case 3: return BITSWAP8(value, 7,6,5,4, 2,3,0,1);
|
||||
}
|
||||
}
|
||||
|
||||
static int kram3_permut2(int tbl_index, int idx, int *xor_table)
|
||||
{
|
||||
int xor = 0;
|
||||
|
||||
if (idx == 0 || idx == 3)
|
||||
{
|
||||
xor = xor_table[tbl_index];
|
||||
|
||||
// handle missing values in table
|
||||
if (xor == 99)
|
||||
return xor;
|
||||
}
|
||||
|
||||
xor ^= 0x02;
|
||||
|
||||
if (idx == 3)
|
||||
xor = BITSWAP8(xor, 7,6,5,4, 0,2,3,1);
|
||||
|
||||
return xor;
|
||||
}
|
||||
|
||||
static int kram3_decrypt(int address, int value)
|
||||
{
|
||||
int indx1 = (BIT(address,1) << 1) | BIT(address,5);
|
||||
int indx2 = (BIT(address,7) << 1) | BIT(address,3);
|
||||
|
||||
int bits1 = ((value & 0x10) >> 1) | ((value & 0x07) >> 0);
|
||||
int bits2 = ((value & 0xe0) >> 4) | ((value & 0x08) >> 3);
|
||||
|
||||
int tbl_index = ((address & 0x7f00) >> 4) | (BIT(address,6) << 3) | (BIT(address,4) << 2) | (BIT(address,2) << 1) | (BIT(address,0) << 0);
|
||||
|
||||
int xor1 = kram3_permut2(tbl_index, indx1, xor1_table);
|
||||
int xor2 = kram3_permut2(tbl_index, indx2, xor2_table);
|
||||
|
||||
// handle missing values in table
|
||||
if (xor1 == 99 || xor2 == 99)
|
||||
return 99;
|
||||
|
||||
bits1 = kram3_permut1(indx1, bits1);
|
||||
bits2 = kram3_permut1(indx2, bits2);
|
||||
|
||||
bits1 ^= xor1;
|
||||
bits2 ^= xor2;
|
||||
|
||||
return ((bits2 & 0xe) << 4) | ((bits1 & 0x8) << 1) | ((bits2 & 0x1) << 3) | ((bits1 & 0x7) << 0);
|
||||
}
|
||||
|
||||
static DRIVER_INIT( kram3 )
|
||||
{
|
||||
const UINT8 *patch;
|
||||
@ -1033,13 +1230,10 @@ static DRIVER_INIT( kram3 )
|
||||
|
||||
/********************************
|
||||
|
||||
The encryption algorithm is not known.
|
||||
The encryption algorithm is only partially understood.
|
||||
|
||||
I kept the two tables separate, but the two CPUs are encrypted identically.
|
||||
Addresses that are present in both tables show that when the encrypted value
|
||||
is the same, the decrypted value is the same. When one bit changes in the
|
||||
encrypted value, one bit changes in the decrypted value, and so on.
|
||||
I couldn't find any obvious relationship between values at different addresses.
|
||||
We are currently using two incomplete 2048-nibble tables to get a address
|
||||
dependant xor.
|
||||
|
||||
One important thing to note is that for 6809 instructions that take two
|
||||
opcodes (that is, 10 xx and 11 xx) only the first opcode is encrypted, not the
|
||||
@ -1050,22 +1244,15 @@ static DRIVER_INIT( kram3 )
|
||||
|
||||
i = 0;
|
||||
patch = memory_region(machine, "user1");
|
||||
size = memory_region_length(machine, "user1");
|
||||
rom = memory_region(machine, "main");
|
||||
decrypted = auto_malloc(0x6000);
|
||||
|
||||
memory_set_decrypted_region(0, 0xa000, 0xffff, decrypted);
|
||||
|
||||
memcpy(decrypted,&rom[0xa000],0x6000);
|
||||
while (i < size)
|
||||
for (i = 0xa000; i < 0x10000; ++i)
|
||||
{
|
||||
int a = patch[i] + (patch[i+1] << 8);
|
||||
if (rom[a] != patch[i+2])
|
||||
logerror("error in patch data at address %04x\n",a);
|
||||
else
|
||||
decrypted[a-0xa000] = patch[i+3];
|
||||
|
||||
i += 4;
|
||||
decrypted[i-0xa000] = kram3_decrypt(i, rom[i]);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
@ -1077,15 +1264,9 @@ static DRIVER_INIT( kram3 )
|
||||
memory_set_decrypted_region(1, 0xa000, 0xffff, decrypted);
|
||||
|
||||
memcpy(decrypted,&rom[0xa000],0x6000);
|
||||
while (i < size)
|
||||
for (i = 0xa000; i < 0x10000; ++i)
|
||||
{
|
||||
int a = patch[i] + (patch[i+1] << 8);
|
||||
if (rom[a] != patch[i+2])
|
||||
logerror("error in patch data at address %04x\n",a);
|
||||
else
|
||||
decrypted[a-0xa000] = patch[i+3];
|
||||
|
||||
i += 4;
|
||||
decrypted[i-0xa000] = kram3_decrypt(i, rom[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "driver.h"
|
||||
#include "video/mc6845.h"
|
||||
#include "qix.h"
|
||||
#include "cpu/m6809/m6809.h"
|
||||
|
||||
|
||||
|
||||
@ -440,9 +441,16 @@ static const mc6845_interface mc6845_intf =
|
||||
};
|
||||
|
||||
|
||||
static const m6809_config encryption_config =
|
||||
{
|
||||
TRUE, /* encrypt only the first byte in 10 xx and 11 xx opcodes */
|
||||
};
|
||||
|
||||
|
||||
MACHINE_DRIVER_START( qix_video )
|
||||
MDRV_CPU_ADD("video", M6809, MAIN_CLOCK_OSC/4/4) /* 1.25 MHz */
|
||||
MDRV_CPU_PROGRAM_MAP(qix_video_map,0)
|
||||
MDRV_CPU_CONFIG(encryption_config) // for kram3
|
||||
|
||||
MDRV_VIDEO_START(qix)
|
||||
MDRV_VIDEO_UPDATE(qix)
|
||||
|
Loading…
Reference in New Issue
Block a user