dinit.for 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. C INIT-- DUNGEON INITIALIZATION SUBROUTINE
  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. LOGICAL FUNCTION INIT(X)
  10. IMPLICIT INTEGER (A-Z)
  11. LOGICAL PROTCT
  12. INTEGER DATARRY(3)
  13. include 'parser.h'
  14. include 'gamestat.h'
  15. include 'state.h'
  16. include 'screen.h'
  17. include 'mindex.h'
  18. C
  19. C MISCELLANEOUS VARIABLES
  20. C
  21. COMMON /STAR/ MBASE,STRBIT
  22. COMMON /VERS/ VMAJ,VMIN,VEDIT
  23. COMMON /TIME/ PLTIME,SHOUR,SMIN,SSEC
  24. include 'io.h'
  25. include 'debug.h'
  26. COMMON /HYPER/ HFACTR
  27. include 'rooms.h'
  28. include 'rflag.h'
  29. include 'rindex.h'
  30. include 'exits.h'
  31. include 'curxt.h'
  32. include 'xpars.h'
  33. include 'objects.h'
  34. include 'oindex.h'
  35. include 'clock.h'
  36. include 'villians.h'
  37. include 'advers.h'
  38. include 'flags.h'
  39. C INIT, PAGE 2
  40. C
  41. C FIRST CHECK FOR PROTECTION VIOLATION
  42. C
  43. IF(PROTCT(X)) GO TO 10000
  44. C !PROTECTION VIOLATION?
  45. PRINT 10100
  46. 10100 FORMAT(' There appears before you a threatening figure clad ',
  47. &'all over'/' in heavy black armor. His legs seem like the ',
  48. &'massive trunk'/' of the oak tree. His broad shoulders and ',
  49. &'helmeted head loom'/' high over your own puny frame, and ',
  50. &'you realize that his powerful'/' arms could easily crush the ',
  51. &'very life from your body. There'/' hangs from his belt a ',
  52. &'veritable arsenal of deadly weapons:'/' sword, mace, ball ',
  53. &'and chain, dagger, lance, and trident.'/' He speaks with a ',
  54. &'commanding voice:'//20X,'"You shall not pass."'//' As ',
  55. &'he grabs you by the neck all grows dim about you.')
  56. CALL EXIT
  57. C
  58. C NOW START INITIALIZATION PROPER
  59. C
  60. 10000 INIT=.FALSE.
  61. C !ASSUME INIT FAILS.
  62. MMAX=1820
  63. C !SET UP ARRAY LIMITS.
  64. OMAX=220
  65. RMAX=200
  66. VMAX=4
  67. AMAX=4
  68. CMAX=25
  69. FMAX=46
  70. SMAX=22
  71. XMAX=900
  72. R2MAX=20
  73. DIRMAX=15
  74. C
  75. MLNT=0
  76. C !INIT ARRAY COUNTERS.
  77. OLNT=0
  78. RLNT=0
  79. VLNT=0
  80. ALNT=0
  81. CLNT=0
  82. XLNT=1
  83. R2LNT=0
  84. C
  85. LTSHFT=10
  86. C !SET UP STATE VARIABLES.
  87. MXSCOR=LTSHFT
  88. EGSCOR=0
  89. EGMXSC=0
  90. MXLOAD=100
  91. RWSCOR=0
  92. DEATHS=0
  93. MOVES=0
  94. PLTIME=0
  95. MUNGRM=0
  96. HS=0
  97. PRSA=0
  98. C !CLEAR PARSE VECTOR.
  99. PRSI=0
  100. PRSO=0
  101. PRSCON=1
  102. OFLAG=0
  103. C !CLEAR ORPHANS.
  104. OACT=0
  105. OSLOT=0
  106. OPREP=0
  107. ONAME=0
  108. THFFLG=.FALSE.
  109. C !THIEF NOT INTRODUCED BUT
  110. THFACT=.TRUE.
  111. C !IS ACTIVE.
  112. SWDACT=.FALSE.
  113. C !SWORD IS INACTIVE.
  114. SWDSTA=0
  115. C !SWORD IS OFF.
  116. C
  117. RECNO=1
  118. C !INIT DB FILE POINTER.
  119. MBASE=0
  120. C !INIT MELEE BASE.
  121. C LOGICAL UNIT NRS: 5=STDIN, 6=STDOUT
  122. INPCH=5
  123. C !TTY INPUT
  124. OUTCH=6
  125. DBCH=2
  126. C !DATA BASE.
  127. C INIT, PAGE 3
  128. C
  129. C INIT ALL ARRAYS.
  130. C
  131. DO 5 I=1,CMAX
  132. C !CLEAR CLOCK EVENTS
  133. CFLAG(I)=.FALSE.
  134. CTICK(I)=0
  135. CACTIO(I)=0
  136. 5 CONTINUE
  137. C
  138. DO 10 I=1,FMAX
  139. C !CLEAR FLAGS.
  140. FLAGS(I)=.FALSE.
  141. 10 CONTINUE
  142. BUOYF=.TRUE.
  143. C !SOME START AS TRUE.
  144. EGYPTF=.TRUE.
  145. CAGETF=.TRUE.
  146. MR1F=.TRUE.
  147. MR2F=.TRUE.
  148. FOLLWF=.TRUE.
  149. DO 12 I=1,SMAX
  150. C !CLEAR SWITCHES.
  151. SWITCH(I)=0
  152. 12 CONTINUE
  153. ORMTCH=4
  154. C !NUMBER OF MATCHES.
  155. LCELL=1
  156. PNUMB=1
  157. MDIR=270
  158. MLOC=MRB
  159. CPHERE=10
  160. C
  161. DO 15 I=1,R2MAX
  162. C !CLEAR ROOM 2 ARRAY.
  163. RROOM2(I)=0
  164. OROOM2(I)=0
  165. 15 CONTINUE
  166. C
  167. DO 20 I=1,XMAX
  168. C !CLEAR TRAVEL ARRAY.
  169. TRAVEL(I)=0
  170. 20 CONTINUE
  171. C
  172. DO 30 I=1,VMAX
  173. C !CLEAR VILLAINS ARRAYS.
  174. VOPPS(I)=0
  175. VPROB(I)=0
  176. VILLNS(I)=0
  177. VBEST(I)=0
  178. VMELEE(I)=0
  179. 30 CONTINUE
  180. C
  181. DO 40 I=1,OMAX
  182. C !CLEAR OBJECT ARRAYS.
  183. ODESC1(I)=0
  184. ODESC2(I)=0
  185. ODESCO(I)=0
  186. OREAD(I)=0
  187. OACTIO(I)=0
  188. OFLAG1(I)=0
  189. OFLAG2(I)=0
  190. OFVAL(I)=0
  191. OTVAL(I)=0
  192. OSIZE(I)=0
  193. OCAPAC(I)=0
  194. OCAN(I)=0
  195. OADV(I)=0
  196. OROOM(I)=0
  197. 40 CONTINUE
  198. C
  199. RDESC2=0
  200. C !CLEAR DESC BASE PTR.
  201. DO 50 I=1,RMAX
  202. C !CLEAR ROOM ARRAYS.
  203. RDESC1(I)=0
  204. RACTIO(I)=0
  205. RFLAG(I)=0
  206. RVAL(I)=0
  207. REXIT(I)=0
  208. 50 CONTINUE
  209. C
  210. DO 60 I=1,MMAX
  211. C !CLEAR MESSAGE DIRECTORY.
  212. RTEXT(I)=0
  213. 60 CONTINUE
  214. C
  215. DO 70 I=1,AMAX
  216. C !CLEAR ADVENTURER'S ARRAYS.
  217. AROOM(I)=0
  218. ASCORE(I)=0
  219. AVEHIC(I)=0
  220. AOBJ(I)=0
  221. AACTIO(I)=0
  222. ASTREN(I)=0
  223. AFLAG(I)=0
  224. 70 CONTINUE
  225. C
  226. DBGFLG=0
  227. PRSFLG=0
  228. C
  229. C allow setting gdtflg true if user id matches wizard id
  230. C this way, the wizard doesn't have to recompile to use gdt
  231. C
  232. C Changed by TAA so that always in wizard ID
  233. D gdtflg=1
  234. C
  235. FROMDR=0
  236. C !INIT SCOL GOODIES.
  237. SCOLRM=0
  238. SCOLAC=0
  239. C INIT, PAGE 4
  240. C
  241. C NOW RESTORE FROM EXISTING INDEX FILE.
  242. C
  243. OPEN(UNIT=1,file='/usr/share/games/dungeon/dindx.dat',
  244. & status='OLD',FORM='FORMATTED',ACCESS='SEQUENTIAL',ERR=1900)
  245. READ(1,130) I,J,K
  246. C !GET VERSION.
  247. IF((I.NE.VMAJ).OR.(J.NE.VMIN))
  248. & GO TO 1925
  249. OPEN(UNIT=DBCH,file='/usr/share/games/dungeon/dtext.dat',
  250. & status='OLD',FORM='UNFORMATTED',ACCESS='DIRECT',
  251. & recl=76,ERR=1950)
  252. D PRINT 150
  253. D150 FORMAT(' RESTORING FROM "dindx.dat"')
  254. READ(1,130) MXSCOR,STRBIT,EGMXSC
  255. READ(1,130) RLNT,RDESC2,RDESC1,REXIT,RACTIO,RVAL,RFLAG
  256. READ(1,130) XLNT,TRAVEL
  257. READ(1,130) OLNT,ODESC1,ODESC2,ODESCO,OACTIO,OFLAG1,OFLAG2,
  258. & OFVAL,OTVAL,OSIZE,OCAPAC,OROOM,OADV,OCAN,
  259. & OREAD
  260. READ(1,130) R2LNT,OROOM2,RROOM2
  261. READ(1,130) CLNT,CTICK,CACTIO
  262. READ(1,135) CFLAG
  263. READ(1,130) VLNT,VILLNS,VPROB,VOPPS,VBEST,VMELEE
  264. READ(1,130) ALNT,AROOM,ASCORE,AVEHIC,AOBJ,AACTIO,ASTREN,AFLAG
  265. READ(1,130) MBASE,MLNT,RTEXT
  266. C
  267. CLOSE(1)
  268. GO TO 1025
  269. C !INIT DONE.
  270. C
  271. C 130 FORMAT(I8)
  272. 130 FORMAT(I6)
  273. 135 FORMAT(L4)
  274. C INIT, PAGE 5
  275. C
  276. C THE INTERNAL DATA BASE IS NOW ESTABLISHED.
  277. C SET UP TO PLAY THE GAME.
  278. C
  279. 1025 CALL INTIME(SHOUR,SMIN,SSEC)
  280. C !GET TIME AND DATE.
  281. C CALL IDATE(I,J,K)
  282. C CALL IDATE(DATARRY(1))
  283. C CALL INIRND(or(DATARRY(1),or(DATARRY(2),DATARRY(3))),
  284. C & or(SHOUR,or(SMIN,SSEC)))
  285. C NEW WAY TO INITIALIZE /*TAA*/
  286. CALL INIRND(SHOUR*3600+SMIN*60+SSEC)
  287. C
  288. WINNER=PLAYER
  289. LASTIT=AOBJ(PLAYER)
  290. HERE=AROOM(WINNER)
  291. THFPOS=OROOM(THIEF)
  292. BLOC=OROOM(BALLO)
  293. INIT=.TRUE.
  294. C
  295. D PRINT 1050,RLNT,RMAX,XLNT,XMAX,OLNT,OMAX,MLNT,MMAX,
  296. D & VLNT,VMAX,ALNT,AMAX,CLNT,CMAX,R2LNT,R2MAX
  297. D1050 FORMAT(' USED:'/1X,I5,' OF',I5,' ROOMS'/
  298. D & 1X,I5,' OF',I5,' EXITS'/
  299. D & 1X,I5,' OF',I5,' OBJECTS'/
  300. D & 1X,I5,' OF',I5,' MESSAGES'/
  301. D & 1X,I5,' OF',I5,' VILLAINS'/
  302. D & 1X,I5,' OF',I5,' ADVENTURERS'/
  303. D & 1X,I5,' OF',I5,' CLOCK EVENTS'/
  304. D & 1X,I5,' OF',I5,' ROOM2 SLOTS')
  305. D PRINT 1150,MXSCOR,EGMXSC,RECNO,RDESC2,MBASE,STRBIT
  306. D1150 FORMAT(' MAX SCORE=',I5/' EG SCORE=',I5/
  307. D & ' MAX RECNO=',I5/' RDESC2 BASE=',I5/
  308. D & ' MELEE START=',I5/' STAR MASK=',I7)
  309. D PAUSE 1
  310. C
  311. RETURN
  312. C INIT, PAGE 6
  313. C
  314. C ERRORS-- INIT FAILS.
  315. C
  316. 1900 PRINT 910
  317. PRINT 980
  318. RETURN
  319. 1925 PRINT 920,I,J,K,VMAJ,VMIN,VEDIT
  320. PRINT 980
  321. RETURN
  322. 1950 PRINT 960
  323. PRINT 980
  324. RETURN
  325. 910 FORMAT(' I can''t open ','dindx.dat','.')
  326. 920 FORMAT(' "dindx.dat" is version ',I1,'.',I1,A1,'.'/
  327. & ' I require version ',I1,'.',I1,A1,'.')
  328. 960 FORMAT(' I can''t open ','dtext.dat','.')
  329. 980 FORMAT(' Suddenly a sinister, wraithlike figure appears before ',
  330. &'you,'/' seeming to float in the air. In a low, sorrowful voice',
  331. &' he says,'/' "Alas, the very nature of the world has changed, ',
  332. &'and the dungeon'/' cannot be found. All must now pass away."',
  333. &' Raising his oaken staff'/' in farewell, he fades into the ',
  334. &'spreading darkness. In his place'/' appears a tastefully ',
  335. &'lettered sign reading:'//23X,'INITIALIZATION FAILURE'//
  336. &' The darkness becomes all encompassing, and your vision fails.')
  337. C
  338. END
  339. C PROTCT-- CHECK FOR USER VIOLATION
  340. C
  341. C THIS ROUTINE SHOULD BE MODIFIED IF YOU WISH TO ADD SYSTEM
  342. C DEPENDANT PROTECTION AGAINST ABUSE.
  343. C
  344. C AT THE MOMENT, PLAY IS PERMITTED UNDER ALL CIRCUMSTANCES.
  345. C
  346. LOGICAL FUNCTION PROTCT(X)
  347. IMPLICIT INTEGER(A-Z)
  348. C
  349. PROTCT=.TRUE.
  350. RETURN
  351. END