--- /dev/null
+/* Reconstructed Commander Keen 4-6 Source Code\r
+ * Copyright (C) 2021 K1n9_Duk3\r
+ *\r
+ * This file is primarily based on:\r
+ * Catacomb 3-D Source Code\r
+ * Copyright (C) 1993-2014 Flat Rock Software\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License along\r
+ * with this program; if not, write to the Free Software Foundation, Inc.,\r
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
+ */\r
+\r
+//\r
+// ID Engine\r
+// ID_SD.h - Sound Manager Header\r
+// v1.0d1\r
+// By Jason Blochowiak\r
+//\r
+\r
+#ifndef __TYPES__\r
+#include "ID_Types.h"\r
+#endif\r
+\r
+#ifndef __ID_SD__\r
+#define __ID_SD__\r
+\r
+#ifdef __DEBUG__\r
+#define __DEBUG_SoundMgr__\r
+#endif\r
+\r
+#define TickBase 70 // 70Hz per tick - used as a base for timer 0\r
+\r
+typedef enum {\r
+ sdm_Off,\r
+ sdm_PC,sdm_AdLib,\r
+ } SDMode;\r
+typedef enum {\r
+ smm_Off,smm_AdLib\r
+ } SMMode;\r
+\r
+typedef struct\r
+ {\r
+ longword length;\r
+ word priority;\r
+ } SoundCommon;\r
+\r
+// PC Sound stuff\r
+#define pcTimer 0x42\r
+#define pcTAccess 0x43\r
+#define pcSpeaker 0x61\r
+\r
+#define pcSpkBits 3\r
+\r
+typedef struct\r
+ {\r
+ SoundCommon common;\r
+ byte data[1];\r
+ } PCSound;\r
+\r
+// Registers for the Sound Blaster card - needs to be offset by n0\r
+#define sbReset 0x206\r
+#define sbReadData 0x20a\r
+#define sbWriteCmd 0x20c\r
+#define sbWriteData 0x20c\r
+#define sbWriteStat 0x20c\r
+#define sbDataAvail 0x20e\r
+\r
+typedef struct\r
+ {\r
+ SoundCommon common;\r
+ word hertz;\r
+ byte bits,\r
+ reference,\r
+ data[1];\r
+ } SampledSound;\r
+\r
+// Registers for the AdLib card\r
+// Operator stuff\r
+#define alChar 0x20\r
+#define alScale 0x40\r
+#define alAttack 0x60\r
+#define alSus 0x80\r
+#define alWave 0xe0\r
+// Channel stuff\r
+#define alFreqL 0xa0\r
+#define alFreqH 0xb0\r
+#define alFeedCon 0xc0\r
+// Global stuff\r
+#define alEffects 0xbd\r
+\r
+typedef struct\r
+ {\r
+ byte mChar,cChar,\r
+ mScale,cScale,\r
+ mAttack,cAttack,\r
+ mSus,cSus,\r
+ mWave,cWave,\r
+ nConn,\r
+\r
+ // These are only for Muse - these bytes are really unused\r
+ voice,\r
+ mode,\r
+ unused[3];\r
+ } Instrument;\r
+\r
+typedef struct\r
+ {\r
+ SoundCommon common;\r
+ Instrument inst;\r
+ byte block,\r
+ data[1];\r
+ } AdLibSound;\r
+\r
+//\r
+// Sequencing stuff\r
+//\r
+#define sqMaxTracks 10\r
+#define sqMaxMoods 1 // DEBUG\r
+\r
+#define sev_Null 0 // Does nothing\r
+#define sev_NoteOff 1 // Turns a note off\r
+#define sev_NoteOn 2 // Turns a note on\r
+#define sev_NotePitch 3 // Sets the pitch of a currently playing note\r
+#define sev_NewInst 4 // Installs a new instrument\r
+#define sev_NewPerc 5 // Installs a new percussive instrument\r
+#define sev_PercOn 6 // Turns a percussive note on\r
+#define sev_PercOff 7 // Turns a percussive note off\r
+#define sev_SeqEnd -1 // Terminates a sequence\r
+\r
+// Flags for MusicGroup.flags\r
+#define sf_Melodic 0\r
+#define sf_Percussive 1\r
+\r
+#if 1\r
+typedef struct\r
+ {\r
+ word length,\r
+ values[1];\r
+ } MusicGroup;\r
+#else\r
+typedef struct\r
+ {\r
+ word flags,\r
+ count,\r
+ offsets[1];\r
+ } MusicGroup;\r
+#endif\r
+\r
+typedef struct\r
+ {\r
+ /* This part needs to be set up by the user */\r
+ word mood,far *moods[sqMaxMoods];\r
+\r
+ /* The rest is set up by the code */\r
+ Instrument inst;\r
+ boolean percussive;\r
+ word far *seq;\r
+ longword nextevent;\r
+ } ActiveTrack;\r
+\r
+#define sqmode_Normal 0\r
+#define sqmode_FadeIn 1\r
+#define sqmode_FadeOut 2\r
+\r
+#define sqMaxFade 64 // DEBUG\r
+\r
+\r
+// Global variables\r
+extern boolean AdLibPresent,\r
+ NeedsMusic, // For Caching Mgr\r
+ QuietFX;\r
+extern SDMode SoundMode;\r
+extern SMMode MusicMode;\r
+extern longword TimeCount; // Global time in ticks\r
+\r
+// Function prototypes\r
+extern void SD_Startup(void),\r
+ SD_Shutdown(void),\r
+ SD_Default(boolean gotit,SDMode sd,SMMode sm),\r
+ SD_PlaySound(soundnames sound),\r
+ SD_StopSound(void),\r
+ SD_WaitSoundDone(void),\r
+ SD_StartMusic(MusicGroup far *music),\r
+ SD_MusicOn(void),\r
+ SD_MusicOff(void),\r
+ SD_FadeOutMusic(void),\r
+ SD_SetUserHook(void (*hook)(void));\r
+extern boolean SD_MusicPlaying(void),\r
+ SD_SetSoundMode(SDMode mode),\r
+ SD_SetMusicMode(SMMode mode);\r
+extern word SD_SoundPlaying(void);\r
+\r
+#ifdef _MUSE_ // MUSE Goes directly to the lower level routines\r
+extern void SDL_PCPlaySound(PCSound far *sound),\r
+ SDL_PCStopSound(void),\r
+ SDL_ALPlaySound(AdLibSound far *sound),\r
+ SDL_ALStopSound(void);\r
+#endif\r
+\r
+#endif\r