Previous 15994 Revisions Next

r5711 Sunday 13th September, 2009 at 05:57:44 UTC by Jonathan Gevaryahu
[dectalk] beginnings of work on input scheme. split nvram and led memory map up using AM_READWRITE8 per R. Belmont's suggestion.
[src/mess/drivers]dectalk.c

src/mess/drivers/dectalk.c
r5710r5711
150150
151151/* Components */
152152
153static struct
154{
155UINT8 data[8]; // ? what is this for?
156UINT8 nvram_local[256]; // sram tempspace on the x2214
157UINT8 statusLED;
158// input fifo, between m68k and tms32010
159UINT16 infifo[32]; // technically eight 74LS224 4bit*16stage FIFO chips, arranged as a 32 stage, 16-bit wide fifo
160UINT8 infifo_tail_ptr;
161UINT8 infifo_head_ptr;
162// output fifo, between tms32010 and 10khz sample latch for dac
163UINT16 outfifo[16]; // technically three 74LS224 4bit*16stage FIFO chips, arranged as a 16 stage, 12-bit wide fifo
164UINT8 outfifo_tail_ptr;
165UINT8 outfifo_head_ptr;
166UINT8 infifo_semaphore; // latch for status of output fifo, d-latch 74ls74 @ E64 'lower half'
167UINT8 spc_error_latch; // latch for error status of speech dsp, d-latch 74ls74 @ E64 'upper half'
168UINT8 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!
169UINT8 m68k_tlcflags_latch; // latch for telephone interface stuff, d-latches 74ls74 @ E93 'upper half' and @ 103 'upper and lower halves'
170UINT8 simulate_outfifo_error; // simulate an error on the outfifo, which does something unusual to the dsp latches
171UINT8 tlc_tonedetect;
172UINT8 tlc_ringdetect;
173UINT8 tlc_dtmf; // dtmf holding reg
174UINT8 duart_inport; // low 4 bits of duart input
175UINT8 duart_outport; // most recent duart output
176} dectalk={ {0}};
177
153178/* Devices */
154179static void duart_irq_handler(const device_config *device, UINT8 vector)
155180{
r5710r5711
162187
163188static UINT8 duart_input(const device_config *device)
164189{
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);
169193    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
170194    hack_self_test = 1;
171195   return data;
r5710r5711
173197
174198static void duart_output(const device_config *device, UINT8 data)
175199{
176   // todo: handle the RTS (bit 0) and DTR (bit 2) bits
200   dectalk.duart_outport = data;
177201#ifdef SERIAL_TO_STDERR
178202   fprintf(stderr, "RTS: %01X, DTR: %01X\n", data&1, (data&4)>>2);
179203#endif
r5710r5711
194218   duart_output
195219};
196220
197static struct
198{
199UINT8 data[8]; // ? what is this for?
200UINT8 nvram_local[256]; // sram tempspace on the x2214
201UINT8 statusLED;
202// input fifo, between m68k and tms32010
203UINT16 infifo[32]; // technically eight 74LS224 4bit*16stage FIFO chips, arranged as a 32 stage, 16-bit wide fifo
204UINT8 infifo_tail_ptr;
205UINT8 infifo_head_ptr;
206// output fifo, between tms32010 and 10khz sample latch for dac
207UINT16 outfifo[16]; // technically three 74LS224 4bit*16stage FIFO chips, arranged as a 16 stage, 12-bit wide fifo
208UINT8 outfifo_tail_ptr;
209UINT8 outfifo_head_ptr;
210UINT8 infifo_semaphore; // latch for status of output fifo, d-latch 74ls74 @ E64 'lower half'
211UINT8 spc_error_latch; // latch for error status of speech dsp, d-latch 74ls74 @ E64 'upper half'
212UINT8 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!
213UINT8 m68k_tlcflags_latch; // latch for telephone interface stuff, d-latches 74ls74 @ E93 'upper half' and @ 103 'upper and lower halves'
214UINT8 simulate_outfifo_error; // simulate an error on the outfifo, which does something unusual to the dsp latches
215UINT8 tlc_tonedetect;
216UINT8 tlc_ringdetect;
217UINT8 tlc_dtmf; // dtmf holding reg
218} dectalk={ {0}};
219
220221#define SPC_INITIALIZE dectalk.m68k_spcflags_latch&0x1 // speech initialize flag
221222#define SPC_IRQ_ENABLED ((dectalk.m68k_spcflags_latch&0x40)>>6) // irq enable flag
222223
r5710r5711
309310   dectalk.tlc_tonedetect = 0; // TODO, needed for selftest pass
310311   dectalk.tlc_ringdetect = 0; // TODO
311312   dectalk.tlc_dtmf = 0; // TODO
313   dectalk.duart_inport = 0xF;
314   dectalk.duart_outport = 0;
312315}
313316
314317MACHINE_RESET( dectalk )
r5710r5711
318321}
319322
320323/* 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*/
323READ16_HANDLER( led_sw_nvr_read )
324READ8_HANDLER( nvram_read ) // read from x2212 nvram chip and possibly do recall
324325{
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.
339328#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;
341330#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);
347333   return data;
348334}
349335
350WRITE16_HANDLER( led_sw_nv_write )
336WRITE8_HANDLER( led_write )
351337{
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);
356340#ifdef VERBOSE
357      logerror("m68k: LED status: %02X\n", data&0xFF);
341   logerror("m68k: LED status: %02X\n", data&0xFF);
358342#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
346WRITE8_HANDLER( nvram_write ) // write to X2212 NVRAM chip and possibly do store
347{
363348#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);
365350#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);
370354}
371355
372356WRITE16_HANDLER( m68k_infifo_w ) // 68k write to the speech input fifo
r5710r5711
630614    ADDRESS_MAP_UNMAP_HIGH
631615    AM_RANGE(0x000000, 0x03ffff) AM_ROM AM_MIRROR(0x740000) /* ROM */
632616    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 */
634620    AM_RANGE(0x098000, 0x09801f) AM_DEVREADWRITE8( "duart68681", duart68681_r, duart68681_w, 0xff) AM_MIRROR(0x763FE0) /* DUART */
635621    AM_RANGE(0x09C000, 0x09C001) AM_READWRITE(m68k_spcflags_r, m68k_spcflags_w) AM_MIRROR(0x763FF8) /* SPC flags reg */
636622    AM_RANGE(0x09C002, 0x09C003) AM_WRITE(m68k_infifo_w) AM_MIRROR(0x763FF8) /* SPC fifo reg */
r5710r5711
687673#ifdef VERBOSE
688674   if (data!= 0x8000) logerror("sample output: %04X\n", data);
689675#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);
691677   dac_signed_data_16_w( speaker, data );
692678}
693679
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
682static 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
694689/* Driver init: stuff that needs setting up which isn't directly affected by reset */
695690DRIVER_INIT( dectalk )
696691{
697692   dectalk_clear_all_fifos(machine);
698693   dectalk.simulate_outfifo_error = 0;
699694   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);
700696}
701697
702698

Previous 15994 Revisions Next


© 1998-2018 The MESS Team