From 1dbd79f535c2617caefe848842199988dbedc12f Mon Sep 17 00:00:00 2001 From: sparky4 Date: Thu, 22 Sep 2016 14:44:04 -0500 Subject: [PATCH] reverted to older ver of 16_mm because of bugs --- 16/16_mm.c | 1802 ++++++++++++++++++++++ DEBUG.16B | 16 +- DEBUG.16W | 16 +- HEAP.16W | 86 +- MMDUMP.16B | Bin 75 -> 75 bytes MMDUMP.16W | Bin 22 -> 66 bytes bcexmm.exe | Bin 83827 -> 83128 bytes bcexmm.prj | Bin 7812 -> 6566 bytes src/exmmtest.c | 8 +- src/lib/16_head.h | 3 +- src/lib/16_mm.c | 3625 ++++++++++++++++++++++---------------------- src/lib/16_mm.h | 5 +- src/lib/16_pm.c | 25 +- src/lib/16_pm.h | 2 +- src/lib/length | 4 + src/lib/next | 0 src/lib/typdefst.h | 1 + 17 files changed, 3697 insertions(+), 1896 deletions(-) create mode 100755 16/16_mm.c create mode 100755 src/lib/length create mode 100755 src/lib/next diff --git a/16/16_mm.c b/16/16_mm.c new file mode 100755 index 00000000..9f10fd39 --- /dev/null +++ b/16/16_mm.c @@ -0,0 +1,1802 @@ +/* Catacomb Apocalypse Source Code + * Copyright (C) 1993-2014 Flat Rock Software + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +// NEWMM.C + +/* +============================================================================= + + ID software memory manager + -------------------------- + +Primary coder: John Carmack + +RELIES ON +--------- +Quit (char *error) function + + +WORK TO DO +---------- +MM_SizePtr to change the size of a given pointer + +Multiple purge levels utilized + +EMS / XMS unmanaged routines + +============================================================================= +*/ +/* + +Open Watcom port by sparky4 + +*/ +#include "src/lib/16_mm.h" +#include "src/lib/16_ca.h" +#pragma hdrstop + +#pragma warn -pro +#pragma warn -use + +/* +============================================================================= + + GLOBAL VARIABLES + +============================================================================= +*/ + +void (* beforesort) (void); +void (* aftersort) (void); +void (* XMSaddr) (void); // far pointer to XMS driver + +/* +============================================================================= + + LOCAL VARIABLES + +============================================================================= +*/ + +/* +====================== += += MML_CheckForEMS += += Routine from p36 of Extending DOS += +======================= +*/ + +boolean MML_CheckForEMS(void) +{ + boolean emmcfems; + static char emmname[] = "EMMXXXX0"; //fix by andrius4669 + __asm { + mov dx,OFFSET emmname //fix by andrius4669 + mov ax,0x3d00 + int 0x21 // try to open EMMXXXX0 device + jc error + + mov bx,ax + mov ax,0x4400 + + int 0x21 // get device info + jc error + + and dx,0x80 + jz error + + mov ax,0x4407 + + int 0x21 // get status + jc error + or al,al + jz error + + mov ah,0x3e + int 0x21 // close handle + jc error + // + // EMS is good + // + mov emmcfems,1 + jmp End +#ifdef __BORLANDC__ + } +#endif + error: +#ifdef __BORLANDC__ + __asm { +#endif + // + // EMS is bad + // + mov emmcfems,0 +#ifdef __BORLANDC__ + } +#endif + End: +#ifdef __WATCOMC__ + } +#endif + return(emmcfems); +} + + +/* +====================== += += MML_SetupEMS += +======================= +*/ + +byte MML_SetupEMS(global_game_variables_t *gvar) +{ + byte str[160]; + byte err; + boolean errorflag=false; + + unsigned int EMSVer = 0; + //byte EMS_status; + unsigned totalEMSpages,freeEMSpages,EMSPageFrame,EMSpagesmapped,EMSHandle; + totalEMSpages = freeEMSpages = EMSPageFrame = EMSpagesmapped = 0; + + __asm { + mov ah,EMS_STATUS + int EMS_INT // make sure EMS hardware is present + or ah,ah + //mov [EMS_status],ah + jnz error + + mov ah,EMS_VERSION + int EMS_INT + or ah,ah + jnz error + mov [EMSVer],ax // set EMSVer + cmp al,0x32 // only work on ems 3.2 or greater + jb error + + mov ah,EMS_GETFRAME + int EMS_INT // find the page frame address + or ah,ah + jnz error + mov [EMSPageFrame],bx + + mov ah,EMS_GETPAGES + int EMS_INT // find out how much EMS is there + or ah,ah + jnz error + mov [totalEMSpages],dx + mov [freeEMSpages],bx + or bx,bx + jz noEMS // no EMS at all to allocate + //EXPAND DONG!!!! + cmp [EMSVer],0x40 + jb low + cmp bx,[freeEMSpages] + jle getpages + mov bx,[freeEMSpages] + jmp getpages +#ifdef __BORLANDC__ + } +#endif + low: +#ifdef __BORLANDC__ + __asm { +#endif + cmp bx,4 + jle getpages // there is only 1,2,3,or 4 pages + mov bx,4 // we can't use more than 4 pages +#ifdef __BORLANDC__ + } +#endif + getpages: +#ifdef __BORLANDC__ + __asm { +#endif + mov [EMSpagesmapped],bx + mov ah,EMS_ALLOCPAGES // allocate up to 64k of EMS + int EMS_INT + or ah,ah + jnz error + mov [EMSHandle],dx + jmp End +#ifdef __BORLANDC__ + } +#endif + error: +#ifdef __BORLANDC__ + __asm { +#endif + mov err,ah + mov errorflag,1 + jmp End +#ifdef __BORLANDC__ + } +#endif +noEMS: +End: +#ifdef __WATCOMC__ + } +#endif + if(errorflag==true) + { + strcpy(str,"MM_SetupEMS: EMS error "); + MM_EMSerr(str, err); + printf("%s\n",str); + return err; + } + gvar->pm.emm.totalEMSpages=totalEMSpages; + gvar->pm.emm.freeEMSpages=freeEMSpages; + gvar->pm.emm.EMSPageFrame=EMSPageFrame; + gvar->pm.emm.EMSpagesmapped=EMSpagesmapped; + gvar->pm.emm.EMSHandle=EMSHandle; + gvar->pm.emm.EMSVer=EMSVer; + return 0; +} + + +/* +====================== += += MML_ShutdownEMS += +======================= +*/ + +void MML_ShutdownEMS(global_game_variables_t *gvar) +{ + boolean errorflag=false; + unsigned EMSHandle=gvar->pm.emm.EMSHandle; + + if(!EMSHandle) + return; + __asm { + mov ah,EMS_FREEPAGES + mov dx,[EMSHandle] + int EMS_INT + or ah,ah + jz ok + mov errorflag,1 +#ifdef __BORLANDC__ + } +#endif + ok: +#ifdef __WATCOMC__ + } +#endif + if(errorflag==true) + Quit("MML_ShutdownEMS: Error freeing EMS!\n"); //++++ add something +} + +/* +==================== += += MM_MapEMS += += Maps the 64k of EMS used by memory manager into the page frame += for general use. This only needs to be called if you are keeping += other things in EMS. += +==================== +*/ + +byte MM_MapEMS(global_game_variables_t *gvar) +{ + byte str[160]; + unsigned EMSHandle; + byte err; + boolean errorflag=false; + int i; + EMSHandle=gvar->pm.emm.EMSHandle; + + for (i=0;i<4/*MAPPAGES*/;i++) + { + __asm { + mov ah,EMS_MAPPAGE + mov bx,[i] // logical page + mov al,bl // physical page + mov dx,[EMSHandle] // handle + int EMS_INT + or ah,ah + jnz error + jmp End +#ifdef __BORLANDC__ + } +#endif + error: +#ifdef __BORLANDC__ + __asm { +#endif + mov err,ah + mov errorflag,1 +#ifdef __BORLANDC__ + } +#endif + End: +#ifdef __WATCOMC__ + } +#endif + if(errorflag==true) + { + strcpy(str,"MM_MapEMS: EMS error "); + MM_EMSerr(str, err); + printf("%s\n",str); + return err; + } + } + gvar->mmi.EMSmem = (i)*0x4000lu; + //printf(" gvar->mmi.EMSmem=%lu\n", gvar->mmi.EMSmem); + return 0; +} + +byte MM_MapXEMS(global_game_variables_t *gvar) +{ +//SUB EMS.MapXPages (PhysicalStart, LogicalStart, NumPages, Handle) + + //Maps up to 4 logical EMS pages to physical pages in the page frame, where: + //PhysicalStart = Physical page first logical page is mapped to + //LogicalStart = First logical page to map + //NumPages = Number of pages to map (1 to 4) + //Handle = EMS handle logical pages are allocated to + + /*//Create a buffer containing the page information +// FOR x = 0 TO NumPages - 1 +// MapInfo$ = MapInfo$ + MKI$(LogicalStart + x) + MKI$(PhysicalStart + x) +// NEXT*/ + +// Regs.ax = 0x5000 //Map the pages in the buffer +// Regs.cx = NumPages //to the pageframe +// Regs.dx = Handle +// Regs.ds = VARSEG(MapInfo$) +// Regs.si = SADD(MapInfo$) +// InterruptX 0x67, Regs, Regs +// EMS.Error = (Regs.ax AND 0xFF00&) \ 0x100 //Store the status code + +//END SUB + byte str[160]; + byte err; + word EMSHandle; + boolean errorflag=false; + int i; + EMSHandle=gvar->pm.emm.EMSHandle; + + if(gvar->pm.emm.EMSVer<0x40) + return 5; + + for (i=0;immi.EMSmem = (i)*0x4000lu; + return 0; +} + +//========================================================================== + +/* +====================== += += MML_CheckForXMS += += Check for XMM driver += +======================= +*/ + +boolean MML_CheckForXMS(global_game_variables_t *gvar) +{ + boolean errorflag=false; + gvar->mm.numUMBs = 0; + + __asm { + mov ax,0x4300 + int 0x2f // query status of installed diver + cmp al,0x80 + je good + mov errorflag,1 +#ifdef __BORLANDC__ + } +#endif + good: +#ifdef __WATCOMC__ + } +#endif + if(errorflag==true) return false; + else return true; +} + + +/* +====================== += += MML_SetupXMS += += Try to allocate all upper memory block += +======================= +*/ + +void MML_SetupXMS(global_game_variables_t *gvar) +{ + word base,size; + + + __asm { + mov ax,0x4310 + int 0x2f + mov [WORD PTR XMSaddr],bx + mov [WORD PTR XMSaddr+2],es // function pointer to XMS driver + } +getmemory: + __asm { + mov ah,XMS_ALLOCUMB + mov dx,0xffff // try for largest block possible + //mov ax,dx // Set available Kbytes. + call [DWORD PTR XMSaddr] + or ax,ax + jnz gotone + + cmp bl,0xb0 // error: smaller UMB is available + jne done; + + mov ah,XMS_ALLOCUMB + call [DWORD PTR XMSaddr] // DX holds largest available UMB + or ax,ax + jz done // another error... +#ifdef __BORLANDC__ + } +#endif + gotone: +#ifdef __BORLANDC__ + __asm { +#endif + mov [base],bx + mov [size],dx +#ifdef __BORLANDC__ + } +#endif + done: +#ifdef __WATCOMC__ + } +#endif +// printf("base=%u ", base); printf("size=%u\n", size); + MML_UseSpace(base,size, gvar); + gvar->mmi.XMSmem += size*16; + gvar->mm.UMBbase[gvar->mm.numUMBs] = base; + gvar->mm.numUMBs++; + if(gvar->mm.numUMBs < MAXUMBS) + goto getmemory; +} + + +/* +====================== += += MML_ShutdownXMS += +====================== +*/ + +void MML_ShutdownXMS(global_game_variables_t *gvar) +{ + int i; + unsigned base; + + for (i=0;imm.numUMBs;i++) + { + base = gvar->mm.UMBbase[i]; + __asm { + mov ah,XMS_FREEUMB + mov dx,[base] + call [DWORD PTR XMSaddr] + } + } +} + +//========================================================================== + +/* +====================== += += MML_UseSpace += += Marks a range of paragraphs as usable by the memory manager += This is used to mark space for the near heap, far heap, ems page frame, += and upper memory blocks += +====================== +*/ + +/*void MML_UseSpace(word segstart, dword seglength, global_game_variables_t *gvar) +{ + //huge mmblocktype huge *scan,huge *last; + word segm=1; + word oldend; + dword segmlen; + dword extra; + + scan = last = gvar->mm.mmhead; + gvar->mm.mmrover = gvar->mm.mmhead; // reset rover to start of memory + +// +// search for the block that contains the range of segments +// + while(scan->start+scan->length < segstart) + { + last = scan; + scan = scan->next; + } + +// +// take the given range out of the block +// + oldend = scan->start + scan->length; + extra = oldend - (segstart+seglength); + + segmlen=extra; + + //++++emsver stuff! + if(segm>1)/// || extra>=0x10000lu) + //if(extra>0xfffflu) + { + scan->blob=segm; + + //MML_UseSpace(segstart, seglength, gvar); + + printf("MML_UseSpace: Segment spans two blocks!\n"); + //} + printf("segm=%u ", segm); + printf("ex=%lu ", extra); + printf("old=%u ", oldend); + printf("start+seglen=%lu\n", segstart+seglength); + printf("segsta=%x ", segstart); + printf("len=%lu ", scan->length); + printf("seglen=%lu ", seglength); + printf("segmlen=%lu\n", segmlen); + } +//++++todo: linked list of segment! + if(segstart == scan->start) + { + last->next = scan->next; // unlink block + FREEBLOCK(scan); + scan = last; + } + else + scan->length = segstart-scan->start; // shorten block + + if(extra > 0) + { + GETNEWBLOCK; + gvar->mm.mmnew->useptr = NULL; + + gvar->mm.mmnew->next = scan->next; + scan->next = gvar->mm.mmnew; + gvar->mm.mmnew->start = segstart+seglength; + gvar->mm.mmnew->length = extra; + gvar->mm.mmnew->attributes = LOCKBIT; + }//else if(segm>0) goto segu; + +}*/ +void MML_UseSpace(word segstart, dword seglength, global_game_variables_t *gvar) +{ + mmblocktype far *scan,far *last; + word oldend; + sdword extra; + //word segm=1; + + scan = last = gvar->mm.mmhead; + gvar->mm.mmrover = gvar->mm.mmhead; // reset rover to start of memory + +// +// search for the block that contains the range of segments +// + while (scan->start+scan->length < segstart) + { + last = scan; + scan = scan->next; + } + +// +// find out how many blocks it spans! +// + /*for(;seglength>=0x10000;seglength-=0xFFFF) + { + //printf(" seglen=%lu\n", segmlen); + segm++; + }*/ + +// +// take the given range out of the block +// + oldend = scan->start + scan->length; + extra = oldend - (segstart+((unsigned)seglength)); + if (extra < 0) + { + printf("========================================\n"); + printf("start=%x ", scan->start); + printf("old=%u ", oldend); + printf("start+seglen=%lu\n", segstart+seglength); + printf("segsta=%x ", segstart); + printf("len=%lu ", scan->length); + printf("seglen=%lu ", seglength); + printf("\n"); + printf("MML_UseSpace: Segment spans two blocks! %d\n", extra); + printf("========================================\n"); + //return; + } + + if (segstart == scan->start) + { + last->next = scan->next; // unlink block + FREEBLOCK(scan); + scan = last; + } + else + scan->length = segstart-scan->start; // shorten block + + if (extra > 0) + { + GETNEWBLOCK; + gvar->mm.mmnew->useptr = NULL; + + gvar->mm.mmnew->next = scan->next; + scan->next = gvar->mm.mmnew; + gvar->mm.mmnew->start = segstart+seglength; + gvar->mm.mmnew->length = extra; + gvar->mm.mmnew->attributes = LOCKBIT; + } + +} + +//========================================================================== + +/* +==================== += += MML_ClearBlock += += We are out of blocks, so free a purgable block += +==================== +*/ + +void MML_ClearBlock(global_game_variables_t *gvar) +{ + //huge mmblocktype huge *scan,huge *last; + mmblocktype far *scan,far *last; + + scan = gvar->mm.mmhead->next; + + while(scan) + { + if(!(scan->attributes&LOCKBIT) && (scan->attributes&PURGEBITS)) + { + MM_FreePtr(scan->useptr, gvar); + return; + } + scan = scan->next; + } + + printf("MM_ClearBlock: No purgable blocks!\n"); +} + + +//========================================================================== + +/* +=================== += += MM_Startup += += Grabs all space from turbo with malloc/farmalloc += Allocates bufferseg misc buffer += +=================== +*/ + +void MM_Startup(global_game_variables_t *gvar) +{ + int i; + //dword length,seglength; + dword length; + //huge void huge *start; + void far *start; + word segstart,seglength,endfree; + //memptr *peeonself; + + if(gvar->mm.mmstarted) + MM_Shutdown(gvar); + + + gvar->mm.mmstarted = true; + gvar->mm.bombonerror = true; +// +// set up the linked list (everything in the free list; +// + 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; + +// +// locked block of all memory until we punch out free space +// + GETNEWBLOCK; + gvar->mm.mmhead = gvar->mm.mmnew; // this will allways be the first node + gvar->mm.mmnew->start = 0; + 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)); + printf("Borland C unique function\n"); + printf(" coreleft() %lu\n", coreleft()); +#endif + length -= 16-(FP_OFF(start)&15); + length -= SAVENEARHEAP; + seglength = length / 16; // now in paragraphs + segstart = FP_SEG(start)+(FP_OFF(start)+15)/16; + MML_UseSpace(segstart,seglength, gvar); + gvar->mmi.nearheap = length; + //printf("start=%Fp segstart=%x seglen=%lu len=%lu\n", start, segstart, seglength, length); + +// +// get all available far conventional memory segments +// + //printf("_FARCORELEFT %lu\n", _FCORELEFT); +#ifdef __WATCOMC__ + _fheapgrow(); +#endif +#ifdef __BORLANDC__ + printf(" farcoreleft() %lu\n", farcoreleft()); + printf(" (farcoreleft()+32)-_FCORELEFT %d\n", (sword)((farcoreleft()+32)-_FCORELEFT)); +#endif + length=_FCORELEFT;//_fcoreleft();//(dword)GetFarFreeSize();//0xffffUL*4UL; + start = gvar->mm.farheap = _fmalloc(length); + //start = gvar->mm.farheap = halloc(length, 1); + length -= 16-(FP_OFF(start)&15); + length -= SAVEFARHEAP; + seglength = length / 16; // now in paragraphs + segstart = FP_SEG(start)+(FP_OFF(start)+15)/16; + MML_UseSpace(segstart,seglength, gvar); + gvar->mmi.farheap = length; + gvar->mmi.mainmem = gvar->mmi.nearheap + gvar->mmi.farheap; + //printf("start=%Fp segstart=%x seglen=%lu len=%lu\n", start, segstart, seglength, length); + +#ifdef __DEBUG_PM__ +goto xmsskip; //INFO: 16_PM dose this job better +#endif + +// +// detect EMS and allocate up to 64K at page frame +// + gvar->mmi.EMSmem = 0; +//goto emsskip; //0000 + if(MML_CheckForEMS()) + { + MML_SetupEMS(gvar); // allocate space + //TODO: EMS4! AND EMS 3.2 MASSIVE DATA HANDLMENT! + MML_UseSpace(gvar->pm.emm.EMSPageFrame,(MAPPAGES)*0x4000lu, gvar); + //if(gvar->pm.emm.EMSVer<0x40) + MM_MapEMS(gvar); // map in used pages + //else + //MM_MapXEMS(gvar); // map in used pages + } + +// +// detect XMS and get upper memory blocks +// +//emsskip: + gvar->mmi.XMSmem = 0; +goto xmsskip;//0000 + if(MML_CheckForXMS(gvar)) + { + MML_SetupXMS(gvar); // allocate as many UMBs as possible + } + +// +// allocate the misc buffer +// +xmsskip: + gvar->mm.mmrover = gvar->mm.mmhead; // start looking for space after low block + + MM_GetPtr(&(gvar->mm.bufferseg),BUFFERSIZE, gvar); +} + +//========================================================================== + +/* +==================== += += MM_Shutdown += += Frees all conventional, EMS, and XMS allocated += +==================== +*/ + +void MM_Shutdown(global_game_variables_t *gvar) +{ + if(!(gvar->mm.mmstarted)) + return; + + _ffree(gvar->mm.farheap);// printf(" far freed\n"); +#ifdef __WATCOMC__ + _nfree(gvar->mm.nearheap);// printf(" near freed\n"); +#endif +#ifdef __BORLANDC__ + free(gvar->mm.nearheap);// printf(" near freed\n"); +#endif +#ifndef __DEBUG_PM__ + if(MML_CheckForEMS()){ MML_ShutdownEMS(gvar); }//printf(" EMS freed\n"); } + if(MML_CheckForXMS(gvar)){ MML_ShutdownXMS(gvar); }//printf(" XMS freed\n"); } //INFO: 16_PM dose this job better +#endif +} + +//========================================================================== + +/* +==================== += += MM_GetPtr += += Allocates an unlocked, unpurgable block += +==================== +*/ + +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; + + needed = (size+15)/16; // convert size from bytes to paragraphs + + GETNEWBLOCK; // fill in start and next after a spot is found + gvar->mm.mmnew->length = needed; + gvar->mm.mmnew->useptr = baseptr; + //if(gvar->mm.mmnew->useptr==NULL){ +#ifdef __DEBUG__ + printf(" MM_GetPtr\n"); + 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)); +#endif + //exit(-5); } + gvar->mm.mmnew->attributes = BASEATTRIBUTES; + +//tryagain: + for (search = 0; search<3; search++) + { + // + // first search: try to allocate right after the rover, then on up + // second search: search from the head pointer up to the rover + // third search: compress memory, then scan from start + if (search == 1 && gvar->mm.mmrover == gvar->mm.mmhead) + search++; + + switch (search) + { + case 0: + lastscan = gvar->mm.mmrover; + scan = gvar->mm.mmrover->next; + endscan = NULL; + break; + case 1: + lastscan = gvar->mm.mmhead; + scan = gvar->mm.mmhead->next; + endscan = gvar->mm.mmrover; + break; + case 2: + MM_SortMem (gvar); + lastscan = gvar->mm.mmhead; + scan = gvar->mm.mmhead->next; + endscan = NULL; + break; + } + + startseg = lastscan->start + lastscan->length; + + while (scan != endscan) + { + if (scan->start - startseg >= needed) + { + // + // got enough space between the end of lastscan and + // the start of scan, so throw out anything in the middle + // and allocate the new block + // + purge = lastscan->next; + lastscan->next = gvar->mm.mmnew; + gvar->mm.mmnew->start = *(unsigned *)baseptr = startseg; + gvar->mm.mmnew->next = scan; + while ( purge != scan) + { // free the purgable block + next = purge->next; + FREEBLOCK(purge); + purge = next; // purge another if not at scan + } + gvar->mm.mmrover = gvar->mm.mmnew; + return; // good allocation! + } + + // + // if this block is purge level zero or locked, skip past it + // + if ( (scan->attributes & LOCKBIT) + || !(scan->attributes & PURGEBITS) ) + { + lastscan = scan; + startseg = lastscan->start + lastscan->length; + } + + + scan=scan->next; // look at next line + } + } + + if (gvar->mm.bombonerror) + { +#ifdef __WATCOMC__ + //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); + } + else + gvar->mm.mmerror = true; +} + +//========================================================================== + +/* +==================== += += MM_FreePtr += += Allocates an unlocked, unpurgable block += +==================== +*/ + +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; + scan = last->next; + + if(baseptr == gvar->mm.mmrover->useptr) // removed the last allocated block + gvar->mm.mmrover = gvar->mm.mmhead; + + while(scan->useptr != baseptr && scan) + { + last = scan; + scan = scan->next; + } + + if(!scan) + { + printf("MM_FreePtr: Block not found!\n"); + return; + } + + last->next = scan->next; + + FREEBLOCK(scan); +} +//========================================================================== + +/* +===================== += += MM_SetPurge += += Sets the purge level for a block (locked blocks cannot be made purgable) += +===================== +*/ + +void MM_SetPurge(memptr *baseptr, int purge, global_game_variables_t *gvar) +{ + //huge mmblocktype huge *start; + mmblocktype far *start; + + start = gvar->mm.mmrover; + + do + { + if(gvar->mm.mmrover->useptr == baseptr) + break; + + gvar->mm.mmrover = gvar->mm.mmrover->next; + + if(!gvar->mm.mmrover) + gvar->mm.mmrover = gvar->mm.mmhead; + else if(gvar->mm.mmrover == start) + { +#ifdef __DEBUG_PM__ + printf("\nstart->useptr gvar->mm.mmhead->useptr\n"); + printf(" %Fp %Fp\n", start->useptr, gvar->mm.mmhead->useptr); + printf("& %Fp %Fp\n", &(start->useptr), &(gvar->mm.mmhead->useptr)); + printf("baseptr gvar->mm.mmrover->useptr\n"); + printf(" %Fp %Fp\n", baseptr, gvar->mm.mmrover->useptr); + printf("& %Fp %Fp\n", &(baseptr), &(gvar->mm.mmrover->useptr)); + printf("* %Fp %Fp\n", *(baseptr), *(gvar->mm.mmrover->useptr)); + printf("start gvar->mm.mmrover gvar->mm.mmrover->next\n"); + printf(" %Fp %Fp %Fp\n", start, gvar->mm.mmrover, gvar->mm.mmrover->next); + printf("& %Fp %Fp %Fp\n", &start, &gvar->mm.mmrover, gvar->mm.mmrover->next); + getch(); + MM_ShowMemory(gvar); + MM_DumpData(gvar); + MM_Report_(gvar); + getch(); +#endif + Quit("MM_SetPurge: Block not found!"); + return; + } + + } while(1); + + gvar->mm.mmrover->attributes &= ~PURGEBITS; + gvar->mm.mmrover->attributes |= purge; +} + +//========================================================================== + +/* +===================== += += MM_SetLock += += Locks / unlocks the block += +===================== +*/ + +void MM_SetLock(memptr *baseptr, boolean locked, global_game_variables_t *gvar) +{ + //huge mmblocktype huge *start; + mmblocktype far *start; + + start = gvar->mm.mmrover; + + do + { + if(gvar->mm.mmrover->useptr == baseptr) + break; + + gvar->mm.mmrover = gvar->mm.mmrover->next; + + if(!gvar->mm.mmrover) + gvar->mm.mmrover = gvar->mm.mmhead; + else if(gvar->mm.mmrover == start) + { + Quit("MM_SetLock: Block not found!"); + //return; + } + + } while(1); + + gvar->mm.mmrover->attributes &= ~LOCKBIT; + gvar->mm.mmrover->attributes |= locked*LOCKBIT; +} + +//========================================================================== + +/* +===================== += += MM_SortMem += += Throws out all purgable stuff and compresses movable blocks += +===================== +*/ + +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; + + // + // lock down a currently playing sound + // +/*++++ playing = SD_SoundPlaying (); + if(playing) + { + switch (SoundMode) + { + case sdm_PC: + playing += STARTPCSOUNDS; + break; + case sdm_AdLib: + playing += STARTADLIBSOUNDS; + break; + } + MM_SetLock(&(memptr)audiosegs[playing],true); + } + + + SD_StopSound();*/ +// oldborder = bordercolor; +// VW_ColorBorder (15); + + if(beforesort) + beforesort(); + + scan = gvar->mm.mmhead; + + last = NULL; // shut up compiler warning + + while(scan) + { + if(scan->attributes & LOCKBIT) + { + // + // block is locked, so try to pile later blocks right after it + // + start = scan->start + scan->length; + } + else + { + if(scan->attributes & PURGEBITS) + { + // + // throw out the purgable block + // + next = scan->next; + FREEBLOCK(scan); + //MM_FreeBlock(scan, gvar); + last->next = next; + scan = next; + continue; + } + else + { + // + // push the non purgable block on top of the last moved block + // + if(scan->start != start) + { + length = scan->length; + source = scan->start; + dest = start; + while(length > 0xf00) + { + movedata(source,0,dest,0,0xf00*16); + length -= 0xf00; + source += 0xf00; + dest += 0xf00; + } + movedata(source,0,dest,0,length*16); + + scan->start = start; + *(unsigned *)scan->useptr = start; + } + start = scan->start + scan->length; + } + } + + last = scan; + scan = scan->next; // go to next block + } + + gvar->mm.mmrover = gvar->mm.mmhead; + + if(aftersort) + aftersort(); + +// VW_ColorBorder (oldborder); + +/*++++ if(playing) + MM_SetLock(&(memptr)audiosegs[playing],false);*/ +} + +//========================================================================== + +/* +===================== += += MM_ShowMemory += +===================== +*/ + +void MM_ShowMemory(global_game_variables_t *gvar) +{ + //huge mmblocktype huge *scan; + mmblocktype far *scan; + word temp; + sdword end,owner; + //word chx,chy; + word w; + //dword wwww; + byte scratch[160],scratch0[4096],scratch1[160],str[16]; + //byte d = '#'; +//**** VW_SetDefaultColors(); +//**** VW_SetLineWidth(40); +//++++mh temp = bufferofs; +//++++mh bufferofs = 0; +//**** VW_SetScreen (0,0); + scan = gvar->mm.mmhead; + end = -1; + + CA_OpenDebug (gvar); + w=0; + while(scan) + { + strcpy(scratch, AARESET); + if(scan->attributes & PURGEBITS) + strcpy(scratch0, AAMAGENTA); // dark purple = purgable + else + strcpy(scratch0, AABLUE); // medium blue = non purgable + if(scan->attributes & LOCKBIT) + strcpy(scratch0, AARED); // red = locked + if(scan->start<=end) + { + printf("\nend==%d\n\n", end); + strcat(scratch, "MM_ShowMemory: Memory block order currupted!\n"); + strcat(scratch, "End's Size: "); + ultoa (end,str,10); + strcat (scratch,str); + strcat(scratch, "\nscan->start's Size: "); + ultoa (scan->start,str,10); + strcat (scratch,str); + write(gvar->handle.debughandle,scratch,strlen(scratch)); + //modexprint(&page, chx, chy, 1, 0, 24, "\nMM_ShowMemory: Memory block order currupted!\n"); + break; + } + end = scan->start+(scan->length)-1; +//++++ chy = scan->start/320; +//++++ chx = scan->start%320; + //modexhlin(page, scan->start, (unsigned)end, chy, color); + //for(chx=scan->start;chx+4>=(word)end;chx+=4) + //{ +//++++ modexClearRegion(page, chx, chy, 4, 4, color); + //} +//++++ VW_Hlin(scan->start,(unsigned)end,0,color); + for(w=(scan->start)/80;w<=end/80;w++) + { + //printf("+ %u %lu\n", w, scan->length); + strcat(scratch0, "+"); + } + //++==++==optional strcat(scratch0, AARESET); strcat(scratch0, AAGREY); strcat(scratch0,"_"); +//++++ VW_Plot(scan->start,0,15); +//++++ modexClearRegion(page, chx, chy, 4, 4, 15); +//++++ VW_Hlin(end+1,scan->next->start,0,0); // black = free + + //wwww=(dword)(scan->next->start)-(dword)scan->start; + //wwww=(dword)scan->start+(dword)(scan->next->start); + if (scan->next && scan->next->start >= end+1) + { + strcat(scratch0, AARESET); + //++==++==optional strcat(scratch0, "\n"); + strcat(scratch0,AAGREEN); + for(w=(end+1)/80;w<=((scan->next->start-scan->start)/80);w++) + //for(w=(wwww)/80;w<=((end+1)/80);w++) + //for(w=(end+1)/80;w<=((wwww)/80);w++) + { + //printf("0 %x %u %lu\n", scan->next->start, w, scan->length); + strcat(scratch0,"0"); + } + //printf("==================\n"); + //printf("w=%u wwww=%lu start=%04x next=%04x end=%lu\n", w/80, wwww/80, scan->start, (scan->next->start), end+1); + //printf("==================\n"); + strcat(scratch0, "\n"); + //getch(); + }/*else {//if(scan->next->start <= scan->start){ + scan->next->start=scan->start+0x1000; + wwww=(dword)(scan->next->start)-(dword)scan->start; + strcat(scratch0, AARESET); + strcat(scratch0, "\n"); + strcat(scratch0,AAGREEN); + for(w=(end+1);w<=(0x1000/80);w++) + { + //printf("0 %x %x %u\n", scan->start, w); + strcat(scratch0,"0"); + } + printf("================\n"); + printf("w=%x start=%x next=%x end=%u %lu\n", w, scan->start, (scan->next->start), end+1, wwww); + printf("================\n"); + getch(); + }*/ + strcat(scratch0, AARESET); + //strcat(scratch0,"\n"); + //for(chx=scan->next->start;chx+4>=(word)end+1;chx+=4) + //{ +// chx+=scan->next->start; +// modexClearRegion(page, chx, chy, 4, 4, 2); + //} + //modexhlin(page, end+1,scan->next->start, chy, 0); +/* y = scan->start/320; + x = scan->start%320; + VW_Hlin(x,x+end,y,color); + VW_Plot(x,y,15);*/ +//++++ VW_Hlin(x+end+1,x+(scan->next->start-scan->start),y,0); // black = free + strcat(scratch,"Seg:"); + ultoa (scan->start,str,16); + strcat (scratch,str); + strcat (scratch,"\tSize:"); + ultoa ((unsigned)scan->length,str,10); + strcat (scratch,str); + strcat (scratch,"\tOwner:0x"); + owner = (unsigned)scan->useptr; + ultoa (owner,str,16); + strcat (scratch,str); + strcat (scratch,"\n"); + write(gvar->handle.debughandle,scratch,strlen(scratch)); + write(gvar->handle.debughandle,scratch0,strlen(scratch0)); +//modexprint(page, chx, chy, 1, 0, 24, &scratch); +//++++chy+=4; +//fprintf(stdout, "%s", scratch); + + scan = scan->next; + } + /*strcpy(scratch1, AARESET); + strcat(scratch1, "========================================\n"); + strcat(scratch1, "near= "); + ultoa (*(gvar->mm.nearheap),str,10); + strcat (scratch1,str); + strcat(scratch1, " far= "); + ultoa (*(gvar->mm.farheap),str,10); + strcat (scratch1,str); + strcat(scratch1, "\n"); + //strcat(scratch1, "&near= %Fp ", &(gvar->mm.nearheap)); + //strcat(scratch1, "&far= %Fp", &(gvar->mm.farheap)); + //strcat(scratch1, "\n"); + strcat(scratch1, "========================================\n"); + write(gvar->handle.debughandle,scratch1,strlen(scratch1));*/ + + + CA_CloseDebug (gvar); + +//++++mh IN_Ack(); +//**** VW_SetLineWidth(64); +//++++mh bufferofs = temp; +} + +//========================================================================== + +/* +===================== += += MM_DumpData += +===================== +*/ + +void MM_DumpData(global_game_variables_t *gvar) +{ + //huge mmblocktype huge *scan,huge *best; + mmblocktype far *scan,far *best; + long lowest,oldlowest; + word owner; + byte lock,purge; + FILE *dumpfile; + + free(gvar->mm.nearheap); +#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; + } + + lowest = -1; + do + { + oldlowest = lowest; + lowest = 0xffff; + + scan = gvar->mm.mmhead; + while (scan) + { + owner = (unsigned)scan->useptr; + + if (owner && owner oldlowest) + { + best = scan; + lowest = owner; + } + + scan = scan->next; + } + + if (lowest != 0xffff) + { + if (best->attributes & PURGEBITS) + purge = 'P'; + else + purge = '-'; + if (best->attributes & LOCKBIT) + lock = 'L'; + else + lock = '-'; + fprintf (dumpfile,"0x%p (%c%c) = %u\n" + ,(unsigned)lowest,lock,purge,best->length); + } + + } while (lowest != 0xffff); + + fclose(dumpfile); + printf("MMDUMP.16 created.\n"); +} + +//========================================================================== + + +/* +====================== += += MM_UnusedMemory += += Returns the total free space without purging += +====================== +*/ + +dword MM_UnusedMemory(global_game_variables_t *gvar) +{ + dword free; + //huge mmblocktype huge *scan; + mmblocktype far *scan; + + free = 0; + scan = gvar->mm.mmhead; + + while(scan->next) + { + free += scan->next->start - (scan->start + scan->length); + scan = scan->next; + } + + return free*16lu; +// return free; +} + +//========================================================================== + + +/* +====================== += += MM_TotalFree += += Returns the total free space with purging += +====================== +*/ + +dword MM_TotalFree(global_game_variables_t *gvar) +{ + dword free; + //huge mmblocktype huge *scan; + mmblocktype far *scan; + + free = 0; + scan = gvar->mm.mmhead; + + while(scan->next) + { + if((scan->attributes&PURGEBITS) && !(scan->attributes&LOCKBIT)) + free += scan->length; + free += scan->next->start - (scan->start + scan->length); + scan = scan->next; + } + + return free*16lu; +// return free; +} + +//========================================================================== + +/* +===================== += += MM_Report += +===================== +*/ + +void MM_Report_(global_game_variables_t *gvar) +{ + printf("========================================\n"); + printf(" MM_Report\n"); + printf("========================================\n"); + if(MML_CheckForEMS()) + { + printf(" LIMEMS\n"); + printf(" EMM v%x.%x available\n", gvar->pm.emm.EMSVer>>4,gvar->pm.emm.EMSVer&0x0F); + printf(" totalEMSpages: %u ", gvar->pm.emm.totalEMSpages); printf("freeEMSpages: %u\n", gvar->pm.emm.freeEMSpages); + printf(" EMSPageFrame: %x\n", gvar->pm.emm.EMSPageFrame); + } + if(MML_CheckForXMS(gvar)) + { + printf(" XMS\n"); + printf(" XMSaddr: %X\n", *XMSaddr); + } + printf("near: %lu ", gvar->mmi.nearheap); printf("far: %lu\n", gvar->mmi.farheap); if(MML_CheckForEMS()) + printf("EMSmem: %lu ", gvar->mmi.EMSmem); if(MML_CheckForXMS(gvar)) printf("XMSmem: %lu", gvar->mmi.XMSmem); printf("\n"); + //printf("mainmem: %lu\n", gvar->mmi.mainmem); + printf("Total convmem: %lu ", gvar->mmi.mainmem); printf("TotalFree: %lu ", MM_TotalFree(gvar)); printf("TotalUsed: %lu\n", gvar->mmi.mainmem+gvar->mmi.EMSmem+gvar->mmi.XMSmem+gvar->mmi.XMSmem); + printf(" UnusedMemory: %lu\n", MM_UnusedMemory(gvar)); +} + +//========================================================================== + +/* +===================== += += MM_EMSerr += +===================== +*/ + +void MM_EMSerr(byte *stri, byte err) +{ + //Returns a text string describing the error code in EMS.Error. + switch(err) + { + case 0x0: + strcat(stri, "successful"); + break; + case 0x80: + strcat(stri, "internal error"); + break; + case 0x81: + strcat(stri, "hardware malfunction"); + break; + case 0x82: + strcat(stri, "busy .. retry later"); + break; + case 0x83: + strcat(stri, "invalid handle"); + break; + case 0x84: + strcat(stri, "undefined function requested by application"); + break; + case 0x85: + strcat(stri, "no more handles available"); + break; + case 0x86: + strcat(stri, "error in save or restore of mapping context"); + break; + case 0x87: + strcat(stri, "insufficient memory pages in system"); + break; + case 0x88: + strcat(stri, "insufficient memory pages available"); + break; + case 0x89: + strcat(stri, "zero pages requested"); + break; + case 0x8A: + strcat(stri, "invalid logical page number encountered"); + break; + case 0x8B: + strcat(stri, "invalid physical page number encountered"); + break; + case 0x8C: + strcat(stri, "page-mapping hardware state save area is full"); + break; + case 0x8D: + strcat(stri, "save of mapping context failed"); + break; + case 0x8E: + strcat(stri, "restore of mapping context failed"); + break; + case 0x8F: + strcat(stri, "undefined subfunction"); + break; + case 0x90: + strcat(stri, "undefined attribute type"); + break; + case 0x91: + strcat(stri, "feature not supported"); + break; + case 0x92: + strcat(stri, "successful, but a portion of the source region has been overwritten"); + break; + case 0x93: + strcat(stri, "length of source or destination region exceeds length of region allocated to either source or destination handle"); + break; + case 0x94: + strcat(stri, "conventional and expanded memory regions overlap"); + break; + case 0x95: + strcat(stri, "offset within logical page exceeds size of logical page"); + break; + case 0x96: + strcat(stri, "region length exceeds 1 MB"); + break; + case 0x97: + strcat(stri, "source and destination EMS regions have same handle and overlap"); + break; + case 0x98: + strcat(stri, "memory source or destination type undefined"); + break; + case 0x9A: + strcat(stri, "specified alternate map register or DMA register set not supported"); + break; + case 0x9B: + strcat(stri, "all alternate map register or DMA register sets currently allocated"); + break; + case 0x9C: + strcat(stri, "alternate map register or DMA register sets not supported"); + break; + case 0x9D: + strcat(stri, "undefined or unallocated alternate map register or DMA register set"); + break; + case 0x9E: + strcat(stri, "dedicated DMA channels not supported"); + break; + case 0x9F: + strcat(stri, "specified dedicated DMA channel not supported"); + break; + case 0xA0: + strcat(stri, "no such handle name"); + break; + case 0xA1: + strcat(stri, "a handle found had no name, or duplicate handle name"); + break; + case 0xA2: + strcat(stri, "attempted to wrap around 1M conventional address space"); + break; + case 0xA3: + strcat(stri, "source array corrupted"); + break; + case 0xA4: + strcat(stri, "operating system denied access"); + break; + default: + strcat(stri, "undefined error"); + } +} + +//========================================================================== + +/* +===================== += += MM_BombOnError += +===================== +*/ + +void MM_BombOnError(boolean bomb, global_game_variables_t *gvar) +{ + gvar->mm.bombonerror = bomb; +} + +/*void MM_GetNewBlock(global_game_variables_t *gvar) +{ + if(!gvar->mm.mmfree) + MML_ClearBlock(gvar); + gvar->mm.mmnew=gvar->mm.mmfree; + gvar->mm.mmfree=gvar->mm.mmfree->next; + if(!(gvar->mm.mmnew=gvar->mm.mmfree)) + { + printf("MM_GETNEWBLOCK: No free blocks!\n"); + return; + } + gvar->mm.mmfree=gvar->mm.mmfree->next; +} + +void MM_FreeBlock(mmblocktype *x, global_game_variables_t *gvar) +{ + x->useptr=NULL; + x->next=gvar->mm.mmfree; + gvar->mm.mmfree=x; +}*/ + +/*void MM_seguin(void) +{ + __asm { + push ds + mov ax,ds + inc ax + mov ds,ax + } +} + +void MM_segude(void) +{ + __asm { + pop ds + } +}*/ + +/* +pull data from far and put it into ds var +mov ax,es:si +mov x,ax +*/ +/* +ss stack segment +sp top of stack +bp bottem of stack +*/ diff --git a/DEBUG.16B b/DEBUG.16B index 97df5039..f5605e85 100755 --- a/DEBUG.16B +++ b/DEBUG.16B @@ -1,12 +1,10 @@ -Seg:0 Size:3016 Owner:0x2065 -++++++++++++++++++++++++++++++++++++++0 -Seg:bc8 Size:256 Owner:0xcf79 +Seg:0 Size:3547 Owner:0x696c ++++++++++++++++++++++++++++++++++++++++++++++0 +Seg:ddb Size:256 Owner:0xcf85 ++++ -Seg:cc8 Size:273 Owner:0xfde -+++++0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +Seg:edb Size:273 Owner:0xfde +++++0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Seg:9fde Size:28706 Owner:0x0  -Seg:9ffe Size:16386 Owner:0x0 -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -Seg:e000 Size:8191 Owner:0x0 -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file +Seg:9ffe Size:24577 Owner:0x0 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file diff --git a/DEBUG.16W b/DEBUG.16W index e42fdf08..7e2f4f13 100755 --- a/DEBUG.16W +++ b/DEBUG.16W @@ -1,8 +1,12 @@ -Seg:0 Size:8601 Owner:0x0 +Seg:0 Size:8567 Owner:0xfc7e ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0 -Seg:2199 Size:256 Owner:0x5424 +Seg:2177 Size:256 Owner:0x5428 ++++ -Seg:280e Size:44 Owner:0x0 -+0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -Seg:b83a Size:18373 Owner:0x0 -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file +Seg:2277 Size:17 Owner:0x9480 ++ +Seg:27eb Size:44 Owner:0x0 +++0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +Seg:b817 Size:10217 Owner:0x0 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +Seg:e000 Size:8191 Owner:0x0 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file diff --git a/HEAP.16W b/HEAP.16W index 11a19e83..c5de931a 100755 --- a/HEAP.16W +++ b/HEAP.16W @@ -1,71 +1,47 @@ == default == - FREE block at 2e330016 of size 18 - USED block at 2e330028 of size 136 - USED block at 2e3300b0 of size 50 - USED block at 2e3300e2 of size 50 - USED block at 2e330114 of size 50 - USED block at 2e330146 of size 50 - USED block at 2e330178 of size 50 - USED block at 2e3301aa of size 50 - USED block at 2e3301dc of size 50 - USED block at 2e33020e of size 50 - USED block at 2e330240 of size 50 - USED block at 2e330272 of size 50 - USED block at 2e3302a4 of size 50 - USED block at 2e3302d6 of size 50 - USED block at 2e330308 of size 50 - FREE block at 2e33033a of size 14 - USED block at 2e330348 of size 20 - FREE block at 2e33035c of size 7328 + USED block at 280d0016 of size 66 + USED block at 280d0058 of size 66 + FREE block at 280d009a of size 18 + USED block at 280d00ac of size 136 + USED block at 280d0134 of size 20 + FREE block at 280d0148 of size 7860 OK - end of heap == near == - USED block at 1e32a466 of size 12 - USED block at 1e32a472 of size 330 - USED block at 1e32a5bc of size 52 - USED block at 1e32a5f0 of size 20 - USED block at 1e32a604 of size 20 - USED block at 1e32a618 of size 20 - USED block at 1e32a62c of size 20 - USED block at 1e32a640 of size 20 - USED block at 1e32a654 of size 22952 + USED block at 180c94b6 of size 12 + USED block at 180c94c2 of size 332 + USED block at 180c960e of size 52 + USED block at 180c9642 of size 20 + USED block at 180c9656 of size 20 + USED block at 180c966a of size 20 + USED block at 180c967e of size 20 + USED block at 180c9692 of size 20 + USED block at 180c96a6 of size 26966 OK - end of heap == far == - USED block at 2e330016 of size 18 - USED block at 2e330028 of size 136 - USED block at 2e3300b0 of size 50 - USED block at 2e3300e2 of size 50 - USED block at 2e330114 of size 50 - USED block at 2e330146 of size 50 - USED block at 2e330178 of size 50 - USED block at 2e3301aa of size 50 - USED block at 2e3301dc of size 50 - USED block at 2e33020e of size 50 - USED block at 2e330240 of size 50 - USED block at 2e330272 of size 50 - USED block at 2e3302a4 of size 50 - USED block at 2e3302d6 of size 50 - USED block at 2e330308 of size 50 - USED block at 2e33033a of size 14 - USED block at 2e330348 of size 20 - USED block at 2e33035c of size 7328 + USED block at 280d0016 of size 66 + USED block at 280d0058 of size 66 + USED block at 280d009a of size 18 + USED block at 280d00ac of size 136 + USED block at 280d0134 of size 20 + USED block at 280d0148 of size 7860 OK - end of heap Memory Type Total Used Free ---------------- -------- -------- -------- -Default 8166 806 7360 -Near 23446 494 22952 -Far 8166 806 7360 +Default 8166 288 7878 +Near 27462 496 26966 +Far 8166 288 7878 ---------------- -------- -------- -------- -coreleft = 22950 -farcoreleft = 21944 -GetFreeSize = 64548 -GetNearFreeSize = 22952 -GetFarFreeSize = 64548 -memavl = 22950 -stackavail = 11203 +coreleft = 26964 +farcoreleft = 51072 +GetFreeSize = 24128 +GetNearFreeSize = 26966 +GetFarFreeSize = 24128 +memavl = 26964 +stackavail = 11268 diff --git a/MMDUMP.16B b/MMDUMP.16B index 5bad126273a3882136631318e8e68b81cdb942a7..b9dba4098a7462b56b9604a128c8017cdd85933e 100755 GIT binary patch literal 75 zcmXr0FfcH3u`+OTaaGXJ71UI)RWPzNH09+o07{rRTbWs!IRhnbqe=jEIJ;Sx0wov_ F5&%-f4*UQB literal 75 zcmXr0FfcH3u`+OTaaGXJ71UI)RWLF!FyQ4f07{rRTNxRcnF1wFph^IBIJ=o!0wov_ F5&%ds4zK_K diff --git a/MMDUMP.16W b/MMDUMP.16W index 86d239b00841ce04466efae3ed916a82d1f0cd6a..023a748e760120c2b35dd5d05d472d69bb9208e8 100755 GIT binary patch literal 66 zcmXr0FfcGmu`)F=vQW^_WzbZxRWRV?GJuF$nphYBMFo*WO_HtBlFd_rqUBIg0KR$+ AMF0Q* literal 22 dcmXr0FfcGmu`)F=GEvabWzbZxRWRV?0suDL1PTBE diff --git a/bcexmm.exe b/bcexmm.exe index 88bb916e0afed6d8df51f7e676ee5833b5fe2f42..ebfd740ed727432e13bf8452aa20e4eceeb46292 100755 GIT binary patch delta 37095 zcmcG%2VfLc*FJvR%$6jZP2aRlAP{=*y@w_w(xf9Dr1vH)5Gf(_QKAR}0tzAs(gGqx zKp-ke5d>631PmReh_wAZcV>1I^nKs2{J($n%sltpbI)z(*131NH($xlP=Z@^cGAwI zFUui>c)bG`1=oxCfluULgX)3GgW^CF7WJ>>xonxp4}sQ$-UOwCMuOUcYJ-wM4$xzD zBEJCI2wDW{4=Mq=txV)+K<|MDfzm*)iix}dCgZ{xfJEs3&Mg)I{C`)CROYaw5MU zF_HfW$^=ygeG(3((I_3zuda!FD`+{W6Uaf%TkRkfG?GUs-9fEEJ6VMC0jLq^9*s~o zgE;6H4~bCrfTn|nfr^7dKtHPy$_da+&=62d&;=zzc?UEF6eS{*m-q~&4yZUN3KRgk z!e%HFKvh6?&;>d}*$?^vG!rxs)C{D6PLdgl=R-WEfO>(N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az*X%Q~D2w9{}g&+;LuNc-zSeY}dL0IkgruJg&#n^|jAKub>H{7RpdN2=T zeIEqV&y)KxKY;avm>41VZpa3{A-G!rSJK7fr+E&+Q!%e9!Go2-^^ZIlaz) zb|#+9pR;l~GutE#+bB{ON4PX3NKz$nB7S#(|2RMU4>yyj3_@@l3bP?>r`BQf&6I9( z0v$FjZVbrL1DykG!3nQ&R>quUcN*$emKDph&O{&}treC_fua;)HWJ>Z&G>kWrxO`g LOjew)JF7nc12`#o diff --git a/src/exmmtest.c b/src/exmmtest.c index aa21497e..a1e0391f 100755 --- a/src/exmmtest.c +++ b/src/exmmtest.c @@ -97,9 +97,11 @@ main(int argc, char *argv[]) } //printf("main()=%Fp start MM\n", *argv[0]); MM_Startup(&gvar); +#ifdef __DEBUG_PM__ PM_Startup(&gvar); - PM_CheckMainMem(&gvar); + //PM_CheckMainMem(&gvar); PM_UnlockMainMem(&gvar); +#endif CA_Startup(&gvar); // printf(" done!\n"); PRINTBB; @@ -144,8 +146,12 @@ for(w=0;w<2;w++) #ifdef FILEREAD } #endif + printf("bakapee1=%s\n", bakapee1); + printf("bakapee2=%s\n", bakapee2); MM_FreePtr(&bigbuffer, &gvar); +#ifdef __DEBUG_PM__ PM_Shutdown(&gvar); +#endif CA_Shutdown(&gvar); MM_Shutdown(&gvar); free(bakapee1); free(bakapee2); diff --git a/src/lib/16_head.h b/src/lib/16_head.h index 0155c81e..ec7db9f8 100755 --- a/src/lib/16_head.h +++ b/src/lib/16_head.h @@ -152,7 +152,7 @@ static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ extern int profilehandle,debughandle; //make it into game global #define __DEBUG__ -#define __DEBUG_PM__ +//0000#define __DEBUG_PM__ #define nil ((void *)0) #ifdef __BORLANDC__ @@ -199,7 +199,6 @@ int US_CheckParm(char *parm,char **strings); #ifdef __BORLANDC__ void Quit (char *error); #endif -void XMS_CALL(byte v, global_game_variables_t *gvar); byte dirchar(byte in); #endif/*_LIBHEAD_H_*/ diff --git a/src/lib/16_mm.c b/src/lib/16_mm.c index 5f5b6444..9eb93c67 100755 --- a/src/lib/16_mm.c +++ b/src/lib/16_mm.c @@ -1,1808 +1,1817 @@ -/* Catacomb Apocalypse Source Code - * Copyright (C) 1993-2014 Flat Rock Software - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -// NEWMM.C - -/* -============================================================================= - - ID software memory manager - -------------------------- - -Primary coder: John Carmack - -RELIES ON ---------- -Quit (char *error) function - - -WORK TO DO ----------- -MM_SizePtr to change the size of a given pointer - -Multiple purge levels utilized - -EMS / XMS unmanaged routines - -============================================================================= -*/ -/* - -Open Watcom port by sparky4 - -*/ -#include "src/lib/16_mm.h" -#include "src/lib/16_ca.h" -#pragma hdrstop - -#pragma warn -pro -#pragma warn -use - -/* -============================================================================= - - GLOBAL VARIABLES - -============================================================================= -*/ - -void (* beforesort) (void); -void (* aftersort) (void); -void (* XMSaddr) (void); // far pointer to XMS driver - -/* -============================================================================= - - LOCAL VARIABLES - -============================================================================= -*/ - -/* -====================== -= -= MML_CheckForEMS -= -= Routine from p36 of Extending DOS -= -======================= -*/ - -boolean MML_CheckForEMS(void) -{ - boolean emmcfems; - static char emmname[] = "EMMXXXX0"; //fix by andrius4669 - __asm { - mov dx,OFFSET emmname //fix by andrius4669 - mov ax,0x3d00 - int 0x21 // try to open EMMXXXX0 device - jc error - - mov bx,ax - mov ax,0x4400 - - int 0x21 // get device info - jc error - - and dx,0x80 - jz error - - mov ax,0x4407 - - int 0x21 // get status - jc error - or al,al - jz error - - mov ah,0x3e - int 0x21 // close handle - jc error - // - // EMS is good - // - mov emmcfems,1 - jmp End -#ifdef __BORLANDC__ - } -#endif - error: -#ifdef __BORLANDC__ - __asm { -#endif - // - // EMS is bad - // - mov emmcfems,0 -#ifdef __BORLANDC__ - } -#endif - End: -#ifdef __WATCOMC__ - } -#endif - return(emmcfems); -} - - -/* -====================== -= -= MML_SetupEMS -= -======================= -*/ - -byte MML_SetupEMS(global_game_variables_t *gvar) -{ - byte str[160]; - byte err; - boolean errorflag=false; - - unsigned int EMSVer = 0; - //byte EMS_status; - unsigned totalEMSpages,freeEMSpages,EMSPageFrame,EMSpagesmapped,EMSHandle; - totalEMSpages = freeEMSpages = EMSPageFrame = EMSpagesmapped = 0; - - __asm { - mov ah,EMS_STATUS - int EMS_INT // make sure EMS hardware is present - or ah,ah - //mov [EMS_status],ah - jnz error - - mov ah,EMS_VERSION - int EMS_INT - or ah,ah - jnz error - mov [EMSVer],ax // set EMSVer - cmp al,0x32 // only work on ems 3.2 or greater - jb error - - mov ah,EMS_GETFRAME - int EMS_INT // find the page frame address - or ah,ah - jnz error - mov [EMSPageFrame],bx - - mov ah,EMS_GETPAGES - int EMS_INT // find out how much EMS is there - or ah,ah - jnz error - mov [totalEMSpages],dx - mov [freeEMSpages],bx - or bx,bx - jz noEMS // no EMS at all to allocate - //EXPAND DONG!!!! - cmp [EMSVer],0x40 - jb low - cmp bx,[freeEMSpages] - jle getpages - mov bx,[freeEMSpages] - jmp getpages -#ifdef __BORLANDC__ - } -#endif - low: -#ifdef __BORLANDC__ - __asm { -#endif - cmp bx,4 - jle getpages // there is only 1,2,3,or 4 pages - mov bx,4 // we can't use more than 4 pages -#ifdef __BORLANDC__ - } -#endif - getpages: -#ifdef __BORLANDC__ - __asm { -#endif - mov [EMSpagesmapped],bx - mov ah,EMS_ALLOCPAGES // allocate up to 64k of EMS - int EMS_INT - or ah,ah - jnz error - mov [EMSHandle],dx - jmp End -#ifdef __BORLANDC__ - } -#endif - error: -#ifdef __BORLANDC__ - __asm { -#endif - mov err,ah - mov errorflag,1 - jmp End -#ifdef __BORLANDC__ - } -#endif -noEMS: -End: -#ifdef __WATCOMC__ - } -#endif - if(errorflag==true) - { - strcpy(str,"MM_SetupEMS: EMS error "); - MM_EMSerr(str, err); - printf("%s\n",str); - return err; - } - gvar->pm.emm.totalEMSpages=totalEMSpages; - gvar->pm.emm.freeEMSpages=freeEMSpages; - gvar->pm.emm.EMSPageFrame=EMSPageFrame; - gvar->pm.emm.EMSpagesmapped=EMSpagesmapped; - gvar->pm.emm.EMSHandle=EMSHandle; - gvar->pm.emm.EMSVer=EMSVer; - return 0; -} - - -/* -====================== -= -= MML_ShutdownEMS -= -======================= -*/ - -void MML_ShutdownEMS(global_game_variables_t *gvar) -{ - boolean errorflag=false; - unsigned EMSHandle=gvar->pm.emm.EMSHandle; - - if(!EMSHandle) - return; - __asm { - mov ah,EMS_FREEPAGES - mov dx,[EMSHandle] - int EMS_INT - or ah,ah - jz ok - mov errorflag,1 -#ifdef __BORLANDC__ - } -#endif - ok: -#ifdef __WATCOMC__ - } -#endif - if(errorflag==true) - Quit("MML_ShutdownEMS: Error freeing EMS!\n"); //++++ add something -} - -/* -==================== -= -= MM_MapEMS -= -= Maps the 64k of EMS used by memory manager into the page frame -= for general use. This only needs to be called if you are keeping -= other things in EMS. -= -==================== -*/ - -byte MM_MapEMS(global_game_variables_t *gvar) -{ - byte str[160]; - unsigned EMSHandle; - byte err; - boolean errorflag=false; - int i; - EMSHandle=gvar->pm.emm.EMSHandle; - - for (i=0;i<4/*MAPPAGES*/;i++) - { - __asm { - mov ah,EMS_MAPPAGE - mov bx,[i] // logical page - mov al,bl // physical page - mov dx,[EMSHandle] // handle - int EMS_INT - or ah,ah - jnz error - jmp End -#ifdef __BORLANDC__ - } -#endif - error: -#ifdef __BORLANDC__ - __asm { -#endif - mov err,ah - mov errorflag,1 -#ifdef __BORLANDC__ - } -#endif - End: -#ifdef __WATCOMC__ - } -#endif - if(errorflag==true) - { - strcpy(str,"MM_MapEMS: EMS error "); - MM_EMSerr(str, err); - printf("%s\n",str); - return err; - } - } - gvar->mmi.EMSmem = (i)*0x4000lu; - //printf(" gvar->mmi.EMSmem=%lu\n", gvar->mmi.EMSmem); - return 0; -} - -byte MM_MapXEMS(global_game_variables_t *gvar) -{ -//SUB EMS.MapXPages (PhysicalStart, LogicalStart, NumPages, Handle) - - //Maps up to 4 logical EMS pages to physical pages in the page frame, where: - //PhysicalStart = Physical page first logical page is mapped to - //LogicalStart = First logical page to map - //NumPages = Number of pages to map (1 to 4) - //Handle = EMS handle logical pages are allocated to - - /*//Create a buffer containing the page information -// FOR x = 0 TO NumPages - 1 -// MapInfo$ = MapInfo$ + MKI$(LogicalStart + x) + MKI$(PhysicalStart + x) -// NEXT*/ - -// Regs.ax = 0x5000 //Map the pages in the buffer -// Regs.cx = NumPages //to the pageframe -// Regs.dx = Handle -// Regs.ds = VARSEG(MapInfo$) -// Regs.si = SADD(MapInfo$) -// InterruptX 0x67, Regs, Regs -// EMS.Error = (Regs.ax AND 0xFF00&) \ 0x100 //Store the status code - -//END SUB - byte str[160]; - byte err; - word EMSHandle; - boolean errorflag=false; - int i; - EMSHandle=gvar->pm.emm.EMSHandle; - - if(gvar->pm.emm.EMSVer<0x40) - return 5; - - for (i=0;immi.EMSmem = (i)*0x4000lu; - return 0; -} - -//========================================================================== - -/* -====================== -= -= MML_CheckForXMS -= -= Check for XMM driver -= -======================= -*/ - -boolean MML_CheckForXMS(global_game_variables_t *gvar) -{ - boolean errorflag=false; - gvar->mm.numUMBs = 0; - - __asm { - mov ax,0x4300 - int 0x2f // query status of installed diver - cmp al,0x80 - je good - mov errorflag,1 -#ifdef __BORLANDC__ - } -#endif - good: -#ifdef __WATCOMC__ - } -#endif - if(errorflag==true) return false; - else return true; -} - - -/* -====================== -= -= MML_SetupXMS -= -= Try to allocate all upper memory block -= -======================= -*/ - -void MML_SetupXMS(global_game_variables_t *gvar) -{ - word base,size; - - - __asm { - mov ax,0x4310 - int 0x2f - mov [WORD PTR XMSaddr],bx - mov [WORD PTR XMSaddr+2],es // function pointer to XMS driver - } -getmemory: - __asm { - mov ah,XMS_ALLOCUMB - mov dx,0xffff // try for largest block possible - //mov ax,dx // Set available Kbytes. - call [DWORD PTR XMSaddr] - or ax,ax - jnz gotone - - cmp bl,0xb0 // error: smaller UMB is available - jne done; - - mov ah,XMS_ALLOCUMB - call [DWORD PTR XMSaddr] // DX holds largest available UMB - or ax,ax - jz done // another error... -#ifdef __BORLANDC__ - } -#endif - gotone: -#ifdef __BORLANDC__ - __asm { -#endif - mov [base],bx - mov [size],dx -#ifdef __BORLANDC__ - } -#endif - done: -#ifdef __WATCOMC__ - } -#endif -// printf("base=%u ", base); printf("size=%u\n", size); - MML_UseSpace(base,size, gvar); - gvar->mmi.XMSmem += size*16; - gvar->mm.UMBbase[gvar->mm.numUMBs] = base; - gvar->mm.numUMBs++; - if(gvar->mm.numUMBs < MAXUMBS) - goto getmemory; -} - - -/* -====================== -= -= MML_ShutdownXMS -= -====================== -*/ - -void MML_ShutdownXMS(global_game_variables_t *gvar) -{ - int i; - unsigned base; - - for (i=0;imm.numUMBs;i++) - { - base = gvar->mm.UMBbase[i]; - __asm { - mov ah,XMS_FREEUMB - mov dx,[base] - call [DWORD PTR XMSaddr] - } - } -} - -//========================================================================== - -/* -====================== -= -= MML_UseSpace -= -= Marks a range of paragraphs as usable by the memory manager -= This is used to mark space for the near heap, far heap, ems page frame, -= and upper memory blocks -= -====================== -*/ - -/*void MML_UseSpace(word segstart, dword seglength, global_game_variables_t *gvar) -{ - //huge mmblocktype huge *scan,huge *last; - word segm=1; - word oldend; - dword segmlen; - dword extra; - - scan = last = gvar->mm.mmhead; - gvar->mm.mmrover = gvar->mm.mmhead; // reset rover to start of memory - -// -// search for the block that contains the range of segments -// - while(scan->start+scan->length < segstart) - { - last = scan; - scan = scan->next; - } - -// -// take the given range out of the block -// - oldend = scan->start + scan->length; - extra = oldend - (segstart+seglength); - - segmlen=extra; - - //++++emsver stuff! - if(segm>1)/// || extra>=0x10000lu) - //if(extra>0xfffflu) - { - scan->blob=segm; - - //MML_UseSpace(segstart, seglength, gvar); - - printf("MML_UseSpace: Segment spans two blocks!\n"); - //} - printf("segm=%u ", segm); - printf("ex=%lu ", extra); - printf("old=%u ", oldend); - printf("start+seglen=%lu\n", segstart+seglength); - printf("segsta=%x ", segstart); - printf("len=%lu ", scan->length); - printf("seglen=%lu ", seglength); - printf("segmlen=%lu\n", segmlen); - } -//++++todo: linked list of segment! - if(segstart == scan->start) - { - last->next = scan->next; // unlink block - FREEBLOCK(scan); - scan = last; - } - else - scan->length = segstart-scan->start; // shorten block - - if(extra > 0) - { - GETNEWBLOCK; - gvar->mm.mmnew->useptr = NULL; - - gvar->mm.mmnew->next = scan->next; - scan->next = gvar->mm.mmnew; - gvar->mm.mmnew->start = segstart+seglength; - gvar->mm.mmnew->length = extra; - gvar->mm.mmnew->attributes = LOCKBIT; - }//else if(segm>0) goto segu; - -}*/ -void MML_UseSpace(word segstart, dword seglength, global_game_variables_t *gvar) -{ - mmblocktype far *scan,far *last; - word oldend; - sdword extra; - //word segm=1; - - scan = last = gvar->mm.mmhead; - gvar->mm.mmrover = gvar->mm.mmhead; // reset rover to start of memory - -// -// search for the block that contains the range of segments -// - while (scan->start+scan->length < segstart) - { - last = scan; - scan = scan->next; - } - -// -// find out how many blocks it spans! -// - /*for(;seglength>=0x10000;seglength-=0xFFFF) - { - //printf(" seglen=%lu\n", segmlen); - segm++; - }*/ - -// -// take the given range out of the block -// - oldend = scan->start + scan->length; - extra = oldend - (segstart+((unsigned)seglength)); - if (extra < 0) - { - printf("========================================\n"); - printf("start=%x ", scan->start); - printf("old=%u ", oldend); - printf("start+seglen=%lu\n", segstart+seglength); - printf("segsta=%x ", segstart); - printf("len=%lu ", scan->length); - printf("seglen=%lu ", seglength); - printf("\n"); - printf("MML_UseSpace: Segment spans two blocks! %d\n", extra); - printf("========================================\n"); - //return; - } - - if (segstart == scan->start) - { - last->next = scan->next; // unlink block - FREEBLOCK(scan); - scan = last; - } - else - scan->length = segstart-scan->start; // shorten block - - if (extra > 0) - { - GETNEWBLOCK; - gvar->mm.mmnew->useptr = NULL; - - gvar->mm.mmnew->next = scan->next; - scan->next = gvar->mm.mmnew; - gvar->mm.mmnew->start = segstart+seglength; - gvar->mm.mmnew->length = extra; - gvar->mm.mmnew->attributes = LOCKBIT; - } - -} - -//========================================================================== - -/* -==================== -= -= MML_ClearBlock -= -= We are out of blocks, so free a purgable block -= -==================== -*/ - -void MML_ClearBlock(global_game_variables_t *gvar) -{ - //huge mmblocktype huge *scan,huge *last; - mmblocktype far *scan,far *last; - - scan = gvar->mm.mmhead->next; - - while(scan) - { - if(!(scan->attributes&LOCKBIT) && (scan->attributes&PURGEBITS)) - { - MM_FreePtr(scan->useptr, gvar); - return; - } - scan = scan->next; - } - - printf("MM_ClearBlock: No purgable blocks!\n"); -} - - -//========================================================================== - -/* -=================== -= -= MM_Startup -= -= Grabs all space from turbo with malloc/farmalloc -= Allocates bufferseg misc buffer -= -=================== -*/ - -void MM_Startup(global_game_variables_t *gvar) -{ - int i; - //dword length,seglength; - dword length; - //huge void huge *start; - void far *start; - word segstart,seglength,endfree; - //memptr *peeonself; - - if(gvar->mm.mmstarted) - MM_Shutdown(gvar); - - - gvar->mm.mmstarted = true; - gvar->mm.bombonerror = true; -// -// set up the linked list (everything in the free list; -// - 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; - -// -// locked block of all memory until we punch out free space -// - GETNEWBLOCK; - gvar->mm.mmhead = gvar->mm.mmnew; // this will allways be the first node - gvar->mm.mmnew->start = 0; - 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)); - printf("Borland C unique function\n"); - printf(" coreleft() %lu\n", coreleft()); -#endif - length -= 16-(FP_OFF(start)&15); - length -= SAVENEARHEAP; - seglength = length / 16; // now in paragraphs - segstart = FP_SEG(start)+(FP_OFF(start)+15)/16; - MML_UseSpace(segstart,seglength, gvar); - gvar->mmi.nearheap = length; - //printf("start=%Fp segstart=%x seglen=%lu len=%lu\n", start, segstart, seglength, length); - -// -// get all available far conventional memory segments -// - //printf("_FARCORELEFT %lu\n", _FCORELEFT); -#ifdef __WATCOMC__ - _fheapgrow(); -#endif -#ifdef __BORLANDC__ - printf(" farcoreleft() %lu\n", farcoreleft()); - printf(" (farcoreleft()+32)-_FCORELEFT %d\n", (sword)((farcoreleft()+32)-_FCORELEFT)); -#endif - length=_FCORELEFT;//_fcoreleft();//(dword)GetFarFreeSize();//0xffffUL*4UL; - start = gvar->mm.farheap = _fmalloc(length); - //start = gvar->mm.farheap = halloc(length, 1); - length -= 16-(FP_OFF(start)&15); - length -= SAVEFARHEAP; - seglength = length / 16; // now in paragraphs - segstart = FP_SEG(start)+(FP_OFF(start)+15)/16; - MML_UseSpace(segstart,seglength, gvar); - gvar->mmi.farheap = length; - gvar->mmi.mainmem = gvar->mmi.nearheap + gvar->mmi.farheap; - //printf("start=%Fp segstart=%x seglen=%lu len=%lu\n", start, segstart, seglength, length); - -goto xmsskip; //INFO: 16_PM dose this job better - -// -// detect EMS and allocate up to 64K at page frame -// - gvar->mmi.EMSmem = 0; -//goto emsskip; //0000 - if(MML_CheckForEMS()) - { - MML_SetupEMS(gvar); // allocate space - //TODO: EMS4! AND EMS 3.2 MASSIVE DATA HANDLMENT! - MML_UseSpace(gvar->pm.emm.EMSPageFrame,(MAPPAGES)*0x4000lu, gvar); - //if(gvar->pm.emm.EMSVer<0x40) - MM_MapEMS(gvar); // map in used pages - //else - //MM_MapXEMS(gvar); // map in used pages - } - -// -// detect XMS and get upper memory blocks -// -//emsskip: - gvar->mmi.XMSmem = 0; -//goto xmsskip;//0000 - if(MML_CheckForXMS(gvar)) - { - MML_SetupXMS(gvar); // allocate as many UMBs as possible - } - -// -// allocate the misc buffer -// -xmsskip: - gvar->mm.mmrover = gvar->mm.mmhead; // start looking for space after low block - - MM_GetPtr(&(gvar->mm.bufferseg),BUFFERSIZE, gvar); -} - -//========================================================================== - -/* -==================== -= -= MM_Shutdown -= -= Frees all conventional, EMS, and XMS allocated -= -==================== -*/ - -void MM_Shutdown(global_game_variables_t *gvar) -{ - if(!(gvar->mm.mmstarted)) - return; - - _ffree(gvar->mm.farheap);// printf(" far freed\n"); -#ifdef __WATCOMC__ - _nfree(gvar->mm.nearheap);// printf(" near freed\n"); -#endif -#ifdef __BORLANDC__ - free(gvar->mm.nearheap);// printf(" near freed\n"); -#endif - if(MML_CheckForEMS()){ MML_ShutdownEMS(gvar); }//printf(" EMS freed\n"); } - if(MML_CheckForXMS(gvar)){ MML_ShutdownXMS(gvar); }//printf(" XMS freed\n"); } -} - -//========================================================================== - -/* -==================== -= -= MM_GetPtr -= -= Allocates an unlocked, unpurgable block -= -==================== -*/ - -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; - - needed = (size+15)/16; // convert size from bytes to paragraphs - - GETNEWBLOCK; // fill in start and next after a spot is found - gvar->mm.mmnew->length = needed; - gvar->mm.mmnew->useptr = baseptr; - //if(gvar->mm.mmnew->useptr==NULL){ -#ifdef __DEBUG__ - printf(" MM_GetPtr\n"); - 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)); -#endif - //exit(-5); } - gvar->mm.mmnew->attributes = BASEATTRIBUTES; - -//tryagain: - for (search = 0; search<3; search++) - { - // - // first search: try to allocate right after the rover, then on up - // second search: search from the head pointer up to the rover - // third search: compress memory, then scan from start - if (search == 1 && gvar->mm.mmrover == gvar->mm.mmhead) - search++; - - switch (search) - { - case 0: - lastscan = gvar->mm.mmrover; - scan = gvar->mm.mmrover->next; - endscan = NULL; - break; - case 1: - lastscan = gvar->mm.mmhead; - scan = gvar->mm.mmhead->next; - endscan = gvar->mm.mmrover; - break; - case 2: - MM_SortMem (gvar); - lastscan = gvar->mm.mmhead; - scan = gvar->mm.mmhead->next; - endscan = NULL; - break; - } - - startseg = lastscan->start + lastscan->length; - - while (scan != endscan) - { - if (scan->start - startseg >= needed) - { - // - // got enough space between the end of lastscan and - // the start of scan, so throw out anything in the middle - // and allocate the new block - // - purge = lastscan->next; - lastscan->next = gvar->mm.mmnew; - gvar->mm.mmnew->start = *(unsigned *)baseptr = startseg; - gvar->mm.mmnew->next = scan; - while ( purge != scan) - { // free the purgable block - next = purge->next; - FREEBLOCK(purge); - purge = next; // purge another if not at scan - } - gvar->mm.mmrover = gvar->mm.mmnew; - return; // good allocation! - } - - // - // if this block is purge level zero or locked, skip past it - // - if ( (scan->attributes & LOCKBIT) - || !(scan->attributes & PURGEBITS) ) - { - lastscan = scan; - startseg = lastscan->start + lastscan->length; - } - - - scan=scan->next; // look at next line - } - } - - if (gvar->mm.bombonerror) - { -#ifdef __WATCOMC__ - //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); - } - else - gvar->mm.mmerror = true; -} - -//========================================================================== - -/* -==================== -= -= MM_FreePtr -= -= Allocates an unlocked, unpurgable block -= -==================== -*/ - -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; - scan = last->next; - - if(baseptr == gvar->mm.mmrover->useptr) // removed the last allocated block - gvar->mm.mmrover = gvar->mm.mmhead; - - while(scan->useptr != baseptr && scan) - { - last = scan; - scan = scan->next; - } - - if(!scan) - { - printf("MM_FreePtr: Block not found!\n"); - return; - } - - last->next = scan->next; - - FREEBLOCK(scan); -} -//========================================================================== - -/* -===================== -= -= MM_SetPurge -= -= Sets the purge level for a block (locked blocks cannot be made purgable) -= -===================== -*/ - -void MM_SetPurge(memptr *baseptr, int purge, global_game_variables_t *gvar) -{ - mmblocktype huge *start; - //mmblocktype far *start; - - start = gvar->mm.mmrover; - - do - { - if(gvar->mm.mmrover->useptr == baseptr) - break; - - gvar->mm.mmrover = gvar->mm.mmrover->next; - - if(!gvar->mm.mmrover) - gvar->mm.mmrover = gvar->mm.mmhead; - else if(gvar->mm.mmrover == start) - { -#ifdef __DEBUG_PM__ - printf("\n\nstart->useptr gvar->mm.mmhead->useptr\n"); - printf(" %Fp %Fp\n", start->useptr, gvar->mm.mmhead->useptr); - printf("& %Fp %Fp\n", &(start->useptr), &(gvar->mm.mmhead->useptr)); - printf("baseptr gvar->mm.mmrover->useptr\n"); - printf(" %Fp %Fp\n", baseptr, gvar->mm.mmrover->useptr); - printf("& %Fp %Fp\n", &(baseptr), &(gvar->mm.mmrover->useptr)); - printf("* %Fp %Fp\n", *(baseptr), *(gvar->mm.mmrover->useptr)); - printf("start gvar->mm.mmrover gvar->mm.mmrover->next\n"); - printf(" %Fp %Fp %Fp\n", start, gvar->mm.mmrover, gvar->mm.mmrover->next); - printf("& %Fp %Fp %Fp\n", &start, &gvar->mm.mmrover, gvar->mm.mmrover->next); - getch(); - MM_ShowMemory(gvar); - MM_DumpData(gvar); - MM_Report_(gvar); - getch(); -#endif - Quit("MM_SetPurge: Block not found!"); - return; - } - - } while(1); - - gvar->mm.mmrover->attributes &= ~PURGEBITS; - gvar->mm.mmrover->attributes |= purge; -} - -//========================================================================== - -/* -===================== -= -= MM_SetLock -= -= Locks / unlocks the block -= -===================== -*/ - -void MM_SetLock(memptr *baseptr, boolean locked, global_game_variables_t *gvar) -{ - //huge mmblocktype huge *start; - mmblocktype far *start; - - start = gvar->mm.mmrover; - - do - { - if(gvar->mm.mmrover->useptr == baseptr) - break; - - gvar->mm.mmrover = gvar->mm.mmrover->next; - - if(!gvar->mm.mmrover) - gvar->mm.mmrover = gvar->mm.mmhead; - else if(gvar->mm.mmrover == start) - { - Quit("MM_SetLock: Block not found!"); - //return; - } - - } while(1); - - gvar->mm.mmrover->attributes &= ~LOCKBIT; - gvar->mm.mmrover->attributes |= locked*LOCKBIT; -} - -//========================================================================== - -/* -===================== -= -= MM_SortMem -= -= Throws out all purgable stuff and compresses movable blocks -= -===================== -*/ - -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; - - // - // lock down a currently playing sound - // -/*++++ playing = SD_SoundPlaying (); - if(playing) - { - switch (SoundMode) - { - case sdm_PC: - playing += STARTPCSOUNDS; - break; - case sdm_AdLib: - playing += STARTADLIBSOUNDS; - break; - } - MM_SetLock(&(memptr)audiosegs[playing],true); - } - - - SD_StopSound();*/ -// oldborder = bordercolor; -// VW_ColorBorder (15); - - if(beforesort) - beforesort(); - - scan = gvar->mm.mmhead; - - last = NULL; // shut up compiler warning - - while(scan) - { - if(scan->attributes & LOCKBIT) - { - // - // block is locked, so try to pile later blocks right after it - // - start = scan->start + scan->length; - } - else - { - if(scan->attributes & PURGEBITS) - { - // - // throw out the purgable block - // - next = scan->next; - FREEBLOCK(scan); - //MM_FreeBlock(scan, gvar); - last->next = next; - scan = next; - continue; - } - else - { - // - // push the non purgable block on top of the last moved block - // - if(scan->start != start) - { - length = scan->length; - source = scan->start; - dest = start; - while(length > 0xf00) - { - movedata(source,0,dest,0,0xf00*16); - length -= 0xf00; - source += 0xf00; - dest += 0xf00; - } - movedata(source,0,dest,0,length*16); - - scan->start = start; - *(unsigned *)scan->useptr = start; - } - start = scan->start + scan->length; - } - } - - last = scan; - scan = scan->next; // go to next block - } - - gvar->mm.mmrover = gvar->mm.mmhead; - - if(aftersort) - aftersort(); - -// VW_ColorBorder (oldborder); - -/*++++ if(playing) - MM_SetLock(&(memptr)audiosegs[playing],false);*/ -} - -//========================================================================== - -/* -===================== -= -= MM_ShowMemory -= -===================== -*/ - -void MM_ShowMemory(global_game_variables_t *gvar) -{ - //huge mmblocktype huge *scan; - mmblocktype far *scan; - word temp; - sdword end,owner; - //word chx,chy; - word w; - //dword wwww; - byte scratch[160],scratch0[4096],scratch1[160],str[16]; - //byte d = '#'; -//**** VW_SetDefaultColors(); -//**** VW_SetLineWidth(40); -//++++mh temp = bufferofs; -//++++mh bufferofs = 0; -//**** VW_SetScreen (0,0); - scan = gvar->mm.mmhead; - end = -1; - - CA_OpenDebug (gvar); - w=0; - while(scan) - { - strcpy(scratch, AARESET); - if(scan->attributes & PURGEBITS) - strcpy(scratch0, AAMAGENTA); // dark purple = purgable - else - strcpy(scratch0, AABLUE); // medium blue = non purgable - if(scan->attributes & LOCKBIT) - strcpy(scratch0, AARED); // red = locked - if(scan->start<=end) - { - printf("\nend==%d\n\n", end); - strcat(scratch, "MM_ShowMemory: Memory block order currupted!\n"); - strcat(scratch, "End's Size: "); - ultoa (end,str,10); - strcat (scratch,str); - strcat(scratch, "\nscan->start's Size: "); - ultoa (scan->start,str,10); - strcat (scratch,str); - write(gvar->handle.debughandle,scratch,strlen(scratch)); - //modexprint(&page, chx, chy, 1, 0, 24, "\nMM_ShowMemory: Memory block order currupted!\n"); - break; - } - end = scan->start+(scan->length)-1; -//++++ chy = scan->start/320; -//++++ chx = scan->start%320; - //modexhlin(page, scan->start, (unsigned)end, chy, color); - //for(chx=scan->start;chx+4>=(word)end;chx+=4) - //{ -//++++ modexClearRegion(page, chx, chy, 4, 4, color); - //} -//++++ VW_Hlin(scan->start,(unsigned)end,0,color); - for(w=(scan->start)/80;w<=end/80;w++) - { - //printf("+ %u %lu\n", w, scan->length); - strcat(scratch0, "+"); - } - //++==++==optional strcat(scratch0, AARESET); strcat(scratch0, AAGREY); strcat(scratch0,"_"); -//++++ VW_Plot(scan->start,0,15); -//++++ modexClearRegion(page, chx, chy, 4, 4, 15); -//++++ VW_Hlin(end+1,scan->next->start,0,0); // black = free - - //wwww=(dword)(scan->next->start)-(dword)scan->start; - //wwww=(dword)scan->start+(dword)(scan->next->start); - if (scan->next && scan->next->start >= end+1) - { - strcat(scratch0, AARESET); - //++==++==optional strcat(scratch0, "\n"); - strcat(scratch0,AAGREEN); - for(w=(end+1)/80;w<=((scan->next->start-scan->start)/80);w++) - //for(w=(wwww)/80;w<=((end+1)/80);w++) - //for(w=(end+1)/80;w<=((wwww)/80);w++) - { - //printf("0 %x %u %lu\n", scan->next->start, w, scan->length); - strcat(scratch0,"0"); - } - //printf("==================\n"); - //printf("w=%u wwww=%lu start=%04x next=%04x end=%lu\n", w/80, wwww/80, scan->start, (scan->next->start), end+1); - //printf("==================\n"); - strcat(scratch0, "\n"); - //getch(); - }/*else {//if(scan->next->start <= scan->start){ - scan->next->start=scan->start+0x1000; - wwww=(dword)(scan->next->start)-(dword)scan->start; - strcat(scratch0, AARESET); - strcat(scratch0, "\n"); - strcat(scratch0,AAGREEN); - for(w=(end+1);w<=(0x1000/80);w++) - { - //printf("0 %x %x %u\n", scan->start, w); - strcat(scratch0,"0"); - } - printf("================\n"); - printf("w=%x start=%x next=%x end=%u %lu\n", w, scan->start, (scan->next->start), end+1, wwww); - printf("================\n"); - getch(); - }*/ - strcat(scratch0, AARESET); - //strcat(scratch0,"\n"); - //for(chx=scan->next->start;chx+4>=(word)end+1;chx+=4) - //{ -// chx+=scan->next->start; -// modexClearRegion(page, chx, chy, 4, 4, 2); - //} - //modexhlin(page, end+1,scan->next->start, chy, 0); -/* y = scan->start/320; - x = scan->start%320; - VW_Hlin(x,x+end,y,color); - VW_Plot(x,y,15);*/ -//++++ VW_Hlin(x+end+1,x+(scan->next->start-scan->start),y,0); // black = free - strcat(scratch,"Seg:"); - ultoa (scan->start,str,16); - strcat (scratch,str); - strcat (scratch,"\tSize:"); - ultoa ((unsigned)scan->length,str,10); - strcat (scratch,str); - strcat (scratch,"\tOwner:0x"); - owner = (unsigned)scan->useptr; - ultoa (owner,str,16); - strcat (scratch,str); - strcat (scratch,"\n"); - write(gvar->handle.debughandle,scratch,strlen(scratch)); - write(gvar->handle.debughandle,scratch0,strlen(scratch0)); -//modexprint(page, chx, chy, 1, 0, 24, &scratch); -//++++chy+=4; -//fprintf(stdout, "%s", scratch); - - scan = scan->next; - } - /*strcpy(scratch1, AARESET); - strcat(scratch1, "========================================\n"); - strcat(scratch1, "near= "); - ultoa (*(gvar->mm.nearheap),str,10); - strcat (scratch1,str); - strcat(scratch1, " far= "); - ultoa (*(gvar->mm.farheap),str,10); - strcat (scratch1,str); - strcat(scratch1, "\n"); - //strcat(scratch1, "&near= %Fp ", &(gvar->mm.nearheap)); - //strcat(scratch1, "&far= %Fp", &(gvar->mm.farheap)); - //strcat(scratch1, "\n"); - strcat(scratch1, "========================================\n"); - write(gvar->handle.debughandle,scratch1,strlen(scratch1));*/ - - - CA_CloseDebug (gvar); - -//++++mh IN_Ack(); -//**** VW_SetLineWidth(64); -//++++mh bufferofs = temp; -} - -//========================================================================== - -/* -===================== -= -= MM_DumpData -= -===================== -*/ - -void MM_DumpData(global_game_variables_t *gvar) -{ - //huge mmblocktype huge *scan,huge *best; - mmblocktype far *scan,far *best; - long lowest,oldlowest; - word owner; - byte lock,purge; - FILE *dumpfile; - - free(gvar->mm.nearheap); -#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; - } - - lowest = -1; - do - { - oldlowest = lowest; - lowest = 0xffff; - - scan = gvar->mm.mmhead; - while (scan) - { - owner = (unsigned)scan->useptr; - - if (owner && owner oldlowest) - { - best = scan; - lowest = owner; - } - - scan = scan->next; - } - - if (lowest != 0xffff) - { - if (best->attributes & PURGEBITS) - purge = 'P'; - else - purge = '-'; - if (best->attributes & LOCKBIT) - lock = 'L'; - else - lock = '-'; - fprintf (dumpfile,"0x%p (%c%c) = %u\n" - ,(unsigned)lowest,lock,purge,best->length); - } - - } while (lowest != 0xffff); - - fclose(dumpfile); - printf("MMDUMP.16 created.\n"); -} - -//========================================================================== - - -/* -====================== -= -= MM_UnusedMemory -= -= Returns the total free space without purging -= -====================== -*/ - -dword MM_UnusedMemory(global_game_variables_t *gvar) -{ - dword free; - //huge mmblocktype huge *scan; - mmblocktype far *scan; - - free = 0; - scan = gvar->mm.mmhead; - - while(scan->next) - { - free += scan->next->start - (scan->start + scan->length); - scan = scan->next; - } - - return free*16lu; -// return free; -} - -//========================================================================== - - -/* -====================== -= -= MM_TotalFree -= -= Returns the total free space with purging -= -====================== -*/ - -dword MM_TotalFree(global_game_variables_t *gvar) -{ - dword free; - //huge mmblocktype huge *scan; - mmblocktype far *scan; - - free = 0; - scan = gvar->mm.mmhead; - - while(scan->next) - { - if((scan->attributes&PURGEBITS) && !(scan->attributes&LOCKBIT)) - free += scan->length; - free += scan->next->start - (scan->start + scan->length); - scan = scan->next; - } - - return free*16lu; -// return free; -} - -//========================================================================== - -/* -===================== -= -= MM_Report -= -===================== -*/ - -void MM_Report_(global_game_variables_t *gvar) -{ - printf("========================================\n"); - printf(" MM_Report\n"); - printf("========================================\n"); - if(MML_CheckForEMS()) - { - printf(" LIMEMS\n"); - printf(" EMM v%x.%x available\n", gvar->pm.emm.EMSVer>>4,gvar->pm.emm.EMSVer&0x0F); - printf(" totalEMSpages: %u ", gvar->pm.emm.totalEMSpages); printf("freeEMSpages: %u\n", gvar->pm.emm.freeEMSpages); - printf(" EMSPageFrame: %x\n", gvar->pm.emm.EMSPageFrame); - } - if(MML_CheckForXMS(gvar)) - { - printf(" XMS\n"); - printf(" XMSaddr: %X\n", *XMSaddr); - } - printf("near: %lu ", gvar->mmi.nearheap); printf("far: %lu\n", gvar->mmi.farheap); if(MML_CheckForEMS()) - printf("EMSmem: %lu ", gvar->mmi.EMSmem); if(MML_CheckForXMS(gvar)) printf("XMSmem: %lu", gvar->mmi.XMSmem); printf("\n"); - //printf("mainmem: %lu\n", gvar->mmi.mainmem); - printf("Total convmem: %lu ", gvar->mmi.mainmem); printf("TotalFree: %lu ", MM_TotalFree(gvar)); printf("TotalUsed: %lu\n", gvar->mmi.mainmem+gvar->mmi.EMSmem+gvar->mmi.XMSmem+gvar->mmi.XMSmem); - printf(" UnusedMemory: %lu\n", MM_UnusedMemory(gvar)); -} - -//========================================================================== - -/* -===================== -= -= MM_EMSerr -= -===================== -*/ - -void MM_EMSerr(byte *stri, byte err) -{ - //Returns a text string describing the error code in EMS.Error. - switch(err) - { - case 0x0: - strcat(stri, "successful"); - break; - case 0x80: - strcat(stri, "internal error"); - break; - case 0x81: - strcat(stri, "hardware malfunction"); - break; - case 0x82: - strcat(stri, "busy .. retry later"); - break; - case 0x83: - strcat(stri, "invalid handle"); - break; - case 0x84: - strcat(stri, "undefined function requested by application"); - break; - case 0x85: - strcat(stri, "no more handles available"); - break; - case 0x86: - strcat(stri, "error in save or restore of mapping context"); - break; - case 0x87: - strcat(stri, "insufficient memory pages in system"); - break; - case 0x88: - strcat(stri, "insufficient memory pages available"); - break; - case 0x89: - strcat(stri, "zero pages requested"); - break; - case 0x8A: - strcat(stri, "invalid logical page number encountered"); - break; - case 0x8B: - strcat(stri, "invalid physical page number encountered"); - break; - case 0x8C: - strcat(stri, "page-mapping hardware state save area is full"); - break; - case 0x8D: - strcat(stri, "save of mapping context failed"); - break; - case 0x8E: - strcat(stri, "restore of mapping context failed"); - break; - case 0x8F: - strcat(stri, "undefined subfunction"); - break; - case 0x90: - strcat(stri, "undefined attribute type"); - break; - case 0x91: - strcat(stri, "feature not supported"); - break; - case 0x92: - strcat(stri, "successful, but a portion of the source region has been overwritten"); - break; - case 0x93: - strcat(stri, "length of source or destination region exceeds length of region allocated to either source or destination handle"); - break; - case 0x94: - strcat(stri, "conventional and expanded memory regions overlap"); - break; - case 0x95: - strcat(stri, "offset within logical page exceeds size of logical page"); - break; - case 0x96: - strcat(stri, "region length exceeds 1 MB"); - break; - case 0x97: - strcat(stri, "source and destination EMS regions have same handle and overlap"); - break; - case 0x98: - strcat(stri, "memory source or destination type undefined"); - break; - case 0x9A: - strcat(stri, "specified alternate map register or DMA register set not supported"); - break; - case 0x9B: - strcat(stri, "all alternate map register or DMA register sets currently allocated"); - break; - case 0x9C: - strcat(stri, "alternate map register or DMA register sets not supported"); - break; - case 0x9D: - strcat(stri, "undefined or unallocated alternate map register or DMA register set"); - break; - case 0x9E: - strcat(stri, "dedicated DMA channels not supported"); - break; - case 0x9F: - strcat(stri, "specified dedicated DMA channel not supported"); - break; - case 0xA0: - strcat(stri, "no such handle name"); - break; - case 0xA1: - strcat(stri, "a handle found had no name, or duplicate handle name"); - break; - case 0xA2: - strcat(stri, "attempted to wrap around 1M conventional address space"); - break; - case 0xA3: - strcat(stri, "source array corrupted"); - break; - case 0xA4: - strcat(stri, "operating system denied access"); - break; - default: - strcat(stri, "undefined error"); - } -} - -//========================================================================== - -/* -===================== -= -= MM_BombOnError -= -===================== -*/ - -void MM_BombOnError(boolean bomb, global_game_variables_t *gvar) -{ - gvar->mm.bombonerror = bomb; -} - -/*void MM_GetNewBlock(global_game_variables_t *gvar) -{ - if(!gvar->mm.mmfree) - MML_ClearBlock(gvar); - gvar->mm.mmnew=gvar->mm.mmfree; - gvar->mm.mmfree=gvar->mm.mmfree->next; - if(!(gvar->mm.mmnew=gvar->mm.mmfree)) - { - printf("MM_GETNEWBLOCK: No free blocks!\n"); - return; - } - gvar->mm.mmfree=gvar->mm.mmfree->next; -} - -void MM_FreeBlock(mmblocktype *x, global_game_variables_t *gvar) -{ - x->useptr=NULL; - x->next=gvar->mm.mmfree; - gvar->mm.mmfree=x; -}*/ - -void XMS_CALL(byte v, global_game_variables_t *gvar) -{ - XMSD; - //XMSDriver=gvar->pm.xmm.XMSDriver; - __asm { - mov v,ah - call [WORD PTR XMSDriver] - } -} - -/*void MM_seguin(void) -{ - __asm { - push ds - mov ax,ds - inc ax - mov ds,ax - } -} - -void MM_segude(void) -{ - __asm { - pop ds - } -}*/ - -/* -pull data from far and put it into ds var -mov ax,es:si -mov x,ax -*/ -/* -ss stack segment -sp top of stack -bp bottem of stack -*/ +/* Catacomb Apocalypse Source Code + * Copyright (C) 1993-2014 Flat Rock Software + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +// NEWMM.C + +/* +============================================================================= + + ID software memory manager + -------------------------- + +Primary coder: John Carmack + +RELIES ON +--------- +Quit (char *error) function + + +WORK TO DO +---------- +MM_SizePtr to change the size of a given pointer + +Multiple purge levels utilized + +EMS / XMS unmanaged routines + +============================================================================= +*/ +/* + +Open Watcom port by sparky4 + +*/ +#include "src/lib/16_mm.h" +#include "src/lib/16_ca.h" +#pragma hdrstop + +#pragma warn -pro +#pragma warn -use + +/* +============================================================================= + + GLOBAL VARIABLES + +============================================================================= +*/ + +void (* beforesort) (void); +void (* aftersort) (void); +void (* XMSaddr) (void); // far pointer to XMS driver + +/* +============================================================================= + + LOCAL VARIABLES + +============================================================================= +*/ + +static char *ParmStringsexmm[] = {"noems","noxms",""}; + +/* +====================== += += MML_CheckForEMS += += Routine from p36 of Extending DOS += +======================= +*/ + +boolean MML_CheckForEMS(void) +{ + boolean emmcfems; + static char emmname[] = "EMMXXXX0"; //fix by andrius4669 + __asm { + mov dx,OFFSET emmname //fix by andrius4669 + mov ax,0x3d00 + int 0x21 // try to open EMMXXXX0 device + jc error + + mov bx,ax + mov ax,0x4400 + + int 0x21 // get device info + jc error + + and dx,0x80 + jz error + + mov ax,0x4407 + + int 0x21 // get status + jc error + or al,al + jz error + + mov ah,0x3e + int 0x21 // close handle + jc error + // + // EMS is good + // + mov emmcfems,1 + jmp End +#ifdef __BORLANDC__ + } +#endif + error: +#ifdef __BORLANDC__ + __asm { +#endif + // + // EMS is bad + // + mov emmcfems,0 +#ifdef __BORLANDC__ + } +#endif + End: +#ifdef __WATCOMC__ + } +#endif + return(emmcfems); +} + + +/* +====================== += += MML_SetupEMS += +======================= +*/ + +byte MML_SetupEMS(global_game_variables_t *gvar) +{ + byte str[160]; + byte err; + boolean errorflag=false; + + unsigned int EMSVer = 0; + //byte EMS_status; + unsigned totalEMSpages,freeEMSpages,EMSpageframe,EMSpagesmapped,EMShandle; + totalEMSpages = freeEMSpages = EMSpageframe = EMSpagesmapped = 0; + + __asm { + mov ah,EMS_STATUS + int EMS_INT // make sure EMS hardware is present + or ah,ah + //mov [EMS_status],ah + jnz error + + mov ah,EMS_VERSION + int EMS_INT + or ah,ah + jnz error + mov [EMSVer],ax // set EMSVer + cmp al,0x32 // only work on ems 3.2 or greater + jb error + + mov ah,EMS_GETFRAME + int EMS_INT // find the page frame address + or ah,ah + jnz error + mov [EMSpageframe],bx + + mov ah,EMS_GETPAGES + int EMS_INT // find out how much EMS is there + or ah,ah + jnz error + mov [totalEMSpages],dx + mov [freeEMSpages],bx + or bx,bx + jz noEMS // no EMS at all to allocate + //EXPAND DONG!!!! + cmp [EMSVer],0x40 + jb low + cmp bx,[freeEMSpages] + jle getpages + mov bx,[freeEMSpages] + jmp getpages +#ifdef __BORLANDC__ + } +#endif + low: +#ifdef __BORLANDC__ + __asm { +#endif + cmp bx,4 + jle getpages // there is only 1,2,3,or 4 pages + mov bx,4 // we can't use more than 4 pages +#ifdef __BORLANDC__ + } +#endif + getpages: +#ifdef __BORLANDC__ + __asm { +#endif + mov [EMSpagesmapped],bx + mov ah,EMS_ALLOCPAGES // allocate up to 64k of EMS + int EMS_INT + or ah,ah + jnz error + mov [EMShandle],dx + jmp End +#ifdef __BORLANDC__ + } +#endif + error: +#ifdef __BORLANDC__ + __asm { +#endif + mov err,ah + mov errorflag,1 + jmp End +#ifdef __BORLANDC__ + } +#endif +noEMS: +End: +#ifdef __WATCOMC__ + } +#endif + if(errorflag==true) + { + strcpy(str,"MM_SetupEMS: EMS error "); + MM_EMSerr(str, err); + printf("%s\n",str); + return err; + } + gvar->mm.totalEMSpages=totalEMSpages; + gvar->mm.freeEMSpages=freeEMSpages; + gvar->mm.EMSpageframe=EMSpageframe; + gvar->mm.EMSpagesmapped=EMSpagesmapped; + gvar->mm.EMShandle=EMShandle; + gvar->mm.EMSVer=EMSVer; + return 0; +} + + +/* +====================== += += MML_ShutdownEMS += +======================= +*/ + +void MML_ShutdownEMS(global_game_variables_t *gvar) +{ + boolean errorflag=false; + unsigned EMShandle=gvar->mm.EMShandle; + + if(!EMShandle) + return; + __asm { + mov ah,EMS_FREEPAGES + mov dx,[EMShandle] + int EMS_INT + or ah,ah + jz ok + mov errorflag,1 +#ifdef __BORLANDC__ + } +#endif + ok: +#ifdef __WATCOMC__ + } +#endif + if(errorflag==true) + Quit("MML_ShutdownEMS: Error freeing EMS!\n"); //++++ add something +} + +/* +==================== += += MM_MapEMS += += Maps the 64k of EMS used by memory manager into the page frame += for general use. This only needs to be called if you are keeping += other things in EMS. += +==================== +*/ + +byte MM_MapEMS(global_game_variables_t *gvar) +{ + byte str[160]; + unsigned EMShandle; + byte err; + boolean errorflag=false; + int i; + EMShandle=gvar->mm.EMShandle; + + for (i=0;i<4/*MAPPAGES*/;i++) + { + __asm { + mov ah,EMS_MAPPAGE + mov bx,[i] // logical page + mov al,bl // physical page + mov dx,[EMShandle] // handle + int EMS_INT + or ah,ah + jnz error + jmp End +#ifdef __BORLANDC__ + } +#endif + error: +#ifdef __BORLANDC__ + __asm { +#endif + mov err,ah + mov errorflag,1 +#ifdef __BORLANDC__ + } +#endif + End: +#ifdef __WATCOMC__ + } +#endif + if(errorflag==true) + { + strcpy(str,"MM_MapEMS: EMS error "); + MM_EMSerr(str, err); + printf("%s\n",str); + return err; + } + } + gvar->mmi.EMSmem = (i)*0x4000lu; + //printf(" gvar->mmi.EMSmem=%lu\n", gvar->mmi.EMSmem); + return 0; +} + +byte MM_MapXEMS(global_game_variables_t *gvar) +{ +//SUB EMS.MapXPages (PhysicalStart, LogicalStart, NumPages, Handle) + + //Maps up to 4 logical EMS pages to physical pages in the page frame, where: + //PhysicalStart = Physical page first logical page is mapped to + //LogicalStart = First logical page to map + //NumPages = Number of pages to map (1 to 4) + //Handle = EMS handle logical pages are allocated to + + /*//Create a buffer containing the page information +// FOR x = 0 TO NumPages - 1 +// MapInfo$ = MapInfo$ + MKI$(LogicalStart + x) + MKI$(PhysicalStart + x) +// NEXT*/ + +// Regs.ax = 0x5000 //Map the pages in the buffer +// Regs.cx = NumPages //to the pageframe +// Regs.dx = Handle +// Regs.ds = VARSEG(MapInfo$) +// Regs.si = SADD(MapInfo$) +// InterruptX 0x67, Regs, Regs +// EMS.Error = (Regs.ax AND 0xFF00&) \ 0x100 //Store the status code + +//END SUB + byte str[160]; + byte err; + word EMShandle; + boolean errorflag=false; + int i; + EMShandle=gvar->mm.EMShandle; + + if(gvar->mm.EMSVer<0x40) + return 5; + + for (i=0;immi.EMSmem = (i)*0x4000lu; + return 0; +} + +//========================================================================== + +/* +====================== += += MML_CheckForXMS += += Check for XMM driver += +======================= +*/ + +boolean MML_CheckForXMS(global_game_variables_t *gvar) +{ + boolean errorflag=false; + gvar->mm.numUMBs = 0; + + __asm { + mov ax,0x4300 + int 0x2f // query status of installed diver + cmp al,0x80 + je good + mov errorflag,1 +#ifdef __BORLANDC__ + } +#endif + good: +#ifdef __WATCOMC__ + } +#endif + if(errorflag==true) return false; + else return true; +} + + +/* +====================== += += MML_SetupXMS += += Try to allocate all upper memory block += +======================= +*/ + +void MML_SetupXMS(global_game_variables_t *gvar) +{ + word base,size; + + + __asm { + mov ax,0x4310 + int 0x2f + mov [WORD PTR XMSaddr],bx + mov [WORD PTR XMSaddr+2],es // function pointer to XMS driver + } +getmemory: + __asm { + mov ah,XMS_ALLOCUMB + mov dx,0xffff // try for largest block possible + //mov ax,dx // Set available Kbytes. + call [DWORD PTR XMSaddr] + or ax,ax + jnz gotone + + cmp bl,0xb0 // error: smaller UMB is available + jne done; + + mov ah,XMS_ALLOCUMB + call [DWORD PTR XMSaddr] // DX holds largest available UMB + or ax,ax + jz done // another error... +#ifdef __BORLANDC__ + } +#endif + gotone: +#ifdef __BORLANDC__ + __asm { +#endif + mov [base],bx + mov [size],dx +#ifdef __BORLANDC__ + } +#endif + done: +#ifdef __WATCOMC__ + } +#endif +// printf("base=%u ", base); printf("size=%u\n", size); + MML_UseSpace(base,size, gvar); + gvar->mmi.XMSmem += size*16; + gvar->mm.UMBbase[gvar->mm.numUMBs] = base; + gvar->mm.numUMBs++; + if(gvar->mm.numUMBs < MAXUMBS) + goto getmemory; +} + + +/* +====================== += += MML_ShutdownXMS += +====================== +*/ + +void MML_ShutdownXMS(global_game_variables_t *gvar) +{ + int i; + unsigned base; + + for (i=0;imm.numUMBs;i++) + { + base = gvar->mm.UMBbase[i]; + __asm { + mov ah,XMS_FREEUMB + mov dx,[base] + call [DWORD PTR XMSaddr] + } + } +} + +//========================================================================== + +/* +====================== += += MML_UseSpace += += Marks a range of paragraphs as usable by the memory manager += This is used to mark space for the near heap, far heap, ems page frame, += and upper memory blocks += +====================== +*/ + +/*void MML_UseSpace(word segstart, dword seglength, global_game_variables_t *gvar) +{ + //huge mmblocktype huge *scan,huge *last; + word segm=1; + word oldend; + dword segmlen; + dword extra; + + scan = last = gvar->mm.mmhead; + gvar->mm.mmrover = gvar->mm.mmhead; // reset rover to start of memory + +// +// search for the block that contains the range of segments +// + while(scan->start+scan->length < segstart) + { + last = scan; + scan = scan->next; + } + +// +// take the given range out of the block +// + oldend = scan->start + scan->length; + extra = oldend - (segstart+seglength); + + segmlen=extra; + + //++++emsver stuff! + if(segm>1)/// || extra>=0x10000lu) + //if(extra>0xfffflu) + { + scan->blob=segm; + + //MML_UseSpace(segstart, seglength, gvar); + + printf("MML_UseSpace: Segment spans two blocks!\n"); + //} + printf("segm=%u ", segm); + printf("ex=%lu ", extra); + printf("old=%u ", oldend); + printf("start+seglen=%lu\n", segstart+seglength); + printf("segsta=%x ", segstart); + printf("len=%lu ", scan->length); + printf("seglen=%lu ", seglength); + printf("segmlen=%lu\n", segmlen); + } +//++++todo: linked list of segment! + if(segstart == scan->start) + { + last->next = scan->next; // unlink block + FREEBLOCK(scan); + scan = last; + } + else + scan->length = segstart-scan->start; // shorten block + + if(extra > 0) + { + GETNEWBLOCK; + gvar->mm.mmnew->useptr = NULL; + + gvar->mm.mmnew->next = scan->next; + scan->next = gvar->mm.mmnew; + gvar->mm.mmnew->start = segstart+seglength; + gvar->mm.mmnew->length = extra; + gvar->mm.mmnew->attributes = LOCKBIT; + }//else if(segm>0) goto segu; + +}*/ +void MML_UseSpace(word segstart, dword seglength, global_game_variables_t *gvar) +{ + mmblocktype far *scan,far *last; + word oldend; + sdword extra; + //word segm=1; + + scan = last = gvar->mm.mmhead; + gvar->mm.mmrover = gvar->mm.mmhead; // reset rover to start of memory + +// +// search for the block that contains the range of segments +// + while (scan->start+scan->length < segstart) + { + last = scan; + scan = scan->next; + } + +// +// find out how many blocks it spans! +// + /*for(;seglength>=0x10000;seglength-=0xFFFF) + { + //printf(" seglen=%lu\n", segmlen); + segm++; + }*/ + +// +// take the given range out of the block +// + oldend = scan->start + scan->length; + extra = oldend - (segstart+((unsigned)seglength)); + if (extra < 0) + { + printf("========================================\n"); + printf("start=%x ", scan->start); + printf("old=%u ", oldend); + printf("start+seglen=%lu\n", segstart+seglength); + printf("segsta=%x ", segstart); + printf("len=%lu ", scan->length); + printf("seglen=%lu ", seglength); + printf("\n"); + printf("MML_UseSpace: Segment spans two blocks! %d\n", extra); + printf("========================================\n"); + //return; + } + + if (segstart == scan->start) + { + last->next = scan->next; // unlink block + FREEBLOCK(scan); + scan = last; + } + else + scan->length = segstart-scan->start; // shorten block + + if (extra > 0) + { + GETNEWBLOCK; + gvar->mm.mmnew->useptr = NULL; + + gvar->mm.mmnew->next = scan->next; + scan->next = gvar->mm.mmnew; + gvar->mm.mmnew->start = segstart+seglength; + gvar->mm.mmnew->length = extra; + gvar->mm.mmnew->attributes = LOCKBIT; + } + +} + +//========================================================================== + +/* +==================== += += MML_ClearBlock += += We are out of blocks, so free a purgable block += +==================== +*/ + +void MML_ClearBlock(global_game_variables_t *gvar) +{ + //huge mmblocktype huge *scan,huge *last; + mmblocktype far *scan,far *last; + + scan = gvar->mm.mmhead->next; + + while(scan) + { + if(!(scan->attributes&LOCKBIT) && (scan->attributes&PURGEBITS)) + { + MM_FreePtr(scan->useptr, gvar); + return; + } + scan = scan->next; + } + + printf("MM_ClearBlock: No purgable blocks!\n"); +} + + +//========================================================================== + +/* +=================== += += MM_Startup += += Grabs all space from turbo with malloc/farmalloc += Allocates bufferseg misc buffer += +=================== +*/ + +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); + + gvar->mm.mmstarted = true; + gvar->mm.bombonerror = true; + +// +// set up the linked list (everything in the free list; +// + 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; + +// +// locked block of all memory until we punch out free space +// + GETNEWBLOCK; + gvar->mm.mmhead = gvar->mm.mmnew; // this will allways be the first node + gvar->mm.mmnew->start = 0; + 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); + length -= SAVENEARHEAP; + seglength = length / 16; // now in paragraphs + segstart = FP_SEG(start)+(FP_OFF(start)+15)/16; + MML_UseSpace(segstart,seglength, gvar); + gvar->mmi.nearheap = length; + //printf("start=%Fp segstart=%x seglen=%lu len=%lu\n", start, segstart, seglength, length); + +// +// get all available far conventional memory segments +// + //printf("_FARCORELEFT %lu\n", _FCORELEFT); +#ifdef __WATCOMC__ + _fheapgrow(); +#endif +#ifdef __BORLANDC__ + printf("farcoreleft() %lu\n", farcoreleft()); + printf("(farcoreleft()+32)-_FCORELEFT %d\n", (sword)((farcoreleft()+32)-_FCORELEFT)); +#endif + length=_FCORELEFT;//_fcoreleft();//(dword)GetFarFreeSize();//0xffffUL*4UL; + start = gvar->mm.farheap = _fmalloc(length); + //start = gvar->mm.farheap = halloc(length, 1); + length -= 16-(FP_OFF(start)&15); + length -= SAVEFARHEAP; + seglength = length / 16; // now in paragraphs + segstart = FP_SEG(start)+(FP_OFF(start)+15)/16; + MML_UseSpace(segstart,seglength, gvar); + gvar->mmi.farheap = length; + //printf("start=%Fp segstart=%x seglen=%lu len=%lu\n", start, segstart, seglength, length); + + gvar->mmi.mainmem = gvar->mmi.nearheap + gvar->mmi.farheap; + +// +// detect EMS and allocate up to 64K at page frame +// + gvar->mmi.EMSmem = 0; +//goto emsskip; //0000 + for(i = 1;i < +#ifdef __WATCOMC__ + __argc +#endif +#ifdef __BORLANDC__ + _argc +#endif + ;i++) + { + if(US_CheckParm( +#ifdef __WATCOMC__ + __argv[i] +#endif +#ifdef __BORLANDC__ + _argv[i] +#endif + ,ParmStringsexmm) == 0) + goto emsskip; // param NOEMS + } + if(MML_CheckForEMS()) + { + MML_SetupEMS(gvar); // allocate space + //TODO: EMS4! AND EMS 3.2 MASSIVE DATA HANDLMENT! + MML_UseSpace(gvar->mm.EMSpageframe,(MAPPAGES)*0x4000lu, gvar); + //if(gvar->pm.emm.EMSVer<0x40) + MM_MapEMS(gvar); // map in used pages + //else + //MM_MapXEMS(gvar); // map in used pages + } + +// +// detect XMS and get upper memory blocks +// +emsskip: + gvar->mmi.XMSmem = 0; +goto xmsskip;//0000 + for(i = 1;i < +#ifdef __WATCOMC__ + __argc +#endif +#ifdef __BORLANDC__ + _argc +#endif + ;i++) + { + if(US_CheckParm( +#ifdef __WATCOMC__ + __argv[i] +#endif +#ifdef __BORLANDC__ + _argv[i] +#endif + ,ParmStringsexmm) == 0) + goto xmsskip; // param NOXMS + } + if(MML_CheckForXMS(gvar)) + { + MML_SetupXMS(gvar); // allocate as many UMBs as possible + } + +// +// allocate the misc buffer +// +xmsskip: + gvar->mm.mmrover = gvar->mm.mmhead; // start looking for space after low block + + MM_GetPtr(&(gvar->mm.bufferseg),BUFFERSIZE, gvar); +} + +//========================================================================== + +/* +==================== += += MM_Shutdown += += Frees all conventional, EMS, and XMS allocated += +==================== +*/ + +void MM_Shutdown(global_game_variables_t *gvar) +{ + if(!(gvar->mm.mmstarted)) + return; + + _ffree(gvar->mm.farheap);// printf(" far freed\n"); +#ifdef __WATCOMC__ + _nfree(gvar->mm.nearheap);// printf(" near freed\n"); +#endif +#ifdef __BORLANDC__ + free(gvar->mm.nearheap);// printf(" near freed\n"); +#endif + if(MML_CheckForEMS()){ MML_ShutdownEMS(gvar); }//printf(" EMS freed\n"); } + if(MML_CheckForXMS(gvar)){ MML_ShutdownXMS(gvar); }//printf(" XMS freed\n"); } +} + +//========================================================================== + +/* +==================== += += MM_GetPtr += += Allocates an unlocked, unpurgable block += +==================== +*/ + +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; + + needed = (size+15)/16; // convert size from bytes to paragraphs + + GETNEWBLOCK; // fill in start and next after a spot is found + 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)); +#endif + //exit(-5); } + gvar->mm.mmnew->attributes = BASEATTRIBUTES; + +//tryagain: + for (search = 0; search<3; search++) + { + // + // first search: try to allocate right after the rover, then on up + // second search: search from the head pointer up to the rover + // third search: compress memory, then scan from start + if (search == 1 && gvar->mm.mmrover == gvar->mm.mmhead) + search++; + + switch (search) + { + case 0: + lastscan = gvar->mm.mmrover; + scan = gvar->mm.mmrover->next; + endscan = NULL; + break; + case 1: + lastscan = gvar->mm.mmhead; + scan = gvar->mm.mmhead->next; + endscan = gvar->mm.mmrover; + break; + case 2: + MM_SortMem (gvar); + lastscan = gvar->mm.mmhead; + scan = gvar->mm.mmhead->next; + endscan = NULL; + break; + } + + startseg = lastscan->start + lastscan->length; + + while (scan != endscan) + { + if (scan->start - startseg >= needed) + { + // + // got enough space between the end of lastscan and + // the start of scan, so throw out anything in the middle + // and allocate the new block + // + purge = lastscan->next; + lastscan->next = gvar->mm.mmnew; + gvar->mm.mmnew->start = *(unsigned *)baseptr = startseg; + gvar->mm.mmnew->next = scan; + while ( purge != scan) + { // free the purgable block + next = purge->next; + FREEBLOCK(purge); + purge = next; // purge another if not at scan + } + gvar->mm.mmrover = gvar->mm.mmnew; + return; // good allocation! + } + + // + // if this block is purge level zero or locked, skip past it + // + if ( (scan->attributes & LOCKBIT) + || !(scan->attributes & PURGEBITS) ) + { + lastscan = scan; + startseg = lastscan->start + lastscan->length; + } + + + scan=scan->next; // look at next line + } + } + + if (gvar->mm.bombonerror) + { +#ifdef __WATCOMC__ + //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); + } + else + gvar->mm.mmerror = true; +} + +//========================================================================== + +/* +==================== += += MM_FreePtr += += Allocates an unlocked, unpurgable block += +==================== +*/ + +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; + scan = last->next; + + if(baseptr == gvar->mm.mmrover->useptr) // removed the last allocated block + gvar->mm.mmrover = gvar->mm.mmhead; + + while(scan->useptr != baseptr && scan) + { + last = scan; + scan = scan->next; + } + + if(!scan) + { + printf("MM_FreePtr: Block not found!\n"); + return; + } + + last->next = scan->next; + + FREEBLOCK(scan); +} +//========================================================================== + +/* +===================== += += MM_SetPurge += += Sets the purge level for a block (locked blocks cannot be made purgable) += +===================== +*/ + +void MM_SetPurge(memptr *baseptr, int purge, global_game_variables_t *gvar) +{ + //huge mmblocktype huge *start; + mmblocktype far *start; + + start = gvar->mm.mmrover; + + do + { + if(gvar->mm.mmrover->useptr == baseptr) + break; + + gvar->mm.mmrover = gvar->mm.mmrover->next; + + if(!gvar->mm.mmrover) + gvar->mm.mmrover = gvar->mm.mmhead; + else if(gvar->mm.mmrover == start) + { + Quit("MM_SetPurge: Block not found!"); + //return; + } + + } while(1); + + gvar->mm.mmrover->attributes &= ~PURGEBITS; + gvar->mm.mmrover->attributes |= purge; +} + +//========================================================================== + +/* +===================== += += MM_SetLock += += Locks / unlocks the block += +===================== +*/ + +void MM_SetLock(memptr *baseptr, boolean locked, global_game_variables_t *gvar) +{ + //huge mmblocktype huge *start; + mmblocktype far *start; + + start = gvar->mm.mmrover; + + do + { + if(gvar->mm.mmrover->useptr == baseptr) + break; + + gvar->mm.mmrover = gvar->mm.mmrover->next; + + if(!gvar->mm.mmrover) + gvar->mm.mmrover = gvar->mm.mmhead; + else if(gvar->mm.mmrover == start) + { + Quit("MM_SetLock: Block not found!"); + //return; + } + + } while(1); + + gvar->mm.mmrover->attributes &= ~LOCKBIT; + gvar->mm.mmrover->attributes |= locked*LOCKBIT; +} + +//========================================================================== + +/* +===================== += += MM_SortMem += += Throws out all purgable stuff and compresses movable blocks += +===================== +*/ + +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; + + // + // lock down a currently playing sound + // +/*++++ playing = SD_SoundPlaying (); + if(playing) + { + switch (SoundMode) + { + case sdm_PC: + playing += STARTPCSOUNDS; + break; + case sdm_AdLib: + playing += STARTADLIBSOUNDS; + break; + } + MM_SetLock(&(memptr)audiosegs[playing],true); + } + + + SD_StopSound();*/ +// oldborder = bordercolor; +// VW_ColorBorder (15); + + if(beforesort) + beforesort(); + + scan = gvar->mm.mmhead; + + last = NULL; // shut up compiler warning + + while(scan) + { + if(scan->attributes & LOCKBIT) + { + // + // block is locked, so try to pile later blocks right after it + // + start = scan->start + scan->length; + } + else + { + if(scan->attributes & PURGEBITS) + { + // + // throw out the purgable block + // + next = scan->next; + FREEBLOCK(scan); + //MM_FreeBlock(scan, gvar); + last->next = next; + scan = next; + continue; + } + else + { + // + // push the non purgable block on top of the last moved block + // + if(scan->start != start) + { + length = scan->length; + source = scan->start; + dest = start; + while(length > 0xf00) + { + movedata(source,0,dest,0,0xf00*16); + length -= 0xf00; + source += 0xf00; + dest += 0xf00; + } + movedata(source,0,dest,0,length*16); + + scan->start = start; + *(unsigned *)scan->useptr = start; + } + start = scan->start + scan->length; + } + } + + last = scan; + scan = scan->next; // go to next block + } + + gvar->mm.mmrover = gvar->mm.mmhead; + + if(aftersort) + aftersort(); + +// VW_ColorBorder (oldborder); + +/*++++ if(playing) + MM_SetLock(&(memptr)audiosegs[playing],false);*/ +} + +//========================================================================== + +/* +===================== += += MM_ShowMemory += +===================== +*/ + +void MM_ShowMemory(global_game_variables_t *gvar) +{ + //huge mmblocktype huge *scan; + mmblocktype far *scan; + word temp; + sdword end,owner; + //word chx,chy; + word w; + //dword wwww; + byte scratch[160],scratch0[4096],scratch1[160],str[16]; + //byte d = '#'; +//**** VW_SetDefaultColors(); +//**** VW_SetLineWidth(40); +//++++mh temp = bufferofs; +//++++mh bufferofs = 0; +//**** VW_SetScreen (0,0); + scan = gvar->mm.mmhead; + end = -1; + + CA_OpenDebug (gvar); + w=0; + while(scan) + { + strcpy(scratch, AARESET); + if(scan->attributes & PURGEBITS) + strcpy(scratch0, AAMAGENTA); // dark purple = purgable + else + strcpy(scratch0, AABLUE); // medium blue = non purgable + if(scan->attributes & LOCKBIT) + strcpy(scratch0, AARED); // red = locked + if(scan->start<=end) + { + printf("\nend==%d\n\n", end); + strcat(scratch, "MM_ShowMemory: Memory block order currupted!\n"); + strcat(scratch, "End's Size: "); + ultoa (end,str,10); + strcat (scratch,str); + strcat(scratch, "\nscan->start's Size: "); + ultoa (scan->start,str,10); + strcat (scratch,str); + write(gvar->handle.debughandle,scratch,strlen(scratch)); + //modexprint(&page, chx, chy, 1, 0, 24, "\nMM_ShowMemory: Memory block order currupted!\n"); + break; + } + end = scan->start+(scan->length)-1; +//++++ chy = scan->start/320; +//++++ chx = scan->start%320; + //modexhlin(page, scan->start, (unsigned)end, chy, color); + //for(chx=scan->start;chx+4>=(word)end;chx+=4) + //{ +//++++ modexClearRegion(page, chx, chy, 4, 4, color); + //} +//++++ VW_Hlin(scan->start,(unsigned)end,0,color); + for(w=(scan->start)/80;w<=end/80;w++) + { + //printf("+ %u %lu\n", w, scan->length); + strcat(scratch0, "+"); + } + //++==++==optional strcat(scratch0, AARESET); strcat(scratch0, AAGREY); strcat(scratch0,"_"); +//++++ VW_Plot(scan->start,0,15); +//++++ modexClearRegion(page, chx, chy, 4, 4, 15); +//++++ VW_Hlin(end+1,scan->next->start,0,0); // black = free + + //wwww=(dword)(scan->next->start)-(dword)scan->start; + //wwww=(dword)scan->start+(dword)(scan->next->start); + if (scan->next && scan->next->start >= end+1) + { + strcat(scratch0, AARESET); + //++==++==optional strcat(scratch0, "\n"); + strcat(scratch0,AAGREEN); + for(w=(end+1)/80;w<=((scan->next->start-scan->start)/80);w++) + //for(w=(wwww)/80;w<=((end+1)/80);w++) + //for(w=(end+1)/80;w<=((wwww)/80);w++) + { + //printf("0 %x %u %lu\n", scan->next->start, w, scan->length); + strcat(scratch0,"0"); + } + //printf("==================\n"); + //printf("w=%u wwww=%lu start=%04x next=%04x end=%lu\n", w/80, wwww/80, scan->start, (scan->next->start), end+1); + //printf("==================\n"); + strcat(scratch0, "\n"); + //getch(); + }/*else {//if(scan->next->start <= scan->start){ + scan->next->start=scan->start+0x1000; + wwww=(dword)(scan->next->start)-(dword)scan->start; + strcat(scratch0, AARESET); + strcat(scratch0, "\n"); + strcat(scratch0,AAGREEN); + for(w=(end+1);w<=(0x1000/80);w++) + { + //printf("0 %x %x %u\n", scan->start, w); + strcat(scratch0,"0"); + } + printf("================\n"); + printf("w=%x start=%x next=%x end=%u %lu\n", w, scan->start, (scan->next->start), end+1, wwww); + printf("================\n"); + getch(); + }*/ + strcat(scratch0, AARESET); + //strcat(scratch0,"\n"); + //for(chx=scan->next->start;chx+4>=(word)end+1;chx+=4) + //{ +// chx+=scan->next->start; +// modexClearRegion(page, chx, chy, 4, 4, 2); + //} + //modexhlin(page, end+1,scan->next->start, chy, 0); +/* y = scan->start/320; + x = scan->start%320; + VW_Hlin(x,x+end,y,color); + VW_Plot(x,y,15);*/ +//++++ VW_Hlin(x+end+1,x+(scan->next->start-scan->start),y,0); // black = free + strcat(scratch,"Seg:"); + ultoa (scan->start,str,16); + strcat (scratch,str); + strcat (scratch,"\tSize:"); + ultoa ((unsigned)scan->length,str,10); + strcat (scratch,str); + strcat (scratch,"\tOwner:0x"); + owner = (unsigned)scan->useptr; + ultoa (owner,str,16); + strcat (scratch,str); + strcat (scratch,"\n"); + write(gvar->handle.debughandle,scratch,strlen(scratch)); + write(gvar->handle.debughandle,scratch0,strlen(scratch0)); +//modexprint(page, chx, chy, 1, 0, 24, &scratch); +//++++chy+=4; +//fprintf(stdout, "%s", scratch); + + scan = scan->next; + } + /*strcpy(scratch1, AARESET); + strcat(scratch1, "========================================\n"); + strcat(scratch1, "near= "); + ultoa (*(gvar->mm.nearheap),str,10); + strcat (scratch1,str); + strcat(scratch1, " far= "); + ultoa (*(gvar->mm.farheap),str,10); + strcat (scratch1,str); + strcat(scratch1, "\n"); + //strcat(scratch1, "&near= %Fp ", &(gvar->mm.nearheap)); + //strcat(scratch1, "&far= %Fp", &(gvar->mm.farheap)); + //strcat(scratch1, "\n"); + strcat(scratch1, "========================================\n"); + write(gvar->handle.debughandle,scratch1,strlen(scratch1));*/ + + + CA_CloseDebug (gvar); + +//++++mh IN_Ack(); +//**** VW_SetLineWidth(64); +//++++mh bufferofs = temp; +} + +//========================================================================== + +/* +===================== += += MM_DumpData += +===================== +*/ + +void MM_DumpData(global_game_variables_t *gvar) +{ + //huge mmblocktype huge *scan,huge *best; + mmblocktype far *scan,far *best; + long lowest,oldlowest; + word owner; + byte lock,purge; + FILE *dumpfile; + + free(gvar->mm.nearheap); +#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; + } + + lowest = -1; + do + { + oldlowest = lowest; + lowest = 0xffff; + + scan = gvar->mm.mmhead; + while (scan) + { + owner = (unsigned)scan->useptr; + + if (owner && owner oldlowest) + { + best = scan; + lowest = owner; + } + + scan = scan->next; + } + + if (lowest != 0xffff) + { + if (best->attributes & PURGEBITS) + purge = 'P'; + else + purge = '-'; + if (best->attributes & LOCKBIT) + lock = 'L'; + else + lock = '-'; + fprintf (dumpfile,"0x%p (%c%c) = %u\n" + ,(unsigned)lowest,lock,purge,best->length); + } + + } while (lowest != 0xffff); + + fclose(dumpfile); + printf("MMDUMP.16 created.\n"); +} + +//========================================================================== + + +/* +====================== += += MM_UnusedMemory += += Returns the total free space without purging += +====================== +*/ + +dword MM_UnusedMemory(global_game_variables_t *gvar) +{ + dword free; + //huge mmblocktype huge *scan; + mmblocktype far *scan; + + free = 0; + scan = gvar->mm.mmhead; + + while(scan->next) + { + free += scan->next->start - (scan->start + scan->length); + scan = scan->next; + } + + return free*16lu; +// return free; +} + +//========================================================================== + + +/* +====================== += += MM_TotalFree += += Returns the total free space with purging += +====================== +*/ + +dword MM_TotalFree(global_game_variables_t *gvar) +{ + dword free; + //huge mmblocktype huge *scan; + mmblocktype far *scan; + + free = 0; + scan = gvar->mm.mmhead; + + while(scan->next) + { + if((scan->attributes&PURGEBITS) && !(scan->attributes&LOCKBIT)) + free += scan->length; + free += scan->next->start - (scan->start + scan->length); + scan = scan->next; + } + + return free*16lu; +// return free; +} + +//========================================================================== + +/* +===================== += += MM_Report += +===================== +*/ + +void MM_Report_(global_game_variables_t *gvar) +{ + printf("========================================\n"); + printf(" MM_Report\n"); + printf("========================================\n"); + if(MML_CheckForEMS()) + { + 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); + } + if(MML_CheckForXMS(gvar)) + { + printf(" XMS\n"); + printf(" XMSaddr: %X\n", *XMSaddr); + } + printf("near: %lu ", gvar->mmi.nearheap); printf("far: %lu\n", gvar->mmi.farheap); if(MML_CheckForEMS()) + printf("EMSmem: %lu ", gvar->mmi.EMSmem); if(MML_CheckForXMS(gvar)) printf("XMSmem: %lu", gvar->mmi.XMSmem); printf("\n"); + //printf("mainmem: %lu\n", gvar->mmi.mainmem); + printf("Total convmem: %lu ", gvar->mmi.mainmem); printf("TotalFree: %lu ", MM_TotalFree(gvar)); printf("TotalUsed: %lu\n", gvar->mmi.mainmem+gvar->mmi.EMSmem+gvar->mmi.XMSmem+gvar->mmi.XMSmem); + printf(" UnusedMemory: %lu\n", MM_UnusedMemory(gvar)); +} + +//========================================================================== + +/* +===================== += += MM_EMSerr += +===================== +*/ + +void MM_EMSerr(byte *stri, byte err) +{ + //Returns a text string describing the error code in EMS.Error. + switch(err) + { + case 0x0: + strcat(stri, "successful"); + break; + case 0x80: + strcat(stri, "internal error"); + break; + case 0x81: + strcat(stri, "hardware malfunction"); + break; + case 0x82: + strcat(stri, "busy .. retry later"); + break; + case 0x83: + strcat(stri, "invalid handle"); + break; + case 0x84: + strcat(stri, "undefined function requested by application"); + break; + case 0x85: + strcat(stri, "no more handles available"); + break; + case 0x86: + strcat(stri, "error in save or restore of mapping context"); + break; + case 0x87: + strcat(stri, "insufficient memory pages in system"); + break; + case 0x88: + strcat(stri, "insufficient memory pages available"); + break; + case 0x89: + strcat(stri, "zero pages requested"); + break; + case 0x8A: + strcat(stri, "invalid logical page number encountered"); + break; + case 0x8B: + strcat(stri, "invalid physical page number encountered"); + break; + case 0x8C: + strcat(stri, "page-mapping hardware state save area is full"); + break; + case 0x8D: + strcat(stri, "save of mapping context failed"); + break; + case 0x8E: + strcat(stri, "restore of mapping context failed"); + break; + case 0x8F: + strcat(stri, "undefined subfunction"); + break; + case 0x90: + strcat(stri, "undefined attribute type"); + break; + case 0x91: + strcat(stri, "feature not supported"); + break; + case 0x92: + strcat(stri, "successful, but a portion of the source region has been overwritten"); + break; + case 0x93: + strcat(stri, "length of source or destination region exceeds length of region allocated to either source or destination handle"); + break; + case 0x94: + strcat(stri, "conventional and expanded memory regions overlap"); + break; + case 0x95: + strcat(stri, "offset within logical page exceeds size of logical page"); + break; + case 0x96: + strcat(stri, "region length exceeds 1 MB"); + break; + case 0x97: + strcat(stri, "source and destination EMS regions have same handle and overlap"); + break; + case 0x98: + strcat(stri, "memory source or destination type undefined"); + break; + case 0x9A: + strcat(stri, "specified alternate map register or DMA register set not supported"); + break; + case 0x9B: + strcat(stri, "all alternate map register or DMA register sets currently allocated"); + break; + case 0x9C: + strcat(stri, "alternate map register or DMA register sets not supported"); + break; + case 0x9D: + strcat(stri, "undefined or unallocated alternate map register or DMA register set"); + break; + case 0x9E: + strcat(stri, "dedicated DMA channels not supported"); + break; + case 0x9F: + strcat(stri, "specified dedicated DMA channel not supported"); + break; + case 0xA0: + strcat(stri, "no such handle name"); + break; + case 0xA1: + strcat(stri, "a handle found had no name, or duplicate handle name"); + break; + case 0xA2: + strcat(stri, "attempted to wrap around 1M conventional address space"); + break; + case 0xA3: + strcat(stri, "source array corrupted"); + break; + case 0xA4: + strcat(stri, "operating system denied access"); + break; + default: + strcat(stri, "undefined error"); + } +} + +//========================================================================== + +/* +===================== += += MM_BombOnError += +===================== +*/ + +void MM_BombOnError(boolean bomb, global_game_variables_t *gvar) +{ + gvar->mm.bombonerror = bomb; +} + +/*void MM_GetNewBlock(global_game_variables_t *gvar) +{ + if(!gvar->mm.mmfree) + MML_ClearBlock(gvar); + gvar->mm.mmnew=gvar->mm.mmfree; + gvar->mm.mmfree=gvar->mm.mmfree->next; + if(!(gvar->mm.mmnew=gvar->mm.mmfree)) + { + printf("MM_GETNEWBLOCK: No free blocks!\n"); + return; + } + gvar->mm.mmfree=gvar->mm.mmfree->next; +} + +void MM_FreeBlock(mmblocktype *x, global_game_variables_t *gvar) +{ + x->useptr=NULL; + x->next=gvar->mm.mmfree; + gvar->mm.mmfree=x; +}*/ + +/*void MM_seguin(void) +{ + __asm { + push ds + mov ax,ds + inc ax + mov ds,ax + } +} + +void MM_segude(void) +{ + __asm { + pop ds + } +}*/ + +/* +pull data from far and put it into ds var +mov ax,es:si +mov x,ax +*/ +/* +ss stack segment +sp top of stack +bp bottem of stack +*/ diff --git a/src/lib/16_mm.h b/src/lib/16_mm.h index d351abfa..1a448a2a 100755 --- a/src/lib/16_mm.h +++ b/src/lib/16_mm.h @@ -66,7 +66,9 @@ //-------- #define XMS_INT 0x2f -#define XMSD dword XMSDriver=gvar->pm.xmm.XMSDriver; +#define XMS_CALL(v) _AH = (v);\ + __asm call [WORD PTR XMSDriver] +/*__asm { //mov (v),ah*/ #define XMS_VERSION 0x00 @@ -205,7 +207,6 @@ void MM_Report_(global_game_variables_t *gvar); void MM_BombOnError(boolean bomb, global_game_variables_t *gvar); //void MM_GetNewBlock(mminfo_t *mm); //void MM_FreeBlock(mmblocktype *x, mminfo_t *mm); -void XMS_CALL(byte v, global_game_variables_t *gvar); //========================================================================== diff --git a/src/lib/16_pm.c b/src/lib/16_pm.c index 139b72c8..e699fcbf 100755 --- a/src/lib/16_pm.c +++ b/src/lib/16_pm.c @@ -44,9 +44,9 @@ // XMS specific variables boolean gvar->pm.xmm.XMSPresent; - word gvar->pm.xmm.XMSAvail,gvar->pm.xmm.XMSPagesAvail,gvar->pm.xmm.XMSHandle; - dword XMSDriver; - int gvar->pm.xmm.XMSProtectPage = -1; + word gvar->pm.xmm.XMSAvail,gvar->pm.xmm.XMSPagesAvail,gvar->pm.xmm.XMSHandle;*/ + word XMSDriver; +/* int gvar->pm.xmm.XMSProtectPage = -1; // File specific variables char gvar->pm.fi.PageFileName[13] = {"VSWAP."}; @@ -293,7 +293,7 @@ PML_ShutdownEMS(global_game_variables_t *gvar) boolean PML_StartupXMS(global_game_variables_t *gvar) { - XMSD; + //XMSD; gvar->pm.xmm.XMSPresent = false; // Assume failure gvar->pm.xmm.XMSAvail = 0; @@ -310,7 +310,7 @@ PML_StartupXMS(global_game_variables_t *gvar) mov [WORD PTR XMSDriver+2],es // function pointer to XMS driver } - XMS_CALL(XMS_QUERYFREE, gvar); // Find out how much XMS is available + XMS_CALL(XMS_QUERYFREE); // Find out how much XMS is available gvar->pm.xmm.XMSAvail = _AX; if (!_AX) // AJR: bugfix 10/8/92 goto error; @@ -320,7 +320,7 @@ PML_StartupXMS(global_game_variables_t *gvar) goto error; _DX = gvar->pm.xmm.XMSAvail; - XMS_CALL(XMS_ALLOC, gvar); // And do the allocation + XMS_CALL(XMS_ALLOC); // And do the allocation gvar->pm.xmm.XMSHandle = _DX; if (!_AX) // AJR: bugfix 10/8/92 @@ -344,7 +344,7 @@ void PML_XMSCopy(boolean toxms,byte far *addr,word xmspage,word length, global_game_variables_t *gvar) { #ifdef __WATCOMC__ - XMSD; + //XMSD; #endif dword xoffset; struct @@ -374,7 +374,7 @@ PML_XMSCopy(boolean toxms,byte far *addr,word xmspage,word length, global_game_v push si } _SI = (word)© - XMS_CALL(XMS_MOVE, gvar); + XMS_CALL(XMS_MOVE); __asm { pop si } @@ -416,11 +416,11 @@ PML_CopyFromXMS(byte far *target,int sourcepage,word length, global_game_variabl void PML_ShutdownXMS(global_game_variables_t *gvar) { - XMSD; + //XMSD; if (gvar->pm.xmm.XMSPresent) { _DX = gvar->pm.xmm.XMSHandle; - XMS_CALL(XMS_FREE, gvar); + XMS_CALL(XMS_FREE); if (_BL) { Quit("PML_ShutdownXMS: Error freeing XMS"); @@ -1277,6 +1277,9 @@ PM_Reset(global_game_variables_t *gvar) gvar->pm.PMPanicMode = false; + gvar->pm.fi.PageFile = -1; + gvar->pm.xmm.XMSProtectPage = -1; + // Initialize page list for (i = 0,page = gvar->pm.PMPages;i < gvar->pm.PMNumBlocks;i++,page++) { @@ -1300,8 +1303,6 @@ PM_Startup(global_game_variables_t *gvar) return; strcat(&(gvar->pm.fi.PageFileName), "VSWAP."); - gvar->pm.fi.PageFile = -1; - gvar->pm.xmm.XMSProtectPage = -1; nomain = noems = noxms = false; for (i = 1;i < diff --git a/src/lib/16_pm.h b/src/lib/16_pm.h index 85135d91..b9d801e1 100755 --- a/src/lib/16_pm.h +++ b/src/lib/16_pm.h @@ -110,5 +110,5 @@ extern void PM_Startup(global_game_variables_t *gvar), 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 PM_SetMainMemPurge(int level, global_game_variables_t *gvar); #endif diff --git a/src/lib/length b/src/lib/length new file mode 100755 index 00000000..ff49ecdf --- /dev/null +++ b/src/lib/length @@ -0,0 +1,4 @@ + total used free shared buffers cached +Mem: 7879884 7039184 840700 199796 367668 4095452 +-/+ buffers/cache: 2576064 5303820 +Swap: 2097148 0 2097148 diff --git a/src/lib/next b/src/lib/next new file mode 100755 index 00000000..e69de29b diff --git a/src/lib/typdefst.h b/src/lib/typdefst.h index 4d031f9e..d069b92f 100755 --- a/src/lib/typdefst.h +++ b/src/lib/typdefst.h @@ -171,6 +171,7 @@ typedef struct #endif //byte EMS_status; word numUMBs,UMBbase[MAXUMBS]; + word totalEMSpages, freeEMSpages, EMSpagesmapped, EMShandle, EMSpageframe,EMSVer; //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; -- 2.39.5