Try this James:
static void svcchaos_gfx_decrypt( void )
{
const unsigned char xor1[ 4 ] = {
0x34, 0x21, 0xc4, 0xe9,
};
int i;
int ofst;
UINT8 *s1 = memory_region( REGION_GFX1 ); // Moved this to the top
size_t s1_size = memory_region_length( REGION_GFX1 ); // Moved
UINT8 *src = memory_region( REGION_GFX3 );
int len = memory_region_length( REGION_GFX3 );
UINT8 *dst = malloc( len );
for( i = 0; i < len; i++ ){
src[ i ] ^= xor1[ (i % 4) ];
}
for( i = 0; i < len; i += 4 ){
UINT32 *src32 = (UINT32*)&src[ i ];
*src32 = BITSWAP32( *src32, 0x09, 0x0d, 0x13, 0x00, 0x17, 0x0f, 0x03, 0x05,
0x04, 0x0c, 0x11, 0x1e, 0x12, 0x15, 0x0b, 0x06,
0x1b, 0x0a, 0x1a, 0x1c, 0x14, 0x02, 0x0e, 0x1d,
0x18, 0x08, 0x01, 0x10, 0x19, 0x1f, 0x07, 0x16 );
}
memcpy( dst, src, len );
for( i = 0; i < len / 4; i++ ){
ofst = BITSWAP24( (i & 0x1fffff), 0x17, 0x16, 0x15, 0x04, 0x0b, 0x0e, 0x08, 0x0c,
0x10, 0x00, 0x0a, 0x13, 0x03, 0x06, 0x02, 0x07,
0x0d, 0x01, 0x11, 0x09, 0x14, 0x0f, 0x12, 0x05 );
ofst ^= 0x0c8923;
ofst += (i & 0xffe00000);
memcpy( &src[ i * 4 ], &dst[ ofst * 4 ], 0x04 );
}
free( dst );
kof2000_neogeo_gfx_decrypt(0x57);
for( i = 0; i < s1_size; i++ ){
s1[ i ] = BITSWAP8( s1[ i ] ^ 0xd2, 4, 0, 7, 2, 5, 1, 6, 3 );
}
}