[net.sources.games] Visual Trek: Help on libs for SVR2?

johnnyr@ihu1m.UUCP (John R. Rosenberg) (09/10/85)

Does anyone know what library to use as a replacement
for the -ltermlib option on the cc that loads
this game? SVR2 has no such library. Replacing
it with curses loads the modules, but the
program does not function properly. Any help
will be appreciated.

Thanks...

John Rosenberg AT&T NS
ihnp4!ihu1m!johnnyr

"Ramming speed, Mr. Sulu!"

ccrdave@ucdavis.UUCP (Lord Kahless) (09/12/85)

> Does anyone know what library to use as a replacement
> for the -ltermlib option on the cc that loads
> this game? SVR2 has no such library.
> John Rosenberg AT&T NS
> ihnp4!ihu1m!johnnyr

try changing the make file to -ltermcap. (It makes mille work.)

By the way, the factory version wouldn't work with a vt102 terminal
on our 4.2 system.  I have a patch, if anybody else found the same
bug.

			ucbvax!ucdavis!vega!ccrdave

dta@cpsc53.UUCP (Doug Anderson) (09/12/85)

> Does anyone know what library to use as a replacement
> for the -ltermlib option on the cc that loads
> this game? SVR2 has no such library. Replacing
> it with curses loads the modules, but the
> program does not function properly. Any help
> will be appreciated.
> 
> Thanks...
> 
> John Rosenberg AT&T NS
> ihnp4!ihu1m!johnnyr
> 
> "Ramming speed, Mr. Sulu!"

	Thank God some one else is having the same problem I
	am.  I was beginning to think I was just screwed up or
	somthing. 

	If anyone has the time to research this please post it
	to the net. 

		Thanks

		Doug Anderson

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (09/13/85)

> > Does anyone know what library to use as a replacement
> > for the -ltermlib option on the cc that loads
> > this game? SVR2 has no such library.
> > John Rosenberg AT&T NS
> > ihnp4!ihu1m!johnnyr
> 
> try changing the make file to -ltermcap. (It makes mille work.)

What -ltermcap??  Try -lcurses.  Geez.

hestenes@sdcsla.UUCP (Eric Hestenes) (09/15/85)

> > Does anyone know what library to use as a replacement
> > for the -ltermlib option on the cc that loads
> > this game? SVR2 has no such library.

where do these def'ns reside? I can't get a successful compile.


Undefined:
_sqrt
_atan2
_tan
_tgetent
_tgetstr
_tgoto



Eric Hestenes
arpanet: hestenes@nprdc.ARPA
other: ucbvax!sdcsvax!sdcsla!hestenes or hestenes@sdcsla.UUCP

dta@cpsc53.UUCP (Doug Anderson) (09/17/85)

> > > Does anyone know what library to use as a replacement
> > > for the -ltermlib option on the cc that loads
> > > this game? SVR2 has no such library.
> > > John Rosenberg AT&T NS
> > > ihnp4!ihu1m!johnnyr
> > 
> > try changing the make file to -ltermcap. (It makes mille work.)
> 
> What -ltermcap??  Try -lcurses.  Geez.

	Curses doesn't work either. At least not on my 3B2.

		Doug Anderson

spear@ihopb.UUCP (Steven Spearman) (09/18/85)

My understanding is that the 'termcap' routines are
only partially supported in SVR2 as a compatability mode
in curses.  Users are expected to convert programs to
use curses instead since this support will go away in
future releases.

I guess this incompatability with the rest of the Unix
community is progress.

Steve Spearman   ihnp4!ihopb!spear

ccrdave@ucdavis.UUCP (Lord Kahless) (09/19/85)

> > Does anyone know what library to use as a replacement
> > for the -ltermlib option on the cc that loads
> > this game? SVR2 has no such library. Replacing
> > it with curses loads the modules, but the
> > program does not function properly.
> > John Rosenberg AT&T NS
> > ihnp4!ihu1m!johnnyr

There are various problems w/ sys V vtrek.

1)  The i/o sets you to RAW!  Look in the termio module.

2)  The way to make it compile w/o diagnostics (NOT run) is
to change termlib to termcap in the make file.  Anybody who
can fix the tty stuff would have my thanks.

3)  The afore mentioned term problems.  I posted one fix, another
was posted.

			ucbvax!ucdavis!vega!ccrdave

guy@sun.uucp (Guy Harris) (09/19/85)

> > Does anyone know what library to use as a replacement
> > for the -ltermlib option on the cc that loads
> > this game? SVR2 has no such library. Replacing
> > it with curses loads the modules, but the
> > program does not function properly.

The problem is that Visual Trek uses the "termcap" library incorrectly (or,
at least, not in the way it's supposed to be used).  The "curses"/"terminfo"
library has routines which emulate the behavior of the "tget..." routines
but only if you use them correctly.

The code in question (in excerpted form):

	static char cm[20];

		p = cm;
		tgetstr("cm", &p);
		p = cl;
		tgetstr("cl", &p);
		...

A more "correct" version would be

	static char string[1024];	/* or however big it has to be */
	static char *stringp = &string[0];
	static char *cm;

		cm = tgetstr("cm", &stringp);
		cl = tgetstr("cl", &stringp);

The intent was that "tget<whatever>" would return the gotten
boolean/number/string.  The pointer for "tgetstr" is merely to a buffer into
which the strings are to be dumped.  The reason it works differently in
"curses"/"terminfo" is that "terminfo" reads the entire "terminfo" entry as
one big lump, and you then reference the capability strings directly from
that lump.  The "tgetstr" routines merely return pointers into that lump;
they do not use the second argument in any way whatsoever.

Speaking of suspicious code:

	gtty(0, &tty);
	saveflags = tty.sg_flags;
	tty.sg_flags |= RAW;
	tty.sg_flags &= ~(ECHO | XTABS);
	stty(0, &tty);

Programs should not use RAW mode unless they need an 8-bit data path to/from
the terminal (no parity, just 8 data bits) and no flow control.  If the
program just wants to capture each character as it is typed, CBREAK mode is
just fine.  You probably want to turn off CRMOD also (RAW mode disables all
output translations).  The RAW should be CBREAK and the ECHO | XTABS should
probably include CRMOD (and maybe LCASE).

	ioctl(0, TIOCGETP, &tty);
		/* I consider "gtty" and "stty" to be deprecated */
	saveflags = tty.sg_flags;
	tty.sg_flags |= CBREAK;
	tty.sg_flags &= ~(ECHO | XTABS | CRMOD | LCASE);
	ioctl(0, TIOCSETP, &tty);

None of that will work right in System III or System V.  Declare "tty" as a
"struct termio", declare "savetty" as "struct termio" also and throw out
"saveflags", and replace the code with

	ioctl(0, TCGETA, &tty);
	savetty = tty;
	/*
	 * This assumes you want to turn off all output translations,
	 * which is very likely to be the case in any full-screen program.
	 */
	tty.c_oflag &= ~OPOST;
	tty.c_lflag &= ~(ICANON | ECHO);
		/* turning ICANON off is like turning CBREAK on */
	ioctl(0, TCSETAW, &tty);

Note that in both these cases, the user's interrupt character will work
normally.  This means that unless you want to disable the interrupt and quit
characters (for information on that, see below), you'll have to catch SIGINT
(and maybe SIGQUIT) and, if you get those signals, restore the modes, clear
the screen, and exit.

To disable the interrupt characters in V7 (and, hence, 4.xBSD):

	struct tchars tc, savetc;

	ioctl(0, TIOCGETC, &tc);
	savetc = tc;
	tc.t_intrc = '\377';
	tc.t_quitc = '\377';
	ioctl(0, TIOCSETC, &tc);

For S3/S5, just turn off the ISIG bit as well as the ICANON bit in
"c_lflags".

If you're running under 4.xBSD, you should also either

	1) catch SIGTSTP and, when it is caught, reset the TTY modes, clear
	   the screen, reset the SIGTSTP handler if you're running under
	   4.2BSD, and send yourself a SIGTSTP with "kill"

or

	2) disable the suspend and delayed-suspend characters as well.
	   To do this, look up the TIOCGLTC and TIOCSLTC "ioctl" calls in
	   TTY(4).

Moral - writing full-screen programs is more complicated than you probably
thought.

	Guy Harris

guy@sun.uucp (Guy Harris) (09/22/85)

> where do these def'ns reside? I can't get a successful compile.
> _sqrt
> _atan2
> _tan

The math library ("-lm").

> _tgetent
> _tgetstr
> _tgoto

On a system with the old "termcap" library, in the "termcap library"
("-ltermcap" or "-ltermlib").  On a system with the new "curses"/"terminfo"
library, in that library ("-lcurses") (although note that the code that uses
"tgetstr" uses it in a way that may be "correct", in that the documentation
doesn't explicitly say it's wrong, but won't work with the new library; see
earlier posting on this subject).

The Makefile posted with this game gives both "-lm" and "-ltermlib".  Did
you use that Makefile or did you try compiling it on your own?

	Guy Harris

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (09/22/85)

> I guess this incompatability with the rest of the Unix
> community is progress.

Actually, it is.  Termcap has severe problems that have been
fixed in terminfo.  The (very few) primitive termlib routines
were closely tied to the termcap database structure, so they
do not all have a direct replacement in terminfo-based curses.

ccrdave@ucdavis.UUCP (Lord Kahless) (09/22/85)

> > > Does anyone know what library to use as a replacement
> > > for the -ltermlib option on the cc that loads
> > > this game? SVR2 has no such library.
> 
> where do these def'ns reside? I can't get a successful compile.
> 
> 
> Undefined:
> _sqrt
> _atan2
> _tan
> _tgetent
> _tgetstr
> _tgoto
> 
> arpanet: hestenes@nprdc.ARPA
> other: ucbvax!sdcsvax!sdcsla!hestenes or hestenes@sdcsla.UUCP

Looks like you
1)  aren't getting to the curses library, the tgetent, tgetstr,
and tgoto error
2) aren't getting to math library.

What sort of sys V system.  There are zillions.  Here's a generic
fix for the little UNISOFT port machines.  It may work for you...
1)  change the make file to -ltermcap.  -lcurses may work on some
machines.
2)  Use one of the posted terminal fixes.
3)  If you get the program to compile and it acts incredibly freaky,
try replacing the direct setting of your tty, in the termio.c file,
with calls to the curses equivalents, noecho and crmode.  That
worked.  You will have some more butchering to do, but the rest is
obvious.  I will post a running UNISOFT port version, if I get
requests.

Anyone have hack running on unisoft?  Other games?  I'd be interested...
Perhaps mutually benificial swaps can be arranged.

			ucbvax!ucdavis!vega!ccrdave

guy@sun.uucp (Guy Harris) (09/24/85)

> The (very few) primitive termlib routines were closely tied to the termcap
> database structure, so they do not all have a direct replacement in
> terminfo-based curses.

Say what?  There are routines in the curses/terminfo library for emulating
the old termcap routines.  The S5R2 documentation says they may go away at a
later date, but I'm not sure that statement is still operative.

	Guy Harris

lasse@daab.UUCP (Lars Hammarstrand) (10/03/85)

In article <90@ucdavis.UUCP> ccrdave@ucdavis.UUCP (Lord Kahless) writes:
>
>Anyone have hack running on unisoft?  Other games?  I'd be interested...
>Perhaps mutually benificial swaps can be arranged.
>
>			ucbvax!ucdavis!vega!ccrdave

Sure, what's the problem with a UniPlus+ SysV port?, I think it's great and I
have hack and other games running on my machine.
I haven't heard that it should be any major difference between UniPlus+ and
UniPlus+, so what's the problem?.



	Lars Hammarstrand.
	Datorisering AB, Stockholm, SWEDEN.

	UUCP:	{seismo,decvax,philabs}!{mcvax,ukc,unido}!enea!daab!lasse
	ARPA:	decvax!mcvax!enea!daab!lasse@berkley.ARPA
		decvax!mcvax!enea!daab!lasse@seismo.ARPA

Ps...
If you have a 1/2" tape station, I can send you a 1600 BPI tar tape with hack
and some other stuff.