int waveLogStart() { TCHAR szFilter[1024]; int nRet; int bOldPause; waveLogStop(); // make sure old log is closed WaveMakeOfn(szFilter); bOldPause = bRunPause; bRunPause = 1; nRet = GetSaveFileName(&ofn); bRunPause = bOldPause; if (nRet == 0) { return 1; } { if (!wave_open(nAudSampleRate, WtoA(szChoice))) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_DISK_CREATE)); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_DISK_SOUND)); FBAPopupDisplay(PUF_TYPE_ERROR); return 1; } wave_enable_stereo(); soundLogStart = true; } menuSync(MENUT_FILE); return 0; }
int WaveLogStart() { TCHAR szFilter[1024]; int nRet; int bOldPause; WaveLogStop(); // make sure old log is closed MakeOfn(szFilter); bOldPause = bRunPause; bRunPause = 1; nRet = GetSaveFileName(&ofn); bRunPause = bOldPause; if (nRet == 0) { return 1; } { WaveLog=_tfopen(szChoice,_T("wb")); if (WaveLog==NULL) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_DISK_CREATE)); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_DISK_SOUND)); FBAPopupDisplay(PUF_TYPE_ERROR); return 1; } WaveLogHeaderStart(WaveLog,nAudSampleRate[nAudSelect]); } MenuEnableItems(); return 0; }
int MediaInit() { dprintf(_T("s1\n")); if (ScrnInit()) { // Init the Scrn Window FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_UI_WINDOW)); FBAPopupDisplay(PUF_TYPE_ERROR); return 1; } dprintf(_T("s2\n")); if (!bInputOkay) { InputInit(); // Init Input } dprintf(_T("s3\n")); nAppVirtualFps = nBurnFPS; dprintf(_T("s4\n")); if (!bAudOkay) { AudSoundInit(); // Init Sound (not critical if it fails) } dprintf(_T("s5\n")); nBurnSoundRate = 0; // Assume no sound pBurnSoundOut = NULL; if (bAudOkay) { nBurnSoundRate = nAudSampleRate[nAudSelect]; nBurnSoundLen = nAudSegLen; } dprintf(_T("s6\n")); if (!bVidOkay) { dprintf(_T("s7\n")); // Reinit the video plugin VidInit(); if (!bVidOkay && nVidFullscreen) { dprintf(_T("s8\n")); nVidFullscreen = 0; dprintf(_T("s9\n")); MediaExit(); return (MediaInit()); } if (!nVidFullscreen) { ScrnSize(); } dprintf(_T("s10\n")); if (!bVidOkay) { // Make sure the error will be visible SplashDestroy(1); dprintf(_T("s11\n")); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_UI_MODULE), VidGetModuleName()); FBAPopupDisplay(PUF_TYPE_ERROR); } dprintf(_T("s12\n")); if (bVidOkay && ((bRunPause && bAltPause) || !bDrvOkay)) { VidRedraw(); } } dprintf(_T("s13\n")); return 0; }
// Init the screen window (create it) int scrnInit() { if (hScrnWnd) { return 0; } if (scrnRegister() != 0) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_UI_WINDOW)); FBAPopupDisplay(PUF_TYPE_ERROR); return 1; } DWORD nWindowStyles, nWindowExStyles; if (nVidFullscreen) { nWindowStyles = WS_POPUP; nWindowExStyles = 0; } else { if (bMenuEnabled) { nWindowStyles = WS_OVERLAPPEDWINDOW; nWindowExStyles = 0; } else { nWindowStyles = WS_MINIMIZEBOX | WS_POPUP | WS_SYSMENU | WS_THICKFRAME; nWindowExStyles = WS_EX_CLIENTEDGE; } } hScrnWnd = CreateWindowEx(nWindowExStyles, szClass, _T(APP_TITLE), nWindowStyles, 0, 0, 0, 0, NULL, NULL, hAppInst, NULL); if (hScrnWnd == NULL) { scrnExit(); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_UI_WINDOW)); FBAPopupDisplay(PUF_TYPE_ERROR); return 1; } if (!nVidFullscreen) { // enable drag & drop DragAcceptFiles(hScrnWnd, TRUE); // Create the menu toolbar itself menuCreate(); scrnTitle(); scrnSize(); } return 0; }
static void FBALocaliseError(TCHAR* pszFilename, int nLineNumber, TCHAR* pszInfo, wchar_t* pszLine) { FBAPopupAddText(PUF_TEXT_NO_TRANSLATE, _T("Language file %s is malformed.\nPlease remove or repair the file.\n\n"), pszFilename); FBAPopupAddText(PUF_TEXT_NO_TRANSLATE, _T("Parse error at line %i.\n"), nLineNumber); if (pszInfo) { FBAPopupAddText(PUF_TEXT_NO_TRANSLATE, _T("Problem:\t%s.\n"), pszInfo); } if (pszLine) { FBAPopupAddText(PUF_TEXT_NO_TRANSLATE, _T("Text:\t%ls\n"), pszLine); } FBAPopupDisplay(PUF_TYPE_ERROR); }
int StatedLoad(int nSlot) { TCHAR szFilter[1024]; int nRet; int bOldPause; if (bDrvOkay == 0) { return 1; } if (nSlot) { CreateStateName(nSlot); } else { if (bDrvOkay) { _stprintf(szChoice, _T("GAME:\\savestates\\%S.fs"), BurnDrvGetText(DRV_NAME)); } else { _stprintf(szChoice, _T("savestate")); } StateMakeOfn(szFilter); bOldPause = bRunPause; bRunPause = 1; bRunPause = bOldPause; } nRet = BurnStateLoad(szChoice, 1, &DrvInitCallback); if (nSlot) { return nRet; } // Describe any possible errors: if (nRet == 3) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_DISK_THIS_STATE)); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_DISK_UNAVAIL)); } else { if (nRet == 4) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_DISK_THIS_STATE)); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_DISK_TOOOLD), _T(APP_TITLE)); } else { if (nRet == 5) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_DISK_THIS_STATE)); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_DISK_TOONEW), _T(APP_TITLE)); } else { if (nRet && !nSlot) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_DISK_LOAD)); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_DISK_STATE)); } } } } if (nRet) { FBAPopupDisplay(PUF_TYPE_ERROR); } return nRet; }
static int RomDescribe(struct BurnRomInfo* pri) { if (!pri) { return 1; } if (nBArchiveError == 0) { nBArchiveError |= 0x8000; FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_INVALID)); } FBAPopupAddText(PUF_TEXT_DEFAULT, _T(" ") _T(SEPERATOR_1)); if (pri->nType & BRF_ESS) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DET_ESS)); } if (pri->nType & BRF_BIOS) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DET_BIOS)); } if (pri->nType & BRF_PRG) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DET_PRG)); } if (pri->nType & BRF_GRA) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DET_GRA)); } if (pri->nType & BRF_SND) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DET_SND)); } FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DET_ROM)); return 0; }
int StatedLoad(int nSlot) { TCHAR szFilter[1024]; int nRet; int bOldPause; if (nSlot) { CreateStateName(nSlot); } else { if (bDrvOkay) { _stprintf(szChoice, _T("%s*.fs"), BurnDrvGetText(DRV_NAME)); } else { _stprintf(szChoice, _T("savestate")); } MakeOfn(szFilter); ofn.lpstrTitle = FBALoadStringEx(hAppInst, IDS_STATE_LOAD, true); bOldPause = bRunPause; bRunPause = 1; nRet = GetOpenFileName(&ofn); bRunPause = bOldPause; if (nRet == 0) { // Error return 1; } } nRet = BurnStateLoad(szChoice, 1, &DrvInitCallback); if (nSlot) { return nRet; } // Describe any possible errors: if (nRet == 3) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_DISK_THIS_STATE)); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_DISK_UNAVAIL)); } else { if (nRet == 4) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_DISK_THIS_STATE)); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_DISK_TOOOLD), _T(APP_TITLE)); } else { if (nRet == 5) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_DISK_THIS_STATE)); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_DISK_TOONEW), _T(APP_TITLE)); } else { if (nRet && !nSlot) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_DISK_LOAD)); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_DISK_STATE)); } } } } if (nRet) { FBAPopupDisplay(PUF_TYPE_ERROR); } return nRet; }
static void CheatError(TCHAR* pszFilename, int nLineNumber, CheatInfo* pCheat, TCHAR* pszInfo, TCHAR* pszLine) { FBAPopupAddText(PUF_TEXT_NO_TRANSLATE, _T("Cheat file %s is malformed.\nPlease remove or repair the file.\n\n"), pszFilename); if (pCheat) { FBAPopupAddText(PUF_TEXT_NO_TRANSLATE, _T("Parse error at line %i, in cheat \"%s\".\n"), nLineNumber, pCheat->szCheatName); } else { FBAPopupAddText(PUF_TEXT_NO_TRANSLATE, _T("Parse error at line %i.\n"), nLineNumber); } if (pszInfo) { FBAPopupAddText(PUF_TEXT_NO_TRANSLATE, _T("Problem:\t%s.\n"), pszInfo); } if (pszLine) { FBAPopupAddText(PUF_TEXT_NO_TRANSLATE, _T("Text:\t%s\n"), pszLine); } FBAPopupDisplay(PUF_TYPE_ERROR); }
int StatedSave(int nSlot) { TCHAR szFilter[1024]; int nRet; int bOldPause; if (bDrvOkay == 0) { return 1; } if (nSlot) { CreateStateName(nSlot); } else { _stprintf(szChoice, _T("%s"), BurnDrvGetText(DRV_NAME)); MakeOfn(szFilter); ofn.lpstrTitle = FBALoadStringEx(hAppInst, IDS_STATE_SAVE, true); ofn.Flags |= OFN_OVERWRITEPROMPT; bOldPause = bRunPause; bRunPause = 1; nRet = GetSaveFileName(&ofn); bRunPause = bOldPause; if (nRet == 0) { // Error return 1; } } nRet = BurnStateSave(szChoice, 1); if (nRet && !nSlot) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_DISK_CREATE)); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_DISK_STATE)); FBAPopupDisplay(PUF_TYPE_ERROR); } return nRet; }
static int CheckRoms() { BurnRomInfo ri; int state = STAT_NOFIND; int error; for (int i = 0; i < nRomCount; i++) { memset(&ri, 0, sizeof(ri)); BurnDrvGetRomInfo(&ri, i); // Find information about the wanted rom if (!(ri.nType & BRF_OPT) && (ri.nCrc != 0)) { state = RomFind[i].nState; // Get the state of the rom in the archive file error = GetBArchiveError(state); if (state == STAT_NOFIND && ri.nType) { // (A type of 0 means empty slot - no rom) char* szName = "Unknown"; RomDescribe(&ri); BurnDrvGetRomName(&szName, i, 0); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_NOTFOUND), szName); } if (error == 0) { nBArchiveError |= 0x2000; } if (ri.nType & BRF_ESS) { // essential rom - without it the game may not run at all nBArchiveError |= error << 0; } if (ri.nType & BRF_PRG) { // rom which contains program information nBArchiveError |= error << 1; } if (ri.nType & BRF_GRA) { // rom which contains graphics information nBArchiveError |= error << 2; } if (ri.nType & BRF_SND) { // rom which contains sound information nBArchiveError |= error << 3; } } } if (nBArchiveError & 0x0F0F) { nBArchiveError |= 0x4000; } return 0; }
int FBALocaliseInit(TCHAR* lanaugae) { FBALocaliseExit(); if (!lanaugae || !lanaugae[0]) { return 0; } hLanguage = LoadLibrary(lanaugae); if (!hLanguage) { FBAPopupAddText(PUF_TYPE_WARNING, _T("Language dll load failed!")); FBAPopupDisplay(PUF_TYPE_WARNING); return 1; } _tcsncpy(szLanguage, lanaugae, sizearray(szLanguage)); bLanguageActive = true; return 0; }
// Catch calls to BurnLoadRom() once the emulation has started; // Intialise the zip module before forwarding the call, and exit cleanly. static int __cdecl DrvLoadRom(unsigned char* Dest, int* pnWrote, int i) { int nRet; BzipOpen(false); if ((nRet = BurnExtLoadRom(Dest, pnWrote, i)) != 0) { char* pszFilename; BurnDrvGetRomName(&pszFilename, i, 0); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_REQUEST), pszFilename, BurnDrvGetText(DRV_NAME)); FBAPopupDisplay(PUF_TYPE_ERROR); } BzipClose(); BurnExtLoadRom = DrvLoadRom; ScrnTitle(); return nRet; }
int ProcessCmdLine() { unsigned int i; int nOptX = 0, nOptY = 0, nOptD = 0; int nOpt1Size; TCHAR szOpt2[64] = _T(""); TCHAR szName[MAX_PATH]; if (szCmdLine[0] == _T('\"')) { int nLen = _tcslen(szCmdLine); nOpt1Size = 1; while (szCmdLine[nOpt1Size] != _T('\"') && nOpt1Size < nLen) { nOpt1Size++; } if (nOpt1Size == nLen) { szName[0] = 0; } else { nOpt1Size++; _tcsncpy(szName, szCmdLine + 1, nOpt1Size - 2); szName[nOpt1Size - 2] = 0; } } else { int nLen = _tcslen(szCmdLine); nOpt1Size = 0; while (szCmdLine[nOpt1Size] != _T(' ') && nOpt1Size < nLen) { nOpt1Size++; } _tcsncpy(szName, szCmdLine, nOpt1Size); szName[nOpt1Size] = 0; } if (_tcslen(szName)) { if (_tcscmp(szName, _T("-listinfo")) == 0) { write_datfile(0, stdout); return 1; } } _stscanf(&szCmdLine[nOpt1Size], _T("%64s %i x %i x %i"), szOpt2, &nOptX, &nOptY, &nOptD); if (_tcslen(szName)) { bool bFullscreen = 1; bCmdOptUsed = 1; if (_tcscmp(szOpt2, _T("-r")) == 0) { if (nOptX && nOptY) { nVidWidth = nOptX; nVidHeight = nOptY; } if (nOptD) { nVidDepth = nOptD; } } else if (_tcscmp(szOpt2, _T("-a")) == 0) { bVidArcaderes = 1; } else if (_tcscmp(szOpt2, _T("-w")) == 0) { bCmdOptUsed = 0; bFullscreen = 0; } else if (_tcsncmp(szOpt2, _T("-e"), 2) == 0) { bCmdOptUsed = 0; bFullscreen = 0; bHideLoadProgress = 1; nVidEmbeddedWindow = strtol(szOpt2 + 2, NULL, 16); /* Not unicode clean. =( */ if (!IsWindow((HWND)nVidEmbeddedWindow)) { nVidEmbeddedWindow = NULL; bFullscreen = 0; } } if (bFullscreen) { nVidFullscreen = 1; } if (_tcscmp(&szName[_tcslen(szName) - 3], _T(".fs")) == 0) { if (BurnStateLoad(szName, 1, &DrvInitCallback)) { return 1; } else { // bRunPause = 1; } } else { if (_tcscmp(&szName[_tcslen(szName) - 3], _T(".fr")) == 0) { if (StartReplay(szName)) { return 1; } } else if (_tcsncmp(szName, _T("quark:"), 6) == 0) { QuarkInit(szName); } else { for (i = 0; i < nBurnDrvCount; i++) { nBurnDrvSelect = i; if (_tcscmp(BurnDrvGetText(DRV_NAME), szName) == 0) { MediaInit(); DrvInit(i, true); break; } } if (i == nBurnDrvCount) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_UI_NOSUPPORT), szName, _T(APP_TITLE)); FBAPopupDisplay(PUF_TYPE_ERROR); return 1; } } } } POST_INITIALISE_MESSAGE; if (!nVidFullscreen) { MenuEnableItems(); } return 0; }
int BArchiveOpen(bool bootApp) { if (szBArchiveName == NULL) { return 1; } BArchiveClose(); // Make sure nothing is open // Count the number of roms needed for (nRomCount = 0; ; nRomCount++) { if (BurnDrvGetRomInfo(NULL, nRomCount)) { break; } } if (nRomCount <= 0) { return 1; } // Create an array for holding lookups for each rom -> archive entries unsigned int nMemLen = nRomCount * sizeof(ROMFIND); RomFind = (ROMFIND*)malloc(nMemLen); if (RomFind == NULL) { return 1; } memset(RomFind, 0, nMemLen); // Locate each archive file bool bFound = false; int checkvalue = ARC_NONE; TCHAR szFullName[MAX_PATH] = _T(""); char* szName = NULL; for (int y = 0, z = 0; y < BZIP_MAX && z < BZIP_MAX; y++) { // Get archive name without extension if (BurnDrvGetArchiveName(&szName, y, false)) { break; } bFound = false; for (int d = 0; d < DIRS_MAX; d++) { // if (bFound) { // break; // } if (!_tcsicmp(szAppRomPaths[d], _T(""))) { continue; // skip empty path } // check the archived rom file, modified by regret _stprintf(szFullName, _T("%s%hs"), szAppRomPaths[d], szName); checkvalue = archiveCheck(szFullName, (nLoadMenuShowX & CHECK7ZIP) ? 0 : 1); if (checkvalue == ARC_NONE) { continue; } bFound = true; szBArchiveName[z] = (TCHAR*)malloc(MAX_PATH * sizeof(TCHAR)); if (!szBArchiveName[z]) { continue; } _tcscpy(szBArchiveName[z], szFullName); if (!bootApp) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_FOUND), szName, szBArchiveName[z]); } z++; #if 0 // Look further in the last path specified, so you can put files with ROMs // used only by FB Alpha there without causing problems with dat files if (d < DIRS_MAX - 2) { d = DIRS_MAX - 2; } else { if (d >= DIRS_MAX - 1) { break; } } #endif } if (!bootApp && !bFound) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_NOTFOUND), szName); } } if (!bootApp) { FBAPopupAddText(PUF_TEXT_DEFAULT, _T("\n")); } // Locate the ROM data in the archive files int nFind = -1; BurnRomInfo ri; for (int z = 0; z < BZIP_MAX; z++) { if (!szBArchiveName[z]) { continue; } if (archiveOpen(szBArchiveName[z])) { continue; } archiveGetList(&List, &nListCount); // Get the list of entries nCurrentArc = z; for (int i = 0; i < nRomCount; i++) { if (RomFind[i].nState == STAT_OK) { continue; // Already found this and it's okay } nFind = findRom(i, List, nListCount); if (nFind < 0) { // Couldn't find this rom at all continue; } RomFind[i].nArchive = z; // Remember which archive file it is in RomFind[i].nPos = nFind; RomFind[i].nState = STAT_OK; // Set to found okay memset(&ri, 0, sizeof(ri)); BurnDrvGetRomInfo(&ri, i); // Get info about the rom // if size good & nodump, try to load the file with correct filename if (!(ri.nType & BRF_OPT) && (ri.nCrc != 0)) { nTotalSize += ri.nLen; } if (List[nFind].nLen == ri.nLen) { if (ri.nCrc) { // If we know the CRC if (List[nFind].nCrc != ri.nCrc) { // Length okay, but CRC wrong if (!(nLoadMenuShowX & DISABLECRC)) { // disable crc check RomFind[i].nState = STAT_CRC; } } } } else { if (nLoadMenuShowX & DISABLECRC) { ri.nLen = List[nFind].nLen; // disable size check } else { if (List[nFind].nLen < ri.nLen) { RomFind[i].nState = STAT_SMALL; // Too small } else { RomFind[i].nState = STAT_LARGE; // Too big } } } if (!bootApp) { if (RomFind[i].nState != STAT_OK) { RomDescribe(&ri); if (RomFind[i].nState == STAT_CRC) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_CRC), getFilenameA(List[nFind].szName), List[nFind].nCrc, ri.nCrc); } if (RomFind[i].nState == STAT_SMALL) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_SMALL), getFilenameA(List[nFind].szName), List[nFind].nLen >> 10, ri.nLen >> 10); } if (RomFind[i].nState == STAT_LARGE) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_LARGE), getFilenameA(List[nFind].szName), List[nFind].nLen >> 10, ri.nLen >> 10); } } }
int BArchiveCheckRoms(const bool& bootApp) { #ifdef USE_OLD_AUDIT if (bootApp) { return CheckRomsBoot(); } #endif // Check the roms to see if the code, graphics etc are complete CheckRoms(); if (nBArchiveError & 0x2000) { if (!(nBArchiveError & 0x0F0F)) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_OK)); } else { FBAPopupAddText(PUF_TEXT_DEFAULT, _T("\n")); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_PROBLEM)); } if (nBArchiveError & 0x0101) { FBAPopupAddText(PUF_TEXT_DEFAULT, _T("\n ") _T(SEPERATOR_1)); if (nBArchiveError & 0x0001) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_ESS_MISS)); } else { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_ESS_BAD)); } } if (nBArchiveError & 0x0202) { FBAPopupAddText(PUF_TEXT_DEFAULT, _T("\n ") _T(SEPERATOR_1)); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DET_PRG)); if (nBArchiveError & 0x0002) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DATA_MISS)); } else { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DATA_BAD)); } } if (nBArchiveError & 0x0404) { FBAPopupAddText(PUF_TEXT_DEFAULT, _T("\n ") _T(SEPERATOR_1)); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DET_GRA)); if (nBArchiveError & 0x0004) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DATA_MISS)); } else { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DATA_BAD)); } } if (nBArchiveError & 0x0808) { FBAPopupAddText(PUF_TEXT_DEFAULT, _T("\n ") _T(SEPERATOR_1)); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DET_SND)); if (nBArchiveError & 0x0008) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DATA_MISS)); } else { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DATA_BAD)); } } // Catch non-categorised ROMs if ((nBArchiveError & 0x0F0F) == 0) { if (nBArchiveError & 0x0010) { FBAPopupAddText(PUF_TEXT_DEFAULT, _T("\n ") _T(SEPERATOR_1)); if (nBArchiveError & 0x1000) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DATA_MISS)); } else { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DATA_BAD)); } } } } else { FBAPopupAddText(PUF_TEXT_DEFAULT, _T("\n")); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_NODATA)); } BurnExtLoadRom = BArchiveBurnLoadRom; // Okay to call our function to load each rom return 0; }
static int __cdecl BArchiveBurnLoadRom(unsigned char* Dest, int* pnWrote, int i) { if (i < 0 || i >= nRomCount || !RomFind) { return 1; } BurnRomInfo ri; memset(&ri, 0, sizeof(ri)); BurnDrvGetRomInfo(&ri, i); // Get info // show what we're doing char* pszRomName = NULL; BurnDrvGetRomName(&pszRomName, i, 0); if (pszRomName == NULL) { pszRomName = "unknown"; } TCHAR szText[MAX_PATH]; _stprintf(szText, _T("Loading")); if (ri.nType & (BRF_PRG | BRF_GRA | BRF_SND | BRF_BIOS)) { if (ri.nType & BRF_BIOS) { _stprintf (szText + _tcslen(szText), _T(" %s"), _T("BIOS ")); } if (ri.nType & BRF_PRG) { _stprintf (szText + _tcslen(szText), _T(" %s"), _T("program ")); } if (ri.nType & BRF_GRA) { _stprintf (szText + _tcslen(szText), _T(" %s"), _T("graphics ")); } if (ri.nType & BRF_SND) { _stprintf (szText + _tcslen(szText), _T(" %s"), _T("sound ")); } _stprintf(szText + _tcslen(szText), _T("(%hs)..."), pszRomName); } else { _stprintf(szText + _tcslen(szText), _T(" %hs..."), pszRomName); } ProgressUpdateBurner(ri.nLen ? 1.0 / ((double)nTotalSize / ri.nLen) : 0, szText, 0); #if defined (_WIN32) // Check for messages: MSG Msg; while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { DispatchMessage(&Msg); } #endif #ifndef LOAD_OPT_ROM // skip loading optional rom if (ri.nType & BRF_OPT) { return 0; } #endif if (RomFind[i].nState == STAT_NOFIND) { // Rom not found in archive at all return 1; } int nWantZip = RomFind[i].nArchive; // Which archive file it is in if (nCurrentArc != nWantZip) { // If we haven't got the right archive file currently open archiveClose(); nCurrentArc = -1; if (archiveOpen(szBArchiveName[nWantZip])) { return 1; } nCurrentArc = nWantZip; } // Read in file and return how many bytes we read if (archiveLoadFile(Dest, ri.nLen, RomFind[i].nPos, pnWrote)) { // Error loading from the archive file FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DISK), pszRomName, getFilenameW(szBArchiveName[nCurrentArc])); FBAPopupDisplay(PUF_TYPE_WARNING); return 1; } return 0; }
static int __cdecl BzipBurnLoadRom(unsigned char* Dest, int* pnWrote, int i) { #if defined (BUILD_WIN32) MSG Msg; #endif struct BurnRomInfo ri; int nWantZip = 0; TCHAR szText[128]; char* pszRomName = NULL; int nRet = 0; if (i < 0 || i >= nRomCount) { return 1; } ri.nLen = 0; BurnDrvGetRomInfo(&ri, i); // Get info // show what we're doing BurnDrvGetRomName(&pszRomName, i, 0); if (pszRomName == NULL) { pszRomName = "unknown"; } _stprintf(szText, _T("Loading")); if (ri.nType & (BRF_PRG | BRF_GRA | BRF_SND | BRF_BIOS)) { if (ri.nType & BRF_BIOS) { _stprintf (szText + _tcslen(szText), _T(" %s"), _T("BIOS ")); } if (ri.nType & BRF_PRG) { _stprintf (szText + _tcslen(szText), _T(" %s"), _T("program ")); } if (ri.nType & BRF_GRA) { _stprintf (szText + _tcslen(szText), _T(" %s"), _T("graphics ")); } if (ri.nType & BRF_SND) { _stprintf (szText + _tcslen(szText), _T(" %s"), _T("sound ")); } _stprintf(szText + _tcslen(szText), _T("(%hs)..."), pszRomName); } else { _stprintf(szText + _tcslen(szText), _T(" %hs..."), pszRomName); } ProgressUpdateBurner(ri.nLen ? 1.0 / ((double)nTotalSize / ri.nLen) : 0, szText, 0); #if defined (BUILD_WIN32) // Check for messages: while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { DispatchMessage(&Msg); } #endif if (RomFind[i].nState == 0) { // Rom not found in zip at all return 1; } nWantZip = RomFind[i].nZip; // Which zip file it is in if (nCurrentZip != nWantZip) { // If we haven't got the right zip file currently open ZipClose(); nCurrentZip = -1; if (ZipOpen(TCHARToANSI(szBzipName[nWantZip], NULL, 0))) { return 1; } nCurrentZip = nWantZip; } // Read in file and return how many bytes we read if (ZipLoadFile(Dest, ri.nLen, pnWrote, RomFind[i].nPos)) { // Error loading from the zip file FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(nRet == 2 ? IDS_ERR_LOAD_DISK_CRC : IDS_ERR_LOAD_DISK), pszRomName, GetFilenameW(szBzipName[nCurrentZip])); FBAPopupDisplay(PUF_TYPE_WARNING); return 1; } return 0; }
int BzipOpen(bool bootApp) { int nMemLen; // Zip name number nTotalSize = 0; nBzipError = 0; if (szBzipName == NULL) { return 1; } BzipClose(); // Make sure nothing is open // Count the number of roms needed for (nRomCount = 0; ; nRomCount++) { if (BurnDrvGetRomInfo(NULL, nRomCount)) { break; } } if (nRomCount <= 0) { return 1; } // Create an array for holding lookups for each rom -> zip entries nMemLen = nRomCount * sizeof(struct RomFind); RomFind = (struct RomFind*)malloc(nMemLen); if (RomFind == NULL) { return 1; } memset(RomFind, 0, nMemLen); for (int y = 0; y < BZIP_MAX; y++) { free(szBzipName[y]); szBzipName[y] = NULL; } // Locate each zip file for (int y = 0, z = 0; y < BZIP_MAX && z < BZIP_MAX; y++) { char* szName = NULL; bool bFound = false; if (BurnDrvGetZipName(&szName, y)) { break; } for (int d = 0; d < DIRS_MAX; d++) { TCHAR szFullName[MAX_PATH]; _stprintf(szFullName, _T("%s%hs"), szAppRomPaths[d], szName); if (ZipOpen(TCHARToANSI(szFullName, NULL, 0)) == 0) { // Open the rom zip file ZipClose(); bFound = true; szBzipName[z] = (TCHAR*)malloc(MAX_PATH * sizeof(TCHAR)); _tcscpy(szBzipName[z], szFullName); if (!bootApp) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_FOUND), szName, szBzipName[z]); } z++; // Look further in the last path specified, so you can put files with ROMs // used only by FB Alpha there without causing problems with dat files if (d < DIRS_MAX - 2) { d = DIRS_MAX - 2; } else { if (d >= DIRS_MAX - 1) { break; } } } } if (!bootApp && !bFound) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_NOTFOUND), szName); } } if (!bootApp) { FBAPopupAddText(PUF_TEXT_DEFAULT, _T("\n")); } // Locate the ROM data in the zip files for (int z = 0; z < BZIP_MAX; z++) { if (szBzipName[z] == NULL) { continue; } if (ZipOpen(TCHARToANSI(szBzipName[z], NULL, 0)) == 0) { // Open the rom zip file nCurrentZip = z; ZipGetList(&List, &nListCount); // Get the list of entries for (int i = 0; i < nRomCount; i++) { struct BurnRomInfo ri; int nFind; if (RomFind[i].nState == 1) { // Already found this and it's okay continue; } memset(&ri, 0, sizeof(ri)); nFind = FindRom(i); if (nFind < 0) { // Couldn't find this rom at all continue; } RomFind[i].nZip = z; // Remember which zip file it is in RomFind[i].nPos = nFind; RomFind[i].nState = 1; // Set to found okay BurnDrvGetRomInfo(&ri, i); // Get info about the rom if ((ri.nType & BRF_OPT) == 0 && (ri.nType & BRF_NODUMP) == 0) { nTotalSize += ri.nLen; } if (List[nFind].nLen == ri.nLen) { if (ri.nCrc) { // If we know the CRC if (List[nFind].nCrc != ri.nCrc) { // Length okay, but CRC wrong RomFind[i].nState = 2; } } } else { if (List[nFind].nLen < ri.nLen) { RomFind[i].nState = 3; // Too small } else { RomFind[i].nState = 4; // Too big } } if (!bootApp) { if (RomFind[i].nState != 1) { RomDescribe(&ri); if (RomFind[i].nState == 2) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_CRC), GetFilenameA(List[nFind].szName), List[nFind].nCrc, ri.nCrc); } if (RomFind[i].nState == 3) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_SMALL), GetFilenameA(List[nFind].szName), List[nFind].nLen >> 10, ri.nLen >> 10); } if (RomFind[i].nState == 4) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_LARGE), GetFilenameA(List[nFind].szName), List[nFind].nLen >> 10, ri.nLen >> 10); } } }
int ProcessCmdLine() { unsigned int i; int nOptX = 0, nOptY = 0, nOptD = 0; int nOpt1Size; TCHAR szOpt2[3] = _T(""); TCHAR szName[MAX_PATH]; if (szCmdLine[0] == _T('\"')) { int nLen = _tcslen(szCmdLine); nOpt1Size = 1; while (szCmdLine[nOpt1Size] != _T('\"') && nOpt1Size < nLen) { nOpt1Size++; } if (nOpt1Size == nLen) { szName[0] = 0; } else { nOpt1Size++; _tcsncpy(szName, szCmdLine + 1, nOpt1Size - 2); szName[nOpt1Size - 2] = 0; } } else { int nLen = _tcslen(szCmdLine); nOpt1Size = 0; while (szCmdLine[nOpt1Size] != _T(' ') && nOpt1Size < nLen) { nOpt1Size++; } _tcsncpy(szName, szCmdLine, nOpt1Size); szName[nOpt1Size] = 0; } if (_tcslen(szName)) { if (_tcscmp(szName, _T("-listinfo")) == 0) { write_datfile(0, 0, stdout); return 1; } if (_tcscmp(szName, _T("-listinfowithmd")) == 0) { write_datfile(0, 1, stdout); return 1; } if (_tcscmp(szName, _T("-listinfomdonly")) == 0) { write_datfile(0, 2, stdout); return 1; } if (_tcscmp(szName, _T("-listextrainfo")) == 0) { int nWidth; int nHeight; int nAspectX; int nAspectY; for (i = 0; i < nBurnDrvCount; i++) { nBurnDrvSelect = i; BurnDrvGetVisibleSize(&nWidth, &nHeight); BurnDrvGetAspect(&nAspectX, &nAspectY); printf("%s\t%ix%i\t%i:%i\t0x%08X\t\"%s\"\t%i\t%i\t%x\t%x\t\"%s\"\n", BurnDrvGetTextA(DRV_NAME), nWidth, nHeight, nAspectX, nAspectY, BurnDrvGetHardwareCode(), BurnDrvGetTextA(DRV_SYSTEM), BurnDrvIsWorking(), BurnDrvGetMaxPlayers(), BurnDrvGetGenreFlags(), BurnDrvGetFamilyFlags(), BurnDrvGetTextA(DRV_COMMENT)); } return 1; } } _stscanf(&szCmdLine[nOpt1Size], _T("%2s %i x %i x %i"), szOpt2, &nOptX, &nOptY, &nOptD); if (_tcslen(szName)) { bool bFullscreen = 1; bCmdOptUsed = 1; if (_tcscmp(szOpt2, _T("-r")) == 0) { if (nOptX && nOptY) { nVidWidth = nOptX; nVidHeight = nOptY; } if (nOptD) { nVidDepth = nOptD; } } else { if (_tcscmp(szOpt2, _T("-a")) == 0) { bVidArcaderes = 1; } else { if (_tcscmp(szOpt2, _T("-w")) == 0) { bCmdOptUsed = 0; bFullscreen = 0; } } } if (bFullscreen) { nVidFullscreen = 1; } if (_tcscmp(&szName[_tcslen(szName) - 3], _T(".fs")) == 0) { if (BurnStateLoad(szName, 1, &DrvInitCallback)) { return 1; } else { // bRunPause = 1; } } else { if (_tcscmp(&szName[_tcslen(szName) - 3], _T(".fr")) == 0) { if (StartReplay(szName)) { return 1; } } else { for (i = 0; i < nBurnDrvCount; i++) { nBurnDrvSelect = i; if (_tcscmp(BurnDrvGetText(DRV_NAME), szName) == 0) { MediaInit(); DrvInit(i, true); break; } } if (i == nBurnDrvCount) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_UI_NOSUPPORT), szName, _T(APP_TITLE)); FBAPopupDisplay(PUF_TYPE_ERROR); return 1; } } } } POST_INITIALISE_MESSAGE; if (!nVidFullscreen) { MenuEnableItems(); } return 0; }
int DrvInit(int nDrvNum, bool bRestore) { int nStatus; DrvExit(); // Make sure exitted MediaExit(); nBurnDrvActive = nDrvNum; // Set the driver number if ((BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_SNK_MVS) { BurnExtCartridgeSetupCallback = DrvCartridgeAccess; if (SelMVSDialog()) { POST_INITIALISE_MESSAGE; return 0; } } if ((BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_SNK_NEOCD) { if (CDEmuInit()) { FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_CDEMU_INI_FAIL)); FBAPopupDisplay(PUF_TYPE_ERROR); POST_INITIALISE_MESSAGE; return 0; } } MediaInit(); // Define nMaxPlayers early; GameInpInit() needs it (normally defined in DoLibInit()). nMaxPlayers = BurnDrvGetMaxPlayers(); GameInpInit(); // Init game input if(ConfigGameLoad(true)) { ConfigGameLoadHardwareDefaults(); } InputMake(true); GameInpDefault(); if (kNetGame) { nBurnCPUSpeedAdjust = 0x0100; } nStatus = DoLibInit(); // Init the Burn library's driver if (nStatus) { if (nStatus & 2) { BurnDrvExit(); // Exit the driver ScrnTitle(); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_BURN_INIT), BurnDrvGetText(DRV_FULLNAME)); FBAPopupDisplay(PUF_TYPE_WARNING); } POST_INITIALISE_MESSAGE; return 1; } BurnExtLoadRom = DrvLoadRom; bDrvOkay = 1; // Okay to use all BurnDrv functions if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) { nScreenSize = nScreenSizeVer; bVidArcaderes = bVidArcaderesVer; nVidWidth = nVidVerWidth; nVidHeight = nVidVerHeight; } else { nScreenSize = nScreenSizeHor; bVidArcaderes = bVidArcaderesHor; nVidWidth = nVidHorWidth; nVidHeight = nVidHorHeight; } bSaveRAM = false; if (kNetGame) { KailleraInitInput(); KailleraGetInput(); } else { if (bRestore) { StatedAuto(0); bSaveRAM = true; ConfigCheatLoad(); } } nBurnLayer = 0xFF; // show all layers // Reset the speed throttling code, so we don't 'jump' after the load RunReset(); VidExit(); POST_INITIALISE_MESSAGE; return 0; }