News: 11 March 2016 - Forum Rules

Author Topic: Legend of Zelda Bombable Armos  (Read 780 times)

gzip

  • RHDN Patreon Supporter!
  • Jr. Member
  • *****
  • Posts: 54
    • View Profile
Legend of Zelda Bombable Armos
« on: July 16, 2021, 11:09:35 pm »
The Legend of Zelda (nes) contains code for a bombable Armos which mostly works. The only problem is that bombing the Armos reveals a cave entrance instead of stairs. After you exit the cave or re-enter the screen there are stairs in the location as expected.

I debugged for a while and located the code which writes the cave tiles. Changing the value at $10F09 (headered) to $70 will change the behavior as desired for the Armos but the problem is that this changes the tiles for bombable walls as well.

I was unable to locate anything in RAM that would allow a bit of logic to determine which tiles should be written: cave or stairs. One possibility is that the logic would be based on the tile code that is being replaced.

Anyone have the hacking chops to dig into this more?

An easy way to test this is to change $15E39 (headered) to $2B and $18611 to $00 which will add the bombable Armos to the starting screen and put some bombs in the starting cave.

Code: [Select]
-015e30  45 c5 4e 4e 4e 0e 45 db 5b 34 4e 4e 1a 1b db 5b
+015e30  45 c5 4e 4e 4e 0e 45 db 5b 2b 4e 4e 1a 1b db 5b
-018610  3f 01 7f 20 3f 5a 7f 02 7f 7f 03 7f 3f 3f 3f 3f
+018610  3f 00 7f 20 3f 5a 7f 02 7f 7f 03 7f 3f 3f 3f 3f

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 708
  • I am the baldest romhacker
    • View Profile
Re: Legend of Zelda Bombable Armos
« Reply #1 on: July 17, 2021, 02:07:49 am »
I have a disassembly, link is in my signature.

gzip

  • RHDN Patreon Supporter!
  • Jr. Member
  • *****
  • Posts: 54
    • View Profile
Re: Legend of Zelda Bombable Armos
« Reply #2 on: July 17, 2021, 06:12:03 pm »
Thanks @Cyneprepou4uk. I've been using Aldo Nunez's disassembly along with some of Trax's notes in a Mesen debug file. It makes debugging much more manageable.

I was able to figure this out after all. Later in the code execution the relevant row and column are available which can be used to determine the corresponding tile (using code borrowed from elsewhere) and branch accordingly. Here's the diff:

Code: [Select]
-013480  ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
-013490  ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
-0134a0  ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+013480  a5 03 29 f8 4a 4a a8 b9 00 e4 85 00 b9 01 e4 85
+013490  01 a5 02 38 e9 40 4a 4a 4a a8 b1 00 c9 c0 d0 04
+0134a0  a9 70 85 05 20 70 75 60 ff ff ff ff ff ff ff ff

-01e880  75 ae 01 03 a5 00 9d 02 03 9d 07 03 a5 01 9d 03
+01e880  b4 ae 01 03 a5 00 9d 02 03 9d 07 03 a5 01 9d 03

This is using Save RAM. Not sure how safe that is.

Trax

  • RHDN Patreon Supporter!
  • Hero Member
  • *****
  • Posts: 604
    • View Profile
    • Trax ROM Hacking
Re: Legend of Zelda Bombable Armos
« Reply #3 on: July 24, 2021, 09:05:32 pm »
If you're referring to Cartridge RAM, then yes, the game does use this space for various stuff, including code that is copied there before being executed. If the data is other than the actual saved game data, then it comes from ROM one way or another.