Add macros for metatile manipulation
This commit is contained in:
@@ -383,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 |= MAP_IMPASSABLE_MASK;
|
||||
}
|
||||
|
||||
if (block == 0x3ff)
|
||||
if (block == MAP_UNDEFINED_METATILE_ID)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return block >> 12;
|
||||
return block >> MAP_TILE_ELEVATION_SHIFT;
|
||||
}
|
||||
|
||||
u8 MapGridIsImpassableAt(int x, int y)
|
||||
@@ -411,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 |= MAP_IMPASSABLE_MASK;
|
||||
}
|
||||
if (block == 0x3ff)
|
||||
if (block == MAP_UNDEFINED_METATILE_ID)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return (block & 0xc00) >> 10;
|
||||
return (block & MAP_IMPASSABLE_MASK) >> MAP_IMPASSABLE_SHIFT;
|
||||
}
|
||||
|
||||
u32 MapGridGetMetatileIdAt(int x, int y)
|
||||
@@ -439,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] | MAP_IMPASSABLE_MASK;
|
||||
}
|
||||
if (block == 0x3ff)
|
||||
if (block == MAP_UNDEFINED_METATILE_ID)
|
||||
{
|
||||
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 |= MAP_IMPASSABLE_MASK;
|
||||
return block2 & MAP_METATILE_ID_MASK;
|
||||
}
|
||||
return block & 0x3ff;
|
||||
return block & MAP_METATILE_ID_MASK;
|
||||
}
|
||||
|
||||
u32 MapGridGetMetatileBehaviorAt(int x, int y)
|
||||
@@ -464,7 +465,7 @@ u8 MapGridGetMetatileLayerTypeAt(int x, int y)
|
||||
{
|
||||
u16 metatile;
|
||||
metatile = MapGridGetMetatileIdAt(x, y);
|
||||
return (GetBehaviorByMetatileId(metatile) & 0xf000) >> 12;
|
||||
return (GetBehaviorByMetatileId(metatile) & MAP_TILE_ELEVATION_MASK) >> MAP_TILE_ELEVATION_SHIFT;
|
||||
}
|
||||
|
||||
void MapGridSetMetatileIdAt(int x, int y, u16 metatile)
|
||||
@@ -474,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] & MAP_TILE_ELEVATION_MASK) | (metatile & ~MAP_TILE_ELEVATION_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -654,7 +655,7 @@ int GetMapBorderIdAt(int x, int y)
|
||||
i = gBackupMapLayout.width;
|
||||
i *= y;
|
||||
block = gBackupMapLayout.map[x + i];
|
||||
if (block == 0x3ff)
|
||||
if (block == MAP_UNDEFINED_METATILE_ID)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
@@ -664,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 = MAP_IMPASSABLE_MASK | mapLayout->border[j];
|
||||
if (block2 == MAP_UNDEFINED_METATILE_ID)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
@@ -921,7 +922,7 @@ 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] |= MAP_IMPASSABLE_MASK;
|
||||
else
|
||||
gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= 0xF3FF;
|
||||
}
|
||||
@@ -937,7 +938,7 @@ static bool8 SkipCopyingMetatileFromSavedMap(u16* mapMetatilePtr, u16 mapWidth,
|
||||
else
|
||||
mapMetatilePtr += mapWidth;
|
||||
|
||||
if (sub_80FADE4(*mapMetatilePtr & 0x3FF, yMode) == 1)
|
||||
if (sub_80FADE4(*mapMetatilePtr & MAP_METATILE_ID_MASK, yMode) == 1)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user