//for instance 应用举例
// SvC Chaos: SNK vs Capcom (bootleg) 格斗之王对街头霸王:混沌版 (盗版)
static struct BurnRomInfo svcbootRomDesc[] = {
{"svc-p1.bin", 0x800000, 0x0348F162, 1 | BRF_ESS | BRF_PRG}, // 0 68K code
{"svc-s1.bin", 0x020000, 0x70B44DF1, 2 | BRF_GRA}, // 1
{"svc-c1.bin", 0x800000, 0xA7826B89, 3 | BRF_GRA}, // 2 Sprite data
{"svc-c2.bin", 0x800000, 0xED3C2089, 3 | BRF_GRA}, // 3
{"svc-c3.bin", 0x800000, 0x71ED8063, 3 | BRF_GRA}, // 4
{"svc-c4.bin", 0x800000, 0x250BDE2D, 3 | BRF_GRA}, // 5
{"svc-c5.bin", 0x800000, 0x9817C082, 3 | BRF_GRA}, // 6
{"svc-c6.bin", 0x800000, 0x2BC0307F, 3 | BRF_GRA}, // 7
{"svc-c7.bin", 0x800000, 0x4358D7B9, 3 | BRF_GRA}, // 8
{"svc-c8.bin", 0x800000, 0x366DEEE5, 3 | BRF_GRA}, // 9
{"svc-m1.bin", 0x020000, 0x804328C3, 4 | BRF_ESS | BRF_PRG}, // 10 Z80 code
{"svc-v2.bin", 0x400000, 0xB5097287, 5 | BRF_SND}, // 11
{"svc-v1.bin", 0x400000, 0xBD3A391F, 5 | BRF_SND}, // 12 Sound data
{"svc-v4.bin", 0x400000, 0x33FC0B37, 5 | BRF_SND}, // 13
{"svc-v3.bin", 0x400000, 0xAA9849A0, 5 | BRF_SND}, // 14
};
STDROMPICKEXT(svcboot, svcboot, neogeo);
STD_ROM_FN(svcboot);
static void svcboot_c()
{
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,ofst,crom_size = 0x4000000;
UINT8 *crom = NeoSpriteROM;
UINT8 *buf = (UINT8*)malloc(crom_size);
memcpy( buf, crom, crom_size );
for( i = 0; i < crom_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 = BITSWAP08( (i & 0x0000ff), 7, 6, 5, 4, bit3, bit2, bit1, bit0 );
ofst += (i & 0xfffff00);
memcpy( &crom[ i * 0x80 ], &buf[ ofst * 0x80 ], 0x80 );
}
free( buf );
// nSaveBootlegDecryptedC = 1; //for saving decrypted Sprite data 保存解密的盗版图像文件
}
static void svcboot_mx_decrypt()
{
UINT8 *mrom = (UINT8 *)(NeoZ80ROM);
UINT8 *dst = (UINT8*)malloc(0x20000);
memcpy( dst+0x00000, mrom+0x10000, 0x10000 );
memcpy( dst+0x10000, mrom+0x00000, 0x10000 );
memcpy( mrom,dst,0x20000 );
free(dst);
//声音文件位交换
nADPCMByteswap = 2;
}
static void svcboot_decrypt()
{
const unsigned char sec[] = {0x06, 0x07, 0x01, 0x02, 0x03, 0x04, 0x05, 0x00};
int i,ofst,rom_size = 0x800000;
UINT8 *rom = (UINT8*)(Neo68KROM);
UINT8 *buf = (UINT8*)malloc(rom_size);
for( i = 0; i < rom_size / 0x100000; i++ ){
memcpy( &buf[ i * 0x100000 ], &rom[ sec[ i ] * 0x100000 ], 0x100000 );
}
for( i = 0; i < rom_size / 2; i++ ){
ofst = BITSWAP08( (i & 0x0000ff), 7, 6, 1, 0, 3, 2, 5, 4 );
ofst += (i & 0xffff00);
memcpy( &rom[ i * 2 ], &buf[ ofst * 2 ], 0x02 );
}
free(buf);
svcboot_mx_decrypt();
svcboot_c();
}
static int svcbootInit()
{
pNeoInitCallback=svcboot_decrypt;
nNeoTextROMFixType=3;
memset(CartRAM,0,sizeof(CartRAM));
int nRet=NeoInit();
if(!nRet)
mv0_BankMapHandler();
return nRet;
}
struct BurnDriver BurnDrvsvcboot= {
"svcboot",NULL, "neogeo", "2003",
"SvC Chaos: SNK vs Capcom (bootleg)\0格斗之王对街头霸王:混沌版 (盗版)\0图像、声音盗版加密\0",NULL,"SNK Playmore公司", "Neo Geo",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_BOOTLEG, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_CUSTOM_BANKING | HARDWARE_SNK_SRAM,
NULL, svcbootRomInfo, svcbootRomName, neogeoInputInfo, neogeoDIPInfo,
svcbootInit, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};
// SvC Chaos: SNK vs Capcom Super Plus! (hack) 格斗之王对街头霸王:混沌版超级加强 (盗版)
static struct BurnRomInfo svcsplusRomDesc[] = {
{"svc-p1sp.bin",0x400000, 0x2601902F, 1 | BRF_ESS | BRF_PRG}, // 0 68K code
{"svc-p2sp.bin",0x400000, 0x0CA13305, 1 | BRF_ESS | BRF_PRG}, // 1
{"svc-s1sp.bin",0x020000, 0x233D6439, 2 | BRF_GRA}, // 2
{"svc-c1.bin", 0x800000, 0xA7826B89, 3 | BRF_GRA}, // 3 Sprite data
{"svc-c2.bin", 0x800000, 0xED3C2089, 3 | BRF_GRA}, // 4
{"svc-c3.bin", 0x800000, 0x71ED8063, 3 | BRF_GRA}, // 5
{"svc-c4.bin", 0x800000, 0x250BDE2D, 3 | BRF_GRA}, // 6
{"svc-c5.bin", 0x800000, 0x9817C082, 3 | BRF_GRA}, // 7
{"svc-c6.bin", 0x800000, 0x2BC0307F, 3 | BRF_GRA}, // 8
{"svc-c7.bin", 0x800000, 0x4358D7B9, 3 | BRF_GRA}, // 9
{"svc-c8.bin", 0x800000, 0x366DEEE5, 3 | BRF_GRA}, // 10
{"svc-m1.bin", 0x020000, 0x804328C3, 4 | BRF_ESS | BRF_PRG}, // 11 Z80 code
{"svc-v2.bin", 0x400000, 0xB5097287, 5 | BRF_SND}, // 12
{"svc-v1.bin", 0x400000, 0xBD3A391F, 5 | BRF_SND}, // 13 Sound data
{"svc-v4.bin", 0x400000, 0x33FC0B37, 5 | BRF_SND}, // 14
{"svc-v3.bin", 0x400000, 0xAA9849A0, 5 | BRF_SND}, // 15
};
STDROMPICKEXT(svcsplus, svcsplus, neogeo);
STD_ROM_FN(svcsplus);
static void svcsplus_decrypt()
{
int sec[] = {0x06, 0x01, 0x02, 0x03, 0x04, 0x05, 0x00, 0x07};
int sed[] = {0x000000,0x700000,0x100000,0x200000,0x300000,0x400000,0x500000};
unsigned char *src = Neo68KROM;
int i,ofst,size = 0x800000;
unsigned char *dst = (unsigned char*)malloc(size);
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 );
}
memcpy(dst,src,0x800000);
for(i = 0; i < 7; ++i)
memcpy(src+i*0x100000,dst+sed,0x100000);
free(dst);
svcboot_mx_decrypt();
svcboot_c();
*((unsigned short*)(Neo68KROM + 0x9E90)) = 0x000F; // Enable S. Plus
*((unsigned short*)(Neo68KROM + 0x9E92)) = 0xC9C0;
*((unsigned short*)(Neo68KROM + 0xA10C)) = 0x4EB9; // Enable boss icons
*((unsigned short*)(Neo68KROM + 0xA10E)) = 0x000E;
*((unsigned short*)(Neo68KROM + 0xA110)) = 0x9750;
}
static int svcsplusInit()
{
pNeoInitCallback=svcsplus_decrypt;
nNeoTextROMFixType = 5;
memset(CartRAM,0,sizeof(CartRAM));
int nRet=NeoInit();
if(!nRet)
mv0_BankMapHandler();
return nRet;
}
struct BurnDriver BurnDrvsvcsplus= {
"svcsplus","svcboot", "neogeo", "2003",
"SvC Chaos: SNK vs Capcom Super Plus! (hack)\0格斗之王对街头霸王:混沌版超级加强 (盗版)\0图像、声音盗版加密\0",NULL,"SNK Playmore公司", "Neo Geo",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_CUSTOM_BANKING | HARDWARE_SNK_SRAM,
NULL, svcsplusRomInfo, svcsplusRomName, neogeoInputInfo, neogeoDIPInfo,
svcsplusInit, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};
// SvC Chaos: SNK vs Capcom Plus! (hack, set 1) 格斗之王对街头霸王:混沌版加强 (盗版第一集)
static struct BurnRomInfo svcplusRomDesc[] = {
{"svc-p1p.bin", 0x200000, 0xA194D842, 1 | BRF_ESS | BRF_PRG}, // 0 68K code
{"svc-p2p.bin", 0x200000, 0x50C0E2B7, 1 | BRF_ESS | BRF_PRG}, // 1
{"svc-p3p.bin", 0x200000, 0x58CDC293, 1 | BRF_ESS | BRF_PRG}, // 2
{"svc-s1p.bin", 0x020000, 0x73344711, 2 | BRF_GRA}, // 3
{"svc-c1.bin", 0x800000, 0xA7826B89, 3 | BRF_GRA}, // 4 Sprite data
{"svc-c2.bin", 0x800000, 0xED3C2089, 3 | BRF_GRA}, // 5
{"svc-c3.bin", 0x800000, 0x71ED8063, 3 | BRF_GRA}, // 6
{"svc-c4.bin", 0x800000, 0x250BDE2D, 3 | BRF_GRA}, // 7
{"svc-c5.bin", 0x800000, 0x9817C082, 3 | BRF_GRA}, // 8
{"svc-c6.bin", 0x800000, 0x2BC0307F, 3 | BRF_GRA}, // 9
{"svc-c7.bin", 0x800000, 0x4358D7B9, 3 | BRF_GRA}, // 10
{"svc-c8.bin", 0x800000, 0x366DEEE5, 3 | BRF_GRA}, // 11
{"svc-m1.bin", 0x020000, 0x804328C3, 4 | BRF_ESS | BRF_PRG}, // 12 Z80 code
{"svc-v2.bin", 0x400000, 0xB5097287, 5 | BRF_SND}, // 13
{"svc-v1.bin", 0x400000, 0xBD3A391F, 5 | BRF_SND}, // 14 Sound data
{"svc-v4.bin", 0x400000, 0x33FC0B37, 5 | BRF_SND}, // 15
{"svc-v3.bin", 0x400000, 0xAA9849A0, 5 | BRF_SND}, // 16
};
STDROMPICKEXT(svcplus, svcplus, neogeo);
STD_ROM_FN(svcplus);
static void svcplus_decrypt()
{
int sec[] = {0x00, 0x03, 0x02, 0x05, 0x04, 0x01};
unsigned char *src = Neo68KROM;
int i,ofst,rom_size = 0x600000;
unsigned char *dst = (unsigned char*)malloc(rom_size);
memcpy( dst, src, rom_size );
for( i = 0; i < rom_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 * 2 ], &dst[ ofst * 2 ], 0x02 );
}
memcpy( dst, src, rom_size );
for( i = 0; i < 6; i++ ){
memcpy( &src[ i << 20 ], &dst[ sec[ i ] << 20 ], (1 << 20) );
}
free( dst );
svcboot_mx_decrypt();
svcboot_c();
*((unsigned short*)(Neo68KROM + 0xF8016)) = 0x33C1; // Patch protected address
}
static int svcplusInit()
{
pNeoInitCallback=svcplus_decrypt;
nNeoTextROMFixType= 1;
return NeoInit();
}
struct BurnDriver BurnDrvsvcplus= {
"svcplus","svcboot", "neogeo", "2003",
"SvC Chaos: SNK vs Capcom Plus! (hack, set 1)\0格斗之王对街头霸王:混沌版加强 (盗版第一集)\0图像、声音盗版加密\0",NULL,"SNK Playmore公司", "Neo Geo",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_SRAM,
NULL, svcplusRomInfo, svcplusRomName, neogeoInputInfo, neogeoDIPInfo,
svcplusInit, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};
// SvC Chaos: SNK vs Capcom Plus! (hack, set 2) 格斗之王对街头霸王:混沌版加强 (盗版第二集)
static struct BurnRomInfo svcplusaRomDesc[] = {
{"svc-p1pl.bin",0x200000, 0x16B44144, 1 | BRF_ESS | BRF_PRG}, // 0 68K code
{"svc-p2pl.bin",0x400000, 0x7231ACE2, 1 | BRF_ESS | BRF_PRG}, // 1
{"svc-s1pl.bin",0x020000, 0xCA3C735E, 2 | BRF_GRA}, // 2
{"svc-c1.bin", 0x800000, 0xA7826B89, 3 | BRF_GRA}, // 3 Sprite data
{"svc-c2.bin", 0x800000, 0xED3C2089, 3 | BRF_GRA}, // 4
{"svc-c3.bin", 0x800000, 0x71ED8063, 3 | BRF_GRA}, // 5
{"svc-c4.bin", 0x800000, 0x250BDE2D, 3 | BRF_GRA}, // 6
{"svc-c5.bin", 0x800000, 0x9817C082, 3 | BRF_GRA}, // 7
{"svc-c6.bin", 0x800000, 0x2BC0307F, 3 | BRF_GRA}, // 8
{"svc-c7.bin", 0x800000, 0x4358D7B9, 3 | BRF_GRA}, // 9
{"svc-c8.bin", 0x800000, 0x366DEEE5, 3 | BRF_GRA}, // 10
{"svc-m1.bin", 0x020000, 0x804328C3, 4 | BRF_ESS | BRF_PRG}, // 11 Z80 code
{"svc-v2.bin", 0x400000, 0xB5097287, 5 | BRF_SND}, // 12
{"svc-v1.bin", 0x400000, 0xBD3A391F, 5 | BRF_SND}, // 13 Sound data
{"svc-v4.bin", 0x400000, 0x33FC0B37, 5 | BRF_SND}, // 14
{"svc-v3.bin", 0x400000, 0xAA9849A0, 5 | BRF_SND}, // 15
};
STDROMPICKEXT(svcplusa, svcplusa, neogeo);
STD_ROM_FN(svcplusa);
static void svcplusa_decrypt()
{
unsigned char* src = Neo68KROM;
unsigned char* dst = (unsigned char*)malloc(0x600000);
int sec[] = {0x100000,0x200000,0x300000,0x400000,0x500000,0x000000};
if (dst){
memcpy(dst,src,0x600000);
for(int i = 0; i < 6; ++i){
memcpy(src+i*0x100000,dst+sec,0x100000);
}
free(dst);
}
svcboot_mx_decrypt();
svcboot_c();
// Patch out protection bits
*((unsigned short*)(Neo68KROM+0xF8016)) = 0x33C1;
}
static int svcplusaInit()
{
pNeoInitCallback=svcplusa_decrypt;
nNeoTextROMFixType= 3;
return NeoInit();
}
struct BurnDriver BurnDrvsvcplusa= {
"svcplusa","svcboot", "neogeo", "2003",
"SvC Chaos: SNK vs Capcom Plus! (hack, set 2)\0格斗之王对街头霸王:混沌版加强 (盗版第二集)\0图像、声音盗版加密\0",NULL,"SNK Playmore公司", "Neo Geo",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_SRAM,
NULL, svcplusaRomInfo, svcplusaRomName, neogeoInputInfo, neogeoDIPInfo,
svcplusaInit, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};
neo_run.cpp中
//svcboot及其克隆ROM和斗婚(盗版)声音位交换 开始部分
switch (nADPCMByteswap) {
//斗婚(盗版)使用
case 1 :
//V2、V4ROM位交换
BurnByteswap(YM2610ADPCMAROM+0x400000, 0x400000);
BurnByteswap(YM2610ADPCMAROM+0xc00000, 0x400000);
break;
//svcboot、svcsplus、svcplus、svcplusa
case 2 :
BurnByteswap(YM2610ADPCMAROM,nYM2610ADPCMASize);
break;
//samsh5bl
case 3 : {
for(int i=0; i YM2610ADPCMAROM = BITSWAP08(YM2610ADPCMAROM,0,1,5,4,3,2,6,7);
}
}
//svcboot和斗婚(盗版)声音位交换 结束部分