]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_mm.c
__seguse.txt added to show _seg usage also OpenVGMFile needs to be ported to 16_snd...
[16.git] / src / lib / 16_mm.c
index 5f8bb38e47aea4972ccb5a68bf77bdc68ea60d30..fb308db63950e31230d3658e29ec93156f802cfc 100755 (executable)
@@ -88,18 +88,20 @@ static      char *ParmStringsexmm[] = {"noems","noxms",""};
 
 boolean MML_CheckForEMS(void)
 {
-       boolean emmcfems=0;
+       boolean emmcfems = false;
+       word            EMSPageFrame = 0;
+       byte    err=0, str[64];
        static char     emmname[] = "EMMXXXX0"; //fix by andrius4669
        __asm {
                mov     dx,OFFSET emmname       //fix by andrius4669
                mov     ax,0x3d00
-               int     0x21            // try to open EMMXXXX0 device
+               int     EMM_INT         // try to open EMMXXXX0 device
                jc      error
 
                mov     bx,ax
                mov     ax,0x4400
 
-               int     0x21            // get device info
+               int     EMM_INT         // get device info
                jc      error
 
                and     dx,0x80
@@ -107,19 +109,29 @@ boolean MML_CheckForEMS(void)
 
                mov     ax,0x4407
 
-               int     0x21            // get status
+               int     EMM_INT         // get status
                jc      error
                or      al,al
                jz      error
 
                mov     ah,0x3e
-               int     0x21            // close handle
+               int     EMM_INT         // close handle
                jc      error
+
+               //
+               // pageframe check
+               //
+               mov     ah,EMS_GETFRAME
+               int     EMS_INT                 // find the page frame address
+               or      ah,ah
+               jnz     error
+               mov     [EMSPageFrame],bx
+
                //
                // EMS is good
                //
-               mov     emmcfems,1
-               jmp End
+               mov     emmcfems,1
+               jmp     End
 #ifdef __BORLANDC__
        }
 #endif
@@ -130,7 +142,8 @@ boolean MML_CheckForEMS(void)
                //
                // EMS is bad
                //
-               mov     emmcfems,0
+               mov     err,ah
+               mov     emmcfems,0
 #ifdef __BORLANDC__
        }
 #endif
@@ -138,6 +151,23 @@ boolean MML_CheckForEMS(void)
 #ifdef __WATCOMC__
        }
 #endif
+
+       //
+       // Pageframe switch to determine if there is one!
+       //
+       if(!EMSPageFrame)
+       {
+               emmcfems = false;
+#if defined(__DEBUG_PM__) || defined(__DEBUG_MM__)
+               printf("MML_CheckForEMS: EMS error No Pageframe!\nAddress detected to be %04x\n", EMSPageFrame);
+#endif
+       }else   if(!emmcfems)// if there is an error and page frame is not 0000
+       {
+               strcpy(str,"MML_CheckForEMS: EMS error ");
+               MM_EMSerr(str, err);
+               printf("%s\n",str);
+       }
+
        return(emmcfems);
 }
 
@@ -1138,7 +1168,7 @@ void MM_SortMem(global_game_variables_t *gvar)
                        playing += STARTADLIBSOUNDS;
                        break;
                }
-               MM_SetLock(&(memptr)audiosegs[playing],true);
+               MM_SetLock((memptr *)&audiosegs[playing],true);
        }
 
 
@@ -1214,7 +1244,7 @@ void MM_SortMem(global_game_variables_t *gvar)
 //     VW_ColorBorder (oldborder);
 
 /*++++ if(playing)
-               MM_SetLock(&(memptr)audiosegs[playing],false);*/
+               MM_SetLock((memptr *)&audiosegs[playing],false);*/
 }
 
 //==========================================================================