Poison Marsh Routine

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
BATTLE.BIN :  - Poison Marsh Routine
------------------------------------------------------------------------------------------
Parameter : r4 = Pointer to unit battle data (801908cc)
Return : r2 = 0x01 if Poison will be inflicted
         r2 = 0x00 if no status infliction
------------------------------------------------------------------------------------------
0018da88: 27bdffe0 addiu r29,r29,-0x0020     |
0018da8c: afb10014 sw r17,0x0014(r29)        |
0018da90: 00808821 addu r17,r4,r0            |Preserve Unit data pointer
0018da94: afbf0018 sw r31,0x0018(r29)        |
0018da98: afb00010 sw r16,0x0010(r29)        |
0018da9c: 92300182 lbu r16,0x0182(r17)       |Mount Info
0018daa0: 0c063691 jal 0x0018da44            |-->Crystal,_Dead,_Jump,_Petrify,_Treasure_check
0018daa4: 00000000 nop                       |
0018daa8: 1440003b bne r2,r0,0x0018db98      #If unit is afflicted with the above Status : branch to END return 0x00
0018daac: 00001021 addu r2,r0,r0             |
0018dab0: 32020040 andi r2,r16,0x0040        |
0018dab4: 14400038 bne r2,r0,0x0018db98      #If unit is being ridden : branch to END return 0x00
0018dab8: 00001021 addu r2,r0,r0             |
0018dabc: 32020080 andi r2,r16,0x0080        |
0018dac0: 1040000d beq r2,r0,0x0018daf8      #If Unit is riding
0018dac4: 3202001f andi r2,r16,0x001f            |Mount ID
0018dac8: 000218c0 sll r3,r2,0x03                |
0018dacc: 00621823 subu r3,r3,r2                 |
0018dad0: 00031980 sll r3,r3,0x06                |Mount ID * 0x1c0
0018dad4: 3c018019 lui r1,0x8019                 |
0018dad8: 00230821 addu r1,r1,r3                 |Mout  data pointer
0018dadc: 90220926 lbu r2,0x0926(r1)             |Mount Current Status 3
0018dae0: 00000000 nop                           |
0018dae4: 30420040 andi r2,r2,0x0040             |
0018dae8: 10400006 beq r2,r0,0x0018db04          #Branch if bit x40 or float is active
0018daec: 2624018c addiu r4,r17,0x018c           |Unit current action data pointer
0018daf0: 080636e6 j 0x0018db98                      >>Exit routine : returns 0x00
0018daf4: 00001021 addu r2,r0,r0                     |r2 = 0
                                            ELSE : Unit is not riding
0018daf8: 9222005a lbu r2,0x005a(r17)            |Load Current Statuses 3
0018dafc: 080636ba j 0x0018dae8                  >>Jump back and check Float status
0018db00: 30420040 andi r2,r2,0x0040             |Float ?
0018db04: 9222018a lbu r2,0x018a(r17)        |Unit ID
0018db08: 3c018019 lui r1,0x8019             |
0018db0c: ac312d98 sw r17,0x2d98(r1)         |Store Defender's Data Pointer
0018db10: 3c018019 lui r1,0x8019             |
0018db14: ac242d90 sw r4,0x2d90(r1)          |Store Defender's Current Action Data Pointer
0018db18: 3c018019 lui r1,0x8019             |
0018db1c: a02238c1 sb r2,0x38c1(r1)          |Store Target Unit ID
0018db20: 0c062f5d jal 0x0018bd74            |-->Current_Action_Data_Nulling
0018db24: 00000000 nop                       |
0018db28: 0c060428 jal 0x001810a0            |-->Map Location Calculation returns Unit's Tile ID
0018db2c: 02202021 addu r4,r17,r0            |Send Unit data pointer
0018db30: 000210c0 sll r2,r2,0x03            |Tile ID*8
0018db34: 3c018019 lui r1,0x8019             |
0018db38: 00220821 addu r1,r1,r2             |
0018db3c: 9022f8cc lbu r2,-0x0734(r1)        |Unit's Tile data pointer
0018db40: 00000000 nop                       |
0018db44: 3042003f andi r2,r2,0x003f         |Keep Tile's type
0018db48: 3c018006 lui r1,0x8006             |
0018db4c: 00220821 addu r1,r1,r2             |
0018db50: 9022ea10 lbu r2,-0x15f0(r1)        |Load Terrain Status Infliction  8005ea10 + Terrain type
0018db54: 00000000 nop                       |
0018db58: 30420080 andi r2,r2,0x0080         |
0018db5c: 1040000d beq r2,r0,0x0018db94      #If Terrain inflict poison
0018db60: 00002021 addu r4,r0,r0                 |Send 0x00 in below routine
0018db64: 3c038019 lui r3,0x8019                 |
0018db68: 8c632d90 lw r3,0x2d90(r3)              |Load Current Action Data Pointer
0018db6c: 34020080 ori r2,r0,0x0080              |
0018db70: 0c0612c9 jal 0x00184b24                |-->Validate_Status_Changes returns 0x00 if poison cannot be inflicted
0018db74: a062001e sb r2,0x001e(r3)              |Store Status Infliction as Poison
0018db78: 10400006 beq r2,r0,0x0018db94          #If Poison will be inflicted
0018db7c: 34020001 ori r2,r0,0x0001                  |returns 0x01
0018db80: 3c048019 lui r4,0x8019                     |
0018db84: 8c842d90 lw r4,0x2d90(r4)                  |Target Current action data pointer
0018db88: 34030008 ori r3,r0,0x0008                  |
0018db8c: 080636e6 j 0x0018db98                      >>Exit and returns 0x01
0018db90: a0830025 sb r3,0x0025(r4)                  |Store status change as attack type
0018db94: 00001021 addu r2,r0,r0             |Returns 0x00
0018db98: 8fbf0018 lw r31,0x0018(r29)
0018db9c: 8fb10014 lw r17,0x0014(r29)
0018dba0: 8fb00010 lw r16,0x0010(r29)
0018dba4: 27bd0020 addiu r29,r29,0x0020
0018dba8: 03e00008 jr r31
0018dbac: 00000000 nop

Return locations

BATTLE.BIN
 00182ee0: In_between_turn_control_routine