source: buchla-68k/orig/RAM/LDFIELD.C@ ee49131

Last change on this file since ee49131 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

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