home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (c) 1994 Michael D. Bayne.
- * All rights reserved.
- *
- * Please see the documentation accompanying the distribution for distribution
- * and disclaimer information.
- */
-
- #include <dos/dos.h>
- #include <devices/timer.h>
-
- #include "includes.h"
- #include "libraries.h"
- #include "protos/protos.h"
-
- __far extern LONG RangeSeed;
-
- STATIC const UBYTE VersTag[] = VERSTAG;
- LONG Blanking = FALSE, BlankAfterInit = FALSE;
- struct MsgPort *ServerPort = 0L, *TimerPort = 0L;
- struct List *BlankerEntries, *ActiveEntries;
- struct timerequest *TimeOutIO;
- struct Task *ServerTask;
- BlankerPrefs *Prefs;
-
- VOID FreeResources( VOID )
- {
- MessageModule( BM_DOQUIT );
-
- CloseBlankerWindow();
- CloseDownScreen();
-
- FreeBlankerEntries( BlankerEntries );
-
- if( TimeOutIO )
- {
- if( TimeOutIO->tr_node.io_Device )
- CloseDevice(( struct IORequest * )TimeOutIO );
- DeleteExtIO(( struct IORequest * )TimeOutIO );
- }
-
- if( TimerPort )
- DeletePort( TimerPort );
-
- if( ServerPort )
- DeletePort( ServerPort );
-
- ShutdownCX();
- CloseLibraries();
- }
-
- LONG AllocResources( VOID )
- {
- if( OpenLibraries() == 1L )
- return 1L;
-
- RangeSeed = ( LONG )( ServerTask = FindTask( 0L ));
-
- if( CheckCX() == QUIT )
- return 1L;
-
- ServerPort = CreatePort( "GarshneServer", 0 );
- TimerPort = CreatePort( 0L, 0 );
- if( !ServerPort || !TimerPort )
- return 1L;
-
- TimeOutIO = ( struct timerequest * )
- CreateExtIO( TimerPort, sizeof( struct timerequest ));
- if( !TimeOutIO )
- return 1L;
-
- if( OpenDevice( "timer.device", UNIT_VBLANK,
- ( struct IORequest * )TimeOutIO, 0L ))
- return 1L;
-
- return 0L;
- }
-
- VOID main( int argc, char *argv[] )
- {
- LONG sigs, retval;
-
- if( AllocResources() == 1L )
- {
- FreeResources();
- return;
- }
-
- Prefs = LoadDefaultPrefs();
- BlankerEntries = LoadBlankerEntries( Prefs->bp_Dir );
- if( !( Prefs->bp_Flags & BF_REPLACE ) ||
- Stricmp( Prefs->bp_Blanker, "Random" ))
- LoadModule( Prefs->bp_Dir, Prefs->bp_Blanker );
-
- if( SetupCX() == QUIT )
- {
- FreeResources();
- return;
- }
-
- if( Prefs->bp_PopUp )
- retval = openMainWindow();
-
- do
- {
- sigs = Wait( SIG_CX | SIG_SERVWIN | SIG_SERVPORT | SIG_TIMER |
- SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_D );
-
- if( sigs & SIG_SERVPORT )
- retval = HandleServerMsg();
-
- if( sigs & SIG_CX )
- retval = HandleCxMess();
-
- if( sigs & SIG_SERVWIN )
- retval = HandleBlankerIDCMP();
-
- if( sigs & SIGBREAKF_CTRL_C )
- retval = 0L;
-
- if( sigs & SIGBREAKF_CTRL_D )
- retval = HandleMouseCheck();
-
- if( sigs & SIG_TIMER )
- {
- WaitIO(( struct IORequest * )TimeOutIO );
- MessageModule( BM_UNBLANK );
- InternalBlank();
- }
-
- if( retval == CLOSEWIN )
- {
- Prefs->bp_Left = BlankerWnd->LeftEdge;
- Prefs->bp_Top = BlankerWnd->TopEdge;
- CloseBlankerWindow();
- CloseDownScreen();
- }
- }
- while( retval );
-
- FreeResources();
- }
-