mirror of https://github.com/pret/pokeemerald.git
Document cave transition code.
This commit is contained in:
parent
258784f263
commit
711e7d884c
|
@ -33,7 +33,7 @@ void sub_8161560(u8 taskId);
|
||||||
|
|
||||||
// flash
|
// flash
|
||||||
bool8 SetUpFieldMove_Flash(void);
|
bool8 SetUpFieldMove_Flash(void);
|
||||||
void c2_change_map(void);
|
void CB2_DoChangeMap(void);
|
||||||
bool8 GetMapPairFadeToType(u8 a1, u8 a2);
|
bool8 GetMapPairFadeToType(u8 a1, u8 a2);
|
||||||
bool8 GetMapPairFadeFromType(u8 a1, u8 a2);
|
bool8 GetMapPairFadeFromType(u8 a1, u8 a2);
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,13 @@
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "constants/songs.h"
|
#include "constants/songs.h"
|
||||||
|
#include "constants/map_types.h"
|
||||||
|
|
||||||
// structures
|
// structures
|
||||||
struct FlashStruct
|
struct FlashStruct
|
||||||
{
|
{
|
||||||
u8 unk0;
|
u8 fromType;
|
||||||
u8 unk1;
|
u8 toType;
|
||||||
bool8 unk2;
|
bool8 unk2;
|
||||||
bool8 unk3;
|
bool8 unk3;
|
||||||
void (*func)(void);
|
void (*func)(void);
|
||||||
|
@ -28,38 +29,38 @@ struct FlashStruct
|
||||||
// static functions
|
// static functions
|
||||||
static void hm2_flash(void);
|
static void hm2_flash(void);
|
||||||
static void sub_81371B4(void);
|
static void sub_81371B4(void);
|
||||||
static bool8 sub_8137304(void);
|
static bool8 MaybeDoMapTransition(void);
|
||||||
static void sub_81373F0(void);
|
static void DoExitCaveTransition(void);
|
||||||
static void sub_8137404(u8 taskId);
|
static void Task_ExitCaveTransition1(u8 taskId);
|
||||||
static void sub_8137420(u8 taskId);
|
static void Task_ExitCaveTransition2(u8 taskId);
|
||||||
static void sub_81374C4(u8 taskId);
|
static void Task_ExitCaveTransition3(u8 taskId);
|
||||||
static void sub_813750C(u8 taskId);
|
static void Task_ExitCaveTransition4(u8 taskId);
|
||||||
static void sub_8137574(u8 taskId);
|
static void Task_ExitCaveTransition5(u8 taskId);
|
||||||
static void sub_81375A8(void);
|
static void DoEnterCaveTransition(void);
|
||||||
static void sub_81375BC(u8 taskId);
|
static void Task_EnterCaveTransition1(u8 taskId);
|
||||||
static void sub_81375D8(u8 taskId);
|
static void Task_EnterCaveTransition2(u8 taskId);
|
||||||
static void sub_8137678(u8 taskId);
|
static void Task_EnterCaveTransition3(u8 taskId);
|
||||||
static void sub_81376DC(u8 taskId);
|
static void Task_EnterCaveTransition4(u8 taskId);
|
||||||
|
|
||||||
// rodata
|
// rodata
|
||||||
static const struct FlashStruct gUnknown_085B27C8[] =
|
static const struct FlashStruct sTransitionTypes[] =
|
||||||
{
|
{
|
||||||
{1, 4, 1, 0, sub_81375A8},
|
{MAP_TYPE_TOWN, MAP_TYPE_UNDERGROUND, 1, 0, DoEnterCaveTransition},
|
||||||
{2, 4, 1, 0, sub_81375A8},
|
{MAP_TYPE_CITY, MAP_TYPE_UNDERGROUND, 1, 0, DoEnterCaveTransition},
|
||||||
{3, 4, 1, 0, sub_81375A8},
|
{MAP_TYPE_ROUTE, MAP_TYPE_UNDERGROUND, 1, 0, DoEnterCaveTransition},
|
||||||
{5, 4, 1, 0, sub_81375A8},
|
{MAP_TYPE_UNDERWATER, MAP_TYPE_UNDERGROUND, 1, 0, DoEnterCaveTransition},
|
||||||
{6, 4, 1, 0, sub_81375A8},
|
{MAP_TYPE_OCEAN_ROUTE, MAP_TYPE_UNDERGROUND, 1, 0, DoEnterCaveTransition},
|
||||||
{7, 4, 1, 0, sub_81375A8},
|
{MAP_TYPE_UNUSED_2, MAP_TYPE_UNDERGROUND, 1, 0, DoEnterCaveTransition},
|
||||||
{8, 4, 1, 0, sub_81375A8},
|
{MAP_TYPE_INDOOR, MAP_TYPE_UNDERGROUND, 1, 0, DoEnterCaveTransition},
|
||||||
{9, 4, 1, 0, sub_81375A8},
|
{MAP_TYPE_SECRET_BASE, MAP_TYPE_UNDERGROUND, 1, 0, DoEnterCaveTransition},
|
||||||
{4, 1, 0, 1, sub_81373F0},
|
{MAP_TYPE_UNDERGROUND, MAP_TYPE_TOWN, 0, 1, DoExitCaveTransition},
|
||||||
{4, 2, 0, 1, sub_81373F0},
|
{MAP_TYPE_UNDERGROUND, MAP_TYPE_CITY, 0, 1, DoExitCaveTransition},
|
||||||
{4, 3, 0, 1, sub_81373F0},
|
{MAP_TYPE_UNDERGROUND, MAP_TYPE_ROUTE, 0, 1, DoExitCaveTransition},
|
||||||
{4, 5, 0, 1, sub_81373F0},
|
{MAP_TYPE_UNDERGROUND, MAP_TYPE_UNDERWATER, 0, 1, DoExitCaveTransition},
|
||||||
{4, 6, 0, 1, sub_81373F0},
|
{MAP_TYPE_UNDERGROUND, MAP_TYPE_OCEAN_ROUTE, 0, 1, DoExitCaveTransition},
|
||||||
{4, 7, 0, 1, sub_81373F0},
|
{MAP_TYPE_UNDERGROUND, MAP_TYPE_UNUSED_2, 0, 1, DoExitCaveTransition},
|
||||||
{4, 8, 0, 1, sub_81373F0},
|
{MAP_TYPE_UNDERGROUND, MAP_TYPE_INDOOR, 0, 1, DoExitCaveTransition},
|
||||||
{4, 9, 0, 1, sub_81373F0},
|
{MAP_TYPE_UNDERGROUND, MAP_TYPE_SECRET_BASE, 0, 1, DoExitCaveTransition},
|
||||||
{0, 0, 0, 0, NULL},
|
{0, 0, 0, 0, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -108,7 +109,7 @@ static void sub_81371B4(void)
|
||||||
ScriptContext1_SetupScript(EventScript_2926F8);
|
ScriptContext1_SetupScript(EventScript_2926F8);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sub_81371D4(void)
|
static void CB2_ChangeMapMain(void)
|
||||||
{
|
{
|
||||||
RunTasks();
|
RunTasks();
|
||||||
AnimateSprites();
|
AnimateSprites();
|
||||||
|
@ -116,14 +117,14 @@ static void sub_81371D4(void)
|
||||||
UpdatePaletteFade();
|
UpdatePaletteFade();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sub_81371EC(void)
|
static void VBC_ChangeMapVBlank(void)
|
||||||
{
|
{
|
||||||
LoadOam();
|
LoadOam();
|
||||||
ProcessSpriteCopyRequests();
|
ProcessSpriteCopyRequests();
|
||||||
TransferPlttBuffer();
|
TransferPlttBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void c2_change_map(void)
|
void CB2_DoChangeMap(void)
|
||||||
{
|
{
|
||||||
u16 ime;
|
u16 ime;
|
||||||
|
|
||||||
|
@ -148,23 +149,23 @@ void c2_change_map(void)
|
||||||
REG_IME = 0;
|
REG_IME = 0;
|
||||||
REG_IE |= INTR_FLAG_VBLANK;
|
REG_IE |= INTR_FLAG_VBLANK;
|
||||||
REG_IME = ime;
|
REG_IME = ime;
|
||||||
SetVBlankCallback(sub_81371EC);
|
SetVBlankCallback(VBC_ChangeMapVBlank);
|
||||||
SetMainCallback2(sub_81371D4);
|
SetMainCallback2(CB2_ChangeMapMain);
|
||||||
if (!sub_8137304())
|
if (!MaybeDoMapTransition())
|
||||||
SetMainCallback2(gMain.savedCallback);
|
SetMainCallback2(gMain.savedCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool8 sub_8137304(void)
|
static bool8 MaybeDoMapTransition(void)
|
||||||
{
|
{
|
||||||
u8 i;
|
u8 i;
|
||||||
u8 v0 = GetLastUsedWarpMapType();
|
u8 fromType = GetLastUsedWarpMapType();
|
||||||
u8 v1 = GetCurrentMapType();
|
u8 toType = GetCurrentMapType();
|
||||||
|
|
||||||
for (i = 0; gUnknown_085B27C8[i].unk0; i++)
|
for (i = 0; sTransitionTypes[i].fromType; i++)
|
||||||
{
|
{
|
||||||
if (gUnknown_085B27C8[i].unk0 == v0 && gUnknown_085B27C8[i].unk1 == v1)
|
if (sTransitionTypes[i].fromType == fromType && sTransitionTypes[i].toType == toType)
|
||||||
{
|
{
|
||||||
gUnknown_085B27C8[i].func();
|
sTransitionTypes[i].func();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,51 +173,51 @@ static bool8 sub_8137304(void)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool8 GetMapPairFadeToType(u8 a1, u8 a2)
|
bool8 GetMapPairFadeToType(u8 _fromType, u8 _toType)
|
||||||
{
|
{
|
||||||
u8 i;
|
u8 i;
|
||||||
u8 v0 = a1;
|
u8 fromType = _fromType;
|
||||||
u8 v1 = a2;
|
u8 toType = _toType;
|
||||||
|
|
||||||
for (i = 0; gUnknown_085B27C8[i].unk0; i++)
|
for (i = 0; sTransitionTypes[i].fromType; i++)
|
||||||
{
|
{
|
||||||
if (gUnknown_085B27C8[i].unk0 == v0 && gUnknown_085B27C8[i].unk1 == v1)
|
if (sTransitionTypes[i].fromType == fromType && sTransitionTypes[i].toType == toType)
|
||||||
{
|
{
|
||||||
return gUnknown_085B27C8[i].unk2;
|
return sTransitionTypes[i].unk2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool8 GetMapPairFadeFromType(u8 a1, u8 a2)
|
bool8 GetMapPairFadeFromType(u8 _fromType, u8 _toType)
|
||||||
{
|
{
|
||||||
u8 i;
|
u8 i;
|
||||||
u8 v0 = a1;
|
u8 fromType = _fromType;
|
||||||
u8 v1 = a2;
|
u8 toType = _toType;
|
||||||
|
|
||||||
for (i = 0; gUnknown_085B27C8[i].unk0; i++)
|
for (i = 0; sTransitionTypes[i].fromType; i++)
|
||||||
{
|
{
|
||||||
if (gUnknown_085B27C8[i].unk0 == v0 && gUnknown_085B27C8[i].unk1 == v1)
|
if (sTransitionTypes[i].fromType == fromType && sTransitionTypes[i].toType == toType)
|
||||||
{
|
{
|
||||||
return gUnknown_085B27C8[i].unk3;
|
return sTransitionTypes[i].unk3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sub_81373F0(void)
|
static void DoExitCaveTransition(void)
|
||||||
{
|
{
|
||||||
CreateTask(sub_8137404, 0);
|
CreateTask(Task_ExitCaveTransition1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sub_8137404(u8 taskId)
|
static void Task_ExitCaveTransition1(u8 taskId)
|
||||||
{
|
{
|
||||||
gTasks[taskId].func = sub_8137420;
|
gTasks[taskId].func = Task_ExitCaveTransition2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sub_8137420(u8 taskId)
|
static void Task_ExitCaveTransition2(u8 taskId)
|
||||||
{
|
{
|
||||||
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
||||||
LZ77UnCompVram(gCaveTransitionTiles, (void *)(VRAM + 0xC000));
|
LZ77UnCompVram(gCaveTransitionTiles, (void *)(VRAM + 0xC000));
|
||||||
|
@ -241,12 +242,12 @@ static void sub_8137420(u8 taskId)
|
||||||
| DISPCNT_OBJ_1D_MAP
|
| DISPCNT_OBJ_1D_MAP
|
||||||
| DISPCNT_BG0_ON
|
| DISPCNT_BG0_ON
|
||||||
| DISPCNT_OBJ_ON);
|
| DISPCNT_OBJ_ON);
|
||||||
gTasks[taskId].func = sub_81374C4;
|
gTasks[taskId].func = Task_ExitCaveTransition3;
|
||||||
gTasks[taskId].data[0] = 16;
|
gTasks[taskId].data[0] = 16;
|
||||||
gTasks[taskId].data[1] = 0;
|
gTasks[taskId].data[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sub_81374C4(u8 taskId)
|
static void Task_ExitCaveTransition3(u8 taskId)
|
||||||
{
|
{
|
||||||
u16 count = gTasks[taskId].data[1];
|
u16 count = gTasks[taskId].data[1];
|
||||||
u16 blend = count + 0x1000;
|
u16 blend = count + 0x1000;
|
||||||
|
@ -259,11 +260,11 @@ static void sub_81374C4(u8 taskId)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gTasks[taskId].data[2] = 0;
|
gTasks[taskId].data[2] = 0;
|
||||||
gTasks[taskId].func = sub_813750C;
|
gTasks[taskId].func = Task_ExitCaveTransition4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sub_813750C(u8 taskId)
|
static void Task_ExitCaveTransition4(u8 taskId)
|
||||||
{
|
{
|
||||||
u16 count;
|
u16 count;
|
||||||
|
|
||||||
|
@ -278,12 +279,12 @@ static void sub_813750C(u8 taskId)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LoadPalette(gCaveTransitionPalette_White, 0, 0x20);
|
LoadPalette(gCaveTransitionPalette_White, 0, 0x20);
|
||||||
gTasks[taskId].func = sub_8137574;
|
gTasks[taskId].func = Task_ExitCaveTransition5;
|
||||||
gTasks[taskId].data[2] = 8;
|
gTasks[taskId].data[2] = 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sub_8137574(u8 taskId)
|
static void Task_ExitCaveTransition5(u8 taskId)
|
||||||
{
|
{
|
||||||
if (gTasks[taskId].data[2])
|
if (gTasks[taskId].data[2])
|
||||||
gTasks[taskId].data[2]--;
|
gTasks[taskId].data[2]--;
|
||||||
|
@ -291,17 +292,17 @@ static void sub_8137574(u8 taskId)
|
||||||
SetMainCallback2(gMain.savedCallback);
|
SetMainCallback2(gMain.savedCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sub_81375A8(void)
|
static void DoEnterCaveTransition(void)
|
||||||
{
|
{
|
||||||
CreateTask(sub_81375BC, 0);
|
CreateTask(Task_EnterCaveTransition1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sub_81375BC(u8 taskId)
|
static void Task_EnterCaveTransition1(u8 taskId)
|
||||||
{
|
{
|
||||||
gTasks[taskId].func = sub_81375D8;
|
gTasks[taskId].func = Task_EnterCaveTransition2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sub_81375D8(u8 taskId)
|
static void Task_EnterCaveTransition2(u8 taskId)
|
||||||
{
|
{
|
||||||
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
||||||
LZ77UnCompVram(gCaveTransitionTiles, (void *)(VRAM + 0xC000));
|
LZ77UnCompVram(gCaveTransitionTiles, (void *)(VRAM + 0xC000));
|
||||||
|
@ -320,13 +321,13 @@ static void sub_81375D8(u8 taskId)
|
||||||
| DISPCNT_OBJ_ON);
|
| DISPCNT_OBJ_ON);
|
||||||
LoadPalette(gCaveTransitionPalette_White, 0xE0, 0x20);
|
LoadPalette(gCaveTransitionPalette_White, 0xE0, 0x20);
|
||||||
LoadPalette(gCaveTransitionPalette_Black, 0, 0x20);
|
LoadPalette(gCaveTransitionPalette_Black, 0, 0x20);
|
||||||
gTasks[taskId].func = sub_8137678;
|
gTasks[taskId].func = Task_EnterCaveTransition3;
|
||||||
gTasks[taskId].data[0] = 16;
|
gTasks[taskId].data[0] = 16;
|
||||||
gTasks[taskId].data[1] = 0;
|
gTasks[taskId].data[1] = 0;
|
||||||
gTasks[taskId].data[2] = 0;
|
gTasks[taskId].data[2] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sub_8137678(u8 taskId)
|
static void Task_EnterCaveTransition3(u8 taskId)
|
||||||
{
|
{
|
||||||
u16 count = gTasks[taskId].data[2];
|
u16 count = gTasks[taskId].data[2];
|
||||||
|
|
||||||
|
@ -346,11 +347,11 @@ static void sub_8137678(u8 taskId)
|
||||||
| BLDCNT_TGT2_BG3
|
| BLDCNT_TGT2_BG3
|
||||||
| BLDCNT_TGT2_OBJ
|
| BLDCNT_TGT2_OBJ
|
||||||
| BLDCNT_TGT2_BD);
|
| BLDCNT_TGT2_BD);
|
||||||
gTasks[taskId].func = sub_81376DC;
|
gTasks[taskId].func = Task_EnterCaveTransition4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sub_81376DC(u8 taskId)
|
static void Task_EnterCaveTransition4(u8 taskId)
|
||||||
{
|
{
|
||||||
u16 count = 16 - gTasks[taskId].data[1];
|
u16 count = 16 - gTasks[taskId].data[1];
|
||||||
u16 blend = count + 0x1000;
|
u16 blend = count + 0x1000;
|
||||||
|
|
|
@ -1579,7 +1579,7 @@ void CB2_LoadMap(void)
|
||||||
ScriptContext1_Init();
|
ScriptContext1_Init();
|
||||||
ScriptContext2_Disable();
|
ScriptContext2_Disable();
|
||||||
SetMainCallback1(NULL);
|
SetMainCallback1(NULL);
|
||||||
SetMainCallback2(c2_change_map);
|
SetMainCallback2(CB2_DoChangeMap);
|
||||||
gMain.savedCallback = CB2_LoadMap2;
|
gMain.savedCallback = CB2_LoadMap2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue