1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
\r
4 * This file is part of Project 16.
\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
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
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
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
34 #include "src/lib/16_head.h"
\r
35 #include "src/lib/16_pm.h"
\r
37 //#define SD_USECATA3DSETTIMERSPEED
\r
39 void alOut(byte n,byte b);
\r
42 #define __DEBUG_SoundMgr__
\r
45 #define TickBase 70 // 70Hz per tick - used as a base for timer 0
\r
55 sds_Off,sds_PC,sds_SoundSource,sds_SoundBlaster
\r
64 #define pcTimer 0x42
\r
65 #define pcTAccess 0x43
\r
66 #define pcSpeaker 0x61
\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
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
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
114 SoundCommon common;
\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
126 // Register addresses
\r
128 #define alChar 0x20
\r
129 #define alScale 0x40
\r
130 #define alAttack 0x60
\r
132 #define alWave 0xe0
\r
134 #define alFreqL 0xa0
\r
135 #define alFreqH 0xb0
\r
136 #define alFeedCon 0xc0
\r
138 #define alEffects 0xbd
\r
149 // These are only for Muse - these bytes are really unused
\r
157 SoundCommon common;
\r
164 // Sequencing stuff
\r
166 #define sqMaxTracks 10
\r
167 #define sqMaxMoods 1 // DEBUG
\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
179 // Flags for MusicGroup.flags
\r
180 #define sf_Melodic 0
\r
181 #define sf_Percussive 1
\r
200 /* This part needs to be set up by the user */
\r
201 word mood,far *moods[sqMaxMoods];
\r
203 /* The rest is set up by the code */
\r
205 boolean percussive;
\r
210 #define sqmode_Normal 0
\r
211 #define sqmode_FadeIn 1
\r
212 #define sqmode_FadeOut 2
\r
214 #define sqMaxFade 64 // DEBUG
\r
217 // Global variables
\r
218 extern boolean AdLibPresent,
\r
219 SoundSourcePresent,
\r
220 SoundBlasterPresent,
\r
221 NeedsMusic, // For Caching Mgr
\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
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
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
241 SD_StartMusic(MusicGroup far *music),
\r
244 SD_FadeOutMusic(void),
\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
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
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