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 byte 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 //err = CPURegs.h.ah;
211 strcpy(str,"MML_SetupEMS: EMS error 0x");
214 //printf("%s\n",str);
215 printf("%s%x\n",str,err);
218 mm->totalEMSpages=totalEMSpages;
219 mm->freeEMSpages=freeEMSpages;
220 mm->EMSpageframe=EMSpageframe;
221 mm->EMSpagesmapped=EMSpagesmapped;
222 mm->EMShandle=EMShandle;
229 ======================
233 =======================
236 void MML_ShutdownEMS(mminfo_t *mm)
238 boolean errorflag=false;
239 unsigned EMShandle=mm->EMShandle;
253 if(errorflag==true) printf("MML_ShutdownEMS: Error freeing EMS!"); //++++ add something
261 = Maps the 64k of EMS used by memory manager into the page frame
262 = for general use. This only needs to be called if you are keeping
263 = other things in EMS.
268 byte MM_MapEMS(mminfo_t *mm)
270 char str[80];//,str2[10];
271 unsigned /*err, */EMShandle;
273 boolean errorflag=false;
276 EMShandle=mm->EMShandle;
278 for (i=0;i<MAPPAGES;i++)
283 mov bx,[i] // logical page
284 mov al,bl // physical page
285 mov dx,[EMShandle] // handle
297 //err = CPURegs.h.ah;
298 strcpy(str,"MM_MapEMS: EMS error 0x");
301 //printf("%s\n",str);
302 printf("%s%x\n",str, err);
303 //printf("FACK! %x\n", err);
310 void MM_MapXEMS(mminfo_t *mm)
313 //SUB EMS.MapXPages (PhysicalStart, LogicalStart, NumPages, Handle)
\r
315 //Maps up to 4 logical EMS pages to physical pages in the page frame, where:
\r
316 //PhysicalStart = Physical page first logical page is mapped to
\r
317 //LogicalStart = First logical page to map
\r
318 //NumPages = Number of pages to map (1 to 4)
\r
319 //Handle = EMS handle logical pages are allocated to
\r
321 /*//Create a buffer containing the page information
\r
322 // FOR x = 0 TO NumPages - 1
\r
323 // MapInfo$ = MapInfo$ + MKI$(LogicalStart + x) + MKI$(PhysicalStart + x)
\r
326 // Regs.ax = &H5000 //Map the pages in the buffer
\r
327 // Regs.cx = NumPages //to the pageframe
\r
328 // Regs.dx = Handle
\r
329 // Regs.ds = VARSEG(MapInfo$)
\r
330 // Regs.si = SADD(MapInfo$)
\r
331 // InterruptX &H67, Regs, Regs
\r
332 // EMS.Error = (Regs.ax AND &HFF00&) \ &H100 //Store the status code
\r
337 //==========================================================================
340 ======================
344 = Check for XMM driver
346 =======================
349 boolean MML_CheckForXMS(mminfo_t *mm)
351 boolean errorflag=false;
357 int 0x2f // query status of installed diver
363 if(errorflag==true) return false;
369 ======================
373 = Try to allocate all upper memory block
375 =======================
378 void MML_SetupXMS(mminfo_t *mm, mminfotype *mmi)
387 mov [WORD PTR XMSaddr],bx
388 mov [WORD PTR XMSaddr+2],es // function pointer to XMS driver
391 mov dx,0xffff // try for largest block possible
392 //mov ax,dx // Set available Kbytes.
393 call [DWORD PTR XMSaddr]
397 cmp bl,0xb0 // error: smaller UMB is available
401 call [DWORD PTR XMSaddr] // DX holds largest available UMB
403 jz done // another error...
410 printf("base=%u ", base); printf("size=%u\n", size);
411 MML_UseSpace(base,size, mm);
412 mmi->XMSmem += size*16;
413 mm->UMBbase[mm->numUMBs] = base;
415 if(mm->numUMBs < MAXUMBS)
421 ======================
425 ======================
428 void MML_ShutdownXMS(mminfo_t *mm)
433 for (i=0;i<mm->numUMBs;i++)
435 base = mm->UMBbase[i];
440 call [DWORD PTR XMSaddr]
445 //==========================================================================
448 ======================
452 = Marks a range of paragraphs as usable by the memory manager
453 = This is used to mark space for the near heap, far heap, ems page frame,
454 = and upper memory blocks
456 ======================
459 void MML_UseSpace(/*d*/word segstart, dword seglength, mminfo_t *mm)
461 mmblocktype huge *scan,huge *last;
466 scan = last = mm->mmhead;
467 mm->mmrover = mm->mmhead; // reset rover to start of memory
470 // search for the block that contains the range of segments
472 while(scan->start+scan->length < segstart)
478 //find out how many blocks it spans!
479 if(seglength>0xffffu)
481 // segm=seglength/0x4000u;
482 segm=seglength/0xffffu;
487 if(segm>1/*extra>0xfffflu*/)
498 //MML_UseSpace(?segstart?, ?length?, mm);
504 //printf("MML_UseSpace: Segment spans two blocks!\n");
508 // take the given range out of the block
510 oldend = scan->start + scan->length;
511 extra = oldend - (segstart+seglength);
513 printf("segm=%u ", segm);
514 printf("ex=%lu ", extra);
515 printf("start+seglen=%lu ", segstart+seglength);
516 printf("len=%u ", scan->length);
517 printf("segsta=%x ", segstart);
518 printf("seglen=%lu\n", seglength);
521 //++++todo: linked list of segment!
522 //printf("segm=%lu\n", segm);
523 if(segstart == scan->start)
525 last->next = scan->next; // unlink block
526 MM_FreeBlock(scan, mm);
530 scan->length = segstart-scan->start; // shorten block
537 mm->mmnew->next = scan->next;
538 scan->next = mm->mmnew;
539 mm->mmnew->start = segstart+seglength;
540 mm->mmnew->length = extra;
541 mm->mmnew->attributes = LOCKBIT;
542 }//else if(segm>0) goto segu;
546 //==========================================================================
553 = We are out of blocks, so free a purgable block
558 void MML_ClearBlock(mminfo_t *mm)
560 mmblocktype huge *scan,huge *last;
562 scan = mm->mmhead->next;
566 if(!(scan->attributes&LOCKBIT) && (scan->attributes&PURGEBITS))
568 MM_FreePtr(scan->useptr, mm);
574 printf("MM_ClearBlock: No purgable blocks!\n");
578 //==========================================================================
585 = Grabs all space from turbo with malloc/farmalloc
586 = Allocates bufferseg misc buffer
591 void MM_Startup(mminfo_t *mm, mminfotype *mmi)
596 unsigned segstart,seglength,endfree;
601 mm->mmstarted = true;
602 mm->bombonerror = true;
604 // set up the linked list (everything in the free list;
607 mm->mmfree = &(mm->mmblocks[0]);
608 for(i=0;i<MAXBLOCKS-1;i++)
610 mm->mmblocks[i].next = &(mm->mmblocks[i+1]);
612 mm->mmblocks[i].next = NULL;
615 // locked block of all memory until we punch out free space
618 mm->mmhead = mm->mmnew; // this will allways be the first node
619 mm->mmnew->start = 0;
620 mm->mmnew->length = 0xffff;
621 mm->mmnew->attributes = LOCKBIT;
622 mm->mmnew->next = NULL;
623 mm->mmrover = mm->mmhead;
625 // farlen=_bios_memsize()*1024;
628 // get all available near conventional memory segments
630 //---- length=coreleft();
633 start = (void huge *)(mm->nearheap = malloc(length));
634 length -= 16-(FP_OFF(start)&15);
635 length -= SAVENEARHEAP;
636 seglength = length / 16; // now in paragraphs
637 segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
638 MML_UseSpace(segstart,seglength, mm);
639 mmi->nearheap = length;
640 //printf("near heap ok!\n");
643 // get all available far conventional memory segments
645 //---- length=farcoreleft();
648 start = mm->farheap = halloc(length, sizeof(byte));
649 //start = mm->farheap = _fmalloc(length);
650 length -= 16-(FP_OFF(start)&15);
651 length -= SAVEFARHEAP;
652 seglength = length / 16; // now in paragraphs
653 segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
654 MML_UseSpace(segstart,seglength, mm);
655 mmi->farheap = length;
656 mmi->mainmem = mmi->nearheap + mmi->farheap;
657 //printf("far heap ok!\n");
661 // detect EMS and allocate up to 64K at page frame
663 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!
665 for(i = 1;i < __argc;i++)
667 if(US_CheckParm(__argv[i],ParmStringsexmm) == 0)
668 goto emsskip; // param NOEMS
670 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!
671 if(MML_CheckForEMS())
674 MML_SetupEMS(mm); // allocate space
676 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!
677 //TODO: EMS4! AND EMS 3.2 MASSIVE DATA HANDLMENT!
678 MML_UseSpace(mm->EMSpageframe,(MAPPAGES)*0x4000lu, mm);
680 MM_MapEMS(mm); // map in used pages
682 mmi->EMSmem = (MAPPAGES)*0x4000lu;
686 // detect XMS and get upper memory blocks
690 for(i = 1;i < __argc;i++)
692 if(US_CheckParm(__argv[i],ParmStringsexmm) == 0)
693 goto xmsskip; // param NOXMS
695 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!
696 if(MML_CheckForXMS(mm))
699 //MML_SetupXMS(mm, mmi); // allocate as many UMBs as possible
703 // allocate the misc buffer
706 mm->mmrover = mm->mmhead; // start looking for space after low block
708 MM_GetPtr(&(mm->bufferseg),BUFFERSIZE, mm, mmi);
711 //==========================================================================
718 = Frees all conventional, EMS, and XMS allocated
723 void MM_Shutdown(mminfo_t *mm)
729 printf("far freed\n");
731 printf("near freed\n");
732 //hfree(mm->hugeheap);
733 //printf("huge freed\n");
734 if(MML_CheckForEMS()){ MML_ShutdownEMS(mm); printf("EMS freed\n"); }
735 if(MML_CheckForXMS(mm)){ MML_ShutdownXMS(mm); printf("XMS freed\n"); }
738 //==========================================================================
745 = Allocates an unlocked, unpurgable block
750 void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
752 mmblocktype huge *scan,huge *lastscan,huge *endscan,huge *purge,huge *next;
754 unsigned needed,startseg;
756 needed = (size+15)/16; // convert size from bytes to paragraphs
758 MM_GetNewBlock(mm); // fill in start and next after a spot is found
759 mm->mmnew->length = needed;
760 mm->mmnew->useptr = baseptr;
761 mm->mmnew->attributes = BASEATTRIBUTES;
763 for(search = 0; search<3; search++)
766 // first search: try to allocate right after the rover, then on up
767 // second search: search from the head pointer up to the rover
768 // third search: compress memory, then scan from start
769 if(search == 1 && mm->mmrover == mm->mmhead)
775 lastscan = mm->mmrover;
776 scan = mm->mmrover->next;
780 lastscan = mm->mmhead;
781 scan = mm->mmhead->next;
782 endscan = mm->mmrover;
786 lastscan = mm->mmhead;
787 scan = mm->mmhead->next;
792 startseg = lastscan->start + lastscan->length;
794 while(scan != endscan)
796 if(scan->start - startseg >= needed)
799 // got enough space between the end of lastscan and
800 // the start of scan, so throw out anything in the middle
801 // and allocate the new block
803 purge = lastscan->next;
804 lastscan->next = mm->mmnew;
805 mm->mmnew->start = *(unsigned *)baseptr = startseg;
806 mm->mmnew->next = scan;
808 { // free the purgable block
810 MM_FreeBlock(purge, mm);
811 purge = next; // purge another if not at scan
813 mm->mmrover = mm->mmnew;
814 return; // good allocation!
818 // if this block is purge level zero or locked, skip past it
820 if((scan->attributes & LOCKBIT)
821 || !(scan->attributes & PURGEBITS) )
824 startseg = lastscan->start + lastscan->length;
828 scan=scan->next; // look at next line
833 printf(OUT_OF_MEM_MSG,(size-mmi->nearheap));
838 //==========================================================================
845 = Allocates an unlocked, unpurgable block
850 void MM_FreePtr(memptr *baseptr, mminfo_t *mm)
852 mmblocktype huge *scan,huge *last;
857 if(baseptr == mm->mmrover->useptr) // removed the last allocated block
858 mm->mmrover = mm->mmhead;
860 while(scan->useptr != baseptr && scan)
868 printf("MM_FreePtr: Block not found!\n");
872 last->next = scan->next;
874 MM_FreeBlock(scan, mm);
876 //==========================================================================
879 =====================
883 = Sets the purge level for a block (locked blocks cannot be made purgable)
885 =====================
888 void MM_SetPurge(memptr *baseptr, int purge, mminfo_t *mm)
890 mmblocktype huge *start;
896 if(mm->mmrover->useptr == baseptr)
899 mm->mmrover = mm->mmrover->next;
902 mm->mmrover = mm->mmhead;
903 else if(mm->mmrover == start)
905 printf("MM_SetPurge: Block not found!");
911 mm->mmrover->attributes &= ~PURGEBITS;
912 mm->mmrover->attributes |= purge;
915 //==========================================================================
918 =====================
922 = Locks / unlocks the block
924 =====================
927 void MM_SetLock(memptr *baseptr, boolean locked, mminfo_t *mm)
929 mmblocktype huge *start;
935 if(mm->mmrover->useptr == baseptr)
938 mm->mmrover = mm->mmrover->next;
941 mm->mmrover = mm->mmhead;
942 else if(mm->mmrover == start)
944 printf("MM_SetLock: Block not found!");
950 mm->mmrover->attributes &= ~LOCKBIT;
951 mm->mmrover->attributes |= locked*LOCKBIT;
954 //==========================================================================
957 =====================
961 = Throws out all purgable stuff and compresses movable blocks
963 =====================
966 void MM_SortMem(mminfo_t *mm)
968 mmblocktype huge *scan,huge *last,huge *next;
969 unsigned start,length,source,dest,oldborder;
973 // lock down a currently playing sound
975 /*++++ playing = SD_SoundPlaying ();
981 playing += STARTPCSOUNDS;
984 playing += STARTADLIBSOUNDS;
987 MM_SetLock(&(memptr)audiosegs[playing],true);
992 // oldborder = bordercolor;
993 // VW_ColorBorder (15);
1000 last = NULL; // shut up compiler warning
1004 if(scan->attributes & LOCKBIT)
1007 // block is locked, so try to pile later blocks right after it
1009 start = scan->start + scan->length;
1013 if(scan->attributes & PURGEBITS)
1016 // throw out the purgable block
1019 MM_FreeBlock(scan, mm);
1027 // push the non purgable block on top of the last moved block
1029 if(scan->start != start)
1031 length = scan->length;
1032 source = scan->start;
1034 while(length > 0xf00)
1036 movedata(source,0,dest,0,0xf00*16);
1041 movedata(source,0,dest,0,length*16);
1043 scan->start = start;
1044 *(unsigned *)scan->useptr = start;
1046 start = scan->start + scan->length;
1051 scan = scan->next; // go to next block
1054 mm->mmrover = mm->mmhead;
1059 // VW_ColorBorder (oldborder);
1062 MM_SetLock(&(memptr)audiosegs[playing],false);*/
1066 //==========================================================================
1070 =====================
1074 =====================
1077 void MM_ShowMemory(page_t *page, mminfo_t *mm)
1079 mmblocktype huge *scan;
1083 byte scratch[160],str[16];
1085 //**** VW_SetDefaultColors();
1086 //**** VW_SetLineWidth(40);
1087 //++++mh temp = bufferofs;
1088 //++++mh bufferofs = 0;
1089 //**** VW_SetScreen (0,0);
1102 if(scan->attributes & PURGEBITS)
1103 color = 5; // dark purple = purgable
1105 color = 9; // medium blue = non purgable
1106 if(scan->attributes & LOCKBIT)
1107 color = 12; // red = locked
1108 if(scan->start<=end)
1111 write(debughandle,"\nMM_ShowMemory: Memory block order currupted!\n",strlen("\nMM_ShowMemory: Memory block order currupted!\n"));
1112 //modexprint(&page, chx, chy, 1, 0, 24, "\nMM_ShowMemory: Memory block order currupted!\n");
1115 end = scan->start+scan->length-1;
1116 chy = scan->start/320;
1117 chx = scan->start%320;
1118 //modexhlin(page, scan->start, (unsigned)end, chy, color);
1119 //for(chx=scan->start;chx+4>=(word)end;chx+=4)
1121 modexClearRegion(page, chx, chy, 4, 4, color);
1124 //++++ VW_Hlin(scan->start,(unsigned)end,0,color);
1126 //++++ VW_Plot(scan->start,0,15);
1127 modexClearRegion(page, chx, chy, 4, 4, 15);
1128 if(scan->next->start > end+1)
1129 //++++ VW_Hlin(end+1,scan->next->start,0,0); // black = free
1130 //for(chx=scan->next->start;chx+4>=(word)end+1;chx+=4)
1132 chx+=scan->next->start;
1133 modexClearRegion(page, chx, chy, 4, 4, 2);
1135 //modexhlin(page, end+1,scan->next->start, chy, 0);
1138 end = scan->length-1;
1139 y = scan->start/320;
1140 x = scan->start%320;
1141 VW_Hlin(x,x+end,y,color);
1143 if (scan->next && scan->next->start > end+1)
1144 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 //==========================================================================
1180 =====================
1184 =====================
1187 void MM_DumpData(mminfo_t *mm)
1189 mmblocktype far *scan,far *best;
1190 long lowest,oldlowest;
1196 free (mm->nearheap);
1197 dumpfile = fopen ("mmdump.txt","w");
1199 printf("MM_DumpData: Couldn't open MMDUMP.TXT!\n");
1212 owner = (word)scan->useptr;
1214 if (owner && owner<lowest && owner > oldlowest)
1223 if (lowest != 0xffff)
1225 if (best->attributes & PURGEBITS)
1229 if (best->attributes & LOCKBIT)
1233 fprintf (dumpfile,"0x%p (%c%c) = %u\n"
1234 ,(word)lowest,lock,purge,best->length);
1237 } while (lowest != 0xffff);
1240 printf("MMDUMP.TXT created.\n");
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)
1319 if(MML_CheckForEMS())
1321 printf("EMM v%x.%x available\n", mm->EMSVer>>4,mm->EMSVer&0x0F);
1322 printf("totalEMSpages=%u\n", mm->totalEMSpages);
1323 printf("freeEMSpages=%u\n", mm->freeEMSpages);
1324 printf("EMSpageframe=%x\n", mm->EMSpageframe);
1326 if(MML_CheckForXMS(mm)) printf("XMSaddr=%Fp\n", *XMSaddr);
1327 printf("near=%lu\n", mmi->nearheap);
1328 printf("far=%lu\n", mmi->farheap);
1329 printf("EMSmem=%lu\n", mmi->EMSmem);
1330 printf("XMSmem=%lu\n", mmi->XMSmem);
1331 printf("mainmem=%lu\n", mmi->mainmem);
1332 printf("UnusedMemory=%lu\n", MM_UnusedMemory(mm));
1333 printf("TotalFree=%lu\n", MM_TotalFree(mm));
1335 // printf("UnusedMemory=%lu kb\n", MM_UnusedMemory()/10248);
1336 // printf("TotalFree=%lu kb\n", MM_TotalFree()/10248);
1339 //==========================================================================
1342 =====================
1346 =====================
1361 //==========================================================================
1364 =====================
1368 =====================
1371 void MM_BombOnError(boolean bomb, mminfo_t *mm)
1373 mm->bombonerror = bomb;
1376 void MM_GetNewBlock(mminfo_t *mm)
1380 mm->mmnew=mm->mmfree;
1381 mm->mmfree=mm->mmfree->next;
1382 /*if(!(mm->mmnew=mm->mmfree))
1384 printf("MM_GETNEWBLOCK: No free blocks!");
1387 mm->mmfree=mm->mmfree->next;*/
1390 void MM_FreeBlock(mmblocktype *x, mminfo_t *mm)
1397 void MM_seguin(void)
1408 void MM_segude(void)
1417 pull data from far and put it into ds var