🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #25924

Problem with Atari o.s. terminal handling

#25924
From: minow
Date: Fri, 27 Mar 1987 04:10
160 lines
4681 bytes
/*
 * This program illustrates what appears to be a bug deep in the
 * bowels of the Atari operating system.  The program initializes
 * the desktop, then starts one of two terminal emulators, which
 * have identical logic, but use different operating system functions.
 * To elicit the problem, execute the program, connect to a host,
 * and cause the host to send text (at 2400 Baud).  Then, type something
 * (I use <CTRL/C>) while output is being transmitted.  The program
 * will crash in various ways.  You will probably have to reset the
 * computer.
 *
 * Compile using "cc -VGEM tinytty.c" in Mark Williams C
 * Execute (from the Mark Williams desktop) by "gem tinytty"
 * Set the terminal service as follows:
 *	2400 Baud, XON mode, other parameters seem irrelevant.
 * Connect to a VMS system and login.
 * 	$ type *.*		! type a bunch of files
 *	... type <CTRL/C> to cancel a file and start another.
 *	    there appears to be a 10% probability of crashing.
 *
 * Submitted by
 * Martin Minow
 * decvax!minow
 * minow%thundr.dec@decwrl.dec.com
 */

#include	<gemdefs.h>
#include	<aesbind.h>
#include	<osbind.h>
#include	<vdibind.h>
#include	<obdefs.h>
#define	FALSE	0			/* Falsehood.			*/
#define	TRUE	1			/* Truth.			*/
#define EOS	0			/* End of string		*/
#define	NULL	((char *)0)
#define ESC	0x1B			/* Escape			*/
#define	CON	2			/* Console			*/
#define	AUX	1			/* RS232 port			*/

/*
 * Window definition structure
 */

typedef struct window {
    int		id;
    int		x, y, w, h;
} WINDOW;

long		_stksize = 4096;

#define V_OVW_IN_SIZE	11	/* work in size	 for v_openvwrk()	*/
#define V_OVW_OUT_SIZE	57	/* work out size for v_openvwrk()	*/

int			contrl[12];
int			intin[128];
int			ptsin[128];
int			intout[128];
int			ptsout[128];

extern int		gl_apid;	/* Real application id		*/
int			gem_handle;
int			vdi_handle;

WINDOW			desk;		/* The screen itself		*/
int			char_height;	/* Box (cell) height		*/

int			debug = FALSE;


main()
{
	int		junk;
	register int	i;
	int		work_in[V_OVW_IN_SIZE];
	int		work_out[V_OVW_OUT_SIZE];

	appl_init();
	gem_handle = graf_handle(&junk, &char_height, &junk, &junk);
	wind_update(BEG_UPDATE);
	for (i = 0; i < 10; i++)
	    work_in[i] = 1;
	work_in[10] = 2;		/* Raster coordinates		*/
	vdi_handle = gem_handle;
	v_opnvwk(work_in, &vdi_handle, work_out);
	if (vdi_handle == 0) {
	    form_alert(1,"[1][Too many windows|Close one and try again][OK]");
	    return;
	}
	wind_get(0, WF_WORKXYWH, &desk.x, &desk.y, &desk.w, &desk.h);
	desk.id = wind_create(0, desk.x, desk.y, desk.w, desk.h);
	if (desk.id == 0) {
	    form_alert(1, "[1][Can't create window][OK]");
	    return;
	}
	wind_open(desk.id, desk.x, desk.y, desk.w, desk.h);
	graf_growbox(0, 0, 36, 36, desk.x, desk.y, desk.w, desk.h);
	graf_mouse(M_OFF, 0xL);
	if (form_alert(1, "[1][ Which version ][ Good | Crashes ]") == 1)
	    good_version();
	else {
	    bad_version();
	}
	form_alert(1,"[1][ Exiting ][OK]");
	graf_mouse(M_ON, 0xL);
	wind_close(desk.id);
	wind_delete(desk.id);
	graf_shrinkbox(0, 0, 36, 36, desk.x, desk.y, desk.w, desk.h);
	wind_update(END_UPDATE);
	v_clsvwk(vdi_handle);
	appl_exit();
	Cconout('\r');
	Cconout('\n');
}

bad_version()
{
	register long		c;

	start_screen();
	for (;;) {				/* The emulator itself	*/
	    if ((c = Crawio(0xFF)) != 0) {
		c &= 0x7F;
		if (c == '@' || c == ('Z' & 0x1F))
		    break;
		Cauxout((int) c);
	    }
	    if (Cauxis() != 0)
		 Cconout(((int) Cauxin()) & 0x7F);
	}
	stop_screen();
}

good_version()
{
	register long		c;

	start_screen();
	for (;;) {				/* The emulator itself	*/
	    if (Bconstat(CON) != 0) {
		c = Bconin(CON) & 0x7F;
		if (c == '@' || c == ('Z' & 0x1F))
		    break;
		Bconout(AUX, (int) c);
	    }
	    if (Bconstat(AUX) != 0)
		 Bconout(CON, ((int) Bconin(AUX)) & 0x7F);
	}
	stop_screen();
}

start_screen()
{
	Cconout(ESC); Cconout('e');		/* Text cursor on	*/
	Cconout(ESC); Cconout('E');		/* Clear screen		*/
}

stop_screen()
{
	Cconout(ESC); Cconout('f');		/* Text cursor off	*/
}
Technical Details
Message-ID: <8830@decwrl.DEC.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!sri-unix!ctnews!pyramid!decwrl!thundr.dec.com!minow

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!sri-unix!ctnews!pyramid!decwrl!thundr.dec.com!minow
From: minow@thundr.dec.com.UUCP
Newsgroups: comp.sys.atari.st
Subject: Problem with Atari o.s. terminal handling
Message-ID: <8830@decwrl.DEC.COM>
Date: Thu, 26-Mar-87 23:10:38 EST
Article-I.D.: decwrl.8830
Posted: Thu Mar 26 23:10:38 1987
Date-Received: Sat, 28-Mar-87 11:26:30 EST
Sender: daemon@decwrl.DEC.COM
Organization: Digital Equipment Corporation
Lines: 160