Author Topic: Some PVC Bankswitch code  (Read 19521 times)

Offline JiMMy_PaGe

  • Expert
  • *****
  • Posts: 60
  • Karma: +2/-0
    • SNK-NeoFighters
Some PVC Bankswitch code
« Reply #15 on: January 19, 2005, 09:00:20 AM »
Good work bms888!
Thanks for the codes, i will update my old bankswitch codes for those one :D
Now im just wating for ur mv0_proto code hehe lol :D
Thanks again
See ya

Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Some PVC Bankswitch code
« Reply #16 on: January 19, 2005, 01:35:55 PM »
Quote from: bms888
these code can working on mslug5,mslug5b,svcboot,svcsplus,kof2003b,kof2k3up,kof2k4ex....^_^

You mean along with the first bank code, remember that this carts except ms5 uses 2 bankswitches... I'll test it.
Thanks and 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
Some PVC Bankswitch code
« Reply #17 on: February 21, 2005, 11:13:41 AM »
Quote from: Jimmy_Page
Good work bms888!
Thanks for the codes, i will update my old bankswitch codes for those one :D
Now im just wating for ur mv0_proto code hehe lol :D
Thanks again
See ya



Ok, the new PVC code out in EGCG forums now!

http://bbs.emu-zone.org/egcg/showthread.php?t=14

Offline JiMMy_PaGe

  • Expert
  • *****
  • Posts: 60
  • Karma: +2/-0
    • SNK-NeoFighters
Some PVC Bankswitch code
« Reply #18 on: February 21, 2005, 11:17:01 AM »
Quote from: bms888
Ok, the new PVC code out in EGCG forums now!

http://bbs.emu-zone.org/egcg/showthread.php?t=14

Great!!!!!
Thanks a lot bms888 now the patch codes wont be needed !!!  :D   :D  :D   :D
See ya

Offline iq_132

  • Administrator
  • *****
  • Posts: 3723
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Some PVC Bankswitch code
« Reply #19 on: February 21, 2005, 05:35:54 PM »
Thanks BMS :) Very good stuff there ;)


Offline netbug

  • Newbies
  • *
  • Posts: 37
  • Karma: +1/-0
  • Member
Some PVC Bankswitch code
« Reply #20 on: February 21, 2005, 10:13:57 PM »
I am most grateful to BMS for your job. ;)
Have a great year!

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Some PVC Bankswitch code
« Reply #21 on: February 22, 2005, 06:27:50 AM »
Sadly I cannot veiw that site for some reason  Can anyone post the code here ?
IQ Forum Member

Offline iq_132

  • Administrator
  • *****
  • Posts: 3723
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Some PVC Bankswitch code
« Reply #22 on: February 22, 2005, 08:23:25 AM »
Here ya go James :)

Code: [Select]
static unsigned short CartRAM[0x1000];
// for save states
unsigned char *NeoCartRAM = (unsigned char *)CartRAM;

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

void pvc_w8(unsigned int sekAddress,unsigned char byteValue)
{
*(((unsigned char *)CartRAM)+((sekAddress^1)-0x2fe000))=byteValue;
}

unsigned char __fastcall pvcReadByteBankSwitch(unsigned int sekAddress)
{
return pvc_r8(sekAddress);
}

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

// Special Bankswitch
void pvc_CalcBank() // on writes to f0-f3
{
unsigned int offset=(pvc_r8(0x2ffff2)<<16)|(pvc_r8(0x2ffff3)<<8)|(pvc_r8(0x2ffff0)<<0);
*((unsigned char *) (CartRAM+((0x2ffff0-0x2fe000)^1)))&=0xfe;
*((unsigned char *) (CartRAM+((0x2ffff1-0x2fe000)^1)))=0xa0;
*((unsigned char *) (CartRAM+((0x2ffff2-0x2fe000)^1)))&=0x7f;
SekMapMemory(Neo68KROM+0x100000+offset,0x200000,0x2fdfff,SM_ROM);
}

// These perform some palette calculations
// Unpack palette word to RGB dword
void pvc_prot1() // on writes to e0/e1
{
unsigned char b1, b2;
b1 = pvc_r8(0x2fffe0);
b2 = pvc_r8(0x2fffe1);
pvc_w8(0x2fffe3,(((b2>>0)&0xf)<<1)|((b1>>4)&1));
pvc_w8(0x2fffe2,(((b2>>4)&0xf)<<1)|((b1>>5)&1));
pvc_w8(0x2fffe5,(((b1>>0)&0xf)<<1)|((b1>>6)&1));
pvc_w8(0x2fffe4,  (b1>>7));
}

// pack RGB dword to palette word
void pvc_prot2() // on writes to e8/e9/ea/eb
{
unsigned char b1, b2, b3, b4;
b1 = pvc_r8(0x2fffe8);
b2 = pvc_r8(0x2fffe9);
b3 = pvc_r8(0x2fffea);
b4 = pvc_r8(0x2fffeb);

pvc_w8(0x2fffed,(b2>>1)|((b1>>1)<<4));
pvc_w8(0x2fffec,(b4>>1)|((b2&1)<<4)|((b1&1)<<5)|((b4&1)<<6)|((b3&1)<<7));
}

void __fastcall pvcWriteByteBankSwitch(unsigned int sekAddress, unsigned char byteValue)
{
pvc_w8(sekAddress,byteValue);
  if (sekAddress>=0x2fffe0 && sekAddress<=0x2fffe1)pvc_prot1();
else if(sekAddress>=0x2fffe8 && sekAddress<=0x2fffeb)pvc_prot2();
else if(sekAddress>=0x2ffff0 && sekAddress<=0x2ffff3)pvc_CalcBank();
}

void __fastcall pvcWriteWordBankSwitch(unsigned int sekAddress, unsigned short wordValue)
{
CartRAM[(sekAddress-0x2fe000)/2]=wordValue;
  if (sekAddress>=0x2fffe0 && sekAddress<=0x2fffe1)pvc_prot1();
else if(sekAddress>=0x2fffe8 && sekAddress<=0x2fffeb)pvc_prot2();
else if(sekAddress>=0x2ffff0 && sekAddress<=0x2ffff3)pvc_CalcBank();
}

// Special Bankswitch
void pvc_CalcBank2() // on writes to f0-f3
{
unsigned int offset;
// Make this universal for kof2003b + kof2003p
if ((!strcmp(BurnDrvGetTextA(DRV_NAME), "kof2k4eh")) || (!strcmp(BurnDrvGetTextA(DRV_NAME), "kof2k4ex"))) {
offset=(pvc_r8(0x2ffff2)<<16)|(pvc_r8(0x2ffff3)<<8)|(pvc_r8(0x2ffff1)<<0);
*((unsigned char *) (CartRAM+((0x2ffff1-0x2fe000)^1)))&=0xfe;
*((unsigned char *) (CartRAM+((0x2ffff2-0x2fe000)^1)))&=0x7f;
} else {
offset=(pvc_r8(0x2ffff2)<<16)|(pvc_r8(0x2ffff3)<<8)|(pvc_r8(0x2ffff0)<<0);
*((unsigned char *) (CartRAM+((0x2ffff0-0x2fe000)^1)))&=0xfe;
*((unsigned char *) (CartRAM+((0x2ffff1-0x2fe000)^1)))=0xa0;
*((unsigned char *) (CartRAM+((0x2ffff2-0x2fe000)^1)))&=0x7f;
Neo68KROM[0x58196]=pvc_r8(0x2ffff3);
}
SekMapMemory(Neo68KROM+0x100000+offset,0x200000,0x2fdfff,SM_ROM);
}

void __fastcall pvcWriteByteBankSwitch2(unsigned int sekAddress, unsigned char byteValue)
{
pvc_w8(sekAddress,byteValue);
if(sekAddress>=0x2ffff0 && sekAddress<=0x2ffff3)pvc_CalcBank2();
}

void __fastcall pvcWriteWordBankSwitch2(unsigned int sekAddress, unsigned short wordValue)
{
CartRAM[(sekAddress-0x2fe000)/2]=wordValue;
if(sekAddress>=0x2ffff0 && sekAddress<=0x2ffff3)pvc_CalcBank2();
}


static void pvcMapHandler()
{
// Install BankSwitch handler
SekMapHandler(5, 0x2fe000, 0x2fffff, SM_READ);
SekSetReadWordHandler(5,  pvcReadWordBankSwitch);
SekSetReadByteHandler(5,  pvcReadByteBankSwitch);

SekMapHandler(5, 0x2fe000, 0x2fffff, SM_WRITE);
SekSetWriteWordHandler(5, pvcWriteWordBankSwitch);
SekSetWriteByteHandler(5, pvcWriteByteBankSwitch);
}

static void pvcMapHandler2()
{
// Install BankSwitch handler
SekMapHandler(5, 0x2fe000, 0x2fffff, SM_READ);
SekSetReadWordHandler(5,  pvcReadWordBankSwitch);
SekSetReadByteHandler(5,  pvcReadByteBankSwitch);

SekMapHandler(5, 0x2fe000, 0x2fffff, SM_WRITE);
SekSetWriteWordHandler(5, pvcWriteWordBankSwitch2);
SekSetWriteByteHandler(5, pvcWriteByteBankSwitch2);
}

static void pcbBiosMapHandler()
{
SekMapMemory(Neo68KBIOS+0x20000,0xC20000,0xC3FFFF,SM_ROM); // for PCB BIOS
}

static void kof03pvcMapHandler()
{
pvcMapHandler();

pcbBiosMapHandler(); // for PCB BIOS
}

Code: [Select]
// Metal Slug 5

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

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

{ "268-m1d.bin",  0x040000, 0x6866d696, 4 | BRF_ESS | BRF_PRG }, // 10 Z80 code (decrypted)
{ "268-m1.bin",   0x040000, 0x88c11f51, 0 | BRF_PRG | BRF_OPT }, // 11 Z80 code

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

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

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

// AES Patch
unsigned short *mem16 = (unsigned short *)Neo68KROM;
mem16[ 0x122A/2 ] = 0x4e71;
mem16[ 0x122C/2 ] = 0x4e71;
}

static int mslug5Init()
{
int nRet;

memset(CartRAM,0,0x2000);

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

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

struct BurnDriver BurnDrvmslug5 = {
"mslug5", NULL, "neogeo", "2003",
"Metal Slug 5\0", "Eecrypted C & V-ROMS", "SNK Playmore Corporation", "Neo Geo",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING, 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
};  

Code: [Select]
// SvC Chaos: SNK vs Capcom (PCB board)

static struct BurnRomInfo svcchaosRomDesc[] = {
{ "269-p1.bin",   0x2000000, 0x432CFDFC, 1 | BRF_ESS | BRF_PRG }, //  0 68K code

{ "269-c1.bin",   0x2000000, 0x1B608F9C, 3 | BRF_GRA }, //  1 Sprite data
{ "269-c2.bin",   0x2000000, 0x5A95F294, 3 | BRF_GRA }, //  2

{ "269-m1d.bin",  0x020000, 0xFD4F0FF9, 4 | BRF_ESS | BRF_PRG }, // 3 Z80 code (decrypted)
{ "269-m1.bin",   0x080000, 0xF6819D00, 0 | BRF_PRG | BRF_OPT }, // 4 Z80 code

/* This uses Neo-PCM2 PLAYMORE(c) 2002 Chip */
{ "269-v1.bin",   0x800000, 0xC659B34C, 5 | BRF_SND }, // 5
{ "269-v2.bin",   0x800000, 0xDD903835, 5 | BRF_SND }, // 6
};

STDROMPICKEXT(svcchaos, svcchaos, neosvc);
STD_ROM_FN(svcchaos);

static void svcchaos_px_patch()
{
// To patch svcchaos NEO LOGO Loop bug with ASM core
unsigned short *mem16 = (unsigned short *)Neo68KROM;
mem16[ 0x9DF0/2 ] = 0x4E71;
mem16[ 0x9DF2/2 ] = 0x4E71;
mem16[ 0x9E08/2 ] = 0x4E71;
mem16[ 0x9E0A/2 ] = 0x4E71;
}

static void svcchaosPVCDecrypt()
{
do_neopvc(2);
svcchaos_px_patch();
}

static int svcchaosInit()
{
int nRet;

memset(CartRAM,0,0x2000);

pNeoInitCallback = svcchaosPVCDecrypt;
nNeoProtectionXor = 0x57;
nNeoTextROMSize = 0x080000;
nNeoTextROMFixType = 8;
nNeoPCM2PLAYMOREByteswap = 5;

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

struct BurnDriver BurnDrvsvcchaos = {
"svcchaos", NULL, "neogeo", "2003",
"SvC Chaos: SNK vs Capcom\0", "PCB version", "Capcom / Playmore Corporation", "Neo Geo",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_ENCRYPTED_B | HARDWARE_SNK_ALTERNATE_TEXT | HARDWARE_SNK_NEWBANKSYSTEM,
NULL, svcchaosRomInfo, svcchaosRomName, neogeoInputInfo, neogeoDIPInfo,
svcchaosInit, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};

// SvC Chaos: SNK vs Capcom (MVS Cart)

static struct BurnRomInfo svchaosaRomDesc[] = {
{ "269-p1a.bin",  0x400000, 0x38e2005e, 1 | BRF_ESS | BRF_PRG }, //  0 68K code
{ "269-p2a.bin",  0x400000, 0x6d13797c, 1 | BRF_ESS | BRF_PRG }, //  1

{ "269-c1r.bin",  0x800000, 0x887b4068, 3 | BRF_GRA }, //  2 Sprite data
{ "269-c2r.bin",  0x800000, 0x4e8903e4, 3 | BRF_GRA }, //  3
{ "269-c3r.bin",  0x800000, 0x7d9c55b0, 3 | BRF_GRA }, //  4
{ "269-c4r.bin",  0x800000, 0x8acb5bb6, 3 | BRF_GRA }, //  5
{ "269-c5r.bin",  0x800000, 0x097a4157, 3 | BRF_GRA }, //  6
{ "269-c6r.bin",  0x800000, 0xe19df344, 3 | BRF_GRA }, //  7
{ "269-c7r.bin",  0x800000, 0xd8f0340b, 3 | BRF_GRA }, //  8
{ "269-c8r.bin",  0x800000, 0x2570b71b, 3 | BRF_GRA }, //  9

{ "269-m1d.bin",  0x020000, 0xFD4F0FF9, 4 | BRF_ESS | BRF_PRG }, // 10 Z80 code (decrypted)
{ "269-m1.bin",   0x080000, 0xF6819D00, 0 | BRF_PRG | BRF_OPT }, // 11 Z80 code

/* This uses Neo-PCM2 PLAYMORE(c) 2002 Chip */
{ "269-v1.bin",   0x800000, 0xC659B34C, 5 | BRF_SND }, // 12
{ "269-v2.bin",   0x800000, 0xDD903835, 5 | BRF_SND }, // 13
};

STDROMPICKEXT(svchaosa, svchaosa, neogeo);
STD_ROM_FN(svchaosa);

static void svchaosaPVCDecrypt()
{
interleave_pdata();
svcchaosPVCDecrypt();
}

static int svchaosaInit()
{
int nRet;

memset(CartRAM,0,0x2000);

pNeoInitCallback = svchaosaPVCDecrypt;
nNeoProtectionXor = 0x57;
nNeoTextROMSize = 0x080000;
nNeoPCM2PLAYMOREByteswap = 5;

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

struct BurnDriver BurnDrvsvchaosa = {
"svchaosa", "svcchaos", "neogeo", "2003",
"SvC Chaos: SNK vs Capcom (set 2)\0", "MVS version", "Capcom / Playmore Corporation", "Neo Geo",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_ENCRYPTED_B | HARDWARE_SNK_ALTERNATE_TEXT | HARDWARE_SNK_NEWBANKSYSTEM,
NULL, svchaosaRomInfo, svchaosaRomName, neogeoInputInfo, neogeoDIPInfo,
svchaosaInit, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};

Code: [Select]
// The King Of Fighters 2003

static struct BurnRomInfo kof2003RomDesc[] = {
{ "271-p1.bin",   0x400000, 0xb9da070c, 1 | BRF_ESS | BRF_PRG }, //  0 68K code
{ "271-p2.bin",   0x400000, 0xda3118c4, 1 | BRF_ESS | BRF_PRG }, //  1
{ "271-p3d.bin",  0x100000, 0x59d376da, 1 | BRF_ESS | BRF_PRG }, //  2
// { "271-p3.bin",   0x100000, 0x5cefd0d2, 1 | BRF_ESS | BRF_PRG }, //  2

{ "271-c1d.bin",  0x1000000, 0xc29acd28, 3 | BRF_GRA }, //  3 Sprite data
{ "271-c2d.bin",  0x1000000, 0x328e80b1, 3 | BRF_GRA }, //  4
{ "271-c3d.bin",  0x1000000, 0x020a11f1, 3 | BRF_GRA }, //  5
{ "271-c4d.bin",  0x1000000, 0x991b5ed2, 3 | BRF_GRA }, //  6
{ "271-c5d.bin",  0x1000000, 0xc2de8b66, 3 | BRF_GRA }, //  7
{ "271-c6d.bin",  0x1000000, 0x3ff750db, 3 | BRF_GRA }, //  8

{ "271-m1d.bin",  0x080000, 0x0e86af8f, 4 | BRF_ESS | BRF_PRG }, // 9 Z80 code (decrypted)
// { "271-m1.bin",   0x080000, 0xd6bcf2bc, 0 | BRF_PRG | BRF_OPT }, // 10 Z80 code

/* This uses Neo-PCM2 PLAYMORE(c) 2002 Chip */
{ "271-v1.bin",   0x1000000, 0x1d96154b, 5 | BRF_SND }, // 11
};

STDROMPICKEXT(kof2003, kof2003, neokof03);
STD_ROM_FN(kof2003);

static void kof2003PVCDecrypt()
{
interleave_pdata();
do_neopvc(1);

// 0xF9 for Good CRC, 0x75 to patch black screen with ASM core
Neo68KROM[ 0x0816 ]=0x75;
}

static int kof2003Init()
{
int nRet;

memset(CartRAM,0,0x2000);

nNeoTextROMSize = 0x100000;
pNeoInitCallback = kof2003PVCDecrypt;
nNeoTextROMFixType = 8;
nNeoPCM2PLAYMOREByteswap = 6;

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

struct BurnDriver BurnDrvkof2003 = {
"kof2003", NULL, "neogeo", "2003",
"The King of Fighters 2003\0", "Decrypted C-ROMS", "SNK Playmore Corporation", "Neo Geo",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_ALTERNATE_TEXT | HARDWARE_SNK_NEWBANKSYSTEM,
NULL, kof2003RomInfo, kof2003RomName, neogeoInputInfo, neogeoDIPInfo,
kof2003Init, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};

Code: [Select]
static void svchaosaPVCDecrypt()
{
interleave_pdata();
svcchaosPVCDecrypt();
}

Code: [Select]
// The King Of Fighters 2003 (bootleg)

static struct BurnRomInfo kof2003bRomDesc[] = {
{ "271-p1bl.bin",  0x400000, 0x92ed6ee3, 1 | BRF_ESS | BRF_PRG }, //  0 68K code
{ "271-p2bl.bin",  0x400000, 0x5d3d8bb3, 1 | BRF_ESS | BRF_PRG }, //  1

{ "271-s1bl.bin",  0x020000, 0x482c48a5, 2 | BRF_GRA }, //  2 Text layer tiles

{ "271-c1d.bin",  0x1000000, 0xc29acd28, 3 | BRF_GRA }, //  3 Sprite data
{ "271-c2d.bin",  0x1000000, 0x328e80b1, 3 | BRF_GRA }, //  4
{ "271-c3d.bin",  0x1000000, 0x020a11f1, 3 | BRF_GRA }, //  5
{ "271-c4d.bin",  0x1000000, 0x991b5ed2, 3 | BRF_GRA }, //  6

{ "271-m1d.bin",  0x080000,  0x0e86af8f, 4 | BRF_ESS | BRF_PRG }, // 9 Z80 code (decrypted)

{ "271-v1d.bin",  0x1000000, 0x2964F36E, 5 | BRF_SND }, // 10
};

STDROMPICKEXT(kof2003b, kof2003b, neokof03);
STD_ROM_FN(kof2003b);

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

int i, rom_size = 0x800000;
UINT8 *src = Neo68KROM;
UINT8 *dst = (UINT8 *)malloc( rom_size );

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

static int kof2003bInit()
{
int nRet;

memset(CartRAM,0,0x2000);

nNeoTextROMFixType = 3;
pNeoInitCallback = kof2003bDecrypt;

nRet=NeoInit();
if(!nRet)
pvcMapHandler2();
pcbBiosMapHandler();
return nRet;
}

struct BurnDriver BurnDrvkof2003b = {
"kof2003b", "kof2003", "neogeo", "2003",
"The King of Fighters 2003 (bootleg)\0", "Decrypted C-ROMS", "SNK Playmore Corporation", "Neo Geo",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_BOOTLEG, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_NEWBANKSYSTEM,
NULL, kof2003bRomInfo, kof2003bRomName, neogeoInputInfo, neogeoDIPInfo,
kof2003bInit, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};
« Last Edit: September 30, 2006, 06:01:48 AM by iq_132 »


Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Some PVC Bankswitch code
« Reply #23 on: February 22, 2005, 06:46:07 PM »
Thank you   :D
IQ Forum Member

Offline LikkleBaer

  • New Member
  • *
  • Posts: 9
  • Karma: +0/-0
  • Junior Member
Some PVC Bankswitch code
« Reply #24 on: February 23, 2005, 04:57:37 AM »
Are neosvc and neokof03 seperate bios sets? If so could somebody please post the names/CRCs of the roms that should be in them?

Thankies ^_^
"My God! ...It's full of Baers!"

www.likklebaer.eclipse.co.uk

Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Some PVC Bankswitch code
« Reply #25 on: March 07, 2005, 08:17:12 PM »
Tested again the new bankcode... SVCnd (using the same encrypted P rom) boots perfectly the first time you load the game, but if you reset you get again the NEO-GEO logo loop..., maybe I'm missing something...
I'll wait until IQ_132 release the drivers as he promised, his drivers always work XD
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 FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Some PVC Bankswitch code
« Reply #26 on: March 13, 2005, 08:58:10 PM »
Nevermind, i made a clean compile and worked...
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 Shoometsu

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
  • I finally have an avatar XD
Some PVC Bankswitch code
« Reply #27 on: March 14, 2005, 07:06:42 PM »
Quote from: FerchogtX
Tested again the new bankcode... SVCnd (using the same encrypted P rom) boots perfectly the first time you load the game, but if you reset you get again the NEO-GEO logo loop..., maybe I'm missing something...
I'll wait until IQ_132 release the drivers as he promised, his drivers always work XD
See ya!!!!!! :D


the probl here is that I cannot load the saves, thera are lots of busg and if I press reset th reset bug occurs...
<- Who are you?

Offline CaptainCPS

  • FBNeo Dev
  • ******
  • Posts: 1513
  • Karma: +127/-0
  • FB Alpha Team
    • CaptainCPS's Home
Some PVC Bankswitch code
« Reply #28 on: March 15, 2005, 09:34:48 AM »
Sorry for my ignorance but :P where i have to add this code?? im confused

Quote

static unsigned short CartRAM[0x1000];
// for save states
unsigned char *NeoCartRAM = (unsigned char *)CartRAM;

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

void pvc_w8(unsigned int sekAddress,unsigned char byteValue)
{
*(((unsigned char *)CartRAM)+((sekAddress^1)-0x2fe000))=byteValue;
}

unsigned char __fastcall pvcReadByteBankSwitch(unsigned int sekAddress)
{
return pvc_r8(sekAddress);
}

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

// Special Bankswitch
void pvc_CalcBank() // on writes to f0-f3
{
unsigned int offset=(pvc_r8(0x2ffff2)<<16)|(pvc_r8(0x2ffff3)<<8)|(pvc_r8(0x2ffff0)<<0);
*((unsigned char *) (CartRAM+((0x2ffff0-0x2fe000)^1)))&=0xfe;
*((unsigned char *) (CartRAM+((0x2ffff1-0x2fe000)^1)))=0xa0;
*((unsigned char *) (CartRAM+((0x2ffff2-0x2fe000)^1)))&=0x7f;
SekMapMemory(Neo68KROM+0x100000+offset,0x200000,0x 2fdfff,SM_ROM);
}

// These perform some palette calculations
// Unpack palette word to RGB dword
void pvc_prot1() // on writes to e0/e1
{
unsigned char b1, b2;
b1 = pvc_r8(0x2fffe0);
b2 = pvc_r8(0x2fffe1);
pvc_w8(0x2fffe3,(((b2>>0)&0xf)<<1)|((b1>>4)&1));
pvc_w8(0x2fffe2,(((b2>>4)&0xf)<<1)|((b1>>5)&1));
pvc_w8(0x2fffe5,(((b1>>0)&0xf)<<1)|((b1>>6)&1));
pvc_w8(0x2fffe4, (b1>>7));
}

// pack RGB dword to palette word
void pvc_prot2() // on writes to e8/e9/ea/eb
{
unsigned char b1, b2, b3, b4;
b1 = pvc_r8(0x2fffe8);
b2 = pvc_r8(0x2fffe9);
b3 = pvc_r8(0x2fffea);
b4 = pvc_r8(0x2fffeb);

pvc_w8(0x2fffed,(b2>>1)|((b1>>1)<<4));
pvc_w8(0x2fffec,(b4>>1)|((b2&1)<<4)|((b1&1)<<5)|((b4&1)<<6)|((b3&1)<<7));
}

void __fastcall pvcWriteByteBankSwitch(unsigned int sekAddress, unsigned char byteValue)
{
pvc_w8(sekAddress,byteValue);
if (sekAddress>=0x2fffe0 && sekAddress<=0x2fffe1)pvc_prot1();
else if(sekAddress>=0x2fffe8 && sekAddress<=0x2fffeb)pvc_prot2();
else if(sekAddress>=0x2ffff0 && sekAddress<=0x2ffff3)pvc_CalcBank();
}

void __fastcall pvcWriteWordBankSwitch(unsigned int sekAddress, unsigned short wordValue)
{
CartRAM[(sekAddress-0x2fe000)/2]=wordValue;
if (sekAddress>=0x2fffe0 && sekAddress<=0x2fffe1)pvc_prot1();
else if(sekAddress>=0x2fffe8 && sekAddress<=0x2fffeb)pvc_prot2();
else if(sekAddress>=0x2ffff0 && sekAddress<=0x2ffff3)pvc_CalcBank();
}

// Special Bankswitch
void pvc_CalcBank2() // on writes to f0-f3
{
unsigned int offset;
// Make this universal for kof2003b + kof2003p
if ((!strcmp(BurnDrvGetTextA(DRV_NAME), "kof2k4eh")) || (!strcmp(BurnDrvGetTextA(DRV_NAME), "kof2k4ex"))) {
offset=(pvc_r8(0x2ffff2)<<16)|(pvc_r8(0x2ffff3)<<8)|(pvc_r8(0x2ffff1)<<0);
*((unsigned char *) (CartRAM+((0x2ffff1-0x2fe000)^1)))&=0xfe;
*((unsigned char *) (CartRAM+((0x2ffff2-0x2fe000)^1)))&=0x7f;
} else {
offset=(pvc_r8(0x2ffff2)<<16)|(pvc_r8(0x2ffff3)<<8)|(pvc_r8(0x2ffff0)<<0);
*((unsigned char *) (CartRAM+((0x2ffff0-0x2fe000)^1)))&=0xfe;
*((unsigned char *) (CartRAM+((0x2ffff1-0x2fe000)^1)))=0xa0;
*((unsigned char *) (CartRAM+((0x2ffff2-0x2fe000)^1)))&=0x7f;
Neo68KROM[0x58196]=pvc_r8(0x2ffff3);
}
SekMapMemory(Neo68KROM+0x100000+offset,0x200000,0x 2fdfff,SM_ROM);
}

void __fastcall pvcWriteByteBankSwitch2(unsigned int sekAddress, unsigned char byteValue)
{
pvc_w8(sekAddress,byteValue);
if(sekAddress>=0x2ffff0 && sekAddress<=0x2ffff3)pvc_CalcBank2();
}

void __fastcall pvcWriteWordBankSwitch2(unsigned int sekAddress, unsigned short wordValue)
{
CartRAM[(sekAddress-0x2fe000)/2]=wordValue;
if(sekAddress>=0x2ffff0 && sekAddress<=0x2ffff3)pvc_CalcBank2();
}


static void pvcMapHandler()
{
// Install BankSwitch handler
SekMapHandler(5, 0x2fe000, 0x2fffff, SM_READ);
SekSetReadWordHandler(5, pvcReadWordBankSwitch);
SekSetReadByteHandler(5, pvcReadByteBankSwitch);

SekMapHandler(5, 0x2fe000, 0x2fffff, SM_WRITE);
SekSetWriteWordHandler(5, pvcWriteWordBankSwitch);
SekSetWriteByteHandler(5, pvcWriteByteBankSwitch);
}

static void pvcMapHandler2()
{
// Install BankSwitch handler
SekMapHandler(5, 0x2fe000, 0x2fffff, SM_READ);
SekSetReadWordHandler(5, pvcReadWordBankSwitch);
SekSetReadByteHandler(5, pvcReadByteBankSwitch);

SekMapHandler(5, 0x2fe000, 0x2fffff, SM_WRITE);
SekSetWriteWordHandler(5, pvcWriteWordBankSwitch2);
SekSetWriteByteHandler(5, pvcWriteByteBankSwitch2);
}

static void pcbBiosMapHandler()
{
SekMapMemory(Neo68KBIOS+0x20000,0xC20000,0xC3FFFF, SM_ROM); // for PCB BIOS
}

static void kof03pvcMapHandler()
{
pvcMapHandler();

pcbBiosMapHandler(); // for PCB BIOS
}


ThanX in advance :)

Offline JiMMy_PaGe

  • Expert
  • *****
  • Posts: 60
  • Karma: +2/-0
    • SNK-NeoFighters
Some PVC Bankswitch code
« Reply #29 on: March 15, 2005, 09:50:17 AM »
Quote from: CaptainCPS-X
Sorry for my ignorance but :P where i have to add this code?? im confused

 

ThanX in advance :)

I made a especial cpp for those codes, but u have to declare somethings on "neogeo.h", so its better to put in the middle or on the begining of d_neogeo.cpp  :D
See ya