-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconsole.c
345 lines (302 loc) · 9.11 KB
/
console.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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
/*--------------------------------------------------------------------------
**
** Copyright (c) 2003-2011, Tom Hunter
**
** Name: console.c
**
** Description:
** Perform emulation of CDC 6612 or CC545 console.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License version 3 as
** published by the Free Software Foundation.
**
** 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 version 3 for more details.
**
** You should have received a copy of the GNU General Public License
** version 3 along with this program in file "license-gpl-3.0.txt".
** If not, see <http://www.gnu.org/licenses/gpl-3.0.txt>.
**
**--------------------------------------------------------------------------
*/
/*
** -------------
** Include Files
** -------------
*/
#include <stdio.h>
#include <stdlib.h>
#include "const.h"
#include "types.h"
#include "proto.h"
/*
** -----------------
** Private Constants
** -----------------
*/
/*
** CDC 6612 console functions and status codes.
*/
#define Fc6612Sel64CharLeft 07000
#define Fc6612Sel32CharLeft 07001
#define Fc6612Sel16CharLeft 07002
#define Fc6612Sel512DotsLeft 07010
#define Fc6612Sel512DotsRight 07110
#define Fc6612SelKeyIn 07020
#define Fc6612Sel64CharRight 07100
#define Fc6612Sel32CharRight 07101
#define Fc6612Sel16CharRight 07102
/*
** -----------------------
** Private Macro Functions
** -----------------------
*/
/*
** -----------------------------------------
** Private Typedef and Structure Definitions
** -----------------------------------------
*/
/*
** ---------------------------
** Private Function Prototypes
** ---------------------------
*/
static FcStatus consoleFunc(PpWord funcCode);
static void consoleIo(void);
static void consoleActivate(void);
static void consoleDisconnect(void);
/*
** ----------------
** Public Variables
** ----------------
*/
/*
** -----------------
** Private Variables
** -----------------
*/
static u8 currentFont;
static u16 currentOffset;
static bool emptyDrop = FALSE;
/*
**--------------------------------------------------------------------------
**
** Public Functions
**
**--------------------------------------------------------------------------
*/
/*--------------------------------------------------------------------------
** Purpose: Initialise 6612 console.
**
** Parameters: Name Description.
** eqNo equipment number
** unitNo unit number
** channelNo channel number the device is attached to
** deviceName optional device file name
**
** Returns: Nothing.
**
**------------------------------------------------------------------------*/
void consoleInit(u8 eqNo, u8 unitNo, u8 channelNo, char *deviceName)
{
DevSlot *dp;
(void)eqNo;
(void)unitNo;
(void)deviceName;
dp = channelAttach(channelNo, eqNo, DtConsole);
dp->activate = consoleActivate;
dp->disconnect = consoleDisconnect;
dp->selectedUnit = 0;
dp->func = consoleFunc;
dp->io = consoleIo;
/*
** Initialise (X)Windows environment.
*/
windowInit();
/*
** Print a friendly message.
*/
printf("Console initialised on channel %o\n", channelNo);
}
/*--------------------------------------------------------------------------
** Purpose: Execute function code on 6612 console.
**
** Parameters: Name Description.
** funcCode function code
**
** Returns: FcStatus
**
**------------------------------------------------------------------------*/
static FcStatus consoleFunc(PpWord funcCode)
{
activeChannel->full = FALSE;
switch (funcCode)
{
default:
return(FcDeclined);
case Fc6612Sel512DotsLeft:
currentFont = FontDot;
currentOffset = OffLeftScreen;
windowSetFont(currentFont);
break;
case Fc6612Sel512DotsRight:
currentFont = FontDot;
currentOffset = OffRightScreen;
windowSetFont(currentFont);
break;
case Fc6612Sel64CharLeft:
currentFont = FontSmall;
currentOffset = OffLeftScreen;
windowSetFont(currentFont);
break;
case Fc6612Sel32CharLeft:
currentFont = FontMedium;
currentOffset = OffLeftScreen;
windowSetFont(currentFont);
break;
case Fc6612Sel16CharLeft:
currentFont = FontLarge;
currentOffset = OffLeftScreen;
windowSetFont(currentFont);
break;
case Fc6612Sel64CharRight:
currentFont = FontSmall;
currentOffset = OffRightScreen;
windowSetFont(currentFont);
break;
case Fc6612Sel32CharRight:
currentFont = FontMedium;
currentOffset = OffRightScreen;
windowSetFont(currentFont);
break;
case Fc6612Sel16CharRight:
currentFont = FontLarge;
currentOffset = OffRightScreen;
windowSetFont(currentFont);
break;
case Fc6612SelKeyIn:
break;
}
activeDevice->fcode = funcCode;
return(FcAccepted);
}
/*--------------------------------------------------------------------------
** Purpose: Perform I/O on 6612 console.
**
** Parameters: Name Description.
** device Device control block
**
** Returns: Nothing.
**
**------------------------------------------------------------------------*/
static void consoleIo(void)
{
u8 ch;
switch (activeDevice->fcode)
{
default:
break;
case Fc6612Sel64CharLeft:
case Fc6612Sel32CharLeft:
case Fc6612Sel16CharLeft:
case Fc6612Sel64CharRight:
case Fc6612Sel32CharRight:
case Fc6612Sel16CharRight:
if (activeChannel->full)
{
emptyDrop = FALSE;
ch = (u8)((activeChannel->data >> 6) & Mask6);
if (ch >= 060)
{
if (ch >= 070)
{
/*
** Vertical coordinate.
*/
windowSetY((u16)(activeChannel->data & Mask9));
}
else
{
/*
** Horizontal coordinate.
*/
windowSetX((u16)((activeChannel->data & Mask9) + currentOffset));
}
}
else
{
windowQueue(consoleToAscii[(activeChannel->data >> 6) & Mask6]);
windowQueue(consoleToAscii[(activeChannel->data >> 0) & Mask6]);
}
activeChannel->full = FALSE;
}
break;
case Fc6612Sel512DotsLeft:
case Fc6612Sel512DotsRight:
if (activeChannel->full)
{
emptyDrop = FALSE;
ch = (u8)((activeChannel->data >> 6) & Mask6);
if (ch >= 060)
{
if (ch >= 070)
{
/*
** Vertical coordinate.
*/
windowSetY((u16)(activeChannel->data & Mask9));
windowQueue('.');
}
else
{
/*
** Horizontal coordinate.
*/
windowSetX((u16)((activeChannel->data & Mask9) + currentOffset));
}
}
activeChannel->full = FALSE;
}
break;
case Fc6612SelKeyIn:
windowGetChar();
activeChannel->data = asciiToConsole[ppKeyIn];
activeChannel->full = TRUE;
activeChannel->status = 0;
activeDevice->fcode = 0;
ppKeyIn = 0;
break;
}
}
/*--------------------------------------------------------------------------
** Purpose: Handle channel activation.
**
** Parameters: Name Description.
**
** Returns: Nothing.
**
**------------------------------------------------------------------------*/
static void consoleActivate(void)
{
emptyDrop = TRUE;
}
/*--------------------------------------------------------------------------
** Purpose: Handle disconnecting of channel.
**
** Parameters: Name Description.
**
** Returns: Nothing.
**
**------------------------------------------------------------------------*/
static void consoleDisconnect(void)
{
if (emptyDrop)
{
windowUpdate();
emptyDrop = FALSE;
}
}
/*--------------------------- End Of File ------------------------------*/