diff options
-rw-r--r-- | asm/overworld.s | 30 | ||||
-rw-r--r-- | include/fldeff.h | 4 | ||||
-rw-r--r-- | include/map_preview_screen.h | 22 | ||||
-rw-r--r-- | include/overworld.h | 4 | ||||
-rw-r--r-- | include/quest_log.h | 2 | ||||
-rw-r--r-- | src/field_fadetransition.c | 14 | ||||
-rw-r--r-- | src/fldeff_flash.c | 277 | ||||
-rw-r--r-- | src/map_preview_screen.c | 140 | ||||
-rw-r--r-- | src/quest_log.c | 2 | ||||
-rw-r--r-- | src/scrcmd.c | 4 |
10 files changed, 251 insertions, 248 deletions
diff --git a/asm/overworld.s b/asm/overworld.s index 571d305b4..14afde17a 100644 --- a/asm/overworld.s +++ b/asm/overworld.s @@ -1739,7 +1739,7 @@ _080558D4: bl DoCurrentWeather bl ResetFieldTasksArgs bl mapheader_run_script_with_tag_x5 - bl sub_80561B4 + bl GetLastUsedWarpMapSectionId ldr r1, _0805591C @ =gMapHeader lsls r0, 24 lsrs r0, 24 @@ -2899,8 +2899,8 @@ GetCurrentMapType: @ 8056188 _0805619C: .4byte gSaveBlock1Ptr thumb_func_end GetCurrentMapType - thumb_func_start get_map_light_from_warp0 -get_map_light_from_warp0: @ 80561A0 + thumb_func_start GetLastUsedWarpMapType +GetLastUsedWarpMapType: @ 80561A0 push {lr} ldr r0, _080561B0 @ =gUnknown_2031DB4 bl get_map_light_level_from_warp @@ -2910,10 +2910,10 @@ get_map_light_from_warp0: @ 80561A0 bx r1 .align 2, 0 _080561B0: .4byte gUnknown_2031DB4 - thumb_func_end get_map_light_from_warp0 + thumb_func_end GetLastUsedWarpMapType - thumb_func_start sub_80561B4 -sub_80561B4: @ 80561B4 + thumb_func_start GetLastUsedWarpMapSectionId +GetLastUsedWarpMapSectionId: @ 80561B4 push {lr} ldr r1, _080561D4 @ =gUnknown_2031DB4 movs r0, 0 @@ -2931,7 +2931,7 @@ sub_80561B4: @ 80561B4 bx r1 .align 2, 0 _080561D4: .4byte gUnknown_2031DB4 - thumb_func_end sub_80561B4 + thumb_func_end GetLastUsedWarpMapSectionId thumb_func_start IsMapTypeOutdoors IsMapTypeOutdoors: @ 80561D8 @@ -3579,7 +3579,7 @@ CB2_LoadMap: @ 805671C bl ScriptContext2_Disable movs r0, 0 bl SetMainCallback1 - ldr r0, _08056740 @ =sub_80C9BFC + ldr r0, _08056740 @ =CB2_DoChangeMap bl SetMainCallback2 ldr r1, _08056744 @ =gMain ldr r0, _08056748 @ =sub_805674C @@ -3587,7 +3587,7 @@ CB2_LoadMap: @ 805671C pop {r0} bx r0 .align 2, 0 -_08056740: .4byte sub_80C9BFC +_08056740: .4byte CB2_DoChangeMap _08056744: .4byte gMain _08056748: .4byte sub_805674C thumb_func_end CB2_LoadMap @@ -4196,7 +4196,7 @@ _08056C72: bl InitTilesetAnimations b _08056CCA _08056C78: - bl sub_80561B4 + bl GetLastUsedWarpMapSectionId ldr r5, _08056CA4 @ =gMapHeader lsls r0, 24 lsrs r0, 24 @@ -4205,13 +4205,13 @@ _08056C78: beq _08056CA8 ldrb r0, [r5, 0x14] movs r1, 0x1 - bl sub_80F8154 + bl MapHasPreviewScreen_HandleQLState2 cmp r0, 0x1 bne _08056CA8 ldrb r0, [r5, 0x14] - bl sub_80F819C + bl MapPreview_LoadGfx ldrb r0, [r5, 0x14] - bl sub_80F8268 + bl MapPreview_StartForestTransition b _08056CCA .align 2, 0 _08056CA4: .4byte gMapHeader @@ -4922,7 +4922,7 @@ sub_805726C: @ 805726C bl ScriptContext2_Disable movs r0, 0 bl SetMainCallback1 - ldr r0, _0805729C @ =sub_80C9BFC + ldr r0, _0805729C @ =CB2_DoChangeMap bl SetMainCallback2 ldr r1, _080572A0 @ =gMain ldr r0, _080572A4 @ =sub_80572D8 @@ -4931,7 +4931,7 @@ sub_805726C: @ 805726C bx r0 .align 2, 0 _08057298: .4byte gUnknown_2036E28 -_0805729C: .4byte sub_80C9BFC +_0805729C: .4byte CB2_DoChangeMap _080572A0: .4byte gMain _080572A4: .4byte sub_80572D8 thumb_func_end sub_805726C diff --git a/include/fldeff.h b/include/fldeff.h index 00f2d01f4..9dd6121b2 100644 --- a/include/fldeff.h +++ b/include/fldeff.h @@ -13,8 +13,8 @@ bool8 CheckObjectGraphicsInFrontOfPlayer(u8 graphicsId); u8 CreateFieldEffectShowMon(void); // flash -u8 sub_80C9DCC(u8 lightLevel, u8 mapType); -u8 sub_80C9D7C(u8 mapType1, u8 mapType2); +u8 MapTransitionIsExit(u8 lightLevel, u8 mapType); +u8 MapTransitionIsEnter(u8 mapType1, u8 mapType2); bool8 SetUpFieldMove_Flash(void); // cut diff --git a/include/map_preview_screen.h b/include/map_preview_screen.h index 195e86929..b884403ca 100644 --- a/include/map_preview_screen.h +++ b/include/map_preview_screen.h @@ -37,23 +37,23 @@ enum MapPreviewScreenId struct MapPreviewScreen { u8 mapsec; - bool8 forceFirstTime; + bool8 type; u16 flagId; const void * tilesptr; const void * tilemapptr; const void * palptr; }; -u16 sub_80F8318(u8 id); -void sub_80F85BC(u16 a0); -u16 sub_80F856C(u8 id); -bool8 sub_80F8110(u8 mapsec, bool8 forceFirstTime); -bool32 sub_80F83B0(void); +u16 MapPreview_CreateMapNameWindow(u8 id); +void MapPreview_SetFlag(u16 a0); +u16 MapPreview_GetDuration(u8 id); +bool8 MapHasPreviewScreen(u8 mapsec, bool8 type); +bool32 ForestMapPreviewScreenIsRunning(void); const struct MapPreviewScreen * GetDungeonMapPreviewScreenInfo(u8 mapsec); -bool32 sub_80F8154(u8 mapsec, u8 forceFirstTime); -void sub_80F8180(void); -void sub_80F819C(u8 mapsec); -bool32 sub_80F8258(void); -void sub_80F8234(s32 windowId); +bool32 MapHasPreviewScreen_HandleQLState2(u8 mapsec, u8 type); +void MapPreview_InitBgs(void); +void MapPreview_LoadGfx(u8 mapsec); +bool32 MapPreview_IsGfxLoadFinished(void); +void MapPreview_Unload(s32 windowId); #endif //GUARD_MAP_PREVIEW_SCREEN_H diff --git a/include/overworld.h b/include/overworld.h index 06d4bcb8e..02492f74b 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -157,7 +157,7 @@ void Overworld_ResetStateAfterDigEscRope(void); bool32 sub_8058244(void); u8 GetCurrentMapType(void); -u8 get_map_light_from_warp0(void); +u8 GetLastUsedWarpMapType(void); const struct MapHeader *warp1_get_mapheader(void); void TryFadeOutOldMapMusic(void); void CB2_ReturnToFieldCableClub(void); @@ -192,7 +192,7 @@ void sub_8057F48(void); void SetMainCallback1(MainCallback cb); void CB1_Overworld(void); void sub_80568C4(void); -u8 sub_80561B4(void); +u8 GetLastUsedWarpMapSectionId(void); extern u16 gHeldKeyCodeToSend; diff --git a/include/quest_log.h b/include/quest_log.h index 3241046bc..b2645954f 100644 --- a/include/quest_log.h +++ b/include/quest_log.h @@ -26,7 +26,7 @@ extern const u16 gUnknown_84566A8[]; void sub_8112720(u8); void SetQuestLogEvent(u16, const u16 *); void sub_811539C(void); -void sub_8115748(u16); +void QuestLog_RecordEnteredMap(u16); u8 sub_8112CAC(void); bool8 QuestLog_SchedulePlaybackCB(void (*func)(void)); void sub_8111F38(u16 offset, u16 idx); diff --git a/src/field_fadetransition.c b/src/field_fadetransition.c index 4ff105056..eeca2e171 100644 --- a/src/field_fadetransition.c +++ b/src/field_fadetransition.c @@ -52,7 +52,7 @@ void palette_bg_faded_fill_black(void) void WarpFadeInScreen(void) { - switch (sub_80C9DCC(get_map_light_from_warp0(), GetCurrentMapType())) + switch (MapTransitionIsExit(GetLastUsedWarpMapType(), GetCurrentMapType())) { case 0: palette_bg_faded_fill_black(); @@ -69,7 +69,7 @@ void WarpFadeInScreen(void) static void sub_807DBAC(void) { - switch (sub_80C9DCC(get_map_light_from_warp0(), GetCurrentMapType())) + switch (MapTransitionIsExit(GetLastUsedWarpMapType(), GetCurrentMapType())) { case 0: palette_bg_faded_fill_black(); @@ -94,11 +94,11 @@ void FadeInFromBlack(void) void WarpFadeOutScreen(void) { const struct MapHeader *header = warp1_get_mapheader(); - if (header->regionMapSectionId != gMapHeader.regionMapSectionId && sub_80F8110(header->regionMapSectionId, FALSE)) + if (header->regionMapSectionId != gMapHeader.regionMapSectionId && MapHasPreviewScreen(header->regionMapSectionId, FALSE)) FadeScreen(1, 0); else { - switch (sub_80C9D7C(GetCurrentMapType(), header->mapType)) + switch (MapTransitionIsEnter(GetCurrentMapType(), header->mapType)) { case 0: FadeScreen(1, 0); @@ -112,7 +112,7 @@ void WarpFadeOutScreen(void) static void sub_807DC70(void) { - switch (sub_80C9D7C(GetCurrentMapType(), warp1_get_mapheader()->mapType)) + switch (MapTransitionIsEnter(GetCurrentMapType(), warp1_get_mapheader()->mapType)) { case 0: FadeScreen(1, 3); @@ -246,7 +246,7 @@ static void sub_807DE78(bool8 a0) if (MetatileBehavior_IsWarpDoor_2(behavior) == TRUE) { func = sub_807DFBC; - switch (sub_80C9DCC(get_map_light_from_warp0(), GetCurrentMapType())) + switch (MapTransitionIsExit(GetLastUsedWarpMapType(), GetCurrentMapType())) { case 0: palette_bg_faded_fill_black(); @@ -521,7 +521,7 @@ static bool32 sub_807E40C(void) bool32 sub_807E418(void) { - if (IsWeatherNotFadingIn() == TRUE && sub_80F83B0()) + if (IsWeatherNotFadingIn() == TRUE && ForestMapPreviewScreenIsRunning()) return TRUE; else return FALSE; 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; } diff --git a/src/map_preview_screen.c b/src/map_preview_screen.c index a553ca122..3f45c7833 100644 --- a/src/map_preview_screen.c +++ b/src/map_preview_screen.c @@ -16,10 +16,10 @@ #include "map_preview_screen.h" #include "constants/region_map.h" -static EWRAM_DATA bool8 gUnknown_203ABEC = FALSE; -static EWRAM_DATA bool8 gUnknown_203ABED = FALSE; +static EWRAM_DATA bool8 sHasVisitedMapBefore = FALSE; +static EWRAM_DATA bool8 sAllocedBg0TilemapBuffer = FALSE; -static void sub_80F83D0(u8 taskId); +static void Task_RunMapPreviewScreenForest(u8 taskId); static const u8 gViridianForestMapPreviewPalette[] = INCBIN_U8("data/map_preview/viridian_forest_pal.gbapal"); static const u8 gViridianForestMapPreviewTiles[] = INCBIN_U8("data/map_preview/viridian_forest_tiles.4bpp.lz"); @@ -88,7 +88,7 @@ static const u8 gAlteringCaveMapPreviewTilemap[] = INCBIN_U8("data/map_preview/a static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { [MPS_VIRIDIAN_FOREST] = { .mapsec = MAPSEC_VIRIDIAN_FOREST, - .forceFirstTime = TRUE, + .type = TRUE, .flagId = FLAG_WORLD_MAP_VIRIDIAN_FOREST, .tilesptr = gViridianForestMapPreviewTiles, .tilemapptr = gViridianForestMapPreviewTilemap, @@ -96,7 +96,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_MT_MOON] = { .mapsec = MAPSEC_MT_MOON, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_MT_MOON_1F, .tilesptr = gMtMoonMapPreviewTiles, .tilemapptr = gMtMoonMapPreviewTilemap, @@ -104,7 +104,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_DIGLETTS_CAVE] = { .mapsec = MAPSEC_DIGLETTS_CAVE, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_DIGLETTS_CAVE_B1F, .tilesptr = gDiglettsCaveMapPreviewTiles, .tilemapptr = gDiglettsCaveMapPreviewTilemap, @@ -112,7 +112,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_ROCK_TUNNEL] = { .mapsec = MAPSEC_ROCK_TUNNEL, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_ROCK_TUNNEL_1F, .tilesptr = gRockTunnelMapPreviewTiles, .tilemapptr = gRockTunnelMapPreviewTilemap, @@ -120,7 +120,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_POKEMON_TOWER] = { .mapsec = MAPSEC_POKEMON_TOWER, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_POKEMON_TOWER_1F, .tilesptr = gPokemonTowerMapPreviewTiles, .tilemapptr = gPokemonTowerMapPreviewTilemap, @@ -128,7 +128,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_SAFARI_ZONE] = { .mapsec = MAPSEC_KANTO_SAFARI_ZONE, - .forceFirstTime = TRUE, + .type = TRUE, .flagId = FLAG_WORLD_MAP_SAFARI_ZONE_CENTER, .tilesptr = gKantoSafariZoneMapPreviewTiles, .tilemapptr = gKantoSafariZoneMapPreviewTilemap, @@ -136,7 +136,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_SEAFOAM_ISLANDS] = { .mapsec = MAPSEC_SEAFOAM_ISLANDS, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_SEAFOAM_ISLANDS_1F, .tilesptr = gSeafoamIslandsMapPreviewTiles, .tilemapptr = gSeafoamIslandsMapPreviewTilemap, @@ -144,7 +144,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_POKEMON_MANSION] = { .mapsec = MAPSEC_POKEMON_MANSION, - .forceFirstTime = TRUE, + .type = TRUE, .flagId = FLAG_WORLD_MAP_POKEMON_MANSION_1F, .tilesptr = gPokemonMansionMapPreviewTiles, .tilemapptr = gPokemonMansionMapPreviewTilemap, @@ -152,7 +152,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_ROCKET_HIDEOUT] = { .mapsec = MAPSEC_ROCKET_HIDEOUT, - .forceFirstTime = TRUE, + .type = TRUE, .flagId = FLAG_WORLD_MAP_ROCKET_HIDEOUT_B1F, .tilesptr = gRocketHideoutMapPreviewTiles, .tilemapptr = gRocketHideoutMapPreviewTilemap, @@ -160,7 +160,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_SILPH_CO] = { .mapsec = MAPSEC_SILPH_CO, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_SILPH_CO_1F, .tilesptr = gSilphCoMapPreviewTiles, .tilemapptr = gSilphCoMapPreviewTilemap, @@ -168,7 +168,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_VICTORY_ROAD] = { .mapsec = MAPSEC_KANTO_VICTORY_ROAD, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_VICTORY_ROAD_1F, .tilesptr = gKantoVictoryRoadMapPreviewTiles, .tilemapptr = gKantoVictoryRoadMapPreviewTilemap, @@ -176,7 +176,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_CERULEAN_CAVE] = { .mapsec = MAPSEC_CERULEAN_CAVE, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_CERULEAN_CAVE_1F, .tilesptr = gCeruleanCaveMapPreviewTiles, .tilemapptr = gCeruleanCaveMapPreviewTilemap, @@ -184,7 +184,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_POWER_PLANT] = { .mapsec = MAPSEC_POWER_PLANT, - .forceFirstTime = TRUE, + .type = TRUE, .flagId = FLAG_WORLD_MAP_POWER_PLANT, .tilesptr = gPowerPlantMapPreviewTiles, .tilemapptr = gPowerPlantMapPreviewTilemap, @@ -192,7 +192,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_MT_EMBER] = { .mapsec = MAPSEC_MT_EMBER, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_MT_EMBER_EXTERIOR, .tilesptr = gMtEmberMapPreviewTiles, .tilemapptr = gMtEmberMapPreviewTilemap, @@ -200,7 +200,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_ROCKET_WAREHOUSE] = { .mapsec = MAPSEC_ROCKET_WAREHOUSE, - .forceFirstTime = TRUE, + .type = TRUE, .flagId = FLAG_WORLD_MAP_THREE_ISLAND_BERRY_FOREST, .tilesptr = gRocketWarehouseMapPreviewTiles, .tilemapptr = gRocketWarehouseMapPreviewTilemap, @@ -208,7 +208,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_MONEAN_CHAMBER] = { .mapsec = MAPSEC_MONEAN_CHAMBER, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_SEVEN_ISLAND_TANOBY_RUINS_MONEAN_CHAMBER, .tilesptr = gMoneanChamberMapPreviewTiles, .tilemapptr = gMoneanChamberMapPreviewTilemap, @@ -216,7 +216,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_DOTTED_HOLE] = { .mapsec = MAPSEC_DOTTED_HOLE, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_SIX_ISLAND_DOTTED_HOLE_1F, .tilesptr = gDottedHoleMapPreviewTiles, .tilemapptr = gDottedHoleMapPreviewTilemap, @@ -224,7 +224,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_BERRY_FOREST] = { .mapsec = MAPSEC_BERRY_FOREST, - .forceFirstTime = TRUE, + .type = TRUE, .flagId = FLAG_WORLD_MAP_THREE_ISLAND_BERRY_FOREST, .tilesptr = gBerryForestMapPreviewTiles, .tilemapptr = gBerryForestMapPreviewTilemap, @@ -232,7 +232,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_ICEFALL_CAVE] = { .mapsec = MAPSEC_ICEFALL_CAVE, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_FOUR_ISLAND_ICEFALL_CAVE_ENTRANCE, .tilesptr = gIcefallCaveMapPreviewTiles, .tilemapptr = gIcefallCaveMapPreviewTilemap, @@ -240,7 +240,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_LOST_CAVE] = { .mapsec = MAPSEC_LOST_CAVE, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_FIVE_ISLAND_LOST_CAVE_ENTRANCE, .tilesptr = gLostCaveMapPreviewTiles, .tilemapptr = gLostCaveMapPreviewTilemap, @@ -248,7 +248,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_ALTERING_CAVE] = { .mapsec = MAPSEC_ALTERING_CAVE, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_SIX_ISLAND_ALTERING_CAVE, .tilesptr = gAlteringCaveMapPreviewTiles, .tilemapptr = gAlteringCaveMapPreviewTilemap, @@ -256,7 +256,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_PATTERN_BUSH] = { .mapsec = MAPSEC_PATTERN_BUSH, - .forceFirstTime = TRUE, + .type = TRUE, .flagId = FLAG_WORLD_MAP_SIX_ISLAND_PATTERN_BUSH, .tilesptr = gViridianForestMapPreviewTiles, .tilemapptr = gViridianForestMapPreviewTilemap, @@ -264,7 +264,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_LIPTOO_CHAMBER] = { .mapsec = MAPSEC_LIPTOO_CHAMBER, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_SEVEN_ISLAND_TANOBY_RUINS_MONEAN_CHAMBER, .tilesptr = gMoneanChamberMapPreviewTiles, .tilemapptr = gMoneanChamberMapPreviewTilemap, @@ -272,7 +272,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_WEEPTH_CHAMBER] = { .mapsec = MAPSEC_WEEPTH_CHAMBER, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_SEVEN_ISLAND_TANOBY_RUINS_MONEAN_CHAMBER, .tilesptr = gMoneanChamberMapPreviewTiles, .tilemapptr = gMoneanChamberMapPreviewTilemap, @@ -280,7 +280,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_TDILFORD_CHAMBER] = { .mapsec = MAPSEC_DILFORD_CHAMBER, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_SEVEN_ISLAND_TANOBY_RUINS_MONEAN_CHAMBER, .tilesptr = gMoneanChamberMapPreviewTiles, .tilemapptr = gMoneanChamberMapPreviewTilemap, @@ -288,7 +288,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_SCUFIB_CHAMBER] = { .mapsec = MAPSEC_SCUFIB_CHAMBER, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_SEVEN_ISLAND_TANOBY_RUINS_MONEAN_CHAMBER, .tilesptr = gMoneanChamberMapPreviewTiles, .tilemapptr = gMoneanChamberMapPreviewTilemap, @@ -296,7 +296,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_RIXY_CHAMBER] = { .mapsec = MAPSEC_RIXY_CHAMBER, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_SEVEN_ISLAND_TANOBY_RUINS_MONEAN_CHAMBER, .tilesptr = gMoneanChamberMapPreviewTiles, .tilemapptr = gMoneanChamberMapPreviewTilemap, @@ -304,7 +304,7 @@ static const struct MapPreviewScreen sMapPreviewScreenData[MPS_COUNT] = { }, [MPS_VIAPOIS_CHAMBER] = { .mapsec = MAPSEC_VIAPOIS_CHAMBER, - .forceFirstTime = FALSE, + .type = FALSE, .flagId = FLAG_WORLD_MAP_SEVEN_ISLAND_TANOBY_RUINS_MONEAN_CHAMBER, .tilesptr = gMoneanChamberMapPreviewTiles, .tilemapptr = gMoneanChamberMapPreviewTilemap, @@ -328,7 +328,7 @@ static const struct BgTemplate sMapPreviewBgTemplate[1] = { } }; -static u8 sub_80F80E4(u8 mapsec) +static u8 GetMapPreviewScreenIdx(u8 mapsec) { s32 i; @@ -342,20 +342,20 @@ static u8 sub_80F80E4(u8 mapsec) return MPS_COUNT; } -bool8 sub_80F8110(u8 mapsec, u8 forceFirstTime) +bool8 MapHasPreviewScreen(u8 mapsec, u8 type) { u8 idx; - idx = sub_80F80E4(mapsec); + idx = GetMapPreviewScreenIdx(mapsec); if (idx != MPS_COUNT) { - if (forceFirstTime == 2) + if (type == 2) { return TRUE; } else { - return sMapPreviewScreenData[idx].forceFirstTime == forceFirstTime ? TRUE : FALSE; + return sMapPreviewScreenData[idx].type == type ? TRUE : FALSE; } } else @@ -364,29 +364,29 @@ bool8 sub_80F8110(u8 mapsec, u8 forceFirstTime) } } -bool32 sub_80F8154(u8 mapsec, u8 forceFirstTime) +bool32 MapHasPreviewScreen_HandleQLState2(u8 mapsec, u8 type) { - if (gQuestLogState == 2) + if (gQuestLogState == QL_STATE_2) { return FALSE; } else { - return sub_80F8110(mapsec, forceFirstTime); + return MapHasPreviewScreen(mapsec, type); } } -void sub_80F8180(void) +void MapPreview_InitBgs(void) { InitBgsFromTemplates(0, sMapPreviewBgTemplate, NELEMS(sMapPreviewBgTemplate)); ShowBg(0); } -void sub_80F819C(u8 mapsec) +void MapPreview_LoadGfx(u8 mapsec) { u8 idx; - idx = sub_80F80E4(mapsec); + idx = GetMapPreviewScreenIdx(mapsec); if (idx != MPS_COUNT) { ResetTempTileDataBuffers(); @@ -395,55 +395,55 @@ void sub_80F819C(u8 mapsec) if (GetBgTilemapBuffer(0) == NULL) { SetBgTilemapBuffer(0, Alloc(BG_SCREEN_SIZE)); - gUnknown_203ABED = TRUE; + sAllocedBg0TilemapBuffer = TRUE; } else { - gUnknown_203ABED = FALSE; + sAllocedBg0TilemapBuffer = FALSE; } CopyToBgTilemapBuffer(0, sMapPreviewScreenData[idx].tilemapptr, 0, 0x000); CopyBgTilemapBufferToVram(0); } } -void sub_80F8234(s32 windowId) +void MapPreview_Unload(s32 windowId) { RemoveWindow(windowId); - if (gUnknown_203ABED) + if (sAllocedBg0TilemapBuffer) { Free(GetBgTilemapBuffer(0)); } } -bool32 sub_80F8258(void) +bool32 MapPreview_IsGfxLoadFinished(void) { return FreeTempTileDataBuffersIfPossible(); } -void sub_80F8268(u8 mapsec) +void MapPreview_StartForestTransition(u8 mapsec) { u8 taskId; - taskId = CreateTask(sub_80F83D0, 0); + taskId = CreateTask(Task_RunMapPreviewScreenForest, 0); gTasks[taskId].data[2] = GetBgAttribute(0, BG_ATTR_PRIORITY); gTasks[taskId].data[4] = GetGpuReg(REG_OFFSET_BLDCNT); gTasks[taskId].data[5] = GetGpuReg(REG_OFFSET_BLDALPHA); gTasks[taskId].data[3] = GetGpuReg(REG_OFFSET_DISPCNT); gTasks[taskId].data[6] = GetGpuReg(REG_OFFSET_WININ); gTasks[taskId].data[7] = GetGpuReg(REG_OFFSET_WINOUT); - gTasks[taskId].data[10] = sub_80F856C(mapsec); + gTasks[taskId].data[10] = MapPreview_GetDuration(mapsec); gTasks[taskId].data[8] = 16; gTasks[taskId].data[9] = 0; SetBgAttribute(0, BG_ATTR_PRIORITY, 0); 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, BLDALPHA_BLEND(16, 0)); - SetGpuRegBits(REG_OFFSET_WININ, 0x2020); - SetGpuRegBits(REG_OFFSET_WINOUT, 0x0020); - gTasks[taskId].data[11] = sub_80F8318(mapsec); + SetGpuRegBits(REG_OFFSET_WININ, WININ_WIN0_CLR | WININ_WIN1_CLR); + SetGpuRegBits(REG_OFFSET_WINOUT, WINOUT_WIN01_CLR); + gTasks[taskId].data[11] = MapPreview_CreateMapNameWindow(mapsec); ScriptContext2_Enable(); } -u16 sub_80F8318(u8 mapsec) +u16 MapPreview_CreateMapNameWindow(u8 mapsec) { u16 windowId; u32 xctr; @@ -452,18 +452,18 @@ u16 sub_80F8318(u8 mapsec) windowId = AddWindow(&sMapNameWindow); FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); PutWindowTilemap(windowId); - color[0] = 1; // Access violation - color[1] = 4; // Access violation - color[2] = 3; // Access violation + color[0] = TEXT_COLOR_WHITE; // Access violation + color[1] = TEXT_COLOR_RED; // Access violation + color[2] = TEXT_COLOR_LIGHT_GREY; // Access violation GetMapName(gStringVar4, mapsec, 0); xctr = 104 - GetStringWidth(2, gStringVar4, 0); AddTextPrinterParameterized4(windowId, 2, xctr / 2, 2, 0, 0, color/* Access violation */, -1, gStringVar4); return windowId; } -bool32 sub_80F83B0(void) +bool32 ForestMapPreviewScreenIsRunning(void) { - if (FuncIsActiveTask(sub_80F83D0) == TRUE) + if (FuncIsActiveTask(Task_RunMapPreviewScreenForest) == TRUE) { return FALSE; } @@ -473,7 +473,7 @@ bool32 sub_80F83B0(void) } } -static void sub_80F83D0(u8 taskId) +static void Task_RunMapPreviewScreenForest(u8 taskId) { s16 * data; @@ -481,7 +481,7 @@ static void sub_80F83D0(u8 taskId) switch (data[0]) { case 0: - if (!sub_80F8258() && !IsDma3ManagerBusyWithBgCopy()) + if (!MapPreview_IsGfxLoadFinished() && !IsDma3ManagerBusyWithBgCopy()) { CopyWindowToVram(data[11], 3); data[0]++; @@ -539,7 +539,7 @@ static void sub_80F83D0(u8 taskId) case 5: if (!IsDma3ManagerBusyWithBgCopy()) { - sub_80F8234(data[11]); + MapPreview_Unload(data[11]); SetBgAttribute(0, BG_ATTR_PRIORITY, data[2]); SetGpuReg(REG_OFFSET_DISPCNT, data[3]); SetGpuReg(REG_OFFSET_BLDCNT, data[4]); @@ -556,7 +556,7 @@ const struct MapPreviewScreen * GetDungeonMapPreviewScreenInfo(u8 mapsec) { u8 idx; - idx = sub_80F80E4(mapsec); + idx = GetMapPreviewScreenIdx(mapsec); if (idx == MPS_COUNT) { return NULL; @@ -567,18 +567,18 @@ const struct MapPreviewScreen * GetDungeonMapPreviewScreenInfo(u8 mapsec) } } -u16 sub_80F856C(u8 mapsec) +u16 MapPreview_GetDuration(u8 mapsec) { u8 idx; u16 flagId; - idx = sub_80F80E4(mapsec); + idx = GetMapPreviewScreenIdx(mapsec); if (idx == MPS_COUNT) { return 0; } flagId = sMapPreviewScreenData[idx].flagId; - if (!sMapPreviewScreenData[idx].forceFirstTime) + if (sMapPreviewScreenData[idx].type == 0) { if (!FlagGet(flagId)) { @@ -590,7 +590,7 @@ u16 sub_80F856C(u8 mapsec) } } else { - if (gUnknown_203ABEC) + if (sHasVisitedMapBefore) { return 120; } @@ -601,15 +601,15 @@ u16 sub_80F856C(u8 mapsec) } } -void sub_80F85BC(u16 flagId) +void MapPreview_SetFlag(u16 flagId) { if (!FlagGet(flagId)) { - gUnknown_203ABEC = TRUE; + sHasVisitedMapBefore = TRUE; } else { - gUnknown_203ABEC = FALSE; + sHasVisitedMapBefore = FALSE; } FlagSet(flagId); } diff --git a/src/quest_log.c b/src/quest_log.c index 5d260b58f..8f53f9c5e 100644 --- a/src/quest_log.c +++ b/src/quest_log.c @@ -4294,7 +4294,7 @@ static const u16 sQuestLogWorldMapFlags[] = FLAG_WORLD_MAP_SIX_ISLAND }; -void sub_8115748(u16 worldMapFlag) +void QuestLog_RecordEnteredMap(u16 worldMapFlag) { s32 i; diff --git a/src/scrcmd.c b/src/scrcmd.c index b4605e9d5..7eaa98c76 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -598,8 +598,8 @@ bool8 ScrCmd_comparestattoword(struct ScriptContext * ctx) bool8 ScrCmd_setworldmapflag(struct ScriptContext * ctx) { u16 value = ScriptReadHalfword(ctx); - sub_8115748(value); - sub_80F85BC(value); + QuestLog_RecordEnteredMap(value); + MapPreview_SetFlag(value); return FALSE; } |