📄 gfx.inc
字号:
{* ______ ___ ___
* /\ _ \ /\_ \ /\_ \
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
* \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
* \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
* \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
* /\____/
* \_/__/
*
* Basic graphics support routines.
*
* By Shawn Hargreaves.
*
* See readme.txt for copyright information.
*}
{$IFDEF ALLEGRO_INTERFACE}
const
GFX_TEXT = -1;
GFX_AUTODETECT = 0;
GFX_AUTODETECT_FULLSCREEN = 1;
GFX_AUTODETECT_WINDOWED = 2;
GFX_SAFE = (ord ('S') shl 24) + (ord ('A') shl 16) + (ord ('F') shl 8) + ord ('E');
// Blender mode defines, for the gfx_driver->set_blender_mode() function
blender_mode_none = 0;
blender_mode_trans = 1;
blender_mode_add = 2;
blender_mode_burn = 3;
blender_mode_color = 4;
blender_mode_difference = 5;
blender_mode_dissolve = 6;
blender_mode_dodge = 7;
blender_mode_hue = 8;
blender_mode_invert = 9;
blender_mode_luminance = 10;
blender_mode_multiply = 11;
blender_mode_saturation = 12;
blender_mode_screen = 13;
blender_mode_alpha = 14;
type
P_GFX_MODE_LIST = ^GFX_MODE_LIST;
GFX_MODE_LIST = record // number of gfx modes
num_modes : sint32; // pointer to the actual mode list array
modes : P_GFX_MODE;
end;
P_GFX_DRIVER = ^GFX_DRIVER;
GFX_DRIVER = record // creates and manages the screen bitmap
id : sint32;
name : PChar;
desc : PChar;
ascii_name : PChar;
init : function(w, h, v_w, v_h, color_depth: sint32): P_BITMAP; cdecl;
exit : procedure(b: P_BITMAP); cdecl;
scroll : function(x, y: sint32): sint32; cdecl;
vsync : procedure; cdecl;
set_palette : procedure(const p: P_RGB; from, tos, retracesync: sint32); cdecl;
request_scroll : function(x, y: sint32): sint32; cdecl;
poll_scroll : function: sint32; cdecl;
enable_triple_buffer : procedure; cdecl;
create_video_bitmap : function(width, height: sint32): P_BITMAP; cdecl;
destroy_video_bitamp : procedure(bitmap: P_BITMAP); cdecl;
show_video_bitmap : function(bitmap: P_BITMAP): sint32; cdecl;
request_video_bitmap : function(bitmap: P_BITMAP): sint32; cdecl;
create_system_bitmap : function(width, height: sint32): P_BITMAP; cdecl;
destroy_system_bitmap : procedure(bitmap: P_BITMAP); cdecl;
set_mouse_sprite : function(sprite: P_BITMAP; xfocus, yfocus: sint32): sint32; cdecl;
show_mouse : function(bmp: P_BITMAP; x, y: sint32): sint32; cdecl;
hide_mouse : procedure; cdecl;
move_mouse : procedure(x, y: sint32); cdecl;
drawing_mode : procedure; cdecl;
save_video_state : procedure; cdecl;
restore_video_state : procedure; cdecl;
set_blender_mode : procedure(mode, r, g, b, a: sint32); cdecl;
fetch_mode_list : function: P_GFX_MODE_LIST; cdecl;
w, h : sint32; // physical (not virtual!) screen size
linear : sint32; // true if video memory is linear
bank_size : sint32; // bank size, in bytes
bank_gran : sint32; // bank granularity, in bytes
vid_mem : sint32; // video memory size, in bytes
vid_phys_base : sint32; // physical address of video memory
windowed : sint32; // true if driver runs windowed
end;
var
the_gfx_driver : ^P_GFX_DRIVER;
_gfx_driver_list : P_DRIVER_INFO;
const
GFX_CAN_SCROLL = $00000001;
GFX_CAN_TRIPLE_BUFFER = $00000002;
GFX_HW_CURSOR = $00000004;
GFX_HW_HLINE = $00000008;
GFX_HW_HLINE_XOR = $00000010;
GFX_HW_HLINE_SOLID_PATTERN = $00000020;
GFX_HW_HLINE_COPY_PATTERN = $00000040;
GFX_HW_FILL = $00000080;
GFX_HW_FILL_XOR = $00000100;
GFX_HW_FILL_SOLID_PATTERN = $00000200;
GFX_HW_FILL_COPY_PATTERN = $00000400;
GFX_HW_LINE = $00000800;
GFX_HW_LINE_XOR = $00001000;
GFX_HW_TRIANGLE = $00002000;
GFX_HW_TRIANGLE_XOR = $00004000;
GFX_HW_GLYPH = $00008000;
GFX_HW_VRAM_BLIT = $00010000;
GFX_HW_VRAM_BLIT_MASKED = $00020000;
GFX_HW_MEM_BLIT = $00040000;
GFX_HW_MEM_BLIT_MASKED = $00080000;
GFX_HW_SYS_TO_VRAM_BLIT = $00100000;
GFX_HW_SYS_TO_VRAM_BLIT_MASKED = $00200000;
GFX_SYSTEM_CURSOR = $00400000;
var
gfx_capabilities : p_sint32;
{GFX_TABLE defined in system.inc}
var
__linear_vtable8 : P_GFX_VTABLE;
__linear_vtable15 : P_GFX_VTABLE;
__linear_vtable16 : P_GFX_VTABLE;
__linear_vtable24 : P_GFX_VTABLE;
__linear_vtable32 : P_GFX_VTABLE;
type
P_VTABLE_INFO = ^_VTABLE_INFO;
_VTABLE_INFO = record
color_depth : sint32;
vtable : P_GFX_VTABLE;
end;
var
_vtable_list : P_VTABLE_INFO;
const
BMP_ID_VIDEO = $80000000;
BMP_ID_SYSTEM = $40000000;
BMP_ID_SUB = $20000000;
BMP_ID_PLANAR = $10000000;
BMP_ID_NOBLIT = $08000000;
BMP_ID_LOCKED = $04000000;
BMP_ID_AUTOLOCK = $02000000;
BMP_ID_MASK = $01FFFFFF;
var
screen : ^P_BITMAP;
const
COLORCONV_NONE = 0;
COLORCONV_8_TO_15 = 1;
COLORCONV_8_TO_16 = 2;
COLORCONV_8_TO_24 = 4;
COLORCONV_8_TO_32 = 8;
COLORCONV_15_TO_8 = $10;
COLORCONV_15_TO_16 = $20;
COLORCONV_15_TO_24 = $40;
COLORCONV_15_TO_32 = $80;
COLORCONV_16_TO_8 = $100;
COLORCONV_16_TO_15 = $200;
COLORCONV_16_TO_24 = $400;
COLORCONV_16_TO_32 = $800;
COLORCONV_24_TO_8 = $1000;
COLORCONV_24_TO_15 = $2000;
COLORCONV_24_TO_16 = $4000;
COLORCONV_24_TO_32 = $8000;
COLORCONV_32_TO_8 = $10000;
COLORCONV_32_TO_15 = $20000;
COLORCONV_32_TO_16 = $40000;
COLORCONV_32_TO_24 = $80000;
COLORCONV_32A_TO_8 = $100000;
COLORCONV_32A_TO_15 = $200000;
COLORCONV_32A_TO_16 = $400000;
COLORCONV_32A_TO_24 = $800000;
COLORCONV_DITHER_PAL = $1000000;
COLORCONV_DITHER_HI = $2000000;
COLORCONV_KEEP_TRANS = $4000000;
COLORCONV_DITHER = (COLORCONV_DITHER_PAL or COLORCONV_DITHER_HI);
COLORCONV_EXPAND_256 = (COLORCONV_8_TO_15 or COLORCONV_8_TO_16 or COLORCONV_8_TO_24 or COLORCONV_8_TO_32);
COLORCONV_REDUCE_TO_256 = (COLORCONV_15_TO_8 or COLORCONV_16_TO_8 or COLORCONV_24_TO_8 or COLORCONV_32_TO_8 or COLORCONV_32A_TO_8);
COLORCONV_EXPAND_15_TO_16 = COLORCONV_15_TO_16;
COLORCONV_REDUCE_16_TO_15 = COLORCONV_16_TO_15;
COLORCONV_EXPAND_HI_TO_TRUE = (COLORCONV_15_TO_24 or COLORCONV_15_TO_32 or COLORCONV_16_TO_24 or COLORCONV_16_TO_32);
COLORCONV_REDUCE_TRUE_TO_HI = (COLORCONV_24_TO_15 or COLORCONV_24_TO_16 or COLORCONV_32_TO_15 or COLORCONV_32_TO_16);
COLORCONV_24_EQUALS_32 = (COLORCONV_24_TO_32 or COLORCONV_32_TO_24);
COLORCONV_TOTAL = (COLORCONV_EXPAND_256 or COLORCONV_REDUCE_TO_256 or COLORCONV_EXPAND_15_TO_16 or
COLORCONV_REDUCE_16_TO_15 or COLORCONV_EXPAND_HI_TO_TRUE or COLORCONV_REDUCE_TRUE_TO_HI or COLORCONV_24_EQUALS_32 or
COLORCONV_32A_TO_15 or COLORCONV_32A_TO_16 or COLORCONV_32A_TO_24);
COLORCONV_PARTIAL = (COLORCONV_EXPAND_15_TO_16 or COLORCONV_REDUCE_16_TO_15 or COLORCONV_24_EQUALS_32);
COLORCONV_MOST = (COLORCONV_EXPAND_15_TO_16 or COLORCONV_REDUCE_16_TO_15 or COLORCONV_EXPAND_HI_TO_TRUE or
COLORCONV_REDUCE_TRUE_TO_HI or COLORCONV_24_EQUALS_32);
COLORCONV_KEEP_ALPHA = (COLORCONV_TOTAL and not(COLORCONV_32A_TO_8 or COLORCONV_32A_TO_15 or
COLORCONV_32A_TO_16 or COLORCONV_32A_TO_24));
var
get_gfx_mode_list: function(card: sint32): P_GFX_MODE_LIST; cdecl;
destroy_gfx_mode_list: procedure(gfx_mode_list: P_GFX_MODE_LIST); cdecl;
set_color_depth: procedure(depth: sint32); cdecl;
get_color_depth: function: sint32; cdecl;
set_color_conversion: procedure(mode: sint32); cdecl;
get_color_conversion: function: sint32; cdecl;
request_refresh_rate: procedure(rate: sint32); cdecl;
get_refresh_rate: function: sint32; cdecl;
set_gfx_mode: function(card, w, h, v_w, v_h: sint32): sint32; cdecl;
scroll_screen: function(x, y: sint32): sint32; cdecl;
request_scroll: function(x, y: sint32): sint32; cdecl;
poll_scroll: function: sint32; cdecl;
show_video_bitmap: function(bitmap: P_BITMAP): sint32; cdecl;
request_video_bitmap: function(bitmap: P_BITMAP): sint32; cdecl;
enable_triple_buffer: function: sint32; cdecl;
create_bitmap: function(width, height: sint32): P_BITMAP; cdecl;
create_bitmap_ex: function(color_depth, width, height: sint32): P_BITMAP; cdecl;
create_sub_bitmap: function(parent: P_BITMAP; x, y, width, height: sint32): P_BITMAP; cdecl;
create_video_bitmap: function(width, height: sint32): P_BITMAP;
create_system_bitmap: function(width, height: sint32): P_BITMAP;
destroy_bitmap: procedure(bitmap: P_BITMAP); cdecl;
set_clip_rect: procedure(bitmap: P_BITMAP; x1, y1, x2, y2: sint32); cdecl;
add_clip_rect: procedure(bitmap: P_BITMAP; x1, y1, x2, y2: sint32); cdecl;
clear_bitmap: procedure(bitmap: P_BITMAP); cdecl;
vsync: procedure; cdecl;
const
SWITCH_NONE = 0;
SWITCH_PAUSE = 1;
SWITCH_AMNESIA = 2;
SWITCH_BACKGROUND = 3;
SWITCH_BACKAMNESIA = 4;
SWITCH_IN = 0;
SWITCH_OUT = 1;
var
set_display_switch_mode: function(mode: sint32): sint32; cdecl;
get_display_switch_mode: function: sint32; cdecl;
set_display_switch_callback: function(dir: sint32; cb: proc_ptr): sint32; cdecl;
remove_display_switch_callback: procedure(cb: proc_ptr); cdecl;
lock_bitmap: procedure(bmp: P_BITMAP); cdecl;
function SCREEN_W: sint32;
function SCREEN_H: sint32;
function VIRTUAL_W: sint32;
function VIRTUAL_H: sint32;
{$ENDIF ALLEGRO_INTERFACE}
{$IFDEF ALLEGRO_IMPLEMENTATION}
function SCREEN_W: sint32;
begin
if the_gfx_driver^ <> nil then
Result := the_gfx_driver^.w
else
Result := 0;
end;
function SCREEN_H: sint32;
begin
if the_gfx_driver^ <> nil then
Result := the_gfx_driver^.h
else
Result := 0;
end;
function VIRTUAL_W: sint32;
begin
if screen^ <> nil then
Result := screen^.w
else
Result := 0;
end;
function VIRTUAL_H: sint32;
begin
if screen^ <> nil then
Result := screen^.h
else
Result := 0;
end;
{$ENDIF ALLEGRO_IMPLEMENTATION}
{$IFDEF ALLEGRO_LOADVARIABLE}
the_gfx_driver := LoadDLL('gfx_driver');
_gfx_driver_list := LoadDLL('_gfx_driver_list');
gfx_capabilities := LoadDLL('gfx_capabilities');
__linear_vtable8 := LoadDLL('__linear_vtable8');
__linear_vtable15 := LoadDLL('__linear_vtable15');
__linear_vtable16 := LoadDLL('__linear_vtable16');
__linear_vtable24 := LoadDLL('__linear_vtable24');
__linear_vtable32 := LoadDLL('__linear_vtable32');
_vtable_list := LoadDLL('_vtable_list');
screen := LoadDLL('screen');
get_gfx_mode_list := LoadDLL('get_gfx_mode_list');
destroy_gfx_mode_list := LoadDLL('destroy_gfx_mode_list');
set_color_depth := LoadDLL('set_color_depth');
get_color_depth := LoadDLL('get_color_depth');
set_color_conversion := LoadDLL('set_color_conversion');
get_color_conversion := LoadDLL('get_color_conversion');
request_refresh_rate := LoadDLL('request_refresh_rate');
get_refresh_rate := LoadDLL('get_refresh_rate');
set_gfx_mode := LoadDLL('set_gfx_mode');
scroll_screen := LoadDLL('scroll_screen');
request_scroll := LoadDLL('request_scroll');
poll_scroll := LoadDLL('poll_scroll');
show_video_bitmap := LoadDLL('show_video_bitmap');
request_video_bitmap := LoadDLL('request_video_bitmap');
enable_triple_buffer := LoadDLL('enable_triple_buffer');
create_bitmap := LoadDLL('create_bitmap');
create_bitmap_ex := LoadDLL('create_bitmap_ex');
create_sub_bitmap := LoadDLL('create_sub_bitmap');
create_video_bitmap := LoadDLL('create_video_bitmap');
create_system_bitmap := LoadDLL('create_system_bitmap');
destroy_bitmap := LoadDLL('destroy_bitmap');
set_clip_rect := LoadDLL('set_clip_rect');
add_clip_rect := LoadDLL('add_clip_rect');
clear_bitmap := LoadDLL('clear_bitmap');
vsync := LoadDLL('vsync');
set_display_switch_mode := LoadDLL('set_display_switch_mode');
get_display_switch_mode := LoadDLL('get_display_switch_mode');
set_display_switch_callback := LoadDLL('set_display_switch_callback');
remove_display_switch_callback := LoadDLL('remove_display_switch_callback');
lock_bitmap := LoadDLL('lock_bitmap');
{$ENDIF ALLEGRO_LOADVARIABLE}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -