shithub: zelda3

Download patch

ref: e4d167c2d736580d67834d02fd5ad737057ddc0e
parent: f0163c162e96c7a480b20712c8de3ef625a0074f
author: Snesrev <snesrev@protonmail.com>
date: Sat Sep 17 17:56:49 EDT 2022

Add config option 'TurnWhileDashing'

--- a/config.c
+++ b/config.c
@@ -267,6 +267,9 @@
     if (StringEqualsNoCase(key, "ItemSwitchLR")) {
       g_config.item_switch_lr = (bool)strtol(value, (char **)NULL, 10);
       return true;
+    } else if (StringEqualsNoCase(key, "TurnWhileDashing")) {
+      g_config.turn_while_dashing = (bool)strtol(value, (char **)NULL, 10);
+      return true;
     }
   }
   return false;
--- a/config.h
+++ b/config.h
@@ -47,6 +47,7 @@
   bool display_perf_title;
   bool enable_msu;
   bool item_switch_lr;
+  bool turn_while_dashing;
 } Config;
 
 extern Config g_config;
--- a/dungeon.c
+++ b/dungeon.c
@@ -6764,7 +6764,7 @@
 
 void Dungeon_ResetTorchBackgroundAndPlayerInner() {  // 828b0c
   Ancilla_TerminateSelectInteractives(0);
-  if (link_is_running) {
+  if (link_is_running && !(enhanced_features0 & kFeatures0_TurnWhileDashing)) {
     link_auxiliary_state = 0;
     link_incapacitated_timer = 0;
     link_actual_vel_z = 0xff;
--- a/main.c
+++ b/main.c
@@ -189,6 +189,7 @@
     uint32 f = 0;
     f |= (g_zenv.ppu->extraLeftRight && !g_config.extended_aspect_ratio_nospr) ? kFeatures0_ExtendScreen64 : 0;
     f |= g_config.item_switch_lr * kFeatures0_SwitchLR;
+    f |= g_config.turn_while_dashing * kFeatures0_TurnWhileDashing;
     g_wanted_zelda_features = f;
   }
 
--- a/overworld.c
+++ b/overworld.c
@@ -518,6 +518,9 @@
   link_need_for_poof_for_transform = 0;
   link_is_bunny = 0;
   link_is_bunny_mirror = 0;
+
+  if (enhanced_features0 & kFeatures0_TurnWhileDashing)
+    link_is_running = 0;
 }
 
 void RecoverPositionAfterDrowning() {  // 829583
--- a/player.c
+++ b/player.c
@@ -1224,7 +1224,27 @@
   }
 
   link_incapacitated_timer = 0;
-  if ((joypad1H_last & 0xf) && (joypad1H_last & 0xf) != kDashTab2[link_direction_facing >> 1]) {
+
+  bool want_stop_dash = false;
+
+  if (enhanced_features0 & kFeatures0_TurnWhileDashing) {
+    if (!(joypad1L_last & 0x80)) {
+      link_countdown_for_dash = 0x11;
+      want_stop_dash = true;
+    } else {
+      static const uint8 kDashCtrlsToDir[16] = { 0, 1, 2, 0, 4, 4, 4, 0, 8, 8, 8, 0, 0, 0, 0, 0 };
+      uint8 t = kDashCtrlsToDir[joypad1H_last & 0xf];
+      if (t != 0 && t != link_direction_last) {
+        link_direction = link_direction_last = t;
+        link_some_direction_bits = t;
+        Link_HandleMovingAnimation_FullLongEntry();
+      }
+    }
+  } else {
+    want_stop_dash = (joypad1H_last & 0xf) && (joypad1H_last & 0xf) != kDashTab2[link_direction_facing >> 1];
+  }
+
+  if (want_stop_dash) {
     link_player_handler_state = kPlayerState_StopDash;
     button_mask_b_y &= ~0x80;
     button_b_frames = 0;
@@ -4122,7 +4142,11 @@
       submodule_index = tiledetect_inroom_staircase & 0x70 ? 16 : 8;
       main_module_index = 7;
       Link_CancelDash();
+    } else if (enhanced_features0 & kFeatures0_TurnWhileDashing) {
+      // avoid weirdness in stairs
+      Link_CancelDash();
     }
+
     if ((link_last_direction_moved_towards & 2) == 0) {
       link_speed_setting = 2;
       link_speed_modifier = 1;
--- a/tagalong.c
+++ b/tagalong.c
@@ -203,6 +203,12 @@
   tagalong_var3 = 0;
   tagalong_var4 = 0;
   link_speed_setting = 0;
+
+  if (enhanced_features0 & kFeatures0_TurnWhileDashing) {
+    link_player_handler_state = kPlayerState_Ground;
+    link_is_running = false;
+  }
+
 }
 
 void Sprite_BecomeFollower(int k) {  // 899f39
--- a/zelda3.ini
+++ b/zelda3.ini
@@ -36,6 +36,8 @@
 # Item switch on L/R. Also allows reordering of items in inventory by pressing Y+direction
 ItemSwitchLR = 1
 
+# Allow turning while dashing
+TurnWhileDashing = 0
 
 [KeyMap]
 # Change what keyboard keys map to the joypad
--- a/zelda_rtl.h
+++ b/zelda_rtl.h
@@ -116,6 +116,7 @@
 enum {
   kFeatures0_ExtendScreen64 = 1,
   kFeatures0_SwitchLR = 2,
+  kFeatures0_TurnWhileDashing = 4,
 };
 
 #define enhanced_features0 (*(uint32*)(g_ram+0x64c))