home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / VORX / SUPER_C.ARC / TERM.C < prev    next >
Text File  |  1980-01-01  |  2KB  |  54 lines

  1. /*                      Terminal Emulator Program
  2. */
  3.  
  4. #define SERCONFIG 0x83  /* 1200 baud, 8 bits, 1 stop bit, no parity. */
  5.  
  6. #define SERDRDY 0x100   /* Serial receiver data ready bit mask. */
  7.  
  8. #define TRUE 1
  9. #define FALSE 0
  10.  
  11. /*      main()
  12.  
  13.         Function: Display data coming from COM1 on the screen, and send
  14.         keystrokes from the keyboard out to COM1.
  15.  
  16.         Algorithm: Loop, waiting for data from either side to appear.
  17.         Use keyChk to see if there's anything from the keyboard; if
  18.         there is, send it using serSend. Use serRecv to check if
  19.         there's anything from the serial port; if there is, display
  20.         it using putTty.
  21. */
  22.  
  23. main()
  24.  
  25. {
  26.         int ch; /* Character to transfer. */
  27.  
  28.         /* Initialize the port. */
  29.         serInit(0,SERCONFIG);
  30.  
  31.         /* Main loop. */
  32.         while (TRUE) {
  33.                 /* Check for keyboard input. */
  34.                 if (keyChk(&ch)) {
  35.                         /* If yes, clear the character from the queue. */
  36.                         keyRd();
  37.                         /* Check for non-ASCII. */
  38.                         if ((ch & 0xFF) == 0) {
  39.                                 break;
  40.                         };
  41.                         /* Send the character out the serial port. */
  42.                         serSend(0,ch);
  43.                 };
  44.                 /* Anything available from the serial port? */
  45.                 if (serStat(0) & SERDRDY) {
  46.                         /* If so, read it in. */
  47.                         ch = serRecv(0);
  48.                         /* And put it on the screen. */
  49.                         putTty(0,ch,3);
  50.                 };
  51.         };
  52. }
  53.  
  54.