📄 allegro.pas
字号:
(*
OSTYPE_WIN3 = (ord ('W') shl 24) + (ord ('I') shl 16) + (ord ('N') shl 8) + ord ('3');
{$IFDEF ALLEGRO_INTERFACE}
{$ENDIF ALLEGRO_INTERFACE}
{$IFDEF ALLEGRO_IMPLEMENTATION}
{$ENDIF ALLEGRO_IMPLEMENTATION}
{$IFDEF ALLEGRO_LOADVARIABLE}
{$ENDIF ALLEGRO_LOADVARIABLE}
*)
unit Allegro;
interface
uses
Windows;
type
p_sint8 = ^sint8;
p_sint16 = ^sint16;
p_sint32 = ^sint32;
p_sint64 = ^sint64;
p_uint8 = ^uint8;
p_uint16 = ^uint16;
p_uint32 = ^uint32;
p_single = ^single;
p_fixed = ^fixed;
sint8 = ShortInt;
sint16 = SmallInt;
sint32 = Integer;
sint64 = Int64;
uint8 = Byte;
uint16 = Word;
uint32 = Cardinal;
fixed = sint32;
p_fixeds = ^fixeds;
fixeds = array[0..99999999] of fixed;
p_sint8s = ^sint8s;
sint8s = array[0..99999999] of sint8;
p_sint32s = ^sint32s;
sint32s = array[0..99999999] of sint32;
p_uint8s = ^uint8s;
uint8s = array[0..99999999] of uint8;
p_uint16s = ^uint16s;
uint16s = array[0..99999999] of uint16;
p_uint32s = ^uint32s;
uint32s = array[0..99999999] of uint32;
p_pchar = ^pchars;
pchars = array[0..99999999] of pchar;
p_booleans = ^booleans;
booleans = array[0..99999999] of boolean;
{
P_LZSS_PACK_DATA = ^LZSS_PACK_DATA;
LZSS_PACK_DATA = record
end;
P_LZSS_UNPACK_DATA = ^LZSS_UNPACK_DATA;
LZSS_UNPACK_DATA = record
end;
}
const
INT_MAX = MAXLONGINT;
{$DEFINE ALLEGRO_INTERFACE}
{$I allegro\base.inc}
{$I allegro\unicode.inc}
{$I allegro\config.inc}
{$I allegro\palette.inc}
{$I allegro\system.inc}
{$I allegro\debug.inc}
{$I allegro\mouse.inc}
{$I allegro\timer.inc}
{$I allegro\keyboard.inc}
{$I allegro\joystick.inc}
{$I allegro\fixed.inc}
{$I allegro\3d.inc}
{$I allegro\gfx.inc}
{$I allegro\color.inc}
{$I allegro\draw.inc}
{$I allegro\rle.inc}
{$I allegro\compiled.inc}
{$I allegro\font.inc}
{$I allegro\text.inc}
{$I allegro\fli.inc}
{$I allegro\gui.inc}
{$I allegro\file.inc}
{$I allegro\digi.inc}
{$I allegro\stream.inc}
{$I allegro\midi.inc}
{$I allegro\sound.inc}
{$I allegro\lzss.inc}
{$I allegro\datafile.inc}
{$I allegro\jpeg.inc}
{$I allegro\fblend.inc}
{$I allegro\fmaths.inc}
{$I allegro\matrix.inc}
{$I allegro\quat.inc}
{$I allegro\3dmaths.inc}
{$I allegro\inline\draw.inc}
{$I allegro\inline\fmaths.inc}
{$I allegro\inline\3dmaths.inc}
{$I allegro\inline\color.inc}
{$I allegro\inline\gfx.inc}
{$I allegro\inline\rle.inc}
{$I allegro\inline\gui.inc}
{$I allegro\inline\matrix.inc}
{$I allegro\alcompat.inc}
{$I allegro\platform\alwin.inc}
{$I allegro\internal\aintern.inc}
{$UNDEF ALLEGRO_INTERFACE}
implementation
const
allegro_dll = 'alleg42.dll';
var
allegro_handle : THANDLE = INVALID_HANDLE_VALUE;
errno: array[0..4095] of sint32;
function LoadDLL(const s: PChar): Pointer;
begin
Result := GetProcAddress(allegro_handle, s);
if Result = nil then
MessageBox(0, s, 'Symbol not found!', mb_Ok or mb_IconInformation);
end;
{$DEFINE ALLEGRO_IMPLEMENTATION}
{$I allegro\base.inc}
{$I allegro\unicode.inc}
{$I allegro\config.inc}
{$I allegro\palette.inc}
{$I allegro\system.inc}
{$I allegro\debug.inc}
{$I allegro\mouse.inc}
{$I allegro\timer.inc}
{$I allegro\keyboard.inc}
{$I allegro\joystick.inc}
{$I allegro\fixed.inc}
{$I allegro\3d.inc}
{$I allegro\gfx.inc}
{$I allegro\color.inc}
{$I allegro\draw.inc}
{$I allegro\rle.inc}
{$I allegro\compiled.inc}
{$I allegro\font.inc}
{$I allegro\text.inc}
{$I allegro\fli.inc}
{$I allegro\gui.inc}
{$I allegro\file.inc}
{$I allegro\digi.inc}
{$I allegro\stream.inc}
{$I allegro\midi.inc}
{$I allegro\sound.inc}
{$I allegro\lzss.inc}
{$I allegro\datafile.inc}
{$I allegro\jpeg.inc}
{$I allegro\fblend.inc}
{$I allegro\fmaths.inc}
{$I allegro\matrix.inc}
{$I allegro\quat.inc}
{$I allegro\3dmaths.inc}
{$I allegro\inline\draw.inc}
{$I allegro\inline\fmaths.inc}
{$I allegro\inline\3dmaths.inc}
{$I allegro\inline\color.inc}
{$I allegro\inline\gfx.inc}
{$I allegro\inline\rle.inc}
{$I allegro\inline\gui.inc}
{$I allegro\inline\matrix.inc}
{$I allegro\alcompat.inc}
{$I allegro\platform\alwin.inc}
{$I allegro\internal\aintern.inc}
{$UNDEF ALLEGRO_IMPLEMENTATION}
// 支持中文显示的库
function u_getc (const s: PChar): Integer; cdecl;
var
c: Word;
ch, cl: Byte;
begin
c := Word (Pointer(s)^);
ch := c shr 8;
cl := c and $FF;
if (ch > $7F) and(cl > $7F) then
c := (cl shl 8) + ch
else
c := cl;
Result := C;
end;
function u_getx (s: PPChar): Integer; cdecl;
var
c: Word;
ch, cl: Byte;
size: Integer;
begin
c := Word (Pointer(s^)^);
ch := c shr 8;
cl := c and $FF;
size := 1;
if (ch > $7F) and (cl > $7F) then
begin
c := (cl shl 8) + ch;
inc (size);
end else
c := cl;
inc (s^, size);
Result := c;
end;
function u_setc (s: PChar; c: Integer): Integer; cdecl;
var
ch, cl: Byte;
begin
ch := c shr 8;
cl := c and $FF;
if (ch > $7F) and (cl > $7F) then
begin
s[0] := chr(ch);
s[1] := chr(cl);
Result := 2;
end else
begin
s[0] := chr(cl);
Result := 1;
end;
end;
function u_width (const s: PChar): Integer; cdecl;
var
c: Word;
c1, c2: Byte;
begin
c := Word (Pointer(s)^);
c1 := c shr 8;
c2 := c and $FF;
if (c1 > $7F) and (c2 > $7F) then
Result := 2
else
Result := 1;
end;
function u_cwidth (c: Integer): Integer; cdecl;
begin
if c < 128 then
Result := 1
else
Result := 2;
end;
function u_isok (c: Integer): Integer; cdecl;
begin
Result := 1;
end;
initialization
allegro_handle := LoadLibrary(allegro_dll);
if allegro_handle < 32 then
begin
MessageBox(0, 'Unable to find "alleg42.dll", program terminated !', 'Warning!', mb_Ok or mb_IconError);
Halt(0);
end;
{$DEFINE ALLEGRO_LOADVARIABLE}
{$I allegro\base.inc}
{$I allegro\unicode.inc}
{$I allegro\config.inc}
{$I allegro\palette.inc}
{$I allegro\system.inc}
{$I allegro\debug.inc}
{$I allegro\mouse.inc}
{$I allegro\timer.inc}
{$I allegro\keyboard.inc}
{$I allegro\joystick.inc}
{$I allegro\fixed.inc}
{$I allegro\3d.inc}
{$I allegro\gfx.inc}
{$I allegro\color.inc}
{$I allegro\draw.inc}
{$I allegro\rle.inc}
{$I allegro\compiled.inc}
{$I allegro\font.inc}
{$I allegro\text.inc}
{$I allegro\fli.inc}
{$I allegro\gui.inc}
{$I allegro\file.inc}
{$I allegro\digi.inc}
{$I allegro\stream.inc}
{$I allegro\midi.inc}
{$I allegro\sound.inc}
{$I allegro\lzss.inc}
{$I allegro\datafile.inc}
{$I allegro\jpeg.inc}
{$I allegro\fblend.inc}
{$I allegro\fmaths.inc}
{$I allegro\matrix.inc}
{$I allegro\quat.inc}
{$I allegro\3dmaths.inc}
{$I allegro\inline\draw.inc}
{$I allegro\inline\fmaths.inc}
{$I allegro\inline\3dmaths.inc}
{$I allegro\inline\color.inc}
{$I allegro\inline\gfx.inc}
{$I allegro\inline\rle.inc}
{$I allegro\inline\gui.inc}
{$I allegro\inline\matrix.inc}
{$I allegro\alcompat.inc}
{$I allegro\platform\alwin.inc}
{$I allegro\internal\aintern.inc}
{$UNDEF ALLEGRO_LOADVARIABLE}
register_uformat(U_GB2312, u_getc, u_getx, u_setc, u_width, u_cwidth, u_isok, 2);
finalization
allegro_exit();
FreeLibrary(allegro_handle);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -