News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Zelda 2 spell editing  (Read 906 times)

Revility

  • Jr. Member
  • **
  • Posts: 19
    • View Profile
    • The Revility
Zelda 2 spell editing
« on: February 01, 2018, 03:43:42 pm »
I have been tinkering with combining spells in Zelda 2 by mixing together the values starting at 0x000DCB.  What I was hoping to accomplish was combining reflect with shield spell and removing reflect magic by bumping up when you receive spell spell and Thunder in the towns.  In return the last ghost town would contain the final heart instead of spell. I had no issues bumping up when you learn spells or having a shield/reflect combo spell.

The problems I encountered when trying to edit the values for reflect, spell spell and thunder (20, 40, 80).  There is some math going on here when it comes to changing those.  In other words you can't just change the values from one to the other, glitches start to pop up.  Like wise if you go into spell routines and swap them around, glitches will also pop up.  It appears there is some math going on here that I am not of to achieve the desired results.  If I change reflect's 20 to 60 (20+40)spell spell works fine in it's place.  If I change spell spell's 40 into c0(40+80) Thunder will work in it's place... just a little wonky and thunder is also able to open the hidden door in New Kasuto.

Does anyone know how I could go about altering the last 3 spells?

Psyklax

  • Hero Member
  • *****
  • Posts: 953
    • View Profile
    • Psyklax Translations
Re: Zelda 2 spell editing
« Reply #1 on: February 02, 2018, 12:40:14 pm »
Well, if you're editing $DCB, that's RAM, so it's not exactly a long term solution given that the game can change it at will. You'll need to find the routine in the code that gives you a new spell and change the amounts that you get. Of course, I haven't tested it like you have, so I don't know if it's as simple as that. Also, $DCB is mirrored RAM: the actual RAM is from $0000 to $07FF. So this address should be $5CB.

http://wiki.nesdev.com/w/index.php/CPU_memory_map

I could help further if I knew more about what you wanted to do. :)

Revility

  • Jr. Member
  • **
  • Posts: 19
    • View Profile
    • The Revility
Re: Zelda 2 spell editing
« Reply #2 on: February 02, 2018, 04:00:38 pm »
What I’m tinkering with is combining the effects of shield spell & reflect or having reflect always on once aquired, like an item.  After that would be to remove reflect from the menu & bump the last 2 spells up in the list.

Psyklax

  • Hero Member
  • *****
  • Posts: 953
    • View Profile
    • Psyklax Translations
Re: Zelda 2 spell editing
« Reply #3 on: February 02, 2018, 05:33:50 pm »
I'm looking now: it's just occurred to me that when you said $DCB, you meant in the ROM, not RAM. :) They're really quite simple values, I must say: just each bit on in eight bytes (01, 02, 04 etc). The weird thing is that I can't see what they do. When I set a breakpoint for any of them being read by the game when I acquire or use a spell, I get nothing. So I've no idea what the significance of them is. It's possible that it's not necessarily connected with spells but are a general use set of values for different purposes, given how they're just in sequence like that.

As for what you'd like to do - make reflect always on, for example - I'd have to play through the game to the point where I actually get reflect, and I don't have time to play through Zelda 2 again just for that. :D In theory, though, activating reflect (or shield or jump or whatever) should set something in RAM that says the spell is on, then the game zeroes that value when you leave the room. To make reflect be always on, you could change the routine to save to a different address in RAM, then when the game checks to see if you have reflect (when you get hit) you can redirect it to that value, where it will see that it's on and go "okay then". That way the general spell activating value never gets affected.

Since you acquire shield at the beginning, I'll try and locate the RAM value that indicates a particular spell is activated.

EDIT: Ah, I got the address wrong in my breakpoint. :) 01 seems to equal shield. $76F is where your spell status is stored in RAM, so when you cast a spell, it gets the required bit and puts it there. Clearly the reason they used bits is so you could have eight spells at once. If I change 01 to 04, the game doesn't like it and replaces it with zero so you get nothing, but when I replace it with 10, it has no issue and gives you the fire spell. I tried 20 but I have no way of testing it this early in the game. The best thing for keeping reflect as an item would be to find where in RAM your spells are kept, rather than the ones currently active, and when it's reflect, it does as I mentioned before: puts it somewhere else and redirects status checks to there.
« Last Edit: February 02, 2018, 05:58:10 pm by Psyklax »

Revility

  • Jr. Member
  • **
  • Posts: 19
    • View Profile
    • The Revility
Re: Zelda 2 spell editing
« Reply #4 on: February 02, 2018, 06:04:40 pm »
There should be a save editor floating around, forgot where I found the one I use so you don't have to play through the whole game.

to earliest place I can think of testing reflect is the cave connecting north and south east hyrule where there is a fire spitting monster in there.  Using a game genie hack to cross mountains makes it a quick walk.
If you change shield's 01 to 21, or 41 etc.  you'll get a combo spell going... like shield with reflect or shield with fire balls.  It's when I start messing around with the last 3 spells is where it gets a bit wonky.  I wonder if there is something for each spell to refer to which byte it uses in it's routine.