Author Topic: King of Fighters 2003, The (Set 2)  (Read 21789 times)

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
King of Fighters 2003, The (Set 2)
« on: December 18, 2005, 03:46:35 AM »
The code for fba is a little more complex because of the bankswitch being used.
It seems everyone is using different names and versions of the code.  I'm posting
what I have; you may have to edit it a bit to make it work for you.

Code: [Select]
// The King of Fighters 2003 (MVS Cart)

static struct BurnRomInfo kof2003aRomDesc[] = {
{ "271-p1c.bin",  0x400000, 0x530ecc14, 1 | BRF_ESS | BRF_PRG }, //  0 68K code
{ "271-p2c.bin",  0x400000, 0xfd568da9, 1 | BRF_ESS | BRF_PRG }, //  1
{ "271-p3d.bin",  0x100000, 0x59d376da, 1 | BRF_ESS | BRF_PRG }, //  2 (decrypted)
{ "271-p3c.bin",  0x100000, 0xaec5b4a9, 0 | BRF_PRG | BRF_OPT }, //  3

{ "271-c1c.bin",  0x800000, 0xb1dc25d0, 3 | BRF_GRA }, //  4 Sprite data
{ "271-c2c.bin",  0x800000, 0xd5362437, 3 | BRF_GRA }, //  5
{ "271-c3c.bin",  0x800000, 0x0a1fbeab, 3 | BRF_GRA }, //  6
{ "271-c4c.bin",  0x800000, 0x87b19a0c, 3 | BRF_GRA }, //  7
{ "271-c5c.bin",  0x800000, 0x704ea371, 3 | BRF_GRA }, //  8
{ "271-c6c.bin",  0x800000, 0x20a1164c, 3 | BRF_GRA }, //  9
{ "271-c7c.bin",  0x800000, 0x189aba7f, 3 | BRF_GRA }, // 10
{ "271-c8c.bin",  0x800000, 0x20ec4fdc, 3 | BRF_GRA }, // 11

{ "271-m1cd.bin", 0x080000, 0x4374CB5C, 4 | BRF_ESS | BRF_PRG }, // 12 Z80 code (decrypted)
{ "271-m1c.bin",  0x080000, 0xf5515629, 0 | BRF_PRG | BRF_OPT }, // 13 Z80 code

{ "271-v1c.bin",  0x800000, 0xffa3f8c7, 5 | BRF_SND }, // 14 Sound data
{ "271-v2c.bin",  0x800000, 0x5382c7d1, 5 | BRF_SND }, // 15
};

STDROMPICKEXT(kof2003a, kof2003a, neogeo);
STD_ROM_FN(kof2003a);

static void px_interleave()
{
unsigned char *src = Neo68KROM;
unsigned char *dst = (unsigned char*)malloc(0x800000);
for (int i = 0; i < 0x800000; i+=4) {
memcpy(dst + i + 0, src + 0x000000 + i / 2, 2);
memcpy(dst + i + 2, src + 0x400000 + i / 2, 2);
}
memcpy(src, dst, 0x800000);
free(dst);
}

void kof2003a_px_decrypt()
{
px_interleave(); // can use code from kof2003 interleave

int i,j;
unsigned char *src = Neo68KROM;
unsigned char *dst = (unsigned char*)malloc(0x900000);

for(i = 0; i < 0x100000; i++)
dst[i] = src[i] ^ 0xFF ^ src[ 0x0FFFE0 + (i % 0x20)];

for(i = 0x100000; i < 0x800000; i++)
dst[i] = src[i] ^ 0xFF ^ src[ 0x7FFFE0 + (i % 0x20)];

for(i = 0x100000; i < 0x800000; i += 4) {
unsigned short *rom16 = (unsigned short*)&dst[i + 1];
*rom16 = (*rom16&0xF00F) | BITSWAP08((*rom16>>4)&0xFF, 1, 0, 3, 2, 5, 4, 7, 6)<<4;
}

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

memcpy(src + 0x100000, src + 0x800000, 0x100000);

for(i = 0x100000; i < 0x800000; i += 0x100) {
j = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00800)
+ (BITSWAP08(((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2) << 12);
memcpy(src + i + 0x100000, dst + j, 0x100);
}

free(dst);
}

static int kof2003aInit()
{
int nRet;

memset(CartRAM, 0, 0x1000);

nNeoTextROMSize = 0x080000;
nNeoProtectionXor = 0x9D;
pNeoInitCallback = kof2003a_px_decrypt;
pNeoScanCallback = NeoPVCScan;

nRet = NeoInit();

if (nRet == 0) {
PCM2DecryptVInfo Info = {  0xA7001, 0xFF14EA, { 0x4B, 0xA4, 0x63, 0x46, 0xF0, 0x91, 0xEA, 0x62 } };

PCM2DecryptV(&Info);

pvcMapHandler(); // Install Bankswitch handler
}

return nRet;
}

struct BurnDriver BurnDrvkof2003a = {
"kof2003a", "kof2003", "neogeo", "2003",
"The King of Fighters 2003 (set 2)\0", "MVS Version", "SNK Playmore", "Neo Geo",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_ENCRYPTED_B | HARDWARE_SNK_ALTERNATE_TEXT,
NULL, kof2003aRomInfo, kof2003aRomName, neogeoInputInfo, neogeoDIPInfo,
kof2003aInit, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};


Offline MichaelNet

  • New Member
  • *
  • Posts: 1
  • Karma: +0/-0
Re: King of Fighters 2003, The (Set 2)
« Reply #1 on: December 18, 2005, 04:35:08 PM »
Nice stuff !  :smilie:

Many Thx for the port iq !

Offline DsNo

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +9/-0
  • Junior Member
Re: King of Fighters 2003, The (Set 2)
« Reply #2 on: December 19, 2005, 06:40:42 PM »
Code: [Select]
pNeoScanCallback = NeoPVCScan;

My fba compiling error..
I need NeoPVCScan source... Anyone know this?

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: King of Fighters 2003, The (Set 2)
« Reply #3 on: December 19, 2005, 07:39:46 PM »
Code: [Select]
unsigned char *NeoCartRAM = (unsigned char*)CartRAM;

int NeoPVCScan(int nAction, int* /*pnMin*/)
{
struct BurnArea ba;

if (nAction & ACB_MEMORY_RAM) {
ba.Data = NeoCartRAM;
ba.nLen = 0x00002000;
ba.nAddress = 0;
ba.szName = "Neo-PVC 68K RAM";
BurnAcb(&ba);
}

return 0;
}


Offline DsNo

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +9/-0
  • Junior Member
Re: King of Fighters 2003, The (Set 2)
« Reply #4 on: December 20, 2005, 12:26:21 AM »
Thanks!! IQ_132~  :biggrin:

Offline magni

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
Re: King of Fighters 2003, The (Set 2)
« Reply #5 on: December 21, 2005, 12:42:48 AM »

Hi!

Short question: I see p3d from kof2003 is used in this driver, so gives p3c decrypted the same file as p3 from kof2003?

Thx

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: King of Fighters 2003, The (Set 2)
« Reply #6 on: December 21, 2005, 01:12:31 AM »
Yeah, the p3d from kof2003a and kof2003 should be 100% the same.
The only differences in the P roms (data-wise) are in the 1st mb of the decrypted P - moving the zoom data that was in the pcb bios into the P.
All of the rest of the data (decrypted) should be the same.  Also, the p3d from kof2003 will give the correct CRC in unibios for kof2003a


Offline magni

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
Re: King of Fighters 2003, The (Set 2)
« Reply #7 on: December 21, 2005, 02:33:19 AM »
Yeah, the p3d from kof2003a and kof2003 should be 100% the same.
The only differences in the P roms (data-wise) are in the 1st mb of the decrypted P - moving the zoom data that was in the pcb bios into the P.
All of the rest of the data (decrypted) should be the same.  Also, the p3d from kof2003 will give the correct CRC in unibios for kof2003a

You write should be, so the code for decrypting the p3c is still unknown.
The uni-bios check verifies nothing, as only the first mb is checked, so if p3cd is copied to 2nd seg or higher, uni-bios always tells you good crc32.

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: King of Fighters 2003, The (Set 2)
« Reply #8 on: December 21, 2005, 03:32:01 AM »
You write should be, so the code for decrypting the p3c is still unknown.
The uni-bios check verifies nothing, as only the first mb is checked, so if p3cd is copied to 2nd seg or higher, uni-bios always tells you good crc32.


I don't know where you're getting your information on the uni-bios, but you are incorrect.
The unibios certainly checks the second segment.


Offline JiMMy_PaGe

  • Expert
  • *****
  • Posts: 60
  • Karma: +2/-0
    • SNK-NeoFighters
Re: King of Fighters 2003, The (Set 2)
« Reply #9 on: December 21, 2005, 08:42:05 AM »
"Uni-bios CRC Check" tested with the p3d and without the p3d:

C ya bro

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: King of Fighters 2003, The (Set 2)
« Reply #10 on: December 21, 2005, 02:19:50 PM »
That's odd... I remember doing tests with kof2002 and it did check the p2


Offline magni

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
Re: King of Fighters 2003, The (Set 2)
« Reply #11 on: December 22, 2005, 03:03:38 PM »

I came across FBA Evo 3.1 and that version doesn´t seem to need p3d.
I loaded encrypted p´s and did a ramdump.
Result:
MD5         : 00EE71A61F17B1677EE4A88123880861
CRC-32      : 59D376DA

What about some code sharing?

Thx

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: King of Fighters 2003, The (Set 2)
« Reply #12 on: December 22, 2005, 05:30:56 PM »
How about we try to be less demanding ;)
Not that I'm going to post that anyway...


Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: King of Fighters 2003, The (Set 2)
« Reply #13 on: December 22, 2005, 08:20:16 PM »
It would be cool though if there is code to decrypt all the roms instead of useing the p3d rom :)
IQ Forum Member

Offline tcwlee

  • Newbies
  • *
  • Posts: 11
  • Karma: +0/-0
  • Junior Member
Re: King of Fighters 2003, The (Set 2)
« Reply #14 on: December 23, 2005, 09:56:25 AM »
where is used in FBA0.294.98 SRC~~~~~