Author Topic: May I have help to get back on track plz?  (Read 8033 times)

Offline Cookie Monstruo

  • Newbies
  • *
  • Posts: 17
  • Karma: +0/-0
May I have help to get back on track plz?
« on: July 25, 2005, 03:22:28 AM »
as a mentioned in a different thread, I have fallen behind and I plan to get back on track

the last time I attempted this sort of thing was back in february, but I didn't have as much time

anyway, I noticed there have been a lot of rom changes. So I have some quesitons

is there currently a working driver for this kof2003 set

I tried checking on that one kof2003 thread but I didn't find any other stuff about it (like decryption and what not)

and I notice some roms for kof10th were changed and this is the set I have. Is there a driver for that, I also noticed there were changes to it, is there a patch for it or do I have to go hunt/ask ppl?

I tried checking in the fbaplus source but I found that a whole lot of the code had been changed so I figure I just stick to compiling my own build

Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Re: May I have help to get back on track plz?
« Reply #1 on: July 25, 2005, 07:51:18 PM »
For kof2003 you'll need the following code to get it working (already on fbaplus, aplies for 0.2.95.23)
add this to the top of neogeo.h and delete this from other neogeo src's
Code: [Select]
#include "bitswap.h"Now add this in neogeo.h:
Code: [Select]
extern int nNeoPCM2SNKProtection;
extern int nNeoPCM2PLAYMOREProtection;
extern int nNeoTextROMFixType;
now in neo_run.cpp look for this:
Code: [Select]
static int nSRAMProtAddress;add this BEFORE
Code: [Select]
int nNeoPCM2SNKProtection = 0;
int nNeoPCM2PLAYMOREProtection = 0;
int nNeoTextROMFixType = 0;
look for this:
Code: [Select]
static unsigned char *Neo68KBIOS, *Neo68KVectors, *NeoZ80BIOS;delete "static" statement in that line
look for this:
Code: [Select]
Neo68KBIOS = Next; Next += 0x20000; // 68K boardROMreplace "0x20000" with "nCodeSize"
look for this:
Code: [Select]
if ((BurnDrvGetHardwareCode() & HARDWARE_SNK_CONTROLMASK) == HARDWARE_SNK_TRACKBALL) {
nNewBIOS = 9;
}
add this after:
Code: [Select]
if ((BurnDrvGetHardwareCode() & HARDWARE_SNK_CONTROLMASK) == HARDWARE_SNK_PCB_BIOS) {
nNewBIOS = 10;
}
OPTIONAL look for this:
Code: [Select]
// Load the BIOS ROMs
if (nBIOS >= 0) {
BurnLoadRom(Neo68KBIOS, 0x00080 + nBIOS, 1);
} else {
BurnLoadRom(Neo68KBIOS, 0x00080 +     6, 1);
}
add this after:
Code: [Select]
// Hacks for Neo-Geo MVS BIOS
// Thanks to IQ_132 & BisonSAS for the patches and info
if (nBIOS < 3 || nBIOS == 9 || nBIOS == 10) {
int ofst = 0;
if (nBIOS == 0)  ofst = 0x1C28; // (vs-bios.rom) JP, MVS, ? slot, Ver. 5
// if (nBIOS == 0)  ofst = 0x1B00; // (sp-j2.rom) JP, MVS, ? slot, Ver. 5
// (sp1.jipan.1024) JP, MVS, 4 slot, Ver. 3
if (nBIOS == 1)  ofst = 0x1AD6; // (usa_2slt.bin) US, MVS, 2 slot, Ver. 5
// (sp-e.sp1) AS, MVS, 6 slow, Ver. 5
if (nBIOS == 2)  ofst = 0x0B00; // (asia-s3.rom) AS, MVS, 1 slot, Ver. 6, no z80 BIOS
// if (nBIOS == 2)  ofst = 0x1B00; // (sp-s.sp1) AS, MVS, 4 slot, Ver. 3
// (sp-s2.sp1) AS, MVS, 1 slot, Ver. 5
if (nBIOS == 9)  ofst = 0x0C2A; // (236-bios.bin) AS, MVS, ? slot, Ver  T1 (irrmaze BIOS)
if (nBIOS == 10) ofst = 0x0C24; // (271-bios.bin) JP, MVS, ? slot, Ver. 6  (kof2003 BIOS)

//#if defined NEOGEO_HACKS
// Remove memory check for now
*((unsigned short*)(Neo68KBIOS + ofst + 0x010000)) = 0x4E71;
*((unsigned short*)(Neo68KBIOS + ofst + 0x010002)) = 0x4E71;
*((unsigned short*)(Neo68KBIOS + ofst + 0x010016)) = 0x4EF9;
*((unsigned short*)(Neo68KBIOS + ofst + 0x010018)) = 0x00C1;
*((unsigned short*)(Neo68KBIOS + ofst + 0x01001A)) = 0x006A + ofst;

// Patch Calendar errors
*((unsigned short*)(Neo68KBIOS + ofst + 0x010114)) = 0x4E71;
*((unsigned short*)(Neo68KBIOS + ofst + 0x010116)) = 0x4E71;
*((unsigned short*)(Neo68KBIOS + ofst + 0x01011C)) = 0x4E71;
*((unsigned short*)(Neo68KBIOS + ofst + 0x01011E)) = 0x4E71;
//#endif // NEOGEO_HACKS

// Patch checksum test
*((unsigned short*)(Neo68KBIOS + ofst + 0x010162)) = 0x4E71;
*((unsigned short*)(Neo68KBIOS + ofst + 0x010164)) = 0x4E71;
}
Look for this:
Code: [Select]
if (pInfo->nTextOffset != -1) {
// Load S ROM data
BurnLoadRom(NeoTextROM + 0x020000, pInfo->nTextOffset, 1);
add ALL this after:
Code: [Select]
switch (nNeoTextROMFixType) {
// Original code for MAME by fataku
case 1: {
        for ( int i = 0; i < 0x20000; i++ ) {
        (NeoTextROM+0x20000)[i] = BITSWAP08((NeoTextROM+0x20000)[i],3,2,4,5,1,6,0,7);
        }
        break;
}
// Original code from mame traduced by FerchogtX
case 2: {
unsigned char* tmp = (unsigned char*)malloc(0x20000);
memcpy( tmp + 0x000000, NeoTextROM + 0x020000 + 0x010000, 0x010000 );
memcpy( tmp + 0x010000, NeoTextROM + 0x020000 + 0x000000, 0x010000 );
memcpy( NeoTextROM + 0x20000, tmp, 0x020000 );
free( tmp );
break;
}
// Thanks also to HappyASR for the info
case 3: {
unsigned char* tmp = (unsigned char*)malloc(0x20000);
if (tmp) {
memcpy( tmp, NeoTextROM + 0x20000, 0x20000 );
// descrambling the S1 by dorriGa
for ( int j = 0; j < 0x20000; j += 0x000010 ) {
memcpy( NeoTextROM + 0x20000 + j, tmp + j + 0x000008, 8);
memcpy( NeoTextROM + 0x20000 + j + 0x000008, tmp + j, 8);
}
}
free( tmp );
break;
}
// Original code by HalRIN
case 4: {
unsigned char* tmp = (unsigned char*)malloc(0x40000);
int i, ofst;

memcpy( tmp, NeoTextROM + 0x20000, 0x40000 );
for( i = 0; i < 0x40000; i++ ) {
ofst = BITSWAP24((i & 0x1ffff),23,22,21,20,19,18,17,3,0,1,4,2,13,14,16,15,5,6,11,10,9,8,7,12);
ofst += (i >> 17) << 17;
(NeoTextROM+0x20000)[i] = tmp[ofst];
}
memcpy( tmp, NeoTextROM + 0x20000, 0x40000 );
memcpy( NeoTextROM + 0x20000 + 0x08000, tmp + 0x10000, 0x8000 );
memcpy( NeoTextROM + 0x20000 + 0x10000, tmp + 0x08000, 0x8000 );
memcpy( NeoTextROM + 0x20000 + 0x28000, tmp + 0x30000, 0x8000 );
memcpy( NeoTextROM + 0x20000 + 0x30000, tmp + 0x28000, 0x8000 );
free( tmp );
break;
}
// Converted by Jimmy_Page (www.neofighters.com)
case 5: {
for ( int i = 0; i < 0x20000; i++ ) {
(NeoTextROM+0x20000)[i] = BITSWAP08((NeoTextROM+0x20000)[i],7,6,0,4,3,2,1,5);
}
break;
}
// Thanks to IQ_132, this is to keep saving the descrambled data when needed
case 6: {
// kof2002b_gfx_decrypt(NeoTextROM + 0x20000, 0x20000);
break;
}
}
look for this:
Code: [Select]
// Extract data from the end of C ROMS
BurnUpdateProgress(0.0, _T("Generating text layer graphics..."), 0);
NeoExtractSData(NeoSpriteROM, NeoTextROM + 0x020000, nSpriteSize, nNeoTextROMSize);
add this after:
Code: [Select]
// Original convertion by IQ_132 (This is for svcchaos, kof2003 and clones)
if (nNeoTextROMFixType == 7) {
for( int i = 0; i < nNeoTextROMSize; i++ ) {
(NeoTextROM+0x20000)[i] = BITSWAP08((NeoTextROM+0x20000)[i]^0xd2,4,0,7,2,5,1,6,3);
}
}
look for this:
Code: [Select]
if (BurnDrvGetHardwareCode() & HARDWARE_SNK_SWAPV) {
for (int i = 0; i < 0x00200000; i++) {
unsigned char n = YM2610ADPCMAROM[i];
YM2610ADPCMAROM[i] = YM2610ADPCMAROM[0x00200000 + i];
YM2610ADPCMAROM[0x00200000 + i] = n;
}
}
add this after:
Code: [Select]
// Neo-PCM2 SNK(c) 1999 Sound Chip Emulation
// Original code by the MAME team, converted to FBA code by IQ_132
if (nNeoPCM2SNKProtection != 0) {
// thanks to ElSemi for the NEO-PCM2 info
unsigned short *rom = (unsigned short*)(YM2610ADPCMAROM);
int value = nNeoPCM2SNKProtection;
if( rom != NULL ) {
// swap address lines on the whole ROMs
unsigned short *buffer = (unsigned short*)malloc((value / 2) * sizeof(unsigned short));
if (!buffer) return 1;
for(int i = 0; i < nYM2610ADPCMASize / 2; i += (value / 2) ) {
memcpy( buffer, &rom[ i ], value );
for(int j = 0; j < (value / 2); j++ ) {
rom[ i + j ] = buffer[ j ^ (value / 4) ];
}
}
free(buffer);
}
}

// Neo-PCM2 PLAYMORE(c) 2002 Sound Chip Emulation
// Some code by Fataku & some by the vconv (from 2ch) - FBA conversion by iq_132
if (nNeoPCM2PLAYMOREProtection != 0) {
unsigned int addrs[7][2] = {
{0x000000,0xA5000}, //kof2002
{0xFFCE20,0x01000}, //matrimelee
{0xFE2CF6,0x4E001}, //mslug5
{0xFEB2C0,0x0A000}, //samsho5
{0xFFAC28,0xC2000}, //svcchaos
{0xFF14EA,0xA7001}, //kof2003
{0xFFB440,0x02000}, //samsh5sp
};
        unsigned int xordata[7][8] = {
{0xF9,0xE0,0x5D,0xF3,0xEA,0x92,0xBE,0xEF}, //kof2002
{0xC4,0x83,0xA8,0x5F,0x21,0x27,0x64,0xAF}, //matrimelee
{0xC3,0xFD,0x81,0xAC,0x6D,0xE7,0xBF,0x9E}, //mslug5
{0xCB,0x29,0x7D,0x43,0xD2,0x3A,0xC2,0xB4}, //samsho5
{0xC3,0xFD,0x81,0xAC,0x6D,0xE7,0xBF,0x9E}, //svcchaos
{0x4B,0xA4,0x63,0x46,0xF0,0x91,0xEA,0x62}, //kof2003
{0x4B,0xA4,0x63,0x46,0xF0,0x91,0xEA,0x62}, //samsh5sp
};

int value = (nNeoPCM2PLAYMOREProtection - 1);
unsigned char *rom = YM2610ADPCMAROM;
unsigned char *buf = (unsigned char*)malloc(0x1000000);
int ofst;

memcpy(buf,rom,0x1000000);
for(int i=0; i<0x1000000; i++) {
ofst = (i & 0xfefffe) | ((i & 0x010000) >> 16) | ((i & 0x000001) << 16);
ofst ^= addrs[value][1];
rom[ofst] = (buf[((i + addrs[value][0]) & 0xffffff)] ^ xordata[value][(ofst & 0x07)]);
}
free(buf);
}
look for this:
Code: [Select]
if (nBIOS == -1 || nBIOS == 9) {
// Write system type & region code into BIOS ROM
*((unsigned short*)(Neo68KBIOS + 0x000400)) = ((NeoSystem & 4) << 13) | (NeoSystem & 0x03);
}
replace with this:
Code: [Select]
if (nBIOS == -1 || nBIOS == 9 || nBIOS == 10) {
// Write system type & region code into BIOS ROM
*((unsigned short*)(Neo68KBIOS + 0x000400)) = ((NeoSystem & 4) << 13) | (NeoSystem & 0x03);
}
look for this:
Code: [Select]
if ((BurnDrvGetHardwareCode() & HARDWARE_SNK_CONTROLMASK) != HARDWARE_SNK_GAMBLING) {
SekMapMemory(Neo68KROM + nNeo68KROMBank, 0x200000, 0x2FFFFF, SM_ROM);
}
replace with this:
Code: [Select]
if ((BurnDrvGetHardwareCode() & HARDWARE_SNK_CONTROLMASK) != HARDWARE_SNK_GAMBLING) {
if (!(BurnDrvGetHardwareCode() & HARDWARE_SNK_CUSTOM_BANKING)) {
SekMapMemory(Neo68KROM + nNeo68KROMBank, 0x200000, 0x2FFFFF, SM_ROM);
}
}
find this:
Code: [Select]
nNeoSRAMProtection = -1;
nNeoTextROMSize = -1;
add this after:
Code: [Select]
nNeoPCM2SNKProtection = 0; // Exits Neo-PCM2 emulation
nNeoPCM2PLAYMOREProtection = 0;
nNeoTextROMFixType = 0; // Exit text layer fix
In neogeo.cpp:
replace the whole NeoLoadCode funtion with this one:
Code: [Select]
// This function loads the 68K ROMs (fix by NetBug)
int NeoLoadCode(int nOffset, int nNum, unsigned char* pDest)
{
int nRomSize = 0;
unsigned char* pROM = pDest;
struct BurnRomInfo ri;

// Load the ROMs
for (int i = 0; i < nNum; i++) {
ri.nType = 0;
ri.nLen = 0;
      BurnDrvGetRomInfo(&ri,nOffset+i);
      nRomSize =ri.nLen;
   
if (BurnLoadRom(pROM, nOffset + i, 1)) {
return 1;
}

pROM +=nRomSize;

BurnDrvGetRomInfo(&ri, nOffset + i);
// Swap the blocks in the ROM if needed.
if (BurnDrvGetHardwareCode() & HARDWARE_SNK_SWAPP && i && ri.nLen == 0x400000) {
for (unsigned int k = 0; k < (ri.nLen >> 1); k++) {
unsigned char n = pROM[k];
pROM[k] = pROM[k + (ri.nLen >> 1)];
pROM[k + (ri.nLen >> 1)] = n;
}
}

// Swap the blocks in the ROM if needed.
if (BurnDrvGetHardwareCode() & HARDWARE_SNK_SWAPP && nRomSize == 0x200000) {
for (int j = 0; j < nNum; j++) {
for (int k = 0; k < (nRomSize >> 1); k++) {
unsigned char n = pDest[k];
pDest[k] = pDest[k + (nRomSize >> 1)];
pDest[k + (nRomSize >> 1)] = n;
}
}
}
}

return 0;
}
Continues on next post...
« Last Edit: July 25, 2005, 08:02:36 PM by FerchogtX »

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
Re: May I have help to get back on track plz?
« Reply #2 on: July 25, 2005, 07:57:52 PM »
in neo_decrypt.cpp:
replace the whole NeoExtractSData function with this one:
Code: [Select]
// FBA addy by IQ_132 - http://neosource.1emu.net/
void NeoExtractSData(unsigned char* rom, unsigned char* sdata, int rom_size, int sdata_size)
{
int i;
// the S data comes from the end fo the C data
if (sdata_size == 0x100000) {
// 1 MB of data, special for kof2003 PCB
rom += rom_size - sdata_size /2;
for (i = 0; i < sdata_size / 2; i++) {
sdata[i + 0] = rom[(i & ~0x1F) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4) - 0x1000000 ];
sdata[i + sdata_size / 2] = rom[(i & ~0x1F) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4)];
  }
} else {
// Normal data extraction
  rom += rom_size - sdata_size;
for (i = 0; i < sdata_size; i++) {
sdata[i] = rom[(i & ~0x1F) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4)];
  }
}
}
in d_neogeo.cpp:
add the following code after the PCM2 protection ones:
Code: [Select]
// ---------------------------------------------------------
// Extra code for Neo-PVC Protection

// Code by iq_132 -- http://neosource.1emu.net/
static void interleave_pdata()
{
int j=0,i;
unsigned char* pTemp = (unsigned char*)malloc(0x800000);
for (i = 0; i < 0x800000; i = i+4) {
pTemp[ i+0 ] = Neo68KROM[ j ];
pTemp[ i+1 ] = Neo68KROM[ j+1 ];
pTemp[ i+2 ] = Neo68KROM[ j+0x400000 ];
pTemp[ i+3 ] = Neo68KROM[ j+0x400001 ];
j = j+2;
}
memcpy( Neo68KROM, pTemp, 0x800000 );
free( pTemp );
}

// Neo-PVC Code for PCB and MVS games with this protection
// Original code by(?) HalRIN -- http://www52.tok2.com/home/foge/
// Converted to FBA code by iq_132 -- http://neosource.1emu.net/
static void neo_pvc(int game)
{
unsigned int xor1[ 2 ][ 0x20 ] = { // kof2003 does not use XOR 1
{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},
{0xc2, 0x4b, 0x74, 0xfd, 0x0b, 0x34, 0xeb, 0xd7, 0x10, 0x6d, 0xf9, 0xce, 0x5d, 0xd5, 0x61, 0x29,
0xf5, 0xbe, 0x0d, 0x82, 0x72, 0x45, 0x0f, 0x24, 0xb3, 0x34, 0x1b, 0x99, 0xea, 0x09, 0xf3, 0x03},
};

unsigned int xor2[ 3 ][ 0x20 ] = {
{0xb4, 0x0f, 0x40, 0x6c, 0x38, 0x07, 0xd0, 0x3f, 0x53, 0x08, 0x80, 0xaa, 0xbe, 0x07, 0xc0, 0xfa,
0xd0, 0x08, 0x10, 0xd2, 0xf1, 0x03, 0x70, 0x7e, 0x87, 0x0B, 0x40, 0xf6, 0x2a, 0x0a, 0xe0, 0xf9},
{0x69, 0x0b, 0x60, 0xd6, 0x4f, 0x01, 0x40, 0x1a, 0x9f, 0x0b, 0xf0, 0x75, 0x58, 0x0e, 0x60, 0xb4,
0x14, 0x04, 0x20, 0xe4, 0xb9, 0x0d, 0x10, 0x89, 0xeb, 0x07, 0x30, 0x90, 0x50, 0x0e, 0x20, 0x26},
{0x36, 0x09, 0xb0, 0x64, 0x95, 0x0f, 0x90, 0x42, 0x6e, 0x0f, 0x30, 0xf6, 0xe5, 0x08, 0x30, 0x64,
0x08, 0x04, 0x00, 0x2f, 0x72, 0x09, 0xa0, 0x13, 0xc9, 0x0b, 0xa0, 0x3e, 0xc2, 0x00, 0x40, 0x2b},
};

int i, ofst, ofst2 = 0x00300;
unsigned char* pTemp = (unsigned char*)malloc( 0x800000 );

if (game != 1)
for( i = 0; i < 0x100000; i++ )
Neo68KROM[ i ] ^= xor1[ game-2 ][ (i % 0x20) ];

for( i = 0x100000; i < 0x800000; i++ )
Neo68KROM[ i ] ^= xor2[ game-1 ][ (i % 0x20) ];

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

memcpy( pTemp, Neo68KROM, 0x800000 );

for( i = 0; i < 0x10; i++ ){
ofst = (i & 0xf0) + BITSWAP08( (i & 0x0f), 7, 6, 5, 4, 1, 0, 3, 2 );
if (game==2) ofst = (i & 0xf0) + BITSWAP08( (i & 0x0f), 7, 6, 5, 4, 2, 3, 0, 1 );
memcpy( &Neo68KROM[ i * 0x10000 ], &pTemp[ ofst * 0x10000 ], 0x10000 );
}

for( i = 0x100000; i < 0x800000; i += 0x100 ){
if (game==2) ofst2=0x00a00;
ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ ofst2) + (BITSWAP08( ((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2 ) << 12);
if (game==3)
ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00700) + (BITSWAP08( ((i & 0x0ff000) >> 12), 5, 4, 7, 6, 1, 0, 3, 2 ) << 12);
memcpy( &Neo68KROM[ i ], &pTemp[ ofst ], 0x100 );
}

if (game == 1) {
pTemp= (unsigned char*)malloc( 0x900000 );
memcpy( pTemp, Neo68KROM, 0x900000 );
memcpy( &Neo68KROM[ 0x100000 ], &pTemp[ 0x800000 ], 0x100000 );
memcpy( &Neo68KROM[ 0x200000 ], &pTemp[ 0x100000 ], 0x700000 );
} else {
pTemp = (unsigned char*)malloc( 0x800000 );
memcpy( pTemp, Neo68KROM, 0x800000 );
memcpy( &Neo68KROM[ 0x100000 ], &pTemp[ 0x700000 ], 0x100000 );
memcpy( &Neo68KROM[ 0x200000 ], &pTemp[ 0x100000 ], 0x600000 );
}
free(pTemp);
}

// Universal Read-Handlers for PVC Protected boards
static unsigned short CartRAM[0x1000];

unsigned char *NeoCartRAM = (unsigned char *)CartRAM; // for save states

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 mv0ReadByteBankSwitch(unsigned int sekAddress)
{
return pvc_r8(sekAddress);
}

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

// Bankswitch #1 for PVC protected carts / boards
void mv0WriteBankswitch() // 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;
Neo68KROM[0x58196] = pvc_r8(0x2ffff3);
SekMapMemory(Neo68KROM+0x100000+offset,0x200000,0x2fdfff,SM_ROM);
}

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

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

// Bankswitch #2 for PVC protected carts / boards
// These perform some palette calculations
// Unpack palette word to RGB dword, thanks to bms888
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 mv0WriteProtection() // 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);
}

void __fastcall mv0WriteByteProtection(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)mv0WriteProtection();
}

void __fastcall mv0WriteWordProtection(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)mv0WriteProtection();
}
add this in the DIPs section
Code: [Select]
static struct BurnDIPInfo neopcbDIPList[] = {
// Offset
{0x19, 0xF0, 0x00, 0x00, NULL},

// Defaults
{0x00, 0xFF, 0xFF, 0x00, NULL},
{0x01, 0xFF, 0x7F, 0x00, NULL},
// Fake DIPs
{0x02, 0xFF, 0xFF, 0x86, NULL},

{0, 0xFE, 0, 2,   "Autofire"},
{0x0D, 0x01, 0x04, 0x00, "Off"},
{0x0D, 0x01, 0x04, 0x04, "On"},

// DIP 1
{0, 0xFE, 0, 2,   "Setting mode"},
{0x00, 0x01, 0x01, 0x00, "Off"},
{0x00, 0x01, 0x01, 0x01, "On"},

// 1 or 2 coin slots
{0, 0xFE, 0, 2,   "Coin chutes"},
{0x00, 0x02, 0x02, 0x00, "1"},
{0x02, 0x00, 0x3F, 0x06, NULL},
{0x00, 0x02, 0x02, 0x02, "2"},
{0x02, 0x00, 0x3F, 0x06, NULL},
// 2 or 4 coin slots
{0, 0xFE, 0, 2,   "Coin chutes"},
{0x00, 0x82, 0x02, 0x00, "2"},
{0x02, 0x00, 0x3F, 0x06, NULL},
{0x00, 0x82, 0x02, 0x02, "4"},
{0x02, 0x00, 0x3F, 0x06, NULL},

{0, 0xFE, 0, 5,   "Commmunicaton"},
{0x00, 0x01, 0x38, 0x00, "Disabled"},
{0x00, 0x01, 0x38, 0x08, "Setting 1"},
{0x00, 0x01, 0x38, 0x10, "Setting 2"},
{0x00, 0x01, 0x38, 0x18, "Setting 3"},
{0x00, 0x01, 0x38, 0x20, "Setting 4"},
{0x00, 0x01, 0x38, 0x28, "Setting 5"},
{0x00, 0x01, 0x38, 0x30, "Setting 6"},
{0x00, 0x01, 0x38, 0x38, "Setting 7"},
{0, 0xFE, 0, 2,   "Free play"},
{0x00, 0x01, 0x40, 0x00, "Off"},
{0x00, 0x01, 0x40, 0x40, "On"},
{0, 0xFE, 0, 2,   "Stop mode"},
{0x00, 0x01, 0x80, 0x00, "Off"},
{0x00, 0x01, 0x80, 0x80, "On"},

// MVS/AES system
{0, 0xFD, 0, 2,   NULL},
{0x02, 0x82, 0x04, 0x04, "MVS system"},
{0x02, 0x00, 0x30, 0x30, NULL},
{0x02, 0x82, 0x04, 0x00, "AES system"},
{0x02, 0x00, 0x30, 0x30, NULL},
// Region
{0, 0xFD, 0, 3,   "Region"},
{0x02, 0x02, 0x03, 0x00, "Japan"},
{0x02, 0x00, 0x30, 0x00, NULL},
{0x02, 0x02, 0x03, 0x01, "USA"},
{0x02, 0x00, 0x30, 0x00, NULL},
{0x02, 0x02, 0x03, 0x02, "Asia / Europe"},
{0x02, 0x00, 0x30, 0x00, NULL},
{0x02, 0x02, 0x03, 0x03, "Japan"},
{0x02, 0x00, 0x30, 0x00, NULL},

// Memory card
{0, 0xFD, 0, 2,   "Memory card"},
{0x0F, 0x01, 0x80, 0x80, "Writable"},
{0x0F, 0x01, 0x80, 0x00, "Write-protected"},
{0, 0xFD, 0, 2,   "Default card type"},
{0x0F, 0x01, 0x40, 0x40, "1 Megabit"},
{0x0F, 0x01, 0x40, 0x00, "Normal"},
};
look for this:
Code: [Select]
STDDIPINFO(neotrackball);add this after:
Code: [Select]
STDDIPINFO(neopcb);look for:
Code: [Select]
STD_ROM_FN(neotrackball);add this after:
Code: [Select]
static struct BurnRomInfo neopcbRomDesc[] = {
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },

{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },
{ "271-bios.bin",   0x040000, 0xc521b5bc, BRF_BIOS },
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },

{ "sm1.sm1",        0x020000, 0x97Cf998B, BRF_ESS | BRF_PRG | BRF_BIOS }, // 10 Z80 program
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },

{ "sfix.sfx",       0x020000, 0x354029FC, BRF_GRA | BRF_BIOS }, // 14 Text layer tiles
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },
{ "",                      0,          0, 0 },

{ "000-lo.lo",      0x010000, 0xE09E253C, BRF_ESS | BRF_PRG | BRF_BIOS }, // 18 Zoom table
};


STD_ROM_PICK(neopcb);
STD_ROM_FN(neopcb);
now finally add the following drivers:
Code: [Select]
// The King of Fighters 2003 (PCB board)

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 (decrypted)
{ "271-p3.bin",  0x100000, 0x5cefd0d2,  0 | BRF_PRG | BRF_OPT }, //  3

{ "271-c1.bin",  0x1000000, 0xf5ebb327, 3 | BRF_GRA }, //  4 Sprite data
{ "271-c2.bin",  0x1000000, 0x2be21620, 3 | BRF_GRA }, //  5
{ "271-c3.bin",  0x1000000, 0xddded4ff, 3 | BRF_GRA }, //  6
{ "271-c4.bin",  0x1000000, 0xd85521e6, 3 | BRF_GRA }, //  7
{ "271-c5.bin",  0x1000000, 0x1c40de87, 3 | BRF_GRA }, //  8 (The last 2 Cx roms contains S1-ROM)
{ "271-c6.bin",  0x1000000, 0x18aa3540, 3 | BRF_GRA }, //  9 (data only, no sprite data)

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

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

STDROMPICKEXT(kof2003, kof2003, neopcb);
STD_ROM_FN(kof2003);

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

// 0x4EF9 for Good CRC, 0x4E75 to patch black screen with ASM core
*((unsigned short*)(Neo68KROM + 0x0816)) = 0x4E75;
}

static int kof2003Init()
{
int nRet;
extern unsigned char *Neo68KBIOS;

memset(CartRAM,0,sizeof(CartRAM));

pNeoInitCallback = kof2003PVCDecrypt;
nNeoTextROMSize = 0x100000;
nNeoProtectionXor = 0x9d;
nNeoTextROMFixType = 7;
nNeoPCM2PLAYMOREProtection = 6;

nRet = NeoInit();
if (nRet == 0) {
// Install BankSwitch handler
SekMapHandler(5,    0x2fe000, 0x2fffff, SM_READ);
SekSetReadWordHandler(5,  mv0ReadWordBankSwitch);
SekSetReadByteHandler(5,  mv0ReadByteBankSwitch);

SekMapHandler(5,    0x2fe000, 0x2fffff, SM_WRITE);
SekSetWriteWordHandler(5, mv0WriteWordProtection);
SekSetWriteByteHandler(5, mv0WriteByteProtection);

// Handler for kof2003 BIOS
SekMapMemory(Neo68KBIOS+0x20000, 0xC20000, 0xC3FFFF, SM_ROM);
}
return nRet;
}

struct BurnDriver BurnDrvkof2003 = {
"kof2003", NULL, "neogeo", "2003",
"The King of Fighters 2003 (set 1)\0", "PCB Version", "SNK Playmore", "Neo Geo",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_ALTERNATE_TEXT | HARDWARE_SNK_ENCRYPTED_B | HARDWARE_SNK_PCB_BIOS | HARDWARE_SNK_CUSTOM_BANKING,
NULL, kof2003RomInfo, kof2003RomName, neogeoInputInfo, neopcbDIPInfo,
kof2003Init, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};

// The King of Fighters 2003 (MVS Cart)

static struct BurnRomInfo kof2003aRomDesc[] = {
{ "271-p1c.bin",  0x400000, 0x530ecc14,  1 | BRF_ESS | BRF_PRG }, //  0 68K code (not interleaved?)
{ "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-m1d.bin",  0x080000, 0x0e86af8f,  4 | BRF_ESS | BRF_PRG }, // 12  Z80 code (could be the same as set 1?)
{ "271-m1c.bin",  0x080000, 0xf5515629,  0 | BRF_PRG | BRF_OPT }, // 13 (encrypted)

// This uses Neo-PCM2 PLAYMORE(c) 2002 Chip Protection
{ "271-v1c.bin",  0x800000, 0xffa3f8c7,  5 | BRF_SND },   // 14 Sound data (comming from 16 MB PCB Sample...)
{ "271-v2c.bin",  0x800000, 0x5382c7d1,  5 | BRF_SND },   // 15
};

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

static void kof2003aPVCDecrypt()
{
interleave_pdata();
neo_pvc(1); // New case must be added, kof2003a uses 2 xors for PVC

// 0x4EF9 for Good CRC, 0x4E75 to patch black screen with ASM core
*((unsigned short*)(Neo68KROM + 0x0816)) = 0x4E75;
}

static int kof2003aInit()
{
int nRet;

memset(CartRAM,0,sizeof(CartRAM));

pNeoInitCallback = kof2003aPVCDecrypt;
nNeoTextROMSize = 0x080000;
nNeoProtectionXor = 0x9d;
nNeoPCM2PLAYMOREProtection = 6;

nRet = NeoInit();
if (nRet == 0) {
// Install BankSwitch handler
SekMapHandler(5,    0x2fe000, 0x2fffff, SM_READ);
SekSetReadWordHandler(5,  mv0ReadWordBankSwitch);
SekSetReadByteHandler(5,  mv0ReadByteBankSwitch);

SekMapHandler(5,    0x2fe000, 0x2fffff, SM_WRITE);
SekSetWriteWordHandler(5, mv0WriteWordProtection);
SekSetWriteByteHandler(5, mv0WriteByteProtection);
}
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_CLONE, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_ALTERNATE_TEXT | HARDWARE_SNK_ENCRYPTED_B | HARDWARE_SNK_PCB_BIOS | HARDWARE_SNK_CUSTOM_BANKING,
NULL, kof2003aRomInfo, kof2003aRomName, neogeoInputInfo, neogeoDIPInfo,
kof2003aInit, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};

// The King of Fighters 2003 (decrypted C-ROMs)

static struct BurnRomInfo kof2k3ndRomDesc[] = {
{ "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

{ "kf2k3_c1.rom",  0x1000000, 0xc29acd28, 3 | BRF_GRA },    //  3 Sprite data
{ "kf2k3_c2.rom",  0x1000000, 0x328e80b1, 3 | BRF_GRA },    //  4
{ "kf2k3_c3.rom",  0x1000000, 0x020a11f1, 3 | BRF_GRA },    //  5
{ "kf2k3_c4.rom",  0x1000000, 0x991b5ed2, 3 | BRF_GRA },    //  6
{ "kf2k3_c5.rom",  0x1000000, 0xc2de8b66, 3 | BRF_GRA },    //  7
{ "kf2k3_c6.rom",  0x1000000, 0x3ff750db, 3 | BRF_GRA },    //  8

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

{ "271-v1.bin" ,   0x1000000, 0x1d96154b, 5 | BRF_SND },    // 10 Sound data
};

STDROMPICKEXT(kof2k3nd, kof2k3nd, neopcb);
STD_ROM_FN(kof2k3nd);

struct BurnDriver BurnDrvkof2k3nd = {
"kof2k3nd", "kof2003", "neogeo", "2003",
"The King of Fighters 2003 (decrypted C)\0", "decrypted C-ROMs", "SNK Playmore", "Neo Geo",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_SNK_NEOGEO | HARDWARE_SNK_ALTERNATE_TEXT | HARDWARE_SNK_PCB_BIOS | HARDWARE_SNK_CUSTOM_BANKING,
NULL, kof2k3ndRomInfo, kof2k3ndRomName, neogeoInputInfo, neopcbDIPInfo,
kof2003Init, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};
This should work for kof2003 (kof2k3nd, is the set you have)
See ya!!!!! :biggrin:
« Last Edit: July 26, 2005, 09:45:44 PM by FerchogtX »

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 Cookie Monstruo

  • Newbies
  • *
  • Posts: 17
  • Karma: +0/-0
Re: May I have help to get back on track plz?
« Reply #3 on: July 25, 2005, 08:00:08 PM »
ty very much :D

Offline Cookie Monstruo

  • Newbies
  • *
  • Posts: 17
  • Karma: +0/-0
Re: May I have help to get back on track plz?
« Reply #4 on: July 26, 2005, 12:19:45 AM »
damn, I get this error :(

Code: [Select]
src/burn/neogeo/d_neogeo.cpp:8536: error: `BDF_LOCKED' was not declared in this
   scope
src/burn/neogeo/d_neogeo.cpp:8536: error: `HARDWARE_SNK_PCB_BIOS' was not
   declared in this scope
src/burn/neogeo/d_neogeo.cpp:8611: error: `BDF_LOCKED' was not declared in this
   scope
src/burn/neogeo/d_neogeo.cpp:8611: error: `HARDWARE_SNK_PCB_BIOS' was not
   declared in this scope
src/burn/neogeo/d_neogeo.cpp:8644: error: `BDF_LOCKED' was not declared in this
   scope
src/burn/neogeo/d_neogeo.cpp:8644: error: `HARDWARE_SNK_PCB_BIOS' was not
   declared in this scope
make[1]: *** [d_neogeo.o] Error 1
make: *** [mingw] Error 2

Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Re: May I have help to get back on track plz?
« Reply #5 on: July 26, 2005, 09:44:30 PM »
delete the "BDF_LOCKED" flag from the drivers ('ill delete that to reflect changes)
in burn.h:
add after
Code: [Select]
#define HARDWARE_SNK_GAMBLING (0x5000) // Uses gambling controlsthis:
Code: [Select]
#define HARDWARE_SNK_PCB_BIOS (0x6000) // Uses custom BIOSSee ya!!!!! :biggrin:
« Last Edit: July 26, 2005, 09:46:41 PM by FerchogtX »

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 Cookie Monstruo

  • Newbies
  • *
  • Posts: 17
  • Karma: +0/-0
Re: May I have help to get back on track plz?
« Reply #6 on: July 27, 2005, 12:36:24 AM »
ok, ty :D