home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / util / blank / gblanker / source / blankers / fade / blank.c next >
C/C++ Source or Header  |  1994-10-09  |  1KB  |  78 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.  
  11. #include <clib/exec_protos.h>
  12. #include <clib/intuition_protos.h>
  13. #include <clib/graphics_protos.h>
  14.  
  15. #include "/Garshnelib/Garshnelib_protos.h"
  16. #include "/Garshnelib/Garshnelib_pragmas.h"
  17.  
  18. #include "Fade.h"
  19. #include "/main.h"
  20. #include "//defs.h"
  21.  
  22. struct fPrefObject
  23. {
  24.     LONG Delay;
  25.     LONG Percent;
  26.     LONG TopScr;
  27. };
  28.  
  29. extern struct fPrefObject nP;
  30.  
  31. LONG Blank( VOID *Prefs )
  32. {
  33.     struct fPrefObject *fP;
  34.     struct Screen *FScr;
  35.     LONG RetVal;
  36.     
  37.     if( FadeWnd )
  38.         fP = &nP;
  39.     else
  40.         fP = ( struct fPrefObject * )Prefs;
  41.  
  42.     if( FScr = cloneTopScreen( FALSE, fP->TopScr ))
  43.     {
  44.         LONG ToFrontCount = 0, PctCount, BPG, Delay = fP->Delay + 1;
  45.         struct Window *Wnd;
  46.         ULONG *ColorTable;
  47.         
  48.         Wnd = BlankMousePointer( FScr );
  49.         ColorTable = GetColorTable( FScr );
  50.         
  51.         BPG = AvgBitsPerGun( getTopScreenMode());
  52.         PctCount = ( 1L << BPG ) * fP->Percent / 100;
  53.  
  54.         do
  55.         {
  56.             ToFrontCount++;
  57.             WaitTOF();
  58.  
  59.             if( !( ToFrontCount%Delay ) && ( ToFrontCount/Delay ) < PctCount )
  60.                 FadeAndLoadTable( FScr, BPG, ColorTable );
  61.  
  62.             if(!( ToFrontCount % 60 ))
  63.                 ScreenToFront( FScr );
  64.  
  65.             if(!( ToFrontCount % 5 ))
  66.                 RetVal = ContinueBlanking();
  67.         }
  68.         while( RetVal == OK );
  69.  
  70.         UnblankMousePointer( Wnd );
  71.         CloseScreen( FScr );
  72.     }
  73.     else
  74.         RetVal = FAILED;
  75.  
  76.     return RetVal;
  77. }
  78.