1 /* Catacomb Apocalypse Source Code
2 * Copyright (C) 1993-2014 Flat Rock Software
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 =============================================================================
24 ID software memory manager
25 --------------------------
27 Primary coder: John Carmack
31 Quit (char *error) function
36 MM_SizePtr to change the size of a given pointer
38 Multiple purge levels utilized
40 EMS / XMS unmanaged routines
42 =============================================================================
46 Open Watcom port by sparky4
49 #include "src/lib/16_mm.h"
52 =============================================================================
56 =============================================================================
59 void (* beforesort) (void);
60 void (* aftersort) (void);
61 void (* XMSaddr) (void); // far pointer to XMS driver
64 =============================================================================
68 =============================================================================
71 static char *ParmStringsexmm[] = {"noems","noxms",""};
74 ======================
78 = Routine from p36 of Extending DOS
80 =======================
83 boolean MML_CheckForEMS(void)
86 static char emmname[] = "EMMXXXX0"; //fix by andrius4669
87 // mov dx,OFFSET emmname
89 //LEA DX, emmname //fix by andrius4669
90 mov dx,OFFSET emmname //fix by andrius4669
92 int 0x21 // try to open EMMXXXX0 device
98 int 0x21 // get device info
106 int 0x21 // get status
112 int 0x21 // close handle
131 ======================
135 =======================
138 unsigned MML_SetupEMS(mminfo_t *mm)
140 char str[80],str2[10];
142 boolean errorflag=false;
145 unsigned int EMSVer = 0;
147 unsigned totalEMSpages,freeEMSpages,EMSpageframe,EMSpagesmapped,EMShandle;
148 totalEMSpages = freeEMSpages = EMSpageframe = EMSpagesmapped = 0;
153 int EMS_INT // make sure EMS hardware is present
155 //mov [EMS_status],ah
162 mov [EMSVer],ax // set EMSVer
163 cmp al,0x32 // only work on ems 3.2 or greater
167 int EMS_INT // find the page frame address
170 mov [EMSpageframe],bx
173 int EMS_INT // find out how much EMS is there
176 mov [totalEMSpages],dx
177 mov [freeEMSpages],bx
179 jz noEMS // no EMS at all to allocate
183 cmp bx,[freeEMSpages]
185 mov bx,[freeEMSpages]
190 jle getpages // there is only 1,2,3,or 4 pages
191 mov bx,4 // we can't use more than 4 pages
194 mov [EMSpagesmapped],bx
195 mov ah,EMS_ALLOCPAGES // allocate up to 64k of EMS
210 strcpy(str,"MML_SetupEMS: EMS error 0x");
216 mm->totalEMSpages=totalEMSpages;
217 mm->freeEMSpages=freeEMSpages;
218 mm->EMSpageframe=EMSpageframe;
219 mm->EMSpagesmapped=EMSpagesmapped;
220 mm->EMShandle=EMShandle;
227 ======================
231 =======================
234 void MML_ShutdownEMS(mminfo_t *mm)
236 boolean errorflag=false;
237 unsigned EMShandle=mm->EMShandle;
251 if(errorflag==true) printf("MML_ShutdownEMS: Error freeing EMS!"); //++++ add something
259 = Maps the 64k of EMS used by memory manager into the page frame
260 = for general use. This only needs to be called if you are keeping
261 = other things in EMS.
266 unsigned MM_MapEMS(mminfo_t *mm)
268 char str[80],str2[10];
269 unsigned err, EMShandle;
270 boolean errorflag=false;
273 EMShandle=mm->EMShandle;
275 for (i=0;i<4/*mm->EMSpagesmapped*/;i++)
280 mov bx,[i] // logical page
281 mov al,bl // physical page
282 mov dx,[EMShandle] // handle
294 strcpy(str,"MM_MapEMS: EMS error 0x");
297 //printf("%s\n",str);
298 printf("FACK! %u\n", err);
305 void MM_MapXEMS(mminfo_t *mm)
308 //SUB EMS.MapXPages (PhysicalStart, LogicalStart, NumPages, Handle)
\r
310 //Maps up to 4 logical EMS pages to physical pages in the page frame, where:
\r
311 //PhysicalStart = Physical page first logical page is mapped to
\r
312 //LogicalStart = First logical page to map
\r
313 //NumPages = Number of pages to map (1 to 4)
\r
314 //Handle = EMS handle logical pages are allocated to
\r
316 /*//Create a buffer containing the page information
\r
317 // FOR x = 0 TO NumPages - 1
\r
318 // MapInfo$ = MapInfo$ + MKI$(LogicalStart + x) + MKI$(PhysicalStart + x)
\r
321 // Regs.ax = &H5000 //Map the pages in the buffer
\r
322 // Regs.cx = NumPages //to the pageframe
\r
323 // Regs.dx = Handle
\r
324 // Regs.ds = VARSEG(MapInfo$)
\r
325 // Regs.si = SADD(MapInfo$)
\r
326 // InterruptX &H67, Regs, Regs
\r
327 // EMS.Error = (Regs.ax AND &HFF00&) \ &H100 //Store the status code
\r
332 //==========================================================================
335 ======================
339 = Check for XMM driver
341 =======================
344 boolean MML_CheckForXMS(mminfo_t *mm)
346 boolean errorflag=false;
352 int 0x2f // query status of installed diver
358 if(errorflag==true) return false;
364 ======================
368 = Try to allocate all upper memory block
370 =======================
373 void MML_SetupXMS(mminfo_t *mm, mminfotype *mmi)
382 mov [WORD PTR XMSaddr],bx
383 mov [WORD PTR XMSaddr+2],es // function pointer to XMS driver
386 mov dx,0xffff // try for largest block possible
387 //mov ax,dx // Set available Kbytes.
388 call [DWORD PTR XMSaddr]
392 cmp bl,0xb0 // error: smaller UMB is available
396 call [DWORD PTR XMSaddr] // DX holds largest available UMB
398 jz done // another error...
405 printf("base=%u ", base); printf("size=%u\n", size);
406 MML_UseSpace(base,size, mm);
407 mmi->XMSmem += size*16;
408 mm->UMBbase[mm->numUMBs] = base;
410 if(mm->numUMBs < MAXUMBS)
416 ======================
420 ======================
423 void MML_ShutdownXMS(mminfo_t *mm)
428 for (i=0;i<mm->numUMBs;i++)
430 base = mm->UMBbase[i];
435 call [DWORD PTR XMSaddr]
440 //==========================================================================
443 ======================
447 = Marks a range of paragraphs as usable by the memory manager
448 = This is used to mark space for the near heap, far heap, ems page frame,
449 = and upper memory blocks
451 ======================
454 void MML_UseSpace(/*d*/word segstart, dword seglength, mminfo_t *mm)
456 mmblocktype huge *scan,huge *last;
461 scan = last = mm->mmhead;
462 mm->mmrover = mm->mmhead; // reset rover to start of memory
465 // search for the block that contains the range of segments
467 while(scan->start+scan->length < segstart)
473 //find out how many blocks it spans!
474 if(seglength>0xffffu)
476 // segm=seglength/0x4000u;
477 segm=seglength/0xffffu;
482 if(segm>1/*extra>0xfffflu*/)
493 //MML_UseSpace(?segstart?, ?length?, mm);
499 //printf("MML_UseSpace: Segment spans two blocks!\n");
503 // take the given range out of the block
505 oldend = scan->start + scan->length;
506 extra = oldend - (segstart+seglength);
508 printf("segm=%u ", segm);
509 printf("ex=%lu ", extra);
510 printf("start+seglen=%lu ", segstart+seglength);
511 printf("len=%u ", scan->length);
512 printf("segsta=%x ", segstart);
513 printf("seglen=%lu\n", seglength);
516 //++++todo: linked list of segment!
517 //printf("segm=%lu\n", segm);
518 if(segstart == scan->start)
520 last->next = scan->next; // unlink block
521 MM_FreeBlock(scan, mm);
525 scan->length = segstart-scan->start; // shorten block
532 mm->mmnew->next = scan->next;
533 scan->next = mm->mmnew;
534 mm->mmnew->start = segstart+seglength;
535 mm->mmnew->length = extra;
536 mm->mmnew->attributes = LOCKBIT;
537 }//else if(segm>0) goto segu;
541 //==========================================================================
548 = We are out of blocks, so free a purgable block
553 void MML_ClearBlock(mminfo_t *mm)
555 mmblocktype huge *scan,huge *last;
557 scan = mm->mmhead->next;
561 if(!(scan->attributes&LOCKBIT) && (scan->attributes&PURGEBITS))
563 MM_FreePtr(scan->useptr, mm);
569 printf("MM_ClearBlock: No purgable blocks!\n");
573 //==========================================================================
580 = Grabs all space from turbo with malloc/farmalloc
581 = Allocates bufferseg misc buffer
586 void MM_Startup(mminfo_t *mm, mminfotype *mmi)
591 unsigned segstart,seglength,endfree;
596 mm->mmstarted = true;
597 mm->bombonerror = true;
599 // set up the linked list (everything in the free list;
602 mm->mmfree = &(mm->mmblocks[0]);
603 for(i=0;i<MAXBLOCKS-1;i++)
605 mm->mmblocks[i].next = &(mm->mmblocks[i+1]);
607 mm->mmblocks[i].next = NULL;
610 // locked block of all memory until we punch out free space
613 mm->mmhead = mm->mmnew; // this will allways be the first node
614 mm->mmnew->start = 0;
615 mm->mmnew->length = 0xffff;
616 mm->mmnew->attributes = LOCKBIT;
617 mm->mmnew->next = NULL;
618 mm->mmrover = mm->mmhead;
620 // farlen=_bios_memsize()*1024;
623 // get all available near conventional memory segments
625 //---- length=coreleft();
628 start = (void huge *)(mm->nearheap = malloc(length));
629 length -= 16-(FP_OFF(start)&15);
630 length -= SAVENEARHEAP;
631 seglength = length / 16; // now in paragraphs
632 segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
633 MML_UseSpace(segstart,seglength, mm);
634 mmi->nearheap = length;
635 //printf("near heap ok!\n");
638 // get all available far conventional memory segments
640 //---- length=farcoreleft();
643 start = mm->farheap = halloc(length, sizeof(byte));
644 //start = mm->farheap = _fmalloc(length);
645 length -= 16-(FP_OFF(start)&15);
646 length -= SAVEFARHEAP;
647 seglength = length / 16; // now in paragraphs
648 segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
649 MML_UseSpace(segstart,seglength, mm);
650 mmi->farheap = length;
651 mmi->mainmem = mmi->nearheap + mmi->farheap;
652 //printf("far heap ok!\n");
656 // detect EMS and allocate up to 64K at page frame
658 printf("EMS!\n\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); //bug!
660 for(i = 1;i < __argc;i++)
662 if(US_CheckParm(__argv[i],ParmStringsexmm) == 0)
663 goto emsskip; // param NOEMS
665 printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); //bug!
666 if(MML_CheckForEMS())
669 MML_SetupEMS(mm); // allocate space
671 printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); //bug!
672 //TODO: EMS4! AND EMS 3.2 MASSIVE DATA HANDLMENT!
673 MML_UseSpace(mm->EMSpageframe,(MAPPAGES)*0x4000lu, mm);
675 MM_MapEMS(mm); // map in used pages
677 mmi->EMSmem = (MAPPAGES)*0x4000lu;
681 // detect XMS and get upper memory blocks
685 for(i = 1;i < __argc;i++)
687 if(US_CheckParm(__argv[i],ParmStringsexmm) == 0)
688 goto xmsskip; // param NOXMS
690 printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); //bug!
691 if(MML_CheckForXMS(mm))
694 //MML_SetupXMS(mm, mmi); // allocate as many UMBs as possible
698 // allocate the misc buffer
701 mm->mmrover = mm->mmhead; // start looking for space after low block
703 MM_GetPtr(&(mm->bufferseg),BUFFERSIZE, mm, mmi);
706 //==========================================================================
713 = Frees all conventional, EMS, and XMS allocated
718 void MM_Shutdown(mminfo_t *mm)
724 printf("far freed\n");
726 printf("near freed\n");
727 //hfree(mm->hugeheap);
728 //printf("huge freed\n");
729 if(MML_CheckForEMS()){ MML_ShutdownEMS(mm); printf("EMS freed\n"); }
730 if(MML_CheckForXMS(mm)){ MML_ShutdownXMS(mm); printf("XMS freed\n"); }
733 //==========================================================================
740 = Allocates an unlocked, unpurgable block
745 void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
747 mmblocktype huge *scan,huge *lastscan,huge *endscan,huge *purge,huge *next;
749 unsigned needed,startseg;
751 needed = (size+15)/16; // convert size from bytes to paragraphs
753 MM_GetNewBlock(mm); // fill in start and next after a spot is found
754 mm->mmnew->length = needed;
755 mm->mmnew->useptr = baseptr;
756 mm->mmnew->attributes = BASEATTRIBUTES;
758 for(search = 0; search<3; search++)
761 // first search: try to allocate right after the rover, then on up
762 // second search: search from the head pointer up to the rover
763 // third search: compress memory, then scan from start
764 if(search == 1 && mm->mmrover == mm->mmhead)
770 lastscan = mm->mmrover;
771 scan = mm->mmrover->next;
775 lastscan = mm->mmhead;
776 scan = mm->mmhead->next;
777 endscan = mm->mmrover;
781 lastscan = mm->mmhead;
782 scan = mm->mmhead->next;
787 startseg = lastscan->start + lastscan->length;
789 while(scan != endscan)
791 if(scan->start - startseg >= needed)
794 // got enough space between the end of lastscan and
795 // the start of scan, so throw out anything in the middle
796 // and allocate the new block
798 purge = lastscan->next;
799 lastscan->next = mm->mmnew;
800 mm->mmnew->start = *(unsigned *)baseptr = startseg;
801 mm->mmnew->next = scan;
803 { // free the purgable block
805 MM_FreeBlock(purge, mm);
806 purge = next; // purge another if not at scan
808 mm->mmrover = mm->mmnew;
809 return; // good allocation!
813 // if this block is purge level zero or locked, skip past it
815 if((scan->attributes & LOCKBIT)
816 || !(scan->attributes & PURGEBITS) )
819 startseg = lastscan->start + lastscan->length;
823 scan=scan->next; // look at next line
828 printf(OUT_OF_MEM_MSG,(size-mmi->nearheap));
833 //==========================================================================
840 = Allocates an unlocked, unpurgable block
845 void MM_FreePtr(memptr *baseptr, mminfo_t *mm)
847 mmblocktype huge *scan,huge *last;
852 if(baseptr == mm->mmrover->useptr) // removed the last allocated block
853 mm->mmrover = mm->mmhead;
855 while(scan->useptr != baseptr && scan)
863 printf("MM_FreePtr: Block not found!\n");
867 last->next = scan->next;
869 MM_FreeBlock(scan, mm);
871 //==========================================================================
874 =====================
878 = Sets the purge level for a block (locked blocks cannot be made purgable)
880 =====================
883 void MM_SetPurge(memptr *baseptr, int purge, mminfo_t *mm)
885 mmblocktype huge *start;
891 if(mm->mmrover->useptr == baseptr)
894 mm->mmrover = mm->mmrover->next;
897 mm->mmrover = mm->mmhead;
898 else if(mm->mmrover == start)
900 printf("MM_SetPurge: Block not found!");
906 mm->mmrover->attributes &= ~PURGEBITS;
907 mm->mmrover->attributes |= purge;
910 //==========================================================================
913 =====================
917 = Locks / unlocks the block
919 =====================
922 void MM_SetLock(memptr *baseptr, boolean locked, mminfo_t *mm)
924 mmblocktype huge *start;
930 if(mm->mmrover->useptr == baseptr)
933 mm->mmrover = mm->mmrover->next;
936 mm->mmrover = mm->mmhead;
937 else if(mm->mmrover == start)
939 printf("MM_SetLock: Block not found!");
945 mm->mmrover->attributes &= ~LOCKBIT;
946 mm->mmrover->attributes |= locked*LOCKBIT;
949 //==========================================================================
952 =====================
956 = Throws out all purgable stuff and compresses movable blocks
958 =====================
961 void MM_SortMem(mminfo_t *mm)
963 mmblocktype huge *scan,huge *last,huge *next;
964 unsigned start,length,source,dest,oldborder;
968 // lock down a currently playing sound
970 /*++++ playing = SD_SoundPlaying ();
976 playing += STARTPCSOUNDS;
979 playing += STARTADLIBSOUNDS;
982 MM_SetLock(&(memptr)audiosegs[playing],true);
987 // oldborder = bordercolor;
988 // VW_ColorBorder (15);
995 last = NULL; // shut up compiler warning
999 if(scan->attributes & LOCKBIT)
1002 // block is locked, so try to pile later blocks right after it
1004 start = scan->start + scan->length;
1008 if(scan->attributes & PURGEBITS)
1011 // throw out the purgable block
1014 MM_FreeBlock(scan, mm);
1022 // push the non purgable block on top of the last moved block
1024 if(scan->start != start)
1026 length = scan->length;
1027 source = scan->start;
1029 while(length > 0xf00)
1031 movedata(source,0,dest,0,0xf00*16);
1036 movedata(source,0,dest,0,length*16);
1038 scan->start = start;
1039 *(unsigned *)scan->useptr = start;
1041 start = scan->start + scan->length;
1046 scan = scan->next; // go to next block
1049 mm->mmrover = mm->mmhead;
1054 // VW_ColorBorder (oldborder);
1057 MM_SetLock(&(memptr)audiosegs[playing],false);*/
1061 //==========================================================================
1065 =====================
1069 =====================
1072 void MM_ShowMemory(page_t *page, mminfo_t *mm)
1074 mmblocktype huge *scan;
1078 byte scratch[160],str[16];
1080 //**** VW_SetDefaultColors();
1081 //**** VW_SetLineWidth(40);
1082 //++++mh temp = bufferofs;
1083 //++++mh bufferofs = 0;
1084 //**** VW_SetScreen (0,0);
1097 if(scan->attributes & PURGEBITS)
1098 color = 5; // dark purple = purgable
1100 color = 9; // medium blue = non purgable
1101 if(scan->attributes & LOCKBIT)
1102 color = 12; // red = locked
1103 if(scan->start<=end)
1106 write(debughandle,"\nMM_ShowMemory: Memory block order currupted!\n",strlen("\nMM_ShowMemory: Memory block order currupted!\n"));
1107 //modexprint(&page, chx, chy, 1, 0, 24, "\nMM_ShowMemory: Memory block order currupted!\n");
1110 end = scan->start+scan->length-1;
1111 chy = scan->start/320;
1112 chx = scan->start%320;
1113 //modexhlin(page, scan->start, (unsigned)end, chy, color);
1114 //for(chx=scan->start;chx+4>=(word)end;chx+=4)
1116 modexClearRegion(page, chx, chy, 4, 4, color);
1119 //++++ VW_Hlin(scan->start,(unsigned)end,0,color);
1121 //++++ VW_Plot(scan->start,0,15);
1122 modexClearRegion(page, chx, chy, 4, 4, 15);
1123 if(scan->next->start > end+1)
1124 //++++ VW_Hlin(end+1,scan->next->start,0,0); // black = free
1125 //for(chx=scan->next->start;chx+4>=(word)end+1;chx+=4)
1127 chx+=scan->next->start;
1128 modexClearRegion(page, chx, chy, 4, 4, 2);
1130 //modexhlin(page, end+1,scan->next->start, chy, 0);
1133 end = scan->length-1;
1134 y = scan->start/320;
1135 x = scan->start%320;
1136 VW_Hlin(x,x+end,y,color);
1138 if (scan->next && scan->next->start > end+1)
1139 VW_Hlin(x+end+1,x+(scan->next->start-scan->start),y,0); // black = free
1143 printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); //bug!
1144 strcpy(scratch,"Seg:");
1145 ultoa (scan->start,str,16);
1146 strcat (scratch,str);
1147 strcat (scratch,"\tSize:");
1148 ltoa ((dword)scan->length*16,str,10);
1149 strcat (scratch,str);
1150 strcat (scratch,"\tOwner:0x");
1151 owner = (unsigned)scan->useptr;
1152 ultoa (owner,str,16);
1153 strcat (scratch,str);
1154 strcat (scratch,"\n");
1155 write(debughandle,scratch,strlen(scratch));
1156 //modexprint(page, chx, chy, 1, 0, 24, &scratch);
1158 //fprintf(stdout, "%s", scratch);
1167 //**** VW_SetLineWidth(64);
1168 //++++mh bufferofs = temp;
1172 //==========================================================================
1175 =====================
1179 =====================
1182 void MM_DumpData(mminfo_t *mm)
1184 mmblocktype far *scan,far *best;
1185 long lowest,oldlowest;
1191 free (mm->nearheap);
1192 dumpfile = fopen ("mmdump.txt","w");
1194 printf("MM_DumpData: Couldn't open MMDUMP.TXT!\n");
1207 owner = (word)scan->useptr;
1209 if (owner && owner<lowest && owner > oldlowest)
1218 if (lowest != 0xffff)
1220 if (best->attributes & PURGEBITS)
1224 if (best->attributes & LOCKBIT)
1228 fprintf (dumpfile,"0x%p (%c%c) = %u\n"
1229 ,(word)lowest,lock,purge,best->length);
1232 } while (lowest != 0xffff);
1235 printf("MMDUMP.TXT created.\n");
1238 //==========================================================================
1242 ======================
1246 = Returns the total free space without purging
1248 ======================
1251 dword MM_UnusedMemory(mminfo_t *mm)
1254 mmblocktype huge *scan;
1261 free += scan->next->start - (scan->start + scan->length);
1269 //==========================================================================
1273 ======================
1277 = Returns the total free space with purging
1279 ======================
1282 dword MM_TotalFree(mminfo_t *mm)
1285 mmblocktype huge *scan;
1292 if((scan->attributes&PURGEBITS) && !(scan->attributes&LOCKBIT))
1293 free += scan->length;
1294 free += scan->next->start - (scan->start + scan->length);
1302 //==========================================================================
1305 =====================
1309 =====================
1312 void MM_Report(page_t *page, mminfo_t *mm, mminfotype *mmi)
1314 if(MML_CheckForEMS())
1316 printf("EMM v%x.%x available\n", mm->EMSVer>>4,mm->EMSVer&0x0F);
1317 printf("totalEMSpages=%u\n", mm->totalEMSpages);
1318 printf("freeEMSpages=%u\n", mm->freeEMSpages);
1319 printf("EMSpageframe=%x\n", mm->EMSpageframe);
1321 if(MML_CheckForXMS(mm)) printf("XMSaddr=%Fp\n", *XMSaddr);
1322 printf("near=%lu\n", mmi->nearheap);
1323 printf("far=%lu\n", mmi->farheap);
1324 printf("EMSmem=%lu\n", mmi->EMSmem);
1325 printf("XMSmem=%lu\n", mmi->XMSmem);
1326 printf("mainmem=%lu\n", mmi->mainmem);
1327 printf("UnusedMemory=%lu\n", MM_UnusedMemory(mm));
1328 printf("TotalFree=%lu\n", MM_TotalFree(mm));
1330 // printf("UnusedMemory=%lu kb\n", MM_UnusedMemory()/10248);
1331 // printf("TotalFree=%lu kb\n", MM_TotalFree()/10248);
1334 //==========================================================================
1337 =====================
1341 =====================
1356 //==========================================================================
1359 =====================
1363 =====================
1366 void MM_BombOnError(boolean bomb, mminfo_t *mm)
1368 mm->bombonerror = bomb;
1371 void MM_GetNewBlock(mminfo_t *mm)
1375 mm->mmnew=mm->mmfree;
1376 mm->mmfree=mm->mmfree->next;
1377 /*if(!(mm->mmnew=mm->mmfree))
1379 printf("MM_GETNEWBLOCK: No free blocks!");
1382 mm->mmfree=mm->mmfree->next;*/
1385 void MM_FreeBlock(mmblocktype *x, mminfo_t *mm)
1392 void MM_seguin(void)
1403 void MM_segude(void)
1412 pull data from far and put it into ds var