{"id":399,"date":"2012-07-15T17:12:00","date_gmt":"2012-07-15T22:12:00","guid":{"rendered":"http:\/\/snarfblam.com\/words\/?p=399"},"modified":"2012-07-15T17:12:00","modified_gmt":"2012-07-15T22:12:00","slug":"zelda-hacking-editing-caves","status":"publish","type":"post","link":"http:\/\/snarfblam.com\/words\/?p=399","title":{"rendered":"Zelda Hacking: Editing Caves"},"content":{"rendered":"<h1>Warp Caves<\/h1>\n<p>In The Legend of Zelda, there are four &#8220;warp caves&#8221; that connect to each other, allowing the player to quickly traverse the overworld. If you try to move these warp caves with Zelda Tech, you&#8217;ll discover that either the player will still be warped to one of the original warp cave locations, or, more likely, the game will freeze.<!--more--><\/p>\n<p>To fix this, open the ROM in a hex editor and go to the offset $19344. There will be four &#8220;screen IDs&#8221; listed there. These are the locations the warp caves will bring you to. The values specify a map location, where the first digit is the Y coordinate and the second digit is the X coordinate (0, 0 being the top-left corner of the map). For example, $49 would be the fifth screen down, tenth to the right.<\/p>\n<p>If a warp cave is not in the list and you try to warp through it, the game will freeze.<\/p>\n<h1>Cave Contents<\/h1>\n<p>Zelda Tech allows editing which items appear in each of the four shops, but it is actually pretty easy to more extensively modify what&#8217;s inside any cave type. There are four relevant data tables in the ROM, each of which has 20 entries, one for each cave type.<\/p>\n<p>In typical Zelda fashion, each data table has extra information crammed in the unused bits. There are some bits whose purpose hasn&#8217;t been completely deciphered. Even though every bit contains data, some bits may not actually be used (this could be determined with a debugger). It may be that these bits were originally used, but they ended up hardcoding behavior for certain cave types.<\/p>\n<pre>$045b2 - String ID    (1 byte per cave)\r\n$1861C - Item list    (3 bytes per cave)\r\n$18658 - Item prices  (3 bytes per cave)\r\n$06E7F - Cave dweller (1 byte per cave)<\/pre>\n<h2>String ID<\/h2>\n<p>The string ID table contains one byte for each cave type. The bits of each byte have the following meaning (high bit first).<\/p>\n<pre>MGSS SSSS<\/pre>\n<p><strong>M<\/strong> ($80) is a mystery. It is set for shops, potion shops, and pay-for-info caves. <strong>G<\/strong> ($40) appears to specify whether the player can get items. If G is set, the player can get items in the cave, even if they aren&#8217;t shown. SSSSSS ($3F) is an even number between 0 and 62 that specifies which string is shown in the cave. &#8216;0&#8217; shows the text &#8220;IT&#8217;S DANGEROUS TO GO ALONE! TAKE THIS!&#8221;, &#8216;2&#8217; shows &#8220;MASTER USING IT AND YOU CAN HAVE THIS&#8221;, and so on.<\/p>\n<h2>Item List<\/h2>\n<p>The item list contains three bytes per screen, whose bits have the following meaning (high bit first).<\/p>\n<pre>byte 1:  NMaa aaaa\r\nbyte 2:  HTbb bbbb\r\nbyte 2:  PIcc cccc<\/pre>\n<p><strong>aaaaaa<\/strong>, <strong>bbbbbb<\/strong>, and <strong>cccccc<\/strong> specify the items in the cave and have a value from 0 to 63 (0 = bombs, 1 = sword, etc.). For certain cave types such as secret-money caves, a rupee is shown, but this is for display only. Any item can be placed in these caves and the player will still receive rupees when he touches the item.<\/p>\n<p><strong>N<\/strong> ($80) specifies that prices, if shown, will be negative, such as in\u00a0pay-for-info caves. <strong>M<\/strong> ($40) is set for the white sword and the magic sword. When M is set, the player must have enough heart containers to get the item. The number of hearts needed appears to be 12 for all cave types except cave type 2 (white sword), which requires five hearts.<\/p>\n<p><strong>H<\/strong> ($80) is set for the gambling game and secret money. Clearing it in the secret-money caves causes the player to get and hold up the item instead of receiving free rupees. <strong>T<\/strong> ($40) is set for\u00a0pay-for-info caves.<\/p>\n<p><strong>P<\/strong> ($80) specifies whether prices are shown, and <strong>I<\/strong> ($40) specifies whether items are shown.<\/p>\n<h2>Item Prices<\/h2>\n<p>This one is easy. There are three bytes per screen, each specifying the price for the item.<\/p>\n<h2>Cave Dweller<\/h2>\n<p>This one is also pretty easy. One byte for each screen that identifies which sprite to show for the person that inhabits the cave. $58 is for the old man, $59 the old woman, $5A the merchant, and $5B the moblin.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warp Caves In The Legend of Zelda, there are four &#8220;warp caves&#8221; that connect to each other, allowing the player to quickly traverse the overworld. If you try to move these warp caves with Zelda Tech, you&#8217;ll discover that either the player will still be warped to one of the original warp cave locations, or, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,32],"tags":[10,12,9,33,34],"class_list":["post-399","post","type-post","status-publish","format-standard","hentry","category-romhacking","category-zelda-tech","tag-hacking","tag-nes","tag-rom","tag-zelda","tag-zelda-tech-2"],"_links":{"self":[{"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=\/wp\/v2\/posts\/399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=399"}],"version-history":[{"count":5,"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=\/wp\/v2\/posts\/399\/revisions"}],"predecessor-version":[{"id":405,"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=\/wp\/v2\/posts\/399\/revisions\/405"}],"wp:attachment":[{"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=399"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/snarfblam.com\/words\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}