]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_sd.h
i want to test it before i mess with the variable pushing to gvar
[16.git] / src / lib / 16_sd.h
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 \r
23 //\r
24 //      ID Engine\r
25 //      ID_SD.h - Sound Manager Header\r
26 //      Version for Wolfenstein\r
27 //      By Jason Blochowiak\r
28 //      Open Watcom port by sparky4\r
29 //\r
30 \r
31 #ifndef __16_SD__\r
32 #define __16_SD__\r
33 \r
34 #include "src/lib/16_head.h"\r
35 #include "src/lib/16_pm.h"\r
36 \r
37 void    alOut(byte n,byte b);\r
38 \r
39 #ifdef  __DEBUG__\r
40 #define __DEBUG_SoundMgr__\r
41 #endif\r
42 \r
43 #define TickBase        70              // 70Hz per tick - used as a base for timer 0\r
44 \r
45 typedef enum    {\r
46                                         sdm_Off,\r
47                                         sdm_PC,sdm_AdLib,\r
48                                 }       SDMode;\r
49 typedef enum    {\r
50                                         smm_Off,smm_AdLib\r
51                                 }       SMMode;\r
52 typedef enum    {\r
53                                         sds_Off,sds_PC,sds_SoundSource,sds_SoundBlaster\r
54                                 }       SDSMode;\r
55 typedef struct\r
56                 {\r
57                         dword   length;\r
58                         word            priority;\r
59                 } SoundCommon;\r
60 \r
61 //      PC Sound stuff\r
62 #define pcTimer         0x42\r
63 #define pcTAccess       0x43\r
64 #define pcSpeaker       0x61\r
65 \r
66 #define pcSpkBits       3\r
67 \r
68 typedef struct\r
69                 {\r
70                         SoundCommon     common;\r
71                         byte            data[1];\r
72                 } PCSound;\r
73 \r
74 //      Registers for the Sound Blaster card - needs to be offset by n0 (0x10,0x20,0x30,0x40,0x50,0x60)\r
75 #define sbReset         0x206   // W\r
76 #define sbFMStatus      0x208   // R\r
77 #define sbFMAddr        0x208   // W\r
78 #define sbFMData        0x209   // W\r
79 #define sbReadData      0x20a   // R\r
80 #define sbWriteCmd      0x20c   // W\r
81 #define sbWriteData     0x20c   // W\r
82 #define sbWriteStat     0x20c   // R\r
83 #define sbDataAvail     0x20e   // R\r
84 \r
85 //      Registers for the Sound Blaster Pro card - needs to be offset by n0 (0x20 or 0x40)\r
86 #define sbpLFMStatus    0x200   // R\r
87 #define sbpLFMAddr              0x200   // W\r
88 #define sbpLFMData              0x201   // W\r
89 #define sbpRFMStatus    0x202   // R\r
90 #define sbpRFMAddr              0x202   // W\r
91 #define sbpRFMData              0x203   // W\r
92 #define sbpMixerAddr    0x204   // W\r
93 #define sbpMixerData    0x205   // RW\r
94 #define sbpCDData               0x210   // R\r
95 #define sbpCDCommand    0x210   // W\r
96 #define sbpCDStatus             0x211   // R\r
97 #define sbpCDReset              0x212   // W\r
98 \r
99 //      SBPro Mixer addresses\r
100 #define sbpmReset               0x00\r
101 #define sbpmVoiceVol    0x04\r
102 #define sbpmMicMix              0x0a\r
103 #define sbpmFilterADC   0x0c\r
104 #define sbpmControl             0x0e\r
105 #define sbpmMasterVol   0x22\r
106 #define sbpmFMVol               0x26\r
107 #define sbpmCDVol               0x28\r
108 #define sbpmLineVol             0x2e\r
109 \r
110 typedef struct\r
111                 {\r
112                         SoundCommon     common;\r
113                         word            hertz;\r
114                         byte            bits,\r
115                                                 reference,\r
116                                                 data[1];\r
117                 } SampledSound;\r
118 \r
119 //      Registers for the AdLib card\r
120 #define alFMStatus      0x388   // R\r
121 #define alFMAddr        0x388   // W\r
122 #define alFMData        0x389   // W\r
123 \r
124 //      Register addresses\r
125 // Operator stuff\r
126 #define alChar          0x20\r
127 #define alScale         0x40\r
128 #define alAttack        0x60\r
129 #define alSus           0x80\r
130 #define alWave          0xe0\r
131 // Channel stuff\r
132 #define alFreqL         0xa0\r
133 #define alFreqH         0xb0\r
134 #define alFeedCon       0xc0\r
135 // Global stuff\r
136 #define alEffects       0xbd\r
137 \r
138 typedef struct\r
139                 {\r
140                         byte    mChar,cChar,\r
141                                         mScale,cScale,\r
142                                         mAttack,cAttack,\r
143                                         mSus,cSus,\r
144                                         mWave,cWave,\r
145                                         nConn,\r
146 \r
147                                         // These are only for Muse - these bytes are really unused\r
148                                         voice,\r
149                                         mode,\r
150                                         unused[3];\r
151                 } Instrument;\r
152 \r
153 typedef struct\r
154                 {\r
155                         SoundCommon     common;\r
156                         Instrument      inst;\r
157                         byte            block,\r
158                                                 data[1];\r
159                 } AdLibSound;\r
160 \r
161 //\r
162 //      Sequencing stuff\r
163 //\r
164 #define sqMaxTracks     10\r
165 #define sqMaxMoods      1       // DEBUG\r
166 \r
167 #define sev_Null                0       // Does nothing\r
168 #define sev_NoteOff             1       // Turns a note off\r
169 #define sev_NoteOn              2       // Turns a note on\r
170 #define sev_NotePitch   3       // Sets the pitch of a currently playing note\r
171 #define sev_NewInst             4       // Installs a new instrument\r
172 #define sev_NewPerc             5       // Installs a new percussive instrument\r
173 #define sev_PercOn              6       // Turns a percussive note on\r
174 #define sev_PercOff             7       // Turns a percussive note off\r
175 #define sev_SeqEnd              -1      // Terminates a sequence\r
176 \r
177 //      Flags for MusicGroup.flags\r
178 #define sf_Melodic              0\r
179 #define sf_Percussive   1\r
180 \r
181 #if 1\r
182 typedef struct\r
183                 {\r
184                         word    length,\r
185                                         values[1];\r
186                 } MusicGroup;\r
187 #else\r
188 typedef struct\r
189                 {\r
190                         word    flags,\r
191                                         count,\r
192                                         offsets[1];\r
193                 } MusicGroup;\r
194 #endif\r
195 \r
196 typedef struct\r
197                 {\r
198                         /* This part needs to be set up by the user */\r
199                         word        mood,far *moods[sqMaxMoods];\r
200 \r
201                         /* The rest is set up by the code */\r
202                         Instrument      inst;\r
203                         boolean         percussive;\r
204                         word            far *seq;\r
205                         dword   nextevent;\r
206                 } ActiveTrack;\r
207 \r
208 #define sqmode_Normal           0\r
209 #define sqmode_FadeIn           1\r
210 #define sqmode_FadeOut          2\r
211 \r
212 #define sqMaxFade               64      // DEBUG\r
213 \r
214 \r
215 // Global variables\r
216 extern  boolean         AdLibPresent,\r
217                                         SoundSourcePresent,\r
218                                         SoundBlasterPresent,\r
219                                         NeedsMusic,                                     // For Caching Mgr\r
220                                         SoundPositioned;\r
221 extern  SDMode          SoundMode;\r
222 extern  SDSMode         DigiMode;\r
223 extern  SMMode          MusicMode;\r
224 extern  boolean         DigiPlaying;\r
225 extern  int                     DigiMap[];\r
226 extern  dword   TimeCount;                                      // Global time in ticks\r
227 \r
228 // Function prototypes\r
229 extern  void    SD_Startup(global_game_variables_t *gvar),\r
230                                 SD_Shutdown(global_game_variables_t *gvar),\r
231                                 SD_Default(boolean gotit,SDMode sd,SMMode sm, global_game_variables_t *gvar),\r
232 \r
233                                 SD_PositionSound(int leftvol,int rightvol);\r
234 extern  boolean SD_PlaySound(soundnames sound, global_game_variables_t *gvar);\r
235 extern  void    SD_SetPosition(int leftvol,int rightvol, global_game_variables_t *gvar),\r
236                                 SD_StopSound(global_game_variables_t *gvar),\r
237                                 SD_WaitSoundDone(void),\r
238 \r
239                                 SD_StartMusic(MusicGroup far *music),\r
240                                 SD_MusicOn(void),\r
241                                 SD_MusicOff(void),\r
242                                 SD_FadeOutMusic(void),\r
243 \r
244                                 SD_SetUserHook(void (*hook)(void));\r
245 extern  boolean SD_MusicPlaying(void),\r
246                                 SD_SetSoundMode(SDMode mode, global_game_variables_t *gvar),\r
247                                 SD_SetMusicMode(SMMode mode);\r
248 extern  word    SD_SoundPlaying(void);\r
249 \r
250 extern  void    SD_SetDigiDevice(SDSMode, global_game_variables_t *gvar),\r
251                                 SD_PlayDigitized(word which,int leftpos,int rightpos, global_game_variables_t *gvar),\r
252                                 SD_StopDigitized(global_game_variables_t *gvar),\r
253                                 SD_Poll(global_game_variables_t *gvar);\r
254 \r
255 #ifdef  _MUSE_  // MUSE Goes directly to the lower level routines\r
256 extern  void    SDL_PCPlaySound(PCSound far *sound, global_game_variables_t *gvar),\r
257                                 SDL_PCStopSound(void),\r
258                                 SDL_ALPlaySound(AdLibSound far *sound),\r
259                                 SDL_ALStopSound(void);\r
260 #endif\r
261 \r
262 #endif\r
263 \r