through LoadSaveblockMapHeader
This commit is contained in:
+169
-6
@@ -2,13 +2,16 @@
|
||||
#include "gflib.h"
|
||||
#include "event_data.h"
|
||||
#include "event_scripts.h"
|
||||
#include "field_camera.h"
|
||||
#include "field_specials.h"
|
||||
#include "fieldmap.h"
|
||||
#include "load_save.h"
|
||||
#include "money.h"
|
||||
#include "overworld.h"
|
||||
#include "roamer.h"
|
||||
#include "script.h"
|
||||
#include "script_pokemon_util.h"
|
||||
#include "tileset_anims.h"
|
||||
#include "constants/maps.h"
|
||||
#include "constants/flags.h"
|
||||
|
||||
@@ -19,11 +22,10 @@ struct InitialPlayerAvatarState
|
||||
u8 unk2;
|
||||
};
|
||||
|
||||
|
||||
EWRAM_DATA struct WarpData gUnknown_2031DB4 = {};
|
||||
EWRAM_DATA struct WarpData gUnknown_2031DBC = {};
|
||||
EWRAM_DATA struct WarpData gUnknown_2031DC4 = {};
|
||||
EWRAM_DATA struct WarpData gUnknown_2031DCC = {};
|
||||
EWRAM_DATA struct WarpData gLastUsedWarp = {};
|
||||
EWRAM_DATA struct WarpData sWarpDestination = {};
|
||||
EWRAM_DATA struct WarpData gFixedDiveWarp = {};
|
||||
EWRAM_DATA struct WarpData gFixedHoleWarp = {};
|
||||
EWRAM_DATA struct InitialPlayerAvatarState gUnknown_2031DD4 = {};
|
||||
|
||||
u8 CountBadgesForOverworldWhiteOutLossCalculation(void);
|
||||
@@ -31,6 +33,9 @@ void Overworld_ResetStateAfterWhitingOut(void);
|
||||
void Overworld_SetWhiteoutRespawnPoint(void);
|
||||
void sub_805610C(void);
|
||||
|
||||
extern const struct MapLayout * gMapLayouts[];
|
||||
extern const struct MapHeader *const *gMapGroups[];
|
||||
|
||||
static const u8 sWhiteOutMoneyLossMultipliers[] = {
|
||||
2,
|
||||
4,
|
||||
@@ -196,7 +201,7 @@ void SetGameStat(u8 statId, u32 statVal)
|
||||
gSaveBlock1Ptr->gameStats[statId] = statVal ^ gSaveBlock2Ptr->encryptionKey;
|
||||
}
|
||||
|
||||
void sub_8054F38(u32 newKey)
|
||||
void ApplyNewEncryptionKeyToGameStats(u32 newKey)
|
||||
{
|
||||
u8 i;
|
||||
for (i = 0; i < NUM_GAME_STATS; i++)
|
||||
@@ -204,3 +209,161 @@ void sub_8054F38(u32 newKey)
|
||||
ApplyNewEncryptionKeyToWord(&gSaveBlock1Ptr->gameStats[i], newKey);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8054F68(void)
|
||||
{
|
||||
u8 i, j;
|
||||
u8 mapGroup;
|
||||
u8 mapNum;
|
||||
u8 localId;
|
||||
const struct MapHeader * linkedMap;
|
||||
|
||||
for (i = 0, j = 0; i < gMapHeader.events->objectEventCount; i++)
|
||||
{
|
||||
if (gMapHeader.events->objectEvents[i].unk2 == 0xFF)
|
||||
{
|
||||
localId = gMapHeader.events->objectEvents[i].elevation;
|
||||
mapNum = gMapHeader.events->objectEvents[i].trainerType;
|
||||
mapGroup = gMapHeader.events->objectEvents[i].trainerRange_berryTreeId;
|
||||
linkedMap = Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum);
|
||||
gSaveBlock1Ptr->objectEventTemplates[j] = linkedMap->events->objectEvents[localId - 1];
|
||||
gSaveBlock1Ptr->objectEventTemplates[j].localId = gMapHeader.events->objectEvents[i].localId;
|
||||
gSaveBlock1Ptr->objectEventTemplates[j].x = gMapHeader.events->objectEvents[i].x;
|
||||
gSaveBlock1Ptr->objectEventTemplates[j].y = gMapHeader.events->objectEvents[i].y;
|
||||
gSaveBlock1Ptr->objectEventTemplates[j].elevation = localId;
|
||||
gSaveBlock1Ptr->objectEventTemplates[j].trainerType = mapNum;
|
||||
gSaveBlock1Ptr->objectEventTemplates[j].trainerRange_berryTreeId = mapGroup;
|
||||
gSaveBlock1Ptr->objectEventTemplates[j].unk2 = 0xFF;
|
||||
j++;
|
||||
}
|
||||
else
|
||||
{
|
||||
gSaveBlock1Ptr->objectEventTemplates[j] = gMapHeader.events->objectEvents[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_80550A8(void)
|
||||
{
|
||||
int i;
|
||||
const struct ObjectEventTemplate * src = gMapHeader.events->objectEvents;
|
||||
struct ObjectEventTemplate * savObjTemplates = gSaveBlock1Ptr->objectEventTemplates;
|
||||
|
||||
for (i = 0; i < OBJECT_EVENT_TEMPLATES_COUNT; i++)
|
||||
{
|
||||
savObjTemplates[i].script = src[i].script;
|
||||
}
|
||||
}
|
||||
|
||||
void Overworld_SetMapObjTemplateCoords(u8 localId, s16 x, s16 y)
|
||||
{
|
||||
int i;
|
||||
struct ObjectEventTemplate * savObjTemplates = gSaveBlock1Ptr->objectEventTemplates;
|
||||
for (i = 0; i < OBJECT_EVENT_TEMPLATES_COUNT; i++)
|
||||
{
|
||||
if (savObjTemplates[i].localId == localId)
|
||||
{
|
||||
savObjTemplates[i].x = x;
|
||||
savObjTemplates[i].y = y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Overworld_SetObjEventTemplateMovementType(u8 localId, u8 movementType)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
struct ObjectEventTemplate *savObjTemplates = gSaveBlock1Ptr->objectEventTemplates;
|
||||
for (i = 0; i < OBJECT_EVENT_TEMPLATES_COUNT; i++)
|
||||
{
|
||||
struct ObjectEventTemplate *objectEventTemplate = &savObjTemplates[i];
|
||||
if (objectEventTemplate->localId == localId)
|
||||
{
|
||||
objectEventTemplate->movementType = movementType;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mapdata_load_assets_to_gpu_and_full_redraw(void)
|
||||
{
|
||||
move_tilemap_camera_to_upper_left_corner();
|
||||
copy_map_tileset1_tileset2_to_vram(gMapHeader.mapLayout);
|
||||
apply_map_tileset1_tileset2_palette(gMapHeader.mapLayout);
|
||||
DrawWholeMapView();
|
||||
InitTilesetAnimations();
|
||||
}
|
||||
|
||||
const struct MapLayout *GetMapLayout(void)
|
||||
{
|
||||
u16 mapLayoutId = gSaveBlock1Ptr->mapLayoutId;
|
||||
if (mapLayoutId)
|
||||
return gMapLayouts[mapLayoutId - 1];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const struct WarpData sDummyWarpData = {
|
||||
.mapGroup = MAP_GROUP(UNDEFINED),
|
||||
.mapNum = MAP_NUM(UNDEFINED),
|
||||
.warpId = 0xFF,
|
||||
.x = -1,
|
||||
.y = -1
|
||||
};
|
||||
|
||||
void ApplyCurrentWarp(void)
|
||||
{
|
||||
gLastUsedWarp = gSaveBlock1Ptr->location;
|
||||
gSaveBlock1Ptr->location = sWarpDestination;
|
||||
gFixedDiveWarp = sDummyWarpData;
|
||||
gFixedHoleWarp = sDummyWarpData;
|
||||
}
|
||||
|
||||
void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
|
||||
{
|
||||
warp->mapGroup = mapGroup;
|
||||
warp->mapNum = mapNum;
|
||||
warp->warpId = warpId;
|
||||
warp->x = x;
|
||||
warp->y = y;
|
||||
}
|
||||
|
||||
bool32 IsDummyWarp(struct WarpData *warp)
|
||||
{
|
||||
if (warp->mapGroup != -1)
|
||||
return FALSE;
|
||||
else if (warp->mapNum != -1)
|
||||
return FALSE;
|
||||
else if (warp->warpId != -1)
|
||||
return FALSE;
|
||||
else if (warp->x != -1)
|
||||
return FALSE;
|
||||
else if (warp->y != -1)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
struct MapHeader const *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum)
|
||||
{
|
||||
return gMapGroups[mapGroup][mapNum];
|
||||
}
|
||||
|
||||
struct MapHeader const *const GetDestinationWarpMapHeader(void)
|
||||
{
|
||||
return Overworld_GetMapHeaderByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum);
|
||||
}
|
||||
|
||||
void LoadCurrentMapData(void)
|
||||
{
|
||||
gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
|
||||
gSaveBlock1Ptr->mapLayoutId = gMapHeader.mapLayoutId;
|
||||
gMapHeader.mapLayout = GetMapLayout();
|
||||
}
|
||||
|
||||
void LoadSaveblockMapHeader(void)
|
||||
{
|
||||
gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
|
||||
gMapHeader.mapLayout = GetMapLayout();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user