]> 4ch.mooo.com Git - 16.git/commitdiff
16_pm tweakings
authorsparky4 <sparky4@cock.li>
Thu, 22 Sep 2016 16:20:42 +0000 (11:20 -0500)
committersparky4 <sparky4@cock.li>
Thu, 22 Sep 2016 16:20:42 +0000 (11:20 -0500)
DEBUG.16W
MMDUMP.16W
makefile
src/exmmtest.c
src/lib/16_head.h
src/lib/16_mm.c
src/lib/16_mm.h
src/lib/16_pm.c
src/lib/typdefst.h

index 443a5fd67999740bf14f38c28838790c3421bd91..5fb5e282c3084f1c5ba84b10a3537a53ba0187ba 100755 (executable)
--- a/DEBUG.16W
+++ b/DEBUG.16W
@@ -1,12 +1,12 @@
-\e[0mSeg:0      Size:10392      Owner:0x7cfc\r
-\e[41;31m++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\e[0m\e[42;32m0\r
-\e[0m\e[0mSeg:2898       Size:256        Owner:0x638e\r
-\e[44;34m+++++\e[0m\e[42;32m\r
-\e[0m\e[0mSeg:2998       Size:401        Owner:0xa41a\r
-\e[44;34m++++++\e[0m\e[42;32m\r
-\e[0m\e[0mSeg:2e11       Size:36 Owner:0x0\r
-\e[41;31m+\e[0m\e[42;32m000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r
-\e[0m\e[0mSeg:be35       Size:8651       Owner:0x0\r
-\e[41;31m+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\e[0m\e[42;32m\r
+\e[0mSeg:0      Size:8568       Owner:0xfe7e\r
+\e[41;31m++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\e[0m\e[42;32m0\r
+\e[0m\e[0mSeg:2178       Size:256        Owner:0x5434\r
+\e[44;34m++++\e[0m\e[42;32m\r
+\e[0m\e[0mSeg:2278       Size:17 Owner:0x9480\r
+\e[44;34m+\e[0m\e[42;32m\r
+\e[0m\e[0mSeg:27ec       Size:44 Owner:0x0\r
+\e[41;31m++\e[0m\e[42;32m0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r
+\e[0m\e[0mSeg:b818       Size:10216      Owner:0x0\r
+\e[41;31m++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\e[0m\e[42;32m\r
 \e[0m\e[0mSeg:e000       Size:8191       Owner:0x0\r
 \e[41;31m++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\e[0m
\ No newline at end of file
index 300e3279762e6d5eb41f81bd1adea17b2d92d237..4bf1c809f6d6b2988d2b2f86a1bfb477c54c02e3 100755 (executable)
Binary files a/MMDUMP.16W and b/MMDUMP.16W differ
index 2496bbd8c1c7e3f400facefd33390a967150fc12..e8aa09fcdc1d93afdcf9b68e197c05974ddb7dc4 100755 (executable)
--- a/makefile
+++ b/makefile
@@ -106,9 +106,8 @@ LIBFLAGS=$(WLIBQ) -b -n
 # objects
 #
 VGMSNDOBJ = vgmSnd.$(OBJ) 16_snd.$(OBJ)
-COREOBJS = 16_mm.$(OBJ) 16_pm.$(OBJ) 16_ca.$(OBJ) 16_lib.$(OBJ) 16_in.$(OBJ) 16_head.$(OBJ) 16_dbg.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ)
 GFXLIBOBJS = modex16.$(OBJ) bitmap.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16render.$(OBJ) 16_vrs.$(OBJ) 16_sprit.$(OBJ)
-16LIBOBJS = $(COREOBJS) wcpu.$(OBJ) 16_timer.$(OBJ)
+16LIBOBJS = 16_mm.$(OBJ) 16_pm.$(OBJ) 16_ca.$(OBJ) 16_lib.$(OBJ) 16_in.$(OBJ) 16_head.$(OBJ) 16_dbg.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) wcpu.$(OBJ) 16_timer.$(OBJ)
 #16planar.$(OBJ) planar.$(OBJ)
 DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ)
 !ifeq DEBUGSERIAL 1
index 046380ce9789e168edde04d9d7e1536e6063f982..bddf4a09c13aac7606de08628ae080b1b5eaa613 100755 (executable)
@@ -95,11 +95,10 @@ main(int argc, char *argv[])
                bakapee1 = "data/koishi~.pcx";\r
                bakapee2 = "data/test.map";\r
        }\r
-//     printf("main()=%Fp      start MM\n", *argv[0]);\r
+       //printf("main()=%Fp    start MM\n", *argv[0]);\r
        MM_Startup(&gvar);\r
        PM_Startup(&gvar);\r
-       PM_UnlockMainMem(&gvar);\r
-       //PM_LockMainMem(&gvar);\r
+       //PM_UnlockMainMem(&gvar);\r
        CA_Startup(&gvar);\r
 //     printf("                done!\n");\r
        PRINTBB;\r
index baa983e8e9a1c23324cd0fcaf648816b312affe6..b3423ed0e146d5572c56c10a1b19a9adebebf62f 100755 (executable)
@@ -160,7 +160,23 @@ extern     int                     profilehandle,debughandle;      //make it into game global
 #endif\r
 #ifdef __WATCOMC__\r
 #define _FCORELEFT 0x90000UL+16UL\r
-extern union REGS CPURegs;\r
+static union REGS CPURegs;\r
+\r
+#define _AX CPURegs.x.ax\r
+#define _BX CPURegs.x.bx\r
+#define _CX CPURegs.x.cx\r
+#define _DX CPURegs.x.dx\r
+\r
+#define _SI CPURegs.x.si\r
+\r
+#define _AH CPURegs.h.ah\r
+#define _AL CPURegs.h.al\r
+#define _BH CPURegs.h.bh\r
+#define _BL CPURegs.h.bl\r
+#define _CH CPURegs.h.ch\r
+#define _CL CPURegs.h.cl\r
+#define _DH CPURegs.h.dh\r
+#define _DL CPURegs.h.dl\r
 \r
 #define geninterrupt(n) int86(n,&CPURegs,&CPURegs);\r
 #define peekb(segm,ofs) (*(byte far*)MK_FP((segm),(ofs)))\r
index 9eb93c67b45d47774fe81758d1870ce9d48f803a..9333d380c0583eca68456bbc7df610217da89a5b 100755 (executable)
@@ -157,8 +157,8 @@ byte MML_SetupEMS(global_game_variables_t *gvar)
 
        unsigned int EMSVer = 0;
        //byte  EMS_status;
-       unsigned        totalEMSpages,freeEMSpages,EMSpageframe,EMSpagesmapped,EMShandle;
-       totalEMSpages = freeEMSpages = EMSpageframe = EMSpagesmapped = 0;
+       unsigned        totalEMSpages,freeEMSpages,EMSPageFrame,EMSpagesmapped,EMSHandle;
+       totalEMSpages = freeEMSpages = EMSPageFrame = EMSpagesmapped = 0;
 
        __asm {
                mov     ah,EMS_STATUS
@@ -179,7 +179,7 @@ byte MML_SetupEMS(global_game_variables_t *gvar)
                int     EMS_INT                                         // find the page frame address
                or      ah,ah
                jnz     error
-               mov     [EMSpageframe],bx
+               mov     [EMSPageFrame],bx
 
                mov     ah,EMS_GETPAGES
                int     EMS_INT                                         // find out how much EMS is there
@@ -218,7 +218,7 @@ byte MML_SetupEMS(global_game_variables_t *gvar)
                int     EMS_INT
                or      ah,ah
                jnz     error
-               mov     [EMShandle],dx
+               mov     [EMSHandle],dx
                jmp End
 #ifdef __BORLANDC__
        }
@@ -245,12 +245,12 @@ End:
                printf("%s\n",str);
                return err;
        }
-       gvar->mm.totalEMSpages=totalEMSpages;
-       gvar->mm.freeEMSpages=freeEMSpages;
-       gvar->mm.EMSpageframe=EMSpageframe;
-       gvar->mm.EMSpagesmapped=EMSpagesmapped;
-       gvar->mm.EMShandle=EMShandle;
-       gvar->mm.EMSVer=EMSVer;
+       gvar->pm.emm.totalEMSpages=totalEMSpages;
+       gvar->pm.emm.freeEMSpages=freeEMSpages;
+       gvar->pm.emm.EMSPageFrame=EMSPageFrame;
+       gvar->pm.emm.EMSpagesmapped=EMSpagesmapped;
+       gvar->pm.emm.EMSHandle=EMSHandle;
+       gvar->pm.emm.EMSVer=EMSVer;
        return 0;
 }
 
@@ -266,13 +266,13 @@ End:
 void MML_ShutdownEMS(global_game_variables_t *gvar)
 {
        boolean errorflag=false;
-       unsigned EMShandle=gvar->mm.EMShandle;
+       unsigned EMSHandle=gvar->pm.emm.EMSHandle;
 
-       if(!EMShandle)
+       if(!EMSHandle)
                return;
        __asm {
                mov     ah,EMS_FREEPAGES
-               mov     dx,[EMShandle]
+               mov     dx,[EMSHandle]
                int     EMS_INT
                or      ah,ah
                jz      ok
@@ -303,11 +303,11 @@ void MML_ShutdownEMS(global_game_variables_t *gvar)
 byte MM_MapEMS(global_game_variables_t *gvar)
 {
        byte    str[160];
-       unsigned        EMShandle;
+       unsigned        EMSHandle;
        byte err;
        boolean errorflag=false;
        int     i;
-       EMShandle=gvar->mm.EMShandle;
+       EMSHandle=gvar->pm.emm.EMSHandle;
 
        for (i=0;i<4/*MAPPAGES*/;i++)
        {
@@ -315,7 +315,7 @@ byte MM_MapEMS(global_game_variables_t *gvar)
                        mov     ah,EMS_MAPPAGE
                        mov     bx,[i]                  // logical page
                        mov     al,bl                   // physical page
-                       mov     dx,[EMShandle]  // handle
+                       mov     dx,[EMSHandle]  // handle
                        int     EMS_INT
                        or      ah,ah
                        jnz     error
@@ -375,12 +375,12 @@ byte MM_MapXEMS(global_game_variables_t *gvar)
 //END SUB
        byte    str[160];
        byte err;
-       word    EMShandle;
+       word    EMSHandle;
        boolean errorflag=false;
        int     i;
-       EMShandle=gvar->mm.EMShandle;
+       EMSHandle=gvar->pm.emm.EMSHandle;
 
-       if(gvar->mm.EMSVer<0x40)
+       if(gvar->pm.emm.EMSVer<0x40)
                return 5;
 
        for (i=0;i<MAPPAGES;i++)
@@ -389,7 +389,7 @@ byte MM_MapXEMS(global_game_variables_t *gvar)
                        mov     ah,EMS_MAPXPAGE
                        mov     cx,[i]                  // logical page
                        mov     al,bl                   // physical page
-                       mov     dx,[EMShandle]  // handle
+                       mov     dx,[EMSHandle]  // handle
                        int     EMS_INT
                        or      ah,ah
                        jnz     error
@@ -864,7 +864,7 @@ void MM_Startup(global_game_variables_t *gvar)
        {
                MML_SetupEMS(gvar);                                     // allocate space
                //TODO: EMS4! AND EMS 3.2 MASSIVE DATA HANDLMENT!
-               MML_UseSpace(gvar->mm.EMSpageframe,(MAPPAGES)*0x4000lu, gvar);
+               MML_UseSpace(gvar->pm.emm.EMSPageFrame,(MAPPAGES)*0x4000lu, gvar);
                //if(gvar->pm.emm.EMSVer<0x40)
                        MM_MapEMS(gvar);                                        // map in used pages
                //else
@@ -964,9 +964,10 @@ void MM_GetPtr (memptr *baseptr, dword size, global_game_variables_t *gvar)
        gvar->mm.mmnew->useptr = baseptr;
        //if(gvar->mm.mmnew->useptr==NULL){
 #ifdef __DEBUG__
-               printf("baseptr=%04x    ", baseptr); printf("useptr=%04x\n", gvar->mm.mmnew->useptr);
-               printf("*baseptr=%04x   ", *baseptr); printf("*useptr=%04x\n", *(gvar->mm.mmnew->useptr));
-               printf("*baseptr=%Fp    ", *baseptr); printf("*useptr=%Fp\n", *(gvar->mm.mmnew->useptr));
+               printf("        MM_GetPtr\n");
+               printf("                baseptr=%04x    ", baseptr); printf("useptr=%04x\n", gvar->mm.mmnew->useptr);
+               printf("                *baseptr=%04x   ", *baseptr); printf("*useptr=%04x\n", *(gvar->mm.mmnew->useptr));
+               printf("                *baseptr=%Fp    ", *baseptr); printf("*useptr=%Fp\n", *(gvar->mm.mmnew->useptr));
 #endif
        //exit(-5); }
        gvar->mm.mmnew->attributes = BASEATTRIBUTES;
@@ -1124,8 +1125,11 @@ void MM_SetPurge(memptr *baseptr, int purge, global_game_variables_t *gvar)
                        gvar->mm.mmrover = gvar->mm.mmhead;
                else if(gvar->mm.mmrover == start)
                {
-                       Quit("MM_SetPurge: Block not found!");
-                       //return;
+                       //Quit("MM_SetPurge: Block not found!");
+                       printf("%Fp     %u\n", start->start, start->length);
+                       printf("MM_SetPurge: Block not found!\n");
+                       exit(1);
+                       return;
                }
 
        } while(1);
@@ -1605,9 +1609,9 @@ void MM_Report_(global_game_variables_t *gvar)
        if(MML_CheckForEMS())
        {
                printf("        LIMEMS\n");
-               printf("                EMM v%x.%x available\n", gvar->mm.EMSVer>>4,gvar->mm.EMSVer&0x0F);
-               printf("                totalEMSpages:  %u      ", gvar->mm.totalEMSpages); printf("freeEMSpages:       %u\n", gvar->mm.freeEMSpages);
-               printf("                EMSpageframe:   %x\n", gvar->mm.EMSpageframe);
+               printf("                EMM v%x.%x available\n", gvar->pm.emm.EMSVer>>4,gvar->pm.emm.EMSVer&0x0F);
+               printf("                totalEMSpages:  %u      ", gvar->pm.emm.totalEMSpages); printf("freeEMSpages:   %u\n", gvar->pm.emm.freeEMSpages);
+               printf("                EMSPageFrame:   %x\n", gvar->pm.emm.EMSPageFrame);
        }
        if(MML_CheckForXMS(gvar))
        {
index 7995bf23dbb5ee19a3a0cb38e37e88c453e9c23a..206a3c8b358d6b8f3b85930d1d14a0ff64f88bdc 100755 (executable)
@@ -26,9 +26,9 @@
 #include "src/lib/16_head.h"
 #include "src/lib/16_hc.h"
 #include "src/lib/16_lib.h"
-//#include "src/lib/modex16.h"
 //++++mh       #include "src/lib/16_in.h"
 
+
 #ifdef __DEBUG__               // 1 == Debug/Dev  ;  0 == Production/final
 #define OUT_OF_MEM_MSG "MM_GetPtr: Out of memory!\nYou were short :%lu bytes\n"
 #else
@@ -205,12 +205,12 @@ void MM_FreePtr(memptr *baseptr, global_game_variables_t *gvar);
 void MM_SetPurge(memptr *baseptr, int purge, global_game_variables_t *gvar);
 void MM_SetLock(memptr *baseptr, boolean locked, global_game_variables_t *gvar);
 void MM_SortMem(global_game_variables_t *gvar);
-void MM_ShowMemory(global_game_variables_t *gvar);//,/*page_t *page, */mminfo_t *mm);
+void MM_ShowMemory(global_game_variables_t *gvar);
 void MM_DumpData(global_game_variables_t *gvar);
 dword MM_UnusedMemory(global_game_variables_t *gvar);
 dword MM_TotalFree(global_game_variables_t *gvar);
 void MM_Report_(global_game_variables_t *gvar);
-static void MM_EMSerr(byte *stri, byte err);
+/*static */void MM_EMSerr(byte *stri, byte err);
 void MM_BombOnError(boolean bomb, global_game_variables_t *gvar);
 //void MM_GetNewBlock(mminfo_t *mm);
 //void MM_FreeBlock(mmblocktype *x, mminfo_t *mm);
index 9740195156dc584e7a15d26a248dbe76289c2028..8ebf0ec000a94529bb03c5b4a14230a9d4a8434e 100755 (executable)
@@ -28,7 +28,7 @@
 \r
 #include "src/lib/16_pm.h"\r
 #pragma hdrstop\r
-union REGS CPURegs;\r
+\r
 /*\r
 //     Main Mem specific variables\r
        boolean                 MainPresent;\r
@@ -77,23 +77,50 @@ static      char            *ParmStrings[] = {"nomain","noems","noxms",nil};
 //\r
 //     PML_MapEMS() - Maps a logical page to a physical page\r
 //\r
-void\r
-PML_MapEMS(word logical, word physical, global_game_variables_t *gvar)\r
+byte\r
+PML_MapEMS(word logical, byte physical, global_game_variables_t *gvar)\r
 {\r
-       union REGS CPURegs;\r
-       CPURegs.h.al = physical;\r
-       CPURegs.x.bx = logical;\r
-       CPURegs.x.dx = gvar->pm.emm.EMSHandle;\r
-       CPURegs.h.ah = EMS_MAPPAGE;\r
+       byte    str[160];\r
+       unsigned        EMShandle;\r
+       byte err;\r
+       boolean errorflag=false;\r
+       int     i;\r
+       EMShandle=gvar->pm.emm.EMSHandle;\r
+\r
        __asm {\r
+               mov     ah,EMS_MAPPAGE\r
+               mov     al,physical\r
+               mov     bx,logical\r
+               mov     dx,EMShandle\r
                int     EMS_INT\r
+               or      ah,ah\r
+               jnz     error\r
+               jmp End\r
+#ifdef __BORLANDC__\r
        }\r
-\r
-       if(CPURegs.h.ah)\r
+#endif\r
+               error:\r
+#ifdef __BORLANDC__\r
+       __asm {\r
+#endif\r
+               mov     err,ah\r
+               mov     errorflag,1\r
+#ifdef __BORLANDC__\r
+       }\r
+#endif\r
+               End:\r
+#ifdef __WATCOMC__\r
+       }\r
+#endif\r
+       if(errorflag==true)\r
        {\r
+               strcpy(str,"MM_MapEMS: EMS error ");\r
+               MM_EMSerr(str, err);\r
+               printf("%s\n",str);\r
                Quit("PML_MapEMS: Page mapping failed\n");\r
-               return;\r
+               return err;\r
        }\r
+       return 0;\r
 }\r
 \r
 //\r
@@ -111,7 +138,6 @@ boolean
 PML_StartupEMS(global_game_variables_t *gvar)\r
 {\r
        boolean emmcfems;\r
-       union REGS CPURegs;\r
 \r
        int             i;\r
        long    size;\r
@@ -121,8 +147,8 @@ PML_StartupEMS(global_game_variables_t *gvar)
        emmcfems=0;\r
 \r
        __asm {\r
-       //CPURegs.x.dx = (word)EMMDriverName;\r
-       //CPURegs.x.ax = 0x3d00;\r
+       //_DX = (word)EMMDriverName;\r
+       //_AX = 0x3d00;\r
        //geninterrupt(0x21);                   // try to open EMMXXXX0 device\r
                mov     dx,OFFSET EMMDriverName\r
                mov     ax,0x3d00\r
@@ -139,8 +165,8 @@ gothandle:
 #ifdef __BORLANDC__\r
        __asm {\r
 #endif\r
-       //CPURegs.x.bx = CPURegs.x.ax;\r
-       //CPURegs.x.ax = 0x4400;\r
+       //_BX = _AX;\r
+       //_AX = 0x4400;\r
        //geninterrupt(0x21);                   // get device info\r
                mov     bx,ax\r
                mov     ax,0x4400\r
@@ -159,43 +185,43 @@ gotinfo:
 #endif\r
        if(emmcfems!=0) goto error;\r
        __asm and       dx,0x80\r
-       if (!CPURegs.x.dx)\r
+       if (!_DX)\r
                goto error;\r
 \r
-       CPURegs.x.ax = 0x4407;\r
+       _AX = 0x4407;\r
        geninterrupt(0x21);                     // get status\r
        __asm mov       emmcfems,1\r
        if(emmcfems!=0) goto error;\r
 \r
-       if (!CPURegs.h.al)\r
+       if (!_AL)\r
                goto error;\r
 \r
-       CPURegs.h.ah = 0x3e;\r
+       _AH = 0x3e;\r
        geninterrupt(0x21);                     // close handle\r
 \r
-       CPURegs.h.ah = EMS_STATUS;\r
+       _AH = EMS_STATUS;\r
        geninterrupt(EMS_INT);\r
-       if (CPURegs.h.ah)\r
+       if (_AH)\r
                goto error;                             // make sure EMS hardware is present\r
 \r
-       CPURegs.h.ah = EMS_VERSION;\r
+       _AH = EMS_VERSION;\r
        geninterrupt(EMS_INT);\r
-       if (CPURegs.h.ah || (CPURegs.h.al < 0x32))      // only work on EMS 3.2 or greater (silly, but...)\r
+       if (_AH || (_AL < 0x32))        // only work on EMS 3.2 or greater (silly, but...)\r
                goto error;\r
 \r
-       CPURegs.h.ah = EMS_GETFRAME;\r
+       _AH = EMS_GETFRAME;\r
        geninterrupt(EMS_INT);\r
-       if (CPURegs.h.ah)\r
+       if (_AH)\r
                goto error;                             // find the page frame address\r
-       gvar->pm.emm.EMSPageFrame = CPURegs.x.bx;\r
+       gvar->pm.emm.EMSPageFrame = _BX;\r
 \r
-       CPURegs.h.ah = EMS_GETPAGES;\r
+       _AH = EMS_GETPAGES;\r
        geninterrupt(EMS_INT);\r
-       if (CPURegs.h.ah)\r
+       if (_AH)\r
                goto error;\r
-       if (CPURegs.x.bx < 2)\r
+       if (_BX < 2)\r
                goto error;             // Require at least 2 pages (32k)\r
-       gvar->pm.emm.EMSAvail = CPURegs.x.bx;\r
+       gvar->pm.emm.EMSAvail = _BX;\r
 \r
        // Don't hog all available EMS\r
        size = gvar->pm.emm.EMSAvail * (long)EMSPageSize;\r
@@ -205,12 +231,12 @@ gotinfo:
                gvar->pm.emm.EMSAvail = size / EMSPageSize;\r
        }\r
 \r
-       CPURegs.h.ah = EMS_ALLOCPAGES;\r
-       CPURegs.x.bx = gvar->pm.emm.EMSAvail;\r
+       _AH = EMS_ALLOCPAGES;\r
+       _BX = gvar->pm.emm.EMSAvail;\r
        geninterrupt(EMS_INT);\r
-       if (CPURegs.h.ah)\r
+       if (_AH)\r
                goto error;\r
-       gvar->pm.emm.EMSHandle = CPURegs.x.dx;\r
+       gvar->pm.emm.EMSHandle = _DX;\r
 \r
        gvar->mmi.EMSmem += gvar->pm.emm.EMSAvail * (long)EMSPageSize;\r
 \r
@@ -230,14 +256,12 @@ error:
 void\r
 PML_ShutdownEMS(global_game_variables_t *gvar)\r
 {\r
-       union REGS CPURegs;\r
-\r
        if (gvar->pm.emm.EMSPresent)\r
        {\r
-                       CPURegs.h.ah=EMS_FREEPAGES;\r
-                       CPURegs.x.ax=gvar->pm.emm.EMSHandle;\r
+                       _AH=EMS_FREEPAGES;\r
+                       _AX=gvar->pm.emm.EMSHandle;\r
                        geninterrupt(EMS_INT);\r
-               if (CPURegs.h.ah)\r
+               if (_AH)\r
                {\r
                        Quit("PML_ShutdownEMS: Error freeing EMS\n");\r
                        //return;\r
@@ -260,15 +284,13 @@ PML_ShutdownEMS(global_game_variables_t *gvar)
 boolean\r
 PML_StartupXMS(global_game_variables_t *gvar)\r
 {\r
-       union REGS CPURegs;\r
-\r
        XMSD;\r
        gvar->pm.xmm.XMSPresent = false;                                        // Assume failure\r
        gvar->pm.xmm.XMSAvail = 0;\r
 \r
-       CPURegs.x.ax=0x4300;\r
+       _AX=0x4300;\r
        geninterrupt(XMS_INT);                                  // Check for presence of XMS driver\r
-       if (CPURegs.h.al != 0x80)\r
+       if (_AL != 0x80)\r
                goto error;\r
 \r
 \r
@@ -280,19 +302,19 @@ PML_StartupXMS(global_game_variables_t *gvar)
        }\r
 \r
        XMS_CALL(XMS_QUERYFREE, gvar);                  // Find out how much XMS is available\r
-       gvar->pm.xmm.XMSAvail = CPURegs.x.ax;\r
-       if (!CPURegs.x.ax)                              // AJR: bugfix 10/8/92\r
+       gvar->pm.xmm.XMSAvail = _AX;\r
+       if (!_AX)                               // AJR: bugfix 10/8/92\r
                goto error;\r
 \r
        gvar->pm.xmm.XMSAvail &= ~(PMPageSizeKB - 1);   // Round off to nearest page size\r
        if (gvar->pm.xmm.XMSAvail < (PMPageSizeKB * 2)) // Need at least 2 pages\r
                goto error;\r
 \r
-       CPURegs.x.dx = gvar->pm.xmm.XMSAvail;\r
+       _DX = gvar->pm.xmm.XMSAvail;\r
        XMS_CALL(XMS_ALLOC, gvar);                              // And do the allocation\r
-       gvar->pm.xmm.XMSHandle = CPURegs.x.dx;\r
+       gvar->pm.xmm.XMSHandle = _DX;\r
 \r
-       if (!CPURegs.x.ax)                              // AJR: bugfix 10/8/92\r
+       if (!_AX)                               // AJR: bugfix 10/8/92\r
        {\r
                gvar->pm.xmm.XMSAvail = 0;\r
                goto error;\r
@@ -340,12 +362,12 @@ PML_XMSCopy(boolean toxms,byte far *addr,word xmspage,word length, global_game_v
        __asm {\r
                push si\r
        }\r
-       CPURegs.x.si = (word)&copy;\r
+       _SI = (word)&copy;\r
        XMS_CALL(XMS_MOVE, gvar);\r
        __asm {\r
                pop     si\r
        }\r
-       if (!CPURegs.x.ax)\r
+       if (!_AX)\r
        {\r
                Quit("PML_XMSCopy: Error on copy");\r
                //return;\r
@@ -386,9 +408,9 @@ PML_ShutdownXMS(global_game_variables_t *gvar)
        XMSD;\r
        if (gvar->pm.xmm.XMSPresent)\r
        {\r
-               CPURegs.x.dx = gvar->pm.xmm.XMSHandle;\r
+               _DX = gvar->pm.xmm.XMSHandle;\r
                XMS_CALL(XMS_FREE, gvar);\r
-               if (CPURegs.h.bl)\r
+               if (_BL)\r
                {\r
                        Quit("PML_ShutdownXMS: Error freeing XMS");\r
                        //return;\r
index 5aa4c8c3b536678e395a6b571ea19bccfb688437..4d031f9e66b953822e3458bdfe4db0ed5c93d417 100755 (executable)
@@ -170,8 +170,6 @@ typedef struct
        void __near     *nearheap;\r
 #endif\r
        //byte          EMS_status;\r
-       unsigned        totalEMSpages,freeEMSpages,EMSpageframe,EMSpagesmapped,EMShandle;//TODO: PM use\r
-       unsigned int EMSVer;\r
        word numUMBs,UMBbase[MAXUMBS];\r
        //dword numUMBs,UMBbase[MAXUMBS];\r
        //huge mmblocktype      huge mmblocks[MAXBLOCKS],huge *mmhead,huge *mmfree,huge *mmrover,huge *mmnew;\r
@@ -248,6 +246,7 @@ typedef struct
        boolean                 EMSPresent;\r
        word                    EMSAvail,EMSPagesAvail,EMSHandle,\r
                                        EMSPageFrame,EMSPhysicalPage, EMSVer;\r
+       word                    totalEMSpages, freeEMSpages, EMSpagesmapped;\r
        EMSListStruct   EMSList[EMSFrameCount];\r
 } pm_emmi_t;\r
 \r