wolf3d

The original open source release of Wolfenstein 3D
Log | Files | Refs

ID_SD.H (5211B)


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