mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Decompile dark.c
This commit is contained in:
parent
980b055bf0
commit
f1213ebb4b
2199
asm/dark.s
2199
asm/dark.s
File diff suppressed because it is too large
Load Diff
@ -62,7 +62,7 @@ _0810F22E:
|
||||
adds r0, r4, 0
|
||||
adds r1, r6, 0
|
||||
movs r2, 0
|
||||
bl sub_80A438C
|
||||
bl MoveBattlerSpriteToBG
|
||||
_0810F264:
|
||||
movs r0, 0x2
|
||||
adds r4, r0, 0
|
||||
@ -77,7 +77,7 @@ _0810F264:
|
||||
adds r0, r4, 0
|
||||
adds r1, r6, 0
|
||||
movs r2, 0
|
||||
bl sub_80A438C
|
||||
bl MoveBattlerSpriteToBG
|
||||
_0810F284:
|
||||
mov r0, r8
|
||||
cmp r0, 0
|
||||
|
@ -58,7 +58,7 @@ void DestroyAnimSprite(struct Sprite *sprite);
|
||||
void DestroyAnimVisualTask(u8 taskId);
|
||||
void DestroyAnimSoundTask(u8 taskId);
|
||||
bool8 IsBattlerSpriteVisible(u8 battlerId);
|
||||
void sub_80A438C(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible);
|
||||
void MoveBattlerSpriteToBG(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible);
|
||||
bool8 IsContest(void);
|
||||
s8 BattleAnimAdjustPanning(s8 pan);
|
||||
s8 BattleAnimAdjustPanning2(s8 pan);
|
||||
|
@ -4720,6 +4720,10 @@ extern const u32 gBattleAnimBackgroundTilemap_17[];
|
||||
extern const u32 gBattleAnimBackgroundTilemap_20[];
|
||||
extern const u32 gBattleAnimBackgroundTilemap_21[];
|
||||
|
||||
extern const u32 gUnknown_08C1D0AC[];
|
||||
extern const u32 gUnknown_08C1D1E8[];
|
||||
extern const u32 gUnknown_08C1D210[];
|
||||
|
||||
extern const u32 gUnknown_08C20668[];
|
||||
extern const u32 gUnknown_08C20684[];
|
||||
extern const u32 gBattleStatMask_Gfx[];
|
||||
|
@ -170,7 +170,7 @@ SECTIONS {
|
||||
src/rock.o(.text);
|
||||
src/ghost.o(.text);
|
||||
src/dragon.o(.text);
|
||||
asm/dark.o(.text);
|
||||
src/dark.o(.text);
|
||||
src/ground.o(.text);
|
||||
src/normal.o(.text);
|
||||
src/battle_anim_utility_funcs.o(.text);
|
||||
|
@ -1870,7 +1870,7 @@ static void ScriptCmd_monbg(void)
|
||||
else
|
||||
toBG_2 = TRUE;
|
||||
|
||||
sub_80A438C(battlerId, toBG_2, FALSE);
|
||||
MoveBattlerSpriteToBG(battlerId, toBG_2, FALSE);
|
||||
taskId = CreateTask(sub_80A40F4, 10);
|
||||
gAnimVisualTaskCount++;
|
||||
gTasks[taskId].data[t1_MONBG_BATTLER] = battlerId;
|
||||
@ -1889,7 +1889,7 @@ static void ScriptCmd_monbg(void)
|
||||
else
|
||||
toBG_2 = TRUE;
|
||||
|
||||
sub_80A438C(battlerId, toBG_2, FALSE);
|
||||
MoveBattlerSpriteToBG(battlerId, toBG_2, FALSE);
|
||||
taskId = CreateTask(sub_80A40F4, 10);
|
||||
gAnimVisualTaskCount++;
|
||||
gTasks[taskId].data[0] = battlerId;
|
||||
@ -1922,7 +1922,7 @@ bool8 IsBattlerSpriteVisible(u8 battlerId)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_80A438C(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible)
|
||||
void MoveBattlerSpriteToBG(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible)
|
||||
{
|
||||
struct UnknownAnimStruct2 unknownStruct;
|
||||
u8 battlerSpriteId;
|
||||
@ -2194,7 +2194,7 @@ static void ScriptCmd_monbg_22(void)
|
||||
else
|
||||
toBG_2 = TRUE;
|
||||
|
||||
sub_80A438C(battlerId, toBG_2, FALSE);
|
||||
MoveBattlerSpriteToBG(battlerId, toBG_2, FALSE);
|
||||
}
|
||||
|
||||
battlerId ^= BIT_FLANK;
|
||||
@ -2206,7 +2206,7 @@ static void ScriptCmd_monbg_22(void)
|
||||
else
|
||||
toBG_2 = TRUE;
|
||||
|
||||
sub_80A438C(battlerId, toBG_2, FALSE);
|
||||
MoveBattlerSpriteToBG(battlerId, toBG_2, FALSE);
|
||||
}
|
||||
|
||||
sBattleAnimScriptPtr++;
|
||||
|
820
src/dark.c
820
src/dark.c
@ -1,11 +1,29 @@
|
||||
#include "global.h"
|
||||
#include "battle_anim.h"
|
||||
#include "contest.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "graphics.h"
|
||||
#include "palette.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "trig.h"
|
||||
#include "util.h"
|
||||
#include "constants/rgb.h"
|
||||
|
||||
extern void sub_81138D4(struct Sprite *);
|
||||
extern void sub_81139DC(struct Sprite *);
|
||||
extern void sub_8113A90(struct Sprite *);
|
||||
extern void sub_81144BC(struct Sprite *);
|
||||
void sub_81138D4(struct Sprite *);
|
||||
void sub_81139DC(struct Sprite *);
|
||||
void sub_8113A90(struct Sprite *);
|
||||
void sub_81144BC(struct Sprite *);
|
||||
static void sub_811375C(u8);
|
||||
static void sub_811381C(u8);
|
||||
static void sub_8113950(struct Sprite *);
|
||||
static void sub_8113A18(struct Sprite *);
|
||||
static void sub_8113A58(struct Sprite *);
|
||||
static void sub_8113B90(struct Sprite *);
|
||||
static void sub_8113D60(u8);
|
||||
static void sub_81140C8(u8);
|
||||
static void sub_8114244(struct Task *);
|
||||
static void sub_8114374(u8);
|
||||
static void sub_8114748(u8);
|
||||
|
||||
const struct SpriteTemplate gUnknown_08596FC8 =
|
||||
{
|
||||
@ -167,3 +185,797 @@ const struct SpriteTemplate gBattleAnimSpriteTemplate_8597138 =
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = sub_81144BC,
|
||||
};
|
||||
|
||||
void sub_81136E8(u8 taskId)
|
||||
{
|
||||
int battler;
|
||||
gTasks[taskId].data[0] = gBattleAnimArgs[0];
|
||||
battler = gBattleAnimAttacker;
|
||||
gTasks[taskId].data[1] = 16;
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0));
|
||||
if (GetBattlerSpriteBGPriorityRank(battler) == 1)
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG1);
|
||||
else
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG2);
|
||||
|
||||
gTasks[taskId].func = sub_811375C;
|
||||
}
|
||||
|
||||
static void sub_811375C(u8 taskId)
|
||||
{
|
||||
u8 blendA = gTasks[taskId].data[1] >> 8;
|
||||
u8 blendB = gTasks[taskId].data[1];
|
||||
if (gTasks[taskId].data[2] == (u8)gTasks[taskId].data[0])
|
||||
{
|
||||
blendA++;
|
||||
blendB--;
|
||||
gTasks[taskId].data[1] = BLDALPHA_BLEND(blendB, blendA);
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, gTasks[taskId].data[1]);
|
||||
gTasks[taskId].data[2] = 0;
|
||||
if (blendA == 16)
|
||||
{
|
||||
gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].invisible = 1;
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gTasks[taskId].data[2]++;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_81137E4(u8 taskId)
|
||||
{
|
||||
gTasks[taskId].data[0] = gBattleAnimArgs[0];
|
||||
gTasks[taskId].data[1] = BLDALPHA_BLEND(0, 16);
|
||||
gTasks[taskId].func = sub_811381C;
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, gTasks[taskId].data[1]);
|
||||
}
|
||||
|
||||
static void sub_811381C(u8 taskId)
|
||||
{
|
||||
u8 blendA = gTasks[taskId].data[1] >> 8;
|
||||
u8 blendB = gTasks[taskId].data[1];
|
||||
if (gTasks[taskId].data[2] == (u8)gTasks[taskId].data[0])
|
||||
{
|
||||
blendA--;
|
||||
blendB++;
|
||||
gTasks[taskId].data[1] = (blendA << 8) | blendB;
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, gTasks[taskId].data[1]);
|
||||
gTasks[taskId].data[2] = 0;
|
||||
if (blendA == 0)
|
||||
{
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gTasks[taskId].data[2]++;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8113888(u8 taskId)
|
||||
{
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16));
|
||||
if (GetBattlerSpriteBGPriorityRank(gBattleAnimAttacker) == 1)
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG1);
|
||||
else
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG2);
|
||||
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
|
||||
void sub_81138D4(struct Sprite *sprite)
|
||||
{
|
||||
sprite->data[1] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2);
|
||||
sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2);
|
||||
sprite->data[3] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET);
|
||||
sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET);
|
||||
sprite->data[0] = 0x7E;
|
||||
InitSpriteDataForLinearTranslation(sprite);
|
||||
sprite->data[3] = -sprite->data[1];
|
||||
sprite->data[4] = -sprite->data[2];
|
||||
sprite->data[6] = 0xFFD8;
|
||||
sprite->callback = sub_8113950;
|
||||
sprite->callback(sprite);
|
||||
}
|
||||
|
||||
static void sub_8113950(struct Sprite *sprite)
|
||||
{
|
||||
sprite->data[3] += sprite->data[1];
|
||||
sprite->data[4] += sprite->data[2];
|
||||
sprite->pos2.x = sprite->data[3] >> 8;
|
||||
sprite->pos2.y = sprite->data[4] >> 8;
|
||||
if (sprite->data[7] == 0)
|
||||
{
|
||||
sprite->data[3] += sprite->data[1];
|
||||
sprite->data[4] += sprite->data[2];
|
||||
sprite->pos2.x = sprite->data[3] >> 8;
|
||||
sprite->pos2.y = sprite->data[4] >> 8;
|
||||
sprite->data[0]--;
|
||||
}
|
||||
|
||||
sprite->pos2.y += Sin(sprite->data[5], sprite->data[6]);
|
||||
sprite->data[5] = (sprite->data[5] + 3) & 0xFF;
|
||||
if (sprite->data[5] > 0x7F)
|
||||
{
|
||||
sprite->data[5] = 0;
|
||||
sprite->data[6] += 20;
|
||||
sprite->data[7]++;
|
||||
}
|
||||
|
||||
if (--sprite->data[0] == 0)
|
||||
DestroyAnimSprite(sprite);
|
||||
}
|
||||
|
||||
void sub_81139DC(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_8113A18;
|
||||
}
|
||||
|
||||
static void sub_8113A18(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_8113A58;
|
||||
}
|
||||
|
||||
static void sub_8113A58(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)
|
||||
DestroySpriteAndMatrix(sprite);
|
||||
}
|
||||
|
||||
void sub_8113A90(struct Sprite *sprite)
|
||||
{
|
||||
u8 battler;
|
||||
s8 xOffset;
|
||||
|
||||
if (gBattleAnimArgs[0] == 0)
|
||||
battler = gBattleAnimAttacker;
|
||||
else
|
||||
battler = gBattleAnimTarget;
|
||||
|
||||
xOffset = 20;
|
||||
sprite->oam.tileNum += 4;
|
||||
|
||||
switch (gBattleAnimArgs[1])
|
||||
{
|
||||
case 0:
|
||||
sprite->pos1.x = sub_80A861C(battler, 5) - 8;
|
||||
sprite->pos1.y = sub_80A861C(battler, 2) + 8;
|
||||
break;
|
||||
case 1:
|
||||
sprite->pos1.x = sub_80A861C(battler, 5) - 14;
|
||||
sprite->pos1.y = sub_80A861C(battler, 2) + 16;
|
||||
break;
|
||||
case 2:
|
||||
sprite->pos1.x = sub_80A861C(battler, 4) + 8;
|
||||
sprite->pos1.y = sub_80A861C(battler, 2) + 8;
|
||||
StartSpriteAffineAnim(sprite, 1);
|
||||
xOffset = -20;
|
||||
break;
|
||||
case 3:
|
||||
sprite->pos1.x = sub_80A861C(battler, 4) + 14;
|
||||
sprite->pos1.y = sub_80A861C(battler, 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;
|
||||
|
||||
InitAnimArcTranslation(sprite);
|
||||
sprite->callback = sub_8113B90;
|
||||
}
|
||||
|
||||
static void sub_8113B90(struct Sprite *sprite)
|
||||
{
|
||||
if (TranslateAnimArc(sprite))
|
||||
DestroySpriteAndMatrix(sprite);
|
||||
}
|
||||
|
||||
void sub_8113BAC(u8 taskId)
|
||||
{
|
||||
struct ScanlineEffectParams scanlineParams;
|
||||
struct UnknownAnimStruct2 unknownStruct;
|
||||
u16 i;
|
||||
u8 pos;
|
||||
int var0;
|
||||
struct Task *task = &gTasks[taskId];
|
||||
|
||||
task->data[7] = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y) + 31;
|
||||
task->data[6] = sub_80A861C(gBattleAnimAttacker, 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 = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X);
|
||||
task->data[14] = pos - 32;
|
||||
task->data[15] = pos + 32;
|
||||
|
||||
if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER)
|
||||
task->data[8] = -12;
|
||||
else
|
||||
task->data[8] = -64;
|
||||
|
||||
task->data[3] = GetBattlerSpriteBGPriorityRank(gBattleAnimAttacker);
|
||||
if (task->data[3] == 1)
|
||||
{
|
||||
sub_80A6B30(&unknownStruct);
|
||||
task->data[10] = gBattle_BG1_Y;
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG1);
|
||||
FillPalette(0, unknownStruct.unk8 << 4, 32);
|
||||
scanlineParams.dmaDest = ®_BG1VOFS;
|
||||
var0 = WINOUT_WIN01_BG1;
|
||||
if (!IsContest())
|
||||
gBattle_BG2_X += 240;
|
||||
}
|
||||
else
|
||||
{
|
||||
task->data[10] = gBattle_BG2_Y;
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG2);
|
||||
FillPalette(0, 144, 32);
|
||||
scanlineParams.dmaDest = ®_BG2VOFS;
|
||||
var0 = WINOUT_WIN01_BG2;
|
||||
if (!IsContest())
|
||||
gBattle_BG1_X += 240;
|
||||
}
|
||||
|
||||
scanlineParams.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT;
|
||||
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_8114374(3);
|
||||
for (i = 0; i < 112; i++)
|
||||
{
|
||||
gScanlineEffectRegBuffers[0][i] = task->data[10];
|
||||
gScanlineEffectRegBuffers[1][i] = task->data[10];
|
||||
}
|
||||
|
||||
ScanlineEffect_SetParams(scanlineParams);
|
||||
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | (var0 ^ (WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR)));
|
||||
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR);
|
||||
gBattle_WIN0H = (task->data[14] << 8) | task->data[15];
|
||||
gBattle_WIN0V = 160;
|
||||
|
||||
task->func = sub_8113D60;
|
||||
}
|
||||
|
||||
static void sub_8113D60(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]--;
|
||||
}
|
||||
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(task->data[11], task->data[12]));
|
||||
|
||||
if (task->data[11] == 12 && task->data[12] == 8)
|
||||
task->data[0]++;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
task->data[4] -= 8;
|
||||
sub_8114244(task);
|
||||
|
||||
if (task->data[4] < task->data[8])
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 2:
|
||||
task->data[4] -= 8;
|
||||
sub_8114244(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_8113E78(u8 taskId)
|
||||
{
|
||||
struct UnknownAnimStruct2 unknownStruct;
|
||||
struct ScanlineEffectParams scanlineParams;
|
||||
u8 x;
|
||||
u16 i;
|
||||
struct Task *task = &gTasks[taskId];
|
||||
|
||||
switch (task->data[0])
|
||||
{
|
||||
case 0:
|
||||
if (IsContest() == TRUE)
|
||||
{
|
||||
gBattle_WIN0H = 0;
|
||||
gBattle_WIN0V = 0;
|
||||
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR);
|
||||
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
else
|
||||
{
|
||||
task->data[3] = GetBattlerSpriteBGPriorityRank(gBattleAnimTarget);
|
||||
if (task->data[3] == 1)
|
||||
{
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG1);
|
||||
gBattle_BG2_X += 240;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG2);
|
||||
gBattle_BG1_X += 240;
|
||||
}
|
||||
|
||||
task->data[0]++;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (task->data[3] == 1)
|
||||
{
|
||||
sub_80A6B30(&unknownStruct);
|
||||
task->data[10] = gBattle_BG1_Y;
|
||||
FillPalette(0, unknownStruct.unk8 << 4, 32);
|
||||
}
|
||||
else
|
||||
{
|
||||
task->data[10] = gBattle_BG2_Y;
|
||||
FillPalette(0, 144, 32);
|
||||
}
|
||||
|
||||
sub_8114374(3);
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 2:
|
||||
task->data[7] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y) + 31;
|
||||
task->data[6] = sub_80A861C(gBattleAnimTarget, 2) - 7;
|
||||
task->data[13] = (task->data[7] - task->data[6]) << 8;
|
||||
x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X);
|
||||
task->data[14] = x - 4;
|
||||
task->data[15] = x + 4;
|
||||
|
||||
if (GetBattlerSide(gBattleAnimTarget) == B_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 = ®_BG1VOFS;
|
||||
else
|
||||
scanlineParams.dmaDest = ®_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 = SCANLINE_EFFECT_DMACNT_16BIT;
|
||||
scanlineParams.initState = 1;
|
||||
scanlineParams.unused9 = 0;
|
||||
ScanlineEffect_SetParams(scanlineParams);
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 4:
|
||||
if (task->data[3] == 1)
|
||||
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | WINOUT_WIN01_BG0 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
|
||||
else
|
||||
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
|
||||
|
||||
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR);
|
||||
gBattle_WIN0H = (task->data[14] << 8) | task->data[15];
|
||||
gBattle_WIN0V = 160;
|
||||
|
||||
task->data[0] = 0;
|
||||
task->data[1] = 0;
|
||||
task->data[2] = 0;
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(12, 8));
|
||||
task->func = sub_81140C8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_81140C8(u8 taskId)
|
||||
{
|
||||
u8 pos;
|
||||
u16 i;
|
||||
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_8114244(task);
|
||||
if (task->data[5] == task->data[7])
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
if (task->data[15] - task->data[14] < 0x40)
|
||||
{
|
||||
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_8114244(task);
|
||||
if (task->data[4] == task->data[6] && task->data[1])
|
||||
{
|
||||
task->data[1] = 0;
|
||||
task->data[0]++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (++task->data[1] > 1)
|
||||
{
|
||||
task->data[1] = 0;
|
||||
task->data[2]++;
|
||||
if (task->data[2] & 1)
|
||||
{
|
||||
if (task->data[11])
|
||||
task->data[11]--;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (task->data[12] < 16)
|
||||
task->data[12]++;
|
||||
}
|
||||
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(task->data[11], task->data[12]));
|
||||
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;
|
||||
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR);
|
||||
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
|
||||
DestroyAnimVisualTask(taskId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_8114244(struct Task *task)
|
||||
{
|
||||
int var0, var1;
|
||||
s16 var2;
|
||||
s16 i;
|
||||
int var4;
|
||||
|
||||
var2 = task->data[5] - task->data[4];
|
||||
if (var2 != 0)
|
||||
{
|
||||
var0 = task->data[13] / var2;
|
||||
var1 = task->data[6] << 8;
|
||||
|
||||
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)
|
||||
{
|
||||
s16 var3 = (var1 >> 8) - i;
|
||||
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = var3 + task->data[10];
|
||||
}
|
||||
|
||||
var1 += var0;
|
||||
}
|
||||
|
||||
var4 = task->data[10] - (i - 159);
|
||||
for (i = i; i < task->data[7]; i++)
|
||||
{
|
||||
if (i >= 0)
|
||||
{
|
||||
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = var4;
|
||||
var4--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var4 = task->data[10] + 159;
|
||||
for (i = 0; i < 112; i++)
|
||||
{
|
||||
gScanlineEffectRegBuffers[0][i] = var4;
|
||||
gScanlineEffectRegBuffers[1][i] = var4;
|
||||
var4--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_8114374(u8 priority)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
|
||||
{
|
||||
u8 spriteId = GetAnimBattlerSpriteId(i);
|
||||
if (spriteId != 0xFF)
|
||||
gSprites[spriteId].oam.priority = priority;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_81143C0(u8 taskId)
|
||||
{
|
||||
u8 toBG2 = GetBattlerSpriteBGPriorityRank(gBattleAnimAttacker) ^ 1 ? 1 : 0;
|
||||
MoveBattlerSpriteToBG(gBattleAnimAttacker, toBG2, TRUE);
|
||||
gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].invisible = 0;
|
||||
|
||||
if (IsBattlerSpriteVisible(BATTLE_PARTNER(gBattleAnimAttacker)))
|
||||
{
|
||||
MoveBattlerSpriteToBG(gBattleAnimAttacker ^ 2, toBG2 ^ 1, TRUE);
|
||||
gSprites[gBattlerSpriteIds[gBattleAnimAttacker ^ 2]].invisible = 0;
|
||||
}
|
||||
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
|
||||
void sub_8114470(u8 taskId)
|
||||
{
|
||||
u8 toBG2 = GetBattlerSpriteBGPriorityRank(gBattleAnimAttacker) ^ 1 ? 1 : 0;
|
||||
sub_80A477C(toBG2);
|
||||
|
||||
if (IsBattlerSpriteVisible(BATTLE_PARTNER(gBattleAnimAttacker)))
|
||||
sub_80A477C(toBG2 ^ 1);
|
||||
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
|
||||
void sub_81144BC(struct Sprite *sprite)
|
||||
{
|
||||
sprite->pos1.x += gBattleAnimArgs[0];
|
||||
sprite->pos1.y += gBattleAnimArgs[1];
|
||||
StartSpriteAnim(sprite, gBattleAnimArgs[2]);
|
||||
sprite->callback = RunStoredCallbackWhenAnimEnds;
|
||||
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
|
||||
}
|
||||
|
||||
void sub_81144F8(u8 taskId)
|
||||
{
|
||||
u16 species;
|
||||
u8 spriteId;
|
||||
u8 newSpriteId;
|
||||
u16 paletteNum;
|
||||
struct UnknownAnimStruct2 unknownStruct;
|
||||
int var0 = 0;
|
||||
|
||||
gBattle_WIN0H = var0;
|
||||
gBattle_WIN0V = var0;
|
||||
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR);
|
||||
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | WINOUT_WIN01_BG0 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
|
||||
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJWIN_ON);
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG1);
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(8, 12));
|
||||
SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 0);
|
||||
SetAnimBgAttribute(1, BG_ANIM_SCREEN_SIZE, 0);
|
||||
if (!IsContest())
|
||||
SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 1);
|
||||
|
||||
if (IsDoubleBattle() && !IsContest())
|
||||
{
|
||||
if (GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_PLAYER_LEFT)
|
||||
{
|
||||
if (IsBattlerSpriteVisible(BATTLE_PARTNER(gBattleAnimAttacker)) == TRUE)
|
||||
{
|
||||
gSprites[gBattlerSpriteIds[BATTLE_PARTNER(gBattleAnimAttacker)]].oam.priority--;
|
||||
SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1);
|
||||
var0 = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IsContest())
|
||||
{
|
||||
species = gContestResources->field_18->species;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
|
||||
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES);
|
||||
else
|
||||
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES);
|
||||
}
|
||||
|
||||
spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER);
|
||||
newSpriteId = sub_80A89C8(gBattleAnimAttacker, spriteId, species);
|
||||
|
||||
sub_80A6B30(&unknownStruct);
|
||||
sub_80A6D48(unknownStruct.bgId, gUnknown_08C1D210);
|
||||
sub_80A6CC0(unknownStruct.bgId, gUnknown_08C1D0AC, unknownStruct.tilesOffset);
|
||||
LoadCompressedPalette(gUnknown_08C1D1E8, unknownStruct.unk8 << 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)
|
||||
SetGreyscaleOrOriginalPalette(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_8114748;
|
||||
}
|
||||
|
||||
static void sub_8114748(u8 taskId)
|
||||
{
|
||||
struct UnknownAnimStruct2 unknownStruct;
|
||||
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;
|
||||
gTasks[taskIdCopy].data[11]++;
|
||||
if (gTasks[taskIdCopy].data[11] == 2)
|
||||
{
|
||||
spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER);
|
||||
paletteNum = 16 + gSprites[spriteId].oam.paletteNum;
|
||||
if (gTasks[taskIdCopy].data[1] == 0)
|
||||
SetGreyscaleOrOriginalPalette(paletteNum, 1);
|
||||
|
||||
DestroySprite(&gSprites[gTasks[taskIdCopy].data[0]]);
|
||||
sub_80A6B30(&unknownStruct);
|
||||
sub_80A6C68(unknownStruct.bgId);
|
||||
if (gTasks[taskIdCopy].data[6] == 1)
|
||||
gSprites[gBattlerSpriteIds[BATTLE_PARTNER(gBattleAnimAttacker)]].oam.priority++;
|
||||
}
|
||||
else if (gTasks[taskIdCopy].data[11] == 3)
|
||||
{
|
||||
gBattle_WIN0H = 0;
|
||||
gBattle_WIN0V = 0;
|
||||
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR);
|
||||
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
|
||||
if (!IsContest())
|
||||
SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 0);
|
||||
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) ^ DISPCNT_OBJWIN_ON);
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_811489C(u8 taskId)
|
||||
{
|
||||
u8 spriteId;
|
||||
u8 battler;
|
||||
bool8 calcSpriteId = FALSE;
|
||||
u8 position = B_POSITION_PLAYER_LEFT;
|
||||
|
||||
switch (gBattleAnimArgs[0])
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
spriteId = GetAnimBattlerSpriteId(gBattleAnimArgs[0]);
|
||||
break;
|
||||
case 4:
|
||||
position = B_POSITION_PLAYER_LEFT;
|
||||
calcSpriteId = TRUE;
|
||||
break;
|
||||
case 5:
|
||||
position = B_POSITION_PLAYER_RIGHT;
|
||||
calcSpriteId = TRUE;
|
||||
break;
|
||||
case 6:
|
||||
position = B_POSITION_OPPONENT_LEFT;
|
||||
calcSpriteId = TRUE;
|
||||
break;
|
||||
case 7:
|
||||
position = B_POSITION_OPPONENT_RIGHT;
|
||||
calcSpriteId = TRUE;
|
||||
break;
|
||||
default:
|
||||
spriteId = 0xFF;
|
||||
break;
|
||||
}
|
||||
|
||||
if (calcSpriteId)
|
||||
{
|
||||
battler = GetBattlerAtPosition(position);
|
||||
if (IsBattlerSpriteVisible(battler))
|
||||
spriteId = gBattlerSpriteIds[battler];
|
||||
else
|
||||
spriteId = 0xFF;
|
||||
}
|
||||
|
||||
if (spriteId != 0xFF)
|
||||
SetGreyscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, gBattleAnimArgs[1]);
|
||||
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
|
||||
void sub_8114960(u8 taskId)
|
||||
{
|
||||
if (gAnimMoveTurn < 2)
|
||||
gBattleAnimArgs[7] = 0;
|
||||
|
||||
if (gAnimMoveTurn == 2)
|
||||
gBattleAnimArgs[7] = 1;
|
||||
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user