├── N64-bios-installer.sh ├── README.md ├── saturn-jp-bios-installer.sh ├── saturn-jp-hitachi-bios-installer.sh ├── saturn-updater-workflow-builds.sh ├── saturn-us-bios-installer.sh └── saturn_ds-updater-workflow-builds.sh /N64-bios-installer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | version=1.1 3 | 4 | biospath="" 5 | 6 | corename="N64" 7 | 8 | self="$(readlink -f "$0")" 9 | 10 | conf="${self%.*}.ini" 11 | [ -f "$conf" ] && . "$conf" 12 | 13 | trap "result" 0 1 3 15 14 | 15 | result(){ 16 | case "$?" in 17 | # 0) echo -e "last version: Github says, last commit on $gitversion" 18 | # echo -e "core version: ${corefile##*/}\n";; 19 | 99) echo "self: updated self";; 20 | 100) echo "error: cannot reach url";; 21 | 101) echo "error: cannot write to sdcard";; 22 | 102) echo "error: download failed";; 23 | 103) echo "error: checksum failed";; 24 | 104) echo "error: json parsing failed";; 25 | 105) echo "error: unzip failed";; 26 | esac 27 | } 28 | 29 | makedir(){ [ -d "$1" ] || { mkdir -p "$1" || exit 101;};} 30 | download(){ wget --no-cache -q "$2" -O "$1" || { rm "$1";exit 102;};} 31 | urlcat(){ wget --no-cache -q "$1" -O - || exit 100;} 32 | checksum(){ md5sum "$1"|grep -q "$2" || { rm "$1";exit 103;};} 33 | unpack(){ unzip -j -o "$1" -d "$2" >/dev/null 2>&1 || exit 105;} 34 | 35 | selfurl="https://raw.githubusercontent.com/SwedishGojira/MiSTer-scripts/main/${corename}-bios-installer.sh" 36 | selfurl_version="$(urlcat "$selfurl"|sed -n 's,^version=,,;2p')" 37 | 38 | [ "$selfurl_version" = "$version" ] || { 39 | tempfile="$(mktemp -u)"; download "$tempfile" "$selfurl" 40 | mv "$tempfile" "$self";chmod +x "$self";exec "$self"; exit 99 41 | } 42 | 43 | echo "" 44 | echo -e "█▄\e[32m░░\e[39m█ \e[32m░\e[39m▄▀▀\e[32m░\e[39m ▄█\e[32m░░\e[39m ▄▄▄ ▄▄▄ ▄▄▄▄ ▄▄▄ " 45 | echo -e "█▀█▄█ █▀▀▀▄ ▄▀\e[32m░\e[39m█\e[32m░░\e[39m █▄▄▀ \e[32m░\e[39m█\e[32m░\e[39m █\e[32m░░\e[39m█ █▄▄\e[32m░\e[39m" 46 | echo -e "█\e[32m░░\e[39m▀█ ▀▄▄▄▀ ▀▀▀█▀\e[32m░\e[39m █▄▄▀ ▄█▄ █▄▄█ ▄▄█\e[32m░\e[39m" 47 | echo "" 48 | echo -e "█▀▀▄ █▀▀█ █\e[32m░░░\e[39m█ █▀▀▄ █\e[32m░░\e[39m █▀▀█ █▀▀█ █▀▀▄ █▀▀ █▀▀█" 49 | echo -e "█\e[32m░░\e[39m█ █\e[32m░░\e[39m█ █▄█▄█ █\e[32m░░\e[39m█ █\e[32m░░\e[39m █\e[32m░░\e[39m█ █▄▄█ █\e[32m░░\e[39m█ █▀▀ █▄▄▀ \e[1m\e[32mversion $version\e[0m" 50 | echo -e "▀▀▀\e[32m░\e[39m ▀▀▀▀ \e[32m░\e[39m▀\e[32m░\e[39m▀\e[32m░\e[39m ▀\e[32m░░\e[39m▀ ▀▀▀ ▀▀▀▀ ▀\e[32m░░\e[39m▀ ▀▀▀\e[32m░\e[39m ▀▀▀ ▀\e[32m░\e[39m▀▀ \e[32m░░░░░░░ ░░░\e[39m" 51 | echo "" 52 | 53 | echo "" 54 | echo "" 55 | echo "" 56 | 57 | # Path Priority (https://mister-devel.github.io/MkDocs_MiSTer/cores/paths/#path-priority) 58 | # There is a priority order of core paths. When you plug in a USB drive and it has a folder /games/Saturn on it (mounted locally as /media/usb<0..5>/games/Saturn when plugged in), 59 | # then the MiSTer Saturn core will look to that folder on the USB drive instead of the local one on the MicroSD at /media/fat/games/Saturn. 60 | # Here is the priority list from Main_MiSTer's file_io.cpp in order of highest priority to lowest: 61 | 62 | echo "Detecting $corename file path for bios installation..." 63 | 64 | declare -a paths=("/media/fat" 65 | "/media/fat/games" 66 | "/media/usb0" 67 | "/media/usb1" 68 | "/media/usb2" 69 | "/media/usb3" 70 | "/media/usb4" 71 | "/media/usb5" 72 | "/media/usb0/games" 73 | "/media/usb1/games" 74 | "/media/usb2/games" 75 | "/media/usb3/games" 76 | "/media/usb4/games" 77 | "/media/usb5/games" 78 | "/media/fat/cifs" 79 | "/media/fat/cifs/games" 80 | ) 81 | 82 | # You can access them using echo "${paths[0]}", "${paths[1]}" also 83 | 84 | ## now loop through the above array 85 | for path in "${paths[@]}"; do 86 | if [ -d "$path/$corename" ]; then 87 | echo "[X] $path/$corename" 88 | biospath="$path/$corename" 89 | else 90 | echo "[ ] $path/$corename" 91 | fi 92 | done 93 | 94 | if [ "$biospath" = "" ]; then 95 | biospath="/media/fat/games/$corename" 96 | echo "" 97 | echo "No existing $corename folder found!" 98 | echo "A $corename folder will be created at $biospath" 99 | mkdir -p "$biospath" 100 | fi 101 | 102 | echo "" 103 | 104 | biosurl1="https://github.com/ares-emulator/ares/raw/master/ares/System/Nintendo%2064/pif.ntsc.rom" 105 | bioshash1="5c124e7948ada85da603a522782940d0" 106 | biosfile1="boot.rom" 107 | biosurl2="https://github.com/ares-emulator/ares/raw/master/ares/System/Nintendo%2064/pif.pal.rom" 108 | bioshash2="d4232dc935cad0650ac2664d52281f3a" 109 | biosfile2="boot1.rom" 110 | biospack="/media/fat/Scripts/.N64-bios" 111 | 112 | if [ ! -d "$biospack" ]; then 113 | mkdir -p "$biospack" 114 | echo "Downloading $corename bios pack..." 115 | download "$biospack/$biosfile1" "$biosurl1" 116 | [ -n "$bioshash1" ] && checksum "$biospack/$biosfile1" "$bioshash1" 117 | download "$biospack/$biosfile2" "$biosurl2" 118 | [ -n "$bioshash2" ] && checksum "$biospack/$biosfile2" "$bioshash2" 119 | fi 120 | echo "Installing $corename bios into $biospath..." 121 | cp "$biospack/boot.rom" "$biospack/boot1.rom" "$biospath/" 122 | echo "Finished installing ${corename} bioses (NTSC and PAL) in $biospath" 123 | 124 | echo "" 125 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MiSTer-scripts 2 | Third party scripts for MiSTer FPGA 3 | 4 | > [!IMPORTANT] 5 | > All of my scripts are made to be run directly on the MiSTer from the standard /media/fat/Scripts directory. 6 | 7 | 8 | 9 | ## Saturn core updater scripts 10 | Small scripts that will download the latest successful build of the Saturn core from from the workflow of [srg320's official Saturn repo on Github](https://github.com/srg320/Saturn_MiSTer). 11 | 12 | - If you only want the single SDRAM version just get the "saturn-updater..." script. 13 | - If you want to download the dual SDRAM version of the core get both scripts as the "saturn_ds-updater..." is calling the standard script for all the work. 14 | 15 | As the builds on srg320's github are only available for 90 days before they are automatically deleted the script will now use the unstable builds from [MiSTer-unstable-nightlies / 16 | Saturn_MiSTer](https://github.com/MiSTer-unstable-nightlies/Saturn_MiSTer) as backup. 17 | 18 | 19 | ## Saturn bios installer scripts 20 | Small scripts that will download and install the US, JP or JP Hitachi recommended bios for the Saturn core. 21 | 22 | You only need to install one of the bios, not both. Just make sure you set the region in the core settings to the region matching the game you are loading and it should be working. 23 | 24 | > [!NOTE] 25 | > The Saturn core is still under heavy development and the bios have fluctuated between being called boot.rom and boot.bin. 26 | > Therefore the bios scripts is made to remove any old bios.bin file and replace it with the downloaded boot.rom which is the correct name for the bios at the moment of writing. 27 | 28 | 29 | ## N64 bios installer scripts 30 | Small script that will download and install the recommended NTSC and PAL bioses for the N64 core. 31 | -------------------------------------------------------------------------------- /saturn-jp-bios-installer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | version=1.4 3 | 4 | # === 5 | bios="df94c5b4d47eb3cc404d88b33a8fda237eaf4720" 6 | region="Japan" 7 | biosversion="1.01" 8 | name=jp 9 | # === 10 | 11 | biospath="" 12 | 13 | corename="Saturn" 14 | 15 | self="$(readlink -f "$0")" 16 | 17 | conf="${self%.*}.ini" 18 | [ -f "$conf" ] && . "$conf" 19 | 20 | trap "result" 0 1 3 15 21 | 22 | result(){ 23 | case "$?" in 24 | # 0) echo -e "last version: Github says, last commit on $gitversion" 25 | # echo -e "core version: ${corefile##*/}\n";; 26 | 99) echo "self: updated self";; 27 | 100) echo "error: cannot reach url";; 28 | 101) echo "error: cannot write to sdcard";; 29 | 102) echo "error: download failed";; 30 | 103) echo "error: checksum failed";; 31 | 104) echo "error: json parsing failed";; 32 | 105) echo "error: unzip failed";; 33 | esac 34 | } 35 | 36 | makedir(){ [ -d "$1" ] || { mkdir -p "$1" || exit 101;};} 37 | download(){ wget --no-cache -q "$2" -O "$1" || { rm "$1";exit 102;};} 38 | urlcat(){ wget --no-cache -q "$1" -O - || exit 100;} 39 | checksum(){ md5sum "$1"|grep -q "$2" || { rm "$1";exit 103;};} 40 | unpack(){ unzip -j -o "$1" -d "$2" >/dev/null 2>&1 || exit 105;} 41 | 42 | selfurl="https://raw.githubusercontent.com/SwedishGojira/MiSTer-scripts/main/saturn-${name}-bios-installer.sh" 43 | selfurl_version="$(urlcat "$selfurl"|sed -n 's,^version=,,;2p')" 44 | 45 | [ "$selfurl_version" = "$version" ] || { 46 | tempfile="$(mktemp -u)"; download "$tempfile" "$selfurl" 47 | mv "$tempfile" "$self";chmod +x "$self";exec "$self"; exit 99 48 | } 49 | 50 | echo "" 51 | echo -e "█▀▀ █▀▀█ ▀▀█▀▀ █\e[34m░░\e[39m█ █▀▀█ █▀▀▄ █▀▀▄ ▀█▀ █▀▀█ █▀▀ " 52 | echo -e "▀▀█ █▄▄█ \e[34m░░\e[39m█\e[34m░░\e[39m █\e[34m░░\e[39m█ █▄▄▀ █\e[34m░░\e[39m█ █▀▀▄ \e[34m░\e[39m█\e[34m░\e[39m █\e[34m░░\e[39m█ ▀▀█ " 53 | echo -e "▀▀▀ ▀\e[34m░░\e[39m▀ \e[34m░░\e[39m▀\e[34m░░\e[39m \e[34m░\e[39m▀▀▀ ▀\e[34m░\e[39m▀▀ ▀\e[34m░░\e[39m▀ ▀▀▀\e[34m░\e[39m ▀▀▀ ▀▀▀▀ ▀▀▀ " 54 | echo "" 55 | echo -e "█▀▀▄ █▀▀█ █\e[34m░░░\e[39m█ █▀▀▄ █\e[34m░░\e[39m █▀▀█ █▀▀█ █▀▀▄ █▀▀ █▀▀█ " 56 | echo -e "█\e[34m░░\e[39m█ █\e[34m░░\e[39m█ █▄█▄█ █\e[34m░░\e[39m█ █\e[34m░░\e[39m █\e[34m░░\e[39m█ █▄▄█ █\e[34m░░\e[39m█ █▀▀ █▄▄▀ \e[1m\e[34mversion $version\e[0m" 57 | echo -e "▀▀▀\e[34m░\e[39m ▀▀▀▀ \e[34m░\e[39m▀\e[34m░\e[39m▀\e[34m░\e[39m ▀\e[34m░░\e[39m▀ ▀▀▀ ▀▀▀▀ ▀\e[34m░░\e[39m▀ ▀▀▀\e[34m░\e[39m ▀▀▀ ▀\e[34m░\e[39m▀▀ \e[34m░░░░░░░ ░░░\e[39m" 58 | echo "" 59 | 60 | 61 | # Path Priority (https://mister-devel.github.io/MkDocs_MiSTer/cores/paths/#path-priority) 62 | # There is a priority order of core paths. When you plug in a USB drive and it has a folder /games/Saturn on it (mounted locally as /media/usb<0..5>/games/Saturn when plugged in), 63 | # then the MiSTer Saturn core will look to that folder on the USB drive instead of the local one on the MicroSD at /media/fat/games/Saturn. 64 | # Here is the priority list from Main_MiSTer's file_io.cpp in order of highest priority to lowest: 65 | 66 | echo "Detecting $corename file path for bios installation..." 67 | 68 | declare -a paths=("/media/fat" 69 | "/media/fat/games" 70 | "/media/usb0" 71 | "/media/usb1" 72 | "/media/usb2" 73 | "/media/usb3" 74 | "/media/usb4" 75 | "/media/usb5" 76 | "/media/usb0/games" 77 | "/media/usb1/games" 78 | "/media/usb2/games" 79 | "/media/usb3/games" 80 | "/media/usb4/games" 81 | "/media/usb5/games" 82 | "/media/fat/cifs" 83 | "/media/fat/cifs/games" 84 | ) 85 | 86 | # You can access them using echo "${paths[0]}", "${paths[1]}" also 87 | 88 | ## now loop through the above array 89 | for path in "${paths[@]}"; do 90 | if [ -d "$path/$corename" ]; then 91 | echo "[X] $path/$corename" 92 | biospath="$path/$corename" 93 | else 94 | echo "[ ] $path/$corename" 95 | fi 96 | done 97 | 98 | if [ "$biospath" = "" ]; then 99 | biospath="/media/fat/games/$corename" 100 | echo "" 101 | echo "No existing $corename folder found!" 102 | echo "A $corename folder will be created at $biospath" 103 | mkdir -p "$biospath" 104 | fi 105 | 106 | echo "" 107 | 108 | biosurl="https://archive.org/download/segasaturnbios/Sega%20Saturn%20BIOS.zip" 109 | bioshash="a8cd8951d07cd9ecdc175e9f0462cfb8" 110 | biosfile="/media/fat/Scripts/saturnbios.zip" 111 | biospack="/media/fat/Scripts/.saturn-bios" 112 | 113 | if [ ! -d "$biospack" ]; then 114 | mkdir -p "$biospack" 115 | echo "Downloading Saturn bios pack..." 116 | download "$biosfile" "$biosurl" 117 | [ -n "$bioshash" ] && checksum "$biosfile" "$bioshash" 118 | unpack "$biosfile" "$biospack" 119 | rm "$biosfile" 120 | cd "$biospack" 121 | for i in *.bin; do 122 | sum=$(sha1sum "$i" | cut -f 1 -d ' ') 123 | mv "$i" "$sum" 124 | done 125 | fi 126 | echo "Installing $corename bios into $biospath..." 127 | if [ -f "$biospath/boot.bin" ]; then 128 | rm "$biospath/boot.bin" 129 | fi 130 | cp "$biospack/${bios}" "$biospath/boot.rom" 131 | echo "Finished installing Saturn bios ${biosversion} ${region} version in $biospath" 132 | 133 | echo "" 134 | -------------------------------------------------------------------------------- /saturn-jp-hitachi-bios-installer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | version=1.4 3 | 4 | # === 5 | bios="8c031bf9908fd0142fdd10a9cdd79389f8a3f2fc" 6 | region="Japan Hitachi" 7 | biosversion="1.03" 8 | name="jp-hitachi" 9 | # === 10 | 11 | biospath="" 12 | 13 | corename="Saturn" 14 | 15 | self="$(readlink -f "$0")" 16 | 17 | conf="${self%.*}.ini" 18 | [ -f "$conf" ] && . "$conf" 19 | 20 | trap "result" 0 1 3 15 21 | 22 | result(){ 23 | case "$?" in 24 | # 0) echo -e "last version: Github says, last commit on $gitversion" 25 | # echo -e "core version: ${corefile##*/}\n";; 26 | 99) echo "self: updated self";; 27 | 100) echo "error: cannot reach url";; 28 | 101) echo "error: cannot write to sdcard";; 29 | 102) echo "error: download failed";; 30 | 103) echo "error: checksum failed";; 31 | 104) echo "error: json parsing failed";; 32 | 105) echo "error: unzip failed";; 33 | esac 34 | } 35 | 36 | makedir(){ [ -d "$1" ] || { mkdir -p "$1" || exit 101;};} 37 | download(){ wget --no-cache -q "$2" -O "$1" || { rm "$1";exit 102;};} 38 | urlcat(){ wget --no-cache -q "$1" -O - || exit 100;} 39 | checksum(){ md5sum "$1"|grep -q "$2" || { rm "$1";exit 103;};} 40 | unpack(){ unzip -j -o "$1" -d "$2" >/dev/null 2>&1 || exit 105;} 41 | 42 | selfurl="https://raw.githubusercontent.com/SwedishGojira/MiSTer-scripts/main/saturn-${name}-bios-installer.sh" 43 | selfurl_version="$(urlcat "$selfurl"|sed -n 's,^version=,,;2p')" 44 | 45 | [ "$selfurl_version" = "$version" ] || { 46 | tempfile="$(mktemp -u)"; download "$tempfile" "$selfurl" 47 | mv "$tempfile" "$self";chmod +x "$self";exec "$self"; exit 99 48 | } 49 | 50 | echo "" 51 | echo -e "█▀▀ █▀▀█ ▀▀█▀▀ █\e[34m░░\e[39m█ █▀▀█ █▀▀▄ █▀▀▄ ▀█▀ █▀▀█ █▀▀ " 52 | echo -e "▀▀█ █▄▄█ \e[34m░░\e[39m█\e[34m░░\e[39m █\e[34m░░\e[39m█ █▄▄▀ █\e[34m░░\e[39m█ █▀▀▄ \e[34m░\e[39m█\e[34m░\e[39m █\e[34m░░\e[39m█ ▀▀█ " 53 | echo -e "▀▀▀ ▀\e[34m░░\e[39m▀ \e[34m░░\e[39m▀\e[34m░░\e[39m \e[34m░\e[39m▀▀▀ ▀\e[34m░\e[39m▀▀ ▀\e[34m░░\e[39m▀ ▀▀▀\e[34m░\e[39m ▀▀▀ ▀▀▀▀ ▀▀▀ " 54 | echo "" 55 | echo -e "█▀▀▄ █▀▀█ █\e[34m░░░\e[39m█ █▀▀▄ █\e[34m░░\e[39m █▀▀█ █▀▀█ █▀▀▄ █▀▀ █▀▀█ " 56 | echo -e "█\e[34m░░\e[39m█ █\e[34m░░\e[39m█ █▄█▄█ █\e[34m░░\e[39m█ █\e[34m░░\e[39m █\e[34m░░\e[39m█ █▄▄█ █\e[34m░░\e[39m█ █▀▀ █▄▄▀ \e[1m\e[34mversion $version\e[0m" 57 | echo -e "▀▀▀\e[34m░\e[39m ▀▀▀▀ \e[34m░\e[39m▀\e[34m░\e[39m▀\e[34m░\e[39m ▀\e[34m░░\e[39m▀ ▀▀▀ ▀▀▀▀ ▀\e[34m░░\e[39m▀ ▀▀▀\e[34m░\e[39m ▀▀▀ ▀\e[34m░\e[39m▀▀ \e[34m░░░░░░░ ░░░\e[39m" 58 | echo "" 59 | 60 | 61 | # Path Priority (https://mister-devel.github.io/MkDocs_MiSTer/cores/paths/#path-priority) 62 | # There is a priority order of core paths. When you plug in a USB drive and it has a folder /games/Saturn on it (mounted locally as /media/usb<0..5>/games/Saturn when plugged in), 63 | # then the MiSTer Saturn core will look to that folder on the USB drive instead of the local one on the MicroSD at /media/fat/games/Saturn. 64 | # Here is the priority list from Main_MiSTer's file_io.cpp in order of highest priority to lowest: 65 | 66 | echo "Detecting $corename file path for bios installation..." 67 | 68 | declare -a paths=("/media/fat" 69 | "/media/fat/games" 70 | "/media/usb0" 71 | "/media/usb1" 72 | "/media/usb2" 73 | "/media/usb3" 74 | "/media/usb4" 75 | "/media/usb5" 76 | "/media/usb0/games" 77 | "/media/usb1/games" 78 | "/media/usb2/games" 79 | "/media/usb3/games" 80 | "/media/usb4/games" 81 | "/media/usb5/games" 82 | "/media/fat/cifs" 83 | "/media/fat/cifs/games" 84 | ) 85 | 86 | # You can access them using echo "${paths[0]}", "${paths[1]}" also 87 | 88 | ## now loop through the above array 89 | for path in "${paths[@]}"; do 90 | if [ -d "$path/$corename" ]; then 91 | echo "[X] $path/$corename" 92 | biospath="$path/$corename" 93 | else 94 | echo "[ ] $path/$corename" 95 | fi 96 | done 97 | 98 | if [ "$biospath" = "" ]; then 99 | biospath="/media/fat/games/$corename" 100 | echo "" 101 | echo "No existing $corename folder found!" 102 | echo "A $corename folder will be created at $biospath" 103 | mkdir -p "$biospath" 104 | fi 105 | 106 | echo "" 107 | 108 | biosurl="https://archive.org/download/segasaturnbios/Sega%20Saturn%20BIOS.zip" 109 | bioshash="a8cd8951d07cd9ecdc175e9f0462cfb8" 110 | biosfile="/media/fat/Scripts/saturnbios.zip" 111 | biospack="/media/fat/Scripts/.saturn-bios" 112 | 113 | if [ ! -d "$biospack" ]; then 114 | mkdir -p "$biospack" 115 | echo "Downloading Saturn bios pack..." 116 | download "$biosfile" "$biosurl" 117 | [ -n "$bioshash" ] && checksum "$biosfile" "$bioshash" 118 | unpack "$biosfile" "$biospack" 119 | rm "$biosfile" 120 | cd "$biospack" 121 | for i in *.bin; do 122 | sum=$(sha1sum "$i" | cut -f 1 -d ' ') 123 | mv "$i" "$sum" 124 | done 125 | fi 126 | echo "Installing $corename bios into $biospath..." 127 | if [ -f "$biospath/boot.bin" ]; then 128 | rm "$biospath/boot.bin" 129 | fi 130 | cp "$biospack/${bios}" "$biospath/boot.rom" 131 | echo "Finished installing Saturn bios ${biosversion} ${region} version in $biospath" 132 | 133 | echo "" 134 | -------------------------------------------------------------------------------- /saturn-updater-workflow-builds.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | version=2.1 3 | # 4 | # Saturn Updater based on workflow builds (c) 2022 by SwedishGojira GPLv2 5 | # 6 | # Based on MiSTer-unstable-nightlies Updater (c) 2021 by Akuma GPLv2 7 | # Also uses nightly.link (c) 2020 Oleh Prypin (https://nightly.link/) 8 | # 9 | 10 | corename="Saturn" 11 | 12 | backupformat="Single" 13 | 14 | if [ ! "$DS" = "" ]; then 15 | backupformat="Dual" 16 | fi 17 | 18 | self="$(readlink -f "$0")" 19 | 20 | conf="${self%.*}.ini" 21 | [ -f "$conf" ] && . "$conf" 22 | 23 | trap "result" 0 1 3 15 24 | 25 | result(){ 26 | case "$?" in 27 | 0) echo -e "Last version: Github says, last commit on $gitversion" 28 | echo -e "Core version: ${corefile##*/}\n";; 29 | 99) echo "self: updated self";; 30 | 100) echo "error: cannot reach url";; 31 | 101) echo "error: cannot write to sdcard";; 32 | 102) echo "error: download failed";; 33 | 105) echo "error: unzip failed";; 34 | esac 35 | } 36 | 37 | makedir(){ [ -d "$1" ] || { mkdir -p "$1" || exit 101;};} 38 | download(){ wget --no-cache --read-timeout=10.0 --tries=2 -q "$2" -O "$1" || { rm "$1";exit 102;};} 39 | urlcat(){ wget --no-cache --read-timeout=10.0 --tries=2 -q "$1" -O - || exit 100;} 40 | unpack(){ unzip -j -o "$1" -d "$2" >/dev/null 2>&1 || exit 105;} 41 | 42 | commiturl="https://github.com/srg320/Saturn_MiSTer/commits/master" 43 | commitdate="$(urlcat "$commiturl"|grep "Commits on"|head -1|sed 's,^.*Commits on ,,;s,<.*$,,')" 44 | commitnumdate="$(date -d"$commitdate" +%Y%m%d)" 45 | gitversion="$commitdate" 46 | 47 | selfurl="https://raw.githubusercontent.com/SwedishGojira/MiSTer-scripts/main/saturn-updater-workflow-builds.sh" 48 | selfurl_version="$(urlcat "$selfurl"|sed -n 's,^version=,,;2p')" 49 | 50 | 51 | if [ ! "$selfurl_version" = "$version" ]; then 52 | tempfile="$(mktemp -u)" 53 | download "$tempfile" "$selfurl" 54 | mv "$tempfile" "$self" 55 | chmod +x "$self" 56 | exec "$self" 57 | exit 99 58 | fi 59 | 60 | echo -e "\e[0m█▀ ▄▀█ ▀█▀ █\e[34m░\e[39m█ █▀█ █▄\e[34m░\e[39m█   █▀▀ █▀█ █▀█ █▀▀" 61 | echo -e "▄█ █▀█ \e[34m░\e[39m█\e[34m░\e[39m █▄█ █▀▄ █\e[34m░\e[39m▀█   █▄▄ █▄█ █▀▄ ██▄" 62 | echo "" 63 | echo -e "\e[39m█\e[34m░\e[39m█ █▀█ █▀▄ ▄▀█ ▀█▀ █▀▀ █▀█ \e[1m\e[34mversion. $version\e[0m" 64 | echo -e "█▄█ █▀▀ █▄▀ █▀█ \e[34m░\e[39m█\e[34m░\e[39m ██▄ █▀▄ \e[34m░░░░░░░░ ░░░\e[0m" 65 | echo "" 66 | 67 | storagedir="/media/fat" 68 | coredir="$storagedir/_Unstable";makedir "$coredir" 69 | core="${corename}${DS}_${commitnumdate}.rbf" 70 | tempdir="$storagedir/scripts/.saturn-updater-temp" 71 | corefile="$coredir/$core" 72 | corezip="$coredir/core.zip" 73 | nightlyurl="$(curl -sL --insecure https://nightly.link/srg320/Saturn_MiSTer/blob/master/.github/workflows/test-build$DS.yml | grep -Eo '[>]https://.*[.zip]' | head -1 | cut -c2- | grep .zip)" 74 | if [ "$nightlyurl" = "" ]; then 75 | nightlyurl="$(wget -q -O- https://api.github.com/repos/MiSTer-unstable-nightlies/Saturn_MiSTer/releases | grep "browser_download_url" | grep ".rbf" | grep "$backupformat" | grep "$commitnumdate" | head -n 1 | cut -d \" -f4)" 76 | corezip="$corefile" 77 | fi 78 | if [ "$nightlyurl" = "" ]; then 79 | exit 100 80 | fi 81 | 82 | if [ -f "$corefile" ]; then 83 | echo "Core already up to date." 84 | else 85 | echo "Downloading latest core (${backupformat} RAM)..." 86 | download "$corezip" "$nightlyurl" 87 | if [ -f "$coredir/core.zip" ]; then 88 | mkdir "$tempdir" 89 | unpack "$corezip" "$tempdir/" 90 | rm "$corezip" 91 | find "$tempdir" -iname "*.fit_*.txt" -delete 92 | mv "$tempdir/Saturn_"*.rbf "$corefile" 93 | rm -rf "$tempdir" 94 | fi 95 | fi 96 | 97 | if [ -f "$coredir/${corename}${DS}_latest.rbf" ]; then 98 | rm "$coredir/${corename}${DS}_latest.rbf" 99 | fi 100 | 101 | ln -sf "$corefile" "$coredir/ ${corename}${DS}_latest.rbf" 102 | 103 | [ -n "$maxkeep" -a -n "$coredir" -a -n "$corename" ] \ 104 | && { ls -t "${coredir}/${corename}${DS}_"*".rbf"|awk "NR>$maxkeep"|xargs -r rm;} 105 | 106 | 107 | DS="" 108 | 109 | exit 0 110 | 111 | 112 | -------------------------------------------------------------------------------- /saturn-us-bios-installer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | version=1.4 3 | 4 | # === 5 | bios="faa8ea183a6d7bbe5d4e03bb1332519800d3fbc3" 6 | region="USA" 7 | biosversion="1.01a" 8 | name=us 9 | # === 10 | 11 | biospath="" 12 | 13 | corename="Saturn" 14 | 15 | self="$(readlink -f "$0")" 16 | 17 | conf="${self%.*}.ini" 18 | [ -f "$conf" ] && . "$conf" 19 | 20 | trap "result" 0 1 3 15 21 | 22 | result(){ 23 | case "$?" in 24 | # 0) echo -e "last version: Github says, last commit on $gitversion" 25 | # echo -e "core version: ${corefile##*/}\n";; 26 | 99) echo "self: updated self";; 27 | 100) echo "error: cannot reach url";; 28 | 101) echo "error: cannot write to sdcard";; 29 | 102) echo "error: download failed";; 30 | 103) echo "error: checksum failed";; 31 | 104) echo "error: json parsing failed";; 32 | 105) echo "error: unzip failed";; 33 | esac 34 | } 35 | 36 | makedir(){ [ -d "$1" ] || { mkdir -p "$1" || exit 101;};} 37 | download(){ wget --no-cache -q "$2" -O "$1" || { rm "$1";exit 102;};} 38 | urlcat(){ wget --no-cache -q "$1" -O - || exit 100;} 39 | checksum(){ md5sum "$1"|grep -q "$2" || { rm "$1";exit 103;};} 40 | unpack(){ unzip -j -o "$1" -d "$2" >/dev/null 2>&1 || exit 105;} 41 | 42 | selfurl="https://raw.githubusercontent.com/SwedishGojira/MiSTer-scripts/main/saturn-${name}-bios-installer.sh" 43 | selfurl_version="$(urlcat "$selfurl"|sed -n 's,^version=,,;2p')" 44 | 45 | [ "$selfurl_version" = "$version" ] || { 46 | tempfile="$(mktemp -u)"; download "$tempfile" "$selfurl" 47 | mv "$tempfile" "$self";chmod +x "$self";exec "$self"; exit 99 48 | } 49 | 50 | echo "" 51 | echo -e "█▀▀ █▀▀█ ▀▀█▀▀ █\e[34m░░\e[39m█ █▀▀█ █▀▀▄ █▀▀▄ ▀█▀ █▀▀█ █▀▀ " 52 | echo -e "▀▀█ █▄▄█ \e[34m░░\e[39m█\e[34m░░\e[39m █\e[34m░░\e[39m█ █▄▄▀ █\e[34m░░\e[39m█ █▀▀▄ \e[34m░\e[39m█\e[34m░\e[39m █\e[34m░░\e[39m█ ▀▀█ " 53 | echo -e "▀▀▀ ▀\e[34m░░\e[39m▀ \e[34m░░\e[39m▀\e[34m░░\e[39m \e[34m░\e[39m▀▀▀ ▀\e[34m░\e[39m▀▀ ▀\e[34m░░\e[39m▀ ▀▀▀\e[34m░\e[39m ▀▀▀ ▀▀▀▀ ▀▀▀ " 54 | echo "" 55 | echo -e "█▀▀▄ █▀▀█ █\e[34m░░░\e[39m█ █▀▀▄ █\e[34m░░\e[39m █▀▀█ █▀▀█ █▀▀▄ █▀▀ █▀▀█" 56 | echo -e "█\e[34m░░\e[39m█ █\e[34m░░\e[39m█ █▄█▄█ █\e[34m░░\e[39m█ █\e[34m░░\e[39m █\e[34m░░\e[39m█ █▄▄█ █\e[34m░░\e[39m█ █▀▀ █▄▄▀ \e[1m\e[34mversion $version\e[0m" 57 | echo -e "▀▀▀\e[34m░\e[39m ▀▀▀▀ \e[34m░\e[39m▀\e[34m░\e[39m▀\e[34m░\e[39m ▀\e[34m░░\e[39m▀ ▀▀▀ ▀▀▀▀ ▀\e[34m░░\e[39m▀ ▀▀▀\e[34m░\e[39m ▀▀▀ ▀\e[34m░\e[39m▀▀ \e[34m░░░░░░░ ░░░\e[39m" 58 | echo "" 59 | 60 | 61 | # Path Priority (https://mister-devel.github.io/MkDocs_MiSTer/cores/paths/#path-priority) 62 | # There is a priority order of core paths. When you plug in a USB drive and it has a folder /games/Saturn on it (mounted locally as /media/usb<0..5>/games/Saturn when plugged in), 63 | # then the MiSTer Saturn core will look to that folder on the USB drive instead of the local one on the MicroSD at /media/fat/games/Saturn. 64 | # Here is the priority list from Main_MiSTer's file_io.cpp in order of highest priority to lowest: 65 | 66 | echo "Detecting $corename file path for bios installation..." 67 | 68 | declare -a paths=("/media/fat" 69 | "/media/fat/games" 70 | "/media/usb0" 71 | "/media/usb1" 72 | "/media/usb2" 73 | "/media/usb3" 74 | "/media/usb4" 75 | "/media/usb5" 76 | "/media/usb0/games" 77 | "/media/usb1/games" 78 | "/media/usb2/games" 79 | "/media/usb3/games" 80 | "/media/usb4/games" 81 | "/media/usb5/games" 82 | "/media/fat/cifs" 83 | "/media/fat/cifs/games" 84 | ) 85 | 86 | # You can access them using echo "${paths[0]}", "${paths[1]}" also 87 | 88 | ## now loop through the above array 89 | for path in "${paths[@]}"; do 90 | if [ -d "$path/$corename" ]; then 91 | echo "[X] $path/$corename" 92 | biospath="$path/$corename" 93 | else 94 | echo "[ ] $path/$corename" 95 | fi 96 | done 97 | 98 | if [ "$biospath" = "" ]; then 99 | biospath="/media/fat/games/$corename" 100 | echo "" 101 | echo "No existing $corename folder found!" 102 | echo "A $corename folder will be created at $biospath" 103 | mkdir -p "$biospath" 104 | fi 105 | 106 | echo "" 107 | 108 | biosurl="https://archive.org/download/segasaturnbios/Sega%20Saturn%20BIOS.zip" 109 | bioshash="a8cd8951d07cd9ecdc175e9f0462cfb8" 110 | biosfile="/media/fat/Scripts/saturnbios.zip" 111 | biospack="/media/fat/Scripts/.saturn-bios" 112 | 113 | if [ ! -d "$biospack" ]; then 114 | mkdir -p "$biospack" 115 | echo "Downloading Saturn bios pack..." 116 | download "$biosfile" "$biosurl" 117 | [ -n "$bioshash" ] && checksum "$biosfile" "$bioshash" 118 | unpack "$biosfile" "$biospack" 119 | rm "$biosfile" 120 | cd "$biospack" 121 | for i in *.bin; do 122 | sum=$(sha1sum "$i" | cut -f 1 -d ' ') 123 | mv "$i" "$sum" 124 | done 125 | fi 126 | echo "Installing $corename bios into $biospath..." 127 | if [ -f "$biospath/boot.bin" ]; then 128 | rm "$biospath/boot.bin" 129 | fi 130 | cp "$biospack/${bios}" "$biospath/boot.rom" 131 | echo "Finished installing Saturn bios ${biosversion} ${region} version in $biospath" 132 | 133 | echo "" 134 | -------------------------------------------------------------------------------- /saturn_ds-updater-workflow-builds.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 4 | 5 | DS="_ds" 6 | source "$SCRIPT_DIR/saturn-updater-workflow-builds.sh" 7 | --------------------------------------------------------------------------------