Previous 199869 Revisions Next

r21064 Thursday 14th February, 2013 at 12:54:48 UTC by Miodrag Milanović
pacman protection modernization (nw)
[src/mame/drivers]pacman.c
[src/mame/includes]pacman.h
[src/mame/machine]acitya.c jumpshot.c pacplus.c theglobp.c

trunk/src/mame/drivers/pacman.c
r21063r21064
13571357ADDRESS_MAP_END
13581358
13591359static ADDRESS_MAP_START( theglobp_portmap, AS_IO, 8, pacman_state )
1360   AM_RANGE(0x00, 0xff) AM_READ_LEGACY(theglobp_decrypt_rom)   /* Switch protection logic */
1360   AM_RANGE(0x00, 0xff) AM_READ(theglobp_decrypt_rom)   /* Switch protection logic */
13611361   AM_IMPORT_FROM(writeport)
13621362ADDRESS_MAP_END
13631363
13641364static ADDRESS_MAP_START( acitya_portmap, AS_IO, 8, pacman_state )
1365   AM_RANGE(0x00, 0xff) AM_READ_LEGACY(acitya_decrypt_rom) /* Switch protection logic */
1365   AM_RANGE(0x00, 0xff) AM_READ(acitya_decrypt_rom) /* Switch protection logic */
13661366   AM_IMPORT_FROM(writeport)
13671367ADDRESS_MAP_END
13681368
r21063r21064
60336033
60346034DRIVER_INIT_MEMBER(pacman_state,pacplus)
60356035{
6036   pacplus_decode(machine());
6036   pacplus_decode();
60376037}
60386038
60396039DRIVER_INIT_MEMBER(pacman_state,jumpshot)
60406040{
6041   jumpshot_decode(machine());
6041   jumpshot_decode();
60426042}
60436043
60446044DRIVER_INIT_MEMBER(pacman_state,drivfrcp)
trunk/src/mame/machine/jumpshot.c
r21063r21064
22#include "includes/pacman.h"
33
44
5static UINT8 decrypt(int addr, UINT8 e)
5UINT8 pacman_state::jumpshot_decrypt(int addr, UINT8 e)
66{
77   static const UINT8 swap_xor_table[6][9] =
88   {
r21063r21064
3939}
4040
4141
42void jumpshot_decode(running_machine &machine)
42void pacman_state::jumpshot_decode()
4343{
4444   int i;
4545   UINT8 *RAM;
4646
4747   /* CPU ROMs */
4848
49   RAM = machine.root_device().memregion("maincpu")->base();
49   RAM = memregion("maincpu")->base();
5050   for (i = 0; i < 0x4000; i++)
5151   {
52      RAM[i] = decrypt(i,RAM[i]);
52      RAM[i] = jumpshot_decrypt(i,RAM[i]);
5353   }
5454}
trunk/src/mame/machine/acitya.c
r21063r21064
1616#include "includes/pacman.h"
1717
1818
19static void acitya_decrypt_rom_8(running_machine &machine)
19void pacman_state::acitya_decrypt_rom_8()
2020{
2121   int oldbyte,inverted_oldbyte,newbyte;
2222   int mem;
2323   UINT8 *RAM;
2424
25   RAM = machine.root_device().memregion("maincpu")->base();
25   RAM = memregion("maincpu")->base();
2626
2727
2828   for (mem=0;mem<0x4000;mem++)
r21063r21064
5151}
5252
5353
54static void acitya_decrypt_rom_9(running_machine &machine)
54void pacman_state::acitya_decrypt_rom_9()
5555{
5656   int oldbyte,inverted_oldbyte,newbyte;
5757   int mem;
5858   UINT8 *RAM;
5959
60   RAM = machine.root_device().memregion("maincpu")->base();
60   RAM = memregion("maincpu")->base();
6161
6262   for (mem=0;mem<0x4000;mem++)
6363   {
r21063r21064
8383   return;
8484}
8585
86static void acitya_decrypt_rom_A(running_machine &machine)
86void pacman_state::acitya_decrypt_rom_A()
8787{
8888   int oldbyte,inverted_oldbyte,newbyte;
8989   int mem;
9090   UINT8 *RAM;
9191
92   RAM = machine.root_device().memregion("maincpu")->base();
92   RAM = memregion("maincpu")->base();
9393
9494   for (mem=0;mem<0x4000;mem++)
9595   {
r21063r21064
115115   return;
116116}
117117
118static void acitya_decrypt_rom_B(running_machine &machine)
118void pacman_state::acitya_decrypt_rom_B()
119119{
120120   int oldbyte,inverted_oldbyte,newbyte;
121121   int mem;
122122   UINT8 *RAM;
123123
124   RAM = machine.root_device().memregion("maincpu")->base();
124   RAM = memregion("maincpu")->base();
125125
126126   for (mem=0;mem<0x4000;mem++)
127127   {
r21063r21064
150150}
151151
152152
153READ8_HANDLER( acitya_decrypt_rom )
153READ8_MEMBER(pacman_state::acitya_decrypt_rom )
154154{
155   pacman_state *state = space.machine().driver_data<pacman_state>();
156155   if (offset & 0x01)
157156   {
158      state->m_counter = (state->m_counter - 1) & 0x0F;
157      m_counter = (m_counter - 1) & 0x0F;
159158   }
160159   else
161160   {
162      state->m_counter = (state->m_counter + 1) & 0x0F;
161      m_counter = (m_counter + 1) & 0x0F;
163162   }
164163
165   switch(state->m_counter)
164   switch(m_counter)
166165   {
167      case 0x08:  state->membank ("bank1")->set_entry (0);        break;
168      case 0x09:  state->membank ("bank1")->set_entry (1);        break;
169      case 0x0A:  state->membank ("bank1")->set_entry (2);        break;
170      case 0x0B:  state->membank ("bank1")->set_entry (3);        break;
166      case 0x08:  membank ("bank1")->set_entry (0);        break;
167      case 0x09:  membank ("bank1")->set_entry (1);        break;
168      case 0x0A:  membank ("bank1")->set_entry (2);        break;
169      case 0x0B:  membank ("bank1")->set_entry (3);        break;
171170      default:
172         logerror("Invalid counter = %02X\n",state->m_counter);
171         logerror("Invalid counter = %02X\n",m_counter);
173172         break;
174173   }
175174
r21063r21064
184183   /* While the PAL supports up to 16 decryption methods, only four
185184       are actually used in the PAL.  Therefore, we'll take a little
186185       memory overhead and decrypt the ROMs using each method in advance. */
187   acitya_decrypt_rom_8(machine());
188   acitya_decrypt_rom_9(machine());
189   acitya_decrypt_rom_A(machine());
190   acitya_decrypt_rom_B(machine());
186   acitya_decrypt_rom_8();
187   acitya_decrypt_rom_9();
188   acitya_decrypt_rom_A();
189   acitya_decrypt_rom_B();
191190
192191   membank("bank1")->configure_entries(0, 4, &RAM[0x10000], 0x4000);
193192
trunk/src/mame/machine/theglobp.c
r21063r21064
6565#include "includes/pacman.h"
6666
6767
68static void theglobp_decrypt_rom_8(running_machine &machine)
68void pacman_state::theglobp_decrypt_rom_8()
6969{
7070   int oldbyte,inverted_oldbyte,newbyte;
7171   int mem;
7272   UINT8 *RAM;
7373
74   RAM = machine.root_device().memregion("maincpu")->base();
74   RAM = memregion("maincpu")->base();
7575
7676
7777   for (mem=0;mem<0x4000;mem++)
r21063r21064
101101}
102102
103103
104static void theglobp_decrypt_rom_9(running_machine &machine)
104void pacman_state::theglobp_decrypt_rom_9()
105105{
106106   int oldbyte,inverted_oldbyte,newbyte;
107107   int mem;
108108   UINT8 *RAM;
109109
110   RAM = machine.root_device().memregion("maincpu")->base();
110   RAM = memregion("maincpu")->base();
111111
112112   for (mem=0;mem<0x4000;mem++)
113113   {
r21063r21064
135135   return;
136136}
137137
138static void theglobp_decrypt_rom_A(running_machine &machine)
138void pacman_state::theglobp_decrypt_rom_A()
139139{
140140   int oldbyte,inverted_oldbyte,newbyte;
141141   int mem;
142142   UINT8 *RAM;
143143
144   RAM = machine.root_device().memregion("maincpu")->base();
144   RAM = memregion("maincpu")->base();
145145
146146   for (mem=0;mem<0x4000;mem++)
147147   {
r21063r21064
169169   return;
170170}
171171
172static void theglobp_decrypt_rom_B(running_machine &machine)
172void pacman_state::theglobp_decrypt_rom_B()
173173{
174174   int oldbyte,inverted_oldbyte,newbyte;
175175   int mem;
176176   UINT8 *RAM;
177177
178   RAM = machine.root_device().memregion("maincpu")->base();
178   RAM = memregion("maincpu")->base();
179179
180180   for (mem=0;mem<0x4000;mem++)
181181   {
r21063r21064
204204}
205205
206206
207READ8_HANDLER( theglobp_decrypt_rom )
207READ8_MEMBER(pacman_state::theglobp_decrypt_rom )
208208{
209   pacman_state *state = space.machine().driver_data<pacman_state>();
210209   if (offset & 0x01)
211210   {
212      state->m_counter = (state->m_counter - 1) & 0x0F;
211      m_counter = (m_counter - 1) & 0x0F;
213212   }
214213   else
215214   {
216      state->m_counter = (state->m_counter + 1) & 0x0F;
215      m_counter = (m_counter + 1) & 0x0F;
217216   }
218217
219   switch(state->m_counter)
218   switch(m_counter)
220219   {
221      case 0x08:  state->membank ("bank1")->set_entry (0);        break;
222      case 0x09:  state->membank ("bank1")->set_entry (1);        break;
223      case 0x0A:  state->membank ("bank1")->set_entry (2);        break;
224      case 0x0B:  state->membank ("bank1")->set_entry (3);        break;
220      case 0x08:  membank ("bank1")->set_entry (0);        break;
221      case 0x09:  membank ("bank1")->set_entry (1);        break;
222      case 0x0A:  membank ("bank1")->set_entry (2);        break;
223      case 0x0B:  membank ("bank1")->set_entry (3);        break;
225224      default:
226         logerror("Invalid counter = %02X\n",state->m_counter);
225         logerror("Invalid counter = %02X\n",m_counter);
227226         break;
228227   }
229228
r21063r21064
238237   /* While the PAL supports up to 16 decryption methods, only four
239238       are actually used in the PAL.  Therefore, we'll take a little
240239       memory overhead and decrypt the ROMs using each method in advance. */
241   theglobp_decrypt_rom_8(machine());
242   theglobp_decrypt_rom_9(machine());
243   theglobp_decrypt_rom_A(machine());
244   theglobp_decrypt_rom_B(machine());
240   theglobp_decrypt_rom_8();
241   theglobp_decrypt_rom_9();
242   theglobp_decrypt_rom_A();
243   theglobp_decrypt_rom_B();
245244
246245   membank("bank1")->configure_entries(0, 4, &RAM[0x10000], 0x4000);
247246
trunk/src/mame/machine/pacplus.c
r21063r21064
22#include "includes/pacman.h"
33
44
5static UINT8 decrypt(int addr, UINT8 e)
5UINT8 pacman_state::pacplus_decrypt(int addr, UINT8 e)
66{
77   static const UINT8 swap_xor_table[6][9] =
88   {
r21063r21064
3939}
4040
4141
42void pacplus_decode(running_machine &machine)
42void pacman_state::pacplus_decode()
4343{
4444   int i;
4545   UINT8 *RAM;
4646
4747   /* CPU ROMs */
4848
49   RAM = machine.root_device().memregion("maincpu")->base();
49   RAM = memregion("maincpu")->base();
5050   for (i = 0; i < 0x4000; i++)
5151   {
52      RAM[i] = decrypt(i,RAM[i]);
52      RAM[i] = pacplus_decrypt(i,RAM[i]);
5353   }
5454}
trunk/src/mame/includes/pacman.h
r21063r21064
125125   DECLARE_VIDEO_START(pacman);
126126   DECLARE_PALETTE_INIT(pacman);
127127   DECLARE_VIDEO_START(birdiy);
128   DECLARE_MACHINE_START(theglobp);
129   DECLARE_MACHINE_RESET(theglobp);
130   DECLARE_MACHINE_START(acitya);
131   DECLARE_MACHINE_RESET(acitya);
132128   DECLARE_VIDEO_START(s2650games);
133129   DECLARE_MACHINE_RESET(mschamp);
134130   DECLARE_MACHINE_RESET(superabc);
r21063r21064
145141   void korosuke_rom_decode();
146142   void eyes_decode(UINT8 *data);
147143   void mspacman_install_patches(UINT8 *ROM);
148};
144   
145   // theglopb.c
146   void theglobp_decrypt_rom_8();
147   void theglobp_decrypt_rom_9();
148   void theglobp_decrypt_rom_A();
149   void theglobp_decrypt_rom_B();
150   DECLARE_READ8_MEMBER(theglobp_decrypt_rom);
151   DECLARE_MACHINE_START(theglobp);
152   DECLARE_MACHINE_RESET(theglobp);
149153
150/*----------- defined in machine/pacplus.c -----------*/
151void pacplus_decode(running_machine &machine);
154   // pacplus.c
155   UINT8 pacplus_decrypt(int addr, UINT8 e);
156   void pacplus_decode();
152157
153/*----------- defined in machine/jumpshot.c -----------*/
154void jumpshot_decode(running_machine &machine);
155
156/*----------- defined in machine/theglobp.c -----------*/
157DECLARE_READ8_HANDLER( theglobp_decrypt_rom );
158
159/*----------- defined in machine/acitya.c -------------*/
160DECLARE_READ8_HANDLER( acitya_decrypt_rom );
158   // jumpshot.c
159   UINT8 jumpshot_decrypt(int addr, UINT8 e);
160   void jumpshot_decode();
161   
162   // acitya.c
163   void acitya_decrypt_rom_8();
164   void acitya_decrypt_rom_9();
165   void acitya_decrypt_rom_A();
166   void acitya_decrypt_rom_B();
167   DECLARE_READ8_MEMBER(acitya_decrypt_rom);
168   DECLARE_MACHINE_START(acitya);
169   DECLARE_MACHINE_RESET(acitya);   
170};

Previous 199869 Revisions Next


© 1997-2024 The MAME Team