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

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

Removed form-feed comments.

  • 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 sqwrite() -- store a sequence table
60 =============================================================================
61*/
62
63int16_t sqwrite(FILE *fp)
64{
65 int16_t seq;
66 int8_t cb, zero;
67 int8_t scid[48];
68
69#if DEBUGIT
70 if (debugsw)
71 printf("sqwrite($%08lX): entered\n", fp);
72#endif
73
74 zero = 0;
75
76 ldwmsg("Busy -- Please stand by", (int8_t *)0L, " writing sequences",
77 LCFBX10, LCBBX10);
78
79 for (seq = 0; seq < NSLINES; seq++) {
80
81 cb = 0x00;
82
83 if (seqtab[seq].seqtime)
84 cb |= 0x08;
85
86 if (seqtab[seq].seqact1)
87 cb |= 0x04;
88
89 if (seqtab[seq].seqact2)
90 cb |= 0x02;
91
92 if (seqtab[seq].seqact3)
93 cb |= 0x01;
94
95 if (0 EQ cb)
96 continue;
97
98 if (wr_ec(fp, &cb, 1L)) /* Control byte */
99 return(FAILURE);
100
101 if (wr_ec(fp, &seq, 2L)) /* Line number */
102 return(FAILURE);
103
104 if (cb & 0x08) /* Time */
105 if (wr_ec(fp, &seqtab[seq].seqtime, 2L))
106 return(FAILURE);
107
108 if (cb & 0x04) /* Action 1 */
109 if (wr_ec(fp, &seqtab[seq].seqact1, 4L))
110 return(FAILURE);
111
112 if (cb & 0x02) /* Action 2 */
113 if (wr_ec(fp, &seqtab[seq].seqact2, 4L))
114 return(FAILURE);
115
116 if (cb & 0x01) /* Action 3 */
117 if (wr_ec(fp, &seqtab[seq].seqact3, 4L))
118 return(FAILURE);
119 }
120
121 if (wr_ec(fp, &zero, 1L)) /* terminator */
122 return(FAILURE);
123
124#if DEBUGIT
125 if (debugsw)
126 printf("sqwrite(): SUCCESS\n");
127#endif
128
129 return(SUCCESS);
130}
131
Note: See TracBrowser for help on using the repository browser.