1 // license:GPL-2.0+
2 // copyright-holders:Peter Trauner
3 /*****************************************************************************
4 *
5 * pc1403.cpp
6 * Portable Sharp PC1403 video emulator interface
7 * (Sharp pocket computers)
8 *
9 * Copyright (c) 2001 Peter Trauner, all rights reserved.
10 *
11 * Change Log:
12 * 21.07.2001 Several changes listed below were made by Mario Konegger
13 * (konegger@itp.tu-graz.ac.at)
14 * Placed the graphical symbols in the right place and added
15 * some symbols, so the display is correct.
16 * Added an edge case of the display regarding the on/off
17 * state and the BUSY symbol, which was found out with testing
18 * on an actual PC1403.
19 *
20 * To Do: Convert to SVG rendering or an internal layout
21 *
22 *****************************************************************************/
23
24 #include "emu.h"
25
26 #include "includes/pocketc.h"
27 #include "includes/pc1403.h"
28
29
video_start()30 void pc1403_state::video_start()
31 {
32 m_down = 67;
33 m_right = 152;
34 }
35
video_start()36 void pc1403h_state::video_start()
37 {
38 m_down = 69;
39 m_right = 155;
40 }
41
lcd_read(offs_t offset)42 uint8_t pc1403_state::lcd_read(offs_t offset)
43 {
44 return m_reg[offset];
45 }
46
lcd_write(offs_t offset,uint8_t data)47 void pc1403_state::lcd_write(offs_t offset, uint8_t data)
48 {
49 m_reg[offset] = data;
50 }
51
52 const char* const pc1403_state::s_line[5] = /* simple line */
53 {
54 " ",
55 " ",
56 "11111",
57 "11111",
58 "11111"
59 };
60
61 const char* const pc1403_state::s_busy[5] =
62 {
63 "11 1 1 11 1 1",
64 "1 1 1 1 1 1 1",
65 "11 1 1 1 1 1",
66 "1 1 1 1 1 1 ",
67 "11 1 11 1 "
68 };
69 const char* const pc1403_state::s_def[5] =
70 {
71 "11 111 111",
72 "1 1 1 1 ",
73 "1 1 111 11 ",
74 "1 1 1 1 ",
75 "11 111 1 "
76 };
77 const char* const pc1403_state::s_shift[5] =
78 {
79 " 11 1 1 1 111 111",
80 "1 1 1 1 1 1 ",
81 " 1 111 1 11 1 ",
82 " 1 1 1 1 1 1 ",
83 "11 1 1 1 1 1 "
84 };
85 const char* const pc1403_state::s_hyp[5] =
86 {
87 "1 1 1 1 11 ",
88 "1 1 1 1 1 1",
89 "111 1 1 11 ",
90 "1 1 1 1 ",
91 "1 1 1 1 "
92 };
93 const char* const pc1403_state::s_de[5] =
94 {
95 "11 111",
96 "1 1 1 ",
97 "1 1 111",
98 "1 1 1 ",
99 "11 111"
100 };
101 const char* const pc1403_state::s_g[5] =
102 {
103 " 11",
104 "1 ",
105 "1 1",
106 "1 1",
107 " 11"
108 };
109 const char* const pc1403_state::s_rad[5] =
110 {
111 "11 1 11 ",
112 "1 1 1 1 1 1",
113 "11 111 1 1",
114 "1 1 1 1 1 1",
115 "1 1 1 1 11 "
116 };
117 const char* const pc1403_state::s_braces[5] =
118 {
119 " 1 1 ",
120 "1 1",
121 "1 1",
122 "1 1",
123 " 1 1 "
124 };
125 const char* const pc1403_state::s_m[5] =
126 {
127 "1 1",
128 "11 11",
129 "1 1 1",
130 "1 1",
131 "1 1"
132 };
133 const char* const pc1403_state::s_e[5] =
134 {
135 "111",
136 "1 ",
137 "111",
138 "1 ",
139 "111"
140 };
141 const char* const pc1403_state::s_kana[5] = // katakana charset
142 {
143 " 1 1 ",
144 " 11111 111",
145 " 1 1 1 ",
146 " 1 1 1 ",
147 "1 1 1 "
148 };
149 const char* const pc1403_state::s_shoo[5] = // minor
150 {
151 " 1 ",
152 " 1 1 1 ",
153 "1 1 1",
154 " 1 ",
155 " 1 "
156 };
157 const char* const pc1403_state::s_sml[5] =
158 {
159 " 11 1 1 1 ",
160 "1 111 1 ",
161 " 1 1 1 1 ",
162 " 1 1 1 1 ",
163 "11 1 1 111"
164 };
165
screen_update(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)166 uint32_t pc1403_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
167 {
168 const int contrast = m_dsw0->read() & 7;
169 int color[3] =
170 {
171 7,
172 BIT(m_portc, 0) ? 8 : 7,
173 8
174 };
175
176 bitmap.fill(11, cliprect);
177
178 if (BIT(m_portc, 0))
179 {
180 int x = m_right;
181 int y = m_down;
182 for (int i = 0; i < 6*5; x+=2)
183 for (int j = 0; j < 5; j++, i++, x+=2)
184 m_gfxdecode->gfx(0)->opaque(bitmap, cliprect, m_reg[i], contrast, 0, 0, x, y);
185
186 for (int i = 9*5; i < 12*5; x+=2)
187 for (int j = 0; j < 5; j++, i++, x+=2)
188 m_gfxdecode->gfx(0)->opaque(bitmap, cliprect, m_reg[i], contrast, 0, 0, x, y);
189
190 for (int i = 6*5; i < 9*5; x += 2)
191 for (int j = 0; j < 5; j++, i++, x+=2)
192 m_gfxdecode->gfx(0)->opaque(bitmap, cliprect, m_reg[i], contrast, 0, 0, x, y);
193
194 for (int i = 0x7b - 3*5; i > 0x7b - 6*5; x+=2)
195 for (int j = 0; j < 5; j++, i--, x+=2)
196 m_gfxdecode->gfx(0)->opaque(bitmap, cliprect, m_reg[i], contrast, 0, 0, x, y);
197
198 for (int i = 0x7b; i > 0x7b - 3*5; x += 2)
199 for (int j = 0; j < 5; j++, i--, x+=2)
200 m_gfxdecode->gfx(0)->opaque(bitmap, cliprect, m_reg[i], contrast, 0, 0, x, y);
201
202 for (int i = 0x7b - 6*5; i > 0x7b - 12*5; x += 2)
203 for (int j = 0; j < 5; j++, i--, x+=2)
204 m_gfxdecode->gfx(0)->opaque(bitmap, cliprect, m_reg[i], contrast, 0, 0, x, y);
205 }
206
207 /* If the display is off, busy is always visible. But if the computer is off, busy is hidden. */
208 if(!BIT(m_portc, 3))
209 {
210 if (BIT(m_portc, 0))
211 pocketc_draw_special(bitmap, m_right, m_down-13, s_busy, BIT(m_reg[0x3d], 0) ? color[2] : color[0]);
212 else
213 pocketc_draw_special(bitmap, m_right, m_down-13, s_busy, color[2]);
214 }
215 else
216 {
217 pocketc_draw_special(bitmap, m_right, m_down-13, s_busy, color[0]);
218 }
219
220 pocketc_draw_special(bitmap, m_right+155, m_down-13, s_kana, BIT(m_reg[0x3c], 0) ? color[1] : color[0]);
221 pocketc_draw_special(bitmap, m_right+167, m_down-13, s_shoo, BIT(m_reg[0x3c], 1) ? color[1] : color[0]);
222 pocketc_draw_special(bitmap, m_right+178, m_down-13, s_sml, BIT(m_reg[0x3c], 2) ? color[1] : color[0]);
223 pocketc_draw_special(bitmap, m_right+253, m_down+25, s_line, BIT(m_reg[0x3c], 3) ? color[1] : color[0]); // stat
224 pocketc_draw_special(bitmap, m_right+232, m_down+25, s_line, BIT(m_reg[0x3c], 4) ? color[1] : color[0]); // matrix
225 pocketc_draw_special(bitmap, m_right+94, m_down+25, s_line, BIT(m_reg[0x3c], 5) ? color[1] : color[0]); // empty
226 pocketc_draw_special(bitmap, m_right+10, m_down+25, s_line, BIT(m_reg[0x3c], 6) ? color[1] : color[0]); // empty
227
228 pocketc_draw_special(bitmap, m_right+18, m_down-13, s_def, BIT(m_reg[0x3d], 1) ? color[1] : color[0]);
229 pocketc_draw_special(bitmap, m_right+43, m_down-13, s_shift, BIT(m_reg[0x3d], 2) ? color[1] : color[0]);
230 pocketc_draw_special(bitmap, m_right+63, m_down-13, s_hyp, BIT(m_reg[0x3d], 3) ? color[1] : color[0]);
231 pocketc_draw_special(bitmap, m_right+73, m_down+25, s_line, BIT(m_reg[0x3d], 4) ? color[1] : color[0]); // prog
232 pocketc_draw_special(bitmap, m_right+52, m_down+25, s_line, BIT(m_reg[0x3d], 5) ? color[1] : color[0]); // run
233 pocketc_draw_special(bitmap, m_right+31, m_down+25, s_line, BIT(m_reg[0x3d], 6) ? color[1] : color[0]); // calc
234
235 pocketc_draw_special(bitmap, m_right+281, m_down-13, s_e, BIT(m_reg[0x7c], 0) ? color[1] : color[0]);
236 pocketc_draw_special(bitmap, m_right+274, m_down-13, s_m, BIT(m_reg[0x7c], 1) ? color[1] : color[0]);
237 pocketc_draw_special(bitmap, m_right+266, m_down-13, s_braces, BIT(m_reg[0x7c], 2) ? color[1] : color[0]);
238 pocketc_draw_special(bitmap, m_right+203, m_down-13, s_rad, BIT(m_reg[0x7c], 3) ? color[1] : color[0]);
239 pocketc_draw_special(bitmap, m_right+199, m_down-13, s_g, BIT(m_reg[0x7c], 4) ? color[1] : color[0]);
240 pocketc_draw_special(bitmap, m_right+191, m_down-13, s_de, BIT(m_reg[0x7c], 5) ? color[1] : color[0]);
241 pocketc_draw_special(bitmap, m_right+274, m_down+25, s_line, BIT(m_reg[0x7c], 6) ? color[1] : color[0]); // print
242
243 return 0;
244 }
245