]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_mm.c
ok about to add the massive page management stuff
[16.git] / src / lib / 16_mm.c
index f0c40f9ec4f53b210bba7444cc90f3a280c7fff5..24f78c5bd67e5499be869a796f1f7b99b59a22d0 100644 (file)
@@ -135,10 +135,10 @@ boolean MML_CheckForEMS(void)
 =======================
 */
 
-unsigned MML_SetupEMS(mminfo_t *mm)
+byte MML_SetupEMS(mminfo_t *mm)
 {
-       char    str[80],str2[10];
-       unsigned        err;
+       char    str[80];//,str2[10];
+       byte    err;
        boolean errorflag=false;
        union REGS CPURegs;
 
@@ -199,6 +199,7 @@ getpages:
                mov     [EMShandle],dx
                jmp End
 error:
+               mov     err,ah
                mov     errorflag,1
                jmp End
 noEMS:
@@ -206,11 +207,12 @@ End:
        }
        if(errorflag==true)
        {
-               err = CPURegs.h.ah;
+               //err = CPURegs.h.ah;
                strcpy(str,"MML_SetupEMS: EMS error 0x");
-               itoa(err,str2,16);
-               strcpy(str,str2);
-               printf("%s\n",str);
+               //itoa(err,str2,16);
+               //strcat(str,&err);
+               //printf("%s\n",str);
+               printf("%s%x\n",str,err);
                return err;
        }
        mm->totalEMSpages=totalEMSpages;
@@ -263,16 +265,17 @@ void MML_ShutdownEMS(mminfo_t *mm)
 ====================
 */
 
-unsigned MM_MapEMS(mminfo_t *mm)
+byte MM_MapEMS(mminfo_t *mm)
 {
-       char    str[80],str2[10];
-       unsigned        err, EMShandle;
+       char    str[80];//,str2[10];
+       unsigned        /*err, */EMShandle;
+       byte err;
        boolean errorflag=false;
        int     i;
        union REGS CPURegs;
        EMShandle=mm->EMShandle;
 
-       for (i=0;i<MAPPAGES/*4mm->EMSpagesmapped*/;i++)
+       for (i=0;i<MAPPAGES;i++)
        {
                __asm
                {
@@ -285,51 +288,90 @@ unsigned MM_MapEMS(mminfo_t *mm)
                        jnz     error
                        jmp End
                        error:
+                       mov     err,ah
                        mov     errorflag,1
                        End:
                }
                if(errorflag==true)
                {
-                       err = CPURegs.h.ah;
+                       //err = CPURegs.h.ah;
                        strcpy(str,"MM_MapEMS: EMS error 0x");
-                       itoa(err,str2,16);
-                       strcpy(str,str2);
+                       //itoa(err,str2,16);
+                       //strcat(str,&err);
                        //printf("%s\n",str);
-                       printf("FACK! %u\n", err);
+                       printf("%s%x\n",str, err);
+                       //printf("FACK! %x\n", err);
                        return err;
                }
        }
        return 0;
 }
 
-/*
-SUB EMS.MapXPages (PhysicalStart, LogicalStart, NumPages, Handle)\r
+byte MM_MapXEMS(mminfo_t *mm)
+{
+
+//SUB EMS.MapXPages (PhysicalStart, LogicalStart, NumPages, Handle)\r
 \r
-  'Maps up to 4 logical EMS pages to physical pages in the page frame, where:\r
-  '\r
-  'PhysicalStart = Physical page first logical page is mapped to\r
-  'LogicalStart  = First logical page to map\r
-  'NumPages      = Number of pages to map (1 to 4)\r
-  'Handle        = EMS handle logical pages are allocated to\r
+       //Maps up to 4 logical EMS pages to physical pages in the page frame, where:\r
+       //PhysicalStart = Physical page first logical page is mapped to\r
+       //LogicalStart  = First logical page to map\r
+       //NumPages      = Number of pages to map (1 to 4)\r
+       //Handle        = EMS handle logical pages are allocated to\r
 \r
-  'Create a buffer containing the page information\r
-  FOR x = 0 TO NumPages - 1\r
-    MapInfo$ = MapInfo$ + MKI$(LogicalStart + x) + MKI$(PhysicalStart + x)\r
-  NEXT\r
+  /*//Create a buffer containing the page information\r
+//  FOR x = 0 TO NumPages - 1\r
+//    MapInfo$ = MapInfo$ + MKI$(LogicalStart + x) + MKI$(PhysicalStart + x)\r
+//  NEXT*/\r
 \r
-  Regs.ax = &H5000                           'Map the pages in the buffer\r
-  Regs.cx = NumPages                         'to the pageframe\r
-  Regs.dx = Handle\r
-  Regs.ds = VARSEG(MapInfo$)\r
-  Regs.si = SADD(MapInfo$)\r
-  InterruptX &H67, Regs, Regs\r
-  EMS.Error = (Regs.ax AND &HFF00&) \ &H100  'Store the status code\r
+//  Regs.ax = &H5000                           //Map the pages in the buffer\r
+//  Regs.cx = NumPages                         //to the pageframe\r
+//  Regs.dx = Handle\r
+//  Regs.ds = VARSEG(MapInfo$)\r
+//  Regs.si = SADD(MapInfo$)\r
+//  InterruptX &H67, Regs, Regs\r
+//     EMS.Error = (Regs.ax AND &HFF00&) \ &H100  //Store the status code\r
 \r
-END SUB
-*/
-void MM_MapXEMS(mminfo_t *mm)
-{
+//END SUB
+/*
+char   str[80];//,str2[10];
+       unsigned        EMShandle;
+       byte err;
+       boolean errorflag=false;
+       int     i;
+       union REGS CPURegs;
+       EMShandle=mm->EMShandle;
 
+       for (i=0;i<MAPPAGES;i++)
+       {
+               __asm
+               {
+                       mov     ah,EMS_MAPPAGE
+                       mov     bx,[i]                  // logical page
+                       mov     al,bl                   // physical page
+                       mov     dx,[EMShandle]  // handle
+                       int     EMS_INT
+                       or      ah,ah
+                       jnz     error
+                       jmp End
+                       error:
+                       mov     err,ah
+                       mov     errorflag,1
+                       End:
+               }
+               if(errorflag==true)
+               {
+                       //err = CPURegs.h.ah;
+                       strcpy(str,"MM_MapEMS: EMS error 0x");
+                       //itoa(err,str2,16);
+                       //strcat(str,&err);
+                       //printf("%s\n",str);
+                       printf("%s%x\n",str, err);
+                       //printf("FACK! %x\n", err);
+                       return err;
+               }
+       }
+       return 0;
+*/
 }
 
 //==========================================================================