X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Flib%2Fallegro4%2Fallegro.pas;h=0560035d927097633e50020754300fea258a49ca;hb=23c3f9ee3fc3837cd1d0380496a2e1b0f87833d8;hp=0a1affef875346d773a0cdf9d01b6ad273800576;hpb=ed750d2e31615702f9c230ef4aabe890ea55abab;p=d2df-sdl.git diff --git a/src/lib/allegro4/allegro.pas b/src/lib/allegro4/allegro.pas index 0a1affe..0560035 100644 --- a/src/lib/allegro4/allegro.pas +++ b/src/lib/allegro4/allegro.pas @@ -8,13 +8,14 @@ {$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; @@ -24,18 +25,16 @@ interface 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; @@ -231,6 +230,45 @@ interface 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; + RGB = record r, g, b, filler: cuchar; end; @@ -238,21 +276,30 @@ interface 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; function get_desktop_resolution (width, height: Pcint): cint; LibraryLibAllegroImp; function get_gfx_mode_list (card: cint): PGFX_MODE_LIST; LibraryLibAllegroImp; @@ -267,9 +314,6 @@ interface 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; @@ -298,18 +342,71 @@ interface 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; + (* 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) @@ -317,13 +414,10 @@ implementation 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 @@ -349,4 +443,13 @@ implementation 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.