diff options
Diffstat (limited to 'old/moves_trans/gentranscode.sh')
| -rwxr-xr-x | old/moves_trans/gentranscode.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/old/moves_trans/gentranscode.sh b/old/moves_trans/gentranscode.sh new file mode 100755 index 0000000..198ac93 --- /dev/null +++ b/old/moves_trans/gentranscode.sh | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | type="${1:-src}" | ||
| 4 | |||
| 5 | gcc -DDEBUG h48_to_"$type".c ../cube.c -o h48_to_"$type" | ||
| 6 | gcc -DDEBUG invert.c ../cube.c -o invert | ||
| 7 | |||
| 8 | # Old version | ||
| 9 | genarray() { | ||
| 10 | for f in transform_??_???.txt; do | ||
| 11 | trans="$(echo $f | sed 's/.*_// ; s/\.txt//')" | ||
| 12 | printf '[%s] = ' "$trans" | ||
| 13 | if [ "$1" = "-i" ]; then | ||
| 14 | ./invert <"$f" | ./h48_to_"$type" | ||
| 15 | else | ||
| 16 | ./h48_to_"$type" <"$f" | ||
| 17 | fi | ||
| 18 | printf ',\n' | ||
| 19 | done | ||
| 20 | } | ||
| 21 | |||
| 22 | genfuncs() { | ||
| 23 | for f in transform_??_???.txt; do | ||
| 24 | trans="$(echo $f | sed 's/.*_// ; s/\.txt//')" | ||
| 25 | printf 'static inline cube_fast_t\n_trans_%s' "$trans" | ||
| 26 | printf '(cube_fast_t c)\n{\n' | ||
| 27 | printf '\tcube_fast_t ret;\n\n' | ||
| 28 | printf '\tcube_fast_t tn = ' | ||
| 29 | ./h48_to_"$type" <"$f" | sed '2,4s/^/\t/' | ||
| 30 | printf ';\n\tcube_fast_t ti = ' | ||
| 31 | ./invert <"$f" | ./h48_to_"$type" | sed '2,4 s/^/\t/' | ||
| 32 | printf ';\n\n\tret = compose_fast(tn, c);\n' | ||
| 33 | printf '\tret = compose_fast(ret, ti);\n' | ||
| 34 | if [ -n "$(echo "$trans" | grep "m")" ]; then | ||
| 35 | printf '\tret = invertco_fast(ret);\n' | ||
| 36 | fi | ||
| 37 | printf '\n\treturn ret;\n}\n\n' | ||
| 38 | done | ||
| 39 | } | ||
| 40 | |||
| 41 | genfuncs | ||
| 42 | rm -f h48_to_"$type" invert | ||
