📄 timer.inc
字号:
{* ______ ___ ___
* /\ _ \ /\_ \ /\_ \
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
* \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
* \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
* \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
* /\____/
* \_/__/
*
* Timer routines.
*
* By Shawn Hargreaves.
*
* See readme.txt for copyright information.
*}
{$IFDEF ALLEGRO_INTERFACE}
const
TIMERS_PER_SECOND = 1193181;
function SECS_TO_TIMER(x: sint32): sint32;
function MSEC_TO_TIMER(x: sint32): sint32;
function BPS_TO_TIMER(x: sint32): sint32;
function BPM_TO_TIMER(x: sint32): sint32;
type
time_param_ptr = procedure(param: Pointer); cdecl;
P_TIMER_DRIVER = ^TIMER_DRIVER;
TIMER_DRIVER = record
id : sint32;
name : PChar;
desc : PChar;
ascii_name : PChar;
init : function: sint32; cdecl;
exit : procedure; cdecl;
install_int : function(proc: proc_ptr; speed: sint32): sint32; cdecl;
remove_int : procedure(proc: proc_ptr); cdecl;
install_param_int : function(proc: time_param_ptr; param: Pointer; speed: sint32): sint32; cdecl;
remove_param_int : procedure(proc: time_param_ptr; param: Pointer); cdecl;
can_simulate_retrace : function: sint32; cdecl;
simulate_retrace : procedure(enable: sint32); cdecl;
rest : procedure(time: uint32; callback: proc_ptr); cdecl;
end;
var
the_timer_driver : ^P_TIMER_DRIVER;
_timer_driver_list : P_DRIVER_INFO;
install_timer : function: sint32; cdecl;
remove_timer : procedure; cdecl;
install_int_ex : function(proc: proc_ptr; speed: sint32): sint32; cdecl;
install_int : function(proc: proc_ptr; speed: sint32): sint32; cdecl;
remove_int : procedure(proc: proc_ptr); cdecl;
install_param_int_ex : function(proc: time_param_ptr; param: Pointer; speed: sint32): sint32; cdecl;
install_param_int : function(proc: time_param_ptr; param: Pointer; speed: sint32): sint32; cdecl;
remove_param_int : procedure(proc: time_param_ptr; param: Pointer); cdecl;
retrace_count : ^sint32;
rest : procedure(time: uint32); cdecl;
rest_callback : procedure(time: uint32; callback: proc_ptr); cdecl;
{$ENDIF ALLEGRO_INTERFACE}
{$IFDEF ALLEGRO_IMPLEMENTATION}
function SECS_TO_TIMER(x: sint32): sint32;
begin
Result := x * TIMERS_PER_SECOND;
end;
function MSEC_TO_TIMER(x: sint32): sint32;
begin
Result := x * (TIMERS_PER_SECOND div 1000);
end;
function BPS_TO_TIMER(x: sint32): sint32;
begin
Result := (TIMERS_PER_SECOND div x);
end;
function BPM_TO_TIMER(x: sint32): sint32;
begin
Result := ((60 * TIMERS_PER_SECOND) div (x));
end;
{$ENDIF ALLEGRO_IMPLEMENTATION}
{$IFDEF ALLEGRO_LOADVARIABLE}
the_timer_driver := LoadDLL('timer_driver');
_timer_driver_list := LoadDLL('_timer_driver_list');
install_timer := LoadDLL('install_timer');
remove_timer := LoadDLL('remove_timer');
install_int_ex := LoadDLL('install_int_ex');
install_int := LoadDLL('install_int');
remove_int := LoadDLL('remove_int');
install_param_int_ex := LoadDLL('install_param_int_ex');
install_param_int := LoadDLL('install_param_int');
remove_param_int := LoadDLL('remove_param_int');
retrace_count := LoadDLL('retrace_count');
rest := LoadDLL('rest');
rest_callback := LoadDLL('rest_callback');
{$ENDIF ALLEGRO_LOADVARIABLE}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -