src/mess/drivers/dectalk.c
| r5710 | r5711 | |
| 150 | 150 | |
| 151 | 151 | /* Components */ |
| 152 | 152 | |
| 153 | static struct |
| 154 | { |
| 155 | UINT8 data[8]; // ? what is this for? |
| 156 | UINT8 nvram_local[256]; // sram tempspace on the x2214 |
| 157 | UINT8 statusLED; |
| 158 | // input fifo, between m68k and tms32010 |
| 159 | UINT16 infifo[32]; // technically eight 74LS224 4bit*16stage FIFO chips, arranged as a 32 stage, 16-bit wide fifo |
| 160 | UINT8 infifo_tail_ptr; |
| 161 | UINT8 infifo_head_ptr; |
| 162 | // output fifo, between tms32010 and 10khz sample latch for dac |
| 163 | UINT16 outfifo[16]; // technically three 74LS224 4bit*16stage FIFO chips, arranged as a 16 stage, 12-bit wide fifo |
| 164 | UINT8 outfifo_tail_ptr; |
| 165 | UINT8 outfifo_head_ptr; |
| 166 | UINT8 infifo_semaphore; // latch for status of output fifo, d-latch 74ls74 @ E64 'lower half' |
| 167 | UINT8 spc_error_latch; // latch for error status of speech dsp, d-latch 74ls74 @ E64 'upper half' |
| 168 | UINT8 m68k_spcflags_latch; // latch for initializing the speech dsp, d-latch 74ls74 @ E29 'lower half', AND latch for spc irq enable, d-latch 74ls74 @ E29 'upper half'; these are stored in bits 0 and 6 respectively, the rest of the bits stored here MUST be zeroed! |
| 169 | UINT8 m68k_tlcflags_latch; // latch for telephone interface stuff, d-latches 74ls74 @ E93 'upper half' and @ 103 'upper and lower halves' |
| 170 | UINT8 simulate_outfifo_error; // simulate an error on the outfifo, which does something unusual to the dsp latches |
| 171 | UINT8 tlc_tonedetect; |
| 172 | UINT8 tlc_ringdetect; |
| 173 | UINT8 tlc_dtmf; // dtmf holding reg |
| 174 | UINT8 duart_inport; // low 4 bits of duart input |
| 175 | UINT8 duart_outport; // most recent duart output |
| 176 | } dectalk={ {0}}; |
| 177 | |
| 153 | 178 | /* Devices */ |
| 154 | 179 | static void duart_irq_handler(const device_config *device, UINT8 vector) |
| 155 | 180 | { |
| r5710 | r5711 | |
| 162 | 187 | |
| 163 | 188 | static UINT8 duart_input(const device_config *device) |
| 164 | 189 | { |
| 165 | | UINT8 data = 0xFF; |
| 166 | | data &= 0x8F; // write me: handle bits 0, 2, 3 which are port a CTS, DSR and RLS(DCD?) respectively |
| 167 | | //data |= input_port_read(device->machine, "duart_in"); |
| 168 | | data |= (input_port_read(device->machine, "duart_in")&0x7f); |
| 190 | UINT8 data = 0; |
| 191 | data |= dectalk.duart_inport&0xF; |
| 192 | data |= (input_port_read(device->machine, "duart_in")&0xF0); |
| 169 | 193 | if ((hack_self_test == 1) && (input_port_read(device->machine, "hacks")&0x01)) data |= 0x10; // hack to prevent hang if selftest disable bit is kept low past the first read; i suppose the proper use of this bit was an incremental switch, or perhaps its expecting an interrupt later from serial in or tone in? added a dipswitch to disable the hack for testing |
| 170 | 194 | hack_self_test = 1; |
| 171 | 195 | return data; |
| r5710 | r5711 | |
| 173 | 197 | |
| 174 | 198 | static void duart_output(const device_config *device, UINT8 data) |
| 175 | 199 | { |
| 176 | | // todo: handle the RTS (bit 0) and DTR (bit 2) bits |
| 200 | dectalk.duart_outport = data; |
| 177 | 201 | #ifdef SERIAL_TO_STDERR |
| 178 | 202 | fprintf(stderr, "RTS: %01X, DTR: %01X\n", data&1, (data&4)>>2); |
| 179 | 203 | #endif |
| r5710 | r5711 | |
| 194 | 218 | duart_output |
| 195 | 219 | }; |
| 196 | 220 | |
| 197 | | static struct |
| 198 | | { |
| 199 | | UINT8 data[8]; // ? what is this for? |
| 200 | | UINT8 nvram_local[256]; // sram tempspace on the x2214 |
| 201 | | UINT8 statusLED; |
| 202 | | // input fifo, between m68k and tms32010 |
| 203 | | UINT16 infifo[32]; // technically eight 74LS224 4bit*16stage FIFO chips, arranged as a 32 stage, 16-bit wide fifo |
| 204 | | UINT8 infifo_tail_ptr; |
| 205 | | UINT8 infifo_head_ptr; |
| 206 | | // output fifo, between tms32010 and 10khz sample latch for dac |
| 207 | | UINT16 outfifo[16]; // technically three 74LS224 4bit*16stage FIFO chips, arranged as a 16 stage, 12-bit wide fifo |
| 208 | | UINT8 outfifo_tail_ptr; |
| 209 | | UINT8 outfifo_head_ptr; |
| 210 | | UINT8 infifo_semaphore; // latch for status of output fifo, d-latch 74ls74 @ E64 'lower half' |
| 211 | | UINT8 spc_error_latch; // latch for error status of speech dsp, d-latch 74ls74 @ E64 'upper half' |
| 212 | | UINT8 m68k_spcflags_latch; // latch for initializing the speech dsp, d-latch 74ls74 @ E29 'lower half', AND latch for spc irq enable, d-latch 74ls74 @ E29 'upper half'; these are stored in bits 0 and 6 respectively, the rest of the bits stored here MUST be zeroed! |
| 213 | | UINT8 m68k_tlcflags_latch; // latch for telephone interface stuff, d-latches 74ls74 @ E93 'upper half' and @ 103 'upper and lower halves' |
| 214 | | UINT8 simulate_outfifo_error; // simulate an error on the outfifo, which does something unusual to the dsp latches |
| 215 | | UINT8 tlc_tonedetect; |
| 216 | | UINT8 tlc_ringdetect; |
| 217 | | UINT8 tlc_dtmf; // dtmf holding reg |
| 218 | | } dectalk={ {0}}; |
| 219 | | |
| 220 | 221 | #define SPC_INITIALIZE dectalk.m68k_spcflags_latch&0x1 // speech initialize flag |
| 221 | 222 | #define SPC_IRQ_ENABLED ((dectalk.m68k_spcflags_latch&0x40)>>6) // irq enable flag |
| 222 | 223 | |
| r5710 | r5711 | |
| 309 | 310 | dectalk.tlc_tonedetect = 0; // TODO, needed for selftest pass |
| 310 | 311 | dectalk.tlc_ringdetect = 0; // TODO |
| 311 | 312 | dectalk.tlc_dtmf = 0; // TODO |
| 313 | dectalk.duart_inport = 0xF; |
| 314 | dectalk.duart_outport = 0; |
| 312 | 315 | } |
| 313 | 316 | |
| 314 | 317 | MACHINE_RESET( dectalk ) |
| r5710 | r5711 | |
| 318 | 321 | } |
| 319 | 322 | |
| 320 | 323 | /* Begin 68k i/o handlers */ |
| 321 | | /* x2212 nvram/sram chip and led array demunger due to interleaved addresses */ |
| 322 | | /* 0x400 long: anything at offset&0x1 = 0 is open bus read, write to leds; everything else is nvram*/ |
| 323 | | READ16_HANDLER( led_sw_nvr_read ) |
| 324 | READ8_HANDLER( nvram_read ) // read from x2212 nvram chip and possibly do recall |
| 324 | 325 | { |
| 325 | | UINT16 data = 0xFFFF; |
| 326 | | /* |
| 327 | | if (ACCESSING_BITS_0_7) // LEDS |
| 328 | | { |
| 329 | | return data; // should be open bus; reading the LEDs doesn't work so well |
| 330 | | } |
| 331 | | else if (ACCESSING_BITS_8_15) // X2212 NVRAM chip |
| 332 | | { |
| 333 | | data = dectalk.nvram_local[(offset>>1)&0xff]<<8; // TODO: should this be before or after a possible /RECALL? I'm guessing before. |
| 334 | | if (offset&0x200) // if a9 is set, do a /RECALL |
| 335 | | dectalk_x2212_recall(space->machine); |
| 336 | | } |
| 337 | | */ |
| 338 | | data = dectalk.nvram_local[offset&0xff]<<8; // TODO: should this be before or after a possible /RECALL? I'm guessing before. |
| 326 | UINT8 data = 0xFF; |
| 327 | data = dectalk.nvram_local[offset&0xff]; // TODO: should this be before or after a possible /RECALL? I'm guessing before. |
| 339 | 328 | #ifdef NVRAM_LOG |
| 340 | | logerror("m68k: nvram read at %08X: %02X\n", offset, (data&0xfF00)>>8); |
| 329 | logerror("m68k: nvram read at %08X: %02X\n", offset, data; |
| 341 | 330 | #endif |
| 342 | | if (ACCESSING_BITS_8_15) // X2212 NVRAM chip |
| 343 | | { |
| 344 | | if (offset&0x200) // if a9 is set, do a /RECALL |
| 345 | | dectalk_x2212_recall(space->machine); |
| 346 | | } |
| 331 | if (offset&0x200) // if a9 is set, do a /RECALL |
| 332 | dectalk_x2212_recall(space->machine); |
| 347 | 333 | return data; |
| 348 | 334 | } |
| 349 | 335 | |
| 350 | | WRITE16_HANDLER( led_sw_nv_write ) |
| 336 | WRITE8_HANDLER( led_write ) |
| 351 | 337 | { |
| 352 | | if (ACCESSING_BITS_0_7) // LEDS |
| 353 | | { |
| 354 | | dectalk.statusLED = data&0xFF; |
| 355 | | popmessage("LED status: %02X\n", data&0xFF); |
| 338 | dectalk.statusLED = data&0xFF; |
| 339 | popmessage("LED status: %02X\n", data&0xFF); |
| 356 | 340 | #ifdef VERBOSE |
| 357 | | logerror("m68k: LED status: %02X\n", data&0xFF); |
| 341 | logerror("m68k: LED status: %02X\n", data&0xFF); |
| 358 | 342 | #endif |
| 359 | | //popmessage("LED status: %x %x %x %x %x %x %x %x\n", data&0x80, data&0x40, data&0x20, data&0x10, data&0x8, data&0x4, data&0x2, data&0x1); |
| 360 | | } |
| 361 | | else if (ACCESSING_BITS_8_15) // X2212 NVRAM chip |
| 362 | | { |
| 343 | //popmessage("LED status: %x %x %x %x %x %x %x %x\n", data&0x80, data&0x40, data&0x20, data&0x10, data&0x8, data&0x4, data&0x2, data&0x1); |
| 344 | } |
| 345 | |
| 346 | WRITE8_HANDLER( nvram_write ) // write to X2212 NVRAM chip and possibly do store |
| 347 | { |
| 363 | 348 | #ifdef NVRAM_LOG |
| 364 | | logerror("m68k: nvram write at %08X: %02X\n", offset, (data&0xFf00)>>8); |
| 349 | logerror("m68k: nvram write at %08X: %02X\n", offset, data&0x0f); |
| 365 | 350 | #endif |
| 366 | | dectalk.nvram_local[offset&0xff] = (UINT8)((data&0xF00)>>8); // TODO: should this be before or after a possible /STORE? I'm guessing before. |
| 367 | | if (offset&0x200) // if a9 is set, do a /STORE |
| 368 | | dectalk_x2212_store(space->machine); |
| 369 | | } |
| 351 | dectalk.nvram_local[offset&0xff] = (UINT8)data&0x0f; // TODO: should this be before or after a possible /STORE? I'm guessing before. |
| 352 | if (offset&0x200) // if a9 is set, do a /STORE |
| 353 | dectalk_x2212_store(space->machine); |
| 370 | 354 | } |
| 371 | 355 | |
| 372 | 356 | WRITE16_HANDLER( m68k_infifo_w ) // 68k write to the speech input fifo |
| r5710 | r5711 | |
| 630 | 614 | ADDRESS_MAP_UNMAP_HIGH |
| 631 | 615 | AM_RANGE(0x000000, 0x03ffff) AM_ROM AM_MIRROR(0x740000) /* ROM */ |
| 632 | 616 | AM_RANGE(0x080000, 0x093fff) AM_RAM AM_MIRROR(0x760000) /* RAM */ |
| 633 | | AM_RANGE(0x094000, 0x0943ff) AM_READWRITE(led_sw_nvr_read, led_sw_nv_write) AM_MIRROR(0x763C00) /* LED array and Xicor X2212 NVRAM */ |
| 617 | //AM_RANGE(0x094000, 0x0943ff) AM_READWRITE(led_sw_nvr_read, led_sw_nv_write) AM_MIRROR(0x763C00) /* LED array and Xicor X2212 NVRAM */ |
| 618 | AM_RANGE(0x094000, 0x0943ff) AM_WRITE8(led_write, 0x00FF) AM_MIRROR(0x763C00) /* LED array */ |
| 619 | AM_RANGE(0x094000, 0x0943ff) AM_READWRITE8(nvram_read, nvram_write, 0xFF00) AM_MIRROR(0x763C00) /* Xicor X2212 NVRAM */ |
| 634 | 620 | AM_RANGE(0x098000, 0x09801f) AM_DEVREADWRITE8( "duart68681", duart68681_r, duart68681_w, 0xff) AM_MIRROR(0x763FE0) /* DUART */ |
| 635 | 621 | AM_RANGE(0x09C000, 0x09C001) AM_READWRITE(m68k_spcflags_r, m68k_spcflags_w) AM_MIRROR(0x763FF8) /* SPC flags reg */ |
| 636 | 622 | AM_RANGE(0x09C002, 0x09C003) AM_WRITE(m68k_infifo_w) AM_MIRROR(0x763FF8) /* SPC fifo reg */ |
| r5710 | r5711 | |
| 687 | 673 | #ifdef VERBOSE |
| 688 | 674 | if (data!= 0x8000) logerror("sample output: %04X\n", data); |
| 689 | 675 | #endif |
| 690 | | timer_set(machine, ATTOTIME_IN_HZ(10000), NULL, 0, outfifo_read_cb); |
| 676 | timer_set(machine, ATTOTIME_IN_HZ(10000), NULL, 0, outfifo_read_cb); |
| 691 | 677 | dac_signed_data_16_w( speaker, data ); |
| 692 | 678 | } |
| 693 | 679 | |
| 680 | // the following function reads the keyboard and sends to the duart to allow for user input; it doesn't 'exist' on the real unit |
| 681 | // it more or less simulates a half duplex input terminal |
| 682 | static TIMER_CALLBACK( simulate_input_cb ) |
| 683 | { |
| 684 | // todo: check RTS line |
| 685 | |
| 686 | timer_set(machine, ATTOTIME_IN_HZ(120), NULL, 0, simulate_input_cb); |
| 687 | } |
| 688 | |
| 694 | 689 | /* Driver init: stuff that needs setting up which isn't directly affected by reset */ |
| 695 | 690 | DRIVER_INIT( dectalk ) |
| 696 | 691 | { |
| 697 | 692 | dectalk_clear_all_fifos(machine); |
| 698 | 693 | dectalk.simulate_outfifo_error = 0; |
| 699 | 694 | timer_set(machine, ATTOTIME_IN_HZ(10000), NULL, 0, outfifo_read_cb); |
| 695 | timer_set(machine, ATTOTIME_IN_HZ(120), NULL, 0, simulate_input_cb); |
| 700 | 696 | } |
| 701 | 697 | |
| 702 | 698 | |