From 0dc7ff89945d471a62659b3d9f21cb7f50f331eb Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 6 Apr 2021 17:17:41 -0400 Subject: [PATCH] Minor misc field doc --- .../map_popup/{857F444.pal => underwater.pal} | 0 include/field_camera.h | 7 +-- src/battle_transition.c | 2 +- src/field_camera.c | 14 ++--- src/field_screen_effect.c | 12 ++--- src/map_name_popup.c | 52 +++++++++---------- 6 files changed, 39 insertions(+), 48 deletions(-) rename graphics/interface/map_popup/{857F444.pal => underwater.pal} (100%) diff --git a/graphics/interface/map_popup/857F444.pal b/graphics/interface/map_popup/underwater.pal similarity index 100% rename from graphics/interface/map_popup/857F444.pal rename to graphics/interface/map_popup/underwater.pal diff --git a/include/field_camera.h b/include/field_camera.h index 2bed02b20..b245fca84 100644 --- a/include/field_camera.h +++ b/include/field_camera.h @@ -1,8 +1,6 @@ #ifndef GUARD_FIELD_CAMERA_H #define GUARD_FIELD_CAMERA_H -// Exported type declarations - struct CameraObject { void (*callback)(struct CameraObject *); @@ -13,18 +11,15 @@ struct CameraObject s32 y; }; -// Exported RAM declarations extern struct CameraObject gFieldCamera; extern u16 gTotalCameraPixelOffsetX; extern u16 gTotalCameraPixelOffsetY; -// Exported ROM declarations void DrawWholeMapView(void); void CurrentMapDrawMetatileAt(int x, int y); -void sub_8089C08(s16 *a0, s16 *a1); +void GetCameraOffsetWithPan(s16 *a0, s16 *a1); void DrawDoorMetatileAt(int x, int y, u16 *arr); void ResetFieldCamera(void); -void sub_8057A58(void); void ResetCameraUpdateInfo(void); u32 InitCameraUpdateCallback(u8 a); void CameraUpdate(void); diff --git a/src/battle_transition.c b/src/battle_transition.c index 66a4395b9..d47b99c86 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -3675,7 +3675,7 @@ static bool8 Phase1_TransitionAll_Func2(struct Task *task) static void InitTransitionStructVars(void) { memset(sTransitionStructPtr, 0, sizeof(*sTransitionStructPtr)); - sub_8089C08(&sTransitionStructPtr->field_14, &sTransitionStructPtr->field_16); + GetCameraOffsetWithPan(&sTransitionStructPtr->field_14, &sTransitionStructPtr->field_16); } static void VBlankCB_BattleTransition(void) diff --git a/src/field_camera.c b/src/field_camera.c index 699b984ac..a36b6883c 100644 --- a/src/field_camera.c +++ b/src/field_camera.c @@ -39,7 +39,7 @@ static void CameraPanningCB_PanAhead(void); static struct FieldCameraOffset sFieldCameraOffset; static s16 sHorizontalCameraPan; static s16 sVerticalCameraPan; -static bool8 gUnknown_03000E2C; +static bool8 sBikeCameraPanFlag; static void (*sFieldCameraPanningCallback)(void); struct CameraObject gFieldCamera; @@ -89,7 +89,7 @@ void FieldUpdateBgTilemapScroll(void) SetGpuReg(REG_OFFSET_BG3VOFS, r4); } -void sub_8089C08(s16 *x, s16 *y) +void GetCameraOffsetWithPan(s16 *x, s16 *y) { *x = sFieldCameraOffset.xPixelOffset + sHorizontalCameraPan; *y = sFieldCameraOffset.yPixelOffset + sVerticalCameraPan + 8; @@ -450,7 +450,7 @@ void SetCameraPanning(s16 a, s16 b) void InstallCameraPanAheadCallback(void) { sFieldCameraPanningCallback = CameraPanningCB_PanAhead; - gUnknown_03000E2C = FALSE; + sBikeCameraPanFlag = FALSE; sHorizontalCameraPan = 0; sVerticalCameraPan = 32; } @@ -474,16 +474,16 @@ static void CameraPanningCB_PanAhead(void) } else { - // this code is never reached. + // this code is never reached if (gPlayerAvatar.tileTransitionState == T_TILE_TRANSITION) { - gUnknown_03000E2C ^= 1; - if (gUnknown_03000E2C == FALSE) + sBikeCameraPanFlag ^= 1; + if (sBikeCameraPanFlag == FALSE) return; } else { - gUnknown_03000E2C = FALSE; + sBikeCameraPanFlag = FALSE; } var = GetPlayerMovementDirection(); diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index db82d667c..fbe725c0b 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -1087,7 +1087,7 @@ static void LoadOrbEffectPalette(bool8 blueOrb) } } -static bool8 sub_80B02C8(u16 shakeDir) +static bool8 UpdateOrbEffectBlend(u16 shakeDir) { u8 lo = REG_BLDALPHA & 0xFF; u8 hi = REG_BLDALPHA >> 8; @@ -1095,21 +1095,17 @@ static bool8 sub_80B02C8(u16 shakeDir) if (shakeDir != 0) { if (lo) - { lo--; - } } else { - if (hi < 0x10) - { + if (hi < 16) hi++; - } } SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(lo, hi)); - if (lo == 0 && hi == 0x10) + if (lo == 0 && hi == 16) return TRUE; else return FALSE; @@ -1193,7 +1189,7 @@ static void Task_OrbEffect(u8 taskId) { tShakeDelay = 8; tShakeDir ^= 1; - if (sub_80B02C8(tShakeDir) == TRUE) + if (UpdateOrbEffectBlend(tShakeDir) == TRUE) { tState = 5; sub_8199DF0(0, PIXEL_FILL(0), 0, 1); diff --git a/src/map_name_popup.c b/src/map_name_popup.c index 65192fa33..cd92bbac1 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -36,37 +36,37 @@ static void LoadMapNamePopUpWindowBg(void); static EWRAM_DATA u8 sPopupTaskId = 0; // .rodata -static const u8 gMapPopUp_Table[][960] = +static const u8 sMapPopUp_Table[][960] = { - INCBIN_U8("graphics/interface/map_popup/wood.4bpp"), - INCBIN_U8("graphics/interface/map_popup/marble.4bpp"), - INCBIN_U8("graphics/interface/map_popup/stone.4bpp"), - INCBIN_U8("graphics/interface/map_popup/brick.4bpp"), - INCBIN_U8("graphics/interface/map_popup/underwater.4bpp"), - INCBIN_U8("graphics/interface/map_popup/stone2.4bpp"), + [MAPPOPUP_THEME_WOOD] = INCBIN_U8("graphics/interface/map_popup/wood.4bpp"), + [MAPPOPUP_THEME_MARBLE] = INCBIN_U8("graphics/interface/map_popup/marble.4bpp"), + [MAPPOPUP_THEME_STONE] = INCBIN_U8("graphics/interface/map_popup/stone.4bpp"), + [MAPPOPUP_THEME_BRICK] = INCBIN_U8("graphics/interface/map_popup/brick.4bpp"), + [MAPPOPUP_THEME_UNDERWATER] = INCBIN_U8("graphics/interface/map_popup/underwater.4bpp"), + [MAPPOPUP_THEME_STONE2] = INCBIN_U8("graphics/interface/map_popup/stone2.4bpp"), }; -static const u8 gMapPopUp_Outline_Table[][960] = +static const u8 sMapPopUp_OutlineTable[][960] = { - INCBIN_U8("graphics/interface/map_popup/wood_outline.4bpp"), - INCBIN_U8("graphics/interface/map_popup/marble_outline.4bpp"), - INCBIN_U8("graphics/interface/map_popup/stone_outline.4bpp"), - INCBIN_U8("graphics/interface/map_popup/brick_outline.4bpp"), - INCBIN_U8("graphics/interface/map_popup/underwater_outline.4bpp"), - INCBIN_U8("graphics/interface/map_popup/stone2_outline.4bpp"), + [MAPPOPUP_THEME_WOOD] = INCBIN_U8("graphics/interface/map_popup/wood_outline.4bpp"), + [MAPPOPUP_THEME_MARBLE] = INCBIN_U8("graphics/interface/map_popup/marble_outline.4bpp"), + [MAPPOPUP_THEME_STONE] = INCBIN_U8("graphics/interface/map_popup/stone_outline.4bpp"), + [MAPPOPUP_THEME_BRICK] = INCBIN_U8("graphics/interface/map_popup/brick_outline.4bpp"), + [MAPPOPUP_THEME_UNDERWATER] = INCBIN_U8("graphics/interface/map_popup/underwater_outline.4bpp"), + [MAPPOPUP_THEME_STONE2] = INCBIN_U8("graphics/interface/map_popup/stone2_outline.4bpp"), }; -static const u16 gMapPopUp_Palette_Table[][16] = +static const u16 sMapPopUp_PaletteTable[][16] = { - INCBIN_U16("graphics/interface/map_popup/wood.gbapal"), - INCBIN_U16("graphics/interface/map_popup/marble_outline.gbapal"), - INCBIN_U16("graphics/interface/map_popup/stone_outline.gbapal"), - INCBIN_U16("graphics/interface/map_popup/brick_outline.gbapal"), - INCBIN_U16("graphics/interface/map_popup/underwater_outline.gbapal"), - INCBIN_U16("graphics/interface/map_popup/stone2_outline.gbapal"), + [MAPPOPUP_THEME_WOOD] = INCBIN_U16("graphics/interface/map_popup/wood.gbapal"), + [MAPPOPUP_THEME_MARBLE] = INCBIN_U16("graphics/interface/map_popup/marble_outline.gbapal"), + [MAPPOPUP_THEME_STONE] = INCBIN_U16("graphics/interface/map_popup/stone_outline.gbapal"), + [MAPPOPUP_THEME_BRICK] = INCBIN_U16("graphics/interface/map_popup/brick_outline.gbapal"), + [MAPPOPUP_THEME_UNDERWATER] = INCBIN_U16("graphics/interface/map_popup/underwater_outline.gbapal"), + [MAPPOPUP_THEME_STONE2] = INCBIN_U16("graphics/interface/map_popup/stone2_outline.gbapal"), }; -static const u16 gUnknown_0857F444[16] = INCBIN_U16("graphics/interface/map_popup/857F444.gbapal"); +static const u16 sMapPopUp_Palette_Underwater[16] = INCBIN_U16("graphics/interface/map_popup/underwater.gbapal"); static const u8 gRegionMapSectionId_To_PopUpThemeIdMapping[] = { @@ -380,12 +380,12 @@ static void LoadMapNamePopUpWindowBg(void) } popUpThemeId = gRegionMapSectionId_To_PopUpThemeIdMapping[regionMapSectionId]; - LoadBgTiles(GetWindowAttribute(popupWindowId, WINDOW_BG), gMapPopUp_Outline_Table[popUpThemeId], 0x400, 0x21D); + LoadBgTiles(GetWindowAttribute(popupWindowId, WINDOW_BG), sMapPopUp_OutlineTable[popUpThemeId], 0x400, 0x21D); CallWindowFunction(popupWindowId, DrawMapNamePopUpFrame); PutWindowTilemap(popupWindowId); if (gMapHeader.weather == WEATHER_UNDERWATER_BUBBLES) - LoadPalette(&gUnknown_0857F444, 0xE0, 0x20); + LoadPalette(&sMapPopUp_Palette_Underwater, 0xE0, sizeof(sMapPopUp_Palette_Underwater)); else - LoadPalette(gMapPopUp_Palette_Table[popUpThemeId], 0xE0, 0x20); - BlitBitmapToWindow(popupWindowId, gMapPopUp_Table[popUpThemeId], 0, 0, 80, 24); + LoadPalette(sMapPopUp_PaletteTable[popUpThemeId], 0xE0, sizeof(sMapPopUp_PaletteTable[0])); + BlitBitmapToWindow(popupWindowId, sMapPopUp_Table[popUpThemeId], 0, 0, 80, 24); }