1 | /*
|
---|
2 | =============================================================================
|
---|
3 | ldfield.c -- librarian display field processing and cursor motion
|
---|
4 | Version 47 -- 1989-11-15 -- 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 "charset.h"
|
---|
15 | #include "panel.h"
|
---|
16 | #include "hwdefs.h"
|
---|
17 | #include "fpu.h"
|
---|
18 | #include "curpak.h"
|
---|
19 |
|
---|
20 | #include "midas.h"
|
---|
21 | #include "instdsp.h"
|
---|
22 | #include "libdsp.h"
|
---|
23 | #include "score.h"
|
---|
24 |
|
---|
25 | extern void select(void);
|
---|
26 | extern int16_t whatbox(void);
|
---|
27 | extern void nokey(void);
|
---|
28 | extern int16_t nonf(int16_t k);
|
---|
29 | extern void cxkstd(void);
|
---|
30 | extern void cykstd(void);
|
---|
31 | extern void stdmkey(void);
|
---|
32 | extern int16_t et_null(int16_t n);
|
---|
33 | extern int16_t ef_null(int16_t n);
|
---|
34 | extern int16_t rd_null(int16_t n);
|
---|
35 | extern int16_t nd_null(int16_t n, int16_t k);
|
---|
36 | extern void lmwclr(void);
|
---|
37 | extern void vcputsv(int16_t *obase, int16_t nw, int16_t fg, int16_t bg, int16_t row, int16_t col, int8_t *str, int16_t pitch);
|
---|
38 | extern int16_t ftkind(int16_t ns);
|
---|
39 | extern void _clsvol(void);
|
---|
40 | extern int16_t lcancel(int16_t lct);
|
---|
41 | extern int16_t stdctp0(void);
|
---|
42 | extern int16_t ldline(int16_t cy);
|
---|
43 | extern int16_t lin2slt(int16_t line);
|
---|
44 | extern void dslslot(int16_t slot, uint16_t fg, int16_t row);
|
---|
45 | extern int16_t putcat(void);
|
---|
46 | extern int16_t showcat(void);
|
---|
47 | extern int16_t showsiz(void);
|
---|
48 |
|
---|
49 | extern uint16_t exp_c(uint16_t c);
|
---|
50 |
|
---|
51 | extern void *memset(void *vp, int8_t c, int16_t n);
|
---|
52 | extern int8_t *slotnam(uint16_t slot, uint16_t kind);
|
---|
53 |
|
---|
54 | /* |
---|
55 |
|
---|
56 | */
|
---|
57 |
|
---|
58 | #if DEBUGIT
|
---|
59 | extern short debugsw;
|
---|
60 | #endif
|
---|
61 |
|
---|
62 | extern int16_t astat;
|
---|
63 | extern int16_t catin;
|
---|
64 | extern int16_t cmfirst;
|
---|
65 | extern int16_t cxrate;
|
---|
66 | extern int16_t cxval;
|
---|
67 | extern int16_t cyrate;
|
---|
68 | extern int16_t cyval;
|
---|
69 | extern int16_t ldelsw;
|
---|
70 | extern int16_t lderrsw;
|
---|
71 | extern int16_t ldkind;
|
---|
72 | extern int16_t ldpass;
|
---|
73 | extern int16_t ldrow;
|
---|
74 | extern int16_t ldslot;
|
---|
75 | extern int16_t lmwtype;
|
---|
76 | extern int16_t loadrow;
|
---|
77 | extern int16_t loadsw;
|
---|
78 | extern int16_t lorchl;
|
---|
79 | extern int16_t lrasw;
|
---|
80 | extern int16_t lselsw;
|
---|
81 | extern int16_t ltagged;
|
---|
82 | extern int16_t ndisp;
|
---|
83 | extern int16_t oldltag;
|
---|
84 | extern int16_t oldpk;
|
---|
85 | extern int16_t oldsl;
|
---|
86 | extern int16_t pkctrl;
|
---|
87 | extern int16_t sliders;
|
---|
88 | extern int16_t stcrow;
|
---|
89 | extern int16_t stccol;
|
---|
90 | extern int16_t submenu;
|
---|
91 | extern int16_t tagslot;
|
---|
92 | extern int16_t thcwval;
|
---|
93 | extern int16_t tvcwval;
|
---|
94 |
|
---|
95 | extern uint16_t *librob;
|
---|
96 |
|
---|
97 | extern int8_t bfs[];
|
---|
98 | extern int8_t ldfile[];
|
---|
99 | extern int8_t ldcmnt[];
|
---|
100 |
|
---|
101 | extern int16_t crate1[];
|
---|
102 | extern int16_t ldmap[];
|
---|
103 |
|
---|
104 | extern LPF (*swpt)[];
|
---|
105 | extern LPF (*oldsw)[];
|
---|
106 |
|
---|
107 | extern struct selbox *csbp;
|
---|
108 | extern struct selbox ldboxes[];
|
---|
109 |
|
---|
110 | /* forward reference */
|
---|
111 |
|
---|
112 | void ld_prmv(void);
|
---|
113 | void ldxkey(void);
|
---|
114 | void ldmkey(void);
|
---|
115 | void ldkey(int16_t k);
|
---|
116 | void ldcxupd(void);
|
---|
117 | void ldcyupd(void);
|
---|
118 |
|
---|
119 | /* |
---|
120 |
|
---|
121 | */
|
---|
122 |
|
---|
123 | struct fet ld_fet1[] = {
|
---|
124 |
|
---|
125 | {21, 10, 17, 0x0000, et_null, ef_null, rd_null, nd_null}, /* name */
|
---|
126 | {21, 27, 63, 0x0000, et_null, ef_null, rd_null, nd_null}, /* comment */
|
---|
127 |
|
---|
128 | { 0, 0, 0, 0x0000, FN_NULL, FN_NULL, FN_NULL, FN_NULL}
|
---|
129 | };
|
---|
130 |
|
---|
131 | int16_t ldbox[][8] = { /* display box parameters */
|
---|
132 |
|
---|
133 | { 1, 1, 510, 13, LCFBX00, LCBBX00, 0, 1}, /* 0 - index area label */
|
---|
134 | { 1, 14, 510, 292, LCFBX01, LCBBX01, 1, 1}, /* 1 - index area */
|
---|
135 | { 1, 294, 78, 307, LCFBX02, LCBBX02, 21, 1}, /* 2 - file name label */
|
---|
136 | { 80, 294, 143, 307, LCFBX03, LCBBX03, 21, 10}, /* 3 - file name */
|
---|
137 | {145, 294, 214, 307, LCFBX04, LCBBX04, 21, 19}, /* 4 - comment label */
|
---|
138 | {216, 294, 510, 307, LCFBX05, LCBBX05, 21, 27}, /* 5 - comment */
|
---|
139 | { 1, 309, 70, 321, LCFBX06, LCBBX06, 22, 1}, /* 6 - fetch */
|
---|
140 | { 1, 322, 70, 335, LCFBX07, LCBBX07, 23, 1}, /* 7 - replace / append */
|
---|
141 | { 1, 336, 70, 348, LCFBX08, LCBBX08, 24, 1}, /* 8 - lo orch / hi orch */
|
---|
142 | { 72, 309, 255, 348, LCFBX09, LCBBX09, 22, 10}, /* 9 - store */
|
---|
143 | {257, 309, 510, 348, LCFBX10, LCBBX10, 22, 33} /* 10 - message window */
|
---|
144 | };
|
---|
145 |
|
---|
146 | int8_t *ldbxlb0[] = { /* display box labels */
|
---|
147 |
|
---|
148 | "RecrdType L FileName Comment Mem", /* 0 */
|
---|
149 | "", /* 1 */
|
---|
150 | "FileName", /* 2 */
|
---|
151 | "", /* 3 */
|
---|
152 | "Comment", /* 4 */
|
---|
153 | "", /* 5 */
|
---|
154 | "Index", /* 6 */
|
---|
155 | "", /* 7 */
|
---|
156 | "", /* 8 */
|
---|
157 | "", /* 9 */
|
---|
158 | "" /* 10 */
|
---|
159 | };
|
---|
160 |
|
---|
161 | /* |
---|
162 |
|
---|
163 | */
|
---|
164 |
|
---|
165 | struct curpak ld_flds = {
|
---|
166 |
|
---|
167 | stdctp0, /* curtype */
|
---|
168 | ld_prmv, /* premove */
|
---|
169 | nokey, /* pstmove */
|
---|
170 | cxkstd, /* cx_key */
|
---|
171 | cykstd, /* cy_key */
|
---|
172 | ldcxupd, /* cx_upd */
|
---|
173 | ldcyupd, /* cy_upd */
|
---|
174 | nokey, /* xy_up */
|
---|
175 | nokey, /* xy_dn */
|
---|
176 | ldxkey, /* x_key */
|
---|
177 | select, /* e_key */
|
---|
178 | ldmkey, /* m_key */
|
---|
179 | ldkey, /* d_key */
|
---|
180 | nonf, /* not_fld */
|
---|
181 | ld_fet1, /* curfet */
|
---|
182 | ldboxes, /* csbp */
|
---|
183 | crate1, /* cratex */
|
---|
184 | crate1, /* cratey */
|
---|
185 | CT_TEXT, /* cmtype */
|
---|
186 | LCURX, /* cxval */
|
---|
187 | LCURY /* cyval */
|
---|
188 | };
|
---|
189 |
|
---|
190 | /* |
---|
191 |
|
---|
192 | */
|
---|
193 |
|
---|
194 | /*
|
---|
195 | =============================================================================
|
---|
196 | ldxkey() -- handle the 'X' (delete) key
|
---|
197 | =============================================================================
|
---|
198 | */
|
---|
199 |
|
---|
200 | void ldxkey(void)
|
---|
201 | {
|
---|
202 | register int8_t *fn;
|
---|
203 | register int16_t slot;
|
---|
204 | int8_t buf[4];
|
---|
205 |
|
---|
206 | if (NOT astat) /* only on key closure */
|
---|
207 | return; /* FAILURE */
|
---|
208 |
|
---|
209 | clrerms();
|
---|
210 | stcrow = cyval / 14;
|
---|
211 | stccol = cxval >> 3;
|
---|
212 |
|
---|
213 | if (lselsw AND lrasw) {
|
---|
214 |
|
---|
215 | if (0 NE (slot = ldline(cyval))) {
|
---|
216 |
|
---|
217 | slot -= 1;
|
---|
218 | ldmap[slot] = -1;
|
---|
219 | dpy_scr(ldbox[1][4], slot);
|
---|
220 | return; /* SUCCESS */
|
---|
221 |
|
---|
222 | } else
|
---|
223 | return; /* FAILURE */
|
---|
224 | }
|
---|
225 |
|
---|
226 | if (lcancel(2))
|
---|
227 | return; /* SUCCESS */
|
---|
228 |
|
---|
229 | if (NOT ldelsw) { /* deletion not yet selected ? */
|
---|
230 |
|
---|
231 | if (0 NE (ldrow = ldline(cyval))) { /* index area ? */
|
---|
232 |
|
---|
233 | if (stccol EQ 11) { /* load tag ? */
|
---|
234 |
|
---|
235 | if (-1 EQ (slot = lin2slt(stcrow)))
|
---|
236 | return; /* FAILURE */
|
---|
237 |
|
---|
238 | if (ltagged) {
|
---|
239 |
|
---|
240 | if (slot NE tagslot) {
|
---|
241 |
|
---|
242 | filecat[tagslot].fcp0 = oldltag;
|
---|
243 | ltagged = FALSE;
|
---|
244 | showcat();
|
---|
245 | return; /* FAILURE */
|
---|
246 | }
|
---|
247 |
|
---|
248 | putcat();
|
---|
249 | ltagged = FALSE;
|
---|
250 | showcat();
|
---|
251 |
|
---|
252 | } else {
|
---|
253 |
|
---|
254 | oldltag = filecat[slot].fcp0;
|
---|
255 | filecat[slot].fcp0 = ' ';
|
---|
256 | ltagged = TRUE;
|
---|
257 | tagslot = slot;
|
---|
258 |
|
---|
259 | buf[0] = oldltag;
|
---|
260 | buf[1] = '\0';
|
---|
261 |
|
---|
262 | if (v_regs[5] & 0x0180)
|
---|
263 | vbank(0);
|
---|
264 |
|
---|
265 | vcputsv(librob, 64, exp_c(LD_DELC), ldbox[1][5],
|
---|
266 | stcrow, 11, buf, 14);
|
---|
267 | }
|
---|
268 |
|
---|
269 | return; /* SUCCESS */
|
---|
270 | }
|
---|
271 |
|
---|
272 | if ((stccol < 13) OR (stccol > 20)) /* name ? */
|
---|
273 | return; /* FAILURE */
|
---|
274 |
|
---|
275 | if (-1 NE (ldslot = lin2slt(ldrow))) {
|
---|
276 |
|
---|
277 | /* select file to delete */
|
---|
278 |
|
---|
279 | dslslot(ldslot, exp_c(LD_DELC), ldrow);
|
---|
280 | ldelsw = TRUE;
|
---|
281 | return; /* SUCCESS */
|
---|
282 | }
|
---|
283 | /* |
---|
284 |
|
---|
285 | */
|
---|
286 | } else { /* not in the index area */
|
---|
287 |
|
---|
288 | if (21 EQ stcrow) { /* filename or comment ? */
|
---|
289 |
|
---|
290 | if ((stccol GE 10) AND (stccol LE 17)) {
|
---|
291 |
|
---|
292 | /* clear filename field */
|
---|
293 |
|
---|
294 | memset(ldfile, ' ', 8);
|
---|
295 | ldswin(3);
|
---|
296 | return; /* SUCCESS */
|
---|
297 |
|
---|
298 | } else if (stccol GE 27) {
|
---|
299 |
|
---|
300 | /* clear comment field */
|
---|
301 |
|
---|
302 | memset(ldcmnt, ' ', 37);
|
---|
303 | ldswin(5);
|
---|
304 | return; /* SUCCESS */
|
---|
305 | }
|
---|
306 | }
|
---|
307 |
|
---|
308 | return; /* FAILURE */
|
---|
309 | }
|
---|
310 |
|
---|
311 | /* |
---|
312 |
|
---|
313 | */
|
---|
314 |
|
---|
315 | } else { /* file selected for deletion */
|
---|
316 |
|
---|
317 | /* delete the file if cursor hasn't moved */
|
---|
318 |
|
---|
319 | if (ldrow EQ ldline(cyval)) {
|
---|
320 |
|
---|
321 | filecat[ldslot].fcsize[0] = 0;
|
---|
322 | fn = slotnam(ldslot, ftkind(ldslot));
|
---|
323 |
|
---|
324 | unlink(fn);
|
---|
325 |
|
---|
326 | ldelsw = FALSE;
|
---|
327 | putcat();
|
---|
328 |
|
---|
329 | _clsvol();
|
---|
330 | showcat();
|
---|
331 | showsiz();
|
---|
332 |
|
---|
333 | return; /* SUCCESS */
|
---|
334 | }
|
---|
335 |
|
---|
336 | ldelsw = FALSE;
|
---|
337 | showcat();
|
---|
338 | return; /* SUCCESS */
|
---|
339 | }
|
---|
340 | }
|
---|
341 |
|
---|
342 | /* |
---|
343 |
|
---|
344 | */
|
---|
345 |
|
---|
346 | /*
|
---|
347 | =============================================================================
|
---|
348 | ld_prmv() -- librarian cursor pre-move function
|
---|
349 | =============================================================================
|
---|
350 | */
|
---|
351 |
|
---|
352 | void ld_prmv(void)
|
---|
353 | {
|
---|
354 | if (lderrsw) /* clear any error messages in the window */
|
---|
355 | clrerms();
|
---|
356 |
|
---|
357 | if (ltagged) { /* clear any non-stored load tag */
|
---|
358 |
|
---|
359 | filecat[tagslot].fcp0 = oldltag;
|
---|
360 | ltagged = FALSE;
|
---|
361 | showcat();
|
---|
362 | }
|
---|
363 | }
|
---|
364 |
|
---|
365 | /* |
---|
366 |
|
---|
367 | */
|
---|
368 |
|
---|
369 | /*
|
---|
370 | =============================================================================
|
---|
371 | ldcyupd() -- update cursor y location
|
---|
372 | =============================================================================
|
---|
373 | */
|
---|
374 |
|
---|
375 | void ldcyupd(void)
|
---|
376 | {
|
---|
377 | if (lmwtype EQ 1) {
|
---|
378 |
|
---|
379 | vtcyupd(); /* update virtual typewriter cursor y */
|
---|
380 |
|
---|
381 | } else {
|
---|
382 |
|
---|
383 | cyval += cyrate;
|
---|
384 |
|
---|
385 | if (cyval GT (CYMAX - 1))
|
---|
386 | cyval = CYMAX - 1;
|
---|
387 | else if (cyval LT 1)
|
---|
388 | cyval = 1;
|
---|
389 | }
|
---|
390 | }
|
---|
391 |
|
---|
392 | /* |
---|
393 |
|
---|
394 | */
|
---|
395 |
|
---|
396 | /*
|
---|
397 | =============================================================================
|
---|
398 | ldcxupd() -- update cursor x location
|
---|
399 | =============================================================================
|
---|
400 | */
|
---|
401 |
|
---|
402 | void ldcxupd(void)
|
---|
403 | {
|
---|
404 | if (lmwtype EQ 1 ) {
|
---|
405 |
|
---|
406 | vtcxupd(); /* update virtual typewriter cursor x */
|
---|
407 |
|
---|
408 | } else {
|
---|
409 |
|
---|
410 | cxval += cxrate;
|
---|
411 |
|
---|
412 | if (cxval GT (CXMAX - 1))
|
---|
413 | cxval = CXMAX - 1;
|
---|
414 | else if (cxval LT 1)
|
---|
415 | cxval = 1;
|
---|
416 | }
|
---|
417 | }
|
---|
418 |
|
---|
419 | /* |
---|
420 |
|
---|
421 | */
|
---|
422 |
|
---|
423 | /*
|
---|
424 | =============================================================================
|
---|
425 | ldmkey() -- librarian menu key processor
|
---|
426 | =============================================================================
|
---|
427 | */
|
---|
428 |
|
---|
429 | void ldmkey(void)
|
---|
430 | {
|
---|
431 | if (astat) {
|
---|
432 |
|
---|
433 | ltagged = FALSE;
|
---|
434 |
|
---|
435 | if ((sliders EQ LS_LIBR) OR (pkctrl EQ PK_LIBR)) {
|
---|
436 |
|
---|
437 | sliders = oldsl;
|
---|
438 | swpt = oldsw;
|
---|
439 | pkctrl = oldpk;
|
---|
440 | lcdlbls();
|
---|
441 | setleds();
|
---|
442 | }
|
---|
443 | }
|
---|
444 |
|
---|
445 | stdmkey();
|
---|
446 | }
|
---|
447 |
|
---|
448 | /* |
---|
449 |
|
---|
450 | */
|
---|
451 |
|
---|
452 | /*
|
---|
453 | =============================================================================
|
---|
454 | loadem() -- load multiple files
|
---|
455 | =============================================================================
|
---|
456 | */
|
---|
457 |
|
---|
458 | void loadem(int16_t key)
|
---|
459 | {
|
---|
460 | register int16_t c, i, rc, slot;
|
---|
461 |
|
---|
462 | rc = FALSE;
|
---|
463 |
|
---|
464 | if (getcat(0)) /* get the file catalog */
|
---|
465 | return;
|
---|
466 |
|
---|
467 | for (ldslot = 0; ldslot < 20; ldslot++) { /* check each slot */
|
---|
468 |
|
---|
469 | if (ocslot(ldslot) AND
|
---|
470 | ((c = filecat[ldslot].fcp0) & 0x007F) EQ (key & 0x007F)) {
|
---|
471 |
|
---|
472 | ldkind = ftkind(ldslot);
|
---|
473 |
|
---|
474 | if ((ldkind EQ FT_ORC) OR
|
---|
475 | (ldkind EQ FT_ORL) OR
|
---|
476 | (ldkind EQ FT_ORH))
|
---|
477 | lorchl = (c & 0x0080) ? 1 : 0;
|
---|
478 |
|
---|
479 | if (ldkind EQ FT_SCR)
|
---|
480 | for (i = 0; i < N_SCORES; i++)
|
---|
481 | ldmap[i] = i;
|
---|
482 |
|
---|
483 | if(getit())
|
---|
484 | return;
|
---|
485 |
|
---|
486 | rc = TRUE;
|
---|
487 | }
|
---|
488 | }
|
---|
489 |
|
---|
490 | if (rc AND (ndisp EQ -1))
|
---|
491 | m7menu();
|
---|
492 | }
|
---|
493 |
|
---|
494 | /* |
---|
495 |
|
---|
496 | */
|
---|
497 |
|
---|
498 | /*
|
---|
499 | =============================================================================
|
---|
500 | ldkey() -- process data key entry
|
---|
501 | =============================================================================
|
---|
502 | */
|
---|
503 |
|
---|
504 | void ldkey(int16_t k)
|
---|
505 | {
|
---|
506 | register int16_t c, col, row, slot;
|
---|
507 | int8_t buf[4];
|
---|
508 |
|
---|
509 | if (NOT astat) /* only on key closure */
|
---|
510 | return;
|
---|
511 |
|
---|
512 | if (NOT catin) /* catalog must be valid */
|
---|
513 | return;
|
---|
514 |
|
---|
515 | row = cyval / 14; /* determine cursor position */
|
---|
516 | col = cxval >> 3;
|
---|
517 |
|
---|
518 | if (col NE 11) /* must be column 11 */
|
---|
519 | return;
|
---|
520 |
|
---|
521 | if (-1 EQ (slot = lin2slt(row))) /* ... and a valid slot */
|
---|
522 | return;
|
---|
523 |
|
---|
524 | if (NOT ltagged) {
|
---|
525 |
|
---|
526 | oldltag = filecat[slot].fcp0; /* save old tag */
|
---|
527 | lcancel(3); /* cancel other selections */
|
---|
528 | }
|
---|
529 |
|
---|
530 | /* |
---|
531 |
|
---|
532 | */
|
---|
533 | /* process the key */
|
---|
534 |
|
---|
535 | if (k < 7)
|
---|
536 | filecat[slot].fcp0 = (c = k + 'A');
|
---|
537 | else if (k EQ 7)
|
---|
538 | return;
|
---|
539 | else if (k EQ 8)
|
---|
540 | filecat[slot].fcp0 = (c = filecat[slot].fcp0 & 0x007F);
|
---|
541 | else /* k EQ 9 */
|
---|
542 | filecat[slot].fcp0 = (c = filecat[slot].fcp0 | 0x0080);
|
---|
543 |
|
---|
544 | loadrow = row;
|
---|
545 | tagslot = slot;
|
---|
546 | ltagged = TRUE;
|
---|
547 |
|
---|
548 | dslslot(slot, exp_c(LD_SELC), row);
|
---|
549 | return;
|
---|
550 | }
|
---|
551 |
|
---|
552 | /* |
---|
553 |
|
---|
554 | */
|
---|
555 |
|
---|
556 | /*
|
---|
557 | =============================================================================
|
---|
558 | ldfield() -- setup field routines for the librarian
|
---|
559 | =============================================================================
|
---|
560 | */
|
---|
561 |
|
---|
562 | void ldfield(void)
|
---|
563 | {
|
---|
564 | lmwtype = 0;
|
---|
565 | ltagged = FALSE;
|
---|
566 | submenu = FALSE;
|
---|
567 |
|
---|
568 | curset(&ld_flds);
|
---|
569 | }
|
---|