void CMainWindow::ProcessCommandLine() { for(unsigned int i = 0; i < __argc; i++) { auto arg = __targv[i]; if(_tcsstr(arg, _T("--cdrom0")) != nullptr) { BootCDROM(); } else if(_tcsstr(arg, _T("--elf")) != nullptr) { if((__argc - i) < 2) continue; auto nextArg = __targv[i + 1]; LoadELF(string_cast<std::string>(nextArg).c_str()); } #ifdef DEBUGGER_INCLUDED else if(_tcsstr(arg, _T("--debugger")) != nullptr) { ShowDebugger(); } else if(_tcsstr(arg, _T("--framedebugger")) != nullptr) { ShowFrameDebugger(); } #endif } }
CMainWindow::CMainWindow(CPS2VM& virtualMachine, char* cmdLine) : m_virtualMachine(virtualMachine) , m_recordingAvi(false) , m_recordBuffer(nullptr) , m_recordBufferWidth(0) , m_recordBufferHeight(0) , m_recordAviMutex(NULL) , m_frames(0) , m_drawCallCount(0) , m_stateSlot(0) , m_outputWnd(nullptr) , m_statusBar(nullptr) , m_accTable(NULL) { m_recordAviMutex = CreateMutex(NULL, FALSE, NULL); TCHAR sVersion[256]; CAppConfig::GetInstance().RegisterPreferenceBoolean(PREF_UI_PAUSEWHENFOCUSLOST, true); if(!DoesWindowClassExist(CLSNAME)) { WNDCLASSEX wc; memset(&wc, 0, sizeof(WNDCLASSEX)); wc.cbSize = sizeof(WNDCLASSEX); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW); wc.hInstance = GetModuleHandle(NULL); wc.lpszClassName = CLSNAME; wc.lpfnWndProc = CWindow::WndProc; wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; RegisterClassEx(&wc); } Create(NULL, CLSNAME, _T(""), WNDSTYLE, Framework::Win32::CRect(0, 0, 640, 480), NULL, NULL); SetClassPtr(); #ifdef DEBUGGER_INCLUDED CDebugger::InitializeConsole(); #endif m_virtualMachine.Initialize(); SetIcon(ICON_SMALL, LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PUREI))); SetIcon(ICON_BIG, LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PUREI))); SetMenu(LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MAINWINDOW))); #ifdef DEBUGGER_INCLUDED m_debugger = std::unique_ptr<CDebugger>(new CDebugger(m_virtualMachine)); m_frameDebugger = std::unique_ptr<CFrameDebugger>(new CFrameDebugger()); CreateDebugMenu(); #endif PrintVersion(sVersion, countof(sVersion)); m_outputWnd = new COutputWnd(m_hWnd); m_statusBar = new Framework::Win32::CStatusBar(m_hWnd); m_statusBar->SetParts(2, m_statusBarPanelWidths); m_statusBar->SetText(STATUSPANEL, sVersion); m_statusBar->SetText(FPSPANEL, _T("")); //m_virtualMachine.CreateGSHandler(CGSH_Null::GetFactoryFunction()); m_virtualMachine.CreateGSHandler(CGSH_OpenGLWin32::GetFactoryFunction(m_outputWnd)); m_virtualMachine.CreatePadHandler(CPH_DirectInput::GetFactoryFunction(m_hWnd)); m_deactivatePause = false; m_pauseFocusLost = CAppConfig::GetInstance().GetPreferenceBoolean(PREF_UI_PAUSEWHENFOCUSLOST); m_virtualMachine.m_gs->OnNewFrame.connect(boost::bind(&CMainWindow::OnNewFrame, this, _1)); SetTimer(m_hWnd, NULL, 1000, NULL); //Initialize status bar OnTimer(0); m_virtualMachine.m_os->OnExecutableChange.connect(boost::bind(&CMainWindow::OnExecutableChange, this)); CreateStateSlotMenu(); CreateAccelerators(); if(strstr(cmdLine, "--cdrom0") != nullptr) { BootCDROM(); } #ifdef DEBUGGER_INCLUDED if(strstr(cmdLine, "--debugger") != nullptr) { ShowDebugger(); } if(strstr(cmdLine, "--framedebugger") != nullptr) { ShowFrameDebugger(); } #endif RefreshLayout(); UpdateUI(); Center(); Show(SW_SHOW); }
long CMainWindow::OnCommand(unsigned short nID, unsigned short nCmd, HWND hSender) { switch(nID) { case ID_MAIN_FILE_LOADELF: OpenELF(); break; case ID_MAIN_FILE_BOOTCDROM: BootCDROM(); break; case ID_MAIN_FILE_BOOTDISKIMAGE: BootDiskImage(); break; case ID_MAIN_FILE_RECORDAVI: RecordAvi(); break; case ID_MAIN_FILE_EXIT: DestroyWindow(m_hWnd); break; case ID_MAIN_VM_RESUME: ResumePause(); break; case ID_MAIN_VM_RESET: Reset(); break; case ID_MAIN_VM_PAUSEFOCUS: PauseWhenFocusLost(); break; case ID_MAIN_VM_SAVESTATE: SaveState(); break; case ID_MAIN_VM_LOADSTATE: LoadState(); break; case ID_MAIN_VM_STATESLOT_0 + 0: case ID_MAIN_VM_STATESLOT_0 + 1: case ID_MAIN_VM_STATESLOT_0 + 2: case ID_MAIN_VM_STATESLOT_0 + 3: case ID_MAIN_VM_STATESLOT_0 + 4: case ID_MAIN_VM_STATESLOT_0 + 5: case ID_MAIN_VM_STATESLOT_0 + 6: case ID_MAIN_VM_STATESLOT_0 + 7: case ID_MAIN_VM_STATESLOT_0 + 8: case ID_MAIN_VM_STATESLOT_0 + 9: ChangeStateSlot(nID - ID_MAIN_VM_STATESLOT_0); break; case ID_MAIN_VIEW_FITTOSCREEN: ChangeViewMode(CGSHandler::PRESENTATION_MODE_FIT); break; case ID_MAIN_VIEW_FILLSCREEN: ChangeViewMode(CGSHandler::PRESENTATION_MODE_FILL); break; case ID_MAIN_VIEW_ACTUALSIZE: ChangeViewMode(CGSHandler::PRESENTATION_MODE_ORIGINAL); break; case ID_MAIN_OPTIONS_RENDERER: ShowRendererSettings(); break; case ID_MAIN_OPTIONS_CONTROLLER: ShowControllerSettings(); break; case ID_MAIN_OPTIONS_VFSMANAGER: ShowVfsManager(); break; case ID_MAIN_OPTIONS_MCMANAGER: ShowMcManager(); break; case ID_MAIN_DEBUG_SHOWDEBUG: ShowDebugger(); break; case ID_MAIN_DEBUG_SHOWFRAMEDEBUG: ShowFrameDebugger(); break; case ID_MAIN_DEBUG_DUMPFRAME: DumpNextFrame(); break; case ID_MAIN_DEBUG_ENABLEGSDRAW: ToggleGsDraw(); break; case ID_MAIN_HELP_SYSINFO: ShowSysInfo(); break; case ID_MAIN_HELP_ABOUT: ShowAbout(); break; } return TRUE; }