summaryrefslogtreecommitdiffstats
path: root/code/ATTIC/old-hpgl.c
diff options
context:
space:
mode:
Diffstat (limited to 'code/ATTIC/old-hpgl.c')
-rw-r--r--code/ATTIC/old-hpgl.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/code/ATTIC/old-hpgl.c b/code/ATTIC/old-hpgl.c
new file mode 100644
index 0000000..a915b8c
--- /dev/null
+++ b/code/ATTIC/old-hpgl.c
@@ -0,0 +1,70 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+
+void pos(int x,int y,int b )
+{
+int16_t lr[2];
+
+lr[0]=x;
+lr[1]=y;
+
+lr[0]&=~1;
+if (!b) lr[1]|=1;
+
+fwrite(lr,sizeof(lr),1,stdout);
+fwrite(lr,sizeof(lr),1,stdout);
+fwrite(lr,sizeof(lr),1,stdout);
+}
+
+
+
+void ana(char *s )
+{
+int16_t lr[2];
+int x,y;
+
+
+if (strncmp(s,"PA",2)) return;
+
+if (sscanf(s,"PA%d,%d",&x,&y)!=2) return;
+
+
+lr[0]=y*2 - 10000;
+lr[1]=10000-x*2;
+
+lr[0]&=~1;
+if (x<3000) lr[1]|=1;
+
+fwrite(lr,sizeof(lr),1,stdout);
+}
+
+
+int main(int argc,char *argv[])
+{
+char c;
+char buf[1024];
+int ic,len;
+
+
+buf[0]=0;
+len=0;
+
+while ((ic=getchar())!=EOF)
+{
+c=ic;
+if ((c==';') || (c=='\n') || (c=='\r')) {
+ ana(buf);
+ buf[0]=0;
+ len=0;
+} else {
+ buf[len++]=c;
+ buf[len]=0;
+}
+}
+
+ana(buf);
+
+return 0;
+}