index 0a1affef875346d773a0cdf9d01b6ad273800576..d2483528bd2abc3372b576d0127ba2a350c787c1 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;
mode: PGFX_MODE;
end;
+ PGFX_DRIVER_T = ^GFX_DRIVER_T;
+ GFX_DRIVER_T = record
+ id: cint;
+ name: PChar;
+ desc: PChar;
+ ascii_name: PChar;
+
+ init: Pointer;
+ exit: Pointer;
+ scroll: Pointer;
+ vsync: Pointer;
+ set_palette: Pointer;
+ request_scroll: Pointer;
+ poll_scroll: Pointer;
+ enable_triple_buffer: Pointer;
+ create_video_bitmap: Pointer;
+ destroy_video_bitmap: Pointer;
+ show_video_bitmap: Pointer;
+ request_video_bitmap: Pointer;
+ create_system_bitmap: Pointer;
+ destroy_system_bitmap: Pointer;
+ set_mouse_sprite: Pointer;
+ show_mouse: Pointer;
+ hide_mouse: Pointer;
+ move_mouse: Pointer;
+ drawing_mode: Pointer;
+ save_video_state: Pointer;
+ restore_video_state: Pointer;
+ set_blender_mode: Pointer;
+ fetch_mode_list: function (): PGFX_MODE_LIST; cdecl;
+ w, h: cint;
+ linear: cint;
+ bank_size: clong;
+ bank_gran: clong;
+ vid_mem: clong;
+ vid_phys_base: clong;
+ windowed: cint;
+ end;
+
+ PRGB = ^RGB;
RGB = record
r, g, b, filler: cuchar;
end;
PALETTE = array [0..PAL_SIZE - 1] of RGB;
PPALETTE = ^PALETTE;
+ COLOR_MAP_T = record
+ data: array [0..PAL_SIZE - 1, 0..PAL_SIZE - 1] of cuchar;
+ end;
+ PCOLOR_MAP_T = ^COLOR_MAP_T;
+
KeyboardCallback = procedure (scancode: cint); LibraryLibAllegroDecl;
AtExitCallback = procedure; LibraryLibAllegroDecl;
AtExitFunction = function (func: AtExitCallback): cint; LibraryLibAllegroDecl;
TimerIntCallback = procedure; LibraryLibAllegroDecl;
+ QuitCallback = procedure; LibraryLibAllegroDecl;
+ CreateTableCallback = procedure (pos: cint); 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;
+ key_shifts: cint; LibraryLibAllegroVar;
+ color_map: PCOLOR_MAP_T; LibraryLibAllegroVar;
+ gfx_driver: PGFX_DRIVER_T; LibraryLibAllegroVar;
+ palette_color: array [0..255] of cint; 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;
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;
+ procedure acquire_bitmap (bmp: PBITMAP); LibraryLibAllegroImp;
+ procedure release_bitmap (bmp: PBITMAP); LibraryLibAllegroImp;
+ procedure acquire_screen; LibraryLibAllegroImp;
+ procedure release_screen; LibraryLibAllegroImp;
+
+ procedure rotate_sprite (bmp, sprite: PBITMAP; x, y: cint; a: cint32); LibraryLibAllegroImp;
+ procedure rotate_sprite_v_flip (bmp, sprite: PBITMAP; x, y: cint; a: cint32); LibraryLibAllegroImp;
+
+ function scancode_to_ascii (scancode: cint): cint; LibraryLibAllegroImp;
+ function scancode_to_name (scancode: cint): PChar; LibraryLibAllegroImp;
+
+ procedure drawing_mode (mode: cint; pattern: PBITMAP; x_anchor, y_anchor: cint); LibraryLibAllegroImp;
+
+ procedure set_trans_blender (r, g, b, a: cint); LibraryLibAllegroImp;
+ procedure set_alpha_blender; LibraryLibAllegroImp;
+ procedure set_write_alpha_blender; LibraryLibAllegroImp;
+ procedure set_add_blender (r, g, b, a: cint); LibraryLibAllegroImp;
+ procedure set_burn_blender (r, g, b, a: cint); LibraryLibAllegroImp;
+ procedure set_color_blender (r, g, b, a: cint); LibraryLibAllegroImp;
+ procedure set_difference_blender (r, g, b, a: cint); LibraryLibAllegroImp;
+ procedure set_dissolve_blender (r, g, b, a: cint); LibraryLibAllegroImp;
+ procedure set_dodge_blender (r, g, b, a: cint); LibraryLibAllegroImp;
+ procedure set_hue_blender (r, g, b, a: cint); LibraryLibAllegroImp;
+ procedure set_invert_blender (r, g, b, a: cint); LibraryLibAllegroImp;
+ procedure set_luminance_blender (r, g, b, a: cint); LibraryLibAllegroImp;
+ procedure set_multiply_blender (r, g, b, a: cint); LibraryLibAllegroImp;
+ procedure set_saturation_blender (r, g, b, a: cint); LibraryLibAllegroImp;
+ procedure set_screen_blender (r, g, b, a: cint); LibraryLibAllegroImp;
+
+ function getr (col: cint): cint; LibraryLibAllegroImp;
+ function getg (col: cint): cint; LibraryLibAllegroImp;
+ function getb (col: cint): cint; LibraryLibAllegroImp;
+ function geta (col: cint): cint; LibraryLibAllegroImp;
+
+ procedure create_light_table (table: PCOLOR_MAP_T; const pal: PALETTE; r, g, b: cint; callback: CreateTableCallback); LibraryLibAllegroImp;
+ procedure create_trans_table (table: PCOLOR_MAP_T; const pal: PALETTE; r, g, b: cint; callback: CreateTableCallback); LibraryLibAllegroImp;
+
+ procedure vsync; LibraryLibAllegroImp;
+ function desktop_color_depth: cint; LibraryLibAllegroImp;
+
+ procedure select_palette (const p: PALETTE); LibraryLibAllegroImp;
+ procedure unselect_palette; LibraryLibAllegroImp;
+ procedure set_color (index: cint; const p: PRGB); 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;
+
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
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.