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

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

Fixed sqwrite.c.

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