trunk/src/mame/machine/neoprot.c
| r23713 | r23714 | |
| 487 | 487 | mslug5, svcchaos, kof2003 |
| 488 | 488 | ***************************************************************/ |
| 489 | 489 | |
| 490 | | void neogeo_state::pvc_w8(offs_t offset, UINT8 data ) |
| 490 | void neogeo_state::pvc_write_unpack_color() |
| 491 | 491 | { |
| 492 | | *(((UINT8*)m_pvc_cartridge_ram) + BYTE_XOR_LE(offset)) = data; |
| 493 | | } |
| 492 | UINT16 pen = m_pvc_cartridge_ram[0xff0]; |
| 494 | 493 | |
| 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; |
| 495 | 498 | |
| 496 | | UINT8 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; |
| 499 | 501 | } |
| 500 | 502 | |
| 501 | 503 | |
| 502 | | void neogeo_state::pvc_prot1() |
| 504 | void neogeo_state::pvc_write_pack_color() |
| 503 | 505 | { |
| 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; |
| 505 | 510 | |
| 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); |
| 512 | 518 | } |
| 513 | 519 | |
| 514 | 520 | |
| 515 | | void 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 | | |
| 528 | 521 | void neogeo_state::pvc_write_bankswitch( address_space &space ) |
| 529 | 522 | { |
| 530 | 523 | UINT32 bankaddress; |
| 531 | 524 | |
| 532 | 525 | 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; |
| 536 | 528 | neogeo_set_main_cpu_bank_address(bankaddress + 0x100000); |
| 537 | 529 | } |
| 538 | 530 | |
| r23713 | r23714 | |
| 547 | 539 | { |
| 548 | 540 | COMBINE_DATA(&m_pvc_cartridge_ram[offset] ); |
| 549 | 541 | if (offset == 0xff0) |
| 550 | | pvc_prot1(); |
| 542 | pvc_write_unpack_color(); |
| 551 | 543 | else if(offset >= 0xff4 && offset <= 0xff5) |
| 552 | | pvc_prot2(); |
| 544 | pvc_write_pack_color(); |
| 553 | 545 | else if(offset >= 0xff8) |
| 554 | 546 | pvc_write_bankswitch(space); |
| 555 | 547 | } |
trunk/src/mame/includes/neogeo.h
| r23713 | r23714 | |
| 360 | 360 | void garouh_install_protection(); |
| 361 | 361 | void mslug3_install_protection(); |
| 362 | 362 | 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(); |
| 367 | 365 | void pvc_write_bankswitch( address_space &space ); |
| 368 | 366 | DECLARE_READ16_MEMBER( pvc_prot_r ); |
| 369 | 367 | DECLARE_WRITE16_MEMBER( pvc_prot_w ); |