fredi пишет:
цитата: |
А Ft_ontick из Nanfor тикает, когда ... ? |
|
* $SYNTAX$
* FT_OnTick( bCode, nInterval )
* $ARGUMENTS$
* <bCode> is the code block to evaluate.
* <nInterval> is the number of clock ticks to wait between
* evaluations of the code block.
* $RETURNS$
* NIL
***************************
Исходник
***************************
#include <EXTEND.API>
#include <ITEM.API>
#include <CPMI.H>
typedef union
{
long far * Address;
struct
{
unsigned int Offset;
unsigned int Segment;
} Pointer;
} LONGPTR;
void cdecl _evLow( unsigned int, void *, unsigned int );
void cdecl _bcopy( void *, void *, unsigned int );
static long far Ticks = 0;
static long far Interval = 1;
static ITEM far codeBlock;
static char inProgress = 0;
static void cdecl TickTock( void )
{
auto unsigned int ProtMode = cpmiIsProtected();
auto LONGPTR Timer;
auto EVALINFO eval;
if ( inProgress ) return;
inProgress = 1;
if ( ProtMode )
{
Timer.Pointer.Segment = cpmiProtectedPtr( ( long * ) ( 0x0000046C ), sizeof( long ) );
Timer.Pointer.Offset = 0;
if ( Timer.Pointer.Segment == 0 ) goto Exit;
}
else
Timer.Address = ( long * ) ( 0x0000046C );
if ( *Timer.Address >= ( Ticks + Interval ) ||
( *Timer.Address < Ticks ) )
{
Ticks = *Timer.Address;
_evalNew( &eval, codeBlock );
_itemRelease( _evalLaunch( &eval ) );
}
if ( ProtMode ) cpmiFreeSelector( Timer.Pointer.Segment );
Exit: inProgress = 0;
return;
}
CLIPPER FT_OnTick( void )
{
if ( _itemType( codeBlock ) == BLOCK ) _itemRelease( codeBlock );
codeBlock = _itemParam( 1 );
if ( _itemType( codeBlock ) == BLOCK )
{
Interval = _parnl( 2 );
_evLow( 5, TickTock, TRUE );
}
else
_evLow( 5, TickTock, FALSE );
return;
}