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

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

Unused variables and parameters.

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