==========================\r
*/\r
\r
-boolean CA_FarRead (int handle, byte huge *dest, dword length)\r
+boolean CA_FarRead(int handle, byte huge *dest, dword length)\r
{\r
boolean flag;\r
dword fat=0;
word segm=0;\r
- while(length>0xffffl)
+ if(length>0xfffflu)
{
- fat=length-0xffffl;
- segm++;\r
+ segm=(length%0xfffflu)-1;
+ fat=segm*0xfffflu;
+ length-=fat;\r
// printf("CA_FarRead doesn't support 64K reads yet!\n");\r
}
-\r
- __asm\r
+
+ if(!fat&&!segm)
{\r
- push ds\r
- mov bx,[handle]\r
- mov cx,[WORD PTR length]\r
- mov dx,[WORD PTR dest]\r
- mov ds,[WORD PTR dest+2]\r
- mov ah,0x3f // READ w/handle\r
- int 21h\r
- pop ds\r
- jnc good\r
- mov errno,ax\r
- mov flag,0\r
- jmp End\r
+ __asm\r
+ {\r
+ push ds\r
+ mov bx,[handle]\r
+ mov cx,[WORD PTR length]\r
+ mov dx,[WORD PTR dest]\r
+ mov ds,[WORD PTR dest+2]\r
+ mov ah,0x3f // READ w/handle\r
+ int 21h\r
+ pop ds\r
+ jnc good\r
+ mov errno,ax\r
+ mov flag,0\r
+ jmp End\r
good:\r
- cmp ax,[WORD PTR length]\r
- je done\r
-// errno = EINVFMT; // user manager knows this is bad read\r
- mov flag,0\r
- jmp End\r
+ cmp ax,[WORD PTR length]\r
+ je done\r
+// errno = EINVFMT; // user manager knows this is bad read\r
+ mov flag,0\r
+ jmp End\r
done:\r
- mov flag,1\r
+ mov flag,1\r
End:\r
- }\r
- return flag;\r
+ }\r
+ return flag;
+ }else return 0;//todo: EXPAND!!!\r
}\r
\r
\r
==========================\r
*/\r
\r
-boolean CA_FarWrite (int handle, byte huge *source, dword length)\r
+boolean CA_FarWrite(int handle, byte huge *source, dword length)\r
{\r
boolean flag;\r
dword fat=0;
word segm=0;\r
- while(length>0xffffl)
+ if(length>0xfffflu)
{
- fat=length-0xffffl;
- segm++;\r
+ segm=(length%0xfffflu)-1;
+ fat=segm*0xfffflu;
+ length-=fat;\r
// printf("CA_FarRead doesn't support 64K reads yet!\n");\r
}\r
-\r
- __asm\r
+
+ if(!fat&&!segm)
{\r
- push ds\r
- mov bx,[handle]\r
- mov cx,[WORD PTR length]\r
- mov dx,[WORD PTR source]\r
- mov ds,[WORD PTR source+2]\r
- mov ah,0x40 // WRITE w/handle\r
- int 21h\r
- pop ds\r
- jnc good\r
- mov errno,ax\r
- mov flag,0\r
- jmp End\r
+ __asm\r
+ {\r
+ push ds\r
+ mov bx,[handle]\r
+ mov cx,[WORD PTR length]\r
+ mov dx,[WORD PTR source]\r
+ mov ds,[WORD PTR source+2]\r
+ mov ah,0x40 // WRITE w/handle\r
+ int 21h\r
+ pop ds\r
+ jnc good\r
+ mov errno,ax\r
+ mov flag,0\r
+ jmp End\r
good:\r
- cmp ax,[WORD PTR length]\r
- je done\r
- //errno = ENOMEM; // user manager knows this is bad write\r
- mov flag,0\r
- jmp End\r
+ cmp ax,[WORD PTR length]\r
+ je done\r
+ //errno = ENOMEM; // user manager knows this is bad write\r
+ mov flag,0\r
+ jmp End\r
done:\r
- mov flag,1\r
+ mov flag,1\r
End:\r
- }\r
- return flag;\r
+ }\r
+ return flag;
+ }else return 0;\r
}\r
\r
\r
mov [freeEMSpages],bx
or bx,bx
jz noEMS // no EMS at all to allocate
-
+//++++EXPAND DONG!!!!
cmp bx,4
jle getpages // there is only 1,2,3,or 4 pages
mov bx,4 // we can't use more than 4 pages
void MML_UseSpace(unsigned segstart, dword seglength, mminfo_t *mm)
{
mmblocktype huge *scan,huge *last;
- unsigned oldend;
- //++++if(mm->EMSVer)
+ dword oldend;
+ dword fat=0;
+ word segm=0;
dword extra;
scan = last = mm->mmhead;
oldend = scan->start + scan->length;
extra = oldend - (segstart+seglength);
//++++emsver stuff!
- if(extra > 0xfffflu)
+ if(extra>0xfffflu)
{
- printf("MML_UseSpace: Segment spans two blocks!\n");
- //return;
+ segm=(extra%(0xfffflu))-1;
+ fat=segm*(0xfffflu);
+ extra-=fat;
+//printf("extra=%lu ", extra);
+//printf("segm=%lu\n", segm);
+ printf("MML_UseSpace: Segment spans two blocks!\n");\r
}
-
+//segu:
+//++++todo: linked list of segment!
+//printf("segm=%lu\n", segm);
if(segstart == scan->start)
{
last->next = scan->next; // unlink block
else
scan->length = segstart-scan->start; // shorten block
+// segm--;
+
if(0xfffflu > extra > 0)
{
MM_GetNewBlock(mm);
mm->mmnew->start = segstart+seglength;
mm->mmnew->length = extra;
mm->mmnew->attributes = LOCKBIT;
- }
+ }//else if(segm>0) goto segu;
}
MML_SetupEMS(mm); // allocate space
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!
- if(mm->EMSVer>=0x40) MML_UseSpace(mm->EMSpageframe,((dword)mm->EMSpagesmapped)*((dword)mm->freeEMSpages), mm);
- else MML_UseSpace(mm->EMSpageframe,mm->EMSpagesmapped*0x400, mm);
+ if(mm->EMSVer>=0x40) MML_UseSpace(mm->EMSpageframe,((dword)mm->EMSpagesmapped)*0x4000lu, mm);
+ else MML_UseSpace(mm->EMSpageframe,mm->EMSpagesmapped*0x4000lu, mm);
//printf("EMS3\n");
MM_MapEMS(mm); // map in used pages
//printf("EMS4\n");
- if(mm->EMSVer>=0x40) mmi->EMSmem = ((dword)mm->EMSpagesmapped)*((dword)mm->freeEMSpages);
- else mmi->EMSmem = mm->EMSpagesmapped*0x4000l;
+ if(mm->EMSVer>=0x40) mmi->EMSmem = ((dword)mm->EMSpagesmapped)*0x4000lu;
+ else mmi->EMSmem = mm->EMSpagesmapped*0x4000lu;
}
//