forked from hrydgard/ppsspp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
163 lines (125 loc) · 4.19 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// 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.
// 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);
}
#include "file/vfs.h"
#include "file/zip_read.h"
#include "../Core/Config.h"
#include "../Core/SaveState.h"
#include "EmuThread.h"
#include "ext/disarm.h"
#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};
int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
{
Common::EnableCrashingOnCrashes();
bool hideLog = true;
#ifdef _DEBUG
hideLog = false;
#endif
g_Config.Load();
VFSRegister("", new DirectoryAssetReader("assets/"));
VFSRegister("", new DirectoryAssetReader(""));
// The rest is handled in NativeInit().
for (int i = 1; i < __argc; ++i)
{
if (__argv[i][0] == '\0')
continue;
if (__argv[i][0] == '-')
{
switch (__argv[i][1])
{
case 'l':
hideLog = false;
break;
case 's':
g_Config.bAutoRun = false;
g_Config.bSaveSettings = false;
break;
}
}
}
//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);
MainWindow::Init(_hInstance);
HACCEL hAccelTable = LoadAccelerators(_hInstance, (LPCTSTR)IDR_ACCELS);
g_hPopupMenus = LoadMenu(_hInstance, (LPCSTR)IDR_POPUPMENUS);
MainWindow::Show(_hInstance, iCmdShow);
host = new WindowsHost(MainWindow::GetHWND(), MainWindow::GetDisplayHWND());
HWND hwndMain = MainWindow::GetHWND();
HMENU menu = GetMenu(hwndMain);
//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));
MainWindow::Update();
MainWindow::UpdateMenus();
LogManager::Init();
LogManager::GetInstance()->GetConsoleListener()->Open(hideLog, 150, 120, "PPSSPP Debug Console");
LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LERROR);
// Emu thread is always running!
EmuThread_Start();
if (g_Config.bBrowse)
MainWindow::BrowseAndBoot("");
if (!hideLog)
SetForegroundWindow(hwndMain);
//so.. we're at the message pump of the GUI thread
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) //while no quit
{
//DSound_UpdateSound();
//hack to make it possible to get to main window from floating windows with Esc
if (msg.hwnd != hwndMain && msg.message==WM_KEYDOWN && msg.wParam==VK_ESCAPE)
BringWindowToTop(hwndMain);
//Translate accelerators and dialog messages...
if (!TranslateAccelerator(hwndMain, hAccelTable, &msg))
{
if (!DialogManager::IsDialogMessage(&msg))
{
//and finally translate and dispatch
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
VFSShutdown();
LogManager::Shutdown();
DialogManager::DestroyAll();
timeEndPeriod(1);
g_Config.Save();
delete host;
return 0;
}