1 #include "driver.h"
2 #include "vidhrdw/generic.h"
3
4
decrypt(int addr,unsigned char e)5 static unsigned char decrypt(int addr, unsigned char e)
6 {
7 static const unsigned char swap_xor_table[6][9] =
8 {
9 { 7,6,5,4,3,2,1,0, 0x00 },
10 { 7,6,5,4,3,2,1,0, 0x28 },
11 { 6,1,3,2,5,7,0,4, 0x96 },
12 { 6,1,5,2,3,7,0,4, 0xbe },
13 { 0,3,7,6,4,2,1,5, 0xd5 },
14 { 0,3,4,6,7,2,1,5, 0xdd }
15 };
16 static const int picktable[32] =
17 {
18 0,2,4,2,4,0,4,2,2,0,2,2,4,0,4,2,
19 2,2,4,0,4,2,4,0,0,4,0,4,4,2,4,2
20 };
21 unsigned int method = 0;
22 const unsigned char *tbl;
23
24
25 /* pick method from bits 0 2 5 7 9 of the address */
26 method = picktable[
27 (addr & 0x001) |
28 ((addr & 0x004) >> 1) |
29 ((addr & 0x020) >> 3) |
30 ((addr & 0x080) >> 4) |
31 ((addr & 0x200) >> 5)];
32
33 /* switch method if bit 11 of the address is set */
34 if ((addr & 0x800) == 0x800)
35 method ^= 1;
36
37 tbl = swap_xor_table[method];
38 return BITSWAP8(e,tbl[0],tbl[1],tbl[2],tbl[3],tbl[4],tbl[5],tbl[6],tbl[7]) ^ tbl[8];
39 }
40
41
pacplus_decode(void)42 void pacplus_decode(void)
43 {
44 int i;
45 unsigned char *RAM;
46
47 /* CPU ROMs */
48
49 RAM = memory_region(REGION_CPU1);
50 for (i = 0; i < 0x4000; i++)
51 {
52 RAM[i] = decrypt(i,RAM[i]);
53 }
54 }
55
56
57