]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_mm.c
new files ^^
[16.git] / src / lib / 16_mm.c
index f63c126a1158d6926ecddb3b03b38bc38a0ad781..524d7ae53892768a0012249766823faea0c689c2 100644 (file)
@@ -325,6 +325,10 @@ SUB EMS.MapXPages (PhysicalStart, LogicalStart, NumPages, Handle)
 \r
 END SUB
 */
+void MM_MapXEMS(mminfo_t *mm)
+{
+
+}
 
 //==========================================================================
 
@@ -662,15 +666,16 @@ void MM_Startup(mminfo_t *mm, mminfotype *mmi)
        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!
        if(MML_CheckForEMS())
        {
-//printf("EMS1\n");
+printf("EMS1\n");
                MML_SetupEMS(mm);                                       // allocate space
+printf("EMS2\n");
                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!
                //TODO: EMS4! AND EMS 3.2 MASSIVE DATA HANDLMENT!
-               MML_UseSpace(mm->EMSpageframe,(mm->EMSpagesmapped)*0x4000lu, mm);
-//printf("EMS3\n");
+               MML_UseSpace(mm->EMSpageframe,(MAPPAGES)*0x4000lu, mm);
+printf("EMS3\n");
                MM_MapEMS(mm);                                  // map in used pages
-//printf("EMS4\n");
-               mmi->EMSmem = (mm->EMSpagesmapped)*0x4000lu;
+printf("EMS4\n");
+               mmi->EMSmem = (MAPPAGES)*0x4000lu;
        }
 
 //
@@ -1065,11 +1070,12 @@ void MM_SortMem(mminfo_t *mm)
 =====================
 */
 
-void MM_ShowMemory(mminfo_t *mm)
+void MM_ShowMemory(page_t *page, mminfo_t *mm)
 {
        mmblocktype huge *scan;
        unsigned color,temp;
        long    end,owner;
+       word chx,chy;
        char    scratch[160],str[16];
 
 //**** VW_SetDefaultColors();
@@ -1082,7 +1088,10 @@ void MM_ShowMemory(mminfo_t *mm)
 
        end = -1;
 
-//CA_OpenDebug ();
+CA_OpenDebug ();
+
+       chx=0;
+       chy=0;
 
        while(scan)
        {
@@ -1094,18 +1103,26 @@ void MM_ShowMemory(mminfo_t *mm)
                        color = 12;             // red = locked
                if(scan->start<=end)
                {
-                       printf("\nMM_ShowMemory: Memory block order currupted!\n");
+                       //printf(");
+                       write (debughandle,"\nMM_ShowMemory: Memory block order currupted!\n",strlen("\nMM_ShowMemory: Memory block order currupted!\n"));
+                       //modexprint(&page, chx, chy, 1, 0, 24, "\nMM_ShowMemory: Memory block order currupted!\n");
                        return;
                }
                end = scan->start+scan->length-1;
+                               modexhlin(page, scan->start, (unsigned)end, chy, color);
 //++++         VW_Hlin(scan->start,(unsigned)end,0,color);
+//void VW_Plot(unsigned x, unsigned y, unsigned color);
+//void VW_Hlin(unsigned xl, unsigned xh, unsigned y, unsigned color);
+
 //++++         VW_Plot(scan->start,0,15);
+                               modexputPixel(page, scan->start, chy, 15);
                if(scan->next->start > end+1)
 //++++                 VW_Hlin(end+1,scan->next->start,0,0);   // black = free
+                                       modexhlin(page, end+1,scan->next->start, chy, color);
 
 //****#if 0
 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!
-strcpy(scratch,"Location:");
+strcpy(scratch,"Seg:");
 ultoa (scan->start,str,16);
 strcat (scratch,str);
 strcat (scratch,"\tSize:");
@@ -1116,14 +1133,16 @@ owner = (unsigned)scan->useptr;
 ultoa (owner,str,16);
 strcat (scratch,str);
 strcat (scratch,"\n");
-//++++write (debughandle,scratch,strlen(scratch));
-fprintf(stdout, "%s", scratch);
+write(debughandle,scratch,strlen(scratch));
+//modexprint(page, chx, chy, 1, 0, 24, &scratch);
+//chy+=4;
+//fprintf(stdout, "%s", scratch);
 //****#endif
 
                scan = scan->next;
        }
 
-//CA_CloseDebug ();
+CA_CloseDebug ();
 
 //++++mh       IN_Ack();
 //**** VW_SetLineWidth(64);
@@ -1131,6 +1150,72 @@ fprintf(stdout, "%s", scratch);
 }
 //****#endif
 
+//==========================================================================\r
+\r
+/*\r
+=====================\r
+=\r
+= MM_DumpData\r
+=\r
+=====================\r
+*/\r
+\r
+void MM_DumpData(mminfo_t *mm)\r
+{\r
+       mmblocktype far *scan,far *best;\r
+       long    lowest,oldlowest;\r
+       unsigned        owner;\r
+       char    lock,purge;\r
+       FILE    *dumpfile;\r
+\r
+\r
+       free (mm->nearheap);\r
+       dumpfile = fopen ("mmdump.txt","w");\r
+       if (!dumpfile){\r
+               printf("MM_DumpData: Couldn't open MMDUMP.TXT!");
+               return;
+       }\r
+\r
+       lowest = -1;\r
+       do\r
+       {\r
+               oldlowest = lowest;\r
+               lowest = 0xffff;\r
+\r
+               scan = mm->mmhead;\r
+               while (scan)\r
+               {\r
+                       owner = (unsigned)scan->useptr;\r
+\r
+                       if (owner && owner<lowest && owner > oldlowest)\r
+                       {\r
+                               best = scan;\r
+                               lowest = owner;\r
+                       }\r
+\r
+                       scan = scan->next;\r
+               }\r
+\r
+               if (lowest != 0xffff)\r
+               {\r
+                       if (best->attributes & PURGEBITS)\r
+                               purge = 'P';\r
+                       else\r
+                               purge = '-';\r
+                       if (best->attributes & LOCKBIT)\r
+                               lock = 'L';\r
+                       else\r
+                               lock = '-';\r
+                       fprintf (dumpfile,"0x%p (%c%c) = %u\n"\r
+                       ,(unsigned)lowest,lock,purge,best->length);\r
+               }\r
+\r
+       } while (lowest != 0xffff);\r
+\r
+       fclose (dumpfile);\r
+       printf("MMDUMP.TXT created.");\r
+}
+
 //==========================================================================
 
 
@@ -1205,11 +1290,11 @@ dword MM_TotalFree(mminfo_t *mm)
 =====================
 */
 
-void MM_Report(mminfo_t *mm, mminfotype *mmi)
+void MM_Report(page_t *page, mminfo_t *mm, mminfotype *mmi)
 {
        if(MML_CheckForEMS())
        {
-               printf("EMM %x available\n", mm->EMSVer);
+               printf("EMM v%x.%x available\n", mm->EMSVer>>4,mm->EMSVer&0x0F);
                printf("totalEMSpages=%u\n", mm->totalEMSpages);
                printf("freeEMSpages=%u\n", mm->freeEMSpages);
                printf("EMSpageframe=%x\n", mm->EMSpageframe);