Jump to content

Adding games


Robert

Recommended Posts

Now that I've gotten the hang of compiling, I'd like to add some games.

Is it just a matter of adding a line to drivers.c and adding that other stuff to neogeo.c ?

 

I'm going to give it a go anyways and see what happens.

Link to comment
Share on other sites

  • Replies 70
  • Created
  • Last Reply

Top Posters In This Topic

And were you adding Encrypted or Decrypted sets ?.

And what games did you add ?. and did you know I already posted drivers here ? http://www.1emulation.com/forums/index.php?showtopic=10562

 

If they were only decrypted sets then you have lot more to do :lol:

 

I have added code to drivers.c drivers\neogeo.c machine\neogeo.c machine\neocrypt.c and thats just the neogeo games.

Link to comment
Share on other sites

I've added these sets:

bangbedp, digerman, neopong,

mslug5, mslug5a, mslug5nd,

matrimbl, pnyaa, samsho5, samsh5bl,

svcboot, svcsplus, svcplus,

svcplusa, svcchaos, svchaosa,

kof2003, kof2003a, kof2003b,

kof2k4ex, kf2k4spe, kof2k4se,

kof2k3up, kof10th

 

As to what is encrypted or not, I have no idea.

I just followed the instructions.

 

Modifications were done to driver.c, drivers\neogeo.c, common.h

 

bangbedp is already in mame, just had to be commented back in and added to driver.c

I found 2 mslug5 drivers that were completely different,

so one has been renamed to mslug5a until I know which one is the right one.

 

I only discovered your thread after I'd already gotten your stuff from a@h, I figured they are probably the same.

Link to comment
Share on other sites

decrypted sets are easier to add than encrypted sets IMO

Yes true for some :ph34r: . But I rather encrypted sets

 

 

 

I've added these sets:

bangbedp, digerman, neopong,

mslug5, mslug5a, mslug5nd,

matrimbl, pnyaa, samsho5, samsh5bl,

svcboot, svcsplus, svcplus,

svcplusa, svcchaos, svchaosa,

kof2003, kof2003a, kof2003b,

kof2k4ex, kf2k4spe, kof2k4se,

kof2k3up, kof10th

 

As to what is encrypted or not, I have no idea.

I just followed the instructions.

 

Modifications were done to driver.c, drivers\neogeo.c, common.h

 

bangbedp is already in mame, just had to be commented back in and added to driver.c

I found 2 mslug5 drivers that were completely different,

so one has been renamed to mslug5a until I know which one is the right one.

 

I only discovered your thread after I'd already gotten your stuff from a@h, I figured they are probably the same.

 

 

 

You no longer need to add code to common.h since that code is now offically supported.

Link to comment
Share on other sites

I decided I was being a bit ambitious, so I removed everything, applied the 101u4 patch, and added back in only

 

bangbedp, pnyaa, mslug5, mslug5a, mslug5nd

 

and compiled again. The errors I got this time were:

 

src/drivers/neogeo.c: In function `mv0_bankswitch_w':

src/drivers/neogeo.c:6894: warning: ISO C90 forbids mixed declarations and code

src/drivers/neogeo.c: In function `ms5plus_bankswitch_w':

src/drivers/neogeo.c:6902: warning: ISO C90 forbids mixed declarations and code

src/drivers/neogeo.c: In function `mslug5_vx_decrypt':

src/drivers/neogeo.c:6979: error: 'for' loop initial declaration used outside C99 mode

 

Then I got rid of the mslug5 routines and replaced them with your ones. Now I'm compiling again.

Link to comment
Share on other sites

Some of the code was changed I will post all the init here and you can pick the ones you need

 

 

/* Clone Mame Extra Games Code  */
DRIVER_INIT( kof2002 )
{
int i;
unsigned int sec[]={0x100000,0x280000,0x300000,0x180000,0x000000,0x380000,0x200000,0x080000};
UINT8 *src = memory_region(REGION_CPU1)+0x100000;
UINT8 *dst = malloc(0x400000);
if (dst)
{
  memcpy( dst, src, 0x400000 );
  for( i=0; i<8; ++i )
  {
   memcpy( src+i*0x80000, dst+sec[i], 0x80000 );
  }
free(dst);
}

neo_pcm2_playmore_2002(0); // kof2002

neogeo_fix_bank_type = 0;
kof2000_neogeo_gfx_decrypt(0xec);

init_neogeo();
}

DRIVER_INIT( samsho5 )
{
/* Descrambling P ROMs */
UINT8 *src = memory_region(REGION_CPU1);
UINT8 *dst = malloc(0x800000);
int i;
unsigned int sec[]={0x000000, 0x080000, 0x700000, 0x680000, 0x500000, 0x180000, 0x200000, 0x480000, 0x300000, 0x780000, 0x600000, 0x280000, 0x100000, 0x580000, 0x400000, 0x380000};
if (dst)
{
  memcpy(dst,src,0x800000);

  for(i=0;i<16;++i)
  {
   memcpy(src+i*0x80000,dst+sec[i],0x80000);
  }
  free(dst);
}
neogeo_fix_bank_type = 1;
kof2000_neogeo_gfx_decrypt(0x0f);
neo_pcm2_playmore_2002(3); // samsho5
init_neogeo();
}

DRIVER_INIT( samsh5nd )
{
/* Descrambling P ROMs */
UINT8 *src = memory_region(REGION_CPU1);
UINT8 *dst = malloc(0x800000);
int i;
unsigned int sec[]={0x000000, 0x080000, 0x700000, 0x680000, 0x500000, 0x180000, 0x200000, 0x480000, 0x300000, 0x780000, 0x600000, 0x280000, 0x100000, 0x580000, 0x400000, 0x380000};
if (dst)
{
  memcpy(dst,src,0x800000);

  for(i=0;i<16;++i)
  {
   memcpy(src+i*0x80000,dst+sec[i],0x80000);
  }
  free(dst);
}
init_neogeo();
}

DRIVER_INIT( samsh5sp )
{
/* Descrambling Px by Vorador from speksnk Converted to Mame code by James */
UINT8 *src = memory_region(REGION_CPU1);
UINT8 *dst = malloc(0x800000);
int i;
unsigned int sec[]={0x0,0x1,0xA,0x9,0xC,0xB,0xE,0x5,0x2,0xD,0x8,0xF,0x4,0x7,0x6,0x3};
if (dst)
{
  memcpy(dst,src,0x800000);

  for(i=0;i<0x10;i++)
  {
   memcpy(src+i*0x80000,dst+sec[i]*0x80000,0x80000);
  }
  free(dst);
}
neogeo_fix_bank_type = 1;
kof2000_neogeo_gfx_decrypt(0x0d);
neo_pcm2_playmore_2002(6); // samsh5sp
init_neogeo();
}

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 );
}
}

DRIVER_INIT( kof2003 )
{
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);
kof2003_sx_decrypt();

neogeo_fix_bank_type = 2;
neo_pcm2_playmore_2002(5); // Kof2003
init_neogeo();
}

DRIVER_INIT( kof2003a )
{
kof2003_sx_decrypt();
neogeo_fix_bank_type = 2;
init_neogeo();
}

DRIVER_INIT( kof2003p )
{
neogeo_fix_bank_type = 2;
init_neogeo();
}

DRIVER_INIT( pnyaa )
{
neogeo_fix_bank_type = 1;
kof2000_neogeo_gfx_decrypt(0x2e);
neo_pcm2_snk_1999(4);
init_neogeo();
}

DRIVER_INIT( matrim )
{
UINT8 *src = memory_region(REGION_CPU1)+0x100000;
UINT8 *dst = malloc(0x400000);
int i;
unsigned int sec[]={0x100000,0x280000,0x300000,0x180000,0x000000,0x380000,0x200000,0x080000};

if (dst)
{
  memcpy(dst,src,0x400000);

  for(i=0;i<8;++i)
  {
   memcpy(src+i*0x80000,dst+sec[i],0x80000);
  }
  free(dst);
}

neogeo_fix_bank_type = 2;
kof2000_neogeo_gfx_decrypt(0x6a);
neo_pcm2_playmore_2002(1); // Matrim
init_neogeo();
}

DRIVER_INIT( matrimnd )
{
UINT8 *src = memory_region(REGION_CPU1)+0x100000;
UINT8 *dst = malloc(0x400000);
int i;
unsigned int sec[]={0x100000,0x280000,0x300000,0x180000,0x000000,0x380000,0x200000,0x080000};

if (dst)
{
  memcpy(dst,src,0x400000);

  for(i=0;i<8;++i)
  {
   memcpy(src+i*0x80000,dst+sec[i],0x80000);
  }
  free(dst);
}

neogeo_fix_bank_type = 2;

/* the S data comes from the end of the C data */
{
  
  int i;
  int tx_size = memory_region_length(REGION_GFX1);
  int rom_size = memory_region_length(REGION_GFX3);
  UINT8 *src = memory_region(REGION_GFX3)+rom_size-tx_size;
  UINT8 *dst = memory_region(REGION_GFX1);

  for (i = 0;i < tx_size;i++)
  dst[i] = src[(i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4)];
}
neo_pcm2_playmore_2002(1); // Matrim
init_neogeo();
}

/* descrambling information from razoola */
static void matrimbl_neogeo_gfx_address_fix_do(int start, int end, int bit3shift, int bit2shift, int bit1shift, int bit0shift)
{
int i,j;
int tilesize=128;

UINT8* rom = (UINT8*)malloc(16*tilesize);	// 16 tiles buffer
UINT8* realrom = memory_region(REGION_GFX3) + start*tilesize;

for (i = 0; i < (end-start)/16; i++) {
  for (j = 0; j < 16; j++) {
   int offset = (((j&1)>>0)<<bit0shift)
            +(((j&2)>>1)<<bit1shift)
            +(((j&4)>>2)<<bit2shift)
      +(((j&8)>>3)<<bit3shift);

   memcpy(rom+j*tilesize, realrom+offset*tilesize, tilesize);
  }
  memcpy(realrom,rom,tilesize*16);
  realrom+=16*tilesize;
}
free(rom);
}

static void matrimbl_neogeo_gfx_address_fix(int start, int end)
{
matrimbl_neogeo_gfx_address_fix_do(start+512*0, end+512*0, 0,3,2,1);
matrimbl_neogeo_gfx_address_fix_do(start+512*1, end+512*1, 1,0,3,2);
matrimbl_neogeo_gfx_address_fix_do(start+512*2, end+512*2, 2,1,0,3);
// skip 3 & 4
matrimbl_neogeo_gfx_address_fix_do(start+512*5, end+512*5, 0,1,2,3);
matrimbl_neogeo_gfx_address_fix_do(start+512*6, end+512*6, 0,1,2,3);
matrimbl_neogeo_gfx_address_fix_do(start+512*7, end+512*7, 0,2,3,1);
}

static void matrimbl_c(int pow)
{
int i;

for (i=0; i<=192; i+=8)
  matrimbl_neogeo_gfx_address_fix(i*512,i*512+512);

for (i=200; i<=392; i+=8)
  matrimbl_neogeo_gfx_address_fix(i*512,i*512+512);

for (i=400; i<=592; i+=8)
  matrimbl_neogeo_gfx_address_fix(i*512,i*512+512);

for (i=600; i<=792; i+=8)
  matrimbl_neogeo_gfx_address_fix(i*512,i*512+512);

for (i=800; i<=992; i+=8)
  matrimbl_neogeo_gfx_address_fix(i*512,i*512+512);

for (i=1000; i<=1016; i+=8)
  matrimbl_neogeo_gfx_address_fix(i*512,i*512+512);
}

#define MATRIMBLFIX(i) (i^(BITSWAP8(i&0x3,4,3,1,2,0,7,6,5)<<8))

DRIVER_INIT( matrimbl )
{
UINT8 *src = memory_region(REGION_CPU1)+0x100000;
UINT8 *dst = malloc(0x400000);
        int i; int j=0;
        int tx_size = memory_region_length(REGION_GFX1);
        int rom_size = memory_region_length(REGION_GFX3);

unsigned int sec[]={0x100000,0x280000,0x300000,0x180000,0x000000,0x380000,0x200000,0x080000};

if (dst){
  memcpy(dst,src,0x400000);
  for(i=0;i<8;++i){
   memcpy(src+i*0x80000,dst+sec[i],0x80000);
  }
  free(dst);
}
        matrimbl_c(0);
src = memory_region(REGION_GFX3)+rom_size-tx_size;
        dst = memory_region(REGION_GFX1);
        for (i = 0;i < tx_size;i++)
            dst [ i ] = src[(i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4)];

        neogeo_fix_bank_type = 2;
        src = memory_region(REGION_CPU2)+0x10000;
        dst = (UINT8*)malloc(0x20000);
        memcpy(dst,src,0x20000);
        for(i=0x00000;i<0x20000;i++){
           if (i&0x10000){
                 if (i&0x800){
                   j=MATRIMBLFIX(i);
                   j=j^0x10000;
                 }else{
                   j=MATRIMBLFIX((i^0x01));
                 }
           }else{
                 if (i&0x800){
                   j=MATRIMBLFIX((i^0x01));
                   j=j^0x10000;
                 }else{
                   j=MATRIMBLFIX(i);
                 }
           }
          src[j]=dst[i];
        }
  free(dst);
memcpy(src-0x10000,src,0x10000);

init_neogeo();
}


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 );
}

static void svcchaos_gfx_decrypt( void )
{
   const unsigned char xor1[ 4 ] = {
      0x34, 0x21, 0xc4, 0xe9,
   };

   int i;
   int ofst;
   UINT8 *src = memory_region( REGION_GFX3 );
   int len = memory_region_length( REGION_GFX3 );
   UINT8 *dst = malloc( len );
   UINT8 *s1 = memory_region( REGION_GFX1 );
   size_t s1_size = memory_region_length( REGION_GFX1 );

   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 );

   }
}

DRIVER_INIT( svcchaos )
{
neogeo_fix_bank_type = 2;
svcchaos_px_decrypt();
svcchaos_gfx_decrypt();
neo_pcm2_playmore_2002(4); // Svcchaos, Svchaosa
init_neogeo();
}

DRIVER_INIT( svchaosa )
{
svcchaos_px_decrypt();
neo_pcm2_playmore_2002(4); // Svcchaos, Svchaosa
neogeo_fix_bank_type = 2;
kof2000_neogeo_gfx_decrypt(0x57);
init_neogeo();
}

static void svcboot_px_decrypt( void )
{
const unsigned char sec[] = {
  0x06, 0x07, 0x01, 0x02, 0x03, 0x04, 0x05, 0x00
};

int i;
int size = memory_region_length( REGION_CPU1 );
UINT8 *src = memory_region( REGION_CPU1 );
UINT8 *dst = malloc( size );
int ofst;

for( i = 0; i < size / 0x100000; i++ ){
  memcpy( &dst[ i * 0x100000 ], &src[ sec[ i ] * 0x100000 ], 0x100000 );
}

for( i = 0; i < size / 2; i++ ){
  ofst = BITSWAP8( (i & 0x0000ff), 7, 6, 1, 0, 3, 2, 5, 4 );
  ofst += (i & 0xffff00);

  memcpy( &src[ i * 2 ], &dst[ ofst * 2 ], 0x02 );
}

free( dst );
}

static void svcboot_cx_decrypt( void )
{
const unsigned char idx_tbl[ 0x10 ] = {
  0, 1, 0, 1, 2, 3, 2, 3, 3, 4, 3, 4, 4, 5, 4, 5,
};

const unsigned char bitswap4_tbl[ 6 ][ 4 ] = {
  { 3, 0, 1, 2 },
  { 2, 3, 0, 1 },
  { 1, 2, 3, 0 },
  { 0, 1, 2, 3 },
  { 3, 2, 1, 0 },
  { 3, 0, 2, 1 },
};

int i;
int size = memory_region_length( REGION_GFX3 );
UINT8 *src = memory_region( REGION_GFX3 );
UINT8 *dst = malloc( size );
int ofst;

memcpy( dst, src, size );

for( i = 0; i < size / 0x80; i++ ){
  int idx = idx_tbl[ (i & 0xf00) >> 8 ];

  int bit0 = bitswap4_tbl[ idx ][ 0 ];
  int bit1 = bitswap4_tbl[ idx ][ 1 ];
  int bit2 = bitswap4_tbl[ idx ][ 2 ];
  int bit3 = bitswap4_tbl[ idx ][ 3 ];

  ofst = BITSWAP8( (i & 0x0000ff), 7, 6, 5, 4, bit3, bit2, bit1, bit0 );
  ofst += (i & 0xfffff00);

  memcpy( &src[ i * 0x80 ], &dst[ ofst * 0x80 ], 0x80 );
}

free( dst );
}

static void svcplus_px_decrypt( void )
{
int sec[] = {
  0x00, 0x03, 0x02, 0x05, 0x04, 0x01
};

int size = memory_region_length( REGION_CPU1 );
UINT8 *src = memory_region( REGION_CPU1 );
UINT8 *dst = malloc( size );
int i;
int ofst;

memcpy( dst, src, size );

for( i = 0; i < size / 2; i++ ){
  ofst = BITSWAP24( (i & 0xfffff), 0x17, 0x16, 0x15, 0x14, 0x13, 0x00, 0x01, 0x02,
           0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
           0x07, 0x06, 0x05, 0x04, 0x03, 0x10, 0x11, 0x12 );

  ofst ^= 0x0f0007;
  ofst += (i & 0xff00000);

  memcpy( &src[ i * 0x02 ], &dst[ ofst * 0x02 ], 0x02 );
}

memcpy( dst, src, size );

for( i = 0; i < 6; i++ ){
  memcpy( &src[ i * 0x100000 ], &dst[ sec[ i ] * 0x100000 ], 0x100000 );
}

free( dst );
}


static void svcplus_sx_decrypt( void )
{
int i; // move this outside of the "for" loop
int rom_size = memory_region_length( REGION_GFX1 );
UINT8 *rom = memory_region( REGION_GFX1 );
UINT8 *buf = malloc( rom_size );

memcpy( buf, rom, rom_size );

for( i = 0; i < rom_size; i += 0x10 ){ // notice removal of "int i =0"
  memcpy( &rom[ i        ], &buf[ i + 0x08 ], 0x08 );
  memcpy( &rom[ i + 0x08 ], &buf[ i        ], 0x08 );
}

free( buf );
}

static void svcplusa_px_decrypt( void )
{
int sec[] = {
  0x01, 0x02, 0x03, 0x04, 0x05, 0x00
};

int i; // move this outside of the "for" loop
int rom_size = memory_region_length( REGION_CPU1 );
UINT8 *rom = memory_region( REGION_CPU1 );
UINT8 *buf = malloc( rom_size );

memcpy( buf, rom, rom_size );

for( i = 0; i < 6; i++ ){ // notice removal of "int i = 0"
  memcpy( &rom[ i * 0x100000 ], &buf[ sec[ i ] * 0x100000 ], 0x100000 );
}

free( buf );
}

static void svcsplus_px_decrypt( void )
{
int sec[] = {
  0x06, 0x07, 0x01, 0x02, 0x03, 0x04, 0x05, 0x00
};

int size = memory_region_length( REGION_CPU1 );
UINT8 *src = memory_region( REGION_CPU1 );
UINT8 *dst = malloc( size );
int i;
int ofst;

memcpy( dst, src, size );

for (i = 0; i < size / 2; i++ ){
  ofst = BITSWAP16( (i & 0x007fff), 0x0f, 0x00, 0x08, 0x09, 0x0b, 0x0a, 0x0c, 0x0d,
            0x04, 0x03, 0x01, 0x07, 0x06, 0x02, 0x05, 0x0e );

  ofst += (i & 0x078000);
  ofst += sec[ (i & 0xf80000) >> 19 ] << 19;

  memcpy( &src[ i * 2 ], &dst[ ofst * 2 ], 0x02 );
}

free( dst );

}


static void svcsplus_sx_decrypt( void )
{
int i; // move this outside of the "for" loop
UINT8 *rom = memory_region( REGION_GFX1 );
int rom_size = memory_region_length( REGION_GFX1 );

for( i = 0; i < rom_size; i++ ){// notice removal of "int i = 0"
  rom[ i ] = BITSWAP8( rom[ i ], 7, 6, 0, 4, 3, 2, 1, 5 );
}
}

static void svcsplus_px_patch( void )
{	
  UINT16 *prom = (UINT16*)memory_region(REGION_CPU1);
  prom[0x9e90/2] = 0x000f;
  prom[0x9e92/2] = 0xc9c0;
  prom[0xa10c/2] = 0x4eb9;
  prom[0xa10e/2] = 0x000e;
  prom[0xa110/2] = 0x9750;



}

DRIVER_INIT( svcboot )
{
svcboot_px_decrypt();
svcboot_cx_decrypt();

init_neogeo();
}

DRIVER_INIT( svcplus )
{
svcplus_px_decrypt();
svcboot_cx_decrypt();
svcplus_sx_decrypt();

init_neogeo();
}

DRIVER_INIT( svcplusa )
{
svcplusa_px_decrypt();
svcboot_cx_decrypt();

init_neogeo();
}

DRIVER_INIT( svcsplus )
{
svcsplus_px_decrypt();
svcsplus_sx_decrypt();
svcboot_cx_decrypt();
svcsplus_px_patch();

init_neogeo();
}

DRIVER_INIT( svcrmu )
{
neogeo_fix_bank_type = 2;
init_neogeo();
}


static void mslug5_px_decrypt( void )
{
const unsigned char xor1[ 0x20 ] = {
  0xc2, 0x4b, 0x74, 0xfd, 0x0b, 0x34, 0xeb, 0xd7, 0x10, 0x6d, 0xf9, 0xce, 0x5d, 0xd5, 0x61, 0x29,
  0xf5, 0xbe, 0x0d, 0x82, 0x72, 0x45, 0x0f, 0x24, 0xb3, 0x34, 0x1b, 0x99, 0xea, 0x09, 0xf3, 0x03,
};

const unsigned char xor2[ 0x20 ] = {
  0x36, 0x09, 0xb0, 0x64, 0x95, 0x0f, 0x90, 0x42, 0x6e, 0x0f, 0x30, 0xf6, 0xe5, 0x08, 0x30, 0x64,
  0x08, 0x04, 0x00, 0x2f, 0x72, 0x09, 0xa0, 0x13, 0xc9, 0x0b, 0xa0, 0x3e, 0xc2, 0x00, 0x40, 0x2b,
};

int i;
UINT8 *rom, *buf;
int ofst;

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 < 0x0800000; 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, 1, 0, 3, 2 );
  memcpy( &rom[ i * 0x10000 ], &buf[ ofst * 0x10000 ], 0x10000 );
}

for( i = 0x100000; i < 0x800000; i += 0x100 ){
  ofst = (i & 0xf000ff) + 
      ((i & 0x000f00) ^ 0x00700) +
      (BITSWAP8( ((i & 0x0ff000) >> 12), 5, 4, 7, 6, 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( mslug5 )
{
mslug5_px_decrypt();
neo_pcm2_playmore_2002(2); // Mslug5
neogeo_fix_bank_type = 1;
kof2000_neogeo_gfx_decrypt(0x19);
init_neogeo();
}

DRIVER_INIT( mslug5nd )
{
        /* the S data comes from the end of the C data */
        {
                int i;
                int tx_size = memory_region_length(REGION_GFX1);
                int rom_size = memory_region_length(REGION_GFX3);

                UINT8 *src = memory_region(REGION_GFX3)+rom_size-tx_size;
                UINT8 *dst = memory_region(REGION_GFX1);

                for (i = 0;i < tx_size;i++)
                dst[i] = src[(i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4)];
         }

mslug5_px_decrypt();
        init_neogeo();
}

DRIVER_INIT( ms5plus )
{
UINT8 *dst = malloc(0x20000);
UINT8 *roms1 = (memory_region(REGION_GFX1));
int j;

if ( dst )
{
  memcpy(dst,roms1,0x20000);
  for (j=0;j<0x20000; j+=0x000010)
  {
   memcpy( roms1+j, dst+j+0x000008,8);
   memcpy( roms1+j+0x000008, dst+j,8);
                      
  }
}
free( dst );
        
neogeo_fix_bank_type = 1;
        kof2000_neogeo_gfx_decrypt(0x19);
        init_neogeo();
}

DRIVER_INIT( kf2k4spe )
{
int i;
UINT8 *src = memory_region(REGION_CPU1)+0x100000;
UINT8 *dst = malloc(0x400000);
unsigned int sec[] = {0x300000,0x200000,0x100000,0x000000};
if (dst)
{
  memcpy(dst,src,0x400000);

for (i = 0; i < 4; ++i)
  {
   memcpy(src+i*0x100000,dst+sec[i],0x100000);
  }
  free(dst);
}
init_neogeo();
}

/* kof10th Bankswitch */
static UINT16 neogeo_sram16_2[0x2000];

READ16_HANDLER( neogeo_sram16_2_r )
{
return neogeo_sram16_2[offset];
}

WRITE16_HANDLER( neogeo_sram16_2_w )
{
COMBINE_DATA(&neogeo_sram16_2[offset]);
}

DRIVER_INIT( kof10th )
{
int i,j;
UINT16 *prom = (UINT16*)memory_region(REGION_CPU1);
UINT16 *buf  = (UINT16*)malloc(0x800000);
UINT16 *srom = (UINT16*)memory_region(REGION_GFX1);

if (buf){
  memcpy(buf,prom,0x800000);
  for(i=0;i<0x800000/2;i++){
   j=BITSWAP24(i,23,22,21,20,19,18,17,16,15,14,13,12,11,10,1,8,7,6,0,4,3,2,9,5);
   prom[j]=buf[i];
  }
  free(buf);
}

  // get 8x8 tiles from P rom
  // bank 1, game does this on the fly!
  for (i=0;i<0x10000/2;i++){
   srom[i+0x00000/2]=BITSWAP16(prom[i+0x600000/2]^0xf3f3,7,6,0,4,3,2,1,5,15,14,8,12,11,10,9,13);
   srom[i+0x10000/2]=BITSWAP16(prom[i+0x6d0000/2]^0xf3f3,7,6,0,4,3,2,1,5,15,14,8,12,11,10,9,13);
   }
  for (i=0;i<0x4000/2;i++){
  srom[i+0x02000/2]=BITSWAP16(prom[i+0x6c2000/2]^0xf3f3,7,6,0,4,3,2,1,5,15,14,8,12,11,10,9,13);
  srom[i+0x12000/2]=BITSWAP16(prom[i+0x612000/2]^0xf3f3,7,6,0,4,3,2,1,5,15,14,8,12,11,10,9,13);
  }
// bank 2, game does this on the fly!
for (i=0;i<0x20000/2;i++){
  srom[i+0x40000/2]=BITSWAP16(prom[i+0x600000/2]^0xf3f3,7,6,0,4,3,2,1,5,15,14,8,12,11,10,9,13);
  srom[i+0x60000/2]=srom[i+0x20000/2]; // copy bios again
  }

// Altera protection chip patches these over P ROM

prom[0x00124/2] = 0x000d;	// Run code that gives XOR for RAM moves and forces SoftDIPs
prom[0x00126/2] = 0xf7a8;	// (how to play off and always teamplay). Also forces USA region. 

prom[0x08bf4/2] = 0x4ef9;	// Run code to change 8x8 tiles (needed for neogeo logo tiles)
prom[0x08bf6/2] = 0x000d;
prom[0x08bf8/2] = 0xf980;

// remove protection (game has ram mapped to 0xe0000 and 0xf0000 and moves code into it)

for(i=0;i<0x40;i++){
  prom[0xe0000/2+i]=((prom[0x531680/2+i]^(0xc11d-0xc0c8))^prom[0x531600/2+i]);
}
for(i=0;i<0x270;i++){
  prom[0xe1000/2+i]=((prom[0x531970/2+i]^(0xc11d-0xc0d9))^prom[0x531700/2+i]);
}

prom[0xe1154/2] = 0x125c;	// fix a jmp offset (was in 0xe0000 range)
prom[0xdf986/2] = 0x168C;	// fix a bsr offset (was in 0xe0000 range)
prom[0xdf998/2] = 0x1668;	// fix a bsr offset (was in 0xe0000 range)

prom[0xdd880/2] = 0x4e75;	// fix level drawing   (from 0xf0000 range)
prom[0xdd89e/2] = 0x4e75;	// fix level anim      (from 0xf0000 range)
prom[0xdd8bc/2] = 0x4e75;	// fix continue screen (from 0xf0000 range)

neogeo_fix_bank_type = 0;

/* kof10th Bankswitch handler */
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000,0x2fffff, 0, 0, neogeo_sram16_2_r);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000,0x2fffff, 0, 0, neogeo_sram16_2_w);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2ffff0,0x2fffff, 0, 0, neo_bankswitch_w);

init_neogeo();
}

/* descrambling information from razoola */
/* descrambling S rom for cthd2003 Super Plus */
static void ct2k3sp_sx_decrypt( void )
{
int rom_size = memory_region_length( REGION_GFX1 );
UINT8 *rom = memory_region( REGION_GFX1 );
UINT8 *buf = malloc( rom_size );
int i;
int ofst;

memcpy( buf, rom, rom_size );

for( i = 0; i < rom_size; i++ ){
  ofst = BITSWAP24( (i & 0x1ffff), 23, 22, 21, 20, 19, 18, 17,  3,
            0,  1,  4,  2, 13, 14, 16, 15,
            5,  6, 11, 10,  9,  8,  7, 12 );

  ofst += (i >> 17) << 17;

  rom[ i ] = buf[ ofst ];
}

memcpy( buf, rom, rom_size );

memcpy( &rom[ 0x08000 ], &buf[ 0x10000 ], 0x8000 );
memcpy( &rom[ 0x10000 ], &buf[ 0x08000 ], 0x8000 );
memcpy( &rom[ 0x28000 ], &buf[ 0x30000 ], 0x8000 );
memcpy( &rom[ 0x30000 ], &buf[ 0x28000 ], 0x8000 );

free( buf );
}

static void cthd2003_neogeo_gfx_address_fix_do(int start, int end, int bit3shift, int bit2shift, int bit1shift, int bit0shift)
{
int i,j;
int tilesize=128;

UINT8* rom = (UINT8*)malloc(16*tilesize);	// 16 tiles buffer
UINT8* realrom = memory_region(REGION_GFX3) + start*tilesize;

for (i = 0; i < (end-start)/16; i++) {
  for (j = 0; j < 16; j++) {
   int offset = (((j&1)>>0)<<bit0shift)
            +(((j&2)>>1)<<bit1shift)
            +(((j&4)>>2)<<bit2shift)
      +(((j&8)>>3)<<bit3shift);

   memcpy(rom+j*tilesize, realrom+offset*tilesize, tilesize);
  }
  memcpy(realrom,rom,tilesize*16);
  realrom+=16*tilesize;
}
free(rom);
}

static void cthd2003_neogeo_gfx_address_fix(int start, int end)
{
cthd2003_neogeo_gfx_address_fix_do(start+512*0, end+512*0, 0,3,2,1);
cthd2003_neogeo_gfx_address_fix_do(start+512*1, end+512*1, 1,0,3,2);
cthd2003_neogeo_gfx_address_fix_do(start+512*2, end+512*2, 2,1,0,3);
// skip 3 & 4
cthd2003_neogeo_gfx_address_fix_do(start+512*5, end+512*5, 0,1,2,3);
cthd2003_neogeo_gfx_address_fix_do(start+512*6, end+512*6, 0,1,2,3);
cthd2003_neogeo_gfx_address_fix_do(start+512*7, end+512*7, 0,2,3,1);
}

static void cthd2003_c(int pow)
{
int i;

for (i=0; i<=192; i+=8)
  cthd2003_neogeo_gfx_address_fix(i*512,i*512+512);

for (i=200; i<=392; i+=8)
  cthd2003_neogeo_gfx_address_fix(i*512,i*512+512);

for (i=400; i<=592; i+=8)
  cthd2003_neogeo_gfx_address_fix(i*512,i*512+512);

for (i=600; i<=792; i+=8)
  cthd2003_neogeo_gfx_address_fix(i*512,i*512+512);

for (i=800; i<=992; i+=8)
  cthd2003_neogeo_gfx_address_fix(i*512,i*512+512);

for (i=1000; i<=1016; i+=8)
  cthd2003_neogeo_gfx_address_fix(i*512,i*512+512);
}

DRIVER_INIT (cthd2003)
{
UINT8 *romdata = memory_region(REGION_GFX1);
UINT8*tmp = (UINT8*)malloc(8*128*128);

memcpy(tmp+8*0*128, romdata+8*0*128, 8*32*128);
memcpy(tmp+8*32*128, romdata+8*64*128, 8*32*128);
memcpy(tmp+8*64*128, romdata+8*32*128, 8*32*128);
memcpy(tmp+8*96*128, romdata+8*96*128, 8*32*128);
memcpy(romdata, tmp, 8*128*128);

romdata = memory_region(REGION_CPU2)+0x10000;
  memcpy(tmp+8*0*128, romdata+8*0*128, 8*32*128);
memcpy(tmp+8*32*128, romdata+8*64*128, 8*32*128);
  memcpy(tmp+8*64*128, romdata+8*32*128, 8*32*128);
memcpy(tmp+8*96*128, romdata+8*96*128, 8*32*128);
memcpy(romdata, tmp, 8*128*128);

  free(tmp);

memcpy(romdata-0x10000,romdata,0x10000);

cthd2003_c(0);
  init_neogeo();
}

DRIVER_INIT (ct2k3sp)
{

UINT8 *romdata = memory_region(REGION_CPU2)+0x10000;
UINT8*tmp = (UINT8*)malloc(8*128*128);
  memcpy(tmp+8*0*128, romdata+8*0*128, 8*32*128);
memcpy(tmp+8*32*128, romdata+8*64*128, 8*32*128);
  memcpy(tmp+8*64*128, romdata+8*32*128, 8*32*128);
memcpy(tmp+8*96*128, romdata+8*96*128, 8*32*128);
memcpy(romdata, tmp, 8*128*128);

  free(tmp);
memcpy(romdata-0x10000,romdata,0x10000);
ct2k3sp_sx_decrypt();
cthd2003_c(0);
  init_neogeo();
}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...