=======================
*/
-unsigned MML_SetupEMS(mminfo_t *mm)
+byte MML_SetupEMS(mminfo_t *mm)
{
- char str[80],str2[10];
- unsigned err;
+ char str[80];//,str2[10];
+ byte err;
boolean errorflag=false;
union REGS CPURegs;
unsigned int EMSVer = 0;
+ //byte EMS_status;
unsigned totalEMSpages,freeEMSpages,EMSpageframe,EMSpagesmapped,EMShandle;
totalEMSpages = freeEMSpages = EMSpageframe = EMSpagesmapped = 0;
mov ah,EMS_STATUS
int EMS_INT // make sure EMS hardware is present
or ah,ah
+ //mov [EMS_status],ah
jnz error
mov ah,EMS_VERSION
mov [EMShandle],dx
jmp End
error:
+ mov err,ah
mov errorflag,1
jmp End
noEMS:
}
if(errorflag==true)
{
- err = CPURegs.h.ah;
+ //err = CPURegs.h.ah;
strcpy(str,"MML_SetupEMS: EMS error 0x");
- itoa(err,str2,16);
- strcpy(str,str2);
- printf("%s\n",str);
+ //itoa(err,str2,16);
+ //strcat(str,&err);
+ //printf("%s\n",str);
+ printf("%s%x\n",str,err);
return err;
}
mm->totalEMSpages=totalEMSpages;
====================
*/
-unsigned MM_MapEMS(mminfo_t *mm)
+byte MM_MapEMS(mminfo_t *mm)
{
- char str[80],str2[10];
- unsigned err, EMShandle;
+ char str[80];//,str2[10];
+ unsigned /*err, */EMShandle;
+ byte err;
boolean errorflag=false;
int i;
union REGS CPURegs;
EMShandle=mm->EMShandle;
- for (i=0;i<4/*mm->EMSpagesmapped*/;i++)
+ for (i=0;i<MAPPAGES;i++)
{
__asm
{
jnz error
jmp End
error:
+ mov err,ah
mov errorflag,1
End:
}
if(errorflag==true)
{
- err = CPURegs.h.ah;
+ //err = CPURegs.h.ah;
strcpy(str,"MM_MapEMS: EMS error 0x");
- itoa(err,str2,16);
- strcpy(str,str2);
+ //itoa(err,str2,16);
+ //strcat(str,&err);
//printf("%s\n",str);
- printf("FACK! %u\n", err);
+ printf("%s%x\n",str, err);
+ //printf("FACK! %x\n", err);
return err;
}
}
return 0;
}
-/*
-SUB EMS.MapXPages (PhysicalStart, LogicalStart, NumPages, Handle)\r
+byte MM_MapXEMS(mminfo_t *mm)
+{
+
+//SUB EMS.MapXPages (PhysicalStart, LogicalStart, NumPages, Handle)\r
\r
- 'Maps up to 4 logical EMS pages to physical pages in the page frame, where:\r
- '\r
- 'PhysicalStart = Physical page first logical page is mapped to\r
- 'LogicalStart = First logical page to map\r
- 'NumPages = Number of pages to map (1 to 4)\r
- 'Handle = EMS handle logical pages are allocated to\r
+ //Maps up to 4 logical EMS pages to physical pages in the page frame, where:\r
+ //PhysicalStart = Physical page first logical page is mapped to\r
+ //LogicalStart = First logical page to map\r
+ //NumPages = Number of pages to map (1 to 4)\r
+ //Handle = EMS handle logical pages are allocated to\r
\r
- 'Create a buffer containing the page information\r
- FOR x = 0 TO NumPages - 1\r
- MapInfo$ = MapInfo$ + MKI$(LogicalStart + x) + MKI$(PhysicalStart + x)\r
- NEXT\r
+ /*//Create a buffer containing the page information\r
+// FOR x = 0 TO NumPages - 1\r
+// MapInfo$ = MapInfo$ + MKI$(LogicalStart + x) + MKI$(PhysicalStart + x)\r
+// NEXT*/\r
\r
- Regs.ax = &H5000 'Map the pages in the buffer\r
- Regs.cx = NumPages 'to the pageframe\r
- Regs.dx = Handle\r
- Regs.ds = VARSEG(MapInfo$)\r
- Regs.si = SADD(MapInfo$)\r
- InterruptX &H67, Regs, Regs\r
- EMS.Error = (Regs.ax AND &HFF00&) \ &H100 'Store the status code\r
+// Regs.ax = &H5000 //Map the pages in the buffer\r
+// Regs.cx = NumPages //to the pageframe\r
+// Regs.dx = Handle\r
+// Regs.ds = VARSEG(MapInfo$)\r
+// Regs.si = SADD(MapInfo$)\r
+// InterruptX &H67, Regs, Regs\r
+// EMS.Error = (Regs.ax AND &HFF00&) \ &H100 //Store the status code\r
\r
-END SUB
-*/
-void MM_MapXEMS(mminfo_t *mm)
-{
+//END SUB
+/*
+char str[80];//,str2[10];
+ unsigned EMShandle;
+ byte err;
+ boolean errorflag=false;
+ int i;
+ union REGS CPURegs;
+ EMShandle=mm->EMShandle;
+ for (i=0;i<MAPPAGES;i++)
+ {
+ __asm
+ {
+ mov ah,EMS_MAPPAGE
+ mov bx,[i] // logical page
+ mov al,bl // physical page
+ mov dx,[EMShandle] // handle
+ int EMS_INT
+ or ah,ah
+ jnz error
+ jmp End
+ error:
+ mov err,ah
+ mov errorflag,1
+ End:
+ }
+ if(errorflag==true)
+ {
+ //err = CPURegs.h.ah;
+ strcpy(str,"MM_MapEMS: EMS error 0x");
+ //itoa(err,str2,16);
+ //strcat(str,&err);
+ //printf("%s\n",str);
+ printf("%s%x\n",str, err);
+ //printf("FACK! %x\n", err);
+ return err;
+ }
+ }
+ return 0;
+*/
}
//==========================================================================
if(!scan)
{
- printf("MM_FreePtr: Block not found!");
+ printf("MM_FreePtr: Block not found!\n");
return;
}
void MM_ShowMemory(page_t *page, mminfo_t *mm)
{
mmblocktype huge *scan;
- unsigned color,temp;
+ word color,temp;
long end,owner;
word chx,chy;
- char scratch[160],str[16];
+ byte scratch[160],str[16];
//**** VW_SetDefaultColors();
//**** VW_SetLineWidth(40);
return;
}
end = scan->start+scan->length-1;
- modexhlin(page, scan->start, (unsigned)end, chy, color);
+ chy = scan->start/320;
+ chx = scan->start%320;
+ //modexhlin(page, scan->start, (unsigned)end, chy, color);
+ //for(chx=scan->start;chx+4>=(word)end;chx+=4)
+ //{
+ modexClearRegion(page, chx, chy, 4, 4, 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);
- modexClearRegion(page, scan->start, chy, 4, 4, 15);
+ modexClearRegion(page, chx, chy, 4, 4, 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, 9);
+ //for(chx=scan->next->start;chx+4>=(word)end+1;chx+=4)
+ //{
+ chx+=scan->next->start;
+ modexClearRegion(page, chx, chy, 4, 4, 2);
+ //}
+ //modexhlin(page, end+1,scan->next->start, chy, 0);
+
+/*
+ end = scan->length-1;
+ y = scan->start/320;
+ x = scan->start%320;
+ VW_Hlin(x,x+end,y,color);
+ VW_Plot(x,y,15);
+ if (scan->next && scan->next->start > end+1)
+ VW_Hlin(x+end+1,x+(scan->next->start-scan->start),y,0); // black = free
+*/
//****#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!
strcat (scratch,"\n");
write(debughandle,scratch,strlen(scratch));
//modexprint(page, chx, chy, 1, 0, 24, &scratch);
-//chy+=4;
+chy+=4;
//fprintf(stdout, "%s", scratch);
//****#endif
}
//****#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!");
+//==========================================================================
+
+/*
+=====================
+=
+= MM_DumpData
+=
+=====================
+*/
+
+void MM_DumpData(mminfo_t *mm)
+{
+ mmblocktype far *scan,far *best;
+ long lowest,oldlowest;
+ word owner;
+ byte lock,purge;
+ FILE *dumpfile;
+
+
+ free (mm->nearheap);
+ dumpfile = fopen ("mmdump.txt","w");
+ if (!dumpfile){
+ printf("MM_DumpData: Couldn't open MMDUMP.TXT!\n");
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
+ }
+
+ lowest = -1;
+ do
+ {
+ oldlowest = lowest;
+ lowest = 0xffff;
+
+ scan = mm->mmhead;
+ while (scan)
+ {
+ owner = (word)scan->useptr;
+
+ if (owner && owner<lowest && owner > oldlowest)
+ {
+ best = scan;
+ lowest = owner;
+ }
+
+ scan = scan->next;
+ }
+
+ if (lowest != 0xffff)
+ {
+ if (best->attributes & PURGEBITS)
+ purge = 'P';
+ else
+ purge = '-';
+ if (best->attributes & LOCKBIT)
+ lock = 'L';
+ else
+ lock = '-';
+ fprintf (dumpfile,"0x%p (%c%c) = %u\n"
+ ,(word)lowest,lock,purge,best->length);
+ }
+
+ } while (lowest != 0xffff);
+
+ fclose (dumpfile);
+ printf("MMDUMP.TXT created.\n");
}
//==========================================================================