source: buchla-68k/ram/select.c@ 0c834c5

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

Point of no return.

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