-\e[0mSeg:0 Size:3547 Owner:0x696c\r
+\e[0mSeg:0 Size:3552 Owner:0x6974\r
\e[41;31m+++++++++++++++++++++++++++++++++++++++++++++\e[0m\e[42;32m0\r
-\e[0m\e[0mSeg:ddb Size:256 Owner:0xcf85\r
-\e[44;34m++++\e[0m\e[42;32m\r
-\e[0m\e[0mSeg:edb Size:273 Owner:0xfde\r
-\e[44;34m++++\e[0m\e[42;32m0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r
+\e[0m\e[0mSeg:de0 Size:256 Owner:0xcf79\r
+\e[44;34m++++\e[0m\e[42;32m0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r
\e[0m\e[0mSeg:9fde Size:28706 Owner:0x0\r
\e[41;31m\e[0m\e[42;32m\r
\e[0m\e[0mSeg:9ffe Size:24577 Owner:0x0\r
-\e[0mSeg:0 Size:8575 Owner:0x0\r
-\e[41;31m++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\e[0m\e[42;32m0\r
-\e[0m\e[0mSeg:217f Size:256 Owner:0x5438\r
+\e[0mSeg:0 Size:8558 Owner:0x1\r
+\e[41;31m+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\e[0m\e[42;32m0\r
+\e[0m\e[0mSeg:216e Size:256 Owner:0x5448\r
+\e[44;34m+++++\e[0m\e[42;32m\r
+\e[0m\e[0mSeg:226e Size:273 Owner:0x94a0\r
\e[44;34m++++\e[0m\e[42;32m\r
-\e[0m\e[0mSeg:227f Size:273 Owner:0x9490\r
-\e[44;34m++++\e[0m\e[42;32m\r
-\e[0m\e[0mSeg:27f2 Size:44 Owner:0x0\r
+\e[0m\e[0mSeg:27e0 Size:44 Owner:0x0\r
\e[41;31m++\e[0m\e[42;32m0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r
-\e[0m\e[0mSeg:b81e Size:10210 Owner:0x0\r
-\e[41;31m++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\e[0m\e[42;32m\r
+\e[0m\e[0mSeg:b80c Size:10228 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
\r
== default ==\r
\r
- USED block at 28140016 of size 66\r
- USED block at 28140058 of size 66\r
- FREE block at 2814009a of size 18\r
- USED block at 281400ac of size 136\r
- USED block at 28140134 of size 20\r
- FREE block at 28140148 of size 7860\r
+ USED block at 28020016 of size 66\r
+ USED block at 28020058 of size 66\r
+ FREE block at 2802009a of size 18\r
+ USED block at 280200ac of size 136\r
+ USED block at 28020134 of size 20\r
+ FREE block at 28020148 of size 7860\r
OK - end of heap\r
\r
== near ==\r
\r
- USED block at 181394c6 of size 12\r
- USED block at 181394d2 of size 332\r
- USED block at 1813961e of size 52\r
- USED block at 18139652 of size 20\r
- USED block at 18139666 of size 20\r
- USED block at 1813967a of size 20\r
- USED block at 1813968e of size 20\r
- USED block at 181396a2 of size 20\r
- USED block at 181396b6 of size 26950\r
+ USED block at 180194d6 of size 12\r
+ USED block at 180194e2 of size 332\r
+ USED block at 1801962e of size 52\r
+ USED block at 18019662 of size 20\r
+ USED block at 18019676 of size 20\r
+ USED block at 1801968a of size 20\r
+ USED block at 1801969e of size 20\r
+ USED block at 180196b2 of size 20\r
+ USED block at 180196c6 of size 26934\r
OK - end of heap\r
\r
== far ==\r
\r
- USED block at 28140016 of size 66\r
- USED block at 28140058 of size 66\r
- USED block at 2814009a of size 18\r
- USED block at 281400ac of size 136\r
- USED block at 28140134 of size 20\r
- USED block at 28140148 of size 7860\r
+ USED block at 28020016 of size 66\r
+ USED block at 28020058 of size 66\r
+ USED block at 2802009a of size 18\r
+ USED block at 280200ac of size 136\r
+ USED block at 28020134 of size 20\r
+ USED block at 28020148 of size 7860\r
OK - end of heap\r
\r
Memory Type Total Used Free\r
---------------- -------- -------- --------\r
Default 8166 288 7878\r
-Near 27446 496 26950\r
+Near 27430 496 26934\r
Far 8166 288 7878\r
---------------- -------- -------- --------\r
-coreleft = 26948\r
-farcoreleft = 51056\r
+coreleft = 26932\r
+farcoreleft = 51040\r
GetFreeSize = 24128\r
-GetNearFreeSize = 26950\r
+GetNearFreeSize = 26934\r
GetFarFreeSize = 24128\r
-memavl = 26948\r
+memavl = 26932\r
stackavail = 11268\r
//file name //\r
\r
gvar.mm.mmstarted=0;\r
- pmdebug=0;\r
+ debugpm=0;\r
\r
//PRINTBB\r
if(argv[1]){ bakapee1 = argv[1];\r
}\r
//printf("main()=%Fp start MM\n", *argv[0]);\r
MM_Startup(&gvar);\r
- if(pmdebug>0)\r
+ if(debugpm>0)\r
{\r
PM_Startup(&gvar);\r
- PM_CheckMainMem(&gvar);\r
+ //PM_CheckMainMem(&gvar);\r
PM_UnlockMainMem(&gvar);\r
}\r
CA_Startup(&gvar);\r
printf("bakapee1=%s\n", bakapee1);\r
printf("bakapee2=%s\n", bakapee2);\r
MM_FreePtr(&bigbuffer, &gvar);\r
- if(pmdebug>0)\r
+ if(debugpm>0)\r
PM_Shutdown(&gvar);\r
CA_Shutdown(&gvar);\r
MM_Shutdown(&gvar);\r
extern int profilehandle,debughandle; //make it into game global\r
\r
#define __DEBUG__\r
-//0000#define __DEBUG_PM__\r
+#define __DEBUG_PM__\r
+//#define __DEBUG_MM__\r
\r
#define nil ((void *)0)\r
#ifdef __BORLANDC__\r
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
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
int EMS_INT
or ah,ah
jnz error
- mov [EMShandle],dx
+ mov [EMSHandle],dx
jmp End
#ifdef __BORLANDC__
}
}
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;
}
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
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++)
{
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
//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;
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
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
//
{
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
{
MML_SetupXMS(gvar); // allocate as many UMBs as possible
}
+#ifdef __DEBUG__
}
+#endif
//
// allocate the misc buffer
//
#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
}
//==========================================================================
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;
=====================
*/
+
void MM_SetPurge(memptr *baseptr, int purge, global_game_variables_t *gvar)
{
//huge mmblocktype huge *start;
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))
{
#include "src/lib/16_hc.h"\r
#include "src/lib/16_lib.h"\r
//++++mh #include "src/lib/16_in.h"\r
-extern boolean pmdebug;\r
-\r
\r
#ifdef __DEBUG__ // 1 == Debug/Dev ; 0 == Production/final\r
#define OUT_OF_MEM_MSG "MM_GetPtr: Out of memory!\nYou were short :%lu bytes\n"\r
+extern boolean debugpm;\r
#else\r
#define OUT_OF_MEM_MSG "\npee\n"\r
#endif\r
\r
extern void (* beforesort) (void);\r
extern void (* aftersort) (void);\r
-extern void (* XMSaddr) (void); // far pointer to XMS driver\r
+extern void (* XMSaddr) (void); // far pointer to XMS driver\r
\r
//==========================================================================\r
\r
#include "src/lib/16_pm.h"\r
#pragma hdrstop\r
\r
-boolean pmdebug=0;\r
+#ifdef __DEBUG__\r
+boolean debugpm=0;\r
+#endif\r
\r
-/*\r
// Main Mem specific variables\r
- boolean MainPresent;\r
+/* boolean MainPresent;\r
memptr MainMemPages[PMMaxMainMem];\r
PMBlockAttr gvar->pm.mm.MainMemUsed[PMMaxMainMem];\r
int gvar->pm.mm.MainPagesAvail;\r
\r
// EMS specific variables\r
- boolean gvar->pm.emm.EMSPresent;\r
+ boolean EMSPresent;\r
word gvar->pm.emm.EMSAvail,gvar->pm.emm.EMSPagesAvail,gvar->pm.emm.EMSHandle,\r
gvar->pm.emm.EMSPageFrame,gvar->pm.emm.EMSPhysicalPage;\r
gvar->pm.emm.EMSListStruct gvar->pm.emm.EMSList[EMSFrameCount];\r
\r
// XMS specific variables\r
- boolean gvar->pm.xmm.XMSPresent;\r
+ boolean XMSPresent;\r
word gvar->pm.xmm.XMSAvail,gvar->pm.xmm.XMSPagesAvail,gvar->pm.xmm.XMSHandle;*/\r
word XMSDriver;\r
/* int gvar->pm.xmm.XMSProtectPage = -1;\r
PageListStruct far *gvar->pm.PMPages,\r
_seg *gvar->pm.PMSegPages;\r
*/\r
+boolean PMStarted, MainPresent, EMSPresent, XMSPresent;\r
static char *ParmStrings[] = {"nomain","noems","noxms",nil};\r
\r
/////////////////////////////////////////////////////////////////////////////\r
// to the maximum we need)\r
//\r
\r
- char EMMDriverName[9] = "EMMXXXX0";\r
-\r
boolean\r
PML_StartupEMS(global_game_variables_t *gvar)\r
{\r
int i;\r
long size;\r
- boolean errorflag;\r
+ byte str[160];\r
+ byte err;\r
\r
- gvar->pm.emm.EMSPresent = false; // Assume that we'll fail\r
+ boolean errorflag=0;\r
+ static char emmname[] = "EMMXXXX0"; //fix by andrius4669\r
+ unsigned int EMSVer = 0;\r
+ unsigned totalEMSpages,freeEMSpages,EMSPageFrame,EMSHandle,EMSAvail;\r
+ totalEMSpages = freeEMSpages = EMSPageFrame = 0;\r
+ EMSPresent = false; // Assume that we'll fail\r
gvar->pm.emm.EMSAvail = 0;\r
- errorflag=0;\r
\r
- _DX = (word)EMMDriverName;\r
- _AX = 0x3d00;\r
- geninterrupt(0x21); // try to open EMMXXXX0 device\r
__asm {\r
- jnc gothandle\r
- mov errorflag,1\r
+ mov dx,OFFSET emmname //fix by andrius4669\r
+ mov ax,0x3d00\r
+ int EMS_INT // try to open EMMXXXX0 device\r
+ jc error1\r
+\r
+ mov bx,ax\r
+ mov ax,0x4400\r
+\r
+ int EMS_INT // get device info\r
+ jc error1\r
+\r
+ and dx,0x80\r
+ jz error1\r
+\r
+ mov ax,0x4407\r
+\r
+ int EMS_INT // get status\r
+ jc error1\r
+ or al,al\r
+ jz error1\r
+\r
+ mov ah,0x3e\r
+ int EMS_INT // close handle\r
+ jc error1\r
+\r
+ mov ah,EMS_STATUS\r
+ int EMS_INT\r
+ jc error1 // make sure EMS hardware is present\r
+\r
+ mov ah,EMS_VERSION\r
+ int EMS_INT // only work on EMS 3.2 or greater (silly, but...)\r
+ or ah,ah\r
+ jnz error1\r
+ mov [EMSVer],ax // set EMSVer\r
+ cmp al,0x32 // only work on ems 3.2 or greater\r
+ jb error1\r
+\r
+ mov ah,EMS_GETFRAME\r
+ int EMS_INT // find the page frame address\r
+ or ah,ah\r
+ jnz error1\r
+ mov [EMSPageFrame],bx\r
+\r
+ mov ah,EMS_GETPAGES\r
+ int EMS_INT // find out how much EMS is there\r
+ or ah,ah\r
+ jnz error1\r
+ or bx,bx\r
+ jz noEMS // no EMS at all to allocate\r
+ cmp bx,2\r
+ jl noEMS // Require at least 2 pages (32k)\r
+ mov [totalEMSpages],dx\r
+ mov [freeEMSpages],bx\r
+ mov [EMSAvail],bx\r
+ jmp End1\r
#ifdef __BORLANDC__\r
}\r
#endif\r
- gothandle:\r
-#ifdef __WATCOMC__\r
- }\r
-#endif\r
- if(errorflag)\r
- goto error;\r
-\r
-//gothandle:\r
- _BX = _AX;\r
- _AX = 0x4400;\r
- geninterrupt(0x21); // get device info\r
+ error1:\r
+#ifdef __BORLANDC__\r
__asm {\r
- jnc gotinfo\r
+#endif\r
+ mov err,ah\r
mov errorflag,1\r
+ jmp End1\r
#ifdef __BORLANDC__\r
}\r
#endif\r
- gotinfo:\r
+noEMS:\r
+End1:\r
#ifdef __WATCOMC__\r
}\r
#endif\r
- if(errorflag)\r
- goto error;\r
-\r
-//gotinfo:\r
-__asm and dx,0x80\r
- if (!_DX)\r
- goto error;\r
+ if(errorflag==false)\r
+ {\r
+ // Don't hog all available EMS\r
+ size = gvar->pm.emm.EMSAvail * (long)EMSPageSize;\r
+ if (size - (EMSPageSize * 2) > (gvar->pm.fi.ChunksInFile * (long)PMPageSize))\r
+ {\r
+ size = (gvar->pm.fi.ChunksInFile * (long)PMPageSize) + EMSPageSize;\r
+ gvar->pm.emm.EMSAvail = size / EMSPageSize;\r
+ }\r
+ }\r
\r
- _AX = 0x4407;\r
- geninterrupt(0x21); // get status\r
__asm {\r
- jc error\r
- jmp end\r
- error:\r
+ mov ah,EMS_ALLOCPAGES\r
+ mov bx,[EMSAvail];\r
+ int EMS_INT\r
+ or ah,ah\r
+ jnz error2\r
+ mov [EMSHandle],dx\r
+ jmp End2\r
+#ifdef __BORLANDC__\r
+ }\r
+#endif\r
+ error2:\r
+#ifdef __BORLANDC__\r
+ __asm {\r
+#endif\r
+ mov err,ah\r
mov errorflag,1\r
+ jmp End2\r
#ifdef __BORLANDC__\r
}\r
#endif\r
- end:\r
+End2:\r
#ifdef __WATCOMC__\r
}\r
#endif\r
- if (!_AL)\r
- goto error;\r
\r
- _AH = 0x3e;\r
- geninterrupt(0x21); // close handle\r
-\r
- _AH = EMS_STATUS;\r
- geninterrupt(EMS_INT);\r
- if (_AH)\r
- goto error; // make sure EMS hardware is present\r
-\r
- _AH = EMS_VERSION;\r
- geninterrupt(EMS_INT);\r
- if (_AH || (_AL < 0x32)) // only work on EMS 3.2 or greater (silly, but...)\r
- goto error;\r
-\r
- _AH = EMS_GETFRAME;\r
- geninterrupt(EMS_INT);\r
- if (_AH)\r
- goto error; // find the page frame address\r
- gvar->pm.emm.EMSPageFrame = _BX;\r
-\r
- _AH = EMS_GETPAGES;\r
- geninterrupt(EMS_INT);\r
- if (_AH)\r
- goto error;\r
- if (_BX < 2)\r
- goto error; // Require at least 2 pages (32k)\r
- gvar->pm.emm.EMSAvail = _BX;\r
-\r
- // Don't hog all available EMS\r
- size = gvar->pm.emm.EMSAvail * (long)EMSPageSize;\r
- if (size - (EMSPageSize * 2) > (gvar->pm.fi.ChunksInFile * (long)PMPageSize))\r
+ if(errorflag==false)\r
{\r
- size = (gvar->pm.fi.ChunksInFile * (long)PMPageSize) + EMSPageSize;\r
- gvar->pm.emm.EMSAvail = size / EMSPageSize;\r
- }\r
-\r
- _AH = EMS_ALLOCPAGES;\r
- _BX = gvar->pm.emm.EMSAvail;\r
- geninterrupt(EMS_INT);\r
- if (_AH)\r
- goto error;\r
- gvar->pm.emm.EMSHandle = _DX;\r
-\r
gvar->mmi.EMSmem += gvar->pm.emm.EMSAvail * (long)EMSPageSize;\r
\r
// Initialize EMS mapping cache\r
for (i = 0;i < EMSFrameCount;i++)\r
gvar->pm.emm.EMSList[i].baseEMSPage = -1;\r
\r
- gvar->pm.emm.EMSPresent = true; // We have EMS\r
+ }\r
+ else\r
+ {\r
+ strcpy(str,"PML_StartupEMS: EMS error ");\r
+ MM_EMSerr(str, err);\r
+ printf("%s\n",str);\r
+ return(EMSPresent);\r
+ }\r
\r
-error:\r
- return(gvar->pm.emm.EMSPresent);\r
+ EMSPresent = true; // We have EMS\r
+ gvar->pm.emm.EMSPageFrame = EMSPageFrame;\r
+ gvar->pm.emm.EMSAvail = EMSAvail;\r
+ gvar->pm.emm.EMSVer = EMSVer;\r
+ gvar->pm.emm.EMSHandle = EMSHandle;\r
+\r
+ return(EMSPresent);\r
}\r
\r
//\r
word EMSHandle;\r
EMSHandle=gvar->pm.emm.EMSHandle;\r
\r
- if (gvar->pm.emm.EMSPresent)\r
+ if (EMSPresent)\r
{\r
__asm {\r
mov ah,EMS_FREEPAGES\r
boolean\r
PML_StartupXMS(global_game_variables_t *gvar)\r
{\r
- gvar->pm.xmm.XMSPresent = false; // Assume failure\r
+ XMSPresent = false; // Assume failure\r
gvar->pm.xmm.XMSAvail = 0;\r
\r
_AX=0x4300;\r
\r
gvar->mmi.XMSmem += gvar->pm.xmm.XMSAvail * 1024;\r
\r
- gvar->pm.xmm.XMSPresent = true;\r
+ XMSPresent = true;\r
error:\r
- return(gvar->pm.xmm.XMSPresent);\r
+ return(XMSPresent);\r
}\r
\r
//\r
void\r
PML_ShutdownXMS(global_game_variables_t *gvar)\r
{\r
- if (gvar->pm.xmm.XMSPresent)\r
+ if (XMSPresent)\r
{\r
_DX = gvar->pm.xmm.XMSHandle;\r
XMS_CALL(XMS_FREE);\r
{\r
int i;\r
\r
+ if(MainPresent)\r
for (i = 0;i < PMMaxMainMem;i++)\r
{\r
#ifdef __DEBUG_PM__\r
printf("PM_SetMainMemPurge() info of gvar->pm.mm.MainMemPages[i]\n");\r
- printf(" %Fp, %Fp\n", gvar->pm.mm.MainMemPages[i], (gvar->pm.mm.MainMemPages[i]));\r
+ //printf(" %Fp, %Fp\n", gvar->pm.mm.MainMemPages[i], (gvar->pm.mm.MainMemPages[i]));\r
printf("& %Fp, %Fp\n", &gvar->pm.mm.MainMemPages[i], &(gvar->pm.mm.MainMemPages[i]));\r
+ //MM_ShowMemory(gvar);\r
+ //MM_DumpData(gvar);\r
+ //MM_Report_(gvar);\r
#endif\r
if (gvar->pm.mm.MainMemPages[i])\r
- MM_SetPurge((gvar->pm.mm.MainMemPages[i]),level, gvar);\r
+ MM_SetPurge(&(gvar->pm.mm.MainMemPages[i]),level, gvar);\r
+ }\r
+\r
+ else\r
+ {\r
+ printf("MainPresent IS NULL\n");\r
+ printf("%x ", MainPresent);\r
+ exit(-4);\r
}\r
}\r
\r
PMBlockAttr *used;\r
PageListStruct far *page;\r
\r
- if (!gvar->pm.mm.MainPresent)\r
+ if (!MainPresent)\r
return;\r
\r
for (i = 0,page = gvar->pm.PMPages;i < gvar->pm.fi.ChunksInFile;i++,page++)\r
memptr *p;\r
\r
gvar->pm.mm.MainPagesAvail = 0;\r
+ MainPresent = false;\r
MM_BombOnError(false, gvar);\r
+ printf("PML_StartupMainMem()\n");\r
+ printf(" p=%04x MainMemPages=%04x\n", p, gvar->pm.mm.MainMemPages);\r
+ printf(" p=%Fp MainMemPages=%Fp\n", p, gvar->pm.mm.MainMemPages);\r
for (i = 0,p = gvar->pm.mm.MainMemPages;i < PMMaxMainMem;i++,p++)\r
{\r
MM_GetPtr(p,PMPageSize, gvar);\r
Quit("PM_SetupMainMem: Not enough main memory");\r
//return;\r
}\r
- gvar->pm.mm.MainPresent = true;\r
+ MainPresent = true;\r
}\r
\r
//\r
int usexms;\r
PageListStruct far *page;\r
\r
- if (!gvar->pm.xmm.XMSPresent)\r
+ if (!XMSPresent)\r
return;\r
\r
page = &gvar->pm.PMPages[pagenum];\r
PageListStruct far *page;\r
\r
page = &gvar->pm.PMPages[pagenum];\r
- if (gvar->pm.xmm.XMSPresent && (page->xmsPage != -1))\r
+ if (XMSPresent && (page->xmsPage != -1))\r
{\r
gvar->pm.xmm.XMSProtectPage = pagenum;\r
checkaddr = PML_GetAPageBuffer(pagenum,mainonly, gvar);\r
boolean nomain,noems,noxms;\r
int i;\r
\r
- if (gvar->pm.PMStarted)\r
+ if (PMStarted)\r
+ {\r
+ printf("pee\n");\r
return;\r
+ }\r
\r
strcat(&(gvar->pm.fi.PageFileName), "VSWAP.");\r
\r
if (!noxms)\r
PML_StartupXMS(gvar);\r
\r
- if (nomain && !gvar->pm.emm.EMSPresent)\r
+ if (nomain && !EMSPresent)\r
{\r
Quit("PM_Startup: No main or EMS\n");\r
//return;\r
}\r
- else\r
- PML_StartupMainMem(gvar);\r
+ printf("PML_StartupMainMem\n");\r
+ PML_StartupMainMem(gvar);\r
\r
PM_Reset(gvar);\r
\r
- gvar->pm.PMStarted = true;\r
+ PMStarted = true;\r
}\r
\r
//\r
PML_ShutdownXMS(gvar);\r
PML_ShutdownEMS(gvar);\r
\r
- if (!gvar->pm.PMStarted)\r
+ if (!PMStarted)\r
return;\r
\r
PML_ClosePageFile(gvar);\r
#include "src/lib/16_mm.h"\r
#include <dos.h>\r
\r
-extern boolean pmdebug;\r
+#ifdef __DEBUG__\r
+extern boolean debugpm;\r
+#endif\r
\r
/*// NOTE! PMPageSize must be an even divisor of EMSPageSize, and >= 1024\r
#define EMSPageSize 16384\r
PM_GetPage(int pagenum, global_game_variables_t *gvar); // Use this one to cache page\r
\r
void PM_SetMainMemPurge(int level, global_game_variables_t *gvar);\r
+void PML_StartupMainMem(global_game_variables_t *gvar);\r
#endif\r
typedef struct\r
{\r
dword nearheap,farheap,EMSmem,XMSmem,mainmem;\r
+// boolean PMStarted, MainPresent, EMSPresent, XMSPresent;\r
} mminfotype;\r
\r
typedef struct\r
#ifdef __WATCOMC__\r
void __near *nearheap;\r
#endif\r
- //byte EMS_status;\r
+ unsigned int EMSVer;\r
word numUMBs,UMBbase[MAXUMBS];\r
- word totalEMSpages, freeEMSpages, EMSpagesmapped, EMShandle, EMSpageframe,EMSVer;\r
+ word totalEMSpages, freeEMSpages, EMSpagesmapped, EMSHandle, EMSPageFrame;\r
//dword numUMBs,UMBbase[MAXUMBS];\r
//huge mmblocktype huge mmblocks[MAXBLOCKS],huge *mmhead,huge *mmfree,huge *mmrover,huge *mmnew;\r
mmblocktype far mmblocks[MAXBLOCKS],far *mmhead,far *mmfree,far *mmrover,far *mmnew;\r
// Main Mem specific variables\r
typedef struct\r
{\r
- boolean MainPresent;\r
+// boolean MainPresent;\r
memptr MainMemPages[PMMaxMainMem];\r
PMBlockAttr MainMemUsed[PMMaxMainMem];\r
int MainPagesAvail;\r
// EMS specific variables\r
typedef struct\r
{\r
- boolean EMSPresent;\r
+// boolean EMSPresent;\r
+ unsigned int EMSVer;\r
word EMSAvail,EMSPagesAvail,EMSHandle,\r
- EMSPageFrame,EMSPhysicalPage, EMSVer;\r
+ EMSPageFrame,EMSPhysicalPage;\r
word totalEMSpages, freeEMSpages, EMSpagesmapped;\r
EMSListStruct EMSList[EMSFrameCount];\r
} pm_emmi_t;\r
// XMS specific variables\r
typedef struct\r
{\r
- boolean XMSPresent;\r
+// boolean XMSPresent;\r
word XMSAvail,XMSPagesAvail,XMSHandle;\r
dword XMSDriver; //TODO: changed to word\r
int XMSProtectPage;// = -1;\r