summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@gmail.com>2020-03-28 12:20:20 -0400
committerPikalaxALT <PikalaxALT@gmail.com>2020-03-28 12:20:20 -0400
commit24ac46856ad10af92054d82b4ec50486feaf222e (patch)
tree2b8ff76d6f7cf4855e254b6a8c28a890ba7756e4 /src
parent9c62fd51aabaf9301d6a89a03a8e3ddf91d61164 (diff)
through sub_805644C
Diffstat (limited to 'src')
-rw-r--r--src/overworld.c232
-rw-r--r--src/quest_log.c6
2 files changed, 235 insertions, 3 deletions
diff --git a/src/overworld.c b/src/overworld.c
index a7d23d870..d4299d044 100644
--- a/src/overworld.c
+++ b/src/overworld.c
@@ -4,6 +4,7 @@
#include "event_scripts.h"
#include "field_camera.h"
#include "field_control_avatar.h"
+#include "field_message_box.h"
#include "field_player_avatar.h"
#include "field_screen_effect.h"
#include "field_specials.h"
@@ -15,11 +16,13 @@
#include "map_name_popup.h"
#include "metatile_behavior.h"
#include "money.h"
+#include "new_menu_helpers.h"
#include "overworld.h"
#include "quest_log.h"
#include "random.h"
#include "renewable_hidden_items.h"
#include "roamer.h"
+#include "safari_zone.h"
#include "save_location.h"
#include "script.h"
#include "script_pokemon_util.h"
@@ -61,6 +64,15 @@ EWRAM_DATA s16 gUnknown_2031DEA = 0;
// File boundary perhaps?
EWRAM_DATA struct LinkPlayerObjectEvent gLinkPlayerObjectEvents[4] = {};
+u16 *gBGTilemapBuffers1;
+u16 *gBGTilemapBuffers2;
+u16 *gBGTilemapBuffers3;
+void (*gFieldCallback)(void);
+bool8 (*gFieldCallback2)(void);
+u16 gHeldKeyCodeToSend;
+u8 gLocalLinkPlayerId;
+u8 gFieldLinkPlayerCount;
+
u8 CountBadgesForOverworldWhiteOutLossCalculation(void);
void Overworld_ResetStateAfterWhitingOut(void);
void Overworld_SetWhiteoutRespawnPoint(void);
@@ -72,6 +84,10 @@ void SetDefaultFlashLevel(void);
void Overworld_TryMapConnectionMusicTransition(void);
void ChooseAmbientCrySpecies(void);
+void MoveSaveBlocks_ResetHeap_(void);
+void sub_8056E80(void);
+void CB1_UpdateLinkState(void);
+
extern const struct MapLayout * gMapLayouts[];
extern const struct MapHeader *const *gMapGroups[];
@@ -1057,3 +1073,219 @@ bool32 sub_8056124(u16 music)
}
return TRUE;
}
+
+u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum)
+{
+ return Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum)->mapType;
+}
+
+u8 GetMapTypeByWarpData(struct WarpData *warp)
+{
+ return GetMapTypeByGroupAndId(warp->mapGroup, warp->mapNum);
+}
+
+u8 GetCurrentMapType(void)
+{
+ return GetMapTypeByWarpData(&gSaveBlock1Ptr->location);
+}
+
+u8 GetLastUsedWarpMapType(void)
+{
+ return GetMapTypeByWarpData(&gLastUsedWarp);
+}
+
+u8 GetLastUsedWarpMapSectionId(void)
+{
+ return Overworld_GetMapHeaderByGroupAndId(gLastUsedWarp.mapGroup, gLastUsedWarp.mapNum)->regionMapSectionId;
+}
+
+bool8 IsMapTypeOutdoors(u8 mapType)
+{
+ if (mapType == MAP_TYPE_ROUTE
+ || mapType == MAP_TYPE_TOWN
+ || mapType == MAP_TYPE_UNDERWATER
+ || mapType == MAP_TYPE_CITY
+ || mapType == MAP_TYPE_OCEAN_ROUTE)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType)
+{
+ if (mapType == MAP_TYPE_ROUTE
+ || mapType == MAP_TYPE_TOWN
+ || mapType == MAP_TYPE_OCEAN_ROUTE
+ || mapType == MAP_TYPE_CITY)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+bool8 IsMapTypeIndoors(u8 mapType)
+{
+ if (mapType == MAP_TYPE_INDOOR
+ || mapType == MAP_TYPE_SECRET_BASE)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+u8 GetSavedWarpRegionMapSectionId(void)
+{
+ return Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->dynamicWarp.mapGroup, gSaveBlock1Ptr->dynamicWarp.mapNum)->regionMapSectionId;
+}
+
+u8 GetCurrentRegionMapSectionId(void)
+{
+ return Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum)->regionMapSectionId;
+}
+
+u8 GetCurrentMapBattleScene(void)
+{
+ return Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum)->battleType;
+}
+
+const int sUnusedData[] = {
+ 1200,
+ 3600,
+ 1200,
+ 2400,
+ 50,
+ 80,
+ -44,
+ 44
+};
+
+const struct UCoords32 gDirectionToVectors[] = {
+ { 0u, 0u},
+ { 0u, 1u},
+ { 0u, -1u},
+ {-1u, 0u},
+ { 1u, 0u},
+ {-1u, 1u},
+ { 1u, 1u},
+ {-1u, -1u},
+ { 1u, -1u},
+};
+
+const struct BgTemplate sOverworldBgTemplates[] = {
+ {
+ .bg = 0,
+ .charBaseIndex = 2,
+ .mapBaseIndex = 31,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 0,
+ .baseTile = 0x000
+ }, {
+ .bg = 1,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 29,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 1,
+ .baseTile = 0x000
+ }, {
+ .bg = 2,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 28,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 2,
+ .baseTile = 0x000
+ }, {
+ .bg = 3,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 30,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 3,
+ .baseTile = 0x000
+ }
+};
+
+void InitOverworldBgs(void)
+{
+ MoveSaveBlocks_ResetHeap_();
+ sub_8056E80();
+ ResetBgsAndClearDma3BusyFlags(FALSE);
+ InitBgsFromTemplates(0, sOverworldBgTemplates, NELEMS(sOverworldBgTemplates));
+ SetBgAttribute(1, BG_ATTR_MOSAIC, TRUE);
+ SetBgAttribute(2, BG_ATTR_MOSAIC, TRUE);
+ SetBgAttribute(3, BG_ATTR_MOSAIC, TRUE);
+ gBGTilemapBuffers2 = AllocZeroed(BG_SCREEN_SIZE);
+ gBGTilemapBuffers1 = AllocZeroed(BG_SCREEN_SIZE);
+ gBGTilemapBuffers3 = AllocZeroed(BG_SCREEN_SIZE);
+ SetBgTilemapBuffer(1, gBGTilemapBuffers2);
+ SetBgTilemapBuffer(2, gBGTilemapBuffers1);
+ SetBgTilemapBuffer(3, gBGTilemapBuffers3);
+ InitStandardTextBoxWindows();
+ ResetBg0();
+ sub_8069348();
+}
+
+void InitOverworldBgs_NoResetHeap(void)
+{
+ ResetBgsAndClearDma3BusyFlags(FALSE);
+ InitBgsFromTemplates(0, sOverworldBgTemplates, NELEMS(sOverworldBgTemplates));
+ SetBgAttribute(1, BG_ATTR_MOSAIC, TRUE);
+ SetBgAttribute(2, BG_ATTR_MOSAIC, TRUE);
+ SetBgAttribute(3, BG_ATTR_MOSAIC, TRUE);
+ gBGTilemapBuffers2 = AllocZeroed(BG_SCREEN_SIZE);
+ gBGTilemapBuffers1 = AllocZeroed(BG_SCREEN_SIZE);
+ gBGTilemapBuffers3 = AllocZeroed(BG_SCREEN_SIZE);
+ SetBgTilemapBuffer(1, gBGTilemapBuffers2);
+ SetBgTilemapBuffer(2, gBGTilemapBuffers1);
+ SetBgTilemapBuffer(3, gBGTilemapBuffers3);
+ InitStandardTextBoxWindows();
+ ResetBg0();
+ sub_8069348();
+}
+
+void CleanupOverworldWindowsAndTilemaps(void)
+{
+ FreeAllOverworldWindowBuffers();
+ Free(gBGTilemapBuffers3);
+ Free(gBGTilemapBuffers1);
+ Free(gBGTilemapBuffers2);
+}
+
+void ResetSafariZoneFlag_(void)
+{
+ ResetSafariZoneFlag();
+}
+
+bool32 IsUpdateLinkStateCBActive(void)
+{
+ if (gMain.callback1 == CB1_UpdateLinkState)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+void sub_805644C(u16 newKeys, u16 heldKeys)
+{
+ struct FieldInput fieldInput;
+
+ sub_8112B3C();
+ sub_805BEB8();
+ FieldClearPlayerInput(&fieldInput);
+ FieldGetPlayerInput(&fieldInput, newKeys, heldKeys);
+ FieldInput_HandleCancelSignpost(&fieldInput);
+ if (!ScriptContext2_IsEnabled())
+ {
+ if (ProcessPlayerFieldInput(&fieldInput) == TRUE)
+ {
+ if (gUnknown_3005E88 == 2)
+ sub_81127F8(&gInputToStoreInQuestLogMaybe);
+ ScriptContext2_Enable();
+ DismissMapNamePopup();
+ }
+ else
+ {
+ player_step(fieldInput.dpadDirection, newKeys, heldKeys);
+ }
+ }
+ RunQuestLogCB();
+}
diff --git a/src/quest_log.c b/src/quest_log.c
index 21a05f407..f705335da 100644
--- a/src/quest_log.c
+++ b/src/quest_log.c
@@ -96,7 +96,7 @@ struct UnkStruct_203B044
u8 gUnknown_3005E88;
u16 sNumEventsInLogEntry;
-struct UnkStruct_3005E90 gUnknown_3005E90;
+struct FieldInput gUnknown_3005E90;
struct QuestLogEntry * sCurQuestLogEntry;
static struct UnkStruct_300201C * sFlagOrVarRecords;
@@ -1536,7 +1536,7 @@ void sub_811278C(u8 movementActionId, u8 duration)
}
}
-void sub_81127F8(struct UnkStruct_3005E90 * a0)
+void sub_81127F8(struct FieldInput * a0)
{
if (sQuestLogCursor < sNumEventsInLogEntry)
{
@@ -1616,7 +1616,7 @@ static void SetUpQuestLogEntry(u8 kind, struct QuestLogEntry *entry, u16 size)
}
sQuestLogCursor = 0;
gUnknown_203B01C = 0;
- gUnknown_3005E90 = (struct UnkStruct_3005E90){};
+ gUnknown_3005E90 = (struct FieldInput){};
sNextStepDelay = sCurQuestLogEntry[sQuestLogCursor].unk_4;
sMovementScripts[0][0] = sCurQuestLogEntry[sQuestLogCursor].unk_3;
sMovementScripts[0][1] = 0xFF;