• Welcome to Final Fantasy Hacktics. Please login or sign up.
January 26, 2021, 07:22:16 am


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.

Glain's Assorted ASM (Latest: RSM, Skillsets, Jump, ENTD, oh my!)

Started by Glain, October 07, 2011, 07:27:15 pm


October 07, 2011, 07:27:15 pm Last Edit: January 11, 2021, 04:27:59 pm by Glain Reason: Updating with new version
This is my miscellaneous ASM thread, for assorted ASM hacks I've done that don't have a thread, or are scattered throughout miscellaneous threads. Basically I'm starting this thread at Pride's suggestion, as sometimes I'll write some ASM in some other section and it will get buried somewhere in a thread that's hard to find. Also, so I have a place to post some things I've done that don't fit anywhere else.

The latest version of my .XML also comes with (and requires) the latest FFTPatcher suite 0.493, currently available here.


MassHexASM - For encoding ASM commands into PSX-ready binary commands (with the little-endian option), or decoding them from binary commands to ASM instructions. This way you don't have to manually switch byte order like you did with Renegade64. Ideally, the output can just be pasted into a patch file.
Thread: http://ffhacktics.com/smf/index.php?topic=7130.0

LEDecoder - Disassemble binary files into ASM commands, with an option for using little endian byte order. I couldn't find any MIPS disassemblers out there that would let you specify little endian, so I wrote this. (I used this program to disassemble some of the files in the EFFECT subdirectory of the ISO and found ASM commands in there...)
Thread: http://ffhacktics.com/smf/index.php?topic=7758.0

Spreadsheet ASM Hacks

UWEntries - Change which base jobs use which UNIT.BIN and WLDFACE.BIN entries. For changing special characters, not generics.
Thread: http://ffhacktics.com/smf/index.php?topic=7833.0

Gear Level ASM Hacks

Gear Level bugfix - Fixes a bug in FFT where the random gear routine could select extremely low level equipment in certain situations (e.g. Linen Robe in Chapter 4).
Post: http://ffhacktics.com/smf/index.php?topic=6971.msg142849#msg142849

Gear level based on Shop Availability (Story Progression) with override (0x16b)
This is the standard gear level patch (based on shop availability) with an FFTPatcher override.  My latest version.

Gear level based on Shop Availability (Story Progression) - Picks random equipment based on what's currently in the shops instead of the levels of the units. Allows enemy levels to scale with you without their equipment scaling.
Post: http://ffhacktics.com/smf/index.php?topic=6971.msg146276#msg146276

Other ASM Hacks

All formulas apply elemental (v2)
All formulas apply elemental.
Affects HP Damage, MP Damage, HP Healing, and MP Healing.

Ability element takes precedent over weapon element, and will be used unless
the ability's "Weapon Strike" and flag under "Hit Allies" are both checked, in which
case the Ability and Weapon elements will be combined.

Optional: You can specify a multiplier to be applied to damage and/or a separate multiplier for healing. 
The format for the multipliers is 16.16 fixed point (e.g. 1.25 = 00014000).
A multiplier of zero (default) will be ignored.

Swordskill strengthen (v2) - Strengthen should work with ability element for Holy/Dark sword; Dark Sword gains strengthen, status proc, (WP+Y)
This version has a variable flag to decide whether to use PA or MA.

Defense (Equipment grants damage reduction) (v2)
In the item data, this patch interprets Unknown 1 as Physical damage reduction (percentage) and Unknown 2 as Magical damage reduction (percentage).
The damage reduction percentage for each piece of equipment is added to determine the total damage reduction.
An ability's classification as physical or magical is determined by the 'Physical Attack' and 'Magical Attack' AI flags for the ability.
If an ability is flagged with both (this shouldn't happen, really), both damage reduction percentages (physical AND magical) will be applied
(the sum of the two)!

Crystals - Learn from any base job
This hack's for learning from crystals where the enemy base job is different from yours. For example, Night Sword from Gafgarion. You'll need to put the ability to learn in the same slot as the skillset you're learning into. Since this one did appear in another thread, there's more info on it here.

Hide excessive HP/MP recovery
Excessive HP/MP recovery is not displayed.
Post: http://ffhacktics.com/smf/index.php?topic=10535.msg203041#msg203041

Signed Ability Y Values
This allows you to use negative numbers for Y values in formulas. Any Y > 127 is considered as the negative number Y - 256 (e.g. 253 becomes -3). The source for this one is just changing lbu to lb where this particular address (0x801938fa) is read.

Target's Faith in Spell damage calculations becomes XX%

[Half of MP] becomes [No MP Cost]
Might be useful as an enemy-only ability for bosses, to use MP-heavy abilities without depleting their MP.

Require Materia Blade -> Require Item Type X (Default Lance)

Formula Hacks

Formula 3B: Mana Burn/Feedback (v2)
Version 2 of the mana burn hack, which caps damage at MA * Y.  Damages MP and deals equivalent HP damage.

Formula 11: Damage = MA * (WP+Y)

Elemental cancel: Formulas 17,3e,44
This makes formulas [17], [3e], and [44] subject to elemental cancel. Useful if you don't want bosses to be affected.

Formula 54 becomes HealMP_(Y%)

Formula 44: Use HP instead of MP

Fix Reraise Graphic Width
The graphic width for the Reraise status text is slightly too short; this patch fixes that.

Start button skips events, effects, battle and event text, etc.
Thread: http://ffhacktics.com/smf/index.php?topic=11608.0

Speed shortens ability CT
This one uses a curve where CT is affected more at lower speeds, and the effect depends on the CT factor you choose (default 5).  With CT Factor = 5, it begins taking effect at Speed = 5 and ability CT halves by Speed = 10, and would quarter by Speed = 20. 
Basically, for any ability, the CT is affected by a multiplier where ((CT Multiplier) = (CT Factor) / Speed).

Geomancy single ability
Creates a single ability for Geomancy that changes its properties based on the tile the caster is standing on.
Should be used inside a Default skillset.  Ability ID can be specified; default is 0x7E (Pitfall)

JP scroll glitch actual fix (Disable paging on confirm menu)
This patch disables paging up or down while the confirm menu is up on the ability learn screen.  As a result, there is no way to do the JP scroll glitch.

Unit slots backfilled when unit is removed from party
Removing a unit from the party no longer leaves a gap in the party!

Speed up text crawls
Speeds up text crawls significantly.
Text delays longer than a certain amount are changed to that amount.  Default is 2.  Lower is faster.

Switch unit number with L1 and R1 buttons (formation)
Switch unit number with L1 and R1 buttons in the formation screen.  Changes unit order as appropriate.  L1 and R1 still work normally (switching the selected unit) in menus.

Press buttons to win!
Press a button combination (default L1 + Select) to win the current battle.  It needs to be done while the game is processing the battle event conditionals, so between turns, or between a unit moving and acting, or somesuch.  Works even in Bethla Sluice.

Load Formation ignored if unit not in party
Doesn't try to load a unit from the party from the ENTD (Load Formation flag set) if they're not in the party, and instead uses whatever data is in the ENTD for that unit.  You won't normally encounter this scenario, but if it were to happen in the normal game, it would create a messed up unit that would overwrite Ramza when the battle/event was over.

Break out of multi-battle sequences
Break out of multi-battle sequences by pressing a button combination directly after exiting the formation screen.  Default is L1 + R1.
Includes the "Load Formation ignored if unit not in party" patch, because that situation can occur if breaking out of a sequence where a Guest has already left the party.

Equipment duplication glitch fixes
Fixes the equipment duplication glitches that can be triggered from using Best Fit in the shops.

Level down fix
Fixes leveling down to subtract raw stats based on old level instead of new level, so it should subtract the same amount gained in the previous level.  Also fixes level up abilities so that they add the same amount as leveling up via experience gain.

Crits always deal bonus damage
Crit XA bonus minimum is 1 instead of 0.  Maximum is still XA - 1.

Always crit
Always get a critical hit.  Can be useful if you're testing crits or somesuch.

Brave story can point to non-setup events

Enforce level caps
Varies by chapter, like in SCC challenges, but enforced by the game.

Change camera zoom values

Disable Now Loading Message
This hack disables the Now Loading routine entirely, saving the most SCUS space.

Now Loading Routine Rewrite
Rewrites the Now Loading routine to save space.  Includes variables to modify the color of the message.

Expand load and save data
Expands the load and save data to use all 64 blocks of the save file, instead of only 60.

Unit bench (10 extra unit slots)
Add the unit bench, which can hold 10 extra units.  Accessible from the formation screen, with Bench Unit and Unbench Unit menu items.  Units sent to the bench lose EXP and JP.  Joining units will join to the bench if party is full.

----- Latest -----

Jump single ability
Makes an ability function as Jump.  It should be placed in a normal skillset with Default action menu.  Recommended to use the default ability ID, 0x018A Level Jump2.
Range (Both level and vertical) are based on Lancer job level.

Skillset learned ability fix
When determining usable abilities in a skillset, finds the learned abilities based on the job instead of skillset ID.  Fixes an issue where changing the skillset for a generic job to an unused skillset resulted in those abilities all being auto-learned.

Skillset menu hardcoding fix
Skillset menu actions based on action menu instead of being hardcoded to skillset ID.  Fixes some issues resulting from changing action menus on generic skillsets.  Similar to (and mutually exclusive with) Generic Skillset Fix / Skillset Behaviors hack, but based on action menu.

Save between battles after formation screen
Allows saving between battles AFTER the formation screen. 
Loading a save made this way will still load the formation screen, but with the latest changes saved.
Saving before the formation screen still functions as normal.

Gained JP functions as if Gained JP UP was always active

Equippable R/S/M only limited by job innates

All (and only) player human units can find items on moving

Blade Grasp dodge percentage is (Brave * Multiplier) / 1024 and only affects certain weapons

Abandon multiplies evasion by 1024 / Divisor

Require Sword and Require Materia Blade check only first weapon

ENTD Job Level also applies to Job and secondary skillset job

Enhanced ENTD
ENTD can now specify extra parameters for units.  (See description in XML.  Can use extra ENTD slots to modify previous slots.)

Defense Up and Defend status multiply damage by Multiplier / 1024

Stat variation
Base stats for PA and HP vary based on Brave, while MA and MP vary based on Faith.  Starting job stat multipliers also cause further variation.

Base stat decrease
Base speed is 5 for humans and 4 for monsters (instead of 6 and 5, respectively).  Base PA and MA use values of 3.25 and 4 instead of 4 and 5.  Male and female soldier office recruits both have Broad Swords.
  • Modding version: Other/Unknown


Thanks for setting this up!

question about mana burn - is there any way to alter how much MP drain/HP damage it does?


Not currently. I could think about doing something like that though. A damage formula, or percentage, or something of the sort?
  • Modding version: Other/Unknown


For your hacks, could you list other things you've done, like the various Random Equipment Hacks (The original thread contains lots of ASM-talk and is very hard for an ASM-idiot to read and understand what the hacks there actually do, and is buried) and your apps, etc?

Also, were you the one who made a hack so that AI units with <Random> R/S/M chosen would always come into battle with one if chosen?  If so, can you repost that hack here too?  I know -somebody- made that hack and I can't find it.


Yeah, the random gear hack thread is sorta crazy... a little while ago I edited it to put the hacks at the top, and attached an XML at the bottom of the post. I figured the patch that does gear level based on shop availability was the one to feature, as once that became available, the other patch options didn't seem to see much use.

Other than that, I could link to the various threads for the other hacks/apps from here, I suppose?

Not sure about the R/S/M thing; I don't think that hack was me. Sounds interesting, actually, because I think I have seen AI come in with nothing on one or more of those slots even though they were set to Random.
  • Modding version: Other/Unknown


Quote from: Glain on October 26, 2011, 08:04:17 pm
Yeah, the random gear hack thread is sorta crazy... a little while ago I edited it to put the hacks at the top, and attached an XML at the bottom of the post. I figured the patch that does gear level based on shop availability was the one to feature, as once that became available, the other patch options didn't seem to see much use.

Honestly - I can't tell how to use most of them because with all the shit going on it's impossible to tell what they do.  You have one spot where you try to tl;dr explain them but the names you gave them are too vague to matter and the descriptions are equally so.  Putting them here with better names + better descriptions would be incredibly appreciated.  The Story Progression one is used the most in large part because it's the easiest to understand at a glance, the others aren't even getting a fair shot.

Quote from: Glain on October 26, 2011, 08:04:17 pmNot sure about the R/S/M thing; I don't think that hack was me. Sounds interesting, actually, because I think I have seen AI come in with nothing on one or more of those slots even though they were set to Random.

Maybe it was Pokeytax then?

I could've sworn I saw that ASM at some point.  Maybe I'm insane.


All right, I went through and added the links to my apps/hacks/what have you. Not sure I did a better job tl;dr'ing the gear level ones, but at least they're more succinct than in the thread.
  • Modding version: Other/Unknown


Requesting this be added to the "important links" list so it doesn't get lost in the mix. I think some of Glains utilities are in there already but in different threads.


Does your Formula 11 becomes MA*(WP+Y) hack accept Attack UP / Defense UP / Protect or Magic AttackUP / Magic DefendUP / Shell?  Is there a way to change what it accepts?

I'm going through flagging my AI for a few skills using it, and you don't list whether the skills using the formula are treated as physical or magical, just how to change which evasion it accepts.


I know we talked about this on IRC, but as a general answer, it should be magic damage and be subject to everything that entails. I used formula [4e] as a base and it uses the same magic damage calculation routine, which should take all that into account, or at least I assumed it did. I should probably test that.
  • Modding version: Other/Unknown


According to the notes, jal 0x00188964 leads to a section that calculates using magic damage.

00188964: 27bdffe8 addiu r29,r29,0xffe8
00188968: afbf0010 sw r31,0x0010(r29)
0018896c: 0c0617ff jal 0x00185ffc      Elemental Strenghten
00188970: 00000000 nop            
00188974: 0c0621d1 jal 0x00188744      Magical Support/Status/Compat
00188978: 00000000 nop
0018897c: 0c0621df jal 0x0018877c      Elemental XA * YA
00188980: 00000000 nop
00188984: 14400003 bne r2,r0,0x00188994      
00188988: 00000000 nop
0018898c: 0c0621f1 jal 0x001887c4      Elemental Absorb/Status
00188990: 00000000 nop
00188994: 8fbf0010 lw r31,0x0010(r29)
00188998: 27bd0018 addiu r29,r29,0x0018
0018899c: 03e00008 jr r31
001889a0: 00000000 nop

00188744: 27bdffe8 addiu r29,r29,0xffe8      
00188748: afbf0010 sw r31,0x0010(r29)      
0018874c: 0c061881 jal 0x00186204      Magic Attack Up
00188750: 00000000 nop            
00188754: 0c0618c7 jal 0x0018631c      Magic Defense Up
00188758: 00000000 nop            
0018875c: 0c061918 jal 0x00186460      Target's Status Affecting XA (Magical)
00188760: 00000000 nop            
00188764: 0c061259 jal 0x00184964      Zodiac Compat
00188768: 00000000 nop            
0018876c: 8fbf0010 lw r31,0x0010(r29)      
00188770: 27bd0018 addiu r29,r29,0x0018      
00188774: 03e00008 jr r31         
00188778: 00000000 nop   

  • Modding version: PSX
Check out my ASM thread. Who doesn't like hax?


Hey Glain, you're smart.  How would you like to tackle changing which Reactions are tied to which triggers?  I've got some basic stuff I'd /like/ but don't need on a life-or-death level I'd make use of in Journey of the Five if you're interested:

Brave Up - Share the same trigger as Faith Up.  (Responds to basically anything that happens to the unit.)
Dragon Spirit, Sunken state - Share the same trigger as Regenerator, Caution.  (Responds to anything that inflicts 1+ points of damage.)
Counter Tackle - Share the same trigger as Counter Flood.  (Responds to anything with the 'Counter Flood' flag set.)

Yes, this'd leave just Counter and Blade Grasp on the Countergrasp flag - truly only Countergrasp now!

And something a bit more bold...

Making "copies" of Counter Tackle in unused Reaction slots / Reaction slots I'm no longer making use of.  (By "copies", I mean, make a Reaction with the same properties as Counter Tackle that responds with a skill of my choosing.  Possibly even make an inverted version of this that has the skill used on the caster instead of the target.)  Mostly asking if you'd be interested in this one because it's the easiest way to make "new" Reactions.  If you are, I can give you more details on what I'd like, but feel free to tell me off!


I could look at making a patch to change which flags are for which counter abilities. I'm not promising results or anything, but I may look into it. It sounds interesting.

I was hoping, when I looked into the question of "Where does Counter Tackle figure out which ability to counter with?" that it would be something associated with the ability, but from what I saw of the code, it might be hardcoded to ability ID, which would make the second part a lot harder.

(Hardcoded as in, Is my Ability ID [Counter Tackle's Ability ID]? If so, use [Dash's Ability ID])
  • Modding version: Other/Unknown


Swordskill strengthen - I do hope you mean they gain /everything/, and not /just/ Strengthen.  It'd be pretty derpy if it didn't accept Half/Weak/Cancel/Absorb.  If it is /everything/, this is 90% of an ASM hack I need.  By "Dark Sword", I assume you mean the formula for both Dark Sword and Night Sword.  Would it be possible to get a variation of this hack where the Dark Sword and Night Sword formula are Abs[HP/MP]_(PA*(WP+Y))/2?  That'd be perfect for my needs.


Yes, it seems to be everything (Half/Weak/Cancel/Absorb should all work). And yes, I was referring to the skillset Dark Sword, so that's Dark/Night sword, specifically formulas [2f] and [30].

Regarding "halving" the damage: It seems what the formulas all do is: Load in two factors, then call the damage routine to multiply them. That damage routine is apparently shared by just about every formula (the multiplication to addition change would never have been so easy if it wasn't). You can see it'd be a bit problematic to try to put a division by 2 in there at the end as it would affect every single formula.

So basically what I'm saying is that it'd be a lot easier/better to do [(PA div 2) * (WP+Y)] or [PA * ((WP+Y) div 2)] where div is integer division. It just has a lot more error from truncating decimals than [(PA * (WP+Y)) div 2] does.

EDIT: I can probably just put it in what I have, but I can't think of an easy way to configure whether or not you want Dark/Night sword to be halved, so it'd probably have to be a separate hack.
  • Modding version: Other/Unknown


You could use X=0 normal, X=1 halved to try and combine both into one hack, Glain.  If you wanted to get ambitious, you could also beef up the Mighty Sword formula (2E) to also accept all this shit and be halved or not halved by X=0 and X=1, since that formula is also NS and likely no-Element as well.  Then you could toss in your MA*WP+Y edit as Formula 18 (Seriously, no one edits Formula 18, man) under the same stuff and have the super obscene all-in-one Swordskill Formula Patch of Awesome.  I'd also say to divide the XA and not the WP, since you generally want the weapon scaling more than the PA scaling.

/total overachiever.


I've got it as (PA / 2^X) * (WP+Y) now. Integer division, of course. Updated the main post with it.

Bah, formula [2e]. Psh. Maybe later or something. It's weird.

I can't centralize all the formulas unless I can introduce another variable, not X or Y since they're both already used; I need a parameter to tell my function which formula we're on (should we be absorbing HP, MP, etc).
  • Modding version: Other/Unknown


What about the register that holds the "Z" value for Items?  I imagine that's not being used for anything at the time an ability is cast. Unless the "Z" is really either X or Y and Melonhead just labeled it as Z because you can't affect it through a formula, in which case, derp.  The game must have a way of telling which Formula is which.  I don't think FDC and I ever had an issue when designing aspects of his Formula Hack when we needed to see which Formula was being called, but hell if I remember exactly where that info was stored, either.

The other alternative is to topload everything onto Y.  0-7 is PA/1, +0-7 Y, 8-15 is PA/2, +0-7 Y, etc., then use X to determine which formula it is.  Bit ugly, but it does the job.

Still, this suits everything I personally need it for perfectly.  I just like things to exceed what I need them for because I know that either I'll think of a use for the things I didn't think I'd need, or that someone else definitely will use it, at least in a cast like this.  Very much thanks for what you've done so far with it, in any case.