Previous 199869 Revisions Next

r23714 Saturday 15th June, 2013 at 02:03:43 UTC by Alex Jackson
neogeo: clean up PVC protection. [Alex Jackson]
[src/mame/includes]neogeo.h
[src/mame/machine]neoprot.c

trunk/src/mame/machine/neoprot.c
r23713r23714
487487  mslug5, svcchaos, kof2003
488488***************************************************************/
489489
490void neogeo_state::pvc_w8(offs_t offset, UINT8 data )
490void neogeo_state::pvc_write_unpack_color()
491491{
492   *(((UINT8*)m_pvc_cartridge_ram) + BYTE_XOR_LE(offset)) = data;
493}
492   UINT16 pen = m_pvc_cartridge_ram[0xff0];
494493
494   UINT8 b = ((pen & 0x000f) << 1) | ((pen & 0x1000) >> 12);
495   UINT8 g = ((pen & 0x00f0) >> 3) | ((pen & 0x2000) >> 13);
496   UINT8 r = ((pen & 0x0f00) >> 7) | ((pen & 0x4000) >> 14);
497   UINT8 s = (pen & 0x8000) >> 15;
495498
496UINT8 neogeo_state::pvc_r8(offs_t offset )
497{
498   return *(((UINT8*)m_pvc_cartridge_ram) + BYTE_XOR_LE(offset));
499   m_pvc_cartridge_ram[0xff1] = (g << 8) | b;
500   m_pvc_cartridge_ram[0xff2] = (s << 8) | r;
499501}
500502
501503
502void neogeo_state::pvc_prot1()
504void neogeo_state::pvc_write_pack_color()
503505{
504   UINT8 b1, b2;
506   UINT8 b = m_pvc_cartridge_ram[0xff4] & 0xff;
507   UINT8 g = m_pvc_cartridge_ram[0xff4] >> 8;
508   UINT8 r = m_pvc_cartridge_ram[0xff5] & 0xff;
509   UINT8 s = m_pvc_cartridge_ram[0xff5] >> 8;
505510
506   b1 = pvc_r8(0x1fe1);
507   b2 = pvc_r8(0x1fe0);
508   pvc_w8(0x1fe2, (((b2 >> 0) & 0xf) << 1) | ((b1 >> 4) & 1));
509   pvc_w8(0x1fe3, (((b2 >> 4) & 0xf) << 1) | ((b1 >> 5) & 1));
510   pvc_w8(0x1fe4, (((b1 >> 0) & 0xf) << 1) | ((b1 >> 6) & 1));
511   pvc_w8(0x1fe5, (b1 >> 7));
511   m_pvc_cartridge_ram[0xff6] = (b >> 1) |
512                        ((g >> 1) << 4) |
513                        ((r >> 1) << 8) |
514                        ((b & 1) << 12) |
515                        ((g & 1) << 13) |
516                        ((r & 1) << 14) |
517                        ((s & 1) << 15);
512518}
513519
514520
515void neogeo_state::pvc_prot2() // on writes to e8/e9/ea/eb
516{
517   UINT8 b1, b2, b3, b4;
518
519   b1 = pvc_r8(0x1fe9);
520   b2 = pvc_r8(0x1fe8);
521   b3 = pvc_r8(0x1feb);
522   b4 = pvc_r8(0x1fea);
523   pvc_w8(0x1fec, (b2 >> 1) | ((b1 >> 1) << 4));
524   pvc_w8(0x1fed, (b4 >> 1) | ((b2 & 1) << 4) | ((b1 & 1) << 5) | ((b4 & 1) << 6) | ((b3 & 1) << 7));
525}
526
527
528521void neogeo_state::pvc_write_bankswitch( address_space &space )
529522{
530523   UINT32 bankaddress;
531524
532525   bankaddress = ((m_pvc_cartridge_ram[0xff8] >> 8)|(m_pvc_cartridge_ram[0xff9] << 8));
533   *(((UINT8 *)m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff0)) = 0xa0;
534   *(((UINT8 *)m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff1)) &= 0xfe;
535   *(((UINT8 *)m_pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff3)) &= 0x7f;
526   m_pvc_cartridge_ram[0xff8] = (m_pvc_cartridge_ram[0xff8] & 0xfe00) | 0x00a0;
527   m_pvc_cartridge_ram[0xff9] &= 0x7fff;
536528   neogeo_set_main_cpu_bank_address(bankaddress + 0x100000);
537529}
538530
r23713r23714
547539{
548540   COMBINE_DATA(&m_pvc_cartridge_ram[offset] );
549541   if (offset == 0xff0)
550      pvc_prot1();
542      pvc_write_unpack_color();
551543   else if(offset >= 0xff4 && offset <= 0xff5)
552      pvc_prot2();
544      pvc_write_pack_color();
553545   else if(offset >= 0xff8)
554546      pvc_write_bankswitch(space);
555547}
trunk/src/mame/includes/neogeo.h
r23713r23714
360360   void garouh_install_protection();
361361   void mslug3_install_protection();
362362   void kof2000_install_protection();
363   void pvc_w8( offs_t offset, UINT8 data );
364   UINT8 pvc_r8( offs_t offset );
365   void pvc_prot1();
366   void pvc_prot2(); // on writes to e8/e9/ea/eb
363   void pvc_write_unpack_color();
364   void pvc_write_pack_color();
367365   void pvc_write_bankswitch( address_space &space );
368366   DECLARE_READ16_MEMBER( pvc_prot_r );
369367   DECLARE_WRITE16_MEMBER( pvc_prot_w );

Previous 199869 Revisions Next


© 1997-2024 The MAME Team