a really hard math function

This commit is contained in:
DizzyEggg 2017-08-22 17:10:50 +02:00
parent fc9f7853a0
commit be47f6b54b
3 changed files with 280 additions and 588 deletions

View File

@ -8,487 +8,6 @@
thumb_func_start sub_811D584
sub_811D584: @ 811D584
push {r4,lr}
adds r4, r0, 0
ldrh r1, [r4, 0x14]
movs r2, 0x14
ldrsh r0, [r4, r2]
cmp r0, 0
beq _0811D59C
subs r0, r1, 0x1
strh r0, [r4, 0x14]
lsls r0, 16
cmp r0, 0
bne _0811D5C0
_0811D59C:
ldrh r0, [r4, 0xA]
strh r0, [r4, 0x14]
ldrh r0, [r4, 0x10]
ldrh r1, [r4, 0x16]
adds r0, r1
strh r0, [r4, 0x16]
lsls r0, 16
asrs r0, 16
cmp r0, 0x10
ble _0811D5B4
movs r0, 0x10
strh r0, [r4, 0x16]
_0811D5B4:
movs r0, 0x1
negs r0, r0
ldrb r1, [r4, 0x16]
ldr r2, _0811D5DC @ =0x00002d6b
bl BlendPalettes
_0811D5C0:
movs r2, 0x16
ldrsh r0, [r4, r2]
cmp r0, 0xF
ble _0811D5D2
ldrh r0, [r4, 0x8]
adds r0, 0x1
strh r0, [r4, 0x8]
ldrh r0, [r4, 0xC]
strh r0, [r4, 0x14]
_0811D5D2:
movs r0, 0
pop {r4}
pop {r1}
bx r1
.align 2, 0
_0811D5DC: .4byte 0x00002d6b
thumb_func_end sub_811D584
thumb_func_start sub_811D5E0
sub_811D5E0: @ 811D5E0
push {r4,lr}
adds r4, r0, 0
ldrh r1, [r4, 0x14]
movs r2, 0x14
ldrsh r0, [r4, r2]
cmp r0, 0
beq _0811D5F8
subs r0, r1, 0x1
strh r0, [r4, 0x14]
lsls r0, 16
cmp r0, 0
bne _0811D61A
_0811D5F8:
ldrh r0, [r4, 0xC]
strh r0, [r4, 0x14]
ldrh r0, [r4, 0x16]
ldrh r1, [r4, 0x12]
subs r0, r1
strh r0, [r4, 0x16]
lsls r0, 16
cmp r0, 0
bge _0811D60E
movs r0, 0
strh r0, [r4, 0x16]
_0811D60E:
movs r0, 0x1
negs r0, r0
ldrb r1, [r4, 0x16]
ldr r2, _0811D640 @ =0x00002d6b
bl BlendPalettes
_0811D61A:
movs r0, 0x16
ldrsh r1, [r4, r0]
cmp r1, 0
bne _0811D64E
ldrh r0, [r4, 0xE]
subs r0, 0x1
strh r0, [r4, 0xE]
lsls r0, 16
cmp r0, 0
bne _0811D648
ldr r0, _0811D644 @ =sub_811D54C
bl FindTaskIdByFunc
lsls r0, 24
lsrs r0, 24
bl DestroyTask
b _0811D64E
.align 2, 0
_0811D640: .4byte 0x00002d6b
_0811D644: .4byte sub_811D54C
_0811D648:
ldrh r0, [r4, 0xA]
strh r0, [r4, 0x14]
strh r1, [r4, 0x8]
_0811D64E:
movs r0, 0
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_811D5E0
thumb_func_start sub_811D658
sub_811D658: @ 811D658
push {lr}
ldr r0, _0811D674 @ =sTransitionStructPtr
ldr r0, [r0]
movs r1, 0
movs r2, 0x3C
bl memset
ldr r0, _0811D678 @ =0x0200c014
adds r1, r0, 0x2
bl sub_8057B14
pop {r0}
bx r0
.align 2, 0
_0811D674: .4byte sTransitionStructPtr
_0811D678: .4byte 0x0200c014
thumb_func_end sub_811D658
thumb_func_start VBlankCB_BattleTransition
VBlankCB_BattleTransition: @ 811D67C
push {lr}
bl LoadOam
bl ProcessSpriteCopyRequests
bl TransferPlttBuffer
pop {r0}
bx r0
thumb_func_end VBlankCB_BattleTransition
thumb_func_start sub_811D690
sub_811D690: @ 811D690
ldr r1, _0811D6A4 @ =REG_BG0CNT
ldrh r1, [r1]
lsrs r1, 2
lsls r1, 30
lsrs r1, 16
movs r2, 0xC0
lsls r2, 19
adds r1, r2
str r1, [r0]
bx lr
.align 2, 0
_0811D6A4: .4byte REG_BG0CNT
thumb_func_end sub_811D690
thumb_func_start sub_811D6A8
sub_811D6A8: @ 811D6A8
push {r4,lr}
ldr r3, _0811D6D0 @ =REG_BG0CNT
ldrh r2, [r3]
lsrs r2, 8
ldrh r3, [r3]
lsrs r3, 2
lsls r2, 27
lsrs r2, 16
lsls r3, 30
lsrs r3, 16
movs r4, 0xC0
lsls r4, 19
adds r2, r4
str r2, [r0]
adds r3, r4
str r3, [r1]
pop {r4}
pop {r0}
bx r0
.align 2, 0
_0811D6D0: .4byte REG_BG0CNT
thumb_func_end sub_811D6A8
thumb_func_start sub_811D6D4
sub_811D6D4: @ 811D6D4
push {lr}
movs r0, 0x1
negs r0, r0
movs r1, 0x10
movs r2, 0
bl BlendPalettes
pop {r0}
bx r0
thumb_func_end sub_811D6D4
thumb_func_start sub_811D6E8
sub_811D6E8: @ 811D6E8
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
mov r10, r0
ldr r0, [sp, 0x20]
ldr r4, [sp, 0x24]
lsls r1, 16
lsrs r7, r1, 16
lsls r2, 16
lsrs r2, 16
lsls r3, 16
lsrs r3, 16
lsls r0, 16
lsrs r1, r0, 16
lsls r4, 16
movs r6, 0
lsrs r5, r4, 16
cmp r4, 0
ble _0811D750
lsls r0, r7, 16
asrs r0, 16
mov r9, r0
lsls r1, 16
mov r8, r1
lsls r0, r3, 16
asrs r7, r0, 16
_0811D720:
lsls r4, r2, 16
asrs r4, 16
movs r0, 0xFF
ands r0, r4
mov r2, r8
asrs r1, r2, 16
bl Sin
lsls r1, r6, 1
add r1, r10
add r0, r9
strh r0, [r1]
lsls r1, r5, 16
ldr r0, _0811D760 @ =0xffff0000
adds r1, r0
adds r0, r6, 0x1
lsls r0, 24
lsrs r6, r0, 24
adds r4, r7
lsls r4, 16
lsrs r2, r4, 16
lsrs r5, r1, 16
cmp r1, 0
bgt _0811D720
_0811D750:
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_0811D760: .4byte 0xffff0000
thumb_func_end sub_811D6E8
thumb_func_start sub_811D764
sub_811D764: @ 811D764
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x14
mov r9, r0
adds r5, r2, 0
adds r4, r3, 0
lsls r1, 16
lsrs r1, 16
str r1, [sp]
lsls r5, 16
lsrs r5, 16
lsls r4, 16
lsrs r4, 16
movs r2, 0xA0
lsls r2, 1
movs r1, 0xA
bl memset
movs r1, 0
lsls r4, 16
asrs r4, 16
str r4, [sp, 0x4]
lsls r5, 16
asrs r5, 16
str r5, [sp, 0x8]
_0811D79C:
lsls r5, r1, 16
asrs r0, r5, 16
mov r10, r0
ldr r1, [sp, 0x4]
bl Sin
adds r4, r0, 0
lsls r4, 16
lsrs r4, 16
mov r0, r10
ldr r1, [sp, 0x4]
bl Cos
ldr r2, [sp]
lsls r1, r2, 16
asrs r1, 16
lsls r4, 16
asrs r4, 16
subs r2, r1, r4
lsls r2, 16
adds r1, r4
lsls r1, 16
lsrs r6, r1, 16
lsls r0, 16
asrs r0, 16
ldr r3, [sp, 0x8]
subs r1, r3, r0
lsls r1, 16
lsrs r7, r1, 16
adds r0, r3, r0
lsls r0, 16
lsrs r0, 16
mov r8, r0
lsrs r1, r2, 16
str r5, [sp, 0x10]
cmp r2, 0
bge _0811D7E8
movs r1, 0
_0811D7E8:
lsls r0, r6, 16
asrs r0, 16
cmp r0, 0xF0
ble _0811D7F2
movs r6, 0xF0
_0811D7F2:
lsls r0, r7, 16
cmp r0, 0
bge _0811D7FA
movs r7, 0
_0811D7FA:
mov r2, r8
lsls r0, r2, 16
asrs r0, 16
cmp r0, 0x9F
ble _0811D808
movs r3, 0x9F
mov r8, r3
_0811D808:
lsls r0, r1, 24
lsrs r0, 16
orrs r6, r0
lsls r0, r7, 16
asrs r0, 16
str r0, [sp, 0xC]
lsls r0, 1
add r0, r9
strh r6, [r0]
mov r0, r8
lsls r4, r0, 16
asrs r0, r4, 15
add r0, r9
strh r6, [r0]
mov r0, r10
adds r0, 0x1
lsls r0, 16
asrs r0, 16
ldr r1, [sp, 0x4]
bl Cos
lsls r0, 16
asrs r0, 16
ldr r2, [sp, 0x8]
subs r1, r2, r0
lsls r1, 16
adds r0, r2, r0
lsls r0, 16
lsrs r2, r0, 16
lsrs r3, r1, 16
cmp r1, 0
bge _0811D84A
movs r3, 0
_0811D84A:
lsls r0, r2, 16
asrs r0, 16
cmp r0, 0x9F
ble _0811D854
movs r2, 0x9F
_0811D854:
lsls r0, r3, 16
asrs r1, r0, 16
adds r3, r0, 0
lsls r5, r2, 16
ldr r0, [sp, 0xC]
cmp r0, r1
ble _0811D878
adds r2, r1, 0
_0811D864:
lsls r1, r7, 16
ldr r0, _0811D8F8 @ =0xffff0000
adds r1, r0
asrs r0, r1, 15
add r0, r9
strh r6, [r0]
lsrs r7, r1, 16
asrs r1, 16
cmp r1, r2
bgt _0811D864
_0811D878:
lsls r1, r7, 16
asrs r0, r3, 16
cmp r1, r3
bge _0811D896
adds r2, r0, 0
_0811D882:
movs r3, 0x80
lsls r3, 9
adds r0, r1, r3
asrs r1, r0, 15
add r1, r9
strh r6, [r1]
adds r1, r0, 0
asrs r0, r1, 16
cmp r0, r2
blt _0811D882
_0811D896:
asrs r0, r5, 16
cmp r4, r5
ble _0811D8B4
adds r1, r0, 0
_0811D89E:
ldr r2, _0811D8F8 @ =0xffff0000
adds r0, r4, r2
lsrs r3, r0, 16
mov r8, r3
asrs r0, 15
add r0, r9
strh r6, [r0]
lsls r4, r3, 16
asrs r0, r4, 16
cmp r0, r1
bgt _0811D89E
_0811D8B4:
mov r0, r8
lsls r4, r0, 16
asrs r0, r5, 16
cmp r4, r5
bge _0811D8D4
adds r2, r0, 0
_0811D8C0:
movs r1, 0x80
lsls r1, 9
adds r0, r4, r1
asrs r1, r0, 15
add r1, r9
strh r6, [r1]
adds r4, r0, 0
asrs r0, r4, 16
cmp r0, r2
blt _0811D8C0
_0811D8D4:
ldr r2, [sp, 0x10]
movs r3, 0x80
lsls r3, 9
adds r0, r2, r3
lsrs r1, r0, 16
asrs r0, 16
cmp r0, 0x3F
bgt _0811D8E6
b _0811D79C
_0811D8E6:
add sp, 0x14
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_0811D8F8: .4byte 0xffff0000
thumb_func_end sub_811D764
thumb_func_start sub_811D8FC
sub_811D8FC: @ 811D8FC
push {r4-r7,lr}

View File

@ -18,21 +18,25 @@ enum // TRANSITION_MUGSHOT
#define MUGSHOTS_NO 5
// credits for the names go to Dyskinesia
// credits for the names go to Dyskinesia, Tetrable and Dizzy Egg
// names are naturally subject to change
#define B_TRANSITION_BLUR 0
#define B_TRANSITION_SMEAR 1
#define B_TRANSITION_SHUFFLE 2
#define B_TRANSITION_BIG_POKEBALL 3
#define B_TRANSITION_POKEBALLS_WIPEOUT 4
#define B_TRANSITION_RIPPLE 6
#define B_TRANSITION_WAVE 7
#define B_TRANSITION_SLICE 8
#define B_TRANSITION_SHARDS 11
#define B_TRANSITION_SYDNEY 12
#define B_TRANSITION_PHOEBE 13
#define B_TRANSITION_GLACIA 14
#define B_TRANSITION_DRAKE 15
#define B_TRANSITION_STEVEN 16
#define B_TRANSITION_BLUR 0
#define B_TRANSITION_SWEARL 1
#define B_TRANSITION_SHUFFLE 2
#define B_TRANSITION_BIG_POKEBALL 3
#define B_TRANSITION_POKEBALLS_WIPEOUT 4
#define B_TRANSITION_CLOCKWISE_BLACKFADE 5
#define B_TRANSITION_RIPPLE 6
#define B_TRANSITION_WAVE 7
#define B_TRANSITION_SLICE 8
#define B_TRANSITION_WHITEFADE 9
#define B_TRANSITION_GRID_SQUARES 10
#define B_TRANSITION_SHARDS 11
#define B_TRANSITION_SYDNEY 12
#define B_TRANSITION_PHOEBE 13
#define B_TRANSITION_GLACIA 14
#define B_TRANSITION_DRAKE 15
#define B_TRANSITION_STEVEN 16
#endif // GUARD_BATTLE_TRANSITION_H

View File

@ -11,6 +11,7 @@
#include "sound.h"
#include "songs.h"
#include "trainer.h"
#include "field_camera.h"
void sub_807DE10(void);
void dp12_8087EA4(void);
@ -46,6 +47,12 @@ struct TransitionData
s16 field_2A;
s16 field_2C;
s16 field_2E;
s16 field_30;
s16 field_32;
s16 field_34;
s16 field_36;
s16 field_38;
s16 field_3A;
};
#define TRANSITION_STRUCT (*(struct TransitionData *) (ewram + 0xC000))
@ -160,22 +167,22 @@ static bool8 sub_811C938(struct Sprite* sprite);
static bool8 sub_811C984(struct Sprite* sprite);
static bool8 sub_811C9B8(struct Sprite* sprite);
static bool8 sub_811C9E4(struct Sprite* sprite);
static void sub_811D4C8(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4);
static void CreatePhase1Task(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4);
static bool8 sub_811D52C(void);
static void Phase1_Task_RunFuncs(u8 taskID);
static bool8 Phase1_TransitionAll_Func1(struct Task* task);
static bool8 Phase1_TransitionAll_Func2(struct Task* task);
static void sub_811D658(void);
static void VBlankCB_BattleTransition(void);
static void sub_811D6A8(u16** a0, u16** a1);
static void sub_811D690(u16** a0);
static void sub_811D6D4(void);
static void sub_811D6E8(s16* array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize);
void sub_811D658(void);
void VBlankCB_BattleTransition(void);
void sub_811D6E8(s16* a0, s16 a1, s16 a2, s16 a3, s16 a4, s16 a5);
void sub_811D6A8(u16** a0, u16** a1);
void sub_811D690(u16** a0);
void sub_811D764(u16* a0, s16 a1, s16 a2, s16 a3);
void sub_811D6D4(void);
void sub_811D8FC(s16* a0, s16 a1, s16 a2, s16 a3, s16 a4, s16 a5, s16 a6);
bool8 sub_811D978(s16* a0, bool8 a1, bool8 a2);
void sub_811CFD0(struct Sprite* sprite);
void sub_811D54C(u8 taskID);
bool8 sub_811D584(struct Task* task);
bool8 sub_811D5E0(struct Task* task);
// const data
@ -187,7 +194,7 @@ const u32 gSpriteImage_83FC528[] = INCBIN_U32("graphics/battle_transitions/unuse
const u32 gSpriteImage_83FCD28[] = INCBIN_U32("graphics/battle_transitions/unused_lass.4bpp");
const u32 gUnknown_083FD528[] = INCBIN_U32("graphics/battle_transitions/shrinking_box.4bpp");
struct TransitionData * const sTransitionStructPtr = &TRANSITION_STRUCT;
static struct TransitionData * const sTransitionStructPtr = &TRANSITION_STRUCT;
static const TaskFunc sPhase1_Tasks[TRANSITIONS_NO] =
{
@ -380,10 +387,10 @@ static const s16 gUnknown_083FD8F4[][5] =
static const s16 gUnknown_083FD93A[] = {8, 4, 2, 1, 1, 1, 0};
static const TransitionState gUnknown_083FD948[] =
static const TransitionState sPhase1_TransitionAll_Funcs[] =
{
&sub_811D584,
&sub_811D5E0
&Phase1_TransitionAll_Func1,
&Phase1_TransitionAll_Func2
};
extern const u16 gFieldEffectObjectPalette10[];
@ -416,10 +423,10 @@ bool8 IsBattleTransitionDone(void)
if (gTasks[taskID].tTransitionDone)
{
DestroyTask(taskID);
return 1;
return TRUE;
}
else
return 0;
return FALSE;
}
static void LaunchBattleTransitionTask(u8 transitionID)
@ -441,12 +448,12 @@ static bool8 Transition_Phase1(struct Task* task)
{
CreateTask(sPhase1_Tasks[task->tTransitionID], 4);
task->tState++;
return 0;
return FALSE;
}
else
{
task->tState = 2;
return 1;
return TRUE;
}
}
@ -455,17 +462,17 @@ static bool8 Transition_WaitForPhase1(struct Task* task)
if (FindTaskIdByFunc(sPhase1_Tasks[task->tTransitionID]) == 0xFF)
{
task->tState++;
return 1;
return TRUE;
}
else
return 0;
return FALSE;
}
static bool8 Transition_Phase2(struct Task* task)
{
CreateTask(sPhase2_Tasks[task->tTransitionID], 0);
task->tState++;
return 0;
return FALSE;
}
static bool8 Transition_WaitForPhase2(struct Task* task)
@ -473,7 +480,7 @@ static bool8 Transition_WaitForPhase2(struct Task* task)
task->tTransitionDone = 0;
if (FindTaskIdByFunc(sPhase2_Tasks[task->tTransitionID]) == 0xFF)
task->tTransitionDone = 1;
return 0;
return FALSE;
}
static void Phase1Task_TransitionAll(u8 taskID)
@ -481,7 +488,7 @@ static void Phase1Task_TransitionAll(u8 taskID)
if (gTasks[taskID].tState == 0)
{
gTasks[taskID].tState++;
sub_811D4C8(0, 0, 3, 2, 2);
CreatePhase1Task(0, 0, 3, 2, 2);
}
else if (sub_811D52C())
DestroyTask(taskID);
@ -499,7 +506,7 @@ static bool8 Phase2_Transition0_Func1(struct Task* task)
REG_BG2CNT |= 0x40;
REG_BG3CNT |= 0x40;
task->tState++;
return 1;
return TRUE;
}
static bool8 Phase2_Transition0_Func2(struct Task* task)
@ -515,7 +522,7 @@ static bool8 Phase2_Transition0_Func2(struct Task* task)
if (task->data[2] > 14)
task->tState++;
}
return 0;
return FALSE;
}
static bool8 Phase2_Transition0_Func3(struct Task* task)
@ -525,7 +532,7 @@ static bool8 Phase2_Transition0_Func3(struct Task* task)
u8 taskID = FindTaskIdByFunc(Phase2Task_Transition0);
DestroyTask(taskID);
}
return 0;
return FALSE;
}
static void Phase2Task_Transition1(u8 taskID)
@ -552,7 +559,7 @@ static bool8 Phase2_Transition1_Func1(struct Task* task)
REG_DISPSTAT |= 0x18;
task->tState++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition1_Func2(struct Task* task)
@ -570,7 +577,7 @@ static bool8 Phase2_Transition1_Func2(struct Task* task)
}
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static void VBlankCB_Phase2_Transition1(void)
@ -613,7 +620,7 @@ static bool8 Phase2_Transition2_Func1(struct Task* task)
REG_DISPSTAT |= 0x18;
task->tState++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition2_Func2(struct Task* task)
@ -637,7 +644,7 @@ static bool8 Phase2_Transition2_Func2(struct Task* task)
DestroyTask(FindTaskIdByFunc(Phase2Task_Transition2));
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static void VBlankCB_Phase2_Transition2(void)
@ -692,7 +699,7 @@ static bool8 Phase2_Transition3_Func1(struct Task* task)
LoadPalette(gFieldEffectObjectPalette10, 240, 32);
task->tState++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition3_Func2(struct Task* task)
@ -713,7 +720,7 @@ static bool8 Phase2_Transition3_Func2(struct Task* task)
sub_811D6E8(gUnknown_03004DE0[0], 0, task->data[4], 132, task->data[5], 160);
task->tState++;
return 1;
return TRUE;
}
static bool8 Phase2_Transition3_Func3(struct Task* task)
@ -733,7 +740,7 @@ static bool8 Phase2_Transition3_Func3(struct Task* task)
sub_811D6E8(gUnknown_03004DE0[0], 0, task->data[4], 132, task->data[5] >> 8, 160);
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition3_Func4(struct Task* task)
@ -753,7 +760,7 @@ static bool8 Phase2_Transition3_Func4(struct Task* task)
sub_811D6E8(gUnknown_03004DE0[0], 0, task->data[4], 132, task->data[5] >> 8, 160);
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition3_Func5(struct Task* task)
@ -773,7 +780,7 @@ static bool8 Phase2_Transition3_Func5(struct Task* task)
}
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition3_Func6(struct Task* task)
@ -801,7 +808,7 @@ static bool8 Phase2_Transition3_Func6(struct Task* task)
}
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static void Transition3_Vblank(void)
@ -844,7 +851,7 @@ static bool8 Phase2_Transition4_Func1(struct Task* task)
LoadPalette(gFieldEffectObjectPalette10, 0xF0, 0x20);
task->tState++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition4_Func2(struct Task* task)
@ -867,7 +874,7 @@ static bool8 Phase2_Transition4_Func2(struct Task* task)
}
task->tState++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition4_Func3(struct Task* task)
@ -877,7 +884,7 @@ static bool8 Phase2_Transition4_Func3(struct Task* task)
sub_811D6D4();
DestroyTask(FindTaskIdByFunc(Phase2Task_Transition4));
}
return 0;
return FALSE;
}
bool8 FldEff_Pokeball(void)
@ -890,7 +897,7 @@ bool8 FldEff_Pokeball(void)
gSprites[spriteID].data2 = -1;
InitSpriteAffineAnim(&gSprites[spriteID]);
StartSpriteAffineAnim(&gSprites[spriteID], gUnknown_0202FF84[2]);
return 0;
return FALSE;
}
#define SOME_VRAM_STORE(ptr, posY, posX, toStore) \
@ -960,7 +967,7 @@ static bool8 Phase2_Transition5_Func1(struct Task* task)
TRANSITION_STRUCT.field_2C = 120;
task->tState++;
return 1;
return TRUE;
}
static bool8 Phase2_Transition5_Func2(struct Task* task)
@ -981,7 +988,7 @@ static bool8 Phase2_Transition5_Func2(struct Task* task)
}
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition5_Func3(struct Task* task)
@ -1019,7 +1026,7 @@ static bool8 Phase2_Transition5_Func3(struct Task* task)
}
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition5_Func4(struct Task* task)
@ -1040,7 +1047,7 @@ static bool8 Phase2_Transition5_Func4(struct Task* task)
}
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition5_Func5(struct Task* task)
@ -1079,7 +1086,7 @@ static bool8 Phase2_Transition5_Func5(struct Task* task)
}
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition5_Func6(struct Task* task)
@ -1103,7 +1110,7 @@ static bool8 Phase2_Transition5_Func6(struct Task* task)
task->tState++;
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition5_Func7(struct Task* task)
@ -1111,7 +1118,7 @@ static bool8 Phase2_Transition5_Func7(struct Task* task)
DmaStop(0);
sub_811D6D4();
DestroyTask(FindTaskIdByFunc(Phase2Task_Transition5));
return 0;
return FALSE;
}
static void VBlankCB_Phase2_Transition5(void)
@ -1151,7 +1158,7 @@ static bool8 Phase2_Transition6_Func1(struct Task* task)
REG_DISPSTAT |= 0x10;
task->tState++;
return 1;
return TRUE;
}
static bool8 Phase2_Transition6_Func2(struct Task* task)
@ -1188,7 +1195,7 @@ static bool8 Phase2_Transition6_Func2(struct Task* task)
DestroyTask(FindTaskIdByFunc(Phase2Task_Transition6));
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static void VBlankCB_Phase2_Transition6(void)
@ -1231,7 +1238,7 @@ static bool8 Phase2_Transition7_Func1(struct Task* task)
SetVBlankCallback(VBlankCB_Phase2_Transition7);
task->tState++;
return 1;
return TRUE;
}
static bool8 Phase2_Transition7_Func2(struct Task* task)
@ -1261,7 +1268,7 @@ static bool8 Phase2_Transition7_Func2(struct Task* task)
task->tState++;
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition7_Func3(struct Task* task)
@ -1269,7 +1276,7 @@ static bool8 Phase2_Transition7_Func3(struct Task* task)
DmaStop(0);
sub_811D6D4();
DestroyTask(FindTaskIdByFunc(Phase2Task_Transition7));
return 0;
return FALSE;
}
static void VBlankCB_Phase2_Transition7(void)
@ -1346,7 +1353,7 @@ static bool8 Phase2_Mugshot_Func1(struct Task* task)
SetVBlankCallback(VBlankCB0_Phase2_Mugshots);
task->tState++;
return 0;
return FALSE;
}
static bool8 Phase2_Mugshot_Func2(struct Task* task)
@ -1373,7 +1380,7 @@ static bool8 Phase2_Mugshot_Func2(struct Task* task)
REG_DISPSTAT |= 0x10;
SetHBlankCallback(HBlankCB_Phase2_Mugshots);
task->tState++;
return 0;
return FALSE;
}
static bool8 Phase2_Mugshot_Func3(struct Task* task)
@ -1421,7 +1428,7 @@ static bool8 Phase2_Mugshot_Func3(struct Task* task)
TRANSITION_STRUCT.field_18 -= 8;
TRANSITION_STRUCT.field_1A += 8;
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Mugshot_Func4(struct Task* task)
@ -1450,7 +1457,7 @@ static bool8 Phase2_Mugshot_Func4(struct Task* task)
PlaySE(SE_BT_START);
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Mugshot_Func5(struct Task* task)
@ -1462,7 +1469,7 @@ static bool8 Phase2_Mugshot_Func5(struct Task* task)
task->tState++;
sub_811CA28(task->tMugshotPlayerID);
}
return 0;
return FALSE;
}
static bool8 Phase2_Mugshot_Func6(struct Task* task)
@ -1484,7 +1491,7 @@ static bool8 Phase2_Mugshot_Func6(struct Task* task)
TRANSITION_STRUCT.BLDCNT = 0xBF;
SetVBlankCallback(VBlankCB1_Phase2_Mugshots);
}
return 0;
return FALSE;
}
static bool8 Phase2_Mugshot_Func7(struct Task* task)
@ -1525,7 +1532,7 @@ static bool8 Phase2_Mugshot_Func7(struct Task* task)
task->tState++;
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Mugshot_Func8(struct Task* task)
@ -1536,7 +1543,7 @@ static bool8 Phase2_Mugshot_Func8(struct Task* task)
task->data[3] = 0;
task->tState++;
return 1;
return TRUE;
}
static bool8 Phase2_Mugshot_Func9(struct Task* task)
@ -1549,7 +1556,7 @@ static bool8 Phase2_Mugshot_Func9(struct Task* task)
task->tState++;
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Mugshot_Func10(struct Task* task)
@ -1557,7 +1564,7 @@ static bool8 Phase2_Mugshot_Func10(struct Task* task)
DmaStop(0);
sub_811D6D4();
DestroyTask(FindTaskIdByFunc(task->func));
return 0;
return FALSE;
}
static void VBlankCB0_Phase2_Mugshots(void)
@ -1634,7 +1641,7 @@ void sub_811C90C(struct Sprite* sprite)
bool8 sub_811C934(struct Sprite* sprite)
{
return 0;
return FALSE;
}
bool8 sub_811C938(struct Sprite* sprite)
@ -1648,7 +1655,7 @@ bool8 sub_811C938(struct Sprite* sprite)
sprite->data0++;
sprite->data1 = arr0[sprite->data7];
sprite->data2 = arr1[sprite->data7];
return 1;
return TRUE;
}
bool8 sub_811C984(struct Sprite* sprite)
@ -1658,7 +1665,7 @@ bool8 sub_811C984(struct Sprite* sprite)
sprite->data0++;
else if (!sprite->data7 && sprite->pos1.x > 103)
sprite->data0++;
return 0;
return FALSE;
}
bool8 sub_811C9B8(struct Sprite* sprite)
@ -1671,7 +1678,7 @@ bool8 sub_811C9B8(struct Sprite* sprite)
sprite->data2 = -sprite->data2;
sprite->data6 = 1;
}
return 0;
return FALSE;
}
bool8 sub_811C9E4(struct Sprite* sprite)
@ -1680,7 +1687,7 @@ bool8 sub_811C9E4(struct Sprite* sprite)
sprite->pos1.x += sprite->data1;
if (sprite->pos1.x < -31 || sprite->pos1.x > 271)
sprite->data0++;
return 0;
return FALSE;
}
static void sub_811CA10(s16 spriteID, s16 value)
@ -1733,7 +1740,7 @@ static bool8 Phase2_Transition8_Func1(struct Task* task)
SetHBlankCallback(HBlankCB_Phase2_Transition8);
task->tState++;
return 1;
return TRUE;
}
static bool8 Phase2_Transition8_Func2(struct Task* task)
@ -1770,7 +1777,7 @@ static bool8 Phase2_Transition8_Func2(struct Task* task)
task->tState++;
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition8_Func3(struct Task* task)
@ -1778,7 +1785,7 @@ static bool8 Phase2_Transition8_Func3(struct Task* task)
DmaStop(0);
sub_811D6D4();
DestroyTask(FindTaskIdByFunc(Phase2Task_Transition8));
return 0;
return FALSE;
}
static void VBlankCB_Phase2_Transition8(void)
@ -1832,7 +1839,7 @@ static bool8 Phase2_Transition9_Func1(struct Task* task)
SetVBlankCallback(VBlankCB0_Phase2_Transition9);
task->tState++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition9_Func2(struct Task* task)
@ -1852,7 +1859,7 @@ static bool8 Phase2_Transition9_Func2(struct Task* task)
sprite->data6++;
task->tState++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition9_Func3(struct Task* task)
@ -1863,7 +1870,7 @@ static bool8 Phase2_Transition9_Func3(struct Task* task)
BlendPalettes(-1, 0x10, 0x7FFF);
task->tState++;
}
return 0;
return FALSE;
}
static bool8 Phase2_Transition9_Func4(struct Task* task)
@ -1882,7 +1889,7 @@ static bool8 Phase2_Transition9_Func4(struct Task* task)
SetVBlankCallback(VBlankCB1_Phase2_Transition9);
task->tState++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition9_Func5(struct Task* task)
@ -1892,7 +1899,7 @@ static bool8 Phase2_Transition9_Func5(struct Task* task)
sub_811D6D4();
DestroyTask(FindTaskIdByFunc(Phase2Task_Transition9));
}
return 0;
return FALSE;
}
static void VBlankCB0_Phase2_Transition9(void)
@ -1982,7 +1989,7 @@ static bool8 Phase2_Transition10_Func1(struct Task* task)
LoadPalette(gFieldEffectObjectPalette10, 0xF0, 0x20);
task->tState++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition10_Func2(struct Task* task)
@ -2003,7 +2010,7 @@ static bool8 Phase2_Transition10_Func2(struct Task* task)
}
task->data[1]--;
return 0;
return FALSE;
}
static bool8 Phase2_Transition10_Func3(struct Task* task)
@ -2013,7 +2020,7 @@ static bool8 Phase2_Transition10_Func3(struct Task* task)
sub_811D6D4();
DestroyTask(FindTaskIdByFunc(Phase2Task_Transition10));
}
return 0;
return FALSE;
}
static void Phase2Task_Transition11(u8 taskID)
@ -2041,7 +2048,7 @@ static bool8 Phase2_Transition11_Func1(struct Task* task)
SetVBlankCallback(VBlankCB_Phase2_Transition11);
task->tState++;
return 1;
return TRUE;
}
static bool8 Phase2_Transition11_Func2(struct Task* task)
@ -2054,7 +2061,7 @@ static bool8 Phase2_Transition11_Func2(struct Task* task)
1, 1);
task->data[2] = gUnknown_083FD8F4[task->data[1]][4];
task->tState++;
return 1;
return TRUE;
}
static bool8 Phase2_Transition11_Func3(struct Task* task)
@ -2093,7 +2100,7 @@ static bool8 Phase2_Transition11_Func3(struct Task* task)
}
TRANSITION_STRUCT.VBlank_DMA++;
return 0;
return FALSE;
}
static bool8 Phase2_Transition11_Func4(struct Task* task)
@ -2102,14 +2109,14 @@ static bool8 Phase2_Transition11_Func4(struct Task* task)
{
task->tState++;
task->data[3] = gUnknown_083FD93A[task->data[1] - 1];
return 1;
return TRUE;
}
else
{
DmaStop(0);
sub_811D6D4();
DestroyTask(FindTaskIdByFunc(Phase2Task_Transition11));
return 0;
return FALSE;
}
}
@ -2118,10 +2125,10 @@ static bool8 Phase2_Transition11_Func5(struct Task* task)
if (--task->data[3] == 0)
{
task->tState = 1;
return 1;
return TRUE;
}
else
return 0;
return FALSE;
}
static void VBlankCB_Phase2_Transition11(void)
@ -2137,9 +2144,9 @@ static void VBlankCB_Phase2_Transition11(void)
DmaSet(0, gUnknown_03004DE0[1], &REG_WIN0H, 0xA2400001);
}
static void sub_811D4C8(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4)
static void CreatePhase1Task(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4)
{
u8 taskID = CreateTask(sub_811D54C, 3);
u8 taskID = CreateTask(Phase1_Task_RunFuncs, 3);
gTasks[taskID].data[1] = a0;
gTasks[taskID].data[2] = a1;
gTasks[taskID].data[3] = a2;
@ -2150,13 +2157,175 @@ static void sub_811D4C8(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4)
static bool8 sub_811D52C(void)
{
if (FindTaskIdByFunc(sub_811D54C) == 0xFF)
return 1;
if (FindTaskIdByFunc(Phase1_Task_RunFuncs) == 0xFF)
return TRUE;
else
return 0;
return FALSE;
}
void sub_811D54C(u8 taskID)
static void Phase1_Task_RunFuncs(u8 taskID)
{
while (gUnknown_083FD948[gTasks[taskID].tState](&gTasks[taskID]));
while (sPhase1_TransitionAll_Funcs[gTasks[taskID].tState](&gTasks[taskID]));
}
static bool8 Phase1_TransitionAll_Func1(struct Task* task)
{
if (task->data[6] == 0 || --task->data[6] == 0)
{
task->data[6] = task->data[1];
task->data[7] += task->data[4];
if (task->data[7] > 16)
task->data[7] = 16;
BlendPalettes(-1, task->data[7], 0x2D6B);
}
if (task->data[7] > 15)
{
task->tState++;
task->data[6] = task->data[2];
}
return FALSE;
}
static bool8 Phase1_TransitionAll_Func2(struct Task* task)
{
if (task->data[6] == 0 || --task->data[6] == 0)
{
task->data[6] = task->data[2];
task->data[7] -= task->data[5];
if (task->data[7] < 0)
task->data[7] = 0;
BlendPalettes(-1, task->data[7], 0x2D6B);
}
if (task->data[7] == 0)
{
if (--task->data[3] == 0)
DestroyTask(FindTaskIdByFunc(Phase1_Task_RunFuncs));
else
{
task->data[6] = task->data[1];
task->tState = 0;
}
}
return FALSE;
}
static void sub_811D658(void)
{
struct TransitionData* const* dummy = &sTransitionStructPtr;
memset(*dummy, 0, sizeof(struct TransitionData));
sub_8057B14(&TRANSITION_STRUCT.field_14, &TRANSITION_STRUCT.field_16);
}
static void VBlankCB_BattleTransition(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
static void sub_811D690(u16** a0)
{
u16 reg, *vram;
reg = REG_BG0CNT >> 2;
reg <<= 0xE;
vram = (u16*)(VRAM + reg);
*a0 = vram;
}
static void sub_811D6A8(u16** a0, u16** a1)
{
u16 reg0, reg1, *vram0, *vram1;
reg0 = REG_BG0CNT >> 8;
reg1 = REG_BG0CNT >> 2;
reg0 <<= 0xB;
reg1 <<= 0xE;
vram0 = (u16*)(VRAM + reg0);
*a0 = vram0;
vram1 = (u16*)(VRAM + reg1);
*a1 = vram1;
}
static void sub_811D6D4(void)
{
BlendPalettes(-1, 0x10, 0);
}
static void sub_811D6E8(s16* array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize)
{
u8 i;
for (i = 0; arrSize > 0; arrSize--, i++, index += indexIncrementer)
{
array[i] = sinAdd + Sin(0xFF & index, amplitude);
}
}
void sub_811D764(u16* array, s16 a1, s16 a2, s16 a3)
{
s16 i;
memset(array, 0xA, 160 * sizeof(s16));
for (i = 0; i < 64; i++)
{
s16 sinResult, cosResult, r1, r6, r7, r8;
s16 r2, r3;
s16 j;
sinResult = Sin(i, a3);
cosResult = Cos(i, a3);
r1 = a1 - sinResult;
r6 = a1 + sinResult;
r7 = a2 - cosResult;
r8 = a2 + cosResult;
if (r1 < 0)
r1 = 0;
if (r6 > 0xF0)
r6 = 0xF0;
if (r7 < 0)
r7 = 0;
if (r8 > 0x9F)
r8 = 0x9F;
r6 |= (r1 << 8);
array[r7] = r6;
array[r8] = r6;
cosResult = Cos(i + 1, a3);
r3 = a2 - cosResult;
r2 = a2 + cosResult;
if (r3 < 0)
r3 = 0;
if (r2 > 0x9F)
r2 = 0x9F;
j = r7;
while (j > r3)
{
array[--j] = r6;
}
j = r7;
while (j < r3)
{
array[++j] = r6;
}
j = r8;
while (j > r2)
{
array[--j] = r6;
}
j = r8;
while (j < r2)
{
array[++j] = r6;
}
}
}