Final Fantasy Hacktics

Modding => PSX FFT Hacking => Topic started by: formerdeathcorps on January 06, 2011, 05:09:33 am

Title: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on January 06, 2011, 05:09:33 am
This thread is intended to essentially function as a collaborative thread for completely decompiling essential files into the requisite subroutines.  Eventually, we'll put this all on the Wiki.

We need to organize a group ASM decompilation of all of BATTLE.BIN.  There's enough people here who know how to do this and we all know Square's coding is horridly inefficient.  Doing this should open up more space for hacks, and will allow us to finally get a grip on how the AI works.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: secondadvent on January 06, 2011, 05:20:00 am
http://www.filefront.com/17756931/New-Folder.rar/

I should have had a bit more done with this, but i jump around WAY too much :P. Maybe once we get a group together to work on stuff, i will be more motivated to stick with it.

I will continue to work towards cleaning up my data locations file a bit, and updating the pointers to the many sections of the formula data, which i started on but didn't finish :/.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on January 06, 2011, 08:45:00 am
Here are my corrections to SA's work.  Anything slashed out means redundant routines by Square.  Underlined is anything stupid that not only takes up space, but removes features from certain formulas.  Bold means bugs unintended by the game.  Since the spoiler is massive and I had to edit my own notes, I'll post the first 0x1F formulas first.


To get Battle.bin offset, subtract 0x67000

Main formula data:

[01]
00188b64: 27bdffe8 addiu r29,r29,0xffe8
00188b68: afbf0010 sw r31,0x0010(r29)
00188b6c: 0c062144 jal 0x00188510      Physical Evade Calculation
00188b70: 00000000 nop
00188b74: 14400007 bne r2,r0,0x00188b94      Branch if attack is evaded
00188b78: 00000000 nop
00188b7c: 0c06218e jal 0x00188638      Physical Damage Calculation (Weapons)
00188b80: 00000000 nop
00188b84: 14400003 bne r2,r0,0x00188b94      Branch if no damage is dealt
00188b88: 00000000 nop
00188b8c: 0c061fad jal 0x00187eb4      Status Calculation
00188b90: 00000000 nop
00188b94: 8fbf0010 lw r31,0x0010(r29)
00188b98: 27bd0018 addiu r29,r29,0x0018
00188b9c: 03e00008 jr r31
00188ba0: 00000000 nop

[02]
00188ba4: 27bdffe8 addiu r29,r29,0xffe8
00188ba8: afbf0010 sw r31,0x0010(r29)
00188bac: 0c062144 jal 0x00188510      Physical Evade Calculation
00188bb0: 00000000 nop
00188bb4: 14400007 bne r2,r0,0x00188bd4      Branch if attack is evaded
00188bb8: 00000000 nop
00188bbc: 0c06218e jal 0x00188638      Physical Damage Calculation (Weapons)
00188bc0: 00000000 nop
00188bc4: 14400003 bne r2,r0,0x00188bd4      Branch if no damage is dealt
00188bc8: 00000000 nop
00188bcc: 0c061db9 jal 0x001876e4      Spell Proc
00188bd0: 00000000 nop
00188bd4: 8fbf0010 lw r31,0x0010(r29)
00188bd8: 27bd0018 addiu r29,r29,0x0018
00188bdc: 03e00008 jr r31
00188be0: 00000000 nop

[03]
00188be4: 3c028019 lui r2,0x8019
00188be8: 90423902 lbu r2,0x3902(r2)      Load WP
00188bec: 27bdffe8 addiu r29,r29,0xffe8
00188bf0: afbf0010 sw r31,0x0010(r29)
00188bf4: 3c018019 lui r1,0x8019
00188bf8: a42238ce sh r2,0x38ce(r1)      XA = WP
00188bfc: 3c018019 lui r1,0x8019
00188c00: a42238d0 sh r2,0x38d0(r1)      YA = WP
00188c04: 0c0617e0 jal 0x00185f80      Charge Calculation
00188c08: 00000000 nop
00188c0c: 0c0621a9 jal 0x001886a4      Physical Damage Calculation
00188c10: 00000000 nop
00188c14: 8fbf0010 lw r31,0x0010(r29)
00188c18: 27bd0018 addiu r29,r29,0x0018
00188c1c: 03e00008 jr r31
00188c20: 00000000 nop

[04]
00188c24: 27bdffe8 addiu r29,r29,0xffe8
00188c28: afbf0010 sw r31,0x0010(r29)
00188c2c: 0c061dcc jal 0x00187730      Magic Gun Ability Decision
00188c30: 00000000 nop
00188c34: 3c028019 lui r2,0x8019
00188c38: 90423902 lbu r2,0x3902(r2)      Load WP
00188c3c: 3c038019 lui r3,0x8019
00188c40: 906338fa lbu r3,0x38fa(r3)      Load Ability Power
00188c44: 3c018019 lui r1,0x8019
00188c48: a42238ce sh r2,0x38ce(r1)      XA = WP
00188c4c: 3c018019 lui r1,0x8019
00188c50: a42338d0 sh r3,0x38d0(r1)      YA = Ability Power
00188c54: 0c0617e0 jal 0x00185f80      Charge Calculation
00188c58: 00000000 nop
00188c5c: 0c0617e9 jal 0x00185fa4      Element Strengthen Calculation
00188c60: 00000000 nop
00188c64: 0c0621d1 jal 0x00188744      Magic XA Modifications
00188c68: 00000000 nop
00188c6c: 0c0621df jal 0x0018877c      Magic Damage Calculation
00188c70: 00000000 nop
00188c74: 14400005 bne r2,r0,0x00188c8c      Branch if element was nullified
00188c78: 00000000 nop
00188c7c: 0c061c54 jal 0x00187150      Faith Calculation
00188c80: 00000000 nop
00188c84: 0c061c3f jal 0x001870fc      Elemental Absorption
00188c88: 00000000 nop
00188c8c: 8fbf0010 lw r31,0x0010(r29)
00188c90: 27bd0018 addiu r29,r29,0x0018
00188c94: 03e00008 jr r31
00188c98: 00000000 nop

[05]
00188c9c: 27bdffe8 addiu r29,r29,0xffe8
00188ca0: afbf0010 sw r31,0x0010(r29)
00188ca4: 0c06215a jal 0x00188568      Physical Evade Calculation
00188ca8: 00000000 nop
00188cac: 1440000d bne r2,r0,0x00188ce4      Branch if attack was evaded
00188cb0: 00000000 nop
00188cb4: 0c0616a7 jal 0x00185a9c      Weapon XA Calculation
00188cb8: 00000000 nop
00188cbc: 0c0617e0 jal 0x00185f80      Charge Calculation
00188cc0: 00000000 nop
00188cc4: 0c0621a9 jal 0x001886a4      Physical Damage Calculation
00188cc8: 00000000 nop
00188ccc: 0c062130 jal 0x001884c0      ?
00188cd0: 00000000 nop
00188cd4: 14400003 bne r2,r0,0x00188ce4
00188cd8: 00000000 nop
00188cdc: 0c061fad jal 0x00187eb4      Status Calculation
00188ce0: 00000000 nop
00188ce4: 8fbf0010 lw r31,0x0010(r29)
00188ce8: 27bd0018 addiu r29,r29,0x0018
00188cec: 03e00008 jr r31
00188cf0: 00000000 nop


[06]
00188cf4: 27bdffe8 addiu r29,r29,0xffe8
00188cf8: afbf0010 sw r31,0x0010(r29)
00188cfc: 0c062144 jal 0x00188510      Physical Evade Calculation
00188d00: 00000000 nop
00188d04: 14400009 bne r2,r0,0x00188d2c      Branch if attack was evaded
00188d08: 00000000 nop
00188d0c: 0c0616a7 jal 0x00185a9c      Weapon XA Calculation
00188d10: 00000000 nop
00188d14: 0c0617e0 jal 0x00185f80      Charge Calculation
00188d18: 00000000 nop
00188d1c: 0c0621a9 jal 0x001886a4      Physical Damage Calculation Essentially, this is the same coding as the subroutine in 0x188638 but missing the weapon elemental routine.
00188d20: 00000000 nop
00188d24: 0c061c92 jal 0x00187248      HP Absorb Calculation
00188d28: 00000000 nop
00188d2c: 8fbf0010 lw r31,0x0010(r29)
00188d30: 27bd0018 addiu r29,r29,0x0018
00188d34: 03e00008 jr r31
00188d38: 00000000 nop

[07]
00188d3c: 27bdffe8 addiu r29,r29,0xffe8
00188d40: afbf0010 sw r31,0x0010(r29)
00188d44: 0c0616a7 jal 0x00185a9c      Weapon XA Calculation
00188d48: 00000000 nop
00188d4c: 0c061259 jal 0x00184964      Zodiac Calculation Already covered under weapon XA.
00188d50: 00000000 nop
00188d54: 0c0617e0 jal 0x00185f80      Charge Calculation
00188d58: 00000000 nop
00188d5c: 0c06217e jal 0x001885f8      Zodiac Calculation Already covered under weapon XA.
00188d60: 00000000 nop
00188d64: 0c06195a jal 0x00186568      Healing (Weapon) Potency Calculation Essentially, this is the same coding as the subroutine in 0x188638 but missing the weapon elemental routine.
00188d68: 00000000 nop
00188d6c: 0c061cd4 jal 0x00187350      Healing Calculation
00188d70: 00000000 nop
00188d74: 8fbf0010 lw r31,0x0010(r29)
00188d78: 27bd0018 addiu r29,r29,0x0018
00188d7c: 03e00008 jr r31
00188d80: 00000000 nop

[08]
00188d84: 27bdffe8 addiu r29,r29,0xffe8
00188d88: afbf0010 sw r31,0x0010(r29)
00188d8c: 0c06216e jal 0x001885b8      Magic Evade
00188d90: 00000000 nop
00188d94: 14400013 bne r2,r0,0x00188de4
00188d98: 00000000 nop
00188d9c: 0c061725 jal 0x00185c94      Get Ability Power
00188da0: 00000000 nop
00188da4: 0c0617ff jal 0x00185ffc      Get Elemental Boost
00188da8: 00000000 nop
00188dac: 0c0621d1 jal 0x00188744      Magic XA Modifications
00188db0: 00000000 nop
00188db4: 0c0621df jal 0x0018877c      Magic Damage Calculation
00188db8: 00000000 nop
00188dbc: 14400009 bne r2,r0,0x00188de4
00188dc0: 00000000 nop
00188dc4: 0c061c54 jal 0x00187150      Faith Calculation
00188dc8: 00000000 nop
00188dcc: 0c0621c7 jal 0x0018871c      Elemental Absorption
00188dd0: 00000000 nop
00188dd4: 14400003 bne r2,r0,0x00188de4
00188dd8: 00000000 nop
00188ddc: 0c061fad jal 0x00187eb4      Status
00188de0: 00000000 nop
00188de4: 8fbf0010 lw r31,0x0010(r29)
00188de8: 27bd0018 addiu r29,r29,0x0018
00188dec: 03e00008 jr r31
00188df0: 00000000 nop

[09]
00188df4: 27bdffe8 addiu r29,r29,0xffe8
00188df8: afbf0010 sw r31,0x0010(r29)
00188dfc: 0c06216e jal 0x001885b8      Magic Evade
00188e00: 00000000 nop
00188e04: 14400018 bne r2,r0,0x00188e68
00188e08: 00000000 nop
00188e0c: 0c062289 jal 0x00188a24               Calculate (MA + X)*Faith%?
00188e10: 00000000 nop
00188e14: 14400014 bne r2,r0,0x00188e68
00188e18: 00000000 nop
00188e1c: 0c061989 jal 0x00186624       Calculate damage as % of HP      
00188e20: 00000000 nop
00188e24: 0c061bb4 jal 0x00186ed0       Elemental Weak
00188e28: 00000000 nop
00188e2c: 0c061bfe jal 0x00186ff8      Elemental Cancel
00188e30: 00000000 nop
00188e34: 3c028019 lui r2,0x8019
00188e38: 8c422d90 lw r2,0x2d90(r2)
00188e3c: 00000000 nop
00188e40: 90420000 lbu r2,0x0000(r2)
00188e44: 00000000 nop
00188e48: 10400007 beq r2,r0,0x00188e68
00188e4c: 00000000 nop
00188e50: 0c0621c7 jal 0x0018871c      Elemental Absorb
00188e54: 00000000 nop
00188e58: 14400003 bne r2,r0,0x00188e68
00188e5c: 00000000 nop
00188e60: 0c061fad jal 0x00187eb4      Status
00188e64: 00000000 nop
00188e68: 8fbf0010 lw r31,0x0010(r29)
00188e6c: 27bd0018 addiu r29,r29,0x0018
00188e70: 03e00008 jr r31
00188e74: 00000000 nop

[0a]
00188e78: 27bdffe8 addiu r29,r29,0xffe8
00188e7c: afbf0010 sw r31,0x0010(r29)
00188e80: 0c06216e jal 0x001885b8    Magic Evade
00188e84: 00000000 nop
00188e88: 14400007 bne r2,r0,0x00188ea8
00188e8c: 00000000 nop
00188e90: 0c062289 jal 0x00188a24    Calculates (MA+X)*Faith%?
00188e94: 00000000 nop
00188e98: 14400003 bne r2,r0,0x00188ea8
00188e9c: 00000000 nop
00188ea0: 0c061fc9 jal 0x00187f24     Add Status at (MA+X)*Faith%
00188ea4: 00000000 nop
00188ea8: 8fbf0010 lw r31,0x0010(r29)
00188eac: 27bd0018 addiu r29,r29,0x0018
00188eb0: 03e00008 jr r31
00188eb4: 00000000 nop

[0b]
00188eb8: 27bdffe8 addiu r29,r29,0xffe8
00188ebc: afbf0010 sw r31,0x0010(r29)
00188ec0: 0c061760 jal 0x00185d80   Get X and MA
00188ec4: 00000000 nop
00188ec8: 0c0617ff jal 0x00185ffc      Elemental Boost
00188ecc: 00000000 nop
00188ed0: 0c062200 jal 0x00188800   Calculate (MA + X)*Faith%
This is essentially the same routine as 0x188a24 except without MADEF and Shell.
00188ed4: 00000000 nop
00188ed8: 14400003 bne r2,r0,0x00188ee8
00188edc: 00000000 nop
00188ee0: 0c061fc9 jal 0x00187f24     Add Status at (MA+X)*Faith%
00188ee4: 00000000 nop
00188ee8: 8fbf0010 lw r31,0x0010(r29)
00188eec: 27bd0018 addiu r29,r29,0x0018
00188ef0: 03e00008 jr r31
00188ef4: 00000000 nop

[0c]
00188ef8: 27bdffe8 addiu r29,r29,0xffe8
00188efc: afbf0010 sw r31,0x0010(r29)
00188f00: 0c061725 jal 0x00185c94               Get Ability Power
00188f04: 00000000 nop
00188f08: 0c0617ff jal 0x00185ffc                  Get Elemental Boost
00188f0c: 00000000 nop
00188f10: 0c062216 jal 0x00188858                Healing Calculation This is essentially the same routine as 0x188744 and 0x18877C except without MADEF/Shell/Elemental, even though elemental boost is allowed.
00188f14: 00000000 nop
00188f18: 0c061c54 jal 0x00187150      Faith Calculation
00188f1c: 00000000 nop
00188f20: 0c061cd4 jal 0x00187350      Undead Reversal
00188f24: 00000000 nop
00188f28: 8fbf0010 lw r31,0x0010(r29)
00188f2c: 27bd0018 addiu r29,r29,0x0018
00188f30: 03e00008 jr r31
00188f34: 00000000 nop

[0d]
00188f38: 27bdffe8 addiu r29,r29,0xffe8
00188f3c: afbf0010 sw r31,0x0010(r29)
00188f40: 0c061760 jal 0x00185d80        Get X and MA
00188f44: 00000000 nop
00188f48: 0c0617ff jal 0x00185ffc          Elemental Boost
00188f4c: 00000000 nop
00188f50: 0c062200 jal 0x00188800       Calculate (MA + X)*Faith%
This is essentially the same routine as 0x188a24 except without MADEF and Shell.
00188f54: 00000000 nop
00188f58: 14400009 bne r2,r0,0x00188f80
00188f5c: 00000000 nop
00188f60: 0c062b37 jal 0x0018acdc       Add Status at (MA+X)*Faith%; must add or spell fails.
00188f64: 00000000 nop
00188f68: 10400005 beq r2,r0,0x00188f80
00188f6c: 00000000 nop
00188f70: 0c061989 jal 0x00186624             Calculate damage as % of HP
00188f74: 00000000 nop
00188f78: 0c061cd4 jal 0x00187350             Undead Reversal (Heal = Damage)
00188f7c: 00000000 nop
00188f80: 8fbf0010 lw r31,0x0010(r29)
00188f84: 27bd0018 addiu r29,r29,0x0018
00188f88: 03e00008 jr r31
00188f8c: 00000000 nop

[0e]
00188f90: 3c028019 lui r2,0x8019
00188f94: 8c422d98 lw r2,0x2d98(r2)
00188f98: 27bdffe8 addiu r29,r29,0xffe8
00188f9c: afbf0010 sw r31,0x0010(r29)
00188fa0: 90420058 lbu r2,0x0058(r2)
00188fa4: 00000000 nop
00188fa8: 30420010 andi r2,r2,0x0010
00188fac: 10400005 beq r2,r0,0x00188fc4       Undead Check
00188fb0: 34020001 ori r2,r0,0x0001
00188fb4: 3c018019 lui r1,0x8019
00188fb8: a02238e6 sb r2,0x38e6(r1)             Undead Reverse Flag; target is undead.
00188fbc: 080623f7 j 0x00188fdc
00188fc0: 00000000 nop
00188fc4: 3c018019 lui r1,0x8019
00188fc8: a02038e6 sb r0,0x38e6(r1)             Undead Reverse Flag; target is not undead
00188fcc: 0c06216e jal 0x001885b8               Magic Evade
00188fd0: 00000000 nop
00188fd4: 14400027 bne r2,r0,0x00189074
00188fd8: 00000000 nop
00188fdc: 0c061760 jal 0x00185d80               Get X and MA
00188fe0: 00000000 nop
00188fe4: 0c0617ff jal 0x00185ffc                  Elemental Boost
00188fe8: 00000000 nop
00188fec: 0c061881 jal 0x00186204                MATUP Bonus
00188ff0: 00000000 nop
00188ff4: 3c028019 lui r2,0x8019
00188ff8: 904238e6 lbu r2,0x38e6(r2)
00188ffc: 00000000 nop
00189000: 14400005 bne r2,r0,0x00189018       Branch only if not against undead
00189004: 00000000 nop
00189008: 0c0618c7 jal 0x0018631c                ?
0018900c: 00000000 nop
00189010: 0c061918 jal 0x00186460                ?
00189014: 00000000 nop
00189018: 0c061259 jal 0x00184964                Zodiac Calculation
0018901c: 00000000 nop
00189020: 0c061967 jal 0x0018659c               Sets MA + X as X
00189024: 00000000 nop
00189028: 0c061c54 jal 0x00187150      Faith Calculation
0018902c: 00000000 nop
00189030: 0c061d44 jal 0x00187510               Total Accuracy Check?
00189034: 00000000 nop
00189038: 3c028019 lui r2,0x8019
0018903c: 8c422d90 lw r2,0x2d90(r2)
00189040: 00000000 nop
00189044: 90420000 lbu r2,0x0000(r2)
00189048: 00000000 nop
0018904c: 10400009 beq r2,r0,0x00189074
00189050: 00000000 nop
00189054: 0c062b37 jal 0x0018acdc        Add Status at (MA+X)*Faith%; must add or spell fails.
00189058: 00000000 nop
0018905c: 10400005 beq r2,r0,0x00189074
00189060: 00000000 nop
00189064: 0c061989 jal 0x00186624           Calculate Damage as % of HP
00189068: 00000000 nop
0018906c: 0c061cf6 jal 0x001873d8           Undead Reversal (Damage = Healing)
00189070: 00000000 nop
00189074: 8fbf0010 lw r31,0x0010(r29)
00189078: 27bd0018 addiu r29,r29,0x0018
0018907c: 03e00008 jr r31
00189080: 00000000 nop

[0f]
00189084: 27bdffe8 addiu r29,r29,0xffe8
00189088: afbf0010 sw r31,0x0010(r29)
0018908c: 0c06216e jal 0x001885b8            Magic Evade
00189090: 00000000 nop
00189094: 1440000d bne r2,r0,0x001890cc
00189098: 00000000 nop
0018909c: 0c062273 jal 0x001889cc           Calculate (MA + X)*Faith% This is essentially the same routine as 0x188a24 except without elemental boosting.
001890a0: 00000000 nop
001890a4: 14400009 bne r2,r0,0x001890cc
001890a8: 00000000 nop
001890ac: 0c0619a3 jal 0x0018668c           MP Damage
001890b0: 00000000 nop
001890b4: 3c038019 lui r3,0x8019
001890b8: 8c632d90 lw r3,0x2d90(r3)
001890bc: 00000000 nop
001890c0: 94620008 lhu r2,0x0008(r3)
001890c4: 0c061d1b jal 0x0018746c           MP Healing
001890c8: a4620004 sh r2,0x0004(r3)
001890cc: 8fbf0010 lw r31,0x0010(r29)
001890d0: 27bd0018 addiu r29,r29,0x0018
001890d4: 03e00008 jr r31
001890d8: 00000000 nop

[10]
001890dc: 27bdffe8 addiu r29,r29,0xffe8
001890e0: afbf0010 sw r31,0x0010(r29)
001890e4: 0c06216e jal 0x001885b8            Magic Evade
001890e8: 00000000 nop
001890ec: 14400009 bne r2,r0,0x00189114
001890f0: 00000000 nop
001890f4: 0c062273 jal 0x001889cc            Calculate (MA + X)*Faith% This is essentially the same routine as 0x188a24 except without elemental boosting.
001890f8: 00000000 nop
001890fc: 14400005 bne r2,r0,0x00189114
00189100: 00000000 nop
00189104: 0c061989 jal 0x00186624     Calculate damage as % of HP  
00189108: 00000000 nop
0018910c: 0c061c92 jal 0x00187248     Absorption Calculation
00189110: 00000000 nop
00189114: 8fbf0010 lw r31,0x0010(r29)
00189118: 27bd0018 addiu r29,r29,0x0018
0018911c: 03e00008 jr r31
00189120: 00000000 nop

[11]
00189124: 03e00008 jr r31
00189128: 00000000 nop
 Does not work.

[12]
0018912c: 27bdffe8 addiu r29,r29,0xffe8
00189130: afbf0010 sw r31,0x0010(r29)
00189134: 0c061760 jal 0x00185d80   Get X and MA
00189138: 00000000 nop
0018913c: 0c062200 jal 0x00188800   Calculate (MA + X)*Faith%
This is essentially the same as 0x188a24 except without elemental boosting, shell, or MADEF.
00189140: 00000000 nop
00189144: 14400003 bne r2,r0,0x00189154
00189148: 00000000 nop
0018914c: 0c061e0f jal 0x0018783c   Quick Effect
00189150: 00000000 nop
00189154: 8fbf0010 lw r31,0x0010(r29)
00189158: 27bd0018 addiu r29,r29,0x0018
0018915c: 03e00008 jr r31
00189160: 00000000 nop

[13]
00189164: 03e00008 jr r31
00189168: 00000000 nop
 Doesn't work.

[14]
0018916c: 27bdffe8 addiu r29,r29,0xffe8
00189170: afbf0010 sw r31,0x0010(r29)
00189174: 0c062222 jal 0x00188888     Calculate Accuracy as User Faith * (MA + X)%
00189178: 00000000 nop
0018917c: 14400007 bne r2,r0,0x0018919c
00189180: 34030001 ori r3,r0,0x0001
00189184: 3c028019 lui r2,0x8019
00189188: 8c422d90 lw r2,0x2d90(r2)
0018918c: 00000000 nop
00189190: a4430010 sh r3,0x0010(r2)   Set status as golem
00189194: 34030001 ori r3,r0,0x0001
00189198: a0430025 sb r3,0x0025(r2)    Set damage type to Pseudo-Status
0018919c: 8fbf0010 lw r31,0x0010(r29)
001891a0: 27bd0018 addiu r29,r29,0x0018
001891a4: 03e00008 jr r31
001891a8: 00000000 nop

[15]
001891ac: 27bdffe8 addiu r29,r29,0xffe8
001891b0: afbf0010 sw r31,0x0010(r29)
001891b4: 0c06216e jal 0x001885b8      Magic Evade
001891b8: 00000000 nop
001891bc: 1440000d bne r2,r0,0x001891f4
001891c0: 00000000 nop
001891c4: 0c062273 jal 0x001889cc      Calculate (MA + X)*Faith% This is essentially the same routine as 0x188a24 except without elemental boosting.
001891c8: 00000000 nop
001891cc: 14400009 bne r2,r0,0x001891f4
001891d0: 3402007f ori r2,r0,0x007f
001891d4: 3c038019 lui r3,0x8019
001891d8: 8c632d90 lw r3,0x2d90(r3)
001891dc: 00000000 nop
001891e0: a0620013 sb r2,0x0013(r3)  Set target CT to -127.
001891e4: 3c038019 lui r3,0x8019
001891e8: 8c632d90 lw r3,0x2d90(r3)
001891ec: 34020001 ori r2,r0,0x0001
001891f0: a0620025 sb r2,0x0025(r3)  Set damage type to Pseudo-Status
001891f4: 8fbf0010 lw r31,0x0010(r29)
001891f8: 27bd0018 addiu r29,r29,0x0018
001891fc: 03e00008 jr r31
00189200: 00000000 nop

[16]
00189204: 27bdffe8 addiu r29,r29,0xffe8
00189208: afbf0010 sw r31,0x0010(r29)
0018920c: 0c06216e jal 0x001885b8  Magic Evade
00189210: 00000000 nop
00189214: 1440000d bne r2,r0,0x0018924c
00189218: 00000000 nop
0018921c: 0c062273 jal 0x001889cc  Calculate (MA + X)*Faith% This is essentially the same routine as 0x188a24 except without elemental boosting.
00189220: 00000000 nop
00189224: 14400009 bne r2,r0,0x0018924c
00189228: 00000000 nop
0018922c: 3c028019 lui r2,0x8019
00189230: 8c422d98 lw r2,0x2d98(r2)
00189234: 3c038019 lui r3,0x8019
00189238: 8c632d90 lw r3,0x2d90(r3)
0018923c: 9444002c lhu r4,0x002c(r2)  Load CurMP
00189240: 34020020 ori r2,r0,0x0020
00189244: a0620025 sb r2,0x0025(r3)  Set damage type as MP Damage
00189248: a4640008 sh r4,0x0008(r3)  Load as MP damage
0018924c: 8fbf0010 lw r31,0x0010(r29)
00189250: 27bd0018 addiu r29,r29,0x0018
00189254: 03e00008 jr r31
00189258: 00000000 nop

[17]
0018925c: 27bdffe8 addiu r29,r29,0xffe8
00189260: afbf0010 sw r31,0x0010(r29)
00189264: 0c06216e jal 0x001885b8   Magic Evade
00189268: 00000000 nop
0018926c: 14400007 bne r2,r0,0x0018928c
00189270: 00000000 nop
00189274: 0c062273 jal 0x001889cc    Calculate (MA + X)*Faith% This is essentially the same routine as 0x188a24 except without elemental boosting.
00189278: 00000000 nop
0018927c: 14400003 bne r2,r0,0x0018928c
00189280: 00000000 nop
00189284: 0c0619bb jal 0x001866ec  Gravi2 Damage Routine
00189288: 00000000 nop
0018928c: 8fbf0010 lw r31,0x0010(r29)
00189290: 27bd0018 addiu r29,r29,0x0018
00189294: 03e00008 jr r31
00189298: 00000000 nop

[18]
0018929c: 03e00008 jr r31
001892a0: 00000000 nop
Doesn't work

[19]
001892a4: 03e00008 jr r31
001892a8: 00000000 nop
Doesn't work

[1a]
001892ac: 27bdffe8 addiu r29,r29,0xffe8
001892b0: afbf0010 sw r31,0x0010(r29)
001892b4: 0c06216e jal 0x001885b8    Magic Evade
001892b8: 00000000 nop
001892bc: 1440001b bne r2,r0,0x0018932c
001892c0: 00000000 nop
001892c4: 0c061725 jal 0x00185c94    Get Ability Power
001892c8: 00000000 nop
001892cc: 0c0617ff jal 0x00185ffc       Elemental Boost
001892d0: 00000000 nop
001892d4: 0c0621d1 jal 0x00188744      Magic XA Modifications
001892d8: 00000000 nop
001892dc: 0c061967 jal 0x0018659c               Set MA + X as X
001892e0: 00000000 nop
001892e4: 0c061c54 jal 0x00187150      Faith Calculation
001892e8: 00000000 nop
001892ec: 0c061d44 jal 0x00187510               Total Accuracy Calculation?
001892f0: 00000000 nop
001892f4: 3c038019 lui r3,0x8019
001892f8: 8c632d90 lw r3,0x2d90(r3)
001892fc: 00000000 nop
00189300: 90620000 lbu r2,0x0000(r3)
00189304: 00000000 nop
00189308: 14400006 bne r2,r0,0x00189324
0018930c: 00000000 nop
00189310: 94620010 lhu r2,0x0010(r3)
00189314: 00000000 nop
00189318: 3042fffb andi r2,r2,0xfffb
0018931c: 080624cb j 0x0018932c
00189320: a4620010 sh r2,0x0010(r3)   Do not allow absorption.
00189324: 0c061e18 jal 0x00187860     Determine which stat (PA/MA/SP) is reduced, Spell Slot Hard-Code Routine
00189328: 00000000 nop
0018932c: 8fbf0010 lw r31,0x0010(r29)
00189330: 27bd0018 addiu r29,r29,0x0018
00189334: 03e00008 jr r31
00189338: 00000000 nop

[1b]
0018933c: 27bdffe8 addiu r29,r29,0xffe8
00189340: afbf0010 sw r31,0x0010(r29)
00189344: 0c06216e jal 0x001885b8    Magic Evade
00189348: 00000000 nop
0018934c: 14400007 bne r2,r0,0x0018936c
00189350: 00000000 nop
00189354: 0c062289 jal 0x00188a24   (MA + X)*Faith%
00189358: 00000000 nop
0018935c: 14400003 bne r2,r0,0x0018936c
00189360: 00000000 nop
00189364: 0c0619a3 jal 0x0018668c   MP Damage
00189368: 00000000 nop
0018936c: 8fbf0010 lw r31,0x0010(r29)
00189370: 27bd0018 addiu r29,r29,0x0018
00189374: 03e00008 jr r31
00189378: 00000000 nop

[1c]
0018937c: 27bdffe8 addiu r29,r29,0xffe8
00189380: afbf0010 sw r31,0x0010(r29)
00189384: 0c061d7f jal 0x001875fc   Sleep Check
00189388: 00000000 nop
0018938c: 3c028019 lui r2,0x8019
00189390: 8c422d90 lw r2,0x2d90(r2)
00189394: 00000000 nop
00189398: 90420000 lbu r2,0x0000(r2)
0018939c: 00000000 nop
001893a0: 10400009 beq r2,r0,0x001893c8
001893a4: 00000000 nop
001893a8: 0c0610d8 jal 0x00184360    Skill-Set Hard Coding
001893ac: 00000000 nop
001893b0: 14400005 bne r2,r0,0x001893c8
001893b4: 00000000 nop
001893b8: 0c061725 jal 0x00185c94    Get Ability Power
001893bc: 00000000 nop
001893c0: 0c061a7b jal 0x001869ec    Magic/Angel Song
001893c4: 00000000 nop
001893c8: 8fbf0010 lw r31,0x0010(r29)
001893cc: 27bd0018 addiu r29,r29,0x0018
001893d0: 03e00008 jr r31
001893d4: 00000000 nop

[1d]
001893d8: 27bdffe8 addiu r29,r29,0xffe8
001893dc: afbf0010 sw r31,0x0010(r29)
001893e0: 0c061d7f jal 0x001875fc    Sleep Check
001893e4: 00000000 nop
001893e8: 3c028019 lui r2,0x8019
001893ec: 8c422d90 lw r2,0x2d90(r2)
001893f0: 00000000 nop
001893f4: 90420000 lbu r2,0x0000(r2)
001893f8: 00000000 nop
001893fc: 10400009 beq r2,r0,0x00189424
00189400: 00000000 nop
00189404: 0c0610d8 jal 0x00184360       Skill-Set Hard Coding
00189408: 00000000 nop
0018940c: 14400005 bne r2,r0,0x00189424
00189410: 00000000 nop
00189414: 0c0616a7 jal 0x00185a9c      Weapon XA Calculation
00189418: 00000000 nop
0018941c: 0c061abe jal 0x00186af8                Wiznaibus/Witch Hunt Formula
00189420: 00000000 nop
00189424: 8fbf0010 lw r31,0x0010(r29)
00189428: 27bd0018 addiu r29,r29,0x0018
0018942c: 03e00008 jr r31
00189430: 00000000 nop

[1e]
00189434: 27bdffe8 addiu r29,r29,0xffe8
00189438: afbf0010 sw r31,0x0010(r29)
0018943c: 0c06216e jal 0x001885b8   Magic Evade
00189440: 00000000 nop
00189444: 14400003 bne r2,r0,0x00189454
00189448: 00000000 nop
0018944c: 0c062269 jal 0x001889a4   Truth Formula
00189450: 00000000 nop
00189454: 8fbf0010 lw r31,0x0010(r29)
00189458: 27bd0018 addiu r29,r29,0x0018
0018945c: 03e00008 jr r31
00189460: 00000000 nop

[1f]
00189464: 27bdffe8 addiu r29,r29,0xffe8
00189468: afbf0010 sw r31,0x0010(r29)
0018946c: 0c06216e jal 0x001885b8   Magic Evade
00189470: 00000000 nop
00189474: 1440004f bne r2,r0,0x001895b4
00189478: 00000000 nop
0018947c: 0c061730 jal 0x00185cc0               Set (MA + Y) / 2 as Y
00189480: 00000000 nop
00189484: 0c0617ff jal 0x00185ffc                 Elemental Boost
00189488: 00000000 nop
0018948c: 0c0621d1 jal 0x00188744      Magic XA Modifications
00189490: 00000000 nop
00189494: 0c0621df jal 0x0018877c      Magic Damage Calculation
00189498: 00000000 nop
0018949c: 14400045 bne r2,r0,0x001895b4
001894a0: 00000000 nop
001894a4: 3c028019 lui r2,0x8019
001894a8: 8c422d94 lw r2,0x2d94(r2)
001894ac: 00000000 nop
001894b0: 9042005c lbu r2,0x005c(r2)
001894b4: 00000000 nop
001894b8: 30420080 andi r2,r2,0x0080
001894bc: 10400003 beq r2,r0,0x001894cc
001894c0: 00000000 nop
001894c4: 3c018019 lui r1,0x8019
001894c8: a02038d3 sb r0,0x38d3(r1)          Faith sets your faith to 0. (Bug)
001894cc: 3c028019 lui r2,0x8019
001894d0: 8c422d94 lw r2,0x2d94(r2)            
001894d4: 00000000 nop
001894d8: 9042005c lbu r2,0x005c(r2)
001894dc: 00000000 nop
001894e0: 30420040 andi r2,r2,0x0040
001894e4: 10400003 beq r2,r0,0x001894f4
001894e8: 34020064 ori r2,r0,0x0064
001894ec: 3c018019 lui r1,0x8019
001894f0: a02238d3 sb r2,0x38d3(r1)         Innocent sets your faith to 100. (Bug)
001894f4: 3c028019 lui r2,0x8019
001894f8: 8c422d98 lw r2,0x2d98(r2)
001894fc: 00000000 nop
00189500: 9042005c lbu r2,0x005c(r2)
00189504: 00000000 nop
00189508: 30420080 andi r2,r2,0x0080
0018950c: 10400003 beq r2,r0,0x0018951c
00189510: 00000000 nop
00189514: 3c018019 lui r1,0x8019
00189518: a02038d2 sb r0,0x38d2(r1)         Faith sets enemy faith to 0. (Bug)
0018951c: 3c028019 lui r2,0x8019
00189520: 8c422d98 lw r2,0x2d98(r2)
00189524: 00000000 nop
00189528: 9042005c lbu r2,0x005c(r2)
0018952c: 00000000 nop
00189530: 30420040 andi r2,r2,0x0040
00189534: 10400004 beq r2,r0,0x00189548
00189538: 34030064 ori r3,r0,0x0064
0018953c: 34020064 ori r2,r0,0x0064
00189540: 3c018019 lui r1,0x8019
00189544: a02238d2 sb r2,0x38d2(r1)          Innocent sets enemy faith to 100.  (Bug)
00189548: 3c058019 lui r5,0x8019               If no one has status...begin here.
0018954c: 8ca52d90 lw r5,0x2d90(r5)
00189550: 3c028019 lui r2,0x8019
00189554: 904238d2 lbu r2,0x38d2(r2)
00189558: 84a40004 lh r4,0x0004(r5)
0018955c: 00621023 subu r2,r3,r2
00189560: 00820018 mult r4,r2
00189564: 3c028019 lui r2,0x8019
00189568: 904238d3 lbu r2,0x38d3(r2)
0018956c: 00002012 mflo r4
00189570: 00621823 subu r3,r3,r2
00189574: 00000000 nop
00189578: 00830018 mult r4,r3          
0018957c: 00001812 mflo r3            
00189580: 3c0268db lui r2,0x68db
00189584: 34428bad ori r2,r2,0x8bad
00189588: 00620018 mult r3,r2
0018958c: 00031fc3 sra r3,r3,0x1f
00189590: 00001010 mfhi r2
00189594: 00021303 sra r2,r2,0x0c
00189598: 00431023 subu r2,r2,r3
0018959c: 0c0621c7 jal 0x0018871c          Elemental Absorption
001895a0: a4a20004 sh r2,0x0004(r5)        Final Damage
001895a4: 14400003 bne r2,r0,0x001895b4
001895a8: 00000000 nop
001895ac: 0c061fad jal 0x00187eb4            Status Calculation
001895b0: 00000000 nop
001895b4: 8fbf0010 lw r31,0x0010(r29)
001895b8: 27bd0018 addiu r29,r29,0x0018
001895bc: 03e00008 jr r31
001895c0: 00000000 nop
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Vanya on January 06, 2011, 06:59:53 pm
So 05 is a duplicate of 01?
And what about 00 is that also the same as 01 or is it empty?
0E? Seriously? There HAS got to be a more efficient way of applying a Death status.
Not to mention that no other ability uses this formula, so did it really need to be that complex?
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on January 06, 2011, 07:50:03 pm
05 is not only a duplicate of 01, but is missing features, like elemental, and is redundant (Charge is added when it's already considered under physical damage).
Formula 00 is not actually listed in the offset table, so I presume the game auto-loads 01 if you select 00, but I haven't tested it.
As for 0E, let's remember that it can apply any status; the reason for the large space is because SQUARE decided to add everything from a standard (MA+X)*Faith% routine, a % Damage routine, and a must cast status or fail routine, while interspersing in special routines that run only when undead.  However, this is still unacceptable coding, considering that a similar routine for Life Drain exists, reverses against the undead, and wastes far less space.

I'll soon post the next 0x20 formulas or so.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: pokeytax on January 06, 2011, 08:13:41 pm
This is a good plan, I will help out.

As far as space goes, I don't know how much we have - for all I know my learning hack is in the middle of game code. But a high priority would be rewriting FFTorgASM so that jumps are dynamic - count the lines in allocated space for each hack and write the jumps accordingly. Right now every hack ever written is effectively taking up ASM space...
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on January 10, 2011, 07:04:02 am
There was no need to delete Vanya's request for a customizable CT function.  That's actually a very good idea and would save the space of two other functions.  We'll reintroduce the idea, but in spoilers, since this isn't the main focus of this thread:

Change Formula 15 to Set CT to Y, at (MA + X)*Faith% chance


Pokeytax, I'm not so sure that's as easy as it sounds; last I remember, Razele and Xifanie said that there wasn't much free memory to begin with.  Pretty much every data file with ASM commands without a Japanese Character map (everything but BATTLE.BIN and WORLD.BIN, I think) have no free space unless you reorganize the file.  Potentially, there are sections of "free space" in unit data, but unless you're going to write in delete routines for entire custom functions, it's not really worth it (nor even predictable what will and won't be zero).
We currently also a face an understanding problem.  We don't know where in the overall battle loop data is added and specific data erased and rewritten yet (especially involving offsets outside of BATTLE.BIN).  Hence, we don't want to jump stuff to "free space" only to find that it's part of the sound file or something like that.
Most of our mechanics hacks will involve BATTLE.BIN.  Reorganizing BATTLE.BIN would free up space as well, so I'd rather exhaust that before we think about this.

Oh, and before I forget, here's some more general locations.  In general, everything after unit RAM is instructions for FFT's AI.  Again, this is RAM, so subtract 0x67000 for BATTLE.BIN offsets.  Note, the following is not tested or documented very well.

Table of Offsets from 0x193D48-E4F
1959D4 (Throw Item)
195A30 (Something to do with moving?)
195BBC (?)
195C00 (?)
195A24 (?)
195944 (?)
195A90 (CTR calculation for spells)
195BA0 (?)
198578 (?)
1985F8 (?)
19870C (Checks r2 for 1 or -1 at beginning, ELSE, proceed to bottom routines...stuff for positive or negative status, maybe?)
198748 (?)
198788 (?...very similar to above...one's for damage, the other healing?)
1987C0 (?...very similar to above...this one's for pseudo-status?)
1986A0 (Goes into routine 0x19870C but inputs different variables)
1992E8 (Blood Suck)
199240 (All routines that go to the same place as Blood Suck...telling the AI know unit is KO'd?)
199288 (Check something?  Increment r18 by 1 to check 21 times.)
1992FC (AI Routine for crystal/treasure?)
1992A0 (More routines that go to the same place as Blood Suck)
199214 (Check something different?  Increment r18 by 1 to check 21 times.)
19B0B8 (?)
19B100 (?...very similar to above...again, there's a check for -1 that voids the routine)
19B160 (?...very similar to above...again, there's a check for -1 that voids the routine)
19B1CC (?)
19B240 (?)
19B2C0 (?)
19B068 (?...leads into 0x190B8 but with 2 extra checks, with a check for -1 that voids the routine)
19AF74 (?...leads into previous routine but loads a random number...something to do with decision making?)
19B094 (The second check of 0x19B068)
19D8EC (Multiplies X? with r4 for CT?)
19D91C (AI on CT effects like slow/stop and sleep/don't move/don't act)
19D8F8 (Multiplies Y? with r4 for CT?)
19D978 (CT effects' AI)
19D950 (AI for control effects like Blood Suck/Confuse/Charm...my AI hack for Invite probably also needs to edit this or the AI won't use invite the way he uses charm...0x19D974 touches something important?)


Here's the next 0x20 formulas.  I have finally finished documenting [38].


[20]
001895c4: 27bdffe8 addiu r29,r29,0xffe8
001895c8: afbf0010 sw r31,0x0010(r29)
001895cc: 0c061e44 jal 0x00187910      Katana Break Calculation
001895d0: 00000000 nop
001895d4: 0c061725 jal 0x00185c94      Load Ability Power
001895d8: 00000000 nop
001895dc: 0c062259 jal 0x00188964      Calculate MA*Y Damage
001895e0: 00000000 nop
001895e4: 8fbf0010 lw r31,0x0010(r29)
001895e8: 27bd0018 addiu r29,r29,0x0018
001895ec: 03e00008 jr r31
001895f0: 00000000 nop

[21]
001895f4: 27bdffe8 addiu r29,r29,0xffe8
001895f8: afbf0010 sw r31,0x0010(r29)
001895fc: 0c061e44 jal 0x00187910      Katana Break Calculation
00189600: 00000000 nop
00189604: 0c061725 jal 0x00185c94      Load Ability Power
00189608: 00000000 nop
0018960c: 0c0621d1 jal 0x00188744      Magic XA Modifications
00189610: 00000000 nop
00189614: 3c038019 lui r3,0x8019
00189618: 946338ce lhu r3,0x38ce(r3)
0018961c: 3c028019 lui r2,0x8019
00189620: 944238d0 lhu r2,0x38d0(r2)
00189624: 00000000 nop
00189628: 00620018 mult r3,r2
0018962c: 3c038019 lui r3,0x8019
00189630: 8c632d90 lw r3,0x2d90(r3)
00189634: 34020020 ori r2,r0,0x0020      Set as MP Damage
00189638: a0620025 sb r2,0x0025(r3)
0018963c: 00001012 mflo r2
00189640: a4620008 sh r2,0x0008(r3)      Load MP Damage
00189644: 8fbf0010 lw r31,0x0010(r29)
00189648: 27bd0018 addiu r29,r29,0x0018
0018964c: 03e00008 jr r31
00189650: 00000000 nop

[22]
00189654: 27bdffe8 addiu r29,r29,0xffe8
00189658: afbf0010 sw r31,0x0010(r29)
0018965c: 0c061e44 jal 0x00187910      Katana Break Calculation
00189660: 00000000 nop
00189664: 0c061fc9 jal 0x00187f24      Proc Status at 100% since there's no accuracy modifier
00189668: 00000000 nop
0018966c: 8fbf0010 lw r31,0x0010(r29)
00189670: 27bd0018 addiu r29,r29,0x0018
00189674: 03e00008 jr r31
00189678: 00000000 nop

[23]
0018967c: 27bdffe8 addiu r29,r29,0xffe8
00189680: afbf0010 sw r31,0x0010(r29)
00189684: 0c061e44 jal 0x00187910      Katana Break Calculation
00189688: 00000000 nop
0018968c: 0c061725 jal 0x00185c94      Load Ability Power
00189690: 00000000 nop
00189694: 0c06195a jal 0x00186568      Calculate Healing (Use standard weapon formula instead)
00189698: 00000000 nop
0018969c: 0c061cd4 jal 0x00187350      Undead Reversal
001896a0: 00000000 nop
001896a4: 8fbf0010 lw r31,0x0010(r29)
001896a8: 27bd0018 addiu r29,r29,0x0018
001896ac: 03e00008 jr r31
001896b0: 00000000 nop

[24]
001896b4: 27bdffe8 addiu r29,r29,0xffe8
001896b8: afbf0010 sw r31,0x0010(r29)
001896bc: 0c06216e jal 0x001885b8      Magic Evade
001896c0: 00000000 nop
001896c4: 14400005 bne r2,r0,0x001896dc
001896c8: 00000000 nop
001896cc: 0c061750 jal 0x00185d40      Set (PA + Y ) / 2 as Y
001896d0: 00000000 nop
001896d4: 0c062259 jal 0x00188964      Calculate MA*Y with status.
001896d8: 00000000 nop
001896dc: 8fbf0010 lw r31,0x0010(r29)
001896e0: 27bd0018 addiu r29,r29,0x0018
001896e4: 03e00008 jr r31
001896e8: 00000000 nop

[25]
001896ec: 27bdffe8 addiu r29,r29,0xffe8
001896f0: afbf0010 sw r31,0x0010(r29)
001896f4: 0c061e72 jal 0x001879c8      Skill Slot Hard-Coding BREAK/STEAL/MIGHTY SWORD
001896f8: 00000000 nop
001896fc: 10400007 beq r2,r0,0x0018971c
00189700: 34020001 ori r2,r0,0x0001
00189704: 3c018019 lui r1,0x8019
00189708: a02238e9 sb r2,0x38e9(r1)
0018970c: 0c062b56 jal 0x0018ad58      Double WP if has TWO HANDS
00189710: 00000000 nop
00189714: 080625e1 j 0x00189784
00189718: 00000000 nop
0018971c: 3c018019 lui r1,0x8019
00189720: a02038e9 sb r0,0x38e9(r1)
00189724: 0c062144 jal 0x00188510      Physical Evade Calculation
00189728: 00000000 nop
0018972c: 14400015 bne r2,r0,0x00189784
00189730: 00000000 nop
00189734: 0c061797 jal 0x00185e5c      Load WP + Y as Y
00189738: 00000000 nop
0018973c: 0c0621b5 jal 0x001886d4      Load (PA + Y)%
00189740: 00000000 nop
00189744: 10400005 beq r2,r0,0x0018975c
00189748: 00000000 nop
0018974c: 3c028019 lui r2,0x8019
00189750: 8c422d90 lw r2,0x2d90(r2)
00189754: 080625e1 j 0x00189784
00189758: a4400010 sh r0,0x0010(r2)
0018975c: 0c061d8e jal 0x00187638      Maintenance Check
00189760: 00000000 nop
00189764: 3c038019 lui r3,0x8019
00189768: 8c632d90 lw r3,0x2d90(r3)
0018976c: 00000000 nop
00189770: 90620000 lbu r2,0x0000(r3)
00189774: 00000000 nop
00189778: 10400002 beq r2,r0,0x00189784
0018977c: 34020004 ori r2,r0,0x0004
00189780: a4620010 sh r2,0x0010(r3)
00189784: 8fbf0010 lw r31,0x0010(r29)
00189788: 27bd0018 addiu r29,r29,0x0018
0018978c: 03e00008 jr r31
00189790: 00000000 nop

[26]
00189794: 27bdffe8 addiu r29,r29,0xffe8
00189798: afbf0010 sw r31,0x0010(r29)
0018979c: 0c061e72 jal 0x001879c8      Skill Slot Hard-Coding BREAK/STEAL/MIGHTY SWORD
001897a0: 00000000 nop
001897a4: 10400008 beq r2,r0,0x001897c8
001897a8: 00000000 nop
001897ac: 0c061390 jal 0x00184e40      If fail, set stuff to 0 (Made redundant by above branch statement.)
001897b0: 00000000 nop
001897b4: 3c038019 lui r3,0x8019
001897b8: 8c632d90 lw r3,0x2d90(r3)
001897bc: 34020007 ori r2,r0,0x0007
001897c0: 08062606 j 0x00189818
001897c4: a0620002 sb r2,0x0002(r3)
001897c8: 0c062144 jal 0x00188510      Physical Evade Calculation
001897cc: 00000000 nop
001897d0: 14400011 bne r2,r0,0x00189818
001897d4: 00000000 nop
001897d8: 0c06178c jal 0x00185e30      Load SP and X
001897dc: 00000000 nop
001897e0: 0c0622c5 jal 0x00188b14      Hit Chance Calculation (Contains superfluous checks for berserk and frog on the user when the user can't use this while berserk or frogged.)
001897e4: 00000000 nop
001897e8: 1440000b bne r2,r0,0x00189818
001897ec: 00000000 nop
001897f0: 0c061d8e jal 0x00187638      Maintenance Check
001897f4: 00000000 nop
001897f8: 3c038019 lui r3,0x8019
001897fc: 8c632d90 lw r3,0x2d90(r3)
00189800: 00000000 nop
00189804: 90620000 lbu r2,0x0000(r3)
00189808: 00000000 nop
0018980c: 10400002 beq r2,r0,0x00189818
00189810: 34020010 ori r2,r0,0x0010
00189814: a4620010 sh r2,0x0010(r3)
00189818: 8fbf0010 lw r31,0x0010(r29)
0018981c: 27bd0018 addiu r29,r29,0x0018
00189820: 03e00008 jr r31
00189824: 00000000 nop

[27]
00189828: 27bdffe8 addiu r29,r29,0xffe8
0018982c: afbf0010 sw r31,0x0010(r29)
00189830: 0c062144 jal 0x00188510      Physical Evade Calculation
00189834: 00000000 nop
00189838: 14400009 bne r2,r0,0x00189860
0018983c: 00000000 nop
00189840: 0c06178c jal 0x00185e30      Load SP and X
00189844: 00000000 nop
00189848: 0c0622c5 jal 0x00188b14      Hit Chance Calculation (Contains superfluous checks for berserk and frog on the user when the user can't use this while berserk or frogged.)
0018984c: 00000000 nop
00189850: 14400003 bne r2,r0,0x00189860
00189854: 00000000 nop
00189858: 0c0619d1 jal 0x00186744      Steal Gil Effect
0018985c: 00000000 nop
00189860: 8fbf0010 lw r31,0x0010(r29)
00189864: 27bd0018 addiu r29,r29,0x0018
00189868: 03e00008 jr r31
0018986c: 00000000 nop

[28]
00189870: 27bdffe8 addiu r29,r29,0xffe8
00189874: afbf0010 sw r31,0x0010(r29)
00189878: 0c062144 jal 0x00188510      Physical Evade Calculation
0018987c: 00000000 nop
00189880: 1440001f bne r2,r0,0x00189900
00189884: 00000000 nop
00189888: 0c06178c jal 0x00185e30      Load SP and X
0018988c: 00000000 nop
00189890: 0c061853 jal 0x0018614c      ATTACK UP/Martial Arts Check
00189894: 00000000 nop
00189898: 0c061895 jal 0x00186254      Berserk/Frog Check
0018989c: 00000000 nop
001898a0: 0c0618b3 jal 0x001862cc      Defense UP Check
001898a4: 00000000 nop
001898a8: 0c0618db jal 0x0018636c      Protect Check
001898ac: 00000000 nop
001898b0: 0c061259 jal 0x00184964      Zodiac Calculation
001898b4: 00000000 nop
001898b8: 0c061967 jal 0x0018659c      (SP + X)% Hit
001898bc: 00000000 nop
001898c0: 0c061d44 jal 0x00187510      Total Accuracy Check
(Exactly the same as jal 0x188b14.)
001898c4: 00000000 nop
001898c8: 3c028019 lui r2,0x8019
001898cc: 8c422d90 lw r2,0x2d90(r2)
001898d0: 00000000 nop
001898d4: 90420000 lbu r2,0x0000(r2)
001898d8: 00000000 nop
001898dc: 14400006 bne r2,r0,0x001898f8
001898e0: 00000000 nop
001898e4: 3c028019 lui r2,0x8019
001898e8: 8c42f5fc lw r2,-0x0a04(r2)
001898ec: 00000000 nop
001898f0: 10400003 beq r2,r0,0x00189900      STatus Inflict Check
(The previous branch statement is an evasion check.  If this branch is not an evasion check, it can circumvent the previous one.  If it checks evasion, it is redundant.)
001898f4: 00000000 nop
001898f8: 0c061a05 jal 0x00186814      Set EXP Stolen
001898fc: 00000000 nop
00189900: 8fbf0010 lw r31,0x0010(r29)
00189904: 27bd0018 addiu r29,r29,0x0018
00189908: 03e00008 jr r31
0018990c: 00000000 nop

[29]
00189910: 27bdffe8 addiu r29,r29,0xffe8
00189914: afbf0010 sw r31,0x0010(r29)
00189918: 0c061760 jal 0x00185d80      Load MA and X
0018991c: 00000000 nop
00189920: 0c061259 jal 0x00184964      Zodiac Calculation
00189924: 00000000 nop
00189928: 0c061967 jal 0x0018659c      (MA + X)% Hit
0018992c: 00000000 nop
00189930: 0c061d44 jal 0x00187510      Final Accuracy Check
00189934: 00000000 nop
00189938: 3c028019 lui r2,0x8019
0018993c: 8c422d90 lw r2,0x2d90(r2)
00189940: 00000000 nop
00189944: 90420000 lbu r2,0x0000(r2)
00189948: 00000000 nop
0018994c: 10400011 beq r2,r0,0x00189994
00189950: 00000000 nop
00189954: 3c028019 lui r2,0x8019
00189958: 8c422d98 lw r2,0x2d98(r2)
0018995c: 3c048019 lui r4,0x8019
00189960: 8c842d94 lw r4,0x2d94(r4)
00189964: 90430006 lbu r3,0x0006(r2)
00189968: 90820006 lbu r2,0x0006(r4)
0018996c: 306300e0 andi r3,r3,0x00e0
00189970: 304200e0 andi r2,r2,0x00e0
00189974: 14620005 bne r3,r2,0x0018998c
00189978: 00000000 nop
0018997c: 0c0610c3 jal 0x0018430c      ELSE, MISS Routine (Except for graphics, this just wastes space.)
00189980: 00000000 nop
00189984: 08062665 j 0x00189994
00189988: 00000000 nop
0018998c: 0c061fc9 jal 0x00187f24      Inflict Status at (MA + X)%
00189990: 00000000 nop
00189994: 8fbf0010 lw r31,0x0010(r29)
00189998: 27bd0018 addiu r29,r29,0x0018
0018999c: 03e00008 jr r31
001899a0: 00000000 nop

[2a]
001899a4: 27bdffe8 addiu r29,r29,0xffe8
001899a8: afbf0010 sw r31,0x0010(r29)
001899ac: 0c061d7f jal 0x001875fc      Sleep Check
001899b0: 00000000 nop
001899b4: 3c028019 lui r2,0x8019
001899b8: 8c422d98 lw r2,0x2d98(r2)
001899bc: 00000000 nop
001899c0: 90420006 lbu r2,0x0006(r2)
001899c4: 00000000 nop
001899c8: 30420020 andi r2,r2,0x0020
001899cc: 1040000b beq r2,r0,0x001899fc      Monster Check
001899d0: 00000000 nop
001899d4: 3c028019 lui r2,0x8019
001899d8: 8c422d94 lw r2,0x2d94(r2)
001899dc: 00000000 nop
001899e0: 90420091 lbu r2,0x0091(r2)
001899e4: 00000000 nop
001899e8: 30420010 andi r2,r2,0x0010
001899ec: 14400003 bne r2,r0,0x001899fc      Monster Talk Check
001899f0: 00000000 nop
001899f4: 0c0610c3 jal 0x0018430c      ELSE MISS Routine
001899f8: 00000000 nop
001899fc: 3c028019 lui r2,0x8019
00189a00: 8c422d90 lw r2,0x2d90(r2)
00189a04: 00000000 nop
00189a08: 90420000 lbu r2,0x0000(r2)
00189a0c: 00000000 nop
00189a10: 1040001b beq r2,r0,0x00189a80
00189a14: 00000000 nop
00189a18: 0c0620be jal 0x001882f8      Finger Guard Check?
00189a1c: 00000000 nop
00189a20: 3c028019 lui r2,0x8019
00189a24: 8c422d90 lw r2,0x2d90(r2)
00189a28: 00000000 nop
00189a2c: 90420000 lbu r2,0x0000(r2)
00189a30: 00000000 nop
00189a34: 10400012 beq r2,r0,0x00189a80      Evasion Check

00189a38: 00000000 nop
00189a3c: 0c061760 jal 0x00185d80      Load MA and X
00189a40: 00000000 nop
00189a44: 0c061259 jal 0x00184964      Zodiac Calculation
00189a48: 00000000 nop
00189a4c: 0c061967 jal 0x0018659c      (MA + X)% Hit
00189a50: 00000000 nop
00189a54: 0c061d44 jal 0x00187510      Total Accuracy Check
00189a58: 00000000 nop
00189a5c: 3c028019 lui r2,0x8019
00189a60: 8c422d90 lw r2,0x2d90(r2)
00189a64: 00000000 nop
00189a68: 90420000 lbu r2,0x0000(r2)
00189a6c: 00000000 nop
00189a70: 10400003 beq r2,r0,0x00189a80
00189a74: 00000000 nop
00189a78: 0c061b01 jal 0x00186c04      Skill Set Hard-Coding
00189a7c: 00000000 nop
00189a80: 8fbf0010 lw r31,0x0010(r29)
00189a84: 27bd0018 addiu r29,r29,0x0018
00189a88: 03e00008 jr r31
00189a8c: 00000000 nop

[2b]
00189a90: 27bdffe8 addiu r29,r29,0xffe8
00189a94: afbf0010 sw r31,0x0010(r29)
00189a98: 0c062144 jal 0x00188510      Physical Evade Calculation
00189a9c: 00000000 nop
00189aa0: 14400009 bne r2,r0,0x00189ac8
00189aa4: 00000000 nop
00189aa8: 0c061781 jal 0x00185e04      Loads PA and Y
00189aac: 00000000 nop
00189ab0: 0c0621b5 jal 0x001886d4      Load (PA + Y)%
00189ab4: 00000000 nop
00189ab8: 14400003 bne r2,r0,0x00189ac8
00189abc: 00000000 nop
00189ac0: 0c061e18 jal 0x00187860   Determine which stat (PA/MA/SP) is reduced, Spell Slot Hard-Code Routine
00189ac4: 00000000 nop
00189ac8: 8fbf0010 lw r31,0x0010(r29)
00189acc: 27bd0018 addiu r29,r29,0x0018
00189ad0: 03e00008 jr r31
00189ad4: 00000000 nop

[2c]
00189ad8: 27bdffe8 addiu r29,r29,0xffe8
00189adc: afbf0010 sw r31,0x0010(r29)
00189ae0: 0c062144 jal 0x00188510      Physical Evade Calculation
00189ae4: 00000000 nop
00189ae8: 14400009 bne r2,r0,0x00189b10
00189aec: 00000000 nop
00189af0: 0c061781 jal 0x00185e04      Loads PA and Y
00189af4: 00000000 nop
00189af8: 0c0621b5 jal 0x001886d4      Load (PA + Y)%
00189afc: 00000000 nop
00189b00: 14400003 bne r2,r0,0x00189b10
00189b04: 00000000 nop
00189b08: 0c0619a3 jal 0x0018668c      MP Damage Routine (Uses Y instead of X.)
00189b0c: 00000000 nop
00189b10: 8fbf0010 lw r31,0x0010(r29)
00189b14: 27bd0018 addiu r29,r29,0x0018
00189b18: 03e00008 jr r31
00189b1c: 00000000 nop

[2d]
00189b20: 27bdffe8 addiu r29,r29,0xffe8
00189b24: afbf0010 sw r31,0x0010(r29)
00189b28: 0c062144 jal 0x00188510      Physical Evade Calculation
00189b2c: 00000000 nop
00189b30: 14400014 bne r2,r0,0x00189b84
00189b34: 00000000 nop
00189b38: 0c061797 jal 0x00185e5c      Load WP + Y as Y
00189b3c: 00000000 nop
00189b40: 0c0617e9 jal 0x00185fa4      Element Strengthen Calculation
00189b44: 00000000 nop
00189b48: 0c0621a9 jal 0x001886a4      Physical Damage Calculation
00189b4c: 00000000 nop
00189b50: 0c061bf4 jal 0x00186fd0      Weapon Elemental = Swordskill Routine (Fixed by Xifanie.)
00189b54: 00000000 nop
00189b58: 3c028019 lui r2,0x8019
00189b5c: 8c422d90 lw r2,0x2d90(r2)
00189b60: 00000000 nop
00189b64: 90420000 lbu r2,0x0000(r2)
00189b68: 00000000 nop
00189b6c: 10400005 beq r2,r0,0x00189b84
00189b70: 00000000 nop
00189b74: 0c061c3f jal 0x001870fc      Elemental Absorption
00189b78: 00000000 nop
00189b7c: 0c061fad jal 0x00187eb4      Status Proc
00189b80: 00000000 nop
00189b84: 8fbf0010 lw r31,0x0010(r29)
00189b88: 27bd0018 addiu r29,r29,0x0018
00189b8c: 03e00008 jr r31
00189b90: 00000000 nop

[2e]
00189b94: 27bdffe8 addiu r29,r29,0xffe8
00189b98: afbf0010 sw r31,0x0010(r29)
00189b9c: 0c062144 jal 0x00188510      Physical Evade Calculation
00189ba0: 00000000 nop
00189ba4: 14400026 bne r2,r0,0x00189c40
00189ba8: 00000000 nop
00189bac: 0c061e72 jal 0x001879c8      Skill Slot Hard-Coding BREAK/STEAL/MIGHTY SWORD
00189bb0: 00000000 nop
00189bb4: 10400008 beq r2,r0,0x00189bd8
00189bb8: 00000000 nop
00189bbc: 0c061390 jal 0x00184e40      If fail, set stuff to 0. (Made obsolete by previous branch statement)      
00189bc0: 00000000 nop
00189bc4: 3c038019 lui r3,0x8019
00189bc8: 8c632d90 lw r3,0x2d90(r3)
00189bcc: 34020007 ori r2,r0,0x0007
00189bd0: 08062710 j 0x00189c40
00189bd4: a0620002 sb r2,0x0002(r3)
00189bd8: 0c061d8e jal 0x00187638      Maintanence Check
00189bdc: 00000000 nop
00189be0: 3c038019 lui r3,0x8019
00189be4: 8c632d90 lw r3,0x2d90(r3)
00189be8: 00000000 nop
00189bec: 90620000 lbu r2,0x0000(r3)
00189bf0: 00000000 nop
00189bf4: 10400012 beq r2,r0,0x00189c40
00189bf8: 34020004 ori r2,r0,0x0004
00189bfc: 0c061776 jal 0x00185dd8      Load WP and PA
00189c00: a4620010 sh r2,0x0010(r3)
00189c04: 0c0617e9 jal 0x00185fa4      Element Strengthen Calculation
00189c08: 00000000 nop
00189c0c: 0c0621a9 jal 0x001886a4      Physical Damage Calculation
00189c10: 00000000 nop
00189c14: 0c061bf4 jal 0x00186fd0      Weapon Elemental = Swordskill Routine (Fixed by Xifanie.)
00189c18: 00000000 nop
00189c1c: 3c028019 lui r2,0x8019
00189c20: 8c422d90 lw r2,0x2d90(r2)
00189c24: 00000000 nop
00189c28: 90420000 lbu r2,0x0000(r2)
00189c2c: 00000000 nop
00189c30: 10400003 beq r2,r0,0x00189c40
00189c34: 00000000 nop
00189c38: 0c061c3f jal 0x001870fc      Elemental Absorption
00189c3c: 00000000 nop
00189c40: 8fbf0010 lw r31,0x0010(r29)
00189c44: 27bd0018 addiu r29,r29,0x0018
00189c48: 03e00008 jr r31
00189c4c: 00000000 nop

[2f]
00189c50: 27bdffe8 addiu r29,r29,0xffe8
00189c54: afbf0010 sw r31,0x0010(r29)
00189c58: 0c062144 jal 0x00188510      Physical Evade Calculation
00189c5c: 00000000 nop
00189c60: 14400007 bne r2,r0,0x00189c80
00189c64: 00000000 nop
00189c68: 0c061776 jal 0x00185dd8      Load WP and PA
00189c6c: 00000000 nop
00189c70: 0c0621a9 jal 0x001886a4      Physical Damage Calculation (Does not allow elemental.)
00189c74: 00000000 nop
00189c78: 0c061d1b jal 0x0018746c      MP Healing
00189c7c: 00000000 nop
00189c80: 8fbf0010 lw r31,0x0010(r29)
00189c84: 27bd0018 addiu r29,r29,0x0018
00189c88: 03e00008 jr r31
00189c8c: 00000000 nop

[30]
00189c90: 27bdffe8 addiu r29,r29,0xffe8
00189c94: afbf0010 sw r31,0x0010(r29)
00189c98: 0c062144 jal 0x00188510      Physical Evade Calculation
00189c9c: 00000000 nop
00189ca0: 14400007 bne r2,r0,0x00189cc0
00189ca4: 00000000 nop
00189ca8: 0c061776 jal 0x00185dd8      Load WP and PA
00189cac: 00000000 nop
00189cb0: 0c0621a9 jal 0x001886a4      Physical Damage Calculation (Does not allow elemental.)
00189cb4: 00000000 nop
00189cb8: 0c061c92 jal 0x00187248      HP Absorb
00189cbc: 00000000 nop
00189cc0: 8fbf0010 lw r31,0x0010(r29)
00189cc4: 27bd0018 addiu r29,r29,0x0018
00189cc8: 03e00008 jr r31
00189ccc: 00000000 nop

[31]
00189cd0: 27bdffe8 addiu r29,r29,0xffe8
00189cd4: afbf0010 sw r31,0x0010(r29)
00189cd8: 0c062144 jal 0x00188510      Physical Evade Calculation
00189cdc: 00000000 nop
00189ce0: 14400020 bne r2,r0,0x00189d64
00189ce4: 00000000 nop
00189ce8: 0c061740 jal 0x00185d00      Load (PA + Y) / 2
00189cec: 00000000 nop
00189cf0: 0c0617ff jal 0x00185ffc      Get Elemental Boost
00189cf4: 00000000 nop
00189cf8: 0c061853 jal 0x0018614c      Get ATTACK UP/Martial Arts Check
00189cfc: 00000000 nop
00189d00: 0c0622b7 jal 0x00188adc      Damage Modifiers (Includes berserk and frog checks on user.)
00189d04: 00000000 nop
00189d08: 0c06193e jal 0x001864f8      Critical HIt Routine
00189d0c: 00000000 nop
00189d10: 0c06195a jal 0x00186568      Damage Routine
00189d14: 00000000 nop
00189d18: 0c061bb4 jal 0x00186ed0      Elemental Weak
00189d1c: 00000000 nop
00189d20: 0c061bfe jal 0x00186ff8      Elemental Cancel
00189d24: 00000000 nop
00189d28: 3c028019 lui r2,0x8019
00189d2c: 8c422d90 lw r2,0x2d90(r2)
00189d30: 00000000 nop
00189d34: 90420000 lbu r2,0x0000(r2)
00189d38: 00000000 nop
00189d3c: 10400009 beq r2,r0,0x00189d64
00189d40: 00000000 nop
00189d44: 0c061c3f jal 0x001870fc      Elemental Absorption
00189d48: 00000000 nop
00189d4c: 0c062130 jal 0x001884c0
00189d50: 00000000 nop
00189d54: 14400003 bne r2,r0,0x00189d64
00189d58: 00000000 nop
00189d5c: 0c061fad jal 0x00187eb4      Status
00189d60: 00000000 nop
00189d64: 8fbf0010 lw r31,0x0010(r29)
00189d68: 27bd0018 addiu r29,r29,0x0018
00189d6c: 03e00008 jr r31
00189d70: 00000000 nop

[32]
00189d74: 27bdffe8 addiu r29,r29,0xffe8
00189d78: afbf0010 sw r31,0x0010(r29)
00189d7c: 0c062144 jal 0x00188510      Physical Evade Calculation
00189d80: 00000000 nop
00189d84: 14400024 bne r2,r0,0x00189e18
00189d88: 00000000 nop
00189d8c: 0c061740 jal 0x00185d00      Load (PA + Y) / 2 as Y
00189d90: 00000000 nop
00189d94: 0c061853 jal 0x0018614c      ATTACK UP/Martial Arts Check
00189d98: 00000000 nop
00189d9c: 0c0622b7 jal 0x00188adc      Damage Modifiers (Contains checks for frog and berserk for the caster.)
00189da0: 00000000 nop
00189da4: 0c06193e jal 0x001864f8      Critical HIt Routine
00189da8: 00000000 nop
00189dac: 0c061967 jal 0x0018659c      Load PA + Y
00189db0: 00000000 nop
00189db4: 0c063ba8 jal 0x0018eea0      Load RN between 0 and 1 to r2
00189db8: 00000000 nop
00189dbc: 3c038019 lui r3,0x8019
00189dc0: 906338f9 lbu r3,0x38f9(r3)      Load X
00189dc4: 00000000 nop
00189dc8: 00430018 mult r2,r3         
00189dcc: 3c058019 lui r5,0x8019
00189dd0: 24a538ea addiu r5,r5,0x38ea
00189dd4: 00001012 mflo r2                 X * RN
00189dd8: 04410002 bgez r2,0x00189de4
00189ddc: 00000000 nop
00189de0: 24427fff addiu r2,r2,0x7fff
00189de4: 000213c3 sra r2,r2,0xf
00189de8: 3c048019 lui r4,0x8019
00189dec: 8c842d90 lw r4,0x2d90(r4)
00189df0: 24420001 addiu r2,r2,0x0001
00189df4: a0a20000 sb r2,0x0000(r5)      
00189df8: 90a20000 lbu r2,0x0000(r5)      
(Replace with  AND r2, r2, 0x00FF)
00189dfc: 84830004 lh r3,0x0004(r4)      Load PA + (PA + Y) / 2
00189e00: 00000000 nop
00189e04: 00620018 mult r3,r2
00189e08: 34020080 ori r2,r0,0x0080
00189e0c: a0820025 sb r2,0x0025(r4)      Set as HP Damage
00189e10: 00001012 mflo r2                 Damage = {1...X} * [PA + (PA + Y) / 2]
00189e14: a4820004 sh r2,0x0004(r4)      Store Damage
00189e18: 8fbf0010 lw r31,0x0010(r29)
00189e1c: 27bd0018 addiu r29,r29,0x0018
00189e20: 03e00008 jr r31
00189e24: 00000000 nop


[33]
00189e28: 27bdffe8 addiu r29,r29,0xffe8
00189e2c: afbf0010 sw r31,0x0010(r29)
00189e30: 0c06176b jal 0x00185dac      Load PA and X
00189e34: 00000000 nop
00189e38: 0c061853 jal 0x0018614c      ATTACK UP/Martial Arts Check
00189e3c: 00000000 nop
00189e40: 0c061895 jal 0x00186254      Berserk/Frog Check (Dumb idea)
00189e44: 00000000 nop
00189e48: 0c061259 jal 0x00184964      Zodiac Calculation
00189e4c: 00000000 nop
00189e50: 0c061967 jal 0x0018659c      (PA + X)%
00189e54: 00000000 nop
00189e58: 0c061d44 jal 0x00187510      Total Accuracy Check
00189e5c: 00000000 nop
00189e60: 3c028019 lui r2,0x8019
00189e64: 8c422d90 lw r2,0x2d90(r2)
00189e68: 00000000 nop
00189e6c: 90420000 lbu r2,0x0000(r2)
00189e70: 00000000 nop
00189e74: 10400003 beq r2,r0,0x00189e84
00189e78: 00000000 nop
00189e7c: 0c061fc9 jal 0x00187f24      Cast Status at (PA + X)%
00189e80: 00000000 nop
00189e84: 8fbf0010 lw r31,0x0010(r29)
00189e88: 27bd0018 addiu r29,r29,0x0018
00189e8c: 03e00008 jr r31
00189e90: 00000000 nop

[34]
00189e94: 27bdffe8 addiu r29,r29,0xffe8
00189e98: afbf0010 sw r31,0x0010(r29)
00189e9c: 0c061781 jal 0x00185e04      Loads PA and Y
00189ea0: 00000000 nop
00189ea4: 0c061853 jal 0x0018614c      Attack UP/Martial Arts Check
00189ea8: 00000000 nop
00189eac: 0c061259 jal 0x00184964      Zodiac Calculation
00189eb0: 00000000 nop
00189eb4: 0c06195a jal 0x00186568      Damage Calculation (Forbids elemental.)
00189eb8: 00000000 nop
00189ebc: 3c048019 lui r4,0x8019
00189ec0: 8c842d90 lw r4,0x2d90(r4)
00189ec4: 00000000 nop
00189ec8: 94820004 lhu r2,0x0004(r4)
00189ecc: a4800004 sh r0,0x0004(r4)
00189ed0: a4820006 sh r2,0x0006(r4)      Set HP Healing
00189ed4: 94830006 lhu r3,0x0006(r4)
00189ed8: 34020050 ori r2,r0,0x0050
00189edc: a0820025 sb r2,0x0025(r4)
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
00189ef4: a482000a sh r2,0x000a(r4)      SEt MP Healing as half of HP
00189ef8: 8fbf0010 lw r31,0x0010(r29)
00189efc: 27bd0018 addiu r29,r29,0x0018
00189f00: 03e00008 jr r31
00189f04: 00000000 nop

[35]
00189f08: 27bdffe8 addiu r29,r29,0xffe8
00189f0c: afbf0010 sw r31,0x0010(r29)
00189f10: 0c06176b jal 0x00185dac      Loads PA and X
00189f14: 00000000 nop
00189f18: 0c061853 jal 0x0018614c      Attack UP/Martial Arts Check
00189f1c: 00000000 nop
00189f20: 0c061259 jal 0x00184964      Zodiac Calculation
00189f24: 00000000 nop
00189f28: 0c061967 jal 0x0018659c      (PA + X)%
00189f2c: 00000000 nop
00189f30: 0c061d44 jal 0x00187510      Total Accuracy Check
00189f34: 00000000 nop
00189f38: 3c028019 lui r2,0x8019
00189f3c: 8c422d90 lw r2,0x2d90(r2)
00189f40: 00000000 nop
00189f44: 90420000 lbu r2,0x0000(r2)
00189f48: 00000000 nop
00189f4c: 10400009 beq r2,r0,0x00189f74
00189f50: 00000000 nop
00189f54: 0c062b37 jal 0x0018acdc      Add Status at (PA+X)%; must add or spell fails.
00189f58: 00000000 nop
00189f5c: 10400005 beq r2,r0,0x00189f74
00189f60: 00000000 nop
00189f64: 0c061989 jal 0x00186624      Inflict Y% Damage
00189f68: 00000000 nop
00189f6c: 0c061cd4 jal 0x00187350      Undead Reversal
00189f70: 00000000 nop
00189f74: 8fbf0010 lw r31,0x0010(r29)
00189f78: 27bd0018 addiu r29,r29,0x0018
00189f7c: 03e00008 jr r31
00189f80: 00000000 nop

[36]
001868f0: 3c028019 lui r2,0x8019
001868f4: 904238fa lbu r2,0x38fa(r2)      Load Y
001868f8: 3c038019 lui r3,0x8019
001868fc: 8c632d90 lw r3,0x2d90(r3)
00186900: 34420080 ori r2,r2,0x0080      Make Negative
00186904: a0620014 sb r2,0x0014(r3)      Load as 0x80 + PA decrement (bonus)
00186908: 3c038019 lui r3,0x8019
0018690c: 8c632d90 lw r3,0x2d90(r3)
00186910: 34020001 ori r2,r0,0x0001      Load as Psuedo-Status
00186914: 03e00008 jr r31
00186918: a0620025 sb r2,0x0025(r3)

[37]
00189f84: 27bdffe8 addiu r29,r29,0xffe8
00189f88: afbf0010 sw r31,0x0010(r29)
00189f8c: 0c062144 jal 0x00188510      Physical Evade Calculation
00189f90: 00000000 nop
00189f94: 14400009 bne r2,r0,0x00189fbc
00189f98: 00000000 nop
00189f9c: 0c061781 jal 0x00185e04      Load PA and Y
00189fa0: 00000000 nop
00189fa4: 0c061853 jal 0x0018614c      Attack UP/Martial Arts Check
00189fa8: 00000000 nop
00189fac: 0c0622b7 jal 0x00188adc      Damage Modifiers (Berserk and Frog check on user, though I suspect dragons may use this, so it's not entirely dumb.)
00189fb0: 00000000 nop
00189fb4: 0c061a47 jal 0x0018691c      Damage and Knockback Routine
00189fb8: 00000000 nop
00189fbc: 8fbf0010 lw r31,0x0010(r29)
00189fc0: 27bd0018 addiu r29,r29,0x0018
00189fc4: 03e00008 jr r31
00189fc8: 00000000 nop

[38]
00187f24: 3c038019 lui r3,0x8019
00187f28: 90633906 lbu r3,0x3906(r3)
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'
00187f44: 1040000b beq r2,r0,0x00187f74
00187f48: afb000b0 sw r16,0x00b0(r29)
00187f4c: 3c048019 lui r4,0x8019
00187f50: 8c842d90 lw r4,0x2d90(r4)
00187f54: 00000000 nop
00187f58: 8482002a lh r2,0x002a(r4)
00187f5c: 00000000 nop
00187f60: 04410002 bgez r2,0x00187f6c       (Always true)
00187f64: 00000000 nop
00187f68: 24420003 addiu r2,r2,0x0003
00187f6c: 00021083 sra r2,r2,0x02
00187f70: a482002a sh r2,0x002a(r4)      If Separate, store maximum accuracy as 1/4.
00187f74: 30620060 andi r2,r3,0x0060      Check for 'Random' or "Separate"
00187f78: 10400008 beq r2,r0,0x00187f9c
00187f7c: 30620080 andi r2,r3,0x0080       Useless command.  
00187f80: 3c028019 lui r2,0x8019
00187f84: 8c42f5fc lw r2,-0x0a04(r2)
00187f88: 00000000 nop
00187f8c: 10400003 beq r2,r0,0x00187f9c      If attack not flagged as status, do not check all or nothing.
00187f90: 30620080 andi r2,r3,0x0080      Check for 'All or Nothing'
00187f94: 34030080 ori r3,r0,0x0080      
00187f98: 30620080 andi r2,r3,0x0080      
(Repeats)
00187f9c: 10400010 beq r2,r0,0x00187fe0
00187fa0: 00008021 addu r16,r0,r0
00187fa4: 3c038019 lui r3,0x8019
00187fa8: 8c632d90 lw r3,0x2d90(r3)
00187fac: 3c018019 lui r1,0x8019
00187fb0: 00300821 addu r1,r1,r16      
00187fb4: 90243907 lbu r4,0x3907(r1)      Load status copied from SCUS
00187fb8: 00701821 addu r3,r3,r16      
00187fbc: 9062001b lbu r2,0x001b(r3)      
00187fc0: 26100001 addiu r16,r16,0x0001
00187fc4: 00441025 or r2,r2,r4
00187fc8: a062001b sb r2,0x001b(r3)      Store Status to inflict
00187fcc: 2a020005 slti r2,r16,0x0005
00187fd0: 1440fff4 bne r2,r0,0x00187fa4      Loop
00187fd4: 00002021 addu r4,r0,r0
00187fd8: 08062070 j 0x001881c0         Inflict Status Routine
00187fdc: 00000000 nop
00187fe0: 30620040 andi r2,r3,0x0040      Check for "Random"
00187fe4: 10400030 beq r2,r0,0x001880a8
00187fe8: 00008821 addu r17,r0,r0
00187fec: 00008021 addu r16,r0,r0
00187ff0: 34050080 ori r5,r0,0x0080
00187ff4: 27a40010 addiu r4,r29,0x0010
00187ff8: 06010002 bgez r16,0x00188004
00187ffc: 02001021 addu r2,r16,r0
00188000: 26020007 addiu r2,r16,0x0007
00188004: 000210c3 sra r2,r2,0x03      
00188008: 3c018019 lui r1,0x8019
0018800c: 00220821 addu r1,r1,r2
00188010: 90233907 lbu r3,0x3907(r1)
00188014: 32020007 andi r2,r16,0x0007
00188018: 00451007 srav r2,r5,r2
0018801c: 00621824 and r3,r3,r2
00188020: 10600004 beq r3,r0,0x00188034
00188024: 00000000 nop
00188028: ac900000 sw r16,0x0000(r4)      Store value if status can be hit
0018802c: 24840004 addiu r4,r4,0x0004
00188030: 26310001 addiu r17,r17,0x0001
00188034: 26100001 addiu r16,r16,0x0001
00188038: 2a020028 slti r2,r16,0x0028      Run checks for each status
0018803c: 1440ffee bne r2,r0,0x00187ff8      Loop
00188040: 00000000 nop
00188044: 0c063ba8 jal 0x0018eea0
00188048: 00000000 nop
0018804c: 00510018 mult r2,r17
00188050: 00001012 mflo r2         Number of statii * Random number
00188054: 04410002 bgez r2,0x00188060
00188058: 00000000 nop
0018805c: 24427fff addiu r2,r2,0x7fff
00188060: 000213c3 sra r2,r2,0x0f      r2 = 1 if was 0x8000, ELSE, r2 = 0.
00188064: 00021080 sll r2,r2,0x02
00188068: 03a21021 add r2,r29,r2
0018806c: 8c450010 lw r5,0x0010(r2)      LOAD first or second status written
00188070: 3c028019 lui r2,0x8019
00188074: 8c422d90 lw r2,0x2d90(r2)
00188078: 04a10002 bgez r5,0x00188084      Always true, r5 = r16 from the last loop
0018807c: 00a02021 addu r4,r5,r0
00188080: 24a40007 addiu r4,r5,0x0007
00188084: 000420c3 sra r4,r4,0x03      r5 / 8
00188088: 00442021 addu r4,r2,r4      r2 + r5 / 8
0018808c: 30a50007 andi r5,r5,0x0007
00188090: 34020080 ori r2,r0,0x0080
00188094: 9083001b lbu r3,0x001b(r4)      Load r3 as r2 + 1b (Inflict Status) + r5 / 8
00188098: 00a21007 srav r2,r2,r5      Load Status
0018809c: 00621825 or r3,r3,r2         
001880a0: 0806206f j 0x001881bc
001880a4: a083001b sb r3,0x001b(r4)      Store First Inflicted Status
001880a8: 30620020 andi r2,r3,0x0020      Check for "Separate"
001880ac: 10400033 beq r2,r0,0x0018817c
001880b0: 00008021 addu r16,r0,r0
001880b4: 34130080 ori r19,r0,0x0080
001880b8: 06010002 bgez r16,0x001880c4
001880bc: 02001021 addu r2,r16,r0
001880c0: 26020007 addiu r2,r16,0x0007
001880c4: 000288c3 sra r17,r2,0x03
001880c8: 3c018019 lui r1,0x8019
001880cc: 00310821 addu r1,r1,r17
001880d0: 90233907 lbu r3,0x3907(r1)      Load Status copied from SCUS
001880d4: 32020007 andi r2,r16,0x0007
001880d8: 00539007 srav r18,r19,r2      
001880dc: 00721824 and r3,r3,r18      Check for equality
(Why wouldn't it be?)
001880e0: 10600012 beq r3,r0,0x0018812c      GOTO end if no status
001880e4: 34040064 ori r4,r0,0x0064
001880e8: 0c017833 jal 0x0005e0cc
001880ec: 34050018 ori r5,r0,0x0018      Separate = innate 25%
001880f0: 14400006 bne r2,r0,0x0018810c
001880f4: 34020002 ori r2,r0,0x0002      
001880f8: 3c038019 lui r3,0x8019
001880fc: 8c63f5fc lw r3,-0x0a04(r3)
00188100: 00000000 nop
00188104: 14620009 bne r3,r2,0x0018812c      GOTO end if no status added
00188108: 00000000 nop
0018810c: 3c018019 lui r1,0x8019      If probability check is successful, GO here.
00188110: 00310821 addu r1,r1,r17
00188114: 90223907 lbu r2,0x3907(r1)
00188118: 00000000 nop
0018811c: 00521026 xor r2,r2,r18      Add status only if target does not already have it.
00188120: 3c018019 lui r1,0x8019
00188124: 00310821 addu r1,r1,r17
00188128: a0223907 sb r2,0x3907(r1)      Store Status
0018812c: 26100001 addiu r16,r16,0x0001      Increment r16
00188130: 2a020028 slti r2,r16,0x0028      Run through all status effects
00188134: 1440ffe0 bne r2,r0,0x001880b8      Loop
00188138: 00000000 nop
0018813c: 00008021 addu r16,r0,r0
00188140: 3c038019 lui r3,0x8019
00188144: 8c632d90 lw r3,0x2d90(r3)
00188148: 3c018019 lui r1,0x8019
0018814c: 00300821 addu r1,r1,r16
00188150: 90243907 lbu r4,0x3907(r1)
00188154: 00701821 addu r3,r3,r16
00188158: 9062001b lbu r2,0x001b(r3)
0018815c: 26100001 addiu r16,r16,0x0001
00188160: 00441025 or r2,r2,r4         
00188164: a062001b sb r2,0x001b(r3)      Load Status effects to be added
00188168: 2a020005 slti r2,r16,0x0005      Run through all status effects to be added
0018816c: 1440fff4 bne r2,r0,0x00188140      Loop
00188170: 00002021 addu r4,r0,r0
00188174: 08062070 j 0x001881c0         Inflict Status Routine
00188178: 00000000 nop
0018817c: 30620010 andi r2,r3,0x0010      Check for "Cancel"
00188180: 1040000f beq r2,r0,0x001881c0
00188184: 00002021 addu r4,r0,r0
00188188: 3c038019 lui r3,0x8019
0018818c: 8c632d90 lw r3,0x2d90(r3)
00188190: 3c018019 lui r1,0x8019
00188194: 00300821 addu r1,r1,r16
00188198: 90243907 lbu r4,0x3907(r1)      Load Status copied from SCUS
0018819c: 00701821 addu r3,r3,r16
001881a0: 90620020 lbu r2,0x0020(r3)
001881a4: 26100001 addiu r16,r16,0x0001
001881a8: 00441025 or r2,r2,r4
001881ac: a0620020 sb r2,0x0020(r3)      Store status to remove      
001881b0: 2a020005 slti r2,r16,0x0005      Go through all status effects
001881b4: 1440fff4 bne r2,r0,0x00188188      Loop
001881b8: 00000000 nop
001881bc: 00002021 addu r4,r0,r0
001881c0: 00008021 addu r16,r0,r0
001881c4: 3c058019 lui r5,0x8019
001881c8: 8ca52d90 lw r5,0x2d90(r5)
001881cc: 00000000 nop
001881d0: 00b01021 addu r2,r5,r16
001881d4: 9043001b lbu r3,0x001b(r2)
001881d8: 90420020 lbu r2,0x0020(r2)
001881dc: 26100001 addiu r16,r16,0x0001
001881e0: 00621825 or r3,r3,r2         Final value of r3 is that of 1f/24
001881e4: 2a020005 slti r2,r16,0x0005      Loop
001881e8: 1440fff8 bne r2,r0,0x001881cc
001881ec: 00832025 or r4,r4,r3
001881f0: 308200ff andi r2,r4,0x00ff      r2 = r4
001881f4: 10400005 beq r2,r0,0x0018820c      
001881f8: 00000000 nop
001881fc: 0c0612c9 jal 0x00184b24      Extra Checks if Status
00188200: 00002021 addu r4,r0,r0
00188204: 14400005 bne r2,r0,0x0018821c
00188208: 00000000 nop
0018820c: 0c0610c3 jal 0x0018430c      Set bytes to zero if no status (Should already be 0.)
00188210: 00000000 nop
00188214: 0806209a j 0x00188268
00188218: 00000000 nop
0018821c: 3c028019 lui r2,0x8019
00188220: 8c422d90 lw r2,0x2d90(r2)
00188224: 00000000 nop
00188228: 90430025 lbu r3,0x0025(r2)
0018822c: 00000000 nop
00188230: 34630008 ori r3,r3,0x0008
00188234: a0430025 sb r3,0x0025(r2)      Set as status infliction
00188238: 3c038019 lui r3,0x8019
0018823c: 8c632d90 lw r3,0x2d90(r3)
00188240: 00000000 nop
00188244: 9062001c lbu r2,0x001c(r3)
00188248: 00000000 nop
0018824c: 30420040 andi r2,r2,0x0040
00188250: 10400005 beq r2,r0,0x00188268      Ignore if target isn't invited
00188254: 00000000 nop
00188258: 94620010 lhu r2,0x0010(r3)
0018825c: 00000000 nop
00188260: 34420040 ori r2,r2,0x0040
00188264: a4620010 sh r2,0x0010(r3)      Change target team
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

[39]
00186d2c: 3c028019 lui r2,0x8019
00186d30: 904238fa lbu r2,0x38fa(r2)
00186d34: 3c038019 lui r3,0x8019
00186d38: 8c632d90 lw r3,0x2d90(r3)
00186d3c: 34420080 ori r2,r2,0x0080
00186d40: a0620012 sb r2,0x0012(r3)      Store Y as 0x80 + SP decrement (boost)
00186d44: 3c038019 lui r3,0x8019
00186d48: 8c632d90 lw r3,0x2d90(r3)
00186d4c: 34020001 ori r2,r0,0x0001
00186d50: 03e00008 jr r31
00186d54: a0620025 sb r2,0x0025(r3)      Store attack type as Pseudo-Status

[3a]
00186d00: 3c028019 lui r2,0x8019
00186d04: 904238fa lbu r2,0x38fa(r2)
00186d08: 3c038019 lui r3,0x8019
00186d0c: 8c632d90 lw r3,0x2d90(r3)
00186d10: 34420080 ori r2,r2,0x0080
00186d14: a0620016 sb r2,0x0016(r3)      Store Y as 0x80 + Br decrement (boost)
00186d18: 3c038019 lui r3,0x8019
00186d1c: 8c632d90 lw r3,0x2d90(r3)
00186d20: 34020001 ori r2,r0,0x0001
00186d24: 03e00008 jr r31
00186d28: a0620025 sb r2,0x0025(r3)      Store attack type as Psuedo-Status

[3b]
00186d58: 3c028019 lui r2,0x8019
00186d5c: 904238f9 lbu r2,0x38f9(r2)
00186d60: 3c038019 lui r3,0x8019
00186d64: 8c632d90 lw r3,0x2d90(r3)
00186d68: 34420080 ori r2,r2,0x0080
00186d6c: a0620016 sb r2,0x0016(r3)      Store X as 0x80 + Br decrement (boost)
00186d70: 3c038019 lui r3,0x8019
00186d74: 906338fa lbu r3,0x38fa(r3)
00186d78: 3c028019 lui r2,0x8019
00186d7c: 8c422d90 lw r2,0x2d90(r2)
00186d80: 34630080 ori r3,r3,0x0080
00186d84: a0430014 sb r3,0x0014(r2)      Store Y as 0x80 + PA decrement (boost)
00186d88: 3c028019 lui r2,0x8019
00186d8c: 8c422d90 lw r2,0x2d90(r2)
00186d90: 00000000 nop
00186d94: a0430015 sb r3,0x0015(r2)      Store Y as 0x80 + MA decrement (boost)
00186d98: 3c028019 lui r2,0x8019
00186d9c: 8c422d90 lw r2,0x2d90(r2)
00186da0: 00000000 nop
00186da4: a0430012 sb r3,0x0012(r2)      Store Y as 0x80 + SP decrement (boost)
00186da8: 3c038019 lui r3,0x8019
00186dac: 8c632d90 lw r3,0x2d90(r3)
00186db0: 34020001 ori r2,r0,0x0001
00186db4: 03e00008 jr r31
00186db8: a0620025 sb r2,0x0025(r3)      Store attack type as Psuedo-Status

[3c]
[3c]
00186dbc: 3c028019 lui r2,0x8019
00186dc0: 8c422d94 lw r2,0x2d94(r2)
00186dc4: 3c03cccc lui r3,0xcccc
00186dc8: 9442002a lhu r2,0x002a(r2)      Set variable as maxHP
00186dcc: 3463cccd ori r3,r3,0xcccd
00186dd0: 00430019 multu r2,r3
00186dd4: 3c038019 lui r3,0x8019
00186dd8: 8c632d8c lw r3,0x2d8c(r3)
00186ddc: 34020080 ori r2,r0,0x0080
00186de0: a0620025 sb r2,0x0025(r3)      Set as HP Healing
00186de4: 00001010 mfhi r2
00186de8: 00021082 srl r2,r2,0x02
00186dec: a4620004 sh r2,0x0004(r3)      Damage is 1/5 of maxHP
00186df0: 3c038019 lui r3,0x8019
00186df4: 8c632d8c lw r3,0x2d8c(r3)
00186df8: 34020001 ori r2,r0,0x0001
00186dfc: a0620000 sb r2,0x0000(r3)      Guarantee Hit
00186e00: 3c028019 lui r2,0x8019
00186e04: 8c422d8c lw r2,0x2d8c(r2)
00186e08: 3c048019 lui r4,0x8019
00186e0c: 8c842d90 lw r4,0x2d90(r4)
00186e10: 84420004 lh r2,0x0004(r2)
00186e14: 34030040 ori r3,r0,0x0040
00186e18: a0830025 sb r3,0x0025(r4)      Add in HP Healing
00186e1c: 00021040 sll r2,r2,0x01      
00186e20: 03e00008 jr r31
00186e24: a4820006 sh r2,0x0006(r4)      Healing is 2/5 of maxHP

[3d]
00189fcc: 27bdffe8 addiu r29,r29,0xffe8
00189fd0: afbf0010 sw r31,0x0010(r29)
00189fd4: 0c06216e jal 0x001885b8      Magic Evade
00189fd8: 00000000 nop
00189fdc: 14400007 bne r2,r0,0x00189ffc
00189fe0: 00000000 nop
00189fe4: 0c0622a1 jal 0x00188a84      Sets (MA + X)% as hit chance
00189fe8: 00000000 nop
00189fec: 14400003 bne r2,r0,0x00189ffc
00189ff0: 00000000 nop
00189ff4: 0c061fc9 jal 0x00187f24      Status Proc
00189ff8: 00000000 nop
00189ffc: 8fbf0010 lw r31,0x0010(r29)
0018a000: 27bd0018 addiu r29,r29,0x0018
0018a004: 03e00008 jr r31
0018a008: 00000000 nop

[3e]
0018a00c: 27bdffe8 addiu r29,r29,0xffe8
0018a010: afbf0010 sw r31,0x0010(r29)
0018a014: 0c0619bb jal 0x001866ec      Gravi2 Damage Routine
0018a018: 00000000 nop
0018a01c: 8fbf0010 lw r31,0x0010(r29)
0018a020: 27bd0018 addiu r29,r29,0x0018
0018a024: 03e00008 jr r31
0018a028: 00000000 nop

[3f]
0018a02c: 27bdffe8 addiu r29,r29,0xffe8
0018a030: afbf0010 sw r31,0x0010(r29)
0018a034: 0c06178c jal 0x00185e30      Loads SP and X
0018a038: 00000000 nop
0018a03c: 0c06217e jal 0x001885f8      Zodiac Calculation
0018a040: 00000000 nop
0018a044: 0c061967 jal 0x0018659c      Loads SP + X as X
0018a048: 00000000 nop
0018a04c: 0c061d44 jal 0x00187510      Total Accuracy Check
0018a050: 00000000 nop
0018a054: 3c028019 lui r2,0x8019
0018a058: 8c422d90 lw r2,0x2d90(r2)
0018a05c: 00000000 nop
0018a060: 90420000 lbu r2,0x0000(r2)
0018a064: 00000000 nop
0018a068: 10400003 beq r2,r0,0x0018a078
0018a06c: 00000000 nop
0018a070: 0c061fc9 jal 0x00187f24      Status Proc      
0018a074: 00000000 nop
0018a078: 8fbf0010 lw r31,0x0010(r29)
0018a07c: 27bd0018 addiu r29,r29,0x0018
0018a080: 03e00008 jr r31
0018a084: 00000000 nop

[40]
0018a088: 27bdffe8 addiu r29,r29,0xffe8
0018a08c: afbf0010 sw r31,0x0010(r29)
0018a090: 0c06178c jal 0x00185e30      Loads SP and X
0018a094: 00000000 nop
0018a098: 0c06217e jal 0x001885f8      Zodiac Calculation
0018a09c: 00000000 nop
0018a0a0: 0c061967 jal 0x0018659c      Loads SP + X as X
0018a0a4: 00000000 nop
0018a0a8: 0c061d44 jal 0x00187510      Total Accuracy Check
0018a0ac: 00000000 nop
0018a0b0: 3c028019 lui r2,0x8019
0018a0b4: 8c422d90 lw r2,0x2d90(r2)
0018a0b8: 00000000 nop
0018a0bc: 90420000 lbu r2,0x0000(r2)
0018a0c0: 00000000 nop
0018a0c4: 1040000f beq r2,r0,0x0018a104
0018a0c8: 00000000 nop
0018a0cc: 3c028019 lui r2,0x8019
0018a0d0: 8c422d98 lw r2,0x2d98(r2)
0018a0d4: 00000000 nop
0018a0d8: 90420058 lbu r2,0x0058(r2)
0018a0dc: 00000000 nop
0018a0e0: 30420010 andi r2,r2,0x0010
0018a0e4: 14400005 bne r2,r0,0x0018a0fc      Zombie Check
0018a0e8: 00000000 nop
0018a0ec: 0c0610c3 jal 0x0018430c      ELSE FAIL routine
0018a0f0: 00000000 nop
0018a0f4: 08062841 j 0x0018a104
0018a0f8: 00000000 nop
0018a0fc: 0c061fc9 jal 0x00187f24      Status Proc
0018a100: 00000000 nop
0018a104: 8fbf0010 lw r31,0x0010(r29)
0018a108: 27bd0018 addiu r29,r29,0x0018
0018a10c: 03e00008 jr r31
0018a110: 00000000 nop


Some other bits:
1) The Truth and Un-Truth formulas [1E/1F] do not have multi-hit routines in them, and likely neither do the ones for Triple Thunder/Holy Breath/Dark Whisper.  However, due to the nature of rerunning the formula, status becomes 6.25% per hit because it is hard-coded into the status application formula (38), rather than 1E/1F.
2) Stat boosts are read by the game as 0x80 + stat decrements, which is hard-coded into the formulas for stat gain.  A similar trick is used by CT, if anyone noticed on the CT00 formula.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Vanya on January 10, 2011, 07:35:40 pm
Holy Crap! 38 (100)% is a monster!! There's another that probably could and should be deconstructed for efficiency.

Seems like 39 & 3A could be merged by using X as an index for selecting which attribute to modify.

Looks like as long as the zombie check sub-routine in 40 only checks the status it should be easy to edit. And since it doesn't use Y it could probably be made to have the specific status selectable.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on January 11, 2011, 11:34:14 pm
Here's the last 0x24.

[41]
0018a114: 27bdffe8 addiu r29,r29,0xffe8
0018a118: afbf0010 sw r31,0x0010(r29)
0018a11c: 0c0622a1 jal 0x00188a84      Sets (MA + X)% as hit chance
0018a120: 00000000 nop
0018a124: 14400011 bne r2,r0,0x0018a16c
0018a128: 00000000 nop
0018a12c: 3c028019 lui r2,0x8019
0018a130: 8c422d98 lw r2,0x2d98(r2)
0018a134: 3c048019 lui r4,0x8019
0018a138: 8c842d94 lw r4,0x2d94(r4)
0018a13c: 94430008 lhu r3,0x0008(r2)
0018a140: 94820008 lhu r2,0x0008(r4)
0018a144: 3063f000 andi r3,r3,0xf000
0018a148: 3042f000 andi r2,r2,0xf000
0018a14c: 14620005 bne r3,r2,0x0018a164      If target and caster Zodiacs are different, inflict status.
0018a150: 00000000 nop
0018a154: 0c0610c3 jal 0x0018430c      ELSE, MISS Routine (Only graphics are affected here.)
0018a158: 00000000 nop
0018a15c: 0806285b j 0x0018a16c
0018a160: 00000000 nop
0018a164: 0c061fc9 jal 0x00187f24      Inflict status at (MA+X)%
0018a168: 00000000 nop
0018a16c: 8fbf0010 lw r31,0x0010(r29)
0018a170: 27bd0018 addiu r29,r29,0x0018
0018a174: 03e00008 jr r31
0018a178: 00000000 nop

[42]
0018a17c: 27bdffe8 addiu r29,r29,0xffe8
0018a180: afbf0010 sw r31,0x0010(r29)
0018a184: 0c061781 jal 0x00185e04      Loads PA and Y
0018a188: 00000000 nop
0018a18c: 0c061259 jal 0x00184964      Zodiac Calculation
0018a190: 00000000 nop
0018a194: 3c038019 lui r3,0x8019
0018a198: 946338ce lhu r3,0x38ce(r3)      Load PA
0018a19c: 3c028019 lui r2,0x8019
0018a1a0: 944238d0 lhu r2,0x38d0(r2)      Load Y
0018a1a4: 00000000 nop
0018a1a8: 00620018 mult r3,r2
0018a1ac: 3c038019 lui r3,0x8019
0018a1b0: 8c632d90 lw r3,0x2d90(r3)
0018a1b4: 00001012 mflo r2         PA * Y
0018a1b8: a4620004 sh r2,0x0004(r3)      Set PA * Y as HP Damage to enemy
0018a1bc: 00021400 sll r2,r2,0x10
0018a1c0: 3c038019 lui r3,0x8019
0018a1c4: 906338f9 lbu r3,0x38f9(r3)      Load X
0018a1c8: 00021403 sra r2,r2,0x10
0018a1cc: 0043001a div r2,r3
0018a1d0: 00001012 mflo r2         Damage / X
0018a1d4: 3c048019 lui r4,0x8019
0018a1d8: 8c842d8c lw r4,0x2d8c(r4)
0018a1dc: 34030001 ori r3,r0,0x0001
0018a1e0: a0830000 sb r3,0x0000(r4)      Hit Self
0018a1e4: a4820004 sh r2,0x0004(r4)      Damage Self for PA * Y / X
0018a1e8: 3c028019 lui r2,0x8019
0018a1ec: 8c422d90 lw r2,0x2d90(r2)
0018a1f0: 34030080 ori r3,r0,0x0080
0018a1f4: a0430025 sb r3,0x0025(r2)      Load as HP damage to enemy
0018a1f8: 3c028019 lui r2,0x8019
0018a1fc: 8c422d8c lw r2,0x2d8c(r2)
0018a200: 00000000 nop
0018a204: a0430025 sb r3,0x0025(r2)      Load as HP damage to self
0018a208: 8fbf0010 lw r31,0x0010(r29)
0018a20c: 27bd0018 addiu r29,r29,0x0018
0018a210: 03e00008 jr r31
0018a214: 00000000 nop

[43]
00186e28: 3c028019 lui r2,0x8019
00186e2c: 8c422d94 lw r2,0x2d94(r2)
00186e30: 3c058019 lui r5,0x8019
00186e34: 8ca52d90 lw r5,0x2d90(r5)
00186e38: 9443002a lhu r3,0x002a(r2)
00186e3c: 94440028 lhu r4,0x0028(r2)
00186e40: 34020080 ori r2,r0,0x0080
00186e44: a0a20025 sb r2,0x0025(r5)      Set as HP Damage
00186e48: 00641823 subu r3,r3,r4      Damage is Self maxHP - curHP
00186e4c: 03e00008 jr r31
00186e50: a4a30004 sh r3,0x0004(r5)      Store Damage

[44]
00186e54: 3c028019 lui r2,0x8019
00186e58: 8c422d98 lw r2,0x2d98(r2)
00186e5c: 3c038019 lui r3,0x8019
00186e60: 8c632d90 lw r3,0x2d90(r3)
00186e64: 9444002c lhu r4,0x002c(r2)
00186e68: 34020080 ori r2,r0,0x0080
00186e6c: a0620025 sb r2,0x0025(r3)      Set as HP Damage
00186e70: 03e00008 jr r31
00186e74: a4640004 sh r4,0x0004(r3)      Damage is target's curMP

[45]
00186e78: 3c028019 lui r2,0x8019
00186e7c: 8c422d98 lw r2,0x2d98(r2)
00186e80: 3c058019 lui r5,0x8019
00186e84: 8ca52d90 lw r5,0x2d90(r5)
00186e88: 9443002a lhu r3,0x002a(r2)
00186e8c: 94440028 lhu r4,0x0028(r2)
00186e90: 34020080 ori r2,r0,0x0080
00186e94: a0a20025 sb r2,0x0025(r5)      Set as HP Damage
00186e98: 00641823 subu r3,r3,r4      Damage is Target maxHP - curHP
00186e9c: 03e00008 jr r31
00186ea0: a4a30004 sh r3,0x0004(r5)      Store Damage


[46]
0018a218: 03e00008 jr r31         
0018a21c: 00000000 nop
(Does not work)

[47]
0018a220: 27bdffe8 addiu r29,r29,0xffe8
0018a224: afbf0010 sw r31,0x0010(r29)
0018a228: 0c061989 jal 0x00186624      Calculate Damage as Y% of HP
0018a22c: 00000000 nop
0018a230: 0c061c92 jal 0x00187248      Abosrb HP
0018a234: 00000000 nop
0018a238: 0c061fad jal 0x00187eb4      Status Proc
0018a23c: 00000000 nop
0018a240: 8fbf0010 lw r31,0x0010(r29)
0018a244: 27bd0018 addiu r29,r29,0x0018
0018a248: 03e00008 jr r31
0018a24c: 00000000 nop


[48] Healing = Z * 10 (with undead reversal)
0018a250: 3c038019 lui r3,0x8019
0018a254: 906338db lbu r3,0x38db(r3)      Load Used Item ID
0018a258: 27bdffe8 addiu r29,r29,0xffe8
0018a25c: afbf0010 sw r31,0x0010(r29)
0018a260: 00031040 sll r2,r3,0x01      ID * 2
0018a264: 00431021 addu r2,r2,r3      ID * 3
0018a268: 3c018006 lui r1,0x8006
0018a26c: 00220821 addu r1,r1,r2      80060000 + ID * 3 (Secondary Data)
0018a270: 90233f99 lbu r3,0x3f99(r1)      Load Used Item's Z value
0018a274: 00000000 nop
0018a278: 00031080 sll r2,r3,0x02      Z * 4
0018a27c: 00431021 addu r2,r2,r3      Z * 5
0018a280: 3c038019 lui r3,0x8019
0018a284: 8c632d90 lw r3,0x2d90(r3)      Load Current Attack Data Pointer
0018a288: 00021040 sll r2,r2,0x01      Z * 10
0018a28c: 0c061cd4 jal 0x00187350      Undead Reversal
0018a290: a4620004 sh r2,0x0004(r3)      Store HP Damage = Z * 10
0018a294: 8fbf0010 lw r31,0x0010(r29)
0018a298: 27bd0018 addiu r29,r29,0x0018
0018a29c: 03e00008 jr r31
0018a2a0: 00000000 nop

[49] MP Healing = Z * 10
0018a2a4: 27bdffe8 addiu r29,r29,0xffe8
0018a2a8: afbf0010 sw r31,0x0010(r29)
0018a2ac: 0c0620a2 jal 0x00188288      MP Healing Item Formula
0018a2b0: 00000000 nop
0018a2b4: 8fbf0010 lw r31,0x0010(r29)
0018a2b8: 27bd0018 addiu r29,r29,0x0018
0018a2bc: 03e00008 jr r31
0018a2c0: 00000000 nop

[4a] 100% HP/MP Healing
0018a2c4: 27bdffe8 addiu r29,r29,0xffe8
0018a2c8: afbf0010 sw r31,0x0010(r29)
0018a2cc: 0c0620b2 jal 0x001882c8      100% HP/MP Healing (actual calculation)
0018a2d0: 00000000 nop
0018a2d4: 0c061cd4 jal 0x00187350      Undead Reversal
0018a2d8: 00000000 nop
0018a2dc: 8fbf0010 lw r31,0x0010(r29)
0018a2e0: 27bd0018 addiu r29,r29,0x0018
0018a2e4: 03e00008 jr r31
0018a2e8: 00000000 nop

[4b] Remove status and restore Rand(1..(Z-1)) HP
0018a2ec: 27bdffe8 addiu r29,r29,0xffe8
0018a2f0: afbf0010 sw r31,0x0010(r29)
0018a2f4: 0c062b37 jal 0x0018acdc          Add Status at 100%; must add or item fails.
0018a2f8: 00000000 nop
0018a2fc: 10400024 beq r2,r0,0x0018a390
0018a300: 00000000 nop
0018a304: 3c048019 lui r4,0x8019
0018a308: 8c842d98 lw r4,0x2d98(r4)
0018a30c: 00000000 nop
0018a310: 90820058 lbu r2,0x0058(r4)
0018a314: 00000000 nop
0018a318: 30420010 andi r2,r2,0x0010
0018a31c: 10400006 beq r2,r0,0x0018a338
0018a320: 00000000 nop
0018a324: 3c038019 lui r3,0x8019      Run only if undead.
0018a328: 8c632d90 lw r3,0x2d90(r3)
0018a32c: 94820028 lhu r2,0x0028(r4)      Load Target curHP
0018a330: 080628e2 j 0x0018a388         Skip to damage if undead
0018a334: 00000000 nop
0018a338: 0c063ba8 jal 0x0018eea0      Load RN between 0 and 1
0018a33c: 00000000 nop
0018a340: 3c038019 lui r3,0x8019
0018a344: 906338db lbu r3,0x38db(r3)      Load item used
0018a348: 00000000 nop
0018a34c: 00032040 sll r4,r3,0x01      Item ID * 2
0018a350: 00832021 addu r4,r4,r3      ID * 3
0018a354: 3c018006 lui r1,0x8006
0018a358: 00240821 addu r1,r1,r4
0018a35c: 90233f99 lbu r3,0x3f99(r1)      Load Z
0018a360: 00000000 nop
0018a364: 00430018 mult r2,r3
0018a368: 3c038019 lui r3,0x8019
0018a36c: 8c632d90 lw r3,0x2d90(r3)
0018a370: 00001012 mflo r2         Load Z * RN
0018a374: 04410002 bgez r2,0x0018a380
0018a378: 00000000 nop
0018a37c: 24427fff addiu r2,r2,0x7fff
0018a380: 000213c3 sra r2,r2,0x0f
0018a384: 24420001 addiu r2,r2,0x0001
0018a388: 0c061cd4 jal 0x00187350      Undead Reversal
0018a38c: a4620004 sh r2,0x0004(r3)      Store as HP Damage (Changed to healing by above routine)
0018a390: 8fbf0010 lw r31,0x0010(r29)
0018a394: 27bd0018 addiu r29,r29,0x0018
0018a398: 03e00008 jr r31
0018a39c: 00000000 nop

[4c]
0018a3a0: 27bdffe8 addiu r29,r29,0xffe8
0018a3a4: afbf0010 sw r31,0x0010(r29)
0018a3a8: 0c061725 jal 0x00185c94      Get Ability Power
0018a3ac: 00000000 nop
0018a3b0: 0c062216 jal 0x00188858      Healing Calculation
0018a3b4: 00000000 nop
0018a3b8: 0c061cd4 jal 0x00187350      Undead Reversal
0018a3bc: 00000000 nop
0018a3c0: 8fbf0010 lw r31,0x0010(r29)
0018a3c4: 27bd0018 addiu r29,r29,0x0018
0018a3c8: 03e00008 jr r31
0018a3cc: 00000000 nop

[4d]
0018a3d0: 27bdffe8 addiu r29,r29,0xffe8
0018a3d4: afbf0010 sw r31,0x0010(r29)
0018a3d8: 0c062144 jal 0x00188510      Physical Evade Calculation
0018a3dc: 00000000 nop
0018a3e0: 1440000b bne r2,r0,0x0018a410
0018a3e4: 00000000 nop
0018a3e8: 0c061760 jal 0x00185d80      Get MA and X
0018a3ec: 00000000 nop
0018a3f0: 0c0622c5 jal 0x00188b14      Hit Chance Calculation (Has superfluous checks for frog/berserk.)
0018a3f4: 00000000 nop
0018a3f8: 14400005 bne r2,r0,0x0018a410
0018a3fc: 00000000 nop
0018a400: 0c061989 jal 0x00186624      Deal Y% HP Damage
0018a404: 00000000 nop
0018a408: 0c061c92 jal 0x00187248      HP Absorb
0018a40c: 00000000 nop
0018a410: 8fbf0010 lw r31,0x0010(r29)
0018a414: 27bd0018 addiu r29,r29,0x0018
0018a418: 03e00008 jr r31
0018a41c: 00000000 nop

[4e]
0018a420: 27bdffe8 addiu r29,r29,0xffe8
0018a424: afbf0010 sw r31,0x0010(r29)
0018a428: 0c06216e jal 0x001885b8      Magic Evade
0018a42c: 00000000 nop
0018a430: 14400005 bne r2,r0,0x0018a448
0018a434: 00000000 nop
0018a438: 0c061725 jal 0x00185c94      Get Ability Power
0018a43c: 00000000 nop
0018a440: 0c062259 jal 0x00188964      Calculate MA * Y Damage
0018a444: 00000000 nop
0018a448: 8fbf0010 lw r31,0x0010(r29)
0018a44c: 27bd0018 addiu r29,r29,0x0018
0018a450: 03e00008 jr r31
0018a454: 00000000 nop

[4f]
0018a458: 27bdffe8 addiu r29,r29,0xffe8
0018a45c: afbf0010 sw r31,0x0010(r29)
0018a460: 0c062144 jal 0x00188510      Physical Evade Calculation
0018a464: 00000000 nop
0018a468: 14400009 bne r2,r0,0x0018a490
0018a46c: 00000000 nop
0018a470: 0c061760 jal 0x00185d80      Get X and MA
0018a474: 00000000 nop
0018a478: 0c0622c5 jal 0x00188b14      Hit Chance Calculation (Has superfluous checks for frog/berserk.)
0018a47c: 00000000 nop
0018a480: 14400003 bne r2,r0,0x0018a490
0018a484: 00000000 nop
0018a488: 0c061b8a jal 0x00186e28      Damage = Enemy maxHP - Enemy curHP
0018a48c: 00000000 nop
0018a490: 8fbf0010 lw r31,0x0010(r29)
0018a494: 27bd0018 addiu r29,r29,0x0018
0018a498: 03e00008 jr r31
0018a49c: 00000000 nop

[50]
0018a4a0: 27bdffe8 addiu r29,r29,0xffe8
0018a4a4: afbf0010 sw r31,0x0010(r29)
0018a4a8: 0c062144 jal 0x00188510      Physical Evade Calculation
0018a4ac: 00000000 nop
0018a4b0: 14400009 bne r2,r0,0x0018a4d8
0018a4b4: 00000000 nop
0018a4b8: 0c061760 jal 0x00185d80      Get X and MA
0018a4bc: 00000000 nop
0018a4c0: 0c0622c5 jal 0x00188b14      Hit Chance Calculation (Has superfluous checks for frog/berserk.)
0018a4c4: 00000000 nop
0018a4c8: 14400003 bne r2,r0,0x0018a4d8
0018a4cc: 00000000 nop
0018a4d0: 0c061fc9 jal 0x00187f24      Status Proc at (MA + X)%
0018a4d4: 00000000 nop
0018a4d8: 8fbf0010 lw r31,0x0010(r29)
0018a4dc: 27bd0018 addiu r29,r29,0x0018
0018a4e0: 03e00008 jr r31
0018a4e4: 00000000 nop

[51]
0018a4e8: 27bdffe8 addiu r29,r29,0xffe8
0018a4ec: afbf0010 sw r31,0x0010(r29)
0018a4f0: 0c061760 jal 0x00185d80      Get X and MA
0018a4f4: 00000000 nop
0018a4f8: 0c0617ff jal 0x00185ffc      Elemental Boost
0018a4fc: 00000000 nop
0018a500: 0c061881 jal 0x00186204      MATUP bonus
0018a504: 00000000 nop
0018a508: 0c061259 jal 0x00184964      Zodiac Calculation
0018a50c: 00000000 nop
0018a510: 0c061967 jal 0x0018659c      Set MA + X as X
0018a514: 00000000 nop
0018a518: 0c061d44 jal 0x00187510      Total Accuracy Check
0018a51c: 00000000 nop
0018a520: 3c028019 lui r2,0x8019
0018a524: 8c422d90 lw r2,0x2d90(r2)
0018a528: 00000000 nop
0018a52c: 90420000 lbu r2,0x0000(r2)
0018a530: 00000000 nop
0018a534: 10400003 beq r2,r0,0x0018a544
0018a538: 00000000 nop
0018a53c: 0c061fc9 jal 0x00187f24      Status Proc at (MA + X)%
0018a540: 00000000 nop
0018a544: 8fbf0010 lw r31,0x0010(r29)
0018a548: 27bd0018 addiu r29,r29,0x0018
0018a54c: 03e00008 jr r31
0018a550: 00000000 nop

[52]
0018a554: 3c048019 lui r4,0x8019
0018a558: 8c842d98 lw r4,0x2d98(r4)
0018a55c: 3c038019 lui r3,0x8019
0018a560: 8c632d94 lw r3,0x2d94(r3)
0018a564: 27bdffe8 addiu r29,r29,0xffe8
0018a568: 1083000a beq r4,r3,0x0018a594
0018a56c: afbf0010 sw r31,0x0010(r29)
0018a570: 9462002a lhu r2,0x002a(r3)      Damage to others routine
0018a574: 94630028 lhu r3,0x0028(r3)
0018a578: 3c048019 lui r4,0x8019
0018a57c: 8c842d90 lw r4,0x2d90(r4)
0018a580: 00431023 subu r2,r2,r3
0018a584: a4820004 sh r2,0x0004(r4)      Store Damage as Self maxHP - curHP.
0018a588: 34020080 ori r2,r0,0x0080
0018a58c: 0806296c j 0x0018a5b0
0018a590: a0820025 sb r2,0x0025(r4)      Set as HP Damage
0018a594: 3c028019 lui r2,0x8019      Damage to self routine
0018a598: 8c422d90 lw r2,0x2d90(r2)
0018a59c: 94830028 lhu r3,0x0028(r4)
0018a5a0: 00000000 nop
0018a5a4: a4430004 sh r3,0x0004(r2)      Store Damage as Target/Self curHP
0018a5a8: 34030080 ori r3,r0,0x0080
0018a5ac: a0430025 sb r3,0x0025(r2)      Set as HP damage
0018a5b0: 3c038019 lui r3,0x8019
0018a5b4: 8c632d98 lw r3,0x2d98(r3)
0018a5b8: 3c028019 lui r2,0x8019
0018a5bc: 8c422d94 lw r2,0x2d94(r2)
0018a5c0: 00000000 nop
0018a5c4: 10620003 beq r3,r2,0x0018a5d4      Only inflict status to enemies
0018a5c8: 00000000 nop
0018a5cc: 0c061fad jal 0x00187eb4      Inflict status at 100%
0018a5d0: 00000000 nop
0018a5d4: 8fbf0010 lw r31,0x0010(r29)
0018a5d8: 27bd0018 addiu r29,r29,0x0018
0018a5dc: 03e00008 jr r31
0018a5e0: 00000000 nop

[53]
0018a5e4: 27bdffe8 addiu r29,r29,0xffe8
0018a5e8: afbf0010 sw r31,0x0010(r29)
0018a5ec: 0c06216e jal 0x001885b8      Magic Evade
0018a5f0: 00000000 nop
0018a5f4: 14400018 bne r2,r0,0x0018a658
0018a5f8: 00000000 nop
0018a5fc: 0c0622a1 jal 0x00188a84      Sets (MA + X)% as hit chance
0018a600: 00000000 nop
0018a604: 14400014 bne r2,r0,0x0018a658
0018a608: 00000000 nop
0018a60c: 0c061989 jal 0x00186624      Set HP damage as Y%
0018a610: 00000000 nop
0018a614: 0c061bb4 jal 0x00186ed0      Elemental Weak
0018a618: 00000000 nop
0018a61c: 0c061bfe jal 0x00186ff8      Elemental Cancel
0018a620: 00000000 nop
0018a624: 3c028019 lui r2,0x8019
0018a628: 8c422d90 lw r2,0x2d90(r2)
0018a62c: 00000000 nop
0018a630: 90420000 lbu r2,0x0000(r2)
0018a634: 00000000 nop
0018a638: 10400007 beq r2,r0,0x0018a658      HIt Check
0018a63c: 00000000 nop
0018a640: 0c0621c7 jal 0x0018871c      Elemental Absorption
0018a644: 00000000 nop
0018a648: 14400003 bne r2,r0,0x0018a658
0018a64c: 00000000 nop
0018a650: 0c061fad jal 0x00187eb4      Inflict status at (MA + X)%
0018a654: 00000000 nop
0018a658: 8fbf0010 lw r31,0x0010(r29)
0018a65c: 27bd0018 addiu r29,r29,0x0018
0018a660: 03e00008 jr r31
0018a664: 00000000 nop

[54]
0018a668: 27bdffe8 addiu r29,r29,0xffe8
0018a66c: afbf0010 sw r31,0x0010(r29)
0018a670: 0c061725 jal 0x00185c94      Get Ability Power
0018a674: 00000000 nop
0018a678: 0c062216 jal 0x00188858      Healing Calculation
0018a67c: 00000000 nop
0018a680: 0c061d3b jal 0x001874ec      Convert HP Healing to MP Healing
0018a684: 00000000 nop
0018a688: 8fbf0010 lw r31,0x0010(r29)
0018a68c: 27bd0018 addiu r29,r29,0x0018
0018a690: 03e00008 jr r31
0018a694: 00000000 nop

[55]
0018a698: 27bdffe8 addiu r29,r29,0xffe8
0018a69c: afbf0010 sw r31,0x0010(r29)
0018a6a0: 0c06216e jal 0x001885b8      Magic Evade
0018a6a4: 00000000 nop
0018a6a8: 1440000f bne r2,r0,0x0018a6e8
0018a6ac: 00000000 nop
0018a6b0: 0c0622a1 jal 0x00188a84      Sets (MA + X)% as hit chance
0018a6b4: 00000000 nop
0018a6b8: 1440000b bne r2,r0,0x0018a6e8
0018a6bc: 00000000 nop
0018a6c0: 3c028019 lui r2,0x8019
0018a6c4: 904238fa lbu r2,0x38fa(r2)      Load Y
0018a6c8: 3c038019 lui r3,0x8019
0018a6cc: 8c632d90 lw r3,0x2d90(r3)
0018a6d0: 3042007f andi r2,r2,0x007f      Forced as decrement
0018a6d4: a0620014 sb r2,0x0014(r3)      Store PA loss as Y.
0018a6d8: 3c038019 lui r3,0x8019
0018a6dc: 8c632d90 lw r3,0x2d90(r3)
0018a6e0: 34020001 ori r2,r0,0x0001
0018a6e4: a0620025 sb r2,0x0025(r3)      Set Type as Psuedo-Status
0018a6e8: 8fbf0010 lw r31,0x0010(r29)
0018a6ec: 27bd0018 addiu r29,r29,0x0018
0018a6f0: 03e00008 jr r31
0018a6f4: 00000000 nop

[56]
0018a6f8: 27bdffe8 addiu r29,r29,0xffe8
0018a6fc: afbf0010 sw r31,0x0010(r29)
0018a700: 0c06216e jal 0x001885b8      Magic Evade
0018a704: 00000000 nop
0018a708: 1440000f bne r2,r0,0x0018a748
0018a70c: 00000000 nop
0018a710: 0c0622a1 jal 0x00188a84      Sets (MA + X)% as hit chance
0018a714: 00000000 nop
0018a718: 1440000b bne r2,r0,0x0018a748
0018a71c: 00000000 nop
0018a720: 3c028019 lui r2,0x8019
0018a724: 904238fa lbu r2,0x38fa(r2)      Load Y
0018a728: 3c038019 lui r3,0x8019
0018a72c: 8c632d90 lw r3,0x2d90(r3)
0018a730: 3042007f andi r2,r2,0x007f      Forced as decrement
0018a734: a0620015 sb r2,0x0015(r3)      Store MA loss as Y
0018a738: 3c038019 lui r3,0x8019
0018a73c: 8c632d90 lw r3,0x2d90(r3)
0018a740: 34020001 ori r2,r0,0x0001
0018a744: a0620025 sb r2,0x0025(r3)      Set type as Psuedo-status
0018a748: 8fbf0010 lw r31,0x0010(r29)
0018a74c: 27bd0018 addiu r29,r29,0x0018
0018a750: 03e00008 jr r31
0018a754: 00000000 nop

[57]
0018a758: 27bdffe0 addiu r29,r29,0xffe0
0018a75c: afbf0018 sw r31,0x0018(r29)
0018a760: afb10014 sw r17,0x0014(r29)
0018a764: 0c0620b2 jal 0x001882c8      100% HP/MP Healing
0018a768: afb00010 sw r16,0x0010(r29)
0018a76c: 0c061cd4 jal 0x00187350      Healing Calculation
0018a770: 00000000 nop
0018a774: 3c028019 lui r2,0x8019
0018a778: 8c422d98 lw r2,0x2d98(r2)
0018a77c: 00000000 nop
0018a780: 90420022 lbu r2,0x0022(r2)
0018a784: 00000000 nop
0018a788: 2c420063 sltiu r2,r2,0x0063       (Should be 0x64)
0018a78c: 14400007 bne r2,r0,0x0018a7ac
0018a790: 34060001 ori r6,r0,0x0001      Runs if target is level 99+.
0018a794: 3c028019 lui r2,0x8019
0018a798: 8c422d90 lw r2,0x2d90(r2)
0018a79c: 0c0610c3 jal 0x0018430c      ELSE MISS routine
0018a7a0: a0400025 sb r0,0x0025(r2)      Set attack as Miss
0018a7a4: 08062a03 j 0x0018a80c         GOTO end
0018a7a8: 00000000 nop
0018a7ac: 3c058019 lui r5,0x8019      Runs if target < L99.
0018a7b0: 8ca52d90 lw r5,0x2d90(r5)
0018a7b4: 00000000 nop
0018a7b8: a0a60025 sb r6,0x0025(r5)      Set type as Psuedo-Status
0018a7bc: 3c108019 lui r16,0x8019
0018a7c0: 8e102d98 lw r16,0x2d98(r16)
0018a7c4: 3c118019 lui r17,0x8019
0018a7c8: 8e312d90 lw r17,0x2d90(r17)
0018a7cc: 3c048019 lui r4,0x8019
0018a7d0: 8c842d94 lw r4,0x2d94(r4)
0018a7d4: 3c038019 lui r3,0x8019
0018a7d8: 8c632d8c lw r3,0x2d8c(r3)
0018a7dc: 34020080 ori r2,r0,0x0080
0018a7e0: a4a20010 sh r2,0x0010(r5)      +1 Level to target
0018a7e4: 3c018019 lui r1,0x8019
0018a7e8: ac242d98 sw r4,0x2d98(r1)      Set target as self
0018a7ec: 3c018019 lui r1,0x8019
0018a7f0: ac232d90 sw r3,0x2d90(r1)      Set target as self
0018a7f4: 0c061fc9 jal 0x00187f24      Add status at 100%
0018a7f8: a0660000 sb r6,0x0000(r3)      Flag as hit
0018a7fc: 3c018019 lui r1,0x8019
0018a800: ac302d98 sw r16,0x2d98(r1)      Reset target to unit selected
0018a804: 3c018019 lui r1,0x8019
0018a808: ac312d90 sw r17,0x2d90(r1)      Reset caster as caster
0018a80c: 8fbf0018 lw r31,0x0018(r29)
0018a810: 8fb10014 lw r17,0x0014(r29)
0018a814: 8fb00010 lw r16,0x0010(r29)
0018a818: 27bd0020 addiu r29,r29,0x0020
0018a81c: 03e00008 jr r31
0018a820: 00000000 nop

[58]
0018a824: 27bdffe8 addiu r29,r29,0xffe8
0018a828: afbf0010 sw r31,0x0010(r29)
0018a82c: 0c061760 jal 0x00185d80      Get MA and X
0018a830: 00000000 nop
0018a834: 0c0617ff jal 0x00185ffc      Elemental Boost
0018a838: 00000000 nop
0018a83c: 0c061881 jal 0x00186204      MATUP Boost
0018a840: 00000000 nop
0018a844: 0c061259 jal 0x00184964      Zodiac Calculation
0018a848: 00000000 nop
0018a84c: 0c061967 jal 0x0018659c      Set MA + X as X
0018a850: 00000000 nop
0018a854: 0c061d44 jal 0x00187510      Total Evasion Check
0018a858: 00000000 nop
0018a85c: 3c048019 lui r4,0x8019
0018a860: 8c842d90 lw r4,0x2d90(r4)
0018a864: 00000000 nop
0018a868: 90820000 lbu r2,0x0000(r4)
0018a86c: 00000000 nop
0018a870: 10400021 beq r2,r0,0x0018a8f8
0018a874: 00000000 nop
0018a878: 3c038019 lui r3,0x8019
0018a87c: 8c632d98 lw r3,0x2d98(r3)
0018a880: 00000000 nop
0018a884: 90620005 lbu r2,0x0005(r3)
0018a888: 00000000 nop
0018a88c: 30420004 andi r2,r2,0x0004
0018a890: 14400017 bne r2,r0,0x0018a8f0      Immortal Check
0018a894: 00000000 nop
0018a898: 90620182 lbu r2,0x0182(r3)
0018a89c: 00000000 nop
0018a8a0: 14400013 bne r2,r0,0x0018a8f0      Rider/Water Check
0018a8a4: 00000000 nop
0018a8a8: 90620000 lbu r2,0x0000(r3)
0018a8ac: 00000000 nop
0018a8b0: 2442ff80 addiu r2,r2,0xff80
0018a8b4: 304200ff andi r2,r2,0x00ff      Unit Type (8?) + 0x80
0018a8b8: 2c420003 sltiu r2,r2,0x0003
0018a8bc: 1040000c beq r2,r0,0x0018a8f0      
0018a8c0: 00000000 nop
0018a8c4: 90620003 lbu r2,0x0003(r3)      Run only if unit is generic; Loads job class
0018a8c8: 00000000 nop
0018a8cc: 2442007e addiu r2,r2,0x007e
0018a8d0: 304200ff andi r2,r2,0x00ff      r2 = Job Class + 0x7e
0018a8d4: 2c420003 sltiu r2,r2,0x0003      
0018a8d8: 14400005 bne r2,r0,0x0018a8f0      Check if already murbol
0018a8dc: 34020002 ori r2,r0,0x0002
0018a8e0: a4820010 sh r2,0x0010(r4)      Turn unit into murbol
0018a8e4: 34020001 ori r2,r0,0x0001
0018a8e8: 08062a3e j 0x0018a8f8
0018a8ec: a0820025 sb r2,0x0025(r4)      Set as Psuedo-Status
0018a8f0: 0c0610c3 jal 0x0018430c      ELSE MISS Routine
0018a8f4: 00000000 nop
0018a8f8: 8fbf0010 lw r31,0x0010(r29)
0018a8fc: 27bd0018 addiu r29,r29,0x0018
0018a900: 03e00008 jr r31
0018a904: 00000000 nop

[59]
0018a908: 27bdffe8 addiu r29,r29,0xffe8
0018a90c: afbf0010 sw r31,0x0010(r29)
0018a910: 0c06216e jal 0x001885b8      Magic Evade
0018a914: 00000000 nop
0018a918: 14400015 bne r2,r0,0x0018a970
0018a91c: 00000000 nop
0018a920: 0c0622a1 jal 0x00188a84      Set (MA + X)% as evade
0018a924: 00000000 nop
0018a928: 14400011 bne r2,r0,0x0018a970
0018a92c: 00000000 nop
0018a930: 3c028019 lui r2,0x8019
0018a934: 8c422d98 lw r2,0x2d98(r2)
0018a938: 00000000 nop
0018a93c: 90420022 lbu r2,0x0022(r2)      Load Level
0018a940: 00000000 nop
0018a944: 2c420002 sltiu r2,r2,0x0002
0018a948: 10400003 beq r2,r0,0x0018a958      Check to make sure target Lv > 1
0018a94c: 00000000 nop
0018a950: 0c0610c3 jal 0x0018430c      ELSE MISS
0018a954: 00000000 nop
0018a958: 3c028019 lui r2,0x8019
0018a95c: 8c422d90 lw r2,0x2d90(r2)
0018a960: 34030100 ori r3,r0,0x0100
0018a964: a4430010 sh r3,0x0010(r2)      -1 Level
0018a968: 34030001 ori r3,r0,0x0001
0018a96c: a0430025 sb r3,0x0025(r2)      Set as Pseudo-Status
0018a970: 8fbf0010 lw r31,0x0010(r29)
0018a974: 27bd0018 addiu r29,r29,0x0018
0018a978: 03e00008 jr r31
0018a97c: 00000000 nop

[5a]
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

[5b]
0018a9c4: 27bdffe8 addiu r29,r29,0xffe8
0018a9c8: afbf0010 sw r31,0x0010(r29)
0018a9cc: 0c061d6f jal 0x001875bc      Dragon Check
0018a9d0: 00000000 nop
0018a9d4: 3c028019 lui r2,0x8019
0018a9d8: 8c422d90 lw r2,0x2d90(r2)
0018a9dc: 00000000 nop
0018a9e0: 90420000 lbu r2,0x0000(r2)
0018a9e4: 00000000 nop
0018a9e8: 10400005 beq r2,r0,0x0018aa00      Check if evaded
(Already done above)
0018a9ec: 00000000 nop
0018a9f0: 0c061b6f jal 0x00186dbc      Wish Routine
0018a9f4: 00000000 nop
0018a9f8: 0c061fad jal 0x00187eb4      Status Proc at 100%
0018a9fc: 00000000 nop
0018aa00: 8fbf0010 lw r31,0x0010(r29)
0018aa04: 27bd0018 addiu r29,r29,0x0018
0018aa08: 03e00008 jr r31
0018aa0c: 00000000 nop

[5c]
0018aa10: 27bdffe8 addiu r29,r29,0xffe8
0018aa14: afbf0010 sw r31,0x0010(r29)
0018aa18: 0c061d6f jal 0x001875bc      Dragon Check
0018aa1c: 00000000 nop
0018aa20: 3c028019 lui r2,0x8019
0018aa24: 8c422d90 lw r2,0x2d90(r2)
0018aa28: 00000000 nop
0018aa2c: 90420000 lbu r2,0x0000(r2)
0018aa30: 00000000 nop
0018aa34: 10400003 beq r2,r0,0x0018aa44      Check if evaded
(Already done above)
0018aa38: 00000000 nop
0018aa3c: 0c061b56 jal 0x00186d58      Scream Routine
0018aa40: 00000000 nop
0018aa44: 8fbf0010 lw r31,0x0010(r29)
0018aa48: 27bd0018 addiu r29,r29,0x0018
0018aa4c: 03e00008 jr r31
0018aa50: 00000000 nop

[5d]
0018aa54: 27bdffe8 addiu r29,r29,0xffe8
0018aa58: afbf0010 sw r31,0x0010(r29)
0018aa5c: 0c061d6f jal 0x001875bc      Dragon Check
0018aa60: 00000000 nop
0018aa64: 3c028019 lui r2,0x8019
0018aa68: 8c422d90 lw r2,0x2d90(r2)
0018aa6c: 00000000 nop
0018aa70: 90420000 lbu r2,0x0000(r2)
0018aa74: 00000000 nop
0018aa78: 10400003 beq r2,r0,0x0018aa88      Check if evaded
(Already done above)
0018aa7c: 00000000 nop
0018aa80: 0c061e0f jal 0x0018783c      Quick Effect at 100%
0018aa84: 00000000 nop
0018aa88: 8fbf0010 lw r31,0x0010(r29)
0018aa8c: 27bd0018 addiu r29,r29,0x0018
0018aa90: 03e00008 jr r31
0018aa94: 00000000 nop

[5e]
0018aa98: 27bdffe8 addiu r29,r29,0xffe8
0018aa9c: afbf0010 sw r31,0x0010(r29)
0018aaa0: 0c06216e jal 0x001885b8      Magic Evade
0018aaa4: 00000000 nop
0018aaa8: 14400003 bne r2,r0,0x0018aab8
0018aaac: 00000000 nop
0018aab0: 0c062269 jal 0x001889a4      Truth Formula
0018aab4: 00000000 nop
0018aab8: 8fbf0010 lw r31,0x0010(r29)
0018aabc: 27bd0018 addiu r29,r29,0x0018
0018aac0: 03e00008 jr r31
0018aac4: 00000000 nop
(Repeat of 1E)

[5f]
0018aac8: 27bdffe8 addiu r29,r29,0xffe8
0018aacc: afbf0010 sw r31,0x0010(r29)
0018aad0: 0c06216e jal 0x001885b8      Magic Evade
0018aad4: 00000000 nop
0018aad8: 14400003 bne r2,r0,0x0018aae8
0018aadc: 00000000 nop
0018aae0: 0c062269 jal 0x001889a4      Truth Formula
0018aae4: 00000000 nop
0018aae8: 8fbf0010 lw r31,0x0010(r29)
0018aaec: 27bd0018 addiu r29,r29,0x0018
0018aaf0: 03e00008 jr r31
0018aaf4: 00000000 nop
(Repeat of 1E)

[60]
0018aaf8: 27bdffe8 addiu r29,r29,0xffe8
0018aafc: afbf0010 sw r31,0x0010(r29)
0018ab00: 0c062269 jal 0x001889a4      Truth Formula
0018ab04: 00000000 nop
0018ab08: 8fbf0010 lw r31,0x0010(r29)
0018ab0c: 27bd0018 addiu r29,r29,0x0018
0018ab10: 03e00008 jr r31
0018ab14: 00000000 nop

[61]
0018ab18: 27bdffe8 addiu r29,r29,0xffe8
0018ab1c: afbf0010 sw r31,0x0010(r29)
0018ab20: 0c06216e jal 0x001885b8      Magic Evade
0018ab24: 00000000 nop
0018ab28: 14400007 bne r2,r0,0x0018ab48
0018ab2c: 00000000 nop
0018ab30: 0c062289 jal 0x00188a24               Evade = (MA + X)*Faith%      
0018ab34: 00000000 nop
0018ab38: 14400003 bne r2,r0,0x0018ab48
0018ab3c: 00000000 nop
0018ab40: 0c061ba9 jal 0x00186ea4      -Y Brave Routine
0018ab44: 00000000 nop
0018ab48: 8fbf0010 lw r31,0x0010(r29)
0018ab4c: 27bd0018 addiu r29,r29,0x0018
0018ab50: 03e00008 jr r31
0018ab54: 00000000 nop

[62]
0018ab58: 27bdffe8 addiu r29,r29,0xffe8
0018ab5c: afbf0010 sw r31,0x0010(r29)
0018ab60: 0c06216e jal 0x001885b8      Magic Evade
0018ab64: 00000000 nop
0018ab68: 14400007 bne r2,r0,0x0018ab88
0018ab6c: 00000000 nop
0018ab70: 0c0622a1 jal 0x00188a84      Evade = (MA + x)%
0018ab74: 00000000 nop
0018ab78: 14400003 bne r2,r0,0x0018ab88
0018ab7c: 00000000 nop
0018ab80: 0c061ba9 jal 0x00186ea4      -Y Brave Routine
0018ab84: 00000000 nop
0018ab88: 8fbf0010 lw r31,0x0010(r29)
0018ab8c: 27bd0018 addiu r29,r29,0x0018
0018ab90: 03e00008 jr r31
0018ab94: 00000000 nop

[63]
0018ab98: 27bdffe8 addiu r29,r29,0xffe8
0018ab9c: afbf0010 sw r31,0x0010(r29)
0018aba0: 0c0620eb jal 0x001883ac      Throw/Catch Routine
0018aba4: 00000000 nop
0018aba8: 3c028019 lui r2,0x8019
0018abac: 8c422d90 lw r2,0x2d90(r2)
0018abb0: 00000000 nop
0018abb4: 90420000 lbu r2,0x0000(r2)
0018abb8: 00000000 nop
0018abbc: 1040001d beq r2,r0,0x0018ac34      Evasion Check
(Already checked above.)
0018abc0: 00000000 nop
0018abc4: 0c062144 jal 0x00188510      Physical Evasion
0018abc8: 00000000 nop
0018abcc: 14400019 bne r2,r0,0x0018ac34
0018abd0: 00000000 nop
0018abd4: 3c028019 lui r2,0x8019
0018abd8: 8c422d94 lw r2,0x2d94(r2)
0018abdc: 3c038019 lui r3,0x8019
0018abe0: 90633902 lbu r3,0x3902(r3)      Load WP
0018abe4: 90420038 lbu r2,0x0038(r2)      Load SP
0018abe8: 3c018019 lui r1,0x8019
0018abec: a42338d0 sh r3,0x38d0(r1)      Store WP as Y
0018abf0: 3c018019 lui r1,0x8019
0018abf4: a42238ce sh r2,0x38ce(r1)      Store SP as X
0018abf8: 0c0622b7 jal 0x00188adc      Damage Modifiers
0018abfc: 00000000 nop
0018ac00: 0c06195a jal 0x00186568      Damage Calculation (No elemental checks)
0018ac04: 00000000 nop
0018ac08: 0c061bf4 jal 0x00186fd0      Weapon Elemental (Fixed by Xifanie.)
0018ac0c: 00000000 nop
0018ac10: 3c028019 lui r2,0x8019
0018ac14: 8c422d90 lw r2,0x2d90(r2)
0018ac18: 00000000 nop
0018ac1c: 90420000 lbu r2,0x0000(r2)
0018ac20: 00000000 nop
0018ac24: 10400003 beq r2,r0,0x0018ac34
0018ac28: 00000000 nop
0018ac2c: 0c061c3f jal 0x001870fc      Elemental Absorption
0018ac30: 00000000 nop
0018ac34: 8fbf0010 lw r31,0x0010(r29)
0018ac38: 27bd0018 addiu r29,r29,0x0018
0018ac3c: 03e00008 jr r31
0018ac40: 00000000 nop

[64]
0018ac44: 27bdffe8 addiu r29,r29,0xffe8
0018ac48: afbf0010 sw r31,0x0010(r29)
0018ac4c: 0c0617a5 jal 0x00185e94      PA * Brave / 100 = Y (PA * 3/2 if weapon if polearm)
0018ac50: 00000000 nop
0018ac54: 0c0622b7 jal 0x00188adc      Damage Modifiers
0018ac58: 00000000 nop
0018ac5c: 0c06195a jal 0x00186568      Damage Calculation  (No elemental checks)
0018ac60: 00000000 nop
0018ac64: 8fbf0010 lw r31,0x0010(r29)
0018ac68: 27bd0018 addiu r29,r29,0x0018
0018ac6c: 03e00008 jr r31
0018ac70: 00000000 nop


Note:
Figured some things out by looking at Pokeytax's notes
1) +1 Level = 0x80 at 0x10 + 0x192d8c (self) or 0x192d90 (foe)
2) Switch Team = 0x40 at 0x10 + 0x192d8c (self) or 0x192d90 (foe)
3) Steal Item = 0x10 at 0x10 + 0x192d8c (self) or 0x192d90 (foe)
4) Break Item = 0x4 at 0x10 + 0x192d8c (self) or 0x192d90 (foe)
5) Unit is now murbol = 0x2 at 0x10 + 0x192d8c (self) or 0x192d90 (foe)
3) Target has golem = 0x1 at 0x10 + 0x192d8c (self) or 0x192d90 (foe)
6) -1 Level = 0x1 at 0x11 + 0x192d8c (self) or 0x192d90 (foe)

39 and 3A could easily be merged with X.
However, changing 40 is nowhere as easy because to load a status effect, you need to load a byte (5 different options) and each byte could have any value from 0-FF.  Hence, you'd need two variables to be able to check for any status.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Vanya on January 12, 2011, 02:16:24 pm
48, 49, 4B - Perhaps the weapon routine that sets formula 0 for abilities could be used as a base to make these load Y instead of Z if it detects NOT an item ability.

5A ~ 5D - Now having the address of the subroutine that checks for Dragons, I would definitely encourage some enterprising ASM hacker to consider modding it to check for monster type based on the value of Y. This would conflict with some of the existing Dragon formulas, but those can be changed anyway. I think we can all agree that having a double of Shout that only works on Dragons is redundant. I would immediately suggest an attack formula with a power boost so Hunters can have their XX Killer abilities.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on January 17, 2011, 07:01:40 am
All right: time to post my formula hacks.  Again, this will be done in parts, for it is very large.

Note, the following assumes you are using my gun damage fix.

BATTLE.BIN
0x121B64
E8FFBD27
1000BFAF
4421060C
00000000
16004014
00000000
8E21060C
00000000
12004014
00000000
1980023C
E5384394
00000000
FEFF6224
0A004010
00000000
F9FF6224
03004014
00000000
921C060C
00000000
AD1F060C
00000000
F4220608
00000000
B91D060C
00000000
1000BF8F
1800BD27
0800E003
00000000

BATTLE.BIN
0x128618
64
0x12861C
64
0x128624
648B
0x128628
648B



BATTLE.BIN
0x121BE0
E8 FF BD 27
10 00 BF AF
CC 1D 06 0C
00 00 00 00
19 80 02 3C
02 39 42 90
19 80 03 3C
FA 38 63 90
19 80 01 3C
CE 38 22 A4
19 80 01 3C
D0 38 23 A4
E0 17 06 0C
00 00 00 00
E9 17 06 0C
00 00 00 00
D1 21 06 0C
00 00 00 00
DF 21 06 0C
00 00 00 00
E7 FF 40 14
00 00 00 00
54 1C 06 0C
00 00 00 00
3F 1C 06 0C
00 00 00 00
EE 22 06 08
00 00 00 00

BATTLE.BIN
0x128620
E08B



BATTLE.BIN
0x121C50
E8 FF BD 27
10 00 BF AF
A7 16 06 0C
00 00 00 00
E0 17 06 0C
00 00 00 00
E9 17 06 0C
00 00 00 00
7E 21 06 0C
00 00 00 00
5A 19 06 0C
00 00 00 00
F4 1B 06 0C
00 00 00 00
D4 1C 06 0C
00 00 00 00
EE 22 06 08
00 00 00 00

BATTLE.BIN
0x12862C
508C
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Vanya on January 17, 2011, 03:39:01 pm
what do you mean by "allows procs"?

And the "functions like 2d" means that thing you mentioned before about it having 100% Status, right?
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on January 17, 2011, 05:37:29 pm
"Allows procs" was a feature I didn't add to the weapon formulas because I realized weapon attacks would mess it up.  It will, however, be added to all other formulas.  It allows you to use an unused tab to toggle status/spell procs.  I also intend to use another toggle to which will determine whether P/M-EV is used and whether it's classified as physical or magical damage.
Yes, "functions like 2D" means 100% with All or Nothing, Cancel, or Random and 25% on Separate.  If set to spell procs, they will occur at 100%.

An example of this will be given tonight.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on January 17, 2011, 06:22:07 pm
That sounds rather great for consolidating a lot of the damage based formulas and giving them more utility.  Will you also be using those suggestions I gave you for consolidating the various Hit_F(MA+X) formulas, Hit_(MA+X) formulas, (Stat)+(Y) formulas, Hit_(Stat)+/-(Y) formulas, and Hit_F(Stat)+/-(Y) formulas as well?  They'd give full control of all stat and status manipulation centered in a compact 7 formula vs the retardation Square used to get not even half the effect so it seems like a waste not to.

E: In addition to our discussion before, I recommend letting those stat formulas reference CT as well, so skills that boost the current CT of a unit can be made as well, if possible.  More utility is never bad after all.

E2: Is the Cheer Up one even needed?  Can an unevadable Hit_(MA+255) even be dodged?  My memory is flaky as to whether the game treats taking Compat out of 100 or out of the 255+ in that situation.

E3: Actually... couldn't you use a signed byte for the Y value in Hit_(Stat)+(Y) and Hit_F(Stat)+(Y), further reducing it to two formula to control all forms of stat increments and decrements while the two aforementioned Hit_(MA+X) Evade(Y) and Hit_F(MA+X) Evade(Y) controlled all the status related stuff?

When you get to disassembling it's code more, could the third unused flag be used to determine Knockback?  I know I've bugged you on that about probably 3-4 times now but it's one of those things that could actually be used to create huge strategic implications if it could be used on more than one formula outside of Critical Hits.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on January 18, 2011, 07:40:16 am
E1 and 3: I intend to do all that.
E2: MA + 255 without evasion can miss between shell/MADEF/worst compatibility/elemental half/null.  If it's "curative", then the first two don't apply.
Knock Back: I'm not sure.  I already know how to add it, but I'm not sure knockback's the best use.  Maybe a flag to load healing/cancel status checks to help me save more space while allowing any formula to heal or ignore protect/supports?

Note, my following hack assigns commands to Kanji-space.  This is temporary as I try to fully realize my efficiency gains.  Once all the formulas are coded, I'll likely move this back into the main formula routine space.
Also, the following hack hard-codes the Work formula to deal 25% damage as recoil as default.  It will be noted, so future hackers may freely change it.
Lastly, this hack depends on the other consolidation hack for weapon formulas for certain offsets.


BATTLE.BIN
0xF2098 //Katana Break
E8FFBD27
1000BFAF
1980023C
E5384294
00000000
E0FF4224
0400422C
03004010
00000000
441E060C
00000000
1000BF8F
1800BD27
0800E003
00000000

BATTLE.BIN
0xF20D4 //Toggle for Physical/Magical
E8FFBD27
1000BFAF
1980023C
F3384290
00000000
80004230
05004010 //Toggled means M-EV
00000000
6E21060C
00000000
45640508
01000424
4421060C
00000000
00000424
1000BF8F
1800BD27
0800E003
00000000

BATTLE.BIN
0xF2120 //Toggle for Spell/Status Proc
1980023C
F3384290
00000000
40004230 //Toggled means spell proc.
03004010
00000000
F2220608
00000000
EE220608
00000000

BATTLE.BIN
0x11EC94 //Loads any stat instead of MA, referenced by X.  ASM may fail.
1980023C
942D428C
1980033C
F9386190
21104100 //Fear rides on this line...if fail, move to free space and add nop
00004290
FA386190 //Ditto
00000000
CE3862A4
0800E003
D03861A4

BATTLE.BIN
0x121C98  //Main Routine
E8FFBD27
1000BFAF
2664050C
00000000
3564050C
00000000
C7FF4014
00000000
2517060C
00000000
FF17060C
00000000
19008014
00000000
D121060C
00000000
1980023C
E5384294
00000000
C9FF4224
0100422C
21004014
00000000
DF21060C
00000000
B3FF4014
00000000
1980023C
E5384294
00000000
F8FF4224
0100422C
24004010
00000000
541C060C
00000000
6B230608
00000000
5318060C
00000000
B722060C
00000000
3E19060C
00000000
1980023C
E5384294
00000000
C9FF4224
0100422C
05004010
00000000
471A060C
00000000
60230608
00000000
5A19060C
00000000
B41B060C
00000000
FE1B060C
00000000
1980023C
902D428C
00000000
00004290
00000000
8AFF4010
00000000
C721060C
00000000
86FF4014
00000000
1980043C
902D848C
00000000
04008190
00000000
03002014
00000000
06008194
01000434
1980023C
E5384294
00000000
DFFF4324
0100632C
10006014
00000000
BEFF4324
0100632C
13006010
00000000
1B80023C
8C2D428C
01000334
000043A0
80000334
250043A0
83180100 //Recoil is 25%
040043A4
00000000
9C230608
00000000
1980033C
902D638C
07008014
00000000
20000434
250064A0
040060A4
080061A4
9C230608
00000000
10000434
250064A0
060060A4
0A0061A4
48640508
00000000

BATTLE.BIN
0x128630
988C
0x128690
988C
0x128694
988C
0x1286EC
988C
0x128718
988C
0x128748
988C


The above disables formula 09 (demi).  Until I upload my fixes for that formula, test this at your own risk.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on January 18, 2011, 02:28:00 pm
Allowing any formula to heal is as simple as making better use of elements - the only problem in that method is Undead Reverse but I can't imagine that not being something that could be fixed.  Though... are there unused flags in the Inflict Status window?  One could very easily rig one of those to trigger Knockback as well if they exist, though that means any skill that wants to inflict more than just Knockback needs unique Inflict Statuses.  Either that or possibly making use of any empty toggles in the Learn with JP / Learn on Hit / etc boxes?  I'm all for saving as much space as humanly possible, but Knockback needs a huge sum of love too.

I've thought on it more, and I really think you should make a secondary version of this hack with vanilla's Work Formula if you can since your change costs utility to gain it, and I can easily imagine people wanting the old utility more than the new one.  

When your notes say "ASM may fail" does that mean it is imperfect and you still need to update it or that it jumps to a backup that covers it when it fails?  Also, you should probably say which checkboxes on Patcher toggle which item.

E: Is it safe to assume for Steal Equipment / Equipment Break / Mighty Sword, the unused variable will be used to determine which equipment slot is affected?  If so, is it possible to merge this check to incorporate PA / MA / SP / CT / HP / MP / etc. to max out the versatility of all three relevant formula and bomb Formula 2B entirely?  Actually making the game be able to handle what to do if a stat is "stolen" would be another matter, but I'd tell people not to do that for now and call that something for another day since I'd assume they'd all draw from the same X variable.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on January 18, 2011, 05:32:36 pm
No, if you convert damage to healing, you still run into evasion, defense/magic defense UP, shell/protect, and reaction triggers.  Hence, I actually can't easily consolidate healing spells with damage spells because of the missing checks on the former.

The flags used are the first two blank ability flags, the two above "Ranged Weapon".

E: No, the unused variable does not determine that; the game hard-codes the matter by checking the used ability's number.  Similarly, the game checks ability numbers to determine whether PA/MA/SP is reduced.  Although I can put two hard-code subroutines in one function as long as it's impossible to run both (while having maintenance block both), I won't put the weapon break sequences in the same routine because the formula used will be totally different (the only common check will be maintenance).  I'll likely fuse all the stat/up down formulas (maybe even Demi/Gravi2/Mute) into this instead (and ignore maintenance on HP/MP damage).
However, we still face the classic problem of insufficient variables for full customization:
1) Accuracy is (Stat1 + Y)%  (2 Variables)
2) Effect is +/-(X) to Stat2 (2 more variables...treat X as unsigned% if HP or MP)
The question now really is this....which variable is most important?  I think Square got it right by setting X (which should include boosts and decrements) and Y as the most important, meaning I should hard-code formulas to use different Stat1 depending on the formula (PA/MA/SP + Y and the faith variants of those...so six possibilities) and rework hard-coding to make Stat2 dependent on modular arithmetic (mod 8 since we have CT/maxHP/maxMP/PA/MA/SP/Faith/Brave) based on the ability slot's number.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on January 18, 2011, 06:42:15 pm
Quote from: formerdeathcorps on January 18, 2011, 05:32:36 pmThe flags used are the first two blank ability flags, the two above "Ranged Weapon".


This doesn't tell which is which...

Quote from: formerdeathcorps on January 18, 2011, 05:32:36 pmNo, the unused variable does not determine that; the game hard-codes the matter by checking the used ability's number.  Similarly, the game checks ability numbers to determine whether PA/MA/SP is reduced.  Although I can put two hard-code subroutines in one function as long as it's impossible to run both (while having maintenance block both), I won't put the weapon break sequences in the same routine because the formula used will be totally different (the only common check will be maintenance).  I'll likely fuse all the stat/up down formulas (maybe even Demi/Gravi2/Mute) into this instead (and ignore maintenance on HP/MP damage).


I see.  So the garbage hardcoding is going to be maintained currently, but a bunch of stuff is going to be crunched together.  It's a wash, I guess, but still seems rather mediocre.

Quote from: formerdeathcorps on January 18, 2011, 05:32:36 pmThe question now really is this....which variable is most important?  I think Square got it right by setting X (which should include boosts and decrements) and Y as the most important, meaning I should hard-code formulas to use different Stat1 depending on the formula (PA/MA/SP + Y and the faith variants of those...so six possibilities) and rework hard-coding to make Stat2 dependent on modular arithmetic (mod 8 since we have CT/maxHP/maxMP/PA/MA/SP/Faith/Brave) based on the ability slot's number.


I see.  I feel it's worth pointing out though that the changes we discussed to the Beaking and Foxbird formulas basically makes this pointless and lets you just gut all the involved hardcoding related to it though, unless I'm missing something.  Though I realized my previous examples for those formula were a bit flawed.  Using Hit_F(MA+X) (Y), where Y controls the stat and operation done and every increment of 16 (0-255) is the flag.  So say, 0-15 is -1-16 PA, 16-31 is -1-16 MA, 127-143 is +1-16 PA, etc., or possibly use a less "even" version that leaves more space allocated for Br/Fa since most PA/MA reductions never break 5 each anyway.  If you can do this, you can then dupe the two formula with a (PA+X) input and again with a (SP+X) input, avoiding all the hardcoding altogether and possibly dedicating it to other things.

If you don't get what I'm trying to say here, PM me or try to get me on Mibbit, since I think this is probably your best bet for saving fucktons of space and dodging fucktons of hardcoding simultaneously and uses lower net formula slots.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Vanya on January 18, 2011, 09:16:12 pm
Quote from: formerdeathcorps on January 18, 2011, 05:32:36 pm
No, if you convert damage to healing, you still run into evasion, defense/magic defense UP, shell/protect, and reaction triggers.  Hence, I actually can't easily consolidate healing spells with damage spells because of the missing checks on the former.


If you had a flag that marked a skill as healing rather than damaging couldn't you use that same flag to bypass said checks with a simple jump in the main formula?
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on January 19, 2011, 06:31:35 am
The upper flag, if flagged, is M-EV and Shell/MADEF.  Otherwise, it defaults to P-EV (works only if evadable is also checked), and will consider Protect/DEFUP/Critical Hits.
The lower flag, if flagged, allows spell procs.  Otherwise, it defaults to status procs.

QuoteIf you had a flag that marked a skill as healing rather than damaging couldn't you use that same flag to bypass said checks with a simple jump in the main formula?

Exactly why I want it.  However, Raven is right; the tactical features wouldn't be too impressive.  Hence why I'm in a quandary.

QuoteWhen your notes say "ASM may fail" does that mean it is imperfect and you still need to update it or that it jumps to a backup that covers it when it fails?

It means that my tests wrote to Kanji-space but I realized I could improve on Square's coding in the original get MA and Y routine without wasting space, but it's untested (and is missing a few of the safety NOP commands I used when I wrote to Kanji-space), and hence, may screw up.

QuoteI see.  So the garbage hardcoding is going to be maintained currently, but a bunch of stuff is going to be crunched together.  It's a wash, I guess, but still seems rather mediocre.

Already addressed this with you in iRC, but for anyone who doesn't understand my post:
Stats lowered will be assigned by applying modular arithmetic to the skill numbers.  This means skill numbers {1, 9, 11, 19...} would lower PA, {2, A, 12, 1A...} would lower MA, and so on, through all 8 stats.
Y influences hit rate.  This can be fixed by FFTP.
X (fixable by FFTP) influences decrement/boost.  Numbers that are less than 0x80 decrement by X.  Numbers that are higher than 0x80 boost by the amount X - 0x80.  Maintenance will void status if X < 0x80.
The status checked by hit rate is fixed and will be determined by the formula.  Since there are lots of formulas that boost/lower stats, we can easily spare 9 of them to check for ({PA, MA, SP, 0} + X)*{Faith, 1} OR (100%).  This means that we should be able to free up formula numbers that are usable for totally new formulas (yes, I'll take suggestions for those now).

To be honest, however, considering how FFT checks for damage, I probably will not lump HP/MP % damage with stat decrements.  It would be too messy.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Vanya on January 19, 2011, 12:26:49 pm
Quote from: formerdeathcorps on January 19, 2011, 06:31:35 am
The upper flag, if flagged, is M-EV and Shell/MADEF.  Otherwise, it defaults to P-EV (works only if evadable is also checked), and will consider Protect/DEFUP/Critical Hits.
The lower flag, if flagged, allows spell procs.  Otherwise, it defaults to status procs.


Alright, just to make sure I get you:
upper flag = treat this as a magic skill. (further referenced as "magic flag")
no upper flag + evadable flag = treat this as physical skill.

If so, then what if I set the magic flag and the evadable flag? What if I set neither?

And because I'm just not sure I'm getting it:
spell procs = cast spell as indexed by 'inflict status'.
status procs = process status as indexed by 'inflict status'.


Quote from: formerdeathcorps on January 19, 2011, 06:31:35 am
Already addressed this with you in iRC, but for anyone who doesn't understand my post:
Stats lowered will be assigned by applying modular arithmetic to the skill numbers.  This means skill numbers {1, 9, 11, 19...} would lower PA, {2, A, 12, 1A...} would lower MA, and so on, through all 8 stats.
Y influences hit rate.  This can be fixed by FFTP.
X (fixable by FFTP) influences decrement/boost.  Numbers that are less than 0x80 decrement by X.  Numbers that are higher than 0x80 boost by the amount X - 0x80.  Maintenance will void status if X < 0x80.
The status checked by hit rate is fixed and will be determined by the formula.  Since there are lots of formulas that boost/lower stats, we can easily spare 9 of them to check for ({PA, MA, SP, 0} + X)*{Faith, 1} OR (100%).  This means that we should be able to free up formula numbers that are usable for totally new formulas (yes, I'll take suggestions for those now).


That's pretty neat, but wont it require that certain abilities be swapped around to new slots? I imagine that they aren't currently sitting in places that would allow them to keep the stat they're supposed to be modding. Also, what about the 2 abilities that mod PA, MA, SP & Brave; how will these be treated?

And lastly, will X now always be signed or is that just for formulas that mod a stat?
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on January 21, 2011, 11:46:19 pm
I haven't been able to catch you on IRC, but I've been meaning to ask - now that I know what you're doing, is there a reason to modularly divide by Ability Slots to find the breaking stat instead of just dividing the Y value itself similarly to how I suggested before?

The ranges would be more than large enough that no one would be bothered, and anything that removes tying things to ability slots seems better than anything that does, and I can't imagine it taking more space.  This is the same for the X value in the Break, Steal, and Mighty Sword skills.  Is there a reason you can't divide the X (since I assume you'll use X to decide PA/MA/SP etc as you have been) by a certain value for those formulas to determine the slot the ability will affect?  So say, X=1 is PA that affects Weapon, X=9 is PA that affects Shield, etc.  Maintaining the current hardcoding is a horrible idea if it can be avoided because it severely limits skill creation.

If you for some reason cannot by any means whatsoever avoid maintaining the hardcoding, will you at least be doing something similar to your original plan for the stat breaking skills and modularly dividing ability slots by 5 so any of the 3 formula can affect the proper gear when in the proper slot and they're not limited to one instance each?  That's still better than current, but I think using the X value itself for all its worth is infinitely, infinitely superior.  Any time you can break reliance on an ability slot is good because it eases the creative process, and these seem like two huge areas to go for the easing even more than the space if it for some reason hits that point.

If you're looking for custom formula to add for free formula spaces, my first recommendation would be selectable versions of all the weapon formulas in Swordskill form.  2D already covers XA * (WP+Y), so add (XA1+XA2)/2 * (WP+Y), XA * [Br/Fa]/100 * (WP+Y), etc.  For the second, again divide the X to find out what XA2 should be, same with XA * Br/Fa.  You're using them all so exploit all your Xs for all they're worth.

Also, if you make this hack require use of ARH, you can make use of the Requires Sword and Requires Materia Blade flags for your own devices.  Just saying.  Though speaking of requiring other ASMs, you should place your Gun Fix in the post where you mention needing it as well so everything is in one place.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on January 23, 2011, 05:21:19 am
Quote
upper flag = treat this as a magic skill. (further referenced as "magic flag")
no upper flag + evadable flag = treat this as physical skill.


Upper Flag = Treat as magic.  No Upper Flag = Treat as physical.  If evadable, will reference upper flag to see what type; otherwise, it will ignore evasion altogether.

QuoteThe ranges would be more than large enough that no one would be bothered


That is only true for PA/MA/SP (assuming you're not making a gimmick patch where -All PA is allowed).  Quick (+127 CT), Last Dance (-127 CT), and a boss chicken spell (-40+ brave) would necessitate numbers larger than your suggested range (+/- 16).  Arguably, I could have two different routines for reading, depending on formula used, to differentiate between PA/MA/SP and CT/Br/Fa, but I'd then need two separate read routines, which seems inefficient.

Quotewill you at least be doing something similar to your original plan for the stat breaking skills and modularly dividing ability slots by 5 so any of the 3 formula can affect the proper gear when in the proper slot and they're not limited to one instance each?


Of course, though you'll still need a check on formula number, so you can differentiate between steal and break.  It's just that there's no good reason to use the same routine as stat breaks.  Dance/Sing/Talk Skill's hard-coding will likely be deleted altogether (since most of the effects are covered by either negative status formulas or my PA/MA/SP consolidation), though I'll probably put status guard (finger guard) in the general negative status routine (so it'll block all negative status formulas that don't use faith).

QuoteThough speaking of requiring other ASMs, you should place your Gun Fix in the post where you mention needing it as well so everything is in one place.


I will do that when I'm completely done; right now, I'm using up other people's ASM space for some of my hacks, meaning there will be compatibility problems.  When finished, I'll move my custom routines to the sections I managed to free up.

Quotewe can easily spare 9 of them to check for ({PA, MA, SP, 0} + X)*{Faith, 1} OR (100%)


No longer needed.  If X < 101, it will always be non-faith, if 100 < X < 255, it will always use faith, and if X = 255, it means 100%.  Thus, we really only need 4 such formulas.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on January 23, 2011, 08:21:10 pm
Quote from: formerdeathcorps on January 23, 2011, 05:21:19 amThat is only true for PA/MA/SP (assuming you're not making a gimmick patch where -All PA is allowed).  Quick (+127 CT), Last Dance (-127 CT), and a boss chicken spell (-40+ brave) would necessitate numbers larger than your suggested range (+/- 16).  Arguably, I could have two different routines for reading, depending on formula used, to differentiate between PA/MA/SP and CT/Br/Fa, but I'd then need two separate read routines, which seems inefficient.


You already had separate formulas for + and -, meaning each range would be 32 by default, not 16.  You can easily cut into the space used by PA, MA, SP for more Br, Fa, CT.  I would honestly just remove the ability to "break" max HP and MP altogether for a plethora of reasons and eat that 64 space, so that PA, MA, SP could have ranges something like 10, 10, 10, and the remaining 220/221 or 215/216 could be dedicated to Br/Fa/CT in groups of 75.  Quick and CT00 will need their own formula anyway unless you know how to make a read that causes "Quick" or "CT00" display if the value is +/- 127. Regardless, though, I would remove CT from this formation and add its own two formulas that read whether the number is greater than 126 or not to determine Faith use, adding 1 to the bonus if it's below 127 CT so it can add Quick or CT00 CT.

Tl;dr, read X, 0-9 = PA +1-10, 10-19 MA +1-10, 20-29 SP +1-10, 30-104 Br +1-75, 105-179 Fa +1-17, 180-255 CT +1-75, +/- operation determined by formula is what I'm suggesting based on your old setup.

Quote from: formerdeathcorps on January 23, 2011, 05:21:19 amOf course, though you'll still need a check on formula number, so you can differentiate between steal and break.  It's just that there's no good reason to use the same routine as stat breaks.


I see.  I will always mandate that you should destroy that hardcoding though.  Are you honestly just unable to do it at this time?

One could argue reading by Mod 13 and allowing XA*Y, FA_XA*Y, 100%, XA*WP*Y, Dmg_XA*(WP+Y), , etc all be able to go at any stat or equipment slot would be pretty good from a design standpoint, honestly - being able to make a unit lose 1 PA while doing damage, etc. is a nice added bit of versatility and actually justifies you maintaining the equipment slot hardcoding.  If you want to get messy, you could also consolidate the Mighty Sword formula with 2D, using X to both find the XA and determine whether it reads for Break or not, and extend this to the other damage formulas I suggested, allowing a designer to use any weapon formula to break any piece of gear or any stat without using any additional formula.  Or possibly use one of the Requires Sword or Requires Materia Blade flags to say "this skill breaks shit" if you use my suggestion of requiring ARH to get the flags you need to both go "this skill heals" and "this skill Knocks Back."  Even if you use two separate Mod formulas, the last bit about merging Mighty Sword and 2D for breaking and extending it to more damage formulas seems like a great idea.

Honestly, I know a lot of people use ARH anyway, so even if you don't want them in the general release, finding the best use for the third flag then making "add on" mini-hacks for the other two so people who are using ARH can have some added capability for their now-useless flags.

Quote from: formerdeathcorps on January 23, 2011, 05:21:19 amDance/Sing/Talk Skill's hard-coding will likely be deleted altogether (since most of the effects are covered by either negative status formulas or my PA/MA/SP consolidation), though I'll probably put status guard (finger guard) in the general negative status routine (so it'll block all negative status formulas that don't use faith)


This is good.  I don't like the idea of forcing people to use a "buffed" Finger Guard should they not want it if they want to use this consolidated Formula hack, though.  I'm guessing your use of flags makes my suggestion of X determining XA*Y's evasion useless, so I suggest something else - use two tables for X, where X = 1/2/3/4/etc determines PA/MA/SP/etc, then the next numbers after that determine the same values again but say "This skill can be blocked by Finger Guard."  This allows both XA*Y and Fa_XA*Y to be blocked by it if people want, and allows them to make skills of both that aren't instead of imposing one single form of design on them.  I would also add two optional bits of code in the hack itself that causes something blocked by Finger/Status Guard to have 0% on Sleeping targets and Monster targets, so the user can choose to implement either or both should they want to more faithfully represent Talk Skill in whatever project they're making.

The only concern is that one can't use Finger Guard to block Br/Fa modding on bosses anymore because that hard coding is being rightfully destroyed, which was a great bit of design freedom even if the skill was useless in game for the player.  Is there any plan to remedy this?

Quote from: formerdeathcorps on January 23, 2011, 05:21:19 amNo longer needed.  If X < 101, it will always be non-faith, if 100 < X < 255, it will always use faith, and if X = 255, it means 100%.  Thus, we really only need 4 such formulas.


That still doesn't cover Quick and CT00, juss sayin'.  You should use 0-126 and 127-254.  I like that this only takes 4 formula but dislike that this still forces the use of hardcoding.  I suppose there's not much choice here though, since a gain of all that formula space is pretty awesome.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on January 31, 2011, 07:58:52 am
I'm taking a break from direct formula coding since a lot of my coding inefficiency (i.e. not enough sub-routinization) is coming from Square's inflexible code routines (which then forces me to write to free-space).  Thus, I need to switch focus, at least temporarily, to making more efficient code routines (rather than just jal commands in the formula routines) for various functions, as well as their generalizations that reflect my plans.

In theory, this should also making testing easier since the objects being tested are smaller chunks.

Zodiac Compat. Routine Rewrite:
BATTLE.BIN
0x11D990
52
0x11D99C
4F
0x11DA2C
FF008330
21304000
02000234
0F006210
2110C000
03006228
05004010
01000234
10006210
2110C000
AA120608
00000000
04000234
0D006210
05000234
06006210
2110C000
AA120608
00000000
00021082
A9120608
2110C200
00021042
A9120608
2110C200
A8120608
00021082
2110C000
00021042
2310C200
0000E2A4
1980033C
CE386324
00006284
00000000
0200401C
01000234
000062A4
0008BD27
0800E003
00000000
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on February 05, 2011, 04:31:44 am
After weeks of discussion on iRC with Raven, I think I have the final structure hammered out.  Everything I've already posted on this matter will be completely rewritten.

Plans:

1) HP Damage is determined by the AI HP flag.
2) MP Damage is determined by the AI MP flag.
3) Stat +/- is determined by the AI Stats flag.
4) Steal is determined by the AI Unequip flag.
5) Protective effects are considered if the AI Target Enemies flag is checked.
 a) MADEF/Shell are considered if the AI MADEF flag is checked.
 b) DEFUP/Protect are considered if the AI DEF flag is checked.
 c) Checking both means both sets will be considered.  Checking neither means no protective status effects are considered.
6) Protective status effects and damaging counters are ignored if AI Target Allies flag is checked.
 a) Counters like Absorb Used MP will still trigger.
7) AI Undead Reverse now a toggle.  If flagged:
 a) The third blank spot under Abilities (going from top to bottom and then left to right), if flagged, means drain.  If not, means healing.
 b) If AI Undead Reverse is not flagged, the corresponding flag has no meaning.
8) Random Fire is now a toggle.  If flagged:
 a) If AI Random Hits is flagged, use 1-X hits.
 b) IF AI Random Hits is unflagged, use X hits.
9) Faith will be considered if the Unknown under AI Random Hits is flagged (this one means calculate Faith)
10) P-EV will be considered if the Unknown under the above is flagged (this one means calculate P-EV).
 a) The evadable flag will be changed to mean calculate M-EV.  Obviously, if both are flagged, P and M-EV are calculated against an attack.  If neither is flagged, neither will be.
11) The second blank spot under Abilities (going from top to bottom and then left to right) is spell proc if flagged and status proc if not.  This is unchanged from before.
12) Using ARH 2.1, Equip Sword is now redundant.  The slot is now a knockback flag.  The chance used is the same as that of Formula 37.
13) Using ARH 2.1, Equip Materia Blade is now redundant.  The slot is now a recoil flag.  The recoil damage is referenced by X (which is division as a percent of total damage)
14) All formulas will be standardized.  This means X determines XA and Y determines accuracy (on XA + Y) or damage (on XA * Y).
 a) If the lower 3 bits of X is 1, use PA (automatically means ATK UP is referenced)
 b) If the lower 3 bits of X is 2, use MA (automatically means MATK UP is referenced)
 c) If the lower 3 bits of X is 3, use SP (automatically means ATK UP is referenced)
 d) If the lower 3 bits of X is 4, use WP (automatically means ATK UP is referenced)
 e) If the lower 3 bits of X is 5, use W-EV (automatically means ATK UP is referenced)
 f) If the lower 3 bits of X is 6, use S-EV Physical (automatically means ATK UP is referenced)
 g) If the lower 3 bits of X is 7, use Level / 4, with a minimum cap of 5 (automatically means MATK UP is referenced)
 h) On formulas using % damage/recoil, damage/recoil percentage is determined by the upper 5 bits on X.  Essentially the formula is X = [X/8] * 3 + 7.  Y is normal.
 i) Items broken/stolen is determined by the upper 5 bits in X (0x8 = Shield, 0x10 = Head, 0x20 = Armor, 0x40 = Weapon, 0x80 = Accessory).  Y is normal.  Break is true if the upper 5 bits in X are non-zero and Unequip is not flagged.  Steal is true if the upper 5 bits in X are non-zero and Unequip is flagged.  Steal Gil is true (LVL * XA1 gil stolen) is true if the upper 5 bits in X are zero and Unequip is flagged.  Note, this does not stack with formulas using % damage.
 j) Stats +/- is determined by the upper 6 bits in X (0x4 = PA, 0x8 = MA, 0x10 = SP, 0x20 = CT, 0x40 = Br, 0x80 = Fa).  This means that only PA/MA/SP are possible for XA choices.  Y is such that the lower 3 bits on Y determine gradations (0 = +1 PA/MA/SP, +10 CT, +5 Br/Fa; 1 = +2 PA/MA/SP, +20 CT, +10 Br/Fa; 2 = +3 PA/MA/SP, +30 CT, +15 Br/Fa; 3 = +4 PA/MA/SP, +40 CT, +20 Br/Fa; 4 = +5 PA/MA/SP, +50 CT, +30 Br/Fa; 5 = +6 PA/MA/SP, +60 CT, +40 Br/Fa; 6 = +7 PA/MA/SP, +80 CT, +50 Br/Fa; 7 = +8 PA/MA/SP, +127 CT, +60 Br/Fa), the 4th bit determines sign (so 8-15 are the negative versions of the above), while Y = [Y/16] * 16 is the accuracy boost.  This is true only if Stats is flagged.
 k) The upper 5 bits in X determine the cap on the amount of extra hits (up to 31) if Random Fire is flagged.
 l) On formulae using (XA_1 + Y) / 2 * XA_2 or (XA_1 + Y) * XA_2 as damage formulas, or (XA_1 + XA_2 + Y)% as hit formulas, 0-15 on X corresponds to (PA/PA, PA/MA, PA/SP, PA/WP, MA/PA, MA/MA, MA/SP, MA/WP, SP/PA, SP/MA, SP/SP, SP/WP, WP/PA, WP/MA, WP/SP, WP/WP).  The damage/recoil percentage is determined by the upper 4 bits on X and is X = [X/16] * 6 + 4.  The multi-hit cap is also determined by the upper 4 bits (up to 15).  Equipment break will only consider the top 4 bits (notice this still corresponds perfectly to MIGHTY SWORD, which cannot destroy shields...while for BREAK, I will simply divide the upper four bits by two, so accessories can't be broken).
 m) On any formula using (XA + Y)% as hit chance, if Y = 255, it automatically means 100%.  On the stat break formula, if Y > 239, it automatically functions as 100% (meaning that there, the maximum effective Y in the accuracy formula is 224).
 n) It is inadvisable to try to have moves using more than one of recoil, % damage, stat break, item break, multi-hit because they all compete for the same 4-5 upper bits.
15) Undead status now absorbs dark and is weak against holy.  Oil will function correctly (weak: fire) in this hack.
16) Drain is now always reversed against any element's absorption, and cure is always reversed against any element's weakness.  This replaces undead reversal with something far more generic.  Thus, this patch now forces drain to be darkness elemental and curative spells to be holy element.
17) After seeing the exploitative nature of ice ball + concentrate + flame shield + magic ring in the 1.3 AI tournaments (and knowing that similar tricks are possible between oil and flame shields), I'm proposing to make weak override absorb (meaning if you're weak against an element, you cannot be healed by that element).  I'm also likely going to make absorb completely ignore reactions that don't boost evasion (so you can't proc dragon spirit on fire/ice ball healing).
18) Signed loading of HP/MP damage bytes.  Doing this should free up 4 bytes I can use, possibly to assist the AI calculate damage better.  The only downside I can think of is that a 1.3 Utlima can no longer heal for 65535 HP when she eats a crystal, but rather, is forced to heal for half that amount.
19) All formulas that are non-elemental or NS will take elemental and status.
20) The first blank spot under Abilities (going from top to bottom and then left to right), if flagged, means 100% inflict on All or Nothing and 25% on separate.  If unflagged, the vanilla formulas will be observed (25% on everything except Random Fire, which is 6.25%).
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Vanya on February 05, 2011, 08:14:40 am
That all sounds fantastic to me. I don't see anything that needs be improved here.
Using the AI flags for referencing ability features is brilliant. Makes me wonder why I didn't think of that... really makes me wonder what the hell Square's PAID, PROFESSIONAL programmers were thinking.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on February 05, 2011, 01:26:46 pm
EDIT: 4) How does the game determine Break or Steal?  Look for a specially declared "Steal" formula(e), if true, Steak , else, Break?  Or have you broken my expectations and made Steal applicable to more formulae without telling me?  Actually.  We could have "Break" be the default setting if people choose to use an X of 9+, and override that code if Stats, Unequip, Random Fire, or Recoil.  If Stats is checked, hit stats based on X and Y, Unequip is checked and X is 9+, Steal proper slot(s), if Recoil is checked, Recoil with divisor based on table, if Random Fire is checked, hit randomly based on table.  This makes both Break and Steal completely flexible in addition to everything else, allowing for skills such as "Mug Helmet" that do a small amount of damage in addition to Stealing... or other, far more evil things.  I should've thought just of this during our IRC discussion but I was a bit too sick to think properly, I think.  Doing that also removes the need for an explicit "Steal" formula, saving space and letting Vanilla flavor Thief piggyback on the XA * Y formula like everyone else.

7) You need to force out separate space for each Undead Reverse, Heal, and Drain instead of forcing them to be together.  Vanilla has formula that can heal without Undead Reversal triggering, this hack should too.

14-l) We had agreed that the Mighty Sword being unable to hit Shields if the designer wanted it to was retarded and were going to make every equipment slot reachable by any formula.  Why the fuck did you go back on that?  That's dumb as hell.

15) Should be an optional feature as it deviates from Vanilla, though your hack of Undead Reverse pretty much makes it mandatory.

16) Is dumb, removes utility that existed in the original game, and forces more linear design.  This is why you need separate flags for each Undead Reverse, Heal, and Drain, so that if Undead Reverse, the skill gains that property, else functions as it does in Vanilla. This goes all the way back to my points against 7.  You're forcing certain design schema onto people when you shouldn't, and don't even need to.  You're using XA to determine Treat As Magical and Treat As Physical, two already used flags to determine P-EV and M-EV, and two more already used flags to determine Magic DefendUP and Defense UP.  if I remember correctly, another flag used to be Treat as MP Damage, but we incorporated that into the AI flags too.  Going through FFTP, I see...

Spell Proc Flag
Knockback Flag
Recoil Flag
Undead Reverse's current Heal/Drain flag.
???

So why the separation?  This still doesn't quite fix Drain based skills since they'd still need to be Dark to be Undead Reversed on this schema and some more minor bits of Healing nuance are still lost, but it's still far closer to Vanilla and you can easily check for the Drain flag instead of the Drain Element to reverse it and all should be good.

17) Both halves of that should be optional features of this hack.  It's forcing your own thoughts of game balance onto people else, and in no way has bearing on how the rest of the hack functions.  I say make both halves optional separately because I can easily see people wanting one and not the other - personally, I would want the second but not the first, and I could probably find someone with the opposite opinion in like 5 minutes.

Rest looks about right.  Yes, I'm being a rather picky dick about these things, but I'm still going to mandate until the end of time that if I cannot make the original Vanilla game with no noteworthy functional differences, this isn't good enough because the goal is to add features, not remove them.  Not being able to properly represent Chakra due to your use of the Undead Reverse Flag is a big offender here.  There are other smaller things that I also pointed out and should be easy tweaks.  Some of the most minor ones can't be avoided, but they're at least the most minor of the minor.

EDIT: If you remember my one request for this hack after the initial version is finished, you'll probably anticipate this last thought - but you should take the empty AI flag next to Line of Sight and make it connocate (CasBr + (ZZ))/100 * (TarBr + (ZZ))/100 and slightly edit the Faith input to be (CasFa + (YY))/100 * (TarFa + (YY))/100, where ZZ and YY are bolded portions that can be edited by the end user.  This allows for both modification of the Faith mechanic and builds the somewhat popular Fury directly into this hack in a far more controllable way.  The one I asked you for on IRC was a bit different from what I'm suggesting here (and I'd quite like it for my own work), but adding this to the general release would be amazing and round off the flag use nicely, by allowing the addition of Fury at the choice of the end user, giving Faith a constant at the choice of the end user, removing all NS, Non-Elemental, all hardcoding, better Undead Reverse control, and many other things.

EDIT 2: Vanya, Square didn't have FDC and I both being the stingiest motherfuckers imaginable and wanting to max out versatility in every possible way working for them for the span of about a week's worth of discussion.  We also know what a consistent coding convention is, which also helps a lot.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on February 05, 2011, 10:07:21 pm
1) Extra flag, as we discussed today in iRC, will be for setting 100% on all or nothing and 25% on separate (as formula 2D does).
2) Undead Reverse no longer exists except as a toggle.  AS I mentioned, it is now Undead status causing changes to elemental weakness/absorb and different behavior for drain/cure when dealing with absorb/weakness.  If you want a curative spell that heals everything, including the undead, flag it as non-elemental.  Ditto with drain.
3) As mentioned on iRC, I'll probably point out in the ASM the place to modify so the user can decide the correspondences for each of the 4 bits of BREAK and MIGHTY SWORD.  However, in the general release version, I will keep FFT's defaults.  The reason why I needed to use only 4 bits on formulas like MIGHTY SWORD (and ultimately BREAK as well) is because it uses two XA variables (PA and WP), both of which should be modifiable by 4 different stats.  That's a total of 16 different choices, which is the lower 4 bits.
4) Your idea about break and steal sounds good.  I didn't have a way to distinguish them before.
5) Your extra suggestion about incorporating the Fury hack as a toggle?  I probably will do it if no one else proposes a better idea, but it should be known that this is a suggestion, just like my 17).
6) I'll probably delete S-EV Magical for LVL / 4 (with a minimum cap of 5, referenced by MATK UP) because the latter has better scaling.  That being said, however, I'll reference the ASM so anyone can customize this if they want.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on February 06, 2011, 02:02:30 am
Okay, FDC and I hammered out a lot of stuff regarding flags and finishing touches and stuff, and all I have to say is... 23.  It's a glorious number and you all will shit bricks.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on February 06, 2011, 04:02:02 pm
All right...posting time.  This will not be in hex, as I normally post, but in commented commands, so people can understand better what I'm doing.

Convention:
Black = Commands
Blue = Offsets
Purple = Comments

Gets XA1 and XA2:
lui r1, 0x8019
lbu r3, 0x38F9 (r1) Loads X
lw r2, 0x2D94 (r1) Loads the attacker's stats
addiu r6, r1, 0x38CE r6 = XA1's address
addiu r7, r1, 0x38D0 r7 = XA2's address
andi r3, r3, 0x000F r3 = the last 4 bits of X
(LS) sltiu r4, r3, 0x0004
bne r4, r0, (*) If r3 < 4, GOTO (*)
lbu r5, 0x0036 (r2) r5 = Attacker PA
sltiu r4, r3, 0x0008
bne r4, r0, (*) If r3 < 8, GOTO (*)
lbu r5, 0x0037 (r2) r5 = Attacker MA
sltiu r4, r3, 0x000C
bne r4, r0, (*) If r3 < 12, GOTO (*)
lbu r5, 0x0038 (r2)  r5 = Attacker SP
nop
lbu r5, 0x3902 (r1)  r5 = Attacker WP
(*) beq r6, r7, (E) If r6 = r7, GOTO  End.
sb r5, 0x0000 (r6) Stores r5 at the address of r6
andi r3, r3, 0x0003
sll r3, r3, 0x0002
addiu r3, r3, 0x0001 The purpose of these r3 manipulations is to put r3 in a form that the previous loop can understand.
j (LS) Jumps back to the Loop's Start.
addiu r6, r6, 0x0002 r6 = r6 + 2 = r7 = XA2's address
(E) jr 31 Returns to the Main Formula Routine.
nop
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on February 07, 2011, 08:49:05 pm
Checks XA2 for support abilities (must come immediately after the above routine):

ori r4, r0, 0x0005
beq r4, r3, (MA) NOTE: r3 can only be 1, 5, 9, or 13, which corresponds to PA, MA, SP, WP.  If r3 is MA, GOTO (MA)
addu r7, r31, r0 Stores the return address in r7 because it'll be modified by the jal commands below.
ori r4, r0, 0x000D
bne r4, r3, (PA/SP) If r3 isn't WP, GOTO (PA/SP)
lbu r5, 0x38D9 (r1)  Loads the "Two Hands" byte.
jal (WP-UP) If WP, GOTO  (WP-UP)
lbu r4, 0x38FF (r1) Loads weapon characteristic byte.
(PA/SP) jal (P-UP) If PA/SP, GOTO (P-UP)
lbu r3, 0x38D8 (r1) Loads Weapon Type byte.
j (E1) GOTO (E1)
nop
(MA) jal (M-UP) If MA, GOTO (M-UP)
lbu r3, 0x0090 (r2) Loads Support Byte 4.
(E1) jr 7 Return to Main Routine
nop

(WP-UP) lh r6, 0x38D0 (r1) Loads XA2 = WP
beq r5, r0, (E2) If not using two-hands, GOTO  (E2)
andi r3, r4, 0x0001
bne r3, r0, (E2) If weapon is forced two-hands, GOTO  (E2)
andi r5, r4, 0x0004
beq r5, r0, (E2) If weapon is not two-handable, GOTO  (E2)
sll r6, r6, 0x01
sh r6, 0x38D0 (r1) If 2H is used and XA2 is WP, XA2 = XA2 * 2.
(E2) jr 31
nop
(P-UP) lbu r4, 0x0091 (r1) Loads Support Byte 5.
bne r3, r0, (A-UP)  If equipping a weapon, GOTO (A-UP)
lh r5, 0x38D0 (r1) Loads XA2 = PA or SP.
andi r4, r4, 0x0020
beq r4, r0, (A-UP) If Martial Arts isn't used, GOTO (A-UP)
sll r6, r5, 0x01
addu r6, r6, r5
sra r6, r6, 0x01
sh r6, 0x38D0 (r1) If 2H is used and XA2 is PA or SP, XA2 = XA2 * 3/2.
(A-UP) lbu r3, 0x0090 (r2) Loads Support Byte 4.
lui r4, 0x5555  r4 = 55550000.
andi r5, r3, 0x0010
beq r5, r0, (E3)  If Attack Up isn't used, GOTO (E3)
lh r3, 0x38D0 (r1) Loads XA2.
(Mult) addiu r4, r4, 0x5556 r4 = 55555556 as a multiplier against FFFFFFFF.  In simple terms, this is 1/3.
sll r3, r3, 0x02
mult r4, r3 Term on HI is XA2 * 4 * 1/3.
sra r3, r3, 0x1F r3 = 0.
mfhi r4
subu r4, r4, r3 r4 = r4 - 0.
sh r4, 0x38D0 (r1)  If ATTACK or MAGIC ATTACK UP is flagged, XA2 = XA2 * 4/3.
(E3) jr r31
nop

(M-UP) lui r4, 0x5555  r4 = 55550000.
andi r5, r3, 0x0004
beq r5, r0, (E3) If Magic Attack Up isn't used, GOTO (E3)
lh r3, 0x38D0 (r1)  Loads XA2.
j (Mult) GOTO (Mult)
nop
Title: Re: ASM Collective BATTLE.BIN Map
Post by: secondadvent on February 08, 2011, 07:42:34 am
Throughout your code here, you have 1938F0 as XA2's location (which is actually Ability's Range) when XA2 is located at 1938D0; if you were to use 1938F0 as the ending pointer, your initial loop would override everything past the actual XA2 location until it stopped at 1938F0. 1938CE + 2 = 1938D0 = XA2's location.


Instead of:

andi r3, r3, 0x0003
sll r3, r3, 0x0002
addiu r3, r3, 0x0001

you could instead do:

srl r3, r3, 0x02

and just change the checks around a bit to achieve the same thing (instead of checking for < 4/8/12, you can check for < 1/2/3; in the following section you could change = 5/!= 13 -> = 1/!= 3). You would also need to flip the flags around in FFTP so that 0-3 = XA1, and 4-C = XA2 (instead of 0-3 = XA2, 4-C = XA1), otherwise it'd check XA1 for determining things in the support check code.


As for the:

sra r3, r3, 0x1F
mfhi r4
subu r4, r4, r3

section, do you really need to have the sra/subu? Maybe I'm missing something, but I never really saw the reason for this :/.


I don't really notice anything that is wrong, but you'll know for sure if anything is off by following it while the game is running :P. I can't really think of anything else to change; it looks pretty good.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on February 12, 2011, 06:31:27 am
SA, addressed concerns 1 and 3.  Concern 2 seems a bit too trivial to fix.

Sets up the formula (Gets Y):
lhu r7, 0x38CE (r1) Loads XA1
lbu r4, 0x38E5 (r1) Loads Formula
lbu r3, 0x38FA (r1) Loads Y
addiu r5, r0, 0x0008
beq r5, r4, (F8) If Formula 8 (I'll change this to some other number later), GOTO (F8).
addiu r6, r0, 0x0009
beq r6, r4, (F9) If Formula 9 (I'll change this to some other number later), GOTO (F9).
addiu r5, r0, 0x000A
beq r5, r4, (FA) If Formula A (I'll change this to some other number later), GOTO (FA).
addiu r6, r0, 0x000B
beq r6, r4, (FB) If Formula B (I'll change this to some other number later), GOTO (FB).
addu r7, r7, r3 r7 = XA1 + Y
lhu r4, 0x38D0 (r1) r4 = XA2
nop
addu r4, r7, r4
jr 31 Return to Main Routine
sb r4, 0x38D0 (r1) XA2 = XA1 + XA2 + Y
(FB) srl r7, r7, 0x01 XA1 = (XA1 + Y) / 2
j (E)
(FA) srl r6, r3, 0x03 r6 = [Y/8]
andi r3, r3, 0x0007 r3 = last 3 bits of Y
beq r3, r0, (Calc)
lbu r5, 0x0036 (r2) r5 = PA if r3 = 0
addiu r4, r0, 0x0001
beq r3, r4, (Calc)
lbu r5, 0x0037 (r2) r5 = MA if r3 = 1
addiu r4, r0, 0x0002
beq r3, r4, (Calc)
lbu r5, 0x0038 (r2) r5 = SP if r3 = 2
addiu r4, r0, 0x0003
beq r3, r4, (Calc)
lbu r5, 0x3902 (r1) r5 = WP if r3 = 3
addiu r4, r0, 0x0004
beq r3, r4, (Div4)
lbu r5, 0x0022 (r2) r5 = LVL if r3 = 4
addiu r4, r0, 0x0005
beq r3, r4, (Check)
addu r5, r2, 0x003E Readies the check where r5 = WEV1 if r3 = 5
addiu r4, r0, 0x0006
beq r3, r4, (Check)
addu r5, r2, 0x0045 Readies the check where r5 = SMEV1 if r3 = 6
addu r5, r2, 0x0041 Readies the check where r5 = SPEV1 if r3 = 7
(Check) lbu r4, 0x0000 (r5) r4 = RH equipment evasion.
bne r4, r0, (DivCheck) Checks RH equipment for evasion.
sltiu r3, r3, 0x0007 r3 = 1 if r3 < 7. r3 = 0 if r3 = 7.
lbu r4, 0x0001 (r5) r4 = LH equipment evasion.
(DivCheck) beq r3, r0 (Div3) If r3 = 0 (original r3 = 7), GOTO (Div3)
addu r5, r4, r0 r5 = r4
j (Calc)
srl r5, r5, 0x01  r5 = r5 / 2...this allows the SM-EV and W-EV used in formulas to cap at 25-30 in vanilla.
(Div3) lui r4, 0x5555
addu r4, r4, 0x5556
mult r5, r4
j (Calc)
mfhi r5 r5 = r5 / 3...this allows the SP-EV used in formulas to cap at 25 in vanilla.
(Div4) j (Calc)
srl r5, r5, 0x02  r5 = r5 / 4...this allows the LVL used in formulas to cap at 25 in vanilla.
(Calc) bne r5, r0 (Nonzero) If r5 is not zero, GOTO (Nonzero)
nop
addiu r5, r0, 0x0001
(Nonzero) addu r7, r7, r5 r7 = XA1 + r5 (which we'll now call YA3)
srl r7, r7, 0x01 r7 = (XA1 + YA3) / 2
j (E)
addu r7, r7, r6 XA1 = (XA1 + YA3) / 2 + [Y/8]
(F9) andi r5, r3, 0x0008 r5 = first bit of Y
beq r5, r0 (Sorter)
srl r6, r3, 0x04 r6 = [Y/16]
lw r2, 0x2D98 (r1) Load the target's stats.
(Sorter) andi r5, r3, 0x0003 r5 = last 2 bits of Y
andi r3, r3, 0x0004 r3 = second bit of Y
beq r5, r0 (Divider1)
addiu r4, r2, 0x0028 Readies the check where r4 = curHP if r5 = 0
addiu r5, r5, 0xFFFF r5 = r5 - 1
beq r5, r0 (Divider1)
addiu r4, r2, 0x002C Readies the check where r4 = curMP if r5 = 0 (original r5 = 1).
addiu r5, r5, 0xFFFF r5 = r5 - 1
beq r5, r0 (Divider2)
lbu r4, 0x0024 (r2) r4 = Br of target or caster if r5 = 0 (original r5 = 2)
lbu r5, 0x005C (r2) r5 = Status Byte 5 on target or caster if r5 = 1 (original r5 = 3)
lbu r4, 0x0026 (r2) r4 = Fa of target or caster if r5 = 1 (original r5 = 3)
andi r5, r5 0x00C0
beq r5, r0 (Divider2) If not Innocent or Faith, GOTO (Divider2)
nop
sltiu r5, r5, 0x0080 r5 = 1 if Innocent.  r5 = 0 if Faith.
beq r5, r0 (Divider2) If Faith, GOTO (Divider2)
addiu r4, r0, 0x0064 r4 = 100
addiu r4, r0, 0x0000 ELSE, r4 = 0
(Divider2) beq r3, r0 (Div100) If r3 = 0 (normal), GOTO (Div100)
addiu r5, r0, 0x0064 r5 = 100
subu r4, r5, r4 If r3 = 1 (reversed stats), r4 = 100 - (BR or Adjusted FA)
(Div100) mult r7, r4
mflo r4 r4 = XA1 * BR/FA/UnBr/UnFa
lui r5, 0x028F
addiu r5, r5, 0x5C29
mult r4, r5
mfhi r5 r5 = XA1 * Br/Fa/UnBr/UnFa / 100
j (E)
addu r7, r5, r6 XA1 = (XA1 * Br/Fa/UnBr/UnFa / 100) + [Y/16]
(Divider1) lhu r5, 0x0000 (r4) r5 = curHP or curMP
beq r3, r0 (OverMax) If r3 = 0 (normal), GOTO (OverMax)
lhu r4, 0x0002 (r4) r4 = maxHP or maxMP
subu r5, r4, r5 If r3 = 1 (reversed stats), r4 = max-cur HP/MP
(OverMax) mult r7, r5
mflo r5 r5 = XA1 * curHP/MP/max-curHP/max-curMP
nop
nop
div r5, r4
mflo r5 r5 = XA1 * curHP/MP/max-curHP/max-curMP / maxHP/MP
j (E)
addu r7, r5, r6 XA1 = (XA1 * curHP/max-curHP/curMP/max-curMP / maxHP/MP) + [Y/16]
(F8) lui r4, 0xA001
lw r5, -0x6FF0 (r4) Load random word.
lui r6, 0x41C6
addiu r6, r6, 0x4E6D
multu r5, r6
mflo r5
addiu r5, r5, 0x3039
sw r5, -0x6FF0 (r4) Store new Random Word.
mult r7, r5
mfhi r7 r7 = {0...XA1-1}
addiu r7, r7, 0x0001 r7 = {1...XA1}
addu r7, r7, r3 XA1 = {1...XA1}+Y
(E) jr 31 Return to Main Routine
sb r7, 0x38CE (r1) Store modified XA1.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Vanya on February 12, 2011, 09:47:01 pm
I need to study more because I barely understand half this stuff. But what I do get is beautiful for the promises it sweetly whispers. <3
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on February 12, 2011, 10:50:18 pm
What do you currently not understand, Vanya?  There are 5 formulas being made:
8: XA1 = {1...XA1} + Y; XA2 = XA2
9: XA1 = (XA1 * YA3 + [Y/16]), where YA3 = target/self Normal/Reversed HP Ratio/MP Ratio/Br Percentage/Fa Percentage; XA2 = XA2
10: XA1 = ((XA1 + YA3) / 2 + [Y/8]), where YA3 = PA/MA/SP/WP/LVL*.25/W-EV*.5/MS-EV*.5/PS-EV*.3333333333; XA2 = XA2
11: XA1 = (XA1 + Y) / 2; XA2 = XA2
12: XA1 = XA1; XA2 = (XA1 + XA2 + Y)

Formula 9 works as thus.  0/1/2/3 means YA3 is the caster's HP Ratio/MP Ratio/Br%/Fa%.  4/5/6/7 means YA3 is the caster's HP Ratio/MP Ratio/Br%/Fa% subtracted from 1.  8/9/10/11 means YA3 is the target's HP Ratio/MP Ratio/Br%/Fa%.  12/13/14/15 means YA3 is the target's HP Ratio/MP Ratio/Br%/Fa% subtracted from 1.  The additive value of Y is Y / 16, rounded down.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on February 13, 2011, 12:45:50 am
Zodiac Compatibility Routine (SA...feel free to improve this or make it compatible with yours):

lw r2, 0x2D94 (r1) Loads the attacker's stats
lw r3, 0x2D98 (r1) Loads the defender's stats
lui r7, 0x8006
lhu r6, 0x38D6 (r1) r6 = Used Ability ID
lbu r4, 0x0009 (r2) Loads the attacker's Zodiac Sign Byte
sll r6, r6, 0x03 r6 = r6 * 8
addu r7, r7, r6
lbu r7, -0x140D (r7) r7 = AI Byte 1 for attack
addiu r6, r0, 0x000C
andi r7, r7, 0x0010 Checks if the currently unused flag under "Learn on Hit" is flagged.
bne r7, r0, (E) If flagged, GOTO (E)
lbu r5, 0x0009 (r3) Loads the defender's Zodiac Sign Byte
srl r4, r4, 0x04 Gets the attacker byte's upper 4 bits.
beq r4, r6, (E) If Attacker sign is Ophiuchus, GOTO (E)
srl r5, r5, 0x04 Gets the defender byte's upper 4 bits.
beq r5, r6, (E) If Defender sign is Ophiuchus, GOTO (E)
andi r7, r4, 0x0003 r7 = the lower 2 bits of attacker sign
andi r6, r5, 0x0003 r6 = the lower 2 bits of defender sign
beq r6, r7, (Good) If attacker and defender signs differ by 4, GOTO (Good)
lbu r1, 0x38D0 (r1) r1 = XA2
addiu r7, r0, 0x0002
addiu r6, r0, 0x0006
(MOD) div r4, r6
mfhi r4 r4 = r4 MOD r6...MOD means you take the remainder of the division.
nop
nop
div r5, r6
mfhi r5 r5 = r5 MOD r6
beq r4, r5 (Diff) If attacker and defender signs form a square or its diagonal, GOTO (Diff)
addiu r7, r7, 0xFFFF r7 = r7 - 1
bne r7, r0, (MOD) If r7 isn't zero, GOTO (MOD)
addiu r6, r0, 0x0003
(E) jr 31 Return to Main Routine
lui r1, 0x8019 Resets r1 = 0x80190000.
(Diff) beq r7, r0 (Bad) If r7 = 0 (when r6 = 3), GOTO (Bad)
lbu r6, 0x0006 (r2) r6 = attacker gender
lbu r7, 0x0006 (r3) r7 = defender gender
or r4, r6, r7
andi r4, r4, 0x0020
bne r4, r0, (Bad) If either combatant is a monster, GOTO (Bad)
andi r6, r6, 0x00C0
andi r7, r7, 0x00C0
beq r6, r7 (EndBranch) If the genders are the same, GOTO (EndBranch)
srl r4, r1, 0x01 XA2 = [XA2/2]
(+) addu r4, r1, r4 XA2 = XA2 + r4
(EndBranch) lui r7, 0x8019
j (E)
sb r4, 0x38D0 (r7) Store r1 as XA2
(Good) j (+)
(Bad) srl r4, r1, 0x02 r4 = [XA2/4]
j (EndBranch)
subu r4, r1, r4 XA2 = XA2 - [XA2/4]
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on February 14, 2011, 11:05:07 pm
Oh... FDC.  I just realized we've made a minor faux paus in 08-0B.  The Y modifier should be added to XA2, not the end value of XA1 and YA3.  We were so busy both trying to cram as much out of these formula as we could that the Y modifier got shoved in the wrong place at some point.  I suppose it's not a ridiculously huge deal, but it breaks the Vanilla-friendly convention we've worked so hard to keep and should probably be fixed if it's not too hard to do.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on February 16, 2011, 04:25:38 am
Quote from: RavenOfRazgriz on February 14, 2011, 11:05:07 pm
Oh... FDC.  I just realized we've made a minor faux paus in 08-0B.  The Y modifier should be added to XA2, not the end value of XA1 and YA3.  We were so busy both trying to cram as much out of these formula as we could that the Y modifier got shoved in the wrong place at some point.  I suppose it's not a ridiculously huge deal, but it breaks the Vanilla-friendly convention we've worked so hard to keep and should probably be fixed if it's not too hard to do.


As I explained yesterday in iRC, this is not an issue. The addition of Y on "Charge" is the same addition used in "Geomancy" and "Martial Arts", so it's actually 2D that's the exception.  Furthermore, if you think that WP + Y gives better scaling, you can just switch XA1 (PA) and YA3 (??) with XA2 (WP--in both instances, if need be).  The only real differences from vanilla are when you try to apply 2 Hands to XA1 as WP (which is rather broken to begin with), when Magic Attack Up affects MA * WP (because MA is XA2 instead of WP, but MA * (WP + Y) didn't exist in vanilla anyways), or when you try to use the multiplicative function (((XA1 * YA3) + Y) * XA2) when Y is not zero (but people would only use that attack when YA3 is close to 1, meaning the difference is usually not much more than 20% of the spell's overall damage output).

Protect/Shell/DEFUP/MADEF Routine:

addu r2, r31, r0 r2 = Return Address, because r31 will be modified below by the jal commands.
lhu r5, 0x38D6 (r1) r5 = Used Ability ID
lui r4, 0x8006
sll r5, r5, 0x03 r5 = r5 * 8
addu r4, r4, r5
lbu r5, -0x1F0A (r4) r4 = AI Byte 4
lbu r6, 0x005B (r3) r6 = Status Byte 4
andi r4, r5, 0x0002
beq r4, r0 (Prot) If AI flag Magic Defense Up is not checked, GOTO (Prot)
andi r7, r6, 0x0010
beq r7, r0 (Prot) If target does not have Shell, GOTO (Prot)
nop
jal (Mult) If target has Shell and skill is blocked by Shell, GOTO (Mult)
(Prot) andi r4, r5, 0x0001
beq r4, r0 (MADEF) If AI flag Defense Up is not checked, GOTO (MADEF)
andi r7, r6, 0x0020
beq r7, r0 (MADEF) If target does not have Protect, GOTO (MADEF)
nop
jal (Mult) If target has Protect and skill is blocked by Protect, GOTO (Mult)
(MADEF) lbu r6, 0x0090 (r3) r6 = Support Byte 2
andi r4, r5, 0x0002
beq r4, r0 (DEFUP) If AI flag Magic Defense Up is not checked, GOTO (DEFUP)
andi r7, r6, 0x0002
beq r7, r0 (DEFUP) If target does not have Magic Defense Up, GOTO (DEFUP)
nop
jal (Mult) If target has Magic Defense Up and skill is blocked by Shell, GOTO (Mult)
(MADEF) andi r4, r5, 0x0001
beq r4, r0 (E) If AI flag Defense Up is not checked, GOTO (E)
andi r7, r6, 0x0008
beq r7, r0 (E) If target does not have Defense Up, GOTO (E)
nop
jal (Mult) If target has Defense Up and skill is blocked by Protect, GOTO (Mult)
nop
(E) jr r2 Return to Main Routine
nop

(Mult) lui r4, 0xAAAA
lhu r7, 0x38D0 (r1) r7 = XA2
addiu r4, r4, 0xAAAB r4 = AAAAAAAB
mult r7, r4
mfhi r7 r7 = XA2 * 2/3
jr 31 Return to Protect/Shell/MADEF/DEFUP Routine
sh r7, 0x38D0 (r1) XA2 = XA2 * 2/3
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on February 16, 2011, 04:35:22 am
OK...the order I posted in isn't entirely right.  The order should be:

lui r1, 0x8019
lbu r3, 0x38F9 (r1) Loads X
lw r2, 0x2D94 (r1) Loads the attacker's stats
addiu r6, r1, 0x38CE r6 = XA1's address
addiu r7, r1, 0x38D0 r7 = XA2's address
andi r3, r3, 0x000F r3 = the last 4 bits of X
(LS) sltiu r4, r3, 0x0004
bne r4, r0, (*) If r3 < 4, GOTO (*)
lbu r5, 0x0036 (r2) r5 = Attacker PA
sltiu r4, r3, 0x0008
bne r4, r0, (*) If r3 < 8, GOTO (*)
lbu r5, 0x0037 (r2) r5 = Attacker MA
sltiu r4, r3, 0x000C
bne r4, r0, (*) If r3 < 12, GOTO (*)
lbu r5, 0x0038 (r2)  r5 = Attacker SP
nop
lbu r5, 0x3902 (r1)  r5 = Attacker WP
(*) beq r6, r7, (E) If r6 = r7, GOTO  End.
sb r5, 0x0000 (r6) Stores r5 at the address of r6
andi r3, r3, 0x0003
sll r3, r3, 0x0002
addiu r3, r3, 0x0001 The purpose of these r3 manipulations is to put r3 in a form that the previous loop can understand.
j (LS) Jumps back to the Loop's Start.
addiu r6, r6, 0x0002 r6 = r6 + 2 = r7 = XA2's address
(E) jr 31 Returns to the Main Formula Routine.
nop


lbu r4, 0x38F7 (r1) Loads ability element
lbu r5, 0x0071 (r2) Loads elements strengthened
lhu r6, 0x38D0 (r1) Loads XA2
and r4, r4, r5 Checks ability element against elements strengthened
beq r4, r0, (E) If ability element isn't a boosted element, GOTO (E)
srl r5, r6, 0x02 If ability element is boosted, r5 = [XA2/4]
addu r6, r6, r5 XA2 = XA2 + [XA2/4]
(E)  jr 31 Return to Main Routine
sh r6, 0x38D0 (r1) Stores XA2


lw r5, 0x2D98 (r1) Load target address.
ori r4, r0, 0x0005
beq r3, r4, (E) NOTE: r3 can only be 1, 5, 9, or 13, which corresponds to PA, MA, SP, WP.  If XA2 is MA, GOTO (E)
lbu r6, 0x005C (r5) Load Status Byte 5.
lbu r7, 0x0058 (r5) Load Status Byte 1.
lbu r5, 0x005A (r5) Load Status Byte 3.
andi r6, r6, 0x0010
bne r6, r0, (Mult) If target is asleep, GOTO (Mult)
andi r7, r7, 0x0008
bne r7, r0, (Mult) If target is charging, GOTO (Mult)
andi r5, r5, 0x0006
beq r5, r0, (E) If target isn't chickened/frogged, GOTO (E)
(Mult) lhu r4, 0x38D0 (r1) Load XA2.
nop
srl r5, r4, 0x01 r5 = [XA2/2]
addu r4, r4, r5 XA2 = XA2 + [XA2/2]
sh r4, 0x38D0 (r1) Store XA2.
(E) jr 31 Return to Main Routine
nop

ori r4, r0, 0x0005
beq r4, r3, (MA) NOTE: r3 can only be 1, 5, 9, or 13, which corresponds to PA, MA, SP, WP.  If r3 is MA, GOTO (MA)
addu r7, r31, r0 Stores the return address in r7 because it'll be modified by the jal commands below.
ori r4, r0, 0x000D
bne r4, r3, (PA/SP) If r3 isn't WP, GOTO (PA/SP)
lbu r5, 0x38D9 (r1)  Loads the "Two Hands" byte.
jal (WP-UP) If WP, GOTO  (WP-UP)
lbu r4, 0x38FF (r1) Loads weapon characteristic byte.
(PA/SP) jal (P-UP) If PA/SP, GOTO (P-UP)
lbu r3, 0x38D8 (r1) Loads Weapon Type byte.
j (E1) GOTO (E1)
nop
(MA) jal (M-UP) If MA, GOTO (M-UP)
lbu r3, 0x0090 (r2) Loads Support Byte 4.
(E1) jr 7 Return to Main Routine
nop

(WP-UP) lhu r6, 0x38D0 (r1) Loads XA2 = WP
beq r5, r0, (E2) If not using two-hands, GOTO  (E2)
andi r3, r4, 0x0001
bne r3, r0, (E2) If weapon is forced two-hands, GOTO  (E2)
andi r5, r4, 0x0004
beq r5, r0, (E2) If weapon is not two-handable, GOTO  (E2)
sll r6, r6, 0x01
sh r6, 0x38D0 (r1) If 2H is used and XA2 is WP, XA2 = XA2 * 2.
(E2) jr 31
nop
(P-UP) lbu r4, 0x0091 (r1) Loads Support Byte 5.
bne r3, r0, (A-UP)  If equipping a weapon, GOTO (A-UP)
lhu r5, 0x38D0 (r1) Loads XA2 = PA or SP.
andi r4, r4, 0x0020
beq r4, r0, (A-UP) If Martial Arts isn't used, GOTO (A-UP)
srl r6, r5, 0x01
addu r6, r5, r6
sh r6, 0x38D0 (r1) If Martial Arts is used and XA2 is PA or SP, XA2 = XA2 + [XA2/2].
(A-UP) lbu r3, 0x0090 (r2) Loads Support Byte 4.
lui r4, 0x5555  r4 = 55550000.
andi r5, r3, 0x0010
beq r5, r0, (E3)  If Attack Up isn't used, GOTO (E3)
lhu r3, 0x38D0 (r1) Loads XA2.
(Mult) addiu r4, r4, 0x5556 r4 = 55555556 as a multiplier against FFFFFFFF.  In simple terms, this is 1/3.
sll r3, r3, 0x02
mult r4, r3 Term on HI is XA2 * 4 * 1/3.
sra r3, r3, 0x1F r3 = 0.
mfhi r4
subu r4, r4, r3 r4 = r4 - 0.
sh r4, 0x38D0 (r1)  If ATTACK or MAGIC ATTACK UP is flagged, XA2 = XA2 * 4/3.
(E3) jr r31
nop

(M-UP) lui r4, 0x5555  r4 = 55550000.
andi r5, r3, 0x0004
beq r5, r0, (E3) If Magic Attack Up isn't used, GOTO (E3)
lhu r3, 0x38D0 (r1)  Loads XA2.
j (Mult) GOTO (Mult)
nop


addu r2, r31, r0 r2 = Return Address, because r31 will be modified below by the jal commands.
lw r3, 0x2D98 (r1) Load target address.
lhu r5, 0x38D6 (r1) r5 = Used Ability ID
lui r4, 0x8006
sll r5, r5, 0x03 r5 = r5 * 8
addu r4, r4, r5
lbu r5, -0x1F0A (r4) r4 = AI Byte 4
lbu r6, 0x005B (r3) r6 = Status Byte 4
andi r4, r5, 0x0002
beq r4, r0 (Prot) If AI flag Magic Defense Up is not checked, GOTO (Prot)
andi r7, r6, 0x0010
beq r7, r0 (Prot) If target does not have Shell, GOTO (Prot)
nop
jal (Mult) If target has Shell and skill is blocked by Shell, GOTO (Mult)
nop
(Prot) andi r4, r5, 0x0001
beq r4, r0 (MADEF) If AI flag Defense Up is not checked, GOTO (MADEF)
andi r7, r6, 0x0020
beq r7, r0 (MADEF) If target does not have Protect, GOTO (MADEF)
nop
jal (Mult) If target has Protect and skill is blocked by Protect, GOTO (Mult)
(MADEF) lbu r6, 0x0090 (r3) r6 = Support Byte 2
andi r4, r5, 0x0002
beq r4, r0 (DEFUP) If AI flag Magic Defense Up is not checked, GOTO (DEFUP)
andi r7, r6, 0x0002
beq r7, r0 (DEFUP) If target does not have Magic Defense Up, GOTO (DEFUP)
nop
jal (Mult) If target has Magic Defense Up and skill is blocked by Shell, GOTO (Mult)
(DEFUP) andi r5, r5, 0x0001
beq r5, r0 (E) If AI flag Defense Up is not checked, GOTO (E)
andi r6, r6, 0x0008
beq r6, r0 (E) If target does not have Defense Up, GOTO (E)
nop
jal (Mult) If target has Defense Up and skill is blocked by Protect, GOTO (Mult)
nop
(E) jr r2 Return to Main Routine
nop

(Mult) lui r4, 0xAAAA
lhu r7, 0x38D0 (r1) r7 = XA2
addiu r4, r4, 0xAAAB r4 = AAAAAAAB
mult r7, r4
mfhi r7 r7 = XA2 * 2/3
jr 31 Return to Protect/Shell/MADEF/DEFUP Routine
sh r7, 0x38D0 (r1) XA2 = XA2 * 2/3


lbu r4, 0x38F7 (r1) Loads ability element
lbu r5, 0x006F (r3) Loads elements halved
lhu r6, 0x38D0 (r1) Load XA2
and r4, r4, r5 Checks ability element against elements halved
beq r4, r0, (E) If ability element isn't a halved element, GOTO (E)
lw r2, 0x2D94 (r1) Loads attacker address
srl r6, r6, 0x01 If ability element is halved, XA2 = [XA2/2]
(E) jr 31 Return to Main Routine
sh r6, 0x38D0 (r1) Stores XA2


lhu r7, 0x38CE (r1) Loads XA1
lbu r4, 0x38E5 (r1) Loads Formula
lbu r3, 0x38FA (r1) Loads Y
addiu r5, r0, 0x0008
beq r5, r4, (F8) If Formula 8 (I'll change this to some other number later), GOTO (F8).
addiu r6, r0, 0x0009
beq r6, r4, (F9) If Formula 9 (I'll change this to some other number later), GOTO (F9).
addiu r5, r0, 0x000A
beq r5, r4, (FA) If Formula A (I'll change this to some other number later), GOTO (FA).
addiu r6, r0, 0x000B
beq r6, r4, (FB) If Formula B (I'll change this to some other number later), GOTO (FB).
addu r7, r7, r3 r7 = XA1 + Y
lhu r4, 0x38D0 (r1) r4 = XA2
nop
addu r4, r7, r4
jr 31 Return to Main Routine
sb r4, 0x38D0 (r1) XA2 = XA1 + XA2 + Y
(FB) srl r7, r7, 0x01 XA1 = (XA1 + Y) / 2
j (E)
(FA) srl r6, r3, 0x03 r6 = [Y/8]
andi r3, r3, 0x0007 r3 = last 3 bits of Y
beq r3, r0, (Calc)
lbu r5, 0x0036 (r2) r5 = PA if r3 = 0
addiu r4, r0, 0x0001
beq r3, r4, (Calc)
lbu r5, 0x0037 (r2) r5 = MA if r3 = 1
addiu r4, r0, 0x0002
beq r3, r4, (Calc)
lbu r5, 0x0038 (r2) r5 = SP if r3 = 2
addiu r4, r0, 0x0003
beq r3, r4, (Calc)
lbu r5, 0x3902 (r1) r5 = WP if r3 = 3
addiu r4, r0, 0x0004
beq r3, r4, (Div4)
lbu r5, 0x0022 (r2) r5 = LVL if r3 = 4
addiu r4, r0, 0x0005
beq r3, r4, (Check)
addu r5, r2, 0x003E Readies the check where r5 = WEV1 if r3 = 5
addiu r4, r0, 0x0006
beq r3, r4, (Check)
addu r5, r2, 0x0045 Readies the check where r5 = SMEV1 if r3 = 6
addu r5, r2, 0x0041 Readies the check where r5 = SPEV1 if r3 = 7
(Check) lbu r4, 0x0000 (r5) r4 = RH equipment evasion.
bne r4, r0, (DivCheck) Checks RH equipment for evasion.
sltiu r3, r3, 0x0007 r3 = 1 if r3 < 7. r3 = 0 if r3 = 7.
lbu r4, 0x0001 (r5) r4 = LH equipment evasion.
(DivCheck) beq r3, r0 (Div3) If r3 = 0 (original r3 = 7), GOTO (Div3)
addu r5, r4, r0 r5 = r4
j (Calc)
srl r5, r5, 0x01  r5 = r5 / 2...this allows the SM-EV and W-EV used in formulas to cap at 25-30 in vanilla.
(Div3) lui r4, 0x5555
addu r4, r4, 0x5556
mult r5, r4
j (Calc)
mfhi r5 r5 = r5 / 3...this allows the SP-EV used in formulas to cap at 25 in vanilla.
(Div4) j (Calc)
srl r5, r5, 0x02  r5 = r5 / 4...this allows the LVL used in formulas to cap at 25 in vanilla.
(Calc) bne r5, r0 (Nonzero) If r5 is not zero, GOTO (Nonzero)
nop
addiu r5, r0, 0x0001
(Nonzero) addu r7, r7, r5 r7 = XA1 + r5 (which we'll now call YA3)
srl r7, r7, 0x01 r7 = (XA1 + YA3) / 2
j (E)
addu r7, r7, r6 XA1 = (XA1 + YA3) / 2 + [Y/8]
(F9) andi r5, r3, 0x0008 r5 = first bit of Y
beq r5, r0 (Sorter)
srl r6, r3, 0x04 r6 = [Y/16]
lw r2, 0x2D98 (r1) Load the target's stats.
(Sorter) andi r5, r3, 0x0003 r5 = last 2 bits of Y
andi r3, r3, 0x0004 r3 = second bit of Y
beq r5, r0 (Divider1)
addiu r4, r2, 0x0028 Readies the check where r4 = curHP if r5 = 0
addiu r5, r5, 0xFFFF r5 = r5 - 1
beq r5, r0 (Divider1)
addiu r4, r2, 0x002C Readies the check where r4 = curMP if r5 = 0 (original r5 = 1).
addiu r5, r5, 0xFFFF r5 = r5 - 1
beq r5, r0 (Divider2)
lbu r4, 0x0024 (r2) r4 = Br of target or caster if r5 = 0 (original r5 = 2)
lbu r5, 0x005C (r2) r5 = Status Byte 5 on target or caster if r5 = 1 (original r5 = 3)
lbu r4, 0x0026 (r2) r4 = Fa of target or caster if r5 = 1 (original r5 = 3)
andi r5, r5 0x00C0
beq r5, r0 (Divider2) If not Innocent or Faith, GOTO (Divider2)
nop
sltiu r5, r5, 0x0080 r5 = 1 if Innocent.  r5 = 0 if Faith.
beq r5, r0 (Divider2) If Faith, GOTO (Divider2)
addiu r4, r0, 0x0064 r4 = 100
addiu r4, r0, 0x0000 ELSE, r4 = 0
(Divider2) beq r3, r0 (Div100) If r3 = 0 (normal), GOTO (Div100)
addiu r5, r0, 0x0064 r5 = 100
subu r4, r5, r4 If r3 = 1 (reversed stats), r4 = 100 - (BR or Adjusted FA)
(Div100) mult r7, r4
mflo r4 r4 = XA1 * BR/FA/UnBr/UnFa
lui r5, 0x028F
addiu r5, r5, 0x5C29
mult r4, r5
mfhi r5 r5 = XA1 * Br/Fa/UnBr/UnFa / 100
j (E)
addu r7, r5, r6 XA1 = (XA1 * Br/Fa/UnBr/UnFa / 100) + [Y/16]
(Divider1) lhu r5, 0x0000 (r4) r5 = curHP or curMP
beq r3, r0 (OverMax) If r3 = 0 (normal), GOTO (OverMax)
lhu r4, 0x0002 (r4) r4 = maxHP or maxMP
subu r5, r4, r5 If r3 = 1 (reversed stats), r4 = max-cur HP/MP
(OverMax) mult r7, r5
mflo r5 r5 = XA1 * curHP/MP/max-curHP/max-curMP
nop
nop
div r5, r4
mflo r5 r5 = XA1 * curHP/MP/max-curHP/max-curMP / maxHP/MP
j (E)
addu r7, r5, r6 XA1 = (XA1 * curHP/max-curHP/curMP/max-curMP / maxHP/MP) + [Y/16]
(F8) lui r4, 0xA001
lw r5, -0x6FF0 (r4) Load random word.
lui r6, 0x41C6
addiu r6, r6, 0x4E6D
multu r5, r6
mflo r5
addiu r5, r5, 0x3039
sw r5, -0x6FF0 (r4) Store new Random Word.
mult r7, r5
mfhi r7 r7 = {0...XA1-1}
addiu r7, r7, 0x0001 r7 = {1...XA1}
addu r7, r7, r3 XA1 = {1...XA1}+Y
(E) jr 31 Return to Main Routine
sb r7, 0x38CE (r1) Store modified XA1.


lw r2, 0x2D94 (r1) Loads the attacker's stats
lw r3, 0x2D98 (r1) Loads the defender's stats
lui r7, 0x8006
lhu r6, 0x38D6 (r1) r6 = Used Ability ID
lbu r4, 0x0009 (r2) Loads the attacker's Zodiac Sign Byte
sll r6, r6, 0x03 r6 = r6 * 8
addu r7, r7, r6
lbu r7, -0x140D (r7) r7 = AI Byte 1 for attack
addiu r6, r0, 0x000C
andi r7, r7, 0x0010 Checks if the currently unused flag under "Learn on Hit" is flagged.
bne r7, r0, (E) If flagged, GOTO (E)
lbu r5, 0x0009 (r3) Loads the defender's Zodiac Sign Byte
srl r4, r4, 0x04 Gets the attacker byte's upper 4 bits.
beq r4, r6, (E) If Attacker sign is Ophiuchus, GOTO (E)
srl r5, r5, 0x04 Gets the defender byte's upper 4 bits.
beq r5, r6, (E) If Defender sign is Ophiuchus, GOTO (E)
andi r7, r4, 0x0003 r7 = the lower 2 bits of attacker sign
andi r6, r5, 0x0003 r6 = the lower 2 bits of defender sign
beq r6, r7, (Good) If attacker and defender signs differ by 4, GOTO (Good)
lbu r1, 0x38D0 (r1) r1 = XA2
addiu r7, r0, 0x0002
addiu r6, r0, 0x0006
(MOD) div r4, r6
mfhi r4 r4 = r4 MOD r6...MOD means you take the remainder of the division.
nop
nop
div r5, r6
mfhi r5 r5 = r5 MOD r6
beq r4, r5 (Diff) If attacker and defender signs form a square or its diagonal, GOTO (Diff)
addiu r7, r7, 0xFFFF r7 = r7 - 1
bne r7, r0, (MOD) If r7 isn't zero, GOTO (MOD)
addiu r6, r0, 0x0003
(E) jr 31 Return to Main Routine
lui r1, 0x8019 Resets r1 = 0x80190000.
(Diff) beq r7, r0 (Bad) If r7 = 0 (when r6 = 3), GOTO (Bad)
lbu r6, 0x0006 (r2) r6 = attacker gender
lbu r7, 0x0006 (r3) r7 = defender gender
or r4, r6, r7
andi r4, r4, 0x0020
bne r4, r0, (Bad) If either combatant is a monster, GOTO (Bad)
andi r6, r6, 0x00C0
andi r7, r7, 0x00C0
beq r6, r7 (EndBranch) If the genders are the same, GOTO (EndBranch)
srl r4, r1, 0x01 XA2 = [XA2/2]
(+) addu r4, r1, r4 XA2 = XA2 + r4
(EndBranch) lui r7, 0x8019
j (E)
sb r4, 0x38D0 (r7) Store r1 as XA2
(Good) j (+)
(Bad) srl r4, r1, 0x02 r4 = [XA2/4]
j (EndBranch)
subu r4, r1, r4 XA2 = XA2 - [XA2/4]
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on February 16, 2011, 05:26:53 pm
Okay, I'm going to take what FDC has so far and put it into stupid-people talk.

See this post for the most up-to-date stupid-people talk breakdown of this hack. (http://ffhacktics.com/smf/index.php?topic=6538.msg139839#msg139839)
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Celdia on February 20, 2011, 09:52:01 pm
@Raven & FDC - Can you point out for me in the code where the (XA2 * 3/2) for Martial Arts is, or am I misunderstanding how its applying the multiplier and it doesn't do that? Preferably with a HEX address? Because I thought I was seeing what I wanted but the notations here leave me wondering if they're wrong or if I'm just not getting it.

beq r4, r0, (A-UP) If Martial Arts isn't used, GOTO (A-UP)
srl r6, r5, 0x01
addu r6, r5, r6
sh r6, 0x38D0 (r1) If 2H is used and XA2 is PA or SP, XA2 = XA2 + [XA2/2].

Is that supposed to be 2H again or is that for Martial Arts and just mis-commented? If it IS for Martial Arts, what do I change to make the following: If Martial Arts is used and XA2 is PA or SP, XA2 = XA2 + [XA2/ 4 ] ?
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on February 21, 2011, 01:28:12 pm
Sorry, that's a typo on my part.  The bolded section should be "If Martial Arts is used".
If you want 1/4, change srl r6, r5, 0x01 to 0x02.


lhu r4, 0x38D6 (r1) r4 = Used Ability ID
lui r5, 0x8006
sll r4, r4, 0x03 r4 = r4 * 8
addu r5, r5, r4
lbu r6, -0x1F0D (r5) r6 = AI Byte 1
lbu r7, -0x1F0A (r5) r7 = AI Byte 4
lbu r5, -0x1F0B (r5) r5 = AI Byte 3
andi r6, r6, 0x0010
bne r6, r0, (Un) If AI flag under Learn on Hit is flagged, GOTO (Un)
(Check) andi r7, r7, 0x0080
bne r7, r0, (Br) If the blank AI flag above Direct Attack is flagged, GOTO (Br)
andi r5, r5, 0x0004
bne r5, r0, (Fa) If the Unknown AI flag under Random Hits is flagged, GOTO (Fa)
nop
jr 31 ELSE, GOTO Main Routine
nop

(Un) addiu r6, r0, 0x0064
j (Check) r6 = 100, r4 = Yes, GOTO (Check)
addiu r4, r0, 0x0001

(Br) bne r4, r0, (UnBr) If UnBrave/UnFaith is flagged, GOTO (UnBr)
lbu r7, 0x0024 (r2) r7 = Attacker Brave
j (Mult) ELSE, GOTO (Mult)
(UnBr) lbu r4, 0x0024 (r3) r4 = Defender Brave
subu r7, r6, r7 r7 = 100 - Attacker Brave if UnBrave/UnFaith is flagged
subu r4, r6, r4 r4 = 100 - Defender Brave if UnBrave/UnFaith is flagged
(Mult) lhu r6, 0x38D0 (r1) r6 = XA2
nop
mult r6, r7
mflo r6 r6 = XA2 * (CaBr/Fa or 100 - CaBr/Fa)
nop
nop
mult r6, r4
mflo r6 r6 = XA2 * (CaBr/Fa or 100 - CaBr/Fa) * (TaBr/Fa or 100 - TaBr/Fa)
lui r4, 0x0006
addu r4, r4, 0x8DB8
mult r6, r4
mfhi r6 XA2 = [XA2 * (CaBr/Fa or 100 - CaBr/Fa) * (TaBr/Fa or 100 - TaBr/Fa) / 10000]
jr 31 GOTO Main Routine
sh r6, 0x38D0 (r1) Stores new XA2
(Fa) lbu r5, 0x005C (r2) r5 = Attacker Status Byte 5
lbu r7, 0x005C (r3) r7 = Defender Status Byte 5
andi r5, r5, 0x00C0
beq r5, r0, (Load-AFa) If attacker does not have innocent or faith, GOTO (Load-AFa)
andi r7, r7, 0x00C0
sltiu r5, r5, 0x0080
beq r5, r0, (A-Inn) If attacker has Innocent, GOTO (A-Inn)
nop
j (CheckTar) If attacker has Faith, r5 = 100 and GOTO (CheckTar)
addiu r5, r0, 0x0064
(A-Inn) j (CheckTar) If attacker has Innocent, r5 = 0 and GOTO (CheckTar)
addiu r5, r0, 0x0000
(Load-AFa) lbu r5, 0x0026 (r2) If attacker has neither, r5 = Attacker Faith
(CheckTar) beq r7, r0, (Load-DFa) If defender does not have innocent or faith, GOTO (Load-DFa)
nop
sltiu r7, r7, 0x0080
beq r7, r0, (D-Inn) If defender has Innocent, GOTO (D-Inn)
nop
j (CheckUn) If defender has Faith, r7 = 100 and GOTO (CheckUn)
addiu r7, r0, 0x0064
(D-Inn) j (CheckUn) If defender has Innocent, r7 = 0 and GOTO (CheckUn)
addiu r7, r0, 0x0000
(Load-DFa) lbu r7, 0x0026 (r3) If defender has neither, r7 = Defender Faith
(CheckUn) beq r4, r0, (Normal) If UnBrave/UnFaith isn't flagged, GOTO (Normal)
nop
subu r5, r6, r5 r5 = 100 - Attacker Faith if UnBrave/UnFaith is flagged
subu r7, r6, r7 r7 = 100 - Defender Faith if UnBrave/UnFaith is flagged
(Normal) addu r4, r7, r0 r4 = r7 = Defender Faith
j (Mult) GOTO (Mult)
addu r7, r5, r0 r7 = r5 = Attacker Faith


Note, if you want the above hack to work like Xif's fury hack and add YY to brave and ZZ to faith, here's a slightly modified version (with the differences underlined).


lhu r4, 0x38D6 (r1) r4 = Used Ability ID
lui r5, 0x8006
sll r4, r4, 0x03 r4 = r4 * 8
addu r5, r5, r4
lbu r6, -0x1F0D (r5) r6 = AI Byte 1
lbu r7, -0x1F0A (r5) r7 = AI Byte 4
lbu r5, -0x1F0B (r5) r5 = AI Byte 3
andi r6, r6, 0x0010
bne r6, r0, (Un) If AI flag under Learn on Hit is flagged, GOTO (Un)
(Check) andi r7, r7, 0x0080
bne r7, r0, (Br) If the blank AI flag above Direct Attack is flagged, GOTO (Br)
andi r5, r5, 0x0004
bne r5, r0, (Fa) If the Unknown AI flag under Random Hits is flagged, GOTO (Fa)
nop
jr 31 ELSE, GOTO Main Routine
nop

(Un) addiu r6, r0, 0x0064
j (Check) r6 = 100, r4 = Yes, GOTO (Check)
addiu r4, r0, 0x0001

(Br) bne r4, r0, (UnBr) If UnBrave/UnFaith is flagged, GOTO (UnBr)
lbu r7, 0x0024 (r2) r7 = Attacker Brave
j (AddBr) ELSE, GOTO (AddBr)
(UnBr) lbu r4, 0x0024 (r3) r4 = Defender Brave
subu r7, r6, r7 r7 = 100 - Attacker Brave if UnBrave/UnFaith is flagged
subu r4, r6, r4 r4 = 100 - Defender Brave if UnBrave/UnFaith is flagged
(AddBr) addiu r7, r7, 0x00YY r7 = Attacker Brave + 0xYY
j (Mult) GOTO (Mult)
addiu r4, r4, 0x00YY r4 = Defender Brave + 0xYY
(AddFa) addiu r7, r7, 0x00ZZ r7 = Attacker Faith + 0xZZ
addiu r4, r4, 0x00ZZ r4 = Defender Faith + 0xZZ

(Mult) lhu r6, 0x38D0 (r1) r6 = XA2
nop
mult r6, r7
mflo r6 r6 = XA2 * (CaBr/Fa or 100 - CaBr/Fa)
nop
nop
mult r6, r4
mflo r6 r6 = XA2 * (CaBr/Fa or 100 - CaBr/Fa) * (TaBr/Fa or 100 - TaBr/Fa)
lui r4, 0x0006
addu r4, r4, 0x8DB8
mult r6, r4
mfhi r6 XA2 = [XA2 * (CaBr/Fa or 100 - CaBr/Fa) * (TaBr/Fa or 100 - TaBr/Fa) / 10000]
jr 31 GOTO Main Routine
sh r6, 0x38D0 (r1) Stores new XA2
(Fa) lbu r5, 0x005C (r2) r5 = Attacker Status Byte 5
lbu r7, 0x005C (r3) r7 = Defender Status Byte 5
andi r5, r5, 0x00C0
beq r5, r0, (Load-AFa) If attacker does not have innocent or faith, GOTO (Load-AFa)
andi r7, r7, 0x00C0
sltiu r5, r5, 0x0080
beq r5, r0, (A-Inn) If attacker has Innocent, GOTO (A-Inn)
nop
j (CheckTar) If attacker has Faith, r5 = 100 and GOTO (CheckTar)
addiu r5, r0, 0x0064
(A-Inn) j (CheckTar) If attacker has Innocent, r5 = 0 and GOTO (CheckTar)
addiu r5, r0, 0x0000
(Load-AFa) lbu r5, 0x0026 (r2) If attacker has neither, r5 = Attacker Faith
(CheckTar) beq r7, r0, (Load-DFa) If defender does not have innocent or faith, GOTO (Load-DFa)
nop
sltiu r7, r7, 0x0080
beq r7, r0, (D-Inn) If defender has Innocent, GOTO (D-Inn)
nop
j (CheckUn) If defender has Faith, r7 = 100 and GOTO (CheckUn)
addiu r7, r0, 0x0064
(D-Inn) j (CheckUn) If defender has Innocent, r7 = 0 and GOTO (CheckUn)
addiu r7, r0, 0x0000
(Load-DFa) lbu r7, 0x0026 (r3) If defender has neither, r7 = Defender Faith
(CheckUn) beq r4, r0, (Normal) If UnBrave/UnFaith isn't flagged, GOTO (Normal)
nop
subu r5, r6, r5 r5 = 100 - Attacker Faith if UnBrave/UnFaith is flagged
subu r7, r6, r7 r7 = 100 - Defender Faith if UnBrave/UnFaith is flagged
(Normal) addu r4, r7, r0 r4 = r7 = Defender Faith
j (AddFa) GOTO (AddFa)
addu r7, r5, r0 r7 = r5 = Attacker Faith
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on February 21, 2011, 05:51:00 pm
Updated to include the Faith/Fury breakdown in stupidspeak:

See this post for the most up-to-date stupid-people talk breakdown of this hack. (http://ffhacktics.com/smf/index.php?topic=6538.msg139839#msg139839)
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on February 22, 2011, 03:44:18 am
Quote
This routine starts by checking 3 flags.  The first is the Un- flag, checking to see whether the ability is trying to connocate a typical C(Br or Fa) * T(Br or Fa) / 10000 or a Malak-inspired (100-C[Br or Fa]) * (100-T[Br or Fa]) / 10000.  It then checks to see which is actually flagged between Br or Fa, and makes the jump to the proper section of the routine and calculating the Br and Fa (normal or inverted) that will actually be inserted into the routines.  It then adds constants (if using the latter version) to this end-value Br and Fa, avoiding errors in the inverted conversion.  It then "builds" the calculation of (end TBrFa * CBrFa / 10000).  Finally, it checks for Innocent or Faith, setting the TFa or CFa values to their proper setting if true.  In then performs a secondary "Un-" check for if either of these status are found, setting "Faith" to 100 if Innocent is found (meaning you cause maximum damage with an UnFaith skill) or 0 if Faith is found (meaning you cause no damage with an UnFaith skill).


No, that's not right.  It should be more like this.

This routine starts by checking 3 flags.  The first is the Un- flag, checking to see whether the ability is trying to connocate a typical C(Br or Fa) * T(Br or Fa) / 10000 or a Malak-inspired (100-C[Br or Fa]) * (100-T[Br or Fa]) / 10000.  It then checks to see which is actually flagged between Br or Fa, and makes the jump to the proper section of the routine and calculating the Br and Fa (normal) that will actually be inserted into the routines.  Innocent and Faith is then calculated for the faith routine. It then calculates the inverted Brave or Faith (if flagged) and adds constants (if using the latter version) to this end-value Br and Fa.  It finally then "builds" the calculation of (end TBrFa * CBrFa / 10000).


I suspect the non-linear nature of that routine confused you, Raven, on top of typing while tired.

I made a slight error.  The following routine comes before Faith/Fury on damage formulas.


lhu r4, 0x38D0 (r1) Loads r4 as XA2
lhu r5, 0x38CE (r1) Loads r5 as XA1
beq r4, r0 (Set1) If XA2 is 0, GOTO (Set1)
nop
(Mult) mult r4, r5
mflo r4 XA2 = XA1 * XA2
jr 31 Return to Main Routine
sh r4, 0x38D0 (r1) Stores new XA2

(Set1) j (Mult) GOTO (Mult)
addiu r4, r0, 0x0001 If XA2 = 0, XA2 is now 1.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on February 22, 2011, 04:11:18 am
Mostly the latter, considering all you had to do was condense/change the order of my sentences and edit maybe four words.

EDIT: Update to include the Base Damage Routine, which is properly located before the Brave/Faith Routine Knockback and Critical Hit routine.

Loads the attacker's stats and reads the X variable as input in FFTPatcher.  When looking for both XA1 and XA2, there are 16 combinations:

PA and PA
PA and MA
PA and SP
PA and WP
MA and PA
MA and MA
MA and SP
MA and WP
SP and PA
SP and MA
SP and SP
SP and WP
WP and PA
WP and MA
WP and SP
WP and WP

Basically, this allows you to take a formula and "load" it with values based on X.  So, the same formula that tells a skill to be PA * WP would also be MA * WP, SP * MA, WP * SP, and a host of other combinations based on your input for X.  Some of the values on the above table (PA and WP vs WP and PA) may seem redundant, but they certainly aren't, because all boosts and decrements are based on the XA2 value, meaning PA*MA and MA*PA and very different Formula.


Loads whatever value is defined as XA2, checks to see if attack's Element is the same as an Element that the unit as "Strengthen:" enabled for, and increases XA2 by 25% for the duration of this attack, resulting in a 25% damage boost.


If target is afflicted with any combination of Charge/Sleep/Frog/Chicken, XA2 is boosted by 50%, resulting in a 50% damage boost.


Checks XA2 value.  If XA2 is WP, unit is using Two Hands, weapon is compatible with Two Hands Support, XA2 is multiplied by 2, resulting in double damage.  If XA2 is PA or SP, unit is using Martial Arts, and unit does not have a weapon equipped in either hand, XA2 is multiplied by 1.5, resulting in a 50% damage boost.  If XA2 is PA, SP, or WP, unit is using Attack UP, XA2 is multiplied by 1.34x, resulting in a ~34% damage boost.  If XA2 is MA , unit is using Magic Attack UP, XA2 is multiplied by 1.34x, resulting in a ~34% damage boost.


Loads Ability ID, then checks Ability Flags for Defense UP.  If Defense UP is found as checked, the target unit is checked for having the Defense UP Support Ability and/or the status Protect, and the proper routines are run based on which are found, if any.  Then, the Ability Flags are checked for Magic Defense UP.  If Magic Defense UP is found as checked, the target unit is checked for having the Magic Defense UP Support Ability and/or the status Shell, and the proper routines are run based on which are found, if any.  Yes, this means by flagging both, you can create skills that are blocked by all of Defense UP, Protect, Magic Defense UP, and Shell.


Loads Ability's Element, checks it against the target unit's enabled "Half:" elements, then divides XA2 by 2 for the duration of the ability if true, resulting in a 50% damage reduction.


As they share the XA1 and XA2 code, this begins by checking whether you are using Formula 08, Formula 09, Formula 0A, Formula 0B, or Formula 0C, and branches to the proper code to "complete" the Formula.

If Formula = 08, the Formula is "completed" as (Rdm(1...XA1)+Y)*XA2.  If you remember our XA1 and XA2 tables, this means this formula can be anything from (Rdm(1...PA)+Y)*WP, which you should remember as the "Axe" Formula, all the way to (Rdm(1...MA)+Y)*MA or other crazy fun combinations based on X.

If Formula = 09, the Formula is "completed" as (XA1*YA3+Y/16)*XA2.  Now you'll notice a new value, YA3, and that Y is being divided.  This is because this is a three-entry Formula, where Y determines the third entry on a loop where each time through, the Y-boost for the formula is incremented by 1.  If you load this up with (PA*Br/100+Y)*WP, you may recognize this as the Katana or Knight Sword Formula, but as usual, this is much more than that.  In this case, YA3 controls the input that is essentially (0...1), and it can be anything as follows:

Caster's Br/100
Caster's Fa/100
Caster's (100-Br)/100
Caster's (100-Fa)/100
Caster's CurHP/MaxHP
Caster's CurMP/MaxMP
Caster's (MaxHP-CurHP)/MaxHP
Caster's (MaxMP-CurMP)/MaxMP
Target's Br/100
Target's Fa/100
Target's (100-Br)/100
Target's (100-Fa)/100
Target's CurHP/MaxHP
Target's CurMP/MaxMP
Target's (MaxHP-CurHP)/MaxHP
Target's (MaxMP-CurMP)/MaxMP

If Formula = 0A, the Formula is "completed" as ((XA1+YA3)/2+Y/8)*XA2.  You may recognize this Formula to be ((PA+SP)/2+Y)*WP or ((PA+MA)/2+Y)*WP, the Longbow and Book Formula. Again, not only does this act as much more than those, but this also substitutes as PA*WP and similar formula by being able to be loaded as ((PA+PA)/2+Y)*WP, etc.  Again, YA3 is a third value determined by the Y input, this time with 8 potential options:

PA
MA
SP
WP
W-Ev/2
S-Ev P/3
S-Ev M/2
LVL/4

(Note - the divisors on these values can easily be modified or removed for those using lower evasion values.)

If Formula = 0B, the Formula is "completed" as (XA1+Y)/2*XA2.  You may know this Formula to be (PA+Y)/2*PA, (PA+Y)/2*MA, or (MA+Y)/2*MA, the Formula for Punch Art, Geomancy, and Truth, respectively.  Obviously, though, because this runs off XA1 and XA2, it can now be much more than that based on X input.

If Formula = 0C, the Formula is "completed" as XA1+Y+XA2.  You may know this Formula to be PA+Y+WP, the Formula used by the Knight's Break techniques, though now it can support far more than just PA and WP obviously.  There is no special operation performed by Y here.


This checks if the "Zodiac Enabled" Flag has been checked, checks to see neither is Serpentarius, checks alignment, checks Gender for Best/Worst, and modifies XA2 based on the results of those checks.


Load XA2, XA1. Check for XA2=0, if true, set XA2 to 1, else multiply XA2 by XA1 and store the new XA2.


This routine starts by checking 3 flags.  The first is the Un- flag, checking to see whether the ability is trying to connocate a typical C(Br or Fa) * T(Br or Fa) / 10000 or a Malak-inspired (100-C[Br or Fa]) * (100-T[Br or Fa]) / 10000.  It then checks to see which is actually flagged between Br or Fa, and makes the jump to the proper section of the routine and calculating the Br and Fa (normal) that will actually be inserted into the routines.  Innocent and Faith is then calculated for the faith routine. It then calculates the inverted Brave or Faith (if flagged) and adds constants (if using the latter version) to this end-value Br and Fa.  It finally then "builds" the calculation of (end TBrFa * CBrFa / 10000).


This routine starts by checking your Ability ID and whether the Critical Hit flag is toggled.  If yes, this gives your skill a percent chance to land a Critical Hit as defined by the user. (The rate can be modified by editing the code.)  If a Critical Hit lands, an extra value from 1 to the original damage score is added to the attack's damage.  It then checks to see whether the Knockback flag is toggled.  If so, it rolls for Knockback (the percent chance can again be changed my modifying the code) then checks whether user is targeting self, a Chocobo, a mounted unit, then... this routine does a whole load or horseshit you don't need to know about unless you intend to modify it.  Just know it checks for various map bounds, illegal panels to be knocked into, etc., along with the attacker's direction, and sends the unit in the correct direction based on all these factors.  If the unit performing the Knockback is at a diagonal, there is a semi-random element involved as to whether the unit being Knocked will go one direction or the other.  It then checks for the height drop and any damage that should be inflicted, including a random +/- modifier to compensate for the removed acknowledgement of .5h tiles.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on February 23, 2011, 04:20:47 am
Finally, my knockback routine is done.

There are some small differences with FFT:
1) Sloped height is no longer calculated.
2) Frogged units can be knocked back.  Units with float (status and movement ability), fly, or ignore height do not take damage.
3) Critical attacks now no longer default to knockback.
4) WE no longer consider halves of elevation.  This means a unit from 7h can technically be knocked to a tile of 7.5h, which previously was not allowed.
5) COMING SOON: There will be a 5% of HPMax Variance on fall damage to compensate for not considering halves of elevation.


lhu r4, 0x38D6 (r1) r4 = Used Ability ID
lui r5, 0x8006
sll r4, r4, 0x03 r4 = r4 * 8
addu r4, r5, r4
lbu r9, -0x1409 (r4) r9 = AI Byte 8
addu r8, r31, r0 Sends r31 into r8 because r31 will be modified by jal commands below.
andi r4, r9, 0x0010
beq r4, r0, (KB Check) If the first blank flag under the Third Unknown in the "Learn on Hit" box is unflagged, GOTO (KB Check)
sb r0, 0x38CC (r1) Reset Higher Tile Flag
jal (RNG) ELSE, GOTO (RNG)
addiu r7, r0, 0x0064
addiu r4, r0, 0x0004
sub r4, r4, r7 r4 = 4 - RN from 0 to 99
bltz r4 (KB check) If RN > 4, GOTO (KB check)
addiu r5, r0, 0x0001
sb r5, 0x018D (r2) Flag attack as critical.
jal (RNG) GOTO (RNG)
lhu r7, 0x38D0 (r1) r7 = Base Damage
lhu r6, 0x38D0 (r1) r6 = Base Damage
addiu r7, r7, 0x0001 r7 = {1...Base Damage}
addu r6, r6, r7 New Damage = Base Damage + {1...Base Damage}
sh r6, 0x38D0 (r1) Store New Damage
(KB check) andi r4, r9, 0x0008
beq r4, r0, (E) If the second blank flag under the Third Unknown in the "Learn on Hit" box is unflagged, GOTO (E)
sb r0, 0x38EE (r1) Reset Knockback Height
jal (RNG) GOTO (RNG)
addiu r7, r0, 0x0064
addiu r4, r0, 0x0031
sub r4, r4, r7 r4 = 49 - RN from 0 to 99
bltz r4 (E) If RN > 49, GOTO (E)
(KB) lbu r5, 0x0182 (r3)
beq r2, r3, (E) If you are targeting yourself with knockback, GOTO (E)
lbu r4, 0x0005 (r3)
lbu r6, 0x0047 (r2) r6 = Attacker X Coordinate
andi r4, r4, 0x0004
bne r4, r0, (E) If target is immortal, GOTO (E)
lbu r7, 0x0047 (r3) r7 = Defender X Coordinate
bne r5, r0, (E) If target is riding a chocobo or in 2h+ water, GOTO (E)
lui r4, 0x800E
lbu r5, 0x4E9C (r4) r5 = Map Maximum X
beq r7, r0 (CheckEdge1) If Defender X Coordinate = 0, GOTO (CheckEdge1)
sb r0, 0x38EC (r1) Reset Knockback Flag
beq r7, r5 (CheckEdge2) If Defender X Coordinate = Map Maximum X, GOTO (CheckEdge2)
nop
sub r5, r6, r7 XA1 Byte 1 = Attacker X - Defender X
j (YChecks) Store Byte 1 of XA1 and GOTO (YChecks)
sb r5, 0x38CE (r1)
(CheckEdge1) beq r6, r0 (YChecks) If Defender and Attacker X Coordinate = 0, GOTO (YChecks)
sb r0, 0x38CE (r1) Store Byte 1 of XA1 as 0.
(E) jr r8 ELSE, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(CheckEdge2) beq r6, r5 (YChecks) If Defender and Attacker X Coordinate = Maximum, GOTO (YChecks)
sb r0, 0x38CE (r1) Store Byte 1 of XA1 as 0.
jr r8 If Defender X Coordinate = Maximum, but Attacker X coordinate is not maximal, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(YChecks) lbu r6, 0x0048 (r2) r6 = Attacker Y Coordinate
lbu r7, 0x0048 (r3) r7 = Defender Y Coordinate
lbu r5, 0x4EA0 (r4) r5 = Map Maximum Y
beq r7, r0, (CheckEdge3) If Defender Y Coordinate = 0, GOTO (CheckEdge3)
nop
beq r7, r5, (CheckEdge4) If Defender Y Coordinate = Maximum Y, GOTO (CheckEdge4)
nop
sub r5, r6, r7 XA1 Byte 1 = Attacker Y - Defender Y
j (NewXY) Store Byte 2 of XA1 and GOTO (NewXY)
sb r5, 0x38CF (r1)
(CheckEdge3) beq r6, r0 (NewXY) If Defender and Attacker Y Coordinate = 0, GOTO (NewXY)
sb r0, 0x38CF (r1) Store Byte 2 of XA1 as 0.
jr r8 If Defender Y Coordinate = 0, while Attacker Y Coordinate isn't, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(CheckEdge4) beq r6, r5 (NewXY) If Defender and Attacker Y Coordinate = Maximum, GOTO (NewXY)
sb r0, 0x38CF (r1) Store Byte 2 of XA1 as 0.
jr r8 If Defender Y Coordinate = Maximum, but Attacker Y coordinate is not maximal, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(NewXY) lb r4, 0x38CE (r1) r4 = Attacker X - Defender X
lb r5, 0x38CF (r1) r5 = Attacker Y - Defender Y
bgez r4 (+X) If r4 is greater than or equal to 0, GOTO (+X)
addiu r7, r0, 0x0100
addiu r6, r0, 0x0001 If r4 < 0, r6 = 1
j (YDiff) Make r4 positive and GOTO (YDiff)
subu r4, r7, r4 If r4 < 0, r4 = 0x100 - r4 (as unsigned byte), essentially the equivalent of multiplying a signed byte by -1.
(+X) bne r4, r0 (YDiff) If r4 > 0, r6 = 2 and GOTO (YDiff)
addiu r6, r0, 0x0002
addiu r6, r0, 0x0000 ELSE, r6 = 0
(YDiff) bgez r5 (+Y) If r5 is greater than or equal to 0, GOTO (+Y)
addiu r7, r0, 0x0100
ori r6, r6, 0x0004 If r5 < 0, r6 = r6 OR 0x4 = r6 + 4 (because r6 = 0, 1, or 2)
j (CoordChange) Make r5 positive and GOTO (CoordChange)
subu r5, r7, r5 If r5 < 0, r5 = 0x100 - r5 (as unsigned byte), essentially the equivalent of multiplying a signed byte by -1.
(+Y) beq r5, r0 (CoordChange) If r5 = 0, r6 = r6 and GOTO (CoordChange)
ori r6, r6, 0x0000
ori r6, r6, 0x0008 ELSE, r6 = r6 OR 0x8 = r6 + 8 (because r6 = 0, 1, or 2)
(CoordChange) jal (RNG) r7 = r4 + r5 = Distance Attacker is from Defender and GOTO (RNG)
addu r7, r4, r5
sub r7, r4, r7 r7 = |Attacker X - Defender X| - {0...|Attacker X - Defender X| + |Attacker Y - Defender Y| - 1}
bgtz r7 (ChangeX) If r7 > 0, GOTO (Change X)
lbu r5, 0x0048 (r3) r5 = Defender Y
andi r6, r6, 0x0008
beq r6, r0, (+1Y) If Attacker Y < Defender Y, GOTO (+1Y)
nop
j (NewCoord) If Attacker Y > Defender Y, Defender Y = Defender Y - 1 and GOTO (NewCoord)
addi r5, r5, -0x0001
(+1Y) j (NewCoord) If Attacker Y < Defender Y, Defender Y = Defender Y + 1 and GOTO (NewCoord)
addiu r5, r5, 0x0001
(ChangeX) lbu r4, 0x0047 (r3) r4 = Defender X
andi r6, r6, 0x0002
beq r6, r0, (+1X) If Attacker X < Defender X, GOTO (+1X)
nop
j (NewCoord) If Attacker X > Defender X, Defender X = Defender X - 1 and GOTO (NewCoord)
addi r4, r4, -0x0001
(+1X) addiu r4, r4, 0x0001 If Attacker X < Defender X, Defender X = Defender X + 1
(NewCoord) lui r6, 0x800E
lbu r6, 0x4E9C (r6) r6 = Map Maximum X
sb r4, 0x38CE (r1) Store Defender X as XA1 Byte 1
sb r5, 0x38CF (r1) Store Defender Y as XA1 Byte 2
lhu r5, 0x0048 (r3) r5 = Pre-Attack Defender Y + Unit Facing
lbu r4, 0x0047 (r3) r4 = Pre-Attack Defender X
andi r7, r5, 0x8000
jal (TileOffset) GOTO (TileOffset)
andi r5, r5, 0x00FF r5 = Pre-Attack Defender Y
bne r7, r0, (HigherTile) If the defender stood on a higher tile, GOTO (HigherTile)
nop
j (NewHeight) ELSE, r7 = Height of Lower Tile and GOTO (NewHeight)
lbu r7, -0x0732 (r4)
(HigherTile) lbu r7, 0x00CE (r4) r7 = Height of Higher Tile
(NewHeight) lbu r5, 0x38CF (r1) r5 = Defender Y (current)
jal (TileOffset) GOTO (TileOffset)
lbu r4, 0x38CE (r1) r4 = Defender X (current)
lbu r9, 0x005A (r3) r9 = Current Status Byte 3
lbu r5, 0x0093 (r3) r5 = Movement Status Byte 1
andi r9, r9. 0x0040
bne r9, r0, (SCheckFail) If target has float status, GOTO (SCheckFail)
lbu r2, 0x0095 (r3) r2 = Movement Status Byte 3
andi r5, r5, 0x0002
bne r5, r0, (SCheckFail) If target has ignore height, GOTO (SCheckFail)
andi r2, r2, 0x000C
beq r2, r0, (SCheckGood) If target doesn't have float/fly, GOTO (SCheckGood)
addu r9, r0, r0 If target doesn't have float/fly/ignore height, r9 = 0
(SCheckFail) addiu r9, r0, 0x0001 ELSE, r9 = 1
(SCheckGood) lbu r5, -0x0732 (r4) r5 = Height of Current Lower Tile
lbu r2, -0x072E (r4) r2 = Byte 7 of Current Lower Tile Data
sltu r4, r7, r5
bne r4, r0 (E) IF r7 < r5, GOTO (E)
andi r2, r2, 0x0001
bne r2, r0, (HigherTile) ELSE IF lower tile is impassable, GOTO (HigherTile)
sub r4, r7, r5 r4 = r7 - r5
bne, r9, r0, (NoFallDamageL) ELSE If target has float/fly/ignore height, GOTO (NoFallDamageL)
nop
sb r4, 0x38EE (r1) ELSE, Store r4 as knockback height
(NoFallDamageL) ori r4, r0, 0x0001 r4 = 1
sb r4, 0x38EC (r1) Flag Knockback
(HigherTile) lbu r5, 0x38CF (r1) r5 = Defender Y (current)
jal (TileOffset) GOTO (TileOffset)
lbu r4, 0x38CE (r1) r4 = Defender X (current)
lbu r5, 0x00CE (r4) r5 = Height of Current Higher Tile
lbu r2, 0x00D2 (r4) r2 = Byte 7 of Current Higher Tile Data
beq r5, r0 (E2) IF r5 = 0, GOTO (E2)
sltu r4, r7, r5
bne r4, r0 (E2) ELSE IF r7 < r5, GOTO (E2)
andi r2, r2, 0x0001
bne r2, r0, (E) ELSE IF higher tile is impassable, GOTO (E)
sub r4, r7, r5 r4 = r7 - r5
bne, r9, r0, (NoFallDamageH) ELSE If target has float/fly/ignore height, GOTO (NoFallDamageH)
addu r6, r0, r0 r6 = 0
sb r4, 0x38EE (r1) ELSE, store r4 as Knockback Height.
(NoFallDamageH) ori r4, r0, 0x0001 r4 = 1
sb r4, 0x38EC (r1) Flag Knockback
(E2) lbu r4, 0x38EC (r1) r4 = Knockback flag.
nop
beq r4, r0, (E) If Knockback is not flagged, GOTO (E)
nop
bne r6, r0, (LowerFlag) ELSE If r6 = Map Maximum X (and not 0), GOTO (LowerFlag)
addiu r7, r0, 0x0001 r7 = 1
sb r7, 0x38CC (r1) ELSE, flag Higher Tile
(LowerFlag) lbu r5, 0x38C1 (r1) r5 = The Xth unit on map (target)
lbu r4, 0x38CE (r1) r4 = Target X (current)
sb r5, 0x38EF (r1) Store r5.
lbu r5, 0x38CF (r1) r5 = Target Y (current)
sb r4, 0x38CA (r1) Store r4.
lbu r4, 0x019D (r3) r4 = Attack Elemental Modifier Flags vs. Target
sb r5, 0x38CB (r1) Store r5.
ori r4, r4, 0x0040 r4 = r4 OR 0x40
jr r8 GOTO Main Routine
sb r4, 0x019D (r3) Store r4, which now has a knockback on attack flag

(TileOffset) mult r5, r6
mflo r5 r5 = Map Maximum X * Defender Y (pre-attack or current)
addiu r5, r5, r4 r5 = Map Maximum X * Defender Y + Defender X (pre-attack or current)
sll r5, r5, 0x03 r5 = r5 * 8
lui r4, 0x8019
jr 31  Return to Critical/Knockback Routine
addu r4, r4, r5

(RNG) lui r4, 0xA001
lw r5, -0x6FF0 (r4) Load random word.
lui r6, 0x41C6
addiu r6, r6, 0x4E6D
multu r5, r6
mflo r5
addiu r5, r5, 0x3039
sw r5, -0x6FF0 (r4) Store new Random Word.
mult r7, r5
jr 31 Return to Critical/Knockback Routine
mfhi r7 r7 = {0...value(r7)-1}

BATTLE.BIN
0x123EB0
00000000

BATTLE.BIN
0x11408C
00000000
00000000

BATTLE.BIN
0x1140FC
00000000
00000000

BATTLE.BIN
0x115FD8
EC

BATTLE.BIN
0x115FE0
01

BATTLE.BIN
0x124420
EC

BATTLE.BIN
0x124428
01

BATTLE.BIN
0x116250
EC

BATTLE.BIN
0x1162AC
EC

BATTLE.BIN
0x1162B4
01

BATTLE.BIN
0x1162C4
EC

BATTLE.BIN
0x123E50
EC

BATTLE.BIN
0x119EB8
lui r18, 0x8019 or 1980123C
0x119EC4
lbu r18, 0x38CC (r18) or CC385292

Title: Re: ASM Collective BATTLE.BIN Map
Post by: Vanya on February 26, 2011, 07:13:18 pm
That sounds like a huge improvement over the original. Huzzah!
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on February 26, 2011, 07:37:12 pm
5) Is the unit just not Knocked back, or is the option to pick it up given?  If the option is given, what happens if the unit chooses No?  You don't want there to be a Knight standing inside of a Treasure Box or something equally stupid occurring.

I'll trace through that retarded monster of a routine that's still maybe a third of what Square originally had coded and do my retarded-people-friendly writeup tonight.  I mostly know how it works but I'm having a bad headache so I'd rather not mess this one up like I did the last one.

EDIT: added KB/CHit routine description to my previous post.  Don't feel like moving it around to this one.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on February 28, 2011, 07:22:14 am
Quote from: RavenOfRazgriz on February 26, 2011, 07:37:12 pm
5) Is the unit just not Knocked back, or is the option to pick it up given?  If the option is given, what happens if the unit chooses No?  You don't want there to be a Knight standing inside of a Treasure Box or something equally stupid occurring.


My code actually does not address that issue.  I checked the code again.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on March 02, 2011, 11:56:15 pm
All right, next routine.

DONE!


lw r2, 0x2D94 (r1) r2 = Attacker Offset
lhu r4, 0x38D6 (r1) r4 = Ability ID
lbu r8, 0x3904 (r1) r8 = Weapon Elemental
lbu r5, 0x38F3 (r1) r5 = Ability Flags Byte 1
lbu r7, 0x38F7 (r1) r7 = Ability Elemental
andi r9, r5, 0x0020
beq r9, r0 (CheckWS) If Ranged Weapon is not flagged, GOTO (CheckWS)
lui r6, 0x8006
addu r7, r8, r0 ELSE, Ability Elemental = Weapon Elemental
(CheckWS) andi r9, r5, 0x0004
beq r9, r0 (CheckNull) If Weapon Strike is not flagged, GOTO (CheckNull)
nop
or r7, r7, r8 ELSE, Ability Elemental = Weapon Elemental + Ability Elemental
(CheckNull) sll r4, r4, 0x03 r4 = Ability ID * 8
addu r6, r6, r4 r6 = r6 + Ability ID * 8
lbu r8, 0x006E (r3) r8 = Target Elemental Nullification Byte
lhu r4, 0x0058 (r3) r4 = Target Status Bytes 1 and 2
andi r8, r8, r7
bne r8, r0, (ENull) If element is Nulled, GOTO (ENull)
lbu r6, -0x140B (r6) r6 = AI Flags Byte 5
lbu r8, 0x0070 (r3) ELSE, r8 = Target Elemental Weakness Byte
andi r4, r4, 0x0410
beq r4, r0, (CheckOil) If target is not undead or vampire (has blood suck), GOTO (CheckOil)
addiu r9, r0, 0x0001
ori r8, r8, 0x0002 ELSE, Target is now weak against holy
(CheckOil) lbu r4, 0x005A (r3) r4 = Target Status Bytes 3
sb r9, 0x018C (r3) Flag attack as hit.
andi r4, r4, 0x0080
beq r4, r0 (NoStatusWeak) If target does not have oil, GOTO (NoStatusWeak)
nop
ori r8, r8, 0x0080 ELSE, Target is now weak against fire
(NoStatusWeak) lhu r4, 0x38D0 (r1) r4 = Base Damage
andi r6, r6, 0x0020
beq r6, r0, (EWeak) If AI Undead Reverse Flag is not flagged, r9 = 1 and GOTO (EWeak)
addiu r9, r0, 0x0001
andi r9, r5, 0x0080 ELSE r9 = 0, if the first blank flag under Player Abilities isn't flagged (healing), or 80 if it is (drain)
(EWeak) lbu r5, 0x38D6 (r1) r5 = Ability ID
lui r6, 0x8006
sll r5, r5, 0x03 r5 = Ability ID * 8
addu r6, r6, r5 r6 = r6 + Ability ID * 8
lbu r5, -0x140C (r6) r5 = AI Flags Byte 4
and r8, r8, r7
beq r8, r0, (SetupDMG) If the target is not weak against the spell's element, GOTO (SetupDMG)
addi r9, r9, -0x0001
sll r4, r4, 0x01 ELSE, r4 = r4 * 2
(SetupDMG) andi r5, r5, 0x00A0
beq r5, r0, (EAbsorb) If the AI HP and MP flags are unflagged, GOTO (EAbsorb)
addu r6, r4, r0 r6 = r4
andi r6, r5, 0x0080
beq r6, r0 (-MP) ELSE, r6 = 0 or 0x80 and if AI flag HP is not flagged (r6 = 0), GOTO (-MP)
nop
andi r6, r5, 0x0040
beq r6, r0 (-HP) ELSE, If AI flag MP is not flagged, GOTO (-HP)
sh r4, 0x0190 (r3) Stores HP Damage as 2x Base Damage
srl r4, r4, 0x01
(-MP) sh r4, 0x0194 (r3) Stores r4 as MP Damage
(-HP) lbu r4, 0x019D (r3) r4 = Elemental Resistance Byte
beq r8, r0, (EAbsorb) If the target is not weak against the spell's element, GOTO (EAbsorb)
lbu r6, 0x01B1 (r3) r6 = Attack Type Byte
ori r4, r4, 0x0008 ELSE, r4 includes damage is elemental weakness
ori r6, r6, 0x00A0 r6 includes HP/MP Damage
sb r4, 0x019D (r3) Store r4 as elemental resistance byte
bgtz r9, (DrainFlags) If attack is supposed to drain, GOTO (DrainFlags)
sb r6, 0x01B1 (r3) Store r6 as attack type byte
j (EAbsorb) ELSE, GOTO (EAbsorb)
nop
(DrainFlags) lhu r4, 0x0194 (r3) r4 = MP Damage Dealt
lhu r5, 0x002C (r3) r5 = Target MP
lhu r6, 0x002C (r3) r6 = Target MP
sub r5, r5, r4
bltz r5, (ExcessMPDMG) If target MP < MP Damage Dealt, GOTO (ExcessMPDMG)
nop
j (HPDrain) GOTO (HPDrain)
sh r4, 0x0196 (r2) ELSE, Set MP restored to MP Damage Dealt.
(ExcessMPDMG) sh r6, 0x0196 (r2) If target MP < MP Damage Dealt, set MP restored as target MP.
(HPDrain) lhu r4, 0x0190 (r3) r4 = HP Damage Dealt
lhu r5, 0x0028 (r3) r5 = Target HP
lhu r6, 0x0028 (r3) r6 = Target HP
sub r5, r5, r4
bltz r5, (ExcessHPDMG) If target HP < HP Damage Dealt, GOTO (ExcessMPDMG)
nop
j (SelfFlags) GOTO (SelfFlags)
sh r4, 0x0192 (r2) ELSE, Set HP restored to HP Damage Dealt.
(ExcessHPDMG) sh r6, 0x0192 (r2) If target HP < HP Damage Dealt, set HP restored as target HP.
(SelfFlags) ori r4, r0, 0x0001
lbu r5, 0x01B1 (r2) r5 = Attack Type Byte of caster.
sb r4, 0x018C (r2) Drain will affect caster.
ori r5, r5, 0x0050 r5 includes HP/MP Healing
sb r5, 0x01B1 (r2) r5 is stored as the caster attack type byte.
ori r6, r0, 0x0100 r6 = 0x100
beq r9, r6, (E) If r9 = 0x100 (only possible if drain attack has no elemental modifiers), GOTO (E)
(EAbsorb) lbu r4, 0x0058 (r3) r4 = Target Status Bytes 1
lbu r8, 0x006D (r3) r8 = Target Elemental Absorption Byte
andi r4, r4, 0x0010
beq r4, r0, (NoUndead) If the target isn't undead, GOTO (NoUndead)
nop
ori r8, r8, 0x0001 ELSE, the target absorbs dark attacks.
(NoUndead) and r8, r8, r7
beq r8, r0, (Normal) If the target does not absorb the spell's element, GOTO (Normal)
lhu r4, 0x0190 (r3) r4 = HP Damage
bne r5, r0 (NotStatus) If the attack deals damage, drain, or healing, GOTO (NotStatus)
sll r6, r6, 0x01 Double hit chance of non-damage attack if target absorbs element.
j (E) ELSE, GOTO (E)
sh r6, 0x01B6 (r2) r6 = Attacker Hit Chance
(NotStatus) lhu r5, 0x0194 (r3) r5 = MP Damage
(HealSetup) sh r0, 0x0190 (r3) HP Damage is 0
bgtz r9, (DrainReversalFlags) If attack is supposed to drain, GOTO (DrainReversalFlags)
sh r0, 0x0194 (r3) MP Damage is 0
sh r4, 0x0192 (r3) r4 = HP Healing
sh r5, 0x0196 (r3) r5 = MP Healing
(EAbsorbFlags) lbu r5, 0x019D (r3) r5 = Elemental Resistance Byte
lbu r6, 0x01B1 (r3) r6 = Attack Type Byte
ori r5, r5, 0x0004 r5 includes healing is elemental absorption
andi r6, r6, 0x005F r6 no longer includes HP/MP damage.
ori r6, r6, 0x0050 r6 includes HP/MP Healing
sb r5, 0x019D (r3) Store r5 as elemental resistance byte
jr 31 Return to Main Formula Routine
sb r6, 0x01B1 (r3) Store r6 as attack type byte
(DrainReversalFlags) sh r4, 0x0190 (r2) r4 = HP Damage on Caster
lbu r6, 0x002C (r2) r6 = Caster MP
sh r5, 0x0194 (r2) r5 = MP Damage on Caster
sub r6, r6, r5
bltz r6, (ExcessMPHeal) If caster MP < MP Damage Dealt, GOTO (ExcessMPHeal)
sh r0, 0x0196 (r2) MP Healing on Caster is 0
j (HPReversal) GOTO (HPReversal)
sh r5, 0x0196 (r3) ELSE, Target MP Healing = Caster MP Damage
(ExcessMPHeal) add r6, r6, r5
sh r6, 0x0196 (r3) If Caster MP < MP Damage Dealt, Target MP Healing = Caster MP
(HPReversal) lbu r6, 0x0028 (r2) r6 = Caster HP
nop
sub r6, r6, r4
bltz r6, (ExcessHPHeal) If caster HP < HP Damage Dealt, GOTO (ExcessHPHeal)
sh r0, 0x0192 (r2) HP Healing on Caster is 0
j (SelfReverseFlags) GOTO (SelfReverseFlags)
sh r4, 0x0192 (r3) ELSE, Target HP Healing = Caster HP Damage
(ExcessMPHeal) add r6, r6, r4
sh r6, 0x0192 (r3) If Caster HP < HP Damage Dealt, Target MP Healing = Caster MP
(SelfReverseFlags) lbu r6, 0x01B1 (r2) r6 = Caster Attack Type Byte
ori r5, r0, 0x0001
andi r6, r6, 0x00AF r6 no longer includes HP/MP healing.
ori r6, r6, 0x00A0 r6 includes HP/MP Damage
sb r5, 0x018C (r2) Caster is affected by drain reversal.
j (EAbsorbFlags) GOTO (EAbsorbFlags)
sb r6, 0x01B1 (r2) Store r6 as attack type byte
(Normal) bne r5, r0 (NotStatus2) If the attack deals damage, drain, or healing, GOTO (NotStatus2)
nop
j (E) ELSE, GOTO (E)
sh r6, 0x01B6 (r2) r6 = Attacker Hit Chance
(NotStatus2) bltz r9, (Healing) If r9 < 0 (if the AI flags are set as healing), GOTO (Healing)
lhu r5, 0x0194 (r3) r5 = MP Damage
lbu r6, 0x01B1 (r3) ELSE, r6 = Attack Type Byte
nop
ori r6, r6, 0x00A0 r6 includes HP/MP Damage
bgtz r9, (Drain) If r9 > 0 (if the AI flags are set as drain), GOTO (Drain)
sb r6, 0x01B1 (r3) Store r6 as Attack Type Byte
jr 31 ELSE (if attack is not drain/healing), return to Main Formula Routine
nop
(Healing) addu, r7, r31, r0 r7 = Return address
jal (HealSetup) Save offset into r31 and GOTO (HealSetup)
nop
andi r5, r5, 0x00FB r5 no longer includes healing as elemental absorption
jr r7 Return to Main Formula Routine
sb r5, 0x019D (r3) Store r5 as elemental resistance byte
(Drain) j (DrainFlags) GOTO (DrainFlags)
addiu r9, r0, 0x0100 r9 = 0x100 (for comparison purposes above)
(E) jr r31 Return to Main Formula Routine
nop

(ENull) sb r0, 0x018C (r3) Attack will miss.
sh r0, 0x0190 (r3) HP Damage is 0.
sh r0, 0x0192 (r3) MP Damage is 0.
sh r0, 0x0194 (r3) HP Healing is 0.
sh r0, 0x0196 (r3) MP Healing is 0.
sh r0, 0x019C (r3) Set the elemental resistance byte to 0
sb r0, 0x01B1 (r3) Set the attack type byte to 0
sh r0, 0x01B6 (r3) Set the accuracy to 0
lhu r5, 0x38C8 (r1) r5 = Halfword
ori r4, r0, 0x0005
sb r4, r0, 0x018E (r3) Display on missed attack is "Nullified"
lbu r4, 0x38ED (r1) r4 = Byte
beq r5, r0, (NextCheck) If Halfword is 0, GOTO (NextCheck)
sh r0, 0x38C8 (r1) r5's halfword = 0
sh r0, 0x38C6 (r1) ELSE, previous halfword = 0
(NextCheck) andi r4, r4, 0x0080 r4 = r4 AND 0x80
beq r4, r0 (E2) If Byte is 0, GOTO (E2)
nop
sb r0, 0x38ED (r1) ELSE, r4's byte = 0
(E2) jr r31 Return to Main Formula Routine
nop

Title: Re: ASM Collective BATTLE.BIN Map
Post by: RandMuadDib on March 03, 2011, 03:41:53 am
Since you plan on using the boolean in FFTPatcher between "Hit Allies" and "Follow Target," does that mean you are going to build in Xif's Weapon Strike Fix into the elemental calculations, so weapon elementals can be taken into consideration as well? I know you said that the elemental routine you posted isnt finished, but i didnt see anything that mentioned weapon elements (i am also very poor at reading asm and am relying on your purple text). Thanks!
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on March 03, 2011, 03:49:57 am
^ Yes, Xifanie's Weapon Strike Fix will have been made irrelevant once the Formula Hack is done... in addition to a rather huge as hell pile of other things.  
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RandMuadDib on March 03, 2011, 03:54:22 am
Excellent you're my hero and i eagerly await any and all process. Super excited :)
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RandMuadDib on March 06, 2011, 05:36:42 pm
There's also the blank AI flag just above Direct Attack. No abilities have it flagged, and so should be completely usable if you had a desire to do so.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on March 06, 2011, 06:45:14 pm
It's already in use.  We've already mapped out all the blank flags and put them to use, and the V2 release will put far more... unexpected things to use as well.  All the flags are also getting rearranged for optimal customization, since not all abilities support the Abilities box (the one on the bottom, see stuff like Charge and Throw for people who want to still use those), nor do R/S/M for whatever functionality we can force out of flags for those.  We spend tons of time mapping things out in advance to maximize features, to the point where I think almost everything is pretty well mapped, the coding for some areas (mostly shit like Knockback/Critical) just means coding some areas takes far longer than planning them does.  That, and I can't code in assembly worth shit and FDC's only human, so getting it from design phase to product phase takes time since he's essentially recoding nearly every section he comes across.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RandMuadDib on March 06, 2011, 07:03:00 pm
Sure, i was just prepping resources.zip from a post back on page 2,

Quote from: formerdeathcorps on February 05, 2011, 04:31:44 am
After weeks of discussion on iRC with Raven, I think I have the final structure hammered out.  Everything I've already posted on this matter will be completely rewritten.

Plans:


And I didnt see any mention of that particular flag, so i figured i'd say something, just on the extremely off chance that you guys missed it.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on March 06, 2011, 08:02:29 pm
Quote from: RandMuadDib on March 06, 2011, 07:03:00 pm
Sure, i was just prepping resources.zip from a post back on page 2,

And I didnt see any mention of that particular flag, so i figured i'd say something, just on the extremely off chance that you guys missed it.


It's cool.

Those plans are horrifically out of date, that's all. The flag-hijacking has become a lot more elaborate since he made that post. It's just easier to code and then retard-friendly-document each piece instead of trying to constantly revise a Plans notes since we're still not 100% on which features will be in V1 and which in V2 until he sees how hard each is to code and if that feature is going to need some of the space we're freeing up from recoding the thing, since a few things being added will actually take more space than before in order to add a pile of extra features, and you can't use more space until you know how much space is actually free.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RandMuadDib on March 13, 2011, 10:52:54 am
I was wondering if you were planning on adding a way to check for the job of the target, to do extra damage or have a better chance o hit. I know a few people have asked for that in other threads and having a beast-hunter option open would be cool.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on March 13, 2011, 04:36:28 pm
Quote from: RandMuadDib on March 13, 2011, 10:52:54 am
I was wondering if you were planning on adding a way to check for the job of the target, to do extra damage or have a better chance o hit. I know a few people have asked for that in other threads and having a beast-hunter option open would be cool.


V2 is slated to have checks for Status and Gender, meaning you can make proper Beast Tamers and Necromancers by checking for "Monster" Gender, the "Undead" Status, etc.  Same effect, but it's far more efficient to check for Gender and Status instead of Job IDs and other stupid crap... and easier for a user to modify the checks that way.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pickle Girl Fanboy on March 22, 2011, 11:37:31 am
When this is done, will we be able to give all status effects charge times?
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on April 13, 2011, 06:59:35 am
That's tangentially covered by this hack when I rewrite how unit RAM is read and written (but that's likely much later, once I get a handle of how the AI reads unit RAM data).  However, the lower hanging fruit (i.e. simply getting 2 statii to share 1 timer as long as they are mutually canceling), is certainly within my reach.

Just finished my elemental resistance/weakness hack.  Onwards to equipment break/steal!
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on April 17, 2011, 05:29:27 am
OK, here's some AI unit RAM stuff:

0x19F3C4 (RAM byte)
This is the current skill set of the move being considered by the AI.

0x19F3C6 (RAM halfword)
This is the current move being considered by the AI.

0x19F3C8 (RAM byte)
This is the range of the current move being considered by the AI.

0x19F3C9 (RAM byte)
This is the AoE of the current move being considered by the AI.

0x19F3CA (RAM byte)
This is the item destroyed/stolen by the current move being considered by the AI.

0x19F3D0 (RAM 3 bytes)
Here's where the AI behavior bytes for the move currently under consideration are stored.

0x19F3E0 (RAM byte)
Byte = the Yth unit on the map, though units 0x10 and above are player units

0x19F3E1 (RAM byte)
A copy of 0x19FEC4.

0x19F3E2 (RAM halfword)
A copy of 0x19FEC6, except that if the move isn't usable, it won't be copied.

0x19F3E8 (RAM byte)
A copy of 0x19FECA.

0x19FEF5 (RAM byte)
Here's where the base accuracy is stored for the AI.

0x1A02B4 + 0x88*Y (RAM...sequence of words starts here...Y refers to the Yth unit on the map...though units 0x10 and above are player units)
Here are the moves of the target the AI commanded unit wants to attack---order is:
1) Halfword for the Ability/R/S/M (meaning getting the AI to consider reactions shouldn't be hard...Byte 2 can take any value that leaves a remainder of 0 or 1 when divided by 4)
2) Halfword for ??? (job of the target in byte 1 [default skillset for the basic ATTACK move 0x16F is A9, but move 0x00 is also ATTACK, with a job class 0xFF, which defaults to job class 0x1, which is named "Attack"] and priority of use in byte 2?...Byte 1 gets copied to 0x19F3C4; Byte 2 gets copied to 0x19F3D3...Byte 2 gains 0x80 if checked already by the routine that checks all the moves [which is reset to lose the 0x80s when the same routine checks the data again]; during the final check, only the move that the AI will actually use will get the 0x80 flag at 0x19F3D3, everything else won't, moves that do not have the first Unknown trigger under "Learn on Hit" will never be written into 0x19F3E2 and thus will not be considered during this final check)
3) The spacing implies a unit can't have more than 0x22 or 34 independent moves (between a primary/secondary + 00 Attack + 0x16F attack).  It also is the primary reason why the AI can't check for counters...insufficient space, though since the AI shouldn't need that redundancy for attack, we might as well take that space for reactions.

Routine Process:
1) Check all moves of all units on map (includes self)
2) Check self moves at least twice (last time seems to actually determine what moves to use)
3) Act
Title: Re: ASM Collective BATTLE.BIN Map
Post by: pokeytax on April 17, 2011, 09:00:03 am
Wow, that's fantastic, good stuff.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on April 21, 2011, 08:54:44 pm
This is the latest version, which should have no more pipeline hazard and signed/unsigned problems, as well as float nulling earth (I forgot this) and my notation on the hit byte (0x2 means your formula was a % formula).  Another bug fixed was one AI flag being used in two separate routines.

Another fixed bug is that weapon elemental on weapon strike weapon wasn't being considered for elemental boost/halve, and float was nulling wind, not earth.

lui r1, 0x8019
lbu r3, 0x38F9 (r1) Loads X
lw r2, 0x2D94 (r1) Loads the attacker's stats
addiu r6, r1, 0x38CE r6 = XA1's address
addiu r7, r1, 0x38D0 r7 = XA2's address
andi r3, r3, 0x000F r3 = the last 4 bits of X
(LS) sltiu r4, r3, 0x0004
bne r4, r0, (*) If r3 < 4, GOTO (*)
lbu r5, 0x0036 (r2) r5 = Attacker PA
sltiu r4, r3, 0x0008
bne r4, r0, (*) If r3 < 8, GOTO (*)
lbu r5, 0x0037 (r2) r5 = Attacker MA
sltiu r4, r3, 0x000C
bne r4, r0, (*) If r3 < 12, GOTO (*)
lbu r5, 0x0038 (r2)  r5 = Attacker SP
nop
lbu r5, 0x3902 (r1)  r5 = Attacker WP
(*) beq r6, r7, (E) If r6 = r7, GOTO  End.
sb r5, 0x0000 (r6) Stores r5 at the address of r6
andi r3, r3, 0x0003
sll r3, r3, 0x0002
addiu r3, r3, 0x0001 The purpose of these r3 manipulations is to put r3 in a form that the previous loop can understand.
j (LS) Jumps back to the Loop's Start.
addiu r6, r6, 0x0002 r6 = r6 + 2 = r7 = XA2's address
(E) jr 31 Returns to the Main Formula Routine.
nop


lbu r6, 0x3904 (r1) r6 = Weapon Elemental
lbu r4, 0x38F3 (r1) r4 = Ability Flags Byte 1
lbu r5, 0x38F7 (r1) r5 = Ability Elemental
andi r7, r4, 0x0004
beq r7, r0 (E) If Weapon Strike is not flagged, GOTO (E)
nop
or r5, r5, r6 ELSE, Ability Elemental = Weapon Elemental + Ability Elemental
(E) jr 31 Returns to the Main Formula Routine.
sb r5, 0x38F7 (r1) Store new Ability Elemental


lbu r4, 0x38F7 (r1) Loads ability element
lbu r5, 0x0071 (r2) Loads elements strengthened
lhu r6, 0x38D0 (r1) Loads XA2
and r4, r4, r5 Checks ability element against elements strengthened
beq r4, r0, (E) If ability element isn't a boosted element, GOTO (E)
srl r5, r6, 0x02 If ability element is boosted, r5 = [XA2/4]
addu r6, r6, r5 XA2 = XA2 + [XA2/4]
(E)  jr 31 Return to Main Routine
sh r6, 0x38D0 (r1) Stores XA2


lw r5, 0x2D98 (r1) Load target address.
ori r4, r0, 0x0005
beq r3, r4, (E) NOTE: r3 can only be 1, 5, 9, or 13, which corresponds to PA, MA, SP, WP.  If XA2 is MA, GOTO (E)
lbu r6, 0x005C (r5) Load Status Byte 5.
lbu r7, 0x0058 (r5) Load Status Byte 1.
lbu r5, 0x005A (r5) Load Status Byte 3.
andi r6, r6, 0x0010
bne r6, r0, (Mult) If target is asleep, GOTO (Mult)
andi r7, r7, 0x0008
bne r7, r0, (Mult) If target is charging, GOTO (Mult)
andi r5, r5, 0x0006
beq r5, r0, (E) If target isn't chickened/frogged, GOTO (E)
(Mult) lhu r4, 0x38D0 (r1) Load XA2.
nop
srl r5, r4, 0x01 r5 = [XA2/2]
addu r4, r4, r5 XA2 = XA2 + [XA2/2]
sh r4, 0x38D0 (r1) Store XA2.
(E) jr 31 Return to Main Routine
nop

ori r4, r0, 0x0005
beq r4, r3, (MA) NOTE: r3 can only be 1, 5, 9, or 13, which corresponds to PA, MA, SP, WP.  If r3 is MA, GOTO (MA)
addu r7, r31, r0 Stores the return address in r7 because it'll be modified by the jal commands below.
ori r4, r0, 0x000D
bne r4, r3, (PA/SP) If r3 isn't WP, GOTO (PA/SP)
lbu r5, 0x38D9 (r1)  Loads the "Two Hands" byte.
jal (WP-UP) If WP, GOTO  (WP-UP)
lbu r4, 0x38FF (r1) Loads weapon characteristic byte.
(PA/SP) jal (P-UP) If PA/SP, GOTO (P-UP)
lbu r3, 0x38D8 (r1) Loads Weapon Type byte.
j (E1) GOTO (E1)
nop
(MA) jal (M-UP) If MA, GOTO (M-UP)
lbu r3, 0x0090 (r2) Loads Support Byte 4.
(E1) jr 7 Return to Main Routine
nop

(WP-UP) lhu r6, 0x38D0 (r1) Loads XA2 = WP
beq r5, r0, (E2) If not using two-hands, GOTO  (E2)
andi r3, r4, 0x0001
bne r3, r0, (E2) If weapon is forced two-hands, GOTO  (E2)
andi r5, r4, 0x0004
beq r5, r0, (E2) If weapon is not two-handable, GOTO  (E2)
sll r6, r6, 0x01
sh r6, 0x38D0 (r1) If 2H is used and XA2 is WP, XA2 = XA2 * 2.
(E2) jr 31
nop
(P-UP) lbu r4, 0x0091 (r1) Loads Support Byte 5.
bne r3, r0, (A-UP)  If equipping a weapon, GOTO (A-UP)
lhu r5, 0x38D0 (r1) Loads XA2 = PA or SP.
andi r4, r4, 0x0020
beq r4, r0, (A-UP) If Martial Arts isn't used, GOTO (A-UP)
srl r6, r5, 0x01
addu r6, r5, r6
sh r6, 0x38D0 (r1) If Martial Arts is used and XA2 is PA or SP, XA2 = XA2 + [XA2/2].
(A-UP) lbu r3, 0x0090 (r2) Loads Support Byte 4.
lui r4, 0x5555  r4 = 55550000.
andi r5, r3, 0x0010
beq r5, r0, (E3)  If Attack Up isn't used, GOTO (E3)
lhu r3, 0x38D0 (r1) Loads XA2.
(Mult) addiu r4, r4, 0x5556 r4 = 55555556 as a multiplier against FFFFFFFF.  In simple terms, this is 1/3.
sll r3, r3, 0x02
mult r4, r3 Term on HI is XA2 * 4 * 1/3.
sra r3, r3, 0x1F r3 = 0.
mfhi r4
nop
subu r4, r4, r3 r4 = r4 - 0.
sh r4, 0x38D0 (r1)  If ATTACK or MAGIC ATTACK UP is flagged, XA2 = XA2 * 4/3.
(E3) jr r31
nop

(M-UP) lui r4, 0x5555  r4 = 55550000.
andi r5, r3, 0x0004
beq r5, r0, (E3) If Magic Attack Up isn't used, GOTO (E3)
lhu r3, 0x38D0 (r1)  Loads XA2.
j (Mult) GOTO (Mult)
nop


addu r2, r31, r0 r2 = Return Address, because r31 will be modified below by the jal commands.
lw r3, 0x2D98 (r1) Load target address.
lhu r5, 0x38D6 (r1) r5 = Used Ability ID
lui r4, 0x8006
sll r5, r5, 0x03 r5 = r5 * 8
addu r4, r4, r5
lbu r5, -0x140A (r4) r5 = AI Byte 4
lbu r6, 0x005B (r3) r6 = Status Byte 4
andi r4, r5, 0x0002
beq r4, r0 (Prot) If AI flag Magic Defense Up is not checked, GOTO (Prot)
andi r7, r6, 0x0010
beq r7, r0 (Prot) If target does not have Shell, GOTO (Prot)
nop
jal (Mult) If target has Shell and skill is blocked by Shell, GOTO (Mult)
nop
(Prot) andi r4, r5, 0x0001
beq r4, r0 (MADEF) If AI flag Defense Up is not checked, GOTO (MADEF)
andi r7, r6, 0x0020
beq r7, r0 (MADEF) If target does not have Protect, GOTO (MADEF)
nop
jal (Mult) If target has Protect and skill is blocked by Protect, GOTO (Mult)
(MADEF) lbu r6, 0x0090 (r3) r6 = Support Byte 2
andi r4, r5, 0x0002
beq r4, r0 (DEFUP) If AI flag Magic Defense Up is not checked, GOTO (DEFUP)
andi r7, r6, 0x0002
beq r7, r0 (DEFUP) If target does not have Magic Defense Up, GOTO (DEFUP)
nop
jal (Mult) If target has Magic Defense Up and skill is blocked by Shell, GOTO (Mult)
(DEFUP) andi r5, r5, 0x0001
beq r5, r0 (E) If AI flag Defense Up is not checked, GOTO (E)
andi r6, r6, 0x0008
beq r6, r0 (E) If target does not have Defense Up, GOTO (E)
nop
jal (Mult) If target has Defense Up and skill is blocked by Protect, GOTO (Mult)
nop
(E) jr r2 Return to Main Routine
nop

(Mult) lui r4, 0xAAAA
lhu r7, 0x38D0 (r1) r7 = XA2
addiu r4, r4, 0xAAAB r4 = AAAAAAAB
multu r7, r4
mfhi r7 r7 = XA2 * 2/3
nop
jr 31 Return to Protect/Shell/MADEF/DEFUP Routine
sh r7, 0x38D0 (r1) XA2 = XA2 * 2/3


lbu r4, 0x38F7 (r1) Loads ability element
lbu r5, 0x006F (r3) Loads elements halved
lhu r6, 0x38D0 (r1) Load XA2
and r4, r4, r5 Checks ability element against elements halved
beq r4, r0, (E) If ability element isn't a halved element, GOTO (E)
lw r2, 0x2D94 (r1) Loads attacker address
srl r6, r6, 0x01 If ability element is halved, XA2 = [XA2/2]
(E) jr 31 Return to Main Routine
sh r6, 0x38D0 (r1) Stores XA2


lhu r7, 0x38CE (r1) Loads XA1
lbu r4, 0x38E5 (r1) Loads Formula
lbu r3, 0x38FA (r1) Loads Y
addiu r5, r0, 0x0008
beq r5, r4, (F8) If Formula 8 (I'll change this to some other number later), GOTO (F8).
addiu r6, r0, 0x0009
beq r6, r4, (F9) If Formula 9 (I'll change this to some other number later), GOTO (F9).
addiu r5, r0, 0x000A
beq r5, r4, (FA) If Formula A (I'll change this to some other number later), GOTO (FA).
addiu r6, r0, 0x000B
beq r6, r4, (FB) If Formula B (I'll change this to some other number later), GOTO (FB).
addu r7, r7, r3 r7 = XA1 + Y
lhu r4, 0x38D0 (r1) r4 = XA2
nop
addu r4, r7, r4
jr 31 Return to Main Routine
sb r4, 0x38D0 (r1) XA2 = XA1 + XA2 + Y
(FB) srl r7, r7, 0x01 XA1 = (XA1 + Y) / 2
j (E)
(FA) srl r6, r3, 0x03 r6 = [Y/8]
andi r3, r3, 0x0007 r3 = last 3 bits of Y
beq r3, r0, (Calc)
lbu r5, 0x0036 (r2) r5 = PA if r3 = 0
addiu r4, r0, 0x0001
beq r3, r4, (Calc)
lbu r5, 0x0037 (r2) r5 = MA if r3 = 1
addiu r4, r0, 0x0002
beq r3, r4, (Calc)
lbu r5, 0x0038 (r2) r5 = SP if r3 = 2
addiu r4, r0, 0x0003
beq r3, r4, (Calc)
lbu r5, 0x3902 (r1) r5 = WP if r3 = 3
addiu r4, r0, 0x0004
beq r3, r4, (Div4)
lbu r5, 0x0022 (r2) r5 = LVL if r3 = 4
addiu r4, r0, 0x0005
beq r3, r4, (Check)
addu r5, r2, 0x003E Readies the check where r5 = WEV1 if r3 = 5
addiu r4, r0, 0x0006
beq r3, r4, (Check)
addu r5, r2, 0x0045 Readies the check where r5 = SMEV1 if r3 = 6
addu r5, r2, 0x0041 Readies the check where r5 = SPEV1 if r3 = 7
(Check) lbu r4, 0x0000 (r5) r4 = RH equipment evasion.
bne r4, r0, (DivCheck) Checks RH equipment for evasion.
sltiu r3, r3, 0x0007 r3 = 1 if r3 < 7. r3 = 0 if r3 = 7.
lbu r4, 0x0001 (r5) r4 = LH equipment evasion.
(DivCheck) beq r3, r0 (Div3) If r3 = 0 (original r3 = 7), GOTO (Div3)
addu r5, r4, r0 r5 = r4
j (Calc)
srl r5, r5, 0x01  r5 = r5 / 2...this allows the SM-EV and W-EV used in formulas to cap at 25-30 in vanilla.
(Div3) lui r4, 0x5555
addu r4, r4, 0x5556
mult r5, r4
mfhi r5 r5 = r5 / 3...this allows the SP-EV used in formulas to cap at 25 in vanilla.
j (Calc)
nop
(Div4) j (Calc)
srl r5, r5, 0x02  r5 = r5 / 4...this allows the LVL used in formulas to cap at 25 in vanilla.
(Calc) bne r5, r0 (Nonzero) If r5 is not zero, GOTO (Nonzero)
nop
addiu r5, r0, 0x0001
(Nonzero) addu r7, r7, r5 r7 = XA1 + r5 (which we'll now call YA3)
srl r7, r7, 0x01 r7 = (XA1 + YA3) / 2
j (E)
addu r7, r7, r6 XA1 = (XA1 + YA3) / 2 + [Y/8]
(F9) andi r5, r3, 0x0008 r5 = first bit of Y
beq r5, r0 (Sorter)
srl r6, r3, 0x04 r6 = [Y/16]
lw r2, 0x2D98 (r1) Load the target's stats.
(Sorter) andi r5, r3, 0x0003 r5 = last 2 bits of Y
andi r3, r3, 0x0004 r3 = second bit of Y
beq r5, r0 (Divider1)
addiu r4, r2, 0x0028 Readies the check where r4 = curHP if r5 = 0
addiu r5, r5, 0xFFFF r5 = r5 - 1
beq r5, r0 (Divider1)
addiu r4, r2, 0x002C Readies the check where r4 = curMP if r5 = 0 (original r5 = 1).
addiu r5, r5, 0xFFFF r5 = r5 - 1
beq r5, r0 (Divider2)
lbu r4, 0x0024 (r2) r4 = Br of target or caster if r5 = 0 (original r5 = 2)
lbu r5, 0x005C (r2) r5 = Status Byte 5 on target or caster if r5 = 1 (original r5 = 3)
lbu r4, 0x0026 (r2) r4 = Fa of target or caster if r5 = 1 (original r5 = 3)
andi r5, r5 0x00C0
beq r5, r0 (Divider2) If not Innocent or Faith, GOTO (Divider2)
nop
sltiu r5, r5, 0x0080 r5 = 1 if Innocent.  r5 = 0 if Faith.
beq r5, r0 (Divider2) If Faith, GOTO (Divider2)
addiu r4, r0, 0x0064 r4 = 100
addiu r4, r0, 0x0000 ELSE, r4 = 0
(Divider2) beq r3, r0 (Div100) If r3 = 0 (normal), GOTO (Div100)
addiu r5, r0, 0x0064 r5 = 100
subu r4, r5, r4 If r3 = 1 (reversed stats), r4 = 100 - (BR or Adjusted FA)
(Div100) mult r7, r4
mflo r4 r4 = XA1 * BR/FA/UnBr/UnFa
lui r5, 0x028F
addiu r5, r5, 0x5C29
mult r4, r5
mfhi r5 r5 = XA1 * Br/Fa/UnBr/UnFa / 100
nop
j (E)
addu r7, r5, r6 XA1 = (XA1 * Br/Fa/UnBr/UnFa / 100) + [Y/16]
(Divider1) lhu r5, 0x0000 (r4) r5 = curHP or curMP
beq r3, r0 (OverMax) If r3 = 0 (normal), GOTO (OverMax)
lhu r4, 0x0002 (r4) r4 = maxHP or maxMP
subu r5, r4, r5 If r3 = 1 (reversed stats), r4 = max-cur HP/MP
(OverMax) mult r7, r5
mflo r5 r5 = XA1 * curHP/MP/max-curHP/max-curMP
nop
nop
div r5, r4
mflo r5 r5 = XA1 * curHP/MP/max-curHP/max-curMP / maxHP/MP
nop
j (E)
addu r7, r5, r6 XA1 = (XA1 * curHP/max-curHP/curMP/max-curMP / maxHP/MP) + [Y/16]
(F8) lui r4, 0xA001
lw r5, -0x6FF0 (r4) Load random word.
lui r6, 0x41C6
addiu r6, r6, 0x4E6D
multu r5, r6
mflo r5
nop
addiu r5, r5, 0x3039
sw r5, -0x6FF0 (r4) Store new Random Word.
multu r7, r5
mfhi r7 r7 = {0...XA1-1}
nop
addiu r7, r7, 0x0001 r7 = {1...XA1}
addu r7, r7, r3 XA1 = {1...XA1}+Y
(E) jr 31 Return to Main Routine
sb r7, 0x38CE (r1) Store modified XA1.


lw r2, 0x2D94 (r1) Loads the attacker's stats
lw r3, 0x2D98 (r1) Loads the defender's stats
lui r7, 0x8006
lhu r6, 0x38D6 (r1) r6 = Used Ability ID
lbu r4, 0x0009 (r2) Loads the attacker's Zodiac Sign Byte
sll r6, r6, 0x03 r6 = r6 * 8
addu r7, r7, r6
lbu r7, -0x140D (r7) r7 = AI Byte 1 for attack
addiu r6, r0, 0x000C
andi r7, r7, 0x0010 Checks if the currently unused flag under "Learn on Hit" is flagged.
bne r7, r0, (E) If flagged, GOTO (E)
lbu r5, 0x0009 (r3) Loads the defender's Zodiac Sign Byte
srl r4, r4, 0x04 Gets the attacker byte's upper 4 bits.
beq r4, r6, (E) If Attacker sign is Ophiuchus, GOTO (E)
srl r5, r5, 0x04 Gets the defender byte's upper 4 bits.
beq r5, r6, (E) If Defender sign is Ophiuchus, GOTO (E)
andi r7, r4, 0x0003 r7 = the lower 2 bits of attacker sign
andi r6, r5, 0x0003 r6 = the lower 2 bits of defender sign
beq r6, r7, (Good) If attacker and defender signs differ by 4, GOTO (Good)
lbu r1, 0x38D0 (r1) r1 = XA2
addiu r7, r0, 0x0002
addiu r6, r0, 0x0006
(MOD) div r4, r6
mfhi r4 r4 = r4 MOD r6...MOD means you take the remainder of the division.
nop
nop
div r5, r6
mfhi r5 r5 = r5 MOD r6
nop
beq r4, r5 (Diff) If attacker and defender signs form a square or its diagonal, GOTO (Diff)
addiu r7, r7, 0xFFFF r7 = r7 - 1
bne r7, r0, (MOD) If r7 isn't zero, GOTO (MOD)
addiu r6, r0, 0x0003
(E) jr 31 Return to Main Routine
lui r1, 0x8019 Resets r1 = 0x80190000.
(Diff) beq r7, r0 (Bad) If r7 = 0 (when r6 = 3), GOTO (Bad)
lbu r6, 0x0006 (r2) r6 = attacker gender
lbu r7, 0x0006 (r3) r7 = defender gender
or r4, r6, r7
andi r4, r4, 0x0020
bne r4, r0, (Bad) If either combatant is a monster, GOTO (Bad)
andi r6, r6, 0x00C0
andi r7, r7, 0x00C0
beq r6, r7 (EndBranch) If the genders are the same, GOTO (EndBranch)
srl r4, r1, 0x01 XA2 = [XA2/2]
(+) addu r4, r1, r4 XA2 = XA2 + r4
(EndBranch) lui r7, 0x8019
j (E)
sb r4, 0x38D0 (r7) Store r1 as XA2
(Good) j (+)
(Bad) srl r4, r1, 0x02 r4 = [XA2/4]
j (EndBranch)
subu r4, r1, r4 XA2 = XA2 - [XA2/4]


lhu r4, 0x38D0 (r1) Loads r4 as XA2
lhu r5, 0x38CE (r1) Loads r5 as XA1
beq r4, r0 (Set1) If XA2 is 0, GOTO (Set1)
nop
(Mult) mult r4, r5
mflo r4 XA2 = XA1 * XA2
nop
jr 31 Return to Main Routine
sh r4, 0x38D0 (r1) Stores new XA2

(Set1) j (Mult) GOTO (Mult)
addiu r4, r0, 0x0001 If XA2 = 0, XA2 is now 1.


lhu r4, 0x38D6 (r1) r4 = Used Ability ID
lui r5, 0x8006
sll r4, r4, 0x03 r4 = r4 * 8
addu r5, r5, r4
lbu r6, -0x1409 (r5) r6 = AI Byte 5
lbu r7, -0x140A (r5) r7 = AI Byte 4
lbu r5, -0x140B (r5) r5 = AI Byte 3
andi r6, r6, 0x0004
bne r6, r0, (Un) If 3rd blank AI flag under the Third Unknown under Learn on Hit is flagged, GOTO (Un)
(Check) andi r7, r7, 0x0080
bne r7, r0, (Br) If the blank AI flag above Direct Attack is flagged, GOTO (Br)
andi r5, r5, 0x0004
bne r5, r0, (Fa) If the Unknown AI flag under Random Hits is flagged, GOTO (Fa)
nop
jr 31 ELSE, GOTO Main Routine
nop

(Un) addiu r6, r0, 0x0064
j (Check) r6 = 100, r4 = Yes, GOTO (Check)
addiu r4, r0, 0x0001

(Br) bne r4, r0, (UnBr) If UnBrave/UnFaith is flagged, GOTO (UnBr)
lbu r7, 0x0024 (r2) r7 = Attacker Brave
j (Mult) ELSE, GOTO (Mult)
(UnBr) lbu r4, 0x0024 (r3) r4 = Defender Brave
subu r7, r6, r7 r7 = 100 - Attacker Brave if UnBrave/UnFaith is flagged
subu r4, r6, r4 r4 = 100 - Defender Brave if UnBrave/UnFaith is flagged
(Mult) lhu r6, 0x38D0 (r1) r6 = XA2
nop
mult r6, r7
mflo r6 r6 = XA2 * (CaBr/Fa or 100 - CaBr/Fa)
nop
nop
mult r6, r4
mflo r6 r6 = XA2 * (CaBr/Fa or 100 - CaBr/Fa) * (TaBr/Fa or 100 - TaBr/Fa)
lui r4, 0x0006
addu r4, r4, 0x8DB8
mult r6, r4
mfhi r6 XA2 = [XA2 * (CaBr/Fa or 100 - CaBr/Fa) * (TaBr/Fa or 100 - TaBr/Fa) / 10000]
nop
jr 31 GOTO Main Routine
sh r6, 0x38D0 (r1) Stores new XA2
(Fa) lbu r5, 0x005C (r2) r5 = Attacker Status Byte 5
lbu r7, 0x005C (r3) r7 = Defender Status Byte 5
andi r5, r5, 0x00C0
beq r5, r0, (Load-AFa) If attacker does not have innocent or faith, GOTO (Load-AFa)
andi r7, r7, 0x00C0
sltiu r5, r5, 0x0080
beq r5, r0, (A-Inn) If attacker has Innocent, GOTO (A-Inn)
nop
j (CheckTar) If attacker has Faith, r5 = 100 and GOTO (CheckTar)
addiu r5, r0, 0x0064
(A-Inn) j (CheckTar) If attacker has Innocent, r5 = 0 and GOTO (CheckTar)
addiu r5, r0, 0x0000
(Load-AFa) lbu r5, 0x0026 (r2) If attacker has neither, r5 = Attacker Faith
(CheckTar) beq r7, r0, (Load-DFa) If defender does not have innocent or faith, GOTO (Load-DFa)
nop
sltiu r7, r7, 0x0080
beq r7, r0, (D-Inn) If defender has Innocent, GOTO (D-Inn)
nop
j (CheckUn) If defender has Faith, r7 = 100 and GOTO (CheckUn)
addiu r7, r0, 0x0064
(D-Inn) j (CheckUn) If defender has Innocent, r7 = 0 and GOTO (CheckUn)
addiu r7, r0, 0x0000
(Load-DFa) lbu r7, 0x0026 (r3) If defender has neither, r7 = Defender Faith
(CheckUn) beq r4, r0, (Normal) If UnBrave/UnFaith isn't flagged, GOTO (Normal)
nop
subu r5, r6, r5 r5 = 100 - Attacker Faith if UnBrave/UnFaith is flagged
subu r7, r6, r7 r7 = 100 - Defender Faith if UnBrave/UnFaith is flagged
(Normal) addu r4, r7, r0 r4 = r7 = Defender Faith
j (Mult) GOTO (Mult)
addu r7, r5, r0 r7 = r5 = Attacker Faith


lhu r4, 0x38D6 (r1) r4 = Used Ability ID
lui r5, 0x8006
sll r4, r4, 0x03 r4 = r4 * 8
addu r4, r5, r4
lbu r9, -0x1409 (r4) r9 = AI Byte 5
addu r8, r31, r0 Sends r31 into r8 because r31 will be modified by jal commands below.
andi r4, r9, 0x0010
beq r4, r0, (KB Check) If the first blank flag under the Third Unknown in the "Learn on Hit" box is unflagged, GOTO (KB Check)
sb r0, 0x38CC (r1) Reset Higher Tile Flag
jal (RNG) ELSE, GOTO (RNG)
addiu r7, r0, 0x0064
addiu r4, r0, 0x0004
sub r4, r4, r7 r4 = 4 - RN from 0 to 99
bltz r4 (KB check) If RN > 4, GOTO (KB check)
addiu r5, r0, 0x0001
sb r5, 0x018D (r2) Flag attack as critical.
jal (RNG) GOTO (RNG)
lhu r7, 0x38D0 (r1) r7 = Base Damage
lhu r6, 0x38D0 (r1) r6 = Base Damage
addiu r7, r7, 0x0001 r7 = {1...Base Damage}
addu r6, r6, r7 New Damage = Base Damage + {1...Base Damage}
sh r6, 0x38D0 (r1) Store New Damage
(KB check) andi r4, r9, 0x0008
beq r4, r0, (E) If the second blank flag under the Third Unknown in the "Learn on Hit" box is unflagged, GOTO (E)
sb r0, 0x38EE (r1) Reset Knockback Height
jal (RNG) GOTO (RNG)
addiu r7, r0, 0x0064
addiu r4, r0, 0x0031
sub r4, r4, r7 r4 = 49 - RN from 0 to 99
bltz r4 (E) If RN > 49, GOTO (E)
(KB) lbu r5, 0x0182 (r3)
beq r2, r3, (E) If you are targeting yourself with knockback, GOTO (E)
lbu r4, 0x0005 (r3)
lbu r6, 0x0047 (r2) r6 = Attacker X Coordinate
andi r4, r4, 0x0004
bne r4, r0, (E) If target is immortal, GOTO (E)
lbu r7, 0x0047 (r3) r7 = Defender X Coordinate
bne r5, r0, (E) If target is riding a chocobo or in 2h+ water, GOTO (E)
lui r4, 0x800E
lbu r5, 0x4E9C (r4) r5 = Map Maximum X
beq r7, r0 (CheckEdge1) If Defender X Coordinate = 0, GOTO (CheckEdge1)
sb r0, 0x38EC (r1) Reset Knockback Flag
beq r7, r5 (CheckEdge2) If Defender X Coordinate = Map Maximum X, GOTO (CheckEdge2)
nop
sub r5, r6, r7 XA1 Byte 1 = Attacker X - Defender X
j (YChecks) Store Byte 1 of XA1 and GOTO (YChecks)
sb r5, 0x38CE (r1)
(CheckEdge1) beq r6, r0 (YChecks) If Defender and Attacker X Coordinate = 0, GOTO (YChecks)
sb r0, 0x38CE (r1) Store Byte 1 of XA1 as 0.
(E) jr r8 ELSE, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(CheckEdge2) beq r6, r5 (YChecks) If Defender and Attacker X Coordinate = Maximum, GOTO (YChecks)
sb r0, 0x38CE (r1) Store Byte 1 of XA1 as 0.
jr r8 If Defender X Coordinate = Maximum, but Attacker X coordinate is not maximal, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(YChecks) lbu r6, 0x0048 (r2) r6 = Attacker Y Coordinate
lbu r7, 0x0048 (r3) r7 = Defender Y Coordinate
lbu r5, 0x4EA0 (r4) r5 = Map Maximum Y
beq r7, r0, (CheckEdge3) If Defender Y Coordinate = 0, GOTO (CheckEdge3)
nop
beq r7, r5, (CheckEdge4) If Defender Y Coordinate = Maximum Y, GOTO (CheckEdge4)
nop
sub r5, r6, r7 XA1 Byte 1 = Attacker Y - Defender Y
j (NewXY) Store Byte 2 of XA1 and GOTO (NewXY)
sb r5, 0x38CF (r1)
(CheckEdge3) beq r6, r0 (NewXY) If Defender and Attacker Y Coordinate = 0, GOTO (NewXY)
sb r0, 0x38CF (r1) Store Byte 2 of XA1 as 0.
jr r8 If Defender Y Coordinate = 0, while Attacker Y Coordinate isn't, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(CheckEdge4) beq r6, r5 (NewXY) If Defender and Attacker Y Coordinate = Maximum, GOTO (NewXY)
sb r0, 0x38CF (r1) Store Byte 2 of XA1 as 0.
jr r8 If Defender Y Coordinate = Maximum, but Attacker Y coordinate is not maximal, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(NewXY) lb r4, 0x38CE (r1) r4 = Attacker X - Defender X
lb r5, 0x38CF (r1) r5 = Attacker Y - Defender Y
bgez r4 (+X) If r4 is greater than or equal to 0, GOTO (+X)
addiu r7, r0, 0x0100
addiu r6, r0, 0x0001 If r4 < 0, r6 = 1
j (YDiff) Make r4 positive and GOTO (YDiff)
subu r4, r7, r4 If r4 < 0, r4 = 0x100 - r4 (as unsigned byte), essentially the equivalent of multiplying a signed byte by -1.
(+X) bne r4, r0 (YDiff) If r4 > 0, r6 = 2 and GOTO (YDiff)
addiu r6, r0, 0x0002
addiu r6, r0, 0x0000 ELSE, r6 = 0
(YDiff) bgez r5 (+Y) If r5 is greater than or equal to 0, GOTO (+Y)
addiu r7, r0, 0x0100
ori r6, r6, 0x0004 If r5 < 0, r6 = r6 OR 0x4 = r6 + 4 (because r6 = 0, 1, or 2)
j (CoordChange) Make r5 positive and GOTO (CoordChange)
subu r5, r7, r5 If r5 < 0, r5 = 0x100 - r5 (as unsigned byte), essentially the equivalent of multiplying a signed byte by -1.
(+Y) beq r5, r0 (CoordChange) If r5 = 0, r6 = r6 and GOTO (CoordChange)
ori r6, r6, 0x0000
ori r6, r6, 0x0008 ELSE, r6 = r6 OR 0x8 = r6 + 8 (because r6 = 0, 1, or 2)
(CoordChange) jal (RNG) r7 = r4 + r5 = Distance Attacker is from Defender and GOTO (RNG)
addu r7, r4, r5
sub r7, r4, r7 r7 = |Attacker X - Defender X| - {0...|Attacker X - Defender X| + |Attacker Y - Defender Y| - 1}
bgtz r7 (ChangeX) If r7 > 0, GOTO (Change X)
lbu r5, 0x0048 (r3) r5 = Defender Y
andi r6, r6, 0x0008
beq r6, r0, (+1Y) If Attacker Y < Defender Y, GOTO (+1Y)
nop
j (NewCoord) If Attacker Y > Defender Y, Defender Y = Defender Y - 1 and GOTO (NewCoord)
addiu r5, r5, 0xFFFF
(+1Y) j (NewCoord) If Attacker Y < Defender Y, Defender Y = Defender Y + 1 and GOTO (NewCoord)
addiu r5, r5, 0x0001
(ChangeX) lbu r4, 0x0047 (r3) r4 = Defender X
andi r6, r6, 0x0002
beq r6, r0, (+1X) If Attacker X < Defender X, GOTO (+1X)
nop
j (NewCoord) If Attacker X > Defender X, Defender X = Defender X - 1 and GOTO (NewCoord)
addiu r4, r4, -0xFFFF
(+1X) addiu r4, r4, 0x0001 If Attacker X < Defender X, Defender X = Defender X + 1
(NewCoord) lui r6, 0x800E
lbu r6, 0x4E9C (r6) r6 = Map Maximum X
sb r4, 0x38CE (r1) Store Defender X as XA1 Byte 1
sb r5, 0x38CF (r1) Store Defender Y as XA1 Byte 2
lhu r5, 0x0048 (r3) r5 = Pre-Attack Defender Y + Unit Facing
lbu r4, 0x0047 (r3) r4 = Pre-Attack Defender X
andi r7, r5, 0x8000
jal (TileOffset) GOTO (TileOffset)
andi r5, r5, 0x00FF r5 = Pre-Attack Defender Y
bne r7, r0, (HigherTile) If the defender stood on a higher tile, GOTO (HigherTile)
nop
j (NewHeight) ELSE, r7 = Height of Lower Tile and GOTO (NewHeight)
lbu r7, -0x0732 (r4)
(HigherTile) lbu r7, 0x00CE (r4) r7 = Height of Higher Tile
(NewHeight) lbu r5, 0x38CF (r1) r5 = Defender Y (current)
jal (TileOffset) GOTO (TileOffset)
lbu r4, 0x38CE (r1) r4 = Defender X (current)
lbu r9, 0x005A (r3) r9 = Current Status Byte 3
lbu r5, 0x0093 (r3) r5 = Movement Status Byte 1
andi r9, r9. 0x0040
bne r9, r0, (SCheckFail) If target has float status, GOTO (SCheckFail)
lbu r2, 0x0095 (r3) r2 = Movement Status Byte 3
andi r5, r5, 0x0002
bne r5, r0, (SCheckFail) If target has ignore height, GOTO (SCheckFail)
andi r2, r2, 0x000C
beq r2, r0, (SCheckGood) If target doesn't have float/fly, GOTO (SCheckGood)
addu r9, r0, r0 If target doesn't have float/fly/ignore height, r9 = 0
(SCheckFail) addiu r9, r0, 0x0001 ELSE, r9 = 1
(SCheckGood) lbu r5, -0x0732 (r4) r5 = Height of Current Lower Tile
lbu r2, -0x072E (r4) r2 = Byte 7 of Current Lower Tile Data
sltu r4, r7, r5
bne r4, r0 (E) IF r7 < r5, GOTO (E)
andi r2, r2, 0x0001
bne r2, r0, (HigherTile) ELSE IF lower tile is impassable, GOTO (HigherTile)
sub r4, r7, r5 r4 = r7 - r5
bne, r9, r0, (NoFallDamageL) ELSE If target has float/fly/ignore height, GOTO (NoFallDamageL)
nop
sb r4, 0x38EE (r1) ELSE, Store r4 as knockback height
(NoFallDamageL) ori r4, r0, 0x0001 r4 = 1
sb r4, 0x38EC (r1) Flag Knockback
(HigherTile) lbu r5, 0x38CF (r1) r5 = Defender Y (current)
jal (TileOffset) GOTO (TileOffset)
lbu r4, 0x38CE (r1) r4 = Defender X (current)
lbu r5, 0x00CE (r4) r5 = Height of Current Higher Tile
lbu r2, 0x00D2 (r4) r2 = Byte 7 of Current Higher Tile Data
beq r5, r0 (E2) IF r5 = 0, GOTO (E2)
sltu r4, r7, r5
bne r4, r0 (E2) ELSE IF r7 < r5, GOTO (E2)
andi r2, r2, 0x0001
bne r2, r0, (E) ELSE IF higher tile is impassable, GOTO (E)
sub r4, r7, r5 r4 = r7 - r5
bne, r9, r0, (NoFallDamageH) ELSE If target has float/fly/ignore height, GOTO (NoFallDamageH)
addu r6, r0, r0 r6 = 0
sb r4, 0x38EE (r1) ELSE, store r4 as Knockback Height.
(NoFallDamageH) ori r4, r0, 0x0001 r4 = 1
sb r4, 0x38EC (r1) Flag Knockback
(E2) lbu r4, 0x38EC (r1) r4 = Knockback flag.
nop
beq r4, r0, (E) If Knockback is not flagged, GOTO (E)
nop
bne r6, r0, (LowerFlag) ELSE If r6 = Map Maximum X (and not 0), GOTO (LowerFlag)
addiu r7, r0, 0x0001 r7 = 1
sb r7, 0x38CC (r1) ELSE, flag Higher Tile
(LowerFlag) lbu r5, 0x38C1 (r1) r5 = The Xth unit on map (target)
lbu r4, 0x38CE (r1) r4 = Target X (current)
sb r5, 0x38EF (r1) Store r5.
lbu r5, 0x38CF (r1) r5 = Target Y (current)
sb r4, 0x38CA (r1) Store r4.
lbu r4, 0x019D (r3) r4 = Attack Elemental Modifier Flags vs. Target
sb r5, 0x38CB (r1) Store r5.
ori r4, r4, 0x0040 r4 = r4 OR 0x40
jr r8 GOTO Main Routine
sb r4, 0x019D (r3) Store r4, which now has a knockback on attack flag

(TileOffset) mult r5, r6
mflo r5 r5 = Map Maximum X * Defender Y (pre-attack or current)
nop
addiu r5, r5, r4 r5 = Map Maximum X * Defender Y + Defender X (pre-attack or current)
sll r5, r5, 0x03 r5 = r5 * 8
lui r4, 0x8019
jr 31  Return to Critical/Knockback Routine
addu r4, r4, r5

(RNG) lui r4, 0xA001
lw r5, -0x6FF0 (r4) Load random word.
lui r6, 0x41C6
addiu r6, r6, 0x4E6D
multu r5, r6
mflo r5
nop
addiu r5, r5, 0x3039
sw r5, -0x6FF0 (r4) Store new Random Word.
multu r7, r5
mfhi r7 r7 = {0...value(r7)-1}
jr 31 Return to Critical/Knockback Routine
nop

BATTLE.BIN
0x123EB0
00000000

BATTLE.BIN
0x11408C
00000000
00000000

BATTLE.BIN
0x1140FC
00000000
00000000

BATTLE.BIN
0x115FD8
EC

BATTLE.BIN
0x115FE0
01

BATTLE.BIN
0x124420
EC

BATTLE.BIN
0x124428
01

BATTLE.BIN
0x116250
EC

BATTLE.BIN
0x1162AC
EC

BATTLE.BIN
0x1162B4
01

BATTLE.BIN
0x1162C4
EC

BATTLE.BIN
0x123E50
EC

BATTLE.BIN
0x119EB8
lui r18, 0x8019 or 1980123C
0x119EC4
lbu r18, 0x38CC (r18) or CC385292


lw r2, 0x2D94 (r1) r2 = Attacker Offset
lhu r4, 0x38D6 (r1) r4 = Ability ID
lbu r7, 0x38F7 (r1) r7 = Ability Elemental
lui r6, 0x8006
sll r4, r4, 0x03 r4 = Ability ID * 8
addu r6, r6, r4 r6 = r6 + Ability ID * 8
lbu r4, 0x005A (r3) r4 = Target Status Bytes 3
lbu r8, 0x006E (r3) r8 = Target Elemental Nullification Byte
andi r4, r4, 0x0040
beq r4, r0, (NullCompare) If target is does not have float, GOTO (NullCompare)
nop
ori r8, r8, 0x0008 ELSE, Target is now nulls earth.
(NullCompare) andi r8, r8, r7
bne r8, r0, (ENull) If element is Nulled, GOTO (ENull)
lbu r6, -0x140B (r6) r6 = AI Flags Byte 3
lhu r4, 0x0058 (r3) ELSE, r4 = Target Status Bytes 1 and 2
lbu r8, 0x0070 (r3) r8 = Target Elemental Weakness Byte
andi r4, r4, 0x0410
beq r4, r0, (CheckOil) If target is not undead or vampire (has blood suck), GOTO (CheckOil)
addiu r9, r0, 0x0001
ori r8, r8, 0x0002 ELSE, Target is now weak against holy
(CheckOil) lbu r4, 0x005A (r3) r4 = Target Status Bytes 3
sb r9, 0x018C (r3) Flag attack as hit.
andi r4, r4, 0x0080
beq r4, r0 (NoStatusWeak) If target does not have oil, GOTO (NoStatusWeak)
nop
ori r8, r8, 0x0080 ELSE, Target is now weak against fire
(NoStatusWeak) lhu r4, 0x38D0 (r1) r4 = Base Damage
andi r6, r6, 0x0020
beq r6, r0, (EWeak) If AI Undead Reverse Flag is not flagged, r9 = 1 and GOTO (EWeak)
addiu r9, r0, 0x0001
andi r9, r5, 0x0080 ELSE r9 = 0, if the first blank flag under Player Abilities isn't flagged (healing), or 80 if it is (drain)
(EWeak) lbu r5, 0x38D6 (r1) r5 = Ability ID
lui r6, 0x8006
sll r5, r5, 0x03 r5 = Ability ID * 8
addu r6, r6, r5 r6 = r6 + Ability ID * 8
lbu r5, -0x140C (r6) r5 = AI Flags Byte 2
and r8, r8, r7
beq r8, r0, (SetupDMG) If the target is not weak against the spell's element, GOTO (SetupDMG)
addiu r9, r9, 0xFFFF
sll r4, r4, 0x01 ELSE, r4 = r4 * 2
(SetupDMG) andi r5, r5, 0x00A0
beq r5, r0, (EAbsorb) If the AI HP and MP flags are unflagged, GOTO (EAbsorb)
addu r6, r4, r0 r6 = r4
andi r6, r5, 0x0080
beq r6, r0 (-MP) ELSE, r6 = 0 or 0x80 and if AI flag HP is not flagged (r6 = 0), GOTO (-MP)
nop
andi r6, r5, 0x0040
beq r6, r0 (-HP) ELSE, If AI flag MP is not flagged, GOTO (-HP)
sh r4, 0x0190 (r3) Stores HP Damage as 2x Base Damage
srl r4, r4, 0x01
(-MP) sh r4, 0x0194 (r3) Stores r4 as MP Damage
(-HP) lbu r4, 0x019D (r3) r4 = Elemental Resistance Byte
beq r8, r0, (EAbsorb) If the target is not weak against the spell's element, GOTO (EAbsorb)
lbu r6, 0x01B1 (r3) r6 = Attack Type Byte
ori r4, r4, 0x0008 ELSE, r4 includes damage is elemental weakness
ori r6, r6, 0x00A0 r6 includes HP/MP Damage
sb r4, 0x019D (r3) Store r4 as elemental resistance byte
bgtz r9, (DrainFlags) If attack is supposed to drain, GOTO (DrainFlags)
sb r6, 0x01B1 (r3) Store r6 as attack type byte
j (EAbsorb) ELSE, GOTO (EAbsorb)
nop
(DrainFlags) lhu r4, 0x0194 (r3) r4 = MP Damage Dealt
lhu r5, 0x002C (r3) r5 = Target MP
lhu r6, 0x002C (r3) r6 = Target MP
sub r5, r5, r4
bltz r5, (ExcessMPDMG) If target MP < MP Damage Dealt, GOTO (ExcessMPDMG)
nop
j (HPDrain) GOTO (HPDrain)
sh r4, 0x0196 (r2) ELSE, Set MP restored to MP Damage Dealt.
(ExcessMPDMG) sh r6, 0x0196 (r2) If target MP < MP Damage Dealt, set MP restored as target MP.
(HPDrain) lhu r4, 0x0190 (r3) r4 = HP Damage Dealt
lhu r5, 0x0028 (r3) r5 = Target HP
lhu r6, 0x0028 (r3) r6 = Target HP
sub r5, r5, r4
bltz r5, (ExcessHPDMG) If target HP < HP Damage Dealt, GOTO (ExcessMPDMG)
nop
j (SelfFlags) GOTO (SelfFlags)
sh r4, 0x0192 (r2) ELSE, Set HP restored to HP Damage Dealt.
(ExcessHPDMG) sh r6, 0x0192 (r2) If target HP < HP Damage Dealt, set HP restored as target HP.
(SelfFlags) ori r4, r0, 0x0001
lbu r5, 0x01B1 (r2) r5 = Attack Type Byte of caster.
sb r4, 0x018C (r2) Drain will affect caster.
ori r5, r5, 0x0050 r5 includes HP/MP Healing
sb r5, 0x01B1 (r2) r5 is stored as the caster attack type byte.
ori r6, r0, 0x0100 r6 = 0x100
beq r9, r6, (E) If r9 = 0x100 (only possible if drain attack has no elemental modifiers), GOTO (E)
(EAbsorb) lbu r4, 0x0058 (r3) r4 = Target Status Bytes 1
lbu r8, 0x006D (r3) r8 = Target Elemental Absorption Byte
andi r4, r4, 0x0010
beq r4, r0, (NoUndead) If the target isn't undead, GOTO (NoUndead)
nop
ori r8, r8, 0x0001 ELSE, the target absorbs dark attacks.
(NoUndead) and r8, r8, r7
beq r8, r0, (Normal) If the target does not absorb the spell's element, GOTO (Normal)
lhu r4, 0x0190 (r3) r4 = HP Damage
bne r5, r0 (NotStatus) If the attack deals damage, drain, or healing, GOTO (NotStatus)
sll r6, r6, 0x01 Double hit chance of non-damage attack if target absorbs element.
addiu r9, r0, 0x0002
sb r9, 0x018C (r3) ELSE, Store 0x2 into target hit byte.
j (E) GOTO (E)
sh r6, 0x01B6 (r3) r6 = Hit Chance
(NotStatus) lhu r5, 0x0194 (r3) r5 = MP Damage
(HealSetup) sh r0, 0x0190 (r3) HP Damage is 0
bgtz r9, (DrainReversalFlags) If attack is supposed to drain, GOTO (DrainReversalFlags)
sh r0, 0x0194 (r3) MP Damage is 0
sh r4, 0x0192 (r3) r4 = HP Healing
sh r5, 0x0196 (r3) r5 = MP Healing
(EAbsorbFlags) lbu r5, 0x019D (r3) r5 = Elemental Resistance Byte
lbu r6, 0x01B1 (r3) r6 = Attack Type Byte
ori r5, r5, 0x0004 r5 includes healing is elemental absorption
andi r6, r6, 0x005F r6 no longer includes HP/MP damage.
ori r6, r6, 0x0050 r6 includes HP/MP Healing
sb r5, 0x019D (r3) Store r5 as elemental resistance byte
jr 31 Return to Main Formula Routine
sb r6, 0x01B1 (r3) Store r6 as attack type byte
(DrainReversalFlags) sh r4, 0x0190 (r2) r4 = HP Damage on Caster
lbu r6, 0x002C (r2) r6 = Caster MP
sh r5, 0x0194 (r2) r5 = MP Damage on Caster
sub r6, r6, r5
bltz r6, (ExcessMPHeal) If caster MP < MP Damage Dealt, GOTO (ExcessMPHeal)
sh r0, 0x0196 (r2) MP Healing on Caster is 0
j (HPReversal) GOTO (HPReversal)
sh r5, 0x0196 (r3) ELSE, Target MP Healing = Caster MP Damage
(ExcessMPHeal) add r6, r6, r5
sh r6, 0x0196 (r3) If Caster MP < MP Damage Dealt, Target MP Healing = Caster MP
(HPReversal) lbu r6, 0x0028 (r2) r6 = Caster HP
nop
sub r6, r6, r4
bltz r6, (ExcessHPHeal) If caster HP < HP Damage Dealt, GOTO (ExcessHPHeal)
sh r0, 0x0192 (r2) HP Healing on Caster is 0
j (SelfReverseFlags) GOTO (SelfReverseFlags)
sh r4, 0x0192 (r3) ELSE, Target HP Healing = Caster HP Damage
(ExcessMPHeal) add r6, r6, r4
sh r6, 0x0192 (r3) If Caster HP < HP Damage Dealt, Target MP Healing = Caster MP
(SelfReverseFlags) lbu r6, 0x01B1 (r2) r6 = Caster Attack Type Byte
ori r5, r0, 0x0001
andi r6, r6, 0x00AF r6 no longer includes HP/MP healing.
ori r6, r6, 0x00A0 r6 includes HP/MP Damage
sb r5, 0x018C (r2) Caster is affected by drain reversal.
j (EAbsorbFlags) GOTO (EAbsorbFlags)
sb r6, 0x01B1 (r2) Store r6 as attack type byte
(Normal) bne r5, r0 (NotStatus2) If the attack deals damage, drain, or healing, GOTO (NotStatus2)
nop
addiu r9, r0, 0x0002
sb r9, 0x018C (r3) ELSE, Store 0x2 into target hit byte.
j (E) GOTO (E)
sh r6, 0x01B6 (r3) r6 = Hit Chance
(NotStatus2) bltz r9, (Healing) If r9 < 0 (if the AI flags are set as healing), GOTO (Healing)
lhu r5, 0x0194 (r3) r5 = MP Damage
lbu r6, 0x01B1 (r3) ELSE, r6 = Attack Type Byte
nop
ori r6, r6, 0x00A0 r6 includes HP/MP Damage
bgtz r9, (Drain) If r9 > 0 (if the AI flags are set as drain), GOTO (Drain)
sb r6, 0x01B1 (r3) Store r6 as Attack Type Byte
jr 31 ELSE (if attack is not drain/healing), return to Main Formula Routine
nop
(Healing) addu, r7, r31, r0 r7 = Return address
jal (HealSetup) Save offset into r31 and GOTO (HealSetup)
nop
andi r5, r5, 0x00FB r5 no longer includes healing as elemental absorption
jr r7 Return to Main Formula Routine
sb r5, 0x019D (r3) Store r5 as elemental resistance byte
(Drain) j (DrainFlags) GOTO (DrainFlags)
addiu r9, r0, 0x0100 r9 = 0x100 (for comparison purposes above)
(E) jr r31 Return to Main Formula Routine
nop

(ENull) sb r0, 0x018C (r3) Attack will miss.
sh r0, 0x0190 (r3) HP Damage is 0.
sh r0, 0x0192 (r3) MP Damage is 0.
sh r0, 0x0194 (r3) HP Healing is 0.
sh r0, 0x0196 (r3) MP Healing is 0.
sh r0, 0x019C (r3) Set the elemental resistance byte to 0
sb r0, 0x01B1 (r3) Set the attack type byte to 0
sh r0, 0x01B6 (r3) Set the accuracy to 0
ori r4, r0, 0x0005
sb r4, 0x018E (r3) Display on missed attack is "Nullified"
lbu r4, 0x38ED (r1) r4 = Target Terrain Byte
sh r0, 0x38C8 (r1) Spell/Status Flags = 0
sh r0, 0x38C6 (r1) Status/Spell ID = 0
andi r4, r4, 0x0080
beq r4, r0 (E2) If target isn't above the terrain because of fly/float/chicken/frog, GOTO (E2)
nop
sb r0, 0x38ED (r1) ELSE, r4 = 0
(E2) jr r31 Return to Main Formula Routine
nop
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on April 22, 2011, 04:01:03 am
Do I need to re-write or reorganize any of the summaries at all?

It doesn't look like anything was added besides the unfinished Steal/Break code and Element modification, which I'll probably sum up both at once when the Steal/Break is done, and hell if I can tell if anything integral to the way I simplified things down was changed in the code without comparing it all side by side.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on April 25, 2011, 05:34:07 pm
No, you don't have to rewrite anything, Raven.

It should be noted that the following routine is not vanilla's because I want to better consolidate ability space.  Instead:
1) If you steal a slot that has nothing equipped, you steal gil instead.
2) If you break helm, but no helmet's equipped, you lower MA by 1.
3) If you break shield, but no shield's equipped, you lower PA by 1.
4) If you break armor, but no armor's equipped, you lower CT by 20.
5) Maintenance blocks breaks, steals, stat downs from break, and steal gil.  It does not set accuracy to 0 as it did in vanilla.
6) Divine Knight can deal damage to all units, unless the unit has maintenance.
7) All attacks that don't use Ability X for other purposes (like % hit or % HP damage or determining which stat is reduced/by how much) can now have break as an added effect.  Essentially, you check the unequip AI flag and then specify:
0x0? (No steal or break...note, if you specify this on the formula XA1+XA2+Y, then that Hit% is then applied towards inflicting status/inflicting proc...also, if you want to use that formula for break/steal, DO NOT use the default FFTP HP flag on steal/break armor/helm because the hit chance will then be assumed to be damage and you will have 100% break/steal if the attack hits.)
0x1?/0x2?/0x3?/0x4?/0x5? (Break Helm/Armor/Accessory/Weapon/Shield)
0x6?/0x7?/0x8?/0x9?/0xA? (Steal Helm/Armor/Accessory/Weapon/Shield)
0xB? (Steal Gil, i.e. Mug Skill)
Anything Else (Steal EXP)
8) Steal Gil is now SP * (20 + LVL) so it's better early, but you can now only steal from humans and only once per each enemy human.
9) Steal EXP is now min{20, target EXP}.
10) All of the above are hackable.

I'm posting my break routine here because I just hit the character limit on my previous post; I couldn't fit in the break routine.


lbu r4, 0x0091 (r3) r4 = Target Support Byte 3
lbu r5, 0x38D6 (r1) r5 = Used Ability ID
andi r4, r4, 0x0004
bne r4, r0, (SetZero) If target has Maintenance, GOTO (SetZero)
sll r5, r5, 0x03 r5 = r5 * 8
lui r4, 0x8006
addu r4, r4, r5
lbu r5, -0x140C (r4) ELSE, r5 = AI Byte 2
addu r9, r31, r0 r9 = r31 since it will be modified later in this routine.
andi r5, r5, 0x0004
beq r5, r0, (E) If Unequip is not flagged, GOTO (E)
lbu r8, 0x018C (r3) r8 = Target Hit Byte
ori r5, r0, 0x0002 ELSE, r5 = 2
bne r8, r5, (MissCheck) If target hit byte is not 2, GOTO (MissCheck)
nop
jal (RNG) If target hit byte is 2, GOTO (RNG)
ori r7, r0, 0x0064
lbu r4, 0x01B6 (r3) r4 = Hit Chance
addiu r7, r7, 0x0001
sub r4, r4, r7 r4 = Hit Chance - {1...100}
bltz r4, (E) If Hit Chance < {1...100}, GOTO (E)
sb r0, 0x018C (r3) Target Hit Byte is 0.
addiu r4, r0, 0x0001
sb r4, 0x018C (r3) ELSE, Target Hit Byte is 1.
(MissCheck) beq r8, r0, (E) If target hit byte is 0, GOTO (E)
lbu r4, 0x38F9 (r1) r4 = Ability X
nop
srl r4, r4, 0x04 ELSE, r4 = r4 / 0x10
beq r4, r0, (E) If the upper 4 bits of Ability X is 0, GOTO (E)
sltiu r5, r4, 0x0006
bne r5, r0, (Break) If 0 < r4 < 6, GOTO (Break)
sltiu r6, r4, 0x000B
bne r6, r0, (Steal) If 5 < r4 < 11, GOTO (Steal)
addiu r5, r0, 0x000B
beq r5, r4 (StealGil) If r4 = 11, GOTO (StealGil)
nop
j (StealEXP) ELSE, GOTO (StealEXP)
nop
(E) jr r9 Return to Main Formula Routine
nop

(Break) jal (SlotDeterm) GOTO (SlotDeterm)
nop
ori r5, r0, 0x00FF
beq r7, r5 (StatDown) If (human) equips "Nothing" in the selected slot, GOTO (StatDown)
lui r1, 0x8019 r1 is changed back to 0x80190000
beq r7, r0, (StatDown) ELSE, if (monster) equips "None", GOTO (StatDown)
nop
lbu r4, 0x019C (r3) r4 = Special Effect Byte
sb r7, 0x018F (r3) ELSE, set equipment lost byte to the hex value (r7) of equipment destroyed
ori r4, r4, 0x0004
jr r9 Return to Main Formula Routine
sb r4, 0x019C (r3) Set special effect byte to include break.

(Steal) jal (SlotDeterm) GOTO (SlotDeterm)
addiu r4, r4, 0xFFFB r4 = r4 - 5 (since all the steals are 5 + break)
ori r5, r0, 0x00FF
beq r7, r5 (StealGil) If (human) equips "Nothing" in the selected slot, GOTO (StealGil)
lui r1, 0x8019 r1 is changed back to 0x80190000
beq r7, r0, (StealGil) ELSE, if (monster) equips "None", GOTO (StealGil)
nop
lbu r4, 0x019C (r3) r4 = Special Effect Byte
sb r7, 0x018F (r3) ELSE, set equipment lost byte to the hex value (r7) of equipment destroyed
ori r4, r0, 0x0010
jr r9 Return to Main Formula Routine
sb r4, 0x019C (r3) Set special effect byte to include steal.

(SlotDeterm) addiu r5, r0, 0x0001
addiu r6, r3, 0x001A
ori r8, r0, 0x0004
ori r1, r0, 0x0100
(LoopStart) bne r4, r5, (LoopCheck) If r4 isn't r5, GOTO (LoopCheck)
srl r1, r1, 0x01
sb r1, 0x01A5 (r3) ELSE, Defender Lost Equipment Byte is the corresponding slot.
jr 31 Return to Break or Steal and r7 = target head/body/accessory.
lbu r7, 0x0000 (r6)
(LoopCheck)  addiu r5, r5, 0x0001
bne r8, r5, (LoopStart) If r5 < 4, GOTO (LoopStart)
addiu r6, r6, 0x0001
beq r4, r5 (CheckHands) If r4 = 4, GOTO (CheckHands)
srl r1, r1, 0x01 r1 = 0x10
addiu r6, r6, 0x0001 If r4 = 5, r6 is target shield byte.
srl r1, r1, 0x01 r1 = 0x8
(CheckHands) lbu r7, 0x0000 (r6) r7 = Weapon/Shield
ori r5, r0, 0x00FF
beq r7, r5 (LoopCheck2) If (human) equips "Nothing", GOTO (LoopCheck2)
addiu r8, r8, 0xFFFE r8 = r8 - 2 (r8 starts at 4, due to the previous loop)
beq r7, r0, (LoopCheck2) ELSE, if (monster) equips "None", GOTO (LoopCheck2)
nop
jr 31 ELSE, return to Break or Steal and r7 = target weapon/shield.
sb r1, 0x01A5 (r3) Defender Lost Equipment Byte is the corresponding slot.
(LoopCheck2) srl r1, r1, 0x02 r1 = 0x4/0x2
bne r8, r0, (CheckHands) If r8 > 0, GOTO (CheckHands)
addiu r6, r6, 0x0002
jr 31 ELSE, return to Break or Steal and r7 = 0

(StatDown) ori r7, r0, 0x0014 r7 = 20
ori r5, r0, 0x0002
beq r4, r5, (StatBreak) If r4 = 2 (break armor, but no armor is equipped), GOTO (StatBreak)
addiu r6, r3, 0x019F r6 = CT add/reduce byte
ori r7, r0, 0x0001 r7 = 1
ori r5, r0, 0x0001
beq r4, r5, (StatBreak) If r4 = 1 (break helm, but no helm is equipped), GOTO (StatBreak)
addiu r6, r3, 0x01A1 r6 = MA add/reduce byte
ori r5, r0, 0x0005
beq r4, r5, (StatBreak) If r4 = 5 (break shield, but no shield is equipped), GOTO (StatBreak)
addiu r6, r3, 0x01A0 r6 = PA add/reduce byte
jr r9 ELSE, return to Main Formula Routine
(StatBreak) lbu r5, 0x01B1 (r3) r5 = Attack Type Byte
sb r7, 0x0000 (r6) Set PA/MA/CT reduction byte as decrement
ori r5, r5, 0x0001
jr r9 Return to Main Formula Routine
sb r5, 0x01B1 (r3) Store Attack Byte as including Psuedo-Status [0x01] bit.

(StealGil) lbu r4, 0x0006 (r3) r4 = Defender Type
lbu r5, 0x0049 (r3) r5 = Defender Elevation/Facing Byte
andi r4, r4, 0x0020
bne r4, r0, (E) If Defender is a monster, GOTO (E)
andi r6, r5, 0x0040
bne r6, r0, (E) ELSE, if Defender has already been mugged, GOTO (E)
lbu r4, 0x0022 (r2) r4 = Attacker LVL
lbu r6, 0x0038 (r2) r5 = Attacker SP
addiu r4, r4, 0x0014
mult r4, r6
mflo r6 ELSE, r6 = SP * (20 +  LVL)
lbu r4, 0x01B1 (r2) r4 = Attacker Attack Type Byte
ori r5, r5, 0x0040
ori r4, r4, 0x0001
ori r7, r0, 0x0001
sh r6, 0x0198 (r2) Gain gil by the amount of r6.
sb r4, 0x01B1 (r2) Attacker Attack Type includes "pseudo-status" [0x01] bit.
sb r7, 0x018C (r2) Gil gain "hits" the attacker.
lbu r4, 0x01B1 (r3) r4 = Defender Attack Type Byte
subu r6, r0, r6
ori r4, r4, 0x0001
sb r5, 0x0049 (r3) Defender Elevation Byte includes "has been mugged" bit.
sh r6, 0x0198 (r3) Defender loses gil by the amount of r6.
jr r9 Return to Main Formula Routine
sb r4, 0x01B1 (r3) Defender Attack Type includes "pseudo-status" [0x01] bit.

(StealEXP) lbu r5, 0x0021 (r3) r5 = Target EXP
ori r4, r0, 0x0014 r4 = 20
beq r5, r0, (E) If Target EXP = 0, GOTO (E)
slt r6, r4, r5
beq r6, r0, (EXPChange) If 20 < Target EXP, GOTO (EXPChange) with r7 = 20.
addu r7, r4, r0
addu r7, r5, r0 ELSE, r7 = Target EXP
(EXPChange) sb r7, 0x01B4 (r2) Attacker gains r7 EXP.
addiu r7, r7, 0x0080
sb r7, 0x01B4 (r3) Defender loses r7 EXP.
lbu r4, 0x01B1 (r2) r4 = Attacker Attack Type Byte.
lbu r5, 0x01B1 (r3) r5 = Defender Attack Type Byte.
ori r4, r4, 0x0001
ori r5, r5, 0x0001
sb r4, 0x01B1 (r2) Attacker Attack Type Byte includes "pseudo-status" [0x01] bit.
sb r5, 0x01B1 (r3) Defender Attack Type Byte includes "pseudo-status" [0x01] bit..
ori r7, r0, 0x0001
jr r9 Return to Main Formula Routine
sb r7, 0x018C (r2) EXP gain "hits" the attacker.

(Set Zero) sb r0, 0x01B4 (r3) Defender loses 0 EXP.
sb r0, 0x01B4 (r2) Attacker gains 0 EXP.
sh r0, 0x0198 (r3) Defender loses 0 Gil.
lbu r4, 0x019C (r3) r4 = Special Effect Byte
sh r0, 0x0198 (r2) Attacker gains 0 Gil.
andi r4, r4, 0x00EB
sb r4, 0x019C (r3) Target Special Effect Byte does not include break or steal.
addiu r6, r3, 0x019E
addiu r5, r0, 0x0001
ori r7, r0, 0x0006
(PositiveLoop) beq r5, r7 (End) IF r5 = 6, GOTO (End)
lbu r4, 0x0000 (r6) r4 = Target SP/CT/PA/MA/BR Change Byte
addiu r5, r5, 0x0001 IF r5 < 6, r5 = r5 +1.
andi r4, r4, 0x0080
bne r4, r0, (CheckNext) If Stat Change Byte is Stat Gain, GOTO (CheckNext)
nop
sb r4, 0x0000 (r6) ELSE, Stat Change Byte is 0.
(CheckNext) j (PositiveLoop) GOTO (PositiveLoop)
addiu r6, r6, 0x0001
(End) jr 31 Return to Main Formula Routine and Defender faith gain/loss is 0.
sb r0, 0x01A3 (r3)

(RNG) lui r4, 0xA001
lw r5, -0x6FF0 (r4) Load random word.
lui r6, 0x41C6
addiu r6, r6, 0x4E6D
multu r5, r6
mflo r5
nop
addiu r5, r5, 0x3039
sw r5, -0x6FF0 (r4) Store new Random Word.
multu r7, r5
mfhi r7 r7 = {0...value(r7)-1}
jr 31 Return to Break/Steal Routine
nop
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pride on May 12, 2011, 09:34:24 pm
Might as well post some of notes on reactions while I continue to try and rebuild some of my lost asm information

Reaction Stuff

0018d384: 3c028019 lui r2,0x8019      
0018d388: 8c42f5fc lw r2,-0x0a04(r2)      Load ???
0018d38c: 27bdffe8 addiu r29,r29,0xffe8      
0018d390: 14400006 bne r2,r0,0x0018d3ac      
0018d394: afbf0010 sw r31,0x0010(r29)      
0018d398: 90850024 lbu r5,0x0024(r4)      Load Brave
0018d39c: 0c017833 jal 0x0005e0cc      Random Process
0018d3a0: 34040064 ori r4,r0,0x0064      r4 = 100
0018d3a4: 080634ec j 0x0018d3b0         
0018d3a8: 00000000 nop            
0018d3ac: 00001021 addu r2,r0,r0      
0018d3b0: 8fbf0010 lw r31,0x0010(r29)      
0018d3b4: 27bd0018 addiu r29,r29,0x0018      
0018d3b8: 03e00008 jr r31         
0018d3bc: 00000000 nop   



0018cb00: 27bdffe8 addiu r29,r29,0xffe8      
0018cb04: 3c038019 lui r3,0x8019
0018cb08: 906338e5 lbu r3,0x38e5(r3)      Load Attack Formula ?
0018cb0c: 34020007 ori r2,r0,0x0007      
0018cb10: 10620044 beq r3,r2,0x0018cc24      Branch if using the "Healing" Weapon Formula ?
0018cb14: afbf0010 sw r31,0x0010(r29)      
0018cb18: 3c048019 lui r4,0x8019      
0018cb1c: 8c842d98 lw r4,0x2d98(r4)      Load Target's Stats
0018cb20: 0c063248 jal 0x0018c920      ???
0018cb24: 00000000 nop            
0018cb28: 1440003e bne r2,r0,0x0018cc24      
0018cb2c: 00000000 nop            
0018cb30: 3c048019 lui r4,0x8019      
0018cb34: 8c842d98 lw r4,0x2d98(r4)      Load Target's Stats
0018cb38: 00000000 nop
0018cb3c: 9083008b lbu r3,0x008b(r4)      Load first set of Reactions
0018cb40: 00000000 nop            
0018cb44: 30620010 andi r2,r3,0x0010      
0018cb48: 10400003 beq r2,r0,0x0018cb58      Branch if not using Sunken State
0018cb4c: 34050010 ori r5,r0,0x0010      r5 = 10
0018cb50: 08063307 j 0x0018cc1c         
0018cb54: 340401a9 ori r4,r0,0x01a9      Load Attack's Status Inflict
0018cb58: 30620008 andi r2,r3,0x0008      
0018cb5c: 10400003 beq r2,r0,0x0018cb6c      Branch if not using Caution
0018cb60: 30620004 andi r2,r3,0x0004      r2 = 4
0018cb64: 08063307 j 0x0018cc1c         
0018cb68: 340401aa ori r4,r0,0x01aa      Load Attack's Status Inflict
0018cb6c: 10400003 beq r2,r0,0x0018cb7c      Branch if not using Dragon Spirit
0018cb70: 34050010 ori r5,r0,0x0010      r5 = 10
0018cb74: 08063307 j 0x0018cc1c         
0018cb78: 340401ab ori r4,r0,0x01ab      Load Attack's Status Inflict
0018cb7c: 30620001 andi r2,r3,0x0001      
0018cb80: 10400003 beq r2,r0,0x0018cb90      Branch if not using Brave Up
0018cb84: 00000000 nop            
0018cb88: 08063307 j 0x0018cc1c         
0018cb8c: 340401ad ori r4,r0,0x01ad      Load Attack's Stats Removal
0018cb90: 9083008c lbu r3,0x008c(r4)      Load Second set of Reactions
0018cb94: 00000000 nop            
0018cb98: 30620080 andi r2,r3,0x0080      
0018cb9c: 10400005 beq r2,r0,0x0018cbb4      Branch if not using Faith (Face) up
0018cba0: 30620002 andi r2,r3,0x0002      r2= 2
0018cba4: 0c0633dd jal 0x0018cf74      
0018cba8: 340401ae ori r4,r0,0x01ae      
0018cbac: 08063309 j 0x0018cc24         
0018cbb0: 00000000 nop         
0018cbb4: 10400003 beq r2,r0,0x0018cbc4      Branch if not using Counter Tackle
0018cbb8: 34050010 ori r5,r0,0x0010      r5 = 10
0018cbbc: 08063307 j 0x0018cc1c         
0018cbc0: 340401b4 ori r4,r0,0x01b4      
0018cbc4: 30620001 andi r2,r3,0x0001      
0018cbc8: 10400003 beq r2,r0,0x0018cbd8      Branch if not using Counter Flood
0018cbcc: 34050080 ori r5,r0,0x0080      Prepare Counter Flood Flag Check
0018cbd0: 08063307 j 0x0018cc1c         
0018cbd4: 340401b5 ori r4,r0,0x01b5      
0018cbd8: 9084008d lbu r4,0x008d(r4)      Load 3rd set of Reactions
0018cbdc: 00000000 nop            
0018cbe0: 30820080 andi r2,r4,0x0080      
0018cbe4: 10400005 beq r2,r0,0x0018cbfc      Branch if not using Absorb Used Mp
0018cbe8: 30820008 andi r2,r4,0x0008      r2 = 8
0018cbec: 0c0633dd jal 0x0018cf74      
0018cbf0: 340401b6 ori r4,r0,0x01b6      Hit % for Attack on Self
0018cbf4: 08063309 j 0x0018cc24         
0018cbf8: 00000000 nop            
0018cbfc: 10400003 beq r2,r0,0x0018cc0c      Branch if not using Counter
0018cc00: 340401ba ori r4,r0,0x01ba      
0018cc04: 08063307 j 0x0018cc1c         
0018cc08: 34050010 ori r5,r0,0x0010      
0018cc0c: 30620004 andi r2,r3,0x0004      
0018cc10: 10400004 beq r2,r0,0x0018cc24      Branch if not using Counter Magic?!
0018cc14: 340401b3 ori r4,r0,0x01b3
0018cc18: 34050040 ori r5,r0,0x0040      Prepare for Counter Magic Flag Check
0018cc1c: 0c063381 jal 0x0018ce04      Chance to React
0018cc20: 00000000 nop
0018cc24: 8fbf0010 lw r31,0x0010(r29)
0018cc28: 27bd0018 addiu r29,r29,0x0018
0018cc2c: 03e00008 jr r31
0018cc30: 00000000 nop



0018ce04: 27bdffe8 addiu r29,r29,0xffe8      
0018ce08: afb00010 sw r16,0x0010(r29)      
0018ce0c: 00808021 addu r16,r4,r0      
0018ce10: 3c038019 lui r3,0x8019      
0018ce14: 906338d4 lbu r3,0x38d4(r3)      ???
0018ce18: 34020015 ori r2,r0,0x0015      
0018ce1c: 10620015 beq r3,r2,0x0018ce74      
0018ce20: afbf0014 sw r31,0x0014(r29)      
0018ce24: 3c028019 lui r2,0x8019      
0018ce28: 904238f6 lbu r2,0x38f6(r2)      Ability flags 4
0018ce2c: 00000000 nop
0018ce30: 00451024 and r2,r2,r5         
0018ce34: 1040000f beq r2,r0,0x0018ce74      Branch if ability is not using specific ability flag (counter magic/flood/etc.)
0018ce38: 00000000 nop            
0018ce3c: 3c048019 lui r4,0x8019      
0018ce40: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018ce44: 0c0634e1 jal 0x0018d384      Chance to react
0018ce48: 00000000 nop            
0018ce4c: 14400009 bne r2,r0,0x0018ce74      
0018ce50: 00000000 nop            
0018ce54: 3c038019 lui r3,0x8019      
0018ce58: 8c632d90 lw r3,0x2d90(r3)      Current Action Data Pointer
0018ce5c: 00000000 nop            
0018ce60: a470000e sh r16,0x000e(r3)      Reaction ID ?
0018ce64: 3c028019 lui r2,0x8019      
0018ce68: 944238d6 lhu r2,0x38d6(r2)      Used Ability ID
0018ce6c: 00000000 nop            
0018ce70: a4620026 sh r2,0x0026(r3)      
0018ce74: 8fbf0014 lw r31,0x0014(r29)      
0018ce78: 8fb00010 lw r16,0x0010(r29)      
0018ce7c: 27bd0018 addiu r29,r29,0x0018      
0018ce80: 03e00008 jr r31         
0018ce84: 00000000 nop      


      
0018cf74: 27bdffe0 addiu r29,r29,0xffe0      
0018cf78: afb10014 sw r17,0x0014(r29)      
0018cf7c: 3c118019 lui r17,0x8019      
0018cf80: 263138eb addiu r17,r17,0x38eb      Load MP Used
0018cf84: afbf0018 sw r31,0x0018(r29)      
0018cf88: afb00010 sw r16,0x0010(r29)      
0018cf8c: 92220000 lbu r2,0x0000(r17)      Load MP used into R2
0018cf90: 00000000 nop            
0018cf94: 1040000e beq r2,r0,0x0018cfd0      Branch to end if No MP was used
0018cf98: 00808021 addu r16,r4,r0      
0018cf9c: 3c048019 lui r4,0x8019      
0018cfa0: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018cfa4: 0c0634e1 jal 0x0018d384      Chance to React
0018cfa8: 00000000 nop            
0018cfac: 14400008 bne r2,r0,0x0018cfd0      Branch if Reaction Failed
0018cfb0: 00000000 nop            
0018cfb4: 3c038019 lui r3,0x8019      
0018cfb8: 8c632d90 lw r3,0x2d90(r3)      Current Action Data Pointer
0018cfbc: 00000000 nop            
0018cfc0: a470000e sh r16,0x000e(r3)      Store Reaction ID
0018cfc4: 92220000 lbu r2,0x0000(r17)      lol
0018cfc8: 00000000 nop            
0018cfcc: a4620026 sh r2,0x0026(r3)      Store Last Attack on Self?
0018cfd0: 8fbf0018 lw r31,0x0018(r29)      
0018cfd4: 8fb10014 lw r17,0x0014(r29)      
0018cfd8: 8fb00010 lw r16,0x0010(r29)      
0018cfdc: 27bd0020 addiu r29,r29,0x0020      
0018cfe0: 03e00008 jr r31         
0018cfe4: 00000000 nop   

It appears any ability with MP will trigger Face/Faith Up.... Didn't know that



0018cc34: 27bdffe8 addiu r29,r29,0xffe8      
0018cc38: 3c038019 lui r3,0x8019      
0018cc3c: 906338e5 lbu r3,0x38e5(r3)      
0018cc40: 34020007 ori r2,r0,0x0007      
0018cc44: 10620020 beq r3,r2,0x0018ccc8      
0018cc48: afbf0010 sw r31,0x0010(r29)      
0018cc4c: 3c048019 lui r4,0x8019      
0018cc50: 8c842d98 lw r4,0x2d98(r4)      
0018cc54: 0c063248 jal 0x0018c920      
0018cc58: 00000000 nop            
0018cc5c: 1440001a bne r2,r0,0x0018ccc8      
0018cc60: 00000000 nop            
0018cc64: 3c048019 lui r4,0x8019      
0018cc68: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018cc6c: 00000000 nop            
0018cc70: 9083008d lbu r3,0x008d(r4)      Load 3rd set of Reactions
0018cc74: 00000000 nop            
0018cc78: 30620001 andi r2,r3,0x0001      
0018cc7c: 10400005 beq r2,r0,0x0018cc94      Branch if not using MP switch
0018cc80: 30620002 andi r2,r3,0x0002      r2 = 2
0018cc84: 0c06346e jal 0x0018d1b8      MP Switch Calc
0018cc88: 00000000 nop            
0018cc8c: 08063332 j 0x0018ccc8         End
0018cc90: 00000000 nop            
0018cc94: 10400005 beq r2,r0,0x0018ccac      Branch if not using Distrubute
0018cc98: 00000000 nop            
0018cc9c: 0c0634aa jal 0x0018d2a8      Distribute Calc
0018cca0: 00000000 nop            
0018cca4: 08063332 j 0x0018ccc8         End
0018cca8: 00000000 nop            
0018ccac: 9082008e lbu r2,0x008e(r4)      Load 4th set of Reactions
0018ccb0: 00000000 nop            
0018ccb4: 30420080 andi r2,r2,0x0080      
0018ccb8: 10400003 beq r2,r0,0x0018ccc8      Branch if not using Damage Split
0018ccbc: 00000000 nop            
0018ccc0: 0c0634c6 jal 0x0018d318      
0018ccc4: 00000000 nop            
0018ccc8: 8fbf0010 lw r31,0x0010(r29)      
0018cccc: 27bd0018 addiu r29,r29,0x0018      
0018ccd0: 03e00008 jr r31         
0018ccd4: 00000000 nop            



0018d1b8: 3c028019 lui r2,0x8019      
0018d1bc: 8c422d90 lw r2,0x2d90(r2)      Current Action Data Pointer
0018d1c0: 27bdffe8 addiu r29,r29,0xffe8      
0018d1c4: afbf0010 sw r31,0x0010(r29)      
0018d1c8: 84420004 lh r2,0x0004(r2)      HP Damage
0018d1cc: 00000000 nop            
0018d1d0: 10400031 beq r2,r0,0x0018d298      Branch if no damage was dealt
0018d1d4: 00000000 nop            
0018d1d8: 3c048019 lui r4,0x8019      
0018d1dc: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018d1e0: 00000000 nop            
0018d1e4: 9482002c lhu r2,0x002c(r4)      Load Current MP
0018d1e8: 00000000 nop            
0018d1ec: 1040002a beq r2,r0,0x0018d298      Branch if no MP
0018d1f0: 00000000 nop            
0018d1f4: 0c0634e1 jal 0x0018d384      Chance to React
0018d1f8: 00000000 nop            
0018d1fc: 14400026 bne r2,r0,0x0018d298      Branch if did not react
0018d200: 00000000 nop            
0018d204: 3c028019 lui r2,0x8019      
0018d208: 8c42f5fc lw r2,-0x0a04(r2)      ???
0018d20c: 00000000 nop            
0018d210: 14400021 bne r2,r0,0x0018d298      
0018d214: 00000000 nop            
0018d218: 3c048019 lui r4,0x8019      
0018d21c: 8c842d90 lw r4,0x2d90(r4)      Current Action Data Pointer
0018d220: 00000000 nop            
0018d224: 94820008 lhu r2,0x0008(r4)      Load HP Damage
0018d228: 94830004 lhu r3,0x0004(r4)      Load MP Damage
0018d22c: 00000000 nop            
0018d230: 00431021 addu r2,r2,r3      
0018d234: a4820008 sh r2,0x0008(r4)      Store as MP Damage
0018d238: 00021400 sll r2,r2,0x10      ...
0018d23c: 00021403 sra r2,r2,0x10      ...
0018d240: 284203e8 slti r2,r2,0x03e8      
0018d244: 14400002 bne r2,r0,0x0018d250      
0018d248: 340203e7 ori r2,r0,0x03e7      
0018d24c: a4820008 sh r2,0x0008(r4)      Store as MP Damage
0018d250: 3c038019 lui r3,0x8019      
0018d254: 8c632d90 lw r3,0x2d90(r3)      Current Action Data Pointer
0018d258: 00000000 nop            
0018d25c: 90620025 lbu r2,0x0025(r3)      Attack Flags
0018d260: 00000000 nop            
0018d264: 3042007f andi r2,r2,0x007f      Not HP Damage...
0018d268: a0620025 sb r2,0x0025(r3)      Store...
0018d26c: 3c048019 lui r4,0x8019      
0018d270: 8c842d90 lw r4,0x2d90(r4)      Current Action Data Pointer >_>
0018d274: a4600004 sh r0,0x0004(r3)      0 HP Damage
0018d278: 90820025 lbu r2,0x0025(r4)      
0018d27c: 00000000 nop            
0018d280: 34420020 ori r2,r2,0x0020      
0018d284: a0820025 sb r2,0x0025(r4)      Store Attack Flag as MP Damage
0018d288: 3c038019 lui r3,0x8019      
0018d28c: 8c632d90 lw r3,0x2d90(r3)      CUrrent Action Data Pointer
0018d290: 340201bd ori r2,r0,0x01bd      
0018d294: a462000e sh r2,0x000e(r3)      Reaction ID?
0018d298: 8fbf0010 lw r31,0x0010(r29)
0018d29c: 27bd0018 addiu r29,r29,0x0018
0018d2a0: 03e00008 jr r31
0018d2a4: 00000000 nop


               
0018d2a8: 3c058019 lui r5,0x8019      
0018d2ac: 8ca52d98 lw r5,0x2d98(r5)      Load Defender's Stats
0018d2b0: 3c048019 lui r4,0x8019      
0018d2b4: 8c842d90 lw r4,0x2d90(r4)      Current Action Data Pointer
0018d2b8: 27bdffe8 addiu r29,r29,0xffe8      
0018d2bc: afbf0014 sw r31,0x0014(r29)      
0018d2c0: afb00010 sw r16,0x0010(r29)      
0018d2c4: 94a2002a lhu r2,0x002a(r5)      Load Max HP
0018d2c8: 94a30028 lhu r3,0x0028(r5)      Load Current HP
0018d2cc: 84840006 lh r4,0x0006(r4)      HP Recovery
0018d2d0: 00431023 subu r2,r2,r3      Max HP - Current HP
0018d2d4: 00828023 subu r16,r4,r2      
0018d2d8: 1a00000a blez r16,0x0018d304      Branch if r16 on less then or equal to zero
0018d2dc: 00000000 nop            
0018d2e0: 0c0634e1 jal 0x0018d384      Chance to Counter
0018d2e4: 00a02021 addu r4,r5,r0      
0018d2e8: 14400006 bne r2,r0,0x0018d304      Branch if didn't react
0018d2ec: 340201bc ori r2,r0,0x01bc      
0018d2f0: 3c038019 lui r3,0x8019      
0018d2f4: 8c632d90 lw r3,0x2d90(r3)      Current Action Data Pointer
0018d2f8: 00000000 nop            
0018d2fc: a4700026 sh r16,0x0026(r3)      Last Attack on Self?
0018d300: a462000e sh r2,0x000e(r3)      Reaction ID?
0018d304: 8fbf0014 lw r31,0x0014(r29)      
0018d308: 8fb00010 lw r16,0x0010(r29)      
0018d30c: 27bd0018 addiu r29,r29,0x0018      
0018d310: 03e00008 jr r31         
0018d314: 00000000 nop         



0018d318: 3c028019 lui r2,0x8019      
0018d31c: 8c422d90 lw r2,0x2d90(r2)      Current Action Data Pointer
0018d320: 27bdffe8 addiu r29,r29,0xffe8      
0018d324: afbf0014 sw r31,0x0014(r29)      
0018d328: afb00010 sw r16,0x0010(r29)      
0018d32c: 94500004 lhu r16,0x0004(r2)      Load Damage?
0018d330: 00000000 nop            
0018d334: 1200000e beq r16,r0,0x0018d370   Branch if no Damage?
0018d338: 00000000 nop            
0018d33c: 3c048019 lui r4,0x8019      
0018d340: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018d344: 0c0634e1 jal 0x0018d384      Chance to React
0018d348: 00000000 nop            
0018d34c: 14400008 bne r2,r0,0x0018d370      
0018d350: 26100001 addiu r16,r16,0x0001      
0018d354: 3202ffff andi r2,r16,0xffff      
0018d358: 00028042 srl r16,r2,0x01      Damage / 2 ?
0018d35c: 3c038019 lui r3,0x8019      
0018d360: 8c632d90 lw r3,0x2d90(r3)      Current Action Data Pointer
0018d364: 340201be ori r2,r0,0x01be      
0018d368: a4700026 sh r16,0x0026(r3)      
0018d36c: a462000e sh r2,0x000e(r3)      
0018d370: 8fbf0014 lw r31,0x0014(r29)      
0018d374: 8fb00010 lw r16,0x0010(r29)      
0018d378: 27bd0018 addiu r29,r29,0x0018      
0018d37c: 03e00008 jr r31
0018d380: 00000000 nop      




001882f8: 3c048019 lui r4,0x8019            
001882fc: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
00188300: 27bdffe8 addiu r29,r29,0xffe8      
00188304: afbf0010 sw r31,0x0010(r29)      
00188308: 0c063248 jal 0x0018c920      ???
0018830c: 00000000 nop            
00188310: 14400022 bne r2,r0,0x0018839c      
00188314: 00000000 nop            
00188318: 3c058019 lui r5,0x8019      
0018831c: 8ca52d98 lw r5,0x2d98(r5)      Load Defender's Stats....
00188320: 00000000 nop            
00188324: 90a2008e lbu r2,0x008e(r5)      Load 4th set of Reactions
00188328: 00000000 nop            
0018832c: 30420020 andi r2,r2,0x0020      Branch if not equiped with Finger Guard
00188330: 1040001a beq r2,r0,0x0018839c
00188334: 34020064 ori r2,r0,0x0064      R2=100
00188338: 90a30024 lbu r3,0x0024(r5)      
0018833c: 3c048019 lui r4,0x8019      
00188340: 8c842d90 lw r4,0x2d90(r4)      Load Current Action Data Pointer
00188344: 00431023 subu r2,r2,r3      100 - Brave
00188348: 1040000a beq r2,r0,0x00188374      Branch if Brave > 100?
0018834c: a482002a sh r2,0x002a(r4)      Store Hit %
00188350: 0c0634e1 jal 0x0018d384      chance to React
00188354: 00a02021 addu r4,r5,r0      
00188358: 14400010 bne r2,r0,0x0018839c      
0018835c: 00000000 nop            
00188360: 3c028019 lui r2,0x8019      
00188364: 8c42f5fc lw r2,-0x0a04(r2)      Load Something to do with Damage Display?
00188368: 00000000 nop            
0018836c: 1440000b bne r2,r0,0x0018839c      
00188370: 00000000 nop            
00188374: 3c028019 lui r2,0x8019      
00188378: 8c422d90 lw r2,0x2d90(r2)      Load Current Action Data Pointer
0018837c: 00000000 nop            
00188380: a0400000 sb r0,0x0000(r2)      Change hit flag to miss
00188384: 3c038019 lui r3,0x8019      
00188388: 8c632d90 lw r3,0x2d90(r3)      Load Current Action Data Pointer...
0018838c: 340201c0 ori r2,r0,0x01c0      
00188390: a462000e sh r2,0x000e(r3)      Store Reaction ID
00188394: 3402000b ori r2,r0,0x000b      
00188398: a0620002 sb r2,0x0002(r3)      Store Evade type?
0018839c: 8fbf0010 lw r31,0x0010(r29)      
001883a0: 27bd0018 addiu r29,r29,0x0018      
001883a4: 03e00008 jr r31         
001883a8: 00000000 nop            




001883ac: 3c048019 lui r4,0x8019      
001883b0: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
001883b4: 27bdffe8 addiu r29,r29,0xffe8      
001883b8: afbf0010 sw r31,0x0010(r29)      
001883bc: 0c063248 jal 0x0018c920      ???
001883c0: 00000000 nop            
001883c4: 1440002c bne r2,r0,0x00188478      
001883c8: 00000000 nop            
001883cc: 3c028019 lui r2,0x8019      
001883d0: 8c422d94 lw r2,0x2d94(r2)      Load Attacker's Stats
001883d4: 00000000 nop            
001883d8: 90430003 lbu r3,0x0003(r2)      Load Attacker's Job
001883dc: 3402005d ori r2,r0,0x005d      
001883e0: 10620025 beq r3,r2,0x00188478      Branch to end if Attacker is a mime?
001883e4: 00000000 nop            
001883e8: 3c058019 lui r5,0x8019      
001883ec: 8ca52d98 lw r5,0x2d98(r5)      Load Defender's Stats
001883f0: 00000000 nop            
001883f4: 90a2008e lbu r2,0x008e(r5)      Load Defender's 4th set of Reactions
001883f8: 00000000 nop            
001883fc: 30420008 andi r2,r2,0x0008      
00188400: 1040001d beq r2,r0,0x00188478      Branch to end if user is not equiped with Catch
00188404: 34020064 ori r2,r0,0x0064      R2 = 100
00188408: 90a30024 lbu r3,0x0024(r5)      Load Brave
0018840c: 3c048019 lui r4,0x8019      
00188410: 8c842d90 lw r4,0x2d90(r4)      Current Action Data Pointer
00188414: 00431023 subu r2,r2,r3      100 - Brave
00188418: 1040000a beq r2,r0,0x00188444      Branch if Brave > 100 ?
0018841c: a482002a sh r2,0x002a(r4)      Store Hit % for Attack on self?
00188420: 0c0634e1 jal 0x0018d384      Chance to React
00188424: 00a02021 addu r4,r5,r0      
00188428: 14400013 bne r2,r0,0x00188478      Branch to end if Reaction failed
0018842c: 00000000 nop            
00188430: 3c028019 lui r2,0x8019      
00188434: 8c42f5fc lw r2,-0x0a04(r2)      Load something to do with Damage Display?
00188438: 00000000 nop            
0018843c: 1440000e bne r2,r0,0x00188478      
00188440: 00000000 nop            
00188444: 3c028019 lui r2,0x8019      
00188448: 8c422d90 lw r2,0x2d90(r2)      Load Current Action Data Pointer
0018844c: 00000000 nop            
00188450: a0400000 sb r0,0x0000(r2)      Change hit flag to miss
00188454: 3c038019 lui r3,0x8019      
00188458: 8c632d90 lw r3,0x2d90(r3)      Load Current Action Data Pointer
0018845c: 340201c2 ori r2,r0,0x01c2      
00188460: a462000e sh r2,0x000e(r3)      Store Reaction ID?
00188464: 3c048019 lui r4,0x8019      
00188468: 908438d8 lbu r4,0x38d8(r4)      Load Used Weapon ID
0018846c: 3402000d ori r2,r0,0x000d      
00188470: a0620002 sb r2,0x0002(r3)      Store Miss type?
00188474: a4640026 sh r4,0x0026(r3)      Store Used Weapon ID to something?
00188478: 8fbf0010 lw r31,0x0010(r29)      
0018847c: 27bd0018 addiu r29,r29,0x0018      
00188480: 03e00008 jr r31         
00188484: 00000000 nop            




0018ccd8: 27bdffe8 addiu r29,r29,0xffe8      
0018ccdc: 3c038019 lui r3,0x8019      
0018cce0: 906338e5 lbu r3,0x38e5(r3)      Load Attack formula ?
0018cce4: 34020007 ori r2,r0,0x0007      
0018cce8: 10620042 beq r3,r2,0x0018cdf4      Branch if used Formula is the "Healing" Weapon Formula?
0018ccec: afbf0010 sw r31,0x0010(r29)      
0018ccf0: 3c048019 lui r4,0x8019      
0018ccf4: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018ccf8: 0c063248 jal 0x0018c920      ???
0018ccfc: 00000000 nop            
0018cd00: 1440003c bne r2,r0,0x0018cdf4      
0018cd04: 00000000 nop            
0018cd08: 3c048019 lui r4,0x8019      
0018cd0c: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018cd10: 00000000 nop            
0018cd14: 9083008b lbu r3,0x008b(r4)      Load Defender's 1st Set of Reactions
0018cd18: 00000000 nop            
0018cd1c: 30620080 andi r2,r3,0x0080      
0018cd20: 10400003 beq r2,r0,0x0018cd30      Branch if PA Save is not equiped
0018cd24: 30620040 andi r2,r3,0x0040      R2 = 40
0018cd28: 0806337b j 0x0018cdec         
0018cd2c: 340401a6 ori r4,r0,0x01a6      Prepares Reaction ID check?
0018cd30: 10400003 beq r2,r0,0x0018cd40      Branch if MA Save is not equiped
0018cd34: 30620020 andi r2,r3,0x0020      R2 = 20
0018cd38: 0806337b j 0x0018cdec         
0018cd3c: 340401a7 ori r4,r0,0x01a7      Prepares Reaction ID check?
0018cd40: 10400003 beq r2,r0,0x0018cd50      Branch if Speed Save is not equiped
0018cd44: 30620002 andi r2,r3,0x0002      R2 = 2
0018cd48: 0806337b j 0x0018cdec         
0018cd4c: 340401a8 ori r4,r0,0x01a8      Prepares Reaction ID check?
0018cd50: 10400003 beq r2,r0,0x0018cd60      Branch if Regenerator is not equiped
0018cd54: 00000000 nop            
0018cd58: 0806337b j 0x0018cdec         
0018cd5c: 340401ac ori r4,r0,0x01ac      Prepares Reaction ID Check?
0018cd60: 9083008c lbu r3,0x008c(r4)      Load Defender's 2nd set of Reactions
0018cd64: 00000000 nop            
0018cd68: 30620040 andi r2,r3,0x0040      
0018cd6c: 10400005 beq r2,r0,0x0018cd84      Branch if HP Restore is not equiped
0018cd70: 30620020 andi r2,r3,0x0020      R2 = 20
0018cd74: 0c0633bd jal 0x0018cef4      
0018cd78: 340401af ori r4,r0,0x01af      Prepares Reaction ID Check?
0018cd7c: 0806337d j 0x0018cdf4         
0018cd80: 00000000 nop            
0018cd84: 10400005 beq r2,r0,0x0018cd9c      Branch if MP Restore is not equiped
0018cd88: 30620010 andi r2,r3,0x0010      R2 = 10
0018cd8c: 0c0633bd jal 0x0018cef4      
0018cd90: 340401b0 ori r4,r0,0x01b0      Prepares Reaction ID Check?
0018cd94: 0806337d j 0x0018cdf4         
0018cd98: 00000000 nop            
0018cd9c: 10400005 beq r2,r0,0x0018cdb4      Branch if Critical Quick is not equiped
0018cda0: 30620008 andi r2,r3,0x0008      R2 = 8
0018cda4: 0c0633bd jal 0x0018cef4      
0018cda8: 340401b1 ori r4,r0,0x01b1      Prepares Reaction ID Check?
0018cdac: 0806337d j 0x0018cdf4         
0018cdb0: 00000000 nop            
0018cdb4: 10400005 beq r2,r0,0x0018cdcc      Branch if Meatbone Slash is not equiped
0018cdb8: 00000000 nop            
0018cdbc: 0c0633bd jal 0x0018cef4      
0018cdc0: 340401b2 ori r4,r0,0x01b2      Prepares Reaction ID Check?
0018cdc4: 0806337d j 0x0018cdf4         
0018cdc8: 00000000 nop            
0018cdcc: 9083008d lbu r3,0x008d(r4)      Load Defender's 3th Set of Reactions
0018cdd0: 00000000 nop            
0018cdd4: 30620040 andi r2,r3,0x0040      
0018cdd8: 14400004 bne r2,r0,0x0018cdec      Branch if unit is not equiped with Gilgame Heart
0018cddc: 340401b7 ori r4,r0,0x01b7      Prepares Reaction ID Check?
0018cde0: 30620010 andi r2,r3,0x0010      
0018cde4: 10400003 beq r2,r0,0x0018cdf4      Branch if unit is not equiped with Auto Potion
0018cde8: 340401b9 ori r4,r0,0x01b9      Prepares Reaction ID CHeck?
0018cdec: 0c0633a2 jal 0x0018ce88      
0018cdf0: 00000000 nop            
0018cdf4: 8fbf0010 lw r31,0x0010(r29)      
0018cdf8: 27bd0018 addiu r29,r29,0x0018      
0018cdfc: 03e00008 jr r31         
0018ce00: 00000000 nop            




0018ce88: 3c028019 lui r2,0x8019      
0018ce8c: 8c422d90 lw r2,0x2d90(r2)      Load Current Action Data Pointer
0018ce90: 27bdffe8 addiu r29,r29,0xffe8      
0018ce94: afbf0014 sw r31,0x0014(r29)      
0018ce98: afb00010 sw r16,0x0010(r29)      
0018ce9c: 90420025 lbu r2,0x0025(r2)      Load Attack Type
0018cea0: 00000000 nop            
0018cea4: 30420080 andi r2,r2,0x0080      
0018cea8: 1040000d beq r2,r0,0x0018cee0      Branch if Attack was not HP Damage
0018ceac: 00808021 addu r16,r4,r0      
0018ceb0: 3c048019 lui r4,0x8019      
0018ceb4: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats   
0018ceb8: 0c0634e1 jal 0x0018d384      Load Chance to React
0018cebc: 00000000 nop            
0018cec0: 14400007 bne r2,r0,0x0018cee0      Branch if Reaction Failed
0018cec4: 00000000 nop            
0018cec8: 3c028019 lui r2,0x8019      
0018cecc: 8c422d90 lw r2,0x2d90(r2)      Load Current Action Data Pointer
0018ced0: 00000000 nop            
0018ced4: 94430004 lhu r3,0x0004(r2)      Load HP Damage
0018ced8: a450000e sh r16,0x000e(r2)      Store Reaction ID
0018cedc: a4430026 sh r3,0x0026(r2)      Store Last Attack on Self?
0018cee0: 8fbf0014 lw r31,0x0014(r29)      
0018cee4: 8fb00010 lw r16,0x0010(r29)      
0018cee8: 27bd0018 addiu r29,r29,0x0018      
0018ceec: 03e00008 jr r31         
0018cef0: 00000000 nop         



0018cef4: 27bdffe8 addiu r29,r29,0xffe8      
0018cef8: afb00010 sw r16,0x0010(r29)      
0018cefc: 00808021 addu r16,r4,r0      
0018cf00: 3c048019 lui r4,0x8019      
0018cf04: 8c842d98 lw r4,0x2d98(r4)      Load Defender's Stats
0018cf08: afbf0014 sw r31,0x0014(r29)      
0018cf0c: 9082005a lbu r2,0x005a(r4)      Load Target's 3rd set of Current Status
0018cf10: 00000000 nop            
0018cf14: 30420001 andi r2,r2,0x0001      
0018cf18: 10400011 beq r2,r0,0x0018cf60      Branch if Target is not in Critical
0018cf1c: 00000000 nop            
0018cf20: 3c028019 lui r2,0x8019      
0018cf24: 8c422d90 lw r2,0x2d90(r2)      Current Action Data Pointer
0018cf28: 00000000 nop            
0018cf2c: 90420025 lbu r2,0x0025(r2)      Attack Type Flag
0018cf30: 00000000 nop            
0018cf34: 30420080 andi r2,r2,0x0080      
0018cf38: 10400009 beq r2,r0,0x0018cf60      Branch if Attack was not HP Damage
0018cf3c: 00000000 nop            
0018cf40: 0c0634e1 jal 0x0018d384      Chance to React
0018cf44: 00000000 nop            
0018cf48: 14400005 bne r2,r0,0x0018cf60      Branch if did not react
0018cf4c: 00000000 nop            
0018cf50: 3c028019 lui r2,0x8019      
0018cf54: 8c422d90 lw r2,0x2d90(r2)      Current Action Data Pointer
0018cf58: 00000000 nop            
0018cf5c: a450000e sh r16,0x000e(r2)      Store Reaction ID
0018cf60: 8fbf0014 lw r31,0x0014(r29)      
0018cf64: 8fb00010 lw r16,0x0010(r29)      
0018cf68: 27bd0018 addiu r29,r29,0x0018      
0018cf6c: 03e00008 jr r31         
0018cf70: 00000000 nop   


MP Cost Section (Contains Half of MP check and calculation)

0017da20: 27bdffd8 addiu r29,r29,0xffd8      
0017da24: afb00018 sw r16,0x0018(r29)      
0017da28: 00808021 addu r16,r4,r0      Attacker's Data Pointer to r16?   
0017da2c: afbf0024 sw r31,0x0024(r29)      
0017da30: afb20020 sw r18,0x0020(r29)      
0017da34: afb1001c sw r17,0x001c(r29)      
0017da38: 9202016f lbu r2,0x016f(r16)      
0017da3c: 96110170 lhu r17,0x0170(r16)      
0017da40: 3c018006 lui r1,0x8006      
0017da44: 00220821 addu r1,r1,r2      
0017da48: 90325cb4 lbu r18,0x5cb4(r1)      Load Monster Skill Set?
0017da4c: 3c028019 lui r2,0x8019      
0017da50: 8c42f5f0 lw r2,-0x0a10(r2)      
0017da54: 3c018019 lui r1,0x8019      
0017da58: a02038eb sb r0,0x38eb(r1)      Used MP = 0 ?
0017da5c: 14400003 bne r2,r0,0x0017da6c      Branch if used MP is not 0
0017da60: 00000000 nop
0017da64: 0c0179ea jal 0x0005e7a8      
0017da68: 340500ff ori r5,r0,0x00ff      r5 = FF
0017da6c: 0c0604c3 jal 0x0018130c      MP Usability, Weapon Guard Usability, Reaction Usability
0017da70: 02002021 addu r4,r16,r0      Attacker's Data Pointer to r16?
0017da74: 9203005c lbu r3,0x005c(r16)      5th set of Current Status
0017da78: 00000000 nop            
0017da7c: 30630004 andi r3,r3,0x0004      
0017da80: 10600002 beq r3,r0,0x0017da8c      Branch if unit is not affected with Don't Act
0017da84: 00000000 nop            
0017da88: 34020001 ori r2,r0,0x0001      r2 = 1
0017da8c: 14400047 bne r2,r0,0x0017dbac      Branch to end if r2 > 0
0017da90: 24420006 addiu r2,r2,0x0006      r2 + 6
0017da94: 9202005a lbu r2,0x005a(r16)      Load 3rd set of Status
0017da98: 00000000 nop            
0017da9c: 30420002 andi r2,r2,0x0002      
0017daa0: 1040000e beq r2,r0,0x0017dadc      Branch if unit is not Frogged
0017daa4: 00111400 sll r2,r17,0x10      
0017daa8: 00021c03 sra r3,r2,0x10      
0017daac: 10600005 beq r3,r0,0x0017dac4      
0017dab0: 3402016f ori r2,r0,0x016f      
0017dab4: 10620003 beq r3,r2,0x0017dac4      
0017dab8: 3402001d ori r2,r0,0x001d      
0017dabc: 1462003b bne r3,r2,0x0017dbac      
0017dac0: 34020005 ori r2,r0,0x0005      
0017dac4: 324300ff andi r3,r18,0x00ff      
0017dac8: 3402000a ori r2,r0,0x000a      
0017dacc: 14620004 bne r3,r2,0x0017dae0      
0017dad0: 2e220170 sltiu r2,r17,0x0170      
0017dad4: 0805f6eb j 0x0017dbac         Jump to End
0017dad8: 34020005 ori r2,r0,0x0005      R2 = 5
0017dadc: 2e220170 sltiu r2,r17,0x0170      
0017dae0: 10400031 beq r2,r0,0x0017dba8      
0017dae4: 00111400 sll r2,r17,0x10      
0017dae8: 00021403 sra r2,r2,0x10      
0017daec: 000218c0 sll r3,r2,0x03      
0017daf0: 00621823 subu r3,r3,r2      
0017daf4: 00031840 sll r3,r3,0x01      
0017daf8: 3c028006 lui r2,0x8006      
0017dafc: 2442fbf0 addiu r2,r2,0xfbf0      
0017db00: 00622021 addu r4,r3,r2      
0017db04: 324300ff andi r3,r18,0x00ff      
0017db08: 10600003 beq r3,r0,0x0017db18      
0017db0c: 34020006 ori r2,r0,0x0006      
0017db10: 1462000b bne r3,r2,0x0017db40      
0017db14: 00000000 nop            
0017db18: 90820005 lbu r2,0x0005(r4)      Load Abilities 3rd set of Flags
0017db1c: 00000000 nop            
0017db20: 30420020 andi r2,r2,0x0020      
0017db24: 10400006 beq r2,r0,0x0017db40      Branch if ability is not affected by Silence (Ability Flag)
0017db28: 00000000 nop            
0017db2c: 92020059 lbu r2,0x0059(r16)      Load 2nd set of Status
0017db30: 00000000 nop            
0017db34: 30420008 andi r2,r2,0x0008      Branch if Silenced
0017db38: 1440001c bne r2,r0,0x0017dbac      
0017db3c: 34020002 ori r2,r0,0x0002      r2 = 2
0017db40: 1640001a bne r18,r0,0x0017dbac      
0017db44: 00001021 addu r2,r0,r0      r2 = 0
0017db48: 92030003 lbu r3,0x0003(r16)      Load Job
0017db4c: 3402005d ori r2,r0,0x005d      r2 = 5d
0017db50: 10620016 beq r3,r2,0x0017dbac      Branch if Job # is Mime
0017db54: 00001021 addu r2,r0,r0      r2 = 0
0017db58: 92020090 lbu r2,0x0090(r16)      Load secend set of Support
0017db5c: 9084000d lbu r4,0x000d(r4)      Abilities MP Cost
0017db60: 30420080 andi r2,r2,0x0080      
0017db64: 10400002 beq r2,r0,0x0017db70      Branch if not equiped with Half of MP
0017db68: 00000000 nop            
0017db6c: 00042042 srl r4,r4,0x01      Abilities MP Cost / 2      
0017db70: 3c018019 lui r1,0x8019      
0017db74: a02438eb sb r4,0x38eb(r1)      Store new Abilities MP Cost
0017db78: 8602002c lh r2,0x002c(r16)      Load Current MP
0017db7c: 00000000 nop            
0017db80: 00402821 addu r5,r2,r0      Current MP to r5
0017db84: 0044102a slt r2,r2,r4         Set r2 to 1 if Current MP is less than Ability Clost
0017db88: 14400008 bne r2,r0,0x0017dbac      If Current MP is less then Ability Cost Branch to end
0017db8c: 34020003 ori r2,r0,0x0003      r2 = 3
0017db90: 3c038019 lui r3,0x8019      
0017db94: 8c63f5fc lw r3,-0x0a04(r3)      ???
0017db98: 34020002 ori r2,r0,0x0002      r2 = 2
0017db9c: 10620002 beq r3,r2,0x0017dba8      
0017dba0: 00a41023 subu r2,r5,r4      Current MP - Used MP
0017dba4: a602002c sh r2,0x002c(r16)      Store new Current MP
0017dba8: 00001021 addu r2,r0,r0      r2 = 0
0017dbac: 8fbf0024 lw r31,0x0024(r29)
0017dbb0: 8fb20020 lw r18,0x0020(r29)
0017dbb4: 8fb1001c lw r17,0x001c(r29)
0017dbb8: 8fb00018 lw r16,0x0018(r29)
0017dbbc: 27bd0028 addiu r29,r29,0x0028
0017dbc0: 03e00008 jr r31
0017dbc4: 00000000 nop


Poison and Regen affect HP Section


0018d7c8: 27bdffe8 addiu r29,r29,0xffe8      
0018d7cc: afb00010 sw r16,0x0010(r29)      
0018d7d0: afbf0014 sw r31,0x0014(r29)      
0018d7d4: 0c063691 jal 0x0018da44      Check for Crystal, Dead, Jump, Petrify, or Treasure
0018d7d8: 00808021 addu r16,r4,r0      
0018d7dc: 1440001d bne r2,r0,0x0018d854      Branch to end if unit has Crystal, Dead, Jump, Petrify or Treasure
0018d7e0: 00001021 addu r2,r0,r0      r2 = 0
0018d7e4: 0c063681 jal 0x0018da04      
0018d7e8: 02002021 addu r4,r16,r0      
0018d7ec: 9203005b lbu r3,0x005b(r16)      Load Attacker's 4th set of Current status
0018d7f0: 00000000 nop            
0018d7f4: 30620080 andi r2,r3,0x0080      
0018d7f8: 10400008 beq r2,r0,0x0018d81c      Branch if unit isn't Poisoned
0018d7fc: 00000000 nop            
0018d800: 9602002a lhu r2,0x002a(r16)      Load Max HP
0018d804: 3c038019 lui r3,0x8019      
0018d808: 8c632d90 lw r3,0x2d90(r3)      Load Current Action Data Pointer
0018d80c: 000210c2 srl r2,r2,0x03      Max HP / 8
0018d810: a4620004 sh r2,0x0004(r3)      Store has HP Damage
0018d814: 08063610 j 0x0018d840         
0018d818: 34020080 ori r2,r0,0x0080      Attack Flag (Damage)
0018d81c: 30620040 andi r2,r3,0x0040      
0018d820: 10400008 beq r2,r0,0x0018d844      Branch if unit doesn't have Regen
0018d824: 00000000 nop            
0018d828: 9602002a lhu r2,0x002a(r16)      Load Max HP
0018d82c: 3c038019 lui r3,0x8019      
0018d830: 8c632d90 lw r3,0x2d90(r3)      Load Current Action Data Pointer
0018d834: 000210c2 srl r2,r2,0x03      Max HP / 8
0018d838: a4620006 sh r2,0x0006(r3)      Store has Healing
0018d83c: 34020040 ori r2,r0,0x0040      Attack Flag (Heal)
0018d840: a0620025 sb r2,0x0025(r3)      Store Attack Flag
0018d844: 3c028019 lui r2,0x8019      
0018d848: 8c422d90 lw r2,0x2d90(r2)      Load Current Action Data Pointer
0018d84c: 00000000 nop            
0018d850: 90420025 lbu r2,0x0025(r2)      Load Attack Flag
0018d854: 8fbf0014 lw r31,0x0014(r29)      
0018d858: 8fb00010 lw r16,0x0010(r29)      
0018d85c: 27bd0018 addiu r29,r29,0x0018      
0018d860: 03e00008 jr r31         Return to Routine
0018d864: 00000000 nop   
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RandMuadDib on May 12, 2011, 09:54:48 pm
sorry to hear you lost data :( glad to hear you're making progress though!
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pride on May 13, 2011, 01:02:52 am
Added some more.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: LastingDawn on May 13, 2011, 01:07:58 am
Hmm about that "store weapon ID", the game gives the item to you right afterwards, is it preparing to give the item to the player with that?
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pride on May 13, 2011, 04:45:34 am
That's probably it... I've just never gone through Throw really so its basically new territory for me...

Added more to my post with more reaction checks and their triggers.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pride on May 14, 2011, 06:29:59 pm
Added a section on MP cost above
Title: Re: ASM Collective BATTLE.BIN Map
Post by: LastingDawn on May 15, 2011, 10:59:50 am
How curious? Is this what we will need to disable for monsters to use MP in their attacks?
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pride on May 16, 2011, 09:26:44 am
I can't say for certain but it does appear you may be able to enable monsters using mp here (the monster skill set being loaded into R18 suggest that). I won't know without testing it; which also wouldn't take long to test.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: LastingDawn on May 17, 2011, 11:19:29 pm
Hmm, has any delving of the Poison Status and the Silence Status been done? I've just noticed something (that's likely been noticed and noted long ago) is that the Status Effects with CT are only the last 16 statii, if Poison and Silence aren't that complicated perhaps we can switch their two functionality, with Silence taking the spot of Poison and Poison being in the spot that Silence was. It is my experience that one of the first changes people make to their personal hacks is to get rid of the CT on Poison to make it possibly worthy using somewhere along the lines.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pride on May 18, 2011, 12:15:41 am
I only know where the HP damage (and HP recovery from Regen) is for Poison. I have very little knowledge on the CT of status. (I think fdc might have more knowledge on it)
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Glain on May 18, 2011, 09:25:22 pm
So I was looking at some of the physical evasion stuff, and though it turns out SA had already documented most of what I looked at, I did find something fairly interesting. The last of the physical evade routines is the one that actually does the evasion roll, but my analysis of it would look like this:


00188488: 27bdffe8 addiu r29,r29,0xffe8
0018848c: afbf0010 sw r31,0x0010(r29)
00188490: 0c061605 jal 0x00185814               Combined evasion roll (Sets ability's hit status)
00188494: 00000000 nop
00188498: 3c028019 lui r2,0x8019
0018849c: 8c422d90 lw r2,0x2d90(r2)               
001884a0: 00000000 nop
001884a4: 90420000 lbu r2,0x0000(r2)            
001884a8: 00000000 nop
001884ac: 2c420001 sltiu r2,r2,0x0001            Find ability's evaded status (Why not just use 0x00185814's return value?)

001884b0: 8fbf0010 lw r31,0x0010(r29)
001884b4: 27bd0018 addiu r29,r29,0x0018
001884b8: 03e00008 jr r31                     RETURN r2 (Exactly the same as 0x00185814's return value)
001884bc: 00000000 nop                     


It looks like the entire call is worthless except for the call to another routine... they even return the same thing. I tried replacing the call to 0x188488 with a call to 0x185814 and everything still seemed to work fine, so this may free up some space to replace this code with something else.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pride on May 18, 2011, 10:49:29 pm
That's very interesting and nice find Glain (and unsurprising due to Square always wasting space) =P

Added the poison/regen affect hp routine above in my post.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: LastingDawn on May 19, 2011, 12:41:01 am
Hmm, seems pretty par for the course. I have a feeling that the Silence status will probably be a little more complicated than that. Good work.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Glain on May 24, 2011, 12:13:04 am
I talked to fdc a while back about looking at some of the evasion routines, and one thing we talked about was that there were several routines for different kinds of evasion... three called from formulas (physical, charge, and magic). And looking into that, there's another routine that finds the various evasion numbers (A-EV, S-EV, C-EV) within the physical/magic sections that's nearly duplicated, just that it grabs magic evade instead of physical evade for the magic sections. It also turns out that those routines are next to each other in BATTLE.BIN... which means, if we wrote one big routine, we could save some space... or if we decided to change one, we'd only have to change it in one place, in theory.

I came up with this as a combined routine for finding either physical or magic evade numbers (This was the test case I was using for my app, by the way). Here I'm using r4 ($a0) as the parameter (0=physical, 1=magic):



COMBINED EVASION NUMBERS ROUTINE
PARAMETERS: r4 = TYPE (0 = physical, 1 = magical)

# SETUP (r16 = TYPE)
addiu r29,r29,0xffe8
sw r31, 0x0010(r29)
sw r16, 0x0014(r29)
addu r16,r4,r0                              # r16 = r4
lui r4,0x8019
lw r4,0x2d98(r4)                           # r4 = [Target unit]         
bne r16,r0,(SECTION3)                        # Skip next section if Type==MAGIC
addu r7,r0,r0                              # r7 (Can use weapon guard) = 0 (false)

(SECTION2):                        # CHECK FOR WEAPON GUARD (PHYSICAL)
lbu r2,0x008e(r4)                              
nop
andi r2,r2,0x0040                           # r2 = [Reaction is Weapon Guard]   
beq r2,r0,(SECTION3)                           
nop            
jal 0x0018130c                              # CALL: Weapon Guard usability            
nop
sltiu r7,r2,0x0001                           # r7 = !r2                              

(SECTION3):                        # INITIALIZE
ori r2,r0,0x0064
lui r1,0x8019
sb r2,0x38dc(r1)                           # Hit rate = 100
lui r1,0x8019
sb r0,0x38de(r1)                           # A-EV = 0
lui r1,0x8019
sb r0,0x38df(r1)                           # R-EV = 0
lui r1,0x8019
sb r0,0x38e0(r1)                           # L-EV = 0
bne r16,r0,(SECTION3p1)                        
addu r2,r0,r0                               
lbu r2,0x0043(r4)                           

(SECTION3p1):                     # C-EV
lui r1,0x8019
sb r2,0x38e1(r1)                           # C-EV = (Type==MAGIC) ? 0 : [C-EV]
lbu r2,0x0006(r4)                                                   
nop
andi r2,r2,0x0020
bne r2,r0,(RETURN)                           # If target is monster, RETURN
nop

(SECTION4):                        # A-EV
lbu r2,0x001c(r4)
lui r5,0x8006
addiu r5,r5,0x2eb8
sll r3,r2,0x01
addu r3,r3,r2
sll r3,r3,0x02
addu r3,r3,r5
lbu r2,0x0003(r3)            
nop
andi r2,r2,0x0008
beq r2,r0,(SECTION5)                        # Skip A-EV if Accessory isn't actually an accessory
nop
lbu r2,0x0004(r3)
nop
sll r2,r2,0x01
lui r1,0x8006
addu r1,r1,r2
addu r1,r1,r16                              # Use magic evade (1 offset higher) if Type==MAGIC
lbu r2,0x3f58(r1)                           # r2 = [Accessory A-EV]
lui r1,0x8019
sb r2,0x38de(r1)                           # Save [A-EV]

(SECTION5):                        # R-EV (Right hand)
lbu r3,0x001d(r4)                           # r3 = [Right hand weapon of target unit]
nop
sll r2,r3,0x01
addu r2,r2,r3
sll r2,r2,0x02               
lui r1,0x8006
addu r1,r1,r2               
lbu r5,0x2ebb(r1)            
lbu r3,0x001e(r4)                           # r3 = [Right hand shield of target unit]
lbu r8,0x2ebc(r1)            
sll r2,r3,0x01
addu r2,r2,r3
sll r2,r2,0x02               
lui r1,0x8006
addu r1,r1,r2               
lbu r3,0x2ebb(r1)            
lbu r6,0x2ebc(r1)            
andi r2,r5,0x0080            
beq r2,r0,(SECTION5p1)                        # IF [Right hand weapon] not a weapon, skip to shield section
nop
beq r7,r0,(SECTION5p1)                        # IF [No weapon guard], skip to shield section
sll r2,r8,0x03
lui r1,0x8006
addu r1,r1,r2            
addu r1,r1,r16                              # Use magic evade if Type==MAGIC
lbu r2,0x3abd(r1)                           # r2 = [Right-hand weapon evade]
j (SECTION5p2)                              # Skip to save
nop

(SECTION5p1):                           # Shield section
andi r2,r3,0x0040            
beq r2,r0,(SECTION6)                        # IF [Right hand shield] not a shield, skip
sll r2,r6,0x01
lui r1,0x8006
addu r1,r1,r2
addu r1,r1,r16                              # Use magic evade if Type==MAGIC
lbu r2,0x3eb8(r1)                           # r2 = [Right-hand shield S-EV]

(SECTION5p2):                           # Save R-EV
lui r1,0x8019
sb r2,0x38df(r1)                           # Save [R-EV] (Right hand evade)

(SECTION6):                        # L-EV (Left hand)
lbu r3,0x001f(r4)                           # r3 = [Left hand weapon of target unit]
nop
sll r2,r3,0x01
addu r2,r2,r3
sll r2,r2,0x02               
lui r1,0x8006
addu r1,r1,r2               
lbu r5,0x2ebb(r1)            
lbu r3,0x0020(r4)                           # r3 = [Left hand shield of target unit]
lbu r8,0x2ebc(r1)            
sll r2,r3,0x01
addu r2,r2,r3
sll r2,r2,0x02               
lui r1,0x8006
addu r1,r1,r2               
lbu r3,0x2ebb(r1)                        
lbu r6,0x2ebc(r1)            
andi r2,r5,0x0080            
beq r2,r0,(SECTION6p1)                        # IF [Left hand weapon] not a weapon, skip to shield section
nop
beq r7,r0,(SECTION6p1)                        # IF [No weapon guard], skip to shield section
sll r2,r8,0x03
lui r1,0x8006
addu r1,r1,r2
addu r1,r1,r16                              # Use magic evade if Type==MAGIC
lbu r2,0x3abd(r1)                           # r2 = [Left-hand weapon evade]
j (SECTION6p2)                              # Skip to save
nop

(SECTION6p1):                           # Shield section   
andi r2,r3,0x0040            
beq r2,r0,(RETURN)                           # IF [Left hand shield] not a shield, skip
sll r2,r6,0x01
lui r1,0x8006
addu r1,r1,r2
addu r1,r1,r16                              # Use magic evade if Type==MAGIC
lbu r2,0x3eb8(r1)                           # r2 = [Left-hand shield S-EV]

(SECTION6p2):                           # Save L-EV
lui r1,0x8019
sb r2,0x38e0(r1)                           # Save [L-EV] (Left hand evade)

(RETURN):
lw r31,0x0010(r29)
lw r16,0x0014(r29)
addiu r29,r29,0x0018
jr r31                                    # RETURN
nop


That one is probably just about as big as the routine for physical evade was, so there'd be a decent chunk of space gained here (maybe 50-75 lines?), if we wanted to expand the routine.

Then there'd be the main evasion routine to combine:


COMBINED
PARAMETERS: (r4=TYPE (0=physical, 1=charge(physical), 2=magic))

addiu r29,r29,0xffe8
sw r31,0x0010(r29)
sw r16,0x0014(r29)
sw r17,0x000c(r29)
addu r16,r4,r0               # r16 = r4 (0=physical, 1=charge, 2=magic)
slti r17,r16,0x0002
slti r17,r17,0x0001            # r17 = (0=physical/charge, 1=magic)
jal 0x00184f9c               # Equipment Evasion Setting
addu r4,r17,r0               # (r4 == TYPE)
bne r17,r0,(SECTION2)            # IF (TYPE == MAGIC), skip
nop
jal 0x001852e4               # Concentrate Calculation (Attacker)
nop
jal 0x00185328               # Dark/Confuse/Transparent Calculation (Attacker)
nop

(SECTION2):
jal 0x0018537c               # Abandon Calculation (Defender)
nop
jal 0x001853f4               # Evasion Changes due to Status (Defender)
nop
bne r16,r0,(SECTION3)            # If (TYPE != PHYSICAL), skip
nop
jal 0x00185738               # Weather Effects on Bows/Crossbows
nop

(SECTION3):
bne r17,r0,(SECTION4)            # If (TYPE == MAGIC), skip
nop
jal 0x001854fc               # Facing Evade Calculation
nop

(SECTION4):
jal 0x00185814               # Combined Evasion Roll (Calculates Hit %)
nop
lw r31,0x0010(r29)
lw r16,0x0014(r29)
lw r17,0x000c(r29)
addiu r29,r29,0x0018
jr r31
nop


I also replaced the call to a function that did nothing but delegate to another function (which I mentioned earlier in the thread). This is basically a bunch of function calls, so I was just selecting which ones were needed. Here r4 ($a0) is the type parameter, but now is (0=physical, 1=charge, 2=magic).

Of course, that means all the formulas would have to specify r4's value before calling the combined evasion routine (0x188510). That's annoying but luckily there is a nop after each call to the evasion functions, so you could replace the nop with:

Physical: addu r4,r0,r0
Charge: addiu r4,r0,1
Magic: addiu r4,r0,2

A one-time patch could change them, but it's still annoying because new formulas would have to remember to follow that format. Anyhow, this is just an idea for how to consolidate these routines.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on May 24, 2011, 05:07:43 pm
Next routine:


lbu r4, 0x018C (r3) r4 = Target Hit Flag
lbu r5, 0x38F3 (r1) r5 = Ability Flag 1
beq r4, r0, (E) If attack doesn't hit/is negated, GOTO (E)
ori r6, r0, 0x0002
beq r4, r6, (UseAccuracy) If r4 =2 (if formula is % hit to cast status), GOTO (UseAccuracy)
andi r5, r5, 0x0040
bne r5, r0, (ProcCheck) ELSE, if the blank flag directly above Ranged Weapon is flagged, r8 = 100 and GOTO (ProcCheck)
ori r8, r0, 0x0064
j (ProcCheck) ELSE (if blank flag isn't flagged), r8 = 25 and GOTO (ProcCheck)
ori r8, r0, 0x0019
(UseAccuracy) j (ProcCheck) r8 = Attack Accuracy and GOTO (ProcCheck)
lbu r8, 0x01B6 (r3)
(ProcCheck) addu r9, r31, r0 r9 = r31 because r31 will be modified by the following routine.
jal (RNG) To get the random hit%, GOTO (RNG)
addiu r7, r0, 0x0064
lbu r4, 0x38F4 (r1) r4 = Ability Flags 2
slt r6, r7, r8
andi r4, r4, 0x0020
bne r6, r0, (Status/Spell) If RN < Chance, GOTO (Status/Spell)
lbu r5, 0x018C (r3) r6 = Target Hit Flag
ori r6, r0, 0x0002
lbu r7, 0x3906 (r1) r7 = Status Infliction Type Byte
beq r6, r5, (SetZero) If RN > Chance and hit type = 2 (variable hit rate), GOTO (SetZero)
nop
bne r4, r0, (E) If RN > Chance, hit type = 1 (already hit), and proc is spell, GOTO (E)
andi r7, r7, 0x0001
bne r7, r0, (SetZero) If RN > Chance, hit type = 1 (already hit), proc is status, and the 4th blank flag on inflict status is checked, GOTO (SetZero)
nop
j (E) If RN > Chance, hit type = 1 (already hit), proc is status and the 4th blank flag on inflict status isn't checked, GOTO (E)
(Status/Spell) ori r6, r0, 0x0001
bne r4, r0, (Spell) If RN < Chance, hit type = 1 (already hit), and if proc is spell, GOTO (Spell)
sb r6, 0x018C (r3)
j (Status) If RN < Chance, hit type = 1, and if proc is status, GOTO (Status)
nop


(RNG) lui r4, 0xA001
lw r5, -0x6FF0 (r4) Load random word.
lui r6, 0x41C6
addiu r6, r6, 0x4E6D
multu r5, r6
mflo r5
nop
addiu r5, r5, 0x3039
sw r5, -0x6FF0 (r4) Store new Random Word.
multu r7, r5
mfhi r7 r7 = {0...value(r7)-1}
jr 31 Return to Proc Status/Spell Routine
nop

Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on May 25, 2011, 05:09:24 am
All right, here's an interesting routine, with some hard-coded stuff many of us here would love to delete.


0017d4a0: 27bdffe8 addiu r29,r29,0xffe8
0017d4a4: 3c038019 lui r3,0x8019
0017d4a8: 8c63f5f0 lw r3,-0x0a10(r3)
0017d4ac: 34020001 ori r2,r0,0x0001
0017d4b0: afbf0014 sw r31,0x0014(r29)
0017d4b4: afb00010 sw r16,0x0010(r29)
0017d4b8: 3c018019 lui r1,0x8019
0017d4bc: a02238c2 sb r2,0x38c2(r1) Hit is normal hits, not multi-hit.
0017d4c0: 3c018019 lui r1,0x8019
0017d4c4: a02038c3 sb r0,0x38c3(r1) ???
0017d4c8: 3c018019 lui r1,0x8019
0017d4cc: a42038c8 sh r0,0x38c8(r1) No Spell Procs.
0017d4d0: 3c018019 lui r1,0x8019
0017d4d4: a02038ed sb r0,0x38ed(r1) Attack is not evaded?
0017d4d8: 14600009 bne r3,r0,0x0017d500 If RAM 0x18F5F0 isn't 0, GOTO RAM 0x17D500.
0017d4dc: 00002821 addu r5,r0,r0
0017d4e0: 3c018019 lui r1,0x8019
0017d4e4: a02038e8 sb r0,0x38e8(r1) ELSE, No Spell Procs (again).
0017d4e8: 3c018019 lui r1,0x8019
0017d4ec: a02038e7 sb r0,0x38e7(r1) No EXP bonus.
0017d4f0: 3c018019 lui r1,0x8019
0017d4f4: a020390c sb r0,0x390c(r1) ???
0017d4f8: 3c018019 lui r1,0x8019
0017d4fc: a020390d sb r0,0x390d(r1) ???
0017d500: 9082016f lbu r2,0x016f(r4) Load attack's Skillset ID.
0017d504: 3c018006 lui r1,0x8006
0017d508: 00220821 addu r1,r1,r2
0017d50c: 90265cb4 lbu r6,0x5cb4(r1) Load attack's menu type from SCUS.
0017d510: 3c018019 lui r1,0x8019
0017d514: a020f7ec sb r0,-0x0814(r1) Clear byte where Ability Flags are copied (one of many places).
0017d518: 9082001d lbu r2,0x001d(r4)
0017d51c: 3c018019 lui r1,0x8019
0017d520: a02238c4 sb r2,0x38c4(r1) RH Weapon is stored.
0017d524: 9082001f lbu r2,0x001f(r4)
0017d528: 3c038019 lui r3,0x8019
0017d52c: 906338c4 lbu r3,0x38c4(r3)
0017d530: 3c018019 lui r1,0x8019
0017d534: a02238c5 sb r2,0x38c5(r1) LH Weapon is stored.
0017d538: 340200ff ori r2,r0,0x00ff
0017d53c: 14620008 bne r3,r2,0x0017d560 If RH weapon exists, GOTO RAM 0x17D560.  This is what allows a RH Scorpion Tail and a LH iron sword to always count for 23 WP on holy explosion, even though it's really the WP of the sword that should count.
0017d540: 30c300ff andi r3,r6,0x00ff
0017d544: 9083001f lbu r3,0x001f(r4)
0017d548: 340200ff ori r2,r0,0x00ff
0017d54c: 3c018019 lui r1,0x8019
0017d550: a02238c5 sb r2,0x38c5(r1)
0017d554: 3c018019 lui r1,0x8019
0017d558: a02338c4 sb r3,0x38c4(r1) ELSE, LH weapon is set as primary weapon, and LH weapon byte = none.
0017d55c: 30c300ff andi r3,r6,0x00ff
0017d560: 34020002 ori r2,r0,0x0002
0017d564: 14620006 bne r3,r2,0x0017d580 If attack type isn't THROW, GOTO RAM 0x17D580
0017d568: 00000000 nop
0017d56c: 90820176 lbu r2,0x0176(r4)
0017d570: 3c018019 lui r1,0x8019
0017d574: a02238c4 sb r2,0x38c4(r1) If attack type is THROW, store thrown item and GOTO END.
0017d578: 0805f5bd j 0x0017d6f4
0017d57c: 00000000 nop
0017d580: 10600003 beq r3,r0,0x0017d590 If attack type is <Default>, GOTO RAM 0x17D590
0017d584: 34020006 ori r2,r0,0x0006
0017d588: 1462002b bne r3,r2,0x0017d638 If attack type isn't Monster, GOTO RAM 0x17D638
0017d58c: 30c300ff andi r3,r6,0x00ff
0017d590: 84830170 lh r3,0x0170(r4) If Attack type is <Default> or Monster, load attack ID.
0017d594: 00000000 nop
0017d598: 04610004 bgez r3,0x0017d5ac
0017d59c: 000310c0 sll r2,r3,0x03
0017d5a0: 28620170 slti r2,r3,0x0170
0017d5a4: 1040000b beq r2,r0,0x0017d5d4 If attack is after Potion, GOTO RAM 0x17D5D4
0017d5a8: 000310c0 sll r2,r3,0x03
0017d5ac: 00431023 subu r2,r2,r3
0017d5b0: 00021040 sll r2,r2,0x01
0017d5b4: 3c038006 lui r3,0x8006
0017d5b8: 2463fbf0 addiu r3,r3,0xfbf0
0017d5bc: 00431021 addu r2,r2,r3
0017d5c0: 90430003 lbu r3,0x0003(r2)
0017d5c4: 3c018019 lui r1,0x8019
0017d5c8: a023f7ec sb r3,-0x0814(r1) Store Ability Flags Byte 1
0017d5cc: 90500009 lbu r16,0x0009(r2) Load X
0017d5d0: 90450008 lbu r5,0x0008(r2) Load Formula
0017d5d4: 00000000 nop
0017d5d8: 24a2ffe2 addiu r2,r5,0xffe2
0017d5dc: 2c420002 sltiu r2,r2,0x0002
0017d5e0: 10400010 beq r2,r0,0x0017d624 If Formula is not Rafa's or Malak's, GOTO RAM 0x17D624.  This is the hard-coding of multi-hit for Rafa/Malak.
0017d5e4: 30a300ff andi r3,r5,0x00ff
0017d5e8: 3c028019 lui r2,0x8019
0017d5ec: 8c42f5fc lw r2,-0x0a04(r2)
0017d5f0: 00000000 nop
0017d5f4: 1440000c bne r2,r0,0x0017d628 ELSE if attack hits no one, GOTO RAM 0x17D628.  Because this is only checked once, multi-hit formulas will continue attacking even if all targets in range, including the caster, were killed.
0017d5f8: 3402005e ori r2,r0,0x005e
0017d5fc: 0c0088c3 jal 0x0002230c
0017d600: 00000000 nop
0017d604: 02020018 mult r16,r2
0017d608: 00001012 mflo r2
0017d60c: 04410002 bgez r2,0x0017d618
0017d610: 00000000 nop
0017d614: 24427fff addiu r2,r2,0x7fff
0017d618: 000213c3 sra r2,r2,0x0f
0017d61c: 0805f5bb j 0x0017d6ec ELSE (if Rafa/Malak formula hits), GOTO RAM 0x17D6EC and store r2 = RN{1...X+1}, the amount of hits.
0017d620: 24420001 addiu r2,r2,0x0001
0017d624: 3402005e ori r2,r0,0x005e
0017d628: 14620003 bne r3,r2,0x0017d638 If Formula is not Triple Thunder/Flame's, GOTO RAM 0x17D638.  This is the hard-coding of multi-hit for Triple Flame/Thunder.
0017d62c: 30c300ff andi r3,r6,0x00ff
0017d630: 0805f5bb j 0x0017d6ec  If it is, GOTO RAM 0x17D6EC and store X+1, the amount of hits.  Because there is no corresponding check (like Rafa/Malak) to see if you actually hit anything in the AoE, it is possible to have the animation appear even if nothing is in the AoE.
0017d634: 26020001 addiu r2,r16,0x0001
0017d638: 34020009 ori r2,r0,0x0009
0017d63c: 1062002d beq r3,r2,0x0017d6f4 If attack type is Jump, GOTO END.
0017d640: 34020008 ori r2,r0,0x0008
0017d644: 10620009 beq r3,r2,0x0017d66c
0017d648: 3402000a ori r2,r0,0x000a
0017d64c: 10620007 beq r3,r2,0x0017d66c If attack type is Attack or Charge, GOTO RAM 0x17D66C
0017d650: 00000000 nop
0017d654: 3c028019 lui r2,0x8019
0017d658: 9042f7ec lbu r2,-0x0814(r2)
0017d65c: 00000000 nop
0017d660: 30420020 andi r2,r2,0x0020
0017d664: 10400023 beq r2,r0,0x0017d6f4
0017d668: 00000000 nop
0017d66c: 9082005a lbu r2,0x005a(r4) Attack type here is Attack, Charge, or has Ranged Weapon.
0017d670: 90850091 lbu r5,0x0091(r4)
0017d674: 30420002 andi r2,r2,0x0002
0017d678: 14400006 bne r2,r0,0x0017d694 If attacker is frogged, GOTO RAM 0x17D694
0017d67c: 340200ff ori r2,r0,0x00ff
0017d680: 90820006 lbu r2,0x0006(r4)
0017d684: 00000000 nop
0017d688: 30420020 andi r2,r2,0x0020
0017d68c: 10400005 beq r2,r0,0x0017d6a4 If attacker is not a monster, GOTO RAM 0x17D6A4
0017d690: 340200ff ori r2,r0,0x00ff
0017d694: 3c018019 lui r1,0x8019
0017d698: a02238c4 sb r2,0x38c4(r1) If attacker is frogged or is a monster, RH Weapon = none.
0017d69c: 3c018019 lui r1,0x8019
0017d6a0: a02238c5 sb r2,0x38c5(r1) If attacker is frogged or is a monster, LH Weapon = none.
0017d6a4: 3c048019 lui r4,0x8019
0017d6a8: 248438c4 addiu r4,r4,0x38c4
0017d6ac: 94830000 lhu r3,0x0000(r4)
0017d6b0: 3402ffff ori r2,r0,0xffff
0017d6b4: 1062000a beq r3,r2,0x0017d6e0
0017d6b8: 340300ff ori r3,r0,0x00ff
0017d6bc: 90820000 lbu r2,0x0000(r4)
0017d6c0: 00000000 nop
0017d6c4: 1043000b beq r2,r3,0x0017d6f4
0017d6c8: 00000000 nop
0017d6cc: 3c028019 lui r2,0x8019
0017d6d0: 904238c5 lbu r2,0x38c5(r2)
0017d6d4: 00000000 nop
0017d6d8: 10430006 beq r2,r3,0x0017d6f4
0017d6dc: 00000000 nop
0017d6e0: 30a20001 andi r2,r5,0x0001
0017d6e4: 10400003 beq r2,r0,0x0017d6f4
0017d6e8: 34020002 ori r2,r0,0x0002
0017d6ec: 3c018019 lui r1,0x8019
0017d6f0: a02238c2 sb r2,0x38c2(r1) Store number of hits from multi-hit or two swords.
0017d6f4: 8fbf0014 lw r31,0x0014(r29)
0017d6f8: 8fb00010 lw r16,0x0010(r29)
0017d6fc: 27bd0018 addiu r29,r29,0x0018
0017d700: 03e00008 jr r31
0017d704: 00000000 nop

Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pride on May 25, 2011, 06:08:32 pm
Ramza causes game over?


00180b2c: 27bdffe0 addiu r29,r29,0xffe0      
00180b30: 2c820080 sltiu r2,r4,0x0080      
00180b34: afbf001c sw r31,0x001c(r29)      
00180b38: afb20018 sw r18,0x0018(r29)      
00180b3c: afb10014 sw r17,0x0014(r29)      
00180b40: 14400005 bne r2,r0,0x00180b58      
00180b44: afb00010 sw r16,0x0010(r29)      
00180b48: 0806031d j 0x00180c74         
00180b4c: 2402ffff addiu r2,r0,0xffff      
00180b50: 0806031d j 0x00180c74         
00180b54: 2402fffe addiu r2,r0,0xfffe      
00180b58: 00008021 addu r16,r0,r0      
00180b5c: 340600ff ori r6,r0,0x00ff      R6 = FF
00180b60: 308500ff andi r5,r4,0x00ff      
00180b64: 3c038019 lui r3,0x8019      
00180b68: 246308cc addiu r3,r3,0x08cc      Load Unit Data
00180b6c: 90620001 lbu r2,0x0001(r3)      Unit ID
00180b70: 00000000 nop            
00180b74: 10460011 beq r2,r6,0x00180bbc      Branch if unit ID is FF (doesn't exist)?
00180b78: 00000000 nop            
00180b7c: 90620000 lbu r2,0x0000(r3)      Load Sprite Set
00180b80: 00000000 nop            
00180b84: 1445000d bne r2,r5,0x00180bbc      Branch if Sprite set isn't Ramza (01 - 03)?
00180b88: 00000000 nop            
00180b8c: 90620058 lbu r2,0x0058(r3)      Load 1st Set of Current Status
00180b90: 00000000 nop            
00180b94: 30420040 andi r2,r2,0x0040      
00180b98: 14400006 bne r2,r0,0x00180bb4      Branch if in Crystal Status
00180b9c: 00000000 nop            
00180ba0: 90630059 lbu r3,0x0059(r3)      Load 2nd Set of Current Status
00180ba4: 00000000 nop            
00180ba8: 30630001 andi r3,r3,0x0001      
00180bac: 10600031 beq r3,r0,0x00180c74      Branch to end if not in Treasure Status
00180bb0: 02001021 addu r2,r16,r0      
00180bb4: 0806031d j 0x00180c74         
00180bb8: 2402fffd addiu r2,r0,0xfffd      
00180bbc: 26100001 addiu r16,r16,0x0001      
00180bc0: 2a020015 slti r2,r16,0x0015      
00180bc4: 1440ffe9 bne r2,r0,0x00180b6c      
00180bc8: 246301c0 addiu r3,r3,0x01c0      
00180bcc: 00008021 addu r16,r0,r0      
00180bd0: 340800ff ori r8,r0,0x00ff      R8 = FF
00180bd4: 308600ff andi r6,r4,0x00ff      
00180bd8: 34070080 ori r7,r0,0x0080      
00180bdc: 3c038019 lui r3,0x8019      
00180be0: 246308cc addiu r3,r3,0x08cc      Load Unit Data
00180be4: 90650001 lbu r5,0x0001(r3)      Load Unit ID
00180be8: 00000000 nop            
00180bec: 14a8000d bne r5,r8,0x00180c24      
00180bf0: 26100001 addiu r16,r16,0x0001      
00180bf4: 90620000 lbu r2,0x0000(r3)      Load Sprite Set
00180bf8: 00000000 nop            
00180bfc: 1446000a bne r2,r6,0x00180c28      
00180c00: 2a020015 slti r2,r16,0x0015      
00180c04: 90620183 lbu r2,0x0183(r3)      
00180c08: 00000000 nop            
00180c0c: 10450005 beq r2,r5,0x00180c24      
00180c10: 00000000 nop            
00180c14: 1040ffce beq r2,r0,0x00180b50      
00180c18: 00000000 nop            
00180c1c: 10470015 beq r2,r7,0x00180c74      
00180c20: 2402fffd addiu r2,r0,0xfffd      
00180c24: 2a020015 slti r2,r16,0x0015      
00180c28: 1440ffee bne r2,r0,0x00180be4      
00180c2c: 246301c0 addiu r3,r3,0x01c0      
00180c30: 00008021 addu r16,r0,r0      
00180c34: 341200ff ori r18,r0,0x00ff      
00180c38: 309100ff andi r17,r4,0x00ff      
00180c3c: 0c0166bc jal 0x00059af0      
00180c40: 02002021 addu r4,r16,r0      
00180c44: 00401821 addu r3,r2,r0      
00180c48: 90620001 lbu r2,0x0001(r3)      Load Unit ID
00180c4c: 00000000 nop            
00180c50: 10520005 beq r2,r18,0x00180c68      
00180c54: 26100001 addiu r16,r16,0x0001      
00180c58: 90620000 lbu r2,0x0000(r3)      Load Sprite Set
00180c5c: 00000000 nop            
00180c60: 10510004 beq r2,r17,0x00180c74   
00180c64: 2402fffc addiu r2,r0,0xfffc      
00180c68: 2a020014 slti r2,r16,0x0014      
00180c6c: 1440fff3 bne r2,r0,0x00180c3c      
00180c70: 2402fffb addiu r2,r0,0xfffb      
00180c74: 8fbf001c lw r31,0x001c(r29)      
00180c78: 8fb20018 lw r18,0x0018(r29)      
00180c7c: 8fb10014 lw r17,0x0014(r29)      
00180c80: 8fb00010 lw r16,0x0010(r29)      
00180c84: 27bd0020 addiu r29,r29,0x0020      
00180c88: 03e00008 jr r31         
00180c8c: 00000000 nop            
Title: Re: ASM Collective BATTLE.BIN Map
Post by: LastingDawn on May 25, 2011, 06:25:22 pm
Looks to be. Is that looking at a range, of 1-3 or is it saying 01,02,03? If it is digit based I would really like to change one to 022 (for Rad)
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on May 25, 2011, 07:32:43 pm
OK, here's another interesting routine.


00187ca0: 3c068019 lui r6,0x8019
00187ca4: 8cc62d90 lw r6,0x2d90(r6)
00187ca8: 27bdffe8 addiu r29,r29,0xffe8
00187cac: afbf0010 sw r31,0x0010(r29)
00187cb0: 90c20025 lbu r2,0x0025(r6)
00187cb4: 00000000 nop
00187cb8: 30420080 andi r2,r2,0x0080
00187cbc: 10400079 beq r2,r0,0x00187ea4 If not HP Damage, GOTO END.
00187cc0: 00000000 nop
00187cc4: 3c058019 lui r5,0x8019
00187cc8: 8ca52d98 lw r5,0x2d98(r5)
00187ccc: 84c20004 lh r2,0x0004(r6)
00187cd0: 94a30028 lhu r3,0x0028(r5)
00187cd4: 84c40006 lh r4,0x0006(r6)
00187cd8: 00621823 subu r3,r3,r2 r3 = Target HP - HP Damage
00187cdc: 90a20006 lbu r2,0x0006(r5)
00187ce0: 00000000 nop
00187ce4: 304200c0 andi r2,r2,0x00c0
00187ce8: 1440006e bne r2,r0,0x00187ea4 GOTO END if target is not monster.
00187cec: 00642021 addu r4,r3,r4 r4 = Target HP - HP Damage + HP Healing
00187cf0: 90a201ba lbu r2,0x01ba(r5)
00187cf4: 00000000 nop
00187cf8: 30420030 andi r2,r2,0x0030
00187cfc: 000210c2 srl r2,r2,0x03
00187d00: 3c018019 lui r1,0x8019
00187d04: 00220821 addu r1,r1,r2
00187d08: 9422f5f4 lhu r2,-0x0a0c(r1)
00187d0c: 00000000 nop
00187d10: 10400007 beq r2,r0,0x00187d30 ELSE, if r2 = 0, skip Normal Attack Check.
00187d14: 00000000 nop
00187d18: 3c028019 lui r2,0x8019
00187d1c: 904238f5 lbu r2,0x38f5(r2)
00187d20: 00000000 nop
00187d24: 30420008 andi r2,r2,0x0008
00187d28: 1440005e bne r2,r0,0x00187ea4 If r2 = ??? (has something to do with if the monster is always there, randomly there, or both) and normal attack, GOTO END.
00187d2c: 00000000 nop
00187d30: 94a20058 lhu r2,0x0058(r5)
00187d34: 00000000 nop
00187d38: 30428020 andi r2,r2,0x8020
00187d3c: 14400059 bne r2,r0,0x00187ea4 If target is petrified or dead, GOTO END....(you would think this was included in the weapon formulas themselves).
00187d40: 00000000 nop
00187d44: 90a2005b lbu r2,0x005b(r5)
00187d48: 00000000 nop
00187d4c: 30420001 andi r2,r2,0x0001
00187d50: 14400054 bne r2,r0,0x00187ea4 If target has wall, GOTO END.
00187d54: 00000000 nop
00187d58: 18800006 blez r4,0x00187d74 If enemy HP is 0 or less, GOTO RAM 0x187D74
00187d5c: 00000000 nop
00187d60: 90c2001b lbu r2,0x001b(r6)
00187d64: 00000000 nop
00187d68: 30420020 andi r2,r2,0x0020
00187d6c: 10400021 beq r2,r0,0x00187df4 If dead isn't being added, GOTO RAM 0x187DF4
00187d70: 00000000 nop
00187d74: 3c028019 lui r2,0x8019
00187d78: 8c422d94 lw r2,0x2d94(r2)
00187d7c: 00000000 nop
00187d80: 90420091 lbu r2,0x0091(r2)
00187d84: 00000000 nop
00187d88: 30420040 andi r2,r2,0x0040
00187d8c: 10400019 beq r2,r0,0x00187df4 If monster is killed, but attacker doesn't have secret hunt, GOTO RAM 0x187DF4
00187d90: 00000000 nop
00187d94: 90a20005 lbu r2,0x0005(r5)
00187d98: 00000000 nop
00187d9c: 30420004 andi r2,r2,0x0004
00187da0: 14400014 bne r2,r0,0x00187df4 If monster is killed, but monster has immortal, GOTO RAM 0x187DF4
00187da4: 00000000 nop
00187da8: 90a20003 lbu r2,0x0003(r5)
00187dac: 00000000 nop
00187db0: 2442ffa2 addiu r2,r2,0xffa2
00187db4: 2c420030 sltiu r2,r2,0x0030
00187db8: 1040003a beq r2,r0,0x00187ea4 If monster is killed, but monster is not poachable, GOTO END.
00187dbc: 00000000 nop
00187dc0: 0c062f4d jal 0x0018bd34 Disable second attack?
00187dc4: 00000000 nop
00187dc8: 0c062f3c jal 0x0018bcf0 Disable spell proc.
00187dcc: 00000000 nop
00187dd0: 3c028019 lui r2,0x8019
00187dd4: 8c422d90 lw r2,0x2d90(r2)
00187dd8: 00000000 nop
00187ddc: 94430010 lhu r3,0x0010(r2)
00187de0: 00000000 nop
00187de4: 34630020 ori r3,r3,0x0020
00187de8: a4430010 sh r3,0x0010(r2) Store attack type as poaching.
00187dec: 08061fa7 j 0x00187e9c GOTO END and end of turn effect is poach.
00187df0: 34020006 ori r2,r0,0x0006
00187df4: 1880002b blez r4,0x00187ea4 Check (again) if target has 0 or less HP and GOTO END if true.
00187df8: 3c03cccc lui r3,0xcccc
00187dfc: 3c028019 lui r2,0x8019
00187e00: 8c422d98 lw r2,0x2d98(r2)
00187e04: 00000000 nop
00187e08: 9442002a lhu r2,0x002a(r2)
00187e0c: 3463cccd ori r3,r3,0xcccd
00187e10: 00430019 multu r2,r3
00187e14: 00001010 mfhi r2
00187e18: 00021082 srl r2,r2,0x02
00187e1c: 3042ffff andi r2,r2,0xffff
00187e20: 0044102a slt r2,r2,r4
00187e24: 1440001f bne r2,r0,0x00187ea4 GOTO END if monster's HP > 20% of maxHP.
00187e28: 00000000 nop
00187e2c: 3c028019 lui r2,0x8019
00187e30: 8c422d94 lw r2,0x2d94(r2)
00187e34: 00000000 nop
00187e38: 90420091 lbu r2,0x0091(r2)
00187e3c: 00000000 nop
00187e40: 30420080 andi r2,r2,0x0080
00187e44: 10400017 beq r2,r0,0x00187ea4 ELSE, GOTO END if the attacker doesn't have train.
00187e48: 00002021 addu r4,r0,r0
00187e4c: 3c038019 lui r3,0x8019
00187e50: 8c632d90 lw r3,0x2d90(r3)
00187e54: 00000000 nop
00187e58: 9062001c lbu r2,0x001c(r3)
00187e5c: 00000000 nop
00187e60: 34420040 ori r2,r2,0x0040
00187e64: 0c0612c9 jal 0x00184b24 ELSE, +Invite to monster, but also run routine to make sure it's not nullified (shouldn't this be done earlier)?
00187e68: a062001c sb r2,0x001c(r3)
00187e6c: 1040000d beq r2,r0,0x00187ea4 If nullified, GOTO END.
00187e70: 00000000 nop
00187e74: 3c048019 lui r4,0x8019
00187e78: 8c842d90 lw r4,0x2d90(r4)
00187e7c: 00000000 nop
00187e80: 94820010 lhu r2,0x0010(r4)
00187e84: 90830025 lbu r3,0x0025(r4)
00187e88: 34420040 ori r2,r2,0x0040
00187e8c: 34630008 ori r3,r3,0x0008
00187e90: a4820010 sh r2,0x0010(r4) Attack type is add status.
00187e94: 34020009 ori r2,r0,0x0009
00187e98: a0830025 sb r3,0x0025(r4) Attack type is add status.
00187e9c: 3c018019 lui r1,0x8019
00187ea0: a022390e sb r2,0x390e(r1) End of turn effect is whatever r2 is (6 is poach, 9 is tame).
00187ea4: 8fbf0010 lw r31,0x0010(r29)
00187ea8: 27bd0018 addiu r29,r29,0x0018
00187eac: 03e00008 jr r31
00187eb0: 00000000 nop
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RandMuadDib on June 07, 2011, 03:05:18 pm
So I was thinking about new abilities and was looking at infamous (#2 came out today) and shockwave caught my attention, being able to fliing multiple opponents. I took a look at your knockback routine, but I'm bad at interpreting code. Will it allow knockback when there are multiple targets?
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Celdia on June 08, 2011, 08:25:07 am
@FDC: I was looking to rewrite formula 5E to replace PA for every instance of MA and found you had the formula flagged as a clone of 1E. Surprise, surprise, I come in here and find out you've got this
0017d628: 14620003 bne r3,r2,0x0017d638 If Formula is not Triple Thunder/Flame's, GOTO RAM 0x17D638.  This is the hard-coding of multi-hit for Triple Flame/Thunder.

already figured out. I just need to make sure that I'm reading everything right and that its not actually calling 1E's code so that I can change 5E without altering 1E.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Glain on June 08, 2011, 11:40:28 pm
Quote from: Celdia on June 08, 2011, 08:25:07 am
@FDC: I was looking to rewrite formula 5E to replace PA for every instance of MA and found you had the formula flagged as a clone of 1E. Surprise, surprise, I come in here and find out you've got this already figured out. I just need to make sure that I'm reading everything right and that its not actually calling 1E's code so that I can change 5E without altering 1E.


I can probably comment on this as I've done a few formula hacks.

It's not that 1E and 5E necessarily have anything to do with each other, except that they both call a common routine... the one that calculates damage. That is, all the work in calculating damage is done here (in both formulas):

0c062269 jal 0x001889a4   Truth Formula

As far as I can tell, changing 5E without changing 1E would mean you'd either have to create a new routine for 5E to call, or edit the existing one to take a parameter that can tell it whether to use PA or MA.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pride on June 09, 2011, 12:17:21 am
Just reaffirming what glain said. I'll write you the new routine if you would like.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pride on June 09, 2011, 04:20:07 am
Double posting ftw

Very early in the thread fdc offers a formula 07 "fix" to add status and elemental properties (Click here to see his post (http://ffhacktics.com/smf/index.php?topic=6538.msg136729#msg136729)) but celdia pointed out it was bugged so... here is a semi fixed version of it. Its not a complete fix because if you absorb the element you are healing you'll always miss your target. Other then that though... Its fine. It also assumes you are using his other formula consolidation found in that post.

0x121C50

E8FFBD27
1000BFAF
8E21060C
00000000
D41C060C
00000000
AD1F060C
00000000
1000BF8F
1800BD27
0800E003
00000000

0x12862C

508C

If you aren't using his other formula fixes then put the edit at 0x121d3c and don't change 0x12862c.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Mando on June 09, 2011, 01:47:41 pm
Just to clarify, this fix above pride, will miss if you attack someone that can absorb the element of your skill?

(I normally don't apply the formula fix because I change skills that are element involved to another formula)
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pride on June 09, 2011, 02:18:24 pm
Only for formula 07.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Celdia on June 11, 2011, 05:23:25 pm
Okay, so I ran into a snag I didn't foresee in my design stages and figured you guys could figure this one out. I think Glain's post at the top of this page actually might have the answer in it technically. Its another one of my simple ideas that I don't think applies so simply behind the code.

I made Platina Shield into an Armlet Type item, making it equipable by everyone in their Hand slots. The equip preview displays correctly but the item won't apply any evasion % to the unit its equipped on. I want it to apply Armlet-type Item Evade % to Shield Evade on the unit. I'm wondering if my problem is something like the notation in (SECTION 4) "# Skip A-EV if Accessory isn't actually an accessory" causing it to ignore the evasion on the item because its claiming to be a shield but isn't.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Glain on June 11, 2011, 09:01:26 pm
Quote from: Celdia on June 11, 2011, 05:23:25 pm
Okay, so I ran into a snag I didn't foresee in my design stages and figured you guys could figure this one out. I think Glain's post at the top of this page actually might have the answer in it technically. Its another one of my simple ideas that I don't think applies so simply behind the code.

I made Platina Shield into an Armlet Type item, making it equipable by everyone in their Hand slots. The equip preview displays correctly but the item won't apply any evasion % to the unit its equipped on. I want it to apply Armlet-type Item Evade % to Shield Evade on the unit. I'm wondering if my problem is something like the notation in (SECTION 4) "# Skip A-EV if Accessory isn't actually an accessory" causing it to ignore the evasion on the item because its claiming to be a shield but isn't.


It looks like that could happen if Platina Shield no longer had the Shield checkbox selected in FFTPatcher (to the right of item type).
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Celdia on June 13, 2011, 03:10:42 am
What do those checkboxes actually affect in the upper right? I tried a few variations on them and nothing seemed to change anywhere.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Glain on June 13, 2011, 08:20:49 pm
The checkboxes are what the evade ASM is checking when it does the whole "Skip A-EV if accessory slot isn't an accessory" kind of thing. I thought that might be why the evasion was being skipped, but it seems that's not the case.

There's another funky thing about the left/right hand slots. In battle, it's stored like: ([Right hand weapon], [Right hand shield], [Left hand weapon], [Left hand shield]). All as separate slots. Anything that doesn't apply is just set to [Empty]. So if a character had a weapon and a shield, it would be: ([Equipped Weapon], [Empty], [Empty], [Equipped Shield]).

I set up a quick scenario like this, using Gold Shield as the armlet-type shield and put it on Mustadio, and ran it in the pSX debugger. What I saw in memory for Mustadio's equipment was this:

[Left hand weapon] = [Romanda Gun]
[Left hand shield] = [Empty]
[Right hand weapon] = [Gold Shield]
[Right hand shield] = [Empty]

...Oops. The obvious guess would be that switching the item type made the game believe that the Gold Shield belonged in the weapon slot instead of the shield slot. It's got me a bit curious, so I may look into it later.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on June 14, 2011, 06:45:35 pm
OK, considering how crammed I was for register space in writing my Knockback and Elemental routines (both of which have bugs, by the way), as well as my repeated calling of AI flags, I'm going to rewrite my formula hack to save more space by using the Stack Pointer.

Very start of any formula routine:

addiu r29, r29, 0xFFEC
sw r16, 0x0000 (r29)
sw r17, 0x0004 (r29)
sw r18, 0x0008 (r29)
sw r19, 0x000C (r29)
sw r20, 0x0010 (r29)
lui r16, 0x8019 r16 = 0x190000
lw r17, 0x2D94 (r16) r17 = Attacker Offset
lw r18, 0x2D98 (r16) r18 = Defender Offset
lhu r19, 0x38D6 (r16)
lui r20, 0x8006
sll r19, r19, 0x03
addu r19, r20, r19
lbu r19, -0x1410 (r19) r19 = AI flags; r20 will be used as a r31 replacement for complicated mechanics routines that call subroutines
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on June 18, 2011, 09:13:01 am
This will be more than a simple register swap.  I intend to add a new flag that lets you use the foe's stats instead of your own (in the XA1/YA3 position).

NOTE: The following assumes you are using Xifanie's Ability Requirement Hack (latest version).

lbu r3, 0x38F9 (r16) Loads X
lbu r1, 0x38F6 (r16) r1 = Ability Flags Byte 4
addiu r6, r16, 0x38CE r6 = XA1's address
addiu r7, r16, 0x38D0 r7 = XA2's address
andi r3, r3, 0x000F r3 = the last 4 bits of X
andi r1, r1, 0x0008 r1 = 8 if "Require Sword" is checked, ELSE r1 = 0
(LS) addu r2, r17, r0 r2 = Attacker's data address
beq r6, r7 (CS) If r6 = r7, GOTO Calculation Start.
sltiu r4, r3, 0x0004
beq r1, r0, (CS) If blank flag under "Hit Allies" is not checked, GOTO Calculation Start.
nop
addu r2, r18, r0 r2 = Defender's data address
lhu r8, 0x003c (r2)  r8 = Defender WP1 and WP2
(CS) bne r4, r0, (*) If r3 < 4, GOTO (*)
lbu r5, 0x0036 (r2) r5 = Attacker/Defender PA
sltiu r4, r3, 0x0008
bne r4, r0, (*) If r3 < 8, GOTO (*)
lbu r5, 0x0037 (r2) r5 = Attacker/Defender MA
sltiu r4, r3, 0x000C
bne r4, r0, (*) If r3 < 12, GOTO (*)
lbu r5, 0x0038 (r2)  r5 = Attacker/Defender SP
beq r6, r7 (*) If r6 = r7, GOTO (*).
lbu r5, 0x3902 (r16)  r5 = Attacker WP
beq r1, r0, (*) If blank flag under "Hit Allies" is not checked, GOTO (*).
andi r9, r8, 0x00FF  r9 = Defender WP1
srl r8, r8, 0x08  r8 = Defender WP2
sltiu r5, r9, r8  r5 = 1 if Defender WP1 < WP2, ELSE, r5 = 0.
bne r5, r0, (*) If Defender WP1 < WP2, GOTO (*).
addu r5, r8, r0  r5 = Defender WP2.
addu r5, r9, r0  ELSE, r5 = Defender WP1.
(*) beq r6, r7, (E) If r6 = r7, GOTO  End.
sb r5, 0x0000 (r6) Stores r5 at the address of r6
andi r3, r3, 0x0003
sll r3, r3, 0x0002
addiu r3, r3, 0x0001 The purpose of these r3 manipulations is to put r3 in a form that the previous loop can understand.
j (LS) Jumps back to the Loop's Start.
addiu r6, r6, 0x0002 r6 = r6 + 2 = r7 = XA2's address
(E) jr 31 Returns to the Main Formula Routine.
nop

SCUS
0x4CE24
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000


ori r4, r0, 0x0005
beq r3, r4, (E) NOTE: r3 can only be 1, 5, 9, or 13, which corresponds to PA, MA, SP, WP.  If XA2 is MA, GOTO (E)
lbu r6, 0x005C (r18) Load Status Byte 5.
lbu r7, 0x0058 (r18) Load Status Byte 1.
lbu r5, 0x005A (r18) Load Status Byte 3.
lhu r4, 0x38D0 (r16) Load XA2.
andi r6, r6, 0x0010
bne r6, r0, (Mult) If target is asleep, GOTO (Mult)
andi r7, r7, 0x0008
bne r7, r0, (Mult) If target is charging, GOTO (Mult)
andi r5, r5, 0x0006
beq r5, r0, (E) If target isn't chickened/frogged, GOTO (E)
(Mult) srl r5, r4, 0x01 r5 = [XA2/2]
addu r4, r4, r5 XA2 = XA2 + [XA2/2]
sh r4, 0x38D0 (r16) Store XA2.
(E) jr 31 Return to Main Routine
nop

addu r20, r31, r0 Stores the return address in r20 because it'll be modified by the jal commands below.
ori r4, r0, 0x0005
beq r4, r3, (MA) NOTE: r3 can only be 1, 5, 9, or 13, which corresponds to PA, MA, SP, WP.  If r3 is MA, GOTO (MA)
lhu r7, 0x38D0 (r16) Loads XA2
ori r4, r0, 0x000D
bne r4, r3, (PA/SP) If r3 isn't WP, GOTO (PA/SP)
lbu r5, 0x38D9 (r16)  Loads the "Two Hands" byte.
jal (WP-UP) If WP, GOTO  (WP-UP)
lbu r4, 0x38FF (r16) Loads weapon characteristic byte.
(PA/SP) jal (P-UP) If PA/SP, GOTO (P-UP)
lbu r3, 0x38D8 (r16) Loads Weapon Type byte.
j (E1) GOTO (E1)
nop
(MA) jal (M-UP) If MA, GOTO (M-UP)
lbu r3, 0x0090 (r17) Loads Support Byte 4.
(E1) jr 20 Return to Main Routine
nop

(WP-UP)beq r5, r0, (E2) If not using two-hands, GOTO  (E2)
andi r3, r4, 0x0001
bne r3, r0, (E2) If weapon is forced two-hands, GOTO  (E2)
andi r3, r4, 0x0004
beq r3, r0, (E2) If weapon is not two-handable, GOTO  (E2)
sll r6, r7, 0x01
sh r6, 0x38D0 (r16) If 2H is used and XA2 is WP, XA2 = XA2 * 2.
(E2) jr 31
nop
(P-UP) lbu r4, 0x0091 (r17) Loads Support Byte 5.
bne r3, r0, (A-UP)  If equipping a weapon, GOTO (A-UP)
andi r4, r4, 0x0020
beq r4, r0, (A-UP) If Martial Arts isn't used, GOTO (A-UP)
srl r6, r7, 0x01
addu r6, r7, r6
sh r6, 0x38D0 (r16) If Martial Arts is used and XA2 is PA or SP, XA2 = XA2 + [XA2/2].
(A-UP) lbu r3, 0x0090 (r2) Loads Support Byte 4.
lui r4, 0x5555  r4 = 55550000.
andi r5, r3, 0x0010
beq r5, r0, (E3)  If Attack Up isn't used, GOTO (E3)
(Mult) addiu r4, r4, 0x5556 r4 = 55555556 as a multiplier against FFFFFFFF.  In simple terms, this is 1/3.
sll r3, r7, 0x02
mult r4, r3 Term on HI is XA2 * 4 * 1/3.
sra r3, r3, 0x1F r3 = 0.
mfhi r4
subu r4, r4, r3 r4 = r4 - 0.
sh r4, 0x38D0 (r16)  If ATTACK or MAGIC ATTACK UP is flagged, XA2 = XA2 * 4/3.
(E3) jr r31
nop

(M-UP)lui r4, 0x5555  r4 = 55550000.
andi r5, r3, 0x0004
beq r5, r0, (E3) If Magic Attack Up isn't used, GOTO (E3)
nop
j (Mult) GOTO (Mult)
nop


lhu r7, 0x38CE (r1) Loads XA1
lbu r4, 0x38E5 (r1) Loads Formula
lbu r3, 0x38FA (r1) Loads Y
addiu r5, r0, 0x0008
beq r5, r4, (F8) If Formula 8 (I'll change this to some other number later), GOTO (F8).
addiu r6, r0, 0x0009
beq r6, r4, (F9) If Formula 9 (I'll change this to some other number later), GOTO (F9).
addiu r5, r0, 0x000A
beq r5, r4, (FA) If Formula A (I'll change this to some other number later), GOTO (FA).
addiu r6, r0, 0x000B
beq r6, r4, (FB) If Formula B (I'll change this to some other number later), GOTO (FB).
addu r7, r7, r3 r7 = XA1 + Y
lhu r4, 0x38D0 (r1) r4 = XA2
nop
addu r4, r7, r4
jr 31 Return to Main Routine
sb r4, 0x38D0 (r1) XA2 = XA1 + XA2 + Y
(FB) srl r7, r7, 0x01 XA1 = (XA1 + Y) / 2
j (E)
(FA) srl r6, r3, 0x03 r6 = [Y/8]
andi r3, r3, 0x0007 r3 = last 3 bits of Y
beq r3, r0, (Calc)
lbu r5, 0x0036 (r2) r5 = PA if r3 = 0
addiu r4, r0, 0x0001
beq r3, r4, (Calc)
lbu r5, 0x0037 (r2) r5 = MA if r3 = 1
addiu r4, r0, 0x0002
beq r3, r4, (Calc)
lbu r5, 0x0038 (r2) r5 = SP if r3 = 2
addiu r4, r0, 0x0003
beq r3, r4, (Calc)
lbu r5, 0x3902 (r1) r5 = WP if r3 = 3
addiu r4, r0, 0x0004
beq r3, r4, (Div4)
lbu r5, 0x0022 (r2) r5 = LVL if r3 = 4
addiu r4, r0, 0x0005
beq r3, r4, (Check)
addu r5, r2, 0x003E Readies the check where r5 = WEV1 if r3 = 5
addiu r4, r0, 0x0006
beq r3, r4, (Check)
addu r5, r2, 0x0045 Readies the check where r5 = SMEV1 if r3 = 6
addu r5, r2, 0x0041 Readies the check where r5 = SPEV1 if r3 = 7
(Check) lbu r4, 0x0000 (r5) r4 = RH equipment evasion.
bne r4, r0, (DivCheck) Checks RH equipment for evasion.
sltiu r3, r3, 0x0007 r3 = 1 if r3 < 7. r3 = 0 if r3 = 7.
lbu r4, 0x0001 (r5) r4 = LH equipment evasion.
(DivCheck) beq r3, r0 (Div3) If r3 = 0 (original r3 = 7), GOTO (Div3)
addu r5, r4, r0 r5 = r4
j (Calc)
srl r5, r5, 0x01  r5 = r5 / 2...this allows the SM-EV and W-EV used in formulas to cap at 25-30 in vanilla.
(Div3) lui r4, 0x5555
addu r4, r4, 0x5556
mult r5, r4
mfhi r5 r5 = r5 / 3...this allows the SP-EV used in formulas to cap at 25 in vanilla.
j (Calc)
nop
(Div4) j (Calc)
srl r5, r5, 0x02  r5 = r5 / 4...this allows the LVL used in formulas to cap at 25 in vanilla.
(Calc) bne r5, r0 (Nonzero) If r5 is not zero, GOTO (Nonzero)
nop
addiu r5, r0, 0x0001
(Nonzero) addu r7, r7, r5 r7 = XA1 + r5 (which we'll now call YA3)
srl r7, r7, 0x01 r7 = (XA1 + YA3) / 2
j (E)
addu r7, r7, r6 XA1 = (XA1 + YA3) / 2 + [Y/8]
(F9) andi r5, r3, 0x0008 r5 = first bit of Y
beq r5, r0 (Sorter)
srl r6, r3, 0x04 r6 = [Y/16]
lw r2, 0x2D98 (r1) Load the target's stats.
(Sorter) andi r5, r3, 0x0003 r5 = last 2 bits of Y
andi r3, r3, 0x0004 r3 = second bit of Y
beq r5, r0 (Divider1)
addiu r4, r2, 0x0028 Readies the check where r4 = curHP if r5 = 0
addiu r5, r5, 0xFFFF r5 = r5 - 1
beq r5, r0 (Divider1)
addiu r4, r2, 0x002C Readies the check where r4 = curMP if r5 = 0 (original r5 = 1).
addiu r5, r5, 0xFFFF r5 = r5 - 1
beq r5, r0 (Divider2)
lbu r4, 0x0024 (r2) r4 = Br of target or caster if r5 = 0 (original r5 = 2)
lbu r5, 0x005C (r2) r5 = Status Byte 5 on target or caster if r5 = 1 (original r5 = 3)
lbu r4, 0x0026 (r2) r4 = Fa of target or caster if r5 = 1 (original r5 = 3)
andi r5, r5 0x00C0
beq r5, r0 (Divider2) If not Innocent or Faith, GOTO (Divider2)
nop
sltiu r5, r5, 0x0080 r5 = 1 if Innocent.  r5 = 0 if Faith.
beq r5, r0 (Divider2) If Faith, GOTO (Divider2)
addiu r4, r0, 0x0064 r4 = 100
addiu r4, r0, 0x0000 ELSE, r4 = 0
(Divider2) beq r3, r0 (Div100) If r3 = 0 (normal), GOTO (Div100)
addiu r5, r0, 0x0064 r5 = 100
subu r4, r5, r4 If r3 = 1 (reversed stats), r4 = 100 - (BR or Adjusted FA)
(Div100) mult r7, r4
mflo r4 r4 = XA1 * BR/FA/UnBr/UnFa
lui r5, 0x028F
addiu r5, r5, 0x5C29
mult r4, r5
mfhi r5 r5 = XA1 * Br/Fa/UnBr/UnFa / 100
nop
j (E)
addu r7, r5, r6 XA1 = (XA1 * Br/Fa/UnBr/UnFa / 100) + [Y/16]
(Divider1) lhu r5, 0x0000 (r4) r5 = curHP or curMP
beq r3, r0 (OverMax) If r3 = 0 (normal), GOTO (OverMax)
lhu r4, 0x0002 (r4) r4 = maxHP or maxMP
subu r5, r4, r5 If r3 = 1 (reversed stats), r4 = max-cur HP/MP
(OverMax) mult r7, r5
mflo r5 r5 = XA1 * curHP/MP/max-curHP/max-curMP
nop
nop
div r5, r4
mflo r5 r5 = XA1 * curHP/MP/max-curHP/max-curMP / maxHP/MP
nop
j (E)
addu r7, r5, r6 XA1 = (XA1 * curHP/max-curHP/curMP/max-curMP / maxHP/MP) + [Y/16]
(F8) lui r4, 0xA001
lw r5, -0x6FF0 (r4) Load random word.
lui r6, 0x41C6
addiu r6, r6, 0x4E6D
multu r5, r6
mflo r5
nop
addiu r5, r5, 0x3039
sw r5, -0x6FF0 (r4) Store new Random Word.
multu r7, r5
mfhi r7 r7 = {0...XA1-1}
nop
addiu r7, r7, 0x0001 r7 = {1...XA1}
addu r7, r7, r3 XA1 = {1...XA1}+Y
(E) jr 31 Return to Main Routine
sb r7, 0x38CE (r1) Store modified XA1.


lhu r4, 0x38D0 (r1) Loads r4 as XA2
lhu r5, 0x38CE (r1) Loads r5 as XA1
beq r4, r0 (Set1) If XA2 is 0, GOTO (Set1)
nop
(Mult) mult r4, r5
mflo r4 XA2 = XA1 * XA2
nop
jr 31 Return to Main Routine
sh r4, 0x38D0 (r1) Stores new XA2

(Set1) j (Mult) GOTO (Mult)
addiu r4, r0, 0x0001 If XA2 = 0, XA2 is now 1.


lbu r6, 0x3904 (r1) r6 = Weapon Elemental
lbu r4, 0x38F3 (r1) r4 = Ability Flags Byte 1
lbu r5, 0x38F7 (r1) r5 = Ability Elemental
andi r7, r4, 0x0004
beq r7, r0 (E) If Weapon Strike is not flagged, GOTO (E)
nop
or r5, r5, r6 ELSE, Ability Elemental = Weapon Elemental + Ability Elemental
(E) jr 31 Returns to the Main Formula Routine.
sb r5, 0x38F7 (r1) Store new Ability Elemental


lbu r4, 0x38F7 (r1) Loads ability element
lbu r5, 0x0071 (r2) Loads elements strengthened
lhu r6, 0x38D0 (r1) Loads XA2
and r4, r4, r5 Checks ability element against elements strengthened
beq r4, r0, (E) If ability element isn't a boosted element, GOTO (E)
srl r5, r6, 0x02 If ability element is boosted, r5 = [XA2/4]
addu r6, r6, r5 XA2 = XA2 + [XA2/4]
(E)  jr 31 Return to Main Routine
sh r6, 0x38D0 (r1) Stores XA2

addu r2, r31, r0 r2 = Return Address, because r31 will be modified below by the jal commands.
lw r3, 0x2D98 (r1) Load target address.
lhu r5, 0x38D6 (r1) r5 = Used Ability ID
lui r4, 0x8006
sll r5, r5, 0x03 r5 = r5 * 8
addu r4, r4, r5
lbu r5, -0x140A (r4) r5 = AI Byte 4
lbu r6, 0x005B (r3) r6 = Status Byte 4
andi r4, r5, 0x0002
beq r4, r0 (Prot) If AI flag Magic Defense Up is not checked, GOTO (Prot)
andi r7, r6, 0x0010
beq r7, r0 (Prot) If target does not have Shell, GOTO (Prot)
nop
jal (Mult) If target has Shell and skill is blocked by Shell, GOTO (Mult)
nop
(Prot) andi r4, r5, 0x0001
beq r4, r0 (MADEF) If AI flag Defense Up is not checked, GOTO (MADEF)
andi r7, r6, 0x0020
beq r7, r0 (MADEF) If target does not have Protect, GOTO (MADEF)
nop
jal (Mult) If target has Protect and skill is blocked by Protect, GOTO (Mult)
(MADEF) lbu r6, 0x0090 (r3) r6 = Support Byte 2
andi r4, r5, 0x0002
beq r4, r0 (DEFUP) If AI flag Magic Defense Up is not checked, GOTO (DEFUP)
andi r7, r6, 0x0002
beq r7, r0 (DEFUP) If target does not have Magic Defense Up, GOTO (DEFUP)
nop
jal (Mult) If target has Magic Defense Up and skill is blocked by Shell, GOTO (Mult)
(DEFUP) andi r5, r5, 0x0001
beq r5, r0 (E) If AI flag Defense Up is not checked, GOTO (E)
andi r6, r6, 0x0008
beq r6, r0 (E) If target does not have Defense Up, GOTO (E)
nop
jal (Mult) If target has Defense Up and skill is blocked by Protect, GOTO (Mult)
nop
(E) jr r2 Return to Main Routine
nop

(Mult) lui r4, 0xAAAA
lhu r7, 0x38D0 (r1) r7 = XA2
addiu r4, r4, 0xAAAB r4 = AAAAAAAB
multu r7, r4
mfhi r7 r7 = XA2 * 2/3
nop
jr 31 Return to Protect/Shell/MADEF/DEFUP Routine
sh r7, 0x38D0 (r1) XA2 = XA2 * 2/3


lw r2, 0x2D94 (r1) Loads the attacker's stats
lw r3, 0x2D98 (r1) Loads the defender's stats
lui r7, 0x8006
lhu r6, 0x38D6 (r1) r6 = Used Ability ID
lbu r4, 0x0009 (r2) Loads the attacker's Zodiac Sign Byte
sll r6, r6, 0x03 r6 = r6 * 8
addu r7, r7, r6
lbu r7, -0x140D (r7) r7 = AI Byte 1 for attack
addiu r6, r0, 0x000C
andi r7, r7, 0x0010 Checks if the currently unused flag under "Learn on Hit" is flagged.
bne r7, r0, (E) If flagged, GOTO (E)
lbu r5, 0x0009 (r3) Loads the defender's Zodiac Sign Byte
srl r4, r4, 0x04 Gets the attacker byte's upper 4 bits.
beq r4, r6, (E) If Attacker sign is Ophiuchus, GOTO (E)
srl r5, r5, 0x04 Gets the defender byte's upper 4 bits.
beq r5, r6, (E) If Defender sign is Ophiuchus, GOTO (E)
andi r7, r4, 0x0003 r7 = the lower 2 bits of attacker sign
andi r6, r5, 0x0003 r6 = the lower 2 bits of defender sign
beq r6, r7, (Good) If attacker and defender signs differ by 4, GOTO (Good)
lbu r1, 0x38D0 (r1) r1 = XA2
addiu r7, r0, 0x0002
addiu r6, r0, 0x0006
(MOD) div r4, r6
mfhi r4 r4 = r4 MOD r6...MOD means you take the remainder of the division.
nop
nop
div r5, r6
mfhi r5 r5 = r5 MOD r6
nop
beq r4, r5 (Diff) If attacker and defender signs form a square or its diagonal, GOTO (Diff)
addiu r7, r7, 0xFFFF r7 = r7 - 1
bne r7, r0, (MOD) If r7 isn't zero, GOTO (MOD)
addiu r6, r0, 0x0003
(E) jr 31 Return to Main Routine
lui r1, 0x8019 Resets r1 = 0x80190000.
(Diff) beq r7, r0 (Bad) If r7 = 0 (when r6 = 3), GOTO (Bad)
lbu r6, 0x0006 (r2) r6 = attacker gender
lbu r7, 0x0006 (r3) r7 = defender gender
or r4, r6, r7
andi r4, r4, 0x0020
bne r4, r0, (Bad) If either combatant is a monster, GOTO (Bad)
andi r6, r6, 0x00C0
andi r7, r7, 0x00C0
beq r6, r7 (EndBranch) If the genders are the same, GOTO (EndBranch)
srl r4, r1, 0x01 XA2 = [XA2/2]
(+) addu r4, r1, r4 XA2 = XA2 + r4
(EndBranch) lui r7, 0x8019
j (E)
sb r4, 0x38D0 (r7) Store r1 as XA2
(Good) j (+)
(Bad) srl r4, r1, 0x02 r4 = [XA2/4]
j (EndBranch)
subu r4, r1, r4 XA2 = XA2 - [XA2/4]


lbu r4, 0x38F7 (r1) Loads ability element
lbu r5, 0x006F (r3) Loads elements halved
lhu r6, 0x38D0 (r1) Load XA2
and r4, r4, r5 Checks ability element against elements halved
beq r4, r0, (E) If ability element isn't a halved element, GOTO (E)
lw r2, 0x2D94 (r1) Loads attacker address
srl r6, r6, 0x01 If ability element is halved, XA2 = [XA2/2]
(E) jr 31 Return to Main Routine
sh r6, 0x38D0 (r1) Stores XA2


lhu r4, 0x38D6 (r1) r4 = Used Ability ID
lui r5, 0x8006
sll r4, r4, 0x03 r4 = r4 * 8
addu r5, r5, r4
lbu r6, -0x1409 (r5) r6 = AI Byte 5
lbu r7, -0x140A (r5) r7 = AI Byte 4
lbu r5, -0x140B (r5) r5 = AI Byte 3
andi r6, r6, 0x0004
bne r6, r0, (Un) If 3rd blank AI flag under the Third Unknown under Learn on Hit is flagged, GOTO (Un)
(Check) andi r7, r7, 0x0080
bne r7, r0, (Br) If the blank AI flag above Direct Attack is flagged, GOTO (Br)
andi r5, r5, 0x0004
bne r5, r0, (Fa) If the Unknown AI flag under Random Hits is flagged, GOTO (Fa)
nop
jr 31 ELSE, GOTO Main Routine
nop

(Un) addiu r6, r0, 0x0064
j (Check) r6 = 100, r4 = Yes, GOTO (Check)
addiu r4, r0, 0x0001

(Br) bne r4, r0, (UnBr) If UnBrave/UnFaith is flagged, GOTO (UnBr)
lbu r7, 0x0024 (r2) r7 = Attacker Brave
j (Mult) ELSE, GOTO (Mult)
(UnBr) lbu r4, 0x0024 (r3) r4 = Defender Brave
subu r7, r6, r7 r7 = 100 - Attacker Brave if UnBrave/UnFaith is flagged
subu r4, r6, r4 r4 = 100 - Defender Brave if UnBrave/UnFaith is flagged
(Mult) lhu r6, 0x38D0 (r1) r6 = XA2
nop
mult r6, r7
mflo r6 r6 = XA2 * (CaBr/Fa or 100 - CaBr/Fa)
nop
nop
mult r6, r4
mflo r6 r6 = XA2 * (CaBr/Fa or 100 - CaBr/Fa) * (TaBr/Fa or 100 - TaBr/Fa)
lui r4, 0x0006
addu r4, r4, 0x8DB8
mult r6, r4
mfhi r6 XA2 = [XA2 * (CaBr/Fa or 100 - CaBr/Fa) * (TaBr/Fa or 100 - TaBr/Fa) / 10000]
nop
jr 31 GOTO Main Routine
sh r6, 0x38D0 (r1) Stores new XA2
(Fa) lbu r5, 0x005C (r2) r5 = Attacker Status Byte 5
lbu r7, 0x005C (r3) r7 = Defender Status Byte 5
andi r5, r5, 0x00C0
beq r5, r0, (Load-AFa) If attacker does not have innocent or faith, GOTO (Load-AFa)
andi r7, r7, 0x00C0
sltiu r5, r5, 0x0080
beq r5, r0, (A-Inn) If attacker has Innocent, GOTO (A-Inn)
nop
j (CheckTar) If attacker has Faith, r5 = 100 and GOTO (CheckTar)
addiu r5, r0, 0x0064
(A-Inn) j (CheckTar) If attacker has Innocent, r5 = 0 and GOTO (CheckTar)
addiu r5, r0, 0x0000
(Load-AFa) lbu r5, 0x0026 (r2) If attacker has neither, r5 = Attacker Faith
(CheckTar) beq r7, r0, (Load-DFa) If defender does not have innocent or faith, GOTO (Load-DFa)
nop
sltiu r7, r7, 0x0080
beq r7, r0, (D-Inn) If defender has Innocent, GOTO (D-Inn)
nop
j (CheckUn) If defender has Faith, r7 = 100 and GOTO (CheckUn)
addiu r7, r0, 0x0064
(D-Inn) j (CheckUn) If defender has Innocent, r7 = 0 and GOTO (CheckUn)
addiu r7, r0, 0x0000
(Load-DFa) lbu r7, 0x0026 (r3) If defender has neither, r7 = Defender Faith
(CheckUn) beq r4, r0, (Normal) If UnBrave/UnFaith isn't flagged, GOTO (Normal)
nop
subu r5, r6, r5 r5 = 100 - Attacker Faith if UnBrave/UnFaith is flagged
subu r7, r6, r7 r7 = 100 - Defender Faith if UnBrave/UnFaith is flagged
(Normal) addu r4, r7, r0 r4 = r7 = Defender Faith
j (Mult) GOTO (Mult)
addu r7, r5, r0 r7 = r5 = Attacker Faith


lhu r4, 0x38D6 (r1) r4 = Used Ability ID
lui r5, 0x8006
sll r4, r4, 0x03 r4 = r4 * 8
addu r4, r5, r4
lbu r9, -0x1409 (r4) r9 = AI Byte 5
addu r8, r31, r0 Sends r31 into r8 because r31 will be modified by jal commands below.
andi r4, r9, 0x0010
beq r4, r0, (KB Check) If the first blank flag under the Third Unknown in the "Learn on Hit" box is unflagged, GOTO (KB Check)
sb r0, 0x38CC (r1) Reset Higher Tile Flag
jal (RNG) ELSE, GOTO (RNG)
addiu r7, r0, 0x0064
addiu r4, r0, 0x0004
sub r4, r4, r7 r4 = 4 - RN from 0 to 99
bltz r4 (KB check) If RN > 4, GOTO (KB check)
addiu r5, r0, 0x0001
sb r5, 0x018D (r2) Flag attack as critical.
jal (RNG) GOTO (RNG)
lhu r7, 0x38D0 (r1) r7 = Base Damage
lhu r6, 0x38D0 (r1) r6 = Base Damage
addiu r7, r7, 0x0001 r7 = {1...Base Damage}
addu r6, r6, r7 New Damage = Base Damage + {1...Base Damage}
sh r6, 0x38D0 (r1) Store New Damage
(KB check) andi r4, r9, 0x0008
beq r4, r0, (E) If the second blank flag under the Third Unknown in the "Learn on Hit" box is unflagged, GOTO (E)
sb r0, 0x38EE (r1) Reset Knockback Height
jal (RNG) GOTO (RNG)
addiu r7, r0, 0x0064
addiu r4, r0, 0x0031
sub r4, r4, r7 r4 = 49 - RN from 0 to 99
bltz r4 (E) If RN > 49, GOTO (E)
(KB) lbu r5, 0x0182 (r3)
beq r2, r3, (E) If you are targeting yourself with knockback, GOTO (E)
lbu r4, 0x0005 (r3)
lbu r6, 0x0047 (r2) r6 = Attacker X Coordinate
andi r4, r4, 0x0004
bne r4, r0, (E) If target is immortal, GOTO (E)
lbu r7, 0x0047 (r3) r7 = Defender X Coordinate
bne r5, r0, (E) If target is riding a chocobo or in 2h+ water, GOTO (E)
lui r4, 0x800E
lbu r5, 0x4E9C (r4) r5 = Map Maximum X
beq r7, r0 (CheckEdge1) If Defender X Coordinate = 0, GOTO (CheckEdge1)
sb r0, 0x38EC (r1) Reset Knockback Flag
beq r7, r5 (CheckEdge2) If Defender X Coordinate = Map Maximum X, GOTO (CheckEdge2)
nop
sub r5, r6, r7 XA1 Byte 1 = Attacker X - Defender X
j (YChecks) Store Byte 1 of XA1 and GOTO (YChecks)
sb r5, 0x38CE (r1)
(CheckEdge1) beq r6, r0 (YChecks) If Defender and Attacker X Coordinate = 0, GOTO (YChecks)
sb r0, 0x38CE (r1) Store Byte 1 of XA1 as 0.
(E) jr r8 ELSE, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(CheckEdge2) beq r6, r5 (YChecks) If Defender and Attacker X Coordinate = Maximum, GOTO (YChecks)
sb r0, 0x38CE (r1) Store Byte 1 of XA1 as 0.
jr r8 If Defender X Coordinate = Maximum, but Attacker X coordinate is not maximal, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(YChecks) lbu r6, 0x0048 (r2) r6 = Attacker Y Coordinate
lbu r7, 0x0048 (r3) r7 = Defender Y Coordinate
lbu r5, 0x4EA0 (r4) r5 = Map Maximum Y
beq r7, r0, (CheckEdge3) If Defender Y Coordinate = 0, GOTO (CheckEdge3)
nop
beq r7, r5, (CheckEdge4) If Defender Y Coordinate = Maximum Y, GOTO (CheckEdge4)
nop
sub r5, r6, r7 XA1 Byte 1 = Attacker Y - Defender Y
j (NewXY) Store Byte 2 of XA1 and GOTO (NewXY)
sb r5, 0x38CF (r1)
(CheckEdge3) beq r6, r0 (NewXY) If Defender and Attacker Y Coordinate = 0, GOTO (NewXY)
sb r0, 0x38CF (r1) Store Byte 2 of XA1 as 0.
jr r8 If Defender Y Coordinate = 0, while Attacker Y Coordinate isn't, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(CheckEdge4) beq r6, r5 (NewXY) If Defender and Attacker Y Coordinate = Maximum, GOTO (NewXY)
sb r0, 0x38CF (r1) Store Byte 2 of XA1 as 0.
jr r8 If Defender Y Coordinate = Maximum, but Attacker Y coordinate is not maximal, unflag knockback and return to Main Routine
sb r0, 0x38EC (r1)
(NewXY) lb r4, 0x38CE (r1) r4 = Attacker X - Defender X
lb r5, 0x38CF (r1) r5 = Attacker Y - Defender Y
bgez r4 (+X) If r4 is greater than or equal to 0, GOTO (+X)
addiu r7, r0, 0x0100
addiu r6, r0, 0x0001 If r4 < 0, r6 = 1
j (YDiff) Make r4 positive and GOTO (YDiff)
subu r4, r7, r4 If r4 < 0, r4 = 0x100 - r4 (as unsigned byte), essentially the equivalent of multiplying a signed byte by -1.
(+X) bne r4, r0 (YDiff) If r4 > 0, r6 = 2 and GOTO (YDiff)
addiu r6, r0, 0x0002
addiu r6, r0, 0x0000 ELSE, r6 = 0
(YDiff) bgez r5 (+Y) If r5 is greater than or equal to 0, GOTO (+Y)
addiu r7, r0, 0x0100
ori r6, r6, 0x0004 If r5 < 0, r6 = r6 OR 0x4 = r6 + 4 (because r6 = 0, 1, or 2)
j (CoordChange) Make r5 positive and GOTO (CoordChange)
subu r5, r7, r5 If r5 < 0, r5 = 0x100 - r5 (as unsigned byte), essentially the equivalent of multiplying a signed byte by -1.
(+Y) beq r5, r0 (CoordChange) If r5 = 0, r6 = r6 and GOTO (CoordChange)
ori r6, r6, 0x0000
ori r6, r6, 0x0008 ELSE, r6 = r6 OR 0x8 = r6 + 8 (because r6 = 0, 1, or 2)
(CoordChange) jal (RNG) r7 = r4 + r5 = Distance Attacker is from Defender and GOTO (RNG)
addu r7, r4, r5
sub r7, r4, r7 r7 = |Attacker X - Defender X| - {0...|Attacker X - Defender X| + |Attacker Y - Defender Y| - 1}
bgtz r7 (ChangeX) If r7 > 0, GOTO (Change X)
lbu r5, 0x0048 (r3) r5 = Defender Y
andi r6, r6, 0x0008
beq r6, r0, (+1Y) If Attacker Y < Defender Y, GOTO (+1Y)
nop
j (NewCoord) If Attacker Y > Defender Y, Defender Y = Defender Y - 1 and GOTO (NewCoord)
addiu r5, r5, 0xFFFF
(+1Y) j (NewCoord) If Attacker Y < Defender Y, Defender Y = Defender Y + 1 and GOTO (NewCoord)
addiu r5, r5, 0x0001
(ChangeX) lbu r4, 0x0047 (r3) r4 = Defender X
andi r6, r6, 0x0002
beq r6, r0, (+1X) If Attacker X < Defender X, GOTO (+1X)
nop
j (NewCoord) If Attacker X > Defender X, Defender X = Defender X - 1 and GOTO (NewCoord)
addiu r4, r4, -0xFFFF
(+1X) addiu r4, r4, 0x0001 If Attacker X < Defender X, Defender X = Defender X + 1
(NewCoord) lui r6, 0x800E
lbu r6, 0x4E9C (r6) r6 = Map Maximum X
sb r4, 0x38CE (r1) Store Defender X as XA1 Byte 1
sb r5, 0x38CF (r1) Store Defender Y as XA1 Byte 2
lhu r5, 0x0048 (r3) r5 = Pre-Attack Defender Y + Unit Facing
lbu r4, 0x0047 (r3) r4 = Pre-Attack Defender X
andi r7, r5, 0x8000
jal (TileOffset) GOTO (TileOffset)
andi r5, r5, 0x00FF r5 = Pre-Attack Defender Y
bne r7, r0, (HigherTile) If the defender stood on a higher tile, GOTO (HigherTile)
nop
j (NewHeight) ELSE, r7 = Height of Lower Tile and GOTO (NewHeight)
lbu r7, -0x0732 (r4)
(HigherTile) lbu r7, 0x00CE (r4) r7 = Height of Higher Tile
(NewHeight) lbu r5, 0x38CF (r1) r5 = Defender Y (current)
jal (TileOffset) GOTO (TileOffset)
lbu r4, 0x38CE (r1) r4 = Defender X (current)
lbu r9, 0x005A (r3) r9 = Current Status Byte 3
lbu r5, 0x0093 (r3) r5 = Movement Status Byte 1
andi r9, r9. 0x0040
bne r9, r0, (SCheckFail) If target has float status, GOTO (SCheckFail)
lbu r2, 0x0095 (r3) r2 = Movement Status Byte 3
andi r5, r5, 0x0002
bne r5, r0, (SCheckFail) If target has ignore height, GOTO (SCheckFail)
andi r2, r2, 0x000C
beq r2, r0, (SCheckGood) If target doesn't have float/fly, GOTO (SCheckGood)
addu r9, r0, r0 If target doesn't have float/fly/ignore height, r9 = 0
(SCheckFail) addiu r9, r0, 0x0001 ELSE, r9 = 1
(SCheckGood) lbu r5, -0x0732 (r4) r5 = Height of Current Lower Tile
lbu r2, -0x072E (r4) r2 = Byte 7 of Current Lower Tile Data
sltu r4, r7, r5
bne r4, r0 (E) IF r7 < r5, GOTO (E)
andi r2, r2, 0x0001
bne r2, r0, (HigherTile) ELSE IF lower tile is impassable, GOTO (HigherTile)
sub r4, r7, r5 r4 = r7 - r5
bne, r9, r0, (NoFallDamageL) ELSE If target has float/fly/ignore height, GOTO (NoFallDamageL)
nop
sb r4, 0x38EE (r1) ELSE, Store r4 as knockback height
(NoFallDamageL) ori r4, r0, 0x0001 r4 = 1
sb r4, 0x38EC (r1) Flag Knockback
(HigherTile) lbu r5, 0x38CF (r1) r5 = Defender Y (current)
jal (TileOffset) GOTO (TileOffset)
lbu r4, 0x38CE (r1) r4 = Defender X (current)
lbu r5, 0x00CE (r4) r5 = Height of Current Higher Tile
lbu r2, 0x00D2 (r4) r2 = Byte 7 of Current Higher Tile Data
beq r5, r0 (E2) IF r5 = 0, GOTO (E2)
sltu r4, r7, r5
bne r4, r0 (E2) ELSE IF r7 < r5, GOTO (E2)
andi r2, r2, 0x0001
bne r2, r0, (E) ELSE IF higher tile is impassable, GOTO (E)
sub r4, r7, r5 r4 = r7 - r5
bne, r9, r0, (NoFallDamageH) ELSE If target has float/fly/ignore height, GOTO (NoFallDamageH)
addu r6, r0, r0 r6 = 0
sb r4, 0x38EE (r1) ELSE, store r4 as Knockback Height.
(NoFallDamageH) ori r4, r0, 0x0001 r4 = 1
sb r4, 0x38EC (r1) Flag Knockback
(E2) lbu r4, 0x38EC (r1) r4 = Knockback flag.
nop
beq r4, r0, (E) If Knockback is not flagged, GOTO (E)
nop
bne r6, r0, (LowerFlag) ELSE If r6 = Map Maximum X (and not 0), GOTO (LowerFlag)
addiu r7, r0, 0x0001 r7 = 1
sb r7, 0x38CC (r1) ELSE, flag Higher Tile
(LowerFlag) lbu r5, 0x38C1 (r1) r5 = The Xth unit on map (target)
lbu r4, 0x38CE (r1) r4 = Target X (current)
sb r5, 0x38EF (r1) Store r5.
lbu r5, 0x38CF (r1) r5 = Target Y (current)
sb r4, 0x38CA (r1) Store r4.
lbu r4, 0x019D (r3) r4 = Attack Elemental Modifier Flags vs. Target
sb r5, 0x38CB (r1) Store r5.
ori r4, r4, 0x0040 r4 = r4 OR 0x40
jr r8 GOTO Main Routine
sb r4, 0x019D (r3) Store r4, which now has a knockback on attack flag

(TileOffset) mult r5, r6
mflo r5 r5 = Map Maximum X * Defender Y (pre-attack or current)
nop
addiu r5, r5, r4 r5 = Map Maximum X * Defender Y + Defender X (pre-attack or current)
sll r5, r5, 0x03 r5 = r5 * 8
lui r4, 0x8019
jr 31  Return to Critical/Knockback Routine
addu r4, r4, r5

(RNG) lui r4, 0xA001
lw r5, -0x6FF0 (r4) Load random word.
lui r6, 0x41C6
addiu r6, r6, 0x4E6D
multu r5, r6
mflo r5
nop
addiu r5, r5, 0x3039
sw r5, -0x6FF0 (r4) Store new Random Word.
multu r7, r5
mfhi r7 r7 = {0...value(r7)-1}
jr 31 Return to Critical/Knockback Routine
nop

BATTLE.BIN
0x123EB0
00000000

BATTLE.BIN
0x11408C
00000000
00000000

BATTLE.BIN
0x1140FC
00000000
00000000

BATTLE.BIN
0x115FD8
EC

BATTLE.BIN
0x115FE0
01

BATTLE.BIN
0x124420
EC

BATTLE.BIN
0x124428
01

BATTLE.BIN
0x116250
EC

BATTLE.BIN
0x1162AC
EC

BATTLE.BIN
0x1162B4
01

BATTLE.BIN
0x1162C4
EC

BATTLE.BIN
0x123E50
EC

BATTLE.BIN
0x119EB8
lui r18, 0x8019 or 1980123C
0x119EC4
lbu r18, 0x38CC (r18) or CC385292


lw r2, 0x2D94 (r1) r2 = Attacker Offset
lhu r4, 0x38D6 (r1) r4 = Ability ID
lbu r7, 0x38F7 (r1) r7 = Ability Elemental
lui r6, 0x8006
sll r4, r4, 0x03 r4 = Ability ID * 8
addu r6, r6, r4 r6 = r6 + Ability ID * 8
lbu r4, 0x005A (r3) r4 = Target Status Bytes 3
lbu r8, 0x006E (r3) r8 = Target Elemental Nullification Byte
andi r4, r4, 0x0040
beq r4, r0, (NullCompare) If target is does not have float, GOTO (NullCompare)
nop
ori r8, r8, 0x0008 ELSE, Target is now nulls earth.
(NullCompare) andi r8, r8, r7
bne r8, r0, (ENull) If element is Nulled, GOTO (ENull)
lbu r6, -0x140B (r6) r6 = AI Flags Byte 3
lhu r4, 0x0058 (r3) ELSE, r4 = Target Status Bytes 1 and 2
lbu r8, 0x0070 (r3) r8 = Target Elemental Weakness Byte
andi r4, r4, 0x0410
beq r4, r0, (CheckOil) If target is not undead or vampire (has blood suck), GOTO (CheckOil)
addiu r9, r0, 0x0001
ori r8, r8, 0x0002 ELSE, Target is now weak against holy
(CheckOil) lbu r4, 0x005A (r3) r4 = Target Status Bytes 3
sb r9, 0x018C (r3) Flag attack as hit.
andi r4, r4, 0x0080
beq r4, r0 (NoStatusWeak) If target does not have oil, GOTO (NoStatusWeak)
nop
ori r8, r8, 0x0080 ELSE, Target is now weak against fire
(NoStatusWeak) lhu r4, 0x38D0 (r1) r4 = Base Damage
andi r6, r6, 0x0020
beq r6, r0, (EWeak) If AI Undead Reverse Flag is not flagged, r9 = 1 and GOTO (EWeak)
addiu r9, r0, 0x0001
andi r9, r5, 0x0080 ELSE r9 = 0, if the first blank flag under Player Abilities isn't flagged (healing), or 80 if it is (drain)
(EWeak) lbu r5, 0x38D6 (r1) r5 = Ability ID
lui r6, 0x8006
sll r5, r5, 0x03 r5 = Ability ID * 8
addu r6, r6, r5 r6 = r6 + Ability ID * 8
lbu r5, -0x140C (r6) r5 = AI Flags Byte 2
and r8, r8, r7
beq r8, r0, (SetupDMG) If the target is not weak against the spell's element, GOTO (SetupDMG)
addiu r9, r9, 0xFFFF
sll r4, r4, 0x01 ELSE, r4 = r4 * 2
(SetupDMG) andi r5, r5, 0x00A0
beq r5, r0, (EAbsorb) If the AI HP and MP flags are unflagged, GOTO (EAbsorb)
addu r6, r4, r0 r6 = r4
andi r6, r5, 0x0080
beq r6, r0 (-MP) ELSE, r6 = 0 or 0x80 and if AI flag HP is not flagged (r6 = 0), GOTO (-MP)
nop
andi r6, r5, 0x0040
beq r6, r0 (-HP) ELSE, If AI flag MP is not flagged, GOTO (-HP)
sh r4, 0x0190 (r3) Stores HP Damage as 2x Base Damage
srl r4, r4, 0x01
(-MP) sh r4, 0x0194 (r3) Stores r4 as MP Damage
(-HP) lbu r4, 0x019D (r3) r4 = Elemental Resistance Byte
beq r8, r0, (EAbsorb) If the target is not weak against the spell's element, GOTO (EAbsorb)
lbu r6, 0x01B1 (r3) r6 = Attack Type Byte
ori r4, r4, 0x0008 ELSE, r4 includes damage is elemental weakness
ori r6, r6, 0x00A0 r6 includes HP/MP Damage
sb r4, 0x019D (r3) Store r4 as elemental resistance byte
bgtz r9, (DrainFlags) If attack is supposed to drain, GOTO (DrainFlags)
sb r6, 0x01B1 (r3) Store r6 as attack type byte
j (EAbsorb) ELSE, GOTO (EAbsorb)
nop
(DrainFlags) lhu r4, 0x0194 (r3) r4 = MP Damage Dealt
lhu r5, 0x002C (r3) r5 = Target MP
lhu r6, 0x002C (r3) r6 = Target MP
sub r5, r5, r4
bltz r5, (ExcessMPDMG) If target MP < MP Damage Dealt, GOTO (ExcessMPDMG)
nop
j (HPDrain) GOTO (HPDrain)
sh r4, 0x0196 (r2) ELSE, Set MP restored to MP Damage Dealt.
(ExcessMPDMG) sh r6, 0x0196 (r2) If target MP < MP Damage Dealt, set MP restored as target MP.
(HPDrain) lhu r4, 0x0190 (r3) r4 = HP Damage Dealt
lhu r5, 0x0028 (r3) r5 = Target HP
lhu r6, 0x0028 (r3) r6 = Target HP
sub r5, r5, r4
bltz r5, (ExcessHPDMG) If target HP < HP Damage Dealt, GOTO (ExcessMPDMG)
nop
j (SelfFlags) GOTO (SelfFlags)
sh r4, 0x0192 (r2) ELSE, Set HP restored to HP Damage Dealt.
(ExcessHPDMG) sh r6, 0x0192 (r2) If target HP < HP Damage Dealt, set HP restored as target HP.
(SelfFlags) ori r4, r0, 0x0001
lbu r5, 0x01B1 (r2) r5 = Attack Type Byte of caster.
sb r4, 0x018C (r2) Drain will affect caster.
ori r5, r5, 0x0050 r5 includes HP/MP Healing
sb r5, 0x01B1 (r2) r5 is stored as the caster attack type byte.
ori r6, r0, 0x0100 r6 = 0x100
beq r9, r6, (E) If r9 = 0x100 (only possible if drain attack has no elemental modifiers), GOTO (E)
(EAbsorb) lbu r4, 0x0058 (r3) r4 = Target Status Bytes 1
lbu r8, 0x006D (r3) r8 = Target Elemental Absorption Byte
andi r4, r4, 0x0010
beq r4, r0, (NoUndead) If the target isn't undead, GOTO (NoUndead)
nop
ori r8, r8, 0x0001 ELSE, the target absorbs dark attacks.
(NoUndead) and r8, r8, r7
beq r8, r0, (Normal) If the target does not absorb the spell's element, GOTO (Normal)
lhu r4, 0x0190 (r3) r4 = HP Damage
bne r5, r0 (NotStatus) If the attack deals damage, drain, or healing, GOTO (NotStatus)
sll r6, r6, 0x01 Double hit chance of non-damage attack if target absorbs element.
addiu r9, r0, 0x0002
sb r9, 0x018C (r3) ELSE, Store 0x2 into target hit byte.
j (E) GOTO (E)
sh r6, 0x01B6 (r3) r6 = Hit Chance
(NotStatus) lhu r5, 0x0194 (r3) r5 = MP Damage
(HealSetup) sh r0, 0x0190 (r3) HP Damage is 0
bgtz r9, (DrainReversalFlags) If attack is supposed to drain, GOTO (DrainReversalFlags)
sh r0, 0x0194 (r3) MP Damage is 0
sh r4, 0x0192 (r3) r4 = HP Healing
sh r5, 0x0196 (r3) r5 = MP Healing
(EAbsorbFlags) lbu r5, 0x019D (r3) r5 = Elemental Resistance Byte
lbu r6, 0x01B1 (r3) r6 = Attack Type Byte
ori r5, r5, 0x0004 r5 includes healing is elemental absorption
andi r6, r6, 0x005F r6 no longer includes HP/MP damage.
ori r6, r6, 0x0050 r6 includes HP/MP Healing
sb r5, 0x019D (r3) Store r5 as elemental resistance byte
jr 31 Return to Main Formula Routine
sb r6, 0x01B1 (r3) Store r6 as attack type byte
(DrainReversalFlags) sh r4, 0x0190 (r2) r4 = HP Damage on Caster
lbu r6, 0x002C (r2) r6 = Caster MP
sh r5, 0x0194 (r2) r5 = MP Damage on Caster
sub r6, r6, r5
bltz r6, (ExcessMPHeal) If caster MP < MP Damage Dealt, GOTO (ExcessMPHeal)
sh r0, 0x0196 (r2) MP Healing on Caster is 0
j (HPReversal) GOTO (HPReversal)
sh r5, 0x0196 (r3) ELSE, Target MP Healing = Caster MP Damage
(ExcessMPHeal) add r6, r6, r5
sh r6, 0x0196 (r3) If Caster MP < MP Damage Dealt, Target MP Healing = Caster MP
(HPReversal) lbu r6, 0x0028 (r2) r6 = Caster HP
nop
sub r6, r6, r4
bltz r6, (ExcessHPHeal) If caster HP < HP Damage Dealt, GOTO (ExcessHPHeal)
sh r0, 0x0192 (r2) HP Healing on Caster is 0
j (SelfReverseFlags) GOTO (SelfReverseFlags)
sh r4, 0x0192 (r3) ELSE, Target HP Healing = Caster HP Damage
(ExcessMPHeal) add r6, r6, r4
sh r6, 0x0192 (r3) If Caster HP < HP Damage Dealt, Target MP Healing = Caster MP
(SelfReverseFlags) lbu r6, 0x01B1 (r2) r6 = Caster Attack Type Byte
ori r5, r0, 0x0001
andi r6, r6, 0x00AF r6 no longer includes HP/MP healing.
ori r6, r6, 0x00A0 r6 includes HP/MP Damage
sb r5, 0x018C (r2) Caster is affected by drain reversal.
j (EAbsorbFlags) GOTO (EAbsorbFlags)
sb r6, 0x01B1 (r2) Store r6 as attack type byte
(Normal) bne r5, r0 (NotStatus2) If the attack deals damage, drain, or healing, GOTO (NotStatus2)
nop
addiu r9, r0, 0x0002
sb r9, 0x018C (r3) ELSE, Store 0x2 into target hit byte.
j (E) GOTO (E)
sh r6, 0x01B6 (r3) r6 = Hit Chance
(NotStatus2) bltz r9, (Healing) If r9 < 0 (if the AI flags are set as healing), GOTO (Healing)
lhu r5, 0x0194 (r3) r5 = MP Damage
lbu r6, 0x01B1 (r3) ELSE, r6 = Attack Type Byte
nop
ori r6, r6, 0x00A0 r6 includes HP/MP Damage
bgtz r9, (Drain) If r9 > 0 (if the AI flags are set as drain), GOTO (Drain)
sb r6, 0x01B1 (r3) Store r6 as Attack Type Byte
jr 31 ELSE (if attack is not drain/healing), return to Main Formula Routine
nop
(Healing) addu, r7, r31, r0 r7 = Return address
jal (HealSetup) Save offset into r31 and GOTO (HealSetup)
nop
andi r5, r5, 0x00FB r5 no longer includes healing as elemental absorption
jr r7 Return to Main Formula Routine
sb r5, 0x019D (r3) Store r5 as elemental resistance byte
(Drain) j (DrainFlags) GOTO (DrainFlags)
addiu r9, r0, 0x0100 r9 = 0x100 (for comparison purposes above)
(E) jr r31 Return to Main Formula Routine
nop

(ENull) sb r0, 0x018C (r3) Attack will miss.
sh r0, 0x0190 (r3) HP Damage is 0.
sh r0, 0x0192 (r3) MP Damage is 0.
sh r0, 0x0194 (r3) HP Healing is 0.
sh r0, 0x0196 (r3) MP Healing is 0.
sh r0, 0x019C (r3) Set the elemental resistance byte to 0
sb r0, 0x01B1 (r3) Set the attack type byte to 0
sh r0, 0x01B6 (r3) Set the accuracy to 0
ori r4, r0, 0x0005
sb r4, 0x018E (r3) Display on missed attack is "Nullified"
lbu r4, 0x38ED (r1) r4 = Target Terrain Byte
sh r0, 0x38C8 (r1) Spell/Status Flags = 0
sh r0, 0x38C6 (r1) Status/Spell ID = 0
andi r4, r4, 0x0080
beq r4, r0 (E2) If target isn't above the terrain because of fly/float/chicken/frog, GOTO (E2)
nop
sb r0, 0x38ED (r1) ELSE, r4 = 0
(E2) jr r31 Return to Main Formula Routine
nop
Title: Re: ASM Collective BATTLE.BIN Map
Post by: LastingDawn on June 22, 2011, 10:33:59 am
That's some Class A work there FDC, but that Critical/Knockback routine, oy... makes the head spin. You've already your own added fix to that it seems though?
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on July 19, 2011, 08:03:28 am
All right, let's try a slightly different approach.  I'm getting really tired of coding long routines, so let's explicitly write down the called functions first.


addiu r29, r29, 0xFFE0
sw r16, 0x0000 (r29)
sw r17, 0x0004 (r29)
sw r18, 0x0008 (r29)
sw r19, 0x000C (r29)
sw r20, 0x0010 (r29)
sw r21, 0x0014 (r29)
sw r22, 0x0018 (r29)
sw r23, 0x001C (r29)
lui r16, 0x8019 r16 = 0x190000
sh r0, 0x38CE (r16) Resets XA to 0.
sh r0, 0x38D0 (r16) Resets YA to 0.
lw r17, 0x2D94 (r16) r17 = Attacker Offset
lw r18, 0x2D98 (r16) r18 = Defender Offset
lhu r19, 0x38D6 (r16)
lui r20, 0x8006
sll r19, r19, 0x03
addu r19, r20, r19
jr 31 Return to Main Routine
lbu r19, -0x1410 (r19) r19 = AI flags.  r20 will be used as a r31 replacement for complicated mechanics routines that call subroutines; r21-r23 will be used during the floating point multiplication routine.



This allows you to multiply stats without ever again running into rounding errors.  This function accepts r1/r2 and r21.r22 as inputs (r1 = numerator, r2 = denominator, r21 = integer part, r22 = fractional part) and returns r21.r22 (r21 = new integer part, r22 = new fractional part).  This formula assumes you already used "Initialize", r21.r22 is your XA2 stat, and r1/r2 is your multiplier from ATKUP/2H/...  NOTE, r3 is overridden and r2 should NEVER be 0 or 1.

lui r3, 0xFFFF
ori r3, r3, 0xFFFF r3 = 0xFFFFFFFF
divu r3, r2
mflo r3
addiu r3, r3, 0x0001 r3 = 0xFFFFFFFF / denominator1 + 1
nop
multu r21, r3
mfhi r21 r21 = int{r21 / r2}
mflo r23 r23 = frac{r21 / r2}
nop
nop
multu r22, r3
mfhi r3 r3 = Upper32Bits{[1 / r2] * 0.r22}
addu r22, r3, r23 r22 = r3 + r23
sltu r3, r22, r3 r3 = 1 if overflow, ELSE, r3 = 0
beq r3, r0, (*Top) If no overflow, GOTO (*Top)
nop
addiu r21, r21, 0x0001 If overflow, r21 = r21 + 1 (arithmetic carryover).
(*Top) multu r21, r1
mflo r21 r21 = (int{r21 / r2} + int{frac{r21 / r2} + frac{0.r22 * 1 / r2}}) * r1
nop
nop
multu r22, r1
mfhi r1 r1 = int{frac{{frac{r21 / r2} + frac{0.r22 * 1 / r2}} * r1}
mflo r22 r22 = frac{frac{{frac{r21 / r2} + frac{0.r22 * 1 / r2}} * r1}
jr 31 Return to Main Routine
addu r21, r21, r1 r21 = r21 + r1



This generates a random number.  This function accepts r4 as an input, and outputs int{r4 * {0...1}}.  NOTE, this overrides r1, r2, and r3.

lui r1, 0xA001
lw r2, -0x6FF0 (r1) Load random word.
lui r3, 0x41C6
addiu r3, r3, 0x4E6D
multu r2, r3
mflo r2
addiu r2, r2, 0x3039
sw r2, -0x6FF0 (r1) Store new random word.
multu r4, r2
mfhi r4 r4 = {0...value(r4)-1}
jr 31 Return to Critical/Knockback Routine
nop



This formula outputs r10 as non-zero if the first blank flag under "Learn on Hit" is flagged and zero if not.  From here on out, this flag will be known as "FoeStats".  r6 is outputted as either the target's or attacker's data offsets, depending on FoeStat's state.  This formula assumes "Initialize" was already used.  NOTE, this overrides r1.

lbu r1, 0x0003 (r19)
nop
andi r10, r1, 0x0010
beq r10, r0, (End)
addu r6, r17, r0
addu r6, r18, r0
(End) jr 31
nop
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on July 19, 2011, 11:12:39 am
The above were the simplest functions (the ones that perform basic legwork); here are the functions that determine XA1/XA2/YA3/Y, which assume the functions "Initialize" and "Address" were already used.
Coded below are all the possibilities, but a given formula will just use one or none of each colored type.

Get XA1:


This formula outputs r5 as XA1.  Used with formulas that involve 3 or more stats.  NOTE, this overrides r1-r4.

lbu r3, 0x38F9 (r16)
ori r2, r0, 0x0001
andi r3, r3, 0x0003
beq r3, r0, (End)
lbu r5, 0x0036 (r6)
beq r3, r2, (End)
lbu r5, 0x0037 (r6)
ori r2, r0, 0x0002
beq r3, r2, (End)
lbu r5, 0x0038 (r6)
lbu r4, 0x003C (r18)
lbu r1, 0x003D (r18)
beq r10, r0, (End)
lbu r5, 0x3902 (r16)
sltiu r5, r1, r4
bne r5, r0, (End)
addu r5, r4, r0
addu r5, r1, r0
(End) jr 31
sh r5, 0x38CE (r16)



This formula outputs r5 as XA1.  Used with formulas of the Lifebreak type.  NOTE, this overrides r3.

lbu r3, 0x38F9 (r16)
nop
andi r3, r3, 0x0001
beq r3, r0, (End)
lhu r5, 0x002a (r6)
nop
lhu r5, 0x002e (r6)
(End) jr 31
sh r5, 0x38CE (r16)


Get XA2:


This formula outputs r8 as XA2 and r7 as the attack type (for ATKUP/MATKUP/2H purposes).  Used with formulas that involve 2 or fewer stats.  NOTE, this overrides r1-r4.

lbu r3, 0x38F9 (r16)
ori r7, r0, 0x00FF
andi r3, r3, 0x0007
beq r3, r0, (End)
ori r8, r0, 0x0001
ori r7, r0, 0x0001
ori r2, r0, 0x0001
beq r3, r2, (End)
lbu r8, 0x0036 (r17)
ori r2, r0, 0x0003
beq r3, r2, (End)
lbu r8, 0x0038 (r17)
lbu r1, 0x003e (r17)
lbu r4, 0x003f (r17)
ori r2, r0, 0x0005
sltiu r8, r4, r1
bne r8, r0, (Quarter)
addu r8, r1, r0
addu r8, r4, r0
(Quarter) srl r8, r8, 0x02
beq r3, r2, (End)
addiu r8, r8, 0x0003
lbu r1, 0x0041 (r17)
lbu r4, 0x0042 (r17)
ori r2, r0, 0x0006
sltiu r8, r4, r1
bne r8, r0, (*.25)
addu r8, r1, r0
addu r8, r4, r0
(*.25) beq r3, r2, (End)
srl r8, r8, 0x02
ori r7, r0, 0x0000
lbu r8, 0x0022 (r17)
ori r2, r0, 0x0007
srl r8, r8, 0x03
beq r3, r2, (End)
addiu r8, r8, 0x0006
ori r2, r0, 0x0002
beq r3, r2, (End)
lbu r8, 0x0037 (r17)
ori r7, r0, 0x0002
lbu r8, 0x3902 (r16)
(End) jr 31
sh r8, 0x38D0 (r16)



This formula outputs r8 as XA2 and r7 as the attack type (for ATKUP/MATKUP/2H purposes).  Used with formulas that involve 3 or more stats.  NOTE, this overrides r2/r3.

lbu r3, 0x38F9 (r16)
ori r7, r0, 0x0001
andi r3, r3, 0x000F
sltiu r2, r3, 0x0004
bne r2, r0, (End)
lbu r8, 0x0036 (r17)
sltiu r2, r3, 0x0008
ori r7, r0, 0x0000
bne r2, r0, (End)
lbu r8, 0x0037 (r17)
sltiu r2, r3, 0x0008
ori r7, r0, 0x0001
bne r2, r0, (End)
lbu r8, 0x0038 (r17)
ori r7, r0, 0x0002
lbu r8, 0x3902 (r16)
(End) jr 31
sh r8, 0x38D0 (r16)


Get YA3:


This formula outputs r5 as XA1 + YA3.  There are 8 options for YA3 and is used with most formulas.  NOTE, this overrides r1-r4 and r9.

lbu r3, 0x38FA (r16)
lhu r5, 0x38CE (r16)
andi r3, r3, 0x0007
beq r3, r0, (End)
addiu r9, r0, 0x000A
ori r2, r0, 0x0001
beq r3, r2, (End)
lbu r9, 0x0036 (r6)
ori r2, r0, 0x0002
beq r3, r2, (End)
lbu r9, 0x0037 (r6)
ori r2, r0, 0x0003
beq r3, r2, (End)
lbu r9, 0x0038 (r6)
ori r2, r0, 0x0004
bne r3, r2, (NotWP)
lbu r4, 0x003C (r18)
lbu r1, 0x003D (r18)
beq r10, r0, (End)
lbu r9, 0x3902 (r16)
sltiu r9, r1, r4
bne r9, r0, (End)
addu r9, r4, r0
addu r9, r1, r0
(NotWP) lbu r1, 0x003e (r6)
lbu r4, 0x003f (r6)
ori r2, r0, 0x0005
sltiu r9, r4, r1
bne r9, r0, (Quarter)
addu r9, r1, r0
addu r9, r4, r0
(Quarter) srl r9, r9, 0x02
beq r3, r2, (End)
addiu r9, r9, 0x0003
lbu r1, 0x0041 (r6)
lbu r4, 0x0042 (r6)
ori r2, r0, 0x0006
sltiu r9, r4, r1
bne r9, r0, (*.25)
addu r9, r1, r0
addu r9, r4, r0
(*.25) beq r3, r2, (End)
srl r9, r9, 0x02
lbu r9, 0x0022 (r6)
nop
srl r9, r9, 0x03
addiu r9, r9, 0x0006
(End) nop
addu r5, r9, r5
jr 31
sh r5, 0x38CE (r16)



This formula outputs r5 as XA1 * YA3.  There are 8 options for YA3 and is used mostly with type Lifebreak formulas.  NOTE, this overrides r1-r4 and r9.

lbu r3, 0x38FA (r16)
lhu r5, 0x38CE (r16)
andi r3, r3, 0x0007
lhu r4, 0x0002a (r6)
beq r3, r0, (0Check)
lhu r9, 0x0028 (r6)
ori r2, r0, 0x0001
beq r3, r2, (0Check-1)
ori r2, r0, 0x0002
lhu r4, 0x0002e (r6)
beq r3, r2, (0Check)
lhu r9, 0x002c (r6)
ori r2, r0, 0x0003
beq r3, r2, (0Check-1)
ori r2, r0, 0x0004
ori r4, r0, 0x0064
beq r3, r2, (0Check)
lbu r9, 0x0024 (r6)
ori r2, r0, 0x0005
beq r3, r2, (0Check-1)
lbu r1, 0x005c (r6)
ori r2, r0, 0x0006
andi r1, r1, 0x00c0
beq r1, r0, (Jumper)
lbu r9, 0x0026 (r6)
addiu r1, r1, FF80
beq r1, r0, (Jumper)
ori r9, r0, 0x0064
ori r9, r0, 0x0000
(Jumper) beq r3, r2, (0Check)
nop
(0Check-1) subu r9, r4, r9
(0Check) bne r5, r0, (Mult)
nop
addiu r5, r0, 0x0001
(Mult) multu r9, r5
mflo r5
nop
nop
divu r5, r4
mflo r5
jr 31
sh r5, 0x38CE (r16)



This formula outputs r5 as XA1 * YA3.  There are 16 options for YA3 and is used mostly % healing/damage formulas.  NOTE, this overrides r2-r4.

lbu r3, 0x38FA (r16)
lhu r5, 0x38CE (r16)
andi r3, r3, 0x000F
sll r2, r3, 0x01
sll r3, r3, 0x03
subu r3, r3, r2
bne r5, r0, (Mult)
addiu r3, r3, 0x000A
addiu r5, r0, 0x0001
(Mult) multu r3, r5
mflo r5
ori r4, r0, 0x0064
nop
divu r5, r4
mflo r5
jr 31
sh r5, 0x38CE (r16)


Get Y:


This formula outputs r5 as XA1 + Y.  This assumes there's no YA3 term and is mostly used with formulas of the XA2 * Y type.  NOTE, this overrides r3.

lbu r3, 0x38FA (r16)
lhu r5, 0x38CE (r16)
nop
addu r5, r3, r5
jr 31
sh r5, 0x38CE (r16)



This formula outputs r5 as XA1 + YA3 + Y.  This is mostly used with damage formulas.  NOTE, this overrides r3.

lbu r3, 0x38FA (r16)
lhu r5, 0x38CE (r16)
srl r3, r3, 0x03
addu r5, r3, r5
jr 31
sh r5, 0x38CE (r16)



This formula outputs r8 as XA2 + Y.  This assumes XA2 has already undergone all the requisite multipliers and is mostly used with % hit formulas.  NOTE, this overrides r3.

lbu r3, 0x38FA (r16)
nop
andi r3, r3, 0x00F0
addu r8, r3, r21
jr 31
sh r8, 0x38D0 (r16)
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on August 06, 2011, 05:09:30 pm
The following will list multiplier routines that every formula will use.  Most of the important ones are tied to flags for added customization.  This assumes "Initialize", "Address", and "Get XA2" were already used.


This incorporates Xif's fix to holy sword, but ties it to the weapon strike flag.  r11 carries the final element of the attack.  This overrides r1-r3.

lbu r1, 0x3904 (r16) r1 = Weapon Elemental
lbu r2, 0x38F3 (r16) r2 = Ability Flags Byte 1
lbu r3, 0x38F7 (r16) r3 = Ability Elemental
andi r2, r2, 0x0004
beq r2, r0 (E) If Weapon Strike is not flagged, GOTO (E)
addiu r21, r8, 0x0000 r21 = XA2
or r3, r3, r1 ELSE, Ability Elemental = Weapon Elemental + Ability Elemental
(E) jr 31 Returns to the Main Formula Routine.
addiu r11, r3, 0x0000 r11 = new Ability Elemental



This applies the elemental boost to an attack (set at default to 5/4 * XA2).  This overrides r1-r4, r20, and r23.

lbu r4, 0x0071 (r17) Loads elements strengthened
addiu r20, r31, 0x0000 r20 = r31 since r31 will be modified below.
and r4, r11, r4 Checks ability element against elements strengthened
beq r4, r0, (E) If ability element isn't a boosted element, GOTO (E)
addiu r1, r0, 0x0005
jal Fraction If ability element is boosted, GOTO (Fraction)
addiu r2, r0, 0x0004 The fraction to be multiplied against XA2 is 5/4.
(E)  jr 20 Return to Main Routine
nop



This applies the support boost to an attack (set at default to 4/3 * XA2 for ATKUP/MATKUP, 3/2 * XA2 for Martial Arts, and 2 * XA2 for Two Hands).  This overrides r1-r4, r20, and r23.

lbu r4, 0x0090 (r17) r4 = Support Byte 2
bne r7, r0, (NoMATKUP) If r7 isn't 0x00 (magical damage), GOTO (NoMATKUP)
addiu r20, r31, 0x0000 r20 = r31 since r31 will be modified below.
andi r3, r4, 0x0004
beq r3, r0, (NoMATKUP) If r3 is zero (meaning no MATKUP is used), GOTO (NoMATKUP)
addiu r1, r0, 0x0004
jal (Fraction) If attack is magical and MATKUP is used, GOTO (Fraction)
addiu r2, r0, 0x0003 The fraction to be multiplied against XA2 is 4/3.
(NoMATKUP) andi r2, r7, 0x0003
beq r2, r0, (NoATKUP) If r7 isn't 0x01 or 0x02 (PA/SP/W-EV/SP-EV/WP), GOTO (NoATKUP)
andi r3, r4, 0x0010
beq r3, r0, (NoATKUP) If r3 is zero (meaning no ATKUP is used), GOTO (NoATKUP)
addiu r1, r0, 0x0004
jal (Fraction) If attack is physical and ATKUP is used, GOTO (Fraction)
addiu r2, r0, 0x0003 The fraction to be multiplied against XA2 is 4/3.
(NoATKUP) lbu r4, 0x0091 (r17) r4 = Support Byte 3
ori r3, r0, 0x0001
bne r3, r7 (NoMar-A) If r7 isn't 0x01 (PA/SP/W-EV/SP-EV), GOTO (NoMar-A)
lbu r1, 0x38E5 (r16) r1 = Skill Formula #
lbu r2, 0x38D8 (r16) r2 = Weapon ID #
sltiu r1, r1, 0x0008
beq r1, r0 (NotATTACK) If skill formula isn't less than 0x08 (isn't a weapon formula), GOTO (NotATTACK)
andi r3, r4, 0x0020
beq r2, r0 (NoMar-A) If using weapon formula and equipping a non-fist weapon, GOTO (NoMar-A)
nop
(NotATTACK) beq r3, r0, (NoMar-A) If r3 is zero (meaning no Martial Arts is used), GOTO (NoMar-A)
addiu r1, r0, 0x0003
jal (Fraction) If attack is non-weapon in both ID and XA2 and Martial Arts is used, GOTO (Fraction)
addiu r2, r0, 0x0002 The fraction to be multiplied against XA2 is 3/2.
(NoMar-A) ori r3, r0, 0x0002
bne r3, r7 (End) If r7 isn't 0x02 (WP), GOTO (End)
lbu r1, 0x38D9 (r16) r1 = 0x01 if 2H is active.
lbu r2, 0x38FF (r16) r2 = Weapon Characteristics byte
beq r1, r0 (End) If 2H is inactive (not being equipped or not being used due to a RH and LH equip), GOTO (End)
andi r3, r2, 0x0001
bne r3, r0 (End) If weapon is Forced 2H, GOTO (End)
andi r3, r2, 0x0004
beq r3, r0 (End) If weapon is not 2H-able, GOTO (End)
addiu r1, r0, 0x0004
jal (Fraction) ELSE, GOTO (Fraction)
addiu r2, r0, 0x0002 The fraction to be multiplied against XA2 is 4/2 (the subroutine Fraction will mess up if you multiply anything with a denominator of 1).
(End)  jr 20 Return to Main Routine
nop

NOTE: For the above to work correctly, you must apply the following ASM hack as well.
BATTLE.BIN:
0x124734
00000000
00000000
08001092
00000000
302E0608



This applies the defensive multiplier to an attack (set at default to 2/3 * XA2 for Protect/Shell/DEFUP/MADEF).  Attacks will take Protect and DEFUP if the AI flag "Defense Up" is flagged and will take Shell and MADEF if the AI flag "Magic Defense Up" is flagged.  This overrides r1-r4, r8, r20, and r23.

addiu r20, r31, 0x0000 r20 = r31, since r31 will be modified below
lbu r4, 0x0006 (r19) r4 = AI Byte 6
lbu r8, 0x005B (r3) r8 = Status Byte 4
andi r1, r4, 0x0002
beq r1, r0 (Prot) If Magic Defense Up is not checked, GOTO (Prot)
andi r2, r8, 0x0010
beq r2, r0 (Prot) If target does not have Shell, GOTO (Prot)
addiu r1, r0, 0x0002
jal (Fraction) If attack takes MADEF and target has Shell, GOTO (Fraction)
addiu r2, r0, 0x0003 The fraction to be multiplied against XA2 is 2/3.
(Prot) andi r1, r4, 0x0001
beq r1, r0 (MADEF) If flag Defense Up is not checked, GOTO (MADEF)
andi r2, r8, 0x0020
beq r2, r0 (MADEF) If target does not have Protect, GOTO (MADEF)
addiu r1, r0, 0x0002
jal (Fraction) If attack takes DEFUP and target has Protect, GOTO (Fraction)
addiu r2, r0, 0x0003 The fraction to be multiplied against XA2 is 2/3.
(MADEF) lbu r8, 0x0090 (r3) r8 = Support Byte 2
andi r1, r4, 0x0002
beq r1, r0 (DEFUP) If flag Magic Defense Up is not checked, GOTO (DEFUP)
andi r2, r8, 0x0002
beq r2, r0 (DEFUP) If target does not have Magic Defense Up, GOTO (DEFUP)
addiu r1, r0, 0x0002
jal (Fraction) If attack takes MADEF and target has MADEF, GOTO (Fraction)
addiu r2, r0, 0x0003 The fraction to be multiplied against XA2 is 2/3.
(DEFUP) andi r1, r4, 0x0001
beq r5, r0 (E) If flag Defense Up is not checked, GOTO (E)
andi r2, r8, 0x0008
beq r2, r0 (E) If target does not have Defense Up, GOTO (E)
addiu r1, r0, 0x0002
jal (Fraction) If attack takes DEFUP and target has DEFUP, GOTO (Fraction)
addiu r2, r0, 0x0003 The fraction to be multiplied against XA2 is 2/3.
(E) jr r20 Return to Main Routine
nop
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on September 16, 2011, 06:00:56 am

0017b4d0: 27bdffb0 addiu r29,r29,0xffb0
0017b4d4: afb50044 sw r21,0x0044(r29)
0017b4d8: 0000a821 addu r21,r0,r0
0017b4dc: 27a50018 addiu r5,r29,0x0018
0017b4e0: afbf004c sw r31,0x004c(r29)
0017b4e4: afb60048 sw r22,0x0048(r29)
0017b4e8: afb40040 sw r20,0x0040(r29)
0017b4ec: afb3003c sw r19,0x003c(r29)
0017b4f0: afb20038 sw r18,0x0038(r29)
0017b4f4: afb10034 sw r17,0x0034(r29)
0017b4f8: 0c01788b jal 0x0005e22c
0017b4fc: afb00030 sw r16,0x0030(r29)
0017b500: 3407fe62 ori r7,r0,0xfe62
0017b504: 97a6001c lhu r6,0x001c(r29)
0017b508: 93a30018 lbu r3,0x0018(r29)
0017b50c: 97a5001e lhu r5,0x001e(r29)
0017b510: 00c72021 addu r4,r6,r7  r4 = 00-07 if calculator skills, r6 = CT/Height/LVL/EXP Parameter?
0017b514: 000310c0 sll r2,r3,0x03
0017b518: 00431023 subu r2,r2,r3
0017b51c: 00021180 sll r2,r2,0x06
0017b520: 3c038019 lui r3,0x8019
0017b524: 246308cc addiu r3,r3,0x08cc
0017b528: 3084ffff andi r4,r4,0xffff
0017b52c: 2c840008 sltiu r4,r4,0x0008
0017b530: 10800019 beq r4,r0,0x0017b598 if r4 isn't 00-07, GOTO END and r2 = 0xFFFF
0017b534: 0043b021 addu r22,r2,r3
0017b538: 00a71021 addu r2,r5,r7 r2 = 00-07 if calculator skills, r5 = Prime/5/4/3 Parameter?
0017b53c: 3042ffff andi r2,r2,0xffff
0017b540: 2c420008 sltiu r2,r2,0x0008
0017b544: 10400014 beq r2,r0,0x0017b598 if r2 isn't 00-07, GOTO END and r2 = 0xFFFF
0017b548: 00061c00 sll r3,r6,0x10
0017b54c: 00031c03 sra r3,r3,0x10
0017b550: 3c048006 lui r4,0x8006
0017b554: 24840eb6 addiu r4,r4,0x0eb6
0017b558: 00641821 addu r3,r3,r4
0017b55c: 00051400 sll r2,r5,0x10
0017b560: 00021403 sra r2,r2,0x10
0017b564: 00441021 addu r2,r2,r4
0017b568: 90730000 lbu r19,0x0000(r3)
0017b56c: 90510000 lbu r17,0x0000(r2)
0017b570: 326300f0 andi r3,r19,0x00f0
0017b574: 10600008 beq r3,r0,0x0017b598
0017b578: 3222000f andi r2,r17,0x000f
0017b57c: 10400006 beq r2,r0,0x0017b598
0017b580: 3262000f andi r2,r19,0x000f
0017b584: 14400080 bne r2,r0,0x0017b788
0017b588: 2402ffff addiu r2,r0,0xffff
0017b58c: 322200f0 andi r2,r17,0x00f0
0017b590: 10400003 beq r2,r0,0x0017b5a0
0017b594: 00000000 nop
0017b598: 0805ede2 j 0x0017b788 If there aren't 4 Grid Params or 4 Num Params, GOTO END
0017b59c: 2402ffff addiu r2,r0,0xffff
0017b5a0: 0c05ed28 jal 0x0017b4a0 //Initialize Grid
0017b5a4: 00009021 addu r18,r0,r0
0017b5a8: 0000a021 addu r20,r0,r0
0017b5ac: 3c028019 lui r2,0x8019
0017b5b0: 244208cc addiu r2,r2,0x08cc
0017b5b4: 02828021 addu r16,r20,r2
0017b5b8: 92030001 lbu r3,0x0001(r16)
0017b5bc: 340200ff ori r2,r0,0x00ff
0017b5c0: 1062006c beq r3,r2,0x0017b774 If unit doesn't exist, Check NEXT UNIT
0017b5c4: 00000000 nop
0017b5c8: 92020058 lbu r2,0x0058(r16)
0017b5cc: 00000000 nop
0017b5d0: 30420044 andi r2,r2,0x0044
0017b5d4: 14400067 bne r2,r0,0x0017b774 If unit is jumping or crystallized, Check NEXT UNIT
0017b5d8: 00000000 nop
0017b5dc: 92020059 lbu r2,0x0059(r16)
0017b5e0: 00000000 nop
0017b5e4: 30420001 andi r2,r2,0x0001
0017b5e8: 14400062 bne r2,r0,0x0017b774 If unit is treasure boxed, Check NEXT UNIT.
0017b5ec: 00000000 nop
0017b5f0: 92020182 lbu r2,0x0182(r16)
0017b5f4: 00000000 nop
0017b5f8: 30420040 andi r2,r2,0x0040
0017b5fc: 1440005d bne r2,r0,0x0017b774 If unit is riding a chocobo, Check NEXT UNIT
0017b600: 32620080 andi r2,r19,0x0080
0017b604: 1040000a beq r2,r0,0x0017b630 If not CT, GOTO check LEVEL
0017b608: 32620040 andi r2,r19,0x0040
0017b60c: 92040039 lbu r4,0x0039(r16)
0017b610: 00000000 nop
0017b614: 2c820065 sltiu r2,r4,0x0065
0017b618: 10400003 beq r2,r0,0x0017b628 If CT > 100, treat CT as 100.
0017b61c: 00000000 nop
0017b620: 16160016 bne r16,r22,0x0017b67c If Target isn't Self, r5 = CT.
0017b624: 308500ff andi r5,r4,0x00ff
0017b628: 0805ed9e j 0x0017b678 If CT > 100 or Target is Self, CT = 100
0017b62c: 34040064 ori r4,r0,0x0064
0017b630: 10400004 beq r2,r0,0x0017b644 If not LVL, GOTO EXP
0017b634: 32620020 andi r2,r19,0x0020
0017b638: 92040022 lbu r4,0x0022(r16)
0017b63c: 0805ed9f j 0x0017b67c
0017b640: 308500ff andi r5,r4,0x00ff ELSE, r5 = LVL
0017b644: 10400004 beq r2,r0,0x0017b658 If not EXP, GOTO HEight
0017b648: 27a40010 addiu r4,r29,0x0010
0017b64c: 92040021 lbu r4,0x0021(r16)
0017b650: 0805ed9f j 0x0017b67c
0017b654: 308500ff andi r5,r4,0x00ff ELSE, r5 = EXP
0017b658: 0c05f056 jal 0x0017c158 If Height, r5 = Height
0017b65c: 02402821 addu r5,r18,r0
0017b660: 93a40015 lbu r4,0x0015(r29)
0017b664: 00000000 nop
0017b668: 30820001 andi r2,r4,0x0001
0017b66c: 14400041 bne r2,r0,0x0017b774 If ??? is 1, GOTO Check NExt Unit
0017b670: 00000000 nop
0017b674: 00042042 srl r4,r4,0x01
0017b678: 308500ff andi r5,r4,0x00ff r5 = r4 / 2, so r4 = ??? = Height in half tiles?  If that's the case, then why even run jal 0x17c158?
0017b67c: 10a0003d beq r5,r0,0x0017b774 If ??? = 0 or 1, GOTO Check Next Unit
0017b680: 32220008 andi r2,r17,0x0008
0017b684: 1040000e beq r2,r0,0x0017b6c0 If not Prime, GOTO Check 5
0017b688: 00003021 addu r6,r0,r0
0017b68c: 00001821 addu r3,r0,r0
0017b690: 00a02021 addu r4,r5,r0
0017b694: 3c018006 lui r1,0x8006
0017b698: 00230821 addu r1,r1,r3
0017b69c: 90226198 lbu r2,0x6198(r1)
0017b6a0: 00000000 nop
0017b6a4: 10440026 beq r2,r4,0x0017b740 If Prime = Above Param, Unit = Hit
0017b6a8: 24630001 addiu r3,r3,0x0001
0017b6ac: 28620036 slti r2,r3,0x0036
0017b6b0: 10400024 beq r2,r0,0x0017b744 If no prime = Above Param, Check Next Unit
0017b6b4: 00000000 nop
0017b6b8: 0805eda5 j 0x0017b694
0017b6bc: 00000000 nop
0017b6c0: 32220004 andi r2,r17,0x0004
0017b6c4: 1040000b beq r2,r0,0x0017b6f4 If not 5, GOTO Check 4
0017b6c8: 3c02cccc lui r2,0xcccc
0017b6cc: 3442cccd ori r2,r2,0xcccd
0017b6d0: 00a20019 multu r5,r2
0017b6d4: 00001810 mfhi r3
0017b6d8: 00031882 srl r3,r3,0x02
0017b6dc: 00031080 sll r2,r3,0x02
0017b6e0: 00431021 addu r2,r2,r3
0017b6e4: 00a21023 subu r2,r5,r2
0017b6e8: 304200ff andi r2,r2,0x00ff
0017b6ec: 10400014 beq r2,r0,0x0017b740 If x MOD 5 = 0, Unit = HIT
0017b6f0: 00000000 nop
0017b6f4: 32220002 andi r2,r17,0x0002
0017b6f8: 10400003 beq r2,r0,0x0017b708 If NOT 4, Check 3
0017b6fc: 30820003 andi r2,r4,0x0003
0017b700: 1040000f beq r2,r0,0x0017b740 If X MOD 4 = 0, Check Next unit
0017b704: 00000000 nop
0017b708: 32220001 andi r2,r17,0x0001
0017b70c: 1040000d beq r2,r0,0x0017b744
0017b710: 3c02aaaa lui r2,0xaaaa
0017b714: 3442aaab ori r2,r2,0xaaab
0017b718: 308400ff andi r4,r4,0x00ff
0017b71c: 00820019 multu r4,r2
0017b720: 00001810 mfhi r3
0017b724: 00031842 srl r3,r3,0x01
0017b728: 00031040 sll r2,r3,0x01
0017b72c: 00431021 addu r2,r2,r3
0017b730: 00822023 subu r4,r4,r2
0017b734: 308400ff andi r4,r4,0x00ff
0017b738: 14800002 bne r4,r0,0x0017b744 If X MOD 3 != 0, Check NExt Unit
0017b73c: 00000000 nop
0017b740: 34060001 ori r6,r0,0x0001
0017b744: 10c0000b beq r6,r0,0x0017b774
0017b748: 00000000 nop
0017b74c: 0c060428 jal 0x001810a0 Find X/Y coordinate of target
0017b750: 02002021 addu r4,r16,r0
0017b754: 000210c0 sll r2,r2,0x03
0017b758: 3c038019 lui r3,0x8019
0017b75c: 2463f8cc addiu r3,r3,0xf8cc
0017b760: 00431021 addu r2,r2,r3
0017b764: 90430005 lbu r3,0x0005(r2)
0017b768: 26b50001 addiu r21,r21,0x0001
0017b76c: 34630080 ori r3,r3,0x0080
0017b770: a0430005 sb r3,0x0005(r2) Flag X/Y coordinate as green = target.
0017b774: 26520001 addiu r18,r18,0x0001
0017b778: 2a420015 slti r2,r18,0x0015
0017b77c: 1440ff8b bne r2,r0,0x0017b5ac
0017b780: 269401c0 addiu r20,r20,0x01c0 Pointer = next unit's data.
0017b784: 02a01021 addu r2,r21,r0 RETURN (r2) = # of units hit
0017b788: 8fbf004c lw r31,0x004c(r29)
0017b78c: 8fb60048 lw r22,0x0048(r29)
0017b790: 8fb50044 lw r21,0x0044(r29)
0017b794: 8fb40040 lw r20,0x0040(r29)
0017b798: 8fb3003c lw r19,0x003c(r29)
0017b79c: 8fb20038 lw r18,0x0038(r29)
0017b7a0: 8fb10034 lw r17,0x0034(r29)
0017b7a4: 8fb00030 lw r16,0x0030(r29)
0017b7a8: 27bd0050 addiu r29,r29,0x0050
0017b7ac: 03e00008 jr r31
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on September 18, 2011, 06:15:57 am
Here's more basic research from me...and this is only half the routine.


0018b34c: 27bdffc8 addiu r29,r29,0xffc8
0018b350: afb00028 sw r16,0x0028(r29)
0018b354: 00a08021 addu r16,r5,r0
0018b358: 27a50010 addiu r5,r29,0x0010
0018b35c: afbf0034 sw r31,0x0034(r29)
0018b360: afb20030 sw r18,0x0030(r29)
0018b364: 0c01788b jal 0x0005e22c
0018b368: afb1002c sw r17,0x002c(r29)
0018b36c: 3c018019 lui r1,0x8019
0018b370: a03038c1 sb r16,0x38c1(r1) Store ID of the defending unit.
0018b374: 321000ff andi r16,r16,0x00ff
0018b378: 001010c0 sll r2,r16,0x03
0018b37c: 00501023 subu r2,r2,r16
0018b380: 00021180 sll r2,r2,0x06
0018b384: 3c048019 lui r4,0x8019
0018b388: 248408cc addiu r4,r4,0x08cc
0018b38c: 00441821 addu r3,r2,r4
0018b390: 3c018019 lui r1,0x8019
0018b394: ac232d98 sw r3,0x2d98(r1) Store pointer of the defending unit.
0018b398: 2483018c addiu r3,r4,0x018c
0018b39c: 00431021 addu r2,r2,r3
0018b3a0: 93a30010 lbu r3,0x0010(r29)
0018b3a4: 3c018019 lui r1,0x8019
0018b3a8: ac222d90 sw r2,0x2d90(r1) Store pointer2 of defending unit
0018b3ac: 3c028019 lui r2,0x8019
0018b3b0: 244238c0 addiu r2,r2,0x38c0
0018b3b4: 3c018019 lui r1,0x8019
0018b3b8: a020390e sb r0,0x390e(r1) Store 0 into ????
0018b3bc: a0430000 sb r3,0x0000(r2) Store ID of the attacking unit.
0018b3c0: 90430000 lbu r3,0x0000(r2)
0018b3c4: 3c028019 lui r2,0x8019
0018b3c8: 24422da0 addiu r2,r2,0x2da0
0018b3cc: 3c018019 lui r1,0x8019
0018b3d0: ac222d8c sw r2,0x2d8c(r1) Stores 192da0 into Pointer2 of attacking unit?!
0018b3d4: 000310c0 sll r2,r3,0x03
0018b3d8: 00431023 subu r2,r2,r3
0018b3dc: 00021180 sll r2,r2,0x06
0018b3e0: 3c038019 lui r3,0x8019
0018b3e4: 8c63f5f0 lw r3,-0x0a10(r3)
0018b3e8: 00441021 addu r2,r2,r4
0018b3ec: 3c018019 lui r1,0x8019
0018b3f0: ac222d94 sw r2,0x2d94(r1) Store pointer of attacking unit
0018b3f4: 10600009 beq r3,r0,0x0018b41c If Reaction did not activate, GOTO ???
0018b3f8: 00000000 nop
0018b3fc: 0c062bcb jal 0x0018af2c ELSE, setup Reaction
0018b400: 00000000 nop
0018b404: 10400005 beq r2,r0,0x0018b41c If reaction failed, GOTO ???
0018b408: 00000000 nop
0018b40c: 0c062c9d jal 0x0018b274 Store correct weapon ID, modified by action menu ID (this should be deleted anyways)
0018b410: 27a40010 addiu r4,r29,0x0010
0018b414: 08062e77 j 0x0018b9dc GOTO END
0018b418: 00001021 addu r2,r0,r0
0018b41c: 3c028019 lui r2,0x8019
0018b420: 904238ed lbu r2,0x38ed(r2)
0018b424: 00000000 nop
0018b428: 30420080 andi r2,r2,0x0080
0018b42c: 10400005 beq r2,r0,0x0018b444 If NOT Crystal/Treasure Box/Please Eat(?), GOTO normal attack
0018b430: 00000000 nop
0018b434: 0c062b8f jal 0x0018ae3c Erase unit from map (?)
0018b438: 00000000 nop
0018b43c: 08062e77 j 0x0018b9dc GOTO END
0018b440: 00001021 addu r2,r0,r0
0018b444: 3c048019 lui r4,0x8019
0018b448: 8c842d98 lw r4,0x2d98(r4)
0018b44c: 0c060428 jal 0x001810a0
0018b450: 00000000 nop
0018b454: 000210c0 sll r2,r2,0x03
0018b458: 3c018019 lui r1,0x8019
0018b45c: 00220821 addu r1,r1,r2
0018b460: 9022f8cc lbu r2,-0x0734(r1)
0018b464: 3c038019 lui r3,0x8019
0018b468: 906338c3 lbu r3,0x38c3(r3)
0018b46c: 3042003f andi r2,r2,0x003f
0018b470: 3c018019 lui r1,0x8019
0018b474: a02238cd sb r2,0x38cd(r1) Store terrain type into 1938cd.
0018b478: 14600005 bne r3,r0,0x0018b490
0018b47c: 00000000 nop
0018b480: 3c078019 lui r7,0x8019
0018b484: 90e738c4 lbu r7,0x38c4(r7)
0018b488: 08062d26 j 0x0018b498
0018b48c: 00000000 nop
0018b490: 3c078019 lui r7,0x8019
0018b494: 90e738c5 lbu r7,0x38c5(r7)
0018b498: 93a30011 lbu r3,0x0011(r29) Load equipment ID type
0018b49c: 34020013 ori r2,r0,0x0013
0018b4a0: 14620004 bne r3,r2,0x0018b4b4 If not shields, r2 is weapon ID
0018b4a4: 30e200ff andi r2,r7,0x00ff
0018b4a8: 93a70018 lbu r7,0x0018(r29)
0018b4ac: 00000000 nop
0018b4b0: 30e200ff andi r2,r7,0x00ff ELSE, r2 = 0xFF
0018b4b4: 2c420080 sltiu r2,r2,0x0080
0018b4b8: 14400002 bne r2,r0,0x0018b4c4
0018b4bc: 00000000 nop
0018b4c0: 00003821 addu r7,r0,r0 If equipment type was shields, weapon ID = 0
0018b4c4: 97a30012 lhu r3,0x0012(r29)
0018b4c8: 3c108019 lui r16,0x8019
0018b4cc: 261038d8 addiu r16,r16,0x38d8
0018b4d0: a2070000 sb r7,0x0000(r16) Store weapon ID.
0018b4d4: 3c018019 lui r1,0x8019
0018b4d8: a42338d6 sh r3,0x38d6(r1) Store used ability ID.
0018b4dc: 3c028019 lui r2,0x8019
0018b4e0: 944238d6 lhu r2,0x38d6(r2)
0018b4e4: 3c018019 lui r1,0x8019
0018b4e8: a02038d9 sb r0,0x38d9(r1) Set 2H to false.
0018b4ec: 2c420171 sltiu r2,r2,0x0171
0018b4f0: 14400002 bne r2,r0,0x0018b4fc If Move ID < Hi-Potion (shouldn't this be potion?), GOTO get ability pointer.
0018b4f4: 26050018 addiu r5,r16,0x0018
0018b4f8: 00001821 addu r3,r0,r0 ELSE, load the pointer of first attack.
0018b4fc: 000320c0 sll r4,r3,0x03
0018b500: 00832023 subu r4,r4,r3
0018b504: 00042040 sll r4,r4,0x01
0018b508: 3c028006 lui r2,0x8006
0018b50c: 2442fbf0 addiu r2,r2,0xfbf0
0018b510: 00822021 addu r4,r4,r2
0018b514: 3406000e ori r6,r0,0x000e
0018b518: 30e200ff andi r2,r7,0x00ff
0018b51c: 000210c0 sll r2,r2,0x03 r2 = weapon ID * 8
0018b520: 3c038006 lui r3,0x8006
0018b524: 24633ab8 addiu r3,r3,0x3ab8
0018b528: 0c017895 jal 0x0005e254 Store ability data into 0x1938f0-d
0018b52c: 00438821 addu r17,r2,r3 r17 = pointer of weapon
0018b530: 02202021 addu r4,r17,r0
0018b534: 26050026 addiu r5,r16,0x0026
0018b538: 0c017895 jal 0x0005e254 Store weapon data into 0x1938fe-905
0018b53c: 34060008 ori r6,r0,0x0008
0018b540: 92240007 lbu r4,0x0007(r17)
0018b544: 3c038019 lui r3,0x8019
0018b548: 8c632d94 lw r3,0x2d94(r3)
0018b54c: 34020001 ori r2,r0,0x0001
0018b550: 3c018019 lui r1,0x8019
0018b554: a02038e4 sb r0,0x38e4(r1) Default Charge (on charged attacks) = 0
0018b558: 3c018019 lui r1,0x8019
0018b55c: a02238e5 sb r2,0x38e5(r1) Default formula = 01
0018b560: 3c018019 lui r1,0x8019
0018b564: a02438da sb r4,0x38da(r1) Store weapon proc
0018b568: 90620026 lbu r2,0x0026(r3)
0018b56c: 3c038019 lui r3,0x8019
0018b570: 8c632d98 lw r3,0x2d98(r3)
0018b574: 3c018019 lui r1,0x8019
0018b578: a02238d3 sb r2,0x38d3(r1) Store faith of attacker (never used)
0018b57c: 90620026 lbu r2,0x0026(r3)
0018b580: 3c018019 lui r1,0x8019
0018b584: a02238d2 sb r2,0x38d2(r1) Store faith of defender (never used)
0018b588: 0c062b7d jal 0x0018adf4 Clear micro-unit RAM (this code in SCUS is terribly inefficient), but set attack type = psuedo-status, hit = true, and base accuracy = 100%
0018b58c: 00000000 nop
0018b590: 93a20011 lbu r2,0x0011(r29)
0018b594: 3c038019 lui r3,0x8019
0018b598: 946338c8 lhu r3,0x38c8(r3) r3 = 0x1 if spell proc is true, and 0x0 otherwise
0018b59c: 3c018019 lui r1,0x8019
0018b5a0: a02238d4 sb r2,0x38d4(r1) Store Action Menu # (put a read on this location to find hard-coded WTF)
0018b5a4: 304200ff andi r2,r2,0x00ff
0018b5a8: 3c018006 lui r1,0x8006
0018b5ac: 00220821 addu r1,r1,r2
0018b5b0: 90325cb4 lbu r18,0x5cb4(r1) r18 = Action Menu ID
0018b5b4: 10600009 beq r3,r0,0x0018b5dc
0018b5b8: 00000000 nop
0018b5bc: 3c028019 lui r2,0x8019
0018b5c0: 944238c6 lhu r2,0x38c6(r2)
0018b5c4: 00000000 nop
0018b5c8: a7a20012 sh r2,0x0012(r29) If Spell proc is true, store proc ID as used ability ID (temporary)
0018b5cc: 3c018019 lui r1,0x8019
0018b5d0: a42238d6 sh r2,0x38d6(r1) Store proc ID as used ability ID (unit RAM)
0018b5d4: 08062d79 j 0x0018b5e4
0018b5d8: 00009021 addu r18,r0,r0 Ignore action menu ID.
0018b5dc: 3c018019 lui r1,0x8019
0018b5e0: a42038c6 sh r0,0x38c6(r1) If Spell proc is false, proc ID = 0.
0018b5e4: 87a30012 lh r3,0x0012(r29)
0018b5e8: 3c028006 lui r2,0x8006
0018b5ec: 2442ebf0 addiu r2,r2,0xebf0
0018b5f0: 000318c0 sll r3,r3,0x03 Load AI pointer of used ability
0018b5f4: 00621821 addu r3,r3,r2
0018b5f8: 90620004 lbu r2,0x0004(r3)
0018b5fc: 3c048019 lui r4,0x8019
0018b600: 8c842d90 lw r4,0x2d90(r4)
0018b604: 30420003 andi r2,r2,0x0003
0018b608: a0820018 sb r2,0x0018(r4) Store target enemy/self flags into byte 0x18 of target's micro-unit RAM
0018b60c: 90620007 lbu r2,0x0007(r3)
0018b610: 00000000 nop
0018b614: 30420001 andi r2,r2,0x0001
0018b618: 10400009 beq r2,r0,0x0018b640
0018b61c: 324300ff andi r3,r18,0x00ff
0018b620: 3c038019 lui r3,0x8019
0018b624: 8c632d90 lw r3,0x2d90(r3)
0018b628: 00000000 nop
0018b62c: 90620018 lbu r2,0x0018(r3)
0018b630: 00000000 nop
0018b634: 24420080 addiu r2,r2,0x0080
0018b638: a0620018 sb r2,0x0018(r3) If animate on miss, store animate on miss flag as bit 8 into byte 0x18 of target's micro-unit RAM
0018b63c: 324300ff andi r3,r18,0x00ff
0018b640: 34020007 ori r2,r0,0x0007
0018b644: 14620006 bne r3,r2,0x0018b660 Branch if Action Menu Type isn't Draw Out
0018b648: 2c62000b sltiu r2,r3,0x000b
0018b64c: 93a20018 lbu r2,0x0018(r29)
0018b650: 00000000 nop
0018b654: 24420026 addiu r2,r2,0x0026
0018b658: a7a20012 sh r2,0x0012(r29) If Draw Out, store weapon ID of katana as used ability ID (temp).
0018b65c: 2c62000b sltiu r2,r3,0x000b
0018b660: 10400095 beq r2,r0,0x0018b8b8 Branch if Action Menu Type is defend/equip change; weapon formula = 0x01
0018b664: 00031080 sll r2,r3,0x02
0018b668: 3c018017 lui r1,0x8017
0018b66c: 00220821 addu r1,r1,r2
0018b670: 8c224344 lw r2,0x4344(r1)
0018b674: 00000000 nop
0018b678: 00400008 jr r2
0018b67c: 00000000 nop
0018b680: 3c048019 lui r4,0x8019
0018b684: 8c842d94 lw r4,0x2d94(r4)
0018b688: 0c05fcb6 jal 0x0017f2d8 ELEMENTAL terrain to skill hard-coding
0018b68c: 00000000 nop
0018b690: a7a20012 sh r2,0x0012(r29)
0018b694: 87a20012 lh r2,0x0012(r29)
0018b698: 00000000 nop
0018b69c: 28420171 slti r2,r2,0x0171
0018b6a0: 10400086 beq r2,r0,0x0018b8bc Branch if Move ID >= Hi-Potion (shouldn't this be potion?) to get formula address, using the basic attack formula
0018b6a4: 34100001 ori r16,r0,0x0001
0018b6a8: 3c028019 lui r2,0x8019
0018b6ac: 8c422d94 lw r2,0x2d94(r2)
0018b6b0: 00000000 nop
0018b6b4: 9042005a lbu r2,0x005a(r2)
0018b6b8: 00000000 nop
0018b6bc: 30420002 andi r2,r2,0x0002
0018b6c0: 1040000d beq r2,r0,0x0018b6f8 Branch if not frogged
0018b6c4: 00000000 nop
0018b6c8: 3c058019 lui r5,0x8019
0018b6cc: 24a538c8 addiu r5,r5,0x38c8
0018b6d0: 94a20000 lhu r2,0x0000(r5)
0018b6d4: 00000000 nop
0018b6d8: 14400007 bne r2,r0,0x0018b6f8 Branch if spell proc is true (but I don't recall frogged holy lance users doing normal damage, so frog probably overrides this byte; check is redundant)
0018b6dc: 24a50036 addiu r5,r5,0x0036
0018b6e0: 3c018019 lui r1,0x8019
0018b6e4: a02038d8 sb r0,0x38d8(r1) If frogged and no spell proc, weapon ID = 0.
0018b6e8: 3c048006 lui r4,0x8006
0018b6ec: 24843ab8 addiu r4,r4,0x3ab8
0018b6f0: 0c017895 jal 0x0005e254 Store data for the null weapon (fists) into 0x1938fe-905
0018b6f4: 34060008 ori r6,r0,0x0008
0018b6f8: 3c058019 lui r5,0x8019
0018b6fc: 24a538f0 addiu r5,r5,0x38f0
0018b700: 87a20012 lh r2,0x0012(r29)
0018b704: 3406000e ori r6,r0,0x000e
0018b708: 000280c0 sll r16,r2,0x03
0018b70c: 02028023 subu r16,r16,r2
0018b710: 00108040 sll r16,r16,0x01
0018b714: 3c028006 lui r2,0x8006
0018b718: 2442fbf0 addiu r2,r2,0xfbf0
0018b71c: 02028021 addu r16,r16,r2
0018b720: 0c017895 jal 0x0005e254 Store ability data into 0x1938f0-d (but didn't we already do this?)
0018b724: 02002021 addu r4,r16,r0
0018b728: 9202000b lbu r2,0x000b(r16)
0018b72c: 3c018019 lui r1,0x8019
0018b730: a02238da sb r2,0x38da(r1) Store status proc from spell
0018b734: 3c028019 lui r2,0x8019
0018b738: 904238f3 lbu r2,0x38f3(r2)
0018b73c: 92100008 lbu r16,0x0008(r16)
0018b740: 30420024 andi r2,r2,0x0024
0018b744: 1440005e bne r2,r0,0x0018b8c0 Branch if ranged weapon or weapon strike to get formula address, using the spell's formula
0018b748: 320200ff andi r2,r16,0x00ff
0018b74c: 324300ff andi r3,r18,0x00ff
0018b750: 34020007 ori r2,r0,0x0007
0018b754: 1062005a beq r3,r2,0x0018b8c0 Branch if Draw Out to get formula address, using the spell's formula
0018b758: 320200ff andi r2,r16,0x00ff
0018b75c: 3c018019 lui r1,0x8019
0018b760: a02038d8 sb r0,0x38d8(r1) If not, Used Weapon ID = 0
0018b764: 08062e2f j 0x0018b8bc Jump to get formula address, using the spell's formula [but WP = 0]
0018b768: 00000000 nop
0018b76c: 93a70018 lbu r7,0x0018(r29)
0018b770: 00000000 nop
0018b774: 2ce200f0 sltiu r2,r7,0x00f0
0018b778: 14400050 bne r2,r0,0x0018b8bc Branch if ITEM was not used
0018b77c: 34100001 ori r16,r0,0x0001
0018b780: 3c048019 lui r4,0x8019
0018b784: 248438d8 addiu r4,r4,0x38d8
0018b788: a0870000 sb r7,0x0000(r4) If ITEM was used, store item ID as Used Weapon ID.
0018b78c: 24e70010 addiu r7,r7,0x0010
0018b790: 24840018 addiu r4,r4,0x0018
0018b794: 30e200ff andi r2,r7,0x00ff
0018b798: 00028040 sll r16,r2,0x01
0018b79c: 02028021 addu r16,r16,r2
0018b7a0: 3c028006 lui r2,0x8006
0018b7a4: 24423f98 addiu r2,r2,0x3f98
0018b7a8: 02028021 addu r16,r16,r2
0018b7ac: 3c018019 lui r1,0x8019
0018b7b0: a02738db sb r7,0x38db(r1) Store item used as Conusmable ID (which is simply item ID - 0xF0)
0018b7b4: 92020002 lbu r2,0x0002(r16)
0018b7b8: 3c018019 lui r1,0x8019
0018b7bc: a02238da sb r2,0x38da(r1) Store status proc of item
0018b7c0: 0c017991 jal 0x0005e644 Set to zero ability data from 0x1938f0-d (I'm assuming ability range is then later determined)
0018b7c4: 3405000e ori r5,r0,0x000e
0018b7c8: 92100000 lbu r16,0x0000(r16)
0018b7cc: 08062e30 j 0x0018b8c0 If ITEM, get formula address of item formula.
0018b7d0: 320200ff andi r2,r16,0x00ff
0018b7d4: 08062e2f j 0x0018b8bc If THROW, get formula address with formula = 0x63
0018b7d8: 34100063 ori r16,r0,0x0063
0018b7dc: 08062e2f j 0x0018b8bc If JUMP, get formula address with formula = 0x64
0018b7e0: 34100064 ori r16,r0,0x0064
0018b7e4: 97a30012 lhu r3,0x0012(r29)
0018b7e8: 00000000 nop
0018b7ec: 2462fe6a addiu r2,r3,0xfe6a
0018b7f0: 2c420008 sltiu r2,r2,0x0008
0018b7f4: 14400003 bne r2,r0,0x0018b804 Branch if skill is CHARGE (where does CHARGE decide to always use formula 05?)
0018b7f8: 00031040 sll r2,r3,0x01
0018b7fc: 34030196 ori r3,r0,0x0196 ELSE, default to Charge +1 (if I change this a bit, should be possible to make Charge accept Charge +X attacks and normal attacks)
0018b800: 00031040 sll r2,r3,0x01
0018b804: 3c018006 lui r1,0x8006
0018b808: 00220821 addu r1,r1,r2
0018b80c: 90220d19 lbu r2,0x0d19(r1)
0018b810: 3c018019 lui r1,0x8019
0018b814: a02238e4 sb r2,0x38e4(r1) Store charge power boost
0018b818: 3c028019 lui r2,0x8019
0018b81c: 904238ff lbu r2,0x38ff(r2)
0018b820: 92300002 lbu r16,0x0002(r17)
0018b824: 30420004 andi r2,r2,0x0004
0018b828: 10400025 beq r2,r0,0x0018b8c0 If weapon can't be 2H, get formula address with formula = weapon formula
0018b82c: 320200ff andi r2,r16,0x00ff
0018b830: 3c038019 lui r3,0x8019
0018b834: 8c632d94 lw r3,0x2d94(r3)
0018b838: 00000000 nop
0018b83c: 90620091 lbu r2,0x0091(r3)
0018b840: 00000000 nop
0018b844: 30420002 andi r2,r2,0x0002
0018b848: 1040001c beq r2,r0,0x0018b8bc If 2H support is not used, get formula address with formula = weapon formula
0018b84c: 340200ff ori r2,r0,0x00ff
0018b850: 9064001d lbu r4,0x001d(r3)
0018b854: 00000000 nop
0018b858: 14820009 bne r4,r2,0x0018b880 Branch to ??? if 2H is an active support but RH weapon exists
0018b85c: 00000000 nop
0018b860: 9062001e lbu r2,0x001e(r3)
0018b864: 00000000 nop
0018b868: 14440005 bne r2,r4,0x0018b880 Branch to ??? if 2H is an active support but RH shield exists (no...this should cause auto-void)
0018b86c: 34020001 ori r2,r0,0x0001
0018b870: 3c018019 lui r1,0x8019
0018b874: a02238d9 sb r2,0x38d9(r1) ELSE, set 2H flag as true.
0018b878: 3c038019 lui r3,0x8019
0018b87c: 8c632d94 lw r3,0x2d94(r3)
0018b880: 00000000 nop
0018b884: 9064001f lbu r4,0x001f(r3)
0018b888: 340200ff ori r2,r0,0x00ff
0018b88c: 1482000c bne r4,r2,0x0018b8c0 Branch to get formula address using weapon formula if 2H is an active support and LH weapon exists
0018b890: 320200ff andi r2,r16,0x00ff
0018b894: 90620020 lbu r2,0x0020(r3)
0018b898: 00000000 nop
0018b89c: 14440008 bne r2,r4,0x0018b8c0 Branch to get formula address using weapon formula if 2H is an active support and LH shield exists
0018b8a0: 320200ff andi r2,r16,0x00ff
0018b8a4: 34020001 ori r2,r0,0x0001
0018b8a8: 3c018019 lui r1,0x8019
0018b8ac: a02238d9 sb r2,0x38d9(r1) ELSE, set 2H flag as true and get formula address using weapon formula
0018b8b0: 08062e30 j 0x0018b8c0
0018b8b4: 320200ff andi r2,r16,0x00ff
0018b8b8: 34100001 ori r16,r0,0x0001
0018b8bc: 320200ff andi r2,r16,0x00ff
0018b8c0: 3c018019 lui r1,0x8019
0018b8c4: a42038c8 sh r0,0x38c8(r1) Turn off spell proc (obviously, this would make no sense unless this routine is run twice, first by the regular attack, and then by the spell proc)
0018b8c8: 3c018019 lui r1,0x8019
0018b8cc: a02038ed sb r0,0x38ed(r1) Zero byte 0x1938ed (but this byte is always either zero....or above 0x80, in which this code gets skipped...WTF?)
0018b8d0: 10400003 beq r2,r0,0x0018b8e0
0018b8d4: 2c420065 sltiu r2,r2,0x0065
0018b8d8: 14400002 bne r2,r0,0x0018b8e4 If formula is from 0x01 to 0x64, GOTO calculate offset
0018b8dc: 00000000 nop
0018b8e0: 34100001 ori r16,r0,0x0001 ELSE, formula is hard-coded to 0x01
0018b8e4: 3c058019 lui r5,0x8019
0018b8e8: 24a538da addiu r5,r5,0x38da
0018b8ec: 90a70000 lbu r7,0x0000(r5) r7 = Spell Proc ID
0018b8f0: 321100ff andi r17,r16,0x00ff r17 = Formula ID
0018b8f4: 34020003 ori r2,r0,0x0003
0018b8f8: 16220002 bne r17,r2,0x0018b904 If formula isn't Guns, GOTO ???
0018b8fc: 24a5002c addiu r5,r5,0x002c
0018b900: 00003821 addu r7,r0,r0 If formula is guns, spell proc ID = 0
0018b904: 30e200ff andi r2,r7,0x00ff
0018b908: 00022040 sll r4,r2,0x01
0018b90c: 00822021 addu r4,r4,r2
0018b910: 00042040 sll r4,r4,0x01
0018b914: 3c028006 lui r2,0x8006
0018b918: 24423fc4 addiu r2,r2,0x3fc4
0018b91c: 00822021 addu r4,r4,r2
0018b920: 0c017895 jal 0x0005e254 Store status proc type and statii to 0x193906-0B
0018b924: 34060006 ori r6,r0,0x0006
0018b928: 0c062e7e jal 0x0018b9f8 Write status cured to 0x193860-64
0018b92c: 00000000 nop
0018b930: 3c018019 lui r1,0x8019
0018b934: a03038e5 sb r16,0x38e5(r1) Store formula ID.
0018b938: 0c063279 jal 0x0018c9e4 Hard-coded stuff (Reflect status triggers the "unused" reaction Reflect, Blade Grasp/Arrow Guard modify accuracy, spell/status proc is nulled by specials...)
0018b93c: 00000000 nop
0018b940: 3c028019 lui r2,0x8019
0018b944: 8c422d90 lw r2,0x2d90(r2)
0018b948: 00000000 nop
0018b94c: 90420000 lbu r2,0x0000(r2)
0018b950: 00000000 nop
0018b954: 14400003 bne r2,r0,0x0018b964 Branch to get formula address if attack hits.
0018b958: 00111080 sll r2,r17,0x02
0018b95c: 08062e77 j 0x0018b9dc If miss, GOTO ???
0018b960: 34020001 ori r2,r0,0x0001
0018b964: 3c018019 lui r1,0x8019
0018b968: 00220821 addu r1,r1,r2
0018b96c: 8c22f610 lw r2,-0x09f0(r1)
0018b970: 00000000 nop
0018b974: 0040f809 jalr r2,r31 Jump to Formula Routine
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Xifanie on November 29, 2011, 01:41:28 am
00143bd8: 27bdffb0 addiu r29,r29,0xffb0   
00143bdc: 34040044 ori r4,r0,0x0044       
00143be0: afbf004c sw r31,0x004c(r29)     
00143be4: afbe0048 sw r30,0x0048(r29)     
00143be8: afb70044 sw r23,0x0044(r29)     
00143bec: afb60040 sw r22,0x0040(r29)     
00143bf0: afb5003c sw r21,0x003c(r29)     
00143bf4: afb40038 sw r20,0x0038(r29)     
00143bf8: afb30034 sw r19,0x0034(r29)     
00143bfc: afb20030 sw r18,0x0030(r29)     
00143c00: afb1002c sw r17,0x002c(r29)     
00143c04: 0c052752 jal 0x00149d48         
00143c08: afb00028 sw r16,0x0028(r29)     
00143c0c: 0c04b721 jal 0x0012dc84         
00143c10: 00000000 nop                   
00143c14: 10400003 beq r2,r0,0x00143c24   
00143c18: 00000000 nop                   
00143c1c: 0c04b6f7 jal 0x0012dbdc         
00143c20: 00000000 nop                   
00143c24: 3c028016 lui r2,0x8016         
00143c28: 94425ff6 lhu r2,0x5ff6(r2)     
00143c2c: 00000000 nop                   
00143c30: 1440000c bne r2,r0,0x00143c64   
00143c34: 340200aa ori r2,r0,0x00aa       
00143c38: 34100002 ori r16,r0,0x0002     
00143c3c: 0c053274 jal 0x0014c9d0         
00143c40: 02002021 addu r4,r16,r0         
00143c44: 26100001 addiu r16,r16,0x0001   
00143c48: 2a02000e slti r2,r16,0x000e     
00143c4c: 1440fffb bne r2,r0,0x00143c3c   
00143c50: 00000000 nop                   
00143c54: 0c04b765 jal 0x0012dd94         
00143c58: 00000000 nop                   
00143c5c: 08050f21 j 0x00143c84           
00143c60: 00000000 nop                   
00143c64: 3c018017 lui r1,0x8017         
00143c68: a422864a sh r2,-0x79b6(r1)     
00143c6c: 3c018017 lui r1,0x8017         
00143c70: a4228652 sh r2,-0x79ae(r1)     
00143c74: 3c018017 lui r1,0x8017         
00143c78: a422865a sh r2,-0x79a6(r1)     
00143c7c: 3c018017 lui r1,0x8017         
00143c80: a4228662 sh r2,-0x799e(r1)     
00143c84: 0c05214f jal 0x0014853c         
00143c88: 00000000 nop                   
00143c8c: 0c04ed64 jal 0x0013b590         
00143c90: 340401fd ori r4,r0,0x01fd       
00143c94: 10400006 beq r2,r0,0x00143cb0   
00143c98: 00000000 nop                   
00143c9c: 00002021 addu r4,r0,r0         
00143ca0: 0c052336 jal 0x00148cd8         
00143ca4: 00002821 addu r5,r0,r0         
00143ca8: 08050f2f j 0x00143cbc           
00143cac: 34040028 ori r4,r0,0x0028       
00143cb0: 0c04b639 jal 0x0012d8e4         
00143cb4: 00000000 nop                   
00143cb8: 34040028 ori r4,r0,0x0028       
00143cbc: 0c04ed91 jal 0x0013b644         
00143cc0: 00002821 addu r5,r0,r0         
00143cc4: 34040029 ori r4,r0,0x0029       
00143cc8: 0c04ed91 jal 0x0013b644         
00143ccc: 00002821 addu r5,r0,r0         
00143cd0: 3404002a ori r4,r0,0x002a       
00143cd4: 0c04ed91 jal 0x0013b644         
00143cd8: 00002821 addu r5,r0,r0         
00143cdc: 0c04f680 jal 0x0013da00         
00143ce0: 34040001 ori r4,r0,0x0001       
00143ce4: 0c04b771 jal 0x0012ddc4         
00143ce8: 0000f021 addu r30,r0,r0         
00143cec: 340303e8 ori r3,r0,0x03e8       
00143cf0: 34100003 ori r16,r0,0x0003     
00143cf4: 3c028016 lui r2,0x8016         
00143cf8: 24425fee addiu r2,r2,0x5fee     
00143cfc: a4430000 sh r3,0x0000(r2)       
00143d00: 2610ffff addiu r16,r16,0xffff   
00143d04: 0601fffd bgez r16,0x00143cfc   
00143d08: 2442fffe addiu r2,r2,0xfffe     
00143d0c: 3c028017 lui r2,0x8017         
00143d10: 8c423ca4 lw r2,0x3ca4(r2)       
00143d14: 00000000 nop                   
00143d18: 005e1021 addu r2,r2,r30         
00143d1c: 24510001 addiu r17,r2,0x0001   
00143d20: 90520001 lbu r18,0x0001(r2)     
00143d24: 90550002 lbu r21,0x0002(r2)     
00143d28: 90560003 lbu r22,0x0003(r2)     
00143d2c: 90570004 lbu r23,0x0004(r2)     
00143d30: 90540000 lbu r20,0x0000(r2)     
00143d34: 0c05181e jal 0x00146078         
00143d38: 02202021 addu r4,r17,r0         
00143d3c: 00409821 addu r19,r2,r0         
00143d40: 340200c0 ori r2,r0,0x00c0       
00143d44: 12820877 beq r20,r2,0x00145f24  {C0} GOTO END
00143d48: 340200f2 ori r2,r0,0x00f2       
00143d4c: 12820875 beq r20,r2,0x00145f24  {F2} GOTO END
00143d50: 2682ff60 addiu r2,r20,0xff60   
00143d54: 2c420006 sltiu r2,r2,0x0006     
00143d58: 10400005 beq r2,r0,0x00143d70   
00143d5c: 2682ff50 addiu r2,r20,0xff50   
00143d60: 0c0527c4 jal 0x00149f10         {A0-A5}
00143d64: 02802021 addu r4,r20,r0         
00143d68: 080517c9 j 0x00145f24           GOTO END
00143d6c: 00000000 nop                   
00143d70: 2c42000f sltiu r2,r2,0x000f     
00143d74: 1040000e beq r2,r0,0x00143db0   
00143d78: 3402004d ori r2,r0,0x004d       
00143d7c: 3c048017 lui r4,0x8017          {B0-BE}
00143d80: 8c843ca4 lw r4,0x3ca4(r4)       
00143d84: 3272ffff andi r18,r19,0xffff   
00143d88: 03c42021 addu r4,r30,r4         
00143d8c: 0c05181e jal 0x00146078         
00143d90: 24840003 addiu r4,r4,0x0003     
00143d94: 02802021 addu r4,r20,r0         
00143d98: 02402821 addu r5,r18,r0         
00143d9c: 3046ffff andi r6,r2,0xffff     
00143da0: 0c052806 jal 0x0014a018         
00143da4: 00003821 addu r7,r0,r0         
00143da8: 080517c9 j 0x00145f24           GOTO END
00143dac: 00000000 nop                   
00143db0: 16820005 bne r20,r2,0x00143dc8 
00143db4: 3402007a ori r2,r0,0x007a       
00143db8: 3c018017 lui r1,0x8017          {4D}
00143dbc: a432d9bc sh r18,-0x2644(r1)     
00143dc0: 080512d0 j 0x00144b40           
00143dc4: 00000000 nop                   
00143dc8: 16820009 bne r20,r2,0x00143df0 
00143dcc: 34020043 ori r2,r0,0x0043       
00143dd0: 0c04ed64 jal 0x0013b590         {7A} DismissUnit ?
00143dd4: 340401fc ori r4,r0,0x01fc       
00143dd8: 14400852 bne r2,r0,0x00145f24   
00143ddc: 00132400 sll r4,r19,0x10       
00143de0: 0c04d02b jal 0x001340ac         
00143de4: 00042403 sra r4,r4,0x10         
00143de8: 080517c9 j 0x00145f24           GOTO END
00143dec: 00000000 nop                   
00143df0: 16820127 bne r20,r2,0x00144290 
00143df4: 34020099 ori r2,r0,0x0099       
00143df8: 0c053216 jal 0x0014c858         {43}
00143dfc: 34040004 ori r4,r0,0x0004       
00143e00: 0c04ed64 jal 0x0013b590         
00143e04: 340401fc ori r4,r0,0x01fc       
00143e08: 1440004a bne r2,r0,0x00143f34   
00143e0c: 34080001 ori r8,r0,0x0001       
00143e10: 1648000b bne r18,r8,0x00143e40 
00143e14: 34020006 ori r2,r0,0x0006       
00143e18: 0c04ed64 jal 0x0013b590         
00143e1c: 34040027 ori r4,r0,0x0027       
00143e20: 2842004e slti r2,r2,0x004e     
00143e24: 10400003 beq r2,r0,0x00143e34   
00143e28: 00000000 nop                   
00143e2c: 0c010a84 jal 0x00042a10         
00143e30: 00000000 nop                   
00143e34: 0c04d060 jal 0x00134180         
00143e38: 00000000 nop                   
00143e3c: 34020006 ori r2,r0,0x0006       
00143e40: 1642003d bne r18,r2,0x00143f38 
00143e44: 34020002 ori r2,r0,0x0002       
00143e48: 34120002 ori r18,r0,0x0002     
00143e4c: 34110003 ori r17,r0,0x0003     
00143e50: 34100800 ori r16,r0,0x0800     
00143e54: 02402021 addu r4,r18,r0         
00143e58: 00002821 addu r5,r0,r0         
00143e5c: 00003021 addu r6,r0,r0         
00143e60: 0c05328e jal 0x0014ca38         
00143e64: 34070001 ori r7,r0,0x0001       
00143e68: 3c018017 lui r1,0x8017         
00143e6c: 00300821 addu r1,r1,r16         
00143e70: ac3198b8 sw r17,-0x6748(r1)     
00143e74: 0c053274 jal 0x0014c9d0         
00143e78: 02402021 addu r4,r18,r0         
00143e7c: 26520001 addiu r18,r18,0x0001   
00143e80: 2a42000f slti r2,r18,0x000f     
00143e84: 1440fff3 bne r2,r0,0x00143e54   
00143e88: 26100400 addiu r16,r16,0x0400   
00143e8c: 0c04ed64 jal 0x0013b590         
00143e90: 34040027 ori r4,r0,0x0027       
00143e94: 3403012c ori r3,r0,0x012c       
00143e98: 10430004 beq r2,r3,0x00143eac   
00143e9c: 00000000 nop                   
00143ea0: 34040064 ori r4,r0,0x0064       
00143ea4: 0c04ed91 jal 0x0013b644         
00143ea8: 34050001 ori r5,r0,0x0001       
00143eac: 34040051 ori r4,r0,0x0051       
00143eb0: 0c04ed91 jal 0x0013b644         
00143eb4: 34050001 ori r5,r0,0x0001       
00143eb8: 0c04ef05 jal 0x0013bc14         
00143ebc: 3404000e ori r4,r0,0x000e       
00143ec0: 34020005 ori r2,r0,0x0005       
00143ec4: 3c018016 lui r1,0x8016         
00143ec8: ac22600c sw r2,0x600c(r1)       
00143ecc: 0c0532a0 jal 0x0014ca80         
00143ed0: 00000000 nop                   
00143ed4: 3c028016 lui r2,0x8016         
00143ed8: 8c42600c lw r2,0x600c(r2)       
00143edc: 00000000 nop                   
00143ee0: 1440fffa bne r2,r0,0x00143ecc   
00143ee4: 34040064 ori r4,r0,0x0064       
00143ee8: 0c04ed91 jal 0x0013b644         
00143eec: 00002821 addu r5,r0,r0         
00143ef0: 34120002 ori r18,r0,0x0002     
00143ef4: 34110003 ori r17,r0,0x0003     
00143ef8: 34100800 ori r16,r0,0x0800     
00143efc: 02402021 addu r4,r18,r0         
00143f00: 00002821 addu r5,r0,r0         
00143f04: 00003021 addu r6,r0,r0         
00143f08: 0c05328e jal 0x0014ca38         
00143f0c: 34070001 ori r7,r0,0x0001       
00143f10: 3c018017 lui r1,0x8017         
00143f14: 00300821 addu r1,r1,r16         
00143f18: ac3198b8 sw r17,-0x6748(r1)     
00143f1c: 0c053274 jal 0x0014c9d0         
00143f20: 02402021 addu r4,r18,r0         
00143f24: 26520001 addiu r18,r18,0x0001   
00143f28: 2a42000f slti r2,r18,0x000f     
00143f2c: 1440fff3 bne r2,r0,0x00143efc   
00143f30: 26100400 addiu r16,r16,0x0400   
00143f34: 34020002 ori r2,r0,0x0002       
00143f38: 12420003 beq r18,r2,0x00143f48 
00143f3c: 34020007 ori r2,r0,0x0007       
00143f40: 16420004 bne r18,r2,0x00143f54 
00143f44: 34020003 ori r2,r0,0x0003       
00143f48: 0c04d089 jal 0x00134224         
00143f4c: 00000000 nop                   
00143f50: 34020003 ori r2,r0,0x0003       
00143f54: 16420004 bne r18,r2,0x00143f68 
00143f58: 34020004 ori r2,r0,0x0004       
00143f5c: 0c04d092 jal 0x00134248         
00143f60: 00000000 nop                   
00143f64: 34020004 ori r2,r0,0x0004       
00143f68: 16420006 bne r18,r2,0x00143f84 
00143f6c: 34020005 ori r2,r0,0x0005       
00143f70: 0c051f3c jal 0x00147cf0         
00143f74: 00000000 nop                   
00143f78: 0c053216 jal 0x0014c858         
00143f7c: 34040078 ori r4,r0,0x0078       
00143f80: 34020005 ori r2,r0,0x0005       
00143f84: 16420004 bne r18,r2,0x00143f98 
00143f88: 34020008 ori r2,r0,0x0008       
00143f8c: 34080001 ori r8,r0,0x0001       
00143f90: 3c018017 lui r1,0x8017         
00143f94: ac2896f8 sw r8,-0x6908(r1)     
00143f98: 16420005 bne r18,r2,0x00143fb0 
00143f9c: 34020009 ori r2,r0,0x0009       
00143fa0: 3c018004 lui r1,0x8004         
00143fa4: ac2059cc sw r0,0x59cc(r1)       
00143fa8: 3c018004 lui r1,0x8004         
00143fac: ac2059d8 sw r0,0x59d8(r1)       
00143fb0: 16420005 bne r18,r2,0x00143fc8 
00143fb4: 3402000a ori r2,r0,0x000a       
00143fb8: 34040053 ori r4,r0,0x0053       
00143fbc: 0c04ed91 jal 0x0013b644         
00143fc0: 34050001 ori r5,r0,0x0001       
00143fc4: 3402000a ori r2,r0,0x000a       
00143fc8: 16420005 bne r18,r2,0x00143fe0 
00143fcc: 3402000b ori r2,r0,0x000b       
00143fd0: 34040053 ori r4,r0,0x0053       
00143fd4: 0c04ed91 jal 0x0013b644         
00143fd8: 00002821 addu r5,r0,r0         
00143fdc: 3402000b ori r2,r0,0x000b       
00143fe0: 1642000f bne r18,r2,0x00144020 
00143fe4: 3402000c ori r2,r0,0x000c       
00143fe8: 0c050cfa jal 0x001433e8         
00143fec: 00000000 nop                   
00143ff0: 3c028016 lui r2,0x8016         
00143ff4: 8442605c lh r2,0x605c(r2)       
00143ff8: 00000000 nop                   
00143ffc: 10400008 beq r2,r0,0x00144020   
00144000: 3402000c ori r2,r0,0x000c       
00144004: 0c0532a0 jal 0x0014ca80         
00144008: 00000000 nop                   
0014400c: 3c028016 lui r2,0x8016         
00144010: 8442605c lh r2,0x605c(r2)       
00144014: 00000000 nop                   
00144018: 1440fffa bne r2,r0,0x00144004   
0014401c: 3402000c ori r2,r0,0x000c       
00144020: 1642000c bne r18,r2,0x00144054 
00144024: 3402000d ori r2,r0,0x000d       
00144028: 34040013 ori r4,r0,0x0013       
0014402c: 34020013 ori r2,r0,0x0013       
00144030: 3c018016 lui r1,0x8016         
00144034: a4205fd8 sh r0,0x5fd8(r1)       
00144038: 3c018016 lui r1,0x8016         
0014403c: a4225fd4 sh r2,0x5fd4(r1)       
00144040: 3c018016 lui r1,0x8016         
00144044: a4205fd6 sh r0,0x5fd6(r1)       
00144048: 0c04f49e jal 0x0013d278         
0014404c: 00002821 addu r5,r0,r0         
00144050: 3402000d ori r2,r0,0x000d       
00144054: 16420023 bne r18,r2,0x001440e4 
00144058: 3402000e ori r2,r0,0x000e       
0014405c: 0c0602bf jal 0x00180afc         
00144060: 34040007 ori r4,r0,0x0007       
00144064: 00408821 addu r17,r2,r0         
00144068: 0c0602bf jal 0x00180afc         
0014406c: 34040008 ori r4,r0,0x0008       
00144070: 00403021 addu r6,r2,r0         
00144074: 92220047 lbu r2,0x0047(r17)     
00144078: 34040008 ori r4,r0,0x0008       
0014407c: a0c20047 sb r2,0x0047(r6)       
00144080: 92220048 lbu r2,0x0048(r17)     
00144084: 34050001 ori r5,r0,0x0001       
00144088: a0c20048 sb r2,0x0048(r6)       
0014408c: 96230048 lhu r3,0x0048(r17)     
00144090: 94c20048 lhu r2,0x0048(r6)     
00144094: 30638000 andi r3,r3,0x8000     
00144098: 30427fff andi r2,r2,0x7fff     
0014409c: 00431025 or r2,r2,r3           
001440a0: 0c023417 jal 0x0008d05c         
001440a4: a4c20048 sh r2,0x0048(r6)       
001440a8: 34080001 ori r8,r0,0x0001       
001440ac: 3c018016 lui r1,0x8016         
001440b0: a428604e sh r8,0x604e(r1)       
001440b4: 0c0532a0 jal 0x0014ca80         
001440b8: 00000000 nop                   
001440bc: 3c028016 lui r2,0x8016         
001440c0: 9442604e lhu r2,0x604e(r2)     
001440c4: 00000000 nop                   
001440c8: 1440fffa bne r2,r0,0x001440b4   
001440cc: 00000000 nop                   
001440d0: 0c0532a0 jal 0x0014ca80         
001440d4: 00000000 nop                   
001440d8: 0c0532a0 jal 0x0014ca80         
001440dc: 00000000 nop                   
001440e0: 3402000e ori r2,r0,0x000e       
001440e4: 1642002d bne r18,r2,0x0014419c 
001440e8: 34020011 ori r2,r0,0x0011       
001440ec: 00008021 addu r16,r0,r0         
001440f0: 0c0232ed jal 0x0008cbb4         
001440f4: 02002021 addu r4,r16,r0         
001440f8: 10400024 beq r2,r0,0x0014418c   
001440fc: 00000000 nop                   
00144100: 0c023374 jal 0x0008cdd0         
00144104: 02002021 addu r4,r16,r0         
00144108: 00409021 addu r18,r2,r0         
0014410c: 2402ffff addiu r2,r0,0xffff     
00144110: 1242001e beq r18,r2,0x0014418c 
00144114: 00000000 nop                   
00144118: 0c0602bf jal 0x00180afc         
0014411c: 02402021 addu r4,r18,r0         
00144120: 00408821 addu r17,r2,r0         
00144124: 92220047 lbu r2,0x0047(r17)     
00144128: 00000000 nop                   
0014412c: 2c420004 sltiu r2,r2,0x0004     
00144130: 10400008 beq r2,r0,0x00144154   
00144134: 00000000 nop                   
00144138: 92220048 lbu r2,0x0048(r17)     
0014413c: 00000000 nop                   
00144140: 2c42000b sltiu r2,r2,0x000b     
00144144: 10400003 beq r2,r0,0x00144154   
00144148: 00000000 nop                   
0014414c: 0c023463 jal 0x0008d18c         
00144150: 02002021 addu r4,r16,r0         
00144154: 92220047 lbu r2,0x0047(r17)     
00144158: 00000000 nop                   
0014415c: 2442fffc addiu r2,r2,0xfffc     
00144160: 2c420003 sltiu r2,r2,0x0003     
00144164: 10400009 beq r2,r0,0x0014418c   
00144168: 00000000 nop                   
0014416c: 92220048 lbu r2,0x0048(r17)     
00144170: 00000000 nop                   
00144174: 2442fffe addiu r2,r2,0xfffe     
00144178: 2c420006 sltiu r2,r2,0x0006     
0014417c: 10400003 beq r2,r0,0x0014418c   
00144180: 00000000 nop                   
00144184: 0c023463 jal 0x0008d18c         
00144188: 02002021 addu r4,r16,r0         
0014418c: 26100001 addiu r16,r16,0x0001   
00144190: 2a020015 slti r2,r16,0x0015     
00144194: 1440ffd6 bne r2,r0,0x001440f0   
00144198: 34020011 ori r2,r0,0x0011       
0014419c: 16420028 bne r18,r2,0x00144240 
001441a0: 2642fff1 addiu r2,r18,0xfff1   
001441a4: 0c0602bf jal 0x00180afc         
001441a8: 34040001 ori r4,r0,0x0001       
001441ac: 00408821 addu r17,r2,r0         
001441b0: 0c0602bf jal 0x00180afc         
001441b4: 34040007 ori r4,r0,0x0007       
001441b8: 00403021 addu r6,r2,r0         
001441bc: 92230047 lbu r3,0x0047(r17)     
001441c0: 34040007 ori r4,r0,0x0007       
001441c4: a0c30047 sb r3,0x0047(r6)       
001441c8: 92220048 lbu r2,0x0048(r17)     
001441cc: 34050001 ori r5,r0,0x0001       
001441d0: a0c20048 sb r2,0x0048(r6)       
001441d4: 96230048 lhu r3,0x0048(r17)     
001441d8: 94c20048 lhu r2,0x0048(r6)     
001441dc: 30638000 andi r3,r3,0x8000     
001441e0: 30427fff andi r2,r2,0x7fff     
001441e4: 00431025 or r2,r2,r3           
001441e8: a4c20048 sh r2,0x0048(r6)       
001441ec: 96230048 lhu r3,0x0048(r17)     
001441f0: 3042f0ff andi r2,r2,0xf0ff     
001441f4: 30630f00 andi r3,r3,0x0f00     
001441f8: 00431025 or r2,r2,r3           
001441fc: 0c023417 jal 0x0008d05c         
00144200: a4c20048 sh r2,0x0048(r6)       
00144204: 34080001 ori r8,r0,0x0001       
00144208: 3c018016 lui r1,0x8016         
0014420c: a428604e sh r8,0x604e(r1)       
00144210: 0c0532a0 jal 0x0014ca80         
00144214: 00000000 nop                   
00144218: 3c028016 lui r2,0x8016         
0014421c: 9442604e lhu r2,0x604e(r2)     
00144220: 00000000 nop                   
00144224: 1440fffa bne r2,r0,0x00144210   
00144228: 00000000 nop                   
0014422c: 0c0532a0 jal 0x0014ca80         
00144230: 00000000 nop                   
00144234: 0c0532a0 jal 0x0014ca80         
00144238: 00000000 nop                   
0014423c: 2642fff1 addiu r2,r18,0xfff1   
00144240: 2c420002 sltiu r2,r2,0x0002     
00144244: 10400004 beq r2,r0,0x00144258   
00144248: 34020012 ori r2,r0,0x0012       
0014424c: 0c04d0b3 jal 0x001342cc         
00144250: 02402021 addu r4,r18,r0         
00144254: 34020012 ori r2,r0,0x0012       
00144258: 16420732 bne r18,r2,0x00145f24 
0014425c: 00000000 nop                   
00144260: 0c04cc56 jal 0x00133158         
00144264: 3404003e ori r4,r0,0x003e       
00144268: 00021400 sll r2,r2,0x10         
0014426c: 00028403 sra r16,r2,0x10       
00144270: 340807d0 ori r8,r0,0x07d0       
00144274: 1208072b beq r16,r8,0x00145f24 
00144278: 00000000 nop                   
0014427c: 0c023374 jal 0x0008cdd0         
00144280: 02002021 addu r4,r16,r0         
00144284: 00402021 addu r4,r2,r0         
00144288: 08051589 j 0x00145624           
0014428c: 00002821 addu r5,r0,r0         
00144290: 16820006 bne r20,r2,0x001442ac 
00144294: 340200db ori r2,r0,0x00db       
00144298: 00132400 sll r4,r19,0x10        {99}
0014429c: 0c051f66 jal 0x00147d98         
001442a0: 00042403 sra r4,r4,0x10         
001442a4: 080517c9 j 0x00145f24           GOTO END
001442a8: 00000000 nop                   
001442ac: 12820003 beq r20,r2,0x001442bc  {DB} EventEnd
001442b0: 340200e3 ori r2,r0,0x00e3       
001442b4: 16820077 bne r20,r2,0x00144494 
001442b8: 340200da ori r2,r0,0x00da       
001442bc: 0c051829 jal 0x001460a4         {E3}
001442c0: 00000000 nop                   
001442c4: 0c0532a0 jal 0x0014ca80         
001442c8: 00000000 nop                   
001442cc: 0c05272f jal 0x00149cbc         
001442d0: 34040008 ori r4,r0,0x0008       
001442d4: 1440fffb bne r2,r0,0x001442c4   
001442d8: 00000000 nop                   
001442dc: 0c0532a0 jal 0x0014ca80         
001442e0: 00000000 nop                   
001442e4: 0c0111b2 jal 0x000446c8         
001442e8: 00000000 nop                   
001442ec: 1440fffb bne r2,r0,0x001442dc   
001442f0: 00000000 nop                   
001442f4: 0c0532a0 jal 0x0014ca80         
001442f8: 00000000 nop                   
001442fc: 0c04b721 jal 0x0012dc84         
00144300: 00000000 nop                   
00144304: 1040000c beq r2,r0,0x00144338   
00144308: 00000000 nop                   
0014430c: 0c04b70c jal 0x0012dc30         
00144310: 00000000 nop                   
00144314: 340401fc ori r4,r0,0x01fc       
00144318: 3c028017 lui r2,0x8017         
0014431c: 8c42d99c lw r2,-0x2664(r2)     
00144320: 3c018004 lui r1,0x8004         
00144324: ac2273ac sw r2,0x73ac(r1)       
00144328: 0c04ed91 jal 0x0013b644         
0014432c: 00002821 addu r5,r0,r0         
00144330: 0c0230e8 jal 0x0008c3a0         
00144334: 34040020 ori r4,r0,0x0020       
00144338: 3c028016 lui r2,0x8016         
0014433c: 94425ff6 lhu r2,0x5ff6(r2)     
00144340: 00000000 nop                   
00144344: 14400008 bne r2,r0,0x00144368   
00144348: 00000000 nop                   
0014434c: 34100002 ori r16,r0,0x0002     
00144350: 0c053274 jal 0x0014c9d0         
00144354: 02002021 addu r4,r16,r0         
00144358: 26100001 addiu r16,r16,0x0001   
0014435c: 2a02000e slti r2,r16,0x000e     
00144360: 1440fffb bne r2,r0,0x00144350   
00144364: 00000000 nop                   
00144368: 0c04ed64 jal 0x0013b590         
0014436c: 34040027 ori r4,r0,0x0027       
00144370: 00409021 addu r18,r2,r0         
00144374: 340201ad ori r2,r0,0x01ad       
00144378: 12420006 beq r18,r2,0x00144394 
0014437c: 00000000 nop                   
00144380: 340201d1 ori r2,r0,0x01d1       
00144384: 12420004 beq r18,r2,0x00144398 
00144388: 340401fd ori r4,r0,0x01fd       
0014438c: 0c023654 jal 0x0008d950         
00144390: 00000000 nop                   
00144394: 340401fd ori r4,r0,0x01fd       
00144398: 0c04ed91 jal 0x0013b644         
0014439c: 00002821 addu r5,r0,r0         
001443a0: 00121040 sll r2,r18,0x01       
001443a4: 3c018005 lui r1,0x8005         
001443a8: 00220821 addu r1,r1,r2         
001443ac: 9422e5d0 lhu r2,-0x1a30(r1)     
001443b0: 3c038016 lui r3,0x8016         
001443b4: 94635ff6 lhu r3,0x5ff6(r3)     
001443b8: 3042f300 andi r2,r2,0xf300     
001443bc: 14600010 bne r3,r0,0x00144400   
001443c0: 00021203 sra r2,r2,0x08         
001443c4: 1440000e bne r2,r0,0x00144400   
001443c8: 2642fe70 addiu r2,r18,0xfe70   
001443cc: 2c42001a sltiu r2,r2,0x001a     
001443d0: 1440000b bne r2,r0,0x00144400   
001443d4: 00000000 nop                   
001443d8: 12400009 beq r18,r0,0x00144400 
001443dc: 340200ff ori r2,r0,0x00ff       
001443e0: 3c018015 lui r1,0x8015         
001443e4: ac22d304 sw r2,-0x2cfc(r1)     
001443e8: 0c05096c jal 0x001425b0         
001443ec: 00000000 nop                   
001443f0: 0c0517de jal 0x00145f78         
001443f4: 00000000 nop                   
001443f8: 1440fe38 bne r2,r0,0x00143cdc   
001443fc: 00000000 nop                   
00144400: 0c023079 jal 0x0008c1e4         
00144404: 00008021 addu r16,r0,r0         
00144408: 00002021 addu r4,r0,r0         
0014440c: 0c052336 jal 0x00148cd8         
00144410: 34050001 ori r5,r0,0x0001       
00144414: 0c0232ed jal 0x0008cbb4         
00144418: 02002021 addu r4,r16,r0         
0014441c: 10400011 beq r2,r0,0x00144464   
00144420: 00000000 nop                   
00144424: 0c023374 jal 0x0008cdd0         
00144428: 02002021 addu r4,r16,r0         
0014442c: 00409021 addu r18,r2,r0         
00144430: 0640000c bltz r18,0x00144464   
00144434: 00000000 nop                   
00144438: 0c0602bf jal 0x00180afc         
0014443c: 02402021 addu r4,r18,r0         
00144440: 00408821 addu r17,r2,r0         
00144444: 0c022fc7 jal 0x0008bf1c         
00144448: 02002021 addu r4,r16,r0         
0014444c: 3042000f andi r2,r2,0x000f     
00144450: 96230048 lhu r3,0x0048(r17)     
00144454: 00021200 sll r2,r2,0x08         
00144458: 3063f0ff andi r3,r3,0xf0ff     
0014445c: 00621825 or r3,r3,r2           
00144460: a6230048 sh r3,0x0048(r17)     
00144464: 26100001 addiu r16,r16,0x0001   
00144468: 2a020015 slti r2,r16,0x0015     
0014446c: 1440ffe9 bne r2,r0,0x00144414   
00144470: 00000000 nop                   
00144474: 0c04b771 jal 0x0012ddc4         
00144478: 00000000 nop                   
0014447c: 0c04b77a jal 0x0012dde8         
00144480: 00000000 nop                   
00144484: 0c053256 jal 0x0014c958         
00144488: 00000000 nop                   
0014448c: 080517c9 j 0x00145f24           GOTO END
00144490: 00000000 nop                   
00144494: 128206a3 beq r20,r2,0x00145f24  {DA} GOTO END
00144498: 340200d0 ori r2,r0,0x00d0       
0014449c: 1682000b bne r20,r2,0x001444cc 
001444a0: 340200d1 ori r2,r0,0x00d1       
001444a4: 3c028016 lui r2,0x8016          {D0} (B) Block Start
001444a8: 8c425f9c lw r2,0x5f9c(r2)       
001444ac: 00000000 nop                   
001444b0: 8c420000 lw r2,0x0000(r2)       
001444b4: 00000000 nop                   
001444b8: 1440069a bne r2,r0,0x00145f24   
001444bc: 27c40002 addiu r4,r30,0x0002   
001444c0: 340500d2 ori r5,r0,0x00d2       Block End = D2
001444c4: 08051141 j 0x00144504           
001444c8: 340600d4 ori r6,r0,0x00d4        
001444cc: 16820004 bne r20,r2,0x001444e0 
001444d0: 340200d2 ori r2,r0,0x00d2       
001444d4: 27c40002 addiu r4,r30,0x0002    {D1}
001444d8: 08051140 j 0x00144500           GOTO (AAA)
001444dc: 340500d2 ori r5,r0,0x00d2       
001444e0: 12820690 beq r20,r2,0x00145f24  {D2} GOTO END
001444e4: 340200d4 ori r2,r0,0x00d4       
001444e8: 12820694 beq r20,r2,0x00145f3c  {D4}
001444ec: 340200d3 ori r2,r0,0x00d3       
001444f0: 16820008 bne r20,r2,0x00144514 
001444f4: 340200d5 ori r2,r0,0x00d5       
001444f8: 03c02021 addu r4,r30,r0         {D3} (C) Block Start
001444fc: 340500d5 ori r5,r0,0x00d5       Block End = D5
00144500: 2406ffff addiu r6,r0,0xffff     (AAA)
00144504: 0c05275b jal 0x00149d6c         
00144508: 02403821 addu r7,r18,r0         
0014450c: 08050f43 j 0x00143d0c           
00144510: 0040f021 addu r30,r2,r0         
00144514: 12820683 beq r20,r2,0x00145f24  {D5} GOTO END
00144518: 340200d8 ori r2,r0,0x00d8       
0014451c: 12820681 beq r20,r2,0x00145f24  {D8} GOTO END
00144520: 340200d9 ori r2,r0,0x00d9       
00144524: 1282067f beq r20,r2,0x00145f24  {D9} GOTO END
00144528: 340200dc ori r2,r0,0x00dc       
0014452c: 16820006 bne r20,r2,0x00144548 
00144530: 34020010 ori r2,r0,0x0010       
00144534: 3402000d ori r2,r0,0x000d       {DC}
00144538: 3c018016 lui r1,0x8016         
0014453c: a4225fb0 sh r2,0x5fb0(r1)       
00144540: 080517c9 j 0x00145f24           GOTO END
00144544: 00000000 nop                   
00144548: 1682004c bne r20,r2,0x0014467c 
0014454c: 34020051 ori r2,r0,0x0051       
00144550: 0c0526fb jal 0x00149bec         {10} DisplayMessage
00144554: 02402021 addu r4,r18,r0         
00144558: 00409021 addu r18,r2,r0         
0014455c: 3c058013 lui r5,0x8013         
00144560: 24a508c0 addiu r5,r5,0x08c0     
00144564: 0c053228 jal 0x0014c8a0         
00144568: 02402021 addu r4,r18,r0         
0014456c: 03c02021 addu r4,r30,r0         
00144570: 02a02821 addu r5,r21,r0         
00144574: 00128280 sll r16,r18,0x0a       
00144578: 3c068017 lui r6,0x8017         
0014457c: 24c698d4 addiu r6,r6,0x98d4     
00144580: 0c04bd38 jal 0x0012f4e0         
00144584: 02063021 addu r6,r16,r6         
00144588: 00171200 sll r2,r23,0x08       
0014458c: 00561021 addu r2,r2,r22         
00144590: 3c048017 lui r4,0x8017         
00144594: 8c843ca4 lw r4,0x3ca4(r4)       
00144598: 2442ffff addiu r2,r2,0xffff     
0014459c: 3c018017 lui r1,0x8017         
001445a0: 00300821 addu r1,r1,r16         
001445a4: ac35986c sw r21,-0x6794(r1)     
001445a8: 3c018017 lui r1,0x8017         
001445ac: 00300821 addu r1,r1,r16         
001445b0: ac229870 sw r2,-0x6790(r1)     
001445b4: 009e2021 addu r4,r4,r30         
001445b8: 90970006 lbu r23,0x0006(r4)     
001445bc: 90960005 lbu r22,0x0005(r4)     
001445c0: 00171200 sll r2,r23,0x08       
001445c4: 00561021 addu r2,r2,r22         
001445c8: 3c018017 lui r1,0x8017         
001445cc: 00300821 addu r1,r1,r16         
001445d0: ac229874 sw r2,-0x678c(r1)     
001445d4: 90820007 lbu r2,0x0007(r4)     
001445d8: 3c018017 lui r1,0x8017         
001445dc: 00300821 addu r1,r1,r16         
001445e0: ac229878 sw r2,-0x6788(r1)     
001445e4: 0c05181e jal 0x00146078         
001445e8: 24840008 addiu r4,r4,0x0008     
001445ec: 00021400 sll r2,r2,0x10         
001445f0: 3c048017 lui r4,0x8017         
001445f4: 8c843ca4 lw r4,0x3ca4(r4)       
001445f8: 00021403 sra r2,r2,0x10         
001445fc: 3c018017 lui r1,0x8017         
00144600: 00300821 addu r1,r1,r16         
00144604: ac2298c4 sw r2,-0x673c(r1)     
00144608: 03c42021 addu r4,r30,r4         
0014460c: 0c05181e jal 0x00146078         
00144610: 2484000a addiu r4,r4,0x000a     
00144614: 00021400 sll r2,r2,0x10         
00144618: 3c048017 lui r4,0x8017         
0014461c: 8c843ca4 lw r4,0x3ca4(r4)       
00144620: 00021403 sra r2,r2,0x10         
00144624: 3c018017 lui r1,0x8017         
00144628: 00300821 addu r1,r1,r16         
0014462c: ac2298c8 sw r2,-0x6738(r1)     
00144630: 03c42021 addu r4,r30,r4         
00144634: 0c05181e jal 0x00146078         
00144638: 2484000c addiu r4,r4,0x000c     
0014463c: 00021400 sll r2,r2,0x10         
00144640: 3c038017 lui r3,0x8017         
00144644: 8c633ca4 lw r3,0x3ca4(r3)       
00144648: 00021403 sra r2,r2,0x10         
0014464c: 3c018017 lui r1,0x8017         
00144650: 00300821 addu r1,r1,r16         
00144654: ac2298cc sw r2,-0x6734(r1)     
00144658: 007e1821 addu r3,r3,r30         
0014465c: 9062000e lbu r2,0x000e(r3)     
00144660: 3c018017 lui r1,0x8017         
00144664: 00300821 addu r1,r1,r16         
00144668: ac2298d0 sw r2,-0x6730(r1)     
0014466c: 0c0532a0 jal 0x0014ca80         
00144670: 00000000 nop                   
00144674: 080517c9 j 0x00145f24           GOTO END
00144678: 00000000 nop                   
0014467c: 1682003c bne r20,r2,0x00144770 
00144680: 34020050 ori r2,r0,0x0050       
00144684: 00008021 addu r16,r0,r0         {51} ChangeDialog
00144688: 00008821 addu r17,r0,r0         
0014468c: 3c018017 lui r1,0x8017         
00144690: 00310821 addu r1,r1,r17         
00144694: 8c22e450 lw r2,-0x1bb0(r1)     
00144698: 3c018017 lui r1,0x8017         
0014469c: 00310821 addu r1,r1,r17         
001446a0: 8c35e440 lw r21,-0x1bc0(r1)     
001446a4: 1452002c bne r2,r18,0x00144758 
001446a8: 00000000 nop                   
001446ac: 0c053325 jal 0x0014cc94         
001446b0: 02a02021 addu r4,r21,r0         
001446b4: 34080001 ori r8,r0,0x0001       
001446b8: 14480027 bne r2,r8,0x00144758   
001446bc: 00159a80 sll r19,r21,0x0a       
001446c0: 3c018017 lui r1,0x8017         
001446c4: 00330821 addu r1,r1,r19         
001446c8: 8c2398b8 lw r3,-0x6748(r1)     
001446cc: 34020033 ori r2,r0,0x0033       
001446d0: 14620021 bne r3,r2,0x00144758   
001446d4: 00000000 nop                   
001446d8: 3c048017 lui r4,0x8017         
001446dc: 8c843ca4 lw r4,0x3ca4(r4)       
001446e0: 00000000 nop                   
001446e4: 03c42021 addu r4,r30,r4         
001446e8: 0c05181e jal 0x00146078         
001446ec: 24840002 addiu r4,r4,0x0002     
001446f0: 00021400 sll r2,r2,0x10         
001446f4: 00029403 sra r18,r2,0x10       
001446f8: 3243ffff andi r3,r18,0xffff     
001446fc: 3402ffff ori r2,r0,0xffff       
00144700: 10620002 beq r3,r2,0x0014470c   
00144704: 00000000 nop                   
00144708: 2652ffff addiu r18,r18,0xffff   
0014470c: 3c048017 lui r4,0x8017         
00144710: 8c843ca4 lw r4,0x3ca4(r4)       
00144714: 3c018017 lui r1,0x8017         
00144718: 00330821 addu r1,r1,r19         
0014471c: ac329870 sw r18,-0x6790(r1)     
00144720: 03c42021 addu r4,r30,r4         
00144724: 0c05181e jal 0x00146078         
00144728: 24840004 addiu r4,r4,0x0004     
0014472c: 00021400 sll r2,r2,0x10         
00144730: 00021403 sra r2,r2,0x10         
00144734: 34080001 ori r8,r0,0x0001       
00144738: 3c018017 lui r1,0x8017         
0014473c: 00330821 addu r1,r1,r19         
00144740: ac229878 sw r2,-0x6788(r1)     
00144744: 3c018017 lui r1,0x8017         
00144748: 00330821 addu r1,r1,r19         
0014474c: ac2898b8 sw r8,-0x6748(r1)     
00144750: 080517c9 j 0x00145f24           GOTO END
00144754: 00000000 nop                   
00144758: 26100002 addiu r16,r16,0x0002   
0014475c: 2a020006 slti r2,r16,0x0006     
00144760: 1440ffca bne r2,r0,0x0014468c   
00144764: 26310230 addiu r17,r17,0x0230   
00144768: 080517c9 j 0x00145f24           GOTO END
0014476c: 00000000 nop                   
00144770: 16820005 bne r20,r2,0x00144788 
00144774: 34020054 ori r2,r0,0x0054       
00144778: 0c04f22a jal 0x0013c8a8         {50} PortraitCol
0014477c: 02402021 addu r4,r18,r0         
00144780: 080517c9 j 0x00145f24           GOTO END
00144784: 00000000 nop                   
00144788: 1682000c bne r20,r2,0x001447bc 
0014478c: 34020056 ori r2,r0,0x0056       
00144790: 34080001 ori r8,r0,0x0001       {54}
00144794: 3c018016 lui r1,0x8016         
00144798: a4285fe2 sh r8,0x5fe2(r1)       
0014479c: 3c018017 lui r1,0x8017         
001447a0: a4323c94 sh r18,0x3c94(r1)     
001447a4: 3c018017 lui r1,0x8017         
001447a8: a4353c96 sh r21,0x3c96(r1)     
001447ac: 0c0532a0 jal 0x0014ca80         
001447b0: 00000000 nop                   
001447b4: 080517c9 j 0x00145f24           GOTO END
001447b8: 00000000 nop                   
001447bc: 1682000d bne r20,r2,0x001447f4 
001447c0: 34020055 ori r2,r0,0x0055       
001447c4: 34080001 ori r8,r0,0x0001       {56}
001447c8: 3c018016 lui r1,0x8016         
001447cc: a428606e sh r8,0x606e(r1)       
001447d0: 0c0532a0 jal 0x0014ca80         
001447d4: 00000000 nop                   
001447d8: 3c028016 lui r2,0x8016         
001447dc: 9442606e lhu r2,0x606e(r2)     
001447e0: 00000000 nop                   
001447e4: 104005cf beq r2,r0,0x00145f24   
001447e8: 00000000 nop                   
001447ec: 080511f4 j 0x001447d0           
001447f0: 00000000 nop                   
001447f4: 1682000c bne r20,r2,0x00144828 
001447f8: 34020057 ori r2,r0,0x0057       
001447fc: 34080001 ori r8,r0,0x0001       {55} UseFieldObject
00144800: 3c018016 lui r1,0x8016         
00144804: a4285fe4 sh r8,0x5fe4(r1)       
00144808: 3c018017 lui r1,0x8017         
0014480c: a4324058 sh r18,0x4058(r1)     
00144810: 3c018017 lui r1,0x8017         
00144814: a435405a sh r21,0x405a(r1)     
00144818: 0c0532a0 jal 0x0014ca80         
0014481c: 00000000 nop                   
00144820: 080517c9 j 0x00145f24           GOTO END
00144824: 00000000 nop                   
00144828: 1682000d bne r20,r2,0x00144860 
0014482c: 34020068 ori r2,r0,0x0068       
00144830: 34080001 ori r8,r0,0x0001       {57} WaitFieldObject ?
00144834: 3c018016 lui r1,0x8016         
00144838: a4286070 sh r8,0x6070(r1)       
0014483c: 0c0532a0 jal 0x0014ca80         
00144840: 00000000 nop                   
00144844: 3c028016 lui r2,0x8016         
00144848: 94426070 lhu r2,0x6070(r2)     
0014484c: 00000000 nop                   
00144850: 104005b4 beq r2,r0,0x00145f24   
00144854: 00000000 nop                   
00144858: 0805120f j 0x0014483c           
0014485c: 00000000 nop                   
00144860: 16820005 bne r20,r2,0x00144878 
00144864: 34020097 ori r2,r0,0x0097       
00144868: 0c04f997 jal 0x0013e65c         {68}
0014486c: 02202021 addu r4,r17,r0         
00144870: 080517c9 j 0x00145f24           GOTO END
00144874: 00000000 nop                   
00144878: 16820005 bne r20,r2,0x00144890 
0014487c: 34020071 ori r2,r0,0x0071       
00144880: 0c04f9b1 jal 0x0013e6c4         {97} ResetUnitColor
00144884: 02202021 addu r4,r17,r0         
00144888: 080517c9 j 0x00145f24           GOTO END
0014488c: 00000000 nop                   
00144890: 1682000c bne r20,r2,0x001448c4 
00144894: 34020011 ori r2,r0,0x0011       
00144898: 00132400 sll r4,r19,0x10        {71}
0014489c: 0c04cc56 jal 0x00133158         
001448a0: 00042403 sra r4,r4,0x10         
001448a4: 00409021 addu r18,r2,r0         
001448a8: 340807d0 ori r8,r0,0x07d0       
001448ac: 1248059d beq r18,r8,0x00145f24 
001448b0: 00000000 nop                   
001448b4: 0c01e9ee jal 0x0007a7b8         
001448b8: 02402021 addu r4,r18,r0         
001448bc: 080517c9 j 0x00145f24           GOTO END
001448c0: 00000000 nop                   
001448c4: 16820005 bne r20,r2,0x001448dc 
001448c8: 34020080 ori r2,r0,0x0080       
001448cc: 0c0524e6 jal 0x00149398         {11} UnitAnim
001448d0: 02202021 addu r4,r17,r0         
001448d4: 080517c9 j 0x00145f24           GOTO END
001448d8: 00000000 nop                   
001448dc: 16820005 bne r20,r2,0x001448f4 
001448e0: 34020081 ori r2,r0,0x0081       
001448e4: 0c052524 jal 0x00149490         {80} March
001448e8: 02202021 addu r4,r17,r0         
001448ec: 080517c9 j 0x00145f24           GOTO END
001448f0: 00000000 nop                   
001448f4: 16820005 bne r20,r2,0x0014490c 
001448f8: 34020012 ori r2,r0,0x0012       
001448fc: 0c05254b jal 0x0014952c         {81}
00144900: 02202021 addu r4,r17,r0         
00144904: 080517c9 j 0x00145f24           GOTO END
00144908: 00000000 nop                   
0014490c: 1682000c bne r20,r2,0x00144940 
00144910: 34020013 ori r2,r0,0x0013       
00144914: 00132400 sll r4,r19,0x10        {12}
00144918: 0c04cc56 jal 0x00133158         
0014491c: 00042403 sra r4,r4,0x10         
00144920: 00409021 addu r18,r2,r0         
00144924: 340807d0 ori r8,r0,0x07d0       
00144928: 1248057e beq r18,r8,0x00145f24 
0014492c: 00000000 nop                   
00144930: 0c052936 jal 0x0014a4d8         
00144934: 02402021 addu r4,r18,r0         
00144938: 080517c9 j 0x00145f24           GOTO END
0014493c: 00000000 nop                   
00144940: 16820005 bne r20,r2,0x00144958 
00144944: 3402004c ori r2,r0,0x004c       
00144948: 3c018017 lui r1,0x8017          {13} ChangeMap
0014494c: a4334054 sh r19,0x4054(r1)     
00144950: 0805125a j 0x00144968           
00144954: 00000000 nop                   
00144958: 16820009 bne r20,r2,0x00144980 
0014495c: 3402004f ori r2,r0,0x004f       
00144960: 3c018017 lui r1,0x8017          {4C}
00144964: a433405c sh r19,0x405c(r1)     
00144968: 0c053216 jal 0x0014c858         
0014496c: 34040002 ori r4,r0,0x0002       
00144970: 0c04fc30 jal 0x0013f0c0         
00144974: 00000000 nop                   
00144978: 080517c9 j 0x00145f24           GOTO END
0014497c: 00000000 nop                   
00144980: 16820005 bne r20,r2,0x00144998 
00144984: 3402003c ori r2,r0,0x003c       
00144988: 3c018017 lui r1,0x8017          {4F}
0014498c: a4323f64 sh r18,0x3f64(r1)     
00144990: 0805126a j 0x001449a8           
00144994: 00000000 nop                   
00144998: 16820009 bne r20,r2,0x001449c0 
0014499c: 34020027 ori r2,r0,0x0027       
001449a0: 3c018017 lui r1,0x8017          {3C} Weather
001449a4: a4333f68 sh r19,0x3f68(r1)     
001449a8: 0c053216 jal 0x0014c858         
001449ac: 34040002 ori r4,r0,0x0002       
001449b0: 0c051829 jal 0x001460a4         
001449b4: 00000000 nop                   
001449b8: 080517c9 j 0x00145f24           GOTO END
001449bc: 00000000 nop                   
001449c0: 1682000d bne r20,r2,0x001449f8 
001449c4: 34020096 ori r2,r0,0x0096       
001449c8: 34080001 ori r8,r0,0x0001       {27}
001449cc: 3c018016 lui r1,0x8016         
001449d0: a4285fde sh r8,0x5fde(r1)       
001449d4: 0c0532a0 jal 0x0014ca80         
001449d8: 00000000 nop                   
001449dc: 3c028016 lui r2,0x8016         
001449e0: 94425fde lhu r2,0x5fde(r2)     
001449e4: 00000000 nop                   
001449e8: 1040054e beq r2,r0,0x00145f24   
001449ec: 00000000 nop                   
001449f0: 08051275 j 0x001449d4           
001449f4: 00000000 nop                   
001449f8: 1682000d bne r20,r2,0x00144a30 
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Xifanie on November 29, 2011, 02:29:40 am
001449fc: 34020016 ori r2,r0,0x0016   
00144a00: 34080001 ori r8,r0,0x0001       {96}
00144a04: 3c018016 lui r1,0x8016         
00144a08: a4285fe0 sh r8,0x5fe0(r1)       
00144a0c: 0c0532a0 jal 0x0014ca80         
00144a10: 00000000 nop                   
00144a14: 3c028016 lui r2,0x8016         
00144a18: 94425fe0 lhu r2,0x5fe0(r2)     
00144a1c: 00000000 nop                   
00144a20: 10400540 beq r2,r0,0x00145f24   
00144a24: 00000000 nop                   
00144a28: 08051283 j 0x00144a0c           
00144a2c: 00000000 nop                   
00144a30: 16820005 bne r20,r2,0x00144a48 
00144a34: 34020026 ori r2,r0,0x0026       
00144a38: 0c04cbe7 jal 0x00132f9c         {16} Pause
00144a3c: 00000000 nop                   
00144a40: 080517c9 j 0x00145f24           GOTO END
00144a44: 00000000 nop                   
00144a48: 1682001a bne r20,r2,0x00144ab4 
00144a4c: 34020037 ori r2,r0,0x0037       
00144a50: 34100001 ori r16,r0,0x0001      {26}
00144a54: 34050002 ori r5,r0,0x0002       
00144a58: 00131400 sll r2,r19,0x10       
00144a5c: 00022403 sra r4,r2,0x10         
00144a60: 3c038017 lui r3,0x8017         
00144a64: 24639c6c addiu r3,r3,0x9c6c     
00144a68: 8c620048 lw r2,0x0048(r3)       
00144a6c: 00000000 nop                   
00144a70: 1040000b beq r2,r0,0x00144aa0   
00144a74: 26100001 addiu r16,r16,0x0001   
00144a78: 8c62004c lw r2,0x004c(r3)       
00144a7c: 00000000 nop                   
00144a80: 14450008 bne r2,r5,0x00144aa4   
00144a84: 2a020010 slti r2,r16,0x0010     
00144a88: 8c620004 lw r2,0x0004(r3)       
00144a8c: 00000000 nop                   
00144a90: 14440004 bne r2,r4,0x00144aa4   
00144a94: 2a020010 slti r2,r16,0x0010     
00144a98: 34080001 ori r8,r0,0x0001       
00144a9c: ac68004c sw r8,0x004c(r3)       
00144aa0: 2a020010 slti r2,r16,0x0010     
00144aa4: 1440fff0 bne r2,r0,0x00144a68   
00144aa8: 24630400 addiu r3,r3,0x0400     
00144aac: 080517c9 j 0x00145f24           GOTO END
00144ab0: 00000000 nop                   
00144ab4: 16820005 bne r20,r2,0x00144acc 
00144ab8: 34020017 ori r2,r0,0x0017       
00144abc: 0c0526ce jal 0x00149b38         {37}
00144ac0: 02202021 addu r4,r17,r0         
00144ac4: 080517c9 j 0x00145f24           GOTO END
00144ac8: 00000000 nop                   
00144acc: 12820515 beq r20,r2,0x00145f24  {17} GOTO END
00144ad0: 34020018 ori r2,r0,0x0018       
00144ad4: 1682001e bne r20,r2,0x00144b50 
00144ad8: 3402008a ori r2,r0,0x008a       
00144adc: 3c028017 lui r2,0x8017          {18} Effect
00144ae0: 8c423ca4 lw r2,0x3ca4(r2)       
00144ae4: 3c018017 lui r1,0x8017         
00144ae8: a4333cb4 sh r19,0x3cb4(r1)     
00144aec: 005e1021 addu r2,r2,r30         
00144af0: 90440003 lbu r4,0x0003(r2)     
00144af4: 0c04cc56 jal 0x00133158         
00144af8: 00000000 nop                   
00144afc: 3c038017 lui r3,0x8017         
00144b00: 8c633ca4 lw r3,0x3ca4(r3)       
00144b04: 3c018016 lui r1,0x8016         
00144b08: a4225ff8 sh r2,0x5ff8(r1)       
00144b0c: 007e1821 addu r3,r3,r30         
00144b10: 90620004 lbu r2,0x0004(r3)     
00144b14: 3c018016 lui r1,0x8016         
00144b18: a4225ffc sh r2,0x5ffc(r1)       
00144b1c: 90620005 lbu r2,0x0005(r3)     
00144b20: 3404001f ori r4,r0,0x001f       
00144b24: 3c018016 lui r1,0x8016         
00144b28: a4225ffe sh r2,0x5ffe(r1)       
00144b2c: 90620006 lbu r2,0x0006(r3)     
00144b30: 3c018016 lui r1,0x8016         
00144b34: a4226000 sh r2,0x6000(r1)       
00144b38: 0c04ed91 jal 0x0013b644         
00144b3c: 00002821 addu r5,r0,r0         
00144b40: 0c053216 jal 0x0014c858         
00144b44: 34040002 ori r4,r0,0x0002       
00144b48: 080517c9 j 0x00145f24           GOTO END
00144b4c: 00000000 nop                   
00144b50: 1682000d bne r20,r2,0x00144b88 
00144b54: 3402008b ori r2,r0,0x008b       
00144b58: 3c108009 lui r16,0x8009         {8A} EffectStart
00144b5c: 2610dda8 addiu r16,r16,0xdda8   
00144b60: 0c0532a0 jal 0x0014ca80         
00144b64: 00000000 nop                   
00144b68: 3c018017 lui r1,0x8017         
00144b6c: ac303ca8 sw r16,0x3ca8(r1)     
00144b70: 0c0533ad jal 0x0014ceb4         
00144b74: 00000000 nop                   
00144b78: 104004ea beq r2,r0,0x00145f24   
00144b7c: 00000000 nop                   
00144b80: 080512d8 j 0x00144b60           
00144b84: 00000000 nop                   
00144b88: 16820009 bne r20,r2,0x00144bb0 
00144b8c: 3402001f ori r2,r0,0x001f       
00144b90: 0c0526fb jal 0x00149bec         {8B} EffectEnd
00144b94: 34040010 ori r4,r0,0x0010       
00144b98: 3c058014 lui r5,0x8014         
00144b9c: 24a5e8d4 addiu r5,r5,0xe8d4     
00144ba0: 0c053228 jal 0x0014c8a0         
00144ba4: 00402021 addu r4,r2,r0         
00144ba8: 080517c9 j 0x00145f24           GOTO END
00144bac: 00000000 nop                   
00144bb0: 1682000b bne r20,r2,0x00144be0 
00144bb4: 34020038 ori r2,r0,0x0038       
00144bb8: 3c028016 lui r2,0x8016          {1F} Focus
00144bbc: 8c425f9c lw r2,0x5f9c(r2)       
00144bc0: 00000000 nop                   
00144bc4: 8c440078 lw r4,0x0078(r2)       
00144bc8: 0c051cb7 jal 0x001472dc         
00144bcc: 00000000 nop                   
00144bd0: 0c051d61 jal 0x00147584         
00144bd4: 02202021 addu r4,r17,r0         
00144bd8: 080517c9 j 0x00145f24           GOTO END
00144bdc: 00000000 nop                   
00144be0: 16820009 bne r20,r2,0x00144c08 
00144be4: 34020073 ori r2,r0,0x0073       
00144be8: 3c068016 lui r6,0x8016          {38}
00144bec: 8cc65f9c lw r6,0x5f9c(r6)       
00144bf0: 02202021 addu r4,r17,r0         
00144bf4: 24c50068 addiu r5,r6,0x0068     
00144bf8: 0c051de0 jal 0x00147780         
00144bfc: 24c60074 addiu r6,r6,0x0074     
00144c00: 080517c9 j 0x00145f24           GOTO END
00144c04: 00000000 nop                   
00144c08: 16820008 bne r20,r2,0x00144c2c 
00144c0c: 34020019 ori r2,r0,0x0019       
00144c10: 3c058016 lui r5,0x8016          {73}
00144c14: 8ca55f9c lw r5,0x5f9c(r5)       
00144c18: 02202021 addu r4,r17,r0         
00144c1c: 0c051d29 jal 0x001474a4         
00144c20: 24a50068 addiu r5,r5,0x0068     
00144c24: 080517c9 j 0x00145f24           GOTO END
00144c28: 00000000 nop                   
00144c2c: 16820008 bne r20,r2,0x00144c50 
00144c30: 3402001d ori r2,r0,0x001d       
00144c34: 0c0526fb jal 0x00149bec         {19} Camera
00144c38: 34040010 ori r4,r0,0x0010       
00144c3c: 00409021 addu r18,r2,r0         
00144c40: 3c058014 lui r5,0x8014         
00144c44: 24a56110 addiu r5,r5,0x6110     
00144c48: 08051413 j 0x0014504c           
00144c4c: 02402021 addu r4,r18,r0         
00144c50: 1682000f bne r20,r2,0x00144c90 
00144c54: 3402001e ori r2,r0,0x001e       
00144c58: 0c0526fb jal 0x00149bec         {1D}
00144c5c: 34040010 ori r4,r0,0x0010       
00144c60: 00409021 addu r18,r2,r0         
00144c64: 3c058014 lui r5,0x8014         
00144c68: 24a5db9c addiu r5,r5,0xdb9c     
00144c6c: 0c053228 jal 0x0014c8a0         
00144c70: 02402021 addu r4,r18,r0         
00144c74: 00121280 sll r2,r18,0x0a       
00144c78: 3c018017 lui r1,0x8017         
00144c7c: 00220821 addu r1,r1,r2         
00144c80: ac31986c sw r17,-0x6794(r1)     
00144c84: 03c02021 addu r4,r30,r0         
00144c88: 08051651 j 0x00145944           
00144c8c: 3405001e ori r5,r0,0x001e       Block End = 1E
00144c90: 128204a4 beq r20,r2,0x00145f24  {1E} GOTO END
00144c94: 34020063 ori r2,r0,0x0063       
00144c98: 16820005 bne r20,r2,0x00144cb0 
00144c9c: 34020074 ori r2,r0,0x0074       
00144ca0: 3c018016 lui r1,0x8016          {63}
00144ca4: ac326054 sw r18,0x6054(r1)     
00144ca8: 080517c9 j 0x00145f24           GOTO END
00144cac: 00000000 nop                   
00144cb0: 16820005 bne r20,r2,0x00144cc8 
00144cb4: 34020028 ori r2,r0,0x0028       
00144cb8: 0c0526f9 jal 0x00149be4         {74}
00144cbc: 02202021 addu r4,r17,r0         
00144cc0: 080517c9 j 0x00145f24           GOTO END
00144cc4: 00000000 nop                   
00144cc8: 16820009 bne r20,r2,0x00144cf0 
00144ccc: 34020070 ori r2,r0,0x0070       
00144cd0: 3c028014 lui r2,0x8014          {28} WalkTo
00144cd4: 2442e5c0 addiu r2,r2,0xe5c0     
00144cd8: 3c018017 lui r1,0x8017         
00144cdc: ac223ca8 sw r2,0x3ca8(r1)       
00144ce0: 0c0533ad jal 0x0014ceb4         
00144ce4: 02202021 addu r4,r17,r0         
00144ce8: 080517c9 j 0x00145f24           GOTO END
00144cec: 00000000 nop                   
00144cf0: 16820005 bne r20,r2,0x00144d08 
00144cf4: 34020029 ori r2,r0,0x0029       
00144cf8: 0c04f9c2 jal 0x0013e708         {70}
00144cfc: 02202021 addu r4,r17,r0         
00144d00: 080517c9 j 0x00145f24           GOTO END
00144d04: 00000000 nop                   
00144d08: 16820006 bne r20,r2,0x00144d24 
00144d0c: 34020079 ori r2,r0,0x0079       
00144d10: 00132400 sll r4,r19,0x10        {29} WaitWalk
00144d14: 0c04f9f4 jal 0x0013e7d0         
00144d18: 00042403 sra r4,r4,0x10         
00144d1c: 080517c9 j 0x00145f24           GOTO END
00144d20: 00000000 nop                   
00144d24: 16820017 bne r20,r2,0x00144d84 
00144d28: 34020039 ori r2,r0,0x0039       
00144d2c: 00132400 sll r4,r19,0x10        {79} MovementAnim
00144d30: 0c04cc56 jal 0x00133158         
00144d34: 00042403 sra r4,r4,0x10         
00144d38: 00409021 addu r18,r2,r0         
00144d3c: 340807d0 ori r8,r0,0x07d0       
00144d40: 12480478 beq r18,r8,0x00145f24 
00144d44: 00000000 nop                   
00144d48: 3c048017 lui r4,0x8017         
00144d4c: 8c843ca4 lw r4,0x3ca4(r4)       
00144d50: 00000000 nop                   
00144d54: 03c42021 addu r4,r30,r4         
00144d58: 0c05181e jal 0x00146078         
00144d5c: 24840003 addiu r4,r4,0x0003     
00144d60: 00121840 sll r3,r18,0x01       
00144d64: 3c018017 lui r1,0x8017         
00144d68: 00230821 addu r1,r1,r3         
00144d6c: a422da6c sh r2,-0x2594(r1)     
00144d70: 3c018017 lui r1,0x8017         
00144d74: 00230821 addu r1,r1,r3         
00144d78: a420da98 sh r0,-0x2568(r1)     
00144d7c: 080517c9 j 0x00145f24           GOTO END
00144d80: 00000000 nop                   
00144d84: 16820009 bne r20,r2,0x00144dac 
00144d88: 3402003a ori r2,r0,0x003a       
00144d8c: 0c0532a0 jal 0x0014ca80         {39}
00144d90: 00000000 nop                   
00144d94: 0c051801 jal 0x00146004         
00144d98: 2404ffff addiu r4,r0,0xffff     
00144d9c: 10400461 beq r2,r0,0x00145f24   
00144da0: 00000000 nop                   
00144da4: 08051363 j 0x00144d8c           
00144da8: 00000000 nop                   
00144dac: 16820009 bne r20,r2,0x00144dd4 
00144db0: 3402002d ori r2,r0,0x002d       
00144db4: 0c0532a0 jal 0x0014ca80         {3A}
00144db8: 00000000 nop                   
00144dbc: 0c0111b2 jal 0x000446c8         
00144dc0: 00000000 nop                   
00144dc4: 10400457 beq r2,r0,0x00145f24   
00144dc8: 00000000 nop                   
00144dcc: 0805136d j 0x00144db4           
00144dd0: 00000000 nop                   
00144dd4: 16820005 bne r20,r2,0x00144dec 
00144dd8: 3402002c ori r2,r0,0x002c       
00144ddc: 0c0520a1 jal 0x00148284         {2D} RotateUnit
00144de0: 02202021 addu r4,r17,r0         
00144de4: 080517c9 j 0x00145f24           GOTO END
00144de8: 00000000 nop                   
00144dec: 16820006 bne r20,r2,0x00144e08 
00144df0: 34020053 ori r2,r0,0x0053       
00144df4: 02202021 addu r4,r17,r0         {2C}
00144df8: 0c052021 jal 0x00148084         
00144dfc: 00002821 addu r5,r0,r0         
00144e00: 080517c9 j 0x00145f24           GOTO END
00144e04: 00000000 nop                   
00144e08: 16820006 bne r20,r2,0x00144e24 
00144e0c: 34020069 ori r2,r0,0x0069       
00144e10: 02202021 addu r4,r17,r0         {53} FaceUnit
00144e14: 0c052021 jal 0x00148084         
00144e18: 34050001 ori r5,r0,0x0001       
00144e1c: 080517c9 j 0x00145f24           GOTO END
00144e20: 00000000 nop                   
00144e24: 16820005 bne r20,r2,0x00144e3c 
00144e28: 34020064 ori r2,r0,0x0064       
00144e2c: 0c0525e3 jal 0x0014978c         {69}
00144e30: 02202021 addu r4,r17,r0         
00144e34: 080517c9 j 0x00145f24           GOTO END
00144e38: 00000000 nop                   
00144e3c: 16820006 bne r20,r2,0x00144e58 
00144e40: 34020065 ori r2,r0,0x0065       
00144e44: 00132400 sll r4,r19,0x10        {64} WaitRotateUnit ?
00144e48: 0c05263f jal 0x001498fc         
00144e4c: 00042403 sra r4,r4,0x10         
00144e50: 080517c9 j 0x00145f24           GOTO END
00144e54: 00000000 nop                   
00144e58: 16820005 bne r20,r2,0x00144e70 
00144e5c: 3402002a ori r2,r0,0x002a       
00144e60: 0c05263f jal 0x001498fc         {65} WaitFaceUnit ?
00144e64: 2404ffff addiu r4,r0,0xffff     
00144e68: 080517c9 j 0x00145f24           GOTO END
00144e6c: 00000000 nop                   
00144e70: 1682000f bne r20,r2,0x00144eb0 
00144e74: 3402002b ori r2,r0,0x002b       
00144e78: 0c0526fb jal 0x00149bec         {2A} (A) Block Start
00144e7c: 34040010 ori r4,r0,0x0010       
00144e80: 00409021 addu r18,r2,r0         
00144e84: 3c058014 lui r5,0x8014         
00144e88: 24a5e904 addiu r5,r5,0xe904     
00144e8c: 0c053228 jal 0x0014c8a0         
00144e90: 02402021 addu r4,r18,r0         
00144e94: 00121280 sll r2,r18,0x0a       
00144e98: 3c018017 lui r1,0x8017         
00144e9c: 00220821 addu r1,r1,r2         
00144ea0: ac31986c sw r17,-0x6794(r1)     
00144ea4: 03c02021 addu r4,r30,r0         
00144ea8: 08051651 j 0x00145944           
00144eac: 3405002b ori r5,r0,0x002b       Block End = 2B
00144eb0: 1282041c beq r20,r2,0x00145f24  {2B} GOTO END
00144eb4: 34020023 ori r2,r0,0x0023       
00144eb8: 1282041a beq r20,r2,0x00145f24  {23} GOTO END
00144ebc: 34020024 ori r2,r0,0x0024       
00144ec0: 12820418 beq r20,r2,0x00145f24  {24} GOTO END
00144ec4: 34020042 ori r2,r0,0x0042       
00144ec8: 16820009 bne r20,r2,0x00144ef0 
00144ecc: 34020025 ori r2,r0,0x0025       
00144ed0: 0c053216 jal 0x0014c858         {42}
00144ed4: 34040001 ori r4,r0,0x0001       
00144ed8: 0c05272f jal 0x00149cbc         
00144edc: 3404000d ori r4,r0,0x000d       
00144ee0: 0c053250 jal 0x0014c940         
00144ee4: 00402021 addu r4,r2,r0         
00144ee8: 080517c9 j 0x00145f24           GOTO END
00144eec: 00000000 nop                   
00144ef0: 1682000c bne r20,r2,0x00144f24 
00144ef4: 3402001a ori r2,r0,0x001a       
00144ef8: 3c048017 lui r4,0x8017          {25}
00144efc: 8c843ca4 lw r4,0x3ca4(r4)       
00144f00: 3c018016 lui r1,0x8016         
00144f04: a4336072 sh r19,0x6072(r1)     
00144f08: 03c42021 addu r4,r30,r4         
00144f0c: 0c05181e jal 0x00146078         
00144f10: 24840003 addiu r4,r4,0x0003     
00144f14: 3c018016 lui r1,0x8016         
00144f18: a4226074 sh r2,0x6074(r1)       
00144f1c: 080517c9 j 0x00145f24           GOTO END
00144f20: 00000000 nop                   
00144f24: 16820008 bne r20,r2,0x00144f48 
00144f28: 3402003e ori r2,r0,0x003e       
00144f2c: 0c0526fb jal 0x00149bec         {1A}
00144f30: 34040010 ori r4,r0,0x0010       
00144f34: 00409021 addu r18,r2,r0         
00144f38: 3c058014 lui r5,0x8014         
00144f3c: 24a566b4 addiu r5,r5,0x66b4     
00144f40: 08051413 j 0x0014504c           
00144f44: 02402021 addu r4,r18,r0         
00144f48: 16820008 bne r20,r2,0x00144f6c 
00144f4c: 34020041 ori r2,r0,0x0041       
00144f50: 0c0526fb jal 0x00149bec         {3E}
00144f54: 34040010 ori r4,r0,0x0010       
00144f58: 00409021 addu r18,r2,r0         
00144f5c: 3c058014 lui r5,0x8014         
00144f60: 24a567dc addiu r5,r5,0x67dc     
00144f64: 08051413 j 0x0014504c           
00144f68: 02402021 addu r4,r18,r0         
00144f6c: 16820008 bne r20,r2,0x00144f90 
00144f70: 3410003b ori r16,r0,0x003b     
00144f74: 0c0526fb jal 0x00149bec         {41} Earthquake
00144f78: 34040010 ori r4,r0,0x0010       
00144f7c: 00409021 addu r18,r2,r0         
00144f80: 3c058014 lui r5,0x8014         
00144f84: 24a5672c addiu r5,r5,0x672c     
00144f88: 08051413 j 0x0014504c           
00144f8c: 02402021 addu r4,r18,r0         
00144f90: 12900003 beq r20,r16,0x00144fa0 {3B} SpriteMove
00144f94: 3402006e ori r2,r0,0x006e       
00144f98: 1682001d bne r20,r2,0x00145010 
00144f9c: 3402006f ori r2,r0,0x006f       
00144fa0: 0c052712 jal 0x00149c48         {6E}
00144fa4: 34040010 ori r4,r0,0x0010       
00144fa8: 16900005 bne r20,r16,0x00144fc0
00144fac: 00409021 addu r18,r2,r0         
00144fb0: 3c058014 lui r5,0x8014         
00144fb4: 24a56ee4 addiu r5,r5,0x6ee4     
00144fb8: 080513f3 j 0x00144fcc           
00144fbc: 02402021 addu r4,r18,r0         
00144fc0: 02402021 addu r4,r18,r0         
00144fc4: 3c058014 lui r5,0x8014         
00144fc8: 24a56f20 addiu r5,r5,0x6f20     
00144fcc: 0c053228 jal 0x0014c8a0         
00144fd0: 00128280 sll r16,r18,0x0a       
00144fd4: 00132400 sll r4,r19,0x10       
00144fd8: 3402000b ori r2,r0,0x000b       
00144fdc: 3c018017 lui r1,0x8017         
00144fe0: 00300821 addu r1,r1,r16         
00144fe4: ac31986c sw r17,-0x6794(r1)     
00144fe8: 3c018017 lui r1,0x8017         
00144fec: 00300821 addu r1,r1,r16         
00144ff0: ac2298b8 sw r2,-0x6748(r1)     
00144ff4: 0c04cc56 jal 0x00133158         
00144ff8: 00042403 sra r4,r4,0x10         
00144ffc: 3c018017 lui r1,0x8017         
00145000: 00300821 addu r1,r1,r16         
00145004: ac2298bc sw r2,-0x6744(r1)     
00145008: 080517c9 j 0x00145f24           GOTO END
0014500c: 00000000 nop                   
00145010: 16820006 bne r20,r2,0x0014502c 
00145014: 3402001b ori r2,r0,0x001b       
00145018: 00132400 sll r4,r19,0x10        {6F} WaitSpriteMove ?
0014501c: 0c051bd7 jal 0x00146f5c         
00145020: 00042403 sra r4,r4,0x10         
00145024: 080517c9 j 0x00145f24           GOTO END
00145028: 00000000 nop                   
0014502c: 1682000f bne r20,r2,0x0014506c 
00145030: 3402002e ori r2,r0,0x002e       
00145034: 0c0526fb jal 0x00149bec         {1B}
00145038: 34040010 ori r4,r0,0x0010       
0014503c: 00409021 addu r18,r2,r0         
00145040: 02402021 addu r4,r18,r0         
00145044: 3c058014 lui r5,0x8014         
00145048: 24a5703c addiu r5,r5,0x703c     
0014504c: 0c053228 jal 0x0014c8a0         
00145050: 00000000 nop                   
00145054: 00121280 sll r2,r18,0x0a       
00145058: 3c018017 lui r1,0x8017         
0014505c: 00220821 addu r1,r1,r2         
00145060: ac31986c sw r17,-0x6794(r1)     
00145064: 080517c9 j 0x00145f24           GOTO END
00145068: 00000000 nop                   
0014506c: 16820019 bne r20,r2,0x001450d4 
00145070: 34020031 ori r2,r0,0x0031       
00145074: 3c108017 lui r16,0x8017         {2E} Background
00145078: 2610e418 addiu r16,r16,0xe418   
0014507c: 02002021 addu r4,r16,r0         
00145080: 02202821 addu r5,r17,r0         
00145084: 0c052fd5 jal 0x0014bf54         
00145088: 34060003 ori r6,r0,0x0003       
0014508c: 26040004 addiu r4,r16,0x0004   
00145090: 26250003 addiu r5,r17,0x0003   
00145094: 0c052fd5 jal 0x0014bf54         
00145098: 34060003 ori r6,r0,0x0003       
0014509c: 92220007 lbu r2,0x0007(r17)     
001450a0: 00000000 nop                   
001450a4: 14400006 bne r2,r0,0x001450c0   
001450a8: 00000000 nop                   
001450ac: 92240006 lbu r4,0x0006(r17)     
001450b0: 0c02407e jal 0x000901f8         
001450b4: 02002821 addu r5,r16,r0         
001450b8: 080517c9 j 0x00145f24           GOTO END
001450bc: 00000000 nop                   
001450c0: 92240006 lbu r4,0x0006(r17)     
001450c4: 0c024d7d jal 0x000935f4         
001450c8: 02002821 addu r5,r16,r0         
001450cc: 080517c9 j 0x00145f24           GOTO END
001450d0: 00000000 nop                   
001450d4: 1682000a bne r20,r2,0x00145100 
001450d8: 34020032 ori r2,r0,0x0032       
001450dc: 82220003 lb r2,0x0003(r17)      {31} ColorBGBeta
001450e0: 92240000 lbu r4,0x0000(r17)     
001450e4: 92250004 lbu r5,0x0004(r17)     
001450e8: 82260001 lb r6,0x0001(r17)     
001450ec: 82270002 lb r7,0x0002(r17)     
001450f0: 0c024d27 jal 0x0009349c         
001450f4: afa20010 sw r2,0x0010(r29)     
001450f8: 080517c9 j 0x00145f24           GOTO END
001450fc: 00000000 nop                   
00145100: 16820005 bne r20,r2,0x00145118 
00145104: 3402006c ori r2,r0,0x006c       
00145108: 0c052578 jal 0x001495e0         {32} ColorUnit
0014510c: 02202021 addu r4,r17,r0         
00145110: 080517c9 j 0x00145f24           GOTO END
00145114: 00000000 nop                   
00145118: 16820006 bne r20,r2,0x00145134 
0014511c: 3402006d ori r2,r0,0x006d       
00145120: 3264ffff andi r4,r19,0xffff     {6C}
00145124: 0c0525a3 jal 0x0014968c         
00145128: 00002821 addu r5,r0,r0         
0014512c: 080517c9 j 0x00145f24           GOTO END
00145130: 00000000 nop                   
00145134: 16820006 bne r20,r2,0x00145150 
00145138: 34020033 ori r2,r0,0x0033       
0014513c: 3264ffff andi r4,r19,0xffff     {6D}
00145140: 0c0525a3 jal 0x0014968c         
00145144: 34050001 ori r5,r0,0x0001       
00145148: 080517c9 j 0x00145f24           GOTO END
0014514c: 00000000 nop                   
00145150: 1682000a bne r20,r2,0x0014517c 
00145154: 34020066 ori r2,r0,0x0066       
00145158: 82220003 lb r2,0x0003(r17)      {33} ColorField
0014515c: 92240000 lbu r4,0x0000(r17)     
00145160: 92250004 lbu r5,0x0004(r17)     
00145164: 82260001 lb r6,0x0001(r17)     
00145168: 82270002 lb r7,0x0002(r17)     
0014516c: 0c024c5c jal 0x00093170         
00145170: afa20010 sw r2,0x0010(r29)     
00145174: 080517c9 j 0x00145f24           GOTO END
00145178: 00000000 nop                   
0014517c: 16820007 bne r20,r2,0x0014519c 
00145180: 3402003f ori r2,r0,0x003f       
00145184: 00002021 addu r4,r0,r0          {66}
00145188: 00002821 addu r5,r0,r0         
0014518c: 0c023d8f jal 0x0008f63c         
00145190: 34060001 ori r6,r0,0x0001       
00145194: 080517c9 j 0x00145f24           GOTO END
00145198: 00000000 nop                   
0014519c: 1682000a bne r20,r2,0x001451c8 
001451a0: 34020040 ori r2,r0,0x0040       
001451a4: 92250000 lbu r5,0x0000(r17)     {3F}
001451a8: 92260001 lbu r6,0x0001(r17)     
001451ac: 92270002 lbu r7,0x0002(r17)     
001451b0: 92220003 lbu r2,0x0003(r17)     
001451b4: 3404000b ori r4,r0,0x000b       
001451b8: 0c061053 jal 0x0018414c         
001451bc: afa20010 sw r2,0x0010(r29)     
001451c0: 080517c9 j 0x00145f24           GOTO END
001451c4: 00000000 nop                   
001451c8: 1682001f bne r20,r2,0x00145248 
001451cc: 3402001c ori r2,r0,0x001c       
001451d0: 92240000 lbu r4,0x0000(r17)     {40}
001451d4: 92250001 lbu r5,0x0001(r17)     
001451d8: 92260002 lbu r6,0x0002(r17)     
001451dc: 0c060fed jal 0x00183fb4         
001451e0: 00000000 nop                   
001451e4: 00402021 addu r4,r2,r0         
001451e8: 90820000 lbu r2,0x0000(r4)     
001451ec: 00000000 nop                   
001451f0: 3042003f andi r2,r2,0x003f     
001451f4: 2442fffd addiu r2,r2,0xfffd     
001451f8: 2c420002 sltiu r2,r2,0x0002     
001451fc: 14400006 bne r2,r0,0x00145218   
00145200: 00000000 nop                   
00145204: 90820000 lbu r2,0x0000(r4)     
00145208: 00000000 nop                   
0014520c: 304200c0 andi r2,r2,0x00c0     
00145210: 34420015 ori r2,r2,0x0015       
00145214: a0820000 sb r2,0x0000(r4)       
00145218: 92220003 lbu r2,0x0003(r17)     
0014521c: 00000000 nop                   
00145220: a0820002 sb r2,0x0002(r4)       
00145224: 92230004 lbu r3,0x0004(r17)     
00145228: 90820006 lbu r2,0x0006(r4)     
0014522c: 30630001 andi r3,r3,0x0001     
00145230: 00031840 sll r3,r3,0x01         
00145234: 304200fd andi r2,r2,0x00fd     
00145238: 00431025 or r2,r2,r3           
0014523c: 304200fe andi r2,r2,0x00fe     
00145240: 080517c9 j 0x00145f24           GOTO END
00145244: a0820006 sb r2,0x0006(r4)       
00145248: 16820005 bne r20,r2,0x00145260 
0014524c: 34020076 ori r2,r0,0x0076       
00145250: 0c04f680 jal 0x0013da00         {1C}
00145254: 02402021 addu r4,r18,r0         
00145258: 080517c9 j 0x00145f24           GOTO END
0014525c: 00000000 nop                   
00145260: 1682000e bne r20,r2,0x0014529c 
00145264: 34020077 ori r2,r0,0x0077       
00145268: 3c018016 lui r1,0x8016          {76} DarkScreen
0014526c: ac206044 sw r0,0x6044(r1)       
00145270: 0c0526fb jal 0x00149bec         
00145274: 34040010 ori r4,r0,0x0010       
00145278: 00409021 addu r18,r2,r0         
0014527c: 3c058014 lui r5,0x8014         
00145280: 24a5bd94 addiu r5,r5,0xbd94     
00145284: 0c053228 jal 0x0014c8a0         
00145288: 02402021 addu r4,r18,r0         
0014528c: 02402021 addu r4,r18,r0         
00145290: 00002821 addu r5,r0,r0         
00145294: 080517c3 j 0x00145f0c           
00145298: 02203021 addu r6,r17,r0         
0014529c: 1682000c bne r20,r2,0x001452d0 
001452a0: 34020078 ori r2,r0,0x0078       
001452a4: 0c05272f jal 0x00149cbc         {77} RemoveDarkScreen
001452a8: 34040037 ori r4,r0,0x0037       
001452ac: 00409021 addu r18,r2,r0         
001452b0: 1240031c beq r18,r0,0x00145f24 
001452b4: 00121a80 sll r3,r18,0x0a       
001452b8: 34020036 ori r2,r0,0x0036       
001452bc: 3c018017 lui r1,0x8017         
001452c0: 00230821 addu r1,r1,r3         
001452c4: ac2298b8 sw r2,-0x6748(r1)     
001452c8: 080517c9 j 0x00145f24           GOTO END
001452cc: 00000000 nop                   
001452d0: 16820014 bne r20,r2,0x00145324 
001452d4: 3402007d ori r2,r0,0x007d       
001452d8: 0c0526fb jal 0x00149bec         {78} DisplayConditions
001452dc: 34040010 ori r4,r0,0x0010       
001452e0: 0040b021 addu r22,r2,r0         
001452e4: 34020004 ori r2,r0,0x0004       
001452e8: 16c20006 bne r22,r2,0x00145304 
001452ec: 34020007 ori r2,r0,0x0007       
001452f0: 16420004 bne r18,r2,0x00145304 
001452f4: 00000000 nop                   
001452f8: 0c053274 jal 0x0014c9d0         
001452fc: 34040002 ori r4,r0,0x0002       
00145300: 34160002 ori r22,r0,0x0002     
00145304: 3c058014 lui r5,0x8014         
00145308: 24a5bd6c addiu r5,r5,0xbd6c     
0014530c: 0c053228 jal 0x0014c8a0         
00145310: 02c02021 addu r4,r22,r0         
00145314: 02c02021 addu r4,r22,r0         
00145318: 02402821 addu r5,r18,r0         
0014531c: 080517c3 j 0x00145f0c           
00145320: 02a03021 addu r6,r21,r0         
00145324: 1682000b bne r20,r2,0x00145354 
00145328: 34020021 ori r2,r0,0x0021       
0014532c: 0c0526fb jal 0x00149bec         {7D} ShowChapter
00145330: 34040010 ori r4,r0,0x0010       
00145334: 0040b021 addu r22,r2,r0         
00145338: 3c058014 lui r5,0x8014         
0014533c: 24a5c710 addiu r5,r5,0xc710     
00145340: 0c053228 jal 0x0014c8a0         
00145344: 02c02021 addu r4,r22,r0         
00145348: 02c02021 addu r4,r22,r0         
0014534c: 080517c2 j 0x00145f08           
00145350: 02402821 addu r5,r18,r0         
00145354: 16820007 bne r20,r2,0x00145374 
00145358: 3402006b ori r2,r0,0x006b       
0014535c: 00131400 sll r2,r19,0x10        {21} Sound
00145360: 00021403 sra r2,r2,0x10         
00145364: 3c018016 lui r1,0x8016         
00145368: ac225fb4 sw r2,0x5fb4(r1)       
0014536c: 080517c9 j 0x00145f24           GOTO END
00145370: 00000000 nop                   
00145374: 16820008 bne r20,r2,0x00145398 
00145378: 3402006a ori r2,r0,0x006a       
0014537c: 0c0526fb jal 0x00149bec         {6B} BGSound
00145380: 34040010 ori r4,r0,0x0010       
00145384: 00409021 addu r18,r2,r0         
00145388: 3c058015 lui r5,0x8015         
0014538c: 24a599ac addiu r5,r5,0x99ac     
00145390: 080517be j 0x00145ef8           
00145394: 02402021 addu r4,r18,r0         
00145398: 16820008 bne r20,r2,0x001453bc 
0014539c: 34020022 ori r2,r0,0x0022       
001453a0: 0c0526fb jal 0x00149bec         {6A}
001453a4: 34040010 ori r4,r0,0x0010       
001453a8: 00409021 addu r18,r2,r0         
001453ac: 3c058015 lui r5,0x8015         
001453b0: 24a59a54 addiu r5,r5,0x9a54     
001453b4: 080517be j 0x00145ef8           
001453b8: 02402021 addu r4,r18,r0         
001453bc: 1682000b bne r20,r2,0x001453ec 
001453c0: 34020060 ori r2,r0,0x0060       
001453c4: 3c018016 lui r1,0x8016          {22} Music
001453c8: a4325fc8 sh r18,0x5fc8(r1)     
001453cc: 3c018017 lui r1,0x8017         
001453d0: a4353f54 sh r21,0x3f54(r1)     
001453d4: 3c018017 lui r1,0x8017         
001453d8: a4363f56 sh r22,0x3f56(r1)     
001453dc: 0c0532a0 jal 0x0014ca80         
001453e0: 00000000 nop                   
001453e4: 080517c9 j 0x00145f24           GOTO END
001453e8: 00000000 nop                   
001453ec: 16820009 bne r20,r2,0x00145414 
001453f0: 3402005e ori r2,r0,0x005e       
001453f4: 26420010 addiu r2,r18,0x0010    {60}
001453f8: 00551004 sllv r2,r21,r2         
001453fc: 3c018016 lui r1,0x8016         
00145400: ac225fc0 sw r2,0x5fc0(r1)       
00145404: 0c0532a0 jal 0x0014ca80         
00145408: 00000000 nop                   
0014540c: 080517c9 j 0x00145f24           GOTO END
00145410: 00000000 nop                   
00145414: 16820007 bne r20,r2,0x00145434 
00145418: 34020058 ori r2,r0,0x0058       
0014541c: 3c018016 lui r1,0x8016          {5E}
00145420: a4325fca sh r18,0x5fca(r1)     
00145424: 0c0532a0 jal 0x0014ca80         
00145428: 00000000 nop                   
0014542c: 080517c9 j 0x00145f24           GOTO END
00145430: 00000000 nop                   
00145434: 16820018 bne r20,r2,0x00145498 
00145438: 3402005b ori r2,r0,0x005b       
0014543c: 0c0526fb jal 0x00149bec         {58} LoadEVTCHR
00145440: 34040010 ori r4,r0,0x0010       
00145444: 0040a821 addu r21,r2,r0         
00145448: 3c058014 lui r5,0x8014         
0014544c: 24a5c7c4 addiu r5,r5,0xc7c4     
00145450: 0c053228 jal 0x0014c8a0         
00145454: 02a02021 addu r4,r21,r0         
00145458: 3c048017 lui r4,0x8017         
0014545c: 8c843ca4 lw r4,0x3ca4(r4)       
00145460: 00000000 nop                   
00145464: 03c42021 addu r4,r30,r4         
00145468: 0c05181e jal 0x00146078         
0014546c: 24840002 addiu r4,r4,0x0002     
00145470: 02a02021 addu r4,r21,r0         
00145474: 02402821 addu r5,r18,r0         
00145478: 00021400 sll r2,r2,0x10         
0014547c: 00023403 sra r6,r2,0x10         
00145480: 0c05328e jal 0x0014ca38         
00145484: 00003821 addu r7,r0,r0         
00145488: 0c0532a0 jal 0x0014ca80         
0014548c: 00000000 nop                   
00145490: 080517c9 j 0x00145f24           GOTO END
00145494: 00000000 nop                   
00145498: 16820007 bne r20,r2,0x001454b8 
0014549c: 34020059 ori r2,r0,0x0059       
001454a0: 3c018017 lui r1,0x8017          {5B}
001454a4: ac323ca0 sw r18,0x3ca0(r1)     
001454a8: 0c0532a0 jal 0x0014ca80         
001454ac: 00000000 nop                   
001454b0: 080517c9 j 0x00145f24           GOTO END
001454b4: 00000000 nop                   
001454b8: 16820007 bne r20,r2,0x001454d8 
001454bc: 3402005a ori r2,r0,0x005a       
001454c0: 3c018017 lui r1,0x8017          {59} SaveEVTCHR
001454c4: ac323f4c sw r18,0x3f4c(r1)     
001454c8: 0c0532a0 jal 0x0014ca80         
001454cc: 00000000 nop                   
001454d0: 080517c9 j 0x00145f24           GOTO END
001454d4: 00000000 nop                   
001454d8: 16820007 bne r20,r2,0x001454f8 
001454dc: 3402005c ori r2,r0,0x005c       
001454e0: 3c018017 lui r1,0x8017          {5A}
001454e4: ac323f50 sw r18,0x3f50(r1)     
001454e8: 0c0532a0 jal 0x0014ca80         
001454ec: 00000000 nop                   
001454f0: 080517c9 j 0x00145f24           GOTO END
001454f4: 00000000 nop                   
001454f8: 1682000c bne r20,r2,0x0014552c 
001454fc: 3402005d ori r2,r0,0x005d       
00145500: 00132400 sll r4,r19,0x10        {5C}
00145504: 0c04cc56 jal 0x00133158         
00145508: 00042403 sra r4,r4,0x10         
0014550c: 00021200 sll r2,r2,0x08         
00145510: 00561025 or r2,r2,r22           
00145514: 3c018017 lui r1,0x8017         
00145518: ac223cac sw r2,0x3cac(r1)       
0014551c: 0c0532a0 jal 0x0014ca80         
00145520: 00000000 nop                   
00145524: 080517c9 j 0x00145f24           GOTO END
00145528: 00000000 nop                   
0014552c: 16820007 bne r20,r2,0x0014554c 
00145530: 340200e0 ori r2,r0,0x00e0       
00145534: 3c018017 lui r1,0x8017          {5D}
00145538: ac323f48 sw r18,0x3f48(r1)     
0014553c: 0c0532a0 jal 0x0014ca80         
00145540: 00000000 nop                   
00145544: 080517c9 j 0x00145f24           GOTO END
00145548: 00000000 nop                   
0014554c: 12820275 beq r20,r2,0x00145f24  {E0}
00145550: 3402003d ori r2,r0,0x003d       
00145554: 1682001e bne r20,r2,0x001455d0 
00145558: 34020044 ori r2,r0,0x0044       
0014555c: 00132400 sll r4,r19,0x10        {3D}
00145560: 0c04cc56 jal 0x00133158         
00145564: 00042403 sra r4,r4,0x10         
00145568: 00021400 sll r2,r2,0x10         
0014556c: 00022403 sra r4,r2,0x10         
00145570: 340807d0 ori r8,r0,0x07d0       
00145574: 1088026b beq r4,r8,0x00145f24   
00145578: 00808021 addu r16,r4,r0         
0014557c: 0c051801 jal 0x00146004         
00145580: 02002021 addu r4,r16,r0         
00145584: 10400005 beq r2,r0,0x0014559c   
00145588: 340807d0 ori r8,r0,0x07d0       
0014558c: 0c0532a0 jal 0x0014ca80         
00145590: 00000000 nop                   
00145594: 0805155f j 0x0014557c           
00145598: 00000000 nop                   
0014559c: 12080261 beq r16,r8,0x00145f24 
001455a0: 00000000 nop                   
001455a4: 0c023374 jal 0x0008cdd0         
001455a8: 02002021 addu r4,r16,r0         
001455ac: 00409021 addu r18,r2,r0         
001455b0: 0c02348a jal 0x0008d228         
001455b4: 02002021 addu r4,r16,r0         
001455b8: 0640025a bltz r18,0x00145f24   
001455bc: 00000000 nop                   
001455c0: 0c05ff60 jal 0x0017fd80         
001455c4: 02402021 addu r4,r18,r0         
001455c8: 080517c9 j 0x00145f24           GOTO END
001455cc: 00000000 nop                   
001455d0: 1682001e bne r20,r2,0x0014564c 
001455d4: 34020046 ori r2,r0,0x0046       
001455d8: 00132400 sll r4,r19,0x10        {44} Draw
001455dc: 0c04cc56 jal 0x00133158         
001455e0: 00042403 sra r4,r4,0x10         
001455e4: 00021400 sll r2,r2,0x10         
001455e8: 00028403 sra r16,r2,0x10       
001455ec: 340807d0 ori r8,r0,0x07d0       
001455f0: 1208024c beq r16,r8,0x00145f24 
001455f4: 00000000 nop                   
001455f8: 0c02344e jal 0x0008d138         
001455fc: 02002021 addu r4,r16,r0         
00145600: 0c04ed64 jal 0x0013b590         
00145604: 34040027 ori r4,r0,0x0027       
00145608: 3403018c ori r3,r0,0x018c       
0014560c: 14430245 bne r2,r3,0x00145f24   
00145610: 00000000 nop                   
00145614: 0c023374 jal 0x0008cdd0         
00145618: 02002021 addu r4,r16,r0         
0014561c: 00402021 addu r4,r2,r0         
00145620: 34050001 ori r5,r0,0x0001       
00145624: 0c052122 jal 0x00148488         
00145628: 00000000 nop                   
0014562c: 3c028009 lui r2,0x8009         
00145630: 2442bde4 addiu r2,r2,0xbde4     
00145634: 3c018017 lui r1,0x8017         
00145638: ac223ca8 sw r2,0x3ca8(r1)       
0014563c: 0c0533ad jal 0x0014ceb4         
00145640: 02002021 addu r4,r16,r0         
00145644: 080517c9 j 0x00145f24           GOTO END
00145648: 00000000 nop                   
0014564c: 16820015 bne r20,r2,0x001456a4 
00145650: 34020047 ori r2,r0,0x0047       
00145654: 00132400 sll r4,r19,0x10        {46} Erase
00145658: 0c04cc56 jal 0x00133158         
0014565c: 00042403 sra r4,r4,0x10         
00145660: 00021400 sll r2,r2,0x10         
00145664: 00022403 sra r4,r2,0x10         
00145668: 340807d0 ori r8,r0,0x07d0       
0014566c: 1088022d beq r4,r8,0x00145f24   
00145670: 00000000 nop                   
00145674: 0c023463 jal 0x0008d18c         
00145678: 00000000 nop                   
0014567c: 080517c9 j 0x00145f24           GOTO END
00145680: 00000000 nop                   
00145684: 92220000 lbu r2,0x0000(r17)     
00145688: 00000000 nop                   
0014568c: 00021040 sll r2,r2,0x01         
00145690: 3c018016 lui r1,0x8016         
00145694: 00220821 addu r1,r1,r2         
00145698: a4305fe8 sh r16,0x5fe8(r1)     
0014569c: 080515bc j 0x001456f0           
001456a0: 34020015 ori r2,r0,0x0015       
001456a4: 16820027 bne r20,r2,0x00145744 
001456a8: 34020075 ori r2,r0,0x0075       
001456ac: 3c028017 lui r2,0x8017          {47}
001456b0: 8c423ca4 lw r2,0x3ca4(r2)       
001456b4: 34100003 ori r16,r0,0x0003     
001456b8: 03c21021 addu r2,r30,r2         
001456bc: 24510003 addiu r17,r2,0x0003   
001456c0: 2610ffff addiu r16,r16,0xffff   
001456c4: 0601ffff bgez r16,0x001456c4   
001456c8: 2610ffff addiu r16,r16,0xffff   
001456cc: 00008021 addu r16,r0,r0         
001456d0: 0c0232ed jal 0x0008cbb4         
001456d4: 02002021 addu r4,r16,r0         
001456d8: 1040ffea beq r2,r0,0x00145684   
001456dc: 00000000 nop                   
001456e0: 26100001 addiu r16,r16,0x0001   
001456e4: 2a020015 slti r2,r16,0x0015     
001456e8: 1440fff9 bne r2,r0,0x001456d0   
001456ec: 34020015 ori r2,r0,0x0015       
001456f0: 1202f986 beq r16,r2,0x00143d0c 
001456f4: 00131400 sll r2,r19,0x10       
001456f8: 92240001 lbu r4,0x0001(r17)     
001456fc: 92250002 lbu r5,0x0002(r17)     
00145700: 92260003 lbu r6,0x0003(r17)     
00145704: 92270004 lbu r7,0x0004(r17)     
00145708: 00021403 sra r2,r2,0x10         
0014570c: afa20010 sw r2,0x0010(r29)     
00145710: 92220000 lbu r2,0x0000(r17)     
00145714: 00000000 nop                   
00145718: 00021040 sll r2,r2,0x01         
0014571c: 3c018016 lui r1,0x8016         
00145720: 00220821 addu r1,r1,r2         
00145724: 84225fe8 lh r2,0x5fe8(r1)       
00145728: 00000000 nop                   
0014572c: afa20014 sw r2,0x0014(r29)     
00145730: 92220005 lbu r2,0x0005(r17)     
00145734: 0c0233de jal 0x0008cf78         
00145738: afa20018 sw r2,0x0018(r29)     
0014573c: 080515f6 j 0x001457d8           
00145740: 34080001 ori r8,r0,0x0001       
00145744: 128201f7 beq r20,r2,0x00145f24  {75} GOTO END
00145748: 34020045 ori r2,r0,0x0045       
0014574c: 16820036 bne r20,r2,0x00145828 
00145750: 3402005f ori r2,r0,0x005f       
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Xifanie on November 29, 2011, 02:33:23 am
00145754: 0c050ef4 jal 0x00143bd0         {45}
00145758: 00000000 nop                   
0014575c: 00132400 sll r4,r19,0x10       
00145760: 00042403 sra r4,r4,0x10         
00145764: 0c060324 jal 0x00180c90         
00145768: 27a50020 addiu r5,r29,0x0020   
0014576c: 00408821 addu r17,r2,r0         
00145770: 8fa30020 lw r3,0x0020(r29)     
00145774: 2402fffe addiu r2,r0,0xfffe     
00145778: 10620003 beq r3,r2,0x00145788   
0014577c: 00008021 addu r16,r0,r0         
00145780: 046001e8 bltz r3,0x00145f24     
00145784: 00000000 nop                   
00145788: 0c0602bf jal 0x00180afc         
0014578c: 02002021 addu r4,r16,r0         
00145790: 10510005 beq r2,r17,0x001457a8 
00145794: 00000000 nop                   
00145798: 26100001 addiu r16,r16,0x0001   
0014579c: 2a020015 slti r2,r16,0x0015     
001457a0: 1440fff9 bne r2,r0,0x00145788   
001457a4: 00000000 nop                   
001457a8: 0c023388 jal 0x0008ce20         
001457ac: 02002021 addu r4,r16,r0         
001457b0: 00409021 addu r18,r2,r0         
001457b4: 2402ffff addiu r2,r0,0xffff     
001457b8: 1642000b bne r18,r2,0x001457e8 
001457bc: 00000000 nop                   
001457c0: 0c052160 jal 0x00148580         
001457c4: 02002021 addu r4,r16,r0         
001457c8: 02002021 addu r4,r16,r0         
001457cc: 0c023417 jal 0x0008d05c         
001457d0: 02c02821 addu r5,r22,r0         
001457d4: 34080001 ori r8,r0,0x0001       
001457d8: 3c018016 lui r1,0x8016         
001457dc: a428604e sh r8,0x604e(r1)       
001457e0: 080517c9 j 0x00145f24           GOTO END
001457e4: 00000000 nop                   
001457e8: 16c00003 bne r22,r0,0x001457f8 
001457ec: 00000000 nop                   
001457f0: 0c02344e jal 0x0008d138         
001457f4: 02402021 addu r4,r18,r0         
001457f8: 0c052160 jal 0x00148580         
001457fc: 02002021 addu r4,r16,r0         
00145800: 104001c8 beq r2,r0,0x00145f24   
00145804: 00000000 nop                   
00145808: 3c028009 lui r2,0x8009         
0014580c: 2442bde4 addiu r2,r2,0xbde4     
00145810: 3c018017 lui r1,0x8017         
00145814: ac223ca8 sw r2,0x3ca8(r1)       
00145818: 0c0533ad jal 0x0014ceb4         
0014581c: 02402021 addu r4,r18,r0         
00145820: 080517c9 j 0x00145f24           GOTO END
00145824: 00000000 nop                   
00145828: 16820005 bne r20,r2,0x00145840 
0014582c: 34020061 ori r2,r0,0x0061       
00145830: 0c051f98 jal 0x00147e60         {5F} WarpUnit
00145834: 02202021 addu r4,r17,r0         
00145838: 080517c9 j 0x00145f24           GOTO END
0014583c: 00000000 nop                   
00145840: 128201b8 beq r20,r2,0x00145f24  {61} GOTO END
00145844: 34020062 ori r2,r0,0x0062       
00145848: 1682001a bne r20,r2,0x001458b4 
0014584c: 34020048 ori r2,r0,0x0048       
00145850: 0c0602bf jal 0x00180afc         {62}
00145854: 02402021 addu r4,r18,r0         
00145858: 3c048017 lui r4,0x8017         
0014585c: 8c843ca4 lw r4,0x3ca4(r4)       
00145860: 00000000 nop                   
00145864: 03c42021 addu r4,r30,r4         
00145868: 90830003 lbu r3,0x0003(r4)     
0014586c: 00408821 addu r17,r2,r0         
00145870: a2230047 sb r3,0x0047(r17)     
00145874: 90820004 lbu r2,0x0004(r4)     
00145878: 00000000 nop                   
0014587c: a2220048 sb r2,0x0048(r17)     
00145880: 90820005 lbu r2,0x0005(r4)     
00145884: 96230048 lhu r3,0x0048(r17)     
00145888: 000213c0 sll r2,r2,0x0f         
0014588c: 30637fff andi r3,r3,0x7fff     
00145890: 00621825 or r3,r3,r2           
00145894: a6230048 sh r3,0x0048(r17)     
00145898: 90820006 lbu r2,0x0006(r4)     
0014589c: 3063f0ff andi r3,r3,0xf0ff     
001458a0: 3042000f andi r2,r2,0x000f     
001458a4: 00021200 sll r2,r2,0x08         
001458a8: 00621825 or r3,r3,r2           
001458ac: 080517c9 j 0x00145f24           GOTO END
001458b0: a6230048 sh r3,0x0048(r17)     
001458b4: 1682000a bne r20,r2,0x001458e0 
001458b8: 3402004b ori r2,r0,0x004b       
001458bc: 0c0532a0 jal 0x0014ca80         {48}
001458c0: 00000000 nop                   
001458c4: 3c028016 lui r2,0x8016         
001458c8: 9442604e lhu r2,0x604e(r2)     
001458cc: 00000000 nop                   
001458d0: 10400194 beq r2,r0,0x00145f24   
001458d4: 00000000 nop                   
001458d8: 0805162f j 0x001458bc           
001458dc: 00000000 nop                   
001458e0: 16820009 bne r20,r2,0x00145908 
001458e4: 34020049 ori r2,r0,0x0049       
001458e8: 0c0532a0 jal 0x0014ca80         {4B} AddUnitEnd ?
001458ec: 00000000 nop                   
001458f0: 0c05272f jal 0x00149cbc         
001458f4: 3404000e ori r4,r0,0x000e       
001458f8: 1040018a beq r2,r0,0x00145f24   
001458fc: 00000000 nop                   
00145900: 0805163a j 0x001458e8           
00145904: 00000000 nop                   
00145908: 16820012 bne r20,r2,0x00145954 
0014590c: 3402004a ori r2,r0,0x004a       
00145910: 0c0526fb jal 0x00149bec         {49}
00145914: 34040010 ori r4,r0,0x0010       
00145918: 00409021 addu r18,r2,r0         
0014591c: 3c058014 lui r5,0x8014         
00145920: 24a5edd8 addiu r5,r5,0xedd8     
00145924: 0c053228 jal 0x0014c8a0         
00145928: 02402021 addu r4,r18,r0         
0014592c: 00121280 sll r2,r18,0x0a       
00145930: 3c018017 lui r1,0x8017         
00145934: 00220821 addu r1,r1,r2         
00145938: ac31986c sw r17,-0x6794(r1)     
0014593c: 03c02021 addu r4,r30,r0         
00145940: 3405004a ori r5,r0,0x004a       Block End = 4A
00145944: 0c0527af jal 0x00149ebc         
00145948: 00000000 nop                   
0014594c: 080517c9 j 0x00145f24           GOTO END
00145950: 0040f021 addu r30,r2,r0         
00145954: 12820173 beq r20,r2,0x00145f24  {4A} GOTO END
00145958: 340200e5 ori r2,r0,0x00e5       
0014595c: 1682001a bne r20,r2,0x001459c8 
00145960: 340200f0 ori r2,r0,0x00f0       
00145964: 00151200 sll r2,r21,0x08        {E5} WaitForInstruction
00145968: 0052b021 addu r22,r2,r18       
0014596c: 3c118017 lui r17,0x8017         
00145970: 2631986c addiu r17,r17,0x986c   
00145974: 0c0532a0 jal 0x0014ca80         
00145978: 34100001 ori r16,r0,0x0001     
0014597c: 00101280 sll r2,r16,0x0a       
00145980: 00511821 addu r3,r2,r17         
00145984: 8c620048 lw r2,0x0048(r3)       
00145988: 00000000 nop                   
0014598c: 10400005 beq r2,r0,0x001459a4   
00145990: 00000000 nop                   
00145994: 8c62004c lw r2,0x004c(r3)       
00145998: 00000000 nop                   
0014599c: 10560006 beq r2,r22,0x001459b8 
001459a0: 34020010 ori r2,r0,0x0010       
001459a4: 26100001 addiu r16,r16,0x0001   
001459a8: 2a020010 slti r2,r16,0x0010     
001459ac: 1440fff4 bne r2,r0,0x00145980   
001459b0: 00101280 sll r2,r16,0x0a       
001459b4: 34020010 ori r2,r0,0x0010       
001459b8: 1202015a beq r16,r2,0x00145f24 
001459bc: 00000000 nop                   
001459c0: 0805165d j 0x00145974           
001459c4: 00000000 nop                   
001459c8: 16820005 bne r20,r2,0x001459e0 
001459cc: 340200f1 ori r2,r0,0x00f1       
001459d0: 0c0532a0 jal 0x0014ca80         {F0}
001459d4: 00000000 nop                   
001459d8: 080517c9 j 0x00145f24           GOTO END
001459dc: 00000000 nop                   
001459e0: 16820016 bne r20,r2,0x00145a3c 
001459e4: 3402007b ori r2,r0,0x007b       
001459e8: 0c04b721 jal 0x0012dc84         {F1} Wait
001459ec: 00000000 nop                   
001459f0: 1040000d beq r2,r0,0x00145a28   
001459f4: 00131400 sll r2,r19,0x10       
001459f8: 00028403 sra r16,r2,0x10       
001459fc: 2a020003 slti r2,r16,0x0003     
00145a00: 1440000a bne r2,r0,0x00145a2c   
00145a04: 00132400 sll r4,r19,0x10       
00145a08: 0c0237b6 jal 0x0008ded8         
00145a0c: 00000000 nop                   
00145a10: 0202001a div r16,r2             
00145a14: 00002012 mflo r4               
00145a18: 0c053216 jal 0x0014c858         
00145a1c: 00000000 nop                   
00145a20: 080517c9 j 0x00145f24           GOTO END
00145a24: 00000000 nop                   
00145a28: 00132400 sll r4,r19,0x10       
00145a2c: 0c053216 jal 0x0014c858         
00145a30: 00042403 sra r4,r4,0x10         
00145a34: 080517c9 j 0x00145f24           GOTO END
00145a38: 00000000 nop                   
00145a3c: 1682000d bne r20,r2,0x00145a74 
00145a40: 3402007c ori r2,r0,0x007c       
00145a44: 00131400 sll r2,r19,0x10        {7B}
00145a48: 00028403 sra r16,r2,0x10       
00145a4c: 0c0532a0 jal 0x0014ca80         
00145a50: 00000000 nop                   
00145a54: 3c028017 lui r2,0x8017         
00145a58: 8c42d9b4 lw r2,-0x264c(r2)     
00145a5c: 00000000 nop                   
00145a60: 02021024 and r2,r16,r2         
00145a64: 1040fff9 beq r2,r0,0x00145a4c   
00145a68: 00000000 nop                   
00145a6c: 080517c9 j 0x00145f24           GOTO END
00145a70: 00000000 nop                   
00145a74: 16820005 bne r20,r2,0x00145a8c 
00145a78: 3402004e ori r2,r0,0x004e       
00145a7c: 0c011033 jal 0x000440cc         {7C}
00145a80: 00000000 nop                   
00145a84: 080517c9 j 0x00145f24           GOTO END
00145a88: 00000000 nop                   
00145a8c: 16820013 bne r20,r2,0x00145adc 
00145a90: 34020072 ori r2,r0,0x0072       
00145a94: 00132400 sll r4,r19,0x10        {4E} AddUnit
00145a98: 0c04cc56 jal 0x00133158         
00145a9c: 00042403 sra r4,r4,0x10         
00145aa0: 00021400 sll r2,r2,0x10         
00145aa4: 00022403 sra r4,r2,0x10         
00145aa8: 340807d0 ori r8,r0,0x07d0       
00145aac: 1088011d beq r4,r8,0x00145f24   
00145ab0: 00000000 nop                   
00145ab4: 12c00005 beq r22,r0,0x00145acc 
00145ab8: 00000000 nop                   
00145abc: 0c0230a9 jal 0x0008c2a4         
00145ac0: 00000000 nop                   
00145ac4: 080517c9 j 0x00145f24           GOTO END
00145ac8: 00000000 nop                   
00145acc: 0c02309a jal 0x0008c268         
00145ad0: 00000000 nop                   
00145ad4: 080517c9 j 0x00145f24           GOTO END
00145ad8: 00000000 nop                   
00145adc: 16820005 bne r20,r2,0x00145af4 
00145ae0: 3402007e ori r2,r0,0x007e       
00145ae4: 0c04f961 jal 0x0013e584         {72}
00145ae8: 00000000 nop                   
00145aec: 080517c9 j 0x00145f24           GOTO END
00145af0: 00000000 nop                   
00145af4: 16820005 bne r20,r2,0x00145b0c 
00145af8: 3402007f ori r2,r0,0x007f       
00145afc: 0c0528fe jal 0x0014a3f8         {7E}
00145b00: 02202021 addu r4,r17,r0         
00145b04: 080517c9 j 0x00145f24           GOTO END
00145b08: 00000000 nop                   
00145b0c: 1682000d bne r20,r2,0x00145b44 
00145b10: 34020082 ori r2,r0,0x0082       
00145b14: 00132400 sll r4,r19,0x10        {7F}
00145b18: 0c04cc56 jal 0x00133158         
00145b1c: 00042403 sra r4,r4,0x10         
00145b20: 00021400 sll r2,r2,0x10         
00145b24: 00022403 sra r4,r2,0x10         
00145b28: 340807d0 ori r8,r0,0x07d0       
00145b2c: 108800fd beq r4,r8,0x00145f24   
00145b30: 02c02821 addu r5,r22,r0         
00145b34: 0c0236b0 jal 0x0008dac0         
00145b38: 02e03021 addu r6,r23,r0         
00145b3c: 080517c9 j 0x00145f24           GOTO END
00145b40: 00000000 nop                   
00145b44: 16820005 bne r20,r2,0x00145b5c 
00145b48: 34020083 ori r2,r0,0x0083       
00145b4c: 0c04fa07 jal 0x0013e81c         {82}
00145b50: 00000000 nop                   
00145b54: 080517c9 j 0x00145f24           GOTO END
00145b58: 00000000 nop                   
00145b5c: 16820005 bne r20,r2,0x00145b74 
00145b60: 34020084 ori r2,r0,0x0084       
00145b64: 0c052476 jal 0x001491d8         {83} ChangeStats ?
00145b68: 02202021 addu r4,r17,r0         
00145b6c: 080517c9 j 0x00145f24           GOTO END
00145b70: 00000000 nop                   
00145b74: 16820005 bne r20,r2,0x00145b8c 
00145b78: 34020085 ori r2,r0,0x0085       
00145b7c: 0c010f48 jal 0x00043d20         {84}
00145b80: 02402021 addu r4,r18,r0         
00145b84: 080517c9 j 0x00145f24           GOTO END
00145b88: 00000000 nop                   
00145b8c: 16820014 bne r20,r2,0x00145be0 
00145b90: 34020086 ori r2,r0,0x0086       
00145b94: 0c04ed64 jal 0x0013b590         {85} Date
00145b98: 340401fc ori r4,r0,0x01fc       
00145b9c: 144000e1 bne r2,r0,0x00145f24   
00145ba0: 00000000 nop                   
00145ba4: 124000df beq r18,r0,0x00145f24 
00145ba8: 00000000 nop                   
00145bac: 0c04ed64 jal 0x0013b590         
00145bb0: 3404002e ori r4,r0,0x002e       
00145bb4: 3404002f ori r4,r0,0x002f       
00145bb8: 0c04ed64 jal 0x0013b590         
00145bbc: 00408021 addu r16,r2,r0         
00145bc0: 3c048005 lui r4,0x8005         
00145bc4: 24847cec addiu r4,r4,0x7cec     
00145bc8: 2645ffff addiu r5,r18,0xffff   
00145bcc: 02003021 addu r6,r16,r0         
00145bd0: 0c04f6b9 jal 0x0013dae4         
00145bd4: 00403821 addu r7,r2,r0         
00145bd8: 080517c9 j 0x00145f24           GOTO END
00145bdc: 00000000 nop                   
00145be0: 1682000d bne r20,r2,0x00145c18 
00145be4: 34020087 ori r2,r0,0x0087       
00145be8: 00132400 sll r4,r19,0x10        {86} TempWeapon
00145bec: 0c04cc56 jal 0x00133158         
00145bf0: 00042403 sra r4,r4,0x10         
00145bf4: 00021400 sll r2,r2,0x10         
00145bf8: 00022c03 sra r5,r2,0x10         
00145bfc: 340807d0 ori r8,r0,0x07d0       
00145c00: 10a800c8 beq r5,r8,0x00145f24   
00145c04: 00000000 nop                   
00145c08: 0c0233cf jal 0x0008cf3c         
00145c0c: 02c02021 addu r4,r22,r0         
00145c10: 080517c9 j 0x00145f24           GOTO END
00145c14: 00000000 nop                   
00145c18: 16820026 bne r20,r2,0x00145cb4 
00145c1c: 34020089 ori r2,r0,0x0089       
00145c20: 00132400 sll r4,r19,0x10        {87} Arrow
00145c24: 0c04cc56 jal 0x00133158         
00145c28: 00042403 sra r4,r4,0x10         
00145c2c: 00021400 sll r2,r2,0x10         
00145c30: 00022403 sra r4,r2,0x10         
00145c34: 340807d0 ori r8,r0,0x07d0       
00145c38: 108800ba beq r4,r8,0x00145f24   
00145c3c: 00000000 nop                   
00145c40: 0c023374 jal 0x0008cdd0         
00145c44: 00000000 nop                   
00145c48: 3c048017 lui r4,0x8017         
00145c4c: 8c843ca4 lw r4,0x3ca4(r4)       
00145c50: 00409021 addu r18,r2,r0         
00145c54: 03c42021 addu r4,r30,r4         
00145c58: 0c05181e jal 0x00146078         
00145c5c: 24840003 addiu r4,r4,0x0003     
00145c60: 00021400 sll r2,r2,0x10         
00145c64: 0c04cc56 jal 0x00133158         
00145c68: 00022403 sra r4,r2,0x10         
00145c6c: 00021400 sll r2,r2,0x10         
00145c70: 00022403 sra r4,r2,0x10         
00145c74: 340807d0 ori r8,r0,0x07d0       
00145c78: 108800aa beq r4,r8,0x00145f24   
00145c7c: 00000000 nop                   
00145c80: 0c023374 jal 0x0008cdd0         
00145c84: 00000000 nop                   
00145c88: 3c03801b lui r3,0x801b         
00145c8c: 24630a90 addiu r3,r3,0x0a90     
00145c90: 3c018017 lui r1,0x8017         
00145c94: ac233ca8 sw r3,0x3ca8(r1)       
00145c98: 00402021 addu r4,r2,r0         
00145c9c: 3c058017 lui r5,0x8017         
00145ca0: 24a5e40c addiu r5,r5,0xe40c     
00145ca4: 0c0533ad jal 0x0014ceb4         
00145ca8: 02403021 addu r6,r18,r0         
00145cac: 080517c9 j 0x00145f24           GOTO END
00145cb0: 00000000 nop                   
00145cb4: 16820005 bne r20,r2,0x00145ccc 
00145cb8: 34020088 ori r2,r0,0x0088       
00145cbc: 0c024c46 jal 0x00093118         {89}
00145cc0: 00000000 nop                   
00145cc4: 080517c9 j 0x00145f24           GOTO END
00145cc8: 00000000 nop                   
00145ccc: 16820005 bne r20,r2,0x00145ce4 
00145cd0: 3402008c ori r2,r0,0x008c       
00145cd4: 0c024c51 jal 0x00093144         {88}
00145cd8: 00000000 nop                   
00145cdc: 080517c9 j 0x00145f24           GOTO END
00145ce0: 00000000 nop                   
00145ce4: 16820005 bne r20,r2,0x00145cfc 
00145ce8: 3402008e ori r2,r0,0x008e       
00145cec: 0c051feb jal 0x00147fac         {8C}
00145cf0: 02202021 addu r4,r17,r0         
00145cf4: 080517c9 j 0x00145f24           GOTO END
00145cf8: 00000000 nop                   
00145cfc: 16820012 bne r20,r2,0x00145d48 
00145d00: 3402008f ori r2,r0,0x008f       
00145d04: 0c0532a0 jal 0x0014ca80         {8E}
00145d08: 00000000 nop                   
00145d0c: 0c0532a0 jal 0x0014ca80         
00145d10: 00000000 nop                   
00145d14: 0c05272f jal 0x00149cbc         
00145d18: 3404003d ori r4,r0,0x003d       
00145d1c: 00409021 addu r18,r2,r0         
00145d20: 12400080 beq r18,r0,0x00145f24 
00145d24: 00121280 sll r2,r18,0x0a       
00145d28: 3c018017 lui r1,0x8017         
00145d2c: 00220821 addu r1,r1,r2         
00145d30: 8c229878 lw r2,-0x6788(r1)     
00145d34: 00000000 nop                   
00145d38: 1040fff4 beq r2,r0,0x00145d0c   
00145d3c: 00000000 nop                   
00145d40: 080517c9 j 0x00145f24           GOTO END
00145d44: 00000000 nop                   
00145d48: 16820005 bne r20,r2,0x00145d60 
00145d4c: 34020090 ori r2,r0,0x0090       
00145d50: 3c018016 lui r1,0x8016          {8F}
00145d54: ac326028 sw r18,0x6028(r1)     
00145d58: 080517c9 j 0x00145f24           GOTO END
00145d5c: 00000000 nop                   
00145d60: 16820029 bne r20,r2,0x00145e08 
00145d64: 34020091 ori r2,r0,0x0091       
00145d68: 3c028009 lui r2,0x8009          {90}
00145d6c: 8c4261b4 lw r2,0x61b4(r2)       
00145d70: 00000000 nop                   
00145d74: 1452000e bne r2,r18,0x00145db0 
00145d78: 00000000 nop                   
00145d7c: 3c028009 lui r2,0x8009         
00145d80: 8c4261bc lw r2,0x61bc(r2)       
00145d84: 00000000 nop                   
00145d88: 14550009 bne r2,r21,0x00145db0 
00145d8c: 00000000 nop                   
00145d90: 3c038017 lui r3,0x8017         
00145d94: 8c63d9b4 lw r3,-0x264c(r3)     
00145d98: 00000000 nop                   
00145d9c: 30620020 andi r2,r3,0x0020     
00145da0: 10400003 beq r2,r0,0x00145db0   
00145da4: 3062f000 andi r2,r3,0xf000     
00145da8: 1040005e beq r2,r0,0x00145f24   
00145dac: 00000000 nop                   
00145db0: 0c0532a0 jal 0x0014ca80         
00145db4: 00000000 nop                   
00145db8: 3c028009 lui r2,0x8009         
00145dbc: 8c4261b4 lw r2,0x61b4(r2)       
00145dc0: 00000000 nop                   
00145dc4: 1452fffa bne r2,r18,0x00145db0 
00145dc8: 00000000 nop                   
00145dcc: 3c028009 lui r2,0x8009         
00145dd0: 8c4261bc lw r2,0x61bc(r2)       
00145dd4: 00000000 nop                   
00145dd8: 1455fff5 bne r2,r21,0x00145db0 
00145ddc: 00000000 nop                   
00145de0: 3c038017 lui r3,0x8017         
00145de4: 8c63d9b4 lw r3,-0x264c(r3)     
00145de8: 00000000 nop                   
00145dec: 30620020 andi r2,r3,0x0020     
00145df0: 1040ffef beq r2,r0,0x00145db0   
00145df4: 3062f000 andi r2,r3,0xf000     
00145df8: 1040004a beq r2,r0,0x00145f24   
00145dfc: 00000000 nop                   
00145e00: 0805176c j 0x00145db0           
00145e04: 00000000 nop                   
00145e08: 16820018 bne r20,r2,0x00145e6c 
00145e0c: 34020093 ori r2,r0,0x0093       
00145e10: 0c0526fb jal 0x00149bec         {91} ShowMapTitle
00145e14: 34040010 ori r4,r0,0x0010       
00145e18: 0040b821 addu r23,r2,r0         
00145e1c: 0c04ef05 jal 0x0013bc14         
00145e20: 3404000d ori r4,r0,0x000d       
00145e24: 0c0727b0 jal 0x001c9ec0         
00145e28: 00000000 nop                   
00145e2c: 3c05801d lui r5,0x801d         
00145e30: 24a59d68 addiu r5,r5,0x9d68     
00145e34: 0c053228 jal 0x0014c8a0         
00145e38: 02e02021 addu r4,r23,r0         
00145e3c: 02e02021 addu r4,r23,r0         
00145e40: 00122e00 sll r5,r18,0x18       
00145e44: 00052e03 sra r5,r5,0x18         
00145e48: 00153600 sll r6,r21,0x18       
00145e4c: 00063603 sra r6,r6,0x18         
00145e50: 00163e00 sll r7,r22,0x18       
00145e54: 0c05328e jal 0x0014ca38         
00145e58: 00073e03 sra r7,r7,0x18         
00145e5c: 0c053274 jal 0x0014c9d0         
00145e60: 02e02021 addu r4,r23,r0         
00145e64: 080517c9 j 0x00145f24           GOTO END
00145e68: 00000000 nop                   
00145e6c: 1682000a bne r20,r2,0x00145e98 
00145e70: 34020094 ori r2,r0,0x0094       
00145e74: 0c04ed64 jal 0x0013b590         {93}
00145e78: 340401fc ori r4,r0,0x01fc       
00145e7c: 14400029 bne r2,r0,0x00145f24   
00145e80: 34040054 ori r4,r0,0x0054       
00145e84: 00132c00 sll r5,r19,0x10       
00145e88: 0c04ed91 jal 0x0013b644         
00145e8c: 00052c03 sra r5,r5,0x10         
00145e90: 080517c9 j 0x00145f24           GOTO END
00145e94: 00000000 nop                   
00145e98: 16820007 bne r20,r2,0x00145eb8 
00145e9c: 34020098 ori r2,r0,0x0098       
00145ea0: 00132400 sll r4,r19,0x10        {94} TeleportOut
00145ea4: 00042403 sra r4,r4,0x10         
00145ea8: 0c051ef4 jal 0x00147bd0         
00145eac: 34050001 ori r5,r0,0x0001       
00145eb0: 080517c9 j 0x00145f24           GOTO END
00145eb4: 00000000 nop                   
00145eb8: 16820007 bne r20,r2,0x00145ed8 
00145ebc: 34020092 ori r2,r0,0x0092       
00145ec0: 00132400 sll r4,r19,0x10        {98} TeleportIn
00145ec4: 00042403 sra r4,r4,0x10         
00145ec8: 0c051f2a jal 0x00147ca8         
00145ecc: 34050001 ori r5,r0,0x0001       
00145ed0: 080517c9 j 0x00145f24           GOTO END
00145ed4: 00000000 nop                   
00145ed8: 16820010 bne r20,r2,0x00145f1c 
00145edc: 34020095 ori r2,r0,0x0095       
00145ee0: 0c0526fb jal 0x00149bec         {92} InflictStatus ?
00145ee4: 34040010 ori r4,r0,0x0010       
00145ee8: 00409021 addu r18,r2,r0         
00145eec: 02402021 addu r4,r18,r0         
00145ef0: 3c058015 lui r5,0x8015         
00145ef4: 24a58e88 addiu r5,r5,0x8e88     
00145ef8: 0c053228 jal 0x0014c8a0         
00145efc: 00000000 nop                   
00145f00: 02402021 addu r4,r18,r0         
00145f04: 02202821 addu r5,r17,r0         
00145f08: 00003021 addu r6,r0,r0         
00145f0c: 0c05328e jal 0x0014ca38         
00145f10: 00003821 addu r7,r0,r0         
00145f14: 080517c9 j 0x00145f24           GOTO END
00145f18: 00000000 nop                   
00145f1c: 16820007 bne r20,r2,0x00145f3c 
00145f20: 00000000 nop                   
00145f24: 3c018015 lui r1,0x8015          {95} (END)
00145f28: 00340821 addu r1,r1,r20         
00145f2c: 9023d170 lbu r3,-0x2e90(r1)     
00145f30: 27c20001 addiu r2,r30,0x0001   
00145f34: 08050f43 j 0x00143d0c           
00145f38: 0043f021 addu r30,r2,r3         
00145f3c: 0c053256 jal 0x0014c958         
00145f40: 00000000 nop                   
00145f44: 8fbf004c lw r31,0x004c(r29)     
00145f48: 8fbe0048 lw r30,0x0048(r29)     
00145f4c: 8fb70044 lw r23,0x0044(r29)     
00145f50: 8fb60040 lw r22,0x0040(r29)     
00145f54: 8fb5003c lw r21,0x003c(r29)     
00145f58: 8fb40038 lw r20,0x0038(r29)     
00145f5c: 8fb30034 lw r19,0x0034(r29)     
00145f60: 8fb20030 lw r18,0x0030(r29)     
00145f64: 8fb1002c lw r17,0x002c(r29)     
00145f68: 8fb00028 lw r16,0x0028(r29)     
00145f6c: 27bd0050 addiu r29,r29,0x0050   
00145f70: 03e00008 jr r31                 
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Glain on January 13, 2012, 11:04:07 am
Here's a few battle.bin routines I made notes on while checking out crystal inheriting (The forum seems to hate my formatting).



ROUTINE: FIND UNIT AT SPECIFIED COORDINATES

   PARAMETERS:
      r4 = X-Coordinate
      r5 = Y-Coordinate
      r6 = Is on Upper Level
      r7 = Flags to specify which units to find (Example 0x41 = Crystal and Treasure units)
         0x80 : Chocobo
         0x40 : Crystal
         0x10 : Transparent
         0x01 : Treasure
      
   RETURNS:
      r2    =    -2, If coordinates invalid;
            -1, If no unit found at coordinates with any of the specified flags;
            >=0, If unit found at coordinates with at least one specified flag; Value = [index of unit found]

SECTION 1 : SET UP ROUTINE

0017dca8: 27bdffd0 addiu r29,r29,0xffd0
0017dcac: afb40020 sw r20,0x0020(r29)
0017dcb0: 0080a021 addu r20,r4,r0            #   r20 = r4 (X)
0017dcb4: afb50024 sw r21,0x0024(r29)
0017dcb8: 00a0a821 addu r21,r5,r0            #    r21 = r5 (Y)
0017dcbc: afb60028 sw r22,0x0028(r29)
0017dcc0: 00c0b021 addu r22,r6,r0            #    r22 = r6 (Is on Upper Level)
0017dcc4: afb20018 sw r18,0x0018(r29)   
0017dcc8: 00e09021 addu r18,r7,r0            #    r18 = r7 (Flags)
0017dccc: afbf002c sw r31,0x002c(r29)
0017dcd0: afb3001c sw r19,0x001c(r29)
0017dcd4: afb10014 sw r17,0x0014(r29)

SECTION 2 : INTEGRITY CHECK ON COORDINATES

0017dcd8: 0680002c bltz r20,0x0017dd8c         #    IF (X < 0)
0017dcdc: afb00010 sw r16,0x0010(r29)         #      RETURN -2
0017dce0: 3c03800e lui r3,0x800e
0017dce4: 90634e9c lbu r3,0x4e9c(r3)         #   r3 = [Map MAX X]      
0017dce8: 00000000 nop
0017dcec: 0283102a slt r2,r20,r3            #   IF (X >= [Map MAX X])
0017dcf0: 10400026 beq r2,r0,0x0017dd8c         #      RETURN -2
0017dcf4: 00000000 nop
0017dcf8: 06a0006a bltz r21,0x0017dea4         #   IF (Y < 0)
0017dcfc: 2402fffe addiu r2,r0,0xfffe         #      RETURN -2
0017dd00: 3c02800e lui r2,0x800e
0017dd04: 90424ea0 lbu r2,0x4ea0(r2)         
0017dd08: 00000000 nop
0017dd0c: 02a2102a slt r2,r21,r2            #   IF (Y >= [Map MAX Y])
0017dd10: 1040001e beq r2,r0,0x0017dd8c         #      RETURN -2
0017dd14: 2ec20002 sltiu r2,r22,0x0002         #   IF (r22 >= 2)
0017dd18: 1040001c beq r2,r0,0x0017dd8c         #      RETURN -2
0017dd1c: 02a30018 mult r21,r3               
0017dd20: 00161200 sll r2,r22,0x08            
0017dd24: 00001812 mflo r3                  
0017dd28: 00431021 addu r2,r2,r3
0017dd2c: 00541021 addu r2,r2,r20            
0017dd30: 000210c0 sll r2,r2,0x03
0017dd34: 3c038019 lui r3,0x8019
0017dd38: 2463f8cc addiu r3,r3,0xf8cc
0017dd3c: 00431821 addu r3,r2,r3            #   r3 = [Tile data for current tile specified by (X,Y)]
0017dd40: 90620006 lbu r2,0x0006(r3)
0017dd44: 00000000 nop
0017dd48: 30420003 andi r2,r2,0x0003         #   IF (current tile unselectable and/or cannot target)
0017dd4c: 14400055 bne r2,r0,0x0017dea4         #      RETURN -2
0017dd50: 2402fffe addiu r2,r0,0xfffe
0017dd54: 30e20002 andi r2,r7,0x0002         #   r17 = 0; IF (?) (TRUE for r7=65)
0017dd58: 10400010 beq r2,r0,0x0017dd9c         #      JUMP to [SECTION 3]
0017dd5c: 00008821 addu r17,r0,r0            
0017dd60: 90620003 lbu r2,0x0003(r3)
0017dd64: 00000000 nop
0017dd68: 304200e0 andi r2,r2,0x00e0         #   IF (tile depth >= 2)
0017dd6c: 1440004d bne r2,r0,0x0017dea4         #      RETURN -2
0017dd70: 2402fffe addiu r2,r0,0xfffe
0017dd74: 90620003 lbu r2,0x0003(r3)
0017dd78: 00000000 nop
0017dd7c: 3042001f andi r2,r2,0x001f
0017dd80: 28420003 slti r2,r2,0x0003         #   IF (tile height < 3) ??
0017dd84: 14400006 bne r2,r0,0x0017dda0         #      JUMP to [SECTION 3]
0017dd88: 00009821 addu r19,r0,r0
0017dd8c: 0805f7a9 j 0x0017dea4
0017dd90: 2402fffe addiu r2,r0,0xfffe         #   RETURN -2
0017dd94: 0805f7a9 j 0x0017dea4
0017dd98: 3082001f andi r2,r4,0x001f         #   RETURN r4 (low 5 bits)
0017dd9c: 00009821 addu r19,r0,r0            #   r19 = 0 (Offset to current unit in loop)

# SECTION 3 : LOOP THROUGH IN-BATTLE UNITS

#   SECTION 3.0 : START OF LOOP : BEGIN FLAG CHECKS : CRYSTAL=0x40

0017dda0: 3c028019 lui r2,0x8019            #    DO {
0017dda4: 244208cc addiu r2,r2,0x08cc         #      
0017dda8: 02628021 addu r16,r19,r2            #      r16 = [Current unit in loop]
0017ddac: 92030001 lbu r3,0x0001(r16)
0017ddb0: 340200ff ori r2,r0,0x00ff
0017ddb4: 10620036 beq r3,r2,0x0017de90         #       IF (current unit doesn't exist)
0017ddb8: 32420051 andi r2,r18,0x0051         #         CONTINUE
0017ddbc: 10400018 beq r2,r0,0x0017de20         #      (Check r18 = fourth parameter) : bits 0x40, 0x10, 0x01
0017ddc0: 32420040 andi r2,r18,0x0040         #      IF (Checked bits) == 0
0017ddc4: 10400007 beq r2,r0,0x0017dde4         #         r2 = (Check r18 bit 0x01); JUMP to [SECTION 3.1]
0017ddc8: 32420001 andi r2,r18,0x0001         
0017ddcc: 92020058 lbu r2,0x0058(r16)         
0017ddd0: 00000000 nop
0017ddd4: 30420040 andi r2,r2,0x0040         #      IF (current unit is crystal)
0017ddd8: 14400012 bne r2,r0,0x0017de24         #         r2 = (Check r18 bit 0x80); JUMP TO [SECTION 3.3]
0017dddc: 32420080 andi r2,r18,0x0080
0017dde0: 32420001 andi r2,r18,0x0001         #      r2 = (Check r18 bit 0x01)

#   SECTION 3.1 : FLAG CHECKS SUBSECTION 1 : TREASURE=0x01

0017dde4: 10400007 beq r2,r0,0x0017de04         #      IF (Check r18 bit 0x01) == 0
0017dde8: 32420010 andi r2,r18,0x0010         #         r2 = (Check r18 bit 0x10); JUMP to [SECTION 3.2]
0017ddec: 92020059 lbu r2,0x0059(r16)
0017ddf0: 00000000 nop
0017ddf4: 30420001 andi r2,r2,0x0001         #      IF (current unit is treasure)
0017ddf8: 1440000a bne r2,r0,0x0017de24         #         r2 = (Check r18 bit 0x80); JUMP to [SECTION 3.3]
0017ddfc: 32420080 andi r2,r18,0x0080
0017de00: 32420010 andi r2,r18,0x0010         #      r2 = (Check r18 bit 0x10)

#   SECTION 3.2 : FLAG CHECKS SUBSECTION 2 : TRANSPARENT=0x10

0017de04: 10400022 beq r2,r0,0x0017de90         #      IF (Check r18 bit 0x10) == 0
0017de08: 00000000 nop                     #         CONTINUE
0017de0c: 9202005a lbu r2,0x005a(r16)               
0017de10: 00000000 nop
0017de14: 30420010 andi r2,r2,0x0010
0017de18: 1040001d beq r2,r0,0x0017de90         #       IF (current unit is not transparent)
0017de1c: 00000000 nop                     #         CONTINUE
0017de20: 32420080 andi r2,r18,0x0080         #      r2 = (Check r18 bit 0x80)

#   SECTION 3.3 : FLAG CHECKS SUBSECTION 3 : CHOCOBO=0x80

0017de24: 10400005 beq r2,r0,0x0017de3c         #       IF (Check r18 bit 0x80) == 0
0017de28: 00000000 nop                     #         JUMP to [SECTION 3.4]
0017de2c: 0c05d0f2 jal 0x001743c8            #      Routine: Chocobo check? (r4 = current unit pointer)
0017de30: 02002021 addu r4,r16,r0
0017de34: 10400016 beq r2,r0,0x0017de90         #      IF (Chocobo check result == 0)
0017de38: 00000000 nop                     #         CONTINUE

#   SECTION 3.4 : UNIT CHECKS

0017de3c: 92020047 lbu r2,0x0047(r16)
0017de40: 00000000 nop
0017de44: 14540012 bne r2,r20,0x0017de90      #      IF (current unit X-coord != X)
0017de48: 00000000 nop                     #         CONTINUE
0017de4c: 92020048 lbu r2,0x0048(r16)         
0017de50: 00000000 nop
0017de54: 1455000e bne r2,r21,0x0017de90      #      IF (current unit Y-coord != Y)
0017de58: 00000000 nop                     #         CONTINUE
0017de5c: 96020048 lhu r2,0x0048(r16)
0017de60: 00000000 nop
0017de64: 000213c2 srl r2,r2,0x0f            #      IF (current unit IsOnUpperLevel != IsOnUpperLevel)
0017de68: 14560009 bne r2,r22,0x0017de90      #         CONTINUE
0017de6c: 00000000 nop
0017de70: 92040182 lbu r4,0x0182(r16)
0017de74: 00000000 nop
0017de78: 308200ff andi r2,r4,0x00ff
0017de7c: 2c420080 sltiu r2,r2,0x0080         #      IF (current unit is riding a unit?)
0017de80: 1040ffc4 beq r2,r0,0x0017dd94         #         RETURN (??)
0017de84: 02201021 addu r2,r17,r0            #       
0017de88: 0805f7a9 j 0x0017dea4               #      RETURN (current unit index)
0017de8c: 00000000 nop

#    SECTION 3.5 : END OF LOOP

0017de90: 26310001 addiu r17,r17,0x0001
0017de94: 2a220015 slti r2,r17,0x0015
0017de98: 1440ffc1 bne r2,r0,0x0017dda0         #    } WHILE (r17 (current unit index) < 21)
0017de9c: 267301c0 addiu r19,r19,0x01c0
0017dea0: 2402ffff addiu r2,r0,0xffff         #   r2 (Return result) = -1 (No unit found)

# SECTION 4 : RETURN r2

0017dea4: 8fbf002c lw r31,0x002c(r29)
0017dea8: 8fb60028 lw r22,0x0028(r29)
0017deac: 8fb50024 lw r21,0x0024(r29)
0017deb0: 8fb40020 lw r20,0x0020(r29)
0017deb4: 8fb3001c lw r19,0x001c(r29)
0017deb8: 8fb20018 lw r18,0x0018(r29)
0017debc: 8fb10014 lw r17,0x0014(r29)
0017dec0: 8fb00010 lw r16,0x0010(r29)
0017dec4: 27bd0030 addiu r29,r29,0x0030
0017dec8: 03e00008 jr r31
0017decc: 00000000 nop




ROUTINE : GENERATE CRYSTAL/TREASURE

   PARAMETERS:
      r4 = [In-battle unit index of moving unit]
      
   RETURNS:
      r2               =   0x8006623c (Pointer);
      MEMORY[0x8006623c]    =    -1, If no crystal/treasure unit found; 0, If no abilities to inherit from a crystal; 1, Otherwise;
      MEMORY[0x80066254]   =    [Crystal abilities: List of flags by skillset (1-8,9-16,17-24) for which ability slots are contained in crystal];
      MEMORY[0x8006628d]    =    [In-battle unit index of unit found], if a unit was found;
      MEMORY[0x8006628e]    =    [Treasure item ID], if unit is obtaining treasure; 2, Otherwise;
      MEMORY[0x8006628f]    =    ?

# SECTION 1 : SET UP ROUTINE

00180530: 27bdff70 addiu r29,r29,0xff70
00180534: afb20070 sw r18,0x0070(r29)
00180538: 00809021 addu r18,r4,r0         #    r18 = (Moving unit)
0018053c: 34070041 ori r7,r0,0x0041         #    r7 = 0x41 = (Flags for find-unit-at-coords routine: Crystal, Treasure)
00180540: afbf008c sw r31,0x008c(r29)
00180544: afbe0088 sw r30,0x0088(r29)
00180548: afb70084 sw r23,0x0084(r29)
0018054c: afb60080 sw r22,0x0080(r29)
00180550: afb5007c sw r21,0x007c(r29)
00180554: afb40078 sw r20,0x0078(r29)
00180558: afb30074 sw r19,0x0074(r29)
0018055c: afb1006c sw r17,0x006c(r29)
00180560: afb00068 sw r16,0x0068(r29)

# SECTION 2 : FIND APPROPRIATE UNIT, BEGIN LIST?

00180564: 92440047 lbu r4,0x0047(r18)      #    Load in coordinates (X,Y,IsOnUpperLevel) of moving unit
00180568: 96460048 lhu r6,0x0048(r18)
0018056c: 92450048 lbu r5,0x0048(r18)
00180570: 0c05f72a jal 0x0017dca8         #    Routine: Find unit at coordinates (Flags: Crystal, Treasure)
00180574: 000633c2 srl r6,r6,0x0f         
00180578: 00401821 addu r3,r2,r0         #    r3 = r2 (Index of unit found)
0018057c: 04610006 bgez r3,0x00180598      #    IF (No unit found) {
00180580: 000310c0 sll r2,r3,0x03
00180584: 3c028006 lui r2,0x8006
00180588: 2442623c addiu r2,r2,0x623c
0018058c: 2403ffff addiu r3,r0,0xffff            MEM[0x06623c] = -1 (Code for empty?)
00180590: 08060234 j 0x001808d0                  RETURN 0x8006623c
00180594: ac430000 sw r3,0x0000(r2)         #   }
00180598: 3c118006 lui r17,0x8006
0018059c: 2631623c addiu r17,r17,0x623c      #    r17 = 0x8006623c
001805a0: 00431023 subu r2,r2,r3
001805a4: 00021180 sll r2,r2,0x06
001805a8: ae200000 sw r0,0x0000(r17)      #    MEM[0x06623c] = 0
001805ac: 3c018006 lui r1,0x8006
001805b0: a023628d sb r3,0x628d(r1)         #    MEM[0x06628d] = [Coordinate routine result?]
001805b4: 3c038019 lui r3,0x8019
001805b8: 246308cc addiu r3,r3,0x08cc      
001805bc: 00438021 addu r16,r2,r3         #    r16 = (Found unit)
001805c0: 92020059 lbu r2,0x0059(r16)   
001805c4: 00000000 nop
001805c8: 30420001 andi r2,r2,0x0001      
001805cc: 10400008 beq r2,r0,0x001805f0      #    IF (Found unit is treasure status) {
001805d0: 02002021 addu r4,r16,r0
001805d4: 34020004 ori r2,r0,0x0004
001805d8: 0c060282 jal 0x00180a08               Routine: Generate treasure from treasure unit
001805dc: ae220000 sw r2,0x0000(r17)
001805e0: 3c018006 lui r1,0x8006
001805e4: a022628e sb r2,0x628e(r1)               MEM[0x6628e] = [Routine result]
001805e8: 08060232 j 0x001808c8                  RETURN 0x8006623c
001805ec: 00000000 nop                  #   }
001805f0: 34020002 ori r2,r0,0x0002
001805f4: ae220000 sw r2,0x0000(r17)      #    MEM[0x6628e] = 2
001805f8: 924b0006 lbu r11,0x0006(r18)      
001805fc: 00000000 nop
00180600: 31620020 andi r2,r11,0x0020
00180604: afab0040 sw r11,0x0040(r29)      #    STACK[0x40] = [Gender/monster flags of moving unit]
00180608: 92030006 lbu r3,0x0006(r16)
0018060c: 144000ae bne r2,r0,0x001808c8      #    IF (Moving unit or found unit is monster), RETURN 0x8006623c
00180610: 30620020 andi r2,r3,0x0020
00180614: 144000ac bne r2,r0,0x001808c8
00180618: 00000000 nop
0018061c: 26240053 addiu r4,r17,0x0053      #    r4 = 0x800662e1
00180620: 34050040 ori r5,r0,0x0040         #    r5 = 0x40 (64)
00180624: 27aa0010 addiu r10,r29,0x0010
00180628: 27ab0018 addiu r11,r29,0x0018
0018062c: 0240b021 addu r22,r18,r0         #    r22 = (Moving unit)
00180630: afa00028 sw r0,0x0028(r29)      #    STACK[0x28] = 0      
00180634: afaa0058 sw r10,0x0058(r29)      #    STACK[0x58] = (Pointer to stack) + 0x10
00180638: afab0050 sw r11,0x0050(r29)      #    STACK[0x50] = (Pointer to stack) + 0x18
0018063c: afb00060 sw r16,0x0060(r29)      #    STACK[0x60] = (Found unit)
00180640: 92c20096 lbu r2,0x0096(r22)      #    r2 = [Moving unit jobs unlocked 1]   
00180644: 92c30097 lbu r3,0x0097(r22)      #    r3 = [Moving unit jobs unlocked 2]
00180648: 92c60098 lbu r6,0x0098(r22)      #    r6 = [Moving unit jobs unlocked 3]
0018064c: 00021400 sll r2,r2,0x10
00180650: 00031a00 sll r3,r3,0x08
00180654: 00431021 addu r2,r2,r3
00180658: 00461021 addu r2,r2,r6
0018065c: afa20048 sw r2,0x0048(r29)      #    STACK[0x48] = [Moving unit unlocked job info]
00180660: 92ca0000 lbu r10,0x0000(r22)      #    r10 = [Moving unit base job]
00180664: 0000a821 addu r21,r0,r0         #    r21 = 0
00180668: afaa0030 sw r10,0x0030(r29)      #    STACK[0x30] = [Moving unit base job]
0018066c: 920b0000 lbu r11,0x0000(r16)      #    r11 = [Found unit base job]
00180670: 26370018 addiu r23,r17,0x0018      #    r23 = 0x66254 (Starting list position?)
00180674: 0c017991 jal 0x0005e644         #    Routine: Clear (zero out) array (pointer=0x6628F, size=0x40=64)
00180678: afab0038 sw r11,0x0038(r29)      #    STACK[0x38] = [Found unit base job]

SECTION 3 : START OF LOOP

0018067c: 27a40020 addiu r4,r29,0x0020      #   DO {
00180680: 26c60099 addiu r6,r22,0x0099      #       r6 = [Moving unit's action abilities for current class]
00180684: 02e01821 addu r3,r23,r0         #       r3 = [list position]
00180688: 27a90023 addiu r9,r29,0x0023
0018068c: 8faa0060 lw r10,0x0060(r29)      #       r10 = [Found unit]
00180690: 8fa70050 lw r7,0x0050(r29)      #       r7 = (Pointer to stack) + 0x18
00180694: 8fa50058 lw r5,0x0058(r29)      #       r5 = (Pointer to stack) + 0x10
00180698: 25480099 addiu r8,r10,0x0099      #       r8 = [Found unit's action abilities for current class]

SECTION 4 : LOOP THROUGH BASE ACTION ABILITIES

0018069c: a0600000 sb r0,0x0000(r3)         #       FOR (i=1; i < 3; i++) {
001806a0: a0a00000 sb r0,0x0000(r5)         #          MEM[r3] = 0; STACK[r5] = 0
001806a4: 90c20000 lbu r2,0x0000(r6)      #          r2 = (i-th Moving unit base action abilities)
001806a8: 24c60001 addiu r6,r6,0x0001      #          r6++
001806ac: 24a50001 addiu r5,r5,0x0001      #          r5++
001806b0: 24630001 addiu r3,r3,0x0001      #          r3++
001806b4: a0e20000 sb r2,0x0000(r7)         #          STACK[r7] = (i-th Moving unit base action abilities)
001806b8: 91020000 lbu r2,0x0000(r8)      #          r2 = (i-th Found unit base action abilities)
001806bc: 25080001 addiu r8,r8,0x0001      #          r8++
001806c0: a0820000 sb r2,0x0000(r4)         #          STACK[r4] = (i-th Found unit base action abilities)
001806c4: 24840001 addiu r4,r4,0x0001      #          r4++; r7++
001806c8: 0089102a slt r2,r4,r9            #       }
001806cc: 1440fff3 bne r2,r0,0x0018069c
001806d0: 24e70001 addiu r7,r7,0x0001      

SECTION 5 : BASE JOB CHECK

                                 #       r3 = r21 + 0x4A (NOTE: Start of generic jobs? Job 0x4A = Squire)
001806d4: 16a0000b bne r21,r0,0x00180704   #       IF (r21 != 0)
001806d8: 26a3004a addiu r3,r21,0x004a      #         JUMP to [SECTION 6]
001806dc: 8fab0030 lw r11,0x0030(r29)      #       r11 = [Moving unit base job]
001806e0: 8faa0038 lw r10,0x0038(r29)      #       r10 = [Found unit base job]
001806e4: 00000000 nop                  #       IF (r11 != r10)
001806e8: 156a0065 bne r11,r10,0x00180880   #         JUMP to [SECTION 14]
001806ec: 29620080 slti r2,r11,0x0080      #       IF (r11 >= 0x80)
001806f0: 1040000a beq r2,r0,0x0018071c      #         JUMP to [SECTION 7]
001806f4: 34020011 ori r2,r0,0x0011
001806f8: 8fa30030 lw r3,0x0030(r29)      #       r3 = [Moving unit base job]
001806fc: 080601c7 j 0x0018071c            #       JUMP to [SECTION 7]
00180700: 00000000 nop

SECTION 6 : JOB UNLOCKED CHECK

00180704: 3c020080 lui r2,0x0080
00180708: 8fab0048 lw r11,0x0048(r29)      #       r11 = [Moving unit unlocked job info]
0018070c: 02a21007 srav r2,r2,r21
00180710: 01621024 and r2,r11,r2         #       IF (Moving unit doesn't have this job unlocked)
00180714: 1040005a beq r2,r0,0x00180880      #         Jump to [SECTION 14]
00180718: 34020011 ori r2,r0,0x0011

SECTION 7 : BARD CHECK

0018071c: 16a20006 bne r21,r2,0x00180738   #       IF (r21 != 0x11 (BARD))
00180720: 34020012 ori r2,r0,0x0012         #         Jump to [SECTION 8]
00180724: 8faa0040 lw r10,0x0040(r29)      #       r10 = [Gender/monster flags of moving unit]
00180728: 00000000 nop
0018072c: 31420040 andi r2,r10,0x0040      
00180730: 14400053 bne r2,r0,0x00180880      #       IF (Moving unit is female)
00180734: 34020012 ori r2,r0,0x0012         #         JUMP to [SECTION 14]

SECTION 8 : DANCER CHECK

                                 #       r17 = 0 (NULL?)
00180738: 16a20006 bne r21,r2,0x00180754   #       IF (r21 != 0x12 (DANCER))
0018073c: 00008821 addu r17,r0,r0         #         Jump to [SECTION 9]
00180740: 8fab0040 lw r11,0x0040(r29)      #       r11 = [Gender/monster flags of moving unit]
00180744: 00000000 nop
00180748: 31620080 andi r2,r11,0x0080      #       IF (Moving unit is male)
0018074c: 1440004c bne r2,r0,0x00180880      #         JUMP to [SECTION 14]
00180750: 00000000 nop

SECTION 9 : FIND SKILLSET ID

00180754: 00031040 sll r2,r3,0x01
00180758: 00431021 addu r2,r2,r3
0018075c: 3c038006 lui r3,0x8006
00180760: 8c636194 lw r3,0x6194(r3)         
00180764: 00021100 sll r2,r2,0x04
00180768: 00431021 addu r2,r2,r3         
0018076c: 905e0000 lbu r30,0x0000(r2)      #       r30 = [Skillset ID of current job]      

SECTION 10 : BEGIN INNER LOOP : LOOP THROUGH ABILITIES OF SKILLSET?

00180770: 06210002 bgez r17,0x0018077c      #      DO
00180774: 02201821 addu r3,r17,r0         #      {
00180778: 26230007 addiu r3,r17,0x0007      #          r3 = [Ability index]   NOTE: Calculation is: r3 =(r17 >= 0) ? r17 : (r17 + 7)

SECTION 11

0018077c: 000390c3 sra r18,r3,0x03
00180780: 001218c0 sll r3,r18,0x03
00180784: 02231823 subu r3,r17,r3         #         r3 = Offset?
00180788: 8faa0050 lw r10,0x0050(r29)      #         r10 = (Pointer to stack) + 0x18
0018078c: 34040080 ori r4,r0,0x0080         #         r4 = 0x80
00180790: 01521021 addu r2,r10,r18         #         r2 = Offset?
00180794: 90420000 lbu r2,0x0000(r2)      #         r2 = STACK[0x18+r18]
00180798: 00649807 srav r19,r4,r3
0018079c: 00531024 and r2,r2,r19         #         r2 = (Stack pointer offset?); IF (???)
001807a0: 14400029 bne r2,r0,0x00180848      #            JUMP to [SECTION 12]
001807a4: 03b21021 addu r2,r29,r18               
001807a8: 90420020 lbu r2,0x0020(r2)      #         r2 = MEM[r2+0x20]
001807ac: 00000000 nop
001807b0: 00531024 and r2,r2,r19         #         r2 = Offset?
001807b4: 10400024 beq r2,r0,0x00180848      #         IF (???)
001807b8: 03c02021 addu r4,r30,r0         #            Jump to [SECTION 12]
001807bc: 0c01695a jal 0x0005a568         #         Routine : Get Ability ID (r4=[Skillset ID]; r5=[Ability index])
001807c0: 02202821 addu r5,r17,r0
001807c4: 0040a021 addu r20,r2,r0         
001807c8: 3290ffff andi r16,r20,0xffff      #         r16 = (Routine result)
001807cc: 1200001e beq r16,r0,0x00180848   #         IF (r16 == 0) JUMP to [SECTION 12]
001807d0: 001010c0 sll r2,r16,0x03         #         
001807d4: 3c018006 lui r1,0x8006
001807d8: 00220821 addu r1,r1,r2         
001807dc: 9025ebf2 lbu r5,-0x140e(r1)      #         r5 = (Ability's Chance to Learn?)
001807e0: 0c017833 jal 0x0005e0cc         #          Routine: Pass/Fail Roll (Possibilities=100, Threshold=r5)
001807e4: 34040064 ori r4,r0,0x0064
001807e8: 14400017 bne r2,r0,0x00180848      #         IF (Roll was a Fail)
001807ec: 00000000 nop                  #            JUMP to [SECTION 12]
001807f0: 8fab0058 lw r11,0x0058(r29)      #         r11 = (Pointer to stack) + 0x10
001807f4: 00000000 nop
001807f8: 01721021 addu r2,r11,r18         #         r2 = Offset?
001807fc: 8faa0028 lw r10,0x0028(r29)      #         
00180800: 90430000 lbu r3,0x0000(r2)      #         r3 = MEM[r2]
00180804: 254a0001 addiu r10,r10,0x0001      #         
00180808: 02631825 or r3,r19,r3            #         r3 = ?
0018080c: afaa0028 sw r10,0x0028(r29)      #         STACK[0x28]++
00180810: a0430000 sb r3,0x0000(r2)         #         MEM[r2] = r3
00180814: 2e020200 sltiu r2,r16,0x0200      #         IF (r16 >= 0x200)
00180818: 1040000b beq r2,r0,0x00180848      #            JUMP to [SECTION 12]
0018081c: 001020c2 srl r4,r16,0x03
00180820: 32850007 andi r5,r20,0x0007      #         r5 = r20 + 7
00180824: 34020001 ori r2,r0,0x0001         #         r2 = 1
00180828: 3c018006 lui r1,0x8006
0018082c: 00240821 addu r1,r1,r4
00180830: 9023628f lbu r3,0x628f(r1)      #         r3 = (Element of list)
00180834: 00a21004 sllv r2,r2,r5
00180838: 00431025 or r2,r2,r3
0018083c: 3c018006 lui r1,0x8006
00180840: 00240821 addu r1,r1,r4
00180844: a022628f sb r2,0x628f(r1)         #         (Save new element to list)

SECTION 12 : END OF INNER LOOP

00180848: 26310001 addiu r17,r17,0x0001
0018084c: 2a220018 slti r2,r17,0x0018
00180850: 1440ffc7 bne r2,r0,0x00180770      #      } WHILE (r17 < 0x18)
00180854: 26e50003 addiu r5,r23,0x0003
00180858: 02e01821 addu r3,r23,r0
0018085c: 8fa40058 lw r4,0x0058(r29)   

SECTION 13 : WRITE ELEMENTS TO LIST
      
00180860: 00000000 nop                  #      DO {
00180864: 90820000 lbu r2,0x0000(r4)      
00180868: 00000000 nop
0018086c: a0620000 sb r2,0x0000(r3)         #         LIST[r23 + i] = STACK[0x10 + i]
00180870: 24630001 addiu r3,r3,0x0001      #         r3++; r4++
00180874: 0065102a slt r2,r3,r5            
00180878: 1440fff9 bne r2,r0,0x00180860      #      } WHILE (r3 < r5)
0018087c: 24840001 addiu r4,r4,0x0001

SECTION 14 : END OF OUTER LOOP : INCREMENT APPROPRIATE COUNTERS/VARIABLES

00180880: 26f70003 addiu r23,r23,0x0003      #       r23 += 3            NOTE: r23 = (Position in list?)
00180884: 26d60003 addiu r22,r22,0x0003      #       r22 += 3            NOTE: r22 = [Moving unit offset]
00180888: 26b50001 addiu r21,r21,0x0001      #       r21++                NOTE: r21 = (Current job ID) - 0x4A (Loop counter)
0018088c: 8fab0060 lw r11,0x0060(r29)      
00180890: 2aa20013 slti r2,r21,0x0013      #       STACK[0x60] += 3      NOTE: STACK[0x60] = [Found unit offset]
00180894: 256b0003 addiu r11,r11,0x0003   
00180898: 1440ff78 bne r2,r0,0x0018067c      #    } WHILE (r21 < 0x13)
0018089c: afab0060 sw r11,0x0060(r29)

SECTION 15

001808a0: 8faa0028 lw r10,0x0028(r29)
001808a4: 00000000 nop
001808a8: 11400007 beq r10,r0,0x001808c8   #    IF (STACK[0x28] == 0)
001808ac: 00000000 nop                  #      RETURN 0x8006623c
001808b0: 3c038006 lui r3,0x8006
001808b4: 2463623c addiu r3,r3,0x623c
001808b8: 8c620000 lw r2,0x0000(r3)
001808bc: 00000000 nop
001808c0: 34420001 ori r2,r2,0x0001
001808c4: ac620000 sw r2,0x0000(r3)         #   MEM[0x6623c]++

SECTION 16 : RETURN 0x8006623c (Pointer to list?)

001808c8: 3c028006 lui r2,0x8006
001808cc: 2442623c addiu r2,r2,0x623c      #   RETURN 0x8006623c
001808d0: 8fbf008c lw r31,0x008c(r29)
001808d4: 8fbe0088 lw r30,0x0088(r29)
001808d8: 8fb70084 lw r23,0x0084(r29)
001808dc: 8fb60080 lw r22,0x0080(r29)
001808e0: 8fb5007c lw r21,0x007c(r29)
001808e4: 8fb40078 lw r20,0x0078(r29)
001808e8: 8fb30074 lw r19,0x0074(r29)
001808ec: 8fb20070 lw r18,0x0070(r29)
001808f0: 8fb1006c lw r17,0x006c(r29)
001808f4: 8fb00068 lw r16,0x0068(r29)
001808f8: 27bd0090 addiu r29,r29,0x0090
001808fc: 03e00008 jr r31
00180900: 00000000 nop




ROUTINE : CHOCOBO CHECK

   PARAMETERS:
      r4 = Unit
   
   RETURNS:
      r2   =   0, If proper statuses not found and/or unit is not a chocobo
            1, If unit is a chocobo with proper status and riding check was not passed
            2, If unit is a chocobo with proper status and riding check was passed

SECTION 1 : SET UP ROUTINE AND CALL OTHER ROUTINE

001743c8: 27bdffe8 addiu r29,r29,0xffe8
001743cc: afb00010 sw r16,0x0010(r29)
001743d0: 00808021 addu r16,r4,r0
001743d4: afbf0014 sw r31,0x0014(r29)
001743d8: 92020003 lbu r2,0x0003(r16)         #   r2 = [Current job ID of unit]
001743dc: 00000000 nop
001743e0: 2442ffa2 addiu r2,r2,0xffa2         #   r2 = r2 - 0x5E (94)
001743e4: 2c420003 sltiu r2,r2,0x0003         #   IF (Unit is not a chocobo)   Note: Condition is (UNSIGNED r2 < 3); can only happen for jobs 0x5E - 0x60
001743e8: 10400005 beq r2,r0,0x00174400         #      RETURN 0
001743ec: 02002021 addu r4,r16,r0         
001743f0: 0c01786c jal 0x0005e1b0            #   Routine: Check status flags (r4 = current unit, r5 = 10)
001743f4: 3405000a ori r5,r0,0x000a            
001743f8: 10400003 beq r2,r0,0x00174408         #   IF (Routine result == 0)
001743fc: 00000000 nop                     #      JUMP to [SECTION 2]
00174400: 0805d107 j 0x0017441c               #   RETURN 0
00174404: 00001021 addu r2,r0,r0

SECTION 2 : CHECK RIDDEN UNIT

00174408: 92030182 lbu r3,0x0182(r16)
0017440c: 00000000 nop
00174410: 14600002 bne r3,r0,0x0017441c         #   IF (Something to do with riding?)
00174414: 34020002 ori r2,r0,0x0002            #      RETURN 2
00174418: 34020001 ori r2,r0,0x0001            #    RETURN 1

SECTION 3 : RETURN r2

0017441c: 8fbf0014 lw r31,0x0014(r29)
00174420: 8fb00010 lw r16,0x0010(r29)
00174424: 27bd0018 addiu r29,r29,0x0018
00174428: 03e00008 jr r31
0017442c: 00000000 nop




ROUTINE : GENERATE TREASURE FOR TREASURE CHEST

   PARAMETERS:
      r4    =   [Treasure unit]
      
   RETURNS:
      r2   =   [Item]

SECTION 1 : SET UP
      
00180a08: 3c028019 lui r2,0x8019
00180a0c: 8c42f5fc lw r2,-0x0a04(r2)            #   r2 = MEM[0x18f5fc]
00180a10: 27bdffe0 addiu r29,r29,0xffe0
00180a14: afbf001c sw r31,0x001c(r29)            #   IF (r2 != 0)
00180a18: 14400033 bne r2,r0,0x00180ae8            #      RETURN r2
00180a1c: afb00018 sw r16,0x0018(r29)
00180a20: 00008021 addu r16,r0,r0               #   r16 = 0   [Count of valid items]
00180a24: 00003021 addu r6,r0,r0               #   r6 = 0    [Current equipment slot index]
00180a28: 27a50010 addiu r5,r29,0x0010            #   r5 =    [Valid item array pointer]

SECTION 2 : FIND VALID ITEMS ON TREASURE UNIT (EQUIPMENT)

                                       #   DO {
00180a2c: 00861021 addu r2,r4,r6               #      
00180a30: 9042001a lbu r2,0x001a(r2)            #      r2 = MEM[r4+r6+0x1a) [Equip] (Equipment in current slot of treasure unit)
00180a34: 00000000 nop
00180a38: a0a20000 sb r2,0x0000(r5)               #      ValidItems[i-th] (MEM[r5]) = [Equip]
00180a3c: 90a30000 lbu r3,0x0000(r5)
00180a40: 00000000 nop                        #      r6++ (LoopCount++)
00180a44: 2c6200fe sltiu r2,r3,0x00fe            #      IF ([Equip] >= 0xFE) (empty)
00180a48: 10400005 beq r2,r0,0x00180a60            #         CONTINUE (skip this item)
00180a4c: 24c60001 addiu r6,r6,0x0001
00180a50: 10600004 beq r3,r0,0x00180a64            #      IF ([Equip] == 0x00)
00180a54: 28c20007 slti r2,r6,0x0007            #         CONTINUE (skip this item)
00180a58: 24a50001 addiu r5,r5,0x0001            #      r5++
00180a5c: 26100001 addiu r16,r16,0x0001            #      r16++ (ValidItemCount++)
00180a60: 28c20007 slti r2,r6,0x0007
00180a64: 1440fff1 bne r2,r0,0x00180a2c            #   } WHILE (r6 < 7)
00180a68: 00000000 nop

SECTION 3 : NO VALID ITEMS : FIND USABLE ITEM? (POTION, ETC?)

00180a6c: 16000014 bne r16,r0,0x00180ac0         #   IF ([Valid item count] = 0)
00180a70: 00000000 nop                        #   {   
00180a74: 0c0088c3 jal 0x0002230c               #       r2 = [Random number]
00180a78: 00000000 nop
00180a7c: 00021840 sll r3,r2,0x01
00180a80: 00621821 addu r3,r3,r2
00180a84: 00031880 sll r3,r3,0x02
00180a88: 00621021 addu r2,r3,r2               
00180a8c: 04410002 bgez r2,0x00180a98            
00180a90: 00000000 nop                        
00180a94: 24427fff addiu r2,r2,0x7fff            
00180a98: 000213c3 sra r2,r2,0x0f               
00180a9c: 2442fff0 addiu r2,r2,0xfff0            #      r2 = [Random usable item]
00180aa0: a3a20010 sb r2,0x0010(r29)            #      ValidItems[0] (STACK[0x10]) = r2
00180aa4: 93a30010 lbu r3,0x0010(r29)            #      r3 = r2
00180aa8: 00000000 nop                        #      IF (r3 >= 0xf5) (We found a usable item?)
00180aac: 2c6200f5 sltiu r2,r3,0x00f5            #      {   
00180ab0: 14400003 bne r2,r0,0x00180ac0            #         ValidItemCount (r16) = 1
00180ab4: 34100001 ori r16,r0,0x0001            #         r2 = r3 + 1
00180ab8: 24620001 addiu r2,r3,0x0001            #         ValidItems[0] = r2
00180abc: a3a20010 sb r2,0x0010(r29)            #      }

SECTION 4 : RETURN RANDOM ITEM FROM VALID ITEMS LIST

00180ac0: 0c0088c3 jal 0x0002230c               #    r2 = [Random number]
00180ac4: 00000000 nop
00180ac8: 00500018 mult r2,r16
00180acc: 00001012 mflo r2                     #   r2 = [Random index]
00180ad0: 04410003 bgez r2,0x00180ae0
00180ad4: 000233c3 sra r6,r2,0x0f
00180ad8: 24427fff addiu r2,r2,0x7fff
00180adc: 000233c3 sra r6,r2,0x0f
00180ae0: 03a61021 addu r2,r29,r6               
00180ae4: 90420010 lbu r2,0x0010(r2)            #   r2 = ValidItems[RandomIndex]
00180ae8: 8fbf001c lw r31,0x001c(r29)
00180aec: 8fb00018 lw r16,0x0018(r29)
00180af0: 27bd0020 addiu r29,r29,0x0020
00180af4: 03e00008 jr r31                     #   RETURN r2
00180af8: 00000000 nop




#    ROUTINE : LEARN FROM CRYSTAL ?

#      PARAMETERS:
#         r4 = [In-battle unit pointer]
#         r5 = ?

#      RETURNS:
#         r2   =   0?

#    SECTION 1 : CHECKS AND SET UP

00180904: 27bdffe0 addiu r29,r29,0xffe0
00180908: afb00010 sw r16,0x0010(r29)
0018090c: 00808021 addu r16,r4,r0               #   r16 = r4
00180910: afb10014 sw r17,0x0014(r29)
00180914: 00a08821 addu r17,r5,r0               #   r17 = r5
00180918: afbf0018 sw r31,0x0018(r29)
0018091c: 0c062f5d jal 0x0018bd74               #   Routine: clear some temp in-battle unit data?
00180920: 2604018c addiu r4,r16,0x018c   
00180924: 34020008 ori r2,r0,0x0008               #    Temp in-battle data offsets : read/write
00180928: a202018e sb r2,0x018e(r16)
0018092c: 32220004 andi r2,r17,0x0004            #   r2 = (r17 bit 0x04 check)
00180930: 10400007 beq r2,r0,0x00180950            #   IF (r2 != 0)
00180934: a200018c sb r0,0x018c(r16)            #    {
00180938: 3c058006 lui r5,0x8006
0018093c: 90a5628e lbu r5,0x628e(r5)            #      r5 = MEM[0x8006628e]
00180940: 0c063a7a jal 0x0018e9e8               #      Routine: ? (r4=[In-battle unit pointer])
00180944: 02002021 addu r4,r16,r0
00180948: 0806027c j 0x001809f0                  #      RETURN r2
0018094c: 00000000 nop                        #   }
00180950: 32220002 andi r2,r17,0x0002            #   r2 = (r17 bit 0x02 check)
00180954: 1040000d beq r2,r0,0x0018098c            #   IF (r2 != 0)
00180958: 34020001 ori r2,r0,0x0001               #   {
0018095c: a202018c sb r2,0x018c(r16)            #      (Mess with temp data)   
00180960: 34020050 ori r2,r0,0x0050
00180964: a20201b1 sb r2,0x01b1(r16)
00180968: 9602002a lhu r2,0x002a(r16)
0018096c: 96040028 lhu r4,0x0028(r16)
00180970: 9603002e lhu r3,0x002e(r16)
00180974: 9605002c lhu r5,0x002c(r16)
00180978: a200018e sb r0,0x018e(r16)
0018097c: 00441023 subu r2,r2,r4
00180980: 00651823 subu r3,r3,r5
00180984: a6020192 sh r2,0x0192(r16)
00180988: a6030196 sh r3,0x0196(r16)            #   }
0018098c: 32220001 andi r2,r17,0x0001            #   r2 = (r17 bit 0x01 check)
00180990: 10400017 beq r2,r0,0x001809f0            #   IF (r2 == 0), RETURN 0
00180994: 00001021 addu r2,r0,r0               #   r2 = 0
00180998: 00004821 addu r9,r0,r0               #   r9 = 0
0018099c: 3c088006 lui r8,0x8006               
001809a0: 25086254 addiu r8,r8,0x6254            #   r8 = MEM[0x80066254]
001809a4: 02002021 addu r4,r16,r0               #   r4 = [Unit]

#   SECTION 2 : BEGIN OUTER LOOP

001809a8: 24850099 addiu r5,r4,0x0099            #   DO
001809ac: 01003021 addu r6,r8,r0               #   {
001809b0: 2487009c addiu r7,r4,0x009c            #      r6 = r8

#    SECTION 3 : BEGIN INNER LOOP

001809b4: 90a20000 lbu r2,0x0000(r5)            #      DO {
001809b8: 90c30000 lbu r3,0x0000(r6)            #         r2 = [Unit Action abilities]    (r5th)
001809bc: 00000000 nop                        #         r3 = [Crystal action abilities]   (r6th)
001809c0: 00431025 or r2,r2,r3
001809c4: a0a20000 sb r2,0x0000(r5)               #         [Unit action abilities] = (Combination of r2 and r3)   NOTE : r2 | r3
001809c8: 24a50001 addiu r5,r5,0x0001            #         r5++
001809cc: 00a7102a slt r2,r5,r7                  #         r6++
001809d0: 1440fff8 bne r2,r0,0x001809b4            #      } WHILE (r5 < r7)
001809d4: 24c60001 addiu r6,r6,0x0001            #      
001809d8: 25080003 addiu r8,r8,0x0003            #      r8++
001809dc: 25290001 addiu r9,r9,0x0001            #      r9++
001809e0: 29220013 slti r2,r9,0x0013            #      r4 += 3
001809e4: 1440fff0 bne r2,r0,0x001809a8            #   } WHILE (r9 < 0x13)
001809e8: 24840003 addiu r4,r4,0x0003

#   SECTION 4 : RETURN

001809ec: 00001021 addu r2,r0,r0               #   RETURN 0
001809f0: 8fbf0018 lw r31,0x0018(r29)
001809f4: 8fb10014 lw r17,0x0014(r29)
001809f8: 8fb00010 lw r16,0x0010(r29)
001809fc: 27bd0020 addiu r29,r29,0x0020
00180a00: 03e00008 jr r31
00180a04: 00000000 nop
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pride on February 04, 2012, 04:47:05 am
 Transparent Removal Routine (gogogo Ghost Status)

0018d868: 27bdffe8 addiu r29,r29,0xffe8      
0018d86c: afb00010 sw r16,0x0010(r29)      
0018d870: afbf0014 sw r31,0x0014(r29)      
0018d874: 0c063691 jal 0x0018da44      Check for Crystal, Dead, Jump, Petrify, or Treasure
0018d878: 00808021 addu r16,r4,r0      r16 = Unit Data
0018d87c: 1440001f bne r2,r0,0x0018d8fc      Branch if Crystal, Dead, Jump, Petrify, or Treasure
0018d880: 00001021 addu r2,r0,r0      r2 = 0
0018d884: 0c063681 jal 0x0018da04      Store Unit Data
0018d888: 02002021 addu r4,r16,r0      r4 = Unit Data
0018d88c: 92020188 lbu r2,0x0188(r16)      Load Unit Action Taken?
0018d890: 00000000 nop         
0018d894: 10400015 beq r2,r0,0x0018d8ec      Branch if No Action Taken
0018d898: 00000000 nop            
0018d89c: 3c038019 lui r3,0x8019      
0018d8a0: 8c632d98 lw r3,0x2d98(r3)      Load Defender's Stats
0018d8a4: 00000000 nop            
0018d8a8: 906201bd lbu r2,0x01bd(r3)      Load Inflicted Status List 3
0018d8ac: 00000000 nop            
0018d8b0: 30420010 andi r2,r2,0x0010      
0018d8b4: 1040000d beq r2,r0,0x0018d8ec      Branch if Unit is not Transparent
0018d8b8: 00000000 nop            
0018d8bc: 90620027 lbu r2,0x0027(r3)      Load... Unit's Turn?
0018d8c0: 00000000 nop            
0018d8c4: 10400009 beq r2,r0,0x0018d8ec      Branch if /not/ Unit's Turn
0018d8c8: 34020010 ori r2,r0,0x0010      r2 = 0x10
0018d8cc: 3c038019 lui r3,0x8019      
0018d8d0: 8c632d90 lw r3,0x2d90(r3)      Load Current Action Data Pointer
0018d8d4: 00000000 nop            
0018d8d8: a0620022 sb r2,0x0022(r3)      Store Transparent Removal
0018d8dc: 3c038019 lui r3,0x8019      
0018d8e0: 8c632d90 lw r3,0x2d90(r3)      Load Current Action Data Pointer
0018d8e4: 34020008 ori r2,r0,0x0008      
0018d8e8: a0620025 sb r2,0x0025(r3)      Store Attack-Type as Status Change
0018d8ec: 3c028019 lui r2,0x8019      
0018d8f0: 8c422d90 lw r2,0x2d90(r2)      Load Current Action Data Pointer
0018d8f4: 00000000 nop            
0018d8f8: 90420025 lbu r2,0x0025(r2)      Load Current Action Data Pointer
0018d8fc: 8fbf0014 lw r31,0x0014(r29)      
0018d900: 8fb00010 lw r16,0x0010(r29)      
0018d904: 27bd0018 addiu r29,r29,0x0018      
0018d908: 03e00008 jr r31         
0018d90c: 00000000 nop            
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pride on February 07, 2012, 09:55:24 pm
Some more routines

Poison Marsh Routine (found by Pokeytax, I'm just giving notes)

0018da88: 27bdffe0 addiu r29,r29,0xffe0
0018da8c: afb10014 sw r17,0x0014(r29)
0018da90: 00808821 addu r17,r4,r0
0018da94: afbf0018 sw r31,0x0018(r29)
0018da98: afb00010 sw r16,0x0010(r29)
0018da9c: 92300182 lbu r16,0x0182(r17)      
0018daa0: 0c063691 jal 0x0018da44      Check for Crystal, Dead, Jump, Petrify, or Treasure
0018daa4: 00000000 nop
0018daa8: 1440003b bne r2,r0,0x0018db98      Branch if unit is afflicted with the above Status
0018daac: 00001021 addu r2,r0,r0      r2 = 0x00
0018dab0: 32020040 andi r2,r16,0x0040      
0018dab4: 14400038 bne r2,r0,0x0018db98      Branch if being ridden.
0018dab8: 00001021 addu r2,r0,r0      r2 = 0x00
0018dabc: 32020080 andi r2,r16,0x0080      
0018dac0: 1040000d beq r2,r0,0x0018daf8      Branch if user is riding another unit
0018dac4: 3202001f andi r2,r16,0x001f      
0018dac8: 000218c0 sll r3,r2,0x03      
0018dacc: 00621823 subu r3,r3,r2      
0018dad0: 00031980 sll r3,r3,0x06      
0018dad4: 3c018019 lui r1,0x8019      
0018dad8: 00230821 addu r1,r1,r3      Load Unit data?
0018dadc: 90220926 lbu r2,0x0926(r1)      ?_?
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      
0018daf0: 080636e6 j 0x0018db98         
0018daf4: 00001021 addu r2,r0,r0      r2 = 0
0018daf8: 9222005a lbu r2,0x005a(r17)      Load Current Statuses 3
0018dafc: 080636ba j 0x0018dae8         
0018db00: 30420040 andi r2,r2,0x0040      
0018db04: 9222018a lbu r2,0x018a(r17)      
0018db08: 3c018019 lui r1,0x8019      
0018db0c: ac312d98 sw r17,0x2d98(r1)      Store Defender's Data
0018db10: 3c018019 lui r1,0x8019      
0018db14: ac242d90 sw r4,0x2d90(r1)      Store Defender's Current Action Data
0018db18: 3c018019 lui r1,0x8019
0018db1c: a02238c1 sb r2,0x38c1(r1)      Store Target Unit ID
0018db20: 0c062f5d jal 0x0018bd74      Sub-routine (there's a routine to load all this...)
0018db24: 00000000 nop            
0018db28: 0c060428 jal 0x001810a0      Map Location Calculation
0018db2c: 02202021 addu r4,r17,r0      r4 = Unit Data
0018db30: 000210c0 sll r2,r2,0x03      
0018db34: 3c018019 lui r1,0x8019      
0018db38: 00220821 addu r1,r1,r2      
0018db3c: 9022f8cc lbu r2,-0x0734(r1)      Load some RAM data
0018db40: 00000000 nop            
0018db44: 3042003f andi r2,r2,0x003f      
0018db48: 3c018006 lui r1,0x8006      
0018db4c: 00220821 addu r1,r1,r2      
0018db50: 9022ea10 lbu r2,-0x15f0(r1)      Load Terrain Status Infliction
0018db54: 00000000 nop            
0018db58: 30420080 andi r2,r2,0x0080      
0018db5c: 1040000d beq r2,r0,0x0018db94      Branch if Status is Poison
0018db60: 00002021 addu r4,r0,r0      r4 = 0
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      
0018db74: a062001e sb r2,0x001e(r3)      Store Status Infliction as Poison
0018db78: 10400006 beq r2,r0,0x0018db94      
0018db7c: 34020001 ori r2,r0,0x0001      
0018db80: 3c048019 lui r4,0x8019      
0018db84: 8c842d90 lw r4,0x2d90(r4)      
0018db88: 34030008 ori r3,r0,0x0008      
0018db8c: 080636e6 j 0x0018db98         
0018db90: a0830025 sb r3,0x0025(r4)      
0018db94: 00001021 addu r2,r0,r0      
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   


Traps Routine

0018dbb0: 27bdffe0 addiu r29,r29,0xffe0      
0018dbb4: afb00010 sw r16,0x0010(r29)      
0018dbb8: 00808021 addu r16,r4,r0      
0018dbbc: afbf0018 sw r31,0x0018(r29)      
0018dbc0: afb10014 sw r17,0x0014(r29)      
0018dbc4: 92040047 lbu r4,0x0047(r16)      Load X Coordinate
0018dbc8: 96060048 lhu r6,0x0048(r16)      Load Y Coordinate
0018dbcc: 92050048 lbu r5,0x0048(r16)      Load Y Coordinate
0018dbd0: 0c0600b2 jal 0x001802c8      Big routine, I can only assume that it finds out if the unit triggered a trap.
0018dbd4: 000633c2 srl r6,r6,0x0f      
0018dbd8: 92030182 lbu r3,0x0182(r16)      Mount Info
0018dbdc: 90510004 lbu r17,0x0004(r2)      
0018dbe0: 30620040 andi r2,r3,0x0040      
0018dbe4: 10400007 beq r2,r0,0x0018dc04      
0018dbe8: 3062001f andi r2,r3,0x001f      
0018dbec: 000218c0 sll r3,r2,0x03      
0018dbf0: 00621823 subu r3,r3,r2      
0018dbf4: 00031980 sll r3,r3,0x06      
0018dbf8: 3c028019 lui r2,0x8019      
0018dbfc: 244208cc addiu r2,r2,0x08cc      Load Unit Data
0018dc00: 00628021 addu r16,r3,r2      
0018dc04: 9202018a lbu r2,0x018a(r16)      Load Unit ID   
0018dc08: 2604018c addiu r4,r16,0x018c      
0018dc0c: 3c018019 lui r1,0x8019      
0018dc10: ac302d98 sw r16,0x2d98(r1)      Store Defender's Stats
0018dc14: 3c018019 lui r1,0x8019      
0018dc18: ac242d90 sw r4,0x2d90(r1)      Store Defender's Current Action Data
0018dc1c: 3c018019 lui r1,0x8019      
0018dc20: a02238c1 sb r2,0x38c1(r1)      Store Target ID
0018dc24: 0c062f5d jal 0x0018bd74      
0018dc28: 00000000 nop            
0018dc2c: 322300ff andi r3,r17,0x00ff      
0018dc30: 34020001 ori r2,r0,0x0001      
0018dc34: 10620017 beq r3,r2,0x0018dc94      
0018dc38: 28620002 slti r2,r3,0x0002      
0018dc3c: 10400005 beq r2,r0,0x0018dc54      
0018dc40: 00000000 nop            
0018dc44: 1060000a beq r3,r0,0x0018dc70      
0018dc48: 34020001 ori r2,r0,0x0001      
0018dc4c: 0806374a j 0x0018dd28         
0018dc50: 341100ff ori r17,r0,0x00ff      
0018dc54: 34020002 ori r2,r0,0x0002      
0018dc58: 10620018 beq r3,r2,0x0018dcbc      
0018dc5c: 34020003 ori r2,r0,0x0003      
0018dc60: 10620027 beq r3,r2,0x0018dd00      
0018dc64: 3c03cccc lui r3,0xcccc      
0018dc68: 0806374a j 0x0018dd28         
0018dc6c: 341100ff ori r17,r0,0x00ff      
0018dc70: 3c038019 lui r3,0x8019      
0018dc74: 8c632d90 lw r3,0x2d90(r3)      Load Defender Current Action Data
0018dc78: 00000000 nop            
0018dc7c: a0620025 sb r2,0x0025(r3)      Store Attack-type
0018dc80: 3c038019 lui r3,0x8019      
0018dc84: 8c632d90 lw r3,0x2d90(r3)      Load Defender Current Action Data
0018dc88: 34020100 ori r2,r0,0x0100      
0018dc8c: 0806374a j 0x0018dd28         
0018dc90: a4620010 sh r2,0x0010(r3)      Store flag as Level Reduction
0018dc94: 00002021 addu r4,r0,r0      r4 = 0x00
0018dc98: 3c038019 lui r3,0x8019      
0018dc9c: 8c632d90 lw r3,0x2d90(r3)      Load Defender Current Action Data
0018dca0: 34020001 ori r2,r0,0x0001      
0018dca4: 0c0612c9 jal 0x00184b24      Check if Unit is immune to status
0018dca8: a062001f sb r2,0x001f(r3)      Store Status as Death Sentence
0018dcac: 10400010 beq r2,r0,0x0018dcf0      Branch if no status is inflicted
0018dcb0: 00000000 nop            
0018dcb4: 08063737 j 0x0018dcdc         
0018dcb8: 00000000 nop            
0018dcbc: 00002021 addu r4,r0,r0      r4 = 0x00
0018dcc0: 3c038019 lui r3,0x8019      
0018dcc4: 8c632d90 lw r3,0x2d90(r3)      Load Defender Current Action Data
0018dcc8: 34020010 ori r2,r0,0x0010      
0018dccc: 0c0612c9 jal 0x00184b24      Check if Unit is immune to status
0018dcd0: a062001f sb r2,0x001f(r3)      Store Unit as Sleeping
0018dcd4: 10400006 beq r2,r0,0x0018dcf0      
0018dcd8: 00000000 nop            
0018dcdc: 3c038019 lui r3,0x8019      
0018dce0: 8c632d90 lw r3,0x2d90(r3)      Load Defender Current Action Data
0018dce4: 34020008 ori r2,r0,0x0008      
0018dce8: 0806374a j 0x0018dd28         
0018dcec: a0620025 sb r2,0x0025(r3)      Store Attack-type as Status change
0018dcf0: 0c0610c3 jal 0x0018430c      
0018dcf4: 00000000 nop            
0018dcf8: 0806374b j 0x0018dd2c         
0018dcfc: 02201021 addu r2,r17,r0      
0018dd00: 9602002a lhu r2,0x002a(r16)      Load Max HP
0018dd04: 3463cccd ori r3,r3,0xcccd            
0018dd08: 00430019 multu r2,r3         
0018dd0c: 3c038019 lui r3,0x8019      
0018dd10: 8c632d90 lw r3,0x2d90(r3)      Load Current Action Data Pointer
0018dd14: 34020080 ori r2,r0,0x0080      
0018dd18: a0620025 sb r2,0x0025(r3)      Store attack type has HP Damage
0018dd1c: 00001010 mfhi r2         
0018dd20: 00021082 srl r2,r2,0x02      
0018dd24: a4620004 sh r2,0x0004(r3)      Store HP Damage
0018dd28: 02201021 addu r2,r17,r0      
0018dd2c: 8fbf0018 lw r31,0x0018(r29)      
0018dd30: 8fb10014 lw r17,0x0014(r29)      
0018dd34: 8fb00010 lw r16,0x0010(r29)      
0018dd38: 27bd0020 addiu r29,r29,0x0020      
0018dd3c: 03e00008 jr r31         
0018dd40: 00000000 nop            
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pride on February 11, 2012, 06:54:29 am
Some display stuff and some stuff SecondAdvent g
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on February 12, 2012, 12:25:46 am
Steal routine with shoddy notes:

Edit: also, inventory increment routine


Steal Routine
0018d3c0: 3c028019 lui r2,0x8019
0018d3c4: 8c422d90 lw r2,0x2d90(r2)      target current action pointer
0018d3c8: 27bdffe0 addiu r29,r29,0xffe0
0018d3cc: afbf001c sw r31,0x001c(r29)
0018d3d0: afb20018 sw r18,0x0018(r29)
0018d3d4: afb10014 sw r17,0x0014(r29)
0018d3d8: afb00010 sw r16,0x0010(r29)
0018d3dc: 94420010 lhu r2,0x0010(r2)      load steal/break item flags
0018d3e0: 00000000 nop
0018d3e4: 30420014 andi r2,r2,0x0014      
0018d3e8: 10400059 beq r2,r0,0x0018d550      branch if not stealing or breaking
0018d3ec: 00008821 addu r17,r0,r0
0018d3f0: 00008021 addu r16,r0,r0
0018d3f4: 341200ff ori r18,r0,0x00ff
0018d3f8: 3c028019 lui r2,0x8019
0018d3fc: 8c422d90 lw r2,0x2d90(r2)      target current action pointer again
0018d400: 34030080 ori r3,r0,0x0080      
0018d404: 90420019 lbu r2,0x0019(r2)      load remove equipment byte
0018d408: 02031807 srav r3,r3,r16      r3 = 0?
0018d40c: 00431024 and r2,r2,r3         
0018d410: 10400021 beq r2,r0,0x0018d498      skip if nothing stolen/broken?
0018d414: 00000000 nop
0018d418: 3c028019 lui r2,0x8019
0018d41c: 8c422d98 lw r2,0x2d98(r2)      target data pointer
0018d420: 00000000 nop
0018d424: 00501821 addu r3,r2,r16      
0018d428: 9065001a lbu r5,0x001a(r3)      ??
0018d42c: 00000000 nop
0018d430: 10a00019 beq r5,r0,0x0018d498
0018d434: 00000000 nop
0018d438: 10b20017 beq r5,r18,0x0018d498   
0018d43c: 00051040 sll r2,r5,0x01      
0018d440: 00451021 addu r2,r2,r5
0018d444: 00021080 sll r2,r2,0x02
0018d448: 3c018006 lui r1,0x8006
0018d44c: 00220821 addu r1,r1,r2
0018d450: 90222ebb lbu r2,0x2ebb(r1)      item data pointer
0018d454: 00000000 nop
0018d458: 30420001 andi r2,r2,0x0001      
0018d45c: 1440000e bne r2,r0,0x0018d498
0018d460: 00000000 nop
0018d464: a072001a sb r18,0x001a(r3)      decrement?
0018d468: 3c028019 lui r2,0x8019
0018d46c: 8c422d90 lw r2,0x2d90(r2)      target current action pointer
0018d470: 00000000 nop
0018d474: 94420010 lhu r2,0x0010(r2)      steal/break byte
0018d478: 00000000 nop
0018d47c: 30420010 andi r2,r2,0x0010      steal check
0018d480: 10400005 beq r2,r0,0x0018d498
0018d484: 26310001 addiu r17,r17,0x0001      
0018d488: 3c048019 lui r4,0x8019
0018d48c: 8c842d94 lw r4,0x2d94(r4)      attacker data ponter
0018d490: 0c063a7a jal 0x0018e9e8      item/stat increment routines?
0018d494: 00000000 nop
0018d498: 26100001 addiu r16,r16,0x0001      counter
0018d49c: 2a020007 slti r2,r16,0x0007      runs 7 times
0018d4a0: 1440ffd5 bne r2,r0,0x0018d3f8
0018d4a4: 00000000 nop
0018d4a8: 1220002a beq r17,r0,0x0018d554   branch if no steal?
0018d4ac: 00001021 addu r2,r0,r0
0018d4b0: 3c028019 lui r2,0x8019
0018d4b4: 8c42f5fc lw r2,-0x0a04(r2)
0018d4b8: 00000000 nop
0018d4bc: 14400005 bne r2,r0,0x0018d4d4      ?
0018d4c0: 00000000 nop
0018d4c4: 3c048019 lui r4,0x8019
0018d4c8: 8c842d98 lw r4,0x2d98(r4)      target data pointer
0018d4cc: 0c017578 jal 0x0005d5e0      status setting/checking + equip R/S/M stats check
0018d4d0: 00000000 nop
0018d4d4: 3c058019 lui r5,0x8019
0018d4d8: 8ca52d90 lw r5,0x2d90(r5)      target current action pointer
0018d4dc: 00000000 nop
0018d4e0: 90a30019 lbu r3,0x0019(r5)      remove item byte
0018d4e4: 34020010 ori r2,r0,0x0010      
0018d4e8: 10620003 beq r3,r2,0x0018d4f8      branch if right hand weapon
0018d4ec: 34020004 ori r2,r0,0x0004      
0018d4f0: 14620018 bne r3,r2,0x0018d554      branch if left hand weapon
0018d4f4: 34020001 ori r2,r0,0x0001      
0018d4f8: 3c048019 lui r4,0x8019
0018d4fc: 8c842d98 lw r4,0x2d98(r4)      target data pointer?? again??
0018d500: 00000000 nop
0018d504: 90820058 lbu r2,0x0058(r4)      load status 1   
0018d508: 00000000 nop
0018d50c: 30420008 andi r2,r2,0x0008      if  charging?
0018d510: 1040000d beq r2,r0,0x0018d548      branch if not charging
0018d514: 340200ff ori r2,r0,0x00ff
0018d518: 9083015d lbu r3,0x015d(r4)      load target current ability CT
0018d51c: 00000000 nop
0018d520: 10620009 beq r3,r2,0x0018d548
0018d524: 34020008 ori r2,r0,0x0008
0018d528: 9083016f lbu r3,0x016f(r4)      skillset of last attack used
0018d52c: 00000000 nop
0018d530: 14620005 bne r3,r2,0x0018d548      branch if skillset != charge?
0018d534: 00000000 nop
0018d538: 90a20020 lbu r2,0x0020(r5)      attack status removal 1
0018d53c: 00000000 nop
0018d540: 34420008 ori r2,r2,0x0008
0018d544: a0a20020 sb r2,0x0020(r5)      store remove charge
0018d548: 08063555 j 0x0018d554         
0018d54c: 34020001 ori r2,r0,0x0001
0018d550: 00001021 addu r2,r0,r0
0018d554: 8fbf001c lw r31,0x001c(r29)
0018d558: 8fb20018 lw r18,0x0018(r29)
0018d55c: 8fb10014 lw r17,0x0014(r29)
0018d560: 8fb00010 lw r16,0x0010(r29)
0018d564: 27bd0020 addiu r29,r29,0x0020
0018d568: 03e00008 jr r31
0018d56c: 00000000 nop



Item quantity increment for steal/break?
0018e9e8: 3c028019 lui r2,0x8019
0018e9ec: 8c42f5fc lw r2,-0x0a04(r2)      
0018e9f0: 27bdffe0 addiu r29,r29,0xffe0
0018e9f4: afb10014 sw r17,0x0014(r29)
0018e9f8: 00808821 addu r17,r4,r0      r17 = attacker data pointer
0018e9fc: afbf0018 sw r31,0x0018(r29)
0018ea00: 1440000a bne r2,r0,0x0018ea2c
0018ea04: afb00010 sw r16,0x0010(r29)
0018ea08: 922201ba lbu r2,0x01ba(r17)      load ENTD team flags
0018ea0c: 00000000 nop
0018ea10: 30420030 andi r2,r2,0x0030      team = red lightblue green
0018ea14: 14400005 bne r2,r0,0x0018ea2c      skip routine if not
0018ea18: 30b000ff andi r16,r5,0x00ff      r16 = r5?
0018ea1c: 12000003 beq r16,r0,0x0018ea2c   skip routine if r5 = 0
0018ea20: 340200ff ori r2,r0,0x00ff      r2 = ff
0018ea24: 16020003 bne r16,r2,0x0018ea34   skip if r5 = ff
0018ea28: 02002021 addu r4,r16,r0
0018ea2c: 08063aa0 j 0x0018ea80
0018ea30: 00001021 addu r2,r0,r0
0018ea34: 0c0178a2 jal 0x0005e288      get total equipment quantity
0018ea38: 34050001 ori r5,r0,0x0001
0018ea3c: 28420063 slti r2,r2,0x0063      set if quantity <99
0018ea40: 1040000b beq r2,r0,0x0018ea70      skip if not
0018ea44: 00001021 addu r2,r0,r0
0018ea48: 3c018006 lui r1,0x8006
0018ea4c: 00300821 addu r1,r1,r16
0018ea50: 902396e0 lbu r3,-0x6920(r1)      item data pointer?
0018ea54: 00000000 nop
0018ea58: 24630001 addiu r3,r3,0x0001      increment by 1
0018ea5c: 3c018006 lui r1,0x8006
0018ea60: 00300821 addu r1,r1,r16
0018ea64: a02396e0 sb r3,-0x6920(r1)      store new item quantity
0018ea68: 08063aa0 j 0x0018ea80         jump to end
0018ea6c: 00000000 nop
0018ea70: 02202021 addu r4,r17,r0      r4 = data pointer?
0018ea74: 00002821 addu r5,r0,r0      r5 = 0
0018ea78: 0c063aa6 jal 0x0018ea98
0018ea7c: 02003021 addu r6,r16,r0      r6 = item ID?
0018ea80: 8fbf0018 lw r31,0x0018(r29)
0018ea84: 8fb10014 lw r17,0x0014(r29)
0018ea88: 8fb00010 lw r16,0x0010(r29)
0018ea8c: 27bd0020 addiu r29,r29,0x0020
0018ea90: 03e00008 jr r31
0018ea94: 00000000 nop
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on February 12, 2012, 09:41:11 am
Big targeting routine with even shoddier notes:


Targeting routine:
0017b874: 27bdffb8 addiu r29,r29,0xffb8
0017b878: 27a50010 addiu r5,r29,0x0010
0017b87c: afbf0040 sw r31,0x0040(r29)
0017b880: afb5003c sw r21,0x003c(r29)
0017b884: afb40038 sw r20,0x0038(r29)
0017b888: afb30034 sw r19,0x0034(r29)
0017b88c: afb20030 sw r18,0x0030(r29)
0017b890: afb1002c sw r17,0x002c(r29)
0017b894: 0c01788b jal 0x0005e22c
0017b898: afb00028 sw r16,0x0028(r29)
0017b89c: 3c058019 lui r5,0x8019
0017b8a0: 24a508cc addiu r5,r5,0x08cc
0017b8a4: 87a20012 lh r2,0x0012(r29)
0017b8a8: 93b40010 lbu r20,0x0010(r29)
0017b8ac: 000218c0 sll r3,r2,0x03
0017b8b0: 00621823 subu r3,r3,r2
0017b8b4: 00031840 sll r3,r3,0x01
0017b8b8: 3c028006 lui r2,0x8006
0017b8bc: 2442fbf0 addiu r2,r2,0xfbf0
0017b8c0: 00621821 addu r3,r3,r2
0017b8c4: 001410c0 sll r2,r20,0x03
0017b8c8: 00541023 subu r2,r2,r20
0017b8cc: 00021180 sll r2,r2,0x06
0017b8d0: 90690003 lbu r9,0x0003(r3)      ability flags 1
0017b8d4: 90710004 lbu r17,0x0004(r3)      ability flags 2
0017b8d8: 90640006 lbu r4,0x0006(r3)      ability flags 4
0017b8dc: 90730001 lbu r19,0x0001(r3)      load aoe
0017b8e0: 90750002 lbu r21,0x0002(r3)      load verticle
0017b8e4: 30840020 andi r4,r4,0x0020      
0017b8e8: 10800003 beq r4,r0,0x0017b8f8      branch if not direct attack
0017b8ec: 00458021 addu r16,r2,r5      r16 = unit data pointer
0017b8f0: 35290020 ori r9,r9,0x0020      r9 = 20
0017b8f4: 32310039 andi r17,r17,0x0039      set if all flags under cannot hit allies=true
0017b8f8: 32220006 andi r2,r17,0x0006      set if linear 3 direction
0017b8fc: 10400006 beq r2,r0,0x0017b918      else branch
0017b900: 34020006 ori r2,r0,0x0006      r2= 06
0017b904: 92050047 lbu r5,0x0047(r16)      load x coordinate
0017b908: 96020048 lhu r2,0x0048(r16)      load y coordinate
0017b90c: 92040048 lbu r4,0x0048(r16)      load y coordinate
0017b910: 0805ee59 j 0x0017b964         skip following routine
0017b914: 00021bc2 srl r3,r2,0x0f      r2= y coordinate/2^0f?
0017b918: 93a3001a lbu r3,0x001a(r29)      load target Y coordinate?
0017b91c: 00000000 nop
0017b920: 10620006 beq r3,r2,0x0017b93c      branch if target y = caster y
0017b924: 00000000 nop
0017b928: 93a5001c lbu r5,0x001c(r29)      load target x
0017b92c: 93a40020 lbu r4,0x0020(r29)      load target y
0017b930: 93a3001e lbu r3,0x001e(r29)      load ?
0017b934: 0805ee59 j 0x0017b964         
0017b938: 00000000 nop
0017b93c: 93a2001b lbu r2,0x001b(r29)      load ?
0017b940: 00000000 nop
0017b944: 000218c0 sll r3,r2,0x03
0017b948: 00621823 subu r3,r3,r2
0017b94c: 00031980 sll r3,r3,0x06
0017b950: 00651821 addu r3,r3,r5
0017b954: 90650047 lbu r5,0x0047(r3)      load caster x
0017b958: 94620048 lhu r2,0x0048(r3)      load caster y
0017b95c: 90640048 lbu r4,0x0048(r3)      load caster y
0017b960: 00021bc2 srl r3,r2,0x0f      caster y/2^0f?
0017b964: 3c06800e lui r6,0x800e
0017b968: 90c64e9c lbu r6,0x4e9c(r6)      map max x
0017b96c: 00000000 nop   
0017b970: 00a6102a slt r2,r5,r6         set if caster x < max x??
0017b974: 104000b6 beq r2,r0,0x0017bc50      skip to end if not
0017b978: 2402ffff addiu r2,r0,0xffff      
0017b97c: 3c02800e lui r2,0x800e
0017b980: 90424ea0 lbu r2,0x4ea0(r2)      load max y?
0017b984: 00000000 nop
0017b988: 0082102a slt r2,r4,r2         set if caster y < max y??
0017b98c: 10400010 beq r2,r0,0x0017b9d0      skip to end if not      
0017b990: 28620002 slti r2,r3,0x0002      set if caster y/2^0f < 02
0017b994: 1040000e beq r2,r0,0x0017b9d0      skip to end if not?
0017b998: 00860018 mult r4,r6
0017b99c: 00031200 sll r2,r3,0x08
0017b9a0: 00001812 mflo r3
0017b9a4: 00431021 addu r2,r2,r3
0017b9a8: 00453021 addu r6,r2,r5
0017b9ac: 000618c0 sll r3,r6,0x03      
0017b9b0: 3c028019 lui r2,0x8019
0017b9b4: 2442f8cc addiu r2,r2,0xf8cc      load tile data start
0017b9b8: 00622821 addu r5,r3,r2
0017b9bc: 90a20006 lbu r2,0x0006(r5)      load byte at 8018f8cc + 2B8 (20)
0017b9c0: 00000000 nop
0017b9c4: 30420001 andi r2,r2,0x0001      
0017b9c8: 10400003 beq r2,r0,0x0017b9d8      jump if tile isn't unselectable via cursor
0017b9cc: 00000000 nop
0017b9d0: 0805ef14 j 0x0017bc50         else skip to end
0017b9d4: 2402ffff addiu r2,r0,0xffff
0017b9d8: 90a40002 lbu r4,0x0002(r5)      load tile height
0017b9dc: 90a30003 lbu r3,0x0003(r5)      load depth
0017b9e0: 90a20003 lbu r2,0x0003(r5)      load depth
0017b9e4: 00042040 sll r4,r4,0x01      height*2
0017b9e8: 3063001f andi r3,r3,0x001f      set if depth flag = 1f? (never)
0017b9ec: 00832021 addu r4,r4,r3      r4 = (height*2) + 0?
0017b9f0: 00021142 srl r2,r2,0x05      depth/2^5
0017b9f4: 00021040 sll r2,r2,0x01      depth*2
0017b9f8: 00829021 addu r18,r4,r2      
0017b9fc: 326300ff andi r3,r19,0x00ff      ?dunno what r19 is, 01 in this case
0017ba00: 340200ff ori r2,r0,0x00ff      
0017ba04: 1462000c bne r3,r2,0x0017ba38      ?
0017ba08: 00002021 addu r4,r0,r0      
0017ba0c: 34050001 ori r5,r0,0x0001      
0017ba10: 3c038019 lui r3,0x8019      
0017ba14: 24632dd8 addiu r3,r3,0x2dd8      
0017ba18: a0650000 sb r5,0x0000(r3)
0017ba1c: a0600001 sb r0,0x0001(r3)
0017ba20: 24840001 addiu r4,r4,0x0001
0017ba24: 28820200 slti r2,r4,0x0200      loop runs 200 times?
0017ba28: 1440fffb bne r2,r0,0x0017ba18
0017ba2c: 24630005 addiu r3,r3,0x0005
0017ba30: 0805eebf j 0x0017bafc         skip big following routine
0017ba34: 00000000 nop
0017ba38: 3c038019 lui r3,0x8019
0017ba3c: 24632dd8 addiu r3,r3,0x2dd8      
0017ba40: a0600000 sb r0,0x0000(r3)
0017ba44: a0600001 sb r0,0x0001(r3)
0017ba48: 24840001 addiu r4,r4,0x0001
0017ba4c: 28820200 slti r2,r4,0x0200
0017ba50: 1440fffb bne r2,r0,0x0017ba40      loop runs 200 times, clearing every 5th byte starting at 80192dd8
0017ba54: 24630005 addiu r3,r3,0x0005
0017ba58: 00061080 sll r2,r6,0x02
0017ba5c: 00461821 addu r3,r2,r6
0017ba60: 3c048019 lui r4,0x8019
0017ba64: 24842dd8 addiu r4,r4,0x2dd8
0017ba68: 00644021 addu r8,r3,r4
0017ba6c: 26620001 addiu r2,r19,0x0001
0017ba70: a1020000 sb r2,0x0000(r8)
0017ba74: 28c20100 slti r2,r6,0x0100
0017ba78: 10400005 beq r2,r0,0x0017ba90
0017ba7c: 24820500 addiu r2,r4,0x0500
0017ba80: 00623821 addu r7,r3,r2
0017ba84: 34020001 ori r2,r0,0x0001
0017ba88: 0805eea8 j 0x0017baa0
0017ba8c: a1020001 sb r2,0x0001(r8)
0017ba90: 2482fb00 addiu r2,r4,0xfb00
0017ba94: 00623821 addu r7,r3,r2
0017ba98: 34020001 ori r2,r0,0x0001
0017ba9c: a0e20001 sb r2,0x0001(r7)
0017baa0: 30c300ff andi r3,r6,0x00ff
0017baa4: 00031080 sll r2,r3,0x02
0017baa8: 00431021 addu r2,r2,r3
0017baac: 34030001 ori r3,r0,0x0001
0017bab0: 3c018019 lui r1,0x8019
0017bab4: 00220821 addu r1,r1,r2
0017bab8: a0232dd9 sb r3,0x2dd9(r1)
0017babc: 31220020 andi r2,r9,0x0020
0017bac0: 1440000e bne r2,r0,0x0017bafc
0017bac4: 02602021 addu r4,r19,r0
0017bac8: 00002821 addu r5,r0,r0
0017bacc: 26620001 addiu r2,r19,0x0001
0017bad0: a1020000 sb r2,0x0000(r8)
0017bad4: 0c05e546 jal 0x00179518
0017bad8: a0e20000 sb r2,0x0000(r7)
0017badc: 324400ff andi r4,r18,0x00ff
0017bae0: 02a02821 addu r5,r21,r0
0017bae4: 00113142 srl r6,r17,0x05
0017bae8: 0c05e4a9 jal 0x001792a4
0017baec: 30c60001 andi r6,r6,0x0001
0017baf0: 87a40012 lh r4,0x0012(r29)
0017baf4: 0c05e481 jal 0x00179204
0017baf8: 00000000 nop
0017bafc: 0c060428 jal 0x001810a0
0017bb00: 02002021 addu r4,r16,r0
0017bb04: 00021880 sll r3,r2,0x02
0017bb08: 00621821 addu r3,r3,r2
0017bb0c: 3c128019 lui r18,0x8019
0017bb10: 26522dd8 addiu r18,r18,0x2dd8
0017bb14: 32220001 andi r2,r17,0x0001
0017bb18: 10400002 beq r2,r0,0x0017bb24
0017bb1c: 00721821 addu r3,r3,r18
0017bb20: a0600000 sb r0,0x0000(r3)
0017bb24: 32220004 andi r2,r17,0x0004
0017bb28: 10400003 beq r2,r0,0x0017bb38
0017bb2c: 27a40010 addiu r4,r29,0x0010
0017bb30: 0c05ef9a jal 0x0017be68
0017bb34: 34050001 ori r5,r0,0x0001
0017bb38: 32220002 andi r2,r17,0x0002
0017bb3c: 10400004 beq r2,r0,0x0017bb50
0017bb40: 323000c0 andi r16,r17,0x00c0
0017bb44: 27a40010 addiu r4,r29,0x0010
0017bb48: 0c05ef9a jal 0x0017be68
0017bb4c: 34050003 ori r5,r0,0x0003
0017bb50: 12000006 beq r16,r0,0x0017bb6c
0017bb54: 02802021 addu r4,r20,r0
0017bb58: 32250080 andi r5,r17,0x0080
0017bb5c: 32260040 andi r6,r17,0x0040
0017bb60: 3a6700ff xori r7,r19,0x00ff
0017bb64: 0c05ef1e jal 0x0017bc78
0017bb68: 2ce70001 sltiu r7,r7,0x0001
0017bb6c: 1600001d bne r16,r0,0x0017bbe4
0017bb70: 00003021 addu r6,r0,r0
0017bb74: 00002021 addu r4,r0,r0
0017bb78: 02402821 addu r5,r18,r0
0017bb7c: 3c038019 lui r3,0x8019
0017bb80: 2463f8cc addiu r3,r3,0xf8cc
0017bb84: 90a20000 lbu r2,0x0000(r5)
0017bb88: 00000000 nop
0017bb8c: 1040000a beq r2,r0,0x0017bbb8
0017bb90: 00000000 nop
0017bb94: 90620006 lbu r2,0x0006(r3)
0017bb98: 00000000 nop
0017bb9c: 30420003 andi r2,r2,0x0003
0017bba0: 14400005 bne r2,r0,0x0017bbb8
0017bba4: 00000000 nop
0017bba8: 90620005 lbu r2,0x0005(r3)
0017bbac: 24c60001 addiu r6,r6,0x0001
0017bbb0: 0805eef1 j 0x0017bbc4
0017bbb4: 34420080 ori r2,r2,0x0080
0017bbb8: 90620005 lbu r2,0x0005(r3)
0017bbbc: 00000000 nop
0017bbc0: 3042007f andi r2,r2,0x007f
0017bbc4: a0620005 sb r2,0x0005(r3)
0017bbc8: 24a50005 addiu r5,r5,0x0005
0017bbcc: 24840001 addiu r4,r4,0x0001
0017bbd0: 28820200 slti r2,r4,0x0200
0017bbd4: 1440ffeb bne r2,r0,0x0017bb84
0017bbd8: 24630008 addiu r3,r3,0x0008
0017bbdc: 0805ef14 j 0x0017bc50
0017bbe0: 00c01021 addu r2,r6,r0
0017bbe4: 00002021 addu r4,r0,r0
0017bbe8: 02402821 addu r5,r18,r0
0017bbec: 3c038019 lui r3,0x8019
0017bbf0: 2463f8cc addiu r3,r3,0xf8cc
0017bbf4: 90a20001 lbu r2,0x0001(r5)
0017bbf8: 00000000 nop
0017bbfc: 1040000a beq r2,r0,0x0017bc28
0017bc00: 00000000 nop
0017bc04: 90620006 lbu r2,0x0006(r3)
0017bc08: 00000000 nop
0017bc0c: 30420003 andi r2,r2,0x0003
0017bc10: 14400005 bne r2,r0,0x0017bc28
0017bc14: 00000000 nop
0017bc18: 90620005 lbu r2,0x0005(r3)
0017bc1c: 24c60001 addiu r6,r6,0x0001
0017bc20: 0805ef0d j 0x0017bc34
0017bc24: 34420080 ori r2,r2,0x0080
0017bc28: 90620005 lbu r2,0x0005(r3)
0017bc2c: 00000000 nop
0017bc30: 3042007f andi r2,r2,0x007f
0017bc34: a0620005 sb r2,0x0005(r3)
0017bc38: 24a50005 addiu r5,r5,0x0005
0017bc3c: 24840001 addiu r4,r4,0x0001
0017bc40: 28820200 slti r2,r4,0x0200
0017bc44: 1440ffeb bne r2,r0,0x0017bbf4
0017bc48: 24630008 addiu r3,r3,0x0008
0017bc4c: 00c01021 addu r2,r6,r0
0017bc50: 8fbf0040 lw r31,0x0040(r29)
0017bc54: 8fb5003c lw r21,0x003c(r29)
0017bc58: 8fb40038 lw r20,0x0038(r29)
0017bc5c: 8fb30034 lw r19,0x0034(r29)
0017bc60: 8fb20030 lw r18,0x0030(r29)
0017bc64: 8fb1002c lw r17,0x002c(r29)
0017bc68: 8fb00028 lw r16,0x0028(r29)
0017bc6c: 27bd0048 addiu r29,r29,0x0048
0017bc70: 03e00008 jr r31
0017bc74: 00000000 nop

Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on February 12, 2012, 09:43:24 am
3 routines dealing with act/move/end of turn with semi-crumby notes:


Various Flags? r4= data pointer?
00183bf0: 27bdffe8 addiu r29,r29,0xffe8
00183bf4: afb00010 sw r16,0x0010(r29)
00183bf8: 00808021 addu r16,r4,r0
00183bfc: 001010c0 sll r2,r16,0x03
00183c00: 00501023 subu r2,r2,r16
00183c04: 00021180 sll r2,r2,0x06
00183c08: 3c038019 lui r3,0x8019
00183c0c: 246308cc addiu r3,r3,0x08cc      r3 = unit data pointer
00183c10: 00432021 addu r4,r2,r3
00183c14: afbf0014 sw r31,0x0014(r29)
00183c18: 90830001 lbu r3,0x0001(r4)      
00183c1c: 340200ff ori r2,r0,0x00ff
00183c20: 1062000d beq r3,r2,0x00183c58
00183c24: 2402ffff addiu r2,r0,0xffff
00183c28: 10a00002 beq r5,r0,0x00183c34
00183c2c: 34020001 ori r2,r0,0x0001
00183c30: a0820187 sb r2,0x0187(r4)      store movement taken
00183c34: 10c00002 beq r6,r0,0x00183c40
00183c38: 34020001 ori r2,r0,0x0001
00183c3c: a0820188 sb r2,0x0188(r4)      Store action taken
00183c40: 0c060f44 jal 0x00183d10      jump to Nullify act/move
00183c44: 00000000 nop
00183c48: 10400003 beq r2,r0,0x00183c58      Branch if action not taken
00183c4c: 00000000 nop
00183c50: 0c060f1b jal 0x00183c6c      Jump to end of turn***
00183c54: 02002021 addu r4,r16,r0
00183c58: 8fbf0014 lw r31,0x0014(r29)
00183c5c: 8fb00010 lw r16,0x0010(r29)
00183c60: 27bd0018 addiu r29,r29,0x0018
00183c64: 03e00008 jr r31
00183c68: 00000000 nop

End of Turn
00183c6c: 000410c0 sll r2,r4,0x03      r2 = r4* 8?
00183c70: 00441023 subu r2,r2,r4      r2 = r2 - r4
00183c74: 00021180 sll r2,r2,0x06      r2 *
00183c78: 3c038019 lui r3,0x8019      
00183c7c: 246308cc addiu r3,r3,0x08cc      Unit Data pointer?
00183c80: 00433821 addu r7,r2,r3      Get certain unit data
00183c84: 3c018019 lui r1,0x8019      
00183c88: 00220821 addu r1,r1,r2
00183c8c: 902308cd lbu r3,0x08cd(r1)      ?
00183c90: 340200ff ori r2,r0,0x00ff      r2 = ff
00183c94: 1062001c beq r3,r2,0x00183d08      skip routine if equal
00183c98: 34020001 ori r2,r0,0x0001      r2 = 01
00183c9c: 90e20186 lbu r2,0x0186(r7)      Load Characters turn
00183ca0: 00000000 nop
00183ca4: 10400018 beq r2,r0,0x00183d08      Skip routine if turn over
00183ca8: 34020001 ori r2,r0,0x0001
00183cac: 90e60039 lbu r6,0x0039(r7)      Load CT?
00183cb0: 90e3005c lbu r3,0x005c(r7)      load status
00183cb4: 90e50187 lbu r5,0x0187(r7)      Load movement taken
00183cb8: 90e40188 lbu r4,0x0188(r7)      Load action taken
00183cbc: 30620008 andi r2,r3,0x0008      Don't move check
00183cc0: 00a22825 or r5,r5,r2         r5 = 1 if no movement allowed
00183cc4: 30630004 andi r3,r3,0x0004      r3 = 1 if don't act status
00183cc8: 90e20058 lbu r2,0x0058(r7)      load performing check?
00183ccc: 00641825 or r3,r3,r4         r3 = 1 if don't act or action taken
00183cd0: 30420001 andi r2,r2,0x0001      r2 = 1 if performing?
00183cd4: 14a00002 bne r5,r0,0x00183ce0      branch if movement taken?
00183cd8: 00621825 or r3,r3,r2         r3 = 1 if don't act, action taken, or performing
00183cdc: 24c60014 addiu r6,r6,0x0014      Award 20 CT?
00183ce0: 14600003 bne r3,r0,0x00183cf0      Branch if action taken?
00183ce4: 30c2ffff andi r2,r6,0xffff      
00183ce8: 24c60014 addiu r6,r6,0x0014      Award 20 CT?
00183cec: 30c2ffff andi r2,r6,0xffff
00183cf0: 2c42003d sltiu r2,r2,0x003d      If CT < 61?
00183cf4: 14400002 bne r2,r0,0x00183d00      branch if ct = 0
00183cf8: 34020001 ori r2,r0,0x0001      r2 = 01?
00183cfc: 3406003c ori r6,r0,0x003c      r6 = 01?
00183d00: a0e60039 sb r6,0x0039(r7)      store r6 as CT
00183d04: a0e00186 sb r0,0x0186(r7)      store store turn over
00183d08: 03e00008 jr r31
00183d0c: 00000000 nop

Able to move/Act checks (loading menu?)
00183d10: 27bdffe8 addiu r29,r29,0xffe8
00183d14: afb00010 sw r16,0x0010(r29)
00183d18: afbf0014 sw r31,0x0014(r29)
00183d1c: 0c0604c3 jal 0x0018130c
00183d20: 00808021 addu r16,r4,r0
00183d24: 9204005c lbu r4,0x005c(r16)      Load Current Status
00183d28: 92030187 lbu r3,0x0187(r16)      Load Movement Taken
00183d2c: 92050188 lbu r5,0x0188(r16)      Load Action Taken
00183d30: 30840008 andi r4,r4,0x0008      r4 = 1 if Don't Move
00183d34: 00642025 or r4,r3,r4         r4 = 1 if Don't move or movement taken
00183d38: 00a23025 or r6,r5,r2         r6=1 if action taken or ?? stop ride?
00183d3c: 00001021 addu r2,r0,r0
00183d40: 00651825 or r3,r3,r5         if movement taken or action taken
00183d44: 10800005 beq r4,r0,0x00183d5c      branch if don't move or movement taken?
00183d48: 00602821 addu r5,r3,r0      
00183d4c: 30c300ff andi r3,r6,0x00ff
00183d50: 10600002 beq r3,r0,0x00183d5c      brance if neither moved nor acted
00183d54: 00000000 nop
00183d58: 0005102b sltu r2,r0,r5      r2=1 if action taken or movement taken?
00183d5c: 8fbf0014 lw r31,0x0014(r29)
00183d60: 8fb00010 lw r16,0x0010(r29)
00183d64: 27bd0018 addiu r29,r29,0x0018
00183d68: 03e00008 jr r31
00183d6c: 00000000 nop
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on February 13, 2012, 05:49:07 pm
I've seen alot of people interested in looking at AI, so here's a disassembly of what I think is most of the AI routines. I pointed out where they reference unit data and do checks that I could decipher, but most of it references unknown locations.

801af3c4 - This address is referenced in quite a few of the routines and is preceded by about 0x10000 of AI data. I'm not sure if all that space is filled up, but it seems to be where all the AI stuff is going on
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on February 15, 2012, 10:32:31 pm
Please visit the Wiki page "Routine Locations" and add any routines that aren't up there already if you have time. I can't get the formatting to work correctly on the wiki when posting routines. If anybody figures it out let me know please! thanks! Oh also try to keep them in order of location!

http://ffhacktics.com/wiki/Routine_Locations
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Glain on February 16, 2012, 11:13:23 pm
Here's some of the elemental stuff. I've written comments as valid C/C++ code, because why not. I had to use code tags so that my formatting didn't get butchered. Doesn't seem you can spoiler code tags... hmm.

186ff8: Apply Elemental

void apply_elemental()

00186ff8: 3c028019 lui r2,0x8019
00186ffc: 8c422d98 lw r2,0x2d98(r2)
00187000: 27bdffe8 addiu r29,r29,0xffe8
00187004: afbf0014 sw r31,0x0014(r29)
00187008: afb00010 sw r16,0x0010(r29)
0018700c: 9042005a lbu r2,0x005a(r2)
00187010: 3c108019 lui r16,0x8019
00187014: 921038f7 lbu r16,0x38f7(r16)
00187018: 30420080 andi r2,r2,0x0080
0018701c: 10400015 beq r2,r0,0x00187074
00187020: 32020080 andi r2,r16,0x0080
00187024: 10400013 beq r2,r0,0x00187074 # if ((target[UNIT_STATUS_FLAGS_3] & STATUS_OIL) && (ability_element == ELEMENT_FIRE))
00187028: 00002021 addu r4,r0,r0 # {
0018702c: 3c028019 lui r2,0x8019
00187030: 844238ce lh r2,0x38ce(r2)
00187034: 3c038019 lui r3,0x8019
00187038: 8c632d90 lw r3,0x2d90(r3)
0018703c: 00021040 sll r2,r2,0x01
00187040: 3c018019 lui r1,0x8019
00187044: a42238ce sh r2,0x38ce(r1) # action_XA = action_XA * 2
00187048: 90620022 lbu r2,0x0022(r3)
0018704c: 00000000 nop
00187050: 34420080 ori r2,r2,0x0080 # action[STATUS_REMOVAL_3] = action[STATUS_REMOVAL_3] | STATUS_OIL
00187054: 0c0612c9 jal 0x00184b24
00187058: a0620022 sb r2,0x0022(r3)
0018705c: 10400005 beq r2,r0,0x00187074 # if (validate_status_changes(false) != 0) // If this action changes a status
00187060: 34020008 ori r2,r0,0x0008 # {
00187064: 3c038019 lui r3,0x8019
00187068: 8c632d90 lw r3,0x2d90(r3)
0018706c: 00000000 nop # action[ACTION_TYPE] = ACTION_TYPE_STATUS_CHANGE;
00187070: a0620025 sb r2,0x0025(r3) # }
00187074: 3c038019 lui r3,0x8019 # }
00187078: 8c632d98 lw r3,0x2d98(r3) # Unit affected_unit = target;
0018707c: 00000000 nop
00187080: 90640182 lbu r4,0x0182(r3)
00187084: 00000000 nop
00187088: 30820080 andi r2,r4,0x0080
0018708c: 10400007 beq r2,r0,0x001870ac # if (target[UNIT_FLAGS_0x182] & UNIT_FLAGS_0x182_RIDING_CHOCOBO)
00187090: 3082001f andi r2,r4,0x001f # {
00187094: 000218c0 sll r3,r2,0x03 # int ridden_unit_index = target[UNIT_FLAGS_0x182] & 0x1f;
00187098: 00621823 subu r3,r3,r2
0018709c: 00031980 sll r3,r3,0x06
001870a0: 3c028019 lui r2,0x8019
001870a4: 244208cc addiu r2,r2,0x08cc
001870a8: 00621821 addu r3,r3,r2 # affected_unit = units[ridden_unit_index];
001870ac: 9062005a lbu r2,0x005a(r3) # }
001870b0: 00000000 nop
001870b4: 30420040 andi r2,r2,0x0040
001870b8: 10400009 beq r2,r0,0x001870e0
001870bc: 32020008 andi r2,r16,0x0008
001870c0: 10400007 beq r2,r0,0x001870e0 # if ((units[affected_unit][UNIT_STATUS_FLAGS_3] & STATUS_FLOAT) && (ability_element == ELEMENT_EARTH))
001870c4: 00000000 nop # {
001870c8: 0c061390 jal 0x00184e40 # nullify_action();
001870cc: 00000000 nop
001870d0: 3c038019 lui r3,0x8019
001870d4: 8c632d90 lw r3,0x2d90(r3)
001870d8: 34020007 ori r2,r0,0x0007 # action[EVADE_TYPE] = EVADE_TYPE_FLOATING;
001870dc: a0620002 sb r2,0x0002(r3) # }
001870e0: 0c0613a6 jal 0x00184e98 # apply_elemental_unit_modifiers(ability_element);
001870e4: 02002021 addu r4,r16,r0
001870e8: 8fbf0014 lw r31,0x0014(r29)
001870ec: 8fb00010 lw r16,0x0010(r29)
001870f0: 27bd0018 addiu r29,r29,0x0018
001870f4: 03e00008 jr r31 # return;
001870f8: 00000000 nop


184b24: Validate status changes

int validate_status_changes(bool p_IgnoreInvalidStatusChanges)

00184b24: 00803821 addu r7,r4,r0
00184b28: 3c028019 lui r2,0x8019
00184b2c: 8c422d98 lw r2,0x2d98(r2)
00184b30: 00005021 addu r10,r0,r0 # int result = 0;
00184b34: 90430005 lbu r3,0x0005(r2)
00184b38: 90420182 lbu r2,0x0182(r2)
00184b3c: 00000000 nop # int flags;
00184b40: 30420080 andi r2,r2,0x0080
00184b44: 1040000f beq r2,r0,0x00184b84 # if (target[UNIT_FLAGS_0x182] & UNIT_FLAGS_0x182_RIDING_CHOCOBO)
00184b48: 30680004 andi r8,r3,0x0004 # {
00184b4c: 00003021 addu r6,r0,r0 # for (int i=0; i < 5; i++)
00184b50: 3c038019 lui r3,0x8019 # {
00184b54: 8c632d90 lw r3,0x2d90(r3)
00184b58: 3c018019 lui r1,0x8019
00184b5c: 00260821 addu r1,r1,r6
00184b60: 9024f60c lbu r4,-0x09f4(r1)
00184b64: 00661821 addu r3,r3,r6
00184b68: 9062001b lbu r2,0x001b(r3)
00184b6c: 24c60001 addiu r6,r6,0x0001
00184b70: 00441024 and r2,r2,r4
00184b74: a062001b sb r2,0x001b(r3) # action[ACTION_STATUS_INFLICTION_FLAGS_1 + i] &= array_18f60c[i];
00184b78: 28c20005 slti r2,r6,0x0005
00184b7c: 1440fff4 bne r2,r0,0x00184b50 # }
00184b80: 00000000 nop # }
00184b84: 3c048019 lui r4,0x8019
00184b88: 8c842d90 lw r4,0x2d90(r4)
00184b8c: 00000000 nop
00184b90: 9083001d lbu r3,0x001d(r4)
00184b94: 00000000 nop
00184b98: 30620002 andi r2,r3,0x0002
00184b9c: 10400013 beq r2,r0,0x00184bec # if (action[ACTION_STATUS_INFLICTION_FLAGS_3] & STATUS_FROG)
00184ba0: 00003021 addu r6,r0,r0 # {
00184ba4: 3c028019 lui r2,0x8019
00184ba8: 8c422d98 lw r2,0x2d98(r2)
00184bac: 00000000 nop
00184bb0: 9042005a lbu r2,0x005a(r2)
00184bb4: 00000000 nop
00184bb8: 30420002 andi r2,r2,0x0002
00184bbc: 1040000b beq r2,r0,0x00184bec
00184bc0: 00000000 nop
00184bc4: 14e00009 bne r7,r0,0x00184bec # if ((target[UNIT_STATUS_FLAGS_3] & STATUS_FROG) && (!p_IgnoreInvalidStatusChanges))
00184bc8: 306200fd andi r2,r3,0x00fd # {
00184bcc: a082001d sb r2,0x001d(r4) # action[ACTION_STATUS_INFLICTION_FLAGS_3] &= 0xFD; // Removes "Frog" from status inflict list
00184bd0: 3c038019 lui r3,0x8019
00184bd4: 8c632d90 lw r3,0x2d90(r3)
00184bd8: 00000000 nop
00184bdc: 90620022 lbu r2,0x0022(r3) # action[ACTION_STATUS_REMOVAL_FLAGS_3] |= STATUS_FROG; // Adds "Frog" to status removal list
00184be0: 00000000 nop
00184be4: 34420002 ori r2,r2,0x0002 # }
00184be8: a0620022 sb r2,0x0022(r3) # }
00184bec: 14e00023 bne r7,r0,0x00184c7c # for (int i=0; i < 5; i++)
00184bf0: 28c20003 slti r2,r6,0x0003 # {
00184bf4: 1040000a beq r2,r0,0x00184c20 # if (!p_IgnoreInvalidStatusChanges)
00184bf8: 00000000 nop # {
00184bfc: 3c058019 lui r5,0x8019 # if (i < 3)
00184c00: 8ca52d90 lw r5,0x2d90(r5) # {
00184c04: 3c028019 lui r2,0x8019
00184c08: 8c422d98 lw r2,0x2d98(r2)
00184c0c: 00000000 nop
00184c10: 00461021 addu r2,r2,r6
00184c14: 90430058 lbu r3,0x0058(r2) # flags = target[UNIT_STATUS_FLAGS_1 + i] // Can't be reapplied
00184c18: 0806130f j 0x00184c3c
00184c1c: 00a62821 addu r5,r5,r6 # }
00184c20: 3c058019 lui r5,0x8019 # else
00184c24: 8ca52d90 lw r5,0x2d90(r5) # {
00184c28: 3c028019 lui r2,0x8019
00184c2c: 8c422d98 lw r2,0x2d98(r2)
00184c30: 00a62821 addu r5,r5,r6
00184c34: 00461021 addu r2,r2,r6 # flags = target[UNIT_AUTO_STATUS_FLAGS_1 + i] // Can be reapplied
00184c38: 9043004e lbu r3,0x004e(r2) # }
00184c3c: 90440053 lbu r4,0x0053(r2)
00184c40: 90a2001b lbu r2,0x001b(r5)
00184c44: 00641827 nor r3,r3,r4
00184c48: 00431024 and r2,r2,r3 # action[STATUS_INFLICT_1 + i] &= !(flags | target[STATUS_IMMUNE_1 + i]);
00184c4c: 1100000b beq r8,r0,0x00184c7c # if (target[UNIT_TEAM_FLAGS] & TEAM_FLAGS_IMMORTAL)
00184c50: a0a2001b sb r2,0x001b(r5) # {
00184c54: 3c028019 lui r2,0x8019
00184c58: 8c422d90 lw r2,0x2d90(r2)
00184c5c: 3c018006 lui r1,0x8006
00184c60: 00260821 addu r1,r1,r6
00184c64: 902362ee lbu r3,0x62ee(r1)
00184c68: 00461021 addu r2,r2,r6
00184c6c: 9044001b lbu r4,0x001b(r2)
00184c70: 00031827 nor r3,r0,r3 # action[STATUS_INFLICT_1 + i] &= !array_0662ee[i];
00184c74: 00832024 and r4,r4,r3 # }
00184c78: a044001b sb r4,0x001b(r2) # }
00184c7c: 3c058019 lui r5,0x8019
00184c80: 8ca52d90 lw r5,0x2d90(r5)
00184c84: 3c048019 lui r4,0x8019
00184c88: 8c842d98 lw r4,0x2d98(r4)
00184c8c: 00a62821 addu r5,r5,r6
00184c90: 00862021 addu r4,r4,r6
00184c94: 24c60001 addiu r6,r6,0x0001
00184c98: 9083004e lbu r3,0x004e(r4)
00184c9c: 90a20020 lbu r2,0x0020(r5)
00184ca0: 908401bb lbu r4,0x01bb(r4)
00184ca4: 00031827 nor r3,r0,r3
00184ca8: 00431024 and r2,r2,r3
00184cac: 00441024 and r2,r2,r4
00184cb0: a0a20020 sb r2,0x0020(r5) # action[STATUS_REMOVAL_1 + i] &= !target[UNIT_AUTO_STATUS_FLAGS_1 + i] & target[0x1bb + i];
00184cb4: 28c20005 slti r2,r6,0x0005
00184cb8: 1440ffcc bne r2,r0,0x00184bec # }
00184cbc: 00000000 nop
00184cc0: 14e00051 bne r7,r0,0x00184e08 # if (!p_IgnoreInvalidStatusChanges)
00184cc4: 00003021 addu r6,r0,r0 # {
00184cc8: 340b0080 ori r11,r0,0x0080 #
00184ccc: 3c098006 lui r9,0x8006 # for (int i=0; i < 40; i++)
00184cd0: 25295def addiu r9,r9,0x5def # {
00184cd4: 04c10002 bgez r6,0x00184ce0 #
00184cd8: 00c01021 addu r2,r6,r0
00184cdc: 24c20007 addiu r2,r6,0x0007
00184ce0: 000238c3 sra r7,r2,0x03
00184ce4: 3c028019 lui r2,0x8019
00184ce8: 8c422d90 lw r2,0x2d90(r2)
00184cec: 30c30007 andi r3,r6,0x0007
00184cf0: 00471021 addu r2,r2,r7
00184cf4: 9042001b lbu r2,0x001b(r2) # int action_status_flags = action[STATUS_INFLICT_1 + (i / 8)]; // Integer division
00184cf8: 006b1807 srav r3,r11,r3 # char current_flag = 0x80 >> (i % 8);
00184cfc: 00431024 and r2,r2,r3
00184d00: 10400019 beq r2,r0,0x00184d68 # if (action_status_flags & current_flag) // Does ability inflict this status?
00184d04: 00000000 nop # {
00184d08: 00002821 addu r5,r0,r0
00184d0c: 00034027 nor r8,r0,r3
00184d10: 01202021 addu r4,r9,r0
00184d14: 3c028019 lui r2,0x8019 # for (int j=0; j < 5; j++)
00184d18: 8c422d98 lw r2,0x2d98(r2) # {
00184d1c: 90830000 lbu r3,0x0000(r4)
00184d20: 00451021 addu r2,r2,r5
00184d24: 90420058 lbu r2,0x0058(r2)
00184d28: 00000000 nop
00184d2c: 00431024 and r2,r2,r3
00184d30: 10400009 beq r2,r0,0x00184d58 # if (target[STATUS_FLAGS_1 + j] & status[i][NO_STACK_1 + j])
00184d34: 24840001 addiu r4,r4,0x0001 # {
00184d38: 3c038019 lui r3,0x8019
00184d3c: 8c632d90 lw r3,0x2d90(r3)
00184d40: 00000000 nop
00184d44: 00671821 addu r3,r3,r7
00184d48: 9062001b lbu r2,0x001b(r3)
00184d4c: 00000000 nop
00184d50: 00481024 and r2,r2,r8 # action[STATUS_INFLICT_1 + (i / 8)] &= !current_flag;
00184d54: a062001b sb r2,0x001b(r3) # }
00184d58: 24a50001 addiu r5,r5,0x0001
00184d5c: 28a20005 slti r2,r5,0x0005
00184d60: 1440ffec bne r2,r0,0x00184d14 # }
00184d64: 00000000 nop # }
00184d68: 24c60001 addiu r6,r6,0x0001
00184d6c: 28c20028 slti r2,r6,0x0028
00184d70: 1440ffd8 bne r2,r0,0x00184cd4 # }
00184d74: 25290010 addiu r9,r9,0x0010
00184d78: 00003021 addu r6,r0,r0
00184d7c: 34090080 ori r9,r0,0x0080
00184d80: 3c088006 lui r8,0x8006
00184d84: 25085dea addiu r8,r8,0x5dea #
00184d88: 04c10002 bgez r6,0x00184d94 # for (int i=0; i < 40; i++)
00184d8c: 00c01021 addu r2,r6,r0 # {
00184d90: 24c20007 addiu r2,r6,0x0007
00184d94: 000238c3 sra r7,r2,0x03
00184d98: 3c028019 lui r2,0x8019
00184d9c: 8c422d90 lw r2,0x2d90(r2)
00184da0: 30c30007 andi r3,r6,0x0007
00184da4: 00471021 addu r2,r2,r7
00184da8: 9042001b lbu r2,0x001b(r2) # int action_status_flags = action[STATUS_INFLICT_1 + (i / 8)]; // Integer division
00184dac: 00691807 srav r3,r9,r3 # char current_flag = 0x80 >> (i % 8);
00184db0: 00431024 and r2,r2,r3
00184db4: 1040000f beq r2,r0,0x00184df4 # if (action_status_flags & current_flag) // Does ability inflict this status?
00184db8: 00000000 nop # {
00184dbc: 00002821 addu r5,r0,r0
00184dc0: 01003821 addu r7,r8,r0
00184dc4: 3c048019 lui r4,0x8019 # for (int j=0; j < 5; j++)
00184dc8: 8c842d90 lw r4,0x2d90(r4) # {
00184dcc: 90e30000 lbu r3,0x0000(r7)
00184dd0: 00852021 addu r4,r4,r5
00184dd4: 24a50001 addiu r5,r5,0x0001
00184dd8: 9082001b lbu r2,0x001b(r4)
00184ddc: 00031827 nor r3,r0,r3
00184de0: 00431024 and r2,r2,r3
00184de4: a082001b sb r2,0x001b(r4) # action[STATUS_INFLICT_1 + j] &= status[i][STATUS_CANCELS_1 + j];
00184de8: 28a20005 slti r2,r5,0x0005
00184dec: 1440fff5 bne r2,r0,0x00184dc4 # }
00184df0: 24e70001 addiu r7,r7,0x0001
00184df4: 24c60001 addiu r6,r6,0x0001
00184df8: 28c20028 slti r2,r6,0x0028
00184dfc: 1440ffe2 bne r2,r0,0x00184d88 # }
00184e00: 25080010 addiu r8,r8,0x0010 # }
00184e04: 00003021 addu r6,r0,r0 # for (int i=0; i < 5; i++)
00184e08: 3c048019 lui r4,0x8019 # {
00184e0c: 8c842d90 lw r4,0x2d90(r4)
00184e10: 00000000 nop
00184e14: 00861821 addu r3,r4,r6
00184e18: 24c60001 addiu r6,r6,0x0001
00184e1c: 9062001b lbu r2,0x001b(r3)
00184e20: 90630020 lbu r3,0x0020(r3)
00184e24: 01421021 addu r2,r10,r2
00184e28: 00435021 addu r10,r2,r3 # result += action[STATUS_INFLICT_1 + i] + action[STATUS_REMOVAL_1 + i];
00184e2c: 28c20005 slti r2,r6,0x0005
00184e30: 1440fff7 bne r2,r0,0x00184e10 # }
00184e34: 00000000 nop
00184e38: 03e00008 jr r31 # return result; // "result" signifies whether a status was changed (non-zero=changed, zero=not)
00184e3c: 01401021 addu r2,r10,r0


184e98: Apply elemental unit modifiers

void apply_elemental_unit_modifiers(int p_abilityElement)

00184e98: 3c028019 lui r2,0x8019
00184e9c: 8c422d98 lw r2,0x2d98(r2)
00184ea0: 27bdffe8 addiu r29,r29,0xffe8
00184ea4: afbf0010 sw r31,0x0010(r29)
00184ea8: 9042006d lbu r2,0x006d(r2)
00184eac: 00802821 addu r5,r4,r0
00184eb0: 00451024 and r2,r2,r5
00184eb4: 10400008 beq r2,r0,0x00184ed8 # if (target[UNIT_ELEMENTAL_ABSORB] & p_abilityElement)
00184eb8: 00000000 nop # {
00184ebc: 3c038019 lui r3,0x8019
00184ec0: 8c632d90 lw r3,0x2d90(r3)
00184ec4: 00000000 nop
00184ec8: 94620010 lhu r2,0x0010(r3)
00184ecc: 00000000 nop
00184ed0: 34420400 ori r2,r2,0x0400 # action[0x11] = action[0x11] | 0x04;
00184ed4: a4620010 sh r2,0x0010(r3) # }
00184ed8: 3c038019 lui r3,0x8019
00184edc: 8c632d98 lw r3,0x2d98(r3)
00184ee0: 00000000 nop
00184ee4: 9062006e lbu r2,0x006e(r3)
00184ee8: 00000000 nop
00184eec: 00451024 and r2,r2,r5
00184ef0: 10400005 beq r2,r0,0x00184f08 # if (target[UNIT_ELEMENTAL_CANCEL] & p_AbilityElement)
00184ef4: 00000000 nop # {
00184ef8: 0c061390 jal 0x00184e40 # nullify_action();
00184efc: 00000000 nop
00184f00: 080613e3 j 0x00184f8c # return;
00184f04: 00000000 nop # }
00184f08: 9062006f lbu r2,0x006f(r3)
00184f0c: 00000000 nop
00184f10: 00451024 and r2,r2,r5
00184f14: 1040000c beq r2,r0,0x00184f48 # if (target[UNIT_ELEMENTAL_HALF] & p_AbilityElement)
00184f18: 00000000 nop # {
00184f1c: 3c028019 lui r2,0x8019
00184f20: 8c422d90 lw r2,0x2d90(r2)
00184f24: 00000000 nop
00184f28: 94430004 lhu r3,0x0004(r2)
00184f2c: 00000000 nop
00184f30: 00031c00 sll r3,r3,0x10
00184f34: 00032403 sra r4,r3,0x10
00184f38: 00031fc2 srl r3,r3,0x1f
00184f3c: 00832021 addu r4,r4,r3
00184f40: 00042043 sra r4,r4,0x01 # action[ACTION_HP_DAMAGE] = action[ACTION_HP_DAMAGE] / 2;
00184f44: a4440004 sh r4,0x0004(r2) # }
00184f48: 3c028019 lui r2,0x8019
00184f4c: 8c422d98 lw r2,0x2d98(r2)
00184f50: 00000000 nop
00184f54: 90420070 lbu r2,0x0070(r2)
00184f58: 00000000 nop
00184f5c: 00451024 and r2,r2,r5
00184f60: 1040000a beq r2,r0,0x00184f8c # if (target[UNIT_ELEMENTAL_WEAK] & p_AbilityElement)
00184f64: 00000000 nop # {
00184f68: 3c028019 lui r2,0x8019
00184f6c: 8c422d90 lw r2,0x2d90(r2)
00184f70: 00000000 nop
00184f74: 94430010 lhu r3,0x0010(r2)
00184f78: 84440004 lh r4,0x0004(r2)
00184f7c: 34630800 ori r3,r3,0x0800
00184f80: 00042040 sll r4,r4,0x01
00184f84: a4430010 sh r3,0x0010(r2) # action[0x11] = action[0x11] | 0x08;
00184f88: a4440004 sh r4,0x0004(r2) # action[ACTION_HP_DAMAGE] = action[ACTION_HP_DAMAGE] * 2;
00184f8c: 8fbf0010 lw r31,0x0010(r29) # }
00184f90: 27bd0018 addiu r29,r29,0x0018
00184f94: 03e00008 jr r31 # return;
00184f98: 00000000 nop


184e40: Nullify action

void nullify_action()

00184e40: 3c028019 lui r2,0x8019
00184e44: 8c422d90 lw r2,0x2d90(r2)
00184e48: 27bdffe8 addiu r29,r29,0xffe8
00184e4c: afbf0010 sw r31,0x0010(r29)
00184e50: a0400000 sb r0,0x0000(r2) # action[ACTION_HIT_STATUS] = HIT_STATUS_MISS;
00184e54: 3c038019 lui r3,0x8019
00184e58: 8c632d90 lw r3,0x2d90(r3)
00184e5c: 34020005 ori r2,r0,0x0005
00184e60: a0620002 sb r2,0x0002(r3) # action[ACTION_EVADE_TYPE] = EVADE_TYPE_NULLIFIED;
00184e64: 3c028019 lui r2,0x8019
00184e68: 8c422d90 lw r2,0x2d90(r2)
00184e6c: a4600004 sh r0,0x0004(r3) # action[ACTION_HP_DAMAGE] = 0;
00184e70: a460002a sh r0,0x002a(r3) # action[ACTION_HIT_PERCENT_SELF] = 0;
00184e74: a4600010 sh r0,0x0010(r3) # action[0x10] = 0; action[ACTION_TYPE] = ACTION_TYPE_NOTHING;
00184e78: 0c062f3c jal 0x0018bcf0 # func_18bcf0();
00184e7c: a0400025 sb r0,0x0025(r2)
00184e80: 0c062f4d jal 0x0018bd34 # func_18bd34();
00184e84: 00000000 nop
00184e88: 8fbf0010 lw r31,0x0010(r29) # return;
00184e8c: 27bd0018 addiu r29,r29,0x0018
00184e90: 03e00008 jr r31
00184e94: 00000000 nop


Here's a few functions, called by nullify_action() above (0x184e40), where I can see what's happening but don't understand the significance:


void func_18bcf0()

0018bcf0: 3c048019 lui r4,0x8019
0018bcf4: 248438c8 addiu r4,r4,0x38c8
0018bcf8: 94820000 lhu r2,0x0000(r4)
0018bcfc: 00000000 nop
0018bd00: 1040000a beq r2,r0,0x0018bd2c # if (var_1938c8 == 0) return;
0018bd04: 00000000 nop
0018bd08: 3c038019 lui r3,0x8019
0018bd0c: 8c632d90 lw r3,0x2d90(r3)
0018bd10: 3c018019 lui r1,0x8019
0018bd14: a42038c6 sh r0,0x38c6(r1) # var_1938c6 = 0;
0018bd18: a4800000 sh r0,0x0000(r4) # var_1938c8 = 0;
0018bd1c: 94620010 lhu r2,0x0010(r3)
0018bd20: 00000000 nop
0018bd24: 3042fdff andi r2,r2,0xfdff
0018bd28: a4620010 sh r2,0x0010(r3) # action[0x11] &= 0xfd; // Remove flag 0x02 from action[0x11]
0018bd2c: 03e00008 jr r31 # return;
0018bd30: 00000000 nop



void func_18bd34()

0018bd34: 3c048019 lui r4,0x8019
0018bd38: 248438ed addiu r4,r4,0x38ed
0018bd3c: 90820000 lbu r2,0x0000(r4)
0018bd40: 00000000 nop
0018bd44: 30420080 andi r2,r2,0x0080
0018bd48: 10400008 beq r2,r0,0x0018bd6c # if (!(var_1938ed & 0x80)) return;
0018bd4c: 00000000 nop
0018bd50: 3c038019 lui r3,0x8019
0018bd54: 8c632d90 lw r3,0x2d90(r3)
0018bd58: a0800000 sb r0,0x0000(r4) # var_1938ed = 0;
0018bd5c: 94620010 lhu r2,0x0010(r3)
0018bd60: 00000000 nop
0018bd64: 3042bfff andi r2,r2,0xbfff
0018bd68: a4620010 sh r2,0x0010(r3) # action[0x11] &= 0xbf; // Remove flag 0x20 from action[0x11]
0018bd6c: 03e00008 jr r31 # return;
0018bd70: 00000000 nop

Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on February 17, 2012, 03:27:36 pm
Here's an interesting routine. This carries out some of the residual effects of an action - transparent removal, chicken brave increment/status application, critical status application/removal, etc. Its also on the wiki I think if anybody wants to fill the holes.

Its a huge routine and it loads the target's action and data pointers about 50 billion times.

0018be08: 27bdffc8 addiu r29,r29,0xffc8
0018be0c: afb20030 sw r18,0x0030(r29)
0018be10: 00809021 addu r18,r4,r0
0018be14: afb00028 sw r16,0x0028(r29)
0018be18: 00008021 addu r16,r0,r0
0018be1c: 2a420015 slti r2,r18,0x0015
0018be20: afbf0034 sw r31,0x0034(r29)
0018be24: 10400013 beq r2,r0,0x0018be74
0018be28: afb1002c sw r17,0x002c(r29)
0018be2c: 001218c0 sll r3,r18,0x03
0018be30: 00721823 subu r3,r3,r18
0018be34: 00031980 sll r3,r3,0x06
0018be38: 3c028019 lui r2,0x8019
0018be3c: 244208cc addiu r2,r2,0x08cc      Unit Data
0018be40: 00622021 addu r4,r3,r2      
0018be44: 2442018c addiu r2,r2,0x018c      
0018be48: 00622821 addu r5,r3,r2      
0018be4c: 3c018019 lui r1,0x8019      
0018be50: a03238c1 sb r18,0x38c1(r1)      AI action data?
0018be54: 3c018019 lui r1,0x8019      
0018be58: ac242d98 sw r4,0x2d98(r1)      store targte data
0018be5c: 3c018019 lui r1,0x8019      
0018be60: ac252d90 sw r5,0x2d90(r1)      store target action
0018be64: 90830001 lbu r3,0x0001(r4)      
0018be68: 340200ff ori r2,r0,0x00ff      
0018be6c: 14620003 bne r3,r2,0x0018be7c      
0018be70: 00000000 nop            
0018be74: 08063199 j 0x0018c664         
0018be78: 2402ffff addiu r2,r0,0xffff      
0018be7c: 90820058 lbu r2,0x0058(r4)      Load First Set of Current Status   
0018be80: 00000000 nop            
0018be84: 30420020 andi r2,r2,0x0020      
0018be88: 1040000f beq r2,r0,0x0018bec8      Branch if unit is not dead?
0018be8c: 00000000 nop            
0018be90: 90a2001b lbu r2,0x001b(r5)      status infliction 1
0018be94: 00000000 nop
0018be98: 30420040 andi r2,r2,0x0040      
0018be9c: 14400006 bne r2,r0,0x0018beb8      branch if crystal inflicted
0018bea0: 02402021 addu r4,r18,r0
0018bea4: 90a2001c lbu r2,0x001c(r5)      status infliction 2
0018bea8: 00000000 nop
0018beac: 30420001 andi r2,r2,0x0001
0018beb0: 10400005 beq r2,r0,0x0018bec8      branch if treasure inflicted
0018beb4: 00000000 nop
0018beb8: 0c06381f jal 0x0018e07c      ????
0018bebc: 00002821 addu r5,r0,r0
0018bec0: 08063199 j 0x0018c664         jump to end
0018bec4: 00001021 addu r2,r0,r0
0018bec8: 3c028019 lui r2,0x8019
0018becc: 8c42f5f0 lw r2,-0x0a10(r2)
0018bed0: 00000000 nop
0018bed4: 14400005 bne r2,r0,0x0018beec
0018bed8: 34020001 ori r2,r0,0x0001
0018bedc: 3c038019 lui r3,0x8019
0018bee0: 8c632d98 lw r3,0x2d98(r3)      Load Defender's Data
0018bee4: 00000000 nop            
0018bee8: a0620189 sb r2,0x0189(r3)      
0018beec: 0c0632c0 jal 0x0018cb00      Sunken State, Caution, Dragon Spirit, Brave Up, Face Up, Counter Tackle, Counter Flood, Absorb Used MP, Counter, Counter Magic usability
0018bef0: 00000000 nop            
0018bef4: 3c058019 lui r5,0x8019      
0018bef8: 8ca52d90 lw r5,0x2d90(r5)      Load Defender's Current Action Data
0018befc: 00000000 nop            
0018bf00: 84a3000e lh r3,0x000e(r5)      Load Reaction ID
0018bf04: 340201c2 ori r2,r0,0x01c2      
0018bf08: 14620006 bne r3,r2,0x0018bf24      Branch if Reaction ID isn't Catch
0018bf0c: 00000000 nop            
0018bf10: 3c048019 lui r4,0x8019      
0018bf14: 8c842d98 lw r4,0x2d98(r4)      Load Target Data
0018bf18: 90a50026 lbu r5,0x0026(r5)      Load Last Attack?
0018bf1c: 0c063a7a jal 0x0018e9e8      Store Caught Item in Inventory
0018bf20: 00000000 nop            
0018bf24: 3c048019 lui r4,0x8019      
0018bf28: 8c842d90 lw r4,0x2d90(r4)      Load Defender's Current Action Data
0018bf2c: 00000000 nop            
0018bf30: 90820000 lbu r2,0x0000(r4)      Load Hit Flag
0018bf34: 00000000 nop            
0018bf38: 104001ca beq r2,r0,0x0018c664      Branch if Attack Missed
0018bf3c: 00001021 addu r2,r0,r0      
0018bf40: 94830010 lhu r3,0x0010(r4)      load special flags
0018bf44: 00000000 nop            
0018bf48: 30628000 andi r2,r3,0x8000      
0018bf4c: 10400013 beq r2,r0,0x0018bf9c      ?
0018bf50: 30620001 andi r2,r3,0x0001      
0018bf54: 3c028019 lui r2,0x8019      
0018bf58: 8c422d98 lw r2,0x2d98(r2)      Load Defender's Data
0018bf5c: 00000000 nop            
0018bf60: 904201ba lbu r2,0x01ba(r2)      modified ENTD flags
0018bf64: 3c038019 lui r3,0x8019      
0018bf68: 2463f5f4 addiu r3,r3,0xf5f4      
0018bf6c: 30420030 andi r2,r2,0x0030      enemy team check
0018bf70: 000210c2 srl r2,r2,0x03      
0018bf74: 00432821 addu r5,r2,r3      
0018bf78: 94a30000 lhu r3,0x0000(r5)      Load Hit Flag
0018bf7c: 84820004 lh r2,0x0004(r4)      Load HP Damage
0018bf80: 00000000 nop            
0018bf84: 00628823 subu r17,r3,r2      
0018bf88: 06210002 bgez r17,0x0018bf94      
0018bf8c: 00001021 addu r2,r0,r0      
0018bf90: 00008821 addu r17,r0,r0      
0018bf94: 08063199 j 0x0018c664         jump to end
0018bf98: a4b10000 sh r17,0x0000(r5)      store no hit
0018bf9c: 1040000b beq r2,r0,0x0018bfcc      
0018bfa0: 00000000 nop            
0018bfa4: 3c028019 lui r2,0x8019      
0018bfa8: 8c422d98 lw r2,0x2d98(r2)      Load Defender's Data
0018bfac: 34100001 ori r16,r0,0x0001      
0018bfb0: 90430005 lbu r3,0x0005(r2)      Load Defender's Team
0018bfb4: 9442002a lhu r2,0x002a(r2)      Load Defender's Max HP
0018bfb8: 30630030 andi r3,r3,0x0030      enemy team check
0018bfbc: 000318c2 srl r3,r3,0x03
0018bfc0: 3c018019 lui r1,0x8019
0018bfc4: 00230821 addu r1,r1,r3
0018bfc8: a422f5f4 sh r2,-0x0a0c(r1)
0018bfcc: 0c06330d jal 0x0018cc34      MP Switch, Distribute, Damage Split Check
0018bfd0: 00000000 nop            
0018bfd4: 3c058019 lui r5,0x8019      
0018bfd8: 8ca52d98 lw r5,0x2d98(r5)      Load Defender's Data
0018bfdc: 3c048019 lui r4,0x8019      
0018bfe0: 8c842d90 lw r4,0x2d90(r4)      Load Defender's Current Action Data
0018bfe4: 94a70028 lhu r7,0x0028(r5)      Load Defender's Current HP
0018bfe8: 84820004 lh r2,0x0004(r4)      Load HP Damage
0018bfec: 84830006 lh r3,0x0006(r4)      Load HP Recovery
0018bff0: 00e21023 subu r2,r7,r2      Defender's Current HP - HP Damage
0018bff4: 00438821 addu r17,r2,r3      Defender's Current HP - HP Damage + HP Recovery
0018bff8: 06210002 bgez r17,0x0018c004      Branch if >= 0
0018bffc: 00000000 nop            
0018c000: 00008821 addu r17,r0,r0      else unit ko'd
0018c004: 94a3002a lhu r3,0x002a(r5)      Load Defender's Max HP
0018c008: 00000000 nop            
0018c00c: 0071102a slt r2,r3,r17      If Defender's Max HP < above, r2 = 1;else is 0
0018c010: 10400002 beq r2,r0,0x0018c01c      branch if defenders max < hp recovery (cap check)
0018c014: 00000000 nop            
0018c018: 00608821 addu r17,r3,r0      r17 = max hp
0018c01c: 94a6002c lhu r6,0x002c(r5)      Load Defender's Current MP
0018c020: 84820008 lh r2,0x0008(r4)      Load MP Damage
0018c024: 8483000a lh r3,0x000a(r4)      Load MP Recovery
0018c028: 00c21023 subu r2,r6,r2      Defender's Current MP - MP Damage
0018c02c: 00431821 addu r3,r2,r3      Defender's Current MP - MP Damage + MP Recovery
0018c030: 04610002 bgez r3,0x0018c03c      Branch if >= 0
0018c034: 00000000 nop            
0018c038: 00001821 addu r3,r0,r0      
0018c03c: 94a4002e lhu r4,0x002e(r5)      Load Defender's Max MP
0018c040: 00000000 nop            
0018c044: 0083102a slt r2,r4,r3         If target max MP < above, r2 = 1; else is 0
0018c048: 10400002 beq r2,r0,0x0018c054      branch if max mp < mp recovery (cap?)
0018c04c: 00000000 nop            
0018c050: 00801821 addu r3,r4,r0      r3 = max mp
0018c054: 14f10003 bne r7,r17,0x0018c064   branch if current HP != max hp or 0?   
0018c058: 00000000 nop
0018c05c: 10c30003 beq r6,r3,0x0018c06c      branch if current mp != max mp or 0?
0018c060: 34060032 ori r6,r0,0x0032      r6 = 0x32
0018c064: 34100001 ori r16,r0,0x0001      r16 = 1
0018c068: 34060032 ori r6,r0,0x0032      um.. r6 = 0x32 again
0018c06c: 3c058019 lui r5,0x8019
0018c070: 8ca52d98 lw r5,0x2d98(r5)      target data
0018c074: 3c028019 lui r2,0x8019
0018c078: 8c422d90 lw r2,0x2d90(r2)      target action
0018c07c: 34070001 ori r7,r0,0x0001      r7 = 01
0018c080: a4b10028 sh r17,0x0028(r5)      Store current HP
0018c084: a4a3002c sh r3,0x002c(r5)      store current MP
0018c088: 90440012 lbu r4,0x0012(r2)      load speed change?      
0018c08c: 0c06355c jal 0x0018d570      stat change?
0018c090: 24a50032 addiu r5,r5,0x0032      target data + 0x32 (stat change prep?)
0018c094: 02028025 or r16,r16,r2      target action OR 0x01
0018c098: 340600ff ori r6,r0,0x00ff
0018c09c: 00003821 addu r7,r0,r0
0018c0a0: 3c028019 lui r2,0x8019
0018c0a4: 8c422d90 lw r2,0x2d90(r2)      target action
0018c0a8: 3c058019 lui r5,0x8019
0018c0ac: 8ca52d98 lw r5,0x2d98(r5)      target data
0018c0b0: 90440013 lbu r4,0x0013(r2)      load CT change
0018c0b4: 0c06355c jal 0x0018d570      stat change routine?
0018c0b8: 24a50039 addiu r5,r5,0x0039      (stat change prep)
0018c0bc: 02028025 or r16,r16,r2      
0018c0c0: 34060063 ori r6,r0,0x0063      
0018c0c4: 34070001 ori r7,r0,0x0001
0018c0c8: 3c028019 lui r2,0x8019
0018c0cc: 8c422d90 lw r2,0x2d90(r2)      target action
0018c0d0: 3c058019 lui r5,0x8019
0018c0d4: 8ca52d98 lw r5,0x2d98(r5)      target data
0018c0d8: 90440014 lbu r4,0x0014(r2)      load PA change
0018c0dc: 0c06355c jal 0x0018d570
0018c0e0: 24a50030 addiu r5,r5,0x0030
0018c0e4: 02028025 or r16,r16,r2
0018c0e8: 34060063 ori r6,r0,0x0063
0018c0ec: 34070001 ori r7,r0,0x0001
0018c0f0: 3c028019 lui r2,0x8019
0018c0f4: 8c422d90 lw r2,0x2d90(r2)      target action
0018c0f8: 3c058019 lui r5,0x8019
0018c0fc: 8ca52d98 lw r5,0x2d98(r5)      target data
0018c100: 90440015 lbu r4,0x0015(r2)      load MA change
0018c104: 0c06355c jal 0x0018d570
0018c108: 24a50031 addiu r5,r5,0x0031
0018c10c: 02028025 or r16,r16,r2
0018c110: 34060064 ori r6,r0,0x0064
0018c114: 3c038019 lui r3,0x8019
0018c118: 8c632d98 lw r3,0x2d98(r3)      target data
0018c11c: 3c028019 lui r2,0x8019
0018c120: 8c422d90 lw r2,0x2d90(r2)      target action
0018c124: 24650024 addiu r5,r3,0x0024      
0018c128: 90670182 lbu r7,0x0182(r3)      load mount info
0018c12c: 90440016 lbu r4,0x0016(r2)      load brave change
0018c130: 000739c2 srl r7,r7,0x07
0018c134: 00073823 subu r7,r0,r7
0018c138: 0c06355c jal 0x0018d570   
0018c13c: 30e7000a andi r7,r7,0x000a
0018c140: 02028025 or r16,r16,r2
0018c144: 34060064 ori r6,r0,0x0064
0018c148: 00003821 addu r7,r0,r0
0018c14c: 3c028019 lui r2,0x8019
0018c150: 8c422d90 lw r2,0x2d90(r2)      target action
0018c154: 3c058019 lui r5,0x8019
0018c158: 8ca52d98 lw r5,0x2d98(r5)      target data
0018c15c: 90440017 lbu r4,0x0017(r2)      load faith change
0018c160: 0c06355c jal 0x0018d570
0018c164: 24a50026 addiu r5,r5,0x0026
0018c168: 0c0634f0 jal 0x0018d3c0      Steal/break(?) Routine
0018c16c: 02028025 or r16,r16,r2
0018c170: 3c038019 lui r3,0x8019
0018c174: 8c632d90 lw r3,0x2d90(r3)      target action
0018c178: 00000000 nop
0018c17c: 94630010 lhu r3,0x0010(r3)      item to break/use
0018c180: 00000000 nop
0018c184: 30630008 andi r3,r3,0x0008      assassin dagger?
0018c188: 10600007 beq r3,r0,0x0018c1a8      
0018c18c: 02028025 or r16,r16,r2
0018c190: 3c048019 lui r4,0x8019
0018c194: 8c842d98 lw r4,0x2d98(r4)      target data
0018c198: 00000000 nop
0018c19c: 90850176 lbu r5,0x0176(r4)      load used item/equip ID
0018c1a0: 0c063a7a jal 0x0018e9e8      item increment   
0018c1a4: 00000000 nop
0018c1a8: 3c038019 lui r3,0x8019
0018c1ac: 8c632d90 lw r3,0x2d90(r3)      target action
0018c1b0: 00000000 nop
0018c1b4: 8462000c lh r2,0x000c(r3)      load gil lost/stolen      
0018c1b8: 00000000 nop
0018c1bc: 14400005 bne r2,r0,0x0018c1d4      skip if not 0
0018c1c0: 00000000 nop
0018c1c4: 90620028 lbu r2,0x0028(r3)      load stolen exp
0018c1c8: 00000000 nop
0018c1cc: 10400002 beq r2,r0,0x0018c1d8      skip if 0
0018c1d0: 00000000 nop
0018c1d4: 36100001 ori r16,r16,0x0001      sets 1 if exp/gil stolen
0018c1d8: 3c028019 lui r2,0x8019
0018c1dc: 8c422d90 lw r2,0x2d90(r2)      target action pointer
0018c1e0: 3c048019 lui r4,0x8019
0018c1e4: 8c842d98 lw r4,0x2d98(r4)      target data pointer
0018c1e8: 8445000c lh r5,0x000c(r2)
0018c1ec: 0c063aa6 jal 0x0018ea98      some steal routine (gil/exp?)
0018c1f0: 00003021 addu r6,r0,r0
0018c1f4: 3c028019 lui r2,0x8019
0018c1f8: 8c422d90 lw r2,0x2d90(r2)      target action pointer
0018c1fc: 3c048019 lui r4,0x8019
0018c200: 8c842d98 lw r4,0x2d98(r4)      target data pointer
0018c204: 90450028 lbu r5,0x0028(r2)      
0018c208: 0c063ad4 jal 0x0018eb50      unknown yet
0018c20c: 00000000 nop
0018c210: 3c028019 lui r2,0x8019
0018c214: 8c422d90 lw r2,0x2d90(r2)      target action pointer
0018c218: 00000000 nop
0018c21c: 90420029 lbu r2,0x0029(r2)      stolen jp? unknown data
0018c220: 00000000 nop
0018c224: 10400005 beq r2,r0,0x0018c23c      branch if 0
0018c228: 00000000 nop
0018c22c: 3c048019 lui r4,0x8019
0018c230: 8c842d98 lw r4,0x2d98(r4)      target data
0018c234: 0c0637fe jal 0x0018dff8      ???
0018c238: 00000000 nop
0018c23c: 0c063217 jal 0x0018c85c      ???
0018c240: 00000000 nop
0018c244: 0c0631a0 jal 0x0018c680      ???
0018c248: 02028025 or r16,r16,r2
0018c24c: 3c038019 lui r3,0x8019
0018c250: 8c632d90 lw r3,0x2d90(r3)
0018c254: 00000000 nop
0018c258: 94630010 lhu r3,0x0010(r3)      load special flags (marlboro)
0018c25c: 00000000 nop
0018c260: 30630002 andi r3,r3,0x0002      murbol morph check
0018c264: 1060000a beq r3,r0,0x0018c290      branch if not morbolized
0018c268: 02028025 or r16,r16,r2
0018c26c: 3c028019 lui r2,0x8019
0018c270: 8c42f5fc lw r2,-0x0a04(r2)      load display data      
0018c274: 00000000 nop
0018c278: 14400005 bne r2,r0,0x0018c290      skip if not 0
0018c27c: 36100001 ori r16,r16,0x0001      
0018c280: 3c048019 lui r4,0x8019
0018c284: 8c842d98 lw r4,0x2d98(r4)      target data
0018c288: 0c0603d0 jal 0x00180f40      ???
0018c28c: 00000000 nop
0018c290: 16200028 bne r17,r0,0x0018c334   branch if ?
0018c294: 00000000 nop
0018c298: 3c028019 lui r2,0x8019
0018c29c: 8c422d98 lw r2,0x2d98(r2)      target data
0018c2a0: 00000000 nop
0018c2a4: 94420058 lhu r2,0x0058(r2)      current status 1
0018c2a8: 00000000 nop
0018c2ac: 30420160 andi r2,r2,0x0160      dead/crystal/performing check?
0018c2b0: 14400020 bne r2,r0,0x0018c334      branch  if ^
0018c2b4: 00000000 nop
0018c2b8: 3c048019 lui r4,0x8019
0018c2bc: 8c842d90 lw r4,0x2d90(r4)      target action
0018c2c0: 0c062f75 jal 0x0018bdd4      ???      
0018c2c4: 00000000 nop
0018c2c8: 02402021 addu r4,r18,r0
0018c2cc: 34050001 ori r5,r0,0x0001
0018c2d0: 3c028019 lui r2,0x8019
0018c2d4: 8c422d90 lw r2,0x2d90(r2)      target action
0018c2d8: 34030020 ori r3,r0,0x0020
0018c2dc: 0c06381f jal 0x0018e07c      ???
0018c2e0: a043001b sb r3,0x001b(r2)      store dead as status inflictin      
0018c2e4: 3c028019 lui r2,0x8019
0018c2e8: 8c42f5fc lw r2,-0x0a04(r2)      display data
0018c2ec: 00000000 nop
0018c2f0: 14400008 bne r2,r0,0x0018c314      ??
0018c2f4: 00000000 nop
0018c2f8: 3c038019 lui r3,0x8019
0018c2fc: 8c632d98 lw r3,0x2d98(r3)      target data
0018c300: 00000000 nop
0018c304: 9062015c lbu r2,0x015c(r3)      load ??
0018c308: 00000000 nop
0018c30c: 24420001 addiu r2,r2,0x0001      
0018c310: a062015c sb r2,0x015c(r3)      store 01 into ??
0018c314: 0c063588 jal 0x0018d620      gained EXP
0018c318: 34040002 ori r4,r0,0x0002
0018c31c: 3c028019 lui r2,0x8019
0018c320: 8c422d98 lw r2,0x2d98(r2)      target data
0018c324: 00000000 nop
0018c328: 90420182 lbu r2,0x0182(r2)      mount flags
0018c32c: 08063198 j 0x0018c660         end
0018c330: 000211c2 srl r2,r2,0x07
0018c334: 3c028019 lui r2,0x8019
0018c338: 8c422d98 lw r2,0x2d98(r2)      target data
0018c33c: 3c03cccc lui r3,0xcccc
0018c340: 9442002a lhu r2,0x002a(r2)      load max HP      
0018c344: 3463cccd ori r3,r3,0xcccd
0018c348: 00430019 multu r2,r3
0018c34c: 00001010 mfhi r2
0018c350: 00021082 srl r2,r2,0x02
0018c354: 3042ffff andi r2,r2,0xffff      checking if max hp = fraction of max hp (critical)
0018c358: 0051102a slt r2,r2,r17
0018c35c: 14400009 bne r2,r0,0x0018c384      branch if not critical?
0018c360: 00000000 nop
0018c364: 3c038019 lui r3,0x8019
0018c368: 8c632d90 lw r3,0x2d90(r3)      target action pointer
0018c36c: 00000000 nop
0018c370: 9062001d lbu r2,0x001d(r3)      status infliction 3
0018c374: 00000000 nop
0018c378: 34420001 ori r2,r2,0x0001      critical
0018c37c: 080630e8 j 0x0018c3a0         skip next rountine
0018c380: a062001d sb r2,0x001d(r3)      store set critical status
0018c384: 3c038019 lui r3,0x8019
0018c388: 8c632d90 lw r3,0x2d90(r3)      target action
0018c38c: 00000000 nop
0018c390: 90620022 lbu r2,0x0022(r3)      load status removal 3
0018c394: 00000000 nop
0018c398: 34420001 ori r2,r2,0x0001
0018c39c: a0620022 sb r2,0x0022(r3)      store remove critical status
0018c3a0: 3c028019 lui r2,0x8019
0018c3a4: 8c422d98 lw r2,0x2d98(r2)      target data
0018c3a8: 00000000 nop
0018c3ac: 90420024 lbu r2,0x0024(r2)      load brave
0018c3b0: 00000000 nop
0018c3b4: 2c42000a sltiu r2,r2,0x000a      set if less than 10
0018c3b8: 10400009 beq r2,r0,0x0018c3e0      branch if not less than 10 brave
0018c3bc: 00000000 nop
0018c3c0: 3c038019 lui r3,0x8019
0018c3c4: 8c632d90 lw r3,0x2d90(r3)
0018c3c8: 00000000 nop
0018c3cc: 9062001d lbu r2,0x001d(r3)      load
0018c3d0: 00000000 nop
0018c3d4: 34420004 ori r2,r2,0x0004
0018c3d8: 080630ff j 0x0018c3fc         skip brave increment
0018c3dc: a062001d sb r2,0x001d(r3)      store chicken status
0018c3e0: 3c038019 lui r3,0x8019
0018c3e4: 8c632d90 lw r3,0x2d90(r3)      target action
0018c3e8: 00000000 nop
0018c3ec: 90620022 lbu r2,0x0022(r3)      load status removal
0018c3f0: 00000000 nop
0018c3f4: 34420004 ori r2,r2,0x0004
0018c3f8: a0620022 sb r2,0x0022(r3)      store remove chicken status
0018c3fc: 3c038019 lui r3,0x8019
0018c400: 8c632d90 lw r3,0x2d90(r3)
0018c404: 00000000 nop
0018c408: 90620025 lbu r2,0x0025(r3)      load attack type
0018c40c: 00000000 nop
0018c410: 30420080 andi r2,r2,0x0080      HP damage check
0018c414: 10400013 beq r2,r0,0x0018c464      branch if not HP damage
0018c418: 00000000 nop
0018c41c: 90620024 lbu r2,0x0024(r3)      load status removal 5
0018c420: 00000000 nop
0018c424: 34420030 ori r2,r2,0x0030      store charm/sleep
0018c428: a0620024 sb r2,0x0024(r3)      remove ^      
0018c42c: 3c038019 lui r3,0x8019
0018c430: 8c632d90 lw r3,0x2d90(r3)      target action
0018c434: 00000000 nop
0018c438: 90620022 lbu r2,0x0022(r3)      status removal 3
0018c43c: 00000000 nop
0018c440: 34420010 ori r2,r2,0x0010      
0018c444: a0620022 sb r2,0x0022(r3)      store remove transparent
0018c448: 3c038019 lui r3,0x8019
0018c44c: 8c632d90 lw r3,0x2d90(r3)      target current action
0018c450: 00000000 nop
0018c454: 90620021 lbu r2,0x0021(r3)      status removal 2
0018c458: 00000000 nop
0018c45c: 34420010 ori r2,r2,0x0010
0018c460: a0620021 sb r2,0x0021(r3)      store remove confusion
0018c464: 3c028019 lui r2,0x8019
0018c468: 8c422d90 lw r2,0x2d90(r2)      target current action
0018c46c: 00000000 nop
0018c470: 94420010 lhu r2,0x0010(r2)      special flags
0018c474: 00000000 nop
0018c478: 30424000 andi r2,r2,0x4000      switch team?
0018c47c: 10400012 beq r2,r0,0x0018c4c8      branch if no team switch
0018c480: 00000000 nop
0018c484: 3c048019 lui r4,0x8019
0018c488: 8c842d98 lw r4,0x2d98(r4)      target data
0018c48c: 0c06005e jal 0x00180178      ????
0018c490: 00002821 addu r5,r0,r0      r5 = 0
0018c494: 1040000c beq r2,r0,0x0018c4c8      branch if ?
0018c498: 00000000 nop
0018c49c: 3c038019 lui r3,0x8019
0018c4a0: 8c632d90 lw r3,0x2d90(r3)      target current action
0018c4a4: 00000000 nop
0018c4a8: 90620020 lbu r2,0x0020(r3)      attack status removal 1
0018c4ac: 00000000 nop
0018c4b0: 34420008 ori r2,r2,0x0008      charging
0018c4b4: a0620020 sb r2,0x0020(r3)      remove charging
0018c4b8: 3c038019 lui r3,0x8019
0018c4bc: 8c632d98 lw r3,0x2d98(r3)      target data
0018c4c0: 340200ff ori r2,r0,0x00ff      ff
0018c4c4: a062015d sb r2,0x015d(r3)      store current ability CT ff (no charge?)
0018c4c8: 0c0612c9 jal 0x00184b24      status infliction checks
0018c4cc: 00002021 addu r4,r0,r0
0018c4d0: 00002021 addu r4,r0,r0
0018c4d4: 27a30010 addiu r3,r29,0x0010
0018c4d8: 3c028019 lui r2,0x8019
0018c4dc: 8c422d98 lw r2,0x2d98(r2)      target data
0018c4e0: 00000000 nop
0018c4e4: 00441021 addu r2,r2,r4
0018c4e8: 90420058 lbu r2,0x0058(r2)      load current status 1
0018c4ec: 24840001 addiu r4,r4,0x0001      ??
0018c4f0: a0620000 sb r2,0x0000(r3)      store current status ??
0018c4f4: 28820005 slti r2,r4,0x0005
0018c4f8: 1440fff7 bne r2,r0,0x0018c4d8      ??
0018c4fc: 24630001 addiu r3,r3,0x0001
0018c500: 00002021 addu r4,r0,r0
0018c504: 27a30018 addiu r3,r29,0x0018
0018c508: 3c028019 lui r2,0x8019
0018c50c: 8c422d98 lw r2,0x2d98(r2)      target data
0018c510: 00000000 nop
0018c514: 00441021 addu r2,r2,r4
0018c518: 9042005d lbu r2,0x005d(r2)      current status 2
0018c51c: 24840001 addiu r4,r4,0x0001
0018c520: a0620000 sb r2,0x0000(r3)
0018c524: 28820010 slti r2,r4,0x0010
0018c528: 1440fff7 bne r2,r0,0x0018c508      ???
0018c52c: 24630001 addiu r3,r3,0x0001
0018c530: 02402021 addu r4,r18,r0
0018c534: 0c06381f jal 0x0018e07c      ???
0018c538: 00002821 addu r5,r0,r0
0018c53c: 3c038019 lui r3,0x8019
0018c540: 8c632d98 lw r3,0x2d98(r3)      target data
0018c544: 00000000 nop
0018c548: 90620058 lbu r2,0x0058(r3)      current status 1
0018c54c: 00000000 nop
0018c550: 30420020 andi r2,r2,0x0020      dead
0018c554: 10400014 beq r2,r0,0x0018c5a8      branch if not
0018c558: 00002021 addu r4,r0,r0      r4 = 0
0018c55c: 93a20010 lbu r2,0x0010(r29)      
0018c560: 00000000 nop
0018c564: 30420020 andi r2,r2,0x0020
0018c568: 1440000f bne r2,r0,0x0018c5a8      skip if not dead
0018c56c: 00000000 nop
0018c570: 3c028019 lui r2,0x8019
0018c574: 8c42f5fc lw r2,-0x0a04(r2)      display data
0018c578: 00000000 nop
0018c57c: 14400023 bne r2,r0,0x0018c60c      branch if not dead?
0018c580: 34100002 ori r16,r0,0x0002      r16 = 02
0018c584: 9062015c lbu r2,0x015c(r3)      load dead flag?
0018c588: 00000000 nop
0018c58c: 24420001 addiu r2,r2,0x0001      add 0x01
0018c590: 08063183 j 0x0018c60c         
0018c594: a062015c sb r2,0x015c(r3)      store unit dead
0018c598: 08063176 j 0x0018c5d8
0018c59c: 34100001 ori r16,r0,0x0001
0018c5a0: 08063183 j 0x0018c60c
0018c5a4: 34100001 ori r16,r0,0x0001
0018c5a8: 3c068019 lui r6,0x8019
0018c5ac: 8cc62d98 lw r6,0x2d98(r6)      target data
0018c5b0: 27a50010 addiu r5,r29,0x0010      target dead check
0018c5b4: 00c41021 addu r2,r6,r4
0018c5b8: 90430058 lbu r3,0x0058(r2)      load current status
0018c5bc: 90a20000 lbu r2,0x0000(r5)      ??      
0018c5c0: 00000000 nop
0018c5c4: 1462fff4 bne r3,r2,0x0018c598      ??
0018c5c8: 24840001 addiu r4,r4,0x0001
0018c5cc: 28820005 slti r2,r4,0x0005
0018c5d0: 1440fff8 bne r2,r0,0x0018c5b4
0018c5d4: 24a50001 addiu r5,r5,0x0001
0018c5d8: 00002021 addu r4,r0,r0
0018c5dc: 3c068019 lui r6,0x8019
0018c5e0: 8cc62d98 lw r6,0x2d98(r6)      target data
0018c5e4: 27a50018 addiu r5,r29,0x0018
0018c5e8: 00c41021 addu r2,r6,r4
0018c5ec: 9043005d lbu r3,0x005d(r2)      load status CT left
0018c5f0: 90a20000 lbu r2,0x0000(r5)
0018c5f4: 00000000 nop
0018c5f8: 1462ffe9 bne r3,r2,0x0018c5a0      ??
0018c5fc: 24840001 addiu r4,r4,0x0001      
0018c600: 28820010 slti r2,r4,0x0010
0018c604: 1440fff8 bne r2,r0,0x0018c5e8
0018c608: 24a50001 addiu r5,r5,0x0001
0018c60c: 0c063588 jal 0x0018d620      attackers earned exp
0018c610: 02002021 addu r4,r16,r0
0018c614: 12000005 beq r16,r0,0x0018c62c   
0018c618: 34020002 ori r2,r0,0x0002      r2 = 02
0018c61c: 3c038019 lui r3,0x8019
0018c620: 8c632d98 lw r3,0x2d98(r3)      target data
0018c624: 00000000 nop
0018c628: a0620189 sb r2,0x0189(r3)      store in water??
0018c62c: 0c063336 jal 0x0018ccd8      PA Save, MA Save, Speed Save, Regenerator, HP Restore, MP Restore, Critical Quick Meatbone Slash, Auto Potion, Gilgame Heart check
0018c630: 00000000 nop
0018c634: 3c048019 lui r4,0x8019
0018c638: 8c842d98 lw r4,0x2d98(r4)      target data
0018c63c: 00000000 nop
0018c640: 90830058 lbu r3,0x0058(r4)      load current status
0018c644: 00000000 nop
0018c648: 30630060 andi r3,r3,0x0060      
0018c64c: 10600005 beq r3,r0,0x0018c664      branch if not dead/crystal
0018c650: 00001021 addu r2,r0,r0
0018c654: 90820182 lbu r2,0x0182(r4)      set mount flags = 0
0018c658: 00000000 nop
0018c65c: 000211c2 srl r2,r2,0x07
0018c660: 00021023 subu r2,r0,r2
0018c664: 8fbf0034 lw r31,0x0034(r29)
0018c668: 8fb20030 lw r18,0x0030(r29)
0018c66c: 8fb1002c lw r17,0x002c(r29)
0018c670: 8fb00028 lw r16,0x0028(r29)
0018c674: 27bd0038 addiu r29,r29,0x0038
0018c678: 03e00008 jr r31
0018c67c: 00000000 nop


Title: Re: ASM Collective BATTLE.BIN Map
Post by: Vanya on February 17, 2012, 11:15:08 pm
Could that routine be the place to mess around to make a skill act like the Defend command, Choto?
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on February 17, 2012, 11:34:27 pm
unfortunately, I don't think it handles that kinda stuff. if we found the defend and equip change routines though, it might show how they make them direct commands.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pickle Girl Fanboy on February 21, 2012, 03:19:53 pm
Is anything being done to make sprites less stupid?  Like, to make the battle sprite sheet used for the formation screen and the troop placement screen, so the only thing you have to deal with is custom animations in events?
Title: Re: ASM Collective BATTLE.BIN Map
Post by: RavenOfRazgriz on February 21, 2012, 03:23:16 pm
That has nothing to do with BATTLE.BIN at all and would require recoding aspects of the game no one has info on or wants to touch at this time, PGF.  -_-
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on February 24, 2012, 10:09:35 am
If anybody uploads routines to the wiki (which I strongly encourage), here's a VERY easy way to format them correctly: If you have Microsoft office, copy and paste it into there. Under "edit", find "replace". type the character to be replaced as the beginning of the address for each line ex: "0005...." and replace it with "(space)0005..." hit replace all and voila, your arrow keys and space bar are saved from destruction!
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pickle Girl Fanboy on February 24, 2012, 04:12:21 pm
Leafpad, a plain text editor (like Windows Notepad) for Linux, has Replace and Replace All functionality.  You can access it from the Search menu, or with the keyboard shortcut Ctrl + h.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on March 03, 2012, 06:36:11 pm
Does anybody have these routines documented?

00186af8               Wiznaibus/Witch Hunt Formula

00184360               Skill-Set Hard Coding
001869ec          Magic/Angel Song

They're from formulas 1d and 1c:

http://ffhacktics.com/wiki/1D_Hit_%28X%29%25
http://ffhacktics.com/wiki/1C_Hit_%28X%29%25
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on March 26, 2012, 08:43:22 am
Who says old routines can't yield new fruit?


0011f91c: 27bdffe8 addiu r29,r29,-0x0018
0011f920: afbf0010 sw r31,0x0010(r29)
0011f924: 0c063ba8 jal 0x0018eea0             Get RN into r2.
0011f928: 00000000 nop
0011f92c: 3c038019 lui r3,0x8019
0011f930: 906338fa lbu r3,0x38fa(r3)            Load Y
0011f934: 00000000 nop
0011f938: 00430018 mult r2,r3
0011f93c: 00001012 mflo r2
0011f940: 04410002 bgez r2,0x0011f94c
0011f944: 00000000 nop
0011f948: 24427fff addiu r2,r2,0x7fff
0011f94c: 000213c3 sra r2,r2,0x0f
0011f950: 3c038019 lui r3,0x8019
0011f954: 946338ce lhu r3,0x38ce(r3)             Load XA = PA
0011f958: 24420001 addiu r2,r2,0x0001           r2 an RN from (1...Y)
0011f95c: 00430018 mult r2,r3
0011f960: 3c048019 lui r4,0x8019
0011f964: 8c842d90 lw r4,0x2d90(r4)
0011f968: 34020080 ori r2,r0,0x0080
0011f96c: a0820025 sb r2,0x0025(r4)               Set as HP DMG
0011f970: 3c038019 lui r3,0x8019
0011f974: 8c63f5fc lw r3,-0x0a04(r3)
0011f978: 00001012 mflo r2                            r2 = XA * (1...Y)
0011f97c: 14600017 bne r3,r0,0x0011f9dc
0011f980: a4820004 sh r2,0x0004(r4)               Store r2 as HP DMG
0011f984: 0c063ba8 jal 0x0018eea0                 Get RNG, put in r2
0011f988: 00000000 nop
0011f98c: 3c038019 lui r3,0x8019
0011f990: 8c632d94 lw r3,0x2d94(r3)
0011f994: 00000000 nop
0011f998: 90630024 lbu r3,0x0024(r3)              Get Caster Brave?  (Here's where the fun begins)
0011f99c: 00000000 nop
0011f9a0: 00430018 mult r2,r3
0011f9a4: 00002812 mflo r5
0011f9a8: 04a10002 bgez r5,0x0011f9b4
0011f9ac: 00000000 nop
0011f9b0: 24a57fff addiu r5,r5,0x7fff
0011f9b4: 3c028019 lui r2,0x8019
0011f9b8: 8c422d98 lw r2,0x2d98(r2)
0011f9bc: 00000000 nop
0011f9c0: 90440024 lbu r4,0x0024(r2)                  r4 is TarBr
0011f9c4: 0c017833 jal 0x0005e0cc                     Random Hits routine!
0011f9c8: 00052bc3 sra r5,r5,0x0f                       r5 is CasBr * RNG
0011f9cc: 14400003 bne r2,r0,0x0011f9dc             If Check fails, SKIP...
0011f9d0: 00000000 nop
0011f9d4: 0c0610fb jal 0x001843ec                      ...the Knockback routine
0011f9d8: 00000000 nop
0011f9dc: 8fbf0010 lw r31,0x0010(r29)
0011f9e0: 27bd0018 addiu r29,r29,0x0018
0011f9e4: 03e00008 jr r31


In short, what the above demonstrates is that the chance for knockback to occur in Vanilla is not 50%, but actually the chance CasBr * RNG will exceed TarBr * RNG.
What this means is that the probability of knockback on these formulas is actually (CasBr) / (CasBr + TarBr).
If you don't believe me, try using a 100 Brave Ramza to knockback an 10 or 11 brave opponent.  Your error rate should be only 9 - 10%
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on May 02, 2012, 09:03:01 am
Here's a little bit of the stuff SA was looking at for display. Its pretty much the basic framework for all post-action data display. Here are some noticeable things:

-His notes are AWESOME. They're clear as can be, i'm truly envious of how he tears through whole sections with such complete notes.

-there are 6 unused bytes under "status image data", which hopefully can be used to display custom or additional statii.

-there is some hardcoding for the 999 cap in the display section, should we ever want to take down that wall. (*wink wink)

all the rest is self-explanatory, i'm sure you guys will notice more things than i did checking it out. He said he has other notes but they're pretty disorganized/don't have many notes attached to them. I feel like this is a good basic starting point for post-action display alterations. I'll put this up on the wiki too, but here it is in file form.

Title: Re: ASM Collective BATTLE.BIN Map
Post by: Celdia on May 02, 2012, 09:28:20 am
Quote from: Choto on May 02, 2012, 09:03:01 am
-there are 6 unused bytes under "status image data", which hopefully can be used to display custom or additional statii.

That's exactly what its for. Anyone that ever wanted to make the Wall status display something on screen now can using this. There are some additional notes that I don't think are in the raw that allow you to modify the same tables in WORLD.BIN so that you can make those status names appear in the Item List properly as well. A couple of examples in the spoilers below.


(http://img.photobucket.com/albums/v311/Celdia/adng9v.png)


(http://img.photobucket.com/albums/v311/Celdia/2h3vi37.png)

Title: Re: ASM Collective BATTLE.BIN Map
Post by: Pickle Girl Fanboy on May 02, 2012, 05:56:19 pm
Comment: This is awesome!
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on May 14, 2012, 11:24:02 am
Not sure if i ever posted these 2 routines, but they're worth mentioning.

This one is the main in-between turn routine... its on the wiki i think. It's analogous to the main reaction routine on the wiki, so it seems quite useful.



Main in between turn routine
001827f0: 27bdffc0 addiu r29,r29,0xffc0
001827f4: afb5002c sw r21,0x002c(r29)
001827f8: 0000a821 addu r21,r0,r0
001827fc: 34020001 ori r2,r0,0x0001
00182800: afbf003c sw r31,0x003c(r29)
00182804: afbe0038 sw r30,0x0038(r29)
00182808: afb70034 sw r23,0x0034(r29)
0018280c: afb60030 sw r22,0x0030(r29)
00182810: afb40028 sw r20,0x0028(r29)
00182814: afb30024 sw r19,0x0024(r29)
00182818: afb20020 sw r18,0x0020(r29)
0018281c: afb1001c sw r17,0x001c(r29)
00182820: afb00018 sw r16,0x0018(r29)
00182824: 1482001f bne r4,r2,0x001828a4
00182828: afa00010 sw r0,0x0010(r29)
0018282c: 34120003 ori r18,r0,0x0003
00182830: 3c038019 lui r3,0x8019
00182834: 2463f5fa addiu r3,r3,0xf5fa
00182838: 2402ffff addiu r2,r0,0xffff
0018283c: 3c018019 lui r1,0x8019
00182840: ac20f518 sw r0,-0x0ae8(r1)
00182844: 3c018019 lui r1,0x8019
00182848: ac22f520 sw r2,-0x0ae0(r1)
0018284c: a4600000 sh r0,0x0000(r3)
00182850: 2652ffff addiu r18,r18,0xffff
00182854: 0641fffd bgez r18,0x0018284c
00182858: 2463fffe addiu r3,r3,0xfffe
0018285c: 3c018019 lui r1,0x8019
00182860: a020389d sb r0,0x389d(r1)
00182864: 00009021 addu r18,r0,r0
00182868: 340400ff ori r4,r0,0x00ff
0018286c: 3c038019 lui r3,0x8019
00182870: 246308cc addiu r3,r3,0x08cc

00182874: a0600039 sb r0,0x0039(r3)       store 0 CT
00182878: a0600186 sb r0,0x0186(r3)      store turn over
0018287c: a0600189 sb r0,0x0189(r3)      store ?
00182880: a064015d sb r4,0x015d(r3)      Store Current ability CT = ff
00182884: 26520001 addiu r18,r18,0x0001
00182888: 2a420015 slti r2,r18,0x0015
0018288c: 1440fff9 bne r2,r0,0x00182874      cycles through each unit?
00182890: 246301c0 addiu r3,r3,0x01c0

00182894: 0c06398a jal 0x0018e628      ???
00182898: 00000000 nop
0018289c: 08060c11 j 0x00183044         jump to end?
001828a0: 3402e000 ori r2,r0,0xe000
001828a4: 34020002 ori r2,r0,0x0002
001828a8: 14820034 bne r4,r2,0x0018297c      ??
001828ac: 341e0001 ori r30,r0,0x0001
001828b0: 00009021 addu r18,r0,r0
001828b4: 340400ff ori r4,r0,0x00ff
001828b8: 3c038019 lui r3,0x8019
001828bc: 246308cc addiu r3,r3,0x08cc      unit data

001828c0: 90620001 lbu r2,0x0001(r3)      
001828c4: 00000000 nop
001828c8: 1044000b beq r2,r4,0x001828f8      unit exists check
001828cc: 00000000 nop
001828d0: 90620058 lbu r2,0x0058(r3)      current status
001828d4: 00000000 nop
001828d8: 30420064 andi r2,r2,0x0064
001828dc: 14400006 bne r2,r0,0x001828f8      dead/crystal/jump check
001828e0: 00000000 nop
001828e4: 90620059 lbu r2,0x0059(r3)      
001828e8: 00000000 nop
001828ec: 30420081 andi r2,r2,0x0081      
001828f0: 104001d4 beq r2,r0,0x00183044      petrify/treasure check
001828f4: 3642d000 ori r2,r18,0xd000
001828f8: 26520001 addiu r18,r18,0x0001
001828fc: 2a420015 slti r2,r18,0x0015
00182900: 1440ffef bne r2,r0,0x001828c0      cycles through each unit?
00182904: 246301c0 addiu r3,r3,0x01c0

00182908: 08060c11 j 0x00183044         jump to end?
0018290c: 3402df00 ori r2,r0,0xdf00
00182910: 3c018019 lui r1,0x8019
00182914: 00320821 addu r1,r1,r18
00182918: a020f8b0 sb r0,-0x0750(r1)      ??
0018291c: 08060c11 j 0x00183044
00182920: 36420300 ori r2,r18,0x0300
00182924: 001410c0 sll r2,r20,0x03
00182928: 00541023 subu r2,r2,r20
0018292c: 00021180 sll r2,r2,0x06
00182930: 3c038019 lui r3,0x8019
00182934: 246308cc addiu r3,r3,0x08cc      unit data
00182938: 00438821 addu r17,r2,r3
0018293c: 34030001 ori r3,r0,0x0001
00182940: a2230186 sb r3,0x0186(r17)      store turn = 1
00182944: a2230027 sb r3,0x0027(r17)      store active turn?
00182948: 34030009 ori r3,r0,0x0009
0018294c: a2200039 sb r0,0x0039(r17)      store CT = 0
00182950: a2200187 sb r0,0x0187(r17)      store can move
00182954: a2200188 sb r0,0x0188(r17)      store can act
00182958: 3c018019 lui r1,0x8019
0018295c: ac23f51c sw r3,-0x0ae4(r1)      store ? = 9
00182960: 3403000a ori r3,r0,0x000a
00182964: 3c018019 lui r1,0x8019
00182968: ac34f520 sw r20,-0x0ae0(r1)      store ? = r20 (set by jal routine?)
0018296c: 3c018019 lui r1,0x8019
00182970: ac23f518 sw r3,-0x0ae8(r1)      store ? = 10
00182974: 08060c11 j 0x00183044         jump to end
00182978: 36820100 ori r2,r20,0x0100
0018297c: 3c168019 lui r22,0x8019
00182980: 26d608cc addiu r22,r22,0x08cc      
00182984: 341700ff ori r23,r0,0x00ff
00182988: 3c038019 lui r3,0x8019
0018298c: 8c63f518 lw r3,-0x0ae8(r3)      store ?? = 10?
00182990: 00000000 nop
00182994: 2c620014 sltiu r2,r3,0x0014      set if r3 < 20
00182998: 104001a1 beq r2,r0,0x00183020
0018299c: 00031080 sll r2,r3,0x02
001829a0: 3c018017 lui r1,0x8017
001829a4: 00220821 addu r1,r1,r2
001829a8: 8c224174 lw r2,0x4174(r1)
001829ac: 00000000 nop
001829b0: 00400008 jr r2
001829b4: 00000000 nop
001829b8: 00009021 addu r18,r0,r0
001829bc: 00008021 addu r16,r0,r0

001829c0: 02168821 addu r17,r16,r22
001829c4: 0c060cb3 jal 0x001832cc      various checks
001829c8: 02202021 addu r4,r17,r0
001829cc: 00401821 addu r3,r2,r0
001829d0: 30620001 andi r2,r3,0x0001
001829d4: 14400013 bne r2,r0,0x00182a24
001829d8: 30620020 andi r2,r3,0x0020
001829dc: 92240038 lbu r4,0x0038(r17)      load speed
001829e0: 10400003 beq r2,r0,0x001829f0
001829e4: 30620010 andi r2,r3,0x0010
001829e8: 08060a80 j 0x00182a00
001829ec: 00042042 srl r4,r4,0x01
001829f0: 10400003 beq r2,r0,0x00182a00
001829f4: 3082ffff andi r2,r4,0xffff
001829f8: 00021042 srl r2,r2,0x01
001829fc: 00822021 addu r4,r4,r2
00182a00: 92220039 lbu r2,0x0039(r17)      load CT
00182a04: 00000000 nop
00182a08: 00821821 addu r3,r4,r2
00182a0c: 3062ffff andi r2,r3,0xffff
00182a10: 2c4200ff sltiu r2,r2,0x00ff
00182a14: 14400002 bne r2,r0,0x00182a20
00182a18: 00000000 nop
00182a1c: 340300fe ori r3,r0,0x00fe
00182a20: a2230039 sb r3,0x0039(r17)      store CT
00182a24: 26520001 addiu r18,r18,0x0001
00182a28: 2a420015 slti r2,r18,0x0015
00182a2c: 1440ffe4 bne r2,r0,0x001829c0      cycle through each unit

00182a30: 261001c0 addiu r16,r16,0x01c0
00182a34: 3c018019 lui r1,0x8019
00182a38: ac3ef518 sw r30,-0x0ae8(r1)
00182a3c: 08060c08 j 0x00183020
00182a40: 00000000 nop
00182a44: 34130063 ori r19,r0,0x0063
00182a48: 341400ff ori r20,r0,0x00ff
00182a4c: 00009021 addu r18,r0,r0
00182a50: 02c08021 addu r16,r22,r0

00182a54: 0c060cb3 jal 0x001832cc
00182a58: 02002021 addu r4,r16,r0
00182a5c: 30420001 andi r2,r2,0x0001
00182a60: 14400008 bne r2,r0,0x00182a84
00182a64: 00000000 nop
00182a68: 92030039 lbu r3,0x0039(r16)      laod CT
00182a6c: 00000000 nop
00182a70: 0263102b sltu r2,r19,r3
00182a74: 10400003 beq r2,r0,0x00182a84
00182a78: 00000000 nop
00182a7c: 0240a021 addu r20,r18,r0
00182a80: 00609821 addu r19,r3,r0
00182a84: 26520001 addiu r18,r18,0x0001
00182a88: 2a420015 slti r2,r18,0x0015
00182a8c: 1440fff1 bne r2,r0,0x00182a54
00182a90: 261001c0 addiu r16,r16,0x01c0



00182a94: 12970043 beq r20,r23,0x00182ba4
00182a98: 001410c0 sll r2,r20,0x03
00182a9c: 00541023 subu r2,r2,r20
00182aa0: 00021180 sll r2,r2,0x06
00182aa4: 00568821 addu r17,r2,r22
00182aa8: 92220058 lbu r2,0x0058(r17)      load status
00182aac: 00000000 nop
00182ab0: 30420004 andi r2,r2,0x0004
00182ab4: 10400003 beq r2,r0,0x00182ac4      jump check
00182ab8: 34020063 ori r2,r0,0x0063
00182abc: 08060c0e j 0x00183038
00182ac0: a2220039 sb r2,0x0039(r17)      store CT
00182ac4: 92220039 lbu r2,0x0039(r17)      Load CT
00182ac8: 00000000 nop
00182acc: 14570003 bne r2,r23,0x00182adc
00182ad0: 3c0251eb lui r2,0x51eb
00182ad4: 08060ac3 j 0x00182b0c
00182ad8: a2200039 sb r0,0x0039(r17)      store 0 in CT
00182adc: 3442851f ori r2,r2,0x851f
00182ae0: 3264ffff andi r4,r19,0xffff
00182ae4: 00820019 multu r4,r2
00182ae8: 00001810 mfhi r3
00182aec: 00031942 srl r3,r3,0x05
00182af0: 00031040 sll r2,r3,0x01
00182af4: 00431021 addu r2,r2,r3
00182af8: 000210c0 sll r2,r2,0x03
00182afc: 00431021 addu r2,r2,r3
00182b00: 00021080 sll r2,r2,0x02
00182b04: 00822023 subu r4,r4,r2
00182b08: a2240039 sb r4,0x0039(r17)      store CT
00182b0c: 02802021 addu r4,r20,r0
00182b10: 0c060c1e jal 0x00183078      undead revive, reraise, death sentence, etc.
00182b14: 02202821 addu r5,r17,r0
00182b18: 00408021 addu r16,r2,r0
00182b1c: 12000009 beq r16,r0,0x00182b44
00182b20: 32020001 andi r2,r16,0x0001
00182b24: 10400007 beq r2,r0,0x00182b44
00182b28: 36950300 ori r21,r20,0x0300
00182b2c: 161e0145 bne r16,r30,0x00183044
00182b30: 02a01021 addu r2,r21,r0
00182b34: 0c01799c jal 0x0005e670      [[Increase Casualties/Injured Counters]]
00182b38: 02202021 addu r4,r17,r0
00182b3c: 08060c11 j 0x00183044         jump to end
00182b40: 02a01021 addu r2,r21,r0
00182b44: 0c060cb3 jal 0x001832cc
00182b48: 02202021 addu r4,r17,r0
00182b4c: 30420007 andi r2,r2,0x0007
00182b50: 10400003 beq r2,r0,0x00182b60
00182b54: 34020002 ori r2,r0,0x0002
00182b58: 16020137 bne r16,r2,0x00183038
00182b5c: 00000000 nop
00182b60: a23e0186 sb r30,0x0186(r17)      store turn ?
00182b64: a2200187 sb r0,0x0187(r17)      store can move
00182b68: a2200188 sb r0,0x0188(r17)      store can act
00182b6c: 16000002 bne r16,r0,0x00182b78
00182b70: a23e0027 sb r30,0x0027(r17)      store units turn ?
00182b74: 36950100 ori r21,r20,0x0100
00182b78: 3c048019 lui r4,0x8019
00182b7c: 8c84f518 lw r4,-0x0ae8(r4)
00182b80: 3403000a ori r3,r0,0x000a
00182b84: 3c018019 lui r1,0x8019
00182b88: ac34f520 sw r20,-0x0ae0(r1)
00182b8c: 3c018019 lui r1,0x8019
00182b90: ac23f518 sw r3,-0x0ae8(r1)
00182b94: 3c018019 lui r1,0x8019
00182b98: ac24f51c sw r4,-0x0ae4(r1)
00182b9c: 08060c11 j 0x00183044
00182ba0: 02a01021 addu r2,r21,r0
00182ba4: 08060c06 j 0x00183018
00182ba8: 34020002 ori r2,r0,0x0002
00182bac: 00009021 addu r18,r0,r0
00182bb0: 02c08021 addu r16,r22,r0

00182bb4: 0c060cb3 jal 0x001832cc      various checks
00182bb8: 02002021 addu r4,r16,r0
00182bbc: 3042000f andi r2,r2,0x000f
00182bc0: 14400009 bne r2,r0,0x00182be8
00182bc4: 26520001 addiu r18,r18,0x0001
00182bc8: 9203015d lbu r3,0x015d(r16)      load current ability CT
00182bcc: 00000000 nop
00182bd0: 306200ff andi r2,r3,0x00ff
00182bd4: 10570004 beq r2,r23,0x00182be8   branch if not charging ability
00182bd8: 00000000 nop
00182bdc: 10400002 beq r2,r0,0x00182be8      branch if
00182be0: 2463ffff addiu r3,r3,0xffff      CT decrement?
00182be4: a203015d sb r3,0x015d(r16)      store new ability CT
00182be8: 2a420015 slti r2,r18,0x0015
00182bec: 1440fff1 bne r2,r0,0x00182bb4      cycle through each unit
00182bf0: 261001c0 addiu r16,r16,0x01c0      r16 = next unit

00182bf4: 34060003 ori r6,r0,0x0003
00182bf8: 3c018019 lui r1,0x8019
00182bfc: ac26f518 sw r6,-0x0ae8(r1)
00182c00: 08060c08 j 0x00183020
00182c04: 00000000 nop
00182c08: 00009021 addu r18,r0,r0
00182c0c: 00008021 addu r16,r0,r0
00182c10: 02168821 addu r17,r16,r22
00182c14: 0c060cb3 jal 0x001832cc
00182c18: 02202021 addu r4,r17,r0
00182c1c: 3042000f andi r2,r2,0x000f
00182c20: 14400015 bne r2,r0,0x00182c78
00182c24: 00000000 nop
00182c28: 9222015d lbu r2,0x015d(r17)      load ability CT
00182c2c: 00000000 nop
00182c30: 14400011 bne r2,r0,0x00182c78
00182c34: 00000000 nop
00182c38: 92220058 lbu r2,0x0058(r17)      load status
00182c3c: 00000000 nop
00182c40: 30420001 andi r2,r2,0x0001
00182c44: 10400006 beq r2,r0,0x00182c60      performing check
00182c48: 00000000 nop
00182c4c: 0c0179de jal 0x0005e778      [[Transfer Last Ability Used CT]]
00182c50: 02202021 addu r4,r17,r0
00182c54: 9222018b lbu r2,0x018b(r17)      load unit id?
00182c58: 08060b19 j 0x00182c64
00182c5c: a222015d sb r2,0x015d(r17)      store ability CT
00182c60: a237015d sb r23,0x015d(r17)      store ability CT
00182c64: 34020009 ori r2,r0,0x0009
00182c68: 3c018019 lui r1,0x8019
00182c6c: ac22f518 sw r2,-0x0ae8(r1)      store 9 into ??
00182c70: 08060c11 j 0x00183044
00182c74: 36420200 ori r2,r18,0x0200
00182c78: 26520001 addiu r18,r18,0x0001
00182c7c: 2a420015 slti r2,r18,0x0015
00182c80: 1440ffe3 bne r2,r0,0x00182c10
00182c84: 261001c0 addiu r16,r16,0x01c0      cycles through each unit

00182c88: 08060c06 j 0x00183018
00182c8c: 34020004 ori r2,r0,0x0004
00182c90: 00009021 addu r18,r0,r0
00182c94: 02c08021 addu r16,r22,r0
00182c98: 92020001 lbu r2,0x0001(r16)      load unit ID
00182c9c: 00000000 nop
00182ca0: 10570008 beq r2,r23,0x00182cc4   branch if doesn't exist?
00182ca4: 00000000 nop
00182ca8: 92020058 lbu r2,0x0058(r16)      laod status
00182cac: 00000000 nop
00182cb0: 30420004 andi r2,r2,0x0004
00182cb4: 14400003 bne r2,r0,0x00182cc4      jump check?
00182cb8: 00000000 nop
00182cbc: 0c063644 jal 0x0018d910      ??
00182cc0: 02402021 addu r4,r18,r0
00182cc4: 26520001 addiu r18,r18,0x0001
00182cc8: 2a420015 slti r2,r18,0x0015
00182ccc: 1440fff2 bne r2,r0,0x00182c98
00182cd0: 261001c0 addiu r16,r16,0x01c0      Cycles through each unit

00182cd4: 34060005 ori r6,r0,0x0005
00182cd8: 3c018019 lui r1,0x8019
00182cdc: ac26f518 sw r6,-0x0ae8(r1)
00182ce0: 08060c08 j 0x00183020
00182ce4: 00000000 nop
00182ce8: 00009021 addu r18,r0,r0
00182cec: 3c048019 lui r4,0x8019
00182cf0: 2484f8b0 addiu r4,r4,0xf8b0      AI data?
00182cf4: 02c01821 addu r3,r22,r0

00182cf8: a0800000 sb r0,0x0000(r4)
00182cfc: 90620001 lbu r2,0x0001(r3)
00182d00: 00000000 nop
00182d04: 10570009 beq r2,r23,0x00182d2c
00182d08: 26520001 addiu r18,r18,0x0001
00182d0c: 90620058 lbu r2,0x0058(r3)      
00182d10: 00000000 nop
00182d14: 30420004 andi r2,r2,0x0004
00182d18: 14400004 bne r2,r0,0x00182d2c      jump check
00182d1c: 00000000 nop
00182d20: 906201b1 lbu r2,0x01b1(r3)
00182d24: 00000000 nop
00182d28: a0820000 sb r2,0x0000(r4)
00182d2c: 24840001 addiu r4,r4,0x0001
00182d30: 2a420015 slti r2,r18,0x0015
00182d34: 1440fff0 bne r2,r0,0x00182cf8
00182d38: 246301c0 addiu r3,r3,0x01c0      Cycle through each nit

00182d3c: 34060006 ori r6,r0,0x0006
00182d40: 3c018019 lui r1,0x8019
00182d44: ac26f518 sw r6,-0x0ae8(r1)
00182d48: 08060c08 j 0x00183020
00182d4c: 00000000 nop
00182d50: 00009021 addu r18,r0,r0

00182d54: 3c018019 lui r1,0x8019
00182d58: 00320821 addu r1,r1,r18
00182d5c: 9022f8b0 lbu r2,-0x0750(r1)
00182d60: 00000000 nop
00182d64: 1440feea bne r2,r0,0x00182910      skip to active turn part
00182d68: 00000000 nop
00182d6c: 26520001 addiu r18,r18,0x0001
00182d70: 2a420015 slti r2,r18,0x0015
00182d74: 1440fff7 bne r2,r0,0x00182d54
00182d78: 00000000 nop

00182d7c: 3c018019 lui r1,0x8019
00182d80: ac20f518 sw r0,-0x0ae8(r1)
00182d84: 08060c08 j 0x00183020
00182d88: 00000000 nop
00182d8c: 341300fe ori r19,r0,0x00fe
00182d90: 341400ff ori r20,r0,0x00ff
00182d94: 00009021 addu r18,r0,r0
00182d98: 02c08821 addu r17,r22,r0
00182d9c: 00008021 addu r16,r0,r0
00182da0: 0c060cb3 jal 0x001832cc
00182da4: 02202021 addu r4,r17,r0
00182da8: 30420001 andi r2,r2,0x0001
00182dac: 1440000a bne r2,r0,0x00182dd8
00182db0: 263101c0 addiu r17,r17,0x01c0
00182db4: 3c018019 lui r1,0x8019
00182db8: 00300821 addu r1,r1,r16
00182dbc: 90230905 lbu r3,0x0905(r1)      load CT
00182dc0: 00000000 nop
00182dc4: 0263102b sltu r2,r19,r3
00182dc8: 10400003 beq r2,r0,0x00182dd8
00182dcc: 00000000 nop
00182dd0: 0240a021 addu r20,r18,r0
00182dd4: 00609821 addu r19,r3,r0
00182dd8: 26520001 addiu r18,r18,0x0001
00182ddc: 2a420015 slti r2,r18,0x0015
00182de0: 1440ffef bne r2,r0,0x00182da0
00182de4: 261001c0 addiu r16,r16,0x01c0      Cycle through each unit

00182de8: 1697fece bne r20,r23,0x00182924
00182dec: 34060003 ori r6,r0,0x0003
00182df0: 3c018019 lui r1,0x8019
00182df4: ac26f51c sw r6,-0x0ae4(r1)
00182df8: 08060c06 j 0x00183018
00182dfc: 3402000d ori r2,r0,0x000d
00182e00: 00009021 addu r18,r0,r0
00182e04: 02c09821 addu r19,r22,r0
00182e08: 02608821 addu r17,r19,r0
00182e0c: 92220186 lbu r2,0x0186(r17)      load current turn byte
00182e10: 00000000 nop
00182e14: 1040000f beq r2,r0,0x00182e54      skip if turn over?
00182e18: 00000000 nop
00182e1c: 0c060cb3 jal 0x001832cc      jump to ?
00182e20: 02202021 addu r4,r17,r0
00182e24: 02202021 addu r4,r17,r0
00182e28: 0c060f44 jal 0x00183d10      Jump to nullify act/move
00182e2c: 00408021 addu r16,r2,r0
00182e30: 32100001 andi r16,r16,0x0001
00182e34: 16000003 bne r16,r0,0x00182e44
00182e38: 267301c0 addiu r19,r19,0x01c0
00182e3c: 10400081 beq r2,r0,0x00183044
00182e40: 36420100 ori r2,r18,0x0100
00182e44: 0c060f1b jal 0x00183c6c
00182e48: 02402021 addu r4,r18,r0
00182e4c: 08060b96 j 0x00182e58
00182e50: a2200186 sb r0,0x0186(r17)      store turn over(?)
00182e54: 267301c0 addiu r19,r19,0x01c0
00182e58: 26520001 addiu r18,r18,0x0001
00182e5c: 2a420015 slti r2,r18,0x0015
00182e60: 1440ffea bne r2,r0,0x00182e0c
00182e64: 02608821 addu r17,r19,r0      cycle through each unit?

00182e68: 08060c06 j 0x00183018
00182e6c: 34020013 ori r2,r0,0x0013
00182e70: 3c038019 lui r3,0x8019
00182e74: 8c63f520 lw r3,-0x0ae0(r3)
00182e78: 3402000f ori r2,r0,0x000f
00182e7c: 3c018019 lui r1,0x8019
00182e80: ac22f518 sw r2,-0x0ae8(r1)
00182e84: 2402ffff addiu r2,r0,0xffff
00182e88: 10620065 beq r3,r2,0x00183020
00182e8c: 00000000 nop
00182e90: 000320c0 sll r4,r3,0x03
00182e94: 00832023 subu r4,r4,r3
00182e98: 00042180 sll r4,r4,0x06
00182e9c: 0c0635f2 jal 0x0018d7c8      Regen and Poison
00182ea0: 00962021 addu r4,r4,r22
00182ea4: 08060bc7 j 0x00182f1c
00182ea8: 00000000 nop
00182eac: 3c038019 lui r3,0x8019
00182eb0: 8c63f520 lw r3,-0x0ae0(r3)
00182eb4: 34020011 ori r2,r0,0x0011
00182eb8: 3c018019 lui r1,0x8019
00182ebc: ac22f518 sw r2,-0x0ae8(r1)
00182ec0: 2402ffff addiu r2,r0,0xffff
00182ec4: 10620056 beq r3,r2,0x00183020
00182ec8: 00000000 nop
00182ecc: 000320c0 sll r4,r3,0x03
00182ed0: 00832023 subu r4,r4,r3
00182ed4: 00042180 sll r4,r4,0x06
00182ed8: 0c0636a2 jal 0x0018da88      Poison Marsh Routine
00182edc: 00962021 addu r4,r4,r22
00182ee0: 08060bc7 j 0x00182f1c
00182ee4: 00000000 nop
00182ee8: 3c038019 lui r3,0x8019
00182eec: 8c63f520 lw r3,-0x0ae0(r3)
00182ef0: 3402000d ori r2,r0,0x000d
00182ef4: 3c018019 lui r1,0x8019
00182ef8: ac22f518 sw r2,-0x0ae8(r1)
00182efc: 2402ffff addiu r2,r0,0xffff
00182f00: 10620047 beq r3,r2,0x00183020
00182f04: 00000000 nop
00182f08: 000320c0 sll r4,r3,0x03
00182f0c: 00832023 subu r4,r4,r3
00182f10: 00042180 sll r4,r4,0x06
00182f14: 0c06361a jal 0x0018d868      transparent removal routine
00182f18: 00962021 addu r4,r4,r22
00182f1c: 10400040 beq r2,r0,0x00183020
00182f20: 00000000 nop
00182f24: 3c028019 lui r2,0x8019
00182f28: 8c42f520 lw r2,-0x0ae0(r2)
00182f2c: 08060c11 j 0x00183044
00182f30: 34420300 ori r2,r2,0x0300
00182f34: 3c028019 lui r2,0x8019
00182f38: 9042389d lbu r2,0x389d(r2)
00182f3c: 00000000 nop
00182f40: 10400033 beq r2,r0,0x00183010
00182f44: 3405005d ori r5,r0,0x005d
00182f48: 00009021 addu r18,r0,r0
00182f4c: 3c048019 lui r4,0x8019
00182f50: 2484f8b0 addiu r4,r4,0xf8b0
00182f54: 02c01821 addu r3,r22,r0

00182f58: a0800000 sb r0,0x0000(r4)
00182f5c: 90620003 lbu r2,0x0003(r3)
00182f60: 00000000 nop
00182f64: 14450006 bne r2,r5,0x00182f80
00182f68: 26520001 addiu r18,r18,0x0001
00182f6c: 90620001 lbu r2,0x0001(r3)
00182f70: 00000000 nop
00182f74: 10570002 beq r2,r23,0x00182f80
00182f78: 00000000 nop
00182f7c: a09e0000 sb r30,0x0000(r4)
00182f80: 24840001 addiu r4,r4,0x0001
00182f84: 2a420015 slti r2,r18,0x0015
00182f88: 1440fff3 bne r2,r0,0x00182f58
00182f8c: 246301c0 addiu r3,r3,0x01c0      Cycle through each unit

00182f90: 3406000e ori r6,r0,0x000e
00182f94: 3c018019 lui r1,0x8019
00182f98: ac26f518 sw r6,-0x0ae8(r1)
00182f9c: 08060c08 j 0x00183020
00182fa0: 00000000 nop
00182fa4: 3c018019 lui r1,0x8019
00182fa8: a020389d sb r0,0x389d(r1)
00182fac: 00009021 addu r18,r0,r0
00182fb0: 3c138019 lui r19,0x8019
00182fb4: 2673f8b0 addiu r19,r19,0xf8b0
00182fb8: 02c08821 addu r17,r22,r0

00182fbc: 92620000 lbu r2,0x0000(r19)
00182fc0: 00000000 nop
00182fc4: 1040000d beq r2,r0,0x00182ffc
00182fc8: 00000000 nop
00182fcc: 92220001 lbu r2,0x0001(r17)
00182fd0: 00000000 nop
00182fd4: 10570009 beq r2,r23,0x00182ffc
00182fd8: 00000000 nop
00182fdc: a2600000 sb r0,0x0000(r19)
00182fe0: 0c063c0e jal 0x0018f038
00182fe4: 02202021 addu r4,r17,r0
00182fe8: 00408021 addu r16,r2,r0
00182fec: 121eff20 beq r16,r30,0x00182c70
00182ff0: 2402ffff addiu r2,r0,0xffff
00182ff4: 12020013 beq r16,r2,0x00183044
00182ff8: 36420500 ori r2,r18,0x0500
00182ffc: 26730001 addiu r19,r19,0x0001
00183000: 26520001 addiu r18,r18,0x0001
00183004: 2a420015 slti r2,r18,0x0015
00183008: 1440ffec bne r2,r0,0x00182fbc
0018300c: 263101c0 addiu r17,r17,0x01c0      Cycle through each unit

00183010: 3c028019 lui r2,0x8019
00183014: 8c42f51c lw r2,-0x0ae4(r2)
00183018: 3c018019 lui r1,0x8019
0018301c: ac22f518 sw r2,-0x0ae8(r1)
00183020: 8fa60010 lw r6,0x0010(r29)
00183024: 00000000 nop
00183028: 24c60001 addiu r6,r6,0x0001
0018302c: 28c204b1 slti r2,r6,0x04b1
00183030: 10400003 beq r2,r0,0x00183040
00183034: afa60010 sw r6,0x0010(r29)
00183038: 12a0fe53 beq r21,r0,0x00182988
0018303c: 00000000 nop
00183040: 3402ff00 ori r2,r0,0xff00
00183044: 8fbf003c lw r31,0x003c(r29)
00183048: 8fbe0038 lw r30,0x0038(r29)
0018304c: 8fb70034 lw r23,0x0034(r29)
00183050: 8fb60030 lw r22,0x0030(r29)
00183054: 8fb5002c lw r21,0x002c(r29)
00183058: 8fb40028 lw r20,0x0028(r29)
0018305c: 8fb30024 lw r19,0x0024(r29)
00183060: 8fb20020 lw r18,0x0020(r29)
00183064: 8fb1001c lw r17,0x001c(r29)
00183068: 8fb00018 lw r16,0x0018(r29)
0018306c: 27bd0040 addiu r29,r29,0x0040
00183070: 03e00008 jr r31
00183074: 00000000 nop


This one handles undead revival, death sentence, reraise, crystal/treasure infliction, and a couple other things


Undead Revive, Reraise, death sentence, some brave change? some defend change?
00183078: 27bdffe0 addiu r29,r29,0xffe0
0018307c: afb00010 sw r16,0x0010(r29)
00183080: 00a08021 addu r16,r5,r0
00183084: afb10014 sw r17,0x0014(r29)
00183088: 2611018c addiu r17,r16,0x018c
0018308c: afbf0018 sw r31,0x0018(r29)
00183090: 0c062f5d jal 0x0018bd74
00183094: 02202021 addu r4,r17,r0
00183098: 0c0088c3 jal 0x0002230c
0018309c: 00000000 nop
001830a0: 00403021 addu r6,r2,r0
001830a4: 92030058 lbu r3,0x0058(r16)      load status
001830a8: 34020020 ori r2,r0,0x0020      dead check
001830ac: 30630030 andi r3,r3,0x0030      dead + undead check
001830b0: 14620013 bne r3,r2,0x00183100
001830b4: 00000000 nop
001830b8: 9202005a lbu r2,0x005a(r16)      load status
001830bc: 00000000 nop
001830c0: 30420020 andi r2,r2,0x0020      reraise check
001830c4: 1040000e beq r2,r0,0x00183100
001830c8: 3c03cccc lui r3,0xcccc
001830cc: 9602002a lhu r2,0x002a(r16)      load max hp
001830d0: 3463cccd ori r3,r3,0xcccd
001830d4: 00430019 multu r2,r3
001830d8: 34020002 ori r2,r0,0x0002
001830dc: 34030020 ori r3,r0,0x0020
001830e0: a20301ac sb r3,0x01ac(r16)      store remove dead
001830e4: a20301ae sb r3,0x01ae(r16)      store remove reraise
001830e8: 34030048 ori r3,r0,0x0048
001830ec: a20301b1 sb r3,0x01b1(r16)      store attack type HP recovery + status change
001830f0: 00001810 mfhi r3
001830f4: 000318c2 srl r3,r3,0x03
001830f8: 08060cad j 0x001832b4
001830fc: a6030192 sh r3,0x0192(r16)      store hp recovery
00183100: 92050058 lbu r5,0x0058(r16)      load status
00183104: 00000000 nop
00183108: 30a20020 andi r2,r5,0x0020      dead check?
0018310c: 1040003d beq r2,r0,0x00183204
00183110: 00000000 nop
00183114: 3c028019 lui r2,0x8019
00183118: 8c42f5fc lw r2,-0x0a04(r2)      load ?
0018311c: 00000000 nop
00183120: 14400038 bne r2,r0,0x00183204
00183124: 00000000 nop
00183128: 92020005 lbu r2,0x0005(r16)      load ENTD flags
0018312c: 00000000 nop
00183130: 30420004 andi r2,r2,0x0004
00183134: 1440005f bne r2,r0,0x001832b4      immortal check
00183138: 00001021 addu r2,r0,r0
0018313c: 92020006 lbu r2,0x0006(r16)      load gender
00183140: 00000000 nop
00183144: 30420009 andi r2,r2,0x0009
00183148: 1440005a bne r2,r0,0x001832b4      load/save formation check
0018314c: 00001021 addu r2,r0,r0
00183150: 92040007 lbu r4,0x0007(r16)      load death counter
00183154: 340200ff ori r2,r0,0x00ff
00183158: 2484ffff addiu r4,r4,0xffff
0018315c: 308300ff andi r3,r4,0x00ff
00183160: 10620003 beq r3,r2,0x00183170      something with death counter?
00183164: 00001021 addu r2,r0,r0
00183168: 08060cad j 0x001832b4
0018316c: a2040007 sb r4,0x0007(r16)      store death counter
00183170: 30a20010 andi r2,r5,0x0010
00183174: 10400012 beq r2,r0,0x001831c0      undead check?
00183178: 30c20001 andi r2,r6,0x0001
0018317c: 10400010 beq r2,r0,0x001831c0
00183180: 34020020 ori r2,r0,0x0020
00183184: 0c0088c3 jal 0x0002230c
00183188: a2220020 sb r2,0x0020(r17)      store dead status removal
0018318c: 9603002a lhu r3,0x002a(r16)      load max hp
00183190: 00000000 nop
00183194: 00430018 mult r2,r3
00183198: 00001812 mflo r3
0018319c: 04610002 bgez r3,0x001831a8
001831a0: 34020002 ori r2,r0,0x0002
001831a4: 24637fff addiu r3,r3,0x7fff
001831a8: 00031bc3 sra r3,r3,0x0f
001831ac: 24630001 addiu r3,r3,0x0001
001831b0: a6230006 sh r3,0x0006(r17)      store HP recovery      
001831b4: 34030048 ori r3,r0,0x0048
001831b8: 08060cad j 0x001832b4
001831bc: a2230025 sb r3,0x0025(r17)      store attack type
001831c0: 920201ba lbu r2,0x01ba(r16)      load ENTD flags
001831c4: 00000000 nop
001831c8: 30420008 andi r2,r2,0x0008      Control check
001831cc: 10400002 beq r2,r0,0x001831d8
001831d0: 34030010 ori r3,r0,0x0010
001831d4: 34030110 ori r3,r0,0x0110
001831d8: 00c31024 and r2,r6,r3
001831dc: 10400004 beq r2,r0,0x001831f0      ??
001831e0: 34020001 ori r2,r0,0x0001
001831e4: 34030040 ori r3,r0,0x0040
001831e8: 08060c7e j 0x001831f8
001831ec: a223001b sb r3,0x001b(r17)      store status infliction crystal
001831f0: 34030001 ori r3,r0,0x0001
001831f4: a223001c sb r3,0x001c(r17)      store status infliction treasure
001831f8: 34030008 ori r3,r0,0x0008
001831fc: 08060cad j 0x001832b4
00183200: a2230025 sb r3,0x0025(r17)      store status change attack type
00183204: 9202005c lbu r2,0x005c(r16)      load status 5
00183208: 00000000 nop
0018320c: 30420001 andi r2,r2,0x0001
00183210: 10400013 beq r2,r0,0x00183260      death sentence check
00183214: 00000000 nop
00183218: 9204006c lbu r4,0x006c(r16)      load death sentence CT
0018321c: 00000000 nop
00183220: 2484ffff addiu r4,r4,0xffff
00183224: 308200ff andi r2,r4,0x00ff      decrement?
00183228: 1440000c bne r2,r0,0x0018325c      branch if not death sentence killed
0018322c: 34020001 ori r2,r0,0x0001
00183230: a2220024 sb r2,0x0024(r17)      remove death sentence
00183234: 34020008 ori r2,r0,0x0008
00183238: a2220025 sb r2,0x0025(r17)      store status change
0018323c: 92020058 lbu r2,0x0058(r16)      load status
00183240: 00000000 nop
00183244: 30420010 andi r2,r2,0x0010      
00183248: 14400005 bne r2,r0,0x00183260      branch if not undead
0018324c: 34020020 ori r2,r0,0x0020
00183250: a222001b sb r2,0x001b(r17)      store add dead status
00183254: 08060cad j 0x001832b4         
00183258: 34020003 ori r2,r0,0x0003
0018325c: a204006c sb r4,0x006c(r16)      store death sentence CT
00183260: 92020058 lbu r2,0x0058(r16)      load status
00183264: 00000000 nop
00183268: 30420002 andi r2,r2,0x0002      defending flag?
0018326c: 10400004 beq r2,r0,0x00183280      branch if not defending?
00183270: 34020002 ori r2,r0,0x0002
00183274: a2220020 sb r2,0x0020(r17)      store defending status
00183278: 34020008 ori r2,r0,0x0008
0018327c: a2220025 sb r2,0x0025(r17)      store status change attack type
00183280: 92020024 lbu r2,0x0024(r16)      load status removal
00183284: 00000000 nop
00183288: 2c42000a sltiu r2,r2,0x000a
0018328c: 10400005 beq r2,r0,0x001832a4      ?
00183290: 34030081 ori r3,r0,0x0081
00183294: 92220025 lbu r2,0x0025(r17)      load attack type
00183298: a2230016 sb r3,0x0016(r17)      store brave change?
0018329c: 34420001 ori r2,r2,0x0001
001832a0: a2220025 sb r2,0x0025(r17)      store psuedo status change
001832a4: 92220025 lbu r2,0x0025(r17)      load attack type
001832a8: 00000000 nop
001832ac: 0002102b sltu r2,r0,r2      set if attack type != 0
001832b0: 00021040 sll r2,r2,0x01      attack type*2
001832b4: 8fbf0018 lw r31,0x0018(r29)
001832b8: 8fb10014 lw r17,0x0014(r29)
001832bc: 8fb00010 lw r16,0x0010(r29)
001832c0: 27bd0020 addiu r29,r29,0x0020
001832c4: 03e00008 jr r31
001832c8: 00000000 nop


sorry if i already posted this stuff, but i thought it was some important/useful ones
Title: Re: ASM Collective BATTLE.BIN Map
Post by: formerdeathcorps on June 29, 2012, 02:21:55 am
0011acdc: 27bdff10 addiu r29,r29,-0x00f0
0011ace0: afb100cc sw r17,0x00cc(r29)
0011ace4: 00808821 addu r17,r4,r0
0011ace8: afb400d8 sw r20,0x00d8(r29)
0011acec: 00c0a021 addu r20,r6,r0
0011acf0: afb500dc sw r21,0x00dc(r29)
0011acf4: 0000a821 addu r21,r0,r0
0011acf8: afb000c8 sw r16,0x00c8(r29)
0011acfc: 00a08021 addu r16,r5,r0
0011ad00: afbf00e8 sw r31,0x00e8(r29)
0011ad04: afb700e4 sw r23,0x00e4(r29)
0011ad08: afb600e0 sw r22,0x00e0(r29)
0011ad0c: afb300d4 sw r19,0x00d4(r29)
0011ad10: 0c060435 jal 0x001810d4      //r2 = Address of Unit RAM
0011ad14: afb200d0 sw r18,0x00d0(r29)
0011ad18: 0040b021 addu r22,r2,r0
0011ad1c: 16c00003 bne r22,r0,0x0011ad2c
0011ad20: 320300ff andi r3,r16,0x00ff
0011ad24: 080607b0 j 0x00181ec0           //If address is zero, GOTO END
0011ad28: 00001021 addu r2,r0,r0
0011ad2c: 34020014 ori r2,r0,0x0014
0011ad30: 14620010 bne r3,r2,0x0011ad74   //If r16 isn't 0x14, store r2 = 0xFF and GOTO END
0011ad34: 340200ff ori r2,r0,0x00ff
0011ad38: 02202021 addu r4,r17,r0
0011ad3c: 34050014 ori r5,r0,0x0014
0011ad40: 27a60020 addiu r6,r29,0x0020
0011ad44: 27a20078 addiu r2,r29,0x0078
0011ad48: afa20010 sw r2,0x0010(r29)
0011ad4c: 27a20090 addiu r2,r29,0x0090
0011ad50: afa20018 sw r2,0x0018(r29)
0011ad54: 27a200a8 addiu r2,r29,0x00a8
0011ad58: 27a70060 addiu r7,r29,0x0060
0011ad5c: afa00014 sw r0,0x0014(r29)
0011ad60: 0c0605f0 jal 0x001817c0
0011ad64: afa2001c sw r2,0x001c(r29)
0011ad68: 00409021 addu r18,r2,r0
0011ad6c: 16400004 bne r18,r0,0x0011ad80
0011ad70: 340200ff ori r2,r0,0x00ff
0011ad74: a2820000 sb r2,0x0000(r20)
0011ad78: 080607b0 j 0x00181ec0
0011ad7c: 00001021 addu r2,r0,r0
0011ad80: 02b2102a slt r2,r21,r18
0011ad84: 10400018 beq r2,r0,0x0011ade8
0011ad88: 00008821 addu r17,r0,r0
0011ad8c: 3407fe82 ori r7,r0,-0x017e
0011ad90: 3c068006 lui r6,0x8006
0011ad94: 24c61020 addiu r6,r6,0x1020
0011ad98: 27a50048 addiu r5,r29,0x0048
0011ad9c: 27a40020 addiu r4,r29,0x0020
0011ada0: 94830000 lhu r3,0x0000(r4)
0011ada4: 00000000 nop
0011ada8: 00671021 addu r2,r3,r7
0011adac: 3042ffff andi r2,r2,-0x0001
0011adb0: 2c42000c sltiu r2,r2,0x000c
0011adb4: 10400008 beq r2,r0,0x0011add8
0011adb8: 24840002 addiu r4,r4,0x0002
0011adbc: 2462fe82 addiu r2,r3,-0x017e
0011adc0: 00021400 sll r2,r2,0x10
0011adc4: 00021403 sra r2,r2,0x10
0011adc8: 00461021 addu r2,r2,r6
0011adcc: 90420000 lbu r2,0x0000(r2)
0011add0: 00000000 nop
0011add4: a0a20000 sb r2,0x0000(r5)
0011add8: 26310001 addiu r17,r17,0x0001
0011addc: 0232102a slt r2,r17,r18
0011ade0: 1440ffef bne r2,r0,0x0011ada0
0011ade4: 24a50001 addiu r5,r5,0x0001
0011ade8: 00008821 addu r17,r0,r0
0011adec: 27b70048 addiu r23,r29,0x0048
0011adf0: 00009821 addu r19,r0,r0
0011adf4: 3c028006 lui r2,0x8006
0011adf8: 24422eb8 addiu r2,r2,0x2eb8
0011adfc: 02623021 addu r6,r19,r2
0011ae00: 90c20005 lbu r2,0x0005(r6)     //Load weapon type
0011ae04: 1a40000e blez r18,0x0011ae40
0011ae08: 00002021 addu r4,r0,r0
0011ae0c: 304700ff andi r7,r2,0x00ff
0011ae10: 02e01821 addu r3,r23,r0
0011ae14: 02432821 addu r5,r18,r3
0011ae18: 90620000 lbu r2,0x0000(r3)
0011ae1c: 00000000 nop
0011ae20: 14e20003 bne r7,r2,0x0011ae30  //If weapon type doesn't match that of THROW skill, GOTO NEXT
0011ae24: 00000000 nop
0011ae28: 08060790 j 0x00181e40
0011ae2c: 34040001 ori r4,r0,0x0001
0011ae30: 24630001 addiu r3,r3,0x0001
0011ae34: 0065102a slt r2,r3,r5
0011ae38: 1440fff7 bne r2,r0,0x0011ae18
0011ae3c: 00000000 nop
0011ae40: 10800019 beq r4,r0,0x0011aea8
0011ae44: 2673000c addiu r19,r19,0x000c
0011ae48: 90c20003 lbu r2,0x0003(r6)
0011ae4c: 00000000 nop
0011ae50: 30420080 andi r2,r2,0x0080        //Check for weapon
0011ae54: 10400014 beq r2,r0,0x0011aea8
0011ae58: 00000000 nop
0011ae5c: 90c20004 lbu r2,0x0004(r6)        //Weapon ID
0011ae60: 00000000 nop
0011ae64: 000210c0 sll r2,r2,0x03
0011ae68: 3c018006 lui r1,0x8006
0011ae6c: 00220821 addu r1,r1,r2
0011ae70: 90223ab9 lbu r2,0x3ab9(r1)
0011ae74: 00000000 nop
0011ae78: 30420002 andi r2,r2,0x0002
0011ae7c: 1040000a beq r2,r0,0x0011aea8     //Throwable Check
0011ae80: 02c02021 addu r4,r22,r0
0011ae84: 02208021 addu r16,r17,r0
0011ae88: 320500ff andi r5,r16,0x00ff
0011ae8c: 0c05f255 jal 0x0017c954
0011ae90: 00003021 addu r6,r0,r0
0011ae94: 14400004 bne r2,r0,0x0011aea8
0011ae98: 00000000 nop
0011ae9c: a2900000 sb r16,0x0000(r20)
0011aea0: 26940001 addiu r20,r20,0x0001
0011aea4: 26b50001 addiu r21,r21,0x0001
0011aea8: 26310001 addiu r17,r17,0x0001
0011aeac: 2a220100 slti r2,r17,0x0100
0011aeb0: 1440ffd0 bne r2,r0,0x0011adf4
0011aeb4: 340200ff ori r2,r0,0x00ff
0011aeb8: a2820000 sb r2,0x0000(r20)
0011aebc: 26a20100 addiu r2,r21,0x0100
0011aec0: 8fbf00e8 lw r31,0x00e8(r29)
0011aec4: 8fb700e4 lw r23,0x00e4(r29)
0011aec8: 8fb600e0 lw r22,0x00e0(r29)
0011aecc: 8fb500dc lw r21,0x00dc(r29)
0011aed0: 8fb400d8 lw r20,0x00d8(r29)
0011aed4: 8fb300d4 lw r19,0x00d4(r29)
0011aed8: 8fb200d0 lw r18,0x00d0(r29)
0011aedc: 8fb100cc lw r17,0x00cc(r29)
0011aee0: 8fb000c8 lw r16,0x00c8(r29)
0011aee4: 27bd00f0 addiu r29,r29,0x00f0
0011aee8: 03e00008 jr r31
0011aeec: 00000000 nop
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on September 10, 2012, 10:16:02 pm
I found this after setting a breakpoint to the beginning of effects data when cure was being cast. There is a ton of other routines before and some after this part, but this could let us crack into effects a bit.

0007b27c: 25087798 addiu r8,r8,0x7798
0007b280: 01006821 addu r13,r8,r0
0007b284: 3c08800a lui r8,0x800a
0007b288: 250877a0 addiu r8,r8,0x77a0
0007b28c: 01007021 addu r14,r8,r0
0007b290: c9800000 lwc2 gtedr00_vxy0,0x0000(r12)
0007b294: c9810004 lwc2 gtedr01_vz0,0x0004(r12)
0007b298: c9a20000 lwc2 gtedr02_vxy1,0x0000(r13)
0007b29c: c9a30004 lwc2 gtedr03_vz1,0x0004(r13)
0007b2a0: c9c40000 lwc2 gtedr04_vxy2,0x0000(r14)
0007b2a4: c9c50004 lwc2 gtedr05_vz2,0x0004(r14)
0007b2a8: 00000000 nop
0007b2ac: 00000000 nop
0007b2b0: 4a280030 rtpt
0007b2b4: 02571025 or r2,r18,r23
0007b2b8: 30420001 andi r2,r2,0x0001
0007b2bc: 10400004 beq r2,r0,0x0007b2d0
0007b2c0: 00000000 nop
0007b2c4: 90820007 lbu r2,0x0007(r4)
0007b2c8: 0801ecb7 j 0x0007b2dc
0007b2cc: 34420002 ori r2,r2,0x0002
0007b2d0: 90820007 lbu r2,0x0007(r4)
0007b2d4: 00000000 nop
0007b2d8: 304200fd andi r2,r2,0x00fd
0007b2dc: a0820007 sb r2,0x0007(r4)
0007b2e0: 96c20004 lhu r2,0x0004(r22)
0007b2e4: 32e30060 andi r3,r23,0x0060
0007b2e8: 00431025 or r2,r2,r3
0007b2ec: a4820016 sh r2,0x0016(r4)
0007b2f0: 96c20006 lhu r2,0x0006(r22)
0007b2f4: 00000000 nop
0007b2f8: a482000e sh r2,0x000e(r4)
0007b2fc: 24820008 addiu r2,r4,0x0008
0007b300: 00406021 addu r12,r2,r0
0007b304: 24820010 addiu r2,r4,0x0010
0007b308: 00406821 addu r13,r2,r0
0007b30c: 24820018 addiu r2,r4,0x0018
0007b310: 00407021 addu r14,r2,r0
0007b314: e98c0000 swc2 gtedr12_sxy0,0x0000(r12)
0007b318: e9ad0000 swc2 gtedr13_sxy1,0x0000(r13)
0007b31c: e9ce0000 swc2 gtedr14_sxy2,0x0000(r14)
0007b320: 3c08800a lui r8,0x800a
0007b324: 250877a8 addiu r8,r8,0x77a8
0007b328: 01006021 addu r12,r8,r0
0007b32c: c9800000 lwc2 gtedr00_vxy0,0x0000(r12)
0007b330: c9810004 lwc2 gtedr01_vz0,0x0004(r12)
0007b334: 00000000 nop
0007b338: 00000000 nop
0007b33c: 4a180001 rtps


I'm also posting some spreadsheets that Xif shared, which really got this kickstarted. Effects Data.txt is all the notes i have.. which isn't much. Graphics Routines are a huge bunch of seemingly-important graphic-related routines.

EDIT: updated Effect Data.txt
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Glain on September 11, 2012, 10:55:36 am
Interesting stuff.

If we want to try to crack into this a bit...
I found a site here (http://code.google.com/p/pops-gte/wiki/GTE_Programming_Guide) that seems useful in determining what some of these commands do (lwc2, swc2). Still not entirely sure what "rtps" or "rtpt" are. The page at the link I posted shows them as commands but doesn't say what they do.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on September 11, 2012, 05:00:18 pm
Great find.. inside info ^_^

I found this that explains the commands a little bit more. just ctrl f and put in the command word

http://www.weblearn.hs-bremen.de/risse/RST/docs/MIPS/mips-isa.pdf

I'm gonna continue deciphering the routines... I think once we know a bit more about the effect architecture and we decipher some things close to the coprocessor commands they may be more easily understood
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Glain on September 12, 2012, 01:21:19 am
True enough.

I think rtps and rtpt have something to do with division.

They're listed here (http://mamedev.org/source/src/emu/cpu/psx/gte.c.html). Seems to be source code for the MAME emulator.

You do have to scroll through a bunch of code to find rtps and rtpt, and they do a bunch of math that's difficult to follow, but it looks like you could follow that code to figure out what they do...

Seems like different CPUs can have different coprocessors, and the PSX used its own unique one. So these commands are basically PSX-exclusive, not standard MIPS at all. (I couldn't find them in the document you linked... I did download it though; looks like a good resource.)
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on September 12, 2012, 11:41:03 pm
I'm attaching an updated report on effect file data. I figured out that you can mess with some of the parameters of the effects... like what frame is called, how many of that frame are called, or how long that frame is called for. Although you still have to work within the architecture so it's not free reign yet. There are some patterns with the other blocks of data, but some sections are just ambiguous code blocks and sparse isolated values. I tried to structure the top as reader-friendly as possible. I think if you open cure in a hex editor you can follow the numbers in the .txt.

Here is a couple of examples of how things can change, courtesy of the awesome Celdia :D

http://www.youtube.com/watch?v=6vtfcyL-i78&feature=youtu.be

http://www.youtube.com/watch?v=CpTQvBDLEaM&feature=youtu.be


Still got a long way to go, but its the first breakthrough so far so.... \o/
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on September 14, 2012, 03:32:51 pm
OK, i'm posting effect data.txt one more time. I went through the entire E001.bin file and was able to determine what most of the sections do. There are a couple of sections that control motion. Another one of the sections is sound effect data which I have no clue how one would edit. The biggest block of data seems like a bunch of empty data that /could/ be utilized. It controls stuff like camera commands, background and foreground shading/flashing. However, I think it would be very difficult to develop a standard structure that applies for all effect files. Perhaps with more research we could lock down exactly what each bit does, but there's alot to go through.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Vanya on September 14, 2012, 11:20:20 pm
Sweet stuff, Choto. I've been waiting for this info to be cracked for a very long time. Can't wait to see it go further.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on October 02, 2012, 08:57:14 am
Question: Does anybody know wtf this byte is/does???

lui r2,0x8019
lw r2,-0x0a10(r2)

It's used like everywhere in the routines that i'm decoding.. It seems to be some kind of control variable that decides what action to take later on... and it seems to be related to display. Could be totally wrong though
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Glain on October 02, 2012, 06:29:44 pm
The latest Data Locations (that I know of) from SA has it listed as:
8018f5f0 - Reaction Check? (word)

But I don't think I've ever seen it in any of the stuff I looked at...
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on October 02, 2012, 10:52:45 pm
Thanks for the heads up Glain, for some reason I never saw that byte in my data locations.txt.

I did some deciphering in the past couple days and compiled this file. It started just looking up something on auto potion and snowballed into other things. There's some good stuff on Reactions, some good stuff on data transfer during an action. There's some formula hardcoding for multi-hit formulas. There's some two swords hardcoding. there's some routines that are based on action menu types and skillset loading. Seems like we could reap some benefits from them if they're sorted out a bit. I lost a little steam at this point and i have to finish something up for JoT5... so I'm gonna post what I've gotten so far in case anybody else gets active or interested.

Oh there's also a big grid that controls the panel highlighting for movement and targeting... I think i saw some reflect reaction undoing too. and some mime functions.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on October 05, 2012, 11:20:14 am
Double post \o/

So it appears that everything I decoded... SA already decoded. Kinda the point of the wiki to avoid stuff like that but he did a much better job than I could have anyway. If you visit the wiki you'll notice the new routines with a red link. I'll upload the routines soon. There is quite a big chunk of info though, so i'm sure we can get some hacks or bug fixes out of it. I'm also gonna post the notes he sent me so anybody else can play with them if they want.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Glain on October 05, 2012, 04:21:46 pm
I ran into the same exact situation with evasion.  I had commented a bunch of those routines and then realized SA had already done it.  I think that was before I even had any of his elusive text files.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on October 26, 2012, 11:52:19 am
a little while ago i posted coprocessor commands in the code. I found this very detailed explanation of how the PSX works and what the coprocessor commands are actually doing. It's a very technical article but well worth taking a look at:

http://www.raphnet.net/electronique/psx_adaptor/Playstation.txt

he explains how graphics are rendered... system calls... sound processing.. all kinds of stuff.
Title: Re: ASM Collective BATTLE.BIN Map
Post by: Choto on November 26, 2012, 05:50:51 pm
Here's another seemingly robust resource on how the PSX works. I think alot of info could be discovered from these resources

http://psx.rules.org/psxrul2.shtml