Fixes c64 script.

This commit is contained in:
2026-09-07 17:38:37 -07:00
parent ad5036564e
commit fcfeee44cb

View File

@@ -1,9 +1,105 @@
if [ -f "$HOME/Applications/KickAssembler/KickAss.jar" ]; then # Setup Commodore 64 development environment (KickAssembler & VICE)
# TODO: typeset may fail if CLASSPATH is already tied by another script. Handle this. _setup_c64() {
typeset -T CLASSPATH classpath [ -n "$ZSH_VERSION" ] && setopt localoptions nonomatch nullglob
classpath+="$HOME/Applications/KickAssembler/KickAss.jar"
export CLASSPATH _add_to_path() {
fi [ -d "$1" ] || return 0
if [ -d "/Applications/VICE/bin" ]; then case ":$PATH:" in
path=(/Applications/VICE/bin $path) *":$1:"*) ;;
fi *) PATH="$1:$PATH"; export PATH ;;
esac
}
_add_to_classpath() {
[ -f "$1" ] || return 0
case ":$CLASSPATH:" in
*":$1:"*) ;;
*) CLASSPATH="${CLASSPATH:+$CLASSPATH:}$1"; export CLASSPATH ;;
esac
}
# 1. KickAssembler search locations (macOS and Linux)
_kickass_candidates=(
"${KICKASS_JAR:-}"
"${KICKASS_HOME:-}/KickAss.jar"
"${KICKASSEMBLER_HOME:-}/KickAss.jar"
"$HOME/Applications/KickAssembler/KickAss.jar"
"$HOME/Applications/KickAssembler/kickass.jar"
"/Applications/KickAssembler/KickAss.jar"
"/Applications/KickAssembler/kickass.jar"
"$HOME/Applications/KickAss/KickAss.jar"
"/Applications/KickAss/KickAss.jar"
"/opt/homebrew/share/kickassembler/KickAss.jar"
"/usr/local/share/kickassembler/KickAss.jar"
"/opt/kickassembler/KickAss.jar"
"/usr/share/kickassembler/KickAss.jar"
"$HOME/.local/share/kickassembler/KickAss.jar"
"$HOME/kickassembler/KickAss.jar"
"$HOME/KickAssembler/KickAss.jar"
)
_found_kickass_jar=""
for _jar in "${_kickass_candidates[@]}"; do
if [ -n "$_jar" ] && [ -f "$_jar" ]; then
_found_kickass_jar="$_jar"
break
fi
done
if [ -n "$_found_kickass_jar" ]; then
_add_to_classpath "$_found_kickass_jar"
_kickass_dir="$(dirname "$_found_kickass_jar")"
_add_to_path "$_kickass_dir"
export KICKASS_HOME="$_kickass_dir"
export KICKASS_JAR="$_found_kickass_jar"
if ! command -v kickass >/dev/null 2>&1; then
kickass() {
java -jar "$KICKASS_JAR" "$@"
}
fi
fi
# 2. VICE search locations (macOS and Linux)
_vice_candidates=(
"${VICE_HOME:-}/bin"
"${VICE_HOME:-}"
"$HOME/Applications/VICE/bin"
"/Applications/VICE/bin"
"$HOME/Applications/VICE.app/Contents/Resources/bin"
"/Applications/VICE.app/Contents/Resources/bin"
"$HOME/Applications/VICE.app/Contents/MacOS"
"/Applications/VICE.app/Contents/MacOS"
"/opt/homebrew/opt/vice/bin"
"/opt/homebrew/bin"
"/usr/local/opt/vice/bin"
"/usr/local/bin"
"/opt/vice/bin"
"/usr/bin"
)
_found_vice_bin=""
for _vdir in "${_vice_candidates[@]}"; do
if [ -n "$_vdir" ] && [ -d "$_vdir" ]; then
if [ -x "$_vdir/x64sc" ] || [ -x "$_vdir/x64" ] || [ -x "$_vdir/c1541" ] || [ -x "$_vdir/vice" ]; then
_found_vice_bin="$_vdir"
break
elif case "$_vdir" in *VICE*bin*|*vice*bin*) true ;; *) false ;; esac; then
_found_vice_bin="$_vdir"
break
fi
fi
done
if [ -n "$_found_vice_bin" ]; then
_add_to_path "$_found_vice_bin"
if [ -z "$VICE_HOME" ]; then
case "$_found_vice_bin" in
*/bin) export VICE_HOME="$(dirname "$_found_vice_bin")" ;;
*) export VICE_HOME="$_found_vice_bin" ;;
esac
fi
fi
}
_setup_c64
unset -f _setup_c64 _add_to_path _add_to_classpath