1 | /*
|
---|
2 | =============================================================================
|
---|
3 | sqwrite.c -- librarian - write sequence functions
|
---|
4 | Version 2 -- 1988-11-17 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #define DEBUGIT 0
|
---|
9 |
|
---|
10 | #include "stddefs.h"
|
---|
11 | #include "stdio.h"
|
---|
12 | #include "hwdefs.h"
|
---|
13 | #include "graphdef.h"
|
---|
14 | #include "vsdd.h"
|
---|
15 | #include "patch.h"
|
---|
16 |
|
---|
17 | #include "midas.h"
|
---|
18 | #include "libdsp.h"
|
---|
19 |
|
---|
20 | #if DEBUGIT
|
---|
21 | extern short debugsw;
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | extern long chksum();
|
---|
25 |
|
---|
26 | /* |
---|
27 |
|
---|
28 | */
|
---|
29 |
|
---|
30 | /*
|
---|
31 | =============================================================================
|
---|
32 | sqsizer() -- return number of bytes necessary for storing
|
---|
33 | active sequence lines
|
---|
34 | =============================================================================
|
---|
35 | */
|
---|
36 |
|
---|
37 | long
|
---|
38 | sqsizer()
|
---|
39 | {
|
---|
40 | register short i, na;
|
---|
41 | register long nb;
|
---|
42 |
|
---|
43 | nb = 0L;
|
---|
44 |
|
---|
45 | for (i = 0; i < NSLINES; i++) {
|
---|
46 |
|
---|
47 | na = 0;
|
---|
48 |
|
---|
49 | if (seqtab[i].seqtime) /* check the time */
|
---|
50 | na += 2L;
|
---|
51 |
|
---|
52 | if (seqtab[i].seqact1) /* check action 1 */
|
---|
53 | na += 4L;
|
---|
54 |
|
---|
55 | if (seqtab[i].seqact2) /* check action 2 */
|
---|
56 | na += 4L;
|
---|
57 |
|
---|
58 | if (seqtab[i].seqact3) /* check action 3 */
|
---|
59 | na += 4L;
|
---|
60 |
|
---|
61 | if (na) /* tote up the result */
|
---|
62 | nb += (na + 3);
|
---|
63 | }
|
---|
64 |
|
---|
65 | if (nb)
|
---|
66 | ++nb;
|
---|
67 |
|
---|
68 | #if DEBUGIT
|
---|
69 | if (debugsw)
|
---|
70 | printf("sqsizer(): %ld bytes required\n", nb);
|
---|
71 | #endif
|
---|
72 |
|
---|
73 | return(nb);
|
---|
74 | }
|
---|
75 |
|
---|
76 | /* |
---|
77 |
|
---|
78 | */
|
---|
79 |
|
---|
80 | /*
|
---|
81 | =============================================================================
|
---|
82 | sqwrite() -- store a sequence table
|
---|
83 | =============================================================================
|
---|
84 | */
|
---|
85 |
|
---|
86 | short
|
---|
87 | sqwrite(fp)
|
---|
88 | register FILE *fp;
|
---|
89 | {
|
---|
90 | short seq;
|
---|
91 | char cb, zero;
|
---|
92 | char scid[48];
|
---|
93 |
|
---|
94 | #if DEBUGIT
|
---|
95 | if (debugsw)
|
---|
96 | printf("sqwrite($%08lX): entered\n", fp);
|
---|
97 | #endif
|
---|
98 |
|
---|
99 | zero = 0;
|
---|
100 |
|
---|
101 | ldwmsg("Busy -- Please stand by", (char *)0L, " writing sequences",
|
---|
102 | LCFBX10, LCBBX10);
|
---|
103 |
|
---|
104 | for (seq = 0; seq < NSLINES; seq++) {
|
---|
105 |
|
---|
106 | cb = 0x00;
|
---|
107 |
|
---|
108 | if (seqtab[seq].seqtime)
|
---|
109 | cb |= 0x08;
|
---|
110 |
|
---|
111 | if (seqtab[seq].seqact1)
|
---|
112 | cb |= 0x04;
|
---|
113 |
|
---|
114 | if (seqtab[seq].seqact2)
|
---|
115 | cb |= 0x02;
|
---|
116 |
|
---|
117 | if (seqtab[seq].seqact3)
|
---|
118 | cb |= 0x01;
|
---|
119 |
|
---|
120 | if (0 EQ cb)
|
---|
121 | continue;
|
---|
122 |
|
---|
123 | if (wr_ec(fp, &cb, 1L)) /* Control byte */
|
---|
124 | return(FAILURE);
|
---|
125 |
|
---|
126 | if (wr_ec(fp, &seq, 2L)) /* Line number */
|
---|
127 | return(FAILURE);
|
---|
128 |
|
---|
129 | if (cb & 0x08) /* Time */
|
---|
130 | if (wr_ec(fp, &seqtab[seq].seqtime, 2L))
|
---|
131 | return(FAILURE);
|
---|
132 |
|
---|
133 | if (cb & 0x04) /* Action 1 */
|
---|
134 | if (wr_ec(fp, &seqtab[seq].seqact1, 4L))
|
---|
135 | return(FAILURE);
|
---|
136 |
|
---|
137 | if (cb & 0x02) /* Action 2 */
|
---|
138 | if (wr_ec(fp, &seqtab[seq].seqact2, 4L))
|
---|
139 | return(FAILURE);
|
---|
140 |
|
---|
141 | if (cb & 0x01) /* Action 3 */
|
---|
142 | if (wr_ec(fp, &seqtab[seq].seqact3, 4L))
|
---|
143 | return(FAILURE);
|
---|
144 | }
|
---|
145 |
|
---|
146 | if (wr_ec(fp, &zero, 1L)) /* terminator */
|
---|
147 | return(FAILURE);
|
---|
148 |
|
---|
149 | #if DEBUGIT
|
---|
150 | if (debugsw)
|
---|
151 | printf("sqwrite(): SUCCESS\n");
|
---|
152 | #endif
|
---|
153 |
|
---|
154 | return(SUCCESS);
|
---|
155 | }
|
---|