source: buchla-68k/ram/select.c@ 7258c6a

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

Use standard integer types.

  • Property mode set to 100644
File size: 2.4 KB
RevLine 
[f40a309]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
[7258c6a]19extern int16_t cxval, cyval, astat;
[f40a309]20
[7258c6a]21extern int16_t cursbox; /* currently selected box */
22extern int16_t hitbox; /* box we just hit */
23extern int16_t hitcx, hitcy; /* x,y of cursor when we hit the box */
[f40a309]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*/
[7258c6a]37
[f40a309]38int16_t 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 =============================================================================
[0580615]96*/
[f40a309]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.