[alt.sources.amiga] meter: memory meter -- Howard Hull

amiga-sources@sugar.uu.net (alt.sources.amiga) (10/15/88)

Archive: uunet!~uucp/amiga-sources/meter.sh.Z

:
#! /bin/sh
# This is a shell archive, created on Sugar Land Unix (..!uunet!sugar)
# (bbs: 713-438-5018) by peter (Peter da Silva) on Sat Oct 15 08:05:28 1988
# Remove anything before the "#! /bin/sh" line, then unpack it by saving
# it into a file and typing "sh file".  If you do not have sh, you need 
# unshar, a dearchiving program which is widely available.  In the absolute
# wost case, you can crack the files out by hand.
# If the archive is complete, you will see the message "End of archive."
# at the end.
# This archive contains the following files...
# 'mm.doc'
# 'mm.h'
# 'mm3.c'
# 'mminit3.c'
# To extract them, run the following through /bin/sh
echo x - mm.doc
sed 's/^X//' > mm.doc << '//END_OF_FILE'
X/* : ai=0 bk=0 ts=8 */
X/*
X *   MemMometer - program hacked from Rokicki's WFrags more or less...
X *   (in fact, a heck of a lot) in the style of Peter DaSilva's "Gauge."
X *   The program opens a narrow window with the same dimensions as the
X *   disk capacity gadget found in the top-level workbench window for
X *   a floppy volume.  The sizing gadget is like the one in Gauge; to
X *   resize the window, just click the left mouse button over the "E".
X *   My bin copy of Gauge broke when I put a Michigan Insider in my A1000.
X *   I did not have source for the Gauge program, so I conjured this one.
X *
X *   Note that in the display there's one memmometer for Chip (left-hand
X *   column ), another for Slow Fast mem (center column) and another for
X *   Fast mem (right-hand column ).  These memmometers can be turned on or
X *   off as desired by selecting "NONE" or the various items in the Size
X *   menus.  Parts of several FD programs have been used to make MemMometer.
X *   Menus, for instance, are a la VT100 (Wecker, et al).  As with the
X *   VT100 program, MemMometer has preset variables.  However, the program
X *   does not presently contain a script file reader or an AREXX interface
X *   with which to automatically set the variables.  Maybe this will
X *   happen in a future rev (volunteers?).
X *
X *   FRAGS mode:
X *   The 'mometers display a frequently-updated window indicating the extent
X *   of memory fragmentation and free memory, thus showing the sizes of the
X *   largest available chunks.  Black is unallocated, blue is partially
X *   framented, red-orange is fully allocated.  It takes a while after
X *   startup to settle out and display the upper fast mem, so be patient...
X *   It's useful for finding out why those large programs won't load.  Also
X *   useful during development to see what impact your application is having
X *   on memory fragmentation.
X *
X *   WARPS mode:
X *   The 'mometer displays any change that it sees in memory, BUT this mode
X *   only works sensibly when JUST ONE memory size selection is active (set
X *   others to "NONE").  Black areas are unchanged sections of memory, blue
X *   areas are sections with zeroed long words in them, and red-orange areas
X *   are sections containing recently changed long words.  Given that you
X *   may have two areas of memory active in the compare, though, it is
X *   possible to set it up (by careful planning w.r.t. the ways of AmigaDOS
X *   memory management) so that something double buffered between CHIP and
X *   RAM can be compared using this "mis-feature."  If you can load an area,
X *   say, at a selectable boundary in RAM and its counterpart at the 256K
X *   boundary in CHIP, (or similarly juggled arrangements in slow-fast and
X *   fast RAM) you can use WARPS to judge the extent of differences between
X *   two or perhaps even three similar fields.
X *
X *   To run, simply type
X *
X *      run MM3  or  click on the icon.
X *
X *   Then open the menu item selections and set them for your configuration.
X *   Frags mode, 512K of CHIP @0, 0.5Meg of SF @C00000, and 2MB FAST mem are
X *   the defaults.  Timing (Freq) is rather ragged, sorry about that...
X *
X *   That's all!  Enjoy this program.  Forget about the bugs.  :-)  mm3 uses
X *   Amy's Forbid, Permit, and the notorious v1.2 Delay function - so you'll
X *   probably get a track 40 error some day when you expect it least (I did).
X *   It's good discipline for remembering to make backups... ::--))
X *
X *   The source to mm3 is freely distributable; the copy of Rokiki's WFrags
X *   I was working with had no copyright or distribution restrictions, and
X *   Wecker's VT100 is known to be in the public domain.  I add no further
X *   restrictions to, nor accept any responsibilities for the use of the
X *   codes herein, which are recommended for entertainment purposes only.
X *   So get out your Manx 3.6a compiler and fix the bugs yourself, then
X *   compile and link as described in the makefile.
X *                                                              Good Luck.
X *
X *   Howard Hull  (The C Barbarian)*     hull@hao.ucar.edu
X *
X *   			*( A matter of primitive language, not piracy...)
X */
//END_OF_FILE
echo x - mm.h
sed 's/^X//' > mm.h << '//END_OF_FILE'
X/* : ai=0 bk=0 ts=8 */
X#include <intuition/intuition.h>
X#include <intuition/intuitionbase.h>
X#include <graphics/gfx.h>
X#include <graphics/gfxbase.h>
X#include <exec/exec.h>
X#include <exec/execbase.h>
X#include <functions.h>
X
Xextern struct IntuitionBase *IntuitionBase ;
Xextern struct Window *window ;
Xextern struct MsgPort *myport ;
X
//END_OF_FILE
echo x - mm3.c
sed 's/^X//' > mm3.c << '//END_OF_FILE'
X/* : ai=0 bk=0 ts=8 */
X#include "mm.h"
X
X#define REDP 3L        /* workbench pen colors for Draw and RectFill */
X#define BLKP 2L
X#define WHTP 1L
X#define BLUP 0L
X
X#define SOK        0x001f     /* memory allocation control masks */
X#define S1         0x0001
X#define S2         0x0002
X#define S4         0x0004
X#define S8         0x0008
X#define SA         0x0010
X#define C1         0xfffe
X#define C2         0xfffd
X#define C4         0xfffb
X#define C8         0xfff7
X#define CA         0xffef
X
X#define EXTENSION  16L       /* allocation request increment */
X
X#define EVENMASK 0x7ffffffe           /* used to prevent odd address traps */
X#define CLIHEIGHT 200L                             /* window scaling stuff */
X#define SIZEGAD 9L
X#define DRAGBAR 10L
X#define BORDER 2L
X#define WINW 16L                                   /* initial window width */
X#define WINH (long)(CLIHEIGHT - SIZEGAD - DRAGBAR)   /* initial win height */
X#define MINH 81L                              /* shortest allowable window */
X#define MAXH 576L                              /* longest allowable window */
X#define BART 1L                               /* title bar F text location */
X#define BARH (long)(WINH - SIZEGAD - DRAGBAR)                /* bar height */
X#define BARS (long)(BARH + 1)        /* number of memory items to allocate */
X#define BARB (long)(BARH + DRAGBAR - 1)        /* bottom of mercury column */
X#define BARE (long)(BARB + BORDER)              /* bar end E text position */
X#define BARW (long)(((WINW - (2 * BORDER)) / 3) - 1)  /* 3 memfragmometers */
X#define LEFT BORDER                   /* SLOW : since we're syncopated, we */
X#define MIDDLE (LEFT + BARW + 1)      /* SLOW-FAST : do it going from bar  */
X#define RIGHT (MIDDLE + BARW + 1)     /* FAST :to bar at an irregular pace */
X#define RTEXT - 4L        /* offset for three char E/F text from left edge */
X#define STARTVAL 64L    /* start by getting enough storage for a few frags */
X
X/* typedef short BOOL */        /* this is in include/exec/types.h */
X
Xstruct IntuitionBase *IntuitionBase ;
Xstruct Window *window ;
Xstruct IntuiMessage *message;
X/* struct IntuiMessage *GetMsg(); */        /* in functions.h */
X
Xstruct GfxBase *GfxBase ;
X
Xextern void InitProjItems();        /* this stuff is in the mminit section */
Xextern void InitSetupItems();
Xextern void InitChipItems();
Xextern void InitChipAItems();
Xextern void InitSFItems();
Xextern void InitSFAItems();
Xextern void InitFastItems();
Xextern void InitFastAItems();
Xextern void InitMenu();
Xextern void StartMenus();
X
XBOOL p_mode = 0;              /* preset frags mode = 0, warps mode = 1 */
Xlong p_rate = 2;              /* preset sample interval, secs see menu */
Xlong p_chip = 512;            /* preset chip mem size, kbytes see menu */
Xlong p_chipa = 0;             /* preset chip mem address, kb  see menu */
Xlong p_sf = 512;              /* preset slowfast mem size, kb see menu */
Xlong p_sfa = 0x3000;          /* preset slowfast mem addr, kb see menu */
Xlong p_fast = 2;              /* preset fast mem size, mbytes see menu */
Xlong p_fasta = 2;             /* preset fast mem addr, mbytes see menu */
X
Xstatic BOOL mode;                    /* uninitialized for mode  menu */
Xstatic long delayval;                /* uninitialized for delay menu */
Xstatic long cmemsize;                /* uninitialized for chip  menu */
Xstatic long cmembase;                /* uninitialized for chipa menu */
Xstatic long sfmemsize;               /* uninitialized for sf    menu */
Xstatic long sfmembase;               /* uninitialized for sfa   menu */
Xstatic long fmemsize;                /* uninitialized for fast  menu */
Xstatic long fmembase;                /* uninitialized for fasta menu */
X
Xstatic USHORT log ;
Xstatic BOOL things_are_cool = TRUE ; /* tells when to close the window  */
Xstatic BOOL intsig = FALSE ;         /* intuition message detector */
Xstatic long chip[3], fast[3] ;       /* place to keep mem header pointers */
Xstatic ULONG  *chunkv ;              /* demand allocated for frag chunks */
Xstatic ULONG  *sizev ;               /* demand allocated for frag sizes */
Xstatic ULONG  *csum ;                /* a col's height worth of checksums */
Xstatic ULONG  *oldcsum ;             /* same height worth of old checksums */
Xstatic USHORT *cell;                 /* 1 cell per pixel height of mercury */
Xstatic long x1, x2 ;                 /* used to Draw() memometer segments */
Xstatic long frags = STARTVAL ;       /* # of demand allocated frag items */
Xstatic long warps = BARS ;           /* # of demand allocated column items */
Xstatic long barh = BARH ;            /* EVEN #'d height of mercury column */
Xstatic long barb = BARB ;            /* bottom position of mercury column */
X
X/* struct RastPort *rp ; */          /* wonder why we don't need this... ? */
X
Xstatic struct TextAttr myfont = {
X   (STRPTR) "topaz.font",
X   TOPAZ_EIGHTY,
X   0,
X   0
X};
X/* E newsize gadget refresh text */ 
Xstatic char ebuf[4] = " E " ;
Xstatic struct IntuiText e_text = { 
X   BLUP, WHTP,
X   JAM2, 
X   0, BARE,
X   &myfont,
X   (UBYTE *)ebuf, 
X   NULL 
X};
X/* F title refresh text */
Xstatic char fbuf[4] = " F " ;
Xstatic struct IntuiText f_text = {
X   BLUP, WHTP,
X   JAM2,
X   0, BART,
X   &myfont,
X   (UBYTE *)fbuf,
X   &e_text
X};
Xstatic struct NewWindow newwindow = {
X   0,                                        /* left edge */
X   10,                                       /* top edge */
X   WINW,                                     /* width */
X   WINH,                                     /* height */
X   0,                                        /* detail pen */
X   1,                                        /* block pen */
X   MENUPICK | NEWSIZE,                       /* messages */
X/* WINDOWDEPTH | WINDOWCLOSE */              /* don't use these gads */
X   WINDOWDRAG | WINDOWSIZING | SMART_REFRESH,   /* add a few gadgets */
X   NULL,                                     /* no custom gadgets */
X   NULL,                                     /* default checkmark */
X   (UBYTE *)"F",                             /* title */
X   NULL,                                     /* initialize this! */
X   NULL,                                     /* use screen bitmap */
X   WINW, MINH, WINW, MAXH,                   /* min and max sizes */
X   WBENCHSCREEN } ;                          /* use workbench screen */
X
Xvoid initmenus()
X{
X   (void) InitProjItems();     	        /* Initialize the menu items */
X   (void) InitSetupItems();
X   (void) InitChipItems();
X   (void) InitChipAItems();
X   (void) InitSFItems();
X   (void) InitSFAItems();
X   (void) InitFastItems();
X   (void) InitFastAItems();
X   (void) InitMenu();
X   (void) StartMenus();
X   }
X
Xvoid handle_MENUPICK( class, code )
Xunsigned long class;
Xunsigned int code;
X{
X    unsigned int menunum, itemnum, subnum;
X
X    if (code == MENUNULL) return;
X
X    menunum = MENUNUM( code );
X    itemnum = ITEMNUM( code );
X    subnum  = SUBNUM( code );
X    switch( menunum ) {
X        case 0:
X        switch( itemnum ) {
X            case 0:
X            WindowToFront(window);
X            break;
X
X            case 1:
X            WindowToBack(window);
X            break;
X
X            case 2:
X            things_are_cool = FALSE;
X            break;
X            } /* end of switch ( Project itemnum ) */
X        break;
X
X        case 1:
X        switch( itemnum ) {
X            case 0:
X            switch( subnum ) {
X                case 0:
X                mode = FALSE ;
X                break;
X
X                case 1:
X                mode = TRUE ;
X                break;
X                /* end of switch ( Mode subnum ) */
X                }
X            break;       
X            case 1:
X            switch( subnum ) {
X                case 0:
X                delayval = 36;
X                break;
X
X                case 1:
X                delayval = 72;
X                break;
X
X                case 2:
X                delayval = 180;
X                break;
X
X                case 3:
X                delayval = 360;
X                break;
X                /* end of switch ( Freq subnum ) */
X                }
X            break;       
X            /* end of switch ( Setup itemnum ) */
X            }
X        break;
X
X        case 2:
X        switch( itemnum ) {
X            case 0:
X            cmemsize = 0x000000;
X            break;
X
X            case 1:
X            cmemsize = 0x040000;
X            break;
X
X            case 2:
X            cmemsize = 0x080000;
X            break;
X
X            case 3:
X            cmemsize = 0x100000;
X            break;
X
X            case 4:
X            cmemsize = 0x200000;
X            break;
X            }
X            /* end of switch ( Chip Size itemnum ) */
X        break;
X
X        case 3:
X        switch( itemnum ) {
X            case 0:
X            cmembase = 0x000000;
X            break;
X
X            case 1:
X            cmembase = 0x040000;
X            break;
X
X            case 2:
X            cmembase = 0x080000;
X            break;
X
X            case 3:
X            cmembase = 0x100000;
X            break;
X            }
X            /* end of switch ( Chip Addr itemnum ) */
X        break;
X
X        case 4:
X        switch( itemnum ) {
X            case 0:
X            sfmemsize = 0x000000;
X            break;
X
X            case 1:
X            sfmemsize = 0x080000;
X            break;
X
X            case 2:
X            sfmemsize = 0x100000;
X            break;
X
X            case 3:
X            sfmemsize = 0x180000;
X            break;
X            }
X            /* end of switch ( SF Size itemnum ) */
X        break;
X
X        case 5:
X        switch( itemnum ) {
X            case 0:
X            sfmembase = 0xc00000;
X            break;
X
X            case 1:
X            sfmembase = 0xc80000;
X            break;
X
X            case 2:
X            sfmembase = 0xd00000;
X            break;
X
X            case 3:
X            sfmembase = 0xd80000;
X            break;
X            }
X            /* end of switch ( SF Addr itemnum ) */
X        break;
X
X        case 6:
X        switch( itemnum ) {
X            case 0:
X            fmemsize = 0x000000;
X            break;
X
X            case 1:
X            fmemsize = 0x080000;
X            break;
X
X            case 2:
X            fmemsize = 0x100000;
X            break;
X
X            case 3:
X            fmemsize = 0x200000;
X            break;
X
X            case 4:
X            fmemsize = 0x400000;
X            break;
X
X            case 5:
X            fmemsize = 0x600000;
X            break;
X
X            case 6:
X            fmemsize = 0x800000;
X            break;
X            }
X            /* end of switch ( Fast Size itemnum ) */
X        break;
X
X        case 7:
X        switch( itemnum ) {
X            case 0:
X            fmembase = 0x200000;
X            break;
X
X            case 1:
X            fmembase = 0x300000;
X            break;
X
X            case 2:
X            fmembase = 0x400000;
X            break;
X
X            case 3:
X            fmembase = 0x500000;
X            break;
X
X            case 4:
X            fmembase = 0x600000;
X            break;
X
X            case 5:
X            fmembase = 0x700000;
X            break;
X
X            case 6:
X            fmembase = 0x800000;
X            break;
X
X            case 7:
X            fmembase = 0x900000;
X            break;
X            }
X            /* end of switch ( Fast Addr itemnum ) */
X        break;
X        }
X        /* end of switch ( menunum ) */
X}
X
Xvoid wrack_sploot() /* this subprogram cashes in the chips in bad times */
X    {
X    if (log != 0) {
X        if (log & SA) {
X            (void) FreeMem(oldcsum, (long)(sizeof(ULONG) * warps)) ;
X            log = log & CA ;
X            }
X        if (log & S8) {
X            (void) FreeMem(csum, (long)(sizeof(ULONG) * warps)) ;
X            log = log & C8 ;
X            }
X        if (log & S4)  {
X            (void) FreeMem(sizev, (long)(sizeof(long) * frags)) ;
X            log = log & C4 ;
X            }
X        if (log & S2)  {
X            (void) FreeMem(chunkv, (long)(sizeof(long) * frags)) ;
X            log = log & C2 ;
X            }
X        if (log & S1) {
X            (void) FreeMem(cell, (long)(sizeof(USHORT) * warps)) ;
X            log = log & C1 ;
X            }
X        frags = 0;
X        warps = 0;
X        }
X}
X
Xvoid handle_NEWSIZE()        /* oh rats, the user found the size gadget... */
X    {
X    if (barh != window->Height)  {  /* cash in the old memory allocations  */
X        if (log & SA)  {
X            (void) FreeMem(oldcsum, (long)(sizeof(ULONG) * warps)) ;
X            log = log & CA ;
X            }
X        if (log & S8)  {
X            (void) FreeMem(csum, (long)(sizeof(ULONG) * warps)) ;
X            log = log & C8 ;
X            }
X        if (log & S1)  {
X            (void) FreeMem(cell, (long)(sizeof(USHORT) * warps)) ;
X            log = log & C1 ;
X            }
X        barh = window->Height - SIZEGAD - DRAGBAR ;  /* recalculate height */
X        barb = window->Height - SIZEGAD - 1 ; /* get new bar base position */
X        warps = barh + 1 ;       /* number of storage cells to be reserved */
X        if ((cell = (USHORT *)AllocMem((long)sizeof(USHORT) * warps,
X                                        MEMF_PUBLIC)) != 0L ) log = log | S1;
X        if ((csum = (ULONG *)AllocMem((long)sizeof(ULONG) * warps,
X                                        MEMF_PUBLIC)) != 0L ) log = log | S8;
X        if ((oldcsum = (ULONG *)AllocMem((long)sizeof(ULONG) * warps,
X                                        MEMF_PUBLIC)) != 0L ) log = log | SA;
X        if (log != SOK)  {      /* bail out if we didn't get an allocation */
X            wrack_sploot() ;
X            things_are_cool = FALSE ;     /* tell _main that we're leaving */
X            }
X        e_text.TopEdge = barb + BORDER ;        /* set the E text position */
X        }
X}
X
Xvoid handle_MESSAGES()  {
X    unsigned long class;
X    unsigned int code, qual;
X
X    /* Wait (1L << window->UserPort->mp_SigBit); this is rediculous! */
X    while ((message=(struct IntuiMessage *)GetMsg(window->UserPort))
X                                                                != 0L) {
X        class = message->Class ;
X        code = message->Code ;
X        qual = message->Qualifier ;
X        ReplyMsg ;
X        switch( class ) {
X            case NEWSIZE:
X            intsig = TRUE ;			/* resize when done here */
X            break ;
X
X            case MENUPICK:
X            handle_MENUPICK( class, code ) ;    /* do menus ASAP */
X            break ;
X            }
X        }
X}
X
Xvoid memometer()                /* this subprogram draws the bar graphs */
X    {
X    long i;
X    long y;
X
X    i = 0 ;
X    while ((i < barh) && (intsig == FALSE)) {
X        y = barb - i ;
X        SetAPen(window->RPort, (long)cell[i]);
X        Move(window->RPort, x1, y);
X        Draw(window->RPort, x2, y);
X        (void) handle_MESSAGES() ;  /* go see if the user wants anything */
X        i++ ;
X        }
X}
X
Xvoid shake()    /* this subprogram slings down the mercury column */
X    {
X    int i;
X
X    for (i = 0; i < barh; i++)  {
X        cell[i] = REDP ;
X        }
X}
X
Xvoid lockout()  /* this subprogram renders a whole column in border colors */
X    {
X    (void) handle_MESSAGES() ;        /* go see if the user wants anything */
X    SetAPen(window->RPort, WHTP) ;    /* set in the border color */
X    RectFill(window->RPort, x1, (barb - barh + 1), x2, barb) ; /* fill in */
X}
X
Xvoid updatewarps( wf, membase, memseg )  /* this subprogram finds changes */
Xshort wf;
Xlong membase, memseg ;
X    {
X    register long i ;
X    register ULONG r ;
X    register ULONG delta ;
X    register ULONG *a ;
X
X    if (memseg == 0) {
X        (void) lockout() ;
X        return ;
X        }
X    else (void) shake() ;
X
X    delta = (ULONG)(memseg & EVENMASK) ;  /* try to avoid odd address trap */
X    r = (ULONG)(membase & EVENMASK) ;     /* prefer wrong address to death */
X    for (i = 0; i < barh; i++)  {
X        csum[i] = 0 ;
X        }
X    for (i = 0; i < barh; i++)  {
X        for (a = (ULONG *)r; a < (ULONG *)(r + delta); a++)  {
X            csum[i] += *a ;
X            }
X        if (csum[i] == 0) cell[i] = cell[i] & BLUP ;
X        if (csum[i] == oldcsum[i])  cell[i] = cell[i] & BLKP ;
X        oldcsum[i] = csum[i] ;
X        r += delta ;
X        }
X    (void) memometer();
X}
X
Xvoid updatescreen( wf, membase, memseg )
Xshort wf;
Xlong membase, memseg;
X    {
X    register long size ;
X    register struct MemHeader *hdr ;
X    register struct MemChunk *chunk ;
X    extern struct ExecBase *SysBase ;
X    register long *which ;                /* active memlist chunk pointer */
X    register long newlimit ;  /* number of chunks, incl 1 null chunk, + 1 */
X    register long newfrags ;  /* number of chunks, incl null chunks, + 1  */
X    long newsize ;  /* size of next request for chunkv/sizev memory, + 1  */
X    int i, j, k, l ;
X    int length ;       /* length is number of chunks to be processed, + 1 */
X    BOOL cf, nf ;      /* cf is "chip flag" nf is "null chunk found" flag */
X
X    if (memseg == 0) {
X        (void) lockout() ;
X        return;
X        }
X    else (void) shake() ;
X
X    for (i = 0; i < 3; i++) {
X        chip[i] = 0;
X        fast[i] = 0;
X        }
X    for (i = 0; i < frags; i++) {
X        chunkv[i] = 0;
X        sizev[i] = 0;
X        }
X    newfrags = 0 ;
X    newlimit = 0 ;
X    nf = FALSE;
X    Forbid() ;
X    hdr = (struct MemHeader *) SysBase->MemList.lh_Head ;
X    while (hdr->mh_Node.ln_Succ) {
X        if (hdr->mh_Attributes & MEMF_CHIP) {
X            which = chip ;
X            cf = TRUE;
X            }
X        else {
X            which = fast ;
X            cf = FALSE;
X            }
X        if (((cf == TRUE) && (wf == 0)) || ((cf == FALSE) && (wf > 0)))  {
X            for (chunk = hdr->mh_First; chunk; chunk = chunk->mc_Next) {
X                if (which[1] < frags)  chunkv[which[1]++] = (unsigned long)chunk ;
X                size = chunk->mc_Bytes ;
X                if (which[2] < frags)  sizev[which[2]++] = (unsigned long)size;
X                *which += size ;
X                if (nf == FALSE)  {
X                    newlimit++ ;
X                    if (chunkv[newfrags] == NULL)  {
X                        nf = TRUE;
X                        }
X                    }
X                newfrags++ ;
X            }
X        }
X        hdr = (struct MemHeader *)hdr->mh_Node.ln_Succ ;
X        }
X    Permit() ;
X    length = frags ;
X    if (newlimit < frags)  length = newlimit ;
X    for (i = 0; i < length; i++)  {
X        chunkv[i] -= membase;   /* chunkv is now array offset from base   */
X        sizev[i] += chunkv[i];  /* and sizev is now address of array top  */
X        chunkv[i] = chunkv[i] / memseg;  /* this is the number of pixels  */
X        sizev[i] = sizev[i] / memseg;       /* and this is the top pixel  */
X        if (chunkv[i] < 0) chunkv[i] = 0 ;  /* we do some bounds checking */
X        if (sizev[i] < 0) sizev[i] = 0 ;
X        if (chunkv[i] >= barh) chunkv[i] = barh - 1 ;
X        if (sizev[i] >= barh) sizev[i] = barh - 1 ;
X        if (sizev[i] - chunkv[i] < 0)  sizev[i] = chunkv[i] ;
X        j = chunkv[i] ; /* from now on it will be less confusing if */
X        k = sizev[i] ;  /* we assign some variables for this stuff  */
X        if (sizev[i] - chunkv[i] == 0)  {
X            cell[j] = cell[j] & BLUP ;
X            }
X        else  {
X            for (l = j; l < k; l++)  {
X                cell[l] = cell[l] & BLKP ;
X                }
X            }
X        }
X    (void) memometer();
X    newsize = frags ;
X    while (newsize < newlimit)  {
X        newsize += EXTENSION ;
X        }
X    if (newlimit > frags)  {
X        (void) FreeMem(chunkv, (long)(sizeof(long) * frags));
X        if ((chunkv = (unsigned long *)AllocMem((long)sizeof(long) * newsize,
X                                        MEMF_PUBLIC)) == 0L )  {
X            log = log & C2 ;
X            }
X        (void) FreeMem(sizev, (long)(sizeof(long) * frags));
X        if ((sizev = (unsigned long *)AllocMem((long)sizeof(long) * newsize,
X                                        MEMF_PUBLIC)) == 0L ) {
X            (void) FreeMem(chunkv, (long)(sizeof(long) * newsize));
X            log = log & C4 ;
X            }
X        if (log != SOK)  {
X            wrack_sploot() ;
X            things_are_cool = FALSE ;
X            }
X        else frags = newsize ;
X        }
X}
X
Xmain() {
X    int i;
X    short wf;
X    long cmemseg;
X    long sfmemseg;
X    long fmemseg;
X    long membase;
X    long memseg;
X    long memsize;
X
X
X    log = 0 ;
X    if ((cell = (USHORT *)AllocMem((long)sizeof(USHORT) * BARS,
X                                        MEMF_PUBLIC)) != 0L ) log = log | S1;
X    if ((chunkv = (ULONG *)AllocMem((long)sizeof(ULONG) * STARTVAL,
X                                        MEMF_PUBLIC)) != 0L ) log = log | S2;
X    if ((sizev = (ULONG *)AllocMem((long)sizeof(ULONG) * STARTVAL,
X                                        MEMF_PUBLIC)) != 0L ) log = log | S4;
X    if ((csum = (ULONG *)AllocMem((long)sizeof(ULONG) * BARS,
X                                        MEMF_PUBLIC)) != 0L ) log = log | S8;
X    if ((oldcsum = (ULONG *)AllocMem((long)sizeof(ULONG) * BARS,
X                                        MEMF_PUBLIC)) != 0L ) log = log | SA;
X    if (log != SOK)  {
X        wrack_sploot() ;
X        Exit() ;
X        }
X    if ((IntuitionBase = (struct IntuitionBase *)OpenLibrary(
X            "intuition.library",33L)) != NULL &&
X            (window=OpenWindow(&newwindow)) != NULL)  {
X        if ((GfxBase = (struct GfxBase *)OpenLibrary(
X                "graphics.library", 0L)) != NULL)  { 
X            (void) initmenus();
X            /* rp = window->RPort ; */
X            wf = 0;
X            mode = p_mode ;
X            delayval = p_rate * 36 ;
X            cmemsize = p_chip << 10 ;
X            cmembase = p_chipa << 10 ;
X            sfmemsize = p_sf << 10 ;
X            sfmembase = p_sfa << 10 ;
X            if (p_fast >= 512)  fmemsize = p_fast << 10 ;
X            else fmemsize = p_fast << 20 ;
X            fmembase = p_fasta << 20 ;
X            while (things_are_cool == TRUE) {
X                cmemseg = cmemsize / barh ;
X                sfmemseg = sfmemsize / barh ;
X                fmemseg = fmemsize / barh ;
X                switch ( wf ) {
X                    case 0:
X                    x1 = LEFT ;
X                    membase = cmembase ;
X                    memseg = cmemseg ;
X                    memsize = cmemsize ;
X                    break;
X
X                    case 1:
X                    x1 = MIDDLE ;
X                    membase = sfmembase ;
X                    memseg = sfmemseg ;
X                    memsize = sfmemsize ;
X                    break;
X
X                    case 2:
X                    x1 = RIGHT ;
X                    membase = fmembase ;
X                    memseg = fmemseg ;
X                    memsize = fmemsize ;
X                    break;
X                    }
X                x2 = x1 + BARW ;
X                if (mode == TRUE)  {
X                    (void) updatewarps( wf, membase, memseg ) ;
X                    }
X                if (mode == FALSE)  {
X                    (void) updatescreen( wf, membase, memseg ) ;
X                    }
X                if (intsig == TRUE)  {
X                    handle_NEWSIZE() ;
X                    intsig = FALSE ;
X                    }
X                if (wf == 2)  {
X                    PrintIText(window->RPort,&f_text,RTEXT,0L) ;
X                    Delay(delayval) ;
X                    }
X                wf++ ;
X                if (wf >= 3)  wf = 0 ;
X                } /* end of while ( things_are_cool) */
X            wrack_sploot() ;
X            }
X        if (GfxBase)    CloseLibrary(GfxBase) ;
X        }
X    if (window)         CloseWindow(window) ;
X    if (IntuitionBase)  CloseLibrary(IntuitionBase) ;
X}
X_cli_parse() {}
X_wb_parse() {}
//END_OF_FILE
echo x - mminit3.c
sed 's/^X//' > mminit3.c << '//END_OF_FILE'
X/* : ai=0 bk=0 ts=8 */
X#include "mm.h"
X
X#define PROJMAX 3               /* number of project menu items */
X#define SETUPMAX 2              /* number of setup menu items */
X#define MODEMAX 2
X#define FREQMAX 4               /* number of frequency menu items */
X#define CHIPMAX 5               /* number of chip mem size menu items */
X#define CHIPAMAX 4              /* number of chip mem base addr menu items */
X#define SFMAX 4                 /* number of sf mem size menu items */
X#define SFAMAX 4                /* number of sf mem base addr menu items */
X#define FASTMAX 7               /* number of fast mem size menu items */
X#define FASTAMAX 8              /* number of fast mem base addr menu items */
X#define MAXMENU 9               /* total number of top level menus */
X
Xextern BOOL p_mode;             /* preset frags mode = 0, warps mode = 1 */
Xextern long p_rate;             /* preset sample interval, secs see menu */
Xextern long p_chip;             /* preset chip mem size, kbytes see menu */
Xextern long p_chipa;            /* preset chip mem address, kb  see menu */
Xextern long p_sf;               /* preset slowfast mem size, kb see menu */
Xextern long p_sfa;              /* preset slowfast mem addr, kb see menu */
Xextern long p_fast;             /* preset fast mem size, mbytes see menu */
Xextern long p_fasta;            /* preset fast mem addr, mbytes see menu */
X
X/******************************************************/
X/*    Structure declarations for the menu sections    */
X/******************************************************/
X
Xstruct   MenuItem ProjItem[PROJMAX];
Xstruct   IntuiText ProjText[PROJMAX];
Xstruct   MenuItem SetupItem[SETUPMAX];
Xstruct   IntuiText SetupText[SETUPMAX];
Xstruct   MenuItem ModeItem[MODEMAX];
Xstruct   IntuiText ModeText[MODEMAX];
Xstruct   MenuItem FreqItem[FREQMAX];
Xstruct   IntuiText FreqText[FREQMAX];
Xstruct   MenuItem ChipItem[CHIPMAX];
Xstruct   IntuiText ChipText[CHIPMAX];
Xstruct   MenuItem ChipAItem[CHIPAMAX];
Xstruct   IntuiText ChipAText[CHIPAMAX];
Xstruct   MenuItem SFItem[SFMAX];
Xstruct   IntuiText SFText[SFMAX];
Xstruct   MenuItem SFAItem[SFAMAX];
Xstruct   IntuiText SFAText[SFAMAX];
Xstruct   MenuItem FastItem[FASTMAX];
Xstruct   IntuiText FastText[FASTMAX];
Xstruct   MenuItem FastAItem[FASTAMAX];
Xstruct   IntuiText FastAText[FASTAMAX];
Xstruct   Menu menu[MAXMENU];
X
X/*****************************************************************/
X/*    The following function initializes the structure arrays    */
X/*    needed to provide the Project menu topic.                  */
X/*    this was left retro-compatible with Manx 3.4a (nplus1)     */
X/*****************************************************************/
Xvoid InitProjItems()
X    {
X    int       n,nplus1;
X
X/* initialize each menu item and IntuiText with loop */
Xfor( n=0; n<PROJMAX; n++ )
X    {
X    nplus1 = n + 1;
X    ProjItem[n].NextItem = &ProjItem[nplus1];
X    ProjItem[n].LeftEdge = 0;
X    ProjItem[n].TopEdge = 9 * n;
X    ProjItem[n].Width = 64;
X    ProjItem[n].Height = 9;
X    ProjItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP;
X    ProjItem[n].MutualExclude = 0;
X    ProjItem[n].ItemFill = (APTR)&ProjText[n];
X    ProjItem[n].SelectFill = NULL;
X    ProjItem[n].Command = 0;
X    ProjItem[n].SubItem = NULL;
X    ProjItem[n].NextSelect = 0;
X
X    ProjText[n].FrontPen = 0;
X    ProjText[n].BackPen = 1;
X    ProjText[n].DrawMode = JAM2;/* render in fore and background */
X    ProjText[n].LeftEdge = 0;
X    ProjText[n].TopEdge = 1;
X    ProjText[n].ITextFont = NULL;
X    ProjText[n].NextText = NULL;
X    }
XProjItem[PROJMAX-1].NextItem = NULL;
X
X/* initialize text for specific menu items */
X
XProjText[0].IText = (UBYTE *)"Front";
XProjText[1].IText = (UBYTE *)"Back";
XProjText[2].IText = (UBYTE *)"Close";
X}
X
X/*****************************************************************/
X/*    The following initializes the structure arrays             */
X/*   needed to provide the Setup menu topic.                     */
X/*****************************************************************/
X
Xvoid InitSetupItems()
X    {
X    int       n,nplus1;
X
X/* initialize each menu item and IntuiText with loop */
Xfor( n=0; n<SETUPMAX; n++ )
X    {
X    nplus1 = n + 1;
X    SetupItem[n].NextItem = &SetupItem[nplus1];
X    SetupItem[n].LeftEdge = 0;
X    SetupItem[n].TopEdge = 9 * n;
X    SetupItem[n].Width = 44;
X    SetupItem[n].Height = 9;
X    SetupItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP ;
X    SetupItem[n].MutualExclude = 0;
X    SetupItem[n].ItemFill = (APTR)&SetupText[n];
X    SetupItem[n].SelectFill = NULL;
X    SetupItem[n].Command = 0;
X    SetupItem[n].NextSelect = 0;
X
X    SetupText[n].FrontPen = 0;
X    SetupText[n].BackPen = 1;
X    SetupText[n].DrawMode = JAM2;    
X    SetupText[n].LeftEdge = 0;
X    SetupText[n].TopEdge = 1;
X    SetupText[n].ITextFont = NULL;
X    SetupText[n].NextText = NULL;
X    }
XSetupItem[SETUPMAX-1].NextItem = NULL;
X
XSetupText[0].IText = (UBYTE *)"Mode";
XSetupItem[0].SubItem = ModeItem;
XSetupText[1].IText = (UBYTE *)"Freq";
XSetupItem[1].SubItem = FreqItem;
X
X/*****************************************************************/
X/*    The following initializes the structure arrays             */
X/*   needed to provide the Mode submenu topic.                   */
X/*****************************************************************/
X
Xfor( n=0; n<MODEMAX; n++ )
X    {
X    nplus1 = n + 1;
X    ModeItem[n].NextItem = &ModeItem[nplus1];
X    ModeItem[n].LeftEdge = 38;
X    ModeItem[n].TopEdge = 9 * n;
X    ModeItem[n].Width = 72;
X    ModeItem[n].Height = 9;
X    ModeItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
X    ModeItem[n].MutualExclude = (~(1 << n));
X    ModeItem[n].ItemFill = (APTR)&ModeText[n];
X    ModeItem[n].SelectFill = NULL;
X    ModeItem[n].Command = 0;
X    ModeItem[n].SubItem = NULL;
X    ModeItem[n].NextSelect = 0;
X
X    ModeText[n].FrontPen = 0;
X    ModeText[n].BackPen = 1;
X    ModeText[n].DrawMode = JAM2;     /* render in fore and background */
X    ModeText[n].LeftEdge = 0;
X    ModeText[n].TopEdge = 1;
X    ModeText[n].ITextFont = NULL;
X    ModeText[n].NextText = NULL;
X    }
XModeItem[MODEMAX-1].NextItem = NULL;
X
X/* select mode subitem checked */
Xswitch (p_mode) {
X    case 0:     n = 0; break;
X    case 1:     n = 1; break;
X    default:    n = 1; p_mode = FALSE;
X    }
XModeItem[n].Flags |= CHECKED;
X
X/* initialize text for specific submenu items */
XModeText[0].IText = (UBYTE *)"   Frags";
XModeText[1].IText = (UBYTE *)"   Warps";
X
X/*****************************************************************/
X/*    The following initializes the structure arrays             */
X/*   needed to provide the Freq submenu topic.                   */
X/*****************************************************************/
X
Xfor( n=0; n<FREQMAX; n++ )
X    {
X    nplus1 = n + 1;
X    FreqItem[n].NextItem = &FreqItem[nplus1];
X    FreqItem[n].LeftEdge = 38;
X    FreqItem[n].TopEdge = 9 * n;
X    FreqItem[n].Width = 88;
X    FreqItem[n].Height = 9;
X    FreqItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
X    FreqItem[n].MutualExclude = (~(1 << n));
X    FreqItem[n].ItemFill = (APTR)&FreqText[n];
X    FreqItem[n].SelectFill = NULL;
X    FreqItem[n].Command = 0;
X    FreqItem[n].SubItem = NULL;
X    FreqItem[n].NextSelect = 0;
X
X    FreqText[n].FrontPen = 0;
X    FreqText[n].BackPen = 1;
X    FreqText[n].DrawMode = JAM2;     /* render in fore and background */
X    FreqText[n].LeftEdge = 0;
X    FreqText[n].TopEdge = 1;
X    FreqText[n].ITextFont = NULL;
X    FreqText[n].NextText = NULL;
X    }
XFreqItem[FREQMAX-1].NextItem = NULL;
X
X/* select frequency item checked */
Xswitch (p_rate) {
X    case 1:     n = 0; break;
X    case 2:     n = 1; break;
X    case 5:     n = 2; break;
X    case 10:    n = 3; break;
X    default:    n = 1; p_rate = 2;
X    }
XFreqItem[n].Flags |= CHECKED;
X
X/* initialize text for specific menu items */
XFreqText[0].IText = (UBYTE *)"    1 Sec ";
XFreqText[1].IText = (UBYTE *)"    2 Secs";
XFreqText[2].IText = (UBYTE *)"    5 Secs";
XFreqText[3].IText = (UBYTE *)"   10 Secs";
X}
X
X/*****************************************************************/
X/*    The following initializes the structure arrays             */
X/*   needed to provide the Chip Mem Size menu topic.             */
X/*****************************************************************/
X
Xvoid InitChipItems()
X    {
X    int       n,nplus1;
X
X/* initialize each menu item and IntuiText with loop */
Xfor( n=0; n<CHIPMAX; n++ )
X    {
X    nplus1 = n + 1;
X    ChipItem[n].NextItem = &ChipItem[nplus1];
X    ChipItem[n].LeftEdge = 0;
X    ChipItem[n].TopEdge = 9 * n;
X    ChipItem[n].Width = 80;
X    ChipItem[n].Height = 9;
X    ChipItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
X    ChipItem[n].MutualExclude = (~(1 << n));
X    ChipItem[n].ItemFill = (APTR)&ChipText[n];
X    ChipItem[n].SelectFill = NULL;
X    ChipItem[n].Command = 0;
X    ChipItem[n].NextSelect = 0;
X
X    ChipText[n].FrontPen = 0;
X    ChipText[n].BackPen = 1;
X    ChipText[n].DrawMode = JAM2;    
X    ChipText[n].LeftEdge = 0;
X    ChipText[n].TopEdge = 1;
X    ChipText[n].ITextFont = NULL;
X    ChipText[n].NextText = NULL;
X    }
XChipItem[CHIPMAX-1].NextItem = NULL;
X
X/* select chip mem size item checked */
Xswitch (p_chip) {
X    case    0:     n = 0; break;
X    case  256:     n = 1; break;
X    case  512:     n = 2; break;
X    case 1024:     n = 3; break;
X    case 2048:     n = 4; break;
X    default:       n = 2; p_chip = 512;
X    }
XChipItem[n].Flags |= CHECKED;
X
XChipText[0].IText = (UBYTE *)"   NONE";
XChipText[1].IText = (UBYTE *)"   256K";
XChipText[2].IText = (UBYTE *)"   512K";
XChipText[3].IText = (UBYTE *)"   1 MB";
XChipText[4].IText = (UBYTE *)"   2 MB";
X}
X
X/*****************************************************************/
X/*    The following initializes the structure arrays             */
X/*   needed to provide the Chip Base Addr menu topic.            */
X/*****************************************************************/
X
Xvoid InitChipAItems()
X    {
X    int       n,nplus1;
X
X/* initialize each menu item and IntuiText with loop */
Xfor( n=0; n<CHIPAMAX; n++ )
X    {
X    nplus1 = n + 1;
X    ChipAItem[n].NextItem = &ChipAItem[nplus1];
X    ChipAItem[n].LeftEdge = 0;
X    ChipAItem[n].TopEdge = 9 * n;
X    ChipAItem[n].Width = 80;
X    ChipAItem[n].Height = 9;
X    ChipAItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
X    ChipAItem[n].MutualExclude = (~(1 << n));
X    ChipAItem[n].ItemFill = (APTR)&ChipAText[n];
X    ChipAItem[n].SelectFill = NULL;
X    ChipAItem[n].Command = 0;
X    ChipAItem[n].NextSelect = 0;
X
X    ChipAText[n].FrontPen = 0;
X    ChipAText[n].BackPen = 1;
X    ChipAText[n].DrawMode = JAM2;    
X    ChipAText[n].LeftEdge = 0;
X    ChipAText[n].TopEdge = 1;
X    ChipAText[n].ITextFont = NULL;
X    ChipAText[n].NextText = NULL;
X    }
XChipAItem[CHIPAMAX-1].NextItem = NULL;
X
X/* select chip base address item checked */
Xswitch (p_chipa) {
X    case    0:     n = 0; break;
X    case  256:     n = 1; break;
X    case  512:     n = 2; break;
X    case 1024:     n = 3; break;
X    default:       n = 0; p_chipa = 0;
X    }
XChipAItem[n].Flags |= CHECKED;
X
XChipAText[0].IText = (UBYTE *)"   @   0K";
XChipAText[1].IText = (UBYTE *)"   @ 256K";
XChipAText[2].IText = (UBYTE *)"   @ 512K";
XChipAText[3].IText = (UBYTE *)"   @ 1 MB";
X}
X
X/*****************************************************************/
X/*    The following initializes the structure arrays             */
X/*   needed to provide the Slow Fast Mem Size menu topic.        */
X/*****************************************************************/
X
Xvoid InitSFItems()
X    {
X    int       n,nplus1;
X
X/* initialize each menu item and IntuiText with loop */
Xfor( n=0; n<SFMAX; n++ )
X    {
X    nplus1 = n + 1;
X    SFItem[n].NextItem = &SFItem[nplus1];
X    SFItem[n].LeftEdge = 0;
X    SFItem[n].TopEdge = 9 * n;
X    SFItem[n].Width = 80;
X    SFItem[n].Height = 9;
X    SFItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
X    SFItem[n].MutualExclude = (~(1 << n));
X    SFItem[n].ItemFill = (APTR)&SFText[n];
X    SFItem[n].SelectFill = NULL;
X    SFItem[n].Command = 0;
X    SFItem[n].NextSelect = 0;
X
X    SFText[n].FrontPen = 0;
X    SFText[n].BackPen = 1;
X    SFText[n].DrawMode = JAM2;    
X    SFText[n].LeftEdge = 0;
X    SFText[n].TopEdge = 1;
X    SFText[n].ITextFont = NULL;
X    SFText[n].NextText = NULL;
X    }
XSFItem[SFMAX-1].NextItem = NULL;
X
X/* select slow fast mem size item checked */
Xswitch (p_sf) {
X    case    0:     n = 0; break;
X    case  512:     n = 1; break;
X    case 1024:     n = 2; break;
X    case 1536:     n = 3; break;
X    default:       n = 1; p_sf = 512;
X    }
XSFItem[n].Flags |= CHECKED;
X
XSFText[0].IText = (UBYTE *)"   NONE  ";
XSFText[1].IText = (UBYTE *)"   0.5 MB";
XSFText[2].IText = (UBYTE *)"   1   MB";
XSFText[3].IText = (UBYTE *)"   1.5 MB";
X}
X
X/*****************************************************************/
X/*    The following initializes the structure arrays             */
X/*   needed to provide the Slow Fast Mem Base Addr menu topic.   */
X/*****************************************************************/
X
Xvoid InitSFAItems()
X    {
X    int       n,nplus1;
X
X/* initialize each menu item and IntuiText with loop */
Xfor( n=0; n<SFAMAX; n++ )
X    {
X    nplus1 = n + 1;
X    SFAItem[n].NextItem = &SFAItem[nplus1];
X    SFAItem[n].LeftEdge = 0;
X    SFAItem[n].TopEdge = 9 * n;
X    SFAItem[n].Width = 104;
X    SFAItem[n].Height = 9;
X    SFAItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
X    SFAItem[n].MutualExclude = (~(1 << n));
X    SFAItem[n].ItemFill = (APTR)&SFAText[n];
X    SFAItem[n].SelectFill = NULL;
X    SFAItem[n].Command = 0;
X    SFAItem[n].NextSelect = 0;
X
X    SFAText[n].FrontPen = 0;
X    SFAText[n].BackPen = 1;
X    SFAText[n].DrawMode = JAM2;    
X    SFAText[n].LeftEdge = 0;
X    SFAText[n].TopEdge = 1;
X    SFAText[n].ITextFont = NULL;
X    SFAText[n].NextText = NULL;
X    }
XSFAItem[SFAMAX-1].NextItem = NULL;
X
X/* select slow fast mem base address item checked */
Xswitch (p_sfa) {
X    case 12288:     n = 0; break;               /* 0x3000 kb = 12   mb */
X    case 12800:     n = 1; break;               /* 0x3200 kb = 12.5 mb */
X    case 13312:     n = 2; break;               /* 0x3400 kb = 13   mb */
X    case 13824:     n = 3; break;               /* 0x3600 kb = 13.5 mb */
X    default:        n = 0; p_sfa = 12288;
X    }
XSFAItem[n].Flags |= CHECKED;
X
XSFAText[0].IText = (UBYTE *)"   @ C.0 Meg";
XSFAText[1].IText = (UBYTE *)"   @ C.8 Meg";
XSFAText[2].IText = (UBYTE *)"   @ D.0 Meg";
XSFAText[3].IText = (UBYTE *)"   @ D.8 Meg";
X}
X
X/*****************************************************************/
X/*    The following initializes the structure arrays             */
X/*   needed to provide the Fast Mem Size menu topic.             */
X/*****************************************************************/
X
Xvoid InitFastItems()
X    {
X    int       n,nplus1;
X
X/* initialize each menu item and IntuiText with loop */
Xfor( n=0; n<FASTMAX; n++ )
X    {
X    nplus1 = n + 1;
X    FastItem[n].NextItem = &FastItem[nplus1];
X    FastItem[n].LeftEdge = 0;
X    FastItem[n].TopEdge = 9 * n;
X    FastItem[n].Width = 80;
X    FastItem[n].Height = 9;
X    FastItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
X    FastItem[n].MutualExclude = (~(1 << n));
X    FastItem[n].ItemFill = (APTR)&FastText[n];
X    FastItem[n].SelectFill = NULL;
X    FastItem[n].Command = 0;
X    FastItem[n].NextSelect = 0;
X
X    FastText[n].FrontPen = 0;
X    FastText[n].BackPen = 1;
X    FastText[n].DrawMode = JAM2;    
X    FastText[n].LeftEdge = 0;
X    FastText[n].TopEdge = 1;
X    FastText[n].ITextFont = NULL;
X    FastText[n].NextText = NULL;
X    }
XFastItem[FASTMAX-1].NextItem = NULL;
X
X/* select fast mem size item checked */
Xswitch (p_fast) {
X    case 0:       n = 0; break;
X    case 512:     n = 1; break;
X    case 1:       n = 2; break;
X    case 2:       n = 3; break;
X    case 4:       n = 4; break;
X    case 6:       n = 5; break;
X    case 8:       n = 6; break;
X    default:      n = 3; p_fast = 2;
X    }
XFastItem[n].Flags |= CHECKED;
X
XFastText[0].IText = (UBYTE *)"   NONE";
XFastText[1].IText = (UBYTE *)"   512K";
XFastText[2].IText = (UBYTE *)"   1 MB";
XFastText[3].IText = (UBYTE *)"   2 MB";
XFastText[4].IText = (UBYTE *)"   4 MB";
XFastText[5].IText = (UBYTE *)"   6 MB";
XFastText[6].IText = (UBYTE *)"   8 MB";
X}
X
X/*****************************************************************/
X/*    The following initializes the structure arrays             */
X/*   needed to provide the Fast Mem Base Addr menu topic.        */
X/*****************************************************************/
X
Xvoid InitFastAItems()
X    {
X    int       n,nplus1;
X
X/* initialize each menu item and IntuiText with loop */
Xfor( n=0; n<FASTAMAX; n++ )
X    {
X    nplus1 = n + 1;
X    FastAItem[n].NextItem = &FastAItem[nplus1];
X    FastAItem[n].LeftEdge = 0;
X    FastAItem[n].TopEdge = 9 * n;
X    FastAItem[n].Width = 80;
X    FastAItem[n].Height = 9;
X    FastAItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
X    FastAItem[n].MutualExclude = (~(1 << n));
X    FastAItem[n].ItemFill = (APTR)&FastAText[n];
X    FastAItem[n].SelectFill = NULL;
X    FastAItem[n].Command = 0;
X    FastAItem[n].NextSelect = 0;
X
X    FastAText[n].FrontPen = 0;
X    FastAText[n].BackPen = 1;
X    FastAText[n].DrawMode = JAM2;    
X    FastAText[n].LeftEdge = 0;
X    FastAText[n].TopEdge = 1;
X    FastAText[n].ITextFont = NULL;
X    FastAText[n].NextText = NULL;
X    }
XFastAItem[FASTAMAX-1].NextItem = NULL;
X
X/* select fast base address item checked */
Xswitch (p_fasta) {
X    case 2:     n = 0; break;
X    case 3:     n = 1; break;
X    case 4:     n = 2; break;
X    case 5:     n = 3; break;
X    case 6:     n = 4; break;
X    case 7:     n = 5; break;
X    case 8:     n = 6; break;
X    case 9:     n = 7; break;
X    default:    n = 0; p_fasta = 2;
X    }
XFastAItem[n].Flags |= CHECKED;
X
XFastAText[0].IText = (UBYTE *)"   @ 2 M";
XFastAText[1].IText = (UBYTE *)"   @ 3 M";
XFastAText[2].IText = (UBYTE *)"   @ 4 M";
XFastAText[3].IText = (UBYTE *)"   @ 5 M";
XFastAText[4].IText = (UBYTE *)"   @ 6 M";
XFastAText[5].IText = (UBYTE *)"   @ 7 M";
XFastAText[6].IText = (UBYTE *)"   @ 8 M";
XFastAText[7].IText = (UBYTE *)"   @ 9 M";
X}
X
X/****************************************************************/
X/*   The following function inits the Menu structure array with */
X/*  appropriate values for our simple menu.  Review the manual  */
X/*  if you need to know what each value means.                  */
X/****************************************************************/
Xvoid InitMenu()
X{
Xmenu[0].NextMenu = &menu[1];
Xmenu[0].LeftEdge = 4;
Xmenu[0].TopEdge = 0;
Xmenu[0].Width = 64;
Xmenu[0].Height = 10;
Xmenu[0].Flags = MENUENABLED;
Xmenu[0].MenuName = "Project";        /* text for menu-bar display */
Xmenu[0].FirstItem = &ProjItem[0]; /* pointer to first item in list */
X
Xmenu[1].NextMenu = &menu[2];
Xmenu[1].LeftEdge = 68;
Xmenu[1].TopEdge = 0;
Xmenu[1].Width = 48;
Xmenu[1].Height = 10;
Xmenu[1].Flags = MENUENABLED;
Xmenu[1].MenuName = "Setup";   /* text for menu-bar display */
Xmenu[1].FirstItem = &SetupItem[0];  /* pointer to first item in list */
X
Xmenu[2].NextMenu = &menu[3];
Xmenu[2].LeftEdge = 180;
Xmenu[2].TopEdge = 0;
Xmenu[2].Width = 80;
Xmenu[2].Height = 10;
Xmenu[2].Flags = MENUENABLED;
Xmenu[2].MenuName = "Chip Size";        /* text for menu-bar display */
Xmenu[2].FirstItem = &ChipItem[0]; /* pointer to first item in list */
X
Xmenu[3].NextMenu = &menu[4];
Xmenu[3].LeftEdge = 260;
Xmenu[3].TopEdge = 0;
Xmenu[3].Width = 80;
Xmenu[3].Height = 10;
Xmenu[3].Flags = MENUENABLED;
Xmenu[3].MenuName = "Chip Addr";        /* text for menu-bar display */
Xmenu[3].FirstItem = &ChipAItem[0]; /* pointer to first item in list */
X
Xmenu[4].NextMenu = &menu[5];
Xmenu[4].LeftEdge = 340;
Xmenu[4].TopEdge = 0;
Xmenu[4].Width = 64;
Xmenu[4].Height = 10;
Xmenu[4].Flags = MENUENABLED;
Xmenu[4].MenuName = "SF Size";        /* text for menu-bar display */
Xmenu[4].FirstItem = &SFItem[0]; /* pointer to first item in list */
X
Xmenu[5].NextMenu = &menu[6];
Xmenu[5].LeftEdge = 404;
Xmenu[5].TopEdge = 0;
Xmenu[5].Width = 64;
Xmenu[5].Height = 10;
Xmenu[5].Flags = MENUENABLED;
Xmenu[5].MenuName = "SF Addr";        /* text for menu-bar display */
Xmenu[5].FirstItem = &SFAItem[0]; /* pointer to first item in list */
X
Xmenu[6].NextMenu = &menu[7];
Xmenu[6].LeftEdge = 468;
Xmenu[6].TopEdge = 0;
Xmenu[6].Width = 80;
Xmenu[6].Height = 10;
Xmenu[6].Flags = MENUENABLED;
Xmenu[6].MenuName = "Fast Size";      /* text for menu-bar display */
Xmenu[6].FirstItem = &FastItem[0]; /* pointer to first item in list */
X
Xmenu[7].NextMenu = NULL;
Xmenu[7].LeftEdge = 548;
Xmenu[7].TopEdge = 0;
Xmenu[7].Width = 80;
Xmenu[7].Height = 10;
Xmenu[7].Flags = MENUENABLED;
Xmenu[7].MenuName = "Fast Addr";        /* text for menu-bar display */
Xmenu[7].FirstItem = &FastAItem[0]; /* pointer to first item in list */
X
X}
X
Xvoid StartMenus()
X{
XSetMenuStrip(window,&menu[0]);
X}
//END_OF_FILE
echo "End of archive."
# end of archive.
exit 0