summaryrefslogtreecommitdiffstats
path: root/code/ATTIC/old-hpgl.c
blob: a915b8c8d737cbc8a41e76a7e9d651f6a5fcce8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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;
}