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 
5 #define ENUMERATE_READER_COMMANDS \
6  X(0x40, read, "Read unchanged") \
7  X(0x21, read_normal_1, "Read normal i" ) \
8  X(0x01, read_normal_2, "Read normal ii") \
9  X(0x24, read_mixed_1, "Read mixed i" ) \
10  X(0x04, read_mixed_2, "Read mixed ii" ) \
11  X(0x20, read_binary, "Read binary" ) \
12  X(0xa1, put_normal_1, "Put normal i" ) \
13  X(0x81, put_normal_2, "Put normal ii" ) \
14  X(0xa4, put_mixed_1, "Put mixed i" ) \
15  X(0x84, put_mixed_2, "Put mixed ii" ) \
16  X(0xa0, put_binary, "Put binary" ) \
17  X(0xac, put_manual, "Put manual" ) \
18  X(0x48, card_reject, "Card_reject" ) \
19  X(0x0c, no_function, "No function" )
20 
21 void reader_send_tu00(struct ge *ge)
22 {
23  uint8_t command = ge->rRE;
24  ge_log(LOG_READER, "EMIT TU201 (CE10)\n");
25 
26  switch (command) {
27 #define X(cmd, name, desc) case cmd: ge_log(LOG_READER, " Command: %02x - %s\n", cmd, desc ); break;
29 #undef X
30  }
31 }
32 
33 void reader_setup_to_send(struct ge *ge, uint8_t data, uint8_t end)
34 {
36  ge->integrated_reader.data = data;
37  ge->integrated_reader.fini = end;
38 
39  /* signal end character */
40  /* todo: should use RF101 here? is "if (end)" correct? */
41  if (end)
42  ge->RIG1 = 1;
43 
44  /* todo: should be conditioned by PIM11, but it's false at this point
45  * without this, we don't get to state ea after waiting state b8 when
46  * reading */
47  if (end) {
48  ge->PEC1 = 1;
49  }
50 
51  if (RB111(ge)) {
52  ge_log(LOG_READER, "XXX\n");
53  }
54 }
55 
56 void reader_clear_sending(struct ge *ge)
57 {
60 }
61 
62 void reader_send_tu10(struct ge *ge)
63 {
64  ge_log(LOG_READER, "EMIT TU101 (CE09)\n");
65  ge_log(LOG_READER, " Card feed\n");
66 }
67 
68 uint8_t reader_get_LU08(struct ge *ge)
69 {
70  ge_log(LOG_READER, "reading LU081 -- character strobe\n");
71 
72  if (ge->integrated_reader.lu08) {
74  " wanting to send char: %02x\n",
76  }
77 
78  return ge->integrated_reader.lu08;
79 }
80 
81 uint8_t reader_get_LUPO1(struct ge *ge)
82 {
83  ge_log(LOG_READER, "reading LUPO1\n");
84  return 0;
85 }
86 
87 uint8_t reader_get_FINI1(struct ge *ge)
88 {
89  ge_log(LOG_READER, "**** reading FINI1 %d\n", ge->integrated_reader.fini);
90  return ge->integrated_reader.fini;
91 }
92 
93 uint8_t connector_get_MARE(struct ge_connector *conn)
94 {
95  ge_log(LOG_READER, "%s -- connector_get_MARE\n", conn->name);
96  return conn->mare;
97 }
98 
99 uint8_t connector_get_TE10(struct ge_connector *conn)
100 {
101  ge_log(LOG_READER, "%s -- connector_get_TE10\n", conn->name);
102  return conn->te10;
103 }
104 
105 uint8_t connector_get_TE20(struct ge_connector *conn)
106 {
107  ge_log(LOG_READER, "%s -- connector_get_TE20\n", conn->name);
108  return conn->te20;
109 }
110 
111 uint8_t connector_get_TE30(struct ge_connector *conn)
112 {
113  ge_log(LOG_READER, "%s -- connector_get_TE30\n", conn->name);
114  return conn->te30;
115 }
116 
117 uint8_t connector_get_FINE(struct ge_connector *conn)
118 {
119  ge_log(LOG_READER, "%s -- connector_get_FINE\n", conn->name);
120  return conn->fine;
121 }
122 
123 void connector_setup_to_send(struct ge *ge, struct ge_connector *conn, uint8_t data, uint8_t end)
124 {
125  /* equivalent of lu08, but not sure if it's TE10 or TE20, seems or-red together
126  * (intermediate fo. 11, D1, D2) */
127 
128  conn->te10 = 1;
129  conn->te20 = 1;
130  conn->data = data;
131  conn->fine = end;
132 
133  /* signal end character */
134  /* todo: should use RF101 here? is "if (end)" correct? */
135  if (end)
136  ge->RIG1 = 1;
137 
138  /* todo: should be conditioned by PIM11, but it's false at this point
139  * without this, we don't get to state ea after waiting state b8 when
140  * reading */
141  if (end)
142  ge->PEC1 = 1;
143 
144  if (RB111(ge)) {
145  ge_log(LOG_READER, "XXX\n");
146  }
147 }
148 
150 {
151  conn->te10 = 0;
152  conn->te20 = 0;
153  conn->data = 0;
154 }
155 
156 void connector_send_tu00(struct ge *ge, struct ge_connector *conn)
157 {
158  uint8_t command = ge->rRE;
159 
160  switch (command) {
161 #define X(cmd, namex, desc) case cmd: ge_log(LOG_READER, " connector %s got: %02x - %s\n", conn->name, cmd, desc ); break;
163 #undef X
164  }
165 
166 }
void ge_log(ge_log_type type, const char *format,...)
Log message.
Definition: log.c:31
@ 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:33
uint8_t reader_get_LUPO1(struct ge *ge)
Definition: reader.c:81
uint8_t connector_get_TE30(struct ge_connector *conn)
Definition: reader.c:111
uint8_t reader_get_LU08(struct ge *ge)
Definition: reader.c:68
uint8_t connector_get_MARE(struct ge_connector *conn)
Definition: reader.c:93
void connector_clear_sending(struct ge_connector *conn)
Definition: reader.c:149
void reader_clear_sending(struct ge *ge)
Definition: reader.c:56
void reader_send_tu10(struct ge *ge)
Definition: reader.c:62
uint8_t reader_get_FINI1(struct ge *ge)
Definition: reader.c:87
void connector_send_tu00(struct ge *ge, struct ge_connector *conn)
Definition: reader.c:156
void connector_setup_to_send(struct ge *ge, struct ge_connector *conn, uint8_t data, uint8_t end)
Definition: reader.c:123
uint8_t connector_get_TE10(struct ge_connector *conn)
Definition: reader.c:99
uint8_t connector_get_TE20(struct ge_connector *conn)
Definition: reader.c:105
void reader_send_tu00(struct ge *ge)
Definition: reader.c:21
#define ENUMERATE_READER_COMMANDS
Definition: reader.c:5
uint8_t connector_get_FINE(struct ge_connector *conn)
Definition: reader.c:117
Signals.
uint8_t te20
Definition: reader.h:32
uint8_t mare
Definition: reader.h:30
uint8_t data
Definition: reader.h:28
uint8_t te30
Definition: reader.h:33
uint8_t fine
Definition: reader.h:34
const char * name
Definition: reader.h:26
uint8_t te10
Definition: reader.h:31
uint8_t lu08
Definition: reader.h:9
The entire state of the emulated system, including registers, memory, peripherals and timings.
Definition: ge.h:94
uint8_t rRE
Definition: ge.h:220
struct ge_integrated_reader integrated_reader
The I/O interface for the integrated reader (RI)
Definition: ge.h:535
uint8_t PEC1
Definition: ge.h:383
uint8_t RIG1
End from controller 1.
Definition: ge.h:489