shithub: zelda3

Download patch

ref: 97cf3feef012827c71158627fa1fd9413f036c80
parent: 88306be549a308dc29e28d78ac29606c234406e5
author: Snesrev <snesrev@protonmail.com>
date: Sun Sep 18 14:58:37 EDT 2022

Add 'BreakPotsWithSword'

--- a/config.c
+++ b/config.c
@@ -278,6 +278,9 @@
     } else if (StringEqualsNoCase(key, "CollectItemsWithSword")) {
       g_config.collect_items_with_sword = (bool)strtol(value, (char **)NULL, 10);
       return true;
+    } else if (StringEqualsNoCase(key, "BreakPotsWithSword")) {
+      g_config.break_pots_with_sword = (bool)strtol(value, (char **)NULL, 10);
+      return true;
     }
   }
   return false;
--- a/config.h
+++ b/config.h
@@ -50,6 +50,7 @@
   bool turn_while_dashing;
   bool mirror_to_darkworld;
   bool collect_items_with_sword;
+  bool break_pots_with_sword;
 } Config;
 
 extern Config g_config;
--- a/dungeon.c
+++ b/dungeon.c
@@ -5551,17 +5551,22 @@
 }
 
 uint8 HandleItemTileAction_Dungeon(uint16 x, uint16 y) {  // 81dabb
-  if (!(link_item_in_hand & 2))
-    return 0;
+  if (!(link_item_in_hand & 2)) {
+    if (!(enhanced_features0 & kFeatures0_BreakPotsWithSword) ||
+        button_b_frames == 0 || link_sword_type == 1)
+      return 0;
+  }
   uint16 pos = (y & 0x1f8) * 8 + x + (link_is_on_lower_level ? 0x1000 : 0);
   uint16 tile = dung_bg2_attr_table[pos];
   if ((tile & 0xf0) == 0x70) {
     uint16 tile2 = dung_replacement_tile_state[tile & 0xf];
-    if ((tile2 & 0xf0f0) == 0x4040) {
+    if ((tile2 & 0xf0f0) == 0x4040) {  // Hammer peg
+      if (!(link_item_in_hand & 2))
+        return 0;  // only hammers on pegs
       dung_misc_objs_index = (tile & 0xf) * 2;
       RoomDraw_16x16Single(dung_misc_objs_index);
       sound_effect_1 = 0x11;
-    } else if ((tile2 & 0xf0f0) == 0x1010) {
+    } else if ((tile2 & 0xf0f0) == 0x1010) {  // Pot
       dung_misc_objs_index = (tile & 0xf) * 2;
       RevealPotItem(pos, dung_object_tilemap_pos[tile & 0xf]);
       RoomDraw_16x16Single(dung_misc_objs_index);
--- a/main.c
+++ b/main.c
@@ -192,6 +192,7 @@
     f |= g_config.turn_while_dashing * kFeatures0_TurnWhileDashing;
     f |= g_config.mirror_to_darkworld * kFeatures0_MirrorToDarkworld;
     f |= g_config.collect_items_with_sword * kFeatures0_CollectItemsWithSword;
+    f |= g_config.break_pots_with_sword * kFeatures0_BreakPotsWithSword;
     g_wanted_zelda_features = f;
   }
 
--- a/zelda3.ini
+++ b/zelda3.ini
@@ -46,6 +46,9 @@
 # Collect items (like hearts) with sword instead of having to touch them
 CollectItemsWithSword = 0
 
+# Level 2-4 sword can be used to break pots
+BreakPotsWithSword = 0
+
 
 [KeyMap]
 # Change what keyboard keys map to the joypad
--- a/zelda_rtl.h
+++ b/zelda_rtl.h
@@ -119,6 +119,8 @@
   kFeatures0_TurnWhileDashing = 4,
   kFeatures0_MirrorToDarkworld = 8,
   kFeatures0_CollectItemsWithSword = 16,
+  kFeatures0_BreakPotsWithSword = 32,
+
 };
 
 #define enhanced_features0 (*(uint32*)(g_ram+0x64c))