2009-07-28 15:32:10 -06:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include "svnrev.h"
|
|
|
|
|
2008-12-08 02:52:30 -07:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
#include "Common.h" // Common
|
|
|
|
#include "CPUDetect.h"
|
|
|
|
#include "IniFile.h"
|
|
|
|
#include "FileUtil.h"
|
2009-02-22 14:16:12 -07:00
|
|
|
#include "Setup.h"
|
|
|
|
|
|
|
|
#include "Host.h" // Core
|
2009-03-18 11:17:58 -06:00
|
|
|
#include "PluginManager.h"
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-02-22 14:16:12 -07:00
|
|
|
#include "Globals.h" // Local
|
|
|
|
#include "Main.h"
|
2009-01-17 16:41:21 -07:00
|
|
|
#include "ConfigManager.h"
|
2008-12-07 22:30:24 -07:00
|
|
|
#include "CodeWindow.h"
|
2009-08-31 17:09:50 -06:00
|
|
|
#include "LogWindow.h"
|
2009-07-11 14:37:55 -06:00
|
|
|
#include "JitWindow.h"
|
2009-01-08 17:09:07 -07:00
|
|
|
#include "ExtendedTrace.h"
|
2008-12-07 22:30:24 -07:00
|
|
|
#include "BootManager.h"
|
2009-01-04 14:53:41 -07:00
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-09-05 19:40:44 -06:00
|
|
|
// ------------
|
2009-09-03 14:00:09 -06:00
|
|
|
// Main window
|
2009-09-05 19:40:44 -06:00
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
IMPLEMENT_APP(DolphinApp)
|
|
|
|
|
2008-12-14 05:30:37 -07:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-07-11 22:10:52 -06:00
|
|
|
#include <wx/stdpaths.h>
|
2008-12-28 11:50:24 -07:00
|
|
|
bool wxMsgAlert(const char*, const char*, bool, int);
|
2008-12-14 05:30:37 -07:00
|
|
|
#endif
|
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
CFrame* main_frame = NULL;
|
2009-03-18 11:17:58 -06:00
|
|
|
LogManager *logManager = NULL;
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
//Has no error handling.
|
|
|
|
//I think that if an error occurs here there's no way to handle it anyway.
|
|
|
|
LONG WINAPI MyUnhandledExceptionFilter(LPEXCEPTION_POINTERS e) {
|
|
|
|
//EnterCriticalSection(&g_uefcs);
|
|
|
|
|
2009-02-17 15:48:16 -07:00
|
|
|
FILE* file = NULL;
|
2008-12-07 22:30:24 -07:00
|
|
|
fopen_s(&file, "exceptioninfo.txt", "a");
|
|
|
|
fseek(file, 0, SEEK_END);
|
2009-01-08 17:09:07 -07:00
|
|
|
etfprint(file, "\n");
|
|
|
|
//etfprint(file, g_buildtime);
|
|
|
|
//etfprint(file, "\n");
|
2008-12-07 22:30:24 -07:00
|
|
|
//dumpCurrentDate(file);
|
2009-01-08 17:09:07 -07:00
|
|
|
etfprintf(file, "Unhandled Exception\n Code: 0x%08X\n",
|
2008-12-07 22:30:24 -07:00
|
|
|
e->ExceptionRecord->ExceptionCode);
|
|
|
|
#ifndef _M_X64
|
|
|
|
STACKTRACE2(file, e->ContextRecord->Eip, e->ContextRecord->Esp, e->ContextRecord->Ebp);
|
|
|
|
#else
|
|
|
|
STACKTRACE2(file, e->ContextRecord->Rip, e->ContextRecord->Rsp, e->ContextRecord->Rbp);
|
|
|
|
#endif
|
|
|
|
fclose(file);
|
|
|
|
_flushall();
|
|
|
|
|
|
|
|
//LeaveCriticalSection(&g_uefcs);
|
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-07-11 22:10:52 -06:00
|
|
|
// The `main program' equivalent that creates the main window and return the main frame
|
2009-01-04 14:53:41 -07:00
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
bool DolphinApp::OnInit()
|
|
|
|
{
|
2009-02-15 23:18:18 -07:00
|
|
|
|
2009-03-18 11:17:58 -06:00
|
|
|
NOTICE_LOG(BOOT, "Starting application");
|
2009-01-04 14:53:41 -07:00
|
|
|
// Declarations and definitions
|
|
|
|
bool UseDebugger = false;
|
2009-09-01 09:16:44 -06:00
|
|
|
bool UseLogger = false;
|
2009-07-11 22:10:52 -06:00
|
|
|
bool LoadElf = false;
|
|
|
|
wxString ElfFile;
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-01-04 14:53:41 -07:00
|
|
|
// Detect CPU info and write it to the cpu_info struct
|
2009-02-06 11:04:24 -07:00
|
|
|
cpu_info.Detect();
|
|
|
|
|
2009-01-04 14:53:41 -07:00
|
|
|
#if defined _DEBUG && defined _WIN32
|
|
|
|
int tmpflag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
|
|
|
|
tmpflag |= _CRTDBG_DELAY_FREE_MEM_DF;
|
|
|
|
_CrtSetDbgFlag(tmpflag);
|
|
|
|
#endif
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-01-04 14:53:41 -07:00
|
|
|
// Register message box handler
|
2009-01-18 01:47:24 -07:00
|
|
|
#if ! defined(_WIN32) && defined(HAVE_WX) && HAVE_WX
|
2009-01-04 14:53:41 -07:00
|
|
|
RegisterMsgAlertHandler(&wxMsgAlert);
|
2009-01-18 01:47:24 -07:00
|
|
|
#endif
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
|
2009-08-10 18:35:07 -06:00
|
|
|
// "ExtendedTrace" looks freakin dangerous!!!
|
2009-01-04 14:53:41 -07:00
|
|
|
#ifdef _WIN32
|
|
|
|
EXTENDEDTRACEINITIALIZE(".");
|
|
|
|
SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter);
|
2009-03-18 16:05:31 -06:00
|
|
|
#endif
|
|
|
|
|
2009-08-10 18:35:07 -06:00
|
|
|
// TODO: if First Boot
|
|
|
|
if (!cpu_info.bSSE2)
|
|
|
|
{
|
|
|
|
PanicAlert("Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n"
|
|
|
|
"Unfortunately your CPU does not support them, so Dolphin will not run.\n\n"
|
|
|
|
"Sayonara!\n");
|
|
|
|
return false;
|
|
|
|
}
|
2009-07-11 22:10:52 -06:00
|
|
|
#ifndef __APPLE__
|
|
|
|
// Keep the user config dir free unless user wants to save the working dir
|
2009-08-11 06:09:46 -06:00
|
|
|
if (!File::Exists(FULL_CONFIG_DIR "portable"))
|
2009-07-11 22:10:52 -06:00
|
|
|
{
|
|
|
|
char tmp[1024];
|
2009-08-01 23:59:55 -06:00
|
|
|
sprintf(tmp, "%s/.dolphin%swd", (const char*)wxStandardPaths::Get().GetUserConfigDir().mb_str(),
|
2009-07-17 00:03:53 -06:00
|
|
|
#ifdef _M_IX86
|
|
|
|
"x32");
|
|
|
|
#else
|
|
|
|
"x64");
|
|
|
|
#endif
|
2009-07-11 22:10:52 -06:00
|
|
|
FILE* workingDir = fopen(tmp, "r");
|
|
|
|
if (!workingDir)
|
|
|
|
{
|
|
|
|
if (PanicYesNo("Dolphin has not been configured with an install location,\nKeep Dolphin portable?"))
|
|
|
|
{
|
|
|
|
FILE* portable = fopen(FULL_CONFIG_DIR "portable", "w");
|
|
|
|
if (!portable)
|
|
|
|
{
|
|
|
|
PanicAlert("Portable Setting could not be saved\n Are you running Dolphin from read only media or from a directory that dolphin is not located in?");
|
|
|
|
}
|
2009-08-31 16:51:19 -06:00
|
|
|
else
|
|
|
|
{
|
|
|
|
fclose(portable);
|
|
|
|
}
|
2009-07-11 22:10:52 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char CWD[1024];
|
2009-08-01 23:59:55 -06:00
|
|
|
sprintf(CWD, "%s", (const char*)wxGetCwd().mb_str());
|
2009-07-11 22:10:52 -06:00
|
|
|
if (PanicYesNo("Set install location to:\n %s ?", CWD))
|
|
|
|
{
|
|
|
|
FILE* workingDirF = fopen(tmp, "w");
|
2009-08-11 06:09:46 -06:00
|
|
|
if (!workingDirF)
|
|
|
|
PanicAlert("Install directory could not be saved");
|
2009-07-11 22:10:52 -06:00
|
|
|
else
|
|
|
|
{
|
|
|
|
fwrite(CWD, ((std::string)CWD).size()+1, 1, workingDirF);
|
|
|
|
fwrite("", 1, 1, workingDirF); //seems to be needed on linux
|
|
|
|
fclose(workingDirF);
|
|
|
|
}
|
|
|
|
}
|
2009-08-11 06:09:46 -06:00
|
|
|
else
|
|
|
|
PanicAlert("Relaunch Dolphin from the install directory and save from there");
|
2009-07-11 22:10:52 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-12 01:17:43 -06:00
|
|
|
char *tmpChar;
|
|
|
|
long len;
|
2009-08-11 06:09:46 -06:00
|
|
|
fseek(workingDir, 0, SEEK_END);
|
|
|
|
len = ftell(workingDir);
|
|
|
|
fseek(workingDir, 0, SEEK_SET);
|
2009-07-12 01:17:43 -06:00
|
|
|
tmpChar = new char[len];
|
|
|
|
fread(tmpChar, len, 1, workingDir);
|
2009-07-11 22:10:52 -06:00
|
|
|
fclose(workingDir);
|
2009-07-12 01:17:43 -06:00
|
|
|
if (!wxSetWorkingDirectory(wxString::FromAscii(tmpChar)))
|
2009-07-11 22:10:52 -06:00
|
|
|
{
|
2009-07-17 00:03:53 -06:00
|
|
|
INFO_LOG(CONSOLE, "set working directory failed");
|
2009-07-11 22:10:52 -06:00
|
|
|
}
|
2009-07-12 01:17:43 -06:00
|
|
|
delete [] tmpChar;
|
2009-07-11 22:10:52 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-01-04 14:53:41 -07:00
|
|
|
// Parse command lines
|
|
|
|
#if wxUSE_CMDLINE_PARSER
|
|
|
|
wxCmdLineEntryDesc cmdLineDesc[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("Show this help message"),
|
|
|
|
wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP
|
|
|
|
},
|
|
|
|
{
|
|
|
|
wxCMD_LINE_SWITCH, _T("d"), _T("debugger"), _T("Opens the debugger")
|
|
|
|
},
|
2009-09-01 09:16:44 -06:00
|
|
|
{
|
|
|
|
wxCMD_LINE_SWITCH, _T("l"), _T("logger"), _T("Opens The Logger")
|
|
|
|
},
|
2009-01-04 14:53:41 -07:00
|
|
|
{
|
|
|
|
wxCMD_LINE_OPTION, _T("e"), _T("elf"), _T("Loads an elf file"),
|
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
|
|
|
{
|
|
|
|
wxCMD_LINE_NONE
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
// check to see if ~/Library/Application Support/Dolphin exists; if not, create it
|
|
|
|
char AppSupportDir[MAXPATHLEN];
|
|
|
|
snprintf(AppSupportDir, sizeof(AppSupportDir), "%s/Library/Application Support", getenv("HOME"));
|
|
|
|
if (!File::Exists(AppSupportDir) || !File::IsDirectory(AppSupportDir))
|
|
|
|
PanicAlert("Could not open ~/Library/Application Support");
|
|
|
|
|
|
|
|
strlcat(AppSupportDir, "/Dolphin", sizeof(AppSupportDir));
|
|
|
|
|
|
|
|
if (!File::Exists(AppSupportDir))
|
|
|
|
File::CreateDir(AppSupportDir);
|
|
|
|
|
|
|
|
if (!File::IsDirectory(AppSupportDir))
|
|
|
|
PanicAlert("~/Library/Application Support/Dolphin exists, but is not a directory");
|
|
|
|
|
|
|
|
chdir(AppSupportDir);
|
|
|
|
|
2009-05-07 15:19:55 -06:00
|
|
|
//create all necessary dir in user directory
|
|
|
|
if (!File::Exists(FULL_GC_USER_DIR)) File::CreateFullPath(FULL_GC_USER_DIR);
|
|
|
|
if (!File::Exists(FULL_WII_SYSCONF_DIR)) File::CreateFullPath(FULL_WII_SYSCONF_DIR);
|
|
|
|
if (!File::Exists(FULL_CONFIG_DIR)) File::CreateDir(FULL_CONFIG_DIR);
|
|
|
|
if (!File::Exists(FULL_CACHE_DIR)) File::CreateDir(FULL_CACHE_DIR);
|
|
|
|
if (!File::Exists(FULL_DSP_DUMP_DIR)) File::CreateFullPath(FULL_DSP_DUMP_DIR);
|
|
|
|
if (!File::Exists(FULL_DUMP_TEXTURES_DIR)) File::CreateFullPath(FULL_DUMP_TEXTURES_DIR);
|
|
|
|
if (!File::Exists(FULL_HIRES_TEXTURES_DIR)) File::CreateFullPath(FULL_HIRES_TEXTURES_DIR);
|
|
|
|
if (!File::Exists(FULL_MAIL_LOGS_DIR)) File::CreateFullPath(FULL_MAIL_LOGS_DIR);
|
|
|
|
if (!File::Exists(FULL_SCREENSHOTS_DIR)) File::CreateFullPath(FULL_SCREENSHOTS_DIR);
|
|
|
|
if (!File::Exists(FULL_STATESAVES_DIR)) File::CreateFullPath(FULL_STATESAVES_DIR);
|
|
|
|
|
|
|
|
//copy user wii shared2 SYSCONF if not exist
|
|
|
|
if (!File::Exists(WII_SYSCONF_FILE)) File::Copy((File::GetBundleDirectory() + DIR_SEP + "Contents" + DIR_SEP + WII_SYSCONF_FILE).c_str(),WII_SYSCONF_FILE);
|
|
|
|
//TODO : if not exist copy game config dir in user dir and detect the revision to upgrade if necessary
|
|
|
|
//TODO : if not exist copy maps dir in user dir and detect revision to upgrade if necessary
|
|
|
|
|
2009-01-04 14:53:41 -07:00
|
|
|
// HACK: Get rid of bogus osx param
|
|
|
|
if (argc > 1 && wxString(argv[argc - 1]).StartsWith(_("-psn_"))) {
|
|
|
|
delete argv[argc-1];
|
|
|
|
argv[argc-1] = NULL;
|
|
|
|
argc--;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Gets the passed media files from command line
|
|
|
|
wxCmdLineParser parser(cmdLineDesc, argc, argv);
|
|
|
|
|
|
|
|
// Get filenames from the command line
|
|
|
|
if (parser.Parse() != 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-01-04 14:53:41 -07:00
|
|
|
UseDebugger = parser.Found(_T("debugger"));
|
2009-09-01 09:16:44 -06:00
|
|
|
UseLogger = parser.Found(_T("logger"));
|
2009-01-04 14:53:41 -07:00
|
|
|
LoadElf = parser.Found(_T("elf"), &ElfFile);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-01-04 14:53:41 -07:00
|
|
|
if( LoadElf && ElfFile == wxEmptyString )
|
|
|
|
PanicAlert("You did not specify a file name");
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-01-04 14:53:41 -07:00
|
|
|
// ============
|
|
|
|
#endif
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-03-18 16:05:31 -06:00
|
|
|
// Load CONFIG_FILE settings
|
2009-03-18 11:17:58 -06:00
|
|
|
SConfig::GetInstance().LoadSettings();
|
2009-03-18 16:05:31 -06:00
|
|
|
|
|
|
|
// Enable the PNG image handler
|
|
|
|
wxInitAllImageHandlers();
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-03-18 16:05:31 -06:00
|
|
|
SetEnableAlert(SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers);
|
|
|
|
|
2009-01-04 14:53:41 -07:00
|
|
|
// Create the window title
|
|
|
|
#ifdef _DEBUG
|
2009-03-18 16:05:31 -06:00
|
|
|
const char *title = "Dolphin Debug SVN R " SVN_REV_STR;
|
2009-01-04 14:53:41 -07:00
|
|
|
#else
|
2009-03-18 16:05:31 -06:00
|
|
|
const char *title = "Dolphin SVN R " SVN_REV_STR;
|
2009-01-04 14:53:41 -07:00
|
|
|
#endif
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
// If we are debugging let use save the main window position and size
|
|
|
|
IniFile ini;
|
|
|
|
ini.Load(DEBUGGER_CONFIG_FILE);
|
|
|
|
int x, y, w, h;
|
|
|
|
ini.Get("MainWindow", "x", &x, 100);
|
|
|
|
ini.Get("MainWindow", "y", &y, 100);
|
2009-01-19 13:43:47 -07:00
|
|
|
ini.Get("MainWindow", "w", &w, 800);
|
|
|
|
ini.Get("MainWindow", "h", &h, 600);
|
2009-03-18 11:17:58 -06:00
|
|
|
|
2009-02-20 15:04:52 -07:00
|
|
|
if (UseDebugger)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2009-09-01 09:16:44 -06:00
|
|
|
main_frame = new CFrame((wxFrame*)NULL, wxID_ANY, wxString::FromAscii(title),
|
|
|
|
wxPoint(x, y), wxSize(w, h), true, UseLogger);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-01 09:16:44 -06:00
|
|
|
main_frame = new CFrame((wxFrame*)NULL, wxID_ANY, wxString::FromAscii(title),
|
|
|
|
wxPoint(100, 100), wxSize(800, 600), false, UseLogger);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2009-01-04 14:53:41 -07:00
|
|
|
|
2009-09-05 19:40:44 -06:00
|
|
|
// ------------
|
2009-01-04 14:53:41 -07:00
|
|
|
// Check the autoboot options.
|
2009-09-05 19:40:44 -06:00
|
|
|
|
2009-01-04 14:53:41 -07:00
|
|
|
// First check if we have a elf command line. Todo: Should we place this under #if wxUSE_CMDLINE_PARSER?
|
2008-12-07 22:30:24 -07:00
|
|
|
if (LoadElf && ElfFile != wxEmptyString)
|
|
|
|
{
|
2009-08-01 23:59:55 -06:00
|
|
|
BootManager::BootCore(std::string(ElfFile.mb_str()));
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
/* If we have selected Automatic Start, start the default ISO, or if no default
|
|
|
|
ISO exists, start the last loaded ISO */
|
2009-08-24 19:50:27 -06:00
|
|
|
else if (UseDebugger)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2009-08-24 19:50:27 -06:00
|
|
|
if (main_frame->g_pCodeWindow->AutomaticStart())
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2009-08-24 19:50:27 -06:00
|
|
|
if(!SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM.empty()
|
|
|
|
&& File::Exists(SConfig::GetInstance().m_LocalCoreStartupParameter.
|
|
|
|
m_strDefaultGCM.c_str()))
|
|
|
|
{
|
|
|
|
BootManager::BootCore(SConfig::GetInstance().m_LocalCoreStartupParameter.
|
|
|
|
m_strDefaultGCM);
|
|
|
|
}
|
|
|
|
else if(!SConfig::GetInstance().m_LastFilename.empty()
|
|
|
|
&& File::Exists(SConfig::GetInstance().m_LastFilename.c_str()))
|
|
|
|
{
|
|
|
|
BootManager::BootCore(SConfig::GetInstance().m_LastFilename);
|
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
2009-01-04 14:53:41 -07:00
|
|
|
// ---------------------
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-01-04 14:53:41 -07:00
|
|
|
// Set main parent window
|
2008-12-07 22:30:24 -07:00
|
|
|
SetTopWindow(main_frame);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DolphinApp::OnEndSession()
|
|
|
|
{
|
|
|
|
SConfig::GetInstance().SaveSettings();
|
|
|
|
}
|
2009-01-04 14:53:41 -07:00
|
|
|
|
2009-09-03 01:59:24 -06:00
|
|
|
|
2009-09-05 19:40:44 -06:00
|
|
|
// ------------
|
2009-09-03 14:00:09 -06:00
|
|
|
// Talk to GUI
|
2009-09-05 19:40:44 -06:00
|
|
|
|
2009-09-03 14:00:09 -06:00
|
|
|
|
2009-09-03 01:59:24 -06:00
|
|
|
// g_VideoInitialize.pSysMessage() goes here
|
|
|
|
void Host_SysMessage(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list list;
|
|
|
|
char msg[512];
|
|
|
|
|
|
|
|
va_start(list, fmt);
|
|
|
|
vsprintf(msg, fmt, list);
|
|
|
|
va_end(list);
|
|
|
|
|
|
|
|
if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
|
|
|
|
//wxMessageBox(wxString::FromAscii(msg));
|
|
|
|
PanicAlert("%s", msg);
|
|
|
|
}
|
|
|
|
|
2009-01-18 01:47:24 -07:00
|
|
|
#if defined HAVE_WX && HAVE_WX
|
2009-01-23 17:45:46 -07:00
|
|
|
bool wxMsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*/)
|
2008-12-28 11:50:24 -07:00
|
|
|
{
|
2009-01-18 01:47:24 -07:00
|
|
|
return wxYES == wxMessageBox(wxString::FromAscii(text),
|
|
|
|
wxString::FromAscii(caption),
|
|
|
|
(yes_no)?wxYES_NO:wxOK);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2009-03-20 12:25:36 -06:00
|
|
|
// Accessor for the main window class
|
|
|
|
CFrame* DolphinApp::GetCFrame()
|
|
|
|
{
|
|
|
|
return main_frame;
|
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
// OK, this thread boundary is DANGEROUS on linux
|
|
|
|
// wxPostEvent / wxAddPendingEvent is the solution.
|
|
|
|
void Host_NotifyMapLoaded()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_NOTIFYMAPLOADED);
|
|
|
|
wxPostEvent(main_frame, event);
|
|
|
|
|
2009-09-03 01:59:24 -06:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2009-09-03 01:59:24 -06:00
|
|
|
wxPostEvent(main_frame->g_pCodeWindow, event);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Host_UpdateLogDisplay()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATELOGDISPLAY);
|
|
|
|
wxPostEvent(main_frame, event);
|
|
|
|
|
2009-09-03 01:59:24 -06:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2009-09-03 01:59:24 -06:00
|
|
|
wxPostEvent(main_frame->g_pCodeWindow, event);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Host_UpdateDisasmDialog()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEDISASMDIALOG);
|
|
|
|
wxPostEvent(main_frame, event);
|
2009-07-15 09:09:20 -06:00
|
|
|
|
2009-09-03 01:59:24 -06:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2009-09-03 01:59:24 -06:00
|
|
|
wxPostEvent(main_frame->g_pCodeWindow, event);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-11 14:37:55 -06:00
|
|
|
void Host_ShowJitResults(unsigned int address)
|
|
|
|
{
|
|
|
|
CJitWindow::ViewAddr(address);
|
|
|
|
}
|
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
void Host_UpdateMainFrame()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEGUI);
|
|
|
|
wxPostEvent(main_frame, event);
|
|
|
|
|
2009-09-03 01:59:24 -06:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2009-09-03 01:59:24 -06:00
|
|
|
wxPostEvent(main_frame->g_pCodeWindow, event);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
2009-08-27 05:08:52 -06:00
|
|
|
// Remove this?
|
2008-12-07 22:30:24 -07:00
|
|
|
void Host_UpdateBreakPointView()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEBREAKPOINTS);
|
|
|
|
wxPostEvent(main_frame, event);
|
|
|
|
|
2009-09-03 01:59:24 -06:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2009-09-03 01:59:24 -06:00
|
|
|
wxPostEvent(main_frame->g_pCodeWindow, event);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-02 15:00:45 -06:00
|
|
|
|
2009-08-27 05:08:52 -06:00
|
|
|
// Update Wiimote status bar
|
2009-09-05 19:40:44 -06:00
|
|
|
|
2009-02-08 05:27:04 -07:00
|
|
|
void Host_UpdateLeds(int led_bits)
|
|
|
|
{
|
2008-12-09 13:33:40 -07:00
|
|
|
// Convert it to a simpler byte format
|
|
|
|
main_frame->g_Leds[0] = led_bits >> 0;
|
|
|
|
main_frame->g_Leds[1] = led_bits >> 1;
|
|
|
|
main_frame->g_Leds[2] = led_bits >> 2;
|
|
|
|
main_frame->g_Leds[3] = led_bits >> 3;
|
|
|
|
|
|
|
|
main_frame->UpdateLeds();
|
|
|
|
}
|
|
|
|
|
2009-02-08 05:27:04 -07:00
|
|
|
void Host_UpdateSpeakerStatus(int index, int speaker_bits)
|
|
|
|
{
|
2008-12-09 13:33:40 -07:00
|
|
|
main_frame->g_Speakers[index] = speaker_bits;
|
|
|
|
main_frame->UpdateSpeakers();
|
|
|
|
}
|
|
|
|
|
2009-01-04 14:53:41 -07:00
|
|
|
void Host_UpdateStatus()
|
|
|
|
{
|
2008-12-09 14:46:12 -07:00
|
|
|
// Debugging
|
|
|
|
//std::string Tmp = ArrayToString(main_frame->g_Speakers, sizeof(main_frame->g_Speakers));
|
|
|
|
//std::string Tmp2 = ArrayToString(main_frame->g_Speakers_, sizeof(main_frame->g_Speakers_));
|
|
|
|
//LOGV(CONSOLE, 0, "Tmp: %s", Tmp.c_str());
|
|
|
|
//LOGV(CONSOLE, 0, "Tmp2: %s", Tmp2.c_str());
|
2008-12-09 13:33:40 -07:00
|
|
|
// Don't do a lot of CreateBitmap() if we don't need to
|
|
|
|
if(memcmp(main_frame->g_Speakers_, main_frame->g_Speakers,
|
|
|
|
sizeof(main_frame->g_Speakers)))
|
|
|
|
{
|
2009-02-08 05:27:04 -07:00
|
|
|
// Turn off the activity light again
|
2008-12-09 13:33:40 -07:00
|
|
|
main_frame->g_Speakers[2] = 0;
|
|
|
|
main_frame->UpdateSpeakers();
|
|
|
|
memcpy(main_frame->g_Speakers_, main_frame->g_Speakers, sizeof(main_frame->g_Speakers));
|
|
|
|
}
|
|
|
|
}
|
2009-09-02 15:00:45 -06:00
|
|
|
|
2009-01-04 14:53:41 -07:00
|
|
|
|
2008-12-09 13:33:40 -07:00
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
void Host_UpdateMemoryView()
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
void Host_SetDebugMode(bool)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
void Host_SetWaitCursor(bool enable)
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
if (enable)
|
|
|
|
{
|
|
|
|
SetCursor(LoadCursor(NULL, IDC_WAIT));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetCursor(LoadCursor(NULL, IDC_ARROW));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-02-15 23:18:18 -07:00
|
|
|
void Host_UpdateStatusBar(const char* _pText, int Field)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATESTATUSBAR);
|
2009-02-15 23:18:18 -07:00
|
|
|
// Set the event string
|
2008-12-07 22:30:24 -07:00
|
|
|
event.SetString(wxString::FromAscii(_pText));
|
2009-02-15 23:18:18 -07:00
|
|
|
// Update statusbar field
|
|
|
|
event.SetInt(Field);
|
|
|
|
// Post message
|
2009-08-01 12:16:12 -06:00
|
|
|
// TODO : this has been said to cause hang (??) how is that even possible ? :d
|
2009-09-03 03:13:41 -06:00
|
|
|
event.StopPropagation();
|
2009-08-01 12:16:12 -06:00
|
|
|
wxPostEvent(main_frame, event);
|
2009-09-03 03:13:41 -06:00
|
|
|
// Process the event before continue
|
2009-09-03 14:00:09 -06:00
|
|
|
wxGetApp().ProcessPendingEvents();
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void Host_SetWiiMoteConnectionState(int _State)
|
|
|
|
{
|
|
|
|
static int currentState = -1;
|
|
|
|
if (_State == currentState)
|
|
|
|
return;
|
|
|
|
currentState = _State;
|
|
|
|
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATESTATUSBAR);
|
|
|
|
|
|
|
|
switch(_State)
|
|
|
|
{
|
|
|
|
case 0: event.SetString(wxString::FromAscii("Not connected")); break;
|
|
|
|
case 1: event.SetString(wxString::FromAscii("Connecting...")); break;
|
|
|
|
case 2: event.SetString(wxString::FromAscii("Wiimote Connected")); break;
|
|
|
|
}
|
2009-02-15 23:18:18 -07:00
|
|
|
// Update field 1 or 2
|
|
|
|
#ifdef RERECORDING
|
|
|
|
event.SetInt(2);
|
|
|
|
#else
|
|
|
|
event.SetInt(1);
|
|
|
|
#endif
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
wxPostEvent(main_frame, event);
|
|
|
|
}
|
2009-09-05 19:40:44 -06:00
|
|
|
#endif // HAVE_WX
|