home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser 2002 January / STC_CD_01_2002.iso / GAMES / BOINKO21 / SRC / SRC / BO_SOUND.C < prev    next >
C/C++ Source or Header  |  2000-09-28  |  3KB  |  177 lines

  1. /* Boinkout2 sound routines */
  2.  
  3. #include "boink.h"
  4.  
  5. long snd_system = 0;  /* This is the soundsystem that exists on the computer */
  6. int sound_switch = 1;
  7.  
  8.  
  9. /* First the atari sound routines: */
  10. #if OS_TOS
  11.  
  12.  
  13. /* the sound string is the yamaha sound chip parameter for the bouncing        */
  14. /* ball sound. The osound array resets the modified sound chip registers    */
  15. /* to their old values so that key click sounds will be normal when the        */
  16. /* program terminates.                                                        */
  17.  
  18. char sound[] =    {
  19.     0,0xf0,1,0x0f, 2,0xff, 3,0x0f, 4,0x00, 5,0, 6,0x1f, 7,0xdc,
  20.     8,0x10,9,0x10,10,0x10,11,0x00,12,25,13,0,0xff,0
  21.     };
  22.  
  23. short appear[] = {
  24.     0x040,0x102,0x242,0x302,0x400,0x500,0x61f,0x7dc,
  25.     0x810,0x910,0xA10,0xB00,0xC15,0xD0f,0xFF00
  26.     };
  27.  
  28. /* osound restores registers 9 and 10 for normal key click */
  29. char osound[] = { 9, 0, 10, 0, 0xff, 0    };
  30.  
  31. short magic_bell[] = {
  32.     0x0ff,0x100,0x2fe,0x300,0x400,0x500,0x600,0x7fc,
  33.     0x810,0x910,0xa00,0xb00,0xc20,0xd09,0xff00
  34.     };
  35.  
  36. short bricksound[] = {
  37.     0x035,0x100,0x234,0x300,0x400,0x500,0x600,0x7fc,
  38.     0x810,0x910,0xa00,0xb00,0xc15,0xd09,0xff00
  39.     };
  40.  
  41. short permbricksound[] = {
  42.     0x038,0x100,0x237,0x300,0x400,0x500,0x600,0x7fc,
  43.     0x810,0x910,0xa00,0xb00,0xc0b,0xd09,0xff00
  44.     };
  45.  
  46. short death[] = {
  47.     0x0018,0x0100,0x073e,0x0810,0x0d09,0x8000,0x0b00,0x0c60,
  48.     0x8100,0xce01,0xff00
  49.     };
  50.  
  51. short lost_ball[] = {
  52.     0x0000,0x0102,0x073e,0x0810,0x0d09,0x8000,0x0b00,0x0c30,
  53.     0x8100,0x1801,0xff00
  54.     };
  55.  
  56. short psound[] = {
  57.     0x041,0x100,0x240,0x300,0x400,0x500,0x600,0x7fc,
  58.     0x810,0x910,0xa00,0xb00,0xc15,0xd09,0xff00
  59.     };
  60.  
  61. short bonus[] = {        /* bonus sound effect */
  62.     0x000,0x100,0x200,0x300,0x400,0x500,0x600,0x7FE,
  63.     0x80F,0x900,0xA00,0xB00,0xC00,0xD00,
  64.     0x8040,0x8100,0xfd31,
  65.     0x8040,0x8100,0xfd31,
  66.     0x8040,0x8100,0xfd31,
  67.     0x800,0xFF00
  68.     };
  69.  
  70.  
  71. /* Initialize the sounds - only a dummy function by now, but */
  72. /* one day, we could load here the sample sound for example  */
  73. int sound_init()
  74. {
  75.  return 0;
  76. }
  77.  
  78. /* Play a sound */
  79. int sound_play(int num)
  80. {
  81.  static void *dosndtab[]={appear, magic_bell, bricksound, permbricksound,
  82.                  death, lost_ball, psound, bonus };
  83.  
  84.  if (sound_switch == 1)
  85.   {
  86.    if(num<=S_BONUS)
  87.      Dosound(dosndtab[num]);
  88.     else
  89.      switch(num)
  90.       {
  91.        case S_SIDE:
  92.     *(sound + 13) = 0x1e;
  93.     Dosound(sound);
  94.     break;
  95.        case S_TOP:
  96.     *(sound + 13) = 0x1d;
  97.     Dosound(sound);
  98.     break;
  99.        case S_BOTTOM:
  100.     *(sound + 13) = 0x1f;
  101.     Dosound(sound);
  102.     break;
  103.       }
  104.   }
  105.  
  106.  return 0;
  107. }
  108.  
  109. int sound_exit()
  110. {
  111.  Dosound(osound);
  112.  return 0;
  113. }
  114.  
  115.  
  116. #endif /* OS_TOS */
  117.  
  118.  
  119.  
  120.  
  121. /* And now the poor DOS sound routines */
  122.  
  123. #if OS_DOS
  124.  
  125.  
  126. int sound_init()
  127. {
  128.  return 0;
  129. }
  130.  
  131. /* Play a sound */
  132. int sound_play(int num)
  133. {
  134.  int i;
  135.  if (sound_switch == 1)
  136.   {
  137.    switch(num)
  138.     {
  139.      case S_APPEAR:
  140.     for(i=400; i<1000; i+=80)  v_sound(vdi_handle, i, 1);
  141.     break;
  142.      case S_BRICKSOUND:
  143.     v_sound(vdi_handle, 1600, 1);
  144.     break;
  145.      case S_PERMBRICKSOUND:
  146.     v_sound(vdi_handle, 1000, 1);
  147.     break;
  148.      case S_DEATH:
  149.     for(i=1000; i>400; i-=80)  v_sound(vdi_handle, i, 1);
  150.     break;
  151.      case S_LOSTBALL:
  152.     for(i=800; i>400; i-=100)  v_sound(vdi_handle, i, 1);
  153.     break;
  154.      case S_SIDE:
  155.     v_sound(vdi_handle, 50, 1);
  156.     break;
  157.      case S_TOP:
  158.     v_sound(vdi_handle, 100, 1);
  159.     break;
  160.      case S_BOTTOM:
  161.     v_sound(vdi_handle, 150, 1);
  162.     break;
  163.     }
  164.   }
  165.  
  166.  return 0;
  167. }
  168.  
  169. int sound_exit()
  170. {
  171.  return 0;
  172. }
  173.  
  174.  
  175. #endif /* OS_DOS */
  176.  
  177.