⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alcompat.inc

📁 著名的游戏开发库Allegro4.2.0 for DELPHI
💻 INC
字号:
{*         ______   ___    ___
 *        /\  _  \ /\_ \  /\_ \
 *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
 *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
 *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
 *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
 *            \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
 *                                           /\____/
 *                                           \_/__/
 *
 *      Backward compatibility stuff.
 *
 *      By Shawn Hargreaves.
 *
 *      See readme.txt for copyright information.
 *}
{$IFDEF ALLEGRO_INTERFACE}
const
  KB_NORMAL      = 1;
  KB_EXTENDED    = 2;

function  is_cpu_fpu: Boolean;
function  is_cpu_mmx: Boolean;
function  is_cpu_3dnow: Boolean;
function  is_cpu_cpuid: Boolean;
function  joy_x: Integer;
function  joy_y: Integer;
function  joy_left: Integer;
function  joy_right: Integer;
function  joy_up: Integer;
function  joy_down: Integer;
function  joy_b1: Integer;
function  joy_b2: Integer;
function  joy_b3: Integer;
function  joy_b4: Integer;
function  joy_b5: Integer;
function  joy_b6: Integer;
function  joy_b7: Integer;
function  joy_b8: Integer;
function  joy2_x: Integer;
function  joy2_y: Integer;
function  joy2_left: Integer;
function  joy2_right: Integer;
function  joy2_up: Integer;
function  joy2_down: Integer;
function  joy2_b1: Integer;
function  joy2_b2: Integer;
function  joy_throttle: Integer;
function  joy_hat: Integer;

const
  JOY_HAT_CENTRE       = 0;
  JOY_HAT_CENTER       = 0;
  JOY_HAT_LEFT         = 1;
  JOY_HAT_DOWN         = 2;
  JOY_HAT_RIGHT        = 3;
  JOY_HAT_UP           = 4;

var
  initialise_joystick: function: sint32; cdecl;

// a pretty vague name
function fix_filename_path(dest: PChar; const filename: PChar; size: sint32): PChar;

const
// the good old file selector
  OLD_FILESEL_WIDTH  = -1;
  OLD_FILESEL_HEIGHT = -1;

function file_select(const messages: PChar; path: PChar; const ext: PChar): sint32;

type
  for_ptr = procedure(const filename: PChar; attirb, param: sint32);

var
  for_each_file: function(const name: PChar; attrib: sint32; callback: for_ptr; param: sint32): sint32; cdecl;
  // the old state-based textout functions
  _textmode: p_sint32;
  text_mode: function(mode: sint32): sint32; cdecl;

procedure textout(bmp: P_BITMAP; const f: P_FONT; const str: PChar; x, y, color: sint32);
procedure textout_centre(bmp: P_BITMAP; const f: P_FONT; const str: PChar; x, y, color: sint32);
procedure textout_right(bmp: P_BITMAP; const f: P_FONT; const str: PChar; x, y, color: sint32);
procedure textout_justify(bmp: P_BITMAP; const f: P_FONT; const str: PChar; x1, x2, y, diff, color: sint32);

var
  textprintf: procedure(bmp: P_BITMAP; const f: P_FONT; x, y, color: sint32; const format: PChar; arglist: va_list); cdecl;
  textprintf_centre: procedure(bmp: P_BITMAP; const f: P_FONT; x, y, color: sint32; const format: PChar; arglist: va_list); cdecl;
  textprintf_right: procedure(bmp: P_BITMAP; const f: P_FONT; x, y, color: sint32; const format: PChar; arglist: va_list); cdecl;
  textprintf_justify: procedure(bmp: P_BITMAP; const f: P_FONT; x1, x2, y, diff, color: sint32; const format: PChar; arglist: va_list); cdecl;

procedure draw_character(bmp, sprite: P_BITMAP; x, y, color: sint32);
function gui_textout(bmp: P_BITMAP; const s: PChar; x, y, color, centre: sint32): sint32;
function set_window_close_button(enable: Boolean): sint32;
procedure set_window_close_hook(proc: proc_ptr);

var
  // the weird old clipping API
  set_clip: procedure(bitmap: P_BITMAP; x1, y1, x2, y2: sint32); cdecl;

// unnecessary, can use rest(0)
procedure yield_timeslice;

var
  // DOS-ish monitor retrace ideas that don't work elsewhere
  retrace_proc: ^proc_ptr;

  timer_can_simulate_retrace: function: sint32; cdecl;
  timer_simulate_retrace: procedure(enable: sint32); cdecl;
  timer_is_using_retrace: function: sint32; cdecl;

{$ENDIF ALLEGRO_INTERFACE}
{$IFDEF ALLEGRO_IMPLEMENTATION}
function  is_cpu_fpu: Boolean;
begin result := (cpu_capabilities^ and CPU_FPU) <> 0; end;
function  is_cpu_mmx: Boolean;
begin result := (cpu_capabilities^ and CPU_MMX) <> 0; end;
function  is_cpu_3dnow: Boolean;
begin result := (cpu_capabilities^ and CPU_3DNOW) <> 0; end;
function  is_cpu_cpuid: Boolean;
begin result := (cpu_capabilities^ and CPU_ID) <> 0; end;
function  joy_x: Integer;
begin result := joy^[0].stick[0].axis[0].pos; end;
function  joy_y: Integer;
begin result := joy^[0].stick[0].axis[1].pos; end;
function  joy_left: Integer;
begin result := joy^[0].stick[0].axis[0].d1; end;
function  joy_right: Integer;
begin result := joy^[0].stick[0].axis[0].d2; end;
function  joy_up: Integer;
begin result := joy^[0].stick[0].axis[1].d1; end;
function  joy_down: Integer;
begin result := joy^[0].stick[0].axis[1].d2; end;
function  joy_b1: Integer;
begin result := joy^[0].button[0].b; end;
function  joy_b2: Integer;
begin result := joy^[0].button[1].b; end;
function  joy_b3: Integer;
begin result := joy^[0].button[2].b; end;
function  joy_b4: Integer;
begin result := joy^[0].button[3].b; end;
function  joy_b5: Integer;
begin result := joy^[0].button[4].b; end;
function  joy_b6: Integer;
begin result := joy^[0].button[5].b; end;
function  joy_b7: Integer;
begin result := joy^[0].button[6].b; end;
function  joy_b8: Integer;
begin result := joy^[0].button[7].b; end;
function  joy2_x: Integer;
begin result := joy^[1].stick[0].axis[0].pos; end;
function  joy2_y: Integer;
begin result := joy^[1].stick[0].axis[1].pos; end;
function  joy2_left: Integer;
begin result := joy^[1].stick[0].axis[0].d1; end;
function  joy2_right: Integer;
begin result := joy^[1].stick[0].axis[0].d2; end;
function  joy2_up: Integer;
begin result := joy^[1].stick[0].axis[1].d1; end;
function  joy2_down: Integer;
begin result := joy^[1].stick[0].axis[1].d2; end;
function  joy2_b1: Integer;
begin result := joy^[1].button[0].b; end;
function  joy2_b2: Integer;
begin result := joy^[1].button[1].b; end;
function  joy_throttle: Integer;
begin result := joy^[0].stick[2].axis[0].pos; end;
function  joy_hat: Integer;
begin
  if joy^[0].stick[1].axis[0].d1 <> 0 then
    result := 1
  else
  if joy^[0].stick[1].axis[0].d2 <> 0 then
    result := 3
  else
  if joy^[0].stick[1].axis[1].d1 <> 0 then
    result := 4
  else
  if joy^[0].stick[1].axis[1].d2 <> 0 then
    result := 2
  else
    result := 0;
end;

function fix_filename_path(dest: PChar; const filename: PChar; size: sint32): PChar;
begin
  Result := canonicalize_filename(dest, filename, size);
end;

function file_select(const messages: PChar; path: PChar; const ext: PChar): sint32;
begin
  Result := file_select_ex(messages, path, ext, 1024, OLD_FILESEL_WIDTH, OLD_FILESEL_HEIGHT);
end;

procedure textout(bmp: P_BITMAP; const f: P_FONT; const str: PChar; x, y, color: sint32);
begin
  textout_ex(bmp, f, str, x, y, color, _textmode^);
end;

procedure textout_centre(bmp: P_BITMAP; const f: P_FONT; const str: PChar; x, y, color: sint32);
begin
  textout_centre_ex(bmp, f, str, x, y, color, _textmode^);
end;

procedure textout_right(bmp: P_BITMAP; const f: P_FONT; const str: PChar; x, y, color: sint32);
begin
  textout_right_ex(bmp, f, str, x, y, color, _textmode^);
end;

procedure textout_justify(bmp: P_BITMAP; const f: P_FONT; const str: PChar; x1, x2, y, diff, color: sint32);
begin
   textout_justify_ex(bmp, f, str, x1, x2, y, diff, color, _textmode^);
end;

procedure draw_character(bmp, sprite: P_BITMAP; x, y, color: sint32);
begin
   draw_character_ex(bmp, sprite, x, y, color, _textmode^);
end;

function gui_textout(bmp: P_BITMAP; const s: PChar; x, y, color, centre: sint32): sint32;
begin
  Result := gui_textout_ex(bmp, s, x, y, color, _textmode^, centre);
end;

function set_window_close_button(enable: Boolean): sint32;
begin
  Result := 0;
end;

procedure set_window_close_hook(proc: proc_ptr);
begin
   set_close_button_callback(proc);
end;

procedure yield_timeslice;
begin
  assert(the_system_driver^ <> nil);

  if @the_system_driver^.yield_timeslice <> nil then
    the_system_driver^.yield_timeslice();
end;
{$ENDIF ALLEGRO_IMPLEMENTATION}
{$IFDEF ALLEGRO_LOADVARIABLE}
  initialise_joystick        := LoadDLL('initialise_joystick');
  for_each_file              := LoadDLL('for_each_file');
  text_mode                  := LoadDLL('text_mode');
  textprintf                 := LoadDLL('textprintf');
  textprintf_centre          := LoadDLL('textprintf_centre');
  textprintf_right           := LoadDLL('textprintf_right');
  textprintf_justify         := LoadDLL('textprintf_justify');
  set_clip                   := LoadDLL('set_clip');
  retrace_proc               := LoadDLL('retrace_proc');
  timer_can_simulate_retrace := LoadDLL('timer_can_simulate_retrace');
  timer_simulate_retrace     := LoadDLL('timer_simulate_retrace');
  timer_is_using_retrace     := LoadDLL('timer_is_using_retrace');
{$ENDIF ALLEGRO_LOADVARIABLE}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -