[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 |
|
---|
[b28a12e] | 10 | #include "ram.h"
|
---|
[f40a309] | 11 |
|
---|
| 12 | /*
|
---|
| 13 | =============================================================================
|
---|
| 14 | sqsizer() -- return number of bytes necessary for storing
|
---|
| 15 | active sequence lines
|
---|
| 16 | =============================================================================
|
---|
| 17 | */
|
---|
| 18 |
|
---|
[7258c6a] | 19 | int32_t sqsizer(void)
|
---|
[f40a309] | 20 | {
|
---|
[7258c6a] | 21 | register int16_t i, na;
|
---|
| 22 | register int32_t nb;
|
---|
[f40a309] | 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 */
|
---|
[6f0834c] | 31 | na += 2;
|
---|
[f40a309] | 32 |
|
---|
| 33 | if (seqtab[i].seqact1) /* check action 1 */
|
---|
[6f0834c] | 34 | na += 4;
|
---|
[f40a309] | 35 |
|
---|
| 36 | if (seqtab[i].seqact2) /* check action 2 */
|
---|
[6f0834c] | 37 | na += 4;
|
---|
[f40a309] | 38 |
|
---|
| 39 | if (seqtab[i].seqact3) /* check action 3 */
|
---|
[6f0834c] | 40 | na += 4;
|
---|
[f40a309] | 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 |
|
---|
[7258c6a] | 63 | int16_t sqwrite(FILE *fp)
|
---|
[f40a309] | 64 | {
|
---|
[7258c6a] | 65 | int16_t seq;
|
---|
| 66 | int8_t cb, zero;
|
---|
[f40a309] | 67 |
|
---|
| 68 | #if DEBUGIT
|
---|
| 69 | if (debugsw)
|
---|
| 70 | printf("sqwrite($%08lX): entered\n", fp);
|
---|
| 71 | #endif
|
---|
| 72 |
|
---|
| 73 | zero = 0;
|
---|
| 74 |
|
---|
[7258c6a] | 75 | ldwmsg("Busy -- Please stand by", (int8_t *)0L, " writing sequences",
|
---|
[f40a309] | 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 | }
|
---|
[6262b5c] | 130 |
|
---|