From 9f4f0df4d708f720990111034131de703ebfbb19 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 8 Mar 2020 18:38:30 -0400 Subject: fldeff_flash.c --- src/fldeff_flash.c | 476 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 476 insertions(+) create mode 100644 src/fldeff_flash.c (limited to 'src/fldeff_flash.c') diff --git a/src/fldeff_flash.c b/src/fldeff_flash.c new file mode 100644 index 000000000..7f40558d9 --- /dev/null +++ b/src/fldeff_flash.c @@ -0,0 +1,476 @@ +#include "global.h" +#include "gflib.h" +#include "event_data.h" +#include "event_scripts.h" +#include "fldeff.h" +#include "field_effect.h" +#include "map_preview_screen.h" +#include "overworld.h" +#include "party_menu.h" +#include "script.h" +#include "constants/songs.h" + +struct FlashStruct +{ + u8 fromType; + u8 toType; + bool8 isEnter; + bool8 isExit; + void (*func1)(void); + void (*func2)(u8 mapSecId); +}; + +static void sub_80C9B74(void); +static void sub_80C9BB0(void); +static bool8 sub_80C9CE8(void); +static void sub_80C9E1C(void); +static void sub_80C9E30(u8 taskId); +static void sub_80C9E4C(u8 taskId); +static void sub_80C9EF0(u8 taskId); +static void sub_80C9F38(u8 taskId); +static void sub_80C9FA0(u8 taskId); +static void sub_80C9FD4(void); +static void sub_80C9FE8(u8 taskId); +static void sub_80CA004(u8 taskId); +static void sub_80CA0A4(u8 taskId); +static void sub_80CA108(u8 taskId); +static void sub_80CA160(u8 mapsecId); +static void sub_80CA190(u8 taskId); + +static const struct FlashStruct gUnknown_83F5738[] = { + { + .fromType = 1, + .toType = 4, + .isEnter = TRUE, + .isExit = FALSE, + .func1 = sub_80C9FD4, + .func2 = sub_80CA160 + }, { + .fromType = 2, + .toType = 4, + .isEnter = TRUE, + .isExit = FALSE, + .func1 = sub_80C9FD4, + .func2 = sub_80CA160 + }, { + .fromType = 3, + .toType = 4, + .isEnter = TRUE, + .isExit = FALSE, + .func1 = sub_80C9FD4, + .func2 = sub_80CA160 + }, { + .fromType = 5, + .toType = 4, + .isEnter = TRUE, + .isExit = FALSE, + .func1 = sub_80C9FD4, + .func2 = sub_80CA160 + }, { + .fromType = 6, + .toType = 4, + .isEnter = TRUE, + .isExit = FALSE, + .func1 = sub_80C9FD4, + .func2 = sub_80CA160 + }, { + .fromType = 7, + .toType = 4, + .isEnter = TRUE, + .isExit = FALSE, + .func1 = sub_80C9FD4, + .func2 = sub_80CA160 + }, { + .fromType = 8, + .toType = 4, + .isEnter = TRUE, + .isExit = FALSE, + .func1 = sub_80C9FD4, + .func2 = sub_80CA160 + }, { + .fromType = 9, + .toType = 4, + .isEnter = TRUE, + .isExit = FALSE, + .func1 = sub_80C9FD4, + .func2 = sub_80CA160 + }, { + .fromType = 4, + .toType = 1, + .isEnter = FALSE, + .isExit = TRUE, + .func1 = sub_80C9E1C, + .func2 = sub_80CA160 + }, { + .fromType = 4, + .toType = 2, + .isEnter = FALSE, + .isExit = TRUE, + .func1 = sub_80C9E1C, + .func2 = sub_80CA160 + }, { + .fromType = 4, + .toType = 3, + .isEnter = FALSE, + .isExit = TRUE, + .func1 = sub_80C9E1C, + .func2 = sub_80CA160 + }, { + .fromType = 4, + .toType = 5, + .isEnter = FALSE, + .isExit = TRUE, + .func1 = sub_80C9E1C, + .func2 = sub_80CA160 + }, { + .fromType = 4, + .toType = 6, + .isEnter = FALSE, + .isExit = TRUE, + .func1 = sub_80C9E1C, + .func2 = sub_80CA160 + }, { + .fromType = 4, + .toType = 7, + .isEnter = FALSE, + .isExit = TRUE, + .func1 = sub_80C9E1C, + .func2 = sub_80CA160 + }, { + .fromType = 4, + .toType = 8, + .isEnter = FALSE, + .isExit = TRUE, + .func1 = sub_80C9E1C, + .func2 = sub_80CA160 + }, { + .fromType = 4, + .toType = 9, + .isEnter = FALSE, + .isExit = TRUE, + .func1 = sub_80C9E1C, + .func2 = sub_80CA160 + }, {0} +}; + +static const u16 gUnknown_83F5804[] = INCBIN_U16("graphics/field_effects/flash_white.gbapal"); +static const u16 gUnknown_83F5824[] = INCBIN_U16("graphics/field_effects/flash_black.gbapal"); +static const u16 gUnknown_83F5844[] = INCBIN_U16("graphics/field_effects/flash_gradient.gbapal"); +static const u32 gUnknown_83F5864[] = INCBIN_U32("graphics/field_effects/flash_effect_map.bin.lz"); +static const u32 gUnknown_83F5A44[] = INCBIN_U32("graphics/field_effects/flash_effect_tiles.4bpp.lz"); + +bool8 SetUpFieldMove_Flash(void) +{ + if (gMapHeader.cave != TRUE) + return FALSE; + + if (FlagGet(FLAG_SYS_FLASH_ACTIVE)) + return FALSE; + + gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; + gPostMenuFieldCallback = sub_80C9B74; + return TRUE; +} + +static void sub_80C9B74(void) +{ + u8 taskId = CreateFieldEffectShowMon(); + gFieldEffectArguments[0] = GetCursorSelectionMonId(); + gTasks[taskId].data[8] = ((uintptr_t)sub_80C9BB0) >> 16; + gTasks[taskId].data[9] = ((uintptr_t)sub_80C9BB0); +} + +static void sub_80C9BB0(void) +{ + PlaySE(SE_W115); + FlagSet(FLAG_SYS_FLASH_ACTIVE); + ScriptContext1_SetupScript(EventScript_FldEffFlash); +} + +static void sub_80C9BD0(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +static void sub_80C9BE8(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +void sub_80C9BFC(void) +{ + SetVBlankCallback(NULL); + + SetGpuReg(REG_OFFSET_DISPCNT, 0); + SetGpuReg(REG_OFFSET_BG2CNT, 0); + SetGpuReg(REG_OFFSET_BG1CNT, 0); + SetGpuReg(REG_OFFSET_BG0CNT, 0); + SetGpuReg(REG_OFFSET_BG2HOFS, 0); + SetGpuReg(REG_OFFSET_BG2VOFS, 0); + SetGpuReg(REG_OFFSET_BG1HOFS, 0); + SetGpuReg(REG_OFFSET_BG1VOFS, 0); + SetGpuReg(REG_OFFSET_BG0HOFS, 0); + SetGpuReg(REG_OFFSET_BG0VOFS, 0); + + DmaFill16(3, 0, (void *)VRAM, VRAM_SIZE); + DmaFill32(3, 0, (void *)OAM, OAM_SIZE); + DmaFill16(3, 0, (void *)(PLTT + 2), PLTT_SIZE - 2); + ResetPaletteFade(); + ResetTasks(); + ResetSpriteData(); + EnableInterrupts(INTR_FLAG_VBLANK); + SetVBlankCallback(sub_80C9BE8); + SetMainCallback2(sub_80C9BD0); + if (!sub_80C9CE8()) + SetMainCallback2(gMain.savedCallback); +} + +static bool8 sub_80C9CE8(void) +{ + u8 fromType = get_map_light_from_warp0(); + u8 toType = GetCurrentMapType(); + u8 i = 0; + if (sub_80561B4() != gMapHeader.regionMapSectionId && sub_80F8154(gMapHeader.regionMapSectionId, FALSE) == TRUE) + { + sub_80CA160(gMapHeader.regionMapSectionId); + return TRUE; + } + for (; gUnknown_83F5738[i].fromType != 0; i++) + { + if (gUnknown_83F5738[i].fromType == fromType && gUnknown_83F5738[i].toType == toType) + { + gUnknown_83F5738[i].func1(); + return TRUE; + } + } + return FALSE; +} + +bool8 sub_80C9D7C(u8 _fromType, u8 _toType) +{ + u8 fromType = _fromType; + u8 toType = _toType; + u8 i = 0; + for (; gUnknown_83F5738[i].fromType != 0; i++) + { + if (gUnknown_83F5738[i].fromType == fromType && gUnknown_83F5738[i].toType == toType) + { + return gUnknown_83F5738[i].isEnter; + } + } + return FALSE; +} + +bool8 sub_80C9DCC(u8 _fromType, u8 _toType) +{ + u8 fromType = _fromType; + u8 toType = _toType; + u8 i = 0; + for (; gUnknown_83F5738[i].fromType != 0; i++) + { + if (gUnknown_83F5738[i].fromType == fromType && gUnknown_83F5738[i].toType == toType) + { + return gUnknown_83F5738[i].isExit; + } + } + return FALSE; +} + +static void sub_80C9E1C(void) +{ + CreateTask(sub_80C9E30, 0); +} + +static void sub_80C9E30(u8 taskId) +{ + gTasks[taskId].func = sub_80C9E4C; +} + +static void sub_80C9E4C(u8 taskId) +{ + SetGpuReg(REG_OFFSET_DISPCNT, 0); + LZ77UnCompVram(gUnknown_83F5A44, (void *)BG_CHAR_ADDR(3)); + LZ77UnCompVram(gUnknown_83F5864, (void *)BG_SCREEN_ADDR(31)); + LoadPalette(gUnknown_83F5804, 0xE0, 0x20); + LoadPalette(gUnknown_83F5844 + 8, 0xE0, 0x10); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(3) | BGCNT_SCREENBASE(31)); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_OBJ_ON); + gTasks[taskId].func = sub_80C9EF0; + gTasks[taskId].data[0] = 16; + gTasks[taskId].data[1] = 0; +} + +static void sub_80C9EF0(u8 taskId) +{ + u16 r4 = gTasks[taskId].data[1]; + SetGpuReg(REG_OFFSET_BLDALPHA, (16 << 8) + r4); + if (r4 <= 16) + { + gTasks[taskId].data[1]++; + } + else + { + gTasks[taskId].data[2] = 0; + gTasks[taskId].func = sub_80C9F38; + } +} + +static void sub_80C9F38(u8 taskId) +{ + u16 r4; + SetGpuReg(REG_OFFSET_BLDALPHA, (16 << 8) + 16); + r4 = gTasks[taskId].data[2]; + if (r4 < 8) + { + gTasks[taskId].data[2]++; + LoadPalette(gUnknown_83F5844 + 8 + r4, 0xE0, 0x10 - 2 * r4); + } + else + { + LoadPalette(gUnknown_83F5804, 0x00, 0x20); + gTasks[taskId].func = sub_80C9FA0; + gTasks[taskId].data[2] = 8; + } +} + +static void sub_80C9FA0(u8 taskId) +{ + if (gTasks[taskId].data[2] != 0) + gTasks[taskId].data[2]--; + else + SetMainCallback2(gMain.savedCallback); +} + +static void sub_80C9FD4(void) +{ + CreateTask(sub_80C9FE8, 0); +} + +static void sub_80C9FE8(u8 taskId) +{ + gTasks[taskId].func = sub_80CA004; +} + +static void sub_80CA004(u8 taskId) +{ + SetGpuReg(REG_OFFSET_DISPCNT, 0); + LZ77UnCompVram(gUnknown_83F5A44, (void *)BG_CHAR_ADDR(3)); + LZ77UnCompVram(gUnknown_83F5864, (void *)BG_SCREEN_ADDR(31)); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(3) | BGCNT_SCREENBASE(31)); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_OBJ_ON); + LoadPalette(gUnknown_83F5804, 0xE0, 0x20); + LoadPalette(gUnknown_83F5824, 0, 0x20); + gTasks[taskId].func = sub_80CA0A4; + gTasks[taskId].data[0] = 16; + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; +} + +static void sub_80CA0A4(u8 taskId) +{ + u16 r4; + r4 = gTasks[taskId].data[2]; + if (r4 < 16) + { + gTasks[taskId].data[2]++; + gTasks[taskId].data[2]++; + LoadPalette(&gUnknown_83F5844[16 - (r4 + 1)], 0xE0, 2 * (r4 + 1)); + } + else + { + SetGpuReg(REG_OFFSET_BLDALPHA, (16 << 8) + 16); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD); + gTasks[taskId].func = sub_80CA108; + } +} + +static void sub_80CA108(u8 taskId) +{ + u16 r4 = 16 - gTasks[taskId].data[1]; + SetGpuReg(REG_OFFSET_BLDALPHA, (16 << 8) + r4); + if (r4 != 0) + { + gTasks[taskId].data[1]++; + } + else + { + LoadPalette(gUnknown_83F5824, 0x00, 0x20); + SetMainCallback2(gMain.savedCallback); + } +} + +static void sub_80CA160(u8 mapSecId) +{ + u8 taskId = CreateTask(sub_80CA190, 0); + gTasks[taskId].data[3] = mapSecId; +} + +static void sub_80CA190(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + switch (data[0]) + { + case 0: + SetWordTaskArg(taskId, 5, (uintptr_t)gMain.vblankCallback); + SetVBlankCallback(NULL); + sub_80F8180(); + sub_80F819C(data[3]); + BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK); + data[0]++; + break; + case 1: + if (!sub_80F8258()) + { + data[4] = sub_80F8318(data[3]); + CopyWindowToVram(data[4], 3); + data[0]++; + } + break; + case 2: + if (!IsDma3ManagerBusyWithBgCopy()) + { + BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); + SetVBlankCallback((IntrCallback)GetWordTaskArg(taskId, 5)); + data[0]++; + } + break; + case 3: + if (!UpdatePaletteFade()) + { + data[2] = sub_80F856C(data[3]); + data[0]++; + } + break; + case 4: + data[1]++; + if (data[1] > data[2] || JOY_HELD(B_BUTTON)) + { + BeginNormalPaletteFade(0xFFFFFFFF, -2, 0, 16, RGB_WHITE); + data[0]++; + } + break; + case 5: + if (!UpdatePaletteFade()) + { + int i; + for (i = 0; i < 16; i++) + { + data[i] = 0; + } + sub_80F8234(data[4]); + gTasks[taskId].func = sub_80CA004; + } + break; + } +} -- cgit v1.2.3 From 73e62801445cd2e5367b00a48830e437785128db Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 8 Mar 2020 19:54:02 -0400 Subject: Document fldeff_flash and map_preview_screen --- src/fldeff_flash.c | 277 +++++++++++++++++++++++++++-------------------------- 1 file changed, 140 insertions(+), 137 deletions(-) (limited to 'src/fldeff_flash.c') diff --git a/src/fldeff_flash.c b/src/fldeff_flash.c index 7f40558d9..f6bfd6e62 100644 --- a/src/fldeff_flash.c +++ b/src/fldeff_flash.c @@ -9,6 +9,7 @@ #include "party_menu.h" #include "script.h" #include "constants/songs.h" +#include "constants/map_types.h" struct FlashStruct { @@ -20,136 +21,136 @@ struct FlashStruct void (*func2)(u8 mapSecId); }; -static void sub_80C9B74(void); -static void sub_80C9BB0(void); -static bool8 sub_80C9CE8(void); -static void sub_80C9E1C(void); -static void sub_80C9E30(u8 taskId); -static void sub_80C9E4C(u8 taskId); -static void sub_80C9EF0(u8 taskId); -static void sub_80C9F38(u8 taskId); -static void sub_80C9FA0(u8 taskId); -static void sub_80C9FD4(void); -static void sub_80C9FE8(u8 taskId); -static void sub_80CA004(u8 taskId); -static void sub_80CA0A4(u8 taskId); -static void sub_80CA108(u8 taskId); -static void sub_80CA160(u8 mapsecId); -static void sub_80CA190(u8 taskId); +static void FieldCallback_Flash(void); +static void FldEff_UseFlash(void); +static bool8 TryDoMapTransition(void); +static void FlashTransition_Exit(void); +static void Task_FlashTransition_Exit_0(u8 taskId); +static void Task_FlashTransition_Exit_1(u8 taskId); +static void Task_FlashTransition_Exit_2(u8 taskId); +static void Task_FlashTransition_Exit_3(u8 taskId); +static void Task_FlashTransition_Exit_4(u8 taskId); +static void FlashTransition_Enter(void); +static void Task_FlashTransition_Enter_0(u8 taskId); +static void Task_FlashTransition_Enter_1(u8 taskId); +static void Task_FlashTransition_Enter_2(u8 taskId); +static void Task_FlashTransition_Enter_3(u8 taskId); +static void RunMapPreviewScreen(u8 mapsecId); +static void Task_MapPreviewScreen_0(u8 taskId); -static const struct FlashStruct gUnknown_83F5738[] = { +static const struct FlashStruct sTransitionTypes[] = { { - .fromType = 1, - .toType = 4, + .fromType = MAP_TYPE_TOWN, + .toType = MAP_TYPE_UNDERGROUND, .isEnter = TRUE, .isExit = FALSE, - .func1 = sub_80C9FD4, - .func2 = sub_80CA160 + .func1 = FlashTransition_Enter, + .func2 = RunMapPreviewScreen }, { - .fromType = 2, - .toType = 4, + .fromType = MAP_TYPE_CITY, + .toType = MAP_TYPE_UNDERGROUND, .isEnter = TRUE, .isExit = FALSE, - .func1 = sub_80C9FD4, - .func2 = sub_80CA160 + .func1 = FlashTransition_Enter, + .func2 = RunMapPreviewScreen }, { - .fromType = 3, - .toType = 4, + .fromType = MAP_TYPE_ROUTE, + .toType = MAP_TYPE_UNDERGROUND, .isEnter = TRUE, .isExit = FALSE, - .func1 = sub_80C9FD4, - .func2 = sub_80CA160 + .func1 = FlashTransition_Enter, + .func2 = RunMapPreviewScreen }, { - .fromType = 5, - .toType = 4, + .fromType = MAP_TYPE_UNDERWATER, + .toType = MAP_TYPE_UNDERGROUND, .isEnter = TRUE, .isExit = FALSE, - .func1 = sub_80C9FD4, - .func2 = sub_80CA160 + .func1 = FlashTransition_Enter, + .func2 = RunMapPreviewScreen }, { - .fromType = 6, - .toType = 4, + .fromType = MAP_TYPE_OCEAN_ROUTE, + .toType = MAP_TYPE_UNDERGROUND, .isEnter = TRUE, .isExit = FALSE, - .func1 = sub_80C9FD4, - .func2 = sub_80CA160 + .func1 = FlashTransition_Enter, + .func2 = RunMapPreviewScreen }, { - .fromType = 7, - .toType = 4, + .fromType = MAP_TYPE_UNKNOWN, + .toType = MAP_TYPE_UNDERGROUND, .isEnter = TRUE, .isExit = FALSE, - .func1 = sub_80C9FD4, - .func2 = sub_80CA160 + .func1 = FlashTransition_Enter, + .func2 = RunMapPreviewScreen }, { - .fromType = 8, - .toType = 4, + .fromType = MAP_TYPE_INDOOR, + .toType = MAP_TYPE_UNDERGROUND, .isEnter = TRUE, .isExit = FALSE, - .func1 = sub_80C9FD4, - .func2 = sub_80CA160 + .func1 = FlashTransition_Enter, + .func2 = RunMapPreviewScreen }, { - .fromType = 9, - .toType = 4, + .fromType = MAP_TYPE_SECRET_BASE, + .toType = MAP_TYPE_UNDERGROUND, .isEnter = TRUE, .isExit = FALSE, - .func1 = sub_80C9FD4, - .func2 = sub_80CA160 + .func1 = FlashTransition_Enter, + .func2 = RunMapPreviewScreen }, { - .fromType = 4, - .toType = 1, + .fromType = MAP_TYPE_UNDERGROUND, + .toType = MAP_TYPE_TOWN, .isEnter = FALSE, .isExit = TRUE, - .func1 = sub_80C9E1C, - .func2 = sub_80CA160 + .func1 = FlashTransition_Exit, + .func2 = RunMapPreviewScreen }, { - .fromType = 4, - .toType = 2, + .fromType = MAP_TYPE_UNDERGROUND, + .toType = MAP_TYPE_CITY, .isEnter = FALSE, .isExit = TRUE, - .func1 = sub_80C9E1C, - .func2 = sub_80CA160 + .func1 = FlashTransition_Exit, + .func2 = RunMapPreviewScreen }, { - .fromType = 4, - .toType = 3, + .fromType = MAP_TYPE_UNDERGROUND, + .toType = MAP_TYPE_ROUTE, .isEnter = FALSE, .isExit = TRUE, - .func1 = sub_80C9E1C, - .func2 = sub_80CA160 + .func1 = FlashTransition_Exit, + .func2 = RunMapPreviewScreen }, { - .fromType = 4, - .toType = 5, + .fromType = MAP_TYPE_UNDERGROUND, + .toType = MAP_TYPE_UNDERWATER, .isEnter = FALSE, .isExit = TRUE, - .func1 = sub_80C9E1C, - .func2 = sub_80CA160 + .func1 = FlashTransition_Exit, + .func2 = RunMapPreviewScreen }, { - .fromType = 4, - .toType = 6, + .fromType = MAP_TYPE_UNDERGROUND, + .toType = MAP_TYPE_OCEAN_ROUTE, .isEnter = FALSE, .isExit = TRUE, - .func1 = sub_80C9E1C, - .func2 = sub_80CA160 + .func1 = FlashTransition_Exit, + .func2 = RunMapPreviewScreen }, { - .fromType = 4, - .toType = 7, + .fromType = MAP_TYPE_UNDERGROUND, + .toType = MAP_TYPE_UNKNOWN, .isEnter = FALSE, .isExit = TRUE, - .func1 = sub_80C9E1C, - .func2 = sub_80CA160 + .func1 = FlashTransition_Exit, + .func2 = RunMapPreviewScreen }, { - .fromType = 4, - .toType = 8, + .fromType = MAP_TYPE_UNDERGROUND, + .toType = MAP_TYPE_INDOOR, .isEnter = FALSE, .isExit = TRUE, - .func1 = sub_80C9E1C, - .func2 = sub_80CA160 + .func1 = FlashTransition_Exit, + .func2 = RunMapPreviewScreen }, { - .fromType = 4, - .toType = 9, + .fromType = MAP_TYPE_UNDERGROUND, + .toType = MAP_TYPE_SECRET_BASE, .isEnter = FALSE, .isExit = TRUE, - .func1 = sub_80C9E1C, - .func2 = sub_80CA160 + .func1 = FlashTransition_Exit, + .func2 = RunMapPreviewScreen }, {0} }; @@ -168,26 +169,28 @@ bool8 SetUpFieldMove_Flash(void) return FALSE; gFieldCallback2 = FieldCallback_PrepareFadeInFromMenu; - gPostMenuFieldCallback = sub_80C9B74; + gPostMenuFieldCallback = FieldCallback_Flash; return TRUE; } -static void sub_80C9B74(void) +static void FieldCallback_Flash(void) { u8 taskId = CreateFieldEffectShowMon(); gFieldEffectArguments[0] = GetCursorSelectionMonId(); - gTasks[taskId].data[8] = ((uintptr_t)sub_80C9BB0) >> 16; - gTasks[taskId].data[9] = ((uintptr_t)sub_80C9BB0); + gTasks[taskId].data[8] = ((uintptr_t)FldEff_UseFlash) >> 16; + gTasks[taskId].data[9] = ((uintptr_t)FldEff_UseFlash); } -static void sub_80C9BB0(void) +static void FldEff_UseFlash(void) { PlaySE(SE_W115); FlagSet(FLAG_SYS_FLASH_ACTIVE); ScriptContext1_SetupScript(EventScript_FldEffFlash); } -static void sub_80C9BD0(void) +// Map transition animatics + +static void CB2_ChangeMapMain(void) { RunTasks(); AnimateSprites(); @@ -195,14 +198,14 @@ static void sub_80C9BD0(void) UpdatePaletteFade(); } -static void sub_80C9BE8(void) +static void VBC_ChangeMapVBlank(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -void sub_80C9BFC(void) +void CB2_DoChangeMap(void) { SetVBlankCallback(NULL); @@ -224,74 +227,74 @@ void sub_80C9BFC(void) ResetTasks(); ResetSpriteData(); EnableInterrupts(INTR_FLAG_VBLANK); - SetVBlankCallback(sub_80C9BE8); - SetMainCallback2(sub_80C9BD0); - if (!sub_80C9CE8()) + SetVBlankCallback(VBC_ChangeMapVBlank); + SetMainCallback2(CB2_ChangeMapMain); + if (!TryDoMapTransition()) SetMainCallback2(gMain.savedCallback); } -static bool8 sub_80C9CE8(void) +static bool8 TryDoMapTransition(void) { - u8 fromType = get_map_light_from_warp0(); + u8 fromType = GetLastUsedWarpMapType(); u8 toType = GetCurrentMapType(); u8 i = 0; - if (sub_80561B4() != gMapHeader.regionMapSectionId && sub_80F8154(gMapHeader.regionMapSectionId, FALSE) == TRUE) + if (GetLastUsedWarpMapSectionId() != gMapHeader.regionMapSectionId && MapHasPreviewScreen_HandleQLState2(gMapHeader.regionMapSectionId, FALSE) == TRUE) { - sub_80CA160(gMapHeader.regionMapSectionId); + RunMapPreviewScreen(gMapHeader.regionMapSectionId); return TRUE; } - for (; gUnknown_83F5738[i].fromType != 0; i++) + for (; sTransitionTypes[i].fromType != 0; i++) { - if (gUnknown_83F5738[i].fromType == fromType && gUnknown_83F5738[i].toType == toType) + if (sTransitionTypes[i].fromType == fromType && sTransitionTypes[i].toType == toType) { - gUnknown_83F5738[i].func1(); + sTransitionTypes[i].func1(); return TRUE; } } return FALSE; } -bool8 sub_80C9D7C(u8 _fromType, u8 _toType) +bool8 MapTransitionIsEnter(u8 _fromType, u8 _toType) { u8 fromType = _fromType; u8 toType = _toType; u8 i = 0; - for (; gUnknown_83F5738[i].fromType != 0; i++) + for (; sTransitionTypes[i].fromType != 0; i++) { - if (gUnknown_83F5738[i].fromType == fromType && gUnknown_83F5738[i].toType == toType) + if (sTransitionTypes[i].fromType == fromType && sTransitionTypes[i].toType == toType) { - return gUnknown_83F5738[i].isEnter; + return sTransitionTypes[i].isEnter; } } return FALSE; } -bool8 sub_80C9DCC(u8 _fromType, u8 _toType) +bool8 MapTransitionIsExit(u8 _fromType, u8 _toType) { u8 fromType = _fromType; u8 toType = _toType; u8 i = 0; - for (; gUnknown_83F5738[i].fromType != 0; i++) + for (; sTransitionTypes[i].fromType != 0; i++) { - if (gUnknown_83F5738[i].fromType == fromType && gUnknown_83F5738[i].toType == toType) + if (sTransitionTypes[i].fromType == fromType && sTransitionTypes[i].toType == toType) { - return gUnknown_83F5738[i].isExit; + return sTransitionTypes[i].isExit; } } return FALSE; } -static void sub_80C9E1C(void) +static void FlashTransition_Exit(void) { - CreateTask(sub_80C9E30, 0); + CreateTask(Task_FlashTransition_Exit_0, 0); } -static void sub_80C9E30(u8 taskId) +static void Task_FlashTransition_Exit_0(u8 taskId) { - gTasks[taskId].func = sub_80C9E4C; + gTasks[taskId].func = Task_FlashTransition_Exit_1; } -static void sub_80C9E4C(u8 taskId) +static void Task_FlashTransition_Exit_1(u8 taskId) { SetGpuReg(REG_OFFSET_DISPCNT, 0); LZ77UnCompVram(gUnknown_83F5A44, (void *)BG_CHAR_ADDR(3)); @@ -303,12 +306,12 @@ static void sub_80C9E4C(u8 taskId) SetGpuReg(REG_OFFSET_BLDY, 0); SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(3) | BGCNT_SCREENBASE(31)); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_OBJ_ON); - gTasks[taskId].func = sub_80C9EF0; + gTasks[taskId].func = Task_FlashTransition_Exit_2; gTasks[taskId].data[0] = 16; gTasks[taskId].data[1] = 0; } -static void sub_80C9EF0(u8 taskId) +static void Task_FlashTransition_Exit_2(u8 taskId) { u16 r4 = gTasks[taskId].data[1]; SetGpuReg(REG_OFFSET_BLDALPHA, (16 << 8) + r4); @@ -319,11 +322,11 @@ static void sub_80C9EF0(u8 taskId) else { gTasks[taskId].data[2] = 0; - gTasks[taskId].func = sub_80C9F38; + gTasks[taskId].func = Task_FlashTransition_Exit_3; } } -static void sub_80C9F38(u8 taskId) +static void Task_FlashTransition_Exit_3(u8 taskId) { u16 r4; SetGpuReg(REG_OFFSET_BLDALPHA, (16 << 8) + 16); @@ -336,12 +339,12 @@ static void sub_80C9F38(u8 taskId) else { LoadPalette(gUnknown_83F5804, 0x00, 0x20); - gTasks[taskId].func = sub_80C9FA0; + gTasks[taskId].func = Task_FlashTransition_Exit_4; gTasks[taskId].data[2] = 8; } } -static void sub_80C9FA0(u8 taskId) +static void Task_FlashTransition_Exit_4(u8 taskId) { if (gTasks[taskId].data[2] != 0) gTasks[taskId].data[2]--; @@ -349,17 +352,17 @@ static void sub_80C9FA0(u8 taskId) SetMainCallback2(gMain.savedCallback); } -static void sub_80C9FD4(void) +static void FlashTransition_Enter(void) { - CreateTask(sub_80C9FE8, 0); + CreateTask(Task_FlashTransition_Enter_0, 0); } -static void sub_80C9FE8(u8 taskId) +static void Task_FlashTransition_Enter_0(u8 taskId) { - gTasks[taskId].func = sub_80CA004; + gTasks[taskId].func = Task_FlashTransition_Enter_1; } -static void sub_80CA004(u8 taskId) +static void Task_FlashTransition_Enter_1(u8 taskId) { SetGpuReg(REG_OFFSET_DISPCNT, 0); LZ77UnCompVram(gUnknown_83F5A44, (void *)BG_CHAR_ADDR(3)); @@ -371,13 +374,13 @@ static void sub_80CA004(u8 taskId) SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_OBJ_ON); LoadPalette(gUnknown_83F5804, 0xE0, 0x20); LoadPalette(gUnknown_83F5824, 0, 0x20); - gTasks[taskId].func = sub_80CA0A4; + gTasks[taskId].func = Task_FlashTransition_Enter_2; gTasks[taskId].data[0] = 16; gTasks[taskId].data[1] = 0; gTasks[taskId].data[2] = 0; } -static void sub_80CA0A4(u8 taskId) +static void Task_FlashTransition_Enter_2(u8 taskId) { u16 r4; r4 = gTasks[taskId].data[2]; @@ -391,11 +394,11 @@ static void sub_80CA0A4(u8 taskId) { SetGpuReg(REG_OFFSET_BLDALPHA, (16 << 8) + 16); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD); - gTasks[taskId].func = sub_80CA108; + gTasks[taskId].func = Task_FlashTransition_Enter_3; } } -static void sub_80CA108(u8 taskId) +static void Task_FlashTransition_Enter_3(u8 taskId) { u16 r4 = 16 - gTasks[taskId].data[1]; SetGpuReg(REG_OFFSET_BLDALPHA, (16 << 8) + r4); @@ -410,13 +413,13 @@ static void sub_80CA108(u8 taskId) } } -static void sub_80CA160(u8 mapSecId) +static void RunMapPreviewScreen(u8 mapSecId) { - u8 taskId = CreateTask(sub_80CA190, 0); + u8 taskId = CreateTask(Task_MapPreviewScreen_0, 0); gTasks[taskId].data[3] = mapSecId; } -static void sub_80CA190(u8 taskId) +static void Task_MapPreviewScreen_0(u8 taskId) { s16 *data = gTasks[taskId].data; switch (data[0]) @@ -424,15 +427,15 @@ static void sub_80CA190(u8 taskId) case 0: SetWordTaskArg(taskId, 5, (uintptr_t)gMain.vblankCallback); SetVBlankCallback(NULL); - sub_80F8180(); - sub_80F819C(data[3]); + MapPreview_InitBgs(); + MapPreview_LoadGfx(data[3]); BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK); data[0]++; break; case 1: - if (!sub_80F8258()) + if (!MapPreview_IsGfxLoadFinished()) { - data[4] = sub_80F8318(data[3]); + data[4] = MapPreview_CreateMapNameWindow(data[3]); CopyWindowToVram(data[4], 3); data[0]++; } @@ -448,7 +451,7 @@ static void sub_80CA190(u8 taskId) case 3: if (!UpdatePaletteFade()) { - data[2] = sub_80F856C(data[3]); + data[2] = MapPreview_GetDuration(data[3]); data[0]++; } break; @@ -468,8 +471,8 @@ static void sub_80CA190(u8 taskId) { data[i] = 0; } - sub_80F8234(data[4]); - gTasks[taskId].func = sub_80CA004; + MapPreview_Unload(data[4]); + gTasks[taskId].func = Task_FlashTransition_Enter_1; } break; } -- cgit v1.2.3 From 926b7c975de9be4937c332eaedcdc928255a0c9a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 8 Mar 2020 20:03:12 -0400 Subject: Name fldeff_flash gfx --- src/fldeff_flash.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/fldeff_flash.c') diff --git a/src/fldeff_flash.c b/src/fldeff_flash.c index f6bfd6e62..2cd7445d1 100644 --- a/src/fldeff_flash.c +++ b/src/fldeff_flash.c @@ -154,11 +154,11 @@ static const struct FlashStruct sTransitionTypes[] = { }, {0} }; -static const u16 gUnknown_83F5804[] = INCBIN_U16("graphics/field_effects/flash_white.gbapal"); -static const u16 gUnknown_83F5824[] = INCBIN_U16("graphics/field_effects/flash_black.gbapal"); -static const u16 gUnknown_83F5844[] = INCBIN_U16("graphics/field_effects/flash_gradient.gbapal"); -static const u32 gUnknown_83F5864[] = INCBIN_U32("graphics/field_effects/flash_effect_map.bin.lz"); -static const u32 gUnknown_83F5A44[] = INCBIN_U32("graphics/field_effects/flash_effect_tiles.4bpp.lz"); +static const u16 sCaveTransitionPalette_White[] = INCBIN_U16("graphics/field_effects/flash_white.gbapal"); +static const u16 sCaveTransitionPalette_Black[] = INCBIN_U16("graphics/field_effects/flash_black.gbapal"); +static const u16 sCaveTransitionPalette_Gradient[] = INCBIN_U16("graphics/field_effects/flash_gradient.gbapal"); +static const u32 sCaveTransitionTilemap[] = INCBIN_U32("graphics/field_effects/flash_effect_map.bin.lz"); +static const u32 sCaveTransitionTiles[] = INCBIN_U32("graphics/field_effects/flash_effect_tiles.4bpp.lz"); bool8 SetUpFieldMove_Flash(void) { @@ -297,10 +297,10 @@ static void Task_FlashTransition_Exit_0(u8 taskId) static void Task_FlashTransition_Exit_1(u8 taskId) { SetGpuReg(REG_OFFSET_DISPCNT, 0); - LZ77UnCompVram(gUnknown_83F5A44, (void *)BG_CHAR_ADDR(3)); - LZ77UnCompVram(gUnknown_83F5864, (void *)BG_SCREEN_ADDR(31)); - LoadPalette(gUnknown_83F5804, 0xE0, 0x20); - LoadPalette(gUnknown_83F5844 + 8, 0xE0, 0x10); + LZ77UnCompVram(sCaveTransitionTiles, (void *)BG_CHAR_ADDR(3)); + LZ77UnCompVram(sCaveTransitionTilemap, (void *)BG_SCREEN_ADDR(31)); + LoadPalette(sCaveTransitionPalette_White, 0xE0, 0x20); + LoadPalette(sCaveTransitionPalette_Gradient + 8, 0xE0, 0x10); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD); SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDY, 0); @@ -334,11 +334,11 @@ static void Task_FlashTransition_Exit_3(u8 taskId) if (r4 < 8) { gTasks[taskId].data[2]++; - LoadPalette(gUnknown_83F5844 + 8 + r4, 0xE0, 0x10 - 2 * r4); + LoadPalette(sCaveTransitionPalette_Gradient + 8 + r4, 0xE0, 0x10 - 2 * r4); } else { - LoadPalette(gUnknown_83F5804, 0x00, 0x20); + LoadPalette(sCaveTransitionPalette_White, 0x00, 0x20); gTasks[taskId].func = Task_FlashTransition_Exit_4; gTasks[taskId].data[2] = 8; } @@ -365,15 +365,15 @@ static void Task_FlashTransition_Enter_0(u8 taskId) static void Task_FlashTransition_Enter_1(u8 taskId) { SetGpuReg(REG_OFFSET_DISPCNT, 0); - LZ77UnCompVram(gUnknown_83F5A44, (void *)BG_CHAR_ADDR(3)); - LZ77UnCompVram(gUnknown_83F5864, (void *)BG_SCREEN_ADDR(31)); + LZ77UnCompVram(sCaveTransitionTiles, (void *)BG_CHAR_ADDR(3)); + LZ77UnCompVram(sCaveTransitionTilemap, (void *)BG_SCREEN_ADDR(31)); SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDY, 0); SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(3) | BGCNT_SCREENBASE(31)); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_OBJ_ON); - LoadPalette(gUnknown_83F5804, 0xE0, 0x20); - LoadPalette(gUnknown_83F5824, 0, 0x20); + LoadPalette(sCaveTransitionPalette_White, 0xE0, 0x20); + LoadPalette(sCaveTransitionPalette_Black, 0, 0x20); gTasks[taskId].func = Task_FlashTransition_Enter_2; gTasks[taskId].data[0] = 16; gTasks[taskId].data[1] = 0; @@ -388,7 +388,7 @@ static void Task_FlashTransition_Enter_2(u8 taskId) { gTasks[taskId].data[2]++; gTasks[taskId].data[2]++; - LoadPalette(&gUnknown_83F5844[16 - (r4 + 1)], 0xE0, 2 * (r4 + 1)); + LoadPalette(&sCaveTransitionPalette_Gradient[16 - (r4 + 1)], 0xE0, 2 * (r4 + 1)); } else { @@ -408,7 +408,7 @@ static void Task_FlashTransition_Enter_3(u8 taskId) } else { - LoadPalette(gUnknown_83F5824, 0x00, 0x20); + LoadPalette(sCaveTransitionPalette_Black, 0x00, 0x20); SetMainCallback2(gMain.savedCallback); } } -- cgit v1.2.3 From 8955f1fa5fd8ead93efb18bb91f066a6ee1aacbf Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 9 Mar 2020 09:32:17 -0400 Subject: Use MPS_TYPE_ defines in field_fadetransition and fldeff_flash --- src/fldeff_flash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fldeff_flash.c') diff --git a/src/fldeff_flash.c b/src/fldeff_flash.c index 2cd7445d1..58cb4c251 100644 --- a/src/fldeff_flash.c +++ b/src/fldeff_flash.c @@ -238,7 +238,7 @@ static bool8 TryDoMapTransition(void) u8 fromType = GetLastUsedWarpMapType(); u8 toType = GetCurrentMapType(); u8 i = 0; - if (GetLastUsedWarpMapSectionId() != gMapHeader.regionMapSectionId && MapHasPreviewScreen_HandleQLState2(gMapHeader.regionMapSectionId, FALSE) == TRUE) + if (GetLastUsedWarpMapSectionId() != gMapHeader.regionMapSectionId && MapHasPreviewScreen_HandleQLState2(gMapHeader.regionMapSectionId, MPS_TYPE_CAVE) == TRUE) { RunMapPreviewScreen(gMapHeader.regionMapSectionId); return TRUE; -- cgit v1.2.3