Merge pull request #386 from drifloony/field_fadetransition

decompile field_fadetransition
This commit is contained in:
Cameron Hall 2017-07-22 22:34:07 -05:00 committed by GitHub
commit bb0cad7c07
7 changed files with 562 additions and 1236 deletions

File diff suppressed because it is too large Load Diff

View File

@ -130,6 +130,8 @@ void PokeballGlowEffect_5(struct Sprite *);
void PokeballGlowEffect_6(struct Sprite *);
void PokeballGlowEffect_7(struct Sprite *);
void sub_8086748(void);
bool8 sub_80867AC(struct Task *);
bool8 sub_8086854(struct Task *);
bool8 sub_8086870(struct Task *);
@ -138,6 +140,8 @@ bool8 sub_808699C(struct Task *);
bool8 sub_80869B8(struct Task *);
bool8 sub_80869F8(struct Task *);
void sub_8086A2C(u8, u8);
bool8 sub_8086AA0(struct Task *);
bool8 sub_8086AC0(struct Task *);
bool8 sub_8086B30(struct Task *);
@ -163,6 +167,8 @@ bool8 sub_8087124(struct Task *);
bool8 dive_2_unknown(struct Task *);
bool8 dive_3_unknown(struct Task *);
void sub_80871B8(u8);
bool8 sub_808722C(struct Task *, struct MapObject *, struct Sprite *);
bool8 sub_8087264(struct Task *, struct MapObject *, struct Sprite *);
bool8 sub_8087298(struct Task *, struct MapObject *, struct Sprite *);
@ -175,6 +181,8 @@ bool8 sub_80874FC(struct Task *, struct MapObject *, struct Sprite *);
bool8 sub_8087548(struct Task *, struct MapObject *, struct Sprite *);
bool8 sub_808759C(struct Task *, struct MapObject *, struct Sprite *);
void sub_8087654(u8);
bool8 sub_80876C8(struct Task *, struct MapObject *, struct Sprite *);
bool8 sub_80876F8(struct Task *, struct MapObject *, struct Sprite *);
bool8 sub_8087774(struct Task *, struct MapObject *, struct Sprite *);

View File

@ -16,7 +16,7 @@ void sub_8080B60(void);
void atk17_seteffectuser(void);
void sub_8080E28(void);
void sub_8080E44(void);
int sub_8080E70(void);
bool32 sub_8080E70(void);
void sub_8080E88(void);
void sub_8080E88();
void sp13E_warp_to_last_warp(void);

View File

@ -9,5 +9,6 @@ void Task_Truck3(u8 taskId);
void Task_HandleTruckSequence(u8 taskId);
void ExecuteTruckSequence(void);
void EndTruckSequence(u8);
void sub_80C791C(void);
#endif // GUARD_FIELD_SPECIAL_SCENE_H

View File

@ -99,7 +99,7 @@ void sub_8053F0C(void);
void sub_8053F84(void);
void sub_8053FB0(u16);
// is_warp1_light_level_8_or_9
// sub_8053FF8
void sub_8053FF8(void);
bool8 sub_8054034(void);
void sub_8054044(void);
// sub_8054050
@ -129,8 +129,8 @@ void CB2_NewGame(void);
void CB2_WhiteOut(void);
void CB2_LoadMap(void);
void CB2_LoadMap2(void);
// sub_8054534
// sub_8054588
void sub_8054534(void);
void sub_8054588(void);
void c2_80567AC(void);
void c2_exit_to_overworld_2_switch(void);
void c2_exit_to_overworld_2_local(void);

View File

@ -127,7 +127,6 @@ SECTIONS {
src/field_weather.o(.text);
asm/field_weather.o(.text);
src/field_fadetransition.o(.text);
asm/field_fadetransition.o(.text);
src/field_screen_effect.o(.text);
src/battle_setup.o(.text);
asm/cable_club.o(.text);

View File

@ -1,26 +1,41 @@
#include "global.h"
#include "gba/syscall.h"
#include "cable_club.h"
#include "fieldmap.h"
#include "field_door.h"
#include "field_effect.h"
#include "field_fadetransition.h"
#include "field_map_obj.h"
#include "field_map_obj_helpers.h"
#include "field_player_avatar.h"
#include "field_special_scene.h"
#include "field_weather.h"
#include "fldeff_flash.h"
#include "global.fieldmap.h"
#include "link.h"
#include "main.h"
#include "map_obj_lock.h"
#include "metatile_behavior.h"
#include "palette.h"
#include "rom4.h"
#include "script.h"
#include "songs.h"
#include "sound.h"
#include "start_menu.h"
#include "task.h"
extern u16 gPlttBufferFaded[];
void sub_8080B9C(u8);
void task_map_chg_seq_0807E20C(u8);
void task_map_chg_seq_0807E2CC(u8);
void task0A_fade_n_map_maybe(u8);
void sub_808115C(u8);
void palette_bg_fill_white(void)
{
u32 source_color = 0x7fff7fff;
CpuFastSet(&source_color, gPlttBufferFaded, 0x100 | (1 << 24));
CpuFastFill16(RGB_WHITE, gPlttBufferFaded, PLTT_SIZE);
}
void palette_bg_fill_black(void)
{
u32 source_color = 0;
CpuFastSet(&source_color, gPlttBufferFaded, 0x100 | (1 << 24));
CpuFastFill16(RGB_BLACK, gPlttBufferFaded, PLTT_SIZE);
}
void pal_fill_for_map_transition(void)
@ -64,7 +79,7 @@ void sub_8080958(u8 arg)
void task0A_asap_script_env_2_enable_and_set_ctx_running(u8 taskID)
{
if (sub_8080E70() == 1)
if (sub_8080E70() == TRUE)
{
DestroyTask(taskID);
EnableBothScriptContexts();
@ -76,12 +91,536 @@ void sub_8080990(void)
ScriptContext2_Enable();
sub_8053E90();
pal_fill_black();
CreateTask(&task0A_asap_script_env_2_enable_and_set_ctx_running, 0x0a);
CreateTask(task0A_asap_script_env_2_enable_and_set_ctx_running, 10);
}
void sub_80809B0(void)
{
ScriptContext2_Enable();
pal_fill_black();
CreateTask(&task0A_asap_script_env_2_enable_and_set_ctx_running, 0x0a);
CreateTask(task0A_asap_script_env_2_enable_and_set_ctx_running, 10);
}
void task_mpl_807DD60(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
{
case 0:
task->data[1] = sub_8083664();
task->data[0]++;
break;
case 1:
if (gTasks[task->data[1]].isActive != TRUE)
{
pal_fill_for_map_transition();
task->data[0]++;
}
break;
case 2:
if (sub_8080E70() == TRUE)
{
ScriptContext2_Disable();
DestroyTask(taskId);
}
}
}
void sub_8080A3C(void)
{
ScriptContext2_Enable();
sub_8053E90();
palette_bg_fill_black();
CreateTask(task_mpl_807DD60, 10);
}
void sub_8080A5C(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
{
case 0:
sub_80084A4();
task->data[0]++;
break;
case 1:
if (sub_8007ECC())
{
pal_fill_for_map_transition();
task->data[0]++;
}
break;
case 2:
if (sub_8080E70() == TRUE)
{
sub_8007B14();
ScriptContext2_Disable();
DestroyTask(taskId);
}
}
}
void sub_8080AC4(void)
{
ScriptContext2_Enable();
sub_8053E90();
palette_bg_fill_black();
CreateTask(sub_8080A5C, 10);
}
void sub_8080AE4(void)
{
s16 x, y;
u8 behavior;
TaskFunc func;
PlayerGetDestCoords(&x, &y);
behavior = MapGridGetMetatileBehaviorAt(x, y);
if (MetatileBehavior_IsDoor(behavior) == TRUE)
func = sub_8080B9C;
else if (MetatileBehavior_IsNonAnimDoor(behavior) == TRUE)
func = task_map_chg_seq_0807E20C;
else
func = task_map_chg_seq_0807E2CC;
CreateTask(func, 10);
}
void mapldr_default(void)
{
sub_8053E90();
pal_fill_for_map_transition();
sub_8080AE4();
ScriptContext2_Enable();
}
void sub_8080B60(void)
{
sub_8053E90();
pal_fill_black();
sub_8080AE4();
ScriptContext2_Enable();
}
void sub_8080B78(void)
{
sub_8053E90();
pal_fill_for_map_transition();
PlaySE(SE_TK_WARPOUT);
CreateTask(task_map_chg_seq_0807E2CC, 10);
ScriptContext2_Enable();
}
void sub_8080B9C(u8 taskId)
{
struct Task *task = &gTasks[taskId];
s16 *x = &task->data[2];
s16 *y = &task->data[3];
switch (task->data[0])
{
case 0:
sub_8080958(0);
FreezeMapObjects();
PlayerGetDestCoords(x, y);
FieldSetDoorOpened(*x, *y);
task->data[0] = 1;
break;
case 1:
if (sub_8080E70())
{
u8 mapObjId;
sub_8080958(1);
mapObjId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0);
FieldObjectSetSpecialAnim(&gMapObjects[mapObjId], 8);
task->data[0] = 2;
}
break;
case 2:
if (walkrun_is_standing_still())
{
u8 mapObjId;
task->data[1] = FieldAnimateDoorClose(*x, *y);
mapObjId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0);
FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[mapObjId]);
task->data[0] = 3;
}
break;
case 3:
if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE)
{
UnfreezeMapObjects();
task->data[0] = 4;
}
break;
case 4:
ScriptContext2_Disable();
DestroyTask(taskId);
break;
}
}
void task_map_chg_seq_0807E20C(u8 taskId)
{
struct Task *task = &gTasks[taskId];
s16 *x = &task->data[2];
s16 *y = &task->data[3];
switch (task->data[0])
{
case 0:
sub_8080958(0);
FreezeMapObjects();
PlayerGetDestCoords(x, y);
task->data[0] = 1;
break;
case 1:
if (sub_8080E70())
{
u8 mapObjId;
sub_8080958(1);
mapObjId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0);
FieldObjectSetSpecialAnim(&gMapObjects[mapObjId], GetGoSpeed0AnimId(player_get_direction_lower_nybble()));
task->data[0] = 2;
}
break;
case 2:
if (walkrun_is_standing_still())
{
UnfreezeMapObjects();
task->data[0] = 3;
}
break;
case 3:
ScriptContext2_Disable();
DestroyTask(taskId);
break;
}
}
void task_map_chg_seq_0807E2CC(u8 taskId)
{
switch (gTasks[taskId].data[0])
{
case 0:
FreezeMapObjects();
ScriptContext2_Enable();
gTasks[taskId].data[0]++;
break;
case 1:
if (sub_8080E70())
{
UnfreezeMapObjects();
ScriptContext2_Disable();
DestroyTask(taskId);
}
break;
}
}
void sub_8080DC4(u8 taskId)
{
if (sub_8080E70() == TRUE)
{
DestroyTask(taskId);
CreateTask(sub_80712B4, 80);
}
}
void atk17_seteffectuser(void)
{
pal_fill_black();
CreateStartMenuTask(sub_8080DC4);
ScriptContext2_Enable();
}
void task_mpl_807E3C8(u8 taskId)
{
if (sub_8080E70() == 1)
{
ScriptContext2_Disable();
DestroyTask(taskId);
sub_8064E2C();
}
}
void sub_8080E28(void)
{
ScriptContext2_Enable();
pal_fill_black();
CreateTask(task_mpl_807E3C8, 10);
}
void sub_8080E44(void)
{
ScriptContext2_Enable();
sub_8053E90();
pal_fill_black();
CreateTask(task_mpl_807E3C8, 10);
}
bool32 sub_8080E64(void)
{
return gPaletteFade.active;
}
bool32 sub_8080E70(void)
{
if (sub_807D770() == TRUE)
return TRUE;
else
return FALSE;
}
void sub_8080E88(void)
{
ScriptContext2_Enable();
sub_8053FF8();
fade_8080918();
PlayRainSoundEffect();
PlaySE(SE_KAIDAN);
gFieldCallback = mapldr_default;
CreateTask(task0A_fade_n_map_maybe, 10);
}
void sp13E_warp_to_last_warp(void)
{
ScriptContext2_Enable();
sub_8053FF8();
fade_8080918();
PlayRainSoundEffect();
gFieldCallback = mapldr_default;
CreateTask(task0A_fade_n_map_maybe, 10);
}
void sub_8080EF0(void)
{
ScriptContext2_Enable();
gFieldCallback = mapldr_default;
CreateTask(sub_808115C, 10);
}
void sp13F_fall_to_last_warp(void)
{
sp13E_warp_to_last_warp();
gFieldCallback = sub_8086748;
}
void sub_8080F2C(u8 metatileBehavior)
{
ScriptContext2_Enable();
sub_8086A2C(metatileBehavior, 10);
}
void sub_8080F48(void)
{
ScriptContext2_Enable();
sub_80871B8(10);
}
void sub_8080F58(void)
{
ScriptContext2_Enable();
sub_8087654(10);
}
void sub_8080F68(void)
{
ScriptContext2_Enable();
sub_8053FF8();
fade_8080918();
PlaySE(SE_TK_WARPIN);
CreateTask(task0A_fade_n_map_maybe, 10);
gFieldCallback = sub_8080B78;
}
void sub_8080F9C(void)
{
ScriptContext2_Enable();
fade_8080918();
CreateTask(task0A_fade_n_map_maybe, 10);
gFieldCallback = sub_80C791C;
}
void sub_8080FC4(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
{
case 0:
ScriptContext2_Enable();
task->data[0]++;
break;
case 1:
if (!sub_8080E64() && sub_8054034())
{
task->data[0]++;
}
break;
case 2:
warp_in();
SetMainCallback2(sub_8054588);
DestroyTask(taskId);
break;
}
}
void DoCableClubWarp(void)
{
ScriptContext2_Enable();
sub_8053FF8();
fade_8080918();
PlaySE(SE_KAIDAN);
CreateTask(sub_8080FC4, 10);
}
void sub_8081050(u8 taskId)
{
s16 *data = gTasks[taskId].data;
switch (data[0])
{
case 0:
ClearLinkCallback_2();
fade_screen(1, 0);
sub_8053FF8();
PlaySE(SE_KAIDAN);
data[0]++;
break;
case 1:
if (!sub_8080E64() && sub_8054034())
{
sub_800832C();
data[0]++;
}
break;
case 2:
if (!gReceivedRemoteLinkPlayers)
{
warp_in();
SetMainCallback2(CB2_LoadMap);
DestroyTask(taskId);
}
break;
}
}
void sub_80810DC(void)
{
CreateTask(sub_8081050, 10);
}
void task0A_fade_n_map_maybe(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
{
case 0:
FreezeMapObjects();
ScriptContext2_Enable();
task->data[0]++;
break;
case 1:
if (!sub_8080E64() && sub_8054034())
{
task->data[0]++;
}
break;
case 2:
warp_in();
SetMainCallback2(CB2_LoadMap);
DestroyTask(taskId);
break;
}
}
void sub_808115C(u8 taskId)
{
struct Task *task = &gTasks[taskId];
s16 *x = &task->data[2];
s16 *y = &task->data[3];
switch (task->data[0])
{
case 0:
FreezeMapObjects();
PlayerGetDestCoords(x, y);
PlaySE(sub_8058790(*x, *y - 1));
task->data[1] = FieldAnimateDoorOpen(*x, *y - 1);
task->data[0] = 1;
break;
case 1:
if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE)
{
u8 mapObjId;
mapObjId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0);
FieldObjectClearAnimIfSpecialAnimActive(&gMapObjects[mapObjId]);
mapObjId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0);
FieldObjectSetSpecialAnim(&gMapObjects[mapObjId], 9);
task->data[0] = 2;
}
break;
case 2:
if (walkrun_is_standing_still())
{
u8 mapObjId;
task->data[1] = FieldAnimateDoorClose(*x, *y - 1);
mapObjId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0);
FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[mapObjId]);
sub_8080958(0);
task->data[0] = 3;
}
break;
case 3:
if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE)
{
task->data[0] = 4;
}
break;
case 4:
sub_8053FF8();
fade_8080918();
PlayRainSoundEffect();
task->data[0] = 0;
task->func = task0A_fade_n_map_maybe;
break;
}
}
void sub_80812C8(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
{
case 0:
FreezeMapObjects();
ScriptContext2_Enable();
task->data[0]++;
break;
case 1:
if (!sub_8080E64() && sub_8054034())
{
task->data[0]++;
}
break;
case 2:
warp_in();
SetMainCallback2(sub_8054534);
DestroyTask(taskId);
break;
}
}
void sub_8081334(void)
{
ScriptContext2_Enable();
sub_8053FF8();
fade_8080918();
PlayRainSoundEffect();
PlaySE(SE_KAIDAN);
gFieldCallback = sub_8080B60;
CreateTask(sub_80812C8, 10);
}