X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fexmm%2Femm.c;h=f50a91aa8773414c38c318e4bbc859edc4e84ecf;hb=6559b4112bb03d246cda3e3b1855b02495ab505c;hp=e3dcaa2a1d6554f673a4132916cd800395b7a667;hpb=c00274b45c7a7ea7cc9c139f46ef97e1a02c320e;p=16.git diff --git a/src/lib/exmm/emm.c b/src/lib/exmm/emm.c index e3dcaa2a..f50a91aa 100644 --- a/src/lib/exmm/emm.c +++ b/src/lib/exmm/emm.c @@ -14,45 +14,50 @@ */ - #include #include #include +#include #include "memory.h" void TransformData(char *pEmmData, unsigned int len) { - while ( len ) - { - (*pEmmData)++; - pEmmData++; + while(len) + { + (*pEmmData)++; + pEmmData++; - len--; - } + len--; + } } -void main(int argc, char *argv[]) +int main(int argc, char *argv[]) { 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 + { // 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("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=%p\n", pEmmData); //printf("b4 EMS *pEmmData=%s\n", *pEmmData); + advi=EMMCoreLeft()*EMMPAGESIZE; + printf("advi=%lu\n", advi); - pEmmData = (byte *)EMMalloc(&hEData, EMMCoreLeft(/*6*/)); // get 6 * 16K bytes - 96K + pEmmData = (byte *)EMMalloc(&hEData, EMMCoreLeft()); // get 6 * 16K bytes - 96K if(pEmmData == NULL/* || pEmmData0 == NULL*/) { printf("Not enough EMM or out of handles.\n"); @@ -63,23 +68,24 @@ void main(int argc, char *argv[]) printf("EMS pages available are %lu\n", EMMCoreLeft()); + + printf("Map 1st 4 pages\n"); - MapEMM(hEData, 0, EMMCoreLeft(/*4*/)-2); // load 1st 4 pages into page frame: 0-3 + MapEMM(hEData, 0, 4); // load 1st 4 pages into page frame: 0-3 //memset(pEmmData, 0x0e, 64000u); - memset(pEmmData, atoi(argv[1]), 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("*pEmmData=%c\n", *pEmmData); + 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, EMMCoreLeft(/*4*/)-2, EMMCoreLeft(/*2*/)); // map last 2 pages: 4-5 - memset(pEmmData, 0x0e, 32768u); + /*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);*/ + printf(" pEmmData=%p\n", pEmmData);*/ /*MapEMM(hEData, 0, 4); // do some stuff with the first 64K of file data. @@ -90,14 +96,42 @@ void main(int argc, char *argv[]) // do stuff with remaining 32K of data 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); + 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])) + { + UnmapEMM(hEData, 0, 4); // 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; }