foxygit / fake-08-xbox360 Log in
commit 5792b5aa47c7397e1db3b562a187ded8ca54c54d
Author:     jtothebell <j.to.the.bell@gmail.com>
AuthorDate: Wed Apr 14 19:38:00 2021 -0600
Commit:     jtothebell <j.to.the.bell@gmail.com>
CommitDate: Wed Apr 14 19:38:00 2021 -0600

    default sfx speed to 16 when parsing a cart
---
 source/cart.cpp    | 5 +++++
 test/carttests.cpp | 6 +++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/source/cart.cpp b/source/cart.cpp
index ef8efcc..89715f8 100644
--- a/source/cart.cpp
+++ b/source/cart.cpp
@@ -473,6 +473,11 @@ void Cart::setSfx(std::string sfxString) {
     std::string line;
     char buf[3] = {0};
     int sfxIdx = 0;
+
+    //SFX speed defaults to 16. Everything else should be zeroed out
+    for (int i = 0; i < 64; i++) {
+        CartRom.SfxData[i].speed = 16;
+    }

     while (std::getline(s, line)) {
         buf[0] = line[0];
diff --git a/test/carttests.cpp b/test/carttests.cpp
index c879531..e9579e3 100644
--- a/test/carttests.cpp
+++ b/test/carttests.cpp
@@ -108,7 +108,11 @@ TEST_CASE("Load simple p8 cart") {
         CHECK(cart->CartRom.SfxData[2].data[11] == 218);
         CHECK(cart->CartRom.SfxData[2].data[12] == 165);
         CHECK(cart->CartRom.SfxData[2].data[13] == 236);
-
+    }
+    SUBCASE("Sfx not set by string defaults correctly") {
+        //speed doesn't default to 0
+        CHECK(cart->CartRom.SfxData[63].speed == 16);
+        CHECK(cart->CartRom.SfxData[63].data[65] == 16);
     }
     SUBCASE("Music song data is populated") {
         CHECK(cart->CartRom.SongData[0].sfx0 == 1);