Welcome!

Final Burn Neo => FBN Development => Topic started by: iq_132 on December 18, 2005, 03:46:35 AM

Title: King of Fighters 2003, The (Set 2)
Post by: iq_132 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
};
Title: Re: King of Fighters 2003, The (Set 2)
Post by: MichaelNet on December 18, 2005, 04:35:08 PM
Nice stuff !  :smilie:

Many Thx for the port iq !
Title: Re: King of Fighters 2003, The (Set 2)
Post by: DsNo on December 19, 2005, 06:40:42 PM
Code: [Select]
pNeoScanCallback = NeoPVCScan;

My fba compiling error..
I need NeoPVCScan source... Anyone know this?
Title: Re: King of Fighters 2003, The (Set 2)
Post by: iq_132 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;
}
Title: Re: King of Fighters 2003, The (Set 2)
Post by: DsNo on December 20, 2005, 12:26:21 AM
Thanks!! IQ_132~  :biggrin:
Title: Re: King of Fighters 2003, The (Set 2)
Post by: magni 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
Title: Re: King of Fighters 2003, The (Set 2)
Post by: iq_132 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
Title: Re: King of Fighters 2003, The (Set 2)
Post by: magni 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.
Title: Re: King of Fighters 2003, The (Set 2)
Post by: iq_132 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.
Title: Re: King of Fighters 2003, The (Set 2)
Post by: JiMMy_PaGe on December 21, 2005, 08:42:05 AM
"Uni-bios CRC Check" tested with the p3d and without the p3d:
(http://img175.imageshack.us/img175/3693/kof2003a12161714408up.png)
C ya bro
Title: Re: King of Fighters 2003, The (Set 2)
Post by: iq_132 on December 21, 2005, 02:19:50 PM
That's odd... I remember doing tests with kof2002 and it did check the p2
Title: Re: King of Fighters 2003, The (Set 2)
Post by: magni 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
Title: Re: King of Fighters 2003, The (Set 2)
Post by: iq_132 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...
Title: Re: King of Fighters 2003, The (Set 2)
Post by: James33 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 :)
Title: Re: King of Fighters 2003, The (Set 2)
Post by: tcwlee on December 23, 2005, 09:56:25 AM
where is used in FBA0.294.98 SRC~~~~~
Title: Re: King of Fighters 2003, The (Set 2)
Post by: csog on March 25, 2006, 07:18:09 PM
Hi everybody!

I need help adding King of Fighters 2003 to FBA 2.95.23. I've succesfully compiled my own build with the changes suggested on this thread:

http://neo-source.com/index.php?topic=407.0

but the game appears as "not working" in the emulator, I load it anyway and it loads fine but then I just get a black screen.

This is the set I have, its the MVS version (? AFAIK):

271-c1c.bin             b1dc25d0
271-c2c.bin             d5362437
271-c3c.bin             0a1fbeab
271-c4c.bin             87b19a0c
271-c5c.bin             704ea371
271-c6c.bin             20a1164c
271-c7c.bin             189aba7f
271-c8c.bin             20ec4fdc
271-m1_decrypted.bin    0e86af8f
271-m1c.bin             f5515629
271-p1c.bin             530ecc14
271-p2c.bin             fd568da9
271-p3_decrypted.bin    59d376da
271-p3c.bin             aec5b4a9
271-v1c.bin             ffa3f8c7
271-v2c.bin             5382c7d1


any help would be appreciated.
Title: Re: King of Fighters 2003, The (Set 2)
Post by: iq_132 on March 26, 2006, 05:48:53 PM
Do you have kf2k3pcb working?  If so, please post the static int ...Init part.  And the init for kof2003 (mvs), and I'll see what I can do for you. ;)
Title: Re: King of Fighters 2003, The (Set 2)
Post by: csog on March 26, 2006, 10:06:13 PM
Do you have kf2k3pcb working?  If so, please post the static int ...Init part.
Nope, I just have the kof2003 MVS version romset.

Quote
  And the init for kof2003 (mvs), and I'll see what I can do for you. ;)
Sorry but I don't understand what you mean. :confused: Like I said I just followed the instructions given in that thread but I'm pretty much clueless about all the programming stuff sorry. :redface: Could you be more specific?

Thanks for the help.
Title: Re: King of Fighters 2003, The (Set 2)
Post by: iq_132 on March 27, 2006, 12:52:19 AM
lol I think you may be better off using ferchogtx's source ( http://fbap.1emulation.com )
There are a buttload of games in there and working, just strip out what you don't need.
Title: Re: King of Fighters 2003, The (Set 2)
Post by: csog on March 28, 2006, 10:05:37 PM
I already tried FBA Plus, but it seems like I'm missing a rom... I checked with clrmamepro and it says I'm missing the 271-m1c_decrypted.bin rom for the kof2003 MVS version romset. I assume it's the decrypted version of the 271-m1c.bin rom, right? if so, is there a way to decrypt the m1c rom to obtain the rom I'm missing?

Thanks again for the help.
Title: Re: King of Fighters 2003, The (Set 2)
Post by: iq_132 on March 31, 2006, 01:21:21 AM
lol, I meant you should try to compile fba plus.  If you're not happy with that, I can walk you through adding kof2003 (mvs) in a regular fba 0.2.95.23 source build.

Also, you can disable the crc checking in fbap. So if you want, you can just copy 271-m1_decrypted.bin and rename it 271-m1c_decrypted.
Title: Re: King of Fighters 2003, The (Set 2)
Post by: csog on March 31, 2006, 09:52:19 PM
Sorry for the misunderstanding. :biggrin:

Renaming the m1_decrypted rom worked fine, thanks. Just one question, I've been playing the game for a few minutes and so far so good, but does the missing m1c_decrypted rom has any noticeable effect on the game? i.e. graphic or sound glitches, etc?
Title: Re: King of Fighters 2003, The (Set 2)
Post by: Death Metal on April 01, 2006, 01:52:13 AM
Csog: no, not really. They're only different files (and that's why they differ CRCs), but they share the same code (Z80) for the same game, so don't worry.
Title: Re: King of Fighters 2003, The (Set 2)
Post by: csog on April 01, 2006, 06:34:05 PM
Oh I see, thanks for the info Death Metal... and also thanks iq_132 for the help. :smilie: