comparison ffstools/caltools/fc-add-ramps.c @ 859:e5ef798e2d35

fc-add-ramps new program written, compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 18 Dec 2021 21:15:21 +0000
parents
children 7d4f080f66db
comparison
equal deleted inserted replaced
858:a684dd7799f8 859:e5ef798e2d35
1 /*
2 * This utility reads a tx-ramps table in FreeCalypso ASCII format,
3 * sums up each ramp and reports these sums. The intended purpose is
4 * to check if all ramps add up to 128 like they are supposed to.
5 */
6
7 #include <sys/types.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <strings.h>
12
13 u_char data[512];
14 unsigned sums[32];
15
16 read_input(filename)
17 char *filename;
18 {
19 char *format;
20
21 if (read_rf_table_ext(filename, data, 1, &format, (unsigned *) 0))
22 exit(1);
23 if (strcmp(format, "tx-ramps")) {
24 fprintf(stderr, "error: %s is not a tx-ramps table\n",
25 filename);
26 exit(1);
27 }
28 }
29
30 compute_sums()
31 {
32 int i, j;
33 unsigned accum;
34 u_char *dp = data;
35
36 for (i = 0; i < 32; i++) {
37 accum = 0;
38 for (j = 0; j < 16; j++)
39 accum += *dp++;
40 sums[i] = accum;
41 }
42 }
43
44 output()
45 {
46 unsigned n;
47
48 for (n = 0; n < 16; n++) {
49 printf("Template #%u ramp-up sum: %u\n", sums[n*2]);
50 printf("Template #%u ramp-down sum: %u\n", sums[n*2+1]);
51 }
52 }
53
54 main(argc, argv)
55 char **argv;
56 {
57 if (argc != 2) {
58 fprintf(stderr, "usage: %s tx-ramps-file\n", argv[0]);
59 exit(1);
60 }
61 read_input(argv[1]);
62 compute_sums();
63 output();
64 exit(0);
65 }