source: buchla-68k/ram/sqwrite.c@ 7258c6a

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

Use standard integer types.

  • Property mode set to 100644
File size: 2.7 KB
Line 
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
21extern short debugsw;
22#endif
23
24extern int32_t chksum(int8_t *area, int32_t len);
25
26/*
27
28*/
29
30/*
31 =============================================================================
32 sqsizer() -- return number of bytes necessary for storing
33 active sequence lines
34 =============================================================================
35*/
36
37int32_t sqsizer(void)
38{
39 register int16_t i, na;
40 register int32_t nb;
41
42 nb = 0L;
43
44 for (i = 0; i < NSLINES; i++) {
45
46 na = 0;
47
48 if (seqtab[i].seqtime) /* check the time */
49 na += 2L;
50
51 if (seqtab[i].seqact1) /* check action 1 */
52 na += 4L;
53
54 if (seqtab[i].seqact2) /* check action 2 */
55 na += 4L;
56
57 if (seqtab[i].seqact3) /* check action 3 */
58 na += 4L;
59
60 if (na) /* tote up the result */
61 nb += (na + 3);
62 }
63
64 if (nb)
65 ++nb;
66
67#if DEBUGIT
68 if (debugsw)
69 printf("sqsizer(): %ld bytes required\n", nb);
70#endif
71
72 return(nb);
73}
74
75/*
76
77*/
78
79/*
80 =============================================================================
81 sqwrite() -- store a sequence table
82 =============================================================================
83*/
84
85int16_t sqwrite(FILE *fp)
86{
87 int16_t seq;
88 int8_t cb, zero;
89 int8_t scid[48];
90
91#if DEBUGIT
92 if (debugsw)
93 printf("sqwrite($%08lX): entered\n", fp);
94#endif
95
96 zero = 0;
97
98 ldwmsg("Busy -- Please stand by", (int8_t *)0L, " writing sequences",
99 LCFBX10, LCBBX10);
100
101 for (seq = 0; seq < NSLINES; seq++) {
102
103 cb = 0x00;
104
105 if (seqtab[seq].seqtime)
106 cb |= 0x08;
107
108 if (seqtab[seq].seqact1)
109 cb |= 0x04;
110
111 if (seqtab[seq].seqact2)
112 cb |= 0x02;
113
114 if (seqtab[seq].seqact3)
115 cb |= 0x01;
116
117 if (0 EQ cb)
118 continue;
119
120 if (wr_ec(fp, &cb, 1L)) /* Control byte */
121 return(FAILURE);
122
123 if (wr_ec(fp, &seq, 2L)) /* Line number */
124 return(FAILURE);
125
126 if (cb & 0x08) /* Time */
127 if (wr_ec(fp, &seqtab[seq].seqtime, 2L))
128 return(FAILURE);
129
130 if (cb & 0x04) /* Action 1 */
131 if (wr_ec(fp, &seqtab[seq].seqact1, 4L))
132 return(FAILURE);
133
134 if (cb & 0x02) /* Action 2 */
135 if (wr_ec(fp, &seqtab[seq].seqact2, 4L))
136 return(FAILURE);
137
138 if (cb & 0x01) /* Action 3 */
139 if (wr_ec(fp, &seqtab[seq].seqact3, 4L))
140 return(FAILURE);
141 }
142
143 if (wr_ec(fp, &zero, 1L)) /* terminator */
144 return(FAILURE);
145
146#if DEBUGIT
147 if (debugsw)
148 printf("sqwrite(): SUCCESS\n");
149#endif
150
151 return(SUCCESS);
152}
Note: See TracBrowser for help on using the repository browser.