CMemoryCardView::CMemoryCardView(HWND hParent, const RECT& rect) : m_itemCount(0) , m_memoryCard(NULL) , m_render(NULL) { if(!DoesWindowClassExist(CLSNAME)) { WNDCLASSEX wc; memset(&wc, 0, sizeof(WNDCLASSEX)); wc.cbSize = sizeof(WNDCLASSEX); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = NULL; wc.hInstance = GetModuleHandle(NULL); wc.lpszClassName = CLSNAME; wc.lpfnWndProc = CWindow::WndProc; wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; RegisterClassEx(&wc); } Create(WS_EX_CLIENTEDGE, CLSNAME, _T(""), WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, rect, hParent, NULL); SetClassPtr(); UpdateGeometry(); m_render = new CRender(m_hWnd, &m_viewState); }
CCallStackWnd::CCallStackWnd(HWND hParent, CVirtualMachine& virtualMachine, CMIPS* context, CBiosDebugInfoProvider* biosDebugInfoProvider) : m_virtualMachine(virtualMachine) , m_context(context) , m_list(nullptr) , m_biosDebugInfoProvider(biosDebugInfoProvider) { 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; RegisterClassEx(&wc); } Create(NULL, CLSNAME, _T("Call Stack"), WS_CLIPCHILDREN | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_CHILD | WS_MAXIMIZEBOX, Framework::Win32::CRect(0, 0, 320, 240), hParent, NULL); SetClassPtr(); m_list = new Framework::Win32::CListView(m_hWnd, Framework::Win32::CRect(0, 0, 1, 1), LVS_REPORT); m_list->SetExtendedListViewStyle(m_list->GetExtendedListViewStyle() | LVS_EX_FULLROWSELECT); m_virtualMachine.OnMachineStateChange.connect(boost::bind(&CCallStackWnd::Update, this)); m_virtualMachine.OnRunningStateChange.connect(boost::bind(&CCallStackWnd::Update, this)); CreateColumns(); RefreshLayout(); Update(); }
CMiniDebugger::CMiniDebugger(CVirtualMachine& virtualMachine, const CDebuggable& debuggable) : m_virtualMachine(virtualMachine) , m_debuggable(debuggable) , m_functionsView(nullptr) , m_mainSplitter(nullptr) , m_subSplitter(nullptr) , m_disAsmView(nullptr) , m_registerView(nullptr) , m_memoryView(nullptr) { InitializeConsole(); if(!DoesWindowClassExist(CLSNAME)) { WNDCLASSEX w; memset(&w, 0, sizeof(WNDCLASSEX)); w.cbSize = sizeof(WNDCLASSEX); w.lpfnWndProc = CWindow::WndProc; w.lpszClassName = CLSNAME; w.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); w.hInstance = GetModuleHandle(NULL); w.hCursor = LoadCursor(NULL, IDC_ARROW); RegisterClassEx(&w); } auto windowRect = Framework::Win32::PointsToPixels(Framework::Win32::CRect(0, 0, 1000, 600)); Create(WNDSTYLEEX, CLSNAME, _T("MiniDebugger"), WNDSTYLE, windowRect, NULL, NULL); SetClassPtr(); Center(); CreateAccelerators(); m_mainSplitter = new Framework::Win32::CVerticalSplitter(m_hWnd, GetClientRect()); m_subSplitter = new Framework::Win32::CHorizontalSplitter(m_mainSplitter->m_hWnd, GetClientRect()); m_memoryView = new CMemoryViewMIPS(m_mainSplitter->m_hWnd, Framework::Win32::CRect(0, 0, 1, 1), m_virtualMachine, &m_debuggable.GetCpu()); m_disAsmView = new CDisAsm(m_subSplitter->m_hWnd, Framework::Win32::CRect(0, 0, 1, 1), m_virtualMachine, &m_debuggable.GetCpu()); m_registerView = new CRegViewGeneral(m_subSplitter->m_hWnd, Framework::Win32::CRect(0, 0, 1, 1), m_virtualMachine, &m_debuggable.GetCpu()); m_registerView->Show(SW_SHOW); m_functionsView = new CFunctionsView(NULL); m_functionsView->OnFunctionDblClick.connect(boost::bind(&CMiniDebugger::OnFunctionDblClick, this, _1)); m_functionsView->SetContext(&m_debuggable.GetCpu(), m_debuggable.biosDebugInfoProvider); m_functionsView->Refresh(); m_subSplitter->SetChild(0, *m_disAsmView); m_subSplitter->SetChild(1, *m_registerView); m_subSplitter->SetEdgePosition(0.675); m_mainSplitter->SetChild(0, *m_subSplitter); m_mainSplitter->SetChild(1, *m_memoryView); m_disAsmView->SetAddress(m_debuggable.GetCpu().m_State.nPC); }
CFunctionsView::CFunctionsView(HWND hParent) : m_context(nullptr) , m_biosDebugInfoProvider(nullptr) { 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; RegisterClassEx(&wc); } unsigned long windowStyle = WS_CLIPCHILDREN | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX; #ifndef FUNCTIONSVIEW_STANDALONE windowStyle |= WS_CHILD; #endif int ydpi = GetDeviceCaps(GetDC(NULL), LOGPIXELSY); Create(NULL, CLSNAME, _T("Functions"), windowStyle, Framework::Win32::CRect(0, 0, SCALE(320), SCALE(240)), hParent, NULL); SetClassPtr(); m_pList = new Framework::Win32::CListView(m_hWnd, Framework::Win32::CRect(0, 0, 0, 0), LVS_REPORT | LVS_SINGLESEL | LVS_SORTASCENDING | LVS_SHOWSELALWAYS); m_pList->SetExtendedListViewStyle(m_pList->GetExtendedListViewStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); CreateListColumns(); m_pNew = new Framework::Win32::CButton(_T("New..."), m_hWnd, Framework::Win32::CRect(0, 0, 0, 0)); m_pRename = new Framework::Win32::CButton(_T("Rename..."), m_hWnd, Framework::Win32::CRect(0, 0, 0, 0)); m_pDelete = new Framework::Win32::CButton(_T("Delete"), m_hWnd, Framework::Win32::CRect(0, 0, 0, 0)); m_pImport = new Framework::Win32::CButton(_T("Load ELF symbols"), m_hWnd, Framework::Win32::CRect(0, 0, 0, 0)); Framework::FlatLayoutPtr pSubLayout0 = Framework::CHorizontalLayout::Create(); pSubLayout0->InsertObject(Framework::CLayoutStretch::Create()); pSubLayout0->InsertObject(Framework::Win32::CLayoutWindow::CreateButtonBehavior(SCALE(100), SCALE(23), m_pNew)); pSubLayout0->InsertObject(Framework::Win32::CLayoutWindow::CreateButtonBehavior(SCALE(100), SCALE(23), m_pRename)); pSubLayout0->InsertObject(Framework::Win32::CLayoutWindow::CreateButtonBehavior(SCALE(100), SCALE(23), m_pDelete)); pSubLayout0->InsertObject(Framework::Win32::CLayoutWindow::CreateButtonBehavior(SCALE(100), SCALE(23), m_pImport)); m_pLayout = Framework::CVerticalLayout::Create(); m_pLayout->InsertObject(Framework::Win32::CLayoutWindow::CreateCustomBehavior(1, 1, 1, 1, m_pList)); m_pLayout->InsertObject(pSubLayout0); SetSize(SCALE(469), SCALE(612)); RefreshLayout(); }
COutputWnd::COutputWnd(HWND hParent) { if(!DoesWindowClassExist(CLSNAME)) { WNDCLASSEX wc; memset(&wc, 0, sizeof(WNDCLASSEX)); wc.cbSize = sizeof(WNDCLASSEX); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.hInstance = GetModuleHandle(NULL); wc.lpszClassName = CLSNAME; wc.lpfnWndProc = CWindow::WndProc; wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; RegisterClassEx(&wc); } Create(NULL, CLSNAME, NULL, WNDSTYLE, Framework::Win32::CRect(0, 0, 1, 1), hParent, NULL); SetClassPtr(); }
CSaveIconView::CSaveIconView(HWND hParent, const RECT& rect) : m_nGrabbing(false) , m_iconMesh(NULL) , m_iconType(CSave::ICON_NORMAL) , m_nRotationX(0) , m_nRotationY(0) , m_nGrabPosX(0) , m_nGrabPosY(0) , m_nGrabDistX(0) , m_nGrabDistY(0) , m_nGrabRotX(0) , m_nGrabRotY(0) , m_nZoom(-7.0f) , m_save(NULL) , m_hRC(NULL) , m_thread(NULL) , m_threadOver(false) { if(!DoesWindowClassExist(CLSNAME)) { WNDCLASSEX wc; memset(&wc, 0, sizeof(WNDCLASSEX)); wc.cbSize = sizeof(WNDCLASSEX); wc.hCursor = NULL; wc.hbrBackground = NULL; wc.hInstance = GetModuleHandle(NULL); wc.lpszClassName = CLSNAME; wc.lpfnWndProc = CWindow::WndProc; wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; RegisterClassEx(&wc); } Create(WS_EX_STATICEDGE, CLSNAME, _T(""), WS_VISIBLE | WS_CLIPCHILDREN | WS_CHILD, rect, hParent, NULL); SetClassPtr(); m_thread = new std::thread(std::bind(&CSaveIconView::ThreadProc, this)); }
CDebugger::CDebugger(CPS2VM& virtualMachine) : m_virtualMachine(virtualMachine) { RegisterPreferences(); if(!DoesWindowClassExist(CLSNAME)) { WNDCLASSEX wc; memset(&wc, 0, sizeof(WNDCLASSEX)); wc.cbSize = sizeof(WNDCLASSEX); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH); wc.hInstance = GetModuleHandle(NULL); wc.lpszClassName = CLSNAME; wc.lpfnWndProc = CWindow::WndProc; RegisterClassEx(&wc); } Create(NULL, CLSNAME, _T(""), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, Framework::Win32::CRect(0, 0, 640, 480), NULL, NULL); SetClassPtr(); SetMenu(LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_DEBUGGER))); CreateClient(NULL); //Show(SW_MAXIMIZE); //ELF View Initialization m_pELFView = new CELFView(m_pMDIClient->m_hWnd); m_pELFView->Show(SW_HIDE); //Functions View Initialization m_pFunctionsView = new CFunctionsView(m_pMDIClient->m_hWnd); m_pFunctionsView->Show(SW_HIDE); m_pFunctionsView->OnFunctionDblClick.connect(boost::bind(&CDebugger::OnFunctionsViewFunctionDblClick, this, _1)); m_pFunctionsView->OnFunctionsStateChange.connect(boost::bind(&CDebugger::OnFunctionsViewFunctionsStateChange, this)); //Threads View Initialization m_threadsView = new CThreadsViewWnd(m_pMDIClient->m_hWnd, m_virtualMachine); m_threadsView->Show(SW_HIDE); m_threadsView->OnGotoAddress.connect(boost::bind(&CDebugger::OnThreadsViewAddressDblClick, this, _1)); //Find Callers View Initialization m_findCallersView = new CFindCallersViewWnd(m_pMDIClient->m_hWnd); m_findCallersView->Show(SW_HIDE); m_findCallersView->AddressSelected.connect([&] (uint32 address) { OnFindCallersAddressDblClick(address); }); //Debug Views Initialization m_nCurrentView = -1; memset(m_pView, 0, sizeof(m_pView)); m_pView[DEBUGVIEW_EE] = new CDebugView(m_pMDIClient->m_hWnd, m_virtualMachine, &m_virtualMachine.m_ee->m_EE, std::bind(&CPS2VM::StepEe, &m_virtualMachine), m_virtualMachine.m_ee->m_os, "EmotionEngine"); m_pView[DEBUGVIEW_VU0] = new CDebugView(m_pMDIClient->m_hWnd, m_virtualMachine, &m_virtualMachine.m_ee->m_VU0, std::bind(&CPS2VM::StepVu0, &m_virtualMachine), nullptr, "Vector Unit 0", CDisAsmWnd::DISASM_VU); m_pView[DEBUGVIEW_VU1] = new CDebugView(m_pMDIClient->m_hWnd, m_virtualMachine, &m_virtualMachine.m_ee->m_VU1, std::bind(&CPS2VM::StepVu1, &m_virtualMachine), nullptr, "Vector Unit 1", CDisAsmWnd::DISASM_VU); m_pView[DEBUGVIEW_IOP] = new CDebugView(m_pMDIClient->m_hWnd, m_virtualMachine, &m_virtualMachine.m_iop->m_cpu, std::bind(&CPS2VM::StepIop, &m_virtualMachine), m_virtualMachine.m_iopOs.get(), "IO Processor"); m_virtualMachine.m_ee->m_os->OnExecutableChange.connect(boost::bind(&CDebugger::OnExecutableChange, this)); m_virtualMachine.m_ee->m_os->OnExecutableUnloading.connect(boost::bind(&CDebugger::OnExecutableUnloading, this)); ActivateView(DEBUGVIEW_EE); LoadSettings(); if(GetDisassemblyWindow()->IsVisible()) { GetDisassemblyWindow()->SetFocus(); } CreateAccelerators(); }
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); }
CELFSymbolView::CELFSymbolView(HWND hParent, CELF* pELF) : m_pELF(pELF) , m_listView(NULL) { 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; RegisterClassEx(&wc); } Create(NULL, CLSNAME, _T(""), WS_CHILD | WS_DISABLED | WS_CLIPCHILDREN, Framework::Win32::CRect(0, 0, 1, 1), hParent, NULL); SetClassPtr(); m_listView = new Framework::Win32::CListView(m_hWnd, Framework::Win32::CRect(0, 0, 1, 1), LVS_REPORT | LVS_OWNERDATA); m_listView->SetExtendedListViewStyle(m_listView->GetExtendedListViewStyle() | LVS_EX_FULLROWSELECT); LVCOLUMN col; memset(&col, 0, sizeof(LVCOLUMN)); col.pszText = _T("Name"); col.mask = LVCF_TEXT; m_listView->InsertColumn(0, col); memset(&col, 0, sizeof(LVCOLUMN)); col.pszText = _T("Address"); col.mask = LVCF_TEXT; m_listView->InsertColumn(1, col); memset(&col, 0, sizeof(LVCOLUMN)); col.pszText = _T("Size"); col.mask = LVCF_TEXT; m_listView->InsertColumn(2, col); memset(&col, 0, sizeof(LVCOLUMN)); col.pszText = _T("Type"); col.mask = LVCF_TEXT; m_listView->InsertColumn(3, col); memset(&col, 0, sizeof(LVCOLUMN)); col.pszText = _T("Binding"); col.mask = LVCF_TEXT; m_listView->InsertColumn(4, col); memset(&col, 0, sizeof(LVCOLUMN)); col.pszText = _T("Section"); col.mask = LVCF_TEXT; m_listView->InsertColumn(5, col); RefreshLayout(); RECT rc = m_listView->GetClientRect(); m_listView->SetColumnWidth(0, rc.right / 3); m_listView->SetColumnWidth(1, rc.right / 4); m_listView->SetColumnWidth(2, rc.right / 4); m_listView->SetColumnWidth(3, rc.right / 4); m_listView->SetColumnWidth(4, rc.right / 4); m_listView->SetColumnWidth(5, rc.right / 4); PopulateList(); m_listView->Redraw(); }