1、LOADDISP.C
#include <fcntl.h>
#include <io.h>
#include <dos.h>
#define DISPMAP "disp.map"
#define GRAPHSIZE 65534
char far *dispbuf=MK_FP(0xb800,0);
char buf[20][256];
int handle;
char cur[2];
loadega(char *sfile) {
unsigned char i,j;
handle=_open(sfile,O_RDWR);
if(handle==-1)
return 1;
_read(handle,&i,1);
_read(handle,cur,2);
_AH=0;
_AL=i;
geninterrupt(0x10);
_read(handle,buf[0],5117);
if(i>8)
{
for(j=1;j<8;j*=2) {
_ES=FP_SEG(buf[j]);
_BX=FP_OFF(buf[j]);
_CX=j;
_AX=0x1c02;
geninterrupt(0x10);
}
}
_DL=cur[0];
_DH=cur[1];
_BH=0;
_AH=2;
geninterrupt(0x10);
if(i<8)
readtext();
else
readgraph();
_close(handle);
}
char path[64];
char name[64];
main(int argc,char *argv[]) {
char *s,*t;
s=argv[0];
t=0;
for(;*s;s++) {
if(*s=='\\')
t=s;
}
*(t+1)=0;
sprintf(path,"%s",argv[0]);
if(argc>1)
sprintf(name,"%s",argv[1]);
else
sprintf(name,"%s%s",path,DISPMAP);
loadega(name);
}
readgraph() {
unsigned char far *buffer;
char tmp[2];
buffer=MK_FP(0xa000,0);
tmp[0]=inportb(0x3c4);
outportb(0x3c4,2);
tmp[1]=inportb(0x3c5);
outportb(0x3c5,8);
_read(handle,(char *far)buffer,GRAPHSIZE);
outportb(0x3c5,4);
_read(handle,(char *far)buffer,GRAPHSIZE);
outportb(0x3c5,2);
_read(handle,(char *far)buffer,GRAPHSIZE);
outportb(0x3c5,1);
_read(handle,(char *far)buffer,GRAPHSIZE);
outportb(0x3c5,tmp[1]);
outportb(0x3c4,tmp[0]);
}
readtext() {
int i,a,b;
int c,r;
int x,y;
_read(handle,(char far *)dispbuf,4000);
}
2、SAVEDISP.C
#include <fcntl.h>
#include <io.h>
#include <dos.h>
#define DISPMAP "disp.map"
#define GRAPHSIZE 65534
char far *dispbuf=MK_FP(0xb800,0);
char buf[20][256];
int handle;
char cur[2];
saveega(char *sfile) {
unsigned char i;
for(i=1;i<8;i*=2) {
_ES=FP_SEG(buf[i]);
_BX=FP_OFF(buf[i]);
_CX=i;
_AX=0x1c01;
geninterrupt(0x10);
}
_AH=0xf;
geninterrupt(0x10);
i=_AL;
_BH=0;
_AH=3;
geninterrupt(0x10);
cur[0]=_DL;
cur[1]=_DH;
handle=_creat(sfile,FA_ARCH);
if(handle==-1)
return 1;
_write(handle,&i,1);
_write(handle,cur,2);
_write(handle,buf[0],5117);
if(i<8)
_write(handle,dispbuf,4000);
else
writegraph();
_close(handle);
}
char path[64];
char name[64];
main(int argc,char *argv[]) {
char *s,*t;
s=argv[0];
t=0;
for(;*s;s++) {
if(*s=='\\')
t=s;
}
*(t+1)=0;
sprintf(path,"%s",argv[0]);
if(argc>1)
sprintf(name,"%s",argv[1]);
else
sprintf(name,"%s%s",path,DISPMAP);
saveega(name);
}
writegraph() {
unsigned char far *buffer;
buffer=MK_FP(0xa000,0);
outportb(0x3ce,5);
outportb(0x3cf,0);
outportb(0x3ce,4);
outportb(0x3cf,3);
_write(handle,(void *far)buffer,GRAPHSIZE);
outportb(0x3cf,2);
_write(handle,(void *far)buffer,GRAPHSIZE);
outportb(0x3cf,1);
_write(handle,(void *far)buffer,GRAPHSIZE);
outportb(0x3cf,0);
_write(handle,(void *far)buffer,GRAPHSIZE);
}