Skip to content

Instantly share code, notes, and snippets.

@remy
Created June 1, 2020 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remy/4913bdb6b3f8d5901016b050216382b1 to your computer and use it in GitHub Desktop.
Save remy/4913bdb6b3f8d5901016b050216382b1 to your computer and use it in GitHub Desktop.
See readme for usage

For use with: https://github.com/kounch/knloader

Written for the mac, though I'm sure it can be adjusted to work on linux and WSL.

Make sure to change SD_CARD and GAMES to the root of your SD Card and the games/rom folder on the card - this last variable GAMES is needed in the knloader.bdt database.

Then run as:

sh knloader-db-maker.sh > knloader.bdt

Copy the file across to your SD card into the same location as the knloader.bas file, then follow the directions at https://github.com/kounch/knloader

Notes

  • The types are hardcoded in the script as: TAP=1, TZX=10, etc - see the database format for the types that suit you.
set -e
# set -x
# change these vars to suit your own locations
SD_CARD=/Volumes/NEXT
GAMES=/ROMS
function upper() {
echo $1 | tr "[a-z]" "[A-Z]"
}
# modes hard coded - adjust to your needs:
# https://github.com/kounch/knloader/blob/master/docs/Manual_en.adoc#database-file-format
function modes() {
ext=$(echo $1 | tr "[a-z]" "[A-Z]") # to uppercase
if [ "$ext" = "3DOS" ]; then
echo "0"
return 0
fi
if [ "$ext" = "TAP" ]; then
echo "1"
return 0
fi
if [ "$ext" = "TZX" ]; then
echo "10"
return 0
fi
if [ "$ext" = "NEX" ]; then
echo "15"
return 0
fi
# default to SNA, etc
echo "16"
}
function format() {
full=$@
filename=$(basename -- "$full")
filePath="${full#$SD_CARD$GAMES/}"
if [ "$filePath" = "$filename" ] ; then
filePath=""
fi
extension="${filename##*.}"
base="${filename%%.*}"
mode=$(modes $extension)
echo "$base,$mode,$filePath,$filename"
}
echo $GAMES
find $SD_CARD$GAMES -type f \( -iname '*.tap' -or -iname '*.tzx' -or -iname '*.sna' -or -iname '*.z80' -or -iname '*.nex' \) | grep -v '/._' | sort -i | while read line; do
format "$line"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment