}\r
}\r
\r
-void main(void)\r
+void main(int argc, char *argv[])\r
{\r
- char *pEmmData;\r
- int hEData;\r
-\r
- if ( OpenEMM() != SUCCESS )\r
- { // make sure we got EMM\r
- printf("EMM unavailable.\n");\r
- exit(1);\r
- }\r
- else\r
- printf("Emm %x available\n", EMVer());
- printf("EMS pages available are %lu\n", EMMCoreLeft());\r
-\r
- pEmmData = (char *)EMMalloc(&hEData, 6); // get 6 * 16K bytes - 96K\r
- if ( pEmmData == NULL )\r
- {\r
- printf("Not enough EMM or out of handles.\n");\r
- exit(2);\r
- }\r
- else\r
- printf("emm alloced OK\n");\r
-\r
-\r
- printf("Map 1st 4 pages\n");\r
- MapEMM(hEData, 0, 4); // load 1st 4 pages into page frame: 0-3\r
-\r
- memset(pEmmData, 0x0e, 64000u);\r
- UnmapEMM(hEData, 0, 4); // not absolutely necessary\r
- \r
- printf("Map next 2 pages\n");\r
- MapEMM(hEData, 4, 2); // map last 2 pages: 4-5\r
- memset(pEmmData, 0x0e, 32768u);\r
+ byte *pEmmData;
+ int hEData;
+\r
+ if(OpenEMM() != SUCCESS)\r
+ { // make sure we got EMM\r
+ printf("EMM unavailable.\n");\r
+ exit(1);\r
+ }\r
+ else
+ {\r
+ printf("Emm %x available\n", EMVer());
+ printf("EMS pages available are %lu\n", EMMCoreLeft());
+ //printf("EMM Hardware Information %lu\n", EMInfo());
+ }\r
+
+ printf("b4 EMS *pEmmData=%x\n", *pEmmData);
+ //printf("b4 EMS *pEmmData=%s\n", *pEmmData);
+
+ pEmmData = (byte *)EMMalloc(&hEData, EMMCoreLeft(/*6*/)); // get 6 * 16K bytes - 96K
+ if(pEmmData == NULL/* || pEmmData0 == NULL*/)\r
+ {\r
+ printf("Not enough EMM or out of handles.\n");\r
+ exit(2);\r
+ }\r
+ else\r
+ printf("EMM allocate OK\n");\r
+
+ printf("EMS pages available are %lu\n", EMMCoreLeft());
+
+ printf("Map 1st 4 pages\n");\r
+ MapEMM(hEData, 0, EMMCoreLeft(/*4*/)-2); // load 1st 4 pages into page frame: 0-3\r
+ //memset(pEmmData, 0x0e, 64000u);
+ memset(pEmmData, atoi(argv[1]), 64000u);
+//---- UnmapEMM(hEData, 0, 4); // not absolutely necessary
+ printf("*pEmmData=%c\n", *pEmmData);
+\r
+ printf("Map next 2 pages\n");\r
+ MapEMM(hEData, EMMCoreLeft(/*4*/)-2, EMMCoreLeft(/*2*/)); // map last 2 pages: 4-5\r
+ memset(pEmmData, 0x0e, 32768u);
+// memset(pEmmData, atoi(argv[0]), 32768u);
+ printf("*pEmmData=%c\n", *pEmmData);
+// printf("*pEmmData++=%c\n", *(pEmmData++));
+
+ /*MapEMM(hEData0, 0, 1);
+ memset(pEmmData0, (short)4, sizeof(short));
+ printf("*pEmmData0=%d\n", *pEmmData0);*/
\r
- MapEMM(hEData, 0, 4);\r
+ /*MapEMM(hEData, 0, 4);\r
// do some stuff with the first 64K of file data.\r
printf("Transform data\n");\r
- TransformData(pEmmData, 64000UL);\r
+ TransformData(pEmmData, 64000UL);
+ printf("*pEmmData=%lu\n", *pEmmData);\r
MapEMM(hEData, 4, 2); // only unmaps 1st two pages of prior 64k mapping\r
// do stuff with remaining 32K of data\r
- TransformData(pEmmData, 32768UL);\r
- UnmapEMM(hEData, 0, 4); // should unmap before freeing\r
-\r
- printf("Close emm\n");\r
- EMMFree(hEData); // finished with the file data\r
- CloseEMM();\r
+ TransformData(pEmmData, 32768UL);
+ printf("*pEmmData=%lu\n", *pEmmData);*/
+\r
+ UnmapEMM(hEData, 0, EMMCoreLeft(/*4*/)); // should unmap before freeing
+ //UnmapEMM(hEData0, 0, 1); // should unmap before freeing\r
+ //printf("after EMS *pEmmData=%c\n", *pEmmData);
+\r
+ printf("Close emm\n");\r
+ EMMFree(hEData); // finished with the file data\r
+ CloseEMM();
+ printf("after EMS *pEmmData=%x\n", *pEmmData);
+ printf("EMS pages available are %lu\n", EMMCoreLeft());
}\r
static int EMStateSave(int Handle);\r
static void EMStateRestore(int Handle);\r
+/********************************************************************/
+//beta
+unsigned long\r
+EMInfo(void)\r
+{
+ int EMSinfo;\r
+ _asm
+ {
+ mov ah,0x58\r
+ int 0x67
+ mov EMSinfo,ax\r
+ }
+ return((unsigned long)EMSinfo);\r
+}
+
/********************************************************************/
int\r
return(EMSver);\r
}\r
\r
-/********************************************************************/\r
+/********************************************************************/
+\r
int\r
OpenEMM(void)\r
{\r
End:
}
if(!interr)
- RtnVal = ((unsigned long)Pages); /* Pages * 16K rtns bytes*/
+ RtnVal = ((unsigned long)Pages); /* Pages * 16K rtns bytes*/ //<< 14);
\r
return(RtnVal);\r
} /* End of EMMCoreLeft() */\r
*Handle = NOTREADY;\r
return(NULL);\r
}\r
- if ((Pages < 1) || (Pages > EMMCoreLeft())) {\r
+ if ((Pages < 1) || (Pages > EMMCoreLeft(/*1020*/))) {\r
*Handle = VALUE_OUTF_RANGE;\r
return (NULL);\r
}\r
if (!EMMSeg) return(NOTREADY);\r
for (i = 0; (i < MAXEMHANDLES) && (ActiveEMList[i] != Handle); i++) ;\r
if (i == MAXEMHANDLES) return (NO_DATA);\r
- if ((GetNumPages(Handle) < Pages) || (Pages < 1) || (Pages > 4)) {\r
+ if ((GetNumPages(Handle) < Pages) || (Pages < 1) || (Pages > EMMCoreLeft(/*4*/))) {\r
return (VALUE_OUTF_RANGE);\r
}\r
for (i = Start; i < Start + Pages; i++) {\r
for (i = 0; (i < MAXEMHANDLES) && (ActiveEMList[i] != Handle); i++) ;\r
if (i == MAXEMHANDLES) return;\r
j = Start + Pages;\r
- if ((Pages < 1) || (j > 4)) return;\r
+ if ((Pages < 1) || (j > EMMCoreLeft(/*4*/))) return;\r
\r
for (i = Start; i < j; i++) {\r
EMMap(Handle, NONE, i);\r