2012-11-01 15:19:01 +00:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// 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
|
2012-11-04 22:01:49 +00:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
// 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 git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2013-09-04 10:07:42 +00:00
|
|
|
#include <WinNls.h>
|
2013-07-29 04:01:49 +00:00
|
|
|
#include "Common/CommonWindows.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
#include "file/vfs.h"
|
|
|
|
#include "file/zip_read.h"
|
2013-09-04 09:29:38 +00:00
|
|
|
#include "base/NativeApp.h"
|
2013-08-26 17:00:16 +00:00
|
|
|
#include "util/text/utf8.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-07-29 04:01:49 +00:00
|
|
|
#include "Core/Config.h"
|
|
|
|
#include "Core/SaveState.h"
|
|
|
|
#include "Windows/EmuThread.h"
|
2013-01-08 16:03:17 +00:00
|
|
|
#include "ext/disarm.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-07-29 04:01:49 +00:00
|
|
|
#include "Common/LogManager.h"
|
|
|
|
#include "Common/ConsoleListener.h"
|
|
|
|
#include "Common/Thread.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
#include "Commctrl.h"
|
|
|
|
|
|
|
|
#include "Windows/resource.h"
|
|
|
|
|
|
|
|
#include "Windows/WndMainWindow.h"
|
|
|
|
#include "Windows/Debugger/Debugger_MemoryDlg.h"
|
|
|
|
#include "Windows/Debugger/Debugger_VFPUDlg.h"
|
|
|
|
|
|
|
|
#include "Windows/W32Util/DialogManager.h"
|
|
|
|
|
|
|
|
#include "Windows/Debugger/CtrlDisAsmView.h"
|
|
|
|
#include "Windows/Debugger/CtrlMemView.h"
|
|
|
|
#include "Windows/Debugger/CtrlRegisterList.h"
|
|
|
|
|
|
|
|
#include "Windows/WindowsHost.h"
|
|
|
|
#include "Windows/main.h"
|
|
|
|
|
2013-04-01 01:35:29 +00:00
|
|
|
CDisasm *disasmWindow[MAX_CPUCOUNT] = {0};
|
|
|
|
CMemoryDlg *memoryWindow[MAX_CPUCOUNT] = {0};
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-09-04 10:07:42 +00:00
|
|
|
static std::string langRegion;
|
|
|
|
|
2013-08-26 17:00:16 +00:00
|
|
|
void LaunchBrowser(const char *url) {
|
|
|
|
ShellExecute(NULL, L"open", ConvertUTF8ToWString(url).c_str(), NULL, NULL, SW_SHOWNORMAL);
|
2013-08-17 22:41:19 +00:00
|
|
|
}
|
|
|
|
|
2013-09-04 09:29:38 +00:00
|
|
|
std::string System_GetProperty(SystemProperty prop) {
|
|
|
|
switch (prop) {
|
|
|
|
case SYSPROP_NAME:
|
|
|
|
return "PC:Windows";
|
|
|
|
case SYSPROP_LANGREGION:
|
2013-09-04 10:07:42 +00:00
|
|
|
return langRegion;
|
2013-09-04 09:29:38 +00:00
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
2013-08-17 22:41:19 +00:00
|
|
|
}
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
|
|
|
|
{
|
|
|
|
Common::EnableCrashingOnCrashes();
|
|
|
|
|
2013-08-26 18:48:34 +00:00
|
|
|
wchar_t modulePath[MAX_PATH];
|
|
|
|
GetModuleFileName(NULL, modulePath, MAX_PATH);
|
2013-08-31 05:12:04 +00:00
|
|
|
for (size_t i = wcslen(modulePath) - 1; i > 0; i--) {
|
2013-08-26 18:48:34 +00:00
|
|
|
if (modulePath[i] == '\\') {
|
|
|
|
modulePath[i] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetCurrentDirectory(modulePath);
|
|
|
|
// GetCurrentDirectory(MAX_PATH, modulePath); // for checking in the debugger
|
2013-09-12 20:56:18 +00:00
|
|
|
#ifndef _DEBUG
|
2012-12-22 17:54:07 +00:00
|
|
|
bool hideLog = true;
|
2013-09-12 20:56:18 +00:00
|
|
|
#else
|
|
|
|
bool hideLog = false;
|
2012-12-22 17:54:07 +00:00
|
|
|
#endif
|
|
|
|
|
2013-09-15 09:02:13 +00:00
|
|
|
VFSRegister("", new DirectoryAssetReader("assets/"));
|
|
|
|
VFSRegister("", new DirectoryAssetReader(""));
|
|
|
|
|
|
|
|
wchar_t lcCountry[256];
|
|
|
|
|
|
|
|
// LOCALE_SNAME is only available in WinVista+
|
|
|
|
// Really should find a way to do this in XP too :/
|
|
|
|
if (0 != GetLocaleInfo(LOCALE_NAME_USER_DEFAULT, LOCALE_SNAME, lcCountry, 256)) {
|
|
|
|
langRegion = ConvertWStringToUTF8(lcCountry);
|
|
|
|
for (int i = 0; i < langRegion.size(); i++) {
|
|
|
|
if (langRegion[i] == '-')
|
|
|
|
langRegion[i] = '_';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
langRegion = "en_US";
|
|
|
|
}
|
|
|
|
|
2013-09-12 20:56:18 +00:00
|
|
|
// Load config up here, because those changes below would be overwritten
|
|
|
|
// if it's not loaded here first.
|
|
|
|
g_Config.Load();
|
|
|
|
|
2013-04-01 01:22:27 +00:00
|
|
|
// The rest is handled in NativeInit().
|
2012-12-22 17:49:29 +00:00
|
|
|
for (int i = 1; i < __argc; ++i)
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
2012-12-22 17:49:29 +00:00
|
|
|
if (__argv[i][0] == '\0')
|
2012-12-22 17:21:23 +00:00
|
|
|
continue;
|
|
|
|
|
2012-12-22 17:49:29 +00:00
|
|
|
if (__argv[i][0] == '-')
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
2012-12-22 17:49:29 +00:00
|
|
|
switch (__argv[i][1])
|
2012-12-22 17:21:23 +00:00
|
|
|
{
|
|
|
|
case 'l':
|
2012-12-22 17:54:07 +00:00
|
|
|
hideLog = false;
|
2012-12-22 17:21:23 +00:00
|
|
|
break;
|
|
|
|
case 's':
|
2013-01-04 09:26:14 +00:00
|
|
|
g_Config.bAutoRun = false;
|
|
|
|
g_Config.bSaveSettings = false;
|
2012-12-22 17:21:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-09-12 20:56:18 +00:00
|
|
|
|
|
|
|
if (!strncmp(__argv[i], "--fullscreen", strlen("--fullscreen")))
|
|
|
|
g_Config.bFullScreen = true;
|
|
|
|
|
|
|
|
if (!strncmp(__argv[i], "--windowed", strlen("--windowed")))
|
|
|
|
g_Config.bFullScreen = false;
|
2012-12-22 17:21:23 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
2013-06-15 08:55:18 +00:00
|
|
|
LogManager::Init();
|
|
|
|
LogManager::GetInstance()->GetConsoleListener()->Open(hideLog, 150, 120, "PPSSPP Debug Console");
|
|
|
|
|
2013-06-08 00:32:07 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
//Windows, API init stuff
|
|
|
|
INITCOMMONCONTROLSEX comm;
|
|
|
|
comm.dwSize = sizeof(comm);
|
|
|
|
comm.dwICC = ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES | ICC_TAB_CLASSES;
|
|
|
|
InitCommonControlsEx(&comm);
|
2012-12-03 08:44:37 +00:00
|
|
|
timeBeginPeriod(1);
|
2012-11-01 15:19:01 +00:00
|
|
|
MainWindow::Init(_hInstance);
|
|
|
|
|
2013-08-26 17:00:16 +00:00
|
|
|
g_hPopupMenus = LoadMenu(_hInstance, (LPCWSTR)IDR_POPUPMENUS);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
MainWindow::Show(_hInstance, iCmdShow);
|
|
|
|
|
|
|
|
HWND hwndMain = MainWindow::GetHWND();
|
2013-06-08 00:32:07 +00:00
|
|
|
HWND hwndDisplay = MainWindow::GetDisplayHWND();
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
//initialize custom controls
|
|
|
|
CtrlDisAsmView::init();
|
|
|
|
CtrlMemView::init();
|
|
|
|
CtrlRegisterList::init();
|
|
|
|
|
|
|
|
DialogManager::AddDlg(memoryWindow[0] = new CMemoryDlg(_hInstance, hwndMain, currentDebugMIPS));
|
|
|
|
DialogManager::AddDlg(vfpudlg = new CVFPUDlg(_hInstance, hwndMain, currentDebugMIPS));
|
|
|
|
|
2013-06-08 00:32:07 +00:00
|
|
|
host = new WindowsHost(hwndMain, hwndDisplay);
|
2013-08-20 15:21:25 +00:00
|
|
|
host->SetWindowTitle(0);
|
2013-03-29 17:50:08 +00:00
|
|
|
|
2013-08-26 12:19:46 +00:00
|
|
|
MainWindow::CreateDebugWindows();
|
|
|
|
|
2013-03-29 17:50:08 +00:00
|
|
|
// Emu thread is always running!
|
|
|
|
EmuThread_Start();
|
|
|
|
|
2013-06-08 00:32:07 +00:00
|
|
|
HACCEL hAccelTable = LoadAccelerators(_hInstance, (LPCTSTR)IDR_ACCELS);
|
2013-08-14 21:30:50 +00:00
|
|
|
HACCEL hDebugAccelTable = LoadAccelerators(_hInstance, (LPCTSTR)IDR_DEBUGACCELS);
|
2012-12-22 17:21:23 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
//so.. we're at the message pump of the GUI thread
|
2013-06-08 00:32:07 +00:00
|
|
|
for (MSG msg; GetMessage(&msg, NULL, 0, 0); ) // for no quit
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
|
|
|
//DSound_UpdateSound();
|
|
|
|
|
2013-05-13 08:08:10 +00:00
|
|
|
if (msg.message == WM_KEYDOWN)
|
|
|
|
{
|
|
|
|
//hack to enable/disable menu command accelerate keys
|
|
|
|
MainWindow::UpdateCommands();
|
|
|
|
|
|
|
|
//hack to make it possible to get to main window from floating windows with Esc
|
|
|
|
if (msg.hwnd != hwndMain && msg.wParam == VK_ESCAPE)
|
|
|
|
BringWindowToTop(hwndMain);
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
//Translate accelerators and dialog messages...
|
2013-08-14 21:46:59 +00:00
|
|
|
HWND wnd;
|
|
|
|
HACCEL accel;
|
2013-08-30 18:13:59 +00:00
|
|
|
if (g_debuggerActive) {
|
2013-08-14 21:46:59 +00:00
|
|
|
wnd = disasmWindow[0]->GetDlgHandle();
|
|
|
|
accel = hDebugAccelTable;
|
|
|
|
} else {
|
|
|
|
wnd = hwndMain;
|
|
|
|
accel = hAccelTable;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!TranslateAccelerator(wnd, accel, &msg))
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
|
|
|
if (!DialogManager::IsDialogMessage(&msg))
|
|
|
|
{
|
|
|
|
//and finally translate and dispatch
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-08 18:35:05 +00:00
|
|
|
VFSShutdown();
|
|
|
|
|
2013-06-30 00:47:09 +00:00
|
|
|
EmuThread_Stop();
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
DialogManager::DestroyAll();
|
2012-12-03 08:44:37 +00:00
|
|
|
timeEndPeriod(1);
|
2012-11-01 15:19:01 +00:00
|
|
|
delete host;
|
2013-06-26 07:31:52 +00:00
|
|
|
g_Config.Save();
|
|
|
|
LogManager::Shutdown();
|
2012-11-01 15:19:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|