A couple of sections out of my neogeo.c file, in case you don't want to look through the entire thing. But I'm afraid that I probably didn't cut & paste whatever is actually causing the problem; since I'm not familiar enough with the INIT section to really know what it all means and what does what.
static void kof2003_px_decrypt( void )
{
const unsigned char xor2[ 0x20 ] = {
0xb4, 0x0f, 0x40, 0x6c, 0x38, 0x07, 0xd0, 0x3f, 0x53, 0x08, 0x80, 0xaa, 0xbe, 0x07, 0xc0, 0xfa,
0xd0, 0x08, 0x10, 0xd2, 0xf1, 0x03, 0x70, 0x7e, 0x87, 0x0B, 0x40, 0xf6, 0x2a, 0x0a, 0xe0, 0xf9
};
int i;
int ofst;
UINT8 *rom, *buf;
rom = memory_region( REGION_CPU1 );
for( i = 0x100000; i < 0x800000; i++ ){
rom[ i ] ^= xor2[ (i % 0x20) ];
}
for( i = 0x100000; i < 0x800000; i += 4 ){
UINT16 *rom16 = (UINT16*)&rom[ i + 1 ];
*rom16 = BITSWAP16( *rom16, 15, 14, 13, 12, 4, 5, 6, 7, 8, 9, 10, 11, 3, 2, 1, 0 );
}
buf = malloc( 0x800000 );
memcpy( buf, rom, 0x800000 );
for( i = 0; i < 0x0100000 / 0x10000; i++ ){
ofst = (i & 0xf0) + BITSWAP8( (i & 0x0f), 7, 6, 5, 4, 1, 0, 3, 2 );
memcpy( &rom[ i * 0x10000 ], &buf[ ofst * 0x10000 ], 0x10000 );
}
for( i = 0x100000; i < 0x800000; i += 0x100 ){
ofst = (i & 0xf000ff) +
((i & 0x000f00) ^ 0x00300) +
(BITSWAP8( ((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2 ) << 12);
memcpy( &rom[ i ], &buf[ ofst ], 0x100 );
}
free( buf );
buf = malloc(0x900000);
memcpy( buf, rom, 0x900000 );
memcpy( &rom[0x100000], &buf[0x800000], 0x100000 );
memcpy( &rom[0x200000], &buf[0x100000], 0x700000 );
free(buf);
}
static void kof2003_sx_decrypt( void )
{
int i;
int tx_size = memory_region_length( REGION_GFX1 );
int rom_size = memory_region_length( REGION_GFX3 );
UINT8 *src;
UINT8 *dst;
src = memory_region( REGION_GFX3 ) + rom_size - 0x1000000 - 0x80000;
dst = memory_region( REGION_GFX1 );
for( i = 0; i < tx_size / 2; i++ ){
dst[ i ] = src[ (i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4) ];
}
src = memory_region( REGION_GFX3 ) + rom_size - 0x80000;
dst = memory_region( REGION_GFX1 ) + 0x80000;
for( i = 0; i < tx_size / 2; i++ ){
dst[ i ] = src[ (i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4) ];
}
dst = memory_region( REGION_GFX1 );
for( i = 0; i < tx_size; i++ ){
dst[ i ] = BITSWAP8( dst[ i ] ^ 0xd2, 4, 0, 7, 2, 5, 1, 6, 3 );
}
}
static UINT16 mv0_prot_offset[ 0x08 ];
static UINT16 mv0_bankswitch_offset[ 2 ];
static int mv0_bankswitch_flg;
static READ16_HANDLER( mv0_prot_r )
{
return mv0_prot_offset[ offset ];
}
static WRITE16_HANDLER( mv0_prot_w )
{
mv0_prot_offset[ offset ] = (mv0_prot_offset[ offset ] & mem_mask) | ((~mem_mask) & data);
if( offset == 0 ){
UINT8 *ofst8 = (UINT8*)mv0_prot_offset;
ofst8[ 0x02 ] = ((ofst8[ 0x01 ] >> 4) & 0x01) + ((ofst8[ 0x00 ] & 0x0f) << 1);
ofst8[ 0x03 ] = ((ofst8[ 0x01 ] >> 5) & 0x01) + (((ofst8[ 0x00 ] >> 4) & 0x0f) << 1);
ofst8[ 0x04 ] = ((ofst8[ 0x01 ] >> 6) & 0x01) + ((ofst8[ 0x01 ] & 0x0f) << 1);
ofst8[ 0x05 ] = (ofst8[ 0x01 ] >> 7);
}else if( offset == 5 ){
UINT8 *ofst8 = (UINT8*)mv0_prot_offset;
ofst8[ 0x0c ] = (ofst8[ 0x08 ] >> 1) | ((ofst8[ 0x09 ] >> 1) << 4);
ofst8[ 0x0d ] = (ofst8[ 0x0a ] >> 1) |
((ofst8[ 0x08 ] & 0x01) << 4) |
((ofst8[ 0x09 ] & 0x01) << 5) |
((ofst8[ 0x0a ] & 0x01) << 6) |
(ofst8[ 0x0b ] << 7);
}
}
// imcomplete
static READ16_HANDLER( mv0_bankswitch_r )
{
if( mv0_bankswitch_offset[ 0 ] == 0xffff && mv0_bankswitch_offset[ 1 ] == 0xffff ){
mv0_bankswitch_flg = 1;
if( offset == 0 ){
return 0xfea0;
}else if( offset == 1 ){
return 0x7fff;
}else{
return mv0_bankswitch_offset[ offset ];
}
}else if( mv0_bankswitch_offset[ 0 ] == 0x0000 && mv0_bankswitch_offset[ 1 ] == 0x0000 && mv0_bankswitch_flg == 1 ){
if( offset == 0 ){
return 0x00a0;
}else if( offset == 1 ){
mv0_bankswitch_flg = 0;
return 0x0000;
}else{
return mv0_bankswitch_offset[ offset ];
}
}else{
return mv0_bankswitch_offset[ offset ];
}
}
static WRITE16_HANDLER( mv0_bankswitch_w )
{
UINT32 bank_addr;
mv0_bankswitch_offset[ offset ] = (mv0_bankswitch_offset[ offset ] & mem_mask) | ((~mem_mask) & data);
bank_addr = (mv0_bankswitch_offset[ 0 ] >> 8) +
(mv0_bankswitch_offset[ 1 ] << 8) +
0x100000;
neogeo_set_cpu1_second_bank( bank_addr );
}
static void svcchaos_px_decrypt( void )
{
const unsigned char xor1[ 0x20 ] = {
0x3b, 0x6a, 0xf7, 0xb7, 0xe8, 0xa9, 0x20, 0x99, 0x9f, 0x39, 0x34, 0x0c, 0xc3, 0x9a, 0xa5, 0xc8,
0xb8, 0x18, 0xce, 0x56, 0x94, 0x44, 0xe3, 0x7a, 0xf7, 0xdd, 0x42, 0xf0, 0x18, 0x60, 0x92, 0x9f,
};
const unsigned char xor2[ 0x20 ] = {
0x69, 0x0b, 0x60, 0xd6, 0x4f, 0x01, 0x40, 0x1a, 0x9f, 0x0b, 0xf0, 0x75, 0x58, 0x0e, 0x60, 0xb4,
0x14, 0x04, 0x20, 0xe4, 0xb9, 0x0d, 0x10, 0x89, 0xeb, 0x07, 0x30, 0x90, 0x50, 0x0e, 0x20, 0x26,
};
int i;
int ofst;
UINT8 *rom, *buf;
rom = memory_region( REGION_CPU1 );
for( i = 0; i < 0x100000; i++ ){
rom[ i ] ^= xor1[ (i % 0x20) ];
}
for( i = 0x100000; i < 0x800000; i++ ){
rom[ i ] ^= xor2[ (i % 0x20) ];
}
for( i = 0x100000; i < 0x800000; i += 4 ){
UINT16 *rom16 = (UINT16*)&rom[ i + 1 ];
*rom16 = BITSWAP16( *rom16, 15, 14, 13, 12, 10, 11, 8, 9, 6, 7, 4, 5, 3, 2, 1, 0 );
}
buf = malloc( 0x800000 );
memcpy( buf, rom, 0x800000 );
for( i = 0; i < 0x0100000 / 0x10000; i++ ){
ofst = (i & 0xf0) + BITSWAP8( (i & 0x0f), 7, 6, 5, 4, 2, 3, 0, 1 );
memcpy( &rom[ i * 0x10000 ], &buf[ ofst * 0x10000 ], 0x10000 );
}
for( i = 0x100000; i < 0x800000; i += 0x100 ){
ofst = (i & 0xf000ff) +
((i & 0x000f00) ^ 0x00a00) +
(BITSWAP8( ((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2 ) << 12);
memcpy( &rom[ i ], &buf[ ofst ], 0x100 );
}
free( buf );
buf = malloc( 0x800000 );
memcpy( buf, rom, 0x800000 );
memcpy( &rom[ 0x100000 ], &buf[ 0x700000 ], 0x100000 );
memcpy( &rom[ 0x200000 ], &buf[ 0x100000 ], 0x600000 );
free( buf );
}
DRIVER_INIT( kof2003 )
{
kof2003_px_decrypt();
kof2003_sx_decrypt();
neogeo_fix_bank_type = 2;
init_neogeo();
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, MRA16_RAM );
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, MWA16_RAM );
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fffe0, 0x2fffef, 0, 0, mv0_prot_r );
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fffe0, 0x2fffef, 0, 0, mv0_prot_w );
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2ffff0, 0x2ffff3, 0, 0, mv0_bankswitch_r );
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2ffff0, 0x2ffff3, 0, 0, mv0_bankswitch_w );
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0xc00000, 0xc3ffff, 0, 0, MRA16_BANK3 ); // 256k bios
}