home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume6 / ega-wanderer / part03 / help.c next >
C/C++ Source or Header  |  1989-02-14  |  8KB  |  349 lines

  1. #include "wand_head.h"
  2.  
  3. char *text1[]={
  4. /* 0  */ "      **  W A N D E R E R  **",
  5. /* 1  */ "    ===========================",
  6. /* 2  */ "        by Steven Shipway",
  7. /* 3  */ "How to play:",
  8. /* 4  */ " Collect all the treasure:    %*",
  9. /* 5  */ "",
  10. /* 6  */ " Then go through the exit:    %X",
  11. /* 7  */ "",
  12. /* 8  */ "  %h  Left       %j  Down",
  13. /* 9  */ "  %k  Up         %l  Right",
  14. /* 10 */ "  1  Loud       q  Quit game",
  15. /* 11 */ "  0  Quiet      v  Look at map",
  16. /* 12 */ "  S  Save game  R  Restore Game",
  17. /* 13 */ "  ?  Help mode  @  Center screen",
  18. /* 14 */ "  ~  Jump level #  Switch mode",
  19. /* 15 */ "     (no bonus) ^L Redraw screen",
  20. NULL
  21. },
  22.  
  23.      *text2[]={
  24. /* 0  */ "This is you:  You are a spider.",
  25. /* 1  */ "     %@        (At least, that's",
  26. /* 2  */ "              what you look like)",
  27. /* 3  */ "",
  28. /* 4  */ "The other items you will find are:",
  29. /* 5  */ "",
  30. /* 6  */ "  %#       %=",
  31. /* 7  */ "      and        Solid rock",
  32. /* 8  */ "  %C",
  33. /* 9  */ "         Time capsule (5 points,",
  34. /* 10 */ "        +250 extra moves)",
  35. /* 11 */ "   %:",
  36. /* 12 */ "        Passable earth (one point)",
  37. /* 13 */ "",
  38. /* 14 */ "  %T     Teleport  (50 points for",
  39. /* 15 */ "                  using it)",
  40. NULL
  41. },
  42.  
  43.      *text3[]={
  44. /* 0  */ "  %O     Boulder (falls down, other",
  45. /* 1  */ "        boulders and arrows fall",
  46. /* 2  */ "        off of it)",
  47. /* 3  */ "",
  48. /* 4  */ "  %<       %>    Arrows",
  49. /* 5  */ "      and      (fly left and right)",
  50. /* 6  */ "",
  51. /* 7  */ "  %+     Cage - holds baby monsters",
  52. /* 8  */ "        and changes into diamonds",
  53. /* 9  */ "",
  54. /* 10 */ "  %*      (10 points)",
  55. /* 11 */ "         Money  (collect it)",
  56. /* 12 */ "",
  57. /* 13 */ "  %S    Baby monster (kills you)",
  58. /* 14 */ "",
  59. NULL
  60. },
  61.  
  62.      *text4[]={
  63. /* 0  */ "When a baby monster hits a cage it",
  64. /* 1  */ "is captured and you get 50 points.",
  65. /* 2  */ "The cage also becomes a diamond.",
  66. /* 3  */ "",
  67. /* 4  */ " %!    Instant annihilation         ",
  68. /* 5  */ "",
  69. /* 6  */ "",
  70. /* 7  */ " %\\       %/     Slopes (boulders",
  71. /* 8  */ "     and       and etc. slide off)",
  72. /* 9  */ "",
  73. /* 10 */ " %M    Monster  (eats you up whole.",
  74. /* 11 */ "      Yum Yum yum..) (100 points)",
  75. /* 12 */ "      (kill with a rock or arrow)",
  76. /* 13 */ "",
  77. /* 14 */ " %X    Exit -- Must Collect all the",
  78. /* 15 */ "      treasure first. (250 bonus)",
  79. NULL
  80. },
  81.  
  82.      *text5[]={
  83. /* 0  */ " %^    Balloons rise and are popped",
  84. /* 1  */ "      by arrows.  It does not kill",
  85. /* 2  */ "      you.",
  86. /* 3  */ "",
  87. /* 4  */ "",
  88. /* 5  */ " %?    Unrecognised symbol in map.",
  89. /* 6  */ "      This is probably a **bug** !",
  90. /* 7  */ "",
  91. /* 8  */ " Environment variables:",
  92. /* 9  */ "",
  93. /* 10 */ "   NEWNAME,NAME : Checked in that",
  94. /* 11 */ "       order for the hiscore table",
  95. /* 12 */ "   NEWKEYS : Redefine movement keys",
  96. /* 13 */ "       (default \"hlkj\")",
  97. /* 14 */ "   SAVENAME : File used for saved",
  98. /* 15 */ "       games.",
  99. NULL
  100. };
  101.  
  102. char **texthelp[] ={ text1, text2, text3, text4, text5, NULL };
  103.  
  104. #ifdef    EGA
  105. #include "bitmap.h"
  106.  
  107. extern    bitmap    *b48x48[];
  108. extern    char    *EGAaddr;
  109.  
  110. char author1[] ="                            **  W A N D E R E R  **";
  111. char author2[] ="                               by Steven Shipway";
  112.  
  113. char *ega1[] ={
  114. author1,
  115. author2,
  116. "",
  117. "",
  118. "Environment variables:",
  119. "",
  120. "   NEWNAME,NAME,FULLNAME,USER,LOGNAME : Checked in that order for your name",
  121. "",
  122. "   NEWKEYS : Redefine movement keys (default \"hlkj\")",
  123. "",
  124. "   SAVENAME : File used for saved games",
  125. "",
  126. "",
  127. "",
  128. "How to play:",
  129. "                                %*                                    %X",
  130. "",
  131. "     Collect all the treasure:            then go through the exit:",
  132. "",
  133. "",
  134. "",
  135. "",
  136. "",
  137. "     Keys are:     %h   Left                  %j   Down",
  138. "                   %k   Up                    %l   Right",
  139. "                   1   Loud                  q   Quit game",
  140. "                   0   Quiet                 v   Look at map",
  141. "                   S   Save game             R   Restore game",
  142. "                   ?   Help                  @   Center screen",
  143. "                   ~   Jump level (lose      #   Switch mode",
  144. "                        bonus)               ^L  Redraw screen",
  145. NULL
  146. },
  147.  
  148.      *ega2[]={
  149. author1,
  150. author2,
  151. "",
  152. "Screen Items:",
  153. "                    %@",
  154. "",
  155. "     This is You:",
  156. "",
  157. "",
  158. "",
  159. "",
  160. "     The other items you will find are:",
  161. "",
  162. "             %#         %=                %:                   %!",
  163. "",
  164. "",
  165. "",
  166. "",
  167. "",
  168. "                Solid rock          Passable earth         Land mine",
  169. "                                      (1 point)",
  170. "",
  171. "",
  172. "         %*                    %X                          %C",
  173. "",
  174. "",
  175. "",
  176. "",
  177. "",
  178. "    Money - 10 points    Exit - 250 points       Time capsule - 5 points",
  179. "                         (collect all the           (250 extra moves)",
  180. "                         treasures first)",
  181. NULL
  182. },
  183.  
  184.      *ega3[]={
  185. author1,
  186. author2,
  187. "",
  188. "   %O                                           %^",
  189. "             Boulders (fall down,                        Balloons (rise up)",
  190. "             other boulders fall off,",
  191. "             arrows slide off)",
  192. "",
  193. "",
  194. "   %<        %>                            %\\        %/",
  195. "                     Arrows (fly left                      Slopes (boulders,",
  196. "                     and right, will                       balloons and arrows",
  197. "                     pop balloons)                         slide off)",
  198. "",
  199. "",
  200. "",
  201. "          %M                                    %S",
  202. "",
  203. "",
  204. "",
  205. "",
  206. "",
  207. "    Monster - 100 points               Baby monster - 50 points",
  208. "    (eats you up whole)                (kills you)",
  209. "",
  210. "    Kill with a rock or arrow          When baby monster hits a cage, it",
  211. "                                       is trapped and turns into a diamond",
  212. "",
  213. "          %T                                    %+",
  214. "                    Teleport                             Cage",
  215. "                    50 points for",
  216. "                    using it",
  217. NULL
  218. };
  219.  
  220. char **egahelp[] ={ ega1, ega2, ega3, NULL };
  221. #endif
  222.  
  223. /* remember locations of graphics symbols */
  224. struct    graphics
  225.     {
  226.     int    x, y, c;
  227.     }
  228.     coordinates[10], *nextcoordinate;
  229.  
  230. static char *blank = "                                          ";
  231.  
  232. static
  233. char *
  234. expand( y, line, keys )
  235. char *line;
  236. char *keys;
  237. {
  238.     static char expansion[100];
  239.     char *p;
  240.     int c;
  241.  
  242.     for( p = expansion; c = *line++; )
  243.         {
  244.         if ( c == '%' )
  245.             {
  246.             if ( (c = *line++) != '%' )
  247.                 switch( c )
  248.                     {
  249.                 case 'h': c = keys[2]; break;
  250.                 case 'j': c = keys[1]; break;
  251.                 case 'k': c = keys[0]; break;
  252.                 case 'l': c = keys[3]; break;
  253.                 default:
  254.                     nextcoordinate->y = y;
  255.                     nextcoordinate->x = p - expansion;
  256.                     nextcoordinate++->c = c;
  257.                     c = ' ';
  258.                     break;
  259.                     }
  260.             }
  261.  
  262.         *p++ = c;
  263.         }
  264.  
  265.     *p = '\0';
  266.  
  267.     return( expansion );
  268. }
  269.  
  270. static
  271. int
  272. dopage( page, keys )
  273. char **page;
  274. char *keys;
  275. {
  276.     struct graphics *p;
  277.     char *line;
  278.     int y;
  279.  
  280.     nextcoordinate = coordinates;
  281.  
  282. #ifdef    EGA
  283.     if (EGAaddr)
  284.         clear();
  285. #endif
  286.     for( y = 0; line = *page++; ++y )
  287.         {
  288.         line = expand( y, line, keys );
  289. #ifdef    EGA
  290.         if ( EGAaddr )
  291.             egaputs( 0, 10*y, line );
  292.         else
  293. #endif
  294.             mvprintw(y,0,"%-*s",ROWLEN+2,line);
  295.         }
  296.  
  297.     if ( nextcoordinate > coordinates )
  298.         for( p = coordinates; p < nextcoordinate; ++p )
  299. #ifdef    EGA
  300.             if ( EGAaddr )
  301.                 egapaint( 8*p->x, 10*p->y, b48x48[symbol(p->c)] );
  302.             else
  303. #endif
  304.                 draw_symbol( p->x-1, p->y-1, p->c );
  305.  
  306. #ifdef    EGA
  307.     if ( EGAaddr )
  308.         egaputs( 4+8*(80-44)/2, 341, "Press <return> to continue, <space> to exit." );
  309.     else
  310. #endif
  311.         {
  312.         while( y < 16 )
  313.             mvaddstr(y++,0,blank);
  314.  
  315.         mvaddstr(16,0,blank);
  316.         mvaddstr(16+1,0,"<return> to continue, <space> to exit     ");
  317.         }
  318.  
  319.     refresh();
  320.  
  321.     return( getch() );
  322. }
  323.  
  324. void
  325. helpme(keys)    /* routine to show help menu. */
  326. char *keys;
  327. {
  328.     char ***pages, **page;
  329.  
  330. #ifdef    EGA
  331.     if ( EGAaddr )
  332.         pages = egahelp;
  333.     else
  334. #endif
  335.         pages = texthelp;
  336.  
  337.     while( page = *pages++ )
  338.         if( dopage(page,keys) == ' ' )
  339.             break;
  340.  
  341. #ifdef    EGA
  342.     if ( ! EGAaddr )
  343. #endif
  344.         {
  345.         mvaddstr(16,0,blank);
  346.         mvaddstr(16+1,0,blank);
  347.         }
  348. }
  349.