[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 |
|
---|
[b28a12e] | 10 | #include "ram.h"
|
---|
[f40a309] | 11 |
|
---|
| 12 | #if DEBUGIT
|
---|
| 13 | short debugsf = 1;;
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 | /*
|
---|
| 17 | =============================================================================
|
---|
| 18 | whatbox() -- determine which selection box a hit occured in
|
---|
| 19 | =============================================================================
|
---|
| 20 | */
|
---|
| 21 |
|
---|
[7258c6a] | 22 | int16_t whatbox(void)
|
---|
[f40a309] | 23 | {
|
---|
| 24 | register struct selbox *sb;
|
---|
| 25 |
|
---|
| 26 | sb = csbp;
|
---|
| 27 | hitbox = -1;
|
---|
| 28 |
|
---|
| 29 | #if DEBUGIT
|
---|
| 30 | if (debugsw AND debugsf)
|
---|
| 31 | printf("whatbox(): ENTRY cxval=%d cyval=%d cursbox=%d csbp=$%lX\n",
|
---|
| 32 | cxval, cyval, cursbox, csbp);
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
| 35 | if (0L EQ sb)
|
---|
| 36 | return(FALSE);
|
---|
| 37 |
|
---|
| 38 | while (sb->boxhit) {
|
---|
| 39 |
|
---|
| 40 | hitbox++;
|
---|
| 41 |
|
---|
| 42 | if ((cxval GE sb->sbxmin) AND
|
---|
| 43 | (cxval LE sb->sbxmax) AND
|
---|
| 44 | (cyval GE sb->sbymin) AND
|
---|
| 45 | (cyval LE sb->sbymax)) {
|
---|
| 46 |
|
---|
| 47 | hitcx = cxval;
|
---|
| 48 | hitcy = cyval;
|
---|
| 49 | curboxp = sb;
|
---|
| 50 |
|
---|
| 51 | #if DEBUGIT
|
---|
| 52 | if (debugsw AND debugsf)
|
---|
| 53 | printf("whatbox(): HIT hitbox=%d, curboxp=$%lX, sbarg=$%04.4X\n",
|
---|
| 54 | hitbox, curboxp, sb->sbarg);
|
---|
| 55 | #endif
|
---|
| 56 |
|
---|
| 57 | return(TRUE);
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | sb++;
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | #if DEBUGIT
|
---|
| 64 | if (debugsw AND debugsf)
|
---|
| 65 | printf("whatbox(): FAILED\n");
|
---|
| 66 | #endif
|
---|
| 67 |
|
---|
| 68 | hitbox = -1;
|
---|
| 69 | return(FALSE);
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | /*
|
---|
| 73 | =============================================================================
|
---|
| 74 | select() -- standard item selection processing
|
---|
| 75 | =============================================================================
|
---|
| 76 | */
|
---|
| 77 |
|
---|
[0580615] | 78 | void select(void)
|
---|
[f40a309] | 79 | {
|
---|
| 80 | if (astat) { /* only when the E key goes down */
|
---|
| 81 |
|
---|
| 82 | #if DEBUGIT
|
---|
| 83 | if (debugsw AND debugsf)
|
---|
| 84 | printf("select(): ENTRY\n");
|
---|
| 85 | #endif
|
---|
| 86 |
|
---|
| 87 | if (whatbox()) { /* see if we're in a box */
|
---|
| 88 |
|
---|
| 89 | #if DEBUGIT
|
---|
| 90 | if (debugsw AND debugsf)
|
---|
| 91 | printf("select(): HIT hitbox = %d curboxp $%lX\n",
|
---|
| 92 | hitbox, curboxp);
|
---|
| 93 | #endif
|
---|
| 94 |
|
---|
| 95 | (*curboxp->boxhit)(curboxp->sbarg); /* process it */
|
---|
| 96 | cursbox = hitbox;
|
---|
| 97 |
|
---|
| 98 | } else {
|
---|
| 99 |
|
---|
| 100 | #if DEBUGIT
|
---|
| 101 | if (debugsw AND debugsf)
|
---|
| 102 | printf("select(): FAILED\n");
|
---|
| 103 | #endif
|
---|
| 104 |
|
---|
| 105 | }
|
---|
| 106 | }
|
---|
| 107 | }
|
---|
[6262b5c] | 108 |
|
---|