GE-115 Emulator
An Emulator of the General Electrics GE-115 computer
gecode.c
Go to the documentation of this file.
1/*
2 * gecode.c - GE 100-series internal graphic character code.
3 *
4 * GE 100 Series Graphic Character Set — machine byte -> glyph, transcribed from
5 * the GE APS Reference Manual (EDV-AFL vol. 03) Figure 3, p.16. The 64-character
6 * graphic set occupies 0x40-0x5F and 0xA0-0xBF; all other codes are non-graphic.
7 * Used to annotate DB data bytes (gdis) and to render printer/typewriter output
8 * with the character it represents ON THE MACHINE (not ASCII — which did not yet
9 * exist). Glyphs that have no ASCII equivalent (up/left arrows 0xA0/0xBA, long
10 * dash 0xAA, bullet 0xAC) render '.'.
11 *
12 * This table is corroborated by the CRZ card transcoder: CRZ[2] §5.3 "Table 3 —
13 * IBM card code and Internal GECB code equivalent" (vol. [2] p.113) shows the
14 * transcoder converts card punches to this same internal code (digit '0'=0x40,
15 * 'J'=0xA1). The EBCDIC-like codes in transcode.c (digits 0xF0-0xF9) are an
16 * artifact of the externally-supplied funktionalcpu.bin, not the machine's
17 * code — see docs/ISA.md §2.1 for the full reconciliation.
18 */
19
20#include "gecode.h"
21
22static const char GE_GLYPH[256] = {
23 [0x40]='0',[0x41]='1',[0x42]='2',[0x43]='3',[0x44]='4',[0x45]='5',
24 [0x46]='6',[0x47]='7',[0x48]='8',[0x49]='9',
25 [0x4A]='[',[0x4B]='#',[0x4C]='@',[0x4D]=':',[0x4E]='>',[0x4F]='?',
26 [0x50]=' ',[0x51]='A',[0x52]='B',[0x53]='C',[0x54]='D',[0x55]='E',
27 [0x56]='F',[0x57]='G',[0x58]='H',[0x59]='I',
28 [0x5A]='&',[0x5B]='.',[0x5C]=']',[0x5D]='(',[0x5E]='<',[0x5F]='\\',
29 [0xA1]='J',[0xA2]='K',[0xA3]='L',[0xA4]='M',[0xA5]='N',[0xA6]='O',
30 [0xA7]='P',[0xA8]='Q',[0xA9]='R',
31 [0xAB]='$',[0xAD]=')',[0xAE]=';',[0xAF]='\'',
32 [0xB0]='+',[0xB1]='/',[0xB2]='S',[0xB3]='T',[0xB4]='U',[0xB5]='V',
33 [0xB6]='W',[0xB7]='X',[0xB8]='Y',[0xB9]='Z',
34 [0xBB]=',',[0xBC]='%',[0xBD]='=',[0xBE]='"',[0xBF]='!',
35};
36
37char ge_glyph(uint8_t b)
38{
39 if (b == 0x00)
40 return '\n';
41 if (b == 0xAA)
42 return '-';
43 char c = GE_GLYPH[b];
44 return c ? c : '.';
45}
46
47uint8_t ge_code(uint8_t c)
48{
49 if (c >= '0' && c <= '9') return 0x40 + (c - '0');
50 if (c >= 'A' && c <= 'I') return 0x51 + (c - 'A');
51 if (c >= 'J' && c <= 'R') return 0xA1 + (c - 'J');
52 if (c >= 'S' && c <= 'Z') return 0xB2 + (c - 'S');
53 if (c >= 'a' && c <= 'z') return ge_code((uint8_t)(c - 'a' + 'A'));
54 switch (c) {
55 case '\n': return 0x00;
56 case '\r': return 0x00;
57 case '\t': return 0x50;
58 case ' ': return 0x50;
59 case '[': return 0x4A;
60 case '#': return 0x4B;
61 case '@': return 0x4C;
62 case ':': return 0x4D;
63 case '>': return 0x4E;
64 case '?': return 0x4F;
65 case '&': return 0x5A;
66 case '.': return 0x5B;
67 case ']': return 0x5C;
68 case '(': return 0x5D;
69 case '<': return 0x5E;
70 case '\\': return 0x5F;
71 case '$': return 0xAB;
72 case '-': return 0xAA;
73 case ')': return 0xAD;
74 case ';': return 0xAE;
75 case '\'': return 0xAF;
76 case '+': return 0xB0;
77 case '/': return 0xB1;
78 case ',': return 0xBB;
79 case '%': return 0xBC;
80 case '=': return 0xBD;
81 case '"': return 0xBE;
82 case '!': return 0xBF;
83 case 0: return 0x00;
84 }
85 return 0x50;
86}
static const char GE_GLYPH[256]
Definition gecode.c:22
char ge_glyph(uint8_t b)
Definition gecode.c:37
uint8_t ge_code(uint8_t c)
Definition gecode.c:47