Author Topic: King of Fighters 2003 (Set 2)  (Read 21138 times)

Offline iq_132

  • Administrator
  • *****
  • Posts: 3728
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
King of Fighters 2003 (Set 2)
« on: December 18, 2005, 02:44:19 AM »
The rom struct:

Code: [Select]
ROM_START( kof2003a ) /* Encrypted Code + Sound + GFX Roms */
ROM_REGION( 0x900000, REGION_CPU1, 0 )
ROM_LOAD32_WORD_SWAP( "271-p1c.bin", 0x000000, 0x400000, CRC(530ecc14) SHA1(812cf7e9902af3f5e9e330b7c05c2171b139ad2b) )
ROM_LOAD32_WORD_SWAP( "271-p2c.bin", 0x000002, 0x400000, CRC(fd568da9) SHA1(46364906a1e81dc251117e91a1a7b43af1373ada) )
ROM_LOAD16_WORD_SWAP( "271-p3c.bin", 0x800000, 0x100000, CRC(aec5b4a9) SHA1(74087f785590eda5898ce146029818f86ced42b6) ) // Encrypted
ROM_LOAD16_WORD_SWAP( "271-p3d.bin", 0x800000, 0x100000, CRC(59d376da) SHA1(3c3ad0b79e8b37e838893a8f7b87e11d7eeee8f2) ) // Decrypted

/* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
ROM_REGION( 0x80000, REGION_GFX1, 0 ) /* larger char set */
ROM_FILL( 0x000000, 0x80000, 0 )
ROM_REGION( 0x20000, REGION_GFX2, 0 )
ROM_LOAD( "sfix.sfx",  0x000000, 0x20000, CRC(354029fc) )

ROM_REGION( 0x080000, REGION_USER4, 0 )
/* The M1 ROM is encrypted, we load it here for reference and replace it with a decrypted version */
ROM_LOAD( "271-m1c.bin", 0x00000, 0x080000, CRC(F5515629) SHA1(7516bf1b0207a3c8d41dc30c478f8d8b1f71304b) )
/* Decrypted */
NEO_BIOS_SOUND_512K( "271-m1c_decrypted.bin", CRC(4374CB5C) SHA1(d245a09fcebc8fe59f4af2de2fc30a0871e56d68) ) // Not 100%

ROM_REGION( 0x1000000, REGION_SOUND1, 0 )
/* Encrypted */
ROM_LOAD( "271-v1c.bin", 0x000000, 0x800000, CRC(ffa3f8c7) SHA1(7cf4a933973ca23b7f87c81151d8659e6ec4bd20) )
ROM_LOAD( "271-v2c.bin", 0x800000, 0x800000, CRC(5382c7d1) SHA1(1bf999705eda80ba1e7b0d6bdd010d9bfb18bd76) )

NO_DELTAT_REGION

ROM_REGION( 0x4000000, REGION_GFX3, 0 )
/* Encrypted */
ROM_LOAD16_BYTE( "271-c1c.bin", 0x0000000, 0x800000, CRC(b1dc25d0) SHA1(50adc3c60d5b4b3abd10a49db2267306c6dbd772) )
ROM_LOAD16_BYTE( "271-c2c.bin", 0x0000001, 0x800000, CRC(d5362437) SHA1(66db36522dc09106388c707252df9fe1c88b4856) )
ROM_LOAD16_BYTE( "271-c3c.bin", 0x1000000, 0x800000, CRC(0a1fbeab) SHA1(9fe30d36ba98d00fda010832ff2f27783dd577c1) )
ROM_LOAD16_BYTE( "271-c4c.bin", 0x1000001, 0x800000, CRC(87b19a0c) SHA1(b72a8e7d9124ce859b5149bb4381ba481c161ea5) )
ROM_LOAD16_BYTE( "271-c5c.bin", 0x2000000, 0x800000, CRC(704ea371) SHA1(e75b80422f0d72eac826f8ffadf79efeccaab124) )
ROM_LOAD16_BYTE( "271-c6c.bin", 0x2000001, 0x800000, CRC(20a1164c) SHA1(c9843b37612a16fc95f6851793b1cfb5d49d811d) )
ROM_LOAD16_BYTE( "271-c7c.bin", 0x3000000, 0x800000, CRC(189aba7f) SHA1(7152195a57ad36b28290810fe87ed8c206262ba9) )
ROM_LOAD16_BYTE( "271-c8c.bin", 0x3000001, 0x800000, CRC(20ec4fdc) SHA1(deb5f7ec5a090e419b9d1a6a74877bee081198e2) )
ROM_END

The Px decrypt I wrote, here's the short version (I prefer this)
Code: [Select]
void kof2003a_px_decrypt( void )
{
int i,j;
UINT8 *src = memory_region( REGION_CPU1 );
UINT8 *dst = 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) {
UINT16 *rom16 = (UINT16*)&dst[i + 1];
*rom16 = (*rom16&0xF00F) | BITSWAP8((*rom16>>4)&0xFF, 1, 0, 3, 2, 5, 4, 7, 6)<<4;
}

for(i = 0; i < 0x10; i++) {
j = (i & 0xf0) + BITSWAP8((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)
+ (BITSWAP8(((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2) << 12);
memcpy(src + i + 0x100000, dst + j, 0x100);
}

free(dst);
}

Here's the long version, more like what halrin would have posted
Code: [Select]
static void kof2003a_px_decrypt( void )
{
const unsigned char xor1[0x20] = {
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,
};

const unsigned char xor2[0x20] = {
0x2F, 0x02, 0x60, 0xBB, 0x77, 0x01, 0x30, 0x08, 0xD8, 0x01, 0xA0, 0xDF, 0x37, 0x0A, 0xF0, 0x65,
0x28, 0x03, 0xD0, 0x23, 0xD3, 0x03, 0x70, 0x42, 0xBB, 0x06, 0xF0, 0x28, 0xBA, 0x0F, 0xF0, 0x7A
};

int i;
int ofst;
UINT8 *rom, *buf;

rom = memory_region( REGION_CPU1 );

for( i = 0; i < 0x100000; i++ ){
rom[ i ] ^= xor1[ (i % 0x20) ];
}

for( i = 0x100000; i < 0x800000; i++ ){
rom[ i ] ^= xor2[ (i % 0x20) ];
}

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

buf = malloc( 0x800000 );
memcpy( buf, rom, 0x800000 );

for( i = 0; i < 0x0100000 / 0x10000; i++ ){
ofst = (i & 0xf0) + BITSWAP8( (i & 0x0f), 7, 6, 5, 4, 0, 1, 2, 3);
memcpy( &rom[ i * 0x10000 ], &buf[ ofst * 0x10000 ], 0x10000 );
}

for( i = 0x100000; i < 0x800000; i += 0x100 ){
ofst = (i & 0xf000ff) +
  ((i & 0x000f00) ^ 0x00800) +
  (BITSWAP8( ((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2 ) << 12);

memcpy( &rom[ i ], &buf[ ofst ], 0x100 );
}

free( buf );

buf = malloc(0x900000);
memcpy( buf, rom, 0x900000 );

memcpy( &rom[0x100000], &buf[0x800000], 0x100000 );
memcpy( &rom[0x200000], &buf[0x100000], 0x700000 );

free(buf);
}


Here's the init I'm using.  You need to add the extra stuff in neo_pcm2_swap for this.
Also, you will need the bankswitch code I posted here: [X]

Code: [Select]
DRIVER_INIT( kof2003a )
{
kof2003a_px_decrypt();
neo_pcm2_swap(5);
neogeo_fix_bank_type = 2;
kof2000_neogeo_gfx_decrypt(0x9d);

init_neogeo();

memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_r);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_w);
}

or if you prefer Halrin's bankswitch code:
Code: [Select]
DRIVER_INIT( kof2003a )
{
kof2003a_px_decrypt();
neo_pcm2_swap(5);
neogeo_fix_bank_type = 2;
kof2000_neogeo_gfx_decrypt(0x9d);

init_neogeo();

memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, MRA16_RAM );
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, MWA16_RAM );

memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fffe0, 0x2fffef, 0, 0, mv0_prot_r );
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fffe0, 0x2fffef, 0, 0, mv0_prot_w );

memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2ffff0, 0x2ffff3, 0, 0, mv0_bankswitch_r );
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2ffff0, 0x2ffff3, 0, 0, mv0_bankswitch_w );
}

Code: [Select]
GAMEB( 2003, kof2003a, kof2003, neogeo, neogeo, neogeo,  kof2003a,   ROT0, "SNK Playmore", "The King of Fighters 2003 (set 2)", 0 ) /* Encrypted Code & GFX */


Offline KingHanco

  • Sr. Member
  • ****
  • Posts: 401
  • Karma: +0/-4
  • "Special " Member
Re: King of Fighters 2003 (Set 2)
« Reply #1 on: December 18, 2005, 07:06:16 AM »
I gotting 2 errors and now fixs. I had to move those into the right place. Other wise it looking for those in the machine\neogeo.c.

Code: [Select]
DRIVER_INIT( kof2003a )
{
kof2003a_px_decrypt();
neo_pcm2_swap(5);
neogeo_fix_bank_type = 2;
kof2000_neogeo_gfx_decrypt(0x9d);

init_neogeo();

//memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_r); - Moved to the machine\neogeo.c
//memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_w); - Moved to the machine\neogeo.c
}

if (!strcmp(Machine->gamedrv->name,"svcchaos") || !strcmp(Machine->gamedrv->name,"svchaosa") || !strcmp(Machine->gamedrv->name,"kof2003a"))
        {
                memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_r);
                memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_w);
        }

Btw: I don't like Bush.
« Last Edit: December 18, 2005, 07:07:57 AM by KingHanco »

Offline Ashura-X

  • Member
  • ***
  • Posts: 138
  • Karma: +0/-0
Re: King of Fighters 2003 (Set 2)
« Reply #2 on: December 18, 2005, 08:46:11 AM »
Access violation on mame code here using mame32plus :S

C:\emul\mame>mamep kof2003a

-----------------------------------------------------
Exception at EIP=6EC908AA: ACCESS VIOLATION
While attempting to write memory at 6FAA77F6
-----------------------------------------------------
EAX=6E0177D6 EBX=00000005 ECX=01A90020 EDX=F0A82CBB
ESI=00C80001 EDI=06EB0020 EBP=0022F188 ESP=0022F110

Offline NeoKIM®

  • Newbies
  • *
  • Posts: 11
  • Karma: +0/-0
Re: King of Fighters 2003 (Set 2)
« Reply #3 on: December 18, 2005, 09:22:03 AM »
This is the version of INIT that I am using here. As not taste of the separate INIT, I decided to join everything! I find that it was better thus!

Code: [Select]
DRIVER_INIT( kof2003a )
{
int i,j;
UINT8 *src = memory_region( REGION_CPU1 );
UINT8 *dst = 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) {
UINT16 *rom16 = (UINT16*)&dst[i + 1];
*rom16 = (*rom16&0xF00F) | BITSWAP8((*rom16>>4)&0xFF, 1, 0, 3, 2, 5, 4, 7, 6)<<4;
}

for(i = 0; i < 0x10; i++) {
j = (i & 0xf0) + BITSWAP8((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)
+ (BITSWAP8(((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2) << 12);
memcpy(src + i + 0x100000, dst + j, 0x100);

}

neo_pcm2_swap(5);
neogeo_fix_bank_type = 2;
kof2000_neogeo_gfx_decrypt(0x9d);

memory_install_read16_handler (0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_r);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, pvc_prot_w);

init_neogeo();
}
Thanks

Offline Ashura-X

  • Member
  • ***
  • Posts: 138
  • Karma: +0/-0
Re: King of Fighters 2003 (Set 2)
« Reply #4 on: December 18, 2005, 11:52:25 AM »
Still the same error here !
I am wondering what could be this issue !!!  :idiot:


Never mind !!! HUGE THX Iq for your help !!!!!    :biggrin:
« Last Edit: December 18, 2005, 03:04:53 PM by Ashura-X »

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: King of Fighters 2003 (Set 2)
« Reply #5 on: December 19, 2005, 05:47:45 AM »
So this means this is now public . Looks like I have to go look for the M and P roms  :biggrin:
Hehe looks like I need a few hints to where these files might be .



Still the same error here !
I am wondering what could be this issue !!!  :idiot:


Never mind !!! HUGE THX Iq for your help !!!!!    :biggrin:

Is that the same error that kof2003 had and a line of code was needed in machine\neogeo.c ?
« Last Edit: December 19, 2005, 06:22:46 AM by James33 »
IQ Forum Member

Offline iq_132

  • Administrator
  • *****
  • Posts: 3728
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: King of Fighters 2003 (Set 2)
« Reply #6 on: December 20, 2005, 05:31:57 AM »
many people seem to be having the problem that they do not have svc/kof2003/samsh5/samsh5sp added to their v decrypt code
This will cause crashes

just replace the following function

Static void neo_pcm2_swap(...


with this

Code: [Select]
static void neo_pcm2_swap(int value) /* 0=kof2002, 1=matrim, 2=mslug5, 3=samsho5, 4=svcchaos, 5=kof2003, 6=samsh5sp */
{
unsigned int addrs[7][2]={
{0x000000,0xA5000},
                {0xFFCE20,0x01000},
                {0xFE2CF6,0x4E001},
                {0xFEB2C0,0x0A000},
                {0xFFAC28,0xC2000},
                {0xFF14EA,0xA7001},
                {0xFFB440,0x02000},
                };
       unsigned int xordata[7][8]={
                {0xF9,0xE0,0x5D,0xF3,0xEA,0x92,0xBE,0xEF},
                {0xC4,0x83,0xA8,0x5F,0x21,0x27,0x64,0xAF},
                {0xC3,0xFD,0x81,0xAC,0x6D,0xE7,0xBF,0x9E},
                {0xCB,0x29,0x7D,0x43,0xD2,0x3A,0xC2,0xB4},
                {0xC3,0xFD,0x81,0xAC,0x6D,0xE7,0xBF,0x9E},
                {0x4B,0xA4,0x63,0x46,0xF0,0x91,0xEA,0x62},
                {0x4B,0xA4,0x63,0x46,0xF0,0x91,0xEA,0x62},
                };
UINT8 *src = memory_region(REGION_SOUND1);
UINT8 *buf = malloc(0x1000000);
int i, j, d;

memcpy(buf,src,0x1000000);
for (i=0;i<0x1000000;i++)
{
j=BITSWAP24(i,23,22,21,20,19,18,17,0,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,16);
j=j^addrs[value][1];
d=((i+addrs[value][0])&0xffffff);
src[j]=buf[d]^xordata[value][j&0x7];
}
free(buf);
}


Offline KingHanco

  • Sr. Member
  • ****
  • Posts: 401
  • Karma: +0/-4
  • "Special " Member
Re: King of Fighters 2003 (Set 2)
« Reply #7 on: December 20, 2005, 07:46:24 AM »
many people seem to be having the problem that they do not have svc/kof2003/samsh5/samsh5sp added to their v decrypt code
This will cause crashes

just replace the following function

Static void neo_pcm2_swap(...

Hmmm...I'm using this static void neo_pcm2_playmore_2002(int value) and I will change it to what you just post now.

I will update all to neo_pcm2_swap(?) as well.

Not that the way that I have it that isn't hurting anything at all. Just keeping update.

===============================================================

Hmmm...it was here error. I found it though.

Code: [Select]
static void neo_pcm2_swap(int value) /* 0=kof2002, 1=matrim */
{
unsigned int addrs[2][2]={
{0x000000,0xA5000}, /* kof2002 */
{0xFFCE20,0x01000}}; /* matrimelee */
unsigned int xordata[2][8]={
{0xF9,0xE0,0x5D,0xF3,0xEA,0x92,0xBE,0xEF}, /* kof2002 */
{0xC4,0x83,0xA8,0x5F,0x21,0x27,0x64,0xAF}}; /* matrim */
UINT8 *src = memory_region(REGION_SOUND1);
UINT8 *buf = malloc(0x1000000);
int i, j, d;

memcpy(buf,src,0x1000000);
for (i=0;i<0x1000000;i++)
{
j=BITSWAP24(i,23,22,21,20,19,18,17,0,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,16);
j=j^addrs[value][1];
d=((i+addrs[value][0])&0xffffff);
src[j]=buf[d]^xordata[value][j&0x7];
}
free(buf);
}

I will replace it then and moved the one in the kof2003 as well. I don't need 2 the same thing. :)
« Last Edit: December 20, 2005, 08:20:04 AM by KingHanco »

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: King of Fighters 2003 (Set 2)
« Reply #8 on: December 20, 2005, 07:17:13 PM »
many people seem to be having the problem that they do not have svc/kof2003/samsh5/samsh5sp added to their v decrypt code
This will cause crashes



Yeah I have had this for a very long time now :)
IQ Forum Member

Offline oliverkof

  • Newbies
  • *
  • Posts: 13
  • Karma: +0/-0
Re: King of Fighters 2003 (Set 2)
« Reply #9 on: December 21, 2005, 08:11:10 PM »
I counldn't switch the region (eg from euro to Japan!)!? :idiot:

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: King of Fighters 2003 (Set 2)
« Reply #10 on: December 22, 2005, 05:23:37 AM »
you need to delete the kof2003a.nv from the NVRAM folder when changeing the bios .
IQ Forum Member

Offline oliverkof

  • Newbies
  • *
  • Posts: 13
  • Karma: +0/-0
Re: King of Fighters 2003 (Set 2)
« Reply #11 on: December 23, 2005, 09:04:58 PM »
you need to delete the kof2003a.nv from the NVRAM folder when changeing the bios .

I deleted th kof2003a.nv and changed the japanese bios. but the language is still english, not japanese.
By the way, for all other neogeo games, i don't need to delete the .nv file in order to switch the region, just need to change the bios.! :idiot:

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: King of Fighters 2003 (Set 2)
« Reply #12 on: December 23, 2005, 09:46:46 PM »
I think thats is because of the rom . If you go into the bios by pressing F2 you will see that the language is in Jap .

And it is wise to delete the nvram for the changes to take affect properly .
IQ Forum Member

Offline kispista

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
Re: King of Fighters 2003 (Set 2)
« Reply #13 on: December 25, 2005, 03:25:17 AM »
Any patches to get these CRCs?
271-m1c.bin  F5515629
271-p3c.bin  AEC5B4A9

Thanks and Marry Christmas!

Offline iq_132

  • Administrator
  • *****
  • Posts: 3728
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: King of Fighters 2003 (Set 2)
« Reply #14 on: December 27, 2005, 02:57:07 AM »
From what sources?