void DisasmView_DoDraw(HDC hdc) { ASSERT(g_pBoard != NULL); // Create and select font HFONT hFont = CreateMonospacedFont(); HGDIOBJ hOldFont = SelectObject(hdc, hFont); int cxChar, cyLine; GetFontWidthAndHeight(hdc, &cxChar, &cyLine); COLORREF colorOld = SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT)); SetBkMode(hdc, TRANSPARENT); //COLORREF colorBkOld = SetBkColor(hdc, GetSysColor(COLOR_WINDOW)); CProcessor* pDisasmPU = (m_okDisasmProcessor) ? g_pBoard->GetCPU() : g_pBoard->GetPPU(); // Draw disassembly for the current processor WORD prevPC = (m_okDisasmProcessor) ? g_wEmulatorPrevCpuPC : g_wEmulatorPrevPpuPC; int yFocus = DisasmView_DrawDisassemble(hdc, pDisasmPU, m_wDisasmBaseAddr, prevPC, 0, 2 + 0 * cyLine); SetTextColor(hdc, colorOld); //SetBkColor(hdc, colorBkOld); SelectObject(hdc, hOldFont); DeleteObject(hFont); if (::GetFocus() == m_hwndDisasmViewer) { RECT rcFocus; GetClientRect(m_hwndDisasmViewer, &rcFocus); if (yFocus >= 0) { rcFocus.top = yFocus; rcFocus.bottom = yFocus + cyLine; } DrawFocusRect(hdc, &rcFocus); } }
// Create Console View as child of Main Window void CreateConsoleView(HWND hwndParent, int x, int y, int width, int height) { ASSERT(hwndParent != NULL); g_hwndConsole = CreateWindow( CLASSNAME_TOOLWINDOW, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, x, y, width, height, hwndParent, NULL, g_hInst, NULL); SetWindowText(g_hwndConsole, _T("Debug Console")); // ToolWindow subclassing m_wndprocConsoleToolWindow = (WNDPROC) LongToPtr( SetWindowLongPtr( g_hwndConsole, GWLP_WNDPROC, PtrToLong(ConsoleViewWndProc)) ); RECT rcConsole; GetClientRect(g_hwndConsole, &rcConsole); m_hwndConsoleEdit = CreateWindowEx( WS_EX_CLIENTEDGE, _T("EDIT"), NULL, WS_CHILD | WS_VISIBLE, 90, rcConsole.bottom - 20, rcConsole.right - 90, 20, g_hwndConsole, NULL, g_hInst, NULL); m_hwndConsoleLog = CreateWindowEx( WS_EX_CLIENTEDGE, _T("EDIT"), NULL, WS_CHILD | WS_VSCROLL | WS_VISIBLE | ES_READONLY | ES_MULTILINE, 0, 0, rcConsole.right, rcConsole.bottom - 20, g_hwndConsole, NULL, g_hInst, NULL); m_hwndConsolePrompt = CreateWindowEx( 0, _T("STATIC"), NULL, WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE | SS_CENTER | SS_NOPREFIX, 0, rcConsole.bottom - 20, 90, 20, g_hwndConsole, NULL, g_hInst, NULL); m_hfontConsole = CreateMonospacedFont(); SendMessage(m_hwndConsolePrompt, WM_SETFONT, (WPARAM) m_hfontConsole, 0); SendMessage(m_hwndConsoleEdit, WM_SETFONT, (WPARAM) m_hfontConsole, 0); SendMessage(m_hwndConsoleLog, WM_SETFONT, (WPARAM) m_hfontConsole, 0); // Edit box subclassing m_wndprocConsoleEdit = (WNDPROC) LongToPtr( SetWindowLongPtr( m_hwndConsoleEdit, GWLP_WNDPROC, PtrToLong(ConsoleEditWndProc)) ); ShowWindow(g_hwndConsole, SW_SHOW); UpdateWindow(g_hwndConsole); ConsoleView_Print(_T("Use 'h' command to show help.\r\n\r\n")); PrintConsolePrompt(); SetFocus(m_hwndConsoleEdit); }
void DebugView_DoDraw(HDC hdc) { ASSERT(g_pBoard != NULL); // Create and select font HFONT hFont = CreateMonospacedFont(); HGDIOBJ hOldFont = SelectObject(hdc, hFont); int cxChar, cyLine; GetFontWidthAndHeight(hdc, &cxChar, &cyLine); COLORREF colorOld = SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT)); COLORREF colorBkOld = SetBkColor(hdc, GetSysColor(COLOR_WINDOW)); CProcessor* pDebugPU = (m_okDebugProcessor) ? g_pBoard->GetCPU() : g_pBoard->GetPPU(); ASSERT(pDebugPU != NULL); WORD* arrR = (m_okDebugProcessor) ? m_wDebugCpuR : m_wDebugPpuR; BOOL* arrRChanged = (m_okDebugProcessor) ? m_okDebugCpuRChanged : m_okDebugPpuRChanged; //LPCTSTR sProcName = pDebugPU->GetName(); //TextOut(hdc, cxChar * 1, 2 + 1 * cyLine, sProcName, 3); DebugView_DrawProcessor(hdc, pDebugPU, 30 + cxChar * 2, 2 + 1 * cyLine, arrR, arrRChanged); // Draw stack for the current processor DebugView_DrawMemoryForRegister(hdc, 6, pDebugPU, 30 + 35 * cxChar, 2 + 0 * cyLine); CMemoryController* pDebugMemCtl = pDebugPU->GetMemoryController(); DebugView_DrawPorts(hdc, m_okDebugProcessor, pDebugMemCtl, g_pBoard, 30 + 57 * cxChar, 2 + 0 * cyLine); //DebugView_DrawChannels(hdc, 75 * cxChar, 2 + 0 * cyLine); SetTextColor(hdc, colorOld); SetBkColor(hdc, colorBkOld); SelectObject(hdc, hOldFont); DeleteObject(hFont); if (::GetFocus() == m_hwndDebugViewer) { RECT rcClient; GetClientRect(m_hwndDebugViewer, &rcClient); DrawFocusRect(hdc, &rcClient); } }
void MemoryView_OnDraw(HDC hdc) { ASSERT(g_pBoard != NULL); // Create and select font HFONT hFont = CreateMonospacedFont(); HGDIOBJ hOldFont = SelectObject(hdc, hFont); int cxChar, cyLine; GetFontWidthAndHeight(hdc, &cxChar, &cyLine); COLORREF colorText = GetSysColor(COLOR_WINDOWTEXT); COLORREF colorOld = SetTextColor(hdc, colorText); COLORREF colorBkOld = SetBkColor(hdc, GetSysColor(COLOR_WINDOW)); m_cyLineMemory = cyLine; const TCHAR* ADDRESS_LINE = _T("address 0 2 4 6 10 12 14 16"); TextOut(hdc, cxChar * 4, 0, ADDRESS_LINE, (int) _tcslen(ADDRESS_LINE)); RECT rcClip; GetClipBox(hdc, &rcClip); RECT rcClient; GetClientRect(m_hwndMemoryViewer, &rcClient); m_nPageSize = rcClient.bottom / cyLine - 1; WORD address = m_wBaseAddress; int y = 1 * cyLine; for (;;) // Draw lines { DrawOctalValue(hdc, 5 * cxChar, y, address); int x = 13 * cxChar; TCHAR wchars[16]; for (int j = 0; j < 8; j++) // Draw words as octal value { // Get word from memory WORD word = 0; int addrtype; BOOL okHalt = FALSE; WORD wChanged = 0; //switch (m_Mode) { // case MEMMODE_RAM0: // case MEMMODE_RAM1: // case MEMMODE_RAM2: // word = g_pBoard->GetRAMWord(m_Mode, address); // wChanged = Emulator_GetChangeRamStatus(m_Mode, address); // break; // case MEMMODE_ROM: // ROM - only 32 Kbytes // if (address < 0100000) // okValid = FALSE; // else // word = g_pBoard->GetROMWord(address - 0100000); // break; // case MEMMODE_CPU: okHalt = g_pBoard->GetCPU()->IsHaltMode(); word = g_pBoard->GetWordView(address, okHalt, FALSE, &addrtype); wChanged = Emulator_GetChangeRamStatus(address); // break; //} if ((addrtype & (ADDRTYPE_IO | ADDRTYPE_DENY)) == 0) { ::SetTextColor(hdc, (wChanged != 0) ? RGB(255, 0, 0) : colorText); DrawOctalValue(hdc, x, y, word); } // Prepare characters to draw at right BYTE ch1 = LOBYTE(word); TCHAR wch1 = Translate_BK_Unicode(ch1); if (ch1 < 32) wch1 = _T('·'); wchars[j * 2] = wch1; BYTE ch2 = HIBYTE(word); TCHAR wch2 = Translate_BK_Unicode(ch2); if (ch2 < 32) wch2 = _T('·'); wchars[j * 2 + 1] = wch2; address += 2; x += 7 * cxChar; } ::SetTextColor(hdc, colorText); // Draw characters at right int xch = x + cxChar; TextOut(hdc, xch, y, wchars, 16); y += cyLine; if (y > rcClip.bottom) break; } SetTextColor(hdc, colorOld); SetBkColor(hdc, colorBkOld); SelectObject(hdc, hOldFont); DeleteObject(hFont); if (::GetFocus() == m_hwndMemoryViewer) { RECT rcFocus = rcClient; rcFocus.left += cxChar * 4; rcFocus.top += cyLine; rcFocus.right = cxChar * (63 + 24); DrawFocusRect(hdc, &rcFocus); } }