dso7.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* ENCRYP-- ENCRYPT PASSWORD */
  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. void encryp_(inw, outw)
  9. const char *inw;
  10. char *outw;
  11. {
  12. /* Initialized data */
  13. const char *keyw = "ECORMS";
  14. integer i, j, uinw[6], usum;
  15. char ukeyw[1*6];
  16. integer uinws, ukeyws;
  17. /* Parameter adjustments */
  18. --outw;
  19. --inw;
  20. /* Function Body */
  21. uinws = 0;
  22. /* !UNBIASED INW SUM. */
  23. ukeyws = 0;
  24. /* !UNBIASED KEYW SUM. */
  25. j = 1;
  26. /* !POINTER IN KEYWORD. */
  27. for (i = 1; i <= 6; ++i) {
  28. /* !UNBIAS, COMPUTE SUMS. */
  29. ukeyw[i - 1] = (keyw[i - 1] - 64);
  30. if (inw[j] <= '@') {
  31. j = 1;
  32. }
  33. uinw[i - 1] = inw[j] - 64;
  34. ukeyws += ukeyw[i - 1];
  35. uinws += uinw[i - 1];
  36. ++j;
  37. /* L100: */
  38. }
  39. usum = uinws % 8 + (ukeyws % 8 << 3);
  40. /* !COMPUTE MASK. */
  41. for (i = 1; i <= 6; ++i) {
  42. j = (uinw[i - 1] ^ ukeyw[i - 1] ^ usum) & 31;
  43. usum = (usum + 1) % 32;
  44. if (j > 26) {
  45. j %= 26;
  46. }
  47. outw[i] = (max(1,j) + 64);
  48. /* L200: */
  49. }
  50. } /* encryp_ */
  51. /* CPGOTO-- MOVE TO NEXT STATE IN PUZZLE ROOM */
  52. /* DECLARATIONS */
  53. void cpgoto_(st)
  54. integer st;
  55. {
  56. /* System generated locals */
  57. integer i__1, i__2;
  58. /* Local variables */
  59. integer i;
  60. rooms_1.rflag[rindex_1.cpuzz - 1] &= ~ RSEEN;
  61. i__1 = objcts_1.olnt;
  62. for (i = 1; i <= i__1; ++i) {
  63. /* !RELOCATE OBJECTS. */
  64. if (objcts_1.oroom[i - 1] == rindex_1.cpuzz && (objcts_1.oflag2[i - 1]
  65. & ACTRBT + VILLBT) == 0) {
  66. i__2 = findex_1.cphere * hyper_1.hfactr;
  67. newsta_(i, 0, i__2, 0, 0);
  68. }
  69. if (objcts_1.oroom[i - 1] == st * hyper_1.hfactr) {
  70. newsta_(i, 0, rindex_1.cpuzz, 0, 0);
  71. }
  72. /* L100: */
  73. }
  74. findex_1.cphere = st;
  75. } /* cpgoto_ */
  76. /* CPINFO-- DESCRIBE PUZZLE ROOM */
  77. /* DECLARATIONS */
  78. void cpinfo_(rmk, st)
  79. integer rmk;
  80. integer st;
  81. {
  82. /* Initialized data */
  83. static const integer dgmoft[8] = { -9,-8,-7,-1,1,7,8,9 };
  84. const char *pict = "SSS M";
  85. /* Local variables */
  86. integer i, j, k, l;
  87. char dgm[1*8];
  88. rspeak_(rmk);
  89. for (i = 1; i <= 8; ++i) {
  90. j = dgmoft[i - 1];
  91. dgm[i - 1] = pict[puzzle_1.cpvec[st + j - 1] + 3];
  92. /* !GET PICTURE ELEMENT. */
  93. if (abs(j) == 1 || abs(j) == 8) {
  94. goto L100;
  95. }
  96. k = 8;
  97. if (j < 0) {
  98. k = -8;
  99. }
  100. /* !GET ORTHO DIR. */
  101. l = j - k;
  102. if (puzzle_1.cpvec[st + k - 1] != 0 && puzzle_1.cpvec[st + l - 1] !=
  103. 0) {
  104. dgm[i - 1] = '?';
  105. }
  106. L100:
  107. ;
  108. }
  109. more_output(NULL);
  110. printf(" |%c%c %c%c %c%c|\n", dgm[0], dgm[0], dgm[1], dgm[1],
  111. dgm[2], dgm[2]);
  112. more_output(NULL);
  113. printf(" West |%c%c .. %c%c| East\n", dgm[3], dgm[3], dgm[4], dgm[4]);
  114. more_output(NULL);
  115. printf(" |%c%c %c%c %c%c|\n", dgm[5], dgm[5], dgm[6], dgm[6],
  116. dgm[7], dgm[7]);
  117. if (st == 10) {
  118. rspeak_(870);
  119. }
  120. /* !AT HOLE? */
  121. if (st == 37) {
  122. rspeak_(871);
  123. }
  124. /* !AT NICHE? */
  125. i = 872;
  126. /* !DOOR OPEN? */
  127. if (findex_1.cpoutf) {
  128. i = 873;
  129. }
  130. if (st == 52) {
  131. rspeak_(i);
  132. }
  133. /* !AT DOOR? */
  134. if (puzzle_1.cpvec[st] == -2) {
  135. rspeak_(874);
  136. }
  137. /* !EAST LADDER? */
  138. if (puzzle_1.cpvec[st - 2] == -3) {
  139. rspeak_(875);
  140. }
  141. /* !WEST LADDER? */
  142. } /* cpinfo_ */