|
Glain
[Posts: 356]
Logged
|
  - [August 22, 2012, 03:36:59 AM]
|
« Reply #71 on: August 22, 2012, 03:36:59 AM »
This version should work without having to remove (nop out) any other calls. The idea was to place an immediate return statement at the start of the elemental and inner elemental routines, to make them do nothing, and shift the real routines one line down, making up the space somewhere in the process (removing a nop, reusing a register). Patch and source are one and the same! Formatting looks messed up here but should be right if you copy/paste into a file. <Patch name="All formulas apply elemental"> <Description>All formulas apply elemental</Description> <Location file="BATTLE_BIN" offset="1249F0" mode="ASM"> j 0x186ffc # Call Apply Elemental routine (at new location) at the end of formula code </Location> <Location file="BATTLE_BIN" offset="11FFF8" mode="ASM"> jr ra # Return immediately from original routine lui t0,0x8019 # Shift routine down one space lw v0,0x2d98(t0) addiu sp,sp,-0x18 sw ra,0x14(sp) sw s0,0x10(sp) lbu v0,0x5a(v0) lbu s0,0x38f7(t0) # Regain space through repeated use of t0 = 0x8019 </Location> <Location file="BATTLE_BIN" offset="1200E0" mode="ASM"> jal 0x184e9c # Call inner elemental routine at new location </Location> <Location file="BATTLE_BIN" offset="11DE98" mode="ASM"> jr ra # Return immediately from original routine lui t0,0x8019 # Shift routine down one space lw v0,0x2d98(t0) addiu sp,sp,-0x18 sw ra,0x10(sp) lbu v0,0x6d(v0) move a1,a0 and v0,v0,a1 beq v0,zero,0x184ed8 lw v1,0x2d90(t0) # Regain space by eating a nop and reusing t0 jal 0x15cda0 # Jump to new absorb section nop </Location> <Location file="BATTLE_BIN" offset="11DF1C" mode="ASM"> lui t0,0x8019 # Elemental Half section lw t1,0x2d90(t0) lw t2,0x2d8c(t0) lhu t3,4(t1) nop sra t3,t3,1 # Halve damage sh t3,4(t1) # Store as damage sh t3,6(t2) # Store as returned healing (drain) nop nop nop </Location> <Location file="BATTLE_BIN" offset="11DF64" mode="ASM"> lui t0,0x8019 # Elemental Weak section lw t1,0x2d90(t0) lw t2,0x2d8c(t0) lhu v1,0x10(t1) lh a0,0x04(t1) ori v1,v1,0x0800 sll a0,a0,1 # Double damage sh v1,0x10(t1) sh a0,0x04(t1) # Store as damage sh a0,0x06(t2) # Store as returned healing (drain) </Location> <Location file="BATTLE_BIN" offset="120010" mode="ASM"> jal 0x15cd30 # Call new routine nop </Location> <Location file="BATTLE_BIN" offset="F5D30" mode="ASM"> lui t0,0x8019 # Element determination section lbu t1,0x38f4(t0) lbu t6,0x38f3(t0) sll t1,t1,8 or t1,t1,t6 lbu s0,0x38f7(t0) lbu t4,0x3904(t0) # Weapon element lbu t5,0x38d6(t0) # Ability element ori t2,zero,0x2004 and t3,t1,t2 # Check if "Weapon Strike" and flag under "Hit Allies" checked beq t3,t2,CMB # If so, jump to combine element section nop beq t5,zero,CMB # If this ability is Attack (ID 0), then jump to combine element section nop j PCB # Otherwise, jump past the combine section nop CMB: or s0,s0,t4 # Combine section; combine the weapon and ability element
PCB: j 0x15ce00 # Past combine section; go to next section nop </Location> <Location file="BATTLE_BIN" offset="F5DA0" mode="ASM"> lui t0,0x8019 # Elemental Absorb section lw t6,0x2d90(t0) lw t1,0x2d8c(t0) li t7,0x40 li t2,0x80 lhu t5,0x04(t6) lhu t3,0x06(t1) sb t7,0x25(t6) # Action type = HP Healing beq t5,zero,PDO sh zero,0x04(t6) # HP Damage = 0 sh t5,0x06(t6) # HP Healing = old HP Damage PDO: sh zero,0x06(t1) # Returned HP Healing = 0 (Reverse drain) sh t2,0x25(t1) # Returned action type = HP Damage (Reverse drain) jr ra sh t3,0x04(t1) # Returned HP Damage = Old Returned HP Healing (Reverse drain) </Location> <Location file="BATTLE_BIN" offset="F5E00" mode="ASM"> lui t0,0x8019 # Elemental Strengthen section lw t6,0x2d94(t0) lw t1,0x2d90(t0) lbu t6,0x0071(t6) lhu t2,0x0004(t1) and t6,t6,s0 beq t6,zero,END # Skip if element not strengthened lw t4,0x2d8c(t0) sll t5,t2,2 addu t5,t5,t2 addi t5,t5,2 sra t5,t5,2 # Damage = Damage * 5 / 4 (Rounded) sh t5,0x04(t1) # Save as HP Damage sh t5,0x06(t4) # Save as returned HP Healing (Drain) END: jr ra nop </Location> <Location file="BATTLE_BIN" offset="12002C" mode="ASM"> lw v1,0x80192d90 # Oil section (Target hit by fire attack) nop lhu v0,0x04(v1) nop sll v0,v0,1 # Double HP damage sh v0,0x04(v1) # Save as HP damage lbu v0,0x22(v1) nop </Location> <Location file="BATTLE_BIN" offset="120060" mode="ASM"> nop # Oil - don't overwrite action type lbu t0,0x25(a0) # Load Action type nop ori t0,t0,0x08 # Add status change sb t0,0x25(a0) # Save as action type </Location> <Location file="BATTLE_BIN" offset="120124" mode="ASM"> j 0x187140 # Jump over normal absorption block </Location> <Location file="BATTLE_BIN" offset="11EFA4" mode="ASM"> jr ra # Blank out routine (Weapon element strengthen) nop </Location> <Location file="BATTLE_BIN" offset="11EFFC" mode="ASM"> jr ra # Blank out routine (Ability element strengthen) nop </Location> <Location file="BATTLE_BIN" offset="CEE4" mode="ASM"> j 0x15ce60 # Jump to new section </Location> <Location file="BATTLE_BIN" offset="F5E60" mode="ASM"> lui t0,0x8019 sb zero,0x3904(t0) # Zero out weapon element jr ra sb zero,0x38f7(t0) # Zero out ability element </Location> <Location file="BATTLE_BIN" offset="1200C8" mode="ASM"> jal 0x15d5c0 # Call routine to null action and drain action </Location> <Location file="BATTLE_BIN" offset="11DEF8" mode="ASM"> jal 0x15d5c0 # Call routine to null action and drain action </Location> <Location file="BATTLE_BIN" offset="F65C0" mode="ASM"> addiu sp,sp,-12 sw ra,4(sp)
jal 0x184e40 # Nullify current action nop
lui t0,0x8019 lw t1,0x2d90(t0) lw t2,0x2d8c(t0) sw t1,8(sp) # Save action to stack sw t2,0x2d90(t0) # Save drain action as current action
jal 0x184e40 # Nullify current action (drain action) nop
lw t1,8(sp) # Load action from stack lui t0,0x8019 sw t1,0x2d90(t0) # Save current action back
lw ra,4(sp) addiu sp,sp,12 jr ra nop </Location> </Patch>
|
|
|
|