diff --git a/asm/fight.s b/asm/fight.s deleted file mode 100644 index bc0320757..000000000 --- a/asm/fight.s +++ /dev/null @@ -1,1649 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start unc_080B08A0 -unc_080B08A0: @ 810CE2C - push {r4,r5,lr} - adds r4, r0, 0 - ldr r5, =gBattleAnimArgs - movs r0, 0 - ldrsh r1, [r5, r0] - adds r0, r4, 0 - bl sub_80A6864 - ldrh r0, [r5, 0x2] - ldrh r1, [r4, 0x22] - adds r0, r1 - strh r0, [r4, 0x22] - movs r0, 0xF - strh r0, [r4, 0x2E] - ldr r0, =WaitAnimForDuration - str r0, [r4, 0x1C] - ldr r1, =DestroyAnimSprite - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end unc_080B08A0 - - thumb_func_start sub_810CE68 -sub_810CE68: @ 810CE68 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r4, =gBattleAnimArgs - movs r1, 0xE - ldrsh r0, [r4, r1] - cmp r0, 0x1 - bne _0810CE90 - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810CE90 - ldrh r0, [r4, 0x2] - negs r0, r0 - strh r0, [r4, 0x2] - ldrh r0, [r4, 0x6] - negs r0, r0 - strh r0, [r4, 0x6] -_0810CE90: - ldr r4, =gBattleAnimArgs - ldrb r1, [r4, 0xC] - adds r0, r5, 0 - bl StartSpriteAnim - movs r0, 0 - strh r0, [r4, 0xC] - adds r0, r5, 0 - bl sub_80A7938 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810CE68 - - thumb_func_start sub_810CEB4 -sub_810CEB4: @ 810CEB4 - push {r4,lr} - adds r4, r0, 0 - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _0810CED0 - ldr r0, =gBattleAnimArgs - ldrh r1, [r0, 0x2] - negs r1, r1 - strh r1, [r0, 0x2] - ldrh r1, [r0, 0x6] - negs r1, r1 - strh r1, [r0, 0x6] -_0810CED0: - adds r0, r4, 0 - bl sub_810CE68 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810CEB4 - - thumb_func_start sub_810CEE0 -sub_810CEE0: @ 810CEE0 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r4, =gBattleAnimArgs - ldrb r1, [r4, 0x8] - bl StartSpriteAnim - movs r1, 0x6 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _0810CF04 - adds r0, r5, 0 - movs r1, 0x1 - bl InitAnimSpritePos - b _0810CF0C - .pool -_0810CF04: - adds r0, r5, 0 - movs r1, 0x1 - bl sub_80A6980 -_0810CF0C: - ldr r0, =gBattleAnimArgs - ldrh r0, [r0, 0x4] - strh r0, [r5, 0x2E] - ldr r0, =WaitAnimForDuration - str r0, [r5, 0x1C] - ldr r1, =DestroyAnimSprite - adds r0, r5, 0 - bl StoreSpriteCallbackInData6 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810CEE0 - - thumb_func_start sub_810CF30 -sub_810CF30: @ 810CF30 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r5, r0, 0 - ldr r0, =gBattleAnimArgs - movs r2, 0 - ldrsh r1, [r0, r2] - mov r9, r0 - cmp r1, 0 - bne _0810CF54 - ldr r0, =gBattleAnimAttacker - b _0810CF56 - .pool -_0810CF54: - ldr r0, =gBattleAnimTarget -_0810CF56: - ldrb r0, [r0] - mov r8, r0 - mov r4, r9 - movs r3, 0x4 - ldrsh r0, [r4, r3] - cmp r0, 0 - bge _0810CF74 - bl Random2 - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x5 - bl __umodsi3 - strh r0, [r4, 0x4] -_0810CF74: - ldrb r1, [r4, 0x4] - adds r0, r5, 0 - bl StartSpriteAnim - mov r0, r8 - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x20] - mov r0, r8 - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x22] - mov r0, r8 - movs r1, 0x1 - bl sub_80A861C - lsls r0, 16 - asrs r1, r0, 16 - lsrs r0, 31 - adds r1, r0 - lsls r1, 15 - lsrs r6, r1, 16 - mov r0, r8 - movs r1, 0 - bl sub_80A861C - lsls r0, 16 - asrs r0, 16 - cmp r0, 0 - bge _0810CFBE - adds r0, 0x3 -_0810CFBE: - lsls r4, r0, 14 - lsrs r4, 16 - bl Random2 - lsls r0, 16 - lsrs r0, 16 - lsls r1, r6, 16 - asrs r1, 16 - bl __modsi3 - lsls r0, 16 - lsrs r6, r0, 16 - bl Random2 - lsls r0, 16 - lsrs r0, 16 - lsls r4, 16 - asrs r4, 16 - adds r1, r4, 0 - bl __modsi3 - lsls r0, 16 - lsrs r4, r0, 16 - bl Random2 - movs r7, 0x1 - adds r1, r7, 0 - ands r1, r0 - cmp r1, 0 - beq _0810D000 - lsls r0, r6, 16 - negs r0, r0 - lsrs r6, r0, 16 -_0810D000: - bl Random2 - adds r1, r7, 0 - ands r1, r0 - cmp r1, 0 - beq _0810D012 - lsls r0, r4, 16 - negs r0, r0 - lsrs r4, r0, 16 -_0810D012: - ldr r0, =gBattlerPositions - add r0, r8 - ldrb r1, [r0] - adds r0, r7, 0 - ands r0, r1 - cmp r0, 0 - bne _0810D028 - lsls r0, r4, 16 - ldr r1, =0xfff00000 - adds r0, r1 - lsrs r4, r0, 16 -_0810D028: - lsls r0, r6, 16 - asrs r0, 16 - ldrh r2, [r5, 0x20] - adds r0, r2 - strh r0, [r5, 0x20] - lsls r0, r4, 16 - asrs r0, 16 - ldrh r3, [r5, 0x22] - adds r0, r3 - strh r0, [r5, 0x22] - mov r1, r9 - ldrh r0, [r1, 0x2] - strh r0, [r5, 0x2E] - ldr r0, =gBasicHitSplatSpriteTemplate - movs r2, 0x20 - ldrsh r1, [r5, r2] - movs r3, 0x22 - ldrsh r2, [r5, r3] - adds r3, r5, 0 - adds r3, 0x43 - ldrb r3, [r3] - adds r3, 0x1 - lsls r3, 24 - lsrs r3, 24 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x3C] - cmp r0, 0x40 - beq _0810D08C - movs r0, 0x3C - ldrsh r1, [r5, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r4, =gSprites - adds r0, r4 - movs r1, 0 - bl StartSpriteAffineAnim - movs r2, 0x3C - ldrsh r1, [r5, r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r4, 0x1C - adds r0, r4 - ldr r1, =SpriteCallbackDummy - str r1, [r0] -_0810D08C: - ldr r0, =sub_810D0B8 - str r0, [r5, 0x1C] - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810CF30 - - thumb_func_start sub_810D0B8 -sub_810D0B8: @ 810D0B8 - push {r4,r5,lr} - adds r5, r0, 0 - ldrh r1, [r5, 0x2E] - movs r2, 0x2E - ldrsh r0, [r5, r2] - cmp r0, 0 - bne _0810D100 - movs r1, 0x3C - ldrsh r0, [r5, r1] - cmp r0, 0x40 - beq _0810D0F4 - ldr r4, =gSprites - adds r1, r0, 0 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r0, [r0, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - movs r0, 0x3C - ldrsh r1, [r5, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl DestroySprite -_0810D0F4: - adds r0, r5, 0 - bl DestroyAnimSprite - b _0810D104 - .pool -_0810D100: - subs r0, r1, 0x1 - strh r0, [r5, 0x2E] -_0810D104: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_810D0B8 - - thumb_func_start sub_810D10C -sub_810D10C: @ 810D10C - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x1 - bl sub_80A6980 - movs r0, 0x1E - strh r0, [r4, 0x2E] - ldr r0, =gBattleAnimArgs - movs r1, 0x4 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _0810D130 - ldrh r0, [r4, 0x20] - subs r0, 0x14 - strh r0, [r4, 0x32] - b _0810D142 - .pool -_0810D130: - ldrh r0, [r4, 0x20] - adds r0, 0x14 - strh r0, [r4, 0x32] - adds r2, r4, 0 - adds r2, 0x3F - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] -_0810D142: - ldrh r0, [r4, 0x22] - subs r0, 0x14 - strh r0, [r4, 0x36] - ldr r0, =StartAnimLinearTranslation - str r0, [r4, 0x1C] - ldr r1, =sub_810D164 - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D10C - - thumb_func_start sub_810D164 -sub_810D164: @ 810D164 - push {r4-r6,lr} - adds r5, r0, 0 - ldrh r0, [r5, 0x38] - adds r0, 0x1 - movs r6, 0 - strh r0, [r5, 0x38] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xB - bne _0810D1A4 - ldrh r2, [r5, 0x20] - ldrh r4, [r5, 0x24] - subs r0, r2, r4 - strh r0, [r5, 0x32] - ldrh r1, [r5, 0x22] - ldrh r3, [r5, 0x26] - subs r0, r1, r3 - strh r0, [r5, 0x36] - movs r0, 0x8 - strh r0, [r5, 0x2E] - adds r2, r4 - strh r2, [r5, 0x20] - adds r1, r3 - strh r1, [r5, 0x22] - strh r6, [r5, 0x26] - strh r6, [r5, 0x24] - ldr r0, =StartAnimLinearTranslation - str r0, [r5, 0x1C] - ldr r1, =DestroyAnimSprite - adds r0, r5, 0 - bl StoreSpriteCallbackInData6 -_0810D1A4: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D164 - - thumb_func_start sub_810D1B4 -sub_810D1B4: @ 810D1B4 - push {r4-r6,lr} - adds r6, r0, 0 - ldr r0, =gBattleAnimAttacker - ldrb r1, [r0] - movs r0, 0x2 - ldr r2, =gBattleAnimTarget - eors r0, r1 - ldrb r1, [r2] - cmp r0, r1 - bne _0810D1E0 - ldrb r0, [r2] - bl GetBattlerPosition - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bhi _0810D1E0 - ldr r1, =gBattleAnimArgs - movs r2, 0 - ldrsh r0, [r1, r2] - negs r0, r0 - strh r0, [r1] -_0810D1E0: - adds r0, r6, 0 - movs r1, 0x1 - bl sub_80A6980 - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810D1FE - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x4] - negs r0, r0 - strh r0, [r1, 0x4] -_0810D1FE: - ldr r4, =gBattleAnimArgs - ldrh r0, [r4, 0x6] - movs r5, 0 - strh r0, [r6, 0x2E] - ldrh r0, [r6, 0x20] - strh r0, [r6, 0x30] - ldrh r1, [r4, 0x4] - adds r0, r1 - strh r0, [r6, 0x32] - ldrh r0, [r6, 0x22] - strh r0, [r6, 0x34] - strh r0, [r6, 0x36] - adds r0, r6, 0 - bl InitAnimLinearTranslation - ldrh r0, [r4, 0xA] - strh r0, [r6, 0x38] - ldrh r0, [r4, 0x8] - strh r0, [r6, 0x3A] - strh r5, [r6, 0x3C] - ldr r0, =sub_810D240 - str r0, [r6, 0x1C] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D1B4 - - thumb_func_start sub_810D240 -sub_810D240: @ 810D240 - push {r4,lr} - adds r4, r0, 0 - bl TranslateAnimLinear - lsls r0, 24 - cmp r0, 0 - bne _0810D26C - ldrh r0, [r4, 0x3C] - lsls r0, 16 - asrs r0, 24 - movs r2, 0x38 - ldrsh r1, [r4, r2] - bl Sin - ldrh r1, [r4, 0x26] - adds r0, r1 - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x3A] - ldrh r2, [r4, 0x3C] - adds r0, r2 - strh r0, [r4, 0x3C] - b _0810D272 -_0810D26C: - adds r0, r4, 0 - bl DestroyAnimSprite -_0810D272: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_810D240 - - thumb_func_start sub_810D278 -sub_810D278: @ 810D278 - push {r4,r5,lr} - adds r4, r0, 0 - movs r1, 0x1 - bl sub_80A6980 - ldr r5, =gBattleAnimArgs - ldrb r1, [r5, 0x4] - adds r0, r4, 0 - bl StartSpriteAnim - ldrh r0, [r5, 0x6] - strh r0, [r4, 0x2E] - ldr r0, =WaitAnimForDuration - str r0, [r4, 0x1C] - ldr r1, =sub_810D2B0 - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D278 - - thumb_func_start sub_810D2B0 -sub_810D2B0: @ 810D2B0 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0 - bl StartSpriteAffineAnim - adds r2, r4, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x14 - strh r0, [r4, 0x2E] - ldr r0, =WaitAnimForDuration - str r0, [r4, 0x1C] - ldr r1, =DestroyAnimSprite - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D2B0 - - thumb_func_start sub_810D2E4 -sub_810D2E4: @ 810D2E4 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x1 - bl sub_80A6980 - ldr r0, =gBattleAnimArgs - ldrh r0, [r0, 0x4] - strh r0, [r4, 0x2E] - ldr r0, =sub_810D308 - str r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D2E4 - - thumb_func_start sub_810D308 -sub_810D308: @ 810D308 - push {r4,r5,lr} - adds r5, r0, 0 - ldrh r0, [r5, 0x2E] - subs r0, 0x1 - strh r0, [r5, 0x2E] - lsls r0, 16 - asrs r0, 16 - movs r1, 0x1 - negs r1, r1 - cmp r0, r1 - bne _0810D34C - movs r0, 0x6 - strh r0, [r5, 0x2E] - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x32] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x36] - ldr r0, =StartAnimLinearTranslation - str r0, [r5, 0x1C] - ldr r1, =sub_810D360 - adds r0, r5, 0 - bl StoreSpriteCallbackInData6 -_0810D34C: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D308 - - thumb_func_start sub_810D360 -sub_810D360: @ 810D360 - push {lr} - movs r1, 0xF - strh r1, [r0, 0x2E] - ldr r1, =WaitAnimForDuration - str r1, [r0, 0x1C] - ldr r1, =DestroyAnimSprite - bl StoreSpriteCallbackInData6 - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D360 - - thumb_func_start sub_810D37C -sub_810D37C: @ 810D37C - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _0810D3A8 - adds r0, r4, 0 - movs r1, 0x1 - bl sub_80A6980 - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x4] - strh r0, [r4, 0x30] - ldrh r0, [r1, 0x6] - strh r0, [r4, 0x32] - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - b _0810D404 - .pool -_0810D3A8: - ldrh r0, [r4, 0x30] - ldrh r2, [r4, 0x36] - adds r0, r2 - strh r0, [r4, 0x36] - lsls r0, 16 - asrs r0, 24 - strh r0, [r4, 0x24] - movs r1, 0x34 - ldrsh r0, [r4, r1] - movs r2, 0x32 - ldrsh r1, [r4, r2] - bl Sin - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x34] - adds r0, 0x3 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x34] - cmp r0, 0x64 - ble _0810D3F6 - movs r0, 0x34 - ldrsh r1, [r4, r0] - lsrs r0, r1, 31 - adds r0, r1, r0 - asrs r0, 1 - lsls r0, 1 - subs r1, r0 - adds r3, r4, 0 - adds r3, 0x3E - movs r0, 0x1 - ands r1, r0 - lsls r1, 2 - ldrb r2, [r3] - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] -_0810D3F6: - movs r1, 0x34 - ldrsh r0, [r4, r1] - cmp r0, 0x78 - ble _0810D404 - adds r0, r4, 0 - bl DestroyAnimSprite -_0810D404: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_810D37C - - thumb_func_start sub_810D40C -sub_810D40C: @ 810D40C - push {r4,r5,lr} - adds r5, r0, 0 - ldr r0, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _0810D428 - ldr r4, =gBattleAnimAttacker - b _0810D42A - .pool -_0810D428: - ldr r4, =gBattleAnimTarget -_0810D42A: - ldrb r0, [r4] - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x20] - ldrb r0, [r4] - movs r1, 0x1 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x22] - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x2] - ldrh r2, [r5, 0x20] - adds r0, r2 - movs r2, 0 - strh r0, [r5, 0x20] - ldrh r0, [r1, 0x4] - ldrh r3, [r5, 0x22] - adds r0, r3 - strh r0, [r5, 0x22] - strh r2, [r5, 0x2E] - ldrh r0, [r1, 0x6] - strh r0, [r5, 0x30] - ldrh r0, [r1, 0x8] - strh r0, [r5, 0x32] - strh r2, [r5, 0x34] - ldr r0, =sub_810D47C - str r0, [r5, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D40C - - thumb_func_start sub_810D47C -sub_810D47C: @ 810D47C - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - cmp r2, 0 - beq _0810D48E - cmp r2, 0x1 - beq _0810D4B2 - b _0810D4EC -_0810D48E: - ldrh r0, [r1, 0x30] - subs r0, 0x1 - strh r0, [r1, 0x30] - lsls r0, 16 - cmp r0, 0 - bne _0810D4EC - movs r2, 0x32 - ldrsh r0, [r1, r2] - cmp r0, 0 - bne _0810D4AA - adds r0, r1, 0 - bl DestroyAnimSprite - b _0810D4EC -_0810D4AA: - ldrh r0, [r1, 0x2E] - adds r0, 0x1 - strh r0, [r1, 0x2E] - b _0810D4EC -_0810D4B2: - ldrh r0, [r1, 0x30] - adds r0, 0x1 - strh r0, [r1, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _0810D4DA - movs r0, 0 - strh r0, [r1, 0x30] - ldrh r0, [r1, 0x34] - adds r0, 0x1 - strh r0, [r1, 0x34] - ands r0, r2 - lsls r0, 16 - cmp r0, 0 - beq _0810D4D6 - movs r0, 0x2 - b _0810D4D8 -_0810D4D6: - ldr r0, =0x0000fffe -_0810D4D8: - strh r0, [r1, 0x24] -_0810D4DA: - ldrh r0, [r1, 0x32] - subs r0, 0x1 - strh r0, [r1, 0x32] - lsls r0, 16 - cmp r0, 0 - bne _0810D4EC - adds r0, r1, 0 - bl DestroyAnimSprite -_0810D4EC: - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D47C - - thumb_func_start sub_810D4F4 -sub_810D4F4: @ 810D4F4 - push {r4-r6,lr} - adds r5, r0, 0 - ldr r6, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r6, r1] - cmp r0, 0 - bne _0810D520 - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r2, [r6, 0x4] - adds r0, r2 - b _0810D532 - .pool -_0810D520: - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r6, 0x4] - adds r0, r1 -_0810D532: - strh r0, [r5, 0x20] - ldrb r0, [r4] - movs r1, 0x1 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r6, [r6, 0x6] - adds r0, r6 - strh r0, [r5, 0x22] - ldrh r2, [r5, 0x4] - lsls r1, r2, 22 - lsrs r1, 22 - ldr r3, =gBattleAnimArgs - movs r4, 0x2 - ldrsh r0, [r3, r4] - lsls r0, 4 - adds r1, r0 - ldr r4, =0x000003ff - adds r0, r4, 0 - ands r1, r0 - ldr r0, =0xfffffc00 - ands r0, r2 - orrs r0, r1 - strh r0, [r5, 0x4] - movs r1, 0 - movs r0, 0 - strh r0, [r5, 0x2E] - movs r2, 0x2 - ldrsh r0, [r3, r2] - cmp r0, 0x1 - beq _0810D5A0 - cmp r0, 0x1 - bgt _0810D58C - cmp r0, 0 - beq _0810D596 - b _0810D5C6 - .pool -_0810D58C: - cmp r0, 0x2 - beq _0810D5B0 - cmp r0, 0x3 - beq _0810D5C0 - b _0810D5C6 -_0810D596: - ldr r0, =0x0000fffd - b _0810D5C0 - .pool -_0810D5A0: - movs r0, 0x3 - strh r0, [r5, 0x3A] - ldr r0, =0x0000fffd - strh r0, [r5, 0x3C] - b _0810D5CE - .pool -_0810D5B0: - ldr r0, =0x0000fffd - strh r0, [r5, 0x3A] - movs r0, 0x3 - strh r0, [r5, 0x3C] - b _0810D5CE - .pool -_0810D5C0: - strh r0, [r5, 0x3A] - strh r0, [r5, 0x3C] - b _0810D5CE -_0810D5C6: - adds r0, r5, 0 - bl DestroyAnimSprite - b _0810D5D2 -_0810D5CE: - ldr r0, =sub_810D5DC - str r0, [r5, 0x1C] -_0810D5D2: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D4F4 - - thumb_func_start sub_810D5DC -sub_810D5DC: @ 810D5DC - push {lr} - adds r1, r0, 0 - ldrh r0, [r1, 0x3A] - ldrh r2, [r1, 0x20] - adds r0, r2 - strh r0, [r1, 0x20] - ldrh r0, [r1, 0x3C] - ldrh r2, [r1, 0x22] - adds r0, r2 - strh r0, [r1, 0x22] - ldrh r0, [r1, 0x2E] - adds r0, 0x1 - strh r0, [r1, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x28 - ble _0810D604 - adds r0, r1, 0 - bl DestroyAnimSprite -_0810D604: - pop {r0} - bx r0 - thumb_func_end sub_810D5DC - - thumb_func_start sub_810D608 -sub_810D608: @ 810D608 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r0, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _0810D664 - ldr r4, =gBattlerAttacker - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x20] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x22] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl sub_80A8328 - movs r1, 0x3 - ands r1, r0 - lsls r1, 2 - ldrb r2, [r5, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r5, 0x5] - ldr r0, =gBattleAnimTarget - b _0810D680 - .pool -_0810D664: - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - bl sub_80A8328 - movs r1, 0x3 - ands r1, r0 - lsls r1, 2 - ldrb r2, [r5, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r5, 0x5] - ldr r0, =gBattleAnimAttacker -_0810D680: - ldrb r0, [r0] - strh r0, [r5, 0x3C] - movs r0, 0 - strh r0, [r5, 0x2E] - movs r0, 0xC - strh r0, [r5, 0x30] - movs r0, 0x8 - strh r0, [r5, 0x32] - ldr r0, =sub_810D6A8 - str r0, [r5, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D608 - - thumb_func_start sub_810D6A8 -sub_810D6A8: @ 810D6A8 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xB4 - bne _0810D704 - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x10 - strh r0, [r4, 0x2E] - ldrh r0, [r4, 0x20] - strh r0, [r4, 0x30] - ldrh r0, [r4, 0x3C] - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x32] - ldrh r0, [r4, 0x22] - strh r0, [r4, 0x34] - ldrh r0, [r4, 0x3C] - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x36] - adds r0, r4, 0 - bl InitAnimLinearTranslation - ldr r1, =move_anim_8074EE0 - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - ldr r0, =sub_80A6F98 - str r0, [r4, 0x1C] -_0810D704: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D6A8 - - thumb_func_start sub_810D714 -sub_810D714: @ 810D714 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r4, =gBattleAnimArgs - ldrh r0, [r4] - strh r0, [r5, 0x20] - movs r2, 0x78 - strh r2, [r5, 0x22] - ldrh r0, [r4, 0x6] - strh r0, [r5, 0x2E] - adds r0, r5, 0 - adds r0, 0x36 - adds r1, r5, 0 - adds r1, 0x38 - lsls r2, 8 - bl sub_80A8048 - ldrh r0, [r4, 0x2] - strh r0, [r5, 0x3A] - ldrh r2, [r5, 0x4] - lsls r1, r2, 22 - lsrs r1, 22 - movs r3, 0x4 - ldrsh r0, [r4, r3] - lsls r0, 2 - adds r1, r0 - ldr r3, =0x000003ff - adds r0, r3, 0 - ands r1, r0 - ldr r0, =0xfffffc00 - ands r0, r2 - orrs r0, r1 - strh r0, [r5, 0x4] - ldr r0, =sub_810D770 - str r0, [r5, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D714 - - thumb_func_start sub_810D770 -sub_810D770: @ 810D770 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r7, r0, 0 - movs r1, 0x2E - ldrsh r0, [r7, r1] - cmp r0, 0 - beq _0810D7C2 - movs r2, 0x36 - ldrsh r0, [r7, r2] - movs r2, 0x38 - ldrsh r1, [r7, r2] - bl sub_80A8050 - adds r4, r0, 0 - movs r1, 0x3A - ldrsh r0, [r7, r1] - subs r4, r0 - adds r0, r7, 0 - adds r0, 0x36 - adds r1, r7, 0 - adds r1, 0x38 - adds r2, r4, 0 - bl sub_80A8048 - asrs r4, 8 - strh r4, [r7, 0x22] - lsls r4, 16 - asrs r4, 16 - movs r0, 0x8 - negs r0, r0 - cmp r4, r0 - bge _0810D7BA - adds r0, r7, 0 - bl DestroyAnimSprite - b _0810D818 -_0810D7BA: - ldrh r0, [r7, 0x2E] - subs r0, 0x1 - strh r0, [r7, 0x2E] - b _0810D818 -_0810D7C2: - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - adds r6, r0, 0 - lsls r6, 24 - lsrs r6, 24 - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r2, =gBattleAnimTarget - mov r8, r2 - ldrb r0, [r2] - movs r1, 0x2 - bl GetBattlerSpriteCoord - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - mov r1, r8 - ldrb r0, [r1] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - subs r4, r6 - strh r4, [r7, 0x2E] - lsrs r0, 24 - subs r0, r5 - strh r0, [r7, 0x30] - ldrh r0, [r7, 0x20] - lsls r0, 4 - strh r0, [r7, 0x32] - ldrh r0, [r7, 0x22] - lsls r0, 4 - strh r0, [r7, 0x34] - ldr r0, =sub_810D830 - str r0, [r7, 0x1C] -_0810D818: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D770 - - thumb_func_start sub_810D830 -sub_810D830: @ 810D830 - push {lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x2E] - ldrh r1, [r2, 0x32] - adds r0, r1 - strh r0, [r2, 0x32] - ldrh r1, [r2, 0x30] - ldrh r3, [r2, 0x34] - adds r1, r3 - strh r1, [r2, 0x34] - lsls r0, 16 - asrs r0, 20 - strh r0, [r2, 0x20] - lsls r1, 16 - asrs r3, r1, 20 - strh r3, [r2, 0x22] - adds r0, 0x8 - lsls r0, 16 - movs r1, 0x80 - lsls r1, 17 - cmp r0, r1 - bhi _0810D86A - adds r1, r3, 0 - movs r0, 0x8 - negs r0, r0 - cmp r1, r0 - blt _0810D86A - cmp r1, 0x78 - ble _0810D870 -_0810D86A: - adds r0, r2, 0 - bl DestroyAnimSprite -_0810D870: - pop {r0} - bx r0 - thumb_func_end sub_810D830 - - thumb_func_start sub_810D874 -sub_810D874: @ 810D874 - push {r4,r5,lr} - adds r5, r0, 0 - ldr r0, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _0810D8B8 - ldr r4, =gBattlerAttacker - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x20] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x22] - ldr r0, =gBattleAnimTarget - ldrb r4, [r0] - ldr r0, =gBattleAnimAttacker - b _0810D8BE - .pool -_0810D8B8: - ldr r0, =gBattleAnimAttacker - ldrb r4, [r0] - ldr r0, =gBattleAnimTarget -_0810D8BE: - ldrb r0, [r0] - bl sub_80A8328 - movs r1, 0x3 - ands r1, r0 - lsls r1, 2 - ldrb r2, [r5, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r5, 0x5] - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _0810D8F8 - ldrb r2, [r5, 0x3] - lsls r1, r2, 26 - lsrs r1, 27 - movs r0, 0x8 - orrs r1, r0 - lsls r1, 1 - subs r0, 0x47 - b _0810D912 - .pool -_0810D8F8: - adds r0, r4, 0 - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _0810D918 - ldrb r2, [r5, 0x3] - lsls r1, r2, 26 - lsrs r1, 27 - movs r0, 0x18 - orrs r1, r0 - lsls r1, 1 - subs r0, 0x57 -_0810D912: - ands r0, r2 - orrs r0, r1 - strb r0, [r5, 0x3] -_0810D918: - movs r0, 0x10 - strh r0, [r5, 0x2E] - ldrh r0, [r5, 0x20] - strh r0, [r5, 0x30] - adds r0, r4, 0 - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x32] - ldrh r0, [r5, 0x22] - strh r0, [r5, 0x34] - adds r0, r4, 0 - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x36] - adds r0, r5, 0 - bl InitAnimLinearTranslation - ldr r1, =DestroyAnimSprite - adds r0, r5, 0 - bl StoreSpriteCallbackInData6 - ldr r0, =sub_80A6F98 - str r0, [r5, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D874 - - thumb_func_start sub_810D960 -sub_810D960: @ 810D960 - push {r4,lr} - adds r4, r0, 0 - movs r0, 0x2E - ldrsh r1, [r4, r0] - movs r2, 0x36 - ldrsh r0, [r4, r2] - cmp r1, r0 - bne _0810D976 - adds r0, r4, 0 - bl DestroyAnimSprite -_0810D976: - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_810D960 - - thumb_func_start sub_810D984 -sub_810D984: @ 810D984 - push {r4-r6,lr} - adds r5, r0, 0 - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x20] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x22] - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x6] - strh r0, [r5, 0x30] - ldrh r0, [r1] - strh r0, [r5, 0x32] - ldrh r0, [r1, 0x2] - strh r0, [r5, 0x34] - ldrh r0, [r1, 0x4] - strh r0, [r5, 0x36] - ldr r0, =gAnimMoveTurn - ldrb r6, [r0] - ldrb r0, [r4] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _0810D9CE - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_0810D9CE: - movs r0, 0x1 - ands r6, r0 - cmp r6, 0 - beq _0810D9E2 - ldrh r0, [r5, 0x32] - negs r0, r0 - strh r0, [r5, 0x32] - ldrh r0, [r5, 0x30] - adds r0, 0x1 - strh r0, [r5, 0x30] -_0810D9E2: - ldrh r1, [r5, 0x30] - lsls r1, 24 - lsrs r1, 24 - adds r0, r5, 0 - bl StartSpriteAnim - ldrh r0, [r5, 0x32] - strh r0, [r5, 0x24] - ldrh r0, [r5, 0x34] - strh r0, [r5, 0x26] - ldr r0, =sub_810D960 - str r0, [r5, 0x1C] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810D984 - - thumb_func_start sub_810DA10 -sub_810DA10: @ 810DA10 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =gBattleAnimArgs - movs r1, 0x4 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _0810DA2C - adds r0, r4, 0 - movs r1, 0 - bl InitAnimSpritePos - b _0810DA34 - .pool -_0810DA2C: - adds r0, r4, 0 - movs r1, 0 - bl sub_80A6980 -_0810DA34: - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _0810DA48 - adds r0, r4, 0 - movs r1, 0x2 - bl StartSpriteAnim - b _0810DA5E -_0810DA48: - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810DA5E - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAnim -_0810DA5E: - ldr r0, =sub_80A67D8 - str r0, [r4, 0x1C] - ldr r1, =DestroyAnimSprite - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810DA10 - - thumb_func_start sub_810DA7C -sub_810DA7C: @ 810DA7C - push {r4,lr} - adds r4, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _0810DAB6 - ldrh r0, [r4, 0x30] - adds r0, 0x28 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x30] - movs r1, 0x30 - ldrsh r0, [r4, r1] - movs r1, 0x2 - bl Sin - strh r0, [r4, 0x24] - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x28 - ble _0810DAB6 - adds r0, r4, 0 - bl DestroyAnimSprite -_0810DAB6: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_810DA7C - - thumb_func_start sub_810DABC -sub_810DABC: @ 810DABC - push {r4-r7,lr} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - beq _0810DAF4 - cmp r0, 0x1 - bgt _0810DB0E - cmp r0, 0 - bne _0810DB0E - movs r0, 0 - bl sub_80A6DAC - ldr r0, =gBattleAnimArgs - ldrh r0, [r0] - strh r0, [r4, 0x18] - b _0810DB06 - .pool -_0810DAF4: - ldrh r0, [r4, 0x18] - subs r0, 0x1 - strh r0, [r4, 0x18] - lsls r0, 16 - asrs r0, 16 - movs r1, 0x1 - negs r1, r1 - cmp r0, r1 - bne _0810DB1A -_0810DB06: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _0810DB1A -_0810DB0E: - movs r2, 0xA0 - lsls r2, 3 - adds r0, r2, 0 - ldrh r1, [r4, 0x1A] - adds r0, r1 - strh r0, [r4, 0x1A] -_0810DB1A: - movs r2, 0xB0 - lsls r2, 4 - adds r0, r2, 0 - ldrh r1, [r4, 0x1C] - adds r0, r1 - strh r0, [r4, 0x1C] - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _0810DB50 - ldr r1, =gBattle_BG3_X - ldrh r0, [r4, 0x1A] - lsls r0, 16 - asrs r0, 24 - ldrh r2, [r1] - adds r0, r2 - strh r0, [r1] - adds r7, r1, 0 - b _0810DB60 - .pool -_0810DB50: - ldr r2, =gBattle_BG3_X - ldrh r1, [r4, 0x1A] - lsls r1, 16 - asrs r1, 24 - ldrh r0, [r2] - subs r0, r1 - strh r0, [r2] - adds r7, r2, 0 -_0810DB60: - ldr r3, =gBattle_BG3_Y - ldrh r2, [r4, 0x1C] - lsls r0, r2, 16 - asrs r0, 24 - ldrh r1, [r3] - adds r0, r1 - strh r0, [r3] - movs r0, 0xFF - ldrb r1, [r4, 0x1A] - movs r5, 0 - strh r1, [r4, 0x1A] - ands r0, r2 - strh r0, [r4, 0x1C] - ldr r0, =gBattleAnimArgs - movs r2, 0xE - ldrsh r1, [r0, r2] - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - bne _0810DB98 - strh r5, [r7] - strh r5, [r3] - movs r0, 0x1 - bl sub_80A6DAC - adds r0, r6, 0 - bl DestroyAnimVisualTask -_0810DB98: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810DABC - - .align 2, 0 diff --git a/include/battle_anim.h b/include/battle_anim.h index 293800623..16e9de0ac 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -96,6 +96,12 @@ void sub_80A6864(struct Sprite *sprite, s16 a2); s16 sub_80A861C(u8 battlerId, u8 a2); u8 GetBattlerYCoordWithElevation(u8 battlerId); void WaitAnimForDuration(struct Sprite *sprite); +void sub_80A7938(struct Sprite *sprite); +void InitAnimLinearTranslation(struct Sprite *sprite); +void sub_80A6F98(struct Sprite *sprite); +u8 sub_80A8328(u8 battlerId); +void *sub_80A8050(s16 bottom, s16 top); +void sub_80A8048(s16 *bottom, s16 *top, const void *ptr); void sub_80A8278(void); void sub_80A6B30(struct UnknownAnimStruct2*); void sub_80A6B90(struct UnknownAnimStruct2*, u32 arg1); diff --git a/ld_script.txt b/ld_script.txt index d9c4546ff..45bfd94cb 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -162,7 +162,7 @@ SECTIONS { asm/fire.o(.text); asm/electric.o(.text); asm/ice.o(.text); - asm/fight.o(.text); + src/fight.o(.text); src/poison.o(.text); asm/flying.o(.text); asm/psychic.o(.text); diff --git a/src/battle_anim_80A5C6C.c b/src/battle_anim_80A5C6C.c index 4824b2b3f..2ac6cca90 100644 --- a/src/battle_anim_80A5C6C.c +++ b/src/battle_anim_80A5C6C.c @@ -36,9 +36,7 @@ extern const union AffineAnimCmd *gUnknown_082FF6C0[]; // This file's functions. void sub_80A64EC(struct Sprite *sprite); void sub_80A653C(struct Sprite *sprite); -void InitAnimLinearTranslation(struct Sprite *sprite); void sub_80A6FB4(struct Sprite *sprite); -void sub_80A6F98(struct Sprite *sprite); void sub_80A7144(struct Sprite *sprite); void sub_80A791C(struct Sprite *sprite); void sub_80A8DFC(struct Sprite *sprite); @@ -50,8 +48,6 @@ void sub_80A7AFC(u8 taskId); void sub_80A8CAC(u8 taskId); void AnimTask_BlendMonInAndOutStep(u8 taskId); bool8 sub_80A7238(void); -void sub_80A8048(s16 *bottom, s16 *top, const void *ptr); -void *sub_80A8050(s16 bottom, s16 top); u8 sub_80A82E4(u8 battlerId); void sub_80A8D78(struct Task *task, u8 taskId); diff --git a/src/fight.c b/src/fight.c index 89fe5900b..c9000fae4 100644 --- a/src/fight.c +++ b/src/fight.c @@ -1,25 +1,42 @@ #include "global.h" #include "battle_anim.h" +#include "gpu_regs.h" +#include "random.h" +#include "task.h" +#include "trig.h" #include "constants/rgb.h" -extern void unc_080B08A0(struct Sprite *); -extern void sub_810CE68(struct Sprite *); -extern void sub_810CEB4(struct Sprite *); -extern void sub_810CEE0(struct Sprite *); -extern void sub_810CF30(struct Sprite *); -extern void sub_810D10C(struct Sprite *); -extern void sub_810D1B4(struct Sprite *); -extern void sub_810D278(struct Sprite *); -extern void sub_810D2E4(struct Sprite *); -extern void sub_810D37C(struct Sprite *); -extern void sub_810D40C(struct Sprite *); -extern void sub_810D4F4(struct Sprite *); -extern void sub_810D608(struct Sprite *); -extern void sub_810D714(struct Sprite *); -extern void sub_810D874(struct Sprite *); -extern void sub_810D984(struct Sprite *); -extern void sub_810DA10(struct Sprite *); -extern void sub_810DA7C(struct Sprite *); +void unc_080B08A0(struct Sprite *); +void sub_810CE68(struct Sprite *); +void sub_810CEB4(struct Sprite *); +void AnimBasicFistOrFoot(struct Sprite *); +void sub_810CF30(struct Sprite *); +void sub_810D10C(struct Sprite *); +void sub_810D1B4(struct Sprite *); +void AnimSpinningKickOrPunch(struct Sprite *); +void AnimStompFoot(struct Sprite *); +void sub_810D37C(struct Sprite *); +void sub_810D40C(struct Sprite *); +void sub_810D4F4(struct Sprite *); +void sub_810D608(struct Sprite *); +void sub_810D714(struct Sprite *); +void sub_810D874(struct Sprite *); +void sub_810D984(struct Sprite *); +void sub_810DA10(struct Sprite *); +void sub_810DA7C(struct Sprite *); +static void sub_810D0B8(struct Sprite *); +static void sub_810D164(struct Sprite *); +static void sub_810D240(struct Sprite *); +static void AnimSpinningKickOrPunchFinish(struct Sprite *); +static void AnimStompFootStep(struct Sprite *); +static void AnimStompFootEnd(struct Sprite *); +static void sub_810D47C(struct Sprite *); +static void sub_810D5DC(struct Sprite *); +static void sub_810D6A8(struct Sprite *); +static void sub_810D770(struct Sprite *); +static void sub_810D830(struct Sprite *); + +extern struct SpriteTemplate gBasicHitSplatSpriteTemplate; const struct SpriteTemplate gUnknown_08595E14 = { @@ -109,7 +126,7 @@ const struct SpriteTemplate gFistFootSpriteTemplate = .anims = gUnknown_08595E54, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_810CEE0, + .callback = AnimBasicFistOrFoot, }; const struct SpriteTemplate gUnknown_08595EB0 = @@ -165,7 +182,7 @@ const struct SpriteTemplate gUnknown_08595F14 = .anims = gUnknown_08595E54, .images = NULL, .affineAnims = gUnknown_08595F10, - .callback = sub_810D278, + .callback = AnimSpinningKickOrPunch, }; const union AffineAnimCmd gUnknown_08595F2C[] = @@ -188,7 +205,7 @@ const struct SpriteTemplate gMegaPunchKickSpriteTemplate = .anims = gUnknown_08595E54, .images = NULL, .affineAnims = gUnknown_08595F44, - .callback = sub_810D278, + .callback = AnimSpinningKickOrPunch, }; const struct SpriteTemplate gUnknown_08595F60 = @@ -199,7 +216,7 @@ const struct SpriteTemplate gUnknown_08595F60 = .anims = gUnknown_08595E58, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_810D2E4, + .callback = AnimStompFoot, }; const struct SpriteTemplate gUnknown_08595F78 = @@ -396,3 +413,623 @@ const struct SpriteTemplate gUnknown_08596104 = .affineAnims = gUnknown_08596100, .callback = sub_810DA7C, }; + +void unc_080B08A0(struct Sprite *sprite) +{ + sub_80A6864(sprite, gBattleAnimArgs[0]); + sprite->pos1.y += gBattleAnimArgs[1]; + sprite->data[0] = 15; + sprite->callback = WaitAnimForDuration; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); +} + +void sub_810CE68(struct Sprite *sprite) +{ + if (gBattleAnimArgs[7] == 1 && GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + { + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + gBattleAnimArgs[3] = -gBattleAnimArgs[3]; + } + + StartSpriteAnim(sprite, gBattleAnimArgs[6]); + gBattleAnimArgs[6] = 0; + sub_80A7938(sprite); +} + +void sub_810CEB4(struct Sprite *sprite) +{ + if (IsContest()) + { + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + gBattleAnimArgs[3] = -gBattleAnimArgs[3]; + } + + sub_810CE68(sprite); +} + +// Displays a basic fist or foot sprite for a given duration. +// Used by many fighting moves (and elemental "punch" moves). +// arg 0: initial x pixel offset +// arg 1: initial y pixel offset +// arg 2: duration +// arg 3: ? (todo: related to initial pixel offsets) +// arg 4: anim num +void AnimBasicFistOrFoot(struct Sprite *sprite) +{ + StartSpriteAnim(sprite, gBattleAnimArgs[4]); + + if (gBattleAnimArgs[3] == 0) + InitAnimSpritePos(sprite, 1); + else + sub_80A6980(sprite, TRUE); + + sprite->data[0] = gBattleAnimArgs[2]; + sprite->callback = WaitAnimForDuration; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); +} + +void sub_810CF30(struct Sprite *sprite) +{ + u8 battler; + s16 xMod, yMod; + s16 x, y; + + if (gBattleAnimArgs[0] == 0) + battler = gBattleAnimAttacker; + else + battler = gBattleAnimTarget; + + if (gBattleAnimArgs[2] < 0) + gBattleAnimArgs[2] = Random2() % 5; + + StartSpriteAnim(sprite, gBattleAnimArgs[2]); + sprite->pos1.x = GetBattlerSpriteCoord(battler, 2); + sprite->pos1.y = GetBattlerSpriteCoord(battler, 3); + + xMod = sub_80A861C(battler, 1) / 2; + yMod = sub_80A861C(battler, 0) / 4; + + x = Random2() % xMod; + y = Random2() % yMod; + + if (Random2() & 1) + x *= -1; + if (Random2() & 1) + y *= -1; + + if ((gBattlerPositions[battler] & BIT_SIDE) == B_SIDE_PLAYER) + y += 0xFFF0; + + sprite->pos1.x += x; + sprite->pos1.y += y; + + sprite->data[0] = gBattleAnimArgs[1]; + sprite->data[7] = CreateSprite(&gBasicHitSplatSpriteTemplate, sprite->pos1.x, sprite->pos1.y, sprite->subpriority + 1); + if (sprite->data[7] != 64) + { + StartSpriteAffineAnim(&gSprites[sprite->data[7]], 0); + gSprites[sprite->data[7]].callback = SpriteCallbackDummy; + } + + sprite->callback = sub_810D0B8; +} + +static void sub_810D0B8(struct Sprite *sprite) +{ + if (sprite->data[0] == 0) + { + if (sprite->data[7] != 64) + { + FreeOamMatrix(gSprites[sprite->data[7]].oam.matrixNum); + DestroySprite(&gSprites[sprite->data[7]]); + } + + DestroyAnimSprite(sprite); + } + else + { + sprite->data[0]--; + } +} + +void sub_810D10C(struct Sprite *sprite) +{ + sub_80A6980(sprite, TRUE); + sprite->data[0] = 30; + + if (gBattleAnimArgs[2] == 0) + { + sprite->data[2] = sprite->pos1.x - 20; + } + else + { + sprite->data[2] = sprite->pos1.x + 20; + sprite->hFlip = 1; + } + + sprite->data[4] = sprite->pos1.y - 20; + sprite->callback = StartAnimLinearTranslation; + StoreSpriteCallbackInData6(sprite, sub_810D164); +} + +static void sub_810D164(struct Sprite *sprite) +{ + if (++sprite->data[5] == 11) + { + sprite->data[2] = sprite->pos1.x - sprite->pos2.x; + sprite->data[4] = sprite->pos1.y - sprite->pos2.y; + sprite->data[0] = 8; + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.y = 0; + sprite->pos2.x = 0; + + sprite->callback = StartAnimLinearTranslation; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); + } +} + +void sub_810D1B4(struct Sprite *sprite) +{ + if (BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget && GetBattlerPosition(gBattleAnimTarget) < B_POSITION_PLAYER_RIGHT) + gBattleAnimArgs[0] *= -1; + + sub_80A6980(sprite, TRUE); + + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + + sprite->data[0] = gBattleAnimArgs[3]; + sprite->data[1] = sprite->pos1.x; + sprite->data[2] = sprite->pos1.x + gBattleAnimArgs[2]; + sprite->data[3] = sprite->pos1.y; + sprite->data[4] = sprite->pos1.y; + + InitAnimLinearTranslation(sprite); + + sprite->data[5] = gBattleAnimArgs[5]; + sprite->data[6] = gBattleAnimArgs[4]; + sprite->data[7] = 0; + + sprite->callback = sub_810D240; +} + +static void sub_810D240(struct Sprite *sprite) +{ + if (!TranslateAnimLinear(sprite)) + { + sprite->pos2.y += Sin(sprite->data[7] >> 8, sprite->data[5]); + sprite->data[7] += sprite->data[6]; + } + else + { + DestroyAnimSprite(sprite); + } +} + +// Animates the spinning, shrinking kick or punch, which then +// reappears at full size. Used by moves such as MOVE_MEGA_PUNCH and MOVE_MEGA_KICK. +// arg 0: initial x pixel offset +// arg 1: initial y pixel offset +// arg 2: anim num +// arg 3: spin duration +void AnimSpinningKickOrPunch(struct Sprite *sprite) +{ + sub_80A6980(sprite, TRUE); + StartSpriteAnim(sprite, gBattleAnimArgs[2]); + sprite->data[0] = gBattleAnimArgs[3]; + + sprite->callback = WaitAnimForDuration; + StoreSpriteCallbackInData6(sprite, AnimSpinningKickOrPunchFinish); +} + +static void AnimSpinningKickOrPunchFinish(struct Sprite *sprite) +{ + StartSpriteAffineAnim(sprite, 0); + sprite->affineAnimPaused = 1; + sprite->data[0] = 20; + + sprite->callback = WaitAnimForDuration; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); +} + +// Animates MOVE_STOMP's foot that slides downward. +// arg 0: initial x pixel offset +// arg 1: initial y pixel offset +// arg 2: initial wait duration +void AnimStompFoot(struct Sprite *sprite) +{ + sub_80A6980(sprite, TRUE); + sprite->data[0] = gBattleAnimArgs[2]; + + sprite->callback = AnimStompFootStep; +} + +static void AnimStompFootStep(struct Sprite *sprite) +{ + if (--sprite->data[0] == -1) + { + sprite->data[0] = 6; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3); + + sprite->callback = StartAnimLinearTranslation; + StoreSpriteCallbackInData6(sprite, AnimStompFootEnd); + } +} + +static void AnimStompFootEnd(struct Sprite *sprite) +{ + sprite->data[0] = 15; + + sprite->callback = WaitAnimForDuration; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); +} + +void sub_810D37C(struct Sprite *sprite) +{ + if (sprite->data[0] == 0) + { + sub_80A6980(sprite, TRUE); + sprite->data[1] = gBattleAnimArgs[2]; + sprite->data[2] = gBattleAnimArgs[3]; + sprite->data[0]++; + } + else + { + sprite->data[4] += sprite->data[1]; + sprite->pos2.x = sprite->data[4] >> 8; + sprite->pos2.y = Sin(sprite->data[3], sprite->data[2]); + sprite->data[3] = (sprite->data[3] + 3) & 0xFF; + + if (sprite->data[3] > 100) + sprite->invisible = sprite->data[3] % 2; + + if (sprite->data[3] > 120) + DestroyAnimSprite(sprite); + } +} + +void sub_810D40C(struct Sprite *sprite) +{ + if (gBattleAnimArgs[0] == 0) + { + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 0); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 1); + } + else + { + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, 0); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimTarget, 1); + } + + sprite->pos1.x += gBattleAnimArgs[1]; + sprite->pos1.y += gBattleAnimArgs[2]; + + sprite->data[0] = 0; + sprite->data[1] = gBattleAnimArgs[3]; + sprite->data[2] = gBattleAnimArgs[4]; + sprite->data[3] = 0; + sprite->callback = sub_810D47C; +} + +static void sub_810D47C(struct Sprite *sprite) +{ + switch (sprite->data[0]) + { + case 0: + if (--sprite->data[1] == 0) + { + if (sprite->data[2] == 0) + DestroyAnimSprite(sprite); + else + sprite->data[0]++; + } + break; + case 1: + if (++sprite->data[1] > 1) + { + sprite->data[1] = 0; + sprite->data[3]++; + if (sprite->data[3] & 1) + sprite->pos2.x = 2; + else + sprite->pos2.x = -2; + } + + if (--sprite->data[2] == 0) + DestroyAnimSprite(sprite); + break; + } +} + +void sub_810D4F4(struct Sprite *sprite) +{ + if (gBattleAnimArgs[0] == 0) + { + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 0) + gBattleAnimArgs[2]; + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 1) + gBattleAnimArgs[3]; + } + else + { + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, 0) + gBattleAnimArgs[2]; + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimTarget, 1) + gBattleAnimArgs[3]; + } + + sprite->oam.tileNum += gBattleAnimArgs[1] * 16; + sprite->data[0] = 0; + + switch (gBattleAnimArgs[1]) + { + case 0: + sprite->data[6] = -3; + sprite->data[7] = -3; + break; + case 1: + sprite->data[6] = 3; + sprite->data[7] = -3; + break; + case 2: + sprite->data[6] = -3; + sprite->data[7] = 3; + break; + case 3: + sprite->data[6] = 3; + sprite->data[7] = 3; + break; + default: + DestroyAnimSprite(sprite); + return; + } + + sprite->callback = sub_810D5DC; +} + +static void sub_810D5DC(struct Sprite *sprite) +{ + sprite->pos1.x += sprite->data[6]; + sprite->pos1.y += sprite->data[7]; + + if (++sprite->data[0] > 40) + DestroyAnimSprite(sprite); +} + +void sub_810D608(struct Sprite *sprite) +{ + if (gBattleAnimArgs[0] == 0) + { + sprite->pos1.x = GetBattlerSpriteCoord(gBattlerAttacker, 2); + sprite->pos1.y = GetBattlerSpriteCoord(gBattlerAttacker, 3); + sprite->oam.priority = sub_80A8328(gBattleAnimAttacker); + sprite->data[7] = gBattleAnimTarget; + } + else + { + sprite->oam.priority = sub_80A8328(gBattleAnimTarget); + sprite->data[7] = gBattleAnimAttacker; + } + + sprite->data[0] = 0; + sprite->data[1] = 12; + sprite->data[2] = 8; + sprite->callback = sub_810D6A8; +} + +static void sub_810D6A8(struct Sprite *sprite) +{ + if (++sprite->data[0] == 180) + { + SetGpuReg(REG_OFFSET_BLDCNT, 0); + + sprite->data[0] = 16; + sprite->data[1] = sprite->pos1.x; + sprite->data[2] = GetBattlerSpriteCoord(sprite->data[7], 2); + sprite->data[3] = sprite->pos1.y; + sprite->data[4] = GetBattlerSpriteCoord(sprite->data[7], 3); + + InitAnimLinearTranslation(sprite); + StoreSpriteCallbackInData6(sprite, move_anim_8074EE0); + sprite->callback = sub_80A6F98; + } +} + +void sub_810D714(struct Sprite *sprite) +{ + sprite->pos1.x = gBattleAnimArgs[0]; + sprite->pos1.y = 120; + + sprite->data[0] = gBattleAnimArgs[3]; + sub_80A8048(&sprite->data[4], &sprite->data[5], (void *)(sprite->pos1.y << 8)); + + sprite->data[6] = gBattleAnimArgs[1]; + sprite->oam.tileNum += gBattleAnimArgs[2] * 4; + + sprite->callback = sub_810D770; +} + +static void sub_810D770(struct Sprite *sprite) +{ + void *var0; + + if (sprite->data[0] != 0) + { + var0 = sub_80A8050(sprite->data[4], sprite->data[5]); + var0 -= sprite->data[6]; + sub_80A8048(&sprite->data[4], &sprite->data[5], var0); + + var0 = (void *)(((intptr_t)var0) >> 8); + sprite->pos1.y = (intptr_t)var0; + if (sprite->pos1.y < -8) + DestroyAnimSprite(sprite); + else + sprite->data[0]--; + } + else + { + s16 pos0 = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); + s16 pos1 = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); + s16 pos2 = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + s16 pos3 = GetBattlerSpriteCoord(gBattleAnimTarget, 3); + + sprite->data[0] = pos2 - pos0; + sprite->data[1] = pos3 - pos1; + sprite->data[2] = sprite->pos1.x << 4; + sprite->data[3] = sprite->pos1.y << 4; + + sprite->callback = sub_810D830; + } +} + +static void sub_810D830(struct Sprite *sprite) +{ + u16 edgeX; + + sprite->data[2] += sprite->data[0]; + sprite->data[3] += sprite->data[1]; + sprite->pos1.x = sprite->data[2] >> 4; + sprite->pos1.y = sprite->data[3] >> 4; + + edgeX = sprite->pos1.x + 8; + if (edgeX > 256 || sprite->pos1.y < -8 || sprite->pos1.y > 120) + DestroyAnimSprite(sprite); +} + +void sub_810D874(struct Sprite *sprite) +{ + u8 battler; + + if (gBattleAnimArgs[0] == 0) + { + sprite->pos1.x = GetBattlerSpriteCoord(gBattlerAttacker, 2); + sprite->pos1.y = GetBattlerSpriteCoord(gBattlerAttacker, 3); + battler = gBattleAnimTarget; + sprite->oam.priority = sub_80A8328(gBattleAnimAttacker); + } + else + { + battler = gBattleAnimAttacker; + sprite->oam.priority = sub_80A8328(gBattleAnimTarget); + } + + if (IsContest()) + sprite->oam.matrixNum |= 0x8; + else if (GetBattlerSide(battler) == B_SIDE_PLAYER) + sprite->oam.matrixNum |= 0x18; + + sprite->data[0] = 16; + sprite->data[1] = sprite->pos1.x; + sprite->data[2] = GetBattlerSpriteCoord(battler, 2); + sprite->data[3] = sprite->pos1.y; + sprite->data[4] = GetBattlerSpriteCoord(battler, 3); + + InitAnimLinearTranslation(sprite); + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); + sprite->callback = sub_80A6F98; +} + +static void sub_810D960(struct Sprite *sprite) +{ + if (sprite->data[0] == sprite->data[4]) + DestroyAnimSprite(sprite); + + sprite->data[0]++; +} + +void sub_810D984(struct Sprite *sprite) +{ + u8 turn; + + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimTarget, 3); + sprite->data[1] = gBattleAnimArgs[3]; + sprite->data[2] = gBattleAnimArgs[0]; + sprite->data[3] = gBattleAnimArgs[1]; + sprite->data[4] = gBattleAnimArgs[2]; + + turn = gAnimMoveTurn; + if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER) + turn++; + + if (turn & 1) + { + sprite->data[2] = -sprite->data[2]; + sprite->data[1]++; + } + + StartSpriteAnim(sprite, sprite->data[1]); + sprite->pos2.x = sprite->data[2]; + sprite->pos2.y = sprite->data[3]; + sprite->callback = sub_810D960; +} + +void sub_810DA10(struct Sprite *sprite) +{ + if (gBattleAnimArgs[2] == 0) + InitAnimSpritePos(sprite, 0); + else + sub_80A6980(sprite, FALSE); + + if (IsContest()) + { + StartSpriteAnim(sprite, 2); + } + else if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + { + StartSpriteAnim(sprite, 1); + } + + sprite->callback = sub_80A67D8; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); +} + +void sub_810DA7C(struct Sprite *sprite) +{ + if (sprite->affineAnimEnded) + { + sprite->data[1] = (sprite->data[1] + 40) & 0xFF; + sprite->pos2.x = Sin(sprite->data[1], 2); + if (++sprite->data[0] > 40) + DestroyAnimSprite(sprite); + } +} + +void sub_810DABC(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + sub_80A6DAC(0); + task->data[8] = gBattleAnimArgs[0]; + task->data[0]++; + break; + case 1: + if (--task->data[8] == -1) + task->data[0]++; + break; + case 2: + default: + task->data[9] += 1280; + break; + } + + task->data[10] += 2816; + + if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER) + gBattle_BG3_X += task->data[9] >> 8; + else + gBattle_BG3_X -= task->data[9] >> 8; + + gBattle_BG3_Y += task->data[10] >> 8; + task->data[9] &= 0xFF; + task->data[10] &= 0xFF; + + if (gBattleAnimArgs[7] == -1) + { + gBattle_BG3_X = 0; + gBattle_BG3_Y = 0; + sub_80A6DAC(1); + DestroyAnimVisualTask(taskId); + } +}