コード例 #1
0
ファイル: fceu.c プロジェクト: ficoos/fceu-next
FCEUGI *FCEUI_LoadGame(const char *name)
{
	FCEUFILE *fp;

	ResetGameLoaded();

	FCEUGameInfo = malloc(sizeof(FCEUGI));
	memset(FCEUGameInfo, 0, sizeof(FCEUGI));

	FCEUGameInfo->soundchan = 0;
	FCEUGameInfo->soundrate = 0;
	FCEUGameInfo->name=0;
	FCEUGameInfo->type=GIT_CART;
	FCEUGameInfo->vidsys=GIV_USER;
	FCEUGameInfo->input[0]=FCEUGameInfo->input[1]=-1;
	FCEUGameInfo->inputfc=-1;
	FCEUGameInfo->cspecial=0;

	GetFileBase(name);

	fp=FCEU_fopen(name,"rb",0);

	if(!fp)
		return 0;	/*Error opening ROM*/

	if(iNESLoad(name,fp))
		goto endlseq;
	if(UNIFLoad(name,fp))
		goto endlseq;
	if(FDSLoad(name,fp))
		goto endlseq;

	FCEU_fclose(fp);	/*An error occcurred while loading the file*/
	return 0;

endlseq:
	FCEU_fclose(fp);

	FCEU_ResetVidSys();
	if(FSettings.GameGenie)
		OpenGenie();

	PowerNES();

	FCEU_LoadGamePalette();
	/*FCEU_LoadGameCheats(0);*/

	FCEU_ResetPalette();

	return(FCEUGameInfo);
}
コード例 #2
0
ファイル: fceu.c プロジェクト: ficoos/fceu-next
FCEUGI *FCEUI_CopyFamiStart(void)
{
	ResetGameLoaded();

	FCEUGameInfo = malloc(sizeof(FCEUGI));
	memset(FCEUGameInfo, 0, sizeof(FCEUGI));

	FCEUGameInfo->soundchan = 0;
	FCEUGameInfo->soundrate = 0;
	FCEUGameInfo->name="copyfami";
	FCEUGameInfo->type=GIT_CART;
	FCEUGameInfo->vidsys=GIV_USER;
	FCEUGameInfo->input[0]=FCEUGameInfo->input[1]=-1;
	FCEUGameInfo->inputfc=-1;
	FCEUGameInfo->cspecial=0;

#ifdef FCEU_LOG
	FCEU_printf("Starting CopyFamicom...\n\n");
#endif

	if(!CopyFamiLoad())
		return 0;	/*An error occurred while starting CopyFamicom*/

	FCEU_ResetVidSys();
	if(FSettings.GameGenie)
		OpenGenie();

	PowerNES();

	FCEU_LoadGamePalette();
	FCEU_LoadGameCheats(0);

	FCEU_ResetPalette();

	return(FCEUGameInfo);
}
コード例 #3
0
ファイル: fceu.c プロジェクト: feraligatr/fceugx
FCEUGI *FCEUI_LoadGame(const char *name)
{
        FCEUFILE *fp;
	char *ipsfn;

        ResetGameLoaded();

	FCEUGameInfo = malloc(sizeof(FCEUGI));
	memset(FCEUGameInfo, 0, sizeof(FCEUGI));

	FCEUGameInfo->soundchan = 0;
	FCEUGameInfo->soundrate = 0;
        FCEUGameInfo->name=0;
        FCEUGameInfo->type=GIT_CART;
        FCEUGameInfo->vidsys=GIV_USER;
        FCEUGameInfo->input[0]=FCEUGameInfo->input[1]=-1;
        FCEUGameInfo->inputfc=-1;
        FCEUGameInfo->cspecial=0;

	FCEU_printf("Loading %s...\n\n",name);

        GetFileBase(name);

	ipsfn=FCEU_MakeFName(FCEUMKF_IPS,0,0);
	fp=FCEU_fopen(name,ipsfn,"rb",0);
	free(ipsfn);

	if(!fp)
        {
 	 FCEU_PrintError("Error opening \"%s\"!",name);
	 return 0;
	}

        if(iNESLoad(name,fp))
         goto endlseq;
        if(NSFLoad(fp))
         goto endlseq;
        if(UNIFLoad(name,fp))
         goto endlseq;
        if(FDSLoad(name,fp))
         goto endlseq;

        FCEU_PrintError("An error occurred while loading the file.");
        FCEU_fclose(fp);
        return 0;

        endlseq:
        FCEU_fclose(fp);

        FCEU_ResetVidSys();
        if(FCEUGameInfo->type!=GIT_NSF)
         if(FSettings.GameGenie)
	  OpenGenie();

        PowerNES();
	FCEUSS_CheckStates();
	FCEUMOV_CheckMovies();

        if(FCEUGameInfo->type!=GIT_NSF)
        {
         FCEU_LoadGamePalette();
         FCEU_LoadGameCheats(0);
        }
        
	FCEU_ResetPalette();
	FCEU_ResetMessages();	// Save state, status messages, etc.

        return(FCEUGameInfo);
}
コード例 #4
0
ファイル: emulator_fileio.cpp プロジェクト: cdenix/fceu-ps3
bool LoadRom(const char* fname, int size)
{
	bool biosError = false;
	bool rom_loaded = false;

	ResetGameLoaded();

	FCEUI_CloseGame();
	GameInfo = new FCEUGI();
	memset(GameInfo, 0, sizeof(FCEUGI));

	GameInfo->filename = strdup(fname);
	GameInfo->archiveCount = 0;

	// Set some default values
#define AUDIO_OUT_RATE (48300) // We want slightly more than 48kHz to make sure we're blocking on audio rather than video.
	GameInfo->soundchan = 2;
	GameInfo->soundrate = AUDIO_OUT_RATE;
	GameInfo->name=0;
	GameInfo->type=GIT_CART;
	GameInfo->vidsys=GIV_USER;
	GameInfo->input[0]=GameInfo->input[1]=SI_UNSET;
	GameInfo->inputfc=SIFC_UNSET;
	GameInfo->cspecial=SIS_NONE;

	//Set internal sound information
	FCEUI_Sound(AUDIO_OUT_RATE);

	FCEUFILE * fceufp = new FCEUFILE();
	fceufp->size = size;
	fceufp->filename = fname;
	fceufp->mode = FCEUFILE::READ; // read only
	EMUFILE_MEMFILE *fceumem = new EMUFILE_MEMFILE(nesrom, size);
	fceufp->stream = fceumem;

	rom_loaded = iNESLoad(fname, fceufp, 1);

	if(!rom_loaded)
	{
			rom_loaded = UNIFLoad(fname, fceufp);
	}

	if(!rom_loaded)
	{
			rom_loaded = NSFLoad(fname, fceufp);
	}

	if(!rom_loaded)
	{
	/*		// read FDS BIOS into FDSBIOS - should be 8192 bytes
			if (FDSBIOS[1] == 0)
			{
					size_t biosSize = 0;
					char * tmpbuffer = (char *) memalign(32, 64 * 1024);

					char filepath[1024];

					sprintf (filepath, "%s%s/disksys.rom", pathPrefix[GCSettings.LoadMethod], APPFOLDER);
					biosSize = LoadFile(tmpbuffer, filepath, 0, SILENT);
					if(biosSize == 0 && strlen(appPath) > 0)
					{
							sprintf (filepath, "%s/disksys.rom", appPath);
							biosSize = LoadFile(tmpbuffer, filepath, 0, SILENT);
					}

					if (biosSize == 8192)
					{
							memcpy(FDSBIOS, tmpbuffer, 8192);
					}
					else
					{
							biosError = true;

							if (biosSize > 0)
									ErrorPrompt("FDS BIOS file is invalid!");
							else
									ErrorPrompt("FDS BIOS file not found!");
					}
					free(tmpbuffer);
			}
			if (FDSBIOS[1] != 0)
			{
					rom_loaded = FDSLoad(current_rom, fceufp);
			}*/
	}

	delete fceufp;

	if (rom_loaded)
	{
		GetFileBase(GameInfo->filename);

		FCEU_ResetVidSys();

		if(GameInfo->type!=GIT_NSF)
		{
			if(FSettings.GameGenie)
			{
				OpenGenie();
			}
		}
		PowerNES();

		if(GameInfo->type!=GIT_NSF)
		{
			FCEU_LoadGamePalette();
			FCEU_LoadGameCheats(0);
			FCEUI_DisableAllCheats();
		}

		FCEU_ResetPalette();
		FCEU_ResetMessages();

		return 1;
	}
	else
	{
		delete GameInfo;
		GameInfo = 0;

		if(!biosError)
			FCEU_printf("Invalid game file: %s!",fname);
		rom_loaded = false;
		return 0;
	}
}