X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Femmtest.c;h=e8bfe1f549254a0d9c32df7287073c8b8e6b001d;hb=eb2d77a6f6d61364d97bc8a4ed4951f1393729c1;hp=eefab9ea8cf7337f1a8740d6b0ba38818e92614e;hpb=75e7cf251be21eb29a7c5df05b4b1320393214ff;p=16.git diff --git a/src/emmtest.c b/src/emmtest.c old mode 100644 new mode 100755 index eefab9ea..e8bfe1f5 --- a/src/emmtest.c +++ b/src/emmtest.c @@ -8,8 +8,8 @@ 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~ */ @@ -17,11 +17,11 @@ #include #include #include -#include +#include + +#include "src/lib/exmm/memory.h" +#include "src/lib/types.h" -#include "src/lib/exmm/memory.h" -#include "src/lib/types.h" - #define PEMMDATAPAGENUM 4 void TransformData(char *pEmmData, unsigned int len) @@ -37,30 +37,30 @@ void TransformData(char *pEmmData, unsigned int len) int main(int argc, char *argv[]) { - byte *pEmmData; - int hEData; - unsigned long advi; - unsigned long i=0; - char huge *p =(char huge *)(GetEMMSeg0()*0x10000); + byte *pEmmData; + int hEData; + unsigned long advi; + unsigned long i=0; + char huge *p =(char huge *)(GetEMMSeg0()*0x10000); if(OpenEMM() != SUCCESS) { // make sure we got EMM printf("EMM unavailable.\n"); exit(1); } - else + else { - printf("Emm %x available\n", EMVer()); - printf("EMS pages available are %lu\n", EMMCoreLeft()); - //printf("EMM Hardware Information %lu\n", EMInfo()); + 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=%p\n", pEmmData); - //printf("b4 EMS *pEmmData=%s\n", *pEmmData); - advi=EMMCoreLeft()*EMMPAGESIZE; - printf("advi=%lu\n", advi); - - pEmmData = (byte *)EMMalloc(&hEData, EMMCoreLeft()); // get 6 * 16K bytes - 96K + + printf("b4 EMS pEmmData=%p\n", pEmmData); + //printf("b4 EMS *pEmmData=%s\n", *pEmmData); + advi=EMMCoreLeft()*EMMPAGESIZE; + printf("advi=%lu\n", advi); + + pEmmData = (byte *)EMMalloc(&hEData, EMMCoreLeft()); // get 6 * 16K bytes - 96K if(pEmmData == NULL/* || pEmmData0 == NULL*/) { printf("Not enough EMM or out of handles.\n"); @@ -68,73 +68,73 @@ int main(int argc, char *argv[]) } else printf("EMM allocate OK\n"); - - printf("EMS pages available are %lu\n", EMMCoreLeft()); - - - + + printf("EMS pages available are %lu\n", EMMCoreLeft()); + + + printf("Map 1st 4 pages\n"); MapEMM(hEData, 0, PEMMDATAPAGENUM); // load 1st 4 pages into page frame: 0-3 - //memset(pEmmData, 0x0e, 64000u); -//0000 printf("(advi*EMMPAGESIZE)=%lu\n", advi); - memset(pEmmData, atoi(argv[1]), 0xffff);//sizeof(atoi(argv[1])));//((EMMCoreLeft())*EMMPAGESIZE)); -//qqqq memset(pEmmData+0x10000, atoi(argv[1]), 0xffff);//sizeof(atoi(argv[1])));//((EMMCoreLeft())*EMMPAGESIZE)); -//---- UnmapEMM(hEData, 0, 4); // not absolutely necessary - printf("%p= %c %c %c %c %c %c %c %c\n", pEmmData, -*pEmmData, *(pEmmData+1), *(pEmmData+2), *(pEmmData+3), *(pEmmData+4), *(pEmmData+5), *(pEmmData+6), *(pEmmData+7)); + //memset(pEmmData, 0x0e, 64000u); +//0000 printf("(advi*EMMPAGESIZE)=%lu\n", advi); + memset(pEmmData, atoi(argv[1]), 0xffff);//sizeof(atoi(argv[1])));//((EMMCoreLeft())*EMMPAGESIZE)); +//qqqq memset(pEmmData+0x10000, atoi(argv[1]), 0xffff);//sizeof(atoi(argv[1])));//((EMMCoreLeft())*EMMPAGESIZE)); +//---- UnmapEMM(hEData, 0, 4); // not absolutely necessary + printf("%p= %c %c %c %c %c %c %c %c\n", pEmmData, +*pEmmData, *(pEmmData+1), *(pEmmData+2), *(pEmmData+3), *(pEmmData+4), *(pEmmData+5), *(pEmmData+6), *(pEmmData+7)); /*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=%p\n", pEmmData);*/ + memset(pEmmData, 0x04, 32768u); +// memset(pEmmData, atoi(argv[0]), 32768u); + printf("*pEmmData=%c\n", *pEmmData); + printf(" pEmmData=%p\n", pEmmData);*/ /*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); - printf("*pEmmData=%lu\n", *pEmmData);*/ - if(atoi(argv[2])) - { - while(p<(char huge *)((GetEMMSeg0()*0x10000)+0xffff) && !kbhit()) - { - if((i%16)==0) printf("%p= %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c\n", p, -*p, *(p+1), *(p+2), *(p+3), *(p+4), *(p+5), *(p+6), *(p+7), -*(p+8), *(p+9), *(p+10), *(p+11), *(p+12), *(p+13), *(p+14), *(p+15)); - // (*p)++; - i++; - p++; - } - } - /*if(atoi(argv[3])) - p =(char huge *)(GetEMMSeg0()*0x20000); - while(p<(char huge *)((GetEMMSeg0()*0x20000)+0xffff) && !kbhit()) - { - if((i%16)==0) printf("%p= %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c\n", p, -*p, *(p+1), *(p+2), *(p+3), *(p+4), *(p+5), *(p+6), *(p+7), -*(p+8), *(p+9), *(p+10), *(p+11), *(p+12), *(p+13), *(p+14), *(p+15)); - // (*p)++; - i++; - p++; - } - //free(p); - }*/ - if(!atoi(argv[3])) + TransformData(pEmmData, 32768UL); + printf("*pEmmData=%lu\n", *pEmmData);*/ + if(atoi(argv[2])) { - UnmapEMM(hEData, 0, PEMMDATAPAGENUM); // should unmap before freeing + while(p<(char huge *)((GetEMMSeg0()*0x10000)+0xffff) && !kbhit()) + { + if((i%16)==0) printf("%p= %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c\n", p, +*p, *(p+1), *(p+2), *(p+3), *(p+4), *(p+5), *(p+6), *(p+7), +*(p+8), *(p+9), *(p+10), *(p+11), *(p+12), *(p+13), *(p+14), *(p+15)); + // (*p)++; + i++; + p++; + } + } + /*if(atoi(argv[3])) + p =(char huge *)(GetEMMSeg0()*0x20000); + while(p<(char huge *)((GetEMMSeg0()*0x20000)+0xffff) && !kbhit()) + { + if((i%16)==0) printf("%p= %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c\n", p, +*p, *(p+1), *(p+2), *(p+3), *(p+4), *(p+5), *(p+6), *(p+7), +*(p+8), *(p+9), *(p+10), *(p+11), *(p+12), *(p+13), *(p+14), *(p+15)); + // (*p)++; + i++; + p++; + } + //free(p); + }*/ + if(!atoi(argv[3])) + { + UnmapEMM(hEData, 0, PEMMDATAPAGENUM); // 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=%p\n", pEmmData); - printf("EMS pages available are %lu\n", EMMCoreLeft()); - printf("GetEMMSeg0=%p\n", GetEMMSeg0()*0x10000); - //printf("EMMPAGESIZE=%d\n", EMMPAGESIZE); - return 0; + CloseEMM(); + } + printf("after EMS pEmmData=%p\n", pEmmData); + printf("EMS pages available are %lu\n", EMMCoreLeft()); + printf("GetEMMSeg0=%p\n", GetEMMSeg0()*0x10000); + //printf("EMMPAGESIZE=%d\n", EMMPAGESIZE); + return 0; }