home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / amiga / programm / 18549 < prev    next >
Encoding:
Text File  |  1993-01-12  |  19.3 KB  |  501 lines

  1. Path: sparky!uunet!munnari.oz.au!comp.vuw.ac.nz!actrix!templar!jbickers
  2. From: jbickers@templar.actrix.gen.nz (John Bickers)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: FAQ (long).
  5. Message-ID: <jbickers.0n2z@templar.actrix.gen.nz>
  6. Date: 12 Jan 93 20:43:26 PST
  7. Organization: TAP
  8. Lines: 491
  9.  
  10.     Well, I couldn't make a fortnightly schedule, so this is now
  11.     monthly. I've rearranged the layout a bit. We also had a news
  12.     blackout here last week.
  13.  
  14.     ------------------------------ 8< ------------------------------
  15.  
  16.  
  17.     Last modified 12th Jan 1993. Please address feedback to:
  18.     jbickers@templar.actrix.gen.nz.
  19.  
  20.  
  21.     TABLE OF CONTENTS
  22.  
  23.  
  24.     1   MAILING LISTS
  25.     2   LIBRARIES
  26.     3   AVAILABLE COMPILERS & TOOLS
  27.     4   COMMUNICATIONS INFORMATION
  28.     4.1     Dropping DTR.
  29.     5   DOS INFORMATION
  30.     5.1     Can an ACTION_READ to a console be aborted?
  31.     5.2     Need a pointer to a CLI window.
  32.     5.3     Checksum errors, trimnews and hard links.
  33.     5.4     Scanning each entry in a multi-assign.
  34.     5.5     Read character from console immediately (raw).
  35.     5.6     How the Amiga FS works.
  36.     6   EXEC INFORMATION
  37.     6.1     What do GURU numbers mean?
  38.     6.2     How do you debug an input handler / task?
  39.     7   GRAPHICS INFORMATION
  40.     7.1     What is DIG/RTG?
  41.     7.2     What is the format of IFF ILBM and ANIM files?
  42.     8   INTUITION INFORMATION
  43.     8.1     How do I block a window from user input?
  44.     8.2     Some Workbench icons disappear during WindowToBack()!
  45.     9   SAS C INFORMATION
  46.     9.1     Are malloc()/free() much slower under 6.1 than 5.10?
  47.     9.2     How do I get rid of the CON: created from Workbench?
  48.  
  49. *** 1   MAILING LISTS
  50.  
  51.     A number of mailing lists are set up for email discussion of
  52.     specific subjects. These include:
  53.  
  54.     a68k-request@castrov.cuc.ab.ca
  55.         Discussion of Charlie Gibb's A68k freeware assembler.
  56.  
  57.     amigalisp-request@contessa.palo-alto.ca.us
  58.         Discussion of LISP, Scheme, ML, Gofer, functional programming,
  59.         and other such things.
  60.  
  61.     dice-request@castrov.cuc.ab.ca
  62.         Discussion of Matt Dillon's shareware DICE C compiler.
  63.  
  64.     xpr-request@aldhfn.akron.oh.us
  65.         Discussion of the XPR file transfer protocol.
  66.  
  67. *** 2   LIBRARIES
  68.  
  69.     iff.library [Christian Weber]
  70.         Routines to read and write IFF files, with direct support for
  71.         ILBM and ANIM forms for pictures and animations. ANIM support
  72.         includes decoding of DLTA chunks. It is also XPK-aware. It is
  73.         available from amiga.physik.unizh.ch and on Fish disk #674.
  74.  
  75.     pattern.library [Angela Schmidt]
  76.         AmigaDOS pattern matching routines which are less buggy than
  77.         OS (KS2.0) or ARP (KS1.2) routines, and include some special-
  78.         case optimizations. It is available from ftp.wustl.edu and on
  79.         Fish disk #625.
  80.  
  81.     reqtools.library [Nico Franτois]
  82.         String, screen, color, file and font requesters, with a 2.0
  83.         look. It is available from amiga.physik.unizh.ch.
  84.  
  85.     xpkmaster.library [Dominik Mueller et al]
  86.         A variety of data compression and encryption routines managed
  87.         through a set of sublibraries. Can compress RAM to RAM, file
  88.         to RAM, RAM to file, etc. The user and development archives
  89.         are available from amiga.physik.unizh.ch.
  90.  
  91.     xpr<proto>.library [Willy Langeveld et al]
  92.         A variety of external protocol libraries that meet the XPR 2.0
  93.         specification. The spec. can be found on Fish disk #247. The
  94.         libraries themselves are often distributed independently. Join
  95.         the XPR mailing list for information about XPR 3.0.
  96.  
  97. *** 3   AVAILABLE COMPILERS & TOOLS
  98.  
  99.     a68k
  100.         Charlie Gibbs' freeware 680x0 assember, available from
  101.         amiga.physik.unizh.ch.
  102.  
  103.     AdaEd
  104.         An Ada implementation, available from wuarchive.wustl.edu as
  105.         programming/programming/ada/adaed-1.0.11a.lzh.
  106.  
  107.     ARexx
  108.         William Hawes' commercial REXX package. The address is:
  109.  
  110.         Post.: Wishful Thinking Development Corp.,
  111.                PO Box 308, Maynard, MA 01754, USA.
  112.         Voice: +1-508-568-8695
  113.  
  114.     Comeau C++ 3.0 With Templates
  115.         Comeau Computing's commercial C++ package. Their address is:
  116.  
  117.         Email: attmail.com!csanta!comeau
  118.         Post.: Comeau Computing,
  119.                91-34 120th Street, Richmond Hill, NY 11418, USA.
  120.         Voice: +1-718-945-0009 / Fax: +1-718-441-2310.
  121.  
  122.     DICE
  123.         Matt Dillon's shareware C compiler, available from
  124.         amiga.physik.unizh.ch. His address is:
  125.  
  126.         Email: dillon@overload.berkeley.ca.us
  127.         Post.: Matthew Dillon,
  128.                1005 Apollo Way, Incline Village, NV 89451, USA.
  129.  
  130.     Gofer
  131.         See the LISP entry for more information.
  132.  
  133.     GNU C
  134.         Markus Wild's port of this freeware C compiler, available from
  135.         amiga.physik.unizh.ch.
  136.  
  137.     LISP
  138.         Several implementations are available from gatekeeper.pa.dec.
  139.         com, in the directory /pub/micro/amiga/lisp. The file
  140.         LISP.LIST has pointers to other sources. An up-to-date version
  141.         of this is available via BMS from contessa.palo-alto.ca.us as
  142.         bms:pub/lisp.list. See the Amiga LISP mailing list for more
  143.         information.
  144.  
  145.     ML
  146.         See the LISP entry for more information.
  147.  
  148.     PCQ Pascal
  149.         Patrick Quaid's freeware Pascal compiler, available from
  150.         amiga.physik.unizh.ch.
  151.  
  152.     Scheme
  153.         Suitable Schemes for use with Abelson & Sussman's "Structure
  154.         and Interpretation of Computer Programs" are SIOD, Ed Turner's
  155.         Scheme, or XScheme. If you have experience to the contrary,
  156.         please let amigalisp@contessa.palo-alto.ca.us and the FAQ list
  157.         maintainer know. These systems are available at gatekeeper.pa.
  158.         dec.com, in /pub/micro/amiga/lisp. SIOD is also on Fish disk
  159.         #525, and Scheme is on disk #149.
  160.  
  161.         See the LISP entry for more information.
  162.  
  163. *** 4   COMMUNICATIONS INFORMATION
  164.  
  165.     4.1     Dropping DTR.
  166.  
  167.     a.  If you are using a CBM device, eg serial.device, you must call
  168.         CloseDevice() to drop DTR. DTR is asserted when you open the
  169.         device, and no other system mechanism is provided to drop it.
  170.         Be aware that this fails if another application has opened the
  171.         device in SHARED mode.
  172.  
  173.     b.  Many other devices support an extra command to control the DTR
  174.         and RTS lines. This was originated by ASDG. The following is
  175.         extracted from code originally posted by Russell McOrmond:
  176.  
  177.         #define SIOCMD_SETCTRLLINES 0x10
  178.         #define SIOB_RTSB  0
  179.         #define SIOB_DTRB  1
  180.         #define SIOB_RTSF  (1<<SIOB_RTSB)
  181.         #define SIOB_DTRF  (1<<SIOB_DTRB)
  182.  
  183.         IOSer.io_Command = SIOCMD_SETCTRLLINES;
  184.         IOSer.io_Offset  = SIOB_DTRF;
  185.         if (raising DTR) IOSer.io_Length = SIOB_DTRF;
  186.         else IOSer.io_Length = 0;
  187.  
  188.         The io_Offset is a mask of bits to be affected (RTS and DTR),
  189.         and the io_Length is a value to set each bit to. So to drop
  190.         DTR you set the DTR bit in io_Offset, and clear the DTR bit
  191.         in io_Length. To raise DTR again, you set the DTR bit in both
  192.         io_Offset and io_Length.
  193.  
  194.     c.  If you are using the internal serial port with CBM's
  195.         serial.device, you can drop DTR without calling CloseDevice by
  196.         banging the hardware. Again the following is extracted from
  197.         code originally posted by Russell McOrmond:
  198.  
  199.         struct CIA *Ciab = (struct CIA *)0xbfd000;
  200.  
  201.         Disable();
  202.         Ciab->ciaddra |= CIAF_COMDTR;                   /* Set DTR as output */
  203.         if (raising DTR) Ciab->ciapra &= ~CIAF_COMDTR;  /* Raise */
  204.         else Ciab->ciapra |= CIAF_COMDTR;               /* Drop */
  205.         Enable();
  206.  
  207. *** 5   DOS INFORMATION
  208.  
  209.     5.1     Can an ACTION_READ to a console be aborted?
  210.  
  211.     No, with the exception that if you close the console, then all
  212.     pending packets are returned.
  213.  
  214.     5.2     Need a pointer to a CLI window.
  215.  
  216.     a.  The following may return a pointer with a value of -1, if the
  217.         console you were launched from has had requesters disabled.
  218.  
  219.         struct Process *pProc;
  220.  
  221.             pProc = (struct Process *)FindTask(NULL);
  222.             pWin = pProc->pr_WindowPtr;
  223.  
  224.     b.  The following code is SAS C specific, but should be easy to
  225.         modify for other compilers:
  226.  
  227.         /* findwindow.c - utility routine to find window of a CLI.
  228.             From: deven@rpi.edu (Deven T. Corzine)
  229.             Subject: Re: Finding Windows
  230.             Date: 20 Jul 90 16:14:05 GMT
  231.          */
  232.         #include <exec/types.h>
  233.         #include <exec/memory.h>
  234.         #include <proto/exec.h>
  235.         #include <proto/dos.h>
  236.  
  237.         struct Window __regargs *FindWindow()
  238.         {
  239.            register struct DosLibrary *DOSBase;
  240.            register struct Window *win;
  241.            register struct Process *proc;
  242.            register struct CommandLineInterface *cli;
  243.            register struct InfoData *id;
  244.            register struct StandardPacket *pkt;
  245.            register struct FileHandle *fh;
  246.            register BPTR file;
  247.            register long ret1,ret2;
  248.  
  249.            if (DOSBase=(struct DosLibrary *) OpenLibrary(DOSNAME,0)) {
  250.               if (id=(struct InfoData *)
  251.                 AllocMem(sizeof(struct InfoData),MEMF_PUBLIC|MEMF_CLEAR)) {
  252.                  if (pkt=(struct StandardPacket *)
  253.                    AllocMem(sizeof(struct StandardPacket),MEMF_PUBLIC|MEMF_CLEAR)) {
  254.                     proc=(struct Process *) FindTask(NULL);
  255.                     if (cli=(struct CommandLineInterface *) (proc->pr_CLI<<2)) {
  256.                        ret1=cli->cli_ReturnCode;
  257.                        ret2=cli->cli_Result2;
  258.                        if (file=Open("*",MODE_NEWFILE)) {
  259.                           if (IsInteractive(file)) {
  260.                              pkt->sp_Msg.mn_Node.ln_Name=(char *) &(pkt->sp_Pkt);
  261.                              pkt->sp_Pkt.dp_Link=&(pkt->sp_Msg);
  262.                              pkt->sp_Pkt.dp_Port=&(proc->pr_MsgPort);
  263.                              pkt->sp_Pkt.dp_Type=ACTION_DISK_INFO;
  264.                              pkt->sp_Pkt.dp_Arg1=((ULONG) id)>>2;
  265.                              fh=(struct FileHandle *) (file<<2);
  266.                              PutMsg(fh->fh_Type,(struct Message *) pkt);
  267.                              WaitPort(&(proc->pr_MsgPort));
  268.                              GetMsg(&(proc->pr_MsgPort));
  269.                              win=(struct Window *) id->id_VolumeNode;
  270.                           }
  271.                           Close(file);
  272.                        }
  273.                        cli->cli_Result2=ret2;
  274.                        cli->cli_ReturnCode=ret1;
  275.                     }
  276.                     FreeMem(pkt,sizeof(struct StandardPacket));
  277.                  }
  278.                  FreeMem(id,sizeof(struct InfoData));
  279.               }
  280.               CloseLibrary((struct Library *) DOSBase);
  281.            }
  282.            return(win);
  283.         }
  284.  
  285.     5.3     Checksum errors, trimnews and hard links.
  286.             [Randell Jesup]
  287.  
  288.     The filesystem has a problem with deleting the target of a
  289.     hardlink, especially on dir-cached partitions (DOS\5), but also
  290.     hardlinked directories on FFS, and on files and directories under
  291.     OFS (though you may not see the problem unless you need to recover
  292.     the partition).
  293.  
  294.     Temporary solutions: don't use hardlinks to directories, and don't
  295.     put UUCP news on DCFS partitions.  This will be fixed in a future
  296.     release of the FS.
  297.  
  298.     5.4     Scanning each entry in a multi-assign.
  299.             [Randell Jesup]
  300.  
  301.     BOOL do_something_to_all(char *path, BOOL (*function)(BPTR lock))
  302.     {
  303.     struct DeviceProc *dp = NULL;
  304.     struct MsgPort *old_fsport;
  305.     BPTR lock, old_curdir;
  306.     char *remainder;
  307.     LONG err;
  308.  
  309.         // NOTE: not strrchr - PathMan has files with ':'s in them
  310.         remainder = strchr(path,':');
  311.         if (remainder == NULL)
  312.             remainder = path;
  313.         else
  314.             remainder++;            /* point past ':' */
  315.  
  316.         while (1) {
  317.             dp = GetDeviceProc(path,dp);
  318.             if (!dp)
  319.             {           /* getdevproc freed dp for us */
  320.                         // NOTE: 2.04 and 3.0 have a bug, and never return
  321.                         // ERROR_NO_MORE_ENTRIES.  Accept 0 as no error as well
  322.                         // This will be fixed next release.
  323.                 err = IoErr();
  324.                 if (err == 0 || err == ERROR_NO_MORE_ENTRIES)
  325.                     return TRUE;        // all done
  326.                 else
  327.                     return FALSE;       // never found anything
  328.             }
  329.             /* save filesystem port pointer, set default FS to target */
  330.             old_fsport = SetFileSysTask(dp->dvp_Port);
  331.             old_curdir = CurrentDir(dp->dvp_Lock);      // may be NULL
  332.  
  333.             /* we have an entry, get a lock on the remainder of path */
  334.             lock = Lock(remainder,SHARED_LOCK);
  335.  
  336.             /* reset filesystem port and current dir */
  337.             (void) SetFileSysTask(old_fsport);
  338.             (void) CurrentDir(old_curdir);
  339.  
  340.             /* we got a lock on it, call user function.  Function can */
  341.             /* return FALSE to stop the scan. */
  342.             if (!lock || !(*function)(lock))
  343.             {
  344.                 UnLock(lock);           // NULL is safe
  345.                 FreeDeviceProc(dp);
  346.                 return FALSE;
  347.             }
  348.             UnLock(lock);
  349.         }
  350.     }
  351.  
  352.     Warning: that was written off the top of my head, but I do have
  353.     the source code for reference. Also, at least one developer has
  354.     used this and it works.
  355.  
  356.     5.5     Read character from console immediately (raw).
  357.  
  358.     It is often useful to have functions like getchar() return
  359.     immediately when the user presses a key, rather than waiting until
  360.     they hit Enter. To do this, you need to switch your console into
  361.     "raw" mode. The line-based mode is referred to as "cooked" mode.
  362.  
  363.     a.  Under KS2.0, dos.library has a function SetMode() that does it
  364.         all.
  365.  
  366.     b.  Under DICE, the link library function setvbuf() also switches
  367.         modes automatically.
  368.  
  369.     c.  Otherwise, you need to send an ACTION_SCREEN_MODE packet to
  370.         the console yourself. Set arg[0] to -1L for raw mode, 0 for
  371.         cooked mode.
  372.  
  373.     5.6     How the Amiga FS works.
  374.  
  375.     [Randell Jesup, on coroutines in Amiga filesystems]
  376.  
  377.     Yes, they're coroutines (BCPL ones). Anything that blocks in exec
  378.     (i.e. Wait()) will stop all of them. Internally, it switches
  379.     around between them as needed (no preemption). CallCo() will swap
  380.     to a coroutine (much like jsr), WaitCo() returns a results to the
  381.     parent (much like rts). One important difference with subroutines
  382.     is that the coroutines maintain their own stacks and state.
  383.     ResumeCo() is basically a branch to a coroutine (as if it had been
  384.     CallCo'd by your caller - much like exiting a subroutine with jmp
  385.     some_other_subrutine).  There are various other utility functions,
  386.     like StartCo, KillCo, CreateCo, etc.
  387.  
  388.     Each open filehandle is a coroutine. The master coroutine
  389.     CallCo()'s it when it gets a packet or when IO comes back. Note
  390.     that this is where the stack-based state information of the
  391.     coroutine come into play - a filehandle coroutine does IO by
  392.     queuing a request, and calling WaitCo(). The disk read/write
  393.     coroutine pulls things from the queue and gets woken up when IO is
  394.     done. When an IO is complete and verified, it notes which
  395.     coroutine is waiting for the IO to complete (can be a list), and
  396.     ResumeCo()'s that coroutine. Since the coroutine has a stack, it
  397.     continues at the point after the WaitCo with whatever it was
  398.     doing, now knowing the IO was complete. Note that the master
  399.     coroutine doesn't CallCo() an active filehandle coroutine, it
  400.     queues the packet for later handling.
  401.  
  402.     If this seems simple, I guarantee you, IT'S NOT. It's mind-warping
  403.     and arcane when you need to care about the coroutines (but easy
  404.     and straightforward when you don't).  A lot of state information
  405.     becomes automatic, without having to build a (massive) explicit
  406.     state machine. I burnt out a lot of brain cells figuring out how
  407.     to handle locking of updates to hash chains in this setup, since
  408.     this required major interactions between coroutines. The end
  409.     result was simple, but it was a bitch to figure out.
  410.  
  411. *** 6   EXEC INFORMATION
  412.  
  413.     6.1     What do GURU numbers mean?
  414.  
  415.     Get Stegan Zeiger's program "alert" from amiga.physik.unizh.ch or
  416.     Fish disk #636. It will translate the 32-bit GURU values into
  417.     something more understandable.
  418.  
  419.     6.2     How do you debug an input handler / task?
  420.  
  421.     a.  Create a message port in the parent process to which you can
  422.         send messages from the handler.
  423.  
  424.     b.  Use the kprintf() routines in debug.lib, optionally trapping
  425.         the output to a console with Sushi.
  426.  
  427. *** 7   GRAPHICS INFORMATION
  428.  
  429.     7.1     What is DIG/RTG?
  430.  
  431.     DIG is Device Independent Graphics. A set of graphics routines
  432.     that does not require a particular device to work.
  433.  
  434.     RTG is ReTargetable Graphics. A set of graphics routines that
  435.     normally work with a particular device, but can be changed at a
  436.     low level to work with other devices.
  437.  
  438.     They are basically the same thing, though DIG is more often used
  439.     to refer to things like Postscript where the output device can be
  440.     a monitor, a plotter, a printer, etc. RTG is more often used to
  441.     refer to different display hardware, usually meaning a different
  442.     number of colors or a different pixel format, planar vs chunky.
  443.  
  444.     7.2     What is the format of IFF ILBM and ANIM files?
  445.  
  446.     The complete format specs for these files can be found on Fish
  447.     disk #185. That disk also includes public domain code for the
  448.     creation of OPT 5 DLTA chunks for ANIM files.
  449.  
  450.     It may not be necessary to know the exact format if you use a
  451.     library such as iff.library for loading and saving pictures. This
  452.     library also contains a routine for decoding DLTA chunks from ANIM
  453.     files, including OPT J chunks from the old Sculpt 3D movies. OPT J
  454.     chunks used to be proprietary.
  455.  
  456. *** 8   INTUITION INFORMATION
  457.  
  458.     8.1     How do I block a window from user input?
  459.  
  460.     Normally this is required when you want to open a second window
  461.     that should act like a requester. The solution is to open a real
  462.     requester in the window you want to block, that is 1 pixel by
  463.     1 pixel, and hidden somewhere in your first window. Remove this
  464.     tiny requester when you are ready to close your "requester".
  465.  
  466.     You can also change the IDCMP flags on your first window so that
  467.     messages don't pile up.
  468.  
  469.     8.2     Some Workbench icons disappear during WindowToBack()!
  470.             [Markus Juhani Aalto]
  471.  
  472.     You have to try to lock layers before using WindowToBack().
  473.  
  474.     /* Lock layers. If someone else has locked it, then we wait. */
  475.     LockLayerRom( WorkbenchScreen->LayerInfo.top_layer );
  476.     Forbid();
  477.     UnlockLayerRom( WorkbenchScreen->LayerInfo.top_layer );
  478.  
  479.     WindowToBack(MyWindow);     /* Or WindowToFront() */
  480.     Permit();
  481.  
  482. *** 9   SAS C PROBLEMS
  483.  
  484.     9.1     Are malloc()/free() much slower under 6.1 than 5.10?
  485.  
  486.     Performance problems in programs with a lot of small malloc()/
  487.     free() calls may be overcome by reducing the page size used by the
  488.     memory management code. This is done by declaring a global
  489.     constant:
  490.  
  491.         unsigned long _MSTEP = <whatever>;
  492.  
  493.     9.2     How do I get rid of the CON: created from Workbench?
  494.  
  495.     The window is opened by the ___main() function. Refer to Appendix
  496.     1 of the SAS C User's Guide, Volume 1.
  497.  
  498. --
  499. *** John Bickers, TAP.                   jbickers@templar.actrix.gen.nz ***
  500. ***    "Radioactivity - It's in the air, for you and me" - Kraftwerk    ***
  501.