øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=248.msg2065e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexfd45.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&action=profile;u=6;area=showposts;start=3225e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexfd45.html.zx¬¡h^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ0Pd>OKtext/htmlISO-8859-1gzip@øÕ>ÿÿÿÿÿÿÿÿWed, 11 Mar 2020 08:47:00 GMT0ó°° ®0®P®€§²ð®«¡h^ÿÿÿÿÿÿÿÿ©0> FF6 - possible bug

Author Topic: FF6 - possible bug  (Read 11076 times)

Lenophis

  • Forum Overlord
  • *
  • Posts: 1,688
  • Gender: Male
  • I sad
    • View Profile
    • Slick Productions
Re: FF6 - possible bug
« Reply #15 on: January 31, 2008, 10:18:44 PM »
It's very difficult to address, because in the case of a character dying before they can use the item, there's no practical way to check, "Was their turn unable to execute?".  It's not like you know for a fact that their turn will have completed within X seconds if it's going to complete at all, as there are so many possible intervening factors.  Besides, a timer would be tedious and difficult to set up anyway.
Not to mention completely impractical.

--Edit--
But you said that already! Hooray for reading ability! :happy:
--/Edit--

Quote
how about _before_ C2/4DB0, you preserve A, check the character's current $32F4,Y value, and if it isn't FFh, then call a routine to put its contents back into inventory?  (you'd want to code a custom version of C2/62C7
Ugh, I was hoping I could avoid making another 62C7. :sad:

Quote
to focus on one character, as calling the entire function would mess with other characters' $32F4 values.)  that oughta take care of any aborted Item usages from the character's previous turns.  as you said, you wouldn't be able to use $3A8C here, but i think that'll be alright, unless $32F4 somehow gets misleading garbage in it.
On the other hand, I may have no choice. And instead of looking at 3A8C or B1, I would check the item data directly, and if it's re-addable, re-add to inventory. I suspect I may need to make a duplicate of 54DC as well. :hmm:

Quote
still, there's the matter of if a character is killed while attempting to use Tonic, then they are revived, why should they have to wait til the end of battle to get that Tonic back into inventory?  it's not like the Tonic rolled meters away from them and they have to scour the ground for it.  obviously, the end-of-battle check serves as a catch-all, but there's no good reason that restoral shouldn't happen sooner/immediately.

at one point, i think Imzogelmo suggested cutting off all the ways a character can be taken out of commission (e.g. dying, being petrified, being Sneezed, etc, etc), and adding an item restoral call to each one.  if the character died before they can use an item, it's presumably still on their person, so the party shouldn't even have to wait for the character to be revived just so they can have access to the item -- rigor mortis aside.
All of this for one simple bug. :bah:

Oh well, planning begins.
« Last Edit: January 31, 2008, 10:46:20 PM by Lenophis »

119 bugs fixed and counting.

Deathlike2

  • FF4 R&D Master
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: FF6 - possible bug
« Reply #16 on: January 31, 2008, 10:35:10 PM »
still, there's the matter of if a character is killed while attempting to use Tonic, then they are revived, why should they have to wait til the end of battle to get that Tonic back into inventory?  it's not like the Tonic rolled meters away from them and they have to scour the ground for it.  obviously, the end-of-battle check serves as a catch-all, but there's no good reason that restoral shouldn't happen sooner/immediately.

at one point, i think Imzogelmo suggested cutting off all the ways a character can be taken out of commission (e.g. dying, being petrified, being Sneezed, etc, etc), and adding an item restoral call to each one.  if the character died before they can use an item, it's presumably still on their person, so the party shouldn't even have to wait for the character to be revived just so they can have access to the item -- rigor mortis aside.

Instead of having an item restoral call to each one, you need to set a byte (a new variable or whatever) that says they are unable to execute their turn (although, shouldn't that already exist...?) Just check this variable after the list of status checks and then just call the item restoral function when applicable.
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3

Lenophis

  • Forum Overlord
  • *
  • Posts: 1,688
  • Gender: Male
  • I sad
    • View Profile
    • Slick Productions
Re: FF6 - possible bug
« Reply #17 on: January 31, 2008, 11:55:57 PM »
Ok, there is a fix in place. Kejar gave me concept code last night, and for some reason I didn't think to switch indexes with where I needed it. :tongue: However, it's not a perfect fix. The item will not be lost, but it can be.....misplaced. Explanation:

Character A uses item, but dies before item can be used. Character A gets revived, but since the item wasn't used, the "re-add to inventory" bit was never set. Therefore, the item remains on character's person. However, if character A uses a different item, the original will be re-added. In short, if character A uses another item, the original is returned. If battle ends, the original is returned. However, until one of those two (or steal/metamorph occur), the item will not be re-added back to inventory. This is especially annoying if there is 1 item left, and you desperately need to use it. Unfortunately, I don't think I can work around that, as that would drastically change how the battles flow.

Also, this fix needs to be applied to a few areas (steal and metamorph, specifically), so there's bound to be a few versions of this patch. Freaking bugs...
« Last Edit: February 01, 2008, 12:15:11 AM by Lenophis »

119 bugs fixed and counting.

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: FF6 - possible bug
« Reply #18 on: February 01, 2008, 03:13:30 AM »
Quote from: Lenophis
On the other hand, I may have no choice. And instead of looking at 3A8C or B1, I would check the item data directly, and if it's re-addable, re-add to inventory. I suspect I may need to make a duplicate of 54DC as well.

but the bug isn't limited to re-addable items.  consider my previous example where you tell the character to use Potion, they're killed before they can actually use it, then the character is revived and uses Tonic.


Quote from: Deathlike2
Instead of having an item restoral call to each one, you need to set a byte (a new variable or whatever) that says they are unable to execute their turn (although, shouldn't that already exist...?) Just check this variable after the list of status checks and then just call the item restoral function when applicable.

but the status checks that are executed at the end of a turn won't occur if the turn never occurs.  that's the thing: you have the selection+confirmation of the item, at which point the character's turn is queued.  then there's a wait before the character acts, then the actual execution of their turn.  there's no simple way to determine "this character's turn failed to execute" versus "this character's turn is going to execute at some point".

Lenophis

  • Forum Overlord
  • *
  • Posts: 1,688
  • Gender: Male
  • I sad
    • View Profile
    • Slick Productions
Re: FF6 - possible bug
« Reply #19 on: February 01, 2008, 12:13:38 PM »
Well, I have a feeling that it will need an update, but a patch is released. I tested a couple of ways to lose items, and so far I haven't lost any with it yet. I'm not sure if I tested all methods, though.

119 bugs fixed and counting.

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: FF6 - possible bug
« Reply #20 on: February 02, 2008, 07:12:05 AM »
i notice it calls C2/62C7.  because you can input an Item turn at any point, including while somebody else's turn unfolds, isn't it technically possible that this code could run between Steal/Metamorph setting $32F4, and the $32F4 getting added to inventory at the end of the Steal/Metamorph turn?  maybe that won't change the results, but it still kinda bothers me.

i also had a fear of this code happening in between some other character's Item input and their execution; i thought it would cause the used item to always be restored to inventory (because it's still held in $32F4), even when it should be consumed.  but after more thought, i realize i was wrong, as the other character won't have their $3A8C flag set until the actual turn execution..  so an intervening 62C7 call shouldn't wreck anything.

Lenophis

  • Forum Overlord
  • *
  • Posts: 1,688
  • Gender: Male
  • I sad
    • View Profile
    • Slick Productions
Re: FF6 - possible bug
« Reply #21 on: February 02, 2008, 12:32:53 PM »
i also had a fear of this code happening in between some other character's Item input and their execution; i thought it would cause the used item to always be restored to inventory (because it's still held in $32F4), even when it should be consumed.  but after more thought, i realize i was wrong, as the other character won't have their $3A8C flag set until the actual turn execution..  so an intervening 62C7 call shouldn't wreck anything.
Yeah, the determining factor was $3A8C. It's also because of that is why an item may remain in limbo after death/revival. :tongue: This should fix it, and with the few tests I did it was fixed. I'm still waiting on some more verification though.

119 bugs fixed and counting.

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: FF6 - possible bug
« Reply #22 on: February 02, 2008, 09:12:42 PM »
what're your thoughts on the first paragraph?

Lenophis

  • Forum Overlord
  • *
  • Posts: 1,688
  • Gender: Male
  • I sad
    • View Profile
    • Slick Productions
Re: FF6 - possible bug
« Reply #23 on: February 02, 2008, 09:32:58 PM »
what're your thoughts on the first paragraph?
Well then...

i notice it calls C2/62C7.  because you can input an Item turn at any point, including while somebody else's turn unfolds, isn't it technically possible that this code could run between Steal/Metamorph setting $32F4, and the $32F4 getting added to inventory at the end of the Steal/Metamorph turn?  maybe that won't change the results, but it still kinda bothers me.
It shouldn't be a factor, as $32F4 indexed will check the current character inputting, and steal/metamorph will have probably already executed. IIRC, those are calculated well before the animation even starts. If it were an issue, you'd need exceptionally good timing when entering the command at the moment steal/metamorph adds their items. Although, it's also possible the entering of a command is queued until after the previous is done executing. This is theory, and I have nothing to back it up with. :hmm: In the end, it shouldn't be an issue.

119 bugs fixed and counting.

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: FF6 - possible bug
« Reply #24 on: February 02, 2008, 11:11:26 PM »
Steal/Metamorph set $32F4 before the animation starts, but $32F4 is put into inventory after the animation plays out:

Code: [Select]
Character/Monster Takes One Turn

C2/13D3: DA           PHX

[...]

C2/1412: A9 04        LDA #$04
C2/1414: 20 11 64     JSR $6411   (Shows action?)
C2/1417: 20 B9 4A     JSR $4AB9
C2/141A: 20 7A 14     JSR $147A   
C2/141D: 20 3F 08     JSR $083F
C2/1420: 20 4F 14     JSR $144F
C2/1423: 20 C7 62     JSR $62C7   (Add Stolen or Metamorphed item to inventory.
                                   Also, add back an item used via Equipment Magic
                                   if the item isn't destroyed upon use [no
                                   equipment in the game works that way, but it's
                                   fully possible].)
C2/1426: 28           PLP
C2/1427: FA           PLX
C2/1428: 60           RTS

as for any delay in the queueing, that's a good question, and i'm really not sure of the answer.

Lenophis

  • Forum Overlord
  • *
  • Posts: 1,688
  • Gender: Male
  • I sad
    • View Profile
    • Slick Productions
Re: FF6 - possible bug
« Reply #25 on: February 10, 2008, 10:39:41 PM »
--Edit--

Ok, For What Ails Ya was broken, but only slightly. Slightly in the sense that it wasn't broken. Another patch was interfering with it, and as though it was fate, it was one of my own patches. If you plan on using For What Ails Ya, and you have used Anchors Aweigh, for the love of all that is sacred use the newest Anchors Aweigh version!
« Last Edit: February 10, 2008, 11:24:54 PM by Lenophis »

119 bugs fixed and counting.

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: FF6 - possible bug
« Reply #26 on: February 21, 2011, 11:30:57 PM »
i notice in the February 2008 release of the patch, the 4 patches are all the same size as each other, and the 4 anti-patches are all the same size as each other.

not so with the October 2010 update.  3 of the patches are 83 bytes, while "For What Ails Ya - no multi-steal - header.ips" is 91 bytes.  3 of the anti-patches are 42 bytes, while "Anti Ails - no multi-steal - header.ips" is 55 bytes.

the reason for the discrepancy is that this patch and its anti-patch actually modify the ROM header.  in the case of the anti-patch, it's changing bytes 000003h thru 00000Ah (back) to: 80 00 00 00 00 AA BB 04 .  that's done by the IPS file starting with the following bytes: 50 41 54 43 48 00 00 03 00 08 80 00 00 00 00 AA BB 04 .  straightforward enough.

as for the patch, the file starts with: 50 41 54 43 48 00 00 03 00 00 00 08 00 .   looking at http://zerosoft.zophar.net/ips.php , this uses RLE, and is telling the patcher to overwrite bytes 000003h thru 00000Ah with 00s.

so neither the patch nor the anti-patch will harm anything.  but editing the header is a bit pointless and confusing, and i wonder whether it was intentional, given the first release of the patch doesn't do it, and the Multi-steal version of the current patch still doesn't.

just a heads up, however unurgent.

Lenophis

  • Forum Overlord
  • *
  • Posts: 1,688
  • Gender: Male
  • I sad
    • View Profile
    • Slick Productions
Re: FF6 - possible bug
« Reply #27 on: February 22, 2011, 07:08:45 AM »
the reason for the discrepancy is that this patch and its anti-patch actually modify the ROM header.
Huh. I wonder if that's xkas doing it, cause I know I'm not worried about changing the header.

119 bugs fixed and counting.

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: FF6 - possible bug
« Reply #28 on: February 22, 2011, 07:08:39 PM »
another issue, this time with the documentation.  looking through "C2 - new.txt", it seemed the new function, C2/650D, was never called.  it is, but C2/4DAF thru C2/4DB3 in the aforementioned text file weren't updated to indicate that.  (ails_ya.asm is fine, based on a brief glance.)
« Last Edit: February 22, 2011, 07:21:19 PM by assassin »

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: FF6 - possible bug
« Reply #29 on: August 01, 2013, 11:46:02 AM »
Quote
The item doesn't reappear in inventory until the character that uses it gets their ATB refilled.

i don't think you need to have their ATB refilled, but rather change from one character to another with X or Y.  iirc, the Item List you see can't update while you're just sitting on a character's main battle menu as somebody else is altering the Item inventory.  so it's the same deal with Stolen items.   X/Y triggers the "refresh".

or besides X/Y, having a character take a turn, so another gets first in line.  iow, i think it's tied to having the triangle cursor switch onto a new character.

anyway, it turns out that the inventory adding, after the C2/54DC call in C2/62C7, has two steps:
1) Copy $2E72-$2E76 buffer to a $602D-$6031 [plus offset] buffer , as many as 4 times
2) Copy $602D-$6031 buffer entry/ies to Item menu

C2/62C7 does the first step.  if we're at the end of battle, C2/492E does the call to handle #2 (one call, which loops if there're multiple buffer entries) right after that.  if we're mid-battle, we're reliant on the triangle cursor switch.  or if that never happens, then it's addressed when the battle is finished.

this explains the lag in the Item menu update after acquiring an item, if we didn't move the cursor off of a given character in the process.  this can be prolonged awhile, if we have characters acting automatically.  i don't think there are any problems beyond wait (i.e. no item loss), since the $602D buffer apparently has 16 entries maximum, which is plenty.  (6 stealings + 6 Metamorphings = 12.  though Pandora's Box can exceed that if you indeed implemented the multiple stolen items per enemy?)  the only way i can think of to exceed this in a normal, For-What-Ails-Ya-fixed game involves a character Life 3'ing themselves, trying to use an item, and coincidentally getting killed before they can act -- and doing this at least 5 times (12 + 5 > 16).
EDIT: ok, that last sentence is wrong, because having their main menu come up again when their ATB refills after revival will refresh the Item menu.

elsewhere (i.e. won items), Square just calls C2/6279, which handles Steps #1 and 2 in one shot.  so why do they split up the steps in these cases?  my guess is speed.  at battle end, C2/492E doing step #2 for all characters with one Bank C1 call (LDA #$0A / JSR $6411) is faster than having C2/62C7 do this far call for each character separately.

however, as mentioned, Step #2 doesn't always instantly follow #1 mid-battle.  since i don't favor editing C2/62C7, a fix for the lag would be to have C2/1423 do a "LDA #$0A / JSR $6411" right afterwards.  a far call consumes some cycles, but it can't be *that* bad.

to refresh: this lag behavior is in the original game, and isn't caused by the "For What Ails Ya" patch.
« Last Edit: August 02, 2013, 10:15:45 AM by assassin »