GE-115 Emulator
An Emulator of the General Electrics GE-115 computer
reader.c
Go to the documentation of this file.
1#include "ge.h"
2#include "log.h"
3#include "signals.h"
4#include "connector34.h"
5
6#define ENUMERATE_READER_COMMANDS \
7 X(0x40, read, "Read unchanged") \
8 X(0x21, read_normal_1, "Read normal i" ) \
9 X(0x01, read_normal_2, "Read normal ii") \
10 X(0x24, read_mixed_1, "Read mixed i" ) \
11 X(0x04, read_mixed_2, "Read mixed ii" ) \
12 X(0x20, read_binary, "Read binary" ) \
13 X(0xa1, put_normal_1, "Put normal i" ) \
14 X(0x81, put_normal_2, "Put normal ii" ) \
15 X(0xa4, put_mixed_1, "Put mixed i" ) \
16 X(0x84, put_mixed_2, "Put mixed ii" ) \
17 X(0xa0, put_binary, "Put binary" ) \
18 X(0xac, put_manual, "Put manual" ) \
19 X(0x48, card_reject, "Card_reject" ) \
20 X(0x0c, no_function, "No function" )
21
22void reader_send_tu00(struct ge *ge)
23{
24 uint8_t command = ge->rRE;
25 ge_log(LOG_READER, "EMIT TU201 (CE10)\n");
26
27 /* TU00N read-strobe line: the CPU clocks the command byte (rRE) toward the
28 * reader. Modelled as an explicit pin (inert — observability only). */
30
31 switch (command) {
32#define X(cmd, name, desc) \
33 case cmd: \
34 ge_log(LOG_READER, " Command: %02x - %s\n", cmd, desc ); \
35 break;
37#undef X
38 }
39
40 /* COCON — mode-select clock. An explicit mode-select READ command drives the
41 * N001/N002/DEBI/MI01/MI02 decode and latches the CPU-selected read mode
42 * (active_mode/active_valid). The plain "read unchanged" (0x40) and the
43 * put/reject/manual commands leave the mode as-is, so the bootstrap (which
44 * issues 0x40) never engages the CPU mode and the cardreader keeps its
45 * harness/default mode. This is the loader's "set by-pass" actually
46 * switching normal<->binary. */
47 {
49 int latch = 1;
50 r->mode_n001 = r->mode_n002 = r->mode_debi = r->mode_mi01 = r->mode_mi02 = 0;
51 switch (command) {
52 case 0x21: r->mode_n001 = 1; r->active_mode = TC_NORMAL; break; /* read normal i */
53 case 0x01: r->mode_n002 = 1; r->active_mode = TC_NORMAL; break; /* read normal ii */
54 case 0x24: r->mode_mi01 = 1; r->active_mode = TC_NORMAL; break; /* read mixed i */
55 case 0x04: r->mode_mi02 = 1; r->active_mode = TC_NORMAL; break; /* read mixed ii */
56 case 0x20: r->mode_debi = 1; r->active_mode = TC_COLBIN; break; /* read by-pass / column-binary */
57 case 0xa0: r->mode_debi = 1; r->active_mode = TC_COLBIN; break; /* channel code card: with by-pass */
58 default: latch = 0; break; /* 0x40 etc.: keep mode */
59 }
60 if (latch) { r->cocon = 1; r->active_valid = 1; }
61 }
62}
63
64void reader_setup_to_send(struct ge *ge, uint8_t data, uint8_t end)
65{
69
70 /* A byte is now on the data lines: the reader is busy, not free. Holding
71 * LUPOR (reader free) at 0 whenever LU08=1 keeps PELEA = !(LU08 . LUPO1) at
72 * 1, so the read data path is unchanged by the ready line. */
74
75 /* When end=1, set the end-of-transfer flip-flops.
76 *
77 * In the hardware, FINI1 contributes to RF101 through PF12A when the
78 * integrated reader is selected on channel 1 (PC121=1). RF101 is then
79 * stored into RIG1 on the channel timing edge. Here we short-cut that
80 * path and set RIG1 directly because this helper is only used by the
81 * integrated-reader path.
82 *
83 * PEC1 is a second shortcut, but one stage later. The manual routes
84 * peripheral-end completion through the TO50/PIM11 reset chain; gemu now
85 * records that a PEC1 set is pending here and commits it from pulse.c at
86 * TO50, instead of raising PEC1 immediately in the peripheral helper.
87 */
88 if (end) {
89 ge->RIG1 = 1;
90 ge->PEC1_pending = 1;
91 }
92
93 if (RB111(ge)) {
94 ge_log(LOG_READER, "XXX\n");
95 }
96}
97
99{
102 /* Clear the end-of-card strobe so FINI1 / RF101 deassert once the
103 * machine has consumed the end byte. This is essential for multi-card
104 * reads: if fini stays 1, the NEXT card's first byte would immediately
105 * signal end-of-card again before any data is read. */
107}
108
109void reader_send_tu10(struct ge *ge)
110{
111 ge_log(LOG_READER, "EMIT TU101 (CE09)\n");
112
113 /* LENON ("not operable") inhibits the card-feed: a non-operable reader
114 * does not advance under the CPU's feed strobe. */
116 ge_log(LOG_READER, " Card feed INHIBITED (LENON / not operable)\n");
117 return;
118 }
119
120 ge_log(LOG_READER, " Card feed\n");
121
122 /* TU03N card-feed/advance line. Modelled as an explicit pin (Phase 4
123 * switches the cardreader's deck-advance onto this line). */
125}
126
127uint8_t reader_get_LU08(struct ge *ge)
128{
129 ge_log(LOG_READER, "reading LU081 -- character strobe\n");
130
133 " wanting to send char: %02x\n",
135 }
136
137 return ge->integrated_reader.lu08;
138}
139
140uint8_t reader_get_LUPO1(struct ge *ge)
141{
142 /* LUPOR: reader free / ready. Defaults 0 (== the previous hardcoded stub),
143 * so this is inert until Phase 3 drives `lupor`. */
144 return ge->integrated_reader.lupor;
145}
146
147uint8_t reader_get_FINI1(struct ge *ge)
148{
149 ge_log(LOG_READER, "**** reading FINI1 %d\n", ge->integrated_reader.fini);
150 return ge->integrated_reader.fini;
151}
152
153uint8_t connector_get_MARE(struct ge_connector *conn)
154{
155 ge_log(LOG_READER, "%s -- connector_get_MARE\n", conn->name);
156 return conn->mare;
157}
158
159uint8_t connector_get_TE10(struct ge_connector *conn)
160{
161 ge_log(LOG_READER, "%s -- connector_get_TE10\n", conn->name);
162 return conn->te10;
163}
164
165uint8_t connector_get_TE20(struct ge_connector *conn)
166{
167 ge_log(LOG_READER, "%s -- connector_get_TE20\n", conn->name);
168 return conn->te20;
169}
170
171uint8_t connector_get_TE30(struct ge_connector *conn)
172{
173 ge_log(LOG_READER, "%s -- connector_get_TE30\n", conn->name);
174 return conn->te30;
175}
176
177uint8_t connector_get_FINE(struct ge_connector *conn)
178{
179 ge_log(LOG_READER, "%s -- connector_get_FINE\n", conn->name);
180 return conn->fine;
181}
182
183void connector_setup_to_send(struct ge *ge, struct ge_connector *conn, uint8_t data, uint8_t end)
184{
185 /* equivalent of lu08, but not sure if it's TE10 or TE20, seems or-red together
186 * (intermediate fo. 11, D1, D2) */
187
188 conn->te10 = 1;
189 conn->te20 = 1;
190 conn->data = data;
191 conn->fine = end;
192
193 /* Mirror the same end-of-transfer signalling as reader_setup_to_send.
194 * The connector FINE inputs feed RF101 through PF13A/PF14A when the
195 * external unit is selected; gemu still short-circuits the subsequent
196 * RIG1 timing path here, but now defers PEC1 to the TO50 latch point. */
197 if (end) {
198 ge->RIG1 = 1;
199 ge->PEC1_pending = 1;
200 }
201
202 if (RB111(ge)) {
203 ge_log(LOG_READER, "XXX\n");
204 }
205}
206
208{
209 conn->te10 = 0;
210 conn->te20 = 0;
211 conn->data = 0;
212 /* Clear end-of-card strobe to deassert FINE/RF10x for next card. */
213 conn->fine = 0;
214}
215
216void connector_send_tu00(struct ge *ge, struct ge_connector *conn)
217{
218 uint8_t command = ge->rRE;
219
220 switch (command) {
221#define X(cmd, namex, desc) \
222 case cmd: \
223 ge_log(LOG_READER, " connector %s got: %02x - %s\n", conn->name, cmd, desc ); \
224 break;
226#undef X
227 }
228
229 /* Hand the order byte to a Standard-GE-100 controller (disk/tape) on this
230 * connector, if one is attached. Inert when no connector-3/4 core exists. */
231 if (ge->std_core)
233}
void connector34_deliver_order(struct ge *ge, struct ge_connector *conn)
void ge_log(ge_log_type type, const char *format,...)
Log message.
Definition log.c:122
@ LOG_READER
Integrated Reader.
Definition log.h:28
void reader_setup_to_send(struct ge *ge, uint8_t data, uint8_t end)
Definition reader.c:64
uint8_t reader_get_LUPO1(struct ge *ge)
Definition reader.c:140
uint8_t connector_get_TE30(struct ge_connector *conn)
Definition reader.c:171
uint8_t reader_get_LU08(struct ge *ge)
Definition reader.c:127
uint8_t connector_get_MARE(struct ge_connector *conn)
Definition reader.c:153
void connector_clear_sending(struct ge_connector *conn)
Definition reader.c:207
void reader_clear_sending(struct ge *ge)
Definition reader.c:98
void reader_send_tu10(struct ge *ge)
Definition reader.c:109
uint8_t reader_get_FINI1(struct ge *ge)
Definition reader.c:147
void connector_send_tu00(struct ge *ge, struct ge_connector *conn)
Definition reader.c:216
void connector_setup_to_send(struct ge *ge, struct ge_connector *conn, uint8_t data, uint8_t end)
Definition reader.c:183
uint8_t connector_get_TE10(struct ge_connector *conn)
Definition reader.c:159
uint8_t connector_get_TE20(struct ge_connector *conn)
Definition reader.c:165
void reader_send_tu00(struct ge *ge)
Definition reader.c:22
#define ENUMERATE_READER_COMMANDS
Definition reader.c:6
uint8_t connector_get_FINE(struct ge_connector *conn)
Definition reader.c:177
Signals.
uint8_t te20
Definition reader.h:71
uint8_t mare
Definition reader.h:69
uint8_t data
Definition reader.h:67
uint8_t te30
Definition reader.h:72
uint8_t fine
Definition reader.h:73
const char * name
Definition reader.h:65
uint8_t te10
Definition reader.h:70
uint8_t mode_debi
Definition reader.h:42
enum transcode_mode active_mode
Definition reader.h:50
uint8_t mode_mi01
Definition reader.h:43
uint8_t mode_n001
Definition reader.h:40
uint8_t active_valid
Definition reader.h:51
uint8_t mode_n002
Definition reader.h:41
uint8_t mode_mi02
Definition reader.h:44
The entire state of the emulated system, including registers, memory, peripherals and timings.
Definition ge.h:96
void * std_core
Shared core for Standard-GE-100 controllers on connectors 3/4 (disk/tape).
Definition ge.h:654
uint8_t rRE
Definition ge.h:244
struct ge_integrated_reader integrated_reader
The I/O interface for the integrated reader (RI)
Definition ge.h:595
uint8_t PEC1_pending
Definition ge.h:421
uint8_t RIG1
End from controller 1.
Definition ge.h:527
@ TC_NORMAL
Definition transcode.h:19
@ TC_COLBIN
Definition transcode.h:22