Disambiguate fieldmap names

This commit is contained in:
GriffinR 2022-01-19 10:15:32 -05:00
parent f127e64a3c
commit a8b466dc80
14 changed files with 120 additions and 110 deletions

View File

@ -1053,7 +1053,7 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt
for (x16 = x; x16 < (x + width); x16++) for (x16 = x; x16 < (x + width); x16++)
{ {
CopyTileMapEntry(&firstTileNum, &((u16*)sGpuBgConfigs2[bg].tilemap)[(u16)GetTileMapIndexFromCoords(x16, y16, attribute, mode, mode2)], paletteSlot, 0, 0); CopyTileMapEntry(&firstTileNum, &((u16*)sGpuBgConfigs2[bg].tilemap)[(u16)GetTileMapIndexFromCoords(x16, y16, attribute, mode, mode2)], paletteSlot, 0, 0);
firstTileNum = (firstTileNum & (METATILE_COLLISION_MASK | METATILE_ELEVATION_MASK)) + ((firstTileNum + tileNumDelta) & METATILE_ID_MASK); firstTileNum = (firstTileNum & (MAPGRID_COLLISION_MASK | MAPGRID_ELEVATION_MASK)) + ((firstTileNum + tileNumDelta) & MAPGRID_METATILE_ID_MASK);
} }
} }
break; break;
@ -1064,7 +1064,7 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt
for (x16 = x; x16 < (x + width); x16++) for (x16 = x; x16 < (x + width); x16++)
{ {
((u8*)sGpuBgConfigs2[bg].tilemap)[(y16 * mode3) + x16] = firstTileNum; ((u8*)sGpuBgConfigs2[bg].tilemap)[(y16 * mode3) + x16] = firstTileNum;
firstTileNum = (firstTileNum & (METATILE_COLLISION_MASK | METATILE_ELEVATION_MASK)) + ((firstTileNum + tileNumDelta) & METATILE_ID_MASK); firstTileNum = (firstTileNum & (MAPGRID_COLLISION_MASK | MAPGRID_ELEVATION_MASK)) + ((firstTileNum + tileNumDelta) & MAPGRID_METATILE_ID_MASK);
} }
} }
break; break;

View File

@ -29,7 +29,7 @@ void GetCameraCoords(u16*, u16*);
bool8 MapGridIsImpassableAt(int, int); bool8 MapGridIsImpassableAt(int, int);
int GetMapBorderIdAt(int x, int y); int GetMapBorderIdAt(int x, int y);
bool32 CanCameraMoveInDirection(int direction); bool32 CanCameraMoveInDirection(int direction);
u16 GetBehaviorByMetatileId(u16 metatileId); u16 GetMetatileAttributesById(u16 metatileId);
void GetCameraFocusCoords(u16 *x, u16 *y); void GetCameraFocusCoords(u16 *x, u16 *y);
u8 MapGridGetMetatileLayerTypeAt(int x, int y); u8 MapGridGetMetatileLayerTypeAt(int x, int y);
u8 MapGridGetZCoordAt(int x, int y); u8 MapGridGetZCoordAt(int x, int y);

View File

@ -1,13 +1,24 @@
#ifndef GUARD_GLOBAL_FIELDMAP_H #ifndef GUARD_GLOBAL_FIELDMAP_H
#define GUARD_GLOBAL_FIELDMAP_H #define GUARD_GLOBAL_FIELDMAP_H
#define METATILE_BEHAVIOR_MASK 0x00FF // Masks/shifts for blocks in the map grid
#define METATILE_COLLISION_MASK 0x0C00 // Map grid blocks consist of a 10 bit metatile id, a 2 bit collision value, and a 4 bit elevation value
#define METATILE_ID_MASK 0x03FF // This is the data stored in each data/layouts/*/map.bin and border.bin file
#define METATILE_ID_UNDEFINED 0x03FF #define MAPGRID_METATILE_ID_MASK 0x03FF // Bits 1-10
#define METATILE_ELEVATION_SHIFT 12 #define MAPGRID_COLLISION_MASK 0x0C00 // Bits 11-12
#define METATILE_COLLISION_SHIFT 10 #define MAPGRID_ELEVATION_MASK 0xF000 // Bits 13-16
#define METATILE_ELEVATION_MASK 0xF000 #define MAPGRID_COLLISION_SHIFT 10
#define MAPGRID_ELEVATION_SHIFT 12
// An undefined map grid block has all metatile id bits set and nothing else
#define MAPGRID_UNDEFINED MAPGRID_METATILE_ID_MASK
// Masks/shifts for metatile attributes
// Metatile attributes consist of an 8 bit behavior value, 4 unused bits, and a 4 bit layer type value
// This is the data stored in each data/tilesets/*/*/metatile_attributes.bin file
#define METATILE_ATTR_BEHAVIOR_MASK 0x00FF // Bits 1-8
#define METATILE_ATTR_LAYER_MASK 0xF000 // Bits 13-16
#define METATILE_ATTR_LAYER_SHIFT 12
enum { enum {
METATILE_LAYER_TYPE_NORMAL, // Metatile uses middle and top bg layers METATILE_LAYER_TYPE_NORMAL, // Metatile uses middle and top bg layers

View File

@ -1239,7 +1239,7 @@ static u8 GetPostBattleDirectionHintTextIndex(int *hintType, u8 minDistanceForEx
{ {
for (x = 0; x < 32; x++) for (x = 0; x < 32; x++)
{ {
if ((map[x] & METATILE_ID_MASK) == METATILE_BattlePyramid_Exit) if ((map[x] & MAPGRID_METATILE_ID_MASK) == METATILE_BattlePyramid_Exit)
{ {
x += MAP_OFFSET - gObjectEvents[gSelectedObjectEvent].initialCoords.x; x += MAP_OFFSET - gObjectEvents[gSelectedObjectEvent].initialCoords.x;
y += MAP_OFFSET - gObjectEvents[gSelectedObjectEvent].initialCoords.y; y += MAP_OFFSET - gObjectEvents[gSelectedObjectEvent].initialCoords.y;
@ -1545,7 +1545,7 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio
{ {
for (x = 0; x < mapLayout->width; x++) for (x = 0; x < mapLayout->width; x++)
{ {
if ((layoutMap[x] & METATILE_ID_MASK) != METATILE_BattlePyramid_Exit) if ((layoutMap[x] & MAPGRID_METATILE_ID_MASK) != METATILE_BattlePyramid_Exit)
{ {
map[x] = layoutMap[x]; map[x] = layoutMap[x];
} }
@ -1556,7 +1556,7 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio
gSaveBlock1Ptr->pos.x = (mapLayout->width * (i % 4)) + x; gSaveBlock1Ptr->pos.x = (mapLayout->width * (i % 4)) + x;
gSaveBlock1Ptr->pos.y = (mapLayout->height * (i / 4)) + y; gSaveBlock1Ptr->pos.y = (mapLayout->height * (i / 4)) + y;
} }
map[x] = (layoutMap[x] & (METATILE_ELEVATION_MASK | METATILE_COLLISION_MASK)) | METATILE_BattlePyramid_Floor; map[x] = (layoutMap[x] & (MAPGRID_ELEVATION_MASK | MAPGRID_COLLISION_MASK)) | METATILE_BattlePyramid_Floor;
} }
else else
{ {

View File

@ -80,9 +80,9 @@ void DoBrailleDigEffect(void)
MapGridSetMetatileIdAt( 9 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopLeft); MapGridSetMetatileIdAt( 9 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopLeft);
MapGridSetMetatileIdAt(10 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid); MapGridSetMetatileIdAt(10 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid);
MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopRight); MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopRight);
MapGridSetMetatileIdAt( 9 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomLeft | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt( 9 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomLeft | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(10 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomMid); MapGridSetMetatileIdAt(10 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomMid);
MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomRight | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomRight | MAPGRID_COLLISION_MASK);
DrawWholeMapView(); DrawWholeMapView();
PlaySE(SE_BANG); PlaySE(SE_BANG);
FlagSet(FLAG_SYS_BRAILLE_DIG); FlagSet(FLAG_SYS_BRAILLE_DIG);
@ -207,9 +207,9 @@ static void DoBrailleRegirockEffect(void)
MapGridSetMetatileIdAt(7 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopLeft); MapGridSetMetatileIdAt(7 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopLeft);
MapGridSetMetatileIdAt(8 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid); MapGridSetMetatileIdAt(8 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid);
MapGridSetMetatileIdAt(9 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopRight); MapGridSetMetatileIdAt(9 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopRight);
MapGridSetMetatileIdAt(7 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomLeft | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(7 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomLeft | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(8 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomMid); MapGridSetMetatileIdAt(8 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomMid);
MapGridSetMetatileIdAt(9 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomRight | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(9 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomRight | MAPGRID_COLLISION_MASK);
DrawWholeMapView(); DrawWholeMapView();
PlaySE(SE_BANG); PlaySE(SE_BANG);
FlagSet(FLAG_SYS_REGIROCK_PUZZLE_COMPLETED); FlagSet(FLAG_SYS_REGIROCK_PUZZLE_COMPLETED);
@ -246,9 +246,9 @@ static void DoBrailleRegisteelEffect(void)
MapGridSetMetatileIdAt(7 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopLeft); MapGridSetMetatileIdAt(7 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopLeft);
MapGridSetMetatileIdAt(8 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid); MapGridSetMetatileIdAt(8 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid);
MapGridSetMetatileIdAt(9 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopRight); MapGridSetMetatileIdAt(9 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopRight);
MapGridSetMetatileIdAt(7 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomLeft | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(7 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomLeft | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(8 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomMid); MapGridSetMetatileIdAt(8 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomMid);
MapGridSetMetatileIdAt(9 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomRight | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(9 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomRight | MAPGRID_COLLISION_MASK);
DrawWholeMapView(); DrawWholeMapView();
PlaySE(SE_BANG); PlaySE(SE_BANG);
FlagSet(FLAG_SYS_REGISTEEL_PUZZLE_COMPLETED); FlagSet(FLAG_SYS_REGISTEEL_PUZZLE_COMPLETED);

View File

@ -1185,10 +1185,10 @@ static u16 GetDecorationElevation(u8 decoration, u8 tileIndex)
switch (decoration) switch (decoration)
{ {
case DECOR_STAND: case DECOR_STAND:
elevation = sDecorationStandElevations[tileIndex] << METATILE_ELEVATION_SHIFT; elevation = sDecorationStandElevations[tileIndex] << MAPGRID_ELEVATION_SHIFT;
return elevation; return elevation;
case DECOR_SLIDE: case DECOR_SLIDE:
elevation = sDecorationSlideElevation[tileIndex] << METATILE_ELEVATION_SHIFT; elevation = sDecorationSlideElevation[tileIndex] << MAPGRID_ELEVATION_SHIFT;
return elevation; return elevation;
default: default:
return elevation; return elevation;
@ -1199,7 +1199,7 @@ static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight,
{ {
u16 i, j; u16 i, j;
s16 x, y; s16 x, y;
u16 behavior; u16 attributes;
u16 impassableFlag; u16 impassableFlag;
u16 overlapsWall; u16 overlapsWall;
u16 elevation; u16 elevation;
@ -1210,9 +1210,9 @@ static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight,
for (i = 0; i < decWidth; i++) for (i = 0; i < decWidth; i++)
{ {
x = mapX + i; x = mapX + i;
behavior = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + gDecorations[decoration].tiles[j * decWidth + i]); attributes = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + gDecorations[decoration].tiles[j * decWidth + i]);
if (MetatileBehavior_IsSecretBaseImpassable(behavior) == TRUE || (gDecorations[decoration].permission != DECORPERM_PASS_FLOOR && (behavior >> METATILE_ELEVATION_SHIFT))) if (MetatileBehavior_IsSecretBaseImpassable(attributes) == TRUE || (gDecorations[decoration].permission != DECORPERM_PASS_FLOOR && (attributes >> METATILE_ATTR_LAYER_SHIFT)))
impassableFlag = METATILE_COLLISION_MASK; impassableFlag = MAPGRID_COLLISION_MASK;
else else
impassableFlag = 0; impassableFlag = 0;
@ -1471,17 +1471,16 @@ static void AttemptCancelPlaceDecoration(u8 taskId)
DisplayItemMessageOnField(taskId, gStringVar4, CancelDecoratingPrompt); DisplayItemMessageOnField(taskId, gStringVar4, CancelDecoratingPrompt);
} }
// Note: behaviorBy is pre-anded with METATILE_ELEVATION_MASK. static bool8 IsNonBlockNonElevated(u8 behaviorAt, u16 layerType)
static bool8 IsNonBlockNonElevated(u8 behaviorAt, u16 behaviorBy)
{ {
if (MetatileBehavior_IsBlockDecoration(behaviorAt) != TRUE || behaviorBy != 0) if (MetatileBehavior_IsBlockDecoration(behaviorAt) != TRUE || layerType != 0)
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
static bool8 IsntInitialPosition(u8 taskId, s16 x, s16 y, u16 behaviorBy) static bool8 IsntInitialPosition(u8 taskId, s16 x, s16 y, u16 layerType)
{ {
if (x == gTasks[taskId].tInitialX + MAP_OFFSET && y == gTasks[taskId].tInitialY + MAP_OFFSET && behaviorBy != 0) if (x == gTasks[taskId].tInitialX + MAP_OFFSET && y == gTasks[taskId].tInitialY + MAP_OFFSET && layerType != 0)
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
@ -1505,7 +1504,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
u8 i; u8 i;
u8 j; u8 j;
u8 behaviorAt; u8 behaviorAt;
u16 behaviorBy; u16 layerType;
u8 mapY; u8 mapY;
u8 mapX; u8 mapX;
s16 curY; s16 curY;
@ -1524,11 +1523,11 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
{ {
curX = gTasks[taskId].tCursorX + j; curX = gTasks[taskId].tCursorX + j;
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
behaviorBy = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK; layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ATTR_LAYER_MASK;
if (!IsFloorOrBoardAndHole(behaviorAt, decoration)) if (!IsFloorOrBoardAndHole(behaviorAt, decoration))
return FALSE; return FALSE;
if (!IsntInitialPosition(taskId, curX, curY, behaviorBy)) if (!IsntInitialPosition(taskId, curX, curY, layerType))
return FALSE; return FALSE;
behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0); behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0);
@ -1545,11 +1544,11 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
{ {
curX = gTasks[taskId].tCursorX + j; curX = gTasks[taskId].tCursorX + j;
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
behaviorBy = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK; layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ATTR_LAYER_MASK;
if (!MetatileBehavior_IsNormal(behaviorAt) && !IsNonBlockNonElevated(behaviorAt, behaviorBy)) if (!MetatileBehavior_IsNormal(behaviorAt) && !IsNonBlockNonElevated(behaviorAt, layerType))
return FALSE; return FALSE;
if (!IsntInitialPosition(taskId, curX, curY, behaviorBy)) if (!IsntInitialPosition(taskId, curX, curY, layerType))
return FALSE; return FALSE;
if (GetObjectEventIdByXYZ(curX, curY, 0) != OBJECT_EVENTS_COUNT) if (GetObjectEventIdByXYZ(curX, curY, 0) != OBJECT_EVENTS_COUNT)
@ -1562,11 +1561,11 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
{ {
curX = gTasks[taskId].tCursorX + j; curX = gTasks[taskId].tCursorX + j;
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
behaviorBy = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + decoration->tiles[j]) & METATILE_ELEVATION_MASK; layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[j]) & METATILE_ATTR_LAYER_MASK;
if (!MetatileBehavior_IsNormal(behaviorAt) && !MetatileBehavior_IsSecretBaseNorthWall(behaviorAt)) if (!MetatileBehavior_IsNormal(behaviorAt) && !MetatileBehavior_IsSecretBaseNorthWall(behaviorAt))
return FALSE; return FALSE;
if (!IsntInitialPosition(taskId, curX, curY, behaviorBy)) if (!IsntInitialPosition(taskId, curX, curY, layerType))
return FALSE; return FALSE;
behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0); behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0);

View File

@ -650,10 +650,10 @@ void MauvilleGymSetDefaultBarriers(void)
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH2_On); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH2_On);
break; break;
case METATILE_MauvilleGym_GreenBeamH3_Off: case METATILE_MauvilleGym_GreenBeamH3_Off:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH3_On | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH3_On | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_MauvilleGym_GreenBeamH4_Off: case METATILE_MauvilleGym_GreenBeamH4_Off:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH4_On | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH4_On | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_MauvilleGym_RedBeamH1_On: case METATILE_MauvilleGym_RedBeamH1_On:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH1_Off); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH1_Off);
@ -674,37 +674,37 @@ void MauvilleGymSetDefaultBarriers(void)
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH2_On); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH2_On);
break; break;
case METATILE_MauvilleGym_RedBeamH3_Off: case METATILE_MauvilleGym_RedBeamH3_Off:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH3_On | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH3_On | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_MauvilleGym_RedBeamH4_Off: case METATILE_MauvilleGym_RedBeamH4_Off:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH4_On | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH4_On | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_MauvilleGym_GreenBeamV1_On: case METATILE_MauvilleGym_GreenBeamV1_On:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_On | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_On | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_MauvilleGym_GreenBeamV2_On: case METATILE_MauvilleGym_GreenBeamV2_On:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_FloorTile); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_FloorTile);
break; break;
case METATILE_MauvilleGym_RedBeamV1_On: case METATILE_MauvilleGym_RedBeamV1_On:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_Off | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_Off | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_MauvilleGym_RedBeamV2_On: case METATILE_MauvilleGym_RedBeamV2_On:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_FloorTile); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_FloorTile);
break; break;
case METATILE_MauvilleGym_PoleBottom_On: case METATILE_MauvilleGym_PoleBottom_On:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamV1_On | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamV1_On | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_MauvilleGym_FloorTile: case METATILE_MauvilleGym_FloorTile:
if (MapGridGetMetatileIdAt(x, y - 1) == METATILE_MauvilleGym_GreenBeamV1_On) if (MapGridGetMetatileIdAt(x, y - 1) == METATILE_MauvilleGym_GreenBeamV1_On)
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamV2_On | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamV2_On | MAPGRID_COLLISION_MASK);
else else
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamV2_On | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamV2_On | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_MauvilleGym_PoleBottom_Off: case METATILE_MauvilleGym_PoleBottom_Off:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamV1_On | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamV1_On | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_MauvilleGym_PoleTop_Off: case METATILE_MauvilleGym_PoleTop_Off:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleTop_On | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleTop_On | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_MauvilleGym_PoleTop_On: case METATILE_MauvilleGym_PoleTop_On:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleTop_Off); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleTop_Off);
@ -755,10 +755,10 @@ void MauvilleGymDeactivatePuzzle(void)
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH4_Off); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH4_Off);
break; break;
case METATILE_MauvilleGym_GreenBeamV1_On: case METATILE_MauvilleGym_GreenBeamV1_On:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_On | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_On | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_MauvilleGym_RedBeamV1_On: case METATILE_MauvilleGym_RedBeamV1_On:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_Off | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_Off | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_MauvilleGym_GreenBeamV2_On: case METATILE_MauvilleGym_GreenBeamV2_On:
case METATILE_MauvilleGym_RedBeamV2_On: case METATILE_MauvilleGym_RedBeamV2_On:
@ -867,8 +867,8 @@ static void PetalburgGymSetDoorMetatiles(u8 roomNumber, u16 metatileId)
} }
for (i = 0; i < nDoors; i++) for (i = 0; i < nDoors; i++)
{ {
MapGridSetMetatileIdAt(doorCoordsX[i] + MAP_OFFSET, doorCoordsY[i] + MAP_OFFSET, metatileId | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(doorCoordsX[i] + MAP_OFFSET, doorCoordsY[i] + MAP_OFFSET, metatileId | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(doorCoordsX[i] + MAP_OFFSET, doorCoordsY[i] + MAP_OFFSET + 1, (metatileId + 8) | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(doorCoordsX[i] + MAP_OFFSET, doorCoordsY[i] + MAP_OFFSET + 1, (metatileId + 8) | MAPGRID_COLLISION_MASK);
} }
DrawWholeMapView(); DrawWholeMapView();
} }
@ -1040,7 +1040,7 @@ static void PCTurnOnEffect_1(s16 isPcTurnedOn, s8 dx, s8 dy)
else if (gSpecialVar_0x8004 == PC_LOCATION_MAYS_HOUSE) else if (gSpecialVar_0x8004 == PC_LOCATION_MAYS_HOUSE)
tileId = METATILE_BrendansMaysHouse_MayPC_On; tileId = METATILE_BrendansMaysHouse_MayPC_On;
} }
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + MAP_OFFSET, gSaveBlock1Ptr->pos.y + dy + MAP_OFFSET, tileId | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + MAP_OFFSET, gSaveBlock1Ptr->pos.y + dy + MAP_OFFSET, tileId | MAPGRID_COLLISION_MASK);
} }
void DoPCTurnOffEffect(void) void DoPCTurnOffEffect(void)
@ -1075,7 +1075,7 @@ static void PCTurnOffEffect(void)
tileId = METATILE_BrendansMaysHouse_BrendanPC_Off; tileId = METATILE_BrendansMaysHouse_BrendanPC_Off;
else if (gSpecialVar_0x8004 == 2) else if (gSpecialVar_0x8004 == 2)
tileId = METATILE_BrendansMaysHouse_MayPC_Off; tileId = METATILE_BrendansMaysHouse_MayPC_Off;
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + MAP_OFFSET, gSaveBlock1Ptr->pos.y + dy + MAP_OFFSET, tileId | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + MAP_OFFSET, gSaveBlock1Ptr->pos.y + dy + MAP_OFFSET, tileId | MAPGRID_COLLISION_MASK);
DrawWholeMapView(); DrawWholeMapView();
} }
@ -1106,13 +1106,13 @@ static void LotteryCornerComputerEffect(struct Task *task)
task->data[3] = 0; task->data[3] = 0;
if (task->data[4] != 0) if (task->data[4] != 0)
{ {
MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Normal | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Normal | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_Normal | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_Normal | MAPGRID_COLLISION_MASK);
} }
else else
{ {
MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Flash | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Flash | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_Flash | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_Flash | MAPGRID_COLLISION_MASK);
} }
DrawWholeMapView(); DrawWholeMapView();
task->data[4] ^= 1; task->data[4] ^= 1;
@ -1124,8 +1124,8 @@ static void LotteryCornerComputerEffect(struct Task *task)
void EndLotteryCornerComputerEffect(void) void EndLotteryCornerComputerEffect(void)
{ {
MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Normal | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Normal | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_Normal | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_Normal | MAPGRID_COLLISION_MASK);
DrawWholeMapView(); DrawWholeMapView();
} }
@ -1872,7 +1872,7 @@ static void Task_MoveElevatorWindowLights(u8 taskId)
for (y = 0; y < 3; y++) for (y = 0; y < 3; y++)
{ {
for (x = 0; x < 3; x++) for (x = 0; x < 3; x++)
MapGridSetMetatileIdAt(x + MAP_OFFSET + 1, y + MAP_OFFSET, sElevatorWindowTiles_Ascending[y][data[0] % 3] | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x + MAP_OFFSET + 1, y + MAP_OFFSET, sElevatorWindowTiles_Ascending[y][data[0] % 3] | MAPGRID_COLLISION_MASK);
} }
} }
// descending // descending
@ -1881,7 +1881,7 @@ static void Task_MoveElevatorWindowLights(u8 taskId)
for (y = 0; y < 3; y++) for (y = 0; y < 3; y++)
{ {
for (x = 0; x < 3; x++) for (x = 0; x < 3; x++)
MapGridSetMetatileIdAt(x + MAP_OFFSET + 1, y + MAP_OFFSET, sElevatorWindowTiles_Descending[y][data[0] % 3] | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x + MAP_OFFSET + 1, y + MAP_OFFSET, sElevatorWindowTiles_Descending[y][data[0] % 3] | MAPGRID_COLLISION_MASK);
} }
} }
DrawWholeMapView(); DrawWholeMapView();

View File

@ -43,12 +43,12 @@ static void FillWestConnection(struct MapHeader const *mapHeader, struct MapHead
static 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);
static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader); static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader);
static void LoadSavedMapView(void); static void LoadSavedMapView(void);
static bool8 SkipCopyingMetatileFromSavedMap(u16* mapMetatilePtr, u16 mapWidth, u8 yMode); static bool8 SkipCopyingMetatileFromSavedMap(u16* mapBlock, u16 mapWidth, u8 yMode);
static struct MapConnection *GetIncomingConnection(u8 direction, int x, int y); static struct MapConnection *GetIncomingConnection(u8 direction, int x, int y);
static bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, struct MapConnection *connection); static bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, struct MapConnection *connection);
static bool8 IsCoordInIncomingConnectingMap(int coord, int srcMax, int destMax, int offset); static bool8 IsCoordInIncomingConnectingMap(int coord, int srcMax, int destMax, int offset);
#define MapGridGetBorderTileAt(x, y) ({ \ #define GetBorderBlockAt(x, y)({ \
u16 block; \ u16 block; \
int i; \ int i; \
u16 *border = gMapHeader.mapLayout->border; \ u16 *border = gMapHeader.mapLayout->border; \
@ -56,12 +56,12 @@ static bool8 IsCoordInIncomingConnectingMap(int coord, int srcMax, int destMax,
i = (x + 1) & 1; \ i = (x + 1) & 1; \
i += ((y + 1) & 1) * 2; \ i += ((y + 1) & 1) * 2; \
\ \
block = gMapHeader.mapLayout->border[i] | METATILE_COLLISION_MASK; \ block = gMapHeader.mapLayout->border[i] | MAPGRID_COLLISION_MASK; \
}) })
#define AreCoordsWithinMapGridBounds(x, y) (x >= 0 && x < gBackupMapLayout.width && y >= 0 && y < gBackupMapLayout.height) #define AreCoordsWithinMapGridBounds(x, y) (x >= 0 && x < gBackupMapLayout.width && y >= 0 && y < gBackupMapLayout.height)
#define MapGridGetTileAt(x, y) (AreCoordsWithinMapGridBounds(x, y) ? gBackupMapLayout.map[x + gBackupMapLayout.width * y] : MapGridGetBorderTileAt(x, y)) #define GetMapGridBlockAt(x, y) (AreCoordsWithinMapGridBounds(x, y) ? gBackupMapLayout.map[x + gBackupMapLayout.width * y] : GetBorderBlockAt(x, y))
struct MapHeader const *const GetMapHeaderFromConnection(struct MapConnection *connection) struct MapHeader const *const GetMapHeaderFromConnection(struct MapConnection *connection)
{ {
@ -87,13 +87,13 @@ void InitMapFromSavedGame(void)
void InitBattlePyramidMap(bool8 setPlayerPosition) void InitBattlePyramidMap(bool8 setPlayerPosition)
{ {
CpuFastFill(METATILE_ID_UNDEFINED << 16 | METATILE_ID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData)); CpuFastFill(MAPGRID_UNDEFINED << 16 | MAPGRID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData));
GenerateBattlePyramidFloorLayout(gBackupMapData, setPlayerPosition); GenerateBattlePyramidFloorLayout(gBackupMapData, setPlayerPosition);
} }
void InitTrainerHillMap(void) void InitTrainerHillMap(void)
{ {
CpuFastFill(METATILE_ID_UNDEFINED << 16 | METATILE_ID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData)); CpuFastFill(MAPGRID_UNDEFINED << 16 | MAPGRID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData));
GenerateTrainerHillFloorLayout(gBackupMapData); GenerateTrainerHillFloorLayout(gBackupMapData);
} }
@ -103,7 +103,7 @@ static void InitMapLayoutData(struct MapHeader *mapHeader)
int width; int width;
int height; int height;
mapLayout = mapHeader->mapLayout; mapLayout = mapHeader->mapLayout;
CpuFastFill16(METATILE_ID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData)); CpuFastFill16(MAPGRID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData));
gBackupMapLayout.map = gBackupMapData; gBackupMapLayout.map = gBackupMapData;
width = mapLayout->width + MAP_OFFSET_W; width = mapLayout->width + MAP_OFFSET_W;
gBackupMapLayout.width = width; gBackupMapLayout.width = width;
@ -344,44 +344,44 @@ static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHead
u8 MapGridGetZCoordAt(int x, int y) u8 MapGridGetZCoordAt(int x, int y)
{ {
u16 block = MapGridGetTileAt(x, y); u16 block = GetMapGridBlockAt(x, y);
if (block == METATILE_ID_UNDEFINED) if (block == MAPGRID_UNDEFINED)
return 0; return 0;
return block >> METATILE_ELEVATION_SHIFT; return block >> MAPGRID_ELEVATION_SHIFT;
} }
bool8 MapGridIsImpassableAt(int x, int y) bool8 MapGridIsImpassableAt(int x, int y)
{ {
u16 block = MapGridGetTileAt(x, y); u16 block = GetMapGridBlockAt(x, y);
if (block == METATILE_ID_UNDEFINED) if (block == MAPGRID_UNDEFINED)
return TRUE; return TRUE;
return (block & METATILE_COLLISION_MASK) >> METATILE_COLLISION_SHIFT; return (block & MAPGRID_COLLISION_MASK) >> MAPGRID_COLLISION_SHIFT;
} }
u32 MapGridGetMetatileIdAt(int x, int y) u32 MapGridGetMetatileIdAt(int x, int y)
{ {
u16 block = MapGridGetTileAt(x, y); u16 block = GetMapGridBlockAt(x, y);
if (block == METATILE_ID_UNDEFINED) if (block == MAPGRID_UNDEFINED)
return MapGridGetBorderTileAt(x, y) & METATILE_ID_MASK; return GetBorderBlockAt(x, y) & MAPGRID_METATILE_ID_MASK;
return block & METATILE_ID_MASK; return block & MAPGRID_METATILE_ID_MASK;
} }
u32 MapGridGetMetatileBehaviorAt(int x, int y) u32 MapGridGetMetatileBehaviorAt(int x, int y)
{ {
u16 metatile = MapGridGetMetatileIdAt(x, y); u16 metatile = MapGridGetMetatileIdAt(x, y);
return GetBehaviorByMetatileId(metatile) & METATILE_BEHAVIOR_MASK; return GetMetatileAttributesById(metatile) & METATILE_ATTR_BEHAVIOR_MASK;
} }
u8 MapGridGetMetatileLayerTypeAt(int x, int y) u8 MapGridGetMetatileLayerTypeAt(int x, int y)
{ {
u16 metatile = MapGridGetMetatileIdAt(x, y); u16 metatile = MapGridGetMetatileIdAt(x, y);
return (GetBehaviorByMetatileId(metatile) & METATILE_ELEVATION_MASK) >> METATILE_ELEVATION_SHIFT; return (GetMetatileAttributesById(metatile) & METATILE_ATTR_LAYER_MASK) >> METATILE_ATTR_LAYER_SHIFT;
} }
void MapGridSetMetatileIdAt(int x, int y, u16 metatile) void MapGridSetMetatileIdAt(int x, int y, u16 metatile)
@ -390,7 +390,7 @@ void MapGridSetMetatileIdAt(int x, int y, u16 metatile)
if (AreCoordsWithinMapGridBounds(x, y)) if (AreCoordsWithinMapGridBounds(x, y))
{ {
i = x + y * gBackupMapLayout.width; i = x + y * gBackupMapLayout.width;
gBackupMapLayout.map[i] = (gBackupMapLayout.map[i] & METATILE_ELEVATION_MASK) | (metatile & ~METATILE_ELEVATION_MASK); gBackupMapLayout.map[i] = (gBackupMapLayout.map[i] & MAPGRID_ELEVATION_MASK) | (metatile & ~MAPGRID_ELEVATION_MASK);
} }
} }
@ -404,7 +404,7 @@ void MapGridSetMetatileEntryAt(int x, int y, u16 metatile)
} }
} }
u16 GetBehaviorByMetatileId(u16 metatile) u16 GetMetatileAttributesById(u16 metatile)
{ {
u16 *attributes; u16 *attributes;
if (metatile < NUM_METATILES_IN_PRIMARY) if (metatile < NUM_METATILES_IN_PRIMARY)
@ -565,7 +565,7 @@ static void MoveMapViewToBackup(u8 direction)
int GetMapBorderIdAt(int x, int y) int GetMapBorderIdAt(int x, int y)
{ {
if (MapGridGetTileAt(x, y) == METATILE_ID_UNDEFINED) if (GetMapGridBlockAt(x, y) == MAPGRID_UNDEFINED)
return CONNECTION_INVALID; return CONNECTION_INVALID;
if (x >= (gBackupMapLayout.width - (MAP_OFFSET + 1))) if (x >= (gBackupMapLayout.width - (MAP_OFFSET + 1)))
@ -817,23 +817,23 @@ void MapGridSetMetatileImpassabilityAt(int x, int y, bool32 impassable)
if (AreCoordsWithinMapGridBounds(x, y)) if (AreCoordsWithinMapGridBounds(x, y))
{ {
if (impassable) if (impassable)
gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= METATILE_COLLISION_MASK; gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= MAPGRID_COLLISION_MASK;
else else
gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= ~METATILE_COLLISION_MASK; gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= ~MAPGRID_COLLISION_MASK;
} }
} }
static bool8 SkipCopyingMetatileFromSavedMap(u16* mapMetatilePtr, u16 mapWidth, u8 yMode) static bool8 SkipCopyingMetatileFromSavedMap(u16* mapBlock, u16 mapWidth, u8 yMode)
{ {
if (yMode == 0xFF) if (yMode == 0xFF)
return FALSE; return FALSE;
if (yMode == 0) if (yMode == 0)
mapMetatilePtr -= mapWidth; mapBlock -= mapWidth;
else else
mapMetatilePtr += mapWidth; mapBlock += mapWidth;
if (IsLargeBreakableDecoration(*mapMetatilePtr & METATILE_ID_MASK, yMode) == TRUE) if (IsLargeBreakableDecoration(*mapBlock & MAPGRID_METATILE_ID_MASK, yMode) == TRUE)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }

View File

@ -126,13 +126,13 @@ static void Task_DrawEscalator(u8 taskId)
SetEscalatorMetatile(taskId, sEscalatorMetatiles_1F_1, 0); SetEscalatorMetatile(taskId, sEscalatorMetatiles_1F_1, 0);
break; break;
case 2: case 2:
SetEscalatorMetatile(taskId, sEscalatorMetatiles_1F_2, METATILE_COLLISION_MASK); SetEscalatorMetatile(taskId, sEscalatorMetatiles_1F_2, MAPGRID_COLLISION_MASK);
break; break;
case 3: case 3:
SetEscalatorMetatile(taskId, sEscalatorMetatiles_1F_3, 0); SetEscalatorMetatile(taskId, sEscalatorMetatiles_1F_3, 0);
break; break;
case 4: case 4:
SetEscalatorMetatile(taskId, sEscalatorMetatiles_2F_0, METATILE_COLLISION_MASK); SetEscalatorMetatile(taskId, sEscalatorMetatiles_2F_0, MAPGRID_COLLISION_MASK);
break; break;
case 5: case 5:
SetEscalatorMetatile(taskId, sEscalatorMetatiles_2F_1, 0); SetEscalatorMetatile(taskId, sEscalatorMetatiles_2F_1, 0);

View File

@ -840,9 +840,9 @@ void DoSecretBasePCTurnOffEffect(void)
PlaySE(SE_PC_OFF); PlaySE(SE_PC_OFF);
if (!VarGet(VAR_CURRENT_SECRET_BASE)) if (!VarGet(VAR_CURRENT_SECRET_BASE))
MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_PC | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_PC | MAPGRID_COLLISION_MASK);
else else
MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_RegisterPC | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_RegisterPC | MAPGRID_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y); CurrentMapDrawMetatileAt(x, y);
} }
@ -1083,7 +1083,7 @@ static void SpriteCB_SandPillar_BreakTop(struct Sprite *sprite)
PlaySE(SE_M_ROCK_THROW); PlaySE(SE_M_ROCK_THROW);
if (MapGridGetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6] - 1) == METATILE_SecretBase_SandOrnament_TopWall) if (MapGridGetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6] - 1) == METATILE_SecretBase_SandOrnament_TopWall)
MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6] - 1, METATILE_SecretBase_Wall_TopMid | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6] - 1, METATILE_SecretBase_Wall_TopMid | MAPGRID_COLLISION_MASK);
else else
MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6] - 1, METATILE_SecretBase_SandOrnament_BrokenTop); MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6] - 1, METATILE_SecretBase_SandOrnament_BrokenTop);
@ -1103,7 +1103,7 @@ static void SpriteCB_SandPillar_BreakBase(struct Sprite *sprite)
} }
else else
{ {
MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6], METATILE_SecretBase_SandOrnament_BrokenBase | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6], METATILE_SecretBase_SandOrnament_BrokenBase | MAPGRID_COLLISION_MASK);
CurrentMapDrawMetatileAt(gFieldEffectArguments[5], gFieldEffectArguments[6]); CurrentMapDrawMetatileAt(gFieldEffectArguments[5], gFieldEffectArguments[6]);
sprite->data[0] = 0; sprite->data[0] = 0;
sprite->callback = SpriteCB_SandPillar_End; sprite->callback = SpriteCB_SandPillar_End;

View File

@ -2046,7 +2046,7 @@ bool8 ScrCmd_setmetatile(struct ScriptContext *ctx)
if (!isImpassable) if (!isImpassable)
MapGridSetMetatileIdAt(x, y, tileId); MapGridSetMetatileIdAt(x, y, tileId);
else else
MapGridSetMetatileIdAt(x, y, tileId | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, tileId | MAPGRID_COLLISION_MASK);
return FALSE; return FALSE;
} }

View File

@ -305,7 +305,7 @@ static void FindMetatileIdMapCoords(s16 *x, s16 *y, u16 metatileId)
{ {
for (i = 0; i < mapLayout->width; i++) for (i = 0; i < mapLayout->width; i++)
{ {
if ((mapLayout->map[j * mapLayout->width + i] & METATILE_ID_MASK) == metatileId) if ((mapLayout->map[j * mapLayout->width + i] & MAPGRID_METATILE_ID_MASK) == metatileId)
{ {
*x = i; *x = i;
*y = j; *y = j;
@ -330,7 +330,7 @@ void ToggleSecretBaseEntranceMetatile(void)
{ {
if (sSecretBaseEntranceMetatiles[i].closedMetatileId == metatileId) if (sSecretBaseEntranceMetatiles[i].closedMetatileId == metatileId)
{ {
MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].openMetatileId | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].openMetatileId | MAPGRID_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y); CurrentMapDrawMetatileAt(x, y);
return; return;
} }
@ -341,7 +341,7 @@ void ToggleSecretBaseEntranceMetatile(void)
{ {
if (sSecretBaseEntranceMetatiles[i].openMetatileId == metatileId) if (sSecretBaseEntranceMetatiles[i].openMetatileId == metatileId)
{ {
MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].closedMetatileId | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].closedMetatileId | MAPGRID_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y); CurrentMapDrawMetatileAt(x, y);
return; return;
} }
@ -396,7 +396,7 @@ void SetOccupiedSecretBaseEntranceMetatiles(struct MapEvents const *events)
{ {
if (sSecretBaseEntranceMetatiles[i].closedMetatileId == tile_id) if (sSecretBaseEntranceMetatiles[i].closedMetatileId == tile_id)
{ {
MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].openMetatileId | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].openMetatileId | MAPGRID_COLLISION_MASK);
break; break;
} }
} }
@ -475,7 +475,7 @@ static void EnterNewlyCreatedSecretBase_StartFadeIn(void)
FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC); FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC);
x += MAP_OFFSET; x += MAP_OFFSET;
y += MAP_OFFSET; y += MAP_OFFSET;
MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_PC | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_PC | MAPGRID_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y); CurrentMapDrawMetatileAt(x, y);
FadeInFromBlack(); FadeInFromBlack();
CreateTask(EnterNewlyCreatedSecretBase_WaitFadeIn, 0); CreateTask(EnterNewlyCreatedSecretBase_WaitFadeIn, 0);
@ -536,13 +536,13 @@ void InitSecretBaseAppearance(bool8 hidePC)
{ {
// Another player's secret base. Change PC type to the "Register" PC. // Another player's secret base. Change PC type to the "Register" PC.
FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC); FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC);
MapGridSetMetatileIdAt(x + MAP_OFFSET, y + MAP_OFFSET, METATILE_SecretBase_RegisterPC | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x + MAP_OFFSET, y + MAP_OFFSET, METATILE_SecretBase_RegisterPC | MAPGRID_COLLISION_MASK);
} }
else if (hidePC == TRUE && VarGet(VAR_SECRET_BASE_INITIALIZED) == 1) else if (hidePC == TRUE && VarGet(VAR_SECRET_BASE_INITIALIZED) == 1)
{ {
// Change PC to regular ground tile. // Change PC to regular ground tile.
FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC); FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC);
MapGridSetMetatileIdAt(x + MAP_OFFSET, y + MAP_OFFSET, METATILE_SecretBase_Ground | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x + MAP_OFFSET, y + MAP_OFFSET, METATILE_SecretBase_Ground | MAPGRID_COLLISION_MASK);
} }
} }
} }
@ -838,7 +838,7 @@ static void ClosePlayerSecretBaseEntrance(void)
{ {
MapGridSetMetatileIdAt(events->bgEvents[i].x + MAP_OFFSET, MapGridSetMetatileIdAt(events->bgEvents[i].x + MAP_OFFSET,
events->bgEvents[i].y + MAP_OFFSET, events->bgEvents[i].y + MAP_OFFSET,
sSecretBaseEntranceMetatiles[j].closedMetatileId | METATILE_COLLISION_MASK); sSecretBaseEntranceMetatiles[j].closedMetatileId | MAPGRID_COLLISION_MASK);
break; break;
} }
} }

View File

@ -677,9 +677,9 @@ static u16 GetMetatileForFloor(u8 floorId, u32 x, u32 y, u32 stride) // stride i
impassable = (sHillData->floors[floorId].display.collisionData[y] >> (15 - x) & 1); impassable = (sHillData->floors[floorId].display.collisionData[y] >> (15 - x) & 1);
metatile = sHillData->floors[floorId].display.metatileData[stride * y + x] + NUM_METATILES_IN_PRIMARY; metatile = sHillData->floors[floorId].display.metatileData[stride * y + x] + NUM_METATILES_IN_PRIMARY;
elevation = 3 << METATILE_ELEVATION_SHIFT; elevation = 3 << MAPGRID_ELEVATION_SHIFT;
return ((impassable << METATILE_COLLISION_SHIFT) & METATILE_COLLISION_MASK) | elevation | (metatile & METATILE_ID_MASK); return ((impassable << MAPGRID_COLLISION_SHIFT) & MAPGRID_COLLISION_MASK) | elevation | (metatile & MAPGRID_METATILE_ID_MASK);
} }
void GenerateTrainerHillFloorLayout(u16 *mapArg) void GenerateTrainerHillFloorLayout(u16 *mapArg)

View File

@ -852,7 +852,7 @@ void UpdateTVScreensOnMap(int width, int height)
} }
} }
static void SetTVMetatilesOnMap(int width, int height, u16 tileId) static void SetTVMetatilesOnMap(int width, int height, u16 metatileId)
{ {
int x; int x;
int y; int y;
@ -862,7 +862,7 @@ static void SetTVMetatilesOnMap(int width, int height, u16 tileId)
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
{ {
if (MapGridGetMetatileBehaviorAt(x, y) == MB_TELEVISION) if (MapGridGetMetatileBehaviorAt(x, y) == MB_TELEVISION)
MapGridSetMetatileIdAt(x, y, tileId | METATILE_COLLISION_MASK); MapGridSetMetatileIdAt(x, y, metatileId | MAPGRID_COLLISION_MASK);
} }
} }
} }