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<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);
306 void MM_MapXEMS(mminfo_t *mm)
310 //SUB EMS.MapXPages(PhysicalStart, LogicalStart, NumPages, Handle)
\r
312 //Maps up to 4 logical EMS pages to physical pages in the page frame, where:
\r
314 //PhysicalStart = Physical page first logical page is mapped to
\r
315 //LogicalStart = First logical page to map
\r
316 //NumPages = Number of pages to map (1 to 4)
\r
317 //Handle = EMS handle logical pages are allocated to
\r
319 ///Create a buffer containing the page information
\r
320 /*FOR x = 0 TO NumPages - 1
\r
321 MapInfo$ = MapInfo$ + MKI$(LogicalStart + x) + MKI$(PhysicalStart + x)
\r
324 Regs.ax = &H5000 //Map the pages in the buffer
\r
325 Regs.cx = NumPages //to the pageframe
\r
327 Regs.ds = VARSEG(MapInfo$)
\r
328 Regs.si = SADD(MapInfo$)
\r
329 InterruptX &H67, Regs, Regs
\r
330 EMS.Error = (Regs.ax AND &HFF00&) \ &H100 //Store the status code*/
\r
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;
599 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!
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;
612 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!
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;
623 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!
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))
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 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!\n");
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
1147 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!
1148 strcpy(scratch,"Seg:");
1149 ultoa (scan->start,str,16);
1150 strcat (scratch,str);
1151 strcat (scratch,"\tSize:");
1152 ltoa ((dword)scan->length*16,str,10);
1153 strcat (scratch,str);
1154 strcat (scratch,"\tOwner:0x");
1155 owner = (unsigned)scan->useptr;
1156 ultoa (owner,str,16);
1157 strcat (scratch,str);
1158 strcat (scratch,"\n");
1159 write(debughandle,scratch,strlen(scratch));
1160 //modexprint(page, chx, chy, 1, 0, 24, &scratch);
1162 //fprintf(stdout, "%s", scratch);
1171 //**** VW_SetLineWidth(64);
1172 //++++mh bufferofs = temp;
1176 //==========================================================================
\r
1179 =====================
\r
1183 =====================
\r
1186 void MM_DumpData(mminfo_t *mm)
\r
1188 mmblocktype far *scan,far *best;
\r
1189 long lowest,oldlowest;
\r
1195 free (mm->nearheap);
\r
1196 dumpfile = fopen ("mmdump.txt","w");
\r
1198 printf("MM_DumpData: Couldn't open MMDUMP.TXT!");
1205 oldlowest = lowest;
\r
1208 scan = mm->mmhead;
\r
1211 owner = (word)scan->useptr;
\r
1213 if (owner && owner<lowest && owner > oldlowest)
\r
1219 scan = scan->next;
\r
1222 if (lowest != 0xffff)
\r
1224 if (best->attributes & PURGEBITS)
\r
1228 if (best->attributes & LOCKBIT)
\r
1232 fprintf (dumpfile,"0x%p (%c%c) = %u\n"
\r
1233 ,(word)lowest,lock,purge,best->length);
\r
1236 } while (lowest != 0xffff);
\r
1238 fclose (dumpfile);
\r
1239 printf("MMDUMP.TXT created.");
\r
1242 //==========================================================================
1246 ======================
1250 = Returns the total free space without purging
1252 ======================
1255 dword MM_UnusedMemory(mminfo_t *mm)
1258 mmblocktype huge *scan;
1265 free += scan->next->start - (scan->start + scan->length);
1273 //==========================================================================
1277 ======================
1281 = Returns the total free space with purging
1283 ======================
1286 dword MM_TotalFree(mminfo_t *mm)
1289 mmblocktype huge *scan;
1296 if((scan->attributes&PURGEBITS) && !(scan->attributes&LOCKBIT))
1297 free += scan->length;
1298 free += scan->next->start - (scan->start + scan->length);
1306 //==========================================================================
1309 =====================
1313 =====================
1316 void MM_Report(page_t *page, mminfo_t *mm, mminfotype *mmi)
1319 if(MML_CheckForEMS())
1321 printf("Expanded memory manager present. EMM v%x.%x available\n", mm->EMSVer>>4,mm->EMSVer&0x0F);
1322 printf("totalEMSpages=%u ", mm->totalEMSpages);
1323 printf("freeEMSpages=%u\n", mm->freeEMSpages);
1324 printf("Page frame @0x%04x\n", mm->EMSpageframe);
1325 //printf("EMSpageframe=%x\n", );
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