home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / pascal / rehack / demosrc / gscreen.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-07  |  3.1 KB  |  100 lines

  1. //        Gscreen.hpp
  2.  
  3. #ifndef gscreen_hpp
  4. #define gscreen_hpp
  5.  
  6. #include <dos.h>
  7. #include <stdio.h>
  8.  
  9.  
  10. // ************************************************************************
  11. // this is the 128 byte header at the front of all PCX files. In 256 color
  12. // mode 0x13 the palette structure is ignored, and the palette can be found
  13. // in the last 768 bytes of the file.
  14. // ************************************************************************
  15.  
  16. struct pcx_hdr {
  17.     char Mfg;                // manufacturer, always 0xa0
  18.     char Ver;                // encoder version number
  19.     char Enc;                // encoding code, always 1
  20.     char Bpp;                // bits per pixel, 8 in mode 0x13
  21.     int     Xmin,Ymin;            // image origin, usually 0,0
  22.     int     Xmax,Ymax;            // image dimensions
  23.     int     Hres;                // horizontal resolution value
  24.     int     Vres;                // vertical resolution value
  25.     char Pal[48];            // palette (not in mode 0x13)
  26.     char Reserved;           // who knows?
  27.     char ClrPlanes;            // number of planes, 1 in mode 0x13
  28.     int     Bpl;                // bytes per line, 80 in mode 0x13
  29.     int     PalType;            // Grey or Color palette flag
  30.     char Filler[58];        // Zsoft wanted a 128 byte header
  31. };
  32.  
  33.  
  34. class Gscreen {
  35.     int mode, maxx, maxy;
  36.     char far colregs[3*256];                // Array of color register values
  37.     char far *image_ptr;
  38.     pcx_hdr *pcxh;
  39. public:
  40.     Gscreen (int=0, int=0, int=0);
  41.     ~Gscreen (void);
  42.     void setmode (int=0);
  43.     int Maxx (void) {return maxx;};
  44.     int Maxy (void) {return maxy;};
  45.     void display ();
  46.     const char far *unpackpcx (char*);
  47.     void setpalette (void);
  48.     void wait_for_vbl (void);
  49. };
  50.  
  51.  
  52. class BitMap {
  53.     const char far *image_ptr;
  54.     int maxx, maxy;
  55.     int totalx, totaly;
  56.     int blockx, blocky;
  57.     int countx, county;
  58.     int screnx, screny;
  59.     void wait_for_vbl (void);
  60. public:
  61.     BitMap (const char far *ptr) {image_ptr=ptr;}
  62.     void set (int mx, int my, int tx, int ty, int bx, int by, int cx, int cy) {
  63.         maxx=mx; maxy=my;
  64.         totalx=tx; totaly=ty;
  65.         blockx=bx; blocky=by;
  66.         countx=cx; county=cy;
  67.     }
  68.     void display (int, int, int, int);
  69.     void erase (void);
  70.     ~BitMap (void) {delete (void*)image_ptr;}
  71. };
  72.  
  73.  
  74.  
  75.  
  76. /*
  77. Interpretation:
  78.  
  79.     Mfg        : this byte is always 0x0a for a valid PCX file
  80.     Ver        : if Ver == 0 the file is from PC Paintbrush 2.5,
  81.                    Ver == 2 the file is from 2.8, and has a palette
  82.                          Ver == 3 the file is from 2.8, but has no palette
  83.                    Ver == 5 the file is from 3.0 or later
  84.    Enc        : encoding scheme, always 1
  85.    Bpp        : number of bits ber pixel (8 in mode 13h)
  86.    Xmin       : the screen x origin, usually 0
  87.     Ymin       : the screen y origin, usually 0
  88.    Xmax       : the screen max x, for example Xmin = 0, Xmax = 639
  89.    Ymax       : the screen max y, for example Ymin = 0, Ymax = 479
  90.    Hres       : the number of pixels in x, for example Hres = 640
  91.     Vres       : the number of pixels in y, for example Vres = 480
  92.     Pal[48]    : 16 3-byte palette registers, ignored in 256 color PCX's
  93.    ClrPlanes  : number of planes, _lines stored interleaved_
  94.    Bpl        : number of bytes in one line, for example, 80 in 640 mode
  95.    PalType    : 1 if palette is grey scale, 2 if full color
  96.    
  97. */
  98.  
  99.  
  100. #endif