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