From 15a7b1bc08f89aebae9b52c2047c0d73dc0f0fb0 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Tue, 18 Dec 2018 20:23:07 -0500 Subject: [PATCH 1/4] begin water.s --- asm/water.s | 319 -------------------------------------------------- ld_script.txt | 1 + src/water.c | 119 +++++++++++++++++++ 3 files changed, 120 insertions(+), 319 deletions(-) diff --git a/asm/water.s b/asm/water.s index 693aceddd..04e450565 100644 --- a/asm/water.s +++ b/asm/water.s @@ -5,325 +5,6 @@ .text - thumb_func_start AnimTask_CreateRaindrops -AnimTask_CreateRaindrops: @ 8107188 - push {r4-r6,lr} - lsls r0, 24 - lsrs r0, 24 - adds r6, r0, 0 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r5, r0, r1 - movs r1, 0x8 - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _081071B0 - ldr r1, =gBattleAnimArgs - ldrh r0, [r1] - strh r0, [r5, 0xA] - ldrh r0, [r1, 0x2] - strh r0, [r5, 0xC] - ldrh r0, [r1, 0x4] - strh r0, [r5, 0xE] -_081071B0: - ldrh r0, [r5, 0x8] - adds r0, 0x1 - strh r0, [r5, 0x8] - movs r2, 0x8 - ldrsh r0, [r5, r2] - movs r2, 0xC - ldrsh r1, [r5, r2] - bl __modsi3 - cmp r0, 0x1 - bne _081071F8 - bl Random2 - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xF0 - bl __umodsi3 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl Random2 - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x50 - bl __umodsi3 - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - ldr r0, =gUnknown_08595020 - adds r1, r4, 0 - movs r3, 0x4 - bl CreateSprite -_081071F8: - movs r0, 0x8 - ldrsh r1, [r5, r0] - movs r2, 0xE - ldrsh r0, [r5, r2] - cmp r1, r0 - bne _0810720A - adds r0, r6, 0 - bl DestroyAnimVisualTask -_0810720A: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end AnimTask_CreateRaindrops - - thumb_func_start sub_810721C -sub_810721C: @ 810721C - ldr r1, =sub_8107228 - str r1, [r0, 0x1C] - bx lr - .pool - thumb_func_end sub_810721C - - thumb_func_start sub_8107228 -sub_8107228: @ 8107228 - push {lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x2E] - adds r0, 0x1 - strh r0, [r2, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xD - bgt _08107246 - ldrh r0, [r2, 0x24] - adds r0, 0x1 - strh r0, [r2, 0x24] - ldrh r0, [r2, 0x26] - adds r0, 0x4 - strh r0, [r2, 0x26] -_08107246: - adds r0, r2, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _0810725A - adds r0, r2, 0 - bl DestroySprite -_0810725A: - pop {r0} - bx r0 - thumb_func_end sub_8107228 - - thumb_func_start sub_8107260 -sub_8107260: @ 8107260 - push {r4-r6,lr} - adds r6, r0, 0 - ldr r5, =gBattleAnimAttacker - ldrb r0, [r5] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _08107290 - ldrb r0, [r5] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldr r4, =gBattleAnimArgs - ldrh r1, [r4] - subs r0, r1 - b _081072A2 - .pool -_08107290: - ldrb r0, [r5] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - ldr r4, =gBattleAnimArgs - lsrs r0, 24 - ldrh r1, [r4] - adds r0, r1 -_081072A2: - strh r0, [r6, 0x20] - ldrb r0, [r5] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r4, [r4, 0x2] - adds r0, r4 - strh r0, [r6, 0x22] - adds r2, r6, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _081072D8 - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x4] - negs r0, r0 - strh r0, [r1, 0x4] -_081072D8: - ldr r5, =gBattleAnimArgs - ldrh r0, [r5, 0xC] - strh r0, [r6, 0x2E] - ldrh r0, [r6, 0x20] - strh r0, [r6, 0x30] - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r6, 0x32] - ldrh r0, [r6, 0x22] - strh r0, [r6, 0x34] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r6, 0x36] - adds r0, r6, 0 - bl InitAnimLinearTranslation - ldr r0, =SpriteCallbackDummy - bl CreateInvisibleSpriteWithCallback - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - strh r4, [r6, 0x38] - ldrb r0, [r5, 0x8] - movs r2, 0x4 - ldrsh r1, [r5, r2] - bl Sin - ldrh r1, [r6, 0x20] - subs r1, r0 - strh r1, [r6, 0x20] - ldrb r0, [r5, 0x8] - movs r2, 0x6 - ldrsh r1, [r5, r2] - bl Cos - ldrh r1, [r6, 0x22] - subs r1, r0 - strh r1, [r6, 0x22] - ldr r0, =gSprites - lsls r1, r4, 4 - adds r1, r4 - lsls r1, 2 - adds r1, r0 - ldrh r0, [r5, 0x4] - strh r0, [r1, 0x2E] - ldrh r0, [r5, 0x6] - strh r0, [r1, 0x30] - ldrh r0, [r5, 0xA] - strh r0, [r1, 0x32] - ldrb r0, [r5, 0x8] - lsls r0, 8 - strh r0, [r1, 0x34] - ldrh r0, [r5, 0xC] - strh r0, [r1, 0x36] - ldr r1, =sub_8107380 - str r1, [r6, 0x1C] - adds r0, r6, 0 - bl _call_via_r1 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8107260 - - thumb_func_start sub_8107380 -sub_8107380: @ 8107380 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - adds r5, r0, 0 - ldrh r1, [r5, 0x38] - lsls r1, 24 - lsrs r1, 24 - ldr r2, =gSprites - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r7, r0, r2 - ldrh r4, [r7, 0x36] - lsls r4, 24 - lsrs r4, 24 - ldrh r0, [r7, 0x34] - mov r8, r0 - movs r0, 0x1 - strh r0, [r5, 0x2E] - adds r0, r5, 0 - bl TranslateAnimLinear - mov r1, r8 - lsrs r6, r1, 8 - movs r0, 0x2E - ldrsh r1, [r7, r0] - adds r0, r6, 0 - bl Sin - ldrh r1, [r5, 0x24] - adds r0, r1 - strh r0, [r5, 0x24] - movs r0, 0x30 - ldrsh r1, [r7, r0] - adds r0, r6, 0 - bl Cos - ldrh r1, [r5, 0x26] - adds r0, r1 - strh r0, [r5, 0x26] - ldrh r0, [r7, 0x32] - mov r1, r8 - adds r1, r0 - strh r1, [r7, 0x34] - subs r4, 0x1 - lsls r4, 24 - lsrs r4, 24 - cmp r4, 0 - beq _081073EC - strh r4, [r7, 0x36] - b _081073F6 - .pool -_081073EC: - ldr r0, =sub_8107408 - str r0, [r5, 0x1C] - adds r0, r7, 0 - bl DestroySprite -_081073F6: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8107380 - - thumb_func_start sub_8107408 -sub_8107408: @ 8107408 - push {lr} - adds r3, r0, 0 - adds r3, 0x2C - ldrb r2, [r3] - movs r1, 0x41 - negs r1, r1 - ands r1, r2 - strb r1, [r3] - ldr r1, =RunStoredCallbackWhenAnimEnds - str r1, [r0, 0x1C] - ldr r1, =sub_8107430 - bl StoreSpriteCallbackInData6 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8107408 - thumb_func_start sub_8107430 sub_8107430: @ 8107430 push {lr} diff --git a/ld_script.txt b/ld_script.txt index 4fcd17bce..20750c97d 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -159,6 +159,7 @@ SECTIONS { src/item_use.o(.text); src/battle_anim_effects_1.o(.text); src/battle_anim_effects_2.o(.text); + src/water.o(.text); asm/water.o(.text); src/fire.o(.text); src/electric.o(.text); diff --git a/src/water.c b/src/water.c index 955526ccd..e69e0b54b 100644 --- a/src/water.c +++ b/src/water.c @@ -1,9 +1,20 @@ #include "global.h" +#include "battle.h" #include "battle_anim.h" +#include "random.h" +#include "sprite.h" +#include "task.h" +#include "trig.h" +#include "util.h" +#include "constants/battle.h" #include "constants/rgb.h" extern void sub_810721C(struct Sprite *); +extern void sub_8107228(struct Sprite *); extern void sub_8107260(struct Sprite *); +extern void sub_8107380(struct Sprite *); +extern void sub_8107408(struct Sprite *); +extern void sub_8107430(struct Sprite *); extern void sub_810744C(struct Sprite *); extern void sub_81075EC(struct Sprite *); extern void sub_8107730(struct Sprite *); @@ -440,3 +451,111 @@ const struct SpriteTemplate gUnknown_08595328 = .affineAnims = gUnknown_085952F4, .callback = sub_80A8EE4, }; + +void AnimTask_CreateRaindrops(u8 taskId) +{ + u8 x, y; + + if (gTasks[taskId].data[0] == 0) + { + gTasks[taskId].data[1] = gBattleAnimArgs[0]; + gTasks[taskId].data[2] = gBattleAnimArgs[1]; + gTasks[taskId].data[3] = gBattleAnimArgs[2]; + } + gTasks[taskId].data[0]++; + if (gTasks[taskId].data[0] % gTasks[taskId].data[2] == 1) + { + x = Random2() % 240; + y = Random2() % 80; + CreateSprite(&gUnknown_08595020, x, y, 4); + } + if (gTasks[taskId].data[0] == gTasks[taskId].data[3]) + DestroyAnimVisualTask(taskId); +} + +void sub_810721C(struct Sprite *sprite) +{ + sprite->callback = sub_8107228; +} + +void sub_8107228(struct Sprite *sprite) +{ + if (++sprite->data[0] <= 13) + { + sprite->pos2.x++; + sprite->pos2.y += 4; + } + if (sprite->animEnded != FALSE) + DestroySprite(sprite); +} + +void sub_8107260(struct Sprite *sprite) +{ + u8 spriteId; + + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + { + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2) - gBattleAnimArgs[0]; + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3) + gBattleAnimArgs[1]; + sprite->animPaused = TRUE; + } + else + { + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2) + gBattleAnimArgs[0]; + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3) + gBattleAnimArgs[1]; + sprite->animPaused = TRUE; + } + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + sprite->data[0] = gBattleAnimArgs[6]; + sprite->data[1] = sprite->pos1.x; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + sprite->data[3] = sprite->pos1.y; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3); + InitAnimLinearTranslation(sprite); + spriteId = CreateInvisibleSpriteWithCallback(SpriteCallbackDummy); + sprite->data[5] = spriteId; + sprite->pos1.x -= Sin((u8)gBattleAnimArgs[4], gBattleAnimArgs[2]); + sprite->pos1.y -= Cos((u8)gBattleAnimArgs[4], gBattleAnimArgs[3]); + gSprites[spriteId].data[0] = gBattleAnimArgs[2]; + gSprites[spriteId].data[1] = gBattleAnimArgs[3]; + gSprites[spriteId].data[2] = gBattleAnimArgs[5]; + gSprites[spriteId].data[3] = (u8)gBattleAnimArgs[4] * 256; + gSprites[spriteId].data[4] = gBattleAnimArgs[6]; + sprite->callback = sub_8107380; + sub_8107380(sprite); +} + +void sub_8107380(struct Sprite *sprite) +{ + u8 otherSpriteId = sprite->data[5]; + u8 timer = gSprites[otherSpriteId].data[4]; + u16 trigIndex = gSprites[otherSpriteId].data[3]; + + sprite->data[0] = 1; + TranslateAnimLinear(sprite); + sprite->pos2.x += Sin(trigIndex >> 8, gSprites[otherSpriteId].data[0]); + sprite->pos2.y += Cos(trigIndex >> 8, gSprites[otherSpriteId].data[1]); + gSprites[otherSpriteId].data[3] = trigIndex + gSprites[otherSpriteId].data[2]; + if (--timer != 0) + { + gSprites[otherSpriteId].data[4] = timer; + } + else + { + sprite->callback = sub_8107408; + DestroySprite(&gSprites[otherSpriteId]); + } +} + +/* void FuncNameHere(struct Sprite *sprite) +{ + +} */ + +void sub_8107408(struct Sprite *sprite) +{ + sprite->animPaused = FALSE; + sprite->callback = RunStoredCallbackWhenAnimEnds; + StoreSpriteCallbackInData6(sprite, sub_8107430); +} From cd785011fe66d3c7c0c7348de78e496ee5e407c8 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Wed, 19 Dec 2018 10:31:37 -0500 Subject: [PATCH 2/4] decompiled water --- asm/water.s | 3288 ----------------------------------------- include/battle_anim.h | 3 + include/graphics.h | 7 + ld_script.txt | 1 - src/water.c | 2080 +++++++++++++++++++++++++- 5 files changed, 2083 insertions(+), 3296 deletions(-) delete mode 100644 asm/water.s diff --git a/asm/water.s b/asm/water.s deleted file mode 100644 index 04e450565..000000000 --- a/asm/water.s +++ /dev/null @@ -1,3288 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8107430 -sub_8107430: @ 8107430 - push {lr} - movs r1, 0xA - strh r1, [r0, 0x2E] - ldr r1, =WaitAnimForDuration - str r1, [r0, 0x1C] - ldr r1, =DestroySpriteAndMatrix - bl StoreSpriteCallbackInData6 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8107430 - - thumb_func_start sub_810744C -sub_810744C: @ 810744C - push {r4-r7,lr} - adds r5, r0, 0 - movs r1, 0x1 - bl InitAnimSpritePos - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0810747C - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x4] - negs r0, r0 - lsls r0, 16 - lsrs r6, r0, 16 - adds r7, r1, 0 - b _08107482 - .pool -_0810747C: - ldr r0, =gBattleAnimArgs - ldrh r6, [r0, 0x4] - adds r7, r0, 0 -_08107482: - ldrh r0, [r7, 0x8] - strh r0, [r5, 0x2E] - ldrh r0, [r5, 0x20] - strh r0, [r5, 0x30] - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - adds r0, r6 - strh r0, [r5, 0x32] - ldrh r0, [r5, 0x22] - strh r0, [r5, 0x34] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r7, [r7, 0x6] - adds r0, r7 - strh r0, [r5, 0x36] - adds r0, r5, 0 - bl InitAnimLinearTranslation - ldr r0, =sub_81074E4 - str r0, [r5, 0x1C] - adds r2, r5, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - ldr r1, [r5, 0x1C] - adds r0, r5, 0 - bl _call_via_r1 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810744C - - thumb_func_start sub_81074E4 -sub_81074E4: @ 81074E4 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =gBattleAnimArgs - ldrh r1, [r0, 0xE] - ldr r0, =0x0000ffff - cmp r1, r0 - bne _08107506 - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAnim - adds r2, r4, 0 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2] -_08107506: - adds r0, r4, 0 - bl TranslateAnimLinear - lsls r0, 24 - cmp r0, 0 - beq _08107518 - adds r0, r4, 0 - bl DestroyAnimSprite -_08107518: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81074E4 - - thumb_func_start sub_8107528 -sub_8107528: @ 8107528 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gTasks - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - adds r4, r1 - ldr r0, =gBattleAnimArgs - ldrh r0, [r0] - strh r0, [r4, 0x8] - ldr r0, =0x0000279c - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 20 - movs r1, 0x80 - lsls r1, 1 - adds r0, r1 - strh r0, [r4, 0xC] - ldr r0, =sub_810756C - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8107528 - - thumb_func_start sub_810756C -sub_810756C: @ 810756C - push {r4-r7,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r2, r0, r1 - ldrh r0, [r2, 0x1C] - adds r0, 0x1 - strh r0, [r2, 0x1C] - lsls r0, 16 - asrs r0, 16 - mov r12, r1 - cmp r0, 0x3 - bne _081075BE - movs r0, 0 - strh r0, [r2, 0x1C] - ldrh r0, [r2, 0xC] - adds r0, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - ldr r1, =gPlttBufferFaded - lsls r0, r5, 1 - adds r0, r1 - ldrh r6, [r0] - adds r7, r1, 0 - adds r3, r0, 0x2 - movs r1, 0x6 - adds r2, r0, 0 -_081075A8: - ldrh r0, [r3] - strh r0, [r2] - adds r3, 0x2 - adds r2, 0x2 - subs r1, 0x1 - cmp r1, 0 - bge _081075A8 - adds r0, r5, 0x7 - lsls r0, 1 - adds r0, r7 - strh r6, [r0] -_081075BE: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - add r0, r12 - ldrh r1, [r0, 0x1E] - adds r1, 0x1 - strh r1, [r0, 0x1E] - lsls r1, 16 - asrs r1, 16 - movs r2, 0x8 - ldrsh r0, [r0, r2] - cmp r1, r0 - bne _081075DE - adds r0, r4, 0 - bl DestroyAnimVisualTask -_081075DE: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810756C - - thumb_func_start sub_81075EC -sub_81075EC: @ 81075EC - push {r4,r5,lr} - adds r5, r0, 0 - movs r1, 0x1 - bl InitAnimSpritePos - movs r0, 0x1E - strh r0, [r5, 0x2E] - ldrh r0, [r5, 0x20] - strh r0, [r5, 0x30] - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x32] - ldrh r0, [r5, 0x22] - strh r0, [r5, 0x34] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x36] - adds r0, r5, 0 - bl InitAnimLinearTranslation - movs r0, 0x2E - ldrsh r1, [r5, r0] - movs r0, 0xD2 - lsls r0, 8 - bl __divsi3 - strh r0, [r5, 0x38] - ldr r0, =gBattleAnimArgs - ldrh r2, [r0, 0x6] - strh r2, [r5, 0x3C] - ldrh r1, [r0, 0xE] - movs r3, 0xE - ldrsh r0, [r0, r3] - cmp r0, 0x7F - ble _0810765C - adds r0, r1, 0 - subs r0, 0x7F - lsls r0, 8 - strh r0, [r5, 0x3A] - negs r0, r2 - strh r0, [r5, 0x3C] - b _08107660 - .pool -_0810765C: - lsls r0, r1, 8 - strh r0, [r5, 0x3A] -_08107660: - ldr r1, =sub_8107674 - str r1, [r5, 0x1C] - adds r0, r5, 0 - bl _call_via_r1 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81075EC - - thumb_func_start sub_8107674 -sub_8107674: @ 8107674 - push {r4,lr} - adds r4, r0, 0 - bl TranslateAnimLinear - lsls r0, 24 - cmp r0, 0 - beq _08107688 - adds r0, r4, 0 - bl DestroyAnimSprite -_08107688: - ldrh r0, [r4, 0x3A] - lsls r0, 16 - asrs r0, 24 - movs r2, 0x3C - ldrsh r1, [r4, r2] - bl Sin - ldrh r1, [r4, 0x26] - adds r0, r1 - strh r0, [r4, 0x26] - movs r2, 0x3A - ldrsh r0, [r4, r2] - movs r2, 0x38 - ldrsh r1, [r4, r2] - adds r0, r1 - asrs r0, 8 - cmp r0, 0x7F - ble _081076B8 - movs r0, 0 - strh r0, [r4, 0x3A] - ldrh r0, [r4, 0x3C] - negs r0, r0 - strh r0, [r4, 0x3C] - b _081076C0 -_081076B8: - ldrh r0, [r4, 0x38] - ldrh r1, [r4, 0x3A] - adds r0, r1 - strh r0, [r4, 0x3A] -_081076C0: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8107674 - - thumb_func_start sub_81076C8 -sub_81076C8: @ 81076C8 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r3, =gBattleAnimArgs - ldrh r0, [r3] - movs r2, 0 - strh r0, [r1, 0x8] - strh r2, [r3, 0xE] - ldr r0, =sub_81076F4 - str r0, [r1] - bx lr - .pool - thumb_func_end sub_81076C8 - - thumb_func_start sub_81076F4 -sub_81076F4: @ 81076F4 - push {lr} - lsls r0, 24 - lsrs r3, r0, 24 - ldr r2, =gBattleAnimArgs - ldrh r0, [r2, 0xE] - adds r0, 0x3 - movs r1, 0xFF - ands r0, r1 - strh r0, [r2, 0xE] - ldr r1, =gTasks - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r0, 0x8] - subs r1, 0x1 - strh r1, [r0, 0x8] - lsls r1, 16 - cmp r1, 0 - bne _08107722 - adds r0, r3, 0 - bl DestroyAnimVisualTask -_08107722: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81076F4 - - thumb_func_start sub_8107730 -sub_8107730: @ 8107730 - push {r4-r7,lr} - adds r4, r0, 0 - ldr r7, =gBattleAnimAttacker - ldrb r0, [r7] - movs r1, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x20] - ldrb r0, [r7] - movs r1, 0x1 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x22] - ldr r6, =0x0000fff6 - strh r6, [r4, 0x26] - ldrb r0, [r7] - bl GetBattlerSpriteSubpriority - lsls r0, 24 - lsrs r5, r0, 24 - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _0810778A - ldrb r0, [r7] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _08107784 - movs r0, 0xA - strh r0, [r4, 0x24] - b _0810778C - .pool -_08107784: - strh r6, [r4, 0x24] - subs r0, r5, 0x2 - b _0810778E -_0810778A: - strh r6, [r4, 0x24] -_0810778C: - adds r0, r5, 0x2 -_0810778E: - adds r1, r4, 0 - adds r1, 0x43 - strb r0, [r1] - ldr r0, =sub_81077A4 - str r0, [r4, 0x1C] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8107730 - - thumb_func_start sub_81077A4 -sub_81077A4: @ 81077A4 - push {lr} - adds r2, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _081077BA - adds r0, r2, 0 - bl DestroyAnimSprite -_081077BA: - pop {r0} - bx r0 - thumb_func_end sub_81077A4 - - thumb_func_start sub_81077C0 -sub_81077C0: @ 81077C0 - push {r4-r7,lr} - adds r6, r0, 0 - ldr r5, =gBattleAnimAttacker - ldrb r0, [r5] - bl GetBattlerSide - adds r4, r0, 0 - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - bl GetBattlerSide - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - bne _0810780A - ldr r4, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r4, r1] - negs r0, r0 - strh r0, [r4] - ldrb r0, [r5] - bl GetBattlerPosition - lsls r0, 24 - cmp r0, 0 - beq _08107802 - ldrb r0, [r5] - bl GetBattlerPosition - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0810780A -_08107802: - movs r1, 0 - ldrsh r0, [r4, r1] - negs r0, r0 - strh r0, [r4] -_0810780A: - ldr r5, =gBattleAnimArgs - movs r1, 0xA - ldrsh r0, [r5, r1] - movs r1, 0xFF - lsls r1, 8 - ands r0, r1 - movs r1, 0 - cmp r0, 0 - bne _0810781E - movs r1, 0x1 -_0810781E: - ldrb r0, [r5, 0xA] - movs r7, 0x1 - cmp r0, 0 - bne _08107828 - movs r7, 0x3 -_08107828: - adds r0, r6, 0 - bl InitAnimSpritePos - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _08107842 - ldrh r0, [r5, 0x4] - negs r0, r0 - strh r0, [r5, 0x4] -_08107842: - ldrh r0, [r5, 0x8] - strh r0, [r6, 0x2E] - ldr r4, =gBattleAnimTarget - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r5, 0x4] - adds r0, r1 - strh r0, [r6, 0x32] - ldrb r0, [r4] - adds r1, r7, 0 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - ldrh r5, [r5, 0x6] - adds r0, r5 - strh r0, [r6, 0x36] - ldr r0, =StartAnimLinearTranslation - str r0, [r6, 0x1C] - ldr r1, =DestroyAnimSprite - adds r0, r6, 0 - bl StoreSpriteCallbackInData6 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81077C0 - - thumb_func_start sub_8107894 -sub_8107894: @ 8107894 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x1 - bl sub_80A6980 - ldr r0, =gBattleAnimArgs - ldrh r1, [r0, 0x8] - strh r1, [r4, 0x2E] - ldrh r0, [r0, 0x4] - ldrh r2, [r4, 0x20] - adds r0, r2 - strh r0, [r4, 0x32] - ldrh r0, [r4, 0x22] - adds r1, r0 - strh r1, [r4, 0x36] - ldr r0, =StartAnimLinearTranslation - str r0, [r4, 0x1C] - ldr r1, =DestroyAnimSprite - adds r0, r4, 0 - bl StoreSpriteCallbackInData6 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8107894 - - thumb_func_start sub_81078D0 -sub_81078D0: @ 81078D0 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =gBattleAnimArgs - movs r1, 0x6 - ldrsh r0, [r0, r1] - cmp r0, 0 - beq _081078EC - adds r0, r4, 0 - movs r1, 0x1 - bl sub_80A6980 - b _081078F4 - .pool -_081078EC: - adds r0, r4, 0 - movs r1, 0x1 - bl InitAnimSpritePos -_081078F4: - ldr r0, =gBattleAnimArgs - ldrh r0, [r0, 0x4] - strh r0, [r4, 0x3C] - ldr r0, =sub_810790C - str r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81078D0 - - thumb_func_start sub_810790C -sub_810790C: @ 810790C - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x2E] - adds r0, 0xB - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x2E] - movs r1, 0x2E - ldrsh r0, [r4, r1] - movs r1, 0x4 - bl Sin - strh r0, [r4, 0x24] - ldrh r0, [r4, 0x30] - adds r0, 0x30 - strh r0, [r4, 0x30] - lsls r0, 16 - asrs r0, 24 - negs r0, r0 - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x3C] - subs r0, 0x1 - strh r0, [r4, 0x3C] - lsls r0, 16 - asrs r0, 16 - movs r1, 0x1 - negs r1, r1 - cmp r0, r1 - bne _0810794C - adds r0, r4, 0 - bl DestroyAnimSprite -_0810794C: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_810790C - - thumb_func_start AnimTask_CreateSurfWave -AnimTask_CreateSurfWave: @ 8107954 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - ldr r1, =0x00003f42 - movs r0, 0x50 - bl SetGpuReg - movs r1, 0x80 - lsls r1, 5 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0x1 - movs r1, 0x4 - movs r2, 0x1 - bl SetAnimBgAttribute - movs r0, 0x1 - movs r1, 0 - movs r2, 0x1 - bl SetAnimBgAttribute - mov r0, sp - bl sub_80A6B30 - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _081079E0 - movs r0, 0x1 - movs r1, 0x3 - movs r2, 0x1 - bl SetAnimBgAttribute - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081079D0 - mov r0, sp - ldrb r0, [r0, 0x9] - ldr r1, =gUnknown_08D95E00 - bl sub_80A6D48 - b _081079EA - .pool -_081079D0: - mov r0, sp - ldrb r0, [r0, 0x9] - ldr r1, =gUnknown_08D960D0 - bl sub_80A6D48 - b _081079EA - .pool -_081079E0: - ldr r1, =gUnknown_08D963A4 - mov r0, sp - movs r2, 0x1 - bl sub_80A6D60 -_081079EA: - mov r0, sp - ldrb r0, [r0, 0x9] - ldr r1, =gBattleAnimBackgroundImage_Surf - mov r2, sp - ldrh r2, [r2, 0xA] - bl sub_80A6CC0 - ldr r0, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _08107A24 - ldr r0, =gBattleAnimBackgroundPalette_Surf - mov r1, sp - ldrb r1, [r1, 0x8] - lsls r1, 4 - movs r2, 0x20 - bl LoadCompressedPalette - b _08107A32 - .pool -_08107A24: - ldr r0, =gBattleAnimBackgroundImageMuddyWater_Pal - mov r1, sp - ldrb r1, [r1, 0x8] - lsls r1, 4 - movs r2, 0x20 - bl LoadCompressedPalette -_08107A32: - ldr r0, =sub_8107D58 - ldr r4, =gTasks - mov r2, r10 - lsls r5, r2, 2 - adds r1, r5, r2 - lsls r1, 3 - adds r6, r1, r4 - ldrb r1, [r6, 0x7] - adds r1, 0x1 - lsls r1, 24 - lsrs r1, 24 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r0, 0 - mov r9, r0 - mov r1, r8 - strh r1, [r6, 0x26] - mov r2, r8 - lsls r0, r2, 2 - add r0, r8 - lsls r0, 3 - adds r7, r0, r4 - mov r0, r9 - strh r0, [r7, 0x8] - movs r0, 0x80 - lsls r0, 5 - strh r0, [r7, 0xA] - strh r0, [r7, 0xC] - bl IsContest - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - beq _08107AB4 - ldr r1, =0x0000ffb0 - adds r0, r1, 0 - ldr r2, =gBattle_BG1_X - strh r0, [r2] - adds r1, 0x20 - adds r0, r1, 0 - ldr r2, =gBattle_BG1_Y - strh r0, [r2] - movs r0, 0x2 - strh r0, [r6, 0x8] - movs r0, 0x1 - strh r0, [r6, 0xA] - mov r0, r9 - strh r0, [r7, 0xE] - b _08107B0E - .pool -_08107AB4: - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x1 - bne _08107AF8 - ldr r2, =0x0000ff20 - adds r0, r2, 0 - ldr r2, =gBattle_BG1_X - strh r0, [r2] - movs r2, 0x80 - lsls r2, 1 - adds r0, r2, 0 - ldr r2, =gBattle_BG1_Y - strh r0, [r2] - movs r0, 0x2 - strh r0, [r6, 0x8] - ldr r0, =0x0000ffff - strh r0, [r6, 0xA] - strh r1, [r7, 0xE] - b _08107B0E - .pool -_08107AF8: - ldr r0, =gBattle_BG1_X - strh r4, [r0] - ldr r1, =0x0000ffd0 - adds r0, r1, 0 - ldr r2, =gBattle_BG1_Y - strh r0, [r2] - ldr r0, =0x0000fffe - strh r0, [r6, 0x8] - movs r0, 0x1 - strh r0, [r6, 0xA] - strh r4, [r7, 0xE] -_08107B0E: - ldr r0, =gBattle_BG1_X - ldrh r1, [r0] - movs r0, 0x14 - bl SetGpuReg - ldr r2, =gBattle_BG1_Y - ldrh r1, [r2] - movs r0, 0x16 - bl SetGpuReg - ldr r1, =gTasks - mov r2, r8 - lsls r0, r2, 2 - add r0, r8 - lsls r0, 3 - adds r1, r0, r1 - movs r2, 0xE - ldrsh r0, [r1, r2] - cmp r0, 0 - bne _08107B54 - movs r0, 0x30 - strh r0, [r1, 0x10] - movs r0, 0x70 - b _08107B58 - .pool -_08107B54: - movs r0, 0 - strh r0, [r1, 0x10] -_08107B58: - strh r0, [r1, 0x12] - ldr r1, =gTasks - mov r2, r10 - adds r0, r5, r2 - lsls r0, 3 - adds r0, r1 - movs r1, 0x1 - strh r1, [r0, 0x14] - ldr r1, =sub_8107B84 - str r1, [r0] - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end AnimTask_CreateSurfWave - - thumb_func_start sub_8107B84 -sub_8107B84: @ 8107B84 - push {r4-r7,lr} - sub sp, 0x10 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gBattle_BG1_X - ldr r2, =gBattle_BG1_Y - ldr r0, =gTasks - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - adds r4, r0 - ldrh r0, [r4, 0x8] - ldrh r3, [r1] - adds r0, r3 - strh r0, [r1] - ldrh r0, [r4, 0xA] - ldrh r1, [r2] - adds r0, r1 - strh r0, [r2] - mov r0, sp - bl sub_80A6B30 - ldrh r0, [r4, 0xA] - ldrh r3, [r4, 0xC] - adds r0, r3 - strh r0, [r4, 0xC] - ldrh r0, [r4, 0x12] - adds r0, 0x1 - strh r0, [r4, 0x12] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x4 - bne _08107C18 - ldr r1, =gPlttBufferFaded - mov r0, sp - ldrb r0, [r0, 0x8] - lsls r0, 4 - adds r0, 0x7 - lsls r0, 1 - adds r0, r1 - ldrh r6, [r0] - movs r2, 0x6 - adds r7, r1, 0 - adds r3, r7, 0 - mov r4, sp -_08107BDE: - ldrb r0, [r4, 0x8] - lsls r0, 4 - adds r1, r2, 0x1 - adds r0, r1 - lsls r1, r0, 1 - adds r1, r3 - subs r0, 0x1 - lsls r0, 1 - adds r0, r3 - ldrh r0, [r0] - strh r0, [r1] - subs r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0 - bne _08107BDE - mov r0, sp - ldrb r0, [r0, 0x8] - lsls r0, 4 - adds r0, 0x1 - lsls r0, 1 - adds r0, r7 - strh r6, [r0] - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - strh r2, [r0, 0x12] -_08107C18: - ldr r1, =gTasks - lsls r2, r5, 2 - adds r0, r2, r5 - lsls r0, 3 - adds r3, r0, r1 - ldrh r0, [r3, 0x14] - adds r0, 0x1 - strh r0, [r3, 0x14] - lsls r0, 16 - asrs r0, 16 - adds r4, r1, 0 - adds r6, r2, 0 - cmp r0, 0x1 - ble _08107C86 - movs r0, 0 - strh r0, [r3, 0x14] - ldrh r0, [r3, 0xE] - adds r2, r0, 0x1 - strh r2, [r3, 0xE] - lsls r0, r2, 16 - asrs r0, 16 - cmp r0, 0xD - bgt _08107C62 - movs r1, 0x26 - ldrsh r0, [r3, r1] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r4 - movs r0, 0x10 - subs r0, r2 - lsls r0, 8 - orrs r2, r0 - strh r2, [r1, 0xA] - ldrh r0, [r3, 0x10] - adds r0, 0x1 - strh r0, [r3, 0x10] -_08107C62: - movs r1, 0xE - ldrsh r0, [r3, r1] - cmp r0, 0x36 - ble _08107C86 - ldrh r2, [r3, 0x10] - subs r2, 0x1 - strh r2, [r3, 0x10] - movs r1, 0x26 - ldrsh r0, [r3, r1] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r4 - movs r0, 0x10 - subs r0, r2 - lsls r0, 8 - orrs r2, r0 - strh r2, [r1, 0xA] -_08107C86: - adds r0, r6, r5 - lsls r0, 3 - adds r2, r0, r4 - movs r3, 0x26 - ldrsh r1, [r2, r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r4 - ldrh r0, [r0, 0xA] - movs r3, 0x1F - ands r3, r0 - cmp r3, 0 - bne _08107CA8 - strh r3, [r2, 0x8] - ldr r0, =sub_8107CC4 - str r0, [r2] -_08107CA8: - add sp, 0x10 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8107B84 - - thumb_func_start sub_8107CC4 -sub_8107CC4: @ 8107CC4 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r0, 24 - adds r5, r0, 0 - ldr r7, =gBattle_BG1_X - ldr r0, =gBattle_BG1_Y - mov r8, r0 - ldr r6, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r4, r0, r6 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _08107D08 - movs r0, 0x1 - bl sub_80A6C68 - movs r0, 0x2 - bl sub_80A6C68 - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08107D4A - .pool -_08107D08: - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _08107D1C - movs r0, 0x1 - movs r1, 0x3 - movs r2, 0 - bl SetAnimBgAttribute -_08107D1C: - movs r0, 0 - strh r0, [r7] - mov r1, r8 - strh r0, [r1] - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x26 - ldrsh r1, [r4, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r6 - ldr r1, =0x0000ffff - strh r1, [r0, 0x26] - adds r0, r5, 0 - bl DestroyAnimVisualTask -_08107D4A: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8107CC4 - - thumb_func_start sub_8107D58 -sub_8107D58: @ 8107D58 - push {r4-r7,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r7, r0, 24 - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - bne _08107D74 - b _08107EAC -_08107D74: - cmp r0, 0x1 - bgt _08107D84 - cmp r0, 0 - beq _08107D8C - b _08108022 - .pool -_08107D84: - cmp r0, 0x2 - bne _08107D8A - b _08107F78 -_08107D8A: - b _08108022 -_08107D8C: - movs r3, 0 - movs r2, 0x10 - ldrsh r0, [r4, r2] - ldr r1, =gScanlineEffectRegBuffers - mov r12, r1 - cmp r3, r0 - bge _08107DCA - mov r7, r12 - movs r5, 0xF0 - lsls r5, 3 - add r5, r12 - ldr r6, =0x0000ffff -_08107DA4: - lsls r2, r3, 16 - asrs r2, 16 - lsls r1, r2, 1 - adds r3, r1, r7 - adds r1, r5 - ldrh r0, [r4, 0xC] - strh r0, [r1] - ldrh r1, [r4, 0xC] - adds r0, r6, 0 - ands r0, r1 - strh r0, [r3] - adds r2, 0x1 - lsls r2, 16 - lsrs r3, r2, 16 - asrs r2, 16 - movs r1, 0x10 - ldrsh r0, [r4, r1] - cmp r2, r0 - blt _08107DA4 -_08107DCA: - ldrh r3, [r4, 0x10] - lsls r2, r3, 16 - asrs r1, r2, 16 - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bge _08107E04 - ldr r5, =gScanlineEffectRegBuffers - movs r0, 0xF0 - lsls r0, 3 - adds r6, r5, r0 - ldr r7, =0x0000ffff -_08107DE2: - asrs r2, 16 - lsls r1, r2, 1 - adds r3, r1, r5 - adds r1, r6 - ldrh r0, [r4, 0xA] - strh r0, [r1] - ldrh r1, [r4, 0xA] - adds r0, r7, 0 - ands r0, r1 - strh r0, [r3] - adds r2, 0x1 - lsls r2, 16 - asrs r1, r2, 16 - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - blt _08107DE2 -_08107E04: - ldrh r3, [r4, 0x12] - lsls r2, r3, 16 - asrs r0, r2, 16 - cmp r0, 0x9F - bgt _08107E3A - ldr r5, =gScanlineEffectRegBuffers - movs r0, 0xF0 - lsls r0, 3 - adds r6, r5, r0 - ldr r7, =0x0000ffff -_08107E18: - asrs r2, 16 - lsls r1, r2, 1 - adds r3, r1, r5 - adds r1, r6 - ldrh r0, [r4, 0xC] - strh r0, [r1] - ldrh r1, [r4, 0xC] - adds r0, r7, 0 - ands r0, r1 - strh r0, [r3] - adds r2, 0x1 - lsls r2, 16 - lsrs r3, r2, 16 - lsls r2, r3, 16 - asrs r0, r2, 16 - cmp r0, 0x9F - ble _08107E18 -_08107E3A: - movs r1, 0x10 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _08107E64 - lsls r0, r3, 16 - asrs r0, 15 - mov r3, r12 - adds r2, r0, r3 - movs r1, 0xF0 - lsls r1, 3 - add r1, r12 - adds r0, r1 - ldrh r1, [r4, 0xA] - strh r1, [r0] - ldrh r0, [r4, 0xA] - b _08107E7A - .pool -_08107E64: - lsls r0, r3, 16 - asrs r0, 15 - mov r1, r12 - adds r2, r0, r1 - movs r1, 0xF0 - lsls r1, 3 - add r1, r12 - adds r0, r1 - ldrh r1, [r4, 0xC] - strh r1, [r0] - ldrh r0, [r4, 0xC] -_08107E7A: - strh r0, [r2] - ldr r0, =0x04000052 - str r0, [sp] - ldr r0, =0xa2600001 - str r0, [sp, 0x4] - mov r1, sp - movs r2, 0 - movs r0, 0x1 - strb r0, [r1, 0x8] - mov r0, sp - strb r2, [r0, 0x9] - ldr r0, [sp] - ldr r1, [sp, 0x4] - ldr r2, [sp, 0x8] - bl ScanlineEffect_SetParams - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08108022 - .pool -_08107EAC: - movs r2, 0xE - ldrsh r1, [r4, r2] - cmp r1, 0 - bne _08107EC4 - ldrh r0, [r4, 0x10] - subs r0, 0x1 - strh r0, [r4, 0x10] - lsls r0, 16 - cmp r0, 0 - bgt _08107ED8 - strh r1, [r4, 0x10] - b _08107ED2 -_08107EC4: - ldrh r0, [r4, 0x12] - adds r0, 0x1 - strh r0, [r4, 0x12] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x6F - ble _08107ED8 -_08107ED2: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] -_08107ED8: - movs r3, 0 - movs r1, 0x10 - ldrsh r0, [r4, r1] - cmp r3, r0 - bge _08107F0C - ldr r6, =gScanlineEffectRegBuffers - ldr r5, =gScanlineEffect -_08107EE6: - lsls r1, r3, 16 - asrs r1, 16 - lsls r3, r1, 1 - ldrb r2, [r5, 0x14] - lsls r0, r2, 4 - subs r0, r2 - lsls r0, 7 - adds r3, r0 - adds r3, r6 - ldrh r0, [r4, 0xC] - strh r0, [r3] - adds r1, 0x1 - lsls r1, 16 - lsrs r3, r1, 16 - asrs r1, 16 - movs r2, 0x10 - ldrsh r0, [r4, r2] - cmp r1, r0 - blt _08107EE6 -_08107F0C: - ldrh r3, [r4, 0x10] - lsls r2, r3, 16 - asrs r1, r2, 16 - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bge _08107F40 - ldr r6, =gScanlineEffectRegBuffers - ldr r5, =gScanlineEffect -_08107F1E: - asrs r3, r2, 16 - lsls r2, r3, 1 - ldrb r1, [r5, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - adds r2, r6 - ldrh r0, [r4, 0xA] - strh r0, [r2] - adds r3, 0x1 - lsls r2, r3, 16 - asrs r1, r2, 16 - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - blt _08107F1E -_08107F40: - ldrh r3, [r4, 0x12] - lsls r1, r3, 16 - asrs r0, r1, 16 - cmp r0, 0x9F - bgt _08108022 - ldr r6, =gScanlineEffectRegBuffers - ldr r5, =gScanlineEffect -_08107F4E: - asrs r3, r1, 16 - lsls r2, r3, 1 - ldrb r1, [r5, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - adds r2, r6 - ldrh r0, [r4, 0xC] - strh r0, [r2] - adds r3, 0x1 - lsls r1, r3, 16 - asrs r0, r1, 16 - cmp r0, 0x9F - ble _08107F4E - b _08108022 - .pool -_08107F78: - movs r3, 0 - movs r1, 0x10 - ldrsh r0, [r4, r1] - cmp r3, r0 - bge _08107FAC - ldr r6, =gScanlineEffectRegBuffers - ldr r5, =gScanlineEffect -_08107F86: - lsls r1, r3, 16 - asrs r1, 16 - lsls r3, r1, 1 - ldrb r2, [r5, 0x14] - lsls r0, r2, 4 - subs r0, r2 - lsls r0, 7 - adds r3, r0 - adds r3, r6 - ldrh r0, [r4, 0xC] - strh r0, [r3] - adds r1, 0x1 - lsls r1, 16 - lsrs r3, r1, 16 - asrs r1, 16 - movs r2, 0x10 - ldrsh r0, [r4, r2] - cmp r1, r0 - blt _08107F86 -_08107FAC: - ldrh r3, [r4, 0x10] - lsls r2, r3, 16 - asrs r1, r2, 16 - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bge _08107FE0 - ldr r6, =gScanlineEffectRegBuffers - ldr r5, =gScanlineEffect -_08107FBE: - asrs r3, r2, 16 - lsls r2, r3, 1 - ldrb r1, [r5, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - adds r2, r6 - ldrh r0, [r4, 0xA] - strh r0, [r2] - adds r3, 0x1 - lsls r2, r3, 16 - asrs r1, r2, 16 - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - blt _08107FBE -_08107FE0: - ldrh r3, [r4, 0x12] - lsls r1, r3, 16 - asrs r0, r1, 16 - cmp r0, 0x9F - bgt _0810800C - ldr r6, =gScanlineEffectRegBuffers - ldr r5, =gScanlineEffect -_08107FEE: - asrs r3, r1, 16 - lsls r2, r3, 1 - ldrb r1, [r5, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - adds r2, r6 - ldrh r0, [r4, 0xC] - strh r0, [r2] - adds r3, 0x1 - lsls r1, r3, 16 - asrs r0, r1, 16 - cmp r0, 0x9F - ble _08107FEE -_0810800C: - movs r0, 0x26 - ldrsh r1, [r4, r0] - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - bne _08108022 - bl ScanlineEffect_Stop - adds r0, r7, 0 - bl DestroyTask -_08108022: - add sp, 0xC - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8107D58 - - thumb_func_start sub_8108034 -sub_8108034: @ 8108034 - push {r4-r6,lr} - adds r4, r0, 0 - ldrh r2, [r4, 0x4] - lsls r1, r2, 22 - lsrs r1, 22 - adds r1, 0x8 - ldr r3, =0x000003ff - adds r0, r3, 0 - ands r1, r0 - ldr r0, =0xfffffc00 - ands r0, r2 - orrs r0, r1 - strh r0, [r4, 0x4] - adds r0, r4, 0 - movs r1, 0x1 - bl sub_80A6980 - bl Random2 - movs r5, 0xFF - ands r5, r0 - movs r0, 0x80 - lsls r0, 1 - adds r6, r0, 0 - orrs r5, r6 - bl Random2 - ldr r1, =0x000001ff - ands r1, r0 - adds r0, r1, 0 - cmp r0, 0xFF - ble _0810807A - subs r0, r6, r0 - lsls r0, 16 - lsrs r1, r0, 16 -_0810807A: - strh r5, [r4, 0x30] - strh r1, [r4, 0x32] - ldr r0, =sub_8108098 - str r0, [r4, 0x1C] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8108034 - - thumb_func_start sub_8108098 -sub_8108098: @ 8108098 - push {r4,lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x30] - ldrh r1, [r2, 0x34] - adds r3, r0, r1 - strh r3, [r2, 0x34] - ldrh r1, [r2, 0x32] - ldrh r4, [r2, 0x36] - adds r1, r4 - strh r1, [r2, 0x36] - movs r1, 0x1 - ands r1, r0 - cmp r1, 0 - beq _081080BC - lsls r0, r3, 16 - asrs r0, 24 - negs r0, r0 - b _081080C0 -_081080BC: - lsls r0, r3, 16 - asrs r0, 24 -_081080C0: - strh r0, [r2, 0x24] - ldrh r0, [r2, 0x36] - lsls r0, 16 - asrs r0, 24 - strh r0, [r2, 0x26] - ldrh r0, [r2, 0x2E] - adds r0, 0x1 - strh r0, [r2, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x15 - bne _081080DE - adds r0, r2, 0 - bl DestroyAnimSprite -_081080DE: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8108098 - - thumb_func_start sub_81080E4 -sub_81080E4: @ 81080E4 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r0, =gTasks - adds r4, r0 - movs r0, 0 - bl GetAnimBattlerSpriteId - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x26] - ldr r2, =gSprites - movs r0, 0x26 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r0, [r0, 0x22] - strh r0, [r4, 0x12] - bl sub_8108384 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0xA] - ldrh r0, [r4, 0x26] - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl PrepareBattlerSpriteForRotScale - ldr r0, =sub_8108140 - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81080E4 - - thumb_func_start sub_8108140 -sub_8108140: @ 8108140 - push {r4-r6,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x7 - bls _0810815C - b _0810837A -_0810815C: - lsls r0, 2 - ldr r1, =_08108170 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08108170: - .4byte _08108190 - .4byte _081081B6 - .4byte _08108248 - .4byte _0810827E - .4byte _08108292 - .4byte _081082A0 - .4byte _08108320 - .4byte _0810836C -_08108190: - ldrh r1, [r4, 0x26] - lsls r1, 24 - lsrs r1, 24 - movs r3, 0x80 - lsls r3, 1 - movs r0, 0xE0 - str r0, [sp] - movs r0, 0x80 - lsls r0, 2 - str r0, [sp, 0x4] - movs r0, 0x20 - str r0, [sp, 0x8] - adds r0, r4, 0 - adds r2, r3, 0 - bl sub_80A805C - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] -_081081B6: - ldrh r0, [r4, 0xE] - adds r0, 0x1 - strh r0, [r4, 0xE] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _08108212 - movs r0, 0 - strh r0, [r4, 0xE] - ldrh r0, [r4, 0x10] - adds r0, 0x1 - strh r0, [r4, 0x10] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08108200 - ldr r2, =gSprites - movs r0, 0x26 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0x3 - strh r1, [r0, 0x24] - movs r0, 0x26 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x22] - adds r1, 0x1 - strh r1, [r0, 0x22] - b _08108212 - .pool -_08108200: - ldr r2, =gSprites - movs r0, 0x26 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldr r1, =0x0000fffd - strh r1, [r0, 0x24] -_08108212: - adds r0, r4, 0 - bl sub_80A80C8 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - beq _08108222 - b _0810837A -_08108222: - ldrh r0, [r4, 0x26] - lsls r0, 24 - lsrs r0, 24 - bl SetBattlerSpriteYOffsetFromYScale - ldr r2, =gSprites - movs r0, 0x26 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r5, [r0, 0x24] - strh r5, [r4, 0xE] - b _0810835C - .pool -_08108248: - ldrh r0, [r4, 0xE] - adds r0, 0x1 - strh r0, [r4, 0xE] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x4 - bgt _08108258 - b _0810837A -_08108258: - ldrh r1, [r4, 0x26] - lsls r1, 24 - lsrs r1, 24 - movs r3, 0x80 - lsls r3, 2 - movs r0, 0xC0 - lsls r0, 1 - str r0, [sp] - movs r0, 0xE0 - str r0, [sp, 0x4] - movs r0, 0x8 - str r0, [sp, 0x8] - adds r0, r4, 0 - movs r2, 0xE0 - bl sub_80A805C - movs r0, 0 - strh r0, [r4, 0xE] - b _0810835E -_0810827E: - adds r0, r4, 0 - bl sub_80A80C8 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - bne _0810837A - strh r0, [r4, 0xE] - strh r0, [r4, 0x10] - b _0810835E -_08108292: - adds r0, r4, 0 - adds r1, r2, 0 - bl sub_8108408 - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] -_081082A0: - ldrh r0, [r4, 0xE] - adds r0, 0x1 - strh r0, [r4, 0xE] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _0810837A - movs r0, 0 - strh r0, [r4, 0xE] - ldrh r0, [r4, 0x10] - adds r0, 0x1 - strh r0, [r4, 0x10] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081082D8 - ldr r2, =gSprites - movs r0, 0x26 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x26] - adds r1, 0x2 - b _081082EA - .pool -_081082D8: - ldr r2, =gSprites - movs r0, 0x26 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x26] - subs r1, 0x2 -_081082EA: - strh r1, [r0, 0x26] - movs r1, 0x10 - ldrsh r0, [r4, r1] - cmp r0, 0xA - bne _0810837A - ldrh r1, [r4, 0x26] - lsls r1, 24 - lsrs r1, 24 - movs r2, 0xC0 - lsls r2, 1 - movs r0, 0x80 - lsls r0, 1 - str r0, [sp] - str r0, [sp, 0x4] - movs r0, 0x8 - str r0, [sp, 0x8] - adds r0, r4, 0 - movs r3, 0xE0 - bl sub_80A805C - movs r0, 0 - strh r0, [r4, 0xE] - strh r0, [r4, 0x10] - b _0810835E - .pool -_08108320: - ldr r6, =gSprites - movs r0, 0x26 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - ldrh r1, [r0, 0x22] - subs r1, 0x1 - strh r1, [r0, 0x22] - adds r0, r4, 0 - bl sub_80A80C8 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - bne _0810837A - ldrh r0, [r4, 0x26] - lsls r0, 24 - lsrs r0, 24 - bl ResetSpriteRotScale - movs r0, 0x26 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - ldrh r1, [r4, 0x12] - strh r1, [r0, 0x22] -_0810835C: - strh r5, [r4, 0x10] -_0810835E: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _0810837A - .pool -_0810836C: - movs r1, 0xC - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _0810837A - adds r0, r2, 0 - bl DestroyAnimVisualTask -_0810837A: - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8108140 - - thumb_func_start sub_8108384 -sub_8108384: @ 8108384 - push {r4,r5,lr} - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _081083B8 - ldr r1, =gBattlerPartyIndexes - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, =gPlayerParty - b _081083C8 - .pool -_081083B4: - adds r0, r2, 0 - b _081083FA -_081083B8: - ldr r1, =gBattlerPartyIndexes - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, =gEnemyParty -_081083C8: - adds r5, r1, r0 - adds r0, r5, 0 - movs r1, 0x3A - bl GetMonData - adds r4, r0, 0 - lsls r4, 16 - adds r0, r5, 0 - movs r1, 0x39 - bl GetMonData - lsls r0, 16 - lsrs r3, r0, 16 - lsrs r4, 18 - movs r2, 0 -_081083E6: - adds r1, r2, 0x1 - adds r0, r4, 0 - muls r0, r1 - cmp r3, r0 - blt _081083B4 - lsls r0, r1, 24 - lsrs r2, r0, 24 - cmp r2, 0x2 - bls _081083E6 - movs r0, 0x3 -_081083FA: - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8108384 - - thumb_func_start sub_8108408 -sub_8108408: @ 8108408 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - adds r7, r0, 0 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp] - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r6, r0, 24 - movs r5, 0xAC - ldrb r0, [r4] - bl GetBattlerSpriteSubpriority - subs r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x8] - ldrh r1, [r7, 0xA] - movs r0, 0x4 - subs r0, r1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r0, 0 - bgt _08108458 - movs r1, 0x1 -_08108458: - movs r0, 0 - str r0, [sp, 0x4] - lsls r0, r1, 16 - mov r10, r8 - mov r9, r6 - mov r1, r10 - lsls r1, 4 - str r1, [sp, 0xC] - mov r1, r9 - lsls r1, 4 - str r1, [sp, 0x10] - asrs r0, 16 - mov r8, r0 -_08108472: - ldr r0, =gUnknown_08595268 - mov r1, r10 - mov r2, r9 - ldr r3, [sp, 0x8] - bl CreateSprite - lsls r0, 24 - lsrs r2, r0, 24 - lsls r6, r5, 16 - cmp r2, 0x40 - beq _081084DA - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r5, r0, r1 - mov r0, sp - ldrh r0, [r0, 0x4] - strh r0, [r5, 0x30] - mov r1, sp - ldrh r1, [r1, 0xC] - strh r1, [r5, 0x32] - mov r0, sp - ldrh r0, [r0, 0x10] - strh r0, [r5, 0x34] - asrs r4, r6, 16 - adds r0, r4, 0 - movs r1, 0x40 - bl Cos - strh r0, [r5, 0x36] - adds r0, r4, 0 - movs r1, 0x40 - bl Sin - strh r0, [r5, 0x38] - mov r1, sp - ldrh r1, [r1] - strh r1, [r5, 0x3A] - movs r0, 0x2 - strh r0, [r5, 0x3C] - ldrh r1, [r7, 0xC] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081084D4 - adds r0, r5, 0 - bl sub_810851C -_081084D4: - ldrh r0, [r7, 0xC] - adds r0, 0x1 - strh r0, [r7, 0xC] -_081084DA: - mov r1, r8 - lsls r0, r1, 1 - asrs r1, r6, 16 - adds r1, r0 - lsls r1, 16 - movs r0, 0xFF - lsls r0, 16 - ands r0, r1 - lsrs r5, r0, 16 - ldr r1, [sp, 0x4] - lsls r0, r1, 16 - asrs r0, 16 - add r0, r8 - lsls r0, 16 - lsrs r1, r0, 16 - str r1, [sp, 0x4] - asrs r0, 16 - cmp r0, 0x13 - ble _08108472 - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8108408 - - thumb_func_start sub_810851C -sub_810851C: @ 810851C - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _0810852E - cmp r0, 0x1 - beq _08108564 - b _081085BE -_0810852E: - movs r2, 0x30 - ldrsh r0, [r4, r2] - movs r1, 0x6 - bl __modsi3 - lsls r0, 16 - asrs r0, 16 - lsls r1, r0, 1 - adds r1, r0 - ldrh r0, [r4, 0x36] - adds r1, r0 - strh r1, [r4, 0x36] - movs r1, 0x30 - ldrsh r0, [r4, r1] - movs r1, 0x3 - bl __modsi3 - lsls r0, 16 - asrs r0, 16 - lsls r1, r0, 1 - adds r1, r0 - ldrh r2, [r4, 0x38] - adds r1, r2 - strh r1, [r4, 0x38] - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] -_08108564: - ldrh r0, [r4, 0x36] - ldrh r1, [r4, 0x32] - adds r0, r1 - strh r0, [r4, 0x32] - ldrh r1, [r4, 0x38] - ldrh r2, [r4, 0x34] - adds r1, r2 - strh r1, [r4, 0x34] - lsls r0, 16 - asrs r0, 20 - strh r0, [r4, 0x20] - lsls r1, 16 - asrs r2, r1, 20 - strh r2, [r4, 0x22] - adds r0, 0x8 - lsls r0, 16 - movs r1, 0x80 - lsls r1, 17 - cmp r0, r1 - bhi _0810859A - adds r1, r2, 0 - movs r0, 0x8 - negs r0, r0 - cmp r1, r0 - blt _0810859A - cmp r1, 0x78 - ble _081085BE -_0810859A: - ldr r3, =gTasks - movs r0, 0x3C - ldrsh r1, [r4, r0] - lsls r1, 1 - movs r0, 0x3A - ldrsh r2, [r4, r0] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r1, r0 - adds r3, 0x8 - adds r1, r3 - ldrh r0, [r1] - subs r0, 0x1 - strh r0, [r1] - adds r0, r4, 0 - bl DestroySprite -_081085BE: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810851C - - thumb_func_start sub_81085C8 -sub_81085C8: @ 81085C8 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks - adds r4, r1, r0 - bl sub_8108384 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0xA] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - bne _08108600 - movs r0, 0x88 - strh r0, [r4, 0x10] - movs r0, 0x28 - b _08108606 - .pool -_08108600: - movs r0, 0x10 - strh r0, [r4, 0x10] - movs r0, 0x50 -_08108606: - strh r0, [r4, 0x14] - movs r0, 0x62 - strh r0, [r4, 0x12] - ldrh r0, [r4, 0x10] - adds r0, 0x31 - strh r0, [r4, 0x16] - movs r0, 0xA - ldrsh r1, [r4, r0] - lsls r0, r1, 2 - adds r0, r1 - adds r0, 0x5 - strh r0, [r4, 0x20] - ldr r0, =sub_810862C - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81085C8 - - thumb_func_start sub_810862C -sub_810862C: @ 810862C - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r1, r0, 24 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - ldr r7, =gTasks - adds r4, r0, r7 - movs r0, 0x8 - ldrsh r2, [r4, r0] - cmp r2, 0 - beq _08108654 - cmp r2, 0x1 - beq _08108704 - b _08108712 - .pool -_08108654: - ldrh r0, [r4, 0xC] - adds r0, 0x1 - strh r0, [r4, 0xC] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x2 - ble _0810866A - strh r2, [r4, 0xC] - adds r0, r4, 0 - bl sub_810871C -_0810866A: - movs r1, 0x1C - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _081086E4 - movs r2, 0x22 - ldrsh r0, [r4, r2] - cmp r0, 0 - bne _081086E4 - ldr r5, =gBattleAnimArgs - movs r1, 0x1 - mov r8, r1 - mov r2, r8 - strh r2, [r5] - strh r0, [r5, 0x2] - movs r0, 0xC - strh r0, [r5, 0x4] - ldr r6, =sub_81152DC - adds r0, r6, 0 - movs r1, 0x50 - bl CreateTask - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xFF - beq _081086B4 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r0, r7 - ldr r1, [r0] - adds r0, r2, 0 - bl _call_via_r1 - ldr r1, =gAnimVisualTaskCount - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_081086B4: - movs r0, 0x3 - strh r0, [r5] - adds r0, r6, 0 - movs r1, 0x50 - bl CreateTask - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xFF - beq _081086E0 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r0, r7 - ldr r1, [r0] - adds r0, r2, 0 - bl _call_via_r1 - ldr r1, =gAnimVisualTaskCount - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_081086E0: - mov r0, r8 - strh r0, [r4, 0x22] -_081086E4: - movs r2, 0x1E - ldrsh r1, [r4, r2] - movs r2, 0x20 - ldrsh r0, [r4, r2] - cmp r1, r0 - blt _08108712 - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08108712 - .pool -_08108704: - movs r2, 0x1A - ldrsh r0, [r4, r2] - cmp r0, 0 - bne _08108712 - adds r0, r1, 0 - bl DestroyAnimVisualTask -_08108712: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_810862C - - thumb_func_start sub_810871C -sub_810871C: @ 810871C - push {r4-r6,lr} - adds r4, r0, 0 - lsls r1, 24 - lsrs r6, r1, 24 - ldr r1, =gSineTable - movs r2, 0x18 - ldrsh r0, [r4, r2] - lsls r0, 1 - adds r0, r1 - movs r1, 0 - ldrsh r0, [r0, r1] - adds r0, 0x3 - asrs r0, 4 - ldrh r2, [r4, 0x14] - adds r0, r2 - lsls r0, 16 - lsrs r5, r0, 16 - ldr r0, =gUnknown_08595268 - movs r2, 0x16 - ldrsh r1, [r4, r2] - movs r2, 0 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x40 - beq _08108776 - ldr r3, =gSprites - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r3, 0 - adds r1, 0x1C - adds r1, r0, r1 - ldr r2, =sub_81087C0 - str r2, [r1] - adds r0, r3 - strh r5, [r0, 0x38] - strh r6, [r0, 0x3A] - movs r1, 0x9 - strh r1, [r0, 0x3C] - ldrh r0, [r4, 0x1A] - adds r0, 0x1 - strh r0, [r4, 0x1A] -_08108776: - ldrh r0, [r4, 0x1E] - adds r0, 0x1 - strh r0, [r4, 0x1E] - ldrh r0, [r4, 0x18] - adds r0, 0x27 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x18] - movs r0, 0x16 - ldrsh r1, [r4, r0] - ldr r0, =0x41c64e6d - muls r0, r1 - ldr r1, =0x00003039 - adds r0, r1 - movs r2, 0x12 - ldrsh r1, [r4, r2] - bl __modsi3 - ldrh r1, [r4, 0x10] - adds r1, r0 - strh r1, [r4, 0x16] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810871C - - thumb_func_start sub_81087C0 -sub_81087C0: @ 81087C0 - push {r4,r5,lr} - adds r5, r0, 0 - movs r1, 0x2E - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _08108856 - ldrh r0, [r5, 0x22] - adds r0, 0x8 - strh r0, [r5, 0x22] - lsls r0, 16 - asrs r0, 16 - movs r2, 0x38 - ldrsh r1, [r5, r2] - cmp r0, r1 - blt _08108856 - ldr r2, =gTasks - movs r3, 0x3A - ldrsh r1, [r5, r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - movs r1, 0x1 - strh r1, [r0, 0x1C] - ldr r0, =gUnknown_08597388 - movs r2, 0x20 - ldrsh r1, [r5, r2] - movs r3, 0x22 - ldrsh r2, [r5, r3] - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x30] - cmp r0, 0x40 - beq _08108850 - movs r0, 0x30 - ldrsh r1, [r5, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r4, =gSprites - adds r0, r4 - movs r1, 0x3 - bl StartSpriteAffineAnim - movs r2, 0x30 - ldrsh r1, [r5, r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrh r1, [r5, 0x3A] - strh r1, [r0, 0x3A] - movs r3, 0x30 - ldrsh r1, [r5, r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrh r1, [r5, 0x3C] - strh r1, [r0, 0x3C] - movs r0, 0x30 - ldrsh r1, [r5, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r4, 0x1C - adds r0, r4 - ldr r1, =sub_810886C - str r1, [r0] -_08108850: - adds r0, r5, 0 - bl DestroySprite -_08108856: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81087C0 - - thumb_func_start sub_810886C -sub_810886C: @ 810886C - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x30] - adds r0, 0x1 - strh r0, [r4, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _081088D8 - movs r0, 0 - strh r0, [r4, 0x30] - adds r3, r4, 0 - adds r3, 0x3E - ldrb r2, [r3] - lsls r0, r2, 29 - lsrs r0, 31 - movs r1, 0x1 - eors r1, r0 - lsls r1, 2 - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - ldrh r0, [r4, 0x32] - adds r0, 0x1 - strh r0, [r4, 0x32] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xC - bne _081088D8 - ldr r3, =gTasks - movs r0, 0x3C - ldrsh r1, [r4, r0] - lsls r1, 1 - movs r0, 0x3A - ldrsh r2, [r4, r0] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r1, r0 - adds r3, 0x8 - adds r1, r3 - ldrh r0, [r1] - subs r0, 0x1 - strh r0, [r1] - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - adds r0, r4, 0 - bl DestroySprite -_081088D8: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_810886C - - thumb_func_start sub_81088E4 -sub_81088E4: @ 81088E4 - push {r4-r6,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks - adds r5, r1, r0 - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - movs r6, 0 - strh r0, [r5, 0xE] - ldrb r0, [r4] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0x10] - ldrb r0, [r4] - bl GetBattlerSide - lsls r0, 24 - movs r2, 0x1 - negs r2, r2 - adds r1, r2, 0 - cmp r0, 0 - bne _08108928 - movs r1, 0x1 -_08108928: - strh r1, [r5, 0x16] - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _0810893C - movs r1, 0x16 - ldrsh r0, [r5, r1] - negs r0, r0 - strh r0, [r5, 0x16] -_0810893C: - movs r2, 0x16 - ldrsh r0, [r5, r2] - lsls r0, 3 - ldrh r1, [r5, 0xE] - adds r0, r1 - strh r0, [r5, 0x12] - movs r2, 0x16 - ldrsh r1, [r5, r2] - lsls r1, 3 - ldrh r0, [r5, 0x10] - subs r0, r1 - strh r0, [r5, 0x14] - ldr r0, =0x0000ffe0 - strh r0, [r5, 0x1A] - strh r6, [r5, 0xA] - strh r6, [r5, 0x8] - ldr r0, =sub_8108978 - str r0, [r5] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81088E4 - - thumb_func_start sub_8108978 -sub_8108978: @ 8108978 - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0x6 - bls _08108992 - b _08108AB2 -_08108992: - lsls r0, 2 - ldr r1, =_081089A4 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081089A4: - .4byte _081089C0 - .4byte _081089D0 - .4byte _081089EA - .4byte _08108A2C - .4byte _08108A4E - .4byte _08108A7C - .4byte _08108AA2 -_081089C0: - adds r0, r4, 0 - bl sub_8108AC0 - movs r1, 0x1C - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _08108AB8 - b _08108AAA -_081089D0: - adds r0, r4, 0 - bl sub_8108AC0 - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x10 - ble _08108AB8 - movs r0, 0 - strh r0, [r4, 0xA] - b _08108AAA -_081089EA: - adds r0, r4, 0 - bl sub_8108AC0 - movs r1, 0x16 - ldrsh r0, [r4, r1] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 1 - ldrh r0, [r4, 0x12] - adds r1, r0 - movs r2, 0 - strh r1, [r4, 0x12] - adds r1, 0x10 - lsls r1, 16 - movs r0, 0x88 - lsls r0, 17 - cmp r1, r0 - bls _08108AB8 - ldrh r0, [r4, 0x20] - adds r0, 0x1 - strh r0, [r4, 0x20] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x2 - ble _08108A28 - movs r0, 0x1 - strh r0, [r4, 0x22] - movs r0, 0x6 - strh r0, [r4, 0x8] - strh r2, [r4, 0xA] - b _08108AB8 -_08108A28: - strh r2, [r4, 0xA] - b _08108AAA -_08108A2C: - adds r0, r4, 0 - bl sub_8108AC0 - movs r0, 0x16 - ldrsh r1, [r4, r0] - lsls r1, 1 - ldrh r0, [r4, 0x14] - subs r0, r1 - strh r0, [r4, 0x14] - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x7 - ble _08108AB8 - b _08108AAA -_08108A4E: - adds r0, r4, 0 - bl sub_8108AC0 - movs r1, 0x16 - ldrsh r0, [r4, r1] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 1 - ldrh r0, [r4, 0x12] - subs r0, r1 - strh r0, [r4, 0x12] - adds r0, 0x10 - lsls r0, 16 - movs r1, 0x88 - lsls r1, 17 - cmp r0, r1 - bls _08108AB8 - ldrh r0, [r4, 0x20] - adds r0, 0x1 - strh r0, [r4, 0x20] - movs r0, 0 - strh r0, [r4, 0xA] - b _08108AAA -_08108A7C: - adds r0, r4, 0 - bl sub_8108AC0 - movs r0, 0x16 - ldrsh r1, [r4, r0] - lsls r1, 1 - ldrh r0, [r4, 0x14] - subs r0, r1 - strh r0, [r4, 0x14] - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x7 - ble _08108AB8 - movs r0, 0x2 - strh r0, [r4, 0x8] - b _08108AB8 -_08108AA2: - movs r1, 0x18 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _08108AB8 -_08108AAA: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _08108AB8 -_08108AB2: - adds r0, r2, 0 - bl DestroyAnimVisualTask -_08108AB8: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8108978 - - thumb_func_start sub_8108AC0 -sub_8108AC0: @ 8108AC0 - push {r4-r6,lr} - adds r6, r0, 0 - ldrh r0, [r6, 0xC] - adds r0, 0x1 - strh r0, [r6, 0xC] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _08108B1A - movs r0, 0 - strh r0, [r6, 0xC] - ldr r0, =gUnknown_08595268 - movs r2, 0xE - ldrsh r1, [r6, r2] - movs r3, 0x10 - ldrsh r2, [r6, r3] - movs r3, 0xA - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _08108B1A - ldr r5, =gSprites - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - adds r0, r4, r5 - movs r1, 0x10 - strh r1, [r0, 0x2E] - ldrh r1, [r6, 0x12] - strh r1, [r0, 0x32] - ldrh r1, [r6, 0x14] - strh r1, [r0, 0x36] - ldrh r1, [r6, 0x1A] - strh r1, [r0, 0x38] - bl InitAnimArcTranslation - adds r5, 0x1C - adds r4, r5 - ldr r0, =sub_8108B2C - str r0, [r4] - ldrh r0, [r6, 0x18] - adds r0, 0x1 - strh r0, [r6, 0x18] -_08108B1A: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8108AC0 - - thumb_func_start sub_8108B2C -sub_8108B2C: @ 8108B2C - push {r4-r6,lr} - adds r6, r0, 0 - bl TranslateAnimArc - lsls r0, 24 - cmp r0, 0 - beq _08108B86 - ldrh r0, [r6, 0x24] - ldrh r1, [r6, 0x20] - adds r0, r1 - strh r0, [r6, 0x20] - ldrh r0, [r6, 0x26] - ldrh r1, [r6, 0x22] - adds r0, r1 - strh r0, [r6, 0x22] - movs r0, 0x6 - strh r0, [r6, 0x2E] - bl Random2 - movs r4, 0x1F - adds r1, r4, 0 - ands r1, r0 - ldr r5, =0x0000fff0 - adds r1, r5 - ldrh r0, [r6, 0x20] - adds r1, r0 - strh r1, [r6, 0x32] - bl Random2 - ands r4, r0 - adds r4, r5 - ldrh r1, [r6, 0x22] - adds r4, r1 - strh r4, [r6, 0x36] - bl Random2 - movs r1, 0x7 - ands r1, r0 - mvns r1, r1 - strh r1, [r6, 0x38] - adds r0, r6, 0 - bl InitAnimArcTranslation - ldr r0, =sub_8108B94 - str r0, [r6, 0x1C] -_08108B86: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8108B2C - - thumb_func_start sub_8108B94 -sub_8108B94: @ 8108B94 - push {r4-r6,lr} - adds r5, r0, 0 - bl TranslateAnimArc - lsls r0, 24 - cmp r0, 0 - beq _08108BD0 - movs r4, 0 - ldr r6, =gTasks -_08108BA6: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r2, r0, r6 - ldr r1, [r2] - ldr r0, =sub_8108978 - cmp r1, r0 - bne _08108BC6 - movs r0, 0x1 - strh r0, [r2, 0x1C] - ldrh r0, [r2, 0x18] - subs r0, 0x1 - strh r0, [r2, 0x18] - adds r0, r5, 0 - bl DestroySprite -_08108BC6: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0xF - bls _08108BA6 -_08108BD0: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8108B94 - - thumb_func_start sub_8108BE0 -sub_8108BE0: @ 8108BE0 - ldr r2, =gBattleAnimArgs - ldrh r1, [r2] - strh r1, [r0, 0x20] - ldrh r1, [r2, 0x2] - strh r1, [r0, 0x22] - ldrh r1, [r2, 0x4] - strh r1, [r0, 0x2E] - ldrh r1, [r2, 0x6] - strh r1, [r0, 0x30] - ldrh r1, [r2, 0x8] - strh r1, [r0, 0x32] - ldrh r1, [r2, 0xA] - strh r1, [r0, 0x34] - ldr r1, =sub_8108C08 - str r1, [r0, 0x1C] - bx lr - .pool - thumb_func_end sub_8108BE0 - - thumb_func_start sub_8108C08 -sub_8108C08: @ 8108C08 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x36] - ldrh r1, [r4, 0x2E] - subs r0, r1 - strh r0, [r4, 0x36] - movs r1, 0x36 - ldrsh r0, [r4, r1] - movs r1, 0xA - bl __divsi3 - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x30] - ldrh r2, [r4, 0x38] - adds r0, r2 - movs r1, 0xFF - ands r0, r1 - strh r0, [r4, 0x38] - movs r1, 0x38 - ldrsh r0, [r4, r1] - movs r2, 0x32 - ldrsh r1, [r4, r2] - bl Sin - strh r0, [r4, 0x24] - ldrh r0, [r4, 0x34] - subs r0, 0x1 - strh r0, [r4, 0x34] - lsls r0, 16 - cmp r0, 0 - bne _08108C4C - adds r0, r4, 0 - bl DestroyAnimSprite -_08108C4C: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8108C08 - - thumb_func_start sub_8108C54 -sub_8108C54: @ 8108C54 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x30] - ldrh r1, [r4, 0x34] - adds r0, r1 - strh r0, [r4, 0x34] - ldrh r1, [r4, 0x32] - ldrh r2, [r4, 0x36] - adds r1, r2 - strh r1, [r4, 0x36] - lsls r0, 16 - asrs r0, 23 - strh r0, [r4, 0x24] - lsls r1, 16 - asrs r1, 23 - strh r1, [r4, 0x26] - ldrh r0, [r4, 0x2E] - subs r0, 0x1 - strh r0, [r4, 0x2E] - lsls r0, 16 - cmp r0, 0 - bne _08108C8C - adds r0, r4, 0 - bl FreeSpriteOamMatrix - adds r0, r4, 0 - bl DestroySprite -_08108C8C: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8108C54 - - thumb_func_start sub_8108C94 -sub_8108C94: @ 8108C94 - push {r4,r5,lr} - adds r4, r0, 0 - movs r1, 0x1 - bl InitAnimSpritePos - ldr r5, =gBattleAnimTarget - ldrb r0, [r5] - movs r1, 0x2 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x30] - ldrb r0, [r5] - movs r1, 0x3 - bl GetBattlerSpriteCoord - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x32] - ldr r1, =gBattleAnimArgs - ldrh r0, [r1, 0x4] - strh r0, [r4, 0x34] - ldrh r0, [r1, 0x6] - strh r0, [r4, 0x36] - ldr r0, =sub_8108CDC - str r0, [r4, 0x1C] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8108C94 - - thumb_func_start sub_8108CDC -sub_8108CDC: @ 8108CDC - push {r4-r6,lr} - adds r4, r0, 0 - movs r0, 0x30 - ldrsh r1, [r4, r0] - movs r2, 0x20 - ldrsh r0, [r4, r2] - subs r6, r1, r0 - movs r0, 0x32 - ldrsh r1, [r4, r0] - movs r2, 0x22 - ldrsh r0, [r4, r2] - subs r5, r1, r0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - muls r0, r6 - movs r2, 0x34 - ldrsh r1, [r4, r2] - bl __divsi3 - strh r0, [r4, 0x24] - movs r1, 0x2E - ldrsh r0, [r4, r1] - muls r0, r5 - movs r2, 0x34 - ldrsh r1, [r4, r2] - bl __divsi3 - strh r0, [r4, 0x26] - ldrh r0, [r4, 0x38] - adds r0, 0x1 - strh r0, [r4, 0x38] - lsls r0, 16 - asrs r0, 16 - movs r2, 0x36 - ldrsh r1, [r4, r2] - cmp r0, r1 - bne _08108D34 - movs r0, 0 - strh r0, [r4, 0x38] - adds r0, r4, 0 - adds r1, r6, 0 - adds r2, r5, 0 - bl sub_8108D54 -_08108D34: - movs r0, 0x34 - ldrsh r1, [r4, r0] - movs r2, 0x2E - ldrsh r0, [r4, r2] - cmp r1, r0 - bne _08108D46 - adds r0, r4, 0 - bl DestroyAnimSprite -_08108D46: - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8108CDC - - thumb_func_start sub_8108D54 -sub_8108D54: @ 8108D54 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x18 - adds r4, r1, 0 - adds r5, r2, 0 - movs r2, 0x2E - ldrsh r1, [r0, r2] - lsrs r2, r1, 31 - adds r1, r2 - lsls r1, 15 - lsrs r1, 16 - str r1, [sp] - ldrh r1, [r0, 0x24] - ldrh r3, [r0, 0x20] - adds r1, r3 - lsls r1, 16 - lsrs r1, 16 - mov r8, r1 - ldrh r1, [r0, 0x26] - ldrh r0, [r0, 0x22] - adds r1, r0 - lsls r1, 16 - lsrs r1, 16 - mov r10, r1 - bl Random2 - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xA - bl __umodsi3 - adds r0, r5, r0 - subs r0, 0x5 - lsls r0, 16 - lsrs r0, 16 - mov r9, r0 - bl Random2 - negs r4, r4 - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xA - bl __umodsi3 - adds r4, r0 - subs r4, 0x5 - lsls r4, 16 - lsrs r7, r4, 16 - movs r6, 0 - mov r0, r8 - lsls r0, 16 - mov r8, r0 - mov r1, r10 - lsls r1, 16 - str r1, [sp, 0xC] - ldr r2, [sp] - lsls r2, 16 - str r2, [sp, 0x10] - asrs r1, 16 - lsls r0, r7, 16 - asrs r5, r0, 16 - str r0, [sp, 0x14] - negs r3, r5 - str r3, [sp, 0x4] - asrs r0, r2, 16 - adds r1, r0 - lsls r1, 16 - mov r10, r1 -_08108DE2: - ldr r0, =gUnknown_08595310 - mov r2, r8 - asrs r1, r2, 16 - mov r3, r10 - asrs r2, r3, 16 - movs r3, 0x82 - bl CreateSprite - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r4, r0, r1 - movs r0, 0x14 - strh r0, [r4, 0x2E] - mov r0, r9 - strh r0, [r4, 0x30] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSpriteSubpriority - subs r0, 0x1 - adds r1, r4, 0 - adds r1, 0x43 - strb r0, [r1] - cmp r5, 0 - bge _08108E30 - mov r1, sp - ldrh r1, [r1, 0x4] - strh r1, [r4, 0x32] - b _08108E32 - .pool -_08108E30: - strh r7, [r4, 0x32] -_08108E32: - lsls r0, r6, 16 - movs r2, 0x80 - lsls r2, 9 - adds r0, r2 - lsrs r6, r0, 16 - cmp r0, 0 - ble _08108DE2 - movs r6, 0 - ldr r3, [sp, 0xC] - asrs r1, r3, 16 - ldr r0, [sp, 0x14] - asrs r5, r0, 16 - negs r2, r5 - str r2, [sp, 0x8] - ldr r3, [sp, 0x10] - asrs r0, r3, 16 - subs r1, r0 - lsls r1, 16 - mov r10, r1 -_08108E58: - ldr r0, =gUnknown_08595310 - mov r2, r8 - asrs r1, r2, 16 - mov r3, r10 - asrs r2, r3, 16 - movs r3, 0x82 - bl CreateSprite - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r4, r0, r1 - movs r0, 0x14 - strh r0, [r4, 0x2E] - mov r0, r9 - strh r0, [r4, 0x30] - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSpriteSubpriority - subs r0, 0x1 - adds r1, r4, 0 - adds r1, 0x43 - strb r0, [r1] - cmp r5, 0 - ble _08108EA8 - mov r1, sp - ldrh r1, [r1, 0x8] - strh r1, [r4, 0x32] - b _08108EAA - .pool -_08108EA8: - strh r7, [r4, 0x32] -_08108EAA: - lsls r0, r6, 16 - movs r2, 0x80 - lsls r2, 9 - adds r0, r2 - lsrs r6, r0, 16 - cmp r0, 0 - ble _08108E58 - add sp, 0x18 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8108D54 - - .align 2, 0 diff --git a/include/battle_anim.h b/include/battle_anim.h index b25822992..5b62e594b 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -183,6 +183,9 @@ u8 GetSubstituteSpriteDefault_Y(u8 battlerId); #define STAT_ANIM_MULTIPLE_MINUS2 58 void LaunchStatusAnimation(u8 battlerId, u8 statusAnimId); +// ground.c +void sub_81152DC(u8 taskId); + // battle_anim_8170478.s u8 ItemIdToBallId(u16 itemId); u8 AnimateBallOpenParticles(u8 x, u8 y, u8 priority, u8 subpriority, u8 ballId); diff --git a/include/graphics.h b/include/graphics.h index 48e4532ac..4f7a71b49 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4736,6 +4736,13 @@ extern const u32 gUnknown_08C16FA8[]; extern const u32 gUnknown_08C16E90[]; extern const u32 gUnknown_08C17170[]; +extern const u32 gUnknown_08D95E00[]; +extern const u32 gUnknown_08D960D0[]; +extern const u32 gUnknown_08D963A4[]; +extern const u32 gBattleAnimBackgroundImage_Surf[]; +extern const u32 gBattleAnimBackgroundPalette_Surf[]; +extern const u32 gBattleAnimBackgroundImageMuddyWater_Pal[]; + // Berry blender extern const u32 gBerryBlenderArrowTiles[]; extern const u32 gBerryBlenderStartTiles[]; diff --git a/ld_script.txt b/ld_script.txt index a37f283d6..b36066abb 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -160,7 +160,6 @@ SECTIONS { src/battle_anim_effects_1.o(.text); src/battle_anim_effects_2.o(.text); src/water.o(.text); - asm/water.o(.text); src/fire.o(.text); src/electric.o(.text); asm/ice.o(.text); diff --git a/src/water.c b/src/water.c index e69e0b54b..433b3bc91 100644 --- a/src/water.c +++ b/src/water.c @@ -1,7 +1,11 @@ #include "global.h" #include "battle.h" #include "battle_anim.h" +#include "gpu_regs.h" +#include "graphics.h" +#include "palette.h" #include "random.h" +#include "scanline_effect.h" #include "sprite.h" #include "task.h" #include "trig.h" @@ -16,17 +20,41 @@ extern void sub_8107380(struct Sprite *); extern void sub_8107408(struct Sprite *); extern void sub_8107430(struct Sprite *); extern void sub_810744C(struct Sprite *); +extern void sub_81074E4(struct Sprite *); extern void sub_81075EC(struct Sprite *); +extern void sub_8107674(struct Sprite *); extern void sub_8107730(struct Sprite *); +extern void sub_81077A4(struct Sprite *); extern void sub_81077C0(struct Sprite *); extern void sub_80A78AC(struct Sprite *); extern void sub_8107894(struct Sprite *); extern void sub_81078D0(struct Sprite *); +extern void sub_810790C(struct Sprite *); extern void sub_8108034(struct Sprite *); +extern void sub_8108098(struct Sprite *); extern void sub_810851C(struct Sprite *); +extern void sub_81087C0(struct Sprite *); +extern void sub_810886C(struct Sprite *); +extern void sub_8108B2C(struct Sprite *); +extern void sub_8108B94(struct Sprite *); extern void sub_8108BE0(struct Sprite *); +extern void sub_8108C08(struct Sprite *); extern void sub_8108C54(struct Sprite *); +extern void sub_8108CDC(struct Sprite *); extern void sub_80A8EE4(struct Sprite *); +void sub_810756C(u8); +void sub_81076F4(u8); +void sub_8107B84(u8); +void sub_8107CC4(u8); +void sub_8107D58(u8); +void sub_8108140(u8); +void sub_810862C(u8); +void sub_8108978(u8); +u8 sub_8108384(void); +void sub_8108408(struct Task*, u8); +void sub_810871C(struct Task*, u8); +void sub_8108AC0(struct Task*); +void sub_8108D54(struct Sprite*, int, int); extern const union AffineAnimCmd *const gUnknown_08593420[]; extern const union AffineAnimCmd *const gUnknown_08596208[]; @@ -452,6 +480,8 @@ const struct SpriteTemplate gUnknown_08595328 = .callback = sub_80A8EE4, }; +extern const struct SpriteTemplate gUnknown_08597388; + void AnimTask_CreateRaindrops(u8 taskId) { u8 x, y; @@ -485,7 +515,7 @@ void sub_8107228(struct Sprite *sprite) sprite->pos2.x++; sprite->pos2.y += 4; } - if (sprite->animEnded != FALSE) + if (sprite->animEnded) DestroySprite(sprite); } @@ -523,7 +553,7 @@ void sub_8107260(struct Sprite *sprite) gSprites[spriteId].data[3] = (u8)gBattleAnimArgs[4] * 256; gSprites[spriteId].data[4] = gBattleAnimArgs[6]; sprite->callback = sub_8107380; - sub_8107380(sprite); + sprite->callback(sprite); } void sub_8107380(struct Sprite *sprite) @@ -548,14 +578,2050 @@ void sub_8107380(struct Sprite *sprite) } } -/* void FuncNameHere(struct Sprite *sprite) -{ - -} */ - void sub_8107408(struct Sprite *sprite) { sprite->animPaused = FALSE; sprite->callback = RunStoredCallbackWhenAnimEnds; StoreSpriteCallbackInData6(sprite, sub_8107430); } + +void sub_8107430(struct Sprite *sprite) +{ + sprite->data[0] = 10; + sprite->callback = WaitAnimForDuration; + StoreSpriteCallbackInData6(sprite, DestroySpriteAndMatrix); +} + +void sub_810744C(struct Sprite *sprite) +{ + s16 unkArg; + + InitAnimSpritePos(sprite, TRUE); + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + unkArg = -gBattleAnimArgs[2]; + else + unkArg = gBattleAnimArgs[2]; + sprite->data[0] = gBattleAnimArgs[4]; + sprite->data[1] = sprite->pos1.x; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2) + unkArg; + sprite->data[3] = sprite->pos1.y; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[3]; + InitAnimLinearTranslation(sprite); + sprite->callback = sub_81074E4; + sprite->affineAnimPaused = TRUE; + sprite->callback(sprite); +} + +void sub_81074E4(struct Sprite *sprite) +{ + if ((u16)gBattleAnimArgs[ARG_RET_ID] == 0xFFFF) + { + StartSpriteAnim(sprite, 1); + sprite->affineAnimPaused = FALSE; + } + if (TranslateAnimLinear(sprite)) + DestroyAnimSprite(sprite); +} + +void sub_8107528(u8 taskId) +{ + gTasks[taskId].data[0] = gBattleAnimArgs[0]; + gTasks[taskId].data[2] = IndexOfSpritePaletteTag(ANIM_TAG_RAINBOW_RINGS) * 16 + 256; + gTasks[taskId].func = sub_810756C; +} + +#ifdef NONMATCHING +void sub_810756C(u8 taskId) +{ + int i; + u16 palIndex; + u16 *palPtr1; + u16 *palPtr2; + u16 rgbBuffer; + + if (++gTasks[taskId].data[10] == 3) + { + gTasks[taskId].data[10] = 0; + palIndex = gTasks[taskId].data[2] + 1; + palPtr1 = &gPlttBufferFaded[palIndex]; + rgbBuffer = *palPtr1; + palPtr2 = &palPtr1[1]; + for (i = 0; i < 7; i++) + palPtr1[i] = palPtr2[i]; + gPlttBufferFaded[palIndex + 7] = rgbBuffer; + } + if (++gTasks[taskId].data[11] == gTasks[taskId].data[0]) + DestroyAnimVisualTask(taskId); +} +#else +NAKED +void sub_810756C(u8 taskId) +{ + asm_unified("push {r4-r7,lr}\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + ldr r1, =gTasks\n\ + lsls r0, r4, 2\n\ + adds r0, r4\n\ + lsls r0, 3\n\ + adds r2, r0, r1\n\ + ldrh r0, [r2, 0x1C]\n\ + adds r0, 0x1\n\ + strh r0, [r2, 0x1C]\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + mov r12, r1\n\ + cmp r0, 0x3\n\ + bne _081075BE\n\ + movs r0, 0\n\ + strh r0, [r2, 0x1C]\n\ + ldrh r0, [r2, 0xC]\n\ + adds r0, 0x1\n\ + lsls r0, 16\n\ + lsrs r5, r0, 16\n\ + ldr r1, =gPlttBufferFaded\n\ + lsls r0, r5, 1\n\ + adds r0, r1\n\ + ldrh r6, [r0]\n\ + adds r7, r1, 0\n\ + adds r3, r0, 0x2\n\ + movs r1, 0x6\n\ + adds r2, r0, 0\n\ +_081075A8:\n\ + ldrh r0, [r3]\n\ + strh r0, [r2]\n\ + adds r3, 0x2\n\ + adds r2, 0x2\n\ + subs r1, 0x1\n\ + cmp r1, 0\n\ + bge _081075A8\n\ + adds r0, r5, 0x7\n\ + lsls r0, 1\n\ + adds r0, r7\n\ + strh r6, [r0]\n\ +_081075BE:\n\ + lsls r0, r4, 2\n\ + adds r0, r4\n\ + lsls r0, 3\n\ + add r0, r12\n\ + ldrh r1, [r0, 0x1E]\n\ + adds r1, 0x1\n\ + strh r1, [r0, 0x1E]\n\ + lsls r1, 16\n\ + asrs r1, 16\n\ + movs r2, 0x8\n\ + ldrsh r0, [r0, r2]\n\ + cmp r1, r0\n\ + bne _081075DE\n\ + adds r0, r4, 0\n\ + bl DestroyAnimVisualTask\n\ +_081075DE:\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n"); +} +#endif + +void sub_81075EC(struct Sprite *sprite) +{ + u16 retArg; + + InitAnimSpritePos(sprite, TRUE); + sprite->data[0] = 30; + sprite->data[1] = sprite->pos1.x; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + sprite->data[3] = sprite->pos1.y; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3); + InitAnimLinearTranslation(sprite); + sprite->data[5] = 0xD200 / sprite->data[0]; + sprite->data[7] = gBattleAnimArgs[3]; + retArg = gBattleAnimArgs[ARG_RET_ID]; + if (gBattleAnimArgs[ARG_RET_ID] > 127) + { + sprite->data[6] = (retArg - 127) * 256; + sprite->data[7] = -sprite->data[7]; + } + else + { + sprite->data[6] = retArg * 256; + } + sprite->callback = sub_8107674; + sprite->callback(sprite); +} + +void sub_8107674(struct Sprite *sprite) +{ + if (TranslateAnimLinear(sprite)) + DestroyAnimSprite(sprite); + sprite->pos2.y += Sin(sprite->data[6] >> 8, sprite->data[7]); + if ((sprite->data[6] + sprite->data[5]) >> 8 > 127) + { + sprite->data[6] = 0; + sprite->data[7] = -sprite->data[7]; + } + else + { + sprite->data[6] += sprite->data[5]; + } +} + +void sub_81076C8(u8 taskId) +{ + gTasks[taskId].data[0] = gBattleAnimArgs[0]; + gBattleAnimArgs[ARG_RET_ID] = 0; + gTasks[taskId].func = sub_81076F4; +} + +void sub_81076F4(u8 taskId) +{ + gBattleAnimArgs[ARG_RET_ID] = (gBattleAnimArgs[ARG_RET_ID] + 3) & 0xFF; + if (--gTasks[taskId].data[0] == 0) + DestroyAnimVisualTask(taskId); +} + +void sub_8107730(struct Sprite *sprite) +{ + u8 priority; + + sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 0); + sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 1); + sprite->pos2.y = -10; + priority = GetBattlerSpriteSubpriority(gBattleAnimAttacker); + if (!IsContest()) + { + if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER) + { + sprite->pos2.x = 10; + sprite->subpriority = priority + 2; + } + else + { + sprite->pos2.x = -10; + sprite->subpriority = priority - 2; + } + } + else + { + sprite->pos2.x = -10; + sprite->subpriority = priority + 2; + } + sprite->callback = sub_81077A4; +} + +void sub_81077A4(struct Sprite *sprite) +{ + if (sprite->affineAnimEnded) + DestroyAnimSprite(sprite); +} + +void sub_81077C0(struct Sprite *sprite) +{ + bool8 animType; + u8 coordType; + if (GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget)) + { + gBattleAnimArgs[0] *= -1; + if (GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_PLAYER_LEFT || GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_OPPONENT_LEFT) + gBattleAnimArgs[0] *= -1; + } + if ((gBattleAnimArgs[5] & 0xFF00) == 0) + animType = TRUE; + else + animType = FALSE; + if ((u8)gBattleAnimArgs[5] == 0) + coordType = 3; + else + coordType = 1; + InitAnimSpritePos(sprite, animType); + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + sprite->data[0] = gBattleAnimArgs[4]; + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2) + gBattleAnimArgs[2]; + sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, coordType) + gBattleAnimArgs[3]; + sprite->callback = StartAnimLinearTranslation; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); +} + +void sub_8107894(struct Sprite *sprite) +{ + sub_80A6980(sprite, TRUE); + sprite->data[0] = gBattleAnimArgs[4]; + sprite->data[2] = sprite->pos1.x + gBattleAnimArgs[2]; + sprite->data[4] = sprite->pos1.y + gBattleAnimArgs[4]; + sprite->callback = StartAnimLinearTranslation; + StoreSpriteCallbackInData6(sprite, DestroyAnimSprite); +} + +void sub_81078D0(struct Sprite *sprite) +{ + if (gBattleAnimArgs[3]) + sub_80A6980(sprite, TRUE); + else + InitAnimSpritePos(sprite, TRUE); + sprite->data[7] = gBattleAnimArgs[2]; + sprite->callback = sub_810790C; +} + +void sub_810790C(struct Sprite *sprite) +{ + sprite->data[0] = (sprite->data[0] + 11) & 0xFF; + sprite->pos2.x = Sin(sprite->data[0], 4); + sprite->data[1] += 48; + sprite->pos2.y = -(sprite->data[1] >> 8); + if (--sprite->data[7] == -1) + DestroyAnimSprite(sprite); +} + +#ifdef NONMATCHING +void AnimTask_CreateSurfWave(u8 taskId) +{ + struct UnknownAnimStruct2 unk; + u8 taskId2; + + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); + SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); + SetAnimBgAttribute(1, BG_ANIM_SCREEN_SIZE, 1); + sub_80A6B30(&unk); + if (!IsContest()) + { + SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 1); + if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_OPPONENT) + sub_80A6D48(unk.bgId, gUnknown_08D95E00); + else + sub_80A6D48(unk.bgId, gUnknown_08D960D0); + } + else + { + sub_80A6D60(&unk, gUnknown_08D963A4, 1); + } + sub_80A6CC0(unk.bgId, gBattleAnimBackgroundImage_Surf, unk.tilesOffset); + if (gBattleAnimArgs[0] == 0) + LoadCompressedPalette(gBattleAnimBackgroundPalette_Surf, unk.unk8 * 16, 32); + else + LoadCompressedPalette(gBattleAnimBackgroundImageMuddyWater_Pal, unk.unk8 * 16, 32); + taskId2 = CreateTask(sub_8107D58, gTasks[taskId].priority + 1); + gTasks[taskId].data[15] = taskId2; + gTasks[taskId2].data[0] = 0; + gTasks[taskId2].data[1] = 0x1000; + gTasks[taskId2].data[2] = 0x1000; + if (IsContest()) + { + gBattle_BG1_X = -80; + gBattle_BG1_Y = -48; + gTasks[taskId].data[0] = 2; + gTasks[taskId].data[1] = 1; + gTasks[taskId2].data[3] = 0; + } + else if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_OPPONENT) + { + gBattle_BG1_X = -224; + gBattle_BG1_Y = 256; + gTasks[taskId].data[0] = 2; + gTasks[taskId].data[1] = -1; + gTasks[taskId2].data[3] = 1; + } + else + { + gBattle_BG1_X = 0; + gBattle_BG1_Y = -48; + gTasks[taskId].data[0] = -2; + gTasks[taskId].data[1] = 1; + gTasks[taskId2].data[3] = 0; + } + SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X); + SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y); + if (gTasks[taskId2].data[3] == 0) + { + gTasks[taskId2].data[4] = 48; + gTasks[taskId2].data[5] = 112; + } + else + { + gTasks[taskId2].data[4] = 0; + gTasks[taskId2].data[5] = 0; + } + gTasks[taskId].data[6] = 1; + gTasks[taskId].func = sub_8107B84; +} +#else +NAKED +void AnimTask_CreateSurfWave(u8 taskId) +{ + asm_unified("push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x10\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r10, r0\n\ + ldr r1, =0x00003f42\n\ + movs r0, 0x50\n\ + bl SetGpuReg\n\ + movs r1, 0x80\n\ + lsls r1, 5\n\ + movs r0, 0x52\n\ + bl SetGpuReg\n\ + movs r0, 0x1\n\ + movs r1, 0x4\n\ + movs r2, 0x1\n\ + bl SetAnimBgAttribute\n\ + movs r0, 0x1\n\ + movs r1, 0\n\ + movs r2, 0x1\n\ + bl SetAnimBgAttribute\n\ + mov r0, sp\n\ + bl sub_80A6B30\n\ + bl IsContest\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _081079E0\n\ + movs r0, 0x1\n\ + movs r1, 0x3\n\ + movs r2, 0x1\n\ + bl SetAnimBgAttribute\n\ + ldr r0, =gBattleAnimAttacker\n\ + ldrb r0, [r0]\n\ + bl GetBattlerSide\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x1\n\ + bne _081079D0\n\ + mov r0, sp\n\ + ldrb r0, [r0, 0x9]\n\ + ldr r1, =gUnknown_08D95E00\n\ + bl sub_80A6D48\n\ + b _081079EA\n\ + .pool\n\ +_081079D0:\n\ + mov r0, sp\n\ + ldrb r0, [r0, 0x9]\n\ + ldr r1, =gUnknown_08D960D0\n\ + bl sub_80A6D48\n\ + b _081079EA\n\ + .pool\n\ +_081079E0:\n\ + ldr r1, =gUnknown_08D963A4\n\ + mov r0, sp\n\ + movs r2, 0x1\n\ + bl sub_80A6D60\n\ +_081079EA:\n\ + mov r0, sp\n\ + ldrb r0, [r0, 0x9]\n\ + ldr r1, =gBattleAnimBackgroundImage_Surf\n\ + mov r2, sp\n\ + ldrh r2, [r2, 0xA]\n\ + bl sub_80A6CC0\n\ + ldr r0, =gBattleAnimArgs\n\ + movs r1, 0\n\ + ldrsh r0, [r0, r1]\n\ + cmp r0, 0\n\ + bne _08107A24\n\ + ldr r0, =gBattleAnimBackgroundPalette_Surf\n\ + mov r1, sp\n\ + ldrb r1, [r1, 0x8]\n\ + lsls r1, 4\n\ + movs r2, 0x20\n\ + bl LoadCompressedPalette\n\ + b _08107A32\n\ + .pool\n\ +_08107A24:\n\ + ldr r0, =gBattleAnimBackgroundImageMuddyWater_Pal\n\ + mov r1, sp\n\ + ldrb r1, [r1, 0x8]\n\ + lsls r1, 4\n\ + movs r2, 0x20\n\ + bl LoadCompressedPalette\n\ +_08107A32:\n\ + ldr r0, =sub_8107D58\n\ + ldr r4, =gTasks\n\ + mov r2, r10\n\ + lsls r5, r2, 2\n\ + adds r1, r5, r2\n\ + lsls r1, 3\n\ + adds r6, r1, r4\n\ + ldrb r1, [r6, 0x7]\n\ + adds r1, 0x1\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + bl CreateTask\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r8, r0\n\ + movs r0, 0\n\ + mov r9, r0\n\ + mov r1, r8\n\ + strh r1, [r6, 0x26]\n\ + mov r2, r8\n\ + lsls r0, r2, 2\n\ + add r0, r8\n\ + lsls r0, 3\n\ + adds r7, r0, r4\n\ + mov r0, r9\n\ + strh r0, [r7, 0x8]\n\ + movs r0, 0x80\n\ + lsls r0, 5\n\ + strh r0, [r7, 0xA]\n\ + strh r0, [r7, 0xC]\n\ + bl IsContest\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + cmp r4, 0\n\ + beq _08107AB4\n\ + ldr r1, =0x0000ffb0\n\ + adds r0, r1, 0\n\ + ldr r2, =gBattle_BG1_X\n\ + strh r0, [r2]\n\ + adds r1, 0x20\n\ + adds r0, r1, 0\n\ + ldr r2, =gBattle_BG1_Y\n\ + strh r0, [r2]\n\ + movs r0, 0x2\n\ + strh r0, [r6, 0x8]\n\ + movs r0, 0x1\n\ + strh r0, [r6, 0xA]\n\ + mov r0, r9\n\ + strh r0, [r7, 0xE]\n\ + b _08107B0E\n\ + .pool\n\ +_08107AB4:\n\ + ldr r0, =gBattleAnimAttacker\n\ + ldrb r0, [r0]\n\ + bl GetBattlerSide\n\ + lsls r0, 24\n\ + lsrs r1, r0, 24\n\ + cmp r1, 0x1\n\ + bne _08107AF8\n\ + ldr r2, =0x0000ff20\n\ + adds r0, r2, 0\n\ + ldr r2, =gBattle_BG1_X\n\ + strh r0, [r2]\n\ + movs r2, 0x80\n\ + lsls r2, 1\n\ + adds r0, r2, 0\n\ + ldr r2, =gBattle_BG1_Y\n\ + strh r0, [r2]\n\ + movs r0, 0x2\n\ + strh r0, [r6, 0x8]\n\ + ldr r0, =0x0000ffff\n\ + strh r0, [r6, 0xA]\n\ + strh r1, [r7, 0xE]\n\ + b _08107B0E\n\ + .pool\n\ +_08107AF8:\n\ + ldr r0, =gBattle_BG1_X\n\ + strh r4, [r0]\n\ + ldr r1, =0x0000ffd0\n\ + adds r0, r1, 0\n\ + ldr r2, =gBattle_BG1_Y\n\ + strh r0, [r2]\n\ + ldr r0, =0x0000fffe\n\ + strh r0, [r6, 0x8]\n\ + movs r0, 0x1\n\ + strh r0, [r6, 0xA]\n\ + strh r4, [r7, 0xE]\n\ +_08107B0E:\n\ + ldr r0, =gBattle_BG1_X\n\ + ldrh r1, [r0]\n\ + movs r0, 0x14\n\ + bl SetGpuReg\n\ + ldr r2, =gBattle_BG1_Y\n\ + ldrh r1, [r2]\n\ + movs r0, 0x16\n\ + bl SetGpuReg\n\ + ldr r1, =gTasks\n\ + mov r2, r8\n\ + lsls r0, r2, 2\n\ + add r0, r8\n\ + lsls r0, 3\n\ + adds r1, r0, r1\n\ + movs r2, 0xE\n\ + ldrsh r0, [r1, r2]\n\ + cmp r0, 0\n\ + bne _08107B54\n\ + movs r0, 0x30\n\ + strh r0, [r1, 0x10]\n\ + movs r0, 0x70\n\ + b _08107B58\n\ + .pool\n\ +_08107B54:\n\ + movs r0, 0\n\ + strh r0, [r1, 0x10]\n\ +_08107B58:\n\ + strh r0, [r1, 0x12]\n\ + ldr r1, =gTasks\n\ + mov r2, r10\n\ + adds r0, r5, r2\n\ + lsls r0, 3\n\ + adds r0, r1\n\ + movs r1, 0x1\n\ + strh r1, [r0, 0x14]\n\ + ldr r1, =sub_8107B84\n\ + str r1, [r0]\n\ + add sp, 0x10\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n"); +} +#endif + +#ifdef NONMATCHING +void sub_8107B84(u8 taskId) +{ + struct UnknownAnimStruct2 unk; + u8 i; + u16 rgbBuffer; + u16 *BGptrX = &gBattle_BG1_X; + u16 *BGptrY = &gBattle_BG1_Y; + s16 unkUse; + u32 palOffset; + u16 palNum; + + *BGptrX += gTasks[taskId].data[0]; + *BGptrY += gTasks[taskId].data[1]; + sub_80A6B30(&unk); + gTasks[taskId].data[2] += gTasks[taskId].data[1]; + if (++gTasks[taskId].data[5] == 4) + { + rgbBuffer = gPlttBufferFaded[unk.unk8 * 16 + 7]; + for (i = 6; i != 0; i--) + { + palNum = unk.unk8 * 16; + palOffset = 1 + i; + gPlttBufferFaded[palNum + palOffset] = gPlttBufferFaded[palNum + palOffset - 1]; + } + gPlttBufferFaded[unk.unk8 * 16 + 1] = rgbBuffer; + gTasks[taskId].data[5] = 0; + } + if (++gTasks[taskId].data[6] > 1) + { + gTasks[taskId].data[6] = 0; + unkUse = ++gTasks[taskId].data[3]; + if (unkUse <= 13) + { + gTasks[gTasks[taskId].data[15]].data[1] = unkUse | ((16 - unkUse) * 256); + gTasks[taskId].data[4]++; + } + if (gTasks[taskId].data[3] > 54) + { + unkUse = --gTasks[taskId].data[4]; + gTasks[gTasks[taskId].data[15]].data[1] = unkUse | ((16 - unkUse) * 256); + } + } + if (!(gTasks[gTasks[taskId].data[15]].data[1] & 0x1F)) + { + gTasks[taskId].data[0] = gTasks[gTasks[taskId].data[15]].data[1] & 0x1F; + gTasks[taskId].func = sub_8107CC4; + } +} +#else +NAKED +void sub_8107B84(u8 taskId) +{ + asm_unified("push {r4-r7,lr}\n\ + sub sp, 0x10\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + ldr r1, =gBattle_BG1_X\n\ + ldr r2, =gBattle_BG1_Y\n\ + ldr r0, =gTasks\n\ + lsls r4, r5, 2\n\ + adds r4, r5\n\ + lsls r4, 3\n\ + adds r4, r0\n\ + ldrh r0, [r4, 0x8]\n\ + ldrh r3, [r1]\n\ + adds r0, r3\n\ + strh r0, [r1]\n\ + ldrh r0, [r4, 0xA]\n\ + ldrh r1, [r2]\n\ + adds r0, r1\n\ + strh r0, [r2]\n\ + mov r0, sp\n\ + bl sub_80A6B30\n\ + ldrh r0, [r4, 0xA]\n\ + ldrh r3, [r4, 0xC]\n\ + adds r0, r3\n\ + strh r0, [r4, 0xC]\n\ + ldrh r0, [r4, 0x12]\n\ + adds r0, 0x1\n\ + strh r0, [r4, 0x12]\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + cmp r0, 0x4\n\ + bne _08107C18\n\ + ldr r1, =gPlttBufferFaded\n\ + mov r0, sp\n\ + ldrb r0, [r0, 0x8]\n\ + lsls r0, 4\n\ + adds r0, 0x7\n\ + lsls r0, 1\n\ + adds r0, r1\n\ + ldrh r6, [r0]\n\ + movs r2, 0x6\n\ + adds r7, r1, 0\n\ + adds r3, r7, 0\n\ + mov r4, sp\n\ +_08107BDE:\n\ + ldrb r0, [r4, 0x8]\n\ + lsls r0, 4\n\ + adds r1, r2, 0x1\n\ + adds r0, r1\n\ + lsls r1, r0, 1\n\ + adds r1, r3\n\ + subs r0, 0x1\n\ + lsls r0, 1\n\ + adds r0, r3\n\ + ldrh r0, [r0]\n\ + strh r0, [r1]\n\ + subs r0, r2, 0x1\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ + cmp r2, 0\n\ + bne _08107BDE\n\ + mov r0, sp\n\ + ldrb r0, [r0, 0x8]\n\ + lsls r0, 4\n\ + adds r0, 0x1\n\ + lsls r0, 1\n\ + adds r0, r7\n\ + strh r6, [r0]\n\ + ldr r1, =gTasks\n\ + lsls r0, r5, 2\n\ + adds r0, r5\n\ + lsls r0, 3\n\ + adds r0, r1\n\ + strh r2, [r0, 0x12]\n\ +_08107C18:\n\ + ldr r1, =gTasks\n\ + lsls r2, r5, 2\n\ + adds r0, r2, r5\n\ + lsls r0, 3\n\ + adds r3, r0, r1\n\ + ldrh r0, [r3, 0x14]\n\ + adds r0, 0x1\n\ + strh r0, [r3, 0x14]\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + adds r4, r1, 0\n\ + adds r6, r2, 0\n\ + cmp r0, 0x1\n\ + ble _08107C86\n\ + movs r0, 0\n\ + strh r0, [r3, 0x14]\n\ + ldrh r0, [r3, 0xE]\n\ + adds r2, r0, 0x1\n\ + strh r2, [r3, 0xE]\n\ + lsls r0, r2, 16\n\ + asrs r0, 16\n\ + cmp r0, 0xD\n\ + bgt _08107C62\n\ + movs r1, 0x26\n\ + ldrsh r0, [r3, r1]\n\ + lsls r1, r0, 2\n\ + adds r1, r0\n\ + lsls r1, 3\n\ + adds r1, r4\n\ + movs r0, 0x10\n\ + subs r0, r2\n\ + lsls r0, 8\n\ + orrs r2, r0\n\ + strh r2, [r1, 0xA]\n\ + ldrh r0, [r3, 0x10]\n\ + adds r0, 0x1\n\ + strh r0, [r3, 0x10]\n\ +_08107C62:\n\ + movs r1, 0xE\n\ + ldrsh r0, [r3, r1]\n\ + cmp r0, 0x36\n\ + ble _08107C86\n\ + ldrh r2, [r3, 0x10]\n\ + subs r2, 0x1\n\ + strh r2, [r3, 0x10]\n\ + movs r1, 0x26\n\ + ldrsh r0, [r3, r1]\n\ + lsls r1, r0, 2\n\ + adds r1, r0\n\ + lsls r1, 3\n\ + adds r1, r4\n\ + movs r0, 0x10\n\ + subs r0, r2\n\ + lsls r0, 8\n\ + orrs r2, r0\n\ + strh r2, [r1, 0xA]\n\ +_08107C86:\n\ + adds r0, r6, r5\n\ + lsls r0, 3\n\ + adds r2, r0, r4\n\ + movs r3, 0x26\n\ + ldrsh r1, [r2, r3]\n\ + lsls r0, r1, 2\n\ + adds r0, r1\n\ + lsls r0, 3\n\ + adds r0, r4\n\ + ldrh r0, [r0, 0xA]\n\ + movs r3, 0x1F\n\ + ands r3, r0\n\ + cmp r3, 0\n\ + bne _08107CA8\n\ + strh r3, [r2, 0x8]\n\ + ldr r0, =sub_8107CC4\n\ + str r0, [r2]\n\ +_08107CA8:\n\ + add sp, 0x10\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n"); +} +#endif + +void sub_8107CC4(u8 taskId) +{ + u16 *BGptrX = &gBattle_BG1_X; + u16 *BGptrY = &gBattle_BG1_Y; + if (gTasks[taskId].data[0] == 0) + { + sub_80A6C68(1); + sub_80A6C68(2); + gTasks[taskId].data[0]++; + } + else + { + if (!IsContest()) + SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 0); + *BGptrX = 0; + *BGptrY = 0; + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 0)); + gTasks[gTasks[taskId].data[15]].data[15] = -1; + DestroyAnimVisualTask(taskId); + } +} + +#ifdef NONMATCHING +void sub_8107D58(u8 taskId) +{ + s16 i; + struct ScanlineEffectParams params; + struct Task *task = &gTasks[taskId]; + // u16 *scanlineBuffer; + + switch (task->data[0]) + { + case 0: + for (i = 0; i < task->data[4]; i++) + { + /* scanlineBuffer = &gScanlineEffectRegBuffers[0][i]; + *(u16 *)(&gScanlineEffect) = task->data[2]; + *scanlineBuffer = task->data[2] & -1; */ + gScanlineEffectRegBuffers[1][i] = task->data[2]; + gScanlineEffectRegBuffers[0][i] = (u16)((int)(task->data[2] & 0xFFFF)); + } + for (i = task->data[4]; i < task->data[5]; i++) + { + gScanlineEffectRegBuffers[1][i] = task->data[1]; + gScanlineEffectRegBuffers[0][i] = (u16)((int)(task->data[1] & 0xFFFF)); + } + for (i = task->data[5]; i < 160; i++) + { + gScanlineEffectRegBuffers[1][i] = task->data[2]; + gScanlineEffectRegBuffers[0][i] = (u16)((int)(task->data[2] & 0xFFFF)); + } + if (task->data[4] == 0) + { + gScanlineEffectRegBuffers[1][i] = task->data[1]; + gScanlineEffectRegBuffers[0][i] = task->data[1]; + } + else + { + gScanlineEffectRegBuffers[1][i] = task->data[2]; + gScanlineEffectRegBuffers[0][i] = task->data[2]; + } + params.dmaDest = (vu16 *)REG_ADDR_BLDALPHA; + params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT; + params.initState = 1; + params.unused9 = 0; + ScanlineEffect_SetParams(params); + task->data[0]++; + break; + case 1: + if (task->data[3] == 0) + { + if (--task->data[4] <= 0) + { + task->data[4] = 0; + task->data[0]++; + } + } + else if (++task->data[5] > 111) + { + task->data[0]++; + } + for (i = 0; i < task->data[4]; i++) + { + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; + } + for (i = task->data[4]; i < task->data[5]; i++) + { + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[1]; + } + for (i = task->data[5]; i < 160; i++) + { + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; + } + break; + case 2: + for (i = 0; i < task->data[4]; i++) + { + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; + } + for (i = task->data[4]; i < task->data[5]; i++) + { + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[1]; + } + for (i = task->data[5]; i < 160; i++) + { + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2]; + } + if (task->data[15] == -1) + { + ScanlineEffect_Stop(); + DestroyTask(taskId); + } + break; + } +} +#else +NAKED +void sub_8107D58(u8 taskId) +{ + asm_unified("push {r4-r7,lr}\n\ + sub sp, 0xC\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ + lsls r0, r7, 2\n\ + adds r0, r7\n\ + lsls r0, 3\n\ + ldr r1, =gTasks\n\ + adds r4, r0, r1\n\ + movs r1, 0x8\n\ + ldrsh r0, [r4, r1]\n\ + cmp r0, 0x1\n\ + bne _08107D74\n\ + b _08107EAC\n\ +_08107D74:\n\ + cmp r0, 0x1\n\ + bgt _08107D84\n\ + cmp r0, 0\n\ + beq _08107D8C\n\ + b _08108022\n\ + .pool\n\ +_08107D84:\n\ + cmp r0, 0x2\n\ + bne _08107D8A\n\ + b _08107F78\n\ +_08107D8A:\n\ + b _08108022\n\ +_08107D8C:\n\ + movs r3, 0\n\ + movs r2, 0x10\n\ + ldrsh r0, [r4, r2]\n\ + ldr r1, =gScanlineEffectRegBuffers\n\ + mov r12, r1\n\ + cmp r3, r0\n\ + bge _08107DCA\n\ + mov r7, r12\n\ + movs r5, 0xF0\n\ + lsls r5, 3\n\ + add r5, r12\n\ + ldr r6, =0x0000ffff\n\ +_08107DA4:\n\ + lsls r2, r3, 16\n\ + asrs r2, 16\n\ + lsls r1, r2, 1\n\ + adds r3, r1, r7\n\ + adds r1, r5\n\ + ldrh r0, [r4, 0xC]\n\ + strh r0, [r1]\n\ + ldrh r1, [r4, 0xC]\n\ + adds r0, r6, 0\n\ + ands r0, r1\n\ + strh r0, [r3]\n\ + adds r2, 0x1\n\ + lsls r2, 16\n\ + lsrs r3, r2, 16\n\ + asrs r2, 16\n\ + movs r1, 0x10\n\ + ldrsh r0, [r4, r1]\n\ + cmp r2, r0\n\ + blt _08107DA4\n\ +_08107DCA:\n\ + ldrh r3, [r4, 0x10]\n\ + lsls r2, r3, 16\n\ + asrs r1, r2, 16\n\ + movs r3, 0x12\n\ + ldrsh r0, [r4, r3]\n\ + cmp r1, r0\n\ + bge _08107E04\n\ + ldr r5, =gScanlineEffectRegBuffers\n\ + movs r0, 0xF0\n\ + lsls r0, 3\n\ + adds r6, r5, r0\n\ + ldr r7, =0x0000ffff\n\ +_08107DE2:\n\ + asrs r2, 16\n\ + lsls r1, r2, 1\n\ + adds r3, r1, r5\n\ + adds r1, r6\n\ + ldrh r0, [r4, 0xA]\n\ + strh r0, [r1]\n\ + ldrh r1, [r4, 0xA]\n\ + adds r0, r7, 0\n\ + ands r0, r1\n\ + strh r0, [r3]\n\ + adds r2, 0x1\n\ + lsls r2, 16\n\ + asrs r1, r2, 16\n\ + movs r3, 0x12\n\ + ldrsh r0, [r4, r3]\n\ + cmp r1, r0\n\ + blt _08107DE2\n\ +_08107E04:\n\ + ldrh r3, [r4, 0x12]\n\ + lsls r2, r3, 16\n\ + asrs r0, r2, 16\n\ + cmp r0, 0x9F\n\ + bgt _08107E3A\n\ + ldr r5, =gScanlineEffectRegBuffers\n\ + movs r0, 0xF0\n\ + lsls r0, 3\n\ + adds r6, r5, r0\n\ + ldr r7, =0x0000ffff\n\ +_08107E18:\n\ + asrs r2, 16\n\ + lsls r1, r2, 1\n\ + adds r3, r1, r5\n\ + adds r1, r6\n\ + ldrh r0, [r4, 0xC]\n\ + strh r0, [r1]\n\ + ldrh r1, [r4, 0xC]\n\ + adds r0, r7, 0\n\ + ands r0, r1\n\ + strh r0, [r3]\n\ + adds r2, 0x1\n\ + lsls r2, 16\n\ + lsrs r3, r2, 16\n\ + lsls r2, r3, 16\n\ + asrs r0, r2, 16\n\ + cmp r0, 0x9F\n\ + ble _08107E18\n\ +_08107E3A:\n\ + movs r1, 0x10\n\ + ldrsh r0, [r4, r1]\n\ + cmp r0, 0\n\ + bne _08107E64\n\ + lsls r0, r3, 16\n\ + asrs r0, 15\n\ + mov r3, r12\n\ + adds r2, r0, r3\n\ + movs r1, 0xF0\n\ + lsls r1, 3\n\ + add r1, r12\n\ + adds r0, r1\n\ + ldrh r1, [r4, 0xA]\n\ + strh r1, [r0]\n\ + ldrh r0, [r4, 0xA]\n\ + b _08107E7A\n\ + .pool\n\ +_08107E64:\n\ + lsls r0, r3, 16\n\ + asrs r0, 15\n\ + mov r1, r12\n\ + adds r2, r0, r1\n\ + movs r1, 0xF0\n\ + lsls r1, 3\n\ + add r1, r12\n\ + adds r0, r1\n\ + ldrh r1, [r4, 0xC]\n\ + strh r1, [r0]\n\ + ldrh r0, [r4, 0xC]\n\ +_08107E7A:\n\ + strh r0, [r2]\n\ + ldr r0, =0x04000052\n\ + str r0, [sp]\n\ + ldr r0, =0xa2600001\n\ + str r0, [sp, 0x4]\n\ + mov r1, sp\n\ + movs r2, 0\n\ + movs r0, 0x1\n\ + strb r0, [r1, 0x8]\n\ + mov r0, sp\n\ + strb r2, [r0, 0x9]\n\ + ldr r0, [sp]\n\ + ldr r1, [sp, 0x4]\n\ + ldr r2, [sp, 0x8]\n\ + bl ScanlineEffect_SetParams\n\ + ldrh r0, [r4, 0x8]\n\ + adds r0, 0x1\n\ + strh r0, [r4, 0x8]\n\ + b _08108022\n\ + .pool\n\ +_08107EAC:\n\ + movs r2, 0xE\n\ + ldrsh r1, [r4, r2]\n\ + cmp r1, 0\n\ + bne _08107EC4\n\ + ldrh r0, [r4, 0x10]\n\ + subs r0, 0x1\n\ + strh r0, [r4, 0x10]\n\ + lsls r0, 16\n\ + cmp r0, 0\n\ + bgt _08107ED8\n\ + strh r1, [r4, 0x10]\n\ + b _08107ED2\n\ +_08107EC4:\n\ + ldrh r0, [r4, 0x12]\n\ + adds r0, 0x1\n\ + strh r0, [r4, 0x12]\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + cmp r0, 0x6F\n\ + ble _08107ED8\n\ +_08107ED2:\n\ + ldrh r0, [r4, 0x8]\n\ + adds r0, 0x1\n\ + strh r0, [r4, 0x8]\n\ +_08107ED8:\n\ + movs r3, 0\n\ + movs r1, 0x10\n\ + ldrsh r0, [r4, r1]\n\ + cmp r3, r0\n\ + bge _08107F0C\n\ + ldr r6, =gScanlineEffectRegBuffers\n\ + ldr r5, =gScanlineEffect\n\ +_08107EE6:\n\ + lsls r1, r3, 16\n\ + asrs r1, 16\n\ + lsls r3, r1, 1\n\ + ldrb r2, [r5, 0x14]\n\ + lsls r0, r2, 4\n\ + subs r0, r2\n\ + lsls r0, 7\n\ + adds r3, r0\n\ + adds r3, r6\n\ + ldrh r0, [r4, 0xC]\n\ + strh r0, [r3]\n\ + adds r1, 0x1\n\ + lsls r1, 16\n\ + lsrs r3, r1, 16\n\ + asrs r1, 16\n\ + movs r2, 0x10\n\ + ldrsh r0, [r4, r2]\n\ + cmp r1, r0\n\ + blt _08107EE6\n\ +_08107F0C:\n\ + ldrh r3, [r4, 0x10]\n\ + lsls r2, r3, 16\n\ + asrs r1, r2, 16\n\ + movs r3, 0x12\n\ + ldrsh r0, [r4, r3]\n\ + cmp r1, r0\n\ + bge _08107F40\n\ + ldr r6, =gScanlineEffectRegBuffers\n\ + ldr r5, =gScanlineEffect\n\ +_08107F1E:\n\ + asrs r3, r2, 16\n\ + lsls r2, r3, 1\n\ + ldrb r1, [r5, 0x14]\n\ + lsls r0, r1, 4\n\ + subs r0, r1\n\ + lsls r0, 7\n\ + adds r2, r0\n\ + adds r2, r6\n\ + ldrh r0, [r4, 0xA]\n\ + strh r0, [r2]\n\ + adds r3, 0x1\n\ + lsls r2, r3, 16\n\ + asrs r1, r2, 16\n\ + movs r3, 0x12\n\ + ldrsh r0, [r4, r3]\n\ + cmp r1, r0\n\ + blt _08107F1E\n\ +_08107F40:\n\ + ldrh r3, [r4, 0x12]\n\ + lsls r1, r3, 16\n\ + asrs r0, r1, 16\n\ + cmp r0, 0x9F\n\ + bgt _08108022\n\ + ldr r6, =gScanlineEffectRegBuffers\n\ + ldr r5, =gScanlineEffect\n\ +_08107F4E:\n\ + asrs r3, r1, 16\n\ + lsls r2, r3, 1\n\ + ldrb r1, [r5, 0x14]\n\ + lsls r0, r1, 4\n\ + subs r0, r1\n\ + lsls r0, 7\n\ + adds r2, r0\n\ + adds r2, r6\n\ + ldrh r0, [r4, 0xC]\n\ + strh r0, [r2]\n\ + adds r3, 0x1\n\ + lsls r1, r3, 16\n\ + asrs r0, r1, 16\n\ + cmp r0, 0x9F\n\ + ble _08107F4E\n\ + b _08108022\n\ + .pool\n\ +_08107F78:\n\ + movs r3, 0\n\ + movs r1, 0x10\n\ + ldrsh r0, [r4, r1]\n\ + cmp r3, r0\n\ + bge _08107FAC\n\ + ldr r6, =gScanlineEffectRegBuffers\n\ + ldr r5, =gScanlineEffect\n\ +_08107F86:\n\ + lsls r1, r3, 16\n\ + asrs r1, 16\n\ + lsls r3, r1, 1\n\ + ldrb r2, [r5, 0x14]\n\ + lsls r0, r2, 4\n\ + subs r0, r2\n\ + lsls r0, 7\n\ + adds r3, r0\n\ + adds r3, r6\n\ + ldrh r0, [r4, 0xC]\n\ + strh r0, [r3]\n\ + adds r1, 0x1\n\ + lsls r1, 16\n\ + lsrs r3, r1, 16\n\ + asrs r1, 16\n\ + movs r2, 0x10\n\ + ldrsh r0, [r4, r2]\n\ + cmp r1, r0\n\ + blt _08107F86\n\ +_08107FAC:\n\ + ldrh r3, [r4, 0x10]\n\ + lsls r2, r3, 16\n\ + asrs r1, r2, 16\n\ + movs r3, 0x12\n\ + ldrsh r0, [r4, r3]\n\ + cmp r1, r0\n\ + bge _08107FE0\n\ + ldr r6, =gScanlineEffectRegBuffers\n\ + ldr r5, =gScanlineEffect\n\ +_08107FBE:\n\ + asrs r3, r2, 16\n\ + lsls r2, r3, 1\n\ + ldrb r1, [r5, 0x14]\n\ + lsls r0, r1, 4\n\ + subs r0, r1\n\ + lsls r0, 7\n\ + adds r2, r0\n\ + adds r2, r6\n\ + ldrh r0, [r4, 0xA]\n\ + strh r0, [r2]\n\ + adds r3, 0x1\n\ + lsls r2, r3, 16\n\ + asrs r1, r2, 16\n\ + movs r3, 0x12\n\ + ldrsh r0, [r4, r3]\n\ + cmp r1, r0\n\ + blt _08107FBE\n\ +_08107FE0:\n\ + ldrh r3, [r4, 0x12]\n\ + lsls r1, r3, 16\n\ + asrs r0, r1, 16\n\ + cmp r0, 0x9F\n\ + bgt _0810800C\n\ + ldr r6, =gScanlineEffectRegBuffers\n\ + ldr r5, =gScanlineEffect\n\ +_08107FEE:\n\ + asrs r3, r1, 16\n\ + lsls r2, r3, 1\n\ + ldrb r1, [r5, 0x14]\n\ + lsls r0, r1, 4\n\ + subs r0, r1\n\ + lsls r0, 7\n\ + adds r2, r0\n\ + adds r2, r6\n\ + ldrh r0, [r4, 0xC]\n\ + strh r0, [r2]\n\ + adds r3, 0x1\n\ + lsls r1, r3, 16\n\ + asrs r0, r1, 16\n\ + cmp r0, 0x9F\n\ + ble _08107FEE\n\ +_0810800C:\n\ + movs r0, 0x26\n\ + ldrsh r1, [r4, r0]\n\ + movs r0, 0x1\n\ + negs r0, r0\n\ + cmp r1, r0\n\ + bne _08108022\n\ + bl ScanlineEffect_Stop\n\ + adds r0, r7, 0\n\ + bl DestroyTask\n\ +_08108022:\n\ + add sp, 0xC\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n"); +} +#endif + +void sub_8108034(struct Sprite *sprite) +{ + s16 randData; + s16 randData2; + + sprite->oam.tileNum += 8; + sub_80A6980(sprite, TRUE); + randData = (Random2() & 0xFF) | 256; + randData2 = (Random2() & 0x1FF); + if (randData2 > 255) + randData2 = 256 - randData2; + sprite->data[1] = randData; + sprite->data[2] = randData2; + sprite->callback = sub_8108098; +} + +void sub_8108098(struct Sprite *sprite) +{ + sprite->data[3] += sprite->data[1]; + sprite->data[4] += sprite->data[2]; + if (sprite->data[1] & 1) + sprite->pos2.x = -(sprite->data[3] >> 8); + else + sprite->pos2.x = sprite->data[3] >> 8; + sprite->pos2.y = sprite->data[4] >> 8; + if (++sprite->data[0] == 21) + DestroyAnimSprite(sprite); +} + +void sub_81080E4(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + task->data[15] = GetAnimBattlerSpriteId(ANIM_ATTACKER); + task->data[5] = gSprites[task->data[15]].pos1.y; + task->data[1] = sub_8108384(); + PrepareBattlerSpriteForRotScale(task->data[15], ST_OAM_OBJ_NORMAL); + task->func = sub_8108140; +} + +void sub_8108140(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + sub_80A805C(task, task->data[15], 0x100, 0x100, 224, 0x200, 32); + task->data[0]++; + case 1: + if (++task->data[3] > 1) + { + task->data[3] = 0; + if (++task->data[4] & 1) + { + gSprites[task->data[15]].pos2.x = 3; + gSprites[task->data[15]].pos1.y++; + } + else + { + gSprites[task->data[15]].pos2.x = -3; + } + } + if (sub_80A80C8(task) == 0) + { + SetBattlerSpriteYOffsetFromYScale(task->data[15]); + gSprites[task->data[15]].pos2.x = 0; + task->data[3] = 0; + task->data[4] = 0; + task->data[0]++; + } + break; + case 2: + if (++task->data[3] > 4) + { + sub_80A805C(task, task->data[15], 224, 0x200, 384, 224, 8); + task->data[3] = 0; + task->data[0]++; + } + break; + case 3: + if (sub_80A80C8(task) == 0) + { + task->data[3] = 0; + task->data[4] = 0; + task->data[0]++; + } + break; + case 4: + sub_8108408(task, taskId); + task->data[0]++; + case 5: + if (++task->data[3] > 1) + { + task->data[3] = 0; + if (++task->data[4] & 1) + gSprites[task->data[15]].pos2.y += 2; + else + gSprites[task->data[15]].pos2.y -= 2; + if (task->data[4] == 10) + { + sub_80A805C(task, task->data[15], 384, 224, 0x100, 0x100, 8); + task->data[3] = 0; + task->data[4] = 0; + task->data[0]++; + } + } + break; + case 6: + gSprites[task->data[15]].pos1.y--; + if (sub_80A80C8(task) == 0) + { + ResetSpriteRotScale(task->data[15]); + gSprites[task->data[15]].pos1.y = task->data[5]; + task->data[4] = 0; + task->data[0]++; + } + break; + case 7: + if (task->data[2] == 0) + DestroyAnimVisualTask(taskId); + break; + } +} + +u8 sub_8108384(void) +{ + u8 i; + u16 hp; + u16 maxhp; + u16 partyIndex; + struct Pokemon *slot; + + if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER) + { + partyIndex = gBattlerPartyIndexes[gBattleAnimAttacker]; + slot = &gPlayerParty[partyIndex]; + maxhp = GetMonData(slot, MON_DATA_MAX_HP); + hp = GetMonData(slot, MON_DATA_HP); + maxhp /= 4; + } + else + { + partyIndex = gBattlerPartyIndexes[gBattleAnimAttacker]; + slot = &gEnemyParty[partyIndex]; + maxhp = GetMonData(slot, MON_DATA_MAX_HP); + hp = GetMonData(slot, MON_DATA_HP); + maxhp /= 4; + } + for (i = 0; i < 3; i++) + { + if (hp < maxhp * (i + 1)) + return i; + } + return 3; +} + +void sub_8108408(struct Task *task, u8 taskId) +{ + s16 i; + s16 attackerCoordX = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); + s16 attackerCoordY = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); + s16 trigIndex = 172; + u8 subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) - 1; + s16 increment = 4 - task->data[1]; + u8 spriteId; + + if (increment <= 0) + increment = 1; + for (i = 0; i < 20; i += increment) + { + spriteId = CreateSprite(&gUnknown_08595268, attackerCoordX, attackerCoordY, subpriority); + if (spriteId != MAX_SPRITES) + { + gSprites[spriteId].data[1] = i; + gSprites[spriteId].data[2] = attackerCoordX * 16; + gSprites[spriteId].data[3] = attackerCoordY * 16; + gSprites[spriteId].data[4] = Cos(trigIndex, 64); + gSprites[spriteId].data[5] = Sin(trigIndex, 64); + gSprites[spriteId].data[6] = taskId; + gSprites[spriteId].data[7] = 2; + if (task->data[2] & 1) + sub_810851C(&gSprites[spriteId]); + task->data[2]++; + } + trigIndex = (trigIndex + increment * 2); + trigIndex &= 0xFF; + } +} + +void sub_810851C(struct Sprite *sprite) +{ + switch (sprite->data[0]) + { + case 0: + sprite->data[4] += (sprite->data[1] % 6) * 3; + sprite->data[5] += (sprite->data[1] % 3) * 3; + sprite->data[0]++; + case 1: + sprite->data[2] += sprite->data[4]; + sprite->data[3] += sprite->data[5]; + sprite->pos1.x = sprite->data[2] >> 4; + sprite->pos1.y = sprite->data[3] >> 4; + if (sprite->pos1.x < -8 || sprite->pos1.x > 248 || sprite->pos1.y < -8 || sprite->pos1.y > 120) + { + gTasks[sprite->data[6]].data[sprite->data[7]]--; + DestroySprite(sprite); + } + break; + } +} + +void sub_81085C8(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + task->data[1] = sub_8108384(); + if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER) + { + task->data[4] = 136; + task->data[6] = 40; + } + else + { + task->data[4] = 16; + task->data[6] = 80; + } + task->data[5] = 98; + task->data[7] = task->data[4] + 49; + task->data[12] = task->data[1] * 5 + 5; + task->func = sub_810862C; +} + +void sub_810862C(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + u8 taskId2; + + switch (task->data[0]) + { + case 0: + if (++task->data[2] > 2) + { + task->data[2] = 0; + sub_810871C(task, taskId); + } + if (task->data[10] != 0 && task->data[13] == 0) + { + gBattleAnimArgs[0] = 1; + gBattleAnimArgs[1] = 0; + gBattleAnimArgs[2] = 12; + taskId2 = CreateTask(sub_81152DC, 80); + if (taskId2 != 0xFF) + { + gTasks[taskId2].func(taskId2); + gAnimVisualTaskCount++; + } + gBattleAnimArgs[0] = 3; + taskId2 = CreateTask(sub_81152DC, 80); + if (taskId2 != 0xFF) + { + gTasks[taskId2].func(taskId2); + gAnimVisualTaskCount++; + } + task->data[13] = 1; + } + if (task->data[11] >= task->data[12]) + task->data[0]++; + break; + case 1: + if (task->data[9] == 0) + DestroyAnimVisualTask(taskId); + break; + } +} + +void sub_810871C(struct Task *task, u8 taskId) +{ + u16 yPosArg = ((gSineTable[task->data[8]] + 3) >> 4) + task->data[6]; + u8 spriteId = CreateSprite(&gUnknown_08595268, task->data[7], 0, 0); + + if (spriteId != MAX_SPRITES) + { + gSprites[spriteId].callback = sub_81087C0; + gSprites[spriteId].data[5] = yPosArg; + gSprites[spriteId].data[6] = taskId; + gSprites[spriteId].data[7] = 9; + task->data[9]++; + } + task->data[11]++; + task->data[8] = (task->data[8] + 39) & 0xFF; + task->data[7] = ((task->data[7] * 0x41c64e6d /* EXCUSE ME WHAT */ + 0x3039) % task->data[5]) + task->data[4]; +} + +void sub_81087C0(struct Sprite *sprite) +{ + if (sprite->data[0] == 0) + { + sprite->pos1.y += 8; + if (sprite->pos1.y >= sprite->data[5]) + { + gTasks[sprite->data[6]].data[10] = 1; + sprite->data[1] = CreateSprite(&gUnknown_08597388, sprite->pos1.x, sprite->pos1.y, 1); + if (sprite->data[1] != MAX_SPRITES) + { + StartSpriteAffineAnim(&gSprites[sprite->data[1]], 3); + gSprites[sprite->data[1]].data[6] = sprite->data[6]; + gSprites[sprite->data[1]].data[7] = sprite->data[7]; + gSprites[sprite->data[1]].callback = sub_810886C; + } + DestroySprite(sprite); + } + } +} + +void sub_810886C(struct Sprite *sprite) +{ + if (++sprite->data[1] > 1) + { + sprite->data[1] = 0; + sprite->invisible ^= 1; + if (++sprite->data[2] == 12) + { + gTasks[sprite->data[6]].data[sprite->data[7]]--; + FreeOamMatrix(sprite->oam.matrixNum); + DestroySprite(sprite); + } + } +} + +void sub_81088E4(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + task->data[3] = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); + task->data[4] = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); + task->data[7] = (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER) ? 1 : -1; + if (IsContest()) + task->data[7] *= -1; + task->data[5] = task->data[3] + task->data[7] * 8; + task->data[6] = task->data[4] - task->data[7] * 8; + task->data[9] = -32; + task->data[1] = 0; + task->data[0] = 0; + task->func = sub_8108978; +} + +void sub_8108978(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + sub_8108AC0(task); + if (task->data[10] != 0) + task->data[0]++; + break; + case 1: + sub_8108AC0(task); + if (++task->data[1] > 16) + { + task->data[1] = 0; + task->data[0]++; + } + break; + case 2: + sub_8108AC0(task); + task->data[5] += task->data[7] * 6; + if (!(task->data[5] >= -16 && task->data[5] <= 256)) + { + if (++task->data[12] > 2) + { + task->data[13] = 1; + task->data[0] = 6; + task->data[1] = 0; + } + else + { + task->data[1] = 0; + task->data[0]++; + } + } + break; + case 3: + sub_8108AC0(task); + task->data[6] -= task->data[7] * 2; + if (++task->data[1] > 7) + task->data[0]++; + break; + case 4: + sub_8108AC0(task); + task->data[5] -= task->data[7] * 6; + if (!(task->data[5] >= -16 && task->data[5] <= 256)) + { + task->data[12]++; + task->data[1] = 0; + task->data[0]++; + } + break; + case 5: + sub_8108AC0(task); + task->data[6] -= task->data[7] * 2; + if (++task->data[1] > 7) + task->data[0] = 2; + break; + case 6: + if (task->data[8] == 0) + task->data[0]++; + break; + default: + DestroyAnimVisualTask(taskId); + break; + } +} + +void sub_8108AC0(struct Task *task) +{ + u8 spriteId; + + if (++task->data[2] > 1) + { + task->data[2] = 0; + spriteId = CreateSprite(&gUnknown_08595268, task->data[3], task->data[4], 10); + if (spriteId != MAX_SPRITES) + { + gSprites[spriteId].data[0] = 16; + gSprites[spriteId].data[2] = task->data[5]; + gSprites[spriteId].data[4] = task->data[6]; + gSprites[spriteId].data[5] = task->data[9]; + InitAnimArcTranslation(&gSprites[spriteId]); + gSprites[spriteId].callback = sub_8108B2C; + task->data[8]++; + } + } +} + +void sub_8108B2C(struct Sprite *sprite) +{ + if (TranslateAnimArc(sprite)) + { + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->data[0] = 6; + sprite->data[2] = (Random2() & 0x1F) - 16 + sprite->pos1.x; + sprite->data[4] = (Random2() & 0x1F) - 16 + sprite->pos1.y; + sprite->data[5] = ~(Random2() & 7); + InitAnimArcTranslation(sprite); + sprite->callback = sub_8108B94; + } +} + +void sub_8108B94(struct Sprite *sprite) +{ + u16 i; + + if (TranslateAnimArc(sprite)) + { + for (i = 0; i < NUM_TASKS; i++) + { + if (gTasks[i].func == sub_8108978) + { + gTasks[i].data[10] = 1; + gTasks[i].data[8]--; + DestroySprite(sprite); + } + } + } +} + +void sub_8108BE0(struct Sprite *sprite) +{ + sprite->pos1.x = gBattleAnimArgs[0]; + sprite->pos1.y = gBattleAnimArgs[1]; + sprite->data[0] = gBattleAnimArgs[2]; + sprite->data[1] = gBattleAnimArgs[3]; + sprite->data[2] = gBattleAnimArgs[4]; + sprite->data[3] = gBattleAnimArgs[5]; + sprite->callback = sub_8108C08; +} + +void sub_8108C08(struct Sprite *sprite) +{ + sprite->data[4] -= sprite->data[0]; + sprite->pos2.y = sprite->data[4] / 10; + sprite->data[5] = (sprite->data[5] + sprite->data[1]) & 0xFF; + sprite->pos2.x = Sin(sprite->data[5], sprite->data[2]); + if (--sprite->data[3] == 0) + DestroyAnimSprite(sprite); +} + +void sub_8108C54(struct Sprite *sprite) +{ + sprite->data[3] += sprite->data[1]; + sprite->data[4] += sprite->data[2]; + sprite->pos2.x = sprite->data[3] >> 7; + sprite->pos2.y = sprite->data[4] >> 7; + if (--sprite->data[0] == 0) + { + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + } +} + +void sub_8108C94(struct Sprite *sprite) +{ + InitAnimSpritePos(sprite, TRUE); + sprite->data[1] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); + sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 3); + sprite->data[3] = gBattleAnimArgs[2]; + sprite->data[4] = gBattleAnimArgs[3]; + sprite->callback = sub_8108CDC; +} + +void sub_8108CDC(struct Sprite *sprite) +{ + int xDiff = sprite->data[1] - sprite->pos1.x; + int yDiff = sprite->data[2] - sprite->pos1.y; + + sprite->pos2.x = (sprite->data[0] * xDiff) / sprite->data[3]; + sprite->pos2.y = (sprite->data[0] * yDiff) / sprite->data[3]; + if (++sprite->data[5] == sprite->data[4]) + { + sprite->data[5] = 0; + sub_8108D54(sprite, xDiff, yDiff); + } + if (sprite->data[3] == sprite->data[0]) + DestroyAnimSprite(sprite); + sprite->data[0]++; +} + +#ifdef NONMATCHING +void sub_8108D54(struct Sprite *sprite, int xDiff, int yDiff) +{ + s16 something = sprite->data[0] / 2; + s16 combinedX = sprite->pos1.x + sprite->pos2.x; + s16 combinedY = sprite->pos1.y + sprite->pos2.y; + s16 randomSomethingY = yDiff + (Random2() % 10) - 5; + s16 randomSomethingX = -xDiff + (Random2() % 10) - 5; + s16 i; + u8 spriteId; + + for (i = 0; i <= 0; i++) + { + spriteId = CreateSprite(&gUnknown_08595310, combinedX, combinedY + something, 130); + gSprites[spriteId].data[0] = 20; + gSprites[spriteId].data[1] = randomSomethingY; + gSprites[spriteId].subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) - 1; + if (randomSomethingX < 0) + gSprites[spriteId].data[2] = -randomSomethingX; + else + gSprites[spriteId].data[2] = randomSomethingX; + } + for (i = 0; i <= 0; i++) + { + spriteId = CreateSprite(&gUnknown_08595310, combinedX, combinedY, 130); + gSprites[spriteId].data[0] = 20; + gSprites[spriteId].data[1] = randomSomethingY; + gSprites[spriteId].subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) - 1; + if (randomSomethingX > 0) + gSprites[spriteId].data[2] = -randomSomethingX; + else + gSprites[spriteId].data[2] = randomSomethingX; + } +} +#else +NAKED +void sub_8108D54(struct Sprite *sprite, int xDiff, int yDiff) +{ + asm_unified("push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x18\n\ + adds r4, r1, 0\n\ + adds r5, r2, 0\n\ + movs r2, 0x2E\n\ + ldrsh r1, [r0, r2]\n\ + lsrs r2, r1, 31\n\ + adds r1, r2\n\ + lsls r1, 15\n\ + lsrs r1, 16\n\ + str r1, [sp]\n\ + ldrh r1, [r0, 0x24]\n\ + ldrh r3, [r0, 0x20]\n\ + adds r1, r3\n\ + lsls r1, 16\n\ + lsrs r1, 16\n\ + mov r8, r1\n\ + ldrh r1, [r0, 0x26]\n\ + ldrh r0, [r0, 0x22]\n\ + adds r1, r0\n\ + lsls r1, 16\n\ + lsrs r1, 16\n\ + mov r10, r1\n\ + bl Random2\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r1, 0xA\n\ + bl __umodsi3\n\ + adds r0, r5, r0\n\ + subs r0, 0x5\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + mov r9, r0\n\ + bl Random2\n\ + negs r4, r4\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r1, 0xA\n\ + bl __umodsi3\n\ + adds r4, r0\n\ + subs r4, 0x5\n\ + lsls r4, 16\n\ + lsrs r7, r4, 16\n\ + movs r6, 0\n\ + mov r0, r8\n\ + lsls r0, 16\n\ + mov r8, r0\n\ + mov r1, r10\n\ + lsls r1, 16\n\ + str r1, [sp, 0xC]\n\ + ldr r2, [sp]\n\ + lsls r2, 16\n\ + str r2, [sp, 0x10]\n\ + asrs r1, 16\n\ + lsls r0, r7, 16\n\ + asrs r5, r0, 16\n\ + str r0, [sp, 0x14]\n\ + negs r3, r5\n\ + str r3, [sp, 0x4]\n\ + asrs r0, r2, 16\n\ + adds r1, r0\n\ + lsls r1, 16\n\ + mov r10, r1\n\ +_08108DE2:\n\ + ldr r0, =gUnknown_08595310\n\ + mov r2, r8\n\ + asrs r1, r2, 16\n\ + mov r3, r10\n\ + asrs r2, r3, 16\n\ + movs r3, 0x82\n\ + bl CreateSprite\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ + ldr r1, =gSprites\n\ + lsls r0, r2, 4\n\ + adds r0, r2\n\ + lsls r0, 2\n\ + adds r4, r0, r1\n\ + movs r0, 0x14\n\ + strh r0, [r4, 0x2E]\n\ + mov r0, r9\n\ + strh r0, [r4, 0x30]\n\ + ldr r0, =gBattleAnimAttacker\n\ + ldrb r0, [r0]\n\ + bl GetBattlerSpriteSubpriority\n\ + subs r0, 0x1\n\ + adds r1, r4, 0\n\ + adds r1, 0x43\n\ + strb r0, [r1]\n\ + cmp r5, 0\n\ + bge _08108E30\n\ + mov r1, sp\n\ + ldrh r1, [r1, 0x4]\n\ + strh r1, [r4, 0x32]\n\ + b _08108E32\n\ + .pool\n\ +_08108E30:\n\ + strh r7, [r4, 0x32]\n\ +_08108E32:\n\ + lsls r0, r6, 16\n\ + movs r2, 0x80\n\ + lsls r2, 9\n\ + adds r0, r2\n\ + lsrs r6, r0, 16\n\ + cmp r0, 0\n\ + ble _08108DE2\n\ + movs r6, 0\n\ + ldr r3, [sp, 0xC]\n\ + asrs r1, r3, 16\n\ + ldr r0, [sp, 0x14]\n\ + asrs r5, r0, 16\n\ + negs r2, r5\n\ + str r2, [sp, 0x8]\n\ + ldr r3, [sp, 0x10]\n\ + asrs r0, r3, 16\n\ + subs r1, r0\n\ + lsls r1, 16\n\ + mov r10, r1\n\ +_08108E58:\n\ + ldr r0, =gUnknown_08595310\n\ + mov r2, r8\n\ + asrs r1, r2, 16\n\ + mov r3, r10\n\ + asrs r2, r3, 16\n\ + movs r3, 0x82\n\ + bl CreateSprite\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ + ldr r1, =gSprites\n\ + lsls r0, r2, 4\n\ + adds r0, r2\n\ + lsls r0, 2\n\ + adds r4, r0, r1\n\ + movs r0, 0x14\n\ + strh r0, [r4, 0x2E]\n\ + mov r0, r9\n\ + strh r0, [r4, 0x30]\n\ + ldr r0, =gBattleAnimAttacker\n\ + ldrb r0, [r0]\n\ + bl GetBattlerSpriteSubpriority\n\ + subs r0, 0x1\n\ + adds r1, r4, 0\n\ + adds r1, 0x43\n\ + strb r0, [r1]\n\ + cmp r5, 0\n\ + ble _08108EA8\n\ + mov r1, sp\n\ + ldrh r1, [r1, 0x8]\n\ + strh r1, [r4, 0x32]\n\ + b _08108EAA\n\ + .pool\n\ +_08108EA8:\n\ + strh r7, [r4, 0x32]\n\ +_08108EAA:\n\ + lsls r0, r6, 16\n\ + movs r2, 0x80\n\ + lsls r2, 9\n\ + adds r0, r2\n\ + lsrs r6, r0, 16\n\ + cmp r0, 0\n\ + ble _08108E58\n\ + add sp, 0x18\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n"); +} +#endif From 0fa120ebcd358cfcdc65832b50a5c1dfecb7c7dd Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Wed, 19 Dec 2018 10:48:15 -0500 Subject: [PATCH 3/4] get a nonmatching slightly more functional --- src/water.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/water.c b/src/water.c index 433b3bc91..bb3c065d2 100644 --- a/src/water.c +++ b/src/water.c @@ -2436,7 +2436,7 @@ void sub_8108D54(struct Sprite *sprite, int xDiff, int yDiff) } for (i = 0; i <= 0; i++) { - spriteId = CreateSprite(&gUnknown_08595310, combinedX, combinedY, 130); + spriteId = CreateSprite(&gUnknown_08595310, combinedX, combinedY - something, 130); gSprites[spriteId].data[0] = 20; gSprites[spriteId].data[1] = randomSomethingY; gSprites[spriteId].subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) - 1; From 6f0dd694eadfbee15faec38c59d37b0c4364445e Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Wed, 19 Dec 2018 19:48:28 -0500 Subject: [PATCH 4/4] removed weird comment --- src/water.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/water.c b/src/water.c index bb3c065d2..fd31b324a 100644 --- a/src/water.c +++ b/src/water.c @@ -2172,7 +2172,7 @@ void sub_810871C(struct Task *task, u8 taskId) } task->data[11]++; task->data[8] = (task->data[8] + 39) & 0xFF; - task->data[7] = ((task->data[7] * 0x41c64e6d /* EXCUSE ME WHAT */ + 0x3039) % task->data[5]) + task->data[4]; + task->data[7] = ((task->data[7] * 0x41c64e6d + 0x3039) % task->data[5]) + task->data[4]; } void sub_81087C0(struct Sprite *sprite)