boolean MML_CheckForEMS(void)
{
boolean emmcfems;
- char emmname[] = "EMMXXXX0";
+ static char emmname[] = "EMMXXXX0"; //fix by andrius4669
// mov dx,OFFSET emmname
__asm {
- LEA DX, emmname //fix by andrius4669
+ //LEA DX, emmname //fix by andrius4669
+ mov dx,OFFSET emmname //fix by andrius4669
mov ax,0x3d00
int 0x21 // try to open EMMXXXX0 device
jc error
mov [freeEMSpages],bx
or bx,bx
jz noEMS // no EMS at all to allocate
-//++++EXPAND DONG!!!!
+ //EXPAND DONG!!!!
cmp [EMSVer],0x40
jb low
cmp bx,[freeEMSpages]
}
printf("base=%u ", base); printf("size=%u\n", size);
MML_UseSpace(base,size, mm);
- mmi->XMSmem += ((dword)size)*16;
- mm->UMBbase[mm->numUMBs] = (dword)base;
+ mmi->XMSmem += size*16;
+ mm->UMBbase[mm->numUMBs] = base;
mm->numUMBs++;
if(mm->numUMBs < MAXUMBS)
goto getmemory;
======================
*/
-void MML_UseSpace(unsigned segstart, dword seglength, mminfo_t *mm)
+void MML_UseSpace(/*d*/word segstart, dword seglength, mminfo_t *mm)
{
mmblocktype huge *scan,huge *last;
+ word segm;
dword oldend;
- dword fat=0;
- word segm=0;
dword extra;
scan = last = mm->mmhead;
scan = scan->next;
}
+ //find out how many blocks it spans!
+ if(seglength>0xffffu)
+ {
+ segm=seglength/0x4000u;
+// segm=seglength/0xffffu;
+ }
+ else segm=1;
+
//
// take the given range out of the block
//
- oldend = scan->start + (dword)scan->length;
- extra = oldend - (dword)(segstart+seglength);
+ oldend = scan->start + scan->length;
+ extra = oldend - (segstart+seglength);
//++++emsver stuff!
if(extra>0xfffflu)
{
- /*segm=(extra%(0xfffflu))-1;
- fat=segm*(0xfffflu);
- extra-=fat;*/
-/*printf("extra=%lu ", extra);
-printf("oldend=%lu ", oldend);
-printf("segm=%lu\n", segm);*/
- printf("MML_UseSpace: Segment spans two blocks!\n");
+ /*__asm
+ {
+ push ds
+ mov ax,ds
+ inc ax
+ mov ds,ax
+ }*/
+printf("segm=%u ", segm);
+printf("ex=%lu ", extra);
+printf("len=%u ", scan->length);
+printf("segsta=%x ", segstart);
+printf("seglen=%lu\n", seglength);
+
+//MML_UseSpace(?segstart?, ?length?, mm);
+
+ /*__asm
+ {
+ pop ds
+ }*/
+ //printf("MML_UseSpace: Segment spans two blocks!\n");
}
//segu:
void MM_Startup(mminfo_t *mm, mminfotype *mmi)
{
int i;
- dword length;//,farlen;
+ dword length;
void huge *start;
unsigned segstart,seglength,endfree;
MM_GetNewBlock(mm);
mm->mmhead = mm->mmnew; // this will allways be the first node
mm->mmnew->start = 0;
- mm->mmnew->length = 0xffff; //todo: mm make it fucking massive as fuck!~
+ mm->mmnew->length = 0xffff;
mm->mmnew->attributes = LOCKBIT;
mm->mmnew->next = NULL;
mm->mmrover = mm->mmhead;
_nheapgrow();
length=_memavl();
start = (void huge *)(mm->nearheap = malloc(length));
-
length -= 16-(FP_OFF(start)&15);
length -= SAVENEARHEAP;
seglength = length / 16; // now in paragraphs
segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
MML_UseSpace(segstart,seglength, mm);
mmi->nearheap = length;
+ //printf("near heap ok!\n");
//
// get all available far conventional memory segments
//---- length=farcoreleft();
_fheapgrow();
length=_memavl();
- //length-=farlen;
- start = mm->farheap = halloc(length, sizeof(dword));
+ start = mm->farheap = halloc(length, sizeof(byte));
//start = mm->farheap = _fmalloc(length);
length -= 16-(FP_OFF(start)&15);
length -= SAVEFARHEAP;
MML_UseSpace(segstart,seglength, mm);
mmi->farheap = length;
mmi->mainmem = mmi->nearheap + mmi->farheap;
+ //printf("far heap ok!\n");
//
if(US_CheckParm(__argv[i],ParmStringsexmm) == 0)
goto xmsskip; // param NOXMS
}
-// 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!
+ 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_CheckForXMS(mm))
{
printf("XMS!\n");
void MM_ShowMemory(mminfo_t *mm)
{
mmblocktype huge *scan;
- unsigned color,temp;//, i;
+ unsigned color,temp;
long end,owner;
- char scratch[80],str[10];
+ char scratch[160],str[16];
//**** VW_SetDefaultColors();
//**** VW_SetLineWidth(40);
//CA_OpenDebug ();
- while (scan)
+ while(scan)
{
if(scan->attributes & PURGEBITS)
color = 5; // dark purple = purgable
color = 12; // red = locked
if(scan->start<=end)
{
- printf("MM_ShowMemory: Memory block order currupted!");
+ printf("\nMM_ShowMemory: Memory block order currupted!\n");
return;
}
end = scan->start+scan->length-1;
//++++ VW_Hlin(end+1,scan->next->start,0,0); // black = free
//****#if 0
-printf("Location:");
-printf("%x\t", scan->start);
-strcpy (scratch,"Size:");
+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:");
+ultoa (scan->start,str,16);
+strcat (scratch,str);
+strcat (scratch,"\tSize:");
ltoa ((dword)scan->length*16,str,10);
strcat (scratch,str);
strcat (scratch,"\tOwner:0x");
x->next=mm->mmfree;
mm->mmfree=x;
}
+
+void MM_seguin(void)
+{
+ __asm
+ {
+ push ds
+ mov ax,ds
+ inc ax
+ mov ds,ax
+ }
+}
+
+void MM_segude(void)
+{
+ __asm
+ {
+ pop ds
+ }
+}
+
+/*
+pull data from far and put it into ds var
+mov ax,es:si
+mov x,ax
+*/
+/*
+ss stack segment
+sp top of stack
+bp bottem of stack
+*/