This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dwwin.c
executable file
·285 lines (238 loc) · 5.52 KB
/
dwwin.c
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#include "drivewire.h"
void WinInit(void)
{
if (interactive == false)
{
return;
}
int y = 1;
initscr();
clear();
window0 = newwin(24, 80, 0, 0);
if (window0 == NULL)
{
printf("window must be at least 80x24!\n");
exit(0);
}
wattron(window0, A_STANDOUT);
wprintw(window0, "DriveWire Server v%d.%d (C) 2009 Boisy G. Pitre", REV_MAJOR, REV_MINOR);
wattroff(window0, A_STANDOUT);
WinSetup(window0);
}
void WinSetup(WINDOW *window)
{
if (interactive == false)
{
return;
}
int y = 2;
wmove(window, y++, 1);
wprintw(window, "Last OpCode :");
wmove(window, y++, 1);
wprintw(window, "Sectors Read :");
wmove(window, y++, 1);
wprintw(window, "Sectors Written :");
wmove(window, y++, 1);
wprintw(window, "Last LSN :");
wmove(window, y++, 1);
wprintw(window, "Read Retries :");
wmove(window, y++, 1);
wprintw(window, "Write Retries :");
wmove(window, y++, 1);
wprintw(window, "%% Good Reads :");
wmove(window, y++, 1);
wprintw(window, "%% Good Writes :");
wmove(window, y++, 1);
wprintw(window, "Last GetStat :");
wmove(window, y++, 1);
wprintw(window, "Last SetStat :");
y++;
wmove(window, y++, 1);
wprintw(window, "CoCo Type :");
wmove(window, y++, 1);
wprintw(window, "Serial Port :");
wmove(window, y++, 1);
wprintw(window, "DriveWire Mode :");
wmove(window, y++, 1);
wprintw(window, "Print Command :");
y++;
wmove(window, y++, 1);
wprintw(window, "Disk 0 :");
wmove(window, y++, 1);
wprintw(window, "Disk 1 :");
wmove(window, y++, 1);
wprintw(window, "Disk 2 :");
wmove(window, y++, 1);
wprintw(window, "Disk 3 :");
y++;
wmove(window, y++, 1);
wattron(window, A_STANDOUT);
wprintw(window, "[0-3] Disk [C]oCo [P]ort [R]eset [M]ode [L]Print [Q]uit");
wattroff(window, A_STANDOUT);
/* 2. Refresh */
wrefresh(window);
return;
}
void WinUpdate(WINDOW *window, struct dwTransferData *dp)
{
if (interactive == false)
{
return;
}
int x = 20;
int y = 2;
int i;
if (updating == 1)
{
return;
}
wmove(window, y++, x);
wclrtoeol(window);
switch (dp->lastOpcode)
{
case OP_NOP:
wprintw(window, "OP_NOP");
break;
case OP_INIT:
wprintw(window, "OP_INIT");
break;
case OP_READ:
wprintw(window, "OP_READ");
break;
case OP_READEX:
wprintw(window, "OP_READEX");
break;
case OP_WRITE:
wprintw(window, "OP_WRITE");
break;
case OP_REREAD:
wprintw(window, "OP_REREAD");
break;
case OP_REREADEX:
wprintw(window, "OP_REREADEX");
break;
case OP_REWRITE:
wprintw(window, "OP_REWRITE");
break;
case OP_TERM:
wprintw(window, "OP_TERM");
break;
case OP_RESET1:
case OP_RESET2:
wprintw(window, "OP_RESET");
break;
case OP_GETSTAT:
wprintw(window, "OP_GETSTAT");
break;
case OP_SETSTAT:
wprintw(window, "OP_SETSTAT");
break;
case OP_TIME:
wprintw(window, "OP_TIME");
break;
case OP_PRINT:
wprintw(window, "OP_PRINT");
break;
case OP_PRINTFLUSH:
wprintw(window, "OP_PRINTFLUSH");
break;
default:
wprintw(window, "UNKNOWN (%d)", dp->lastOpcode);
break;
}
wmove(window, y++, x); wclrtoeol(window);
wprintw(window, "%d", dp->sectorsRead);
wmove(window, y++, x); wclrtoeol(window);
wprintw(window, "%d", dp->sectorsWritten);
wmove(window, y++, x); wclrtoeol(window);
wprintw(window, "%d", int3(dp->lastLSN));
wmove(window, y++, x); wclrtoeol(window);
wprintw(window, "%d", dp->readRetries);
wmove(window, y++, x); wclrtoeol(window);
wprintw(window, "%d", dp->writeRetries);
wmove(window, y++, x); wclrtoeol(window);
if (dp->sectorsRead + dp->readRetries == 0)
{
wprintw(window, "0%%");
}
else
{
float percent = ((float)dp->sectorsRead / ((float)dp->sectorsRead + (float)dp->readRetries)) * 100;
wprintw(window, "%3.3f%%", percent);
}
wmove(window, y++, x); wclrtoeol(window);
if (dp->sectorsWritten + dp->writeRetries == 0)
{
wprintw(window, "0%%");
}
else
{
float percent = ((float)dp->sectorsWritten / ((float)dp->sectorsWritten + (float)dp->writeRetries)) * 100;
wprintw(window, "%3.3f%%", percent);
}
wmove(window, y++, x); wclrtoeol(window);
wprintw(window, "$%02X (%s)", dp->lastGetStat, getStatCode(dp->lastGetStat));
wmove(window, y++, x); wclrtoeol(window);
wprintw(window, "$%02X (%s)", dp->lastSetStat, getStatCode(dp->lastSetStat));
wmove(window, y++, x); wclrtoeol(window);
wmove(window, y++, x); wclrtoeol(window);
switch (dp->cocoType)
{
case 3:
if (dp->dw_protocol_vrsn == 3)
{
wprintw(window, "%s", "CoCo 3 (115200 baud)");
}
else
{
wprintw(window, "%s", "CoCo 3 (57600 baud)");
}
break;
case 2:
if (dp->dw_protocol_vrsn == 3)
{
wprintw(window, "%s", "CoCo 2 (57600 baud)");
}
else
{
wprintw(window, "%s", "CoCo 1/2 (38400 baud)");
}
break;
}
wmove(window, y++, x); wclrtoeol(window);
wprintw(window, "%s", device);
wmove(window, y++, x); wclrtoeol(window);
switch (dp->dw_protocol_vrsn)
{
case 3:
wprintw(window, "3.0");
break;
case 2:
wprintw(window, "2.0");
break;
case 1:
wprintw(window, "1.0");
break;
}
wclrtoeol(window);
wmove(window, y++, x); wclrtoeol(window);
wprintw(window, dp->prtcmd);
wmove(window, y++, x); wclrtoeol(window);
for (i = 0; i < 4; i++)
{
wmove(window, y++, x); wclrtoeol(window);
wprintw(window, "%s", dskfile[i]);
}
/* 2. Refresh */
wrefresh(window);
return;
}
void WinTerm(void)
{
if (interactive == false)
{
return;
}
endwin();
return;
}