• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
April 28, 2024, 08:48:59 am

Formula Hacking help please!

Started by Tigerspike, April 16, 2010, 12:45:45 pm

Tigerspike

So, I've been toying around with the idea of making my own patch for the game, but I've run into a snag.  I want to create a focus type skill as a Mage's answer to accumulate.  Would I need to hack an ability formula to be +MA_(Y)NS so that I can create this, or would I utilize the "055 Magic Song" effect in conjunction with a 100% formula?

To be honest, I would prefer a formula hack, as that would allow me the ability to alter the Y variable (and as a lesson on formula hacking).  If anyone could help me with that, I would be very grateful.

Thanks!

EDIT: I guess the only way to achieve the effect that I want right now is to alter the Magic Song ability, since the effect is just the graphic.  :oops:
Oh come now. That doesn't even make sense. How can flimsy paper possibly beat the raw density of stone?

formerdeathcorps

You can use magic song for now.  The formula hack you are asking for isn't hard to do in theory; all you'd need to do is co-opt the +PA_(Y) NS or +SP_(Y) NS formulas and change 3600 (PA) or 3800 (SP) to 3700 (assuming you don't want PA or SP modification in your game).  For more information on what numbers reference what stats, please see: http://www.ffhacktics.com/wiki/Formula_Hacking.  The problem is in actually finding where BATTLE.BIN actually references the formulas desired.

The crude way would be to search BATTLE.BIN's offsets starting from around 11A000 to around 122000 (where most of the weapon formulas are) for every instance of 3600 or 3800 until you find the correct formula.  Naturally, the order in FFTPatcher of the damage formulas is not the actual order of the formulas themselves.  You'd still need to know ASM or at least be able to recognize some patterns to find the desired formula, though.
The other way to find the desired formula to replace is to use the formula you want to replace in battle, find its location on the disk with your debugger, and then use ASM to modify your formula.  Zodiac had more details in his thread: viewtopic.php?f=8&t=953.
The destruction of the will is the rape of the mind.
The dogmas of every era are nothing but the fantasies of those in power; their dreams are our waking nightmares.

Tigerspike

Wow, thanks formerdeathcorps!  

That helps tremendously.  :D  I think I'll try to over-write +Brave_(Y) NS, since I would still have Praise.
Oh come now. That doesn't even make sense. How can flimsy paper possibly beat the raw density of stone?

formerdeathcorps

You still have quite a lot of trial and error unless you know ASM.

From 11A000 in BATTLE.BIN, you want to find the following:
24 00 22 A2 08 00 02 34 25 00 22 A2 58 00 02 92
24 00 02 92
24 00 40 10 FF 00
(*) 24 00 04 34 64 ED 04 0C
24 00 42 90
24 00 63 90
24 00 44 90 33 78 01 0C
(*) 24 00 A3 90 19 80 04 3C (I think this may appear twice)
24 00 40 14
24 00 40 10 (found after the 24 00 40 10 FF 00)

In each case, change 24 to 37 individually and test each with cheer up.  If it doesn't add MA, move on to the next one after changing 37 back to 24.  I'd test the starred ones first because I suspect those are the likeliest ones.
The destruction of the will is the rape of the mind.
The dogmas of every era are nothing but the fantasies of those in power; their dreams are our waking nightmares.

Tigerspike

Thanks again, and yes, I have quite a bit to learn in terms of ASM hacking, but the info you gave me helped set me in the right direction.  Even with my limited knowledge, I figured out the 24 for brave (thanks again for pointing me to the right list).  I learn best by trial and error, so I was going to try all instances of 24, but I will try out those instances you've starred first.  

My only real issue right now is finding time--I have two kids that don't give me a lot of free time (but that's okay, because I love them).
Oh come now. That doesn't even make sense. How can flimsy paper possibly beat the raw density of stone?

Tigerspike

Alright, so I've finally had a chance to try out some of the entries that you suggested.  No luck on getting it to add MA, but here are the results so far:

24 00 22 A2 08 00 02 34 25 00 22 A2 58 00 02 92 --Nothing
24 00 02 92 --Caused every unit to gain 1 Br each turn.
24 00 40 10 FF 00 --Nothing
24 00 04 34 64 ED 04 0C --Nothing
24 00 42 90 --found it twice at 0x11EF10 (nothing) and 0x1253A0 (still gain Br, but turn into a chicken with both Cheer Up and Praise)
24 00 63 90 --Nothing
24 00 44 90 33 78 01 0C --Nothing
24 00 A3 90 19 80 04 3C --Nothing at either entry.

I'll try the other two sometime later, since I found that there are a total of 27 entries that match those, 11 of which are after 11A000.
Oh come now. That doesn't even make sense. How can flimsy paper possibly beat the raw density of stone?

formerdeathcorps

Thank you.  You just discovered where chicken triggers brave gain.  Now I can make it so chickened units gain 4 brave per turn!
The destruction of the will is the rape of the mind.
The dogmas of every era are nothing but the fantasies of those in power; their dreams are our waking nightmares.

Xifanie

Don't play with stuff when you have no idea what you're playing with. You can very easily screw up the game like that.
If you want to change brave so badly it's:
BATTLE.BIN
0x0011C290
XX000334
Change XX to whatever you like + 0x80
Example +4 brave is 0x84

Even there I'm not sure this is completely flawless, I just know that it doesn't seem to affect anything else. Oh and this affects the graphical display too.
  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

Tigerspike

I've been careful to maintain an unedited copy of the BATTLE.BIN, so even if I were to screw something up, I could replace my mistake with the original file.  I'm not really wanting to increase the amount of a brave gain ability, but instead change Cheer Up's formula from +Brave_(Y) NS into  +MA_(Y) NS.  I can increase the amount of brave gained through using FFTPatcher, I was hoping to create a formula so that I don't have to overwrite Magic Song.
Oh come now. That doesn't even make sense. How can flimsy paper possibly beat the raw density of stone?

Pickle Girl Fanboy

Why not use save states?  You don't have to insert them back into the ISO, they aren't permanent, you can duplicate them by changing their name each time you make a change (and keep an unaltered safe copy around that you can open up when the game freezes), and it doesn't take much time to use.

Just take some hexes from around 0x11a000 in battle.bin and search for it in a save state.

Tigerspike

Thanks for the suggestion, I think that I might try that.
Oh come now. That doesn't even make sense. How can flimsy paper possibly beat the raw density of stone?

formerdeathcorps

I'm willing to bet one of those offsets also code for brave up.  That would be fun to test.

The hex fix I used in my recent update of my patch is the offset Zodiac found.  It normally only affects chicken, but if you change 2400 to something else, you'll end up the game reasoning that if your MA (just as an example) < 10, then brave should be increased by 1.  That's how Tigerspike got his strange results when he changed 2400 to something else.
The destruction of the will is the rape of the mind.
The dogmas of every era are nothing but the fantasies of those in power; their dreams are our waking nightmares.

formerdeathcorps

OK, found the faith up offset.

Faith Up: x125124; you can change what stat it adds at x125164.
The destruction of the will is the rape of the mind.
The dogmas of every era are nothing but the fantasies of those in power; their dreams are our waking nightmares.

philsov

Quote from: "formerdeathcorps"OK, found the faith up offset.

Faith Up: x125124; you can change what stat it adds at x125164.

omg, ty

@Zodiac, you too <3
Just another rebel plotting rebellion.

Tigerspike

Sweet, thanks for all the help/work you've put into my request!
Oh come now. That doesn't even make sense. How can flimsy paper possibly beat the raw density of stone?

formerdeathcorps

I'm not nearly done yet.  [s:1krt6oad](This post is still in progress.  I'll post more as I find out more).[/s:1krt6oad]  It's more complicated than I initially realized; all the stat boost reactions are bundled up together.  If you want BATTLE.BIN offsets, subtract 67000 in hex from the offsets given.

0018c064: 34100001 ori r16,r0,0x0001
0018c068: 34060032 ori r6,r0,0x0032
0018c06c: 3c058019 lui r5,0x8019
0018c070: 8ca52d98 lw r5,0x2d98(r5)
0018c074: 3c028019 lui r2,0x8019
0018c078: 8c422d90 lw r2,0x2d90(r2)
0018c07c: 34070001 ori r7,r0,0x0001
0018c080: a4b10028 sh r17,0x0028(r5)
0018c084: a4a3002c sh r3,0x002c(r5)
0018c088: 90440012 lbu r4,0x0012(r2)
0018c08c: 0c06355c jal 0x0018d570
0018c090: 24a50032 addiu r5,r5,0x0032
0018c094: 02028025 or r16,r16,r2
0018c098: 340600ff ori r6,r0,0x00ff
0018c09c: 00003821 addu r7,r0,r0
0018c0a0: 3c028019 lui r2,0x8019
0018c0a4: 8c422d90 lw r2,0x2d90(r2)
0018c0a8: 3c058019 lui r5,0x8019
0018c0ac: 8ca52d98 lw r5,0x2d98(r5)
0018c0b0: 90440013 lbu r4,0x0013(r2)
0018c0b4: 0c06355c jal 0x0018d570
0018c0b8: 24a50039 addiu r5,r5,0x0039
0018c0bc: 02028025 or r16,r16,r2
0018c0c0: 34060063 ori r6,r0,0x0063
0018c0c4: 34070001 ori r7,r0,0x0001
0018c0c8: 3c028019 lui r2,0x8019
0018c0cc: 8c422d90 lw r2,0x2d90(r2)
0018c0d0: 3c058019 lui r5,0x8019
0018c0d4: 8ca52d98 lw r5,0x2d98(r5)
0018c0d8: 90440014 lbu r4,0x0014(r2)
0018c0dc: 0c06355c jal 0x0018d570
0018c0e0: 24a50030 addiu r5,r5,0x0030
0018c0e4: 02028025 or r16,r16,r2
0018c0e8: 34060063 ori r6,r0,0x0063
0018c0ec: 34070001 ori r7,r0,0x0001
0018c0f0: 3c028019 lui r2,0x8019
0018c0f4: 8c422d90 lw r2,0x2d90(r2)
0018c0f8: 3c058019 lui r5,0x8019
0018c0fc: 8ca52d98 lw r5,0x2d98(r5)
0018c100: 90440015 lbu r4,0x0015(r2)
0018c104: 0c06355c jal 0x0018d570
0018c108: 24a50031 addiu r5,r5,0x0031
0018c10c: 02028025 or r16,r16,r2
0018c110: 34060064 ori r6,r0,0x0064
0018c114: 3c038019 lui r3,0x8019
0018c118: 8c632d98 lw r3,0x2d98(r3)
0018c11c: 3c028019 lui r2,0x8019
0018c120: 8c422d90 lw r2,0x2d90(r2)
0018c124: 24650024 addiu r5,r3,0x0024 (change 24 to change the stat added by brave up)
0018c128: 90670182 lbu r7,0x0182(r3)
0018c12c: 90440016 lbu r4,0x0016(r2)
0018c130: 000739c2 srl r7,r7,0x07
0018c134: 00073823 subu r7,r0,r7
0018c138: 0c06355c jal 0x0018d570
0018c13c: 30e7000a andi r7,r7,0x000a
0018c140: 02028025 or r16,r16,r2
0018c144: 34060064 ori r6,r0,0x0064
0018c148: 00003821 addu r7,r0,r0
0018c14c: 3c028019 lui r2,0x8019
0018c150: 8c422d90 lw r2,0x2d90(r2)
0018c154: 3c058019 lui r5,0x8019
0018c158: 8ca52d98 lw r5,0x2d98(r5)
0018c15c: 90440017 lbu r4,0x0017(r2)
0018c160: 0c06355c jal 0x0018d570
0018c164: 24a50026 addiu r5,r5,0x0026 (change 26 to change the stat boosted by faith up)
None of the above has anything to do with the actual triggering of any attack.  Note that x80192d98 is the location where player stats are stored.  I'd like to say that addiu r5, r5, x00XX always corresponds to a stat, but as we all know, x0032 is original speed (not speed), x0039 is undefined, x0030 is original PA (not PA), and x0031 is original MA (not MA).  Similarly, it seems that r6 corresponds to the cap for a given stat (50 for original speed, 255 for x0039, 99 for original PA/MA, and 100 for faith/brave) and r7 corresponds to the minimum (1 for PA/MA/SP and x0039, 0 for Brave/Faith).


0018d570: 90a80000 lbu r8,0x0000(r5)
0018d574: 30c300ff andi r3,r6,0x00ff
0018d578: 340200ff ori r2,r0,0x00ff
0018d57c: 14620005 bne r3,r2,0x0018d594
0018d580: 3089007f andi r9,r4,0x007f
0018d584: 3402007f ori r2,r0,0x007f
0018d588: 15220003 bne r9,r2,0x0018d598
0018d58c: 30820080 andi r2,r4,0x0080
0018d590: 340900ff ori r9,r0,0x00ff
0018d594: 30820080 andi r2,r4,0x0080
0018d598: 10400003 beq r2,r0,0x0018d5a8
0018d59c: 00000000 nop
0018d5a0: 0806356b j 0x0018d5ac
0018d5a4: 01094021 addu r8,r8,r9
0018d5a8: 01094023 subu r8,r8,r9
0018d5ac: 30e700ff andi r7,r7,0x00ff
0018d5b0: 0107102a slt r2,r8,r7
0018d5b4: 10400002 beq r2,r0,0x0018d5c0
0018d5b8: 30c600ff andi r6,r6,0x00ff
0018d5bc: 00e04021 addu r8,r7,r0
0018d5c0: 00c8102a slt r2,r6,r8
0018d5c4: 10400002 beq r2,r0,0x0018d5d0
0018d5c8: 00000000 nop
0018d5cc: 00c04021 addu r8,r6,r0
0018d5d0: 90a20000 lbu r2,0x0000(r5)
0018d5d4: 00000000 nop
0018d5d8: 15020003 bne r8,r2,0x0018d5e8
0018d5dc: 34020001 ori r2,r0,0x0001
0018d5e0: 08063586 j 0x0018d618
0018d5e4: 00001021 addu r2,r0,r0
0018d5e8: 14e2000a bne r7,r2,0x0018d614
0018d5ec: a0a80000 sb r8,0x0000(r5)
0018d5f0: 90a20000 lbu r2,0x0000(r5)
0018d5f4: 90a30003 lbu r3,0x0003(r5)
0018d5f8: 00000000 nop
0018d5fc: 00434021 addu r8,r2,r3
0018d600: 00c8102a slt r2,r6,r8
0018d604: 10400002 beq r2,r0,0x0018d610
0018d608: 00000000 nop
0018d60c: 00c04021 addu r8,r6,r0
0018d610: a0a80006 sb r8,0x0006(r5)
0018d614: 34020001 ori r2,r0,0x0001
0018d618: 03e00008 jr r31
Fairly self-contained (jr r31 loops back to Part I).  All I see is a mess of register comparisons and jumps, probably checks for maximums and minimums.  Definitely not where Faith Up is adding 3 faith.  This means the investigation goes into even more uncharted waters into areas where it jumps back either to x180XXX or x19eYYY.  Either way, this seems to be wandering further and further away from my goal.


Finally found it!  By Zodiac's example, you want to change 83 into XX where, XX = brave/faith gain + 80.  The offsets are at 124090 for Brave Up and 1240A4 for Faith Up.
Pickle, the best debugging method is to actually use the debugger + save states/breakpoints.
The destruction of the will is the rape of the mind.
The dogmas of every era are nothing but the fantasies of those in power; their dreams are our waking nightmares.

Tigerspike

Sorry that it took me such a long time to get back this topic.  Things are finally settling down enough to do serious work on this, although reading the ASM stuff is a good reminder how much I have to catch up on in terms of understanding what exactly to do.  I used Tiny Hexer to help me generate a list of every instance of 24, and it gave me a huge list.  I tried using the debugger, and to be quite honest, I have no idea what I was looking at when using it.  If you're still willing to help me out, FDC, I would really appreciate it.
Oh come now. That doesn't even make sense. How can flimsy paper possibly beat the raw density of stone?


Tigerspike

Including the stuff only after 0x11a000, there are nearly 1544 instances of 24 (including all instances increases it to 2997).  Just to be certain, I had Tiny Hexer generate a list based soley on the occurance of 24 in the battle.bin, that produced 1525 instances.  I'm sure if I double check the list that it generated I can eliminate a few lines (such as the ones generated by formerdeathcorps), although it is still lengthy.
Oh come now. That doesn't even make sense. How can flimsy paper possibly beat the raw density of stone?

Pickle Girl Fanboy

That's pretty good.  About 8 hours of work.  I might try it tomorrow.

I did something like this with 2,300 hits, and it took me about 6 hours to find it.

F4, file save as, click to emulator, load save state,...  I had dreams about it for a few weeks afterwards.  Nothing like waking up from a dream where you're sitting in front of a computer.


Edit

I'm working on this, via save state.  If anyone wants to help me do it this way, please download the patch, savestate, and search log in search.7z and post a reply.  We can divide up the save state and search our assigned areas.

And tigerspike, there's a chance that my method might not work (the game doesn't load entire files all the time - it could just be a tiny chunk of battle.bin in this save state, and with almost 10,000 hits it'll take a month to go through all of it), so please continue with your method, which I believe is exporting, modifying, and importing battle.bin via cdmage and testing it.  If you see anything you like in my method, feel free to adapt it to yours.


Edit, Friday, June 18, 0916 Hours

I got Cheer Up to increase MA instead of Brave in a save state, but I can't find the same data in battle.bin.  So, I need you guys to flesh this out with your asm magic.
Download search.7z (it's an archive), extract the files inside with 7zip (found here: http://www.7-zip.org/ ), and follow the instructions to replicate my findings.

Things I thought while searching last night/this morning:

What exactly triggers Brave Up?   I know that Throw Stone doesn't trigger it.
I want to turn Brave Up into "Take HP Damage: Restore MP In Amount Of HP Damage, But Do Not Exceed Max MP".
Finding the triggers will take care of the "Take HP Damage:" part.
You guys already provided the "Restore MP".  I could make it restore a set amount of MP, which is fine if there's no room, but it doesn't take care of the "But Do Not Exceed Max MP" part.

I looked at Formula Hacking on the Wiki, and I think I could find a lot of hardcoded stuff, like the Equipment Slots hardcoded to the Break and Steal ability slots.