📄 stackview.cpp
字号:
/*-----------------------------------------------------------------------------
6502 Macroassembler and Simulator
Copyright (C) 1995-2003 Michal Kowalski
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; either version 2
of the License, or (at your option) any later version.
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 for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-----------------------------------------------------------------------------*/
// StackView.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "StackView.h"
#include "MemoryGoto.h"
#include "MemoryDC.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CFont CStackView::m_Font;
LOGFONT CStackView::m_LogFont;
COLORREF CStackView::m_rgbTextColor;
COLORREF CStackView::m_rgbBkgndColor;
/////////////////////////////////////////////////////////////////////////////
// CStackView
IMPLEMENT_DYNCREATE(CStackView, CView)
CStackView::CStackView()
{}
CStackView::~CStackView()
{}
BEGIN_MESSAGE_MAP(CStackView, CView)
//{{AFX_MSG_MAP(CStackView)
ON_WM_VSCROLL()
ON_WM_KEYDOWN()
ON_WM_SIZE()
ON_WM_ERASEBKGND()
ON_WM_CONTEXTMENU()
ON_UPDATE_COMMAND_UI(ID_MEMORY_GOTO, OnUpdateMemoryGoto)
ON_COMMAND(ID_MEMORY_GOTO, OnMemoryGoto)
ON_UPDATE_COMMAND_UI(ID_MEMORY_CHG, OnUpdateMemoryChg)
ON_COMMAND(ID_MEMORY_CHG, OnMemoryChg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStackView drawing
void CStackView::OnDraw(CDC* pDC)
{
CMemoryDoc* pDoc= (CMemoryDoc *)GetDocument();
ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CMemoryDoc)));
CString line(_T(' '), 1 + max(m_nCx, 8));
UINT16 addr= 0x1ff - pDoc->m_uAddress;
TCHAR hex[8];
int lim= bytes_in_line(); // ilo滄 wy渨ietlanych w jednym wierszu bajt體
COutputMem& mem= *pDoc->m_pMem;
CMemoryDC dcMem(*pDC, this, m_rgbBkgndColor);
dcMem.SelectObject(&m_Font);
dcMem.SetTextColor(m_rgbTextColor);
dcMem.SetBkColor(m_rgbBkgndColor);
for (int i=0, y=0; i <= m_nCy; i++, y += m_nChrH)
{
int nLo= mem[addr];
int nHi= mem[((addr + 1) & 0xFF) + 0x100];
int nPtr= nLo + (nHi << 8);
ASSERT(nPtr >= 0 && nPtr <= 0xFFFF);
line.Format(_T("%03X %02X '%c' %04X "), int(addr), nLo, nLo > 0 ? nLo : ' ', nPtr);
int j;
for (j= 0; j < lim; j++)
{
wsprintf(hex, _T(" %02X"), int(mem[(nPtr + j) & 0xFFFF]));
line += hex;
}
if (addr <= pDoc->m_uStackPtr)
dcMem.SetTextColor(RGB(192,192,192));
--addr;
dcMem.TextOut(1, y, line);
if (addr < 0x100) // bottom of stack?
break;
}
dcMem.BitBlt();
}
/////////////////////////////////////////////////////////////////////////////
// CStackView diagnostics
#ifdef _DEBUG
void CStackView::AssertValid() const
{
CView::AssertValid();
}
void CStackView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// obliczenia pomocnicze
void CStackView::calc(CDC *pDC)
{
RECT rect;
GetClientRect(&rect);
pDC->SelectObject(&m_Font);
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
m_nChrH = (int)tm.tmHeight + (int)tm.tmExternalLeading;
m_nChrW = tm.tmAveCharWidth;
m_nCx = (rect.right-1) / m_nChrW; // ilo滄 kolumn
m_nCy = rect.bottom / m_nChrH; // ilo滄 wierszy
// if (rect.bottom % m_nCharH) // na dole wystaje kawa砮k wiersza?
if (m_nCy == 0)
m_nCy++;
}
//-----------------------------------------------------------------------------
void CStackView::scroll(UINT nSBCode, int nPos, int nRepeat)
{
CMemoryDoc *pDoc = (CMemoryDoc *)GetDocument();
if (pDoc == NULL)
return;
switch (nSBCode)
{
case SB_ENDSCROLL: // End scroll
break;
case SB_LINEDOWN: // Scroll one line down
switch (find_next_addr(pDoc->m_uAddress,*pDoc->m_pMem))
{
case 0:
break; // dalej ju
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -