diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-22 09:00:15 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-22 09:00:15 +0200 |
| commit | 8b72e391c7185e3da0dfbf0ab60068ac37e4d5cc (patch) | |
| tree | b79d8154f16a0dadd8d8265d32b8bd95e96263aa /utils | |
| parent | 510a7471348788fccba6b7c4b9f7b7cc9aee6ba9 (diff) | |
| download | nissy-core-8b72e391c7185e3da0dfbf0ab60068ac37e4d5cc.tar.gz nissy-core-8b72e391c7185e3da0dfbf0ab60068ac37e4d5cc.zip | |
Removed old scripts and updated public API
Diffstat (limited to '')
| -rw-r--r-- | utils/convert.c (renamed from src/core/io_formats.h) | 6 | ||||
| -rwxr-xr-x | utils/genmovecode.sh | 15 | ||||
| -rwxr-xr-x | utils/genmoveswitch.sh | 8 | ||||
| -rwxr-xr-x | utils/gentranscode.sh | 25 | ||||
| -rwxr-xr-x | utils/gentransswitch.sh | 14 | ||||
| -rwxr-xr-x | utils/gentranstests.sh | 35 | ||||
| -rw-r--r-- | utils/h48_to_lst.c | 22 | ||||
| -rw-r--r-- | utils/invert.c | 19 | ||||
| -rwxr-xr-x | utils/mirror.sh | 3 |
9 files changed, 6 insertions, 141 deletions
diff --git a/src/core/io_formats.h b/utils/convert.c index f5668d4..4f4bb8c 100644 --- a/src/core/io_formats.h +++ b/utils/convert.c | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | /* | ||
| 2 | This file contains code related to cube format conversion that used to | ||
| 3 | be in src/core. It is to be adapted into a standalone tool for cube | ||
| 4 | format conversion. | ||
| 5 | */ | ||
| 6 | |||
| 1 | STATIC cube_t readcube(const char *, const char *); | 7 | STATIC cube_t readcube(const char *, const char *); |
| 2 | STATIC int64_t writecube(const char *, cube_t, size_t n, char [n]); | 8 | STATIC int64_t writecube(const char *, cube_t, size_t n, char [n]); |
| 3 | STATIC void log_available_formats(void); | 9 | STATIC void log_available_formats(void); |
diff --git a/utils/genmovecode.sh b/utils/genmovecode.sh deleted file mode 100755 index cf13441..0000000 --- a/utils/genmovecode.sh +++ /dev/null | |||
| @@ -1,15 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | cc -DDEBUG h48_to_lst.c ../src/nissy.c -o h48_to_lst | ||
| 4 | |||
| 5 | gen() { | ||
| 6 | for f in cubes/move_??_*.txt; do | ||
| 7 | move="$(echo "$f" | sed 's/.*_// ; s/\.txt//')" | ||
| 8 | printf '#define _move_cube_%s fastcube( \\\n ' "$move" | ||
| 9 | ./h48_to_lst <"$f" | ||
| 10 | printf ')\n' | ||
| 11 | done | ||
| 12 | } | ||
| 13 | |||
| 14 | gen | ||
| 15 | rm -f h48_to_lst invert | ||
diff --git a/utils/genmoveswitch.sh b/utils/genmoveswitch.sh deleted file mode 100755 index 3b2a74b..0000000 --- a/utils/genmoveswitch.sh +++ /dev/null | |||
| @@ -1,8 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | printf '\tswitch (m) {\n' | ||
| 4 | for f in cubes/move_??_*.txt; do | ||
| 5 | t="$(echo "$f" | sed 's/.*_// ; s/\.txt//')" | ||
| 6 | printf '\tcase %s:\n\t\treturn _move(%s, c);\n' "$t" "$t" | ||
| 7 | done | ||
| 8 | printf '\t}\n' | ||
diff --git a/utils/gentranscode.sh b/utils/gentranscode.sh deleted file mode 100755 index 9a1de2c..0000000 --- a/utils/gentranscode.sh +++ /dev/null | |||
| @@ -1,25 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | cc -DDEBUG h48_to_lst.c ../src/nissy.c -o h48_to_lst | ||
| 4 | cc -DDEBUG invert.c ../src/nissy.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 cubes/transform_??_???.txt; do | ||
| 13 | trans="$(echo "$f" | sed 's/.*_// ; s/\.txt//')" | ||
| 14 | printf '#define _trans_cube_%s fastcube( \\\n ' "$trans" | ||
| 15 | ./h48_to_lst <"$f" | ||
| 16 | printf ')\n' | ||
| 17 | printf '#define _trans_cube_%s_inverse fastcube( \\\n ' \ | ||
| 18 | "$trans" | ||
| 19 | ./invert <"$f" | ./h48_to_lst | ||
| 20 | printf ')\n' | ||
| 21 | done | ||
| 22 | } | ||
| 23 | |||
| 24 | gen | ||
| 25 | rm -f h48_to_lst invert | ||
diff --git a/utils/gentransswitch.sh b/utils/gentransswitch.sh deleted file mode 100755 index 20e2bfb..0000000 --- a/utils/gentransswitch.sh +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | printf '\tswitch (t) {\n' | ||
| 4 | for f in cubes/transform_??_???.txt; do | ||
| 5 | t="$(echo "$f" | sed 's/.*_// ; s/\.txt//')" | ||
| 6 | mirror_or_rotation="$(echo "$t" | grep m)" | ||
| 7 | if [ -z "$mirror_or_rotation" ]; then | ||
| 8 | m="rotation" | ||
| 9 | else | ||
| 10 | m="mirrored" | ||
| 11 | fi | ||
| 12 | printf '\tcase %s:\n\t\treturn _trans_%s(%s, c);\n' "$t" "$m" "$t" | ||
| 13 | done | ||
| 14 | printf '\t}\n' | ||
diff --git a/utils/gentranstests.sh b/utils/gentranstests.sh deleted file mode 100755 index a257a0a..0000000 --- a/utils/gentranstests.sh +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | outdir="./generated_trans_tests" | ||
| 4 | |||
| 5 | mkdir -p "$outdir" | ||
| 6 | i=100 | ||
| 7 | |||
| 8 | while read -r line; do | ||
| 9 | [ -z "$line" ] && continue | ||
| 10 | |||
| 11 | trans_piece="$(echo "$line" | awk '{print $1}' | tr -d 'rm')" | ||
| 12 | move1="$(echo "$line" | awk '{print $2}')" | ||
| 13 | move2="$(echo "$line" | awk '{print $3}')" | ||
| 14 | |||
| 15 | rotation="rotation $trans_piece" | ||
| 16 | |||
| 17 | file1="$(ls cubes | grep "move_.*_${move1}.txt")" | ||
| 18 | file2="$(ls cubes | grep "move_.*_${move2}.txt")" | ||
| 19 | echo "$rotation" >"$outdir/${i}_${trans_piece}r_${move1}.in" | ||
| 20 | cat "cubes/$file1" >>"$outdir/${i}_${trans_piece}r_${move1}.in" | ||
| 21 | cp "cubes/$file2" "$outdir/${i}_${trans_piece}r_${move1}.out" | ||
| 22 | |||
| 23 | i=$((i+1)) | ||
| 24 | |||
| 25 | mirrored="mirrored $trans_piece" | ||
| 26 | move2m="$(echo "${move2}" | tr 'LR' 'RL')3" | ||
| 27 | |||
| 28 | file1="$(ls cubes | grep "move_.*_${move1}.txt")" | ||
| 29 | file2="$(ls cubes | grep "move_.*_${move2m}.txt")" | ||
| 30 | echo "$mirrored" >"$outdir/${i}_${trans_piece}m_${move1}.in" | ||
| 31 | cat "cubes/$file1" >>"$outdir/${i}_${trans_piece}m_${move1}.in" | ||
| 32 | cp "cubes/$file2" "$outdir/${i}_${trans_piece}m_${move1}.out" | ||
| 33 | |||
| 34 | i=$((i+1)) | ||
| 35 | done <transform_moves.txt | ||
diff --git a/utils/h48_to_lst.c b/utils/h48_to_lst.c deleted file mode 100644 index 03265b7..0000000 --- a/utils/h48_to_lst.c +++ /dev/null | |||
| @@ -1,22 +0,0 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <inttypes.h> | ||
| 3 | #include <stdbool.h> | ||
| 4 | |||
| 5 | #include "../src/nissy.h" | ||
| 6 | |||
| 7 | #define STRLENMAX 1000 | ||
| 8 | |||
| 9 | int main(void) { | ||
| 10 | char strin[STRLENMAX], strout[STRLENMAX]; | ||
| 11 | int result; | ||
| 12 | |||
| 13 | fgets(strin, STRLENMAX, stdin); | ||
| 14 | |||
| 15 | result = nissy_convertcube("H48", "LST", strin, strout); | ||
| 16 | if (result) | ||
| 17 | fprintf(stderr, "Error converting cube: code %d\n", result); | ||
| 18 | |||
| 19 | fputs(strout, stdout); | ||
| 20 | |||
| 21 | return 0; | ||
| 22 | } | ||
diff --git a/utils/invert.c b/utils/invert.c deleted file mode 100644 index 41580c0..0000000 --- a/utils/invert.c +++ /dev/null | |||
| @@ -1,19 +0,0 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <inttypes.h> | ||
| 3 | #include <stdbool.h> | ||
| 4 | |||
| 5 | #include "../src/nissy.h" | ||
| 6 | |||
| 7 | #define STRLENMAX 1000 | ||
| 8 | |||
| 9 | int main(void) { | ||
| 10 | char str[STRLENMAX], cube[22], inv[22]; | ||
| 11 | |||
| 12 | fgets(str, STRLENMAX, stdin); | ||
| 13 | nissy_readcube("H48", str, cube); | ||
| 14 | nissy_inverse(cube, inv); | ||
| 15 | nissy_writecube("H48", inv, str); | ||
| 16 | fputs(str, stdout); | ||
| 17 | |||
| 18 | return 0; | ||
| 19 | } | ||
diff --git a/utils/mirror.sh b/utils/mirror.sh deleted file mode 100755 index 41a434f..0000000 --- a/utils/mirror.sh +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | tr 'LR' 'RL' | ||
