dverb2.for 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. C SAVE- SAVE GAME STATE
  2. C
  3. C COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142
  4. C ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED
  5. C WRITTEN BY R. M. SUPNIK
  6. C
  7. C DECLARATIONS
  8. C
  9. SUBROUTINE SAVEGM
  10. IMPLICIT INTEGER (A-Z)
  11. include 'parser.h'
  12. include 'gamestat.h'
  13. include 'state.h'
  14. include 'screen.h'
  15. include 'puzzle.h'
  16. include 'rooms.h'
  17. include 'exits.h'
  18. include 'objects.h'
  19. include 'clock.h'
  20. include 'villians.h'
  21. include 'advers.h'
  22. include 'flags.h'
  23. C
  24. C MISCELLANEOUS VARIABLES
  25. C
  26. COMMON /VERS/ VMAJ,VMIN,VEDIT
  27. COMMON /TIME/ PLTIME,SHOUR,SMIN,SSEC
  28. C
  29. PRSWON=.FALSE.
  30. C !DISABLE GAME.
  31. C Note: save file format is different for PDP vs. non-PDP versions
  32. C
  33. OPEN (UNIT=1,file='dsave.dat',ACCESS='SEQUENTIAL',
  34. & status='UNKNOWN',FORM='UNFORMATTED',ERR=100)
  35. C
  36. CALL GTTIME(I)
  37. C !GET TIME.
  38. WRITE(1) VMAJ,VMIN,VEDIT
  39. WRITE(1) WINNER,HERE,THFPOS,TELFLG,THFFLG,THFACT,
  40. & SWDACT,SWDSTA,CPVEC
  41. WRITE(1) I,MOVES,DEATHS,RWSCOR,EGSCOR,MXLOAD,
  42. & LTSHFT,BLOC,MUNGRM,HS,FROMDR,SCOLRM,SCOLAC
  43. WRITE(1) ODESC1,ODESC2,OFLAG1,OFLAG2,OFVAL,OTVAL,
  44. & OSIZE,OCAPAC,OROOM,OADV,OCAN
  45. WRITE(1) RVAL,RFLAG
  46. WRITE(1) AROOM,ASCORE,AVEHIC,ASTREN,AFLAG
  47. WRITE(1) FLAGS,SWITCH,VPROB,CFLAG,CTICK
  48. C
  49. CLOSE(UNIT=1)
  50. CALL RSPEAK(597)
  51. RETURN
  52. C
  53. 100 CALL RSPEAK(598)
  54. C !CANT DO IT.
  55. RETURN
  56. END
  57. C RESTORE- RESTORE GAME STATE
  58. C
  59. C DECLARATIONS
  60. C
  61. SUBROUTINE RSTRGM
  62. IMPLICIT INTEGER (A-Z)
  63. include 'parser.h'
  64. include 'gamestat.h'
  65. include 'state.h'
  66. include 'screen.h'
  67. include 'puzzle.h'
  68. include 'rooms.h'
  69. include 'exits.h'
  70. include 'objects.h'
  71. include 'clock.h'
  72. include 'villians.h'
  73. include 'advers.h'
  74. include 'flags.h'
  75. C
  76. C MISCELLANEOUS VARIABLES
  77. C
  78. COMMON /VERS/ VMAJ,VMIN,VEDIT
  79. COMMON /TIME/ PLTIME,SHOUR,SMIN,SSEC
  80. C
  81. PRSWON=.FALSE.
  82. C !DISABLE GAME.
  83. C Note: save file format is different for PDP vs. non-PDP versions
  84. C
  85. OPEN (UNIT=1,file='dsave.dat',ACCESS='SEQUENTIAL',
  86. & status='OLD',FORM='UNFORMATTED',ERR=100)
  87. C
  88. READ(1) I,J,K
  89. IF((I.NE.VMAJ).OR.(J.NE.VMIN)) GO TO 200
  90. C
  91. READ(1) WINNER,HERE,THFPOS,TELFLG,THFFLG,THFACT,
  92. & SWDACT,SWDSTA,CPVEC
  93. READ(1) PLTIME,MOVES,DEATHS,RWSCOR,EGSCOR,MXLOAD,
  94. & LTSHFT,BLOC,MUNGRM,HS,FROMDR,SCOLRM,SCOLAC
  95. READ(1) ODESC1,ODESC2,OFLAG1,OFLAG2,OFVAL,OTVAL,
  96. & OSIZE,OCAPAC,OROOM,OADV,OCAN
  97. READ(1) RVAL,RFLAG
  98. READ(1) AROOM,ASCORE,AVEHIC,ASTREN,AFLAG
  99. READ(1) FLAGS,SWITCH,VPROB,CFLAG,CTICK
  100. C
  101. CLOSE(UNIT=1)
  102. CALL RSPEAK(599)
  103. RETURN
  104. C
  105. 100 CALL RSPEAK(598)
  106. C !CANT DO IT.
  107. RETURN
  108. C
  109. 200 CALL RSPEAK(600)
  110. C !OBSOLETE VERSION
  111. CLOSE (UNIT=1)
  112. RETURN
  113. END
  114. C WALK- MOVE IN SPECIFIED DIRECTION
  115. C
  116. C DECLARATIONS
  117. C
  118. LOGICAL FUNCTION WALK(X)
  119. IMPLICIT INTEGER(A-Z)
  120. LOGICAL FINDXT,QOPEN,LIT,PROB,MOVETO,RMDESC
  121. include 'parser.h'
  122. include 'gamestat.h'
  123. include 'rooms.h'
  124. include 'rflag.h'
  125. include 'curxt.h'
  126. include 'xsrch.h'
  127. include 'objects.h'
  128. include 'oflags.h'
  129. include 'clock.h'
  130. include 'villians.h'
  131. include 'advers.h'
  132. include 'flags.h'
  133. C
  134. C FUNCTIONS AND DATA
  135. C
  136. QOPEN(O)=IAND(OFLAG2(O),OPENBT).NE.0
  137. C WALK, PAGE 2
  138. C
  139. WALK=.TRUE.
  140. C !ASSUME WINS.
  141. IF((WINNER.NE.PLAYER).OR.LIT(HERE).OR.PROB(25,25))
  142. & GO TO 500
  143. IF(.NOT.FINDXT(PRSO,HERE)) GO TO 450
  144. C !INVALID EXIT? GRUE
  145. C !
  146. GO TO (400,200,100,300),XTYPE
  147. C !DECODE EXIT TYPE.
  148. CALL BUG(9,XTYPE)
  149. C
  150. 100 IF(CXAPPL(XACTIO).NE.0) GO TO 400
  151. C !CEXIT... RETURNED ROOM?
  152. IF(FLAGS(XFLAG)) GO TO 400
  153. C !NO, FLAG ON?
  154. 200 CALL JIGSUP(523)
  155. C !BAD EXIT, GRUE
  156. C !
  157. RETURN
  158. C
  159. 300 IF(CXAPPL(XACTIO).NE.0) GO TO 400
  160. C !DOOR... RETURNED ROOM?
  161. IF(QOPEN(XOBJ)) GO TO 400
  162. C !NO, DOOR OPEN?
  163. CALL JIGSUP(523)
  164. C !BAD EXIT, GRUE
  165. C !
  166. RETURN
  167. C
  168. 400 IF(LIT(XROOM1)) GO TO 900
  169. C !VALID ROOM, IS IT LIT?
  170. 450 CALL JIGSUP(522)
  171. C !NO, GRUE
  172. C !
  173. RETURN
  174. C
  175. C ROOM IS LIT, OR WINNER IS NOT PLAYER (NO GRUE).
  176. C
  177. 500 IF(FINDXT(PRSO,HERE)) GO TO 550
  178. C !EXIT EXIST?
  179. 525 XSTRNG=678
  180. C !ASSUME WALL.
  181. IF(PRSO.EQ.XUP) XSTRNG=679
  182. C !IF UP, CANT.
  183. IF(PRSO.EQ.XDOWN) XSTRNG=680
  184. C !IF DOWN, CANT.
  185. IF(IAND(RFLAG(HERE),RNWALL).NE.0) XSTRNG=524
  186. CALL RSPEAK(XSTRNG)
  187. PRSCON=1
  188. C !STOP CMD STREAM.
  189. RETURN
  190. C
  191. 550 GO TO (900,600,700,800),XTYPE
  192. C !BRANCH ON EXIT TYPE.
  193. CALL BUG(9,XTYPE)
  194. C
  195. 700 IF(CXAPPL(XACTIO).NE.0) GO TO 900
  196. C !CEXIT... RETURNED ROOM?
  197. IF(FLAGS(XFLAG)) GO TO 900
  198. C !NO, FLAG ON?
  199. 600 IF(XSTRNG.EQ.0) GO TO 525
  200. C !IF NO REASON, USE STD.
  201. CALL RSPEAK(XSTRNG)
  202. C !DENY EXIT.
  203. PRSCON=1
  204. C !STOP CMD STREAM.
  205. RETURN
  206. C
  207. 800 IF(CXAPPL(XACTIO).NE.0) GO TO 900
  208. C !DOOR... RETURNED ROOM?
  209. IF(QOPEN(XOBJ)) GO TO 900
  210. C !NO, DOOR OPEN?
  211. IF(XSTRNG.EQ.0) XSTRNG=525
  212. C !IF NO REASON, USE STD.
  213. CALL RSPSUB(XSTRNG,ODESC2(XOBJ))
  214. PRSCON=1
  215. C !STOP CMD STREAM.
  216. RETURN
  217. C
  218. 900 WALK=MOVETO(XROOM1,WINNER)
  219. C !MOVE TO ROOM.
  220. IF(WALK) WALK=RMDESC(0)
  221. C !DESCRIBE ROOM.
  222. RETURN
  223. END
  224. C CXAPPL- CONDITIONAL EXIT PROCESSORS
  225. C
  226. C DECLARATIONS
  227. C
  228. INTEGER FUNCTION CXAPPL(RI)
  229. IMPLICIT INTEGER (A-Z)
  230. include 'gamestat.h'
  231. include 'parser.h'
  232. include 'puzzle.h'
  233. include 'rooms.h'
  234. include 'rindex.h'
  235. include 'exits.h'
  236. include 'curxt.h'
  237. include 'xpars.h'
  238. include 'xsrch.h'
  239. include 'objects.h'
  240. include 'oflags.h'
  241. include 'oindex.h'
  242. include 'advers.h'
  243. include 'flags.h'
  244. C CXAPPL, PAGE 2
  245. C
  246. CXAPPL=0
  247. C !NO RETURN.
  248. IF(RI.EQ.0) RETURN
  249. C !IF NO ACTION, DONE.
  250. GO TO (1000,2000,3000,4000,5000,6000,7000,
  251. & 8000,9000,10000,11000,12000,13000,14000),RI
  252. CALL BUG(5,RI)
  253. C
  254. C C1- COFFIN-CURE
  255. C
  256. 1000 EGYPTF=OADV(COFFI).NE.WINNER
  257. C !T IF NO COFFIN.
  258. RETURN
  259. C
  260. C C2- CAROUSEL EXIT
  261. C C5- CAROUSEL OUT
  262. C
  263. 2000 IF(CAROFF) RETURN
  264. C !IF FLIPPED, NOTHING.
  265. 2500 CALL RSPEAK(121)
  266. C !SPIN THE COMPASS.
  267. 5000 I=XELNT(XCOND)*RND(8)
  268. C !CHOOSE RANDOM EXIT.
  269. XROOM1=IAND(TRAVEL(REXIT(HERE)+I),XRMASK)
  270. CXAPPL=XROOM1
  271. C !RETURN EXIT.
  272. RETURN
  273. C
  274. C C3- CHIMNEY FUNCTION
  275. C
  276. 3000 LITLDF=.FALSE.
  277. C !ASSUME HEAVY LOAD.
  278. J=0
  279. DO 3100 I=1,OLNT
  280. C !COUNT OBJECTS.
  281. IF(OADV(I).EQ.WINNER) J=J+1
  282. 3100 CONTINUE
  283. C
  284. IF(J.GT.2) RETURN
  285. C !CARRYING TOO MUCH?
  286. XSTRNG=446
  287. C !ASSUME NO LAMP.
  288. IF(OADV(LAMP).NE.WINNER) RETURN
  289. C !NO LAMP?
  290. LITLDF=.TRUE.
  291. C !HE CAN DO IT.
  292. IF(IAND(OFLAG2(DOOR),OPENBT).EQ.0)
  293. & OFLAG2(DOOR)=IAND(OFLAG2(DOOR), not(TCHBT))
  294. RETURN
  295. C
  296. C C4- FROBOZZ FLAG (MAGNET ROOM, FAKE EXIT)
  297. C C6- FROBOZZ FLAG (MAGNET ROOM, REAL EXIT)
  298. C
  299. 4000 IF(CAROFF) GO TO 2500
  300. C !IF FLIPPED, GO SPIN.
  301. FROBZF=.FALSE.
  302. C !OTHERWISE, NOT AN EXIT.
  303. RETURN
  304. C
  305. 6000 IF(CAROFF) GO TO 2500
  306. C !IF FLIPPED, GO SPIN.
  307. FROBZF=.TRUE.
  308. C !OTHERWISE, AN EXIT.
  309. RETURN
  310. C
  311. C C7- FROBOZZ FLAG (BANK ALARM)
  312. C
  313. 7000 FROBZF=(OROOM(BILLS).NE.0).AND.(OROOM(PORTR).NE.0)
  314. RETURN
  315. C CXAPPL, PAGE 3
  316. C
  317. C C8- FROBOZZ FLAG (MRGO)
  318. C
  319. 8000 FROBZF=.FALSE.
  320. C !ASSUME CANT MOVE.
  321. IF(MLOC.NE.XROOM1) GO TO 8100
  322. C !MIRROR IN WAY?
  323. IF((PRSO.EQ.XNORTH).OR.(PRSO.EQ.XSOUTH)) GO TO 8200
  324. IF(MOD(MDIR,180).NE.0) GO TO 8300
  325. C !MIRROR MUST BE N-S.
  326. XROOM1=((XROOM1-MRA)*2)+MRAE
  327. C !CALC EAST ROOM.
  328. IF(PRSO.GT.XSOUTH) XROOM1=XROOM1+1
  329. C !IF SW/NW, CALC WEST.
  330. 8100 CXAPPL=XROOM1
  331. RETURN
  332. C
  333. 8200 XSTRNG=814
  334. C !ASSUME STRUC BLOCKS.
  335. IF(MOD(MDIR,180).EQ.0) RETURN
  336. C !IF MIRROR N-S, DONE.
  337. 8300 LDIR=MDIR
  338. C !SEE WHICH MIRROR.
  339. IF(PRSO.EQ.XSOUTH) LDIR=180
  340. XSTRNG=815
  341. C !MIRROR BLOCKS.
  342. IF(((LDIR.GT.180).AND..NOT.MR1F).OR.
  343. & ((LDIR.LT.180).AND..NOT.MR2F)) XSTRNG=816
  344. RETURN
  345. C
  346. C C9- FROBOZZ FLAG (MIRIN)
  347. C
  348. 9000 IF(MRHERE(HERE).NE.1) GO TO 9100
  349. C !MIRROR 1 HERE?
  350. IF(MR1F) XSTRNG=805
  351. C !SEE IF BROKEN.
  352. FROBZF=MROPNF
  353. C !ENTER IF OPEN.
  354. RETURN
  355. C
  356. 9100 FROBZF=.FALSE.
  357. C !NOT HERE,
  358. XSTRNG=817
  359. C !LOSE.
  360. RETURN
  361. C CXAPPL, PAGE 4
  362. C
  363. C C10- FROBOZZ FLAG (MIRROR EXIT)
  364. C
  365. 10000 FROBZF=.FALSE.
  366. C !ASSUME CANT.
  367. LDIR=((PRSO-XNORTH)/XNORTH)*45
  368. C !XLATE DIR TO DEGREES.
  369. IF(.NOT.MROPNF .OR.
  370. & ((MOD(MDIR+270,360).NE.LDIR).AND.(PRSO.NE.XEXIT)))
  371. & GO TO 10200
  372. XROOM1=((MLOC-MRA)*2)+MRAE+1-(MDIR/180)
  373. C !ASSUME E-W EXIT.
  374. IF(MOD(MDIR,180).EQ.0) GO TO 10100
  375. C !IF N-S, OK.
  376. XROOM1=MLOC+1
  377. C !ASSUME N EXIT.
  378. IF(MDIR.GT.180) XROOM1=MLOC-1
  379. C !IF SOUTH.
  380. 10100 CXAPPL=XROOM1
  381. RETURN
  382. C
  383. 10200 IF(.NOT.WDOPNF .OR.
  384. & ((MOD(MDIR+180,360).NE.LDIR).AND.(PRSO.NE.XEXIT)))
  385. & RETURN
  386. XROOM1=MLOC+1
  387. C !ASSUME N.
  388. IF(MDIR.EQ.0) XROOM1=MLOC-1
  389. C !IF S.
  390. CALL RSPEAK(818)
  391. C !CLOSE DOOR.
  392. WDOPNF=.FALSE.
  393. CXAPPL=XROOM1
  394. RETURN
  395. C
  396. C C11- MAYBE DOOR. NORMAL MESSAGE IS THAT DOOR IS CLOSED.
  397. C BUT IF LCELL.NE.4, DOOR ISNT THERE.
  398. C
  399. 11000 IF(LCELL.NE.4) XSTRNG=678
  400. C !SET UP MSG.
  401. RETURN
  402. C
  403. C C12- FROBZF (PUZZLE ROOM MAIN ENTRANCE)
  404. C
  405. 12000 FROBZF=.TRUE.
  406. C !ALWAYS ENTER.
  407. CPHERE=10
  408. C !SET SUBSTATE.
  409. RETURN
  410. C
  411. C C13- CPOUTF (PUZZLE ROOM SIZE ENTRANCE)
  412. C
  413. 13000 CPHERE=52
  414. C !SET SUBSTATE.
  415. RETURN
  416. C CXAPPL, PAGE 5
  417. C
  418. C C14- FROBZF (PUZZLE ROOM TRANSITIONS)
  419. C
  420. 14000 FROBZF=.FALSE.
  421. C !ASSSUME LOSE.
  422. IF(PRSO.NE.XUP) GO TO 14100
  423. C !UP?
  424. IF(CPHERE.NE.10) RETURN
  425. C !AT EXIT?
  426. XSTRNG=881
  427. C !ASSUME NO LADDER.
  428. IF(CPVEC(CPHERE+1).NE.-2) RETURN
  429. C !LADDER HERE?
  430. CALL RSPEAK(882)
  431. C !YOU WIN.
  432. FROBZF=.TRUE.
  433. C !LET HIM OUT.
  434. RETURN
  435. C
  436. 14100 IF((CPHERE.NE.52).OR.(PRSO.NE.XWEST).OR..NOT.CPOUTF)
  437. & GO TO 14200
  438. FROBZF=.TRUE.
  439. C !YES, LET HIM OUT.
  440. RETURN
  441. C
  442. 14200 DO 14300 I=1,16,2
  443. C !LOCATE EXIT.
  444. IF(PRSO.EQ.CPDR(I)) GO TO 14400
  445. 14300 CONTINUE
  446. RETURN
  447. C !NO SUCH EXIT.
  448. C
  449. 14400 J=CPDR(I+1)
  450. C !GET DIRECTIONAL OFFSET.
  451. NXT=CPHERE+J
  452. C !GET NEXT STATE.
  453. K=8
  454. C !GET ORTHOGONAL DIR.
  455. IF(J.LT.0) K=-8
  456. IF((((IABS(J).EQ.1).OR.(IABS(J).EQ.8)).OR.
  457. & ((CPVEC(CPHERE+K).EQ.0).OR.(CPVEC(NXT-K).EQ.0))).AND.
  458. & (CPVEC(NXT).EQ.0)) GO TO 14500
  459. RETURN
  460. C
  461. 14500 CALL CPGOTO(NXT)
  462. C !MOVE TO STATE.
  463. XROOM1=CPUZZ
  464. C !STAY IN ROOM.
  465. CXAPPL=XROOM1
  466. RETURN
  467. C
  468. END