Apply status (to action)

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search

Note that this is also formula 38 (100% status). It's both a subroutine called by other formulas, and a formula in the formula table.

[38]
00187f24: 3c038019 lui r3,0x8019
00187f28: 90633906 lbu r3,0x3906(r3)        r3 = Status infliction Type
00187f2c: 27bdff38 addiu r29,r29,0xff38
00187f30: afbf00c0 sw r31,0x00c0(r29)
00187f34: afb300bc sw r19,0x00bc(r29)
00187f38: afb200b8 sw r18,0x00b8(r29)
00187f3c: afb100b4 sw r17,0x00b4(r29)
00187f40: 30620020 andi r2,r3,0x0020        Check for 'Separate' (r2 = 0 if not separate)
00187f44: 1040000b beq r2,r0,0x00187f74     # If separate	
00187f48: afb000b0 sw r16,0x00b0(r29)           |
00187f4c: 3c048019 lui r4,0x8019                | 
00187f50: 8c842d90 lw r4,0x2d90(r4)             | r4 = TCADP (Target Current Action Data Pointer)
00187f54: 00000000 nop                          |			
00187f58: 8482002a lh r2,0x002a(r4)             | r2 = TCADP Hit%
00187f5c: 00000000 nop                          |
00187f60: 04410002 bgez r2,0x00187f6c           # If Hit% >= 0 (Always true)
00187f64: 00000000 nop                              |
00187f68: 24420003 addiu r2,r2,0x0003               | r2 = 0 + 0x0003 (always skipped)
00187f6c: 00021083 sra r2,r2,0x02               | r2 = r2/4
00187f70: a482002a sh r2,0x002a(r4)             | store maximum status accuracy as 1/4 (not sure for which use)
00187f74: 30620060 andi r2,r3,0x0060        Check for 'Random' or "Separate" (r2 = 0 if none)
00187f78: 10400008 beq r2,r0,0x00187f9c     # If separate or random
00187f7c: 30620080 andi r2,r3,0x0080     	 | r2 = 0x0080 if all or nothing - else 0 (checked after branch)
00187f80: 3c028019 lui r2,0x8019                 |
00187f84: 8c42f5fc lw r2,-0x0a04(r2)             | r2 = check real action word
00187f88: 00000000 nop                           |
00187f8c: 10400003 beq r2,r0,0x00187f9c          # If not real action (Branch if real action) 
00187f90: 30620080 andi r2,r3,0x0080             | r2 = 0x0080 if all or nothing - else 0 checked after branch
00187f94: 34030080 ori r3,r0,0x0080                  | r3 = 0x08 
00187f98: 30620080 andi r2,r3,0x0080                 | force r2 to all or nothing; (force status display before action ?)
00187f9c: 10400010 beq r2,r0,0x00187fe0     # If ALL OR NOTHING flagged
00187fa0: 00008021 addu r16,r0,r0               | r16 = 0x00
00187fa4: 3c038019 lui r3,0x8019                @ ALL OR NOTHING LOOP Beginning - (Update Current Action status infliction)
00187fa8: 8c632d90 lw r3,0x2d90(r3)                 | r3 = TCADP
00187fac: 3c018019 lui r1,0x8019                    |
00187fb0: 00300821 addu r1,r1,r16                   | r1 = 0x8019 + offset (r16)
00187fb4: 90243907 lbu r4,0x3907(r1)                | r4 = Status 1 byte from Status ID (from SCUS)
00187fb8: 00701821 addu r3,r3,r16                   | r3 = r3 + offset (r16) 
00187fbc: 9062001b lbu r2,0x001b(r3)                | r2 = TCADP attack status infliction + offset
00187fc0: 26100001 addiu r16,r16,0x0001             | Offset +1
00187fc4: 00441025 or r2,r2,r4                      | r2 = r2 updated with status byte copied from SCUS
00187fc8: a062001b sb r2,0x001b(r3)                 | Store updated Status to inflict
00187fcc: 2a020005 slti r2,r16,0x0005               | r2 = 1 While r16 < 0x05
00187fd0: 1440fff4 bne r2,r0,0x00187fa4         > Loop while r2 = 1 (5 loops for the 5 statuses sets)
00187fd4: 00002021 addu r4,r0,r0                | r4 = 0x00
00187fd8: 08062070 j 0x001881c0                 >> Jump to Confirm Status Part
00187fdc: 00000000 nop						
00187fe0: 30620040 andi r2,r3,0x0040       Check for "Random" (r2 =  0 if not random)
00187fe4: 10400030 beq r2,r0,0x001880a8    # If RANDOM (Choose one status among statuses checked in status ID and update Attack status infliction))
00187fe8: 00008821 addu r17,r0,r0              | r17 = 0x00 (Status counter,  +1 each time a status is stored / present in the status ID))
00187fec: 00008021 addu r16,r0,r0              | r16 = 0x00 (Loop base counter 0 to 0x28 (40) --> +1 each loop)
00187ff0: 34050080 ori r5,r0,0x0080            | r5 = 0x0080
00187ff4: 27a40010 addiu r4,r29,0x0010         | r4 = stack + 0x0010 (Inner routine Stackpointer - Used to store status)
00187ff8: 06010002 bgez r16,0x00188004         #@ If r16 < 0 - STATUS STORAGE LOOP - Beginning
00187ffc: 02001021 addu r2,r16,r0                      | r2 = r16
00188000: 26020007 addiu r2,r16,0x0007                 | r2 = 0x0007 + r16 (is <0) (never checked ? r16 always >= 0x00)
00188004: 000210c3 sra r2,r2,0x03                  | r2 = r2/8	(Offset for Statuses set - Become 1 after 8 cycles, 2 after 16)			
00188008: 3c018019 lui r1,0x8019                   | r1 = 0x80190000
0018800c: 00220821 addu r1,r1,r2                   | r1 = 8019 + status set offset
00188010: 90233907 lbu r3,0x3907(r1)               | r3 = status set 1 loc + status set offset 
00188014: 32020007 andi r2,r16,0x0007              | r2 = 0 to 7 (cycle from 0 to 7 and start again)
00188018: 00451007 srav r2,r5,r2                   | r2 = 0x80 >> 0 to 7 (0x80 then 0x40 then 0x20 until 0x01 --> scan each nimble of the status set byte)
0018801c: 00621824 and r3,r3,r2                    | r3 = status check r2
00188020: 10600004 beq r3,r0,0x00188034            # If Status present (Store it)
00188024: 00000000 nop                                 |								
00188028: ac900000 sw r16,0x0000(r4)                   | Store r16 at Inner stackpointer + 0x10 
0018802c: 24840004 addiu r4,r4,0x0004                  | Add 0x04 to stackpointer
00188030: 26310001 addiu r17,r17,0x0001                | r17 = r17 +1 (r17 = number of statuses stored)
00188034: 26100001 addiu r16,r16,0x0001            | r16 = r16 +1 (counter +1)
00188038: 2a020028 slti r2,r16,0x0028              | r2 = 1 while r16 < 0x28 (40); Run checks for each status
0018803c: 1440ffee bne r2,r0,0x00187ff8        > Loop while r2=1 (r16 < 0x28)
00188040: 00000000 nop
00188044: 0c063ba8 jal 0x0018eea0              --> Random Process, gives a number between 0-7fff
00188048: 00000000 nop
0018804c: 00510018 mult r2,r17                 | Random * r17 (number of statuses)
00188050: 00001012 mflo r2                     | r2 = Number of statii * Random number
00188054: 04410002 bgez r2,0x00188060          # If r2 < 0
00188058: 00000000 nop                             |
0018805c: 24427fff addiu r2,r2,0x7fff              | r2 = r2 positive value (ABS(r2))
00188060: 000213c3 sra r2,r2,0x0f              | r2 = 0 to r17 (Y)
00188064: 00021080 sll r2,r2,0x02              | r2 = Y x 0x04  (Inner offset of status storage)
00188068: 03a21021 add r2,r29,r2               | r2 = stack + inner offset
0018806c: 8c450010 lw r5,0x0010(r2)            | r5 = r16 value stocked in inner stackpointer (LOAD first or second status written)
00188070: 3c028019 lui r2,0x8019               |
00188074: 8c422d90 lw r2,0x2d90(r2)            | r2 = TCADP
00188078: 04a10002 bgez r5,0x00188084          # if r5 < 0 ?; Never true, r5 = r16 from the last loop (>= 0x00)
0018807c: 00a02021 addu r4,r5,r0                   | r4 = r5
00188080: 24a40007 addiu r4,r5,0x0007              | r4 = r5 + 0x07 (never checked ?)
00188084: 000420c3 sra r4,r4,0x03              | r4 = r5 / 8 --> Status set 
00188088: 00442021 addu r4,r2,r4               | r4 = TCAD + status set offset
0018808c: 30a50007 andi r5,r5,0x0007           | r5 = 0 to 7 (according to the stored r16 number)
00188090: 34020080 ori r2,r0,0x0080            | r2 = 0x80
00188094: 9083001b lbu r3,0x001b(r4)           | r3 = load status infliction byte (match status stored status set)
00188098: 00a21007 srav r2,r2,r5         		| r2 = Status byte (from r16)
0018809c: 00621825 or r3,r3,r2                 | r3 = update of status inflicted with the stored one
001880a0: 0806206f j 0x001881bc                >> JUMP to confirm status part
001880a4: a083001b sb r3,0x001b(r4)            | Store TCADP Inflicted Status Updated byte
001880a8: 30620020 andi r2,r3,0x0020       r2 = 0 if not separate 
001880ac: 10400033 beq r2,r0,0x0018817c    # If SEPARATE (roll each status Vs 25% and update Attack status infliction when succesfull)	
001880b0: 00008021 addu r16,r0,r0              | r16 = 0x00 (Loop counter)
001880b4: 34130080 ori r19,r0,0x0080           | r19 = 0x80
001880b8: 06010002 bgez r16,0x001880c4         #@ SEPARATE STATUS TEST Vs 25% LOOP beginning - if r16 < 0	?
001880bc: 02001021 addu r2,r16,r0                  |   | r2 = r16 	
001880c0: 26020007 addiu r2,r16,0x0007                 | r2 = r16 + 0x07 (never checked ?)
001880c4: 000288c3 sra r17,r2,0x03                 | r17 = r2/8 (value from 0 to 4 while looping -> Offset for status set)	
001880c8: 3c018019 lui r1,0x8019                   |
001880cc: 00310821 addu r1,r1,r17                  | r1 = 0x8019000 + status set offset
001880d0: 90233907 lbu r3,0x3907(r1)               | r3 = status set byte Load Status copied from SCUS (with offset -> each set is scanned)
001880d4: 32020007 andi r2,r16,0x0007              | r2 = value from 0 to 7 while looping (return to 0 each time r16 is a multiple of 8 (and 0x00))
001880d8: 00539007 srav r18,r19,r2                 | r18 = value from 0x80 to 0x01 while looping (cf supra))
001880dc: 00721824 and r3,r3,r18                   | r3 = 0x80 to 0x01 if status scanned is in the status ID from SCUS - 0x00 if not
001880e0: 10600012 beq r3,r0,0x0018812c            # If r3 <> 0 (If not  GOTO next loop turn (no status))
001880e4: 34040064 ori r4,r0,0x0064                    | r4 = 0x64 (100)
001880e8: 0c017833 jal 0x0005e0cc                      --> Check if Random is greater/equal to Chance - r2 = 1 if missed 0 if succesfull (< chance)
001880ec: 34050018 ori r5,r0,0x0018                    | r5 = 0x18 (25) - Separate = innate 25%
001880f0: 14400006 bne r2,r0,0x0018810c                # If r2 = 0 - Status successfull (if not branch to E#)
001880f4: 34020002 ori r2,r0,0x0002                        | r2 = 0x02
001880f8: 3c038019 lui r3,0x8019                           |
001880fc: 8c63f5fc lw r3,-0x0a04(r3)                       | r3 = word for checking if real action or simulation
00188100: 00000000 nop                                     |
00188104: 14620009 bne r3,r2,0x0018812c                    #If r3 = r2 (=0x02) not real action -> Stay / if not (= real action) Goto next loop (avoid the E# part)
00188108: 00000000 nop										|
0018810c: 3c018019 lui r1,0x8019                       E# r2 <> 0 -  Probability check not ok (remove status byte from Status ID)
00188110: 00310821 addu r1,r1,r17                          | r1 = 0x8019 + Status set offset
00188114: 90223907 lbu r2,0x3907(r1)                       | r2 = status set byte from status ID (SCUS)
00188118: 00000000 nop                                     |
0018811c: 00521026 xor r2,r2,r18                           | r2 = status set byte without status tested in this loop 
00188120: 3c018019 lui r1,0x8019                           |
00188124: 00310821 addu r1,r1,r17                          | r1 = 0x8019 + Status set offset
00188128: a0223907 sb r2,0x3907(r1)                        | Store updated byte in status infliction ID
0018812c: 26100001 addiu r16,r16,0x0001            | Increment r16
00188130: 2a020028 slti r2,r16,0x0028              | r2 = 1 while r16 < 0x28 (40) - Run through all status effects
00188134: 1440ffe0 bne r2,r0,0x001880b8        > Loop (SEPARATE STATUS TEST LOOP)
00188138: 00000000 nop
0018813c: 00008021 addu r16,r0,r0				|r16 = 0 (initialize counter)
00188140: 3c038019 lui r3,0x8019               @ SEPARATE STATUS INFLICTION LOOP
00188144: 8c632d90 lw r3,0x2d90(r3)                | r3 = TCADP
00188148: 3c018019 lui r1,0x8019                   |
0018814c: 00300821 addu r1,r1,r16                  | r1 = 8019 + offset (= counter)
00188150: 90243907 lbu r4,0x3907(r1)               | r4 = Status set byte (1 to 5 while looping)
00188154: 00701821 addu r3,r3,r16                  | r3 = TCADP + offset
00188158: 9062001b lbu r2,0x001b(r3)               | r2 = TCADP status infliction byte	(1 to 5 while looping)
0018815c: 26100001 addiu r16,r16,0x0001            | r16 = r16 +1
00188160: 00441025 or r2,r2,r4                     | r2 = status infliction byte updated with status to add
00188164: a062001b sb r2,0x001b(r3)                | store TCADP status infliction updated byte
00188168: 2a020005 slti r2,r16,0x0005              | r2 = 1 while r16 < 0x05; Run through all status effects to be added
0018816c: 1440fff4 bne r2,r0,0x00188140       > Loop while r2 = 1
00188170: 00002021 addu r4,r0,r0              | r4 = 0
00188174: 08062070 j 0x001881c0               >> Jump to confirm Status part
00188178: 00000000 nop
0018817c: 30620010 andi r2,r3,0x0010       | r2 = 0x10 if "Cancel" is checked - 0x00 if not 
00188180: 1040000f beq r2,r0,0x001881c0    # If CANCEL checked
00188184: 00002021 addu r4,r0,r0           | r4 = 0 
00188188: 3c038019 lui r3,0x8019               @ CANCEL LOOP Beginning	(update attack status removal with status ID)
0018818c: 8c632d90 lw r3,0x2d90(r3)                | r3 = TCADP
00188190: 3c018019 lui r1,0x8019                   |
00188194: 00300821 addu r1,r1,r16                  | r1 = 0x8019 + Offset (r16 = 0x00 see 001880b0)
00188198: 90243907 lbu r4,0x3907(r1)               | r4 = Status Byte (from set 1 to set 5 while looping) ; Load Status copied from SCUS
0018819c: 00701821 addu r3,r3,r16                  | r3 = TCADP + offset
001881a0: 90620020 lbu r2,0x0020(r3)               | r2 = TCADP status removal byte (from set 1 to set 5 while looping)
001881a4: 26100001 addiu r16,r16,0x0001            | r16 = r16 +1 (offset)
001881a8: 00441025 or r2,r2,r4                     | r2 = TCADP status removal byte updated with the one frome SCUS
001881ac: a0620020 sb r2,0x0020(r3)                | Store updated byte in attack status removal 
001881b0: 2a020005 slti r2,r16,0x0005              | r2 = 1 while r16 < 0x05; Go through all status effects
001881b4: 1440fff4 bne r2,r0,0x00188188       > Loop while r2 = 1 
001881b8: 00000000 nop
001881bc: 00002021 addu r4,r0,r0           |   | r4 = 0  
001881c0: 00008021 addu r16,r0,r0          | r16 = 0  X*** CONFIRM STATUS PART ***X
001881c4: 3c058019 lui r5,0x8019
001881c8: 8ca52d90 lw r5,0x2d90(r5)        | r5 = TCADP
001881cc: 00000000 nop                     @ INFLICTION/REMOVAL LOOP beginning (check if there is any status in attack status infliction/removal)
001881d0: 00b01021 addu r2,r5,r16				| r2 = TCADP + offset
001881d4: 9043001b lbu r3,0x001b(r2)           | r3 = Status infliction byte (from set 1 to set 5 while looping)
001881d8: 90420020 lbu r2,0x0020(r2)           | r2 = status removal byte (from set 1 to set 5 while looping)
001881dc: 26100001 addiu r16,r16,0x0001        | r16 = r16 +1 (offset)
001881e0: 00621825 or r3,r3,r2                 | r3 = status inflicted and removed
001881e4: 2a020005 slti r2,r16,0x0005          | r2 = 1 while r16 < 0x05
001881e8: 1440fff8 bne r2,r0,0x001881cc    > Loop while r2 = 1 (5 loops for each set of status)
001881ec: 00832025 or r4,r4,r3                 | r4 = r4 updated with status inflicted and removed
001881f0: 308200ff andi r2,r4,0x00ff       | r2 = r4 (all statuses set byte cumuled)
001881f4: 10400005 beq r2,r0,0x0018820c    # If r2 <> 0 (at least one status is inflicted or removed) - If not, jump to force attack miss routine
001881f8: 00000000 nop                         |
001881fc: 0c0612c9 jal 0x00184b24              --> Modify Status Inflictions or Validate Status Changes          (check mounted, immortal, toggle frog, Innate status, Immunities, Permanent status)
00188200: 00002021 addu r4,r0,r0               | r4 = 0
00188204: 14400005 bne r2,r0,0x0018821c        # If r2 =0   (r2 = 0 if no status is inflicted (result from jal))
00188208: 00000000 nop                             |
0018820c: 0c0610c3 jal 0x0018430c          E#      --> Force_Attack_Miss        (Attack miss, evade type 0x07,hit 0%)
00188210: 00000000 nop                             |                
00188214: 0806209a j 0x00188268					-> Jump to end of routine
00188218: 00000000 nop
0018821c: 3c028019 lui r2,0x8019               E# (r2 <>0 (status infliction))
00188220: 8c422d90 lw r2,0x2d90(r2)            | r2 = TCADP
00188224: 00000000 nop                         |
00188228: 90430025 lbu r3,0x0025(r2)           | r3 = TCADP attack type
0018822c: 00000000 nop                         |
00188230: 34630008 ori r3,r3,0x0008            | r3 updated with status change
00188234: a0430025 sb r3,0x0025(r2)            | store updated byte
00188238: 3c038019 lui r3,0x8019               |
0018823c: 8c632d90 lw r3,0x2d90(r3)            | r3 = TCADP
00188240: 00000000 nop                         |
00188244: 9062001c lbu r2,0x001c(r3)           | r2 = TCADP status infliction set 2
00188248: 00000000 nop                         |
0018824c: 30420040 andi r2,r2,0x0040           |r2 = 0x40 if invite is inflicted - Else 0x00
00188250: 10400005 beq r2,r0,0x00188268        # If target is invited (r2 <> 0x00)
00188254: 00000000 nop                             |
00188258: 94620010 lhu r2,0x0010(r3)               | r2 = TCADP special flags 1 and 2
0018825c: 00000000 nop                             |
00188260: 34420040 ori r2,r2,0x0040                | r2 updated with switch team
00188264: a4620010 sh r2,0x0010(r3)                | store updated specials flags
00188268: 8fbf00c0 lw r31,0x00c0(r29)
0018826c: 8fb300bc lw r19,0x00bc(r29)
00188270: 8fb200b8 lw r18,0x00b8(r29)
00188274: 8fb100b4 lw r17,0x00b4(r29)
00188278: 8fb000b0 lw r16,0x00b0(r29)
0018827c: 27bd00c8 addiu r29,r29,0x00c8
00188280: 03e00008 jr r31
00188284: 00000000 nop

Return Locations

00187eb4: Apply status (to action) - (Preserve hit status, evade type, hit %)