]> 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 20:26:00 +0000 (15:26 -0500)
committersparky4 <sparky4@cock.li>
Wed, 13 Sep 2017 20:26:00 +0000 (15:26 -0500)
src/lib/id_sd.c

index 8883f62a71d5a20df1b58648edeb8df9d9365c65..8bd50e5914919023edb66144d19127f1de95ebb5 100755 (executable)
 #define        writereg(n)     outportb(alFMData,n)\r
 #define        readstat()      inportb(alFMStatus)\r
 \r
+#define SD_USECATA3DSETTIMERSPEED\r
+\r
 //     Imports from ID_SD_A.ASM\r
-/*extern*/     void                    SDL_SetDS(void),\r
-                                               SDL_IndicatePC(boolean on);\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
 \r
 //     Global variables\r
        boolean         SoundSourcePresent,\r
@@ -126,6 +130,7 @@ static      void                    (*SoundUserHook)(void);
 static boolean                 DigiMissed,DigiLastSegment;\r
 static memptr                  DigiNextAddr;\r
 static word                    DigiNextLen;\r
+               boolean                 pcindicate;\r
 \r
 #if 0\r
 //     SoundBlaster variables\r
@@ -179,7 +184,7 @@ static      byte                    carriers[9] =  { 3, 4, 5,11,12,13,19,20,21},
 static word                    alFXReg;\r
 static ActiveTrack             *tracks[sqMaxTracks];//,\r
 //--                                           mytracks[sqMaxTracks];\r
-static word                    sqMode,sqFadeStep;\r
+//--static     word                    sqMode,sqFadeStep;\r
                word                    far *sqHack,far *sqHackPtr,sqHackLen,sqHackSeqLen;\r
                long                    sqHackTime;\r
 \r
@@ -227,6 +232,7 @@ SDL_SetIntsPerSec(word ints)
        SDL_SetTimer0(1192030 / ints);\r
 }\r
 \r
+#ifndef SD_USECATA3DSETTIMERSPEED\r
 static void\r
 SDL_SetTimerSpeed(void)\r
 {\r
@@ -260,6 +266,19 @@ SDL_SetTimerSpeed(void)
                TimerRate = rate;\r
        }\r
 }\r
+#else\r
+static void\r
+SDL_SetTimerSpeed(void)\r
+{\r
+       word    rate;\r
+\r
+       if (MusicMode == smm_AdLib)\r
+               rate = TickBase * 8;\r
+       else\r
+               rate = TickBase * 2;\r
+       SDL_SetIntsPerSec(rate);\r
+}\r
+#endif\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
 //\r
@@ -903,7 +922,8 @@ asm in      al, dx
 //     SDL_SetInstrument() - Puts an instrument into a generator\r
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
-static void\r
+//static void\r
+void\r
 SDL_SetInstrument(int track,int which,Instrument far *inst,boolean percussive)\r
 {\r
        byte            c,m;\r
@@ -1175,9 +1195,9 @@ SDL_DetectAdLib(void)
        status1 = readstat();\r
        alOut(2,0xff);  // Set timer 1\r
        alOut(4,0x21);  // Start timer 1\r
-#if 0\r
        SDL_Delay(TimerDelay100);\r
-#else\r
+\r
+#if 0\r
        __asm {\r
                mov     dx,0x388\r
                mov     cx,100\r
@@ -1211,19 +1231,20 @@ usecloop:
                return(false);\r
 }\r
 \r
-#if 0\r
 ///////////////////////////////////////////////////////////////////////////\r
 //\r
 //     SDL_t0Service() - My timer 0 ISR which handles the different timings and\r
 //             dispatches to whatever other routines are appropriate\r
 //\r
 ///////////////////////////////////////////////////////////////////////////\r
-static void interrupt\r
+//static void interrupt\r
+void interrupt\r
 SDL_t0Service(void)\r
 {\r
 static word    count = 1;\r
+       boolean myackflag = 0;\r
 \r
-#if 1  // for debugging\r
+//00#if 0      // for debugging\r
 asm    mov     dx,STATUS_REGISTER_1\r
 asm    in      al,dx\r
 asm    mov     dx,ATR_INDEX\r
@@ -1231,14 +1252,14 @@ asm     mov     al,ATR_OVERSCAN
 asm    out     dx,al\r
 asm    mov     al,4    // red\r
 asm    out     dx,al\r
-#endif\r
+//00#endif\r
 \r
        HackCount++;\r
 \r
        if ((MusicMode == smm_AdLib) || (DigiMode == sds_SoundSource))\r
        {\r
                SDL_ALService();\r
-               SDL_SSService();\r
+//SS           SDL_SSService();\r
 //             if (!(++count & 7))\r
                if (!(++count % 10))\r
                {\r
@@ -1281,17 +1302,33 @@ asm     out     dx,al
                }\r
        }\r
 \r
-asm    mov     ax,[WORD PTR TimerCount]\r
-asm    add     ax,[WORD PTR TimerDivisor]\r
-asm    mov     [WORD PTR TimerCount],ax\r
-asm    jnc     myack\r
-       t0OldService();                 // If we overflow a word, time to call old int handler\r
-asm    jmp     olddone\r
-myack:;\r
-       outportb(0x20,0x20);    // Ack the interrupt\r
-olddone:;\r
+       __asm {\r
+               mov     ax,[WORD PTR TimerCount]\r
+               add     ax,[WORD PTR TimerDivisor]\r
+               mov     [WORD PTR TimerCount],ax\r
+               jnc     myack\r
+               jmp end1\r
+#ifdef __BORLANDC__\r
+       }\r
+#endif\r
+myack:\r
+#ifdef __BORLANDC__\r
+       __asm {\r
+#endif\r
+               mov     myackflag,1\r
+#ifdef __BORLANDC__\r
+       }\r
+#endif\r
+end1:\r
+#ifdef __WATCOMC__\r
+       }\r
+#endif\r
+       if(!myackflag)\r
+               t0OldService();                 // If we overflow a word, time to call old int handler\r
+       else\r
+               outportb(0x20,0x20);    // Ack the interrupt\r
 \r
-#if 1  // for debugging\r
+//00#if 0      // for debugging\r
 asm    mov     dx,STATUS_REGISTER_1\r
 asm    in      al,dx\r
 asm    mov     dx,ATR_INDEX\r
@@ -1301,9 +1338,8 @@ asm       mov     al,3    // blue
 asm    out     dx,al\r
 asm    mov     al,0x20 // normal\r
 asm    out     dx,al\r
-#endif\r
+//00#endif\r
 }\r
-#endif\r
 \r
 ////////////////////////////////////////////////////////////////////////////\r
 //\r
@@ -1353,7 +1389,19 @@ SDL_StartDevice(void)
        }\r
        SoundNumber = SoundPriority = 0;\r
 }\r
+#if 0\r
+static void\r
+SDL_SetTimerSpeed(void)\r
+{\r
+       word    rate;\r
 \r
+       if (MusicMode == smm_AdLib)\r
+               rate = TickBase * 8;\r
+       else\r
+               rate = TickBase * 2;\r
+       SDL_SetIntsPerSec(rate);\r
+}\r
+#endif\r
 //     Public routines\r
 \r
 ///////////////////////////////////////////////////////////////////////////\r
@@ -1463,7 +1511,7 @@ SD_Startup(global_game_variables_t *gvar)
        if (SD_Started)\r
                return;\r
 \r
-       SDL_SetDS();\r
+//??   SDL_SetDS();\r
 \r
        ssIsTandy = false;\r
 //SS   ssNoCheck = false;\r
@@ -1510,6 +1558,9 @@ SD_Startup(global_game_variables_t *gvar)
 \r
        t0OldService = getvect(8);      // Get old timer 0 ISR\r
 \r
+       SDL_InitDelay();                        // SDL_InitDelay() uses t0OldService\r
+\r
+       setvect(8,SDL_t0Service);       // Set to my timer 0 ISR\r
        LocalTime = TimeCount = alTimeCount = 0;\r
 \r
        SD_SetSoundMode(sdm_Off, gvar);\r
@@ -2203,12 +2254,12 @@ void interrupt SDL_t0SlowAsmService(void)
        else\r
                outp(0x20,0x20);\r
 }\r
-\r
+#endif\r
 void SDL_IndicatePC(boolean ind)\r
 {\r
        pcindicate=ind;\r
 }\r
-\r
+#if 0\r
 void\r
 SDL_DigitizedDoneInIRQ(void)\r
 {\r