| 1 | /*
|
|---|
| 2 | =============================================================================
|
|---|
| 3 | curset.c -- cursor control and data entry parameter setup
|
|---|
| 4 | Version 14 -- 1988-12-13 -- D.N. Lynx Crowe
|
|---|
| 5 | =============================================================================
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #define DEBUGIT 0
|
|---|
| 9 |
|
|---|
| 10 | #include "stddefs.h"
|
|---|
| 11 | #include "fields.h"
|
|---|
| 12 | #include "vsdd.h"
|
|---|
| 13 | #include "graphdef.h"
|
|---|
| 14 | #include "curpak.h"
|
|---|
| 15 |
|
|---|
| 16 | #include "midas.h"
|
|---|
| 17 |
|
|---|
| 18 | #include "memory.h"
|
|---|
| 19 |
|
|---|
| 20 | #if DEBUGIT
|
|---|
| 21 | extern short debugsw;
|
|---|
| 22 |
|
|---|
| 23 | short debugcs = 1;
|
|---|
| 24 |
|
|---|
| 25 | char *C_TYPE[] = {
|
|---|
| 26 |
|
|---|
| 27 | "CT_GRAF", /* 0 graphics */
|
|---|
| 28 | "CT_TEXT", /* 1 text -- general */
|
|---|
| 29 | "CT_VIRT", /* 2 virtual -- graphic */
|
|---|
| 30 | "CT_SCOR", /* 3 text -- score */
|
|---|
| 31 | "CT_SMTH", /* 4 text -- smooth scroll */
|
|---|
| 32 | "CT_MENU" /* 5 virtual -- character */
|
|---|
| 33 | };
|
|---|
| 34 | #endif
|
|---|
| 35 |
|
|---|
| 36 | int16_t trkonly = FALSE; /* set TRUE to force use of trackball */
|
|---|
| 37 |
|
|---|
| 38 | extern void txstd(void);
|
|---|
| 39 | extern void tystd(void);
|
|---|
| 40 | extern void cmvgen(void);
|
|---|
| 41 |
|
|---|
| 42 | extern void (*curmove)(void);
|
|---|
| 43 | extern int16_t (*curtype)(void);
|
|---|
| 44 | extern void (*cx_key)(void);
|
|---|
| 45 | extern void (*cx_upd)(void);
|
|---|
| 46 | extern void (*cy_key)(void);
|
|---|
| 47 | extern void (*cy_upd)(void);
|
|---|
| 48 | extern void (*d_key)(int16_t k);
|
|---|
| 49 | extern void (*e_key)(void);
|
|---|
| 50 | extern void (*m_key)(void);
|
|---|
| 51 | extern int16_t (*not_fld)(int16_t k);
|
|---|
| 52 | extern void (*premove)(void);
|
|---|
| 53 | extern void (*pstmove)(void);
|
|---|
| 54 | extern void (*x_key)(void);
|
|---|
| 55 | extern void (*xy_dn)(void);
|
|---|
| 56 | extern void (*xy_up)(void);
|
|---|
| 57 |
|
|---|
| 58 | extern int16_t *cratex;
|
|---|
| 59 | extern int16_t *cratey;
|
|---|
| 60 |
|
|---|
| 61 | /* |
|---|
| 62 |
|
|---|
| 63 | */
|
|---|
| 64 |
|
|---|
| 65 | extern int16_t chtime;
|
|---|
| 66 | extern int16_t chwait;
|
|---|
| 67 | extern int16_t cmfirst;
|
|---|
| 68 | extern int16_t cmtype;
|
|---|
| 69 | extern int16_t curhold;
|
|---|
| 70 | extern int16_t curslim;
|
|---|
| 71 | extern int16_t cvtime;
|
|---|
| 72 | extern int16_t cvwait;
|
|---|
| 73 | extern int16_t cxval;
|
|---|
| 74 | extern int16_t cyval;
|
|---|
| 75 | extern int16_t hcwval;
|
|---|
| 76 | extern int16_t nchwait;
|
|---|
| 77 | extern int16_t ncvwait;
|
|---|
| 78 | extern int16_t stccol;
|
|---|
| 79 | extern int16_t stcrow;
|
|---|
| 80 | extern int16_t submenu;
|
|---|
| 81 | extern int16_t syrate;
|
|---|
| 82 | extern int16_t thcwval;
|
|---|
| 83 | extern int16_t tvcwval;
|
|---|
| 84 | extern int16_t vcwval;
|
|---|
| 85 |
|
|---|
| 86 | extern struct selbox *csbp;
|
|---|
| 87 |
|
|---|
| 88 | /* |
|---|
| 89 |
|
|---|
| 90 | */
|
|---|
| 91 |
|
|---|
| 92 | #if DEBUGIT
|
|---|
| 93 |
|
|---|
| 94 | /*
|
|---|
| 95 | =============================================================================
|
|---|
| 96 | SnapCT() -- snap dump curpak variables
|
|---|
| 97 | =============================================================================
|
|---|
| 98 | */
|
|---|
| 99 |
|
|---|
| 100 | SnapCT()
|
|---|
| 101 | {
|
|---|
| 102 | printf("\ncurpak variables:\n");
|
|---|
| 103 | printf(" curtype = $%lX\n", curtype);
|
|---|
| 104 | printf(" premove = $%lX\n", premove);
|
|---|
| 105 | printf(" pstmove = $%lX\n", pstmove);
|
|---|
| 106 | printf(" cx_key = $%lX\n", cx_key);
|
|---|
| 107 | printf(" cy_key = $%lX\n", cy_key);
|
|---|
| 108 | printf(" cx_upd = $%lX\n", cx_upd);
|
|---|
| 109 | printf(" cy_upd = $%lX\n", cy_upd);
|
|---|
| 110 | printf(" xy_up = $%lX\n", xy_up);
|
|---|
| 111 | printf(" xy_dn = $%lX\n", xy_dn);
|
|---|
| 112 | printf(" x_key = $%lX\n", x_key);
|
|---|
| 113 | printf(" e_key = $%lX\n", e_key);
|
|---|
| 114 | printf(" m_key = $%lX\n", m_key);
|
|---|
| 115 | printf(" d_key = $%lX\n", d_key);
|
|---|
| 116 | printf(" not_fld = $%lX\n", not_fld);
|
|---|
| 117 | printf(" curfet = $%lX\n", curfet);
|
|---|
| 118 | printf(" csbp = $%lX\n", csbp);
|
|---|
| 119 | printf(" cratex = $%lX\n", cratex);
|
|---|
| 120 | printf(" cratey = $%lX\n", cratey);
|
|---|
| 121 | printf(" cmtype = %d\n", cmtype);
|
|---|
| 122 | printf(" cxval = %d\n", cxval);
|
|---|
| 123 | printf(" cyval = %d\n", cyval);
|
|---|
| 124 | printf("\n");
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | #endif
|
|---|
| 128 |
|
|---|
| 129 | /* |
|---|
| 130 |
|
|---|
| 131 | */
|
|---|
| 132 |
|
|---|
| 133 | /*
|
|---|
| 134 | =============================================================================
|
|---|
| 135 | stdctp0() -- cursor type - text, virtual
|
|---|
| 136 | =============================================================================
|
|---|
| 137 | */
|
|---|
| 138 |
|
|---|
| 139 | int16_t stdctp0(void)
|
|---|
| 140 | {
|
|---|
| 141 | return(submenu ? CT_VIRT : CT_TEXT);
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | /*
|
|---|
| 145 | =============================================================================
|
|---|
| 146 | stdctp1() -- cursor type -- graphic, text, virtual -- text if > curslim
|
|---|
| 147 | =============================================================================
|
|---|
| 148 | */
|
|---|
| 149 |
|
|---|
| 150 | int16_t stdctp1(void)
|
|---|
| 151 | {
|
|---|
| 152 | if (submenu)
|
|---|
| 153 | return(CT_VIRT);
|
|---|
| 154 |
|
|---|
| 155 | return((cyval > curslim) ? CT_TEXT : CT_GRAF);
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | /*
|
|---|
| 159 | =============================================================================
|
|---|
| 160 | stdctp2() -- cursor type -- graphic
|
|---|
| 161 | =============================================================================
|
|---|
| 162 | */
|
|---|
| 163 |
|
|---|
| 164 | int16_t stdctp2(void)
|
|---|
| 165 | {
|
|---|
| 166 | return(CT_GRAF);
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | /* |
|---|
| 170 |
|
|---|
| 171 | */
|
|---|
| 172 |
|
|---|
| 173 | /*
|
|---|
| 174 | =============================================================================
|
|---|
| 175 | stdctp3() -- cursor type -- graphic, score text, virtual
|
|---|
| 176 | =============================================================================
|
|---|
| 177 | */
|
|---|
| 178 |
|
|---|
| 179 | int16_t stdctp3(void)
|
|---|
| 180 | {
|
|---|
| 181 | if (submenu)
|
|---|
| 182 | return(CT_VIRT);
|
|---|
| 183 |
|
|---|
| 184 | return(((cyval < 14) OR (cyval > 237)) ? CT_SCOR : CT_GRAF);
|
|---|
| 185 | }
|
|---|
| 186 |
|
|---|
| 187 | /*
|
|---|
| 188 | =============================================================================
|
|---|
| 189 | stdctp4() -- cursor type -- graphic, text, virtual -- text if < curslim
|
|---|
| 190 | =============================================================================
|
|---|
| 191 | */
|
|---|
| 192 |
|
|---|
| 193 | int16_t stdctp4(void)
|
|---|
| 194 | {
|
|---|
| 195 | if (submenu)
|
|---|
| 196 | return(CT_VIRT);
|
|---|
| 197 |
|
|---|
| 198 | return((cyval < curslim) ? CT_TEXT : CT_GRAF);
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | /*
|
|---|
| 202 | =============================================================================
|
|---|
| 203 | stdctp5() -- cursor type - text, virtual - character objects
|
|---|
| 204 | =============================================================================
|
|---|
| 205 | */
|
|---|
| 206 |
|
|---|
| 207 | int16_t stdctp5(void)
|
|---|
| 208 | {
|
|---|
| 209 | return(submenu ? CT_MENU : CT_SMTH);
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | /* |
|---|
| 213 |
|
|---|
| 214 | */
|
|---|
| 215 |
|
|---|
| 216 | /*
|
|---|
| 217 | =============================================================================
|
|---|
| 218 | curset() -- setup the cursor control and data entry parameters
|
|---|
| 219 | =============================================================================
|
|---|
| 220 | */
|
|---|
| 221 |
|
|---|
| 222 | void curset(struct curpak *s)
|
|---|
| 223 | {
|
|---|
| 224 | #if DEBUGIT
|
|---|
| 225 | if (debugsw AND debugcs)
|
|---|
| 226 | printf("curset($%lX): ENTRY old cmtype=%d\n", s, cmtype);
|
|---|
| 227 | #endif
|
|---|
| 228 |
|
|---|
| 229 | curtype = s->curtype;
|
|---|
| 230 | premove = s->premove;
|
|---|
| 231 | pstmove = s->pstmove;
|
|---|
| 232 |
|
|---|
| 233 | curmove = cmvgen;
|
|---|
| 234 |
|
|---|
| 235 | if (trkonly) {
|
|---|
| 236 |
|
|---|
| 237 | cx_key = txstd;
|
|---|
| 238 | cy_key = tystd;
|
|---|
| 239 |
|
|---|
| 240 | } else {
|
|---|
| 241 |
|
|---|
| 242 | cx_key = s->cx_key;
|
|---|
| 243 | cy_key = s->cy_key;
|
|---|
| 244 | }
|
|---|
| 245 |
|
|---|
| 246 | cx_upd = s->cx_upd;
|
|---|
| 247 | cy_upd = s->cy_upd;
|
|---|
| 248 | xy_up = s->xy_up;
|
|---|
| 249 | xy_dn = s->xy_dn;
|
|---|
| 250 | x_key = s->x_key;
|
|---|
| 251 | e_key = s->e_key;
|
|---|
| 252 | m_key = s->m_key;
|
|---|
| 253 | d_key = s->d_key;
|
|---|
| 254 | not_fld = s->not_fld;
|
|---|
| 255 | curfet = s->curfet;
|
|---|
| 256 | csbp = s->csbp;
|
|---|
| 257 | cratex = s->cratex;
|
|---|
| 258 | cratey = s->cratey;
|
|---|
| 259 | cmtype = s->cmtype;
|
|---|
| 260 | cxval = s->cxval;
|
|---|
| 261 | cyval = s->cyval;
|
|---|
| 262 |
|
|---|
| 263 | #if DEBUGIT
|
|---|
| 264 | if (debugsw AND debugcs)
|
|---|
| 265 | printf("curset($%lX): new cmtype=%d\n", s, cmtype);
|
|---|
| 266 | #endif
|
|---|
| 267 |
|
|---|
| 268 | /* |
|---|
| 269 |
|
|---|
| 270 | */
|
|---|
| 271 | if (cmtype EQ CT_GRAF) { /* graphics */
|
|---|
| 272 |
|
|---|
| 273 | chtime = hcwval;
|
|---|
| 274 | cvtime = vcwval;
|
|---|
| 275 |
|
|---|
| 276 | } else { /* text of some sort */
|
|---|
| 277 |
|
|---|
| 278 | chtime = thcwval;
|
|---|
| 279 | cvtime = (cmtype EQ CT_SMTH) ? syrate : tvcwval;
|
|---|
| 280 | }
|
|---|
| 281 |
|
|---|
| 282 | stccol = XTOC(cxval);
|
|---|
| 283 | stcrow = YTOR(cyval);
|
|---|
| 284 |
|
|---|
| 285 | chwait = chtime;
|
|---|
| 286 | cvwait = cvtime;
|
|---|
| 287 |
|
|---|
| 288 | nchwait = curhold;
|
|---|
| 289 | ncvwait = curhold;
|
|---|
| 290 |
|
|---|
| 291 | cmfirst = TRUE;
|
|---|
| 292 |
|
|---|
| 293 | ebflag = FALSE;
|
|---|
| 294 | memset(ebuf, '\0', sizeof ebuf);
|
|---|
| 295 |
|
|---|
| 296 | cfetp = (struct fet *)NULL;
|
|---|
| 297 | infetp = (struct fet *)NULL;
|
|---|
| 298 |
|
|---|
| 299 | #if DEBUGIT
|
|---|
| 300 | if (debugsw AND debugcs) {
|
|---|
| 301 |
|
|---|
| 302 | printf("curset($%lX): EXIT cmtype=%d=%s chtime=%d cvtime=%d curhold=%d\n",
|
|---|
| 303 | s, cmtype,
|
|---|
| 304 | (cmtype < 6) ? C_TYPE[cmtype] : "UNKNOWN",
|
|---|
| 305 | chtime, cvtime, curhold);
|
|---|
| 306 |
|
|---|
| 307 | SnapCT();
|
|---|
| 308 | }
|
|---|
| 309 | #endif
|
|---|
| 310 |
|
|---|
| 311 | }
|
|---|