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
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;
222 //mm->EMSstatus=EMSstatus;
228 ======================
232 =======================
235 void MML_ShutdownEMS(mminfo_t *mm)
237 boolean errorflag=false;
238 unsigned EMShandle=mm->EMShandle;
252 if(errorflag==true) printf("MML_ShutdownEMS: Error freeing EMS!"); //++++ add something
260 = Maps the 64k of EMS used by memory manager into the page frame
261 = for general use. This only needs to be called if you are keeping
262 = other things in EMS.
267 unsigned MM_MapEMS(mminfo_t *mm)
269 char str[80],str2[10];
270 unsigned err, EMShandle;
271 boolean errorflag=false;
274 EMShandle=mm->EMShandle;
276 for (i=0;i<4/*mm->EMSpagesmapped*/;i++)
281 mov bx,[i] // logical page
282 mov al,bl // physical page
283 mov dx,[EMShandle] // handle
295 strcpy(str,"MM_MapEMS: EMS error 0x");
298 //printf("%s\n",str);
299 printf("FACK! %u\n", err);
307 SUB EMS.MapXPages (PhysicalStart, LogicalStart, NumPages, Handle)
\r
309 '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
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
331 void MM_MapXEMS(mminfo_t *mm)
336 //==========================================================================
339 ======================
343 = Check for XMM driver
345 =======================
348 boolean MML_CheckForXMS(mminfo_t *mm)
350 boolean errorflag=false;
356 int 0x2f // query status of installed diver
362 if(errorflag==true) return false;
368 ======================
372 = Try to allocate all upper memory block
374 =======================
377 void MML_SetupXMS(mminfo_t *mm, mminfotype *mmi)
386 mov [WORD PTR XMSaddr],bx
387 mov [WORD PTR XMSaddr+2],es // function pointer to XMS driver
390 mov dx,0xffff // try for largest block possible
391 //mov ax,dx // Set available Kbytes.
392 call [DWORD PTR XMSaddr]
396 cmp bl,0xb0 // error: smaller UMB is available
400 call [DWORD PTR XMSaddr] // DX holds largest available UMB
402 jz done // another error...
409 printf("base=%u ", base); printf("size=%u\n", size);
410 MML_UseSpace(base,size, mm);
411 mmi->XMSmem += size*16;
412 mm->UMBbase[mm->numUMBs] = base;
414 if(mm->numUMBs < MAXUMBS)
420 ======================
424 ======================
427 void MML_ShutdownXMS(mminfo_t *mm)
432 for (i=0;i<mm->numUMBs;i++)
434 base = mm->UMBbase[i];
439 call [DWORD PTR XMSaddr]
444 //==========================================================================
447 ======================
451 = Marks a range of paragraphs as usable by the memory manager
452 = This is used to mark space for the near heap, far heap, ems page frame,
453 = and upper memory blocks
455 ======================
458 void MML_UseSpace(/*d*/word segstart, dword seglength, mminfo_t *mm)
460 mmblocktype huge *scan,huge *last;
465 scan = last = mm->mmhead;
466 mm->mmrover = mm->mmhead; // reset rover to start of memory
469 // search for the block that contains the range of segments
471 while(scan->start+scan->length < segstart)
477 //find out how many blocks it spans!
478 if(seglength>0xffffu)
480 // segm=seglength/0x4000u;
481 segm=seglength/0xffffu;
486 if(segm>1/*extra>0xfffflu*/)
497 //MML_UseSpace(?segstart?, ?length?, mm);
503 //printf("MML_UseSpace: Segment spans two blocks!\n");
507 // take the given range out of the block
509 oldend = scan->start + scan->length;
510 extra = oldend - (segstart+seglength);
512 printf("segm=%u ", segm);
513 printf("ex=%lu ", extra);
514 printf("start+seglen=%lu ", segstart+seglength);
515 printf("len=%u ", scan->length);
516 printf("segsta=%x ", segstart);
517 printf("seglen=%lu\n", seglength);
520 //++++todo: linked list of segment!
521 //printf("segm=%lu\n", segm);
522 if(segstart == scan->start)
524 last->next = scan->next; // unlink block
525 MM_FreeBlock(scan, mm);
529 scan->length = segstart-scan->start; // shorten block
536 mm->mmnew->next = scan->next;
537 scan->next = mm->mmnew;
538 mm->mmnew->start = segstart+seglength;
539 mm->mmnew->length = extra;
540 mm->mmnew->attributes = LOCKBIT;
541 }//else if(segm>0) goto segu;
545 //==========================================================================
552 = We are out of blocks, so free a purgable block
557 void MML_ClearBlock(mminfo_t *mm)
559 mmblocktype huge *scan,huge *last;
561 scan = mm->mmhead->next;
565 if(!(scan->attributes&LOCKBIT) && (scan->attributes&PURGEBITS))
567 MM_FreePtr(scan->useptr, mm);
573 printf("MM_ClearBlock: No purgable blocks!\n");
577 //==========================================================================
584 = Grabs all space from turbo with malloc/farmalloc
585 = Allocates bufferseg misc buffer
590 void MM_Startup(mminfo_t *mm, mminfotype *mmi)
595 unsigned segstart,seglength,endfree;
600 mm->mmstarted = true;
601 mm->bombonerror = true;
603 // set up the linked list (everything in the free list;
606 mm->mmfree = &(mm->mmblocks[0]);
607 for(i=0;i<MAXBLOCKS-1;i++)
609 mm->mmblocks[i].next = &(mm->mmblocks[i+1]);
611 mm->mmblocks[i].next = NULL;
614 // locked block of all memory until we punch out free space
617 mm->mmhead = mm->mmnew; // this will allways be the first node
618 mm->mmnew->start = 0;
619 mm->mmnew->length = 0xffff;
620 mm->mmnew->attributes = LOCKBIT;
621 mm->mmnew->next = NULL;
622 mm->mmrover = mm->mmhead;
624 // farlen=_bios_memsize()*1024;
627 // get all available near conventional memory segments
629 //---- length=coreleft();
632 start = (void huge *)(mm->nearheap = malloc(length));
633 length -= 16-(FP_OFF(start)&15);
634 length -= SAVENEARHEAP;
635 seglength = length / 16; // now in paragraphs
636 segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
637 MML_UseSpace(segstart,seglength, mm);
638 mmi->nearheap = length;
639 //printf("near heap ok!\n");
642 // get all available far conventional memory segments
644 //---- length=farcoreleft();
647 start = mm->farheap = halloc(length, sizeof(byte));
648 //start = mm->farheap = _fmalloc(length);
649 length -= 16-(FP_OFF(start)&15);
650 length -= SAVEFARHEAP;
651 seglength = length / 16; // now in paragraphs
652 segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
653 MML_UseSpace(segstart,seglength, mm);
654 mmi->farheap = length;
655 mmi->mainmem = mmi->nearheap + mmi->farheap;
656 //printf("far heap ok!\n");
660 // detect EMS and allocate up to 64K at page frame
662 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!
664 for(i = 1;i < __argc;i++)
666 if(US_CheckParm(__argv[i],ParmStringsexmm) == 0)
667 goto emsskip; // param NOEMS
669 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!
670 if(MML_CheckForEMS())
673 MML_SetupEMS(mm); // allocate space
675 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!
676 //TODO: EMS4! AND EMS 3.2 MASSIVE DATA HANDLMENT!
677 MML_UseSpace(mm->EMSpageframe,(MAPPAGES)*0x4000lu, mm);
679 MM_MapEMS(mm); // map in used pages
681 mmi->EMSmem = (MAPPAGES)*0x4000lu;
685 // detect XMS and get upper memory blocks
689 for(i = 1;i < __argc;i++)
691 if(US_CheckParm(__argv[i],ParmStringsexmm) == 0)
692 goto xmsskip; // param NOXMS
694 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!
695 if(MML_CheckForXMS(mm))
698 //MML_SetupXMS(mm, mmi); // allocate as many UMBs as possible
702 // allocate the misc buffer
705 mm->mmrover = mm->mmhead; // start looking for space after low block
707 MM_GetPtr(&(mm->bufferseg),BUFFERSIZE, mm, mmi);
710 //==========================================================================
717 = Frees all conventional, EMS, and XMS allocated
722 void MM_Shutdown(mminfo_t *mm)
728 printf("far freed\n");
730 printf("near freed\n");
731 //hfree(mm->hugeheap);
732 //printf("huge freed\n");
733 if(MML_CheckForEMS()){ MML_ShutdownEMS(mm); printf("EMS freed\n"); }
734 if(MML_CheckForXMS(mm)){ MML_ShutdownXMS(mm); printf("XMS freed\n"); }
737 //==========================================================================
744 = Allocates an unlocked, unpurgable block
749 void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
751 mmblocktype huge *scan,huge *lastscan,huge *endscan,huge *purge,huge *next;
753 unsigned needed,startseg;
755 needed = (size+15)/16; // convert size from bytes to paragraphs
757 MM_GetNewBlock(mm); // fill in start and next after a spot is found
758 mm->mmnew->length = needed;
759 mm->mmnew->useptr = baseptr;
760 mm->mmnew->attributes = BASEATTRIBUTES;
762 for(search = 0; search<3; search++)
765 // first search: try to allocate right after the rover, then on up
766 // second search: search from the head pointer up to the rover
767 // third search: compress memory, then scan from start
768 if(search == 1 && mm->mmrover == mm->mmhead)
774 lastscan = mm->mmrover;
775 scan = mm->mmrover->next;
779 lastscan = mm->mmhead;
780 scan = mm->mmhead->next;
781 endscan = mm->mmrover;
785 lastscan = mm->mmhead;
786 scan = mm->mmhead->next;
791 startseg = lastscan->start + lastscan->length;
793 while(scan != endscan)
795 if(scan->start - startseg >= needed)
798 // got enough space between the end of lastscan and
799 // the start of scan, so throw out anything in the middle
800 // and allocate the new block
802 purge = lastscan->next;
803 lastscan->next = mm->mmnew;
804 mm->mmnew->start = *(unsigned *)baseptr = startseg;
805 mm->mmnew->next = scan;
807 { // free the purgable block
809 MM_FreeBlock(purge, mm);
810 purge = next; // purge another if not at scan
812 mm->mmrover = mm->mmnew;
813 return; // good allocation!
817 // if this block is purge level zero or locked, skip past it
819 if((scan->attributes & LOCKBIT)
820 || !(scan->attributes & PURGEBITS) )
823 startseg = lastscan->start + lastscan->length;
827 scan=scan->next; // look at next line
832 printf(OUT_OF_MEM_MSG,(size-mmi->nearheap));
837 //==========================================================================
844 = Allocates an unlocked, unpurgable block
849 void MM_FreePtr(memptr *baseptr, mminfo_t *mm)
851 mmblocktype huge *scan,huge *last;
856 if(baseptr == mm->mmrover->useptr) // removed the last allocated block
857 mm->mmrover = mm->mmhead;
859 while(scan->useptr != baseptr && scan)
867 printf("MM_FreePtr: Block not found!");
871 last->next = scan->next;
873 MM_FreeBlock(scan, mm);
875 //==========================================================================
878 =====================
882 = Sets the purge level for a block (locked blocks cannot be made purgable)
884 =====================
887 void MM_SetPurge(memptr *baseptr, int purge, mminfo_t *mm)
889 mmblocktype huge *start;
895 if(mm->mmrover->useptr == baseptr)
898 mm->mmrover = mm->mmrover->next;
901 mm->mmrover = mm->mmhead;
902 else if(mm->mmrover == start)
904 printf("MM_SetPurge: Block not found!");
910 mm->mmrover->attributes &= ~PURGEBITS;
911 mm->mmrover->attributes |= purge;
914 //==========================================================================
917 =====================
921 = Locks / unlocks the block
923 =====================
926 void MM_SetLock(memptr *baseptr, boolean locked, mminfo_t *mm)
928 mmblocktype huge *start;
934 if(mm->mmrover->useptr == baseptr)
937 mm->mmrover = mm->mmrover->next;
940 mm->mmrover = mm->mmhead;
941 else if(mm->mmrover == start)
943 printf("MM_SetLock: Block not found!");
949 mm->mmrover->attributes &= ~LOCKBIT;
950 mm->mmrover->attributes |= locked*LOCKBIT;
953 //==========================================================================
956 =====================
960 = Throws out all purgable stuff and compresses movable blocks
962 =====================
965 void MM_SortMem(mminfo_t *mm)
967 mmblocktype huge *scan,huge *last,huge *next;
968 unsigned start,length,source,dest,oldborder;
972 // lock down a currently playing sound
974 /*++++ playing = SD_SoundPlaying ();
980 playing += STARTPCSOUNDS;
983 playing += STARTADLIBSOUNDS;
986 MM_SetLock(&(memptr)audiosegs[playing],true);
991 // oldborder = bordercolor;
992 // VW_ColorBorder (15);
999 last = NULL; // shut up compiler warning
1003 if(scan->attributes & LOCKBIT)
1006 // block is locked, so try to pile later blocks right after it
1008 start = scan->start + scan->length;
1012 if(scan->attributes & PURGEBITS)
1015 // throw out the purgable block
1018 MM_FreeBlock(scan, mm);
1026 // push the non purgable block on top of the last moved block
1028 if(scan->start != start)
1030 length = scan->length;
1031 source = scan->start;
1033 while(length > 0xf00)
1035 movedata(source,0,dest,0,0xf00*16);
1040 movedata(source,0,dest,0,length*16);
1042 scan->start = start;
1043 *(unsigned *)scan->useptr = start;
1045 start = scan->start + scan->length;
1050 scan = scan->next; // go to next block
1053 mm->mmrover = mm->mmhead;
1058 // VW_ColorBorder (oldborder);
1061 MM_SetLock(&(memptr)audiosegs[playing],false);*/
1065 //==========================================================================
1069 =====================
1073 =====================
1076 void MM_ShowMemory(page_t *page, mminfo_t *mm)
1078 mmblocktype huge *scan;
1082 byte scratch[160],str[16];
1084 //**** VW_SetDefaultColors();
1085 //**** VW_SetLineWidth(40);
1086 //++++mh temp = bufferofs;
1087 //++++mh bufferofs = 0;
1088 //**** VW_SetScreen (0,0);
1101 if(scan->attributes & PURGEBITS)
1102 color = 5; // dark purple = purgable
1104 color = 9; // medium blue = non purgable
1105 if(scan->attributes & LOCKBIT)
1106 color = 12; // red = locked
1107 if(scan->start<=end)
1110 write(debughandle,"\nMM_ShowMemory: Memory block order currupted!\n",strlen("\nMM_ShowMemory: Memory block order currupted!\n"));
1111 //modexprint(&page, chx, chy, 1, 0, 24, "\nMM_ShowMemory: Memory block order currupted!\n");
1114 end = scan->start+scan->length-1;
1115 chy = scan->start/320;
1116 chx = scan->start%320;
1117 //modexhlin(page, scan->start, (unsigned)end, chy, color);
1118 //for(chx=scan->start;chx+4>=(word)end;chx+=4)
1120 modexClearRegion(page, chx, chy, 4, 4, color);
1123 //++++ VW_Hlin(scan->start,(unsigned)end,0,color);
1125 //++++ VW_Plot(scan->start,0,15);
1126 modexClearRegion(page, chx, chy, 4, 4, 15);
1127 if(scan->next->start > end+1)
1128 //++++ VW_Hlin(end+1,scan->next->start,0,0); // black = free
1129 //for(chx=scan->next->start;chx+4>=(word)end+1;chx+=4)
1131 chx+=scan->next->start;
1132 modexClearRegion(page, chx, chy, 4, 4, 2);
1134 //modexhlin(page, end+1,scan->next->start, chy, 0);
1137 end = scan->length-1;
1138 y = scan->start/320;
1139 x = scan->start%320;
1140 VW_Hlin(x,x+end,y,color);
1142 if (scan->next && scan->next->start > end+1)
1143 VW_Hlin(x+end+1,x+(scan->next->start-scan->start),y,0); // black = free
1148 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!
1149 strcpy(scratch,"Seg:");
1150 ultoa (scan->start,str,16);
1151 strcat (scratch,str);
1152 strcat (scratch,"\tSize:");
1153 ltoa ((dword)scan->length*16,str,10);
1154 strcat (scratch,str);
1155 strcat (scratch,"\tOwner:0x");
1156 owner = (unsigned)scan->useptr;
1157 ultoa (owner,str,16);
1158 strcat (scratch,str);
1159 strcat (scratch,"\n");
1160 write(debughandle,scratch,strlen(scratch));
1161 //modexprint(page, chx, chy, 1, 0, 24, &scratch);
1163 //fprintf(stdout, "%s", scratch);
1172 //**** VW_SetLineWidth(64);
1173 //++++mh bufferofs = temp;
1177 //==========================================================================
\r
1180 =====================
\r
1184 =====================
\r
1187 void MM_DumpData(mminfo_t *mm)
\r
1189 mmblocktype far *scan,far *best;
\r
1190 long lowest,oldlowest;
\r
1196 free (mm->nearheap);
\r
1197 dumpfile = fopen ("mmdump.txt","w");
\r
1199 printf("MM_DumpData: Couldn't open MMDUMP.TXT!");
1206 oldlowest = lowest;
\r
1209 scan = mm->mmhead;
\r
1212 owner = (word)scan->useptr;
\r
1214 if (owner && owner<lowest && owner > oldlowest)
\r
1220 scan = scan->next;
\r
1223 if (lowest != 0xffff)
\r
1225 if (best->attributes & PURGEBITS)
\r
1229 if (best->attributes & LOCKBIT)
\r
1233 fprintf (dumpfile,"0x%p (%c%c) = %u\n"
\r
1234 ,(word)lowest,lock,purge,best->length);
\r
1237 } while (lowest != 0xffff);
\r
1239 fclose (dumpfile);
\r
1240 printf("MMDUMP.TXT created.");
\r
1243 //==========================================================================
1247 ======================
1251 = Returns the total free space without purging
1253 ======================
1256 dword MM_UnusedMemory(mminfo_t *mm)
1259 mmblocktype huge *scan;
1266 free += scan->next->start - (scan->start + scan->length);
1274 //==========================================================================
1278 ======================
1282 = Returns the total free space with purging
1284 ======================
1287 dword MM_TotalFree(mminfo_t *mm)
1290 mmblocktype huge *scan;
1297 if((scan->attributes&PURGEBITS) && !(scan->attributes&LOCKBIT))
1298 free += scan->length;
1299 free += scan->next->start - (scan->start + scan->length);
1307 //==========================================================================
1310 =====================
1314 =====================
1317 void MM_Report(page_t *page, mminfo_t *mm, mminfotype *mmi)
1320 if(MML_CheckForEMS())
1322 printf("Expanded memory manager present. EMM v%x.%x available\n", mm->EMSVer>>4,mm->EMSVer&0x0F);
1323 printf("totalEMSpages=%u\n", mm->totalEMSpages);
1324 printf("Page frame @0x%04x\n", mm->freeEMSpages);
1325 printf("EMSpageframe=%x\n", mm->EMSpageframe);
1327 if(MML_CheckForXMS(mm)) printf("XMSaddr=%Fp\n", *XMSaddr);
1328 printf("near=%lu\n", mmi->nearheap);
1329 printf("far=%lu\n", mmi->farheap);
1330 printf("EMSmem=%lu\n", mmi->EMSmem);
1331 printf("XMSmem=%lu\n", mmi->XMSmem);
1332 printf("mainmem=%lu\n", mmi->mainmem);
1333 printf("UnusedMemory=%lu\n", MM_UnusedMemory(mm));
1334 printf("TotalFree=%lu\n", MM_TotalFree(mm));
1336 // printf("UnusedMemory=%lu kb\n", MM_UnusedMemory()/10248);
1337 // printf("TotalFree=%lu kb\n", MM_TotalFree()/10248);
1340 //==========================================================================
1343 =====================
1347 =====================
1362 //==========================================================================
1365 =====================
1369 =====================
1372 void MM_BombOnError(boolean bomb, mminfo_t *mm)
1374 mm->bombonerror = bomb;
1377 void MM_GetNewBlock(mminfo_t *mm)
1381 mm->mmnew=mm->mmfree;
1382 mm->mmfree=mm->mmfree->next;
1383 /*if(!(mm->mmnew=mm->mmfree))
1385 printf("MM_GETNEWBLOCK: No free blocks!");
1388 mm->mmfree=mm->mmfree->next;*/
1391 void MM_FreeBlock(mmblocktype *x, mminfo_t *mm)
1398 void MM_seguin(void)
1409 void MM_segude(void)
1418 pull data from far and put it into ds var