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; }
// Check the roms to see if they code, graphics etc are complete static int CheckRoms() { nBzipError = 0; // Assume romset is fine for (int i = 0; i < nRomCount; i++) { struct BurnRomInfo ri; memset(&ri, 0, sizeof(ri)); BurnDrvGetRomInfo(&ri, i); // Find information about the wanted rom if (ri.nCrc && (ri.nType & BRF_OPT) == 0 && (ri.nType & BRF_NODUMP)) { int nState = RomFind[i].nState; // Get the state of the rom in the zip file int nError = GetBZipError(nState); if (nState == 0 && ri.nType) { // (A type of 0 means empty slot - no rom) char* szName = "Unknown"; RomDescribe(&BzipDetail, &ri); BurnDrvGetRomName(&szName, i, 0); BzipDetail.Add(_T("%hs was not found.\n"), szName); } if (nError == 0) { nBzipError |= 0x2000; } if (ri.nType & BRF_ESS) { // essential rom - without it the game may not run at all nBzipError |= nError << 0; } if (ri.nType & BRF_PRG) { // rom which contains program information nBzipError |= nError << 1; } if (ri.nType & BRF_GRA) { // rom which contains graphics information nBzipError |= nError << 2; } if (ri.nType & BRF_SND) { // rom which contains sound information nBzipError |= nError << 3; } } } if (nBzipError & 0x0F0F) { nBzipError |= 0x4000; } return 0; }
// Check the roms to see if they code, graphics etc are complete static int CheckRoms() { nBzipError = 0; // Assume romset is fine for (int i = 0; i < nRomCount; i++) { struct BurnRomInfo ri; memset(&ri, 0, sizeof(ri)); BurnDrvGetRomInfo(&ri, i); // Find information about the wanted rom if (ri.nCrc && (ri.nType & 0x80) == 0) { int nState = RomFind[i].nState; // Get the state of the rom in the zip file if (nState == 0 && ri.nType) { // (A type of 0 means empty slot - no rom) char* szName = "Unknown"; RomDescribe(&BzipDetail, &ri); BurnDrvGetRomName(&szName, i, 0); BzipDetail.Add(_T("%hs was not found.\n"), szName); } if (ri.nType & 0x90) { // essential rom - without it the game may not run at all nBzipError |= GetBZipError(nState) << 0; } if (ri.nType & 0x01) { // rom which contains graphics information nBzipError |= GetBZipError(nState) << 1; } if (ri.nType & 0x02) { // rom which contains sound information nBzipError |= GetBZipError(nState) << 2; } } } if (!nZipsFound) { nBzipError |= 0x08; // No data at all! } return 0; }
int BzipOpen(bool bootApp) { int nMemLen; // Zip name number nZipsFound = 0; // Haven't found zips yet nTotalSize = 0; if (szBzipName == NULL) { return 1; } BzipClose(); // Make sure nothing is open if(!bootApp) { // reset information strings BzipText.Reset(); BzipDetail.Reset(); } // 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 z = 0; z < BZIP_MAX; z++) { char* szName = NULL; if (BurnDrvGetZipName(&szName, z)) { break; } for (int d = 0; d < DIRS_MAX; d++) { free(szBzipName[z]); szBzipName[z] = (TCHAR*)malloc(MAX_PATH * sizeof(TCHAR)); _stprintf(szBzipName[z], _T("%s%hs"), szAppRomPaths[d], szName); if (ZipOpen(TCHARToANSI(szBzipName[z], NULL, 0)) == 0) { // Open the rom zip file nZipsFound++; nCurrentZip = z; break; } } if (nCurrentZip >= 0) { if (!bootApp) { BzipText.Add(_T("Found %s;\n"), szBzipName[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(&BzipDetail, &ri); if (RomFind[i].nState == 2) { BzipDetail.Add(_T("%hs has a CRC of %.8X. (It should be %.8X.)\n"), GetFilenameA(List[nFind].szName), List[nFind].nCrc, ri.nCrc); } if (RomFind[i].nState == 3) { BzipDetail.Add(_T("%hs is %dk which is incomplete. (It should be %dkB.)\n"), GetFilenameA(List[nFind].szName), List[nFind].nLen >> 10, ri.nLen >> 10); } if (RomFind[i].nState == 4) { BzipDetail.Add(_T("%hs is %dk which is too big. (It should be %dkB.)\n"), GetFilenameA(List[nFind].szName), List[nFind].nLen >> 10, ri.nLen >> 10); } } } }
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 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 2; } // 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 3; } 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++) { if ( strlen(szAppRomPaths[d]) > 0 ){ TCHAR szFullName[MAX_PATH]; _stprintf(szFullName, _T("%s%hs"), szAppRomPaths[d], szName); if (ZipOpen(szFullName) == 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(szBzipName[z]) == 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); } } } } BzipListFree(); } ZipClose(); // Close the last zip file if open nCurrentZip = -1; } if (!bootApp) { // Check the roms to see if the code, graphics etc are complete CheckRoms(); if (nBzipError & 0x2000) { if (!(nBzipError & 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 (nBzipError & 0x0101) { // FBAPopupAddText(PUF_TEXT_DEFAULT, _T("\n ") _T(SEPERATOR_1)); if (nBzipError & 0x0001) { // FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_ESS_MISS)); } else { // FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_ESS_BAD)); } } if (nBzipError & 0x0202) { // FBAPopupAddText(PUF_TEXT_DEFAULT, _T("\n ") _T(SEPERATOR_1)); // FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DET_PRG)); if (nBzipError & 0x0002) { // FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DATA_MISS)); } else { // FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DATA_BAD)); } } if (nBzipError & 0x0404) { // FBAPopupAddText(PUF_TEXT_DEFAULT, _T("\n ") _T(SEPERATOR_1)); // FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DET_GRA)); if (nBzipError & 0x0004) { // FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DATA_MISS)); } else { // FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DATA_BAD)); } } if (nBzipError & 0x0808) { // FBAPopupAddText(PUF_TEXT_DEFAULT, _T("\n ") _T(SEPERATOR_1)); // FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_LOAD_DET_SND)); if (nBzipError & 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 ((nBzipError & 0x0F0F) == 0) { if (nBzipError & 0x0010) { // FBAPopupAddText(PUF_TEXT_DEFAULT, _T("\n ") _T(SEPERATOR_1)); if (nBzipError & 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 = BzipBurnLoadRom; // Okay to call our function to load each rom } else { return CheckRomsBoot(); } return 0; }