src/mess/machine/kb3600.c
| r5088 | r5089 | |
| 12 | 12 | TODO: |
| 13 | 13 | |
| 14 | 14 | - more accurate emulation of real chip |
| 15 | | - any key down |
| 16 | 15 | |
| 17 | 16 | */ |
| 18 | 17 | |
| r5088 | r5089 | |
| 26 | 25 | typedef struct _ay3600_t ay3600_t; |
| 27 | 26 | struct _ay3600_t |
| 28 | 27 | { |
| 29 | | devcb_resolved_write_line out_data_ready_func; |
| 30 | | |
| 31 | 28 | devcb_resolved_read_line in_shift_func; |
| 32 | 29 | devcb_resolved_read_line in_control_func; |
| 33 | 30 | |
| 31 | devcb_resolved_write_line out_data_ready_func; |
| 32 | devcb_resolved_write_line out_ako_func; |
| 33 | |
| 34 | 34 | int b; /* output buffer */ |
| 35 | int ako; /* any key down */ |
| 35 | 36 | |
| 36 | 37 | /* timers */ |
| 37 | 38 | emu_timer *scan_timer; /* keyboard scan timer */ |
| r5088 | r5089 | |
| 71 | 72 | const ay3600_interface *intf = get_interface(device); |
| 72 | 73 | |
| 73 | 74 | int x, y; |
| 74 | | int akd = 0; |
| 75 | int ako = 0; |
| 75 | 76 | |
| 76 | 77 | for (x = 0; x < 9; x++) |
| 77 | 78 | { |
| r5088 | r5089 | |
| 83 | 84 | { |
| 84 | 85 | int b = (x * 10) + y; |
| 85 | 86 | |
| 86 | | akd = 1; |
| 87 | ako = 1; |
| 87 | 88 | |
| 88 | 89 | if (b > 63) |
| 89 | 90 | { |
| r5088 | r5089 | |
| 105 | 106 | } |
| 106 | 107 | } |
| 107 | 108 | |
| 108 | | if (!akd) |
| 109 | if (!ako) |
| 109 | 110 | { |
| 110 | 111 | ay3600->b = -1; |
| 111 | 112 | } |
| 113 | |
| 114 | if (ako != ay3600->ako) |
| 115 | { |
| 116 | devcb_call_write_line(&ay3600->out_ako_func, ako); |
| 117 | ay3600->ako = ako; |
| 118 | } |
| 112 | 119 | } |
| 113 | 120 | |
| 114 | 121 | /*------------------------------------------------- |
| r5088 | r5089 | |
| 136 | 143 | const ay3600_interface *intf = get_interface(device); |
| 137 | 144 | |
| 138 | 145 | /* resolve callbacks */ |
| 139 | | devcb_resolve_write_line(&ay3600->out_data_ready_func, &intf->out_data_ready_func, device); |
| 140 | 146 | devcb_resolve_read_line(&ay3600->in_shift_func, &intf->in_shift_func, device); |
| 141 | 147 | devcb_resolve_read_line(&ay3600->in_control_func, &intf->in_control_func, device); |
| 148 | devcb_resolve_write_line(&ay3600->out_data_ready_func, &intf->out_data_ready_func, device); |
| 149 | devcb_resolve_write_line(&ay3600->out_ako_func, &intf->out_ako_func, device); |
| 142 | 150 | |
| 143 | 151 | /* create the timers */ |
| 144 | 152 | ay3600->scan_timer = timer_alloc(device->machine, ay3600_scan_tick, (void *)device); |
| r5088 | r5089 | |
| 146 | 154 | |
| 147 | 155 | /* register for state saving */ |
| 148 | 156 | state_save_register_device_item(device, 0, ay3600->b); |
| 157 | state_save_register_device_item(device, 0, ay3600->ako); |
| 149 | 158 | } |
| 150 | 159 | |
| 151 | 160 | /*------------------------------------------------- |