[comp.sys.atari.st] Con -> RS232

sfn20715@uxa.cso.uiuc.edu (04/21/89)

I have set up an ST BBS recently and am trying to get some online games
running, specifically Larn and Nethack.  However, both of these games send
output to the screen, not the RS232 port.  Does anyone out there have a 
program that will redirect output from screen to the RS232?  Code fragments
in C or assembler would be just as nice as a full fledged program.  I do have
considerable experience programming STs in C, so dont be afraid to let
the jargon fly!

Reply as e-mail to sfn20715@uxa.cso.uiuc.edu please.
Thanks!

usenet@TSfR.UUCP (usenet) (04/22/89)

In article <111500016@uxa.cso.uiuc.edu> sfn20715@uxa.cso.uiuc.edu writes:
>
>I have set up an ST BBS recently and am trying to get some online games
>running, specifically Larn and Nethack.  However, both of these games send
>output to the screen, not the RS232 port.

 If you're running a STadel, it attempts to redirect i/o to the rs232
 port when you shell out from remote.  If hack & larn still talk to the
 screen, you're S.O.L. unless you wanna hack the BIOS calls.  If you're
 not running STadel, try the following code:

 ------[cut here]------

 /*
  * rexec: execute a program with stdin/stdout pointed at AUX:
  */
 #include <atari\osbind.h>

 main(argc, argv)
 {
    char tail[128];
    char *command;
    int save0, save1;

    if (argc < 2) {
	Cconws("usage: rexec command [args]\r\n");
	exit(255);
    }
    save0 = Fdup(0);	/* save old file descriptors */
    save1 = Fdup(1);

    Fforce(-2, 0);	/* force AUX: (-2) into stdin (0) and stdout (1) */
    Fforce(-2, 1);	/* PARAMETERS MAY BE REVERSED! */

    ++argv, --argc;

    command = *argv++;
    argc--;

    tail[0] = 0;		/* fabricate a command tail */
    while (argc-- > 0) {
	strcat(tail, " ");
	strcat(tail, *argv++);
    }
    if (tail[0])
	tail[0] = strlen(tail)-1;
    
    Pexec(0, command, tail, 0L);	/* Zoom! */

    Fforce(save0, 0);	/* restore stdin/stdout */
    Fforce(save1, 1);
    Fclose(save0);	/* and toss save-handles */
    Fclose(save1);
 }

 ------[cut here]------

 If your applications are well-behaved (talk via GEMDOS calls instead
 of BIOS calls), this will do the trick.  I use a variant of this routine
 from inside STadel for shelling out, and I regularly shell out from
 remote (when Pell is working, that is) even if I'm calling from long
 distance.

>Reply as e-mail to sfn20715@uxa.cso.uiuc.edu please.

 Hope you don't mind that I replied publicly - this sort of code is
 useful to the world in general...

   -david parsons
   -orc@pell.uucp

7103_300@uwovax.uwo.ca (Eric Smith) (04/22/89)

In article <111500016@uxa.cso.uiuc.edu>, sfn20715@uxa.cso.uiuc.edu writes:
> 
> I have set up an ST BBS recently and am trying to get some online games
> running, specifically Larn and Nethack.  However, both of these games send
> output to the screen, not the RS232 port.  Does anyone out there have a 
> program that will redirect output from screen to the RS232?

I don't know about Larn, but it should be possible to redirect the output
and input of NetHack to the RS232 port by means of Fforce(), e.g. something
like Fforce(0, Fopen("AUX:", 2)); Fforce(1, Fopen("AUX:", 2)). The
major potential problem is that NetHack (I'm assuming you're using the version
I posted to comp.binaries.atari.st) uses a Crawcin call, which may not be
properly redirected in all versions of TOS. It's worth a try, though.
Failing all else, the sources for NetHack and Larn are available on
terminator.cc.umich.edu; you could always recompile them with appropriate
modifications!
--
Eric R. Smith                      email:
Dept. of Mathematics               7103_300@uwovax.uwo.ca
University of Western Ontario      7103_300@uwovax.bitnet
London, Ont. Canada N6A 5B7    (a shared mailbox: put my name on
ph: (519) 661-3638              the Subj: line, please!)

hyc@math.lsa.umich.edu (Howard Chu) (04/28/89)

In article <111500016@uxa.cso.uiuc.edu> sfn20715@uxa.cso.uiuc.edu writes:
>
>I have set up an ST BBS recently and am trying to get some online games
>running, specifically Larn and Nethack.  However, both of these games send
>output to the screen, not the RS232 port.  Does anyone out there have a 
>program that will redirect output from screen to the RS232?  Code fragments
>in C or assembler would be just as nice as a full fledged program.  I do have
>considerable experience programming STs in C, so dont be afraid to let
>the jargon fly!
>
>Reply as e-mail to sfn20715@uxa.cso.uiuc.edu please.
>Thanks!

My port of Larn 12.0, based on Don Kneller's port from Unix to MSDOS, used
GEMDOS calls for console I/O. According to the MWC documentation, these can
easily be redirected. I suspect they meant "by a command shell." The simple
fix for your case would be to write a small loader program that understands
how to do redirections. This program would just have to close the three
stdio descriptors, 0-2, open the AUX: device, and use Fdup or Fforce to set
0-2 to the same as the AUX handle. Then Pexec Larn from there. You could do
this in C, which would be easy, but if you're tight for memory space you
might want to code this in assembler instead.
--
 -=- PrayerMail: Send 100Mbits to holyghost@father.son[127.0.0.1]
 and You Too can have a Personal Electronic Relationship with God!

usenet@TSfR.UUCP (usenet) (04/28/89)

In article <620@stag.math.lsa.umich.edu> hyc@math.lsa.umich.edu (Howard Chu) writes:
>In article <111500016@uxa.cso.uiuc.edu> sfn20715@uxa.cso.uiuc.edu writes:
>>...  Does anyone out there have a 
>>program that will redirect output from screen to the RS232?
> ... This program would just have to close the three
>stdio descriptors, 0-2, open the AUX: device, and use Fdup or Fforce to set
>0-2 to the same as the AUX handle.

  'Cepting, of course, that file descriptor 2 isn't stderr.  Gemdos uses
descriptor 0 for stdin and 1 for stdout, just like Unices, but for some
totally inexplicable reason, Atari or DRI decided not to support the concept
of standard error.  File descriptor 2? It points at the rs232 port....


   -david parsons
   -orc@pell.uucp

hyc@math.lsa.umich.edu (Howard Chu) (04/30/89)

In article <531@TSfR.UUCP> orc@pell.UUCP (David L. Parsons) writes:
>In article <620@stag.math.lsa.umich.edu> hyc@math.lsa.umich.edu (Howard Chu) writes:
>> ... This program would just have to close the three
>>stdio descriptors, 0-2, open the AUX: device, and use Fdup or Fforce to set
>>0-2 to the same as the AUX handle.
>
>  'Cepting, of course, that file descriptor 2 isn't stderr.  Gemdos uses
>descriptor 0 for stdin and 1 for stdout, just like Unices, but for some
>totally inexplicable reason, Atari or DRI decided not to support the concept
>of standard error.  File descriptor 2? It points at the rs232 port....

The desktop points descriptor 2 at the rs232 port by default, but you're free
to point it anywhere you want. The MWC runtime code treats descriptor 2 as
stderr, and as such it's usually directed to the console. Of course, none of
this matters if you use Fforce. (Actually, there are 3 variants of the MWC
startup - 1 for desk accessories, 1 for GEM .PRGs, and one for TOS/command line
oriented programs. The default is TOS style, which remaps descriptor 2. That's
what I used for Larn. In actuality, it's the Mark Williams shell that does
the redirection, but that's also beside the point. [The *point* is that you
*can* redirect them and you need to, for the requested purpose.])
--
 -=- PrayerMail: Send 100Mbits to holyghost@father.son[127.0.0.1]
 and You Too can have a Personal Electronic Relationship with God!

WILDDJ@VAXB.ASTON.AC.UK (05/11/89)

>>In article <11150016@uxa.cso.uiuc.edu> sfn20715@uxa.cso.uiuc.edu writes:
>>>... Does anyone out there have a
>>>program that will redirect output from screen to the RS232?

Yes. I've written a little assembly program that does the trick - all TOS
output is sent to the RS232. It dosen't use Fforce, but redirects a system
variable to point to the aux out routine in ROM instead of the con out.
If anyone would like a copy, I could mail it to them ... I know, I'll mail
the 68000 source to the net in a couple of days time.

Dave

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
                     ! JANET   wilddj@uk.ac.aston.vaxb                         !
***      *  *     *  ! BITNET  wilddj@vaxb.aston.ac.uk                         !
*  *     *  *  *  *  ! ARPA    wilddj%vaxb.aston.ac.uk@cunyvm.cuny.edu         !
*  *     *  *  *  *  ! UUCP   ...psuvax1!cunyvm.bitnet!vaxb.aston.ac.uk!wilddj !
*  * *   *  *  *  *  !---------------------------------------------------------+
***   ***    ** **   ! Home Address: 62 Lascelles Avenue, Withernsea, North    !
                     !               Humberside, HU19 2EB, England             !
   David J  Wild     ! University  : Dept of Computer Science,                 !
                     !               Aston University, Birmingham, England     !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-