]> 4ch.mooo.com Git - 16.git/commitdiff
id_sd.c ported and is able to compile. it needs it;s variables to be project 16 compl...
authorsparky4 <sparky4@cock.li>
Wed, 13 Sep 2017 19:29:59 +0000 (14:29 -0500)
committersparky4 <sparky4@cock.li>
Wed, 13 Sep 2017 19:29:59 +0000 (14:29 -0500)
makefile
src/lib/id_sd.c
src/lib/id_sd.h

index 4dd26ebc937c072f8b8063fe638b5d8d3aefe8d7..b66d08cecb954c7d510fe36e7fe2e61d71d498f4 100755 (executable)
--- a/makefile
+++ b/makefile
@@ -127,7 +127,7 @@ STKSIZ=32768
 S_FLAGS=-sg -st -of+ -zu -zdf -zff -zgf -k$(STKSIZ)
 Z_FLAGS=-zk0 -zc#### -zp4 -ei# -zm
 O_FLAGS=-opnr -oe=24 -oil+ -outback -ohm
-T_FLAGS=-bt=dos -wx -m$(MEMORYMODE) -0 -fpi87 $(D_FLAGS) -fo=.$(OBJ)# -e=65536
+T_FLAGS=-bt=dos -wx -m$(MEMORYMODE) -0 -fpi87 $(D_FLAGS) -fo=.$(OBJ)## -e=65536
 
 DBUGFLAGS=-fm=$^&.meh -fd=$^& $(D_FLAGS)
 CPPFLAGS=-DTARGET_MSDOS=16 -DMSDOS=1 -DSTACKSIZE=$(STKSIZ)
@@ -261,7 +261,7 @@ ALLEXEC = &
        $(TESTEXEC2) &
        $(TESTEXEC3)
 
-all: $(EXEC)#  id_sd.$(OBJ)
+all: $(EXEC)   id_sd.$(OBJ)
 testexec: $(EXEC) $(TESTEXEC2)
 
 #
index f98e88cb6a56431db6f44402fd966dee7cca3e90..8883f62a71d5a20df1b58648edeb8df9d9365c65 100755 (executable)
@@ -43,6 +43,9 @@
 //                             (Use SM_SetSoundMode() to set)\r
 //                     MusicMode - What device is used for music\r
 //                             (Use SM_SetMusicMode() to set)\r
+//                     DigiMode - What device is used for digitized sound effects\r
+//                             (Use SM_SetDigiDevice() to set)\r
+//\r
 //             For Cache Mgr:\r
 //                     NeedsDigitized - load digitized sounds?\r
 //                     NeedsMusic - load music?\r
 \r
 #include <dos.h>\r
 \r
-//#ifdef       _MUSE_      // Will be defined in ID_Types.h\r
+#ifndef        _MUSE_      // Will be defined in ID_Types.h\r
 #include "src/lib/id_sd.h"\r
-//#else\r
-//#include "ID_HEADS.H"\r
-//#endif\r
+#else\r
+#include "src/lib/16_head.h"\r
+#endif\r
 #pragma        hdrstop\r
 #pragma        warn    -pia\r
 \r
@@ -93,6 +96,8 @@
 //     Internal variables\r
 static boolean                 SD_Started;\r
                boolean                 nextsoundpos;\r
+               word/*boolean_+*/                       TimerDone;\r
+               word                    TimerVal,TimerDelay10,TimerDelay25,TimerDelay100;\r
                dword           TimerDivisor,TimerCount;\r
 static char                    *ParmStrings[] =\r
                                                {\r
@@ -122,6 +127,7 @@ static      boolean                 DigiMissed,DigiLastSegment;
 static memptr                  DigiNextAddr;\r
 static word                    DigiNextLen;\r
 \r
+#if 0\r
 //     SoundBlaster variables\r
 static boolean                                 sbNoCheck,sbNoProCheck;\r
 static volatile boolean                sbSamplePlaying;\r
@@ -146,6 +152,7 @@ static      byte                                    sbpOldFMMix,sbpOldVOCMix;
                byte                            ssOn,ssOff;\r
                volatile byte           far *ssSample;\r
                volatile dword  ssLengthLeft;\r
+#endif\r
 \r
 //     PC Sound variables\r
                volatile byte   pcLastSample,far *pcSound;\r
@@ -170,8 +177,8 @@ static      byte                    carriers[9] =  { 3, 4, 5,11,12,13,19,20,21},
 //     Sequencer variables\r
                boolean                 sqActive;\r
 static word                    alFXReg;\r
-static ActiveTrack             *tracks[sqMaxTracks],\r
-                                               mytracks[sqMaxTracks];\r
+static ActiveTrack             *tracks[sqMaxTracks];//,\r
+//--                                           mytracks[sqMaxTracks];\r
 static word                    sqMode,sqFadeStep;\r
                word                    far *sqHack,far *sqHackPtr,sqHackLen,sqHackSeqLen;\r
                long                    sqHackTime;\r
@@ -254,242 +261,116 @@ SDL_SetTimerSpeed(void)
        }\r
 }\r
 \r
-\r
-\r
-//     Sound Source Code\r
-\r
 ///////////////////////////////////////////////////////////////////////////\r
 //\r
-//     SDL_SSStopSample() - Stops a sample playing on the Sound Source\r
+//     SDL_TimingService() - Used by SDL_InitDelay() to determine a timing\r
+//             value for the current system that we're running on\r
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
-#ifdef _MUSE_\r
-void\r
-#else\r
-static void\r
-#endif\r
-SDL_SSStopSample(void)\r
+//static void interrupt\r
+void interrupt\r
+SDL_TimingService(void)\r
 {\r
-asm    pushf\r
-asm    cli\r
-\r
-       /*(long)*/ssSample = 0;\r
+       //TimerVal = _CX;\r
+       __asm {\r
+               mov TimerVal,cx\r
+       }\r
+       TimerDone = 1;\r
 \r
-asm    popf\r
+       outportb(0x20,0x20);                            // Ack interrupt\r
 }\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
 //\r
-//     SDL_SSService() - Handles playing the next sample on the Sound Source\r
+//     SDL_InitDelay() - Sets up TimerDelay's for SDL_Delay()\r
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 static void\r
-SDL_SSService(void)\r
+SDL_InitDelay(void)\r
 {\r
-       //boolean       gotit;\r
-       boolean doneflag=false;\r
-       byte    v;\r
+       int             i;\r
+       word    timer;\r
 \r
-       while (ssSample)\r
+       setvect(8,SDL_TimingService);           // Set to my timer 0 ISR\r
+\r
+       SDL_SetIntsPerSec(1000);                        // Time 1ms\r
+\r
+       for (i = 0,timer = 0;i < 10;i++)        // Do timing test 10 times\r
        {\r
-       __asm {\r
-               mov             dx,[ssStatus]   // Check to see if FIFO is currently empty\r
-               in              al,dx\r
-               test    al,0x40\r
-               jnz             done                    // Nope - don't push any more data out\r
-               jmp end\r
+               __asm {\r
+                       xor             dx,dx                                   // Zero DX\r
+                       mov             cx,0xffff                               // Put starting value in CX\r
+                       mov             [TimerDone],cx                  // TimerDone = false - 1\r
 #ifdef __BORLANDC__\r
-       }\r
+               }\r
 #endif\r
-               done:\r
+startloop:\r
 #ifdef __BORLANDC__\r
-       __asm {\r
+               __asm {\r
 #endif\r
-               mov     doneflag,1\r
+                       or              [TimerDone],0\r
+                       jnz             startloop                               // Make sure we're at the start\r
 #ifdef __BORLANDC__\r
-       }\r
+               }\r
 #endif\r
-               end:\r
-#ifdef __WATCOMC__\r
-       }\r
+loop_:\r
+#ifdef __BORLANDC__\r
+               __asm {\r
 #endif\r
-               if(!doneflag)\r
-               {\r
-                       v = *ssSample++;\r
-                       if (!(--ssLengthLeft))\r
-                       {\r
-                               /*(long)*/ssSample = 0;\r
-                               SDL_DigitizedDone();\r
-                       }\r
-\r
-                       __asm {\r
-                               mov             dx,[ssData]             // Pump the value out\r
-                               mov             al,[v]\r
-                               out             dx,al\r
-\r
-                               mov             dx,[ssControl]  // Pulse printer select\r
-                               mov             al,[ssOff]\r
-                               out             dx,al\r
-                               push    ax\r
-                               pop             ax\r
-                               mov             al,[ssOn]\r
-                               out             dx,al\r
-\r
-                               push    ax                              // Delay a short while\r
-                               pop             ax\r
-                               push    ax\r
-                               pop             ax\r
-done:;\r
-                       }\r
+                       test    [TimerDone],1                   // See if TimerDone flag got hit\r
+                       jnz             done                                    // Yep - drop out of the loop\r
+                       loop    loop_\r
+#ifdef __BORLANDC__\r
                }\r
+#endif\r
+done:\r
+#ifdef __WATCOMC__\r
        }\r
-}\r
-\r
-///////////////////////////////////////////////////////////////////////////\r
-//\r
-//     SDL_SSPlaySample() - Plays the specified sample on the Sound Source\r
-//\r
-///////////////////////////////////////////////////////////////////////////\r
-#ifdef _MUSE_\r
-void\r
-#else\r
-static void\r
 #endif\r
-SDL_SSPlaySample(byte huge *data,dword len)\r
-{\r
-asm    pushf\r
-asm    cli\r
-\r
-       ssLengthLeft = len;\r
-       ssSample = (volatile byte far *)data;\r
 \r
-asm    popf\r
-}\r
-\r
-///////////////////////////////////////////////////////////////////////////\r
-//\r
-//     SDL_StartSS() - Sets up for and turns on the Sound Source\r
-//\r
-///////////////////////////////////////////////////////////////////////////\r
-static void\r
-SDL_StartSS(void)\r
-{\r
-       if (ssPort == 3)\r
-               ssControl = 0x27a;      // If using LPT3\r
-       else if (ssPort == 2)\r
-               ssControl = 0x37a;      // If using LPT2\r
-       else\r
-               ssControl = 0x3be;      // If using LPT1\r
-       ssStatus = ssControl - 1;\r
-       ssData = ssStatus - 1;\r
+               if (0xffff - TimerVal > timer)\r
+                       timer = 0xffff - TimerVal;\r
+       }\r
+       timer += timer / 2;                                     // Use some slop\r
+       TimerDelay10 =  timer / (1000 / 10);\r
+       TimerDelay25 =  timer / (1000 / 25);\r
+       TimerDelay100 = timer / (1000 / 100);\r
 \r
-       ssOn = 0x04;\r
-       if (ssIsTandy)\r
-               ssOff = 0x0e;                           // Tandy wierdness\r
-       else\r
-               ssOff = 0x0c;                           // For normal machines\r
+       SDL_SetTimer0(0);                                       // Reset timer 0\r
 \r
-       outportb(ssControl,ssOn);               // Enable SS\r
+       setvect(8,t0OldService);                        // Set back to old ISR\r
 }\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
 //\r
-//     SDL_ShutSS() - Turns off the Sound Source\r
+//     SDL_Delay() - Delays the specified amount of time\r
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 static void\r
-SDL_ShutSS(void)\r
+SDL_Delay(word delay)\r
 {\r
-       outportb(ssControl,ssOff);\r
-}\r
-\r
-///////////////////////////////////////////////////////////////////////////\r
-//\r
-//     SDL_CheckSS() - Checks to see if a Sound Source is present at the\r
-//             location specified by the sound source variables\r
-//\r
-///////////////////////////////////////////////////////////////////////////\r
-static boolean\r
-SDL_CheckSS(void)\r
-{\r
-       boolean         present = false, chkdone=0;\r
-       dword   lasttime;\r
-\r
-       // Turn the Sound Source on and wait awhile (4 ticks)\r
-       SDL_StartSS();\r
-\r
-       lasttime = TimeCount;\r
-       while (TimeCount < lasttime + 4)\r
-       {}\r
-\r
-       __asm {\r
-               mov             dx,[ssStatus]   // Check to see if FIFO is currently empty\r
-               in              al,dx\r
-               test    al,0x40\r
-               jnz             checkdone               // Nope - Sound Source not here\r
+       if (!delay)\r
+               return;\r
 \r
-               mov             cx,32                   // Force FIFO overflow (FIFO is 16 bytes)\r
-#ifdef __BORLANDC__\r
-       }\r
-#endif\r
-outloop:\r
-#ifdef __BORLANDC__\r
        __asm {\r
-#endif\r
-               mov             dx,[ssData]             // Pump a neutral value out\r
-               mov             al,0x80\r
-               out             dx,al\r
-\r
-               mov             dx,[ssControl]  // Pulse printer select\r
-               mov             al,[ssOff]\r
-               out             dx,al\r
-               push    ax\r
-               pop             ax\r
-               mov             al,[ssOn]\r
-               out             dx,al\r
-\r
-               push    ax                              // Delay a short while before we do this again\r
-               pop             ax\r
-               push    ax\r
-               pop             ax\r
-\r
-               loop    outloop\r
-\r
-               mov             dx,[ssStatus]   // Is FIFO overflowed now?\r
-               in              al,dx\r
-               test    al,0x40\r
-               jz              checkdone               // Nope, still not - Sound Source not here\r
-               jmp end\r
+               mov             cx,[delay]\r
 #ifdef __BORLANDC__\r
        }\r
 #endif\r
-checkdone:\r
+loop_:\r
 #ifdef __BORLANDC__\r
        __asm {\r
 #endif\r
-               mov     chkdone,1\r
+               test    [TimerDone],0   // Useless code - just for timing equivilency\r
+               jnz             done\r
+               loop    loop_\r
 #ifdef __BORLANDC__\r
        }\r
 #endif\r
-               end:\r
+done:\r
 #ifdef __WATCOMC__\r
        }\r
 #endif\r
-\r
-       if(!chkdone) present = true;                    // Yes - it's here!\r
-\r
-//checkdone:\r
-       SDL_ShutSS();\r
-       return(present);\r
-}\r
-\r
-static boolean\r
-SDL_DetectSoundSource(void)\r
-{\r
-       for (ssPort = 1;ssPort <= 3;ssPort++)\r
-               if (SDL_CheckSS())\r
-                       return(true);\r
-       return(false);\r
 }\r
 \r
 //\r
@@ -709,12 +590,12 @@ SDL_PlayDigiSegment(memptr addr,word len)
        case sds_PC:\r
        SDL_PCPlaySample(addr,len);\r
                break;\r
-       case sds_SoundSource:\r
-               SDL_SSPlaySample(addr,len);\r
-               break;\r
-       case sds_SoundBlaster:\r
-               SDL_SBPlaySample(addr,len);\r
-               break;\r
+//SS   case sds_SoundSource:\r
+//SS           SDL_SSPlaySample(addr,len);\r
+//SS           break;\r
+//SB   case sds_SoundBlaster:\r
+//SB           SDL_SBPlaySample(addr,len);\r
+//SB           break;\r
        }\r
 }\r
 \r
@@ -741,12 +622,12 @@ asm       cli
        case sds_PC:\r
                SDL_PCStopSample();\r
                break;\r
-       case sds_SoundSource:\r
-               SDL_SSStopSample();\r
-               break;\r
-       case sds_SoundBlaster:\r
-               SDL_SBStopSample();\r
-               break;\r
+//SS   case sds_SoundSource:\r
+//SS           SDL_SSStopSample();\r
+//SS           break;\r
+//SB   case sds_SoundBlaster:\r
+//SB           SDL_SBStopSample();\r
+//SB           break;\r
        }\r
 \r
 asm    popf\r
@@ -758,7 +639,7 @@ asm popf
 }\r
 \r
 void\r
-SD_Poll(void)\r
+SD_Poll(global_game_variables_t *gvar)\r
 {\r
        if (DigiLeft && !DigiNextAddr)\r
        {\r
@@ -766,7 +647,7 @@ SD_Poll(void)
                DigiLeft -= DigiNextLen;\r
                if (!DigiLeft)\r
                        DigiLastSegment = true;\r
-               DigiNextAddr = SDL_LoadDigiSegment(DigiPage++);\r
+               DigiNextAddr = SDL_LoadDigiSegment(DigiPage++, gvar);\r
        }\r
        if (DigiMissed && DigiNextAddr)\r
        {\r
@@ -797,9 +678,9 @@ SD_SetPosition(int leftpos,int rightpos, global_game_variables_t *gvar)
 \r
        switch (DigiMode)\r
        {\r
-       case sds_SoundBlaster:\r
-               SDL_PositionSBP(leftpos,rightpos);\r
-               break;\r
+//SB   case sds_SoundBlaster:\r
+//SB           SDL_PositionSBP(leftpos,rightpos);\r
+//SB           break;\r
        }\r
 }\r
 \r
@@ -812,11 +693,11 @@ SD_PlayDigitized(word which,int leftpos,int rightpos, global_game_variables_t *g
        if (!DigiMode)\r
                return;\r
 \r
-       SD_StopDigitized();\r
+       SD_StopDigitized(gvar);\r
        if (which >= NumDigi)\r
                Quit(gvar, "SD_PlayDigitized: bad sound number");\r
 \r
-       SD_SetPosition(leftpos,rightpos);\r
+       SD_SetPosition(leftpos,rightpos, gvar);\r
 \r
        DigiPage = DigiList[(which * 2) + 0];\r
        DigiLeft = DigiList[(which * 2) + 1];\r
@@ -825,7 +706,7 @@ SD_PlayDigitized(word which,int leftpos,int rightpos, global_game_variables_t *g
        DigiLastEnd = DigiPage + ((DigiLeft + (PMPageSize - 1)) / PMPageSize);\r
 \r
        len = (DigiLeft >= PMPageSize)? PMPageSize : (DigiLeft % PMPageSize);\r
-       addr = SDL_LoadDigiSegment(DigiPage++);\r
+       addr = SDL_LoadDigiSegment(DigiPage++, gvar);\r
 \r
        DigiPlaying = true;\r
        DigiLastSegment = false;\r
@@ -835,7 +716,7 @@ SD_PlayDigitized(word which,int leftpos,int rightpos, global_game_variables_t *g
        if (!DigiLeft)\r
                DigiLastSegment = true;\r
 \r
-       SD_Poll();\r
+       SD_Poll(gvar);\r
 }\r
 \r
 void\r
@@ -867,14 +748,14 @@ SDL_DigitizedDone(void)
 }\r
 \r
 void\r
-SD_SetDigiDevice(SDSMode mode)\r
+SD_SetDigiDevice(SDSMode mode, global_game_variables_t *gvar)\r
 {\r
        boolean devicenotpresent;\r
 \r
        if (mode == DigiMode)\r
                return;\r
 \r
-       SD_StopDigitized();\r
+       SD_StopDigitized(gvar);\r
 \r
        devicenotpresent = false;\r
        switch (mode)\r
@@ -896,13 +777,13 @@ SD_SetDigiDevice(SDSMode mode)
 \r
        if (!devicenotpresent)\r
        {\r
-               if (DigiMode == sds_SoundSource)\r
-                       SDL_ShutSS();\r
+//SS           if (DigiMode == sds_SoundSource)\r
+//SS                   SDL_ShutSS();\r
 \r
                DigiMode = mode;\r
 \r
-               if (mode == sds_SoundSource)\r
-                       SDL_StartSS();\r
+//SS           if (mode == sds_SoundSource)\r
+//SS                   SDL_StartSS();\r
 \r
                SDL_SetTimerSpeed();\r
        }\r
@@ -919,19 +800,19 @@ SDL_SetupDigi(global_game_variables_t *gvar)
        PM_UnlockMainMem(gvar);\r
        MM_GetPtr(&list,PMPageSize, gvar);\r
        PM_CheckMainMem(gvar);\r
-       p = (word far *)MK_FP(PM_GetPage(gvar->pm.fi.ChunksInFile - 1),0,gvar);\r
+       p = (word far *)MK_FP(PM_GetPage(gvar->pm.fi.ChunksInFile - 1, gvar),0);\r
        _fmemcpy((void far *)list,(void far *)p,PMPageSize);\r
        pg = gvar->pm.fi.PMSoundStart;\r
        for (i = 0;i < PMPageSize / (sizeof(word) * 2);i++,p += 2)\r
        {\r
-               if (pg >= ChunksInFile - 1)\r
+               if (pg >= gvar->pm.fi.ChunksInFile - 1)\r
                        break;\r
                pg += (p[1] + (PMPageSize - 1)) / PMPageSize;\r
        }\r
-       PM_UnlockMainMem();\r
-       MM_GetPtr((memptr *)&DigiList,i * sizeof(word) * 2);\r
+       PM_UnlockMainMem(gvar);\r
+       MM_GetPtr(MEMPTRCONV DigiList,i * sizeof(word) * 2, gvar);\r
        _fmemcpy((void far *)DigiList,(void far *)list,i * sizeof(word) * 2);\r
-       MM_FreePtr(&list);\r
+       MM_FreePtr(&list, gvar);\r
        NumDigi = i;\r
 \r
        for (i = 0;i < LASTSOUND;i++)\r
@@ -951,63 +832,72 @@ alOut(byte n,byte b)
 asm    pushf\r
 asm    cli\r
 \r
-asm    mov     dx,0x388\r
-asm    mov     al,[n]\r
-asm    out     dx,al\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    inc     dx\r
-asm    mov     al,[b]\r
-asm    out     dx,al\r
-\r
-asm    popf\r
-\r
-asm    dec     dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
+asm    mov             dx,0x388\r
+asm    mov             al,[n]\r
+asm    out             dx,al\r
+#if 0\r
+       SDL_Delay(TimerDelay10);\r
+#else\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+#endif\r
 \r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
+asm    mov             dx,0x389\r
+asm    mov             al,[b]\r
+asm    out             dx,al\r
 \r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
+asm    popf\r
 \r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
-asm    in      al,dx\r
+#if 0\r
+       SDL_Delay(TimerDelay25);\r
+#else\r
+asm    mov     dx,0x388\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+asm    in      al, dx\r
+#endif\r
 }\r
 \r
-#if 0\r
+//#if 0\r
 ///////////////////////////////////////////////////////////////////////////\r
 //\r
 //     SDL_SetInstrument() - Puts an instrument into a generator\r
@@ -1050,7 +940,7 @@ SDL_SetInstrument(int track,int which,Instrument far *inst,boolean percussive)
 \r
        alOut(which + alFeedCon,inst->nConn);   // DEBUG - I think this is right\r
 }\r
-#endif\r
+//#endif\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
 //\r
@@ -1109,7 +999,7 @@ static void
 #endif\r
 SDL_ALPlaySound(AdLibSound far *sound, global_game_variables_t *gvar)\r
 {\r
-       Instrument      far *inst;\r
+       Instrument      __far *inst;\r
        byte            huge *data;\r
 \r
        SDL_ALStopSound();\r
@@ -1137,7 +1027,7 @@ asm       cli
 asm    popf\r
 }\r
 \r
-#if 0\r
+//#if 0\r
 ///////////////////////////////////////////////////////////////////////////\r
 //\r
 //     SDL_ALSoundService() - Plays the next sample out through the AdLib card\r
@@ -1162,21 +1052,37 @@ SDL_ALSoundService(void)
 \r
                if (!(--alLengthLeft))\r
                {\r
-                       (long)alSound = 0;\r
+                       /*(long)*/alSound = 0;\r
                        alOut(alFreqH + 0,0);\r
                        SDL_SoundFinished();\r
                }\r
        }\r
 }\r
-#endif\r
+//#endif\r
 \r
 #if 0\r
+///////////////////////////////////////////////////////////////////////////\r
+//\r
+//     SDL_SelectMeasure() - sets up sequencing variables for a given track\r
+//\r
+///////////////////////////////////////////////////////////////////////////\r
+void\r
+SDL_SelectMeasure(ActiveTrack *track)\r
+{\r
+       track->seq = track->moods[track->mood];\r
+       track->nextevent = 0;\r
+}\r
+#endif\r
+\r
+//#if 0\r
 void\r
 SDL_ALService(void)\r
 {\r
        byte    a,v;\r
        word    w;\r
 \r
+       a=v=0;\r
+\r
        if (!sqActive)\r
                return;\r
 \r
@@ -1198,7 +1104,7 @@ SDL_ALService(void)
                alTimeCount = sqHackTime = 0;\r
        }\r
 }\r
-#endif\r
+//#endif\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
 //\r
@@ -1456,12 +1362,12 @@ SDL_StartDevice(void)
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 boolean\r
-SD_SetSoundMode(SDMode mode)\r
+SD_SetSoundMode(SDMode mode, global_game_variables_t *gvar)\r
 {\r
        boolean result = false;\r
        word    tableoffset;\r
 \r
-       SD_StopSound();\r
+       SD_StopSound(gvar);\r
 \r
 #ifndef        _MUSE_\r
        if ((mode == sdm_AdLib) && !AdLibPresent)\r
@@ -1496,7 +1402,7 @@ SD_SetSoundMode(SDMode mode)
                SDL_ShutDevice();\r
                SoundMode = mode;\r
 #ifndef        _MUSE_\r
-               SoundTable = (word *)(&audiosegs[tableoffset]);\r
+               SoundTable = (word *)(&gvar->ca.audiosegs[tableoffset]);\r
 #endif\r
                SDL_StartDevice();\r
        }\r
@@ -1560,10 +1466,10 @@ SD_Startup(global_game_variables_t *gvar)
        SDL_SetDS();\r
 \r
        ssIsTandy = false;\r
-       ssNoCheck = false;\r
+//SS   ssNoCheck = false;\r
        alNoCheck = false;\r
-       sbNoCheck = false;\r
-       sbNoProCheck = false;\r
+//SB   sbNoCheck = false;\r
+//SB   sbNoProCheck = false;\r
 #ifndef        _MUSE_\r
        for (i = 1;i < _argc;i++)\r
        {\r
@@ -1572,30 +1478,30 @@ SD_Startup(global_game_variables_t *gvar)
                case 0:                                         // No AdLib detection\r
                        alNoCheck = true;\r
                        break;\r
-               case 1:                                         // No SoundBlaster detection\r
-                       sbNoCheck = true;\r
-                       break;\r
-               case 2:                                         // No SoundBlaster Pro detection\r
-                       sbNoProCheck = true;\r
-                       break;\r
-               case 3:\r
-                       ssNoCheck = true;               // No Sound Source detection\r
-                       break;\r
+//SB           case 1:                                         // No SoundBlaster detection\r
+//SB                   sbNoCheck = true;\r
+//SB                   break;\r
+//SB           case 2:                                         // No SoundBlaster Pro detection\r
+//SB                   sbNoProCheck = true;\r
+//SB                   break;\r
+//SS           case 3:\r
+//SS                   ssNoCheck = true;               // No Sound Source detection\r
+//SS                   break;\r
                case 4:                                         // Tandy Sound Source handling\r
                        ssIsTandy = true;\r
                        break;\r
-               case 5:                                         // Sound Source present at LPT1\r
-                       ssPort = 1;\r
-                       ssNoCheck = SoundSourcePresent = true;\r
-                       break;\r
-               case 6:                     // Sound Source present at LPT2\r
-                       ssPort = 2;\r
-                       ssNoCheck = SoundSourcePresent = true;\r
-                       break;\r
-               case 7:                     // Sound Source present at LPT3\r
-                       ssPort = 3;\r
-                       ssNoCheck = SoundSourcePresent = true;\r
-                       break;\r
+//SS           case 5:                                         // Sound Source present at LPT1\r
+//SS                   ssPort = 1;\r
+//SS                   ssNoCheck = SoundSourcePresent = true;\r
+//SS                   break;\r
+//SS           case 6:                     // Sound Source present at LPT2\r
+//SS                   ssPort = 2;\r
+//SS                   ssNoCheck = SoundSourcePresent = true;\r
+//SS                   break;\r
+//SS           case 7:                     // Sound Source present at LPT3\r
+//SS                   ssPort = 3;\r
+//SS                   ssNoCheck = SoundSourcePresent = true;\r
+//SS                   break;\r
                }\r
        }\r
 #endif\r
@@ -1606,83 +1512,83 @@ SD_Startup(global_game_variables_t *gvar)
 \r
        LocalTime = TimeCount = alTimeCount = 0;\r
 \r
-       SD_SetSoundMode(sdm_Off);\r
+       SD_SetSoundMode(sdm_Off, gvar);\r
        SD_SetMusicMode(smm_Off);\r
 \r
-       if (!ssNoCheck)\r
-               SoundSourcePresent = SDL_DetectSoundSource();\r
+//SS   if (!ssNoCheck)\r
+//SS           SoundSourcePresent = SDL_DetectSoundSource();\r
 \r
        if (!alNoCheck)\r
        {\r
                AdLibPresent = SDL_DetectAdLib();\r
-               if (AdLibPresent && !sbNoCheck)\r
-               {\r
-                       int port = -1;\r
-                       char *env = getenv("BLASTER");\r
-                       if (env)\r
-                       {\r
-                               long temp;\r
-                               while (*env)\r
-                               {\r
-                                       while (isspace(*env))\r
-                                               env++;\r
-\r
-                                       switch (toupper(*env))\r
-                                       {\r
-                                       case 'A':\r
-                                               temp = strtol(env + 1,&env,16);\r
-                                               if\r
-                                               (\r
-                                                       (temp >= 0x210)\r
-                                               &&      (temp <= 0x260)\r
-                                               &&      (!(temp & 0x00f))\r
-                                               )\r
-                                                       port = (temp - 0x200) >> 4;\r
-                                               else\r
-                                                       Quit(gvar, "SD_Startup: Unsupported address value in BLASTER");\r
-                                               break;\r
-                                       case 'I':\r
-                                               temp = strtol(env + 1,&env,10);\r
-                                               if\r
-                                               (\r
-                                                       (temp >= 0)\r
-                                               &&      (temp <= 10)\r
-                                               &&      (sbIntVectors[temp] != -1)\r
-                                               )\r
-                                               {\r
-                                                       sbInterrupt = temp;\r
-                                                       sbIntVec = sbIntVectors[sbInterrupt];\r
-                                               }\r
-                                               else\r
-                                                       Quit(gvar, "SD_Startup: Unsupported interrupt value in BLASTER");\r
-                                               break;\r
-                                       case 'D':\r
-                                               temp = strtol(env + 1,&env,10);\r
-                                               if ((temp == 0) || (temp == 1) || (temp == 3))\r
-                                                       SDL_SBSetDMA(temp);\r
-                                               else\r
-                                                       Quit(gvar, "SD_Startup: Unsupported DMA value in BLASTER");\r
-                                               break;\r
-                                       default:\r
-                                               while (isspace(*env))\r
-                                                       env++;\r
-                                               while (*env && !isspace(*env))\r
-                                                       env++;\r
-                                               break;\r
-                                       }\r
-                               }\r
-                       }\r
-                       SoundBlasterPresent = SDL_DetectSoundBlaster(port);\r
-               }\r
+//SB           if (AdLibPresent) && !sbNoCheck)\r
+//SB           {\r
+//SB                   int port = -1;\r
+//SB                   char *env = getenv("BLASTER");\r
+//SB                   if (env)\r
+//SB                   {\r
+//SB                           long temp;\r
+//SB                           while (*env)\r
+//SB                           {\r
+//SB                                   while (isspace(*env))\r
+//SB                                           env++;\r
+//SB\r
+//SB                                   switch (toupper(*env))\r
+//SB                                   {\r
+//SB                                   case 'A':\r
+//SB                                           temp = strtol(env + 1,&env,16);\r
+//SB                                           if\r
+//SB                                           (\r
+//SB                                                   (temp >= 0x210)\r
+//SB                                           &&      (temp <= 0x260)\r
+//SB                                           &&      (!(temp & 0x00f))\r
+//SB                                           )\r
+//SB                                                   port = (temp - 0x200) >> 4;\r
+//SB                                           else\r
+//SB                                                   Quit(gvar, "SD_Startup: Unsupported address value in BLASTER");\r
+//SB                                           break;\r
+//SB                                   case 'I':\r
+//SB                                           temp = strtol(env + 1,&env,10);\r
+//SB                                           if\r
+//SB                                           (\r
+//SB                                                   (temp >= 0)\r
+//SB                                           &&      (temp <= 10)\r
+//SB                                           &&      (sbIntVectors[temp] != -1)\r
+//SB                                           )\r
+//SB                                           {\r
+//SB                                                   sbInterrupt = temp;\r
+//SB                                                   sbIntVec = sbIntVectors[sbInterrupt];\r
+//SB                                           }\r
+//SB                                           else\r
+//SB                                                   Quit(gvar, "SD_Startup: Unsupported interrupt value in BLASTER");\r
+//SB                                           break;\r
+//SB                                   case 'D':\r
+//SB                                           temp = strtol(env + 1,&env,10);\r
+//SB                                           if ((temp == 0) || (temp == 1) || (temp == 3))\r
+//SB                                                   SDL_SBSetDMA(temp);\r
+//SB                                           else\r
+//SB                                                   Quit(gvar, "SD_Startup: Unsupported DMA value in BLASTER");\r
+//SB                                           break;\r
+//SB                                   default:\r
+//SB                                           while (isspace(*env))\r
+//SB                                                   env++;\r
+//SB                                           while (*env && !isspace(*env))\r
+//SB                                                   env++;\r
+//SB                                           break;\r
+//SB                                   }\r
+//SB                           }\r
+//SB                   }\r
+//SB                   SoundBlasterPresent = SDL_DetectSoundBlaster(port);\r
+//SB           }\r
        }\r
 \r
        for (i = 0;i < 255;i++)\r
                pcSoundLookup[i] = i * 60;\r
 \r
-       if (SoundBlasterPresent)\r
-               SDL_StartSB();\r
+//SB   if (SoundBlasterPresent)\r
+//SB           SDL_StartSB();\r
 \r
-       SDL_SetupDigi();\r
+       SDL_SetupDigi(gvar);\r
 \r
        SD_Started = true;\r
 }\r
@@ -1694,7 +1600,7 @@ SD_Startup(global_game_variables_t *gvar)
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 void\r
-SD_Default(boolean gotit,SDMode sd,SMMode sm)\r
+SD_Default(boolean gotit,SDMode sd,SMMode sm, global_game_variables_t *gvar)\r
 {\r
        boolean gotsd,gotsm;\r
 \r
@@ -1717,7 +1623,7 @@ SD_Default(boolean gotit,SDMode sd,SMMode sm)
                        sd = sdm_PC;\r
        }\r
        if (sd != SoundMode)\r
-               SD_SetSoundMode(sd);\r
+               SD_SetSoundMode(sd, gvar);\r
 \r
 \r
        if (gotsm)      // Make sure requested music hardware is available\r
@@ -1745,21 +1651,21 @@ SD_Default(boolean gotit,SDMode sd,SMMode sm)
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 void\r
-SD_Shutdown(void)\r
+SD_Shutdown(global_game_variables_t *gvar)\r
 {\r
        if (!SD_Started)\r
                return;\r
 \r
        SD_MusicOff();\r
-       SD_StopSound();\r
+       SD_StopSound(gvar);\r
        SDL_ShutDevice();\r
        SDL_CleanDevice();\r
 \r
-       if (SoundBlasterPresent)\r
-               SDL_ShutSB();\r
+//SB   if (SoundBlasterPresent)\r
+//SB           SDL_ShutSB();\r
 \r
-       if (SoundSourcePresent)\r
-               SDL_ShutSS();\r
+//SS   if (SoundSourcePresent)\r
+//SS           SDL_ShutSS();\r
 \r
        asm     pushf\r
        asm     cli\r
@@ -1835,7 +1741,7 @@ SD_PlaySound(soundnames sound, global_game_variables_t *gvar)
 \r
                        SDL_PCStopSound();\r
 \r
-                       SD_PlayDigitized(DigiMap[sound],lp,rp);\r
+                       SD_PlayDigitized(DigiMap[sound],lp,rp, gvar);\r
                        SoundPositioned = ispos;\r
                        SoundNumber = sound;\r
                        SoundPriority = s->priority;\r
@@ -1854,7 +1760,7 @@ SD_PlaySound(soundnames sound, global_game_variables_t *gvar)
                        if (s->priority < DigiPriority)\r
                                return(false);\r
 \r
-                       SD_PlayDigitized(DigiMap[sound],lp,rp);\r
+                       SD_PlayDigitized(DigiMap[sound],lp,rp, gvar);\r
                        SoundPositioned = ispos;\r
                        DigiNumber = sound;\r
                        DigiPriority = s->priority;\r
@@ -1876,7 +1782,7 @@ SD_PlaySound(soundnames sound, global_game_variables_t *gvar)
                SDL_PCPlaySound((void far *)s);\r
                break;\r
        case sdm_AdLib:\r
-               SDL_ALPlaySound((void far *)s);\r
+               SDL_ALPlaySound((void far *)s, gvar);\r
                break;\r
        }\r
 \r
@@ -1919,10 +1825,10 @@ SD_SoundPlaying(void)
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
 void\r
-SD_StopSound(void)\r
+SD_StopSound(global_game_variables_t *gvar)\r
 {\r
        if (DigiPlaying)\r
-               SD_StopDigitized();\r
+               SD_StopDigitized(gvar);\r
 \r
        switch (SoundMode)\r
        {\r
@@ -2051,6 +1957,7 @@ SD_MusicPlaying(void)
        return(result);\r
 }\r
 \r
+#if 0\r
 // SD ASS!\r
 void SDL_SetDS()\r
 {\r
@@ -2395,4 +2302,4 @@ void alOutInIRQ(byte n,byte b)
                in      al,dx\r
        }\r
 }\r
-\r
+#endif\r
index ef22dc8773da641f884f429dd7085fba874f7bcc..12558e66bb45d3e76e6063c63aa6abb6ddf635d7 100755 (executable)
@@ -25,6 +25,7 @@
 //     ID_SD.h - Sound Manager Header\r
 //     Version for Wolfenstein\r
 //     By Jason Blochowiak\r
+//     Open Watcom port by sparky4\r
 //\r
 \r
 #ifndef        __16_SD__\r
@@ -225,14 +226,14 @@ extern    int                     DigiMap[];
 extern dword   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
+extern void    SD_Startup(global_game_variables_t *gvar),\r
+                               SD_Shutdown(global_game_variables_t *gvar),\r
+                               SD_Default(boolean gotit,SDMode sd,SMMode sm, global_game_variables_t *gvar),\r
 \r
                                SD_PositionSound(int leftvol,int rightvol);\r
-extern boolean SD_PlaySound(soundnames sound);\r
-extern void    SD_SetPosition(int leftvol,int rightvol),\r
-                               SD_StopSound(void),\r
+extern boolean SD_PlaySound(soundnames sound, global_game_variables_t *gvar);\r
+extern void    SD_SetPosition(int leftvol,int rightvol, global_game_variables_t *gvar),\r
+                               SD_StopSound(global_game_variables_t *gvar),\r
                                SD_WaitSoundDone(void),\r
 \r
                                SD_StartMusic(MusicGroup far *music),\r
@@ -242,17 +243,17 @@ extern    void    SD_SetPosition(int leftvol,int rightvol),
 \r
                                SD_SetUserHook(void (*hook)(void));\r
 extern boolean SD_MusicPlaying(void),\r
-                               SD_SetSoundMode(SDMode mode),\r
+                               SD_SetSoundMode(SDMode mode, global_game_variables_t *gvar),\r
                                SD_SetMusicMode(SMMode mode);\r
 extern word    SD_SoundPlaying(void);\r
 \r
-extern void    SD_SetDigiDevice(SDSMode),\r
-                               SD_PlayDigitized(word which,int leftpos,int rightpos),\r
+extern void    SD_SetDigiDevice(SDSMode, global_game_variables_t *gvar),\r
+                               SD_PlayDigitized(word which,int leftpos,int rightpos, global_game_variables_t *gvar),\r
                                SD_StopDigitized(global_game_variables_t *gvar),\r
-                               SD_Poll(void);\r
+                               SD_Poll(global_game_variables_t *gvar);\r
 \r
 #ifdef _MUSE_  // MUSE Goes directly to the lower level routines\r
-extern void    SDL_PCPlaySound(PCSound far *sound),\r
+extern void    SDL_PCPlaySound(PCSound far *sound, global_game_variables_t *gvar),\r
                                SDL_PCStopSound(void),\r
                                SDL_ALPlaySound(AdLibSound far *sound),\r
                                SDL_ALStopSound(void);\r