]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_sd.h
i did some minor things including commenting out some joy stick timing stuff and...
[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 //#define SD_USECATA3DSETTIMERSPEED\r
38 \r
39 void    alOut(byte n,byte b);\r
40 \r
41 #ifdef  __DEBUG__\r
42 #define __DEBUG_SoundMgr__\r
43 #endif\r
44 \r
45 #define TickBase        70              // 70Hz per tick - used as a base for timer 0\r
46 \r
47 typedef enum    {\r
48                                         sdm_Off,\r
49                                         sdm_PC,sdm_AdLib,\r
50                                 }       SDMode;\r
51 typedef enum    {\r
52                                         smm_Off,smm_AdLib\r
53                                 }       SMMode;\r
54 typedef enum    {\r
55                                         sds_Off,sds_PC,sds_SoundSource,sds_SoundBlaster\r
56                                 }       SDSMode;\r
57 typedef struct\r
58                 {\r
59                         dword   length;\r
60                         word            priority;\r
61                 } SoundCommon;\r
62 \r
63 //      PC Sound stuff\r
64 #define pcTimer         0x42\r
65 #define pcTAccess       0x43\r
66 #define pcSpeaker       0x61\r
67 \r
68 #define pcSpkBits       3\r
69 \r
70 typedef struct\r
71                 {\r
72                         SoundCommon     common;\r
73                         byte            data[1];\r
74                 } PCSound;\r
75 \r
76 //      Registers for the Sound Blaster card - needs to be offset by n0 (0x10,0x20,0x30,0x40,0x50,0x60)\r
77 #define sbReset         0x206   // W\r
78 #define sbFMStatus      0x208   // R\r
79 #define sbFMAddr        0x208   // W\r
80 #define sbFMData        0x209   // W\r
81 #define sbReadData      0x20a   // R\r
82 #define sbWriteCmd      0x20c   // W\r
83 #define sbWriteData     0x20c   // W\r
84 #define sbWriteStat     0x20c   // R\r
85 #define sbDataAvail     0x20e   // R\r
86 \r
87 //      Registers for the Sound Blaster Pro card - needs to be offset by n0 (0x20 or 0x40)\r
88 #define sbpLFMStatus    0x200   // R\r
89 #define sbpLFMAddr              0x200   // W\r
90 #define sbpLFMData              0x201   // W\r
91 #define sbpRFMStatus    0x202   // R\r
92 #define sbpRFMAddr              0x202   // W\r
93 #define sbpRFMData              0x203   // W\r
94 #define sbpMixerAddr    0x204   // W\r
95 #define sbpMixerData    0x205   // RW\r
96 #define sbpCDData               0x210   // R\r
97 #define sbpCDCommand    0x210   // W\r
98 #define sbpCDStatus             0x211   // R\r
99 #define sbpCDReset              0x212   // W\r
100 \r
101 //      SBPro Mixer addresses\r
102 #define sbpmReset               0x00\r
103 #define sbpmVoiceVol    0x04\r
104 #define sbpmMicMix              0x0a\r
105 #define sbpmFilterADC   0x0c\r
106 #define sbpmControl             0x0e\r
107 #define sbpmMasterVol   0x22\r
108 #define sbpmFMVol               0x26\r
109 #define sbpmCDVol               0x28\r
110 #define sbpmLineVol             0x2e\r
111 \r
112 typedef struct\r
113                 {\r
114                         SoundCommon     common;\r
115                         word            hertz;\r
116                         byte            bits,\r
117                                                 reference,\r
118                                                 data[1];\r
119                 } SampledSound;\r
120 \r
121 //      Registers for the AdLib card\r
122 #define alFMStatus      0x388   // R\r
123 #define alFMAddr        0x388   // W\r
124 #define alFMData        0x389   // W\r
125 \r
126 //      Register addresses\r
127 // Operator stuff\r
128 #define alChar          0x20\r
129 #define alScale         0x40\r
130 #define alAttack        0x60\r
131 #define alSus           0x80\r
132 #define alWave          0xe0\r
133 // Channel stuff\r
134 #define alFreqL         0xa0\r
135 #define alFreqH         0xb0\r
136 #define alFeedCon       0xc0\r
137 // Global stuff\r
138 #define alEffects       0xbd\r
139 \r
140 typedef struct\r
141                 {\r
142                         byte    mChar,cChar,\r
143                                         mScale,cScale,\r
144                                         mAttack,cAttack,\r
145                                         mSus,cSus,\r
146                                         mWave,cWave,\r
147                                         nConn,\r
148 \r
149                                         // These are only for Muse - these bytes are really unused\r
150                                         voice,\r
151                                         mode,\r
152                                         unused[3];\r
153                 } Instrument;\r
154 \r
155 typedef struct\r
156                 {\r
157                         SoundCommon     common;\r
158                         Instrument      inst;\r
159                         byte            block,\r
160                                                 data[1];\r
161                 } AdLibSound;\r
162 \r
163 //\r
164 //      Sequencing stuff\r
165 //\r
166 #define sqMaxTracks     10\r
167 #define sqMaxMoods      1       // DEBUG\r
168 \r
169 #define sev_Null                0       // Does nothing\r
170 #define sev_NoteOff             1       // Turns a note off\r
171 #define sev_NoteOn              2       // Turns a note on\r
172 #define sev_NotePitch   3       // Sets the pitch of a currently playing note\r
173 #define sev_NewInst             4       // Installs a new instrument\r
174 #define sev_NewPerc             5       // Installs a new percussive instrument\r
175 #define sev_PercOn              6       // Turns a percussive note on\r
176 #define sev_PercOff             7       // Turns a percussive note off\r
177 #define sev_SeqEnd              -1      // Terminates a sequence\r
178 \r
179 //      Flags for MusicGroup.flags\r
180 #define sf_Melodic              0\r
181 #define sf_Percussive   1\r
182 \r
183 #if 1\r
184 typedef struct\r
185                 {\r
186                         word    length,\r
187                                         values[1];\r
188                 } MusicGroup;\r
189 #else\r
190 typedef struct\r
191                 {\r
192                         word    flags,\r
193                                         count,\r
194                                         offsets[1];\r
195                 } MusicGroup;\r
196 #endif\r
197 \r
198 typedef struct\r
199                 {\r
200                         /* This part needs to be set up by the user */\r
201                         word        mood,far *moods[sqMaxMoods];\r
202 \r
203                         /* The rest is set up by the code */\r
204                         Instrument      inst;\r
205                         boolean         percussive;\r
206                         word            far *seq;\r
207                         dword   nextevent;\r
208                 } ActiveTrack;\r
209 \r
210 #define sqmode_Normal           0\r
211 #define sqmode_FadeIn           1\r
212 #define sqmode_FadeOut          2\r
213 \r
214 #define sqMaxFade               64      // DEBUG\r
215 \r
216 \r
217 // Global variables\r
218 extern  boolean         AdLibPresent,\r
219                                         SoundSourcePresent,\r
220                                         SoundBlasterPresent,\r
221                                         NeedsMusic,                                     // For Caching Mgr\r
222                                         SoundPositioned;\r
223 extern  SDMode          SoundMode;\r
224 extern  SDSMode         DigiMode;\r
225 extern  SMMode          MusicMode;\r
226 extern  boolean         DigiPlaying;\r
227 extern  int                     DigiMap[];\r
228 extern  dword   TimeCount;                                      // Global time in ticks\r
229 \r
230 // Function prototypes\r
231 extern  void    SD_Startup(global_game_variables_t *gvar),\r
232                                 SD_Shutdown(global_game_variables_t *gvar),\r
233                                 SD_Default(boolean gotit,SDMode sd,SMMode sm, global_game_variables_t *gvar),\r
234 \r
235                                 SD_PositionSound(int leftvol,int rightvol);\r
236 extern  boolean SD_PlaySound(soundnames sound, global_game_variables_t *gvar);\r
237 extern  void    SD_SetPosition(int leftvol,int rightvol, global_game_variables_t *gvar),\r
238                                 SD_StopSound(global_game_variables_t *gvar),\r
239                                 SD_WaitSoundDone(void),\r
240 \r
241                                 SD_StartMusic(MusicGroup far *music),\r
242                                 SD_MusicOn(void),\r
243                                 SD_MusicOff(void),\r
244                                 SD_FadeOutMusic(void),\r
245 \r
246                                 SD_SetUserHook(void (*hook)(void));\r
247 extern  boolean SD_MusicPlaying(void),\r
248                                 SD_SetSoundMode(SDMode mode, global_game_variables_t *gvar),\r
249                                 SD_SetMusicMode(SMMode mode);\r
250 extern  word    SD_SoundPlaying(void);\r
251 \r
252 extern  void    SD_SetDigiDevice(SDSMode, global_game_variables_t *gvar),\r
253                                 SD_PlayDigitized(word which,int leftpos,int rightpos, global_game_variables_t *gvar),\r
254                                 SD_StopDigitized(global_game_variables_t *gvar),\r
255                                 SD_Poll(global_game_variables_t *gvar);\r
256 \r
257 #ifdef  _MUSE_  // MUSE Goes directly to the lower level routines\r
258 extern  void    SDL_PCPlaySound(PCSound far *sound, global_game_variables_t *gvar),\r
259                                 SDL_PCStopSound(void),\r
260                                 SDL_ALPlaySound(AdLibSound far *sound),\r
261                                 SDL_ALStopSound(void);\r
262 #endif\r
263 \r
264 #endif\r