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

Author Topic: zelda 2 ASM hacking and improvements  (Read 12181 times)

ultimaweapon

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: zelda 2 restart from current palace after game over
« Reply #40 on: March 07, 2018, 09:08:16 am »
Oh, and by the way, sorry for the super old Mac OS X editor. I've been working on and off on a better version, and I should have made at least a minor update since then. Shame on me. I think I made a thread in this forum quite some time ago about all the new features of my editor, which I now call Sword II.

If you want to change the magic requirements for spells, the table is at ROM offset 0D7B. Also, the spell effects bits are in the table immediately after, at 0DBB.

0D7B: Table for Magic Needed for Spells (40 bytes)
      
40 30 30 20 20 20 20 20      Shield
60 50 40 40 28 20 18 10      Jump
8C 8C 78 78 64 64 64 64      Life
A0 A0 78 78 50 50 50 50      Fairy
F0 A0 78 3C 20 20 20 20      Fire
F0 F0 A0 60 50 40 30 20      Reflect
F0 E0 C0 A0 60 40 30 20      Spell
F0 F0 F0 F0 F0 F0 C8 80      Thunder

----

0DBB: 01 02 04 08 10 20 40 80   Table for Spell effects bits (8 bytes)

Each row in the first table represents a spell, whereas each column represents a magic level, from 1 to 8. Keep in mind that a single square of magic in the meter is worth 32 (20 in hex) units. So the first byte in the table means the Shield spell when you are at Magic level 1 costs 64 units (40 in hex), or 2 squares.  And for some reason, you have to divide the values in the table by 2 to get the correct cost displayed in the Pause pane.

The spell effects bits mean that you can combine spells in any combination you want. Bit 0 is for Shield, bit 1 for Jump, and so on. If you take the first byte and set bits 0 and 1, which gives you the value 03, the Shield spell will also cast Jump at the same time. A value of FF would cast all the 8 spells simultaneously, but I think some spells may cancel others out. Experiment.

I've been trying to figure out how to combine (Reflect and Shield) and (Life and Shield) magic, but I'm still new to hex editing, and I can't figure this out.
Trust in the Heart of the Cards

ShadowOne333

  • Hero Member
  • *****
  • Posts: 921
    • View Profile
Re: zelda 2 restart from current palace after game over
« Reply #41 on: March 07, 2018, 01:33:13 pm »
I've been trying to figure out how to combine (Reflect and Shield) and (Life and Shield) magic, but I'm still new to hex editing, and I can't figure this out.

Try the following.
At location 0x000DBB (PC Address), you will find the table for spell effects.
Modify what you get there for this:

0DBB: 01 02 04 08 10 20 40 80

to this

0DBB: 01 02 05 08 10 21 40 80

By modifying the 04 for 05 and the 20 for 21, you should get the desired effects (Reflect & Shield and Life & Shield).
Once you modify those two bytes in Hex, load up the ROM and try the spells out in-game.

ultimaweapon

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: zelda 2 restart from current palace after game over
« Reply #42 on: March 07, 2018, 02:45:48 pm »
Try the following.
At location 0x000DBB (PC Address), you will find the table for spell effects.
Modify what you get there for this:

0DBB: 01 02 04 08 10 20 40 80

to this

0DBB: 01 02 05 08 10 21 40 80

By modifying the 04 for 05 and the 20 for 21, you should get the desired effects (Reflect & Shield and Life & Shield).
Once you modify those two bytes in Hex, load up the ROM and try the spells out in-game.

So my thinking was right, and I had the right numbers. I may have been in the wrong location in the hex editor. I'll use a fresh copy of my hack and try that. I think I was a 0DBB0. Thanks ShadowOne, and I'll try it once I get home.
Trust in the Heart of the Cards

ShadowOne333

  • Hero Member
  • *****
  • Posts: 921
    • View Profile
Re: zelda 2 restart from current palace after game over
« Reply #43 on: March 07, 2018, 04:11:39 pm »
So my thinking was right, and I had the right numbers. I may have been in the wrong location in the hex editor. I'll use a fresh copy of my hack and try that. I think I was a 0DBB0. Thanks ShadowOne, and I'll try it once I get home.
Welcome!
Hope it helps.

Also, guys, thanks to the wonderful help by @njosro, I managed to get a proper manual save working on Zelda II :)
Now whenever I press Up+A, the game saves without adding the manual save as a death in the death counter in the selection screen.

Here's the code (which njosro did for the most part :P I simply made the proper branches and jumps and implemented it all in Hex to the ROM).

Code: [Select]
JSR      LD3A0                         ; 0x1caac $CA9C 20 A0 D3                ; Jump to subroutine (label D3A0)
CMP      #$FF                          ; 0x1caaf $CA9F C9 FF                   ; Compare with 255
BEQ      LCAA6                         ; 0x1cab1 $CAA1 F0 03                   ; Branch if A=255
INC      $079F                         ; 0x1cab3 $CAA3 EE 9F 07                ; Number of Continues + 1

; LD3A0:
LDA      $0700                         ; 0x1d3b0 $D3A0 AD 00 07                ; Load Lives Counter from RAM
BEQ      LD3A8                         ; 0x1d3b3 $D3A3 F0 03                   ; If A=0 (Lives=0), branch to original code
LDA      #$FF                          ; 0x1d3b5 $D3A5 A9 FF                   ; Set A to 255
RTS                                    ; 0x1d3b7 $D3A7 60                      ; Return from Subroutine
; LD3A8:
LDA      $079F                        ; 0x1d3b8 $D3A8 AD 9F 07                ; Number of Continues used
RTS                                    ; 0x1d3bb $D3AB 60                      ; Return from Subroutine

I will be posting an IPS patch later today, so stay tuned :P


--------------------------------------------------------------------------------------------------------------------


Here it is!
https://www.dropbox.com/s/9nvida92kyh5svj/Zelda2Redux.ips?dl=0

So that patch should include:
  • Changes to the Life Meter HUD: Should have hearts now instead of the old bars it had for a life meter
  • Manual Save Feature: You can now save the game by Pausing and then pressing Up+A on the Pause screen (both in side-scroll pause and overworld pause!)
  • Manual saves no longer count towards the Death counter in the Selection screen! Now only Game Overs should increment that counter
  • Implemented @njosro's Restart in Current Palace patch (as a bonus) :P

Next up I think will be lowering the amount of magic required for each spell.
I think about reducing each magic amount required for each spell by half to all of them (for all levels of magic), though I am not sure yet.
I will see how I tackle this.
« Last Edit: March 07, 2018, 05:07:31 pm by ShadowOne333 »

Trax

  • Sr. Member
  • ****
  • Posts: 432
    • View Profile
    • Trax ROM Hacking
Re: zelda 2 restart from current palace after game over
« Reply #44 on: March 07, 2018, 08:10:55 pm »
I have the answer for the apparent inconsistency when some spells are moved around. There are two kinds of spells. Instant and persistent. Shield, Jump, Fairy, Fire, and Reflect are persistent spells. They stay activated until you leave the area. Life, Spell and Thunder are instant spells. Their effect is applied once, during one frame.

The consequences are that when an instant spell is cast, the effect bit of the spell must be set to zero after applying the effect, to avoid that the effect continues being executed every frame. If you don't do that, Life gives you infinite life, and Spell and Thunder are cast continously. Here's what the Life spell routine does at the very beginning:

0E5D: AD 6F07   LDA $076F   ; Magic State
0E60: 29 FB   AND #$FB   ; keep bits xxxx x.xx


You have to load the Magic State variable, 76F, and AND it with the reverse of the bit of the spell in question, i.e. a byte with all bits set, except the bit of the spell. Same for Spell and Thunder. That's why when you try to move these spells around by only changing the bytes in the table at 0DBB in not enough.

ultimaweapon

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: zelda 2 restart from current palace after game over
« Reply #45 on: March 08, 2018, 10:21:23 am »
@ShadowOne - That worked. I was clearly in the wrong location. As Trax noted, some spells don't play well together. Thunder and Life was an interesting combination. LOL!

Now if someone can figure out how to make JUMP spell do a jump in midair instead of just jump higher, that would be awesome!  ;D
Trust in the Heart of the Cards

ShadowOne333

  • Hero Member
  • *****
  • Posts: 921
    • View Profile
Re: zelda 2 restart from current palace after game over
« Reply #46 on: March 08, 2018, 12:45:33 pm »
@ShadowOne - That worked. I was clearly in the wrong location. As Trax noted, some spells don't play well together. Thunder and Life was an interesting combination. LOL!

Now if someone can figure out how to make JUMP spell do a jump in midair instead of just jump higher, that would be awesome!  ;D

Oh good thing you found the right one. :)

Now as a general question to everyone.
What suggestions do you guys have in terms of difficulty or balancing to Life/Magic and enemies?
For example, right now I have these ideas in mind which I'd like to implement into Zelda II:

  • Reduce the amount of magic consumption to half for all levels
  • Remove the ability enemies have to steal experience from you. This one bothers me quite a bit in recent playthroughs.
  • Increment experience values each enemy gives to around double the amount (when possible). If not double, perhaps a small amount above to what they usually give.
  • Edit experience message when destroying enemies to reflect the new experience they give (taken from above point).

One thing I am still not sure of, is if I will attempt modifying Enemy health and/or how much damage Link does to enemies. I don't want to make the game TOO easy, just balanced enough so that people can have a much better experience playing Zelda II overall.

I don't think I will touch how much damage Link inflicts on enemies, but I might modify the health of some enemies, not all. Do you guys have any enemies in mind which have way too much health?
The only one I'm thinking right now is that bubble that appears in the very first Palace which takes a million hits to kill. I might change that one.

So, any suggestions?

ultimaweapon

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: zelda 2 restart from current palace after game over
« Reply #47 on: March 08, 2018, 01:47:15 pm »
Oh good thing you found the right one. :)

Now as a general question to everyone.
What suggestions do you guys have in terms of difficulty or balancing to Life/Magic and enemies?
For example, right now I have these ideas in mind which I'd like to implement into Zelda II:

  • Reduce the amount of magic consumption to half for all levels
  • Remove the ability enemies have to steal experience from you. This one bothers me quite a bit in recent playthroughs.
  • Increment experience values each enemy gives to around double the amount (when possible). If not double, perhaps a small amount above to what they usually give.
  • Edit experience message when destroying enemies to reflect the new experience they give (taken from above point).

One thing I am still not sure of, is if I will attempt modifying Enemy health and/or how much damage Link does to enemies. I don't want to make the game TOO easy, just balanced enough so that people can have a much better experience playing Zelda II overall.

I don't think I will touch how much damage Link inflicts on enemies, but I might modify the health of some enemies, not all. Do you guys have any enemies in mind which have way too much health?
The only one I'm thinking right now is that bubble that appears in the very first Palace which takes a million hits to kill. I might change that one.

So, any suggestions?

I can tell you what  I'm working on in my hack that I thought were good changes overall for Zelda II:

1. Increased HP of most enemies not all.
2. Increased damage Link can deliver with his sword on all levels except the 1st to balance things out.
3. Decreased magic cost for all magic including Thunder for levels 5 and higher. Thunder only cost 32 as opposed to 64.
4. Increased experience points for most enemies and bosses. Hammerhead gives 200 instead of 50 and Barba gives 1000 instead of 700.
5. Casting LIFE spell now fills half of your  life meter or 4 bars as opposed to 3.
6. Eliminated enemies stealing experience points since they already have more HP
7. Enemies drop Experience Bag or Magic Jar every 5 enemy kills instead of 6.

So those are the changes I have done. I should be releasing my hack this weekend after a few more tests. Are those changes you would consider good?
Trust in the Heart of the Cards

ShadowOne333

  • Hero Member
  • *****
  • Posts: 921
    • View Profile
Re: zelda 2 restart from current palace after game over
« Reply #48 on: March 08, 2018, 02:47:06 pm »
I can tell you what  I'm working on in my hack that I thought were good changes overall for Zelda II:

1. Increased HP of most enemies not all.
2. Increased damage Link can deliver with his sword on all levels except the 1st to balance things out.
3. Decreased magic cost for all magic including Thunder for levels 5 and higher. Thunder only cost 32 as opposed to 64.
4. Increased experience points for most enemies and bosses. Hammerhead gives 200 instead of 50 and Barba gives 1000 instead of 700.
5. Casting LIFE spell now fills half of your  life meter or 4 bars as opposed to 3.
6. Eliminated enemies stealing experience points since they already have more HP
7. Enemies drop Experience Bag or Magic Jar every 5 enemy kills instead of 6.

So those are the changes I have done. I should be releasing my hack this weekend after a few more tests. Are those changes you would consider good?
I would be interested in points #4, #6 and #7.
The others not so much sadly :P I feel like the enemies and damage dealt are pretty much okay with how one progresses through the game.
I might end up reducing the magic costs by 1/4 or so, not half as it might seem a bit too much.
How did you end up removing the steal experience thing? I do have an idea on how to do so, but I'm interested in how you tackled it.

Also, on #4, what enemies did you change experience for and to what?

ultimaweapon

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: zelda 2 restart from current palace after game over
« Reply #49 on: March 08, 2018, 03:35:42 pm »
@ShadowOne

The weaker enemies' HP vary between 20-50. The stronger enemies vary between 50-200. Some enemies also vary by region as well. For example, and Octorok may have 18 HP in Western Hyrule and Death Mountain, but in East Hyrule and Maze Island, they would have 24 and the experience would be 20 vs 30 for respective regions. Dairas' give 100 & 150 experience for Orange and Red. I made similar changes in the palaces as well. Ironknuckles give 70, 100, and 200 for Blue sword throwing ones. No boss gives less than 200 experience. Helmethead gives 200 plus 150 for each head. Carock gives 500. Gooma gives 700, and Barba 1000. Experience bags have no less than 100 with most being either 200 or 500. I wish there was a way to make some 1000.

My experience scale is higher thus the need to give out more experience. I added balance by increasing HP and also increasing Link's attack strength. At Level 8, no enemy except The Great Palace and Bosses take more than 2 hits with a lot of them only requiring 1 hit. I wanted to change the enemies in the Great Palace, but the game goes haywire every time I try to change anything enemy related.

As far as my magic scale, Thunder, Fairy, and Life cost 32 points or 2 bars. All other magic less with Shield, Fire, Jump, and Reflect 8 and Spell 16. I haven't checked the Reflect/Shield combo, but if that works correctly, Then I will make Reflect 16 or 1 bar. BTW, these values are for Magic at Level 8. In a standard game, Thunder is 64, Life is 50, Fairy is 40, Reflect, Shield, Spell, and Fire 16, and Jump is 8 at Magic Level 8.

I also made LIFE spell refill 4 health bars instead of 3. 

As far as the Enemy HP, Attack Strength, Magic Point, Enemy Experience,I used Trax's tool for it since I'm still learning hex editing.

I'll probably need a beta tester before I release my hack, so when I'm ready, you can beta test it for me, and you can see my changes.

Trust in the Heart of the Cards

wolpak

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: zelda 2 restart from current palace after game over
« Reply #50 on: March 08, 2018, 03:37:36 pm »
I love the idea that a link doll gives you a permanent +1 life instead of one for that game.  Is that feasible at all?

PowerPanda

  • Jr. Member
  • **
  • Posts: 17
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #51 on: March 09, 2018, 11:38:41 am »
Tog's current easy patch has a really good balance. You guys should check it out.
https://www.romhacking.net/hacks/1084/

Trax

  • Sr. Member
  • ****
  • Posts: 432
    • View Profile
    • Trax ROM Hacking
Re: zelda 2 ASM hacking and improvements
« Reply #52 on: March 11, 2018, 04:31:50 pm »
Personally, I don't really understand the desire to increase the experience gained from enemies. Obviously, I'm biased by the fact that I don't find the game that hard anymore, and this is because I played it so much. On a normal playthrough, without taking any detours or doing any grinding, getting to level 8 in the three stats happens somewhere around palace 6, from 3-3-3 (give or take) after palace 1, to 8-8-8 after palace 6. This is, in my opinion, quite a natural progression of the character's strength throughout the game. Adding more experience here and there would only result in the average player reaching level 8 faster. And you have to admit that Level 8 is quite overpowered. With Attack at level 8, most enemies are killed in 1 or 2 hits.

Wolpak. Welcome to RHDN forums, by the way. Getting a permanent +1 life would be relatively simple. Find a spot in Cartridge RAM to save the max lives counter. This is not hard, there is plenty of unused space in Cartridge RAM. Keep 3 bytes to account for the 3 save slots. When you get a doll, increase that number by 1. When lives are initialized, use this value instead of the arbitrary 3 in the game's engine.

Ultima. You can also change the probabilities of what item you get when the counter reaches 6 (or whatever value you change it to). You could tweak that as well. Here's the tables:

Code: [Select]
1E870: Table for Probability for Item given by killed enemy (10 bytes)

90 90 8A 90 90 90 90 90 Minor Item
91 8C 91 8C 8C 91 8C 91 Major Item

8A = 50 Exp. Bag
8C = 200 Exp. Bag
90 = Blue Jar
91 = Red Jar

These values mean that for an enemy that gives a minor item, you have 1/8 (12.5%) chance of getting a 50 Exp Bag, and 7/8 (87.5%) chance of getting a Blue Jar. For major items, you have 4/8 (50%) chance of getting a 200 Exp Bag and 4/8 (50%) chance of getting a Red Jar.

ultimaweapon

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #53 on: March 11, 2018, 07:19:29 pm »
@Trax - With the standard progression scale, by the time I finish the 4th palace, I'm usually Level 8 for everything. Just like you, the game has become relatively easy for me to. And I agree my Level 8 is a bit overpowered, but I'm treating it as a reward of sorts. With the scale I have, it requires 9000 experience to go from Level 7 to Level 8. I'll share with you through email my scale. But my goal was to make it harder to level up, but also more rewarding to level up. Actually if I remember correctly, I did email you and unfinished version of my hack on here, so you can see progression table.
Good thing is I left The Great Palace untouched, so most enemies there still take a lot of hits. I wanted to change the HP there to make them stronger, but every time I do, the enemies can't be killed (becoming intangible) or I have to turn on infinite magic and go crazy using Thunder Magic. Thunderbird took 150 uses of Thunder magic to kill it, and the game still never progressed to Dark Link. If there was a way to overcome that and make the enemies in The Great Palace more HP, I would do so.

Thanks for the info on the enemy drops. I would definitely want it to be more balanced for minor enemies as it is for major enemies.

March 11, 2018, 07:25:32 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
@Trax - Would it work if I change the minor enemies to also give a major drop (200 exp bag or red jar) or must they stick with the minor drops?
« Last Edit: March 11, 2018, 07:25:32 pm by ultimaweapon »
Trust in the Heart of the Cards

Jeville

  • Sr. Member
  • ****
  • Posts: 335
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #54 on: March 11, 2018, 08:05:21 pm »
Personally, I don't really understand the desire to increase the experience gained from enemies. Obviously, I'm biased by the fact that I don't find the game that hard anymore, and this is because I played it so much. On a normal playthrough, without taking any detours or doing any grinding, getting to level 8 in the three stats happens somewhere around palace 6, from 3-3-3 (give or take) after palace 1, to 8-8-8 after palace 6.
That's assuming the average player knows and understands how to utilize the cancel option in a level up menu in order to achieve that comfortably, which they don't. If placing a crystal gives a specific amount of experience points after giving enough for the next level up, there'd be less need to understand. It'd also help if earned experience points can be saved data and not losing them all after a game over, then make more or all enemies steal points to keep it engaging.
« Last Edit: March 12, 2018, 10:52:26 am by Jeville »

ultimaweapon

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #55 on: March 12, 2018, 02:55:29 am »
Is this link really true about adding another overworld? https://github.com/cfrantz/z2doc/wiki/add-an-extra-overworld
Trust in the Heart of the Cards

ShadowOne333

  • Hero Member
  • *****
  • Posts: 921
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #56 on: March 12, 2018, 05:48:55 pm »
Okay I added a few more stuff to the hack I am making, here is the patch:
https://www.dropbox.com/s/9nvida92kyh5svj/Zelda2Redux.ips?dl=0

Here's the changelog of the hack compared to vanilla Zelda II so far:

  • Changes to the Life Meter HUD: Should have hearts now instead of the old bars it had for a life meter
  • Manual Save Feature: You can now save the game by Pausing and then pressing Up+A on the Pause screen (both in side-scroll pause and overworld pause!)
  • Manual saves no longer count towards the Death counter in the Selection screen! Now only Game Overs should increment that counter
  • Implemented @njosro's Restart in Current Palace patch (as a bonus) :P
  • Enemies no longer steal experience from you.
  • Reduced the amount of HP the Bubble (and Giant Bubble) enemies have. Should now go down with like 5 Sword swings instead of a damn million (having FF in their lives was really something stupid for such a meaningless enemy).
  • Reduced the amount of magic consumption by half for all levels

If anyone can give a full run of the game and let me know how the changes feel, please let me know.
I won't be able to test it out until this weekend thoroughly.

Trax

  • Sr. Member
  • ****
  • Posts: 432
    • View Profile
    • Trax ROM Hacking
Re: zelda 2 ASM hacking and improvements
« Reply #57 on: March 12, 2018, 08:14:50 pm »
Ultima. You can set any enemy to one of 3 options for item drop. The data is in the second attributes table, at 54F9 in Bank 1, and corresponding offsets in other banks. In my docs, I call the tables "Enemy Vulnerability/Damage Codes", it's an old name and left it that way. I could call the tables "Attributes 1", "Attributes 2", etc. Bits 6-7 set the item drop type. Here's the complete structure:

Code: [Select]
54F9: Enemy Vulnerability/Damage Codes (24 bytes)

xx.. .... Item Type (0 = gives no items, 1 = minor item, 2 = major item)
..x. .... Immune to Flying Blade and Fire
...x .... ?
.... xxxx Damage Code

Value 3 could be used for a special item. This table also contains a flag (bit 4) that I couldn't identify, and some enemies have it set. Fairy, Red Jar, Locked Door, Enemies 8 and 9, Generators, Elevator and Geldarm. I don't know what these enemies have in common.

As for the extra Overworld, it is absolutely possible. Kudos to that cfrantz guy in GitHub for the thorough explanations of his method. I'm working on something similar for my next Zelda II hack, except I may not limit myself to adding a World 3. I'm not yet decided on whether I will double the map size or quadruple it. The hard part is the Taken Items bits, which are currently stored into RAM at 6xx. The guy mentions this problem at the end of his docs. Since there is no more space in RAM for so many bytes, the only solution is to swap it to Cartridge RAM, where there is ample unused space.

More to come on that...

ultimaweapon

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #58 on: March 16, 2018, 02:04:04 pm »
Once I get my hack fixed and release it, I may experiment with creating an additional overworld.


After replaying Icepenguin's "Shadow Of Night" hack, it also has given me a few more ideas for Zelda 2.
Trust in the Heart of the Cards

itemdrop

  • Jr. Member
  • **
  • Posts: 38
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #59 on: March 19, 2018, 01:33:42 pm »
I wonder if it would be possible to assign a specific enemy to drop a key kind of the way a boss fight does but for a specific enemy that isnt a boss. working more like a drop does with red jars and pbags. obviously you wouldnt want all big drop enemies to have the ability to drop a key. players would just grind keys lol but maybe have a later enemy a one off enemy have this attribute or have a palace were you use a specific enemy only in that palalce and he is assigned to always drop a key. could make for an interesting puzzle or at least an interesting dynamic.