Example #1
0
static int getArchiveInfo(const char* path, const char* name)
{
	if (!name || !path) {
		return 1;
	}

	// omit extension
	string _name = name;
	lowerString(_name); // case-insensitive
	size_t pos = _name.rfind(".");
	_name = _name.substr(0, pos);

//	if (_name == "sf2m13") {
//		int dummy = 0;
//	}

	// set progress
	//checkScanThread();
	//romsSetProgress();

	// find name
	map<string, GameInfo*>::iterator _it = allGameMap.find(_name);
	if (_it == allGameMap.end()) {
		return 1;
	}

	GameInfo* gameInfo = _it->second;
	if (!gameInfo) {
		return 1;
	}

	static char fileName[MAX_PATH];
	sprintf(fileName, "%s%s", path, name);

	if (archiveOpenA(fileName)) {
		return 1;
	}

	if (archiveGetList(&List, &listCount)) {
		freeArchiveList();
		return 1;
	}

	RomInfo* romInfo = NULL;
	map<unsigned int, RomInfo>::iterator iter;

	for (int i = 0; i < listCount; i++) {
		// check roms
		iter = gameInfo->roms.find(List[i].nCrc);
		if (iter != gameInfo->roms.end()) {
			romInfo = &iter->second;
			if (!romInfo) {
				continue;
			}

			if (romInfo->size != List[i].nLen) {
				if (List[i].nLen < romInfo->size) {
					romInfo->state = STAT_SMALL;
				} else {
					romInfo->state = STAT_LARGE;
				}
			} else {
				romInfo->state = STAT_OK;
			}
		} else {
			// wrong CRC
			if (nLoadMenuShowX & DISABLECRC) {
				RomInfo* rom = getSetHasRom(gameInfo, List[i].szName);
				if (rom) {
					rom->state = STAT_OK;
				}
			}
		}

		// check all clones
		setCloneRomInfo(gameInfo, List[i]);
	}

	archiveClose();

	freeArchiveList();

	return 0;
}
Example #2
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;
}
Example #3
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);



#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
 
		return 1;
	}

	return 0;
}