' In its JUMPDISK appearance, this file is crunched. To decrunch it,
' see the DECRUNCH item on the ARTICLES MENU. This Basic source is made
' available to users who want to work with it. It is an element of the
' JumpBlanker progam in this same window. JumpBlanker is compiled by
' HiSoft Basic and does not require AmigaBASIC.
' -------------------------------------------------------------------------

'**** The "GOTO" line lets you put your graphic routine at the start
'**** of the program listing for ease of customizing.

GOTO ThePartAfterMyGraphicProgram

'************************************************************
'********************************* Put your program from here

MyGraphicProgram:                      '**** Essential name
  SCREEN 2,320,200,4,1                 '**** Open your screen
  WINDOW 2,,(0,0)-(311,185),0,2        '**** Open your window
  
  NoThingIsHappening=True              '**** Essential line #1
  WHILE NoThingIsHappening=True        '**** Essential line #2
   
    PSET(RND*320,RND*200),RND*15.5     '**** Do your thang here
     
  WEND                                 '**** Essential line #3
   
  SCREEN CLOSE 2                       '**** Close your screen
  
RETURN                                 '**** Reset to sleeping mode

'to here *****************************************************
'*************************************************************

ThePartAfterMyGraphicProgram:

  WINDOW 1," ** MyBlanker **    ",(20,20)-(200,40),16+2+8,-1
  Keys&=12577793&'   HEX = BFEC01  *** AmigaBasic doesn't accept
  Mice&=14675978&'   HEX = DFF00A  *** big HEX numbers. Go figure.
  Often=2        '**** How many seconds of dormancy between PEEKs
  Waiting=5      '**** Length of time before your program is activated

   '**** You might want to set the "Waiting" before the blanker is    '****
   '**** activated by reading the number of seconds from a diskfile   '****
   '**** created and saved with a text editting program then removing '****
   '**** the "REM"s from the following three lines.                   '****

REM OPEN "MBdelay" FOR INPUT AS (1)
REM   INPUT #1,Waiting
REM CLOSE #1

  True=1
  False=0
  COLOR 1,3:CLS
  GOSUB TurnWaitingTimerOn
  GOSUB ReadEm  

'************************************************************************
'************************** HEART OF PROGRAM ****************************
'**** The "SLEEP" command allows Basic to use as little of the Amiga's
'**** time as possible, so other programs can run at near normal speed.

MainLoop:
  WHILE True = 1: SLEEP: WEND

'*********************** END OF HEART OF PROGRAM ************************
'************************************************************************

   '**** Check for activity since last we PEEKed at keys and mice ****
CheckMouseAndKeys:
  IF PEEK(Keys&)=K1& AND PEEKL(Mice&)=M1& THEN ET=ET+2 ELSE ET=0
  IF ET>=Waiting THEN GOSUB ActivateMyGraphicProgram: RETURN MainLoop 
  LOCATE 2,2:PRINT DATE$;"  ";TIME$;"     ";
  GOSUB ReadEm
 RETURN

   '**** This awakens program from dormancy and activates your routine ****
   '**** then watches for activity which turns it off                  ****
ActivateMyGraphicProgram:
  TIMER OFF                 '**** Turn waiting timer off
                            '**** Then turn graphic screen timer on
  ON TIMER (1) GOSUB HasAnythingBeenTouched
  TIMER ON
  GOSUB ReadEm              '**** Record mouse and key positions
  GOSUB MyGraphicProgram    '**** Run your graphics routine until something happens
  TIMER OFF                 '**** Turn graphic screen timer off
  WINDOW 1                  '**** Direct printing to little window
  ET=0                      '**** Reset activities timer
  GOSUB TurnWaitingTimerOn  '**** Restart waiting timer
  GOSUB ReadEm              '**** Record mouse and key positions
 RETURN                     '**** Return to main loop

   '**** See if keys, mice or sticks have been used  ****
   '**** by PEEKing at three hardware locations.     ****
HasAnythingBeenTouched:
  IF K1&<>PEEK(Keys&) OR M1&<>PEEKL(Mice&) THEN NoThingIsHappening=False

ReadEm: K1&=PEEK(Keys&): M1&=PEEKL(Mice&): RETURN

   '**** Set timer checking for activity every "Often" seconds ****
TurnWaitingTimerOn:
  ON TIMER (Often) GOSUB CheckMouseAndKeys
  TIMER ON
 RETURN

 
