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 >
Wrap
C/C++ Source or Header
|
1997-09-22
|
11KB
|
271 lines
////////////////////
// VESA interface //
////////////////////
#ifndef __IVESA_H
#define __IVESA_H
#include "isoft.h"
#include "block.h"
#include "dpmi.h"
#include "far.h"
#include "near.h"
class IVESA : public ISoftware
{
public:
#ifndef __VESA__
// dummy constructor
IVESA(HWINDOW window=NULL) {};
#else
// setup
IVESA(HWINDOW window=NULL);
virtual ~IVESA();
// interface information
virtual INFO GetInfo();
virtual int GetModeList(List<MODE> &modelist);
// display mode routines
virtual int SetMode(MODE const &info);
virtual int SetMode(int x,int y,int id,int layout,int output,int frequency);
virtual int SetMode(int x,int y,FORMAT const &format,int layout,int output,int frequency);
virtual int QueryMode(MODE const &info);
virtual int QueryMode(int x,int y,int id,int layout,int output,int frequency);
virtual int QueryMode(int x,int y,FORMAT const &format,int layout,int output,int frequency);
virtual MODE GetMode();
// palette routines
virtual int SetPalette(Palette &palette);
virtual int GetPalette(Palette &palette);
// hardware functions
virtual int WaitForRetrace();
virtual int SaveState();
virtual int RestoreState();
// primary surface operations
virtual int SetPrimary(Surface &surface);
virtual Surface* GetPrimary();
virtual int SetOrigin(int x,int y);
virtual int GetOrigin(int &x,int &y);
// video memory management
virtual int GetTotalVideoMemory();
virtual int GetFreeVideoMemory();
virtual int CompactVideoMemory();
// console routines
virtual int getch();
virtual int kbhit();
virtual int keydown(int key);
// native access
virtual void* GetNative();
virtual int NativeType();
// data access
virtual void GetName(char name[]) const;
virtual int GetXResolution() const;
virtual int GetYResolution() const;
virtual int GetBitsPerPixel() const;
virtual int GetBytesPerPixel() const;
virtual int GetLayout() const;
virtual int GetOutput() const;
virtual int GetFrequency() const;
virtual FORMAT GetFormat() const;
virtual HWINDOW GetWindow() const;
// object state
virtual int ok() const;
protected:
// surface management
virtual HSURFACE RequestSurface(Surface &owner,int x,int y,FORMAT const &format,int type,int layout,int advance);
virtual void FreeSurface(HSURFACE handle);
virtual void* LockSurface(HSURFACE handle,int wait);
virtual void UnlockSurface(HSURFACE handle);
virtual int GetSurfaceLockCount(HSURFACE handle);
virtual int RestoreSurface(HSURFACE handle);
virtual SURFACEINFO GetSurfaceInfo(HSURFACE handle);
virtual void SetOwnerSurface(HSURFACE handle,Surface *owner);
// surface update
virtual int Update(Surface &src,void *extra);
virtual int Update(Surface &src,RECTANGLE const &rect,void *extra);
virtual int Update(Surface &src,RECTANGLE const &dest_rect,RECTANGLE const &src_rect,void *extra);
private:
// VBE information block
#pragma pack(1)
struct VBEINFO
{
char VESASignature[4] PACKED; // 'VESA' 4 byte signature
short Version PACKED; // VBE version number
long OemStringPtr PACKED; // Pointer to OEM string
long Capabilities PACKED; // Capabilities of video card
long VideoModePtr PACKED; // Pointer to supported modes
short TotalMemory PACKED; // Number of 64kb memory blocks
// VBE 2.0 extensions
short OemSoftwareRev PACKED; // OEM Software revision number
long OemVendorNamePtr PACKED; // Pointer to Vendor Name string
long OemProductNamePtr PACKED; // Pointer to Product Name string
long OemProductRevPtr PACKED; // Pointer to Product Revision str
char reserved[222] PACKED; // Pad to 256 byte block size
char OemDATA[256] PACKED; // Scratch pad for OEM data
};
// VESA mode information block
struct MODEINFO
{
short ModeAttributes PACKED; // Mode attributes
char WinAAttributes PACKED; // Window A attributes
char WinBAttributes PACKED; // Window B attributes
short WinGranularity PACKED; // Window granularity in k
short WinSize PACKED; // Window size in k
short WinASegment PACKED; // Window A segment
short WinBSegment PACKED; // Window B segment
long WinFuncPtr PACKED; // Pointer to window function
short BytesPerScanLine PACKED; // Bytes per scanline
short XResolution PACKED; // Horizontal resolution
short YResolution PACKED; // Vertical resolution
char XCharSize PACKED; // Character cell width
char YCharSize PACKED; // Character cell height
char NumberOfPlanes PACKED; // Number of memory planes
char BitsPerPixel PACKED; // Bits per pixel
char NumberOfBanks PACKED; // Number of CGA style banks
char MemoryModel PACKED; // Memory model type
char BankSize PACKED; // Size of CGA style banks
char NumberOfImagePages PACKED; // Number of images pages
char reserved1 PACKED; // Reserved
char RedMaskSize PACKED; // Size of direct color red mask
char RedFieldPosition PACKED; // Bit posn of lsb of red mask
char GreenMaskSize PACKED; // Size of direct color green mask
char GreenFieldPosition PACKED; // Bit posn of lsb of green mask
char BlueMaskSize PACKED; // Size of direct color blue mask
char BlueFieldPosition PACKED; // Bit posn of lsb of blue mask
char AlphaMaskSize PACKED; // Size of direct color alpha mask
char AlphaFieldPosition PACKED; // Bit posn of lsb of alpha mask
char DirectColorModeInfo PACKED; // Direct color mode attributes
// VBE 2.0 extensions
long PhysBasePtr PACKED; // Physical address for linear buf
long OffScreenMemOffset PACKED; // Pointer to start of offscreen mem
short OffScreenMemSize PACKED; // Amount of offscreen mem in 1K's
char reserved2[206] PACKED; // Pad to 256 byte block size
};
#pragma pack()
// mode attributes constants
enum MODEATTRIBS { ModeAvailable = 0x0001, // Mode is available
ModeColor = 0x0008, // Mode is a color video mode
ModeGraphics = 0x0010, // Mode is a graphics mode
ModeNonBanked = 0x0040, // Banked mode is not supported
ModeLinear = 0x0080}; // Linear mode supported
// internal mode setting
int SetMode(int mode);
int SetMode(int x,int y,int bits,int layout);
int SetMode(int x,int y,FORMAT const &format,int layout);
int SetGREY8(int x,int y,int layout);
int SetRGB332(int x,int y,int layout);
// mode number retrieval
int GetModeNumber(i