Previous 15994 Revisions Next

r4501 Thursday 16th April, 2009 at 12:10:56 UTC by Robbbert
[KAYPRO2] WIP
[src/mess]mess.mak
[src/mess/drivers]kaypro2.c
[src/mess/machine]kay_kbd.c* kay_kbd.h*

src/mess/machine/kay_kbd.c
r0r4501
1/******************************************************************************
2 *
3 *   kay_kbd.c
4 *
5 *   Kaypro II Serial Keyboard
6 *
7 *   Most of this is copied from kaypro.c,
8 *   rather than re-inventing the wheel.
9 *
10 *   Juergen Buchmueller, July 1998
11 *   Benjamin C. W. Sittler, July 1998 (new keyboard table)
12 *
13 *   Converted to a serial device (as far as MESS will allow)
14 *   by Robbbert, April 2009.
15 
16   NOTE: THIS IS A WIP, IT DOESN'T DO ANYTHING AT THIS TIME !!
17 *
18 ******************************************************************************/
19 
20#include "driver.h"
21#include "sound/beep.h"
22 
23 
24/*
25 * The KAYPRO keyboard has roughly the following layout:
26 *
27 *                                                                  [up] [down] [left] [right]
28 *         [ESC] [1!] [2@] [3#] [4$] [5%] [6^] [7&] [8*] [9(] [0)] [-_] [=+] [`~] [BACK SPACE]
29 *           [TAB] [qQ] [wW] [eE] [rR] [tT] [yY] [uU] [iI] [oO] [pP] [[{] []}]       [DEL]
30 *[CTRL] [CAPS LOCK] [aA] [sS] [dD] [fF] [gG] [hH] [jJ] [kK] [lL] [;:] ['"] [RETURN] [\|]
31 *            [SHIFT] [zZ] [xX] [cC] [vV] [bB] [nN] [mM] [,<] [.>] [/?] [SHIFT] [LINE FEED]
32 *                      [                 SPACE                     ]
33 *
34 * [7] [8] [9] [-]
35 * [4] [5] [6] [,]
36 * [1] [2] [3]
37 * [  0  ] [.] [ENTER]
38 *
39 * Notes on Appearance
40 * -------------------
41 * The RETURN key is shaped like a backwards "L". The keypad ENTER key is actually
42 * oriented vertically, not horizontally. The alpha keys are marked with the uppercase letters
43 * only. Other keys with two symbols have the shifted symbol printed above the unshifted symbol.
44 * The keypad is actually located to the right of the main keyboard; it is shown separately here
45 * as a convenience to users of narrow listing windows. The arrow keys are actually marked with
46 * arrow graphics pointing in the appropriate directions. The F and J keys are specially shaped,
47 * since they are the "home keys" for touch-typing. The CAPS LOCK key has a build-in red indicator
48 * which is lit when CAPS LOCK is pressed once, and extinguished when the key is pressed again.
49 *
50 * Technical Notes
51 * ---------------
52 * The keyboard interfaces to the computer using a serial protocol. Modifier keys are handled
53 * inside the keyboards, as is the CAPS LOCK key. The arrow keys and the numeric keypad send
54 * non-ASCII codes which are not affected by the modifier keys. The remaining keys send the
55 * appropriate ASCII values.
56 *
57 * The keyboard has a built-in buzzer which is activated briefly by a non-modifier keypress,
58 * producing a "clicking" sound for user feedback. Additionally, this buzzer can be activated
59 * for a longer period by sending a 0x04 byte to the keyboard. This is used by the ROM soft
60 * terminal to alert the user in case of a BEL.
61*
62 * 2008-05 FP:
63 * Small note about natural keyboard support: currently,
64 * - "Line Feed" is mapped to the 'End' key
65 * - "Keypad ," is not mapped
66 */
67 
68INPUT_PORTS_START( kay_kbd )
69   PORT_START("ROW0")
70   PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_ESC)         PORT_CHAR(UCHAR_MAMEKEY(ESC))
71   PORT_BIT(0x02, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_1)            PORT_CHAR('1') PORT_CHAR('!')
72   PORT_BIT(0x04, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_2)            PORT_CHAR('2') PORT_CHAR('@')
73   PORT_BIT(0x08, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_3)          PORT_CHAR('3') PORT_CHAR('#')
74   PORT_BIT(0x10, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_4)          PORT_CHAR('4') PORT_CHAR('$')
75   PORT_BIT(0x20, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_5)          PORT_CHAR('5') PORT_CHAR('%')
76   PORT_BIT(0x40, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_6)          PORT_CHAR('6') PORT_CHAR('^')
77   PORT_BIT(0x80, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_7)            PORT_CHAR('7') PORT_CHAR('&')
78 
79   PORT_START("ROW1")
80   PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_8)          PORT_CHAR('8') PORT_CHAR('*')
81   PORT_BIT(0x02, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_9)          PORT_CHAR('9') PORT_CHAR('(')
82   PORT_BIT(0x04, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_0)          PORT_CHAR('0') PORT_CHAR(')')
83   PORT_BIT(0x08, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS)          PORT_CHAR('-') PORT_CHAR('_')
84   PORT_BIT(0x10, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS)          PORT_CHAR('=') PORT_CHAR('+')
85   PORT_BIT(0x20, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE)          PORT_CHAR('`') PORT_CHAR('~')
86   PORT_BIT(0x40, 0x00, IPT_KEYBOARD) PORT_NAME("BACK SPACE")          PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)
87   PORT_BIT(0x80, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB)          PORT_CHAR('\t')
88 
89   PORT_START("ROW2")
90   PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q)          PORT_CHAR('q') PORT_CHAR('Q')
91   PORT_BIT(0x02, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_W)          PORT_CHAR('w') PORT_CHAR('W')
92   PORT_BIT(0x04, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_E)          PORT_CHAR('e') PORT_CHAR('E')
93   PORT_BIT(0x08, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_R)          PORT_CHAR('r') PORT_CHAR('R')
94   PORT_BIT(0x10, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_T)          PORT_CHAR('t') PORT_CHAR('T')
95   PORT_BIT(0x20, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y)          PORT_CHAR('y') PORT_CHAR('Y')
96   PORT_BIT(0x40, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_U)          PORT_CHAR('u') PORT_CHAR('U')
97   PORT_BIT(0x80, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_I)          PORT_CHAR('i') PORT_CHAR('I')
98 
99   PORT_START("ROW3")
100   PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_O)          PORT_CHAR('o') PORT_CHAR('O')
101   PORT_BIT(0x02, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_P)          PORT_CHAR('p') PORT_CHAR('P')
102   PORT_BIT(0x04, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE)         PORT_CHAR('[') PORT_CHAR('{')
103   PORT_BIT(0x08, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE)      PORT_CHAR(']') PORT_CHAR('}')
104   PORT_BIT(0x10, 0x00, IPT_KEYBOARD) PORT_NAME("RETURN")            PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
105   PORT_BIT(0x20, 0x00, IPT_KEYBOARD) PORT_NAME("DEL") PORT_CODE(KEYCODE_DEL)   PORT_CHAR(UCHAR_MAMEKEY(DEL)) 
106   PORT_BIT(0x40, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_LCONTROL)         PORT_CHAR(UCHAR_SHIFT_2)
107   PORT_BIT(0x80, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_CAPSLOCK)         PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK))
108 
109   PORT_START("ROW4")
110   PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_A)          PORT_CHAR('a') PORT_CHAR('A')
111   PORT_BIT(0x02, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_S)          PORT_CHAR('s') PORT_CHAR('S')
112   PORT_BIT(0x04, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_D)          PORT_CHAR('d') PORT_CHAR('D')
113   PORT_BIT(0x08, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_F)          PORT_CHAR('f') PORT_CHAR('F')
114   PORT_BIT(0x10, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_G)          PORT_CHAR('g') PORT_CHAR('G')
115   PORT_BIT(0x20, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_H)          PORT_CHAR('h') PORT_CHAR('H')
116   PORT_BIT(0x40, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_J)          PORT_CHAR('j') PORT_CHAR('J')
117   PORT_BIT(0x80, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_K)          PORT_CHAR('k') PORT_CHAR('K')
118 
119   PORT_START("ROW5")
120   PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_L)          PORT_CHAR('l') PORT_CHAR('L')
121   PORT_BIT(0x02, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON)         PORT_CHAR(';') PORT_CHAR(':')
122   PORT_BIT(0x04, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE)         PORT_CHAR('\'') PORT_CHAR('"')
123   PORT_BIT(0x08, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH)         PORT_CHAR('\\') PORT_CHAR('|')
124   PORT_BIT(0x10, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT)         PORT_CHAR(UCHAR_MAMEKEY(LSHIFT))
125   PORT_BIT(0x20, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z)          PORT_CHAR('z') PORT_CHAR('Z')
126   PORT_BIT(0x40, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_X)          PORT_CHAR('x') PORT_CHAR('X')
127   PORT_BIT(0x80, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_C)          PORT_CHAR('c') PORT_CHAR('C')
128 
129   PORT_START("ROW6")
130   PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_V)          PORT_CHAR('v') PORT_CHAR('V')
131   PORT_BIT(0x02, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_B)          PORT_CHAR('b') PORT_CHAR('B')
132   PORT_BIT(0x04, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_N)          PORT_CHAR('n') PORT_CHAR('N')
133   PORT_BIT(0x08, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_M)            PORT_CHAR('m') PORT_CHAR('M')
134   PORT_BIT(0x10, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA)         PORT_CHAR(',') PORT_CHAR('<')
135   PORT_BIT(0x20, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP)         PORT_CHAR('.') PORT_CHAR('>')
136   PORT_BIT(0x40, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH)         PORT_CHAR('/') PORT_CHAR('?')
137   PORT_BIT(0x80, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_RSHIFT)         PORT_CHAR(UCHAR_MAMEKEY(RSHIFT))
138 
139   PORT_START("ROW7")
140   PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_NAME("LINE FEED")         PORT_CODE(KEYCODE_END) PORT_CHAR(UCHAR_MAMEKEY(END))
141   PORT_BIT(0x02, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE)         PORT_CHAR(' ')
142   PORT_BIT(0x04, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS_PAD)          PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD))
143   PORT_BIT(0x08, 0x00, IPT_KEYBOARD) PORT_NAME("Keypad ,")         PORT_CODE(KEYCODE_PLUS_PAD)
144   PORT_BIT(0x10, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER_PAD)         PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD))
145   PORT_BIT(0x20, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL_PAD)          PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD))
146   PORT_BIT(0x40, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_0_PAD)          PORT_CHAR(UCHAR_MAMEKEY(0_PAD))
147   PORT_BIT(0x80, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_1_PAD)          PORT_CHAR(UCHAR_MAMEKEY(1_PAD))
148 
149   PORT_START("ROW8")
150   PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_2_PAD)          PORT_CHAR(UCHAR_MAMEKEY(2_PAD))
151   PORT_BIT(0x02, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_3_PAD)          PORT_CHAR(UCHAR_MAMEKEY(3_PAD))
152   PORT_BIT(0x04, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_4_PAD)          PORT_CHAR(UCHAR_MAMEKEY(4_PAD))
153   PORT_BIT(0x08, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_5_PAD)          PORT_CHAR(UCHAR_MAMEKEY(5_PAD))
154   PORT_BIT(0x10, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_6_PAD)          PORT_CHAR(UCHAR_MAMEKEY(6_PAD))
155   PORT_BIT(0x20, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_7_PAD)          PORT_CHAR(UCHAR_MAMEKEY(7_PAD))
156   PORT_BIT(0x40, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_8_PAD)          PORT_CHAR(UCHAR_MAMEKEY(8_PAD))
157   PORT_BIT(0x80, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_9_PAD)         PORT_CHAR(UCHAR_MAMEKEY(9_PAD))
158 
159   PORT_START("ROW9")
160   PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_NAME("\xE2\x86\x91")         PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
161   PORT_BIT(0x02, 0x00, IPT_KEYBOARD) PORT_NAME("\xE2\x86\x93")         PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
162   PORT_BIT(0x04, 0x00, IPT_KEYBOARD) PORT_NAME("\xE2\x86\x90")         PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
163   PORT_BIT(0x08, 0x00, IPT_KEYBOARD) PORT_NAME("\xE2\x86\x92")         PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
164   PORT_BIT(0xf0, 0x00, IPT_UNUSED)
165INPUT_PORTS_END
166 
167static const device_config *kay_kbd_beeper;
168//static UINT8 kbd_buff[16];
169//static int kbd_head = 0;
170//static int kbd_tail = 0;
171static UINT8 keyrows[10] = { 0,0,0,0,0,0,0,0,0,0 };
172static const char keyboard[8][10][8] = {
173   { /* normal */
174      { 27,'1','2','3','4','5','6','7'},
175      {'8','9','0','-','=','`',  8,  9},
176      {'q','w','e','r','t','y','u','i'},
177      {'o','p','[',']', 13,127,  0,  0},
178      {'a','s','d','f','g','h','j','k'},
179      {'l',';', 39, 92,  0,'z','x','c'},
180      {'v','b','n','m',',','.','/',  0},
181      { 10, 32, 228, 211, 195, 178, 177, 192},
182      { 193, 194, 208, 209, 210, 225, 226, 227},
183      { 241, 242, 243, 244,  0,  0,  0,  0},
184   },
185   { /* Shift */
186      { 27,'!','@','#','$','%','^','&'},
187      {'*','(',')','_','+','~',  8,  9},
188      {'Q','W','E','R','T','Y','U','I'},
189      {'O','P','{','}', 13,127,  0,  0},
190      {'A','S','D','F','G','H','J','K'},
191      {'L',':','"','|',  0,'Z','X','C'},
192      {'V','B','N','M','<','>','?',  0},
193      { 10, 32, 228, 211, 195, 178, 177, 192},
194      { 193, 194, 208, 209, 210, 225, 226, 227},
195      { 241, 242, 243, 244,  0,  0,  0,  0},
196   },
197   { /* Control */
198      { 27,'1','2','3','4','5','6','7'},
199      {'8','9','0','-','=','`',  8,  9},
200      { 17, 23,  5, 18, 20, 25, 21,  9},
201      { 15, 16, 27, 29, 13,127,  0,  0},
202      {  1, 19,  4,  6,  7,  8, 10, 11},
203      { 12,';', 39, 28,  0, 26, 24,  3},
204      { 22,  2, 14, 13,',','.','/',  0},
205      { 10, 32, 228, 211, 195, 178, 177, 192},
206      { 193, 194, 208, 209, 210, 225, 226, 227},
207      { 241, 242, 243, 244,  0,  0,  0,  0},
208   },
209   { /* Shift+Control */
210      { 27,'!',  0,'#','$','%', 30,'&'},
211      {'*','(',')', 31,'+','~',  8,  9},
212      { 17, 23,  5, 18, 20, 25, 21,  9},
213      { 15, 16, 27, 29, 13,127,  0,  0},
214      {  1, 19,  4,  6,  7,  8, 10, 11},
215      { 12,':','"', 28,  0, 26, 24,  3},
216      { 22,  2, 14, 13,',','.','/',  0},
217      { 10, 32, 228, 211, 195, 178, 177, 192},
218      { 193, 194, 208, 209, 210, 225, 226, 227},
219      { 241, 242, 243, 244,  0,  0,  0,  0},
220   },
221   { /* CapsLock */
222      { 27,'1','2','3','4','5','6','7'},
223      {'8','9','0','-','=','`',  8,  9},
224      {'Q','W','E','R','T','Y','U','I'},
225      {'O','P','[',']', 13,127,  0,  0},
226      {'A','S','D','F','G','H','J','K'},
227      {'L',';', 39, 92,  0,'Z','X','C'},
228      {'V','B','N','M',',','.','/',  0},
229      { 10, 32, 228, 211, 195, 178, 177, 192},
230      { 193, 194, 208, 209, 210, 225, 226, 227},
231      { 241, 242, 243, 244,  0,  0,  0,  0},
232   },
233   { /* Shift+CapsLock */
234      { 27,'!','@','#','$','%','^','&'},
235      {'*','(',')','_','+','~',  8,  9},
236      {'Q','W','E','R','T','Y','U','I'},
237      {'O','P','{','}', 13,127,  0,  0},
238      {'A','S','D','F','G','H','J','K'},
239      {'L',':','"','|',  0,'Z','X','C'},
240      {'V','B','N','M','<','>','?',  0},
241      { 10, 32, 228, 211, 195, 178, 177, 192},
242      { 193, 194, 208, 209, 210, 225, 226, 227},
243      { 241, 242, 243, 244,  0,  0,  0,  0},
244   },
245   { /* Control+CapsLock */
246      { 27,'1','2','3','4','5','6','7'},
247      {'8','9','0','-','=','`',  8,  9},
248      { 17, 23,  5, 18, 20, 25, 21,  9},
249      { 15, 16, 27, 29, 13,127,  0,  0},
250      {  1, 19,  4,  6,  7,  8, 10, 11},
251      { 12,';', 39, 28,  0, 26, 24,  3},
252      { 22,  2, 14, 13,',','.','/',  0},
253      { 10, 32, 228, 211, 195, 178, 177, 192},
254      { 193, 194, 208, 209, 210, 225, 226, 227},
255      { 241, 242, 243, 244,  0,  0,  0,  0},
256   },
257   { /* Shift+Control+CapsLock */
258      { 27,'!',  0,'#','$','%', 30,'&'},
259      {'*','(',')', 31,'+','~',  8,  9},
260      { 17, 23,  5, 18, 20, 25, 21,  9},
261      { 15, 16, 27, 29, 13,127,  0,  0},
262      {  1, 19,  4,  6,  7,  8, 10, 11},
263      { 12,':','"', 28,  0, 26, 24,  3},
264      { 22,  2, 14, 13,',','.','/',  0},
265      { 10, 32, 228, 211, 195, 178, 177, 192},
266      { 193, 194, 208, 209, 210, 225, 226, 227},
267      { 241, 242, 243, 244,  0,  0,  0,  0},
268   },
269};
270 
271MACHINE_RESET( kay_kbd )
272{
273   /* disable CapsLock LED initially */
274   set_led_status(1, 1);
275   set_led_status(1, 0);
276   kay_kbd_beeper = devtag_get_device(machine, "beep");
277}
278 
279/******************************************************
280 * vertical blank interrupt
281 * used to scan keyboard; newly pressed keys
282 * are stuffed into a keyboard buffer;
283 * also drives keyboard LEDs and
284 * and handles autorepeating keys
285 ******************************************************/
286INTERRUPT_GEN( kay_kbd_interrupt )
287{
288//   const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
289   int mod, row, col, chg, new;
290   static int lastrow = 0, mask = 0x00, key = 0x00, repeat = 0, repeater = 0;
291 
292   if( repeat )
293   {
294      if( !--repeat )
295         repeater = 4;
296   }
297   else
298   if( repeater )
299   {
300      repeat = repeater;
301   }
302 
303   row = 9;
304   new = input_port_read(device->machine, "ROW9");
305   chg = keyrows[row] ^ new;
306 
307   if (!chg) { new = input_port_read(device->machine, "ROW8"); chg = keyrows[--row] ^ new; }
308   if (!chg) { new = input_port_read(device->machine, "ROW7"); chg = keyrows[--row] ^ new; }
309   if (!chg) { new = input_port_read(device->machine, "ROW6"); chg = keyrows[--row] ^ new; }
310   if (!chg) { new = input_port_read(device->machine, "ROW5"); chg = keyrows[--row] ^ new; }
311   if (!chg) { new = input_port_read(device->machine, "ROW4"); chg = keyrows[--row] ^ new; }
312   if (!chg) { new = input_port_read(device->machine, "ROW3"); chg = keyrows[--row] ^ new; }
313   if (!chg) { new = input_port_read(device->machine, "ROW2"); chg = keyrows[--row] ^ new; }
314   if (!chg) { new = input_port_read(device->machine, "ROW1"); chg = keyrows[--row] ^ new; }
315   if (!chg) { new = input_port_read(device->machine, "ROW0"); chg = keyrows[--row] ^ new; }
316   if (!chg) --row;
317 
318   if (row >= 0)
319   {
320      repeater = 0x00;
321      mask = 0x00;
322      key = 0x00;
323      lastrow = row;
324      /* CapsLock LED */
325      if( row == 3 && chg == 0x80 )
326         set_led_status(1, (keyrows[3] & 0x80) ? 0 : 1);
327 
328      if (new & chg)   /* key(s) pressed ? */
329      {
330         mod = 0;
331 
332         /* Shift modifier */
333         if ( (keyrows[5] & 0x10) || (keyrows[6] & 0x80) )
334            mod |= 1;
335 
336         /* Control modifier */
337         if (keyrows[3] & 0x40)
338            mod |= 2;
339 
340         /* CapsLock modifier */
341         if (keyrows[3] & 0x80)
342            mod |= 4;
343 
344         /* find new key */
345         mask = 0x01;
346         for (col = 0; col < 8; col ++)
347         {
348            if (chg & mask)
349            {
350               new &= mask;
351               key = keyboard[mod][row][col];
352               break;
353            }
354            mask <<= 1;
355         }
356         if( key )   /* normal key */
357         {
358            repeater = 30;
359   //         kaypro_conin_w(space, 0, key);
360         }
361         else
362         if( (row == 0) && (chg == 0x04) ) /* Ctrl-@ (NUL) */
363   //         kaypro_conin_w(space, 0, 0);
364         keyrows[row] |= new;
365      }
366      else
367      {
368         keyrows[row] = new;
369      }
370      repeat = repeater;
371   }
372   else if ( key && (keyrows[lastrow] & mask) && repeat == 0 )
373   {
374   //   kaypro_conin_w(space, 0, key);
375   }
376}
377#if 0
378/******************************************************
379 * kaypro_const_r (read console status)
380 * 00  no key available
381 * ff  key(s) available
382 ******************************************************/
383static READ8_HANDLER (kaypro2_const_r )
384{
385   int data = 0x00;
386   if( kbd_head != kbd_tail )
387      data = 0xff;
388   return data;
389}
390 
391/******************************************************
392 *   kaypro_const_w (write console status ;)
393 *   bit
394 *   0   flush keyboard buffer
395 ******************************************************/
396static WRITE8_HANDLER ( kaypro2_const_w )
397{
398   if (data & 1)
399      kbd_head = kbd_tail = 0;
400}
401 
402/******************************************************
403 *   kaypro_conin_r (read console input, ie. keyboard)
404 *   returns next character from the keyboard buffer
405 *   suspends CPU if no key is available
406 ******************************************************/
407static READ8_HANDLER (kaypro2_conin_r )
408{
409   int data = 0;
410 
411   if (kbd_tail != kbd_head)
412   {
413      data = kbd_buff[kbd_tail];
414      kbd_tail = (kbd_tail + 1) % sizeof(kbd_buff);
415   }
416   return data;
417}
418 
419/******************************************************
420 *   kaypro_conin_w
421 *   stuff character into the keyboard buffer
422 *   releases CPU if it was waiting for a key
423 *   sounds bell if buffer would overflow
424 ******************************************************/
425static WRITE8_HANDLER ( kaypro2_conin_w )
426{
427   int kbd_head_old;
428 
429//   kaypro_click();
430 
431   kbd_head_old = kbd_head;
432   kbd_buff[kbd_head] = data;
433   kbd_head = (kbd_head + 1) % sizeof(kbd_buff);
434   /* will the buffer overflow ? */
435   if (kbd_head == kbd_tail)
436   {
437      kbd_head = kbd_head_old;
438//      kaypro_bell();
439   }
440}
441#endif
442 
443UINT8 kay_kbd_c_r( void )
444{
445/*   d4 transmit buffer empty - 1=ok to send
446   d0 keyboard buffer empty - 1=key waiting to be used */
447 
448   return 0x10;
449}
450 
451UINT8 kay_kbd_d_r( void )
452{
453/* return next key in buffer */
454 
455   return 0;
456}
457 
458void kay_kbd_d_w( UINT8 data )
459{
460/* Beeper control - not emulated yet.
461   01 - keyclick
462   02 - short beep
463   04 - standard bell beep
464   08 - mute
465   16 - unmute */
466 
467}
src/mess/machine/kay_kbd.h
r0r4501
1UINT8 kay_kbd_c_r( void );
2UINT8 kay_kbd_d_r( void );
3void kay_kbd_d_w( UINT8 data );
4INTERRUPT_GEN( kay_kbd_interrupt );
src/mess/mess.mak
r4500r4501
604604   $(MESS_VIDEO)/kaypro.o    \
605605   $(MESS_AUDIO)/kaypro.o    \
606606   $(MESS_MACHINE)/kaypro.o    \
607   $(MESS_MACHINE)/kay_kbd.o    \
607608
608609$(MESSOBJ)/sinclair.a: \
609610   $(MESS_VIDEO)/border.o      \
src/mess/drivers/kaypro2.c
r4500r4501
55   Each disk was single sided, and could hold 191k. The computer had 2x pio
66   and 1x sio. One of the sio ports communicated with the keyboard with a coiled
77   telephone cord, complete with modular plug on each end. The keyboard carries
8   its own processor and is an intelligent device.
8   its own Intel 8748 processor and is an intelligent device.
99 
1010   There are 2 major problems preventing this driver from working
1111 
r4500r4501
3333#include "machine/z80pio.h"
3434#include "machine/z80sio.h"
3535#include "machine/ctronics.h"
36#include "machine/kay_kbd.h"
3637#include "machine/wd17xx.h"
3738#include "devices/basicdsk.h"
38//#include "machine/beeper.h"
39#include "sound/beep.h"
3940 
4041 
4142static const device_config *kaypro2_z80pio_g;
4243static const device_config *kaypro2_z80pio_s;
4344static const device_config *kaypro2_z80sio;
44//static const device_config *kaypro2_beeper;
4545static const device_config *kaypro2_printer;
4646static const device_config *kaypro2_fdc;
4747 
48INPUT_PORTS_EXTERN( kay_kbd );
4849 
4950 
5051/***********************************************************
r4500r4501
8485 
8586         for (x = ma; x < ma + 80; x++)
8687         {
87            chr = videoram[x]^0x80;
88            if (ra < 8)
89            {
90               chr = videoram[x]^0x80;
8891 
89            /* Take care of flashing characters */
90            if ((chr < 0x80) && (framecnt & 0x08))
91               chr |= 0x80;
92               /* Take care of flashing characters */
93               if ((chr < 0x80) && (framecnt & 0x08))
94                  chr |= 0x80;
9295 
93            /* get pattern of pixels for that character scanline */
94            if (ra < 8) 
96               /* get pattern of pixels for that character scanline */
9597               gfx = FNT[(chr<<3) | ra ];
98            }
9699            else
97100               gfx = 0xff;
98101 
r4500r4501
234237      z80pio_c_w(device, 1, data);
235238}
236239 
240 
237241/***********************************************************
238242 
239243   SIO
r4500r4501
309313      return z80sio_d_r(device, 0);
310314   else
311315   if (offset == 1)
312      return z80sio_d_r(device, 1);
316//      return z80sio_d_r(device, 1);
317      return kay_kbd_d_r();
313318   else
314319   if (offset == 2)
315320      return z80sio_c_r(device, 0);
316321   else
317      return z80sio_c_r(device, 1);
322//      return z80sio_c_r(device, 1);
323      return kay_kbd_c_r();
318324}
319325       
320326static WRITE8_DEVICE_HANDLER( kaypro2_sio_w )
r4500r4501
323329      z80sio_d_w(device, 0, data);
324330   else
325331   if (offset == 1)
326      z80sio_d_w(device, 1, data);
332//      z80sio_d_w(device, 1, data);
333      kay_kbd_d_w(data);
327334   else
328335   if (offset == 2)
329336      z80sio_c_w(device, 0, data);
r4500r4501
380387   }
381388}
382389 
390 
383391/***********************************************************
384392 
385393   Address Maps
r4500r4501
406414   AM_RANGE(0x1c, 0x1f) AM_DEVREADWRITE("z80pio_s", kaypro2_pio_r, kaypro2_pio_w)
407415ADDRESS_MAP_END
408416 
409/***********************************************************
410417 
411   Keyboard Layout
412 
413************************************************************/
414 
415static INPUT_PORTS_START( kaypro2 )
416INPUT_PORTS_END
417 
418 
419418/***********************************************************
420419 
421420   Machine
r4500r4501
427426   kaypro2_z80pio_g = devtag_get_device(machine, "z80pio_g");
428427   kaypro2_z80pio_s = devtag_get_device(machine, "z80pio_s");
429428   kaypro2_z80sio = devtag_get_device(machine, "z80sio");
430//   kaypro2_beeper = devtag_get_device(machine, "beeper");
431429   kaypro2_printer = devtag_get_device(machine, "centronics");
432430   kaypro2_fdc = devtag_get_device(machine, "wd1793");
433431   pio_system_w(kaypro2_z80pio_s, 0, 0x80);
434432}
435433 
434 
436435/***********************************************************
437436 
438437   Machine Driver
r4500r4501
444443   MDRV_CPU_ADD("maincpu", Z80, 2500000)   /* 2.5 MHz */
445444   MDRV_CPU_PROGRAM_MAP(kaypro2_map, 0)
446445   MDRV_CPU_IO_MAP(kaypro2_io, 0)
446   MDRV_CPU_VBLANK_INT("screen", kay_kbd_interrupt)   /* this doesn't actually exist, it is to run the keyboard */
447447 
448448   MDRV_MACHINE_RESET( kaypro2 )
449449 
r4500r4501
460460   MDRV_VIDEO_UPDATE( kaypro2 )
461461 
462462   /* sound hardware */
463//   MDRV_SPEAKER_STANDARD_MONO("mono")
464//   MDRV_SOUND_ADD("beeper", BEEPER, 0)
465//   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
463   MDRV_SPEAKER_STANDARD_MONO("mono")
464   MDRV_SOUND_ADD("beep", BEEP, 0)
465   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
466466 
467467   /* devices */
468468   MDRV_WD179X_ADD("wd1793", kaypro2_wd1793_interface )
r4500r4501
472472   MDRV_Z80SIO_ADD( "z80sio", 4800, kaypro2_sio_intf )   /* start at 300 baud */
473473MACHINE_DRIVER_END
474474 
475 
475476/***********************************************************
476477 
477478   Game driver
r4500r4501
497498SYSTEM_CONFIG_END
498499 
499500/*    YEAR  NAME      PARENT  COMPAT  MACHINE     INPUT    INIT      CONFIG       COMPANY  FULLNAME */
500COMP( 1983, kaypro2,  0,      0,      kaypro2,    kaypro2, 0,        kaypro2,     "Non Linear Systems",  "Kaypro 2/83" , GAME_NOT_WORKING )
501COMP( 1983, kaypro2,  0,      0,      kaypro2,    kay_kbd, 0,        kaypro2,     "Non Linear Systems",  "Kaypro 2/83" , GAME_NOT_WORKING )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team