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

Last change on this file since 6aa430b was b28a12e, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Zero redundant declarations.

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