shithub: zelda3

Download patch

ref: 94e576f035e0fbb5aa8843e22a0d65d3cba7a909
parent: 1b95f8b2b540d45efb57b129840115b2aed6f666
author: Snesrev <[email protected]>
date: Fri Sep 30 11:00:46 EDT 2022

Fix broken Zoras in Shallow Water in Misery Mire (#126)

--- a/config.c
+++ b/config.c
@@ -320,6 +320,8 @@
       return ParseBoolBit(value, &g_config.features0, kFeatures0_CarryMoreRupees);
     } else if (StringEqualsNoCase(key, "MiscBugFixes")) {
       return ParseBoolBit(value, &g_config.features0, kFeatures0_MiscBugFixes);
+    } else if (StringEqualsNoCase(key, "GameChangingBugFixes")) {
+      return ParseBoolBit(value, &g_config.features0, kFeatures0_GameChangingBugFixes);
     } else if (StringEqualsNoCase(key, "CancelBirdTravel")) {
       return ParseBoolBit(value, &g_config.features0, kFeatures0_CancelBirdTravel);
     }
--- a/features.h
+++ b/features.h
@@ -40,6 +40,8 @@
   kFeatures0_MiscBugFixes = 4096,
 
   kFeatures0_CancelBirdTravel = 8192,
+
+  kFeatures0_GameChangingBugFixes = 16384,
 };
 
 #define enhanced_features0 (*(uint32*)(g_ram+0x64c))
--- a/sprite_main.c
+++ b/sprite_main.c
@@ -2959,14 +2959,28 @@
   case 0:  // choose surfacing location
     sprite_ignore_projectile[k] = sprite_delay_main[k];
     if (!sprite_delay_main[k]) {
-      Sprite_SetX(k, (sprite_A[k] | sprite_B[k] << 8) + kSprite_Zora_Surface_XY[GetRandomNumber() & 7]);
-      Sprite_SetY(k, (sprite_C[k] | sprite_head_dir[k] << 8) + kSprite_Zora_Surface_XY[GetRandomNumber() & 7]);
+      int org_x = (sprite_A[k] | sprite_B[k] << 8);
+      int org_y = (sprite_C[k] | sprite_head_dir[k] << 8);
+      Sprite_SetX(k, org_x + kSprite_Zora_Surface_XY[GetRandomNumber() & 7]);
+      Sprite_SetY(k, org_y + kSprite_Zora_Surface_XY[GetRandomNumber() & 7]);
       Sprite_Get16BitCoords(k);
       Sprite_CheckTileCollision(k);
-      if (sprite_tiletype == 8) {
+      if (sprite_tiletype == 8) spawn_anyway: {
         sprite_delay_main[k] = 127;
         sprite_ai_state[k]++;
         sprite_flags3[k] |= 0x40;
+      } else {
+        // In Misery Mire some Zoras are placed in shallow water so they can't spawn
+        // This fixes so they will be able to spawn in shallow water after a delay.
+        if (enhanced_features0 & kFeatures0_GameChangingBugFixes) {
+          if (sprite_tiletype == 9 && sprite_delay_aux2[k] == 1)
+            goto spawn_anyway;
+          Sprite_SetX(k, org_x);
+          Sprite_SetY(k, org_y);
+          sprite_ignore_projectile[k] = 1;
+          if (sprite_delay_aux2[k] == 0)
+            sprite_delay_aux2[k] = 32;
+        }
       }
     }
     break;
--- a/zelda3.ini
+++ b/zelda3.ini
@@ -74,10 +74,13 @@
 CarryMoreRupees = 0
 
 # Enable various zelda bug fixes
-MiscBugFixes = 1
+MiscBugFixes = 0
 
+# Enable some more advanced zelda bugfixes that change game behavior
+GameChangingBugFixes = 0
+
 # Allow bird travel to be cancelled by hitting the X key
-CancelBirdTravel = 1
+CancelBirdTravel = 0
 
 [KeyMap]
 # Change what keyboard keys map to the joypad