ppsspp/Windows/main.cpp

164 lines
4.1 KiB
C++
Raw Normal View History

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
// 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/.
#include <windows.h>
void LaunchBrowser(const char *url)
{
ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
}
2012-11-01 15:19:01 +00:00
#include "file/vfs.h"
#include "file/zip_read.h"
#include "../Core/Config.h"
#include "../Core/SaveState.h"
#include "EmuThread.h"
#include "ext/disarm.h"
2012-11-01 15:19:01 +00:00
#include "LogManager.h"
#include "ConsoleListener.h"
#include "Thread.h"
#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"
CDisasm *disasmWindow[MAX_CPUCOUNT] = {0};
CMemoryDlg *memoryWindow[MAX_CPUCOUNT] = {0};
2012-11-01 15:19:01 +00:00
int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
{
Common::EnableCrashingOnCrashes();
2012-12-22 17:54:07 +00:00
bool hideLog = true;
2012-11-01 15:19:01 +00:00
2012-12-22 17:54:07 +00:00
#ifdef _DEBUG
hideLog = false;
#endif
2012-11-01 15:19:01 +00:00
// The rest is handled in NativeInit().
for (int i = 1; i < __argc; ++i)
2012-11-01 15:19:01 +00:00
{
if (__argv[i][0] == '\0')
continue;
if (__argv[i][0] == '-')
2012-11-01 15:19:01 +00:00
{
switch (__argv[i][1])
{
case 'l':
2012-12-22 17:54:07 +00:00
hideLog = false;
break;
case 's':
g_Config.bAutoRun = false;
g_Config.bSaveSettings = false;
break;
}
}
2012-11-01 15:19:01 +00:00
}
g_Config.Load();
LogManager::Init();
LogManager::GetInstance()->GetConsoleListener()->Open(hideLog, 150, 120, "PPSSPP Debug Console");
LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LERROR);
VFSRegister("", new DirectoryAssetReader("assets/"));
VFSRegister("", new DirectoryAssetReader(""));
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);
timeBeginPeriod(1);
2012-11-01 15:19:01 +00:00
MainWindow::Init(_hInstance);
g_hPopupMenus = LoadMenu(_hInstance, (LPCSTR)IDR_POPUPMENUS);
MainWindow::Show(_hInstance, iCmdShow);
HWND hwndMain = MainWindow::GetHWND();
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));
host = new WindowsHost(hwndMain, hwndDisplay);
2013-03-29 17:50:08 +00:00
// Emu thread is always running!
EmuThread_Start();
HACCEL hAccelTable = LoadAccelerators(_hInstance, (LPCTSTR)IDR_ACCELS);
2012-11-01 15:19:01 +00:00
//so.. we're at the message pump of the GUI thread
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...
if (!TranslateAccelerator(hwndMain, hAccelTable, &msg))
{
if (!DialogManager::IsDialogMessage(&msg))
{
//and finally translate and dispatch
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
2013-02-08 18:35:05 +00:00
VFSShutdown();
2012-11-01 15:19:01 +00:00
DialogManager::DestroyAll();
timeEndPeriod(1);
2012-11-01 15:19:01 +00:00
delete host;
g_Config.Save();
LogManager::Shutdown();
2012-11-01 15:19:01 +00:00
return 0;
}