1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 #include "emu.h"
4 #include "includes/pacman.h"
5
6
jumpshot_decrypt(int addr,uint8_t e)7 uint8_t pacman_state::jumpshot_decrypt(int addr, uint8_t e)
8 {
9 static const uint8_t swap_xor_table[6][9] =
10 {
11 { 7,6,5,4,3,2,1,0, 0x00 },
12 { 7,6,3,4,5,2,1,0, 0x20 },
13 { 5,0,4,3,7,1,2,6, 0xa4 },
14 { 5,0,4,3,7,1,2,6, 0x8c },
15 { 2,3,1,7,4,6,0,5, 0x6e },
16 { 2,3,4,7,1,6,0,5, 0x4e }
17 };
18 static const int picktable[32] =
19 {
20 0,2,4,4,4,2,0,2,2,0,2,4,4,2,0,2,
21 5,3,5,1,5,3,5,3,1,5,1,5,5,3,5,3
22 };
23 uint32_t method = 0;
24 const uint8_t *tbl;
25
26
27 /* pick method from bits 0 2 5 7 9 of the address */
28 method = picktable[
29 (addr & 0x001) |
30 ((addr & 0x004) >> 1) |
31 ((addr & 0x020) >> 3) |
32 ((addr & 0x080) >> 4) |
33 ((addr & 0x200) >> 5)];
34
35 /* switch method if bit 11 of the address is set */
36 if ((addr & 0x800) == 0x800)
37 method ^= 1;
38
39 tbl = swap_xor_table[method];
40 return bitswap<8>(e,tbl[0],tbl[1],tbl[2],tbl[3],tbl[4],tbl[5],tbl[6],tbl[7]) ^ tbl[8];
41 }
42
43
jumpshot_decode()44 void pacman_state::jumpshot_decode()
45 {
46 int i;
47 uint8_t *RAM;
48
49 /* CPU ROMs */
50
51 RAM = memregion("maincpu")->base();
52 for (i = 0; i < 0x4000; i++)
53 {
54 RAM[i] = jumpshot_decrypt(i,RAM[i]);
55 }
56 }
57