-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstructView.cpp
More file actions
133 lines (104 loc) · 2.95 KB
/
InstructView.cpp
File metadata and controls
133 lines (104 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// InstructView.cpp : implementation file
//
#include "stdafx.h"
#include "winEVE.h"
#include "InstructView.h"
#include "utils.h"
#include "WinEVEDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInstructView
IMPLEMENT_DYNCREATE(CInstructView, CScrollView)
CInstructView::CInstructView()
{
}
CInstructView::~CInstructView()
{
}
BEGIN_MESSAGE_MAP(CInstructView, CScrollView)
//{{AFX_MSG_MAP(CInstructView)
ON_WM_KEYDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInstructView drawing
void CInstructView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
// CSize sizeTotal;
// TODO: calculate the total size of this view
// sizeTotal.cx = 101;
// sizeTotal.cy = 140;
// SetScrollSizes(MM_TEXT, sizeTotal);
font.CreateFont(14,0,0,0,400,FALSE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH| FF_SWISS,"Arial");
// font.CreateFont(10,0,0,0,400,FALSE,FALSE,0,
// ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
// DEFAULT_QUALITY,DEFAULT_PITCH|FF_MODERN,"Courier");
}
void CInstructView::OnDraw(CDC* pDC)
{
CWinEVEDoc* pDoc = GetDocument();
CPoint ps;
int cause,now;
ps=GetScrollPosition();
first=ps.y/14;
CRect sz;
GetClientRect(&sz);
nlines=1+sz.Height()/14;
pDC->SelectObject(&font);
for (unsigned int i=0;i<pDoc->entries;i++)
{
now=pDoc->cycles-pDoc->history[i].start_cycle;
cause=pDoc->history[i].status[now].cause;
if (cause==RAW || cause==WAW || cause==STRUCTURAL) pDC->SetTextColor(BLUE);
else if (cause==STALLED) pDC->SetTextColor(GREY);
else pDC->SetTextColor(BLACK);
pDC->TextOut(5,14*i,pDoc->assembly[pDoc->history[i].IR/4]);
}
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CInstructView diagnostics
#ifdef _DEBUG
void CInstructView::AssertValid() const
{
CScrollView::AssertValid();
}
void CInstructView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CWinEVEDoc* CInstructView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWinEVEDoc)));
return (CWinEVEDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CInstructView message handlers
void CInstructView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
CPoint ps;
CWinEVEDoc* pDoc=GetDocument();
CSize sizeTotal;
WORD32 entries=pDoc->entries;
if (lHint==2) return;
sizeTotal.cx=101;
sizeTotal.cy=14*pDoc->entries+14;
SetScrollSizes(MM_TEXT,sizeTotal,CSize(100,56),CSize(100,14));
if (lHint==1L)
{
if (entries < first || entries >= first+nlines-1)
{
ps.x=0;
ps.y=(entries-nlines+2)*14;
ScrollToPosition(ps);
}
}
InvalidateRect(NULL);
}