From 189d387f01104a715d788690fbc76d987ea3d6e1 Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Fri, 22 Feb 2019 03:08:48 -0500 Subject: [PATCH] Add macros for metatile manipulation --- asm/macros/event.inc | 4 ++-- include/global.fieldmap.h | 11 +++++++++-- src/battle_pyramid.c | 4 ++-- src/bg.c | 4 ++-- src/decoration.c | 16 ++++++++-------- src/field_effect.c | 2 +- src/field_specials.c | 12 ++++++------ src/fieldmap.c | 37 +++++++++++++++++++------------------ src/fldeff_escalator.c | 14 +++++++------- src/scrcmd.c | 6 +++--- src/secret_base.c | 16 ++++++++-------- src/tv.c | 5 +++-- 12 files changed, 70 insertions(+), 61 deletions(-) diff --git a/asm/macros/event.inc b/asm/macros/event.inc index fa0b3fa06..fa27d049e 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -1163,12 +1163,12 @@ .endm @ Changes the metatile at (x, y) on the current map. - .macro setmetatile x:req, y:req, metatile_number:req, tile_attrib:req + .macro setmetatile x:req, y:req, metatile_number:req, is_impassable:req .byte 0xa2 .2byte \x .2byte \y .2byte \metatile_number - .2byte \tile_attrib + .2byte \is_impassable .endm @ Queues a weather change to the default weather for the map. diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 74a8363bb..2b85a02d1 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -1,6 +1,13 @@ #ifndef GUARD_GLOBAL_FIELDMAP_H #define GUARD_GLOBAL_FIELDMAP_H +#define MAP_IMPASSABLE_MASK 0x0C00 +#define MAP_METATILE_ID_MASK 0x03FF +#define MAP_UNDEFINED_METATILE_ID 0x03FF +#define MAP_TILE_ELEVATION_SHIFT 12 +#define MAP_IMPASSABLE_SHIFT 10 +#define MAP_TILE_ELEVATION_MASK 0xF000 + enum { CONNECTION_SOUTH = 1, @@ -19,8 +26,8 @@ struct Tileset /*0x01*/ bool8 isSecondary; /*0x04*/ void *tiles; /*0x08*/ void *palettes; - /*0x0c*/ void *metatiles; - /*0x10*/ void *metatileAttributes; + /*0x0c*/ u16 *metatiles; + /*0x10*/ u16 *metatileAttributes; /*0x14*/ TilesetCB callback; }; diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 340c17c59..92ff257b0 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -1267,7 +1267,7 @@ static u8 GetPostBattleDirectionHintTextIndex(int *hintType, u8 minDistanceForEx { for (x = 0; x < 32; x++) { - if ((map[x] & 0x3FF) == FLOOR_EXIT_METATILE) + if ((map[x] & MAP_METATILE_ID_MASK) == FLOOR_EXIT_METATILE) { x += 7 - gEventObjects[gSelectedEventObject].initialCoords.x; y += 7 - gEventObjects[gSelectedEventObject].initialCoords.y; @@ -1568,7 +1568,7 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio { for (x = 0; x < mapLayout->width; x++) { - if ((layoutMap[x] & 0x3FF) != FLOOR_EXIT_METATILE) + if ((layoutMap[x] & MAP_METATILE_ID_MASK) != FLOOR_EXIT_METATILE) { map[x] = layoutMap[x]; } diff --git a/src/bg.c b/src/bg.c index f73f5998d..571518650 100644 --- a/src/bg.c +++ b/src/bg.c @@ -1056,7 +1056,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 & 0xFC00) + ((firstTileNum + tileNumDelta) & 0x3FF); + firstTileNum = (firstTileNum & 0xFC00) + ((firstTileNum + tileNumDelta) & MAP_METATILE_ID_MASK); } } break; @@ -1067,7 +1067,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 & 0xFC00) + ((firstTileNum + tileNumDelta) & 0x3FF); + firstTileNum = (firstTileNum & 0xFC00) + ((firstTileNum + tileNumDelta) & MAP_METATILE_ID_MASK); } } break; diff --git a/src/decoration.c b/src/decoration.c index 2ac49b98c..e5f3b6d46 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -1158,7 +1158,7 @@ void sub_8127B90(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decor) u16 i; u16 j; u16 behavior; - u16 flags; + u16 impassableFlag; u16 v0; u16 v1; s16 decLeft; @@ -1173,11 +1173,11 @@ void sub_8127B90(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decor) behavior = GetBehaviorByMetatileId(0x200 + gDecorations[decor].tiles[i * decWidth + j]); if (MetatileBehavior_IsSecretBaseImpassable(behavior) == TRUE || (gDecorations[decor].permission != DECORPERM_PASS_FLOOR && (behavior >> 12))) { - flags = 0xc00; + impassableFlag = MAP_IMPASSABLE_MASK; } else { - flags = 0x000; + impassableFlag = 0x000; } if (gDecorations[decor].permission != DECORPERM_NA_WALL && MetatileBehavior_IsSecretBaseNorthWall(MapGridGetMetatileBehaviorAt(decLeft, decBottom)) == TRUE) { @@ -1190,11 +1190,11 @@ void sub_8127B90(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decor) v1 = sub_8127B54(gDecorations[decor].id, i * decWidth + j); if (v1 != 0xFFFF) { - MapGridSetMetatileEntryAt(decLeft, decBottom, (gDecorations[decor].tiles[i * decWidth + j] + (0x200 | v0)) | flags | v1); + MapGridSetMetatileEntryAt(decLeft, decBottom, (gDecorations[decor].tiles[i * decWidth + j] + (0x200 | v0)) | impassableFlag | v1); } else { - MapGridSetMetatileIdAt(decLeft, decBottom, (gDecorations[decor].tiles[i * decWidth + j] + (0x200 | v0)) | flags); + MapGridSetMetatileIdAt(decLeft, decBottom, (gDecorations[decor].tiles[i * decWidth + j] + (0x200 | v0)) | impassableFlag); } } } @@ -1502,7 +1502,7 @@ bool8 sub_812853C(u8 taskId, const struct Decoration *decoration) { curX = gTasks[taskId].data[0] + j; behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); - behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & 0xf000; + behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & MAP_TILE_ELEVATION_MASK; if (!sub_81284F4(behaviorAt, decoration)) { return FALSE; @@ -1527,7 +1527,7 @@ bool8 sub_812853C(u8 taskId, const struct Decoration *decoration) { curX = gTasks[taskId].data[0] + j; behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); - behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & 0xf000; + behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & MAP_TILE_ELEVATION_MASK; if (!MetatileBehavior_IsNormal(behaviorAt) && !sub_8128484(behaviorAt, behaviorBy)) { return FALSE; @@ -1547,7 +1547,7 @@ bool8 sub_812853C(u8 taskId, const struct Decoration *decoration) { curX = gTasks[taskId].data[0] + j; behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); - behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[j]) & 0xf000; + behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[j]) & MAP_TILE_ELEVATION_MASK; if (!MetatileBehavior_IsNormal(behaviorAt) && !MetatileBehavior_IsSecretBaseNorthWall(behaviorAt)) { return FALSE; diff --git a/src/field_effect.c b/src/field_effect.c index e7c0b39b9..07a7f9caf 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -2620,7 +2620,7 @@ static void sub_80B8874(u16 offs) dest = (u16 *)(VRAM + 0x140 + offs); for (i = 0; i < 0x140; i++, dest++) { - *dest = gFieldMoveStreaksTilemap[i] | 0xf000; + *dest = gFieldMoveStreaksTilemap[i] | MAP_TILE_ELEVATION_MASK; } } diff --git a/src/field_specials.c b/src/field_specials.c index 307f81399..c7d1f4367 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -887,8 +887,8 @@ static void PetalburgGymFunc(u8 a0, u16 a1) } for (i = 0; i < nDoors; i++) { - MapGridSetMetatileIdAt(x[i] + 7, y[i] + 7, a1 | 0xc00); - MapGridSetMetatileIdAt(x[i] + 7, y[i] + 8, (a1 + 8) | 0xc00); + MapGridSetMetatileIdAt(x[i] + 7, y[i] + 7, a1 | MAP_IMPASSABLE_MASK); + MapGridSetMetatileIdAt(x[i] + 7, y[i] + 8, (a1 + 8) | MAP_IMPASSABLE_MASK); } DrawWholeMapView(); } @@ -1100,7 +1100,7 @@ static void PCTurnOnEffect_1(s16 flag, s8 dx, s8 dy) tileId = 0x27e; } } - MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | 0xc00); + MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | MAP_IMPASSABLE_MASK); } void DoPCTurnOffEffect(void) @@ -1141,7 +1141,7 @@ static void PCTurnOffEffect(void) { tileId = 0x259; } - MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | 0xc00); + MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | MAP_IMPASSABLE_MASK); DrawWholeMapView(); } @@ -1892,7 +1892,7 @@ static void sub_8139C80(u8 taskId) { for (x = 0; x < 3; x++) { - MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2BF4[y][data[0] % 3] | 0xC00); + MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2BF4[y][data[0] % 3] | MAP_IMPASSABLE_MASK); } } } @@ -1902,7 +1902,7 @@ static void sub_8139C80(u8 taskId) { for (x = 0; x < 3; x++) { - MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2C06[y][data[0] % 3] | 0xC00); + MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2C06[y][data[0] % 3] | MAP_IMPASSABLE_MASK); } } } diff --git a/src/fieldmap.c b/src/fieldmap.c index cf5f0356e..8131fb01b 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -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; } diff --git a/src/fldeff_escalator.c b/src/fldeff_escalator.c index 3d00fb162..4a1fb0fd5 100644 --- a/src/fldeff_escalator.c +++ b/src/fldeff_escalator.c @@ -7,7 +7,7 @@ static EWRAM_DATA u8 sEscalatorAnim_TaskId = 0; -static void sub_80E12E8(u8 taskId, const s16 *list, u16 c) +static void sub_80E12E8(u8 taskId, const s16 *list, u16 isImpassableFlag) { s16 r5 = gTasks[taskId].data[4] - 1; s16 r3 = gTasks[taskId].data[5] - 1; @@ -26,9 +26,9 @@ static void sub_80E12E8(u8 taskId, const s16 *list, u16 c) if (list[r4] == metatileId) { if (r4 != 2) - MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[r4 + 1]); + MapGridSetMetatileIdAt(r5 + x, r3 + y, isImpassableFlag | list[r4 + 1]); else - MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[0]); + MapGridSetMetatileIdAt(r5 + x, r3 + y, isImpassableFlag | list[0]); } } } @@ -44,9 +44,9 @@ static void sub_80E12E8(u8 taskId, const s16 *list, u16 c) if (list[2 - r4] == metatileId) { if (r4 != 2) - MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[1 - r4]); + MapGridSetMetatileIdAt(r5 + x, r3 + y, isImpassableFlag | list[1 - r4]); else - MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[2]); + MapGridSetMetatileIdAt(r5 + x, r3 + y, isImpassableFlag | list[2]); } } } @@ -76,13 +76,13 @@ static void sub_80E1444(u8 taskId) sub_80E12E8(taskId, gUnknown_08589AC0, 0); break; case 2: - sub_80E12E8(taskId, gUnknown_08589AC6, 0xC00); + sub_80E12E8(taskId, gUnknown_08589AC6, MAP_IMPASSABLE_MASK); break; case 3: sub_80E12E8(taskId, gUnknown_08589ACC, 0); break; case 4: - sub_80E12E8(taskId, gUnknown_08589AD2, 0xC00); + sub_80E12E8(taskId, gUnknown_08589AD2, MAP_IMPASSABLE_MASK); break; case 5: sub_80E12E8(taskId, gUnknown_08589AD8, 0); diff --git a/src/scrcmd.c b/src/scrcmd.c index 51d96ff2e..9bafac41a 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -2028,14 +2028,14 @@ bool8 ScrCmd_setmetatile(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); u16 tileId = VarGet(ScriptReadHalfword(ctx)); - u16 v8 = VarGet(ScriptReadHalfword(ctx)); + u16 isImpassable = VarGet(ScriptReadHalfword(ctx)); x += 7; y += 7; - if (!v8) + if (!isImpassable) MapGridSetMetatileIdAt(x, y, tileId); else - MapGridSetMetatileIdAt(x, y, tileId | 0xC00); + MapGridSetMetatileIdAt(x, y, tileId | MAP_IMPASSABLE_MASK); return FALSE; } diff --git a/src/secret_base.c b/src/secret_base.c index adcab9cbc..488f49377 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -259,7 +259,7 @@ void sub_80E8CB0(s16 *xPtr, s16 *yPtr, u16 tile) { for (x = 0; x < mapLayout->width; x ++) { - if ((mapLayout->map[y * mapLayout->width + x] & 0x3ff) == tile) + if ((mapLayout->map[y * mapLayout->width + x] & MAP_METATILE_ID_MASK) == tile) { *xPtr = x; *yPtr = y; @@ -282,7 +282,7 @@ void sub_80E8D4C(void) { if (gUnknown_0858CFCC[i].tile1 == tile) { - MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | 0xC00); + MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | MAP_IMPASSABLE_MASK); CurrentMapDrawMetatileAt(x, y); return; } @@ -291,7 +291,7 @@ void sub_80E8D4C(void) { if (gUnknown_0858CFCC[i].tile2 == tile) { - MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile1 | 0xC00); + MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile1 | MAP_IMPASSABLE_MASK); CurrentMapDrawMetatileAt(x, y); return; } @@ -352,7 +352,7 @@ void sub_80E8EE0(struct MapEvents const *events) { if (gUnknown_0858CFCC[i].tile1 == tile_id) { - MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | 0xc00); + MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | MAP_IMPASSABLE_MASK); break; } } @@ -434,7 +434,7 @@ void sub_80E9108(void) sub_80E8CB0(&x, &y, 0x220); x += 7; y += 7; - MapGridSetMetatileIdAt(x, y, 0x220 | 0xC00); + MapGridSetMetatileIdAt(x, y, 0x220 | MAP_IMPASSABLE_MASK); CurrentMapDrawMetatileAt(x, y); pal_fill_black(); CreateTask(sub_80E90C8, 0); @@ -492,12 +492,12 @@ void sub_80E9238(u8 flagIn) if (curBaseId != 0) { sub_80E8CB0(&x, &y, 0x220); - MapGridSetMetatileIdAt(x + 7, y + 7, 0x221 | 0xc00); + MapGridSetMetatileIdAt(x + 7, y + 7, 0x221 | MAP_IMPASSABLE_MASK); } else if (flagIn == 1 && VarGet(VAR_0x4089) == 1) { sub_80E8CB0(&x, &y, 0x220); - MapGridSetMetatileIdAt(x + 7, y + 7, 0x20a | 0xc00); + MapGridSetMetatileIdAt(x + 7, y + 7, 0x20a | MAP_IMPASSABLE_MASK); } } } @@ -791,7 +791,7 @@ void sub_80E9AD0(void) { if (gUnknown_0858CFCC[j].tile2 == tile) { - MapGridSetMetatileIdAt(events->bgEvents[i].x + 7, events->bgEvents[i].y + 7, gUnknown_0858CFCC[j].tile1 | 0xc00); + MapGridSetMetatileIdAt(events->bgEvents[i].x + 7, events->bgEvents[i].y + 7, gUnknown_0858CFCC[j].tile1 | MAP_IMPASSABLE_MASK); break; } } diff --git a/src/tv.c b/src/tv.c index ee3614e83..6ab91ac07 100644 --- a/src/tv.c +++ b/src/tv.c @@ -39,6 +39,7 @@ #include "tv.h" #include "data2.h" #include "constants/layouts.h" +#include "constants/metatile_behaviors.h" // Static type declarations @@ -853,9 +854,9 @@ void SetTVMetatilesOnMap(int width, int height, u16 tileId) { for (x = 0; x < width; x ++) { - if (MapGridGetMetatileBehaviorAt(x, y) == 0x86) // is this tile a TV? + if (MapGridGetMetatileBehaviorAt(x, y) == MB_TELEVISION) { - MapGridSetMetatileIdAt(x, y, tileId | 0xc00); + MapGridSetMetatileIdAt(x, y, tileId | MAP_IMPASSABLE_MASK); } } }