]> 4ch.mooo.com Git - 16.git/commitdiff
ok wolf3d sound stuff and catacomb 3d sound stuff compiles BOTH UNTESTED\! going...
authorsparky4 <sparky4@cock.li>
Thu, 14 Sep 2017 16:42:06 +0000 (11:42 -0500)
committersparky4 <sparky4@cock.li>
Thu, 14 Sep 2017 16:42:06 +0000 (11:42 -0500)
src/lib/id_sd.c

index cffa2d126f35cc76bde3bb9edd5a89178add4c70..2e8788bef0dbb828d9e7fa3fa77cb6e380f58042 100755 (executable)
 #define        writereg(n)     outportb(alFMData,n)\r
 #define        readstat()      inportb(alFMStatus)\r
 \r
-#define SD_USECATA3DSETTIMERSPEED\r
+//#define SD_USECATA3DSETTIMERSPEED\r
 \r
 //     Imports from ID_SD_A.ASM\r
-#if 0\r
 /*extern*/     void                    SDL_SetDS(void);\r
-/*extern*/     void interrupt  SDL_t0ExtremeAsmService(void),\r
-                                               SDL_t0FastAsmService(void),\r
-                                               SDL_t0SlowAsmService(void);\r
-#endif\r
-               void    SDL_IndicatePC(boolean on);\r
+/*extern*/     void interrupt  SDL_t0ExtremeAsmService(void);//,\r
+//                                     SDL_t0FastAsmService(void),\r
+//                                     SDL_t0SlowAsmService(void);\r
+       void                    SDL_IndicatePC(boolean on),\r
+                                       SDL_DigitizedDoneInIRQ();\r
 \r
 //     Global variables\r
        boolean         AdLibPresent,\r
@@ -120,7 +119,6 @@ static      void                    (*SoundUserHook)(void);
 static boolean                 DigiMissed,DigiLastSegment;\r
 static memptr                  DigiNextAddr;\r
 static word                    DigiNextLen;\r
-               boolean                 pcindicate;\r
 \r
 //     PC Sound variables\r
                volatile byte   pcLastSample,far *pcSound;\r
@@ -154,6 +152,196 @@ static    ActiveTrack             *tracks[sqMaxTracks];//,
 //     Internal routines\r
                void                    SDL_DigitizedDone(void);\r
 \r
+//Assembly functions\r
+boolean                alNoIRQ;\r
+\r
+int count_time=0;\r
+int count_fx=0;\r
+int extreme=0;\r
+\r
+void SDL_turnOnPCSpeaker(word timerval)\r
+{\r
+       __asm {\r
+               mov     bx,timerval\r
+               mov     al,0b6h\r
+               out     43h,al\r
+               mov     al,bl\r
+               out     42h,al\r
+               mov     al,bh\r
+               out     42h,al\r
+               in      al,61h\r
+               or      al,3\r
+               out     61h,al\r
+       }\r
+}\r
+\r
+void SDL_turnOffPCSpeaker()\r
+{\r
+       __asm {\r
+               in      al,61h\r
+               and     al,0fch\r
+               out     61h,al\r
+       }\r
+}\r
+\r
+void SDL_setPCSpeaker(byte val)\r
+{\r
+       __asm {\r
+               mov     al,val\r
+               in      al,61h\r
+               and     al,0fch\r
+               or      al,ah\r
+               out     61h,al\r
+       }\r
+}\r
+\r
+void SDL_DoFX()\r
+{\r
+       if(pcSound)\r
+       {\r
+               if(*pcSound!=pcLastSample)\r
+               {\r
+                       pcLastSample=*pcSound;\r
+\r
+                       if(pcLastSample)\r
+                               SDL_turnOnPCSpeaker(pcLastSample*60);\r
+                       else\r
+                               SDL_turnOffPCSpeaker();\r
+               }\r
+               pcSound++;\r
+               pcLengthLeft--;\r
+               if(!pcLengthLeft)\r
+               {\r
+                       pcSound=0;\r
+                       SoundNumber=(soundnames)0;\r
+                       SoundPriority=0;\r
+                       SDL_turnOffPCSpeaker();\r
+               }\r
+       }\r
+\r
+       if(alSound && !alNoIRQ)\r
+       {\r
+               if(*alSound)\r
+               {\r
+                       alOut/*InIRQ*/(alFreqL,*alSound);\r
+                       alOut/*InIRQ*/(alFreqH,alBlock);\r
+               }\r
+               else alOut/*InIRQ*/(alFreqH,0);\r
+               alSound++;\r
+               alLengthLeft--;\r
+               if(!alLengthLeft)\r
+               {\r
+                       alSound=0;\r
+                       SoundNumber=(soundnames)0;\r
+                       SoundPriority=0;\r
+                       alOut/*InIRQ*/(alFreqH,0);\r
+               }\r
+       }\r
+\r
+}\r
+\r
+void SDL_DoFast()\r
+{\r
+       count_fx++;\r
+       if(count_fx>=5)\r
+       {\r
+               count_fx=0;\r
+\r
+               SDL_DoFX();\r
+\r
+               count_time++;\r
+               if(count_time>=2)\r
+               {\r
+                       TimeCount++;\r
+                       count_time=0;\r
+               }\r
+       }\r
+\r
+       if(sqActive && !alNoIRQ)\r
+       {\r
+               if(sqHackLen)\r
+               {\r
+                       do\r
+                       {\r
+                               if(sqHackTime>alTimeCount) break;\r
+                               sqHackTime=alTimeCount+*(sqHackPtr+1);\r
+                               alOut/*InIRQ*/(*(byte *)sqHackPtr,*(((byte *)sqHackPtr)+1));\r
+                               sqHackPtr+=2;\r
+                               sqHackLen-=4;\r
+                       }\r
+                       while(sqHackLen);\r
+               }\r
+               alTimeCount++;\r
+               if(!sqHackLen)\r
+               {\r
+                       sqHackPtr=sqHack;\r
+                       sqHackLen=sqHackSeqLen;\r
+                       alTimeCount=0;\r
+                       sqHackTime=0;\r
+               }\r
+       }\r
+\r
+//SS   if(ssSample)\r
+//SS   {\r
+//SS           if(!(inp(ssStatus)&0x40))\r
+//SS           {\r
+//SS                   outp(ssData,*ssSample++);\r
+//SS                   outp(ssControl,ssOff);\r
+//SS                   __asm push ax\r
+//SS                   __asm pop ax\r
+//SS                   outp(ssControl,ssOn);\r
+//SS                   __asm push ax\r
+//SS                   __asm pop ax\r
+//SS                   ssLengthLeft--;\r
+//SS                   if(!ssLengthLeft)\r
+//SS                   {\r
+//SS                           ssSample=0;\r
+//SS                           SDL_DigitizedDoneInIRQ();\r
+//SS                   }\r
+//SS           }\r
+//SS   }\r
+\r
+       TimerCount+=TimerDivisor;\r
+       if(*((word *)&TimerCount+1))\r
+       {\r
+               *((word *)&TimerCount+1)=0;\r
+               t0OldService();\r
+       }\r
+       else\r
+       {\r
+               outp(0x20,0x20);\r
+       }\r
+}\r
+\r
+// Timer 0 ISR for 700Hz interrupts\r
+void interrupt SDL_t0FastAsmService(void)\r
+{\r
+       SDL_DoFast();\r
+}\r
+\r
+// Timer 0 ISR for 140Hz interrupts\r
+void interrupt SDL_t0SlowAsmService(void)\r
+{\r
+       count_time++;\r
+       if(count_time>=2)\r
+       {\r
+               TimeCount++;\r
+               count_time=0;\r
+       }\r
+\r
+       SDL_DoFX();\r
+\r
+       TimerCount+=TimerDivisor;\r
+       if(*((word *)&TimerCount+1))\r
+       {\r
+               *((word *)&TimerCount+1)=0;\r
+               t0OldService();\r
+       }\r
+       else\r
+               outp(0x20,0x20);\r
+}\r
+\r
+\r
 ///////////////////////////////////////////////////////////////////////////\r
 //\r
 //     SDL_SetTimer0() - Sets system timer 0 to the specified speed\r
@@ -261,7 +449,7 @@ SDL_TimingService(void)
 \r
        outportb(0x20,0x20);                            // Ack interrupt\r
 }\r
-\r
+#ifdef SD_USECATA3DSETTIMERSPEED\r
 ///////////////////////////////////////////////////////////////////////////\r
 //\r
 //     SDL_InitDelay() - Sets up TimerDelay's for SDL_Delay()\r
@@ -322,7 +510,7 @@ done:
 \r
        setvect(8,t0OldService);                        // Set back to old ISR\r
 }\r
-\r
+#endif\r
 ///////////////////////////////////////////////////////////////////////////\r
 //\r
 //     SDL_Delay() - Delays the specified amount of time\r
@@ -1972,8 +2160,15 @@ SD_MusicPlaying(void)
        return(result);\r
 }\r
 \r
-#if 0\r
+//#if 0\r
+//\r
 // SD ASS!\r
+//\r
+\r
+//variables for these assembly functions\r
+volatile boolean pcindicate;\r
+volatile unsigned/*boolean*/ MyDS;\r
+\r
 void SDL_SetDS()\r
 {\r
        __asm {\r
@@ -1983,159 +2178,7 @@ void SDL_SetDS()
        }\r
 }\r
 \r
-void SDL_turnOnPCSpeaker(word timerval)\r
-{\r
-       __asm {\r
-               mov     bx,timerval\r
-               mov     al,0b6h\r
-               out     43h,al\r
-               mov     al,bl\r
-               out     42h,al\r
-               mov     al,bh\r
-               out     42h,al\r
-               in      al,61h\r
-               or      al,3\r
-               out     61h,al\r
-       }\r
-}\r
-\r
-void SDL_turnOffPCSpeaker()\r
-{\r
-       __asm {\r
-               in      al,61h\r
-               and     al,0fch\r
-               out     61h,al\r
-       }\r
-}\r
-\r
-void SDL_setPCSpeaker(byte val)\r
-{\r
-       __asm {\r
-               mov     al,val\r
-               in      al,61h\r
-               and     al,0fch\r
-               or      al,ah\r
-               out     61h,al\r
-       }\r
-}\r
-\r
-void SDL_DoFX()\r
-{\r
-       if(pcSound)\r
-       {\r
-               if(*pcSound!=pcLastSample)\r
-               {\r
-                       pcLastSample=*pcSound;\r
-\r
-                       if(pcLastSample)\r
-                               SDL_turnOnPCSpeaker(pcLastSample*60);\r
-                       else\r
-                               SDL_turnOffPCSpeaker();\r
-               }\r
-               pcSound++;\r
-               pcLengthLeft--;\r
-               if(!pcLengthLeft)\r
-               {\r
-                       pcSound=0;\r
-                       SoundNumber=(soundnames)0;\r
-                       SoundPriority=0;\r
-                       SDL_turnOffPCSpeaker();\r
-               }\r
-       }\r
-\r
-       if(alSound && !alNoIRQ)\r
-       {\r
-               if(*alSound)\r
-               {\r
-                       alOutInIRQ(alFreqL,*alSound);\r
-                       alOutInIRQ(alFreqH,alBlock);\r
-               }\r
-               else alOutInIRQ(alFreqH,0);\r
-               alSound++;\r
-               alLengthLeft--;\r
-               if(!alLengthLeft)\r
-               {\r
-                       alSound=0;\r
-                       SoundNumber=(soundnames)0;\r
-                       SoundPriority=0;\r
-                       alOutInIRQ(alFreqH,0);\r
-               }\r
-       }\r
-\r
-}\r
-\r
-void SDL_DoFast()\r
-{\r
-       count_fx++;\r
-       if(count_fx>=5)\r
-       {\r
-               count_fx=0;\r
-\r
-               SDL_DoFX();\r
-\r
-               count_time++;\r
-               if(count_time>=2)\r
-               {\r
-                       TimeCount++;\r
-                       count_time=0;\r
-               }\r
-       }\r
-\r
-       if(sqActive && !alNoIRQ)\r
-       {\r
-               if(sqHackLen)\r
-               {\r
-                       do\r
-                       {\r
-                               if(sqHackTime>alTimeCount) break;\r
-                               sqHackTime=alTimeCount+*(sqHackPtr+1);\r
-                               alOutInIRQ(*(byte *)sqHackPtr,*(((byte *)sqHackPtr)+1));\r
-                               sqHackPtr+=2;\r
-                               sqHackLen-=4;\r
-                       }\r
-                       while(sqHackLen);\r
-               }\r
-               alTimeCount++;\r
-               if(!sqHackLen)\r
-               {\r
-                       sqHackPtr=sqHack;\r
-                       sqHackLen=sqHackSeqLen;\r
-                       alTimeCount=0;\r
-                       sqHackTime=0;\r
-               }\r
-       }\r
-\r
-       if(ssSample)\r
-       {\r
-               if(!(inp(ssStatus)&0x40))\r
-               {\r
-                       outp(ssData,*ssSample++);\r
-                       outp(ssControl,ssOff);\r
-                       __asm push ax\r
-                       __asm pop ax\r
-                       outp(ssControl,ssOn);\r
-                       __asm push ax\r
-                       __asm pop ax\r
-                       ssLengthLeft--;\r
-                       if(!ssLengthLeft)\r
-                       {\r
-                               ssSample=0;\r
-                               SDL_DigitizedDoneInIRQ();\r
-                       }\r
-               }\r
-       }\r
-\r
-       TimerCount+=TimerDivisor;\r
-       if(*((word *)&TimerCount+1))\r
-       {\r
-               *((word *)&TimerCount+1)=0;\r
-               t0OldService();\r
-       }\r
-       else\r
-       {\r
-               outp(0x20,0x20);\r
-       }\r
-}\r
+//\r
 \r
 // Timer 0 ISR for 7000Hz interrupts\r
 void interrupt SDL_t0ExtremeAsmService(void)\r
@@ -2164,66 +2207,13 @@ void interrupt SDL_t0ExtremeAsmService(void)
                outp(0x20,0x20);\r
 }\r
 \r
-// Timer 0 ISR for 7000Hz interrupts\r
-void interrupt __SDL_t0ExtremeAsmService()\r
-{\r
-       if(pcindicate)\r
-       {\r
-               if(pcSound)\r
-               {\r
-                       SDL_setPCSpeaker(((*pcSound++)&0x80)>>6);\r
-                       pcLengthLeft--;\r
-                       if(!pcLengthLeft)\r
-                       {\r
-                               pcSound=0;\r
-                               SDL_turnOffPCSpeaker();\r
-                               SDL_DigitizedDoneInIRQ();\r
-                       }\r
-               }\r
-       }\r
-       extreme++;\r
-       if(extreme>=10)\r
-       {\r
-               extreme=0;\r
-               SDL_DoFast();\r
-       }\r
-       else\r
-               outp(0x20,0x20);\r
-}\r
-\r
-// Timer 0 ISR for 700Hz interrupts\r
-void interrupt SDL_t0FastAsmService(void)\r
-{\r
-       SDL_DoFast();\r
-}\r
-\r
-// Timer 0 ISR for 140Hz interrupts\r
-void interrupt SDL_t0SlowAsmService(void)\r
-{\r
-       count_time++;\r
-       if(count_time>=2)\r
-       {\r
-               TimeCount++;\r
-               count_time=0;\r
-       }\r
-\r
-       SDL_DoFX();\r
+//\r
 \r
-       TimerCount+=TimerDivisor;\r
-       if(*((word *)&TimerCount+1))\r
-       {\r
-               *((word *)&TimerCount+1)=0;\r
-               t0OldService();\r
-       }\r
-       else\r
-               outp(0x20,0x20);\r
-}\r
-#endif\r
 void SDL_IndicatePC(boolean ind)\r
 {\r
        pcindicate=ind;\r
 }\r
-#if 0\r
+\r
 void\r
 SDL_DigitizedDoneInIRQ(void)\r
 {\r
@@ -2255,6 +2245,7 @@ SDL_DigitizedDoneInIRQ(void)
        }\r
 }\r
 \r
+#if 0\r
 // Inside an interrupt handler interrupts should already be disabled\r
 // so don't disable them again and cause V86 exceptions which cost\r
 // aprox. 300 processor tics!\r