commit 5ae343512cc4210906db58d370244baa69f8692e
parent 9ed87d6f6c1e211a37d322728edc22e6f8011867
Author: phoebos <ben@bvnf.space>
Date: Mon, 6 Jun 2022 16:56:25 +0100
uxnsolve: add change to check version info
Diffstat:
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/uxnsolve b/uxnsolve
@@ -1,5 +1,7 @@
#!/bin/sh -e
+VERSION=1
+
[ "$#" -eq 2 ] || {
printf "usage: %s file.tal.debug address\n" "$0" >&2
exit 1
@@ -20,19 +22,29 @@ esac
debug_file="$1"
source_file="${1%.debug}"
+check_versions() {
+ read -r v < "$1"
+ if [ "$v" != "$VERSION" ]; then
+ printf "\033[1;33mERROR\033[m: incompatible version '%s' (this tool is version %d)\n" "$v" "$VERSION" >&2
+ exit 1
+ fi
+}
+
compare_file_timestamps() {
+ # TODO: recurse through included files to check timestamps
case "$(ls -t "$1" "$1.debug")" in
"$1.debug"*) ;;
*) printf "\033[1;33mWARNING\033[m: source file is newer than debug info\n" >&2 ;;
esac
}
+check_versions "$debug_file"
compare_file_timestamps "$source_file"
address="$(printf "%s" "$2" | tr 'a-f' 'A-F')"
dec_address="$(printf "16iAo%s 100-p\n" "$address" | dc || kill 0)"
-# add 1 because the zeroth byte is on the first line
-dec_address="$((dec_address + 1))"
+# add 3 because the zeroth byte is on the third line
+dec_address="$((dec_address + 3))"
[ "$dec_address" -lt 0 ] && {
printf "address %s is in zero page, don't subtract 0x0100\n" "$address"