foxygit / fake-08-xbox360 Log in
commit ac22fa297595108f091799377fd9ffc1ea9fd9b1
Author:     Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Sun Jul 23 19:24:25 2023 -0600
Commit:     Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Sun Jul 23 19:24:25 2023 -0600

    Revert "Implement channel -2 to stop sfx on all channels"

    This reverts commit 9b818369aa4ce4475097722c05a9936c71ed66a7.
---
 source/Audio.cpp    | 17 ++++-------------
 test/audiotests.cpp | 13 -------------
 2 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/source/Audio.cpp b/source/Audio.cpp
index f838388..314cc26 100644
--- a/source/Audio.cpp
+++ b/source/Audio.cpp
@@ -46,7 +46,7 @@ audioState_t* Audio::getAudioState() {

 void Audio::api_sfx(int sfx, int channel, int offset){

-    if (sfx < -2 || sfx > 63 || channel < -2 || channel > 3 || offset > 31) {
+    if (sfx < -2 || sfx > 63 || channel < -1 || channel > 3 || offset > 31) {
         return;
     }

@@ -66,28 +66,19 @@ void Audio::api_sfx(int sfx, int channel, int offset){
     }
     else
     {
-        //CHANNEL -2: to stop the given sound from playing on any channel
-        if (channel == -2) {
-            for(int i = 0; i < 4; i++) {
-                if (_audioState._sfxChannels[i].sfxId == sfx) {
-                    _audioState._sfxChannels[i].sfxId = -1;
-                }
-            }
-
-        }
         // Find the first available channel: either a channel that plays
         // nothing, or a channel that is already playing this sample (in
         // this case PICO-8 decides to forcibly reuse that channel, which
         // is reasonable)
         if (channel == -1)
         {
-            for (int i = 0; i < 4; ++i) {
+            for (int i = 0; i < 4; ++i)
                 if (_audioState._sfxChannels[i].sfxId == -1 ||
-                    _audioState._sfxChannels[i].sfxId == sfx) {
+                    _audioState._sfxChannels[i].sfxId == sfx)
+                {
                     channel = i;
                     break;
                 }
-            }
         }

         // If still no channel found, the PICO-8 strategy seems to be to
diff --git a/test/audiotests.cpp b/test/audiotests.cpp
index 1decba9..4e01946 100644
--- a/test/audiotests.cpp
+++ b/test/audiotests.cpp
@@ -188,19 +188,6 @@ TEST_CASE("audio class behaves as expected") {

         CHECK_EQ(audioState->_sfxChannels[2].sfxId, 5);
     }
-    SUBCASE("api_sfx() with -2 channel stops the sfx on any channel") {
-        audio->api_sfx(1, 0, 0);
-        audio->api_sfx(10, 1, 0);
-        audio->api_sfx(20, 2, 0);
-        audio->api_sfx(1, 3, 0);
-        audio->api_sfx(1, -2, 0);
-
-
-        CHECK_EQ(audioState->_sfxChannels[0].sfxId, -1);
-        CHECK_EQ(audioState->_sfxChannels[1].sfxId, 10);
-        CHECK_EQ(audioState->_sfxChannels[2].sfxId, 20);
-        CHECK_EQ(audioState->_sfxChannels[3].sfxId, -1);
-    }
     SUBCASE("api_sfx() -2 sfx id stops looping") {
         audioState->_sfxChannels[3].can_loop = true;