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

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

Added include files for global functions and variables.

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