source: buchla-68k/ram/select.c@ 6262b5c

Last change on this file since 6262b5c was 6262b5c, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Added include files for global functions and variables.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 =============================================================================
3 select.c -- field selection processing
4 Version 9 -- 1988-12-13 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define DEBUGIT 0
9
10#include "all.h"
11
12#if DEBUGIT
13extern short debugsw;
14
15short debugsf = 1;;
16#endif
17
18extern int16_t cxval, cyval, astat;
19
20extern int16_t cursbox; /* currently selected box */
21extern int16_t hitbox; /* box we just hit */
22extern int16_t hitcx, hitcy; /* x,y of cursor when we hit the box */
23
24extern struct selbox *csbp; /* current select box table pointer */
25extern struct selbox *curboxp; /* current select box pointer */
26
27/*
28
29*/
30
31/*
32 =============================================================================
33 whatbox() -- determine which selection box a hit occured in
34 =============================================================================
35*/
36
37int16_t whatbox(void)
38{
39 register struct selbox *sb;
40
41 sb = csbp;
42 hitbox = -1;
43
44#if DEBUGIT
45 if (debugsw AND debugsf)
46 printf("whatbox(): ENTRY cxval=%d cyval=%d cursbox=%d csbp=$%lX\n",
47 cxval, cyval, cursbox, csbp);
48#endif
49
50 if (0L EQ sb)
51 return(FALSE);
52
53 while (sb->boxhit) {
54
55 hitbox++;
56
57 if ((cxval GE sb->sbxmin) AND
58 (cxval LE sb->sbxmax) AND
59 (cyval GE sb->sbymin) AND
60 (cyval LE sb->sbymax)) {
61
62 hitcx = cxval;
63 hitcy = cyval;
64 curboxp = sb;
65
66#if DEBUGIT
67 if (debugsw AND debugsf)
68 printf("whatbox(): HIT hitbox=%d, curboxp=$%lX, sbarg=$%04.4X\n",
69 hitbox, curboxp, sb->sbarg);
70#endif
71
72 return(TRUE);
73 }
74
75 sb++;
76 }
77
78#if DEBUGIT
79 if (debugsw AND debugsf)
80 printf("whatbox(): FAILED\n");
81#endif
82
83 hitbox = -1;
84 return(FALSE);
85}
86
87/*
88
89*/
90
91/*
92 =============================================================================
93 select() -- standard item selection processing
94 =============================================================================
95*/
96
97void select(void)
98{
99 if (astat) { /* only when the E key goes down */
100
101#if DEBUGIT
102 if (debugsw AND debugsf)
103 printf("select(): ENTRY\n");
104#endif
105
106 if (whatbox()) { /* see if we're in a box */
107
108#if DEBUGIT
109 if (debugsw AND debugsf)
110 printf("select(): HIT hitbox = %d curboxp $%lX\n",
111 hitbox, curboxp);
112#endif
113
114 (*curboxp->boxhit)(curboxp->sbarg); /* process it */
115 cursbox = hitbox;
116
117 } else {
118
119#if DEBUGIT
120 if (debugsw AND debugsf)
121 printf("select(): FAILED\n");
122#endif
123
124 }
125 }
126}
127
Note: See TracBrowser for help on using the repository browser.