source: buchla-68k/orig/RAM/SELECT.C@ e2707e9

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

Imported original source code.

  • Property mode set to 100755
File size: 2.5 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
39whatbox()
40{
41 register struct selbox *sb;
42
43 sb = csbp;
44 hitbox = -1;
45
46#if DEBUGIT
47 if (debugsw AND debugsf)
48 printf("whatbox(): ENTRY cxval=%d cyval=%d cursbox=%d csbp=$%lX\n",
49 cxval, cyval, cursbox, csbp);
50#endif
51
52 if (0L EQ sb)
53 return(FALSE);
54
55 while (sb->boxhit) {
56
57 hitbox++;
58
59 if ((cxval GE sb->sbxmin) AND
60 (cxval LE sb->sbxmax) AND
61 (cyval GE sb->sbymin) AND
62 (cyval LE sb->sbymax)) {
63
64 hitcx = cxval;
65 hitcy = cyval;
66 curboxp = sb;
67
68#if DEBUGIT
69 if (debugsw AND debugsf)
70 printf("whatbox(): HIT hitbox=%d, curboxp=$%lX, sbarg=$%04.4X\n",
71 hitbox, curboxp, sb->sbarg);
72#endif
73
74 return(TRUE);
75 }
76
77 sb++;
78 }
79
80#if DEBUGIT
81 if (debugsw AND debugsf)
82 printf("whatbox(): FAILED\n");
83#endif
84
85 hitbox = -1;
86 return(FALSE);
87}
88
89/*
90
91*/
92
93/*
94 =============================================================================
95 select() -- standard item selection processing
96 =============================================================================
97*/
98
99select()
100{
101 if (astat) { /* only when the E key goes down */
102
103#if DEBUGIT
104 if (debugsw AND debugsf)
105 printf("select(): ENTRY\n");
106#endif
107
108 if (whatbox()) { /* see if we're in a box */
109
110#if DEBUGIT
111 if (debugsw AND debugsf)
112 printf("select(): HIT hitbox = %d curboxp $%lX\n",
113 hitbox, curboxp);
114#endif
115
116 (*curboxp->boxhit)(curboxp->sbarg); /* process it */
117 cursbox = hitbox;
118
119 } else {
120
121#if DEBUGIT
122 if (debugsw AND debugsf)
123 printf("select(): FAILED\n");
124#endif
125
126 }
127 }
128}
Note: See TracBrowser for help on using the repository browser.