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

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

Make function pointers more consistent.

  • Property mode set to 100644
File size: 10.7 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 void nokey(void);
28extern short nonf(short k);
29extern void cxkstd(void);
30extern void cykstd(void);
31extern void stdmkey(void);
32extern short et_null(short n);
33extern short ef_null(short n);
34extern short rd_null(short n);
35extern short nd_null(short n, short k);
36extern void lmwclr(void);
37extern void vcputsv(int *obase, int nw, int fg, int bg, int row, int col, char *str, int pitch);
38extern short ftkind(short ns);
39extern void _clsvol(void);
40extern short lcancel(short lct);
41extern short stdctp0(void);
42extern short ldline(short cy);
43extern short lin2slt(short line);
44extern void dslslot(short slot, unsigned fg, short row);
45extern short putcat(void);
46extern short showcat(void);
47extern int showsiz(void);
48
49extern unsigned exp_c(unsigned c);
50
51extern char *memset(char *sp, char c, int n);
52extern char *slotnam(unsigned slot, unsigned kind);
53
54/*
55
56*/
57
58#if DEBUGIT
59extern short debugsw;
60#endif
61
62extern short astat;
63extern short catin;
64extern short cmfirst;
65extern short cxrate;
66extern short cxval;
67extern short cyrate;
68extern short cyval;
69extern short ldelsw;
70extern short lderrsw;
71extern short ldkind;
72extern short ldpass;
73extern short ldrow;
74extern short ldslot;
75extern short lmwtype;
76extern short loadrow;
77extern short loadsw;
78extern short lorchl;
79extern short lrasw;
80extern short lselsw;
81extern short ltagged;
82extern short ndisp;
83extern short oldltag;
84extern short oldpk;
85extern short oldsl;
86extern short pkctrl;
87extern short sliders;
88extern short stcrow;
89extern short stccol;
90extern short submenu;
91extern short tagslot;
92extern short thcwval;
93extern short tvcwval;
94
95extern unsigned *librob;
96
97extern char bfs[];
98extern char ldfile[];
99extern char ldcmnt[];
100
101extern short crate1[];
102extern short ldmap[];
103
104extern LPF (*swpt)[];
105extern LPF (*oldsw)[];
106
107extern struct selbox *csbp;
108extern struct selbox ldboxes[];
109
110/* forward reference */
111
112void ld_prmv(void);
113void ldxkey(void);
114void ldmkey(void);
115void ldkey(short k);
116void ldcxupd(void);
117void ldcyupd(void);
118
119/*
120
121*/
122
123struct 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
131short 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
146char *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
165struct 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
200void ldxkey(void)
201{
202 register char *fn;
203 register short slot;
204 char 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
352void 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
375void 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
402void 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
429void 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
458void loadem(short key)
459{
460 register short 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
504void ldkey(short k)
505{
506 register short c, col, row, slot;
507 char 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
562void ldfield(void)
563{
564 lmwtype = 0;
565 ltagged = FALSE;
566 submenu = FALSE;
567
568 curset(&ld_flds);
569}
Note: See TracBrowser for help on using the repository browser.