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 (5 of 8) Message-ID: <6767@amdahl.amdahl.com> Date: Tue, 19-May-87 21:22:33 EDT Article-I.D.: amdahl.6767 Posted: Tue May 19 21:22:33 1987 Date-Received: Thu, 21-May-87 03:00:09 EDT Organization: Amdahl Corporation, Sunnyvale, CA 94086 Lines: 1425 Keywords: MandelVroom sources 3 # 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: # palette.c presets.c savemand.c echo x - palette.c cat > "palette.c" << '//E*O*F palette.c//' /*************************************************************************** * * MandleVroom Color Palette * * Kevin L. Clague * * Copyright (C) 1987 * **************************************************************************/ #include "mand.h" extern USHORT CurContour; extern struct Gadget *ContGadget[], *SelGadget[]; extern struct Window *ContWind, *MandWind; /* * Holder for Allocated color potentiometer gadgets. */ struct ColorGads { struct Gadget *RedPot; struct Gadget *GreenPot; struct Gadget *BluePot; }; extern struct Screen *screen; extern struct ViewPort *vp; extern struct IntuitionBase *IntuitionBase; extern char *ColorBase; extern struct IntuiText *MakeIntui(); struct Window *PalWind; extern SHORT XScale, YScale; extern struct Window *ContWind; struct ColorGads PalGads; USHORT CmdMode; USHORT CurPen; struct NewWindow NewPal = { 122,0, /* start position */ 90,120, /* width, height */ (UBYTE) 0, (UBYTE) 1, /* detail pen, block pen */ /* IDCMP flags */ MENUPICK | GADGETDOWN | GADGETUP | MOUSEMOVE | REQCLEAR| CLOSEWINDOW, /* MandWind flags */ WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH | SIMPLE_REFRESH | NOCAREREFRESH, (struct Gadget *) NULL, /* first gadget */ (struct Image *) NULL, /* user checkmark */ (UBYTE *) "Colors", /* window title */ (struct Screen *) NULL, /* pointer to screen */ (struct BitMap *) NULL, /* pointer to superbitmap */ 80,80,80,80, /* sizing */ CUSTOMSCREEN /* type of screen */ }; extern struct Windows *WindowList; /* * Interpret the gadgets and do the right thing */ DoPalette(gadget) struct Gadget *gadget; { switch (gadget->GadgetID >> TYPEBITS & TYPEMASK) { case PALPENS: ColorPenGotten(gadget); SetNormPointer(); break; case PALCNTLS: ColorCntlGotten(gadget); break; case PALPOTS: SetNormPointer(); CmdMode = COLORSLIDE; break; } } /* DoPalette */ /* * We got a color palette command gadget */ int ColorCntlGotten(gadget) struct Gadget *gadget; { switch (gadget->GadgetID) { case PALCOPY: SetToPointer(); CmdMode = COPY; break; case PALRANGE: SetToPointer(); CmdMode = RANGE; break; case PALEXCG: SetToPointer(); CmdMode = EXCG; break; } } /* ColorCntlGotten */ /* * We got a color pen. Now what was the command we were supposed to perform? */ int ColorPenGotten(gadget) struct Gadget *gadget; { USHORT rgb, rgb2, pen; struct Image *Image; BoxPen((USHORT) CurPen, 0); pen = gadget->GadgetID & 0x003f; switch (CmdMode) { case COPY: rgb = GetRGB4(vp->ColorMap, CurPen); SetRGB4(vp, pen, rgb >> 8, rgb >> 4, rgb); break; case RANGE: ColorRange(CurPen, pen); break; case EXCG: rgb = GetRGB4(vp->ColorMap, CurPen); rgb2 = GetRGB4(vp->ColorMap, pen); SetRGB4(vp, CurPen, rgb2 >> 8, rgb2 >> 4, rgb2 ); SetRGB4(vp, pen, rgb >> 8, rgb >> 4, rgb ); break; case IMPLIEDSET: Image = (struct Image *) SelGadget[ CurContour ]->GadgetRender; Image->PlaneOnOff = pen; RefreshGList( SelGadget[ CurContour ], ContWind, NULL, 1); *(ColorBase + CurContour) = pen; break; } CurPen = pen; SetColorProps( pen ); BoxPen( pen, 1); } /* ColorPenGotten */ /* * Blend a range of colors between two pens */ int ColorRange(first, last) SHORT first, last; { SHORT i; LONG whole, redfraction, greenfraction, bluefraction; USHORT rgb; SHORT firstred, firstgreen, firstblue; SHORT lastred, lastgreen, lastblue; SHORT workred, workgreen, workblue; if (first > last) { i = first; first = last; last = i; } /* I need to see a spread of at least two, where there's at least one * spot between the endpoints, else there's no work to do so I * might as well just return now. */ if (first >= last - 1) return; rgb = GetRGB4(vp->ColorMap, first); firstred = (rgb >> 8) & 0xF; firstgreen = (rgb >> 4) & 0xF; firstblue = (rgb >> 0) & 0xF; rgb = GetRGB4(vp->ColorMap, last); lastred = (rgb >> 8) & 0xF; lastgreen = (rgb >> 4) & 0xF; lastblue = (rgb >> 0) & 0xF; whole = (lastred - firstred) << 16; redfraction = whole / (last - first); whole = (lastgreen - firstgreen) << 16; greenfraction = whole / (last - first); whole = (lastblue - firstblue) << 16; bluefraction = whole / (last - first); for (i = first + 1; i < last; i++) { lastred = (redfraction * (i - first) + 0x8000) >> 16; workred = firstred + lastred; lastgreen = (greenfraction * (i - first) + 0x8000) >> 16; workgreen = firstgreen + lastgreen; lastblue = (bluefraction * (i - first) + 0x8000) >> 16; workblue = firstblue + lastblue; SetRGB4(vp, i, workred, workgreen, workblue); } } /* ColorRange */ /* * Modify the colors in the current pen */ ModifyColors() { USHORT newred, newgreen, newblue; newred = ((struct PropInfo *) PalGads.RedPot->SpecialInfo)->VertPot >> 12; newgreen = ((struct PropInfo *) PalGads.GreenPot->SpecialInfo)->VertPot >> 12; newblue = ((struct PropInfo *) PalGads.BluePot->SpecialInfo)->VertPot >> 12; SetRGB4(vp, CurPen, newred, newgreen, newblue); } /* ModifyColors */ /* * Reflect a pen's new color in the proportional gadget */ SetColorProps(pen) USHORT pen; { USHORT rgb, red, green, blue; rgb = GetRGB4(vp->ColorMap, pen); red = (rgb >> 8) & 0xF; green = (rgb >> 4) & 0xF; blue = (rgb >> 0) & 0xF; red = (red << 12); green = (green << 12); blue = (blue << 12); ModifyProp(PalGads.RedPot, PalWind,NULL,FREEVERT|PROPBORDERLESS, 0L,red,0L,0L); ModifyProp(PalGads.GreenPot,PalWind,NULL,FREEVERT|PROPBORDERLESS, 0L,green,0L,0L); ModifyProp(PalGads.BluePot, PalWind,NULL,FREEVERT|PROPBORDERLESS, 0L,blue,0L,0L); } /* SetColorProps */ BoxPen(BoxPen, DrawPen) USHORT BoxPen, DrawPen; { ULONG row, column; SHORT Top, Bot, Left, Right; #define PALTOP (12 << YScale) #define PALLEFT (4 << XScale) #define PENWIDTH (4 << XScale) #define PENHEIGHT (4 << YScale) #define PENXPITCH (6 << XScale) #define PENYPITCH (6 << YScale) column = BoxPen/8; row = BoxPen - column*8; SetAPen(PalWind->RPort, DrawPen); Left = PALLEFT + PENXPITCH * column - 1; Top = PALTOP + PENYPITCH * row - 1; Right = Left + PENWIDTH + 1; Bot = Top + PENHEIGHT + 1; Move(PalWind->RPort, Left, Top); Draw(PalWind->RPort, Right, Top); Draw(PalWind->RPort, Right, Bot); Draw(PalWind->RPort, Left, Bot); Draw(PalWind->RPort, Left, Top + 1); } /* * Allocate all the gadgets for the color palette window */ struct Gadget *MakePalette() { struct Gadget *FirstGadget, *NextGadget; extern struct Gadget *MakeBool(), *MakePot(); SHORT i,Left,x,y,c = 0; FirstGadget = NextGadget = MakeBool(4,12,5,5,0,PALPEN); i = 1 << (screen->BitMap.Depth); Left = 8; for (x = 0; x < 6*8 && i > 0; x += 6) { for (y = 0; y < 6*8 && i > 0; y += 6) { if (c != 0) { NextGadget->NextGadget = MakeBool(x+4, y+12, 4, 4, c, PALPEN+c); if ((NextGadget = NextGadget->NextGadget) == (struct Gadget *) NULL) return(FirstGadget); } c++; i--; } Left += 8; } for (c = 0, x = 0; x < 10*3; x += 10) { NextGadget->NextGadget = MakeBool(Left+36, x+12, 10, 6, 1, PALCNTL+c); if (NextGadget->NextGadget == (struct Gadget *) NULL) return(FirstGadget); switch (c) { case 0: NextGadget->NextGadget->GadgetText = MakeIntui("Copy",14,-1,3,3,JAM1); break; case 1: NextGadget->NextGadget->GadgetText = MakeIntui("Spread",14,-1,3,3,JAM1); break; case 2: NextGadget->NextGadget->GadgetText = MakeIntui("Exchg",14,-1,3,3,JAM1); break; } NextGadget = NextGadget->NextGadget; c++; } for (x = y = 0; y < 3; x += 10, y++) { NextGadget->NextGadget = MakePot(Left+x, 22, 5, 42, PALPOT + y, y); if (NextGadget->NextGadget == (struct Gadget *) NULL) return(FirstGadget); switch (y) { case 0: PalGads.RedPot = NextGadget->NextGadget; NextGadget->NextGadget->GadgetText = MakeIntui("R",-2,-10,3,3,JAM1); break; case 1: PalGads.GreenPot = NextGadget->NextGadget; NextGadget->NextGadget->GadgetText = MakeIntui("G",-2,-10,3,3,JAM1); break; case 2: PalGads.BluePot = NextGadget->NextGadget; NextGadget->NextGadget->GadgetText = MakeIntui("B",-2,-10,3,3,JAM1); break; } NextGadget = NextGadget->NextGadget; NextGadget->Activation = GADGIMMEDIATE | FOLLOWMOUSE | RELVERIFY; } return(FirstGadget); } /* MakePalette */ /* * Open the Palette window */ OpenPalWind() { struct Window *OpenMyWind(); if (PalWind == (struct Window *) NULL) { PalWind = OpenMyWind(&NewPal,screen,MakePalette(),140,70,140,70); if (PalWind) { CurPen = 0; BoxPen(CurPen, 1); SetColorProps( CurPen ); ForceNormPointer(); } } else { WindowToFront( PalWind ); } } /* OpenPalWind */ /* * Close the Palette window */ ClosePalWind() { if (PalWind != (struct Window *) NULL) { CloseMyWind(PalWind,NewPal.FirstGadget); PalWind = (struct Window *) NULL; } } /* ClosePalWind */ //E*O*F palette.c// echo x - presets.c cat > "presets.c" << '//E*O*F presets.c//' /*************************************************************************** * * MandelVroom Preset Pictures code * * Kevin L. Clague * * Copyright (C) 1987 * **************************************************************************/ #include "mand.h" #define NUMPRESETS 10 extern struct ViewPort *vp; extern struct Screen *screen; extern struct NewScreen NewScreen; extern struct Window *MandWind; extern float StartX,StartY,EndX,EndY; extern SHORT CountX,CountY,MaxCount; extern SHORT NumContours, *ContourBase; extern UBYTE *ColorBase; extern UBYTE MandType; extern ULONG BorderType; extern SHORT *CountBase; struct Preset { char *Name; float StartX, StartY, EndX, EndY; SHORT CountX, CountY; SHORT MaxCount; UBYTE MandType; USHORT ViewModes; USHORT Depth; ULONG BorderType; SHORT *ColorMap; SHORT NumContours; USHORT *Contours; UBYTE *Pens; }; extern struct Preset Preset[]; /* * Generate a preset picture */ SetPreset(Number) int Number; { if (InitPreset(Number) == 0) { CloseDisp(); OpenDisp(); if (MandWind->Width != CountX + LEFTMARG + RIGHTMARG || MandWind->Height != CountY + TOPMARG + BOTMARG) SizeWindow(MandWind, CountX + LEFTMARG + RIGHTMARG - MandWind->Width, CountY + TOPMARG + BOTMARG - MandWind->Height); Delay(1); GenerateIt(); } } /* * Set up system from preset list */ InitPreset(Number) int Number; { struct Preset *CurPreset; SHORT *CurColors; USHORT *CurContours; UBYTE *CurPens; SHORT i; if (Number < NUMPRESETS) { if (CountBase) { FreeMem(CountBase,CountX*CountY*sizeof(SHORT)); CountBase = (SHORT *) NULL; } CurPreset = &Preset[Number]; StartX = CurPreset->StartX; StartY = CurPreset->StartY; EndX = CurPreset->EndX; EndY = CurPreset->EndY; CountX = CurPreset->CountX; CountY = CurPreset->CountY; MaxCount = CurPreset->MaxCount; MandType = CurPreset->MandType; NewScreen.ViewModes = CurPreset->ViewModes; NewScreen.Depth = CurPreset->Depth; BorderType = CurPreset->BorderType; CurColors = CurPreset->ColorMap; LoadRGB4(vp, CurColors, 32); CurContours = CurPreset->Contours; for (i = 0; i < NumContours; i++) *(ContourBase + i) = *CurContours++; CurPens = CurPreset->Pens; for (i = 0; i < NumContours; i++) *(ColorBase + i) = *CurPens++; return(0); } else { DispErrMsg("Invalid Preset",0); return(1); } } /************************************************************************** * * Preset arrays for generating pictures * *************************************************************************/ SHORT big_brotPalette[] = { 0x0000, 0x0fff, 0x0ddf, 0x0bbf, 0x099f, 0x077c, 0x055a, 0x0337, 0x0114, 0x0337, 0x055a, 0x077c, 0x099f, 0x0bbf, 0x0ccf, 0x0eef, 0x0000, 0x0fff, 0x0fff, 0x0eef, 0x0eef, 0x0ddf, 0x0ddf, 0x0ccf, 0x0ccf, 0x099f, 0x088d, 0x066b, 0x055a, 0x0338, 0x0226, 0x0fff }; USHORT big_brotHeights[] = { 1023, 283, 257, 231, 205, 180, 154, 128, 103, 100, 95, 90, 85, 80, 75, 69, 35, 31, 28, 25, 21, 18, 15, 11, 7, 6, 5, 4, 3, 2, 1, 0 }; UBYTE big_brotPens[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 30, 0 }; SHORT Hey_BabyPalette[] = { 0x0000, 0x0fff, 0x0ede, 0x0dbc, 0x0c9b, 0x0b6a, 0x0a49, 0x0927, 0x0806, 0x0716, 0x0727, 0x0637, 0x0658, 0x0568, 0x0579, 0x0489, 0x0000, 0x0fff, 0x0dee, 0x0bcd, 0x09bc, 0x06aa, 0x0499, 0x0278, 0x0067, 0x059a, 0x0acc, 0x0fff, 0x0bdd, 0x08bb, 0x0489, 0x0067 }; USHORT Hey_BabyHeights[] = { 1023, 247, 220, 193, 167, 160, 154, 147, 141, 134, 128, 122, 115, 110, 106, 102, 98, 93, 89, 85, 81, 77, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65 }; UBYTE Hey_BabyPens[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 20, 23 }; SHORT dragon_familyPalette[] = { 0x0000, 0x0a00, 0x0f20, 0x0f40, 0x0f60, 0x0f80, 0x0f90, 0x0fb0, 0x0fd0, 0x0ff0, 0x0dd1, 0x0bb2, 0x0993, 0x0884, 0x0665, 0x0446, 0x0227, 0x0008, 0x0207, 0x0406, 0x0605, 0x0804, 0x0903, 0x0b02, 0x0d01, 0x0f00, 0x0f20, 0x0f40, 0x0f50, 0x0f70, 0x0f90, 0x0fb0 }; USHORT dragon_familyHeights[] = { 1023, 142, 132, 123, 113, 104, 99, 94, 89, 84, 79, 74, 71, 68, 66, 63, 60, 58, 55, 52, 50, 48, 47, 45, 44, 42, 41, 39, 38, 36, 35, 34 }; UBYTE dragon_familyPens[] = { 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 }; SHORT sea_horsePalette[] = { 0x0000, 0x0fff, 0x0ddd, 0x0bbb, 0x0999, 0x0666, 0x0444, 0x0222, 0x0000, 0x0002, 0x0003, 0x0005, 0x0006, 0x0007, 0x0009, 0x000a, 0x002a, 0x003a, 0x0059, 0x0069, 0x0020, 0x0030, 0x0040, 0x0040, 0x0050, 0x0060, 0x0050, 0x0040, 0x0030, 0x0020, 0x0010, 0x0fff }; USHORT sea_horseHeights[] = { 1023, 635, 542, 449, 356, 263, 171, 145, 142, 140, 138, 135, 132, 128, 125, 122, 119, 115, 112, 109, 106, 103, 98, 94, 89, 85, 80, 76, 71, 67, 62, 58 }; UBYTE sea_horsePens[] = { 0, 7, 6, 5, 4, 3, 3, 1, 4, 6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 8, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0 }; SHORT spinePalette[] = { 0x0000, 0x0600, 0x0800, 0x0b00, 0x0d00, 0x0f00, 0x0f40, 0x0f80, 0x0fb0, 0x0ff0, 0x0bb0, 0x0660, 0x0220, 0x0335, 0x022a, 0x000f, 0x0c50, 0x0b40, 0x0940, 0x0830, 0x0630, 0x0520, 0x0310, 0x0210, 0x0000, 0x00c0, 0x0aaa, 0x0bbb, 0x0ccc, 0x0ddd, 0x0eee, 0x0fff }; USHORT spineHeights[] = { 1023, 318, 295, 272, 249, 226, 203, 180, 157, 135, 127, 120, 113, 106, 99, 92, 85, 68, 65, 62, 59, 56, 53, 0, 44, 43, 42, 41, 40, 39, 0, 0 }; UBYTE spinePens[] = { 15, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, 13, 14, 15, 14, 13, 0, 14, 13, 14, 15, 14, 13, 0, 31 }; SHORT vertibraePalette[] = { 0x0000, 0x0f00, 0x0e01, 0x0d01, 0x0c02, 0x0a02, 0x0903, 0x0803, 0x0923, 0x0a42, 0x0b62, 0x0c82, 0x0c91, 0x0db1, 0x0ed0, 0x0ff0, 0x0de0, 0x0cd0, 0x0ac0, 0x09b0, 0x07a0, 0x0590, 0x0480, 0x0270, 0x0272, 0x0283, 0x0185, 0x0196, 0x0198, 0x0199, 0x00ab, 0x00ac }; USHORT vertibraeHeights[] = { 1023, 389, 355, 321, 287, 253, 219, 185, 151, 134, 127, 120, 113, 106, 99, 92, 85, 68, 66, 65, 63, 62, 61, 59, 58, 57, 55, 54, 53, 0, 0, 0 }; UBYTE vertibraePens[] = { 15, 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 }; SHORT beauty2Palette[] = { 0x0000, 0x0d22, 0x0c22, 0x0b22, 0x0a22, 0x0822, 0x0932, 0x0b32, 0x0c42, 0x0d52, 0x0d71, 0x0e91, 0x0ea1, 0x0ec1, 0x0fd0, 0x0ff0, 0x0bd0, 0x08b0, 0x0490, 0x0070, 0x0062, 0x0053, 0x0045, 0x0047, 0x0038, 0x002a, 0x001b, 0x000d, 0x000a, 0x0007, 0x0004, 0x0f0f }; USHORT beauty2Heights[] = { 1023, 465, 427, 389, 351, 313, 276, 259, 244, 229, 213, 198, 183, 167, 163, 158, 154, 151, 148, 145, 142, 138, 134, 130, 126, 122, 118, 114, 109, 104, 99, 100 }; UBYTE beauty2Pens[] = { 31, 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, 0 }; SHORT linkPalette[] = { 0x0000, 0x0ff0, 0x0f00, 0x0e00, 0x0c00, 0x0b00, 0x0900, 0x0800, 0x0600, 0x0fff, 0x0eee, 0x0ccc, 0x0bbb, 0x0999, 0x0888, 0x0777, 0x0555, 0x0ff0, 0x0f00, 0x0900, 0x0111, 0x0222, 0x0222, 0x0444, 0x0555, 0x0777, 0x0999, 0x0aaa, 0x0ccc, 0x0ddd, 0x0fff, 0x000f }; USHORT linkHeights[] = { 1023, 706, 675, 621, 568, 515, 461, 408, 355, 301, 248, 195, 163, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124 }; UBYTE linkPens[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 6, 4, 3, 0, 22, 23, 24, 25, 26, 26, 27, 28, 29, 30, 29, 28, 28, 27, 25, 25, 24, 23, 22 }; SHORT pretty_babyPalette[] = { 0x0000, 0x0044, 0x0255, 0x0477, 0x0688, 0x0abc, 0x0eef, 0x0ccf, 0x0bbf, 0x0aaf, 0x088e, 0x077e, 0x066e, 0x044d, 0x033d, 0x011c, 0x000c, 0x0310, 0x0420, 0x0521, 0x0531, 0x0632, 0x0742, 0x0842, 0x0953, 0x0953, 0x0a64, 0x0b64, 0x0953, 0x0732, 0x0421, 0x0200 }; USHORT pretty_babyHeights[] = { 1023, 618, 541, 465, 389, 313, 308, 304, 300, 296, 292, 288, 284, 280, 276, 272, 267, 203, 200, 197, 195, 192, 190, 187, 185, 182, 179, 177, 174, 172, 169, 167 }; UBYTE pretty_babyPens[] = { 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 }; SHORT horse_chainPalette[] = { 0x0000, 0x0a90, 0x0f00, 0x0d00, 0x0c00, 0x0a00, 0x0800, 0x0600, 0x0400, 0x0fff, 0x0eee, 0x0ccc, 0x0bbb, 0x0999, 0x0888, 0x0777, 0x0555, 0x0ff0, 0x0f00, 0x0d20, 0x0a30, 0x0620, 0x0222, 0x0444, 0x0555, 0x0777, 0x0999, 0x0aaa, 0x0ccc, 0x0ddd, 0x0fff, 0x000f }; USHORT horse_chainHeights[] = { 1023, 706, 441, 371, 295, 265, 247, 226, 205, 195, 185, 174, 136, 133, 130, 127, 124, 121, 118, 116, 113, 110, 107, 104, 101, 99, 96, 93, 90, 87, 84, 82 }; UBYTE horse_chainPens[] = { 31, 1, 8, 7, 6, 5, 4, 3, 2, 19, 20, 21, 0, 22, 23, 24, 25, 26, 26, 27, 28, 29, 30, 29, 28, 28, 27, 25, 25, 24, 23, 22 }; struct Preset Preset[] = { { "big_brot", /* Preset Name */ -2.000000, -1.204545, /* StartX, StartY */ 2.820000, 1.204545, /* EndX, EndY */ 109, 78, /* CountX,CountY */ 1023, /* MaxCount */ 0, /* MandType */ 0x4000, /* ViewModes */ 5, /* Depth */ 0, /* Border Type*/ &big_brotPalette[0], /* Palette colors */ 32, /* NumContours */ &big_brotHeights[0], /* ContourHeights */ &big_brotPens[0] /* ContourPens */ }, { "Hey_Baby", /* Preset Name */ -0.143523, -1.019072, /* StartX, StartY */ -0.143384, -1.018843, /* EndX, EndY */ 96, 65, /* CountX,CountY */ 1023, /* MaxCount */ 0, /* MandType */ 0x4000, /* ViewModes */ 5, /* Depth */ 0, /* Border Type*/ Hey_BabyPalette, /* Palette colors */ 32, /* NumContours */ Hey_BabyHeights, /* ContourHeights */ Hey_BabyPens /* ContourPens */ }, { "dragon_family", /* Preset Name */ -0.942986, -0.270764, /* StartX, StartY */ -0.922458, -0.260287, /* EndX, EndY */ 129, 58, /* CountX,CountY */ 1023, /* MaxCount */ 0, /* MandType */ 0x4000, /* ViewModes */ 5, /* Depth */ 0, /* Border Type*/ dragon_familyPalette, /* Palette colors */ 32, /* NumContours */ dragon_familyHeights, /* ContourHeights */ dragon_familyPens /* ContourPens */ }, { "spine", /* Preset Name */ -1.253688, -0.042351, /* StartX, StartY */ -1.251284, -0.040954, /* EndX, EndY */ 120, 76, /* CountX,CountY */ 1023, /* MaxCount */ 0, /* MandType */ 0x4000, /* ViewModes */ 4, /* Depth */ 0, /* Border Type*/ spinePalette, /* Palette colors */ 32, /* NumContours */ spineHeights, /* ContourHeights */ spinePens /* ContourPens */ }, { "vertibrae", /* Preset Name */ -1.253227, -0.041939, /* StartX, StartY */ -1.251660, -0.041292, /* EndX, EndY */ 105, 56, /* CountX,CountY */ 1023, /* MaxCount */ 0, /* MandType */ 0x4000, /* ViewModes */ 5, /* Depth */ 0, /* Border Type*/ vertibraePalette, /* Palette colors */ 32, /* NumContours */ vertibraeHeights, /* ContourHeights */ vertibraePens /* ContourPens */ }, { "beauty", /* Preset Name */ -1.252925, -0.041729, /* StartX, StartY */ -1.252575, -0.041497, /* EndX, EndY */ 98, 56, /* CountX,CountY */ 1023, /* MaxCount */ 0, /* MandType */ 0x4000, /* ViewModes */ 5, /* Depth */ 0, /* Border Type*/ beauty2Palette, /* Palette colors */ 32, /* NumContours */ beauty2Heights, /* ContourHeights */ beauty2Pens /* ContourPens */ }, { "sea_horse", /* Preset Name */ -0.749790, -0.113353, /* StartX, StartY */ -0.742342, -0.105343, /* EndX, EndY */ 69, 56, /* CountX,CountY */ 1023, /* MaxCount */ 0, /* MandType */ 0x4000, /* ViewModes */ 5, /* Depth */ 0, /* Border Type*/ sea_horsePalette, /* Palette colors */ 32, /* NumContours */ sea_horseHeights, /* ContourHeights */ sea_horsePens /* ContourPens */ }, { "horse_chain", /* Preset Name */ -0.745445, -0.113237, /* StartX, StartY */ -0.744856, -0.112922, /* EndX, EndY */ 105, 56, /* CountX,CountY */ 1023, /* MaxCount */ 0, /* MandType */ 0x4000, /* ViewModes */ 5, /* Depth */ 0, /* Border Type*/ horse_chainPalette, /* Palette colors */ 32, /* NumContours */ horse_chainHeights, /* ContourHeights */ horse_chainPens /* ContourPens */ }, { "link", /* Preset Name */ -0.745464, -0.113034, /* StartX, StartY */ -0.745399, -0.112985, /* EndX, EndY */ 95, 56, /* CountX,CountY */ 1023, /* MaxCount */ 1, /* MandType */ 0x4000, /* ViewModes */ 5, /* Depth */ 0, /* Border Type*/ linkPalette, /* Palette colors */ 32, /* NumContours */ linkHeights, /* ContourHeights */ linkPens /* ContourPens */ }, { "pretty_baby", /* Preset Name */ -0.745436, -0.113016, /* StartX, StartY */ -0.745399, -0.113003, /* EndX, EndY */ 87, 56, /* CountX,CountY */ 1023, /* MaxCount */ 1, /* MandType */ 0x4000, /* ViewModes */ 5, /* Depth */ 0, /* Border Type*/ pretty_babyPalette, /* Palette colors */ 32, /* NumContours */ pretty_babyHeights, /* ContourHeights */ pretty_babyPens /* ContourPens */ }, }; #ifdef DEVELOPMENT SavePreset(name) char *name; { int i; FILE *SaveFile; SaveFile = fopen(name,"a"); if (SaveFile != (struct FILE *) NULL) { fprintf(SaveFile, "SHORT %sPalette[] =\n{\n",name); for (i = 0; i < 32; i++) { fprintf(SaveFile, " 0x%04x", GetRGB4(vp->ColorMap, i)); if (i != 31) fprintf(SaveFile,","); if (i % 8 == 7) fprintf(SaveFile, "\n"); } fprintf(SaveFile, "};\n"); fprintf(SaveFile, "USHORT %sHeights[] =\n{\n",name); for (i = 0; i < NumContours; i++) { fprintf(SaveFile, " %d", *(ContourBase + i) ); if (i != NumContours - 1) { fprintf(SaveFile,","); if (i % 8 == 7) fprintf(SaveFile, "\n"); } } fprintf(SaveFile, "\n};\n"); fprintf(SaveFile, "UBYTE %sPens[] =\n{\n",name); for (i = 0; i < NumContours; i++) { fprintf(SaveFile, " %d", *(ColorBase + i) ); if (i != NumContours - 1) { fprintf(SaveFile,","); if (i % 8 == 7) fprintf(SaveFile, "\n"); } } fprintf(SaveFile, "\n};\n"); fprintf(SaveFile, " {\n"); fprintf(SaveFile, " \"%s\", /* Preset Name */\n", name); fprintf(SaveFile, " %f, %f, /* StartX, StartY */\n", StartX, StartY); fprintf(SaveFile, " %f, %f, /* EndX, EndY */\n", EndX, EndY); fprintf(SaveFile, " %d, %d, /* CountX,CountY */\n", CountX, CountY); fprintf(SaveFile, " %d, /* MaxCount */\n", MaxCount); fprintf(SaveFile, " %d, /* MandType */\n", MandType); fprintf(SaveFile, " 0x%04x, /* ViewModes */\n", screen->ViewPort.Modes); fprintf(SaveFile, " %d, /* Depth */\n", screen->BitMap.Depth); fprintf(SaveFile, " %d, /* Border Type*/\n", BorderType); fprintf(SaveFile, " %sPalette, /* Palette colors */\n", name); fprintf(SaveFile, " %d, /* NumContours */\n", NumContours); fprintf(SaveFile, " %sHeights, /* ContourHeights */\n", name); fprintf(SaveFile, " %sPens /* ContourPens */\n", name); fprintf(SaveFile, " },\n\n\n"); } } #endif //E*O*F presets.c// echo x - savemand.c cat > "savemand.c" << '//E*O*F savemand.c//' /*************************************************************************** * * MandelVroom Load/Save raw information * * Kevin L. Clague * * Copyright (C) 1987 * **************************************************************************/ #include "mand.h" extern struct NewScreen NewScreen; extern struct Screen *screen; extern struct ViewPort *vp; extern float StartX,StartY,EndX,EndY; extern SHORT Zoom; extern SHORT CountX,CountY,MaxCount,*CountBase; extern LONG NavTop,NavBot,NavLeft,NavRight; extern SHORT NumContours, *ContourBase; extern UBYTE *ColorBase; extern SHORT SavePalette[], Inited; extern ULONG CalcTime; extern UBYTE MandType; extern ULONG BorderType; /* * Save all the data needed to restore the system to current state. */ SaveCounts(SaveName) char *SaveName; { FILE *SaveFile; SHORT *CountPtr,Color; ULONG i,Count,Word = 0; USHORT Cur,t; ULONG Version = VERSION; char ErrMsg[80]; /* * Change the mouse pointer to Sleepy pointer */ SetSleepyPointer(); /* * open the desired file for writing */ SaveFile = fopen(SaveName,"w"); if (SaveFile == (FILE *) NULL) { sprintf(ErrMsg, "Can't open file %s", SaveName); DispErrMsg(ErrMsg, 0); return(0); } /* * if there is data to save, save it */ if (CountBase) { /* * Put out the file header */ fwrite((char *) "MAND", 4, 1, SaveFile); /* * Put out the revision number */ fwrite((char *) Version, sizeof(Version), 1, SaveFile); /* * Put out the location on the complex plane */ fwrite((char *) &StartX, sizeof(float), 1, SaveFile); fwrite((char *) &StartY, sizeof(float), 1, SaveFile); fwrite((char *) &EndX, sizeof(float), 1, SaveFile); fwrite((char *) &EndY, sizeof(float), 1, SaveFile); /* * Put out the Maximum iteration count for a given point */ fwrite((char *) &MaxCount, sizeof(SHORT), 1, SaveFile); /* * Put out the generator type */ fwrite((char *) &MandType, sizeof(MandType), 1, SaveFile); /* * Put out the time it took to generate */ fwrite((char *) &CalcTime, sizeof(CalcTime), 1, SaveFile); /* * Put out the screen's viewmodes */ fwrite((char *) &screen->ViewPort.Modes, sizeof(screen->ViewPort.Modes), 1, SaveFile); /* * Put out the number of bit planes */ fwrite((char *) &screen->BitMap.Depth, sizeof(screen->BitMap.Depth), 1, SaveFile); /* * Put some window flags */ fwrite((char *) &BorderType, sizeof(BorderType), 1, SaveFile); /* * Save the Color Palette */ for (i = 0; i < 32; i++) { Color = GetRGB4(vp->ColorMap, i); fwrite((char *) &Color, sizeof(Color), 1, SaveFile); } /* * Save the number of contours */ fwrite((char *) &NumContours, sizeof(NumContours), 1, SaveFile); /* * Save the contour's heights */ fwrite((char *) ContourBase, sizeof(SHORT), (long) NumContours, SaveFile); /* * Save the contour's pen numbers (Color is a misnomer) */ fwrite((char *) ColorBase, sizeof(UBYTE), (long) NumContours, SaveFile); /* * Put out the image dimensions */ fwrite((char *) &CountX, sizeof(SHORT), 1, SaveFile); fwrite((char *) &CountY, sizeof(SHORT), 1, SaveFile); /* Save count information in pseudo RLL format */ /* Bits 9-0 are iteration count. */ /* Bits 15-10 are how many iteration count of same height in a row */ i = CountX*CountY; CountPtr = CountBase; Cur = *CountPtr; Count = 1; while (--i) { CountPtr++; /* * Count up how many in a row have same height */ if (Cur == *CountPtr) { Count++; } else { /* * Break it up into chunks of 64 */ while (Count) { if (Count > 63) { t = 63 << 10 | Cur; Count -= 63; } else { t = Count << 10 | Cur; Count = 0; } fwrite(&t,sizeof(SHORT),1,SaveFile); Word++; } Count = 1; Cur = *CountPtr; } } /* * Break the last one up into chunks */ while (Count) { if (Count > 63) { t = 63 << 10 | Cur; Count -= 63; } else { t = Count << 10 | Cur; Count = 0; } fwrite(&t,sizeof(SHORT),1,SaveFile); Word++; } } else { DispErrMsg("No Picture to save",0); fclose(SaveFile); return(0); } fclose(SaveFile); } /* SaveCounts */ /* * Load the state of the program from file */ LoadCounts(LoadName) char *LoadName; { FILE *LoadFile; SHORT *CountPtr; LONG i; ULONG Count,Word = 0; USHORT t; USHORT ViewModes; UBYTE Depth; UBYTE Header[5]; ULONG Version; char ErrMsg[80]; /* * Change the mouse pointer to Sleepy pointer */ SetSleepyPointer(); LoadFile = fopen(LoadName,"r"); if (CountBase) { FreeMem(CountBase,CountX*CountY*sizeof(SHORT)); CountBase = (SHORT *) NULL; } if (LoadFile == (FILE *) NULL) { /* * can't read a non-existant file */ sprintf(ErrMsg, "File %s not found", LoadName); DispErrMsg(ErrMsg, 0); return(-1); } else { /* * Read and check the file header */ fread((char *) &Header[0], 4, 1, LoadFile); Header[4] = '\0'; if (strcmp(&Header[0], "MAND") != 0) { /* * File of improper format */ sprintf(ErrMsg, "File %s is not a MAND file",LoadName); DispErrMsg(ErrMsg, 0); fclose(LoadFile); return(-1); } else { /* * Read in the version */ fread((char *) &Version, sizeof(Version), 1, LoadFile); /* * Read in the locationin the complex plane */ fread((char *) &StartX, sizeof(float), 1, LoadFile); fread((char *) &StartY, sizeof(float), 1, LoadFile); fread((char *) &EndX, sizeof(float), 1, LoadFile); fread((char *) &EndY, sizeof(float), 1, LoadFile); /* * Read in the maximum iteration count for a given point */ fread((char *) &MaxCount, sizeof(SHORT), 1, LoadFile); /* * Read in the generator type */ fread((char *) &MandType, sizeof(MandType), 1, LoadFile); /* * Read in the calculation time */ fread((char *) &CalcTime, sizeof(CalcTime), 1, LoadFile); /* * Read in the screen's viewmodes */ fread((char *) &ViewModes, sizeof(ViewModes), 1, LoadFile); /* * Read in the number of bit planes */ fread((char *) &Depth, sizeof(Depth), 1, LoadFile); /* * Read in the window flags */ fread((char *) &BorderType, sizeof(BorderType), 1, LoadFile); /* * Read in the color palette information */ fread((char *) &SavePalette[0], sizeof(SHORT), 32, LoadFile); /* * Read in the number of contours */ fread((char *) &NumContours, sizeof(NumContours), 1, LoadFile); /* * Read in the heights */ fread((char *) ContourBase, sizeof(SHORT), (long) NumContours, LoadFile); /* * Read in the pen numbers (Color is a misnomer) */ fread((char *) ColorBase, sizeof(UBYTE), (long) NumContours, LoadFile); /* * Put out the image dimensions */ fread((char *) &CountX, sizeof(SHORT), 1, LoadFile); fread((char *) &CountY, sizeof(SHORT), 1, LoadFile); /* * try to allocate the space for the picture's iteration counts */ CountBase = (SHORT *) AllocMem(CountX*CountY*sizeof(SHORT),0); if (CountBase == (SHORT *) NULL) { DispErrMsg("Can't load counts. Out of RAM!!",0); fclose(LoadFile); return(0); } CountPtr = CountBase; /* Load count information in pseudo RLL format */ /* Bits 9-0 are iteration count. */ /* Bits 15-10 are how many iteration count of same height in a row */ i = CountX*CountY; while (i > 0) { Word++; if (fread((char *) &t, sizeof(t), 1, LoadFile) == 0) { DispErrMsg("Premature EOF on source file",0); fclose(LoadFile); return(0); } Count = t >> 10; t = t & 0x3ff; for (; Count > 0; Count--) { *(CountPtr++) = t; i--; } } CalculateGaps(); } } /* * Open a new screen */ NewScreen.ViewModes = ViewModes; NewScreen.Depth = Depth; Inited = 0; CloseDisp(); Inited = 1; OpenDisp(); /* * Let's show it to them */ ReColor(); /* * Set No ZOOM */ Zoom = 0; fclose(LoadFile); } /* NewLoadCounts */ //E*O*F savemand.c// echo Possible errors detected by \'wc\' [hopefully none]: temp=/tmp/shar$$ trap "rm -f $temp; exit" 0 1 2 3 15 cat > $temp <<\!!! 382 1223 10002 palette.c 607 2254 17314 presets.c 394 1106 8928 savemand.c 1383 4583 36244 total !!! wc palette.c presets.c savemand.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. ]