• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
April 23, 2024, 05:19:27 am

News:

Use of ePSXe before 2.0 is highly discouraged. Mednafen, RetroArch, and Duckstation are recommended for playing/testing, pSX is recommended for debugging.


HELP! (Immortal flag immune formula asm, eventing)

Started by Emmy, June 19, 2016, 04:54:36 pm

Emmy

1.  I managed to create a couple formulas which check for immortal, and fail if the unit is immortal.  They work, except for the display.  Will display a 100% and fail if an immortal unit is targeted.  Even worse is with the Endeavor formula I made, since it displays 100% regardless of whether or not it'll work on the target.  I'm probably missing something really dumb here.  Before I work on another formula that fails on immortal targets, is there a way to make it display 0% if it will fail?

Endeavor:


  <Patch name="Formula 35 = Endeavor">
    <Description>Display screwed up, otherwise works!  Fails on immortal targets</Description>
    <Location file="BATTLE_BIN" offset="122f08">
E8FFBD27
1000BFAF
1980013C
982D218C
00000000
05002290
04004230
09004014
00000000
1980023C
942D428C
00000000
28004494
28002594
00000000
2318A400
900123A4
1000BF8F
1800BD27
0800E003
00000000
    </Location>
  </Patch>

ASM for this formula:

addiu r29,r29,0xffe8
sw r31,0x0010(r29)
lui r1,0x8019
lw r1,0x2d98(r1)
nop
lbu r2,0x0005(r1)
andi r2,r2,0x0004
bne r2,r0,0x00000044
nop
lui r2,0x8019
lw r2,0x2d94(r2)
nop
lhu r4,0x0028(r2)
lhu r5,0x0028(r1)
nop
subu r3,r5,r4
sh r3,0x0190(r1)
lw r31,0x0010(r29)
addiu r29,r29,0x0018   
jr r31
nop


Another formula that displays 100% vs. immortal, but will display the damage it does vs. non-immortal:


  <Patch name="Formula 15 = Y% damage, faith based accuracy, status 100%, immortal immune">
    <Description>Displays 100% but always misses on immortal target</Description>
    <Location file="BATTLE_BIN" offset="1221ac">
E8FFBD27
1000BFAF
1980023C
982D428C
00000000
05004290
04004230
09004014
00000000
8922060C
00000000
05004014
00000000
8919060C
00000000
AD1F060C
00000000
1000BF8F
1800BD27
0800E003
00000000
    </Location>
  </Patch>

ASM for this formula:

[0x00000000] addiu r29,r29,-0x0018
[0x00000004] sw r31,0x0010(r29)
[0x00000008] lui r2,0x8019
[0x0000000c] lw r2,0x2d98(r2)
[0x00000010] nop
[0x00000014] lbu r2,0x0005(r2)
[0x00000018] andi r2,r2,0x0004
[0x0000001c] bne r2,r0,0x00000044
[0x00000020] nop
[0x00000024] jal 0x00188a24
[0x00000028] nop
[0x0000002c] bne r2,r0,0x00000044
[0x00000030] nop
[0x00000034] jal 0x00186624
[0x00000038] nop
[0x0000003c] jal 0x00187eb4
[0x00000040] nop
[0x00000044] lw r31,0x0010(r29)
[0x00000048] addiu r29,r29,0x0018
[0x0000004c] jr r31
[0x00000050] nop



2.  How do you use the Upgraded Event Instructions to apply Petrify to a target?  Give an example.  (Was trying to do this today and yesterday and it was failing) :(  http://ffhacktics.com/wiki/Event_Instruction_Upgrade

3.  How do you change whether or not Ramza is mandatory?
  • Modding version: PSX

Pride

For the ASM, the issue is with how you have it laid out. You need to run the check for Immortal, run the forced missed routine, /then/ branch to the end. Look at formula 5a to see what I mean.


0018a980: 27bdffe8 addiu r29,r29,0xffe8      
0018a984: afbf0010 sw r31,0x0010(r29)      
0018a988: 0c061d6f jal 0x001875bc            Dragon Check
0018a98c: 00000000 nop            
0018a990: 3c028019 lui r2,0x8019      
0018a994: 8c422d90 lw r2,0x2d90(r2)      
0018a998: 00000000 nop            
0018a99c: 90420000 lbu r2,0x0000(r2)      
0018a9a0: 00000000 nop            
0018a9a4: 10400003 beq r2,r0,0x0018a9b4         Check if evaded (Already done above)
0018a9a8: 00000000 nop            
0018a9ac: 0c061fc9 jal 0x00187f24            Status Proc at 100%
0018a9b0: 00000000 nop            
0018a9b4: 8fbf0010 lw r31,0x0010(r29)      
0018a9b8: 27bd0018 addiu r29,r29,0x0018      
0018a9bc: 03e00008 jr r31         
0018a9c0: 00000000 nop   

001875bc: 3c028019 lui r2,0x8019      
001875c0: 8c422d98 lw r2,0x2d98(r2)      Load Target's stats
001875c4: 27bdffe8 addiu r29,r29,0xffe8      
001875c8: afbf0010 sw r31,0x0010(r29)      
001875cc: 9042015e lbu r2,0x015e(r2)      Load Target's Graphic
001875d0: 00000000 nop            
001875d4: 2442fff1 addiu r2,r2,0xfff1      Target's Graphic - E
001875d8: 2c420002 sltiu r2,r2,0x0002      Set to 1 if Target's Graphic is E, F, or 10
001875dc: 14400003 bne r2,r0,0x001875ec      Branch to end if target is using Graphic E, F, 10
001875e0: 00000000 nop            
001875e4: 0c0610c3 jal 0x0018430c      Force Attack Miss
001875e8: 00000000 nop            
001875ec: 8fbf0010 lw r31,0x0010(r29)      
001875f0: 27bd0018 addiu r29,r29,0x0018      
001875f4: 03e00008 jr r31         
001875f8: 00000000 nop   
  • Modding version: PSX
Check out my ASM thread. Who doesn't like hax?

Emmy

Yay got it to display 0% if miss. :)  Separated it into a different routine for efficiency, since I'm going to be using the immortal check in several places/running out of long formulas to write over.

Not sure why it displays kinda strangely (will say 100% if it's capable of hitting a target) if the immortal check routine is used in other formulas.  Here's the routine and another formula to check:

**Edit** I'm a dummy, figured out the problem.
  • Modding version: PSX

Pride

Uou need a nop command after lbu x0005. This isn't your error most likely but it is an error
  • Modding version: PSX
Check out my ASM thread. Who doesn't like hax?

Emmy

Fixed that error too.  Thanks. :)

Error I ended up finding on my own was something extremely dumb, like a bne instead of a beq somewhere.  Stuff like that is easy to make/hard to catch when you're tired.
  • Modding version: PSX

Emmy

I'm putting this here as to not put too many topics up.  How do I check multiple values in a range efficiently?  Is there a way to branch if, for example, r5 is between 1 and 6?
  • Modding version: PSX

Glain

There isn't an instruction for that specifically, but you can do some clever things to make the most of the instructions that do exist.  For example, to test if 1 <= X <= 6, you could test that an unsigned (X - 1) <= 5, and if we're comparing unsigned integers then that's the same as testing that (X - 1) < 6. 

In your example, you could do something like this:


addiu  r6, r5, -1
sltiu  r7, r6, 6
bne    r7, r0, (some address)
nop
  • Modding version: Other/Unknown

Emmy

Thank you for your help. :)  Routine I wrote didn't work at all, but I thought of a different way to accomplish what I need to. 

Looking at Chakra formula, what is all this shifting doing? http://ffhacktics.com/wiki/34_Heal_(PA*Y)_HealMP_(PA*Y/2)

00189ee0: 00031c00 sll r3,r3,0x10            
00189ee4: 00031403 sra r2,r3,0x10            
00189ee8: 00031fc2 srl r3,r3,0x1f            
00189eec: 00431021 addu r2,r2,r3      
00189ef0: 00021043 sra r2,r2,0x01      <-- I know this line is divide by 2, but what purpose does all that stuff above it serve?
  • Modding version: PSX

Glain

That shifting is to handle negative numbers, which is interesting because the damage and healing values are never meant to be negative, as far as I'm aware.  The first two lines sign-extend the register and the next two change the way a negative result rounds (up instead of down, e.g. -11 / 2 produces -5 instead of -6).
  • Modding version: Other/Unknown