src/mess/machine/dai.c
| r4046 | r4047 | |
| 32 | 32 | static const device_config *dai_tms5501; |
| 33 | 33 | |
| 34 | 34 | |
| 35 | | static DIRECT_UPDATE_HANDLER(dai_opbaseoverride) |
| 36 | | { |
| 37 | | tms5501_set_pio_bit_7 (dai_tms5501, (input_port_read(space->machine, "IN8") & 0x04) ? 1:0); |
| 38 | | return address; |
| 39 | | } |
| 40 | | |
| 41 | 35 | /* Memory */ |
| 42 | 36 | |
| 43 | 37 | WRITE8_HANDLER( dai_stack_interrupt_circuit_w ) |
| r4046 | r4047 | |
| 139 | 133 | } |
| 140 | 134 | }; |
| 141 | 135 | |
| 136 | static TIMER_CALLBACK( dai_timer ) |
| 137 | { |
| 138 | tms5501_set_pio_bit_7 (dai_tms5501, (input_port_read(machine, "IN8") & 0x04) ? 1:0); |
| 139 | } |
| 140 | |
| 142 | 141 | MACHINE_START( dai ) |
| 143 | 142 | { |
| 144 | | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 143 | dai_tms5501 = device_list_find_by_tag( machine->config->devicelist, TMS5501, "tms5501" ); |
| 145 | 144 | |
| 146 | | memory_set_direct_update_handler(space, dai_opbaseoverride); |
| 147 | | |
| 148 | | memory_set_bankptr(machine, 1, mess_ram); |
| 149 | 145 | memory_configure_bank(machine, 2, 0, 4, memory_region(machine, "main") + 0x010000, 0x1000); |
| 146 | } |
| 150 | 147 | |
| 148 | MACHINE_RESET( dai ) |
| 149 | { |
| 150 | memory_set_bankptr(machine, 1, mess_ram); |
| 151 | 151 | timer_set(machine, attotime_zero, NULL, 0, dai_bootstrap_callback); |
| 152 | | |
| 153 | | dai_tms5501 = device_list_find_by_tag( machine->config->devicelist, TMS5501, "tms5501" ); |
| 152 | timer_pulse(machine, ATTOTIME_IN_HZ(100),NULL,0,dai_timer); /* timer for tms5501 */ |
| 154 | 153 | } |
| 155 | 154 | |
| 156 | 155 | /*************************************************************************** |
src/mess/machine/tms5501.c
| r4046 | r4047 | |
| 29 | 29 | |
| 30 | 30 | #define DEBUG_TMS5501 0 |
| 31 | 31 | |
| 32 | | #define LOG_TMS5501(device, message, data) do { if (DEBUG_TMS5501) logerror ("TMS5501 %s: %s %02x\n", device->tag, message, data); } while (0) |
| 32 | #define LOG_TMS5501(device, message, data) do { if (DEBUG_TMS5501) printf ("\nTMS5501 %s: %s %02x", device->tag, message, data); } while (0) |
| 33 | 33 | |
| 34 | 34 | /* status register */ |
| 35 | 35 | #define TMS5501_FRAME_ERROR 0x01 |
| r4046 | r4047 | |
| 114 | 114 | return (const tms5501_interface *) device->static_config; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | static const UINT8 timer_name[] = { TMS5501_TIMER_0_INT, TMS5501_TIMER_1_INT, TMS5501_TIMER_2_INT, TMS5501_TIMER_3_INT, TMS5501_TIMER_4_INT }; |
| 117 | 118 | |
| 118 | 119 | /*************************************************************************** |
| 119 | 120 | IMPLEMENTATION |
| r4046 | r4047 | |
| 165 | 166 | int level = find_first_bit(current_ints); |
| 166 | 167 | LOG_TMS5501(device, "Interrupt level", level); |
| 167 | 168 | |
| 168 | | /* reseting proper bit in pending interrupts register */ |
| 169 | /* resetting proper bit in pending interrupts register */ |
| 169 | 170 | tms->pending_interrupts &= ~(1<<level); |
| 170 | 171 | |
| 171 | 172 | /* selecting interrupt vector */ |
| r4046 | r4047 | |
| 200 | 201 | static void tms5501_timer_decrementer(const device_config *device, UINT8 mask) |
| 201 | 202 | { |
| 202 | 203 | tms5501_t *tms = get_token(device); |
| 203 | | tms->pending_interrupts |= mask; |
| 204 | |
| 205 | if ((mask != TMS5501_TIMER_4_INT) || ((mask == TMS5501_TIMER_4_INT) && (!(tms->command & TMS5501_INT_7_SELECT)))) |
| 206 | tms->pending_interrupts |= mask; |
| 207 | |
| 204 | 208 | tms5501_field_interrupts(device); |
| 205 | 209 | } |
| 206 | 210 | |
| r4046 | r4047 | |
| 229 | 233 | |
| 230 | 234 | if (tms->timer_counter[timer]) |
| 231 | 235 | { /* reset clock interval */ |
| 232 | | timer_adjust_periodic(tms->timer[timer], double_to_attotime((double) tms->timer_counter[0] / (intf->clock_rate / 128.)), timer, double_to_attotime((double) tms->timer_counter[timer] / (intf->clock_rate / 128.))); |
| 236 | timer_adjust_periodic(tms->timer[timer], double_to_attotime((double) tms->timer_counter[0] / (intf->clock_rate / 128.)), timer_name[timer], double_to_attotime((double) tms->timer_counter[timer] / (intf->clock_rate / 128.))); |
| 233 | 237 | } |
| 234 | 238 | else |
| 235 | 239 | { /* clock interval == 0 -> no timer */ |
| r4046 | r4047 | |
| 356 | 360 | const tms5501_interface *intf = get_interface(device); |
| 357 | 361 | |
| 358 | 362 | UINT8 data = 0x00; |
| 359 | | switch (offset&0x000f) |
| 363 | offset &= 0x0f; |
| 364 | |
| 365 | switch (offset) |
| 360 | 366 | { |
| 361 | 367 | case 0x00: /* Serial input buffer */ |
| 362 | 368 | data = tms->sio_input_buffer; |
| r4046 | r4047 | |
| 409 | 415 | { |
| 410 | 416 | tms5501_t *tms = get_token(device); |
| 411 | 417 | const tms5501_interface *intf = get_interface(device); |
| 418 | offset &= 0x0f; |
| 412 | 419 | |
| 413 | | switch (offset&0x000f) |
| 420 | switch (offset) |
| 414 | 421 | { |
| 415 | 422 | case 0x00: /* Serial input buffer */ |
| 416 | 423 | case 0x01: /* Keyboard input port, Page blanking signal */ |
| r4046 | r4047 | |
| 478 | 485 | case 0x0b: /* Timer 2 counter */ |
| 479 | 486 | case 0x0c: /* Timer 3 counter */ |
| 480 | 487 | case 0x0d: /* Timer 4 counter */ |
| 481 | | tms->timer_counter[(offset&0x0f)-0x09] = data; |
| 482 | | tms5501_timer_reload(device, (offset&0x0f)-0x09); |
| 483 | | LOG_TMS5501(device, "Write timer", (offset&0x0f)-0x09); |
| 488 | offset -= 9; |
| 489 | tms->timer_counter[offset] = data; |
| 490 | tms5501_timer_reload(device, offset); |
| 491 | LOG_TMS5501(device, "Write timer", offset); |
| 484 | 492 | LOG_TMS5501(device, "Timer counter set", data); |
| 485 | 493 | break; |
| 486 | 494 | } |