2021-04-07 23:00:57 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2021-04-08 15:34:16 +02:00
|
|
|
# Copyright (C) 2021 KikooDX
|
2021-04-07 23:00:57 +02:00
|
|
|
|
2021-05-08 00:33:55 +02:00
|
|
|
START_POS="$PWD"
|
2021-04-20 00:40:12 +02:00
|
|
|
LEVEL_COUNT=0
|
|
|
|
|
2021-05-08 00:33:55 +02:00
|
|
|
cd assets/levels || exit
|
2021-04-07 23:00:57 +02:00
|
|
|
for PACK in *; do
|
2021-05-08 00:33:55 +02:00
|
|
|
PACK_NAME="$(basename "$PACK")"
|
|
|
|
cd "$PACK" || exit
|
2021-04-07 23:00:57 +02:00
|
|
|
for LEVEL in *; do
|
2021-05-08 00:33:55 +02:00
|
|
|
[ "$(basename $LEVEL)" == fxconv-metadata.txt ] && continue
|
|
|
|
LEVEL_ARRAY="$(printf '%s\n\tlevel_binaries[%s] = %s;' \
|
|
|
|
"$LEVEL_ARRAY" "$LEVEL_COUNT" \
|
|
|
|
"kble_$(basename "$LEVEL" .kble)")"
|
|
|
|
EXTERN_LEVEL="$(printf '%s\nextern uint8_t %s[];' "$EXTERN_LEVEL" \
|
|
|
|
"kble_$(basename "$LEVEL" .kble)")"
|
|
|
|
LEVEL_COUNT="$((LEVEL_COUNT + 1))"
|
|
|
|
LEVEL_NAME="$(basename "$LEVEL" | cut -c2- |
|
2021-04-08 00:38:40 +02:00
|
|
|
awk -F '.' '{print $1}' |
|
|
|
|
tr '[:lower:]' '[:upper:]')"
|
2021-04-07 23:00:57 +02:00
|
|
|
[ -z "$LEVEL_NAMES" ] &&
|
|
|
|
LEVEL_NAMES="
|
|
|
|
\"$LEVEL_NAME\"" ||
|
|
|
|
LEVEL_NAMES="$LEVEL_NAMES,
|
|
|
|
\"$LEVEL_NAME\""
|
|
|
|
done
|
|
|
|
cd ..
|
|
|
|
done
|
2021-04-20 00:40:12 +02:00
|
|
|
|
2021-05-08 00:33:55 +02:00
|
|
|
printf '/* SPDX-License-Identifier: GPL-3.0-or-later */\n'
|
|
|
|
printf '/* This code was generated with `make_filepaths.sh` */\n'
|
|
|
|
printf '#include "filepaths.h"\n'
|
|
|
|
printf '#include <stdint.h>\n'
|
|
|
|
|
|
|
|
printf '%s\n\n' "$EXTERN_LEVEL"
|
|
|
|
printf 'uint8_t *level_binaries[%s];\n\n' "$LEVEL_COUNT"
|
|
|
|
|
|
|
|
printf 'char *const level_names[%s] = {%s\n};\n\n' "$LEVEL_COUNT" "$LEVEL_NAMES"
|
2021-04-20 00:40:12 +02:00
|
|
|
|
2021-05-08 00:33:55 +02:00
|
|
|
# init_level_binaries
|
|
|
|
printf 'void\ninit_level_binaries(void)\n{'
|
|
|
|
printf '%s\n}\n' "$LEVEL_ARRAY"
|
2021-04-07 23:00:57 +02:00
|
|
|
|
2021-05-08 00:33:55 +02:00
|
|
|
# Create headers
|
|
|
|
cd "$START_POS"
|
|
|
|
mkdir -p generated/include
|
2021-05-29 12:12:51 +02:00
|
|
|
printf '#define LEVEL_COUNT %s\n' "$LEVEL_COUNT" > generated/include/pack_count.h
|
2021-05-08 00:33:55 +02:00
|
|
|
[ "$((LEVEL_COUNT % 4))" != 0 ] && LEVEL_COUNT="$((LEVEL_COUNT + 4 - LEVEL_COUNT % 4))"
|
2021-05-29 12:12:51 +02:00
|
|
|
printf '#define PACK_COUNT %s\n' "$((LEVEL_COUNT / 4))" >> generated/include/pack_count.h
|