summaryrefslogtreecommitdiff
path: root/src/fieldmap.c
diff options
context:
space:
mode:
authorMarcus Huderle <huderlem@gmail.com>2019-03-23 09:39:46 -0500
committerMarcus Huderle <huderlem@gmail.com>2019-03-23 09:39:46 -0500
commit65391a1eb2979dc050dd4a98afea02bb0ef310ea (patch)
treee31a90d0966cec7e8713ead9ca8083d439c8d9b5 /src/fieldmap.c
parenteb48cc2f7eefc1e56c2dcec21c38381b4534b897 (diff)
parentabe56579c107af58e6f3a43968ba2257ff358189 (diff)
Merge remote-tracking branch 'upstream/master' into use_pokeblock
# Conflicts: # src/use_pokeblock.c
Diffstat (limited to 'src/fieldmap.c')
-rw-r--r--src/fieldmap.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/fieldmap.c b/src/fieldmap.c
index f67f61ede..a96b71c0f 100644
--- a/src/fieldmap.c
+++ b/src/fieldmap.c
@@ -1,4 +1,5 @@
#include "global.h"
+#include "battle_pyramid.h"
#include "bg.h"
#include "fieldmap.h"
#include "fldeff.h"
@@ -15,8 +16,6 @@
#include "tv.h"
#include "constants/rgb.h"
-extern void sub_81AA078(u16*, u8);
-
struct ConnectionFlags
{
u8 south:1;
@@ -54,7 +53,7 @@ void InitMap(void)
{
InitMapLayoutData(&gMapHeader);
sub_80E8EE0(gMapHeader.events);
- mapheader_run_script_with_tag_x1();
+ RunOnLoadMapScript();
}
void InitMapFromSavedGame(void)
@@ -63,14 +62,14 @@ void InitMapFromSavedGame(void)
sub_80E9238(0);
sub_80E8EE0(gMapHeader.events);
LoadSavedMapView();
- mapheader_run_script_with_tag_x1();
+ RunOnLoadMapScript();
UpdateTVScreensOnMap(gBackupMapLayout.width, gBackupMapLayout.height);
}
-void InitBattlePyramidMap(u8 a0)
+void InitBattlePyramidMap(bool8 setPlayerPosition)
{
CpuFastFill(0x03ff03ff, gBackupMapData, sizeof(gBackupMapData));
- sub_81AA078(gBackupMapData, a0);
+ GenerateBattlePyramidFloorLayout(gBackupMapData, setPlayerPosition);
}
void InitTrainerHillMap(void)
@@ -384,15 +383,15 @@ u8 MapGridGetZCoordAt(int x, int y)
i = (x + 1) & 1;
i += ((y + 1) & 1) * 2;
block = gMapHeader.mapLayout->border[i];
- block |= 0xc00;
+ block |= METATILE_COLLISION_MASK;
}
- if (block == 0x3ff)
+ if (block == METATILE_ID_UNDEFINED)
{
return 0;
}
- return block >> 12;
+ return block >> METATILE_ELEVATION_SHIFT;
}
u8 MapGridIsImpassableAt(int x, int y)
@@ -412,13 +411,13 @@ u8 MapGridIsImpassableAt(int x, int y)
i = (x + 1) & 1;
i += ((y + 1) & 1) * 2;
block = gMapHeader.mapLayout->border[i];
- block |= 0xc00;
+ block |= METATILE_COLLISION_MASK;
}
- if (block == 0x3ff)
+ if (block == METATILE_ID_UNDEFINED)
{
return 1;
}
- return (block & 0xc00) >> 10;
+ return (block & METATILE_COLLISION_MASK) >> METATILE_COLLISION_SHIFT;
}
u32 MapGridGetMetatileIdAt(int x, int y)
@@ -440,18 +439,19 @@ u32 MapGridGetMetatileIdAt(int x, int y)
mapLayout = gMapHeader.mapLayout;
i = (x + 1) & 1;
i += ((y + 1) & 1) * 2;
- block = mapLayout->border[i] | 0xc00;
+ block = mapLayout->border[i] | METATILE_COLLISION_MASK;
}
- if (block == 0x3ff)
+ if (block == METATILE_ID_UNDEFINED)
{
border = gMapHeader.mapLayout->border;
j = (x + 1) & 1;
j += ((y + 1) & 1) * 2;
block2 = gMapHeader.mapLayout->border[j];
- block2 |= 0xc00;
- return block2 & block;
+ // This OR is completely pointless.
+ block2 |= METATILE_COLLISION_MASK;
+ return block2 & METATILE_ID_MASK;
}
- return block & 0x3ff;
+ return block & METATILE_ID_MASK;
}
u32 MapGridGetMetatileBehaviorAt(int x, int y)
@@ -465,7 +465,7 @@ u8 MapGridGetMetatileLayerTypeAt(int x, int y)
{
u16 metatile;
metatile = MapGridGetMetatileIdAt(x, y);
- return (GetBehaviorByMetatileId(metatile) & 0xf000) >> 12;
+ return (GetBehaviorByMetatileId(metatile) & METATILE_ELEVATION_MASK) >> METATILE_ELEVATION_SHIFT;
}
void MapGridSetMetatileIdAt(int x, int y, u16 metatile)
@@ -475,7 +475,7 @@ void MapGridSetMetatileIdAt(int x, int y, u16 metatile)
&& y >= 0 && y < gBackupMapLayout.height)
{
i = x + y * gBackupMapLayout.width;
- gBackupMapLayout.map[i] = (gBackupMapLayout.map[i] & 0xf000) | (metatile & 0xfff);
+ gBackupMapLayout.map[i] = (gBackupMapLayout.map[i] & METATILE_ELEVATION_MASK) | (metatile & ~METATILE_ELEVATION_MASK);
}
}
@@ -655,7 +655,7 @@ int GetMapBorderIdAt(int x, int y)
i = gBackupMapLayout.width;
i *= y;
block = gBackupMapLayout.map[x + i];
- if (block == 0x3ff)
+ if (block == METATILE_ID_UNDEFINED)
{
goto fail;
}
@@ -665,8 +665,8 @@ int GetMapBorderIdAt(int x, int y)
mapLayout = gMapHeader.mapLayout;
j = (x + 1) & 1;
j += ((y + 1) & 1) * 2;
- block2 = 0xc00 | mapLayout->border[j];
- if (block2 == 0x3ff)
+ block2 = METATILE_COLLISION_MASK | mapLayout->border[j];
+ if (block2 == METATILE_ID_UNDEFINED)
{
goto fail;
}
@@ -776,7 +776,7 @@ bool8 CameraMove(int x, int y)
old_y = gSaveBlock1Ptr->pos.y;
connection = sub_8088950(direction, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y);
sub_80887F8(connection, direction, x, y);
- mliX_load_map(connection->mapGroup, connection->mapNum);
+ LoadMapFromCameraTransition(connection->mapGroup, connection->mapNum);
gCamera.active = TRUE;
gCamera.x = old_x - gSaveBlock1Ptr->pos.x;
gCamera.y = old_y - gSaveBlock1Ptr->pos.y;
@@ -922,9 +922,9 @@ void sub_8088B94(int x, int y, int a2)
if (x >= 0 && x < gBackupMapLayout.width && y >= 0 && y < gBackupMapLayout.height)
{
if (a2 != 0)
- gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= 0xC00;
+ gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= METATILE_COLLISION_MASK;
else
- gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= 0xF3FF;
+ gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= ~METATILE_COLLISION_MASK;
}
}
@@ -938,7 +938,7 @@ static bool8 SkipCopyingMetatileFromSavedMap(u16* mapMetatilePtr, u16 mapWidth,
else
mapMetatilePtr += mapWidth;
- if (sub_80FADE4(*mapMetatilePtr & 0x3FF, yMode) == 1)
+ if (sub_80FADE4(*mapMetatilePtr & METATILE_ID_MASK, yMode) == 1)
return TRUE;
return FALSE;
}