diff options
Diffstat (limited to 'byterun/rotatecursor.c')
-rw-r--r-- | byterun/rotatecursor.c | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/byterun/rotatecursor.c b/byterun/rotatecursor.c index 7048cd9a6..ddb06113b 100644 --- a/byterun/rotatecursor.c +++ b/byterun/rotatecursor.c @@ -12,6 +12,14 @@ /* $Id$ */ +/* rotatecursor library, written by <Damien.Doligez@inria.fr> + This file is in the public domain. + + version 1.12.2 + + See rotatecursor.h for documentation. +*/ + #include <CursorCtl.h> #include <MacTypes.h> #include <stdlib.h> @@ -29,6 +37,7 @@ int volatile rotatecursor_flag = 1; static int rotatecursor_inited = 0; static int rotatecursor_period = 50; static Xtmtask rotatecursor_tmtask; +static pascal void (*rotatecursor_action) (long) = &RotateCursor; #if GENERATINGCFM @@ -39,7 +48,7 @@ static void rotatecursor_timerproc (Xtmtask *p) if (p->p2 != NULL && *(p->p2) == 0) *(p->p2) = 1; } -#else +#else /* GENERATINGCFM */ extern Xtmtask *getparam() ONEWORDINLINE(0x2009); /* MOVE.L A1, D0 */ @@ -51,51 +60,52 @@ static void rotatecursor_timerproc (void) if (p->p2 != NULL && *(p->p2) == 0) *(p->p2) = 1; } -#endif /* GENERATINGCFM */ +#endif /* else GENERATINGCFM */ -static void rotatecursor_remove_task (void) +void rotatecursor_final (void) { - RmvTime ((QElemPtr) &rotatecursor_tmtask); + if (rotatecursor_inited){ + RmvTime ((QElemPtr) &rotatecursor_tmtask); + rotatecursor_flag = 1; + rotatecursor_inited = 0; + } } static void rotatecursor_init (void) { if (rotatecursor_inited) return; - InitCursorCtl (NULL); - rotatecursor_tmtask.t.tmAddr = NewTimerProc (rotatecursor_timerproc); + rotatecursor_tmtask.t.tmCount = 0; rotatecursor_tmtask.t.tmWakeUp = 0; rotatecursor_tmtask.t.tmReserved = 0; rotatecursor_tmtask.p1 = NULL; rotatecursor_tmtask.p2 = &rotatecursor_flag; InsTime ((QElemPtr) &rotatecursor_tmtask); - PrimeTime ((QElemPtr) &rotatecursor_tmtask, 1); - - atexit (rotatecursor_remove_task); + atexit (rotatecursor_final); + rotatecursor_flag = 1; rotatecursor_inited = 1; } -void rotatecursor_options (int volatile *p1, int period) +void rotatecursor_options (int volatile *p1, int period, pascal void (*f) (long)) { if (!rotatecursor_inited) rotatecursor_init (); - + rotatecursor_tmtask.p1 = p1; - rotatecursor_period = period; + if (p1 != NULL && *p1 == 0) *p1 = rotatecursor_flag; + rotatecursor_period = (period == 0) ? 50 : period; + rotatecursor_action = (f == NULL) ? &RotateCursor : f; } -int rotatecursor_action (int reverse) +int rotatecursor_ticker (void) { if (!rotatecursor_inited) rotatecursor_init (); rotatecursor_flag = 0; - PrimeTime ((QElemPtr) &rotatecursor_tmtask, rotatecursor_period); - - RotateCursor (reverse ? -32 : 32); - + (*rotatecursor_action) (32); return 0; } |