예제 #1
0
static int DoLibInit()					// Do Init of Burn library driver
{
	int nRet = 0;

	BArchiveOpen(false);

	// If there is a problem with the romset, report it
	switch (BArchiveStatus()) {
		case BARC_STATUS_BADDATA: {
			//FBAPopupDisplay(PUF_TYPE_WARNING);
			//BArchiveClose();
			//return 1;
			break;
		}
		case BARC_STATUS_ERROR: {
			FBAPopupDisplay(PUF_TYPE_ERROR);

#if 0 || !defined FBA_DEBUG
			// Don't even bother trying to start the game if we know it won't work
			BArchiveClose();
			return 1;
#endif

			break;
		}
		default: {

#if 0 && defined FBA_DEBUG
			FBAPopupDisplay(PUF_TYPE_INFO);
#else
			FBAPopupDisplay(PUF_TYPE_INFO | PUF_TYPE_LOGONLY);
#endif

		}
	}

	//ProgressCreate();

	nRet = BurnDrvInit();

	BArchiveClose();

	//ProgressDestroy();

	if (nRet) {
		return 3;
	} else {
		return 0;
	}
}
예제 #2
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;

	BArchiveOpen(false);

	if ((nRet = BurnExtLoadRom(Dest, pnWrote, i)) != 0) {
		char* pszFilename;

		BurnDrvGetRomName(&pszFilename, i, 0);
 	}

	BArchiveClose();

	BurnExtLoadRom = DrvLoadRom;

	//scrnTitle();

	return nRet;
}
예제 #3
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);
					}
				}
			}