home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Rat's Nest 1
/
ratsnest1.iso
/
prgmming
/
c
/
pcxx.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-08-12
|
2KB
|
117 lines
/* PCX SHOW.. NOT THE FASTEST, BUT
WORKING ONE.. */
#include <stdio.h>
#include <dos.h>
#include <conio.h>
typedef struct {
unsigned char
manufact,
version,
encoding,
bpp;
unsigned int
xmin,ymin,
xmax,ymax,
hres,vres;
unsigned char pal[48];
unsigned char
reser,
planes;
unsigned int
bpl,
palt;
unsigned char filler[58];
} pcxhdr;
pcxhdr hdr;
unsigned int width,depth;
unsigned int bytes;
unsigned char pal[768];
unsigned char c;
FILE *fp;
void rpcxl(unsigned int ofs)
{
unsigned char c,run;
int n;
unsigned int w;
n=0;
while(n<bytes)
{
fread(&c,1,1,fp);
if((c & 192) == 192)
{
run = c & 63;
fread(&c,1,1,fp);
n = n + run;
for(w=0;w<run;w++)
{
pokeb(0xA000,ofs+w,c);
}
ofs += w;
} else
{
n++;
pokeb(0xA000,ofs,c);
ofs++;
}
}
}
void pcx(const char *fn)
{
int i;
fp = fopen(fn,"rb");
fread(&hdr,1,128,fp);
fseek(fp,-769L,SEEK_END);
fread(&c,1,1,fp);
fread(pal,1,768,fp);
fseek(fp,128,SEEK_SET);
width = hdr.xmax - hdr.xmin;
depth = hdr.ymax - hdr.ymin;
bytes = hdr.bpl;
for(i=0;i<768;i++)
pal[i] >>= 2;
asm mov al,0
asm mov dx,0x3c8
asm out dx,al
asm inc dx
for(i=0;i<768;i++)
asm out dx,al
for(i=0;i<depth-1;i++)
rpcxl(i*320);
asm mov al,0
asm mov dx,0x3c8
asm out dx,al
asm inc dx
for(i=0;i<768;i++)
{_AL = pal[i];
asm out dx,al
}
getch();
}
void main(void)
{
asm mov ax,0x13
asm int 0x10
pcx("lstorus.pcx");
pcx("lstorus.pcx");
pcx("lstorus.pcx");
pcx("lstorus.pcx");
asm mov ax,0x3
asm int 0x10
}