Document some fieldmap stuff

This commit is contained in:
Marcus Huderle 2018-12-28 11:18:23 -06:00
parent ec61336a1f
commit 95dcff581b
10 changed files with 178 additions and 180 deletions

View File

@ -29324,14 +29324,14 @@ sub_81D5FB4: @ 81D5FB4
mov r9, r0
cmp r0, 0x6
bne _081D5FD2
bl sub_8087D74
bl InitMapFromSavedGame
b _081D605E
_081D5FD2:
bl sub_81D56B0
mov r0, r9
cmp r0, 0x5
bne _081D5FE6
bl sub_8087D74
bl InitMapFromSavedGame
bl sub_81D5710
b _081D605E
_081D5FE6:
@ -29342,7 +29342,7 @@ _081D5FE6:
ldr r0, =gMapHeader
ldr r0, [r0]
ldr r2, [r0, 0xC]
ldr r1, =gUnknown_03005DC0
ldr r1, =gBackupMapLayout
str r4, [r1, 0x8]
movs r0, 0x1F
str r0, [r1]

View File

@ -1 +1 @@
gUnknown_03005DC0
gBackupMapLayout

View File

@ -7,8 +7,9 @@
#define NUM_METATILES_TOTAL 1024
#define NUM_PALS_IN_PRIMARY 6
#define NUM_PALS_TOTAL 13
#define MAX_MAP_DATA_SIZE 0x2800
extern struct BackupMapLayout gUnknown_03005DC0;
extern struct BackupMapLayout gBackupMapLayout;
u32 MapGridGetMetatileIdAt(int, int);
u32 MapGridGetMetatileBehaviorAt(int, int);
@ -19,23 +20,19 @@ bool8 MapGridIsImpassableAt(int, int);
int GetMapBorderIdAt(int x, int y);
int CanCameraMoveInDirection(int direction);
u16 GetBehaviorByMetatileId(u16 metatileId);
void sav1_camera_get_focus_coords(u16 *x, u16 *y);
void GetCameraFocusCoords(u16 *x, u16 *y);
u8 MapGridGetMetatileLayerTypeAt(s32 x, s32 y);
u8 MapGridGetZCoordAt(int x, int y);
u8 CameraMove(s32 deltaX, s32 deltaY);
void mapheader_copy_mapdata_with_padding(struct MapHeader *mapHeader);
void map_copy_with_padding(u16 *map, u16 width, u16 height);
void mapheader_copy_mapdata_of_adjacent_maps(struct MapHeader *);
void fillSouthConnection(struct MapHeader const *, struct MapHeader const *, s32);
void fillNorthConnection(struct MapHeader const *, struct MapHeader const *, s32);
void fillWestConnection(struct MapHeader const *, struct MapHeader const *, s32);
void fillEastConnection(struct MapHeader const *, struct MapHeader const *, s32);
void mapdata_from_sav2(void);
bool8 sub_8088BF0(u16*, u16, u8);
struct MapConnection *sub_8088950(u8 direction, int x, int y);
bool8 sub_80889A8(u8 direction, int x, int y, struct MapConnection *connection);
bool8 sub_8088A0C(int x, int src_width, int dest_width, int offset);
void save_serialize_map(void);
void sub_8088B3C(u16 x, u16 y);
void InitMap(void);
void InitMapFromSavedGame(void);
void InitTrainerHillMap(void);
void InitBattlePyramidMap(u8 a0);
void SpriteCB_PokeballGlow(struct Sprite *);
void SpriteCB_PokecenterMonitor(struct Sprite *);

View File

@ -6,8 +6,8 @@ bool8 SetUpFieldMove_Cut(void);
bool8 FldEff_UseCutOnGrass(void);
bool8 FldEff_UseCutOnTree(void);
bool8 FldEff_CutGrass(void);
void sub_80D423C(s16 x, s16 y);
void sub_80D42B8(s16 x, s16 y);
void FixLongGrassMetatilesWindowTop(s16 x, s16 y);
void FixLongGrassMetatilesWindowBottom(s16 x, s16 y);
extern const struct SpritePalette gFieldEffectObjectPaletteInfo6;

View File

@ -1202,8 +1202,8 @@ static u8 sub_81A9998(s32 *arg0, u8 arg1, u8 arg2)
{
s32 i, j;
u8 ret = 0;
u16 *map = gUnknown_03005DC0.map;
map += gUnknown_03005DC0.width * 7 + 7;
u16 *map = gBackupMapLayout.map;
map += gBackupMapLayout.width * 7 + 7;
for (i = 0; i < 32; map += 47, i++)
{
@ -1493,11 +1493,11 @@ void sub_81AA078(u16 *mapArg, u8 arg1)
const struct MapLayout *mapLayout = gMapLayouts[allocated[i] + 0x169];
const u16 *layoutMap = mapLayout->map;
gUnknown_03005DC0.map = mapArg;
gUnknown_03005DC0.width = mapLayout->width * 4 + 15;
gUnknown_03005DC0.height = mapLayout->height * 4 + 14;
gBackupMapLayout.map = mapArg;
gBackupMapLayout.width = mapLayout->width * 4 + 15;
gBackupMapLayout.height = mapLayout->height * 4 + 14;
map = mapArg;
heightAdd = (((i / 4 * mapLayout->height) + 7) * (gUnknown_03005DC0.width));
heightAdd = (((i / 4 * mapLayout->height) + 7) * (gBackupMapLayout.width));
widthAdd = ((i % 4 * mapLayout->width) + 7);
map += heightAdd + widthAdd;
for (j = 0; j < mapLayout->height; j++)

View File

@ -24,84 +24,94 @@ struct ConnectionFlags
u8 east:1;
};
EWRAM_DATA static u16 gUnknown_02032318[0x2800] = {0};
EWRAM_DATA static u16 gBackupMapData[MAX_MAP_DATA_SIZE] = {0};
EWRAM_DATA struct MapHeader gMapHeader = {0};
EWRAM_DATA struct Camera gCamera = {0};
EWRAM_DATA static struct ConnectionFlags gUnknown_02037340 = {0};
EWRAM_DATA static struct ConnectionFlags gMapConnectionFlags = {0};
EWRAM_DATA static u32 sFiller_02037344 = 0; // without this, the next file won't align properly
struct BackupMapLayout gUnknown_03005DC0;
struct BackupMapLayout gBackupMapLayout;
static const struct ConnectionFlags sDummyConnectionFlags = {0};
static void InitMapLayoutData(struct MapHeader *mapHeader);
static void InitBackupMapLayoutData(u16 *map, u16 width, u16 height);
static void FillSouthConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset);
static void FillNorthConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset);
static void FillWestConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset);
static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset);
static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader);
static void LoadSavedMapView(void);
static bool8 SkipCopyingMetatileFromSavedMap(u16* mapMetatilePtr, u16 mapWidth, u8 yMode);
struct MapHeader const *const mapconnection_get_mapheader(struct MapConnection *connection)
{
return Overworld_GetMapHeaderByGroupAndId(connection->mapGroup, connection->mapNum);
}
void not_trainer_hill_battle_pyramid(void)
void InitMap(void)
{
mapheader_copy_mapdata_with_padding(&gMapHeader);
InitMapLayoutData(&gMapHeader);
sub_80E8EE0(gMapHeader.events);
mapheader_run_script_with_tag_x1();
}
void sub_8087D74(void)
void InitMapFromSavedGame(void)
{
mapheader_copy_mapdata_with_padding(&gMapHeader);
InitMapLayoutData(&gMapHeader);
sub_80E9238(0);
sub_80E8EE0(gMapHeader.events);
mapdata_from_sav2();
LoadSavedMapView();
mapheader_run_script_with_tag_x1();
UpdateTVScreensOnMap(gUnknown_03005DC0.width, gUnknown_03005DC0.height);
UpdateTVScreensOnMap(gBackupMapLayout.width, gBackupMapLayout.height);
}
void battle_pyramid_map_load_related(u8 a0)
void InitBattlePyramidMap(u8 a0)
{
CpuFastFill(0x03ff03ff, gUnknown_02032318, sizeof(gUnknown_02032318));
sub_81AA078(gUnknown_02032318, a0);
CpuFastFill(0x03ff03ff, gBackupMapData, sizeof(gBackupMapData));
sub_81AA078(gBackupMapData, a0);
}
void trainer_hill_map_load_related(void)
void InitTrainerHillMap(void)
{
CpuFastFill(0x03ff03ff, gUnknown_02032318, sizeof(gUnknown_02032318));
sub_81D5FB4(gUnknown_02032318);
CpuFastFill(0x03ff03ff, gBackupMapData, sizeof(gBackupMapData));
sub_81D5FB4(gBackupMapData);
}
void mapheader_copy_mapdata_with_padding(struct MapHeader *mapHeader)
static void InitMapLayoutData(struct MapHeader *mapHeader)
{
struct MapLayout const *mapLayout;
int width;
int height;
mapLayout = mapHeader->mapLayout;
CpuFastFill16(0x03ff, gUnknown_02032318, sizeof(gUnknown_02032318));
gUnknown_03005DC0.map = gUnknown_02032318;
CpuFastFill16(0x03ff, gBackupMapData, sizeof(gBackupMapData));
gBackupMapLayout.map = gBackupMapData;
width = mapLayout->width + 15;
gUnknown_03005DC0.width = width;
gBackupMapLayout.width = width;
height = mapLayout->height + 14;
gUnknown_03005DC0.height = height;
if (width * height <= 0x2800)
gBackupMapLayout.height = height;
if (width * height <= MAX_MAP_DATA_SIZE)
{
map_copy_with_padding(mapLayout->map, mapLayout->width, mapLayout->height);
mapheader_copy_mapdata_of_adjacent_maps(mapHeader);
InitBackupMapLayoutData(mapLayout->map, mapLayout->width, mapLayout->height);
InitBackupMapLayoutConnections(mapHeader);
}
}
void map_copy_with_padding(u16 *map, u16 width, u16 height)
static void InitBackupMapLayoutData(u16 *map, u16 width, u16 height)
{
u16 *dest;
int y;
dest = gUnknown_03005DC0.map;
dest += gUnknown_03005DC0.width * 7 + 7;
dest = gBackupMapLayout.map;
dest += gBackupMapLayout.width * 7 + 7;
for (y = 0; y < height; y++)
{
CpuCopy16(map, dest, width * 2);
dest += width + 0xf;
dest += width + 15;
map += width;
}
}
void mapheader_copy_mapdata_of_adjacent_maps(struct MapHeader *mapHeader)
static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader)
{
int count;
struct MapConnection *connection;
@ -111,56 +121,54 @@ void mapheader_copy_mapdata_of_adjacent_maps(struct MapHeader *mapHeader)
{
count = mapHeader->connections->count;
connection = mapHeader->connections->connections;
gUnknown_02037340 = sDummyConnectionFlags;
gMapConnectionFlags = sDummyConnectionFlags;
for (i = 0; i < count; i++, connection++)
{
struct MapHeader const *cMap = mapconnection_get_mapheader(connection);
u32 offset = connection->offset;
switch (connection->direction)
{
case CONNECTION_SOUTH:
fillSouthConnection(mapHeader, cMap, offset);
gUnknown_02037340.south = 1;
FillSouthConnection(mapHeader, cMap, offset);
gMapConnectionFlags.south = 1;
break;
case CONNECTION_NORTH:
fillNorthConnection(mapHeader, cMap, offset);
gUnknown_02037340.north = 1;
FillNorthConnection(mapHeader, cMap, offset);
gMapConnectionFlags.north = 1;
break;
case CONNECTION_WEST:
fillWestConnection(mapHeader, cMap, offset);
gUnknown_02037340.west = 1;
FillWestConnection(mapHeader, cMap, offset);
gMapConnectionFlags.west = 1;
break;
case CONNECTION_EAST:
fillEastConnection(mapHeader, cMap, offset);
gUnknown_02037340.east = 1;
FillEastConnection(mapHeader, cMap, offset);
gMapConnectionFlags.east = 1;
break;
}
}
}
}
void sub_8087F54(int x, int y, struct MapHeader const *mapHeader, int x2, int y2, int width, int height)
static void sub_8087F54(int x, int y, struct MapHeader const *connectedMapHeader, int x2, int y2, int width, int height)
{
int i;
u16 *src;
u16 *dest;
int mapWidth;
mapWidth = mapHeader->mapLayout->width;
src = &mapHeader->mapLayout->map[mapWidth * y2 + x2];
dest = &gUnknown_03005DC0.map[gUnknown_03005DC0.width * y + x];
mapWidth = connectedMapHeader->mapLayout->width;
src = &connectedMapHeader->mapLayout->map[mapWidth * y2 + x2];
dest = &gBackupMapLayout.map[gBackupMapLayout.width * y + x];
for (i = 0; i < height; i++)
{
CpuCopy16(src, dest, width * 2);
dest += gUnknown_03005DC0.width;
dest += gBackupMapLayout.width;
src += mapWidth;
}
}
void fillSouthConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset)
static void FillSouthConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset)
{
int x, y;
int x2;
@ -176,26 +184,26 @@ void fillSouthConnection(struct MapHeader const *mapHeader, struct MapHeader con
{
x2 = -x;
x += cWidth;
if (x < gUnknown_03005DC0.width)
if (x < gBackupMapLayout.width)
{
width = x;
}
else
{
width = gUnknown_03005DC0.width;
width = gBackupMapLayout.width;
}
x = 0;
}
else
{
x2 = 0;
if (x + cWidth < gUnknown_03005DC0.width)
if (x + cWidth < gBackupMapLayout.width)
{
width = cWidth;
}
else
{
width = gUnknown_03005DC0.width - x;
width = gBackupMapLayout.width - x;
}
}
@ -207,7 +215,7 @@ void fillSouthConnection(struct MapHeader const *mapHeader, struct MapHeader con
}
}
void fillNorthConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset)
static void FillNorthConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset)
{
int x;
int x2, y2;
@ -224,26 +232,26 @@ void fillNorthConnection(struct MapHeader const *mapHeader, struct MapHeader con
{
x2 = -x;
x += cWidth;
if (x < gUnknown_03005DC0.width)
if (x < gBackupMapLayout.width)
{
width = x;
}
else
{
width = gUnknown_03005DC0.width;
width = gBackupMapLayout.width;
}
x = 0;
}
else
{
x2 = 0;
if (x + cWidth < gUnknown_03005DC0.width)
if (x + cWidth < gBackupMapLayout.width)
{
width = cWidth;
}
else
{
width = gUnknown_03005DC0.width - x;
width = gBackupMapLayout.width - x;
}
}
@ -256,7 +264,7 @@ void fillNorthConnection(struct MapHeader const *mapHeader, struct MapHeader con
}
}
void fillWestConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset)
static void FillWestConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset)
{
int y;
int x2, y2;
@ -271,26 +279,26 @@ void fillWestConnection(struct MapHeader const *mapHeader, struct MapHeader cons
if (y < 0)
{
y2 = -y;
if (y + cHeight < gUnknown_03005DC0.height)
if (y + cHeight < gBackupMapLayout.height)
{
height = y + cHeight;
}
else
{
height = gUnknown_03005DC0.height;
height = gBackupMapLayout.height;
}
y = 0;
}
else
{
y2 = 0;
if (y + cHeight < gUnknown_03005DC0.height)
if (y + cHeight < gBackupMapLayout.height)
{
height = cHeight;
}
else
{
height = gUnknown_03005DC0.height - y;
height = gBackupMapLayout.height - y;
}
}
@ -302,7 +310,7 @@ void fillWestConnection(struct MapHeader const *mapHeader, struct MapHeader cons
}
}
void fillEastConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset)
static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset)
{
int x, y;
int y2;
@ -316,26 +324,26 @@ void fillEastConnection(struct MapHeader const *mapHeader, struct MapHeader cons
if (y < 0)
{
y2 = -y;
if (y + cHeight < gUnknown_03005DC0.height)
if (y + cHeight < gBackupMapLayout.height)
{
height = y + cHeight;
}
else
{
height = gUnknown_03005DC0.height;
height = gBackupMapLayout.height;
}
y = 0;
}
else
{
y2 = 0;
if (y + cHeight < gUnknown_03005DC0.height)
if (y + cHeight < gBackupMapLayout.height)
{
height = cHeight;
}
else
{
height = gUnknown_03005DC0.height - y;
height = gBackupMapLayout.height - y;
}
}
@ -364,10 +372,10 @@ u8 MapGridGetZCoordAt(int x, int y)
int i;
u16 *border;
if (x >= 0 && x < gUnknown_03005DC0.width
&& y >= 0 && y < gUnknown_03005DC0.height)
if (x >= 0 && x < gBackupMapLayout.width
&& y >= 0 && y < gBackupMapLayout.height)
{
block = gUnknown_03005DC0.map[x + gUnknown_03005DC0.width * y];
block = gBackupMapLayout.map[x + gBackupMapLayout.width * y];
}
else
{
@ -392,10 +400,10 @@ u8 MapGridIsImpassableAt(int x, int y)
int i;
u16 *border;
if (x >= 0 && x < gUnknown_03005DC0.width
&& y >= 0 && y < gUnknown_03005DC0.height)
if (x >= 0 && x < gBackupMapLayout.width
&& y >= 0 && y < gBackupMapLayout.height)
{
block = gUnknown_03005DC0.map[x + gUnknown_03005DC0.width * y];
block = gBackupMapLayout.map[x + gBackupMapLayout.width * y];
}
else
{
@ -421,10 +429,10 @@ u32 MapGridGetMetatileIdAt(int x, int y)
u16 *border;
u16 block2;
if (x >= 0 && x < gUnknown_03005DC0.width
&& y >= 0 && y < gUnknown_03005DC0.height)
if (x >= 0 && x < gBackupMapLayout.width
&& y >= 0 && y < gBackupMapLayout.height)
{
block = gUnknown_03005DC0.map[x + gUnknown_03005DC0.width * y];
block = gBackupMapLayout.map[x + gBackupMapLayout.width * y];
}
else
{
@ -462,22 +470,22 @@ u8 MapGridGetMetatileLayerTypeAt(int x, int y)
void MapGridSetMetatileIdAt(int x, int y, u16 metatile)
{
int i;
if (x >= 0 && x < gUnknown_03005DC0.width
&& y >= 0 && y < gUnknown_03005DC0.height)
if (x >= 0 && x < gBackupMapLayout.width
&& y >= 0 && y < gBackupMapLayout.height)
{
i = x + y * gUnknown_03005DC0.width;
gUnknown_03005DC0.map[i] = (gUnknown_03005DC0.map[i] & 0xf000) | (metatile & 0xfff);
i = x + y * gBackupMapLayout.width;
gBackupMapLayout.map[i] = (gBackupMapLayout.map[i] & 0xf000) | (metatile & 0xfff);
}
}
void MapGridSetMetatileEntryAt(int x, int y, u16 metatile)
{
int i;
if (x >= 0 && x < gUnknown_03005DC0.width
&& y >= 0 && y < gUnknown_03005DC0.height)
if (x >= 0 && x < gBackupMapLayout.width
&& y >= 0 && y < gBackupMapLayout.height)
{
i = x + gUnknown_03005DC0.width * y;
gUnknown_03005DC0.map[i] = metatile;
i = x + gBackupMapLayout.width * y;
gBackupMapLayout.map[i] = metatile;
}
}
@ -507,76 +515,75 @@ void save_serialize_map(void)
u16 *mapView;
int width;
mapView = gSaveBlock1Ptr->mapView;
width = gUnknown_03005DC0.width;
width = gBackupMapLayout.width;
x = gSaveBlock1Ptr->pos.x;
y = gSaveBlock1Ptr->pos.y;
for (i = y; i < y + 14; i++)
{
for (j = x; j < x + 15; j++)
{
*mapView++ = gUnknown_02032318[width * i + j];
*mapView++ = gBackupMapData[width * i + j];
}
}
}
int sub_8088438(void)
static bool32 SavedMapViewIsEmpty(void)
{
u16 i;
u32 r2;
r2 = 0;
u32 marker = 0;
// BUG: This loop extends past the bounds of the mapView array. Its size is only 0x100.
for (i = 0; i < 0x200; i++)
{
r2 |= gSaveBlock1Ptr->mapView[i];
}
if (r2 == 0)
{
return 1;
}
return 0;
marker |= gSaveBlock1Ptr->mapView[i];
if (marker == 0)
return TRUE;
else
return FALSE;
}
void sav2_mapdata_clear(void)
static void ClearSavedMapView(void)
{
CpuFill16(0, gSaveBlock1Ptr->mapView, sizeof(gSaveBlock1Ptr->mapView));
}
void mapdata_from_sav2(void)
static void LoadSavedMapView(void)
{
u8 a0;
u8 yMode;
int i, j;
int x, y;
u16 *mapView;
int width;
mapView = gSaveBlock1Ptr->mapView;
if (!sub_8088438())
if (!SavedMapViewIsEmpty())
{
width = gUnknown_03005DC0.width;
width = gBackupMapLayout.width;
x = gSaveBlock1Ptr->pos.x;
y = gSaveBlock1Ptr->pos.y;
for (i = y; i < y + 14; i++)
{
if (i == y && i != 0)
a0 = 0;
yMode = 0;
else if (i == y + 13 && i != gMapHeader.mapLayout->height - 1)
a0 = 1;
yMode = 1;
else
a0 = -1;
yMode = 0xFF;
for (j = x; j < x + 15; j++)
{
if (!sub_8088BF0(&gUnknown_02032318[j + width * i], width, a0))
gUnknown_02032318[j + width * i] = *mapView;
if (!SkipCopyingMetatileFromSavedMap(&gBackupMapData[j + width * i], width, yMode))
gBackupMapData[j + width * i] = *mapView;
mapView++;
}
}
for (j = x; j < x + 15; j++)
{
if (y != 0)
sub_80D423C(j, y - 1);
FixLongGrassMetatilesWindowTop(j, y - 1);
if (i < gMapHeader.mapLayout->height - 1)
sub_80D42B8(j, y + 13);
FixLongGrassMetatilesWindowBottom(j, y + 13);
}
sav2_mapdata_clear();
ClearSavedMapView();
}
}
@ -592,7 +599,7 @@ void sub_80885C4(u8 a1)
int x, y;
int i, j;
mapView = gSaveBlock1Ptr->mapView;
width = gUnknown_03005DC0.width;
width = gBackupMapLayout.width;
r9 = 0;
r8 = 0;
x0 = gSaveBlock1Ptr->pos.x;
@ -627,13 +634,13 @@ void sub_80885C4(u8 a1)
desti = width * (y + y0);
srci = (y + r8) * 15 + r9;
src = &mapView[srci + i];
dest = &gUnknown_02032318[x0 + desti + j];
dest = &gBackupMapData[x0 + desti + j];
*dest = *src;
i++;
j++;
}
}
sav2_mapdata_clear();
ClearSavedMapView();
}
int GetMapBorderIdAt(int x, int y)
@ -641,12 +648,12 @@ int GetMapBorderIdAt(int x, int y)
struct MapLayout const *mapLayout;
u16 block, block2;
int i, j;
if (x >= 0 && x < gUnknown_03005DC0.width
&& y >= 0 && y < gUnknown_03005DC0.height)
if (x >= 0 && x < gBackupMapLayout.width
&& y >= 0 && y < gBackupMapLayout.height)
{
i = gUnknown_03005DC0.width;
i = gBackupMapLayout.width;
i *= y;
block = gUnknown_03005DC0.map[x + i];
block = gBackupMapLayout.map[x + i];
if (block == 0x3ff)
{
goto fail;
@ -668,9 +675,9 @@ fail:
return -1;
success:
if (x >= (gUnknown_03005DC0.width - 8))
if (x >= (gBackupMapLayout.width - 8))
{
if (!gUnknown_02037340.east)
if (!gMapConnectionFlags.east)
{
return -1;
}
@ -678,15 +685,15 @@ success:
}
else if (x < 7)
{
if (!gUnknown_02037340.west)
if (!gMapConnectionFlags.west)
{
return -1;
}
return CONNECTION_WEST;
}
else if (y >= (gUnknown_03005DC0.height - 7))
else if (y >= (gBackupMapLayout.height - 7))
{
if (!gUnknown_02037340.south)
if (!gMapConnectionFlags.south)
{
return -1;
}
@ -694,7 +701,7 @@ success:
}
else if (y < 7)
{
if (!gUnknown_02037340.north)
if (!gMapConnectionFlags.north)
{
return -1;
}
@ -891,13 +898,13 @@ void sub_8088B3C(u16 x, u16 y)
gSaveBlock1Ptr->pos.y = y - 7;
}
void sav1_camera_get_focus_coords(u16 *x, u16 *y)
void GetCameraFocusCoords(u16 *x, u16 *y)
{
*x = gSaveBlock1Ptr->pos.x + 7;
*y = gSaveBlock1Ptr->pos.y + 7;
}
void SetCameraCoords(u16 x, u16 y)
void SetPlayerCoords(u16 x, u16 y)
{
gSaveBlock1Ptr->pos.x = x;
gSaveBlock1Ptr->pos.y = y;
@ -911,26 +918,26 @@ void GetCameraCoords(u16 *x, u16 *y)
void sub_8088B94(int x, int y, int a2)
{
if (x >= 0 && x < gUnknown_03005DC0.width && y >= 0 && y < gUnknown_03005DC0.height)
if (x >= 0 && x < gBackupMapLayout.width && y >= 0 && y < gBackupMapLayout.height)
{
if (a2 != 0)
gUnknown_03005DC0.map[x + gUnknown_03005DC0.width * y] |= 0xC00;
gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= 0xC00;
else
gUnknown_03005DC0.map[x + gUnknown_03005DC0.width * y] &= 0xF3FF;
gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= 0xF3FF;
}
}
bool8 sub_8088BF0(u16* a0, u16 a1, u8 a2)
static bool8 SkipCopyingMetatileFromSavedMap(u16* mapMetatilePtr, u16 mapWidth, u8 yMode)
{
if (a2 == 0xFF)
if (yMode == 0xFF)
return FALSE;
if (a2 == 0)
a0 -= a1;
if (yMode == 0)
mapMetatilePtr -= mapWidth;
else
a0 += a1;
mapMetatilePtr += mapWidth;
if (sub_80FADE4(*a0 & 0x3FF, a2) == 1)
if (sub_80FADE4(*mapMetatilePtr & 0x3FF, yMode) == 1)
return TRUE;
return FALSE;
}

View File

@ -624,7 +624,7 @@ static void CutGrassSpriteCallbackEnd(struct Sprite *sprite)
ScriptContext1_SetupScript(FarawayIsland_Interior_EventScript_267EDB);
}
void sub_80D423C(s16 x, s16 y)
void FixLongGrassMetatilesWindowTop(s16 x, s16 y)
{
u8 metatileBehavior = MapGridGetMetatileBehaviorAt(x, y);
if (MetatileBehavior_IsLongGrass_Duplicate(metatileBehavior))
@ -647,7 +647,7 @@ void sub_80D423C(s16 x, s16 y)
}
}
void sub_80D42B8(s16 x, s16 y)
void FixLongGrassMetatilesWindowBottom(s16 x, s16 y)
{
if (MapGridGetMetatileIdAt(x, y) == METATILE_ID_GRASS)
{

View File

@ -1166,23 +1166,23 @@ void GetShieldToyTVDecorationInfo(void)
}
}
bool8 sub_80FADE4(u16 arg0, u8 arg1)
bool8 sub_80FADE4(u16 metatileId, u8 arg1)
{
if (!CurrentMapIsSecretBase())
return FALSE;
if (!arg1)
{
if (arg0 == 0x285 || arg0 == 0x286)
if (metatileId == 0x285 || metatileId == 0x286)
return TRUE;
if (arg0 == 0x237)
if (metatileId == 0x237)
return TRUE;
}
else
{
if (arg0 == 0x28d)
if (metatileId == 0x28d)
return TRUE;
if (arg0 == 0x23F)
if (metatileId == 0x23F)
return TRUE;
}

View File

@ -102,7 +102,6 @@ extern void ApplyNewEncryptionKeyToWord(u32 *word, u32 newKey);
extern void mapheader_run_script_with_tag_x5(void);
extern void ResetFieldTasksArgs(void);
extern void sub_80A0A2C(void);
extern void not_trainer_hill_battle_pyramid(void);
extern void apply_map_tileset2_palette(const struct MapLayout *);
extern void copy_map_tileset2_to_vram_2(const struct MapLayout *);
extern void RestartWildEncounterImmunitySteps(void);
@ -126,11 +125,7 @@ extern void sub_80AF168(void);
extern void sub_80AF3C8(void);
extern void ExecuteTruckSequence(void);
extern void sub_80A0A38(void);
extern void trainer_hill_map_load_related(void);
extern void sub_8087D74(void);
extern void battle_pyramid_map_load_related(u8);
extern void WriteFlashScanlineEffectBuffer(u8);
extern void sub_80E9238(u8);
extern void sub_81AA2F8(void);
extern void sub_8195E10(void);
extern void sub_80EDB44(void);
@ -149,7 +144,6 @@ extern void SetUpFieldTasks(void);
extern void ShowStartMenu(void);
extern void sub_80AEE84(void);
extern void mapldr_default(void);
extern void sub_8088B3C(u16, u16);
extern bool32 sub_800F0B8(void);
extern bool32 sub_8009F3C(void);
extern void sub_8010198(void);
@ -870,7 +864,7 @@ void mliX_load_map(u8 mapGroup, u8 mapNum)
SetDefaultFlashLevel();
Overworld_ClearSavedMusic();
mapheader_run_script_with_tag_x3();
not_trainer_hill_battle_pyramid();
InitMap();
copy_map_tileset2_to_vram_2(gMapHeader.mapLayout);
apply_map_tileset2_palette(gMapHeader.mapLayout);
@ -925,15 +919,15 @@ static void mli0_load_map(u32 a1)
UpdateLocationHistoryForRoamer();
RoamerMoveToOtherLocationSet();
if (gMapHeader.mapLayoutId == 0x169)
battle_pyramid_map_load_related(0);
InitBattlePyramidMap(0);
else if (InTrainerHill())
trainer_hill_map_load_related();
InitTrainerHillMap();
else
not_trainer_hill_battle_pyramid();
InitMap();
if (a1 != 1 && indoors)
{
UpdateTVScreensOnMap(gUnknown_03005DC0.width, gUnknown_03005DC0.height);
UpdateTVScreensOnMap(gBackupMapLayout.width, gBackupMapLayout.height);
sub_80E9238(1);
}
}
@ -1774,11 +1768,11 @@ void CB2_ContinueSavedGame(void)
DoTimeBasedEvents();
sub_8084788();
if (gMapHeader.mapLayoutId == 0x169)
battle_pyramid_map_load_related(1);
InitBattlePyramidMap(1);
else if (trainerHillMapId != 0)
trainer_hill_map_load_related();
InitTrainerHillMap();
else
sub_8087D74();
InitMapFromSavedGame();
PlayTimeCounter_Start();
ScriptContext1_Init();
@ -2216,7 +2210,7 @@ static void mli4_mapscripts_and_other(void)
gTotalCameraPixelOffsetX = 0;
gTotalCameraPixelOffsetY = 0;
ResetEventObjects();
sav1_camera_get_focus_coords(&x, &y);
GetCameraFocusCoords(&x, &y);
player = GetInitialPlayerAvatarState();
InitPlayerAvatar(x, y, player->direction, gSaveBlock2Ptr->playerGender);
SetPlayerAvatarTransitionFlags(player->transitionFlags);
@ -2251,7 +2245,7 @@ static void sub_8086AC8(void)
static void sub_8086AE4(void)
{
u16 x, y;
sav1_camera_get_focus_coords(&x, &y);
GetCameraFocusCoords(&x, &y);
sub_8088B3C(x + gUnknown_03005DB4, y);
}
@ -2260,7 +2254,7 @@ static void sub_8086B14(void)
u16 i;
u16 x, y;
sav1_camera_get_focus_coords(&x, &y);
GetCameraFocusCoords(&x, &y);
x -= gUnknown_03005DB4;
for (i = 0; i < gFieldLinkPlayerCount; i++)

View File

@ -862,13 +862,13 @@ void SetTVMetatilesOnMap(int width, int height, u16 tileId)
void TurnOffTVScreen(void)
{
SetTVMetatilesOnMap(gUnknown_03005DC0.width, gUnknown_03005DC0.height, 0x0002);
SetTVMetatilesOnMap(gBackupMapLayout.width, gBackupMapLayout.height, 0x0002);
DrawWholeMapView();
}
void TurnOnTVScreen(void)
{
SetTVMetatilesOnMap(gUnknown_03005DC0.width, gUnknown_03005DC0.height, 0x0003);
SetTVMetatilesOnMap(gBackupMapLayout.width, gBackupMapLayout.height, 0x0003);
DrawWholeMapView();
}