summaryrefslogtreecommitdiff
path: root/src/bin/turn2line.c
blob: 78e4b33d5d0acf692157332023b03b3c2bbd5e8b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[]) {
 int in,x=0,y=0,h=0,dh=argc<2?-4:atoi(argv[1]);
 for(;(in=fgetc(stdin)) != -1;dh=-4) {
  if(dh == -4) {
   switch(in) { case'B':dh++;case'm':dh++;case'L':dh++;case'l':dh++;
     case'F':dh++;case'r':dh++;case'R':dh++;case's':dh++;default:break; }
   if(dh==-4) continue;
  }
  h=(h+8+dh)%8;
  printf("%d %d ",x,y);
  x+=(signed char)"\x01\x01\x00\xff\xff\xff\x00\x01"[h%8];
  y+=(signed char)"\x00\x01\x01\x01\x00\xff\xff\xff"[h%8];
  printf("%d %d\n",x,y);
 }
 return 0;
}