#include <exec/types.h>
#include <graphics/view.h>
#include <intuition/intuition.h>
#include <functions.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>

extern struct Window *window;
extern ULONG RangeRand();
extern struct TextAttr font;

cycle(color) int color;
{   struct ColorMap *cm;
    struct ViewPort *vp;
    UWORD orig, r, g, b, ro, go, bo;
    int i;

    vp = ViewPortAddress( window );
    cm = vp -> ColorMap;

    orig = GetRGB4( cm, (LONG) color );
    b = (bo = (orig     ) & 15);
    g = (go = (orig >> 4) & 15);
    r = (ro = (orig >> 8) & 15);

    for (i=0; i<1000; i++) {
        r = RangeRand(2L) * 15;
        g = RangeRand(2L) * 15;
        b = RangeRand(2L) * 15;
        SetRGB4(vp,(LONG)color,(LONG)r,(LONG)g,(LONG)b);
        }
    SetRGB4(vp,(LONG)color,(LONG)ro,(LONG)go,(LONG)bo);
    }

#define reqW  544
#define reqH  152
#define centerX(chars) (reqW/2 - (chars)*8/2)
#define centerXright(chars) (reqW - 111 - (chars)*8/2)
#define centerXleft(chars) (111 - (chars)*8/2)

SHORT reqborderXY[] = { 2,1, 541,1, 541,150, 2,150, 2,1 };

struct Border reqborder = {
        0,0,        /* LeftEdge, TopEdge */
        1,1,        /* FrontPen, BackPen */
        JAM1,       /* DrawMode */
        5,          /* Count */
        reqborderXY,/* SHORT *XY */
        NULL,       /* NextBorder */
        };

SHORT gadborderXY[] = { 2,1, 97,1, 97,28, 2,28, 2,1 };

struct Border gadborder = {
        2,1,        /* LeftEdge, TopEdge */
        1,2,        /* FrontPen, BackPen */
        JAM2,       /* DrawMode */
        5,          /* Count */
        gadborderXY,   /* SHORT *XY */
        NULL,       /* NextBorder */
        };

struct IntuiText gadtext = {
        1,2,      /* FrontPen, BackPen */
        JAM1,     /* DrawMode */
        18,11,    /* LeftEdge, TopEdge */
        &font,     /* TextAttr *ITextFont */
        (UBYTE *) "Continue", /* IText */
        NULL,     /* struct IntuiText *NextText */
        };

struct Gadget aboutgad = {
        NULL,          /* NextGadget */
        222,117,100,30,  /* LeftEdge, TopEdge, Width, Height */
        GADGHNONE,         /* Flags */
        ENDGADGET | TOGGLESELECT,  /* Activation Flags */
        REQGADGET | BOOLGADGET, /* GadgetType */
        (APTR)&gadborder,       /* GadgetRender */
        NULL,       /* SelectRender */
        &gadtext,       /* GadgetText   */
        NULL,       /* MutualExclude */
        NULL,       /* SpecialInfo  */
        0,          /* GadgetID     */
        NULL,       /* UserData     */
        };

struct IntuiText  ab_txt8= {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        20,102,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "Comments and suggestions are welcome.", /* IText */
        NULL,   /* struct IntuiText *NextText */
        };
struct IntuiText  ab_txt7= {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        20,92,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "writing it.  Please feel free to share it with your friends.", /* IText */
        &ab_txt8,   /* struct IntuiText *NextText */
        };
struct IntuiText  ab_txt6= {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        20,82,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "   I hope you enjoy playing this game as much as I enjoyed", /* IText */
        &ab_txt7,   /* struct IntuiText *NextText */
        };
struct IntuiText  ab_inst3= {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        20,68,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "give you a hint.  Select new mazes from the menu.  Good luck!", /* IText */
        &ab_txt6,   /* struct IntuiText *NextText */
        };
struct IntuiText  ab_inst2= {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        20,59,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "red spot to the dark red spot.  The left mouse button will", /* IText */
        &ab_inst3,   /* struct IntuiText *NextText */
        };
struct IntuiText  ab_inst1= {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        20,50,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "   Move the mouse pointer through the maze from the bright", /* IText */
        &ab_inst2,   /* struct IntuiText *NextText */
        };
struct IntuiText  ab_left2= {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        centerXleft(19),120,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "Usenet Distribution", /* IText */
        &ab_inst1,   /* struct IntuiText *NextText */
        };
struct IntuiText  ab_left1= {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        centerXleft(12),130,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "Spring, 1989", /* IText */
        &ab_left2,   /* struct IntuiText *NextText */
        };
struct IntuiText  ab_txt5= {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        centerXright(24),140,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "utoddl@ecsvax.uncecs.edu", /* IText */
        &ab_left1,   /* struct IntuiText *NextText */
        };
struct IntuiText  ab_txt4= {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        centerXright(20),130,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "utoddl@ecsvax.BITNET", /* IText */
        &ab_txt5,   /* struct IntuiText *NextText */
        };
struct IntuiText  ab_txt3= {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        centerXright(21),120,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "Author: Todd M. Lewis", /* IText */
        &ab_txt4,   /* struct IntuiText *NextText */
        };
struct IntuiText  ab_txt2= {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        centerX(32),35,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "The Disk Magazine for the Amiga.", /* IText */
        &ab_txt3,   /* struct IntuiText *NextText */
        };
struct IntuiText  ab_txt1= {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        centerX(30),25,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "First distributed on JUMPDISK,", /* IText */
        &ab_txt2,   /* struct IntuiText *NextText */
        };
struct IntuiText  ab_txt0= {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        centerX(33),15,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "Copyright (c) 1988, Todd M. Lewis", /* IText */
        &ab_txt1,   /* struct IntuiText *NextText */
        };
struct IntuiText firsttext = {
        3,2,    /* FrontPen, BackPen */
        JAM1,   /* DrawMode */
        centerX(27),6,    /* LeftEdge, TopEdge */
        &font,   /* TextAttr *ITextFont */
        (UBYTE *) "TML's AmigaMaze version 1.2", /* IText */
        &ab_txt0,   /* struct IntuiText *NextText */
        };

struct Requester aboutreq;

about()
{   struct IntuiMessage *msg;
    int class;

    InitRequester( &aboutreq );

    aboutreq.LeftEdge   = 4;
    aboutreq.TopEdge    = 15;
    aboutreq.Width      = reqW;
    aboutreq.Height     = reqH;
    aboutreq.ReqGadget  = &aboutgad;
    aboutreq.ReqText    = &firsttext;
    aboutreq.ReqBorder  = &reqborder;
    aboutreq.BackFill   = 2;      /* BLACK */

    if (Request( &aboutreq, window )) {
       do {
             Wait( 1L << window->UserPort->mp_SigBit );
             while (msg = (struct IntuiMessage *)GetMsg( window->UserPort )) {
                 class = msg->Class;
                 ReplyMsg(msg);
                 }
             } while ( class != REQCLEAR );
       }
   }

