📄 system.inc
字号:
{* ______ ___ ___
* /\ _ \ /\_ \ /\_ \
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
* \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
* \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
* \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
* /\____/
* \_/__/
*
* System level: initialization, cleanup, etc.
*
* By Shawn Hargreaves.
*
* See readme.txt for copyright information.
*}
{$IFDEF ALLEGRO_INTERFACE}
type
P_GFX_VTABLE = ^GFX_VTABLE;
P_RLE_SPRITE = ^RLE_SPRITE;
P_FONT_GLYPH = ^FONT_GLYPH;
P_BITMAP = ^BITMAP;
P_GFX_MODE = ^GFX_MODE;
P_V3D = ^V3D;
P_V3DS = ^V3DS;
P_V3D_f = ^V3D_f;
P_V3DS_f = ^V3DS_f;
Bitmap = record
w, h : integer; // width and height in pixels
clip : integer; // flag if clipping is turned on
cl, cr, ct, cb : Integer; // clip left, right, top and bottom values
vtable : P_GFX_VTABLE; // (GFX_VTABLE *) drawing functions
write_bank : Pointer; // C func on some machines, asm on i386
read_bank : Pointer; // C func on some machines, asm on i386
dat : Pointer; // the memory we allocated for the bitmap
id : LongInt; // for identifying sub-bitmaps
extra : Pointer; // points to a structure with more info
x_ofs : Integer; // horizontal offset (for sub-bitmaps)
y_ofs : Integer; // vertical offset (for sub-bitmaps)
seg : Integer; // bitmap segment
line : array[0..0] of p_uint8s; // unsigned char *line[ZERO_SIZE];
end;
spline_points = array[0..7] of sint32;
GFX_VTABLE = record // functions for drawing onto bitmaps
color_depth : sint32;
mask_color : sint32;
unwrite_bank : Pointer; // C function on some machines, asm on i386
set_clip : procedure(bmp: P_BITMAP); cdecl;
acquire : procedure(bmp: P_BITMAP); cdecl;
release : procedure(bmp: P_BITMAP); cdecl;
create_sub_bitmap : function(parent: P_BITMAP; x, y, width, height: sint32): P_BITMAP; cdecl;
created_sub_bitmap : procedure(bmp, parent: P_BITMAP); cdecl;
getpixel : function(bmp: P_BITMAP; x, y: sint32): sint32; cdecl;
putpixel : procedure(bmp: P_BITMAP; x, y, color: sint32); cdecl;
vline : procedure(bmp: P_BITMAP; x, y1, y2, color: sint32); cdecl;
hline : procedure(bmp: P_BITMAP; x1, y, x2, color: sint32); cdecl;
hfill : procedure(bmp: P_BITMAP; x1, y, x2, color: sint32); cdecl;
line : procedure(bmp: P_BITMAP; x1, y1, x2, y2, color: sint32); cdecl;
fastline : procedure(bmp: P_BITMAP; x1, y1, x2, y2, color: sint32); cdecl;
rectfill : procedure(bmp: P_BITMAP; x1, y1, x2, y2, color: sint32); cdecl;
triangle : procedure(bmp: P_BITMAP; x1, y1, x2, y2, x3, y3, color: sint32); cdecl;
draw_sprite : procedure(bmp, sprite: P_BITMAP; x, y: sint32); cdecl;
draw_256_sprite : procedure(bmp, sprite: P_BITMAP; x, y: sint32); cdecl;
draw_sprite_v_flip : procedure(bmp, sprite: P_BITMAP; x, y: sint32); cdecl;
draw_sprite_h_flip : procedure(bmp, sprite: P_BITMAP; x, y: sint32); cdecl;
draw_sprite_vh_flip : procedure(bmp, sprite: P_BITMAP; x, y: sint32); cdecl;
draw_trans_sprite : procedure(bmp, sprite: P_BITMAP; x, y: sint32); cdecl;
draw_trans_rgba_sprite : procedure(bmp, sprite: P_BITMAP; x, y: sint32); cdecl;
draw_lit_sprite : procedure(bmp, sprite: P_BITMAP; x, y, color: sint32); cdecl;
draw_rle_sprite : procedure(bmp: P_BITMAP; const sprite: P_RLE_SPRITE; x, y: sint32); cdecl;
draw_trans_rle_sprite : procedure(bmp: P_BITMAP; const sprite: P_RLE_SPRITE; x, y: sint32); cdecl;
draw_trans_rgba_rle_sprite : procedure(bmp: P_BITMAP; const sprite: P_RLE_SPRITE; x, y: sint32); cdecl;
draw_lit_rle_sprite : procedure(bmp: P_BITMAP; const sprite: P_RLE_SPRITE; x, y, color: sint32); cdecl;
draw_character : procedure(bmp, sprite: P_BITMAP; x, y, color, bg: sint32); cdecl;
draw_glyph : procedure(bmp: P_BITMAP; glyph: P_FONT_GLYPH; x, y, color, bg: sint32); cdecl;
blit_from_memory : procedure(source, dest: P_BITMAP; source_x, source_y, dest_x, dest_y, width, height: sint32); cdecl;
blit_to_memory : procedure(source, dest: P_BITMAP; source_x, source_y, dest_x, dest_y, width, height: sint32); cdecl;
blit_from_system : procedure(source, dest: P_BITMAP; source_x, source_y, dest_x, dest_y, width, height: sint32); cdecl;
blit_to_sytem : procedure(source, dest: P_BITMAP; source_x, source_y, dest_x, dest_y, width, height: sint32); cdecl;
blit_to_self : procedure(source, dest: P_BITMAP; source_x, source_y, dest_x, dest_y, width, height: sint32); cdecl;
blit_to_self_forward : procedure(source, dest: P_BITMAP; source_x, source_y, dest_x, dest_y, width, height: sint32); cdecl;
blit_to_self_backward : procedure(source, dest: P_BITMAP; source_x, source_y, dest_x, dest_y, width, height: sint32); cdecl;
blit_between_formats : procedure(source, dest: P_BITMAP; source_x, source_y, dest_x, dest_y, width, height: sint32); cdecl;
masked_blit : procedure(source, dest: P_BITMAP; source_x, source_y, dest_x, dest_y, width, height: sint32); cdecl;
clear_to_color : procedure(bitmap: P_BITMAP; color: sint32); cdecl;
pivot_scaled_sprite_flip : procedure(bmp, sprite: P_BITMAP; x, y, cx, cy, angle, scale: fixed; v_flip: sint32); cdecl;
do_stretch_blit : procedure(source, dest: P_BITMAP; source_x, source_y, source_width, source_height, dest_x, dest_y, dest_width, dest_height, masked: sint32); cdecl;
draw_gouraud_sprite : procedure(bmp, sprite: P_BITMAP; x, y, c1, c2, c3, c4: sint32); cdecl;
draw_sprite_end : procedure; cdecl;
blit_end : procedure; cdecl;
polygon : procedure(bmp: P_BITMAP; vertices: sint32; const points: p_sint32s; color: sint32); cdecl;
rect : procedure(bmp: P_BITMAP; x1, y1, x2, y2, color: sint32); cdecl;
circle : procedure(bmp: P_BITMAP; x, y, radius, color: sint32); cdecl;
circlefill : procedure(bmp: P_BITMAP; x, y, radius, color: sint32); cdecl;
ellipse : procedure(bmp: P_BITMAP; x, y, rx, ry, color: sint32); cdecl;
ellipsefill : procedure(bmp: P_BITMAP; x, y, rx, ry, color: sint32); cdecl;
arc : procedure(bmp: P_BITMAP; x, y: sint32; ang1, ang2: fixed; r, color: sint32); cdecl;
spline : procedure(bmp: P_BITMAP; const points: spline_points; color: sint32); cdecl;
floodfill : procedure(bmp: P_BITMAP; x, y, color: sint32); cdecl;
polygon3d : procedure(bmp: P_BITMAP; types: sint32; texture: P_BITMAP; vc: sint32; vtx: P_V3DS); cdecl;
polygon3d_f : procedure(bmp: P_BITMAP; types: sint32; texture: P_BITMAP; vc: sint32; vtx: P_V3DS_f); cdecl;
triangle3d : procedure(bmp: P_BITMAP; types: sint32; texture: P_BITMAP; v1, v2, v3: P_V3D); cdecl;
triangle3d_f : procedure(bmp: P_BITMAP; types: sint32; texture: P_BITMAP; v1, v2, v3: P_V3D_f); cdecl;
quad3d : procedure(bmp: P_BITMAP; types: sint32; texture: P_BITMAP; v1, v2, v3, v4: P_V3D); cdecl;
quad3d_f : procedure(bmp: P_BITMAP; types: sint32; texture: P_BITMAP; v1, v2, v3, v4: P_V3D_f); cdecl;
end;
{ rle.inc }
RLE_SPRITE = record // a RLE compressed sprite
w, h : sint32; // width and height in pixels
color_depth : sint32; // color depth of the image
size : sint32; // size of sprite data in bytes
dat : p_sint8s; // ZERO_SIZE_ARRAY(signed char, dat);
end;
{ font.inc }
FONT_GLYPH = record // a single monochrome font character
w, h : sint16;
dat : p_uint8s;
end;
GFX_MODE = record
width, height, bpp: sint32;
end;
V3D = record // a 3d point (fixed point version)
x, y, z : fixed; // position
u, v : fixed; // texture map coordinates
c : sint32; // color
end;
V3DS = array[0..9999999] of V3D;
V3D_f = record // a 3d point (floating point version)
x, y, z : single; // position
u, v : single; // texture map coordinates
c : sint32; // color
end;
V3DS_f = array[0..9999999] of V3D_f;
P_FONT = ^FONT;
P_FONT_VTABLE = ^FONT_VTABLE;
FONT_VTABLE = record
font_height : function(const f: P_FONT): sint32; cdecl;
char_length : function(const f: P_FONT; ch: sint32): sint32; cdecl;
text_length : function(const f: P_FONT; const text: PChar): sint32; cdecl;
render_char : function(const f: P_FONT; ch, fg, bg: sint32; bmp: P_BITMAP; x, y: sint32): sint32; cdecl;
render : procedure(const f: P_FONT; const text: PChar; fg, bg: sint32; bmp: P_BITMAP; x, y: sint32); cdecl;
destroy : procedure(f: P_FONT); cdecl;
get_font_ranges : function(f: P_FONT): sint32; cdecl;
get_font_range_begin : function(f: P_FONT; range: sint32): sint32; cdecl;
get_font_range_end : function(f: P_FONT; range: sint32): sint32; cdecl;
extract_font_range : function(f: P_FONT; begins, ends: sint32): P_FONT; cdecl;
merge_fonts : function(f1, f2: P_FONT): P_FONT; cdecl;
transpose_font : function(f: P_FONT; drange: sint32): sint32; cdecl;
end;
FONT = record
data : Pointer;
height : sint32;
vtable : P_FONT_VTABLE;
end;
const
ALLEGRO_ERROR_SIZE = 256;
var
allegro_id : PChar;
allegro_error : PChar;
const
OSTYPE_UNKNOWN = 0;
OSTYPE_WIN3 = (ord ('W') shl 24) + (ord ('I') shl 16) + (ord ('N') shl 8) + ord ('3');
OSTYPE_WIN95 = (ord ('W') shl 24) + (ord ('9') shl 16) + (ord ('5') shl 8) + ord (' ');
OSTYPE_WIN98 = (ord ('W') shl 24) + (ord ('9') shl 16) + (ord ('8') shl 8) + ord (' ');
OSTYPE_WINME = (ord ('W') shl 24) + (ord ('M') shl 16) + (ord ('E') shl 8) + ord (' ');
OSTYPE_WINNT = (ord ('W') shl 24) + (ord ('N') shl 16) + (ord ('T') shl 8) + ord (' ');
OSTYPE_WIN2000 = (ord ('W') shl 24) + (ord ('2') shl 16) + (ord ('K') shl 8) + ord (' ');
OSTYPE_WINXP = (ord ('W') shl 24) + (ord ('X') shl 16) + (ord ('P') shl 8) + ord (' ');
OSTYPE_OS2 = (ord ('O') shl 24) + (ord ('S') shl 16) + (ord ('2') shl 8) + ord (' ');
OSTYPE_WARP = (ord ('W') shl 24) + (ord ('A') shl 16) + (ord ('R') shl 8) + ord ('P');
OSTYPE_DOSEMU = (ord ('D') shl 24) + (ord ('E') shl 16) + (ord ('N') shl 8) + ord ('U');
OSTYPE_OPENDOS = (ord ('O') shl 24) + (ord ('D') shl 16) + (ord ('O') shl 8) + ord ('S');
OSTYPE_LINUX = (ord ('T') shl 24) + (ord ('U') shl 16) + (ord ('X') shl 8) + ord (' ');
OSTYPE_SUNOS = (ord ('S') shl 24) + (ord ('U') shl 16) + (ord ('N') shl 8) + ord (' ');
OSTYPE_FREEBSD = (ord ('F') shl 24) + (ord ('B') shl 16) + (ord ('S') shl 8) + ord ('D');
OSTYPE_NETBSD = (ord ('N') shl 24) + (ord ('B') shl 16) + (ord ('S') shl 8) + ord ('D');
OSTYPE_IRIX = (ord ('I') shl 24) + (ord ('R') shl 16) + (ord ('I') shl 8) + ord ('X');
OSTYPE_DARWIN = (ord ('D') shl 24) + (ord ('A') shl 16) + (ord ('R') shl 8) + ord ('W');
OSTYPE_QNX = (ord ('Q') shl 24) + (ord ('N') shl 16) + (ord ('X') shl 8) + ord (' ');
OSTYPE_UNIX = (ord ('U') shl 24) + (ord ('N') shl 16) + (ord ('I') shl 8) + ord ('X');
OSTYPE_BEOS = (ord ('B') shl 24) + (ord ('E') shl 16) + (ord ('O') shl 8) + ord ('S');
OSTYPE_MACOS = (ord ('M') shl 24) + (ord ('A') shl 16) + (ord ('C') shl 8) + ord (' ');
OSTYPE_MACOSX = (ord ('M') shl 24) + (ord ('A') shl 16) + (ord ('C') shl 8) + ord ('X');
var
os_type : p_sint32;
os_version : p_sint32;
os_revision : p_sint32;
os_multitasking : p_sint32;
const
SYSTEM_AUTODETECT = 0;
SYSTEM_NONE = (ord ('N') shl 24) + (ord ('O') shl 16) + (ord ('N') shl 8) + ord ('E');
function MAKE_VERSION(a, b, c: sint32): sint32;
type
proc_ptr = procedure; cdecl;
atexit_ptr = function(func: proc_ptr): sint32; cdecl;
var
_get_allegro_version: function: sint32; cdecl;
_install_allegro: function(system_id: sint32; errno_ptr: p_sint32s; atexit: atexit_ptr): sint32; cdecl;
function install_allegro(system_id: sint32; errno_ptr: p_sint32s; atexit: atexit_ptr): sint32;
function allegro_init: sint32;
var
allegro_exit: procedure; cdecl;
allegro_message: procedure(const msg: PChar); cdecl;
get_executable_name: procedure(output: PChar; size: sint32); cdecl;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -