From b51aaf0879b932bfe32c9e3bd1d27148f2f83363 Mon Sep 17 00:00:00 2001
From: Leon Styhre <leon@leonstyhre.com>
Date: Mon, 6 Mar 2023 17:47:40 +0100
Subject: [PATCH] Added Stella standalone as an alternative emulator for the
 atari2600 system.

---
 es-app/assets/Windows_Portable_README.txt            |  1 +
 resources/systems/macos/es_find_rules.xml            |  8 ++++++++
 resources/systems/macos/es_systems.xml               |  1 +
 resources/systems/unix/es_find_rules.xml             | 11 +++++++++++
 resources/systems/unix/es_systems.xml                |  1 +
 resources/systems/windows/es_find_rules.xml          | 11 +++++++++++
 resources/systems/windows/es_find_rules_portable.xml |  8 ++++++++
 resources/systems/windows/es_systems.xml             |  1 +
 8 files changed, 42 insertions(+)

diff --git a/es-app/assets/Windows_Portable_README.txt b/es-app/assets/Windows_Portable_README.txt
index 77ce029ac..2b8335929 100644
--- a/es-app/assets/Windows_Portable_README.txt
+++ b/es-app/assets/Windows_Portable_README.txt
@@ -87,6 +87,7 @@ Emulators\simple64\simple64-gui.exe
 Emulators\snes9x\snes9x-x64.exe
 Emulators\solarus\solarus-run.exe
 Emulators\SSF\SSF.exe
+Emulators\Stella\64-bit\Stella.exe
 Emulators\Supermodel\Supermodel.exe
 Emulators\Triforce\DolphinWX.exe
 Emulators\tsugaru\Tsugaru_CUI.exe
diff --git a/resources/systems/macos/es_find_rules.xml b/resources/systems/macos/es_find_rules.xml
index d9d20d7a5..2b1aa3375 100644
--- a/resources/systems/macos/es_find_rules.xml
+++ b/resources/systems/macos/es_find_rules.xml
@@ -300,6 +300,14 @@
             <entry>/Applications/Steam.app/Contents/MacOS/steam_osx</entry>
         </rule>
     </emulator>
+    <emulator name="STELLA">
+        <!-- Atari 2600 emulator Stella -->
+        <rule type="staticpath">
+            <entry>/Applications/Stella.app/Contents/MacOS/Stella</entry>
+            <entry>/opt/homebrew/bin/Stella</entry>
+            <entry>/usr/local/bin/Stella</entry>
+        </rule>
+    </emulator>
     <emulator name="VBA-M">
         <!-- Nintendo Game Boy Advance emulator VBA-M -->
         <rule type="staticpath">
diff --git a/resources/systems/macos/es_systems.xml b/resources/systems/macos/es_systems.xml
index 607c0363c..d14075be7 100644
--- a/resources/systems/macos/es_systems.xml
+++ b/resources/systems/macos/es_systems.xml
@@ -150,6 +150,7 @@
         <extension>.a26 .A26 .bin .BIN .7z .7Z .zip .ZIP</extension>
         <command label="Stella">%EMULATOR_RETROARCH% -L %CORE_RETROARCH%/stella_libretro.dylib %ROM%</command>
         <command label="Stella 2014">%EMULATOR_RETROARCH% -L %CORE_RETROARCH%/stella2014_libretro.dylib %ROM%</command>
+        <command label="Stella (Standalone)">%EMULATOR_STELLA% %ROM%</command>
         <command label="ares (Standalone)">%EMULATOR_ARES% --fullscreen --system "Atari 2600" %ROM%</command>
         <platform>atari2600</platform>
         <theme>atari2600</theme>
diff --git a/resources/systems/unix/es_find_rules.xml b/resources/systems/unix/es_find_rules.xml
index 9289d9f98..aa822ca29 100644
--- a/resources/systems/unix/es_find_rules.xml
+++ b/resources/systems/unix/es_find_rules.xml
@@ -658,6 +658,17 @@
             <entry>steam</entry>
         </rule>
     </emulator>
+    <emulator name="STELLA">
+        <!-- Atari 2600 emulator Stella -->
+        <rule type="systempath">
+            <entry>stella</entry>
+            <entry>io.github.stella_emu.Stella</entry>
+        </rule>
+        <rule type="staticpath">
+            <entry>/var/lib/flatpak/exports/bin/io.github.stella_emu.Stella</entry>
+            <entry>~/.local/share/flatpak/exports/bin/io.github.stella_emu.Stella</entry>
+        </rule>
+    </emulator>
     <emulator name="SUPERMODEL">
         <!-- Sega Model 3 emulator Supermodel -->
         <rule type="systempath">
diff --git a/resources/systems/unix/es_systems.xml b/resources/systems/unix/es_systems.xml
index f75a01fff..2bba368f2 100644
--- a/resources/systems/unix/es_systems.xml
+++ b/resources/systems/unix/es_systems.xml
@@ -155,6 +155,7 @@
         <extension>.a26 .A26 .bin .BIN .7z .7Z .zip .ZIP</extension>
         <command label="Stella">%EMULATOR_RETROARCH% -L %CORE_RETROARCH%/stella_libretro.so %ROM%</command>
         <command label="Stella 2014">%EMULATOR_RETROARCH% -L %CORE_RETROARCH%/stella2014_libretro.so %ROM%</command>
+        <command label="Stella (Standalone)">%EMULATOR_STELLA% %ROM%</command>
         <command label="ares (Standalone)">%EMULATOR_ARES% --fullscreen --system "Atari 2600" %ROM%</command>
         <platform>atari2600</platform>
         <theme>atari2600</theme>
diff --git a/resources/systems/windows/es_find_rules.xml b/resources/systems/windows/es_find_rules.xml
index 94d841e0a..36e37e066 100644
--- a/resources/systems/windows/es_find_rules.xml
+++ b/resources/systems/windows/es_find_rules.xml
@@ -720,6 +720,17 @@
             <entry>D:\Program Files (x86)\Steam\steam.exe</entry>
         </rule>
     </emulator>
+    <emulator name="STELLA">
+        <!-- Atari 2600 emulator Stella -->
+        <rule type="systempath">
+            <entry>Stella.exe</entry>
+        </rule>
+        <rule type="staticpath">
+            <entry>%ESPATH%\Emulators\Stella\64-bit\Stella.exe</entry>
+            <entry>%ESPATH%\Stella\64-bit\Stella.exe</entry>
+            <entry>%ESPATH%\..\Stella\64-bit\Stella.exe</entry>
+        </rule>
+    </emulator>
     <emulator name="SUPERMODEL">
         <!-- Sega Model 3 emulator Supermodel -->
         <rule type="systempath">
diff --git a/resources/systems/windows/es_find_rules_portable.xml b/resources/systems/windows/es_find_rules_portable.xml
index a2a462d47..6a39dd35d 100644
--- a/resources/systems/windows/es_find_rules_portable.xml
+++ b/resources/systems/windows/es_find_rules_portable.xml
@@ -496,6 +496,14 @@
             <entry>D:\Program Files (x86)\Steam\steam.exe</entry>
         </rule>
     </emulator>
+    <emulator name="STELLA">
+        <!-- Atari 2600 emulator Stella -->
+        <rule type="staticpath">
+            <entry>%ESPATH%\Emulators\Stella\64-bit\Stella.exe</entry>
+            <entry>%ESPATH%\Stella\64-bit\Stella.exe</entry>
+            <entry>%ESPATH%\..\Stella\64-bit\Stella.exe</entry>
+        </rule>
+    </emulator>
     <emulator name="SUPERMODEL">
         <!-- Sega Model 3 emulator Supermodel -->
         <rule type="staticpath">
diff --git a/resources/systems/windows/es_systems.xml b/resources/systems/windows/es_systems.xml
index 4ecc9b5f8..a709aa6cf 100644
--- a/resources/systems/windows/es_systems.xml
+++ b/resources/systems/windows/es_systems.xml
@@ -157,6 +157,7 @@
         <extension>.a26 .A26 .bin .BIN .7z .7Z .zip .ZIP</extension>
         <command label="Stella">%EMULATOR_RETROARCH% -L %CORE_RETROARCH%\stella_libretro.dll %ROM%</command>
         <command label="Stella 2014">%EMULATOR_RETROARCH% -L %CORE_RETROARCH%\stella2014_libretro.dll %ROM%</command>
+        <command label="Stella (Standalone)">%EMULATOR_STELLA% %ROM%</command>
         <command label="ares (Standalone)">%EMULATOR_ARES% --fullscreen --system "Atari 2600" %ROM%</command>
         <platform>atari2600</platform>
         <theme>atari2600</theme>