Skip to content

Commit 4301a1d

Browse files
larsbrinkhoffvolvo-larsbrinkhoff
authored andcommitted
Convert a Calcomp plot file to SVG.
1 parent 7a94e62 commit 4301a1d

File tree

4 files changed

+95
-4
lines changed

4 files changed

+95
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.o
33
*.dSYM
44
acct
5+
calcomp
56
cat36
67
check
78
classify-tape

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ LIBWORD = libword/libword.a
1111
OBJS = pdp10-opc.o info.o dis.o symbols.o \
1212
timing.o timing_ka10.o timing_ki10.o memory.o weenix.o
1313

14-
UTILS = acct cat36 classify-tape constantinople cross dart dskdmp \
15-
dump dumper harscntopbm ipak itsarc kldcp klfedr linum macdmp \
16-
macro-tapes magdmp magfrm mini-dumper od10 old-cpio palx plt \
17-
scrmbl tape-dir tendmp tito tvpic unscr
14+
UTILS = acct calcomp cat36 classify-tape constantinople cross dart \
15+
dskdmp dump dumper harscntopbm ipak itsarc kldcp klfedr linum \
16+
macdmp macro-tapes magdmp magfrm mini-dumper od10 old-cpio \
17+
palx plt scrmbl tape-dir tendmp tito tvpic unscr
1818

1919
all: dis10 $(UTILS) check
2020

@@ -83,6 +83,9 @@ tito: tito.o $(OBJS) $(LIBWORD)
8383
plt: plt.o svg.o $(OBJS) $(LIBWORD)
8484
$(CC) $(CFLAGS) $^ -o $@
8585

86+
calcomp: calcomp.o svg.o $(OBJS) $(LIBWORD)
87+
$(CC) $(CFLAGS) $^ -o $@
88+
8689
dart: dart.o dec.o $(OBJS) $(LIBWORD)
8790
$(CC) $(CFLAGS) $^ -o $@
8891

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ is elsewhere: http://github.com/larsbrinkhoff/mldev
2828
- Extract files from a DECtape image in TENDMP/DTBOOT format.
2929
- Create a TENDMP/DTBOOT image.
3030
- Print entried in a WAITS accounting file.
31+
- Convert a Calcomp plot file to SVG.
3132

3233
## File formats supported.
3334

calcomp.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/* Copyright (C) 2025 Lars Brinkhoff <lars@nocrew.org>
2+
3+
This program is free software: you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation, either version 2 of the License, or
6+
(at your option) any later version.
7+
8+
This program is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
GNU General Public License for more details.
12+
13+
You should have received a copy of the GNU General Public License
14+
along with this program. If not, see <http://www.gnu.org/licenses/>. */
15+
16+
#include <stdio.h>
17+
//#include <unistd.h>
18+
#include "dis.h"
19+
#include "svg.h"
20+
21+
static int x, y;
22+
static void (*plot)(FILE *f, int x, int y);
23+
24+
static void fatal(const char *message)
25+
{
26+
fputs(message, stderr);
27+
exit(1);
28+
}
29+
30+
static void just_move(FILE *f, int x, int y)
31+
{
32+
(void)f;
33+
(void)x;
34+
(void)y;
35+
}
36+
37+
static void process(int data)
38+
{
39+
if ((data & 060) == 060)
40+
fatal ("Pen both up and down.");
41+
if (data & 040) {
42+
if (plot != just_move)
43+
svg_polyline_end(stdout);
44+
plot = just_move;
45+
}
46+
if (data & 020) {
47+
if (plot == just_move)
48+
plot = svg_polyline_begin;
49+
}
50+
if (data & 010)
51+
y--;
52+
if (data & 004)
53+
y++;
54+
if (data & 002)
55+
x--;
56+
if (data & 001)
57+
x++;
58+
plot (stdout, x, y);
59+
if (plot == svg_polyline_begin)
60+
plot = svg_polyline_point;
61+
}
62+
63+
static void calcomp(FILE *f)
64+
{
65+
word_t data;
66+
int i;
67+
68+
for (;;) {
69+
data = get_word(f);
70+
if (data == -1)
71+
return;
72+
for (i = 0; i < 6; i++, data <<= 6)
73+
process((data >> 30) & 077);
74+
}
75+
}
76+
77+
int main(void)
78+
{
79+
input_word_format = &aa_word_format;
80+
x = y = 0;
81+
plot = just_move;
82+
svg_file_begin(stdout);
83+
calcomp(stdin);
84+
svg_file_end(stdout);
85+
return 0;
86+
}

0 commit comments

Comments
 (0)