static int DrvInit() { int nRet=0; int i=0; unsigned char *pqs=NULL; Cps=2; nCpsRomLen= 4*0x080000; nCpsCodeLen= 2*0x080000; nCpsGfxLen= 0x1000000; nCpsZRomLen= 1*0x020000; nCpsQSamLen= 2*0x200000; nRet=CpsInit(); if (nRet!=0) { return 1; } for (i=0; i<4; i++) { nRet=BurnLoadRom(CpsRom+0x080000*i,2+i,1); if (nRet!=0) { return 1; } } memcpy(CpsCode,CpsRom,nCpsCodeLen); for (i=0; i<2; i++) { nRet=BurnXorRom(CpsCode+0x080000*i,0+i,1); if (nRet!=0) { return 1; } } nRet=Cps2LoadTiles(CpsGfx ,6); nRet=Cps2LoadTiles(CpsGfx+0x0800000,10); nRet=BurnLoadRom(CpsZRom,14,1); pqs=(unsigned char *)CpsQSam; nRet=BurnLoadRom(pqs ,15,1); nRet=BurnLoadRom(pqs+0x200000,16,1); BurnByteswap(pqs,nCpsQSamLen); nRet=CpsRunInit(); if (nRet!=0) { return 1; } return 0; }
static void DrvGfxDecode(int size) { BurnSwap32(pPsikyoshTiles, size); if (strcmp(BurnDrvGetTextA(DRV_NAME), "soldivid") == 0) { BurnByteswap(pPsikyoshTiles, size); } }
static void BurnSwapEndian(int len) { BurnByteswap(DrvSh2ROM, 0x200000); for (int i = 0; i < len; i+=4) { int t = DrvSh2ROM[i + 0]; DrvSh2ROM[i + 0] = DrvSh2ROM[i+3]; DrvSh2ROM[i + 3] = t; t = DrvSh2ROM[i + 1]; DrvSh2ROM[i + 1] = DrvSh2ROM[i + 2]; DrvSh2ROM[i + 2] = t; } }
static int LoadRoms() { // Load 68000 ROM BurnLoadRom(Rom01, 0, 1); BurnLoadRom(CaveSpriteROM + 0x000000, 1, 1); BurnLoadRom(CaveSpriteROM + 0x200000, 2, 1); BurnByteswap(CaveSpriteROM, 0x400000); NibbleSwap2(CaveSpriteROM, 0x400000); BurnLoadRom(CaveTileROM[0], 3, 1); NibbleSwap2(CaveTileROM[0], 0x100000); BurnLoadRom(CaveTileROM[1], 4, 1); NibbleSwap2(CaveTileROM[1], 0x100000); BurnLoadRom(CaveTileROM[2], 5, 1); NibbleSwap2(CaveTileROM[2], 0x040000); // Load MSM6295 ADPCM data BurnLoadRom(MSM6295ROM, 6, 1); BurnLoadRom(MSM6295ROM + 0x100000, 7, 1); return 0; }
static int CpsGetROMs(bool bLoad) { char* pRomName; struct BurnRomInfo ri; unsigned char* CpsCodeLoad = CpsCode; unsigned char* CpsRomLoad = CpsRom; unsigned char* CpsGfxLoad = CpsGfx; unsigned char* CpsZRomLoad = CpsZRom; unsigned char* CpsQSamLoad = (unsigned char*)CpsQSam; int nGfxNum = 0; if (bLoad) { if (!CpsCodeLoad || !CpsRomLoad || !CpsGfxLoad || !CpsZRomLoad || !CpsQSamLoad) { return 1; } } else { nCpsCodeLen = nCpsRomLen = nCpsGfxLen = nCpsZRomLen = nCpsQSamLen = 0; nGfxMaxSize = 0; if (BurnDrvGetHardwareCode() & HARDWARE_CAPCOM_CPS2_SIMM) { nGfxMaxSize = ~0U; } } for (int i = 0; !BurnDrvGetRomName(&pRomName, i, 0); i++) { BurnDrvGetRomInfo(&ri, i); // SIMM Graphics ROMs if (BurnDrvGetHardwareCode() & HARDWARE_CAPCOM_CPS2_SIMM) { if ((ri.nType & BRF_GRA) && (ri.nType & 8)) { if (bLoad) { Cps2LoadTilesSIM(CpsGfxLoad, i); CpsGfxLoad += ri.nLen * 8; i += 7; } else { nCpsGfxLen += ri.nLen; } continue; } // SIMM QSound sample ROMs if ((ri.nType & BRF_SND) && ((ri.nType & 15) == 13)) { if (bLoad) { BurnLoadRom(CpsQSamLoad, i, 1); BurnByteswap(CpsQSamLoad, ri.nLen); CpsQSamLoad += ri.nLen; } else { nCpsQSamLen += ri.nLen; } continue; } // Different interleave SIMM QSound sample ROMs if ((ri.nType & BRF_SND) && ((ri.nType & 15) == 15)) { if (bLoad) { BurnLoadRom(CpsQSamLoad + 1, i + 0, 2); BurnLoadRom(CpsQSamLoad + 0, i + 1, 2); i += 2; } else { nCpsQSamLen += ri.nLen; } continue; } } // 68K program ROMs if ((ri.nType & 7) == 1) { if (bLoad) { BurnLoadRom(CpsRomLoad, i, 1); CpsRomLoad += ri.nLen; } else { nCpsRomLen += ri.nLen; } continue; } // XOR tables if ((ri.nType & 7) == 2) { if (bLoad) { BurnLoadRom(CpsCodeLoad, i, 1); CpsCodeLoad += ri.nLen; } else { nCpsCodeLen += ri.nLen; } continue; } // Z80 program ROMs if ((ri.nType & 7) == 4) { if (bLoad) { BurnLoadRom(CpsZRomLoad, i, 1); CpsZRomLoad += ri.nLen; } else { nCpsZRomLen += ri.nLen; } continue; } // Normal Graphics ROMs if (ri.nType & BRF_GRA) { if (bLoad) { if ((ri.nType & 15) == 6) { Cps2LoadTilesSplit(CpsGfxLoad, i); CpsGfxLoad += (nGfxMaxSize == ~0U ? ri.nLen : nGfxMaxSize) * 4; i += 15; } else { Cps2LoadTiles(CpsGfxLoad, i); CpsGfxLoad += (nGfxMaxSize == ~0U ? ri.nLen : nGfxMaxSize) * 4; i += 3; } } else { if (ri.nLen > nGfxMaxSize) { nGfxMaxSize = ri.nLen; } if (ri.nLen < nGfxMaxSize) { nGfxMaxSize = ~0U; } nCpsGfxLen += ri.nLen; nGfxNum++; } continue; } // QSound sample ROMs if (ri.nType & BRF_SND) { if (bLoad) { BurnLoadRom(CpsQSamLoad, i, 1); BurnByteswap(CpsQSamLoad, ri.nLen); CpsQSamLoad += ri.nLen; } else { nCpsQSamLen += ri.nLen; } continue; } } if (bLoad) { #if 0 for (unsigned int i = 0; i < nCpsCodeLen / 4; i++) { ((unsigned int*)CpsCode)[i] ^= ((unsigned int*)CpsRom)[i]; } #endif cps2_decrypt_game_data(); // if (!nCpsCodeLen) return 1; } else { if (nGfxMaxSize != ~0U) { nCpsGfxLen = nGfxNum * nGfxMaxSize; } #if 1 && defined FBA_DEBUG if (!nCpsCodeLen) { bprintf(PRINT_IMPORTANT, _T(" - 68K ROM size:\t0x%08X (Decrypted with key)\n"), nCpsRomLen); } else { bprintf(PRINT_IMPORTANT, _T(" - 68K ROM size:\t0x%08X (XOR table size: 0x%08X)\n"), nCpsRomLen, nCpsCodeLen); } bprintf(PRINT_IMPORTANT, _T(" - Z80 ROM size:\t0x%08X\n"), nCpsZRomLen); bprintf(PRINT_IMPORTANT, _T(" - Graphics data:\t0x%08X\n"), nCpsGfxLen); bprintf(PRINT_IMPORTANT, _T(" - QSound data:\t0x%08X\n"), nCpsQSamLen); #endif if (/*!nCpsCodeLen ||*/ !nCpsRomLen || !nCpsGfxLen || !nCpsZRomLen || ! nCpsQSamLen) { return 1; } } return 0; }
static int DrvInit() { int nRet=0; int i=0; unsigned char *pqs=NULL; Cps=2; nCpsRomLen= 8*0x080000; nCpsCodeLen= 2*0x080000; nCpsGfxLen= 8*0x400000; nCpsZRomLen= 2*0x020000; nCpsQSamLen= 2*0x400000; nRet=CpsInit(); if (nRet!=0) { return 1; } // Load program roms (as they are on the roms) for CpsRom for (i=0; i<8; i++) { nRet=BurnLoadRom(CpsRom+0x080000*i,2+i,1); if (nRet!=0) { return 1; } } // Make decrypted rom memcpy(CpsCode,CpsRom,nCpsCodeLen); nRet=BurnXorRom(CpsCode ,0,1); if (nRet!=0) { return 1; } nRet=BurnXorRom(CpsCode+0x080000,1,1); if (nRet!=0) { return 1; } // Load graphics roms nRet=Cps2LoadTiles(CpsGfx ,10); nRet=Cps2LoadTiles(CpsGfx+4*0x400000,14); // Load Z80 Roms nRet=BurnLoadRom(CpsZRom ,18,1); nRet=BurnLoadRom(CpsZRom+ 0x20000,19,1); // Load Q Sample Roms pqs=(unsigned char *)CpsQSam; nRet=BurnLoadRom(pqs ,20,1); nRet=BurnLoadRom(pqs+0x400000,21,1); BurnByteswap(pqs,nCpsQSamLen); nRet=CpsRunInit(); nStateNVMin = 0x019990; nStateAllMin = 0x019990; if (nRet!=0) { return 1; } // Ready to go return 0; }
static int DrvInit() { int nRet=0; int i=0; unsigned char *pqs=NULL; Cps=2; nCpsRomLen= 7*0x080000; nCpsCodeLen= 4*0x080000; nCpsGfxLen= 4*0x400000; nCpsZRomLen= 2*0x020000; nCpsQSamLen= 2*0x200000; nRet=CpsInit(); if (nRet!=0) { return 1; } // Load program roms (as they are on the roms) for CpsRom for (i=0; i<7; i++) { nRet=BurnLoadRom(CpsRom+0x080000*i,4+i,1); if (nRet!=0) { return 1; } } memcpy(CpsCode,CpsRom,nCpsCodeLen); for (i=0; i<4; i++) { nRet=BurnXorRom(CpsCode+0x080000*i,0+i,1); if (nRet!=0) { return 1; } } // Load graphics roms nRet=Cps2LoadTiles(CpsGfx ,11); // Load Z80 Roms nRet=BurnLoadRom(CpsZRom ,15,1); nRet=BurnLoadRom(CpsZRom+ 0x20000,16,1); // Load Q Sample Roms pqs=(unsigned char *)CpsQSam; nRet=BurnLoadRom(pqs ,17,1); nRet=BurnLoadRom(pqs+0x200000,18,1); BurnByteswap(pqs,nCpsQSamLen); nRet=CpsRunInit(); if (nRet!=0) { return 1; } // Ready to go return 0; }
static int DrvInit() { int nRet=0; Cps=1; Ghouls=1; nCpsRomLen= 0x100000; nCpsGfxLen= 0x300000; nCpsZRomLen= 0x010000; nRet=CpsInit(); if (nRet!=0) { return 1; } // Load program roms nRet=BurnLoadRom(CpsRom+0x000001,0,2); if (nRet!=0) { return 1; } nRet=BurnLoadRom(CpsRom+0x000000,1,2); if (nRet!=0) { return 1; } nRet=BurnLoadRom(CpsRom+0x040001,2,2); if (nRet!=0) { return 1; } nRet=BurnLoadRom(CpsRom+0x040000,3,2); if (nRet!=0) { return 1; } nRet=BurnLoadRom(CpsRom+0x080000,4,1); if (nRet!=0) { return 1; } BurnByteswap(CpsRom+0x080000,0x080000); // Set dip switches SETUP_DIPSW_3(Cpi01A,Cpi01C,Cpi01E,0x00,0x03,0x60); // Load graphics roms CpsLoadTiles (CpsGfx , 5); CpsLoadTilesByte(CpsGfx+0x200000, 9); CpsLoadTilesByte(CpsGfx+0x280000, 17); MaskAddr[0]=0x68; MaskAddr[1]=0x6a; MaskAddr[2]=0x6c; MaskAddr[3]=0x6e; // Load Z80 Rom nRet=BurnLoadRom(CpsZRom,25,1); ConstructDIPSWList(); nRet=CpsRunInit(); if (nRet!=0) { return 1; } // Ready to go return 0; }
static INT32 CpsGetROMs(bool bLoad) { struct BurnRomInfo ri; UINT8* CpsCodeLoad = CpsCode; UINT8* CpsRomLoad = CpsRom; UINT8* CpsGfxLoad = CpsGfx; UINT8* CpsZRomLoad = CpsZRom; UINT8* CpsQSamLoad = (UINT8*)CpsQSam; INT32 nGfxNum = 0; if (bLoad) { if (!CpsCodeLoad || !CpsRomLoad || !CpsGfxLoad || !CpsZRomLoad || !CpsQSamLoad) { return 1; } } else { nCpsCodeLen = nCpsRomLen = nCpsGfxLen = nCpsZRomLen = nCpsQSamLen = 0; nGfxMaxSize = 0; if (BurnDrvGetHardwareCode() & HARDWARE_CAPCOM_CPS2_SIMM) { nGfxMaxSize = ~0U; } } INT32 i = 0; do { ri.nLen = 0; ri.nType = 0; BurnDrvGetRomInfo(&ri, i); if ((ri.nType & 0x0f) == CPS2_PRG_68K) { if (bLoad) { BurnLoadRom(CpsRomLoad, i, 1); CpsRomLoad += ri.nLen; } else { nCpsRomLen += ri.nLen; } i++; } if ((ri.nType & 0x0f) == CPS2_PRG_68K_SIMM) { if (bLoad) { BurnLoadRom(CpsRomLoad + 0x000001, i + 0, 2); BurnLoadRom(CpsRomLoad + 0x000000, i + 1, 2); CpsRomLoad += ri.nLen * 2; i += 2; } else { nCpsRomLen += ri.nLen; i++; } } if ((ri.nType & 0x0f) == CPS2_PRG_68K_XOR_TABLE) { if (bLoad) { BurnLoadRom(CpsCodeLoad, i, 1); CpsCodeLoad += ri.nLen; } else { nCpsCodeLen += ri.nLen; } i++; } if ((ri.nType & 0x0f) == CPS2_GFX) { if (bLoad) { Cps2LoadTiles(CpsGfxLoad, i); CpsGfxLoad += (nGfxMaxSize == ~0U ? ri.nLen : nGfxMaxSize) * 4; i += 4; } else { if (ri.nLen > nGfxMaxSize) { nGfxMaxSize = ri.nLen; } if (ri.nLen < nGfxMaxSize) { nGfxMaxSize = ~0U; } nCpsGfxLen += ri.nLen; nGfxNum++; i++; } } if ((ri.nType & 0x0f) == CPS2_GFX_SIMM) { if (bLoad) { Cps2LoadTilesSIM(CpsGfxLoad, i); CpsGfxLoad += ri.nLen * 8; i += 8; } else { nCpsGfxLen += ri.nLen; i++; } } if ((ri.nType & 0x0f) == CPS2_GFX_SPLIT4) { if (bLoad) { Cps2LoadTilesSplit4(CpsGfxLoad, i); CpsGfxLoad += (nGfxMaxSize == ~0U ? ri.nLen : nGfxMaxSize) * 16; i += 16; } else { if (ri.nLen > nGfxMaxSize) { nGfxMaxSize = ri.nLen; } if (ri.nLen < nGfxMaxSize) { nGfxMaxSize = ~0U; } nCpsGfxLen += ri.nLen; nGfxNum++; i++; } } if ((ri.nType & 0x0f) == CPS2_GFX_SPLIT8) { if (bLoad) { Cps2LoadTilesSplit8(CpsGfxLoad, i); CpsGfxLoad += (nGfxMaxSize == ~0U ? ri.nLen : nGfxMaxSize) * 32; i += 32; } else { if (ri.nLen > nGfxMaxSize) { nGfxMaxSize = ri.nLen; } if (ri.nLen < nGfxMaxSize) { nGfxMaxSize = ~0U; } nCpsGfxLen += ri.nLen; nGfxNum++; i++; } } if ((ri.nType & 0x0f) == CPS2_PRG_Z80) { if (bLoad) { BurnLoadRom(CpsZRomLoad, i, 1); CpsZRomLoad += ri.nLen; } else { nCpsZRomLen += ri.nLen; } i++; } if ((ri.nType & 0x0f) == CPS2_QSND) { if (bLoad) { BurnLoadRom(CpsQSamLoad, i, 1); BurnByteswap(CpsQSamLoad, ri.nLen); CpsQSamLoad += ri.nLen; } else { nCpsQSamLen += ri.nLen; } i++; } if ((ri.nType & 0x0f) == CPS2_QSND_SIMM) { if (bLoad) { BurnLoadRom(CpsQSamLoad, i, 1); BurnByteswap(CpsQSamLoad, ri.nLen); CpsQSamLoad += ri.nLen; } else { nCpsQSamLen += ri.nLen; } i++; } if ((ri.nType & 0x0f) == CPS2_QSND_SIMM_BYTESWAP) { if (bLoad) { BurnLoadRom(CpsQSamLoad + 1, i + 0, 2); BurnLoadRom(CpsQSamLoad + 0, i + 1, 2); i += 2; } else { nCpsQSamLen += ri.nLen; i++; } } } while (ri.nLen); if (bLoad) { #if 0 for (UINT32 i = 0; i < nCpsCodeLen / 4; i++) { ((UINT32*)CpsCode)[i] ^= ((UINT32*)CpsRom)[i]; } #endif cps2_decrypt_game_data(); // if (!nCpsCodeLen) return 1; } else { if (nGfxMaxSize != ~0U) { nCpsGfxLen = nGfxNum * nGfxMaxSize; } #if 1 && defined FBA_DEBUG if (!nCpsCodeLen) { bprintf(PRINT_IMPORTANT, _T(" - 68K ROM size:\t0x%08X (Decrypted with key)\n"), nCpsRomLen); } else { bprintf(PRINT_IMPORTANT, _T(" - 68K ROM size:\t0x%08X (XOR table size: 0x%08X)\n"), nCpsRomLen, nCpsCodeLen); } bprintf(PRINT_IMPORTANT, _T(" - Z80 ROM size:\t0x%08X\n"), nCpsZRomLen); bprintf(PRINT_IMPORTANT, _T(" - Graphics data:\t0x%08X\n"), nCpsGfxLen); bprintf(PRINT_IMPORTANT, _T(" - QSound data:\t0x%08X\n"), nCpsQSamLen); #endif if (/*!nCpsCodeLen ||*/ !nCpsRomLen || !nCpsGfxLen || !nCpsZRomLen || ! nCpsQSamLen) { return 1; } } return 0; }
static int Sf2rb2Init() { int nRet=0; int i=0; Cps=1; nCpsRomLen =8*0x20000+0x80000; nCpsGfxLen =3*0x200000; nCpsZRomLen= 0x010000; nCpsAdLen =2*0x020000; nRet=CpsInit(); if (nRet!=0) { return 1; } // Load program roms nRet=BurnLoadRom(CpsRom+0x000000,0,2); if (nRet!=0) { return 1; //ROM_LOAD16_BYTE } nRet=BurnLoadRom(CpsRom+0x000001,1,2); if (nRet!=0) { return 1; //ROM_LOAD16_BYTE } nRet=BurnLoadRom(CpsRom+0x040000,2,2); if (nRet!=0) { return 1; //ROM_LOAD16_BYTE } nRet=BurnLoadRom(CpsRom+0x040001,3,2); if (nRet!=0) { return 1; //ROM_LOAD16_BYTE } nRet=BurnLoadRom(CpsRom+0x080000,4,2); if (nRet!=0) { return 1; //ROM_LOAD16_BYTE } nRet=BurnLoadRom(CpsRom+0x080001,5,2); if (nRet!=0) { return 1; //ROM_LOAD16_BYTE } nRet=BurnLoadRom(CpsRom+0x0c0000,6,2); if (nRet!=0) { return 1; //ROM_LOAD16_BYTE } nRet=BurnLoadRom(CpsRom+0x0c0001,7,2); if (nRet!=0) { return 1; //ROM_LOAD16_BYTE } nRet=BurnLoadRom(CpsRom+0x100000,8,1); if (nRet!=0) { return 1; //ROM_LOAD16_WORD_SWAP } // Stuff to patch the copy protection for sf2rb2 starts here BurnByteswap(CpsRom,0x080000*2); // must byteswap the 2 new code roms CpsRom[0xe5333]=0x60; CpsRom[0xe5332]=0x14; // Ends here // Load up and interleve each set of 4 roms to make the 16x16 tiles for (i=0; i<3; i++) { CpsLoadTiles(CpsGfx+i*0x200000,9+i*4); } nCpsGfxScroll[1]=nCpsGfxScroll[2]=nCpsGfxScroll[3]=0x400000; // Offset to Scroll tiles MaskAddr[0]=0x68; MaskAddr[1]=0x6a; MaskAddr[2]=0x6c; MaskAddr[3]=0x6e; // Load Z80 Rom nRet=BurnLoadRom(CpsZRom,21,1); // Load ADPCM data nRet=BurnLoadRom(CpsAd ,22,1); nRet=BurnLoadRom(CpsAd+0x20000,23,1); // Set dip switches SETUP_DIPSW_3(Cpi01A,Cpi01C,Cpi01E,0x00,0x03,0x60); // Start of Board ID improvments by KEV. 0x48,0x0407 CpsBID[0]=0x48; CpsBID[1]=0x04; CpsBID[2]=0x07; //end nPsndIrqPeriod=(60<<10)/250; //OLDTST ConstructDIPSWList(); nRet=CpsRunInit(); if (nRet!=0) { return 1; } // Ready to go return 0; }
static int Sf2rbInit() { int nRet=0; int i=0; Cps=1; nCpsRomLen =3*0x080000; nCpsGfxLen =3*0x200000; nCpsZRomLen= 0x010000; nCpsAdLen =2*0x020000; nRet=CpsInit(); if (nRet!=0) { return 1; } // Load program roms (they are already byteswapped) for (i=0; i<3; i++) { nRet=BurnLoadRom(CpsRom+0x080000*i,0+i,1); if (nRet!=0) { return 1; } } // Stuff to patch the copy protection for sf2rb starts here BurnByteswap(CpsRom,0x080000*2); // must byteswap the 2 new code roms CpsRom[0xe5465]=0x60; CpsRom[0xe5464]=0x12; // Ends here // Load up and interleve each set of 4 roms to make the 16x16 tiles CpsLoadTiles(CpsGfx+0x000000,3+0*4); CpsLoadTiles(CpsGfx+0x200000,3+1*4); CpsLoadTiles(CpsGfx+0x400000,3+2*4); nCpsGfxScroll[1]=nCpsGfxScroll[2]=nCpsGfxScroll[3]=0x400000; // Offset to Scroll tiles MaskAddr[0]=0x68; MaskAddr[1]=0x6a; MaskAddr[2]=0x6c; MaskAddr[3]=0x6e; // Load Z80 Rom nRet=BurnLoadRom(CpsZRom,15,1); // Load ADPCM data nRet=BurnLoadRom(CpsAd ,16,1); nRet=BurnLoadRom(CpsAd+0x20000,17,1); // Set dip switches SETUP_DIPSW_3(Cpi01A,Cpi01C,Cpi01E,0x00,0x03,0x60); // Start of Board ID improvments by KEV. 0x48,0x0407 CpsBID[0]=0x48; CpsBID[1]=0x04; CpsBID[2]=0x07; //end nPsndIrqPeriod=(60<<10)/250; //OLDTST ConstructDIPSWList(); nRet=CpsRunInit(); if (nRet!=0) { return 1; } // Ready to go return 0; }