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