📄 vesa.h
字号:
#ifndef VESA_H
#define VESA_H
#include "dos_mem.h"
const int VESA_CONTROLLER_INFO = 0x4f00;
const int VESA_MODE_INFO = 0x4f01;
const int VESA_SET_MODE = 0x4f02;
const int VESA_GET_MODE = 0x4f03;
const int VIDEO_INT_NUM = 0x10;
const int VESA_PASS = 0x1;
const int VESA_FAIL = 0x0;
const int MAX_VESA_MODES = 64;
typedef struct
{
WORD mode_number;
WORD width;
WORD height;
WORD bpp;
}VESA_MODE_LIST;
typedef struct _VbeInfoBlock
{
BYTE VbeSignature[4]; // VBE Signature
WORD VbeVersion; // VBE Version
DWORD OemStringPtr; // Pointer to OEM String
BYTE Capabilites[4]; // Capabilites of graphics cont.
DWORD VideoModePtr; // Pointer to Video Mode List
WORD TotalMemory; // Number of 64 kb memory blocks
WORD OemSoftwareRev; // VBE implementation Software revision
DWORD OemVendorNamePtr; // VbeFarPtr to Vendor Name String
DWORD OemProductNamePtr; // VbeFarPtr to Product Name String
DWORD OemProductRevPtr; // VbeFarPtr to Product Revision String
BYTE Reserved[222]; // Reserved for VBE implementation sratch area
BYTE OemData[256]; // Data Area for OEM Strings
} VbeInfoBlock;
typedef struct _VESA_MODE_INFO_BLOCK
{
// Mandatory information for all VBE revisions
WORD ModeAttributes; // mode attributes
BYTE WinAAttributes; // window A attributes
BYTE WinBAttributes; // window B attributes
WORD WinGranularity; // window granularity
WORD WinSize; // window size
WORD WinASegment; // window A start segment
WORD WinBSegment; // window B start segment
DWORD WinFuncPtr; // real mode pointer to window function
WORD BytesPerScanLine; // bytes per scan line
// Mandatory information for VBE 1.2 and above
WORD XResolution; // horisontal resolution in pixels or characters
WORD YResolution; // vertical resolution in pixels or characters
BYTE XCharSize; // character cell width in pixels
BYTE YCharSize; // character cell height in pixels
BYTE NumberOfPlanes; // number of memeory planes
BYTE BitsPerPixel; // bits per pixel
BYTE NumberOfBanks; // number of banks
BYTE MemoryModel; // memory model type
BYTE BankSize; // bank size in KB
BYTE NumberOfImagePages; // number of images
BYTE Reserved; // reserved for page function
// Direct Color fields (required/6 and YUV memory models)
BYTE RedMaskSize; // size of direct color red mask in bits
BYTE RedFieldPosition; // bit position of lsb of red mask
BYTE GreenMaskSize; // size of direct color green mask in bits
BYTE GreenFieldPosition; // bit position of lsb of green mask
BYTE BlueMaskSize; // size of direct color blue mask in bits
BYTE BlueFieldPosition; // bit position of lsb of blue mask
BYTE RsvdMaskSize; // size of direct color reserved mask in bit
BYTE RsvdFieldPosition; // bit position of lsb of reserved mask
BYTE DirectColorModeInfo; // direct color mode attributes
// Mandatory information for VBE 2.0 and above
DWORD PhysBasePtr; // phisical address for flat memory frame buffer
DWORD Reserved1; // Reserved - always set to 0
WORD Reserved2; // Reserved - always set to 0
// Mandatory information for VBE 3.0 and above
WORD LinBytesPerScanLine; // bytes per scan line for linear modes
BYTE BnkNumberOfImagePages; // number of images for banked modes
BYTE LinNumberOfImagePages; // number of images for linear modes
BYTE LinRedMaskSize; // size of direct color red mask (linear modes)
BYTE LinRedFieldPosition; // bit position of lsb of red mask (linear modes)
BYTE LinGreenMaskSize; // size of direct color green mask (linear modes)
BYTE LinGreenFieldPosition; // bit position of lsb of green mask (linear modes)
BYTE LinBlueMaskSize; // size of direct color blue mask (linear modes)
BYTE LinBlueFieldPosition; // bit position of lsb of blue mask (linear modes)
BYTE LinRsvdMaskSize; // size of direct color reserved mask (linear modes)
BYTE LinRsvdFieldPosition; // bit position of lsb of reserved mask (linear modes)
DWORD MaxPixelClock; // maximum pixel clock (in Hz) for graphics mode
BYTE Reserved3[189]; // remainder of ModeInfoBlock
}VESA_MODE_INFO_BLOCK;
class VIDEO_VESA
{
private:
DOS_MEM info_block;
BOOL vesa20_support;
int mode_list_length;
VESA_MODE_LIST mode_list[MAX_VESA_MODES];
BYTE* addr;
BYTE* virt_addr;
int GetControllerInfo(void);
void ReadModeList(void);
int FindMode(int width, int height, int bpp);
public:
VIDEO_VESA(void);
~VIDEO_VESA(void);
float GetVersion(void);
int GetModeInfo(int mode, VESA_MODE_INFO_BLOCK *vmib);
int GetMode(void);
int SetMode(int mode);
int SetMode(int width, int height, int bpp);
DWORD GetVideoBuffer(void);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -