[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
|
---|
| 14 | extern short debugsw;
|
---|
| 15 |
|
---|
| 16 | short debugsf = 1;;
|
---|
| 17 | #endif
|
---|
| 18 |
|
---|
[7258c6a] | 19 | extern int16_t cxval, cyval, astat;
|
---|
[f40a309] | 20 |
|
---|
[7258c6a] | 21 | extern int16_t cursbox; /* currently selected box */
|
---|
| 22 | extern int16_t hitbox; /* box we just hit */
|
---|
| 23 | extern int16_t hitcx, hitcy; /* x,y of cursor when we hit the box */
|
---|
[f40a309] | 24 |
|
---|
| 25 | extern struct selbox *csbp; /* current select box table pointer */
|
---|
| 26 | extern 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] | 38 | int16_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 |
|
---|
| 98 | void 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 | }
|
---|