Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!sri-spam!ames!amdahl!orandy From: orandy@amdahl.UUCP Newsgroups: comp.sys.amiga Subject: Initial posting of MandelVroom (3 of 8) Message-ID: <6765@amdahl.amdahl.com> Date: Tue, 19-May-87 21:19:48 EDT Article-I.D.: amdahl.6765 Posted: Tue May 19 21:19:48 1987 Date-Received: Thu, 21-May-87 02:43:05 EDT Organization: Amdahl Corporation, Sunnyvale, CA 94086 Lines: 1997 Keywords: MandelVroom sources 1 # This is a shell archive. Remove anything before this line, then # unpack it by saving it in a file and typing "sh file". (Files # unpacked will be owned by you and have default permissions.) # # This archive contains: # Makefile README contour.c disp.c echo x - Makefile cat > "Makefile" << '//E*O*F Makefile//' SAVEILBM = df1:src/IFF/saveILBM.o df1:src/IFF/packer.o df1:src/IFF/ilbmw.o df1:src/IFF/iffw.o REQ = df1:src/GetFile/getfile.o df1:src/GetFile/safeclose.o MAND = mand.o main.o menu.o menu1.o disp.o nav.o contour.o palette.o savemand.o presets.o OBJECTS = $(MAND) $(REQ) $(SAVEILBM) MandelVroom: mand.p $(OBJECTS) ln $(OBJECTS) -lm32 -lc32 -o MandelVroom mand.p: mand.h cc Mand.h +l -s +HMand.p main.o: mand.p main.c cc main.c -E160 +l +ff +IMand.p mand.o: mand.p mand.c cc mand.c -E160 +l +ff +IMand.p disp.o: mand.p disp.c cc disp.c -E160 +l +ff +IMand.p nav.o: mand.p nav.c cc nav.c -E200 +l +ff +IMand.p contour.o: mand.p contour.c cc contour.c -E200 +l +ff +IMand.p palette.o: mand.p palette.c cc palette.c -E160 +l +ff +IMand.p savemand.o: mand.p savemand.c cc savemand.c +l +ff +IMand.p menu.o: mand.p menu.c cc menu.c +l +ff +IMand.p menu1.o: mand.p menu1.c cc menu1.c +l +IMand.p presets.o: mand.p presets.c cc presets.c +l +ff +IMand.p //E*O*F Makefile// echo x - README cat > "README" << '//E*O*F README//' This directory contains the source to MandelVroom. The source must be compiled with Manx Aztec c Version 3.40a or greater. The 'makefile' in this directory shows you how to make MandleVroom. You must make sure to have prepared and compiled the things in the GetFile and IFF directories before 'making' the things in this directory. //E*O*F README// echo x - contour.c cat > "contour.c" << '//E*O*F contour.c//' /*************************************************************************** * * MandelVroom Contour Editing Window * * Kevin L. Clague * * Copyright (C) 1987 * **************************************************************************/ #include "mand.h" extern struct Screen *screen; extern struct RastPort *rp; extern struct Window *MandWind; extern SHORT MouseX,MouseY; extern SHORT MaxCount; extern struct Menu Menu[]; extern USHORT CmdMode; extern SHORT Zoom; USHORT CurContour; struct Window *ContWind; BYTE ContTitle[80]; struct NewWindow NewCont = { 0,200-80, /* start position */ 320,200, /* width, height */ (UBYTE) 0, (UBYTE) 1, /* detail pen, block pen */ /* IDCMP flags */ MENUPICK | GADGETDOWN | GADGETUP | REQCLEAR | CLOSEWINDOW, /* MandWind flags */ WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH | SIMPLE_REFRESH | NOCAREREFRESH, (struct Gadget *) NULL, /* first gadget */ (struct Image *) NULL, /* user checkmark */ (UBYTE *) NULL, /* window title */ (struct Screen *) NULL, /* pointer to screen */ (struct BitMap *) NULL, /* pointer to superbitmap */ 80,80,320,200, /* sizing */ CUSTOMSCREEN /* type of screen */ }; SHORT Ceiling = 1023; extern SHORT *CountBase; extern SHORT CountX, CountY; SHORT Contours[NUMCONTS] = { 1023,128,64, 32, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; SHORT *ContourBase = Contours; SHORT NumContours = NUMCONTS; UBYTE Colors[NUMCONTS] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }; UBYTE *ColorBase = Colors; struct Gadget *ContGadget[NUMCONTS]; struct Gadget *SelGadget[NUMCONTS]; /* * Figure out what to do for this contour gadget */ DoContourDown(gadget) struct Gadget *gadget; { USHORT ContNum; USHORT Type; extern LONG NavTop, NavBot, NavLeft, NavRight; ContNum = gadget->GadgetID & NUMMASK; switch (Type = gadget->GadgetID >> TYPEBITS & TYPEMASK) { case CONTCNTLS: switch (gadget->GadgetID) { case CONTRECOL: ReColor(); DisplayBeep(screen); if (Zoom) { DrawBox(NavLeft, NavTop, NavRight, NavBot ); DrawExtras(NavLeft, NavTop, NavRight, NavBot ); } SetNormPointer(); break; case CONTSMTH: SetToPointer(); CmdMode = SMOOTH; break; } break; case CONTSELS: if (CmdMode == SMOOTH) { SetNormPointer(); SmoothContours(CurContour, ContNum); } else { SetNormPointer(); CmdMode = IMPLIEDSET; } break; case CONTDOWNS: if (*(ContourBase + ContNum) > 0) { *(ContourBase + ContNum) -= 1; } ReString(ContNum); SetNormPointer(); break; case CONTUPS: if (*(ContourBase + ContNum) < MaxCount) { *(ContourBase + ContNum) += 1; } ReString(ContNum); SetNormPointer(); break; } if ( Type != CONTCNTLS ) { DrawContBox(CurContour, 0); DrawContBox(ContNum, 1); CurContour = ContNum; SetContTitle(ContNum); } } /* * Figure out what to do for this contour gadget */ DoContourUp(gadget) struct Gadget *gadget; { USHORT ContNum; struct PropInfo *PropInfo; ULONG VertPot; char msg[80]; ContNum = gadget->GadgetID & NUMMASK; SetNormPointer(); PropInfo = (struct PropInfo *) gadget->SpecialInfo; VertPot = PropInfo->VertPot + 1; switch (gadget->GadgetID >> TYPEBITS & TYPEMASK) { case CONTCNTLS: Ceiling = ((LONG) MaxCount - ( VertPot * MaxCount >> 16)); ModAll(); break; case CONTPOTS: if (ContourBase[ContNum] < Ceiling) { ContourBase[ContNum] = ( (LONG) Ceiling ) - (VertPot * Ceiling >> 16); } else { PropInfo->VertPot = 0; RefreshGList(gadget,ContWind,NULL,1); } DrawContBox(CurContour, 0); DrawContBox(ContNum, 1); CurContour = ContNum; SetContTitle(ContNum); break; } } /* * Set the contour window's new title */ SetContTitle(ContNum) int ContNum; { SHORT Low, High; char *fmt1 = "Contour: %d Alt: %d-%d Pen: %d"; char *fmt2 = "Contour: %d Alt: %d Pen: %d"; High = ContourBase[ContNum]; if (ContNum != 0) { Low = ContourBase[ContNum-1]; if (Low == High || Low - High == 1) { sprintf(ContTitle, fmt2, ContNum, High, ColorBase[ContNum]); } else { sprintf(ContTitle, fmt1, ContNum, Low - 1, High, ColorBase[ContNum]); } } else { sprintf(ContTitle, fmt2, ContNum, MaxCount, High, ColorBase[ContNum]); } SetWindowTitles(ContWind, ContTitle, NULL); } /* * Set Potentiometer knob's pen */ DrawContBox(Contour, pen) ULONG Contour; int pen; { LONG Left, Right, Top, Bottom; LONG Scaled4; struct RastPort *rp = ContWind->RPort; extern USHORT XScale, YScale; Scaled4 = 4 << XScale; Left = (6 << XScale) * Contour + Scaled4 - 1; Right = Left + Scaled4 + 1; Top = (12 << YScale) - 1; Bottom = Top + (4 << YScale) + 1; SetDrMd(rp, (LONG) JAM1); SetAPen(rp, (LONG) pen); /* * Draw the new box */ Move(rp, Left, Top ); Draw(rp, Right, Top ); Draw(rp, Right, Bottom); Draw(rp, Left, Bottom); Draw(rp, Left, Top+1 ); } /* DrawContBox */ /* * There was a window pick. Do what we need to do to service it */ DoWindowPick(MouseX,MouseY) SHORT MouseX,MouseY; { USHORT Height; if (MouseX >= LEFTMARG && MouseX <= MandWind->Width-RIGHTMARG && MouseY >= TOPMARG && MouseY <= MandWind->Height-BOTMARG) { if (CmdMode == IMPLIEDSET) { Height = *(CountBase + (MouseY-TOPMARG)*CountX + MouseX - LEFTMARG); *(ContourBase + CurContour) = Height; ReString(CurContour); } } } /* * Smooth the heights over a subrange of contours */ SmoothContours(First,Second) USHORT First, Second; { USHORT Temp; float Diff,Start; if (Second-First != 0) { if (Second < First) { Temp = First; First = Second; Second = Temp; } Start = (float) ContourBase[First]; Diff = (((float) ContourBase[Second]) - Start)/((float)(Second-First)); if (Diff > -1.0) { Diff = -1.0; } for ( ; First < Second && Start > 0; First++) ContourBase[First + 1] = (SHORT) (Start += Diff); if (Start == 0) { for ( ; First < NumContours; First++) { ContourBase[First] = 0; } } ModAll(); } } /* SmoothContours */ /* * ReColor the Mandelbrot image */ ReColor() { SHORT *CountPtr = CountBase; SHORT Mask,Width; LONG Mod,CMod; SHORT LF,LP,RF,RP,D[6]; SHORT i,j,k,l, Depth; LONG Sx,TL; SHORT *Planes[6]; UBYTE *ColorPtr; UBYTE *ColorSave,t; UBYTE T[1030]; Depth = screen->BitMap.Depth; if (CountPtr == NULL) { DispErrMsg("No counts to recolor",0); return(0); } if (screen->Width < CountX+LEFTMARG+RIGHTMARG || screen->Height < CountY+TOPMARG+BOTMARG) { DispErrMsg("Picture too big for screen.",0); return(0); } if (MandWind->Width != CountX+LEFTMARG+RIGHTMARG || MandWind->Height != CountY+TOPMARG+BOTMARG) SizeWindow(MandWind,CountX+LEFTMARG+RIGHTMARG-MandWind->Width, CountY+TOPMARG+BOTMARG-MandWind->Height); WindowToFront(MandWind); SetAPen( rp, 0L ); RectFill( rp, LEFTMARG, TOPMARG, LEFTMARG + CountX, TOPMARG + CountY ); if ( Depth < 4 || Depth == 6) { ReColorSlow(); return(0); } /* try to get enough memory to recolor the picture fast. */ ColorPtr = ColorSave = (UBYTE *) AllocMem((LONG) CountX * CountY, 0L); if (ColorPtr == (UBYTE *) NULL) { ReColorSlow(); return(0); } /* So recolor it now that you have the memory */ for (i = 0,j = 1029; i < NUMCONTS; i++) for (; j >= ContourBase[i] && j; ) T[j--] = ColorBase[i]; while (j >= 0) T[j--] = 0; ; #ifdef SLOW1 for (Sx = CountX*CountY; Sx-- >= 0; ) *(ColorPtr++) = T[*(CountPtr++)]; #else #asm CountPtr equ -4 ColorBase equ -82 T equ -1117 move.w _CountX,d1 muls.w _CountY,d1 sub.l #1,d1 move.l CountPtr(a5),a0 lea T(a5),a1 move.l ColorBase(a5),a6 ColorLoop move.w (a0)+,d0 move.b (a1,d0.w),(a6)+ sub.l #1,d1 bge ColorLoop #endasm #endif ClearMenuStrip(MandWind); if (Depth == 4) { ReColor4(ColorSave); } else if (Depth == 5) { ReColor5(ColorSave); } SetMenuStrip(MandWind, Menu); FreeMem(ColorSave,CountX*CountY); } /* ReColor */ /* * Assembly code to recolor 4 bit planes */ ReColor4(ColorSave) UBYTE *ColorSave; { SHORT Mask,Width; LONG Mod,CMod; SHORT LF,LP,RF,RP; SHORT i,j,k,l; LONG Sx,TL; UBYTE *ColorPtr; struct BitMap *BitMap = MandWind->RPort->BitMap; #asm SaveReg reg a0-a6/d0-d7 Plane0 equ 8 Plane1 equ Plane0+4 Plane2 equ Plane0+8 Plane3 equ Plane0+12 Plane4 equ Plane0+16 Plane5 equ Plane0+20 BitMap equ -44 ColorPtr equ -40 TL equ -36 Sx equ -32 l equ -28 k equ -26 j equ -24 i equ -22 RP equ -20 RF equ -18 LP equ -16 LF equ -14 CMod equ -12 Mod equ -8 Width equ -4 Mask equ -2 ColorSave equ 8 #endasm ColorPtr = ColorSave; Sx = screen->Width >> 4; LF = MandWind->LeftEdge + 17 & 0xfff0; LP = MandWind->LeftEdge + LEFTMARG; CMod = CountX - (LF-LP); Mod = Sx - 1; TL = Sx * (MandWind->TopEdge + TOPMARG) + (LP >> 4); Width = LF-LP; Mask = 0xffff << Width; #asm movem.l SaveReg,-(sp) ;Save all the gprs to the stack move.l a5,a1 ;We need a5, so put MANX stack in a1 move.w _CountY,i(a1) move.l BitMap(a1),a0 move.l TL(a1),d0 ;Load Offset to Top,Left corner of screen asl.l #1,d0 ; and make it a 'word' offset move.l Plane0(a0),a2 ;Get address of screens first bit plane adda.l d0,a2 ; add in window top-left offset. move.l Plane1(a0),a3 ;Same for second bit plane. adda.l d0,a3 move.l Plane2(a0),a4 ;Same for third bit plane. adda.l d0,a4 move.l Plane3(a0),a5 ;Same for fourth bit plane. adda.l d0,a5 move.l ColorPtr(a1),a0 ;Load up pointer to recolored data. move.l #1,d1 ;/* for each row */ ; for (i = CountY; i; i--) { Y0Loop4 ; /* for each pixel in column */ move.w Width(a1),d7 ; for (k = Width; k; k--) { eor.w d2,d2 ; Clear all bits in the bit plane data regs. eor.w d3,d3 eor.w d4,d4 eor.w d5,d5 B0Loop4 move.b (a0)+,d0 ; d0 = *(ColorPtr++); asr.b d1,d0 ; get low order bit from d0 addx.w d2,d2 ; put it in bit plane 0 data asr.b d1,d0 ; same for bit plane 1 addx.w d3,d3 asr.b d1,d0 ; same for bit plane 2 addx.w d4,d4 asr.b d1,d0 ; same for bit plane 3 addx.w d5,d5 sub.w d1,d7 ; same for bit plane 5 bgt B0Loop4 ; } /* did each bit in bit plane word */ move.w Mask(a1),d0 ; Turn off all the new bits in planes and.w d0,(a2) and.w d0,(a3) and.w d0,(a4) and.w d0,(a5) or.w d2,(a2)+ ; Set the new bits in the bit planes or.w d3,(a3)+ or.w d4,(a4)+ or.w d5,(a5)+ move.l Mod(a1),d0 ; Adjust plane pointers to start of next line add.l d0,d0 add.l d0,a2 add.l d0,a3 add.l d0,a4 add.l d0,a5 adda.l CMod(a1),a0 ; Adjust color pointer to start of next line sub.w d1,i(a1) ;} /* did each row */ tst.w i(a1) bgt Y0Loop4 movem.l (sp)+,SaveReg ;better restore the registers #endasm RP = LP + CountX & 0xfff0; RF = RP - 16; CMod = CountX - (RP-LF); Mod = Sx - ((RP-LF) >> 4); TL++; Width = (RP-LF) >> 4; ColorPtr = ColorSave + LF - LP; #asm movem.l SaveReg,-(sp) ;Save all the gprs to the stack move.l a5,a1 ;We need a5, so put MANX stack in a1 move.w _CountY,i(a1) ;i = CountY; move.l BitMap(a1),a0 move.l TL(a1),d0 ;Load Offset to Top,Left corner of screen asl.l #1,d0 ; and make it a 'word' offset move.l Plane0(a0),a2 ;Get address of screens first bit plane adda.l d0,a2 ; add in window top-left offset. move.l Plane1(a0),a3 ;Same for second bit plane. adda.l d0,a3 move.l Plane2(a0),a4 ;Same for third bit plane. adda.l d0,a4 move.l Plane3(a0),a5 ;Same for fourth bit plane. adda.l d0,a5 move.l ColorPtr(a1),a0 ;Load up pointer to recolored data. move.l #1,d1 ;/* for each row */ ; for (i = CountY; i; i--) { YLoop4 ; /* for each column */ move.w Width(a1),j(a1) ; for (j = Width; j; j--) { XLoop4 ; /* pack a word for each bit plane */ move.w #16,d7 ; for (k = 16; k; k--) { BLoop4 move.b (a0)+,d0 ; d0 = *(ColorPtr++); asr.b d1,d0 ; get low order bit from d0 addx.w d2,d2 ; put it in bit plane 0 data asr.b d1,d0 ; same for bit plane 1 addx.w d3,d3 asr.b d1,d0 ; same for bit plane 2 addx.w d4,d4 asr.b d1,d0 ; same for bit plane 3 addx.w d5,d5 sub.w d1,d7 ; same for bit plane 5 bgt BLoop4 ; } /* did each bit in bit plane word */ move.w d2,(a2)+ ; Save the packed data in bit planes move.w d3,(a3)+ move.w d4,(a4)+ move.w d5,(a5)+ sub.w d1,j(a1) ; } /* did each word in a row */ tst.w j(a1) bgt XLoop4 move.l Mod(a1),d0 ; Adjust plane pointers to start of next line add.l d0,d0 add.l d0,a2 add.l d0,a3 add.l d0,a4 add.l d0,a5 adda.l CMod(a1),a0 ; Adjust color pointer to start of next line sub.w d1,i(a1) ;} /* did each row */ tst.w i(a1) bgt YLoop4 movem.l (sp)+,SaveReg ;better restore the registers #endasm TL += Width; Width = LP + CountX - RP; CMod = CountX - Width; Mod = Sx - 1; Mask = 0xffff >> Width; ColorPtr = ColorSave + RP - LP; #asm movem.l SaveReg,-(sp) ;Save all the gprs to the stack move.l a5,a1 ;We need a5, so put MANX stack in a1 move.w _CountY,i(a1) move.l BitMap(a1),a0 move.l TL(a1),d0 ;Load Offset to Top,Left corner of screen asl.l #1,d0 ; and make it a 'word' offset move.l Plane0(a0),a2 ;Get address of screens first bit plane adda.l d0,a2 ; add in window top-left offset. move.l Plane1(a0),a3 ;Same for second bit plane. adda.l d0,a3 move.l Plane2(a0),a4 ;Same for third bit plane. adda.l d0,a4 move.l Plane3(a0),a5 ;Same for fourth bit plane. adda.l d0,a5 move.l ColorPtr(a1),a0 ;Load up pointer to recolored data. move.l #1,d1 ;/* for each row */ ; ;for (i = CountY; i; i--) { Y2Loop4 ; /* for each pixel in column */ move.w Width(a1),d7 ; for (k = Width; k; k--) { eor.w d2,d2 ; Clear all bits in the bit plane data regs. eor.w d3,d3 eor.w d4,d4 eor.w d5,d5 B2Loop4 move.b (a0)+,d0 ; d0 = *(ColorPtr++); asr.b d1,d0 ; get low order bit from d0 addx.w d2,d2 ; put it in bit plane 0 data asr.b d1,d0 ; same for bit plane 1 addx.w d3,d3 asr.b d1,d0 ; same for bit plane 2 addx.w d4,d4 asr.b d1,d0 ; same for bit plane 3 addx.w d5,d5 sub.w d1,d7 ; same for bit plane 5 bgt B2Loop4 ; } /* did each bit in bit plane word */ move.w Mask(a1),d0 ; Turn off all the new bits in planes and.w d0,(a2) and.w d0,(a3) and.w d0,(a4) and.w d0,(a5) move.w #16,d0 sub.w Width(a1),d0 asl.w d0,d2 asl.w d0,d3 asl.w d0,d4 asl.w d0,d5 or.w d2,(a2)+ ; Set the new bits in the bit planes or.w d3,(a3)+ or.w d4,(a4)+ or.w d5,(a5)+ move.l Mod(a1),d0 ; Adjust plane pointers to start of next line add.l d0,d0 add.l d0,a2 add.l d0,a3 add.l d0,a4 add.l d0,a5 adda.l CMod(a1),a0 ; Adjust color pointer to start of next line sub.w d1,i(a1) ;} /* did each row */ tst.w i(a1) bgt Y2Loop4 movem.l (sp)+,SaveReg ;better restore the registers #endasm } /* ReColor 4 bit planes */ /* * Assembly code to recolor 5 bit planes */ ReColor5(ColorSave) UBYTE *ColorSave; { SHORT Mask,Width; LONG Mod,CMod; SHORT LF,LP,RF,RP; SHORT i,j,k,l; LONG Sx,TL; UBYTE *ColorPtr; struct BitMap *BitMap = MandWind->RPort->BitMap; ColorPtr = ColorSave; Sx = screen->Width >> 4; LF = MandWind->LeftEdge + 17 & 0xfff0; LP = MandWind->LeftEdge + LEFTMARG; CMod = CountX - (LF-LP); Mod = Sx - 1; TL = Sx * (MandWind->TopEdge + TOPMARG) + (LP >> 4); Width = LF-LP; Mask = 0xffff << Width; #asm movem.l SaveReg,-(sp) ;Save all the gprs to the stack move.l a5,a1 ;We need a5, so put MANX stack in a1 move.w _CountY,i(a1) move.l BitMap(a1),a0 move.l TL(a1),d0 ;Load Offset to Top,Left corner of screen asl.l #1,d0 ; and make it a 'word' offset move.l Plane0(a0),a2 ;Get address of screens first bit plane adda.l d0,a2 ; add in window top-left offset. move.l Plane1(a0),a3 ;Same for second bit plane. adda.l d0,a3 move.l Plane2(a0),a4 ;Same for third bit plane. adda.l d0,a4 move.l Plane3(a0),a5 ;Same for fourth bit plane. adda.l d0,a5 move.l Plane4(a0),a6 ;Same for fifth bit plane. adda.l d0,a6 move.l ColorPtr(a1),a0 ;Load up pointer to recolored data. move.l #1,d1 ;/* for each row */ ; ;for (i = CountY; i; i--) { Y0Loop5 ; /* for each pixel in column */ move.w Width(a1),d7 ; for (k = Width; k; k--) { eor.w d2,d2 ; Clear all bits in the bit plane data regs. eor.w d3,d3 eor.w d4,d4 eor.w d5,d5 eor.w d6,d6 B0Loop5 move.b (a0)+,d0 ; d0 = *(ColorPtr++); asr.b d1,d0 ; get low order bit from d0 addx.w d2,d2 ; put it in bit plane 0 data asr.b d1,d0 ; same for bit plane 1 addx.w d3,d3 asr.b d1,d0 ; same for bit plane 2 addx.w d4,d4 asr.b d1,d0 ; same for bit plane 3 addx.w d5,d5 asr.b d1,d0 ; same for bit plane 4 addx.w d6,d6 sub.w d1,d7 ; same for bit plane 5 bgt B0Loop5 ; } /* did each bit in bit plane word */ move.w Mask(a1),d0 ; Turn off all the new bits in planes and.w d0,(a2) and.w d0,(a3) and.w d0,(a4) and.w d0,(a5) and.w d0,(a6) or.w d2,(a2)+ ; Set the new bits in the bit planes or.w d3,(a3)+ or.w d4,(a4)+ or.w d5,(a5)+ or.w d6,(a6)+ move.l Mod(a1),d0 ; Adjust plane pointers to start of next line add.l d0,d0 add.l d0,a2 add.l d0,a3 add.l d0,a4 add.l d0,a5 add.l d0,a6 adda.l CMod(a1),a0 ; Adjust color pointer to start of next line sub.w d1,i(a1) ;} /* did each row */ tst.w i(a1) bgt Y0Loop5 movem.l (sp)+,SaveReg ;better restore the registers #endasm RP = LP + CountX & 0xfff0; RF = RP - 16; CMod = CountX - (RP-LF); Mod = Sx - ((RP-LF) >> 4); TL++; Width = (RP-LF) >> 4; ColorPtr = ColorSave + LF - LP; #asm movem.l SaveReg,-(sp) ;Save all the gprs to the stack move.l a5,a1 ;We need a5, so put MANX stack in a1 move.w _CountY,i(a1) ;i = CountY; move.l BitMap(a1),a0 move.l TL(a1),d0 ;Load Offset to Top,Left corner of screen asl.l #1,d0 ; and make it a 'word' offset move.l Plane0(a0),a2 ;Get address of screens first bit plane adda.l d0,a2 ; add in window top-left offset. move.l Plane1(a0),a3 ;Same for second bit plane. adda.l d0,a3 move.l Plane2(a0),a4 ;Same for third bit plane. adda.l d0,a4 move.l Plane3(a0),a5 ;Same for fourth bit plane. adda.l d0,a5 move.l Plane4(a0),a6 ;Same for fifth bit plane. adda.l d0,a6 move.l ColorPtr(a1),a0 ;Load up pointer to recolored data. move.l #1,d1 ;/* for each row */ ; ;for (i = CountY; i; i--) { YLoop5 ; /* for each column */ move.w Width(a1),j(a1) ; for (j = Width; j; j--) { XLoop5 ; /* pack a word for each bit plane */ move.w #16,d7 ; for (k = 16; k; k--) { BLoop5 move.b (a0)+,d0 ; d0 = *(ColorPtr++); asr.b d1,d0 ; get low order bit from d0 addx.w d2,d2 ; put it in bit plane 0 data asr.b d1,d0 ; same for bit plane 1 addx.w d3,d3 asr.b d1,d0 ; same for bit plane 2 addx.w d4,d4 asr.b d1,d0 ; same for bit plane 3 addx.w d5,d5 asr.b d1,d0 ; same for bit plane 4 addx.w d6,d6 sub.w d1,d7 ; same for bit plane 5 bgt BLoop5 ; } /* did each bit in bit plane word */ move.w d2,(a2)+ ; Save the packed data in bit planes move.w d3,(a3)+ move.w d4,(a4)+ move.w d5,(a5)+ move.w d6,(a6)+ sub.w d1,j(a1) ; } /* did each word in a row */ tst.w j(a1) bgt XLoop5 move.l Mod(a1),d0 ; Adjust plane pointers to start of next line add.l d0,d0 add.l d0,a2 add.l d0,a3 add.l d0,a4 add.l d0,a5 add.l d0,a6 adda.l CMod(a1),a0 ; Adjust color pointer to start of next line sub.w d1,i(a1) ;} /* did each row */ tst.w i(a1) bgt YLoop5 movem.l (sp)+,SaveReg ;better restore the registers #endasm TL += Width; Width = LP + CountX - RP; CMod = CountX - Width; Mod = Sx - 1; Mask = 0xffff >> Width; ColorPtr = ColorSave + RP - LP; #asm movem.l SaveReg,-(sp) ;Save all the gprs to the stack move.l a5,a1 ;We need a5, so put MANX stack in a1 move.w _CountY,i(a1) move.l BitMap(a1),a0 move.l TL(a1),d0 ;Load Offset to Top,Left corner of screen asl.l #1,d0 ; and make it a 'word' offset move.l Plane0(a0),a2 ;Get address of screens first bit plane adda.l d0,a2 ; add in window top-left offset. move.l Plane1(a0),a3 ;Same for second bit plane. adda.l d0,a3 move.l Plane2(a0),a4 ;Same for third bit plane. adda.l d0,a4 move.l Plane3(a0),a5 ;Same for fourth bit plane. adda.l d0,a5 move.l Plane4(a0),a6 ;Same for fifth bit plane. adda.l d0,a6 move.l ColorPtr(a1),a0 ;Load up pointer to recolored data. move.l #1,d1 ;/* for each row */ ; ;for (i = CountY; i; i--) { Y2Loop5 ; ; /* for each pixel in column */ move.w Width(a1),d7 ; for (k = Width; k; k--) { eor.w d2,d2 ; Clear all bits in the bit plane data regs. eor.w d3,d3 eor.w d4,d4 eor.w d5,d5 eor.w d6,d6 B2Loop5 move.b (a0)+,d0 ; d0 = *(ColorPtr++); asr.b d1,d0 ; get low order bit from d0 addx.w d2,d2 ; put it in bit plane 0 data asr.b d1,d0 ; same for bit plane 1 addx.w d3,d3 asr.b d1,d0 ; same for bit plane 2 addx.w d4,d4 asr.b d1,d0 ; same for bit plane 3 addx.w d5,d5 asr.b d1,d0 ; same for bit plane 4 addx.w d6,d6 sub.w d1,d7 ; same for bit plane 5 bgt B2Loop5 ; } /* did each bit in bit plane word */ move.w Mask(a1),d0 ; Turn off all the new bits in planes and.w d0,(a2) and.w d0,(a3) and.w d0,(a4) and.w d0,(a5) and.w d0,(a6) move.w #16,d0 sub.w Width(a1),d0 asl.w d0,d2 asl.w d0,d3 asl.w d0,d4 asl.w d0,d5 asl.w d0,d6 or.w d2,(a2)+ ; Set the new bits in the bit planes or.w d3,(a3)+ or.w d4,(a4)+ or.w d5,(a5)+ or.w d6,(a6)+ move.l Mod(a1),d0 ; Adjust plane pointers to start of next line add.l d0,d0 add.l d0,a2 add.l d0,a3 add.l d0,a4 add.l d0,a5 add.l d0,a6 adda.l CMod(a1),a0 ; Adjust color pointer to start of next line sub.w d1,i(a1) ;} /* did each row */ tst.w i(a1) bgt Y2Loop5 movem.l (sp)+,SaveReg ;better restore the registers #endasm } /* ReColor 5 bit planes */ ReColorSlow() { LONG i, j, x, y, xl, yl; SHORT *CountPtr = CountBase; UBYTE T[1030]; UBYTE OldColor; UBYTE NewColor; j = MaxCount; for (i = 0; i < NUMCONTS && j >= 0; i++) for (; j >= ContourBase[i] && j >=0 ; ) T[j--] = ColorBase[i]; while (j >= 0) T[j--] = 0; OldColor = 0xff; xl = CountX + LEFTMARG; yl = CountY + TOPMARG; for (y = TOPMARG; y < yl; y++) { for (x = LEFTMARG; x < xl; x++) { NewColor = T[ *CountPtr++ ]; if ( NewColor != OldColor) { SetAPen( rp, NewColor ); OldColor = NewColor; } if (NewColor) WritePixel(rp, x, y); } } } /* ReColorSlow */ /* * Allocate all the gadgets and things for the contour window */ struct Gadget *MakeContours() { struct Gadget *FirstGadget, *NextGadget, *OldGadget; extern struct Gadget *MakeBool(), *MakePot(); extern struct IntuiText *MakeIntui(); USHORT i,x,y; UBYTE c = 0; struct PropInfo *PropInfo; FirstGadget = OldGadget = MakePot(228, 26, 4, 32, CONTCEIL, 0); if (OldGadget == (struct Gadget *) NULL) goto error; for (x = y = 0; x < 2; y += 10, x++) { NextGadget = MakeBool(234,y+14,6,6,1,CONTCNTL+x); if (NextGadget == (struct Gadget *) NULL) goto error; switch (x) { case 0: NextGadget->GadgetText = MakeIntui("ReColor",10,-1,3,3,JAM1); break; case 1: NextGadget->GadgetText = MakeIntui("Smooth",10,-1,3,3,JAM1); break; } OldGadget->NextGadget = NextGadget; OldGadget = NextGadget; } for (x = y = 0; y < NumContours; x += 6, y++) { NextGadget = MakeBool(4+x, 12,4,4,Colors[y],CONTSEL+y); if (NextGadget == (struct Gadget *) NULL) goto error; OldGadget->NextGadget = NextGadget; OldGadget = SelGadget[y] = NextGadget; } NextGadget->GadgetText = MakeIntui("Set",6,-2,3,3,JAM1); for (x = y = 0; y < NumContours; x += 6, y++) { NextGadget = MakeBool(4+x, 18, 4, 4, 3, CONTUP + y); if (NextGadget == (struct Gadget *) NULL) goto error; OldGadget->NextGadget = NextGadget; OldGadget = NextGadget; } NextGadget->GadgetText = MakeIntui("+",6,-2,3,3,JAM1); /* * Allocate the potentiometer gadgets for contour window */ for (x = y = 0; y < NumContours; x += 6, y++) { NextGadget = MakePot(4+x, 24, 4, 32, CONTPOT+y, y); if (NextGadget == (struct Gadget *) NULL) goto error; PropInfo = (struct PropInfo *) NextGadget->SpecialInfo; if (ContourBase[y] < Ceiling) { PropInfo->VertPot = (USHORT) ((((Ceiling - (ContourBase[y] + 1))<<16)/(Ceiling)) & 0xffff); } else PropInfo->VertPot = 0; OldGadget->NextGadget = NextGadget; ContGadget[y] = NextGadget; OldGadget = NextGadget; } NextGadget->GadgetText = MakeIntui("Alt.",6,12,3,3,JAM1); /* * Allocate the push button gadgets for decrementing contours */ for (x = y = 0; y < NumContours; x += 6, y++) { NextGadget = MakeBool(4+x, 58, 4, 4, 3, CONTDOWN + y); if (NextGadget == (struct Gadget *) NULL) goto error; if (y == NUMCONTS - 1) { NextGadget->GadgetText = MakeIntui("-",6,-2,3,3,JAM1); } OldGadget->NextGadget = NextGadget; OldGadget = NextGadget; } return( FirstGadget ); error: FreeGadgets(FirstGadget); return((struct Gadget *) NULL); } /* MakeContours */ /* * Open the Contour window */ OpenContWind() { struct Window *OpenMyWind(); struct Gadget *gadgets; extern USHORT YScale; if (ContWind == (struct Window *) NULL) { gadgets = MakeContours(); if (gadgets == (struct Gadget *) NULL) { DispErrMsg("Can't allocate contour gadget chain",0); return(0); } NewCont.TopEdge = 119 << YScale; ContWind = OpenMyWind(&NewCont, screen, gadgets, 320, 80, 320, 80); if (ContWind == (struct Window *) NULL) { DispErrMsg("Can't open Contour window",0); FreeGadgets(gadgets); return(0); } SetContTitle(0); DrawContBox(CurContour); ForceNormPointer(); } else { WindowToFront( ContWind ); } return(1); } /* OpenContWind */ /* * Close the Mand window */ CloseContWind() { if (ContWind != (struct Window *) NULL) { CloseMyWind(ContWind,NewCont.FirstGadget); ContWind = (struct Window *) NULL; } } /* ClosePalWind */ /* * ReDisplay a given contour potentiometer gadget */ ReString(PotNum) SHORT PotNum; { SHORT i; USHORT VertPot; if (ContourBase[PotNum] < Ceiling) VertPot = (USHORT) ((((Ceiling - (ContourBase[PotNum]+1))<<16)/(Ceiling)) & 0xffff); else VertPot = (USHORT) 0; NewModifyProp(ContGadget[PotNum], ContWind, NULL, FREEVERT | PROPBORDERLESS, 0L, VertPot, 0L, 0L, 1L); } /* ReString */ /* * ReDisplay all the contour potentiometer gadgets */ ModAll() { SHORT i; USHORT VertPot; struct Gadget *PropGad = (struct Gadget *) ContGadget[0]; for (i = 0; i < NUMCONTS; i++) { if (ContourBase[i] < Ceiling) { VertPot = (USHORT) ((((Ceiling - (ContourBase[i] + 1))<<16)/(Ceiling)) & 0xffff); } else VertPot = (USHORT) 0; NewModifyProp(PropGad,ContWind,NULL,FREEVERT|PROPBORDERLESS,0L,VertPot,0L,0L,1L); PropGad = PropGad->NextGadget; } } /* ModAll */ //E*O*F contour.c// echo x - disp.c cat > "disp.c" << '//E*O*F disp.c//' /************************************************************************** * * MandelVroom Display Setup/Cleanup * * Kevin L. Clague * * Copyright (C) 1987 * **************************************************************************/ #include "mand.h" extern struct Window *MandWind, *ContWind, *PalWind; extern struct NewWindow NewMand, NewCont, NewPal; extern struct Menu Menu; extern struct Windows { struct Windows *NextWindow; struct Window *Window; } *WindowList; extern struct MenuItem ViewModeSubs[]; extern SHORT *ContourBase,Ceiling; extern SHORT CountX, CountY; struct IntuitionBase *IntuitionBase; struct GfxBase *GfxBase; struct MathBase *MathBase; struct Screen *screen = (struct Screen *) NULL; struct RastPort *rp; struct ViewPort *vp; USHORT YScale, XScale; USHORT *BabyBrotPointer = (USHORT *) NULL; USHORT *BabyToPointer = (USHORT *) NULL; USHORT *SleepyPointer = (USHORT *) NULL; /* pointer types */ #define UNINITIALIZED 0 #define NORMPOINTER 1 #define TOPOINTER 2 #define SLEEPYPOINTER 3 UBYTE PointerType = UNINITIALIZED; SHORT SavePalette[32]; SHORT Inited; extern USHORT CmdMode; struct NewScreen NewScreen = { 0,0, /* start position */ 320, 200, 5, /* width, height, depth */ (UBYTE) 0, (UBYTE) 1, /* detail pen, block pen */ (USHORT) NULL, /* HIRES, INTERLACE, SPRITES, DUAL, HAM */ CUSTOMSCREEN, /* screen type */ (struct TextAttr *) NULL, /* font to use */ (UBYTE *) " MandelVroom v1.50 by Kevin L. Clague", (struct Gadget *) NULL /* pointer to extra gadgets */ }; /*************************************************************************** * * Open the Libraries and custom screen * **************************************************************************/ /* * Open the libraries */ OpenLibs() { IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library",0); if (IntuitionBase == (struct IntuitionBase *) NULL) { printf("Couldn't get Intuition\n"); return(100); } GfxBase = (struct GfxBase *) OpenLibrary("graphics.library",0); if (GfxBase == (struct GfxBase *) NULL) { printf("Couldn't get Graphics\n"); return(100); } MathBase = (struct MathBase *) OpenLibrary("mathffp.library",0); if (MathBase == (struct MathBase *) NULL) { printf("Couldn't get MathFFP\n"); return(100); } return(0); } /* OpenLibs */ /* * Close the libraries used */ CloseLibs() { if (IntuitionBase != (struct IntuitionBase *) NULL) CloseLibrary(IntuitionBase); if (GfxBase != (struct GfxBase *) NULL) CloseLibrary(GfxBase); if (MathBase != (struct MathBase *) NULL) CloseLibrary(MathBase); } /* CloseLibs */ /* * Open the display */ OpenDisp() { SHORT i; struct Window *OpenMyWind(); struct Screen *OpenScreen(); if (NewScreen.ViewModes & HIRES) { NewScreen.Width = 640; if ( NewScreen.Depth > 4 ) NewScreen.Depth = 4; XScale = 1; } else { NewScreen.Width = 320; XScale = 0; } if (NewScreen.ViewModes & INTERLACE) { NewScreen.Height = 400; YScale = 1; } else { NewScreen.Height = 200; YScale = 0; } screen = OpenScreen( (struct NewScreen *) &NewScreen); if (screen == (struct Screen *) NULL) { AndDie("Can't open new screen!\n"); } InitViewModesSubs(); InitDepthSubs(); InitGenSubs(); InitMaxISubs(); AllocateMice(); OpenMandWind(); if ( MandWind == (struct Window *) NULL ) { AndDie("Can't open Picture window\n"); } rp = MandWind->RPort; vp = &screen->ViewPort; if ( Inited ) LoadRGB4(vp, &SavePalette[0], 32); Inited = 1; return(0); } /* opendisp */ /* * Close the screen */ CloseDisp() { LONG i; ClosePalWind(); CloseContWind(); CloseMandWind(); if (Inited) for (i = 0; i < 32; i++) SavePalette[i] = GetRGB4(vp->ColorMap, i); if ( screen ) CloseScreen(screen); FreeMice(); } /* CloseDisp */ AndDie( ErrMsg ) char *ErrMsg; { extern SHORT *CountBase; printf("%s\n", ErrMsg); CloseLibs(); CloseDisp(); if (CountBase) FreeMem( CountBase, CountX * CountY * sizeof( USHORT ) ); printf("Something unrecoverable happened!!!\n"); exit(0); } /*************************************************************************** * * Open and Close Window tools * **************************************************************************/ /* * Open a window and put it in the window list */ struct Window *OpenMyWind(NewWind, Screen, Gadgets, Width, Height, MaxWidth, MaxHeight) struct NewWindow *NewWind; struct Screen *Screen; struct Gadget *Gadgets; SHORT Width, Height, MaxWidth, MaxHeight; { struct Window *Window, *OpenWindow(); struct Windows *Windows; NewWind->Screen = Screen; NewWind->FirstGadget = Gadgets; NewWind->Width = Width << XScale; NewWind->Height = Height << YScale; NewWind->MaxWidth = MaxWidth << XScale; NewWind->MaxHeight = MaxHeight << YScale; Window = OpenWindow( (struct NewWindow *) NewWind); if (Window == (struct Window *) NULL) { DispErrMsg("Can't open new window",0); return( (struct Window *) NULL); } Windows = (struct Windows *) AllocMem(sizeof(struct Windows), MEMF_CLEAR); if (Windows == (struct Windows *) NULL) { DispErrMsg("Can't malloc Windows. Out of RAM!!",0); return( (struct Window *) NULL); } Windows->Window = Window; if (WindowList) Windows->NextWindow = WindowList; WindowList = Windows; SetMenuStrip(Window, &Menu); return(Window); } /* OpenMyWind */ /* * Remove the window from the window list, * deallocate all the gadgets associated with this window */ CloseMyWind(Window,Gadgets) struct Window *Window; struct Gadget *Gadgets; { struct Windows *Windows = WindowList, *PrevWinds = WindowList; if (Window) { /* get rid of the menu */ ClearMenuStrip(Window); /* get rid of the previous pointer */ ClearPointer(Window); if (Window == Windows->Window) { WindowList = WindowList->NextWindow; FreeMem(Windows,sizeof(struct Windows)); } else { while (Windows && Windows->Window != Window) { PrevWinds = Windows; Windows = Windows->NextWindow; } if (Windows) { PrevWinds->NextWindow = Windows->NextWindow; FreeMem(Windows,sizeof(struct Windows)); } } CloseWindow(Window); if (Gadgets) FreeGadgets(Gadgets); } } /* CloseMyWind */ /************************************************************************* * * Allocate and ititialize gadget tools * ************************************************************************/ /* * Make a generic boolean gadget */ struct Gadget *MakeBool(x,y,xd,yd,c,id) SHORT x,y,xd,yd; UBYTE c; USHORT id; { struct Gadget *NewGadget; struct Image *NewImage; NewGadget = (struct Gadget *) AllocMem( (LONG) sizeof(struct Gadget), (LONG) MEMF_CLEAR ); if (NewGadget == (struct Gadget *) NULL) return((struct Gadget *) NULL); NewImage = (struct Image *) AllocMem( (LONG) sizeof(struct Image), (LONG) MEMF_CHIP | MEMF_CLEAR ); if (NewImage == (struct Image *) NULL) { FreeMem( NewGadget, (LONG) sizeof(struct Gadget)); return((struct Gadget *) NULL); } NewGadget->LeftEdge = x << XScale; NewGadget->TopEdge = y << YScale; NewGadget->Width = xd << XScale; NewGadget->Height = yd << YScale; NewGadget->Flags = GADGHCOMP | GADGIMAGE; NewGadget->Activation = GADGIMMEDIATE; NewGadget->GadgetRender = (APTR) NewImage; NewGadget->GadgetType = BOOLGADGET; NewGadget->GadgetID = id; NewImage->Width = xd << XScale; NewImage->Height = yd << YScale; NewImage->PlaneOnOff = c; return(NewGadget); } /* MakeBool */ /* * Make a generic potentiometer gadget */ struct Gadget *MakePot(x, y, xd, yd, id, cnt) SHORT x,y,xd,yd; USHORT id; USHORT cnt; { struct Gadget *NewGadget; struct PropInfo *NewInfo; struct Image *NewImage; NewGadget = (struct Gadget *) AllocMem( (LONG) sizeof(struct Gadget), MEMF_CLEAR ); if (NewGadget == (struct Gadget *) NULL) return((struct Gadget *) NULL); NewImage = (struct Image *) AllocMem( (LONG) sizeof(struct Image), (LONG) MEMF_CHIP | MEMF_CLEAR ); if (NewImage == (struct Image *) NULL) { FreeMem( NewGadget, (LONG) sizeof(struct Gadget)); return((struct Gadget *) NULL); } NewInfo = (struct PropInfo *) AllocMem( (LONG) sizeof(struct PropInfo), MEMF_CLEAR ); if (NewInfo == (struct PropInfo *) NULL) { FreeMem( NewGadget, (LONG) sizeof(struct Gadget)); FreeMem( NewImage, (LONG) sizeof(struct Image)); return((struct Gadget *) NULL); } NewGadget->LeftEdge = x << XScale; NewGadget->TopEdge = y << YScale; NewGadget->Width = xd << XScale; NewGadget->Height = yd << YScale; NewGadget->Flags = GADGHIMAGE | GADGIMAGE; NewGadget->Activation = RELVERIFY; NewGadget->GadgetType = PROPGADGET; NewGadget->GadgetRender = (APTR) NewImage; NewGadget->SelectRender = (APTR) NewImage; NewGadget->SpecialInfo = (APTR) NewInfo; NewGadget->GadgetID = id; NewImage->PlaneOnOff = 1; NewImage->Width = 4 << XScale; NewImage->Height = 3 << YScale; NewInfo->Flags = PROPBORDERLESS | FREEVERT; return(NewGadget); } /* MakePot */ /* * Make an IntuiText structure */ struct IntuiText *MakeIntui(str, x, y, frontpen, backpen, drawmode ) UBYTE *str; SHORT x, y; UBYTE frontpen, backpen, drawmode; { struct IntuiText *NewIntui; NewIntui = (struct IntuiText *) AllocMem( (LONG) sizeof(struct IntuiText), (LONG) MEMF_CLEAR ); if (NewIntui == (struct IntuiText *) NULL) return((struct IntuiText *) NULL); NewIntui->FrontPen = frontpen; NewIntui->BackPen = backpen; NewIntui->DrawMode = drawmode; NewIntui->LeftEdge = x << XScale; NewIntui->TopEdge = y << YScale; NewIntui->IText = str; return(NewIntui); } /* MakeIntui */ /* * Free a string of gadgets */ FreeGadgets(FirstGadget) struct Gadget *FirstGadget; { struct Gadget *NextGadget; while (FirstGadget) { if (FirstGadget->GadgetRender) FreeMem(FirstGadget->GadgetRender, (LONG) sizeof(struct Image)); if (FirstGadget->SpecialInfo) FreeMem(FirstGadget->SpecialInfo, (LONG) sizeof(struct PropInfo)); if (FirstGadget->GadgetText) FreeMem(FirstGadget->GadgetText, (LONG) sizeof(struct IntuiText)); NextGadget = FirstGadget->NextGadget; FreeMem(FirstGadget, (LONG) sizeof(struct Gadget)); FirstGadget = NextGadget; } } /* FreeGadgets */ /*************************************************************************** * * This section handles the Mouse pointer for the custom screen * **************************************************************************/ /***************************************************************/ /* This is the image for baby Mandelbrot pointer */ /***************************************************************/ USHORT BabyBrotSprite[]= { /*plane1 plane0 */ 0x0000, 0x0000, 0x8000, 0x0000, 0x0000, 0x5000, 0x2000, 0x2202, 0x1600, 0x5f82, 0x0802, 0x1913, 0x1152, 0x11fe, 0x1008, 0x300a, 0x0404, 0x1c06, 0x0006, 0x1407, 0x0404, 0x0404, 0x000c, 0x042c, 0x0400, 0x0c1c, 0x0220, 0x0630, 0x01e0, 0x05f0, 0x0c80, 0x3f80, 0x0000, 0x0880, 0x0000, 0x0000, }; /***************************************************************/ /* This is a baby brot pointer with 'TO' in it. */ /***************************************************************/ USHORT BabyToSprite[]= { /*plane1 plane0 */ 0x0000, 0x0000, 0x8000, 0x0000, 0x0100, 0x5100, 0x2000, 0x2202, 0x1600, 0x5f82, 0xfe7a, 0x0103, 0x93de, 0x0132, 0x108c, 0x200a, 0x5484, 0x4c02, 0x1086, 0x0403, 0x1484, 0x0400, 0x10cc, 0x0420, 0x3c78, 0x0404, 0x0220, 0x0630, 0x01e0, 0x05f0, 0x0c80, 0x3f80, 0x0000, 0x0880, 0x0000, 0x0000, }; /***************************************************************/ /* This is a sleepy cloud pointer */ /***************************************************************/ USHORT SleepySprite[] = { 0x0000, 0x0000, 0x0fe0, 0x0000, 0x1830, 0x07c0, 0x7018, 0x0fe0, 0xc008, 0x3ff0, 0x9e0c, 0x7ff0, 0x8406, 0x7ff8, 0x8802, 0x7ffc, 0x1e03, 0xfffc, 0x80f1, 0x7ffe, 0x8021, 0x7ffe, 0x4040, 0x3fff, 0x80f1, 0x7ffe, 0xc001, 0x3ffe, 0x6003, 0x1ffc, 0x3006, 0x0ff8, 0x180c, 0x07f0, 0x0718, 0x00e0, 0x0070, 0x0f80, 0x1810, 0x07e0, 0x0820, 0x0740, 0x0ff0, 0x0000, 0x0020, 0x03c0, 0x0410, 0x03e0, 0x0310, 0x00e0, 0x00e0, 0x0000, 0x0000, 0x0000, }; /* defines for the cute pointer sprite */ #define MYSPRITE_WIDTH 16 #define MYSPRITE_HEIGHT 16 #define SLEEPY_WIDTH 16 #define SLEEPY_HEIGHT 25 #define MYSPRITE_HOTX -1 #define MYSPRITE_HOTY 0 #define BABYSIZE ( (MYSPRITE_HEIGHT + 2) * 8) #define TOSIZE ( (MYSPRITE_HEIGHT + 2) * 8) #define SLEEPYSIZE ( (SLEEPY_HEIGHT + 2) * 8) /* * Copy an Image into a chip ram image */ USHORT *MakeChipSprite( FastRamSprite, Size ) USHORT *FastRamSprite; int Size; { USHORT *ChipSprite, *SaveSprite, *AllocaMem(); int i; ChipSprite = AllocMem( (LONG) (Size * sizeof(SHORT)), MEMF_CHIP ); if ( ChipSprite == (struct USHORT * ) NULL ) return ( ChipSprite ); SaveSprite = ChipSprite; for ( i = 0; i < Size; i++) *(ChipSprite++) = *(FastRamSprite++); return( SaveSprite ); } /* * Allocate all the mouse pointer sprites used by this program */ AllocateMice() { BabyBrotPointer = MakeChipSprite( BabyBrotSprite, BABYSIZE ); BabyToPointer = MakeChipSprite( BabyToSprite, TOSIZE ); SleepyPointer = MakeChipSprite( SleepySprite, SLEEPYSIZE ); } /* * Free all the mouse pointer sprites used by this program */ FreeMice() { if ( BabyBrotPointer ) FreeMem( BabyBrotPointer, BABYSIZE * sizeof(SHORT) ); BabyBrotPointer = NULL; if ( BabyToPointer ) FreeMem( BabyToPointer, TOSIZE * sizeof(SHORT) ); BabyToPointer = NULL; if ( SleepyPointer ) FreeMem( SleepyPointer, SLEEPYSIZE * sizeof(SHORT) ); SleepyPointer = NULL; } /* * Set all window pointers NewPointer */ SetPointers( NewPointer, Height, Width) USHORT *NewPointer; int Height, Width; { if (NewPointer == (struct USHORT *) NULL ) return(); if ( ContWind ) SetPointer( ContWind, NewPointer, Height, Width, MYSPRITE_HOTX, MYSPRITE_HOTY); if ( MandWind ) SetPointer( MandWind, NewPointer, Height, Width, MYSPRITE_HOTX, MYSPRITE_HOTY); if ( PalWind ) SetPointer( PalWind, NewPointer, Height, Width, MYSPRITE_HOTX, MYSPRITE_HOTY); } /* * Clear the window pointers */ ClearPointers() { if ( MandWind ) ClearPointer( MandWind ); if ( ContWind ) ClearPointer( ContWind ); if ( PalWind ) ClearPointer( PalWind ); } /* * Force normal pointers */ ForceNormPointer() { PointerType = UNINITIALIZED; SetNormPointer(); } /* * Set Normal Mouse Pointer */ SetNormPointer() { if (PointerType != NORMPOINTER ) { ClearPointers(); SetPointers( BabyBrotPointer, MYSPRITE_HEIGHT, MYSPRITE_WIDTH ); PointerType = NORMPOINTER; } CmdMode = NULL; } /* * Set 'To' Mouse Pointer */ SetToPointer() { if (PointerType != TOPOINTER ) { ClearPointers(); SetPointers( BabyToPointer, MYSPRITE_HEIGHT, MYSPRITE_WIDTH ); PointerType = TOPOINTER; } } /* * Set Sleepy Mouse Pointer */ SetSleepyPointer() { if (PointerType != SLEEPYPOINTER ) { ClearPointers(); SetPointers( SleepyPointer, SLEEPY_HEIGHT, SLEEPY_WIDTH ); PointerType = SLEEPYPOINTER; } } SetSystemColors(flag) int flag; { UWORD red, green, blue; static SHORT MenuColors[4] = { 0x0000, 0x0fff, 0x000a, 0x0b44 }; static SHORT PointerColors[4] = { 0x0000, 0x00c0, 0x0dd0, 0x0f00 }; static SHORT ColorSave[32]; static SHORT SaveFull = 0; int i; if (flag) { if (SaveFull == 0) { for (i = 0; i < 32; i++) { ColorSave[i] = GetRGB4(vp->ColorMap, i); } /* Set the colors for the Menu */ for (i = 0; i < 4; i++) { red = (MenuColors[i] & 0xf00) >> 8; green = (MenuColors[i] & 0x0f0) >> 4; blue = (MenuColors[i] & 0x00f) ; SetRGB4(vp, i , red , green, blue); } /* Set the colors for the Mouse pointer */ for (i = 0; i < 4; i++) { red = (PointerColors[i] & 0xf00) >> 8; green = (PointerColors[i] & 0x0f0) >> 4; blue = (PointerColors[i] & 0x00f) ; SetRGB4(vp, i + 16, red , green, blue); } } SaveFull++; } else { if (SaveFull == 1) LoadRGB4(vp, &ColorSave[0], 32); if (--SaveFull < 0) SaveFull = 0; } } /************************************************************************** * * This code is used to display error messages on the cusom screen * **************************************************************************/ struct IntuiText msg_txt = { 0, 1, JAM2, 5, 20, NULL, NULL, NULL }; struct IntuiText OK_txt = { 0, 1, JAM2, 5, 3, NULL, (UBYTE *) "OK", NULL }; struct IntuiText NO_txt = { 0, 1, JAM2, 5, 3, NULL, (UBYTE *) "NO", NULL }; DispErrMsg(ErrMsg, Flag) UBYTE *ErrMsg; SHORT Flag; { msg_txt.IText = ErrMsg; SetNormPointer(); if (MandWind) { SetSystemColors(1); if (Flag) { AutoRequest(MandWind, &msg_txt, &OK_txt, &NO_txt, 0L, 0L, (long) (IntuiTextLength(&msg_txt) + 50L), 70L); } else { AutoRequest(MandWind, &msg_txt, 0L, &OK_txt, 0L, 0L, (long) (IntuiTextLength(&msg_txt) + 50L), 70L); } SetSystemColors(0); } else { printf("%s\n", ErrMsg); } } //E*O*F disp.c// echo Possible errors detected by \'wc\' [hopefully none]: temp=/tmp/shar$$ trap "rm -f $temp; exit" 0 1 2 3 15 cat > $temp <<\!!! 41 128 1097 Makefile 8 55 345 README 1115 4155 31593 contour.c 786 2110 18438 disp.c 1950 6448 51473 total !!! wc Makefile README contour.c disp.c | sed 's=[^ ]*/==' | diff -b $temp - exit 0 -- UUCP: orandy@amdahl.amdahl.com or: {sun,decwrl,hplabs,pyramid,ihnp4,seismo,oliveb,cbosgd}!amdahl!orandy DDD: 408-737-5481 USPS: Amdahl Corp. M/S 249, 1250 E. Arques Av, Sunnyvale, CA 94086 [ Any thoughts or opinions which may or may not have been expressed ] [ herein are my own. They are not necessarily those of my employer. ]