home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / source / gblanker3.5.src.lha / GSource / Blankers / Garshnelib / utility.c < prev   
Encoding:
C/C++ Source or Header  |  1994-10-01  |  15.4 KB  |  598 lines

  1. /*
  2.  *  Copyright (c) 1993 Michael D. Bayne.
  3.  *  All rights reserved.
  4.  *
  5.  *  Please see the documentation accompanying the distribution for
  6.  *  distribution and disclaimer information.
  7.  */
  8.  
  9. #define V39 ( ExecBase->LibNode.lib_Version > 38 )
  10.  
  11. #ifdef SCRMODEREQ
  12. #include <libraries/reqtools.h>
  13. #include <clib/reqtools_protos.h>
  14. #include <pragmas/reqtools_pragmas.h>
  15. #include <libraries/asl.h>
  16. #include <clib/asl_protos.h>
  17. #include <pragmas/asl_pragmas.h>
  18.  
  19. VOID ScreenModeRequest( struct Window *Wnd, LONG *Mode, LONG *Depth )
  20. {
  21.     struct AslBase *AslBase;
  22.     
  23.     if( AslBase = ( struct AslBase * )OpenLibrary( AslName, 38L ))
  24.     {
  25.         struct ScreenModeRequester *smRequest;
  26.         
  27.         if( smRequest = AllocAslRequestTags( ASL_ScreenModeRequest, TAG_END ))
  28.         {
  29.             if( Depth )
  30.             {
  31.                 if( AslRequestTags( smRequest, ASLSM_Window, Wnd,
  32.                                    ASLSM_SleepWindow, TRUE,
  33.                                    ASLSM_TitleText, "Screen Mode",
  34.                                    ASLSM_InitialDisplayID, *Mode,
  35.                                    ASLSM_InitialDisplayDepth, *Depth,
  36.                                    ASLSM_DoDepth, TRUE, TAG_END ))
  37.                 {
  38.                     *Mode = smRequest->sm_DisplayID;
  39.                     *Depth = smRequest->sm_DisplayDepth;
  40.                 }
  41.             }
  42.             else
  43.             {
  44.                 if( AslRequestTags( smRequest, ASLSM_Window, Wnd,
  45.                                    ASLSM_SleepWindow, TRUE,
  46.                                    ASLSM_TitleText, "Screen Mode",
  47.                                    ASLSM_InitialDisplayID, *Mode, TAG_END ))
  48.                     *Mode = smRequest->sm_DisplayID;
  49.             }
  50.             FreeAslRequest( smRequest );
  51.         }
  52.         CloseLibrary(( struct Library * )AslBase );
  53.     }
  54.     else
  55.     {
  56.         struct ReqToolsBase *ReqToolsBase;
  57.  
  58.         if( ReqToolsBase = ( struct ReqToolsBase * )
  59.            OpenLibrary( REQTOOLSNAME, REQTOOLSVERSION ))
  60.         {
  61.             struct rtScreenModeRequester *smRequest;
  62.             
  63.             if( smRequest = rtAllocRequestA( RT_SCREENMODEREQ, 0l ))
  64.             {
  65.                 if( Depth )
  66.                 {
  67.                     LONG Tags[] = { RT_Window, 0L, RT_LockWindow, TRUE,
  68.                                         RTSC_Flags, SCREQF_DEPTHGAD, TAG_END };
  69.                     LONG ReqTags[] = { RTSC_DisplayID, 0L,
  70.                                            RTSC_DisplayDepth, 0L, TAG_END };
  71.                     ReqTags[1] = *Mode;
  72.                     ReqTags[3] = *Depth;
  73.                     rtChangeReqAttrA( smRequest, ( struct TagItem * )ReqTags );
  74.                     
  75.                     Tags[1] = ( LONG )Wnd;
  76.                     if( rtScreenModeRequestA( smRequest, "Screen Mode",
  77.                                              ( struct TagItem * )Tags ))
  78.                     {
  79.                         *Mode = smRequest->DisplayID;
  80.                         *Depth = smRequest->DisplayDepth;
  81.                     }
  82.                 }
  83.                 else
  84.                 {
  85.                     LONG Tags[] = { RT_Window, 0L, RT_LockWindow, TRUE,
  86.                                         TAG_END };
  87.                     LONG ReqTags[] = { RTSC_DisplayID, 0L, TAG_END };
  88.                     
  89.                     ReqTags[1] = *Mode;
  90.                     rtChangeReqAttrA( smRequest, ( struct TagItem * )ReqTags );
  91.                     
  92.                     Tags[1] = ( LONG )Wnd;
  93.                     if( rtScreenModeRequestA( smRequest, "Screen Mode",
  94.                                              ( struct TagItem * )Tags ))
  95.                         *Mode = smRequest->DisplayID;
  96.                 }
  97.                 rtFreeRequest( smRequest );
  98.             }
  99.             CloseLibrary(( struct Library * )ReqToolsBase );
  100.         }
  101.     }
  102. }
  103. #endif
  104.  
  105. #ifdef COPPERLIST
  106. #include <graphics/gfxbase.h>
  107. #include <graphics/gfxmacros.h>
  108. #include <graphics/copper.h>
  109. #include <graphics/videocontrol.h>
  110. #include <hardware/custom.h>
  111.  
  112. __far extern struct Custom custom;
  113. extern struct GfxBase *GfxBase;
  114.  
  115. VOID setCopperList( LONG height, LONG color, struct ViewPort *vp )
  116. {
  117. #define NUMCOLORS 45
  118.     
  119.     struct UCopList *uCopList;
  120.     struct TagItem uCopTags[] = {{ VTAG_USERCLIP_SET, 0L },
  121.                                  { VTAG_END_CM, 0L }};
  122.     register LONG i, index = RangeRand( NUMCOLORS ), spc;
  123.     LONG spectrum[] = {
  124.         0x0F00, 0x0E10, 0x0D20, 0x0C30, 0x0B40, 0x0A50, 0x0960,    0x0870, 0x0780,
  125.         0x0690, 0x05A0, 0x04B0, 0x03C0, 0x02D0,    0x01E0, 0x00F0, 0x00E1, 0x00D2,
  126.         0x00C3, 0x00B4, 0x00A5,    0x0096, 0x0087, 0x0078, 0x0069, 0x005A, 0x004B,
  127.         0x003C,    0x002D, 0x001E, 0x000F, 0x010E, 0x020D, 0x030C, 0x040B,    0x050A,
  128.         0x0609, 0x0708, 0x0807, 0x0906, 0x0A05, 0x0B04,    0x0C03, 0x0D02, 0x0E01
  129.         };
  130.     
  131.     if( uCopList = ( struct UCopList * )AllocMem( sizeof( struct UCopList ),
  132.                                                  MEMF_PUBLIC|MEMF_CLEAR )) {
  133.         spc = height/NUMCOLORS;
  134.         CINIT( uCopList, NUMCOLORS );
  135.         for( i = 0; i < NUMCOLORS; ++i ) {
  136.             CWAIT( uCopList, i * spc, 0 );
  137.             CMOVE( uCopList, custom.color[color],
  138.                   spectrum[( i + index ) % NUMCOLORS] );
  139.         }
  140.         
  141.         CEND( uCopList );
  142.         
  143.         Forbid();
  144.         vp->UCopIns = uCopList;
  145.         Permit();
  146.         
  147.         VideoControl( vp->ColorMap, uCopTags );
  148.         RethinkDisplay();
  149.     }
  150. }
  151. #endif
  152.  
  153. #ifdef CLONETOPSCREEN
  154. #define GETTOPSCREENMODE
  155. #define GETTOPSCREENDEPTH
  156. #endif
  157.  
  158. #ifdef GETTOPSCREENMODE
  159. #include <clib/graphics_protos.h>
  160. #include <intuition/intuitionbase.h>
  161. extern struct IntuitionBase *IntuitionBase;
  162. ULONG getTopScreenMode( void )
  163. {
  164.     BPTR lock;
  165.     struct Screen *pubScr;
  166.     ULONG scrMode;
  167.     
  168.     lock = LockIBase( 0 );
  169.     pubScr = IntuitionBase->FirstScreen;
  170.     scrMode = GetVPModeID(&( pubScr->ViewPort));
  171.     UnlockIBase( lock );
  172.     return( scrMode );
  173. }
  174. #endif
  175.  
  176. #ifdef GETTOPSCREENDEPTH
  177. #include <clib/graphics_protos.h>
  178. #include <intuition/intuitionbase.h>
  179. extern struct IntuitionBase *IntuitionBase;
  180. ULONG getTopScreenDepth( void )
  181. {
  182.     BPTR lock;
  183.     struct Screen *pubScr;
  184.     struct DrawInfo *dri;
  185.     ULONG sDep = 0;
  186.     
  187.     lock = LockIBase( 0 );
  188.     pubScr = IntuitionBase->FirstScreen;
  189.     if( dri = GetScreenDrawInfo( pubScr )) {
  190.         sDep = dri->dri_Depth;
  191.         FreeScreenDrawInfo( pubScr, dri );
  192.     }
  193.     UnlockIBase( lock );
  194.     return( sDep );
  195. }
  196. #endif
  197.  
  198. #ifdef CLONETOPSCREEN
  199. #include <exec/execbase.h>
  200. #define ExecBase (*(( struct ExecBase ** )4L ))
  201.  
  202. #ifndef min
  203. #define min( x, y ) ( (x) < (y) ? (x) : (y) )
  204. #endif
  205.  
  206. struct Screen *cloneTopScreen( LONG MoreColors, LONG GetPublic )
  207. {
  208.     LONG sMod, sDep, i, Wid, Hei, offx, offy;
  209.     struct Screen *Scr, *nScr = 0L;
  210.     struct Rectangle DispRect;
  211.     struct DrawInfo *dri;
  212.     UWORD *cols;
  213.     BPTR lock;
  214.     
  215.     /* Lock IntuitionBase so nothing goes away while we're playing with it */
  216.     lock = LockIBase( 0 );
  217.     
  218.     /* Grab the first screen and get its attributes */
  219.     if( GetPublic )
  220.         Scr = LockPubScreen( 0L );
  221.     else
  222.         Scr = IntuitionBase->FirstScreen;
  223.     sMod = GetVPModeID(&( Scr->ViewPort )); /* Screen Mode ID */
  224.     offx = Scr->LeftEdge; 
  225.     offy = Scr->TopEdge;
  226.     Wid = Scr->Width;
  227.     Hei = Scr->Height;
  228.     if( dri = GetScreenDrawInfo( Scr ))
  229.         sDep = MoreColors ? dri->dri_Depth + 1 : dri->dri_Depth;
  230.     if( cols = AllocMem( sizeof( WORD ) * ( 1L << sDep ), MEMF_CLEAR ))
  231.         for( i = 0; i < ( 1L << dri->dri_Depth ); ++i )
  232.             cols[i] = GetRGB4( Scr->ViewPort.ColorMap, i );
  233.     
  234.     if( GetPublic )
  235.         UnlockPubScreen( 0L, Scr );
  236.  
  237.     UnlockIBase( lock );
  238.     
  239.     QueryOverscan( sMod, &DispRect, OSCAN_TEXT );
  240.  
  241.     Wid = min( Wid, DispRect.MaxX - DispRect.MinX + 1 );
  242.     Hei = min( Hei, DispRect.MaxY - DispRect.MinY + 1 );
  243.     
  244.     if( sMod != INVALID_ID )
  245.     {
  246.         nScr = OpenScreenTags( NULL, SA_DisplayID, sMod, SA_Depth, sDep,
  247.                               SA_Width, Wid, SA_Height, Hei, SA_Behind, TRUE,
  248.                               SA_Quiet, TRUE, TAG_DONE );
  249.         if( nScr )
  250.         {
  251.             BltBitMap( Scr->RastPort.BitMap, offx < 0 ? -offx : 0,
  252.                       offy < 0 ? -offy : 0, nScr->RastPort.BitMap, 0, 0,
  253.                       Wid, Hei, 0x00C0, 0x00FF, NULL );
  254.             LoadRGB4( &(nScr->ViewPort), cols, 1L << sDep );
  255.             if( offx > 0 )
  256.                 MoveScreen( nScr, offx, 0 );
  257.             WaitBlit();
  258.             ScreenToFront( nScr );
  259.         }
  260.     }
  261.  
  262.     if( cols )
  263.         FreeMem( cols, ( 1L << sDep ) * sizeof( UWORD ));
  264.  
  265.     if( dri )
  266.         FreeScreenDrawInfo( Scr, dri );
  267.  
  268.     return nScr;
  269. }
  270. #endif
  271.  
  272. #ifdef FADESCREEN
  273.  
  274. #include <exec/memory.h>
  275. #include <graphics/displayinfo.h>
  276.  
  277. LONG fadeScreen39( struct Screen *Screen, LONG Del, LONG ModeID, LONG Pct )
  278. {
  279.     LONG NumCols = ( 1L << Screen->RastPort.BitMap->Depth ), RetVal = OK;
  280.     struct DisplayInfo *Inf;
  281.     ULONG *ColorTable;
  282.  
  283.     ColorTable = AllocVec( sizeof( LONG ) * ( 3 * NumCols + 2 ), MEMF_CLEAR );
  284.     Inf = AllocVec( sizeof( struct DisplayInfo ), MEMF_CLEAR );
  285.     
  286.     if( ColorTable && Inf )
  287.     {
  288.         LONG i, n, Iters, MaxCols, BPG = 8;
  289.         BPTR Dbg = Open( "RAM:Dbg.out", MODE_NEWFILE );
  290.         
  291.         if( GetDisplayInfoData( 0L, (UBYTE *)Inf, sizeof( struct DisplayInfo ),
  292.                                DTAG_DISP, ModeID ))
  293.             BPG = ( Inf->RedBits + Inf->GreenBits + Inf->BlueBits ) / 3;
  294.         
  295.         MaxCols = 1L << BPG;
  296.         
  297.         GetRGB32( Screen->ViewPort.ColorMap, 0, NumCols, ColorTable + 1 );
  298.         ColorTable[0] = ( NumCols << 16L );
  299.     
  300.         Iters = Pct * MaxCols / 100;
  301.         
  302.         for( n = 0; n < Iters && RetVal == OK; ++n )
  303.         {
  304.             for( i = 0; i < 3 * NumCols; ++i )
  305.             {
  306.                 if( ColorTable[i+1] > 1L << ( 32 - BPG ))
  307.                     ColorTable[i+1] -= ( 1L << ( 32 - BPG ));
  308.                 else
  309.                     ColorTable[i+1] = 0;
  310.             }
  311.             
  312.             LoadRGB32(&( Screen->ViewPort ), ColorTable );
  313.             
  314.             for( i = 0; i < Del && RetVal == OK; ++i )
  315.             {
  316.                 WaitTOF();
  317.                 if(!( i % 5 ))
  318.                     RetVal = ContinueBlanking();
  319.             }
  320.         }
  321.  
  322.         Close( Dbg );
  323.     }
  324.     else
  325.         RetVal = FAILED;
  326.  
  327.     if( ColorTable )
  328.         FreeVec( ColorTable );
  329.  
  330.     if( Inf )
  331.         FreeVec( Inf );
  332.  
  333.     return RetVal;
  334. }
  335.  
  336. LONG fadeScreen( struct Screen *Screen, ULONG delay, ULONG ModeID, ULONG Pct )
  337. {
  338.     LONG NumCols = ( 1L << Screen->RastPort.BitMap->Depth );
  339.     LONG col, i, n, rv = OK;
  340.     
  341.     if( V39 )
  342.         return fadeScreen39( Screen, delay, ModeID, Pct );
  343.         
  344.     for( n = 0; n < Pct * 16 / 100 && rv == OK; n++ )
  345.     {
  346.         for( i = 0; i < NumCols; ++i )
  347.         {
  348.             col = GetRGB4( Screen->ViewPort.ColorMap, i );
  349.             SetRGB4(&( Screen->ViewPort ), i,
  350.                     (( col & 0x0F00 ) >> 8 ) > 0 ?
  351.                     (( col & 0x0F00 ) >> 8 ) - 1 : 0,
  352.                     (( col & 0x00F0 ) >> 4 ) > 0 ?
  353.                     (( col & 0x00F0 ) >> 4 ) - 1 : 0,
  354.                     ( col & 0x000F ) > 0 ? ( col & 0x000F ) - 1 : 0 );
  355.         }
  356.  
  357.         for( i = 0; i < delay && rv == OK; i++ )
  358.         {
  359.             WaitTOF();
  360.             if(!( i % 5 ))
  361.                 rv = ContinueBlanking();
  362.         }
  363.     }
  364.  
  365.     return rv;
  366. }
  367. #endif
  368.  
  369. #ifdef BLANKMOUSE
  370. struct Window *BlankWnd;
  371. UWORD *BlankPtr;
  372.  
  373. VOID BlankMousePointer( struct Screen *Scr )
  374. {
  375.     ULONG   oldmodes;
  376.     
  377.     Forbid();
  378.     oldmodes = SetPubScreenModes( 0 );
  379.     if( BlankPtr = AllocVec( 3*2*sizeof( UWORD ) ,
  380.                             MEMF_CHIP|MEMF_PUBLIC|MEMF_CLEAR )) {
  381.         if( BlankWnd = OpenWindowTags( 0L, WA_Activate, TRUE, WA_Left, 0,
  382.                                       WA_Top, 0, WA_Width, 1, WA_Height, 1,
  383.                                       WA_Borderless, TRUE, WA_CustomScreen,
  384.                                       Scr, TAG_END )) {
  385.             /* Set a pointer sprite of size 16*1 (alloc and clear data for
  386.                sprite def which is 2 control words, 2 words 4-color data for
  387.                each line and 2 empty words at the end (as suggested in
  388.                Hardware Ref. Manual)).
  389.                */
  390.             SetPointer( BlankWnd, BlankPtr, 1, 16, 0, 0 );
  391.         }
  392.     }
  393.     SetPubScreenModes( oldmodes );
  394.     Permit();
  395. }
  396.  
  397. VOID UnblankMousePointer( VOID )
  398. {
  399.     if( BlankWnd )
  400.         CloseWindow( BlankWnd );
  401.     if( BlankPtr )
  402.         FreeVec( BlankPtr );
  403. }
  404. #endif
  405.  
  406. #ifdef RAINBOWPALETTE
  407. #include <math.h>
  408. #include <exec/execbase.h>
  409. #ifndef ExecBase
  410. #define ExecBase (*(( struct ExecBase ** )4L ))
  411. #endif
  412.  
  413. struct ColorStruct {
  414.     ULONG Red;
  415.     ULONG Green;
  416.     ULONG Blue;
  417. };
  418.  
  419. #define CastAndShift( x ) ((( int )( x * Colors )) << Shift )
  420.  
  421. struct ColorStruct *NewColorTable( LONG Colors, LONG Dep, LONG Offset )
  422. {
  423.     struct ColorStruct *Table;
  424.     float incr = 360.0 / Colors;
  425.     float p2, p3, f, h;
  426.     LONG i, Shift;
  427.     USHORT ih;
  428.  
  429.     Table = AllocVec( 2 * ( Colors + Offset ) * sizeof( struct ColorStruct ), MEMF_CLEAR );
  430.  
  431.     if( Table )
  432.     {
  433.         Shift = 32 - Dep;
  434.         for( i = Offset, h = 0.0; i < Colors + Offset; i++, h += incr )
  435.         {
  436.             ih = ( USHORT )( h / 60.0 );
  437.             f = h / 60.0 - ih;
  438.             p2 = 1 - f;
  439.             p3 = f;
  440.             switch( ih )
  441.             {
  442.             case 0:
  443.                 Table[i].Red = Colors << Shift;
  444.                 Table[i].Green = CastAndShift( p3 );
  445.                 Table[i].Blue = 0;
  446.                 break;
  447.             case 1:
  448.                 Table[i].Red = CastAndShift( p2 );
  449.                 Table[i].Green = Colors << Shift;
  450.                 Table[i].Blue = 0;
  451.                 break;
  452.             case 2:
  453.                 Table[i].Red = 0;
  454.                 Table[i].Green = Colors << Shift;
  455.                 Table[i].Blue = CastAndShift( p3 );
  456.                 break;
  457.             case 3:
  458.                 Table[i].Red = 0;
  459.                 Table[i].Green = CastAndShift( p2 );
  460.                 Table[i].Blue = Colors << Shift;
  461.                 break;
  462.             case 4:
  463.                 Table[i].Red = CastAndShift( p3 );
  464.                 Table[i].Green = 0;
  465.                 Table[i].Blue = Colors << Shift;
  466.                 break;
  467.             case 5:
  468.                 Table[i].Red = Colors << Shift;
  469.                 Table[i].Green = 0;
  470.                 Table[i].Blue = CastAndShift( p2 );
  471.                 break;
  472.             }
  473.         }
  474.  
  475.         CopyMem(&( Table[Offset] ), &( Table[Colors+Offset] ),
  476.                 Colors * sizeof( struct ColorStruct ));
  477.         
  478.         return Table;
  479.     }
  480.  
  481.     return 0L;
  482. }
  483.  
  484. VOID agaInit( struct Screen *Screen, LONG Offset, LONG ExtendPal )
  485. {
  486.     static struct ColorStruct *Table = NULL;
  487.     LONG Colors, PDep, PColors, Temp1, Temp2, Dep;
  488.     static LONG ColorPos = 0;
  489.     
  490.     if( Screen )
  491.     {
  492.         Dep = Screen->BitMap.Depth;
  493.         PDep = ( Dep < ( 9 - ExtendPal )) ? Dep + ExtendPal : 8;
  494.         Colors = ( 1L << Dep ) - Offset;
  495.         PColors = ( 1L << PDep ) - Offset;
  496.         if( !Table )
  497.         {
  498.             Table = NewColorTable( PColors, PDep, Offset );
  499.             if( Offset )
  500.                 SetRGB32(&(Screen->ViewPort), 0, 0, 0, 0 );
  501.         }
  502.         
  503.         ColorPos = ( ++ColorPos % PColors );
  504.         
  505.         if( Table )
  506.         {
  507.             Temp1 = Table[ColorPos].Blue;
  508.             Temp2 = Table[ColorPos+Colors+1].Red;
  509.             
  510.             Table[ColorPos].Blue = ( Colors << 16L ) + Offset;
  511.             Table[ColorPos+Colors+1].Red = 0;
  512.             
  513.             LoadRGB32(&(Screen->ViewPort), &( Table[ColorPos].Blue ));
  514.             
  515.             Table[ColorPos].Blue = Temp1;
  516.             Table[ColorPos+Colors+1].Red = Temp2;
  517.         }
  518.     }
  519.     else
  520.     {
  521.         if( Table )
  522.         {
  523.             FreeVec( Table );
  524.             Table = NULL;
  525.         }
  526.     }
  527. }
  528.  
  529. VOID ecsInit( struct Screen *Screen )
  530. {
  531.     UWORD Table6[] = { 0, 0x0F20, 0x0E30, 0x0C50, 0x0B60, 0x0980, 0x0890,
  532.                            0x06B0, 0x05C0, 0x03E0, 0x02F0, 0x00F2, 0x00E3,
  533.                            0x00C5, 0x00B6, 0x0098, 0x006B, 0x005C, 0x003E,
  534.                            0x002F, 0x020F, 0x030E, 0x050C, 0x060B, 0x0809,
  535.                            0x0908, 0x0B06, 0x0C05, 0x0E03, 0x0F02, 0x0F00,
  536.                            0x0F00, 0x0F00, 0x0F20, 0x0E30, 0x0C50, 0x0B60,
  537.                            0x0980, 0x0890, 0x06B0, 0x05C0, 0x03E0, 0x02F0,
  538.                            0x00F2, 0x00E3, 0x00C5, 0x00B6, 0x0098, 0x006B,
  539.                            0x005C, 0x003E, 0x002F, 0x020F, 0x030E, 0x050C,
  540.                            0x060B, 0x0809, 0x0908, 0x0B06, 0x0C05, 0x0E03,
  541.                            0x0F02, 0x0F00, 0x0F20, 0x0E30, 0x0C50, 0x0B60,
  542.                            0x0980, 0x0890, 0x06B0, 0x05C0, 0x03E0, 0x02F0,
  543.                            0x00F2, 0x00E3, 0x00C5, 0x00B6, 0x0098, 0x006B,
  544.                            0x005C, 0x003E, 0x002F, 0x020F, 0x030E, 0x050C,
  545.                            0x060B, 0x0809, 0x0908, 0x0B06, 0x0C05, 0x0E03,
  546.                            0x0F02, 0x0F00, 0x0F00, 0x0F00, 0x0F20, 0x0E30,
  547.                            0x0C50, 0x0B60, 0x0980, 0x0890, 0x06B0, 0x05C0,
  548.                            0x03E0, 0x02F0, 0x00F2, 0x00E3, 0x00C5, 0x00B6,
  549.                            0x0098, 0x006B, 0x005C, 0x003E, 0x002F, 0x020F,
  550.                            0x030E, 0x050C, 0x060B, 0x0809, 0x0908, 0x0B06,
  551.                            0x0C05, 0x0E03, 0x0F02, 0x0F00 };
  552.     UWORD Table5[] = { 0, 0x0F20, 0x0E30, 0x0C50, 0x0B60, 0x0980, 0x0890,
  553.                            0x06B0, 0x05C0, 0x03E0, 0x02F0, 0x00F2, 0x00E3,
  554.                            0x00C5, 0x00B6, 0x0098, 0x006B, 0x005C, 0x003E,
  555.                            0x002F, 0x020F, 0x030E, 0x050C, 0x060B, 0x0809,
  556.                            0x0908, 0x0B06, 0x0C05, 0x0E03, 0x0F02, 0x0F00,
  557.                            0x0F00, 0x0F20, 0x0E30, 0x0C50, 0x0B60, 0x0980,
  558.                            0x0890, 0x06B0, 0x05C0, 0x03E0, 0x02F0, 0x00F2,
  559.                            0x00E3, 0x00C5, 0x00B6, 0x0098, 0x006B, 0x005C,
  560.                            0x003E, 0x002F, 0x020F, 0x030E, 0x050C, 0x060B,
  561.                            0x0809, 0x0908, 0x0B06, 0x0C05, 0x0E03, 0x0F02,
  562.                            0x0F00, 0x0F00 };
  563.     UWORD Table4[] = { 0, 0x0E03, 0x0B06, 0x0909, 0x060B, 0x030E, 0x003E,
  564.                            0x006B, 0x0099, 0x00B6, 0x00E3, 0x03E0, 0x06B0,
  565.                            0x0990, 0x0B60, 0x0E30, 0x0E03, 0x0B06, 0x0909,
  566.                            0x060B, 0x030E, 0x003E, 0x006B, 0x0099, 0x00B6,
  567.                            0x00E3, 0x03E0, 0x06B0, 0x0990, 0x0B60, 0x0E30 };
  568.     UWORD Table3[] = { 0, 0x0E00, 0x0770, 0x00E0, 0x0077, 0x000E, 0x0707,
  569.                            0x0707, 0x0E00, 0x0770, 0x00E0, 0x0077, 0x000E,
  570.                            0x0707, 0x0707 };
  571.     UWORD Table2[] = { 0, 0x0E00, 0x00E0, 0x000E, 0x0E00, 0x00E0, 0x000E };
  572.     UWORD Table1[] = { 0, 0x0FFF };
  573.     UWORD *Table[6], *Cols, Tmp;
  574.     LONG Colors[] = { 2, 4, 8, 16, 32, 64 };
  575.     static LONG i = 0;
  576.     
  577.     Table[0] = Table1; Table[1] = Table2; Table[2] = Table3; Table[3] = Table4;
  578.     Table[4] = Table5; Table[5] = Table6;
  579.     
  580.     if( Screen ) {
  581.         Cols = &( Table[Screen->BitMap.Depth-1][i] );
  582.         Tmp = Cols[0];
  583.         Cols[0] = 0;
  584.         LoadRGB4(&( Screen->ViewPort ), Cols, Colors[Screen->BitMap.Depth-1] );
  585.         Cols[0] = Tmp;
  586.         i = ++i%( Colors[Screen->BitMap.Depth-1] );
  587.     }
  588. }
  589.  
  590. VOID RainbowPalette( struct Screen *Screen, LONG Offset, LONG ExtendPal )
  591. {
  592.     if( ExecBase->LibNode.lib_Version < 39 )
  593.         ecsInit( Screen );
  594.     else
  595.         agaInit( Screen, Offset, ExtendPal );
  596. }
  597. #endif
  598.