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);
306 SUB EMS.MapXPages (PhysicalStart, LogicalStart, NumPages, Handle)
\r
308 'Maps up to 4 logical EMS pages to physical pages in the page frame, where:
\r
310 'PhysicalStart = Physical page first logical page is mapped to
\r
311 'LogicalStart = First logical page to map
\r
312 'NumPages = Number of pages to map (1 to 4)
\r
313 'Handle = EMS handle logical pages are allocated to
\r
315 'Create a buffer containing the page information
\r
316 FOR x = 0 TO NumPages - 1
\r
317 MapInfo$ = MapInfo$ + MKI$(LogicalStart + x) + MKI$(PhysicalStart + x)
\r
320 Regs.ax = &H5000 'Map the pages in the buffer
\r
321 Regs.cx = NumPages 'to the pageframe
\r
323 Regs.ds = VARSEG(MapInfo$)
\r
324 Regs.si = SADD(MapInfo$)
\r
325 InterruptX &H67, Regs, Regs
\r
326 EMS.Error = (Regs.ax AND &HFF00&) \ &H100 'Store the status code
\r
330 void MM_MapXEMS(mminfo_t *mm)
335 //==========================================================================
338 ======================
342 = Check for XMM driver
344 =======================
347 boolean MML_CheckForXMS(mminfo_t *mm)
349 boolean errorflag=false;
355 int 0x2f // query status of installed diver
361 if(errorflag==true) return false;
367 ======================
371 = Try to allocate all upper memory block
373 =======================
376 void MML_SetupXMS(mminfo_t *mm, mminfotype *mmi)
385 mov [WORD PTR XMSaddr],bx
386 mov [WORD PTR XMSaddr+2],es // function pointer to XMS driver
389 mov dx,0xffff // try for largest block possible
390 //mov ax,dx // Set available Kbytes.
391 call [DWORD PTR XMSaddr]
395 cmp bl,0xb0 // error: smaller UMB is available
399 call [DWORD PTR XMSaddr] // DX holds largest available UMB
401 jz done // another error...
408 printf("base=%u ", base); printf("size=%u\n", size);
409 MML_UseSpace(base,size, mm);
410 mmi->XMSmem += size*16;
411 mm->UMBbase[mm->numUMBs] = base;
413 if(mm->numUMBs < MAXUMBS)
419 ======================
423 ======================
426 void MML_ShutdownXMS(mminfo_t *mm)
431 for (i=0;i<mm->numUMBs;i++)
433 base = mm->UMBbase[i];
438 call [DWORD PTR XMSaddr]
443 //==========================================================================
446 ======================
450 = Marks a range of paragraphs as usable by the memory manager
451 = This is used to mark space for the near heap, far heap, ems page frame,
452 = and upper memory blocks
454 ======================
457 void MML_UseSpace(/*d*/word segstart, dword seglength, mminfo_t *mm)
459 mmblocktype huge *scan,huge *last;
464 scan = last = mm->mmhead;
465 mm->mmrover = mm->mmhead; // reset rover to start of memory
468 // search for the block that contains the range of segments
470 while(scan->start+scan->length < segstart)
476 //find out how many blocks it spans!
477 if(seglength>0xffffu)
479 // segm=seglength/0x4000u;
480 segm=seglength/0xffffu;
485 if(segm>1/*extra>0xfffflu*/)
496 //MML_UseSpace(?segstart?, ?length?, mm);
502 //printf("MML_UseSpace: Segment spans two blocks!\n");
506 // take the given range out of the block
508 oldend = scan->start + scan->length;
509 extra = oldend - (segstart+seglength);
511 printf("segm=%u ", segm);
512 printf("ex=%lu ", extra);
513 printf("start+seglen=%lu ", segstart+seglength);
514 printf("len=%u ", scan->length);
515 printf("segsta=%x ", segstart);
516 printf("seglen=%lu\n", seglength);
519 //++++todo: linked list of segment!
520 //printf("segm=%lu\n", segm);
521 if(segstart == scan->start)
523 last->next = scan->next; // unlink block
524 MM_FreeBlock(scan, mm);
528 scan->length = segstart-scan->start; // shorten block
535 mm->mmnew->next = scan->next;
536 scan->next = mm->mmnew;
537 mm->mmnew->start = segstart+seglength;
538 mm->mmnew->length = extra;
539 mm->mmnew->attributes = LOCKBIT;
540 }//else if(segm>0) goto segu;
544 //==========================================================================
551 = We are out of blocks, so free a purgable block
556 void MML_ClearBlock(mminfo_t *mm)
558 mmblocktype huge *scan,huge *last;
560 scan = mm->mmhead->next;
564 if(!(scan->attributes&LOCKBIT) && (scan->attributes&PURGEBITS))
566 MM_FreePtr(scan->useptr, mm);
572 printf("MM_ClearBlock: No purgable blocks!\n");
576 //==========================================================================
583 = Grabs all space from turbo with malloc/farmalloc
584 = Allocates bufferseg misc buffer
589 void MM_Startup(mminfo_t *mm, mminfotype *mmi)
594 unsigned segstart,seglength,endfree;
599 mm->mmstarted = true;
600 mm->bombonerror = true;
602 // set up the linked list (everything in the free list;
605 mm->mmfree = &(mm->mmblocks[0]);
606 for(i=0;i<MAXBLOCKS-1;i++)
608 mm->mmblocks[i].next = &(mm->mmblocks[i+1]);
610 mm->mmblocks[i].next = NULL;
613 // locked block of all memory until we punch out free space
616 mm->mmhead = mm->mmnew; // this will allways be the first node
617 mm->mmnew->start = 0;
618 mm->mmnew->length = 0xffff;
619 mm->mmnew->attributes = LOCKBIT;
620 mm->mmnew->next = NULL;
621 mm->mmrover = mm->mmhead;
623 // farlen=_bios_memsize()*1024;
626 // get all available near conventional memory segments
628 //---- length=coreleft();
631 start = (void huge *)(mm->nearheap = malloc(length));
632 length -= 16-(FP_OFF(start)&15);
633 length -= SAVENEARHEAP;
634 seglength = length / 16; // now in paragraphs
635 segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
636 MML_UseSpace(segstart,seglength, mm);
637 mmi->nearheap = length;
638 //printf("near heap ok!\n");
641 // get all available far conventional memory segments
643 //---- length=farcoreleft();
646 start = mm->farheap = halloc(length, sizeof(byte));
647 //start = mm->farheap = _fmalloc(length);
648 length -= 16-(FP_OFF(start)&15);
649 length -= SAVEFARHEAP;
650 seglength = length / 16; // now in paragraphs
651 segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
652 MML_UseSpace(segstart,seglength, mm);
653 mmi->farheap = length;
654 mmi->mainmem = mmi->nearheap + mmi->farheap;
655 //printf("far heap ok!\n");
659 // detect EMS and allocate up to 64K at page frame
661 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!
663 for(i = 1;i < __argc;i++)
665 if(US_CheckParm(__argv[i],ParmStringsexmm) == 0)
666 goto emsskip; // param NOEMS
668 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!
669 if(MML_CheckForEMS())
672 MML_SetupEMS(mm); // allocate space
674 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!
675 //TODO: EMS4! AND EMS 3.2 MASSIVE DATA HANDLMENT!
676 MML_UseSpace(mm->EMSpageframe,(MAPPAGES)*0x4000lu, mm);
678 MM_MapEMS(mm); // map in used pages
680 mmi->EMSmem = (MAPPAGES)*0x4000lu;
684 // detect XMS and get upper memory blocks
688 for(i = 1;i < __argc;i++)
690 if(US_CheckParm(__argv[i],ParmStringsexmm) == 0)
691 goto xmsskip; // param NOXMS
693 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!
694 if(MML_CheckForXMS(mm))
697 //MML_SetupXMS(mm, mmi); // allocate as many UMBs as possible
701 // allocate the misc buffer
704 mm->mmrover = mm->mmhead; // start looking for space after low block
706 MM_GetPtr(&(mm->bufferseg),BUFFERSIZE, mm, mmi);
709 //==========================================================================
716 = Frees all conventional, EMS, and XMS allocated
721 void MM_Shutdown(mminfo_t *mm)
727 printf("far freed\n");
729 printf("near freed\n");
730 //hfree(mm->hugeheap);
731 //printf("huge freed\n");
732 if(MML_CheckForEMS()){ MML_ShutdownEMS(mm); printf("EMS freed\n"); }
733 if(MML_CheckForXMS(mm)){ MML_ShutdownXMS(mm); printf("XMS freed\n"); }
736 //==========================================================================
743 = Allocates an unlocked, unpurgable block
748 void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
750 mmblocktype huge *scan,huge *lastscan,huge *endscan,huge *purge,huge *next;
752 unsigned needed,startseg;
754 needed = (size+15)/16; // convert size from bytes to paragraphs
756 MM_GetNewBlock(mm); // fill in start and next after a spot is found
757 mm->mmnew->length = needed;
758 mm->mmnew->useptr = baseptr;
759 mm->mmnew->attributes = BASEATTRIBUTES;
761 for(search = 0; search<3; search++)
764 // first search: try to allocate right after the rover, then on up
765 // second search: search from the head pointer up to the rover
766 // third search: compress memory, then scan from start
767 if(search == 1 && mm->mmrover == mm->mmhead)
773 lastscan = mm->mmrover;
774 scan = mm->mmrover->next;
778 lastscan = mm->mmhead;
779 scan = mm->mmhead->next;
780 endscan = mm->mmrover;
784 lastscan = mm->mmhead;
785 scan = mm->mmhead->next;
790 startseg = lastscan->start + lastscan->length;
792 while(scan != endscan)
794 if(scan->start - startseg >= needed)
797 // got enough space between the end of lastscan and
798 // the start of scan, so throw out anything in the middle
799 // and allocate the new block
801 purge = lastscan->next;
802 lastscan->next = mm->mmnew;
803 mm->mmnew->start = *(unsigned *)baseptr = startseg;
804 mm->mmnew->next = scan;
806 { // free the purgable block
808 MM_FreeBlock(purge, mm);
809 purge = next; // purge another if not at scan
811 mm->mmrover = mm->mmnew;
812 return; // good allocation!
816 // if this block is purge level zero or locked, skip past it
818 if((scan->attributes & LOCKBIT)
819 || !(scan->attributes & PURGEBITS) )
822 startseg = lastscan->start + lastscan->length;
826 scan=scan->next; // look at next line
831 printf(OUT_OF_MEM_MSG,(size-mmi->nearheap));
836 //==========================================================================
843 = Allocates an unlocked, unpurgable block
848 void MM_FreePtr(memptr *baseptr, mminfo_t *mm)
850 mmblocktype huge *scan,huge *last;
855 if(baseptr == mm->mmrover->useptr) // removed the last allocated block
856 mm->mmrover = mm->mmhead;
858 while(scan->useptr != baseptr && scan)
866 printf("MM_FreePtr: Block not found!\n");
870 last->next = scan->next;
872 MM_FreeBlock(scan, mm);
874 //==========================================================================
877 =====================
881 = Sets the purge level for a block (locked blocks cannot be made purgable)
883 =====================
886 void MM_SetPurge(memptr *baseptr, int purge, mminfo_t *mm)
888 mmblocktype huge *start;
894 if(mm->mmrover->useptr == baseptr)
897 mm->mmrover = mm->mmrover->next;
900 mm->mmrover = mm->mmhead;
901 else if(mm->mmrover == start)
903 printf("MM_SetPurge: Block not found!");
909 mm->mmrover->attributes &= ~PURGEBITS;
910 mm->mmrover->attributes |= purge;
913 //==========================================================================
916 =====================
920 = Locks / unlocks the block
922 =====================
925 void MM_SetLock(memptr *baseptr, boolean locked, mminfo_t *mm)
927 mmblocktype huge *start;
933 if(mm->mmrover->useptr == baseptr)
936 mm->mmrover = mm->mmrover->next;
939 mm->mmrover = mm->mmhead;
940 else if(mm->mmrover == start)
942 printf("MM_SetLock: Block not found!");
948 mm->mmrover->attributes &= ~LOCKBIT;
949 mm->mmrover->attributes |= locked*LOCKBIT;
952 //==========================================================================
955 =====================
959 = Throws out all purgable stuff and compresses movable blocks
961 =====================
964 void MM_SortMem(mminfo_t *mm)
966 mmblocktype huge *scan,huge *last,huge *next;
967 unsigned start,length,source,dest,oldborder;
971 // lock down a currently playing sound
973 /*++++ playing = SD_SoundPlaying ();
979 playing += STARTPCSOUNDS;
982 playing += STARTADLIBSOUNDS;
985 MM_SetLock(&(memptr)audiosegs[playing],true);
990 // oldborder = bordercolor;
991 // VW_ColorBorder (15);
998 last = NULL; // shut up compiler warning
1002 if(scan->attributes & LOCKBIT)
1005 // block is locked, so try to pile later blocks right after it
1007 start = scan->start + scan->length;
1011 if(scan->attributes & PURGEBITS)
1014 // throw out the purgable block
1017 MM_FreeBlock(scan, mm);
1025 // push the non purgable block on top of the last moved block
1027 if(scan->start != start)
1029 length = scan->length;
1030 source = scan->start;
1032 while(length > 0xf00)
1034 movedata(source,0,dest,0,0xf00*16);
1039 movedata(source,0,dest,0,length*16);
1041 scan->start = start;
1042 *(unsigned *)scan->useptr = start;
1044 start = scan->start + scan->length;
1049 scan = scan->next; // go to next block
1052 mm->mmrover = mm->mmhead;
1057 // VW_ColorBorder (oldborder);
1060 MM_SetLock(&(memptr)audiosegs[playing],false);*/
1064 //==========================================================================
1068 =====================
1072 =====================
1075 void MM_ShowMemory(page_t *page, mminfo_t *mm)
1077 mmblocktype huge *scan;
1081 byte scratch[160],str[16];
1083 //**** VW_SetDefaultColors();
1084 //**** VW_SetLineWidth(40);
1085 //++++mh temp = bufferofs;
1086 //++++mh bufferofs = 0;
1087 //**** VW_SetScreen (0,0);
1100 if(scan->attributes & PURGEBITS)
1101 color = 5; // dark purple = purgable
1103 color = 9; // medium blue = non purgable
1104 if(scan->attributes & LOCKBIT)
1105 color = 12; // red = locked
1106 if(scan->start<=end)
1109 write(debughandle,"\nMM_ShowMemory: Memory block order currupted!\n",strlen("\nMM_ShowMemory: Memory block order currupted!\n"));
1110 //modexprint(&page, chx, chy, 1, 0, 24, "\nMM_ShowMemory: Memory block order currupted!\n");
1113 end = scan->start+scan->length-1;
1114 chy = scan->start/320;
1115 chx = scan->start%320;
1116 //modexhlin(page, scan->start, (unsigned)end, chy, color);
1117 //for(chx=scan->start;chx+4>=(word)end;chx+=4)
1119 modexClearRegion(page, chx, chy, 4, 4, color);
1122 //++++ VW_Hlin(scan->start,(unsigned)end,0,color);
1124 //++++ VW_Plot(scan->start,0,15);
1125 modexClearRegion(page, chx, chy, 4, 4, 15);
1126 if(scan->next->start > end+1)
1127 //++++ VW_Hlin(end+1,scan->next->start,0,0); // black = free
1128 //for(chx=scan->next->start;chx+4>=(word)end+1;chx+=4)
1130 chx+=scan->next->start;
1131 modexClearRegion(page, chx, chy, 4, 4, 2);
1133 //modexhlin(page, end+1,scan->next->start, chy, 0);
1136 end = scan->length-1;
1137 y = scan->start/320;
1138 x = scan->start%320;
1139 VW_Hlin(x,x+end,y,color);
1141 if (scan->next && scan->next->start > end+1)
1142 VW_Hlin(x+end+1,x+(scan->next->start-scan->start),y,0); // black = free
1146 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!
1147 strcpy(scratch,"Seg:");
1148 ultoa (scan->start,str,16);
1149 strcat (scratch,str);
1150 strcat (scratch,"\tSize:");
1151 ltoa ((dword)scan->length*16,str,10);
1152 strcat (scratch,str);
1153 strcat (scratch,"\tOwner:0x");
1154 owner = (unsigned)scan->useptr;
1155 ultoa (owner,str,16);
1156 strcat (scratch,str);
1157 strcat (scratch,"\n");
1158 write(debughandle,scratch,strlen(scratch));
1159 //modexprint(page, chx, chy, 1, 0, 24, &scratch);
1161 //fprintf(stdout, "%s", scratch);
1170 //**** VW_SetLineWidth(64);
1171 //++++mh bufferofs = temp;
1175 //==========================================================================
1178 =====================
1182 =====================
1185 void MM_DumpData(mminfo_t *mm)
1187 mmblocktype far *scan,far *best;
1188 long lowest,oldlowest;
1194 free (mm->nearheap);
1195 dumpfile = fopen ("mmdump.txt","w");
1197 printf("MM_DumpData: Couldn't open MMDUMP.TXT!\n");
1210 owner = (word)scan->useptr;
1212 if (owner && owner<lowest && owner > oldlowest)
1221 if (lowest != 0xffff)
1223 if (best->attributes & PURGEBITS)
1227 if (best->attributes & LOCKBIT)
1231 fprintf (dumpfile,"0x%p (%c%c) = %u\n"
1232 ,(word)lowest,lock,purge,best->length);
1235 } while (lowest != 0xffff);
1238 printf("MMDUMP.TXT created.\n");
1241 //==========================================================================
1245 ======================
1249 = Returns the total free space without purging
1251 ======================
1254 dword MM_UnusedMemory(mminfo_t *mm)
1257 mmblocktype huge *scan;
1264 free += scan->next->start - (scan->start + scan->length);
1272 //==========================================================================
1276 ======================
1280 = Returns the total free space with purging
1282 ======================
1285 dword MM_TotalFree(mminfo_t *mm)
1288 mmblocktype huge *scan;
1295 if((scan->attributes&PURGEBITS) && !(scan->attributes&LOCKBIT))
1296 free += scan->length;
1297 free += scan->next->start - (scan->start + scan->length);
1305 //==========================================================================
1308 =====================
1312 =====================
1315 void MM_Report(page_t *page, mminfo_t *mm, mminfotype *mmi)
1317 if(MML_CheckForEMS())
1319 printf("EMM v%x.%x available\n", mm->EMSVer>>4,mm->EMSVer&0x0F);
1320 printf("totalEMSpages=%u\n", mm->totalEMSpages);
1321 printf("freeEMSpages=%u\n", mm->freeEMSpages);
1322 printf("EMSpageframe=%x\n", mm->EMSpageframe);
1324 if(MML_CheckForXMS(mm)) printf("XMSaddr=%Fp\n", *XMSaddr);
1325 printf("near=%lu\n", mmi->nearheap);
1326 printf("far=%lu\n", mmi->farheap);
1327 printf("EMSmem=%lu\n", mmi->EMSmem);
1328 printf("XMSmem=%lu\n", mmi->XMSmem);
1329 printf("mainmem=%lu\n", mmi->mainmem);
1330 printf("UnusedMemory=%lu\n", MM_UnusedMemory(mm));
1331 printf("TotalFree=%lu\n", MM_TotalFree(mm));
1333 // printf("UnusedMemory=%lu kb\n", MM_UnusedMemory()/10248);
1334 // printf("TotalFree=%lu kb\n", MM_TotalFree()/10248);
1337 //==========================================================================
1340 =====================
1344 =====================
1359 //==========================================================================
1362 =====================
1366 =====================
1369 void MM_BombOnError(boolean bomb, mminfo_t *mm)
1371 mm->bombonerror = bomb;
1374 void MM_GetNewBlock(mminfo_t *mm)
1378 mm->mmnew=mm->mmfree;
1379 mm->mmfree=mm->mmfree->next;
1380 /*if(!(mm->mmnew=mm->mmfree))
1382 printf("MM_GETNEWBLOCK: No free blocks!");
1385 mm->mmfree=mm->mmfree->next;*/
1388 void MM_FreeBlock(mmblocktype *x, mminfo_t *mm)
1395 void MM_seguin(void)
1406 void MM_segude(void)
1415 pull data from far and put it into ds var