Previous 15994 Revisions Next

r6507 Wednesday 2nd December, 2009 at 21:08:38 UTC by Miodrag Milanović
Fixed terminal keyboard problems with multiple key press
[src/mess/machine]teleprinter.c terminal.c terminal.h

src/mess/machine/teleprinter.c
r6506r6507
1313   UINT8 buffer[TELEPRINTER_WIDTH*TELEPRINTER_HEIGHT];
1414   UINT8 x_pos;
1515   UINT8 last_code;
16   UINT8 scan_line;
1617   devcb_resolved_write8 teleprinter_keyboard_func;
1718};
1819
r6506r6507
242243static TIMER_CALLBACK(keyboard_callback)
243244{
244245   teleprinter_state *term = get_safe_token(ptr);
245   term->last_code = terminal_keyboard_handler(machine, &term->teleprinter_keyboard_func, term->last_code);
246   term->last_code = terminal_keyboard_handler(machine, &term->teleprinter_keyboard_func, term->last_code, &term->scan_line);
246247}
247248
248249/***************************************************************************
r6506r6507
299300   
300301   teleprinter_clear(device);
301302   term->last_code = 0;
303   term->scan_line = 0;
302304}
303305
304306/*-------------------------------------------------
src/mess/machine/terminal.c
r6506r6507
1313   UINT8 x_pos;
1414   UINT8 y_pos;
1515   UINT8 last_code;
16   UINT8 scan_line;
1617   devcb_resolved_write8 terminal_keyboard_func;
1718};
1819
r6506r6507
261262   return 0;
262263}
263264
264UINT8 terminal_keyboard_handler(running_machine *machine, devcb_resolved_write8 *callback, UINT8 last_code)
265UINT8 terminal_keyboard_handler(running_machine *machine, devcb_resolved_write8 *callback, UINT8 last_code, UINT8 *scan_line)
265266{
266267   static const char *const keynames[] = { "TERM_LINE0", "TERM_LINE1", "TERM_LINE2", "TERM_LINE3", "TERM_LINE4", "TERM_LINE5", "TERM_LINE6" };
267268   int i;
r6506r6507
271272   UINT8 shift = BIT(input_port_read(machine, "TERM_LINEC"),1);
272273   UINT8 caps  = BIT(input_port_read(machine, "TERM_LINEC"),2);
273274   UINT8 ctrl  = BIT(input_port_read(machine, "TERM_LINEC"),0);
274   for(i = 0; i < 7; i++)
275   i = *scan_line;
275276   {
276
277277      code =    input_port_read(machine, keynames[i]);
278278      if (code != 0)
279279      {
r6506r6507
347347         if (last_code != key_code ) {
348348            devcb_call_write8(callback, 0, key_code);
349349         }
350         retVal = key_code;         
350         retVal = key_code;
351      } else {
352         *scan_line += 1;
353         if (*scan_line==7) {
354            *scan_line = 0;
355         }
351356      }
352357   }
353358   return retVal;
r6506r6507
356361static TIMER_CALLBACK(keyboard_callback)
357362{
358363   terminal_state *term = get_safe_token(ptr);
359   term->last_code = terminal_keyboard_handler(machine, &term->terminal_keyboard_func, term->last_code);
364   term->last_code = terminal_keyboard_handler(machine, &term->terminal_keyboard_func, term->last_code, &term->scan_line);
360365}
361366
362367/***************************************************************************
r6506r6507
399404   const terminal_interface *intf = get_interface(device);
400405   
401406   devcb_resolve_write8(&term->terminal_keyboard_func, &intf->terminal_keyboard_func, device);   
402   timer_pulse(device->machine, ATTOTIME_IN_HZ(240), (void*)device, 0, keyboard_callback);
407   timer_pulse(device->machine, ATTOTIME_IN_HZ(2400), (void*)device, 0, keyboard_callback);
403408}
404409
405410/*-------------------------------------------------
r6506r6507
411416   terminal_state *term = get_safe_token(device);
412417   terminal_clear(device);
413418   term->last_code = 0;
419   term->scan_line = 0;
414420}
415421
416422/*-------------------------------------------------
src/mess/machine/terminal.h
r6506r6507
4444
4545INPUT_PORTS_EXTERN(generic_terminal);
4646
47UINT8 terminal_keyboard_handler(running_machine *machine, devcb_resolved_write8 *callback, UINT8 last_code);
47UINT8 terminal_keyboard_handler(running_machine *machine, devcb_resolved_write8 *callback, UINT8 last_code, UINT8 *scan_line);
4848
4949#endif /* __TERMINAL_H__ */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team