Here's a port of BMS888's fantastic pvc bankswitch code.
// thanks to BMS888 and Halrin for much of this code
// MAME port by IQ_132 - neosource.1emu.net
static unsigned short CartRAM[0x1000];
void pvc_w8(unsigned int offset, unsigned char data)
{
*(((unsigned char*)CartRAM)+offset)=data;
}
unsigned char pvc_r8(unsigned int offset)
{
return *(((unsigned char*)CartRAM)+offset);
}
// These perform some palette calculations
// Unpack palette word to RGB dword
void pvc_prot1( void ) // on writes to e0/e1
{
unsigned char b1, b2;
b1 = pvc_r8(0x1fe1);
b2 = pvc_r8(0x1fe0);
pvc_w8(0x1fe2,(((b2>>0)&0xf)<<1)|((b1>>4)&1));
pvc_w8(0x1fe3,(((b2>>4)&0xf)<<1)|((b1>>5)&1));
pvc_w8(0x1fe4,(((b1>>0)&0xf)<<1)|((b1>>6)&1));
pvc_w8(0x1fe5, (b1>>7));
}
// Pack RGB dword to palette word
void pvc_prot2( void ) // on writes to e8/e9/ea/eb
{
unsigned char b1, b2, b3, b4;
b1 = pvc_r8(0x1fe9);
b2 = pvc_r8(0x1fe8);
b3 = pvc_r8(0x1feb);
b4 = pvc_r8(0x1fea);
pvc_w8(0x1fec,(b2>>1)|((b1>>1)<<4));
pvc_w8(0x1fed,(b4>>1)|((b2&1)<<4)|((b1&1)<<5)|((b4&1)<<6)|((b3&1)<<7));
}
void pvc_write_bankswitch( void )
{
UINT32 bankaddress;
bankaddress = ((CartRAM[0xff8]>>8)|(CartRAM[0xff9]<<8));
*(((unsigned char *)CartRAM) + 0x1ff0) = 0xA0;
*(((unsigned char *)CartRAM) + 0x1ff1) &= 0xFE;
*(((unsigned char *)CartRAM) + 0x1ff3) &= 0x7F;
neogeo_set_cpu1_second_bank(bankaddress+0x100000);
}
static READ16_HANDLER( pvc_prot_r )
{
return CartRAM[ offset ];
}
static WRITE16_HANDLER( pvc_prot_w )
{
COMBINE_DATA( &CartRAM[ offset ] );
if (offset == 0xFF0)pvc_prot1();
else if(offset >= 0xFF4 && offset <= 0xFF5)pvc_prot2();
else if(offset >= 0xFF8)pvc_write_bankswitch();
}
for kof2003, use this init:
DRIVER_INIT( kof2003 )
{
kof2003_px_decrypt();
kof2003_sx_decrypt();
kof2003_vx_decrypt();
neogeo_fix_bank_type = 2;
init_neogeo();
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_r);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_w);
memory_install_read16_handler( 0, ADDRESS_SPACE_PROGRAM, 0xc00000, 0xc3ffff, 0, 0, MRA16_BANK3 ); // 256k bios
}
for kof2003b:
static READ16_HANDLER( kof2003b_prot_r )
{
return CartRAM[0xff9];
}
DRIVER_INIT( kof2003b )
{
kof2003b_px_decrypt();
kof2003b_sx_decrypt();
init_neogeo();
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_r);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_w);
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x058196, 0x058197, 0, 0, kof2003b_prot_r);
}
DRIVER_INIT( kof2k3up )
{
kof2003b_px_decrypt();
kof2k3up_px_decrypt();
kof2k3up_sx_decrypt();
init_neogeo();
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_r);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_w);
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x058196, 0x058197, 0, 0, kof2003b_prot_r);
}
DRIVER_INIT( svcchaos )
{
svcchaos_px_decrypt();
svcchaos_gfx_decrypt();
svcchaos_vx_decrypt();
neogeo_fix_bank_type = 2;
init_neogeo();
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_r);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_w);
}
DRIVER_INIT( svchaosa )
{
svcchaos_px_decrypt();
kof2000_neogeo_gfx_decrypt(0x57);
svcchaos_vx_decrypt();
neogeo_fix_bank_type = 2;
init_neogeo();
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_r);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_w);
}
DRIVER_INIT( svcboot )
{
svcboot_px_decrypt();
svcboot_cx_decrypt();
init_neogeo();
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_r);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_w);
}
DRIVER_INIT( svcsplus )
{
svcsplus_px_decrypt();
svcsplus_sx_decrypt();
svcboot_cx_decrypt();
svcsplus_px_hack();
init_neogeo();
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_r);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_w);
}
DRIVER_INIT( mslug5 )
{
mslug5_px_decrypt();
mslug5_vx_decrypt();
neogeo_fix_bank_type = 1;
kof2000_neogeo_gfx_decrypt(0x19);
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_r);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_w);
init_neogeo();
}