home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 2: PC / frozenfish_august_1995.bin / bbs / d07xx / d0787.lha / Scale / Source.lha / scale3.c < prev   
C/C++ Source or Header  |  1992-12-12  |  9KB  |  291 lines

  1. /* Program scale3.c  help() module, gives on-screen usage instructions  */
  2.  
  3. /*        ==> RECOMMENDED <==
  4. /* Set TAB value to 3 for this listing. */
  5.  
  6. /* Programmer:  Dick Taylor            November 1992 */
  7. /*              99 Valley View Rd, Glastonbury CT 06033 USA */
  8.  
  9. /* Please refer to file scale.doc for usage and background. */
  10.  
  11. #include "exec/types.h"
  12. #include "intuition/intuition.h"
  13.  
  14.  
  15.             /* Back Gadget for HELP screen */
  16.  
  17. SHORT back_box[] = {0,0,  39,0,  39,10,  0,10,  0,0};
  18.  
  19. struct Border back_border = {0,0,1,0,JAM1,5,back_box,NULL};
  20.  
  21. struct IntuiText back_text = {1,0,JAM1,4,2,NULL,"BACK",NULL};
  22.  
  23. struct Gadget back_gadget = {NULL,50,180,40,11,GADGHCOMP | GADGDISABLED,
  24.         GADGIMMEDIATE | RELVERIFY, BOOLGADGET,
  25.         &back_border,NULL,&back_text,NULL,NULL,0,NULL}; 
  26.  
  27.             /* Next Gadget for HELP screen */
  28.  
  29. SHORT next_box[] = {0,0,  39,0,  39,10,  0,10,  0,0};
  30.  
  31. struct Border next_border = {0,0,1,0,JAM1,5,next_box,NULL};
  32.  
  33. struct IntuiText next_text = {1,0,JAM1,4,2,NULL,"NEXT",NULL};
  34.  
  35. struct Gadget next_gadget = {&back_gadget,300,180,40,11,GADGHCOMP,
  36.         GADGIMMEDIATE | RELVERIFY, BOOLGADGET,
  37.         &next_border,NULL,&next_text,NULL,NULL,0,NULL}; 
  38.  
  39.             /* OK Gadget for HELP screen */
  40.  
  41. SHORT ok2_box[] = {0,0,  22,0,  22,10,  0,10,  0,0};
  42.  
  43. struct Border ok2_border = {0,0,1,0,JAM1,5,ok2_box,NULL};
  44.  
  45. struct IntuiText ok2_text = {1,0,JAM1,4,2,NULL,"OK",NULL};
  46.  
  47. struct Gadget ok2_gadget = {&next_gadget,550,180,23,11,GADGHCOMP,
  48.         GADGIMMEDIATE | RELVERIFY, BOOLGADGET,
  49.         &ok2_border,NULL,&ok2_text,NULL,NULL,0,NULL}; 
  50.  
  51. struct IntuiText inth_text = { 1,0,JAM2,16,9,NULL,
  52.         NULL,        /* IText */
  53.         NULL};
  54.  
  55. struct Window *hw;
  56. struct NewWindow nhw = {0,0,640,200,0,1, CLOSEWINDOW |GADGETUP,
  57.         SMART_REFRESH | WINDOWCLOSE | WINDOWDEPTH | 
  58.          ACTIVATE,NULL,NULL,
  59.         "HELP",NULL,NULL,140,50,640,200,WBENCHSCREEN};
  60.  
  61.  
  62. help()
  63. {
  64.  int i,j,go,smark,sline=0,eline,bline[5],hp=0;
  65.  struct IntuiMessage *msg;
  66. /* BOOL fin, list = TRUE;*/
  67.  BOOL fin, Next = FALSE, Back = FALSE;
  68.  ULONG class;
  69.  struct Gadget *address;
  70.  char *cp[] = {
  71. "            SCALE HELP -- 1/5   Initial Display Tutorial",
  72. "",
  73. "On startup, the SCALE display shows a simple scale in the key of C,", 
  74. "starting at middle C, ascending for 1 octave.  Click PLAY button at",
  75. "screen lower right to play it.",
  76. "",  
  77. "This plays at Tempo of .50 sec. note duration, a slow pace.  Use the",
  78. "Tempo slider just above PLAY to vary the tempo between .50 (slowest)",
  79. "and .10 sec. (fastest).",
  80. "",
  81. "Each click of PLAY plays the scale once.  Click on the 'Cycle' button",
  82. "above Tempo for 'Y'.  Then click on PLAY to play the scale over and over.",
  83. "Click on 'STOP Play' to stop.  Click on Cycle again for 'N', and it's",
  84. "back in single-play mode.",
  85. "",
  86. "In the table, the line for Channel 0 shows details for this scale.  The",
  87. "enclosing orange box shows that channel 0 is selected.",
  88. "   N = starting Note.  Click this box to cycle CDEFGABC...",
  89. "   O = Octave.  Click this box to cycle 1234561...  1 = low; 6 = high",
  90. "   T = relative Time value.  Details on a following screen",
  91. "zzz",                        /* End of page marker */
  92.  
  93. "               SCALE HELP -- 2/5      Initial Display 2",
  94. "",
  95. "For control of 'ADR+' entries, use the ADR+ Edit box below the table.",
  96. "Click once on ADR+ button, showing 'D1' in the table.  Now click PLAY,",
  97. "and it plays a descending scale of 1 octave.  Click ADR+ 3 more times,",
  98. "restoring 'A1'.",
  99. "",
  100. "Now click '1-4' button, showing 'A2' in the table.  Now click PLAY for a",
  101. "2-octave ascending scale.  Clicks on '1-4' cycle 12341...",
  102. "",
  103. "More on ADR+ Edit on following screens.",
  104. "",
  105. "You can change the key of the scale by click on 'Key', cycles CDEFGABC...",
  106. "You can make the key sharp (#) or flat (b) by clicking the adjacent",
  107. "button, cycles _#b_...",
  108. "",
  109. "         *****End of tutorial for initial display*****",
  110. "",
  111. "           ===> Three more HELP screens follow <===",
  112. "zzz",                        /* End of page marker */
  113.  
  114. "                    SCALE HELP -- 3/5     General",
  115. "",
  116. "We can play scales on 4 channels--0, 1, 2, 3.  Can play 1 scale alone on",
  117. "any channel, or any combination of channels for 2, 3, 4 scales at once.",
  118. "",
  119. "Back to the table -- more on control boxes to click on:",
  120. "   Chan = select Channel 0,1,2,3.  Orange box shows selected channel.",
  121. "          All other channel controls then apply to this channel.",
  122. "   Clear = Clear this channel.  Use this to erase an unwanted channel.",
  123. "   T = Time.  Click to cycle 1/1, 1/2, 1/4.",
  124. "       1/1 = Base time, note duration set by the Tempo slider.",
  125. "       1/2 = Twice as fast as 1/1,  1/4 = Four times 1/1.",
  126. "",
  127. "               ADR+ Edit",
  128. "",
  129. "We saw in screen 2 that ADR+ can be used to make an ascending or descending",
  130. "scale, of 1, 2, 3, or 4 octaves; for example 'A2' = ascend 2 octaves.  Call",
  131. "this item a 'step'.  For each channel we can use up to a maximum of 14",
  132. "steps.",
  133. "zzz",                /* End of page marker */
  134.  
  135. "                   SCALE HELP -- 4/5     ADR+ Edit cont'd.",
  136. "",
  137. "Besides A and D (ascending, descending), there are 2 more possibilities:",
  138. "",
  139. "    R -- Rest, don't play this channel.  For example: R2 means this",
  140. "         channel rests while 2 octaves are played on another channel.",
  141. "    + -- repeat this channel from step 1.  Use this following 1 or more",
  142. "         A/D/R steps, so that this channel will loop while another channel",
  143. "         with more steps is still playing.  Can use for a 'counterpoint'",
  144. "         effect.  There is no count field associated with +.",
  145. "",
  146. "Following the ADR+ box, there is the count (1-4) box.  Click in this box",
  147. "to cycle 12341... to select the desired count for A, D, R.",
  148. "",
  149. "Note the underline pointer (^^) in the ADR+ step for the selected channel.",
  150. "This pointer shows which ADR+ step is currently selected for edit.  You",
  151. "can move this pointer to left or right by --",
  152. "",
  153. "     > box -- move underline pointer to right. If at end, adds new step.",
  154. "     < box -- move underline pointer to left",
  155. "zzz",                /* End of page marker */
  156.  
  157. "                SCALE HELP 5/5         ADR+ Edit  cont'd.",
  158. "",
  159. "Two more controls add flexibility to the ADR+ Editing:",
  160. "",
  161. "    Insert -- place a new step at the pointer, initialized A1."
  162. "              No insert if already have 14 steps.",
  163. "",
  164. "    Delete -- remove step at the pointer.",
  165. "              No delete if pointer at position 1, no steps to right.",
  166. "",
  167. "You can get acquainted with the SCALE program by running the examples",
  168. "in the directory 'Start'.  Load these using Menu 'Load'.",
  169. "",
  170. "After viewing this on-screen Help material, you may find additional",
  171. "material of interest in the accompanying doc file.",
  172. "",
  173. "When you start making your own examples, don't forget to preserve the",
  174. "better ones by using the Menu 'Save' operation.  Enjoy!!!",
  175. "{{{"};                        /* End of text marker */
  176.  
  177. /* Open new window for help() */
  178.  hw = (struct Window *) OpenWindow(&nhw);
  179.  if (hw == NULL)
  180.  {
  181.     printf ("Error in scale3 -- can't open HELP window.\n");
  182.     return();
  183.  }
  184.  
  185. /* AddGadget(hw,&back_gadget,0);
  186.  AddGadget(hw,&next_gadget,0);*/
  187.  AddGadget(hw,&ok2_gadget,0);
  188.  RefreshGadgets(&ok2_gadget,hw,NULL);
  189.  
  190.  fin = FALSE;
  191.  while (!fin)
  192.  {
  193.     go = TRUE;
  194.     i = sline;        /* start-line */
  195.     j = 0;
  196.  
  197.     while (go)
  198.     {
  199.             eline = i;
  200.                             /* "zzz" is end-of-page marker (smark = 0) */
  201.                             /* "{{{" is end-of-text marker (smark < 0) */
  202.             smark = strcmp("zzz",cp[i]);
  203.             if (smark <= 0)
  204.                 go = FALSE;
  205.             else
  206.                 { inth_text.IText = cp[i];
  207.                     PrintIText(hw->RPort,&inth_text,0,j*8);
  208.                   ++i;  ++j;
  209.                 }
  210.      }                /* on exit while loop, eline contains end-line # */
  211.  
  212. /*    OnGadget(&ok2_gadget,hw,NULL);        /* OK (= exit) is always on */
  213.  
  214.     if (smark < 0)                    /* Last page -- drop Next if in place  */
  215.     {
  216.         if (Next)
  217.         {    RemoveGadget (hw,&next_gadget);
  218.             Next = FALSE;
  219.         }
  220.     }
  221.     else if (!Next)        /* Not last page -- add Next if not in place*/
  222.             {    AddGadget (hw,&next_gadget,-1);
  223.                 Next = TRUE;
  224.             }
  225.  
  226.     if (hp == 0)                    /* First page -- drop Back if in place */
  227.     {
  228.         if (Back)
  229.         {    RemoveGadget (hw,&back_gadget);
  230.             Back = FALSE;
  231.         }
  232.     }
  233.     else if (!Back)            /* Not first page -- add Back if not in place*/
  234.             {    AddGadget(hw,&back_gadget,-1);
  235.                 OnGadget(&back_gadget,hw,NULL);
  236.                 Back = TRUE;
  237.             }
  238.  
  239.     RefreshGadgets(&ok2_gadget,hw,NULL);
  240.  
  241.     Wait(1 << hw->UserPort->mp_SigBit);
  242.     while (msg = (struct IntuiMessage *) GetMsg(hw->UserPort))
  243.     {
  244.         class = msg->Class;
  245.         address = msg->IAddress;
  246.         ReplyMsg(msg);
  247.  
  248.         switch(class)
  249.         {
  250.             case CLOSEWINDOW:
  251.                 Clear_Screen();
  252.                 return(1);            /* return 1 = close window */
  253.             case GADGETUP:
  254.                 if (address == &ok2_gadget)        /* OK = exit */
  255.                 {    Clear_Screen();
  256.                     RemoveGadget(hw,&back_gadget);
  257.                     RemoveGadget(hw,&next_gadget);
  258.                     RemoveGadget(hw,&ok2_gadget);
  259.                     fin = TRUE;
  260.                 }
  261.                 else if (address == &next_gadget)
  262.                 {
  263.                     Clear_Screen();
  264.                     bline[hp++] = sline;        /* save curr start-line for "back" */
  265.                     sline = eline + 1;        /* new start-line = end-line + 1 */
  266.                 }
  267.                 else if (address == &back_gadget)
  268.                 {
  269.                     Clear_Screen();
  270.                     sline = bline[--hp];        /* new start-line from back-line arr*/
  271.                 }
  272.                 break;
  273.         }    /* end switch(class) */
  274.     }        /* end while (msg ...) */
  275.  }            /* End while (!fin) */
  276.  
  277.  CloseWindow(hw);
  278.  return(0);
  279. }
  280.  
  281. Clear_Screen()
  282. {
  283.  static int i;
  284.  char *spaces = 
  285. "                                                                           ";
  286.  
  287.  inth_text.IText = spaces;
  288.  for (i = 0; i < 23; ++i)
  289.     PrintIText(hw->RPort,&inth_text,0,i*8);
  290. }
  291.