summaryrefslogtreecommitdiffstats
path: root/byterun/rotatecursor.c
blob: ad75c24c7e08ccbd67684cf5ba9f13be504cb6a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/***********************************************************************/
/*                                                                     */
/*                           Objective Caml                            */
/*                                                                     */
/*            Damien Doligez, projet Para, INRIA Rocquencourt          */
/*                                                                     */
/*  Copyright 1996 Institut National de Recherche en Informatique et   */
/*  en Automatique.  Distributed only by permission.                   */
/*                                                                     */
/***********************************************************************/

/* $Id$ */

/* Cursor rotation for MPW tools (ocamlrun and ocamlyacc) */

#include <CursorCtl.h>
#include <stdlib.h>
#include <Timer.h>
#include <Types.h>

#include "rotatecursor.h"

int volatile have_to_interact;

typedef struct {
  TMTask t;
  int volatile *p1;
  int volatile *p2;
} Xtmtask;

static Xtmtask mytmtask;


#if GENERATINGCFM

static void mytimerproc (Xtmtask *p)
{
  if (p->p1 != NULL && *(p->p1) == 0) *(p->p1) = 1;
  if (p->p2 != NULL && *(p->p2) == 0) *(p->p2) = 1;
}

#else

extern Xtmtask *getparam() ONEWORDINLINE(0x2009);  /* MOVE.L A1, D0 */

static void mytimerproc (void)
{
  register Xtmtask *p = getparam ();

  if (p->p1 != NULL) *(p->p1) = 1;
  if (p->p2 != NULL) *(p->p2) = 1;
}

#endif /* GENERATINGCFM */


static void remove_task (void)
{
  RmvTime ((QElemPtr) &mytmtask);
}

void rotatecursor_init (int volatile *p1)
{
  InitCursorCtl (NULL);
  mytmtask.t.tmAddr = NewTimerProc (mytimerproc);
  mytmtask.t.tmWakeUp = 0;
  mytmtask.t.tmReserved = 0;
  mytmtask.p1 = p1;
  mytmtask.p2 = &have_to_interact;
  InsTime ((QElemPtr) &mytmtask);
  PrimeTime ((QElemPtr) &mytmtask, 1);
  atexit (remove_task);
}

int rotatecursor_action (int reverse)
{
  PrimeTime ((QElemPtr) &mytmtask, 50);     /* 20 Hz */
  RotateCursor (reverse ? -32 : 32);
  return 0;
}