øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=2293.15e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexe56b-2.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&board=8.60e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexe56b-2.html.zx°$h^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ ,/¦*OKtext/htmlISO-8859-1gzip@øÕ¦*ÿÿÿÿÿÿÿÿTue, 10 Mar 2020 23:53:45 GMT0ó°° ®0®P®€§²ð®°$h^ÿÿÿÿÿÿÿÿ‚+¦* Possible FF6 event bug on game reloading

Author Topic: Possible FF6 event bug on game reloading  (Read 2735 times)

Madsiur

  • Tunnel Armor
  • *
  • Posts: 149
  • Gender: Male
  • FF6AE coder
    • View Profile
    • Madsiur's Lair
Re: Possible FF6 event bug on game reloading
« Reply #15 on: January 23, 2017, 09:19:32 PM »
vivify93 reported a bug on RHDN. When entering loading confirmation screen, returning to save file menu and starting a new game, Object data would be done hence 3 blond Terra at startup. I fixed this by hooking the data reset loop after pressing A on loading confirmation screen. You can apply the "repair" patch if you already had applied v1.2. The "fix" patch is for a first patching.

13375K31C43R

  • Ultros
  • *
  • Posts: 675
  • Gender: Male
    • View Profile
    • Leet Sketcher's Final Fantasy III Patches
Re: Possible FF6 event bug on game reloading
« Reply #16 on: January 24, 2017, 03:55:19 PM »
By the way, I reworked my "Chain of Command" patch to not use free space, so your function could have gone six bytes later.

Don't feel compelled to move your function now, or ever, this is just an FYI.

One thing we really need is an updatable list of all patches that use free space, because Imzogelmo's document is WAY out of date.
"Do not meddle in the affairs of wizards, for they are subtle and quick to anger." -Gildor from The Lord of the Rings

Imzogelmo

  • Ogopogo Aficianado
  • *
  • Posts: 241
  • Gender: Male
  • Ask me about my other job.
    • View Profile
    • NEPROMR
Re: Possible FF6 event bug on game reloading
« Reply #17 on: January 24, 2017, 06:53:48 PM »
...and Imzogelmo has not been keeping up with that, because there's a lot of new patches and, well, life. If anyone else wants to take up the mantle, feel free. If not, I may eventually get around to it.

 :edit:
Another related thing we need is a listing of all bytes affected by all patches, and any subroutines or data blocks that are referenced from them, so that we could more easily track conflicts.

OH, also event code space needs managing.

AND ALSO, and RAM bytes that get allocated by patches.

« Last Edit: January 24, 2017, 07:00:45 PM by Imzogelmo »
5/31/16 - I have an assembly of the battle portion of C2, relocated to the F0 bank, which has both vanilla and patch code in my dropbox. I'll be updating it with additional patches as I have time. I will *not* be releasing it publicly, but ask me for the link and I'll share.

C. V. Reynolds

  • Tunnel Armor
  • *
  • Posts: 153
  • RATED TEM OUTTA TEM.
    • View Profile
    • cvreynolds.net
Re: Possible FF6 event bug on game reloading
« Reply #18 on: January 27, 2017, 02:05:51 PM »
Hoi. Back from vacation. :3

Madsiur: After using the repair patch for the Frozen Terra Fix as indicated, there remains a stray "60" byte at hex address 3FFBB. It isn't there if one patches using the fix patch. I don't know if it would cause any problems being there, but I changed it to "FF" on my end to be sure.
I'm the former Hollywood Narrator from GameFAQs.

I'm a published novelist. My novels "Universe Eleven Series - Blue Ruin" Part 1, Part 2, and Part 3 are for sale on Amazon (check my website) in print and ebook formats.

Madsiur

  • Tunnel Armor
  • *
  • Posts: 149
  • Gender: Male
  • FF6AE coder
    • View Profile
    • Madsiur's Lair
Re: Possible FF6 event bug on game reloading
« Reply #19 on: January 29, 2017, 09:44:04 AM »
Hoi. Back from vacation. :3

Madsiur: After using the repair patch for the Frozen Terra Fix as indicated, there remains a stray "60" byte at hex address 3FFBB. It isn't there if one patches using the fix patch. I don't know if it would cause any problems being there, but I changed it to "FF" on my end to be sure.

Yes, that is a miscalculation leaving the old RTS (0x60) after the new RTS, so removing it cause no problem.


For which patch use which space, maybe we could start something like this: http://slickproductions.org/slickwiki/index.php/Patches_Allocation

Each patch creator could fill this, this way we would have a decent patches map, at least for those created by people who contribute to the list...

13375K31C43R

  • Ultros
  • *
  • Posts: 675
  • Gender: Male
    • View Profile
    • Leet Sketcher's Final Fantasy III Patches
Re: Possible FF6 event bug on game reloading
« Reply #20 on: January 29, 2017, 03:54:26 PM »
For which patch use which space, maybe we could start something like this: http://slickproductions.org/slickwiki/index.php/Patches_Allocation

Each patch creator could fill this, this way we would have a decent patches map, at least for those created by people who contribute to the list...

I like it. Is it just for free space or for every patch ever written? There should at least be some indication of what space is free space. It's also worth mentioning that there's a whole chunk of bank C2 that's free space in the US ROM, but not the Japanese.
"Do not meddle in the affairs of wizards, for they are subtle and quick to anger." -Gildor from The Lord of the Rings

Imzogelmo

  • Ogopogo Aficianado
  • *
  • Posts: 241
  • Gender: Male
  • Ask me about my other job.
    • View Profile
    • NEPROMR
Re: Possible FF6 event bug on game reloading
« Reply #21 on: January 29, 2017, 03:56:37 PM »
This is a good idea. We would need to do this for some older patches whose authors are MIA, but it's not so many as to be untenable.
5/31/16 - I have an assembly of the battle portion of C2, relocated to the F0 bank, which has both vanilla and patch code in my dropbox. I'll be updating it with additional patches as I have time. I will *not* be releasing it publicly, but ask me for the link and I'll share.

Madsiur

  • Tunnel Armor
  • *
  • Posts: 149
  • Gender: Male
  • FF6AE coder
    • View Profile
    • Madsiur's Lair
Re: Possible FF6 event bug on game reloading
« Reply #22 on: January 29, 2017, 07:15:45 PM »
I like it. Is it just for free space or for every patch ever written? There should at least be some indication of what space is free space.

You're right. I added a column for free space. I'm not sure if it's ideal or if cross checking with a free space map would be better.

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: Possible FF6 event bug on game reloading
« Reply #23 on: February 15, 2017, 08:59:09 PM »
maybe also registers clobbered, i.e. ones that the vanilla version of a function doesn't alter.  if vanilla doesn't care about a register that a patch changes, e.g. it overwrites it shortly before or after calling the patched function without reading it, that might be good enough to get the patch made without using free space for push/pull.  however, a theoretical hacker that's treating the original function as more standalone might lean on its not clobbering certain things, not wanting to consume push/pull space themselves.

computer science teachers would probably demand every function list these things at the top under the description.  along with annoying crap like "input" and "output", and big-O notation of execution time.

now, some judgment needs to be used as to whether vanilla altering the register is an existing form of "clobbering", or if it's setting a meaningful value that a caller might look at.  but that's fairly obvious in most cases, even if i couldn't readily define it.

there's currently a patch i'm dragging my feet on updating because while i can shrink free space by 3 bytes as-is, i could shrink another 2 bytes by clobbering Y.  vanilla overwrites Y shortly before and somewhat after the function in question.  so it ought to be safe, but has potential compatibility issues.

Imzogelmo

  • Ogopogo Aficianado
  • *
  • Posts: 241
  • Gender: Male
  • Ask me about my other job.
    • View Profile
    • NEPROMR
Re: Possible FF6 event bug on game reloading
« Reply #24 on: February 15, 2017, 10:52:37 PM »
I know what you mean about the X and Y clobbering/"clobbering" in vanilla. It's one of those things that you know when you see it, but it's hard to nail it down. Typically, I think of it as whether the game is using X or Y to count up or down through a sequence--in that case, feel free to clobber it immediately before or after such a loop. If the function has some LDA, X or LDA, Y, or LDY, X stuff (or STA, X or STZ, X ... i.e. X- and Y-indexed opcodes) going on, and you can't tell where X or Y got set (at least not easily), then leave them alone (meaning preserve them if you need to change them temporarily).  Obviously, these are two extremes and there has to be some middle-ground, gray area in between, and it is best to err on the side of caution in such cases...

I think if X or Y or upper A gets clobbered, that tends to lead to fairly devastating bugs that are hard to track, but for lower A, I would say it's almost never a big deal, since lower A is the real workhorse and never really holds anything for very long before it's needed for something else.
Stack mismatches typically manifest fairly magnificently, so those are usually easy to track (unless it's a very rarely taken branch...).
Branching errors can be avoided by using an assembler as long as the logic is sound.
Logic errors can't really be detected except by a 2nd set of eyes.

« Last Edit: February 15, 2017, 10:59:45 PM by Imzogelmo »
5/31/16 - I have an assembly of the battle portion of C2, relocated to the F0 bank, which has both vanilla and patch code in my dropbox. I'll be updating it with additional patches as I have time. I will *not* be releasing it publicly, but ask me for the link and I'll share.

13375K31C43R

  • Ultros
  • *
  • Posts: 675
  • Gender: Male
    • View Profile
    • Leet Sketcher's Final Fantasy III Patches
Re: Possible FF6 event bug on game reloading
« Reply #25 on: February 15, 2017, 11:48:00 PM »
I do believe we're now branching into stuff that is :offtopic:
"Do not meddle in the affairs of wizards, for they are subtle and quick to anger." -Gildor from The Lord of the Rings

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: Possible FF6 event bug on game reloading
« Reply #26 on: February 16, 2017, 12:41:49 AM »
let the Topic Creator be the arbiter of that. :P  he didn't seem to mind discussing Patch Allocation and things consumed by a patch two weeks ago.  register clobbering is another form of consumption.  code addresses aren't the be-all and end-all.

creating another topic as a follow-up to a discussion that developed in this one would've been pointless and wasteful, imho.

Madsiur

  • Tunnel Armor
  • *
  • Posts: 149
  • Gender: Male
  • FF6AE coder
    • View Profile
    • Madsiur's Lair
Re: Possible FF6 event bug on game reloading
« Reply #27 on: February 18, 2017, 09:58:36 PM »
maybe also registers clobbered, i.e. ones that the vanilla version of a function doesn't alter.  if vanilla doesn't care about a register that a patch changes, e.g. it overwrites it shortly before or after calling the patched function without reading it, that might be good enough to get the patch made without using free space for push/pull.  however, a theoretical hacker that's treating the original function as more standalone might lean on its not clobbering certain things, not wanting to consume push/pull space themselves.

Do you mean identify the patches that are (or not) registers clobbered or do you talk about my patch in this thread? I think I understand what clobbering mean but I don't see at first glance the point of adding to the patch allocation page.

I understand that sometimes without studying the code or running it through a debugger, some hackers might do a push on the registers they will use and a pull at the end of the patch in order to be sure those registers are not altered, even if they get overwritten later on by a TAX, TAY, STX or STY, which render the previous pushes useless. I can say I've done this myself before, I should go back to those patches and make sure thing are tighter. I usually check thee code previous to the patch and after to get a rough idea of what is going on, if a push is necessary, but there are instance where I can lose track of registers.

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: Possible FF6 event bug on game reloading
« Reply #28 on: February 19, 2017, 12:55:59 AM »
Madsiur: yes, identifying patches for allocation documents.  as mentioned, the reason is interoperability with other patches: "however, a theoretical hacker that's treating the original function as more standalone might lean on its not clobbering certain things, not wanting to consume push/pull space themselves."  iow, while i might clobber registers in a patch based upon observing that the caller doesn't "need" them kept a certain way, a hacker calling a vanilla function might be looking at it from an opposite direction: the routine doesn't alter the registers (at least not without preserving them), so why should the hacker feel the need to preserve them?  they're two valid ways of looking at things, but their difference, plus the two hackers' commonality of wanting to minimize code space, sets the stage for conflicts.

i won't say this is as important to list as code addresses or RAM variables, but it does fall under resource consumption, and concerns interoperability.

---------

Imzogelmo: speaking of stack usage, one thing perhaps worth reporting is increase in maximum stack depth during the function.  hopefully, the makers left GOBS of stack space to spare, but we don't know that for sure.  ultimately, it's absolute stack address that matters, but i have no idea how to say what that'd be in all the situations a function can be called..  so i'd probably keep it relative, and go for delta from vanilla at whatever the most stack-extended part of the function is.

Imzogelmo

  • Ogopogo Aficianado
  • *
  • Posts: 241
  • Gender: Male
  • Ask me about my other job.
    • View Profile
    • NEPROMR
Re: Possible FF6 event bug on game reloading
« Reply #29 on: February 19, 2017, 12:56:23 PM »
I don't know the maximum depth of stack usage offhand, and your suggestion that vanilla leaves a lot unused seems spot-on from what I've seen (barring bugs). Honestly, we should know, at least relatively, how deep the stack can grow in vanilla. From all tests that I've seen (again, excluding a nasty bug..), the battle engine is where the stack usage grows to its deepest point. In terms of absolute depth, the number 30 seems to come to mind, although it could be a little higher. This is definitely a topic we need to nail down, what with all the patches jumping to free space and all...
5/31/16 - I have an assembly of the battle portion of C2, relocated to the F0 bank, which has both vanilla and patch code in my dropbox. I'll be updating it with additional patches as I have time. I will *not* be releasing it publicly, but ask me for the link and I'll share.