1 // Cut this out as emm.c
\r
4 * Module: All Modules
\r
5 * Author(s): Chris Somers
\r
6 * Date: December 1, 1992
\r
9 minor mods by Alex Russell to simplify
\r
11 Must use memory model with FAR code
\r
22 void TransformData(char *pEmmData, unsigned int len)
\r
38 if ( OpenEMM() != SUCCESS )
\r
39 { // make sure we got EMM
\r
40 printf("EMM unavailable.\n");
\r
44 printf("Emm available\n");
\r
46 pEmmData = (char *)EMMalloc(&hEData, 6); // get 6 * 16K bytes - 96K
\r
47 if ( pEmmData == NULL )
\r
49 printf("Not enough EMM or out of handles.\n");
\r
53 printf("emm alloced OK\n");
\r
56 printf("Map 1st 4 pages\n");
\r
57 MapEMM(hEData, 0, 4); // load 1st 4 pages into page frame: 0-3
\r
59 memset(pEmmData, 0x0e, 64000u);
\r
60 UnmapEMM(hEData, 0, 4); // not absolutely necessary
\r
62 printf("Map next 2 pages\n");
\r
63 MapEMM(hEData, 4, 2); // map last 2 pages: 4-5
\r
64 memset(pEmmData, 0x0e, 32768u);
\r
66 MapEMM(hEData, 0, 4);
\r
67 // do some stuff with the first 64K of file data.
\r
68 printf("Transform data\n");
\r
69 TransformData(pEmmData, 64000UL);
\r
70 MapEMM(hEData, 4, 2); // only unmaps 1st two pages of prior 64k mapping
\r
71 // do stuff with remaining 32K of data
\r
72 TransformData(pEmmData, 32768UL);
\r
73 UnmapEMM(hEData, 0, 4); // should unmap before freeing
\r
75 printf("Close emm\n");
\r
76 EMMFree(hEData); // finished with the file data
\r