home *** CD-ROM | disk | FTP | other *** search
- /* egxshow.c */
- /* a slide show program by bill buckels 1991 */
- /* supported screen mode is EGA 640 x 350 x 16 color */
- /* supported picture format is zsoft pcx ega compatible */
- /* written in Microsoft Large Model C Version 5.1 */
-
-
- /* this program uses a 2 tank system of data storage */
- /* and breaks its image buffers into arrays of 2 dimns */
- /* in order to overcom the data segment limit of 64K. */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <string.h>
- #include <dos.h>
- #include <bios.h>
- #include <io.h>
- #include <malloc.h>
- #include <conio.h>
-
- #define EGA '\x10'
- #define TEXT '\x03'
-
- unsigned char setcrtmode(unsigned char vidmode)
- {
- union REGS inregs, outregs;
-
- /* set mode */
- inregs.h.ah = 0;
- inregs.h.al = vidmode;
- int86( 0x10, &inregs, &outregs );
-
- /* get mode */
- inregs.h.ah = 0xf;
- int86( 0x10, &inregs, &outregs );
-
- /* return mode */
- return outregs.h.al;
-
- }
-
-
- /* the structure of an ega color number...
-
- | 5 | 4 | 3 | 2 | 1 | 0 |
- | | | | | | |
- | R | G | B | R | G | B | color triples (rgb gun values)
- |
- high | low
- intensity intensity
-
- */
-
-
- /* byte 0-15 are colors... byte 16 is overscan register */
- unsigned char egainfo[17]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- void palettebits(int i, unsigned char color,
- unsigned char arg1, unsigned char arg2)
- {
-
- if(color>0x33)egainfo[i]|=arg1;
-
- if(color>0x77)
- {
- egainfo[i]&=~arg1;
- egainfo[i]|= arg2;
- }
-
- if(color>0xbb)egainfo[i]|=(arg1+arg2);
-
-
- }
-
-
- void rgb2ega(unsigned char *ptr)
- {
- int i;
- unsigned char color;
-
-
- for(i=0;i<16;i++)
- {
- egainfo[i]=0;
- color=*ptr++;
- palettebits(i,color,0x20,0x04);
- color=*ptr++;
- palettebits(i,color,0x10,0x02);
- color=*ptr++;
- palettebits(i,color,0x08,0x01);
- }
- egainfo[0]=0;
-
- }
-
- int setegapalette()
- {
- union REGS regs;
- unsigned char i;
-
- for(i=0;i<16;i++)
- {
- regs.h.ah = 0x10; /* function 10h */
- regs.h.al = 0x00;
- regs.h.bh = egainfo[i];
- regs.h.bl = i;
- int86(0x10,®s,®s);
- }
-
- /* dump data to color registers */
-
- return 0;
-
- }
-
- /* use bresenham's algorithm to draw lines */
- /* using the writepixel subroutine */
-
- #define BLACK 0
- #define BLUE 1
- #define GREEN 2
- #define CYAN 3
- #define RED 4
- #define MAGENTA 5
- #define BROWN 6
- #define WHITE 7
- #define GRAY 8
- #define LBLUE 9
- #define LGREEN 10
- #define LCYAN 11
- #define LRED 12
- #define LMAGENTA 13
- #define YELLOW 14
- #define BWHITE 15
-
- void flood(unsigned char floodcolor)
- {
- union REGS rin,rout;
-
- rin.h.dh =24;
- rin.h.dl =79;
- rin.x.cx = 0;
- rin.h.bh= floodcolor;
- rin.x.ax= 0x0600;
- int86(0x10,&rin,&rout);
- }
-
-
-
- void writepixel(unsigned x, unsigned y, unsigned color)
- {
- union REGS reg;
-
- reg.h.ah = 0x0c;
- reg.h.al = (char )color;
- reg.h.bh = 0;
- reg.x.cx = x;
- reg.x.dx = y;
-
- int86(0x10,®,®);
-
- }
-
-
- void linebox(int x1, int y1, int x2, int y2,unsigned tempcolor)
- {
- register x,y;
-
- x2++;
- x=x1;
- y=y1;
- while(x<x2)
- {
- writepixel(x,y,tempcolor);
- x++;
- }
- y++;
- x2--;
- while(y<y2)
- {
- writepixel(x1,y,tempcolor);
- writepixel(x2,y,tempcolor);
- y++;
- }
-
- x2++;
- x=x1;
- while(x<x2)
- {
- writepixel(x,y,tempcolor);
- x++;
- }
-
- }
-
- void writeline(int x1,int y1,int x2,int y2,unsigned color)
- {
- union REGS inregs, outregs;
- #define sign(x) ((x)>0?1:((x)==0?0:(-1)))
- int dx,dy,dxabs,dyabs,i,px,py,sdx,sdy,x,y;
-
- inregs.h.ah = 0x0c;
- inregs.h.al = (char )color;
- inregs.h.bh = 0;
-
-
- dx=x2-x1;
- dy=y2-y1;
- sdx=sign(dx);
- sdy=sign(dy);
- dxabs=abs(dx);
- dyabs=abs(dy);
- x=0;
- y=0;
- px=x1;
- py=y1;
-
- if(dxabs >= dyabs)
- {
- for(i=0;i<=dxabs;i++)
- {
- y+=dyabs;
- if(y>=dxabs)
- {y-=dxabs;
- py+=sdy;
- }
- inregs.x.cx = px;
- inregs.x.dx = py;
- int86(0x10,&inregs,&outregs);
- px+=sdx;
- }
- }
- else{
- for(i=0;i<=dyabs;i++)
- {
- x+=dxabs;
- if(x>=dyabs)
- {
- x-=dyabs;
- px+=sdx;
- }
- inregs.x.cx = px;
- inregs.x.dx = py;
- int86(0x10,&inregs,&outregs);
- py+=sdy;
- }
- }
- }
-
-
- /* romfont routines */
-
- #define CRETURN '\x0d'
-
- int egatext(char *str, unsigned x, unsigned y, unsigned colorvalue)
- {
-
- union REGS inregs, outregs;
-
- int scanline,byte,character,nibble; /* flags etcetera */
- int counter;
- unsigned char *romfont=(unsigned char *) 0xffa6000el;
- /* a pointer to the 8 x 8 BITMAPPED font in the PC ROM */
-
- int target = strlen(str); /* string length */
-
- if(!target)return 0;
- for(counter=0;counter<target;counter++){
- if(str[counter]<' '||str[counter]>'z')str[counter]=0;
- if(str[counter]==CRETURN)target=counter;
- }
-
- inregs.h.ah = 0x0c;
- inregs.h.al = (char )colorvalue;
- inregs.h.bh = 0;
-
-
-
- for (scanline=0;scanline<8;scanline++) /* finish the current scanline
- before advancing to the next */
- {
- for (byte=0;byte<target;byte++) /* run the scanline */
- { /* use the current character
- as an indices for the font */
- character = romfont[(str[byte]&0x7f)*8+scanline];
- if (character != 0)
- for (nibble=0;nibble<8;nibble++)
- if (character & 0x80>>nibble)
- {
- inregs.x.cx = x+byte*8+nibble;
- inregs.x.dx = y;
- int86(0x10,&inregs,&outregs);
- }
- }
-
- y++;
- }
- return target;
-
- }
-
- /* center justified x-dimension only */
- int egatextM(unsigned char *str,unsigned xorigin,unsigned yorigin,
- unsigned tempcolor)
- {
- int target = strlen(str); /* string length */
- int counter;
-
- if(!target)return 0;
-
- for(counter=0;counter<target;counter++){
- if(str[counter]<' '||str[counter]>'z')str[counter]=0;
- if(str[counter]==CRETURN)target=counter;
- }
- xorigin=(xorigin-(target*4));/* extrapolate the left edge */
- egatext(str,xorigin,yorigin,tempcolor); /* pass to the usual function */
- return target;
-
- }
-
-
- /* some other font routines */
-
- typedef struct
- {
- char filetype[4] ;
- unsigned char width ;
- unsigned char height ;
- unsigned char proportional;
- unsigned char style ;
- }FONTINFO;
-
- unsigned char COUR24Bheader[8]={
- 'F','P','C','C', 15, 25, 0, 2};
-
- unsigned char COUR24Bfont[3123]={
-
- 242, 0, 15,198, 0, 3,128, 3,128, 3,128, 3,
- 128, 3,128, 3,128, 3,128, 3,128, 3, 0, 3,
- 0, 3,199, 0, 3,128, 3,128,204, 0, 15,200,
- 0, 30,193,240, 30,193,240, 30,193,240, 30,193,
- 240, 30,193,240, 12, 96, 12, 96,220, 0, 15,198,
- 0, 3, 96, 3, 96, 3, 96, 3, 96, 3, 96, 3,
- 96, 31,193,248, 6,193,192, 6,193,192, 6,193,
- 192, 63,193,240, 6,193,192, 6,193,192, 6,193,
- 192, 6,193,192, 6,193,192, 6,193,192,202, 0,
- 15,196, 0, 1,128, 1,128, 1,128, 3,193,248,
- 6, 56, 12, 24, 12, 0, 12, 0, 6, 0, 3,193,
- 224, 0, 48, 0, 24, 0,195, 24, 28, 48, 31,193,
- 224, 1,128, 1,128, 1,128, 1,128,198, 0, 15,
- 198, 0, 15, 0, 25,128, 48,193,192, 48,193,192,
- 48,193,192, 25,128, 15, 60, 1,193,224, 15, 0,
- 120,193,240, 1,152, 3, 12, 3, 12, 3, 12, 1,
- 152, 0,193,240,204, 0, 15,204, 0, 7,193,224,
- 13,193,192, 12, 0, 12, 0, 6, 0, 14, 0, 27,
- 112, 51, 96, 49,193,192, 48,193,192, 48,193,224,
- 25,193,224, 15, 56,204, 0, 15,200, 0, 3,193,
- 192, 3,193,192, 7,128, 7, 0, 14, 0, 14,223,
- 0, 15,199, 0, 48, 0, 96, 0, 96, 0,193,192,
- 0,193,192, 0,193,192, 1,128, 1,128, 1,128,
- 1,128, 1,128, 1,128, 1,128, 0,193,192, 0,
- 193,192, 0,193,192, 0, 96, 0, 96, 0, 48,198,
- 0, 15,198, 0, 24, 0, 12, 0, 12, 0, 6, 0,
- 6, 0, 6, 0, 3, 0, 3, 0, 3, 0, 3, 0,
- 3, 0, 3, 0, 3, 0, 6, 0, 6, 0, 6, 0,
- 12, 0, 12, 0, 24,199, 0, 15,198, 0, 1,128,
- 1,128, 1,128, 29,184, 15,193,240, 3,193,192,
- 7,193,224, 14,112, 28, 56,218, 0, 15,202, 0,
- 1,128, 1,128, 1,128, 1,128, 1,128, 1,128,
- 63,193,252, 1,128, 1,128, 1,128, 1,128, 1,
- 128, 1,128,206, 0, 15,224, 0, 3,193,192, 3,
- 193,192, 7,128, 7, 0, 14, 0, 12,199, 0, 15,
- 214, 0, 63,193,252,218, 0, 15,224, 0, 3,193,
- 192, 3,193,192, 3,193,192,204, 0, 15,199, 0,
- 24, 0, 24, 0, 48, 0, 48, 0, 96, 0, 96, 0,
- 193,192, 0,193,192, 1,128, 1,128, 3, 0, 3,
- 0, 6, 0, 6, 0, 12, 0, 12, 0, 24, 0, 24,
- 201, 0, 15,198, 0, 3,193,192, 14,112, 12, 48,
- 212, 24, 12, 48, 14,112, 3,193,192,204, 0, 15,
- 198, 0, 3,128, 31,128, 1,128, 1,128, 1,128,
- 1,128, 1,128, 1,128, 1,128, 1,128, 1,128,
- 1,128, 1,128, 1,128, 1,128, 31,193,248,204,
- 0, 15,198, 0, 7,128, 28,193,224,196, 48, 0,
- 48, 0, 48, 0, 96, 0, 96, 0,193,192, 1,128,
- 3, 0, 6, 0, 12, 0, 24, 0,194, 48, 63,193,
- 240,204, 0, 15,198, 0, 3,193,224, 14, 48,194,
- 24, 0, 24, 0, 24, 0, 48, 0, 96, 3,193,192,
- 0, 96, 0, 48, 0, 24, 0, 24, 0, 24, 48, 24,
- 28, 48, 7,193,224,204, 0, 15,198, 0, 1,193,
- 224, 1,193,224, 3, 96, 3, 96, 6, 96, 6, 96,
- 12, 96, 12, 96, 24, 96, 24, 96, 48, 96, 63,193,
- 240, 0, 96, 0, 96, 0, 96, 1,193,240,204, 0,
- 15,198, 0, 31,193,240, 24, 0, 24, 0, 24, 0,
- 24, 0, 24, 0, 31,193,192, 28,112, 0, 48, 0,
- 24, 0, 24, 0, 24, 0, 24, 0, 48, 56,112, 15,
- 193,192,204, 0, 15,199, 0,193,248, 3,128, 6,
- 0, 12, 0, 12, 0, 24, 0, 24, 0, 27,193,224,
- 30, 48, 28,199, 24, 12, 24, 14, 48, 3,193,224,
- 204, 0, 15,198, 0, 63,193,240,196, 48, 0, 96,
- 0, 96, 0, 96, 0,193,192, 0,193,192, 0,193,
- 192, 0,193,192, 1,128, 1,128, 1,128, 3, 0,
- 3, 0, 3,205, 0, 15,198, 0, 7,193,192, 28,
- 112, 24,194, 48, 24, 48,194, 24, 48, 28,112, 7,
- 193,192, 28,112, 24,194, 48, 24, 48, 24, 48,194,
- 24, 48, 28,112, 7,193,192,204, 0, 15,198, 0,
- 3,193,192, 14, 96, 12, 48,200, 24, 12, 56, 14,
- 120, 3,193,216, 0, 24, 0, 24, 0, 48, 0, 48,
- 0,193,224, 31,128,204, 0, 15,208, 0, 3,193,
- 192, 3,193,192, 3,193,192,202, 0, 3,193,192,
- 3,193,192, 3,193,192,204, 0, 15,208, 0, 3,
- 193,192, 3,193,192, 3,193,192,202, 0, 3,193,
- 192, 3,193,192, 7,128, 7, 0, 14, 0, 12,199,
- 0, 15,205, 0, 60, 0,193,240, 3,193,192, 15,
- 0, 60, 0,112, 0, 60, 0, 15, 0, 3,193,192,
- 0,193,240, 0, 60,208, 0, 15,212, 0,127,193,
- 252,196, 0,127,193,252,214, 0, 15,204, 0,120,
- 0, 30, 0, 7,128, 1,193,224, 0,120, 0, 28,
- 0,120, 1,193,224, 7,128, 30, 0,120,209, 0,
- 15,202, 0, 15,193,192, 24, 96, 24, 48, 0, 48,
- 0, 48, 0, 48, 0, 96, 1,193,192, 3, 0, 3,
- 197, 0, 3,128, 3,128,204, 0, 15,198, 0, 7,
- 193,192, 28, 96, 24,198, 48,193,240, 49,176, 51,
- 48, 51, 48, 51, 48, 51, 48, 49,176, 48,193,248,
- 48, 0, 48, 0, 24, 0, 28,112, 7,193,224,200,
- 0, 15,202, 0, 31,193,192, 3,193,192, 6, 96,
- 6, 96, 6, 96, 12, 48, 12, 48, 12, 48, 31,193,
- 248,196, 24, 48, 12, 48, 12,124, 62,204, 0, 15,
- 202, 0,127,193,240,195, 24, 12, 24, 12, 24, 12,
- 194, 24, 31,193,240,195, 24, 12, 24, 12, 24, 12,
- 24, 12,194, 24,127,193,240,204, 0, 15,202, 0,
- 3,193,236, 14, 60,194, 28, 24, 12, 48, 0, 48,
- 0, 48, 0, 48, 0, 48, 0, 48, 0, 24, 12,194,
- 28, 14, 56, 3,193,224,204, 0, 15,202, 0,127,
- 193,224, 48, 56, 48, 24, 48, 12, 48, 12, 48, 12,
- 48, 12, 48, 12, 48, 12, 48, 12, 48, 12, 48, 24,
- 48, 56,127,193,224,204, 0, 15,202, 0,127,193,
- 248,198, 24, 25,128, 25,128, 31,128, 25,128, 25,
- 128, 24, 12, 24, 12, 24, 12, 24, 12,127,193,252,
- 204, 0, 15,202, 0, 63,193,252,199, 12,193,192,
- 12,193,192, 15,193,192, 12,193,192, 12,193,192,
- 12, 0, 12, 0, 12, 0, 12, 0, 63,193,192,204,
- 0, 15,202, 0, 7,193,216, 28,120,194, 56, 48,
- 24, 96, 0, 96, 0, 96, 0, 96, 0, 97,193,252,
- 96, 24, 48, 24, 56, 24, 28, 48, 7,193,224,204,
- 0, 15,202, 0,194,126,202, 24, 31,193,248,204,
- 24,194,126,204, 0, 15,202, 0, 31,193,248, 1,
- 128, 1,128, 1,128, 1,128, 1,128, 1,128, 1,
- 128, 1,128, 1,128, 1,128, 1,128, 1,128, 31,
- 193,248,204, 0, 15,202, 0, 7,193,254, 0, 48,
- 0, 48, 0, 48, 0, 48, 0, 48, 0, 48, 0,200,
- 48, 96, 24,193,224, 15,128,204, 0, 15,202, 0,
- 126,124, 24, 48, 24, 96, 24,193,192, 25,128, 27,
- 0, 31,128, 29,193,192, 24,193,224, 24, 96, 24,
- 112, 24, 48, 24, 56,126, 30,204, 0, 15,202, 0,
- 127,128, 12, 0, 12, 0, 12, 0, 12, 0, 12, 0,
- 12, 0, 12, 0, 12, 0,200, 12,127,193,252,204,
- 0, 15,202, 0,120, 30, 56, 28, 56, 28,196, 60,
- 54,108, 54,108, 51,193,204, 51,193,204, 48, 12,
- 48, 12, 48, 12, 48, 12,124, 62,204, 0, 15,202,
- 0,193,248,193,254, 56, 24, 60, 24, 54, 24, 54,
- 24, 51, 24, 51, 24, 49,152, 49,152, 48,193,216,
- 48,193,216, 48,120, 48, 56,193,254, 56,204, 0,
- 15,202, 0, 7,193,192, 28,112,194, 56, 48, 24,
- 96, 12, 96, 12, 96, 12, 96, 12, 96, 12, 96, 12,
- 48, 24,194, 56, 28,112, 7,193,192,204, 0, 15,
- 202, 0, 63,193,240, 12, 24,201, 12, 24, 15,193,
- 240, 12, 0, 12, 0, 12, 0, 12, 0, 12, 0, 63,
- 193,192,204, 0, 15,202, 0, 7,193,192, 28,112,
- 194, 56, 48, 24, 96, 12, 96, 12, 96, 12, 96, 12,
- 96, 12, 96, 12, 48, 24,194, 56, 28,112, 7,193,
- 192, 7, 28, 29,193,240,200, 0, 15,202, 0,127,
- 193,224, 24, 48,201, 24, 48, 31,193,224, 24,193,
- 192, 24, 96, 24, 48, 24, 48,194, 24,126, 30,204,
- 0, 15,202, 0, 7,193,216, 28,120, 48, 56, 48,
- 24, 48, 0, 28, 0, 7,193,192, 0,112, 0, 24,
- 0, 24, 48, 24, 56, 24, 60, 48, 55,193,224,204,
- 0, 15,202, 0, 63,193,252, 49,140, 49,140, 49,
- 140, 49,140, 1,128, 1,128, 1,128, 1,128, 1,
- 128, 1,128, 1,128, 1,128, 15,193,240,204, 0,
- 15,202, 0,126,193,252, 48, 24, 48, 24, 48, 24,
- 48, 24, 48, 24, 48, 24, 48, 24, 48, 24, 48, 24,
- 48, 24, 48,194, 24, 48, 15,193,224,204, 0, 15,
- 202, 0,194,126, 48, 12, 48, 12,196, 24, 12, 48,
- 12, 48, 12, 48, 6, 96, 6, 96, 6, 96, 3,193,
- 192, 3,193,192, 1,128,204, 0, 15,202, 0,194,
- 126, 48, 12, 48, 12, 49,140, 49,140, 51,193,204,
- 51,193,204, 27,193,216, 30,120, 30,120, 30,120,
- 28, 56, 28, 56, 28, 56,204, 0, 15,202, 0,194,
- 126,194, 24, 12, 48, 12, 48, 6, 96, 6, 96, 3,
- 193,192, 1,128, 3,193,192, 6, 96, 12, 48, 12,
- 48,194, 24,194,126,204, 0, 15,202, 0,124, 62,
- 194, 24, 12, 48, 12, 48, 6, 96, 6, 96, 3,193,
- 192, 1,128, 1,128, 1,128, 1,128, 1,128, 1,
- 128, 15,193,240,204, 0, 15,202, 0, 63,193,248,
- 48, 24,195, 48, 96, 48,193,192, 0,193,192, 1,
- 128, 3, 0, 6, 0, 6, 24, 12,195, 24, 48, 24,
- 63,193,248,204, 0, 15,198, 0, 1,193,224, 1,
- 128, 1,128, 1,128, 1,128, 1,128, 1,128, 1,
- 128, 1,128, 1,128, 1,128, 1,128, 1,128, 1,
- 128, 1,128, 1,128, 1,128, 1,128, 1,193,224,
- 198, 0, 15,198, 0, 24, 0, 24, 0, 12, 0, 12,
- 0, 6, 0, 6, 0, 3, 0, 3, 0, 1,128, 1,
- 128, 0,193,192, 0,193,192, 0, 96, 0, 96, 0,
- 48, 0, 48, 0, 24, 0, 24,200, 0, 15,198, 0,
- 7,128, 1,128, 1,128, 1,128, 1,128, 1,128,
- 1,128, 1,128, 1,128, 1,128, 1,128, 1,128,
- 1,128, 1,128, 1,128, 1,128, 1,128, 1,128,
- 7,128,198, 0, 15,198, 0, 1,128, 3,193,192,
- 7,193,224, 14,112, 28,194, 56, 28, 48, 12,222,
- 0, 15,238, 0,194,255,194, 0, 15,198, 0, 14,
- 0, 7, 0, 3,128, 1,193,192,228, 0, 15,208,
- 0, 7,193,192, 28, 96, 0, 48, 0, 48, 0, 48,
- 15,193,240, 24,198, 48,112, 31,193,252,204, 0,
- 15,198, 0,120, 0, 24, 0, 24, 0, 24, 0, 24,
- 0, 27,193,240, 30,194, 28, 12, 24, 6, 24, 6,
- 24, 6, 24, 6, 24, 6, 28, 12, 30, 28,123,193,
- 240,204, 0, 15,208, 0, 7,193,248, 28, 56,194,
- 24, 48, 24, 48, 0, 48, 0, 48, 0, 48, 0, 24,
- 194, 28, 56, 7,193,224,204, 0, 15,199, 0,120,
- 0, 24, 0, 24, 0, 24, 0, 24, 15,193,216, 56,
- 120, 48, 56, 96, 24, 96, 24, 96, 24, 96, 24, 96,
- 24, 48,194, 56,120, 15,193,222,204, 0, 15,208,
- 0, 7,193,224, 28, 56,194, 24, 48, 12, 48, 12,
- 63,193,252, 48, 0, 48, 0, 24, 0,194, 28, 7,
- 193,240,204, 0, 15,199, 0,193,252, 1,128, 3,
- 0, 3, 0, 3, 0, 31,193,248, 3, 0, 3, 0,
- 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0,
- 3, 0, 31,193,248,204, 0, 15,208, 0, 15,193,
- 222, 56,120, 48, 56, 96, 24, 96, 24, 96, 24, 96,
- 24, 96, 24, 48,194, 56,120, 15,193,216, 0, 24,
- 0, 24, 0, 48, 0,112, 31,193,192,194, 0, 15,
- 198, 0,120, 0, 24, 0, 24, 0, 24, 0, 24, 0,
- 27,193,224, 30, 48, 28,207, 24,194,126,204, 0,
- 15,198, 0, 1,128, 1,128, 1,128,196, 0, 15,
- 128, 1,128, 1,128, 1,128, 1,128, 1,128, 1,
- 128, 1,128, 1,128, 1,128, 31,193,248,204, 0,
- 15,199, 0, 96, 0, 96, 0, 96,196, 0, 31,193,
- 240, 0, 48, 0, 48, 0, 48, 0, 48, 0, 48, 0,
- 48, 0, 48, 0, 48, 0, 48, 0, 48, 0, 48, 0,
- 48, 0, 96, 0,193,224, 31,128,194, 0, 15,198,
- 0, 60, 0, 12, 0, 12, 0, 12, 0, 12, 0, 12,
- 193,248, 12, 96, 12,193,192, 13,128, 15, 0, 15,
- 0, 13,128, 12,193,192, 12, 96, 12, 48, 60,124,
- 204, 0, 15,198, 0, 31,128, 1,128, 1,128, 1,
- 128, 1,128, 1,128, 1,128, 1,128, 1,128, 1,
- 128, 1,128, 1,128, 1,128, 1,128, 1,128, 63,
- 193,252,204, 0, 15,208, 0,193,255,120, 57,193,
- 204, 49,140, 49,140, 49,140, 49,140, 49,140, 49,
- 140, 49,140, 49,140,193,253,193,206,204, 0, 15,
- 208, 0,123,193,224, 30, 48, 28,207, 24,194,126,
- 204, 0, 15,208, 0, 7,193,224, 28, 56,194, 24,
- 48, 12, 48, 12, 48, 12, 48, 12, 48, 12,194, 24,
- 28, 56, 7,193,224,204, 0, 15,208, 0,123,193,
- 240, 30,194, 28, 12, 24, 6, 24, 6, 24, 6, 24,
- 6, 24, 6, 28, 12, 30, 28, 27,193,240, 24, 0,
- 24, 0, 24, 0, 24, 0,127,195, 0, 15,208, 0,
- 15,193,222, 56,120, 48, 56, 96, 24, 96, 24, 96,
- 24, 96, 24, 96, 24, 48,194, 56,120, 15,193,216,
- 0, 24, 0, 24, 0, 24, 0, 24, 0,193,254,194,
- 0, 15,208, 0, 30,120, 7,193,204, 7, 0, 6,
- 0, 6, 0, 6, 0, 6, 0, 6, 0, 6, 0, 6,
- 0, 63,193,240,204, 0, 15,208, 0, 7,193,248,
- 12, 56, 12, 24, 12, 0, 7,193,192, 0,112, 0,
- 24, 0,195, 24, 28, 48, 31,193,224,204, 0, 15,
- 200, 0, 12, 0, 12, 0, 12, 0, 12, 0, 63,193,
- 240, 12, 0, 12, 0, 12, 0, 12, 0, 12, 0, 12,
- 0, 12, 0, 12, 0, 6, 56, 3,193,224,204, 0,
- 15,208, 0,194,120,207, 24, 56, 12,120, 7,193,
- 220,204, 0, 15,208, 0,194,126,196, 24, 12, 48,
- 12, 48, 12, 48, 6, 96, 6, 96, 3,193,192, 3,
- 193,192, 1,128,204, 0, 15,208, 0,124, 62, 48,
- 12, 48, 12, 49,140, 25,152, 27,193,216, 27,193,
- 216, 27,193,216, 15,193,240, 14,112, 14,112,204,
- 0, 15,208, 0, 62,124,194, 24, 12, 48, 6, 96,
- 3,193,192, 1,128, 3,193,192, 6, 96, 12, 48,
- 194, 24, 62,124,204, 0, 15,208, 0,194,124, 48,
- 24, 48,194, 24, 48, 24, 48, 24, 96, 12, 96, 12,
- 193,192, 6,193,192, 7,128, 3,128, 3, 0, 3,
- 0, 6, 0, 6, 0,127,128,194, 0, 15,208, 0,
- 31,193,248,195, 24, 48, 0, 96, 0,193,192, 1,
- 128, 3, 0, 6, 0, 12,195, 24, 31,193,248,204,
- 0, 15,199, 0,193,224, 1,128, 1,128, 1,128,
- 1,128, 1,128, 1,128, 1,128, 1,128, 7, 0,
- 1,128, 1,128, 1,128, 1,128, 1,128, 1,128,
- 1,128, 1,128, 0,193,224,198, 0, 15,198, 0,
- 1,128, 1,128, 1,128, 1,128, 1,128, 1,128,
- 1,128, 1,128, 1,128, 1,128, 1,128, 1,128,
- 1,128, 1,128, 1,128, 1,128, 1,128, 1,128,
- 1,128,198, 0, 15,198, 0, 7, 0, 1,128, 1,
- 128, 1,128, 1,128, 1,128, 1,128, 1,128, 1,
- 128, 0,193,224, 1,128, 1,128, 1,128, 1,128,
- 1,128, 1,128, 1,128, 1,128, 7,199, 0, 15,
- 212, 0, 31, 28, 59,184,113,193,240,216, 0, 15,
- 202, 0,193,255,193,254,193,255,193,254,193,224,
- 14,193,224, 14,193,224, 14,193,224, 14,193,224,
- 14,193,224, 14,193,224, 14,193,224, 14,193,224,
- 14,193,224, 14,193,255,193,254,193,255,193,254,
- 204, 0, 15};
-
- unsigned char *fontbuffer;
- FONTINFO fontinfo;
-
- int membitfont(unsigned char info[8],unsigned char name[],int target)
- {
- int size;
- int wordcount=0;
- int x;
- int packet;
- int offset=0;
- unsigned char byte,bytecount;
-
- fontinfo.filetype[0]=info[0];
- fontinfo.filetype[1]=info[1];
- fontinfo.filetype[2]=info[2];
- fontinfo.filetype[3]=info[3];
- fontinfo.width=info[4];
- fontinfo.height=info[5];
- fontinfo.proportional=info[6];
- fontinfo.style=info[7];
-
- x=(fontinfo.width/8)+1;
- if((fontinfo.width%8)==0)x--;
- packet=(x*fontinfo.height)+1;
-
- size=packet*256 ;
- fontbuffer=malloc(size);
-
- /* unpacked */
- if(fontinfo.filetype[1]=='O')
- {
- memcpy(fontbuffer,name,size);
- return 0;
- }
-
-
- if(fontinfo.filetype[3]=='C')
- {
- offset=packet*32;
- memset(fontbuffer,0,size);
- /* for(wordcount=0;wordcount<size;wordcount+=packet)
- fontbuffer[wordcount+packet-1]=fontinfo.width; */
- }
-
- wordcount=0;
- do{ bytecount=1; /* start with a seed count */
- byte=name[wordcount];
- wordcount++;
- /* check to see if its raw */
- if(0xC0 == (0xC0 &byte)){ /* if its not, run encoded */
- bytecount= 0x3f &byte;
- byte=name[wordcount];
- wordcount++;
- }
- for(packet=0;packet<bytecount;packet++)
- {
- fontbuffer[offset]=byte;
- offset++;
- }
- }while(wordcount<target);
- return 0;
- }
-
-
- void unloadbitfont(void)
- {
- free(fontbuffer);
- }
-
-
- void egabitfont(unsigned char *str,
- int xorigin, int yorigin,unsigned colorvalue,
- char justify)
- {
- union REGS inregs, outregs;
- int x1;
- int scanline,y,byte,character,nibble;
- int target = strlen(str) ;
-
- int x,xwidth,xgap=0,xfactor;
-
- /* offset into the array */
- int yoffset,scanoffset;
- int xoffset = (fontinfo.width/8)+1;
-
- inregs.h.ah = 0x0c;
- inregs.h.al = (char )colorvalue;
- inregs.h.bh = 0;
-
- if(!(fontinfo.width%8))xoffset-=1;
- yoffset = ((fontinfo.height)*(xoffset))+1;
-
- /* strip hard returns */
- if(str[target-1]=='\n')(target-=1);
-
- /* justification */
- switch(toupper(justify))
- {
- case 'M':
- case 'C': xorigin-=(((target*fontinfo.width)/2)+xoffset);
-
- default : break;
- }
-
-
- #define BOLD 2
-
- if(fontinfo.style==BOLD)xgap++;
-
- for (scanline=0;scanline<fontinfo.height;scanline++)
- {
- y = yorigin+scanline;
- scanoffset = scanline*xoffset;
- x=0;
-
- for (byte=0;byte<target;byte++)
- {
-
- for(xfactor=0;xfactor<xoffset;xfactor++)
- {
- /* the offset into the array is constant */
- character = fontbuffer[(yoffset*str[byte])+(scanoffset+xfactor)];
-
- if (character != 0)
- for (nibble=0;nibble<8;nibble++)
- if (character & 0x80>>nibble)
- {
- x1=(xorigin+x+(xfactor*8)+nibble);
- if(x1>-1 && x1<640 && y<350)
- {
- inregs.x.cx = x1;
- inregs.x.dx = y;
- int86(0x10,&inregs,&outregs);
- }
- }
- }
- /* get the proportional spacing info */
- xwidth = fontbuffer[(yoffset*str[byte])+yoffset-1]+xgap;
- x+=xwidth;
-
- }
- }
-
- }
-
-
- int maple[]={
- 73,65,98,70,106,55,106,55,130,74,122,33,142,42,160,11,
- 178,42,198,33,190,74,214,55,222,70,247,65,241,95,253,102,
- 208,139,217,157,165,151,165,187,155,187,155,151,103,157,
- 112,139,67,102,79,95,73,65,-1,-2};
-
-
- int cga2ega(int *PIX,unsigned color)
- {
- /* illustrates integer conversion of screen coordinates from */
- /* CGA MED RES graphics mode to 640 x 350 EGA mode */
-
- int X=0,Y=1,true=X,done=Y;
- int newx,oldx,newy,oldy;
-
- drawstart:;
-
- /* conversion from 320 x 200 to 640 x 350 */
- oldx= PIX[X]<<1; /* use a ratio 320 to 640 for the x dimn */
- oldy=(PIX[Y]*7)/4; /* use a ratio of 350 to 200 for the y dimn */
-
- while(done!=true)
- {
- X=X+2 ; Y=Y+2;
- if(PIX[X]!=(-1)){
- newx=PIX[X]<<1;
- newy=(PIX[Y]*7)/4;
- writeline(oldx,oldy,newx,newy,color);
- oldx=newx;
- oldy=newy;
- }
- else(done=true);
- }
- true = 0; done = 1;
- if (PIX[X]==PIX[Y]){ X=X+2;Y=Y+2;
- goto drawstart;
- }
-
-
- }
-
-
-
-
-
- void titleblock()
- {
- flood(BLUE); /* flood dark blue */
- linebox(0,0,639,349,LRED); /* draw a red box */
- cga2ega(maple,LRED);
-
- egabitfont("EGXSHOW(C) by Bill Buckels",319,120,BWHITE,'M');
- egatextM("Copyright 1991",319,150,BWHITE);
- egatextM("Correspondence can Be Sent To:",319,170,CYAN);
- egatextM("Bill Buckels",319,190,BWHITE);
- egatextM("982 Hector Ave.",319,200,BWHITE);
- egatextM("Winnipeg, Manitoba, Canada",319,210,BWHITE);
-
-
- egatextM("one moment please... setting up!",319,8,LCYAN);
- egatextM("**** PRESS ESCAPE TO EXIT WHEN DONE ****",319,332,YELLOW);
-
- }
-
- /* type conversion function */
- unsigned int byteword(unsigned char a, unsigned char b){return b<<8|a;}
- unsigned char pcxheader[128];
- int checkforpcx(unsigned char *pcxheader)
- {
- unsigned int zsoft,codetype,pixbits;
- unsigned int xmin, ymin, xmax, ymax;
- unsigned int no_planes, bytesperline;
- int invalid = -1, valid = 0, status=valid;
-
- /* read the file header */
-
- zsoft =pcxheader[0];
- codetype=pcxheader[2];
- pixbits =pcxheader[3];
-
- if(zsoft!=10) status = invalid;
- if(codetype!=1) status = invalid;
- if(pixbits !=1) status = invalid;
-
- xmin=byteword(pcxheader[4],pcxheader[5]);
- ymin=byteword(pcxheader[6],pcxheader[7]);
- xmax=byteword(pcxheader[8],pcxheader[9]);
- ymax=byteword(pcxheader[10],pcxheader[11]);
- no_planes =pcxheader[65];
- bytesperline=byteword(pcxheader[66],pcxheader[67]);
-
-
- if(xmin != 0 ) status = invalid;
- if(ymin != 0 ) status = invalid;
- if(xmax != 639) status = invalid;
- if(ymax != 349) status = invalid;
- if(no_planes!=4) status = invalid;
- if(bytesperline !=80)status = invalid;
- return status;
-
- }
-
- char indexmap[]={ 1,2,4,8};
- void index_set(indexval)
- {
- outp(0x3c4,2);
- outp(0x3c5,indexmap[indexval]);
- }
-
- char far *packbuffer[2],*rawbuffer[2];
-
- int egaread(char *name)
- {
-
- unsigned count1,count2;
-
- unsigned long byteoff;
- unsigned int packet;
- unsigned char byte,bytecount;
- unsigned int temp;
- int safety;
- char far *ptr,*ptr2;
-
-
-
- int fh;
-
- if((fh = open(name,O_RDONLY|O_BINARY))==-1)return -1;
-
- read(fh,pcxheader,128);
- if(checkforpcx(pcxheader)!=0)
- {
- close(fh);
- return -1;
- }
-
- ptr=(char far *)&packbuffer[0][0];
- ptr2=(char far *)&rawbuffer[0][0];
-
- if(read(fh,packbuffer[0],(unsigned)56000)==(unsigned)56000)
- read(fh,packbuffer[1],(unsigned)56000);
- close(fh);
-
- temp=0;
- byteoff=0;
- safety=0;
-
- count1=0;
- count2=0;
-
- do{ bytecount=1; /* start with a seed count */
- byte=ptr[count1];
- count1++;
-
- if(count1==56000)
- {
- count1=0;
- ptr=(char far *)&packbuffer[1][0];
- }
- /* check to see if its raw */
- if(0xC0 == (0xC0 &byte)){ /* if its not, run encoded */
- bytecount= 0x3f &byte;
- byte=ptr[count1];
- count1++;
- if(count1==56000)
- {
- count1=0;
- ptr=(char far *)&packbuffer[1][0];
- }
- }
-
- switch(temp)
- {
- case 320: temp=0;
- case 0 :
- case 80 :
- case 160:
- case 240:
- safety=0;
- }
-
- for(packet=0;packet<bytecount;packet++){
- ptr2[count2]=byte;
- count2++;
- if(count2==56000)
- {
- count2=0;
- ptr2=(char far *)&rawbuffer[1][0];
- }
- byteoff++;
- safety++;
- temp++;
- if(safety>79)packet=bytecount;
- }
- }while(byteoff<112000l);
- return 0;
- }
-
- /* scroll window to clear screen */
- void egashow()
- {
- unsigned ctr=0;
- unsigned count2=0;
-
- char far *crtptr;
- char far *bufptr;
- char *ptr;
-
- int i,j;
-
- /* to clear between pictures use flood */
- /* then set palette here */
- /* flood(0); */
-
- bufptr=(char far *)&rawbuffer[0][0];
-
- for(i=0;i<350;i++)
- {
- crtptr=(char *)0xa0000000l+ctr;
- ctr+=80;
- for(j=0;j<4;j++)
- {
- index_set(j);
- memcpy(crtptr,&bufptr[count2],80);
- count2+=80;
- if(count2==56000)
- {
- count2=0;
- bufptr=(char far *)&rawbuffer[1][0];
- }
- }
- }
-
- ptr=(char *)&pcxheader[16];
- rgb2ega(ptr);
- setegapalette();
-
-
- }
-
-
- void (interrupt _far *int1C)();
- unsigned ticker=0;
- void interrupt timertick(void)
- {
-
- ticker++;
- int1C();
- }
-
-
- main(int argc, char **argv)
- {
- unsigned target=56000;
- FILE *fp;
- char buffer[66];
- char buffer2[66];
- int DONE =0, status=0;
- char *wordptr;
- char c;
- float fseconds;
- unsigned timeout;
-
- membitfont(COUR24Bheader,COUR24Bfont,sizeof(COUR24Bfont));
- if( (packbuffer[0]=malloc(target))==NULL)
- {
- puts("Not enough memory...");
- exit(0);
- }
-
- if( (packbuffer[1]=malloc(target))==NULL)
- {
- puts("Not enough memory...");
- exit(0);
- }
-
- if( (rawbuffer[0]=malloc(target))==NULL)
- {
- puts("Not enough memory...");
- exit(0);
- }
- if( (rawbuffer[1]=malloc(target))==NULL)
- {
- puts("Not enough memory...");
- exit(0);
- }
-
-
-
-
- if((fp=fopen(argv[1],"r"))!=NULL)
- {
- if(setcrtmode(EGA)!=EGA)
- {
- puts("Sorry... EGA adapter required.");
- fclose(fp);
- exit(0);
- }
-
-
- if(argc==3 && atoi(argv[2])>0)
- {
- fseconds=(float)18.2*atoi(argv[2]);
- }
- else
- fseconds=(float)18.2*3;
-
- timeout=(unsigned )fseconds;
-
-
- _disable();
- int1C= _dos_getvect(0x1C);
- _dos_setvect(0x1C, timertick);
- _enable();
-
- titleblock();
- fgets(buffer,66,fp);
- wordptr=strtok(buffer,". \n");
- sprintf(buffer2,"%s.PCX",buffer);
- egaread(buffer2);
-
- while(!DONE)
- {
- egashow();
-
- if(fgets(buffer,66,fp)==NULL)
- {
- rewind(fp);
- fgets(buffer,66,fp);
- }
-
-
- ticker=0;
- if(kbhit())if((c=getch())==27)DONE++;
-
- if(!DONE)
- {
- wordptr=strtok(buffer,". \n");
- sprintf(buffer2,"%s.PCX",buffer);
- egaread(buffer2);
- }
-
- if(!DONE)
- {
- while(ticker<timeout)
- {
- if(kbhit())
- {
- ticker=timeout;
- if((c=getch())==27)DONE++;
- if(c==0)getch();
- }
- }
- }
- }
-
- setcrtmode(TEXT);
-
- /* repair the timer tick */
- _disable();
- _dos_setvect(0x1C, int1C);
- _enable();
-
- fclose(fp);
-
- }
- else
- {
- printf("EGXSHOW(C) Copyright by Bill Buckels 1991\n");
- printf("Usage is \"EGXSHOW [scriptname] [time-seconds]\"\n");
- }
-
- free(packbuffer[0]);
- free(packbuffer[1]);
- free(rawbuffer[0]);
- free(rawbuffer[1]);
- unloadbitfont();
- exit(0);
-
- }
-
-
-
-