src/mess/machine/teleprinter.c
| r6506 | r6507 | |
| 13 | 13 | UINT8 buffer[TELEPRINTER_WIDTH*TELEPRINTER_HEIGHT]; |
| 14 | 14 | UINT8 x_pos; |
| 15 | 15 | UINT8 last_code; |
| 16 | UINT8 scan_line; |
| 16 | 17 | devcb_resolved_write8 teleprinter_keyboard_func; |
| 17 | 18 | }; |
| 18 | 19 | |
| r6506 | r6507 | |
| 242 | 243 | static TIMER_CALLBACK(keyboard_callback) |
| 243 | 244 | { |
| 244 | 245 | 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); |
| 246 | 247 | } |
| 247 | 248 | |
| 248 | 249 | /*************************************************************************** |
| r6506 | r6507 | |
| 299 | 300 | |
| 300 | 301 | teleprinter_clear(device); |
| 301 | 302 | term->last_code = 0; |
| 303 | term->scan_line = 0; |
| 302 | 304 | } |
| 303 | 305 | |
| 304 | 306 | /*------------------------------------------------- |
src/mess/machine/terminal.c
| r6506 | r6507 | |
| 13 | 13 | UINT8 x_pos; |
| 14 | 14 | UINT8 y_pos; |
| 15 | 15 | UINT8 last_code; |
| 16 | UINT8 scan_line; |
| 16 | 17 | devcb_resolved_write8 terminal_keyboard_func; |
| 17 | 18 | }; |
| 18 | 19 | |
| r6506 | r6507 | |
| 261 | 262 | return 0; |
| 262 | 263 | } |
| 263 | 264 | |
| 264 | | UINT8 terminal_keyboard_handler(running_machine *machine, devcb_resolved_write8 *callback, UINT8 last_code) |
| 265 | UINT8 terminal_keyboard_handler(running_machine *machine, devcb_resolved_write8 *callback, UINT8 last_code, UINT8 *scan_line) |
| 265 | 266 | { |
| 266 | 267 | static const char *const keynames[] = { "TERM_LINE0", "TERM_LINE1", "TERM_LINE2", "TERM_LINE3", "TERM_LINE4", "TERM_LINE5", "TERM_LINE6" }; |
| 267 | 268 | int i; |
| r6506 | r6507 | |
| 271 | 272 | UINT8 shift = BIT(input_port_read(machine, "TERM_LINEC"),1); |
| 272 | 273 | UINT8 caps = BIT(input_port_read(machine, "TERM_LINEC"),2); |
| 273 | 274 | UINT8 ctrl = BIT(input_port_read(machine, "TERM_LINEC"),0); |
| 274 | | for(i = 0; i < 7; i++) |
| 275 | i = *scan_line; |
| 275 | 276 | { |
| 276 | | |
| 277 | 277 | code = input_port_read(machine, keynames[i]); |
| 278 | 278 | if (code != 0) |
| 279 | 279 | { |
| r6506 | r6507 | |
| 347 | 347 | if (last_code != key_code ) { |
| 348 | 348 | devcb_call_write8(callback, 0, key_code); |
| 349 | 349 | } |
| 350 | | retVal = key_code; |
| 350 | retVal = key_code; |
| 351 | } else { |
| 352 | *scan_line += 1; |
| 353 | if (*scan_line==7) { |
| 354 | *scan_line = 0; |
| 355 | } |
| 351 | 356 | } |
| 352 | 357 | } |
| 353 | 358 | return retVal; |
| r6506 | r6507 | |
| 356 | 361 | static TIMER_CALLBACK(keyboard_callback) |
| 357 | 362 | { |
| 358 | 363 | 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); |
| 360 | 365 | } |
| 361 | 366 | |
| 362 | 367 | /*************************************************************************** |
| r6506 | r6507 | |
| 399 | 404 | const terminal_interface *intf = get_interface(device); |
| 400 | 405 | |
| 401 | 406 | 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); |
| 403 | 408 | } |
| 404 | 409 | |
| 405 | 410 | /*------------------------------------------------- |
| r6506 | r6507 | |
| 411 | 416 | terminal_state *term = get_safe_token(device); |
| 412 | 417 | terminal_clear(device); |
| 413 | 418 | term->last_code = 0; |
| 419 | term->scan_line = 0; |
| 414 | 420 | } |
| 415 | 421 | |
| 416 | 422 | /*------------------------------------------------- |