home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / comm / ykh121.zip / YKHSRC.ZIP / YKH.C < prev   
C/C++ Source or Header  |  1993-04-18  |  4KB  |  184 lines

  1. #pragma inline
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <dos.h>
  6. #include "graph.h"
  7. #include "input.h"
  8. #include "comio.h"
  9.  
  10. void ykh_init (void);
  11. void ykh_close(void);
  12. void terminal (void);
  13. void ykh_exit (void);
  14.  
  15. int ykhbaud;
  16. char* defpath;
  17. char* defservice;
  18.  
  19. #define EUC       8
  20. #define SHIFT_JIS 9
  21.  
  22. extern int sixteen_encoding;
  23. extern int fix_jis;
  24.  
  25. int main(int argc, char *argv[])
  26. {
  27. unsigned mainport;
  28. defpath=argv[0];
  29.  
  30. asm push sp;
  31. asm pop ax;
  32. asm cmp ax,sp;
  33. asm je asm_1;
  34.  
  35. ykh_exit();
  36. dosprint("unable to find 80286 or better CPU.\r\n$");
  37. exit(1);
  38.  
  39. asm_1:;
  40.  
  41. if (argc==1)
  42.   {
  43.   mainport=COM1_PORT;
  44.   defservice="2400";
  45.   }
  46.   else
  47.   {
  48.   switch(argv[1][0])
  49.     {
  50.     case 'l':
  51.     case 'L': mainport=LAT_PORT;   break;
  52.     case 'c':
  53.     case 'C': mainport=CTERM_PORT; break;
  54.     case '1': mainport=COM1_PORT;  break;
  55.     case '2': mainport=COM2_PORT;  break;
  56.     default :
  57.       ykh_exit();
  58.       dosprint("The first commandline option must be the name of a terminal service:\r\n$");
  59.       dosprint("lat, cterm, 1com, 2com\r\n$");
  60.       exit(1);
  61.     }
  62.  
  63.   if (argv[2]==NULL)
  64.     {
  65.     ykh_exit();
  66.     if ( (mainport!=COM1_PORT) && (mainport!=COM2_PORT) )
  67.       dosprint("If you use LAT or CTERM, you must supply a nodename on the commandline.\r\n$");
  68.       else
  69.       dosprint("If you use a comport, you must supply a baudrate on the commandline\r\n$");
  70.     exit(1);
  71.     }
  72.   defservice=argv[2];
  73.   }
  74.  
  75. switch (com_open(mainport,defservice))
  76.   {
  77.   case 1:
  78.     ykh_exit();
  79.     dosprint("terminal service failed installation check.\r\n$");
  80.     exit(1);
  81.     break;
  82.   case 2:
  83.     ykh_exit();
  84.     dosprint("unable to connect to requested nodename.\r\n$");
  85.     exit(1);
  86.     break;
  87.   }
  88.  
  89. ykh_init();
  90.  
  91. terminal();
  92. ykh_close();
  93. ykh_exit();
  94. return(0);
  95. }
  96.  
  97. void ykh_exit()
  98. {
  99. dosprint("YKH v1.2 Copyright (c)1993 Bryan McNett\r\n$");
  100. dosprint("YKH comes with ABSOLUTELY NO WARRANTY. For details, read GNUGPL.TXT.\r\n$");
  101. dosprint("This is free software, and you are welcome to redistribute it\r\n$");
  102. dosprint("under certain conditions. Read the file GNUGPL.TXT for details.\r\n$");
  103. }
  104.  
  105. void ykh_init()
  106. {
  107. if (key_init())
  108.   {
  109.   ykh_exit();
  110.   dosprint("unable to find the extended keyboard BIOS.\r\n$");
  111.   exit(1);
  112.   }
  113. graphics_init(GRAPH_GRAPHICS);
  114. switch (vidinit(defpath))
  115.   {
  116.   case 0 : break;
  117.   default: graphics_init(GRAPH_TEXT);
  118.            vidinit(defpath);
  119.   }
  120. VTInit();                      /* Initialize VT Emulation */
  121. LogoInit();
  122. InputInit();
  123. font_init();
  124. }
  125.  
  126.  
  127. void ykh_close()
  128. {
  129. com_close();
  130. key_close();
  131. VidClose();
  132. graphics_deinit();
  133. }
  134.  
  135.  
  136. void terminal()
  137. {
  138. int i;
  139. int thru = 0;
  140.  
  141. XORCursor();
  142. while (!thru)
  143.   {                /* Continue until exited */
  144.   if (ConChk())
  145.     {                     /* If a keystroke is present */
  146.     switch (DoKey())
  147.       {
  148.       case -4:
  149.         fix_jis^=1;
  150.         ChangeInput(INPUT_VT100);
  151.         break;
  152.       case -5: ChangeInput(INPUT_VT100); break;
  153.       case -6: ChangeInput(INPUT_HIRAGANA); break;
  154.       case -7: ChangeInput(INPUT_KATAKANA); break;
  155.       case -8:
  156.         if (sixteen_encoding==SHIFT_JIS)
  157.           sixteen_encoding=EUC;
  158.           else
  159.           sixteen_encoding=SHIFT_JIS;
  160.         ChangeInput(INPUT_VT100);
  161.         break;
  162.       case -9:
  163.         XORCursor();
  164.         VTinit();
  165.         LogoInit();
  166.         InputInit();
  167.         XORCursor();
  168.         break;
  169.       case -10: thru=1; break;
  170.       }
  171.     }
  172.   if (com_ready())            /* If incoming communications chars */
  173.     {
  174.     XORCursor();
  175.     i=0;
  176.     while ( (com_ready()) && ( ((i++)<80) ) )
  177.       ConOut( com_get() );   /* Output the character to emulation system*/
  178.     XORCursor();
  179.     }
  180.   }
  181. }
  182.  
  183.  
  184.