home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / util / blank / gblanker / source / blankers / rain / blank.c next >
C/C++ Source or Header  |  1994-10-08  |  2KB  |  111 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/types.h>
  10. #include <exec/memory.h>
  11.  
  12. #include <intuition/intuition.h>
  13.  
  14. #include <dos/dos.h>
  15.  
  16. #include <clib/exec_protos.h>
  17. #include <clib/intuition_protos.h>
  18. #include <clib/graphics_protos.h>
  19. #include <clib/alib_protos.h>
  20.  
  21. #include "/Garshnelib/Garshnelib_protos.h"
  22. #include "/Garshnelib/Garshnelib_pragmas.h"
  23.  
  24. #include "Rain.h"
  25. #include "//defs.h"
  26. #include "/main.h"
  27.  
  28. struct ModulePrefs
  29. {
  30.     LONG Mode;
  31.     LONG Depth;
  32.     LONG Drops;
  33. };
  34.  
  35. extern struct ModulePrefs nP;
  36.  
  37. #ifndef max
  38. #define max( x, y ) ( x > y ? x : y )
  39. #endif
  40.  
  41. LONG Blank( VOID *Prefs )
  42. {
  43.     LONG ToFrontCount = 0, Wid, Hei, Drops, x, y, r, i, incr, RetVal = OK;
  44.     struct ModulePrefs *mP;
  45.     struct RastPort *Rast;
  46.     struct Screen *Scr;
  47.     struct Window *Wnd;
  48.     
  49.     if( RainWnd )
  50.         mP = &nP;
  51.     else
  52.         mP = ( struct ModulePrefs * )Prefs;
  53.     
  54.     Drops = mP->Drops;
  55.     
  56.     Scr = OpenScreenTags( 0L, SA_Depth, mP->Depth, SA_Overscan, OSCAN_STANDARD, SA_DisplayID,
  57.                          mP->Mode, SA_Quiet, TRUE, SA_Behind, TRUE, TAG_DONE );
  58.     
  59.     if( Scr )
  60.     {
  61.         Wid = Scr->Width;
  62.         Hei = Scr->Height;
  63.         
  64.         Rast = &( Scr->RastPort );
  65.         SetRast( Rast, 0 );
  66.         
  67.         for( i = 0; i < 4; i++ )
  68.             SetRGB4(&( Scr->ViewPort ), i, 4 * i, 4 * i, 4 * i );
  69.         
  70.         Wnd = BlankMousePointer( Scr );
  71.         ScreenToFront( Scr );
  72.         
  73.         while( RetVal == OK )
  74.         {
  75.             if(!( ++ToFrontCount % 60 ))
  76.                 ScreenToFront( Scr );
  77.             
  78.             if(!( ToFrontCount % Drops ))
  79.                 SetRast(&( Scr->RastPort ), 0 );
  80.             
  81.             r = RangeRand( Wid/13 ) + Wid/25;
  82.             x = RangeRand( Wid - 2*r ) + r;
  83.             y = RangeRand( Hei - 2*r ) + r;
  84.             
  85.             incr = max( Wid/160, 1 );
  86.  
  87.             for( i = 0; i < r; i += incr )
  88.             {
  89.                 WaitTOF();
  90.                 SetAPen(&( Scr->RastPort ), ( ULONG )RangeRand(( 1L << mP->Depth ) - 1 ) + 1 );
  91.                 DrawEllipse(&( Scr->RastPort ), x, y, i, i );
  92.                 if( i )
  93.                 {
  94.                     SetAPen(&( Scr->RastPort ), 0 );
  95.                     DrawEllipse(&( Scr->RastPort ), x, y, i - incr, i - incr );
  96.                 }
  97.             }
  98.             
  99.             RetVal = ContinueBlanking();
  100.         }
  101.         UnblankMousePointer( Wnd );
  102.     }
  103.     else
  104.         RetVal = FAILED;
  105.     
  106.     if( Scr )
  107.         CloseScreen( Scr );
  108.     
  109.     return RetVal;
  110. }
  111.