2008-09-02 03:57:21 +02:00
|
|
|
/****************************************************************************
|
2009-07-22 04:05:49 +02:00
|
|
|
* FCE Ultra
|
2008-09-02 03:57:21 +02:00
|
|
|
* Nintendo Wii/Gamecube Port
|
|
|
|
*
|
2023-01-30 22:07:47 +01:00
|
|
|
* Tantric 2008-2023
|
2008-09-02 03:57:21 +02:00
|
|
|
*
|
|
|
|
* fceload.c
|
|
|
|
*
|
|
|
|
* NES Memory Load Game
|
|
|
|
*
|
|
|
|
* This performs the functions of LoadGame and iNESLoad from a single module
|
|
|
|
* Helper function for GameCube injected ROMS
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2009-02-07 01:57:39 +01:00
|
|
|
#include <malloc.h>
|
2010-08-29 23:15:42 +02:00
|
|
|
#include <gctypes.h>
|
2008-09-02 03:57:21 +02:00
|
|
|
|
2010-03-22 00:49:24 +01:00
|
|
|
#include "fceultra/file.h"
|
2009-12-14 07:56:29 +01:00
|
|
|
|
2008-11-17 01:09:31 +01:00
|
|
|
#include "fceugx.h"
|
2008-10-22 18:46:44 +02:00
|
|
|
#include "gcaudio.h"
|
2009-07-17 19:27:04 +02:00
|
|
|
#include "fceusupport.h"
|
2008-09-02 03:57:21 +02:00
|
|
|
#include "pad.h"
|
2009-03-28 18:23:08 +01:00
|
|
|
#include "menu.h"
|
2008-10-01 07:25:38 +02:00
|
|
|
#include "fileop.h"
|
2009-03-28 18:23:08 +01:00
|
|
|
#include "filebrowser.h"
|
2009-07-22 03:58:45 +02:00
|
|
|
#include "cheatmgr.h"
|
2008-09-02 03:57:21 +02:00
|
|
|
|
|
|
|
bool romLoaded = false;
|
|
|
|
|
2009-10-02 00:21:25 +02:00
|
|
|
int GCMemROM(int size)
|
2008-10-01 07:25:38 +02:00
|
|
|
{
|
2009-10-04 01:08:40 +02:00
|
|
|
bool biosError = false;
|
|
|
|
|
2009-03-28 18:23:08 +01:00
|
|
|
ResetGameLoaded();
|
2008-09-02 03:57:21 +02:00
|
|
|
|
2009-07-17 19:27:04 +02:00
|
|
|
CloseGame();
|
|
|
|
GameInfo = new FCEUGI();
|
|
|
|
memset(GameInfo, 0, sizeof(FCEUGI));
|
2008-09-02 03:57:21 +02:00
|
|
|
|
2009-07-17 19:27:04 +02:00
|
|
|
GameInfo->filename = strdup(romFilename);
|
|
|
|
GameInfo->archiveCount = 0;
|
2008-09-02 03:57:21 +02:00
|
|
|
|
2009-03-28 18:23:08 +01:00
|
|
|
/*** Set some default values ***/
|
2009-07-17 19:27:04 +02:00
|
|
|
GameInfo->name=0;
|
|
|
|
GameInfo->type=GIT_CART;
|
2020-11-09 00:36:36 +01:00
|
|
|
GameInfo->vidsys=(EGIV)GetFCEUTiming();
|
|
|
|
UpdateDendy();
|
2009-07-17 19:27:04 +02:00
|
|
|
GameInfo->input[0]=GameInfo->input[1]=SI_UNSET;
|
|
|
|
GameInfo->inputfc=SIFC_UNSET;
|
|
|
|
GameInfo->cspecial=SIS_NONE;
|
2008-09-02 03:57:21 +02:00
|
|
|
|
2009-03-28 18:23:08 +01:00
|
|
|
/*** Set internal sound information ***/
|
2011-05-15 20:33:57 +02:00
|
|
|
SetSampleRate();
|
2009-03-28 18:23:08 +01:00
|
|
|
FCEUI_SetSoundVolume(100); // 0-100
|
|
|
|
FCEUI_SetLowPass(0);
|
2008-09-02 03:57:21 +02:00
|
|
|
|
2009-07-18 08:19:04 +02:00
|
|
|
FCEUFILE * fceufp = new FCEUFILE();
|
|
|
|
fceufp->size = size;
|
|
|
|
fceufp->filename = romFilename;
|
2009-12-14 07:56:29 +01:00
|
|
|
fceufp->mode = FCEUFILE::READ; // read only
|
2010-08-29 23:15:42 +02:00
|
|
|
EMUFILE_MEMFILE *fceumem = new EMUFILE_MEMFILE(nesrom, size);
|
2009-07-20 10:05:44 +02:00
|
|
|
fceufp->stream = fceumem;
|
2009-12-14 07:56:29 +01:00
|
|
|
|
2009-07-20 10:05:44 +02:00
|
|
|
romLoaded = iNESLoad(romFilename, fceufp, 1);
|
|
|
|
|
|
|
|
if(!romLoaded)
|
|
|
|
{
|
|
|
|
romLoaded = UNIFLoad(romFilename, fceufp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!romLoaded)
|
|
|
|
{
|
2009-09-15 10:20:48 +02:00
|
|
|
romLoaded = NSFLoad(romFilename, fceufp);
|
2009-07-20 10:05:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!romLoaded)
|
2008-10-01 07:25:38 +02:00
|
|
|
{
|
|
|
|
// read FDS BIOS into FDSBIOS - should be 8192 bytes
|
2009-03-28 18:23:08 +01:00
|
|
|
if (FDSBIOS[1] == 0)
|
2008-10-01 07:25:38 +02:00
|
|
|
{
|
2009-10-04 01:08:40 +02:00
|
|
|
size_t biosSize = 0;
|
2008-10-01 07:25:38 +02:00
|
|
|
char filepath[1024];
|
|
|
|
|
2018-08-28 22:47:21 +02:00
|
|
|
AllocSaveBuffer ();
|
|
|
|
|
2010-01-13 06:53:42 +01:00
|
|
|
sprintf (filepath, "%s%s/disksys.rom", pathPrefix[GCSettings.LoadMethod], APPFOLDER);
|
2018-08-28 22:47:21 +02:00
|
|
|
biosSize = LoadFile(filepath, SILENT);
|
2010-01-13 06:53:42 +01:00
|
|
|
if(biosSize == 0 && strlen(appPath) > 0)
|
2008-10-01 07:25:38 +02:00
|
|
|
{
|
2010-01-13 06:53:42 +01:00
|
|
|
sprintf (filepath, "%s/disksys.rom", appPath);
|
2018-08-28 22:47:21 +02:00
|
|
|
biosSize = LoadFile(filepath, SILENT);
|
2008-10-01 07:25:38 +02:00
|
|
|
}
|
|
|
|
|
2009-03-28 18:23:08 +01:00
|
|
|
if (biosSize == 8192)
|
2008-10-01 07:25:38 +02:00
|
|
|
{
|
2018-08-28 22:47:21 +02:00
|
|
|
memcpy(FDSBIOS, savebuffer, 8192);
|
2008-10-01 07:25:38 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-04 01:08:40 +02:00
|
|
|
biosError = true;
|
|
|
|
|
2009-03-28 18:23:08 +01:00
|
|
|
if (biosSize > 0)
|
|
|
|
ErrorPrompt("FDS BIOS file is invalid!");
|
2009-07-20 08:18:06 +02:00
|
|
|
else
|
|
|
|
ErrorPrompt("FDS BIOS file not found!");
|
2008-10-01 07:25:38 +02:00
|
|
|
}
|
2018-08-28 22:47:21 +02:00
|
|
|
FreeSaveBuffer ();
|
2008-10-01 07:25:38 +02:00
|
|
|
}
|
2009-07-20 09:26:39 +02:00
|
|
|
if (FDSBIOS[1] != 0)
|
|
|
|
{
|
2009-07-20 10:05:44 +02:00
|
|
|
romLoaded = FDSLoad(romFilename, fceufp);
|
2009-07-20 09:26:39 +02:00
|
|
|
}
|
2008-10-01 07:25:38 +02:00
|
|
|
}
|
|
|
|
|
2009-07-20 08:18:06 +02:00
|
|
|
delete fceufp;
|
2009-07-18 08:19:04 +02:00
|
|
|
|
2009-07-20 08:18:06 +02:00
|
|
|
if (romLoaded)
|
2009-03-28 18:23:08 +01:00
|
|
|
{
|
|
|
|
FCEU_ResetVidSys();
|
2009-07-17 19:27:04 +02:00
|
|
|
|
2009-07-29 08:33:17 +02:00
|
|
|
if(GameInfo->type!=GIT_NSF)
|
|
|
|
if(FSettings.GameGenie)
|
|
|
|
OpenGameGenie();
|
2009-03-28 18:23:08 +01:00
|
|
|
PowerNES();
|
2009-07-17 19:27:04 +02:00
|
|
|
|
2009-07-20 08:18:06 +02:00
|
|
|
//if(GameInfo->type!=GIT_NSF)
|
|
|
|
// FCEU_LoadGamePalette();
|
2009-07-17 19:27:04 +02:00
|
|
|
|
2009-03-28 18:23:08 +01:00
|
|
|
FCEU_ResetPalette();
|
2009-07-17 19:27:04 +02:00
|
|
|
FCEU_ResetMessages(); // Save state, status messages, etc.
|
2009-07-22 03:58:45 +02:00
|
|
|
SetupCheats();
|
2009-03-28 18:23:08 +01:00
|
|
|
ResetAudio();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-17 19:27:04 +02:00
|
|
|
delete GameInfo;
|
|
|
|
GameInfo = 0;
|
|
|
|
|
2009-10-04 01:08:40 +02:00
|
|
|
if(!biosError)
|
|
|
|
ErrorPrompt("Invalid game file!");
|
2009-03-28 18:23:08 +01:00
|
|
|
romLoaded = false;
|
|
|
|
return 0;
|
|
|
|
}
|
2008-09-02 03:57:21 +02:00
|
|
|
}
|