From: sparky4 Date: Mon, 26 Sep 2016 18:04:11 +0000 (-0500) Subject: wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww massive work there is issue with... X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=e271343a59cfb8fd3afd1f011a3f9ff860057aba;p=16.git wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww massive work there is issue with structure --- diff --git a/DEBUG.16B b/DEBUG.16B index f5605e85..d6ad70e7 100755 --- a/DEBUG.16B +++ b/DEBUG.16B @@ -1,9 +1,7 @@ -Seg:0 Size:3547 Owner:0x696c +Seg:0 Size:3552 Owner:0x6974 +++++++++++++++++++++++++++++++++++++++++++++0 -Seg:ddb Size:256 Owner:0xcf85 -++++ -Seg:edb Size:273 Owner:0xfde -++++0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +Seg:de0 Size:256 Owner:0xcf79 +++++0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Seg:9fde Size:28706 Owner:0x0  Seg:9ffe Size:24577 Owner:0x0 diff --git a/DEBUG.16W b/DEBUG.16W index d8f8cf89..b3ed514b 100755 --- a/DEBUG.16W +++ b/DEBUG.16W @@ -1,12 +1,12 @@ -Seg:0 Size:8575 Owner:0x0 -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0 -Seg:217f Size:256 Owner:0x5438 +Seg:0 Size:8558 Owner:0x1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0 +Seg:216e Size:256 Owner:0x5448 ++++++ +Seg:226e Size:273 Owner:0x94a0 ++++ -Seg:227f Size:273 Owner:0x9490 -++++ -Seg:27f2 Size:44 Owner:0x0 +Seg:27e0 Size:44 Owner:0x0 ++0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -Seg:b81e Size:10210 Owner:0x0 -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +Seg:b80c Size:10228 Owner:0x0 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Seg:e000 Size:8191 Owner:0x0 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file diff --git a/HEAP.16W b/HEAP.16W index ac2b7f9d..2b94206e 100755 --- a/HEAP.16W +++ b/HEAP.16W @@ -1,47 +1,47 @@ == default == - USED block at 28140016 of size 66 - USED block at 28140058 of size 66 - FREE block at 2814009a of size 18 - USED block at 281400ac of size 136 - USED block at 28140134 of size 20 - FREE block at 28140148 of size 7860 + USED block at 28020016 of size 66 + USED block at 28020058 of size 66 + FREE block at 2802009a of size 18 + USED block at 280200ac of size 136 + USED block at 28020134 of size 20 + FREE block at 28020148 of size 7860 OK - end of heap == near == - USED block at 181394c6 of size 12 - USED block at 181394d2 of size 332 - USED block at 1813961e of size 52 - USED block at 18139652 of size 20 - USED block at 18139666 of size 20 - USED block at 1813967a of size 20 - USED block at 1813968e of size 20 - USED block at 181396a2 of size 20 - USED block at 181396b6 of size 26950 + USED block at 180194d6 of size 12 + USED block at 180194e2 of size 332 + USED block at 1801962e of size 52 + USED block at 18019662 of size 20 + USED block at 18019676 of size 20 + USED block at 1801968a of size 20 + USED block at 1801969e of size 20 + USED block at 180196b2 of size 20 + USED block at 180196c6 of size 26934 OK - end of heap == far == - USED block at 28140016 of size 66 - USED block at 28140058 of size 66 - USED block at 2814009a of size 18 - USED block at 281400ac of size 136 - USED block at 28140134 of size 20 - USED block at 28140148 of size 7860 + USED block at 28020016 of size 66 + USED block at 28020058 of size 66 + USED block at 2802009a of size 18 + USED block at 280200ac of size 136 + USED block at 28020134 of size 20 + USED block at 28020148 of size 7860 OK - end of heap Memory Type Total Used Free ---------------- -------- -------- -------- Default 8166 288 7878 -Near 27446 496 26950 +Near 27430 496 26934 Far 8166 288 7878 ---------------- -------- -------- -------- -coreleft = 26948 -farcoreleft = 51056 +coreleft = 26932 +farcoreleft = 51040 GetFreeSize = 24128 -GetNearFreeSize = 26950 +GetNearFreeSize = 26934 GetFarFreeSize = 24128 -memavl = 26948 +memavl = 26932 stackavail = 11268 diff --git a/MMDUMP.16B b/MMDUMP.16B index b9dba409..253c86cf 100755 Binary files a/MMDUMP.16B and b/MMDUMP.16B differ diff --git a/MMDUMP.16W b/MMDUMP.16W index 8420fa4c..2f5e7ecf 100755 Binary files a/MMDUMP.16W and b/MMDUMP.16W differ diff --git a/bcexmm.exe b/bcexmm.exe index ebfd740e..bbfb5560 100755 Binary files a/bcexmm.exe and b/bcexmm.exe differ diff --git a/bcexmm.prj b/bcexmm.prj index 5778f27a..2610441e 100755 Binary files a/bcexmm.prj and b/bcexmm.prj differ diff --git a/src/exmmtest.c b/src/exmmtest.c index f9582832..da100d8e 100755 --- a/src/exmmtest.c +++ b/src/exmmtest.c @@ -86,7 +86,7 @@ main(int argc, char *argv[]) //file name // gvar.mm.mmstarted=0; - pmdebug=0; + debugpm=0; //PRINTBB if(argv[1]){ bakapee1 = argv[1]; @@ -98,10 +98,10 @@ main(int argc, char *argv[]) } //printf("main()=%Fp start MM\n", *argv[0]); MM_Startup(&gvar); - if(pmdebug>0) + if(debugpm>0) { PM_Startup(&gvar); - PM_CheckMainMem(&gvar); + //PM_CheckMainMem(&gvar); PM_UnlockMainMem(&gvar); } CA_Startup(&gvar); @@ -151,7 +151,7 @@ for(w=0;w<2;w++) printf("bakapee1=%s\n", bakapee1); printf("bakapee2=%s\n", bakapee2); MM_FreePtr(&bigbuffer, &gvar); - if(pmdebug>0) + if(debugpm>0) PM_Shutdown(&gvar); CA_Shutdown(&gvar); MM_Shutdown(&gvar); diff --git a/src/lib/16_head.h b/src/lib/16_head.h index ec7db9f8..2d080d52 100755 --- a/src/lib/16_head.h +++ b/src/lib/16_head.h @@ -152,7 +152,8 @@ static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ extern int profilehandle,debughandle; //make it into game global #define __DEBUG__ -//0000#define __DEBUG_PM__ +#define __DEBUG_PM__ +//#define __DEBUG_MM__ #define nil ((void *)0) #ifdef __BORLANDC__ diff --git a/src/lib/16_mm.c b/src/lib/16_mm.c index db338fa1..859a5b4a 100755 --- a/src/lib/16_mm.c +++ b/src/lib/16_mm.c @@ -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__ } @@ -247,9 +247,9 @@ End: } gvar->mm.totalEMSpages=totalEMSpages; gvar->mm.freeEMSpages=freeEMSpages; - gvar->mm.EMSpageframe=EMSpageframe; + gvar->mm.EMSPageFrame=EMSPageFrame; gvar->mm.EMSpagesmapped=EMSpagesmapped; - gvar->mm.EMShandle=EMShandle; + gvar->mm.EMSHandle=EMSHandle; gvar->mm.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->mm.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->mm.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,10 +375,10 @@ 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->mm.EMSHandle; if(gvar->mm.EMSVer<0x40) return 5; @@ -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 @@ -836,7 +836,9 @@ void MM_Startup(global_game_variables_t *gvar) gvar->mmi.mainmem = gvar->mmi.nearheap + gvar->mmi.farheap; - if(!pmdebug) { +#ifdef __DEBUG__ + if(!debugpm) { +#endif // // detect EMS and allocate up to 64K at page frame // @@ -865,7 +867,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->mm.EMSPageFrame,(MAPPAGES)*0x4000lu, gvar); //if(gvar->pm.emm.EMSVer<0x40) MM_MapEMS(gvar); // map in used pages //else @@ -901,7 +903,9 @@ goto xmsskip;//0000 { MML_SetupXMS(gvar); // allocate as many UMBs as possible } +#ifdef __DEBUG__ } +#endif // // allocate the misc buffer // @@ -935,10 +939,14 @@ void MM_Shutdown(global_game_variables_t *gvar) #ifdef __BORLANDC__ free(gvar->mm.nearheap);// printf(" near freed\n"); #endif - if(!pmdebug) { +#ifdef __DEBUG__ + if(!debugpm) { +#endif if(MML_CheckForEMS()){ MML_ShutdownEMS(gvar); }//printf(" EMS freed\n"); } if(MML_CheckForXMS(gvar)){ MML_ShutdownXMS(gvar); }//printf(" XMS freed\n"); } +#ifdef __DEBUG__ } +#endif } //========================================================================== @@ -966,10 +974,12 @@ void MM_GetPtr (memptr *baseptr, dword size, global_game_variables_t *gvar) gvar->mm.mmnew->length = needed; 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)); +#ifdef __DEBUG_MM__ + printf("MM_GetPtr\n"); + //%04x + printf(" baseptr=%Fp ", baseptr); printf("useptr=%Fp\n", gvar->mm.mmnew->useptr); + printf(" *baseptr=%Fp ", *baseptr); printf("*useptr=%Fp\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; @@ -1109,6 +1119,7 @@ void MM_FreePtr(memptr *baseptr, global_game_variables_t *gvar) ===================== */ + void MM_SetPurge(memptr *baseptr, int purge, global_game_variables_t *gvar) { //huge mmblocktype huge *start; @@ -1610,7 +1621,7 @@ void MM_Report_(global_game_variables_t *gvar) 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(" EMSPageFrame: %x\n", gvar->mm.EMSPageFrame); } if(MML_CheckForXMS(gvar)) { diff --git a/src/lib/16_mm.h b/src/lib/16_mm.h index b04c56ab..d858c0f1 100755 --- a/src/lib/16_mm.h +++ b/src/lib/16_mm.h @@ -27,11 +27,10 @@ #include "src/lib/16_hc.h" #include "src/lib/16_lib.h" //++++mh #include "src/lib/16_in.h" -extern boolean pmdebug; - #ifdef __DEBUG__ // 1 == Debug/Dev ; 0 == Production/final #define OUT_OF_MEM_MSG "MM_GetPtr: Out of memory!\nYou were short :%lu bytes\n" +extern boolean debugpm; #else #define OUT_OF_MEM_MSG "\npee\n" #endif @@ -106,7 +105,7 @@ extern boolean pmdebug; extern void (* beforesort) (void); extern void (* aftersort) (void); -extern void (* XMSaddr) (void); // far pointer to XMS driver +extern void (* XMSaddr) (void); // far pointer to XMS driver //========================================================================== diff --git a/src/lib/16_pm.c b/src/lib/16_pm.c index b472e58b..030a47b6 100755 --- a/src/lib/16_pm.c +++ b/src/lib/16_pm.c @@ -29,23 +29,24 @@ #include "src/lib/16_pm.h" #pragma hdrstop -boolean pmdebug=0; +#ifdef __DEBUG__ +boolean debugpm=0; +#endif -/* // Main Mem specific variables - boolean MainPresent; +/* boolean MainPresent; memptr MainMemPages[PMMaxMainMem]; PMBlockAttr gvar->pm.mm.MainMemUsed[PMMaxMainMem]; int gvar->pm.mm.MainPagesAvail; // EMS specific variables - boolean gvar->pm.emm.EMSPresent; + boolean EMSPresent; word gvar->pm.emm.EMSAvail,gvar->pm.emm.EMSPagesAvail,gvar->pm.emm.EMSHandle, gvar->pm.emm.EMSPageFrame,gvar->pm.emm.EMSPhysicalPage; gvar->pm.emm.EMSListStruct gvar->pm.emm.EMSList[EMSFrameCount]; // XMS specific variables - boolean gvar->pm.xmm.XMSPresent; + boolean XMSPresent; word gvar->pm.xmm.XMSAvail,gvar->pm.xmm.XMSPagesAvail,gvar->pm.xmm.XMSHandle;*/ word XMSDriver; /* int gvar->pm.xmm.XMSProtectPage = -1; @@ -68,6 +69,7 @@ boolean pmdebug=0; PageListStruct far *gvar->pm.PMPages, _seg *gvar->pm.PMSegPages; */ +boolean PMStarted, MainPresent, EMSPresent, XMSPresent; static char *ParmStrings[] = {"nomain","noems","noxms",nil}; ///////////////////////////////////////////////////////////////////////////// @@ -134,126 +136,157 @@ PML_MapEMS(word logical, byte physical, global_game_variables_t *gvar) // to the maximum we need) // - char EMMDriverName[9] = "EMMXXXX0"; - boolean PML_StartupEMS(global_game_variables_t *gvar) { int i; long size; - boolean errorflag; + byte str[160]; + byte err; - gvar->pm.emm.EMSPresent = false; // Assume that we'll fail + boolean errorflag=0; + static char emmname[] = "EMMXXXX0"; //fix by andrius4669 + unsigned int EMSVer = 0; + unsigned totalEMSpages,freeEMSpages,EMSPageFrame,EMSHandle,EMSAvail; + totalEMSpages = freeEMSpages = EMSPageFrame = 0; + EMSPresent = false; // Assume that we'll fail gvar->pm.emm.EMSAvail = 0; - errorflag=0; - _DX = (word)EMMDriverName; - _AX = 0x3d00; - geninterrupt(0x21); // try to open EMMXXXX0 device __asm { - jnc gothandle - mov errorflag,1 + mov dx,OFFSET emmname //fix by andrius4669 + mov ax,0x3d00 + int EMS_INT // try to open EMMXXXX0 device + jc error1 + + mov bx,ax + mov ax,0x4400 + + int EMS_INT // get device info + jc error1 + + and dx,0x80 + jz error1 + + mov ax,0x4407 + + int EMS_INT // get status + jc error1 + or al,al + jz error1 + + mov ah,0x3e + int EMS_INT // close handle + jc error1 + + mov ah,EMS_STATUS + int EMS_INT + jc error1 // make sure EMS hardware is present + + mov ah,EMS_VERSION + int EMS_INT // only work on EMS 3.2 or greater (silly, but...) + or ah,ah + jnz error1 + mov [EMSVer],ax // set EMSVer + cmp al,0x32 // only work on ems 3.2 or greater + jb error1 + + mov ah,EMS_GETFRAME + int EMS_INT // find the page frame address + or ah,ah + jnz error1 + mov [EMSPageFrame],bx + + mov ah,EMS_GETPAGES + int EMS_INT // find out how much EMS is there + or ah,ah + jnz error1 + or bx,bx + jz noEMS // no EMS at all to allocate + cmp bx,2 + jl noEMS // Require at least 2 pages (32k) + mov [totalEMSpages],dx + mov [freeEMSpages],bx + mov [EMSAvail],bx + jmp End1 #ifdef __BORLANDC__ } #endif - gothandle: -#ifdef __WATCOMC__ - } -#endif - if(errorflag) - goto error; - -//gothandle: - _BX = _AX; - _AX = 0x4400; - geninterrupt(0x21); // get device info + error1: +#ifdef __BORLANDC__ __asm { - jnc gotinfo +#endif + mov err,ah mov errorflag,1 + jmp End1 #ifdef __BORLANDC__ } #endif - gotinfo: +noEMS: +End1: #ifdef __WATCOMC__ } #endif - if(errorflag) - goto error; - -//gotinfo: -__asm and dx,0x80 - if (!_DX) - goto error; + if(errorflag==false) + { + // Don't hog all available EMS + size = gvar->pm.emm.EMSAvail * (long)EMSPageSize; + if (size - (EMSPageSize * 2) > (gvar->pm.fi.ChunksInFile * (long)PMPageSize)) + { + size = (gvar->pm.fi.ChunksInFile * (long)PMPageSize) + EMSPageSize; + gvar->pm.emm.EMSAvail = size / EMSPageSize; + } + } - _AX = 0x4407; - geninterrupt(0x21); // get status __asm { - jc error - jmp end - error: + mov ah,EMS_ALLOCPAGES + mov bx,[EMSAvail]; + int EMS_INT + or ah,ah + jnz error2 + mov [EMSHandle],dx + jmp End2 +#ifdef __BORLANDC__ + } +#endif + error2: +#ifdef __BORLANDC__ + __asm { +#endif + mov err,ah mov errorflag,1 + jmp End2 #ifdef __BORLANDC__ } #endif - end: +End2: #ifdef __WATCOMC__ } #endif - if (!_AL) - goto error; - _AH = 0x3e; - geninterrupt(0x21); // close handle - - _AH = EMS_STATUS; - geninterrupt(EMS_INT); - if (_AH) - goto error; // make sure EMS hardware is present - - _AH = EMS_VERSION; - geninterrupt(EMS_INT); - if (_AH || (_AL < 0x32)) // only work on EMS 3.2 or greater (silly, but...) - goto error; - - _AH = EMS_GETFRAME; - geninterrupt(EMS_INT); - if (_AH) - goto error; // find the page frame address - gvar->pm.emm.EMSPageFrame = _BX; - - _AH = EMS_GETPAGES; - geninterrupt(EMS_INT); - if (_AH) - goto error; - if (_BX < 2) - goto error; // Require at least 2 pages (32k) - gvar->pm.emm.EMSAvail = _BX; - - // Don't hog all available EMS - size = gvar->pm.emm.EMSAvail * (long)EMSPageSize; - if (size - (EMSPageSize * 2) > (gvar->pm.fi.ChunksInFile * (long)PMPageSize)) + if(errorflag==false) { - size = (gvar->pm.fi.ChunksInFile * (long)PMPageSize) + EMSPageSize; - gvar->pm.emm.EMSAvail = size / EMSPageSize; - } - - _AH = EMS_ALLOCPAGES; - _BX = gvar->pm.emm.EMSAvail; - geninterrupt(EMS_INT); - if (_AH) - goto error; - gvar->pm.emm.EMSHandle = _DX; - gvar->mmi.EMSmem += gvar->pm.emm.EMSAvail * (long)EMSPageSize; // Initialize EMS mapping cache for (i = 0;i < EMSFrameCount;i++) gvar->pm.emm.EMSList[i].baseEMSPage = -1; - gvar->pm.emm.EMSPresent = true; // We have EMS + } + else + { + strcpy(str,"PML_StartupEMS: EMS error "); + MM_EMSerr(str, err); + printf("%s\n",str); + return(EMSPresent); + } -error: - return(gvar->pm.emm.EMSPresent); + EMSPresent = true; // We have EMS + gvar->pm.emm.EMSPageFrame = EMSPageFrame; + gvar->pm.emm.EMSAvail = EMSAvail; + gvar->pm.emm.EMSVer = EMSVer; + gvar->pm.emm.EMSHandle = EMSHandle; + + return(EMSPresent); } // @@ -265,7 +298,7 @@ PML_ShutdownEMS(global_game_variables_t *gvar) word EMSHandle; EMSHandle=gvar->pm.emm.EMSHandle; - if (gvar->pm.emm.EMSPresent) + if (EMSPresent) { __asm { mov ah,EMS_FREEPAGES @@ -295,7 +328,7 @@ PML_ShutdownEMS(global_game_variables_t *gvar) boolean PML_StartupXMS(global_game_variables_t *gvar) { - gvar->pm.xmm.XMSPresent = false; // Assume failure + XMSPresent = false; // Assume failure gvar->pm.xmm.XMSAvail = 0; _AX=0x4300; @@ -332,9 +365,9 @@ PML_StartupXMS(global_game_variables_t *gvar) gvar->mmi.XMSmem += gvar->pm.xmm.XMSAvail * 1024; - gvar->pm.xmm.XMSPresent = true; + XMSPresent = true; error: - return(gvar->pm.xmm.XMSPresent); + return(XMSPresent); } // @@ -414,7 +447,7 @@ PML_CopyFromXMS(byte far *target,int sourcepage,word length, global_game_variabl void PML_ShutdownXMS(global_game_variables_t *gvar) { - if (gvar->pm.xmm.XMSPresent) + if (XMSPresent) { _DX = gvar->pm.xmm.XMSHandle; XMS_CALL(XMS_FREE); @@ -442,15 +475,26 @@ PM_SetMainMemPurge(int level, global_game_variables_t *gvar) { int i; + if(MainPresent) for (i = 0;i < PMMaxMainMem;i++) { #ifdef __DEBUG_PM__ printf("PM_SetMainMemPurge() info of gvar->pm.mm.MainMemPages[i]\n"); - printf(" %Fp, %Fp\n", gvar->pm.mm.MainMemPages[i], (gvar->pm.mm.MainMemPages[i])); + //printf(" %Fp, %Fp\n", gvar->pm.mm.MainMemPages[i], (gvar->pm.mm.MainMemPages[i])); printf("& %Fp, %Fp\n", &gvar->pm.mm.MainMemPages[i], &(gvar->pm.mm.MainMemPages[i])); + //MM_ShowMemory(gvar); + //MM_DumpData(gvar); + //MM_Report_(gvar); #endif if (gvar->pm.mm.MainMemPages[i]) - MM_SetPurge((gvar->pm.mm.MainMemPages[i]),level, gvar); + MM_SetPurge(&(gvar->pm.mm.MainMemPages[i]),level, gvar); + } + + else + { + printf("MainPresent IS NULL\n"); + printf("%x ", MainPresent); + exit(-4); } } @@ -476,7 +520,7 @@ PM_CheckMainMem(global_game_variables_t *gvar) PMBlockAttr *used; PageListStruct far *page; - if (!gvar->pm.mm.MainPresent) + if (!MainPresent) return; for (i = 0,page = gvar->pm.PMPages;i < gvar->pm.fi.ChunksInFile;i++,page++) @@ -543,7 +587,11 @@ PML_StartupMainMem(global_game_variables_t *gvar) memptr *p; gvar->pm.mm.MainPagesAvail = 0; + MainPresent = false; MM_BombOnError(false, gvar); + printf("PML_StartupMainMem()\n"); + printf(" p=%04x MainMemPages=%04x\n", p, gvar->pm.mm.MainMemPages); + printf(" p=%Fp MainMemPages=%Fp\n", p, gvar->pm.mm.MainMemPages); for (i = 0,p = gvar->pm.mm.MainMemPages;i < PMMaxMainMem;i++,p++) { MM_GetPtr(p,PMPageSize, gvar); @@ -561,7 +609,7 @@ PML_StartupMainMem(global_game_variables_t *gvar) Quit("PM_SetupMainMem: Not enough main memory"); //return; } - gvar->pm.mm.MainPresent = true; + MainPresent = true; } // @@ -853,7 +901,7 @@ PML_PutPageInXMS(int pagenum, global_game_variables_t *gvar) int usexms; PageListStruct far *page; - if (!gvar->pm.xmm.XMSPresent) + if (!XMSPresent) return; page = &gvar->pm.PMPages[pagenum]; @@ -982,7 +1030,7 @@ PML_GetPageFromXMS(int pagenum,boolean mainonly, global_game_variables_t *gvar) PageListStruct far *page; page = &gvar->pm.PMPages[pagenum]; - if (gvar->pm.xmm.XMSPresent && (page->xmsPage != -1)) + if (XMSPresent && (page->xmsPage != -1)) { gvar->pm.xmm.XMSProtectPage = pagenum; checkaddr = PML_GetAPageBuffer(pagenum,mainonly, gvar); @@ -1296,8 +1344,11 @@ PM_Startup(global_game_variables_t *gvar) boolean nomain,noems,noxms; int i; - if (gvar->pm.PMStarted) + if (PMStarted) + { + printf("pee\n"); return; + } strcat(&(gvar->pm.fi.PageFileName), "VSWAP."); @@ -1339,17 +1390,17 @@ PM_Startup(global_game_variables_t *gvar) if (!noxms) PML_StartupXMS(gvar); - if (nomain && !gvar->pm.emm.EMSPresent) + if (nomain && !EMSPresent) { Quit("PM_Startup: No main or EMS\n"); //return; } - else - PML_StartupMainMem(gvar); + printf("PML_StartupMainMem\n"); + PML_StartupMainMem(gvar); PM_Reset(gvar); - gvar->pm.PMStarted = true; + PMStarted = true; } // @@ -1361,7 +1412,7 @@ PM_Shutdown(global_game_variables_t *gvar) PML_ShutdownXMS(gvar); PML_ShutdownEMS(gvar); - if (!gvar->pm.PMStarted) + if (!PMStarted) return; PML_ClosePageFile(gvar); diff --git a/src/lib/16_pm.h b/src/lib/16_pm.h index a8510f17..2a9c368f 100755 --- a/src/lib/16_pm.h +++ b/src/lib/16_pm.h @@ -33,7 +33,9 @@ #include "src/lib/16_mm.h" #include -extern boolean pmdebug; +#ifdef __DEBUG__ +extern boolean debugpm; +#endif /*// NOTE! PMPageSize must be an even divisor of EMSPageSize, and >= 1024 #define EMSPageSize 16384 @@ -113,4 +115,5 @@ extern memptr PM_GetPageAddress(int pagenum, global_game_variables_t *gvar), PM_GetPage(int pagenum, global_game_variables_t *gvar); // Use this one to cache page void PM_SetMainMemPurge(int level, global_game_variables_t *gvar); +void PML_StartupMainMem(global_game_variables_t *gvar); #endif diff --git a/src/lib/typdefst.h b/src/lib/typdefst.h index d069b92f..b34d133d 100755 --- a/src/lib/typdefst.h +++ b/src/lib/typdefst.h @@ -155,6 +155,7 @@ typedef struct mmblockstruct typedef struct { dword nearheap,farheap,EMSmem,XMSmem,mainmem; +// boolean PMStarted, MainPresent, EMSPresent, XMSPresent; } mminfotype; typedef struct @@ -169,9 +170,9 @@ typedef struct #ifdef __WATCOMC__ void __near *nearheap; #endif - //byte EMS_status; + unsigned int EMSVer; word numUMBs,UMBbase[MAXUMBS]; - word totalEMSpages, freeEMSpages, EMSpagesmapped, EMShandle, EMSpageframe,EMSVer; + word totalEMSpages, freeEMSpages, EMSpagesmapped, EMSHandle, EMSPageFrame; //dword numUMBs,UMBbase[MAXUMBS]; //huge mmblocktype huge mmblocks[MAXBLOCKS],huge *mmhead,huge *mmfree,huge *mmrover,huge *mmnew; mmblocktype far mmblocks[MAXBLOCKS],far *mmhead,far *mmfree,far *mmrover,far *mmnew; @@ -235,7 +236,7 @@ typedef struct // Main Mem specific variables typedef struct { - boolean MainPresent; +// boolean MainPresent; memptr MainMemPages[PMMaxMainMem]; PMBlockAttr MainMemUsed[PMMaxMainMem]; int MainPagesAvail; @@ -244,9 +245,10 @@ typedef struct // EMS specific variables typedef struct { - boolean EMSPresent; +// boolean EMSPresent; + unsigned int EMSVer; word EMSAvail,EMSPagesAvail,EMSHandle, - EMSPageFrame,EMSPhysicalPage, EMSVer; + EMSPageFrame,EMSPhysicalPage; word totalEMSpages, freeEMSpages, EMSpagesmapped; EMSListStruct EMSList[EMSFrameCount]; } pm_emmi_t; @@ -254,7 +256,7 @@ typedef struct // XMS specific variables typedef struct { - boolean XMSPresent; +// boolean XMSPresent; word XMSAvail,XMSPagesAvail,XMSHandle; dword XMSDriver; //TODO: changed to word int XMSProtectPage;// = -1;