aboutsummaryrefslogtreecommitdiff
path: root/utils/gentranscode.sh
blob: 4fe7df8807ae2efafc1f71d1034e6f3b434a19a9 (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
#!/bin/sh

gcc -DDEBUG h48_to_lst.c ../cube.c -o h48_to_lst
gcc -DDEBUG invert.c ../cube.c -o invert

lineavx() { printf '#define _trans_cube_%s ' "$1"; }
linesrc() { printf '_static cube_fast_t _trans_cube_%s = ' "$1"; }
sedavx() { sed '1,2s/$/ \\/ ; 3s/$/)/ ; 3q'; }
sedsrc() { sed '3s/$/ };/ ; 3q'; }

gen() {
	for f in transform_??_???.txt; do
		trans="$(echo $f | sed 's/.*_// ; s/\.txt//')"
		printf '[%s] = {\n' "$trans"

		printf '\t[NORMAL] = {\n'
		lst="$(./h48_to_lst <"$f")"
		c="$(echo $lst | cut -d ' ' -f -8 | rev | cut -c 2- | rev)"
		e="$(echo $lst | cut -d ' ' -f 9-)"
		printf '\t\t.corner = {%s},\n' "$c"
		printf '\t\t.edge = {%s}\n' "$e"
		printf '\t},\n'

		printf '\t[INVERSE] = {\n'
		inv="$(./invert <"$f" | ./h48_to_lst)"
		c="$(echo $inv | cut -d ' ' -f -8 | rev | cut -c 2- | rev)"
		e="$(echo $inv | cut -d ' ' -f 9-)"
		printf '\t\t.corner = {%s},\n' "$c"
		printf '\t\t.edge = {%s}\n' "$e"
		printf '\t}\n'

		printf '},\n'
	done
}

gen
rm -f h48_to_lst invert

Generated with cgit - Back to sebastiano.tronto.net