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.
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].
[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
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
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.
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 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
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 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?
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.
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
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.
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
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
(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
(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:
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,
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
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
(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
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):
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:
(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:
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.
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
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
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
(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.
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.
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.
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.
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.
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
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
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]
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] = ?
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
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.
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
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
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.
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.
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.
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
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
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: