[comp.sources.amiga] v89i159: mandelvroom - mandelbrot explorer v2.0, Part08/09

page%swap@Sun.COM (Bob Page) (06/21/89)

Submitted-by: kevin@uts.amdahl.com (Kevin Clague)
Posting-number: Volume 89, Issue 159
Archive-name: graphics/mandelv20.8

# 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:
#	parms.h
#	presets.c
#	recolor.c
#	safeaddhead.c
#	safeclose.c
# This is archive 8 of a 9-part kit.
# This archive created: Tue Jun 20 20:45:32 1989
echo "extracting parms.h"
sed 's/^X//' << \SHAR_EOF > parms.h
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:  These structs are used to ease Mandelbrot/Julia picture
X * calculations.
X */
X
Xstruct PotentialParms {
X  double ScreenReal, ScreenImag; /* 0.0 for Mandelbrot, screen for julia */
X  double C_Real,     C_Imag;     /* C for mandelbrot,   C for julia      */
X  SHORT  MaxIteration;
X};
X
Xstruct IntPotParms {
X  LONG ScreenReal, ScreenImag; /* 0.0 for Mandelbrot, screen for julia */
X  LONG C_Real,     C_Imag;     /* C for mandelbrot,   C for julia      */
X  SHORT  MaxIteration;
X};
X
SHAR_EOF
echo "extracting presets.c"
sed 's/^X//' << \SHAR_EOF > presets.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 create and initialize
X * a preset project selected by the user.
X */
X
X#include "mandp.h"
X
X#define NUMPRESETS 10
X
Xextern struct NewScreen NewScreen;
X
Xstruct Preset {
X  char   *Name;
X  int     Type;
X  double  StartX, StartY, EndX, EndY;
X  SHORT   CountX, CountY;
X  SHORT   MaxCount;
X  UBYTE   MandType;
X  USHORT  ViewModes;
X  USHORT  Depth;
X  ULONG   BorderType;
X  SHORT  *ColorMap;
X  SHORT   NumContours;
X  USHORT *Contours;
X  UBYTE  *Pens;
X};
X
X
Xextern int Num_vp_Colors;
X
Xextern struct Preset Preset[];
X
Xextern USHORT NewViewModes;
Xextern UBYTE  NewDepth;
X
XDefaultColors()
X{
X  LoadRGB4( vp, Preset[0].ColorMap, Num_vp_Colors );
X}
X
X/*
X * Generate a preset picture
X */
XClonePict( Pict, Type )
X  register struct Picture *Pict;
X  register SHORT Type;
X{
X  register struct Picture *ClonedPict;
X  struct Picture *NewPict();
X
X  extern int Num_vp_Colors;
X
X  if ( (ClonedPict = NewPict( Type )) == NULL ) {
X    ErrNoPict();
X    return;
X  }
X
X  CopyPict( ClonedPict, Pict );
X
X  strcpy(ClonedPict->Title,Pict->Title);
X
X  ClonedPict->Flags = 0;
X  ClonedPict->ZoomType == GENPENDSTATE;
X
X  if ( Pict->pNode.ln_Type != Type ) {
X
X    if ( Type == JULIAPICT ) {
X      ClonedPict->Real     = Pict->RealLow;
X      ClonedPict->Imag     = Pict->ImagLow;
X      InitJulia( ClonedPict );
X
X    } else {
X      InitMand( ClonedPict );
X    }
X  }
X
X  if ( OpenPicture( ClonedPict ) != 0 ) {
X    ThrowPict( ClonedPict );
X  }
X
X  GetCurPict();
X}
X
XErrNoPict()
X{
X  DispErrMsg( "Can't Allocate Picture.",0);
X}
X
XCopyPict( DstPict, SrcPict )
X  register struct Picture *DstPict;
X  register struct Picture *SrcPict;
X{
X  movmem( &SrcPict->Real, &DstPict->Real, sizeof(struct Picture)-
X          ((char *) &SrcPict->Real - (char *) SrcPict) );
X}
X
X/*
X * Generate a preset picture
X */
Xint
XSetPreset(Number)
X  int Number;
X{
X  return( NewPreset( Number, Preset[Number].Type ));
X}
X
X/*
X * Generate a preset picture
X */
Xint
XNewPreset(Number, Type)
X  int Number;
X  int Type;
X{
X  register struct Picture *Pict;
X
X  struct Picture *NewPict();
X
X  extern int Num_vp_Colors;
X
X  if ( (Pict = NewPict( Type )) == NULL ) {
X    ErrNoPict();
X    return(UNSUCCESSFUL);
X  }
X
X  if (Number == -1) {
X    InitPreset( 0, Pict );
X
X#define VIEW_MODE_MASK (HIRES|INTERLACE|EXTRA_HALFBRITE)
X
X    Pict->ViewModes = NewViewModes = screen->ViewPort.Modes & VIEW_MODE_MASK;
X    Pict->Depth     = NewDepth     = screen->BitMap.Depth;
X
X    if ( OpenPicture( Pict ) != 0 ) {
X
X      ThrowPict( Pict );
X      return(UNSUCCESSFUL);
X
X    }
X  } else {
X    InitPreset( Number, Pict );
X
X    if (MaybeNewScreen() == 0) {
X
X      if ( OpenPicture( Pict ) != 0 ) {
X
X        ThrowPict( Pict );
X        return(UNSUCCESSFUL);
X
X      } else {
X
X        Generate( Pict );
X      }
X    }
X  }
X  GetCurPict();
X
X  if (CurPict)
X    LoadRGB4( vp, CurPict->RGBs, Num_vp_Colors );
X
X  return(SUCCESSFUL);
X}
X
XInitJulia( Pict )
X  register struct Picture *Pict;
X{
X  double JCountX, JCountY;
X
X  double AspectRatio();
X
X  JCountX        = (double) Pict->CountX;
X  JCountY        = (double) Pict->CountY;
X
X  Pict->ImagLow  = -1.0;
X  Pict->ImagHigh =  1.0;
X
X  Pict->RealLow  =  Pict->ImagLow * AspectRatio() * JCountX / JCountY;
X  Pict->RealHigh = -Pict->RealLow;
X}
X
X/*
X * Set up system from preset list
X */
XInitPreset(Number, Pict)
X  int Number;
X  register struct Picture *Pict;
X{
X  register LONG  i;
X
X  register struct Preset  *CurPreset;
X
X  register SHORT  *CurColors;
X  register USHORT *CurContours;
X  register UBYTE  *CurPens;
X
X  register struct Node *pNode = (struct Node *) Pict;
X
X  extern USHORT NewViewModes;
X  extern UBYTE  NewDepth;
X
X  if (Pict == NULL) {
X    DispErrMsg("Initing NULL Pict",0);
X    return(0);
X  }
X
X  if (Number < NUMPRESETS) {
X
X    Pict->GenState = GENPENDSTATE;
X
X    FreeCounts( Pict );
X
X    CurPreset = &Preset[Number];
X
X    sprintf(Pict->Title,"* %s",CurPreset->Name);
X
X    Pict->CountX = CurPreset->CountX;
X    Pict->CountY = CurPreset->CountY;
X
X    if ( pNode->ln_Type == JULIAPICT ) {
X
X      Pict->Real     = CurPreset->StartX;
X      Pict->Imag     = CurPreset->StartY;
X
X      InitJulia( Pict );
X
X    } else {
X      Pict->RealLow  = CurPreset->StartX;
X      Pict->ImagLow  = CurPreset->StartY;
X      Pict->RealHigh = CurPreset->EndX;
X      Pict->ImagHigh = CurPreset->EndY;
X    }
X
X    Pict->MaxIteration = CurPreset->MaxCount;
X
X    Pict->MathMode = CurPreset->MandType;
X
X    Pict->ViewModes = CurPreset->ViewModes;
X    Pict->Depth     = CurPreset->Depth;
X
X    if ( Number != 0 ) {
X      NewViewModes = CurPreset->ViewModes;
X      NewDepth = CurPreset->Depth;
X    }
X
X    CurColors = CurPreset->ColorMap;
X
X    for (i = 0; i < 32; i++) {
X      Pict->RGBs[i] = *CurColors++;
X    }
X
X    CurContours = CurPreset->Contours;
X    CurPens = CurPreset->Pens;
X
X    for (i = 0; i < CurPreset->NumContours; i++) {
X      *(Pict->Heights + i) = *CurContours++;
X      *(Pict->Pens + i) = *CurPens++;
X    }
X
X    for ( ; i < NumContours; i++ ) {
X      *(Pict->Heights + i) = 0;
X      *(Pict->Pens + i) = NORMALPEN;
X    }
X
X    MakeColorXlate( Pict );
X
X    CalculateGaps( Pict );
X
X    return(0);
X  } else {
X    DispErrMsg("Invalid Preset",0);
X    return(1);
X  }
X}
X
X/**************************************************************************
X *
X *  Preset arrays for generating pictures
X *
X *************************************************************************/
X
XSHORT big_brotPalette[] =
X{
X  0x0000,  0x0b98,  0x0fdc,  0x0765,  0x0114,  0x0225,  0x0337,  0x0448,
X  0x055a,  0x066b,  0x077c,  0x088e,  0x099f,  0x0bbf,  0x0ccf,  0x0eef,
X  0x0fff,  0x0eee,  0x0dde,  0x0ccd,  0x0ccd,  0x0bbc,  0x0aab,  0x099b,
X  0x088a,  0x077a,  0x0669,  0x0558,  0x0558,  0x0447,  0x0337,  0x0226
X};
XUSHORT big_brotHeights[] =
X{
X  128,
X  29,19, 13,  10, 9,  8,  7,  6,
X  5,  4,  3,  2,  1,  0,  0,  0,
X  0,  0,  0,  0,  0,  0,  0,  0,
X  0,  0,  0,  0,  0,  0,  0,  0,
X};
XUBYTE big_brotPens[] =
X{
X  0,  16,  17,  18,  19,  20,  21,  22,
X  23,  24,  25,  26,  27,  28,  29,  30,
X  31,  4,  5,  6,  7,  8,  9,  10,
X  11,  12,  13,  14,  15,  16,  17,  18,
X  19,  20,  21,  22,  23,  24,  25,  26,
X  27,  28,  29,  30,  31,  4,  1,  1,
X};
X
XSHORT Hey_BabyPalette[] =
X{
X  0x0000,  0x0b98,  0x0fdc,  0x0765,  0x0c9b,  0x0b6a,  0x0a49,  0x0927,
X  0x0806,  0x0716,  0x0727,  0x0637,  0x0658,  0x0568,  0x0579,  0x0489,
X  0x0000,  0x0fff,  0x0dee,  0x0bcd,  0x09bc,  0x06aa,  0x0499,  0x0278,
X  0x0067,  0x059a,  0x0acc,  0x0fff,  0x0bdd,  0x08bb,  0x0489,  0x0067
X};
X
XUSHORT Hey_BabyHeights[] =
X{
X  1023,  247,  220,  193,  167,  160,  154,  147,
X  141,  134,  128,  122,  115,  110,  106,  102,
X  98,  93,  89,  85,  81,  77,  74,  73,
X  72,  71,  70,  69,  68,  67,  66,  65
X};
X
XUBYTE Hey_BabyPens[] =
X{
X  0,  1,  2,  3,  4,  5,  6,  7,
X  8,  9,  10,  11,  12,  13,  14,  15,
X  30,  29,  28,  27,  26,  25,  24,  23,
X  22,  21,  20,  19,  18,  17,  20,  23
X};
X
XSHORT coverPalette[] =
X{
X  0x0000,  0x0b98,  0x0fdc,  0x0765,  0x0f58,  0x0f46,  0x0e46,  0x0d35,
X  0x0c35,  0x0b34,  0x0a33,  0x0923,  0x0822,  0x0611,  0x0511,  0x0400,
X  0x0fe7,  0x0f9d,  0x0f8c,  0x0f7a,  0x009f,  0x0ade,  0x0cee,  0x009f,
X  0x03af,  0x05bf,  0x05bd,  0x09de,  0x0ade,  0x0cee,  0x09cd,  0x06bc
X};
XUSHORT coverHeights[] =
X{
X  1023,  111, 106,  96,  86,  76,  75,  74,
X  73,  72,  71,  70,  69,  68,  67,  66,
X  65,  64,  62,  61,  60,  59,  58,  57,
X  48,  47,  46,  45,  42,  39,  36,  35,
X  34,  33,  32,  31,  30,  29,  28,  27,
X  26,  25,  24,  23,  22,  21,  20,  19,
X  18,  17,  16,  15,  14,  13,  12,  11,
X  10,  14,  13,  12,  11,  10,  9,  8,
X  3,  0,  0,  0,  0,  0,  0,  0,
X};
XUBYTE coverPens[] =
X{
X  0,  16,  17,  18,  4,  5,  6,  7,
X  8,  9,  10,  11,  12,  13,  14,  15,
X  17,  17,  18,  19,  4,  5,  6,  7,
X  8,  9,  10,  11,  12,  13,  14,  15,
X  15,  14,  13,  12,  11,  10,  8,  7,
X  6,  5,  4,  19,  18,  17,  11,  10,
X  9,  8,  7,  6,  5,  4,  19,  18,
X  1,  1,  1,  1,  1,  1,  1,  1,
X  1,  1,  1,  1,  1,  1,  1,  1,
X};
X
XSHORT sea_horsePalette[] =
X{
X  0x0000,  0x0b98,  0x0fdc,  0x0765,  0x0fff,  0x0bbb,  0x0888,  0x0444,
X  0x0000,  0x0002,  0x0003,  0x0005,  0x0006,  0x0007,  0x0009,  0x000a,
X  0x002a,  0x003a,  0x0059,  0x0003,  0x0020,  0x0030,  0x0040,  0x0040,
X  0x0050,  0x0060,  0x0050,  0x0040,  0x0030,  0x0020,  0x0010,  0x0fff
X};
XUSHORT sea_horseHeights[] =
X{
X  1023,  635,  542,  449,  356,  263,  171,  145,
X  142,  140,  139,  138,  137,  136,  135,  134,
X  133,  132,  131,  130,  129,  128,  127,  126,
X  125,  124,  123,  122,  121,  120,  119,  118,
X  117,  116,  115,  114,  113,  112,  111,  110,
X  109,  108,  107,  106,  105,  104,  103,  102,
X  101,  100,  99,  98,  97,  96,  95,  94,
X  93,  92,  91,  90,  89,  88,  87,  86,
X  85,  84,  83,  82,  81,  80,  79,  78,
X  77,  76,  75,  74,  73,  72,  71,  70,
X  69,  68,  67,  66,  65,  64,  63,  62,
X  61,  60,  59,  58,  57,  56,  55,  54,
X  53,  52,  51,  50,  49,  48,  47,  46,
X  45,  44,  43,  42,  41,  40,  39,  38,
X  37,  36,  35,  34,  33,  32,  31,  30,
X  29,  28,  27,  26,  25,  24,  23,  22,
X  21,  20,  19,  18,  17,  16,  15,  14,
X  13,  12,  11,  10,  9,  8,  7,  6,
X  5,  4,  3,  2,  1,  0,  0,  0,
X};
XUBYTE sea_horsePens[] =
X{
X  0,  7,  6,  5,  4,  4,  5,  6,
X  7,  8,  10,  20,  11,  21,  12,  22,
X  13,  23,  14,  24,  15,  25,  16,  26,
X  17,  27,  18,  28,  17,  29,  16,  30,
X  15,  20,  14,  21,  13,  22,  12,  23,
X  11,  24,  10,  25,  10,  26,  11,  27,
X  12,  28,  13,  29,  14,  30,  15,  20,
X  16,  21,  17,  22,  18,  23,  17,  24,
X  16,  25,  15,  26,  14,  27,  13,  28,
X  12,  29,  11,  30,  10,  20,  10,  21,
X  11,  22,  12,  23,  13,  24,  14,  25,
X  15,  26,  16,  27,  17,  28,  18,  29,
X  17,  30,  16,  20,  15,  21,  14,  22,
X  13,  23,  12,  24,  11,  25,  10,  26,
X  10,  27,  11,  28,  12,  29,  13,  30,
X  14,  20,  15,  21,  16,  22,  17,  23,
X  18,  24,  17,  25,  16,  26,  15,  27,
X  14,  28,  13,  29,  12,  30,  11,  20,
X  10,  21,  10,  22,  11,  23,  12,  1,
X};
X
XSHORT golden_dragonPalette[] =
X{
X  0x0000,  0x0b98,  0x0fdc,  0x0765,  0x0f93,  0x0e83,  0x0c73,  0x0b53,
X  0x0943,  0x0732,  0x0411,  0x0200,  0x0310,  0x0410,  0x0520,  0x0720,
X  0x0850,  0x0930,  0x0c80,  0x0fb0,  0x0620,  0x0510,  0x0310,  0x0200,
X  0x0521,  0x0742,  0x0a63,  0x0c84,  0x0a63,  0x0742,  0x0521,  0x0200
X};
XUSHORT golden_dragonHeights[] =
X{
X  1023,  353,  316,  279,  274,  270,  266,  261,
X  257,  253,  249,  226,  224,  222,  220,  219,
X  217,  215,  213,  212,  210,  208,  207,  195,
X  194,  193,  192,  191,  190,  189,  188,  187,
X  186,  185,  184,  183,  182,  181,  180,  179,
X  178,  177,  176,  175,  174,  173,  172,  171,
X  170,  169,  168,  167,  166,  165,  164,  163,
X  162,  161,  160,  159,  158,  157,  156,  155,
X  154,  153,  152,  151,  150,  149,  148,  147,
X  146,  145,  144,  0,    0,    0,    0,    0,
X};
XUBYTE golden_dragonPens[] =
X{
X  0,  4,  5,  6,  7,  8,  9,  10,
X  11,  12,  14,  14,  15,  16,  17,  18,
X  19,  20,  21,  22,  23,  24,  25,  26,
X  27,  28,  29,  30,  23,  24,  25,  26,
X  27,  28,  29,  30,  23,  24,  25,  26,
X  27,  28,  29,  30,  23,  24,  25,  26,
X  27,  28,  29,  30,  23,  24,  25,  26,
X  27,  28,  29,  30,  23,  24,  25,  26,
X  27,  28,  29,  30,  13,  24,  25,  26,
X  27,  28,  29,  13,  1,  1,  1,  1,
X};
X
XSHORT dual_spiralPalette[] =
X{
X  0x0000,  0x0b98,  0x0fdc,  0x0765,  0x0bbb,  0x0999,  0x0777,  0x0555,
X  0x0333,  0x0246,  0x0357,  0x0468,  0x0479,  0x058b,  0x068c,  0x079d,
X  0x0fff,  0x0eee,  0x0ccc,  0x0fd0,  0x0246,  0x0357,  0x0468,  0x079d,
X  0x068c,  0x068b,  0x057a,  0x057a,  0x0469,  0x0358,  0x0357,  0x0246
X};
XUSHORT dual_spiralHeights[] =
X{
X  1023,  283,  271,  260,  249,  238,  226,  225,
X  224,  223,  222,  221,  220,  219,  218,  217,
X  216,  215,  214,  213,  212,  211,  210,  209,
X  208,  207,  206,  205,  204,  203,  202,  201,
X  200,  199,  198,  197,  196,  195,  194,  193,
X  192,  191,  190,  189,  188,  187,  186,  185,
X  184,  183,  182,  181,  180,  179,  178,  177,
X  176,  175,  174,  173,  172,  171,  170,  169,
X  168,  167,  166,  165,  164,  163,  162,  161,
X  160,  159,  158,  157,  156,  155,  154,  153,
X  152,  151,  150,  149,  148,  147,  146,  145,
X  144,  143,  142,  141,  140,  139,  138,  137,
X  136,  135,  134,  133,  132,  131,  130,  129,
X  128,  127,  126,  125,  124,  123,  122,  121,
X  120,  119,  118,  117,  116,  115,  114,  113,
X  112,  111,  110,  109,  108,  107,  106,  105,
X  104,  103,  102,  101,  100,  99,  98,  97,
X  96,  95,  94,  93,  92,  91,  90,  89,
X  88,  87,  86,  85,  84,  83,  82,  81,
X  80,  79,  78,  77,  76,  75,  74,  73,
X  72,  71,  70,  69,  68,  67,  66,  65,
X  64,  63,  62,  61,  60,  59,  58,  57,
X  56,  55,  54,  53,  52,  51,  50,  49,
X  48,  47,  46,  45,  44,  43,  42,  41,
X  40,  39,  38,  37,  36,  35,  34,  33,
X  32,  31,  30,  29,  28,  27,  26,  25,
X  24,  23,  22,  21,  20,  19,  18,  17,
X  16,  15,  14,  13,  12,  11,  10,  9,
X  8,  7,  6,  5,  4,  3,  2,  1,
X  0,  0,  0,  0,  0,  0,  0,  0,
X};
XUBYTE dual_spiralPens[] =
X{
X  0,  16,  17,  18,  5,  6,  7,  31,
X  30,  29,  28,  27,  26,  25,  24,  23,
X  24,  25,  26,  27,  28,  29,  30,  31,
X  30,  29,  28,  27,  26,  25,  24,  23,
X  24,  25,  26,  27,  28,  29,  30,  31,
X  31,  30,  29,  28,  27,  26,  25,  24,
X  23,  24,  25,  26,  27,  28,  29,  30,
X  31,  31,  30,  29,  28,  27,  26,  25,
X  24,  23,  24,  25,  26,  27,  28,  29,
X  30,  31,  31,  30,  29,  28,  27,  26,
X  25,  24,  23,  24,  25,  26,  27,  28,
X  29,  30,  31,  31,  30,  29,  28,  27,
X  26,  25,  24,  23,  24,  25,  26,  27,
X  28,  29,  30,  31,  31,  30,  29,  28,
X  27,  26,  25,  24,  23,  24,  25,  26,
X  27,  28,  29,  30,  31,  31,  30,  29,
X  28,  27,  26,  25,  24,  23,  24,  25,
X  26,  27,  28,  29,  30,  31,  31,  30,
X  29,  28,  27,  26,  25,  24,  23,  24,
X  25,  26,  27,  28,  29,  30,  31,  31,
X  30,  29,  28,  27,  26,  25,  24,  23,
X  24,  25,  26,  27,  28,  29,  30,  31,
X  31,  30,  29,  28,  27,  26,  25,  24,
X  23,  24,  25,  26,  27,  28,  29,  30,
X  31,  31,  30,  29,  28,  27,  26,  25,
X  24,  23,  24,  25,  26,  27,  28,  29,
X  30,  31,  31,  30,  29,  28,  27,  26,
X  25,  24,  23,  24,  25,  26,  27,  28,
X  29,  30,  31,  31,  30,  29,  28,  27,
X  26,  25,  24,  23,  24,  25,  26,  27,
X};
X
XSHORT halfbritePalette[] =
X{
X  0x0000,  0x0b98,  0x0fdc,  0x0765,  0x0edd,  0x0dcc,  0x0dcc,  0x0cbb,
X  0x0cbb,  0x0baa,  0x0baa,  0x0a99,  0x0a99,  0x0988,  0x0988,  0x0877,
X  0x0445,  0x0fee,  0x0edd,  0x0dcc,  0x0cbb,  0x0a99,  0x0988,  0x0877,
X  0x0e95,  0x0d84,  0x0d83,  0x0c73,  0x0b62,  0x0a51,  0x0a41,  0x0940
X};
XUSHORT halfbriteHeights[] =
X{
X  1023,  355,  333,  311,  289,  267,  245,  223,
X  201,  179,  173,  167,  161,  155,  149,  143,
X  137,  131,  125,  119,  113,  107,  101,  95,
X  94,  93,  92,  91,  90,  89,  88,  87,
X  86,  85,  84,  83,  82,  81,  80,  79,
X  78,  77,  76,  75,  74,  73,  72,  71,
X  70,  69,  68,  67,  66,  65,  64,  63,
X  62,  61,  60,  59,  58,  57,  56,  55,
X  54,  53,  52,  51,  50,  49,  48,  47,
X  46,  45,  44,  43,  42,  41,  40,  39,
X  38,  37,  36,  35,  34,  33,  32,  31,
X  30,  29,  28,  27,  26,  25,  24,  23,
X  22,  21,  20,  19,  18,  17,  16,  15,
X  14,  13,  12,  11,  10,  9,  8,  7,
X  6,  5,  4,  3,  2,  1,  0,  0,
X};
XUBYTE halfbritePens[] =
X{
X  17,  63,  62,  61,  60,  59,  58,  57,
X  56,  31,  30,  29,  28,  27,  26,  25,
X  24,  25,  26,  27,  28,  29,  30,  31,
X  56,  57,  58,  59,  60,  61,  62,  63,
X  55,  54,  53,  52,  51,  50,  49,  23,
X  22,  21,  20,  19,  18,  17,  18,  19,
X  20,  21,  22,  23,  49,  50,  51,  52,
X  53,  54,  55,  47,  46,  45,  44,  43,
X  42,  41,  40,  39,  38,  37,  36,  34,
X  15,  14,  13,  12,  11,  10,  9,  8,
X  7,  6,  5,  4,  5,  6,  7,  8,
X  9,  10,  11,  12,  13,  14,  15,  34,
X  36,  37,  38,  39,  40,  41,  42,  43,
X  44,  45,  46,  47,  47,  47,  46,  45,
X  44,  43,  42,  41,  40,  39,  38,  37,
X};
X
XSHORT Valley_GalPalette[] =
X{
X  0x0000,  0x0b98,  0x0fdc,  0x0765,  0x099f,  0x077c,  0x055a,  0x0337,
X  0x0114,  0x0225,  0x0446,  0x0557,  0x0668,  0x0779,  0x099a,  0x0aab,
X  0x0bbc,  0x0ccd,  0x0eee,  0x0fff,  0x0eee,  0x0dde,  0x0ccd,  0x0bbc,
X  0x0aab,  0x099b,  0x077a,  0x0669,  0x0558,  0x0448,  0x0337,  0x0226
X};
XUSHORT Valley_GalHeights[] =
X{
X  1023,  182,  137,  126,  115,  105,  94,  83,
X  73,  72,  71,  70,  69,  68,  67,  66,
X  65,  64,  63,  62,  61,  60,  59,  58,
X  57,  56,  55,  54,  53,  52,  51,  50,
X  49,  48,  47,  46,  45,  44,  43,  42,
X  41,  40,  39,  38,  37,  36,  35,  34,
X  33,  32,  31,  30,  29,  28,  27,  26,
X  25,  24,  23,  22,  21,  20,  19,  18,
X  17,  16,  15,  14,  13,  12,  11,  10,
X  9,  8,  7,  6,  5,  4,  3,  2,
X  1,  0,  0,  0,  0,  0,  0,  0,
X};
XUBYTE Valley_GalPens[] =
X{
X  0,  17,  15,  14,  13,  12,  11,  10,
X  9,  8,  8,  9,  10,  11,  12,  13,
X  14,  15,  16,  17,  18,  19,  20,  21,
X  22,  23,  24,  25,  26,  27,  28,  29,
X  30,  8,  9,  10,  11,  12,  13,  14,
X  15,  16,  17,  18,  19,  20,  21,  22,
X  23,  24,  25,  26,  27,  28,  29,  30,
X  8,  9,  10,  11,  12,  13,  14,  15,
X  16,  17,  18,  19,  20,  21,  22,  23,
X  24,  25,  26,  27,  28,  29,  30,  8,
X  9,  10,  11,  12,  13,  14,  15,  16,
X};
X
XSHORT dragon_juliaPalette[] =
X{
X  0x0000,  0x0b98,  0x0fdc,  0x0765,  0x0f60,  0x0f80,  0x0f90,  0x0fb0,
X  0x0fd0,  0x0ff0,  0x0dd1,  0x0bb2,  0x0993,  0x0884,  0x0665,  0x0446,
X  0x0227,  0x0008,  0x0207,  0x0406,  0x0605,  0x0804,  0x0903,  0x0b02,
X  0x0d01,  0x0f00,  0x0f20,  0x0f40,  0x0f50,  0x0f70,  0x0f90,  0x0fb0
X};
XUSHORT dragon_juliaHeights[] =
X{
X  1023,  142,  132,  123,  113,  104,  99,  94,
X  89,  84,  79,  74,  71,  68,  66,  63,
X  60,  58,  55,  52,  50,  48,  47,  45,
X  44,  42,  41,  39,  38,  36,  35,  34,
X  33,  32,  31,  30,  29,  28,  27,  26,
X  25,  24,  23,  22,  21,  20,  19,  18,
X  17,  16,  15,  14,  13,  12,  11,  10,
X  9,  8,  7,  6,  5,  4,  3,  2,
X  1,  0,  0,  0,  0,  0,  0,  0,
X};
XUBYTE dragon_juliaPens[] =
X{
X  0,  26,  27,  28,  4,  5,  6,  7,
X  8,  9,  10,  11,  12,  13,  14,  15,
X  16,  17,  18,  19,  20,  21,  22,  23,
X  24,  25,  26,  27,  28,  29,  30,  31,
X  9,  10,  11,  12,  13,  14,  15,  16,
X  17,  18,  19,  20,  21,  22,  23,  24,
X  25,  26,  27,  28,  29,  30,  31,  9,
X  10,  11,  12,  13,  14,  15,  16,  17,
X  18,  19,  20,  1,  1,  1,  1,  1,
X};
X
XSHORT haloPalette[] =
X{
X  0x0000,  0x0b98,  0x0fdc,  0x0765,  0x000f,  0x011f,  0x022f,  0x033f,
X  0x055f,  0x066f,  0x077f,  0x088f,  0x099f,  0x0aaf,  0x0ccf,  0x0ddf,
X  0x0eef,  0x0fff,  0x0eee,  0x0dde,  0x0ccd,  0x0bbc,  0x0aac,  0x099b,
X  0x088a,  0x0779,  0x0669,  0x0558,  0x0447,  0x0337,  0x0226,  0x0fff
X};
XUSHORT haloHeights[] =
X{
X  1023,  89,  88,  87,  86,  85,  84,  83,
X  82,  81,  80,  79,  78,  77,  76,  75,
X  74,  73,  72,  71,  70,  69,  68,  67,
X  66,  65,  64,  63,  62,  61,  60,  59,
X  58,  57,  56,  55,  54,  53,  52,  51,
X  50,  49,  48,  47,  46,  45,  44,  43,
X  42,  41,  40,  39,  38,  37,  36,  35,
X  34,  33,  32,  31,  30,  29,  28,  27,
X  26,  25,  24,  23,  22,  21,  20,  19,
X  18,  17,  16,  15,  14,  13,  12,  11,
X  10,  9,  8,  7,  6,  5,  4,  3,
X  2,  1,  0,  0,  0,  0,  0,  0,
X};
XUBYTE haloPens[] =
X{
X  0,  15,  14,  13,  12,  11,  10,  9,
X  8,  7,  6,  5,  4,  4,  5,  4,
X  5,  6,  7,  8,  9,  10,  11,  12,
X  13,  14,  15,  15,  14,  13,  12,  11,
X  10,  9,  8,  7,  6,  5,  4,  4,
X  5,  4,  5,  6,  7,  8,  9,  10,
X  11,  12,  13,  14,  15,  15,  14,  13,
X  12,  11,  10,  9,  8,  7,  6,  5,
X  4,  4,  5,  4,  5,  6,  7,  8,
X  9,  10,  11,  12,  13,  14,  15,  15,
X  14,  13,  12,  11,  10,  9,  8,  7,
X  6,  5,  4,  4,  5,  4,  5,  6,
X};
X
X#define NUM_CONTOURS(a) (sizeof(a)/sizeof(USHORT))
X
Xstruct Preset Preset[] =
X  {
X    {
X      "big_brot",  /* Preset Name */
X      MANDPICT,
X      -2.000000, -1.204545, /* StartX, StartY */
X      2.820000, 1.204545, /* EndX, EndY */
X      109, 78, /* CountX,CountY */
X      128,      /* MaxCount */
X      0,     /* MandType */
X      0x0000,   /* ViewModes */
X      5,     /* Depth */
X      0,     /* Border Type*/
X      &big_brotPalette[0], /* Palette colors */
X      32,         /* NumContours */
X      &big_brotHeights[0], /* ContourHeights */
X      &big_brotPens[0]     /* ContourPens */
X    },
X    {
X      "Hey_Baby",  /* Preset Name */
X      MANDPICT,
X      -0.143523, -1.019072, /* StartX, StartY */
X      -0.143384, -1.018843, /* EndX, EndY */
X      96, 65, /* CountX,CountY */
X      1023,     /* MaxCount */
X      0,     /* MandType */
X      0x0000,   /* ViewModes */
X      5,     /* Depth */
X      0,     /* Border Type*/
X      Hey_BabyPalette, /* Palette colors */
X      32,         /* NumContours */
X      Hey_BabyHeights, /* ContourHeights */
X      Hey_BabyPens     /* ContourPens */
X    },
X    {
X      "Aug_85_Cover",  /* Preset Name */
X      MANDPICT,
X      -0.948154, -0.296503, /* StartX, StartY */
X      -0.888359, -0.232261, /* EndX, EndY */
X      92, 86, /* CountX,CountY */
X      1023,     /* MaxCount */
X      0,     /* MathMode */
X      0x0000,   /* ViewModes */
X      5,     /* Depth */
X      0,     /* Border Type*/
X      coverPalette, /* Palette colors */
X      NUM_CONTOURS( coverHeights ),    /* NumContours */
X      coverHeights, /* ContourHeights */
X      coverPens     /* ContourPens */
X    },
X
X    {
X      "sea_horse",  /* Preset Name */
X      MANDPICT,
X      -0.750055,  0.105343, /* StartX, StartY */
X      -0.742464,  0.113267, /* EndX, EndY */
X      86, 79, /* CountX,CountY */
X      1023,     /* MaxCount */
X      0,     /* MathMode */
X      0x0000,   /* ViewModes */
X      5,     /* Depth */
X      0,     /* Border Type*/
X      sea_horsePalette, /* Palette colors */
X      NUM_CONTOURS( sea_horseHeights ),         /* NumContours */
X      sea_horseHeights, /* ContourHeights */
X      sea_horsePens     /* ContourPens */
X    },
X
X    {
X      "golden_dragon",  /* Preset Name */
X      MANDPICT,
X      -0.764140, -0.095187, /* StartX, StartY */
X      -0.764031, -0.095102, /* EndX, EndY */
X      117, 87, /* CountX,CountY */
X      1023,     /* MaxCount */
X      0,     /* MathMode */
X      0x0000,   /* ViewModes */
X      5,     /* Depth */
X      0,     /* Border Type*/
X      golden_dragonPalette, /* Palette colors */
X      NUM_CONTOURS( golden_dragonHeights ), /* NumContours */
X      golden_dragonHeights, /* ContourHeights */
X      golden_dragonPens     /* ContourPens */
X    },
X    {
X      "dual_spiral",  /* Preset Name */
X      MANDPICT,
X      -0.764616, -0.095488, /* StartX, StartY */
X      -0.764312, -0.094471, /* EndX, EndY */
X      94, 85, /* CountX,CountY */
X      1023,     /* MaxCount */
X      0,     /* MathMode */
X      0x0000,   /* ViewModes */
X      5,     /* Depth */
X      0,     /* Border Type*/
X      dual_spiralPalette, /* Palette colors */
X      NUM_CONTOURS( dual_spiralHeights ), /* NumContours */
X      dual_spiralHeights, /* ContourHeights */
X      dual_spiralPens     /* ContourPens */
X    },
X    {
X      "halfbrite",  /* Preset Name */
X      MANDPICT,
X      -0.655231, -0.366674, /* StartX, StartY */
X      -0.654933, -0.366417, /* EndX, EndY */
X      103, 84, /* CountX,CountY */
X      1023,     /* MaxCount */
X      0,     /* MathMode */
X      0x0080,   /* ViewModes */
X      6,     /* Depth */
X      0,     /* Border Type*/
X      halfbritePalette, /* Palette colors */
X      NUM_CONTOURS( halfbriteHeights ), /* NumContours */
X      halfbriteHeights, /* ContourHeights */
X      halfbritePens     /* ContourPens */
X    },
X    {
X      "Valley_Gal",  /* Preset Name */
X      JULIAPICT,
X      -0.760314, -0.135554, /* StartX, StartY */
X      1.707388, 1.064516, /* EndX, EndY */
X      133, 77, /* CountX,CountY */
X      1023,     /* MaxCount */
X      0,     /* MathMode */
X      0x0000,   /* ViewModes */
X      5,     /* Depth */
X      0,     /* Border Type*/
X      Valley_GalPalette, /* Palette colors */
X      NUM_CONTOURS( Valley_GalHeights ), /* NumContours */
X      Valley_GalHeights, /* ContourHeights */
X      Valley_GalPens     /* ContourPens */
X    },
X    {
X      "dragon_julia",  /* Preset Name */
X      JULIAPICT,
X      -0.942986, -0.270764, /* StartX, StartY */
X      1.288473, 0.974026, /* EndX, EndY */
X      149, 77, /* CountX,CountY */
X      1023,     /* MaxCount */
X      0,     /* MathMode */
X      0x0000,   /* ViewModes */
X      5,     /* Depth */
X      0,     /* Border Type*/
X      dragon_juliaPalette, /* Palette colors */
X      NUM_CONTOURS( dragon_juliaHeights ), /* NumContours */
X      dragon_juliaHeights, /* ContourHeights */
X      dragon_juliaPens     /* ContourPens */
X    },
X    {
X      "halo",  /* Preset Name */
X      JULIAPICT,
X       0.263523,  0.000016, /* StartX, StartY */
X      1.031916, 1.233333, /* EndX, EndY */
X      79, 77, /* CountX,CountY */
X      1023,     /* MaxCount */
X      0,     /* MathMode */
X      0x0000,   /* ViewModes */
X      5,     /* Depth */
X      0,     /* Border Type*/
X      haloPalette, /* Palette colors */
X      NUM_CONTOURS( haloHeights ),    /* NumContours */
X      haloHeights, /* ContourHeights */
X      haloPens     /* ContourPens */
X    }
X  };
X
X#define DEVELOPMENT
X#ifdef DEVELOPMENT
X
XSavePreset(name,MPict)
X  char *name;
X  struct Picture *MPict;
X{
X  register struct Picture *Pict = MPict;
X  int i;
X
X  FILE *SaveFile;
X
X  SaveFile = fopen(name,"a");
X
X  if (SaveFile != (struct FILE *) NULL) {
X
X    fprintf(SaveFile, "SHORT %sPalette[] =\n{\n",name);
X    for (i = 0; i < 32; i++) {
X      fprintf(SaveFile, "  0x%04x", GetRGB4(vp->ColorMap, i));
X
X      if (i != 31)
X        fprintf(SaveFile,",");
X
X      if (i % 8 == 7)
X        fprintf(SaveFile, "\n");
X    }
X    fprintf(SaveFile, "};\n");
X
X    fprintf(SaveFile, "USHORT %sHeights[] =\n{\n",name);
X    for (i = 0; i < NumContours; i++) {
X      fprintf(SaveFile, "  %d", *(Pict->Heights + i) );
X
X      if (i != NumContours - 1) {
X        fprintf(SaveFile,",");
X        if (i % 8 == 7)
X          fprintf(SaveFile, "\n");
X      }
X    }
X    fprintf(SaveFile, "\n};\n");
X
X    fprintf(SaveFile, "UBYTE %sPens[] =\n{\n",name);
X    for (i = 0; i < NumContours; i++) {
X      fprintf(SaveFile, "  %d", *(Pict->Pens + i) );
X
X      if (i != NumContours - 1) {
X        fprintf(SaveFile,",");
X        if (i % 8 == 7)
X          fprintf(SaveFile, "\n");
X      }
X    }
X    fprintf(SaveFile, "\n};\n");
X
X    fprintf(SaveFile, "    {\n");
X    fprintf(SaveFile, "      \"%s\",  /* Preset Name */\n", name);
X
X    if (Pict->pNode.ln_Type == JULIAPICT) {
X      fprintf(SaveFile, "      %f, %f, /* StartX, StartY */\n",
X                                      Pict->Real, Pict->Imag);
X    } else {
X      fprintf(SaveFile, "      %f, %f, /* StartX, StartY */\n",
X                                      Pict->RealLow, Pict->ImagLow);
X    }
X
X    fprintf(SaveFile, "      %f, %f, /* EndX, EndY */\n", Pict->RealHigh,
X                                                          Pict->ImagHigh);
X    fprintf(SaveFile, "      %d, %d, /* CountX,CountY */\n",
X                             Pict->CountX, Pict->CountY);
X
X    fprintf(SaveFile, "      %d,     /* MaxCount */\n", Pict->MaxIteration);
X    fprintf(SaveFile, "      %d,     /* MathMode */\n", Pict->MathMode);
X
X    fprintf(SaveFile, "      0x%04x,   /* ViewModes */\n",
X                                    screen->ViewPort.Modes);
X
X    fprintf(SaveFile, "      %d,     /* Depth */\n",
X                                    screen->BitMap.Depth);
X
X    fprintf(SaveFile, "      %d,     /* Border Type*/\n", 0);
X
X    fprintf(SaveFile, "      %sPalette, /* Palette colors */\n",
X                                    name);
X
X    fprintf(SaveFile, "      %d,         /* NumContours */\n",
X                                    NumContours);
X
X    fprintf(SaveFile, "      %sHeights, /* ContourHeights */\n", name);
X    fprintf(SaveFile, "      %sPens     /* ContourPens */\n", name);
X    fprintf(SaveFile, "    },\n\n\n");
X
X    fclose( SaveFile );
X  }
X}
X#endif
SHAR_EOF
echo "extracting recolor.c"
sed 's/^X//' << \SHAR_EOF > recolor.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 functions to redraw (or repaint) Mandelbrot
X * and Julia projects.  There are special high-performance functions to
X * recolor 4 and 5 bit plane pictures (in assembly).  There is also a
X * function that can spawn off a child task to redraw the picture (for the
X * other number of bit planes 1,2,3 and 6)
X */
X
X#include "mandp.h"
X
Xextern LONG pSigMask;
X
X/*
X * ReColor a picture into a window
X */
XReColor( Pict )
X  register struct Picture *Pict;
X{
X  /* This set of variables should not be rearranged or moved.
X     There is Assembly language used in this routine, to increase
X     performance.  The assembly code depends on these variables
X     being located on Manx's stack.  Obviously it is not too portable
X     or maintainable, but it is faster.
X   */
X  SHORT *CountPtr;
X  UBYTE *ColorPtr;
X
X  register LONG CountX, CountY;
X
X  /* These variables are O.K. to rearrange and add to. */
X
X  register struct Window  *Window;
X  register LONG   dx,dy;
X
X  LONG i, Depth;
X
X  UBYTE *ColorSave;
X
X  LONG   wx,wy,Sx;
X
X  if ( Pict == NULL )
X    return;
X
X  KillReColor( Pict );
X  FreeScrollTemp( Pict );
X  PauseChild(Pict);
X
X  Window = Pict->Window;
X  CountPtr = Pict->Counts;
X  CountX = Pict->CountX;
X  CountY = Pict->CountY;
X
X  Depth = screen->BitMap.Depth;
X
X  if (CountPtr == NULL || Pict->Flags & NO_RAM_GENERATE ) {
X    DispErrMsg("No counts to recolor",0);
X    return;
X  }
X
X  wx = CountX + Pict->LeftMarg + Pict->RightMarg;
X  wy = CountY + Pict->TopMarg  + Pict->BotMarg;
X
X  dx = screen->Width  - wx;
X  dy = screen->Height - wy;
X
X  if ( dx < 0 || dy < 0 ) {
X    DispErrMsg("Picture too big for screen.",0);
X    return;
X  }
X
X  dx -= Window->LeftEdge;
X  dy -= Window->TopEdge;
X
X  if ( dx < 0 || dy < 0 ) {
X    MoveWindow( Window, dx, dy );
X  }
X
X  dx = wx - Window->Width;
X  dy = wy - Window->Height;
X
X  if ( dx || dy ) {
X
X    SizeWindow(Window, dx, dy );
X
X    /* Spin till the window gets resized */
X    /* Gross eh? */
X
X    i = 0;
X
X    while (i++ < 10000 && Window->Width != wx && Window->Height != wy);
X
X    if (i == 10000) {
X      DispErrMsg("can't resize the window");
X      return;
X    }
X
X    BorderWindow(Window);
X  }
X
X  if (Pict->CurLine+Pict->TopMarg < Pict->Window->Height-Pict->BotMarg-1) {
X
X    SetAPen(  Pict->Window->RPort, NORMALPEN );
X    RectFill( Pict->Window->RPort, Pict->LeftMarg,
X              Pict->CurLine        + Pict->TopMarg,
X              Pict->Window->Width  - Pict->RightMarg - 1,
X              Pict->Window->Height - Pict->BotMarg   - 1);
X  }
X
X  Pict->Flags &= ~LENS_DISPLAYED;
X
X  MakeColorXlate( Pict );
X
X  if ( Depth != 4 && Depth != 5) {
X    ReColorSlow( Pict );
X    return;
X  }
X
X  /* try to get enough memory to recolor the picture fast. */
X
X  ColorPtr = ColorSave =
X           (UBYTE *) safeAllocMem( CountX * CountY + 1, 0L);
X
X  if (ColorPtr == (UBYTE *) NULL) {
X    ReColorSlow( Pict );
X    return;
X  }
X
X  WindowToFront(Window);
X  ClearMenuStrip(Window);
X
X  Delay(8);
X
X  LockLayers( BackWind->WLayer->LayerInfo );
X
X  /* We were able to allocate enough memory to translate the entire
X     picture from heights to pens.  The array of pens is used to
X     quickly recolor the screen using Recolor4 or Recolor5 */
X
X  /* If you don't like the assembly, you can use this C instead */
X
X#define SLOW1
X#ifdef SLOW1
X  for (Sx = CountX*CountY; Sx-- >= 0; )
X    *(ColorPtr++) = *(Pict->ClrXlate + *(CountPtr++));
X
X#else
X#asm
XCountPtr  equ -4                     ; these define where your variables
XColorBase equ -8                     ; are located on Manx's stack
X   move.w   d4,d1                    ; this is ugly, but CountX is in d4
X   muls.w   d5,d1                    ; and CountY is in d5
X   sub.l    #1,d1
X   move.l   CountPtr(a5),a0
X   move.l   _ColorXlate,a1
X   move.l   ColorBase(a5),a6
XColorLoop
X   move.w   (a0)+,d0
X   move.b   (a1,d0.w),(a6)+
X   sub.l    #1,d1
X   bge      ColorLoop
X#endasm
X#endif
X
X  if (Depth == 4) {
X    ReColor4( ColorSave, Pict);
X  } else
X  if (Depth == 5) {
X    ReColor5( ColorSave, Pict);
X  }
X  UnlockLayers( BackWind->WLayer->LayerInfo );
X  AwakenChild(Pict);
X
X  SetMenuStrip(Window, Menu);
X
X  FreeMem(ColorSave,CountX*CountY+1);
X} /* ReColor */
X
XMakeColorXlate( Pict )
X  register struct Picture *Pict;
X{
X  register LONG i,j;
X
X  /* So prepare the color translate table */
X  for (i = 0,j = 1023; i < NumContours; i++)
X    for (; j >= Pict->Heights[i] && j > 0; )
X     *(Pict->ClrXlate + j--) = Pict->Pens[i];
X  while (j >= 0) *(Pict->ClrXlate + j--) = 0;
X}
X
X/*
X * Assembly code to recolor 4 bit planes
X */
XReColor4(ColorSave, Pict)
X  UBYTE *ColorSave;
X  register struct Picture *Pict;
X{
X  /* This set of variables should not be rearranged or moved.
X     There is Assembly language used in this routine, to increase
X     performance.  The assembly code depends on these variables
X     being located on Manx's stack.  Obviously it is not too portable
X     or maintainable, but it is faster.
X   */
X  SHORT  Mask,Width;
X  LONG   Mod,CMod;
X  SHORT  LF,LP,RF,RP;
X  SHORT  i,j,k,l;
X  LONG   Sx,TL;
X  UBYTE  *ColorPtr;
X
X  struct BitMap *BitMap;
X
X  /* This can be messed with */
X
X  SHORT  CountX, CountY;
X
X  register struct Window  *Window;
X
X#asm
XSaveReg  reg a0-a6/d0-d7
XPlane0   equ 8
XPlane1   equ Plane0+4
XPlane2   equ Plane0+8
XPlane3   equ Plane0+12
XPlane4   equ Plane0+16
XPlane5   equ Plane0+20
X
XCountX    equ -50
XCountY    equ -48
XBitMap    equ -44
XColorPtr  equ -40
XTL        equ -36
XSx        equ -32
Xl         equ -28
Xk         equ -26
Xj         equ -24
Xi         equ -22
XRP        equ -20
XRF        equ -18
XLP        equ -16
XLF        equ -14
XCMod      equ -12
XMod       equ -8
XWidth     equ -4
XMask      equ -2
XColorSave equ 8
X#endasm
X
X  Window = Pict->Window;
X  BitMap = Window->RPort->BitMap;
X  CountX = Pict->CountX;
X  CountY = Pict->CurLine;
X
X  ColorPtr = ColorSave;
X  Sx = (screen->Width + 15) >> 4;
X  LP = Window->LeftEdge + Pict->LeftMarg;
X  LF = (LP + 15) & 0xfff0;
X  CMod = Pict->CountX - (LF-LP);
X  Mod = Sx - 1;
X  TL = Sx *  (Window->TopEdge + Pict->TopMarg) + (LP-1 >> 4);
X  Width = LF-LP;
X  Mask = 0xffff << Width;
X
X  if ( Width > 0 ) {
X
X#asm
X  movem.l SaveReg,-(sp)          ;Save all the gprs to the stack
X  move.l  a5,a1                  ;We need a5, so put MANX stack in a1
X  move.w  CountY(a5),i(a1)
X  move.l  BitMap(a1),a0
X  move.l  TL(a1),d0              ;Load Offset to Top,Left corner of screen
X  asl.l   #1,d0                  ; and make it a 'word' offset
X  move.l  Plane0(a0),a2          ;Get address of screens first bit plane
X  adda.l  d0,a2                  ; add in window top-left offset.
X  move.l  Plane1(a0),a3          ;Same for second bit plane.
X  adda.l  d0,a3
X  move.l  Plane2(a0),a4          ;Same for third bit plane.
X  adda.l  d0,a4
X  move.l  Plane3(a0),a5          ;Same for fourth bit plane.
X  adda.l  d0,a5
X  move.l  ColorPtr(a1),a0        ;Load up pointer to recolored data.
X  move.l  #1,d1                  ;/* for each row */
X;                                for (i = CountY; i; i--) {
XY0Loop4                            ; /* for each pixel in column */
X  move.w  Width(a1),d7           ;  for (k = Width; k; k--) {
X  eor.w   d2,d2                  ;  Clear all bits in the bit plane data regs.
X  eor.w   d3,d3
X  eor.w   d4,d4
X  eor.w   d5,d5
XB0Loop4
X  move.b  (a0)+,d0               ;    d0 = *(ColorPtr++);
X  asr.b   d1,d0                  ;    get low order bit from d0
X  addx.w  d2,d2                  ;    put it in bit plane 0 data
X  asr.b   d1,d0                  ;    same for bit plane 1
X  addx.w  d3,d3
X  asr.b   d1,d0                  ;    same for bit plane 2
X  addx.w  d4,d4
X  asr.b   d1,d0                  ;    same for bit plane 3
X  addx.w  d5,d5
X  sub.w   d1,d7                  ;    same for bit plane 5
X  bgt     B0Loop4                ;  } /* did each bit in bit plane word */
X  move.w  Mask(a1),d0            ;  Turn off all the new bits in planes
X  and.w   d0,(a2)
X  and.w   d0,(a3)
X  and.w   d0,(a4)
X  and.w   d0,(a5)
X  or.w    d2,(a2)+               ;  Set the new bits in the bit planes
X  or.w    d3,(a3)+
X  or.w    d4,(a4)+
X  or.w    d5,(a5)+
X  move.l  Mod(a1),d0             ;  Adjust plane pointers to start of next line
X  add.l   d0,d0
X  add.l   d0,a2
X  add.l   d0,a3
X  add.l   d0,a4
X  add.l   d0,a5
X  adda.l  CMod(a1),a0            ;  Adjust color pointer to start of next line
X  sub.w   d1,i(a1)               ;} /* did each row */
X  tst.w   i(a1)
X  bgt     Y0Loop4
X  movem.l (sp)+,SaveReg          ;better restore the registers
X#endasm
X  ;
X  }
X
X  RP = LP + Pict->CountX & 0xfff0;
X  RF = RP - 16;
X  CMod = Pict->CountX - (RP-LF);
X  Mod = Sx - ((RP-LF) >> 4);
X  TL++;
X  Width = (RP-LF) >> 4;
X  ColorPtr = ColorSave + LF - LP;
X
X  if (Width > 0 ) {
X
X#asm
X  movem.l SaveReg,-(sp)          ;Save all the gprs to the stack
X  move.l  a5,a1                  ;We need a5, so put MANX stack in a1
X  move.w  CountY(a5),i(a1)          ;i = CountY;
X  move.l  BitMap(a1),a0
X  move.l  TL(a1),d0              ;Load Offset to Top,Left corner of screen
X  asl.l   #1,d0                  ; and make it a 'word' offset
X  move.l  Plane0(a0),a2          ;Get address of screens first bit plane
X  adda.l  d0,a2                  ; add in window top-left offset.
X  move.l  Plane1(a0),a3          ;Same for second bit plane.
X  adda.l  d0,a3
X  move.l  Plane2(a0),a4          ;Same for third bit plane.
X  adda.l  d0,a4
X  move.l  Plane3(a0),a5          ;Same for fourth bit plane.
X  adda.l  d0,a5
X  move.l  ColorPtr(a1),a0        ;Load up pointer to recolored data.
X  move.l  #1,d1                  ;/* for each row */
X;                                for (i = CountY; i; i--) {
XYLoop4                            ; /* for each column */
X  move.w  Width(a1),j(a1)        ;  for (j = Width; j; j--) {
XXLoop4                               ; /* pack a word for each bit plane */
X  move.w  #16,d7                 ;    for (k = 16; k; k--) {
XBLoop4
X  move.b  (a0)+,d0               ;      d0 = *(ColorPtr++);
X  asr.b   d1,d0                  ;      get low order bit from d0
X  addx.w  d2,d2                  ;      put it in bit plane 0 data
X  asr.b   d1,d0                  ;      same for bit plane 1
X  addx.w  d3,d3
X  asr.b   d1,d0                  ;      same for bit plane 2
X  addx.w  d4,d4
X  asr.b   d1,d0                  ;      same for bit plane 3
X  addx.w  d5,d5
X  sub.w   d1,d7                  ;      same for bit plane 5
X  bgt     BLoop4                 ;    } /* did each bit in bit plane word */
X  move.w  d2,(a2)+               ;    Save the packed data in bit planes
X  move.w  d3,(a3)+
X  move.w  d4,(a4)+
X  move.w  d5,(a5)+
X  sub.w   d1,j(a1)               ;  } /* did each word in a row */
X  tst.w   j(a1)
X  bgt     XLoop4
X  move.l  Mod(a1),d0             ;  Adjust plane pointers to start of next line
X  add.l   d0,d0
X  add.l   d0,a2
X  add.l   d0,a3
X  add.l   d0,a4
X  add.l   d0,a5
X  adda.l  CMod(a1),a0            ;  Adjust color pointer to start of next line
X  sub.w   d1,i(a1)               ;} /* did each row */
X  tst.w   i(a1)
X  bgt     YLoop4
X  movem.l (sp)+,SaveReg          ;better restore the registers
X#endasm
X  ;
X  }
X
X  TL += Width;
X  Width = LP + Pict->CountX - RP;
X  CMod = Pict->CountX - Width;
X  Mod = Sx - 1;
X  Mask = 0xffff >> Width;
X  ColorPtr = ColorSave + RP - LP;
X
X  if ( Width > 0 ) {
X
X#asm
X  movem.l SaveReg,-(sp)          ;Save all the gprs to the stack
X  move.l  a5,a1                  ;We need a5, so put MANX stack in a1
X  move.w  CountY(a5),i(a1)
X  move.l  BitMap(a1),a0
X  move.l  TL(a1),d0              ;Load Offset to Top,Left corner of screen
X  asl.l   #1,d0                  ; and make it a 'word' offset
X  move.l  Plane0(a0),a2          ;Get address of screens first bit plane
X  adda.l  d0,a2                  ; add in window top-left offset.
X  move.l  Plane1(a0),a3          ;Same for second bit plane.
X  adda.l  d0,a3
X  move.l  Plane2(a0),a4          ;Same for third bit plane.
X  adda.l  d0,a4
X  move.l  Plane3(a0),a5          ;Same for fourth bit plane.
X  adda.l  d0,a5
X  move.l  ColorPtr(a1),a0        ;Load up pointer to recolored data.
X  move.l  #1,d1                  ;/* for each row */
X;                                ;for (i = CountY; i; i--) {
XY2Loop4                            ; /* for each pixel in column */
X  move.w  Width(a1),d7           ;  for (k = Width; k; k--) {
X  eor.w   d2,d2                  ;  Clear all bits in the bit plane data regs.
X  eor.w   d3,d3
X  eor.w   d4,d4
X  eor.w   d5,d5
XB2Loop4
X  move.b  (a0)+,d0                ;   d0 = *(ColorPtr++);
X  asr.b   d1,d0                   ;   get low order bit from d0
X  addx.w  d2,d2                   ;   put it in bit plane 0 data
X  asr.b   d1,d0                   ;   same for bit plane 1
X  addx.w  d3,d3
X  asr.b   d1,d0                   ;   same for bit plane 2
X  addx.w  d4,d4
X  asr.b   d1,d0                   ;   same for bit plane 3
X  addx.w  d5,d5
X  sub.w   d1,d7                   ;   same for bit plane 5
X  bgt     B2Loop4                 ; } /* did each bit in bit plane word */
X  move.w  Mask(a1),d0             ; Turn off all the new bits in planes
X  and.w   d0,(a2)
X  and.w   d0,(a3)
X  and.w   d0,(a4)
X  and.w   d0,(a5)
X  move.w  #16,d0
X  sub.w   Width(a1),d0
X  asl.w   d0,d2
X  asl.w   d0,d3
X  asl.w   d0,d4
X  asl.w   d0,d5
X  or.w    d2,(a2)+                ; Set the new bits in the bit planes
X  or.w    d3,(a3)+
X  or.w    d4,(a4)+
X  or.w    d5,(a5)+
X  move.l  Mod(a1),d0              ; Adjust plane pointers to start of next line
X  add.l   d0,d0
X  add.l   d0,a2
X  add.l   d0,a3
X  add.l   d0,a4
X  add.l   d0,a5
X  adda.l  CMod(a1),a0             ; Adjust color pointer to start of next line
X  sub.w   d1,i(a1)               ;} /* did each row */
X  tst.w   i(a1)
X  bgt     Y2Loop4
X  movem.l (sp)+,SaveReg          ;better restore the registers
X#endasm
X  ;
X  }
X} /* ReColor 4 bit planes */
X
X
X/*
X * Assembly code to recolor 5 bit planes
X */
XReColor5(ColorSave, Pict)
X  UBYTE *ColorSave;
X  register struct Picture *Pict;
X{
X  /* This set of variables should not be rearranged or moved.
X     There is Assembly language used in this routine, to increase
X     performance.  The assembly code depends on these variables
X     being located on Manx's stack.  Obviously it is not too portable
X     or maintainable, but it is faster.
X   */
X  SHORT  Mask,Width;
X  LONG   Mod,CMod;
X  SHORT  LF,LP,RF,RP;
X  SHORT  i,j,k,l;
X  LONG   Sx,TL;
X  UBYTE  *ColorPtr;
X
X  struct BitMap *BitMap;
X
X  /* These can be messed with */
X
X  SHORT  CountX, CountY;
X
X  register struct Window  *Window;
X
X  Window = Pict->Window;
X  BitMap = Window->RPort->BitMap;
X
X  CountX = Pict->CountX;
X  CountY = Pict->CurLine;
X
X  ColorPtr = ColorSave;
X  Sx = (screen->Width + 15) >> 4;
X  LP = Window->LeftEdge + Pict->LeftMarg;
X  LF = (LP + 15) & 0xfff0;
X  CMod = CountX - (LF-LP);
X  Mod = Sx - 1;
X  TL = Sx *  (Window->TopEdge + Pict->TopMarg) + (LP-1 >> 4);
X  Width = LF-LP;
X  Mask = 0xffff << Width;
X
X  if ( Width > 0 ) {
X
X#asm
X  movem.l SaveReg,-(sp)          ;Save all the gprs to the stack
X  move.l  a5,a1                  ;We need a5, so put MANX stack in a1
X  move.w  CountY(a5),i(a1)
X  move.l  BitMap(a1),a0
X  move.l  TL(a1),d0              ;Load Offset to Top,Left corner of screen
X  asl.l   #1,d0                  ; and make it a 'word' offset
X  move.l  Plane0(a0),a2          ;Get address of screens first bit plane
X  adda.l  d0,a2                  ; add in window top-left offset.
X  move.l  Plane1(a0),a3          ;Same for second bit plane.
X  adda.l  d0,a3
X  move.l  Plane2(a0),a4          ;Same for third bit plane.
X  adda.l  d0,a4
X  move.l  Plane3(a0),a5          ;Same for fourth bit plane.
X  adda.l  d0,a5
X  move.l  Plane4(a0),a6          ;Same for fifth bit plane.
X  adda.l  d0,a6
X  move.l  ColorPtr(a1),a0        ;Load up pointer to recolored data.
X  move.l  #1,d1                  ;/* for each row */
X;                                ;for (i = CountY; i; i--) {
XY0Loop5                            ; /* for each pixel in column */
X  move.w  Width(a1),d7           ;  for (k = Width; k; k--) {
X  eor.w   d2,d2                  ;  Clear all bits in the bit plane data regs.
X  eor.w   d3,d3
X  eor.w   d4,d4
X  eor.w   d5,d5
X  eor.w   d6,d6
XB0Loop5
X  move.b  (a0)+,d0               ;    d0 = *(ColorPtr++);
X  asr.b   d1,d0                  ;    get low order bit from d0
X  addx.w  d2,d2                  ;    put it in bit plane 0 data
X  asr.b   d1,d0                  ;    same for bit plane 1
X  addx.w  d3,d3
X  asr.b   d1,d0                  ;    same for bit plane 2
X  addx.w  d4,d4
X  asr.b   d1,d0                  ;    same for bit plane 3
X  addx.w  d5,d5
X  asr.b   d1,d0                  ;    same for bit plane 4
X  addx.w  d6,d6
X  sub.w   d1,d7                  ;    same for bit plane 5
X  bgt     B0Loop5                ;  } /* did each bit in bit plane word */
X  move.w  Mask(a1),d0            ;  Turn off all the new bits in planes
X  and.w   d0,(a2)
X  and.w   d0,(a3)
X  and.w   d0,(a4)
X  and.w   d0,(a5)
X  and.w   d0,(a6)
X  or.w    d2,(a2)+               ;  Set the new bits in the bit planes
X  or.w    d3,(a3)+
X  or.w    d4,(a4)+
X  or.w    d5,(a5)+
X  or.w    d6,(a6)+
X  move.l  Mod(a1),d0             ;  Adjust plane pointers to start of next line
X  add.l   d0,d0
X  add.l   d0,a2
X  add.l   d0,a3
X  add.l   d0,a4
X  add.l   d0,a5
X  add.l   d0,a6
X  adda.l  CMod(a1),a0            ;  Adjust color pointer to start of next line
X  sub.w   d1,i(a1)               ;} /* did each row */
X  tst.w   i(a1)
X  bgt     Y0Loop5
X  movem.l (sp)+,SaveReg          ;better restore the registers
X#endasm
X  ;
X  }
X
X  RP = LP + CountX & 0xfff0;
X  RF = RP - 16;
X  CMod = CountX - (RP-LF);
X  Mod = Sx - ((RP-LF) >> 4);
X  TL++;
X  Width = (RP-LF) >> 4;
X  ColorPtr = ColorSave + LF - LP;
X
X  if ( Width > 0 ) {
X
X#asm
X  movem.l SaveReg,-(sp)          ;Save all the gprs to the stack
X  move.l  a5,a1                  ;We need a5, so put MANX stack in a1
X  move.w  CountY(a5),i(a1)          ;i = CountY;
X  move.l  BitMap(a1),a0
X  move.l  TL(a1),d0              ;Load Offset to Top,Left corner of screen
X  asl.l   #1,d0                  ; and make it a 'word' offset
X  move.l  Plane0(a0),a2          ;Get address of screens first bit plane
X  adda.l  d0,a2                  ; add in window top-left offset.
X  move.l  Plane1(a0),a3          ;Same for second bit plane.
X  adda.l  d0,a3
X  move.l  Plane2(a0),a4          ;Same for third bit plane.
X  adda.l  d0,a4
X  move.l  Plane3(a0),a5          ;Same for fourth bit plane.
X  adda.l  d0,a5
X  move.l  Plane4(a0),a6          ;Same for fifth bit plane.
X  adda.l  d0,a6
X  move.l  ColorPtr(a1),a0        ;Load up pointer to recolored data.
X  move.l  #1,d1                  ;/* for each row */
X;                                ;for (i = CountY; i; i--) {
XYLoop5                            ; /* for each column */
X  move.w  Width(a1),j(a1)        ;  for (j = Width; j; j--) {
XXLoop5                               ; /* pack a word for each bit plane */
X  move.w  #16,d7                 ;    for (k = 16; k; k--) {
XBLoop5
X  move.b  (a0)+,d0               ;      d0 = *(ColorPtr++);
X  asr.b   d1,d0                  ;      get low order bit from d0
X  addx.w  d2,d2                  ;      put it in bit plane 0 data
X  asr.b   d1,d0                  ;      same for bit plane 1
X  addx.w  d3,d3
X  asr.b   d1,d0                  ;      same for bit plane 2
X  addx.w  d4,d4
X  asr.b   d1,d0                  ;      same for bit plane 3
X  addx.w  d5,d5
X  asr.b   d1,d0                  ;      same for bit plane 4
X  addx.w  d6,d6
X  sub.w   d1,d7                  ;      same for bit plane 5
X  bgt     BLoop5                 ;    } /* did each bit in bit plane word */
X  move.w  d2,(a2)+               ;    Save the packed data in bit planes
X  move.w  d3,(a3)+
X  move.w  d4,(a4)+
X  move.w  d5,(a5)+
X  move.w  d6,(a6)+
X  sub.w   d1,j(a1)               ;  } /* did each word in a row */
X  tst.w   j(a1)
X  bgt     XLoop5
X  move.l  Mod(a1),d0             ;  Adjust plane pointers to start of next line
X  add.l   d0,d0
X  add.l   d0,a2
X  add.l   d0,a3
X  add.l   d0,a4
X  add.l   d0,a5
X  add.l   d0,a6
X  adda.l  CMod(a1),a0            ;  Adjust color pointer to start of next line
X  sub.w   d1,i(a1)               ;} /* did each row */
X  tst.w   i(a1)
X  bgt     YLoop5
X  movem.l (sp)+,SaveReg          ;better restore the registers
X#endasm
X  ;
X  }
X
X  TL += Width;
X  Width = LP + CountX - RP;
X  CMod = CountX - Width;
X  Mod = Sx - 1;
X  Mask = 0xffff >> Width;
X  ColorPtr = ColorSave + RP - LP;
X
X  if ( Width > 0 ) {
X#asm
X  movem.l SaveReg,-(sp)          ;Save all the gprs to the stack
X  move.l  a5,a1                  ;We need a5, so put MANX stack in a1
X  move.w  CountY(a5),i(a1)
X  move.l  BitMap(a1),a0
X  move.l  TL(a1),d0              ;Load Offset to Top,Left corner of screen
X  asl.l   #1,d0                  ; and make it a 'word' offset
X  move.l  Plane0(a0),a2          ;Get address of screens first bit plane
X  adda.l  d0,a2                  ; add in window top-left offset.
X  move.l  Plane1(a0),a3          ;Same for second bit plane.
X  adda.l  d0,a3
X  move.l  Plane2(a0),a4          ;Same for third bit plane.
X  adda.l  d0,a4
X  move.l  Plane3(a0),a5          ;Same for fourth bit plane.
X  adda.l  d0,a5
X  move.l  Plane4(a0),a6          ;Same for fifth bit plane.
X  adda.l  d0,a6
X  move.l  ColorPtr(a1),a0        ;Load up pointer to recolored data.
X  move.l  #1,d1                  ;/* for each row */
X;                                ;for (i = CountY; i; i--) {
XY2Loop5                          ;  ; /* for each pixel in column */
X  move.w  Width(a1),d7           ;  for (k = Width; k; k--) {
X  eor.w   d2,d2                  ;  Clear all bits in the bit plane data regs.
X  eor.w   d3,d3
X  eor.w   d4,d4
X  eor.w   d5,d5
X  eor.w   d6,d6
XB2Loop5
X  move.b  (a0)+,d0               ;    d0 = *(ColorPtr++);
X  asr.b   d1,d0                  ;    get low order bit from d0
X  addx.w  d2,d2                  ;    put it in bit plane 0 data
X  asr.b   d1,d0                  ;    same for bit plane 1
X  addx.w  d3,d3
X  asr.b   d1,d0                  ;    same for bit plane 2
X  addx.w  d4,d4
X  asr.b   d1,d0                  ;    same for bit plane 3
X  addx.w  d5,d5
X  asr.b   d1,d0                  ;    same for bit plane 4
X  addx.w  d6,d6
X  sub.w   d1,d7                  ;    same for bit plane 5
X  bgt     B2Loop5                ;  } /* did each bit in bit plane word */
X  move.w  Mask(a1),d0            ;  Turn off all the new bits in planes
X  and.w   d0,(a2)
X  and.w   d0,(a3)
X  and.w   d0,(a4)
X  and.w   d0,(a5)
X  and.w   d0,(a6)
X  move.w  #16,d0
X  sub.w   Width(a1),d0
X  asl.w   d0,d2
X  asl.w   d0,d3
X  asl.w   d0,d4
X  asl.w   d0,d5
X  asl.w   d0,d6
X  or.w    d2,(a2)+               ;  Set the new bits in the bit planes
X  or.w    d3,(a3)+
X  or.w    d4,(a4)+
X  or.w    d5,(a5)+
X  or.w    d6,(a6)+
X  move.l  Mod(a1),d0             ;  Adjust plane pointers to start of next line
X  add.l   d0,d0
X  add.l   d0,a2
X  add.l   d0,a3
X  add.l   d0,a4
X  add.l   d0,a5
X  add.l   d0,a6
X  adda.l  CMod(a1),a0            ;  Adjust color pointer to start of next line
X  sub.w   d1,i(a1)               ;} /* did each row */
X  tst.w   i(a1)
X  bgt     Y2Loop5
X  movem.l (sp)+,SaveReg          ;better restore the registers
X#endasm
X  ;
X  }
X
X} /* ReColor 5 bit planes */
X
Xstatic struct Picture *ReColorPict;
X
XReColorSlow( Pict )
X  register struct Picture *Pict;
X{
X  int ReColorTask();
X
X  WindowToFront(Pict->Window);
X
X  Pict->ColorState = GENERATESTATE;
X
X  ReColorPict = Pict;
X
X  Pict->cTask = CreateTask( "ReColor", 0, ReColorTask, 1024);
X
X  if ( Pict->cTask == NULL ) {
X    DispErrMsg("Could not create recolor task",0);
X  }
X
X  /* Do this so we are sure child is done with ReColorPict */
X
X  Wait( pSigMask );
X}
X
XReColorTask( )
X{
X  register struct Picture  *Pict;
X  register struct RastPort *Rp;
X  register UBYTE  OldColor, NewColor;
X
X  register LONG   x, y;
X           LONG   xl, yl;
X
X  SHORT *CountPtr;
X
X  struct Window *Window;
X
X  geta4();
X
X  Pict = ReColorPict;
X
X  /* Signal Parent that we have accessed ReColorPict */
X
X  Signal( mTask, pSigMask );
X
X  Window = Pict->Window;
X  Pict->ColorChildState = RECOLORINCOMPLETE;
X
X  Rp = Window->RPort;
X  CountPtr = Pict->Counts;
X
X  OldColor = 0xff;
X
X  xl = Pict->CountX  + Pict->LeftMarg;
X  yl = Pict->CurLine + Pict->TopMarg;
X
X  for (y = Pict->TopMarg; y < yl; y++) {
X
X    ObtainSemaphore( &Pict->WindowSemi );
X
X    OldColor = *(Pict->ClrXlate + *CountPtr);
X    Move( Rp, Pict->LeftMarg, y);
X
X    for (x = Pict->LeftMarg; x < xl; x++) {
X
X      NewColor = *(Pict->ClrXlate + *CountPtr++);
X
X      if ( NewColor != OldColor) {
X
X        SetAPen( Rp, OldColor );
X
X        if ( x < Window->Width - Window->BorderRight) {
X          Draw( Rp, x, y);
X        }
X
X        OldColor = NewColor;
X      }
X    }
X    SetAPen( Rp, NewColor );
X    Draw( Rp, x-1, y);
X
X    ReleaseSemaphore( &Pict->WindowSemi );
X
X    ReColorPause( Pict );
X  }
X  Pict->ColorChildState = RECOLORCOMPLETE;
X
X  /* Indicate that generation has finished for this task */
X
X  Signal( mTask, mSigMask );               /* signal parent as to change */
X
X  while (Pict->ColorState != PAUSESTATE) ;
X
X  ReColorPause(Pict);  /* signal back so parent doesn't hang */
X} /* ReColorTask */
X
XKillReColor( Pict )
X  register struct Picture *Pict;
X{
X  register struct Task *cTask;
X
X  if ( cTask = Pict->cTask ) {
X
X    PauseReColor( Pict );
X    DeleteTask( cTask );
X    Pict->cTask = NULL;
X  }
X}
X
SHAR_EOF
echo "extracting safeaddhead.c"
sed 's/^X//' << \SHAR_EOF > safeaddhead.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 some routines to check for adding nodes to
X * lists twice, or removing nodes that are not in a list.
X */
X#include <exec/lists.h>
X#include <exec/nodes.h>
X
X#undef AddHead
X#undef Remove
X
Xextern BYTE FromWB;
X
XsafeAddHead( ListPtr, NodePtr, File, Line, Function )
X  register struct List *ListPtr;
X  register struct Node *NodePtr;
X  char *File, *Function;
X  int  Line;
X{
X  register struct Node *CurNode;
X
X  CurNode = ListPtr->lh_Head;
X
X  while ( CurNode->ln_Succ ) {
X
X    if ( CurNode == NodePtr ) {
X      if (! FromWB)
X        printf("Error adding node to list twice\n in file %s, line %d, function %s\n",
X                File, Line, Function);
X      return;
X    }
X
X    CurNode = CurNode->ln_Succ;
X  }
X  AddHead( ListPtr, NodePtr );
X}
X
XsafeRemove( NodePtr, File, Line, Function )
X  register struct Node *NodePtr;
X  char *File, *Function;
X  int  Line;
X{
X  if (NodePtr->ln_Pred == NULL && !FromWB) {
X      printf("Error Removing node when it'd not it list\n");
X      printf("In File %s Line %d Function %s\n",File,Line,Function);
X  } else {
X
X    if (NodePtr->ln_Succ == NULL && !FromWB) {
X      printf("Error Removing node when it'd not it list\n");
X      printf("In File %s Line %d Function %s\n",File,Line,Function);
X    }
X  }
X
X  Remove( NodePtr );
X
X  NodePtr->ln_Pred = NULL;
X  NodePtr->ln_Succ = NULL;
X}
X
X
X
SHAR_EOF
echo "extracting safeclose.c"
sed 's/^X//' << \SHAR_EOF > safeclose.c
X/* CloseWindowSafely()
X*       This module should be used whenever you are sharing an IDCMP
X* message port with more than one window.  Rather than calling CloseWindow(),
X* you should use CloseWindowSafely().  This will keep Intuition from
X* Guru Meditation, and thus is considered a good thing.  You should still
X* use CloseWindow for the very last window you close.
X*       The reason this is needed, is because Intuition will re-claim
X* any outstanding messages for a window when the window is closed. But...
X* it can't take them out of your message port. Thus, you will receive
X* invalid messages and bad things will happen.  Very bad things.
X*       This code is a slightly condensed version of the same routine
X* written by Neil Katin of Amiga for the April '86 Commodore Developers
X* Newsletter, Amiga Mail (tm).
X*/
X
X/*
X#include <exec/types.h>
X#include <exec/nodes.h>
X#include <exec/lists.h>
X#include <exec/ports.h>
X#include <intuition/intuition.h>
X#include <functions.h>
X*/
X#include "standard.h"
X
Xvoid CloseWindowSafely( p_wind )
X   struct Window   *p_wind;
X   {
X   register struct IntuiMessage    *msg;
X   register struct IntuiMessage    *succ;
X   register struct Window          *win = p_wind;
X   register struct MsgPort         *mp = (struct MsgPort *)win->UserPort;
X
X   Forbid();
X
X   msg = (struct IntuiMessage *)mp->mp_MsgList.lh_Head;
X
X   while ( succ=(struct IntuiMessage *)msg->ExecMessage.mn_Node.ln_Succ )
X      {
X      if ( msg->IDCMPWindow == win )
X         {
X         Remove ( msg );
X         ReplyMsg( msg );
X         }
X      msg = succ;
X      }
X   win->UserPort = NULL;
X   ModifyIDCMP( win, 0L );
X   Permit();
X   CloseWindow( win );
X   }
X
X
SHAR_EOF
echo "End of archive 8 (of 9)"
# if you want to concatenate archives, remove anything after this line
exit