From a8b466dc80eb22146c6bc517d44fdc133a646555 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 19 Jan 2022 10:15:32 -0500 Subject: [PATCH] Disambiguate fieldmap names --- gflib/bg.c | 4 +-- include/fieldmap.h | 2 +- include/global.fieldmap.h | 25 ++++++++++++----- src/battle_pyramid.c | 6 ++--- src/braille_puzzles.c | 12 ++++----- src/decoration.c | 37 +++++++++++++------------- src/field_specials.c | 50 +++++++++++++++++----------------- src/fieldmap.c | 56 +++++++++++++++++++-------------------- src/fldeff_escalator.c | 4 +-- src/fldeff_misc.c | 8 +++--- src/scrcmd.c | 2 +- src/secret_base.c | 16 +++++------ src/trainer_hill.c | 4 +-- src/tv.c | 4 +-- 14 files changed, 120 insertions(+), 110 deletions(-) diff --git a/gflib/bg.c b/gflib/bg.c index c96bcbc23..6e97be207 100644 --- a/gflib/bg.c +++ b/gflib/bg.c @@ -1053,7 +1053,7 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt for (x16 = x; x16 < (x + width); x16++) { 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; @@ -1064,7 +1064,7 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt for (x16 = x; x16 < (x + width); x16++) { ((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; diff --git a/include/fieldmap.h b/include/fieldmap.h index aabfce461..db060497a 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -29,7 +29,7 @@ void GetCameraCoords(u16*, u16*); bool8 MapGridIsImpassableAt(int, int); int GetMapBorderIdAt(int x, int y); bool32 CanCameraMoveInDirection(int direction); -u16 GetBehaviorByMetatileId(u16 metatileId); +u16 GetMetatileAttributesById(u16 metatileId); void GetCameraFocusCoords(u16 *x, u16 *y); u8 MapGridGetMetatileLayerTypeAt(int x, int y); u8 MapGridGetZCoordAt(int x, int y); diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 2613682fd..46450ed44 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -1,13 +1,24 @@ #ifndef GUARD_GLOBAL_FIELDMAP_H #define GUARD_GLOBAL_FIELDMAP_H -#define METATILE_BEHAVIOR_MASK 0x00FF -#define METATILE_COLLISION_MASK 0x0C00 -#define METATILE_ID_MASK 0x03FF -#define METATILE_ID_UNDEFINED 0x03FF -#define METATILE_ELEVATION_SHIFT 12 -#define METATILE_COLLISION_SHIFT 10 -#define METATILE_ELEVATION_MASK 0xF000 +// Masks/shifts for blocks in the map grid +// Map grid blocks consist of a 10 bit metatile id, a 2 bit collision value, and a 4 bit elevation value +// This is the data stored in each data/layouts/*/map.bin and border.bin file +#define MAPGRID_METATILE_ID_MASK 0x03FF // Bits 1-10 +#define MAPGRID_COLLISION_MASK 0x0C00 // Bits 11-12 +#define MAPGRID_ELEVATION_MASK 0xF000 // Bits 13-16 +#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 { METATILE_LAYER_TYPE_NORMAL, // Metatile uses middle and top bg layers diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index b10690ce4..154760396 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -1239,7 +1239,7 @@ static u8 GetPostBattleDirectionHintTextIndex(int *hintType, u8 minDistanceForEx { 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; y += MAP_OFFSET - gObjectEvents[gSelectedObjectEvent].initialCoords.y; @@ -1545,7 +1545,7 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio { 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]; } @@ -1556,7 +1556,7 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio gSaveBlock1Ptr->pos.x = (mapLayout->width * (i % 4)) + x; 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 { diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c index 26caa830d..876e6b4a7 100644 --- a/src/braille_puzzles.c +++ b/src/braille_puzzles.c @@ -80,9 +80,9 @@ void DoBrailleDigEffect(void) MapGridSetMetatileIdAt( 9 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopLeft); MapGridSetMetatileIdAt(10 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid); 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(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(); PlaySE(SE_BANG); 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(8 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid); 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(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(); PlaySE(SE_BANG); 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(8 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid); 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(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(); PlaySE(SE_BANG); FlagSet(FLAG_SYS_REGISTEEL_PUZZLE_COMPLETED); diff --git a/src/decoration.c b/src/decoration.c index 78f6ccb40..825c86818 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -1185,10 +1185,10 @@ static u16 GetDecorationElevation(u8 decoration, u8 tileIndex) switch (decoration) { case DECOR_STAND: - elevation = sDecorationStandElevations[tileIndex] << METATILE_ELEVATION_SHIFT; + elevation = sDecorationStandElevations[tileIndex] << MAPGRID_ELEVATION_SHIFT; return elevation; case DECOR_SLIDE: - elevation = sDecorationSlideElevation[tileIndex] << METATILE_ELEVATION_SHIFT; + elevation = sDecorationSlideElevation[tileIndex] << MAPGRID_ELEVATION_SHIFT; return elevation; default: return elevation; @@ -1199,7 +1199,7 @@ static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, { u16 i, j; s16 x, y; - u16 behavior; + u16 attributes; u16 impassableFlag; u16 overlapsWall; u16 elevation; @@ -1210,9 +1210,9 @@ static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, for (i = 0; i < decWidth; i++) { x = mapX + i; - behavior = GetBehaviorByMetatileId(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))) - impassableFlag = METATILE_COLLISION_MASK; + attributes = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + gDecorations[decoration].tiles[j * decWidth + i]); + if (MetatileBehavior_IsSecretBaseImpassable(attributes) == TRUE || (gDecorations[decoration].permission != DECORPERM_PASS_FLOOR && (attributes >> METATILE_ATTR_LAYER_SHIFT))) + impassableFlag = MAPGRID_COLLISION_MASK; else impassableFlag = 0; @@ -1471,17 +1471,16 @@ static void AttemptCancelPlaceDecoration(u8 taskId) DisplayItemMessageOnField(taskId, gStringVar4, CancelDecoratingPrompt); } -// Note: behaviorBy is pre-anded with METATILE_ELEVATION_MASK. -static bool8 IsNonBlockNonElevated(u8 behaviorAt, u16 behaviorBy) +static bool8 IsNonBlockNonElevated(u8 behaviorAt, u16 layerType) { - if (MetatileBehavior_IsBlockDecoration(behaviorAt) != TRUE || behaviorBy != 0) + if (MetatileBehavior_IsBlockDecoration(behaviorAt) != TRUE || layerType != 0) return FALSE; 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 TRUE; } @@ -1505,7 +1504,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) u8 i; u8 j; u8 behaviorAt; - u16 behaviorBy; + u16 layerType; u8 mapY; u8 mapX; s16 curY; @@ -1524,11 +1523,11 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) { curX = gTasks[taskId].tCursorX + j; 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)) return FALSE; - if (!IsntInitialPosition(taskId, curX, curY, behaviorBy)) + if (!IsntInitialPosition(taskId, curX, curY, layerType)) return FALSE; behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0); @@ -1545,11 +1544,11 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) { curX = gTasks[taskId].tCursorX + j; behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); - behaviorBy = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK; - if (!MetatileBehavior_IsNormal(behaviorAt) && !IsNonBlockNonElevated(behaviorAt, behaviorBy)) + layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ATTR_LAYER_MASK; + if (!MetatileBehavior_IsNormal(behaviorAt) && !IsNonBlockNonElevated(behaviorAt, layerType)) return FALSE; - if (!IsntInitialPosition(taskId, curX, curY, behaviorBy)) + if (!IsntInitialPosition(taskId, curX, curY, layerType)) return FALSE; 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; 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)) return FALSE; - if (!IsntInitialPosition(taskId, curX, curY, behaviorBy)) + if (!IsntInitialPosition(taskId, curX, curY, layerType)) return FALSE; behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0); diff --git a/src/field_specials.c b/src/field_specials.c index 0a7236913..f676600c0 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -650,10 +650,10 @@ void MauvilleGymSetDefaultBarriers(void) MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH2_On); break; 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; 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; case METATILE_MauvilleGym_RedBeamH1_On: MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH1_Off); @@ -674,37 +674,37 @@ void MauvilleGymSetDefaultBarriers(void) MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH2_On); break; 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; 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; 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; case METATILE_MauvilleGym_GreenBeamV2_On: MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_FloorTile); break; 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; case METATILE_MauvilleGym_RedBeamV2_On: MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_FloorTile); break; 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; case METATILE_MauvilleGym_FloorTile: 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 - MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamV2_On | METATILE_COLLISION_MASK); + MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamV2_On | MAPGRID_COLLISION_MASK); break; 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; 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; case METATILE_MauvilleGym_PoleTop_On: MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleTop_Off); @@ -755,10 +755,10 @@ void MauvilleGymDeactivatePuzzle(void) MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH4_Off); break; 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; 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; case METATILE_MauvilleGym_GreenBeamV2_On: case METATILE_MauvilleGym_RedBeamV2_On: @@ -867,8 +867,8 @@ static void PetalburgGymSetDoorMetatiles(u8 roomNumber, u16 metatileId) } 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 + 1, (metatileId + 8) | 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) | MAPGRID_COLLISION_MASK); } DrawWholeMapView(); } @@ -1040,7 +1040,7 @@ static void PCTurnOnEffect_1(s16 isPcTurnedOn, s8 dx, s8 dy) else if (gSpecialVar_0x8004 == PC_LOCATION_MAYS_HOUSE) 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) @@ -1075,7 +1075,7 @@ static void PCTurnOffEffect(void) tileId = METATILE_BrendansMaysHouse_BrendanPC_Off; else if (gSpecialVar_0x8004 == 2) 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(); } @@ -1106,13 +1106,13 @@ static void LotteryCornerComputerEffect(struct Task *task) task->data[3] = 0; if (task->data[4] != 0) { - MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Normal | METATILE_COLLISION_MASK); - MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_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 | MAPGRID_COLLISION_MASK); } else { - MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Flash | METATILE_COLLISION_MASK); - MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_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 | MAPGRID_COLLISION_MASK); } DrawWholeMapView(); task->data[4] ^= 1; @@ -1124,8 +1124,8 @@ static void LotteryCornerComputerEffect(struct Task *task) void EndLotteryCornerComputerEffect(void) { - MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Normal | METATILE_COLLISION_MASK); - MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_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 | MAPGRID_COLLISION_MASK); DrawWholeMapView(); } @@ -1872,7 +1872,7 @@ static void Task_MoveElevatorWindowLights(u8 taskId) for (y = 0; y < 3; y++) { 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 @@ -1881,7 +1881,7 @@ static void Task_MoveElevatorWindowLights(u8 taskId) for (y = 0; y < 3; y++) { 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(); diff --git a/src/fieldmap.c b/src/fieldmap.c index aff72c4c6..8be4206e2 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -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 InitBackupMapLayoutConnections(struct MapHeader *mapHeader); 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 bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, struct MapConnection *connection); static bool8 IsCoordInIncomingConnectingMap(int coord, int srcMax, int destMax, int offset); -#define MapGridGetBorderTileAt(x, y) ({ \ +#define GetBorderBlockAt(x, y)({ \ u16 block; \ int i; \ u16 *border = gMapHeader.mapLayout->border; \ @@ -56,12 +56,12 @@ static bool8 IsCoordInIncomingConnectingMap(int coord, int srcMax, int destMax, i = (x + 1) & 1; \ 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 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) { @@ -87,13 +87,13 @@ void InitMapFromSavedGame(void) 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); } 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); } @@ -103,7 +103,7 @@ static void InitMapLayoutData(struct MapHeader *mapHeader) int width; int height; mapLayout = mapHeader->mapLayout; - CpuFastFill16(METATILE_ID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData)); + CpuFastFill16(MAPGRID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData)); gBackupMapLayout.map = gBackupMapData; width = mapLayout->width + MAP_OFFSET_W; gBackupMapLayout.width = width; @@ -344,44 +344,44 @@ static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHead 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 block >> METATILE_ELEVATION_SHIFT; + return block >> MAPGRID_ELEVATION_SHIFT; } 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 (block & METATILE_COLLISION_MASK) >> METATILE_COLLISION_SHIFT; + return (block & MAPGRID_COLLISION_MASK) >> MAPGRID_COLLISION_SHIFT; } u32 MapGridGetMetatileIdAt(int x, int y) { - u16 block = MapGridGetTileAt(x, y); + u16 block = GetMapGridBlockAt(x, y); - if (block == METATILE_ID_UNDEFINED) - return MapGridGetBorderTileAt(x, y) & METATILE_ID_MASK; + if (block == MAPGRID_UNDEFINED) + 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) { u16 metatile = MapGridGetMetatileIdAt(x, y); - return GetBehaviorByMetatileId(metatile) & METATILE_BEHAVIOR_MASK; + return GetMetatileAttributesById(metatile) & METATILE_ATTR_BEHAVIOR_MASK; } u8 MapGridGetMetatileLayerTypeAt(int x, int 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) @@ -390,7 +390,7 @@ void MapGridSetMetatileIdAt(int x, int y, u16 metatile) if (AreCoordsWithinMapGridBounds(x, y)) { 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; if (metatile < NUM_METATILES_IN_PRIMARY) @@ -565,7 +565,7 @@ static void MoveMapViewToBackup(u8 direction) int GetMapBorderIdAt(int x, int y) { - if (MapGridGetTileAt(x, y) == METATILE_ID_UNDEFINED) + if (GetMapGridBlockAt(x, y) == MAPGRID_UNDEFINED) return CONNECTION_INVALID; if (x >= (gBackupMapLayout.width - (MAP_OFFSET + 1))) @@ -817,23 +817,23 @@ void MapGridSetMetatileImpassabilityAt(int x, int y, bool32 impassable) if (AreCoordsWithinMapGridBounds(x, y)) { if (impassable) - gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= METATILE_COLLISION_MASK; + gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= MAPGRID_COLLISION_MASK; 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) return FALSE; if (yMode == 0) - mapMetatilePtr -= mapWidth; + mapBlock -= mapWidth; 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 FALSE; } diff --git a/src/fldeff_escalator.c b/src/fldeff_escalator.c index 769e73562..0dc98c319 100644 --- a/src/fldeff_escalator.c +++ b/src/fldeff_escalator.c @@ -126,13 +126,13 @@ static void Task_DrawEscalator(u8 taskId) SetEscalatorMetatile(taskId, sEscalatorMetatiles_1F_1, 0); break; case 2: - SetEscalatorMetatile(taskId, sEscalatorMetatiles_1F_2, METATILE_COLLISION_MASK); + SetEscalatorMetatile(taskId, sEscalatorMetatiles_1F_2, MAPGRID_COLLISION_MASK); break; case 3: SetEscalatorMetatile(taskId, sEscalatorMetatiles_1F_3, 0); break; case 4: - SetEscalatorMetatile(taskId, sEscalatorMetatiles_2F_0, METATILE_COLLISION_MASK); + SetEscalatorMetatile(taskId, sEscalatorMetatiles_2F_0, MAPGRID_COLLISION_MASK); break; case 5: SetEscalatorMetatile(taskId, sEscalatorMetatiles_2F_1, 0); diff --git a/src/fldeff_misc.c b/src/fldeff_misc.c index c01babb68..4f3f53fa6 100644 --- a/src/fldeff_misc.c +++ b/src/fldeff_misc.c @@ -840,9 +840,9 @@ void DoSecretBasePCTurnOffEffect(void) PlaySE(SE_PC_OFF); 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 - MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_RegisterPC | METATILE_COLLISION_MASK); + MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_RegisterPC | MAPGRID_COLLISION_MASK); CurrentMapDrawMetatileAt(x, y); } @@ -1083,7 +1083,7 @@ static void SpriteCB_SandPillar_BreakTop(struct Sprite *sprite) PlaySE(SE_M_ROCK_THROW); 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 MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6] - 1, METATILE_SecretBase_SandOrnament_BrokenTop); @@ -1103,7 +1103,7 @@ static void SpriteCB_SandPillar_BreakBase(struct Sprite *sprite) } 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]); sprite->data[0] = 0; sprite->callback = SpriteCB_SandPillar_End; diff --git a/src/scrcmd.c b/src/scrcmd.c index 2c18cb565..a5a380759 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -2046,7 +2046,7 @@ bool8 ScrCmd_setmetatile(struct ScriptContext *ctx) if (!isImpassable) MapGridSetMetatileIdAt(x, y, tileId); else - MapGridSetMetatileIdAt(x, y, tileId | METATILE_COLLISION_MASK); + MapGridSetMetatileIdAt(x, y, tileId | MAPGRID_COLLISION_MASK); return FALSE; } diff --git a/src/secret_base.c b/src/secret_base.c index 8fc97141f..9398c4bb2 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -305,7 +305,7 @@ static void FindMetatileIdMapCoords(s16 *x, s16 *y, u16 metatileId) { 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; *y = j; @@ -330,7 +330,7 @@ void ToggleSecretBaseEntranceMetatile(void) { 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); return; } @@ -341,7 +341,7 @@ void ToggleSecretBaseEntranceMetatile(void) { 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); return; } @@ -396,7 +396,7 @@ void SetOccupiedSecretBaseEntranceMetatiles(struct MapEvents const *events) { 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; } } @@ -475,7 +475,7 @@ static void EnterNewlyCreatedSecretBase_StartFadeIn(void) FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC); x += 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); FadeInFromBlack(); CreateTask(EnterNewlyCreatedSecretBase_WaitFadeIn, 0); @@ -536,13 +536,13 @@ void InitSecretBaseAppearance(bool8 hidePC) { // Another player's secret base. Change PC type to the "Register" 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) { // Change PC to regular ground tile. 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, events->bgEvents[i].y + MAP_OFFSET, - sSecretBaseEntranceMetatiles[j].closedMetatileId | METATILE_COLLISION_MASK); + sSecretBaseEntranceMetatiles[j].closedMetatileId | MAPGRID_COLLISION_MASK); break; } } diff --git a/src/trainer_hill.c b/src/trainer_hill.c index 3ada262e5..bf988b49a 100644 --- a/src/trainer_hill.c +++ b/src/trainer_hill.c @@ -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); 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) diff --git a/src/tv.c b/src/tv.c index 710b98968..b9d064026 100644 --- a/src/tv.c +++ b/src/tv.c @@ -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 y; @@ -862,7 +862,7 @@ static void SetTVMetatilesOnMap(int width, int height, u16 tileId) for (x = 0; x < width; x++) { if (MapGridGetMetatileBehaviorAt(x, y) == MB_TELEVISION) - MapGridSetMetatileIdAt(x, y, tileId | METATILE_COLLISION_MASK); + MapGridSetMetatileIdAt(x, y, metatileId | MAPGRID_COLLISION_MASK); } } }