From: jbickers@templar.actrix.gen.nz (John Bickers)
Newsgroups: comp.sys.amiga.programmer
Subject: Frequently Asked Questions
Date: 14 Dec 92 21:44:57 PST
Organization: TAP

    Well, it's been about a month since I began trying to keep track
    of various questions, so here's the first installment of the FAQ,
    which I will post fortnightly if no-one complains. :)

    Suggestions, flames, etc to jbickers@templar.actrix.gen.nz.

    ------------------------------ 8< ------------------------------

    Last modified 7th Dec 92. Search for "*** index>" to get to a
    specific topic.


    TABLE OF CONTENTS


    Communications
    1   Where can one get information about XPR libraries?
    2   How does one drop DTR?

    Compression
    3   Where can one get information about XPK libraries?

    DOS
    4   Can an ACTION_READ packet to a console be aborted?
    5   How do I get a pointer to the window I was launched from?

    Exec
    6   What do GURU numbers mean?

    Graphics
    7   What is DIG/RTG?

    Intuition
    8   How do I block a window from user input?

    Languages
    9   LISP, Scheme, ML, Gofer, functional programming.
    10  I need a Scheme to use with Abelson & Sussman's "Structure and
        Interpretation of Computer Programs."
    11  Is there an Ada implementation available?
    12  Are there freely distributable C compilers available?

    SAS C
    13  Are malloc()/free() much slower under 6.1 than 5.10?

    Workbench
    14  How do I get rid of the CON: created when my program starts?

*** 1>  Where can one get information about XPR libraries?

    There is an XPR mailing list. To join, send a message to
    xpr-request@aldhfn.akron.oh.us, with "subsribe user@site" as the
    body.

    Version 2.0 of the XPR spec. can be found on Fish disk #247. The
    mailing list is currently discussing things to go into the 3.0
    XPR spec., and comes with an XPR FAQ.

*** 2>  How does one drop DTR?

    1.  If you are using a CBM device, eg serial.device, you must call
        CloseDevice() to drop DTR. DTR is asserted when you open the
        device, and no other system mechanism is provided to drop DTR.

    2.  Many other devices support an extra command to control the DTR
        and RTS lines. This was originated by ASDG. The following is
        extracted from code originally posted by Russell McOrmond:

        #define SIOCMD_SETCTRLLINES 0x10
        #define SIOB_RTSB  0
        #define SIOB_DTRB  1
        #define SIOB_RTSF  (1<<SIOB_RTSB)
        #define SIOB_DTRF  (1<<SIOB_DTRB)

        IOSer.io_Command = SIOCMD_SETCTRLLINES;
        IOSer.io_Offset  = SIOB_DTRF;
        if (raising DTR) IOSer.io_Length = SIOB_DTRF;
        else IOSer.io_Length = 0;

        The io_Offset is a mask of bits to be affected (RTS and DTR),
        and the io_Length is a value to set each bit to. So to drop
        DTR you set the DTR bit in io_Offset, and clear the DTR bit
        in io_Length. To raise DTR again, you set the DTR bit in both
        io_Offset and io_Length.

    3.  If you are using the internal serial port with CBM's
        serial.device, you can drop DTR without calling CloseDevice by
        banging the hardware. Again the following is extracted from
        code originally posted by Russell McOrmond:

        struct CIA *Ciab = (struct CIA *)0xbfd000;

        Disable();
        Ciab->ciaddra |= CIAF_COMDTR;                   /* Set DTR as output */
        if (raising DTR) Ciab->ciapra &= ~CIAF_COMDTR;  /* Raise */
        else Ciab->ciapra |= CIAF_COMDTR;               /* Drop */
        Enable();

*** 3>  Where can one get information about XPK libraries?

    The XPK libraries are a collection of run-time libraries that
    implement a variety of compression and encryption methods. The
    user and development archives are available for FTP from
    amiga.physik.unizh.ch.

*** 4>  Can an ACTION_READ packet to a console be aborted?

    No, with the exception that if you close the console, then all
    pending packets are returned.

*** 5>  How do I get a pointer to the window I was launched from?

    1.  The following may return a pointer with a value of -1, if the
        console you were launched from has had requesters disabled.

        struct Process *pProc;

            pProc = (struct Process *)FindTask(NULL);
            pWin = pProc->pr_WindowPtr;

    2.  The following code is SAS C specific, but could easily be
        modified to suit other compilers:

    /* findwindow.c - utility routine to find window of a CLI.
        From: deven@rpi.edu (Deven T. Corzine)
        Subject: Re: Finding Windows
        Date: 20 Jul 90 16:14:05 GMT
     */
    #include <exec/types.h>
    #include <exec/memory.h>
    #include <proto/exec.h>
    #include <proto/dos.h>

    struct Window __regargs *FindWindow()
    {
       register struct DosLibrary *DOSBase;
       register struct Window *win;
       register struct Process *proc;
       register struct CommandLineInterface *cli;
       register struct InfoData *id;
       register struct StandardPacket *pkt;
       register struct FileHandle *fh;
       register BPTR file;
       register long ret1,ret2;

       if (DOSBase=(struct DosLibrary *) OpenLibrary(DOSNAME,0)) {
          if (id=(struct InfoData *)
            AllocMem(sizeof(struct InfoData),MEMF_PUBLIC|MEMF_CLEAR)) {
             if (pkt=(struct StandardPacket *)
               AllocMem(sizeof(struct StandardPacket),MEMF_PUBLIC|MEMF_CLEAR)) {
                proc=(struct Process *) FindTask(NULL);
                if (cli=(struct CommandLineInterface *) (proc->pr_CLI<<2)) {
                   ret1=cli->cli_ReturnCode;
                   ret2=cli->cli_Result2;
                   if (file=Open("*",MODE_NEWFILE)) {
                      if (IsInteractive(file)) {
                         pkt->sp_Msg.mn_Node.ln_Name=(char *) &(pkt->sp_Pkt);
                         pkt->sp_Pkt.dp_Link=&(pkt->sp_Msg);
                         pkt->sp_Pkt.dp_Port=&(proc->pr_MsgPort);
                         pkt->sp_Pkt.dp_Type=ACTION_DISK_INFO;
                         pkt->sp_Pkt.dp_Arg1=((ULONG) id)>>2;
                         fh=(struct FileHandle *) (file<<2);
                         PutMsg(fh->fh_Type,(struct Message *) pkt);
                         WaitPort(&(proc->pr_MsgPort));
                         GetMsg(&(proc->pr_MsgPort));
                         win=(struct Window *) id->id_VolumeNode;
                      }
                      Close(file);
                   }
                   cli->cli_Result2=ret2;
                   cli->cli_ReturnCode=ret1;
                }
                FreeMem(pkt,sizeof(struct StandardPacket));
             }
             FreeMem(id,sizeof(struct InfoData));
          }
          CloseLibrary((struct Library *) DOSBase);
       }
       return(win);
    }

*** 6>  What do GURU numbers mean?

    Try and find a program called "guru", or another called "alert".
    These programs will decode the GURU value and translate it into
    English.

*** 7>  What is DIG/RTG?

    DIG is Device Independent Graphics. A set of graphics routines
    that does not require a particular device to work.

    RTG is ReTargetable Graphics. A set of graphics routines that
    normally work with a particular device, but can be changed at a
    low level to work with other devices.

    They are basically the same thing, though DIG is more often used
    to refer to things like Postscript where the output device can be
    a monitor, a plotter, a printer, etc. RTG is more often used to
    refer to different display hardware, usually meaning a different
    number of colors or a different pixel format, planar vs chunky.

*** 8>  How do I block a window from user input?

    Normally this is required when you want to open a second window
    that should act like a requester. The solution is to open a real
    requester in the window you want to block, that is 1 pixel by
    1 pixel, and hidden somewhere in your first window. Remove this
    tiny requester when you are ready to close your second window.

    You can also change the IDCMP flags on your first window so that
    messages don't pile up.

*** 9>  LISP, Scheme, ML, Gofer, functional programming.

    A number of Amiga LISP implementations are available by FTP from
    gatekeeper.pa.dec.com, in the directory /pub/micro/amiga/lisp. The
    file LISP.LIST also has a list of such things, though it is a bit
    dated. A modern version of that list can be obtained from
    contessa.palo-alto.ca.us. Either use bms to fetch
    bms:pub/lisp.list, or send mail to:

        amigalisp-request@contessa.palo-alto.ca.us

    asking for that list. This address can be used to ask to be added
    to the amigalisp mail list.

    These references also apply to questions about Scheme, ML, Gofer,
    functional programming, and other such things.

*** 10> I need a Scheme to use with Abelson & Sussman's "Structure and
        Interpretation of Computer Programs."

    Either SIOD, Ed Turner's Scheme, or XScheme should be suitable for
    this. If you have experience to the contrary, please let the FAQ
    list maintainer and amigalisp@contessa.palo-alto.ca.us know. Those
    systems can all be obtained via anonymous FTP from
    gatekeeper.pa.dec.com, in /pub/micro/amiga/lisp. SIOD is on Fish
    disk #525, and Scheme is on disk #149.

*** 11> Is there an Ada implementation available?

    AdaEd, via FTP from wuarchive.wustl.edu, in the amiga subdirectory
    programming/programming/ada. The filename is adaed-1.0.11a.lzh.

*** 12> Are there freely distributable C compilers available?

    GNU C, ported by Markus Wild, is available for FTP from
    amiga.physik.unizh.ch.

    Matt Dillon's DICE, the FD version of which does not handle
    floating point, is also available from amiga.physik.unizh.ch.

*** 13> Are malloc()/free() much slower under 6.1 than 5.10?

    Performance problems in programs with a lot of small malloc()/
    free() calls may be overcome by reducing the page size used by the
    memory management code. This is done by declaring a global
    constant:

        unsigned long _MSTEP = <whatever>;

*** 14> How do I get rid of the CON: created when my program starts?

    This is an SAS C feature. The window is opened by the ___main()
    function. Refer to Appendix 1 of the SAS C User's Guide, Volume 1.

    ------------------------------ 8< ------------------------------

--
*** John Bickers, TAP.                   jbickers@templar.actrix.gen.nz ***
***    "Radioactivity - It's in the air, for you and me" - Kraftwerk    ***