If the DSP LLE can not find the needed ROM files exit the emulator without crashing the application. Also reimplement soren's revision 7195 in a way that works on linux and windows. (This makes it easier to clean up the video backend if the DSP emulator fails to initialize.)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7271 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice
2011-03-02 05:16:49 +00:00
parent 6073600084
commit 3af93e8cf3
12 changed files with 163 additions and 115 deletions

View File

@ -203,8 +203,6 @@ bool Init()
Host_SetWaitCursor(true);
Host_UpdateMainFrame(); // Disable any menus or buttons at boot
emuThreadGoing.Init();
g_aspect_wide = _CoreParameter.bWii;
if (g_aspect_wide)
{
@ -221,14 +219,19 @@ bool Init()
g_pWindowHandle = Host_GetRenderHandle();
if (!g_video_backend->Initialize(g_pWindowHandle))
{
emuThreadGoing.Shutdown();
Host_SetWaitCursor(false);
return false;
}
HW::Init();
DSP::GetDSPEmulator()->Initialize(g_pWindowHandle,
_CoreParameter.bWii, _CoreParameter.bDSPThread);
if (!DSP::GetDSPEmulator()->Initialize(g_pWindowHandle,
_CoreParameter.bWii, _CoreParameter.bDSPThread))
{
HW::Shutdown();
g_video_backend->Shutdown();
Host_SetWaitCursor(false);
return false;
}
Pad::Initialize(g_pWindowHandle);
// Load and Init Wiimotes - only if we are booting in wii mode
if (g_CoreStartupParameter.bWii)
@ -245,6 +248,8 @@ bool Init()
// The hardware is initialized.
g_bHwInit = true;
emuThreadGoing.Init();
// Start the emu thread
g_EmuThread = std::thread(EmuThread);

View File

@ -61,7 +61,7 @@ static bool LoadRom(const char *fname, int size_in_words, u16 *rom)
return true;
}
PanicAlertT("Failed to load DSP ROM: %s", fname);
PanicAlertT("Failed to load DSP ROM:\n%s\nThis file is required to use DSP LLE", fname);
return false;
}
@ -87,6 +87,14 @@ static bool VerifyRoms(const char *irom_filename, const char *coef_filename)
return true;
}
static void DSPCore_FreeMemoryPages()
{
FreeMemoryPages(g_dsp.irom, DSP_IROM_BYTE_SIZE);
FreeMemoryPages(g_dsp.iram, DSP_IRAM_BYTE_SIZE);
FreeMemoryPages(g_dsp.dram, DSP_DRAM_BYTE_SIZE);
FreeMemoryPages(g_dsp.coef, DSP_COEF_BYTE_SIZE);
}
bool DSPCore_Init(const char *irom_filename, const char *coef_filename,
bool bUsingJIT)
{
@ -104,10 +112,13 @@ bool DSPCore_Init(const char *irom_filename, const char *coef_filename,
memset(g_dsp.coef, 0, DSP_COEF_BYTE_SIZE);
// Try to load real ROM contents.
LoadRom(irom_filename, DSP_IROM_SIZE, g_dsp.irom);
LoadRom(coef_filename, DSP_COEF_SIZE, g_dsp.coef);
if (!VerifyRoms(irom_filename, coef_filename))
if (!LoadRom(irom_filename, DSP_IROM_SIZE, g_dsp.irom) ||
!LoadRom(coef_filename, DSP_COEF_SIZE, g_dsp.coef) ||
!VerifyRoms(irom_filename, coef_filename))
{
DSPCore_FreeMemoryPages();
return false;
}
memset(&g_dsp.r,0,sizeof(g_dsp.r));
@ -163,6 +174,9 @@ bool DSPCore_Init(const char *irom_filename, const char *coef_filename,
void DSPCore_Shutdown()
{
if (core_state == DSPCORE_STOP)
return;
core_state = DSPCORE_STOP;
if(dspjit) {
@ -170,10 +184,7 @@ void DSPCore_Shutdown()
dspjit = NULL;
}
step_event.Shutdown();
FreeMemoryPages(g_dsp.irom, DSP_IROM_BYTE_SIZE);
FreeMemoryPages(g_dsp.iram, DSP_IRAM_BYTE_SIZE);
FreeMemoryPages(g_dsp.dram, DSP_DRAM_BYTE_SIZE);
FreeMemoryPages(g_dsp.coef, DSP_COEF_BYTE_SIZE);
DSPCore_FreeMemoryPages();
}
void DSPCore_Reset()

View File

@ -28,7 +28,7 @@ public:
virtual bool IsLLE() = 0;
virtual void Initialize(void *hWnd, bool bWii, bool bDSPThread) = 0;
virtual bool Initialize(void *hWnd, bool bWii, bool bDSPThread) = 0;
virtual void Shutdown() = 0;
virtual void DoState(PointerWrap &p) = 0;

View File

@ -50,7 +50,7 @@ struct DSPState
}
};
void DSPHLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
bool DSPHLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
{
m_hWnd = hWnd;
m_bWii = bWii;
@ -65,6 +65,8 @@ void DSPHLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
m_InitMixer = false;
m_dspState.Reset();
return true;
}
void DSPHLE::DSP_StopSoundStream()

View File

@ -29,7 +29,7 @@ class DSPHLE : public DSPEmulator {
public:
DSPHLE();
virtual void Initialize(void *hWnd, bool bWii, bool bDSPThread);
virtual bool Initialize(void *hWnd, bool bWii, bool bDSPThread);
virtual void Shutdown();
virtual bool IsLLE() { return false; }

View File

@ -99,33 +99,26 @@ void DSPLLE::dsp_thread(DSPLLE *lpParameter)
}
}
void DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
bool DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
{
m_hWnd = hWnd;
m_bWii = bWii;
m_bDSPThread = bDSPThread;
m_InitMixer = false;
bool bCanWork = true;
std::string irom_file = File::GetSysDirectory() + GC_SYS_DIR DIR_SEP DSP_IROM;
std::string coef_file = File::GetSysDirectory() + GC_SYS_DIR DIR_SEP DSP_COEF;
if (!File::Exists(irom_file))
irom_file = File::GetUserPath(D_GCUSER_IDX) + DIR_SEP DSP_IROM;
irom_file = File::GetUserPath(D_GCUSER_IDX) + DSP_IROM;
if (!File::Exists(coef_file))
coef_file = File::GetUserPath(D_GCUSER_IDX) + DIR_SEP DSP_COEF;
bCanWork = DSPCore_Init(irom_file.c_str(), coef_file.c_str(), AudioCommon::UseJIT());
coef_file = File::GetUserPath(D_GCUSER_IDX) + DSP_COEF;
if (!DSPCore_Init(irom_file.c_str(), coef_file.c_str(), AudioCommon::UseJIT()))
return false;
g_dsp.cpu_ram = Memory::GetPointer(0);
DSPCore_Reset();
if (!bCanWork)
{
DSPCore_Shutdown();
// No way to shutdown Core from here? Hardcore shutdown!
exit(EXIT_FAILURE);
return;
}
m_bIsRunning = true;
InitInstructionTable();
@ -134,6 +127,8 @@ void DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
m_hDSPThread = std::thread(dsp_thread, this);
Host_RefreshDSPDebuggerWindow();
return true;
}
void DSPLLE::DSP_StopSoundStream()

View File

@ -27,7 +27,7 @@ class DSPLLE : public DSPEmulator {
public:
DSPLLE();
virtual void Initialize(void *hWnd, bool bWii, bool bDSPThread);
virtual bool Initialize(void *hWnd, bool bWii, bool bDSPThread);
virtual void Shutdown();
virtual bool IsLLE() { return true; }