index ae5adb593452a0411cffba3bd404cf2bdac94f3f..6f4456f765baee8527637e933cbbe9eac3cd8741 100644 (file)
{$DEFINE LibraryLibAllegroDecl := cdecl}
{$DEFINE LibraryLibAllegroImp := cdecl; external}
{$DEFINE LibraryLibAllegroVar := cvar; external}
-{$ELSEIF DEFINED(UNIX)}
- {$LINKLIB liballeg.so}
+{$ELSEIF DEFINED(WINDOWS)}
+ {$DEFINE LibraryLibAllegroDecl := cdecl}
+ {$DEFINE LibraryLibAllegroImp := cdecl; external 'alleg42.dll'}
+ {$DEFINE LibraryLibAllegroVar := external 'alleg42.dll'}
+{$ELSE}
{$DEFINE LibraryLibAllegroDecl := cdecl}
{$DEFINE LibraryLibAllegroImp := cdecl; external 'alleg'}
{$DEFINE LibraryLibAllegroVar := cvar; external 'alleg'}
-{$ELSE}
- {$ERROR unsupported platform!}
{$ENDIF}
unit allegro;
uses ctypes;
const
-{$IF DEFINED(GO32V2)}
+{$IF DEFINED(GO32V2) OR DEFINED(WINDOWS)}
ALLEGRO_VERSION = 4;
ALEGRO_SUB_VERSION = 2;
ALLEGRO_WIP_VERSION = 3;
ALLEGRO_VERSION_STR = '4.2.3';
-{$ELSEIF DEFINED(UNIX)}
+{$ELSE}
ALLEGRO_VERSION = 4;
ALEGRO_SUB_VERSION = 4;
ALLEGRO_WIP_VERSION = 2;
ALLEGRO_VERSION_STR = '4.4.2';
-{$ELSE}
- {$ERROR unsupported platform!}
{$ENDIF}
SYSTEM_AUTODETECT = 0;
GFX_AUTODETECT_WINDOWED = 2;
GFX_SAFE = $53414645;
+ DRAW_MODE_SOLID = 0;
+ DRAW_MODE_XOR = 1;
+ DRAW_MODE_COPY_PATTERN = 2;
+ DRAW_MODE_SOLID_PATTERN = 3;
+ DRAW_MODE_MASKED_PATTERN = 4;
+ DRAW_MODE_TRANS = 5;
+
KEY_A = 1;
KEY_B = 2;
KEY_C = 3;
KB_ACCENT4_FLAG = $8000;
ALLEGRO_ERROR_SIZE = 256;
+ PAL_SIZE = 256;
type
PBITMAP = ^BITMAP;
mode: PGFX_MODE;
end;
+ RGB = record
+ r, g, b, filler: cuchar;
+ end;
+
+ PALETTE = array [0..PAL_SIZE - 1] of RGB;
+ PPALETTE = ^PALETTE;
+
KeyboardCallback = procedure (scancode: cint); LibraryLibAllegroDecl;
AtExitCallback = procedure; LibraryLibAllegroDecl;
AtExitFunction = function (func: AtExitCallback): cint; LibraryLibAllegroDecl;
+ TimerIntCallback = procedure; LibraryLibAllegroDecl;
+ QuitCallback = procedure; LibraryLibAllegroDecl;
var
allegro_id: array [0..ALLEGRO_ERROR_SIZE] of char; LibraryLibAllegroVar;
allegro_error: array [0..ALLEGRO_ERROR_SIZE] of char; LibraryLibAllegroVar;
keyboard_lowlevel_callback: KeyboardCallback; LibraryLibAllegroVar;
+ screen: PBITMAP; LibraryLibAllegroVar;
+ black_palette: PALETTE; LibraryLibAllegroVar;
+ desktop_palette: PALETTE; LibraryLibAllegroVar;
+ default_palette: PALETTE; LibraryLibAllegroVar;
+ _current_palette: PALETTE; LibraryLibAllegroVar;
function get_desktop_resolution (width, height: Pcint): cint; LibraryLibAllegroImp;
function get_gfx_mode_list (card: cint): PGFX_MODE_LIST; LibraryLibAllegroImp;
procedure remove_keyboard; LibraryLibAllegroImp;
function _install_allegro_version_check (system_id: cint; errno_ptr: Pcint; atexit_ptr: AtExitFunction; version: cint): cint; LibraryLibAllegroImp;
- function install_allegro (system_id: cint; errno_ptr: Pcint; atexit_ptr: AtExitFunction): cint; inline; (* macros *)
- function allegro_init: cint; inline; (* macros *)
-
function install_timer: cint; LibraryLibAllegroImp;
procedure remove_timer; LibraryLibAllegroImp;
procedure set_keyboard_rate (delay, _repeat: cint); LibraryLibAllegroImp;
function makecol (r, g, b: cint): cint; LibraryLibAllegroImp;
procedure clear_to_color (source: PBITMAP; color: cint); LibraryLibAllegroImp;
procedure putpixel (bmp: PBITMAP; x, y, color: cint); LibraryLibAllegroImp;
+ function getpixel (bmp: PBITMAP; x, y: cint): cint; LibraryLibAllegroImp;
procedure fastline (bmp: PBITMAP; x1, y_1, x2, y2, color: cint); LibraryLibAllegroImp;
procedure draw_sprite (bmp, sprite: PBITMAP; x, y: cint); LibraryLibAllegroImp;
+ procedure draw_sprite_v_flip (bmp, sprite: PBITMAP; x, y: cint); LibraryLibAllegroImp;
+ procedure draw_sprite_h_flip (bmp, sprite: PBITMAP; x, y: cint); LibraryLibAllegroImp;
+ procedure draw_sprite_vh_flip (bmp, sprite: PBITMAP; x, y: cint); LibraryLibAllegroImp;
procedure rect (bmp: PBITMAP; x1, y_1, x2, y2, color: cint); LibraryLibAllegroImp;
procedure rectfill (bmp: PBITMAP; x1, y_1, x2, y2, color: cint); LibraryLibAllegroImp;
function create_bitmap (width, height: cint): PBITMAP; LibraryLibAllegroImp;
function create_system_bitmap (width, height: cint): PBITMAP; LibraryLibAllegroImp;
procedure allegro_exit; LibraryLibAllegroImp;
+ procedure rest (time: cuint); LibraryLibAllegroImp;
+ function install_int_ex (proc: TimerIntCallback; speed: clong): cint; LibraryLibAllegroImp;
+ procedure blit (source, dest: PBITMAP; source_x, source_y, dest_x, dest_y, width, height: cint); LibraryLibAllegroImp;
+ procedure masked_blit (source, dest: PBITMAP; source_x, source_y, dest_x, dest_y, width, height: cint); LibraryLibAllegroImp;
+ procedure set_clip_rect (bitmap: PBITMAP; x1, y1, x2, y2: cint); LibraryLibAllegroImp;
+ procedure get_clip_rect (bitmap: PBITMAP; var x1, y1, x2, y2: cint); LibraryLibAllegroImp;
+
+ procedure set_palette (const p: PALETTE); LibraryLibAllegroImp;
+ procedure set_color_depth (depth: cint); LibraryLibAllegroImp;
+ function set_close_button_callback (proc: QuitCallback): cint; LibraryLibAllegroImp;
+
// function _install_allegro (system_id: cint; errno_prt: Pcint; AtExitFunction): cint; LibraryLibAllegroImp;
+ (* MACRO *)
+ function install_allegro (system_id: cint; errno_ptr: Pcint; atexit_ptr: AtExitFunction): cint; inline;
+ function allegro_init: cint; inline;
+
+ function TIMERS_PER_SECOND: clong; inline;
+ function SECS_TO_TIMER (x: clong): clong; inline;
+ function MSEC_TO_TIMER (x: clong): clong; inline;
+ function BPS_TO_TIMER (x: clong): clong; inline;
+ function BPM_TO_TIMER (x: clong): clong; inline;
+
+(*
+ function acquire_bitmap (bmp: PBITMAP); inline;
+ function release_bitmap (bmp: PBITMAP); inline;
+ function acquire_screen; inline;
+ function release_screen; inline;
+*)
+
+ procedure acquire_bitmap (bmp: PBITMAP); LibraryLibAllegroImp;
+ procedure release_bitmap (bmp: PBITMAP); LibraryLibAllegroImp;
+ procedure acquire_screen; LibraryLibAllegroImp;
+ procedure release_screen; LibraryLibAllegroImp;
+
implementation
+ {$IF DEFINED(GO32V2)}
+ function atexit (func: AtexitCallback): cint; cdecl; external;
+ {$ELSEIF DEFINED(WINDOWS)}
+ function atexit (func: AtexitCallback): cint; cdecl; external 'msvcrt.dll';
+ {$ELSE}
+ function atexit (func: AtexitCallback): cint; cdecl; external 'c';
+ {$ENDIF}
+
function install_allegro (system_id: cint; errno_ptr: Pcint; atexit_ptr: AtExitFunction): cint; inline;
begin
install_allegro := _install_allegro_version_check(system_id, errno_ptr, atexit_ptr, (ALLEGRO_VERSION shl 16) OR (ALEGRO_SUB_VERSION shl 8) OR ALLEGRO_WIP_VERSION)
function allegro_init: cint; inline;
begin
- (* original macros sets atexit_ptr *)
(* original macros sets libc errno? *)
- allegro_init := _install_allegro_version_check(SYSTEM_AUTODETECT, nil, nil, (ALLEGRO_VERSION shl 16) OR (ALEGRO_SUB_VERSION shl 8) OR ALLEGRO_WIP_VERSION)
+ allegro_init := _install_allegro_version_check(SYSTEM_AUTODETECT, nil, @atexit, (ALLEGRO_VERSION shl 16) OR (ALEGRO_SUB_VERSION shl 8) OR ALLEGRO_WIP_VERSION)
+ end;
+
+ function TIMERS_PER_SECOND: clong; inline;
+ begin
+ TIMERS_PER_SECOND := 1193181
+ end;
+
+ function SECS_TO_TIMER (x: clong): clong; inline;
+ begin
+ SECS_TO_TIMER := x * TIMERS_PER_SECOND
+ end;
+
+ function MSEC_TO_TIMER (x: clong): clong; inline;
+ begin
+ MSEC_TO_TIMER := x * TIMERS_PER_SECOND div 1000
+ end;
+
+ function BPS_TO_TIMER (x: clong): clong; inline;
+ begin
+ BPS_TO_TIMER := TIMERS_PER_SECOND div x
+ end;
+
+ function BPM_TO_TIMER (x: clong): clong; inline;
+ begin
+ BPM_TO_TIMER := 60 * TIMERS_PER_SECOND div x
+ end;
+
+(*
+ function acquire_bitmap (bmp: PBITMAP); inline;
+ begin
+ ASSERT(bmp <> nil);
+ if bmp.vtable.acquire <> nil then
+ bmp.vtable.acquire(bmp)
end;
+*)
end.