      SUBROUTINE RESUME
      IMPLICIT INTEGER*4 (A-Z)
C
C Author       : Kevin B Black
C Date written : December 1987
C Abstract     :
C
C Subroutine restores a game from a file.
C Called from RKB, which afterwards sets things up so that the
C restores location is described.
C
      LOGICAL BLKLIN,NOINPT
      LOGICAL DSEEN,HINTED,YES,DARK,BITSET,CLOSED,GAVEUP,SCORNG,YEA
      LOGICAL TOTING,HERE,AT,WZDARK,LMWARN,CLOSNG,PANIC,FORCED,PCT
C
      INTEGER*4 LINES,EOF
C
      COMMON /TXTCOM/ RTEXT,LINES,ASCVAR
      COMMON /RKSHRD/ YEA,WZDARK,OLDLC2,HINT,WD1,WD1X,WD2
     &,WD2X,LIMIT,SPK
      COMMON /BLKCOM/ BLKLIN,NOINPT
      COMMON /ALPHAS/ CYES,CY,CNO,CN,CPOUR,CWEST,CENTE
      COMMON /BLANKS/ BLANK4,EOF
      COMMON /VOCCOM/ KTAB,ATAB,A2TAB,TABSIZ
      COMMON /PLACOM/ ATLOC,LINK,PLACE,FIXED,HOLDNG
      COMMON /MTXCOM/ MTEXT
      COMMON /PTXCOM/ PTEXT
      COMMON /ABBCOM/ ABB
      COMMON /CONCOM/ COND(150)
      COMMON /PROCOM/ PROP(100),BOTTLE,LAMP,WATER,OIL
      COMMON /LOCCOM/ OLDLOC,LOC
      COMMON /MISCOM/ LINUSE,TRVS,CLSSES,CVAL,TK,NEWLOC,
     &KEY,PLAC,FIXD,ACTSPK,HINTS,HNTMAX,TALLY,TALLY2,
     &HINTLC,CHLOC,CHLOC2,DSEEN,DFLAG,DLOC,DALTLC,KEYS,GRATE,
     &CAGE,ROD,ROD2,STEPS,BIRD,DOOR,PILLOW,SNAKE,FISSUR,TABLET,
     &CLAM,OYSTER,MAGZIN,DWARF,KNIFE,FOOD,PLANT,
     &PLANT2,AXE,MIRROR,DRAGON,CHASM,TROLL,TROLL2,BEAR,MESSAG,VEND,
     &BATTER,NUGGET,COINS,CHEST,EGGS,TRIDNT,VASE,EMRALD,PYRAM,
     &PEARL,RUG,CHAIN,BACK,LOOK,CAVE,NULL,ENTRNC,DPRSSN,SAY,LOCK,
     &THROW,FIND,INVENT,TURNS,LMWARN,KNFLOC,DETAIL,ABBNUM,
     &NUMDIE,MAXDIE,DKILL,FOOBAR,BONUS,CLOCK1,CLOCK2,
     &CLOSNG,PANIC,CLOSED,GAVEUP,SCORNG,ODLOC,STREAM,SPICES
      COMMON /MISC2/ I,RTXSIZ,CLSMAX,MAGSIZ,LOCSIZ,CTEXT,STEXT,LTEXT,
     &SECT,TRAVEL,TRVCON,TRVLOC,TRVSIZ,TABNDX,OBJ,J,K,VERB,HNTSIZ,
     &MAXTRS,HINTED,HNTLOC,KK
      COMMON /SAVEIT/ATTACK,DEST2,DTOTAL,K2,KENT,KQ,LL,MXSCOR,SCORE,
     *               STICK
      INTEGER*2 ICRC,ICRC2
C
      DIMENSION LINES(18)
      DIMENSION TRAVEL(750),TRVCON(750),TRVLOC(750)
      DIMENSION KTAB(300),ATAB(300),A2TAB(300)
      DIMENSION LTEXT(150),STEXT(150),KEY(150),ABB(150),ATLOC(150)
      DIMENSION PLAC(100),PLACE(100),FIXD(100),FIXED(100),LINK(200),
     & PTEXT(100)
      DIMENSION ACTSPK(35)
      DIMENSION RTEXT(205)
      DIMENSION CTEXT(12),CVAL(12)
      DIMENSION HINTLC(20),HINTED(20),HINTS(20,4)
        DIMENSION MTEXT(35)
      DIMENSION TK(20),DSEEN(6),DLOC(6),ODLOC(6)
C
C
C
      LOGICAL*4 EXISTS
      INTEGER*4 IOSTAT
      CHARACTER*80 SFILE
C
C ASK FOR THE NAME OF THE FILE IN WHICH THE GAME HAS BEEN SAVED
C
10    WRITE(*,1000)
1000  FORMAT(
     *' What is the name of the file in which the game',
     *' has been saved?',/,' >')
      READ(5,2000,END=9000,IOSTAT=IOSTAT)SFILE
2000  FORMAT(A80)
      IF(IOSTAT.NE.0)GOTO 10
C
C IF THE USER HAS ENETERD A NULL STRING THEN NO RESTORE
C
      IF(LENBA(SFILE,80).EQ.0)THEN
         WRITE(*,1015)
1015  FORMAT(' No restore performed.')
         GOTO 8000
      ENDIF
C
C SEE IF THE FILE EXISTS
C
      INQUIRE(FILE=SFILE,EXIST=EXISTS)
      IF(.NOT.EXISTS)THEN
         WRITE(*,1020)
1020  FORMAT(' That file does not exist, no restore performed.')
         GOTO 8000
      ENDIF
C
C OPEN THE FILE
C
      CLOSE(UNIT=3,IOSTAT=IOSTAT)
      OPEN(UNIT=3,FILE=SFILE,STATUS='OLD',
     *     FORM='UNFORMATTED')
C
C READ THE SAVED GAME, ALLOW CRASH AT ERRORS AS THE GAME DATA WILL
C BE MUCKED UP IF IT GETS PART WAY THROUGH THIS
C
      READ(3)A2TAB,ABB,ABBNUM,ACTSPK,ASCVAR,ATAB,ATLOC,
     *ATTACK,AXE,BACK,BATTER,BEAR,BIRD,BLANK4,BLKLIN,BONUS,BOTTLE,CAGE,
     *CAVE,CENTE,CHAIN,CHASM,CHEST,CHLOC,CHLOC2,CLAM,CLOCK1,CLOCK2,
     *CLOSED,CLOSNG,CLSMAX,CLSSES,CN,CNO,COINS,COND,CPOUR,CTEXT,CVAL,
     *CWEST,CY,CYES,DALTLC,DEST2,DETAIL,DFLAG,DKILL,DLOC,DOOR,DPRSSN,
     *DRAGON,DSEEN,DTOTAL,DWARF,EGGS,EMRALD,ENTRNC,EOF,FIND,FISSUR,FIXD,
     *FIXED,FOOBAR,FOOD,GAVEUP,GRATE,HINT,HINTED,HINTLC,HINTS,HNTLOC,
     *HNTMAX,HNTSIZ,HOLDNG,I,INVENT,J,K,K2,KENT,KEY,KEYS,KK,KNFLOC,
     *KNIFE,KQ,KTAB,LAMP,LIMIT,LINES,LINK,LINUSE,LL,LMWARN,LOC,LOCK,
     *LOCSIZ,LOOK,MAGSIZ,MAGZIN,MAXDIE,MAXTRS,MESSAG,MIRROR,MTEXT,
     *MXSCOR,NEWLOC,NOINPT,NUGGET,NULL,NUMDIE,OBJ,ODLOC,OIL,OLDLC2,
     *OLDLOC,OYSTER,PANIC,PEARL,PILLOW,PLAC,PLACE,PLANT,PLANT2,PROP,
     *PYRAM,ROD,ROD2,RTEXT,RTXSIZ,RUG,SAY,SCORE,SCORNG,SECT,SNAKE,
     *SPICES,SPK,STEPS,STICK,STREAM,TABLET,TABNDX,TABSIZ,TALLY,
     *TALLY2,THROW,TK,TRIDNT,TROLL,TROLL2,TRVS,
     *TRVSIZ,TURNS,VASE,VEND,VERB,WATER,WD1,WD1X,WD2,WD2X,WZDARK,YEA
      CLOSE(UNIT=3,IOSTAT=IOSTAT)
      WRITE(*,1060)
1060  FORMAT(' Restored.')
C
C THAT IS IT
C
8000  WRITE(*,*)
      RETURN
C
C USER EOFed THE TERMINAL INPUT STREAM
C
9000  CLOSE(UNIT=5)
      OPEN(UNIT=5,FILE='CON',STATUS='NEW')
      GOTO 10
      END
