Previous 15994 Revisions Next

r12424 Sunday 31st July, 2011 at 20:07:11 UTC by Michael Zapf
Geneve: Corrected wait states; RS232: Changed mapping of signal lines
[src/mess/drivers]geneve.c
[src/mess/machine]tms9902.c
[src/mess/machine/ti99]genboard.c ti_rs232.c

src/mess/machine/ti99/genboard.c
r12423r12424
136136   int    keyAutoRepeatTimer;
137137
138138   /* Mode flags */
139   int      palvideo;
140   int      capslock;
141   int      keyboard_clock;
142   int      keep_keybuf;
143   int      zero_wait;
139   bool   palvideo;
140   bool   capslock;
141   bool   keyboard_clock;
142   bool   keep_keybuf;
143   bool   zero_wait;
144144
145   int      genmod;
146   int    turbo;
147   int      timode;
145   bool   genmod;
146   bool   turbo;
147   bool   timode;
148148
149149   /* GROM simulation */
150150   int      grom_address;
151   int      gromraddr_LSB;
152   int      gromwaddr_LSB;
151   bool   gromraddr_LSB;
152   bool   gromwaddr_LSB;
153153
154154   /* Memory */
155155   UINT8   *sram;
r12423r12424
158158   int      sram_mask, sram_val;
159159
160160   /* Mapper */
161   int    geneve_mode;
162   int      direct_mode;
163   int      cartridge_size_8K;
164   int      cartridge_secondpage;
165   int      cartridge6_writable;
166   int      cartridge7_writable;
161   bool   geneve_mode;
162   bool   direct_mode;
163   bool   cartridge_size_8K;
164   bool   cartridge_secondpage;
165   bool   cartridge6_writable;
166   bool   cartridge7_writable;
167167   int      map[8];
168168
169169   int      line_count;
r12423r12424
171171   /* Devices */
172172   device_t   *cpu;
173173   device_t   *video;
174   device_t  *tms9901;
174   device_t   *tms9901;
175175   device_t   *clock;
176176   device_t   *peribox;
177177   device_t   *sound;
r12423r12424
244244   {
245245      // Turbo switch. May be changed at any time.
246246      logerror("Genmod: Setting turbo flag to %d\n", value);
247      ((genboard_state*)board)->turbo = value;
247      ((genboard_state*)board)->turbo = (value!=0);
248248   }
249249   else
250250   {
251251      // TIMode switch. Causes reset when changed.
252252      logerror("Genmod: Setting timode flag to %d\n", value);
253      ((genboard_state*)board)->timode = value;
253      ((genboard_state*)board)->timode = (value!=0);
254254      board->machine().schedule_hard_reset();
255255   }
256256}
r12423r12424
271271   if (offset & 0x0002)
272272   {
273273      // GROM address handling
274      board->gromwaddr_LSB = FALSE;
274      board->gromwaddr_LSB = false;
275275
276276      if (board->gromraddr_LSB)
277277      {
278278         reply = board->grom_address & 0xff;
279         board->gromraddr_LSB = FALSE;
279         board->gromraddr_LSB = false;
280280      }
281281      else
282282      {
283283         reply = (board->grom_address >> 8) & 0xff;
284         board->gromraddr_LSB = TRUE;
284         board->gromraddr_LSB = true;
285285      }
286286   }
287287   else
r12423r12424
291291      int page = 0x38;
292292      reply = board->dram[page*0x2000 + board->grom_address];
293293      board->grom_address = (board->grom_address + 1) & 0xffff;
294      board->gromraddr_LSB = board->gromwaddr_LSB = FALSE;
294      board->gromraddr_LSB = board->gromwaddr_LSB = false;
295295   }
296296   return reply;
297297}
r12423r12424
306306   if (offset & 0x0002)
307307   {
308308      // set address
309      board->gromraddr_LSB = FALSE;
309      board->gromraddr_LSB = false;
310310      if (board->gromwaddr_LSB)
311311      {
312312         board->grom_address = (board->grom_address & 0xff00) | data;
313313         board->grom_address = (board->grom_address + 1) & 0xffff;
314         board->gromwaddr_LSB = FALSE;
314         board->gromwaddr_LSB = false;
315315      }
316316      else
317317      {
318318         board->grom_address = (board->grom_address & 0x00ff) | ((UINT16)data<<8);
319         board->gromwaddr_LSB = TRUE;
319         board->gromwaddr_LSB = true;
320320      }
321321   }
322322   else
323323   {   // write GPL data
324324      // TODO: Check whether available in the real hardware.
325325      board->grom_address = (board->grom_address + 1) & 0xffff;
326      board->gromraddr_LSB = board->gromwaddr_LSB = FALSE;
326      board->gromraddr_LSB = board->gromwaddr_LSB = false;
327327      logerror("Geneve: GROM write ignored\n");
328328   }
329329}
r12423r12424
356356   // Premature access. The CPU reads the start vector before RESET.
357357   if (board->peribox==NULL) return 0;
358358
359   // Add two wait states (checked with a real Geneve)
359360   if (!board->zero_wait)
360      device_adjust_icount(board->cpu, -4);
361      device_adjust_icount(board->cpu, -8);
361362
362363   UINT32   physaddr;
363364
r12423r12424
372373         // 1111 0001 0000 0010
373374         // 1111 0001 0000 1000
374375         // 1111 0001 0000 1010
376         device_adjust_icount(board->cpu, -4);
375377         gen_v9938_rz(board->video, offset, &value);
376378         return value;
377379      }
r12423r12424
419421         // video
420422         // ++++ ++-- ---- ---+
421423         // 1000 1000 0000 00x0
424         device_adjust_icount(board->cpu, -4);
422425         gen_v9938_rz(board->video, offset, &value);
423426         return value;
424427      }
r12423r12424
551554   if (board->peribox==NULL) return;
552555
553556   if (!board->zero_wait)
554      device_adjust_icount(board->cpu, -4);
557      device_adjust_icount(board->cpu, -8);
555558
556559   if (board->geneve_mode)
557560   {
r12423r12424
560563         // video
561564         // ++++ ++++ ++++ ---+
562565         // 1111 0001 0000 .cc0
566         device_adjust_icount(board->cpu, -4);
563567         gen_v9938_w(board->video, offset, data);
564568         return;
565569      }
r12423r12424
613617         // video
614618         // ++++ ++-- ---- ---+
615619         // 1000 1100 0000 00c0
620         device_adjust_icount(board->cpu, -4);
616621         gen_v9938_w(board->video, offset, data);
617622         return;
618623      }
r12423r12424
769774   genboard_state *board = get_safe_token(device);
770775
771776   int addroff = offset << 1;
772   int rising_edge = FALSE;
773   int falling_edge = FALSE;
777   bool rising_edge = false;
778   bool falling_edge = false;
774779
775   if ((addroff & 0x1fe0) == CRU_CONTROL_BASE)
780   if ((addroff & 0xffe0) == CRU_CONTROL_BASE)
776781   {
777782      int bit = (addroff & 0x0001e)>>1;
778783      switch (bit)
779784      {
780785      case 5:
781         board->palvideo = data;
786         board->palvideo = (data!=0);
782787         break;
783788      case 7:
784         board->capslock = data;
789         board->capslock = (data!=0);
785790         break;
786791      case 8:
787         rising_edge = (!board->keyboard_clock && data);
788         board->keyboard_clock = data;
792         rising_edge = (!board->keyboard_clock && (data!=0));
793         board->keyboard_clock = (data!=0);
789794         if (rising_edge)
790795            read_key_if_possible(board);
791796         break;
792797      case 9:
793         rising_edge = (!board->keep_keybuf && data);
794         falling_edge = (board->keep_keybuf && !data);
795         board->keep_keybuf = data;
798         rising_edge = (!board->keep_keybuf && (data!=0));
799         falling_edge = (board->keep_keybuf && (data==0));
800         board->keep_keybuf = (data!=0);
796801
797802         if (rising_edge)
798803            read_key_if_possible(board);
r12423r12424
812817         }
813818         break;
814819      case 10:
815         board->geneve_mode = data;
820         board->geneve_mode = (data!=0);
816821         break;
817822      case 11:
818         board->direct_mode = data;
823         board->direct_mode = (data!=0);
819824         break;
820825      case 12:
821         board->cartridge_size_8K = data;
826         board->cartridge_size_8K = (data!=0);
822827         break;
823828      case 13:
824         board->cartridge6_writable = data;
829         board->cartridge6_writable = (data!=0);
825830         break;
826831      case 14:
827         board->cartridge7_writable = data;
832         board->cartridge7_writable = (data!=0);
828833         break;
829834      case 15:
830         board->zero_wait = data;
835         board->zero_wait = (data!=0);
831836         break;
832837      default:
833838         logerror("geneve: set CRU address %04x=%02x ignored\n", addroff, data);
r12423r12424
12071212*/
12081213static WRITE8_DEVICE_HANDLER( W9901_PE_bus_reset )
12091214{
1215   logerror("genboard: PE bus reset request, ignoring.\n");
12101216}
12111217
12121218/*
r12423r12424
12141220*/
12151221static WRITE8_DEVICE_HANDLER( W9901_VDP_reset )
12161222{
1223   logerror("genboard: Video reset request, ignoring.\n");
12171224}
12181225
12191226/*
r12423r12424
12551262*/
12561263static WRITE8_DEVICE_HANDLER( W9901_ext_mem_wait_states )
12571264{
1265   logerror("genboard: external bus wait states set to %d, not implemented yet.\n", data);
12581266}
12591267
12601268/*
r12423r12424
12621270*/
12631271static WRITE8_DEVICE_HANDLER( W9901_VDP_wait_states )
12641272{
1273   logerror("genboard: vdp wait states set to %d, not implemented yet.\n", data);
12651274}
12661275
12671276/* tms9901 setup */
r12423r12424
13671376   assert(board->peribox && board->cpu);
13681377   assert(board->sound && board->clock);
13691378   assert(board->eprom);
1370   board->geneve_mode = 0;
1371   board->direct_mode = 1;
1379   board->geneve_mode = false;
1380   board->direct_mode = true;
13721381
13731382   memset(board->sram, 0x00, SRAM_SIZE);
13741383   memset(board->dram, 0x00, DRAM_SIZE);
r12423r12424
14021411   board->last_my = 0;
14031412   board->line_count = 0;
14041413
1405   board->palvideo = 0;
1406   board->capslock = 0;
1407   board->keyboard_clock = 0;
1408   board->keep_keybuf = 0;
1409   board->zero_wait = 1;
1414   board->palvideo = false;
1415   board->capslock = false;
1416   board->keyboard_clock = false;
1417   board->keep_keybuf = false;
1418   board->zero_wait = true;
14101419
1411   board->geneve_mode = 0;
1412   board->direct_mode = 1;
1413   board->cartridge_size_8K = 0;
1414   board->cartridge_secondpage = 0;
1415   board->cartridge6_writable = 0;
1416   board->cartridge7_writable = 0;
1420   board->geneve_mode =false;
1421   board->direct_mode = true;
1422   board->cartridge_size_8K = false;
1423   board->cartridge_secondpage = false;
1424   board->cartridge6_writable = false;
1425   board->cartridge7_writable = false;
14171426   for (int i=0; i < 8; i++) board->map[i] = 0;
14181427
1419   board->genmod = FALSE;
1428   board->genmod = false;
14201429   if (input_port_read(device->machine(), "MODE")==0)
14211430   {
14221431      switch (input_port_read(device->machine(), "BOOTROM"))
r12423r12424
14391448      {
14401449         fatalerror("GenMod boot rom missing.\n");
14411450      }
1442      board->genmod = TRUE;
1443      board->turbo = input_port_read(device->machine(), "GENMODDIPS") & GM_TURBO;
1444      board->timode = input_port_read(device->machine(), "GENMODDIPS") & GM_TIM;
1451      board->genmod = true;
1452      board->turbo = ((input_port_read(device->machine(), "GENMODDIPS") & GM_TURBO)!=0);
1453      board->timode = ((input_port_read(device->machine(), "GENMODDIPS") & GM_TIM)!=0);
14451454   }
14461455
14471456   switch (input_port_read(device->machine(), "SRAM"))
src/mess/machine/ti99/ti_rs232.c
r12423r12424
11/*
22    TI-99 RS232 and Parallel interface card
33
4    TI99 RS232 card ('rs232')
5    TMS9902 ('rs232:tms9902_0')
6    TMS9902 ('rs232:tms9902_1')
7    TI99 RS232 attached serial device ('rs232:serdev0')
8    TI99 RS232 attached serial device ('rs232:serdev1')
9    TI99 PIO attached parallel device ('rs232:piodev')
10
411    Currently this emulation does not directly interact with the serial
5    interface on the host computer.
12    interface on the host computer. However, using a socket connection it is
13    possible to attach an external bridge which interacts with a real UART.
614
7    However, using a socket connection it is possible to attach an external
8    bridge which interacts with a real UART.
9
1015    This implementation can make use of such an external bridge. Normal data
1116    are forwarded to the bridge and back, while line control is organized via
1217    special byte sequences. These sequences are introduced by a 0x1B byte (ESC).
r12423r12424
1924    01ab cdef = setting line RTS=a, CTS=b, DSR=c, DCD=d, DTR=e, RI=f
2025    00gh i000 = exception g=BRK, h=FRMERR, i=PARERR
2126
22    TI99 RS232 card ('rs232')
23    TMS9902 ('rs232:tms9902_0')
24    TMS9902 ('rs232:tms9902_1')
25    TI99 RS232 attached serial device ('rs232:serdev0')
26    TI99 RS232 attached serial device ('rs232:serdev1')
27    TI99 PIO attached parallel device ('rs232:piodev')
28
2927    TI RS232 card wiring
3028    --------------------
3129    The card uses this wiring (inverters not included)
r12423r12424
4341     | CRU |--+
4442     +-----+
4543
46    Obviously we have a wiring which is typical for a DCE, not a DTE. The TI
47    RS232 was designed to look like a modem.
44    This wiring is typical for a DCE, not a DTE. The TI RS232 was obviously
45    designed to look like a modem. The advantage is that you can use the same
46    cables for connecting a modem to the RS232 interface or for connecting
47    a second TI via its interface. To connect to a DTE you can use a 1-1
48    wiring cable (1 on 1, 2 on 2 ...)
4849
49    The advantage is that you can use the same cables for connecting a modem
50    to the RS232 interface or for connecting a second TI via its interface. To
51    connect to a DTE you can use a 1-1 wiring cable (1 on 1, 2 on 2 ...)
52
5350    The TI manual for the RS232 card suggests the following cables:
5451
5552    TI RS232   -    Modem or other TI RS232
r12423r12424
7067    interface we have to map the TI wiring to a suitable wiring for PC
7168    interfaces which are designed as DTEs.
7269
73    From the signals used in the suggested cables we can conclude that we just
74    need to do the following conversion if we want a PC serial interface
75    to play the role of the TI RS232:
70    See the functions map_lines_in/out.
7671
77     Emulated      PC serial
78     TI RS232      interface
79       2 -----------( 3) --->
80       3 -----------( 2) <---
81       4 (nc) ------( 5) <---     (cable)
82       5 -----------( 4) --->
83       6 -----------(20) --->
84       8 ---| nc |--( 8) <---
85      20 -----------( 6) <---
72    However, due to the way the board is designed, a proper hardware
73    handshaking between a real TI and the TI emulation is impossible.
8674
87     Note that we now have to swap the cable types: Use a 1-1 cable to connect
88     another TI or a modem on the other end, and use a crossover cable for
89     another PC (the usual way of connecting).
75    Note that we now have to swap the cable types: Use a 1-1 cable to connect
76    another TI or a modem on the other end, and use a crossover cable for
77    another PC (the usual way of connecting).
9078*/
9179
9280#include "emu.h"
r12423r12424
10694
10795#define VERBOSE 1
10896
97#define LOG logerror
98
10999// Second card: Change CRU base to 0x1500
110100// #define CRU_BASE 0x1500
111101
r12423r12424
219209   }
220210   else
221211   {
222      logerror("ti99/rs232: Could not find device tag number\n");
212      LOG("ti99/rs232: Could not find device tag number\n");
223213      return IMAGE_INIT_FAIL;
224214   }
225215
r12423r12424
410400
411401      case 5:
412402         // Set the CTS line for RS232/1
403         LOG("TI-RS232/1: Setting CTS via CRU to %d\n", data);
413404         output_line_state(card->uart[0], CTS, (data)? CTS : 0);
414405         break;
415406
416407      case 6:
417408         // Set the CTS line for RS232/2
409         LOG("TI-RS232/2: Setting CTS via CRU to %d\n", data);
418410         output_line_state(card->uart[1], CTS, (data)? CTS : 0);
419411         break;
420412
r12423r12424
435427
436428   if (card->senila)
437429   {
438      if (VERBOSE>3) logerror("ti99/rs232: Sensing ILA\n");
430      if (VERBOSE>3) LOG("ti99/rs232: Sensing ILA\n");
439431      *value = card->ila;
440432      // The card ROM must be unselected, or we get two values
441433      // on the data bus
r12423r12424
503495   ti_rs232_state *card = get_safe_token(tms9902->owner());
504496   int uartind = (tms9902==card->uart[0])? 0 : 1;
505497
506   if (VERBOSE>2) logerror("TI-RS232/%d: incoming DTR = %d\n", uartind+1, (value==ASSERT_LINE)? 1:0);
498   if (VERBOSE>2) LOG("TI-RS232/%d: incoming DTR = %d\n", uartind+1, (value==ASSERT_LINE)? 1:0);
507499
508500   tms9902_rcv_cts(tms9902, value);
509501   tms9902_rcv_dsr(tms9902, value);
r12423r12424
522514   serial = dynamic_cast<device_image_interface *>(card->serdev[uartind]);
523515   if (!serial->exists())
524516   {
525      if (VERBOSE>1) logerror("TI-RS232/%d: No serial output attached\n", uartind+1);
517      if (VERBOSE>1) LOG("TI-RS232/%d: No serial output attached\n", uartind+1);
526518      return;
527519   }
528520
529521   // Send a double ESC if this is not a control operation
530522   if (buf==0x1b)
531523   {
532      if (VERBOSE>2) logerror("TI-RS232/%d: send ESC (requires another ESC)\n", uartind+1);
524      if (VERBOSE>2) LOG("TI-RS232/%d: send ESC (requires another ESC)\n", uartind+1);
533525      serial->fwrite(&buf, 1);
534526   }
535   if (VERBOSE>3) logerror("TI-RS232/%d: send %c <%02x>\n", uartind+1, buf, buf);
527   if (VERBOSE>3) LOG("TI-RS232/%d: send %c <%02x>\n", uartind+1, buf, buf);
536528   serial->fwrite(&buf, 1);
537529}
538530
539531/*
540532    Map the DCE-like wiring to a DTE-like wiring (and vice versa)
541    If suffices to swap RTS/CTS and DTR/DSR. We can use this function for
542    either direction; note that the RTS pin in the TI RS232 connector is not used.
533
534       Emulated      PC serial
535       TI RS232      interface
536     XOUT  2 -----------( 3) ---> TXD
537      RIN  3 -----------( 2) <--- RXD
538       nc  4 -----------( 5) <--- CTS  (cable)
539      CRU  5 -|       |-( 8) <--- DCD
540  DSR+CTS 20 -----------( 6) <--- DSR
541     +12V  6 -----------(20) ---> DTR
542      RTS  8 -----------( 4) ---> RTS
543543*/
544static UINT8 map_lines(int uartind, UINT8 value)
544static UINT8 map_lines_out(int uartind, UINT8 value)
545545{
546546   UINT8 ret = 0;
547547
548548   //    00ab cdef = setting line RTS=a, CTS=b, DSR=c, DCD=d, DTR=e, RI=f
549549
550   if (VERBOSE>3) logerror("TI-RS232/%d: connector pins = 0x%02x; translate for DTE\n", uartind+1, value);
550   if (VERBOSE>3) LOG("TI-RS232/%d: out connector pins = 0x%02x; translate for DTE\n", uartind+1, value);
551551
552552   if (value & CTS)
553553   {
554      if (VERBOSE>5) LOG("TI-RS232/%d: ... cannot map CTS line, ignoring\n", uartind+1);
555   }
556   if (value & DSR)
557   {
558      ret |= DTR;
559      if (VERBOSE>5) LOG("TI-RS232/%d: ... setting DTR line\n", uartind+1);
560   }
561   if (value & DCD)
562   {
554563      ret |= RTS;
555      if (VERBOSE>5) logerror("TI-RS232/%d: ... setting RTS line\n", uartind+1);
564      if (VERBOSE>5) LOG("TI-RS232/%d: ... setting RTS line\n", uartind+1);
556565   }
566   if (value & BRK)
567   {
568      if (VERBOSE>5) LOG("TI-RS232/%d: ... sending BRK\n", uartind+1);
569      ret |= EXCEPT | BRK;
570   }
571
572   return ret;
573}
574
575static UINT8 map_lines_in(int uartind, UINT8 value)
576{
577   UINT8 ret = 0;
578
579   //    00ab cdef = setting line RTS=a, CTS=b, DSR=c, DCD=d, DTR=e, RI=f
580
581   if (VERBOSE>3) LOG("TI-RS232/%d: in connector pins = 0x%02x; translate for DTE\n", uartind+1, value);
582
583   if (value & CTS)
584   {
585      if (VERBOSE>5) LOG("TI-RS232/%d: ... cannot map CTS line, ignoring\n", uartind+1);
586   }
557587   if (value & DSR)
558588   {
559589      ret |= DTR;
560      if (VERBOSE>5) logerror("TI-RS232/%d: ... setting DTR line\n", uartind+1);
590      if (VERBOSE>5) LOG("TI-RS232/%d: ... setting DTR line\n", uartind+1);
561591   }
562592   if (value & DCD)
563593   {
564      if (VERBOSE>5) logerror("TI-RS232/%d: ... cannot map DCD line, ignoring\n", uartind+1);
594      if (VERBOSE>5) LOG("TI-RS232/%d: ... cannot map DCD line, ignoring\n", uartind+1);
565595   }
566596   if (value & BRK)
567597   {
568      if (VERBOSE>5) logerror("TI-RS232/%d: ... sending BRK\n", uartind+1);
598      if (VERBOSE>5) LOG("TI-RS232/%d: ... sending BRK\n", uartind+1);
569599      ret |= EXCEPT | BRK;
570600   }
571601
572602   return ret;
573603}
574
575604/*
576605    Receive a character or a line state from the remote site. This method
577606    is called by a timer with some sufficiently high polling frequency. Note
r12423r12424
598627
599628   if (!serial->exists())
600629   {
601      if (VERBOSE>1) logerror("TI-RS232/%d: No serial input attached\n", uartind+1);
630      if (VERBOSE>1) LOG("TI-RS232/%d: No serial input attached\n", uartind+1);
602631      return;
603632   }
604633
r12423r12424
622651   case RECV_MODE_NORMAL:
623652      if (buffer==0x1b)
624653      {
625         if (VERBOSE>2) logerror("TI-RS232/%d: received: %c <%02x>, switch to ESC mode\n", uartind+1, buffer, buffer);
654         if (VERBOSE>2) LOG("TI-RS232/%d: received: %c <%02x>, switch to ESC mode\n", uartind+1, buffer, buffer);
626655         card->recv_mode[uartind] = RECV_MODE_ESC;
627656      }
628657      else
629658      {
630         if (VERBOSE>3) logerror("TI-RS232/%d: received: %c <%02x>, pass to UART\n", uartind+1, buffer, buffer);
659         if (VERBOSE>3) LOG("TI-RS232/%d: received: %c <%02x>, pass to UART\n", uartind+1, buffer, buffer);
631660         tms9902_rcv_data(tms9902, buffer);
632661         card->time_hold[uartind] = 0.0;
633662      }
r12423r12424
636665      if (buffer==0x1b)
637666      {
638667         card->recv_mode[uartind] = RECV_MODE_NORMAL;
639         if (VERBOSE>2) logerror("TI-RS232/%d: leaving ESC mode, received: %c <%02x>, pass to UART\n", uartind+1, buffer, buffer);
668         if (VERBOSE>2) LOG("TI-RS232/%d: leaving ESC mode, received: %c <%02x>, pass to UART\n", uartind+1, buffer, buffer);
640669         tms9902_rcv_data(tms9902, buffer);
641670         card->time_hold[uartind] = 0.0;
642671      }
643672      else
644673      {
645674         // the byte in buffer is the length byte
646         if (VERBOSE>3) logerror("TI-RS232/%d: received length byte <%02x> in ESC mode\n", uartind+1, buffer);
675         if (VERBOSE>3) LOG("TI-RS232/%d: received length byte <%02x> in ESC mode\n", uartind+1, buffer);
647676         if (buffer != 1)
648677         {
649            logerror("TI-RS232/%d: expected length 1 but got %02x, leaving ESC mode.\n", uartind+1, buffer);
678            LOG("TI-RS232/%d: expected length 1 but got %02x, leaving ESC mode.\n", uartind+1, buffer);
650679            card->recv_mode[uartind] = RECV_MODE_NORMAL;
651680         }
652681         else
r12423r12424
669698      }
670699      else
671700      {
672         buffer = map_lines(uartind, buffer);
673         if (VERBOSE>2) logerror("TI-RS232/%d: received (remapped) <%02x> in ESC mode\n", uartind+1, buffer);
701         buffer = map_lines_in(uartind, buffer);
702         if (VERBOSE>2) LOG("TI-RS232/%d: received (remapped) <%02x> in ESC mode\n", uartind+1, buffer);
674703
675704         // The DTR line on the RS232 connector of the board is wired to both the
676705         // CTS and the DSR pin of the TMS9902
r12423r12424
682711      break;
683712
684713   default:
685      logerror("TI-RS232/%d: unknown mode: %d\n", uartind+1, card->recv_mode[uartind]);
714      LOG("TI-RS232/%d: unknown mode: %d\n", uartind+1, card->recv_mode[uartind]);
686715   }
687716}
688717
r12423r12424
715744
716745   if (!serial->exists())
717746   {
718      if (VERBOSE>1) logerror("TI-RS232/%d: No serial output attached\n", uartind+1);
747      if (VERBOSE>1) LOG("TI-RS232/%d: No serial output attached\n", uartind+1);
719748      return;
720749   }
721750
r12423r12424
725754
726755   switch (type) {
727756   case RATERECV:
728      if (VERBOSE>2) logerror("TI-RS232/%d: send receive rate %04x\n", uartind+1, value);
757      if (VERBOSE>2) LOG("TI-RS232/%d: send receive rate %04x\n", uartind+1, value);
729758      // value has 12 bits
730759      // 1ccc xaaa                         = config adapter type a
731760      // 1111 xaaa rrrr rrrr rrrr 0000     = config receive rate on a
r12423r12424
736765      bufctrl[3] = (value & 0x0f)<<4;
737766      break;
738767   case RATEXMIT:
739      if (VERBOSE>2) logerror("TI-RS232/%d: send transmit rate %04x\n", uartind+1, value);
768      if (VERBOSE>2) LOG("TI-RS232/%d: send transmit rate %04x\n", uartind+1, value);
740769      bufctrl[0] = 0x03; // length
741770      bufctrl[1] |= RATEXMIT;
742771      bufctrl[2] = (value & 0x0ff0)>>4;
743772      bufctrl[3] = (value & 0x0f)<<4;
744773      break;
745774   case STOPBITS:
746      if (VERBOSE>2) logerror("TI-RS232/%d: send stop bit config %02x\n", uartind+1, value&0x03);
775      if (VERBOSE>2) LOG("TI-RS232/%d: send stop bit config %02x\n", uartind+1, value&0x03);
747776      bufctrl[1] |= STOPBITS;
748777      bufctrl[2] = (value & 0x03);
749778      break;
750779   case DATABITS:
751      if (VERBOSE>2) logerror("TI-RS232/%d: send data bit config %02x\n", uartind+1, value&0x03);
780      if (VERBOSE>2) LOG("TI-RS232/%d: send data bit config %02x\n", uartind+1, value&0x03);
752781      bufctrl[1] |= DATABITS;
753782      bufctrl[2] = (value & 0x03);
754783      break;
755784   case PARITY:
756      if (VERBOSE>2) logerror("TI-RS232/%d: send parity config %02x\n", uartind+1, value&0x03);
785      if (VERBOSE>2) LOG("TI-RS232/%d: send parity config %02x\n", uartind+1, value&0x03);
757786      bufctrl[1] |= PARITY;
758787      bufctrl[2] = (value & 0x03);
759788      break;
760789   default:
761      if (VERBOSE>1) logerror("TI-RS232/%d: error - unknown config type %02x\n", uartind+1, type);
790      if (VERBOSE>1) LOG("TI-RS232/%d: error - unknown config type %02x\n", uartind+1, type);
762791   }
763792
764793   serial->fwrite(bufctrl, bufctrl[0]+1);
r12423r12424
771800   {
772801      switch (line)
773802      {
774      case CTS: logerror("TI-RS232/%d: set CTS(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break;
775      case DCD: logerror("TI-RS232/%d: set DCD(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break;
776      case BRK: logerror("TI-RS232/%d: set BRK(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break;
803      case CTS: LOG("TI-RS232/%d: set CTS(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break;
804      case DCD: LOG("TI-RS232/%d: set DCD(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break;
805      case BRK: LOG("TI-RS232/%d: set BRK(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break;
777806      }
778807   }
779808
r12423r12424
799828
800829   if (!serial->exists())
801830   {
802      if (VERBOSE>1) logerror("TI-RS232/%d: No serial output attached\n", uartind+1);
831      if (VERBOSE>1) LOG("TI-RS232/%d: No serial output attached\n", uartind+1);
803832      return;
804833   }
805834
r12423r12424
828857
829858   if (!serial->exists())
830859   {
831      if (VERBOSE>1) logerror("TI-RS232/%d: No serial output attached\n", uartind+1);
860      if (VERBOSE>1) LOG("TI-RS232/%d: No serial output attached\n", uartind+1);
832861      return;
833862   }
834863
r12423r12424
852881   // Now translate the signals of the board to those of a DTE-like device
853882   // so that we can pass the signal to the real PC serial interface
854883   // (can be imagined as if we emulated the cable)
855   bufctrl[1] = map_lines(uartind, card->signals[uartind]);
884   bufctrl[1] = map_lines_out(uartind, card->signals[uartind]);
856885   serial->fwrite(bufctrl, 2);
857886}
858887
r12423r12424
874903{
875904   // put the value on the data bus. We store it in a state variable.
876905   ti_rs232_state *card = get_safe_token(device);
877   if (VERBOSE>3) logerror("TI-RS232/1-2: Setting SENILA=%d\n", state);
906   if (VERBOSE>3) LOG("TI-RS232/1-2: Setting SENILA=%d\n", state);
878907   card->senila = state;
879908}
880909
src/mess/machine/tms9902.c
r12423r12424
3939#include "tms9902.h"
4040
4141#define VERBOSE 1
42#define LOG logerror
4243
4344// Polling frequency. We use a much higher value to allow for line state changes
4445// happening between character transmissions (which happen in parallel in real
r12423r12424
180181                     || (tms9902->RBRL && tms9902->RIENB)
181182                     || (tms9902->XBRE && tms9902->XBIENB)
182183                     || (tms9902->TIMELP && tms9902->TIMENB);
183// if (VERBOSE>3) logerror("TMS9902: interrupt flags (DSCH = %02x, DSCENB = %02x), (RBRL = %02x, RIENB = %02x), (XBRE = %02x, XBIENB = %02x), (TIMELP = %02x, TIMENB = %02x)\n",
184// if (VERBOSE>3) LOG("TMS9902: interrupt flags (DSCH = %02x, DSCENB = %02x), (RBRL = %02x, RIENB = %02x), (XBRE = %02x, XBIENB = %02x), (TIMELP = %02x, TIMENB = %02x)\n",
184185//  tms9902->DSCH, tms9902->DSCENB, tms9902->RBRL, tms9902->RIENB, tms9902->XBRE, tms9902->XBIENB, tms9902->TIMELP, tms9902->TIMENB);
185186   if (new_int != tms9902->INT)
186187   {
187188      // Only consider edges
188189      tms9902->INT = new_int;
189      if (VERBOSE>3) logerror("TMS9902: /INT = %s\n", (tms9902->INT)? "asserted" : "cleared");
190      if (VERBOSE>3) LOG("TMS9902: /INT = %s\n", (tms9902->INT)? "asserted" : "cleared");
190191      if (tms9902->intf->int_callback)
191192         (*tms9902->intf->int_callback)(device, tms9902->INT? ASSERT_LINE : CLEAR_LINE);
192193   }
r12423r12424
204205   tms9902->CTSflag = (state==ASSERT_LINE)? 1:0;
205206   tms9902->DSCH = 1;
206207
207   if (VERBOSE>3) logerror("TMS9902: CTS* = %s\n", (state==ASSERT_LINE)? "asserted" : "cleared");
208   if (VERBOSE>3) LOG("TMS9902: CTS* = %s\n", (state==ASSERT_LINE)? "asserted" : "cleared");
208209
209210   if (tms9902->CTSflag != previous)
210211   {
r12423r12424
237238{
238239   tms9902_t *tms9902 = get_token(device);
239240   bool previous = tms9902->DSRflag;
240   if (VERBOSE>3) logerror("TMS9902: DSR* = %s\n", (state==ASSERT_LINE)? "asserted" : "cleared");
241   if (VERBOSE>3) LOG("TMS9902: DSR* = %s\n", (state==ASSERT_LINE)? "asserted" : "cleared");
241242   tms9902->DSRflag = (state==ASSERT_LINE)? true:false;
242243   tms9902->DSCH = 1;
243244
r12423r12424
267268   {
268269      // Receive buffer was empty
269270      tms9902->RBRL = 1;
270      if (VERBOSE>3) logerror("TMS9902: Receive buffer loaded with byte %02x\n", data);
271      if (VERBOSE>3) LOG("TMS9902: Receive buffer loaded with byte %02x\n", data);
271272      field_interrupts(device);
272273   }
273274   else
274275   {
275276      // Receive buffer was full
276277      tms9902->ROVER = 1;
277      if (VERBOSE>1) logerror("TMS9902: Receive buffer still loaded; overflow error\n");
278      if (VERBOSE>1) LOG("TMS9902: Receive buffer still loaded; overflow error\n");
278279   }
279280}
280281
r12423r12424
289290void tms9902_rcv_framing_error(device_t *device)
290291{
291292   tms9902_t *tms9902 = get_token(device);
292   if (VERBOSE>2) logerror("TMS9902: Detected framing error\n");
293   if (VERBOSE>2) LOG("TMS9902: Detected framing error\n");
293294   tms9902->RFER = 1;
294295}
295296
r12423r12424
302303void tms9902_rcv_parity_error(device_t *device)
303304{
304305   tms9902_t *tms9902 = get_token(device);
305   if (VERBOSE>2) logerror("TMS9902: Detected parity error\n");
306   if (VERBOSE>2) LOG("TMS9902: Detected parity error\n");
306307   tms9902->RPER = 1;
307308}
308309
r12423r12424
314315*/
315316void tms9902_rcv_break(device_t *device, bool value)
316317{
317   if (VERBOSE>2) logerror("TMS9902: Receive BREAK=%d (no effect)\n", value? 1:0);
318   if (VERBOSE>2) LOG("TMS9902: Receive BREAK=%d (no effect)\n", value? 1:0);
318319}
319320
320321//------------------------------------------------
r12423r12424
403404{
404405   tms9902_t *tms9902 = get_token(device);
405406   int value = (tms9902->CLK4M? 0x800 : 0) | (tms9902->RDV8? 0x400 : 0) | tms9902->RDR;
406   if (VERBOSE>3) logerror("receive rate = %04x\n", value);
407   if (VERBOSE>3) LOG("receive rate = %04x\n", value);
407408
408409   // Calculate the ratio between receive baud rate and polling frequency
409410   double fint = tms9902->clock_rate / ((tms9902->CLK4M) ? 4.0 : 3.0);
r12423r12424
414415   // Thus the callback function should add up this value on each poll
415416   // and deliver a data input not before it sums up to 1.
416417   tms9902->baudpoll = (double)(baud / (10*POLLING_FREQ));
417   if (VERBOSE>3) logerror ("baudpoll = %lf\n", tms9902->baudpoll);
418   if (VERBOSE>3) LOG ("baudpoll = %lf\n", tms9902->baudpoll);
418419
419420   if (tms9902->intf->ctrl_callback)
420421      (*tms9902->intf->ctrl_callback)(device, CONFIG, RATERECV, value);
r12423r12424
428429{
429430   tms9902_t *tms9902 = get_token(device);
430431   int value = (tms9902->CLK4M? 0x800 : 0) | (tms9902->XDV8? 0x400 : 0) | tms9902->XDR;
431   if (VERBOSE>3) logerror("transmit rate = %04x\n", value);
432   if (VERBOSE>3) LOG("transmit rate = %04x\n", value);
432433   if (tms9902->intf->ctrl_callback)
433434      (*tms9902->intf->ctrl_callback)(device, CONFIG, RATEXMIT, value);
434435}
r12423r12424
476477   if (lstate != tms9902->RTSflag)
477478   {
478479      // Signal RTS to the modem
479      if (VERBOSE>3) logerror("TMS9902: Set RTS=%d\n", lstate? 1:0);
480      if (VERBOSE>3) LOG("TMS9902: Set RTS=%d\n", lstate? 1:0);
480481      tms9902->RTSflag = lstate;
481482      transmit_line_state(device);
482483   }
r12423r12424
495496
496497   field_interrupts(device);
497498
498   if (VERBOSE>4) logerror("TMS9902: transmit XSR=%02x, RCL=%02x\n", tms9902->XSR, tms9902->RCL);
499   if (VERBOSE>4) LOG("TMS9902: transmit XSR=%02x, RCL=%02x\n", tms9902->XSR, tms9902->RCL);
499500
500501   if (tms9902->intf->xmit_callback)
501502      (*tms9902->intf->xmit_callback)(device, tms9902->XSR & (0xff >> (3-tms9902->RCL)));
r12423r12424
574575
575576   case 0:
576577      answer = tms9902->RBR;
577      if (VERBOSE>3) logerror("TMS9902: Reading receive buffer\n");
578      if (VERBOSE>3) LOG("TMS9902: Reading receive buffer\n");
578579      break;
579580   }
580581   return answer;
r12423r12424
646647            set_stop_bits(device);
647648            break;
648649         default:
649            if (VERBOSE>1) logerror("tms9902: Invalid control register address %d\n", offset);
650            if (VERBOSE>1) LOG("tms9902: Invalid control register address %d\n", offset);
650651         }
651652      }
652653      else if (tms9902->register_select & register_select_LDIR)
r12423r12424
758759
759760   if (offset == 0x11)
760761   {
761      if (VERBOSE>3) logerror("TMS9902: set BRKON=%d; BRK=%d\n", data, tms9902->BRKflag? 1:0);
762      if (VERBOSE>3) LOG("TMS9902: set BRKON=%d; BRK=%d\n", data, tms9902->BRKflag? 1:0);
762763      tms9902->BRKON = (data!=0);
763764      if (tms9902->BRKflag && data==0)
764765      {
r12423r12424
788789      // (the only way to clear the flag!)
789790      tms9902->RIENB = (data!=0);
790791      tms9902->RBRL = false;
791      if (VERBOSE>4) logerror("TMS9902: set RBRL=0, set RIENB=%d\n", data);
792      if (VERBOSE>4) LOG("TMS9902: set RBRL=0, set RIENB=%d\n", data);
792793      field_interrupts(device);
793794      return;
794795   }
r12423r12424
797798   {
798799      /* Transmit Buffer Interrupt Enable */
799800      tms9902->XBIENB = (data!=0);
800      if (VERBOSE>4) logerror("TMS9902: set XBIENB=%d\n", data);
801      if (VERBOSE>4) LOG("TMS9902: set XBIENB=%d\n", data);
801802      field_interrupts(device);
802803      return;
803804   }
r12423r12424
817818      /* Data Set Change Interrupt Enable */
818819      tms9902->DSCENB = (data!=0);
819820      tms9902->DSCH = false;
820      if (VERBOSE>4) logerror("TMS9902: set DSCH=0, set DSCENB=%d\n", data);
821      if (VERBOSE>4) LOG("TMS9902: set DSCH=0, set DSCENB=%d\n", data);
821822      field_interrupts(device);
822823      return;
823824   }
r12423r12424
831832      return;
832833   }
833834   else
834      if (VERBOSE>1) logerror("tms9902: Write to undefined address %0x ignored.\n", offset);
835      if (VERBOSE>1) LOG("tms9902: Write to undefined address %0x ignored.\n", offset);
835836}
836837
837838
src/mess/drivers/geneve.c
r12423r12424
529529
530530INPUT_PORTS_END
531531
532static const struct tms9995reset_param geneve_processor_config =
533{
534   0,   /* disable automatic wait state generation */
535   0,   /* no IDLE callback */
536   0   /* no MP9537 mask */
537};
538
539
532540static DRIVER_INIT( geneve )
533541{
534542}
r12423r12424
548556   /* basic machine hardware */
549557   /* TMS9995 CPU @ 12.0 MHz */
550558   MCFG_CPU_ADD("maincpu", TMS9995, 12000000)
559   MCFG_CPU_CONFIG(geneve_processor_config)
551560   MCFG_CPU_PROGRAM_MAP(memmap)
552561   MCFG_CPU_IO_MAP(cru_map)
553562   MCFG_CPU_VBLANK_INT_HACK(geneve_hblank_interrupt, 262)   /* 262.5 in 60Hz, 312.5 in 50Hz */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team