X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_mm.c;h=b338e5910e3515bfa8a6722429595e00109de6df;hb=5d57fb1ad5b8342b68eda18973c2f45d81481a2e;hp=42a87440485b974a3b11baf23fb91f8c5119db73;hpb=566d8b59f6381fcadb953dfc2d6771a1959365e1;p=16.git diff --git a/src/lib/16_mm.c b/src/lib/16_mm.c index 42a87440..b338e591 100755 --- a/src/lib/16_mm.c +++ b/src/lib/16_mm.c @@ -28,7 +28,7 @@ Primary coder: John Carmack RELIES ON --------- -Quit (char *error) function +Quit (global_game_variables_t *gvar, char *error) function WORK TO DO @@ -72,9 +72,9 @@ void (* XMSaddr) (void); // far pointer to XMS driver ============================================================================= */ - +#ifndef __16_PM__ static char *ParmStringsexmm[] = {"noems","noxms",""}; - +#endif /* ====================== = @@ -87,7 +87,7 @@ static char *ParmStringsexmm[] = {"noems","noxms",""}; boolean MML_CheckForEMS(void) { - boolean emmcfems; + boolean emmcfems=0; static char emmname[] = "EMMXXXX0"; //fix by andrius4669 __asm { mov dx,OFFSET emmname //fix by andrius4669 @@ -285,7 +285,7 @@ void MML_ShutdownEMS(global_game_variables_t *gvar) } #endif if(errorflag==true) - Quit("MML_ShutdownEMS: Error freeing EMS!\n"); //++++ add something + Quit (gvar, "MML_ShutdownEMS: Error freeing EMS!\n"); //++++ add something } /* @@ -563,7 +563,7 @@ void MML_ShutdownXMS(global_game_variables_t *gvar) /*void MML_UseSpace(word segstart, dword seglength, global_game_variables_t *gvar) { - //huge mmblocktype huge *scan,huge *last; + mmblocktype far *scan,far *last; word segm=1; word oldend; dword segmlen; @@ -716,8 +716,7 @@ void MML_UseSpace(word segstart, dword seglength, global_game_variables_t *gvar) void MML_ClearBlock(global_game_variables_t *gvar) { - //huge mmblocktype huge *scan,huge *last; - mmblocktype far *scan,far *last; + mmblocktype far *scan;//,far *last; scan = gvar->mm.mmhead->next; @@ -753,10 +752,8 @@ void MM_Startup(global_game_variables_t *gvar) int i; //dword length,seglength; dword length; word seglength; - //huge void huge *start; void far *start; word segstart;//,endfree; - //memptr *peeonself; if(gvar->mm.mmstarted) MM_Shutdown(gvar); @@ -770,9 +767,7 @@ void MM_Startup(global_game_variables_t *gvar) gvar->mm.mmhead = NULL; gvar->mm.mmfree = &(gvar->mm.mmblocks[0]); for(i=0;imm.mmblocks[i].next = &(gvar->mm.mmblocks[i+1]); - } gvar->mm.mmblocks[i].next = NULL; // @@ -784,23 +779,18 @@ void MM_Startup(global_game_variables_t *gvar) gvar->mm.mmnew->length = 0xffff; gvar->mm.mmnew->attributes = LOCKBIT; gvar->mm.mmnew->next = NULL; - //gvar->mm.mmnew->useptr = peeonself; gvar->mm.mmrover = gvar->mm.mmhead; - //printf(" %x\n", peeonself); - //printf(" %x\n", *peeonself); // // get all available near conventional memory segments // #ifdef __WATCOMC__ _nheapgrow(); length=(dword)_memavl();//(dword)GetFreeSize(); - //huge start = (void huge *)(gvar->mm.nearheap = _nmalloc(length)); start = (void far *)(gvar->mm.nearheap = _nmalloc(length)); #endif #ifdef __BORLANDC__ length=coreleft(); - //huge start = (void huge *)(gvar->mm.nearheap = malloc(length)); start = (void far *)(gvar->mm.nearheap = malloc(length)); #endif length -= 16-(FP_OFF(start)&15); @@ -936,7 +926,6 @@ void MM_Shutdown(global_game_variables_t *gvar) void MM_GetPtr (memptr *baseptr, dword size, global_game_variables_t *gvar) { - //huge mmblocktype huge *scan,huge *lastscan,huge *endscan,huge *purge,huge *next; mmblocktype far *scan,far *lastscan,far *endscan,far *purge,far *next; int search; unsigned needed,startseg; @@ -954,7 +943,7 @@ void MM_GetPtr (memptr *baseptr, dword size, global_game_variables_t *gvar) 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); } + //Quit(gvar, "gvar->mm.mmnew->useptr==NULL"); } gvar->mm.mmnew->attributes = BASEATTRIBUTES; //tryagain: @@ -1033,9 +1022,7 @@ void MM_GetPtr (memptr *baseptr, dword size, global_game_variables_t *gvar) //heapdump(); #endif printf(OUT_OF_MEM_MSG,(size-gvar->mmi.nearheap)); - printf("for stability reasons the program will shut down! wwww\n"); - MM_Shutdown(gvar); - exit(-1); + Quit(gvar, "for stability reasons the program will shut down! wwww\n"); } else gvar->mm.mmerror = true; @@ -1055,7 +1042,6 @@ void MM_GetPtr (memptr *baseptr, dword size, global_game_variables_t *gvar) void MM_FreePtr(memptr *baseptr, global_game_variables_t *gvar) { - //huge mmblocktype huge *scan,huge *last; mmblocktype far *scan,far *last; last = gvar->mm.mmhead; @@ -1095,7 +1081,6 @@ 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; mmblocktype far *start; start = gvar->mm.mmrover; @@ -1111,7 +1096,7 @@ 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!"); + Quit (gvar, "MM_SetPurge: Block not found!"); //return; } @@ -1135,7 +1120,6 @@ void MM_SetPurge(memptr *baseptr, int purge, global_game_variables_t *gvar) void MM_SetLock(memptr *baseptr, boolean locked, global_game_variables_t *gvar) { - //huge mmblocktype huge *start; mmblocktype far *start; start = gvar->mm.mmrover; @@ -1151,7 +1135,7 @@ void MM_SetLock(memptr *baseptr, boolean locked, global_game_variables_t *gvar) gvar->mm.mmrover = gvar->mm.mmhead; else if(gvar->mm.mmrover == start) { - Quit("MM_SetLock: Block not found!"); + Quit (gvar, "MM_SetLock: Block not found!"); //return; } @@ -1175,10 +1159,9 @@ void MM_SetLock(memptr *baseptr, boolean locked, global_game_variables_t *gvar) void MM_SortMem(global_game_variables_t *gvar) { - //huge mmblocktype huge *scan,huge *last,huge *next; mmblocktype far *scan,far *last,far *next; - unsigned start,length,source,dest,oldborder; - int playing; + unsigned start,length,source,dest;//++++,oldborder; + //++++int playing; // // lock down a currently playing sound @@ -1286,20 +1269,19 @@ void MM_SortMem(global_game_variables_t *gvar) void MM_ShowMemory(global_game_variables_t *gvar) { - //huge mmblocktype huge *scan; mmblocktype far *scan; - word temp; + //word temp; sdword end,owner; //word chx,chy; word w; //dword wwww; - byte scratch[160],scratch0[4096],scratch1[160],str[16]; + byte scratch[160],scratch0[4096],str[16];//[[[[scratch1[160], //byte d = '#'; -//**** VW_SetDefaultColors(); -//**** VW_SetLineWidth(40); +//[[[[ VW_SetDefaultColors(); +//[[[[ VW_SetLineWidth(40); //++++mh temp = bufferofs; //++++mh bufferofs = 0; -//**** VW_SetScreen (0,0); +//[[[[ VW_SetScreen (0,0); scan = gvar->mm.mmhead; end = -1; @@ -1449,7 +1431,6 @@ void MM_ShowMemory(global_game_variables_t *gvar) void MM_DumpData(global_game_variables_t *gvar) { - //huge mmblocktype huge *scan,huge *best; mmblocktype far *scan,far *best; long lowest,oldlowest; word owner; @@ -1524,7 +1505,6 @@ void MM_DumpData(global_game_variables_t *gvar) dword MM_UnusedMemory(global_game_variables_t *gvar) { dword free; - //huge mmblocktype huge *scan; mmblocktype far *scan; free = 0; @@ -1556,7 +1536,6 @@ dword MM_UnusedMemory(global_game_variables_t *gvar) dword MM_TotalFree(global_game_variables_t *gvar) { dword free; - //huge mmblocktype huge *scan; mmblocktype far *scan; free = 0;