X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fexmm%2Femm.c;h=40d5650f71ea64e20905e3fe8f58a72c6649883a;hb=88a70251309902e450052de212343e9d1835d834;hp=60238150aeece26c4ca2b568da95b9eee7a69efd;hpb=de4d33a05ca28e5332570749f3a1c1648db896a3;p=16.git diff --git a/src/lib/exmm/emm.c b/src/lib/exmm/emm.c index 60238150..40d5650f 100644 --- a/src/lib/exmm/emm.c +++ b/src/lib/exmm/emm.c @@ -4,11 +4,13 @@ * Module: All Modules * Author(s): Chris Somers * Date: December 1, 1992 - * Version: V.1.1 + * Version: V.1.1w minor mods by Alex Russell to simplify - Must use memory model with FAR code + Must use memory model with FAR code + + Open Watcom patch by sparky4~ */ @@ -30,49 +32,74 @@ void TransformData(char *pEmmData, unsigned int len) } } -void main(void) +int main(int argc, char *argv[]) { - char *pEmmData; - int hEData; - - if ( OpenEMM() != SUCCESS ) - { // make sure we got EMM - printf("EMM unavailable.\n"); - exit(1); - } - else - printf("Emm %x available\n", EMVer()); - - pEmmData = (char *)EMMalloc(&hEData, 6); // get 6 * 16K bytes - 96K - if ( pEmmData == NULL ) - { - printf("Not enough EMM or out of handles.\n"); - exit(2); - } - else - printf("emm alloced OK\n"); - - - printf("Map 1st 4 pages\n"); - MapEMM(hEData, 0, 4); // load 1st 4 pages into page frame: 0-3 - - memset(pEmmData, 0x0e, 64000u); - UnmapEMM(hEData, 0, 4); // not absolutely necessary - - printf("Map next 2 pages\n"); - MapEMM(hEData, 4, 2); // map last 2 pages: 4-5 - memset(pEmmData, 0x0e, 32768u); - - MapEMM(hEData, 0, 4); + byte *pEmmData; + int hEData; + + if(OpenEMM() != SUCCESS) + { // make sure we got EMM + printf("EMM unavailable.\n"); + exit(1); + } + else + { + printf("Emm %x available\n", EMVer()); + printf("EMS pages available are %lu\n", EMMCoreLeft()); + //printf("EMM Hardware Information %lu\n", EMInfo()); + } + + 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*/) + { + printf("Not enough EMM or out of handles.\n"); + exit(2); + } + else + printf("EMM allocate OK\n"); + + printf("EMS pages available are %lu\n", EMMCoreLeft()); + + printf("Map 1st 4 pages\n"); + MapEMM(hEData, 0, 4); // load 1st 4 pages into page frame: 0-3 + //memset(pEmmData, 0x0e, 64000u); + memset(pEmmData, atoi(argv[1]), sizeof(atoi(argv[1])));//((EMMCoreLeft())*EMMPAGESIZE)); +//---- UnmapEMM(hEData, 0, 4); // not absolutely necessary + printf("*pEmmData=%c\n", *pEmmData); + + printf("Map next 2 pages\n"); + MapEMM(hEData, 4, 2); // map last 2 pages: 4-5 + memset(pEmmData, 0x04, 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);*/ + + /*MapEMM(hEData, 0, 4); // do some stuff with the first 64K of file data. printf("Transform data\n"); - TransformData(pEmmData, 64000UL); + TransformData(pEmmData, 64000UL); + printf("*pEmmData=%lu\n", *pEmmData); MapEMM(hEData, 4, 2); // only unmaps 1st two pages of prior 64k mapping // do stuff with remaining 32K of data - TransformData(pEmmData, 32768UL); - UnmapEMM(hEData, 0, 4); // should unmap before freeing - - printf("Close emm\n"); - EMMFree(hEData); // finished with the file data - CloseEMM(); + TransformData(pEmmData, 32768UL); + printf("*pEmmData=%lu\n", *pEmmData);*/ + + UnmapEMM(hEData, 0, EMMCoreLeft(/*4*/)); // should unmap before freeing + //UnmapEMM(hEData0, 0, 1); // should unmap before freeing + //printf("after EMS *pEmmData=%c\n", *pEmmData); + + printf("Close emm\n"); + EMMFree(hEData); // finished with the file data + CloseEMM(); + printf("after EMS *pEmmData=%x\n", *pEmmData); + printf("EMS pages available are %lu\n", EMMCoreLeft()); + //printf("EMMPAGESIZE=%d\n", EMMPAGESIZE); + return 0; }