Author Topic: How to make this hack driver work?  (Read 5564 times)

Offline lxd_bruce

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +1/-0
How to make this hack driver work?
« on: August 06, 2007, 12:58:44 AM »
I wanna patch "gaia" to make its boss-hack driver.

here is what I did.

src\burn\cave\d_gaia.cpp

find this
Code: [Select]
#define CAVE_VBLANK_LINES 12
add this
Code: [Select]
void (*pCaveInitCallback)() = NULL;

find this
Code: [Select]
static int DrvInit()
{
int nLen;

BurnSetRefreshRate(58.0);

// Find out how much memory is needed
Mem = NULL;
MemIndex();
nLen = MemEnd - (unsigned char *)0;
if ((Mem = (unsigned char *)malloc(nLen)) == NULL) {
return 1;
}
memset(Mem, 0, nLen); // blank all memory
MemIndex(); // Index the allocated memory

// Load the roms into memory
if (LoadRoms()) {
return 1;
}




{
SekInit(0, 0x68000); // Allocate 68000
    SekOpen(0);

// Map 68000 memory:
SekMapMemory(Rom01, 0x000000, 0x0FFFFF, SM_ROM); // CPU 0 ROM
SekMapMemory(Ram01, 0x100000, 0x10FFFF, SM_RAM);
SekMapMemory(CaveSpriteRAM, 0x400000, 0x40FFFF, SM_RAM);
SekMapMemory(CaveTileRAM[0], 0x500000, 0x50FFFF, SM_RAM);
SekMapMemory(CaveTileRAM[1], 0x600000, 0x60FFFF, SM_RAM);
SekMapMemory(CaveTileRAM[2], 0x700000, 0x70FFFF, SM_RAM);

SekMapMemory(CavePalSrc, 0xC00000, 0xC0FFFF, SM_ROM); // Palette RAM (write goes through handler)
SekMapHandler(1, 0xC00000, 0xC0FFFF, SM_WRITE); //

SekSetReadWordHandler(0, gaiaReadWord);
SekSetReadByteHandler(0, gaiaReadByte);
SekSetWriteWordHandler(0, gaiaWriteWord);
SekSetWriteByteHandler(0, gaiaWriteByte);

SekSetWriteWordHandler(1, gaiaWriteWordPalette);
SekSetWriteByteHandler(1, gaiaWriteBytePalette);

SekClose();
}

add this
Code: [Select]
if (pCaveInitCallback) {
pCaveInitCallback();
}


add this at the end

Code: [Select]
// gaiab (Boss version)
static struct BurnRomInfo gaiabRomDesc[] = {
{ "prg1.127",     0x080000, 0x47B904B2, BRF_ESS | BRF_PRG }, //  0 CPU #0 code
{ "prg2.128",     0x080000, 0x469B7794, BRF_ESS | BRF_PRG }, //  1

{ "obj1.736",     0x400000, 0xF4F84E5D, BRF_GRA }, //  2 Sprite data
{ "obj2.738",     0x400000, 0x15C2A9CE, BRF_GRA }, //  3

{ "bg1.989",      0x400000, 0x013A693D, BRF_GRA }, //  4 Layer 0 Tile data
{ "bg2.995",      0x400000, 0x783CC62F, BRF_GRA }, //  5 Layer 1 Tile data
{ "bg3.998",      0x400000, 0xbcd61d1c, BRF_GRA }, //  6 Layer 2 Tile data

{ "snd1.447",     0x400000, 0x92770A52, BRF_SND }, //  7 YMZ280B (AD)PCM data
{ "snd2.454",     0x400000, 0x329AE1CF, BRF_SND }, //  8
{ "snd3.455",     0x400000, 0x4048D64E, BRF_SND }, //  9
};


STD_ROM_PICK(gaiab);
STD_ROM_FN(gaiab);

void gaiab_patch()
{
        Rom01[0x87396] = 0x5C;
        Rom01[0x87398] = 0x5C;
        Rom01[0x8739A] = 0x5C;
        Rom01[0x8739C] = 0x5C;
        Rom01[0x873BA] = 0xB2;
        Rom01[0x873BC] = 0xB2;
        Rom01[0x873BE] = 0xB2;
        Rom01[0x873C0] = 0xB2;
        Rom01[0x93490] = 0x5E;
        Rom01[0x93492] = 0x5E;
        Rom01[0x93494] = 0x5E;
        Rom01[0x93496] = 0x5E;
        Rom01[0x93651] = 0xD0;
        Rom01[0x93653] = 0xD0;
        Rom01[0x93655] = 0xD0;
        Rom01[0x93657] = 0xD0;
        Rom01[0x938B9] = 0x07;
        Rom01[0x938BA] = 0x07;
        Rom01[0x938BB] = 0x07;
        Rom01[0x938BC] = 0x07;
        Rom01[0x938C2] = 0xDC;
        Rom01[0x938C4] = 0xEC;
        Rom01[0x938C6] = 0xDC;
        Rom01[0x938C8] = 0xEC;
        Rom01[0x938CA] = 0xDC;
        Rom01[0x938CC] = 0xEC;
        Rom01[0x938CE] = 0xDC;
        Rom01[0x938D0] = 0xEC;

}

int gaiabInit()
{


pCaveInitCallback = gaiab_patch;

return DrvInit();
}


struct BurnDriver BurnDrvgaiab = {
"gaiab", "gaia", NULL, "2006",
"Gaia Crusaders (hidden characters enabled by 0 DAY-S[EGCG])\0", "The sound emulation isn't 100% accurate.", "hack", "Cave",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_16BIT_ONLY | BDF_CLONE, 2, HARDWARE_CAVE_68K_ONLY,
NULL, gaiabRomInfo, gaiabRomName, gaiaInputInfo, gaiaDIPInfo,
gaiabInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &CaveRecalcPalette,
320, 224, 4, 3
};





Compiling FBA without problem, but the Boss hack driver remain the original one.

I don't know why.

anyone can help?

here is the boss hack patch.
« Last Edit: August 06, 2007, 01:01:41 AM by lxd_bruce »

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: How to make this hack driver work?
« Reply #1 on: August 06, 2007, 04:51:03 PM »
   BurnLoadRom(Rom01 + 0, 1, 2);
   BurnLoadRom(Rom01 + 1, 0, 2);

that means the roms are interleaved, byte 1 comes from prg2, byte 2 comes from prg1, byte 3 comes from prg2, byte 4 comes from prg1 and so on. I think you're patching it like 0-0x7ffff is prg1 and 0x80000-0xffffff is prg2.


Offline lxd_bruce

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +1/-0
Re: How to make this hack driver work?
« Reply #2 on: August 06, 2007, 09:09:05 PM »
THX IQ. ;p

I'VE SOLVED THE PROBLEM. :biggrin:

Offline lxd_bruce

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +1/-0
IQ, Please come in
« Reply #3 on: October 02, 2007, 11:39:22 AM »
IQ, Using your code at http://neo-source.com/index.php?topic=719.0.

I wrote a hack driver for kof2002

here is the code

Code: [Select]
//kf2k2pcf

static void kf2k2pcf_patch()
{
// Descamble P-ROMs

unsigned char* pTemp = (unsigned char*)malloc(0x400000);

if (pTemp) {
unsigned int nBank[] = { 0x100000, 0x280000, 0x300000, 0x180000, 0x000000, 0x380000, 0x200000, 0x080000 };

memcpy(pTemp, Neo68KROM + 0x100000, 0x400000);

for (int i = 0; i < 8; i++) {
memcpy(Neo68KROM + 0x100000 + i * 0x80000, pTemp + nBank[i], 0x80000);
}

free(pTemp);
}
// power cage fix patch
unsigned char *mem8 = nNeoTextROMSize + 0x020000;
mem8[0x17601] = 0x55;
mem8[0x17602] = 0x77;
mem8[0x17603] = 0x77;
mem8[0x17604] = 0x77;
mem8[0x17605] = 0x77;
mem8[0x17606] = 0x55;
mem8[0x17609] = 0x55;
mem8[0x17619] = 0x55;
mem8[0x1761A] = 0x77;
mem8[0x1761B] = 0x77;
mem8[0x1761C] = 0x77;
mem8[0x1761D] = 0x77;
mem8[0x1761E] = 0x55;
mem8[0x17621] = 0x55;
mem8[0x17624] = 0x77;
mem8[0x17629] = 0x55;
mem8[0x1762A] = 0x77;
mem8[0x1762B] = 0x77;
mem8[0x1762C] = 0x77;
mem8[0x1762D] = 0x77;
mem8[0x1762E] = 0x55;
mem8[0x17631] = 0x55;
mem8[0x17632] = 0x77;
mem8[0x17633] = 0x77;
mem8[0x17634] = 0x77;
mem8[0x17635] = 0x77;
mem8[0x17636] = 0x55;
mem8[0x1763A] = 0x77;
mem8[0x1763B] = 0x77;
mem8[0x1763C] = 0x77;
mem8[0x1763D] = 0x77;
mem8[0x1763E] = 0x55;
mem8[0x17641] = 0x88;
mem8[0x17642] = 0x87;
mem8[0x17643] = 0x87;
mem8[0x17644] = 0x87;
mem8[0x17645] = 0x87;
mem8[0x17646] = 0x85;
mem8[0x17649] = 0x88;
mem8[0x1764A] = 0x78;
mem8[0x1764B] = 0x78;
mem8[0x1764C] = 0x78;
mem8[0x1764D] = 0x78;
mem8[0x1764E] = 0x58;
mem8[0x17651] = 0x55;
mem8[0x17652] = 0x77;
mem8[0x17653] = 0x77;
mem8[0x17654] = 0x77;
mem8[0x17655] = 0x77;
mem8[0x17656] = 0x55;
mem8[0x17659] = 0x85;
mem8[0x1765A] = 0x88;
mem8[0x1765B] = 0x88;
mem8[0x1765C] = 0x88;
mem8[0x1765D] = 0x88;
mem8[0x17661] = 0x55;
mem8[0x17662] = 0x87;
mem8[0x17663] = 0x87;
mem8[0x17664] = 0x87;
mem8[0x17665] = 0x87;
mem8[0x17666] = 0x85;
mem8[0x17669] = 0x88;
mem8[0x1766C] = 0x88;
mem8[0x17672] = 0x88;
mem8[0x17673] = 0x88;
mem8[0x17674] = 0x88;
mem8[0x17679] = 0x58;
mem8[0x1767A] = 0x78;
mem8[0x1767B] = 0x78;
mem8[0x1767C] = 0x78;
mem8[0x1767D] = 0x78;
mem8[0x1767E] = 0x58;
mem8[0x17681] = 0x55;
mem8[0x17682] = 0x77;
mem8[0x17683] = 0x77;
mem8[0x17684] = 0x77;
mem8[0x17685] = 0x77;
mem8[0x17686] = 0x55;
mem8[0x17689] = 0x88;
mem8[0x1768B] = 0x77;
mem8[0x1768C] = 0x77;
mem8[0x1768E] = 0x88;
mem8[0x17694] = 0x88;
mem8[0x1769A] = 0x88;
mem8[0x1769B] = 0x88;
mem8[0x1769C] = 0x88;
mem8[0x1769D] = 0x88;
mem8[0x1769E] = 0x88;
mem8[0x176A1] = 0x88;
mem8[0x176A2] = 0x88;
mem8[0x176A5] = 0x88;
mem8[0x176A6] = 0x88;
mem8[0x176A9] = 0x58;
mem8[0x176AA] = 0x77;
mem8[0x176AB] = 0x77;
mem8[0x176AC] = 0x77;
mem8[0x176AD] = 0x77;
mem8[0x176B1] = 0x88;
mem8[0x176B2] = 0x88;
mem8[0x176B3] = 0x88;
mem8[0x176B4] = 0x88;
mem8[0x176B6] = 0x58;
mem8[0x176B9] = 0x55;
mem8[0x176BA] = 0x88;
mem8[0x176BB] = 0x88;
mem8[0x176BC] = 0x88;
mem8[0x176BE] = 0x85;
mem8[0x176C1] = 0x55;
mem8[0x176C2] = 0x77;
mem8[0x176C3] = 0x77;
mem8[0x176C4] = 0x77;
mem8[0x176C5] = 0x77;
mem8[0x176C6] = 0x55;
mem8[0x176D1] = 0x55;
mem8[0x176D2] = 0x77;
mem8[0x176D3] = 0x77;
mem8[0x176D4] = 0x77;
mem8[0x176D5] = 0x77;
mem8[0x176D6] = 0x55;
mem8[0x176D9] = 0x55;
mem8[0x19601] = 0x55;
mem8[0x19602] = 0x77;
mem8[0x19603] = 0x77;
mem8[0x19604] = 0x77;
mem8[0x19605] = 0x77;
mem8[0x19606] = 0x55;
mem8[0x19609] = 0x55;
mem8[0x19619] = 0x55;
mem8[0x1961A] = 0x77;
mem8[0x1961B] = 0x77;
mem8[0x1961C] = 0x77;
mem8[0x1961D] = 0x77;
mem8[0x1961E] = 0x55;
mem8[0x19622] = 0x88;
mem8[0x19623] = 0x88;
mem8[0x19625] = 0x88;
mem8[0x19626] = 0x88;
mem8[0x1962A] = 0x87;
mem8[0x1962B] = 0x87;
mem8[0x1962C] = 0x87;
mem8[0x1962D] = 0x87;
mem8[0x1962E] = 0x85;
mem8[0x19631] = 0x55;
mem8[0x19632] = 0x87;
mem8[0x19633] = 0x87;
mem8[0x19634] = 0x87;
mem8[0x19635] = 0x87;
mem8[0x19636] = 0x85;
mem8[0x19639] = 0x88;
mem8[0x1963A] = 0x78;
mem8[0x1963B] = 0x78;
mem8[0x1963C] = 0x78;
mem8[0x1963D] = 0x78;
mem8[0x1963E] = 0x58;
mem8[0x19641] = 0x85;
mem8[0x19645] = 0x88;
mem8[0x19646] = 0x88;
mem8[0x19649] = 0x88;
mem8[0x1964A] = 0x77;
mem8[0x1964B] = 0x77;
mem8[0x1964D] = 0x77;
mem8[0x1964E] = 0x55;
mem8[0x19651] = 0x88;
mem8[0x19652] = 0x88;
mem8[0x19653] = 0x88;
mem8[0x19654] = 0x88;
mem8[0x19655] = 0x88;
mem8[0x19656] = 0x88;
mem8[0x19659] = 0x55;
mem8[0x1965A] = 0x77;
mem8[0x1965D] = 0x77;
mem8[0x1965E] = 0x55;
mem8[0x19661] = 0x85;
mem8[0x19662] = 0x77;
mem8[0x19663] = 0x77;
mem8[0x19664] = 0x77;
mem8[0x19665] = 0x77;
mem8[0x19666] = 0x85;
mem8[0x19669] = 0x88;
mem8[0x1966A] = 0x88;
mem8[0x1966B] = 0x87;
mem8[0x1966C] = 0x87;
mem8[0x1966D] = 0x88;
mem8[0x1966E] = 0x88;
mem8[0x19672] = 0x88;
mem8[0x19673] = 0x88;
mem8[0x19674] = 0x88;
mem8[0x19679] = 0x58;
mem8[0x1967A] = 0x78;
mem8[0x1967B] = 0x78;
mem8[0x1967C] = 0x78;
mem8[0x1967D] = 0x78;
mem8[0x1967E] = 0x58;
mem8[0x19682] = 0x78;
mem8[0x19683] = 0x77;
mem8[0x19684] = 0x77;
mem8[0x19685] = 0x78;
mem8[0x19689] = 0x55;
mem8[0x1968A] = 0x77;
mem8[0x1968B] = 0x77;
mem8[0x1968C] = 0x77;
mem8[0x1968D] = 0x77;
mem8[0x1968E] = 0x55;
mem8[0x19691] = 0x58;
mem8[0x19692] = 0x88;
mem8[0x19693] = 0x88;
mem8[0x19694] = 0x88;
mem8[0x19695] = 0x88;
mem8[0x19696] = 0x55;
mem8[0x19699] = 0x85;
mem8[0x1969A] = 0x88;
mem8[0x1969B] = 0x88;
mem8[0x1969C] = 0x88;
mem8[0x1969D] = 0x88;
mem8[0x1969E] = 0x88;
mem8[0x196A1] = 0x55;
mem8[0x196A2] = 0x77;
mem8[0x196A3] = 0x77;
mem8[0x196A4] = 0x77;
mem8[0x196A5] = 0x77;
mem8[0x196A9] = 0x55;
mem8[0x196AA] = 0x77;
mem8[0x196AB] = 0x77;
mem8[0x196AC] = 0x77;
mem8[0x196AD] = 0x77;
mem8[0x196AE] = 0x55;
mem8[0x196B5] = 0x77;
mem8[0x196B6] = 0x55;
mem8[0x196B9] = 0x55;
mem8[0x196BA] = 0x77;
mem8[0x196BB] = 0x77;
mem8[0x196BC] = 0x77;
mem8[0x196BD] = 0x77;
mem8[0x196BE] = 0x55;
mem8[0x196C1] = 0x55;
mem8[0x196C2] = 0x77;
mem8[0x196C3] = 0x77;
mem8[0x196C4] = 0x77;
mem8[0x196C5] = 0x77;
mem8[0x196C6] = 0x55;
mem8[0x196D1] = 0x55;
mem8[0x196D2] = 0x77;
mem8[0x196D3] = 0x77;
mem8[0x196D4] = 0x77;
mem8[0x196D5] = 0x77;
mem8[0x196D6] = 0x55;
mem8[0x196D9] = 0x55;

}

static int kf2k2pcfInit()
{
int nRet;

pNeoInitCallback = kf2k2pcf_patch;

nRet = NeoInit();

if (nRet == 0) {
PCM2DecryptVInfo Info = { 0x0A5000, 0x000000, { 0xF9, 0xE0, 0x5D, 0xF3, 0xEA, 0x92, 0xBE, 0xEF } };

PCM2DecryptV(&Info);
}

return nRet;
}


static int kf2k2pcfZipName(char **pszName, unsigned int i)
{
  if (i==0 && pszName!=NULL) { *pszName="neogeo.zip";  return 0; }
  if (i==1 && pszName!=NULL) { *pszName="kof2002.zip";  return 0; }
  if (i==2 && pszName!=NULL) { *pszName="kof2002d.zip";  return 0; }
  if (i==3 && pszName!=NULL) { *pszName="kf2k2pcf.zip";  return 0; }
  return 1;
}

struct BurnDriver BurnDrvkf2k2pcf = {
"kf2k2pcf", "kof2002", "neogeo", "2007",
"The King of Fighters 2002 - challenge to ultimate battle (decrypted C / Power Cage fixed by LXD_Bruce)\0", NULL, "Eolith / Playmore Corporation", "Neo Geo",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_SNK_NEOGEO,
kf2k2pcfZipName, kof2002dRomInfo, kof2002dRomName, neogeoInputInfo, neogeoDIPInfo,
kf2k2pcfInit, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
304, 224, 4, 3
};

but it can't be compiled, look at the picture.

How to fix it?


Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: IQ, Please come in
« Reply #4 on: October 02, 2007, 05:58:56 PM »
   unsigned char *mem8 = nNeoTextROMSize + 0x020000; <<---

change nNeoTextROMSize to NeoTextROM


Btw, please send me a Private Message instead of posting a thread with a title like "IQ, Please come in"
« Last Edit: October 02, 2007, 06:00:21 PM by iq_132 »


Offline lxd_bruce

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +1/-0
Re: How to make this hack driver work?
« Reply #5 on: October 02, 2007, 08:59:52 PM »
thanks IQ. :cool:

I'll send you a message next time. :biggrin: