dgame.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /* GAME- MAIN COMMAND LOOP FOR DUNGEON */
  2. /*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
  3. /* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
  4. /* WRITTEN BY R. M. SUPNIK */
  5. #include <stdio.h>
  6. #include "funcs.h"
  7. #include "vars.h"
  8. /* Do all systems have <string.h>? Don't use it, just in case */
  9. extern int strcmp P((const char *, const char *));
  10. static logical xvehic_ P((integer));
  11. static void xendmv_ P((logical));
  12. void game_()
  13. {
  14. /* Local variables */
  15. logical f;
  16. integer i;
  17. /* START UP, DESCRIBE CURRENT LOCATION. */
  18. rspeak_(1);
  19. /* !WELCOME ABOARD. */
  20. f = rmdesc_(3);
  21. /* !START GAME. */
  22. /* NOW LOOP, READING AND EXECUTING COMMANDS. */
  23. L100:
  24. play_1.winner = aindex_1.player;
  25. /* !PLAYER MOVING. */
  26. play_1.telflg = FALSE_;
  27. /* !ASSUME NOTHING TOLD. */
  28. if (prsvec_1.prscon <= 1) {
  29. rdline_(input_1.inbuf, 1);
  30. }
  31. #ifdef ALLOW_GDT
  32. if (strcmp(input_1.inbuf + prsvec_1.prscon - 1, "GDT") == 0) {
  33. /* !CALL ON GDT? */
  34. gdt_();
  35. /* !YES, INVOKE. */
  36. goto L100;
  37. /* !ONWARD. */
  38. }
  39. #endif /* ALLOW_GDT */
  40. ++state_1.moves;
  41. prsvec_1.prswon = parse_(input_1.inbuf, 1);
  42. if (! prsvec_1.prswon) {
  43. goto L400;
  44. }
  45. /* !PARSE LOSES? */
  46. if (xvehic_(1)) {
  47. goto L400;
  48. }
  49. /* !VEHICLE HANDLE? */
  50. if (prsvec_1.prsa == vindex_1.tellw) {
  51. goto L2000;
  52. }
  53. /* !TELL? */
  54. L300:
  55. if (prsvec_1.prso == oindex_1.valua || prsvec_1.prso == oindex_1.every) {
  56. goto L900;
  57. }
  58. if (! vappli_(prsvec_1.prsa)) {
  59. goto L400;
  60. }
  61. /* !VERB OK? */
  62. L350:
  63. if (! findex_1.echof && play_1.here == rindex_1.echor) {
  64. goto L1000;
  65. }
  66. f = rappli_(rooms_1.ractio[play_1.here - 1]);
  67. L400:
  68. xendmv_(play_1.telflg);
  69. /* !DO END OF MOVE. */
  70. if (! lit_(play_1.here)) {
  71. prsvec_1.prscon = 1;
  72. }
  73. goto L100;
  74. L900:
  75. valuac_(oindex_1.valua);
  76. goto L350;
  77. /* GAME, PAGE 3 */
  78. /* SPECIAL CASE-- ECHO ROOM. */
  79. /* IF INPUT IS NOT 'ECHO' OR A DIRECTION, JUST ECHO. */
  80. L1000:
  81. rdline_(input_1.inbuf, 0);
  82. ++state_1.moves;
  83. /* !CHARGE FOR MOVES. */
  84. if (strcmp(input_1.inbuf, "ECHO") != 0)
  85. goto L1300;
  86. rspeak_(571);
  87. /* !KILL THE ECHO. */
  88. findex_1.echof = TRUE_;
  89. objcts_1.oflag2[oindex_1.bar - 1] &= ~ SCRDBT;
  90. prsvec_1.prswon = TRUE_;
  91. /* !FAKE OUT PARSER. */
  92. prsvec_1.prscon = 1;
  93. /* !FORCE NEW INPUT. */
  94. goto L400;
  95. L1300:
  96. prsvec_1.prswon = parse_(input_1.inbuf, 0);
  97. if (! prsvec_1.prswon || prsvec_1.prsa != vindex_1.walkw) {
  98. goto L1400;
  99. }
  100. if (findxt_(prsvec_1.prso, play_1.here)) {
  101. goto L300;
  102. }
  103. /* !VALID EXIT? */
  104. L1400:
  105. more_output(input_1.inbuf);
  106. play_1.telflg = TRUE_;
  107. /* !INDICATE OUTPUT. */
  108. goto L1000;
  109. /* !MORE ECHO ROOM. */
  110. /* GAME, PAGE 4 */
  111. /* SPECIAL CASE-- TELL <ACTOR>, NEW COMMAND */
  112. /* NOTE THAT WE CANNOT BE IN THE ECHO ROOM. */
  113. L2000:
  114. if ((objcts_1.oflag2[prsvec_1.prso - 1] & ACTRBT) != 0) {
  115. goto L2100;
  116. }
  117. rspeak_(602);
  118. /* !CANT DO IT. */
  119. goto L350;
  120. /* !VAPPLI SUCCEEDS. */
  121. L2100:
  122. play_1.winner = oactor_(prsvec_1.prso);
  123. /* !NEW PLAYER. */
  124. play_1.here = advs_1.aroom[play_1.winner - 1];
  125. /* !NEW LOCATION. */
  126. if (prsvec_1.prscon <= 1) {
  127. goto L2700;
  128. }
  129. /* !ANY INPUT? */
  130. if (parse_(input_1.inbuf, 1)) {
  131. goto L2150;
  132. }
  133. L2700:
  134. i = 341;
  135. /* !FAILS. */
  136. if (play_1.telflg) {
  137. i = 604;
  138. }
  139. /* !GIVE RESPONSE. */
  140. rspeak_(i);
  141. L2600:
  142. play_1.winner = aindex_1.player;
  143. /* !RESTORE STATE. */
  144. play_1.here = advs_1.aroom[play_1.winner - 1];
  145. goto L350;
  146. L2150:
  147. if (aappli_(advs_1.aactio[play_1.winner - 1])) {
  148. goto L2400;
  149. }
  150. /* !ACTOR HANDLE? */
  151. if (xvehic_(1)) {
  152. goto L2400;
  153. }
  154. /* !VEHICLE HANDLE? */
  155. if (prsvec_1.prso == oindex_1.valua || prsvec_1.prso == oindex_1.every) {
  156. goto L2900;
  157. }
  158. if (! vappli_(prsvec_1.prsa)) {
  159. goto L2400;
  160. }
  161. /* !VERB HANDLE? */
  162. /* L2350: */
  163. f = rappli_(rooms_1.ractio[play_1.here - 1]);
  164. L2400:
  165. xendmv_(play_1.telflg);
  166. /* !DO END OF MOVE. */
  167. goto L2600;
  168. /* !DONE. */
  169. L2900:
  170. valuac_(oindex_1.valua);
  171. /* !ALL OR VALUABLES. */
  172. goto L350;
  173. } /* game_ */
  174. /* XENDMV- EXECUTE END OF MOVE FUNCTIONS. */
  175. /* DECLARATIONS */
  176. static void xendmv_(flag)
  177. logical flag;
  178. {
  179. /* Local variables */
  180. logical f;
  181. if (! (flag)) {
  182. rspeak_(341);
  183. }
  184. /* !DEFAULT REMARK. */
  185. if (hack_1.thfact) {
  186. thiefd_();
  187. }
  188. /* !THIEF DEMON. */
  189. if (prsvec_1.prswon) {
  190. fightd_();
  191. }
  192. /* !FIGHT DEMON. */
  193. if (hack_1.swdact) {
  194. swordd_();
  195. }
  196. /* !SWORD DEMON. */
  197. if (prsvec_1.prswon) {
  198. f = clockd_();
  199. }
  200. /* !CLOCK DEMON. */
  201. if (prsvec_1.prswon) {
  202. f = xvehic_(2);
  203. }
  204. /* !VEHICLE READOUT. */
  205. } /* xendmv_ */
  206. /* XVEHIC- EXECUTE VEHICLE FUNCTION */
  207. /* DECLARATIONS */
  208. static logical xvehic_(n)
  209. integer n;
  210. {
  211. /* System generated locals */
  212. logical ret_val;
  213. /* Local variables */
  214. integer av;
  215. ret_val = FALSE_;
  216. /* !ASSUME LOSES. */
  217. av = advs_1.avehic[play_1.winner - 1];
  218. /* !GET VEHICLE. */
  219. if (av != 0) {
  220. ret_val = oappli_(objcts_1.oactio[av - 1], n);
  221. }
  222. return ret_val;
  223. } /* xvehic_ */