diff --git a/.bashrc b/.bashrc index 5fc1ddc..617397f 100644 --- a/.bashrc +++ b/.bashrc @@ -61,6 +61,7 @@ function helpme() { echo -e "star-edit : Edit starship config" echo -e "rip : Rip a music CD" echo -e "wii : Convert Wii games" + echo -e "nds-patcher : Patches NDS ROMs" echo -e "" echo -e "\e[32m--------- System Stats ----------\e[0m" echo -e "kill [tab] : Show processes to Kill" @@ -90,10 +91,11 @@ alias ssh="kitty +kitten ssh" alias pack="tar -cvJf" # pack compressed.tar.xz /folder/file1.txt /folder/folder2 alias unpack="tar -xvf" # Scripts -alias myapps="sudo -v && ~/.bash/fedora-apps.sh" -alias phoneapps="~/.bash/phone-apps.sh" -alias compress="~/.bash/compress.sh" -alias wii="~/.bash/wii.sh" +alias myapps="sudo -v && ~/.bash/scripts/fedora-apps.sh" +alias phoneapps="~/.bash/scripts/phone-apps.sh" +alias compress="~/.bash/scripts/compress.sh" +alias wii="~/.bash/scripts/wii.sh" +alias nds-patcher="~/.bash/scripts/nds.sh" export GSK_RENDERER=cairo eval "$(starship init bash)" diff --git a/compress.sh b/scripts/compress.sh similarity index 100% rename from compress.sh rename to scripts/compress.sh diff --git a/fedora-apps.sh b/scripts/fedora-apps.sh similarity index 100% rename from fedora-apps.sh rename to scripts/fedora-apps.sh diff --git a/scripts/nds.sh b/scripts/nds.sh new file mode 100755 index 0000000..29ff574 --- /dev/null +++ b/scripts/nds.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# --- Configuration & Theme --- +ORANGE="#FF8700" +GREY="#808080" + +# Styling functions +title_style() { gum style --foreground "$ORANGE" --bold --border double --border-foreground "$GREY" --padding "0 2" --margin "1" "$1"; } +info_style() { gum style --foreground "$GREY" "$1"; } +error_style() { gum style --foreground "#FF0000" --bold "Error: $1"; } + +# --- Initialization --- +clear +title_style "NDS ROM PATCHER" + +# 1. Select the Folder +info_style "Navigate to the folder containing your ROM and Patch:" +TARGET_DIR=$(gum file --directory --cursor.foreground "$ORANGE") + +# Exit if no directory selected +[[ -z "$TARGET_DIR" ]] && exit 1 + +cd "$TARGET_DIR" || exit 1 + +# 2. Identify Files +# Find .nds files +NDS_FILES=$(ls *.nds 2>/dev/null) +if [[ -z "$NDS_FILES" ]]; then + error_style "No .nds files found in $TARGET_DIR" + exit 1 +fi + +# Find .xdelta files +PATCH_FILES=$(ls *.xdelta 2>/dev/null) +if [[ -z "$PATCH_FILES" ]]; then + error_style "No .xdelta files found in $TARGET_DIR" + exit 1 +fi + +# 3. User Selection (if multiple files exist) +ROM=$(echo "$NDS_FILES" | gum choose --header "Select the NDS ROM" --cursor.foreground "$ORANGE" --header.foreground "$GREY") +PATCH=$(echo "$PATCH_FILES" | gum choose --header "Select the xdelta patch" --cursor.foreground "$ORANGE" --header.foreground "$GREY") + +# 4. Prepare Output Name +# Strips extension and adds -patch.nds +FILENAME=$(basename "$ROM" .nds) +OUTPUT="${FILENAME}-patch.nds" + +# 5. Execute Patching +echo "" +gum spin --spinner dot --title "Applying patch to $ROM..." --title.foreground "$ORANGE" -- \ + xdelta3 -d -s "$ROM" "$PATCH" "$OUTPUT" + +# 6. Result Check +if [ $? -eq 0 ]; then + gum style --foreground "$ORANGE" --border rounded --border-foreground "$GREY" --padding "1 2" \ + "SUCCESS!" "File created: $OUTPUT" +else + error_style "Patching failed. Ensure your ROM is a clean dump." +fi diff --git a/phone-apps.sh b/scripts/phone-apps.sh similarity index 100% rename from phone-apps.sh rename to scripts/phone-apps.sh diff --git a/wii.sh b/scripts/wii.sh similarity index 100% rename from wii.sh rename to scripts/wii.sh