Jump to content

FBA-XXX coding help needed


+ T +

Recommended Posts

Hi,

 

I'm really hoping that someone with more coding skills than me can help me out with this. I've been trying to get IQ_132's PCM2 PLAYMORE decryption code working in my build of FBA-XXX with little success. The emu just locks up after the romset finishes loading and the game never starts.

 

I've tried two different versions of the code both producing exactly the same result. The first runs from neo_run.cpp and is implemented as follows (from IQ's forum):

 

in neogeo.h

look for this:

// neo_run.cpp

add this after:

extern int nNeoPCM2PLAYMOREByteswap;

in neo_run.cpp

look for this:

int nNeoSRAMProtection = -1;

add this after (or after pcm2 code by IQ_132)

int nNeoPCM2PLAYMOREByteswap = 0; // PCM2 PLAYMORE chip

Look for this:

  if (BurnDrvGetHardwareCode() & HARDWARE_SNK_SWAPV) {
	 for (int i = 0; i < 0x00200000; i++) {
   unsigned char n = YM2610ADPCMAROM[i];
   YM2610ADPCMAROM[i] = YM2610ADPCMAROM[0x00200000 + i];
   YM2610ADPCMAROM[0x00200000 + i] = n;
	 }
 }
}

add this after (or after the IQ_132 PCM2 SNK 1999 code)

	/* Neo-PCM2 PLAYMORE(c) 2002 Sound Chip Emulation */
// some code by Fataku & some by the vconv (from 2ch) - FBA conversion by iq_132
if (nNeoPCM2PLAYMOREByteswap != 0)
{
 unsigned int addrs[7][2]={
	 {0x000000,0xA5000}, //kof2002
	 {0xFFCE20,0x01000}, //matrimelee
	 {0xFE2CF6,0x4E001}, //mslug5
	 {0xFEB2C0,0x0A000}, //samsho5
	 {0xFFAC28,0xC2000}, //svcchaos
	 {0x000000,0x00000}, //kof2003
	 {0xFFB440,0x02000}, //samsh5sp
 };
        unsigned int xordata[7][8]={
	 {0xF9,0xE0,0x5D,0xF3,0xEA,0x92,0xBE,0xEF}, //kof2002
   {0xC4,0x83,0xA8,0x5F,0x21,0x27,0x64,0xAF}, //matrimelee
	 {0xC3,0xFD,0x81,0xAC,0x6D,0xE7,0xBF,0x9E}, //mslug5
	 {0xCB,0x29,0x7D,0x43,0xD2,0x3A,0xC2,0xB4}, //samsho5
	 {0xC3,0xFD,0x81,0xAC,0x6D,0xE7,0xBF,0x9E}, //svcchaos
	 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //kof2003
	 {0x4B,0xA4,0x63,0x46,0xF0,0x91,0xEA,0x62}, //samsh5sp
 };

 int value = (nNeoPCM2PLAYMOREByteswap-1);	
 UINT8 *rom = YM2610ADPCMAROM;
 UINT8 *buf = (UINT8*)malloc(0x1000000);
 int ofst;

 memcpy(buf,rom,0x1000000);

 for(int i=0; i<0x1000000; i++)
 {
	 ofst = (i & 0xfefffe) | ((i & 0x010000) >> 16) | ((i & 0x000001) << 16);
	 ofst ^= addrs[value][1];
	 rom[ofst] = (buf[((i + addrs[value][0]) & 0xffffff)] ^ xordata[value][(ofst & 0x07)]);
 }

 free(buf);
}

look for NeoExit() int add after:

nNeoSramProtection = 0;

this:

nNeoPCM2PLAYMOREByteswap = 0; // exit PCM2 PLAYMORE chip

in d_neogeo.cpp

According with the driver, give the correct value for each game that uses this chip; for example:

static int kof2002Init()
{
nNeoProtectionxor = 0xec
pNeoInitCallback = kof2002Decrypt;
[B]nNeoPCM2PLAYMOREByteswap = 1;[/B]
return NeoInit();
}

 

 

 

The second method runs from the driver itself (matrim for example):

 

// Power Instinct Matrimelee

static struct BurnRomInfo matrimRomDesc[] = {

{"266-p1.bin", 0x100000, 0x5d4c2dc7, 0x10}, // 0 68K code

{"266-p2.bin", 0x400000, 0xa14b1906, 0x10}, // 1

 

{"266-c1.bin", 0x800000, 0x505f4e30, 1}, // 2 Sprite data

{"266-c2.bin", 0x800000, 0x3cb57482, 1}, // 3

{"266-c3.bin", 0x800000, 0xf1cc6ad0, 1}, // 5

{"266-c4.bin", 0x800000, 0x45b806b7, 1}, // 6

{"266-c5.bin", 0x800000, 0x9a15dd6b, 1}, // 7

{"266-c6.bin", 0x800000, 0x281cb939, 1}, // 8

{"266-c7.bin", 0x800000, 0x4b71f780, 1}, // 9

{"266-c8.bin", 0x800000, 0x29873d33, 1}, // 10

 

{"266-m1d.bin",0x020000, 0xd2f3742d, 0x10}, // 11 Z80 code

{"266-m1.bin", 0x020000, 0x456c3e6c, 0x10}, // 12 Z80 code

 

{"266-v1.bin", 0x800000, 0xa4f83690, 2}, // 13 Sound data

{"266-v2.bin", 0x800000, 0xd0f69eda, 2}, // 14

// {"266-v1d.bin", 0x800000, 0x328b2194, 2}, // 13 Sound data

// {"266-v2d.bin", 0x800000, 0x2a13562d, 2}, // 14

};

 

STDROMPICKEXT(matrim, matrim, neogeo);

STD_ROM_FN(matrim);

 

static void matrim()

{

const unsigned char matrim_xor[0x08] = {0xc4, 0x83, 0xa8, 0x5f, 0x21, 0x27, 0x64, 0xaf};

unsigned char *rom = YM2610ADPCMAROM;

unsigned char *buf = (unsigned char*)malloc(0x1000000);

int ofst;

 

memcpy( buf, rom, 0x1000000 );

 

for( int i = 0; i

ofst = (i & 0xfefffe) |

((i & 0x010000) >> 16) |

((i & 0x000001)

 

ofst ^= 0x10000;

 

rom[ofst] = buf[ ((i + 0xffce20) & 0xffffff) ] ^ matrim_xor[ (ofst & 0x07) ];

}

free( buf );

 

*((unsigned short*)(Neo68KROM01 + 0x01050)) = 0x4E75;

 

kof2002Decrypt();//code by iq_132 from RomShare == http://www.freepgs.com/iq_132/

}

 

static int matrimInit()

{

nNeoTextROMSize = 0x080000;

nNeoProtectionXor = 0x6a;

pNeoInitCallback = matrim;

return NeoInit();

}

 

struct BurnDriver BurnDrvmatrim = {

{"matrim", "Power Instinct Matrimelee", "Japanese title is: Shin Gouketsuji-Ichizoku", "Atlus", "Neo Geo", "2002", NULL, "neogeo"},

BDF_GAME_WORKING, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_ENCRYPTED_B | HARDWARE_SNK_ALTERNATE_TEXT,

NULL, matrimRomInfo, matrimRomName, neogeoInputInfo, neogeoDIPInfo,

matrimInit, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,

nNeoScreenWidth, 224, 4, 3

};

 

Any help anyone can give would be greatly appreciated.

 

Thanks

 

+ T +

Edited by + T +
Link to comment
Share on other sites

I donno, give this a try maybe.

 

extern unsigned char* YM2610ADPCMAROM;

static void neo_pcm2_playmore2002(int value)
{
unsigned int addrs[7][2]={
 {0x000000,0xA5000}, //kof2002
 {0xFFCE20,0x01000}, //matrimelee
 {0xFE2CF6,0x4E001}, //mslug5
 {0xFEB2C0,0x0A000}, //samsho5
 {0xFFAC28,0xC2000}, //svcchaos
 {0xFF14EA,0xA7001}, //kof2003
 {0xFFB440,0x02000}, //samsh5sp
};
       unsigned int xordata[7][8]={
 {0xF9,0xE0,0x5D,0xF3,0xEA,0x92,0xBE,0xEF}, //kof2002
 {0xC4,0x83,0xA8,0x5F,0x21,0x27,0x64,0xAF}, //matrimelee
 {0xC3,0xFD,0x81,0xAC,0x6D,0xE7,0xBF,0x9E}, //mslug5
 {0xCB,0x29,0x7D,0x43,0xD2,0x3A,0xC2,0xB4}, //samsho5
 {0xC3,0xFD,0x81,0xAC,0x6D,0xE7,0xBF,0x9E}, //svcchaos
 {0x4B,0xA4,0x63,0x46,0xF0,0x91,0xEA,0x62}, //kof2003
 {0x4B,0xA4,0x63,0x46,0xF0,0x91,0xEA,0x62}, //samsh5sp
};

value = value-1; 
UINT8 *rom = YM2610ADPCMAROM;
UINT8 *buf = (UINT8*)malloc(0x1000000);
int ofst;

memcpy(buf,rom,0x1000000);

for(int i=0; i<0x1000000; i++)
{
 ofst = (i & 0xfefffe) | ((i & 0x010000) >> 16) | ((i & 0x000001) << 16);
 ofst ^= addrs[value][1];
 rom[ofst] = (buf[((i + addrs[value][0]) & 0xffffff)] ^ xordata[value][(ofst & 0x07)]);
}
free(buf);
}

static int kof2002Init()
{
int nRet;

nNeoProtectionxor = 0xec
pNeoInitCallback = kof2002Decrypt;

nRet = NeoInit();

if (nRet == 0) {
 neo_pcm2_playmore2002(1);
}

return nRet;
}

Link to comment
Share on other sites

Thanks ever so much for the help IQ. Nobody else seems to have a clue what to suggest so I really appreciate it. :banghead:

 

Unfortunately its the same story with your revised code. I added it to a couple of the drivers (inserting the appropriate (int value) for the game of course) and the rom loads all the way but then everything locks up at the point where the game should start.

 

As just a shot in the dark from someone who knows next-to-nothing about code, do you think it could be memory related?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...