home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / misc2 / mickiano.lzh / MICKIANO.C < prev    next >
Text File  |  1990-11-04  |  47KB  |  1,581 lines

  1.  /*
  2.              Mickiano.c
  3.  
  4.              written by Bill Buckels in Large Model Microsoft C
  5.  
  6.  */
  7.  
  8.  
  9. /* opening song */
  10. /* musical array created from file ENTERTAN.SND */
  11. /* array structure is frequency,duration */
  12. int ENTERTAN[]={
  13.   587,  2,32767,  1,  623,  2,32767,  1,  659,  2,32767,  1,
  14.  1046,  5,32767,  1,  659,  2,32767,  1, 1046,  5,32767,  1,
  15.   659,  2,32767,  1, 1046,  8,32767,  1,32767,  5,32767,  1,
  16. 32767,  2,32767,  1, 1046,  2,32767,  1, 1175,  2,32767,  1,
  17.  1247,  2,32767,  1, 1318,  2,32767,  1, 1046,  2,32767,  1,
  18.  1175,  2,32767,  1, 1318,  5,32767,  1,  988,  2,32767,  1,
  19.  1175,  5,32767,  1, 1046,  5,32767,  1,32767,  5,32767,  1,
  20. 32767,  5,32767,  1,  587,  2,32767,  1,  623,  2,32767,  1,
  21.   659,  2,32767,  1, 1046,  5,32767,  1,  659,  2,32767,  1,
  22.  1046,  5,32767,  1,  659,  2,32767,  1, 1046,  8,32767,  1,
  23. 32767,  5,32767,  1,32767,  5,32767,  1,  880,  2,32767,  1,
  24.   784,  2,32767,  1,  741,  2,32767,  1,  880,  2,32767,  1,
  25.  1046,  2,32767,  1, 1318,  5,32767,  1, 1175,  2,32767,  1,
  26.  1046,  2,32767,  1,  880,  2,32767,  1, 1175,  5,32767,  1,
  27. 32767,  5,32767,  1,32767,  5,32767,  1,  587,  2,32767,  1,
  28.   623,  2,32767,  1,  659,  2,32767,  1, 1046,  5,32767,  1,
  29.   659,  2,32767,  1, 1046,  5,32767,  1,  659,  2,32767,  1,
  30.  1046,  8,32767,  1,32767,  5,32767,  1,32767,  5,32767,  1,
  31.  1046,  2,32767,  1, 1175,  2,32767,  1, 1247,  2,32767,  1,
  32.  1318,  2,32767,  1, 1046,  2,32767,  1, 1175,  2,32767,  1,
  33.  1318,  5,32767,  1,  988,  2,32767,  1, 1175,  5,32767,  1,
  34.  1046,  5,32767,  1,32767,  5,32767,  1,32767,  5,32767,  1,
  35.  1046,  2,32767,  1, 1175,  2,32767,  1, 1318,  2,32767,  1,
  36.  1046,  2,32767,  1, 1175,  2,32767,  1, 1318,  5,32767,  1,
  37.  1046,  2,32767,  1, 1175,  2,32767,  1, 1046,  2,32767,  1,
  38.  1318,  2,32767,  1, 1046,  2,32767,  1, 1175,  2,32767,  1,
  39.  1318,  5,32767,  1, 1046,  2,32767,  1, 1175,  2,32767,  1,
  40.  1046,  2,32767,  1, 1318,  2,32767,  1, 1046,  2,32767,  1,
  41.  1175,  2,32767,  1, 1318,  5,32767,  1,  988,  2,32767,  1,
  42.  1318,  5,32767,  1, 1046,  5,32767,  1,-1,-1};
  43.  
  44.  
  45. /* closing song */
  46. /* musical array created from file MAPLE.SND */
  47. /* array structure is frequency,duration */
  48. int MAPLE[]={
  49.   392,  1,32767,  1,  467,  1,32767,  1,  312,  1,32767,  1,
  50.   392,  1,32767,  1,  467,  3,32767,  1,  294,  1,32767,  1,
  51.   467,  1,32767,  1,  294,  1,32767,  1,  349,  1,32767,  1,
  52.   467,  1,32767,  1,  467,  8,32767,  1,32767,  1,32767,  1,
  53.   392,  1,32767,  1,  467,  1,32767,  1,  312,  1,32767,  1,
  54.   392,  1,32767,  1,  467,  3,32767,  1,  294,  1,32767,  1,
  55.   467,  1,32767,  1,  294,  1,32767,  1,  349,  1,32767,  1,
  56.   467,  2,  467,  4,  467,  4,  494,  4,  467,  4,  467,  4,
  57.   467,  4,  494,  9,  467,  4,  467,  4,32767,  4,  312,  4,
  58.   371,  4,  467,  4,  371,  4,  312,  4,  371,  4,  467,  4,
  59.   623,  4,  623,  4,  623,  4,  623,  2,  623,  4,  467,  2,
  60.   523,  2,  392,  2,  467,  2,  523,  4,  312,  4,  349,  2,
  61.   371,  2,  312,  2,  349,  2,  392,  4,  312,  2,  392,  2,
  62.   312,  2,  349,  4,  312,  4,  623,  2,  623,  4,  623,  4,
  63.   623,  4,  623,  2,  623,  4,  467,  2,  523,  2,  392,  2,
  64.   467,  2,  523,  4,  312,  2,  312,  2,  349,  2,  371,  2,
  65.   312,  2,  349,  2,  392,  4,  312,  2,  392,  2,  312,  2,
  66.   349,  4,  312,  4,-1,-1};
  67.  
  68.  
  69.  
  70.  
  71.  
  72. /* some embedded musical data if no external files */
  73.  
  74. int danube[]=
  75. {
  76. 294,4,371,4,441,4,441,4,32767,4,882,2,32767,2,882,2,
  77. 32767,6,742,2,32767,2,742,2,32767,6,294,4,294,4,371,4,
  78. 441,4,441,4,32767,4,882,2,32767,2,882,2,32767,6,786,2,
  79. 32767,2,786,2,32767,6,278,4,278,4,330,4,495,4,495,4,
  80. 32767,4,990,2,32767,2,990,2,32767,6,786,2,32767,2,786,2,
  81. 32767,6,278,4,278,4,330,4,495,4,495,4,32767,4,990,2,
  82. 32767,2,990,2,32767,6,742,2,32767,2,742,2,32767,6,294,4,
  83. 294,4,371,4,441,4,589,4,32767,4,1178,2,32767,2,1178,2,
  84. 32767,6,882,2,32767,2,882,2,32767,6,294,4,294,4,371,4,
  85. 441,4,589,4,32767,4,1178,2,32767,2,1178,2,32767,6,990,2,
  86. 32767,2,990,2,32767,6,330,4,330,4,393,4,495,2,32767,2,
  87. 495,14,32767,2,416,4,441,4,742,16,589,4,371,4,371,8,
  88. 330,4,495,8,441,4,294,4,32767,2,294,2,294,4,32767,8,
  89. 441,2,32767,2,393,2,32767,6,441,2,32767,2,393,2,32767,6,
  90. 441,4,742,16,661,4,441,2,32767,2,371,2,32767,6,441,2,
  91. 32767,2,371,2,32767,6,441,4,661,16,589,4,441,2,32767,2,
  92. 393,2,32767,6,441,2,32767,2,393,2,32767,6,441,4,742,16,
  93. 661,4,441,4,589,4,661,4,742,4,882,8,786,4,742,2,
  94. 742,2,742,4,661,2,32767,2,589,4,32767,8,-1,-1
  95. /* the blue danube walz -strauss */
  96. };
  97.  
  98. int dvorak[]=
  99. {
  100. 393,3,32767,2,441,1,393,3,32767,2,441,1,495,3,32767,2,
  101. 589,1,661,3,32767,2,589,1,786,3,32767,2,742,1,882,3,
  102. 32767,2,786,1,742,3,32767,2,882,1,786,3,32767,2,661,1,
  103. 589,3,32767,2,589,1,661,3,32767,2,589,1,786,3,32767,2,
  104. 661,1,589,3,32767,2,495,1,441,24,393,3,32767,2,441,1,
  105. 393,3,32767,2,441,1,495,3,32767,2,589,1,661,3,32767,2,
  106. 589,1,661,3,32767,2,742,1,882,3,32767,2,786,1,742,3,
  107. 32767,2,882,1,786,3,32767,2,661,1,589,3,32767,2,589,1,
  108. 786,3,32767,2,393,1,441,6,589,6,393,18,-1,-1
  109. /* humoresque by dvorak */
  110. };
  111.  
  112. int guonod[]=
  113. {
  114. 221,1,32767,2,147,1,32767,5,294,3,294,3,278,3,248,3,
  115. 278,3,32767,3,294,3,330,3,32767,3,221,1,32767,2,147,1,
  116. 32767,5,294,3,294,3,278,3,248,3,278,3,32767,3,294,3,
  117. 330,3,32767,3,221,3,294,3,32767,3,350,3,441,6,393,3,
  118. 350,3,32767,3,441,3,525,6,467,3,441,3,32767,3,556,3,
  119. 661,6,589,3,556,3,467,3,441,3,393,3,350,3,330,3,
  120. 147,1,32767,5,294,3,294,3,278,3,248,3,278,3,32767,3,
  121. 294,3,330,3,32767,3,221,1,32767,2,147,1,32767,5,294,3,
  122. 294,3,278,3,248,3,278,3,32767,3,294,3,330,3,32767,3,
  123. 221,3,350,3,32767,3,441,3,525,6,467,3,441,3,393,3,
  124. 350,3,312,3,393,3,467,3,294,3,278,3,294,3,330,3,
  125. 32767,3,350,1,32767,2,330,9,294,1,-1,-1
  126. /* funeral march of a marionette by guonod */
  127. };
  128.  
  129. int mexico[]=
  130. {
  131. 525,2,700,2,32767,2,525,2,700,2,32767,2,525,2,700,6,
  132. 32767,4,525,2,700,2,786,2,700,2,661,4,700,2,786,2,
  133. 32767,8,525,2,661,2,32767,2,525,2,661,2,32767,2,525,2,
  134. 661,6,32767,4,525,2,661,2,700,2,661,2,589,4,661,2,
  135. 700,2,32767,6,1049,2,990,2,1049,2,882,2,833,2,882,2,
  136. 700,2,661,2,700,2,525,2,32767,4,441,2,467,2,525,2,
  137. 589,2,661,2,700,2,786,2,882,2,935,2,786,2,32767,4,
  138. 935,2,882,2,935,2,786,2,742,2,786,2,661,2,624,2,
  139. 661,2,525,2,32767,4,1049,2,990,2,1049,2,1178,2,1049,2,
  140. 935,2,882,2,786,2,700,2,-1,-1
  141. /* mexican hat dance */
  142. };
  143.  
  144. int mozart[]=
  145. {
  146. 624,2,589,2,589,4,624,2,589,2,589,4,624,2,589,2,
  147. 589,4,935,4,32767,4,935,2,882,2,786,4,786,2,700,2,
  148. 624,4,624,2,589,2,525,4,525,4,32767,4,589,2,525,2,
  149. 525,4,589,2,525,2,525,4,589,2,525,2,525,4,882,4,
  150. 32767,4,882,2,786,2,742,4,742,2,624,2,589,4,589,2,
  151. 525,2,467,4,467,4,32767,4,935,2,882,2,882,4,1049,4,
  152. 742,4,882,4,786,4,589,4,32767,4,935,2,882,2,882,4,
  153. 1049,4,742,4,882,4,786,4,935,4,882,2,786,2,700,2,
  154. 624,2,589,4,371,4,393,4,441,4,467,4,525,2,467,2,
  155. 441,4,393,4,589,4,32767,4,1112,8,1178,2,32767,6,1112,8,
  156. 1178,2,32767,6,1112,8,1178,4,1112,4,1178,4,1112,4,1178,4,-1,-1
  157. /* symphony #40 by wolfgang mozart */
  158. };
  159.  
  160. int sam[]=
  161. {
  162. 523,3,32767,1,523,3,32767,1,587,3,32767,1,659,3,32767,1,
  163. 523,3,32767,1,659,3,32767,1,587,3,32767,1,392,3,32767,1,
  164. 523,3,32767,1,523,3,32767,1,587,3,32767,1,659,3,32767,1,
  165. 523,6,32767,1,392,6,32767,2,523,3,32767,1,523,3,32767,1,
  166. 587,3,32767,1,659,3,32767,1,698,3,32767,1,659,3,32767,1,
  167. 587,3,32767,1,523,3,32767,1,493,3,32767,1,493,3,32767,1,
  168. 440,3,32767,1,493,3,32767,1,523,6,32767,1,523,6,32767,3,-1,-1
  169. /* yankee doodle */
  170. };
  171.  
  172. int stars[]=
  173. {
  174. 589,6,589,6,525,3,495,3,495,6,467,3,495,3,495,16,32767,2,
  175. 467,3,495,3,495,6,467,3,495,3,589,6,495,3,589,3,525,12,
  176. 441,6,32767,3,441,3,441,6,416,3,441,3,441,6,416,3,441,3,
  177. 525,16,32767,2,495,3,441,3,495,3,589,9,661,9,661,3,441,16,
  178. 32767,2,589,6,589,6,525,3,495,3,495,6,467,3,495,3,495,16,
  179. 32767,2,467,3,495,3,495,6,467,3,495,3,525,3,495,3,441,5,
  180. 371,1,441,12,393,6,32767,3,393,3,393,6,371,3,393,3,467,6,
  181. 441,3,393,3,786,15,32767,3,393,3,441,3,495,3,589,1,32767,2,
  182. 393,3,441,3,495,3,589,1,32767,2,294,3,330,5,495,1,441,12,393,1,
  183. -1,-1
  184. /* the stars and stripes forever
  185.    john p. sousa  */
  186. };
  187.  
  188. int bug[]=
  189. {
  190. 294,1,32767,1,294,1,32767,1,294,1,32767,1,393,1,32767,5,
  191. 495,1,32767,3,294,1,32767,1,294,1,32767,1,294,1,32767,1,
  192. 393,1,32767,5,495,1,32767,5,147,1,32767,1,147,1,32767,1,
  193. 196,1,32767,3,393,1,32767,1,393,1,32767,1,371,1,32767,1,
  194. 371,1,32767,1,330,1,32767,1,330,1,32767,1,294,8,32767,2,
  195. 294,1,32767,1,294,1,32767,1,294,1,32767,1,371,1,32767,5,
  196. 441,1,32767,3,294,1,32767,1,294,1,32767,1,294,1,32767,1,
  197. 371,1,32767,5,441,1,32767,5,221,1,32767,1,221,1,32767,1,
  198. 147,1,32767,3,589,2,661,2,589,2,525,2,495,2,441,2,393,8,-1,-1
  199. /* archie and mehitabel's lovesong */
  200. };
  201.  
  202. int weasel[]=
  203. {
  204. 393,2,32767,2,393,2,441,2,32767,2,441,2,495,2,589,2,
  205. 495,2,393,2,32767,2,294,2,393,2,32767,2,393,2,441,2,
  206. 32767,2,441,2,495,6,393,2,32767,2,294,2,393,2,32767,2,
  207. 393,2,441,2,32767,2,441,2,495,2,589,2,495,2,393,2,
  208. 32767,4,661,2,32767,4,441,2,32767,2,525,2,495,6,393,2,
  209. 32767,4,786,2,32767,2,786,2,661,2,32767,2,786,2,742,2,
  210. 882,2,742,2,589,2,32767,4,786,2,32767,2,786,2,661,2,
  211. 32767,2,786,2,742,6,589,2,32767,2,495,2,525,2,32767,2,
  212. 495,2,525,2,32767,2,589,2,661,2,32767,2,742,2,786,2,
  213. 32767,4,661,2,32767,4,441,2,32767,2,525,2,495,6,393,2,-1,-1
  214. /* popgoestheweasel */
  215. };
  216.  
  217. char *internal_tunes[]={
  218.       "DANUBE",
  219.       "DVORAK",
  220.       "GUONOD",
  221.       "MEXICO",
  222.       "MOZART",
  223.       "STARS",
  224.       "SAM",
  225.       "BUG",
  226.       "WEASEL"};
  227.  
  228. #include <stdio.h>
  229. #include <dos.h>
  230. #include <graph.h>
  231. #include <conio.h>
  232. #include <string.h>
  233. #include <malloc.h>
  234.  
  235. /* note frequency data */
  236.  
  237. int notefrequency[7][12]={
  238.  
  239. /* C           D           E     F           G           A           B  */
  240. /* 0     1     2     3     4     5     6     7    8      9     10    11 */
  241. /* W     B     W     B     W     W     B     W    B      W     B     W  */
  242.    65,   69,   73,   78,   82,   87,   93,   98,  104,  110,  117,  123,
  243.   131,  139,  147,  156,  165,  175,  185,  196,  208,  220,  233,  247,
  244.   262,  278,  294,  312,  330,  349,  371,  392,  416,  440,  467,  494,
  245.   523,  555,  587,  623,  659,  698,  741,  784,  832,  880,  934,  988,
  246.  1046, 1111, 1175, 1247, 1318, 1397, 1482, 1568, 1664, 1760, 1868, 1976,
  247.  2093, 2221, 2349, 2493, 2637, 2794, 2965, 3136, 3328, 3520, 3736, 3951,
  248.  4186, 4442, 4699, 4986, 5274, 5588, 5930, 6272, 6656, 7040, 7471, 7902};
  249.  
  250.  
  251. int WHITES[21][6]={
  252.  
  253. /*    x1  y1  x2 y2   octave note*/
  254.       2,  60, 17,140, 1,  0,
  255.       18, 60, 32,140, 1,  2,
  256.       33, 60, 47,140, 1,  4,
  257.       48, 60, 62,140, 1,  5,
  258.       63, 60, 77,140, 1,  7,
  259.       78, 60, 92,140, 1,  9,
  260.       93, 60,107,140, 1,  11,
  261.       108,60,122,140, 2,  0,
  262.       123,60,137,140, 2,  2,
  263.       138,60,152,140, 2,  4,
  264.       153,60,167,140, 2,  5,
  265.       168,60,182,140, 2,  7,
  266.       183,60,197,140, 2,  9,
  267.       198,60,212,140, 2,  11,
  268.       213,60,227,140, 3,  0,
  269.       228,60,242,140, 3,  2,
  270.       243,60,257,140, 3,  4,
  271.       258,60,272,140, 3,  5,
  272.       273,60,287,140, 3,  7,
  273.       288,60,302,140, 3,  9,
  274.       303,60,317,140, 3,  11};
  275.  
  276. int BLACKS[15][6]={
  277.       13, 60,23, 105, 1,  1,
  278.       28, 60,38, 105, 1,  3,
  279.  
  280.       58, 60,68, 105, 1,  6,
  281.       73, 60,83, 105, 1,  8,
  282.       88, 60,98, 105, 1,  10,
  283.  
  284.       118,60,128,105, 2,  1,
  285.       133,60,143,105, 2,  3,
  286.  
  287.       163,60,173,105, 2,  6,
  288.       178,60,188,105, 2,  8,
  289.       193,60,203,105, 2,  10,
  290.  
  291.       223,60,233,105, 3,  1,
  292.       238,60,248,105, 3,  3,
  293.  
  294.       268,60,278,105, 3,  6,
  295.       283,60,293,105, 3,  8,
  296.       298,60,308,105, 3,  10 };
  297.  
  298. int QUITBOX[]={ 272,176,319,199};
  299. int FLIPBOX[]={ 0,  141,159,199};
  300.  
  301. #define TRUE  1
  302. #define FALSE 0
  303. int whitekey=TRUE;
  304.  
  305.  
  306. int keyplay(int i)
  307. {
  308.     /* input is note frequency       */
  309.     /* returns position on the piano */
  310.  
  311.   whitekey = TRUE;
  312.  
  313.   /* note is not in range */
  314.   if(i<64) return -1;
  315.   if(i>4096)return -1;
  316.  
  317.   /* octave 0 */
  318.   if(i<127)
  319.   {
  320.   if(i<67 ) return  14;
  321.   if(i<71 ) { whitekey = FALSE;return  10;}
  322.   if(i<76 ) return  15;
  323.   if(i<80 ) { whitekey = FALSE;return  11;}
  324.   if(i<85 ) return  16;
  325.   if(i<90 ) return  17;
  326.   if(i<96 ) { whitekey = FALSE;return  12;}
  327.   if(i<101) return  18;
  328.   if(i<107) { whitekey = FALSE;return  13;}
  329.   if(i<114) return  19;
  330.   if(i<120) { whitekey = FALSE;return  14;}
  331.             return  20;
  332.   }
  333.  
  334.   /* first octave */
  335.   if(i<255)
  336.   {
  337.   if(i<136) return  0;
  338.   if(i<143) { whitekey = FALSE;return  0;}
  339.   if(i<152) return  1;
  340.   if(i<160) { whitekey = FALSE;return  1;}
  341.   if(i<170) return  2;
  342.   if(i<180) return  3;
  343.   if(i<190) { whitekey = FALSE;return  2;}
  344.   if(i<202) return  4;
  345.   if(i<215) { whitekey = FALSE;return  3;}
  346.   if(i<227) return  5;
  347.   if(i<240) { whitekey = FALSE;return  4;}
  348.             return  6;
  349.   }
  350.  
  351.   /* second octave */
  352.   if(i<512)
  353.   {
  354.    if(i<270)return 7;
  355.    if(i<286){ whitekey = FALSE;return 5;}
  356.    if(i<304)return 8;
  357.    if(i<322){ whitekey = FALSE;return 6;}
  358.    if(i<340)return 9;
  359.    if(i<360)return 10;
  360.    if(i<382){ whitekey = FALSE;return 7;}
  361.    if(i<406)return 11;
  362.    if(i<428){ whitekey = FALSE;return 8;}
  363.    if(i<454)return 12;
  364.    if(i<480){ whitekey = FALSE;return 9;}
  365.        return 13;
  366.    }
  367.  
  368.    /* third octave */
  369.  
  370.   if(i<1024)
  371.   {
  372.   if(i<540)return 14;
  373.   if(i<572){ whitekey = FALSE;return 10;}
  374.   if(i<605)return 15;
  375.   if(i<643){ whitekey = FALSE;return 11;}
  376.   if(i<680)return 16;
  377.   if(i<720)return 17;
  378.   if(i<765){ whitekey = FALSE;return 12;}
  379.   if(i<810)return 18;
  380.   if(i<855){ whitekey = FALSE;return 13;}
  381.   if(i<910)return 19;
  382.   if(i<965){ whitekey = FALSE;return 14;}
  383.   return 20;
  384.   }
  385.  
  386.   /* fourth octave */
  387.  
  388.   if(i<2048)
  389.   {
  390.   if(i<1080) return  0;
  391.   if(i<1144) { whitekey = FALSE;return  0;}
  392.   if(i<1210) return  1;
  393.   if(i<1286) { whitekey = FALSE;return  1;}
  394.   if(i<1340) return  2;
  395.   if(i<1440) return  3;
  396.   if(i<1530) { whitekey = FALSE;return  2;}
  397.   if(i<1620) return  4;
  398.   if(i<1710) { whitekey = FALSE;return  3;}
  399.   if(i<1820) return  5;
  400.   if(i<1930) { whitekey = FALSE;return  4;}
  401.             return  6;
  402.   }
  403.  
  404.   /* fifth octave */
  405.   /* sixth octave ignored */
  406.    if(i<2160)return 7;
  407.    if(i<2288){ whitekey = FALSE;return 5;}
  408.    if(i<2420)return 8;
  409.    if(i<2572){ whitekey = FALSE;return 6;}
  410.    if(i<2680)return 9;
  411.    if(i<2880)return 10;
  412.    if(i<3060){ whitekey = FALSE;return 7;}
  413.    if(i<3240)return 11;
  414.    if(i<3420){ whitekey = FALSE;return 8;}
  415.    if(i<3640)return 12;
  416.    if(i<3860){ whitekey = FALSE;return 9;}
  417.  
  418.    return 13;
  419.  
  420. }
  421.  
  422.  
  423.  
  424. #define SILENCE 32767
  425. #define QUIT  0
  426. #define FLIP -1
  427. int getfrequency(int x, int y)
  428. {
  429.  
  430.     /* this function checks each of the hot zones on the piano    */
  431.     /* returns the note frequency associated with that area       */
  432.     /* if no hot area is active then the function returns SILENCE */
  433.  
  434.     int frequency = SILENCE;
  435.     int i;
  436.  
  437.     /* check the quit box and return 0 if we're in range */
  438.         if(x >= QUITBOX[0] && y >= QUITBOX[1] &&
  439.            x <= QUITBOX[2] && y <= QUITBOX[3]) return QUIT;
  440.  
  441.    /* check to see if we're being asked to flip the page */
  442.         if(x >= FLIPBOX[0] && y >= FLIPBOX[1] &&
  443.            x <= FLIPBOX[2] && y <= FLIPBOX[3]) return FLIP;
  444.  
  445.     /* check the black keys */
  446.     for(i=0;i!=15;i++)
  447.     {
  448.         /* if its in range return the frequency */
  449.         if(x >= BLACKS[i][0] && y >= BLACKS[i][1] &&
  450.            x <= BLACKS[i][2] && y <= BLACKS[i][3])
  451.                    return notefrequency [BLACKS[i][4]] [BLACKS[i][5]];
  452.      }
  453.  
  454.     /* check the white keys */
  455.     for(i=0;i!=22;i++)
  456.     {
  457.         /* if its in range return the frequency */
  458.         if(x >= WHITES[i][0] && y >= WHITES[i][1] &&
  459.            x <= WHITES[i][2] && y <= WHITES[i][3])
  460.                   return notefrequency [WHITES[i][4]] [WHITES[i][5]];
  461.      }
  462.  
  463.  
  464.  
  465.    /* if we haven't hit a hot spot yet then we're not in range */
  466.    return frequency;
  467. }
  468.  
  469.  
  470. /*                                                           */
  471. /*  a sound function in microsoft C                          */
  472. /*                                                           */
  473.  
  474. #define TIMEOUT 0x2c00
  475.  
  476. int sound(freq,tlen)
  477. int freq;         /* freq of sound in Hertz                  */
  478. int tlen;         /* duration of sound 18.2 ticks per second */
  479. {
  480.     union REGS inregs,outregs;
  481.     unsigned frdiv = 1331000L/freq;   /* timer divisor */
  482.     int seed,hiseed,hold=0,setting;
  483.       
  484.     outp(0x43,0xB6) ;           /* write timer mode register */
  485.     outp(0x42,frdiv & 0x00FF);  /* write divisor LSB */
  486.     outp(0x42,frdiv >> 8);      /* write divisor MSB */
  487.  
  488.     setting= inp(0x61);          /* get current port B setting */
  489.     outp(0x61,setting | 0x03);   /* turn speaker on */
  490.  
  491.     if(tlen>0){
  492.        tlen=((tlen*1000)/182); /* convert from 18.2 ticks to 100ths */
  493.        inregs.x.ax= TIMEOUT;
  494.        int86(0x21,&inregs,&outregs);
  495.        seed=(outregs.x.dx)&0xff;
  496.  
  497.     while(hold<tlen)
  498.      {
  499.        inregs.x.ax = TIMEOUT;
  500.        int86(0x21,&inregs,&outregs);
  501.        if(seed!=(outregs.x.dx&0xff))
  502.         {
  503.           hiseed= (outregs.x.dx)&0xff;
  504.           if(hiseed<seed)hiseed+=100;
  505.           hold+=(hiseed-seed);
  506.           seed =(outregs.x.dx)&0xff;
  507.           }
  508.           }
  509.           }
  510.  
  511.     outp(0x61,setting);
  512.     /* restore port B setting */
  513.     return;
  514. }
  515.  
  516. /* note: the arrow array corresponds to the pixel map and the number   */
  517. /* corresponds to the desired pixel attribute. we use the 2-d array to */
  518. /* construct a visual map of the cursor and call makemickey() to       */
  519. /* produce the binary values. we can visually design any cursor mask   */
  520. /* by overtyping this example.                                         */
  521.  
  522. short arrow[16][8]={   /* the cursor template */
  523. 0,1,1,1,1,1,1,1,
  524. 0,1,0,0,0,0,0,1,
  525. 0,1,0,1,1,1,0,1,
  526. 0,1,0,0,0,0,0,1,
  527. 0,1,0,1,1,1,0,1,       /* this type of array is usually referred     */
  528. 0,1,0,1,0,1,0,1,       /* to as a sprite                             */
  529. 0,1,0,1,0,1,0,1,
  530. 0,1,0,1,0,1,0,1,
  531. 0,1,0,1,0,1,0,1,
  532. 0,1,0,1,1,1,0,1,
  533. 1,1,0,1,1,0,0,1,
  534. 1,0,0,1,1,0,0,1,
  535. 1,0,0,1,1,0,0,1,
  536. 1,0,0,1,1,1,1,1,
  537. 1,1,1,1,0,0,0,0,
  538. 0,0,0,0,0,0,0,0};
  539.  
  540. short zorro[16][8]={   /* the screen mask */
  541. 3,0,0,0,0,0,0,0,
  542. 3,0,0,0,0,0,0,0,       /* the outline of the shape defined by arrow    */
  543. 3,0,0,0,0,0,0,0,       /* is made invisible by anding with 3.          */
  544. 3,0,0,0,0,0,0,0,       /* the shape is anded with 0 to remain visible. */
  545. 3,0,0,0,0,0,0,0,
  546. 3,0,0,0,3,0,0,0,
  547. 3,0,0,0,3,0,0,0,
  548. 3,0,0,0,3,0,0,0,
  549. 3,0,0,0,3,0,0,0,
  550. 3,0,0,0,0,0,0,0,
  551. 0,0,0,0,0,0,0,0,
  552. 0,0,0,0,0,0,0,0,
  553. 0,0,0,0,0,0,0,0,
  554. 0,0,0,0,0,0,0,0,
  555. 0,0,0,0,3,3,3,3,
  556. 3,3,3,3,3,3,3,3};
  557.  
  558. /* icons for the player piano sequence */
  559. char bptr[]={
  560.         '\x18','\x00','\x14','\x00',
  561.         '\xaa','\xaa','\xab',
  562.         '\xaa','\xaa','\xab',
  563.         '\xaa','\xaa','\xab',
  564.         '\x95','\x55','\xab',
  565.         '\x90','\x01','\xab',
  566.         '\x91','\x51','\xab',
  567.         '\x90','\x01','\xab',
  568.         '\x91','\x51','\xab',
  569.         '\x91','\x91','\xab',
  570.         '\x91','\x91','\xab',
  571.         '\x91','\x91','\xab',
  572.         '\x91','\x91','\xab',
  573.         '\x91','\x51','\xab',
  574.         '\x51','\x41','\xab',
  575.         '\x41','\x41','\xab',
  576.         '\x41','\x41','\xab',
  577.         '\x41','\x55','\xab',
  578.         '\x55','\xaa','\xab',
  579.         '\xaa','\xaa','\xab',
  580.         '\xaa','\xaa','\xab'};
  581.  
  582. char bspot[]={
  583.         '\x18','\x00','\x14','\x00',
  584.         '\xaa','\xaa','\xab',
  585.         '\xaa','\xaa','\xab',
  586.         '\xaa','\xaa','\xab',
  587.         '\xaa','\xaa','\xab',
  588.         '\xaa','\xaa','\xab',
  589.         '\xaa','\xaa','\xab',
  590.         '\xaa','\xaa','\xab',
  591.         '\xaa','\xaa','\xab',
  592.         '\xaa','\xaa','\xab',
  593.         '\xaa','\xaa','\xab',
  594.         '\xaa','\xaa','\xab',
  595.         '\xaa','\xaa','\xab',
  596.         '\xaa','\xaa','\xab',
  597.         '\xaa','\xaa','\xab',
  598.         '\xaa','\xaa','\xab',
  599.         '\xaa','\xaa','\xab',
  600.         '\xaa','\xaa','\xab',
  601.         '\xaa','\xaa','\xab',
  602.         '\xaa','\xaa','\xab',
  603.         '\xaa','\xaa','\xab'};
  604.  
  605. char wptr[]={
  606.        '\x18','\x00','\x14','\x00',
  607.        '\x3f','\xff','\xff',
  608.        '\x3d','\x55','\x5f',
  609.        '\x3d','\x00','\x1f',
  610.        '\x3d','\x15','\x1f',
  611.        '\x3d','\x00','\x1f',
  612.        '\x3d','\x15','\x1f',
  613.        '\x3d','\x1d','\x1f',
  614.        '\x3d','\x1d','\x1f',
  615.        '\x3d','\x1d','\x1f',
  616.        '\x3d','\x1d','\x1f',
  617.        '\x3d','\x15','\x1f',
  618.        '\x35','\x14','\x1f',
  619.        '\x34','\x14','\x1f',
  620.        '\x34','\x14','\x1f',
  621.        '\x34','\x15','\x5f',
  622.        '\x35','\x5f','\xff',
  623.        '\x3f','\xff','\xff',
  624.        '\x3f','\xff','\xff',
  625.        '\x3f','\xff','\xff',
  626.        '\x3f','\xff','\xff'};
  627.  
  628. char wspot[]={
  629.        '\x18','\x00','\x14','\x00',
  630.        '\x3f','\xff','\xff',
  631.        '\x3f','\xff','\xff',
  632.        '\x3f','\xff','\xff',
  633.        '\x3f','\xff','\xff',
  634.        '\x3f','\xff','\xff',
  635.        '\x3f','\xff','\xff',
  636.        '\x3f','\xff','\xff',
  637.        '\x3f','\xff','\xff',
  638.        '\x3f','\xff','\xff',
  639.        '\x3f','\xff','\xff',
  640.        '\x3f','\xff','\xff',
  641.        '\x3f','\xff','\xff',
  642.        '\x3f','\xff','\xff',
  643.        '\x3f','\xff','\xff',
  644.        '\x3f','\xff','\xff',
  645.        '\x3f','\xff','\xff',
  646.        '\x3f','\xff','\xff',
  647.        '\x3f','\xff','\xff',
  648.        '\x3f','\xff','\xff',
  649.        '\x3f','\xff','\xff'};
  650.  
  651. int cursor[32]    ;
  652. char far *cptr=(char far *)cursor   ;
  653.  
  654. void makemickey(int cursortype)
  655. {
  656.     /* usage:  load a new cursor into the cursor buffer        */
  657.     /* or   :  switch between different cursor shapes          */
  658.     /* accumulate color value and position to cursor array     */
  659.     /* each pixel value in the CGA MED RES is stored in 2 bits */
  660.     /* and the mouse cursor mask is stored in a word value     */
  661.     /* the pixel map is defined by a left shift of the pixel   */
  662.     /* attribute to the appropriate position in the mask.      */
  663.  
  664.  
  665.     int shifter,i,j,k=16;
  666.  
  667.                for(i=0;i<16;i++){
  668.                    for(j=0;j<8;j++){
  669.                        switch(j){
  670.                            case 0: shifter=14;break;
  671.                            case 1: shifter=12;break;
  672.                            case 2: shifter=10;break;
  673.                            case 3: shifter= 8;break;
  674.                            case 4: shifter= 6;break;
  675.                            case 5: shifter= 4;break;
  676.                            case 6: shifter= 2;break;
  677.                            case 7: shifter= 0;break;
  678.                         }
  679.                     /* reference to additional sprites can be added here */
  680.                        switch(cursortype)
  681.                        {
  682.                         default:
  683.  
  684.                      cursor[k]=(cursor[k] | arrow[i][j]<<shifter);
  685.                      cursor[i]=(cursor[i] | zorro[i][j]<<shifter);
  686.                        }
  687.                     }
  688.                     k++;
  689.                 }
  690.  
  691. }
  692.  
  693. #undef WHITE
  694. #undef RED
  695. #undef CYAN
  696. #undef BLACK
  697.  
  698. #define WHITE 3
  699. #define RED   2
  700. #define CYAN  1
  701. #define BLACK 0
  702.  
  703. int soundbox[22][7]=
  704.     {
  705.  
  706. /*  x1   y1  x2   y2   row  col  record # */
  707.     0,   0,  79,  23,  2,   2,   0,
  708.     80,  0,  159, 23,  2,   12,  0,
  709.     160, 0,  239, 23,  2,   22,  0,
  710.     240, 0,  319, 23,  2,   32,  0,
  711.  
  712.     0,   24, 79,  47,  5,   2,   0,
  713.     80,  24, 159, 47,  5,   12,  0,
  714.     160, 24, 239, 47,  5,   22,  0,
  715.     240, 24, 319, 47,  5,   32,  0,
  716.  
  717.     0,   48, 79,  71,  8,   2,   0,
  718.     80,  48, 159, 71,  8,   12,  0,
  719.     160, 48, 239, 71,  8,   22,  0,
  720.     240, 48, 319, 71,  8,   32,  0,
  721.  
  722.     0,   72, 79,  95,  11,  2,   0,
  723.     80,  72, 159, 95,  11,  12,  0,
  724.     160, 72, 239, 95,  11,  22,  0,
  725.     240, 72, 319, 95,  11,  32,  0,
  726.  
  727.     0,   96, 79,  119, 14,  2,   0,
  728.     80,  96, 159, 119, 14,  12,  0,
  729.     160, 96, 239, 119, 14,  22,  0,
  730.     240, 96, 319, 119, 14,  32,  0,
  731.  
  732.     0,  120, 159, 199, 17,  2,   0, /* turn the page             */
  733.     160,120, 319, 199, 17,  22,  0  /* return to previous screen */
  734.  
  735. };
  736.  
  737.  
  738.  
  739. /* get a series of files of a certain type.. in this case, type .SND */
  740. int wildcounter=9;
  741. char wildfiles[200][15];
  742. int soundindex =0;
  743.  
  744. int getfiles(char *filetype)
  745. {
  746.  
  747.     int i;
  748.     char buffer[15];
  749.     struct find_t wild_card;
  750.  
  751.     memset(wildfiles,0,sizeof(wildfiles));
  752.  
  753.     wildcounter =9;
  754.  
  755.     for(i=0;i!=wildcounter;i++)
  756.         strcpy(wildfiles[i],internal_tunes[i]);
  757.  
  758.     sprintf(buffer,"*.%s",filetype);
  759.  
  760.     if(_dos_findfirst(buffer,_A_NORMAL,&wild_card)==0)
  761.     {
  762.  
  763.         strcpy(wildfiles[wildcounter],wild_card.name);
  764.         wildcounter++;
  765.  
  766.     while(_dos_findnext(&wild_card)==0){
  767.            strcpy(wildfiles[wildcounter],wild_card.name);
  768.            wildcounter++;
  769.            }
  770.         }
  771.  
  772. return wildcounter;
  773. }
  774.  
  775.  
  776. int mousex, mousey;
  777.  
  778. int internal_play(int *musical_script)
  779. {
  780.   int frequency=0, duration=1, done=0,true=1;
  781.   union REGS inregs, outregs;
  782.  
  783.   int temp,status=-1;
  784.   whitekey=TRUE;
  785.  
  786.   /* pause while a button is released */
  787.  
  788.   do{
  789.       inregs.x.ax=3;
  790.       int86(0x33,&inregs,&outregs);
  791.       }
  792.       while(outregs.x.bx!=0);
  793.  
  794.  
  795.  
  796.  
  797.   while(done !=true)
  798.      {
  799.       /* quit if a mouse button is pressed but   */
  800.       /* first replace the divot if we got one   */
  801.  
  802.       if(status!=-1)
  803.       {
  804.             if(whitekey==FALSE)
  805.             {
  806.             mousex = BLACKS[status][0];
  807.             mousey = BLACKS[0][1]+16  ;
  808.             _putimage(mousex,mousey,bspot,_GPSET);
  809.             }
  810.             else
  811.             {
  812.             mousex = WHITES[status][0];
  813.             mousey = BLACKS[0][3]+14  ;
  814.             _putimage(mousex,mousey,wspot,_GPSET);
  815.             }
  816.          }
  817.  
  818.       if(kbhit())
  819.       {
  820.         if(getch()==27)return -1;
  821.        }
  822.  
  823.  
  824.       inregs.x.ax=3;
  825.       int86(0x33,&inregs,&outregs);
  826.       if(outregs.x.bx!=0)
  827.       {
  828.         /* pause until a button is released */
  829.  
  830.                    do{
  831.                       inregs.x.ax=3;
  832.                       int86(0x33,&inregs,&outregs);
  833.                       }
  834.                     while(outregs.x.bx!=0);
  835.         return -1;
  836.         }
  837.       temp=musical_script[frequency];
  838.  
  839.       status=keyplay(temp);
  840.  
  841.       if(status!=-1)
  842.       {
  843.           if(whitekey==FALSE)
  844.             {
  845.             mousex = BLACKS[status][0];
  846.             mousey = BLACKS[0][1]+16  ;
  847.             _putimage(mousex,mousey,bptr,_GPSET);
  848.             }
  849.             else
  850.             {
  851.             mousex = WHITES[status][0];
  852.             mousey = BLACKS[0][3]+14  ;
  853.             _putimage(mousex,mousey,wptr,_GPSET);
  854.             }
  855.        }
  856.       sound(temp,musical_script[duration]);
  857.       frequency+=2;duration+=2;
  858.       if (musical_script[frequency] == -1)done=true;
  859.       }
  860.       if(status!=-1)
  861.       {
  862.           if(whitekey==FALSE)
  863.             {
  864.             mousex = BLACKS[status][0];
  865.             mousey = BLACKS[0][1]+16  ;
  866.             _putimage(mousex,mousey,bspot,_GPSET);
  867.             }
  868.             else
  869.             {
  870.             mousex = WHITES[status][0];
  871.             mousey = BLACKS[0][3]+14  ;
  872.             _putimage(mousex,mousey,wspot,_GPSET);
  873.             }
  874.          }
  875.       return 0;
  876. }
  877.  
  878. int playit_straight(int *musical_script)
  879. {
  880.   int frequency=0, duration=1, done=0,true=1;
  881.   union REGS inregs, outregs;
  882.  
  883.   /* pause while a button is released */
  884.  
  885.   do{
  886.       inregs.x.ax=3;
  887.       int86(0x33,&inregs,&outregs);
  888.       }
  889.       while(outregs.x.bx!=0);
  890.  
  891.  
  892.  
  893.  
  894.   while(done !=true)
  895.      {
  896.       /* quit if a mouse button is pressed but   */
  897.  
  898.       inregs.x.ax=3;
  899.       int86(0x33,&inregs,&outregs);
  900.       if(outregs.x.bx!=0)
  901.       {
  902.         /* pause until a button is released */
  903.  
  904.                    do{
  905.                       inregs.x.ax=3;
  906.                       int86(0x33,&inregs,&outregs);
  907.                       }
  908.                     while(outregs.x.bx!=0);
  909.         return -1;
  910.         }
  911.       sound(musical_script[frequency],musical_script[duration]);
  912.       frequency+=2;duration+=2;
  913.       if (musical_script[frequency] == -1)done=true;
  914.       }
  915.       return 0;
  916. }
  917.  
  918.  
  919.  
  920.  
  921. int external_play(char *sndfile)
  922. {
  923.  
  924.   union REGS inregs, outregs;
  925.  
  926.   FILE *fp;
  927.   int frequency, duration;
  928.  
  929.   int status=-1;
  930.   whitekey=TRUE;
  931.  
  932.   /* pause while a button is released */
  933.  
  934.   do{
  935.       inregs.x.ax=3;
  936.       int86(0x33,&inregs,&outregs);
  937.       }
  938.       while(outregs.x.bx!=0);
  939.  
  940.   if((fp=fopen(sndfile,"rb"))==NULL)return -2;
  941.  
  942.   while((frequency=getw(fp))!=-1)
  943.      {
  944.       /* first replace the divot if we got one   */
  945.  
  946.       if(status!=-1)
  947.       {
  948.           if(whitekey==FALSE)
  949.             {
  950.             mousex = BLACKS[status][0];
  951.             mousey = BLACKS[0][1]+16  ;
  952.             _putimage(mousex,mousey,bspot,_GPSET);
  953.             }
  954.             else
  955.             {
  956.             mousex = WHITES[status][0];
  957.             mousey = BLACKS[0][3]+14  ;
  958.             _putimage(mousex,mousey,wspot,_GPSET);
  959.             }
  960.          }
  961.  
  962.       if(kbhit())
  963.       {
  964.         if(getch()==27)
  965.         {
  966.             fclose(fp);
  967.             return -1;
  968.         }
  969.        }
  970.  
  971.       /* quit if a mouse button is pressed */
  972.       inregs.x.ax=3;
  973.       int86(0x33,&inregs,&outregs);
  974.       if(outregs.x.bx!=0)
  975.                   {
  976.  
  977.                   /* pause until a button is released */
  978.  
  979.                    do{
  980.                       inregs.x.ax=3;
  981.                       int86(0x33,&inregs,&outregs);
  982.                       }
  983.                     while(outregs.x.bx!=0);
  984.  
  985.                     fclose(fp);
  986.                     return -1;
  987.                     }
  988.       status=keyplay(frequency);
  989.  
  990.       if(status!=-1)
  991.       {
  992.           if(whitekey==FALSE)
  993.             {
  994.             mousex = BLACKS[status][0];
  995.             mousey = BLACKS[0][1]+16  ;
  996.             _putimage(mousex,mousey,bptr,_GPSET);
  997.             }
  998.             else
  999.             {
  1000.             mousex = WHITES[status][0];
  1001.             mousey = BLACKS[0][3]+14  ;
  1002.             _putimage(mousex,mousey,wptr,_GPSET);
  1003.             }
  1004.        }
  1005.  
  1006.       duration=fgetc(fp);
  1007.       sound(frequency,duration);
  1008.       }
  1009.       fclose(fp);
  1010.       if(status!=-1)
  1011.       {
  1012.           if(whitekey==FALSE)
  1013.             {
  1014.             mousex = BLACKS[status][0];
  1015.             mousey = BLACKS[0][1]+16  ;
  1016.             _putimage(mousex,mousey,bspot,_GPSET);
  1017.             }
  1018.             else
  1019.             {
  1020.             mousex = WHITES[status][0];
  1021.             mousey = BLACKS[0][3]+14  ;
  1022.             _putimage(mousex,mousey,wspot,_GPSET);
  1023.             }
  1024.          }
  1025.       return 0;
  1026. }
  1027.  
  1028. int play(int selection)
  1029. {
  1030.  
  1031.     switch(selection)
  1032.     {
  1033.         case 0:  internal_play(danube);break;
  1034.         case 1:  internal_play(dvorak);break;
  1035.         case 2:  internal_play(guonod);break;
  1036.         case 3:  internal_play(mexico);break;
  1037.         case 4:  internal_play(mozart);break;
  1038.         case 5:  internal_play(stars); break;
  1039.         case 6:  internal_play(sam);   break;
  1040.         case 7:  internal_play(bug);   break;
  1041.         case 8:  internal_play(weasel);break;
  1042.  
  1043.         default : external_play(wildfiles[selection]);
  1044.     }
  1045.  
  1046. }
  1047.  
  1048.  
  1049.  
  1050. int getsoundfile(int x, int y)
  1051. {
  1052.  
  1053.     /* this function checks each of the hot zones in the files    */
  1054.     /* listing and returns the number of the current choice       */
  1055.  
  1056.     int currentchoice = -1;
  1057.     int i;
  1058.  
  1059.          /* check the flip zone and the quit without selection zone */
  1060.         if(x >= soundbox[20][0] && y >= soundbox[20][1] &&
  1061.            x <= soundbox[20][2] && y <= soundbox[20][3])
  1062.                    return 20;
  1063.         if(x >= soundbox[21][0] && y >= soundbox[21][1] &&
  1064.            x <= soundbox[21][2] && y <= soundbox[21][3])
  1065.                    return 21;
  1066.  
  1067.     for(i=0;i!=20;i++)
  1068.     {
  1069.         /* if its in range return the hot box number */
  1070.         if(x >= soundbox[i][0] && y >= soundbox[i][1] &&
  1071.            x <= soundbox[i][2] && y <= soundbox[i][3])return i;
  1072.      }
  1073.  
  1074.    /* if we haven't hit a hot spot yet then we're not in range */
  1075.    return currentchoice;
  1076. }
  1077.  
  1078.  
  1079. /* Character Arrays of .PCX format Run Length Full Screen CGA Graphics */
  1080. /* BYTE COUNT Descriptor Integers precede the Character Arrays.*/
  1081.  
  1082. /* .PCX Input File Name was MICKIANO.PCX */
  1083. extern int MICKIANO_SIZE;
  1084. extern unsigned char far MICKIANO[12140];
  1085.  
  1086. /* .PCX Input File Name was KEYBOARD.PCX */
  1087. extern int KEYBOARD_SIZE;
  1088. unsigned char far KEYBOARD[11806];
  1089.  
  1090. /* .PCX Input File Name was DIRECTOR.PCX */
  1091. extern int DIRECTOR_SIZE;
  1092. extern unsigned char far DIRECTOR[3758];
  1093.  
  1094. extern int WORDS_SIZE;
  1095. extern unsigned char far WORDS[];
  1096.  
  1097. #define SCREENSIZE 16385
  1098. unsigned char far *crt    =(unsigned char *) 0xB8000000l;
  1099. unsigned char far *inleaf =(unsigned char *)0xB8000000l+0x2000;
  1100. unsigned char far *mickianobuffer;
  1101. unsigned char far *keyboardbuffer;
  1102. unsigned char far *directorbuffer;
  1103. unsigned char far *wordsbuffer;
  1104. unsigned char far *imagebuf;
  1105.  
  1106. #define   CGALINE    80
  1107.  
  1108. int memoryload(unsigned char far *in, unsigned char far *out, int sz)
  1109. {
  1110.     unsigned int byteoff=0,packet,width=0;
  1111.     unsigned char byte,bytecount;
  1112.     int wordcount=0;
  1113.  
  1114.  
  1115.  
  1116.     do{ bytecount=1;                          /* start with a seed count */
  1117.         byte=in[wordcount];
  1118.         wordcount++;
  1119.                                               /* check to see if its raw */
  1120.         if(0xC0 == (0xC0 &byte)){             /* if its not, run encoded */
  1121.                     bytecount= 0x3f &byte;
  1122.                     byte=in[wordcount];
  1123.                     wordcount++;
  1124.                     }
  1125.         for(packet=0;packet<bytecount;packet++){
  1126.                      out[byteoff]=byte;
  1127.                      byteoff++;
  1128.                      }
  1129.         }while(wordcount<sz);
  1130.         return(0);
  1131. }
  1132.  
  1133. int cload(unsigned char far *array)
  1134. {
  1135.  unsigned int y,inset=0, offset=0;
  1136.  
  1137.     for(y=0;y<200;){
  1138.         memcpy(crt+inset,array+offset,CGALINE);
  1139.         offset+=CGALINE;
  1140.         y++;
  1141.         memcpy(inleaf+inset,array+offset,CGALINE);
  1142.         offset+=CGALINE;
  1143.         inset+=CGALINE;
  1144.         y++;
  1145.         }
  1146.      return(0);
  1147.  
  1148. }
  1149.  
  1150. void initraw()
  1151. {
  1152.     mickianobuffer = _fmalloc(SCREENSIZE);
  1153.     keyboardbuffer = _fmalloc(SCREENSIZE);
  1154.     directorbuffer = _fmalloc(SCREENSIZE);
  1155.     wordsbuffer    = _fmalloc(SCREENSIZE);
  1156.     imagebuf       = _fmalloc(2048);
  1157.     /* arbitrary*/
  1158.  
  1159.     memoryload(MICKIANO,mickianobuffer,MICKIANO_SIZE);
  1160.     memoryload(KEYBOARD,keyboardbuffer,KEYBOARD_SIZE);
  1161.     memoryload(DIRECTOR,directorbuffer,DIRECTOR_SIZE);
  1162.     memoryload(WORDS,wordsbuffer,WORDS_SIZE);
  1163. }
  1164.  
  1165. void freeraw()
  1166. {
  1167.     _ffree(keyboardbuffer);
  1168.     _ffree(mickianobuffer);
  1169.     _ffree(directorbuffer);
  1170.     _ffree(wordsbuffer);
  1171.     _ffree(imagebuf);
  1172. }
  1173.  
  1174. void drawscreen(int screentype)
  1175. {
  1176.  
  1177.  int x;
  1178.  char scratchbuf[15];
  1179.  char *wordptr;
  1180.  union REGS inregs,outregs;
  1181.  
  1182.  
  1183.  switch(screentype)
  1184.  {
  1185.     /* falls through here the first time */
  1186.     case 0:    initraw();
  1187.                getfiles("SND");
  1188.                cload(mickianobuffer);
  1189.                playit_straight(ENTERTAN);
  1190.  
  1191.     case 1:    cload(keyboardbuffer);
  1192.                break;
  1193.  
  1194.  
  1195.     case 2:    /* load the screen */
  1196.                cload(directorbuffer);
  1197.     case 3:
  1198.  
  1199.     _setcolor(BLACK);
  1200.  
  1201.  for(x=0;x!=20;x++)
  1202.  {
  1203.    soundbox[x][6]=soundindex;   /* set the index pointer to the wildfiles */
  1204.  
  1205.    if(screentype == 3);
  1206.    _rectangle(_GFILLINTERIOR,soundbox[x][0]+1,soundbox[x][1]+1,
  1207.                              soundbox[x][2]-1,soundbox[x][3]-1);
  1208.    
  1209.    _settextposition(soundbox[x][4],soundbox[x][5]);
  1210.    strcpy(scratchbuf,wildfiles[soundindex]);
  1211.    if(soundindex>8)
  1212.       {
  1213.       wordptr=strtok(scratchbuf,".");
  1214.       printf("%s",wordptr);
  1215.       }
  1216.    else
  1217.       printf("%s",scratchbuf);
  1218.       soundindex++;
  1219.       /* wrap around if we are at the end */
  1220.       if(soundindex==wildcounter)soundindex=0;
  1221.       }
  1222.  
  1223.     /* pause while a button is released */
  1224.  
  1225.   do{
  1226.       inregs.x.ax=3;
  1227.       int86(0x33,&inregs,&outregs);
  1228.       }
  1229.       while(outregs.x.bx!=0);
  1230.  
  1231.    }
  1232.  
  1233.  
  1234. }
  1235.  
  1236.  
  1237. void cursoron(void)
  1238. {
  1239.          union REGS inregs, outregs;
  1240.          /*                                                 */
  1241.          /*  set mouse cursor location, then turn on cursor */
  1242.          /*                                                 */
  1243.          inregs.x.ax=4;
  1244.          inregs.x.cx=mousex*2;
  1245.          inregs.x.dx=mousey;
  1246.          int86(0x33,&inregs,&outregs);
  1247.  
  1248.          inregs.x.ax=1;
  1249.          int86(0x33,&inregs,&outregs);
  1250. }
  1251.  
  1252. void cursoroff(void)
  1253. {
  1254.         union REGS inregs, outregs;
  1255.         inregs.x.ax=2;
  1256.         int86(0x33,&inregs,&outregs);
  1257.  
  1258. }
  1259.  
  1260.  
  1261.  
  1262. main(int argc, char **argv)
  1263. {
  1264.  
  1265.   int x,y,m2;
  1266.   char c;
  1267.  
  1268.   int frequency,duration = 2,songchoice;
  1269.   int newchoice, oldchoice;
  1270.  
  1271.   union REGS inregs, outregs;
  1272.   struct SREGS segregs;
  1273.   long address;
  1274.   unsigned char first_byte;
  1275.  
  1276. /*                                                               */
  1277. /*  check for CGA compatible video adapter on initial video mode.*/
  1278. /*                                                               */
  1279.  
  1280.  
  1281.     int86(0x11,&inregs,&outregs); /* get equipment list from the bios */
  1282.     /* get display type (bits 4 and 5 of ax) */
  1283.  
  1284.     if ((outregs.x.ax & 0x30) == 0x30)
  1285.     {
  1286.         printf("Sorry... CGA or Compatible Video Adapter Required.\n");
  1287.         exit(0);
  1288.      }
  1289.  
  1290.  
  1291. /*                                                             */
  1292. /*  check for microsoft compatible mouse driver                */
  1293. /*                                                             */
  1294.  
  1295.     inregs.x.ax = 0x3533                                       ;
  1296.     intdosx ( &inregs, &outregs, &segregs )                    ;
  1297.     address = (((long) segregs.es) << 16) + (long) outregs.x.bx;
  1298.     first_byte = * (long far *) address                        ;
  1299.     if ((address == 0) || (first_byte == 0xcf))
  1300.     {
  1301.       printf("Sorry... Microsoft Compatible mouse Driver not found!\n");
  1302.       exit(0);
  1303.       }
  1304. /*                                                             */
  1305. /*  initilize and check to see if the mouse is responding      */
  1306. /*                                                             */
  1307.  
  1308.     inregs.x.ax=0               ;
  1309.     int86(0x33,&inregs,&outregs);
  1310.     if(outregs.x.ax==0)
  1311.     {
  1312.        printf("Sorry... Microsoft Compatible Mouse not responding!\n");
  1313.        exit(0);
  1314.        }
  1315.  
  1316. /*                                                      */
  1317. /* set the video mode                                   */
  1318. /*                                                      */
  1319.   _setvideomode(_MRESNOCOLOR);
  1320.  
  1321.  /*                                                      */
  1322.  /*  set mouse sensitivity                               */
  1323.  /*                                                      */
  1324.  inregs.x.ax = 15;
  1325.  inregs.x.bx = 15;
  1326.  inregs.x.cx = 4 ;
  1327.  inregs.x.dx = 8 ;
  1328.  int86(0x33,&inregs,&outregs);
  1329.  
  1330.  
  1331. /*                                                             */
  1332. /*  load the cursor                                            */
  1333. /*                                                             */
  1334.  
  1335.     makemickey(1);
  1336.  
  1337.     segregs.es=FP_SEG(cptr);
  1338.     inregs.x.ax=9                         ;
  1339.     inregs.x.bx=6                         ;
  1340.     inregs.x.cx=0                         ;
  1341.     inregs.x.dx=FP_OFF(cptr);
  1342.     int86x(0x33,&inregs,&outregs,&segregs);
  1343.  
  1344.     drawscreen(0);
  1345.  
  1346.  /*                                                 */
  1347.  /*  set mouse cursor location, then turn on cursor */
  1348.  /*                                                 */
  1349.  mousex = 160;
  1350.  mousey = 160;
  1351.  cursoron();
  1352.  
  1353.  /*                      */
  1354.  /*  m a i n    l o o p  */
  1355.  /*                      */
  1356.  
  1357.      do
  1358.      {
  1359.  
  1360.      m2=0;
  1361.      /* wait here for any button press */
  1362.      /* or allowable keypresses        */
  1363.  
  1364.      while(!(m2))
  1365.      {
  1366.  
  1367.       inregs.x.ax=3;
  1368.       int86(0x33,&inregs,&outregs);
  1369.       m2 = outregs.x.bx   ;
  1370.       x  = outregs.x.cx/2 ;
  1371.       y  = outregs.x.dx   ; /* get mouse location and button status */
  1372.  
  1373.      if(kbhit())
  1374.      {
  1375.         mousex = x;
  1376.         mousey = y;
  1377.  
  1378.         c=toupper(getch());
  1379.  
  1380.         switch(c)
  1381.         {
  1382.  
  1383.              case '2': mousex = BLACKS[0][0]+5 ;
  1384.                        mousey = BLACKS[0][1]+16; m2=1; break;
  1385.              case '3': mousex = BLACKS[1][0]+5 ;
  1386.                        mousey = BLACKS[0][1]+16; m2=1; break;
  1387.              case '5': mousex = BLACKS[2][0]+5 ;
  1388.                        mousey = BLACKS[0][1]+16; m2=1; break;
  1389.              case '6': mousex = BLACKS[3][0]+5 ;
  1390.                        mousey = BLACKS[0][1]+16; m2=1; break;
  1391.              case '7': mousex = BLACKS[4][0]+5 ;
  1392.                        mousey = BLACKS[0][1]+16; m2=1; break;
  1393.  
  1394.              case '9':
  1395.              case 'S': mousex = BLACKS[5][0]+5 ;
  1396.                        mousey = BLACKS[0][1]+16; m2=1; break;
  1397.              case '0':
  1398.              case 'D': mousex = BLACKS[6][0]+5 ;
  1399.                        mousey = BLACKS[0][1]+16; m2=1; break;
  1400.              case '=':
  1401.              case '+':
  1402.              case 'G': mousex = BLACKS[7][0]+5 ;
  1403.                        mousey = BLACKS[0][1]+16; m2=1; break;
  1404.              case 'H': mousex = BLACKS[8][0]+5 ;
  1405.                        mousey = BLACKS[0][1]+16; m2=1; break;
  1406.              case 'J': mousex = BLACKS[9][0]+5 ;
  1407.                        mousey = BLACKS[0][1]+16; m2=1; break;
  1408.  
  1409.             /* 2 octaves available on keys */
  1410.  
  1411.             case 'Q': mousex = WHITES[0][0]+8  ;
  1412.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1413.             case 'W': mousex = WHITES[1][0]+8  ;
  1414.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1415.             case 'E': mousex = WHITES[2][0]+8  ;
  1416.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1417.             case 'R': mousex = WHITES[3][0]+8  ;
  1418.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1419.             case 'T': mousex = WHITES[4][0]+8  ;
  1420.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1421.             case 'Y': mousex = WHITES[5][0]+8  ;
  1422.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1423.             case 'U': mousex = WHITES[6][0]+8  ;
  1424.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1425.  
  1426.             case 'I':
  1427.             case 'Z': /* c */
  1428.                       mousex = WHITES[7][0]+8  ;
  1429.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1430.             case 'O':
  1431.             case 'X': mousex = WHITES[8][0]+8  ;
  1432.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1433.             case 'P':
  1434.             case 'C': mousex = WHITES[9][0]+8  ;
  1435.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1436.             case '{':
  1437.             case '[':
  1438.             case 'V': mousex = WHITES[10][0]+8  ;
  1439.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1440.             case '}':
  1441.             case ']':
  1442.             case 'B': mousex = WHITES[11][0]+8  ;
  1443.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1444.             case 'N': mousex = WHITES[12][0]+8  ;
  1445.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1446.             case 'M': mousex = WHITES[13][0]+8  ;
  1447.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1448.             case '<':
  1449.             case ',':
  1450.                       /* c */
  1451.                       mousex = WHITES[14][0]+8  ;
  1452.                       mousey = BLACKS[0][3]+14 ; m2=1;break;
  1453.         }
  1454.         x=mousex;
  1455.         y=mousey;
  1456.         cursoroff();
  1457.         cursoron();
  1458.         }
  1459.  
  1460.      }
  1461.  
  1462.       /* don't wait for a button release */
  1463.       /* get our menu status and note info based on location */
  1464.       frequency=getfrequency(x,y);
  1465.  
  1466.       /* if we are over the key board play the note */
  1467.       switch(frequency)
  1468.       {
  1469.         case FLIP   :
  1470.         case SILENCE:
  1471.         case QUIT   : break;
  1472.         default     : sound(frequency,duration);
  1473.         }
  1474.  
  1475.      if(frequency==FLIP)    /* song selection menu */
  1476.      {
  1477.  
  1478.         /* turn off cursor */
  1479.         inregs.x.ax=2;
  1480.         int86(0x33,&inregs,&outregs);
  1481.  
  1482.         /* draw the screen */
  1483.         drawscreen(2);
  1484.         oldchoice = -1;
  1485.         newchoice = -1;
  1486.  
  1487.       NEXTPAGE:;   /* short jump back to here if only a page flip */
  1488.  
  1489.  
  1490.         /* turn on the cursor */
  1491.  
  1492.         inregs.x.ax=1;
  1493.         int86(0x33,&inregs,&outregs);
  1494.  
  1495.         songchoice=-1;
  1496.  
  1497.         while(songchoice==-1)
  1498.          {
  1499.          m2=0;
  1500.          /* wait here for a button press */
  1501.          while(!(m2))
  1502.          {
  1503.          inregs.x.ax=3;
  1504.          int86(0x33,&inregs,&outregs);
  1505.          m2 = outregs.x.bx   ;
  1506.          x  = outregs.x.cx/2 ;
  1507.          y  = outregs.x.dx   ; /* get mouse location and button status */
  1508.          newchoice=getsoundfile(x,y);
  1509.  
  1510.          if(newchoice!=oldchoice)
  1511.          {
  1512.               /* turn off cursor */
  1513.                  inregs.x.ax=2;
  1514.                  int86(0x33,&inregs,&outregs);
  1515.  
  1516.               if(oldchoice > -1 && oldchoice <20)
  1517.               {
  1518.                _putimage(soundbox[oldchoice][0]+1,
  1519.                          soundbox[oldchoice][1]+1,imagebuf,_GPSET);
  1520.                }
  1521.                if(newchoice > -1 && newchoice < 20)
  1522.                {
  1523.                _getimage(soundbox[newchoice][0]+1,
  1524.                          soundbox[newchoice][1]+1,
  1525.                          soundbox[newchoice][2]-1,
  1526.                          soundbox[newchoice][3]-1,imagebuf);
  1527.                _putimage(soundbox[newchoice][0]+1,
  1528.                          soundbox[newchoice][1]+1,imagebuf,_GPRESET);
  1529.  
  1530.                }
  1531.               /* turn on the cursor */
  1532.               inregs.x.ax=1;
  1533.               int86(0x33,&inregs,&outregs);
  1534.           }
  1535.          oldchoice = newchoice;
  1536.          }
  1537.  
  1538.         songchoice=getsoundfile(x,y);
  1539.         }
  1540.         mousex=x;
  1541.         mousey=y;
  1542.         cursoroff();
  1543.         /* turn off cursor */
  1544.         /* draw the screen */
  1545.  
  1546.         if(songchoice!=20)
  1547.            drawscreen(1);
  1548.         else
  1549.             {
  1550.              drawscreen(3);
  1551.              goto NEXTPAGE; /* short jump to flip the page */
  1552.             }
  1553.  
  1554.         if(songchoice<20)play(soundbox[songchoice][6]);
  1555.  
  1556.          /*                                                 */
  1557.          /*  set mouse cursor location, then turn on cursor */
  1558.          /*                                                 */
  1559.          cursoron();
  1560.         }
  1561.  
  1562.     }while(frequency!=QUIT);
  1563.  
  1564.  
  1565.  /*  button down inside the quit box */
  1566.  inregs.x.ax =2;
  1567.  int86(0x33,&inregs,&outregs);      /* turn off mouse screen     */
  1568.  
  1569.  _setvideomode(6);
  1570.  cload(wordsbuffer);
  1571.  
  1572.   playit_straight(MAPLE);
  1573.  
  1574.  _setvideomode(3);                  /* reset video mode and exit */
  1575.  freeraw();
  1576.  exit(0);
  1577.  
  1578. }
  1579.  
  1580.  
  1581.