source: buchla-68k/ram/ldfield.c@ 0580615

Last change on this file since 0580615 was 0580615, checked in by Thomas Lopatic <thomas@…>, 4 years ago

Point of no return.

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