#pragma warn -pro\r
#pragma warn -use\r
\r
+\r
+/*\r
+=============================================================================\r
+\r
+ LOCAL INFO\r
+\r
+=============================================================================\r
+*/\r
+\r
+//#define LOCKBIT 0x80 // if set in attributes, block cannot be moved\r
+//#define PURGEBITS 3 // 0-3 level, 0= unpurgable, 3= purge first\r
+//#define PURGEMASK 0xfffc\r
+//#define BASEATTRIBUTES 0 // unlocked, non purgable\r
+\r
+//#define MAXUMBS 10\r
+\r
+/*typedef struct mmblockstruct\r
+{\r
+ unsigned start,length;\r
+ unsigned attributes;\r
+ memptr *useptr; // pointer to the segment start\r
+ struct mmblockstruct far *next;\r
+} mmblocktype;*/\r
+\r
+\r
+//#define GETNEWBLOCK {if(!(mmnew=mmfree))Quit("MM_GETNEWBLOCK: No free blocks!") ;mmfree=mmfree->next;}\r
+//\r
+\r
+//#define GETNEWBLOCK {if(!gvar->mm.mmfree)MML_ClearBlock(gvar);gvar->mm.mmnew=gvar->mm.mmfree;gvar->mm.mmfree=gvar->mm.mmfree->next;}\r
+\r
+//#define FREEBLOCK(x) {*x->useptr=NULL;x->next=gvar->mm.mmfree;gvar->mm.mmfree=x;}\r
+\r
/*\r
=============================================================================\r
\r
=============================================================================\r
*/\r
\r
+/*mminfotype mminfo;\r
+memptr bufferseg;\r
+boolean mmerror;*/\r
+\r
void (* beforesort) (void);\r
void (* aftersort) (void);\r
-void (* XMSaddr) (void); // far pointer to XMS driver\r
\r
/*\r
=============================================================================\r
\r
=============================================================================\r
*/\r
+\r
+/*boolean mmstarted;\r
+\r
+void far *farheap;\r
+void *nearheap;\r
+\r
+mmblocktype far mmblocks[MAXBLOCKS]\r
+ ,far *mmhead,far *mmfree,far *mmrover,far *mmnew;\r
+\r
+boolean bombonerror;*/\r
+\r
+//unsigned totalEMSpages,freeEMSpages,EMSpageframe,EMSpagesmapped,EMShandle;\r
+\r
+void (* XMSaddr) (void); // far pointer to XMS driver\r
+\r
+/*unsigned numUMBs,UMBbase[MAXUMBS];*/\r
+\r
+//==========================================================================\r
+\r
+//\r
+// local prototypes\r
+//\r
+\r
+boolean MML_CheckForEMS (void);\r
+void MML_ShutdownEMS (void);\r
+void MM_MapEMS (void);\r
+boolean MML_CheckForXMS (void);\r
+void MML_ShutdownXMS (void);\r
+//void MML_UseSpace (unsigned segstart, unsigned seglength);\r
+//void MML_ClearBlock (void);\r
+\r
+//==========================================================================\r
#ifndef __16_PM__\r
#if 0\r
static char *ParmStringsexmm[] = {"noems","noxms",""};\r
}\r
//++++todo: linked list of segment!\r
*/\r
-void MML_UseSpace (word segstart, dword seglength, global_game_variables_t *gvar)\r
+void MML_UseSpace (word segstart, word seglength, global_game_variables_t *gvar)\r
{\r
mmblocktype far *scan,far *last;\r
word oldend;\r
// take the given range out of the block\r
//\r
oldend = scan->start + scan->length;\r
- extra = oldend - (segstart+((unsigned)seglength));\r
+ extra = oldend - (segstart+seglength);\r
if (extra < 0)\r
+#ifdef __DEBUG_MM__\r
{\r
printf("========================================\n");\r
printf("start=%x ", scan->start);\r
printf("========================================\n");\r
//return;\r
}\r
+#else\r
+ Quit ("MML_UseSpace: Segment spans two blocks!");\r
+#endif\r
\r
if (segstart == scan->start)\r
{\r
====================\r
*/\r
\r
-void MML_ClearBlock(global_game_variables_t *gvar)\r
+void MML_ClearBlock (global_game_variables_t *gvar)\r
{\r
mmblocktype far *scan;//,far *last;\r
\r
scan = scan->next;\r
}\r
\r
- printf("MM_ClearBlock: No purgable blocks!\n");\r
+ Quit (gvar, "MM_ClearBlock: No purgable blocks!\n");\r
}\r
\r
\r
void MM_Startup (global_game_variables_t *gvar)\r
{\r
int i;\r
- //dword length,seglength;\r
- dword length; word seglength;\r
+ dword length;\r
void far *start;\r
- word segstart;//,endfree;\r
+ word segstart,seglength;//,endfree;\r
\r
if(gvar->mm.mmstarted)\r
- MM_Shutdown(gvar);\r
+ MM_Shutdown (gvar);\r
\r
gvar->mm.mmstarted = true;\r
gvar->mm.bombonerror = true;\r
//\r
gvar->mm.mmhead = NULL;\r
gvar->mm.mmfree = &(gvar->mm.mmblocks[0]);\r
- for(i=0;i<MAXBLOCKS-1;i++)\r
+ for (i=0;i<MAXBLOCKS-1;i++)\r
gvar->mm.mmblocks[i].next = &(gvar->mm.mmblocks[i+1]);\r
gvar->mm.mmblocks[i].next = NULL;\r
\r
gvar->mm.mmnew->next = NULL;\r
gvar->mm.mmrover = gvar->mm.mmhead;\r
\r
+\r
//\r
// get all available near conventional memory segments\r
//\r
//\r
gvar->mm.mmrover = gvar->mm.mmhead; // start looking for space after low block\r
\r
- MM_GetPtr(&(gvar->mm.bufferseg),BUFFERSIZE, gvar);\r
+ MM_GetPtr (&(gvar->mm.bufferseg),BUFFERSIZE, gvar);\r
}\r
\r
//==========================================================================\r
====================\r
*/\r
\r
-void MM_GetPtr (memptr *baseptr, dword size, global_game_variables_t *gvar)\r
+void MM_GetPtr (memptr *baseptr,dword size, global_game_variables_t *gvar)\r
{\r
mmblocktype far *scan,far *lastscan,far *endscan\r
- ,far *purge,far *next;\r
+ ,far *purge,far *next;\r
int search;\r
unsigned needed,startseg;\r
\r
GETNEWBLOCK; // fill in start and next after a spot is found\r
gvar->mm.mmnew->length = needed;\r
gvar->mm.mmnew->useptr = baseptr;\r
+ gvar->mm.mmnew->attributes = BASEATTRIBUTES;\r
//if(gvar->mm.mmnew->useptr==NULL){\r
#ifdef __DEBUG_MM__\r
printf("MM_GetPtr\n");\r
printf(" size is %lu\n", size);\r
#endif\r
//Quit(gvar, "gvar->mm.mmnew->useptr==NULL"); }\r
- gvar->mm.mmnew->attributes = BASEATTRIBUTES;\r
\r
//tryagain:\r
for (search = 0; search<3; search++)\r