Author Topic: Metal Slug 5 Drivers  (Read 25193 times)

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Metal Slug 5 Drivers
« Reply #15 on: November 26, 2004, 12:17:58 AM »
Looks like I removed too many patches :|
Code: [Select]
// This patches out the bankswitch protection
// Code by IQ_132 - Thanks to HappyASR for the info
static void mslug5_patch()
{
for (int i = 0; i < 0x20000; i=i+2)
{
if (*((unsigned short*)(Neo68KROM01 + i + 0)) == 0x33FC)
{
if (*((unsigned short*)(Neo68KROM01 + i + 6)) == 0xfff0)
{
for (int j = i; j < (i+8); j=j+2)
{
*((unsigned short*)(Neo68KROM01 + j)) = 0x4e71;
}
}
}
if (*((unsigned short*)(Neo68KROM01 + i + 0 )) == 0x5247)
{
if (*((unsigned short*)(Neo68KROM01 + i + 4 )) == 0xe94f)
{
*((unsigned short*)(Neo68KROM01 + i + 0 )) = 0x33c7;
*((unsigned short*)(Neo68KROM01 + i + 2 )) = 0x002f;
*((unsigned short*)(Neo68KROM01 + i + 4 )) = 0xfff0;
}
}
}
*((unsigned short*)(Neo68KROM01 + 0x18430)) = 0x0001;
*((unsigned short*)(Neo68KROM01 + 0x0122A)) = 0x4e71; // AES Patch
*((unsigned short*)(Neo68KROM01 + 0x0122C)) = 0x4e71; // AES Patch
}


Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Metal Slug 5 Drivers
« Reply #16 on: November 26, 2004, 01:22:32 PM »
I'll test this one to see if works properly... thanks a lot IQ.
See ya!!!! :D

Good and evil co-exist because of the balance, lies are not part of it...

FB Alpha Plus! site infos updated, see the latest info clicking on my profile link...

Offline PRican25

  • Newbies
  • *
  • Posts: 44
  • Karma: +0/-0
  • Balla Bori Balla
Metal Slug 5 Drivers
« Reply #17 on: December 04, 2004, 01:12:03 AM »
just tried the neo_pvc driver and it resets when the demo starts and this is in mvs mode with japan bios set

also i'm having a lil prob with the ms5plus that i did the text fix as needed but some of the text is garbled like the plus flashing and credits.

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Metal Slug 5 Drivers
« Reply #18 on: December 04, 2004, 06:16:27 AM »
looks like you are missing parts of needed code metal slug 5 works fine here
(encrypted set)
IQ Forum Member

Offline PRican25

  • Newbies
  • *
  • Posts: 44
  • Karma: +0/-0
  • Balla Bori Balla
Metal Slug 5 Drivers
« Reply #19 on: December 04, 2004, 09:57:27 AM »
yeah, i think my neo_run.cpp is out date as the last time i touched it was when samsho5 set based on x emu was working on fba

EDIT: i just added the neopcm2playmore to my neo_run but still the same result but oddly enough the game plays fine if i start it and this also seemed to fix my ms5plus text problem (dunno how but it did hehe).

Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Metal Slug 5 Drivers
« Reply #20 on: December 23, 2004, 06:13:58 PM »
OK here an updated driver for mslug5, now it uses its proper bankswitch as well
first get sure you have this codes by IQ_132
Code: [Select]
// Code by iq_132 -- [url]http://neosource.1emu.net/[/url]
static void interleave_pdata()
{
int j=0,i;
unsigned char* src = Neo68KROM01;
unsigned char* dst = (unsigned char*)malloc(0x800000);
for (i=0;i<0x800000;i=i+4){
dst[i+0]=src[j];
dst[i+1]=src[j+1];
dst[i+2]=src[j+0x400000];
dst[i+3]=src[j+0x400001];
j=j+2;
}
memcpy(Neo68KROM01,dst,0x800000);
free(dst);
}
and this one is the neo-pvc by IQ_132 (the translation and code modification)
just added some lines to get working properly mslug5
Code: [Select]
// Neo-PVC Code for PCB and MVS games with this protection
// Original code by(?) HalRIN -- http://www52.tok2.com/home/foge/
// Converted to FBA code by iq_132 -- http://neosource.1emu.net/
static void neo_pvc(int game)
{
unsigned int xor1[ 2 ][ 0x20 ] = { // kof2003 does not use XOR 1
{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},
{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},
};

unsigned int xor2[ 3 ][ 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},
{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},
{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, ofst, ofst2 = 0x00300;
unsigned char *src = Neo68KROM01;
unsigned char *dst = (unsigned char*)malloc( 0x800000 );

if (game != 1)
for( i = 0; i < 0x100000; i++ )
src[ i ] ^= xor1[ game-2 ][ (i % 0x20) ];

for( i = 0x100000; i < 0x800000; i++ )
src[ i ] ^= xor2[ game-1 ][ (i % 0x20) ];

for( i = 0x100000; i < 0x800000; i += 4 ){
unsigned short *rom16 = (unsigned short*)&src[ i + 1 ];
if (game==1) *rom16 = BITSWAP16( *rom16, 15, 14, 13, 12, 4, 5, 6, 7, 8, 9, 10, 11, 3, 2, 1, 0 );
if (game!=1) *rom16 = BITSWAP16( *rom16, 15, 14, 13, 12, 10, 11, 8, 9, 6, 7, 4, 5, 3, 2, 1, 0 );
}

memcpy( dst, src, 0x800000 );

for( i = 0; i < 0x10; i++ ){
ofst = (i & 0xf0) + BITSWAP08( (i & 0x0f), 7, 6, 5, 4, 1, 0, 3, 2 );
if (game==2) ofst = (i & 0xf0) + BITSWAP08( (i & 0x0f), 7, 6, 5, 4, 2, 3, 0, 1 );
memcpy( &src[ i * 0x10000 ], &dst[ ofst * 0x10000 ], 0x10000 );
}

for( i = 0x100000; i < 0x800000; i += 0x100 ){
if (game==2) ofst2=0x00a00;
ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ ofst2) + (BITSWAP08( ((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2 ) << 12);
if (game==3)
ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00700) + (BITSWAP08( ((i & 0x0ff000) >> 12), 5, 4, 7, 6, 1, 0, 3, 2 ) << 12);
memcpy( &src[ i ], &dst[ ofst ], 0x100 );
}

if (game == 1) {
dst= (unsigned char*)malloc( 0x900000 );
memcpy( dst, src, 0x900000 );
memcpy( &src[ 0x100000 ], &dst[ 0x800000 ], 0x100000 );
memcpy( &src[ 0x200000 ], &dst[ 0x100000 ], 0x700000 );
} else {
dst = (unsigned char*)malloc( 0x800000 );
memcpy( dst, src, 0x800000 );
memcpy( &src[ 0x100000 ], &dst[ 0x700000 ], 0x100000 );
memcpy( &src[ 0x200000 ], &dst[ 0x100000 ], 0x600000 );
}

free(dst);
}
and finally, the driver:
Code: [Select]
// Metal Slug 5
/* ========================================================================
   This game has a new method of encryption in the P-ROMs, the Neo-PVC chip
   this protection consists in a some kind of byteswap, with 1 or 2 xors
   that reorders the data, also there is an interleaving in the P-ROMs (ex-
   cept in some games) the xors can change depending of the game...
======================================================================== */
static struct BurnRomInfo mslug5RomDesc[] = {
{"268-p1.bin", 0x400000, 0xd0466792, 0x10}, //  0 68K code (interleaved)
{"268-p2.bin", 0x400000, 0xfbf6b61e, 0x10}, //  1   (interleaved)

{"268-c1.bin", 0x800000, 0x27d59de8,    1}, //  2 Sprite data
{"268-c2.bin", 0x800000, 0xe600dee1,    1}, //  3
{"268-c3.bin", 0x800000, 0xb650f098,    1}, //  4
{"268-c4.bin", 0x800000, 0x10499589,    1}, //  5
{"268-c5.bin", 0x800000, 0x19352405,    1}, //  6
{"268-c6.bin", 0x800000, 0xb1531523,    1}, //  7
{"268-c7.bin", 0x800000, 0xfe2c1338,    1}, //  8
{"268-c8.bin", 0x800000, 0xecce3141,    1}, //  9

{"268-m1d.bin",0x040000, 0x6866d696, 0x10}, // 10 Z80 code (decrypted)
{"268-m1.bin", 0x040000, 0x88c11f51, 0x10}, // 11 Z80 code

/* This uses Neo-PCM2 PLAYMORE(c) 2002 Chip */
{"268-v1.bin", 0x800000, 0x33c6305c,    2}, // 12 Sound data
{"268-v2.bin", 0x800000, 0x1afb848e,    2}, // 13
};

STDROMPICKEXT(mslug5, mslug5, neogeo);
STD_ROM_FN(mslug5);

static void mslug5PVCDecrypt()
{
interleave_pdata();
neo_pvc(3);

*((unsigned short*)(Neo68KROM01 + 0x122A)) = 0x4e71; // AES Patch
*((unsigned short*)(Neo68KROM01 + 0x122C)) = 0x4e71; // AES Patch
}

// Bankswitch #1 for PVC protected carts / boards
static unsigned short CartRAM[0x1000];

unsigned char __fastcall mv0ReadByteBankSwitch(unsigned int sekAddress)
{
return *(((unsigned char *)CartRAM)+((sekAddress^1)-0x2fe000));
}

unsigned short __fastcall mv0ReadWordBankSwitch(unsigned int sekAddress)
{
return CartRAM[(sekAddress-0x2fe000)/2];
}

static void mv0WriteBankSwitch(unsigned int sekAddress,unsigned short wordValue,unsigned short valueMask)
{
int address=(sekAddress-0x2fe000)/2,bankaddress;
CartRAM[address]=(wordValue&valueMask)|(~valueMask&CartRAM[address]);
if(address!=0xff8 && address!=0xff9 ) return;
bankaddress=(CartRAM[0xff8]>>8)|(CartRAM[0xff9]<<8);
*(((unsigned char *)CartRAM)+0x1ff0)=0xa0;
*(((unsigned char *)CartRAM)+0x1ff1)&=0xfe;
*(((unsigned char *)CartRAM)+0x1ff3)&=0x7f;
SekMapMemory(Neo68KROM02+bankaddress,0x200000,0x2fdfff,SM_ROM);
Neo68KROM01[0x58196]=CartRAM[0xff9]&0xff;
}

void __fastcall mv0WriteWordBankSwitch(unsigned int sekAddress, unsigned short wordValue)
{
unsigned short valueMask=0xffff;
mv0WriteBankSwitch(sekAddress,wordValue,valueMask);
}

void __fastcall mv0WriteByteBankSwitch(unsigned int sekAddress, unsigned char byteValue)
{
unsigned short wordValue=0,valueMask=0xff;
if(!(sekAddress&1)) {
wordValue=byteValue<<8;
valueMask<<=8;
} else {
wordValue=byteValue;
}
mv0WriteBankSwitch(sekAddress,wordValue,valueMask);
}

static void mv0_BankMapHandler()
{
// Install BankSwitch handler
SekMapHandler(5,    0x2fe000, 0x2fffff, SM_READ);
SekSetReadWordHandler(5,  mv0ReadWordBankSwitch);
SekSetReadByteHandler(5,  mv0ReadByteBankSwitch);

SekMapHandler(5,    0x2fe000, 0x2fffff, SM_WRITE);
SekSetWriteWordHandler(5, mv0WriteWordBankSwitch);
SekSetWriteByteHandler(5, mv0WriteByteBankSwitch);
}

static int mslug5Init()
{
int nRet;

memset(CartRAM,0,0x2000);

pNeoInitCallback = mslug5PVCDecrypt;
nNeoProtectionXor = 0x19;
nNeoPCM2PLAYMOREByteswap = 3;

nRet = NeoInit();
if (!nRet)
mv0_BankMapHandler();
return nRet;
}

struct BurnDriver BurnDrvmslug5 = {
{"mslug5", "Metal Slug 5", NULL, "SNK Playmore", "Neo Geo", "2003", NULL, "neogeo"},
BDF_GAME_WORKING | BDF_LOCKED, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_ENCRYPTED_B | HARDWARE_SNK_NEWBANKSYSTEM,
NULL, mslug5RomInfo, mslug5RomName, neogeoInputInfo, neogeoDIPInfo,
mslug5Init, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};

// Metal Slug 5 (decrypted C)

static struct BurnRomInfo mslug5ndRomDesc[] = {
{"268-p1.bin",  0x400000, 0xd0466792, 0x10}, //  0 68K code
{"268-p2.bin",  0x400000, 0xfbf6b61e, 0x10}, //  1

{"ms5n_c1.rom", 0x800000, 0x969C0D62,    1}, //  2 Sprite data
{"ms5n_c2.rom", 0x800000, 0xC69AE867,    1}, //  3
{"ms5n_c3.rom", 0x800000, 0xD7BEAEAF,    1}, //  4
{"ms5n_c4.rom", 0x800000, 0x899fb2af,    1}, //  5
{"ms5n_c5.rom", 0x800000, 0x2FA1A5AD,    1}, //  6
{"ms5n_c6.rom", 0x800000, 0x6DE89589,    1}, //  7
{"ms5n_c7.rom", 0x800000, 0x97BD0C0A,    1}, //  8
{"ms5n_c8.rom", 0x800000, 0xC0D5BC20,    1}, //  9

{"268-m1d.bin", 0x040000, 0x6866d696, 0x10}, // 10 Z80 code

{"268-v1.bin",  0x800000, 0x33c6305c,    2}, // 11 Sound data
{"268-v2.bin",  0x800000, 0x1afb848e,    2}, // 12
};

STDROMPICKEXT(mslug5nd, mslug5nd, neogeo);
STD_ROM_FN(mslug5nd);

struct BurnDriver BurnDrvmslug5nd = {
{"mslug5nd", "Metal Slug 5 (decrypted C)", "Decrypted C-ROMs", "SNK Playmore", "Neo Geo", "2003", "mslug5", "neogeo"},
BDF_GAME_WORKING | BDF_CLONE | BDF_LOCKED, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_NEWBANKSYSTEM,
NULL, mslug5ndRomInfo, mslug5ndRomName, neogeoInputInfo, neogeoDIPInfo,
mslug5Init, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};
make sure you have also the PCM2 playmore chip code (by IQ_132) in your neo_run.cpp
See ya!!!!! :D
P.S. mv0_BankMapHandler = kof2003bBankMapHandler = kof2003BankMapHandler
« Last Edit: May 10, 2005, 01:03:49 PM by iq_132 »

Good and evil co-exist because of the balance, lies are not part of it...

FB Alpha Plus! site infos updated, see the latest info clicking on my profile link...

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Metal Slug 5 Drivers
« Reply #21 on: December 23, 2004, 07:41:54 PM »
Nice work ferchogtx :)

Code: [Select]
// Metal Slug 5 (Bootleg)

static struct BurnRomInfo mslug5bRomDesc[] = {
{"268-p1b.bin", 0x800000, 0x3f1cf3d2, 0x10}, //  0 68K code

{"268-c1b.bin", 0x800000, 0x969c0d62,    1}, //  1 Sprite data
{"268-c2b.bin", 0x800000, 0xc69ae867,    1}, //  2
{"268-c3b.bin", 0x800000, 0xd7beaeaf,    1}, //  3
{"268-c4b.bin", 0x800000, 0xe1b1131b, 1}, //  4
{"268-c5b.bin", 0x800000, 0x2fa1a5ad,    1}, //  5
{"268-c6b.bin", 0x800000, 0x6de89589,    1}, //  6
{"268-c7b.bin", 0x800000, 0x97bd0c0a,    1}, //  7
{"268-c8b.bin", 0x800000, 0xc0d5bc20,    1}, //  8

{"268-m1b.bin", 0x020000, 0x6FA01C9A, 0x10}, //  9 Z80 code

{"268-v1b.bin", 0x400000, 0xc3540e0d,    2}, //  10 Sound data
{"268-v2b.bin", 0x400000, 0x077bd2f4,    2}, //  11
{"268-v3b.bin", 0x400000, 0x39b14567,    2}, //  12
{"268-v4b.bin", 0x400000, 0x969ff3b2,    2}, //  13
};

STDROMPICKEXT(mslug5b, mslug5b, neogeo);
STD_ROM_FN(mslug5b);

static void mslug5b_descramble()
{
unsigned char* src = Neo68KROM01;
unsigned char* dst = (unsigned char*)malloc(0x100000);
memcpy(dst+0x000000, src+0x200000, 0x100000);
memcpy(src+0x200000, src+0x300000, 0x100000);
memcpy(src+0x300000, dst+0x000000, 0x100000);
memcpy(src+0x200000, src+0x100000, 0x400000);
free(dst);

*((unsigned short*)(Neo68KROM01 + 0x122A)) = 0x4e71; // AES Patch
*((unsigned short*)(Neo68KROM01 + 0x122C)) = 0x4e71; // AES Patch
}

static int mslug5bInit()
{
int nRet;

memset(CartRAM,0,0x2000);

pNeoInitCallback = mslug5b_descramble;
nNeoProtectionXor = 0x19;

nRet = NeoInit();
if (!nRet)
mv0_BankMapHandler();
return nRet;
}

struct BurnDriver BurnDrvmslug5b = {

{"mslug5b", "Metal Slug 5 (Bootleg)", NULL, "SNK Playmore Corporation", "Neo Geo", "2003", "mslug5", "neogeo"},
BDF_GAME_WORKING | BDF_BOOTLEG | BDF_CLONE, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_NEWBANKSYSTEM,
NULL, mslug5bRomInfo, mslug5bRomName, neogeoInputInfo, neogeoDIPInfo,
mslug5bInit, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};


Offline Xeon

  • Newbies
  • *
  • Posts: 45
  • Karma: +0/-0
  • Member
Metal Slug 5 Drivers
« Reply #22 on: December 24, 2004, 01:41:17 PM »
urrrgg...darn, im lost again after some matters. anyways, just a little question. if mslug5 uses 3 for neo_pvc then whats the value for svcchaos and kof2003 (i know kof2003 doesnt work yet)

Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Metal Slug 5 Drivers
« Reply #23 on: December 24, 2004, 04:45:21 PM »
for:
SNK vs CAPCOM neo_pvc = neo_pvc(2);
The King of Fighters 2003 neo_pvc = neo_pvc(1);
See ya!!!! :D

Good and evil co-exist because of the balance, lies are not part of it...

FB Alpha Plus! site infos updated, see the latest info clicking on my profile link...

Offline bms888

  • Jr. Member
  • **
  • Posts: 93
  • Karma: +0/-0
  • Member
Metal Slug 5 Drivers
« Reply #24 on: January 13, 2005, 10:08:35 PM »
Metal Slug 5 Plus FBA code is here,not patch,^_^.

Code: [Select]

// Metal Slug 5 Plus! (hack)

static struct BurnRomInfo ms5plusRomDesc[] = {
{"268-p1p.bin", 0x100000, 0x106B276F, 0x10}, //  0 68K code /* protected code */
{"268-p2p.bin", 0x200000, 0xD6A458E8, 0x10}, //  1
{"268-p3p.bin", 0x200000, 0x439EC031, 0x10}, //  2

{"268-s1p.bin", 0x020000, 0x21e04432,    1}, //  3 Text layer tiles /* scrambled */

{"268-c1.bin",  0x800000, 0x27d59de8,    1}, //  4 Sprite data
{"268-c2.bin",  0x800000, 0xe600dee1,    1}, //  5
{"268-c3.bin",  0x800000, 0xb650f098,    1}, //  6
{"268-c4.bin",  0x800000, 0x10499589,    1}, //  7
{"268-c5.bin",  0x800000, 0x19352405,    1}, //  8
{"268-c6.bin",  0x800000, 0xb1531523,    1}, //  9
{"268-c7.bin",  0x800000, 0xfe2c1338,    1}, // 10
{"268-c8.bin",  0x800000, 0xecce3141,    1}, // 11

{"268-m1d.bin", 0x040000, 0x6866d696, 0x10}, // 12 Z80 code

{"268-v1.bin",  0x800000, 0x33c6305c,    2}, // 13 Sound data (encrypted)
{"268-v2.bin",  0x800000, 0x1afb848e,    2}, // 14
};

STDROMPICKEXT(ms5plus, ms5plus, neogeo);
STD_ROM_FN(ms5plus);

static unsigned short CartRAM[0x1000];

void __fastcall ms5plusWriteWordBankSwitch(unsigned int sekAddress, unsigned short wordValue)
{
if (sekAddress==0x2ffff4)
{
unsigned int offset=wordValue<<0x10;
SekMapMemory(Neo68KROM01+offset,0x200000,0x2fdfff,SM_ROM);
};
}

static void ms5plusMapHandler()
{
SekMapHandler(5, 0x2fe000, 0x2fffff, SM_WRITE);
SekSetWriteWordHandler(5, ms5plusWriteWordBankSwitch);
}

static void ms5p_px_fix()
{
// Reload last 2 roms (fixes FBA load problem)
BurnLoadRom(Neo68KROM01+0x100000, 1, 1);
BurnLoadRom(Neo68KROM01+0x300000, 2, 1);
}

static void ms5p_sx_fix()
{
int i, rom_size = 0x20000;
UINT8 *src = (UINT8*)(NeoTextROM+0x20000);
UINT8 *dst = (UINT8 *)malloc( rom_size );

memcpy( dst,src,rom_size );
// descrambling the S1
for( i=0; i memcpy(src+i, dst+i+0x08, 0x08);
memcpy(src+i+0x08, dst+i, 0x08);
}
free( dst );
}

static void ms5p_vx_fix()
{
const unsigned char ms5xor[0x08] = { 0xc3, 0xfd, 0x81, 0xac, 0x6d, 0xe7, 0xbf, 0x9e };

int i, ofst, rom_size = 0x1000000;
UINT8 *rom = YM2610ADPCMAROM;
UINT8 *buf = (UINT8 *)malloc( rom_size );

memcpy(buf, rom, rom_size);

for( i = 0; i < rom_size; i++)
{
ofst = (i & 0xfefffe) | ((i & 0x010000) >> 16) | ((i & 0x000001) << 16);

ofst ^= 0x4e001;

rom[ofst] = (buf[((i + 0xfe2cf6) & 0xffffff)] ^ ms5xor[(ofst & 0x07)]);
}
free( buf );
}

static void ms5plus_decrypt()
{
ms5p_px_fix();
ms5p_sx_fix();
ms5p_vx_fix();
}

static int ms5plusInit()
{
int nRet;

memset(CartRAM,0,0x2000);

nNeoProtectionXor = 0x19;
pNeoInitCallback = ms5plus_decrypt;

nRet = NeoInit();
if (!nRet)
ms5plusMapHandler();
return nRet;
}

struct BurnDriver BurnDrvms5plus = {
{"ms5plus", "Metal Slug 5 Plus! (hack)", "Hack of mslug5", "SNK Playmore", "Neo Geo", "2003", "mslug5", "neogeo"},
BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_ENCRYPTED_B | HARDWARE_SNK_NEWBANKSYSTEM,
NULL, ms5plusRomInfo, ms5plusRomName, neogeoInputInfo, neogeoDIPInfo,
ms5plusInit, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Metal Slug 5 Drivers
« Reply #25 on: January 13, 2005, 10:16:13 PM »
Wow! You're on a roll :)
Thanks BMS :)


Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Metal Slug 5 Drivers
« Reply #26 on: January 13, 2005, 11:57:15 PM »
Thanks a lot man! this is pretty good... maybe you can figure out which protection does kof2002b has in s1, p2 and c roms
Thanks
See ya!!!! :D

Good and evil co-exist because of the balance, lies are not part of it...

FB Alpha Plus! site infos updated, see the latest info clicking on my profile link...

Offline bms888

  • Jr. Member
  • **
  • Posts: 93
  • Karma: +0/-0
  • Member
Metal Slug 5 Drivers
« Reply #27 on: January 14, 2005, 03:10:58 AM »
Quote from: FerchogtX
Thanks a lot man! this is pretty good... maybe you can figure out which protection does kof2002b has in s1, p2 and c roms
Thanks
See ya!!!! :D


kof2002b P-rom code is here,s1 unknown now, I don't have kof2002b C-roms,^_^.

Code: [Select]

// The King of Fighters 2002 (bootleg)

static struct BurnRomInfo kof2002bRomDesc[] = {
{"265-p1.bin",  0x100000, 0x9EDE7323, 0x10}, //  0 68K code
{"265-p2b.bin", 0x400000, 0x6DBEE4DF, 0x10}, //  1


Code: [Select]

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

int i, rom_size = 0x400000;
UINT8 *src = Neo68KROM01+0x100000;
UINT8 *dst = (UINT8 *)malloc( rom_size );
 
memcpy( dst, src, rom_size);
for( i=0; i<8; i++){
memcpy( src+i*0x80000, dst+sec[i]*0x80000, 0x80000);
}
free( dst );
}

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Metal Slug 5 Drivers
« Reply #28 on: January 14, 2005, 07:03:16 AM »
Quote from: Xeon
urrrgg...darn, im lost again after some matters. anyways, just a little question. if mslug5 uses 3 for neo_pvc then whats the value for svcchaos and kof2003 (i know kof2003 doesnt work yet)



I thought kof2003 does work (not the bootleg)  As it works here .
IQ Forum Member

Offline KaNyErO

  • Member
  • ***
  • Posts: 142
  • Karma: +4/-0
Metal Slug 5 Drivers
« Reply #29 on: January 14, 2005, 10:03:47 AM »
Quote from: bms888
kof2002b P-rom code is here,s1 unknown now, I don't have kof2002b C-roms,^_^.

Code: [Select]

// The King of Fighters 2002 (bootleg)

static struct BurnRomInfo kof2002bRomDesc[] = {
{"265-p1.bin",  0x100000, 0x9EDE7323, 0x10}, //  0 68K code
{"265-p2b.bin", 0x400000, 0x6DBEE4DF, 0x10}, //  1


Code: [Select]

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

int i, rom_size = 0x400000;
UINT8 *src = Neo68KROM01+0x100000;
UINT8 *dst = (UINT8 *)malloc( rom_size );
 
memcpy( dst, src, rom_size);
for( i=0; i<8; i++){
memcpy( src+i*0x80000, dst+sec[i]*0x80000, 0x80000);
}
free( dst );
}


the s1 is scrambled: first 128 bytes are where they should be, next 128 bytes belongs to another place and this repeat untill the end of the rom

128 ok 128 moved
128 ok 128 moved
...