-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathIoCardXxx.cpp.skeleton
173 lines (135 loc) · 3.12 KB
/
IoCardXxx.cpp.skeleton
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// This is a skeleton file for patterning future I/O devices
// When creating a new card type, beside filling in thte skeleton code,
// there is one step that must be performed. An enum symbol for the new
// card must be added to card_t in IoCard.h, and the card factory
// function, IoCard::makeCardImpl(), must be taught to associate the new
// class with this enum.
#include "Ui.h"
#include "IoCardXxx.h"
#include "Cpu2200.h"
#define NOISY 0 // turn on some debugging messages
#ifdef _MSC_VER
#pragma warning( disable: 4127 ) // conditional expression is constant
#endif
// instance constructor
IoCardXxx::IoCardXxx(Cpu2200 &cpu, int base_addr, int card_slot) :
m_cpu(cpu),
m_base_addr(base_addr),
m_slot(card_slot)
{
if (m_slot >= 0) {
// ... other creation functions
reset();
} else {
// this is just a probe to determine card properties
}
}
// instance destructor
IoCardXxx::~IoCardXxx()
{
if (m_slot >= 0) {
// not just a temp object, so clean up
reset(); // turns off handshakes in progress
// free allocated resources
// ...
}
}
const std::string
IoCardXxx::getDescription() const
{
return "Card Description";
}
const std::string
IoCardXxx::getName() const
{
return "Card Name (eg, 6541)";
}
// return a list of the various base addresses a card can map to
// the default comes first.
vector<int>
IoCardXxx:getBaseAddresses() const
{
std::vector<int> v { 0x710, 0x720, 0x730 }; // e.g.
return v;
}
// return the list of addresses that this specific card responds to
vector<int>
IoCardXxx::getAddresses() const
{
std::vector<int> v;
v.push_back(m_base_addr);
return v;
}
void
IoCardXxx::reset(bool /*hard_reset*/)
{
// reset card state
m_selected = false;
m_cpb = true; // CPU busy
m_card_busy = false;
...
}
void
IoCardXxx::select()
{
if (NOISY) {
UI_info("xxx ABS");
}
m_selected = true;
m_cpu.setDevRdy(!m_card_busy);
// ...
}
void
IoCardXxx::deselect()
{
if (NOISY) {
UI_info("xxx -ABS");
}
m_cpu->setDevRdy(false);
m_selected = false;
m_cpb = true;
// ...
}
void
IoCardXxx::strobeOBS(int val)
{
val &= 0xFF;
if (NOISY) {
UI_info("xxx OBS: Output of byte 0x%02x", val);
}
// ...
m_cpu.setDevRdy(!m_card_busy);
}
void
IoCardXxx::strobeCBS(int val)
{
val &= 0xFF;
#if 0
// handle it if card uses it instead of the message here
#else
// unexpected -- the real hardware ignores this byte
if (NOISY) {
UI_warn("unexpected xxx CBS: Output of byte 0x%02x", val);
}
#endif
}
int
IoCardXxx::GetIB5() const
{
return 0; // this card doesn't use this feature (or change if it does)
}
// change of CPU Busy state
void
IoCardXxx::setCpuBusy(bool busy)
{
assert(val == 0 || val == 1);
// it appears that except for reset, ucode only ever clears it,
// and of course the IBS sets it back.
if (NOISY) {
UI_info("xxx CPB%c", val?'+':'-');
}
m_cpb = busy;
// ...
m_cpu.setDevRdy(!m_card_busy);
}
// vim: ts=8:et:sw=4:smarttab