Previous 199869 Revisions Next

r26339 Thursday 21st November, 2013 at 17:14:03 UTC by Osso
Misc legacy handlers cleanups. (nw)
[src/mame/drivers]system1.c
[src/mame/includes]galaxold.h namcos1.h
[src/mame/machine]galaxold.c midtunit.c namcos1.c tnzs.c

trunk/src/mame/drivers/system1.c
r26338r26339
47404740   m_videomode_custom = &system1_state::dakkochn_custom_w;
47414741
47424742   mc8123_decrypt_rom(machine(), "maincpu", "key", "bank1", 4);
4743
4744//  m_maincpu->space(AS_IO).install_legacy_read_handler(0x00, 0x00, FUNC(dakkochn_port_00_r));
4745//  m_maincpu->space(AS_IO).install_legacy_read_handler(0x03, 0x03, FUNC(dakkochn_port_03_r));
4746//  m_maincpu->space(AS_IO).install_legacy_read_handler(0x04, 0x04, FUNC(dakkochn_port_04_r));
4747
4748//  m_maincpu->space(AS_IO).install_legacy_write_handler(0x15, 0x15, FUNC(dakkochn_port_15_w));
47494743}
47504744
47514745
trunk/src/mame/machine/galaxold.c
r26338r26339
126126   set_led_status(machine(), offset,data & 1);
127127}
128128
129
130#ifdef UNUSED_FUNCTION
131READ8_MEMBER(galaxold_state::checkmaj_protection_r)
132{
133   switch (space.device().safe_pc())
134   {
135   case 0x0f15:  return 0xf5;
136   case 0x0f8f:  return 0x7c;
137   case 0x10b3:  return 0x7c;
138   case 0x10e0:  return 0x00;
139   case 0x10f1:  return 0xaa;
140   case 0x1402:  return 0xaa;
141   default:
142      logerror("Unknown protection read. PC=%04X\n",space.device().safe_pc());
143   }
144
145   return 0;
146}
147
148
149/* Zig Zag can swap ROMs 2 and 3 as a form of copy protection */
150WRITE8_MEMBER(galaxold_state::zigzag_sillyprotection_w)
151{
152   if (data)
153   {
154      /* swap ROM 2 and 3! */
155      membank("bank1")->set_entry(1);
156      membank("bank2")->set_entry(0);
157   }
158   else
159   {
160      membank("bank1")->set_entry(0);
161      membank("bank2")->set_entry(1);
162   }
163}
164
165DRIVER_INIT_MEMBER(galaxold_state,zigzag)
166{
167   UINT8 *RAM = memregion("maincpu")->base();
168   membank("bank1")->configure_entries(0, 2, &RAM[0x2000], 0x1000);
169   membank("bank2")->configure_entries(0, 2, &RAM[0x2000], 0x1000);
170   membank("bank1")->set_entry(0);
171   membank("bank2")->set_entry(1);
172}
173
174
175
176READ8_MEMBER(galaxold_state::dingo_3000_r)
177{
178   return 0xaa;
179}
180
181READ8_MEMBER(galaxold_state::dingo_3035_r)
182{
183   return 0x8c;
184}
185
186READ8_MEMBER(galaxold_state::dingoe_3001_r)
187{
188   return 0xaa;
189}
190
191
192DRIVER_INIT_MEMBER(galaxold_state,dingoe)
193{
194   offs_t i;
195   UINT8 *rom = memregion("maincpu")->base();
196
197   for (i = 0; i < 0x3000; i++)
198   {
199      UINT8 data_xor;
200
201      /* XOR bit 2 with 4 and 5 with 0 */
202      data_xor = BIT(rom[i], 2) << 4 | BIT(rom[i], 5) << 0;
203      rom[i] ^= data_xor;
204
205
206      /* Invert bit 1 */
207      if (~rom[i] & 0x02)
208         rom[i] = rom[i] | 0x02;
209      else
210         rom[i] = rom[i] & 0xfd;
211
212
213      /* Swap bit0 with bit4 */
214      if ((i & 0x0f) == 0x02 || (i & 0x0f) == 0x0a || (i & 0x0f) == 0x03 || (i & 0x0f) == 0x0b || (i & 0x0f) == 0x06 || (i & 0x0f) == 0x0e || (i & 0x0f) == 0x07 || (i & 0x0f) == 0x0f)   /* Swap Bit 0 and 4 */
215         rom[i] = BITSWAP8(rom[i],7,6,5,0,3,2,1,4);
216   }
217
218   m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x3001, 0x3001, FUNC(dingoe_3001_r));   /* Protection check */
219
220}
221#endif
222
223
224129READ8_MEMBER(galaxold_state::scramblb_protection_1_r)
225130{
226131   switch (space.device().safe_pc())
r26338r26339
260165   return (ioport(portnames[m__4in1_bank])->read() & bit_mask) ? 0x01 : 0x00;
261166}
262167
263#ifdef UNUSED_FUNCTION
264DRIVER_INIT_MEMBER(galaxold_state,pisces)
265{
266   /* the coin lockout was replaced */
267   m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x6002, 0x6002, FUNC(galaxold_gfxbank_w));
268}
269
270DRIVER_INIT_MEMBER(galaxold_state,checkmaj)
271{
272   /* for the title screen */
273   m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x3800, 0x3800, FUNC(checkmaj_protection_r));
274}
275
276DRIVER_INIT_MEMBER(galaxold_state,dingo)
277{
278   m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x3000, 0x3000, FUNC(dingo_3000_r));
279   m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x3035, 0x3035, FUNC(dingo_3035_r));
280}
281
282
283UINT8 galaxold_state::decode_mooncrst(UINT8 data,offs_t addr)
284{
285   UINT8 res;
286
287   res = data;
288   if (BIT(data,1)) res ^= 0x40;
289   if (BIT(data,5)) res ^= 0x04;
290   if ((addr & 1) == 0)
291      res = (res & 0xbb) | (BIT(res,6) << 2) | (BIT(res,2) << 6);
292   return res;
293}
294
295DRIVER_INIT_MEMBER(galaxold_state,mooncrsu)
296{
297   m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0xa000, 0xa002, FUNC(galaxold_gfxbank_w));
298}
299
300DRIVER_INIT_MEMBER(galaxold_state,mooncrst)
301{
302   offs_t i, len = memregion("maincpu")->bytes();
303   UINT8 *rom = memregion("maincpu")->base();
304
305
306   for (i = 0;i < len;i++)
307      rom[i] = decode_mooncrst(rom[i],i);
308
309   DRIVER_INIT_CALL(mooncrsu);
310}
311
312DRIVER_INIT_MEMBER(galaxold_state,mooncrgx)
313{
314   m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x6000, 0x6002, FUNC(galaxold_gfxbank_w));
315}
316
317DRIVER_INIT_MEMBER(galaxold_state,moonqsr)
318{
319   offs_t i;
320   address_space &space = m_maincpu->space(AS_PROGRAM);
321   UINT8 *rom = memregion("maincpu")->base();
322   UINT8 *decrypt = auto_alloc_array(machine(), UINT8, 0x8000);
323
324   space.set_decrypted_region(0x0000, 0x7fff, decrypt);
325
326   for (i = 0;i < 0x8000;i++)
327      decrypt[i] = decode_mooncrst(rom[i],i);
328}
329
330DRIVER_INIT_MEMBER(galaxold_state,checkman)
331{
332/*
333                     Encryption Table
334                     ----------------
335+---+---+---+------+------+------+------+------+------+------+------+
336|A2 |A1 |A0 |D7    |D6    |D5    |D4    |D3    |D2    |D1    |D0    |
337+---+---+---+------+------+------+------+------+------+------+------+
338| 0 | 0 | 0 |D7    |D6    |D5    |D4    |D3    |D2    |D1    |D0^^D6|
339| 0 | 0 | 1 |D7    |D6    |D5    |D4    |D3    |D2    |D1^^D5|D0    |
340| 0 | 1 | 0 |D7    |D6    |D5    |D4    |D3    |D2^^D4|D1^^D6|D0    |
341| 0 | 1 | 1 |D7    |D6    |D5    |D4^^D2|D3    |D2    |D1    |D0^^D5|
342| 1 | 0 | 0 |D7    |D6^^D4|D5^^D1|D4    |D3    |D2    |D1    |D0    |
343| 1 | 0 | 1 |D7    |D6^^D0|D5^^D2|D4    |D3    |D2    |D1    |D0    |
344| 1 | 1 | 0 |D7    |D6    |D5    |D4    |D3    |D2^^D0|D1    |D0    |
345| 1 | 1 | 1 |D7    |D6    |D5    |D4^^D1|D3    |D2    |D1    |D0    |
346+---+---+---+------+------+------+------+------+------+------+------+
347
348For example if A2=1, A1=1 and A0=0 then D2 to the CPU would be an XOR of
349D2 and D0 from the ROM's. Note that D7 and D3 are not encrypted.
350
351Encryption PAL 16L8 on cardridge
352         +--- ---+
353    OE --|   U   |-- VCC
354 ROMD0 --|       |-- D0
355 ROMD1 --|       |-- D1
356 ROMD2 --|VER 5.2|-- D2
357    A0 --|       |-- NOT USED
358    A1 --|       |-- A2
359 ROMD4 --|       |-- D4
360 ROMD5 --|       |-- D5
361 ROMD6 --|       |-- D6
362   GND --|       |-- M1 (NOT USED)
363         +-------+
364Pin layout is such that links can replace the PAL if encryption is not used.
365
366*/
367   static const UINT8 xortable[8][4] =
368   {
369      { 6,0,6,0 },
370      { 5,1,5,1 },
371      { 4,2,6,1 },
372      { 2,4,5,0 },
373      { 4,6,1,5 },
374      { 0,6,2,5 },
375      { 0,2,0,2 },
376      { 1,4,1,4 }
377   };
378
379   offs_t i, len = memregion("maincpu")->bytes();
380   UINT8 *rom = memregion("maincpu")->base();
381
382
383   for (i = 0; i < len; i++)
384   {
385      UINT8 data_xor;
386      int line = i & 0x07;
387
388      data_xor = (BIT(rom[i],xortable[line][0]) << xortable[line][1]) |
389               (BIT(rom[i],xortable[line][2]) << xortable[line][3]);
390
391      rom[i] ^= data_xor;
392   }
393}
394#endif
395
396168DRIVER_INIT_MEMBER(galaxold_state,4in1)
397169{
398170   address_space &space = m_maincpu->space(AS_PROGRAM);
trunk/src/mame/machine/midtunit.c
r26338r26339
491491
492492#if ENABLE_ALL_JDREDD_LEVELS
493493   /* how about the final levels? */
494   jdredd_hack = m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0xFFBA7FF0, 0xFFBA7FFf, FUNC(jdredd_hack_r));
494   jdredd_hack = m_maincpu->space(AS_PROGRAM).install_read_handler(0xFFBA7FF0, 0xFFBA7FFf, read16_delegate(FUNC(midtunit_state::jdredd_hack_r), this));
495495#endif
496496}
497497
trunk/src/mame/machine/tnzs.c
r26338r26339
536536{
537537   m_mcu_type = MCU_TNZS;
538538   /* we need to install a kludge to avoid problems with a bug in the original code */
539//  m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0xef10, 0xef10, FUNC(tnzs_sync_kludge_w));
539//  m_maincpu->space(AS_PROGRAM).install_write_handler(0xef10, 0xef10, write8_delegate(FUNC(tnzs_state::tnzs_sync_kludge_w), this));
540540}
541541
542542DRIVER_INIT_MEMBER(tnzs_state,tnzsb)
r26338r26339
544544   m_mcu_type = MCU_NONE_TNZSB;
545545
546546   /* we need to install a kludge to avoid problems with a bug in the original code */
547//  m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0xef10, 0xef10, FUNC(tnzs_sync_kludge_w));
547//  m_maincpu->space(AS_PROGRAM).install_write_handler(0xef10, 0xef10, write8_delegate(FUNC(tnzs_state::tnzs_sync_kludge_w), this));
548548}
549549
550550DRIVER_INIT_MEMBER(tnzs_state,kabukiz)
trunk/src/mame/machine/namcos1.c
r26338r26339
8282}
8383
8484
85// used by faceoff and tankforce 4 player (input multiplex)
86static DECLARE_READ8_HANDLER( faceoff_inputs_r );
87
8885static READ8_HANDLER( no_key_r )
8986{
9087   popmessage("CPU %s PC %08x: keychip read %04x\n", space.device().tag(), space.device().safe_pc(), offset);
r26338r26339
12171214   };
12181215   namcos1_driver_init(machine(), &tankfrce_specific);
12191216
1220   m_mcu->space(AS_PROGRAM).install_legacy_read_handler(0x1400, 0x1401, FUNC(faceoff_inputs_r));
1217   m_mcu->space(AS_PROGRAM).install_read_handler(0x1400, 0x1401, read8_delegate(FUNC(namcos1_state::faceoff_inputs_r), this));
12211218}
12221219
12231220/*******************************************************************************
r26338r26339
12731270/*******************************************************************************
12741271*   Quester specific                                                           *
12751272*******************************************************************************/
1276static READ8_HANDLER( quester_paddle_r )
1273READ8_MEMBER( namcos1_state::quester_paddle_r )
12771274{
12781275   static int qnum=0, qstrobe=0;
12791276
r26338r26339
12821279      int ret;
12831280
12841281      if (!qnum)
1285         ret = (space.machine().root_device().ioport("CONTROL0")->read()&0x90) | qstrobe | (space.machine().root_device().ioport("PADDLE0")->read()&0x0f);
1282         ret = (ioport("CONTROL0")->read()&0x90) | qstrobe | (ioport("PADDLE0")->read()&0x0f);
12861283      else
1287         ret = (space.machine().root_device().ioport("CONTROL0")->read()&0x90) | qstrobe | (space.machine().root_device().ioport("PADDLE1")->read()&0x0f);
1284         ret = (ioport("CONTROL0")->read()&0x90) | qstrobe | (ioport("PADDLE1")->read()&0x0f);
12881285
12891286      qstrobe ^= 0x40;
12901287
r26338r26339
12951292      int ret;
12961293
12971294      if (!qnum)
1298         ret = (space.machine().root_device().ioport("CONTROL1")->read()&0x90) | qnum | (space.machine().root_device().ioport("PADDLE0")->read()>>4);
1295         ret = (ioport("CONTROL1")->read()&0x90) | qnum | (ioport("PADDLE0")->read()>>4);
12991296      else
1300         ret = (space.machine().root_device().ioport("CONTROL1")->read()&0x90) | qnum | (space.machine().root_device().ioport("PADDLE1")->read()>>4);
1297         ret = (ioport("CONTROL1")->read()&0x90) | qnum | (ioport("PADDLE1")->read()>>4);
13011298
13021299      if (!qstrobe) qnum ^= 0x20;
13031300
r26338r26339
13081305DRIVER_INIT_MEMBER(namcos1_state,quester)
13091306{
13101307   namcos1_driver_init(machine(), NULL);
1311   m_mcu->space(AS_PROGRAM).install_legacy_read_handler(0x1400, 0x1401, FUNC(quester_paddle_r));
1308   m_mcu->space(AS_PROGRAM).install_read_handler(0x1400, 0x1401, read8_delegate(FUNC(namcos1_state::quester_paddle_r), this));
13121309}
13131310
13141311
r26338r26339
13171314*   Beraboh Man specific                                                       *
13181315*******************************************************************************/
13191316
1320static READ8_HANDLER( berabohm_buttons_r )
1317READ8_MEMBER( namcos1_state::berabohm_buttons_r )
13211318{
13221319   int res;
13231320   static int input_count, strobe, strobe_count;
r26338r26339
13271324   {
13281325      int inp = input_count;
13291326
1330      if (inp == 4) res = space.machine().root_device().ioport("CONTROL0")->read();
1327      if (inp == 4) res = ioport("CONTROL0")->read();
13311328      else
13321329      {
13331330         char portname[40];
r26338r26339
13361333         static int counter[4];
13371334
13381335         sprintf(portname,"IN%d",inp);   /* IN0-IN3 */
1339         res = space.machine().root_device().ioport(portname)->read();
1336         res = ioport(portname)->read();
13401337         if (res & 0x80)
13411338         {
13421339            if (counter[inp] >= 0)
r26338r26339
13601357            counter[inp] = -1;
13611358#else
13621359         sprintf(portname,"IN%d",inp);   /* IN0-IN3 */
1363         res = space.machine().root_device().ioport(portname)->read();
1360         res = ioport(portname)->read();
13641361         if (res & 1) res = 0x7f;        /* weak */
13651362         else if (res & 2) res = 0x48;   /* medium */
13661363         else if (res & 4) res = 0x40;   /* strong */
r26338r26339
13711368   }
13721369   else
13731370   {
1374      res = space.machine().root_device().ioport("CONTROL1")->read() & 0x8f;
1371      res = ioport("CONTROL1")->read() & 0x8f;
13751372
13761373      /* the strobe cannot happen too often, otherwise the MCU will waste too
13771374         much time reading the inputs and won't have enough cycles to play two
r26338r26339
13971394DRIVER_INIT_MEMBER(namcos1_state,berabohm)
13981395{
13991396   namcos1_driver_init(machine(), NULL);
1400   m_mcu->space(AS_PROGRAM).install_legacy_read_handler(0x1400, 0x1401, FUNC(berabohm_buttons_r));
1397   m_mcu->space(AS_PROGRAM).install_read_handler(0x1400, 0x1401, read8_delegate(FUNC(namcos1_state::berabohm_buttons_r), this));
14011398}
14021399
14031400
r26338r26339
14061403*   Face Off specific                                                          *
14071404*******************************************************************************/
14081405
1409static READ8_HANDLER( faceoff_inputs_r )
1406// used by faceoff and tankforce 4 player (input multiplex)
1407
1408READ8_MEMBER( namcos1_state::faceoff_inputs_r )
14101409{
14111410   int res;
14121411   static int input_count, strobe_count, stored_input[2];
14131412
14141413   if (offset == 0)
14151414   {
1416      res = (space.machine().root_device().ioport("CONTROL0")->read() & 0x80) | stored_input[0];
1415      res = (ioport("CONTROL0")->read() & 0x80) | stored_input[0];
14171416
14181417      return res;
14191418   }
14201419   else
14211420   {
1422      res = space.machine().root_device().ioport("CONTROL1")->read() & 0x80;
1421      res = ioport("CONTROL1")->read() & 0x80;
14231422
14241423      /* the strobe cannot happen too often, otherwise the MCU will waste too
14251424         much time reading the inputs and won't have enough cycles to play two
r26338r26339
14341433         switch (input_count)
14351434         {
14361435            case 0:
1437               stored_input[0] = space.machine().root_device().ioport("IN0")->read() & 0x1f;
1438               stored_input[1] = (space.machine().root_device().ioport("IN3")->read() & 0x07) << 3;
1436               stored_input[0] = ioport("IN0")->read() & 0x1f;
1437               stored_input[1] = (ioport("IN3")->read() & 0x07) << 3;
14391438               break;
14401439
14411440            case 3:
1442               stored_input[0] = space.machine().root_device().ioport("IN2")->read() & 0x1f;
1441               stored_input[0] = ioport("IN2")->read() & 0x1f;
14431442               break;
14441443
14451444            case 4:
1446               stored_input[0] = space.machine().root_device().ioport("IN1")->read() & 0x1f;
1447               stored_input[1] = space.machine().root_device().ioport("IN3")->read() & 0x18;
1445               stored_input[0] = ioport("IN1")->read() & 0x1f;
1446               stored_input[1] = ioport("IN3")->read() & 0x18;
14481447               break;
14491448
14501449            default:
r26338r26339
14671466DRIVER_INIT_MEMBER(namcos1_state,faceoff)
14681467{
14691468   namcos1_driver_init(machine(), NULL);
1470   m_mcu->space(AS_PROGRAM).install_legacy_read_handler(0x1400, 0x1401, FUNC(faceoff_inputs_r));
1469   m_mcu->space(AS_PROGRAM).install_read_handler(0x1400, 0x1401, read8_delegate(FUNC(namcos1_state::faceoff_inputs_r), this));
14711470}
trunk/src/mame/includes/namcos1.h
r26338r26339
7777   DECLARE_WRITE8_MEMBER(namcos1_subcpu_bank_w);
7878   DECLARE_WRITE8_MEMBER(namcos1_mcu_bankswitch_w);
7979   DECLARE_WRITE8_MEMBER(namcos1_mcu_patch_w);
80   DECLARE_READ8_MEMBER(quester_paddle_r);
81   DECLARE_READ8_MEMBER(berabohm_buttons_r);
82   DECLARE_READ8_MEMBER(faceoff_inputs_r);
8083   DECLARE_DRIVER_INIT(pacmania);
8184   DECLARE_DRIVER_INIT(ws);
8285   DECLARE_DRIVER_INIT(wldcourt);
r26338r26339
110113   virtual void video_start();
111114   UINT32 screen_update_namcos1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
112115   void screen_eof_namcos1(screen_device &screen, bool state);
116   
113117
114118private:
115119   inline void bg_get_info(tile_data &tileinfo,int tile_index,UINT8 *info_vram);
trunk/src/mame/includes/galaxold.h
r26338r26339
101101   DECLARE_WRITE8_MEMBER(galaxold_coin_counter_1_w);
102102   DECLARE_WRITE8_MEMBER(galaxold_coin_counter_2_w);
103103   DECLARE_WRITE8_MEMBER(galaxold_leds_w);
104   DECLARE_WRITE8_MEMBER(zigzag_sillyprotection_w);
105104   DECLARE_READ8_MEMBER(scramblb_protection_1_r);
106105   DECLARE_READ8_MEMBER(scramblb_protection_2_r);
107106   DECLARE_WRITE8_MEMBER(_4in1_bank_w);
108   DECLARE_READ8_MEMBER(checkmaj_protection_r);
109   DECLARE_READ8_MEMBER(dingo_3000_r);
110   DECLARE_READ8_MEMBER(dingo_3035_r);
111   DECLARE_READ8_MEMBER(dingoe_3001_r);
112107   DECLARE_WRITE8_MEMBER(racknrol_tiles_bank_w);
113108   DECLARE_WRITE8_MEMBER(galaxold_videoram_w);
114109   DECLARE_READ8_MEMBER(galaxold_videoram_r);
r26338r26339
244239   void bagmanmc_modify_charcode(UINT16 *code, UINT8 x);
245240   void bagmanmc_modify_spritecode(UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs);
246241   void machine_reset_common(int line);
247   UINT8 decode_mooncrst(UINT8 data,offs_t addr);
248242   required_device<cpu_device> m_maincpu;
249243   optional_device<cpu_device> m_audiocpu;
250244};

Previous 199869 Revisions Next


© 1997-2024 The MAME Team