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;
144 unsigned int EMSVer = 0;
146 unsigned totalEMSpages,freeEMSpages,EMSpageframe,EMSpagesmapped,EMShandle;
147 totalEMSpages = freeEMSpages = EMSpageframe = EMSpagesmapped = 0;
152 int EMS_INT // make sure EMS hardware is present
154 //mov [EMS_status],ah
161 mov [EMSVer],ax // set EMSVer
162 cmp al,0x32 // only work on ems 3.2 or greater
166 int EMS_INT // find the page frame address
169 mov [EMSpageframe],bx
172 int EMS_INT // find out how much EMS is there
175 mov [totalEMSpages],dx
176 mov [freeEMSpages],bx
178 jz noEMS // no EMS at all to allocate
182 cmp bx,[freeEMSpages]
184 mov bx,[freeEMSpages]
189 jle getpages // there is only 1,2,3,or 4 pages
190 mov bx,4 // we can't use more than 4 pages
193 mov [EMSpagesmapped],bx
194 mov ah,EMS_ALLOCPAGES // allocate up to 64k of EMS
209 //err = CPURegs.h.ah;
210 strcpy(str,"MML_SetupEMS: EMS error 0x");
213 //printf("%s\n",str);
214 printf("%s%x\n",str,err);
217 mm->totalEMSpages=totalEMSpages;
218 mm->freeEMSpages=freeEMSpages;
219 mm->EMSpageframe=EMSpageframe;
220 mm->EMSpagesmapped=EMSpagesmapped;
221 mm->EMShandle=EMShandle;
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!\n"); //++++ 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 byte MM_MapEMS(mminfo_t *mm, mminfotype *mmi)
272 boolean errorflag=false;
274 EMShandle=mm->EMShandle;
276 for (i=0;i<4/*MAPPAGES*/;i++)
281 mov bx,[i] // logical page
282 mov al,bl // physical page
283 mov dx,[EMShandle] // handle
295 //err = CPURegs.h.ah;
296 strcpy(str,"MM_MapEMS: EMS error 0x");
299 //printf("%s\n",str);
300 printf("%s%x\n",str, err);
301 //printf("FACK! %x\n", err);
305 mmi->EMSmem = (i)*0x4000lu;
309 byte MM_MapXEMS(mminfo_t *mm, mminfotype *mmi)
312 //SUB EMS.MapXPages (PhysicalStart, LogicalStart, NumPages, Handle)
\r
314 //Maps up to 4 logical EMS pages to physical pages in the page frame, where:
\r
315 //PhysicalStart = Physical page first logical page is mapped to
\r
316 //LogicalStart = First logical page to map
\r
317 //NumPages = Number of pages to map (1 to 4)
\r
318 //Handle = EMS handle logical pages are allocated to
\r
320 /*//Create a buffer containing the page information
\r
321 // FOR x = 0 TO NumPages - 1
\r
322 // MapInfo$ = MapInfo$ + MKI$(LogicalStart + x) + MKI$(PhysicalStart + x)
\r
325 // Regs.ax = &H5000 //Map the pages in the buffer
\r
326 // Regs.cx = NumPages //to the pageframe
\r
327 // Regs.dx = Handle
\r
328 // Regs.ds = VARSEG(MapInfo$)
\r
329 // Regs.si = SADD(MapInfo$)
\r
330 // InterruptX &H67, Regs, Regs
\r
331 // EMS.Error = (Regs.ax AND &HFF00&) \ &H100 //Store the status code
\r
337 boolean errorflag=false;
339 EMShandle=mm->EMShandle;
344 for (i=0;i<MAPPAGES;i++)
349 mov cx,[i] // logical page
350 mov al,bl // physical page
351 mov dx,[EMShandle] // handle
363 //err = CPURegs.h.ah;
364 strcpy(str,"MM_MapXEMS: EMS error 0x");
367 //printf("%s\n",str);
368 printf("%s%x\n",str, err);
369 //printf("FACK! %x\n", err);
373 mmi->EMSmem = (i)*0x4000lu;
377 //==========================================================================
380 ======================
384 = Check for XMM driver
386 =======================
389 boolean MML_CheckForXMS(mminfo_t *mm)
391 boolean errorflag=false;
397 int 0x2f // query status of installed diver
403 if(errorflag==true) return false;
409 ======================
413 = Try to allocate all upper memory block
415 =======================
418 void MML_SetupXMS(mminfo_t *mm, mminfotype *mmi)
427 mov [WORD PTR XMSaddr],bx
428 mov [WORD PTR XMSaddr+2],es // function pointer to XMS driver
431 mov dx,0xffff // try for largest block possible
432 //mov ax,dx // Set available Kbytes.
433 call [DWORD PTR XMSaddr]
437 cmp bl,0xb0 // error: smaller UMB is available
441 call [DWORD PTR XMSaddr] // DX holds largest available UMB
443 jz done // another error...
450 printf("base=%u ", base); printf("size=%u\n", size);
451 MML_UseSpace(base,size, mm);
452 mmi->XMSmem += size*16;
453 mm->UMBbase[mm->numUMBs] = base;
455 if(mm->numUMBs < MAXUMBS)
461 ======================
465 ======================
468 void MML_ShutdownXMS(mminfo_t *mm)
473 for (i=0;i<mm->numUMBs;i++)
475 base = mm->UMBbase[i];
480 call [DWORD PTR XMSaddr]
485 //==========================================================================
488 ======================
492 = Marks a range of paragraphs as usable by the memory manager
493 = This is used to mark space for the near heap, far heap, ems page frame,
494 = and upper memory blocks
496 ======================
499 void MML_UseSpace(/*d*/word segstart, dword seglength, mminfo_t *mm)
501 mmblocktype huge *scan,huge *last;
506 scan = last = mm->mmhead;
507 mm->mmrover = mm->mmhead; // reset rover to start of memory
510 // search for the block that contains the range of segments
512 while(scan->start+scan->length < segstart)
518 //find out how many blocks it spans!
519 if(seglength>0xffffu)
521 // segm=seglength/0x4000u;
522 segm=seglength/0xffffu;
527 if(segm>1/*extra>0xfffflu*/)
538 //MML_UseSpace(?segstart?, ?length?, mm);
544 //printf("MML_UseSpace: Segment spans two blocks!\n");
548 // take the given range out of the block
550 oldend = scan->start + scan->length;
551 extra = oldend - (segstart+seglength);
553 printf("segm=%u ", segm);
554 printf("ex=%lu ", extra);
555 printf("start+seglen=%lu ", segstart+seglength);
556 printf("len=%u ", scan->length);
557 printf("segsta=%x ", segstart);
558 printf("seglen=%lu\n", seglength);
561 //++++todo: linked list of segment!
562 //printf("segm=%lu\n", segm);
563 if(segstart == scan->start)
565 last->next = scan->next; // unlink block
566 MM_FreeBlock(scan, mm);
570 scan->length = segstart-scan->start; // shorten block
577 mm->mmnew->next = scan->next;
578 scan->next = mm->mmnew;
579 mm->mmnew->start = segstart+seglength;
580 mm->mmnew->length = extra;
581 mm->mmnew->attributes = LOCKBIT;
582 }//else if(segm>0) goto segu;
586 //==========================================================================
593 = We are out of blocks, so free a purgable block
598 void MML_ClearBlock(mminfo_t *mm)
600 mmblocktype huge *scan,huge *last;
602 scan = mm->mmhead->next;
606 if(!(scan->attributes&LOCKBIT) && (scan->attributes&PURGEBITS))
608 MM_FreePtr(scan->useptr, mm);
614 printf("MM_ClearBlock: No purgable blocks!\n");
618 //==========================================================================
625 = Grabs all space from turbo with malloc/farmalloc
626 = Allocates bufferseg misc buffer
631 void MM_Startup(mminfo_t *mm, mminfotype *mmi)
636 unsigned segstart,seglength,endfree;
641 mm->mmstarted = true;
642 mm->bombonerror = true;
644 // set up the linked list (everything in the free list;
647 mm->mmfree = &(mm->mmblocks[0]);
648 for(i=0;i<MAXBLOCKS-1;i++)
650 mm->mmblocks[i].next = &(mm->mmblocks[i+1]);
652 mm->mmblocks[i].next = NULL;
655 // locked block of all memory until we punch out free space
658 mm->mmhead = mm->mmnew; // this will allways be the first node
659 mm->mmnew->start = 0;
660 mm->mmnew->length = 0xffff;
661 mm->mmnew->attributes = LOCKBIT;
662 mm->mmnew->next = NULL;
663 mm->mmrover = mm->mmhead;
665 // farlen=_bios_memsize()*1024;
668 // get all available near conventional memory segments
670 //---- length=coreleft();
673 start = (void huge *)(mm->nearheap = malloc(length));
674 length -= 16-(FP_OFF(start)&15);
675 length -= SAVENEARHEAP;
676 seglength = length / 16; // now in paragraphs
677 segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
678 MML_UseSpace(segstart,seglength, mm);
679 mmi->nearheap = length;
680 //printf("near heap ok!\n");
683 // get all available far conventional memory segments
685 //---- length=farcoreleft();
688 start = mm->farheap = halloc(length, sizeof(byte));
689 //start = mm->farheap = _fmalloc(length);
690 length -= 16-(FP_OFF(start)&15);
691 length -= SAVEFARHEAP;
692 seglength = length / 16; // now in paragraphs
693 segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
694 MML_UseSpace(segstart,seglength, mm);
695 mmi->farheap = length;
696 mmi->mainmem = mmi->nearheap + mmi->farheap;
697 //printf("far heap ok!\n");
701 // detect EMS and allocate up to 64K at page frame
703 printf("EMS1\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!
705 for(i = 1;i < __argc;i++)
707 if(US_CheckParm(__argv[i],ParmStringsexmm) == 0)
708 goto emsskip; // param NOEMS
710 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!
711 if(MML_CheckForEMS())
714 MML_SetupEMS(mm); // allocate space
716 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!
717 //TODO: EMS4! AND EMS 3.2 MASSIVE DATA HANDLMENT!
718 MML_UseSpace(mm->EMSpageframe,(MAPPAGES)*0x4000lu, mm);
721 MM_MapEMS(mm, mmi); // map in used pages
723 MM_MapXEMS(mm, mmi); // map in used pages
727 // detect XMS and get upper memory blocks
731 for(i = 1;i < __argc;i++)
733 if(US_CheckParm(__argv[i],ParmStringsexmm) == 0)
734 goto xmsskip; // param NOXMS
736 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!
737 if(MML_CheckForXMS(mm))
740 //MML_SetupXMS(mm, mmi); // allocate as many UMBs as possible
744 // allocate the misc buffer
747 mm->mmrover = mm->mmhead; // start looking for space after low block
749 MM_GetPtr(&(mm->bufferseg),BUFFERSIZE, mm, mmi);
752 //==========================================================================
759 = Frees all conventional, EMS, and XMS allocated
764 void MM_Shutdown(mminfo_t *mm)
770 printf("far freed\n");
772 printf("near freed\n");
773 //hfree(mm->hugeheap);
774 //printf("huge freed\n");
775 if(MML_CheckForEMS()){ MML_ShutdownEMS(mm); printf("EMS freed\n"); }
776 if(MML_CheckForXMS(mm)){ MML_ShutdownXMS(mm); printf("XMS freed\n"); }
779 //==========================================================================
786 = Allocates an unlocked, unpurgable block
791 void MM_GetPtr(memptr *baseptr,dword size, mminfo_t *mm, mminfotype *mmi)
793 mmblocktype huge *scan,huge *lastscan,huge *endscan,huge *purge,huge *next;
795 unsigned needed,startseg;
797 needed = (size+15)/16; // convert size from bytes to paragraphs
799 MM_GetNewBlock(mm); // fill in start and next after a spot is found
800 mm->mmnew->length = needed;
801 mm->mmnew->useptr = baseptr;
802 mm->mmnew->attributes = BASEATTRIBUTES;
804 for(search = 0; search<3; search++)
807 // first search: try to allocate right after the rover, then on up
808 // second search: search from the head pointer up to the rover
809 // third search: compress memory, then scan from start
810 if(search == 1 && mm->mmrover == mm->mmhead)
816 lastscan = mm->mmrover;
817 scan = mm->mmrover->next;
821 lastscan = mm->mmhead;
822 scan = mm->mmhead->next;
823 endscan = mm->mmrover;
827 lastscan = mm->mmhead;
828 scan = mm->mmhead->next;
833 startseg = lastscan->start + lastscan->length;
835 while(scan != endscan)
837 if(scan->start - startseg >= needed)
840 // got enough space between the end of lastscan and
841 // the start of scan, so throw out anything in the middle
842 // and allocate the new block
844 purge = lastscan->next;
845 lastscan->next = mm->mmnew;
846 mm->mmnew->start = *(unsigned *)baseptr = startseg;
847 mm->mmnew->next = scan;
849 { // free the purgable block
851 MM_FreeBlock(purge, mm);
852 purge = next; // purge another if not at scan
854 mm->mmrover = mm->mmnew;
855 return; // good allocation!
859 // if this block is purge level zero or locked, skip past it
861 if((scan->attributes & LOCKBIT)
862 || !(scan->attributes & PURGEBITS) )
865 startseg = lastscan->start + lastscan->length;
869 scan=scan->next; // look at next line
874 printf(OUT_OF_MEM_MSG,(size-mmi->nearheap));
879 //==========================================================================
886 = Allocates an unlocked, unpurgable block
891 void MM_FreePtr(memptr *baseptr, mminfo_t *mm)
893 mmblocktype huge *scan,huge *last;
898 if(baseptr == mm->mmrover->useptr) // removed the last allocated block
899 mm->mmrover = mm->mmhead;
901 while(scan->useptr != baseptr && scan)
909 printf("MM_FreePtr: Block not found!\n");
913 last->next = scan->next;
915 MM_FreeBlock(scan, mm);
917 //==========================================================================
920 =====================
924 = Sets the purge level for a block (locked blocks cannot be made purgable)
926 =====================
929 void MM_SetPurge(memptr *baseptr, int purge, mminfo_t *mm)
931 mmblocktype huge *start;
937 if(mm->mmrover->useptr == baseptr)
940 mm->mmrover = mm->mmrover->next;
943 mm->mmrover = mm->mmhead;
944 else if(mm->mmrover == start)
946 printf("MM_SetPurge: Block not found!");
952 mm->mmrover->attributes &= ~PURGEBITS;
953 mm->mmrover->attributes |= purge;
956 //==========================================================================
959 =====================
963 = Locks / unlocks the block
965 =====================
968 void MM_SetLock(memptr *baseptr, boolean locked, mminfo_t *mm)
970 mmblocktype huge *start;
976 if(mm->mmrover->useptr == baseptr)
979 mm->mmrover = mm->mmrover->next;
982 mm->mmrover = mm->mmhead;
983 else if(mm->mmrover == start)
985 printf("MM_SetLock: Block not found!");
991 mm->mmrover->attributes &= ~LOCKBIT;
992 mm->mmrover->attributes |= locked*LOCKBIT;
995 //==========================================================================
998 =====================
1002 = Throws out all purgable stuff and compresses movable blocks
1004 =====================
1007 void MM_SortMem(mminfo_t *mm)
1009 mmblocktype huge *scan,huge *last,huge *next;
1010 unsigned start,length,source,dest,oldborder;
1014 // lock down a currently playing sound
1016 /*++++ playing = SD_SoundPlaying ();
1022 playing += STARTPCSOUNDS;
1025 playing += STARTADLIBSOUNDS;
1028 MM_SetLock(&(memptr)audiosegs[playing],true);
1033 // oldborder = bordercolor;
1034 // VW_ColorBorder (15);
1041 last = NULL; // shut up compiler warning
1045 if(scan->attributes & LOCKBIT)
1048 // block is locked, so try to pile later blocks right after it
1050 start = scan->start + scan->length;
1054 if(scan->attributes & PURGEBITS)
1057 // throw out the purgable block
1060 MM_FreeBlock(scan, mm);
1068 // push the non purgable block on top of the last moved block
1070 if(scan->start != start)
1072 length = scan->length;
1073 source = scan->start;
1075 while(length > 0xf00)
1077 movedata(source,0,dest,0,0xf00*16);
1082 movedata(source,0,dest,0,length*16);
1084 scan->start = start;
1085 *(unsigned *)scan->useptr = start;
1087 start = scan->start + scan->length;
1092 scan = scan->next; // go to next block
1095 mm->mmrover = mm->mmhead;
1100 // VW_ColorBorder (oldborder);
1103 MM_SetLock(&(memptr)audiosegs[playing],false);*/
1107 //==========================================================================
1111 =====================
1115 =====================
1118 void MM_ShowMemory(page_t *page, mminfo_t *mm)
1120 mmblocktype huge *scan;
1124 byte scratch[160],str[16];
1126 //**** VW_SetDefaultColors();
1127 //**** VW_SetLineWidth(40);
1128 //++++mh temp = bufferofs;
1129 //++++mh bufferofs = 0;
1130 //**** VW_SetScreen (0,0);
1143 if(scan->attributes & PURGEBITS)
1144 color = 5; // dark purple = purgable
1146 color = 9; // medium blue = non purgable
1147 if(scan->attributes & LOCKBIT)
1148 color = 12; // red = locked
1149 if(scan->start<=end)
1152 write(debughandle,"\nMM_ShowMemory: Memory block order currupted!\n",strlen("\nMM_ShowMemory: Memory block order currupted!\n"));
1153 //modexprint(&page, chx, chy, 1, 0, 24, "\nMM_ShowMemory: Memory block order currupted!\n");
1156 end = scan->start+scan->length-1;
1157 chy = scan->start/320;
1158 chx = scan->start%320;
1159 //modexhlin(page, scan->start, (unsigned)end, chy, color);
1160 //for(chx=scan->start;chx+4>=(word)end;chx+=4)
1162 modexClearRegion(page, chx, chy, 4, 4, color);
1165 //++++ VW_Hlin(scan->start,(unsigned)end,0,color);
1167 //++++ VW_Plot(scan->start,0,15);
1168 modexClearRegion(page, chx, chy, 4, 4, 15);
1169 if(scan->next->start > end+1)
1170 //++++ VW_Hlin(end+1,scan->next->start,0,0); // black = free
1171 //for(chx=scan->next->start;chx+4>=(word)end+1;chx+=4)
1173 chx+=scan->next->start;
1174 modexClearRegion(page, chx, chy, 4, 4, 2);
1176 //modexhlin(page, end+1,scan->next->start, chy, 0);
1179 end = scan->length-1;
1180 y = scan->start/320;
1181 x = scan->start%320;
1182 VW_Hlin(x,x+end,y,color);
1184 if (scan->next && scan->next->start > end+1)
1185 VW_Hlin(x+end+1,x+(scan->next->start-scan->start),y,0); // black = free
1189 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!
1190 strcpy(scratch,"Seg:");
1191 ultoa (scan->start,str,16);
1192 strcat (scratch,str);
1193 strcat (scratch,"\tSize:");
1194 ltoa ((dword)scan->length*16,str,10);
1195 strcat (scratch,str);
1196 strcat (scratch,"\tOwner:0x");
1197 owner = (unsigned)scan->useptr;
1198 ultoa (owner,str,16);
1199 strcat (scratch,str);
1200 strcat (scratch,"\n");
1201 write(debughandle,scratch,strlen(scratch));
1202 //modexprint(page, chx, chy, 1, 0, 24, &scratch);
1204 //fprintf(stdout, "%s", scratch);
1213 //**** VW_SetLineWidth(64);
1214 //++++mh bufferofs = temp;
1218 //==========================================================================
1221 =====================
1225 =====================
1228 void MM_DumpData(mminfo_t *mm)
1230 mmblocktype far *scan,far *best;
1231 long lowest,oldlowest;
1237 free (mm->nearheap);
1238 dumpfile = fopen ("mmdump.txt","w");
1240 printf("MM_DumpData: Couldn't open MMDUMP.TXT!\n");
1253 owner = (word)scan->useptr;
1255 if (owner && owner<lowest && owner > oldlowest)
1264 if (lowest != 0xffff)
1266 if (best->attributes & PURGEBITS)
1270 if (best->attributes & LOCKBIT)
1274 fprintf (dumpfile,"0x%p (%c%c) = %u\n"
1275 ,(word)lowest,lock,purge,best->length);
1278 } while (lowest != 0xffff);
1281 printf("MMDUMP.TXT created.\n");
1284 //==========================================================================
1288 ======================
1292 = Returns the total free space without purging
1294 ======================
1297 dword MM_UnusedMemory(mminfo_t *mm)
1300 mmblocktype huge *scan;
1307 free += scan->next->start - (scan->start + scan->length);
1315 //==========================================================================
1319 ======================
1323 = Returns the total free space with purging
1325 ======================
1328 dword MM_TotalFree(mminfo_t *mm)
1331 mmblocktype huge *scan;
1338 if((scan->attributes&PURGEBITS) && !(scan->attributes&LOCKBIT))
1339 free += scan->length;
1340 free += scan->next->start - (scan->start + scan->length);
1348 //==========================================================================
1351 =====================
1355 =====================
1358 void MM_Report(page_t *page, mminfo_t *mm, mminfotype *mmi)
1360 if(MML_CheckForEMS())
1362 printf("EMM v%x.%x available\n", mm->EMSVer>>4,mm->EMSVer&0x0F);
1363 printf("totalEMSpages=%u\n", mm->totalEMSpages);
1364 printf("freeEMSpages=%u\n", mm->freeEMSpages);
1365 printf("EMSpageframe=%x\n", mm->EMSpageframe);
1367 if(MML_CheckForXMS(mm)) printf("XMSaddr=%Fp\n", *XMSaddr);
1368 printf("near=%lu\n", mmi->nearheap);
1369 printf("far=%lu\n", mmi->farheap);
1370 printf("EMSmem=%lu\n", mmi->EMSmem);
1371 printf("XMSmem=%lu\n", mmi->XMSmem);
1372 printf("mainmem=%lu\n", mmi->mainmem);
1373 printf("UnusedMemory=%lu\n", MM_UnusedMemory(mm));
1374 printf("TotalFree=%lu\n", MM_TotalFree(mm));
1376 // printf("UnusedMemory=%lu kb\n", MM_UnusedMemory()/10248);
1377 // printf("TotalFree=%lu kb\n", MM_TotalFree()/10248);
1380 //==========================================================================
1383 =====================
1387 =====================
1402 //==========================================================================
1405 =====================
1409 =====================
1412 void MM_BombOnError(boolean bomb, mminfo_t *mm)
1414 mm->bombonerror = bomb;
1417 void MM_GetNewBlock(mminfo_t *mm)
1421 mm->mmnew=mm->mmfree;
1422 mm->mmfree=mm->mmfree->next;
1423 /*if(!(mm->mmnew=mm->mmfree))
1425 printf("MM_GETNEWBLOCK: No free blocks!");
1428 mm->mmfree=mm->mmfree->next;*/
1431 void MM_FreeBlock(mmblocktype *x, mminfo_t *mm)
1438 void MM_seguin(void)
1449 void MM_segude(void)
1458 pull data from far and put it into ds var