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/.
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include "file/vfs.h"
|
|
|
|
#include "file/zip_read.h"
|
|
|
|
|
|
|
|
#include "../Core/Config.h"
|
2012-12-22 17:21:23 +00:00
|
|
|
#include "EmuThread.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];
|
|
|
|
CMemoryDlg *memoryWindow[MAX_CPUCOUNT];
|
|
|
|
|
|
|
|
int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
|
|
|
|
{
|
|
|
|
Common::EnableCrashingOnCrashes();
|
|
|
|
|
2012-12-22 17:21:23 +00:00
|
|
|
const char *fileToStart = NULL;
|
2012-12-22 17:49:29 +00:00
|
|
|
const char *fileToLog = NULL;
|
2012-12-22 17:21:23 +00:00
|
|
|
bool showLog = false;
|
|
|
|
bool autoRun = true;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
g_Config.Load();
|
2012-12-17 21:24:07 +00:00
|
|
|
VFSRegister("", new DirectoryAssetReader("assets/"));
|
2012-11-18 12:04:49 +00:00
|
|
|
VFSRegister("", new DirectoryAssetReader(""));
|
2012-11-01 15:19:01 +00:00
|
|
|
|
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 'j':
|
|
|
|
g_Config.iCpuCore = CPU_JIT;
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
g_Config.iCpuCore = CPU_INTERPRETER;
|
|
|
|
break;
|
2012-12-22 17:49:59 +00:00
|
|
|
case 'f':
|
|
|
|
g_Config.iCpuCore = CPU_FASTINTERPRETER;
|
|
|
|
break;
|
2012-12-22 17:21:23 +00:00
|
|
|
case 'l':
|
|
|
|
showLog = true;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
autoRun = false;
|
|
|
|
break;
|
2012-12-22 17:49:29 +00:00
|
|
|
case '-':
|
|
|
|
if (!strcmp(__argv[i], "--log") && i < __argc - 1)
|
|
|
|
fileToLog = __argv[++i];
|
|
|
|
if (!strncmp(__argv[i], "--log=", strlen("--log=")) && strlen(__argv[i]) > strlen("--log="))
|
|
|
|
fileToLog = __argv[i] + strlen("--log=");
|
|
|
|
break;
|
2012-12-22 17:21:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (fileToStart == NULL)
|
|
|
|
{
|
2012-12-22 17:49:29 +00:00
|
|
|
fileToStart = __argv[i];
|
2012-12-22 17:21:23 +00:00
|
|
|
if (!File::Exists(fileToStart))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "File not found: %s\n", fileToStart);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Can only boot one file");
|
|
|
|
exit(1);
|
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);
|
|
|
|
|
|
|
|
HACCEL hAccelTable = LoadAccelerators(_hInstance, (LPCTSTR)IDR_ACCELS);
|
|
|
|
g_hPopupMenus = LoadMenu(_hInstance, (LPCSTR)IDR_POPUPMENUS);
|
|
|
|
|
|
|
|
MainWindow::Show(_hInstance, iCmdShow);
|
2012-11-30 20:49:59 +00:00
|
|
|
host = new WindowsHost(MainWindow::GetHWND(), MainWindow::GetDisplayHWND());
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
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();
|
2012-12-22 17:49:29 +00:00
|
|
|
if (fileToLog != NULL)
|
|
|
|
LogManager::GetInstance()->ChangeFileLog(fileToLog);
|
2012-11-01 15:19:01 +00:00
|
|
|
bool hidden = false;
|
|
|
|
#ifndef _DEBUG
|
|
|
|
hidden = true;
|
|
|
|
#endif
|
|
|
|
LogManager::GetInstance()->GetConsoleListener()->Open(hidden, 150, 120, "PPSSPP Debug Console");
|
2012-11-26 17:04:34 +00:00
|
|
|
LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LERROR);
|
2012-12-22 17:21:23 +00:00
|
|
|
if (fileToStart != NULL)
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
2012-12-22 17:21:23 +00:00
|
|
|
MainWindow::SetPlaying(fileToStart);
|
|
|
|
MainWindow::Update();
|
|
|
|
MainWindow::UpdateMenus();
|
|
|
|
|
|
|
|
EmuThread_Start(fileToStart);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
2012-12-22 17:21:23 +00:00
|
|
|
else
|
|
|
|
MainWindow::BrowseAndBoot();
|
|
|
|
|
|
|
|
if (showLog)
|
|
|
|
PostMessage(hwndMain, WM_COMMAND, ID_DEBUG_LOG, 0);
|
|
|
|
if (autoRun)
|
|
|
|
MainWindow::SetNextState(CORE_RUNNING);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
//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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LogManager::Shutdown();
|
|
|
|
DialogManager::DestroyAll();
|
2012-12-03 08:44:37 +00:00
|
|
|
timeEndPeriod(1);
|
2012-11-01 15:19:01 +00:00
|
|
|
g_Config.Save();
|
|
|
|
delete host;
|
|
|
|
return 0;
|
|
|
|
}
|