2 NEC TK-80BS (COMPO BS/80) Emulator 'eTK-80BS'
4 Author : Takeda.Toshiya
13 static const uint8 matrix[256] = {
14 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,
15 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
16 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,
17 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x00,0x00,0x00,0x00,0x00,0x00,
18 0x00,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
19 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x00,0x00,0x00,0x00,0x00,
20 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x2a,0x2b,0x00,0x2d,0x2e,0x2f,
21 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
22 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
23 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
24 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
25 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3a,0x3b,0x2c,0x2d,0x2e,0x2f,
26 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
27 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5b,0x5c,0x5d,0x5e,0x00,
28 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
29 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
32 static const uint8 matrix_s[256] = {
33 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,
34 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
35 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,
36 0x00,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x00,0x00,0x00,0x00,0x00,0x00,
37 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
38 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
39 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
40 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
41 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
42 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
43 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
44 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2a,0x2b,0x3c,0x3d,0x3e,0x3f,
45 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
46 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
47 0x00,0x00,0x5f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
48 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
51 static const uint8 matrix_k[256] = {
52 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,
53 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
54 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,
55 0xdc,0xc7,0xcc,0xb1,0xb3,0xb4,0xb5,0xd4,0xd5,0xd6,0x00,0x00,0x00,0x00,0x00,0x00,
56 0x00,0xc1,0xba,0xbf,0xbc,0xb2,0xca,0xb7,0xb8,0xc6,0xcf,0xc9,0xd8,0xd3,0xd0,0xd7,
57 0xbe,0xc0,0xbd,0xc4,0xb6,0xc5,0xcb,0xc3,0xbb,0xdd,0xc2,0x00,0x00,0x00,0x00,0x00,
58 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
59 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
60 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
61 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
62 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
63 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb9,0xda,0xc8,0xce,0xd9,0xd2,
64 0xde,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
65 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdf,0xb0,0xd1,0xcd,0x00,
66 0x00,0x00,0xdb,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
67 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
70 static const uint8 matrix_ks[256] = {
71 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,
72 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
73 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,
74 0xa6,0x00,0x00,0xa7,0xa9,0xaa,0xab,0xac,0xad,0xae,0x00,0x00,0x00,0x00,0x00,0x00,
75 0x00,0x00,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
76 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x00,0x00,0x00,0x00,0x00,
77 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
78 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
79 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
80 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
81 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
82 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa4,0x00,0xa1,0xa5,
83 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
84 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0x00,0xa3,0x00,0x00,
85 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
86 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
89 void KEYBOARD::initialize()
91 key_stat = emu->key_buffer();
95 void KEYBOARD::reset()
97 prev_type = prev_brk = prev_kana = 0;
102 void KEYBOARD::write_signal(int id, uint32 data, uint32 mask)
104 // update TK-80 keyboard
105 column = data & mask;
109 void KEYBOARD::key_down(int code)
112 bool hit_type = (key_stat[0x1b] && !prev_type); // ESC
113 bool hit_brk = (key_stat[0x13] && !prev_brk); // PAUSE/BREAK
114 bool hit_kana = (key_stat[0x15] && !prev_kana); // KANA
115 prev_type = key_stat[0x1b];
116 prev_brk = key_stat[0x13];
117 prev_kana = key_stat[0x15];
119 // check keyboard focus
129 // update TK-80BS keyboard
133 d_cpu->set_intr_line(true, true, 0);
138 kana_lock = !kana_lock;
144 code = matrix_ks[code & 0xff];
146 code = matrix_k[code & 0xff];
150 code = matrix_s[code & 0xff];
152 code = matrix[code & 0xff];
156 d_pio_b->write_signal(SIG_I8255_PORT_A, code, 0xff);
160 // update TK-80 keyboard
164 void KEYBOARD::key_up(int code)
166 prev_type = key_stat[0x1b];
167 prev_brk = key_stat[0x13];
168 prev_kana = key_stat[0x15];
170 // update TK-80 keyboard
174 uint32 KEYBOARD::intr_ack()
180 void KEYBOARD::update_tk80()
182 /* [RET] [RUN] [STO] [LOA] [RES]
183 [ C ] [ D ] [ E ] [ F ] [ADR]
184 [ 8 ] [ 9 ] [ A ] [ B ] [RD+]
185 [ 4 ] [ 5 ] [ 6 ] [ 7 ] [RD-]
186 [ 0 ] [ 1 ] [ 2 ] [ 3 ] [WR+]
191 if(!(column & 0x10)) {
192 if(key_stat[0x30] || key_stat[0x60]) val &= ~0x01; // 0
193 if(key_stat[0x31] || key_stat[0x61]) val &= ~0x02; // 1
194 if(key_stat[0x32] || key_stat[0x62]) val &= ~0x04; // 2
195 if(key_stat[0x33] || key_stat[0x63]) val &= ~0x08; // 3
196 if(key_stat[0x34] || key_stat[0x64]) val &= ~0x10; // 4
197 if(key_stat[0x35] || key_stat[0x65]) val &= ~0x20; // 5
198 if(key_stat[0x36] || key_stat[0x66]) val &= ~0x40; // 6
199 if(key_stat[0x37] || key_stat[0x67]) val &= ~0x80; // 7
201 if(!(column & 0x20)) {
202 if(key_stat[0x38] || key_stat[0x68]) val &= ~0x01; // 8
203 if(key_stat[0x39] || key_stat[0x69]) val &= ~0x02; // 9
204 if(key_stat[0x41] ) val &= ~0x04; // A
205 if(key_stat[0x42] ) val &= ~0x08; // B
206 if(key_stat[0x43] ) val &= ~0x10; // C
207 if(key_stat[0x44] ) val &= ~0x20; // D
208 if(key_stat[0x45] ) val &= ~0x40; // E
209 if(key_stat[0x46] ) val &= ~0x80; // F
211 if(!(column & 0x40)) {
212 if(key_stat[0x71] ) val &= ~0x01; // RUN F2
213 if(key_stat[0x70] ) val &= ~0x02; // RET F1
214 if(key_stat[0x74] ) val &= ~0x04; // ADRS SET F5
215 if(key_stat[0x76] || key_stat[0x22]) val &= ~0x08; // READ DECR F7 or PgDn
216 if(key_stat[0x75] || key_stat[0x21]) val &= ~0x10; // READ INCR F6 or PgUp
217 if(key_stat[0x77] || key_stat[0x0d]) val &= ~0x20; // WRITE INCR F8 or Enter
218 if(key_stat[0x72] ) val &= ~0x40; // STORE DATA F3
219 if(key_stat[0x73] ) val &= ~0x80; // LOAD DATA F4
221 d_pio_t->write_signal(SIG_I8255_PORT_A, val, 0xff);