Merge branch 'master' into german_debug

This commit is contained in:
Cameron Hall 2018-02-06 18:50:47 -06:00 committed by GitHub
commit 7a264da18b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 1797 additions and 4226 deletions

2013
asm/dark.s

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -63,5 +63,6 @@ void sub_80763FC(u16 a, u16 *b, u32 c, u8 d);
s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan);
s16 sub_8077104(s16 newPan, int oldPan);
void DestroyAnimSoundTask(u8 taskId);
void sub_8076464(u8 a);
#endif

View File

@ -85,7 +85,7 @@ void sub_8078174(struct Sprite *sprite);
void sub_80793C4(struct Sprite *sprite);
void sub_807A3FC(u8 slot, u8 a2, s16 *a3, s16 *a4);
u8 sub_8079ED4(u8 slot);
int sub_807A100(u8 slot, u8 a2);
s16 sub_807A100(u8 slot, u8 a2);
u16 sub_80790F0(s16 a, s16 b);
void sub_8078FDC(struct Sprite *sprite, bool8 a2, s16 xScale, s16 yScale, u16 rotation);
void sub_807867C(struct Sprite *sprite, s16 a2);
@ -105,5 +105,7 @@ void oamt_add_pos2_onto_pos1(struct Sprite *sprite);
void sub_8078BD4(struct Sprite *sprite);
void sub_807941C(struct Sprite *sprite);
void sub_80789D4(bool8 a1);
void sub_8079AB8(u8 sprite, u8 sprite2);
u8 sub_807A4A0(int bank, u8 sprite, int species);
#endif // GUARD_ROM_8077ABC_H

View File

@ -306,13 +306,12 @@ SECTIONS {
asm/fight.o(.text);
src/battle/anim/poison.o(.text);
asm/flying.o(.text);
asm/psychic.o(.text);
src/battle/anim/psychic.o(.text);
src/battle/anim/bug.o(.text);
src/battle/anim/rock.o(.text);
asm/ghost.o(.text);
src/battle/anim/dragon.o(.text);
src/battle/anim/dark.o(.text);
asm/dark.o(.text);
asm/ground.o(.text);
asm/normal.o(.text);
src/battle/anim/battle_intro.o(.text);

View File

@ -1,15 +1,6 @@
@ TODO: remove the raw pointers
.align 2
gMPlayTable:: @ 845545C
.if DEBUG
music_player gMPlay_BGM, 0x3000878, 10, 0
music_player gMPlay_SE1, 0x3000B98, 3, 1
music_player gMPlay_SE2, 0x3000C88, 9, 1
music_player gMPlay_SE3, 0x3000F58, 1, 0
.else
music_player gMPlay_BGM, 0x30007F8, 10, 0
music_player gMPlay_SE1, 0x3000B18, 3, 1
music_player gMPlay_SE2, 0x3000C08, 9, 1
music_player gMPlay_SE3, 0x3000ED8, 1, 0
.endif
music_player gMPlay_BGM, gUnknown_030007B8 + 0x40, 10, 0
music_player gMPlay_SE1, gUnknown_030007B8 + 0x360, 3, 1
music_player gMPlay_SE2, gUnknown_030007B8 + 0x450, 9, 1
music_player gMPlay_SE3, gUnknown_030007B8 + 0x720, 1, 0

View File

@ -1,22 +1,47 @@
#include "global.h"
#include "rom_8077ABC.h"
#include "trig.h"
#include "battle_anim.h"
#include "sound.h"
#include "blend_palette.h"
#include "decompress.h"
#include "ewram.h"
#include "palette.h"
#include "rom_8077ABC.h"
#include "scanline_effect.h"
void sub_80DFE90(struct Sprite *sprite);
void sub_80DFC9C(u8 taskId);
void sub_80DFD58(u8 taskId);
#include "sound.h"
#include "sprite.h"
#include "trig.h"
#include "constants/battle_constants.h"
extern s16 gBattleAnimArgs[];
extern u8 gAnimBankAttacker;
extern u8 gAnimBankTarget;
extern u8 gObjectBankIDs[];
extern u16 gBattle_BG1_X;
extern u16 gBattle_BG1_Y;
extern u16 gBattle_BG2_X;
extern u16 gBattle_BG2_Y;
extern u16 gBattle_WIN0H;
extern u16 gBattle_WIN0V;
extern u16 gBattlePartyID[];
extern u8 gAnimMoveTurn;
extern const u8 gUnknown_08D1D574[];
extern const u8 gUnknown_08D1D410[];
extern const u16 gUnknown_08D1D54C[];
static void sub_80DFE90(struct Sprite *sprite);
static void sub_80DFC9C(u8 taskId);
static void sub_80DFD58(u8 taskId);
static void sub_80DFF58(struct Sprite *sprite);
static void sub_80DFF98(struct Sprite *sprite);
static void sub_80E00D0(struct Sprite *sprite);
static void sub_80E02A4(u8 taskId);
static void sub_80E0620(u8 taskId);
static void sub_80E08CC(u8 priority);
static void sub_80E079C(struct Task *task);
static void sub_80E0CD0(u8 taskId);
// used in Smoke Ball escape, Sky Attack, Feint Attack and Camouflage
void sub_80DFC24(u8 taskId)
{
int bank;
@ -31,7 +56,7 @@ void sub_80DFC24(u8 taskId)
gTasks[taskId].func = sub_80DFC9C;
}
void sub_80DFC9C(u8 taskId)
static void sub_80DFC9C(u8 taskId)
{
u8 r2 = gTasks[taskId].data[1] >> 8;
u8 r1 = gTasks[taskId].data[1];
@ -111,7 +136,7 @@ void sub_80DFE14(struct Sprite *sprite)
sub_80DFE90(sprite);
}
void sub_80DFE90(struct Sprite *sprite)
static void sub_80DFE90(struct Sprite *sprite)
{
sprite->data[3] += sprite->data[1];
sprite->data[4] += sprite->data[2];
@ -136,3 +161,848 @@ void sub_80DFE90(struct Sprite *sprite)
if (--sprite->data[0] == 0)
DestroyAnimSprite(sprite);
}
void sub_80DFF1C(struct Sprite *sprite)
{
sprite->pos1.x += gBattleAnimArgs[0];
sprite->pos1.y += gBattleAnimArgs[1];
StartSpriteAffineAnim(sprite, gBattleAnimArgs[2]);
sprite->data[0] = gBattleAnimArgs[3];
sprite->data[1] = gBattleAnimArgs[4];
sprite->data[2] = gBattleAnimArgs[5];
sprite->callback = sub_80DFF58;
}
static void sub_80DFF58(struct Sprite *sprite)
{
sprite->data[4] += sprite->data[0];
sprite->data[5] += sprite->data[1];
sprite->pos2.x = sprite->data[4] >> 8;
sprite->pos2.y = sprite->data[5] >> 8;
if (++sprite->data[3] == sprite->data[2])
sprite->callback = sub_80DFF98;
}
static void sub_80DFF98(struct Sprite *sprite)
{
sprite->data[4] -= sprite->data[0];
sprite->data[5] -= sprite->data[1];
sprite->pos2.x = sprite->data[4] >> 8;
sprite->pos2.y = sprite->data[5] >> 8;
if (--sprite->data[3] == 0)
move_anim_8074EE0(sprite);
}
void sub_80DFFD0(struct Sprite *sprite)
{
u8 bank;
s8 xOffset;
if (gBattleAnimArgs[0] == 0)
bank = gAnimBankAttacker;
else
bank = gAnimBankTarget;
xOffset = 20;
sprite->oam.tileNum += 4;
switch (gBattleAnimArgs[1])
{
case 0:
sprite->pos1.x = sub_807A100(bank, 5) - 8;
sprite->pos1.y = sub_807A100(bank, 2) + 8;
break;
case 1:
sprite->pos1.x = sub_807A100(bank, 5) - 14;
sprite->pos1.y = sub_807A100(bank, 2) + 16;
break;
case 2:
sprite->pos1.x = sub_807A100(bank, 4) + 8;
sprite->pos1.y = sub_807A100(bank, 2) + 8;
StartSpriteAffineAnim(sprite, 1);
xOffset = -20;
break;
case 3:
sprite->pos1.x = sub_807A100(bank, 4) + 14;
sprite->pos1.y = sub_807A100(bank, 2) + 16;
StartSpriteAffineAnim(sprite, 1);
xOffset = -20;
break;
}
sprite->data[0] = 32;
sprite->data[2] = sprite->pos1.x + xOffset;
sprite->data[4] = sprite->pos1.y + 12;
sprite->data[5] = -12;
sub_80786EC(sprite);
sprite->callback = sub_80E00D0;
}
static void sub_80E00D0(struct Sprite *sprite)
{
if (sub_8078718(sprite))
move_anim_8074EE0(sprite);
}
void sub_80E00EC(u8 taskId)
{
struct ScanlineEffectParams scanlineParams;
struct Struct_sub_8078914 subStruct;
u16 i;
u8 pos;
int var0;
struct Task *task = &gTasks[taskId];
task->data[7] = GetBankPosition(gAnimBankAttacker, 1) + 31;
task->data[6] = sub_807A100(gAnimBankAttacker, 2) - 7;
task->data[5] = task->data[7];
task->data[4] = task->data[6];
task->data[13] = (task->data[7] - task->data[6]) << 8;
pos = GetBankPosition(gAnimBankAttacker, 0);
task->data[14] = pos - 32;
task->data[15] = pos + 32;
if (GetBankSide(gAnimBankAttacker) == SIDE_PLAYER)
task->data[8] = -12;
else
task->data[8] = -64;
task->data[3] = GetBankIdentity_permutated(gAnimBankAttacker);
if (task->data[3] == 1)
{
sub_8078914(&subStruct);
task->data[10] = gBattle_BG1_Y;
REG_BLDCNT = 0x3F42;
FillPalette(0, subStruct.field_8 << 4, 32);
scanlineParams.dmaDest = &REG_BG1VOFS;
var0 = 2;
if (!IsContest())
gBattle_BG2_X += 240;
}
else
{
task->data[10] = gBattle_BG2_Y;
REG_BLDCNT = 0x3F44;
FillPalette(0, 144, 32);
scanlineParams.dmaDest = &REG_BG2VOFS;
var0 = 4;
if (!IsContest())
gBattle_BG1_X += 240;
}
scanlineParams.dmaControl = 0xA2600001;
scanlineParams.initState = 1;
scanlineParams.unused9 = 0;
task->data[11] = 0;
task->data[12] = 16;
task->data[0] = 0;
task->data[1] = 0;
task->data[2] = 0;
sub_80E08CC(3);
for (i = 0; i < 112; i++)
{
gScanlineEffectRegBuffers[0][i] = task->data[10];
gScanlineEffectRegBuffers[1][i] = task->data[10];
}
ScanlineEffect_SetParams(scanlineParams);
REG_WINOUT = 0x3F00 | (var0 ^ 0x3F);
REG_WININ = 0x3F3F;
gBattle_WIN0H = (task->data[14] << 8) | task->data[15];
gBattle_WIN0V = 160;
task->func = sub_80E02A4;
}
static void sub_80E02A4(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
{
case 0:
if (++task->data[1] > 1)
{
task->data[1] = 0;
if (++task->data[2] & 1)
{
if (task->data[11] != 12)
task->data[11]++;
}
else
{
if (task->data[12] != 8)
task->data[12]--;
}
REG_BLDALPHA = (task->data[12] << 8) | task->data[11];
if (task->data[11] == 12 && task->data[12] == 8)
task->data[0]++;
}
break;
case 1:
task->data[4] -= 8;
sub_80E079C(task);
if (task->data[4] < task->data[8])
task->data[0]++;
break;
case 2:
task->data[4] -= 8;
sub_80E079C(task);
task->data[14] += 4;
task->data[15] -= 4;
if (task->data[14] >= task->data[15])
task->data[14] = task->data[15];
gBattle_WIN0H = (task->data[14] << 8) | task->data[15];
if (task->data[14] == task->data[15])
task->data[0]++;
break;
case 3:
gScanlineEffect.state = 3;
task->data[0]++;
break;
case 4:
DestroyAnimVisualTask(taskId);
break;
}
}
void sub_80E03BC(u8 taskId)
{
struct Struct_sub_8078914 subStruct;
struct ScanlineEffectParams scanlineParams;
u8 pos;
u16 i;
struct Task *task = &gTasks[taskId];
switch (task->data[0])
{
case 0:
if (IsContest() == TRUE)
{
gBattle_WIN0H = 0;
gBattle_WIN0V = 0;
REG_WININ = 0x3F3F;
REG_WINOUT = 0x3F3F;
DestroyAnimVisualTask(taskId);
}
else
{
task->data[3] = GetBankIdentity_permutated(gAnimBankTarget);
if (task->data[3] == 1)
{
REG_BLDCNT = 0x3F42;
gBattle_BG2_X += 240;
}
else
{
REG_BLDCNT = 0x3F44;
gBattle_BG1_X += 240;
}
task->data[0]++;
}
break;
case 1:
if (task->data[3] == 1)
{
sub_8078914(&subStruct);
task->data[10] = gBattle_BG1_Y;
FillPalette(0, subStruct.field_8 << 4, 32);
}
else
{
task->data[10] = gBattle_BG2_Y;
FillPalette(0, 144, 32);
}
sub_80E08CC(3);
task->data[0]++;
break;
case 2:
task->data[7] = GetBankPosition(gAnimBankTarget, 1) + 31;
task->data[6] = sub_807A100(gAnimBankTarget, 2) - 7;
task->data[13] = (task->data[7] - task->data[6]) << 8;
pos = GetBankPosition(gAnimBankTarget, 0);
task->data[14] = pos - 4;
task->data[15] = pos + 4;
if (GetBankSide(gAnimBankTarget) == SIDE_PLAYER)
task->data[8] = -12;
else
task->data[8] = -64;
task->data[4] = task->data[8];
task->data[5] = task->data[8];
task->data[11] = 12;
task->data[12] = 8;
task->data[0]++;
break;
case 3:
if (task->data[3] == 1)
scanlineParams.dmaDest = &REG_BG1VOFS;
else
scanlineParams.dmaDest = &REG_BG2VOFS;
for (i = 0; i < 112; i++)
{
gScanlineEffectRegBuffers[0][i] = task->data[10] + (159 - i);
gScanlineEffectRegBuffers[1][i] = task->data[10] + (159 - i);
}
scanlineParams.dmaControl = 0xA2600001;
scanlineParams.initState = 1;
scanlineParams.unused9 = 0;
ScanlineEffect_SetParams(scanlineParams);
task->data[0]++;
break;
case 4:
if (task->data[3] == 1)
REG_WINOUT = 0x3F3D;
else
REG_WINOUT = 0x3F3B;
REG_WININ = 0x3F3F;
gBattle_WIN0H = (task->data[14] << 8) | task->data[15];
gBattle_WIN0V = 160;
task->data[0] = 0;
task->data[1] = 0;
task->data[2] = 0;
REG_BLDALPHA = 0x80C;
task->func = sub_80E0620;
break;
}
}
static void sub_80E0620(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
{
case 0:
task->data[5] += 8;
if (task->data[5] >= task->data[7])
task->data[5] = task->data[7];
sub_80E079C(task);
if (task->data[5] == task->data[7])
task->data[0]++;
break;
case 1:
if (task->data[15] - task->data[14] < 64)
{
task->data[14] -= 4;
task->data[15] += 4;
}
else
{
task->data[1] = 1;
}
gBattle_WIN0H = (task->data[14] << 8) | task->data[15];
task->data[4] += 8;
if (task->data[4] >= task->data[6])
task->data[4] = task->data[6];
sub_80E079C(task);
if (task->data[4] == task->data[6] && task->data[1] != 0)
{
task->data[1] = 0;
task->data[0]++;
}
break;
case 2:
if (++task->data[1] > 1)
{
task->data[1] = 0;
if ((++task->data[2] & 1) != 0)
{
if (task->data[11] != 0)
task->data[11]--;
}
else
{
if (task->data[12] < 16)
task->data[12]++;
}
REG_BLDALPHA = (task->data[12] << 8) | task->data[11];
if (task->data[11] == 0 && task->data[12] == 16)
task->data[0]++;
}
break;
case 3:
gScanlineEffect.state = 3;
task->data[0]++;
break;
case 4:
gBattle_WIN0H = 0;
gBattle_WIN0V = 0;
REG_WININ = 0x3F3F;
REG_WINOUT = 0x3F3F;
DestroyAnimVisualTask(taskId);
break;
}
}
// static void sub_80E079C(struct Task *task)
// {
// int var0, var1;
// s16 var2;
// s16 i, j;
// var2 = task->data[5] - task->data[4];
// if (var2 != 0)
// {
// var0 = task->data[13] / var2;
// var1 = task->data[6];
// for (i = 0; i < task->data[4]; i++)
// {
// gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[10] - (i - 159);
// }
// for (i = task->data[4]; i <= task->data[5]; i++)
// {
// if (i >= 0)
// {
// gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = (var1 - i) + task->data[10];
// }
// var1 += var0;
// }
// for (j = i; j < task->data[7]; j++)
// {
// if (j >= 0)
// {
// gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][j] = (task->data[10] + 159) - j;
// }
// }
// }
// else
// {
// for (i = 0; i < 112; i++)
// {
// gScanlineEffectRegBuffers[0][i] = task->data[10] + 159 - i;
// gScanlineEffectRegBuffers[1][i] = task->data[10] + 159 - i;
// }
// }
// }
__attribute__((naked))
static void sub_80E079C(struct Task *task)
{
asm(".syntax unified\n\
push {r4-r7,lr}\n\
mov r7, r8\n\
push {r7}\n\
adds r6, r0, 0\n\
ldrh r0, [r6, 0x12]\n\
ldrh r4, [r6, 0x10]\n\
subs r0, r4\n\
lsls r0, 16\n\
asrs r1, r0, 16\n\
cmp r1, 0\n\
beq _080E0890\n\
movs r2, 0x22\n\
ldrsh r0, [r6, r2]\n\
bl __divsi3\n\
mov r8, r0\n\
movs r3, 0x14\n\
ldrsh r0, [r6, r3]\n\
lsls r5, r0, 8\n\
lsls r0, r4, 16\n\
movs r4, 0\n\
cmp r0, 0\n\
ble _080E07FC\n\
ldr r0, _080E0888 @ =gScanlineEffectRegBuffers\n\
mov r12, r0\n\
ldr r7, _080E088C @ =gScanlineEffect\n\
_080E07D0:\n\
lsls r2, r4, 16\n\
asrs r2, 16\n\
lsls r3, r2, 1\n\
ldrb r1, [r7, 0x14]\n\
lsls r0, r1, 4\n\
subs r0, r1\n\
lsls r0, 7\n\
adds r3, r0\n\
add r3, r12\n\
adds r1, r2, 0\n\
subs r1, 0x9F\n\
ldrh r0, [r6, 0x1C]\n\
subs r0, r1\n\
strh r0, [r3]\n\
adds r2, 0x1\n\
lsls r2, 16\n\
lsrs r4, r2, 16\n\
asrs r2, 16\n\
movs r1, 0x10\n\
ldrsh r0, [r6, r1]\n\
cmp r2, r0\n\
blt _080E07D0\n\
_080E07FC:\n\
ldrh r4, [r6, 0x10]\n\
lsls r3, r4, 16\n\
asrs r1, r3, 16\n\
movs r2, 0x12\n\
ldrsh r0, [r6, r2]\n\
cmp r1, r0\n\
bgt _080E0846\n\
ldr r0, _080E0888 @ =gScanlineEffectRegBuffers\n\
mov r12, r0\n\
ldr r7, _080E088C @ =gScanlineEffect\n\
_080E0810:\n\
asrs r4, r3, 16\n\
cmp r4, 0\n\
blt _080E0832\n\
asrs r1, r5, 8\n\
subs r1, r4\n\
lsls r3, r4, 1\n\
ldrb r2, [r7, 0x14]\n\
lsls r0, r2, 4\n\
subs r0, r2\n\
lsls r0, 7\n\
adds r3, r0\n\
add r3, r12\n\
lsls r1, 16\n\
asrs r1, 16\n\
ldrh r2, [r6, 0x1C]\n\
adds r1, r2\n\
strh r1, [r3]\n\
_080E0832:\n\
add r5, r8\n\
adds r0, r4, 0x1\n\
lsls r0, 16\n\
lsrs r4, r0, 16\n\
lsls r3, r4, 16\n\
asrs r1, r3, 16\n\
movs r2, 0x12\n\
ldrsh r0, [r6, r2]\n\
cmp r1, r0\n\
ble _080E0810\n\
_080E0846:\n\
movs r3, 0x1C\n\
ldrsh r0, [r6, r3]\n\
adds r0, 0x9F\n\
lsls r2, r4, 16\n\
asrs r1, r2, 16\n\
subs r5, r0, r1\n\
movs r3, 0x16\n\
ldrsh r0, [r6, r3]\n\
cmp r1, r0\n\
bge _080E08BE\n\
ldr r7, _080E0888 @ =gScanlineEffectRegBuffers\n\
ldr r4, _080E088C @ =gScanlineEffect\n\
_080E085E:\n\
asrs r3, r2, 16\n\
cmp r3, 0\n\
blt _080E0876\n\
lsls r2, r3, 1\n\
ldrb r1, [r4, 0x14]\n\
lsls r0, r1, 4\n\
subs r0, r1\n\
lsls r0, 7\n\
adds r2, r0\n\
adds r2, r7\n\
strh r5, [r2]\n\
subs r5, 0x1\n\
_080E0876:\n\
adds r0, r3, 0x1\n\
lsls r2, r0, 16\n\
asrs r1, r2, 16\n\
movs r3, 0x16\n\
ldrsh r0, [r6, r3]\n\
cmp r1, r0\n\
blt _080E085E\n\
b _080E08BE\n\
.align 2, 0\n\
_080E0888: .4byte gScanlineEffectRegBuffers\n\
_080E088C: .4byte gScanlineEffect\n\
_080E0890:\n\
movs r1, 0x1C\n\
ldrsh r0, [r6, r1]\n\
adds r5, r0, 0\n\
adds r5, 0x9F\n\
movs r4, 0\n\
ldr r3, _080E08C8 @ =gScanlineEffectRegBuffers\n\
movs r2, 0xF0\n\
lsls r2, 3\n\
adds r6, r3, r2\n\
_080E08A2:\n\
lsls r0, r4, 16\n\
asrs r0, 16\n\
lsls r2, r0, 1\n\
adds r1, r2, r3\n\
strh r5, [r1]\n\
adds r2, r6\n\
strh r5, [r2]\n\
subs r5, 0x1\n\
adds r0, 0x1\n\
lsls r0, 16\n\
lsrs r4, r0, 16\n\
asrs r0, 16\n\
cmp r0, 0x6F\n\
ble _080E08A2\n\
_080E08BE:\n\
pop {r3}\n\
mov r8, r3\n\
pop {r4-r7}\n\
pop {r0}\n\
bx r0\n\
.align 2, 0\n\
_080E08C8: .4byte gScanlineEffectRegBuffers\n\
.syntax divided\n");
}
static void sub_80E08CC(u8 priority)
{
u16 i;
for (i = 0; i < 4; i++)
{
u8 spriteId = GetAnimBankSpriteId(i);
if (spriteId != 0xFF)
gSprites[spriteId].oam.priority = priority;
}
}
void sub_80E0918(u8 taskId)
{
u8 toBG2 = GetBankIdentity_permutated(gAnimBankAttacker) ^ 1 ? 1 : 0;
sub_8076034(gAnimBankAttacker, toBG2);
gSprites[gObjectBankIDs[gAnimBankAttacker]].invisible = 0;
if (IsAnimBankSpriteVisible(gAnimBankAttacker ^ 2))
{
sub_8076034(gAnimBankAttacker ^ 2, toBG2 ^ 1);
gSprites[gObjectBankIDs[gAnimBankAttacker ^ 2]].invisible = 0;
}
DestroyAnimVisualTask(taskId);
}
void sub_80E09C4(u8 taskId)
{
u8 toBG2 = GetBankIdentity_permutated(gAnimBankAttacker) ^ 1 ? 1 : 0;
sub_8076464(toBG2);
if (IsAnimBankSpriteVisible(gAnimBankAttacker ^ 2))
sub_8076464(toBG2 ^ 1);
DestroyAnimVisualTask(taskId);
}
void sub_80E0A10(struct Sprite *sprite)
{
sprite->pos1.x += gBattleAnimArgs[0];
sprite->pos1.y += gBattleAnimArgs[1];
StartSpriteAnim(sprite, gBattleAnimArgs[2]);
sprite->callback = sub_8078600;
StoreSpriteCallbackInData(sprite, DestroyAnimSprite);
}
void sub_80E0A4C(u8 taskId)
{
u16 species;
u8 spriteId;
u8 newSpriteId;
u16 paletteNum;
struct Struct_sub_8078914 subStruct;
int var0 = 0;
gBattle_WIN0H = var0;
gBattle_WIN0V = var0;
REG_WININ = 0x3F3F;
REG_WINOUT = 0x3F3D;
REG_DISPCNT |= DISPCNT_OBJWIN_ON;
REG_BLDCNT = 0x3F42;
REG_BLDALPHA = 0xC08;
REG_BG1CNT_BITFIELD.priority = 0;
REG_BG1CNT_BITFIELD.screenSize = 0;
if (!IsContest())
REG_BG1CNT_BITFIELD.charBaseBlock = 1;
if (IsDoubleBattle() && !IsContest())
{
if (GetBankIdentity(gAnimBankAttacker) == 3 || GetBankIdentity(gAnimBankAttacker) == 0)
{
if (IsAnimBankSpriteVisible(gAnimBankAttacker ^ 2) == TRUE)
{
gSprites[gObjectBankIDs[gAnimBankAttacker ^ 2]].oam.priority--;
REG_BG1CNT_BITFIELD.priority = 1;
var0 = 1;
}
}
}
if (IsContest())
{
species = EWRAM_19348;
}
else
{
if (GetBankSide(gAnimBankAttacker) != SIDE_PLAYER)
species = GetMonData(&gEnemyParty[gBattlePartyID[gAnimBankAttacker]], MON_DATA_SPECIES);
else
species = GetMonData(&gPlayerParty[gBattlePartyID[gAnimBankAttacker]], MON_DATA_SPECIES);
}
spriteId = GetAnimBankSpriteId(0);
newSpriteId = sub_807A4A0(gAnimBankAttacker, spriteId, species);
sub_8078914(&subStruct);
DmaClear32(3, subStruct.field_4, 0x1000);
LZDecompressVram(&gUnknown_08D1D574, subStruct.field_4);
LZDecompressVram(&gUnknown_08D1D410, subStruct.field_0);
LoadCompressedPalette(&gUnknown_08D1D54C, subStruct.field_8 << 4, 32);
gBattle_BG1_X = -gSprites[spriteId].pos1.x + 96;
gBattle_BG1_Y = -gSprites[spriteId].pos1.y + 32;
paletteNum = 16 + gSprites[spriteId].oam.paletteNum;
if (gBattleAnimArgs[1] == 0)
sub_8079108(paletteNum, FALSE);
else
BlendPalette(paletteNum * 16, 16, 11, gBattleAnimArgs[2]);
gTasks[taskId].data[0] = newSpriteId;
gTasks[taskId].data[1] = gBattleAnimArgs[0];
gTasks[taskId].data[2] = gBattleAnimArgs[1];
gTasks[taskId].data[3] = gBattleAnimArgs[2];
gTasks[taskId].data[6] = var0;
gTasks[taskId].func = sub_80E0CD0;
}
static void sub_80E0CD0(u8 taskId)
{
struct Struct_sub_8078914 subStruct;
u16 paletteNum;
u8 spriteId;
u8 taskIdCopy = taskId;
gTasks[taskIdCopy].data[10] += 4;
gBattle_BG1_X -= 4;
if (gTasks[taskIdCopy].data[10] == 128)
{
gTasks[taskIdCopy].data[10] = 0;
gBattle_BG1_X += 128;
if (++gTasks[taskIdCopy].data[11] == 2)
{
sub_8076464(0);
gBattle_WIN0H = 0;
gBattle_WIN0V = 0;
REG_WININ = 0x3F3F;
REG_WINOUT = 0x3F3F;
if (!IsContest())
REG_BG1CNT_BITFIELD.charBaseBlock = 0;
REG_DISPCNT ^= DISPCNT_OBJWIN_ON;
REG_BLDCNT = 0;
REG_BLDALPHA = 0;
spriteId = GetAnimBankSpriteId(0);
paletteNum = 16 + gSprites[spriteId].oam.paletteNum;
if (gTasks[taskIdCopy].data[1] == 0)
sub_8079108(paletteNum, 1);
DestroySprite(&gSprites[gTasks[taskIdCopy].data[0]]);
sub_8078914(&subStruct);
DmaClear32(3, subStruct.field_4, 0x800);
if (gTasks[taskIdCopy].data[6] == 1)
{
gSprites[gObjectBankIDs[gAnimBankAttacker ^ 2]].oam.priority++;
}
DestroyAnimVisualTask(taskIdCopy);
}
}
}
void sub_80E0E24(u8 taskId)
{
u8 spriteId;
u8 bank;
bool8 calcSpriteId = FALSE;
u8 identity = 0;
switch (gBattleAnimArgs[0])
{
case 0:
case 1:
case 2:
case 3:
spriteId = GetAnimBankSpriteId(gBattleAnimArgs[0]);
break;
case 4:
identity = IDENTITY_PLAYER_MON1;
calcSpriteId = TRUE;
break;
case 5:
identity = IDENTITY_PLAYER_MON2;
calcSpriteId = TRUE;
break;
case 6:
identity = IDENTITY_OPPONENT_MON1;
calcSpriteId = TRUE;
break;
case 7:
identity = IDENTITY_OPPONENT_MON2;
calcSpriteId = TRUE;
break;
default:
spriteId = 0xFF;
break;
}
if (calcSpriteId)
{
bank = GetBankByIdentity(identity);
if (IsAnimBankSpriteVisible(bank))
spriteId = gObjectBankIDs[bank];
else
spriteId = 0xFF;
}
if (spriteId != 0xFF)
sub_8079108(gSprites[spriteId].oam.paletteNum + 16, gBattleAnimArgs[1]);
DestroyAnimVisualTask(taskId);
}
void sub_80E0EE8(u8 taskId)
{
if (gAnimMoveTurn < 2)
gBattleAnimArgs[7] = 0;
if (gAnimMoveTurn == 2)
gBattleAnimArgs[7] = 1;
DestroyAnimVisualTask(taskId);
}

900
src/battle/anim/psychic.c Normal file
View File

@ -0,0 +1,900 @@
#include "global.h"
#include "battle.h"
#include "battle_anim.h"
#include "palette.h"
#include "rom_8077ABC.h"
#include "scanline_effect.h"
#include "sound.h"
#include "task.h"
#include "trig.h"
#include "constants/songs.h"
extern s16 gBattleAnimArgs[];
extern u8 gAnimBankAttacker;
extern u8 gAnimBankTarget;
extern u16 gBattle_BG1_X;
extern u16 gBattle_BG2_X;
extern u8 gObjectBankIDs[];
extern const union AffineAnimCmd *const gUnknown_083DA888[];
extern struct AffineAnimFrameCmd gUnknown_083DA8A4;
extern struct AffineAnimFrameCmd gUnknown_083DA8C4;
extern const struct SpriteTemplate gSpriteTemplate_83DA8DC;
extern const struct SpriteTemplate gSpriteTemplate_83DA9AC;
static void sub_80DB88C(struct Sprite *sprite);
static void sub_80DB8C0(struct Sprite *sprite);
static void sub_80DB92C(struct Sprite *sprite);
static void sub_80DB9E4(struct Sprite *sprite);
static void sub_80DBC00(struct Sprite *sprite);
static void sub_80DBC34(struct Sprite *sprite);
static void sub_80DBCD0(u8 taskId);
static void sub_80DBD58(u8 taskId);
static void sub_80DBE98(u8 taskId);
static void sub_80DC1FC(u8 taskId);
static void sub_80DC3F4(u8 taskId);
void sub_80DC5F4(u8 taskId);
void sub_80DB74C(struct Sprite *sprite)
{
if (GetBankSide(gAnimBankAttacker) == SIDE_PLAYER || IsContest())
{
sprite->oam.priority = 2;
sprite->subpriority = 200;
}
if (!IsContest())
{
u8 bankCopy;
u8 bank = bankCopy = GetBankByIdentity(IDENTITY_OPPONENT_MON1);
u8 identity = GetBankIdentity_permutated(bank);
int var0 = 1;
u8 toBG_2 = (identity ^ var0) != 0;
if (IsAnimBankSpriteVisible(bank))
sub_8076034(bank, toBG_2);
bank = bankCopy ^ 2;
if (IsAnimBankSpriteVisible(bank))
sub_8076034(bank, toBG_2 ^ var0);
}
if (!IsContest() && IsDoubleBattle())
{
if (GetBankSide(gAnimBankAttacker) == SIDE_PLAYER)
{
sprite->pos1.x = 72;
sprite->pos1.y = 80;
}
else
{
sprite->pos1.x = 176;
sprite->pos1.y = 40;
}
}
else
{
if (GetBankSide(gAnimBankAttacker) != SIDE_PLAYER)
gBattleAnimArgs[0] = -gBattleAnimArgs[0];
sprite->pos1.x = GetBankPosition(gAnimBankAttacker, 0) + gBattleAnimArgs[0];
sprite->pos1.y = GetBankPosition(gAnimBankAttacker, 1) + gBattleAnimArgs[1];
}
if (IsContest())
sprite->pos1.y += 9;
sprite->data[0] = 256 + IndexOfSpritePaletteTag(gBattleAnimArgs[2]) * 16;
sprite->callback = sub_80DB88C;
sprite->callback(sprite);
}
static void sub_80DB88C(struct Sprite *sprite)
{
REG_BLDALPHA = ((16 - sprite->data[3]) << 8) | sprite->data[3];
if (sprite->data[3] == 13)
sprite->callback = sub_80DB8C0;
else
sprite->data[3]++;
}
static void sub_80DB8C0(struct Sprite *sprite)
{
u16 color;
u16 startOffset;
int i;
if (++sprite->data[1] == 2)
{
sprite->data[1] = 0;
startOffset = sprite->data[0];
color = gPlttBufferFaded[startOffset + 8];
for (i = 8; i > 0; i--)
gPlttBufferFaded[startOffset + i] = gPlttBufferFaded[startOffset + i - 1];
gPlttBufferFaded[startOffset + 1] = color;
if (++sprite->data[2] == 16)
sprite->callback = sub_80DB92C;
}
}
static void sub_80DB92C(struct Sprite *sprite)
{
REG_BLDALPHA = ((16 - sprite->data[3]) << 8) | sprite->data[3];
if (--sprite->data[3] == -1)
{
if (!IsContest())
{
u8 bankCopy;
u8 bank = bankCopy = GetBankByIdentity(IDENTITY_OPPONENT_MON1);
if (IsAnimBankSpriteVisible(bank))
gSprites[gObjectBankIDs[bank]].invisible = 0;
bank = bankCopy ^ 2;
if (IsAnimBankSpriteVisible(bank))
gSprites[gObjectBankIDs[bank]].invisible = 0;
}
sprite->invisible = 1;
sprite->callback = sub_80DB9E4;
}
}
static void sub_80DB9E4(struct Sprite *sprite)
{
if (!IsContest())
{
u8 bankCopy;
u8 bank = bankCopy = GetBankByIdentity(IDENTITY_OPPONENT_MON1);
u8 identity = GetBankIdentity_permutated(bank);
int var0 = 1;
u8 toBG_2 = (identity ^ var0) != 0;
if (IsAnimBankSpriteVisible(bank))
sub_8076464(toBG_2);
bank = bankCopy ^ 2;
if (IsAnimBankSpriteVisible(bank))
sub_8076464(toBG_2 ^ var0);
}
sprite->callback = DestroyAnimSprite;
}
void sub_80DBA4C(struct Sprite *sprite)
{
if (sprite->data[0] == 0)
{
int arg3 = gBattleAnimArgs[3];
u8 var0 = 0;
if (arg3 == 0)
var0 = 1;
if (!IsContest() && IsDoubleBattle())
{
if (GetBankSide(gAnimBankAttacker) == SIDE_PLAYER)
{
sprite->pos1.x = 72 - gBattleAnimArgs[0];
sprite->pos1.y = gBattleAnimArgs[1] + 80;
}
else
{
sprite->pos1.x = gBattleAnimArgs[0] + 176;
sprite->pos1.y = gBattleAnimArgs[1] + 40;
}
}
else
{
if (gBattleAnimArgs[2] == 0)
sub_80787B0(sprite, var0);
else
sub_8078764(sprite, var0);
}
sprite->data[0]++;
}
else
{
if (sprite->animEnded || sprite->affineAnimEnded)
move_anim_8074EE0(sprite);
}
}
void sub_80DBAF4(struct Sprite *sprite)
{
sprite->pos1.x = GetBankPosition(gAnimBankAttacker, 2);
sprite->pos1.y = GetBankPosition(gAnimBankAttacker, 3);
if (GetBankSide(gAnimBankAttacker) != SIDE_PLAYER)
{
StartSpriteAnim(sprite, 1);
sprite->pos1.x -= 40;
sprite->pos1.y += 10;
sprite->data[1] = -1;
}
else
{
sprite->pos1.x += 40;
sprite->pos1.y -= 10;
sprite->data[1] = 1;
}
StoreSpriteCallbackInData(sprite, DestroyAnimSprite);
sprite->callback = sub_8078600;
}
void sub_80DBB70(struct Sprite *sprite)
{
s16 x = sub_807A100(gAnimBankAttacker, 1) / 2;
s16 y = sub_807A100(gAnimBankAttacker, 0) / -2;
if (GetBankSide(gAnimBankAttacker) == SIDE_OPPONENT)
{
x = -x;
}
sprite->pos1.x = GetBankPosition(gAnimBankAttacker, 2) + x;
sprite->pos1.y = GetBankPosition(gAnimBankAttacker, 3) + y;
if (sprite->pos1.y < 16)
{
sprite->pos1.y = 16;
}
StoreSpriteCallbackInData(sprite, sub_80DBC00);
sprite->callback = sub_8078600;
}
static void sub_80DBC00(struct Sprite *sprite)
{
sprite->oam.affineMode = 1;
sprite->affineAnims = gUnknown_083DA888;
sprite->data[0] = 0;
InitSpriteAffineAnim(sprite);
sprite->callback = sub_80DBC34;
}
static void sub_80DBC34(struct Sprite *sprite)
{
switch (sprite->data[0])
{
case 0:
if (sprite->affineAnimEnded)
{
FreeOamMatrix(sprite->oam.matrixNum);
sprite->oam.affineMode = 0;
sprite->data[1] = 18;
sprite->data[0]++;
}
break;
case 1:
if (--sprite->data[1] == -1)
{
DestroyAnimSprite(sprite);
}
break;
}
}
void sub_80DBC94(u8 taskId)
{
struct Task *task = &gTasks[taskId];
u8 spriteId = GetAnimBankSpriteId(0);
task->data[0] = spriteId;
sub_80798F4(task, spriteId, &gUnknown_083DA8A4);
task->func = sub_80DBCD0;
}
static void sub_80DBCD0(u8 taskId)
{
if (!sub_807992C(&gTasks[taskId]))
{
DestroyAnimVisualTask(taskId);
}
}
void sub_80DBCFC(u8 taskId)
{
struct Task *task = &gTasks[taskId];
u8 spriteId = GetAnimBankSpriteId(0);
task->data[0] = spriteId;
task->data[1] = 0;
task->data[2] = 0;
task->data[3] = GetBankSide(gAnimBankAttacker) != SIDE_PLAYER ? 4 : 8;
sub_80798F4(task, task->data[0], &gUnknown_083DA8C4);
task->func = sub_80DBD58;
}
static void sub_80DBD58(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[1])
{
case 0:
sub_807992C(task);
if (++task->data[2] > 19)
task->data[1]++;
break;
case 1:
if (task->data[3] != 0)
{
gSprites[task->data[0]].pos2.y -= 8;
task->data[3]--;
}
else
{
gSprites[task->data[0]].invisible = 1;
gSprites[task->data[0]].pos1.x = 272;
sub_8078F40(task->data[0]);
DestroyAnimVisualTask(taskId);
}
break;
}
}
void sub_80DBE00(u8 taskId)
{
u16 var0, var1;
struct Task *task = &gTasks[taskId];
task->data[3] = 16;
task->data[4] = 0;
task->data[13] = GetBankPosition(gAnimBankAttacker, 2);
task->data[14] = GetBankPosition(gAnimBankAttacker, 3);
var0 = sub_807A100(gAnimBankAttacker, 1) / 3;
var1 = sub_807A100(gAnimBankAttacker, 0) / 3;
task->data[12] = var0 > var1 ? var0 : var1;
REG_BLDCNT = 0x3F40;
REG_BLDALPHA = 0x10;
task->func = sub_80DBE98;
}
static void sub_80DBE98(u8 taskId)
{
u16 i;
u8 spriteId;
struct Task *task = &gTasks[taskId];
switch (task->data[0])
{
case 0:
if (++task->data[1] > 8)
{
task->data[1] = 0;
spriteId = CreateSprite(&gSpriteTemplate_83DA8DC, task->data[13], task->data[14], 0);
task->data[task->data[2] + 8] = spriteId;
if (spriteId != 64)
{
switch (task->data[2])
{
case 0:
gSprites[spriteId].pos2.x = task->data[12];
gSprites[spriteId].pos2.y = -task->data[12];
break;
case 1:
gSprites[spriteId].pos2.x = -task->data[12];
gSprites[spriteId].pos2.y = task->data[12];
break;
case 2:
gSprites[spriteId].pos2.x = task->data[12];
gSprites[spriteId].pos2.y = task->data[12];
break;
case 3:
gSprites[spriteId].pos2.x = -task->data[12];
gSprites[spriteId].pos2.y = -task->data[12];
break;
}
}
if (++task->data[2] == 5)
task->data[0]++;
}
break;
case 1:
if (task->data[1] & 1)
task->data[3]--;
else
task->data[4]++;
REG_BLDALPHA = (task->data[4] << 8) | task->data[3];
if (++task->data[1] == 32)
{
for (i = 8; i < 13; i++)
{
if (task->data[i] != 64)
DestroySprite(&gSprites[task->data[i]]);
}
task->data[0]++;
}
break;
case 2:
task->data[0]++;
break;
case 3:
REG_BLDALPHA = 0;
REG_BLDCNT = 0;
DestroyAnimVisualTask(taskId);
break;
}
}
static void sub_80DC020(struct Sprite *sprite)
{
if (sprite->data[1] > sprite->data[0] - 10)
sprite->invisible = sprite->data[1] & 1;
if (sprite->data[1] == sprite->data[0])
DestroyAnimSprite(sprite);
sprite->data[1]++;
}
void sub_80DC068(struct Sprite *sprite)
{
if (gBattleAnimArgs[0] == 0)
{
sprite->pos1.x = GetBankPosition(gAnimBankAttacker, 2);
sprite->pos1.y = GetBankPosition(gAnimBankAttacker, 3);
}
sprite->data[0] = gBattleAnimArgs[1];
sprite->callback = sub_80DC020;
}
void sub_80DC0B0(u8 taskId)
{
struct Task *task = &gTasks[taskId];
if (IsContest())
{
if (gBattleAnimArgs[0] == 1)
{
task->data[10] = -10;
task->data[11] = sub_807A100(gAnimBankTarget, 5) - 8;
task->data[12] = sub_807A100(gAnimBankTarget, 2) + 8;
task->data[13] = sub_807A100(gAnimBankAttacker, 5) - 8;
task->data[14] = sub_807A100(gAnimBankAttacker, 2) + 8;
}
else
{
task->data[10] = 10;
task->data[11] = sub_807A100(gAnimBankAttacker, 4) + 8;
task->data[12] = sub_807A100(gAnimBankAttacker, 3) - 8;
task->data[13] = sub_807A100(gAnimBankTarget, 4) + 8;
task->data[14] = sub_807A100(gAnimBankTarget, 3) - 8;
}
}
else
{
if (gBattleAnimArgs[0] == 1)
{
task->data[10] = -10;
task->data[11] = sub_807A100(gAnimBankTarget, 4) + 8;
task->data[12] = sub_807A100(gAnimBankTarget, 2) + 8;
task->data[13] = sub_807A100(gAnimBankAttacker, 4) + 8;
task->data[14] = sub_807A100(gAnimBankAttacker, 2) + 8;
}
else
{
task->data[10] = 10;
task->data[11] = sub_807A100(gAnimBankAttacker, 5) - 8;
task->data[12] = sub_807A100(gAnimBankAttacker, 3) - 8;
task->data[13] = sub_807A100(gAnimBankTarget, 5) - 8;
task->data[14] = sub_807A100(gAnimBankTarget, 3) - 8;
}
}
task->data[1] = 6;
task->func = sub_80DC1FC;
}
static void sub_80DC1FC(u8 taskId)
{
u8 spriteId;
struct Task *task = &gTasks[taskId];
switch (task->data[0])
{
case 0:
if (++task->data[1] > 6)
{
task->data[1] = 0;
spriteId = CreateSprite(&gSpriteTemplate_83DA9AC, task->data[11], task->data[12], 0);
if (spriteId != 64)
{
gSprites[spriteId].data[0] = 16;
gSprites[spriteId].data[2] = task->data[13];
gSprites[spriteId].data[4] = task->data[14];
gSprites[spriteId].data[5] = task->data[10];
sub_80786EC(&gSprites[spriteId]);
StartSpriteAffineAnim(&gSprites[spriteId], task->data[2] & 3);
}
if (++task->data[2] == 12)
task->data[0]++;
}
break;
case 1:
if (++task->data[1] > 17)
DestroyAnimVisualTask(taskId);
break;
}
}
void sub_80DC2B0(struct Sprite *sprite)
{
if (sub_8078718(sprite))
{
FreeOamMatrix(sprite->oam.matrixNum);
DestroySprite(sprite);
}
}
void sub_80DC2D4(u8 taskId)
{
s16 i;
u8 var1;
struct ScanlineEffectParams scanlineParams;
struct Task *task = &gTasks[taskId];
var1 = sub_8077FC0(gAnimBankTarget);
task->data[14] = var1 - 32;
switch (gBattleAnimArgs[0])
{
case 0:
task->data[11] = 2;
task->data[12] = 5;
task->data[13] = 64;
task->data[15] = var1 + 32;
break;
case 1:
task->data[11] = 2;
task->data[12] = 5;
task->data[13] = 192;
task->data[15] = var1 + 32;
break;
case 2:
task->data[11] = 4;
task->data[12] = 4;
task->data[13] = 0;
task->data[15] = var1 + 32;
break;
}
if (task->data[14] < 0)
task->data[14] = 0;
if (GetBankIdentity_permutated(gAnimBankTarget) == 1)
{
task->data[10] = gBattle_BG1_X;
scanlineParams.dmaDest = &REG_BG1HOFS;
}
else
{
task->data[10] = gBattle_BG2_X;
scanlineParams.dmaDest = &REG_BG2HOFS;
}
i = task->data[14];
while (i <= task->data[14] + 64)
{
gScanlineEffectRegBuffers[0][i] = task->data[10];
gScanlineEffectRegBuffers[1][i] = task->data[10];
i++;
}
scanlineParams.dmaControl = 0XA2600001;
scanlineParams.initState = 1;
scanlineParams.unused9 = 0;
ScanlineEffect_SetParams(scanlineParams);
task->func = sub_80DC3F4;
}
static void sub_80DC3F4(u8 taskId)
{
s16 sineIndex, i;
struct Task *task = &gTasks[taskId];
switch (task->data[0])
{
case 0:
sineIndex = task->data[13];
i = task->data[14];
while (i <= task->data[15])
{
s16 var2 = (gSineTable[sineIndex] >> task->data[12]);
if (var2 > 0)
{
var2 += (task->data[1] & 3);
}
else if (var2 < 0)
{
var2 -= (task->data[1] & 3);
}
gScanlineEffectRegBuffers[0][i] = task->data[10] + var2;
gScanlineEffectRegBuffers[1][i] = task->data[10] + var2;
sineIndex += task->data[11];
i++;
}
if (++task->data[1] > 23)
{
task->data[0]++;
}
break;
case 1:
gScanlineEffect.state = 3;
task->data[0]++;
break;
case 2:
DestroyAnimVisualTask(taskId);
break;
}
}
#ifdef NONMATCHING
void sub_80DC4F4(u8 taskId)
{
s16 spriteId;
u8 matrixNum;
register u8 matrixNum2 asm("r6");
struct Task *task = &gTasks[taskId];
matrixNum = AllocOamMatrix();
matrixNum2 = matrixNum;
if (matrixNum2 == 0xFF)
{
DestroyAnimVisualTask(taskId);
return;
}
spriteId = duplicate_obj_of_side_rel2move_in_transparent_mode(gBattleAnimArgs[0]);
if (spriteId < 0)
{
FreeOamMatrix(matrixNum);
DestroyAnimVisualTask(taskId);
return;
}
gSprites[spriteId].callback = SpriteCallbackDummy;
gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_DOUBLE;
gSprites[spriteId].oam.matrixNum = matrixNum2;
gSprites[spriteId].affineAnimPaused = 1;
gSprites[spriteId].subpriority++;
obj_id_set_rotscale(spriteId, 256, 256, 0);
CalcCenterToCornerVec(&gSprites[spriteId], gSprites[spriteId].oam.shape, gSprites[spriteId].oam.size, gSprites[spriteId].oam.affineMode);
task->data[13] = GetAnimBankSpriteId(gBattleAnimArgs[0]);
task->data[14] = matrixNum;
task->data[15] = spriteId;
task->func = sub_80DC5F4;
}
#else
__attribute__((naked))
void sub_80DC4F4(u8 taskId)
{
asm(".syntax unified\n\
push {r4-r7,lr}\n\
mov r7, r10\n\
mov r6, r9\n\
mov r5, r8\n\
push {r5-r7}\n\
lsls r0, 24\n\
lsrs r4, r0, 24\n\
mov r8, r4\n\
lsls r0, r4, 2\n\
adds r0, r4\n\
lsls r0, 3\n\
ldr r1, _080DC528 @ =gTasks\n\
adds r7, r0, r1\n\
bl AllocOamMatrix\n\
lsls r0, 24\n\
lsrs r5, r0, 24\n\
mov r10, r5\n\
adds r6, r5, 0\n\
cmp r6, 0xFF\n\
bne _080DC52C\n\
adds r0, r4, 0\n\
bl DestroyAnimVisualTask\n\
b _080DC5D6\n\
.align 2, 0\n\
_080DC528: .4byte gTasks\n\
_080DC52C:\n\
ldr r1, _080DC550 @ =gBattleAnimArgs\n\
ldrb r0, [r1]\n\
bl duplicate_obj_of_side_rel2move_in_transparent_mode\n\
lsls r0, 16\n\
lsrs r1, r0, 16\n\
mov r9, r1\n\
asrs r0, 16\n\
cmp r0, 0\n\
bge _080DC554\n\
adds r0, r5, 0\n\
bl FreeOamMatrix\n\
mov r0, r8\n\
bl DestroyAnimVisualTask\n\
b _080DC5D6\n\
.align 2, 0\n\
_080DC550: .4byte gBattleAnimArgs\n\
_080DC554:\n\
ldr r2, _080DC5E4 @ =gSprites\n\
lsls r4, r0, 4\n\
adds r4, r0\n\
lsls r4, 2\n\
adds r0, r2, 0\n\
adds r0, 0x1C\n\
adds r0, r4, r0\n\
ldr r1, _080DC5E8 @ =SpriteCallbackDummy\n\
str r1, [r0]\n\
adds r4, r2\n\
ldrb r0, [r4, 0x1]\n\
movs r1, 0x3\n\
orrs r0, r1\n\
strb r0, [r4, 0x1]\n\
movs r0, 0x1F\n\
ands r6, r0\n\
lsls r2, r6, 1\n\
ldrb r1, [r4, 0x3]\n\
movs r0, 0x3F\n\
negs r0, r0\n\
ands r0, r1\n\
orrs r0, r2\n\
strb r0, [r4, 0x3]\n\
adds r2, r4, 0\n\
adds r2, 0x2C\n\
ldrb r0, [r2]\n\
movs r1, 0x80\n\
orrs r0, r1\n\
strb r0, [r2]\n\
adds r1, r4, 0\n\
adds r1, 0x43\n\
ldrb r0, [r1]\n\
adds r0, 0x1\n\
strb r0, [r1]\n\
mov r1, r9\n\
lsls r0, r1, 24\n\
lsrs r0, 24\n\
movs r2, 0x80\n\
lsls r2, 1\n\
adds r1, r2, 0\n\
movs r3, 0\n\
bl obj_id_set_rotscale\n\
ldrb r3, [r4, 0x1]\n\
lsrs r1, r3, 6\n\
ldrb r2, [r4, 0x3]\n\
lsrs r2, 6\n\
lsls r3, 30\n\
lsrs r3, 30\n\
adds r0, r4, 0\n\
bl CalcCenterToCornerVec\n\
ldr r1, _080DC5EC @ =gBattleAnimArgs\n\
ldrb r0, [r1]\n\
bl GetAnimBankSpriteId\n\
lsls r0, 24\n\
lsrs r0, 24\n\
strh r0, [r7, 0x22]\n\
mov r0, r10\n\
strh r0, [r7, 0x24]\n\
mov r1, r9\n\
strh r1, [r7, 0x26]\n\
ldr r0, _080DC5F0 @ =sub_80DC5F4\n\
str r0, [r7]\n\
_080DC5D6:\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\
.align 2, 0\n\
_080DC5E4: .4byte gSprites\n\
_080DC5E8: .4byte SpriteCallbackDummy\n\
_080DC5EC: .4byte gBattleAnimArgs\n\
_080DC5F0: .4byte sub_80DC5F4\n\
.syntax divided\n");
}
#endif // NONMATCHING
void sub_80DC5F4(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
{
case 0:
task->data[1] += 4;
task->data[2] = 256 - (gSineTable[task->data[1]] >> 1);
obj_id_set_rotscale(task->data[15], task->data[2], task->data[2], 0);
sub_8079AB8(task->data[15], task->data[13]);
if (task->data[1] == 48)
task->data[0]++;
break;
case 1:
task->data[1] -= 4;
task->data[2] = 256 - (gSineTable[task->data[1]] >> 1);;
obj_id_set_rotscale(task->data[15], task->data[2], task->data[2], 0);
sub_8079AB8(task->data[15], task->data[13]);
if (task->data[1] == 0)
task->data[0]++;
break;
case 2:
obj_delete_but_dont_free_vram(&gSprites[task->data[15]]);
task->data[0]++;
break;
case 3:
FreeOamMatrix(task->data[14]);
DestroyAnimVisualTask(taskId);
break;
}
}
void sub_80DC700(struct Sprite *sprite)
{
switch (sprite->data[0])
{
case 0:
sprite->pos1.x = GetBankPosition(gAnimBankAttacker, 0);
sprite->pos1.y = GetBankPosition(gAnimBankAttacker, 1);
if (IsContest())
sprite->pos1.y += 12;
sprite->data[1] = 8;
REG_BLDCNT = 0x3F40;
REG_BLDALPHA = ((16 - sprite->data[1]) << 8) | sprite->data[1];
sprite->data[0]++;
break;
case 1:
if (sprite->affineAnimEnded)
{
PlaySE12WithPanning(SE_W100, BattleAnimAdjustPanning(-64));
ChangeSpriteAffineAnim(sprite, 1);
sprite->data[0]++;
}
break;
case 2:
if (sprite->data[2]++ > 1)
{
sprite->data[2] = 0;
sprite->data[1]--;
REG_BLDALPHA = ((16 - sprite->data[1]) << 8) | sprite->data[1];
if (sprite->data[1] == 0)
{
sprite->data[0]++;
sprite->invisible = 1;
}
}
sprite->data[3] += 896;
sprite->pos2.y -= sprite->data[3] >> 8;
sprite->data[3] &= 0xFF;
break;
case 3:
REG_BLDCNT = 0;
REG_BLDALPHA = 0;
DestroyAnimSprite(sprite);
break;
}
}

View File

@ -4,7 +4,11 @@
.syntax unified
.lcomm gUnknown_030007B8, 0x770
.bss
.global gUnknown_030007B8
gUnknown_030007B8:
.space 0x770
.text

View File

@ -1970,7 +1970,7 @@ void sub_807A0F4(struct Sprite *sprite)
DestroySpriteAndFreeResources(sprite);
}
int sub_807A100(u8 slot, u8 a2)
s16 sub_807A100(u8 slot, u8 a2)
{
u16 species;
u32 personality;
@ -2138,7 +2138,7 @@ void sub_807A3FC(u8 slot, bool8 a2, s16 *a3, s16 *a4)
*a4 = (v4 + v6) / 2;
}
u8 sub_807A4A0(int a1, u8 sprite, int a3)
u8 sub_807A4A0(int bank, u8 sprite, int species)
{
u8 new_sprite = CreateInvisibleSpriteWithCallback(SpriteCallbackDummy);
gSprites[new_sprite] = gSprites[sprite];