ID_SD.H 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /* Catacomb Apocalypse Source Code
  2. * Copyright (C) 1993-2014 Flat Rock Software
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. //
  19. // ID Engine
  20. // ID_SD.h - Sound Manager Header
  21. // v1.0d1
  22. // By Jason Blochowiak
  23. //
  24. #ifndef __TYPES__
  25. #include "ID_Types.h"
  26. #endif
  27. #ifndef __ID_SD__
  28. #define __ID_SD__
  29. #ifdef __DEBUG__
  30. #define __DEBUG_SoundMgr__
  31. #endif
  32. #define TickBase 70 // 70Hz per tick - used as a base for timer 0
  33. typedef enum {
  34. sdm_Off,
  35. sdm_PC,sdm_AdLib,
  36. } SDMode;
  37. typedef enum {
  38. smm_Off,smm_AdLib
  39. } SMMode;
  40. typedef struct
  41. {
  42. longword length;
  43. word priority;
  44. } SoundCommon;
  45. // PC Sound stuff
  46. #define pcTimer 0x42
  47. #define pcTAccess 0x43
  48. #define pcSpeaker 0x61
  49. #define pcSpkBits 3
  50. typedef struct
  51. {
  52. SoundCommon common;
  53. byte data[1];
  54. } PCSound;
  55. // Registers for the Sound Blaster card - needs to be offset by n0
  56. #define sbReset 0x206
  57. #define sbReadData 0x20a
  58. #define sbWriteCmd 0x20c
  59. #define sbWriteData 0x20c
  60. #define sbWriteStat 0x20c
  61. #define sbDataAvail 0x20e
  62. typedef struct
  63. {
  64. SoundCommon common;
  65. word hertz;
  66. byte bits,
  67. reference,
  68. data[1];
  69. } SampledSound;
  70. // Registers for the AdLib card
  71. // Operator stuff
  72. #define alChar 0x20
  73. #define alScale 0x40
  74. #define alAttack 0x60
  75. #define alSus 0x80
  76. #define alWave 0xe0
  77. // Channel stuff
  78. #define alFreqL 0xa0
  79. #define alFreqH 0xb0
  80. #define alFeedCon 0xc0
  81. // Global stuff
  82. #define alEffects 0xbd
  83. typedef struct
  84. {
  85. byte mChar,cChar,
  86. mScale,cScale,
  87. mAttack,cAttack,
  88. mSus,cSus,
  89. mWave,cWave,
  90. nConn,
  91. // These are only for Muse - these bytes are really unused
  92. voice,
  93. mode,
  94. unused[3];
  95. } Instrument;
  96. typedef struct
  97. {
  98. SoundCommon common;
  99. Instrument inst;
  100. byte block,
  101. data[1];
  102. } AdLibSound;
  103. //
  104. // Sequencing stuff
  105. //
  106. #define sqMaxTracks 10
  107. #define sqMaxMoods 1 // DEBUG
  108. #define sev_Null 0 // Does nothing
  109. #define sev_NoteOff 1 // Turns a note off
  110. #define sev_NoteOn 2 // Turns a note on
  111. #define sev_NotePitch 3 // Sets the pitch of a currently playing note
  112. #define sev_NewInst 4 // Installs a new instrument
  113. #define sev_NewPerc 5 // Installs a new percussive instrument
  114. #define sev_PercOn 6 // Turns a percussive note on
  115. #define sev_PercOff 7 // Turns a percussive note off
  116. #define sev_SeqEnd -1 // Terminates a sequence
  117. // Flags for MusicGroup.flags
  118. #define sf_Melodic 0
  119. #define sf_Percussive 1
  120. #if 1
  121. typedef struct
  122. {
  123. word length,
  124. values[1];
  125. } MusicGroup;
  126. #else
  127. typedef struct
  128. {
  129. word flags,
  130. count,
  131. offsets[1];
  132. } MusicGroup;
  133. #endif
  134. typedef struct
  135. {
  136. /* This part needs to be set up by the user */
  137. word mood,far *moods[sqMaxMoods];
  138. /* The rest is set up by the code */
  139. Instrument inst;
  140. boolean percussive;
  141. word far *seq;
  142. longword nextevent;
  143. } ActiveTrack;
  144. #define sqmode_Normal 0
  145. #define sqmode_FadeIn 1
  146. #define sqmode_FadeOut 2
  147. #define sqMaxFade 64 // DEBUG
  148. // Global variables
  149. extern boolean AdLibPresent,
  150. NeedsMusic; // For Caching Mgr
  151. extern SDMode SoundMode;
  152. extern SMMode MusicMode;
  153. extern longword TimeCount; // Global time in ticks
  154. extern SDMode oldsoundmode;
  155. // Function prototypes
  156. extern void SD_Startup(void),
  157. SD_Shutdown(void),
  158. SD_Default(boolean gotit,SDMode sd,SMMode sm),
  159. SD_PlaySound(soundnames sound),
  160. SD_StopSound(void),
  161. SD_WaitSoundDone(void),
  162. SD_StartMusic(MusicGroup far *music),
  163. SD_MusicOn(void),
  164. SD_MusicOff(void),
  165. SD_FadeOutMusic(void),
  166. SD_SetUserHook(void (*hook)(void));
  167. extern boolean SD_MusicPlaying(void),
  168. SD_SetSoundMode(SDMode mode),
  169. SD_SetMusicMode(SMMode mode);
  170. extern word SD_SoundPlaying(void);
  171. #ifdef _MUSE_ // MUSE Goes directly to the lower level routines
  172. extern void SDL_PCPlaySound(PCSound far *sound),
  173. SDL_PCStopSound(void),
  174. SDL_ALPlaySound(AdLibSound far *sound),
  175. SDL_ALStopSound(void);
  176. #endif
  177. #endif