📄 nvesa.h
字号:
/*NEO SDK V2.1.90 For DOS
Copyleft Cker Home 2003-2006.
Open Source Obey NEO_PL.TXT.
http://neo.coderlife.net
ckerhome@yahoo.com.cn
文件名称 : nvesa.h
摘 要 : 本头文件包含了NEO SDK里有关显卡硬件加速及显存、屏幕底层处理的函数、结构、全局
变量的声明及定义
当前版本 : 2.22
作 者 : 董凯
完成日期 : 2006.01.18
取代版本 : 2.21
原 作 者 : 董凯
完成日期 : 2006.01.16
*/
#ifndef __NVESA_H__
#define __NVESA_H__
#if defined NEO_color_depth_16_unused && defined NEO_color_depth_8_unused
#undef NEO_color_depth_8_unused
#undef NEO_color_depth_16_unused
#endif
#define VBE320X200X256 0X13
#define VBE640X400X256 0X100
#define VBE640X480X256 0X101
#define VBE800X600X256 0X103
#define VBE1024X768X256 0X105
#define VBE1280X1024X256 0X107
#define VBE320X200X32K 0X10D
#define VBE640X480X32K 0X110
#define VBE800X600X32K 0X113
#define VBE1024X768X32K 0X116
#define VBE1280X1024X32K 0X119
#define VBE320X200X64K 0X10E
#define VBE640X480X64K 0X111
#define VBE800X600X64K 0X114
#define VBE1024X768X64K 0X117
#define VBE1280X1024X64K 0X11A
#define SCREEN_W g_screen_h
#define SCREEN_H g_screen_v
struct vbe_info_t
{
char VESA_signature[4]; /* 'VESA' 4 byte signature */
short VBE_version; /* VBE version number */
char far *OEM_string_ptr; /* Pointer to OEM string */
long capabilities; /* Capabilities of video card */
unsigned far *video_mode_ptr; /* Pointer to supported modes */
short total_memory; /* Number of 64kb memory blocks */
char reserved[492]; /* Pad to 492 byte block size */
};
/*typedef struct CRTCInfoBlock_T
{
unsigned short horizontal_total;
unsigned short horizontal_sync_start;
unsigned short horizontal_sync_end;
unsigned short vertical_total;
unsigned short vertical_sync_start;
unsigned short vertical_sync_end;
Uint8 flags;
unsigned long pixel_clock;
unsigned short refresh_rate;
char reserved[40];
}CRTC_T;*/
typedef struct ModeInfoBlock_T
{
/* Mandatory information for all VBE revisions */
unsigned short mode_attrib; /* Mode attributes */
Uint8 win_a_attrib; /* Window A attributes */
Uint8 win_b_attrib; /* Window B attributes */
unsigned short win_granularity; /* Window granularity in k */
unsigned short win_size; /* Window size in k */
unsigned short win_a_seg; /* Window A segment */
unsigned short win_b_seg; /* Window B segment */
void (far *win_func_ptr)(void); /* Pointer to window function */
unsigned short bytes_per_scan_line; /* Bytes per scanline */
/* Mandatory information for VBE 1.2 and above */
unsigned short x_resolution; /* Horizontal resolution */
unsigned short y_resolution; /* Vertical resolution */
Uint8 x_char_size; /* Character cell width */
Uint8 y_char_size; /* Character cell height */
Uint8 number_of_planes; /* Number of memory planes */
Uint8 bits_per_pixel; /* Bits per pixel */
Uint8 number_of_banks; /* Number of CGA style banks */
Uint8 memory_model; /* Memory model type */
Uint8 bank_size; /* Size of CGA style banks */
Uint8 number_of_image_pages; /* Number of images pages */
Uint8 res1; /* Reserved */
/* Direct Color fields (required for direct/6 and YUV/7 memory models) */
Uint8 red_mask_size; /* Size of direct color red mask */
Uint8 red_field_pos; /* Bit posn of lsb of red mask */
Uint8 green_mask_size; /* Size of direct color green mask */
Uint8 green_field_pos; /* Bit posn of lsb of green mask */
Uint8 blue_mask_size; /* Size of direct color blue mask */
Uint8 blue_field_pos; /* Bit posn of lsb of blue mask */
Uint8 rsvd_mask_size; /* Size of direct color res mask */
Uint8 rsvd_field_pos; /* Bit posn of lsb of res mask */
Uint8 direct_color_mode_info; /* Direct color mode attributes */
/* Mandatory information for VBE 2.0 and above*/
void far *phys_base_ptr;
void far *res2;
unsigned short res3;
/* Mandatory information for VBE 3.0 and above*/
unsigned short bytes_per_scanline;
Uint8 bnk_num_of_imagepages;
Uint8 lin_num_of_imagepages;
Uint8 lin_red_mask_size;
Uint8 lin_red_field_pos;
Uint8 lin_green_mask_size;
Uint8 lin_green_field_pos;
Uint8 lin_blue_mask_size;
Uint8 lin_blue_field_pos;
Uint8 lin_rsvd_mask_size;
Uint8 lin_rsvd_field_pos;
void far *max_pixel_clock;
Uint8 res4[189]; /* Pad to 256 byte block size */
}mode_info_t;
typedef union
{
Uint16 color;
Uint16 c;
}RGB16;
typedef struct
{
Uint8 r;
Uint8 g;
Uint8 b;
}RGB24, RGB;
typedef struct
{
Uint8 blue;
Uint8 green;
Uint8 red;
Uint8 reserved;
}PIC_RGB;
enum MASK_COLOR
{
MASK_COLOR_8 = 0X0,
MASK_COLOR_15 = 0X7C1F,
MASK_COLOR_16 = 0XF81F,
};
/*#define MASK_COLOR_24 0XFF00FFL*/
#define TPT8 MASK_COLOR_8
#define TPT15 MASK_COLOR_15
#define TPT16 MASK_COLOR_16
enum DRAWIMAGEOPS
{
COPY_PUT,
XOR_PUT,
OR_PUT,
AND_PUT,
NOT_PUT
};
#define _PAL_SIZE 256
typedef RGB24 PALLETE[_PAL_SIZE];
#define PALETTE PALLETE
#ifndef NEO_sys_pal_bak_unused
PALETTE g_sys_palette;
#define NEO_SYS_PALLETE g_sys_palette
#endif
/*===============NEO的私有全局变量(请勿擅自俢改,以免造成不可预料的错误!)================*/
long g_screen_size; /*记录当前图形模式的屏幕面积*/
int g_screen_h; /*当前分辨率下的屏幕宽度*/
int g_screen_v; /*当前分辨率下的屏幕高度*/
int g_clear_vram; /*清除显存标志,0表示每次显示模式的改变都同步清除显存原有内容*/
int g_cur_vbe_page; /*当前所处的显示页*/
char g_work_surface; /*当前工作页*/
char g_look_surface; /*当前可视页*/
char g_vbe_version = -1; /*VBE的主版本号*/
char g_vbe_sub_ver; /*VBE的副版本号*/
char g_total_surfaces; /*记录能创建的后台页的总量,视显存大小而定*/
char g_alloc_surface; /*已经申请的后台页数*/
char g_reserved_page = 1; /*保留页面张数*/
char far *g_videoptr = (char far *)0xa0000000L;
char g_page_num;
char g_green_mask;
char g_green_bit;
char g_color_depth; /*记录当前图形模式的色深,为0表示非图形模式*/
char g_color_byte; /*记录当前图形模式每个点占用的字节数*/
Uint16 g_sl_offset;
Uint16 g_total_vram; /*总显存数*/
/*=======================================================================================*/
int g_frt_color = 1;
int g_tptcolor; /*本开发包指定透明色(Transparent color)*/
char g_draw_mode; /*绘图模式,分为COPY_PUT,XOR_PUT,OR_PUT,AND_PUT,NOT_PUT,与TC中Graphics的绘图模式意义相同*/
/*以下4个变量用来支持裁剪输出,分别代表裁剪区域的左上角及右下角坐标(用户通过screen()函数间接设置)*/
int g_rect_left;
int g_rect_right;
int g_rect_top;
int g_rect_bottom;
int g_temp_top;
int g_temp_left;
int g_temp_right;
int g_temp_bottom;
/*======================================================*
* 函数声明(Function declare) *
*======================================================*/
int get_mode_info(int mode, char far *modeinfo);
char set_video_mode(int w, int h, int bpp, int refresh, int flags);
int get_vbe_mode(void);
void set_vga_mode(int mode);
char get_page_num(void);
void set_display_start(unsigned fir_scan_dot, unsigned fir_scan_line);
char screen_rect(int left, int top, int right, int bottom);
void rect_store(void);
void rect_restore(void);
void set_vbe_page(int page);
extern void rectfill(int x1, int y1, int x2, int y2, int color);
char surface_alloc(unsigned sur_num, int clear_flag);
char set_work_surface(unsigned sur_num);
char flip_surface(unsigned sur_num);
void flip(void);
void set_draw_mode(int draw_mode);
void vsync(void);
void get_palette_range(char *pal_buf, int from, int to);
extern void show_mouse(void);
extern void hide_mouse(void);
extern void scare_mouse(void);
extern void unscare_mouse(void);
/*======================================================*
* 函数定义(Function definitions) *
*======================================================*/
#define max_x() g_screen_h
#define max_y() g_screen_v
#define get_color_depth() g_color_depth
#define clear_vram_on() g_clear_vram = 0
#define clear_vram_off() g_clear_vram = 0x8000
#define get_current_page() g_cur_vbe_page
#define get_total_vram() (g_total_vram >> 4)
#define get_total_surfaces() g_total_surfaces
#define surface_realloc(sur_num,flag) surface_alloc(sur_num,flag)
#define set_vbe_mode(mode) set_video_mode(0, 0, 0, 0, mode << 7)
#define screen(x1, y1, x2, y2) screen_rect(x1, y1, x2, y2)
#ifndef NEO_color_depth_8_unused
#ifndef NEO_palette_unused
#define _get_palette_range(pal, from, to) get_palette_range((char *)pal, from, to)
#define update_sys_pal() _get_palette_range(g_sys_palette, 0, 255)
#endif
#endif
int get_mode_info(int mode, /*mode_info_t **/char far *modeinfo)
{
union REGS in,out;
struct SREGS segs;
if (mode < 0x100)
{
return mode == 0x13 ? TRUE : FALSE;
}
in.x.ax = 0x4F01;
in.x.cx = mode;
in.x.di = FP_OFF(modeinfo);
segs.es = FP_SEG(modeinfo);
int86x(0x10, &in, &out, &segs);
return (out.x.ax == 0x4F);
}
/*#define HPOS 0
#define HNEG (1 << 2)
#define VPOS 0
#define VNEG (1 << 3)
#define INTERLACED (1 << 1)
#define DOUBLESCAN (1 << 0)
static int current_refresh_rate = 0;
int _refresh_rate_request;
extern unsigned long __tb;*/
/* request_refresh_rate:
* Requests that the next call to set_gfx_mode() use the specified refresh
* rate.
*/
/*void request_refresh_rate(int rate)
{
_refresh_rate_request = rate;
}*/
/* _set_current_refresh_rate:
* Sets the current refresh rate.
* (This function must be called by the gfx drivers)
*/
/*void _set_current_refresh_rate(int rate)
{
if ((rate<40) || (rate>200))
rate = 0;
current_refresh_rate = rate;
}*/
/* calc_crtc_timing:
* Calculates CRTC mode timings.
*/
/*static void calc_crtc_timing(CRTC_T *crtc, int xres, int yres, int xadjust, int yadjust)
{
int HTotal, VTotal;
int HDisp, VDisp;
int HSS, VSS;
int HSE, VSE;
int HSWidth, VSWidth;
int SS, SE;
int doublescan = FALSE;
if (yres < 400){
doublescan = TRUE;
yres *= 2;
}
HDisp = xres;
HTotal = (int)(HDisp * 1.27) & ~0x7;
HSWidth = (int)((HTotal - HDisp) / 5) & ~0x7;
HSS = HDisp + 16;
HSE = HSS + HSWidth;
VDisp = yres;
VTotal = VDisp * 1.07;
VSWidth = (VTotal / 100) + 1;
VSS = VDisp + ((int)(VTotal - VDisp) / 5) + 1;
VSE = VSS + VSWidth;
SS = HSS + xadjust;
SE = HSE + xadjust;
if (xadjust < 0) {
if (SS < (HDisp + 8)) {
SS = HDisp + 8;
SE = SS + HSWidth;
}
}
else {
if ((HTotal - 24) < SE) {
SE = HTotal - 24;
SS = SE - HSWidth;
}
}
HSS = SS;
HSE = SE;
SS = VSS + yadjust;
SE = VSE + yadjust;
if (yadjust < 0) {
if (SS < (VDisp + 3)) {
SS = VDisp + 3;
SE = SS + VSWidth;
}
}
else {
if ((VTotal - 4) < SE) {
SE = VTotal - 4;
SS = SE - VSWidth;
}
}
VSS = SS;
VSE = SE;
crtc->horizontal_total = HTotal;
crtc->horizontal_sync_start = HSS;
crtc->horizontal_sync_end = HSE;
crtc->vertical_total = VTotal;
crtc->vertical_sync_start = VSS;
crtc->vertical_sync_end = VSE;
crtc->flags = HNEG | VNEG;
if (doublescan)
crtc->flags |= DOUBLESCAN;
}*/
/*void far (*g_win_func)();*/
/*設置SVGA的显示模式*/
char set_video_mode(int w, int h, int bpp, int refresh, int flags)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -