blob: 53aba0d519d40a72ff8941bec2acacbaccd14012 (
plain)
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
134
135
136
137
138
139
140
141
142
143
|
// regdoc.cpp : implementation file
//
#include "stdafx.h"
#include "regdoc.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRegDoc
IMPLEMENT_DYNCREATE(CRegDoc, CDocument)
static CRegDoc *doclist = 0;
CRegDoc::CRegDoc()
{
int i;
for (i= 0; i < MAXREGS; i++)
m_regsinit[i] = 0;
m_next = doclist;
doclist = this;
//Sync();
m_init=0;
}
BOOL CRegDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
return TRUE;
}
CRegDoc::~CRegDoc()
{
}
BEGIN_MESSAGE_MAP(CRegDoc, CDocument)
//{{AFX_MSG_MAP(CRegDoc)
ON_COMMAND(ID_REAL_CMD_BUTTON_SYNC, OnSync)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRegDoc serialization
void CRegDoc::Serialize(CArchive& ar)
{
}
void CRegDoc::ChangeReg(int rn, int val)
{
m_regs[rn] = val;
}
/////////////////////////////////////////////////////////////////////////////
// CRegDoc commands
void CRegDoc::Sync()
{
int rn;
int hadchange = 0;
const int nregs = togdb_maxregs();
long copy[MAXREGS];
/* Do a pass to see if anything changed */
for (rn = 0; rn < nregs; rn++)
{
copy[rn] = togdb_fetchreg(rn);
if (copy[rn] != m_regs[rn])
hadchange = 1;
m_regsinit[rn] = 1;
}
if (hadchange)
{
for (rn = 0; rn < nregs; rn++)
{
if (copy[rn] != m_regs[rn])
{
m_regs[rn] = copy[rn];
m_regchanged[rn] = 1;
}
else
{
m_regchanged[rn] = 0;
}
}
UpdateAllViews(0);
}
}
void CRegDoc::OnSync()
{
// TODO: Add your command handler code here
Sync();
}
void CRegDoc::OnCloseDocument()
{
// TODO: Add your specialized code here and/or call the base class
m_bModified = FALSE;
CDocument::OnCloseDocument();
}
void CRegDoc::prepare()
{
if (!m_init) {
Sync();
m_init =1 ;
}
}
BOOL CRegDoc::SaveModified()
{
// TODO: Add your specialized code here and/or call the base class
return TRUE; // CDocument::SaveModified();
}
|