entrypoint :ENTRYPOINT_0_MAIN
entrypoint :ENTRYPOINT_1_NOOP
entrypoint :ENTRYPOINT_2_TAKE_DAMAGE
entrypoint :ENTRYPOINT_3_TAKE_DAMAGE_SIMPLE
entrypoint :ENTRYPOINT_4_HANDLE_DEATH
entrypoint :ENTRYPOINT_5_NOOP
entrypoint :ENTRYPOINT_6_NOOP
entrypoint :ENTRYPOINT_7_NOOP
entrypoint :ENTRYPOINT_8_NOOP
entrypoint :ENTRYPOINT_9_NOOP
entrypoint :ENTRYPOINT_10
entrypoint :ENTRYPOINT_11_RENDER_TICK_STATUS
entrypoint :ENTRYPOINT_12_NOOP
entrypoint :ENTRYPOINT_13_NOOP
entrypoint :ENTRYPOINT_14_NOOP
entrypoint :ENTRYPOINT_15_NOOP
entrypoint :ENTRYPOINT_16
entrypoint :ENTRYPOINT_17_DETRANSFORM
entrypoint :ENTRYPOINT_18
entrypoint :ENTRYPOINT_19
entrypoint :ENTRYPOINT_20_TAKE_DAMAGE
entrypoint :ENTRYPOINT_21
entrypoint :ENTRYPOINT_22_NOOP
entrypoint :ENTRYPOINT_23_NOOP
entrypoint :ENTRYPOINT_24_NOOP
entrypoint :ENTRYPOINT_25_NOOP
entrypoint :ENTRYPOINT_26_NOOP
entrypoint :ENTRYPOINT_27_NOOP
entrypoint :ENTRYPOINT_28_NOOP
entrypoint :ENTRYPOINT_29_NOOP
entrypoint :ENTRYPOINT_30_NOOP
entrypoint :ENTRYPOINT_31_NOOP



#include lookup_tables.txt



data 0x10c
data 0xf00ff2d
data 0x49



; SUBROUTINE
WAIT_FOR_ANIMATION_TO_FINISH:
yield
call Battle::scriptAnimationHasFinished, stor[0], stor[8] ; bentIndex, finished
jmp_cmp ==, 0x0, stor[8], inl[:WAIT_FOR_ANIMATION_TO_FINISH] ; operand, left, right, addr
return



; SUBROUTINE
WAIT_FOR_BENT_ANIMATION_TO_FINISH:
yield
call Battle::scriptAnimationHasFinished, stor[28], stor[8] ; bentIndex, finished
jmp_cmp ==, 0x0, stor[8], inl[:WAIT_FOR_BENT_ANIMATION_TO_FINISH] ; operand, left, right, addr
return



; SUBROUTINE
; @param int s28 bent index
SET_BENT_ANIMATION:
jmp_cmp &, 0x2, stor[stor[stor[0], 28], 7], inl[:SET_BENT_ANIMATION_IDLE] ; is dragoon
jmp_cmp &, 0x40, stor[stor[stor[0], 28], 7], inl[:SET_BENT_ANIMATION_DEAD_STUNNED] ; is dead

; is stunned
call Battle::scriptGetBentStat, stor[28], STATUS, stor[8] ; bentIndex, statIndex, value
jmp_cmp &, 0x10, stor[8], inl[:SET_BENT_ANIMATION_DEAD_STUNNED] ; operand, left, right, addr

; 0 hp
call Battle::scriptGetBentStat2, stor[28], CURRENT_HP, stor[8] ; bentIndex, statIndex, value
jmp_cmp >=, 0x0, stor[8], inl[:SET_BENT_ANIMATION_DEAD_STUNNED] ; operand, left, right, addr

call Battle::scriptGetBentStat2, stor[28], MAX_HP, stor[9] ; bentIndex, statIndex, value
div 0x4, stor[9] ; amount, operand
jmp_cmp >=, stor[9], stor[8], inl[:SET_BENT_ANIMATION_HURT] ; operand, left, right, addr

call Battle::scriptGetBentStat, stor[28], STATUS, stor[8] ; bentIndex, statIndex, value
jmp_cmp &, 0x40, stor[8], inl[:SET_BENT_ANIMATION_DISPIRITED] ; operand, left, right, addr

SET_BENT_ANIMATION_IDLE:
call Battle::scriptGetLoadingBentAnimationIndex, stor[28], stor[8] ; bentIndex, animationIndex
jmp_cmp ==, 0x0, stor[8], inl[:SET_BENT_ANIMATION_EXIT] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[28], 0x0 ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[28], 0x1 ; bentIndex, loop
return

SET_BENT_ANIMATION_DEAD_STUNNED:
call Battle::scriptGetLoadingBentAnimationIndex, stor[28], stor[8] ; bentIndex, animationIndex
jmp_cmp ==, 0xe, stor[8], inl[:SET_BENT_ANIMATION_EXIT] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[28], 0xe ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[28], 0x0 ; bentIndex, loop
return

SET_BENT_ANIMATION_DISPIRITED:
call Battle::scriptGetLoadingBentAnimationIndex, stor[28], stor[8] ; bentIndex, animationIndex
jmp_cmp ==, 0xa, stor[8], inl[:SET_BENT_ANIMATION_EXIT] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[28], 0xa ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[28], 0x1 ; bentIndex, loop
return

SET_BENT_ANIMATION_HURT:
call Battle::scriptGetLoadingBentAnimationIndex, stor[28], stor[8] ; bentIndex, animationIndex
jmp_cmp ==, 0xb, stor[8], inl[:SET_BENT_ANIMATION_EXIT] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[28], 0xb ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[28], 0x1 ; bentIndex, loop
SET_BENT_ANIMATION_EXIT:
return



; SUBROUTINE
LABEL_8:
call Battle::scriptGetBentSlot, stor[28], stor[10], 0x0 ; bentIndex, charOrBentSlot, mode
mov stor[8], var[128 + stor[10]][5] ; source, dest
mov 0x5, var[128 + stor[10]][0] ; source, dest
call Battle::scriptSetBentStat, stor[30], stor[8], SPELL_ID ; bentIndex, value, statIndex
call Battle::scriptSetTempSpellStats, stor[30] ; bentIndex
mov stor[8], var[45][119] ; source, dest
call Battle::scriptGetBentStat, stor[30], SPELL_TARGET_TYPE, stor[9] ; bentIndex, statIndex, value
jmp_cmp &, 0x80, stor[9], inl[:LABEL_9] ; operand, left, right, addr
call Battle::scriptCheckPhysicalHit, stor[30], stor[28], stor[9] ; attackerIndex, defenderIndex, hit
jmp inl[:LABEL_10] ; addr
LABEL_9:
call Battle::scriptCheckSpellOrStatusHit, stor[30], stor[28], stor[9] ; attackerIndex, defenderIndex, hit
LABEL_10:
jmp_cmp ==, 0x0, stor[9], inl[:LABEL_12] ; operand, left, right, addr
gosub inl[:LABEL_13] ; addr
mov stor[9], var[45][119] ; source, dest
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_11] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[30], STATUS, stor[9] ; bentIndex, statIndex, value
jmp_cmp !&, 0x8, stor[9], inl[:LABEL_11] ; operand, left, right, addr
shr 0x1, stor[8] ; right, left
LABEL_11:
mov var[45][119], stor[9] ; source, dest
return
LABEL_12:
mov 0xffffffff, stor[8] ; source, dest
return

; SUBROUTINE
LABEL_13:
call Battle::scriptGetBentStat, stor[30], SPELL_TARGET_TYPE, stor[8] ; bentIndex, statIndex, value
jmp_cmp &, 0x80, stor[8], inl[:LABEL_14] ; operand, left, right, addr
call Battle::scriptPhysicalAttack, stor[30], stor[28], stor[8], stor[10] ; attackerIndex, defenderIndex, damage, specialEffects
return
LABEL_14:
call Battle::scriptDragoonMagicStatusItemAttack, stor[30], stor[28], var[45][119], stor[8], stor[10] ; attackerIndex, defenderIndex, spellId, damage, specialEffects
return
data 0xa80338
data 0x200001e
data 0x2000008
data 0x25
data 0x1ed0138
data 0x200001e
data 0x208
data 0x2000008
data 0xf00772d
data 0x1fb0338
data 0x200001e
data 0x200001c
data 0x2000009
data 0x20242
data 0x2000009
data 0x9000021
data 0x1730338
data 0x200001c
data 0x200000a
data 0x0
data 0x208
data 0x2000008
data 0x10050a80
data 0x208
data 0x2
data 0x10000a80
data 0x208
data 0x200001e
data 0x10030a80
data 0x208
data 0x2000008
data 0x10020a80
data 0xa90338
data 0x200001e
data 0x50
data 0x2000008
data 0x208
data 0x2000008
data 0x10010a80
data 0x1ec0538
data 0x200001e
data 0x200001c
data 0xf00772d
data 0x2000008
data 0x200000a
data 0x49
data 0x208
data 0xffffffff
data 0x2000008
data 0x49



; SUBROUTINE
; sets my bit in the attack targets bitset
SET_MY_ATTACK_TARGETING_BIT:
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
mov 0x1, stor[9] ; source, dest
shl stor[8], stor[9] ; right, left
or stor[9], var[45][246] ; right, left
return



; SUBROUTINE
; clears my bit in the attack targets bitset
CLEAR_MY_ATTACK_TARGETING_BIT:
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
mov 0x1, stor[9] ; source, dest
shl stor[8], stor[9] ; right, left
neg stor[9] ; operand
decr stor[9] ; operand
and stor[9], var[45][246] ; right, left
return



data 0x10c
data 0x2000008
data 0x70341
data 0x1000000
data 0x200000
data 0x3071c00
data 0x9000007
data 0x11b
data 0x2000008
data 0x49
data 0x357
data 0x200001c
data 0xa
data 0x2000008

; SUBROUTINE
LABEL_17:
yield
jmp_cmp &, 0x200000, stor[stor[stor[0], 28], 7], inl[:LABEL_17] ; operand, left, right, addr
yield
yield
return



; SUBROUTINE
; @param int s8 amount
; @param int s28 bent index
RECOVER_HP:
jmp_cmp &, 0x40, stor[stor[stor[0], 28], 7], inl[:RECOVER_HP_EXIT] ; operand, left, right, addr

call Battle::scriptGetBentStat2, stor[28], CURRENT_HP, stor[10] ; bentIndex, statIndex, value
add stor[8], stor[10] ; amount, operand
call Battle::scriptGetBentStat2, stor[28], MAX_HP, stor[9] ; bentIndex, statIndex, value
jmp_cmp >=, stor[9], stor[10], inl[:RECOVER_HP_SKIP_CLAMP] ; operand, left, right, addr
call Battle::scriptGetBentStat2, stor[28], CURRENT_HP, stor[8] ; bentIndex, statIndex, value
mov stor[9], stor[10] ; source, dest
sub stor[8], stor[9] ; amount, operand
mov stor[9], stor[8] ; source, dest
RECOVER_HP_SKIP_CLAMP:

call Battle::scriptRenderRecover, stor[28], stor[8], 0x7 ; bentIndex, amount, colourIndex
call Battle::scriptSetBentRawStat, stor[28], stor[10], CURRENT_HP ; bentIndex, value, statIndex
RECOVER_HP_EXIT:
return



; SUBROUTINE
; @param int s8 amount
; @param int s28 bent index
RECOVER_MP:
jmp_cmp &, 0x40, stor[stor[stor[0], 28], 7], inl[:RECOVER_MP_EXIT] ; operand, left, right, addr

call Battle::scriptGetBentStat, stor[28], CURRENT_MP, stor[10] ; bentIndex, statIndex, value
add stor[8], stor[10] ; amount, operand
call Battle::scriptGetBentStat, stor[28], MAX_MP, stor[9] ; bentIndex, statIndex, value
jmp_cmp >=, stor[9], stor[10], inl[:RECOVER_MP_SKIP_CLAMP] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[28], CURRENT_MP, stor[8] ; bentIndex, statIndex, value
mov stor[9], stor[10] ; source, dest
sub stor[8], stor[9] ; amount, operand
mov stor[9], stor[8] ; source, dest
RECOVER_MP_SKIP_CLAMP:

call Battle::scriptRenderRecover, stor[28], stor[8], 0xc ; bentIndex, amount, colourIndex
call Battle::scriptSetBentRawStat, stor[28], stor[10], CURRENT_MP ; bentIndex, value, statIndex
RECOVER_MP_EXIT:
return



; SUBROUTINE
RECOVER_SP:
jmp_cmp &, 0x40, stor[stor[stor[0], 28], 7], inl[:RECOVER_SP_EXIT] ; operand, left, right, addr

call Battle::scriptGiveSp, stor[28], stor[8], stor[9] ; bentIndex, amount, total
call Battle::scriptRenderRecover, stor[28], stor[8], 0xd ; bentIndex, amount, colourIndex
jmp_cmp !&, 0x2, stor[stor[stor[0], 28], 7], inl[:RECOVER_SP_EXIT] ; operand, left, right, addr
div 100, stor[8] ; amount, operand
call Battle::scriptGetBentSlot, stor[28], stor[9], 0x1 ; bentIndex, charOrBentSlot, mode
add 69, stor[9] ; amount, operand
add stor[8], var[45][stor[9]] ; amount, operand
RECOVER_SP_EXIT:
return



; SUBROUTINE
LABEL_26:
yield
mov var[49], stor[9] ; s9 = alive bent count
mov 0x0, stor[10] ; source, dest
mov 0x0, stor[11] ; source, dest
mov 0x0, stor[12] ; source, dest
mov 0x0, stor[8] ; loop counter, alive bent slot

LABEL_27:
mov var[48][stor[8]], stor[12] ; s12 = alive bent s8
mov stor[stor[stor[0], 12], 7], stor[10] ; s10 = s12's s7
and 0x200000, stor[10] ; right, left
or stor[10], stor[11] ; right, left
incr stor[8] ; operand
jmp_cmp >, stor[9], stor[8], inl[:LABEL_27] ; operand, left, right, addr

jmp_cmp !=, 0x0, stor[11], inl[:LABEL_26] ; repeat until all alive bents have s7 flag 0x20_0000 cleared
yield
yield
return



; SUBROUTINE
WAIT_FOR_FLOATING_NUMBERS_TO_DISAPPEAR:
yield
call Battle::scriptIsFloatingNumberOnScreen, stor[8] ; onScreen
jmp_cmp !=, 0x0, stor[8], inl[:WAIT_FOR_FLOATING_NUMBERS_TO_DISAPPEAR] ; operand, left, right, addr
return



; SUBROUTINE
CLEAR_BENT_STATUS:
call Battle::scriptGetBentSlot, stor[28], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
add 0x81, stor[9] ; amount, operand
mov 0x0, var[45][stor[9]] ; source, dest
call Battle::scriptGetBentStat, stor[28], STATUS, stor[8] ; bentIndex, statIndex, value
and 0xffffff00, stor[8] ; right, left
call Battle::scriptSetBentStat, stor[28], stor[8], STATUS ; bentIndex, value, statIndex
return
data 0x40242
data 0xf00402d
data 0x900006e
data 0xa80338
data 0x200001e
data 0xf00402d
data 0x29
data 0x1e10438
data 0x200001e
data 0x200001c
data 0x2000009
data 0x200000a
data 0x208
data 0x200000a
data 0xf00f12d
data 0xa90338
data 0x200001e
data 0x5
data 0x200000b
data 0x70341
data 0x1000000
data 0x8
data 0x200000b
data 0x900000b
data 0x20242
data 0x2000009
data 0x9000006
data 0x216
data 0x1
data 0x2000009
data 0x1730338
data 0x200001e
data 0x200000a
data 0x0
data 0x218
data 0xbd
data 0x200000a
data 0x208
data 0x7000a2d
data 0x200000a
data 0x70341
data 0x2
data 0x200000a
data 0x900000b
data 0x60341
data 0x4
data 0x200000a
data 0x9000007
data 0x216
data 0x1
data 0x2000009
data 0x50242
data 0x2000009
data 0x9000033
data 0x1730338
data 0x200001e
data 0x200000a
data 0x0
data 0x218
data 0xbd
data 0x200000a
data 0x70341
data 0x1
data 0x7000a2d
data 0x9000029
data 0xb10338
data 0x200001e
data 0x2
data 0x200000a
data 0xb10338
data 0x200001e
data 0x6
data 0x200000b
data 0x221
data 0x2
data 0x200000b
data 0x10341
data 0x200000b
data 0x200000a
data 0x900001a
data 0xb10338
data 0x200001e
data 0x6
data 0x200000b
data 0x221
data 0x4
data 0x200000b
data 0x50341
data 0x200000b
data 0x200000a
data 0x900000c
data 0x220
data 0x3
data 0x2000009
data 0x216
data 0x1
data 0x2000009
data 0x140
data 0x9000005
data 0x220
data 0x2
data 0x2000009
data 0x50341
data 0x3b9ac9ff
data 0x2000009
data 0x9000007
data 0x208
data 0x3b9ac9ff
data 0x2000009
data 0x49
data 0x208
data 0xffffffff
data 0x2000009
data 0x208
data 0xffffffff
data 0x200000a
data 0x49
data 0x357
data 0x200001c
data 0x11
data 0x0
data 0x148
data 0x900ff43
data 0x49
data 0x10c
data 0x200000d
data 0x208
data 0x7000d32
data 0x200001c
data 0x70341
data 0x1000000
data 0x2
data 0x3071c00
data 0x900000b
data 0x357
data 0x200001c
data 0x11
data 0x0
data 0x148
data 0x900ff32
data 0x11b
data 0x200000d
data 0x208
data 0xa
data 0x200000e
data 0x40341
data 0x5000033
data 0x200000d
data 0x900ffed
data 0x49



; SUBROUTINE
; @param int s8 shadow size
SET_CHAR_BENT_SHADOW_SIZE:
call Battle::scriptGetBentStat, stor[8], FOOT_MODEL_PART, inl[:SET_CHAR_BENT_SHADOW_SIZE_FOOT_MODEL_PART_INDEX]
call Battle::scriptGetBentStat, stor[8], SHADOW_SIZE, inl[:SET_CHAR_BENT_SHADOW_SIZE_SHADOW_SIZE]
call Battle::scriptAttachShadowToBentModelPart, stor[8], inl[:SET_CHAR_BENT_SHADOW_SIZE_FOOT_MODEL_PART_INDEX] ; bentIndex, modelPartAttachmentIndex
call Battle::scriptSetBentShadowSize, stor[8], inl[:SET_CHAR_BENT_SHADOW_SIZE_SHADOW_SIZE], inl[:SET_CHAR_BENT_SHADOW_SIZE_SHADOW_SIZE] ; bentIndex, x, z
return

SET_CHAR_BENT_SHADOW_SIZE_FOOT_MODEL_PART_INDEX:
data 0
SET_CHAR_BENT_SHADOW_SIZE_SHADOW_SIZE:
data 0



; SUBROUTINE
LABEL_57:
call Battle::scriptGetBentStat, stor[28], MIDDLE_OFFSET_X, stor[24] ; bentIndex, statIndex, value
call Battle::scriptGetBentStat, stor[28], MIDDLE_OFFSET_Y, stor[25] ; bentIndex, statIndex, value
mul 0x64, stor[24] ; amount, operand
mul 0x64, stor[25] ; amount, operand
neg stor[25] ; operand
mov 0x0, stor[26] ; source, dest
call Battle::scriptGetBentPos, stor[28], stor[14], stor[15], stor[16] ; bentIndex, x, y, z
add stor[14], stor[24] ; amount, operand
add stor[15], stor[25] ; amount, operand
add stor[16], stor[26] ; amount, operand
return
data 0x1730338
data 0x200001c
data 0x2000008
data 0x0
data 0x208
data 0x200001e
data 0x10040880
data 0x49



; SUBROUTINE
UNSTUN_WHEN_DAMAGE_IS_TAKEN:
jmp_cmp >, 0x0, var[45][224], inl[:LABEL_59] ; no damage dealt

call Battle::scriptGetBentStat, stor[0], STATUS, stor[8] ; bentIndex, statIndex, value
jmp_cmp !&, 0x10, stor[8], inl[:LABEL_59] ; not stunned

call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
add 0x81, stor[8] ; amount, operand
or 0xf00, var[45][stor[8]] ; right, left

LABEL_59:
return



data 0x0
data 0x60341
data 0x4
data 0xf00f52d
data 0x900ffff
data 0x49

; SUBROUTINE
GET_BENT_SPECIAL_EFFECT_FLAGS:
call Battle::scriptGetBentStat, stor[28], SPECIAL_EFFECT_FLAGS, stor[8] ; bentIndex, statIndex, value
and 0x80, stor[8] ; right, left
return

; SUBROUTINE
LABEL_61:
call SEffe::scriptGetAdditionOverlayActiveStatus, 0x0, stor[8] ; type, state
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_62] ; operand, left, right, addr
mov var[45][104], stor[8] ; source, dest
return
LABEL_62:
mov 0xffffffff, stor[8] ; source, dest
return

; SUBROUTINE
LABEL_63:
mov 0x0, var[45][253] ; source, dest
return

; SUBROUTINE
LABEL_64:
mov 0xffffffff, var[45][253] ; source, dest
return

; SUBROUTINE
LABEL_65:
mov 0x0, stor[12] ; source, dest
mov var[51], stor[29] ; source, dest
LABEL_66:
mov var[50][stor[12]], stor[28] ; source, dest
gosub inl[:LABEL_79] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_67] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[28], 0x4 ; bentIndex, animIndex
jmp_cmp &, 0x2, stor[stor[stor[0], 28], 7], inl[:LABEL_67] ; operand, left, right, addr
call Battle::scriptSetBentRotationY, stor[28], 0xc00 ; bentIndex, y
LABEL_67:
incr stor[12] ; operand
jmp_cmp !=, stor[29], stor[12], inl[:LABEL_66] ; operand, left, right, addr
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames
call Audio::scriptPlaySound, 0x0, 0x20, 0x0, 0x0, 0x0, 0x3 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
mov 0x0, stor[12] ; source, dest
LABEL_68:
mov var[50][stor[12]], stor[28] ; source, dest
gosub inl[:LABEL_79] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_69] ; operand, left, right, addr
call Battle::FUN_800cbb00, stor[28], stor[28], 0x14, 0x7d0, 0x0, 0x0 ; bentIndex0, bentIndex1, ticks, x, y, z
call SEffe::scriptAllocateParticleEffect, stor[stor[stor[0], 28], 18], stor[28], 0xfff03, 0x8, 0xc8, 0x3, 0x100, 0x4124000, 0x3 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativePosition, stor[stor[stor[0], 28], 18], stor[28], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[stor[stor[0], 28], 18], 0xffffffff, 0x400, 0x400, 0x400 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[stor[stor[0], 28], 18], 0xffffffff, 0x4f, 0x45, 0x38 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetGenericEffectValue, stor[stor[stor[0], 28], 18], 0x0, 0x1 ; effectIndex, genericIndex, value
call SEffe::scriptSetParticleAcceleration, 0x0, stor[stor[stor[0], 28], 18], 0xfffff800, 0x0, 0x0, 0x100 ; mode, effectIndex, accelerationX, accelerationY, accelerationZ, accelerationScale
call SEffe::scriptAddLifespanAttachment, stor[stor[stor[0], 28], 18], 0x12 ; effectIndex, ticks
LABEL_69:
incr stor[12] ; operand
jmp_cmp !=, stor[29], stor[12], inl[:LABEL_68] ; operand, left, right, addr
mov 0x10, stor[23] ; source, dest
wait stor[23] ; frames
mov 0x0, stor[12] ; source, dest
LABEL_70:
mov var[50][stor[12]], stor[28] ; source, dest
gosub inl[:LABEL_79] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_71] ; operand, left, right, addr
call SEffe::scriptSetParticleAcceleration, 0x1, stor[stor[stor[0], 28], 18], 0x0, 0x0, 0x0, 0x0 ; mode, effectIndex, accelerationX, accelerationY, accelerationZ, accelerationScale
LABEL_71:
incr stor[12] ; operand
jmp_cmp !=, stor[29], stor[12], inl[:LABEL_70] ; operand, left, right, addr
mov 0x2, stor[23] ; source, dest
wait stor[23] ; frames
call Audio::scriptStopSound, 0x0, 0x20, 0x3 ; soundFileIndex, soundIndex, mode
mov 0x0, stor[12] ; source, dest
LABEL_72:
mov var[50][stor[12]], stor[28] ; source, dest
gosub inl[:LABEL_79] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_73] ; operand, left, right, addr
LABEL_73:
incr stor[12] ; operand
jmp_cmp !=, stor[29], stor[12], inl[:LABEL_72] ; operand, left, right, addr
return

; SUBROUTINE
LABEL_74:
mov 0x0, stor[12] ; source, dest
mov var[51], stor[29] ; source, dest
LABEL_75:
mov var[50][stor[12]], stor[28] ; source, dest
gosub inl[:LABEL_79] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_76] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[28], 0x4 ; bentIndex, animIndex
jmp_cmp &, 0x2, stor[stor[stor[0], 28], 7], inl[:LABEL_76] ; operand, left, right, addr
call Battle::scriptSetBentRotationY, stor[28], 0xc00 ; bentIndex, y
LABEL_76:
incr stor[12] ; operand
jmp_cmp !=, stor[29], stor[12], inl[:LABEL_75] ; operand, left, right, addr
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames
mov 0x0, stor[12] ; source, dest
LABEL_77:
mov var[50][stor[12]], stor[28] ; source, dest
gosub inl[:LABEL_79] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_78] ; operand, left, right, addr
gosub inl[:LABEL_648] ; addr
call Battle::scriptSetBentRotationY, stor[28], 0x400 ; bentIndex, y
LABEL_78:
incr stor[12] ; operand
jmp_cmp !=, stor[29], stor[12], inl[:LABEL_77] ; operand, left, right, addr
return

; SUBROUTINE
LABEL_79:
mov 0x0, stor[8] ; source, dest
call Battle::scriptGetBentSlot, stor[28], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
add 0x81, stor[9] ; amount, operand
mov var[45][stor[9]], stor[10] ; source, dest
and 0xf, stor[10] ; right, left
jmp_cmp !=, 0x4, stor[10], inl[:LABEL_80] ; operand, left, right, addr
incr stor[8] ; operand
LABEL_80:
return



; SUBROUTINE
; Either stunned or dead
; @return bool s8 incapacitated
IS_INCAPACITATED:
mov 0x0, stor[8] ; source, dest

; s10 = my status index
call Battle::scriptGetBentSlot, stor[0], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
add 129, stor[9] ; amount, operand
mov var[45][stor[9]], stor[10] ; source, dest
and 0xf, stor[10] ; right, left

jmp_cmp !=, 0x4, stor[10], inl[:IS_INCAPACITATED_NOT_STUNNED] ; if not stunned
incr stor[8] ; operand
jmp inl[:IS_INCAPACITATED_EXIT] ; addr

IS_INCAPACITATED_NOT_STUNNED:
jmp_cmp !&, 0x40, stor[7], inl[:IS_INCAPACITATED_EXIT] ; operand, left, right, addr
incr stor[8] ; operand
IS_INCAPACITATED_EXIT:
return



; SUBROUTINE
; @return bool s10 can become dragoon
CAN_BECOME_DRAGOON:
call Battle::scriptGetBentStat, stor[0], STATUS, stor[10] ; s10 = my status
jmp_cmp !&, 0x2000, stor[10], inl[:CAN_BECOME_DRAGOON_NOPE] ; can't become dragoon
CAN_BECOME_DRAGOON_YUP:
mov 0x1, stor[10] ; source, dest
return
CAN_BECOME_DRAGOON_NOPE:
mov 0x0, stor[10] ; source, dest
return

; SUBROUTINE
; @param int s28 bent slot
; @return bool s10 can become dragoon
CAN_BENT_BECOME_DRAGOON:
call Battle::scriptGetBentStat, stor[28], STATUS, stor[10] ; bentIndex, statIndex, value
jmp_cmp !&, 0x2000, stor[10], inl[:CAN_BECOME_DRAGOON_NOPE] ; operand, left, right, addr
jmp inl[:CAN_BECOME_DRAGOON_YUP] ; addr

; SUBROUTINE
LABEL_88:
jmp_cmp !=, 0x4, stor[11], inl[:LABEL_89] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x9 ; bentIndex, animIndex
gosub inl[:WAIT_FOR_ANIMATION_TO_FINISH] ; addr
LABEL_89:
gosub inl[:SET_IDLE_ANIMATION] ; addr
return

; SUBROUTINE TABLE
LABEL_90:
rel :JMP_1e58_0
rel :JMP_1e58_1
rel :JMP_1e58_1
rel :JMP_1e58_1
rel :LABEL_340
rel :LABEL_341

; SUBROUTINE TABLE
LABEL_91:
rel :JMP_1e58_0
rel :JMP_1e70_1
rel :JMP_1e70_2
rel :JMP_1e70_3
rel :LABEL_340
rel :LABEL_341

; SUBROUTINE
LABEL_92:
call Battle::scriptGetBentSlot, stor[28], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
mov 0xffffffff, var[128 + stor[9]][0] ; source, dest
mov 0xffffffff, var[128 + stor[9]][1] ; source, dest
mov 0xffffffff, var[128 + stor[9]][2] ; source, dest
mov 0xffffffff, var[128 + stor[9]][3] ; source, dest
mov 0xffffffff, var[128 + stor[9]][4] ; source, dest
return

; SUBROUTINE
JMP_1e58_0:
gosub inl[:LABEL_92] ; addr
call Battle::scriptGetBentSlot, stor[28], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
mov 0x0, var[128 + stor[9]][0] ; source, dest
mov stor[0], var[128 + stor[9]][3] ; source, dest
return

; SUBROUTINE
LABEL_93:
gosub inl[:LABEL_92] ; addr
call Battle::scriptGetBentSlot, stor[28], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
LABEL_94:
mov 0x4, var[128 + stor[9]][0] ; source, dest
mov stor[0], var[128 + stor[9]][3] ; source, dest
return
data 0x148
data 0x900ffd2
data 0x1730338
data 0x200001c
data 0x2000009
data 0x0
data 0x208
data 0x4
data 0x10000980
data 0x208
data 0x200001e
data 0x10030980
data 0x49

; SUBROUTINE
JMP_1e70_1:
jmp_cmp >, 0x0, stor[28], inl[:LABEL_95] ; operand, left, right, addr
gosub inl[:LABEL_92] ; addr
call Battle::scriptGetBentSlot, stor[28], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
jmp_cmp &, 0x2, stor[7], inl[:LABEL_94] ; operand, left, right, addr
mov 0x1, var[128 + stor[9]][0] ; source, dest
mov stor[0], var[128 + stor[9]][3] ; source, dest
LABEL_95:
return

; SUBROUTINE
JMP_1e70_2:
jmp_cmp >, 0x0, stor[28], inl[:LABEL_96] ; operand, left, right, addr
gosub inl[:LABEL_92] ; addr
call Battle::scriptGetBentSlot, stor[28], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
mov 0x2, var[128 + stor[9]][0] ; source, dest
mov stor[0], var[128 + stor[9]][3] ; source, dest
mov stor[29], var[128 + stor[9]][2] ; source, dest
LABEL_96:
return

; SUBROUTINE
JMP_1e70_3:
jmp_cmp >, 0x0, stor[28], inl[:LABEL_97] ; operand, left, right, addr
gosub inl[:LABEL_92] ; addr
call Battle::scriptGetBentSlot, stor[28], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
mov 0x3, var[128 + stor[9]][0] ; source, dest
mov stor[0], var[128 + stor[9]][3] ; source, dest
mov inl[:LABEL_98[stor[31]]], var[128 + stor[9]][1] ; source, dest
mov stor[29], stor[8] ; source, dest
add 0xc0, stor[8] ; amount, operand
mov stor[8], var[128 + stor[9]][2] ; source, dest
LABEL_97:
return
LABEL_98:
data 0x80
data 0x1
data 0x40
data 0x10
data 0x2
data 0x20
data 0x4
data 0x0
data 0x0

; SUBROUTINE
JMP_1e58_1:
jmp_cmp <=, 0x0, stor[28], inl[:LABEL_100] ; operand, left, right, addr
mov stor[8], stor[10] ; source, dest
mov 0x0, stor[11] ; source, dest
LABEL_99:
mov var[52][stor[11]], stor[28] ; source, dest
gosub_table stor[10], inl[:LABEL_91] ; index, table
incr stor[11] ; operand
jmp_cmp >, var[53], stor[11], inl[:LABEL_99] ; operand, left, right, addr
return
LABEL_100:
jmp_table stor[8], inl[:LABEL_91] ; index, table



; SUBROUTINE
; @param int s29 item id
USE_ITEM:
call Battle::scriptUseItem, reg[0], stor[28] ; item, target
return



; SUBROUTINE
; @param int s8 0 = material shield, 1 = magical shield
ALLOCATE_MATERIAL_OR_MAGICAL_SHIELD_EFFECT:
jmp_cmp !=, 0x0, stor[8], inl[:ALLOCATE_MAGICAL_SHIELD_EFFECT] ; operand, left, right, addr

; SUBROUTINE
ALLOCATE_MATERIAL_SHIELD_EFFECT:
call Battle::scriptAllocateGuardEffect, stor[18] ; effectIndex
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x2, 0xfd, 0x8b, 0x15 ; effectIndex, parentIndex, ticks, destR, destG, destB
jmp inl[:LABEL_137] ; addr

; SUBROUTINE
ALLOCATE_GUARD_EFFECT:
call Battle::scriptAllocateGuardEffect, stor[18] ; effectIndex
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x2, 0xd5, 0xfd, 0x15 ; effectIndex, parentIndex, ticks, destR, destG, destB
jmp inl[:LABEL_137] ; addr

; SUBROUTINE
ALLOCATE_MAGICAL_SHIELD_EFFECT:
call Battle::scriptAllocateGuardEffect, stor[18] ; effectIndex
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x2, 0x19, 0x82, 0xfd ; effectIndex, parentIndex, ticks, destR, destG, destB
LABEL_137:
call SEffe::scriptSetRelativePosition, stor[18], stor[28], 0x0, 0xfffffd00, 0xfffffe00 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x0, 0xc00, 0xc00 ; bobjIndex1, bobjIndex2, x, y, z
mov 0x2, stor[23] ; source, dest
wait stor[23] ; frames
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0xa, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0xa, 0xfffffa00, 0xc00, 0xc00 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[18], 0xa ; effectIndex, ticks
call SEffe::scriptAllocateParticleEffect, stor[19], stor[28], 0xfff20, 0x18, 0x10, 0x4, 0x400, 0xc7f00, 0x2c ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
gosub inl[:LABEL_138] ; addr
return

; SUBROUTINE
LABEL_138:
call SEffe::scriptSetRelativeRotation, stor[19], stor[28], 0x0, 0x400, 0x400 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativePosition, stor[19], stor[28], 0x0, 0xfffffd00, 0xfffffe00 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[19], 0xffffffff, 0x400, 0x400, 0x400 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[19], 0x18 ; effectIndex, ticks
return

; SUBROUTINE
LOAD_SOUNDS:
call Audio::scriptLoadMonsterAttackSounds, stor[8] ; monsterIndex
LABEL_140:
yield
call Audio::scriptGetLoadedSoundFiles, stor[23] ; flags
jmp_cmp &, 0x20, stor[23], inl[:LABEL_140] ; operand, left, right, addr
return



; SUBROUTINE
LABEL_144:
call Battle::scriptGetBobjModelPartCount, stor[28], stor[8] ; bobjIndex, partCount
call SEffe::scriptAllocateParticleEffect, stor[18], stor[28], 0xfff18, stor[8], 0x0, 0x2, 0x0, 0x7064000, 0x40 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x40, 0x600, 0x600 ; bobjIndex1, bobjIndex2, x, y, z
gosub inl[:LABEL_145] ; addr
call Battle::scriptGetBobjModelPartCount, stor[28], stor[8] ; bobjIndex, partCount
call SEffe::scriptAllocateParticleEffect, stor[18], stor[28], 0xfff18, stor[8], 0x0, 0x2, 0x0, 0x7064000, 0x40 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0xc00, 0x40, 0xc00 ; bobjIndex1, bobjIndex2, x, y, z
gosub inl[:LABEL_145] ; addr
return

; SUBROUTINE
LABEL_145:
call SEffe::scriptSetRelativeRotation, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetEffectTranslucencyModeFlag, stor[18], 0x2 ; effectIndex, set
call SEffe::scriptSetEffectZ, stor[18], 0xffffff00 ; effectIndex, z
call Battle::scriptGetBobjModelPartCount, stor[28], stor[8] ; bobjIndex, partCount
call SEffe::scriptAddLifespanAttachment, stor[18], stor[8] ; effectIndex, ticks
return

; SUBROUTINE TABLE
LABEL_146:
rel :JMP_3128_0
rel :JMP_3128_1
rel :JMP_3128_2
rel :JMP_3128_3
rel :JMP_3128_4

; SUBROUTINE
LABEL_147:
gosub inl[:JMP_1e58_0] ; addr
mov 0x0, var[45][64] ; source, dest
mov 0x0, var[45][82] ; source, dest
mov 0x0, var[45][81] ; source, dest
mov 0x0, var[45][107] ; source, dest
mov 0x0, var[45][83] ; source, dest
mov 0x0, var[45][67] ; source, dest
mov 0x0, var[45][99] ; source, dest
mov 0x0, var[45][103] ; source, dest
mov 0x0, var[45][75] ; source, dest
mov 0x0, var[45][108] ; source, dest
mov 0x0, var[45][112] ; source, dest
mov 0x0, var[45][66] ; source, dest
mov 0x0, var[45][181] ; source, dest
mov 0x0, stor[15] ; source, dest
incr stor[15] ; operand
mov 0x18, var[45][106] ; source, dest
gosub inl[:GET_PLAYER_ADDITION_HIT_COUNT] ; addr
mov stor[9], var[45][89] ; source, dest
fork_reenter stor[28], 0x5, stor[0] ; index, entrypoint, p2
LABEL_148:
mov var[45][82], stor[17] ; source, dest
mov var[45][83], stor[14] ; source, dest
gosub_table stor[17], inl[:LABEL_146] ; index, table
gosub inl[:LABEL_198] ; addr
gosub inl[:LABEL_203] ; addr
gosub inl[:LABEL_206] ; addr
gosub inl[:LABEL_229] ; addr
jmp_cmp !=, 0x3, var[45][66], inl[:LABEL_149] ; operand, left, right, addr
mov 0x10, stor[8] ; source, dest
add stor[14], stor[8] ; amount, operand
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], stor[8] ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop
LABEL_149:
yield
jmp_cmp !=, 0x5, var[45][82], inl[:LABEL_148] ; operand, left, right, addr
gosub inl[:CAN_BECOME_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[10], inl[:LABEL_151] ; operand, left, right, addr
mov var[45][108], stor[8] ; source, dest
call Battle::scriptGetBentSlot, stor[0], stor[31], 0x1 ; bentIndex, charOrBentSlot, mode
add 0x73, stor[31] ; amount, operand
add stor[8], var[45][stor[31]] ; amount, operand
call Battle::scriptGiveSp, stor[0], stor[8], stor[9] ; bentIndex, amount, total
jmp_cmp !=, 0x2, var[45][242], inl[:LABEL_151] ; operand, left, right, addr
jmp_cmp !=, 0x3, var[45][243], inl[:LABEL_151] ; operand, left, right, addr
jmp_cmp >, 0x64, stor[9], inl[:LABEL_150] ; operand, left, right, addr
or 0x20, stor[stor[stor[0], 28], 7] ; right, left
incr var[45][243] ; operand
jmp inl[:LABEL_151] ; addr
LABEL_150:
or 0x20, stor[7] ; right, left
LABEL_151:
jmp_cmp !=, 0x3, var[45][66], inl[:LABEL_155] ; operand, left, right, addr
mov var[45][105], stor[8] ; source, dest
yield
jmp_cmp !=, 0x2, stor[30], inl[:LABEL_151] ; operand, left, right, addr
call Battle::scriptPauseAnimation, stor[0] ; bentIndex
mov 0x0, var[104] ; source, dest
call Battle::scriptApplyScreenDarkening, 0x6 ; intensity
gosub inl[:LABEL_195] ; addr
or 0x80, var[45][105] ; right, left
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames
call Audio::scriptPlaySound, 0x0, 0x26, 0x1, 0x0, 0x0, 0x0 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
incr var[104] ; operand
call Battle::scriptApplyScreenDarkening, 0x10 ; intensity
jmp_cmp !=, 0x1, var[45][75], inl[:LABEL_152] ; operand, left, right, addr
mov 0x4, var[45][66] ; source, dest
jmp inl[:LABEL_153] ; addr
LABEL_152:
call FullScreenEffects::scriptStartFadeEffect, 0x4, 0xa ; type, frames
call Audio::scriptPlaySound, 0x0, 0x17, 0x1, 0x0, 0x0, 0x0 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
LABEL_153:
call Battle::scriptResumeAnimation, stor[0] ; bentIndex
gosub inl[:CAN_BECOME_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[10], inl[:LABEL_154] ; operand, left, right, addr
call Battle::scriptAllocateSpTextEffect, 0xffffffff, 0x0 ; p0, p1
LABEL_154:
return
LABEL_155:
jmp_cmp ==, 0x0, var[45][99], inl[:LABEL_157] ; operand, left, right, addr
mov stor[14], stor[9] ; source, dest
decr stor[9] ; operand
call Battle::scriptGetHitProperty, stor[0], stor[9], 0xe, stor[8] ; bentIndex, hitNum, hitPropertyIndex, value
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_157] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], stor[8] ; bentIndex, animIndex
LABEL_156:
yield
call Battle::scriptAnimationHasFinished, stor[0], stor[8] ; bentIndex, finished
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_156] ; operand, left, right, addr
LABEL_157:
jmp_cmp >=, 0x0, stor[13], inl[:LABEL_160] ; operand, left, right, addr
call Battle::scriptGetCharOrMonsterId, stor[0], stor[8] ; bentIndex, id
call Battle::scriptPauseAnimation, stor[0] ; bentIndex
mov 0x2, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:LABEL_302] ; addr
mov 0xd, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:CAN_BECOME_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[10], inl[:LABEL_158] ; operand, left, right, addr
call Battle::scriptAllocateSpTextEffect, 0xffffffff, 0x0 ; p0, p1
LABEL_158:
gosub inl[:LABEL_242] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_159] ; operand, left, right, addr
jmp_cmp !=, 0x0, var[45][243], inl[:LABEL_159] ; operand, left, right, addr
call Battle::scriptLevelUpAddition, stor[0], 0x1 ; bentIndex, doIt
LABEL_159:
return
LABEL_160:
call Battle::scriptPauseAnimation, stor[0] ; bentIndex
mov 0x2, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:LABEL_302] ; addr
mov 0x8, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:CAN_BECOME_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[10], inl[:LABEL_161] ; operand, left, right, addr
call Battle::scriptAllocateSpTextEffect, 0xffffffff, 0x0 ; p0, p1
LABEL_161:
call Battle::scriptLevelUpAddition, stor[0], 0x0 ; bentIndex, doIt
return

; SUBROUTINE
JMP_3128_0:
gosub inl[:CACHE_ADDITION_TIMINGS] ; addr
gosub inl[:ALLOCATE_WEAPON_TRAIL_EFFECT] ; addr
mov 0x10, stor[8] ; source, dest
add stor[14], stor[8] ; amount, operand
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], stor[8] ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop
gosub inl[:LABEL_221] ; addr
gosub inl[:LABEL_247] ; addr
mov 0x0, var[45][84] ; source, dest
mov var[45][88], var[45][85] ; source, dest
incr var[45][82] ; operand
return

; SUBROUTINE
JMP_3128_1:
incr var[45][84] ; operand
jmp_cmp !=, var[45][87], var[45][84], inl[:LABEL_163] ; operand, left, right, addr
incr var[45][82] ; operand
LABEL_163:
return

; SUBROUTINE
JMP_3128_2:
incr var[45][84] ; operand
decr var[45][85] ; operand
jmp_cmp !=, 0x0, var[45][85], inl[:LABEL_164] ; operand, left, right, addr
incr var[45][82] ; operand
gosub inl[:LABEL_237] ; addr
LABEL_164:
return

; SUBROUTINE
JMP_3128_3:
incr var[45][84] ; operand
incr var[45][82] ; operand
gosub inl[:LABEL_226] ; addr
gosub inl[:LABEL_166] ; addr
gosub inl[:LABEL_175] ; addr
mov stor[14], stor[8] ; source, dest
incr stor[8] ; operand
jmp_cmp !=, stor[8], var[45][89], inl[:LABEL_165] ; operand, left, right, addr
call Battle::scriptGetCharOrMonsterId, stor[0], stor[8] ; bentIndex, id
call Battle::scriptAllocateAdditionScript, stor[8], 0x0 ; charId, p1
or 0x20, var[45][105] ; right, left
call Audio::scriptPlaySound, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
gosub inl[:LABEL_238] ; addr
gosub inl[:CAN_BECOME_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[10], inl[:LABEL_165] ; operand, left, right, addr
mov var[45][108], stor[8] ; source, dest
call Battle::scriptAllocateAdditionNameEffect, stor[8] ; totalSp
LABEL_165:
return

; SUBROUTINE
LABEL_166:
jmp_cmp &, 0x10, var[45][105], inl[:LABEL_167] ; operand, left, right, addr
incr var[45][64] ; operand
return
LABEL_167:
mov 0xffffffff, var[45][64] ; source, dest
return

WEAPON_TRAIL_R:
data 0
WEAPON_TRAIL_G:
data 0
WEAPON_TRAIL_B:
data 0
HAS_WEAPON_TRAIL:
data 0
WEAPON_PART_MODEL_INDEX:
data 0
WEAPON_TRAIL_VERTEX_COMPONENT:
data 0

; SUBROUTINE
ALLOCATE_WEAPON_TRAIL_EFFECT:
call Battle::scriptGetBentStat, stor[0], WEAPON_TRAIL_COLOUR, stor[8] ; s8 = packed rgb
call Battle::scriptGetBentStat, stor[0], HAS_WEAPON_TRAIL, inl[:HAS_WEAPON_TRAIL]
call Battle::scriptGetBentStat, stor[0], WEAPON_MODEL_PART, inl[:WEAPON_PART_MODEL_INDEX]
call Battle::scriptGetBentStat, stor[0], WEAPON_TRAIL_VERTEX_COMPONENT, inl[:WEAPON_TRAIL_VERTEX_COMPONENT]

; Unpack rgb
mov stor[8], inl[:WEAPON_TRAIL_R]
mov stor[8], inl[:WEAPON_TRAIL_G]
mov stor[8], inl[:WEAPON_TRAIL_B]
shr  8, inl[:WEAPON_TRAIL_G]
shr 16, inl[:WEAPON_TRAIL_B]
and 0xff, inl[:WEAPON_TRAIL_R]
and 0xff, inl[:WEAPON_TRAIL_G]
and 0xff, inl[:WEAPON_TRAIL_B]

call Battle::scriptAllocateWeaponTrailEffect, stor[18], stor[0], inl[:WEAPON_PART_MODEL_INDEX] ; effectIndex, parentIndex, dobjIndex
call SEffe::scriptSetGenericEffectValue, stor[18], 0x0, inl[:WEAPON_TRAIL_VERTEX_COMPONENT] ; sets which vertex component to use for the weapon trail
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, inl[:WEAPON_TRAIL_R], inl[:WEAPON_TRAIL_G], inl[:WEAPON_TRAIL_B] ; bobjIndex1, bobjIndex2, r, g, b
call Battle::scriptSetWeaponTrailSegmentCount, stor[18], 0x3 ; effectIndex, count
call SEffe::scriptAddLifespanAttachment, stor[18], var[45][86] ; effectIndex, ticks
jmp_cmp !=, 0, inl[:HAS_WEAPON_TRAIL], inl[:NO_WEAPON_TRAIL]
call Battle::scriptAllocateWeaponTrailEffect, stor[18], stor[0], 0x6 ; effectIndex, parentIndex, dobjIndex
call SEffe::scriptSetGenericEffectValue, stor[18], 0x0, inl[:WEAPON_TRAIL_VERTEX_COMPONENT] ; effectIndex, genericIndex, value
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, inl[:WEAPON_TRAIL_R], inl[:WEAPON_TRAIL_G], inl[:WEAPON_TRAIL_B] ; bobjIndex1, bobjIndex2, r, g, b
call Battle::scriptSetWeaponTrailSegmentCount, stor[18], 0x3 ; effectIndex, count
call SEffe::scriptAddLifespanAttachment, stor[18], var[45][86] ; effectIndex, ticks
NO_WEAPON_TRAIL:
return

; SUBROUTINE
LABEL_175:
jmp_cmp &, 0x10, var[45][105], inl[:LABEL_179] ; operand, left, right, addr
gosub inl[:CAN_BECOME_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[10], inl[:LABEL_179] ; operand, left, right, addr
call Battle::scriptGetHitProperty, stor[0], stor[14], 0x5, stor[8] ; bentIndex, hitNum, hitPropertyIndex, value
call Battle::scriptGetBentStat, stor[0], ADDITION_SP_MULTIPLIER, stor[9] ; bentIndex, statIndex, value
call Battle::scriptGetBentStat, stor[0], SP_MULTIPLIER, stor[10] ; bentIndex, statIndex, value
add 0x64, stor[9] ; amount, operand
mul stor[9], stor[8] ; amount, operand
div 0x64, stor[8] ; amount, operand
add 0x64, stor[10] ; amount, operand
mul stor[10], stor[8] ; amount, operand
div 0x64, stor[8] ; amount, operand
call Battle::scriptGetBentStat, stor[0], STATUS, stor[9] ; bentIndex, statIndex, value
jmp_cmp !&, 0x40, stor[9], inl[:LABEL_176] ; operand, left, right, addr
mov 0x0, stor[9] ; source, dest
jmp inl[:LABEL_178] ; addr
LABEL_176:
mov stor[8], stor[9] ; source, dest
gosub inl[:LABEL_242] ; addr
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_177] ; operand, left, right, addr
shr 0x1, stor[9] ; right, left
LABEL_177:
jmp_cmp >=, 0x63, stor[9], inl[:LABEL_178] ; operand, left, right, addr
mov 0x63, stor[9] ; source, dest
LABEL_178:
call Battle::scriptAllocateSpTextEffect, stor[9], stor[15] ; p0, p1
add stor[9], var[45][108] ; amount, operand
LABEL_179:
return

; SUBROUTINE
JMP_3128_4:
incr var[45][84] ; operand
jmp_cmp <, var[45][84], var[45][86], inl[:LABEL_189] ; operand, left, right, addr
incr stor[14] ; operand
incr var[45][83] ; operand
jmp_cmp ==, stor[14], var[45][89], inl[:LABEL_184] ; operand, left, right, addr
decr stor[14] ; operand
call SEffe::scriptGetHitCompletionState, stor[0], stor[14], stor[13] ; unused, index, result
incr stor[14] ; operand
jmp_cmp <=, 0x0, stor[13], inl[:LABEL_180] ; operand, left, right, addr
or 0x2, var[45][105] ; right, left
LABEL_180:
jmp_cmp !&, 0x10, var[45][105], inl[:LABEL_181] ; operand, left, right, addr
mov 0xffffffff, stor[13] ; source, dest
LABEL_181:
jmp_cmp ==, 0x3, var[45][66], inl[:LABEL_185] ; operand, left, right, addr
jmp_cmp >=, 0x0, stor[13], inl[:LABEL_187] ; operand, left, right, addr
jmp_cmp !=, 0x2, var[45][66], inl[:LABEL_183] ; operand, left, right, addr
jmp_cmp ==, 0x2, var[45][80], inl[:LABEL_183] ; operand, left, right, addr
gosub inl[:LABEL_61] ; addr
jmp_cmp >, 0x0, stor[8], inl[:LABEL_182] ; operand, left, right, addr
call SEffe::scriptAlterAdditionContinuationState, stor[8], 0x1 ; effectIndex, state
LABEL_182:
jmp inl[:LABEL_187] ; addr
LABEL_183:
mov 0x0, var[45][82] ; source, dest
mov 0x0, var[45][81] ; source, dest
mov 0x0, var[45][107] ; source, dest
gosub inl[:LABEL_190] ; addr
jmp inl[:JMP_3128_0] ; addr
LABEL_184:
mov 0x1, stor[13] ; source, dest
LABEL_185:
jmp_cmp >=, 0x0, stor[13], inl[:LABEL_186] ; operand, left, right, addr
jmp inl[:LABEL_186] ; addr
LABEL_186:
mov 0x5, var[45][82] ; source, dest
return
LABEL_187:
mov 0x5, var[45][82] ; source, dest
incr var[45][66] ; operand
jmp_cmp !=, 0x3, var[45][66], inl[:LABEL_188] ; operand, left, right, addr
mov 0x3e7, stor[31] ; source, dest
jmp inl[:LABEL_188] ; addr
LABEL_188:
incr var[45][99] ; operand
gosub inl[:CAN_BECOME_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[10], inl[:LABEL_189] ; operand, left, right, addr
mov var[45][108], stor[8] ; source, dest
call Battle::scriptAllocateAdditionNameEffect, stor[8] ; totalSp
LABEL_189:
return

; SUBROUTINE
LABEL_190:
jmp_cmp !=, 0x2, var[45][66], inl[:LABEL_193] ; operand, left, right, addr
or 0x1, var[45][105] ; right, left
mov 0x5, var[45][66] ; source, dest
call Battle::scriptPauseAnimation, stor[0] ; bentIndex
gosub inl[:LABEL_61] ; addr
jmp_cmp >, 0x0, stor[8], inl[:LABEL_191] ; operand, left, right, addr
call SEffe::scriptAlterAdditionContinuationState, stor[8], 0x0 ; effectIndex, state
LABEL_191:
mov 0x0, var[104] ; source, dest
call Battle::scriptApplyScreenDarkening, 0x6 ; intensity
gosub inl[:LABEL_194] ; addr
mov 0x7, stor[23] ; source, dest
wait stor[23] ; frames
mov 0x3, stor[23] ; source, dest
wait stor[23] ; frames
call Audio::scriptPlaySound, 0x0, 0x26, 0x1, 0x0, 0x0, 0x0 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
incr var[104] ; operand
call Battle::scriptApplyScreenDarkening, 0x10 ; intensity
call Battle::scriptResumeAnimation, stor[0] ; bentIndex
gosub inl[:LABEL_61] ; addr
jmp_cmp >, 0x0, stor[8], inl[:LABEL_192] ; operand, left, right, addr
call SEffe::scriptAlterAdditionContinuationState, stor[8], 0x0 ; effectIndex, state
mov 0x0, stor[stor[stor[0], 8], 8] ; source, dest
LABEL_192:
return
LABEL_193:
return

; SUBROUTINE
LABEL_194:
mov 0x320, stor[19] ; source, dest
mov 0xfffff800, stor[20] ; source, dest
mov 0x17, stor[22] ; source, dest
jmp inl[:LABEL_196] ; addr

; SUBROUTINE
LABEL_195:
mov 0xfffffce0, stor[19] ; source, dest
mov 0x800, stor[20] ; source, dest
mov 0x11, stor[22] ; source, dest
jmp inl[:LABEL_196] ; addr
LABEL_196:
call Battle::scriptAllocateGuardEffect, stor[18] ; effectIndex
call SEffe::scriptSetRelativePosition, stor[18], stor[28], 0x0, 0xfffffce0, 0xfffffe70 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x0, 0x2000, 0x2000 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0x10, stor[19], 0x2000, 0x2000 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAllocateScreenDistortionEffect, stor[21], 0x0, 0x2 ; effectIndex, angleStep, type
call SEffe::scriptAddLifespanAttachment, stor[21], 0xe ; effectIndex, ticks
gosub inl[:LABEL_236] ; addr
add 0x1000, stor[10] ; amount, operand
shl 0x8, stor[8] ; right, left
shl 0x8, stor[9] ; right, left
shl 0x8, stor[10] ; right, left
call Battle::scriptCameraSetViewpoint, 0x5, stor[8], stor[9], stor[10], 0x0 ; mode, x, y, z, scriptIndex
yield
sub 0x100000, stor[10] ; amount, operand
call Battle::scriptCameraAccelerateViewpoint, 0x5, stor[8], stor[9], stor[10], 0x6, 0x1, 0x1, 0x0, 0x0 ; mode, x, y, z, ticks, stepSmoothingMode, stepZ, stepType, scriptIndex
LABEL_197:
yield
call Battle::scriptIsCameraMoving, 0x0, stor[8] ; type, isMoving
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_197] ; operand, left, right, addr
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0x7, stor[20], 0x2000, 0x2000 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x7, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddLifespanAttachment, stor[18], 0x7 ; effectIndex, ticks
gosub inl[:LABEL_239] ; addr
return

; SUBROUTINE
LABEL_198:
jmp_cmp !=, 0x0, var[45][81], inl[:LABEL_201] ; operand, left, right, addr
mov 0x0, var[45][80] ; source, dest
jmp_cmp !&, 0x20, var[4], inl[:LABEL_199] ; operand, left, right, addr
incr var[45][80] ; operand
LABEL_199:
jmp_cmp !&, 0x40, var[4], inl[:LABEL_200] ; operand, left, right, addr
incr var[45][80] ; operand
incr var[45][80] ; operand
LABEL_200:
jmp_cmp ==, 0x0, var[45][80], inl[:LABEL_201] ; operand, left, right, addr
jmp_cmp <=, 0x3, var[45][80], inl[:LABEL_202] ; operand, left, right, addr
jmp_cmp !=, 0x2, var[45][82], inl[:LABEL_202] ; operand, left, right, addr
mov 0x1, var[45][81] ; source, dest
LABEL_201:
return
LABEL_202:
mov 0xffffffff, var[45][81] ; source, dest
return

; SUBROUTINE
LABEL_203:
mov stor[14], stor[8] ; source, dest
incr stor[8] ; operand
jmp_cmp >=, stor[8], var[45][89], inl[:LABEL_204] ; operand, left, right, addr
jmp_cmp &, 0x10, var[45][105], inl[:LABEL_204] ; operand, left, right, addr
jmp_cmp !=, 0x0, var[45][107], inl[:LABEL_204] ; operand, left, right, addr
call SEffe::scriptGetHitCompletionState, stor[0], stor[14], stor[8] ; unused, index, result
mov stor[8], var[45][177] ; source, dest
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_204] ; operand, left, right, addr
jmp_cmp >, 0x0, stor[8], inl[:LABEL_205] ; operand, left, right, addr
mov 0x1, var[45][107] ; source, dest
LABEL_204:
return
LABEL_205:
mov 0xffffffff, var[45][107] ; source, dest
return

; SUBROUTINE
LABEL_206:
jmp_cmp &, 0x10, var[45][105], inl[:LABEL_210] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[28], MONSTER_DAMAGE_REDUCTION, stor[8] ; bentIndex, statIndex, value
jmp_cmp &, 0x10, stor[8], inl[:LABEL_211] ; operand, left, right, addr
jmp_cmp ==, 0x5, var[45][82], inl[:LABEL_210] ; operand, left, right, addr
mov var[45][83], stor[14] ; source, dest
incr stor[14] ; operand
mov var[45][87], stor[10] ; source, dest
add var[45][88], stor[10] ; amount, operand
jmp_cmp !=, var[45][84], stor[10], inl[:LABEL_210] ; operand, left, right, addr
mov 0x3, stor[9] ; source, dest
jmp_cmp ==, stor[14], var[45][89], inl[:LABEL_209] ; operand, left, right, addr
call Battle::scriptGetHitProperty, stor[0], stor[14], 0xc, stor[8] ; bentIndex, hitNum, hitPropertyIndex, value
mov stor[8], stor[9] ; source, dest
sub var[45][122], stor[8] ; amount, operand
mov stor[9], var[45][122] ; source, dest
call Battle::scriptGetHitProperty, stor[0], stor[14], 0xb, stor[9] ; bentIndex, hitNum, hitPropertyIndex, value
jmp_cmp !&, 0x80, stor[9], inl[:LABEL_207] ; operand, left, right, addr
or 0xffffff00, stor[9] ; right, left
LABEL_207:
add stor[8], stor[9] ; amount, operand
add var[45][123], stor[9] ; amount, operand
mov 0x0, stor[8] ; source, dest
jmp_cmp <=, 0x0, stor[9], inl[:LABEL_208] ; operand, left, right, addr
mov stor[9], stor[8] ; source, dest
mov 0x0, stor[9] ; source, dest
LABEL_208:
mov stor[8], var[45][123] ; source, dest
LABEL_209:
mul 0x64, stor[9] ; amount, operand
add stor[9], var[45][67] ; amount, operand
neg stor[9] ; operand
mov stor[9], var[45][112] ; source, dest
call Battle::scriptGetBentPos, stor[28], stor[18], stor[19], stor[20] ; bentIndex, x, y, z
add stor[9], stor[18] ; amount, operand
call Battle::FUN_800cbde0, stor[28], 0xffffffff, 0x3, stor[18], stor[19], stor[20] ; bentIndex0, bentIndex1, ticks, x, y, z
LABEL_210:
return
LABEL_211:
jmp_cmp ==, 0x5, var[45][82], inl[:LABEL_215] ; operand, left, right, addr
mov var[45][83], stor[14] ; source, dest
incr stor[14] ; operand
mov var[45][87], stor[10] ; source, dest
add var[45][88], stor[10] ; amount, operand
jmp_cmp !=, var[45][84], stor[10], inl[:LABEL_215] ; operand, left, right, addr
mov 0x3, stor[9] ; source, dest
mov 0x3, stor[11] ; source, dest
jmp_cmp ==, stor[14], var[45][89], inl[:LABEL_214] ; operand, left, right, addr
call Battle::scriptGetHitProperty, stor[0], stor[14], 0xc, stor[8] ; bentIndex, hitNum, hitPropertyIndex, value
mov stor[8], stor[9] ; source, dest
sub var[45][122], stor[8] ; amount, operand
mov stor[9], var[45][122] ; source, dest
call Battle::scriptGetHitProperty, stor[0], stor[14], 0xb, stor[9] ; bentIndex, hitNum, hitPropertyIndex, value
jmp_cmp !&, 0x80, stor[9], inl[:LABEL_212] ; operand, left, right, addr
or 0xffffff00, stor[9] ; right, left
LABEL_212:
add stor[8], stor[9] ; amount, operand
add var[45][123], stor[9] ; amount, operand
mov 0x0, stor[8] ; source, dest
jmp_cmp <=, 0x0, stor[9], inl[:LABEL_213] ; operand, left, right, addr
mov stor[9], stor[8] ; source, dest
mov 0x0, stor[9] ; source, dest
LABEL_213:
mov stor[8], var[45][123] ; source, dest
LABEL_214:
mul 0x64, stor[9] ; amount, operand
add stor[9], var[45][67] ; amount, operand
call Battle::scriptGetBentPos, stor[0], stor[18], stor[19], stor[20] ; bentIndex, x, y, z
add stor[9], stor[18] ; amount, operand
call Battle::FUN_800cbb00, stor[0], 0xffffffff, stor[11], stor[18], stor[19], stor[20] ; bentIndex0, bentIndex1, ticks, x, y, z
LABEL_215:
return

; SUBROUTINE
GET_PLAYER_ADDITION_HIT_COUNT:
call Battle::scriptGetBentStat, stor[0], ADDITION_HIT_COUNT, stor[9]
return

; SUBROUTINE
CACHE_ADDITION_TIMINGS:
mov 0x56, stor[11] ; source, dest
mov 0x1, stor[10] ; source, dest
mov 0x3, stor[12] ; source, dest
LABEL_220:
call Battle::scriptGetHitProperty, stor[0], stor[14], stor[10], var[45][stor[11]] ; bentIndex, hitNum, hitPropertyIndex, value
incr stor[10] ; operand
incr stor[11] ; operand
while stor[12], inl[:LABEL_220] ; counter, addr
decr var[45][86] ; operand
return
data 0x24a
data 0x200001e
data 0xb1f1fd3

HIT_INDEX:
data 0
SOUND_INDEX:
data 0;

; SUBROUTINE
; Plays addition sounds
LABEL_221:
call Battle::scriptGetBentSlot, stor[28], stor[8], 0x1 ; bentIndex, charOrBentSlot, mode
mov 0x1, stor[9] ; source, dest
shl stor[8], stor[9] ; right, left
jmp_cmp &, stor[9], var[45][250], inl[:LABEL_225] ; operand, left, right, addr

mov 0x0, var[45][74] ; source, dest
mov 0x4, stor[21] ; source, dest
mov var[45][83], inl[:HIT_INDEX]
mov 16, inl[:SOUND_INDEX]

LABEL_222:
call Battle::scriptGetHitProperty, stor[0], inl[:HIT_INDEX], inl[:SOUND_INDEX], stor[10] ; bentIndex, hitNum, hitPropertyIndex, value
incr inl[:SOUND_INDEX]

call Battle::scriptGetHitProperty, stor[0], inl[:HIT_INDEX], inl[:SOUND_INDEX], stor[11] ; bentIndex, hitNum, hitPropertyIndex, value
incr inl[:SOUND_INDEX]

jmp_cmp >, 0x0, stor[10], inl[:LABEL_225] ; operand, left, right, addr

call Battle::scriptPlayBentSound, 0x1, stor[0], stor[10], 0x1, 0x0, stor[11], 0x0 ; type, bentIndex, soundIndex, a3, a4, initialDelay, repeatDelay

while stor[21], inl[:LABEL_222] ; counter, addr

LABEL_225:
return

; SUBROUTINE
LABEL_226:
mov var[45][83], stor[8] ; source, dest
incr stor[8] ; operand
jmp_cmp ==, stor[8], var[45][89], inl[:LABEL_227] ; operand, left, right, addr
call Battle::scriptAllocateAdditionStarburstEffect, stor[19], 0xffffffff, var[45][106], 0x0 ; effectIndex, parentIndex, rayCount, type
call SEffe::scriptAddConstantColourScalerAttachment, stor[19], 0xffffffff, 0x6, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
jmp inl[:LABEL_228] ; addr
LABEL_227:
call Battle::scriptAllocateAdditionStarburstEffect, stor[19], 0xffffffff, var[45][106], 0x1 ; effectIndex, parentIndex, rayCount, type
call SEffe::scriptSetRelativeColour, stor[19], 0xffffffff, 0xa0, 0xa0, 0x60 ; bobjIndex1, bobjIndex2, r, g, b
LABEL_228:
call SEffe::scriptAddLifespanAttachment, stor[19], 0x6 ; effectIndex, ticks
mov var[45][83], stor[8] ; source, dest
shl 0x5, stor[8] ; right, left
div var[45][89], stor[8] ; amount, operand
add stor[8], var[45][106] ; amount, operand
return

; SUBROUTINE
LABEL_229:
jmp_cmp &, 0x10, var[45][105], inl[:LABEL_231] ; operand, left, right, addr
jmp_cmp ==, 0x5, var[45][82], inl[:LABEL_231] ; operand, left, right, addr
mov var[45][83], stor[14] ; source, dest
jmp_cmp ==, 0x0, stor[14], inl[:LABEL_231] ; operand, left, right, addr
mov var[45][89], stor[8] ; source, dest
decr stor[8] ; operand
jmp_cmp ==, stor[14], stor[8], inl[:LABEL_232] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[28], MONSTER_DAMAGE_REDUCTION, stor[8] ; bentIndex, statIndex, value
jmp_cmp &, 0x10, stor[8], inl[:LABEL_231] ; operand, left, right, addr
call Battle::scriptGetHitProperty, stor[0], stor[14], 0x9, stor[10] ; bentIndex, hitNum, hitPropertyIndex, value
jmp_cmp !=, var[45][84], stor[10], inl[:LABEL_231] ; operand, left, right, addr
gosub inl[:LABEL_235] ; addr
mov var[45][112], stor[11] ; source, dest
add stor[11], stor[8] ; amount, operand
call Battle::scriptGetHitProperty, stor[0], stor[14], 0x8, stor[11] ; bentIndex, hitNum, hitPropertyIndex, value
jmp_cmp ==, 0x0, stor[11], inl[:LABEL_230] ; operand, left, right, addr
mul 0x64, stor[11] ; amount, operand
add stor[11], stor[8] ; amount, operand
LABEL_230:
mul 0x100, stor[8] ; amount, operand
mul 0x100, stor[9] ; amount, operand
mul 0x100, stor[10] ; amount, operand
call Battle::scriptGetHitProperty, stor[0], stor[14], 0xa, stor[11] ; bentIndex, hitNum, hitPropertyIndex, value
call Battle::scriptCameraMoveRefpoint, 0x0, stor[8], stor[9], stor[10], 0x0, stor[11], 0x0, stor[0] ; mode, x, y, z, ?, ticks, stepType, scriptIndex
LABEL_231:
return
LABEL_232:
jmp_cmp !=, 0x3, var[45][82], inl[:LABEL_231] ; operand, left, right, addr
call SEffe::scriptAllocateScreenDistortionEffect, stor[21], 0x0, 0x2 ; effectIndex, angleStep, type
call SEffe::scriptAddLifespanAttachment, stor[21], 0x6 ; effectIndex, ticks
call Battle::scriptGetHitProperty, stor[0], stor[14], 0x7, stor[11] ; bentIndex, hitNum, hitPropertyIndex, value
jmp_cmp ==, 0x0, stor[11], inl[:LABEL_233] ; operand, left, right, addr
gosub inl[:LABEL_236] ; addr
add 0x80, stor[9] ; amount, operand
mul 0x100, stor[11] ; amount, operand
add stor[11], stor[10] ; amount, operand
shl 0x8, stor[8] ; right, left
shl 0x8, stor[9] ; right, left
shl 0x8, stor[10] ; right, left
call Battle::scriptCameraAccelerateViewpoint, 0x5, stor[8], stor[9], stor[10], 0x6, 0x1, 0x1, 0x0, 0x0 ; mode, x, y, z, ticks, stepSmoothingMode, stepZ, stepType, scriptIndex
LABEL_233:
call Battle::scriptGetHitProperty, stor[0], stor[14], 0x8, stor[11] ; bentIndex, hitNum, hitPropertyIndex, value
jmp_cmp ==, 0x0, stor[11], inl[:LABEL_234] ; operand, left, right, addr
gosub inl[:LABEL_235] ; addr
mul 0x64, stor[11] ; amount, operand
add stor[11], stor[8] ; amount, operand
mul 0x100, stor[8] ; amount, operand
mul 0x100, stor[9] ; amount, operand
mul 0x100, stor[10] ; amount, operand
call Battle::scriptCameraMoveRefpoint, 0x0, stor[8], stor[9], stor[10], 0x0, 0x6, 0x0, stor[0] ; mode, x, y, z, ?, ticks, stepType, scriptIndex
LABEL_234:
return

; SUBROUTINE
LABEL_235:
call Battle::scriptCalculateCameraValue, 0x1, 0x0, 0x0, stor[0], stor[8] ; type, mode, component, scriptIndex, out
call Battle::scriptCalculateCameraValue, 0x1, 0x0, 0x1, stor[0], stor[9] ; type, mode, component, scriptIndex, out
call Battle::scriptCalculateCameraValue, 0x1, 0x0, 0x2, stor[0], stor[10] ; type, mode, component, scriptIndex, out
return

; SUBROUTINE
LABEL_236:
call Battle::scriptCalculateCameraValue, 0x0, 0x5, 0x0, 0x0, stor[8] ; type, mode, component, scriptIndex, out
call Battle::scriptCalculateCameraValue, 0x0, 0x5, 0x1, 0x0, stor[9] ; type, mode, component, scriptIndex, out
call Battle::scriptCalculateCameraValue, 0x0, 0x5, 0x2, 0x0, stor[10] ; type, mode, component, scriptIndex, out
return

; SUBROUTINE
LABEL_237:
call Rumble::scriptStartRumbleMode, 0x0, 0x1 ; joypadIndex, p1
call Rumble::scriptStartRumble, 0x0, 0x0, 0xc ; joypadIndex, p1, duration
return

; SUBROUTINE
LABEL_238:
call Rumble::scriptStartRumbleMode, 0x0, 0x2 ; joypadIndex, p1
call Rumble::scriptStartRumble, 0x0, 0x0, 0xc ; joypadIndex, p1, duration
return

; SUBROUTINE
LABEL_239:
call Rumble::scriptStartRumbleMode, 0x0, 0x3 ; joypadIndex, p1
call Rumble::scriptStartRumble, 0x0, 0x0, 0xc ; joypadIndex, p1, duration
return

; SUBROUTINE
LABEL_240:
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
add 0xbd, stor[8] ; amount, operand
mov var[45][stor[8]], stor[8] ; source, dest
and 0x2, stor[8] ; right, left
jmp_cmp ==, 0x0, var[45][243], inl[:LABEL_241] ; operand, left, right, addr
mov 0x0, stor[8] ; source, dest
LABEL_241:
return

; SUBROUTINE
LABEL_242:
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
add 0xbd, stor[8] ; amount, operand
mov var[45][stor[8]], stor[8] ; source, dest
jmp_cmp &, 0x4, stor[8], inl[:LABEL_243] ; operand, left, right, addr
and 0x2, stor[8] ; right, left
jmp_cmp ==, 0x0, var[45][243], inl[:LABEL_244] ; operand, left, right, addr
LABEL_243:
mov 0x0, stor[8] ; source, dest
LABEL_244:
return

LABEL_246:
data 0x29
data 0x33
data 0x2d
data 0x3b
data 0x45
data 0x51
data 0x5f
data 0x6f
data 0x6f
data 0x73
data 0x79
data 0x83
data 0x91
data 0xa1
data 0xa1
data 0xa5
data 0xab
data 0xb7
data 0xc7
data 0xc7
data 0xcb
data 0xd3
data 0xdf
data 0xdf
data 0xe3
data 0xeb
data 0xf5
data 0x103
data 0x113
data 0x113
data 0x117
data 0x11d
data 0x125
data 0x12f
data 0x13d
data 0x14d
data 0x14d
data 0x151
data 0x157
data 0x161
data 0x16f
data 0x1c80012
data 0xfc6f9c
data 0x2a60000
data 0xfd6f94
data 0x1c80012
data 0xfc6f9c
data 0x22800fee
data 0xfd0f82
data 0x1760ff4
data 0xfb2f68
data 0x1c80012
data 0xfc6f9c
data 0x65a0000
data 0xfccf96
data 0x3180000
data 0xfcef98
data 0x1760ffa
data 0xfc0f88
data 0x1880012
data 0xfc6f9c
data 0x5220000
data 0xfd2f86
data 0x2c00ffc
data 0xfc2f7c
data 0x43000ff4
data 0xfd6f38
data 0x1f00000
data 0xfb6f34
data 0x1880012
data 0xfc6f9c
data 0x1ea0008
data 0xfdcfa0
data 0x80014
data 0xfcef98
data 0x200ffe
data 0xfeefae
data 0x3a0014
data 0xfcef98
data 0x120000
data 0xfd6fa0
data 0x1880012
data 0xfc6f9c
data 0x45e0000
data 0xfc4f8c
data 0x18a0ff4
data 0xfd4f84
data 0x2580014
data 0xfc0f8f
data 0x41400000
data 0xfd6f5e
data 0x41400000
data 0xfd6f5e
data 0x42ee3000
data 0x18ff4f48
data 0x1880012
data 0xfc6f9c
data 0x3e60000
data 0xfd0f96
data 0x17a0ffc
data 0xfbefb8
data 0x1160000
data 0xfbcf94
data 0x31a0ff1
data 0xfcef7a
data 0x1b80fda
data 0xfd4f82
data 0x21c00000
data 0xfcef60
data 0x3cc000e
data 0xfc8f3c
data 0x42400ff8
data 0xfd2f72
data 0x2c00ffe
data 0xfd0f3a
data 0x42400ff8
data 0xfd2f72
data 0x3b80008
data 0xfbaf6c
data 0x4960ffe
data 0xfc8f3a
data 0x42400ff8
data 0xfd2f72
data 0x2fe0000
data 0xfcaf68
data 0x17e0000
data 0xfcaf38
data 0x23e0000
data 0xfcaeda
data 0x2fc0ff8
data 0xfd0e82
data 0x42400ff8
data 0xfd2f72
data 0x2fc0010
data 0xfc4f5a
data 0x23400000
data 0xfc6ee8
data 0x414e1000
data 0xc0fb9ea4
data 0x3880000
data 0xfc2e92
data 0x1600000
data 0xfc6e5c
data 0x4500000
data 0xfb8e2a
data 0x42400ff8
data 0xfd2f72
data 0x2f00000
data 0xfcef5c
data 0x24c00fe8
data 0xfd0f50
data 0x20a0ff0
data 0xfccf0c
data 0x3800fda
data 0xfc6f08
data 0x43000fec
data 0xfd4ece
data 0x30e0fe0
data 0xfa4e9a
data 0x1500fe8
data 0xfcae68
data 0xc05002
data 0xfd6f8e
data 0x2240004
data 0xfd8f90
data 0xc05002
data 0xfd6f8e
data 0x1de0004
data 0xfccf70
data 0x1405ff0
data 0xfe2f66
data 0xc05002
data 0xfd6f8e
data 0x2400000
data 0xfd6f8a
data 0x3b60ffc
data 0xff2f5c
data 0xc80028
data 0xfd2f66
data 0x43480000
data 0xfdcf0e
data 0x29c0000
data 0xfc8ede
data 0x1005002
data 0xfd6f8e
data 0x12a0000
data 0xfd8f8e
data 0x2004002
data 0xfdaf6e
data 0x33a0ff4
data 0xfd6f40
data 0x42c00000
data 0xfdaef2
data 0x26a0008
data 0xfe8ef8
data 0x2860000
data 0xfd8e92
data 0xa20ff0
data 0xfc6e96
data 0x100ff4
data 0xfd4f80
data 0x47a4000
data 0xfb6fc8
data 0x100ff4
data 0xfd4f80
data 0xb1c0ffc
data 0xfc4f7c
data 0x900000
data 0xfdef3a
data 0x2500ffe
data 0xfccefa
data 0x100ff4
data 0xfd4f80
data 0x30a4004
data 0xfc6f78
data 0x1180000
data 0xfd0f5c
data 0x1b20fdc
data 0xfb6f5c
data 0x100000
data 0xfd4f36
data 0x2500000
data 0xfd0eb8
data 0x20400010
data 0xfcefc8
data 0x21c00010
data 0xfc4fa4
data 0x20400010
data 0xfcefc8
data 0x21c00fe8
data 0xfc4fa4
data 0x2080000c
data 0xfccf90
data 0x23c00022
data 0xfccf8c
data 0x20400010
data 0xfcefc8
data 0x22000006
data 0xfd0fa6
data 0x24000000
data 0xfdcf16
data 0x20400020
data 0xfd0f04
data 0x23000fe0
data 0xfd6f16
data 0x20000010
data 0xfcefc8
data 0x21c00000
data 0xfcafa2
data 0x22400006
data 0xfd4f82
data 0x22400ff6
data 0xfe4f2e
data 0x20400ff0
data 0xfc6f14
data 0x24800000
data 0xfdeee8
data 0x20800020
data 0xfeaece
data 0x20400010
data 0xfcefc8
data 0x24000010
data 0xfe4f72
data 0x20400010
data 0xfd0f0a
data 0x21400ff8
data 0xfccef2
data 0x20400ffc
data 0xfd8e7e
data 0x21400000
data 0xfdee88
data 0x21c00000
data 0xfd4e94
data 0x20800000
data 0xfcae40
data 0x21c00000
data 0xfd0fca
data 0x20800000
data 0xfd4fca
data 0x21c00000
data 0xfd0fca
data 0x20400000
data 0xfd0fca
data 0x6b000000
data 0xfd0fc0
data 0x21c00000
data 0xfd0fca
data 0x22000000
data 0xfd0fca
data 0x22000000
data 0xfdefae
data 0x22400000
data 0xfc6fa0
data 0x21c00000
data 0xfd0fca
data 0x22000000
data 0xfd2fc6
data 0x21400000
data 0xfd8fa0
data 0x21000000
data 0xfd8fa0
data 0x21800000
data 0xfdef88
data 0x21c00000
data 0xfd0fca
data 0x21800000
data 0xfd2fa6
data 0x20c00028
data 0xfd6f9c
data 0x21000ff6
data 0xfd2f8c
data 0x20c00000
data 0xfccf8c
data 0x22000ffc
data 0xfd4f44
data 0x22400ffe
data 0xfd2f14
data 0x21c00000
data 0xfd0fca
data 0x21c00002
data 0xfd2fc6
data 0x20400006
data 0xfd2fa6
data 0x2180000a
data 0xffef90
data 0x21000016
data 0xfe0f9a
data 0x20800000
data 0xfc8f8c
data 0x22400002
data 0xfd4f4e
data 0x2080000a
data 0xfcef3e
data 0x40000ffa
data 0xfdef7a
data 0x33e0000
data 0xfbef92
data 0x40000ffa
data 0xfdef7a
data 0x4000ffe
data 0xfc4faa
data 0x1c0000
data 0xfe4fae
data 0x40000ffa
data 0xfdef7a
data 0x4f80018
data 0xfd4f9c
data 0x7e0000
data 0xfecf92
data 0x0
data 0xfc8f70
data 0x20fee
data 0xfc6f70
data 0x40000ffa
data 0xfdef7a
data 0x47c0fda
data 0xfcef96
data 0x23400fe0
data 0xfdcf28
data 0x3c0018
data 0xfe8f38
data 0x107d020
data 0xfd8f40
data 0x1220ff4
data 0xfd6f26
data 0x2900000
data 0xfd0ed4
data 0x40000ffa
data 0xfdef7a
data 0x2b45fea
data 0xfd4f80
data 0x20800000
data 0xfbef08
data 0x40800000
data 0xfe0eca
data 0x21e0000
data 0xfccf14
data 0x386fc6
data 0x10fd4f06
data 0x3260fc6
data 0xfd6f0a
data 0x10e1ff0
data 0xfbce6a
data 0x400000
data 0xfc0fa0

; SUBROUTINE
LABEL_247:
call Battle::scriptGetBentSlot, stor[28], stor[8], 0x1 ; bentIndex, charOrBentSlot, mode
mov 0x1, stor[9] ; source, dest
shl stor[8], stor[9] ; right, left
jmp_cmp &, stor[9], var[45][250], inl[:LABEL_251] ; operand, left, right, addr

; s8 = hit sound file
call Battle::scriptGetHitProperty, stor[0], 0x0, 0x6, stor[8] ; bentIndex, hitNum, hitPropertyIndex, value
; s8 = look up hit sound file in table
mov inl[:LABEL_246[stor[8]]], stor[8] ; source, dest

; s18 = addition hit index
mov var[45][83], stor[18] ; source, dest
mul 0x2, stor[18] ; amount, operand
add stor[8], stor[18] ; amount, operand

; s22 = look up hit from table - first value
mov inl[:LABEL_246[stor[18]]], stor[22] ; source, dest

; next table index
incr stor[18] ; operand

; s23 = look up hit from table - second value
mov inl[:LABEL_246[stor[18]]], stor[23] ; source, dest

mov stor[22], stor[10] ; source, dest
and 0x3e0000, stor[10] ; right, left
shr 0x11, stor[10] ; right, left
shl 0x7, stor[10] ; right, left
; double slash hit 0: s10 = 0x200

mov stor[22], stor[11] ; source, dest
and 0x1f000, stor[11] ; right, left
shr 0xc, stor[11] ; right, left
shl 0x7, stor[11] ; right, left
; double slash hit 0: s11 = 0

mov stor[23], stor[12] ; source, dest
and 0xf8000000, stor[12] ; right, left
shr 0x1b, stor[12] ; right, left
shl 0x7, stor[12] ; right, left
; double slash hit 0: s12 = 0

mov stor[22], stor[19] ; source, dest
and 0xfff, stor[19] ; right, left
shl 0x4, stor[19] ; right, left
; double slash hit 0: s19 = 0x120

; sign extend
jmp_cmp !&, 0x8000, stor[19], inl[:LABEL_248] ; operand, left, right, addr
or 0xffff0000, stor[19] ; right, left

LABEL_248:
mov stor[23], stor[20] ; source, dest
and 0xfff000, stor[20] ; right, left
shr 0xc, stor[20] ; right, left
shl 0x4, stor[20] ; right, left
; double slash hit 0: s20 = 0xfc60

; sign extend
jmp_cmp !&, 0x8000, stor[20], inl[:LABEL_249] ; operand, left, right, addr
or 0xffff0000, stor[20] ; right, left
; double slash hit 0: s20 = 0xfffffc60

LABEL_249:
mov stor[23], stor[21] ; source, dest
and 0xfff, stor[21] ; right, left
shl 0x4, stor[21] ; right, left
; double slash hit 0: s21 = 0xf9c0

; sign extend
jmp_cmp !&, 0x8000, stor[21], inl[:LABEL_250] ; operand, left, right, addr
or 0xffff0000, stor[21] ; right, left
; double slash hit 0: s21 = 0xfffff9c0

LABEL_250:
mov stor[22], stor[9] ; source, dest
and 0x1fc00000, stor[9] ; right, left
shr 0x16, stor[9] ; right, left

mov stor[22], stor[8] ; source, dest
and 0xe0000000, stor[8] ; right, left
shr 0x1d, stor[8] ; right, left

call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
mov stor[0], stor[30] ; source, dest
mov stor[9], stor[stor[stor[0], 18], 9] ; source, dest
mov stor[10], stor[stor[stor[0], 18], 10] ; source, dest
mov stor[11], stor[stor[stor[0], 18], 11] ; source, dest
mov stor[12], stor[stor[stor[0], 18], 12] ; source, dest
mov stor[19], stor[stor[stor[0], 18], 19] ; source, dest
mov stor[20], stor[stor[stor[0], 18], 20] ; source, dest
mov stor[21], stor[stor[stor[0], 18], 21] ; source, dest
mov stor[30], stor[stor[stor[0], 18], 30] ; source, dest
mov stor[28], stor[stor[stor[0], 18], 28] ; source, dest
call SEffe::scriptSetRelativePosition, stor[18], stor[30], stor[19], stor[20], stor[21] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeRotation, stor[18], stor[30], stor[10], stor[11], stor[12] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:LABEL_252[:LABEL_252[stor[8]]]] ; scriptIndex, address
LABEL_251:
return

; SUBROUTINE TABLE

; FORK RE-ENTRY
LABEL_252:
rel :JMP_5f58_0
rel :JMP_5f58_1
rel :JMP_5f58_2
rel :JMP_5f58_3
rel :JMP_5f58_0
rel :JMP_5f58_0
rel :JMP_5f58_0
rel :JMP_5f58_0

; FORK RE-ENTRY
JMP_5f58_0:
wait stor[9] ; frames
gosub inl[:LABEL_265] ; addr
gosub inl[:LABEL_270] ; addr
call Battle::allocateBillboardSpriteEffect, stor[22], 0xfff17 ; effectIndex, flags
call SEffe::scriptSetRelativePosition, stor[22], stor[0], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[22], stor[0], 0x1000, 0x1000, 0x1000 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[22], 0xffffffff, 0x3, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddLifespanAttachment, stor[22], 0x4 ; effectIndex, ticks
call SEffe::allocateDeffTmd, stor[18], 0xfff18 ; effectIndex, flags
call SEffe::scriptAttachEffectToBobj, stor[18], stor[0], 0xffffffff ; effectIndex, scriptIndex, coord2Index
call SEffe::scriptSetRelativeRotation, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativePosition, stor[18], 0xffffffff, 0xfffff600, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x100, 0x100, 0x1000 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0x2, 0x1000, 0x1000, 0x1000 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x2, 0xc0, 0xc0, 0xc0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::allocateDeffTmd, stor[19], 0xfff18 ; effectIndex, flags
call SEffe::scriptAttachEffectToBobj, stor[19], stor[0], 0xffffffff ; effectIndex, scriptIndex, coord2Index
call SEffe::scriptSetRelativeRotation, stor[19], 0xffffffff, 0x400, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativePosition, stor[19], 0xffffffff, 0xfffff600, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[19], 0xffffffff, 0x100, 0x100, 0x1000 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[19], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[19], 0xffffffff, 0x2, 0x1000, 0x1000, 0x1000 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[19], 0xffffffff, 0x2, 0xc0, 0xc0, 0xc0 ; effectIndex, parentIndex, ticks, destR, destG, destB
yield
call Battle::scriptAllocateAdditionSparksEffect, stor[20], 0x40, 0xc4, 0xc4, 0x80, 0x600, 0x4 ; effectIndex, count, r, g, b, distance, ticks
call SEffe::scriptAttachEffectToBobj, stor[20], stor[0], 0xffffffff ; effectIndex, scriptIndex, coord2Index
call SEffe::scriptSetRelativeRotation, stor[20], stor[0], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativePosition, stor[20], stor[0], 0xfffffe00, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[20], 0x10 ; effectIndex, ticks
yield
call SEffe::scriptAllocateParticleEffect, stor[21], stor[0], 0xfff1f, 0x2, 0x0, 0x0, 0x0, 0xa7f00, 0x1 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptAttachEffectToBobj, stor[21], stor[0], 0xffffffff ; effectIndex, scriptIndex, coord2Index
call SEffe::scriptSetRelativePosition, stor[21], stor[0], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[21], 0xffffffff, 0x200, 0x200, 0x200 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[21], 0xffffffff, 0x2, 0xc00, 0xc00, 0xc00 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[21], 0x14 ; effectIndex, ticks
call SEffe::scriptAddRelativePositionScalerTicks0, stor[18], stor[18], 0x8, 0x800, 0x0, 0x0 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x6, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0x8, 0x800, 0x100, 0x1000 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[18], 0x8 ; effectIndex, ticks
call SEffe::scriptAddRelativePositionScalerTicks0, stor[19], stor[19], 0x8, 0x800, 0x0, 0x0 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[19], 0xffffffff, 0x6, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[19], 0xffffffff, 0x8, 0x800, 0x100, 0x1000 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[19], 0x8 ; effectIndex, ticks
yield
mov 0x14, stor[23] ; source, dest
wait stor[23] ; frames
deallocate

; FORK RE-ENTRY
JMP_5f58_1:
wait stor[9] ; frames
gosub inl[:LABEL_265] ; addr
gosub inl[:LABEL_270] ; addr
call Battle::allocateBillboardSpriteEffect, stor[18], 0xfff40 ; effectIndex, flags
call SEffe::scriptAttachEffectToBobj, stor[18], stor[0], 0xffffffff ; effectIndex, scriptIndex, coord2Index
call SEffe::scriptSetRelativePosition, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0x2, 0x900, 0x900, 0x900 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAllocateParticleEffect, stor[19], 0xffffffff, 0x200002, 0x18, 0xa, 0x1, 0x800, 0xd087f00, 0x27 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptAttachEffectToBobj, stor[19], stor[0], 0xffffffff ; effectIndex, scriptIndex, coord2Index
call SEffe::scriptSetRelativePosition, stor[19], stor[0], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeRotation, stor[19], stor[0], 0x0, 0x400, 0x400 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[19], 0xffffffff, 0x64, 0x80, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetRelativeScale, stor[19], 0xffffffff, 0x100, 0x100, 0x100 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::allocateDeffTmd, stor[20], 0xfff1f ; effectIndex, flags
call SEffe::scriptAttachEffectToBobj, stor[20], stor[0], 0xffffffff ; effectIndex, scriptIndex, coord2Index
call SEffe::scriptSetRelativeRotation, stor[20], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[20], 0xffffffff, 0x19, 0x20, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetRelativeScale, stor[20], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[20], 0xffffffff, 0x2, 0x800, 0x800, 0x800 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::allocateDeffTmd, stor[21], 0xfff1f ; effectIndex, flags
call SEffe::scriptAttachEffectToBobj, stor[21], stor[20], 0xffffffff ; effectIndex, scriptIndex, coord2Index
call SEffe::scriptSetRelativeRotation, stor[21], 0xffffffff, 0x0, 0x0, 0x100 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[21], 0xffffffff, 0x19, 0x20, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetRelativeScale, stor[21], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[21], 0xffffffff, 0x2, 0x800, 0x800, 0x800 ; effectIndex, parentIndex, ticks, x, y, z
mov 0x2, stor[27] ; source, dest
wait stor[27] ; frames
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x4, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddConstantColourScalerAttachment, stor[19], 0xffffffff, 0x6, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddLifespanAttachment, stor[18], 0x4 ; effectIndex, ticks
call SEffe::scriptAddLifespanAttachment, stor[19], 0x6 ; effectIndex, ticks
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[20], 0xffffffff, 0x6, 0x1400, 0x1400, 0x1400 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[21], 0xffffffff, 0x6, 0x1400, 0x1400, 0x1400 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[20], 0xffffffff, 0x6, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddConstantColourScalerAttachment, stor[21], 0xffffffff, 0x6, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
mov 0x6, stor[27] ; source, dest
wait stor[27] ; frames
deallocate_other stor[20] ; index
deallocate_other stor[21] ; index
deallocate

; FORK RE-ENTRY
JMP_5f58_3:
gosub inl[:LABEL_265] ; addr
mov 0x5, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:LABEL_258] ; addr
gosub inl[:LABEL_259] ; addr
mov 0x24, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:LABEL_255] ; addr
gosub inl[:LABEL_270] ; addr
call SEffe::scriptAllocateParticleEffect, stor[19], 0xffffffff, 0xfff26, 0x18, 0xa, 0x1, 0x800, 0xd087f00, 0x27 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptAttachEffectToBobj, stor[19], stor[0], 0xffffffff ; effectIndex, scriptIndex, coord2Index
call SEffe::scriptSetRelativePosition, stor[19], stor[0], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeRotation, stor[19], stor[0], 0x0, 0x400, 0x400 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetGenericEffectValue, stor[19], 0x0, 0x1 ; effectIndex, genericIndex, value
call SEffe::scriptSetRelativeColour, stor[19], 0xffffffff, 0xd8, 0x60, 0xd8 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetRelativeScale, stor[19], 0xffffffff, 0x100, 0x100, 0x100 ; bobjIndex1, bobjIndex2, x, y, z
mov 0x2, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:LABEL_253] ; addr
mov 0x2, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:LABEL_253] ; addr
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames
deallocate

; SUBROUTINE
LABEL_253:
call SEffe::allocateDeffTmd, stor[20], 0xfff1f ; effectIndex, flags
mov 0x1, stor[stor[stor[0], 20], 8] ; source, dest
LABEL_254:
call SEffe::scriptAttachEffectToBobj, stor[20], stor[0], 0xffffffff ; effectIndex, scriptIndex, coord2Index
call SEffe::scriptLoadSameScriptAndJump, stor[20], inl[:LABEL_256] ; scriptIndex, address
return

; SUBROUTINE
LABEL_255:
call SEffe::allocateDeffTmd, stor[20], 0xfff05 ; effectIndex, flags
mov 0x0, stor[stor[stor[0], 20], 8] ; source, dest
jmp inl[:LABEL_254] ; addr

; FORK RE-ENTRY
LABEL_256:
call SEffe::scriptSetRelativeRotation, stor[0], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[0], 0xffffffff, 0xd8, 0x60, 0xd8 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetRelativeScale, stor[0], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[0], 0xffffffff, 0x2, 0x800, 0x800, 0x800 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddRotationScalerAttachment, stor[0], stor[0], 0x0, 0x0, 0x100, 0x0, 0x0, 0x0 ; effectIndex, unused, velocityX, velocityY, velocityZ, accelerationX, accelerationY, accelerationZ
mov 0x2, stor[27] ; source, dest
wait stor[27] ; frames
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_257] ; operand, left, right, addr
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[0], 0xffffffff, 0x4, 0x1800, 0x1800, 0x1800 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[0], 0xffffffff, 0x4, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
mov 0x4, stor[27] ; source, dest
wait stor[27] ; frames
deallocate
LABEL_257:
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[0], 0xffffffff, 0x6, 0x1400, 0x1400, 0x1400 ; effectIndex, parentIndex, ticks, x, y, z
mov 0x5, stor[27] ; source, dest
wait stor[27] ; frames
deallocate

; SUBROUTINE
LABEL_258:
call SEffe::scriptAllocateParticleEffect, stor[18], 0xffffffff, 0x200003, 0x64, 0x5dc, 0xa, 0x200, 0x41a0000, 0x3a ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0xc0, 0xc0, 0x50 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetGenericEffectValue, stor[18], 0x0, 0x1 ; effectIndex, genericIndex, value
call SEffe::scriptSetRelativePosition, stor[18], stor[30], 0xffffffb0, 0xfffffd6c, 0x104 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[18], 0x32 ; effectIndex, ticks
return

; SUBROUTINE
LABEL_259:
gosub inl[:LABEL_260] ; addr
gosub inl[:LABEL_260] ; addr
return

; SUBROUTINE
LABEL_260:
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
mov 0x1e, stor[stor[stor[0], 18], 8] ; source, dest
mov 0x1, stor[stor[stor[0], 18], 9] ; source, dest
mov stor[8], stor[stor[stor[0], 18], 10] ; source, dest
mov stor[30], stor[stor[stor[0], 18], 11] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:LABEL_261] ; scriptIndex, address
return

; FORK RE-ENTRY
LABEL_261:
call Battle::scriptRand, stor[23], 0x0, stor[9] ; value, min, max
jmp_cmp !=, 0x0, stor[23], inl[:LABEL_262] ; operand, left, right, addr
call Battle::scriptRand, stor[18], 0x1, 0x2 ; value, min, max
call SEffe::scriptAllocateElectricityEffect, stor[15], 0xffffffff, 0x3e8, stor[18], 0x3e8, 0x100, 0x51060, 0x0 ; effectIndex, parentIndex, boltAngleRangeCutoff, boltCount, maxSegmentLength, boltAngleStep, flags, type
call SEffe::scriptSetRelativeColour, stor[15], 0xffffffff, 0x18, 0x0, 0xa0 ; bobjIndex1, bobjIndex2, r, g, b
call Battle::scriptRand, stor[18], 0x0, 0x1000 ; value, min, max
call SEffe::scriptSetRelativePosition, stor[15], stor[11], 0xffffffb0, 0xfffffd6c, 0x104 ; bobjIndex1, bobjIndex2, x, y, z
add 0x400, stor[18] ; amount, operand
call SEffe::scriptSetRelativeRotation, stor[15], 0xffffffff, stor[18], 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
mov 0x5, stor[stor[stor[0], 15], 8] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[15], inl[:LABEL_263] ; scriptIndex, address
LABEL_262:
yield
while stor[8], inl[:LABEL_261] ; counter, addr
deallocate

; FORK RE-ENTRY
LABEL_263:
mov stor[stor[stor[0], 0], 8], stor[stor[stor[0], 0], 23] ; source, dest
wait stor[stor[stor[0], 0], 23] ; frames
deallocate

; FORK RE-ENTRY
JMP_5f58_2:
mov 0x9, stor[10] ; source, dest
wait stor[9] ; frames
gosub inl[:LABEL_265] ; addr
gosub inl[:LABEL_270] ; addr
gosub inl[:LABEL_264] ; addr
call SEffe::scriptSetRelativeRotation, stor[18], 0xffffffff, 0x0, 0x500, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x1000, 0x1000, 0x1000 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0xa, 0x2000, 0x2000, 0x2000 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0xff, 0x80, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x6, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAllocateParticleEffect, stor[21], stor[0], 0x200004, 0x14, 0x0, 0x0, 0x2000, 0x408ff00, 0x15 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativePosition, stor[21], stor[0], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeRotation, stor[21], stor[0], 0x400, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[21], 0xffffffff, 0xf8, 0xf8, 0x80 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetGenericEffectValue, stor[21], 0x0, 0x1 ; effectIndex, genericIndex, value
call SEffe::scriptAddLifespanAttachment, stor[21], 0x8 ; effectIndex, ticks
gosub inl[:LABEL_264] ; addr
call SEffe::scriptSetRelativeRotation, stor[18], 0xffffffff, 0x0, 0xfffffb00, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x1000, 0x1000, 0x1000 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0xa, 0x2000, 0x2000, 0x2000 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0xff, 0x80, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x6, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
gosub inl[:LABEL_264] ; addr
call SEffe::scriptSetRelativeRotation, stor[18], 0xffffffff, 0x0, 0x800, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x2000, 0x2000, 0x2000 ; bobjIndex1, bobjIndex2, x, y, z
mov stor[10], stor[11] ; source, dest
mul 0x1000, stor[11] ; amount, operand
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0x7, 0x0, 0x0, stor[11] ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0xff, 0x80, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x6, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames
deallocate

; SUBROUTINE
LABEL_264:
call SEffe::allocateDeffTmd, stor[18], 0xfff1b ; effectIndex, flags
call SEffe::scriptAttachEffectToBobj, stor[18], stor[0], 0xffffffff ; effectIndex, scriptIndex, coord2Index
call SEffe::scriptSetRelativePosition, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetEffectTranslucencySourceFlag, stor[18], 0x1 ; effectIndex, set
call SEffe::scriptSetEffectTranslucencyModeFlag, stor[18], 0x1 ; effectIndex, set
call SEffe::scriptAddLifespanAttachment, stor[18], 0x8 ; effectIndex, ticks
return

; SUBROUTINE
LABEL_265:
call Battle::scriptGetBentPos, stor[30], stor[14], stor[15], stor[16] ; bentIndex, x, y, z
add stor[21], stor[14] ; amount, operand
add stor[20], stor[15] ; amount, operand
add stor[19], stor[16] ; amount, operand
call SEffe::scriptSetRelativePosition, stor[0], 0xffffffff, stor[14], stor[15], stor[16] ; bobjIndex1, bobjIndex2, x, y, z
return

; SUBROUTINE
LABEL_266:
call SEffe::scriptAllocateParticleEffect, stor[18], stor[0], 0xfff03, 0x8, 0xc8, 0x3, 0x200, 0x40a4000, 0x2 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x400, 0x400, 0x400 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[18], 0xa ; effectIndex, ticks
LABEL_267:
call SEffe::scriptSetRelativePosition, stor[18], stor[0], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0x4f, 0x45, 0x38 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetGenericEffectValue, stor[18], 0x0, 0x1 ; effectIndex, genericIndex, value
return

; SUBROUTINE
LABEL_268:
call SEffe::scriptAllocateParticleEffect, stor[18], stor[0], 0xfff03, 0x8, 0xc8, 0x3, 0x100, 0x4134000, 0x3 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x300, 0x300, 0x300 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[18], 0xa ; effectIndex, ticks
jmp inl[:LABEL_267] ; addr
data 0x49

; SUBROUTINE
LABEL_269:
call SEffe::scriptAllocateParticleEffect, stor[18], stor[0], 0xfff03, 0x10, 0xc8, 0x3, 0x100, 0x4134000, 0x4 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x300, 0x300, 0x300 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[18], 0xf ; effectIndex, ticks
jmp inl[:LABEL_267] ; addr
data 0x49

; SUBROUTINE
LABEL_270:
gosub inl[:LABEL_273] ; addr
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_271] ; operand, left, right, addr
call Battle::scriptGetBobjModelPartCount, stor[28], stor[8] ; bobjIndex, partCount
call SEffe::scriptAllocateParticleEffect, stor[18], stor[28], 0xfff18, stor[8], 0x0, 0x4, 0x0, 0x7084000, 0x40 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x40, 0x600, 0x600 ; bobjIndex1, bobjIndex2, x, y, z
gosub inl[:LABEL_272] ; addr
call Battle::scriptGetBobjModelPartCount, stor[28], stor[8] ; bobjIndex, partCount
call SEffe::scriptAllocateParticleEffect, stor[18], stor[28], 0xfff18, stor[8], 0x0, 0x4, 0x0, 0x7084000, 0x40 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x1800, 0x40, 0x1800 ; bobjIndex1, bobjIndex2, x, y, z
gosub inl[:LABEL_272] ; addr
LABEL_271:
return

; SUBROUTINE
LABEL_272:
call SEffe::scriptSetRelativeRotation, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call Battle::scriptGetCharOrMonsterId, stor[30], stor[8] ; bentIndex, id
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, inl[:LABEL_684[stor[8]]], inl[:LABEL_685[stor[8]]], inl[:LABEL_686[stor[8]]] ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetEffectZ, stor[18], 0xffffff00 ; effectIndex, z
call Battle::scriptGetBobjModelPartCount, stor[28], stor[8] ; bobjIndex, partCount
call SEffe::scriptAddLifespanAttachment, stor[18], stor[8] ; effectIndex, ticks
return

; SUBROUTINE
LABEL_273:
call Battle::scriptGetBentStat, stor[30], EQUIPMENT_ATTACK_ELEMENT_OR_MONSTER_DISPLAY_ELEMENT, stor[8] ; bentIndex, statIndex, value
call Battle::scriptGetBentStat, stor[28], MONSTER_ELEMENT, stor[9] ; bentIndex, statIndex, value
add stor[9], stor[8] ; amount, operand
jmp_cmp ==, 0x81, stor[8], inl[:LABEL_274] ; operand, left, right, addr
jmp_cmp ==, 0x42, stor[8], inl[:LABEL_274] ; operand, left, right, addr
jmp_cmp ==, 0x24, stor[8], inl[:LABEL_274] ; operand, left, right, addr
mov 0x0, stor[8] ; source, dest
LABEL_274:
return
data 0x80
data 0x40
data 0x20
data 0x4
data 0x10
data 0x40
data 0x1
data 0x2
data 0x20
data 0x80



; SUBROUTINE
JMP_bf38_0:
mov 0xffffffff, var[45][241] ; source, dest
call Battle::scriptSetBattleHudVisibility, 0x0 ; visible
gosub inl[:LABEL_346] ; addr
call Battle::scriptGetBentPos, stor[0], stor[24], stor[25], stor[26] ; bentIndex, x, y, z
call Battle::scriptGetBentPos, stor[28], stor[stor[stor[0], 28], 24], stor[stor[stor[0], 28], 25], stor[stor[stor[0], 28], 26] ; bentIndex, x, y, z
mov 0x22, var[44] ; set camera
mov stor[0], var[80] ; source, dest
mov stor[28], var[81] ; source, dest
mov 0x0, var[45][105] ; source, dest
call Battle::scriptGetBentSlot, stor[28], stor[8], 0x1 ; bentIndex, charOrBentSlot, mode
mov 0x1, stor[9] ; source, dest
shl stor[8], stor[9] ; right, left
jmp_cmp !&, stor[9], var[45][250], inl[:LABEL_275] ; operand, left, right, addr
or 0x10, var[45][105] ; right, left
or 0x2, var[45][105] ; right, left
jmp inl[:LABEL_277] ; addr
LABEL_275:
call Battle::scriptGetBentStat, stor[0], _159, stor[8] ; bentIndex, statIndex, value
call Battle::scriptSetBentStat, stor[0], stor[8], SPELL_ID ; bentIndex, value, statIndex
call Battle::scriptSetTempSpellStats, stor[0] ; bentIndex
call Battle::scriptCheckPhysicalHit, stor[0], stor[28], stor[8] ; attackerIndex, defenderIndex, hit
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_276] ; operand, left, right, addr
or 0x10, var[45][105] ; right, left
or 0x2, var[45][105] ; right, left
jmp inl[:LABEL_277] ; addr
LABEL_276:
gosub inl[:LABEL_240] ; addr
call SEffe::scriptAllocateAdditionOverlaysEffect, stor[0], stor[28], stor[8], 0x0, stor[18] ; attackerIndex, targetIndex, autoCompleteType, unused, effectIndex
mov stor[18], var[45][104] ; source, dest
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_277] ; operand, left, right, addr
call SEffe::scriptSetEffectErrorFlag, stor[18], 0x0 ; effectIndex, clear
LABEL_277:
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x8 ; bentIndex, animIndex
mov 0x5, stor[23] ; source, dest
wait stor[23] ; frames
mov 0x0, stor[8] ; source, dest
LABEL_278:
mov var[34][stor[8]], stor[9] ; source, dest
jmp_cmp ==, stor[0], stor[9], inl[:LABEL_279] ; operand, left, right, addr
call Battle::scriptSetBentHidden, stor[9], 0x0 ; bentIndex, set
LABEL_279:
incr stor[8] ; operand
jmp_cmp <, stor[8], var[35], inl[:LABEL_278] ; operand, left, right, addr
call SEffe::scriptLoadDeffStageEffects, 0x2 ; mode
gosub inl[:LABEL_294] ; addr
call Battle::scriptSetInterpolationEnabled, stor[0], 0x0 ; bentIndex, set
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x2 ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop
call Battle::scriptGetBentStat, stor[28], MIDDLE_OFFSET_X, stor[9] ; bentIndex, statIndex, value
call Battle::scriptGetHitProperty, stor[0], 0x0, 0xc, stor[8] ; bentIndex, hitNum, hitPropertyIndex, value
mov stor[8], var[45][122] ; source, dest
mov 0x0, var[45][123] ; source, dest
add stor[8], stor[9] ; amount, operand
call Battle::scriptGetHitProperty, stor[0], 0x0, 0xb, stor[8] ; bentIndex, hitNum, hitPropertyIndex, value
add stor[8], stor[9] ; amount, operand
mul 0x64, stor[9] ; amount, operand
call Battle::FUN_800cc0c8, stor[0], stor[28], 0x6, stor[9], 0x0 ; bentIndex0, bentIndex1, ticks, x, z
call Audio::scriptPlaySound, 0x0, 0x20, 0x0, 0x0, 0x0, 0x2 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
call Battle::FUN_800f9c00, 0x1 ; p0
call Battle::FUN_800f9b94, 0x2c, 0x2 ; p0, p1
gosub inl[:LABEL_266] ; addr
mov 0x2, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:LABEL_266] ; addr
mov 0x2, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:LABEL_266] ; addr
mov 0x2, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:LABEL_268] ; addr
call Audio::scriptStopSound, 0x0, 0x20, 0x3 ; soundFileIndex, soundIndex, mode
call Battle::scriptSetBentRotationY, stor[0], 0x400 ; bentIndex, y
mov stor[0], stor[stor[stor[0], 28], 28] ; source, dest
gosub inl[:LABEL_147] ; addr
call Battle::scriptSetInterpolationEnabled, stor[0], 0x1 ; bentIndex, set
call Battle::FUN_800f9bd4, 0x7 ; p0
jmp_cmp !&, 0x2, var[45][105], inl[:LABEL_281] ; operand, left, right, addr
jmp_cmp !&, 0x4, var[45][105], inl[:LABEL_281] ; operand, left, right, addr
or 0x40, var[45][105] ; right, left
LABEL_280:
mov var[45][105], stor[8] ; source, dest
yield
jmp_cmp !&, 0x8, var[45][105], inl[:LABEL_280] ; operand, left, right, addr
jmp inl[:LABEL_282] ; addr
LABEL_281:
jmp_cmp !=, 0x3, var[45][66], inl[:LABEL_285] ; operand, left, right, addr
LABEL_282:
mov 0xffffffff, var[45][241] ; source, dest
jmp_cmp &, 0x100, var[45][105], inl[:LABEL_283] ; operand, left, right, addr
mov 0x11, var[54] ; source, dest
mov 0xe2, var[44] ; source, dest
call Battle::scriptMoveCameraProjectionPlane, 0x2, 0x152, 0x11, 0x0 ; mode, newDistance, frames, stepZ1
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x1b ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop
call Battle::scriptGetBentStat, stor[0], FOOT_MODEL_PART, inl[:JMP_bf38_0_FOOT_MODEL_PART_INDEX]
call Battle::scriptGetBobjLocalWorldMatrixTranslation, stor[0], inl[:JMP_bf38_0_FOOT_MODEL_PART_INDEX], stor[10], stor[11], stor[12] ; effectIndex, partIndex, x, y, z
call Battle::scriptSetBentPos, stor[0], stor[10], stor[11], stor[12] ; bentIndex, x, y, z
call Battle::FUN_800cbde0, stor[0], 0xffffffff, 0xa, stor[24], stor[25], stor[26] ; bentIndex0, bentIndex1, ticks, x, y, z
call Battle::FUN_800cbb00, stor[28], 0xffffffff, 0xa, stor[stor[stor[0], 28], 24], stor[stor[stor[0], 28], 25], stor[stor[stor[0], 28], 26] ; bentIndex0, bentIndex1, ticks, x, y, z
wait_cmp !&, 0x4000000, stor[7] ; operator, left, right
gosub inl[:LABEL_291] ; addr
gosub inl[:LABEL_298] ; addr
call Audio::scriptPlaySound, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
gosub inl[:LABEL_269] ; addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0xe ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop
call Battle::FUN_800cbde0, stor[0], 0xffffffff, 0x7, stor[24], stor[25], stor[26] ; bentIndex0, bentIndex1, ticks, x, y, z
call Rumble::scriptStartRumble, 0x0, 0x1ff, 0x3 ; joypadIndex, p1, duration
mov 0x3, stor[23] ; source, dest
wait stor[23] ; frames
call Rumble::scriptStartRumble, 0x0, 0x15e, 0x3 ; joypadIndex, p1, duration
wait_cmp !&, 0x4000000, stor[7] ; operator, left, right
call Rumble::scriptStartRumble, 0x0, 0x1ff, 0x3 ; joypadIndex, p1, duration
mov 0x3, stor[23] ; source, dest
wait stor[23] ; frames
call Rumble::scriptStartRumble, 0x0, 0x0, 0x3 ; joypadIndex, p1, duration
mov 0x2, stor[23] ; source, dest
wait stor[23] ; frames
mov 0x20, stor[8] ; source, dest
jmp inl[:LABEL_284] ; addr
LABEL_283:
mov 0x21, stor[8] ; source, dest
LABEL_284:
mov stor[28], stor[18] ; source, dest
mov stor[30], stor[20] ; source, dest
mov stor[28], stor[30] ; source, dest
mov stor[0], stor[28] ; source, dest
gosub inl[:LABEL_8] ; addr
mov stor[18], stor[28] ; source, dest
mov stor[20], stor[30] ; source, dest
mov stor[8], stor[32] ; source, dest
gosub inl[:APPLY_DAMAGE_SIMPLE] ; addr
jmp_cmp &, 0x40, stor[7], inl[:LABEL_286] ; operand, left, right, addr
call Battle::scriptGetLoadingBentAnimationIndex, stor[0], stor[8] ; bentIndex, animationIndex
jmp_cmp !=, 0xe, stor[8], inl[:LABEL_286] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x9 ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop
gosub inl[:WAIT_FOR_ANIMATION_TO_FINISH] ; addr
jmp inl[:LABEL_286] ; addr
LABEL_285:
mov 0x11, var[54] ; source, dest
mov 0xe2, var[44] ; source, dest
call Battle::scriptMoveCameraProjectionPlane, 0x2, 0x152, 0x11, 0x0 ; mode, newDistance, frames, stepZ1
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x6 ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop
call Battle::scriptGetBobjLocalWorldMatrixTranslation, stor[0], inl[:JMP_bf38_0_FOOT_MODEL_PART_INDEX], stor[10], stor[11], stor[12] ; effectIndex, partIndex, x, y, z
call Battle::scriptSetBentPos, stor[0], stor[10], 0x0, stor[12] ; bentIndex, x, y, z
yield
call Battle::FUN_800cbb00, stor[0], 0xffffffff, 0x6, stor[24], stor[25], stor[26] ; bentIndex0, bentIndex1, ticks, x, y, z
call Battle::FUN_800cbb00, stor[28], 0xffffffff, 0xa, stor[stor[stor[0], 28], 24], stor[stor[stor[0], 28], 25], stor[stor[stor[0], 28], 26] ; bentIndex0, bentIndex1, ticks, x, y, z
wait_cmp !&, 0x4000000, stor[7] ; operator, left, right
gosub inl[:LABEL_291] ; addr
gosub inl[:LABEL_298] ; addr
gosub inl[:LABEL_268] ; addr
gosub inl[:WAIT_FOR_ANIMATION_TO_FINISH] ; addr
LABEL_286:
call Battle::scriptSetBentPos, stor[28], stor[stor[stor[0], 28], 24], stor[stor[stor[0], 28], 25], stor[stor[stor[0], 28], 26] ; bentIndex, x, y, z
call Battle::scriptSetBentPos, stor[0], stor[24], stor[25], stor[26] ; bentIndex, x, y, z
gosub inl[:SET_IDLE_ANIMATION] ; addr
mov 0x5, stor[23] ; source, dest
wait stor[23] ; frames
jmp_cmp !&, 0x20, var[45][105], inl[:LABEL_287] ; operand, left, right, addr
call Battle::scriptGetCharOrMonsterId, stor[0], stor[8] ; bentIndex, id
call Battle::scriptAllocateAdditionScript, stor[8], 0xffffffff ; charId, p1
LABEL_287:
gosub inl[:CAN_BECOME_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[10], inl[:LABEL_288] ; operand, left, right, addr
call Battle::scriptAllocateAdditionNameEffect, 0xffffffff ; totalSp
LABEL_288:
call Battle::FUN_800f9c00, 0x0 ; p0
jmp_cmp >, 0x0, var[45][241], inl[:LABEL_289] ; operand, left, right, addr
jmp_cmp &, 0x80, var[45][105], inl[:LABEL_289] ; operand, left, right, addr
gosub inl[:LABEL_26] ; addr
jmp_cmp &, 0x40, stor[stor[stor[0], 28], 7], inl[:LABEL_289] ; operand, left, right, addr
mov var[45][241], stor[8] ; source, dest
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_290] ; operand, left, right, addr
gosub inl[:LABEL_427] ; addr
fork_reenter stor[28], 0xa, stor[8] ; index, entrypoint, p2
LABEL_289:
return
LABEL_290:
call Battle::scriptSetBentRawStat, stor[28], 0x0, CURRENT_HP ; bentIndex, value, statIndex
fork_reenter stor[28], 0x4, stor[8] ; index, entrypoint, p2
gosub inl[:LABEL_144] ; addr
return

JMP_bf38_0_FOOT_MODEL_PART_INDEX:
data 0


; SUBROUTINE
LABEL_291:
mov 0x0, stor[8] ; source, dest
LABEL_292:
mov var[34][stor[8]], stor[9] ; source, dest
jmp_cmp ==, stor[0], stor[9], inl[:LABEL_293] ; operand, left, right, addr
call Battle::scriptSetBentHidden, stor[9], 0x1 ; bentIndex, set
LABEL_293:
incr stor[8] ; operand
jmp_cmp <, stor[8], var[35], inl[:LABEL_292] ; operand, left, right, addr
call SEffe::scriptLoadDeffStageEffects, 0x0 ; mode
return

; SUBROUTINE
LABEL_294:
gosub inl[:LABEL_317] ; addr
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_295] ; operand, left, right, addr
gosub inl[:LABEL_296] ; addr
call Battle::scriptAllocateEmptyEffectManagerChild, stor[23] ; effectIndex
mov stor[28], stor[stor[stor[0], 23], 23] ; source, dest
gosub inl[:LABEL_304] ; addr
gosub inl[:LABEL_310] ; addr
LABEL_295:
return

; SUBROUTINE
LABEL_296:
mov 0x0, stor[8] ; source, dest
LABEL_297:
mov var[52][stor[8]], stor[9] ; source, dest
call Battle::scriptSetBentHidden, stor[9], 0x0 ; bentIndex, set
incr stor[8] ; operand
jmp_cmp <, stor[8], var[53], inl[:LABEL_297] ; operand, left, right, addr
return

; SUBROUTINE
LABEL_298:
gosub inl[:LABEL_317] ; addr
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_301] ; operand, left, right, addr

; SUBROUTINE
LABEL_299:
mov 0x0, stor[8] ; source, dest
LABEL_300:
mov var[52][stor[8]], stor[9] ; source, dest
call Battle::scriptAllocateEmptyEffectManagerChild, stor[23] ; effectIndex
mov stor[9], stor[stor[stor[0], 23], 23] ; source, dest
gosub inl[:LABEL_304] ; addr
incr stor[8] ; operand
jmp_cmp <, stor[8], var[53], inl[:LABEL_300] ; operand, left, right, addr
gosub inl[:LABEL_308] ; addr
LABEL_301:
return

; SUBROUTINE
LABEL_302:
mov var[45][241], stor[8] ; source, dest
jmp_cmp >, 0x0, stor[8], inl[:LABEL_303] ; operand, left, right, addr
gosub inl[:LABEL_358] ; addr
LABEL_303:
return

; SUBROUTINE
LABEL_304:
mov stor[8], stor[stor[stor[0], 23], 8] ; source, dest
mov stor[9], stor[stor[stor[0], 23], 9] ; source, dest
call Battle::scriptSetBentHidden, stor[stor[stor[0], 23], 23], 0x1 ; bentIndex, set
jmp_cmp !=, 0x0, inl[:LABEL_316], inl[:LABEL_307] ; operand, left, right, addr
jmp_cmp !&, 0x200, stor[stor[stor[23], 23], 7], inl[:LABEL_307] ; operand, left, right, addr
mov 0x0, stor[8] ; source, dest
LABEL_305:
mov var[36][stor[8]], stor[9] ; source, dest
jmp_cmp !&, 0x8000, stor[stor[stor[0], 9], 7], inl[:LABEL_306] ; operand, left, right, addr
call Battle::scriptSetBentHidden, stor[9], 0x1 ; bentIndex, set
jmp inl[:LABEL_307] ; addr
LABEL_306:
incr stor[9] ; operand
jmp_cmp <, stor[9], var[37], inl[:LABEL_305] ; operand, left, right, addr
LABEL_307:
mov stor[stor[stor[0], 23], 9], stor[9] ; source, dest
mov stor[stor[stor[0], 23], 8], stor[8] ; source, dest
deallocate_other stor[23] ; index
return
data 0x208
data 0x2000008
data 0x3081700
data 0x208
data 0x2000009
data 0x3091700
data 0x30242
data 0x900005c
data 0x900001d
data 0x70341
data 0x1000000
data 0x200
data 0x3071717
data 0x900001a
data 0x10c
data 0x2000008
data 0x208
data 0x7000824
data 0x2000009
data 0x70341
data 0x1000000
data 0x8000
data 0x3070900
data 0x900000a
data 0x208
data 0x2000009
data 0x3171700
data 0x140
data 0x9000008
data 0x11b
data 0x2000009
data 0x10341
data 0x2000009
data 0x5000025
data 0x900fff1
data 0x208
data 0x3171700
data 0x9000040
data 0x208
data 0x3091700
data 0x2000009
data 0x208
data 0x3081700
data 0x2000008
data 0x153
data 0x2000017
data 0x49

; SUBROUTINE
LABEL_308:
mov stor[8], inl[:LABEL_315] ; source, dest
gosub inl[:LABEL_312] ; addr
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_309] ; operand, left, right, addr
call SEffe::scriptSetEffectErrorFlag, var[45][50], 0x1 ; effectIndex, clear
LABEL_309:
mov inl[:LABEL_315], stor[8] ; source, dest
return

; SUBROUTINE
LABEL_310:
mov stor[8], inl[:LABEL_315] ; source, dest
gosub inl[:LABEL_312] ; addr
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_311] ; operand, left, right, addr
call SEffe::scriptSetEffectErrorFlag, var[45][50], 0x0 ; effectIndex, clear
LABEL_311:
mov inl[:LABEL_315], stor[8] ; source, dest
return

; SUBROUTINE
LABEL_312:
mov 0x0, stor[8] ; source, dest
jmp_cmp ==, 0x1a6, var[43], inl[:LABEL_313] ; operand, left, right, addr
jmp_cmp !=, 0x1bb, var[43], inl[:LABEL_314] ; operand, left, right, addr
jmp_cmp !=, 0x1, var[39], inl[:LABEL_314] ; operand, left, right, addr
LABEL_313:
jmp_cmp ==, 0x0, var[45][50], inl[:LABEL_314] ; operand, left, right, addr
incr stor[8] ; operand
LABEL_314:
return
LABEL_315:
data 0x0
LABEL_316:
data 0x0
data 0x0

; SUBROUTINE
LABEL_317:
mov 0x0, stor[8] ; source, dest
jmp_cmp ==, 0x19c, var[43], inl[:LABEL_319] ; operand, left, right, addr
jmp_cmp ==, 0x19f, var[43], inl[:LABEL_319] ; operand, left, right, addr
jmp_cmp ==, 0x1a2, var[43], inl[:LABEL_319] ; operand, left, right, addr
jmp_cmp ==, 0x1a3, var[43], inl[:LABEL_319] ; operand, left, right, addr
jmp_cmp ==, 0x1a6, var[43], inl[:LABEL_319] ; operand, left, right, addr
jmp_cmp ==, 0x1b0, var[43], inl[:LABEL_319] ; operand, left, right, addr
jmp_cmp !=, 0x1bb, var[43], inl[:LABEL_318] ; operand, left, right, addr
jmp_cmp ==, 0x0, var[39], inl[:LABEL_319] ; operand, left, right, addr
jmp_cmp ==, 0x1, var[39], inl[:LABEL_319] ; operand, left, right, addr
LABEL_318:
mov 0x1, stor[8] ; source, dest
LABEL_319:
return

; SUBROUTINE
JMP_bf60_2:
mov 0x1, stor[8] ; source, dest
gosub_table stor[8], inl[:LABEL_90] ; index, table
call Battle::scriptSetBattleHudVisibility, 0x0 ; visible
gosub inl[:LABEL_346] ; addr
mov stor[0], var[80] ; source, dest
mov stor[28], var[81] ; source, dest
gosub inl[:LABEL_363] ; addr
mov 0x0, var[45][105] ; source, dest
call Battle::scriptGetBentSlot, stor[28], stor[8], 0x1 ; bentIndex, charOrBentSlot, mode
mov 0x1, stor[9] ; source, dest
shl stor[8], stor[9] ; right, left
jmp_cmp !&, stor[9], var[45][250], inl[:LABEL_320] ; operand, left, right, addr
jmp_cmp ==, 0x19e, var[43], inl[:LABEL_320] ; operand, left, right, addr
or 0x10, var[45][105] ; right, left
LABEL_320:
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x10 ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop
gosub inl[:LABEL_348] ; addr
call Battle::scriptPlayBentSound, 0x1, stor[0], 0x0, 0x0, 0x0, inl[:LABEL_352[stor[8]]], 0x0 ; type, bentIndex, soundIndex, a3, a4, initialDelay, repeatDelay
call Battle::scriptPlayBentSound, 0x1, stor[0], 0x4, 0x0, 0x0, inl[:LABEL_353[stor[8]]], 0x0 ; type, bentIndex, soundIndex, a3, a4, initialDelay, repeatDelay
call Battle::scriptPlayBentSound, 0x1, stor[0], 0x5, 0x0, 0x0, inl[:LABEL_354[stor[8]]], 0x0 ; type, bentIndex, soundIndex, a3, a4, initialDelay, repeatDelay

call Battle::scriptPrepareAttack

gosub inl[:LABEL_348] ; addr
mov inl[:LABEL_352[stor[8]]], stor[23] ; source, dest
wait stor[23] ; frames
mov stor[0], stor[30] ; source, dest
mov 0x0, stor[9] ; source, dest
mov 0xfffffc00, stor[10] ; source, dest
mov 0x0, stor[11] ; source, dest
gosub inl[:LABEL_404] ; addr
mov 0x6, stor[23] ; source, dest
wait stor[23] ; frames

call Battle::scriptAttack, stor[8] ; attack type
jmp_cmp ==, 1, stor[8], inl[:LABEL_337] ; deff
jmp_cmp ==, 2, stor[8], inl[:LABEL_335] ; custom

; normal attacks
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
mov stor[28], stor[stor[stor[0], 18], 28] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:LABEL_339] ; scriptIndex, address
call Battle::scriptGetBentStat, stor[0], _159, stor[9] ; bentIndex, statIndex, value
call Battle::scriptSetBentStat, stor[0], stor[9], SPELL_ID ; bentIndex, value, statIndex
call Battle::scriptSetTempSpellStats, stor[0] ; bentIndex
call Battle::scriptCheckPhysicalHit, stor[0], stor[28], stor[8] ; attackerIndex, defenderIndex, hit
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_322] ; operand, left, right, addr
jmp_cmp &, 0x10, var[45][105], inl[:LABEL_322] ; operand, left, right, addr
call Battle::scriptPhysicalAttack, stor[0], stor[28], stor[8], stor[9] ; attackerIndex, defenderIndex, damage, specialEffects
jmp inl[:LABEL_323] ; addr
LABEL_322:
mov 0xffffffff, stor[8] ; source, dest
mov 0xffffffff, stor[9] ; source, dest
LABEL_323:
jmp_cmp &, 0x2, stor[7], inl[:LABEL_325] ; operand, left, right, addr
jmp_cmp >, 0x0, stor[8], inl[:LABEL_325] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[0], STATUS, stor[10] ; bentIndex, statIndex, value
jmp_cmp !&, 0x8, stor[10], inl[:LABEL_324] ; operand, left, right, addr
shr 0x1, stor[8] ; right, left
LABEL_324:
jmp_cmp >=, 0x3b9ac9ff, stor[8], inl[:LABEL_325] ; operand, left, right, addr
mov 0x3b9ac9ff, stor[8] ; source, dest
LABEL_325:
fork_reenter stor[28], 0x2, stor[8] ; index, entrypoint, p2
mov stor[8], var[45][120] ; source, dest
mov stor[9], var[45][121] ; source, dest
jmp_cmp >, 0x0, stor[8], inl[:LABEL_329] ; operand, left, right, addr
gosub inl[:LABEL_356] ; addr
gosub inl[:CAN_BECOME_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_329] ; operand, left, right, addr
jmp_cmp &, 0x2, stor[7], inl[:LABEL_329] ; operand, left, right, addr
jmp_cmp &, 0x10, var[45][105], inl[:LABEL_329] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[0], DLEVEL, stor[8] ; bentIndex, statIndex, value
call Battle::scriptGetBentStat, stor[0], ARCHER_SP, stor[8] ; bentIndex, statIndex, value
LABEL_327:
call Battle::scriptGetBentStat, stor[0], SP_MULTIPLIER, stor[9] ; bentIndex, statIndex, value
add 0x64, stor[9] ; amount, operand
mul stor[9], stor[8] ; amount, operand
div 0x64, stor[8] ; amount, operand
call Battle::scriptGetBentStat, stor[0], STATUS, stor[9] ; bentIndex, statIndex, value
jmp_cmp !&, 0x40, stor[9], inl[:LABEL_328] ; operand, left, right, addr
mov 0x0, stor[8] ; source, dest
LABEL_328:
call Battle::scriptGetBentSlot, stor[0], stor[31], 0x1 ; bentIndex, charOrBentSlot, mode
add 0x73, stor[31] ; amount, operand
add stor[8], var[45][stor[31]] ; amount, operand
gosub inl[:CAN_BECOME_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[10], inl[:LABEL_329] ; operand, left, right, addr
call Battle::scriptGiveSp, stor[0], stor[8], stor[31] ; bentIndex, amount, total
mov 0x1, stor[9] ; source, dest
call Battle::scriptAllocateSpTextEffect, stor[8], stor[9] ; p0, p1
mov stor[8], var[45][108] ; source, dest
LABEL_329:
yield
call Battle::scriptAnimationHasFinished, stor[0], stor[8] ; bentIndex, finished
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_329] ; operand, left, right, addr
gosub inl[:SET_IDLE_ANIMATION] ; addr
jmp_cmp &, 0x2, stor[7], inl[:LABEL_332] ; operand, left, right, addr
jmp_cmp &, 0x10, var[45][105], inl[:LABEL_332] ; operand, left, right, addr
jmp_cmp >, 0x0, var[45][120], inl[:LABEL_331] ; operand, left, right, addr
mov var[45][121], stor[9] ; source, dest
jmp_cmp >, 0x0, stor[9], inl[:LABEL_331] ; operand, left, right, addr
mov stor[9], stor[8] ; source, dest
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_330] ; operand, left, right, addr
gosub inl[:LABEL_427] ; addr
mov stor[8], stor[31] ; source, dest
gosub inl[:LABEL_26] ; addr
jmp_cmp &, 0x40, stor[stor[stor[0], 28], 7], inl[:LABEL_331] ; operand, left, right, addr
fork_reenter stor[28], 0xa, stor[31] ; index, entrypoint, p2
jmp inl[:LABEL_331] ; addr
LABEL_330:
gosub inl[:LABEL_26] ; addr
call Battle::scriptSetBentRawStat, stor[28], 0x0, CURRENT_HP ; bentIndex, value, statIndex
fork_reenter stor[28], 0x4, 0x0 ; index, entrypoint, p2
gosub inl[:LABEL_144] ; addr
LABEL_331:
gosub inl[:CAN_BECOME_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[10], inl[:LABEL_332] ; operand, left, right, addr
mov var[45][108], stor[8] ; source, dest
call Battle::scriptAllocateAdditionNameEffect, stor[8] ; totalSp
LABEL_332:
gosub inl[:LABEL_26] ; addr
mov var[45][178], stor[8] ; source, dest
jmp_cmp ==, 0x44, stor[8], inl[:LABEL_333] ; operand, left, right, addr
gosub inl[:LABEL_336] ; addr
jmp inl[:LABEL_334] ; addr
LABEL_333:
mov 0xe3, var[44] ; source, dest
LABEL_334:
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:CAN_BECOME_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[10], inl[:LABEL_335] ; operand, left, right, addr
call Battle::scriptAllocateAdditionNameEffect, 0xffffffff ; totalSp
call Battle::scriptAllocateSpTextEffect, 0xffffffff, 0x0 ; p0, p1
LABEL_335:
return

; SUBROUTINE
LABEL_336:
mov 0x10, var[54] ; source, dest
mov 0xe2, var[44] ; source, dest
call Battle::scriptMoveCameraProjectionPlane, 0x2, 0x140, 0x10, 0x0 ; mode, newDistance, frames, stepZ1
return

LABEL_337:
call Battle::scriptTickDeffLoadingStage, 0x1 ; loadingStage
call Battle::scriptTickDeffLoadingStage, 0x2 ; loadingStage
LABEL_338:
yield
call Battle::scriptAnimationHasFinished, stor[0], stor[8] ; bentIndex, finished
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_338] ; operand, left, right, addr
gosub inl[:SET_IDLE_ANIMATION] ; addr
call Battle::scriptTickDeffLoadingStage, 0x3 ; loadingStage
gosub inl[:LABEL_26] ; addr
gosub inl[:LABEL_336] ; addr
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames
return

; FORK RE-ENTRY
LABEL_339:
mov 0x200, stor[8] ; source, dest
gosub inl[:LABEL_341] ; addr
mov 0x1, stor[23] ; source, dest
wait stor[23] ; frames
mov 0x400, stor[8] ; source, dest
gosub inl[:LABEL_341] ; addr
mov 0x3, stor[23] ; source, dest
wait stor[23] ; frames
mov 0x100, stor[8] ; source, dest
mov 0x4, stor[9] ; source, dest
mov 0x8, stor[10] ; source, dest
mov 0x4, stor[11] ; source, dest
gosub inl[:LABEL_340] ; addr
mov 0x200, stor[8] ; source, dest
gosub inl[:LABEL_340] ; addr
mov 0x2, stor[23] ; source, dest
wait stor[23] ; frames
mov 0x100, stor[8] ; source, dest
mov 0x6, stor[9] ; source, dest
mov 0x6, stor[10] ; source, dest
mov 0x8, stor[11] ; source, dest
gosub inl[:LABEL_340] ; addr
mov 0x200, stor[8] ; source, dest
gosub inl[:LABEL_340] ; addr
mov 0xf, stor[23] ; source, dest
wait stor[23] ; frames
deallocate

; SUBROUTINE
LABEL_340:
call SEffe::allocateDeffTmd, stor[18], 0xfff1f ; effectIndex, flags
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
mov stor[28], stor[stor[stor[0], 18], 28] ; source, dest
mov stor[8], stor[stor[stor[0], 18], 8] ; source, dest
mov stor[9], stor[stor[stor[0], 18], 9] ; source, dest
mov stor[10], stor[stor[stor[0], 18], 10] ; source, dest
mov stor[11], stor[stor[stor[0], 18], 11] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:LABEL_342] ; scriptIndex, address
return

; SUBROUTINE
LABEL_341:
call SEffe::allocateDeffTmd, stor[18], 0xfff05 ; effectIndex, flags
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
mov stor[28], stor[stor[stor[0], 18], 28] ; source, dest
mov stor[8], stor[stor[stor[0], 18], 8] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:LABEL_343] ; scriptIndex, address
return

; FORK RE-ENTRY
LABEL_342:
gosub inl[:LABEL_57] ; addr
call SEffe::scriptSetRelativePosition, stor[0], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[0], 0xffffffff, 0x40, 0x60, 0x80 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetRelativeRotation, stor[0], 0xffffffff, 0x400, 0x200, stor[8] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[0], 0xffffffff, 0x200, 0x200, 0x200 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[0], 0xffffffff, stor[11], 0xc00, 0xc00, 0xc00 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[0], 0xffffffff, 0xc, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
mov stor[9], stor[23] ; source, dest
wait stor[23] ; frames
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[0], 0xffffffff, stor[10], 0x1000, 0x1000, 0x1000 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[0], 0xffffffff, stor[10], 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
mov stor[10], stor[23] ; source, dest
wait stor[23] ; frames
deallocate

; FORK RE-ENTRY
LABEL_343:
gosub inl[:LABEL_57] ; addr
sub 0x80, stor[26] ; amount, operand
call SEffe::scriptSetRelativePosition, stor[0], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[0], 0xffffffff, 0x40, 0x60, 0x80 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetRelativeRotation, stor[0], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[0], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[0], 0xffffffff, 0x3, stor[8], stor[8], stor[8] ; effectIndex, parentIndex, ticks, x, y, z
mov 0x3, stor[23] ; source, dest
wait stor[23] ; frames
shl 0x1, stor[8] ; right, left
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[0], 0xffffffff, 0x4, stor[8], stor[8], stor[8] ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[0], 0xffffffff, 0x4, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
mov 0x4, stor[23] ; source, dest
wait stor[23] ; frames
deallocate

; SUBROUTINE
LABEL_346:
gosub inl[:LABEL_57] ; addr
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
call SEffe::scriptSetRelativePosition, stor[18], 0xffffffff, stor[24], 0x0, stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call Battle::scriptAllocateEmptyEffectManagerChild, stor[19] ; effectIndex
call SEffe::scriptAttachEffectToBobj, stor[19], stor[0], 0xffffffff ; effectIndex, scriptIndex, coord2Index
call SEffe::scriptSetRelativePosition, stor[19], stor[0], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptGetRelativeAngleBetweenBobjs, stor[19], stor[18], stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, z, y
jmp_cmp ==, 0x0, stor[24], inl[:LABEL_347] ; operand, left, right, addr
mov 0x800, stor[8] ; source, dest
sub stor[26], stor[8] ; amount, operand
mov stor[8], stor[26] ; source, dest
LABEL_347:
call Battle::scriptSetBentRotationY, stor[0], stor[26] ; bentIndex, y
deallocate_other stor[18] ; index
deallocate_other stor[19] ; index
return

; SUBROUTINE
LABEL_348:
gosub inl[:GET_MY_CHAR_ID] ; addr
jmp_cmp ==, 0x8, stor[8], inl[:LABEL_349] ; operand, left, right, addr
mov 0x0, stor[8] ; source, dest
jmp inl[:LABEL_350] ; addr
LABEL_349:
mov 0x2, stor[8] ; source, dest
LABEL_350:
gosub inl[:IS_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[31], inl[:LABEL_351] ; operand, left, right, addr
incr stor[8] ; operand
LABEL_351:
return
LABEL_352:
data 0x2c
data 0x2c
data 0x2e
data 0x26
LABEL_353:
data 0x10
data 0x10
data 0x16
data 0x12
LABEL_354:
data 0x2e
data 0x2e
data 0x30
data 0x28

; SUBROUTINE
LABEL_356:
jmp_cmp &, 0x2, stor[7], inl[:LABEL_357] ; operand, left, right, addr
jmp_cmp >, 0x0, var[45][120], inl[:LABEL_357] ; operand, left, right, addr
mov var[45][121], stor[9] ; source, dest
jmp_cmp >, 0x0, stor[9], inl[:LABEL_357] ; operand, left, right, addr
mov stor[9], stor[8] ; source, dest
gosub inl[:LABEL_358] ; addr
LABEL_357:
return

; SUBROUTINE
LABEL_358:
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_360] ; operand, left, right, addr
gosub inl[:LABEL_427] ; addr
jmp inl[:LABEL_359] ; addr
LABEL_359:
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
mov stor[28], stor[stor[stor[0], 18], 28] ; source, dest
mov stor[8], stor[stor[stor[0], 18], 8] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:ALLOCATE_STATUS_AFFLICTED_EFFECT] ; scriptIndex, address
LABEL_360:
return
LABEL_361:
data 0x43
data 0x44
data 0x45
LABEL_362:
data 0x43
data 0x45

; SUBROUTINE
LABEL_363:
call Battle::scriptGetBentStat, var[81], _63, stor[8] ; bentIndex, statIndex, value
jmp_cmp >, 0x4, stor[8], inl[:LABEL_364] ; operand, left, right, addr
rand 0x2, stor[8] ; bound, dest
mov inl[:LABEL_362[stor[8]]], stor[8] ; source, dest
jmp inl[:LABEL_365] ; addr
LABEL_364:
rand 0x3, stor[8] ; bound, dest
mov inl[:LABEL_361[stor[8]]], stor[8] ; source, dest
LABEL_365:
mov stor[8], var[44] ; source, dest
mov stor[8], var[45][178] ; source, dest
return



; SUBROUTINE
ALLOCATE_REGEN_EFFECT:
call Audio::scriptPlaySound, 0x0, 0x2f, 0x0, 0x0, 0x0, 0x0 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
gosub inl[:ALLOCATE_RECOVER_EFFECT] ; addr
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:LABEL_375] ; scriptIndex, address
return



; FORK RE-ENTRY
LABEL_375:
gosub inl[:LABEL_381] ; addr
gosub inl[:LABEL_379] ; addr
yield
yield
gosub inl[:LABEL_382] ; addr
gosub inl[:LABEL_379] ; addr
mov 0x1b, stor[23] ; source, dest
wait stor[23] ; frames
rewind



; SUBROUTINE
ALLOCATE_GUARD_OR_ON_DAMAGE_RECOVER_EFFECT:
call Audio::scriptPlaySound, 0x0, 0x2f, 0x0, 0x0, 0x0, 0x0 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
gosub inl[:ALLOCATE_RECOVER_EFFECT] ; addr
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:LABEL_377] ; scriptIndex, address
return



; FORK RE-ENTRY
LABEL_377:
yield
yield
gosub inl[:LABEL_379] ; addr
yield
yield
gosub inl[:LABEL_379] ; addr
yield
yield
mov 0x19, stor[9] ; source, dest
wait stor[9] ; frames
rewind



; SUBROUTINE
ALLOCATE_RECOVER_EFFECT:
call SEffe::allocateDeffTmd, stor[18], 0xfff24 ; effectIndex, flags
call SEffe::scriptSetRelativePosition, stor[18], stor[28], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeRotation, stor[18], stor[0], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x800, 0x800, 0x800 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0xc, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptSetEffectTranslucencySourceFlag, stor[18], 0x1 ; effectIndex, set
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0xc, 0xff, 0xff, 0xff ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddLifespanAttachment, stor[18], 0x23 ; effectIndex, ticks
mov stor[8], stor[stor[stor[0], 18], 8] ; source, dest
mov stor[28], stor[stor[stor[0], 18], 28] ; source, dest
return



; SUBROUTINE
LABEL_379:
call SEffe::scriptAllocateParticleEffect, stor[18], stor[0], 0xfff3d, 0xa, 0x170, 0x6, 0x170, 0x4197f00, 0x29 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativePosition, stor[18], stor[28], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x100, 0x100, 0x100 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetGenericEffectValue, stor[18], 0x0, 0x1 ; effectIndex, genericIndex, value
call SEffe::scriptAddLifespanAttachment, stor[18], 0x19 ; effectIndex, ticks
return
data 0x2ea0938
data 0x2000012
data 0x2000000
data 0xfff3e
data 0x2
data 0x100
data 0x6
data 0x170
data 0x1000000
data 0x40f7f00
data 0x29
data 0x2210538
data 0x2000012
data 0x200001c
data 0x0
data 0x1000000
data 0x0
data 0x0
data 0x2250538
data 0x2000012
data 0x1000000
data 0xffffffff
data 0x600
data 0x600
data 0x600
data 0x2270538
data 0x2000012
data 0x1000000
data 0xffffffff
data 0xa080096
data 0xa080099
data 0xa08009c
data 0x2290338
data 0x2000012
data 0x0
data 0x1
data 0x24c0238
data 0x2000012
data 0xf
data 0x2ea0938
data 0x2000012
data 0x2000000
data 0xfff3e
data 0x2
data 0x100
data 0x6
data 0x170
data 0x1000000
data 0x40f7f00
data 0x29
data 0x2210538
data 0x2000012
data 0x200001c
data 0x0
data 0x1000000
data 0x0
data 0x0
data 0x2250538
data 0x2000012
data 0x1000000
data 0xffffffff
data 0x600
data 0x600
data 0x600
data 0x2270538
data 0x2000012
data 0x1000000
data 0xffffffff
data 0xa080078
data 0xa08007b
data 0xa08007e
data 0x2290338
data 0x2000012
data 0x0
data 0x1
data 0x24c0238
data 0x2000012
data 0xf

; SUBROUTINE
LABEL_380:
call Battle::scriptAllocateRadialGradientEffect, stor[18], 0x3, 0x2 ; effectIndex, count, type
call SEffe::scriptSetRelativePosition, stor[18], stor[28], 0x0, 0xfffffd00, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetGenericEffectValue, stor[18], 0x1, 0x200 ; effectIndex, genericIndex, value
call SEffe::scriptSetGenericEffectValue, stor[18], 0x2, 0x0 ; effectIndex, genericIndex, value
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[18], 0xc ; effectIndex, ticks
return

; SUBROUTINE
LABEL_381:
gosub inl[:LABEL_380] ; addr
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, inl[:LABEL_383[stor[8]]], inl[:LABEL_384[stor[8]]], inl[:LABEL_385[stor[8]]] ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0xc, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptSetRelativeRotation, stor[18], 0xffffffff, 0x200, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0xc, 0x5dc, 0x5dc, 0x5dc ; effectIndex, parentIndex, ticks, x, y, z
yield
yield
return

; SUBROUTINE
LABEL_382:
gosub inl[:LABEL_380] ; addr
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, inl[:LABEL_386[stor[8]]], inl[:LABEL_387[stor[8]]], inl[:LABEL_388[stor[8]]] ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0xc, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptSetRelativeRotation, stor[18], stor[0], 0x0, 0x600, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0xc, 0x5dc, 0x5dc, 0x5dc ; effectIndex, parentIndex, ticks, x, y, z
return
LABEL_383:
data 0x82
data 0xff
data 0xff
LABEL_384:
data 0xdf
data 0x68
data 0xe0
LABEL_385:
data 0xfa
data 0x68
data 0x68
LABEL_386:
data 0xff
data 0x9f
data 0x68
LABEL_387:
data 0xe0
data 0x68
data 0xcc
LABEL_388:
data 0x68
data 0xff
data 0x82



; SUBROUTINE
ALLOCATE_REVIVAL_EFFECT:
call Audio::scriptPlaySound, 0x0, 0x2e, 0x0, 0x0, 0x0, 0x0 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
call Battle::allocateBillboardSpriteEffect, stor[18], 0xfff25 ; effectIndex, flags
call SEffe::scriptSetRelativePosition, stor[18], stor[28], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x200, 0x200, 0x200 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[18], 0x64 ; effectIndex, ticks
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0xf, 0xff, 0xff, 0xff ; effectIndex, parentIndex, ticks, destR, destG, destB
mov stor[28], stor[stor[stor[0], 18], 28] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:REVIVAL_EFFECT_MAIN] ; scriptIndex, address
return



; FORK RE-ENTRY
REVIVAL_EFFECT_MAIN:
mov 0xfffff500, stor[10] ; source, dest
mov 0x0, stor[12] ; source, dest
call SEffe::scriptAllocateParticleEffect, stor[18], 0xffffffff, 0xfff3e, 0x32, 0x0, 0x6e, 0x100, 0x4107f00, 0x2b ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativePosition, stor[18], stor[28], stor[9], stor[10], stor[11] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x800, 0x800, 0x800 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetGenericEffectValue, stor[18], 0x0, 0x1 ; effectIndex, genericIndex, value
call SEffe::scriptSetGenericEffectValue, stor[18], 0x1, 0x1 ; effectIndex, genericIndex, value
call SEffe::scriptAddLifespanAttachment, stor[18], 0x69 ; effectIndex, ticks
mov 0x0, stor[23] ; source, dest
call SEffe::scriptSetRelativeColour, stor[18], stor[0], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], stor[0], 0x5, 0x80, 0x80, 0x80 ; effectIndex, parentIndex, ticks, destR, destG, destB
LABEL_398:
mov stor[10], stor[15] ; source, dest
sub 0xfffffe00, stor[15] ; amount, operand
div 0xa, stor[15] ; amount, operand
sub stor[15], stor[10] ; amount, operand
mov stor[10], stor[15] ; source, dest
neg stor[15] ; operand
add 0x50, stor[15] ; amount, operand
sin_12 stor[12], stor[16] ; angle, dest
mul 0x50, stor[16] ; amount, operand
div stor[15], stor[16] ; amount, operand
mov stor[10], stor[15] ; source, dest
neg stor[15] ; operand
add 0x50, stor[15] ; amount, operand
cos_12 stor[12], stor[17] ; angle, dest
mul 0x50, stor[17] ; amount, operand
div stor[15], stor[17] ; amount, operand
add 0x64, stor[12] ; amount, operand
call SEffe::scriptSetRelativePosition, stor[0], stor[28], stor[16], stor[10], stor[17] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativePosition, stor[18], stor[28], stor[16], stor[10], stor[17] ; bobjIndex1, bobjIndex2, x, y, z
incr stor[23] ; operand
mov stor[23], stor[22] ; source, dest
mod 0x8, stor[22] ; amount, operand
jmp_cmp !=, 0x0, stor[22], inl[:LABEL_399] ; operand, left, right, addr
mov stor[23], stor[21] ; source, dest
div 0x8, stor[21] ; amount, operand
decr stor[21] ; operand
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x8, inl[:LABEL_401[stor[21]]], inl[:LABEL_402[stor[21]]], inl[:LABEL_403[stor[21]]] ; effectIndex, parentIndex, ticks, destR, destG, destB
LABEL_399:
jmp_cmp !=, 0x3c, stor[23], inl[:LABEL_400] ; operand, left, right, addr
call SEffe::scriptAddConstantColourScalerAttachment, stor[0], 0xffffffff, 0x14, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
LABEL_400:
yield
jmp inl[:LABEL_398] ; addr



LABEL_401:
data 0xff
data 0xff
data 0xff
data 0x0
data 0x0
data 0x0
data 0x80
data 0x20
data 0x4
data 0x0
data 0x0
data 0x0
LABEL_402:
data 0xff
data 0x0
data 0x0
data 0x0
data 0xff
data 0xff
data 0xff
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
LABEL_403:
data 0x0
data 0x0
data 0xff
data 0xff
data 0xff
data 0x0
data 0x0
data 0x0
data 0x4
data 0x0
data 0x0
data 0x0

; SUBROUTINE
LABEL_404:
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
call SEffe::scriptAddLifespanAttachment, stor[18], 0x19 ; effectIndex, ticks
mov stor[28], stor[stor[stor[0], 18], 28] ; source, dest
mov stor[30], stor[stor[stor[0], 18], 30] ; source, dest
mov stor[9], stor[stor[stor[0], 18], 9] ; source, dest
mov stor[10], stor[stor[stor[0], 18], 10] ; source, dest
mov stor[11], stor[stor[stor[0], 18], 11] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:LABEL_405] ; scriptIndex, address
return

; FORK RE-ENTRY
LABEL_405:
call SEffe::allocateDeffTmd, stor[18], 0xfff09 ; effectIndex, flags
call SEffe::scriptSetRelativePosition, stor[18], stor[30], stor[9], stor[10], stor[11] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], stor[18], 0x1000, 0x1000, 0xb00 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[18], 0x14 ; effectIndex, ticks
jmp_cmp ==, 0xffffffff, stor[28], inl[:LABEL_406] ; operand, left, right, addr
gosub inl[:LABEL_57] ; addr
call SEffe::scriptAddRelativePositionScalerTicks1, stor[18], 0xffffffff, 0x4, stor[24], stor[25], stor[26] ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptRotateBobjTowardsPoint, stor[18], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex, parentIndex, x, y, z
jmp inl[:LABEL_407] ; addr
LABEL_406:
call SEffe::scriptAddRelativePositionScalerTicks1, stor[18], 0xffffffff, 0x4, 0xfffff100, 0xfffff900, 0x0 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptRotateBobjTowardsPoint, stor[18], 0xffffffff, 0xfffff100, 0xfffff900, 0x0 ; bobjIndex, parentIndex, x, y, z
jmp inl[:LABEL_407] ; addr
LABEL_407:
yield
yield
gosub inl[:LABEL_408] ; addr
gosub inl[:LABEL_408] ; addr
gosub inl[:LABEL_408] ; addr
mov 0x6, stor[23] ; source, dest
wait stor[23] ; frames
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0xc, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
mov 0xc, stor[23] ; source, dest
wait stor[23] ; frames
rewind

; SUBROUTINE
LABEL_408:
call SEffe::scriptGetEffectTranslationRelativeToParent, stor[18], 0xffffffff, stor[12], stor[13], stor[14] ; effectIndex, parentIndex, x, y, z
call SEffe::allocateDeffTmd, stor[19], 0xfff09 ; effectIndex, flags
call SEffe::scriptSetRelativePosition, stor[19], stor[18], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[19], stor[19], 0x1000, 0x1000, 0x1000 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeRotation, stor[19], stor[18], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetEffectTranslucencySourceFlag, stor[19], 0x1 ; effectIndex, set
call SEffe::scriptSetRelativeColour, stor[19], 0xffffffff, 0x0, 0x0, 0xff ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[19], 0xffffffff, 0x6, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddLifespanAttachment, stor[19], 0x6 ; effectIndex, ticks
yield
return

; FORK RE-ENTRY
; For example, the bubbles and hearts when you get bewitched
ALLOCATE_STATUS_AFFLICTED_EFFECT:
call Battle::allocateBillboardSpriteEffect, stor[18], 0xfff26 ; effectIndex, flags
call SEffe::scriptSetEffectTranslucencyModeFlag, stor[18], inl[:ALLOCATE_STATUS_AFFLICTED_EFFECT_TRANSLUCENCY[stor[8]]] ; effectIndex, set
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x400, 0x400, 0x400 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativePosition, stor[18], stor[28], 0x0, 0xfffffc00, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x8, inl[:ALLOCATE_STATUS_AFFLICTED_EFFECT_R[stor[8]]], inl[:ALLOCATE_STATUS_AFFLICTED_EFFECT_G[stor[8]]], inl[:ALLOCATE_STATUS_AFFLICTED_EFFECT_B[stor[8]]] ; effectIndex, parentIndex, ticks, destR, destG, destB
yield
call SEffe::scriptAllocateParticleEffect, stor[19], stor[28], inl[:ALLOCATE_STATUS_AFFLICTED_EFFECT_TYPE[stor[8]]], 0x14, 0xc8, 0x2, 0x80, 0x1207f00, 0x5 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetEffectTranslucencyModeFlag, stor[19], inl[:ALLOCATE_STATUS_AFFLICTED_EFFECT_TRANSLUCENCY[stor[8]]] ; effectIndex, set
call SEffe::scriptSetRelativeScale, stor[19], 0xffffffff, 0x200, 0x200, 0x200 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativePosition, stor[19], stor[28], 0x0, 0xfffffc00, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[19], 0x10 ; effectIndex, ticks
yield
call SEffe::scriptAllocateParticleEffect, stor[20], stor[28], 0xfff26, 0x6, 0xc8, 0x0, 0x200, 0xc187f00, 0x18 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetEffectTranslucencyModeFlag, stor[20], inl[:ALLOCATE_STATUS_AFFLICTED_EFFECT_TRANSLUCENCY[stor[8]]] ; effectIndex, set
call SEffe::scriptSetRelativeColour, stor[20], 0xffffffff, inl[:ALLOCATE_STATUS_AFFLICTED_EFFECT_R[stor[8]]], inl[:ALLOCATE_STATUS_AFFLICTED_EFFECT_G[stor[8]]], inl[:ALLOCATE_STATUS_AFFLICTED_EFFECT_B[stor[8]]] ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[20], 0xffffffff, 0xa, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptSetRelativeScale, stor[20], 0xffffffff, 0x200, 0x200, 0x200 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativePosition, stor[20], stor[28], 0x0, 0xfffffc00, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[20], 0xffffffff, 0x6, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
mov 0x8, stor[23] ; source, dest
wait stor[23] ; frames
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x9, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
mov 0x9, stor[23] ; source, dest
wait stor[23] ; frames
deallocate
ALLOCATE_STATUS_AFFLICTED_EFFECT_R:
data 0xdc
data 0x78
data 0x64
data 0x1e
data 0x78
data 0xe8
data 0x10
data 0x0
data 0xf5
ALLOCATE_STATUS_AFFLICTED_EFFECT_G:
data 0xdc
data 0x0
data 0x64
data 0x1e
data 0x78
data 0xe0
data 0x10
data 0x50
data 0xff
ALLOCATE_STATUS_AFFLICTED_EFFECT_B:
data 0xdc
data 0x78
data 0x0
data 0xf0
data 0x0
data 0x88
data 0xd8
data 0x14
data 0xd7
ALLOCATE_STATUS_AFFLICTED_EFFECT_TYPE:
data 0xfff03
data 0xfff2b
data 0xfff2f
data 0xfff33
data 0xfff05
data 0xfff38
data 0xfff26
data 0xfff38
data 0xfff00
ALLOCATE_STATUS_AFFLICTED_EFFECT_TRANSLUCENCY:
data 0x1
data 0x1
data 0x1
data 0x1
data 0x1
data 0x1
data 0x2
data 0x1
data 0x1

data 0x208
data 0x1
data 0x2000008
data 0x102
data 0x2000017
data 0x10c
data 0x2000008
data 0x1
data 0x49
data 0x49

; SUBROUTINE
JMP_bf60_0:
gosub inl[:LABEL_93] ; addr
call Battle::scriptGetBentPos, stor[0], stor[24], stor[25], stor[26] ; bentIndex, x, y, z
call Battle::scriptSetBattleHudVisibility, 0x0 ; visible
gosub inl[:LOAD_D_ATTACK_SOUNDS] ; addr
call Battle::scriptGetBentStat, stor[0], DRAGOON_ATTACK_DEFF, inl[:JMP_bf60_0_DEFF]
call Battle::scriptLoadDragoonDeffSync, inl[:JMP_bf60_0_DEFF], stor[0], stor[28], 0x0 ; flagsAndIndex, bentIndex, p2, scriptEntrypoint
yield
call Audio::scriptUnloadSoundFile, 0x6 ; soundType
yield
return

JMP_bf60_0_DEFF:
data 0

; SUBROUTINE
LOAD_D_ATTACK_SOUNDS:
call Battle::scriptGetBentStat, stor[0], DRAGOON_ATTACK_SOUNDS, inl[:LOAD_D_ATTACK_SOUNDS_FILE]
call Audio::scriptLoadMonsterAttackSounds, inl[:LOAD_D_ATTACK_SOUNDS_FILE] ; monsterIndex
LABEL_417:
yield
call Audio::scriptGetLoadedSoundFiles, stor[23] ; flags
jmp_cmp &, 0x20, stor[23], inl[:LABEL_417] ; operand, left, right, addr
return

LOAD_D_ATTACK_SOUNDS_FILE:
data 0

data 0x148
data 0x900de62
data 0x810438
data 0x200001e
data 0x2000018
data 0x2000019
data 0x200001a
data 0xab0138
data 0x0
data 0xa70238
data 0x200001e
data 0x2000008
data 0x148
data 0x900159a
data 0x148
data 0x900ffde
data 0x1a00438
data 0xa08ffd2
data 0x200001e
data 0x200001c
data 0x0
data 0x0
data 0xe80138
data 0x6
data 0x0
data 0x49
data 0x49



ENTRYPOINT_10:
jmp_cmp !=, 0x0, var[57], inl[:LABEL_419] ; operand, left, right, addr
jmp_cmp &, 0x2, stor[7], inl[:LABEL_419] ; operand, left, right, addr
mov stor[32], stor[9] ; source, dest
gosub inl[:LABEL_430] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_419] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[0], GUARD, stor[8] ; bentIndex, statIndex, value
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_420] ; operand, left, right, addr
call Battle::scriptGetBentSlot, stor[0], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
add 0x81, stor[9] ; amount, operand
call Battle::scriptGetBentStat, stor[0], STATUS, stor[8] ; bentIndex, statIndex, value
and 0xff, stor[8] ; right, left
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_423] ; operand, left, right, addr
jmp_cmp &, 0x10, stor[8], inl[:LABEL_423] ; operand, left, right, addr
jmp_cmp >=, stor[8], inl[:LABEL_426[stor[32]]], inl[:LABEL_423] ; operand, left, right, addr
LABEL_419:
consume
LABEL_420:
gosub inl[:LABEL_421] ; addr
call SEffe::scriptSetRelativeRotation, stor[18], stor[18], 0x200, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
mov 0x2, stor[8] ; source, dest
wait stor[8] ; frames
gosub inl[:LABEL_421] ; addr
call SEffe::scriptSetRelativeRotation, stor[18], stor[18], 0x600, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
consume



; SUBROUTINE
LABEL_421:
memcpy 0x3, stor[24], inl[:LABEL_422] ; size, src, dest
call Battle::scriptAllocateRadialGradientEffect, stor[18], 0x3, 0x2 ; effectIndex, count, type
mov 0xfffffd00, stor[8] ; source, dest
mov stor[0], stor[28] ; source, dest
gosub inl[:LABEL_478] ; addr
call SEffe::scriptSetRelativePosition, stor[18], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetGenericEffectValue, stor[18], 0x1, 0x200 ; effectIndex, genericIndex, value
call SEffe::scriptSetGenericEffectValue, stor[18], 0x2, 0x0 ; effectIndex, genericIndex, value
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0xc8, 0x78, 0x8c ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0xc, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0xc, 0x1194, 0x1194, 0x1194 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[18], 0xc ; effectIndex, ticks
memcpy 0x3, inl[:LABEL_422], stor[24] ; size, src, dest
return
LABEL_422:
data 0x0
data 0x0
data 0x0
data 0x211
data 0x380
data 0x700092d
data 0x58
LABEL_423:
jmp_cmp !=, stor[32], 0x1, inl[:LABEL_424] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[0], STATUS, stor[8] ; bentIndex, statIndex, value
jmp_cmp &, 0x2, stor[8], inl[:LABEL_419] ; operand, left, right, addr
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
mov var[128 + stor[8]][4], stor[8] ; source, dest
call Battle::scriptGetBentSlot, stor[0], stor[10], 0x1 ; bentIndex, charOrBentSlot, mode
add 0xb8, stor[10] ; amount, operand
mov stor[8], var[45][stor[10]] ; source, dest
LABEL_424:
call Battle::scriptGetBentStat, stor[0], STATUS, stor[8] ; bentIndex, statIndex, value
and 0xffffff00, stor[8] ; right, left
or inl[:STATUS_AFFLICTION_FLAGS[stor[32]]], stor[8] ; right, left
call Battle::scriptSetBentStat, stor[0], stor[8], STATUS ; bentIndex, value, statIndex
mov var[45][stor[9]], stor[11] ; source, dest
and 0xf, stor[11] ; right, left
mov 0x0, var[45][stor[9]] ; source, dest
or 0x380, var[45][stor[9]] ; right, left
or stor[32], var[45][stor[9]] ; right, left
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
mov stor[0], stor[stor[stor[0], 18], 28] ; source, dest
mov stor[32], stor[stor[stor[0], 18], 31] ; source, dest
mov stor[9], stor[stor[stor[0], 18], 9] ; source, dest
mov 0x1, stor[stor[stor[0], 18], 17] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:LABEL_445] ; scriptIndex, address
gosub inl[:LABEL_88] ; addr
consume

LABEL_426:
data 0x1
data 0x2
data 0x4
data 0x8
data 0x100
data 0x20
data 0x40
data 0x80

; SUBROUTINE
LABEL_427:
mov stor[8], stor[9] ; source, dest
mov 0x0, stor[8] ; source, dest
LABEL_428:
jmp_cmp ==, stor[9], inl[:STATUS_AFFLICTION_FLAGS[stor[8]]], inl[:LABEL_429] ; operand, left, right, addr
incr stor[8] ; operand
jmp_cmp >=, 0x7, stor[8], inl[:LABEL_428] ; operand, left, right, addr
debug96 0x4, 0x8, stor[8] ; ?, ?, ?
mov 0xffffffff, stor[8] ; source, dest
LABEL_429:
return

; SUBROUTINE
LABEL_430:
mov 0x0, stor[8] ; source, dest
call Battle::scriptGetBentSlot, stor[0], stor[11], 0x1 ; bentIndex, charOrBentSlot, mode
add 0x6d, stor[11] ; amount, operand
jmp_cmp &, 0x0, var[45][stor[11]], inl[:LABEL_431] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[0], EQUIPMENT_STATUS_RESIST, stor[10] ; bentIndex, statIndex, value
jmp_cmp !&, inl[:STATUS_AFFLICTION_FLAGS[stor[9]]], stor[10], inl[:LABEL_431] ; operand, left, right, addr
incr stor[8] ; operand
LABEL_431:
return



ENTRYPOINT_11_RENDER_TICK_STATUS:
jmp_cmp !=, 0x0, var[57], inl[:LABEL_433] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[0], STATUS, stor[8] ; bentIndex, statIndex, value
and 0xff, stor[8] ; right, left
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_433] ; operand, left, right, addr
gosub inl[:LABEL_427] ; addr
jmp_cmp >, 0x0, stor[8], inl[:LABEL_435] ; operand, left, right, addr
call Battle::scriptGetBentSlot, stor[0], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
add 0x81, stor[9] ; amount, operand
jmp_cmp &, 0x80, var[45][stor[9]], inl[:LABEL_433] ; operand, left, right, addr
or 0x80, var[45][stor[9]] ; right, left
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
mov stor[0], stor[stor[stor[0], 18], 28] ; source, dest
mov stor[8], stor[stor[stor[0], 18], 31] ; source, dest
mov stor[9], stor[stor[stor[0], 18], 9] ; source, dest
mov 0x1, stor[stor[stor[0], 18], 17] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:LABEL_445] ; scriptIndex, address
jmp_cmp ==, 0x0, var[45][183], inl[:LABEL_434] ; operand, left, right, addr
LABEL_432:
yield
jmp_cmp !=, 0x0, stor[stor[stor[0], 18], 17], inl[:LABEL_432] ; operand, left, right, addr
LABEL_433:
call Battle::scriptGetBentSlot, stor[0], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
mov 0x1, stor[8] ; source, dest
shl stor[9], stor[8] ; right, left
neg stor[8] ; operand
decr stor[8] ; operand
and stor[8], var[45][183] ; right, left
LABEL_434:
consume
LABEL_435:
call Battle::scriptGetBentStat, stor[0], STATUS, stor[8] ; bentIndex, statIndex, value
and 0xffffff00, stor[8] ; right, left
call Battle::scriptSetBentStat, stor[0], stor[8], STATUS ; bentIndex, value, statIndex
jmp inl[:LABEL_433] ; addr



; SUBROUTINE
LABEL_436:
mov 0x0, stor[8] ; source, dest
LABEL_437:
mov var[32][stor[8]], stor[28] ; source, dest
call Battle::scriptGetBentSlot, stor[28], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
add 0x81, stor[9] ; amount, operand
gosub inl[:LABEL_438] ; addr
incr stor[8] ; operand
jmp_cmp <, stor[8], var[33], inl[:LABEL_437] ; operand, left, right, addr
return

; SUBROUTINE
LABEL_438:
jmp_cmp !=, 0x0, var[57], inl[:LABEL_440] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[28], STATUS, stor[18] ; bentIndex, statIndex, value
and 0xff, stor[18] ; right, left
jmp_cmp ==, 0x0, stor[18], inl[:LABEL_440] ; operand, left, right, addr
jmp_cmp &, 0x1, stor[18], inl[:LABEL_439] ; operand, left, right, addr
jmp_cmp &, 0x40, stor[stor[stor[0], 28], 7], inl[:LABEL_440] ; operand, left, right, addr
LABEL_439:
gosub inl[:LABEL_441] ; addr
LABEL_440:
return

; SUBROUTINE
LABEL_441:
mov var[45][stor[9]], stor[31] ; source, dest
and 0xf, stor[31] ; right, left
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
mov stor[28], stor[stor[stor[0], 18], 28] ; source, dest
mov stor[31], stor[stor[stor[0], 18], 31] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:LABEL_442] ; scriptIndex, address
return

; FORK RE-ENTRY
LABEL_442:
call Battle::scriptGetBentSlot, stor[28], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
mov 0x1, stor[8] ; source, dest
shl stor[9], stor[8] ; right, left
or stor[8], var[45][183] ; right, left
fork_reenter stor[28], 0xb, stor[31] ; index, entrypoint, p2
gosub inl[:LABEL_17] ; addr
deallocate

; SUBROUTINE TABLE
LABEL_443:
rel :JMP_ad94_0
rel :JMP_ad94_1
rel :JMP_ad94_2
rel :JMP_ad94_3
rel :JMP_ad94_4
rel :JMP_ad94_5
rel :JMP_ad94_6
rel :JMP_ad94_7

; SUBROUTINE TABLE
LABEL_444:
rel :JMP_adb4_0
rel :JMP_adb4_1
rel :JMP_adb4_2
rel :JMP_adb4_3
rel :JMP_adb4_4
rel :JMP_adb4_5
rel :JMP_adb4_6
rel :JMP_adb4_7

; FORK RE-ENTRY
LABEL_445:
call Battle::scriptGetBentStat2, stor[28], CURRENT_HP, stor[8] ; bentIndex, statIndex, value
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_451] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[28], STATUS, stor[8] ; bentIndex, statIndex, value
jmp_cmp &, 0x1, stor[8], inl[:LABEL_446] ; operand, left, right, addr
jmp_cmp &, 0x40, stor[stor[stor[0], 28], 7], inl[:LABEL_451] ; operand, left, right, addr
LABEL_446:
gosub_table stor[31], inl[:LABEL_444] ; index, table
LABEL_447:
call Battle::scriptGetBentSlot, stor[28], stor[8], 0x1 ; bentIndex, charOrBentSlot, mode
add 0xb8, stor[8] ; amount, operand
mov var[45][stor[8]], stor[8] ; source, dest
jmp_cmp >, 0x0, stor[8], inl[:LABEL_448] ; operand, left, right, addr
jmp_cmp &, 0x40, stor[stor[stor[0], 8], 7], inl[:LABEL_452] ; operand, left, right, addr
LABEL_448:
mov var[45][stor[9]], stor[11] ; source, dest
jmp_cmp !&, 0x80, stor[11], inl[:LABEL_450] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[28], STATUS, stor[8] ; bentIndex, statIndex, value
jmp_cmp &, 0x1, stor[8], inl[:LABEL_449] ; operand, left, right, addr
jmp_cmp &, 0x40, stor[stor[stor[0], 28], 7], inl[:LABEL_450] ; operand, left, right, addr
LABEL_449:
mov stor[11], stor[13] ; source, dest
and 0xf, stor[13] ; right, left
jmp_cmp !=, stor[13], stor[31], inl[:LABEL_451] ; operand, left, right, addr
mov stor[11], stor[13] ; source, dest
and 0xf00, stor[13] ; right, left
jmp_cmp ==, 0xf00, stor[13], inl[:LABEL_452] ; operand, left, right, addr
gosub_table stor[31], inl[:LABEL_443] ; index, table
yield
jmp inl[:LABEL_447] ; addr
LABEL_450:
jmp_cmp ==, 0x0, var[45][stor[9]], inl[:LABEL_452] ; operand, left, right, addr
LABEL_451:
mov 0x0, stor[17] ; source, dest
yield
yield
yield
deallocate
LABEL_452:
mov 0x0, var[45][stor[9]] ; source, dest
call Battle::scriptGetBentStat, stor[28], STATUS, stor[8] ; bentIndex, statIndex, value
and 0xffffff00, stor[8] ; right, left
call Battle::scriptSetBentStat, stor[28], stor[8], STATUS ; bentIndex, value, statIndex
mov 0x1, var[45][225] ; source, dest
gosub_table stor[31], inl[:LABEL_453] ; index, table
mov 0x0, var[45][225] ; source, dest
deallocate

; SUBROUTINE TABLE
LABEL_453:
rel :JMP_afcc_0
rel :JMP_afcc_1
rel :JMP_afcc_2
rel :JMP_afcc_3
rel :JMP_afcc_4
rel :JMP_afcc_5
rel :JMP_afcc_6
rel :JMP_afcc_7

; SUBROUTINE
JMP_afcc_0:
gosub inl[:LABEL_456] ; addr
jmp_cmp &, 0x2, var[45][245], inl[:LABEL_454] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[28], 0x9 ; bentIndex, animIndex
gosub inl[:WAIT_FOR_BENT_ANIMATION_TO_FINISH] ; addr
LABEL_454:
call Battle::scriptSetBentDead, stor[28], 0x0 ; bentIndex, dead
gosub inl[:SET_BENT_ANIMATION] ; addr
gosub inl[:LABEL_459] ; addr
gosub inl[:LABEL_458] ; addr
return

; SUBROUTINE
JMP_afcc_1:
gosub inl[:LABEL_457] ; addr
gosub inl[:LABEL_460] ; addr
call SEffe::scriptSetRelativeColour, stor[19], 0xffffffff, 0x40, 0x0, 0x3c ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetRelativeColour, stor[20], 0xffffffff, 0x40, 0x0, 0x3c ; bobjIndex1, bobjIndex2, r, g, b
gosub inl[:LABEL_459] ; addr
gosub inl[:LABEL_458] ; addr
return

; SUBROUTINE
JMP_afcc_2:
gosub inl[:LABEL_457] ; addr
gosub inl[:LABEL_460] ; addr
call SEffe::scriptSetRelativeColour, stor[19], 0xffffffff, 0x3c, 0x3c, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetRelativeColour, stor[20], 0xffffffff, 0x3c, 0x3c, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
gosub inl[:LABEL_459] ; addr
gosub inl[:LABEL_458] ; addr
return

; SUBROUTINE
JMP_afcc_3:
gosub inl[:LABEL_457] ; addr
gosub inl[:LABEL_460] ; addr
call SEffe::scriptSetRelativeColour, stor[19], 0xffffffff, 0x14, 0x14, 0x46 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetRelativeColour, stor[20], 0xffffffff, 0x14, 0x14, 0x46 ; bobjIndex1, bobjIndex2, r, g, b
gosub inl[:LABEL_459] ; addr
gosub inl[:LABEL_458] ; addr
return

; SUBROUTINE
JMP_afcc_4:
jmp_cmp &, 0x2, var[45][245], inl[:LABEL_455] ; operand, left, right, addr
jmp_cmp &, 0x40, stor[stor[stor[0], 28], 7], inl[:LABEL_455] ; operand, left, right, addr
call Battle::scriptGetLoadingBentAnimationIndex, stor[28], stor[8] ; bentIndex, animationIndex
jmp_cmp ==, 0x9, stor[8], inl[:LABEL_455] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[28], 0x9 ; bentIndex, animIndex
mov 0x6, stor[8] ; source, dest
wait stor[8] ; frames
gosub inl[:WAIT_FOR_BENT_ANIMATION_TO_FINISH] ; addr
LABEL_455:
gosub inl[:SET_BENT_ANIMATION] ; addr
gosub inl[:LABEL_457] ; addr
gosub inl[:LABEL_459] ; addr
gosub inl[:LABEL_458] ; addr
return

; SUBROUTINE
JMP_afcc_5:
gosub inl[:LABEL_457] ; addr
gosub inl[:LABEL_460] ; addr
call SEffe::scriptSetRelativeColour, stor[19], 0xffffffff, 0x1e, 0x1e, 0x1e ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetRelativeColour, stor[20], 0xffffffff, 0x1e, 0x1e, 0x1e ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptSetEffectTranslucencyModeFlag, stor[19], 0x2 ; effectIndex, set
call SEffe::scriptSetEffectTranslucencyModeFlag, stor[20], 0x2 ; effectIndex, set
gosub inl[:LABEL_459] ; addr
gosub inl[:LABEL_458] ; addr
return

; SUBROUTINE
JMP_afcc_6:
gosub inl[:LABEL_459] ; addr
gosub inl[:LABEL_458] ; addr
return

; SUBROUTINE
JMP_afcc_7:
gosub inl[:LABEL_457] ; addr
gosub inl[:LABEL_459] ; addr
gosub inl[:LABEL_458] ; addr
return

; SUBROUTINE
LABEL_456:
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0x8, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[18], 0x8 ; effectIndex, ticks
return

; SUBROUTINE
LABEL_457:
deallocate_other stor[19] ; index
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0xa, 0x1000, 0x1000, 0x1000 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0xa, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddLifespanAttachment, stor[18], 0xa ; effectIndex, ticks
yield
return

; SUBROUTINE
LABEL_458:
call SEffe::scriptAllocateParticleEffect, stor[18], 0xffffffff, 0xfff3d, 0xc, 0x200, 0x2, 0x100, 0x4127f00, 0x29 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
mov 0xfffffc00, stor[8] ; source, dest
gosub inl[:LABEL_478] ; addr
call SEffe::scriptSetRelativePosition, stor[18], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x100, 0x100, 0x100 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeRotation, stor[18], stor[28], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetGenericEffectValue, stor[18], 0x0, 0x1 ; effectIndex, genericIndex, value
call SEffe::scriptAddLifespanAttachment, stor[18], 0x20 ; effectIndex, ticks
mov 0x20, stor[23] ; source, dest
wait stor[23] ; frames
return

; SUBROUTINE
LABEL_459:
mov 0x5, stor[23] ; source, dest
wait stor[23] ; frames
call Audio::scriptPlaySound, 0x0, 0x2d, 0x0, 0x0, 0x0, 0x0 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
call SEffe::scriptAllocateParticleEffect, stor[18], 0xffffffff, 0xfff2d, 0x10, 0x80, 0x2, 0x800, 0x6107f00, 0x4 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
mov 0xfffffd00, stor[8] ; source, dest
gosub inl[:LABEL_478] ; addr
call SEffe::scriptSetRelativePosition, stor[18], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x200, 0x200, 0x200 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeRotation, stor[18], stor[28], 0x100, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetGenericEffectValue, stor[18], 0x0, 0x1 ; effectIndex, genericIndex, value
call SEffe::scriptAddLifespanAttachment, stor[18], 0x28 ; effectIndex, ticks
mov 0x6, stor[23] ; source, dest
wait stor[23] ; frames
return

; SUBROUTINE
LABEL_460:
call SEffe::scriptAllocateParticleEffect, stor[19], stor[28], 0xfff26, 0x8, 0x200, 0x1, 0x200, 0x4187f00, 0x36 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
mov 0xfffffd00, stor[8] ; source, dest
gosub inl[:LABEL_478] ; addr
call SEffe::scriptSetRelativePosition, stor[19], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[19], 0xffffffff, 0xfa, 0xfa, 0xfa ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetGenericEffectValue, stor[19], 0x0, 0x1 ; effectIndex, genericIndex, value
call SEffe::scriptAddLifespanAttachment, stor[19], 0x20 ; effectIndex, ticks
call SEffe::scriptAllocateParticleEffect, stor[20], stor[28], 0xfff26, 0x8, 0x200, 0x1, 0x200, 0x4187f00, 0x36 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
mov 0xfffffd00, stor[8] ; source, dest
gosub inl[:LABEL_478] ; addr
call SEffe::scriptSetRelativePosition, stor[20], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[20], 0xffffffff, 0x96, 0x96, 0x96 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetGenericEffectValue, stor[20], 0x0, 0x1 ; effectIndex, genericIndex, value
call SEffe::scriptAddLifespanAttachment, stor[20], 0x20 ; effectIndex, ticks
return

; SUBROUTINE
JMP_adb4_0:
call Battle::scriptSetBentDead, stor[28], 0x1 ; bentIndex, dead
call Battle::scriptGetLoadingBentAnimationIndex, stor[28], stor[8] ; bentIndex, animationIndex
jmp_cmp ==, 0xe, stor[8], inl[:LABEL_461] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[28], 0xe ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[28], 0x0 ; bentIndex, loop
LABEL_461:
call SEffe::allocateDeffTmd, stor[18], 0xfff25 ; effectIndex, flags
call SEffe::scriptSetRelativePosition, stor[18], stor[28], 0x0, 0xfffffe00, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[18], 0xffffffff, 0x4, 0x1000, 0x1000, 0x1000 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddRotationScalerAttachment, stor[18], 0xffffffff, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0 ; effectIndex, unused, velocityX, velocityY, velocityZ, accelerationX, accelerationY, accelerationZ
call SEffe::scriptSetEffectLightingDisableFlag, stor[18], 0x1 ; effectIndex, set
mov 0x4, stor[23] ; source, dest
wait stor[23] ; frames
mov 0x0, stor[17] ; source, dest

; SUBROUTINE
JMP_ad94_0:
return

; SUBROUTINE
JMP_adb4_1:
gosub inl[:LABEL_477] ; addr
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0xa, 0x1e, 0x0, 0x1e ; effectIndex, parentIndex, ticks, destR, destG, destB
yield
call SEffe::scriptAllocateParticleEffect, stor[19], stor[28], 0xfff2b, 0x5, 0xc8, 0x11, 0x0, 0x5208000, 0x14 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativeRotation, stor[19], 0xffffffff, 0xa00, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
mov 0xfffffc00, stor[8] ; source, dest
gosub inl[:LABEL_478] ; addr
call SEffe::scriptSetRelativePosition, stor[19], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[19], 0xffffffff, 0xfa, 0xfa, 0xfa ; bobjIndex1, bobjIndex2, x, y, z
yield
mov 0x0, stor[17] ; source, dest
return

; SUBROUTINE
JMP_ad94_1:
gosub inl[:LABEL_475] ; addr
return

; SUBROUTINE
JMP_adb4_2:
gosub inl[:LABEL_477] ; addr
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0xa, 0x19, 0x19, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
yield
call SEffe::scriptAllocateParticleEffect, stor[19], stor[28], 0xfff2f, 0x5, 0xc8, 0x11, 0x0, 0x5208000, 0x14 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativeRotation, stor[19], 0xffffffff, 0xa00, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
mov 0xfffffc00, stor[8] ; source, dest
gosub inl[:LABEL_478] ; addr
call SEffe::scriptSetRelativePosition, stor[19], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[19], 0xffffffff, 0x180, 0x180, 0x180 ; bobjIndex1, bobjIndex2, x, y, z
yield
mov 0x0, stor[17] ; source, dest
return

; SUBROUTINE
JMP_ad94_2:
gosub inl[:LABEL_475] ; addr
return

; SUBROUTINE
JMP_adb4_3:
gosub inl[:LABEL_477] ; addr
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0xa, 0x5, 0x5, 0x28 ; effectIndex, parentIndex, ticks, destR, destG, destB
yield
call SEffe::scriptAllocateParticleEffect, stor[19], stor[28], 0xfff33, 0x5, 0xc8, 0x11, 0x0, 0x5208000, 0x14 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativeRotation, stor[19], 0xffffffff, 0xa00, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
mov 0xfffffc00, stor[8] ; source, dest
gosub inl[:LABEL_478] ; addr
call SEffe::scriptSetRelativePosition, stor[19], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[19], 0xffffffff, 0x180, 0x180, 0x180 ; bobjIndex1, bobjIndex2, x, y, z
yield
mov 0x0, stor[17] ; source, dest
return

; SUBROUTINE
JMP_ad94_3:
jmp_cmp !&, 0x1, var[2], inl[:LABEL_462] ; operand, left, right, addr
call Battle::scriptGetBentPos, stor[28], stor[24], stor[25], stor[26] ; bentIndex, x, y, z
add 0x14, stor[26] ; amount, operand
call Battle::scriptSetBentPos, stor[28], stor[24], stor[25], stor[26] ; bentIndex, x, y, z
jmp inl[:LABEL_463] ; addr
LABEL_462:
call Battle::scriptGetBentPos, stor[28], stor[24], stor[25], stor[26] ; bentIndex, x, y, z
sub 0x14, stor[26] ; amount, operand
call Battle::scriptSetBentPos, stor[28], stor[24], stor[25], stor[26] ; bentIndex, x, y, z
LABEL_463:
return

; SUBROUTINE
JMP_adb4_4:
gosub inl[:LABEL_477] ; addr
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0xa, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
yield
call SEffe::scriptAllocateParticleEffect, stor[19], stor[28], 0xfff05, 0x8, 0x78, 0x20, 0x0, 0x0, 0x10 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativeScale, stor[19], 0xffffffff, 0x200, 0x200, 0x200 ; bobjIndex1, bobjIndex2, x, y, z
mov 0xfffffd00, stor[8] ; source, dest
gosub inl[:LABEL_478] ; addr
call SEffe::scriptSetRelativePosition, stor[19], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call Battle::scriptSetBentStat, stor[28], 0x0, GUARD ; bentIndex, value, statIndex
yield
mov 0x0, stor[17] ; source, dest
return

; SUBROUTINE
JMP_ad94_4:
gosub inl[:LABEL_475] ; addr
return

; SUBROUTINE
JMP_adb4_5:
gosub inl[:LABEL_477] ; addr
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0xa, 0x1e, 0x1e, 0x1e ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptSetEffectTranslucencyModeFlag, stor[18], 0x2 ; effectIndex, set
yield
call SEffe::scriptAllocateParticleEffect, stor[19], stor[28], 0xfff26, 0x5, 0xc8, 0x11, 0x0, 0x4208000, 0x14 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
mov 0xfffffc00, stor[8] ; source, dest
gosub inl[:LABEL_478] ; addr
call SEffe::scriptSetRelativePosition, stor[19], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[19], 0xffffffff, 0xfa, 0xfa, 0xfa ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[19], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddConstantColourScalerAttachment, stor[19], 0xffffffff, 0xa, 0x1e, 0x1e, 0x1e ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptSetEffectTranslucencyModeFlag, stor[19], 0x2 ; effectIndex, set
yield
mov 0x0, stor[17] ; source, dest
return

; SUBROUTINE
JMP_ad94_5:
gosub inl[:LABEL_475] ; addr
return

; SUBROUTINE
JMP_adb4_6:
yield
mov 0x0, stor[17] ; source, dest
return

; SUBROUTINE
JMP_ad94_6:
return

; SUBROUTINE
JMP_adb4_7:
gosub inl[:LABEL_477] ; addr
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0xa, 0x0, 0x14, 0x5 ; effectIndex, parentIndex, ticks, destR, destG, destB
yield
call SEffe::scriptAllocateParticleEffect, stor[19], stor[28], 0xfff38, 0x5, 0xc8, 0x1, 0x60, 0x0, 0x14 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativeRotation, stor[19], 0xffffffff, 0xa00, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
mov 0xfffffc00, stor[8] ; source, dest
gosub inl[:LABEL_478] ; addr
call SEffe::scriptSetRelativePosition, stor[19], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[19], 0xffffffff, 0x300, 0x300, 0x300 ; bobjIndex1, bobjIndex2, x, y, z
yield
mov 0x0, stor[17] ; source, dest
return

; SUBROUTINE
JMP_ad94_7:
jmp_cmp !&, 0x40, var[45][stor[9]], inl[:LABEL_465] ; operand, left, right, addr
call Battle::scriptGetBentSlot, stor[28], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
mov 0x1, stor[10] ; source, dest
shl stor[8], stor[10] ; right, left
call Battle::scriptGetBentStat2, stor[28], MAX_HP, stor[8] ; bentIndex, statIndex, value
div 0xa, stor[8] ; amount, operand
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_464] ; operand, left, right, addr
incr stor[8] ; operand
LABEL_464:
or stor[10], var[45][188] ; right, left
fork_reenter stor[28], 0x2, stor[8] ; index, entrypoint, p2
xor 0x40, var[45][stor[9]] ; right, left
LABEL_465:
return



; SUBROUTINE
LABEL_466:
call Battle::scriptGetBentSlot, stor[0], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
add 129, stor[9] ; amount, operand
jmp_cmp !&, 0x80, var[45][stor[9]], inl[:LABEL_467] ; operand, left, right, addr
or 0x40, var[45][stor[9]] ; right, left
LABEL_467:
return



; SUBROUTINE
CLEAR_MY_STATUS:
call Battle::scriptGetBentSlot, stor[0], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
add 129, stor[9] ; amount, operand
mov 0x0, var[45][stor[9]] ; source, dest
call Battle::scriptGetBentStat, stor[0], STATUS, stor[8] ; bentIndex, statIndex, value
and 0xffffff00, stor[8] ; right, left
call Battle::scriptSetBentStat, stor[0], stor[8], STATUS ; bentIndex, value, statIndex
return



; SUBROUTINE
LABEL_469:
; store my battle entity slot in s9
call Battle::scriptGetBentSlot, stor[0], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode

; if unknown flag 0x80 on my battle var status is not set
add 129, stor[9] ; amount, operand
jmp_cmp !&, 0x80, var[45][stor[9]], inl[:LABEL_470] ; operand, left, right, addr

; clear flag 0x80 on my battle var status
and 0xffffff7f, var[45][stor[9]] ; right, left

; set flag 0x10000 on my battle var status
or 0x10000, var[45][stor[9]] ; right, left

LABEL_470:
return



; SUBROUTINE
LABEL_471:
mov 0x0, stor[8] ; source, dest
LABEL_472:
mov var[32][stor[8]], stor[10] ; s10 = allbent[s8]
call Battle::scriptGetBentSlot, stor[10], stor[9], 0x0 ; s9 = bent[s10].slot
add 129, stor[9] ; amount, operand
jmp_cmp !&, 0x80, var[45][stor[9]], inl[:LABEL_473] ; operand, left, right, addr
and 0xffffff7f, var[45][stor[9]] ; right, left
or 0x10000, var[45][stor[9]] ; right, left
LABEL_473:
incr stor[8] ; operand
jmp_cmp <, stor[8], var[33], inl[:LABEL_472] ; operand, left, right, addr
return



; SUBROUTINE
LABEL_474:
call Battle::scriptGetBentSlot, stor[0], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
add 129, stor[9] ; amount, operand
return



; SUBROUTINE
LABEL_475:
jmp_cmp !&, var[45][stor[9]], 0x40, inl[:LABEL_476] ; operand, left, right, addr
sub 0x40, var[45][stor[9]] ; amount, operand
sub 0x100, var[45][stor[9]] ; amount, operand
and 0xf00, stor[11] ; right, left
jmp_cmp !=, 0x0, stor[11], inl[:LABEL_476] ; operand, left, right, addr
mov 0x0, var[45][stor[9]] ; source, dest
LABEL_476:
return

; SUBROUTINE
LABEL_477:
call Battle::allocateBillboardSpriteEffect, stor[18], 0xfff26 ; effectIndex, flags
mov 0xfffffc00, stor[8] ; source, dest
gosub inl[:LABEL_478] ; addr
call SEffe::scriptSetRelativePosition, stor[18], 0xffffffff, stor[24], stor[25], stor[26] ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x3e8, 0x3e8, 0x3e8 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddRotationScalerAttachment, stor[18], stor[18], 0x1e, 0x1e, 0x1e, 0x0, 0x0, 0x0 ; effectIndex, unused, velocityX, velocityY, velocityZ, accelerationX, accelerationY, accelerationZ
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
return

; SUBROUTINE
LABEL_478:
call Battle::scriptGetBentPos, stor[28], stor[24], stor[25], stor[26] ; bentIndex, x, y, z
add stor[8], stor[25] ; amount, operand
return

; SUBROUTINE TABLE
; Indexed by character ID
;TODO addition handler for each character, need to externalize this to support new chars
LABEL_479:
rel :JMP_bf38_0
rel :JMP_bf38_0
rel :JMP_bf60_2
rel :JMP_bf38_0
rel :JMP_bf38_0
rel :JMP_bf38_0
rel :JMP_bf38_0
rel :JMP_bf38_0
rel :JMP_bf60_2
rel :JMP_bf38_0

; SUBROUTINE TABLE
; Indexed by character ID
;TODO dragoon addition handler for each character, need to externalize this to support new chars
LABEL_480:
rel :JMP_bf60_0
rel :JMP_bf60_0
rel :JMP_bf60_2
rel :JMP_bf60_0
rel :JMP_bf60_0
rel :JMP_bf60_0
rel :JMP_bf60_0
rel :JMP_bf60_0
rel :JMP_bf60_2
rel :JMP_bf60_0

data 0xfffff98c
data 0xfffff98c
data 0xfffff9a6
data 0xfffff98c
data 0xfffff98c
data 0xfffff98c
data 0xfffff98c
data 0xfffff98c
data 0xfffff9a6
data 0xfffff98c



ENTRYPOINT_0_MAIN:
mov 0x0, var[45][120] ; source, dest

; set my char loading to 1
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x1 ; bentIndex, charOrBentSlot, mode
add 109, stor[8] ; amount, operand
mov 0x1, var[45][stor[8]] ; source, dest

gosub inl[:INIT_PLAYER] ; addr
gosub inl[:HANDLE_STATUS_CONDITIONS] ; addr

; set my char loading to 0
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x1 ; bentIndex, charOrBentSlot, mode
add 109, stor[8] ; amount, operand
mov 0x0, var[45][stor[8]] ; source, dest

MAIN_LOOP:
; wait until it's my turn
wait_cmp &, 0x8, stor[7] ; operator, left, right

LABEL_482:
yield
jmp_cmp !=, 0x0, var[45][183], inl[:LABEL_482] ; processing status afflictions
jmp_cmp &, 0x1, var[45][245], inl[:LABEL_482] ; operand, left, right, addr

jmp_cmp !&, 0x2, var[45][77], inl[:LABEL_483] ; unknown run away flag 0x2 not set
jmp inl[:LABEL_488] ; addr
LABEL_483:

gosub inl[:HANDLE_DEATH_AFTER_VICTORY] ; addr

; sets scriptState_800c6914 to me
mov stor[0], var[80] ; source, dest

; start the sequence and fade its volume back in to the expected amount
mov var[45][118], stor[8] ; source, dest
call Audio::scriptStartSequenceAndChangeVolumeOverTime, 0xa, stor[8] ; fadeTime, volume

; returns s8, 0 = alive, 1 = dead
gosub inl[:START_TURN] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_488] ; if dead

gosub inl[:IS_DRAGOON] ; addr
jmp_cmp !=, 0x0, stor[31], inl[:MAIN_LOOP_SKIP_STATUS_AFFLICTION] ; operand, left, right, addr

gosub inl[:LABEL_466] ; addr
yield
yield

gosub inl[:LABEL_491] ; wait for var[45][225] to be zero

jmp_cmp !&, 0x40, stor[7], inl[:LABEL_484] ; not dead
mov 0xf, stor[30] ; source, dest
jmp inl[:MAIN_LOOP_SKIP_DRAGOON] ; addr
LABEL_484:

; apply status affliction action
call Battle::scriptGetBentSlot, stor[0], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode
add 0x81, stor[9] ; amount, operand
mov var[45][stor[9]], stor[8] ; source, dest
jmp_cmp !&, 0x80, stor[8], inl[:MAIN_LOOP_SKIP_STATUS_AFFLICTION] ; operand, left, right, addr
and 0x7, stor[8] ; mask status afflictions
mov inl[:STATUS_AFFLICTION_ACTION[stor[8]]], stor[30] ; s30 = action for current status affliction

jmp_cmp ==, 0x0, stor[30], inl[:MAIN_LOOP_SKIP_STATUS_AFFLICTION] ; no action for current status affliction
gosub inl[:RUN_STATUS_AFFLICTION_ACTION] ; addr
jmp inl[:MAIN_LOOP_SKIP_TURN] ; addr
; ---

MAIN_LOOP_SKIP_STATUS_AFFLICTION:

gosub inl[:HANDLE_BATTLE_HUD] ; addr

MAIN_LOOP_SKIP_TURN:

gosub inl[:IS_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[31], inl[:MAIN_LOOP_SKIP_DRAGOON] ; operand, left, right, addr

jmp_cmp ==, 0x2, var[45][242], inl[:MAIN_LOOP_SKIP_DRAGOON] ; operand, left, right, addr

; tick dragoon sp
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x1 ; bentIndex, charOrBentSlot, mode
add 69, stor[8] ; amount, operand
decr var[45][stor[8]] ; decrease dragoon turns remaining
mov var[45][stor[8]], stor[9] ; source, dest
call Battle::scriptGiveSp, stor[0], 0x0, stor[10] ; s10 = current sp
div 100, stor[10] ; s10 = dragoon turns remaining
jmp_cmp ==, stor[9], stor[10], inl[:MAIN_LOOP_SKIP_DRAGOON] ; operand, left, right, addr
call Battle::scriptConsumeSp, stor[0], 0x1, 100 ; consume 100 sp
jmp_cmp !=, 0x0, var[45][stor[8]], inl[:MAIN_LOOP_SKIP_DRAGOON] ; dragoon turns remaining
gosub inl[:LABEL_26] ; addr
mov stor[0], stor[30] ; source, dest
gosub inl[:TRANSFORM_OUT_OF_DRAGOON] ; addr
and 0xfffffffe, var[45][245] ; right, left

MAIN_LOOP_SKIP_DRAGOON:
gosub inl[:LABEL_474] ; addr
call Battle::scriptSetBentRotationY, stor[0], 0x400 ; bentIndex, y

LABEL_488:
gosub inl[:LABEL_26] ; addr
gosub inl[:WAIT_FOR_FLOATING_NUMBERS_TO_DISAPPEAR] ; addr

jmp_cmp !=, 0x0, var[51], inl[:MAIN_LOOP_SKIP_CLEAR_ALL_MONSTER_FORCED_TURNS] ; at least one living player
jmp_cmp ==, 0x0, var[53], inl[:MAIN_LOOP_SKIP_CLEAR_ALL_MONSTER_FORCED_TURNS] ; all monsters dead

mov var[53], stor[8] ; alive monster count
mov 0x0, stor[9] ; loop counter, monster bent slot

MAIN_LOOP_CLEAR_ALL_MONSTER_FORCED_TURNS:
mov var[52][stor[9]], stor[28] ; s28 = monster bent s9 index
and 0xffffffdf, stor[stor[stor[0], 28], 7] ; clear forced turn flag
incr stor[9] ; operand
jmp_cmp >, stor[8], stor[9], inl[:MAIN_LOOP_CLEAR_ALL_MONSTER_FORCED_TURNS] ; operand, left, right, addr

yield
MAIN_LOOP_SKIP_CLEAR_ALL_MONSTER_FORCED_TURNS:
and 0xfffffff7, stor[7] ; clear "my turn" flag
gosub inl[:HANDLE_DEATH_AFTER_VICTORY] ; addr
call Battle::scriptFinishBentTurn, stor[0] ; bentIndex
jmp inl[:MAIN_LOOP] ; addr



; SUBROUTINE
LABEL_491:
yield
jmp_cmp !=, 0x0, var[45][225], inl[:LABEL_491] ; operand, left, right, addr
return



; 0 means no action
STATUS_AFFLICTION_ACTION:
data 0xf  ; petrified
data 0x11 ; bewitched
data 0x12 ; confused
data 0x0  ; fearful
data 0xf  ; stunned
data 0x0  ; weapon blocked
data 0x0  ; dispirited
data 0x0  ; poisoned



; SUBROUTINE
; @param int s30 status affliction action
RUN_STATUS_AFFLICTION_ACTION:
call Battle::scriptSetBattleHudVisibility, 0x0 ; visible
gosub_table stor[30], inl[:ACTION_HANDLERS] ; index, table
return



; SUBROUTINE
HANDLE_BATTLE_HUD:
call Battle::scriptSetBattleHudVisibility, 0x1 ; visible
LABEL_495:
gosub inl[:LABEL_63] ; addr
gosub inl[:IS_DRAGOON] ; s31 = is dragoon
call Battle::scriptSetUpAndHandleCombatMenu, reg[0] ; selectedAction
yield

mov 9, stor[30] ; default to no-op

;TODO maybe rework this, but maybe it's fine
;TODO new actions can be done in code instead of here?
jmp_cmp !=, reg[0], id[lod:attack], inl[:NOT_ACTION_ATTACK]
mov 3, stor[30]
NOT_ACTION_ATTACK:
jmp_cmp !=, reg[0], id[lod:guard], inl[:NOT_ACTION_GUARD]
mov 0, stor[30]
NOT_ACTION_GUARD:
jmp_cmp !=, reg[0], id[lod:items], inl[:NOT_ACTION_ITEMS]
mov 4, stor[30]
NOT_ACTION_ITEMS:
jmp_cmp !=, reg[0], id[lod:spells], inl[:NOT_ACTION_SPELLS]
mov 2, stor[30]
NOT_ACTION_SPELLS:
jmp_cmp !=, reg[0], id[lod:escape], inl[:NOT_ACTION_ESCAPE]
mov 5, stor[30]
NOT_ACTION_ESCAPE:
jmp_cmp !=, reg[0], id[lod:transform], inl[:NOT_ACTION_TRANSFORM]
mov 1, stor[30]
NOT_ACTION_TRANSFORM:
jmp_cmp !=, reg[0], id[lod:special], inl[:NOT_ACTION_SPECIAL]
mov 6, stor[30]
NOT_ACTION_SPECIAL:
jmp_cmp !=, reg[0], id[lod:d_attack], inl[:NOT_ACTION_D_ATTACK]
mov 8, stor[30]
NOT_ACTION_D_ATTACK:

gosub_table stor[30], inl[:ACTION_HANDLERS] ; index, table
gosub inl[:LABEL_515] ; addr
jmp_cmp !=, 0x0, var[45][253], inl[:LABEL_495] ; operand, left, right, addr
call Battle::scriptSetBattleHudVisibility, 0x0 ; visible
return



; SUBROUTINE TABLE
ACTION_HANDLERS:
rel :ACTION_GUARD ; guard
rel :ACTION_TRANSFORM ; transform
rel :ACTION_DRAGOON_MAGIC ; d-magic
rel :ACTION_ATTACK ; attack
rel :ACTION_USE_ITEM ; item
rel :ACTION_RUN_AWAY ; run
rel :ACTION_SPECIAL ; special
rel :ACTION_NOOP ; ? (no-op)
rel :ACTION_DRAGOON_ATTACK ; d-attack
rel :ACTION_NOOP ; no-op
rel :ACTION_NOOP ; no-op
rel :ACTION_NOOP ; no-op
rel :ACTION_NOOP ; no-op
rel :ACTION_NOOP ; no-op
rel :ACTION_NOOP ; no-op
rel :JMP_c400_15 ; no-op
rel :ACTION_NOOP ; no-op
rel :ACTION_ATTACK_ALLY ; attacks another character
rel :ACTION_CONFUSED ; guards, runs, or calls ACTION_ATTACK_ALLY
rel :ACTION_NOOP ; no-op
rel :ACTION_NOOP ; no-op
rel :ACTION_NOOP ; no-op
rel :ACTION_NOOP ; no-op
rel :ACTION_NOOP ; no-op



; SUBROUTINE
LABEL_515:
jmp_cmp ==, 0x0, var[45][243], inl[:LABEL_517] ; operand, left, right, addr
jmp_cmp ==, 0x0, var[45][253], inl[:LABEL_517] ; operand, left, right, addr
jmp_cmp !=, 0x2, var[45][242], inl[:LABEL_516] ; operand, left, right, addr
jmp_cmp ==, 0x3, var[45][243], inl[:LABEL_517] ; operand, left, right, addr
LABEL_516:
decr var[45][243] ; operand
LABEL_517:
return

; SUBROUTINE
JMP_c400_15:
return

; SUBROUTINE
ACTION_NOOP:
return

GUARD_HEAL_PERCENT:
data 0

; SUBROUTINE
ACTION_GUARD:
mov 0x0, stor[8] ; source, dest
mov stor[0], stor[28] ; source, dest
gosub inl[:ALLOCATE_GUARD_OR_ON_DAMAGE_RECOVER_EFFECT] ; addr
call Battle::scriptSetBentStat, stor[0], 0x1, GUARD ; bentIndex, value, statIndex
jmp_cmp &, 0x2, stor[7], inl[:LABEL_518] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x5 ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop
LABEL_518:
call Battle::scriptGetBentStat2, stor[0], CURRENT_HP, stor[8] ; bentIndex, statIndex, value
call Battle::scriptGetBentStat2, stor[0], MAX_HP, stor[9] ; bentIndex, statIndex, value
call Battle::scriptGetBentStat2, stor[0], GUARD_HEAL, inl[:GUARD_HEAL_PERCENT] ; bentIndex, statIndex, value
mov stor[8], stor[11] ; source, dest
mul inl[:GUARD_HEAL_PERCENT], stor[9]
div 100, stor[9] ; amount, operand
add stor[9], stor[11] ; amount, operand
call Battle::scriptGetBentStat2, stor[0], MAX_HP, stor[10] ; bentIndex, statIndex, value
jmp_cmp >=, stor[10], stor[11], inl[:LABEL_519] ; operand, left, right, addr
mov stor[10], stor[11] ; source, dest
mov stor[10], stor[9] ; source, dest
sub stor[8], stor[9] ; amount, operand
LABEL_519:
call Battle::scriptRenderRecover, stor[0], stor[9], 0x7 ; bentIndex, amount, colourIndex
call Battle::scriptSetBentRawStat, stor[0], stor[11], CURRENT_HP ; bentIndex, value, statIndex
gosub inl[:WAIT_FOR_ANIMATION_TO_FINISH] ; addr
gosub inl[:SET_IDLE_ANIMATION] ; addr
return

; SUBROUTINE
ACTION_DRAGOON_MAGIC:
call Battle::scriptInitSpellAndItemMenu, stor[0], 0x1 ; bentIndex, menuType
LABEL_520:
yield
call Battle::scriptGetItemOrSpellTargetingInfo, stor[8], stor[28], stor[29] ; selectionState, targetBentIndex, itemOrSpellId
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_520] ; operand, left, right, addr
jmp_cmp ==, 0xffffffff, stor[8], inl[:LABEL_526] ; operand, left, right, addr
mov 0x2, stor[8] ; source, dest
gosub_table stor[8], inl[:LABEL_90] ; index, table
gosub inl[:LABEL_471] ; addr
call Battle::scriptSetBattleHudVisibility, 0x0 ; visible
call Battle::scriptGetBentPos, stor[0], stor[24], stor[25], stor[26] ; bentIndex, x, y, z
mov var[45][118], stor[8] ; source, dest
mul 0x41, stor[8] ; amount, operand
div 0x64, stor[8] ; amount, operand
call Audio::scriptChangeSequenceVolumeOverTime, 0x3c, stor[8] ; fadeTime, volume
gosub inl[:LABEL_670] ; addr
or 0x2, var[45][245] ; right, left
gosub inl[:GET_DRAGON_SUMMON_SPECIAL_STAGE] ; addr
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_521] ; don't need to change stages
gosub inl[:CHANGE_BATTLE_STAGE] ; addr
LABEL_521:
call Battle::scriptLoadDeff, stor[29], stor[0], stor[28], 0x0, 0x1000000 ; flagsAndIndex, bentIndex, p2, scriptEntrypoint, type
mov 0x1, var[45][248] ; source, dest
LABEL_522:
mov var[45][248], stor[8] ; source, dest
yield
jmp_cmp !=, 0x2, var[45][248], inl[:LABEL_522] ; operand, left, right, addr
call Battle::scriptTickDeffLoadingStage, 0x2 ; loadingStage
call Battle::scriptTickDeffLoadingStage, 0x3 ; loadingStage
call DrgnFiles::scriptWaitForFilesToLoad ; index
gosub inl[:GET_DRAGON_SUMMON_SPECIAL_STAGE] ; addr
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_525] ; don't need to change stages
mov var[45][76], stor[8] ; source, dest
jmp_cmp >, 0x0, stor[8], inl[:LABEL_523] ; operand, left, right, addr
mov inl[:SPECIAL_TRANSFORM_STAGE[stor[8]]], stor[8] ; source, dest
jmp inl[:LABEL_524] ; addr
LABEL_523:
mov var[47], stor[8] ; source, dest
LABEL_524:
gosub inl[:CHANGE_BATTLE_STAGE] ; addr
LABEL_525:
and 0xfffffffd, var[45][245] ; right, left
mov var[45][118], stor[8] ; source, dest
call Audio::scriptStartSequenceAndChangeVolumeOverTime, 0x3c, stor[8] ; fadeTime, volume
call Battle::scriptSetBentPos, stor[0], stor[24], stor[25], stor[26] ; bentIndex, x, y, z
gosub inl[:LABEL_436] ; addr
return
LABEL_526:
gosub inl[:LABEL_64] ; addr
return
data 0x49

; SUBROUTINE
; If the spell is a dragon summon spell, returns the special stage to switch to
; @param int stor[29] spell id
; @return int stor[8] the special stage to switch to if any, or 0 if not a dragon summon or already on that stage
GET_DRAGON_SUMMON_SPECIAL_STAGE:
mov 0x0, stor[23] ; source, dest
gosub inl[:GET_MY_CHAR_ID] ; addr
jmp_cmp !=, stor[29], inl[:DRAGON_SUMMON_SPELL_INDICES[stor[8]]], inl[:LABEL_528] ; operand, left, right, addr
jmp_cmp ==, stor[8], var[45][76], inl[:LABEL_528] ; operand, left, right, addr
mov inl[:SPECIAL_TRANSFORM_STAGE[stor[8]]], stor[23] ; source, dest
LABEL_528:
mov stor[23], stor[8] ; source, dest
return

DRAGON_SUMMON_SPELL_INDICES:
data 0x3
data 0x8
data 0xd
data 0x13
data 0x17
data 0x8
data 0x1c
data 0x1f
data 0xd
data 0xffffffff



; SUBROUTINE
ACTION_ATTACK:
gosub inl[:RANDOMIZE_TARGET_ARROW_IF_FLAG_SET] ; addr

call Battle::scriptGetItemOrSpellAttackTarget, 0x1, stor[28] ; targetMode, targetBentIndex
jmp_cmp >, 0x0, stor[28], inl[:NO_ATTACK_TARGET_SELECTED] ; operand, left, right, addr

mov 0x5, stor[23] ; source, dest
wait stor[23] ; frames

gosub inl[:LABEL_471] ; addr

gosub inl[:GET_MY_CHAR_ID] ; addr
jmp_cmp ==, 0x0, inl[:LABEL_586[stor[8]]], inl[:LABEL_531] ; operand, left, right, addr
call Battle::scriptGetHitProperty, stor[0], 0x0, 0x6, stor[8] ; bentIndex, hitNum, hitPropertyIndex, value
call Audio::scriptLoadCharacterAttackSounds, stor[8] ; charId

ACTION_ATTACK_WAIT_FOR_SOUND_TO_LOAD:
yield
call Audio::scriptGetLoadedSoundFiles, stor[31] ; flags
jmp_cmp &, 0x10000, stor[31], inl[:ACTION_ATTACK_WAIT_FOR_SOUND_TO_LOAD] ; operand, left, right, addr

LABEL_531:
gosub inl[:GET_MY_CHAR_ID] ; addr
gosub_table stor[8], inl[:LABEL_479] ; index, table
call Audio::scriptStopSound, 0xa, 0x0, 0x3 ; soundFileIndex, soundIndex, mode
gosub inl[:GET_MY_CHAR_ID] ; addr
jmp_cmp ==, 0x0, inl[:LABEL_586[stor[8]]], inl[:LABEL_532] ; operand, left, right, addr
call Audio::scriptUnloadSoundFile, 0x7 ; soundType
LABEL_532:
call Battle::scriptSetBentRotationY, stor[0], 0x400 ; bentIndex, y

mov 0x5, stor[23] ; source, dest
wait stor[23] ; frames

gosub inl[:LABEL_26] ; addr
gosub inl[:LABEL_436] ; addr
return



NO_ATTACK_TARGET_SELECTED:
gosub inl[:LABEL_64] ; addr
return



; SUBROUTINE
ACTION_USE_ITEM:
; show item list
call Battle::scriptInitSpellAndItemMenu, stor[0], 0x0 ; bentIndex, menuType

; wait for selection
WAIT_FOR_ITEM_SELECTION:
yield
call Battle::scriptGetItemOrSpellTargetingInfo, stor[8], stor[28], stor[29], reg[0] ; selectionState, targetBentIndex, itemOrSpellId
jmp_cmp ==, 0x0, stor[8], inl[:WAIT_FOR_ITEM_SELECTION] ; operand, left, right, addr

; menu was canceled
jmp_cmp ==, 0xffffffff, stor[8], inl[:NO_ITEM_WAS_SELECTED] ; operand, left, right, addr

; wait 10 frames
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames

; hide item list and use item
call Battle::scriptSetBattleHudVisibility, 0x0 ; visible
gosub inl[:USE_ITEM] ; addr

; smoke bomb was used
jmp_cmp &, 0x1, var[45][77], inl[:ACTION_RUN_AWAY] ; operand, left, right, addr
return

NO_ITEM_WAS_SELECTED:
gosub inl[:LABEL_64] ; addr
return



; SUBROUTINE
ACTION_RUN_AWAY:
call Battle::scriptSetBattleHudVisibility, 0x0 ; visible
gosub inl[:LABEL_471] ; addr
mov var[46][2], stor[8] ; s8 = encounter escape chance

jmp_cmp &, 0x8, var[45][77], inl[:RUN_AWAY_FAILURE] ; operand, left, right, addr
jmp_cmp ==, 0x0, stor[8], inl[:RUN_AWAY_FAILURE] ; operand, left, right, addr

call Battle::scriptGetBentStat, stor[0], ESCAPE_BONUS_151, stor[10] ; s10 = bonus escape chance
add stor[10], stor[8] ; amount, operand
rand 0x64, stor[9] ; bound, dest
jmp_cmp >, stor[8], stor[9], inl[:RUN_AWAY_SUCCESS] ; operand, left, right, addr
jmp_cmp &, 0x1, var[45][77], inl[:RUN_AWAY_SUCCESS] ; operand, left, right, addr

RUN_AWAY_FAILURE:
gosub inl[:LABEL_74] ; addr
gosub inl[:LABEL_436] ; addr
return

RUN_AWAY_SUCCESS:
gosub inl[:LABEL_65] ; addr
call Battle::scriptSetPostBattleAction, 0x5 ; action
yield
return



; SUBROUTINE
ACTION_SPECIAL:
gosub inl[:GET_MY_CHAR_ID] ; addr
mov stor[8], var[45][76] ; source, dest
mov 0x0, stor[8] ; source, dest
LABEL_538:
call Battle::scriptGiveSp, var[34][stor[8]], 0x0, stor[9] ; bentIndex, amount, total
mov stor[9], stor[12] ; source, dest
div 0x64, stor[9] ; amount, operand
mov var[34][stor[8]], stor[11] ; source, dest
call Battle::scriptGetBentSlot, stor[11], stor[10], 0x1 ; bentIndex, charOrBentSlot, mode
add 0x45, stor[10] ; amount, operand
mov stor[9], var[45][stor[10]] ; source, dest
mul 0x64, stor[9] ; amount, operand
sub stor[9], stor[12] ; amount, operand
call Battle::scriptConsumeSp, stor[11], 0x1, stor[12] ; bentIndex, unused, amount
jmp_cmp !=, var[34][stor[8]], stor[0], inl[:LABEL_539] ; operand, left, right, addr
LABEL_539:
incr stor[8] ; operand
jmp_cmp !=, stor[8], var[35], inl[:LABEL_538] ; operand, left, right, addr
mov 0xc, stor[23] ; source, dest
wait stor[23] ; frames
call Battle::scriptSetBattleHudVisibility, 0x0 ; visible
or 0x1000, stor[7] ; mark battle menu for reload
gosub inl[:LABEL_471] ; addr
yield
gosub inl[:CLEAR_MY_STATUS] ; addr
mov var[45][118], stor[8] ; source, dest
mul 0x41, stor[8] ; amount, operand
div 0x64, stor[8] ; amount, operand
call Audio::scriptChangeSequenceVolumeOverTime, 0x3c, stor[8] ; fadeTime, volume
gosub inl[:GET_MY_CHAR_ID] ; addr
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
mov 0x0, stor[stor[stor[0], 18], 31] ; source, dest
mov stor[0], stor[stor[stor[0], 18], 30] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:LABEL_543] ; scriptIndex, address
call Battle::scriptGetBentStat, stor[0], DRAGOON_TRANSFORM_DEFF, stor[27]
call Battle::scriptLoadDeff, stor[27], stor[0], 0x0, 0x0, 0x1000000 ; flagsAndIndex, bentIndex, p2, scriptEntrypoint, type
call Battle::scriptTickDeffLoadingStage, 0x1 ; loadingStage
mov 0x1, stor[stor[stor[0], 18], 31] ; source, dest
call Battle::scriptTickDeffLoadingStage, 0x2 ; loadingStage
call Battle::scriptTickDeffLoadingStage, 0x3 ; loadingStage
call Battle::scriptGetBentStat, stor[0], FOOT_MODEL_PART, inl[:ACTION_SPECIAL_FOOT_MODEL_PART_INDEX]
call Battle::scriptAttachShadowToBentModelPart, stor[0], inl[:ACTION_SPECIAL_FOOT_MODEL_PART_INDEX] ; bentIndex, modelPartAttachmentIndex
call DrgnFiles::scriptWaitForFilesToLoad ; index
call Audio::scriptLoadCharAttackSounds, var[34][0], 0x0 ; bentIndex, type
LABEL_540:
yield
call Audio::scriptGetLoadedSoundFiles, stor[31] ; flags
jmp_cmp &, 0x8, stor[31], inl[:LABEL_540] ; operand, left, right, addr
call Audio::scriptLoadCharAttackSounds, var[34][1], 0x0 ; bentIndex, type
LABEL_541:
yield
call Audio::scriptGetLoadedSoundFiles, stor[31] ; flags
jmp_cmp &, 0x8, stor[31], inl[:LABEL_541] ; operand, left, right, addr
call Audio::scriptLoadCharAttackSounds, var[34][2], 0x0 ; bentIndex, type
LABEL_542:
yield
call Audio::scriptGetLoadedSoundFiles, stor[31] ; flags
jmp_cmp &, 0x8, stor[31], inl[:LABEL_542] ; operand, left, right, addr
gosub inl[:GET_MY_CHAR_ID] ; addr
call Battle::scriptSetDragoonSpaceElementIndex, stor[8] ; charId
mov inl[:SPECIAL_TRANSFORM_STAGE[stor[8]]], stor[8] ; source, dest
mov stor[8], var[45][187] ; source, dest
gosub inl[:CHANGE_BATTLE_STAGE] ; addr
mov var[45][118], stor[8] ; source, dest
call Audio::scriptStartSequenceAndChangeVolumeOverTime, 0x3c, stor[8] ; fadeTime, volume
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x0 ; bentIndex, animIndex
call Battle::scriptSetBattleHudVisibility, 0x1 ; visible
gosub inl[:LABEL_64] ; addr
gosub inl[:LABEL_436] ; addr
return

ACTION_SPECIAL_FOOT_MODEL_PART_INDEX:
data 0

; FORK RE-ENTRY
LABEL_543:
yield
jmp_cmp ==, 0x0, stor[31], inl[:LABEL_543] ; operand, left, right, addr
or 0x4, var[45][245] ; right, left
mov var[34][0], stor[29] ; source, dest
jmp_cmp !=, stor[29], stor[30], inl[:LABEL_544] ; operand, left, right, addr
mov var[34][1], stor[29] ; source, dest
LABEL_544:
gosub inl[:LABEL_546] ; addr
mov var[34][2], stor[29] ; source, dest
jmp_cmp !=, stor[29], stor[30], inl[:LABEL_545] ; operand, left, right, addr
mov var[34][1], stor[29] ; source, dest
LABEL_545:
gosub inl[:LABEL_546] ; addr
and 0xfffffffb, var[45][245] ; right, left
yield
deallocate

; SUBROUTINE
LABEL_546:
call Battle::scriptSetBentDeadAndDropLoot, stor[29], 0x0 ; bentIndex, dead
mov stor[29], stor[28] ; source, dest
gosub inl[:CLEAR_BENT_STATUS] ; addr
call Battle::scriptDisableBentShadow, stor[29] ; bentIndex
call Battle::FUN_800ccba4, stor[29], 0x1 ; bentIndex, isDragoon
call DrgnFiles::scriptWaitForFilesToLoad ; index
gosub inl[:LABEL_712] ; addr
call Battle::scriptGetBentStat, stor[29], FOOT_MODEL_PART, inl[:LABEL_546_FOOT_MODEL_PART_INDEX]
call Battle::scriptAttachShadowToBentModelPart, stor[29], inl[:LABEL_546_FOOT_MODEL_PART_INDEX] ; bentIndex, modelPartAttachmentIndex
call Battle::scriptSetLoadingBentAnimationIndex, stor[29], 0x0 ; bentIndex, animIndex
call Battle::scriptSetBentHidden, stor[29], 0x0 ; bentIndex, set
call Battle::scriptGetBentStat, stor[29], GUARD, stor[23] ; bentIndex, statIndex, value
and 0xfffffffe, stor[23] ; right, left
call Battle::scriptSetBentStat, stor[29], stor[23], GUARD ; bentIndex, value, statIndex
return

LABEL_546_FOOT_MODEL_PART_INDEX:
data 0

; SUBROUTINE
ACTION_TRANSFORM:

; if we're already dragoon, we're detransforming
gosub inl[:IS_DRAGOON] ; addr
jmp_cmp !=, 0, stor[31], inl[:ACTION_DETRANSFORM]

call Battle::scriptGiveSp, stor[0], 0x0, stor[9] ; bentIndex, amount, total
mov stor[9], stor[10] ; source, dest
div 0x64, stor[9] ; amount, operand
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x1 ; bentIndex, charOrBentSlot, mode
add 0x45, stor[8] ; amount, operand
mov stor[9], var[45][stor[8]] ; source, dest
mul 0x64, stor[9] ; amount, operand
sub stor[9], stor[10] ; amount, operand
call Battle::scriptConsumeSp, stor[0], 0x1, stor[10] ; bentIndex, unused, amount
mov 0xc, stor[23] ; source, dest
wait stor[23] ; frames
call Battle::scriptSetBattleHudVisibility, 0x0 ; visible
or 0x1000, stor[7] ; mark battle menu for reload
gosub inl[:LABEL_471] ; addr
yield
gosub inl[:CLEAR_MY_STATUS] ; addr
mov var[45][118], stor[8] ; source, dest
mul 0x41, stor[8] ; amount, operand
div 0x64, stor[8] ; amount, operand
call Audio::scriptChangeSequenceVolumeOverTime, 0x3c, stor[8] ; fadeTime, volume
gosub inl[:GET_MY_CHAR_ID] ; addr
gosub inl[:GET_TRANSFORM_MODE] ; addr
jmp_cmp !=, 0x0, stor[31], inl[:LABEL_547] ; is short transform
call Battle::scriptGetBentStat, stor[0], DRAGOON_TRANSFORM_DEFF, stor[27]
call Battle::scriptLoadDragoonDeffSync, stor[27], stor[0], 0x0, stor[9] ; flagsAndIndex, bentIndex, p2, scriptEntrypoint
jmp inl[:LABEL_548] ; addr
LABEL_547:
mov 0x0, stor[19] ; source, dest
call Battle::scriptLoadDragoonDeffSync, 0x21, stor[0], 0x0, 0x0 ; flagsAndIndex, bentIndex, p2, scriptEntrypoint
LABEL_548:
call DrgnFiles::scriptWaitForFilesToLoad ; index
mov var[45][118], stor[8] ; source, dest
call Audio::scriptStartSequenceAndChangeVolumeOverTime, 0x3c, stor[8] ; fadeTime, volume
call Audio::scriptLoadCharAttackSounds, stor[0], 0x0 ; bentIndex, type
LABEL_549:
yield
call Audio::scriptGetLoadedSoundFiles, stor[31] ; flags
jmp_cmp &, 0x8, stor[31], inl[:LABEL_549] ; operand, left, right, addr
call Battle::scriptSetBattleHudVisibility, 0x1 ; visible
jmp_cmp ==, 0x2, var[45][242], inl[:LABEL_550] ; operand, left, right, addr
gosub inl[:LABEL_64] ; addr
gosub inl[:LABEL_436] ; addr
LABEL_550:
return



; SUBROUTINE
ACTION_DETRANSFORM:
call Battle::scriptGetBentStat, stor[0], DETRANSFORMATION_MODE, stor[8]
jmp_cmp ==, 1, stor[8], inl[:DETRANSFORM_FROM_DRAGOON_AFTER_TURN] ;

call Battle::scriptSetBattleHudVisibility, 0x0 ; visible
call Battle::scriptConsumeSp, stor[0], 1, 100 ; consume 100 sp
gosub inl[:SET_MY_ATTACK_TARGETING_BIT] ; addr
mov stor[0], stor[30] ; source, dest
gosub inl[:TRANSFORM_OUT_OF_DRAGOON] ; addr
and 0xfffffffe, var[45][245] ; right, left
gosub inl[:CLEAR_MY_ATTACK_TARGETING_BIT] ; addr
return

DETRANSFORM_FROM_DRAGOON_AFTER_TURN:
gosub inl[:HANDLE_BATTLE_HUD] ;
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x1 ; bentIndex, charOrBentSlot, mode
add 0x45, stor[8] ; amount, operand
mov 0x1, var[45][stor[8]] ; source, dest
DETRANSFORM_FROM_DRAGOON_EXIT:
return



; SUBROUTINE
; @param int s8 stage
CHANGE_BATTLE_STAGE:
gosub inl[:DARKEN_STAGE_BEFORE_CHANGING_STAGE] ; addr
gosub inl[:ALLOCATE_SCRIPT_THAT_CONSTANTLY_SETS_STAGE_DARKENING_BACK_TO_0] ; addr
call Battle::scriptStopRenderingStage ; index
call Battle::scriptLoadStage, stor[8] ; stageIndex
call DrgnFiles::scriptWaitForFilesToLoad ; index
gosub inl[:APPLY_STAGE_AMBIANCE] ; addr
gosub inl[:DEALLOCATE_SCRIPT_THAT_CONSTANTLY_SETS_STAGE_DARKENING_BACK_TO_0] ; addr
gosub inl[:BRIGHTEN_STAGE_AFTER_CHANGING_STAGE] ; addr
return



; SUBROUTINE
; @param int s8 stage
APPLY_STAGE_AMBIANCE:
; if not dragoon space battle stage
jmp_cmp >, 0x47, stor[8], inl[:APPLY_STAGE_AMBIANCE_NOT_DRAGOON_SPACE] ; operand, left, right, addr
jmp_cmp <, 0x4e, stor[8], inl[:APPLY_STAGE_AMBIANCE_NOT_DRAGOON_SPACE] ; operand, left, right, addr

mov stor[8], stor[9] ; source, dest
sub 0x47, stor[9] ; amount, operand
call Battle::FUN_800e59d8, 0xfffffffd, stor[9] ; sets dragoon space ambiance s9
return

APPLY_STAGE_AMBIANCE_NOT_DRAGOON_SPACE:
call Battle::scriptApplyStageAmbiance ; index
return



; SUBROUTINE
DARKEN_STAGE_BEFORE_CHANGING_STAGE:
mov 0x10, stor[23] ; source, dest
mov 0x80, stor[22] ; source, dest
DARKEN_STAGE_BEFORE_CHANGING_STAGE_LOOP:
decr stor[23] ; operand
sub 0x8, stor[22] ; amount, operand
call Battle::scriptApplyScreenDarkening, stor[23] ; intensity
mov stor[22], var[109] ; mcq colour
yield
jmp_cmp !=, 0x0, stor[23], inl[:DARKEN_STAGE_BEFORE_CHANGING_STAGE_LOOP] ; operand, left, right, addr
return



; SUBROUTINE
BRIGHTEN_STAGE_AFTER_CHANGING_STAGE:
mov 0x0, stor[23] ; source, dest
mov 0x0, stor[22] ; source, dest

BRIGHTEN_STAGE_AFTER_CHANGING_STAGE_LOOP:
incr stor[23] ; operand
add 0x8, stor[22] ; amount, operand
call Battle::scriptApplyScreenDarkening, stor[23] ; intensity
mov stor[22], var[109] ; source, dest
yield
jmp_cmp !=, 0x10, stor[23], inl[:BRIGHTEN_STAGE_AFTER_CHANGING_STAGE_LOOP] ; operand, left, right, addr
return



; SUBROUTINE
; no idea why they did it like this
ALLOCATE_SCRIPT_THAT_CONSTANTLY_SETS_STAGE_DARKENING_BACK_TO_0:
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:CONSTANTLY_SET_STAGE_DARKENING_BACK_TO_0] ; scriptIndex, address
return



; FORK RE-ENTRY
CONSTANTLY_SET_STAGE_DARKENING_BACK_TO_0:
call Battle::scriptApplyScreenDarkening, 0x0 ; intensity
mov 0x0, var[109] ; source, dest
yield
jmp inl[:CONSTANTLY_SET_STAGE_DARKENING_BACK_TO_0] ; addr



; SUBROUTINE
; @param int s18 script index
DEALLOCATE_SCRIPT_THAT_CONSTANTLY_SETS_STAGE_DARKENING_BACK_TO_0:
deallocate_other stor[18] ; index
return



; SUBROUTINE
; @param int stor[8] char id
; @return bool stor[9] has transformed before (and not divine dragoon)
; @return bool stor[31] use short transform
GET_TRANSFORM_MODE:
mov 0x0, stor[9] ; source, dest
call Scus94491BpeSegment::scriptReadGlobalFlag2, inl[:CHAR_HAS_TRANSFORMED_BEFORE_FLAGS[stor[8]]], stor[31] ; flag, value
jmp_cmp ==, 0x0, stor[31], inl[:LABEL_572] ; has not transformed before
jmp_cmp !=, 0x0, var[38], inl[:LABEL_573] ; short transform mode
mov 0x0, stor[31] ; source, dest
jmp_cmp !=, 0x9, stor[8], inl[:LABEL_572] ; not divine dragoon
mov 0x1, stor[9] ; source, dest
LABEL_572:
call Scus94491BpeSegment::scriptSetGlobalFlag2, inl[:CHAR_HAS_TRANSFORMED_BEFORE_FLAGS[stor[8]]], 0x1 ; flag, value
LABEL_573:
return

CHAR_HAS_TRANSFORMED_BEFORE_FLAGS:
data 0x1b8
data 0x1ba
data 0x1b9
data 0x1bb
data 0x1bc
data 0x1bd
data 0x1be
data 0x1bf
data 0x1c0
data 0x1c1



; SUBROUTINE
; @param int s30 bent index
TRANSFORM_OUT_OF_DRAGOON:
yield
jmp_cmp ==, 0x0, var[53], inl[:TRANSFORM_OUT_OF_DRAGOON_EXIT] ; no monsters alive
jmp_cmp &, 0x1, var[45][245], inl[:TRANSFORM_OUT_OF_DRAGOON] ; operand, left, right, addr
or 0x1, var[45][245] ; right, left

jmp_cmp !&, 0x2, stor[stor[stor[0], 30], 7], inl[:TRANSFORM_OUT_OF_DRAGOON_EXIT] ; not dragoon

; load deff
call Battle::scriptLoadDragoonDeffSync, 0x21, stor[30], stor[30], 0x1 ; flagsAndIndex, bentIndex, p2, scriptEntrypoint
call DrgnFiles::scriptWaitForFilesToLoad ; index

; set shadow size and load sounds
mov stor[30], stor[8] ; source, dest
gosub inl[:SET_CHAR_BENT_SHADOW_SIZE] ; addr
call Audio::scriptLoadCharAttackSounds, stor[30], 0x1 ; bentIndex, type

; wait for sounds to load
TRANSFORM_OUT_OF_DRAGOON_WAIT_FOR_SOUNDS:
yield
call Audio::scriptGetLoadedSoundFiles, stor[31] ; flags
jmp_cmp &, 0x8, stor[31], inl[:TRANSFORM_OUT_OF_DRAGOON_WAIT_FOR_SOUNDS] ; operand, left, right, addr

; update animation
mov stor[30], stor[28] ; source, dest
gosub inl[:SET_BENT_ANIMATION] ; addr
yield
yield

gosub inl[:GET_MY_CHAR_ID] ; addr
jmp_cmp !=, stor[8], var[45][76], inl[:TRANSFORM_OUT_OF_DRAGOON_EXIT] ; special field not my element
mov var[47], stor[8] ; s8 = battle stage id
mov stor[8], var[45][187] ; source, dest
gosub inl[:CHANGE_BATTLE_STAGE] ; addr
call Battle::scriptSetDragoonSpaceElementIndex, 0xffffffff ; charId
mov 0xffffffff, var[45][76] ; source, dest
TRANSFORM_OUT_OF_DRAGOON_EXIT:
return



; SUBROUTINE
ACTION_CONFUSED:
rand 0x64, stor[8] ; bound, dest
jmp_cmp >, 0x14, stor[8], inl[:ACTION_GUARD] ; operand, left, right, addr
jmp_cmp >, 0x3c, stor[8], inl[:ACTION_RUN_AWAY] ; operand, left, right, addr
jmp inl[:ACTION_ATTACK_ALLY] ; addr
data 0x49

; SUBROUTINE
ACTION_ATTACK_ALLY:
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames
rand var[51], stor[8] ; s8 = random player bent index
mov var[50][stor[8]], stor[28] ; s28 = bent index s8 id
jmp_cmp ==, stor[0], stor[28], inl[:LABEL_580] ; operand, left, right, addr
call Battle::scriptBentLookAtBent, stor[0], stor[28] ; bentIndexToTurn, bentIndexTarget
LABEL_580:
call Audio::scriptPlaySound, 0x0, 0xb, 0x0, 0x0, 0x0, 0x0 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
call Battle::scriptSetInterpolationEnabled, stor[0], 0x0 ; bentIndex, set
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x10 ; bentIndex, animIndex
gosub inl[:WAIT_FOR_ANIMATION_TO_FINISH] ; addr
call Battle::scriptSetInterpolationEnabled, stor[0], 0x1 ; bentIndex, set
mov stor[0], stor[30] ; source, dest
call Battle::scriptGetBentStat2, stor[0], MAX_HP, stor[8] ; bentIndex, statIndex, value
div 0x5, stor[8] ; amount, operand
call Audio::scriptPlaySound, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
jmp_cmp ==, stor[0], stor[28], inl[:LABEL_582] ; operand, left, right, addr
fork_reenter stor[28], 0x2, stor[8] ; index, entrypoint, p2
call Battle::scriptSetBentRotationY, stor[0], 0x400 ; bentIndex, y
gosub inl[:SET_IDLE_ANIMATION] ; addr
gosub inl[:LABEL_26] ; addr
call Battle::scriptGetBentSlot, stor[28], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
jmp_cmp !&, 0x400, var[128 + stor[8]][7], inl[:LABEL_581] ; operand, left, right, addr
fork_reenter stor[28], 0x4, 0x0 ; index, entrypoint, p2
gosub inl[:LABEL_26] ; addr
LABEL_581:
jmp inl[:LABEL_583] ; addr
LABEL_582:
mov stor[8], stor[32] ; source, dest
gosub inl[:APPLY_DAMAGE] ; addr
LABEL_583:
call Battle::scriptSetBentRotationY, stor[0], 0x400 ; bentIndex, y
gosub inl[:SET_IDLE_ANIMATION] ; addr
mov 0x14, stor[23] ; source, dest
wait stor[23] ; frames
return

; SUBROUTINE
ACTION_DRAGOON_ATTACK:
mov 0x0, var[45][217] ; source, dest
mov 0x0, var[45][216] ; source, dest
gosub inl[:GET_MY_CHAR_ID] ; addr
jmp_cmp !=, stor[8], var[45][76], inl[:LABEL_584] ; operand, left, right, addr
mov 0x1, var[45][216] ; source, dest
LABEL_584:
gosub inl[:RANDOMIZE_TARGET_ARROW_IF_FLAG_SET] ; addr
call Battle::scriptGetItemOrSpellAttackTarget, 0x1, stor[28] ; targetMode, targetBentIndex
jmp_cmp >, 0x0, stor[28], inl[:LABEL_585] ; operand, left, right, addr
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:LABEL_471] ; addr
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
add 0xbd, stor[8] ; amount, operand
mov var[45][stor[8]], var[45][227] ; source, dest
mov 0x0, var[45][stor[8]] ; source, dest
gosub inl[:GET_MY_CHAR_ID] ; addr
gosub_table stor[8], inl[:LABEL_480] ; index, table
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
add 0xbd, stor[8] ; amount, operand
mov var[45][227], var[45][stor[8]] ; source, dest
call Battle::scriptSetBentRotationY, stor[0], 0x400 ; bentIndex, y
mov 0x14, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:LABEL_436] ; addr
return
LABEL_585:
gosub inl[:LABEL_64] ; addr
return



ENTRYPOINT_1_NOOP:
consume



ENTRYPOINT_18:
call Battle::scriptGetBentStat, stor[0], STATUS, stor[8] ; bentIndex, statIndex, value
and 0xff, stor[8] ; right, left
jmp_cmp &, 0x1, stor[8], inl[:LABEL_591] ; operand, left, right, addr
jmp_cmp !&, 0x40, stor[7], inl[:LABEL_589] ; operand, left, right, addr
call Battle::scriptSetBentDeadAndDropLoot, stor[0], 0x0 ; bentIndex, dead
gosub inl[:RECOVER_HALF_HP] ; addr
LABEL_587:
gosub inl[:SET_BENT_ANIMATION] ; addr
LABEL_588:
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
mov 0x0, var[128 + stor[8]][6] ; source, dest
consume
LABEL_589:
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_590] ; operand, left, right, addr
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
jmp_cmp ==, 0x0, var[128 + stor[8]][6], inl[:LABEL_588] ; operand, left, right, addr
LABEL_590:
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x0 ; bentIndex, animIndex
mov stor[0], stor[28] ; source, dest
gosub inl[:CLEAR_BENT_STATUS] ; addr
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
mov stor[0], stor[stor[stor[0], 18], 28] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:LABEL_592] ; scriptIndex, address
jmp inl[:LABEL_587] ; addr
LABEL_591:
call Battle::scriptSetBentDeadAndDropLoot, stor[0], 0x0 ; bentIndex, dead
gosub inl[:RECOVER_HALF_HP] ; addr
jmp inl[:LABEL_590] ; addr
ENTRYPOINT_21:
return

; FORK RE-ENTRY
LABEL_592:
gosub inl[:LABEL_459] ; addr
gosub inl[:LABEL_458] ; addr
deallocate



; SUBROUTINE
RECOVER_HALF_HP:
call Battle::scriptGetBentStat2, stor[0], MAX_HP, stor[8] ; bentIndex, statIndex, value
shr 0x1, stor[8] ; right, left
mov stor[0], stor[28] ; source, dest
gosub inl[:RECOVER_HP] ; addr
return



ENTRYPOINT_19:
call Battle::scriptGetBentStat, stor[0], STATUS, stor[8] ; bentIndex, statIndex, value
and 0xff, stor[8] ; right, left
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_594] ; operand, left, right, addr
jmp_cmp &, 0x40, stor[7], inl[:LABEL_596] ; operand, left, right, addr
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
jmp_cmp ==, 0x0, var[128 + stor[8]][6], inl[:LABEL_596] ; operand, left, right, addr
mov 0x0, stor[8] ; source, dest
LABEL_594:
mov stor[0], stor[28] ; source, dest
call Battle::scriptSetLoadingBentAnimationIndex, stor[28], 0x0 ; bentIndex, animIndex
call Battle::scriptSetBentDead, stor[28], 0x0 ; bentIndex, dead
jmp_cmp !&, 0x1, stor[8], inl[:LABEL_595] ; operand, left, right, addr
gosub inl[:RECOVER_HALF_HP] ; addr
LABEL_595:
gosub inl[:CLEAR_BENT_STATUS] ; addr
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
mov stor[0], stor[stor[stor[0], 18], 28] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:LABEL_592] ; scriptIndex, address
gosub inl[:SET_IDLE_ANIMATION] ; addr
LABEL_596:
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
mov 0x0, var[128 + stor[8]][6] ; source, dest
consume



ENTRYPOINT_2_TAKE_DAMAGE:
gosub inl[:SET_MY_ATTACK_TARGETING_BIT] ; addr
gosub inl[:APPLY_DAMAGE] ; addr
gosub inl[:LABEL_608] ; addr
gosub inl[:CLEAR_MY_ATTACK_TARGETING_BIT] ; addr
consume



; SUBROUTINE
; @param int s32 amount of hp lost
APPLY_DAMAGE:
jmp_cmp &, 0x40, stor[7], inl[:LABEL_604] ; already dead

gosub inl[:ADJUST_INCOMING_DAMAGE] ; addr

gosub inl[:CHECK_MATERIAL_MAGICAL_SHIELD] ; addr
jmp_cmp ==, 0x0, stor[8], inl[:APPLY_DAMAGE_NO_SHIELD] ; operand, left, right, addr

call Audio::scriptPlaySound, 0x0, 0x14, 0x0, 0x0, 0x0, 0x0 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay

decr stor[8] ; sub expects 0/1 for material/magic shield, not 1/2
mov stor[0], stor[28] ; source, dest
gosub inl[:ALLOCATE_MATERIAL_OR_MAGICAL_SHIELD_EFFECT] ; addr

; skip if incapacitated
gosub inl[:IS_INCAPACITATED] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:APPLY_DAMAGE_SKIP_SHIELD_GUARD_ANIMATION] ; operand, left, right, addr

; skip if dragoon
jmp_cmp &, 0x2, stor[7], inl[:APPLY_DAMAGE_SKIP_SHIELD_GUARD_ANIMATION] ; operand, left, right, addr

gosub inl[:GET_BENT_SLOT_BIT] ; s9
jmp_cmp &, stor[9], var[45][188], inl[:APPLY_DAMAGE_SKIP_SHIELD_GUARD_ANIMATION] ; operand, left, right, addr

; apply guard animation
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x5 ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop

APPLY_DAMAGE_SKIP_SHIELD_GUARD_ANIMATION:
mov 0x5, stor[23] ; frames to wait before rendering damage
gosub inl[:ALLOCATE_DAMAGE_RENDERER] ; addr

mov 0x18, stor[23] ; source, dest
wait stor[23] ; frames

gosub inl[:WAIT_FOR_ANIMATION_TO_FINISH] ; addr
jmp inl[:LABEL_603] ; addr

APPLY_DAMAGE_NO_SHIELD:
; check guard
call Battle::scriptGetBentStat, stor[0], GUARD, stor[8] ; bentIndex, statIndex, value
jmp_cmp ==, 0x0, stor[8], inl[:APPLY_DAMAGE_NOT_GUARDING] ; not guarding

call Battle::scriptPlayBentSound, 0x1, stor[0], 0x6, 0x1, 0x0, 0x0, 0x0 ; type, bentIndex, soundIndex, a3, a4, initialDelay, repeatDelay

mov stor[0], stor[28] ; source, dest
gosub inl[:ALLOCATE_GUARD_EFFECT] ; addr

; skip if incapacitated
gosub inl[:IS_INCAPACITATED] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:APPLY_DAMAGE_SKIP_GUARD_GUARD_ANIMATION] ; operand, left, right, addr

; skip if dragoon
jmp_cmp &, 0x2, stor[7], inl[:APPLY_DAMAGE_SKIP_GUARD_GUARD_ANIMATION] ; operand, left, right, addr

gosub inl[:GET_BENT_SLOT_BIT] ; addr
jmp_cmp &, stor[9], var[45][188], inl[:APPLY_DAMAGE_SKIP_GUARD_GUARD_ANIMATION] ; operand, left, right, addr

; apply guard animation
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x5 ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop

APPLY_DAMAGE_SKIP_GUARD_GUARD_ANIMATION:
mov 0x5, stor[23] ; source, dest
gosub inl[:ALLOCATE_DAMAGE_RENDERER] ; addr

mov 0x18, stor[23] ; source, dest
wait stor[23] ; frames

gosub inl[:WAIT_FOR_ANIMATION_TO_FINISH] ; addr
jmp inl[:LABEL_603] ; addr

APPLY_DAMAGE_NOT_GUARDING:
; skip if lost no hp
jmp_cmp >=, 0x0, stor[32], inl[:APPLY_DAMAGE_SKIP_DAMAGED_ANIMATION] ; operand, left, right, addr

; skip if incapacitated
gosub inl[:IS_INCAPACITATED] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:APPLY_DAMAGE_SKIP_DAMAGED_ANIMATION] ; operand, left, right, addr

; apply damaged animation
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x1 ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop

APPLY_DAMAGE_SKIP_DAMAGED_ANIMATION:
mov 0x4, stor[23] ; source, dest
gosub inl[:ALLOCATE_DAMAGE_RENDERER] ; addr

mov 0x10, stor[23] ; source, dest
wait stor[23] ; frames

gosub inl[:WAIT_FOR_ANIMATION_TO_FINISH] ; addr

LABEL_603:
gosub inl[:TAKE_HP] ; addr

call Battle::scriptGetBentStat2, stor[0], CURRENT_HP, stor[8] ; bentIndex, statIndex, value
jmp_cmp >=, 0x0, stor[8], inl[:HANDLE_DEATH] ; dead

gosub inl[:SET_IDLE_ANIMATION] ; addr

jmp_cmp >, 0x0, stor[32], inl[:LABEL_604] ; operand, left, right, addr
gosub inl[:UNSTUN_WHEN_DAMAGE_IS_TAKEN] ; addr
gosub inl[:GIVE_ON_HIT_VITALS] ; addr

LABEL_604:
mov 0x0, var[45][188] ; source, dest
return



; SUBROUTINE
; May have something to do with defensive spells?
; Maybe somehow determining if getting attacked by magic... it's used to decide whether to check for material or magical shield
; @return bool s8 0 if spell's target flag 0x80 is set, 1 otherwise or if spell is not active
LABEL_605:
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
jmp_cmp ==, 0x3, var[128 + stor[8]][0], inl[:LABEL_606] ; set to 3 when using an item DEFF
jmp_cmp ==, 0x2, var[128 + stor[8]][0], inl[:LABEL_606] ; operand, left, right, addr
mov var[128 + stor[8]][5], stor[9] ; source, dest
call Battle::scriptSetBentStat, stor[0], stor[9], SPELL_ID ; bentIndex, value, statIndex
call Battle::scriptSetTempSpellStats, stor[0] ; bentIndex
call Battle::scriptGetBentStat, stor[0], SPELL_TARGET_TYPE, stor[9] ; bentIndex, statIndex, value
mov 0x0, stor[8] ; source, dest
jmp_cmp !&, 0x80, stor[9], inl[:LABEL_607] ; operand, left, right, addr
LABEL_606:
mov 0x1, stor[8] ; source, dest
LABEL_607:
return



; SUBROUTINE
LABEL_608:
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
mov 0xffffffff, var[128 + stor[8]][0] ; source, dest
mov 0x20, var[128 + stor[8]][5] ; source, dest
return



; SUBROUTINE
ALLOCATE_DAMAGE_RENDERER:
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
mov stor[32], stor[stor[stor[0], 18], 8] ; source, dest
mov stor[23], stor[stor[stor[0], 18], 23] ; source, dest
mov stor[0], stor[stor[stor[0], 18], 28] ; source, dest
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:DAMAGE_RENDERER_FORK] ; scriptIndex, address
return



; FORK RE-ENTRY
; @param int s8 damage
; @param int s23 number of frames to wait before rendering damage
; @param int s28 bent index for which to render damage
DAMAGE_RENDERER_FORK:
wait stor[23] ; frames
call Battle::scriptRenderDamage, stor[28], stor[8] ; bentIndex, damage
deallocate



; SUBROUTINE
; @param int s32 damage taken
TAKE_HP:
mov stor[32], var[45][224] ; source, dest

; no damage
jmp_cmp >=, 0x0, stor[32], inl[:TAKE_HP_NO_DAMAGE] ; operand, left, right, addr

call Battle::scriptGetBentStat2, stor[0], CURRENT_HP, stor[8] ; s8 = current hp
sub stor[32], stor[8] ; subtract damage taken

jmp_cmp <=, 0x0, stor[8], inl[:TAKE_HP_SKIP_CLAMP] ; operand, left, right, addr
mov 0x0, stor[8] ; source, dest
TAKE_HP_SKIP_CLAMP:

call Battle::scriptSetBentRawStat, stor[0], stor[8], CURRENT_HP ; bentIndex, value, statIndex
TAKE_HP_NO_DAMAGE:
return



; SUBROUTINE
; @param int s9 my bent slot bit
; @param int s32 amount of hp lost
ADJUST_INCOMING_DAMAGE:
jmp_cmp >=, 0x0, stor[32], inl[:ADJUST_INCOMING_DAMAGE_SKIP_MODIFIERS] ; operand, left, right, addr
jmp_cmp &, stor[9], var[45][188], inl[:ADJUST_INCOMING_DAMAGE_SKIP_MODIFIERS] ; operand, left, right, addr

gosub inl[:APPLY_INCOMING_DAMAGE_MULTIPLIERS] ; addr

; block damage if material/magical shield is applied
gosub inl[:CHECK_MATERIAL_MAGICAL_SHIELD] ; addr
jmp_cmp ==, 0x0, stor[8], inl[:ADJUST_INCOMING_DAMAGE_NO_SHIELDS] ; no material/magical shield
mov 0x0, stor[32] ; source, dest
return

ADJUST_INCOMING_DAMAGE_NO_SHIELDS:
; halve damage if guarding
call Battle::scriptGetBentStat, stor[0], GUARD, stor[8] ; bentIndex, statIndex, value
jmp_cmp ==, 0x0, stor[8], inl[:ADJUST_INCOMING_DAMAGE_SKIP_MODIFIERS] ; operand, left, right, addr
shr 0x1, stor[32] ; right, left

ADJUST_INCOMING_DAMAGE_SKIP_MODIFIERS:
; cap damage
jmp_cmp >=, 999999999, stor[32], inl[:ADJUST_INCOMING_DAMAGE_NOT_CLAMPED] ; operand, left, right, addr
mov 999999999, stor[32] ; source, dest
ADJUST_INCOMING_DAMAGE_NOT_CLAMPED:

return



; SUBROUTINE
; @return int s8 0 = none, 1 = material shield, 2 = magical shield
CHECK_MATERIAL_MAGICAL_SHIELD:
gosub inl[:GET_BENT_SLOT_BIT] ; addr
jmp_cmp &, stor[9], var[45][188], inl[:LABEL_620] ; operand, left, right, addr

; s13 = material/magical shield bits
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
mov var[128 + stor[8]][7], stor[13] ; source, dest
and 0xf, stor[13] ; right, left

; no shield
jmp_cmp ==, 0x0, stor[13], inl[:LABEL_620] ; operand, left, right, addr

gosub inl[:LABEL_605] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:LABEL_619] ; operand, left, right, addr

; mask material shield
and 0x3, stor[13] ; right, left
jmp_cmp ==, 0x0, stor[13], inl[:LABEL_620] ; no material shield

mov 0x1, stor[8] ; source, dest
return

LABEL_619:
; mask magical shield
and 0xc, stor[13] ; right, left
jmp_cmp ==, 0x0, stor[13], inl[:LABEL_620] ; no magic shield

mov 0x2, stor[8] ; source, dest
return

LABEL_620:
mov 0x0, stor[8] ; source, dest
return



; SUBROUTINE
; Applies incoming damage multipliers
; 2x damage if fearful, 10x damage if dragoon and dragon block staff is active
; @param s32 int damage
; @return s32 int modified damage
APPLY_INCOMING_DAMAGE_MULTIPLIERS:

call Battle::scriptGetBentStat, stor[0], STATUS, stor[8] ; bentIndex, statIndex, value

jmp_cmp !&, 0x8, stor[8], inl[:LABEL_622] ; if not fearful
shl 0x1, stor[32] ; right, left
LABEL_622:

jmp_cmp !&, 0x2, stor[7], inl[:LABEL_623] ; not dragoon
; dragon block staff
jmp_cmp !&, 0x1, var[45][244], inl[:LABEL_623] ; operand, left, right, addr
mul 10, stor[32] ; amount, operand
LABEL_623:
return



ENTRYPOINT_3_TAKE_DAMAGE_SIMPLE:
gosub inl[:SET_MY_ATTACK_TARGETING_BIT] ; addr
gosub inl[:APPLY_DAMAGE_SIMPLE] ; addr
gosub inl[:LABEL_608] ; addr
gosub inl[:CLEAR_MY_ATTACK_TARGETING_BIT] ; addr
consume



; SUBROUTINE
; @param int s32 damage taken
APPLY_DAMAGE_SIMPLE:
jmp_cmp &, 0x40, stor[7], inl[:LABEL_626] ; if dead

gosub inl[:ADJUST_INCOMING_DAMAGE] ; addr

mov 0xa, stor[23] ; source, dest
gosub inl[:ALLOCATE_DAMAGE_RENDERER] ; addr

jmp_cmp !=, 0x0, var[45][243], inl[:LABEL_625] ; operand, left, right, addr
gosub inl[:TAKE_HP] ; addr
LABEL_625:

call Battle::scriptGetBentStat2, stor[0], CURRENT_HP, stor[8] ; bentIndex, statIndex, value
jmp_cmp >=, 0x0, stor[8], inl[:HANDLE_DEATH] ; no hp left
jmp_cmp >, 0x0, stor[32], inl[:LABEL_626] ; no damage
gosub inl[:UNSTUN_WHEN_DAMAGE_IS_TAKEN] ; addr
gosub inl[:GIVE_ON_HIT_VITALS] ; addr
LABEL_626:
mov 0x0, var[45][188] ; source, dest
return



ENTRYPOINT_4_HANDLE_DEATH:
gosub inl[:SET_MY_ATTACK_TARGETING_BIT] ; addr
gosub inl[:HANDLE_DEATH] ; addr
gosub inl[:LABEL_608] ; addr
gosub inl[:CLEAR_MY_ATTACK_TARGETING_BIT] ; addr
consume



; SUBROUTINE
HANDLE_DEATH:
gosub inl[:IS_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[31], inl[:HANDLE_DEATH_NOT_DRAGOON] ; not dragoon

call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
jmp_cmp &, 0x400, var[128 + stor[8]][7], inl[:HANDLE_DEATH_DIED_AS_DRAGOON] ; died as dragoon
or 0x400, var[128 + stor[8]][7] ; set died as dragoon
gosub inl[:SET_IDLE_ANIMATION] ; addr
return

HANDLE_DEATH_DIED_AS_DRAGOON:
and 0xfffffbff, var[128 + stor[8]][7] ; clear died as dragoon
mov stor[0], stor[30] ; source, dest
gosub inl[:TRANSFORM_OUT_OF_DRAGOON] ; addr

HANDLE_DEATH_NOT_DRAGOON:
call Battle::scriptGetLoadingBentAnimationIndex, stor[0], stor[8] ; bentIndex, animationIndex
jmp_cmp ==, 0xe, stor[8], inl[:HANDLE_DEATH_ANIMATION_ALREADY_SET] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0xe ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop
gosub inl[:WAIT_FOR_ANIMATION_TO_FINISH] ; addr
HANDLE_DEATH_ANIMATION_ALREADY_SET:

gosub inl[:CLEAR_MY_STATUS] ; addr

; clear menu block
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
mov 0x0, var[128 + stor[8]][6] ; source, dest

gosub inl[:TRY_TO_REVIVE] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:HANDLE_DEATH_REVIVED] ; revived

call Battle::scriptSetBentRawStat, stor[0], 0x0, CURRENT_HP ; bentIndex, value, statIndex
call Battle::scriptSetBentDeadAndDropLoot, stor[0], 0x1 ; bentIndex, dead

HANDLE_DEATH_REVIVED:
jmp_cmp !&, 0x1, var[45][245], inl[:LABEL_632] ; operand, left, right, addr
and 0xfffffffe, var[45][245] ; right, left
LABEL_632:
return



ENTRYPOINT_20_TAKE_DAMAGE:
jmp inl[:ENTRYPOINT_2_TAKE_DAMAGE] ; addr



ENTRYPOINT_6_NOOP:
ENTRYPOINT_7_NOOP:
ENTRYPOINT_8_NOOP:
ENTRYPOINT_9_NOOP:
ENTRYPOINT_12_NOOP:
ENTRYPOINT_13_NOOP:
ENTRYPOINT_14_NOOP:
ENTRYPOINT_15_NOOP:
ENTRYPOINT_22_NOOP:
ENTRYPOINT_23_NOOP:
ENTRYPOINT_24_NOOP:
ENTRYPOINT_25_NOOP:
ENTRYPOINT_26_NOOP:
ENTRYPOINT_27_NOOP:
ENTRYPOINT_28_NOOP:
ENTRYPOINT_29_NOOP:
ENTRYPOINT_30_NOOP:
ENTRYPOINT_31_NOOP:
consume



ENTRYPOINT_5_NOOP:
consume



; SUBROUTINE
HANDLE_DEATH_AFTER_VICTORY:
; if postBattleActionIndex_800bc974 != victory
jmp_cmp !=, 0x1, var[57], inl[:HAVE_NOT_WON_YET] ; operand, left, right, addr

gosub inl[:LABEL_469] ; addr

; if dead, jump to an infinite loop of yielding
jmp_cmp &, 0x40, stor[7], inl[:STAY_DEAD] ; operand, left, right, addr

; if not dead, play death animation and continue to infinite loop of yielding
; death animation
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0xf ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop

; wait
gosub inl[:WAIT_FOR_ANIMATION_TO_FINISH] ; addr

; laying on ground animation
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x1f ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x1 ; bentIndex, loop

STAY_DEAD:
yield
jmp inl[:STAY_DEAD] ; addr

HAVE_NOT_WON_YET:
mov 0x0, stor[8] ; source, dest
return



; SUBROUTINE
; @return bool s31 is dragoon
IS_DRAGOON:
mov 0x0, stor[31] ; source, dest
jmp_cmp !&, 0x2, stor[7], inl[:LABEL_637] ; operand, left, right, addr
mov 0x1, stor[31] ; source, dest
LABEL_637:
return

; SUBROUTINE
; @param int s28 bent id
; @return int s31 is dragoon
IS_BENT_DRAGOON:
mov 0x0, stor[31] ; source, dest
jmp_cmp !&, 0x2, stor[stor[stor[0], 28], 7], inl[:LABEL_639] ; operand, left, right, addr
mov 0x1, stor[31] ; source, dest
LABEL_639:
return



; SUBROUTINE
INIT_PLAYER:
; wait until character models are loaded
yield
jmp_cmp !&, 0x8, var[58], inl[:INIT_PLAYER] ; operand, left, right, addr

; clear dragoon space element
call Battle::scriptSetDragoonSpaceElementIndex, 0xffffffff ; charId

; clear a bunch of mostly-unknown battle vars
mov 0x0, var[45][246] ; attack targets
mov 0x0, var[45][68] ; source, dest
mov 0x0, var[45][245] ; source, dest
mov 0x0, var[45][77] ; run away flags
mov 0x0, var[45][188] ; source, dest
mov 0x0, var[45][183] ; processing status afflictions bitset
mov 0x0, var[45][225] ; source, dest
mov 0x0, var[45][219] ; source, dest
mov 0x0, var[45][220] ; source, dest
mov 0x0, var[45][221] ; source, dest
mov 0x0, var[45][222] ; source, dest
mov 0x0, var[45][223] ; source, dest
mov 0xffffffff, var[45][76] ; special flag

; store my char slot in s8
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x1 ; bentIndex, charOrBentSlot, mode

; copy my char slot to s9, s10, s11
mov stor[8], stor[9] ; source, dest
mov stor[8], stor[10] ; source, dest
mov stor[8], stor[11] ; source, dest

; make some battle var array indices
add 69, stor[8] ; amount, operand
add 90, stor[9] ; amount, operand
add 115, stor[10] ; amount, operand
add 184, stor[11] ; amount, operand

; clear my slot in a few more battle var arrays
mov 0x0, var[45][stor[8]] ; source, dest
mov 0x0, var[45][stor[9]] ; source, dest
mov 0x0, var[45][stor[10]] ; source, dest
mov 0xffffffff, var[45][stor[11]] ; source, dest

; store my bent slot in s8 and s9
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
mov stor[8], stor[9] ; source, dest

; set my status conditions _14 to 0x20
mov 0x20, var[128 + stor[8]][5] ; source, dest

; clear my shield/sig/charm/pan/charging turns
mov 0x0, var[128 + stor[8]][7] ; source, dest

; clear my menu block flag
mov 0x0, var[128 + stor[8]][6] ; source, dest

; clear my status conditions _10
mov 0xffffffff, var[128 + stor[8]][4] ; source, dest

; clear my status
add 129, stor[8] ; amount, operand
mov 0x0, var[45][stor[8]] ; source, dest

; clear my special weapon flags (destroyer mace, wargod, etc)
add 189, stor[9] ; amount, operand
mov 0x0, var[45][stor[9]] ; source, dest

gosub inl[:CACHE_SPECIAL_EQUIPMENT_FLAGS] ; addr

; store battle stage ID in s8
mov var[47], stor[8] ; source, dest

; copy battle stage ID to battle var 187
mov stor[8], var[45][187] ; source, dest

; set my rotation to 0x400
call Battle::scriptSetBentRotationY, stor[0], 0x400 ; bentIndex, y

; attach shadow
call Battle::scriptGetBentStat, stor[0], FOOT_MODEL_PART, inl[:INIT_PLAYER_FOOT_MODEL_PART_INDEX]
call Battle::scriptAttachShadowToBentModelPart, stor[0], inl[:INIT_PLAYER_FOOT_MODEL_PART_INDEX] ; bentIndex, modelPartAttachmentIndex

gosub inl[:SET_IDLE_ANIMATION] ; addr

; wait until initial turn values are calculated
WAIT_FOR_TURN_VALUE_CALCULATION:
yield
jmp_cmp !&, 0x10, var[58], inl[:WAIT_FOR_TURN_VALUE_CALCULATION] ; operand, left, right, addr

; copy current sequence volume to s8 and then to battle var 118
call Audio::scriptGetSequenceVolume, stor[8] ; volume
mov stor[8], var[45][118] ; source, dest
return

INIT_PLAYER_FOOT_MODEL_PART_INDEX:
data 0



; SUBROUTINE
SET_IDLE_ANIMATION:
jmp_cmp &, 0x2, stor[7], inl[:SET_IDLE_ANIMATION_NORMAL] ; is dragoon

jmp_cmp &, 0x40, stor[7], inl[:SET_IDLE_ANIMATION_DEAD_OR_STUNNED] ; is dead

call Battle::scriptGetBentStat, stor[0], STATUS, stor[10] ; bentIndex, statIndex, value
jmp_cmp &, 0x10, stor[10], inl[:SET_IDLE_ANIMATION_DEAD_OR_STUNNED] ; stunned

call Battle::scriptGetBentStat2, stor[0], CURRENT_HP, stor[8] ; bentIndex, statIndex, value
jmp_cmp >=, 0x0, stor[8], inl[:SET_IDLE_ANIMATION_DEAD_OR_STUNNED] ; 0 hp

call Battle::scriptGetBentStat2, stor[0], MAX_HP, stor[9] ; bentIndex, statIndex, value
div 0x4, stor[9] ; amount, operand
jmp_cmp >=, stor[9], stor[8], inl[:SET_IDLE_ANIMATION_RED_HP] ; red hp

call Battle::scriptGetBentStat, stor[0], STATUS, stor[10] ; bentIndex, statIndex, value
jmp_cmp &, 0x40, stor[10], inl[:SET_IDLE_ANIMATION_DISPIRITED] ; dispirited

SET_IDLE_ANIMATION_NORMAL:
call Battle::scriptGetLoadingBentAnimationIndex, stor[0], stor[8] ; bentIndex, animationIndex
jmp_cmp ==, 0x0, stor[8], inl[:SET_IDLE_ANIMATION_EXIT] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x0 ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x1 ; bentIndex, loop
return

SET_IDLE_ANIMATION_DEAD_OR_STUNNED:
call Battle::scriptGetLoadingBentAnimationIndex, stor[0], stor[8] ; bentIndex, animationIndex
jmp_cmp ==, 0xe, stor[8], inl[:SET_IDLE_ANIMATION_EXIT] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0xe ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop
return

SET_IDLE_ANIMATION_DISPIRITED:
call Battle::scriptGetLoadingBentAnimationIndex, stor[0], stor[8] ; bentIndex, animationIndex
jmp_cmp ==, 0xa, stor[8], inl[:SET_IDLE_ANIMATION_EXIT] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0xa ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x1 ; bentIndex, loop
return

SET_IDLE_ANIMATION_RED_HP:
call Battle::scriptGetLoadingBentAnimationIndex, stor[0], stor[8] ; bentIndex, animationIndex
jmp_cmp ==, 0xb, stor[8], inl[:SET_IDLE_ANIMATION_EXIT] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0xb ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x1 ; bentIndex, loop
SET_IDLE_ANIMATION_EXIT:
return

; SUBROUTINE
LABEL_648:
jmp_cmp &, 0x2, stor[stor[stor[0], 28], 7], inl[:LABEL_649] ; operand, left, right, addr
call Battle::scriptGetBentStat2, stor[28], CURRENT_HP, stor[8] ; bentIndex, statIndex, value
call Battle::scriptGetBentStat2, stor[28], MAX_HP, stor[9] ; bentIndex, statIndex, value
div 0x4, stor[9] ; amount, operand
jmp_cmp >=, stor[9], stor[8], inl[:LABEL_651] ; operand, left, right, addr
call Battle::scriptGetBentSlot, stor[28], stor[10], 0x0 ; bentIndex, charOrBentSlot, mode
add 0x81, stor[10] ; amount, operand
mov var[45][stor[10]], stor[9] ; source, dest
and 0xf, stor[9] ; right, left
jmp_cmp ==, 0x6, stor[9], inl[:LABEL_650] ; operand, left, right, addr
LABEL_649:
call Battle::scriptGetLoadingBentAnimationIndex, stor[28], stor[8] ; bentIndex, animationIndex
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_652] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[28], 0x0 ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[28], 0x1 ; bentIndex, loop
return
LABEL_650:
call Battle::scriptGetLoadingBentAnimationIndex, stor[28], stor[8] ; bentIndex, animationIndex
jmp_cmp ==, 0xa, stor[8], inl[:LABEL_652] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[28], 0xa ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[28], 0x1 ; bentIndex, loop
return
LABEL_651:
call Battle::scriptGetLoadingBentAnimationIndex, stor[28], stor[8] ; bentIndex, animationIndex
jmp_cmp ==, 0xb, stor[8], inl[:LABEL_652] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[28], 0xb ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[28], 0x1 ; bentIndex, loop
LABEL_652:
return



; SUBROUTINE
; disables guard, ticks turn-limited effects, applies regen
; @return bool s8 is dead
START_TURN:
; turn off guard
call Battle::scriptGetBentStat, stor[0], GUARD, stor[8] ; bentIndex, statIndex, value
and 0xfffffffe, stor[8] ; right, left
call Battle::scriptSetBentStat, stor[0], stor[8], GUARD ; bentIndex, value, statIndex
yield

; store my battle entity slot in s8
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode

; store my shields, sig, charm, pan, charging turns in s9
mov var[128 + stor[8]][7], stor[9] ; source, dest

; if no material shield
mov stor[9], stor[10] ; source, dest
and 0x3, stor[9] ; right, left
jmp_cmp ==, 0x0, stor[9], inl[:LABEL_654] ; operand, left, right, addr

; otherwise, decrement material shield turns
sub 0x1, var[128 + stor[8]][7] ; amount, operand
LABEL_654:

; if no magical shield
mov stor[10], stor[9] ; source, dest
and 0xc, stor[9] ; right, left
jmp_cmp ==, 0x0, stor[9], inl[:LABEL_655] ; operand, left, right, addr

; otherwise, decrement magical shield turns
sub 0x4, var[128 + stor[8]][7] ; amount, operand
LABEL_655:

; if no sig stone
mov stor[10], stor[9] ; source, dest
and 0xc0, stor[9] ; right, left
jmp_cmp ==, 0x0, stor[9], inl[:LABEL_656] ; operand, left, right, addr

; otherwise, decrement sig stone turns
sub 0x40, var[128 + stor[8]][7] ; amount, operand
LABEL_656:

; if no charm potion
mov stor[10], stor[9] ; source, dest
and 0x300, stor[9] ; right, left
jmp_cmp ==, 0x0, stor[9], inl[:LABEL_657] ; operand, left, right, addr

; otherwise, decrement charm potion turns
sub 0x100, var[128 + stor[8]][7] ; amount, operand
LABEL_657:

; if bewitched
call Battle::scriptGetBentStat, stor[0], STATUS, stor[9] ; bentIndex, statIndex, value
jmp_cmp &, 0x2, stor[9], inl[:LABEL_658] ; operand, left, right, addr
mov 0xffffffff, var[128 + stor[8]][4] ; source, dest
call Battle::scriptGetBentSlot, stor[0], stor[9], 0x1 ; bentIndex, charOrBentSlot, mode
add 184, stor[9] ; amount, operand
mov 0xffffffff, var[45][stor[9]] ; source, dest
LABEL_658:

; if dead
jmp_cmp &, 0x40, stor[7], inl[:LABEL_659] ; operand, left, right, addr

; if petrified
call Battle::scriptGetBentStat, stor[0], STATUS, stor[8] ; bentIndex, statIndex, value
jmp_cmp &, 0x1, stor[8], inl[:LABEL_659] ; operand, left, right, addr

gosub inl[:HANDLE_REGEN] ; addr

; if dead
jmp_cmp &, 0x40, stor[7], inl[:LABEL_659] ; operand, left, right, addr

mov 0x0, var[45][77] ; clear run away flags

mov 0x0, stor[8] ; source, dest
return

LABEL_659:
mov 0x1, stor[8] ; source, dest
return



; SUBROUTINE
HANDLE_STATUS_CONDITIONS:

; if in a tutorial fight, skip status condition stuff
gosub inl[:IS_IN_TUTORIAL] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:HANDLE_STATUS_CONDITIONS_EXIT] ; operand, left, right, addr

; if no status effects, skip status condition stuff
call Battle::scriptGetBentStat, stor[0], STATUS, stor[8] ; bentIndex, statIndex, value
and 0xff, stor[8] ; right, left
jmp_cmp ==, 0x0, stor[8], inl[:HANDLE_STATUS_CONDITIONS_EXIT] ; operand, left, right, addr

mov 0x0, stor[31] ; loop counter

; find the first status effect
HANDLE_STATUS_CONDITIONS_LOOP:
jmp_cmp &, inl[:STATUS_AFFLICTION_FLAGS[stor[31]]], stor[8], inl[:HANDLE_STATUS_CONDITIONS_APPLY_EFFECT] ; operand, left, right, addr
incr stor[31] ; operand
jmp_cmp ==, 0x8, stor[31], inl[:HANDLE_STATUS_CONDITIONS_EXIT] ; operand, left, right, addr
jmp inl[:HANDLE_STATUS_CONDITIONS_LOOP] ; addr

HANDLE_STATUS_CONDITIONS_APPLY_EFFECT:
gosub inl[:APPLY_STATUS_CONDITION] ; addr

HANDLE_STATUS_CONDITIONS_EXIT:
return



; SUBROUTINE
; @param int s31 status condition index
APPLY_STATUS_CONDITION:
; store my battle entity index in s9
call Battle::scriptGetBentSlot, stor[0], stor[9], 0x0 ; bentIndex, charOrBentSlot, mode

; clear my battle var status
add 129, stor[9] ; amount, operand
mov 0x0, var[45][stor[9]] ; source, dest

; set my battle var status turns to 3
or 0x300, var[45][stor[9]] ; right, left

; set my battle var status to the status effect index stored in s31
or stor[31], var[45][stor[9]] ; right, left

; allocate new script state and store index in s18
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex

; set new script s9 to my s9
mov stor[9], stor[stor[stor[0], 18], 9] ; source, dest

; set new script s28 to my index
mov stor[0], stor[stor[stor[0], 18], 28] ; source, dest

; set new script s31 to status effect index
mov stor[31], stor[stor[stor[0], 18], 31] ; source, dest

; store my battle entity slot in s10
call Battle::scriptGetBentSlot, stor[0], stor[10], 0x0 ; bentIndex, charOrBentSlot, mode

; set new script s8 to (1 << my battle entity slot)
mov 0x1, stor[8] ; source, dest
shl stor[10], stor[8] ; right, left
mov stor[8], stor[stor[stor[0], 18], 8] ; source, dest

; or battle var 183 with (1 << my battle entity slot)
or stor[8], var[45][183] ; right, left

; load my script into new state and jump to new entrypoint
call SEffe::scriptLoadSameScriptAndJump, stor[18], inl[:FORK_ENTRYPOINT_RENDER_TICK_STATUS] ; scriptIndex, address

yield

gosub inl[:WAIT_FOR_STATUS_EFFECT_PROCESSING_TO_FINISH] ; addr
return



; FORK RE-ENTRY
FORK_ENTRYPOINT_RENDER_TICK_STATUS:
fork_reenter stor[28], 11, stor[31] ; index, entrypoint, p2
gosub inl[:WAIT_FOR_STATUS_EFFECT_PROCESSING_TO_FINISH] ; addr
yield
yield
deallocate



; SUBROUTINE
; @param int s8 bit for script processing status effect
WAIT_FOR_STATUS_EFFECT_PROCESSING_TO_FINISH:
yield
jmp_cmp &, stor[8], var[45][183], inl[:WAIT_FOR_STATUS_EFFECT_PROCESSING_TO_FINISH] ; operand, left, right, addr
return



; SUBROUTINE
; @param bool s8 is in tutorial fight
IS_IN_TUTORIAL:
mov 0x0, stor[8] ; source, dest
mov var[36][0], stor[28] ; s28 = monster slot 0 bent id
call Battle::scriptGetCharOrMonsterId, stor[28], stor[28] ; s28 = bent id s28 monster id

; NOTE: fixed retail bug here, < and > were flipped
jmp_cmp >, 0xff, stor[28], inl[:LABEL_669] ; operand, left, right, addr
jmp_cmp <, 0xfd, stor[28], inl[:LABEL_669] ; operand, left, right, addr
incr stor[8] ; operand
LABEL_669:
return



; SUBROUTINE
LABEL_670:
call Battle::scriptAllocateEmptyEffectManagerChild, stor[18] ; effectIndex
mov stor[0], stor[stor[stor[0], 18], 30] ; source, dest
call SEffe::scriptSetScriptScript, stor[18], 0xffffffff, 0x10 ; scriptIndex, deffScriptIndex, entrypoint
yield
return



SPELL_RING_R:
data 0
SPELL_RING_G:
data 0
SPELL_RING_B:
data 0

ENTRYPOINT_16:
mov 0x0, var[45][248] ; source, dest
yield
call Battle::scriptGetBentPos, stor[30], stor[24], stor[25], stor[26] ; bentIndex, x, y, z
call SEffe::allocateDeffTmd, stor[18], 0xfff10 ; effectIndex, flags
call SEffe::scriptSetRelativePosition, stor[18], stor[30], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[18], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::allocateDeffTmd, stor[19], 0xfff0f ; effectIndex, flags
call SEffe::scriptSetRelativeScale, stor[19], 0xffffffff, 0x0, 0x400, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativePosition, stor[19], stor[30], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[19], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call Audio::scriptPlaySound, 0x0, 0x1b, 0x0, 0x0, 0x0, 0x0 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
LABEL_671:
yield
call Battle::scriptAnimationHasFinished, stor[30], stor[8] ; bentIndex, finished
jmp_cmp ==, 0x0, stor[8], inl[:LABEL_671] ; operand, left, right, addr
mov 0xffffff6f, stor[10] ; source, dest
mov 0xa, stor[9] ; source, dest
call Battle::scriptCameraSetViewpoint, 0x6, 0xffee0000, 0xfff38000, 0xfff30000, stor[30] ; mode, x, y, z, scriptIndex
call Battle::scriptCameraSetRefpoint, 0x6, 0x0, 0xfffa8000, 0x0, stor[30] ; mode, x, y, z, scriptIndex
mov 0x0, stor[8] ; source, dest
gosub inl[:LABEL_680] ; addr
call Battle::scriptCameraSetViewpoint, 0x0, stor[11], stor[12], stor[13], 0x0 ; mode, x, y, z, scriptIndex
call Battle::scriptCameraMoveViewpoint, 0x5, 0x0, 0x10000, 0x120000, 0x0, 0x40, 0x6, 0x0 ; mode, x, y, z, ?, ticks, stepType, scriptIndex
mov 0x1, stor[8] ; source, dest
gosub inl[:LABEL_680] ; addr
call Battle::scriptCameraSetRefpoint, 0x0, stor[11], stor[12], stor[13], 0x0 ; mode, x, y, z, scriptIndex
call SEffe::scriptAddScaleScalerAttachment, stor[18], 0xd0, 0xd0, 0xd0, 0x0, 0x0, 0x0 ; effectIndex, velocityX, velocityY, velocityZ, accelerationX, accelerationY, accelerationZ
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x14, 0x80, 0x80, 0x80 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAllocateParticleEffect, stor[22], 0xffffffff, 0xfff03, 0x20, 0xc8, 0x1, 0x100, 0x0, 0x4 ; effectIndex, parentIndex, type, count, p4, p5, p6, p7, type2
call SEffe::scriptSetRelativePosition, stor[22], stor[30], 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[22], 0xffffffff, 0x12c, 0x12c, 0x12c ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptAddLifespanAttachment, stor[22], 0xf ; effectIndex, ticks
gosub inl[:LABEL_719] ; addr
gosub inl[:LABEL_296] ; addr
gosub inl[:LABEL_310] ; addr
gosub inl[:LABEL_720] ; addr
mov 0xf, stor[23] ; source, dest
LABEL_672:
mov 0x1, stor[8] ; source, dest
gosub inl[:LABEL_679] ; addr
yield
while stor[23], inl[:LABEL_672] ; counter, addr
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[19], 0xffffffff, 0x5, 0x1000, 0x400, 0x1000 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[19], 0xffffffff, 0x7, 0x80, 0x80, 0x80 ; effectIndex, parentIndex, ticks, destR, destG, destB
mov 0x5, stor[23] ; source, dest
LABEL_673:
mov 0x2, stor[8] ; source, dest
gosub inl[:LABEL_679] ; addr
yield
while stor[23], inl[:LABEL_673] ; counter, addr
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[19], 0xffffffff, 0xf, 0x1400, 0x1000, 0x1400 ; effectIndex, parentIndex, ticks, x, y, z
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames
call SEffe::scriptAddConstantColourScalerAttachment, stor[18], 0xffffffff, 0x19, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddLifespanAttachment, stor[18], 0x19 ; effectIndex, ticks
gosub inl[:GET_BENT_CHAR_ID] ; s8 = bent s30's char id
call SEffe::allocateDeffTmd, stor[20], 0xfff0d ; effectIndex, flags
call SEffe::scriptSetRelativePosition, stor[20], stor[30], 0x0, 0xfffffc00, 0x0 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeScale, stor[20], 0xffffffff, 0x4000, 0x4000, 0x4000 ; bobjIndex1, bobjIndex2, x, y, z
call SEffe::scriptSetRelativeColour, stor[20], 0xffffffff, 0x0, 0x0, 0x0 ; bobjIndex1, bobjIndex2, r, g, b
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[20], 0xffffffff, 0xc, 0x2200, 0x2200, 0x2200 ; effectIndex, parentIndex, ticks, x, y, z

call Battle::scriptGetBentStat, stor[30], SPELL_RING_COLOUR, stor[10] ; s10 = packed rgb

; Unpack rgb
mov stor[10], inl[:SPELL_RING_R]
mov stor[10], inl[:SPELL_RING_G]
mov stor[10], inl[:SPELL_RING_B]
shr  8, inl[:SPELL_RING_G]
shr 16, inl[:SPELL_RING_B]
and 0xff, inl[:SPELL_RING_R]
and 0xff, inl[:SPELL_RING_G]
and 0xff, inl[:SPELL_RING_B]

mov inl[:SPELL_RING_R], stor[10] ; source, dest
mov inl[:SPELL_RING_G], stor[11] ; source, dest
mov inl[:SPELL_RING_B], stor[12] ; source, dest
div 0x2, stor[10] ; amount, operand
div 0x2, stor[11] ; amount, operand
div 0x2, stor[12] ; amount, operand
call SEffe::scriptAddConstantColourScalerAttachment, stor[20], 0xffffffff, 0x18, stor[10], stor[11], stor[12] ; effectIndex, parentIndex, ticks, destR, destG, destB
yield
mov inl[:SPELL_RING_R], stor[10] ; source, dest
mov inl[:SPELL_RING_G], stor[11] ; source, dest
mov inl[:SPELL_RING_B], stor[12] ; source, dest
mul 0x2, stor[10] ; amount, operand
jmp_cmp >=, 0xff, stor[10], inl[:LABEL_675] ; operand, left, right, addr
mov 0xff, stor[10] ; source, dest
LABEL_675:
mul 0x2, stor[11] ; amount, operand
jmp_cmp >=, 0xff, stor[11], inl[:LABEL_676] ; operand, left, right, addr
mov 0xff, stor[11] ; source, dest
LABEL_676:
mul 0x2, stor[12] ; amount, operand
jmp_cmp >=, 0xff, stor[12], inl[:LABEL_677] ; operand, left, right, addr
mov 0xff, stor[12] ; source, dest
LABEL_677:
mov 0xf, stor[23] ; source, dest
wait stor[23] ; frames
call SEffe::scriptAddConstantColourScalerAttachment, stor[19], 0xffffffff, 0xa, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddLifespanAttachment, stor[19], 0xa ; effectIndex, ticks
mov 0x5, stor[23] ; source, dest
wait stor[23] ; frames
call Battle::scriptCameraMoveViewpoint, 0x5, 0x80000, 0x10000, 0x180000, 0x0, 0x190, 0x6, 0x0 ; mode, x, y, z, ?, ticks, stepType, scriptIndex
LABEL_678:
yield
jmp_cmp ==, 0x0, var[45][248], inl[:LABEL_678] ; operand, left, right, addr
call SEffe::scriptAddScaleScalerMultiplicativeAttachmentTicks, stor[20], 0xffffffff, 0x5, 0x4000, 0x4000, 0x4000 ; effectIndex, parentIndex, ticks, x, y, z
call SEffe::scriptAddConstantColourScalerAttachment, stor[20], 0xffffffff, 0x5, 0x0, 0x0, 0x0 ; effectIndex, parentIndex, ticks, destR, destG, destB
call SEffe::scriptAddLifespanAttachment, stor[20], 0xa ; effectIndex, ticks
call FullScreenEffects::scriptStartFadeEffect, 0x3, 0xe ; type, frames
mov 0xd, stor[23] ; source, dest
wait stor[23] ; frames
gosub inl[:LABEL_719] ; addr
gosub inl[:LABEL_299] ; addr
gosub inl[:LABEL_720] ; addr
call Battle::scriptSetBentPos, stor[30], stor[24], stor[25], stor[26] ; bentIndex, x, y, z
call Audio::scriptPlaySound, 0x0, 0x1e, 0x0, 0x0, 0x0, 0x0 ; soundFileIndex, soundIndex, unused1, unused2, initialDelay, repeatDelay
mov 0x2, var[45][248] ; source, dest
deallocate

; SUBROUTINE
LABEL_679:
add stor[9], stor[10] ; amount, operand
call Battle::FUN_800cbb00, stor[30], stor[30], 0x1, 0x0, stor[10], 0x0 ; bentIndex0, bentIndex1, ticks, x, y, z
return

; SUBROUTINE
LABEL_680:
call Battle::scriptCalculateCameraValue, stor[8], 0x0, 0x0, 0x0, stor[11] ; type, mode, component, scriptIndex, out
call Battle::scriptCalculateCameraValue, stor[8], 0x0, 0x1, 0x0, stor[12] ; type, mode, component, scriptIndex, out
call Battle::scriptCalculateCameraValue, stor[8], 0x0, 0x2, 0x0, stor[13] ; type, mode, component, scriptIndex, out
shl 0x8, stor[11] ; right, left
shl 0x8, stor[12] ; right, left
shl 0x8, stor[13] ; right, left
return



ENTRYPOINT_17_DETRANSFORM:
gosub inl[:SET_MY_ATTACK_TARGETING_BIT] ; addr
mov stor[0], stor[30] ; source, dest
gosub inl[:TRANSFORM_OUT_OF_DRAGOON] ; addr
and 0xfffffffe, var[45][245] ; right, left
gosub inl[:CLEAR_MY_ATTACK_TARGETING_BIT] ; addr
consume



; SUBROUTINE
HANDLE_REGEN:
gosub inl[:IS_DRAGOON] ; addr
jmp_cmp !=, 0x0, stor[31], inl[:HANDLE_REGEN_EXIT] ; is dragoon

mov stor[0], stor[28] ; source, dest
call Battle::scriptGetBentStat, stor[0], HP_REGEN, stor[9] ; bentIndex, statIndex, value
gosub inl[:SIGN_HP_REGEN_VALUE] ; addr
jmp_cmp ==, 0x0, stor[9], inl[:HANDLE_REGEN_MP] ; no regen
jmp_cmp >, 0x0, stor[9], inl[:HANDLE_REGEN_NEGATIVE_HP] ; negative regen

call Battle::scriptGetBentStat, stor[0], MAX_HP, stor[8] ; bentIndex, statIndex, value
mul stor[9], stor[8] ; amount, operand
div 100, stor[8] ; amount, operand
gosub inl[:RECOVER_HP] ; addr
gosub inl[:SET_IDLE_ANIMATION] ; addr
mov 0x0, stor[8] ; source, dest
gosub inl[:ALLOCATE_REGEN_EFFECT] ; addr
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames
jmp inl[:HANDLE_REGEN_MP] ; addr

HANDLE_REGEN_NEGATIVE_HP:
call Battle::scriptPlayBentSound, 0x1, stor[0], 0x6, 0x1, 0x0, 0x0, 0x0 ; type, bentIndex, soundIndex, a3, a4, initialDelay, repeatDelay
neg stor[9] ; s9 = percent to subtract
call Battle::scriptGetBentStat, stor[0], MAX_HP, stor[8] ; s8 = my max hp

; s8, s32 = absolute amount to subtract
mul stor[9], stor[8] ; amount, operand
div 100, stor[8] ; amount, operand
mov stor[8], stor[32] ; source, dest

; set my bit on var[45][188]
gosub inl[:GET_BENT_SLOT_BIT] ; addr
or stor[9], var[45][188] ; right, left

gosub inl[:APPLY_DAMAGE] ; addr
jmp_cmp &, 0x40, stor[7], inl[:HANDLE_REGEN_EXIT] ; operand, left, right, addr

HANDLE_REGEN_MP:
call Battle::scriptGetBentStat, stor[0], MP_REGEN, stor[9] ; bentIndex, statIndex, value
jmp_cmp ==, 0x0, stor[9], inl[:HANDLE_REGEN_SP] ; operand, left, right, addr
mov stor[9], stor[8] ; source, dest
gosub inl[:RECOVER_MP] ; addr
mov 0x1, stor[8] ; source, dest
gosub inl[:ALLOCATE_REGEN_EFFECT] ; addr
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames

HANDLE_REGEN_SP:
call Battle::scriptGetBentStat, stor[0], SP_REGEN, stor[8] ; bentIndex, statIndex, value
jmp_cmp ==, 0x0, stor[8], inl[:HANDLE_REGEN_EXIT] ; operand, left, right, addr
gosub inl[:CAN_BECOME_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[10], inl[:HANDLE_REGEN_EXIT] ; operand, left, right, addr
gosub inl[:RECOVER_SP] ; addr
mov 0x2, stor[8] ; source, dest
gosub inl[:ALLOCATE_REGEN_EFFECT] ; addr
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames
HANDLE_REGEN_EXIT:
return



; SUBROUTINE
; Terrible code to convert an unsigned byte to a signed int, with 0x80 considered negative. Why was this not a couple shifts?
; @param int s9 unsigned byte regen
; @return int s9 signed int regen
SIGN_HP_REGEN_VALUE:
and 0xff, stor[9] ; right, left
jmp_cmp !&, 0x80, stor[9], inl[:LABEL_693] ; operand, left, right, addr
mov 0xffffffff, stor[8] ; source, dest
and 0xffffff00, stor[8] ; right, left
or stor[9], stor[8] ; right, left
mov stor[8], stor[9] ; source, dest
LABEL_693:
return



; SUBROUTINE
GIVE_ON_HIT_VITALS:
jmp_cmp &, 0x40, stor[7], inl[:GIVE_ON_HIT_VITALS_EXIT] ; is dead
gosub inl[:IS_DRAGOON] ; addr
jmp_cmp !=, 0x0, stor[31], inl[:GIVE_ON_HIT_VITALS_EXIT] ; is dragoon

mov stor[0], stor[28] ; source, dest
gosub inl[:LABEL_605] ; addr
jmp_cmp !=, 0x0, stor[8], inl[:GIVE_ON_HIT_VITALS_MAGICAL_HIT] ; was magical damage

call Battle::scriptGetBentStat, stor[0], MP_PER_PHYSICAL_HIT, stor[9] ; bentIndex, statIndex, value
gosub inl[:GIVE_ON_HIT_MP] ; addr
call Battle::scriptGetBentStat, stor[0], SP_PER_PHYSICAL_HIT, stor[8] ; bentIndex, statIndex, value
gosub inl[:GIVE_ON_HIT_SP] ; addr

GIVE_ON_HIT_VITALS_EXIT:
return

GIVE_ON_HIT_VITALS_MAGICAL_HIT:
call Battle::scriptGetBentStat, stor[0], MP_PER_MAGICAL_HIT, stor[9] ; bentIndex, statIndex, value
gosub inl[:GIVE_ON_HIT_MP] ; addr
call Battle::scriptGetBentStat, stor[0], SP_PER_MAGICAL_HIT, stor[8] ; bentIndex, statIndex, value
gosub inl[:GIVE_ON_HIT_SP] ; addr
return



; SUBROUTINE
; @param int s9 percentage of mp to recover
GIVE_ON_HIT_MP:
jmp_cmp ==, 0x0, stor[9], inl[:GIVE_ON_HIT_MP_EXIT] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[0], MAX_MP, stor[8] ; bentIndex, statIndex, value
mul stor[9], stor[8] ; amount, operand
div 100, stor[8] ; amount, operand
gosub inl[:RECOVER_MP] ; addr
mov 0x1, stor[8] ; source, dest
gosub inl[:ALLOCATE_GUARD_OR_ON_DAMAGE_RECOVER_EFFECT] ; addr

mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames

GIVE_ON_HIT_MP_EXIT:
return



; SUBROUTINE
; @param int s8 percentage of mp to recover
GIVE_ON_HIT_SP:
jmp_cmp ==, 0x0, stor[8], inl[:GIVE_ON_HIT_SP_EXIT] ; operand, left, right, addr
gosub inl[:CAN_BECOME_DRAGOON] ; addr
jmp_cmp ==, 0x0, stor[10], inl[:GIVE_ON_HIT_SP_EXIT] ; operand, left, right, addr
gosub inl[:RECOVER_SP] ; addr
mov 0x2, stor[8] ; source, dest
gosub inl[:ALLOCATE_GUARD_OR_ON_DAMAGE_RECOVER_EFFECT] ; addr
mov 0xa, stor[23] ; source, dest
wait stor[23] ; frames
GIVE_ON_HIT_SP_EXIT:
return



; SUBROUTINE
; @return int s9 0x1 shifted left by my bent slot
GET_BENT_SLOT_BIT:
call Battle::scriptGetBentSlot, stor[0], stor[8], 0x0 ; bentIndex, charOrBentSlot, mode
mov 0x1, stor[9] ; source, dest
shl stor[8], stor[9] ; right, left
return



; SUBROUTINE
; @return bool s8 revived
TRY_TO_REVIVE:
mov 0x0, stor[8] ; source, dest
call Battle::scriptGetBentStat, stor[0], REVIVE, stor[9] ; bentIndex, statIndex, value
rand 100, stor[10] ; bound, dest
jmp_cmp <=, stor[9], stor[10], inl[:TRY_TO_REVIVE_FAILED] ; operand, left, right, addr
call Battle::scriptGetBentStat, stor[0], STATUS, stor[23] ; bentIndex, statIndex, value
jmp_cmp &, 0x1, stor[23], inl[:TRY_TO_REVIVE_FAILED] ; operand, left, right, addr
gosub inl[:PROC_REVIVE] ; addr
mov 0x1, stor[8] ; source, dest
TRY_TO_REVIVE_FAILED:
return



; SUBROUTINE
PROC_REVIVE:
mov stor[0], stor[28] ; source, dest
mov stor[0], stor[30] ; source, dest
gosub inl[:ALLOCATE_REVIVAL_EFFECT] ; addr

mov 0x28, stor[23] ; source, dest
wait stor[23] ; frames

call Battle::scriptGetLoadingBentAnimationIndex, stor[0], stor[8] ; bentIndex, animationIndex
jmp_cmp !=, 0xe, stor[8], inl[:LABEL_705] ; operand, left, right, addr
call Battle::scriptSetLoadingBentAnimationIndex, stor[0], 0x9 ; bentIndex, animIndex
call Battle::scriptSetBentAnimationLoopState, stor[0], 0x0 ; bentIndex, loop
gosub inl[:WAIT_FOR_ANIMATION_TO_FINISH] ; addr
LABEL_705:

gosub inl[:RECOVER_HALF_HP] ; addr
gosub inl[:SET_IDLE_ANIMATION] ; addr
return



; SUBROUTINE
; @param int s28 target bent
; @return int s28 target bent, randomized of flag is set
RANDOMIZE_TARGET_ARROW_IF_FLAG_SET:
jmp_cmp !&, 0x2, var[45][244], inl[:DO_NOT_RANDOMIZE_TARGET_ARROW] ; operand, left, right, addr
; random monster index
rand var[53], stor[8] ; bound, dest
; monster index
mov var[52][stor[8]], stor[28] ; source, dest
; force target that monster
call Battle::scriptSetHudTargetBobj, 0x1, stor[28] ; targetType, targetBentIndex
DO_NOT_RANDOMIZE_TARGET_ARROW:
return



; SUBROUTINE
; @param int s0 my id
; @return int s8 char id
GET_MY_CHAR_ID:

; if divine dragoon return 9
call Battle::scriptGetBentStat, stor[0], STATUS, stor[8] ; bentIndex, statIndex, value
jmp_cmp !&, 0x4000, stor[8], inl[:GET_MY_CHAR_ID_NOT_DIVINE] ; operand, left, right, addr
mov 0x9, stor[8] ; source, dest
return
GET_MY_CHAR_ID_NOT_DIVINE:

; otherwise get char id
call Battle::scriptGetCharOrMonsterId, stor[0], stor[8] ; bentIndex, id
return



; SUBROUTINE
GET_BENT_CHAR_ID:
call Battle::scriptGetBentStat, stor[30], STATUS, stor[8] ; bentIndex, statIndex, value
jmp_cmp !&, 0x4000, stor[8], inl[:GET_BENT_CHAR_ID_NOT_DIVINE] ; operand, left, right, addr
mov 0x9, stor[8] ; source, dest
return
GET_BENT_CHAR_ID_NOT_DIVINE:

call Battle::scriptGetCharOrMonsterId, stor[30], stor[8] ; bentIndex, id
return



; SUBROUTINE
LABEL_712:
call Battle::scriptGetBentStat, stor[29], STATUS, stor[23] ; bentIndex, statIndex, value
jmp_cmp !&, 0x4000, stor[23], inl[:LABEL_713] ; operand, left, right, addr
mov 0x9, stor[23] ; source, dest
return
LABEL_713:
call Battle::scriptGetCharOrMonsterId, stor[29], stor[23] ; bentIndex, id
return
data 0xa90338
data 0x200001e
data 0x5
data 0x2000016
data 0x70341
data 0x1000000
data 0x4000
data 0x2000016
data 0x9000009
data 0x208
data 0x9
data 0x2000016
data 0x49
data 0xa70238
data 0x200001e
data 0x2000016
data 0x49



; SUBROUTINE
CACHE_SPECIAL_EQUIPMENT_FLAGS:
call Battle::scriptGetBentStat, stor[0], EQUIPMENT_WEAPON_SLOT, reg[0]
call Battle::scriptApplyEquipmentEffect, reg[0], stor[0]

call Battle::scriptGetBentStat, stor[0], EQUIPMENT_HELMET_SLOT, reg[0]
call Battle::scriptApplyEquipmentEffect, reg[0], stor[0]

call Battle::scriptGetBentStat, stor[0], EQUIPMENT_ARMOUR_SLOT, reg[0]
call Battle::scriptApplyEquipmentEffect, reg[0], stor[0]

call Battle::scriptGetBentStat, stor[0], EQUIPMENT_BOOTS_SLOT, reg[0]
call Battle::scriptApplyEquipmentEffect, reg[0], stor[0]

call Battle::scriptGetBentStat, stor[0], EQUIPMENT_ACCESSORY_SLOT, reg[0]
call Battle::scriptApplyEquipmentEffect, reg[0], stor[0]

return



LABEL_718:
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0
data 0x0

; SUBROUTINE
LABEL_719:
memcpy 0x18, stor[8], inl[:LABEL_718] ; size, src, dest
return

; SUBROUTINE
LABEL_720:
memcpy 0x18, inl[:LABEL_718], stor[8] ; size, src, dest
return
