Jump to content

Trying to help gather info about the Hugh glitch


Recommended Posts

We all know the glitch that makes Hugh really strong for no reason, that was introduced by Feditor back in the day(for reference, it really only occurs in the english version.)

The glitch has the weird status of being a completely unpredictable beast that has completely random effects on Hughs stats, but...it kinda is not. Like, not at all. It always happens in the same way and it always has the same effects. It happens after Hugh gets his stats reduced at least two times. After that, the player can suspend and reload the quicksave to get a halfway okay unit for basically free. 2 statreductions always mess with his attackstat and 3 reductions always mess with the attack and the skill-stat. I will attach a picture that shows the "unused behavior"(because it is impossible to occur without hacks) when his stats are lowered by 4 points(or more), which is just that each of his stats that get lowered, except luck and HP for some reason, get affected!

I have no idea what is actually happening in the game, but I wanted to clear up some misinformation regarding the topic(there were two prior topics about it that literally just said "Hey, it exists. can someone explain?") and want to explain what is happening and when it happens, so that maybe someone who can actually deal with code, unlike me, might be able to look into it. Since nobody knew the scope before appearently and thus it was unclear what to look out for. I appologise if the Information presented by me was already some common Knowledge around here.

(Just for reference, appearently the lowest his stats after the suspend can be is 32, which is 1 more than the maximum value that can be saved, if the individual stat is 0 after the statreduction. Just in case that is somehow relevant to finding out what is going on)

Hughglitch 4 times decrease.png

Link to comment
Share on other sites

1 hour ago, German FE Nino said:

Like, not at all. It always happens in the same way and it always has the same effects. It happens after Hugh gets his stats reduced at least two times. After that, the player can suspend and reload the quicksave to get a halfway okay unit for basically free.

Does it always happen when you reload the quicksave after reducing Hugh's stats twice?

Link to comment
Share on other sites

8 hours ago, AnonymousSpeed said:

Does it always happen when you reload the quicksave after reducing Hugh's stats twice?

It seems that way. I tested it multiple times on multiple english roms and the results were consistant every time. I really strongly assume that it only counts as a rare glitch because people did not know how it triggers and people who got it were too spooked by the stats to make out the patern that they all suspended and reloaded at some point.

Link to comment
Share on other sites

2 hours ago, German FE Nino said:

It seems that way. I tested it multiple times on multiple english roms and the results were consistant every time. I really strongly assume that it only counts as a rare glitch because people did not know how it triggers and people who got it were too spooked by the stats to make out the patern that they all suspended and reloaded at some point.

Excellent news, I will be sure to abuse this glitch for my entertainment. Thanks!

Link to comment
Share on other sites

Thanks for looking into how the glitch occurs! It would be great to get it fixed, but if nobody can help we can consider it to be a “fun” abusable glitch like the enemy control glitch and uber spear in FE7. 😘

Link to comment
Share on other sites

  • 3 weeks later...

Appearently,according to additional research and a conversation with someone who can actually hack unlike me, the reason the glitch happens is because the ASM responsible for calling the statreductions for some reason subtracts from his classbases instead of his final unitstats(or even his characterbases if the former is not possible codingwise). The moment the value for a classstat becomes negative, it adds the 32 I mentioned to the stat because the game handles negative values that way. 

No idea how that relates to the japanese version, but according to that person, that version somehow added values instead of subtracting. There is no easy way to look out for proof on that tho. Interessting thing of note tho is that the glitch does not happen when he is on the enemyside, but it stores the classvalue as negative for it to happen once he joins regardless.

And giving him hardmode bonusses can negate the glitch because those stats are counted towards classstats.(likely because only enemys were supposed to have them)

Link to comment
Share on other sites

I investigated this problem and I found the culprit. Seems like there was some code injected from the original translators. This code isn't in the Japanese version.

The additional code executes everytime the characters stats are written to or read from SRAM (when you save, suspend, or the game auto-saves, and then when you reload a game). In the original version, your characters stats are all save as is in SRAM, with a bit of compression going on (all stats are put back to back, and each use only 5 bits, so they can never be over 31). The additional code, for whatever reason (I haven't figured out why they did this, it doesn't serve any apparent purpose), removes each character's base stats before saving the results to SRAM. When you reload a game, another part of the injected code adds back each character's base stats.

Normally, it all goes well except for when Hugh gets recruited with diminished stats. Hugh has only one table entry for his character. When you haggle his recruitment price, the game fetches his base stats from that one table entry, and subtracts 1 to every stats each time you refuse his cost.

The problem arises when the resulting stat is lower than its base in Hugh's table entry. For example, when you recruit Hugh, his base Magic is 12 + the mage class is 1, so you get a 13 Magic Hugh if you don't haggle. When the injected code do its thing, it takes that 13 , subtracts 12 (Hugh's base magic), which gives 1. That gets saved to SRAM. At reload, 1 + 12 = 13, so no problems there. Same thing if you haggle Hugh's recruitment cost once (12 - 12 = 0, then 0 + 12 = 12). But if you haggle twice, now the bug rears its ugly head,. 11 - 12 = -1, -1 is represented in binary form as "11111111". When the original game takes over and smush everything together in SRAM, it only uses 5 bits of each stats, so 11111111 becomes 11111, or 31 in decimal, instead of -1. Now when you reload, the injected code doesn't check for this kind of overflow, and just add the character's base stats as always. So 31 + 12 becomes 43.

I was contemplating just removing the subtracting and re-adding operations for a while as I can't find the purpose of why they did this in the first place, except maybe if you want to cheat and hack yourself monstrous stats like the 43 magic above (with the original game, stats can never be more than 31). But they really injected their code everywhere and I was afraid of breaking something else in the process. So, with the power of math, I found the best way to overcome this bug and with minimal changes. I just added one instruction to the injected code, and moved it a bit to compensate for this added instruction, and lo and behold, the bug is gone. I added a "and $1f" mask whenever the injected code subtracts or adds to a stat. That way, when 11 Magic Hugh gets saved to SRAM, the calculations goes: (11-12) and $1F, which is still 31. That gets saved to SRAM. But when a reload occurs, 31 + 12 = 43 (binary 00101011) AND $1F (binary 00011111) = our old friend 11 (binary 00001011)!

This was the simpler and the best solution I could think of. All other options I thought of made the previous save games oblsolete. Because that injected code made sure all saved games since then were filled with diminished stats. The solution I came up with still has the diminshed stats in the SRAM, and the injected code is still there, doing nothing useful, but at least people's save games / save states are still usable.

I worked on this because Gringe asked me if it was possible to erase this bug for his upcoming final (maybe?) translation version. So, the bug will be gone whenever the new translation version comes out.

Edited by tabachanker
Link to comment
Share on other sites

5 minutes ago, tabachanker said:

I worked on this because Gringe asked me if it was possible to erase this bug for his upcoming final (maybe?) translation version. So, the bug will be gone whenever the new translation version comes out.

Is it possible to inject the fix into other roms too? Just asking because I originally documented the bug to get it fixed in a hack of mine that was based on the older 1.0-release. And translations into other languages would also want to have the bug fixed. Not trying to be rude tho, just wondering.

Link to comment
Share on other sites

It's possible sure. Basically, all you have to do is replace a couple of bytes (about a hundred) in any ROM image with my new version. That part of the ROM was probably never changed by any version of the ROM out there (be it a different language ROM, a stats-altering ROM, or just a ROM with cosmetic changes). As long as the 100 or so bytes I changed are exactly as mine were before the patch, it should work perfectly.

But I want to test the fix though before posting here, because as I said, the injected code was everywhere in the ROM, and not just Hugh's stats were impacted. All the characters and possibly all the enemies are affected. That's why I want to make sure that my fix accounts for every possible outcomes before making it public.

Link to comment
Share on other sites

Just now, tabachanker said:

But I want to test the fix though before posting here, because as I said, the injected code was everywhere in the ROM, and not just Hugh's stats were impacted. All the characters and possibly all the enemies are affected. That's why I want to make sure that my fix accounts for every possible outcomes before making it public.

Ah, I see. Thanks for the reply.

Link to comment
Share on other sites

  • 5 months later...

Is this bit of injected code what also causes giant stat inflation when a save file from a previous ROM version is loaded into a newly-patched version of the ROM?  Here is a reference to what sounds like a similar bug in Gringe's translation thread made by CT075 about half the way down Page 43.

Quote

FEditor has a patch that causes all saved unit stats to be added onto the unit's original bases (this is in order to allow stats to exceed 31)

so if you were to apply the new translation into a game in progress, all your units' stats would be boosted by their bases

Source (as of 2020-11-20): 

 

I'm curious if your changes would end up fixing this parallel issue as well, or if it would only apply to Hugh.  There appears to already be a known workaround for the "patching a saved game" issue (e.g. start a new save file), but it would be a nice side benefit of fixing the Hugh bug.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...