| 1 | /* | 
|---|
| 2 | ============================================================================= | 
|---|
| 3 | scfield.c -- score editor field setup | 
|---|
| 4 | Version 62 -- 1989-11-15 -- D.N. Lynx Crowe | 
|---|
| 5 | ============================================================================= | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #include "ram.h" | 
|---|
| 9 |  | 
|---|
| 10 | #define PCENTER         256L | 
|---|
| 11 |  | 
|---|
| 12 | struct  fet     sc_fet1[] = { | 
|---|
| 13 |  | 
|---|
| 14 | { 0,  2,  4, 0x0000, et_strn, ef_strn, rd_strn, nd_strn}, | 
|---|
| 15 | { 0, 11, 15, 0x0000, et_snbt, ef_snbt, rd_snbt, nd_snbt}, | 
|---|
| 16 |  | 
|---|
| 17 | {17, 11, 12, 0x0000, et_ioas, ef_ioas, rd_ioas, nd_ioas}, | 
|---|
| 18 | {17, 19, 19, 0x0000, et_tune, ef_tune, rd_tune, nd_tune}, | 
|---|
| 19 | {17, 27, 29, 0x0000, et_tmpo, ef_tmpo, rd_tmpo, nd_tmpo}, | 
|---|
| 20 | {17, 35, 38, 0x0000, et_intp, ef_intp, rd_intp, nd_intp}, | 
|---|
| 21 |  | 
|---|
| 22 | {18,  7,  8,      0, et_inst, ef_inst, rd_inst, nd_inst}, | 
|---|
| 23 | {18, 12, 13,      1, et_inst, ef_inst, rd_inst, nd_inst}, | 
|---|
| 24 | {18, 17, 18,      2, et_inst, ef_inst, rd_inst, nd_inst}, | 
|---|
| 25 | {18, 22, 23,      3, et_inst, ef_inst, rd_inst, nd_inst}, | 
|---|
| 26 | {18, 27, 28,      4, et_inst, ef_inst, rd_inst, nd_inst}, | 
|---|
| 27 | {18, 32, 33,      5, et_inst, ef_inst, rd_inst, nd_inst}, | 
|---|
| 28 | {18, 37, 38,      6, et_inst, ef_inst, rd_inst, nd_inst}, | 
|---|
| 29 | {18, 42, 43,      7, et_inst, ef_inst, rd_inst, nd_inst}, | 
|---|
| 30 | {18, 47, 48,      8, et_inst, ef_inst, rd_inst, nd_inst}, | 
|---|
| 31 | {18, 52, 53,      9, et_inst, ef_inst, rd_inst, nd_inst}, | 
|---|
| 32 | {18, 57, 58,     10, et_inst, ef_inst, rd_inst, nd_inst}, | 
|---|
| 33 | {18, 62, 63,     11, et_inst, ef_inst, rd_inst, nd_inst}, | 
|---|
| 34 |  | 
|---|
| 35 | {19,  5,  8,      0, et_trns, ef_trns, rd_trns, nd_trns}, | 
|---|
| 36 | {19, 10, 13,      1, et_trns, ef_trns, rd_trns, nd_trns}, | 
|---|
| 37 | {19, 15, 18,      2, et_trns, ef_trns, rd_trns, nd_trns}, | 
|---|
| 38 | {19, 20, 23,      3, et_trns, ef_trns, rd_trns, nd_trns}, | 
|---|
| 39 | {19, 25, 28,      4, et_trns, ef_trns, rd_trns, nd_trns}, | 
|---|
| 40 | {19, 30, 33,      5, et_trns, ef_trns, rd_trns, nd_trns}, | 
|---|
| 41 | {19, 35, 38,      6, et_trns, ef_trns, rd_trns, nd_trns}, | 
|---|
| 42 | {19, 40, 43,      7, et_trns, ef_trns, rd_trns, nd_trns}, | 
|---|
| 43 | {19, 45, 48,      8, et_trns, ef_trns, rd_trns, nd_trns}, | 
|---|
| 44 | {19, 50, 53,      9, et_trns, ef_trns, rd_trns, nd_trns}, | 
|---|
| 45 | {19, 55, 58,     10, et_trns, ef_trns, rd_trns, nd_trns}, | 
|---|
| 46 | {19, 60, 63,     11, et_trns, ef_trns, rd_trns, nd_trns}, | 
|---|
| 47 |  | 
|---|
| 48 | {20,  6,  6,      0, et_dyn,  ef_dyn,  rd_dyn,  nd_dyn}, | 
|---|
| 49 | {20,  8,  8,      0, et_loc,  ef_loc,  rd_loc,  nd_loc}, | 
|---|
| 50 |  | 
|---|
| 51 | {20, 11, 11,      1, et_dyn,  ef_dyn,  rd_dyn,  nd_dyn}, | 
|---|
| 52 | {20, 13, 13,      1, et_loc,  ef_loc,  rd_loc,  nd_loc}, | 
|---|
| 53 |  | 
|---|
| 54 | {20, 16, 16,      2, et_dyn,  ef_dyn,  rd_dyn,  nd_dyn}, | 
|---|
| 55 | {20, 18, 18,      2, et_loc,  ef_loc,  rd_loc,  nd_loc}, | 
|---|
| 56 |  | 
|---|
| 57 | {20, 21, 21,      3, et_dyn,  ef_dyn,  rd_dyn,  nd_dyn}, | 
|---|
| 58 | {20, 23, 23,      3, et_loc,  ef_loc,  rd_loc,  nd_loc}, | 
|---|
| 59 |  | 
|---|
| 60 | {20, 26, 26,      4, et_dyn,  ef_dyn,  rd_dyn,  nd_dyn}, | 
|---|
| 61 | {20, 28, 28,      4, et_loc,  ef_loc,  rd_loc,  nd_loc}, | 
|---|
| 62 |  | 
|---|
| 63 | {20, 31, 31,      5, et_dyn,  ef_dyn,  rd_dyn,  nd_dyn}, | 
|---|
| 64 | {20, 33, 33,      5, et_loc,  ef_loc,  rd_loc,  nd_loc}, | 
|---|
| 65 |  | 
|---|
| 66 | {20, 36, 36,      6, et_dyn,  ef_dyn,  rd_dyn,  nd_dyn}, | 
|---|
| 67 | {20, 38, 38,      6, et_loc,  ef_loc,  rd_loc,  nd_loc}, | 
|---|
| 68 |  | 
|---|
| 69 | {20, 41, 41,      7, et_dyn,  ef_dyn,  rd_dyn,  nd_dyn}, | 
|---|
| 70 | {20, 43, 43,      7, et_loc,  ef_loc,  rd_loc,  nd_loc}, | 
|---|
| 71 |  | 
|---|
| 72 | {20, 46, 46,      8, et_dyn,  ef_dyn,  rd_dyn,  nd_dyn}, | 
|---|
| 73 | {20, 48, 48,      8, et_loc,  ef_loc,  rd_loc,  nd_loc}, | 
|---|
| 74 |  | 
|---|
| 75 | {20, 51, 51,      9, et_dyn,  ef_dyn,  rd_dyn,  nd_dyn}, | 
|---|
| 76 | {20, 53, 53,      9, et_loc,  ef_loc,  rd_loc,  nd_loc}, | 
|---|
| 77 |  | 
|---|
| 78 | {20, 56, 56,     10, et_dyn,  ef_dyn,  rd_dyn,  nd_dyn}, | 
|---|
| 79 | {20, 58, 58,     10, et_loc,  ef_loc,  rd_loc,  nd_loc}, | 
|---|
| 80 |  | 
|---|
| 81 | {20, 61, 61,     11, et_dyn,  ef_dyn,  rd_dyn,  nd_dyn}, | 
|---|
| 82 | {20, 63, 63,     11, et_loc,  ef_loc,  rd_loc,  nd_loc}, | 
|---|
| 83 |  | 
|---|
| 84 | {21,  6,  8,      0, et_vel,  ef_vel,  rd_vel,  nd_vel}, | 
|---|
| 85 | {21, 11, 13,      1, et_vel,  ef_vel,  rd_vel,  nd_vel}, | 
|---|
| 86 | {21, 16, 18,      2, et_vel,  ef_vel,  rd_vel,  nd_vel}, | 
|---|
| 87 | {21, 21, 23,      3, et_vel,  ef_vel,  rd_vel,  nd_vel}, | 
|---|
| 88 | {21, 26, 28,      4, et_vel,  ef_vel,  rd_vel,  nd_vel}, | 
|---|
| 89 | {21, 31, 33,      5, et_vel,  ef_vel,  rd_vel,  nd_vel}, | 
|---|
| 90 | {21, 36, 38,      6, et_vel,  ef_vel,  rd_vel,  nd_vel}, | 
|---|
| 91 | {21, 41, 43,      7, et_vel,  ef_vel,  rd_vel,  nd_vel}, | 
|---|
| 92 | {21, 46, 48,      8, et_vel,  ef_vel,  rd_vel,  nd_vel}, | 
|---|
| 93 | {21, 51, 53,      9, et_vel,  ef_vel,  rd_vel,  nd_vel}, | 
|---|
| 94 | {21, 56, 58,     10, et_vel,  ef_vel,  rd_vel,  nd_vel}, | 
|---|
| 95 | {21, 61, 63,     11, et_vel,  ef_vel,  rd_vel,  nd_vel}, | 
|---|
| 96 |  | 
|---|
| 97 |  | 
|---|
| 98 | {23,  6,  6,      0, et_res1, ef_res1, rd_res1, nd_res1}, | 
|---|
| 99 | {23,  8, 12,      0, et_aval, ef_aval, rd_aval, nd_aval}, | 
|---|
| 100 |  | 
|---|
| 101 | {23, 15, 15,      1, et_res1, ef_res1, rd_res1, nd_res1}, | 
|---|
| 102 | {23, 17, 21,      1, et_aval, ef_aval, rd_aval, nd_aval}, | 
|---|
| 103 |  | 
|---|
| 104 | {23, 24, 24,      2, et_res1, ef_res1, rd_res1, nd_res1}, | 
|---|
| 105 | {23, 26, 30,      2, et_aval, ef_aval, rd_aval, nd_aval}, | 
|---|
| 106 |  | 
|---|
| 107 | {23, 33, 33,      3, et_res1, ef_res1, rd_res1, nd_res1}, | 
|---|
| 108 | {23, 35, 39,      3, et_aval, ef_aval, rd_aval, nd_aval}, | 
|---|
| 109 |  | 
|---|
| 110 | {23, 42, 42,      4, et_res1, ef_res1, rd_res1, nd_res1}, | 
|---|
| 111 | {23, 44, 48,      4, et_aval, ef_aval, rd_aval, nd_aval}, | 
|---|
| 112 |  | 
|---|
| 113 | {23, 51, 51,      5, et_res1, ef_res1, rd_res1, nd_res1}, | 
|---|
| 114 | {23, 53, 57,      5, et_aval, ef_aval, rd_aval, nd_aval}, | 
|---|
| 115 |  | 
|---|
| 116 | {23, 61, 62,      0, et_agrp, ef_agrp, rd_agrp, nd_agrp}, | 
|---|
| 117 |  | 
|---|
| 118 | {24,  7,  8, 0x0000, et_scor, ef_scor, rd_scor, nd_scor}, | 
|---|
| 119 | {24, 10, 25, 0x0000, et_null, ef_null, rd_null, nd_null}, | 
|---|
| 120 |  | 
|---|
| 121 |  | 
|---|
| 122 | { 0,  0,  0, 0x0000, FN_NULL, FN_NULL, FN_NULL, FN_NULL} | 
|---|
| 123 | }; | 
|---|
| 124 |  | 
|---|
| 125 | struct curpak sc_flds = { | 
|---|
| 126 |  | 
|---|
| 127 | stdctp3,        /* curtype */ | 
|---|
| 128 | nokey,          /* premove */ | 
|---|
| 129 | nokey,          /* pstmove */ | 
|---|
| 130 | cxkstd,         /* cx_key */ | 
|---|
| 131 | cykstd,         /* cy_key */ | 
|---|
| 132 | sdcxu,          /* cx_upd */ | 
|---|
| 133 | sdcyu,          /* cy_upd */ | 
|---|
| 134 | nokey,          /* xy_up */ | 
|---|
| 135 | nokey,          /* xy_dn */ | 
|---|
| 136 | sdxkey,         /* x_key */ | 
|---|
| 137 | select,         /* e_key */ | 
|---|
| 138 | sdmkey,         /* m_key */ | 
|---|
| 139 | stddkey,        /* d_key */ | 
|---|
| 140 | scntfld,        /* not_fld */ | 
|---|
| 141 | sc_fet1,        /* curfet */ | 
|---|
| 142 | sdboxes,        /* csbp */ | 
|---|
| 143 | crate1,         /* cratex */ | 
|---|
| 144 | crate1,         /* cratey */ | 
|---|
| 145 | CT_GRAF,        /* cmtype */ | 
|---|
| 146 | C1X,            /* cxval */ | 
|---|
| 147 | C1Y             /* cyval */ | 
|---|
| 148 | }; | 
|---|
| 149 |  | 
|---|
| 150 | /* | 
|---|
| 151 | ============================================================================= | 
|---|
| 152 | et_null() .. nd_null() -- null data entry key processors | 
|---|
| 153 | ============================================================================= | 
|---|
| 154 | */ | 
|---|
| 155 |  | 
|---|
| 156 | int16_t et_null(int16_t n) | 
|---|
| 157 | { | 
|---|
| 158 | return(SUCCESS); | 
|---|
| 159 | } | 
|---|
| 160 |  | 
|---|
| 161 | int16_t ef_null(int16_t n) | 
|---|
| 162 | { | 
|---|
| 163 | return(SUCCESS); | 
|---|
| 164 | } | 
|---|
| 165 |  | 
|---|
| 166 | int16_t rd_null(int16_t n) | 
|---|
| 167 | { | 
|---|
| 168 | return(SUCCESS); | 
|---|
| 169 | } | 
|---|
| 170 |  | 
|---|
| 171 | int16_t nd_null(int16_t n, int16_t k) | 
|---|
| 172 | { | 
|---|
| 173 | return(SUCCESS); | 
|---|
| 174 | } | 
|---|
| 175 |  | 
|---|
| 176 | /* | 
|---|
| 177 | ============================================================================= | 
|---|
| 178 | istart() -- start insert mode | 
|---|
| 179 | ============================================================================= | 
|---|
| 180 | */ | 
|---|
| 181 |  | 
|---|
| 182 | void istart(void) | 
|---|
| 183 | { | 
|---|
| 184 | register struct s_entry *ep, *pp, *tp; | 
|---|
| 185 |  | 
|---|
| 186 | if (insmode)                            /* can't already be inserting */ | 
|---|
| 187 | return; | 
|---|
| 188 |  | 
|---|
| 189 | ep    = ep_adj(p_cur, 1, t_cur);        /* locate tail */ | 
|---|
| 190 |  | 
|---|
| 191 | if (EV_SCORE EQ (0x007F & ep->e_type))  /* skip begin score event */ | 
|---|
| 192 | ep = ep->e_fwd; | 
|---|
| 193 |  | 
|---|
| 194 | if (EV_FINI EQ (0x007F & ep->e_type))   /* null if at end of score */ | 
|---|
| 195 | return; | 
|---|
| 196 |  | 
|---|
| 197 | tp = scores[curscor]->e_bak;            /* locate end of score */ | 
|---|
| 198 | pp = ep->e_bak;                         /* locate end of head */ | 
|---|
| 199 |  | 
|---|
| 200 | ep->e_bak = E_NULL;                     /* unhook tail from head */ | 
|---|
| 201 | pp->e_fwd = tp;                         /* unhook head from tail */ | 
|---|
| 202 | (tp->e_bak)->e_fwd = E_NULL;            /* unhook tail from end */ | 
|---|
| 203 |  | 
|---|
| 204 | tp->e_bak = pp;                         /* connect end to head */ | 
|---|
| 205 |  | 
|---|
| 206 | t_ins = t_cur;                          /* record tail time */ | 
|---|
| 207 | peg   = ep;                             /* hang tail on peg */ | 
|---|
| 208 |  | 
|---|
| 209 | p_cur = ep_adj(pp, 0, t_cur);           /* adjust p_cur */ | 
|---|
| 210 | p_ctr = p_cur;                          /* adjust p_ctr */ | 
|---|
| 211 | p_bak = ep_adj(p_cur, 0, t_bak);        /* adjust p_bak */ | 
|---|
| 212 | p_fwd = ep_adj(p_cur, 0, t_fwd);        /* adjust p_fwd */ | 
|---|
| 213 |  | 
|---|
| 214 | insmode = TRUE; | 
|---|
| 215 | } | 
|---|
| 216 |  | 
|---|
| 217 | /* | 
|---|
| 218 | ============================================================================= | 
|---|
| 219 | icancel() -- cancel insert mode | 
|---|
| 220 | ============================================================================= | 
|---|
| 221 | */ | 
|---|
| 222 |  | 
|---|
| 223 | void icancel(void) | 
|---|
| 224 | { | 
|---|
| 225 | register struct s_entry *ep, *tp, *rp; | 
|---|
| 226 | struct s_entry *pp; | 
|---|
| 227 | int32_t endtime; | 
|---|
| 228 |  | 
|---|
| 229 | if (NOT insmode) | 
|---|
| 230 | return; | 
|---|
| 231 |  | 
|---|
| 232 | tp = scores[curscor]->e_bak;            /* locate end of score */ | 
|---|
| 233 | pp = tp->e_bak;                         /* locate end of head */ | 
|---|
| 234 |  | 
|---|
| 235 | endtime = pp->e_time;                   /* find last time in score */ | 
|---|
| 236 |  | 
|---|
| 237 | if (t_cur > endtime)                    /* use max of t_cur, endtime */ | 
|---|
| 238 | endtime = t_cur; | 
|---|
| 239 |  | 
|---|
| 240 | rp = peg;                               /* point at start of tail */ | 
|---|
| 241 |  | 
|---|
| 242 | while (E_NULL NE rp) {                  /* scan each event in the tail */ | 
|---|
| 243 |  | 
|---|
| 244 | ep = rp;                        /* update pointers */ | 
|---|
| 245 | rp = ep->e_fwd; | 
|---|
| 246 |  | 
|---|
| 247 | ep->e_time = (ep->e_time - t_ins) + endtime;    /* adjust time */ | 
|---|
| 248 | } | 
|---|
| 249 |  | 
|---|
| 250 | ep->e_fwd = tp;                         /* connect tail to end */ | 
|---|
| 251 | tp->e_bak = ep;                         /* connect end to tail */ | 
|---|
| 252 |  | 
|---|
| 253 | pp->e_fwd  = peg;                       /* connect head to tail */ | 
|---|
| 254 | peg->e_bak = pp;                        /* connect tail to head */ | 
|---|
| 255 |  | 
|---|
| 256 | p_cur = ep_adj(pp, 0, t_cur);           /* adjust p_cur */ | 
|---|
| 257 | p_ctr = p_cur;                          /* adjust p_ctr */ | 
|---|
| 258 | p_bak = ep_adj(p_cur, 0, t_bak);        /* adjust p_bak */ | 
|---|
| 259 | p_fwd = ep_adj(p_cur, 0, t_fwd);        /* adjust p_fwd */ | 
|---|
| 260 |  | 
|---|
| 261 | insmode = FALSE; | 
|---|
| 262 | } | 
|---|
| 263 |  | 
|---|
| 264 | /* | 
|---|
| 265 | ============================================================================= | 
|---|
| 266 | sdcxu() -- score cursor x update processing | 
|---|
| 267 | ============================================================================= | 
|---|
| 268 | */ | 
|---|
| 269 |  | 
|---|
| 270 | void sdcxu(void) | 
|---|
| 271 | { | 
|---|
| 272 | if (sdmctl EQ 0) {              /* typewriter up */ | 
|---|
| 273 |  | 
|---|
| 274 | vtcxupd(); | 
|---|
| 275 |  | 
|---|
| 276 | } else if (sdmctl > 0) {        /* menu up */ | 
|---|
| 277 |  | 
|---|
| 278 | vtccol = XTOC(vtxval += cxrate); | 
|---|
| 279 |  | 
|---|
| 280 | if (vtccol > sdmlim[sdmctl][3]) | 
|---|
| 281 | vtxval = CTOX(vtccol = sdmlim[sdmctl][3]); | 
|---|
| 282 | else if (vtccol < sdmlim[sdmctl][1]) | 
|---|
| 283 | vtxval = CTOX(vtccol = sdmlim[sdmctl][1]); | 
|---|
| 284 |  | 
|---|
| 285 | } else {                /* no menu showing */ | 
|---|
| 286 |  | 
|---|
| 287 | cxval += cxrate; | 
|---|
| 288 |  | 
|---|
| 289 | if (cxval > CXMAX) | 
|---|
| 290 | cxval = CXMAX; | 
|---|
| 291 | else if (cxval < 0) | 
|---|
| 292 | cxval = 0; | 
|---|
| 293 | } | 
|---|
| 294 |  | 
|---|
| 295 | return; | 
|---|
| 296 | } | 
|---|
| 297 |  | 
|---|
| 298 | /* | 
|---|
| 299 | ============================================================================= | 
|---|
| 300 | sdcyu() -- score cursor y update processing | 
|---|
| 301 | ============================================================================= | 
|---|
| 302 | */ | 
|---|
| 303 |  | 
|---|
| 304 | void sdcyu(void) | 
|---|
| 305 | { | 
|---|
| 306 | if (sdmctl EQ 0) { | 
|---|
| 307 |  | 
|---|
| 308 | vtcyupd(); | 
|---|
| 309 |  | 
|---|
| 310 | } else if (sdmctl > 0) {        /* menu up */ | 
|---|
| 311 |  | 
|---|
| 312 | vtcrow = YTOR(vtyval += cyrate); | 
|---|
| 313 |  | 
|---|
| 314 | if (vtcrow < sdmlim[sdmctl][0]) | 
|---|
| 315 | vtyval = RTOY(vtcrow = sdmlim[sdmctl][0]); | 
|---|
| 316 | else if (vtcrow > sdmlim[sdmctl][2]) | 
|---|
| 317 | vtyval = RTOY(vtcrow = sdmlim[sdmctl][2]); | 
|---|
| 318 |  | 
|---|
| 319 | } else {                /* no menu showing */ | 
|---|
| 320 |  | 
|---|
| 321 | cyval += cyrate; | 
|---|
| 322 |  | 
|---|
| 323 | if (cyval > CYMAX) | 
|---|
| 324 | cyval = CYMAX; | 
|---|
| 325 | else if (cyval < 0) | 
|---|
| 326 | cyval = 0; | 
|---|
| 327 |  | 
|---|
| 328 | } | 
|---|
| 329 |  | 
|---|
| 330 | return; | 
|---|
| 331 | } | 
|---|
| 332 |  | 
|---|
| 333 | /* | 
|---|
| 334 | ============================================================================= | 
|---|
| 335 | scntfld() -- not-in-field data entry key processing | 
|---|
| 336 | ============================================================================= | 
|---|
| 337 | */ | 
|---|
| 338 |  | 
|---|
| 339 | int16_t scntfld(int16_t k) | 
|---|
| 340 | { | 
|---|
| 341 | register int16_t grp, fnc, var; | 
|---|
| 342 |  | 
|---|
| 343 | if (NOT astat) | 
|---|
| 344 | return(FAILURE); | 
|---|
| 345 |  | 
|---|
| 346 | if (stcrow EQ 18) {             /* group status or mode */ | 
|---|
| 347 |  | 
|---|
| 348 | if (stccol LT 5) | 
|---|
| 349 | return(FAILURE); | 
|---|
| 350 |  | 
|---|
| 351 | grp = (stccol - 5) / 5;         /* group */ | 
|---|
| 352 | fnc = (stccol - 5) % 5;         /* status or mode */ | 
|---|
| 353 |  | 
|---|
| 354 | if (fnc EQ 0) {                 /* status */ | 
|---|
| 355 |  | 
|---|
| 356 | if (k EQ 8) {           /* '-' */ | 
|---|
| 357 |  | 
|---|
| 358 | grpstat[grp] = FALSE; | 
|---|
| 359 | dsgstat(grp); | 
|---|
| 360 | return(SUCCESS); | 
|---|
| 361 |  | 
|---|
| 362 | } else if (k EQ 9) {    /* '+' */ | 
|---|
| 363 |  | 
|---|
| 364 | grpstat[grp] = TRUE; | 
|---|
| 365 | dsgstat(grp); | 
|---|
| 366 | return(SUCCESS); | 
|---|
| 367 |  | 
|---|
| 368 | } else | 
|---|
| 369 | return(FAILURE); | 
|---|
| 370 |  | 
|---|
| 371 | } else if (fnc EQ 1) {          /* mode */ | 
|---|
| 372 |  | 
|---|
| 373 | if (k EQ 8) {           /* '-' */ | 
|---|
| 374 |  | 
|---|
| 375 | grpmode[grp] = 0; | 
|---|
| 376 | dsgmode(grp); | 
|---|
| 377 | return(SUCCESS); | 
|---|
| 378 |  | 
|---|
| 379 | } else if (k EQ 9) {    /* '+' */ | 
|---|
| 380 |  | 
|---|
| 381 | if (++grpmode[grp] GT 1) | 
|---|
| 382 | grpmode[grp] = 2; | 
|---|
| 383 |  | 
|---|
| 384 | dsgmode(grp); | 
|---|
| 385 | return(SUCCESS); | 
|---|
| 386 |  | 
|---|
| 387 | } else | 
|---|
| 388 | return(FAILURE); | 
|---|
| 389 |  | 
|---|
| 390 | } else | 
|---|
| 391 | return(FAILURE); | 
|---|
| 392 |  | 
|---|
| 393 | } else if (stcrow EQ 22) {      /* analog variables */ | 
|---|
| 394 |  | 
|---|
| 395 | if (stccol < 5) | 
|---|
| 396 | return(FAILURE); | 
|---|
| 397 |  | 
|---|
| 398 | var = (stccol - 5) / 9;         /* variable */ | 
|---|
| 399 | fnc = (stccol - 5) % 9;         /* field column */ | 
|---|
| 400 | grp = abs(angroup) - 1;         /* group */ | 
|---|
| 401 |  | 
|---|
| 402 | if (fnc EQ 0) {                 /* mode column */ | 
|---|
| 403 |  | 
|---|
| 404 | if (k EQ 8) {           /* '-' */ | 
|---|
| 405 |  | 
|---|
| 406 | varmode[var][grp] = 0; | 
|---|
| 407 | dsvmode(var); | 
|---|
| 408 | return(SUCCESS); | 
|---|
| 409 |  | 
|---|
| 410 | } else if (k EQ 9) {    /* '+' */ | 
|---|
| 411 |  | 
|---|
| 412 | if (++varmode[var][grp] GT 1) | 
|---|
| 413 | varmode[var][grp] = 2; | 
|---|
| 414 |  | 
|---|
| 415 | dsvmode(var); | 
|---|
| 416 | return(SUCCESS); | 
|---|
| 417 | } | 
|---|
| 418 | } | 
|---|
| 419 | } | 
|---|
| 420 |  | 
|---|
| 421 | return(FAILURE); | 
|---|
| 422 | } | 
|---|
| 423 |  | 
|---|
| 424 | /* | 
|---|
| 425 | ============================================================================= | 
|---|
| 426 | cp2time() -- check cursor position and convert it to time | 
|---|
| 427 |  | 
|---|
| 428 | Sets 'ctime' if the cursor x argument, 'cx',  is within the score. | 
|---|
| 429 | ============================================================================= | 
|---|
| 430 | */ | 
|---|
| 431 |  | 
|---|
| 432 | int16_t cp2time(int16_t cx) | 
|---|
| 433 | { | 
|---|
| 434 | register int32_t ct; | 
|---|
| 435 |  | 
|---|
| 436 | ct = t_cur + ((int32_t)cx - PCENTER); | 
|---|
| 437 |  | 
|---|
| 438 | if (ct < 0L)                    /* if out of score time range */ | 
|---|
| 439 | return(FALSE);          /* ... return FALSE */ | 
|---|
| 440 |  | 
|---|
| 441 | ctime = ct;                     /* set ctime */ | 
|---|
| 442 | return(TRUE);                   /* ... and return TRUE */ | 
|---|
| 443 | } | 
|---|
| 444 |  | 
|---|
| 445 | /* | 
|---|
| 446 | ============================================================================= | 
|---|
| 447 | delevts() -- delete record enabled non-note events at current time | 
|---|
| 448 | ============================================================================= | 
|---|
| 449 | */ | 
|---|
| 450 |  | 
|---|
| 451 | int16_t delevts(int16_t etp, int32_t thetime) | 
|---|
| 452 | { | 
|---|
| 453 | register struct s_entry *ep, *np; | 
|---|
| 454 | register int16_t et; | 
|---|
| 455 | register int16_t rc; | 
|---|
| 456 | register int16_t dsw; | 
|---|
| 457 |  | 
|---|
| 458 | rc = FALSE;                             /* intialize return code */ | 
|---|
| 459 |  | 
|---|
| 460 | ep = ep_adj(p_cur, 1, thetime);         /* start at left end of chain */ | 
|---|
| 461 |  | 
|---|
| 462 |  | 
|---|
| 463 | while (ep->e_time EQ thetime) {         /* for each event at ctime ... */ | 
|---|
| 464 |  | 
|---|
| 465 | np = ep->e_fwd;                 /* get next event pointer */ | 
|---|
| 466 | et = 0x007F & ep->e_type;       /* get type */ | 
|---|
| 467 | dsw = oktode(ep);               /* get deletion status */ | 
|---|
| 468 |  | 
|---|
| 469 | if (dsw AND     /* delete event if it's deletable ... */ | 
|---|
| 470 | ((etp EQ -1) OR (et EQ etp))) {  /* ... and the right kind */ | 
|---|
| 471 |  | 
|---|
| 472 | rc = TRUE; | 
|---|
| 473 |  | 
|---|
| 474 | if (-1 NE ehdlist[et])  /* if this is a header event ... */ | 
|---|
| 475 | eh_rmv(ep, ehdlist[et]);  /* remove from hdr list */ | 
|---|
| 476 |  | 
|---|
| 477 | /* fix up any effected pointers */ | 
|---|
| 478 |  | 
|---|
| 479 | if (p_bak EQ ep) | 
|---|
| 480 | p_bak = np; | 
|---|
| 481 |  | 
|---|
| 482 | if (p_cur EQ ep) | 
|---|
| 483 | p_cur = np; | 
|---|
| 484 |  | 
|---|
| 485 | if (p_ctr EQ ep) | 
|---|
| 486 | p_ctr = np; | 
|---|
| 487 |  | 
|---|
| 488 | if (p_fwd EQ ep) | 
|---|
| 489 | p_fwd = np; | 
|---|
| 490 |  | 
|---|
| 491 | e_del(e_rmv(ep));       /* delete the event */ | 
|---|
| 492 | } | 
|---|
| 493 |  | 
|---|
| 494 | ep = np; | 
|---|
| 495 | } | 
|---|
| 496 |  | 
|---|
| 497 | if (rc)                         /* if anything was deleted ... */ | 
|---|
| 498 | sc_refr(t_cur);         /* ... update the display */ | 
|---|
| 499 |  | 
|---|
| 500 | return(rc); | 
|---|
| 501 | } | 
|---|
| 502 |  | 
|---|
| 503 | /* | 
|---|
| 504 | ============================================================================= | 
|---|
| 505 | deladat() -- delete analog varaible data | 
|---|
| 506 | ============================================================================= | 
|---|
| 507 | */ | 
|---|
| 508 |  | 
|---|
| 509 | int16_t deladat(void) | 
|---|
| 510 | { | 
|---|
| 511 | register struct s_entry *ep, *rp; | 
|---|
| 512 | register int16_t grp, rc, var, vc, vn; | 
|---|
| 513 |  | 
|---|
| 514 | rc = FALSE; | 
|---|
| 515 |  | 
|---|
| 516 | if (stccol < 6)                         /* pointing at var ? */ | 
|---|
| 517 | return(rc); | 
|---|
| 518 |  | 
|---|
| 519 | vn = (stccol - 6) / 9;                  /* variable number */ | 
|---|
| 520 | vc = (stccol - 6) % 9;                  /* variable column */ | 
|---|
| 521 |  | 
|---|
| 522 | ep = ep_adj(p_cur, 1, t_cur);           /* start at left end of chain */ | 
|---|
| 523 |  | 
|---|
| 524 | if (vc EQ 0) {                          /* resolution */ | 
|---|
| 525 |  | 
|---|
| 526 | while (t_cur EQ ep->e_time) { | 
|---|
| 527 |  | 
|---|
| 528 | rp = ep->e_fwd; | 
|---|
| 529 |  | 
|---|
| 530 | if (EV_ANRS EQ (0x007F & ep->e_type)) { | 
|---|
| 531 |  | 
|---|
| 532 | grp = 0x000F & ep->e_data1; | 
|---|
| 533 | var = 0x000F & (ep->e_data1 >> 4); | 
|---|
| 534 |  | 
|---|
| 535 | if ((var EQ vn) AND grpstat[grp] AND | 
|---|
| 536 | (2 EQ (ancmsw ? varmode[var][grp] : | 
|---|
| 537 | grpmode[grp]))) { | 
|---|
| 538 |  | 
|---|
| 539 | /* fix pointers */ | 
|---|
| 540 |  | 
|---|
| 541 | if (p_bak EQ ep) | 
|---|
| 542 | p_bak = rp; | 
|---|
| 543 |  | 
|---|
| 544 | if (p_cur EQ ep) | 
|---|
| 545 | p_cur = rp; | 
|---|
| 546 |  | 
|---|
| 547 | if (p_ctr EQ ep) | 
|---|
| 548 | p_ctr = rp; | 
|---|
| 549 |  | 
|---|
| 550 | if (p_fwd EQ ep) | 
|---|
| 551 | p_fwd = rp; | 
|---|
| 552 |  | 
|---|
| 553 | /* delete event */ | 
|---|
| 554 |  | 
|---|
| 555 | eh_rmv(ep, EH_ANRS); | 
|---|
| 556 | e_del(e_rmv(ep)); | 
|---|
| 557 | rc = TRUE; | 
|---|
| 558 | } | 
|---|
| 559 | } | 
|---|
| 560 |  | 
|---|
| 561 | ep = rp;                /* next event */ | 
|---|
| 562 | } | 
|---|
| 563 |  | 
|---|
| 564 | } else if ((vc GE 2) AND (vc LE 6)) {   /* value */ | 
|---|
| 565 |  | 
|---|
| 566 | while (t_cur EQ ep->e_time) { | 
|---|
| 567 |  | 
|---|
| 568 | rp = ep->e_fwd; | 
|---|
| 569 |  | 
|---|
| 570 | if (EV_ANVL EQ (0x007F & ep->e_type)) { | 
|---|
| 571 |  | 
|---|
| 572 | grp = 0x000F & ep->e_data1; | 
|---|
| 573 | var = 0x000F & (ep->e_data1 >> 4); | 
|---|
| 574 |  | 
|---|
| 575 | if ((var EQ vn) AND grpstat[grp] AND | 
|---|
| 576 | (2 EQ (ancmsw ? varmode[var][grp] : | 
|---|
| 577 | grpmode[grp]))) { | 
|---|
| 578 |  | 
|---|
| 579 | /* fix pointers */ | 
|---|
| 580 |  | 
|---|
| 581 | if (p_bak EQ ep) | 
|---|
| 582 | p_bak = rp; | 
|---|
| 583 |  | 
|---|
| 584 | if (p_cur EQ ep) | 
|---|
| 585 | p_cur = rp; | 
|---|
| 586 |  | 
|---|
| 587 | if (p_ctr EQ ep) | 
|---|
| 588 | p_ctr = rp; | 
|---|
| 589 |  | 
|---|
| 590 | if (p_fwd EQ ep) | 
|---|
| 591 | p_fwd = rp; | 
|---|
| 592 |  | 
|---|
| 593 | e_del(e_rmv(ep));       /* delete */ | 
|---|
| 594 | rc = TRUE; | 
|---|
| 595 | } | 
|---|
| 596 | } | 
|---|
| 597 |  | 
|---|
| 598 | ep = rp;        /* next event */ | 
|---|
| 599 | } | 
|---|
| 600 | } | 
|---|
| 601 |  | 
|---|
| 602 | if (rc) {                       /* refresh the screen if it changed */ | 
|---|
| 603 |  | 
|---|
| 604 | sc_refr(fc_val); | 
|---|
| 605 | ds_anrs(); | 
|---|
| 606 | ds_anvl(); | 
|---|
| 607 | } | 
|---|
| 608 |  | 
|---|
| 609 | return(rc); | 
|---|
| 610 | } | 
|---|
| 611 |  | 
|---|
| 612 | /* | 
|---|
| 613 | ============================================================================= | 
|---|
| 614 | sdxkey() -- score delete key processing | 
|---|
| 615 | ============================================================================= | 
|---|
| 616 | */ | 
|---|
| 617 |  | 
|---|
| 618 | void sdxkey(void) | 
|---|
| 619 | { | 
|---|
| 620 | register int16_t col, grp, sect; | 
|---|
| 621 | register struct s_entry *ep, *rp; | 
|---|
| 622 |  | 
|---|
| 623 | if (NOT astat)                  /* only do when key goes down */ | 
|---|
| 624 | return; | 
|---|
| 625 |  | 
|---|
| 626 | if (clkrun)                     /* ... and not while clock is running */ | 
|---|
| 627 | return; | 
|---|
| 628 |  | 
|---|
| 629 | if (scmctl NE -1)               /* ... and area 1 menu is down */ | 
|---|
| 630 | return; | 
|---|
| 631 |  | 
|---|
| 632 | if (sdmctl EQ 4) {              /* section menu is up */ | 
|---|
| 633 |  | 
|---|
| 634 | if (((vtcrow EQ 19) OR (vtcrow EQ 20)) AND | 
|---|
| 635 | (vtccol GE 24)) { | 
|---|
| 636 |  | 
|---|
| 637 | if (NOT recsw) | 
|---|
| 638 | return; | 
|---|
| 639 |  | 
|---|
| 640 | /* set up to delete a section marker */ | 
|---|
| 641 |  | 
|---|
| 642 | sect = ((vtccol - 24) >> 2) + ((vtcrow EQ 20) ? 10 : 0); | 
|---|
| 643 | col  = (vtccol - 24) & 3; | 
|---|
| 644 |  | 
|---|
| 645 | switch (col) { | 
|---|
| 646 |  | 
|---|
| 647 | case 0:         /* delete begin section */ | 
|---|
| 648 |  | 
|---|
| 649 |  | 
|---|
| 650 | if (E_NULL NE (ep = seclist[curscor][sect])) { | 
|---|
| 651 |  | 
|---|
| 652 | /* fix pointers */ | 
|---|
| 653 |  | 
|---|
| 654 | rp = ep->e_fwd; | 
|---|
| 655 |  | 
|---|
| 656 | if (p_bak EQ ep) | 
|---|
| 657 | p_bak = rp; | 
|---|
| 658 |  | 
|---|
| 659 | if (p_cur EQ ep) | 
|---|
| 660 | p_cur = rp; | 
|---|
| 661 |  | 
|---|
| 662 | if (p_ctr EQ ep) | 
|---|
| 663 | p_ctr = rp; | 
|---|
| 664 |  | 
|---|
| 665 | if (p_fwd EQ ep) | 
|---|
| 666 | p_fwd = rp; | 
|---|
| 667 |  | 
|---|
| 668 | eh_rmv(ep, EH_SBGN);    /* delete */ | 
|---|
| 669 | e_del(e_rmv(ep)); | 
|---|
| 670 | seclist[curscor][sect] = E_NULL; | 
|---|
| 671 | sdmenu(-1);             /* take down menu */ | 
|---|
| 672 | sc_refr(fc_val);        /* refresh screen */ | 
|---|
| 673 | } | 
|---|
| 674 |  | 
|---|
| 675 | break; | 
|---|
| 676 |  | 
|---|
| 677 | case 1:         /* section number */ | 
|---|
| 678 | case 2: | 
|---|
| 679 | break; | 
|---|
| 680 |  | 
|---|
| 681 | case 3:         /* delete end section */ | 
|---|
| 682 |  | 
|---|
| 683 | if (E_NULL NE | 
|---|
| 684 | (ep = ehfind(EV_SEND, -1L, sect, -1))) { | 
|---|
| 685 |  | 
|---|
| 686 | /* fix pointers */ | 
|---|
| 687 |  | 
|---|
| 688 | rp = ep->e_fwd; | 
|---|
| 689 |  | 
|---|
| 690 | if (p_bak EQ ep) | 
|---|
| 691 | p_bak = rp; | 
|---|
| 692 |  | 
|---|
| 693 | if (p_cur EQ ep) | 
|---|
| 694 | p_cur = rp; | 
|---|
| 695 |  | 
|---|
| 696 | if (p_ctr EQ ep) | 
|---|
| 697 | p_ctr = rp; | 
|---|
| 698 |  | 
|---|
| 699 | if (p_fwd EQ ep) | 
|---|
| 700 | p_fwd = rp; | 
|---|
| 701 |  | 
|---|
| 702 | eh_rmv(ep, EH_SEND);    /* delete */ | 
|---|
| 703 | e_del(e_rmv(ep)); | 
|---|
| 704 | sdmenu(-1);             /* take down menu */ | 
|---|
| 705 | sc_refr(fc_val);        /* refresh screen */ | 
|---|
| 706 | } | 
|---|
| 707 |  | 
|---|
| 708 | break; | 
|---|
| 709 | } | 
|---|
| 710 |  | 
|---|
| 711 | return; | 
|---|
| 712 |  | 
|---|
| 713 |  | 
|---|
| 714 | } else if ((vtcrow EQ 23) AND | 
|---|
| 715 | (vtccol GE 28) AND (vtccol LE 62)) { | 
|---|
| 716 |  | 
|---|
| 717 | /* group map entry */ | 
|---|
| 718 |  | 
|---|
| 719 | col = vtccol - 28; | 
|---|
| 720 |  | 
|---|
| 721 | if (2 EQ (col % 3)) | 
|---|
| 722 | return; | 
|---|
| 723 |  | 
|---|
| 724 | grp = col / 3; | 
|---|
| 725 | grptmap[grp] = -1; | 
|---|
| 726 | dsgtme(grp); | 
|---|
| 727 | return; | 
|---|
| 728 | } | 
|---|
| 729 | } | 
|---|
| 730 |  | 
|---|
| 731 | if (NOT recsw)  /* do only if recording */ | 
|---|
| 732 | return; | 
|---|
| 733 |  | 
|---|
| 734 | if ((cyval GE 14) AND (cyval LE 223)) {                 /* notes */ | 
|---|
| 735 |  | 
|---|
| 736 | delnote();              /* delete a note */ | 
|---|
| 737 |  | 
|---|
| 738 | } else if ((cyval GE 224) AND (cyval LE 237)) {         /* new data */ | 
|---|
| 739 |  | 
|---|
| 740 | if (cp2time(cxval)) | 
|---|
| 741 | delevts(-1, ctime);     /* delete all events at cursor */ | 
|---|
| 742 |  | 
|---|
| 743 | } else if (stcrow EQ 17) { | 
|---|
| 744 |  | 
|---|
| 745 | if ((stccol GE 11) AND (stccol LE 12)) | 
|---|
| 746 | delevts(EV_ASGN, t_cur);                /* assignment */ | 
|---|
| 747 | else if (stccol EQ 19) | 
|---|
| 748 | delevts(EV_TUNE, t_cur);                /* tuning */ | 
|---|
| 749 | else if ((stccol GE 27) AND (stccol LE 29)) | 
|---|
| 750 | delevts(EV_TMPO, t_cur);                /* tempo */ | 
|---|
| 751 | else if ((stccol GE 36) AND (stccol LE 38)) | 
|---|
| 752 | delevts(EV_INTP, t_cur);                /* interpolation */ | 
|---|
| 753 | else if ((stccol GE 40) AND (stccol LE 43)) | 
|---|
| 754 | delevts(EV_STOP, t_cur);                /* stop */ | 
|---|
| 755 | else if ((stccol GE 45) AND (stccol LE 48)) | 
|---|
| 756 | delevts(EV_NEXT, t_cur);                /* next */ | 
|---|
| 757 | else if ((stccol GE 50) AND (stccol LE 55)) | 
|---|
| 758 | delevts(EV_PNCH, t_cur);                /* punch in/out */ | 
|---|
| 759 |  | 
|---|
| 760 | } else if ((stcrow EQ 18) AND | 
|---|
| 761 | (0 EQ ((stccol - 5) % 5))) {                 /* group status */ | 
|---|
| 762 |  | 
|---|
| 763 | delevts(EV_GRP, t_cur); | 
|---|
| 764 |  | 
|---|
| 765 | } else if ((stcrow EQ 18) AND | 
|---|
| 766 | ((2 EQ ((stccol - 5) % 5)) OR | 
|---|
| 767 | (3 EQ ((stccol - 5) % 5)))) {              /* instrument */ | 
|---|
| 768 |  | 
|---|
| 769 | delevts(EV_INST, t_cur); | 
|---|
| 770 |  | 
|---|
| 771 | } else if (stcrow EQ 19) {                              /* transposition */ | 
|---|
| 772 |  | 
|---|
| 773 | delevts(EV_TRNS, t_cur); | 
|---|
| 774 |  | 
|---|
| 775 | } else if ((stcrow EQ 20) AND (stccol GE 6) AND | 
|---|
| 776 | (0 EQ ((stccol - 6) % 5))) {                 /* dynamics */ | 
|---|
| 777 |  | 
|---|
| 778 | delevts(EV_DYN, t_cur); | 
|---|
| 779 |  | 
|---|
| 780 | } else if ((stcrow EQ 20) AND (stccol GE 6) AND | 
|---|
| 781 | (2 EQ ((stccol - 6) % 5))) {                 /* location */ | 
|---|
| 782 |  | 
|---|
| 783 | delevts(EV_LOCN, t_cur); | 
|---|
| 784 |  | 
|---|
| 785 | } else if (stcrow EQ 23) {                              /* analog */ | 
|---|
| 786 |  | 
|---|
| 787 | deladat(); | 
|---|
| 788 |  | 
|---|
| 789 | } else if (stcrow EQ 24) {                              /* score */ | 
|---|
| 790 |  | 
|---|
| 791 | if (stccol LE 4) { | 
|---|
| 792 |  | 
|---|
| 793 | /* clear score */ | 
|---|
| 794 |  | 
|---|
| 795 | if (insmode)            /* cancel insert mode */ | 
|---|
| 796 | icancel(); | 
|---|
| 797 |  | 
|---|
| 798 | sc_clr(curscor);        /* clear score itself */ | 
|---|
| 799 | selscor(curscor);       /* refresh the display */ | 
|---|
| 800 |  | 
|---|
| 801 | } else if ((stccol GE 10) AND (stccol LE 25)) { | 
|---|
| 802 |  | 
|---|
| 803 | /* clear score name */ | 
|---|
| 804 |  | 
|---|
| 805 | memset(scname[curscor], ' ', 16); | 
|---|
| 806 | dswin(13); | 
|---|
| 807 | } | 
|---|
| 808 | } | 
|---|
| 809 | } | 
|---|
| 810 |  | 
|---|
| 811 | /* | 
|---|
| 812 | ============================================================================= | 
|---|
| 813 | sdmkey() -- score display menu key processor | 
|---|
| 814 | ============================================================================= | 
|---|
| 815 | */ | 
|---|
| 816 |  | 
|---|
| 817 | void sdmkey(void) | 
|---|
| 818 | { | 
|---|
| 819 | if (astat) { | 
|---|
| 820 |  | 
|---|
| 821 | if (insmode) | 
|---|
| 822 | icancel(); | 
|---|
| 823 | } | 
|---|
| 824 |  | 
|---|
| 825 | stdmkey(); | 
|---|
| 826 | } | 
|---|
| 827 |  | 
|---|
| 828 | /* | 
|---|
| 829 | ============================================================================= | 
|---|
| 830 | scfield() -- setup field routines for the score display | 
|---|
| 831 | ============================================================================= | 
|---|
| 832 | */ | 
|---|
| 833 |  | 
|---|
| 834 | void scfield(void) | 
|---|
| 835 | { | 
|---|
| 836 | curset(&sc_flds); | 
|---|
| 837 | } | 
|---|
| 838 |  | 
|---|