X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_mm.c;h=7cf59d3dfa3033db30a596e6c627ce33b3d2feb9;hb=19d97c4277378f20c6c756981f4123cdc6cbb32b;hp=20785b91b35f6ac83b047fefc6c24798a729f490;hpb=c871fdd1dbaab98271d313c67d38c3bb4ea79057;p=16.git diff --git a/src/lib/16_mm.c b/src/lib/16_mm.c index 20785b91..7cf59d3d 100755 --- a/src/lib/16_mm.c +++ b/src/lib/16_mm.c @@ -563,7 +563,7 @@ void MML_ShutdownXMS(mminfo_t *mm) /*void MML_UseSpace(word segstart, dword seglength, mminfo_t *mm) { - mmblocktype huge *scan,huge *last; + //huge mmblocktype huge *scan,huge *last; word segm=1; word oldend; dword segmlen; @@ -663,7 +663,7 @@ void MML_UseSpace(word segstart, dword seglength, mminfo_t *mm) // take the given range out of the block // oldend = scan->start + scan->length; - extra = oldend - (segstart+((word)seglength)); + extra = oldend - (segstart+((unsigned)seglength)); if (extra < 0) { printf("========================================\n"); @@ -716,7 +716,8 @@ void MML_UseSpace(word segstart, dword seglength, mminfo_t *mm) void MML_ClearBlock(mminfo_t *mm) { - mmblocktype huge *scan,huge *last; + //huge mmblocktype huge *scan,huge *last; + mmblocktype far *scan,far *last; scan = mm->mmhead->next; @@ -750,10 +751,12 @@ void MML_ClearBlock(mminfo_t *mm) void MM_Startup(mminfo_t *mm, mminfotype *mmi) { int i; - dword length,seglength; - //dword length; word seglength; - void huge *start; + //dword length,seglength; + dword length; word seglength; + //huge void huge *start; + void far *start; word segstart;//,endfree; + //memptr *peeonself; // if(mm->mmstarted) // MM_Shutdown(mm); @@ -781,19 +784,24 @@ void MM_Startup(mminfo_t *mm, mminfotype *mmi) mm->mmnew->length = 0xffff; mm->mmnew->attributes = LOCKBIT; mm->mmnew->next = NULL; + //mm->mmnew->useptr = peeonself; mm->mmrover = 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(); - start = (void huge *)(mm->nearheap = _nmalloc(length)); + //huge start = (void huge *)(mm->nearheap = _nmalloc(length)); + start = (void far *)(mm->nearheap = _nmalloc(length)); #endif #ifdef __BORLANDC__ length=coreleft(); - start = (void huge *)(mm->nearheap = malloc(length)); + //huge start = (void huge *)(mm->nearheap = malloc(length)); + start = (void far *)(mm->nearheap = malloc(length)); #endif length -= 16-(FP_OFF(start)&15); length -= SAVENEARHEAP; @@ -943,8 +951,8 @@ void MM_Shutdown(mminfo_t *mm) void MM_GetPtr (memptr *baseptr, dword size, mminfo_t *mm, mminfotype *mmi) { - mmblocktype huge *scan,huge *lastscan,huge *endscan - ,huge *purge,huge *next; + //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; @@ -953,6 +961,11 @@ void MM_GetPtr (memptr *baseptr, dword size, mminfo_t *mm, mminfotype *mmi) GETNEWBLOCK; // fill in start and next after a spot is found mm->mmnew->length = needed; mm->mmnew->useptr = baseptr; + //if(mm->mmnew->useptr==NULL){ + printf("baseptr=%04x ", baseptr); printf("useptr=%04x\n", mm->mmnew->useptr); + printf("*baseptr=%04x ", *baseptr); printf("*useptr=%04x\n", *(mm->mmnew->useptr)); + //printf("*baseptr=%Fp ", *baseptr); printf("*useptr=%Fp\n", *(mm->mmnew->useptr)); + //exit(-5); } mm->mmnew->attributes = BASEATTRIBUTES; //tryagain: @@ -1053,7 +1066,8 @@ void MM_GetPtr (memptr *baseptr, dword size, mminfo_t *mm, mminfotype *mmi) void MM_FreePtr(memptr *baseptr, mminfo_t *mm) { - mmblocktype huge *scan,huge *last; + //huge mmblocktype huge *scan,huge *last; + mmblocktype far *scan,far *last; last = mm->mmhead; scan = last->next; @@ -1091,7 +1105,8 @@ void MM_FreePtr(memptr *baseptr, mminfo_t *mm) void MM_SetPurge(memptr *baseptr, int purge, mminfo_t *mm) { - mmblocktype huge *start; + //huge mmblocktype huge *start; + mmblocktype far *start; start = mm->mmrover; @@ -1130,7 +1145,8 @@ void MM_SetPurge(memptr *baseptr, int purge, mminfo_t *mm) void MM_SetLock(memptr *baseptr, boolean locked, mminfo_t *mm) { - mmblocktype huge *start; + //huge mmblocktype huge *start; + mmblocktype far *start; start = mm->mmrover; @@ -1169,7 +1185,8 @@ void MM_SetLock(memptr *baseptr, boolean locked, mminfo_t *mm) void MM_SortMem(mminfo_t *mm) { - mmblocktype huge *scan,huge *last,huge *next; + //huge mmblocktype huge *scan,huge *last,huge *next; + mmblocktype far *scan,far *last,far *next; unsigned start,length,source,dest,oldborder; int playing; @@ -1279,7 +1296,8 @@ void MM_SortMem(mminfo_t *mm) void MM_ShowMemory(global_game_variables_t *gvar,/*page_t *page, */mminfo_t *mm) { - mmblocktype huge *scan; + //huge mmblocktype huge *scan; + mmblocktype far *scan; word temp; sdword end,owner; //word chx,chy; @@ -1391,7 +1409,7 @@ void MM_ShowMemory(global_game_variables_t *gvar,/*page_t *page, */mminfo_t *mm) ultoa (scan->start,str,16); strcat (scratch,str); strcat (scratch,"\tSize:"); - ultoa ((word)scan->length,str,10); + ultoa ((unsigned)scan->length,str,10); strcat (scratch,str); strcat (scratch,"\tOwner:0x"); owner = (unsigned)scan->useptr; @@ -1441,14 +1459,20 @@ void MM_ShowMemory(global_game_variables_t *gvar,/*page_t *page, */mminfo_t *mm) void MM_DumpData(mminfo_t *mm) { - mmblocktype huge *scan,huge *best; + //huge mmblocktype huge *scan,huge *best; + mmblocktype far *scan,far *best; long lowest,oldlowest; word owner; byte lock,purge; FILE *dumpfile; free(mm->nearheap); - dumpfile = fopen ("mmdump.16","w"); +#ifdef __BORLANDC__ + dumpfile = fopen ("mmdump.16b","w"); +#endif +#ifdef __WATCOMC__ + dumpfile = fopen ("mmdump.16w","w"); +#endif if (!dumpfile){ printf("MM_DumpData: Couldn't open MMDUMP.16!\n"); return; @@ -1463,7 +1487,7 @@ void MM_DumpData(mminfo_t *mm) scan = mm->mmhead; while (scan) { - owner = (word)scan->useptr; + owner = (unsigned)scan->useptr; if (owner && owner oldlowest) { @@ -1485,7 +1509,7 @@ void MM_DumpData(mminfo_t *mm) else lock = '-'; fprintf (dumpfile,"0x%p (%c%c) = %u\n" - ,(word)lowest,lock,purge,best->length); + ,(unsigned)lowest,lock,purge,best->length); } } while (lowest != 0xffff); @@ -1510,7 +1534,8 @@ void MM_DumpData(mminfo_t *mm) dword MM_UnusedMemory(mminfo_t *mm) { dword free; - mmblocktype huge *scan; + //huge mmblocktype huge *scan; + mmblocktype far *scan; free = 0; scan = mm->mmhead; @@ -1541,7 +1566,8 @@ dword MM_UnusedMemory(mminfo_t *mm) dword MM_TotalFree(mminfo_t *mm) { dword free; - mmblocktype huge *scan; + //huge mmblocktype huge *scan; + mmblocktype far *scan; free = 0; scan = mm->mmhead;