-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay.c
153 lines (141 loc) · 4.74 KB
/
display.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
/*
* Copyright (C) 2024 by Matthieu CASTET <[email protected]>
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <string.h>
#include "emu.h"
static struct {
char out[30];
char out1[30];
int pos;
} disp;
char *display_debug(void)
{
return disp.out1;
}
static int display_process(void *priv, struct bus *bus)
{
/* alu update on S0W and clear at S14W */
if (bus->sstate == 0 && !bus->write) {
/* 13 digits display
* D13/D1 is - and .
* D12 ... D3 digit/. (mantisa)
* D2 is -
* D2 D1 is digit (exponent)
*
* - is connected to segH
*/
if (bus->dstate <= 13 && bus->dstate >= 1) {
if (bus->dstate == 1 && bus->display_segH)
disp.out[0] = '-';
if (bus->dstate == 2) {
if (bus->display_segH)
disp.out[disp.pos++] = '-';
else
disp.out[disp.pos++] = ' ';
}
if (bus->dstate != 13)
disp.out[disp.pos++] = bus->display_digit;
else
disp.out[disp.pos++] = ' ';
/* not really seen in rom, but hw allow it */
if (bus->dstate == 13 && bus->display_segH)
disp.out[0] = '-';
if (bus->display_dpt && bus->dstate >= 3)
disp.out[disp.pos++] = '.';
else if (bus->display_dpt && bus->dstate == 1)
LOG("???? dpt at D1 ");
//LOG("\nSEG.%d='%c' (%s)\n", bus->dstate, bus->display_digit, disp.out);
}
if (bus->dstate==0) {
if (memcmp(disp.out1, disp.out, sizeof(disp.out1))) {
LOG("\nDISP='%s'\n", disp.out);
printf(" \r%s", disp.out);
memcpy(disp.out1, disp.out, sizeof(disp.out1));
}
//memset(disp.out, '\0', sizeof(disp.out));
memset(disp.out, ' ', sizeof(disp.out)-1);
disp.pos = 0;
}
}
return 0;
}
static int display_process2(void *priv, struct bus *bus)
{
/* alu update on S0W and clear at S14W */
if (bus->sstate == 0 && !bus->write) {
/* 12 digit connected to D13-D2
* D13 is (C or -) and .
*/
if (bus->dstate <= 13 && bus->dstate >= 2) {
/* bus->display_segH is connected to C and D13
*/
if (bus->dstate != 13)
disp.out[disp.pos++] = bus->display_digit;
else {
if (bus->display_digit == '-') {
if (bus->display_segH)
disp.out[disp.pos++] = 'E';
else
disp.out[disp.pos++] = '-';
}
else {
if (bus->display_segH)
disp.out[disp.pos++] = 'C';
else
disp.out[disp.pos++] = ' ';
}
}
if (bus->display_dpt)
disp.out[disp.pos++] = '.';
//LOG("\nSEG.%d='%c' (%s)\n", bus->dstate, bus->display_digit, disp.out);
}
if (bus->dstate==0) {
if (memcmp(disp.out1, disp.out, sizeof(disp.out1))) {
LOG("\nDISP='%s'\n", disp.out);
printf(" \r%s", disp.out);
memcpy(disp.out1, disp.out, sizeof(disp.out1));
}
//memset(disp.out, '\0', sizeof(disp.out));
memset(disp.out, ' ', sizeof(disp.out)-1);
disp.pos = 0;
}
}
return 0;
}
void display_print(const char *line)
{
printf("| %.20s\n", line);
printf("\r%s", disp.out);
}
void display_dbgprint(const char *line)
{
printf("|d %.13s %s\n", disp.out1, line);
printf("\r%s", disp.out);
}
int display_init(struct chip *chip, const char *name)
{
if (name && (!strcmp(name, "ti58") || !strcmp(name, "ti58c") ||
!strcmp(name, "ti59") || !strcmp(name, "sr51-II"))) {
chip->process = display_process2;
printf("new display\n");
}
else
chip->process = display_process;
return 0;
}