📄 zeropageview.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.
-----------------------------------------------------------------------------*/
// ZeroPageView.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "ZeroPageView.h"
#include "MemoryGoto.h"
#include "MemoryDC.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CFont CZeroPageView::m_Font;
LOGFONT CZeroPageView::m_LogFont;
COLORREF CZeroPageView::m_rgbTextColor;
COLORREF CZeroPageView::m_rgbBkgndColor;
/////////////////////////////////////////////////////////////////////////////
// CZeroPageView
IMPLEMENT_DYNCREATE(CZeroPageView, CView)
CZeroPageView::CZeroPageView()
{}
CZeroPageView::~CZeroPageView()
{}
BEGIN_MESSAGE_MAP(CZeroPageView, CView)
//{{AFX_MSG_MAP(CZeroPageView)
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()
/////////////////////////////////////////////////////////////////////////////
// CZeroPageView drawing
void CZeroPageView::OnDraw(CDC* pDC)
{
CMemoryDoc *pDoc= (CMemoryDoc *)GetDocument();
ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CMemoryDoc)));
CString line(_T(' '), 1 + max(m_nCx, 8));
UINT16 addr= 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);
if (dcMem.m_hDC == 0)
return;
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];
int nPtr= nLo + (nHi << 8);
ASSERT(nPtr >= 0 && nPtr <= 0xFFFF);
line.Format(_T("%02X %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;
}
addr++;
dcMem.TextOut(1, y, line);
if (addr >= 0x100) // doszli渕y do ko馽a strony zerowej?
break;
}
dcMem.BitBlt();
}
/////////////////////////////////////////////////////////////////////////////
// CZeroPageView diagnostics
#ifdef _DEBUG
void CZeroPageView::AssertValid() const
{
CView::AssertValid();
}
void CZeroPageView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// obliczenia pomocnicze
void CZeroPageView::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 CZeroPageView::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 + -