home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / util / blank / gblanker / source / blankers / dragon / blank.c next >
C/C++ Source or Header  |  1994-10-08  |  2KB  |  110 lines

  1. /*
  2.  *  Copyright (c) 1994 Michael D. Bayne.
  3.  *  All rights reserved.
  4.  *
  5.  *  Please see the documentation accompanying the distribution for distribution
  6.  *  and disclaimer information.
  7.  */
  8.  
  9. #include <exec/memory.h>
  10. #include <dos/dos.h>
  11.  
  12. #include <clib/exec_protos.h>
  13. #include <clib/intuition_protos.h>
  14. #include <clib/graphics_protos.h>
  15. #include <clib/alib_protos.h>
  16.  
  17. #include "/Garshnelib/Garshnelib_protos.h"
  18. #include "/Garshnelib/Garshnelib_pragmas.h"
  19.  
  20. #include <math.h>
  21.  
  22. #include "Dragon.h"
  23. #include "//defs.h"
  24. #include "/main.h"
  25.  
  26. struct ModulePrefs
  27. {
  28.     LONG Mode;
  29.     LONG Depth;
  30. };
  31.  
  32. extern struct ModulePrefs nP;
  33. Triplet *ColorTable = 0L;
  34.  
  35. LONG Dragon( struct Screen *Scr, SHORT Wid, SHORT Hei )
  36. {
  37.     LONG i, flg_end = OK, xd, yd, mod = 1L << Scr->BitMap.Depth - 1, sx, sy;
  38.     float t = ( float )( RangeRand( 100 ) + 10 ), a = PI - t / 5000;
  39.     float xx, yy, x = 0, y = 0;
  40.     struct RastPort *RP = &( Scr->RastPort );
  41.     
  42.     SetRast( RP, 0 );
  43.     ScreenToFront( Scr );
  44.     
  45.     for( i = 0; i < 1000000 && flg_end == OK; i++ )
  46.     {
  47.         if(!( i % 100 ))
  48.         {
  49.             flg_end = ContinueBlanking();
  50.             ScreenToFront( Scr );
  51.         }
  52.         
  53.         xx = y - sin( x );
  54.         yy = a - x;
  55.         
  56.         xd = Wid / 2 + (SHORT)( 2.0 * x );
  57.         yd = Hei / 2 + (SHORT)( 2.0 * y );
  58.  
  59.         sx = xd - Wid/2;
  60.         sx *= sx;
  61.         sy = yd - Hei/2;
  62.         sy *= sy;
  63.  
  64.         if(( xd >= 0 )&&( yd >= 0 )&&( xd < Wid )&&( yd < Hei ))
  65.         {
  66.             SetAPen( RP, (((sx + sy)*2*mod)/(Hei*Hei)) % mod + 1 );
  67.             WritePixel( RP, xd, yd );
  68.         }
  69.  
  70.         x = xx;
  71.         y = yy;
  72.     }
  73.  
  74.     return flg_end;
  75. }
  76.  
  77. LONG Blank( VOID *Prefs )
  78. {
  79.     struct Screen *Scr;
  80.     struct Window *Wnd;
  81.     struct ModulePrefs *mP;
  82.     LONG RetVal;
  83.     
  84.     if( DragonWnd )
  85.         mP = &nP;
  86.     else
  87.         mP = ( struct ModulePrefs * )Prefs;
  88.     
  89.     if( Scr = OpenScreenTags( NULL, SA_Depth, mP->Depth, SA_Quiet, TRUE,
  90.                              SA_DisplayID, mP->Mode, SA_Behind, TRUE,
  91.                              SA_Overscan, OSCAN_STANDARD, TAG_DONE ))
  92.     {
  93.         SetRGB4(&( Scr->ViewPort ), 0, 0, 0, 0 );
  94.         ColorTable = RainbowPalette( Scr, 0L, 1L, 0L );
  95.         Wnd = BlankMousePointer( Scr );
  96.         
  97.         do
  98.             RetVal = Dragon( Scr, Scr->Width, Scr->Height );
  99.         while( RetVal == OK );
  100.         
  101.         UnblankMousePointer( Wnd );
  102.         RainbowPalette( 0L, ColorTable, 1L, 0L );
  103.         CloseScreen( Scr );
  104.     }
  105.     else
  106.         RetVal = FAILED;
  107.     
  108.     return RetVal;
  109. }
  110.