shithub: zelda3

Download patch

ref: 3a2f900b3116bf958d436b4d1c3685c7719411f3
parent: 70df79a4f0f19243b48d403502d5e3c7034d4a75
author: Snesrev <snesrev@protonmail.com>
date: Tue Oct 18 21:50:37 EDT 2022

Fix medallion cast on the same frame as other things (#126)

Bug report:
A medallion cast can be interrupted and drain magic if you
(1) are walking along a pit ledge
(2) cast one frame after releasing a spin attack
(3) cast on the same frame you start a cliff jump.

--- a/player.c
+++ b/player.c
@@ -241,24 +241,25 @@
 
   if (!Link_HandleToss()) {
     Link_HandleAPress();
-    if ((link_state_bits | link_grabbing_wall) == 0 && link_unk_master_sword == 0 && link_player_handler_state != 17) {
+    if ((link_state_bits | link_grabbing_wall) == 0 && link_unk_master_sword == 0 && link_player_handler_state != kPlayerState_StartDash) {
       Link_HandleYItem();
+      // Ensure we're not handling potions. Things further
+      // down don't assume this and change the module indexes randomly.
+      // This also fixes a bug where bombos, ether, quake get aborted if you use spin attack at the same time.
+      if ((enhanced_features0 & kFeatures0_MiscBugFixes) && (
+          main_module_index == 14 && submodule_index != 2 ||
+          link_player_handler_state == kPlayerState_Bombos ||
+          link_player_handler_state == kPlayerState_Ether ||
+          link_player_handler_state == kPlayerState_Quake))
+        goto getout_clear_vel;
       if (sram_progress_indicator != 0) {
         Link_HandleSwordCooldown();
+        if (link_player_handler_state == 3)
+          goto getout_clear_vel;
       }
     }
   }
 
-  // Ensure we're not handling potions. Things further
-  // down don't assume this and change the module indexes randomly.
-  // Also check for spin attack for some reason.
-  if ((enhanced_features0 & kFeatures0_MiscBugFixes) && main_module_index == 14 && submodule_index != 2 ||
-      link_player_handler_state == 3) {
-    link_x_vel = link_y_vel = 0;
-    goto getout_dostuff;
-  }
-
-
   Link_HandleCape_passive_LiftCheck();
   if (link_incapacitated_timer) {
     link_moving_against_diag_tile = 0;
@@ -321,10 +322,10 @@
   Link_HandleVelocity();
   Link_HandleCardinalCollision();
   Link_HandleMovingAnimation_FullLongEntry();
-  if (link_unk_master_sword)
+  if (link_unk_master_sword) getout_clear_vel: {
     link_y_vel = link_x_vel = 0;
+  }
 
-getout_dostuff:
   fallhole_var1 = 0;
 
   // HandleIndoorCameraAndDoors must not be called twice in the same frame,