1996-11-02 10:00:46 -08:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Objective Caml */
|
|
|
|
/* */
|
|
|
|
/* Damien Doligez, projet Para, INRIA Rocquencourt */
|
|
|
|
/* */
|
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1999-11-17 10:59:06 -08:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../LICENSE. */
|
1996-11-02 10:00:46 -08:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2000-04-05 11:30:22 -07:00
|
|
|
/* rotatecursor library, written by <Damien.Doligez@inria.fr>
|
|
|
|
This file is in the public domain.
|
|
|
|
|
2000-04-17 13:01:40 -07:00
|
|
|
version 1.13
|
2000-04-05 11:30:22 -07:00
|
|
|
|
|
|
|
See rotatecursor.h for documentation.
|
|
|
|
*/
|
|
|
|
|
1996-11-02 10:00:46 -08:00
|
|
|
#include <CursorCtl.h>
|
1999-11-08 09:11:23 -08:00
|
|
|
#include <MacTypes.h>
|
1996-11-02 10:00:46 -08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <Timer.h>
|
|
|
|
|
|
|
|
#include "rotatecursor.h"
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
TMTask t;
|
|
|
|
int volatile *p1;
|
|
|
|
int volatile *p2;
|
|
|
|
} Xtmtask;
|
|
|
|
|
1999-11-08 09:11:23 -08:00
|
|
|
int volatile rotatecursor_flag = 1;
|
|
|
|
static int rotatecursor_inited = 0;
|
|
|
|
static int rotatecursor_period = 50;
|
|
|
|
static Xtmtask rotatecursor_tmtask;
|
2000-04-05 11:30:22 -07:00
|
|
|
static pascal void (*rotatecursor_action) (long) = &RotateCursor;
|
1996-11-02 10:00:46 -08:00
|
|
|
|
|
|
|
|
|
|
|
#if GENERATINGCFM
|
|
|
|
|
1999-11-08 09:11:23 -08:00
|
|
|
static void rotatecursor_timerproc (Xtmtask *p)
|
1996-11-02 10:00:46 -08:00
|
|
|
{
|
|
|
|
if (p->p1 != NULL && *(p->p1) == 0) *(p->p1) = 1;
|
|
|
|
if (p->p2 != NULL && *(p->p2) == 0) *(p->p2) = 1;
|
|
|
|
}
|
|
|
|
|
2000-04-05 11:30:22 -07:00
|
|
|
#else /* GENERATINGCFM */
|
1996-11-02 10:00:46 -08:00
|
|
|
|
|
|
|
extern Xtmtask *getparam() ONEWORDINLINE(0x2009); /* MOVE.L A1, D0 */
|
|
|
|
|
1999-11-08 09:11:23 -08:00
|
|
|
static void rotatecursor_timerproc (void)
|
1996-11-02 10:00:46 -08:00
|
|
|
{
|
|
|
|
register Xtmtask *p = getparam ();
|
1998-10-02 06:02:32 -07:00
|
|
|
|
1999-11-08 09:11:23 -08:00
|
|
|
if (p->p1 != NULL && *(p->p1) == 0) *(p->p1) = 1;
|
|
|
|
if (p->p2 != NULL && *(p->p2) == 0) *(p->p2) = 1;
|
1996-11-02 10:00:46 -08:00
|
|
|
}
|
|
|
|
|
2000-04-05 11:30:22 -07:00
|
|
|
#endif /* else GENERATINGCFM */
|
1996-11-02 10:00:46 -08:00
|
|
|
|
|
|
|
|
2000-04-05 11:30:22 -07:00
|
|
|
void rotatecursor_final (void)
|
1996-11-02 10:00:46 -08:00
|
|
|
{
|
2000-04-05 11:30:22 -07:00
|
|
|
if (rotatecursor_inited){
|
|
|
|
RmvTime ((QElemPtr) &rotatecursor_tmtask);
|
|
|
|
rotatecursor_flag = 1;
|
|
|
|
rotatecursor_inited = 0;
|
|
|
|
}
|
1996-11-02 10:00:46 -08:00
|
|
|
}
|
|
|
|
|
1999-11-08 09:11:23 -08:00
|
|
|
static void rotatecursor_init (void)
|
1996-11-02 10:00:46 -08:00
|
|
|
{
|
1999-11-08 09:11:23 -08:00
|
|
|
if (rotatecursor_inited) return;
|
|
|
|
|
|
|
|
rotatecursor_tmtask.t.tmAddr = NewTimerProc (rotatecursor_timerproc);
|
2000-04-05 11:30:22 -07:00
|
|
|
rotatecursor_tmtask.t.tmCount = 0;
|
1999-11-08 09:11:23 -08:00
|
|
|
rotatecursor_tmtask.t.tmWakeUp = 0;
|
|
|
|
rotatecursor_tmtask.t.tmReserved = 0;
|
|
|
|
rotatecursor_tmtask.p1 = NULL;
|
|
|
|
rotatecursor_tmtask.p2 = &rotatecursor_flag;
|
|
|
|
|
|
|
|
InsTime ((QElemPtr) &rotatecursor_tmtask);
|
2000-04-05 11:30:22 -07:00
|
|
|
atexit (rotatecursor_final);
|
|
|
|
rotatecursor_flag = 1;
|
1999-11-08 09:11:23 -08:00
|
|
|
|
|
|
|
rotatecursor_inited = 1;
|
|
|
|
}
|
|
|
|
|
2000-04-05 11:30:22 -07:00
|
|
|
void rotatecursor_options (int volatile *p1, int period, pascal void (*f) (long))
|
1999-11-08 09:11:23 -08:00
|
|
|
{
|
|
|
|
if (!rotatecursor_inited) rotatecursor_init ();
|
2000-04-05 11:30:22 -07:00
|
|
|
|
1999-11-08 09:11:23 -08:00
|
|
|
rotatecursor_tmtask.p1 = p1;
|
2000-04-05 11:30:22 -07:00
|
|
|
if (p1 != NULL && *p1 == 0) *p1 = rotatecursor_flag;
|
|
|
|
rotatecursor_period = (period == 0) ? 50 : period;
|
|
|
|
rotatecursor_action = (f == NULL) ? &RotateCursor : f;
|
1996-11-02 10:00:46 -08:00
|
|
|
}
|
|
|
|
|
2000-04-17 13:01:40 -07:00
|
|
|
int rotatecursor_rearm (void)
|
1996-11-02 10:00:46 -08:00
|
|
|
{
|
1999-11-08 09:11:23 -08:00
|
|
|
if (!rotatecursor_inited) rotatecursor_init ();
|
2000-04-17 13:01:40 -07:00
|
|
|
|
1999-11-08 09:11:23 -08:00
|
|
|
rotatecursor_flag = 0;
|
|
|
|
PrimeTime ((QElemPtr) &rotatecursor_tmtask, rotatecursor_period);
|
2000-04-17 13:01:40 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rotatecursor_ticker (void)
|
|
|
|
{
|
|
|
|
if (!rotatecursor_inited) rotatecursor_init ();
|
|
|
|
|
|
|
|
rotatecursor_rearm ();
|
2000-04-05 11:30:22 -07:00
|
|
|
(*rotatecursor_action) (32);
|
1996-11-02 10:00:46 -08:00
|
|
|
return 0;
|
|
|
|
}
|