cubecore

A library of core functions for working with 3x3x3 Rubik's cubes
git clone https://git.tronto.net/cubecore
Download | Log | Files | Refs | README | LICENSE

gentranscode.sh (993B)


      1 #!/bin/sh
      2 
      3 gcc -DDEBUG h48_to_lst.c ../cube.c -o h48_to_lst
      4 gcc -DDEBUG invert.c ../cube.c -o invert
      5 
      6 lineavx() { printf '#define _trans_cube_%s ' "$1"; }
      7 linesrc() { printf '_static cube_fast_t _trans_cube_%s = ' "$1"; }
      8 sedavx() { sed '1,2s/$/ \\/ ; 3s/$/)/ ; 3q'; }
      9 sedsrc() { sed '3s/$/ };/ ; 3q'; }
     10 
     11 gen() {
     12 	for f in transform_??_???.txt; do
     13 		trans="$(echo $f | sed 's/.*_// ; s/\.txt//')"
     14 		printf '[%s] = {\n' "$trans"
     15 
     16 		printf '\t[NORMAL] = {\n'
     17 		lst="$(./h48_to_lst <"$f")"
     18 		c="$(echo $lst | cut -d ' ' -f -8 | rev | cut -c 2- | rev)"
     19 		e="$(echo $lst | cut -d ' ' -f 9-)"
     20 		printf '\t\t.corner = {%s},\n' "$c"
     21 		printf '\t\t.edge = {%s}\n' "$e"
     22 		printf '\t},\n'
     23 
     24 		printf '\t[INVERSE] = {\n'
     25 		inv="$(./invert <"$f" | ./h48_to_lst)"
     26 		c="$(echo $inv | cut -d ' ' -f -8 | rev | cut -c 2- | rev)"
     27 		e="$(echo $inv | cut -d ' ' -f 9-)"
     28 		printf '\t\t.corner = {%s},\n' "$c"
     29 		printf '\t\t.edge = {%s}\n' "$e"
     30 		printf '\t}\n'
     31 
     32 		printf '},\n'
     33 	done
     34 }
     35 
     36 gen
     37 rm -f h48_to_lst invert