Please login or register.

Login with username, password and session length
Advanced search  

News:

Don't be hasty to start your own mod; all our FFT modding projects are greatly understaffed. Find out how you can help in the Recruitment section.

ASM Collective BATTLE.BIN Map  (Read 32183 times)
Pages: [1] 2 3 ... 8
Bad code, beware! The NOPs are coming to eat you!
formerdeathcorps [Posts: 1322]
  • View Profile
  • share
  • [January 06, 2011, 09:09:33 AM]
ASM Collective BATTLE.BIN Map
« on: January 06, 2011, 09:09:33 AM »
This thread is intended to essentially function as a collaborative thread for completely decompiling essential files into the requisite subroutines.  Eventually, we'll put this all on the Wiki.

We need to organize a group ASM decompilation of all of BATTLE.BIN.  There's enough people here who know how to do this and we all know Square's coding is horridly inefficient.  Doing this should open up more space for hacks, and will allow us to finally get a grip on how the AI works.

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.
secondadvent [Posts: 18]
  • View Profile
  • share
  • [January 06, 2011, 09:20:00 AM]
Re: ASM Collective BATTLE.BIN Map
« Reply #1 on: January 06, 2011, 09:20:00 AM »
http://www.filefront.com/17756931/New-Folder.rar/

I should have had a bit more done with this, but i jump around WAY too much :P. Maybe once we get a group together to work on stuff, i will be more motivated to stick with it.

I will continue to work towards cleaning up my data locations file a bit, and updating the pointers to the many sections of the formula data, which i started on but didn't finish :/.
Bad code, beware! The NOPs are coming to eat you!
formerdeathcorps [Posts: 1322]
  • View Profile
  • share
  • [January 06, 2011, 12:45:00 PM]
Re: ASM Collective BATTLE.BIN Map
« Reply #2 on: January 06, 2011, 12:45:00 PM »
Here are my corrections to SA's work.  Anything slashed out means redundant routines by Square.  Underlined is anything stupid that not only takes up space, but removes features from certain formulas.  Bold means bugs unintended by the game.  Since the spoiler is massive and I had to edit my own notes, I'll post the first 0x1F formulas first.

« Last Edit: January 13, 2011, 03:10:27 PM by formerdeathcorps »
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.
Vanya [Posts: 3965]
  • View Profile
  • My Facebook
  • share
  • [January 06, 2011, 10:59:53 PM]
Re: ASM Collective BATTLE.BIN Map
« Reply #3 on: January 06, 2011, 10:59:53 PM »
So 05 is a duplicate of 01?
And what about 00 is that also the same as 01 or is it empty?
0E? Seriously? There HAS got to be a more efficient way of applying a Death status.
Not to mention that no other ability uses this formula, so did it really need to be that complex?
« Last Edit: January 06, 2011, 11:16:25 PM by Vanya »
    • Modding version: Other/Unknown
  • ¯\(°_0)/¯
    Bad code, beware! The NOPs are coming to eat you!
    formerdeathcorps [Posts: 1322]
    • View Profile
    • share
    • [January 06, 2011, 11:50:03 PM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #4 on: January 06, 2011, 11:50:03 PM »
    05 is not only a duplicate of 01, but is missing features, like elemental, and is redundant (Charge is added when it's already considered under physical damage).
    Formula 00 is not actually listed in the offset table, so I presume the game auto-loads 01 if you select 00, but I haven't tested it.
    As for 0E, let's remember that it can apply any status; the reason for the large space is because SQUARE decided to add everything from a standard (MA+X)*Faith% routine, a % Damage routine, and a must cast status or fail routine, while interspersing in special routines that run only when undead.  However, this is still unacceptable coding, considering that a similar routine for Life Drain exists, reverses against the undead, and wastes far less space.

    I'll soon post the next 0x20 formulas or so.

    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.
    pokeytax [Posts: 515]
    • View Profile
    • share
    • [January 07, 2011, 12:13:41 AM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #5 on: January 07, 2011, 12:13:41 AM »
    This is a good plan, I will help out.

    As far as space goes, I don't know how much we have - for all I know my learning hack is in the middle of game code. But a high priority would be rewriting FFTorgASM so that jumps are dynamic - count the lines in allocated space for each hack and write the jumps accordingly. Right now every hack ever written is effectively taking up ASM space...
    Bad code, beware! The NOPs are coming to eat you!
    formerdeathcorps [Posts: 1322]
    • View Profile
    • share
    • [January 10, 2011, 11:04:02 AM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #6 on: January 10, 2011, 11:04:02 AM »
    There was no need to delete Vanya's request for a customizable CT function.  That's actually a very good idea and would save the space of two other functions.  We'll reintroduce the idea, but in spoilers, since this isn't the main focus of this thread:

    Pokeytax, I'm not so sure that's as easy as it sounds; last I remember, Razele and Xifanie said that there wasn't much free memory to begin with.  Pretty much every data file with ASM commands without a Japanese Character map (everything but BATTLE.BIN and WORLD.BIN, I think) have no free space unless you reorganize the file.  Potentially, there are sections of "free space" in unit data, but unless you're going to write in delete routines for entire custom functions, it's not really worth it (nor even predictable what will and won't be zero).
    We currently also a face an understanding problem.  We don't know where in the overall battle loop data is added and specific data erased and rewritten yet (especially involving offsets outside of BATTLE.BIN).  Hence, we don't want to jump stuff to "free space" only to find that it's part of the sound file or something like that.
    Most of our mechanics hacks will involve BATTLE.BIN.  Reorganizing BATTLE.BIN would free up space as well, so I'd rather exhaust that before we think about this.

    Oh, and before I forget, here's some more general locations.  In general, everything after unit RAM is instructions for FFT's AI.  Again, this is RAM, so subtract 0x67000 for BATTLE.BIN offsets.  Note, the following is not tested or documented very well.


    Here's the next 0x20 formulas.  I have finally finished documenting [38].


    Some other bits:
    1) The Truth and Un-Truth formulas [1E/1F] do not have multi-hit routines in them, and likely neither do the ones for Triple Thunder/Holy Breath/Dark Whisper.  However, due to the nature of rerunning the formula, status becomes 6.25% per hit because it is hard-coded into the status application formula (38), rather than 1E/1F.
    2) Stat boosts are read by the game as 0x80 + stat decrements, which is hard-coded into the formulas for stat gain.  A similar trick is used by CT, if anyone noticed on the CT00 formula.
    « Last Edit: January 17, 2011, 09:25:18 PM by formerdeathcorps »
    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.
    Vanya [Posts: 3965]
    • View Profile
    • My Facebook
    • share
    • [January 10, 2011, 11:35:40 PM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #7 on: January 10, 2011, 11:35:40 PM »
    Holy Crap! 38 (100)% is a monster!! There's another that probably could and should be deconstructed for efficiency.

    Seems like 39 & 3A could be merged by using X as an index for selecting which attribute to modify.

    Looks like as long as the zombie check sub-routine in 40 only checks the status it should be easy to edit. And since it doesn't use Y it could probably be made to have the specific status selectable.
    « Last Edit: January 10, 2011, 11:49:43 PM by Vanya »
    • Modding version: Other/Unknown
  • ¯\(°_0)/¯
    Bad code, beware! The NOPs are coming to eat you!
    formerdeathcorps [Posts: 1322]
    • View Profile
    • share
    • [January 12, 2011, 03:34:14 AM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #8 on: January 12, 2011, 03:34:14 AM »
    Here's the last 0x24.


    Note:
    Figured some things out by looking at Pokeytax's notes
    1) +1 Level = 0x80 at 0x10 + 0x192d8c (self) or 0x192d90 (foe)
    2) Switch Team = 0x40 at 0x10 + 0x192d8c (self) or 0x192d90 (foe)
    3) Steal Item = 0x10 at 0x10 + 0x192d8c (self) or 0x192d90 (foe)
    4) Break Item = 0x4 at 0x10 + 0x192d8c (self) or 0x192d90 (foe)
    5) Unit is now murbol = 0x2 at 0x10 + 0x192d8c (self) or 0x192d90 (foe)
    3) Target has golem = 0x1 at 0x10 + 0x192d8c (self) or 0x192d90 (foe)
    6) -1 Level = 0x1 at 0x11 + 0x192d8c (self) or 0x192d90 (foe)

    39 and 3A could easily be merged with X.
    However, changing 40 is nowhere as easy because to load a status effect, you need to load a byte (5 different options) and each byte could have any value from 0-FF.  Hence, you'd need two variables to be able to check for any status.
    « Last Edit: January 13, 2011, 03:10:44 PM by formerdeathcorps »
    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.
    Vanya [Posts: 3965]
    • View Profile
    • My Facebook
    • share
    • [January 12, 2011, 06:16:24 PM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #9 on: January 12, 2011, 06:16:24 PM »
    48, 49, 4B - Perhaps the weapon routine that sets formula 0 for abilities could be used as a base to make these load Y instead of Z if it detects NOT an item ability.

    5A ~ 5D - Now having the address of the subroutine that checks for Dragons, I would definitely encourage some enterprising ASM hacker to consider modding it to check for monster type based on the value of Y. This would conflict with some of the existing Dragon formulas, but those can be changed anyway. I think we can all agree that having a double of Shout that only works on Dragons is redundant. I would immediately suggest an attack formula with a power boost so Hunters can have their XX Killer abilities.

    • Modding version: Other/Unknown
  • ¯\(°_0)/¯
    Bad code, beware! The NOPs are coming to eat you!
    formerdeathcorps [Posts: 1322]
    • View Profile
    • share
    • [January 17, 2011, 11:01:40 AM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #10 on: January 17, 2011, 11:01:40 AM »
    All right: time to post my formula hacks.  Again, this will be done in parts, for it is very large.

    Note, the following assumes you are using my gun damage fix.


    « Last Edit: January 17, 2011, 08:47:25 PM by formerdeathcorps »
    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.
    Vanya [Posts: 3965]
    • View Profile
    • My Facebook
    • share
    • [January 17, 2011, 07:39:01 PM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #11 on: January 17, 2011, 07:39:01 PM »
    what do you mean by "allows procs"?

    And the "functions like 2d" means that thing you mentioned before about it having 100% Status, right?

    • Modding version: Other/Unknown
  • ¯\(°_0)/¯
    Bad code, beware! The NOPs are coming to eat you!
    formerdeathcorps [Posts: 1322]
    • View Profile
    • share
    • [January 17, 2011, 09:37:29 PM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #12 on: January 17, 2011, 09:37:29 PM »
    "Allows procs" was a feature I didn't add to the weapon formulas because I realized weapon attacks would mess it up.  It will, however, be added to all other formulas.  It allows you to use an unused tab to toggle status/spell procs.  I also intend to use another toggle to which will determine whether P/M-EV is used and whether it's classified as physical or magical damage.
    Yes, "functions like 2D" means 100% with All or Nothing, Cancel, or Random and 25% on Separate.  If set to spell procs, they will occur at 100%.

    An example of this will be given tonight.

    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.
    ALL THE THINGS Official Caretaker.
    RavenOfRazgriz [Posts: 3030]
    • View Profile
    • share
    • [January 17, 2011, 10:22:07 PM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #13 on: January 17, 2011, 10:22:07 PM »
    That sounds rather great for consolidating a lot of the damage based formulas and giving them more utility.  Will you also be using those suggestions I gave you for consolidating the various Hit_F(MA+X) formulas, Hit_(MA+X) formulas, (Stat)+(Y) formulas, Hit_(Stat)+/-(Y) formulas, and Hit_F(Stat)+/-(Y) formulas as well?  They'd give full control of all stat and status manipulation centered in a compact 7 formula vs the retardation Square used to get not even half the effect so it seems like a waste not to.

    E: In addition to our discussion before, I recommend letting those stat formulas reference CT as well, so skills that boost the current CT of a unit can be made as well, if possible.  More utility is never bad after all.

    E2: Is the Cheer Up one even needed?  Can an unevadable Hit_(MA+255) even be dodged?  My memory is flaky as to whether the game treats taking Compat out of 100 or out of the 255+ in that situation.

    E3: Actually... couldn't you use a signed byte for the Y value in Hit_(Stat)+(Y) and Hit_F(Stat)+(Y), further reducing it to two formula to control all forms of stat increments and decrements while the two aforementioned Hit_(MA+X) Evade(Y) and Hit_F(MA+X) Evade(Y) controlled all the status related stuff?

    When you get to disassembling it's code more, could the third unused flag be used to determine Knockback?  I know I've bugged you on that about probably 3-4 times now but it's one of those things that could actually be used to create huge strategic implications if it could be used on more than one formula outside of Critical Hits.
    Bad code, beware! The NOPs are coming to eat you!
    formerdeathcorps [Posts: 1322]
    • View Profile
    • share
    • [January 18, 2011, 11:40:16 AM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #14 on: January 18, 2011, 11:40:16 AM »
    E1 and 3: I intend to do all that.
    E2: MA + 255 without evasion can miss between shell/MADEF/worst compatibility/elemental half/null.  If it's "curative", then the first two don't apply.
    Knock Back: I'm not sure.  I already know how to add it, but I'm not sure knockback's the best use.  Maybe a flag to load healing/cancel status checks to help me save more space while allowing any formula to heal or ignore protect/supports?

    Note, my following hack assigns commands to Kanji-space.  This is temporary as I try to fully realize my efficiency gains.  Once all the formulas are coded, I'll likely move this back into the main formula routine space.
    Also, the following hack hard-codes the Work formula to deal 25% damage as recoil as default.  It will be noted, so future hackers may freely change it.
    Lastly, this hack depends on the other consolidation hack for weapon formulas for certain offsets.


    The above disables formula 09 (demi).  Until I upload my fixes for that formula, test this at your own risk.
    « Last Edit: January 23, 2011, 05:17:52 PM by formerdeathcorps »
    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.
    ALL THE THINGS Official Caretaker.
    RavenOfRazgriz [Posts: 3030]
    • View Profile
    • share
    • [January 18, 2011, 06:28:00 PM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #15 on: January 18, 2011, 06:28:00 PM »
    Allowing any formula to heal is as simple as making better use of elements - the only problem in that method is Undead Reverse but I can't imagine that not being something that could be fixed.  Though... are there unused flags in the Inflict Status window?  One could very easily rig one of those to trigger Knockback as well if they exist, though that means any skill that wants to inflict more than just Knockback needs unique Inflict Statuses.  Either that or possibly making use of any empty toggles in the Learn with JP / Learn on Hit / etc boxes?  I'm all for saving as much space as humanly possible, but Knockback needs a huge sum of love too.

    I've thought on it more, and I really think you should make a secondary version of this hack with vanilla's Work Formula if you can since your change costs utility to gain it, and I can easily imagine people wanting the old utility more than the new one.  

    When your notes say "ASM may fail" does that mean it is imperfect and you still need to update it or that it jumps to a backup that covers it when it fails?  Also, you should probably say which checkboxes on Patcher toggle which item.

    E: Is it safe to assume for Steal Equipment / Equipment Break / Mighty Sword, the unused variable will be used to determine which equipment slot is affected?  If so, is it possible to merge this check to incorporate PA / MA / SP / CT / HP / MP / etc. to max out the versatility of all three relevant formula and bomb Formula 2B entirely?  Actually making the game be able to handle what to do if a stat is "stolen" would be another matter, but I'd tell people not to do that for now and call that something for another day since I'd assume they'd all draw from the same X variable.
    Bad code, beware! The NOPs are coming to eat you!
    formerdeathcorps [Posts: 1322]
    • View Profile
    • share
    • [January 18, 2011, 09:32:36 PM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #16 on: January 18, 2011, 09:32:36 PM »
    No, if you convert damage to healing, you still run into evasion, defense/magic defense UP, shell/protect, and reaction triggers.  Hence, I actually can't easily consolidate healing spells with damage spells because of the missing checks on the former.

    The flags used are the first two blank ability flags, the two above "Ranged Weapon".

    E: No, the unused variable does not determine that; the game hard-codes the matter by checking the used ability's number.  Similarly, the game checks ability numbers to determine whether PA/MA/SP is reduced.  Although I can put two hard-code subroutines in one function as long as it's impossible to run both (while having maintenance block both), I won't put the weapon break sequences in the same routine because the formula used will be totally different (the only common check will be maintenance).  I'll likely fuse all the stat/up down formulas (maybe even Demi/Gravi2/Mute) into this instead (and ignore maintenance on HP/MP damage).
    However, we still face the classic problem of insufficient variables for full customization:
    1) Accuracy is (Stat1 + Y)%  (2 Variables)
    2) Effect is +/-(X) to Stat2 (2 more variables...treat X as unsigned% if HP or MP)
    The question now really is this....which variable is most important?  I think Square got it right by setting X (which should include boosts and decrements) and Y as the most important, meaning I should hard-code formulas to use different Stat1 depending on the formula (PA/MA/SP + Y and the faith variants of those...so six possibilities) and rework hard-coding to make Stat2 dependent on modular arithmetic (mod 8 since we have CT/maxHP/maxMP/PA/MA/SP/Faith/Brave) based on the ability slot's number.
    « Last Edit: January 18, 2011, 09:33:18 PM by formerdeathcorps »
    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.
    ALL THE THINGS Official Caretaker.
    RavenOfRazgriz [Posts: 3030]
    • View Profile
    • share
    • [January 18, 2011, 10:42:15 PM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #17 on: January 18, 2011, 10:42:15 PM »
    The flags used are the first two blank ability flags, the two above "Ranged Weapon".

    This doesn't tell which is which...

    No, the unused variable does not determine that; the game hard-codes the matter by checking the used ability's number.  Similarly, the game checks ability numbers to determine whether PA/MA/SP is reduced.  Although I can put two hard-code subroutines in one function as long as it's impossible to run both (while having maintenance block both), I won't put the weapon break sequences in the same routine because the formula used will be totally different (the only common check will be maintenance).  I'll likely fuse all the stat/up down formulas (maybe even Demi/Gravi2/Mute) into this instead (and ignore maintenance on HP/MP damage).

    I see.  So the garbage hardcoding is going to be maintained currently, but a bunch of stuff is going to be crunched together.  It's a wash, I guess, but still seems rather mediocre.

    The question now really is this....which variable is most important?  I think Square got it right by setting X (which should include boosts and decrements) and Y as the most important, meaning I should hard-code formulas to use different Stat1 depending on the formula (PA/MA/SP + Y and the faith variants of those...so six possibilities) and rework hard-coding to make Stat2 dependent on modular arithmetic (mod 8 since we have CT/maxHP/maxMP/PA/MA/SP/Faith/Brave) based on the ability slot's number.

    I see.  I feel it's worth pointing out though that the changes we discussed to the Beaking and Foxbird formulas basically makes this pointless and lets you just gut all the involved hardcoding related to it though, unless I'm missing something.  Though I realized my previous examples for those formula were a bit flawed.  Using Hit_F(MA+X) (Y), where Y controls the stat and operation done and every increment of 16 (0-255) is the flag.  So say, 0-15 is -1-16 PA, 16-31 is -1-16 MA, 127-143 is +1-16 PA, etc., or possibly use a less "even" version that leaves more space allocated for Br/Fa since most PA/MA reductions never break 5 each anyway.  If you can do this, you can then dupe the two formula with a (PA+X) input and again with a (SP+X) input, avoiding all the hardcoding altogether and possibly dedicating it to other things.

    If you don't get what I'm trying to say here, PM me or try to get me on Mibbit, since I think this is probably your best bet for saving fucktons of space and dodging fucktons of hardcoding simultaneously and uses lower net formula slots.
    Vanya [Posts: 3965]
    • View Profile
    • My Facebook
    • share
    • [January 19, 2011, 01:16:12 AM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #18 on: January 19, 2011, 01:16:12 AM »
    No, if you convert damage to healing, you still run into evasion, defense/magic defense UP, shell/protect, and reaction triggers.  Hence, I actually can't easily consolidate healing spells with damage spells because of the missing checks on the former.

    If you had a flag that marked a skill as healing rather than damaging couldn't you use that same flag to bypass said checks with a simple jump in the main formula?

    • Modding version: Other/Unknown
  • ¯\(°_0)/¯
    Bad code, beware! The NOPs are coming to eat you!
    formerdeathcorps [Posts: 1322]
    • View Profile
    • share
    • [January 19, 2011, 10:31:35 AM]
    Re: ASM Collective BATTLE.BIN Map
    « Reply #19 on: January 19, 2011, 10:31:35 AM »
    The upper flag, if flagged, is M-EV and Shell/MADEF.  Otherwise, it defaults to P-EV (works only if evadable is also checked), and will consider Protect/DEFUP/Critical Hits.
    The lower flag, if flagged, allows spell procs.  Otherwise, it defaults to status procs.

    Quote
    If you had a flag that marked a skill as healing rather than damaging couldn't you use that same flag to bypass said checks with a simple jump in the main formula?
    Exactly why I want it.  However, Raven is right; the tactical features wouldn't be too impressive.  Hence why I'm in a quandary.

    Quote
    When your notes say "ASM may fail" does that mean it is imperfect and you still need to update it or that it jumps to a backup that covers it when it fails?
    It means that my tests wrote to Kanji-space but I realized I could improve on Square's coding in the original get MA and Y routine without wasting space, but it's untested (and is missing a few of the safety NOP commands I used when I wrote to Kanji-space), and hence, may screw up.

    Quote
    I see.  So the garbage hardcoding is going to be maintained currently, but a bunch of stuff is going to be crunched together.  It's a wash, I guess, but still seems rather mediocre.
    Already addressed this with you in iRC, but for anyone who doesn't understand my post:
    Stats lowered will be assigned by applying modular arithmetic to the skill numbers.  This means skill numbers {1, 9, 11, 19...} would lower PA, {2, A, 12, 1A...} would lower MA, and so on, through all 8 stats.
    Y influences hit rate.  This can be fixed by FFTP.
    X (fixable by FFTP) influences decrement/boost.  Numbers that are less than 0x80 decrement by X.  Numbers that are higher than 0x80 boost by the amount X - 0x80.  Maintenance will void status if X < 0x80.
    The status checked by hit rate is fixed and will be determined by the formula.  Since there are lots of formulas that boost/lower stats, we can easily spare 9 of them to check for ({PA, MA, SP, 0} + X)*{Faith, 1} OR (100%).  This means that we should be able to free up formula numbers that are usable for totally new formulas (yes, I'll take suggestions for those now).

    To be honest, however, considering how FFT checks for damage, I probably will not lump HP/MP % damage with stat decrements.  It would be too messy.

    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.
    Pages: [1] 2 3 ... 8