C***   START
C  WIZARDRY ROUTINES (START, MAINT, WIZARD, HOURS(X), NEWHRS(X), MOTD, POOF, GRI

        LOGICAL FUNCTION START(DUMMY)
C  CHECK TO SEE IF THIS IS "PRIME TIME".  IF SO, ONLY WIZARDS MAY PLAY, THOUGH
C  OTHERS MAY BE ALLOWED A SHORT GAME FOR DEMONSTRATION PURPOSES.  IF SETUP<0,
C  WE'RE CONTINUING FROM A SAVED GAME, SO CHECK FOR SUITABLE LATENCY.  RETURN
C  TRUE IF THIS IS A DEMO GAME (VALUE IS IGNORED FOR RESTARTS).
        IMPLICIT INTEGER(A-Z)
      INTEGER*4 PRIMTM,WKDAY,WKEND,HOLID
        LOGICAL PTIME,SOON,YESM,WIZARD,EQV
        DIMENSION HNAME(10),VEC(15)
      REAL*8 MAGIC
        COMMON /WIZCOM/ WKDAY,WKEND,HOLID,HBEGIN,HEND,HNAME,
     1          SHORT,MAGIC,MAGNM,LATNCY,SAVED,SAVET,SETUP
C  FIRST FIND OUT WHETHER IT IS PRIME TIME (SAVE IN PTIME) AND, IF RESTARTING,
C  WHETHER IT'S TOO SOON (SAVE IN SOON).  PRIME-TIME SPECS ARE IN WKDAY, WKEND,
C  AND HOLID; SEE MAINT ROUTINE FOR DETAILS.  LATNCY IS REQUIRED DELAY BEFORE
C  RESTARTING.  WIZARDS MAY CUT THIS TO A THIRD.
        CALL DATIME(D,T)
      CALL TIMDAT(VEC,15)
        PRIMTM=WKDAY
        IF(MOD(D,7).LE.1)PRIMTM=WKEND
        IF(D.GE.HBEGIN.AND.D.LE.HEND)PRIMTM=HOLID
        PTIME=(AND(PRIMTM,LS(000001,(T/60)))).NE.0
        SOON=.FALSE.
        IF(SETUP.GE.0)GOTO 20
        DELAY=(D-SAVED)*1440+(T-SAVET)
        IF(DELAY.GE.LATNCY)GOTO 20
        WRITE(1,10)DELAY
10     FORMAT(' This adventure was suspended a mere',I3,' minutes ago.')
        SOON=.TRUE.
        IF(DELAY.GE.LATNCY/3)GOTO 20
        CALL MSPEAK(2)
        CALL EXIT
C  IF NEITHER TOO SOON NOR PRIME TIME, NO PROBLEM.  ELSE SPECIFY WHAT'S WRONG.
20      START=.FALSE.
        IF(SOON)GOTO 30
        IF(PTIME)GOTO 25
C22    IF(EQV('CHEM  ',VEC(13))) GOTO 23
C22    IF(EQV('CHEM  ',VEC(13))) CALL EXIT  /* DISALLOW CHEM TO ACCESS
22    CONTINUE
        SAVED=-1
23    CALL BREAK$(.TRUE.)
      CALL LOGIN
        RETURN
C  COME HERE IF NOT RESTARTING TOO SOON (MAYBE NOT RESTARTING AT ALL), BUT IT'S
C  PRIME TIME.  GIVE OUR HOURS AND SEE IF HE'S A WIZARD.  IF NOT, THEN CAN'T
C  RESTART, BUT IF JUST BEGINNING THEN WE CAN OFFER A SHORT GAME.
25      CALL MSPEAK(3)
        CALL HOURS
        CALL MSPEAK(4)
        IF(WIZARD(.FALSE.))GOTO 22
        IF(SETUP.LT.0)GOTO 33
        START=YESM(5,7,7)
        IF(START)GOTO 22
        CALL EXIT
C  COME HERE IF RESTARTING TOO SOON.  IF HE'S A WIZARD, LET HIM GO (AND NOTE
C  THAT IT THEN DOESN'T MATTER WHETHER IT'S PRIME TIME).  ELSE, TOUGH BEANS.
30      CALL MSPEAK(8)
        IF(WIZARD(.FALSE.))GOTO 22
33      CALL MSPEAK(9)
        CALL EXIT
        END
