• Welcome to Final Fantasy Hacktics. Please login or sign up.
 

ASM Requests

Started by The Damned, October 29, 2014, 09:16:45 pm

stuminator

This is pretty much it, but how would I adjust the offsets to have multiple copies of the formula each checking for a different status?

<Location file="BATTLE_BIN" offset="128674">B89F1580<!--Formula 19--></Location>
<Location file="BATTLE_BIN" offset="F2FB8">

I know how to change the first part, the offset 128674, by looking it up from the formula table, but I'm not sure how I'd need to adjust the F2FB8. 
  • Modding version: PSX
  • Discord username: stuminator

nitwit

September 23, 2021, 06:48:53 pm #361 Last Edit: September 23, 2021, 11:47:06 pm by nitwit
Quote from: stuminator on September 23, 2021, 06:06:21 pmThis is pretty much it, but how would I adjust the offsets to have multiple copies of the formula each checking for a different status?

<Location file="BATTLE_BIN" offset="128674">B89F1580<!--Formula 19--></Location>
<Location file="BATTLE_BIN" offset="F2FB8">

I know how to change the first part, the offset 128674, by looking it up from the formula table, but I'm not sure how I'd need to adjust the F2FB8. 
You understand that you need two bytes to select the status group and a specific status, and you found two free bytes in existing data. That's very good.

You should get in the discord and get help there, but basically you need to either:
  • Jump to free space and do everything you need there, or...
  • Consolidate one or more formulas adjacent to this one into a single formula, with their formula ID being used to conditionally branch/jump to where the specifics of each are handled.
The latter method could allow a lot more flexibility if the adjacent formulas have much in common with it.

You need to do this because you need some space to write the code to check the byte and bit selected. I'm not sure if the ideal way to do that is with the assembly equivalent of a for or while loop, or if it will Just Work™ if you copy the bytes over. I guess look at what parameters the status proc subroutine call used in 40 uses, or how it works. I'm probably wrong about one or more parts of actually implementing the checks and branches.

If the formulas pointer table requires that sequential formulas have addresses that are also sequential, add a nop in front of the formula and have the earlier one point to it, and the later one point to the actual first line of code. Do the same for any formula calls made elsewhere for the ones you consolidate.

My reasoning for this is that it keeps hardcoding based on formula ID done elsewhere intact.

Looking at Routine Locations, here are the adjacent formulas:
0018a02c - 0018a084: 3F Hit (SP+X)%
0018a088 - 0018a110: 40 Undead: Hit (SP+X)%
0018a114 - 0018a178: 41 Hit (MA+X)%

3F and 40 are the same formula, 40 has the Undead conditional. By incorporating them you'd free up a lot of space for anything else you want to do.

You could incorporate 41 as well, just be aware that anything you do to these three formulas will affect everything that calls them, and you'd have to manually adjust every instance of where they are called. 41 is called in a few places, but I don't think 40 is called ever and I think 3F is only called in 40. By that I mean that every jal 0x0018a114 would need to be replaced with jal 0x0018a02c if you consolidate 41 with 40 and 3F.

Might be a good idea to contact the author of that hack and show him my two posts in reply to you, since he may be interested in something that is an improvement to what he made.
  • Modding version: PSX

stuminator

I've been working on my own request I made earlier and believe I've figured it out. 

<Patch name="Formula 3F Hit (SP+X)%, can require target to have certain status">
  <Description>
    Overwrites the space of the existing 3F and 40 formula routines.  Also adds physical evasion if evadable is checked.
    Allows you to require an already present status on the target as follows:
    Fill in the Y value in FFTPatcher with 88, 89, 90, 91, or 92 depending on which group the status is in, and check the element field in FFTPatcher corresponding to the status's position in the group.
    If you want the ability to work on any target without requiring an existing status, leave Y=0.  Don't use values for Y other than the ones listed here!
    Remember that the existing Seal Evil ability will need to be updated to the new format to work (Formula 3F, Y=88, element=Wind), and don't assign formula 40 to anything.
    Group 88
      0x80
      0x40 Crystal
      0x20 Dead
      0x10 Undead
      0x08 Charging
      0x04 Jump
      0x02 Defending
      0x01 Performing
    Group 89
      0x80 Petrify
      0x40 Invite
      0x20 Darkness
      0x10 Confusion
      0x08 Silence
      0x04 Blood Suck
      0x02 Cursed
      0x01 Treasure
    Group 90
      0x80 Oil
      0x40 Float
      0x20 Reraise
      0x10 Transparent
      0x08 Berserk
      0x04 Chicken
      0x02 Frog
      0x01 Critical
    Group 91
      0x80 Poison
      0x40 Regen
      0x20 Protect
      0x10 Shell
      0x08 Haste
      0x04 Slow
      0x02 Stop
      0x01 Wall
    Group 92
      0x80 Faith
      0x40 Innocent
      0x20 Charm
      0x10 Sleep
      0x08 Don't Move
      0x04 Don't Act
      0x02 Reflect
      0x01 Death Sentence
    Elements:
      0x80 Fire
      0x40 Lightning
      0x20 Ice
      0x10 Wind
      0x08 Earth
      0x04 Water
      0x02 Holy
      0x01 Dark
    For example, to require that the target be in critical, Y=90 and check the Dark element.
  </Description>
    <Location file="BATTLE_BIN" offset="12302C">
      E8FFBD27
      1000BFAF
      4421060C
      00000000
      23004014
      00000000
      8C17060C
      00000000
      7E21060C
      00000000
      6719060C
      00000000
      441D060C
      00000000
      1980023C
      902D428C
      00000000
      00004290
      00000000
      14004010
      00000000
      19800A3C
      982D4B8D
      FA384991
      F7384D91
      0C002011
      00000000
      21086901
      00002590
      00000000
      2418AD00
      00000000
      05006014
      00000000
      C310060C
      00000000
      33280608
      00000000
      C91F060C
      00000000
      1000BF8F
      1800BD27
      0800E003
      00000000
    </Location>
  </Patch>

All my tests with this have worked, hopefully others will find this useful and not have any problems implementing it.  A big thanks to Emmy for this formula that I used as a template to help me figure out how to code my own formula:

<Patch name="Formula 31 - Physical elemental damage, 2x damage + status inflict if unit is affected by indexed status">
    <Description>Requires physical elemental inner routine. Use x = 88, 89, 90, 91, 92 for status effect group 1, 2, 3, 4, 5 respectively.  Ability status effect byte is the status you want the ability to check for and inflict (on the group indexed by x)</Description>
    <Location file="BATTLE_BIN" offset="122cd0">
E8FFBD27
1000BFAF
4421060C
00000000
1A004014
00000000
1B79050C
00000000
19800A3C
942D4B8D
F9384991
902D4C8D
FB384D91
21086901
00002290
04008395
24284D00
0D00A010
00000000
06008495
40180300
40200400
040083A5
060084A5
3D000534
25008491
23182501
21088301
000022A0
08008434
250084A1
1000BF8F
1800BD27
0800E003
00000000
    </Location>
  </Patch>
  • Modding version: PSX
  • Discord username: stuminator

nitwit

@stuminator very nice!

You could probably do something similiar with Reis's* Dragon specific formulas. I remember seeing a hack that lets you choose the two sprites it would work with, maybe if you're so inclined you could de-hardcode that as you did this?

*Peanut Butter Cups?
  • Modding version: PSX

stuminator

Making the dragon formulas work on any monster would be a really quick fix I think - could probably just change the 2 lines of code at 001875d4 and 001875d8 in the dragon check to nops and it should work on anything with a monster graphic.

Setting any 2 sprites with patcher seems a bit more daunting.  Since the x and y fields are already used in some of Reis's abilities, maybe the element field could be used to specify the monster types.  There are 16 monster types, so the first 4 elements could be a bitwise representation of the first sprite, the next 4 elements the second sprite.  This wouldn't be too user friendly, having to convert the monster graphic index # into the appropriate elements checked but it should work.

This would also use lots more lines of code than are normally in the dragon check routine.  How is everyone determining what free space to use and making sure that nobody's hacks conflict with one another?
  • Modding version: PSX
  • Discord username: stuminator

nitwit

I'm not sure if it's up to date, but here's the allocated space listing.
https://ffhacktics.com/wiki/Allocated_space

This seems related.
https://ffhacktics.com/wiki/Static_Free_Space_Allocation

After thinking about it, I'm not sure if dehardcoding the dragon formulas is worth your time. There's only a few of them and they have very niche and OP effects. A more flexible and useful feature would be a flag somewhere that dictates to the formula set-up and AI routines that this skill is monster specific, and have it grab the monster portrait or portraits from an unused byte or two provided by the modder.

That would be more useful for a Monster Hunter class or something similar.

Unfortunately it's beyond the scope of a single person's efforts, though I do remember someone is working on a formula rewrite around here.

I apologize if I made an inadvertent request.
  • Modding version: PSX

stuminator

Actually, this wasn't anywhere near as tough as I thought it would be.  I came up with a monster type check routine that utilizes the element flags and the Y field of an ability to let you mix and match all 16 monster classes so the ability can only target any combination you want.  Only 1 of the existing vanilla Dragon formulas actually uses the X and Y values anyway, 5C, and I was able to create a workaround here by moving the Y value to the status effect field (not a problem since this particular formula doesn't have status effects anyway.)

It uses 32 lines of code so I'd just need some free space to put this.  From looking at the Allocated Space on the wiki, it appears that maybe this could go at 0x000F929C, just after Pride's last formula.  Is this OK, or is there somewhere else this should go?
  • Modding version: PSX
  • Discord username: stuminator

nitwit

Quote from: stuminator on October 02, 2021, 07:01:33 pmActually, this wasn't anywhere near as tough as I thought it would be.  I came up with a monster type check routine that utilizes the element flags and the Y field of an ability to let you mix and match all 16 monster classes so the ability can only target any combination you want.  Only 1 of the existing vanilla Dragon formulas actually uses the X and Y values anyway, 5C, and I was able to create a workaround here by moving the Y value to the status effect field (not a problem since this particular formula doesn't have status effects anyway.)

It uses 32 lines of code so I'd just need some free space to put this.  From looking at the Allocated Space on the wiki, it appears that maybe this could go at 0x000F929C, just after Pride's last formula.  Is this OK, or is there somewhere else this should go?
That should be fine. Ask on the discord if there's a hack conflict checker or some other means of checking.
  • Modding version: PSX

Elric

FFTorgASM has shown conflicts for years now. It can even move hacks that conflict, properly
  • Modding version: PSX
<@Angel> Teach a man to fish and he'll open up a fishery to compete against yours.


Journey of the Five Youtube ChannelThe Lion War Current Status
  
Jot5 Leader :: Eventer :: OtherTLW Leader :: Eventer :: Other

stuminator

October 04, 2021, 03:51:51 pm #369 Last Edit: October 04, 2021, 05:23:22 pm by stuminator Reason: typo
Here are the monster type check codes:

<Patch name="Monster type check routine">
    <Description>
      This creates a monster type check routine that uses the element fields and Y value to allow any formula calling it to only work on whatever monster types you want.
      Monster types are divided into an element group and Y group as follows:
      Element Group:
        Fire=Eyeball
        Lightning=Ghoul
        Ice=Skeleton
        Wind=Squid
        Earth=Panther
        Water=Bomb
        Holy=Goblin
        Dark=Chocobo
      For this group, simply check the element box if you want the ability to be able to target this monster type.
      Y Group:
        128=Hydra
        64=Dragon
        32=Behemoth
        16=Morbol
        8=Minotaur
        4=Woodman
        2=Pig
        1=Bird
      For this group, add up all the values you want the ability to target, and put the sum into the ability Y value.  These values are in decimal.
    </Description>
    <Location file="BATTLE_BIN" offset="FA180">
      19800A3C
      982D428D
      E8FFBD27
      1000BFAF
      5E014390
      01000434
      13006010
      00000000
      22186400
      0800652C
      0800A010
      00000000
      F7384591
      04186400
      24186500
      0A006010
      00000000
      7C840508
      00000000
      FA384591
      08000634
      22186600
      04186400
      24186500
      03006014
      00000000
      C310060C
      00000000
      1000BF8F
      1800BD27
      0800E003
      00000000
    </Location>
  </Patch>

<Patch name="Dragon formulas use monster type check routine">
    <Description>
      This replaces the Dragon check in abilities 5A,5B,5C,5D with a monster type check allowing you specify the types of monsters these abilities work on.
      Note on formulas 5C and 3B:  In order to work with the monster check routine, this makes the status effect field the SP/PA/MA+ value instead of the Y field.
      Both Scream and Dragon Power Up use the same routine, so remember this adjustment if you plan on using either formula.
    </Description>
    <Location file="BATTLE_BIN" offset="123988">
      6084050C
    </Location>
    <Location file="BATTLE_BIN" offset="1239CC">
      6084050C
    </Location>
    <Location file="BATTLE_BIN" offset="123A18">
      6084050C
    </Location>
    <Location file="BATTLE_BIN" offset="123A5C">
      6084050C
    </Location>
    <Location file="BATTLE_BIN" offset="11FD74">
      FB
    </Location>
  </Patch>

Make sure to see in the description of assigning the Dragon formulas to use the new routine that I needed to make a slight change to both the Dragon Power up and Scream formulas.

  • Modding version: PSX
  • Discord username: stuminator

Ansehelm

October 07, 2021, 08:24:33 pm #370 Last Edit: October 07, 2021, 10:08:38 pm by Ansehelm
Quote from: stuminator on October 04, 2021, 03:51:51 pmHere are the monster type check codes:
Yo, this looks super dope.  Nice work!
  • Modding version: PSX

stuminator

Quote from: JadeKnightblazer on July 09, 2021, 11:19:57 amRequest: Formulas 0F and 10 (AbsMP/AbsHP) allow Status infliction.

I've been playing around with this and have something that's mostly working:


<Patch name="Formula 0F = Absorb HP or MP_Y% Hit_F(MA+X)% accepts procs">
    <Description>
      Uses the space for both formulas 0F and 10.
      Formula 0F now accepts procs.  HP asborb is the default.  To absorb MP, check the box between Hit Allies and Follow Target.
    </Description>
    <Location file="BATTLE_BIN" offset="122084">
      E8FFBD27
      1000BFAF
      6E21060C
      19800A3C
      1A004014
      F4384B91
      7322060C
      20006B31
      16004014
      00000000
      07006015
      00000000
      8919060C
      00000000
      921C060C
      00000000
      3A240608
      00000000
      A319060C
      00000000
      902D438D
      00000000
      08006494
      1B1D060C
      040062A4
      3021060C
      00000000
      03004014
      00000000
      AD1F060C
      00000000
      1000BF8F
      1800BD27
      0800E003
      00000000
    </Location>
  </Patch>

This is working most of the time, but sometimes absorbs 0 MP, even at 100% and the target having plenty of MP.  Maybe someone could figure out what the deal is on this?

Here is the code in ASM format with comments:

[0x00189084]   addiu r29,r29,-0x0018         
[0x00189088]   sw r31,0x0010(r29)         
[0x0018908c]   jal 0x001885b8         Magic evade
[0x00189090]   lui r10,0x8019         
[0x00189094]   bne r2,r0,0x00189100         Jump to end if evaded
[0x00189098]   lbu r11,0x38f4(r10)         
[0x0018909c]   jal 0x001889cc         magic accuracy check
[0x001890a0]   andi r11,r11,0x0020         Check for unknown flag
[0x001890a4]   bne r2,r0,0x00189100         Jump to end if accuracy fails
[0x001890a8]   nop         
[0x001890ac]   bne r11,r0,0x001890cc         Jump ahead to MP section if unknown flag checked
[0x001890b0]   nop         
[0x001890b4]   jal 0x00186624         calculate HP% damage
[0x001890b8]   nop         
[0x001890bc]   jal 0x00187248         HP absorption
[0x001890c0]   nop         
[0x001890c4]   j 0x001890e8         jump to proc roll
[0x001890c8]   nop         
[0x001890cc]   jal 0x0018668c         mp damage
[0x001890d0]   nop         
[0x001890d4]   lw r3,0x2d90(r10)         
[0x001890d8]   nop         
[0x001890dc]   lhu r4,0x0008(r3)         
[0x001890e0]   jal 0x0018746c         mp recovery routine
[0x001890e4]   sh r2,0x0004(r3)         
[0x001890e8]   jal 0x001884c0         conditional proc roll
[0x001890ec]   nop         
[0x001890f0]   bne r2,r0,0x00189100         branch if status effect fails
[0x001890f4]   nop         
[0x001890f8]   jal 0x00187eb4         apply status to action
[0x001890fc]   nop         
[0x00189100]   lw r31,0x0010(r29)         
[0x00189104]   addiu r29,r29,0x0018         
[0x00189108]   jr r31         
[0x0018910c]   nop      


  • Modding version: PSX
  • Discord username: stuminator

Glain

There is a logic error here:

[0x0018908c]   jal 0x001885b8           #   Magic evade
[0x00189090]   lui r10,0x8019         

r10 is being set to the value 0x80190000... but then will be overwritten when the routine at 0x1885b8 is run.  You can't assume the value of r10 won't be changed by the routine.  (In this case, the call to rand() should actually change it to 0xa0, with the trace: https://ffhacktics.com/wiki/Rand -> https://ffhacktics.com/wiki/Pass/Fail_Roll -> https://ffhacktics.com/wiki/Attack_Evaded_Calculations -> https://ffhacktics.com/wiki/Calculate_Final_Hit_%25 -> https://ffhacktics.com/wiki/Calculate_Hit_%25 -> https://ffhacktics.com/wiki/Magical_Evade_Calculation)

[0x00189094]   bne r2,r0,0x00189100     #   Jump to end if evaded
[0x00189098]   lbu r11,0x38f4(r10)         
[0x0018909c]   jal 0x001889cc           #   magic accuracy check
[0x001890a0]   andi r11,r11,0x0020      #   Check for unknown flag
[0x001890a4]   bne r2,r0,0x00189100     #   Jump to end if accuracy fails
[0x001890a8]   nop         
[0x001890ac]   bne r11,r0,0x001890cc    #   Jump ahead to MP section if unknown flag checked

Same problem with r11.  You're assuming the value won't change, but it very well might.  Either use saved registers, with appropriate loading and storing on the stack, or use unsaved registers in a way that they load and use their values without a routine call being inbetween them.
  • Modding version: Other/Unknown

stuminator

Thanks for the help Glain.  I was trying to save some space by checking for the unknown flag while the evade/accuracy checks were running, but I guess this is a big no-no.

I redid this and just barely had enough room to fit everything in, seems to be working fine now:

<Patch name="Formula 0F = Absorb HP or MP_Y% Hit_F(MA+X)% accepts procs">
    <Description>
      Uses the space for both formulas 0F and 10.
      Formula 0F now accepts procs.  HP absorb is the default.  To absorb MP, check the box between Hit Allies and Follow Target.
    </Description>
    <Location file="BATTLE_BIN" offset="122084">
      E8FFBD27
      1000BFAF
      6E21060C
      00000000
      1F004014
      00000000
      7322060C
      00000000
      1B004014
      00000000
      19800A3C
      F4384B91
      00000000
      20006B31
      07006015
      00000000
      8919060C
      00000000
      921C060C
      00000000
      3F240608
      00000000
      A319060C
      00000000
      19800A3C
      902D438D
      00000000
      08006494
      1B1D060C
      040062A4
      3021060C
      00000000
      03004014
      00000000
      AD1F060C
      00000000
      1000BF8F
      1800BD27
      0800E003
      00000000
    </Location>
  </Patch>

And everything with comments:

[0x00189084] addiu r29,r29,-0x0018
[0x00189088] sw r31,0x0010(r29)
[0x0018908c] jal 0x001885b8 # Magic evade
[0x00189090] nop
[0x00189094] bne r2,r0,0x00189114 # Branch to end if evaded
[0x00189098] nop
[0x0018909c] jal 0x001889cc # magic accuracy check
[0x001890a0] nop
[0x001890a4] bne r2,r0,0x00189114 # Branch to end if accuracy check fails
[0x001890a8] nop
[0x001890ac] lui r10,0x8019
[0x001890b0] lbu r11,0x38f4(r10)
[0x001890b4] nop
[0x001890b8] andi r11,r11,0x0020 # Checks for unknown flag above Follow Target
[0x001890bc] bne r11,r0,0x001890dc # Branch ahead to MP section if unknown flag checked
[0x001890c0] nop
[0x001890c4] jal 0x00186624 # calculate HP% damage
[0x001890c8] nop
[0x001890cc] jal 0x00187248 # HP absorption
[0x001890d0] nop
[0x001890d4] j 0x001890fc # jump to proc roll
[0x001890d8] nop
[0x001890dc] jal 0x0018668c # mp damage
[0x001890e0] nop
[0x001890e4] lui r10,0x8019
[0x001890e8] lw r3,0x2d90(r10)
[0x001890ec] nop
[0x001890f0] lhu r4,0x0008(r3)
[0x001890f4] jal 0x0018746c # mp recovery routine
[0x001890f8] sh r2,0x0004(r3)
[0x001890fc] jal 0x001884c0 # conditional proc roll
[0x00189100] nop
[0x00189104] bne r2,r0,0x00189114 # branch if status effect fails
[0x00189108] nop
[0x0018910c] jal 0x00187eb4 # apply status to action
[0x00189110] nop
[0x00189114] lw r31,0x0010(r29)
[0x00189118] addiu r29,r29,0x0018
[0x0018911c] jr r31
[0x00189120] nop

  • Modding version: PSX
  • Discord username: stuminator

LV99 Vivi

October 10, 2021, 01:59:21 pm #374 Last Edit: October 10, 2021, 02:15:25 pm by LV99 Vivi
idk if its found or requested or made yet but i would love to mod in more options for math skill targets or the multiples. Targets in general or keeping the same theme as og game like targeting based on faith or brave values or even weird stats like:

gender / zodiac /unit #

or the other obvious ones like: spd / PA / MA / HP / MP / wpn pwr / evasion %

or make it weirder with using a mixture of base 16 or base 2 instead of 10.  using multiple of 0x4 could target a person with 10 value since 10 = 16 in hex and there could also be normal 4 for og method of targeting in the same menu or a new job that has these weird ones but it has access to literally all abilities.

Could call it ASM Math Skill or Hex magic or just 0x0FF70101 for the lols.

could also add a third menu instead of the usual 2 for calc. why not a forth.

sorry just thinking aloud, one can dream.
  • Modding version: PSX & WotL
  • Discord username: LV99 Vivi