page%swap@Sun.COM (Bob Page) (06/21/89)
Submitted-by: kevin@uts.amdahl.com (Kevin Clague) Posting-number: Volume 89, Issue 153 Archive-name: graphics/mandelv20.2 # This is a shell archive. # Remove anything above and including the cut line. # Then run the rest of the file through 'sh'. # Unpacked files will be owned by you and have default permissions. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: SHell ARchive # Run the following text through 'sh' to create: # cycle.c # cycleii.c # disp.c # This is archive 2 of a 9-part kit. # This archive created: Tue Jun 20 20:45:27 1989 echo "extracting cycle.c" sed 's/^X//' << \SHAR_EOF > cycle.c X/* X * MandelVroom 2.0 X * X * (c) Copyright 1987,1989 Kevin L. Clague, San Jose, CA X * X * All rights reserved. X * X * Permission is hereby granted to distribute this program's source X * executable, and documentation for non-comercial purposes, so long as the X * copyright notices are not removed from the sources, executable or X * documentation. This program may not be distributed for a profit without X * the express written consent of the author Kevin L. Clague. X * X * This program is not in the public domain. X * X * Fred Fish is expressly granted permission to distribute this program's X * source and executable as part of the "Fred Fish freely redistributable X * Amiga software library." X * X * Permission is expressly granted for this program and it's source to be X * distributed as part of the Amicus Amiga software disks, and the X * First Amiga User Group's Hot Mix disks. X * X * contents: this file contains the code to open and close the color X * cycling tool. It also contains the functions that implement the color X * cycling commands. X */ X X#include "mandp.h" X#include <ctype.h> X X#define PENLEFT 8 X#define PENTOP 15 X XUBYTE CycleOpen; X X/* X * Holder for Allocated color potentiometer gadgets. X */ Xstruct Gadget *SpeedPot; Xstruct Gadget *DirGadget; Xstruct Gadget *CycleOnGadget; Xstruct Gadget *CycleOffGadget; X Xstruct Window *CycWind; X Xstruct NewWindow NewCyc = { X 128,70, /* start position */ X 164,80, /* width, height */ X (UBYTE) 0, (UBYTE) -1, /* detail pen, block pen */ X NULL, /* IDCMP flags */ X /* MandWind flags */ X WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH | NOCAREREFRESH | SMART_REFRESH, X (struct Gadget *) NULL, /* first gadget */ X (struct Image *) NULL, /* user checkmark */ X (UBYTE *) "Cycling", /* window title */ X (struct Screen *) NULL, /* pointer to screen */ X (struct BitMap *) NULL, /* pointer to superbitmap */ X 80,80,80,80, /* sizing */ X CUSTOMSCREEN /* type of screen */ X }; X Xint EditRange; Xint RangeFirstPen; X XSlideSpeedCmd(Msg) X struct IntuiMessage *Msg; X{ X struct Gadget *gadget; X X gadget = (struct Gadget *) Msg->IAddress; X X switch( Msg->Class ) { X X case GADGETDOWN: /* Start Speed slide */ X if (CurPict->CycleOn == 0) X CreateCycle(); X ModifyIDCMP(CycWind,(long) CycWind->IDCMPFlags | MOUSEMOVE); X State = SLIDESPEEDSTATE; X break; X X case MOUSEMOVE: /* change the speed */ X SetSpeed(); X break; X X case GADGETUP: /* Stop Speed slide */ X if (CurPict->CycleOn == 0) { X KillCycle(); X LoadRGB4(vp, CurPict->RGBs, Num_vp_Colors); X } X SetSpeed(); X ModifyIDCMP(CycWind,(long) CycWind->IDCMPFlags & ~MOUSEMOVE); X State = IDLESTATE; X break; X } X} X XCycleRangeCmd(Msg) X struct IntuiMessage *Msg; X{ X struct Gadget *gadget; X int id; X X /* Need contour selection to complete */ X X gadget = (struct Gadget *) Msg->IAddress; X id = gadget->GadgetID; X X if (Msg->Class == GADGETDOWN) { X if (id == CYCRANGE) { X X StopCycle(); X X /* Color Palette command picks up the finish of the range cmd*/ X X if (CurPen < Num_vp_Colors) { X SetToPointer(); X RangeFirstPen = CurPen; X State = CYCLERANGESTATE; X } else { X DispErrMsg("Can't set color cycle with hafbrite pens",0); X } X } else X if (WIND_TYPE(id) == PALTYPE && GADG_TYPE(id) == PALPENS) { X X FinishRangeCmd(GADG_NUM(id)); X State = IDLESTATE; X } X } X} X XToggleDirCmd(Msg) X struct IntuiMessage *Msg; X{ X struct Gadget *gadget = (struct Gadget *) Msg->IAddress; X X StopCycle(); X X /* Set Direction into current cycle info structure */ X X if (gadget->Flags & SELECTED) { X CurPict->Crngs[ EditRange ].active &= ~REVERSE; X } else { X CurPict->Crngs[ EditRange ].active |= REVERSE; X } X State = IDLESTATE; X} X XCycleOnOffCmd(Msg) X struct IntuiMessage *Msg; X{ X if (CurPict == NULL) X return; X X if (CurPict->CycleOn) { X X StopCycle(); X } else { X X CreateCycle(); X CurPict->CycleOn = 1; X SetOnString(1); X } X State = IDLESTATE; X} X XStopCycle() X{ X if (CurPict->CycleOn == 1) { X KillCycle(); X LoadRGB4(vp, CurPict->RGBs, Num_vp_Colors); X CurPict->CycleOn = 0; X SetOnString( 0 ); X } X} X XSelRangeCmd(Msg) X struct IntuiMessage *Msg; X{ X struct Gadget *gadget = (struct Gadget *) Msg->IAddress; X int id = gadget->GadgetID; X int newpen; X static int end; X X if (WIND_TYPE(id) == CYCTYPE && GADG_TYPE(id) == CYCRNUMS) { X X EditRange = GADG_NUM(id); X X StopCycle(); X X /* move current pen to this range's first pen */ X X BoxPen( CurPen, NORMALPEN ); X X /* toggle endpoint to display */ X X if (end ^= 1) { X CurPen = CurPict->Crngs[ EditRange ].low; X } else { X CurPen = CurPict->Crngs[ EditRange ].high; X } X X BoxPen( CurPen, MEDIUMPEN ); X X ModifySpeedPot(); X X SetDirGadget( CurPict ); X X ExcludeGadgets( gadget ); X } X} X XSetDirGadget( Pict ) X struct Picture *Pict; X{ X int place; X X if (Pict) { X X if (CycWind) { X X place = RemoveGadget(CycWind,DirGadget); X X if (Pict->Crngs[EditRange].active & REVERSE) { X DirGadget->Flags &= ~SELECTED; X } else { X DirGadget->Flags |= SELECTED; X } X AddGadget( CycWind, DirGadget, place); X RefreshGList( DirGadget, CycWind, NULL, 1); X } X } X} X XModifySpeedPot() X{ X int place; X X if (CycWind) { X /* ModifyProp to match EditRange's CycleSpeed */ X X place = RemoveGadget(CycWind,SpeedPot); X X ((struct PropInfo *) SpeedPot->SpecialInfo)->HorizPot = X CurPict->Crngs[ EditRange ].rate << 1; X X AddGadget( CycWind, SpeedPot, place); X RefreshGList( SpeedPot, CycWind, NULL, 1); X } X} X XExcludeGadgets( gadget ) X register struct Gadget *gadget; X{ X register struct Gadget *NextGadget; X register place; X X NextGadget = gadget; X X do { X X place = RemoveGadget( CycWind, NextGadget ); X X if (NextGadget == gadget) { X NextGadget->Flags |= SELECTED; X } else { X NextGadget->Flags &= ~SELECTED; X } X X AddGadget( CycWind, NextGadget, place ); X RefreshGList( NextGadget, CycWind, NULL, 1); X X NextGadget = (struct Gadget *) NextGadget->UserData; X X } while ( NextGadget && NextGadget != gadget ); X} X Xstatic struct PropInfo *PropInfo; X XSetSpeed() X{ X extern LONG cyClocks[]; X X CurPict->Crngs[EditRange].rate = PropInfo->HorizPot >> 1; X cyClocks[EditRange] = 0; X} X XFinishRangeCmd(pen) X int pen; X{ X int t; X X if (CurPict == NULL) X return; X X t = Num_vp_Colors - 1; X X if (RangeFirstPen > t || pen > t) X return; X X if (RangeFirstPen > pen) { X X t = pen; X pen = RangeFirstPen; X RangeFirstPen = t; X X CurPict->Crngs[EditRange].active |= REVERSE; X X } else { X X CurPict->Crngs[EditRange].active &= ~REVERSE; X } X X SetDirGadget( CurPict ); X X CurPict->Crngs[EditRange].low = RangeFirstPen; X CurPict->Crngs[EditRange].high = pen; X X if (pen == RangeFirstPen) { X CurPict->Crngs[EditRange].active &= ~1; X } else { X CurPict->Crngs[EditRange].active |= 1; X } X} X XSetOnString( OnOff ) X{ X int place; X register struct Gadget *SrcGadget,*DstGadget; X X if (CycWind == NULL) X return; X X if ( OnOff ) { X SrcGadget = CycleOffGadget; /* Make it turn on */ X DstGadget = CycleOnGadget; X } else { X SrcGadget = CycleOnGadget; X DstGadget = CycleOffGadget; X } X X if (SrcGadget->NextGadget != NULL) { X place = RemoveGadget( CycWind, SrcGadget ); X SrcGadget->NextGadget = NULL; X X AddGadget( CycWind, DstGadget, place ); X X SetAPen( CycWind->RPort, NORMALPEN ); X RectFill( CycWind->RPort, SrcGadget->LeftEdge, SrcGadget->TopEdge, X SrcGadget->LeftEdge + SrcGadget->Width, X SrcGadget->TopEdge + SrcGadget->Height); X RefreshGList( DstGadget, CycWind, NULL, 1); X } X} X Xstatic struct Border *PotBorder; X X/* X * Allocate all the gadgets for the color palette window X */ Xstruct Gadget *MakeCycle() X{ X struct Gadget *FirstGadget; X register struct Gadget *NextGadget; X register LONG i,Left,x,y,c = 0; X X struct Gadget *ExcludeGadget, *PrevGadget; X X struct Image *Image0; X struct Image *Image1; X struct IntuiText *Text, *NextText; X X extern struct Image Arrow_Image[]; X X LONG fourx = 4 << XScale; X LONG foury = 4 << YScale; X X char *str; X X Left = PENLEFT; X X FirstGadget = NextGadget = MakePot( 84, 35, 64, 4, CYCSPEED, y); X X if ( NextGadget == NULL ) goto error; X X SpeedPot = NextGadget; X X NextGadget->Activation = GADGIMMEDIATE | FOLLOWMOUSE | RELVERIFY; X NextGadget->GadgetText = Text = ShadowIntui("Speed",-46, -3); X X if ( Text == NULL ) goto error; X X Image0 = (struct Image *) NextGadget->GadgetRender; X Image0->Width = 4; X Image0->Height = 4; X Image0->PlaneOnOff = NORMALPEN; X X PropInfo = (struct PropInfo *) NextGadget->SpecialInfo; X PropInfo->Flags = PROPBORDERLESS | FREEHORIZ; X PropInfo->HorizBody = 0xff; X X PotBorder = ShadowBorder( BEVELEDDOWN, 83, 34, 65, 5); X X NextGadget->NextGadget = X MakeBool( LEFTMARG+1, 11, 48, 13, 1, CYCRANGE, NULL); X X NextGadget = NextGadget->NextGadget; X X if ( NextGadget == NULL) goto error; X X NextGadget->GadgetText = ShadowIntui("Range", 4,3); X X NextGadget->NextGadget = MakeBool( 151, 32,16, 8, 4, CYCDIR, GADGIMAGE); X X NextGadget = NextGadget->NextGadget; X X if ( NextGadget == NULL) goto error; X X DirGadget = NextGadget; X X NextGadget->Flags = GADGHIMAGE | GADGIMAGE | SELECTED; X NextGadget->Activation |= TOGGLESELECT; X X Image0 = (struct Image *) NextGadget->GadgetRender; X Image1 = (struct Image *) Image0->NextImage; X Image0->NextImage = NULL; X X NextGadget->SelectRender = (APTR) Image1; X X SetupArrow(Image0, &Arrow_Image[0]); X SetupArrow(Image1, &Arrow_Image[1]); X X CycleOffGadget = MakeBool( 3, 28, 30, 13, 1, CYCON, NULL); X X if ( CycleOffGadget == NULL) goto error; X X CycleOffGadget->GadgetText = ShadowIntui("Off", 4,4); X X CycleOnGadget = MakeBool( 3, 28, 30, 13, 1, CYCON, NULL); X X if ( CycleOnGadget == NULL) goto error; X X CycleOnGadget->GadgetText = ShadowIntui("On", 8,4); X X if (CurPict && CurPict->CycleOn) { X X NextGadget->NextGadget = CycleOnGadget; X } else { X NextGadget->NextGadget = CycleOffGadget; X } X X NextGadget = NextGadget->NextGadget; X X for (c = 0, x = 0; c < 4; c++, x += 28) { X X NextGadget->NextGadget = X MakeBool( 55 + x, 11, 24, 13, 1, CYCRNUM+c, NULL); X X NextGadget = NextGadget->NextGadget; X X if ( NextGadget == NULL ) goto error; X X NextGadget->UserData = (APTR) PrevGadget; X X PrevGadget = NextGadget; X X NextGadget->Flags = GADGHIMAGE; X NextGadget->Activation |= TOGGLESELECT; X NextGadget->SelectRender = X (APTR) ShadowBorder( BEVELEDDOWN, 1, 1, 23, 12); X X if (c == 0) { X ExcludeGadget = NextGadget; X NextGadget->Flags |= SELECTED; X EditRange = 0; X } X X switch (c) { X case 0: NextGadget->GadgetText = ShadowIntui("c1", 4,3); break; X case 1: NextGadget->GadgetText = ShadowIntui("c2", 4,3); break; X case 2: NextGadget->GadgetText = ShadowIntui("c3", 4,3); break; X case 3: NextGadget->GadgetText = ShadowIntui("c4", 4,3); X } X } X ExcludeGadget->UserData = (APTR) NextGadget; X X return(FirstGadget); X Xerror: X FreeGadgets( FirstGadget ); X return( NULL ); X} /* MakeCycle */ X XSetupArrow( ImageDst, ImageSrc, ) X register struct Image *ImageDst; X register struct Image *ImageSrc; X{ X ImageDst->LeftEdge = ImageDst->TopEdge = 0; X ImageDst->Width = 16; X ImageDst->Height = 9; X ImageDst->ImageData = ImageSrc->ImageData; X ImageDst->Depth = 1; X ImageDst->PlanePick = NORMALPEN; X ImageDst->PlaneOnOff = 0; X} X Xstatic struct Gadget *CycGadgets; X X/* X * Open the Cycle window X */ XOpenCycWind() X{ X struct Window *OpenMyWind(); X X register struct Gadget *gadget; X register struct RastPort *Rp; X X if (CurPict == NULL) X return; X X if ( CycWind == NULL ) { X X gadget = MakeCycle(); X X if ( gadget == NULL ) { X DispErrMsg("Couldn't get palette gadgets", 0 ); X return; X } X X CycWind = OpenMyWind( &NewCyc, screen, NULL, 168, 46); X X if ( CycWind != NULL ) { X X Rp = CycWind->RPort; X X SetAPen( Rp, NORMALPEN ); X RectFill( Rp, LEFTMARG, TOPMARG, CycWind->Width, CycWind->Height); X X BorderWindow( CycWind ); X X CycGadgets = gadget; X X AddGList( CycWind, gadget, -1, -1); X X RefreshGadgets( gadget, CycWind, NULL ); X DrawBorder( Rp, PotBorder, 0L, 0L); X FreeBorder(PotBorder); X } X } else { X WindowToFront( CycWind ); X } X CycleOpen = 1; X} /* OpenCycWind */ X X/* X * Close the Cycle window X */ XCloseCycWind() X{ X register struct Gadget *FreeGadget; X if (CycWind != NULL) { X X NewCyc.LeftEdge = CycWind->LeftEdge; X NewCyc.TopEdge = CycWind->TopEdge; X X if (CycleOffGadget->NextGadget == NULL) { X FreeGadgets( CycleOffGadget ); X } else { X FreeGadgets( CycleOnGadget ); X } X X CloseMyWind(CycWind,CycGadgets); X CycGadgets = NULL; X } X CycWind = NULL; X} /* CloseCycWind */ X SHAR_EOF echo "extracting cycleii.c" sed 's/^X//' << \SHAR_EOF > cycleii.c X/* X * MandelVroom 2.0 X * X * (c) Copyright 1987,1989 Kevin L. Clague, San Jose, CA X * X * All rights reserved. X * X * Permission is hereby granted to distribute this program's source X * executable, and documentation for non-comercial purposes, so long as the X * copyright notices are not removed from the sources, executable or X * documentation. This program may not be distributed for a profit without X * the express written consent of the author Kevin L. Clague. X * X * This program is not in the public domain. X * X * Fred Fish is expressly granted permission to distribute this program's X * source and executable as part of the "Fred Fish freely redistributable X * Amiga software library." X * X * Permission is expressly granted for this program and it's source to be X * distributed as part of the Amicus Amiga software disks, and the X * First Amiga User Group's Hot Mix disks. X * X * contents: this file contains the functions to manage the task that X * performs the color cycling. X */ X X#include "mandp.h" X X/* Cycle Task stuff */ X#define CYCLETIME 16384L X#define ACTIVE 0x01 X Xextern VOID cycleTask(); Xchar *cyTaskName = "CycleTask"; Xstruct Task *cyTask; X X/* Data shared with cycleTask */ XCrngChunk *cyCrngs; Xstruct ViewPort *cyVport; Xint cyRegs, cyCnt; XBOOL CycleOn, PrepareToDie; XUSHORT cyMap[maxColorReg]; XLONG cyClocks[maxCycles]; XLONG cyRates[maxCycles]; X Xextern LONG MainPri; X XCreateCycle() X{ X extern int Num_vp_Colors; X X if (cyTask) { X KillCycle(); X LoadRGB4(vp, CurPict->RGBs, Num_vp_Colors); X } X X /* Set up cycle task */ X X initCycle(CurPict, Num_vp_Colors, 4, vp); X X cyTask = (struct Task *)CreateTask(cyTaskName,MainPri,cycleTask,4000); X X if(!cyTask) { X DispErrMsg("Can't create cycling task",0); X return; X } X CycleOn = TRUE; X} X XKillCycle() X{ X if (cyTask) { X CycleOn = FALSE; X PrepareToDie = TRUE; X while(PrepareToDie); X DeleteTask(cyTask); X cyTask = NULL; X LoadRGB4(vp, CurPict->RGBs, Num_vp_Colors); X } X} X X XinitCycle(Pict, Regs, Cnts, vp) X struct Picture *Pict; X int Regs, Cnts; X struct ViewPort *vp; X{ X int k; X X CycleOn = FALSE; X PrepareToDie = FALSE; X cyCrngs = Pict->Crngs; X cyVport = vp; X cyRegs = Regs; X cyCnt = Cnts; X X for(k=0; k<cyRegs; k++) { X cyMap[k] = Pict->RGBs[k]; X } X X /* Init Rates and Clocks */ X for(k=0; k<cyCnt; k++) { X X /* In DPaint CRNG, rate = RNG_NORATE (36) means don't cycle */ X X if(cyCrngs[k].rate == RNG_NORATE) { X cyCrngs[k].rate = 0; X cyCrngs[k].active &= ~ACTIVE; X } X X if((cyCrngs[k].active & ACTIVE)&&(cyCrngs[k].rate)) { X cyRates[k] = cyCrngs[k].rate; X } else { X cyRates[k] = 0; /* Means don't cycle to my cycleTask */ X } X cyClocks[k] = 0; X } X} X X XVOID cycleTask() X { X int k, i, j; X UBYTE low, high; X USHORT cyTmp; X BOOL Cycled; X X geta4(); X X while (!PrepareToDie) { X WaitTOF(); X X if (CycleOn) { X Cycled = FALSE; X X for(k=0; k<cyCnt; k++) { X X if(cyCrngs[k].rate) /* cyRate 0 = inactive */ { X X cyClocks[k] += cyCrngs[k].rate; X X if(cyClocks[k] >= CYCLETIME) { X X Cycled = TRUE; X cyClocks[k] -= CYCLETIME; X low = cyCrngs[k].low; X high= cyCrngs[k].high; X X if(cyCrngs[k].active & REVERSE) { /* Reverse cycle */ X cyTmp = cyMap[low]; X X for(i=low,j=low+1; i < high; i++,j++) { X cyMap[i] = cyMap[j]; X } X cyMap[high] = cyTmp; X } else { /* Forward cycle */ X cyTmp = cyMap[high]; X for(i=high,j=high-1; i > low; i--,j--) { X cyMap[i] = cyMap[j]; X } X cyMap[low] = cyTmp; X } X } X } X } X if(Cycled) { X LoadRGB4(cyVport,cyMap,cyRegs); X } X } X } X PrepareToDie = FALSE; X while(TRUE); /* Busy wait to die */ X} X SHAR_EOF echo "extracting disp.c" sed 's/^X//' << \SHAR_EOF > disp.c X/* X * MandelVroom 2.0 X * X * (c) Copyright 1987,1989 Kevin L. Clague, San Jose, CA X * X * All rights reserved. X * X * Permission is hereby granted to distribute this program's source X * executable, and documentation for non-comercial purposes, so long as the X * copyright notices are not removed from the sources, executable or X * documentation. This program may not be distributed for a profit without X * the express written consent of the author Kevin L. Clague. X * X * This program is not in the public domain. X * X * Fred Fish is expressly granted permission to distribute this program's X * source and executable as part of the "Fred Fish freely redistributable X * Amiga software library." X * X * Permission is expressly granted for this program and it's source to be X * distributed as part of the Amicus Amiga software disks, and the X * First Amiga User Group's Hot Mix disks. X * X * contents: this file contains the routines that open and close X * MandelVrooms custom screen as well as the required Amiga libraries. X * X */ X X#include "mandp.h" X Xchar *ExecLib = "exec.library"; Xchar *IntuiLib = "intuition.library"; Xchar *GfxLib = "graphics.library"; Xchar *LayersLib = "layers.library"; Xchar *FFPLib = "mathffp.library"; Xchar *TransLib = "mathtrans.library"; Xchar *IEEELib = "mathieeedoubbas.library"; Xchar *IconLib = "icon.library"; X Xstruct IntuitionBase *IntuitionBase; Xstruct GfxBase *GfxBase; Xstruct MathBase *MathBase; Xstruct MathTransBase *MathTransBase; Xstruct LayersBase *LayersBase; Xstruct ExecBase *ExecBase; Xstruct MathIeeeDoubBasBase *MathIeeeDoubBasBase; Xextern struct IconBase *IconBase; X Xstruct Screen *screen; Xstruct ViewPort *vp; X Xint Num_vp_Colors; X XUBYTE StandardSize; X Xextern BYTE FromWB; X X/* X * The following window's message port is used to communicate with X * all the other windows in the system. It is a small backdrop, X * borderless window that is always open and in custom screen used X * by MandelVroom. X */ X Xstruct Window *BackWind; X Xstruct NewWindow NewBack = { X 0,10, /* start position */ X 0,0, /* width, height */ X (UBYTE) 0, (UBYTE) 1, /* detail pen, block pen */ X /* IDCMP flags */ X MENUPICK | GADGETDOWN | GADGETUP | REQCLEAR | CLOSEWINDOW | X MOUSEBUTTONS | ACTIVEWINDOW | NEWSIZE, X /* backWind flags */ X ACTIVATE|BACKDROP|BORDERLESS|REPORTMOUSE|NOCAREREFRESH|SIMPLE_REFRESH, X (struct Gadget *) NULL, /* first gadget */ X (struct Image *) NULL, /* user checkmark */ X (UBYTE *) NULL, /* Title */ X (struct Screen *) NULL, /* pointer to screen */ X (struct BitMap *) NULL, /* pointer to superbitmap */ X 8,8,-1,-1, /* sizing */ X CUSTOMSCREEN /* type of screen */ X}; X Xextern struct Window *CurWind; X XSHORT YScale, XScale; X Xstatic Xstruct TextAttr myfont = { X (STRPTR) "topaz.font", X TOPAZ_EIGHTY, X 0, X 0 X}; X X Xstruct NewScreen NewScreen = { X 0,0, /* start position */ X 320, 200, 5, /* width, height, depth */ X (UBYTE) 0, (UBYTE) 1, /* detail pen, block pen */ X (USHORT) NULL, /* HIRES, INTERLACE, SPRITES, DUAL, HAM */ X CUSTOMSCREEN, /* screen type */ X &myfont, /* font to use */ X (UBYTE *) NULL, X (struct Gadget *) NULL /* pointer to extra gadgets */ X}; X X/*************************************************************************** X * X * Open the Libraries and custom screen X * X **************************************************************************/ X X/* X * Open the libraries X */ Xint XOpenLibs() { X X ExecBase = (struct ExecBase *) OpenLibrary( ExecLib, (long) 0); X X if (ExecBase == NULL) { X LibErr( ExecLib ); X return( 100); X } X X#define LIB_FOR_1_2 33L X IntuitionBase = (struct IntuitionBase *) OpenLibrary( IntuiLib, X LIB_FOR_1_2); X X if (IntuitionBase == NULL) { X LibErr( IntuiLib ); X return(100); X } X X GfxBase = (struct GfxBase *) OpenLibrary( GfxLib, (long) 0); X X if (GfxBase == NULL) { X LibErr( GfxLib ); X return(100); X } X X LayersBase = (struct LayersBase *) OpenLibrary( LayersLib, (long) 0); X X if (LayersBase == NULL) { X LibErr( LayersLib ); X return(100); X } X X MathIeeeDoubBasBase = (struct MathIeeeDoubBasBase *) X OpenLibrary( IEEELib, (long) 0); X X if (MathIeeeDoubBasBase == NULL) { X LibErr( IEEELib ); X return(100); X } X X /* if started from the workbench, then open the icon library */ X X if (FromWB) { X X IconBase = (struct IconBase *) OpenLibrary( IconLib, (long) 0); X X if (IconBase == NULL) { X LibErr( IconLib ); X return(100); X } X } X X return(0); X} /* OpenLibs */ X XOpenFFPLibs() X{ X if ( MathBase == NULL ) { X X MathBase = (struct MathBase *) OpenLibrary( FFPLib, (long) 0); X X if (MathBase == NULL) { X DispErrMsg( "Can't open FFP library", 0); X return(100); X } X } X X if ( MathTransBase == NULL ) { X X MathTransBase = (struct MathTransBase *) X OpenLibrary( TransLib, (long) 0); X X if (MathTransBase == NULL) { X DispErrMsg( "Can't open FFP transcendental library", 0); X return(100); X } X } X return(0); X} X XLibErr( Name ) X char *Name; X{ X printf("Can't open %s\nPlease check to see if it is present on your disk\n",Name); X} X X/* X * Close the libraries used X */ XCloseLibs() { X X if ( MathBase ) X CloseLibrary( MathBase ); X MathBase = NULL; X X if ( MathTransBase ) X CloseLibrary( MathTransBase ); X MathTransBase = NULL; X X if ( MathIeeeDoubBasBase ) X CloseLibrary( MathIeeeDoubBasBase ); X MathIeeeDoubBasBase = NULL; X X if ( IconBase ) X CloseLibrary( IconBase ); X IconBase = NULL; X X if ( IntuitionBase ) X CloseLibrary( IntuitionBase ); X IntuitionBase = NULL; X X if ( LayersBase ) X CloseLibrary( LayersBase ); X LayersBase = NULL; X X if ( GfxBase ) X CloseLibrary( GfxBase ); X GfxBase = NULL; X X if ( ExecBase ) X CloseLibrary( ExecBase ); X ExecBase = NULL; X X} /* CloseLibs */ X Xstruct Window *Save_PR_Wind; X X/* X * Open the display X */ Xint XOpenDisp() X{ X extern UBYTE ContOpen, PaletteOpen, CycleOpen, HistOpen; X X extern struct MenuItem GenerateSubs[]; X X NewScreenSize( &NewScreen ); X X if (NewScreen.ViewModes & HIRES) { X XScale = 1; X } else { X XScale = 0; X } X X if (NewScreen.ViewModes & INTERLACE) { X YScale = 1; X } else { X YScale = 0; X } X X RightMarg = 16; X X screen = OpenScreen( (struct NewScreen *) &NewScreen); X X if (screen == NULL) { X AndDie("Can't open new screen!\n"); X } X vp = &screen->ViewPort; X X Num_vp_Colors = 1 << NewScreen.Depth; X X if (Num_vp_Colors > 32) X Num_vp_Colors = 32; X X if (CurPict) X LoadRGB4(vp, CurPict->RGBs, Num_vp_Colors ); X else X DefaultColors(); X X if ( ExecBase->AttnFlags & AFF_68020 ) { X GenerateSubs[ INTIIGENERATOR ].Flags |= ITEMENABLED; X } X X if ( ExecBase->AttnFlags & AFF_68881 ) { X GenerateSubs[ _81GENERATOR ].Flags |= ITEMENABLED; X } X X InitViewModesSubs(); X InitDepthSubs(); X InitGenSubs(); X X AllocateMice(); X X OpenBackWind(); /* Open this before any other window */ X X Save_PR_Wind = (struct Window *) X ((struct Process *) FindTask(0L))->pr_WindowPtr; X X ((struct Process *) FindTask(0L))->pr_WindowPtr = (APTR) BackWind; X X ReOpenPicts(); X X if (ContOpen) OpenContWind(); X if (HistOpen) OpenHistWind(); X if (PaletteOpen) OpenPalWind(); X if (CycleOpen) OpenCycWind(); X X return(0); X} /* opendisp */ X X/* X * Close the screen X */ XCloseDisp() { X X if ( screen ) { X X CloseCycWind(); X ClosePalWind(); X CloseContWind(); X CloseHistWind(); X CloseStatsWind(); X CloseOrbitWind(); X X CloseHelpWind(0,NULL); X X ClosePicts(); X X CloseBackWind(); /* Close this window last */ X X ((struct Process *) FindTask(0L))->pr_WindowPtr = (APTR) Save_PR_Wind; X X NewScreen.TopEdge = screen->TopEdge >> YScale; X X CloseScreen( screen ); X X screen = NULL; X X FreeMice(); X } X} /* CloseDisp */ X X/* X * Check New Screen Size X */ Xint XNewScreenSize( NewScreen ) X struct NewScreen *NewScreen; X{ X extern struct MenuItem ScreenSizeSubs[]; X X struct Screen WBenchScreen; X X (void) GetScreenData( &WBenchScreen, sizeof(struct Screen), X WBENCHSCREEN, NULL); X X if (!(WBenchScreen.ViewPort.Modes & LACE)) { X WBenchScreen.Height <<= 1; X } X X if ( StandardSize ) { X X WBenchScreen.Width = 640; X X if (GfxBase->DisplayFlags & PAL) X WBenchScreen.Height = 512; X else X WBenchScreen.Height = 400; X } X X if (NewScreen->ViewModes & HIRES) { X X if ( NewScreen->Depth > 4 ) X NewScreen->Depth = 4; X X if ( NewScreen->ViewModes & EXTRA_HALFBRITE ) X NewScreen->ViewModes &= ~EXTRA_HALFBRITE; X X NewScreen->Width = WBenchScreen.Width; X X } else { X X NewScreen->Width = WBenchScreen.Width >> 1; X } X X if (NewScreen->ViewModes & INTERLACE) { X X NewScreen->Height = WBenchScreen.Height; X } else { X X NewScreen->Height = WBenchScreen.Height >> 1; X } X X if (NewScreen->ViewModes & EXTRA_HALFBRITE) { X X NewScreen->Depth = 6; X } else { X X if (NewScreen->Depth == 6) X NewScreen->Depth = 5; X } X X NewScreen->TopEdge <<= YScale; X} /* NewScreenSize */ X XSaveRGBs( Pict ) X struct Picture *Pict; X{ X register int i; X register SHORT *RGBs; X X if (Pict) { X X RGBs = Pict->RGBs; X X for (i = 0; i < Num_vp_Colors; i++) X *RGBs++ = GetRGB4(vp->ColorMap, i); X } X} X XAndDie( ErrMsg ) X char *ErrMsg; X{ X printf("%s\n", ErrMsg); X X ThrowPicts(); X X CloseTasks(); X CloseDisp(); X CloseLibs(); X X exit(0); X} X XOpenBackWind() X{ X NewBack.Screen = screen; X NewBack.Width = screen->Width; X NewBack.Height = screen->Height - NewBack.TopEdge - 1; X X BackWind = OpenWindow( &NewBack ); X X if ( BackWind == NULL ) { X AndDie("Can't open common window\n"); X } X X (void) SetMenuStrip( BackWind, Menu ); X X CurWind = BackWind; X X ForceNormPointer(); X} X XCloseBackWind() X{ X ClearPointer( BackWind ); X X ClearMenuStrip( BackWind ); X X CloseWindow( BackWind ); X BackWind = NULL; X} X X/*************************************************************************** X * X * Open and Close Window tools X * X **************************************************************************/ X Xint NumWindows; X X/* X * Open a window and put it in the window list X */ Xstruct Window *OpenMyWind(NewWind, Screen, Gadgets, Width, Height) X struct NewWindow *NewWind; X struct Screen *Screen; X struct Gadget *Gadgets; X SHORT Width, Height; X{ X register struct Window *Window; X register LONG t; X X NewWind->Screen = Screen; X NewWind->FirstGadget = Gadgets; X X NewWind->Width = Width; X NewWind->Height = Height; X X /* Window too wide ? */ X X t = Width - Screen->Width; X X if (t > 0) { X Width -= t; X } X X /* Too far to the right ? */ X X t = NewWind->LeftEdge + Width - Screen->Width; X X if ( t > 0 ) { X NewWind->LeftEdge -= t; X } X X /* Window too tall ? */ X X t = Height - Screen->Height; X X if (t > 0) { X Height -= t; X } X X /* Too close to the bottom ? */ X X t = NewWind->TopEdge + Height - Screen->Height; X X if ( t > 0 ) { X NewWind->TopEdge -= t; X } X X Window = OpenWindow( NewWind ); X X if (Window == (struct Window *) NULL) { X DispErrMsg("Can't open new window",0); X return( (struct Window *) NULL); X } X X Window->UserPort = BackWind->UserPort; X ModifyIDCMP( Window, (long) BackWind->IDCMPFlags ); X X Window->UserData = NULL; X X (void) SetMenuStrip(Window, Menu); X X CurWind = Window; X X ForceNormPointer(); X X return(Window); X} /* OpenMyWind */ X X/* X * Deallocate all the gadgets associated with this window X * Close the window X */ XCloseMyWind(Window,Gadgets) X struct Window *Window; X struct Gadget *Gadgets; X{ X if (Window) { X X /* get rid of the menu */ X if (Window->MenuStrip) X ClearMenuStrip(Window); X X /* get rid of the pointer */ X if (Window->Pointer) X ClearPointer( Window ); X X if ( Window == CurWind ) { X CurWind = BackWind; X } X X CloseWindowSafely( Window ); X X if (Gadgets) X FreeGadgets(Gadgets); X } X} /* CloseMyWind */ X X/*************************************************************************** X * X * This section handles the Mouse pointer for the custom screen X * X **************************************************************************/ X XUSHORT *BabyBrotPointer; XUSHORT *BabyToPointer; XUSHORT *BabyWithPointer; XUSHORT *SleepyPointer; X X/***************************************************************/ X/* This is the image for baby Mandelbrot pointer */ X/***************************************************************/ X XUSHORT BabyBrotSprite[]= { X 0x0000, 0x0000, X 0x8000, 0x0000, X 0x5000, 0x5000, X 0x2202, 0x2202, X 0x4D82, 0x5F82, X 0x0013, 0x1913, X 0x006C, 0x11FE, X 0x2000, 0x300A, X 0x0C00, 0x1C06, X 0x1004, 0x1407, X 0x0004, 0x0404, X 0x0028, 0x042C, X 0x0800, 0x0C1C, X 0x0220, 0x0630, X 0x01C0, 0x05F0, X 0x3800, 0x3F80, X 0x0000, 0x0880, X 0x0000, 0x0000, X }; X X/***************************************************************/ X/* This is a baby brot pointer with 'TO' in it. */ X/***************************************************************/ XUSHORT BabyToSprite[]= { X 0x0000, 0x0000, X 0x8000, 0x0000, X 0x5000, 0x5000, X 0x2202, 0x2202, X 0x4D82, 0x5F82, X 0x0013, 0x1913, X 0x006C, 0x11FE, X 0x2000, 0x300A, X 0x0C00, 0x1C06, X 0x1004, 0x1407, X 0x0004, 0x0404, X 0x0028, 0x042C, X 0x0800, 0x0C1C, X 0x0220, 0x0630, X 0x01C0, 0x05F0, X 0x3800, 0x3F80, X 0x0000, 0x0880, X 0x0000, 0x0000, X 0x3F00, 0x3F00, X 0x2D00, 0x3F80, X 0x0C78, 0x1EF8, X 0x0CCC, 0x0EFC, X 0x0CCC, 0x0EEE, X 0x0CCC, 0x0EEE, X 0x1E78, 0x1E7E, X 0x0000, 0x0F3C, X 0x0000, 0x0000, X }; X X/***************************************************************/ X/* This is a baby brot pointer with 'WITH' in it. */ X/***************************************************************/ XUSHORT BabyWithSprite[]= { X 0x0000, 0x0000, X 0x8000, 0x0000, X 0x5000, 0x5000, X 0x2202, 0x2202, X 0x4D82, 0x5F82, X 0x0013, 0x1913, X 0x006C, 0x11FE, X 0x2000, 0x300A, X 0x0C00, 0x1C06, X 0x1004, 0x1407, X 0x0004, 0x0404, X 0x0028, 0x042C, X 0x0800, 0x0C1C, X 0x0220, 0x0630, X 0x01C0, 0x05F0, X 0x3800, 0x3F80, X 0x0000, 0x0880, X 0x0000, 0x0000, X 0x0630, 0x0630, X 0x0630, 0x0738, X 0x0630, 0x0738, X 0x06B0, 0x07B8, X 0x07F0, 0x07F8, X 0x0770, 0x07F8, X 0x0630, 0x07B8, X 0x0000, 0x0318, X 0x00C0, 0x00C0, X 0x0000, 0x0060, X 0x01C0, 0x01C0, X 0x00C0, 0x00E0, X 0x00C0, 0x00E0, X 0x00C0, 0x00E0, X 0x01E0, 0x01E0, X 0x0000, 0x00F0, X 0x0000, 0x0000, X 0x0040, 0x0040, X 0x00C0, 0x00E0, X 0x01F0, 0x01F0, X 0x00C0, 0x00F8, X 0x00C0, 0x00E0, X 0x00D0, 0x00F0, X 0x0060, 0x0068, X 0x0700, 0x0730, X 0x0300, 0x0380, X 0x0360, 0x03E0, X 0x03B0, 0x03B0, X 0x0330, 0x03F8, X 0x0330, 0x03B8, X 0x0730, 0x07B8, X 0x0000, 0x0398, X 0x0000, 0x0000, X }; X X/***************************************************************/ X/* This is a sleepy cloud pointer */ X/***************************************************************/ XUSHORT SleepySprite[] = { X 0x0000, 0x0000, X 0x0fe0, 0x0000, X 0x1830, 0x07c0, X 0x7018, 0x0fe0, X 0xc008, 0x3ff0, X 0x9e0c, 0x7ff0, X 0x8406, 0x7ff8, X 0x8802, 0x7ffc, X 0x1e03, 0xfffc, X 0x80f1, 0x7ffe, X 0x8021, 0x7ffe, X 0x4040, 0x3fff, X 0x80f1, 0x7ffe, X 0xc001, 0x3ffe, X 0x6003, 0x1ffc, X 0x3006, 0x0ff8, X 0x180c, 0x07f0, X 0x0718, 0x00e0, X 0x0070, 0x0f80, X 0x1810, 0x07e0, X 0x0820, 0x0740, X 0x0ff0, 0x0000, X 0x0020, 0x03c0, X 0x0410, 0x03e0, X 0x0310, 0x00e0, X 0x00e0, 0x0000, X 0x0000, 0x0000, X }; X X/* pointer types */ X#define UNINITIALIZED 0 X#define NORMPOINTER 1 X#define TOPOINTER 2 X#define WITHPOINTER 3 X#define SLEEPYPOINTER 4 X XUBYTE PointerType = UNINITIALIZED; X X/* defines for the cute pointer sprite */ X#define MYSPRITE_WIDTH ((long) 16) X#define MYSPRITE_HEIGHT ((long) 16) X#define TOSPRITE_WIDTH ((long) 16) X#define TOSPRITE_HEIGHT ((long) 25) X#define WITHSPRITE_WIDTH ((long) 16) X#define WITHSPRITE_HEIGHT ((long) 50) X#define SLEEPY_WIDTH ((long) 16) X#define SLEEPY_HEIGHT ((long) 25) X#define MYSPRITE_HOTX ((long) -1) X#define MYSPRITE_HOTY ((long) 0) X X#define BABYSIZE ((int) ((MYSPRITE_HEIGHT + 2) * 8)) X#define TOSIZE ((int) ((TOSPRITE_HEIGHT + 2) * 8)) X#define WITHSIZE ((int) ((WITHSPRITE_HEIGHT + 2) * 8)) X#define SLEEPYSIZE ((int) ((SLEEPY_HEIGHT + 2) * 8)) X X/* X * Copy an Image into a chip ram image X */ XUSHORT * XMakeChipSprite( FastRamSprite, Size ) X register USHORT *FastRamSprite; X register int Size; X{ X register USHORT *ChipSprite, *SaveSprite; X register int i; X X ChipSprite = (USHORT *) X safeAllocMem( (ULONG) (Size * sizeof(SHORT)), MEMF_CHIP ); X X if ( ChipSprite == NULL ) X return ( ChipSprite ); X X SaveSprite = ChipSprite; X X for ( i = 0; i < Size; i++) X *(ChipSprite++) = *(FastRamSprite++); X X return( SaveSprite ); X} X X/* X * Allocate all the mouse pointer sprites used by this program X */ XAllocateMice() X{ X BabyBrotPointer = MakeChipSprite( BabyBrotSprite, BABYSIZE ); X BabyToPointer = MakeChipSprite( BabyToSprite, TOSIZE ); X BabyWithPointer = MakeChipSprite( BabyWithSprite, WITHSIZE ); X SleepyPointer = MakeChipSprite( SleepySprite, SLEEPYSIZE ); X} X X/* X * Free all the mouse pointer sprites used by this program X */ XFreeMice() X{ X if ( BabyBrotPointer ) X FreeMem( (char *) BabyBrotPointer, (long) BABYSIZE * sizeof(SHORT) ); X BabyBrotPointer = NULL; X X if ( BabyToPointer ) X FreeMem( (char *) BabyToPointer, (long) TOSIZE * sizeof(SHORT) ); X BabyToPointer = NULL; X X if ( BabyWithPointer ) X FreeMem( (char *) BabyWithPointer, (long) WITHSIZE * sizeof(SHORT) ); X BabyWithPointer = NULL; X X if ( SleepyPointer ) X FreeMem( (char *) SleepyPointer, (long) SLEEPYSIZE * sizeof(SHORT) ); X SleepyPointer = NULL; X} X X X/* X * Set all window pointers NewPointer X */ XSetPointers() X{ X SetMouse( CurWind ); X} X X/* X * Force normal pointers X */ XForceNormPointer() X{ X PointerType = UNINITIALIZED; X X SetNormPointer(); X} X X/* X * Set Normal Mouse Pointer X */ XSetNormPointer() X{ X if (PointerType != NORMPOINTER ) { X X PointerType = NORMPOINTER; X X SetPointers(); X } X} X X/* X * Set 'To' Mouse Pointer X */ XSetToPointer() X{ X if (PointerType != TOPOINTER ) { X X PointerType = TOPOINTER; X X SetPointers(); X } X} X X/* X * Set 'With' Mouse Pointer X */ XSetWithPointer() X{ X if (PointerType != TOPOINTER ) { X X PointerType = WITHPOINTER; X X SetPointers(); X } X} X X/* X * Set Sleepy Mouse Pointer X */ XSetSleepyPointer() X{ X if (PointerType != SLEEPYPOINTER ) { X X PointerType = SLEEPYPOINTER; X X SetPointers(); X } X} X XSetMouse( window ) X struct Window *window; X{ X if (window == NULL) X return; X X switch ( PointerType ) { X X case NORMPOINTER: X SetPointer( window, BabyBrotPointer, X MYSPRITE_HEIGHT, MYSPRITE_WIDTH, X MYSPRITE_HOTX, MYSPRITE_HOTY); X break; X X case TOPOINTER: X SetPointer( window, BabyToPointer, X TOSPRITE_HEIGHT, TOSPRITE_WIDTH, X MYSPRITE_HOTX, MYSPRITE_HOTY); X break; X X case WITHPOINTER: X SetPointer( window, BabyWithPointer, X WITHSPRITE_HEIGHT, WITHSPRITE_WIDTH, X MYSPRITE_HOTX, MYSPRITE_HOTY); X break; X X case SLEEPYPOINTER: X SetPointer( window, SleepyPointer, X SLEEPY_HEIGHT, SLEEPY_WIDTH, X MYSPRITE_HOTX, MYSPRITE_HOTY); X break; X } X} X X/************************************************************************** X * X * This code is used to display error messages on the cusom screen X * X **************************************************************************/ Xstruct IntuiText msg_txt = X { X 0, X 1, X JAM2, X 5, X 20, X NULL, X NULL, X NULL X }; X Xstruct IntuiText OK_txt = X { X 0, X 1, X JAM2, X 5, X 3, X NULL, X (UBYTE *) "YES", X NULL X }; X Xstruct IntuiText NO_txt = X { X 0, X 1, X JAM2, X 5, X 3, X NULL, X (UBYTE *) "NO", X NULL X }; X Xstruct IntuiText Cont_txt = X { X 0, X 1, X JAM2, X 5, X 3, X NULL, X (UBYTE *) "Continue", X NULL X }; X X XDispErrMsg(ErrMsg, Flag) X char *ErrMsg; X SHORT Flag; X{ X msg_txt.IText = (UBYTE *) ErrMsg; X X SetNormPointer(); X X if (BackWind) { X X if (Flag) { X X return( AutoRequest(BackWind, &msg_txt, &OK_txt, &NO_txt, 0L, 0L, X (long) (IntuiTextLength(&msg_txt) + 50L), 70L)); X } else { X X (void) AutoRequest(BackWind, &msg_txt, 0L, &Cont_txt, 0L, 0L, X (long) (IntuiTextLength(&msg_txt) + 50L), 70L); X } X X } else { X if (FromWB) X printf("%s\n", ErrMsg); X } X return(0); X} X X#define _K (1024L) X#define LOW_MEM_MARK (30*_K) X X#ifdef MEM_DEBUG X XAPTR XSafeAllocMem( size, flags ) X X#else X XAPTR XsafeAllocMem( size, flags ) X X#endif X X ULONG size; X ULONG flags; X{ X register APTR p; X X if ( p = (APTR) AllocMem( (long) size, (long) flags) ) X if ( AvailMem( (long) flags ) < LOW_MEM_MARK ) { X FreeMem((char *) p, (long) size); X return( NULL ); X } X return( p ); X} X SHAR_EOF echo "End of archive 2 (of 9)" # if you want to concatenate archives, remove anything after this line exit