www.pudn.com > SuperMario.zip > PCX.CPP
#include#include #include #include #include #include #include #include "engine.h" typedef struct{ char signature; char version; char encoding; char bits_per_pixel; int x_min; int y_min; int x_max; int y_max; int h_res; int v_res; char palette[48]; char reserved; char color_plane_num; int paletle_type; char zero_pad[58]; }PCX_Head; #define PCX_ID 0x0a void setallpalette(char far *pal) { register i; outportb(0x3c8,0); for(i=0;i<768;i++)outportb(0x3c9,*pal++>>=2); } /* if((pcxfile=fopen(argv[1],"rb"))==NULL)exit(1); if(fread(&pcxhead,sizeof(PCX_Head),1,pcxfile)!=1|| (width=pcxhead.x_max-pcxhead.x_min+1)<0|| (height=pcxhead.y_max-pcxhead.y_min+1)<0)exit(1); fseek(pcxfile,-768L,SEEK_END); fread(pal,3,0x100,pcxfile); setallpalette(pal); fseek(pcxfile,0x80l,SEEK_SET); for(x=100;x<200;x++){ v[640*4+x]=4; } */ void unpackpcxline(BITMAP *buff,FILE *pcxfile,unsigned bytes) { unsigned i=0; char ch; register count; char far *buf=buff->buffer; do{ if(((ch=fgetc(pcxfile))&0xc0)==0xc0){ count=ch&0x3f; i+=count; ch=fgetc(pcxfile); while(count--)*buf++=ch; } else{ *buf++=ch; i++; } }while(i