home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
comm
/
ykh121.zip
/
YKHSRC.ZIP
/
YKH.C
< prev
Wrap
C/C++ Source or Header
|
1993-04-18
|
4KB
|
184 lines
#pragma inline
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include "graph.h"
#include "input.h"
#include "comio.h"
void ykh_init (void);
void ykh_close(void);
void terminal (void);
void ykh_exit (void);
int ykhbaud;
char* defpath;
char* defservice;
#define EUC 8
#define SHIFT_JIS 9
extern int sixteen_encoding;
extern int fix_jis;
int main(int argc, char *argv[])
{
unsigned mainport;
defpath=argv[0];
asm push sp;
asm pop ax;
asm cmp ax,sp;
asm je asm_1;
ykh_exit();
dosprint("unable to find 80286 or better CPU.\r\n$");
exit(1);
asm_1:;
if (argc==1)
{
mainport=COM1_PORT;
defservice="2400";
}
else
{
switch(argv[1][0])
{
case 'l':
case 'L': mainport=LAT_PORT; break;
case 'c':
case 'C': mainport=CTERM_PORT; break;
case '1': mainport=COM1_PORT; break;
case '2': mainport=COM2_PORT; break;
default :
ykh_exit();
dosprint("The first commandline option must be the name of a terminal service:\r\n$");
dosprint("lat, cterm, 1com, 2com\r\n$");
exit(1);
}
if (argv[2]==NULL)
{
ykh_exit();
if ( (mainport!=COM1_PORT) && (mainport!=COM2_PORT) )
dosprint("If you use LAT or CTERM, you must supply a nodename on the commandline.\r\n$");
else
dosprint("If you use a comport, you must supply a baudrate on the commandline\r\n$");
exit(1);
}
defservice=argv[2];
}
switch (com_open(mainport,defservice))
{
case 1:
ykh_exit();
dosprint("terminal service failed installation check.\r\n$");
exit(1);
break;
case 2:
ykh_exit();
dosprint("unable to connect to requested nodename.\r\n$");
exit(1);
break;
}
ykh_init();
terminal();
ykh_close();
ykh_exit();
return(0);
}
void ykh_exit()
{
dosprint("YKH v1.2 Copyright (c)1993 Bryan McNett\r\n$");
dosprint("YKH comes with ABSOLUTELY NO WARRANTY. For details, read GNUGPL.TXT.\r\n$");
dosprint("This is free software, and you are welcome to redistribute it\r\n$");
dosprint("under certain conditions. Read the file GNUGPL.TXT for details.\r\n$");
}
void ykh_init()
{
if (key_init())
{
ykh_exit();
dosprint("unable to find the extended keyboard BIOS.\r\n$");
exit(1);
}
graphics_init(GRAPH_GRAPHICS);
switch (vidinit(defpath))
{
case 0 : break;
default: graphics_init(GRAPH_TEXT);
vidinit(defpath);
}
VTInit(); /* Initialize VT Emulation */
LogoInit();
InputInit();
font_init();
}
void ykh_close()
{
com_close();
key_close();
VidClose();
graphics_deinit();
}
void terminal()
{
int i;
int thru = 0;
XORCursor();
while (!thru)
{ /* Continue until exited */
if (ConChk())
{ /* If a keystroke is present */
switch (DoKey())
{
case -4:
fix_jis^=1;
ChangeInput(INPUT_VT100);
break;
case -5: ChangeInput(INPUT_VT100); break;
case -6: ChangeInput(INPUT_HIRAGANA); break;
case -7: ChangeInput(INPUT_KATAKANA); break;
case -8:
if (sixteen_encoding==SHIFT_JIS)
sixteen_encoding=EUC;
else
sixteen_encoding=SHIFT_JIS;
ChangeInput(INPUT_VT100);
break;
case -9:
XORCursor();
VTinit();
LogoInit();
InputInit();
XORCursor();
break;
case -10: thru=1; break;
}
}
if (com_ready()) /* If incoming communications chars */
{
XORCursor();
i=0;
while ( (com_ready()) && ( ((i++)<80) ) )
ConOut( com_get() ); /* Output the character to emulation system*/
XORCursor();
}
}
}