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

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

Zero redundant declarations.

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