Invincible Guardian

If it has bytes, we can change it. Talk about anything relating to hacking and emulation here.

Moderators: General Moderator, Game Moderator

Re: Invincible Guardian

Postby Assassin » Thu Apr 05, 2012 3:34 am

Drakkhen: do you have a reply to this issue:

me wrote:both the 24-bit code and the 16-bit code will have an issue with the "ADC $11AE" when Gauntlet is not equipped. namely, the result will end up 1 too high, because Carry is set going into the add, as a result of your Gauntlet test. the original game manages to avoid this without an explicit CLC because Carry will always be clear going into C2/2BBA. however, you're probably going to need a "CLC" before the "ADC $11AE". not an issue in the 24-bit version, which has a NOP ripe for the taking, and consumes extra space regardless. however, the 16-bit version has no NOP, and is on the precipice.

or to my optimized function that addresses it? i waited the obligatory one month before following up. ;P
User avatar
Assassin
Moderator
Moderator
 
Posts: 1195
Joined: Tue Sep 14, 2004 5:10 am

Re: Invincible Guardian

Postby Drakkhen » Thu Apr 05, 2012 5:37 pm

Sorry, procrastination can cause quite the derailment.
Fortunately, I had gotten most of the work finished before it had me within its grasp and managed to finish these up in relatively little time.

http://drakkhen.jalchavware.com/ff3pdof16.zip
http://drakkhen.jalchavware.com/ff3pdof24.zip

I think these will rectify the previously mentioned problems without introducing new issues, but I've been wrong before.

I also made this(it's what initially held me up):
http://drakkhen.jalchavware.com/ff3dof.zip

Merges the two damage formulas into one big one, fixing both damage overflows at the same time without using any free space. The only potential issue is that it borrows the ending of a completely unrelated function in order to fit into the space provided.
Drakkhen
Active User
Active User
 
Posts: 71
Joined: Thu Sep 09, 2004 9:06 am
Location: Dry Land, Earth

Re: Invincible Guardian

Postby Assassin » Fri Apr 06, 2012 5:43 am

no prob. there's a good chance i won't have many responses myself (besides this) until tax time is over.

regarding the 16-bit patch:

1) mine (mostly retained from your older one) does:
Code: Select all
C2/2B??: 7B            TDC
[... Y-related instructions]
C2/2B??: AD A6 11      LDA $11A6     (Battle Power)
C2/2B??: C2 20         REP #$20      (Set 16-bit Accumulator)

your new one does:

Code: Select all
C2/2BA3: AC A6 11      LDY $11A6     (Battle Power)
C2/2BA6: C2 20         REP #$20      (Set 16-bit Accumulator)
C2/2BA8: 98            TYA

it's the same size, and the TYA trick is less intuitive to read than the plain ol' TDC. it should run fine (or else i wouldn't have recommended the TYA deal later on), but i'm just curious why you switched given the lack of byte savings.

2) wow, it took me awhile to figure why you had the two PLYs late in the function, and that is UG-LY. :P still, quite clever. it's probably worth commenting on both PLYs as to what exactly you're doing there. different people have different commenting styles, and i recognize most are less verbose than mine, but i think as-is it could be a headscratcher to some people reading it. for that matter, maybe say how the TYAs at C2/2BE7 and C2/2BA8 are zeroing the top half of A, as well.

anyway, another impressive piece of optimization.
User avatar
Assassin
Moderator
Moderator
 
Posts: 1195
Joined: Tue Sep 14, 2004 5:10 am

Re: Invincible Guardian

Postby Drakkhen » Sun Apr 08, 2012 7:59 pm

1. I fiddled with lots of ways of redoing the code, I guess that's just what I wound up with. I can change it back if you think I should.

2. Noted.
Drakkhen
Active User
Active User
 
Posts: 71
Joined: Thu Sep 09, 2004 9:06 am
Location: Dry Land, Earth

Re: Invincible Guardian

Postby Assassin » Mon Apr 09, 2012 9:01 am

1) bah, as long as it works, there's no need to change it. just commenting it should be enough, imho.
User avatar
Assassin
Moderator
Moderator
 
Posts: 1195
Joined: Tue Sep 14, 2004 5:10 am

Re: Invincible Guardian

Postby Assassin » Sun Jul 22, 2012 3:53 pm

belated comment: that "PEA $0000" optimization in the 24-bit patch is also nice.

as for the combined physical and magic overflow fix, that's ambitious and probably quite good.. but i lack the focus and patience to proofread it. one observation: you can compress the first three instructions of C2/2B69 to "LDY $11AF / STY $E8" , saving one byte. there's no point to it now, as you already fit the patch inline, but it could provide wiggle room should issues be run into elsewhere.
User avatar
Assassin
Moderator
Moderator
 
Posts: 1195
Joined: Tue Sep 14, 2004 5:10 am

Re: Invincible Guardian

Postby Drakkhen » Thu Jul 26, 2012 1:15 pm

Yes, I was aware of that particular optimization. However, leaving that spot unoptimized reduces the patch size since those first two instructions are identical to the original code. If not for that, I definitely would have opted for the extra free byte.
Drakkhen
Active User
Active User
 
Posts: 71
Joined: Thu Sep 09, 2004 9:06 am
Location: Dry Land, Earth

Re: Invincible Guardian

Postby Assassin » Sat Aug 18, 2012 2:31 pm

a sort of related request for optimization help... back in March, i discovered an overflow bug with the Atma Weapon special effect. most of the character setups that'd cause this bug also cause the bug in the general physical damage function. so to see Atma Weapon overflow on its own, use a character at level 99 *, with 107 Vigor *, Gauntlet, and Atlas Armlet or Hero Ring, in the front row, and it'll randomly occur most of the time. (* other Level and Vigor values, such as 94 and 125, will work, but the ones i provided give the best shot of seeing it.)

here's my attempt at a fix:

Code: Select all
Atma Weapon damage modification

C2/0E39: 08           PHP
C2/0E3A: DA           PHX
C2/0E3B: 5A           PHY
C2/0E3C: 9B           TXY            (Y points to attacker)
C2/0E3D: B9 F5 3B     LDA $3BF5,Y    (HP / 256)
C2/0E40: 1A           INC
C2/0E41: EB           XBA
C2/0E42: B9 18 3B     LDA $3B18,Y    (Level)
C2/0E45: 20 81 47     JSR $4781      (Level * ((HP / 256) + 1))
C2/0E48: BE 1D 3C     LDX $3C1D,Y    (Max HP / 256)
C2/0E4B: E8           INX
C2/0E4C: 20 92 47     JSR $4792      ((Level * ((HP / 256) + 1)) / ((Max HP / 256) + 1))
C2/0E4F: 85 E8        STA $E8        (save modifier quotient)

-------- everything before this dotted line unchanged --------

stz $eb

C2/0E??: C2 20        REP #$20
C2/0E??: A5 F0        LDA $F0        (load damage so far)
C2/0E??: 20 B7 47     JSR $47B7      (24-bit $E8 = modifier in 8-bit $E8 * 16-bit damage)
C2/0E??: A9 05 00     LDA #$0005

jsr extra
nop

------- everything after this dotted line unchanged -------

C2/0E61: C9 F5 01     CMP #$01F5
C2/0E64: 90 0D        BCC $0E73      (branch if < 501)
C2/0E66: A2 5B        LDX #$5B       (put index for alternate, bigger weapon
                                      graphic, into X)
C2/0E68: C9 E9 03     CMP #$03E9
C2/0E6B: 90 01        BCC $0E6E      (branch if < 1001)
C2/0E6D: E8           INX            (make graphic bigger yet)
C2/0E6E: 86 B7        STX $B7        (save graphic index)
C2/0E70: 20 BB 35     JSR $35BB      (Change Atma Weapon length by updating animation
                                      buffer with altered $B7.)
C2/0E73: 7A           PLY
C2/0E74: FA           PLX
C2/0E75: 28           PLP
C2/0E76: 60           RTS

=================

(somewhere in FF-block land)
extra:
20 D1 0D     JSR $0DD1  (Divide 24-bit Damage in $E8 by 64. [note that
                         calculation operates on 4 bytes])
ldx $ea
bne cap_it

inc
bne skip

cap_it:
tdc
dec

skip:
sta $f0
rts


that uses 15 extra bytes of space. it's kind of embarrassing to add that many bytes for such a small original function, but damned if i can find a way to reduce it any. i am aware of space optimizations for the neighboring C2/0E77, but the problem is i already did them waaaay back when making the Genji Glove damage reduction patch, so an Atma Weapon fix that touched that function wouldn't be able to coexist with the Genji Glove one. and i'm not seeing any optimization chances in C2/0E21.
User avatar
Assassin
Moderator
Moderator
 
Posts: 1195
Joined: Tue Sep 14, 2004 5:10 am

Re: Invincible Guardian

Postby Drakkhen » Sun Aug 19, 2012 6:35 pm

Well, I might see a way to potentially save 3 bytes by modifying the C2/35BB function and jumping there instead of JSR, but a few other places use that function and I'm not sure if the changes would be safe.
Other than that I don't really see anything.
Drakkhen
Active User
Active User
 
Posts: 71
Joined: Thu Sep 09, 2004 9:06 am
Location: Dry Land, Earth

Re: Invincible Guardian

Postby Assassin » Sun Aug 19, 2012 9:02 pm

thanks for the reply. i see what you're getting at. or save 4 bytes by flipping the PHP/PHX and PLX/PHP in C2/0E39, and changing C2/35BB to use Y for the preservation of $3A72, with an accompanying PHY/PLY outside of that. (also, you'd move down the "JSR $35D4" to after the PHX and PHP, which i think you already had in mind.) but i'm not nuts about the safety of this overhaul, either. Metamorph calls C2/35BE. and it's possible that some future hack could be pissy about expecting Function C2/0E39 to preserve the Flags.

the only other thing i had in mind was to save 1 byte in C2/0DED by dropping the "TXY" at C2/0E0F, then modifying the two instructions after it to just use X instead. that byte plus the wasted NOP in my patch code would combine for a 2-byte reduction from what i have currently. but it's probably not worth it, given that this would require Function C2/0E21 to be shifted up, and a number of places in Bank C2 call/jump to its end portion C2/0E32.

so i'll probably just release a patch based on my current code, however lacking in optimization it is.
User avatar
Assassin
Moderator
Moderator
 
Posts: 1195
Joined: Tue Sep 14, 2004 5:10 am

Re: Invincible Guardian

Postby Assassin » Mon Aug 20, 2012 8:08 pm

wow, Atma Weapon isn't even 2-hand compatible. :oops: i'm such a fucking chimp.

i should really fire up the game before writing patches and descriptions. fortunately, the unneeded patch wasn't that complex, and i didn't write a whole Readme yet, just a one paragraph "bug" description.

maybe i'll release this under "miscellaneous" patches, though i might wait to see whether there's any demand for it, before putting a claim on 15 bytes of free space.
User avatar
Assassin
Moderator
Moderator
 
Posts: 1195
Joined: Tue Sep 14, 2004 5:10 am

Re: Invincible Guardian

Postby Imzogelmo » Thu Oct 25, 2012 1:09 pm

I'd personally like to see an Atma Weapon function that is robust enough to handle potentially Gauntlet-compatibiltity (or elemental effects, for that matter). Even though it may not quite count as a bug-fix, it would certainly be a worthy enhancement.

That being said, so many fixes trying to co-exist in the C2 bank makes it quite tricky to work around stuff. Anyone have a self-made update to my "free space used by patches" document?
User avatar
Imzogelmo
Veteran
Veteran
 
Posts: 659
Joined: Wed Sep 08, 2004 4:07 pm
Location: On the spirtual plane

Re: Invincible Guardian

Postby Assassin » Thu Oct 25, 2012 7:26 pm

Imzogelmo wrote:I'd personally like to see an Atma Weapon function that is robust enough to handle potentially Gauntlet-compatibiltity (or elemental effects, for that matter). Even though it may not quite count as a bug-fix, it would certainly be a worthy enhancement.


I did wind up releasing the patch in late August. Glad to hear there's somebody with potential interest in it.

That being said, so many fixes trying to co-exist in the C2 bank makes it quite tricky to work around stuff. Anyone have a self-made update to my "free space used by patches" document?


I'll probably go ahead and make one, since you ignored my last post on updates in the Slick thread. :p
User avatar
Assassin
Moderator
Moderator
 
Posts: 1195
Joined: Tue Sep 14, 2004 5:10 am

Re: Invincible Guardian

Postby Imzogelmo » Thu Oct 25, 2012 7:48 pm

Sorry, I've been under a rock for a long time...
User avatar
Imzogelmo
Veteran
Veteran
 
Posts: 659
Joined: Wed Sep 08, 2004 4:07 pm
Location: On the spirtual plane

Re: Invincible Guardian

Postby Assassin » Sun May 12, 2013 6:09 am

the patches have official releases!

http://drakkhen.jalchavware.com/

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

some background on the bug...

the character version:
http://www14.brinkster.com/assassin17/l ... erflow.htm

how Square mostly-but-not-quite fixed it on GBA, featuring Guardian examples:
http://www14.brinkster.com/assassin17/g ... -gba-1.htm
http://www14.brinkster.com/assassin17/g ... snes-2.htm
User avatar
Assassin
Moderator
Moderator
 
Posts: 1195
Joined: Tue Sep 14, 2004 5:10 am

Re: Invincible Guardian

Postby Warrax » Sat May 18, 2013 2:08 pm

Huge thanks to Drakkhen for releasing the Physical Damage Overflow Fix patch! You rock dude, I've been waiting for that fix for years! That patch and the Ignore-Ignore-Defense patch are very useful (along with FF6MDE), keep up the good work!
User avatar
Warrax
Active User
Active User
 
Posts: 36
Joined: Mon Feb 22, 2010 7:47 pm

Previous

Return to ROM Hacking and Emulation

Who is online

Users browsing this forum: No registered users and 2 guests

cron