C  SAVE/RESTORE PROCESSOR
C
C WRITTEN BY    BOB SUPNIK
C               DISK ENGINEERING
C               25-AUG-78
C
C  CURRENT LIMITS:
C       750 TRAVEL OPTIONS (TRAVEL, TRVSIZ).
C       300 VOCABULARY WORDS (KTAB, ATAB, TABSIZ).
C       150 LOCATIONS (LTEXT, STEXT, KEY, COND, ABB, ATLOC, LOCSIZ).
C       100 OBJECTS (PLAC, PLACE, FIXD, FIXED, LINK (TWICE), PTEXT, PROP).
C        35 "ACTION" VERBS (ACTSPK, VRBSIZ).
C       205 RANDOM MESSAGES (RTEXT, RTXSIZ).
C        12 DIFFERENT PLAYER CLASSIFICATIONS (CTEXT, CVAL, CLSMAX).
C        20 HINTS, LESS 3 (HINTLC, HINTED, HINTS, HNTSIZ).
C  THERE ARE ALSO LIMITS WHICH CANNOT BE EXCEEDED DUE TO THE STRUCTURE OF
C  THE DATABASE.  (E.G., THE VOCABULARY USES N/1000 TO DETERMINE WORD TYPE,
C  SO THERE CAN'T BE MORE THAN 1000 WORDS.)  THESE UPPER LIMITS ARE:
C       1000 NON-SYNONYMOUS VOCABULARY WORDS
C       300 LOCATIONS
C       100 OBJECTS
C
      SUBROUTINE SAVEGM(F1,F2)
      IMPLICIT INTEGER*2 (A-Z)
      LOGICAL F1
      LOGICAL LMWARN,CLOSNG,PANIC,HINTED,
     1       CLOSED,GAVEUP,SCORNG,DSEEN
C
      COMMON /VERSN/ VMAJ,VMIN,VEDIT
      COMMON /TXTCOM/ RTEXT,LINES,ASCVAR
      COMMON /ALPHAS/ BLANK,EOF,CYE,CY,CNO,CN,CPO,CUR,CWE,CST,
     1       CEN,CTE
      COMMON /VOCCOM/ KTAB,ATAB,A2TAB,TABSIZ
      COMMON /PLACOM/ ATLOC,LINK,PLACE,FIXED,HOLDNG
      COMMON /PTXCOM/ PTEXT
      COMMON /ABBCOM/ ABB
      COMMON /MISCOM/ LINUSE,TRVS,CLSSES,OLDLOC,LOC,CVAL,TK,NEWLOC,
     1KEY,PLAC,FIXD,ACTSPK,COND,HINTS,HNTMAX,PROP,TALLY,TALLY2,
     2HINTLC,CHLOC,CHLOC2,DSEEN,DFLAG,DLOC,DALTLC,KEYS,LAMP,GRATE,
     3CAGE,ROD,ROD2,STEPS,BIRD,DOOR,PILLOW,SNAKE,FISSUR,TABLET,
     4CLAM,OYSTER,MAGZIN,DWARF,KNIFE,FOOD,BOTTLE,WATER,OIL,PLANT,
     5PLANT2,AXE,MIRROR,DRAGON,CHASM,TROLL,TROLL2,BEAR,MESSAG,VEND,
     6BATTER,NUGGET,COINS,CHEST,EGGS,TRIDNT,VASE,EMRALD,PYRAM,
     7PEARL,RUG,CHAIN,BACK,LOOK,CAVE,NULL,ENTRNC,DPRSSN,SAY,LOCK,
     8THROW,FIND,INVENT,TURNS,LMWARN,KNFLOC,DETAIL,ABBNUM,
     9NUMDIE,MAXDIE,DKILL,FOOBAR,BONUS,CLOCK1,CLOCK2,
     1CLOSNG,PANIC,CLOSED,GAVEUP,SCORNG,ODLOC,STREAM,SPICES
      COMMON /MISC2/ I,RTXSIZ,CLSMAX,MAGSIZ,LOCSIZ,CTEXT,STEXT,LTEXT,
     1SECT,TRAVEL,TRVCON,TRVLOC,TRVSIZ,TABNDX,OBJ,J,K,VERB,HNTSIZ,
     2MAXTRS,HINTED,HNTLOC,KK
C
      DIMENSION LINES(36)
      DIMENSION TRAVEL(750),TRVCON(750),TRVLOC(750)
      DIMENSION KTAB(300),ATAB(300),A2TAB(300)
      DIMENSION LTEXT(150),STEXT(150),KEY(150),COND(150),ABB(150),
     1       ATLOC(150)
      DIMENSION PLAC(100),PLACE(100),FIXD(100),FIXED(100),LINK(200),
     1       PTEXT(100),PROP(100)
      DIMENSION ACTSPK(35)
      DIMENSION RTEXT(205)
      DIMENSION CTEXT(12),CVAL(12)
      DIMENSION HINTLC(20),HINTED(20),HINTS(20,4)
      DIMENSION TK(20),DSEEN(6),DLOC(6),ODLOC(6)
C
c     IF(F1) CALL ASSIGN(1,'ASAVE.DAT')
c     IF(.NOT.F1) CALL ASSIGN(1,'AINDX.DAT')
      IF(F1) open(unit=1,file='ASAVE.DAT',form='binary',recl=1)
      IF(.NOT.F1) open(unit=1,file='AINDX.DAT',form='binary',recl=1)
C
      WRITE(1) VMAJ,VMIN,VEDIT
      WRITE(1) RTEXT,KTAB,ATAB,A2TAB
      WRITE(1) ATLOC,LINK,PLACE,FIXED,HOLDNG
      WRITE(1) PTEXT,ABB,LINUSE,TRVS,CLSSES
      WRITE(1) OLDLOC,LOC,CVAL,NEWLOC,KEY
      WRITE(1) PLAC,FIXD,ACTSPK,COND,HINTS
      WRITE(1) HNTMAX,PROP,TALLY,TALLY2,HINTLC
      WRITE(1) CHLOC,CHLOC2,DSEEN,DFLAG,DLOC,DALTLC
      WRITE(1) TURNS,LMWARN,KNFLOC,DETAIL,ABBNUM
      WRITE(1) NUMDIE,MAXDIE,DKILL,FOOBAR,BONUS
      WRITE(1) CLOCK1,CLOCK2,CLOSNG,PANIC,CLOSED
      WRITE(1) GAVEUP,SCORNG,ODLOC,CTEXT,STEXT,LTEXT
      WRITE(1) TRAVEL,TRVCON,TRVLOC,MAXTRS,HINTED,HNTLOC
C
      IF(F1) write(*,100)
100   FORMAT(' Saved.')
      CLOSE(1)
      F2=0
      RETURN
      END
C
      SUBROUTINE RSTRGM(F1,F2)
      IMPLICIT INTEGER*2 (A-Z)
      LOGICAL F1
      LOGICAL LMWARN,CLOSNG,PANIC,HINTED,
     1       CLOSED,GAVEUP,SCORNG,DSEEN
C
      COMMON /VERSN/ VMAJ,VMIN,VEDIT
      COMMON /TXTCOM/ RTEXT,LINES,ASCVAR
      COMMON /ALPHAS/ BLANK,EOF,CYE,CY,CNO,CN,CPO,CUR,CWE,CST,
     1       CEN,CTE
      COMMON /VOCCOM/ KTAB,ATAB,A2TAB,TABSIZ
      COMMON /PLACOM/ ATLOC,LINK,PLACE,FIXED,HOLDNG
      COMMON /PTXCOM/ PTEXT
      COMMON /ABBCOM/ ABB
      COMMON /MISCOM/ LINUSE,TRVS,CLSSES,OLDLOC,LOC,CVAL,TK,NEWLOC,
     1KEY,PLAC,FIXD,ACTSPK,COND,HINTS,HNTMAX,PROP,TALLY,TALLY2,
     2HINTLC,CHLOC,CHLOC2,DSEEN,DFLAG,DLOC,DALTLC,KEYS,LAMP,GRATE,
     3CAGE,ROD,ROD2,STEPS,BIRD,DOOR,PILLOW,SNAKE,FISSUR,TABLET,
     4CLAM,OYSTER,MAGZIN,DWARF,KNIFE,FOOD,BOTTLE,WATER,OIL,PLANT,
     5PLANT2,AXE,MIRROR,DRAGON,CHASM,TROLL,TROLL2,BEAR,MESSAG,VEND,
     6BATTER,NUGGET,COINS,CHEST,EGGS,TRIDNT,VASE,EMRALD,PYRAM,
     7PEARL,RUG,CHAIN,BACK,LOOK,CAVE,NULL,ENTRNC,DPRSSN,SAY,LOCK,
     8THROW,FIND,INVENT,TURNS,LMWARN,KNFLOC,DETAIL,ABBNUM,
     9NUMDIE,MAXDIE,DKILL,FOOBAR,BONUS,CLOCK1,CLOCK2,
     1CLOSNG,PANIC,CLOSED,GAVEUP,SCORNG,ODLOC,STREAM,SPICES
      COMMON /MISC2/ I,RTXSIZ,CLSMAX,MAGSIZ,LOCSIZ,CTEXT,STEXT,LTEXT,
     1SECT,TRAVEL,TRVCON,TRVLOC,TRVSIZ,TABNDX,OBJ,J,K,VERB,HNTSIZ,
     2MAXTRS,HINTED,HNTLOC,KK
C
      DIMENSION LINES(36)
      DIMENSION TRAVEL(750),TRVCON(750),TRVLOC(750)
      DIMENSION KTAB(300),ATAB(300),A2TAB(300)
      DIMENSION LTEXT(150),STEXT(150),KEY(150),COND(150),ABB(150),
     1       ATLOC(150)
      DIMENSION PLAC(100),PLACE(100),FIXD(100),FIXED(100),LINK(200),
     1       PTEXT(100),PROP(100)
      DIMENSION ACTSPK(35)
      DIMENSION RTEXT(205)
      DIMENSION CTEXT(12),CVAL(12)
      DIMENSION HINTLC(20),HINTED(20),HINTS(20,4)
      DIMENSION TK(20),DSEEN(6),DLOC(6),ODLOC(6)
C
c     IF(F1) CALL ASSIGN(1,'ASAVE.DAT')
c     IF(.NOT.F1) CALL ASSIGN(1,'AINDX.DAT')
      IF(F1) open(unit=1,file='ASAVE.DAT',form='binary',recl=1)
      IF(.NOT.F1) open(unit=1,file='AINDX.DAT',form='binary',recl=1)
C
      READ(1) I1,I2,I3
      IF((I1.NE.VMAJ).OR.(I2.NE.VMIN)) GO TO 50
C
      READ(1) RTEXT,KTAB,ATAB,A2TAB
      READ(1) ATLOC,LINK,PLACE,FIXED,HOLDNG
      READ(1) PTEXT,ABB,LINUSE,TRVS,CLSSES
      READ(1) OLDLOC,LOC,CVAL,NEWLOC,KEY
      READ(1) PLAC,FIXD,ACTSPK,COND,HINTS
      READ(1) HNTMAX,PROP,TALLY,TALLY2,HINTLC
      READ(1) CHLOC,CHLOC2,DSEEN,DFLAG,DLOC,DALTLC
      READ(1) TURNS,LMWARN,KNFLOC,DETAIL,ABBNUM
      READ(1) NUMDIE,MAXDIE,DKILL,FOOBAR,BONUS
      READ(1) CLOCK1,CLOCK2,CLOSNG,PANIC,CLOSED
      READ(1) GAVEUP,SCORNG,ODLOC,CTEXT,STEXT,LTEXT
      READ(1) TRAVEL,TRVCON,TRVLOC,MAXTRS,HINTED,HNTLOC
C
      IF(F1) write(*,100)
100   FORMAT(' Restored.')
      CLOSE(1)
      F2=0
      RETURN
C
50    IF(F1) write(*,110)
110   FORMAT(' File is obsolete, RESTORE fails.')
      CLOSE(1)
      F2=-1
      RETURN
      END
