home *** CD-ROM | disk | FTP | other *** search
/ Computer Panoráma / computer_panorama_1997-12-hibas.iso / SHARE / GRAPH / PTC051.ZIP / SRC / IVESA.H < prev    next >
C/C++ Source or Header  |  1997-09-22  |  11KB  |  271 lines

  1. ////////////////////
  2. // VESA interface //
  3. ////////////////////
  4.  
  5. #ifndef __IVESA_H
  6. #define __IVESA_H
  7.  
  8. #include "isoft.h"
  9. #include "block.h"
  10. #include "dpmi.h"
  11. #include "far.h"
  12. #include "near.h"
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. class IVESA : public ISoftware
  22. {
  23.     public:
  24.  
  25. #ifndef __VESA__
  26.  
  27.         // dummy constructor
  28.         IVESA(HWINDOW window=NULL) {};
  29. #else
  30.  
  31.         // setup
  32.         IVESA(HWINDOW window=NULL);
  33.         virtual ~IVESA();
  34.  
  35.         // interface information
  36.         virtual INFO GetInfo();
  37.         virtual int GetModeList(List<MODE> &modelist);
  38.  
  39.         // display mode routines
  40.         virtual int SetMode(MODE const &info);
  41.         virtual int SetMode(int x,int y,int id,int layout,int output,int frequency);
  42.         virtual int SetMode(int x,int y,FORMAT const &format,int layout,int output,int frequency);
  43.         virtual int QueryMode(MODE const &info);
  44.         virtual int QueryMode(int x,int y,int id,int layout,int output,int frequency);
  45.         virtual int QueryMode(int x,int y,FORMAT const &format,int layout,int output,int frequency);
  46.         virtual MODE GetMode();
  47.  
  48.         // palette routines
  49.         virtual int SetPalette(Palette &palette);
  50.         virtual int GetPalette(Palette &palette);
  51.         
  52.         // hardware functions
  53.         virtual int WaitForRetrace();
  54.         virtual int SaveState();
  55.         virtual int RestoreState();
  56.         
  57.         // primary surface operations
  58.         virtual int SetPrimary(Surface &surface);
  59.         virtual Surface* GetPrimary();
  60.         virtual int SetOrigin(int x,int y);
  61.         virtual int GetOrigin(int &x,int &y);
  62.  
  63.         // video memory management
  64.         virtual int GetTotalVideoMemory();
  65.         virtual int GetFreeVideoMemory();
  66.         virtual int CompactVideoMemory();
  67.  
  68.         // console routines
  69.         virtual int getch();
  70.         virtual int kbhit();
  71.         virtual int keydown(int key);
  72.  
  73.         // native access
  74.         virtual void* GetNative();
  75.         virtual int NativeType();
  76.  
  77.         // data access
  78.         virtual void GetName(char name[]) const;
  79.         virtual int GetXResolution() const;
  80.         virtual int GetYResolution() const;
  81.         virtual int GetBitsPerPixel() const;
  82.         virtual int GetBytesPerPixel() const;
  83.         virtual int GetLayout() const;
  84.         virtual int GetOutput() const;
  85.         virtual int GetFrequency() const;
  86.         virtual FORMAT GetFormat() const;
  87.         virtual HWINDOW GetWindow() const;
  88.  
  89.         // object state 
  90.         virtual int ok() const;       
  91.  
  92.     protected:
  93.         
  94.         // surface management
  95.         virtual HSURFACE RequestSurface(Surface &owner,int x,int y,FORMAT const &format,int type,int layout,int advance);
  96.         virtual void FreeSurface(HSURFACE handle);
  97.         virtual void* LockSurface(HSURFACE handle,int wait);
  98.         virtual void UnlockSurface(HSURFACE handle);
  99.         virtual int GetSurfaceLockCount(HSURFACE handle);
  100.         virtual int RestoreSurface(HSURFACE handle);
  101.         virtual SURFACEINFO GetSurfaceInfo(HSURFACE handle);
  102.         virtual void SetOwnerSurface(HSURFACE handle,Surface *owner);
  103.         
  104.         // surface update
  105.         virtual int Update(Surface &src,void *extra);
  106.         virtual int Update(Surface &src,RECTANGLE const &rect,void *extra);
  107.         virtual int Update(Surface &src,RECTANGLE const &dest_rect,RECTANGLE const &src_rect,void *extra);
  108.  
  109.     private:
  110.  
  111.         // VBE information block
  112.         #pragma pack(1)
  113.         struct VBEINFO
  114.         {
  115.             char    VESASignature[4]     PACKED;    // 'VESA' 4 byte signature
  116.             short   Version              PACKED;    // VBE version number
  117.             long    OemStringPtr         PACKED;    // Pointer to OEM string
  118.             long    Capabilities         PACKED;    // Capabilities of video card
  119.             long    VideoModePtr         PACKED;    // Pointer to supported modes
  120.             short   TotalMemory          PACKED;    // Number of 64kb memory blocks
  121.             // VBE 2.0 extensions
  122.             short   OemSoftwareRev       PACKED;    // OEM Software revision number
  123.             long    OemVendorNamePtr     PACKED;    // Pointer to Vendor Name string
  124.             long    OemProductNamePtr    PACKED;    // Pointer to Product Name string
  125.             long    OemProductRevPtr     PACKED;    // Pointer to Product Revision str
  126.             char    reserved[222]        PACKED;    // Pad to 256 byte block size
  127.             char    OemDATA[256]         PACKED;    // Scratch pad for OEM data
  128.         };
  129.  
  130.         // VESA mode information block
  131.         struct MODEINFO
  132.         {
  133.             short   ModeAttributes       PACKED;    // Mode attributes
  134.             char    WinAAttributes       PACKED;    // Window A attributes
  135.             char    WinBAttributes       PACKED;    // Window B attributes
  136.             short   WinGranularity       PACKED;    // Window granularity in k
  137.             short   WinSize              PACKED;    // Window size in k
  138.             short   WinASegment          PACKED;    // Window A segment
  139.             short   WinBSegment          PACKED;    // Window B segment
  140.             long    WinFuncPtr           PACKED;    // Pointer to window function
  141.             short   BytesPerScanLine     PACKED;    // Bytes per scanline
  142.             short   XResolution          PACKED;    // Horizontal resolution
  143.             short   YResolution          PACKED;    // Vertical resolution
  144.             char    XCharSize            PACKED;    // Character cell width
  145.             char    YCharSize            PACKED;    // Character cell height
  146.             char    NumberOfPlanes       PACKED;    // Number of memory planes
  147.             char    BitsPerPixel         PACKED;    // Bits per pixel
  148.             char    NumberOfBanks        PACKED;    // Number of CGA style banks
  149.             char    MemoryModel          PACKED;    // Memory model type
  150.             char    BankSize             PACKED;    // Size of CGA style banks
  151.             char    NumberOfImagePages   PACKED;    // Number of images pages
  152.             char    reserved1            PACKED;    // Reserved
  153.             char    RedMaskSize          PACKED;    // Size of direct color red mask
  154.             char    RedFieldPosition     PACKED;    // Bit posn of lsb of red mask
  155.             char    GreenMaskSize        PACKED;    // Size of direct color green mask
  156.             char    GreenFieldPosition   PACKED;    // Bit posn of lsb of green mask
  157.             char    BlueMaskSize         PACKED;    // Size of direct color blue mask
  158.             char    BlueFieldPosition    PACKED;    // Bit posn of lsb of blue mask
  159.             char    AlphaMaskSize        PACKED;    // Size of direct color alpha mask
  160.             char    AlphaFieldPosition   PACKED;    // Bit posn of lsb of alpha mask
  161.             char    DirectColorModeInfo  PACKED;    // Direct color mode attributes
  162.             // VBE 2.0 extensions
  163.             long    PhysBasePtr          PACKED;    // Physical address for linear buf
  164.             long    OffScreenMemOffset   PACKED;    // Pointer to start of offscreen mem
  165.             short   OffScreenMemSize     PACKED;    // Amount of offscreen mem in 1K's
  166.             char    reserved2[206]       PACKED;    // Pad to 256 byte block size
  167.         };
  168.         #pragma pack()
  169.  
  170.         // mode attributes constants               
  171.         enum MODEATTRIBS { ModeAvailable = 0x0001,  // Mode is available
  172.                            ModeColor     = 0x0008,  // Mode is a color video mode
  173.                            ModeGraphics  = 0x0010,  // Mode is a graphics mode
  174.                            ModeNonBanked = 0x0040,  // Banked mode is not supported
  175.                            ModeLinear    = 0x0080}; // Linear mode supported
  176.  
  177.         // internal mode setting
  178.         int SetMode(int mode);
  179.         int SetMode(int x,int y,int bits,int layout);
  180.         int SetMode(int x,int y,FORMAT const &format,int layout);
  181.         int SetGREY8(int x,int y,int layout);
  182.         int SetRGB332(int x,int y,int layout);
  183.  
  184.         // mode number retrieval
  185.         int GetModeNumber(i