home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / djasy10d.zip / ATESTPP.CC < prev    next >
C/C++ Source or Header  |  1992-09-11  |  870b  |  54 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dos.h>
  4. #include <io.h>
  5.  
  6. #include "djasync.h"
  7.  
  8. #ifdef __GNUC__
  9. #include    <gppconio.h>
  10. #else
  11. #include    <conio.h>
  12. #endif
  13.  
  14. #include    <dos.h>
  15.  
  16. main(int ac, char** av)
  17. {
  18.   int port = ac > 1 ? atoi(av[1]) - 1 : 0;
  19.   int show = ac > 2;
  20.   int msec = ac > 2 ? atoi(av[2]) : 0;
  21.   
  22.   DJAsync       asy(port);
  23.  
  24.   while (1)
  25.   {
  26.     int x,y;
  27.  
  28.     if (kb_ready())
  29.     {
  30.       char ch = kb_rx();
  31.       if (ch == '~')
  32.         exit(0);
  33.       asy.Tx(ch);
  34.     }
  35.  
  36.     if (show) {
  37.         if (msec)
  38.             delay(msec);
  39.         x=wherex();
  40.         y=wherey();
  41.         gotoxy(1,1);
  42.         cprintf("%04d %04d",async_cnt(port),async_overflow(port));
  43.         gotoxy(x,y);
  44.     }
  45.         
  46.     if (asy.Rdy())
  47.     {
  48.       char c = asy.Rx();
  49.       write(1, &c, 1);
  50.     }
  51.   }
  52.   return 0;
  53. }
  54.