Pick better names for constants

This commit is contained in:
Phlosioneer 2019-02-26 22:56:22 -05:00 committed by huderlem
parent 189d387f01
commit da0687987d
12 changed files with 54 additions and 54 deletions

View File

@ -1163,12 +1163,12 @@
.endm
@ Changes the metatile at (x, y) on the current map.
.macro setmetatile x:req, y:req, metatile_number:req, is_impassable:req
.macro setmetatile x:req, y:req, metatile_number:req, has_collision:req
.byte 0xa2
.2byte \x
.2byte \y
.2byte \metatile_number
.2byte \is_impassable
.2byte \has_collision
.endm
@ Queues a weather change to the default weather for the map.

View File

@ -1,12 +1,12 @@
#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
#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
enum
{

View File

@ -1267,7 +1267,7 @@ static u8 GetPostBattleDirectionHintTextIndex(int *hintType, u8 minDistanceForEx
{
for (x = 0; x < 32; x++)
{
if ((map[x] & MAP_METATILE_ID_MASK) == FLOOR_EXIT_METATILE)
if ((map[x] & 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] & MAP_METATILE_ID_MASK) != FLOOR_EXIT_METATILE)
if ((layoutMap[x] & METATILE_ID_MASK) != FLOOR_EXIT_METATILE)
{
map[x] = layoutMap[x];
}

View File

@ -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) & MAP_METATILE_ID_MASK);
firstTileNum = (firstTileNum & (METATILE_COLLISION_MASK | METATILE_ELEVATION_MASK)) + ((firstTileNum + tileNumDelta) & 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) & MAP_METATILE_ID_MASK);
firstTileNum = (firstTileNum & (METATILE_COLLISION_MASK | METATILE_ELEVATION_MASK)) + ((firstTileNum + tileNumDelta) & METATILE_ID_MASK);
}
}
break;

View File

@ -1173,7 +1173,7 @@ 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)))
{
impassableFlag = MAP_IMPASSABLE_MASK;
impassableFlag = METATILE_COLLISION_MASK;
}
else
{
@ -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]) & MAP_TILE_ELEVATION_MASK;
behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_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]) & MAP_TILE_ELEVATION_MASK;
behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_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]) & MAP_TILE_ELEVATION_MASK;
behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[j]) & METATILE_ELEVATION_MASK;
if (!MetatileBehavior_IsNormal(behaviorAt) && !MetatileBehavior_IsSecretBaseNorthWall(behaviorAt))
{
return FALSE;

View File

@ -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] | MAP_TILE_ELEVATION_MASK;
*dest = gFieldMoveStreaksTilemap[i] | METATILE_ELEVATION_MASK;
}
}

View File

@ -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 | MAP_IMPASSABLE_MASK);
MapGridSetMetatileIdAt(x[i] + 7, y[i] + 8, (a1 + 8) | MAP_IMPASSABLE_MASK);
MapGridSetMetatileIdAt(x[i] + 7, y[i] + 7, a1 | METATILE_COLLISION_MASK);
MapGridSetMetatileIdAt(x[i] + 7, y[i] + 8, (a1 + 8) | METATILE_COLLISION_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 | MAP_IMPASSABLE_MASK);
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | METATILE_COLLISION_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 | MAP_IMPASSABLE_MASK);
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | METATILE_COLLISION_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] | MAP_IMPASSABLE_MASK);
MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2BF4[y][data[0] % 3] | METATILE_COLLISION_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] | MAP_IMPASSABLE_MASK);
MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2C06[y][data[0] % 3] | METATILE_COLLISION_MASK);
}
}
}

View File

@ -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 |= MAP_IMPASSABLE_MASK;
block |= METATILE_COLLISION_MASK;
}
if (block == MAP_UNDEFINED_METATILE_ID)
if (block == METATILE_ID_UNDEFINED)
{
return 0;
}
return block >> MAP_TILE_ELEVATION_SHIFT;
return block >> METATILE_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 |= MAP_IMPASSABLE_MASK;
block |= METATILE_COLLISION_MASK;
}
if (block == MAP_UNDEFINED_METATILE_ID)
if (block == METATILE_ID_UNDEFINED)
{
return 1;
}
return (block & MAP_IMPASSABLE_MASK) >> MAP_IMPASSABLE_SHIFT;
return (block & METATILE_COLLISION_MASK) >> METATILE_COLLISION_SHIFT;
}
u32 MapGridGetMetatileIdAt(int x, int y)
@ -439,19 +439,19 @@ u32 MapGridGetMetatileIdAt(int x, int y)
mapLayout = gMapHeader.mapLayout;
i = (x + 1) & 1;
i += ((y + 1) & 1) * 2;
block = mapLayout->border[i] | MAP_IMPASSABLE_MASK;
block = mapLayout->border[i] | METATILE_COLLISION_MASK;
}
if (block == MAP_UNDEFINED_METATILE_ID)
if (block == METATILE_ID_UNDEFINED)
{
border = gMapHeader.mapLayout->border;
j = (x + 1) & 1;
j += ((y + 1) & 1) * 2;
block2 = gMapHeader.mapLayout->border[j];
// This OR is completely pointless.
block2 |= MAP_IMPASSABLE_MASK;
return block2 & MAP_METATILE_ID_MASK;
block2 |= METATILE_COLLISION_MASK;
return block2 & METATILE_ID_MASK;
}
return block & MAP_METATILE_ID_MASK;
return block & METATILE_ID_MASK;
}
u32 MapGridGetMetatileBehaviorAt(int x, int y)
@ -465,7 +465,7 @@ u8 MapGridGetMetatileLayerTypeAt(int x, int y)
{
u16 metatile;
metatile = MapGridGetMetatileIdAt(x, y);
return (GetBehaviorByMetatileId(metatile) & MAP_TILE_ELEVATION_MASK) >> MAP_TILE_ELEVATION_SHIFT;
return (GetBehaviorByMetatileId(metatile) & METATILE_ELEVATION_MASK) >> METATILE_ELEVATION_SHIFT;
}
void MapGridSetMetatileIdAt(int x, int y, u16 metatile)
@ -475,7 +475,7 @@ void MapGridSetMetatileIdAt(int x, int y, u16 metatile)
&& y >= 0 && y < gBackupMapLayout.height)
{
i = x + y * gBackupMapLayout.width;
gBackupMapLayout.map[i] = (gBackupMapLayout.map[i] & MAP_TILE_ELEVATION_MASK) | (metatile & ~MAP_TILE_ELEVATION_MASK);
gBackupMapLayout.map[i] = (gBackupMapLayout.map[i] & METATILE_ELEVATION_MASK) | (metatile & ~METATILE_ELEVATION_MASK);
}
}
@ -655,7 +655,7 @@ int GetMapBorderIdAt(int x, int y)
i = gBackupMapLayout.width;
i *= y;
block = gBackupMapLayout.map[x + i];
if (block == MAP_UNDEFINED_METATILE_ID)
if (block == METATILE_ID_UNDEFINED)
{
goto fail;
}
@ -665,8 +665,8 @@ int GetMapBorderIdAt(int x, int y)
mapLayout = gMapHeader.mapLayout;
j = (x + 1) & 1;
j += ((y + 1) & 1) * 2;
block2 = MAP_IMPASSABLE_MASK | mapLayout->border[j];
if (block2 == MAP_UNDEFINED_METATILE_ID)
block2 = METATILE_COLLISION_MASK | mapLayout->border[j];
if (block2 == METATILE_ID_UNDEFINED)
{
goto fail;
}
@ -922,9 +922,9 @@ void sub_8088B94(int x, int y, int a2)
if (x >= 0 && x < gBackupMapLayout.width && y >= 0 && y < gBackupMapLayout.height)
{
if (a2 != 0)
gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= MAP_IMPASSABLE_MASK;
gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= METATILE_COLLISION_MASK;
else
gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= 0xF3FF;
gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= ~METATILE_COLLISION_MASK;
}
}
@ -938,7 +938,7 @@ static bool8 SkipCopyingMetatileFromSavedMap(u16* mapMetatilePtr, u16 mapWidth,
else
mapMetatilePtr += mapWidth;
if (sub_80FADE4(*mapMetatilePtr & MAP_METATILE_ID_MASK, yMode) == 1)
if (sub_80FADE4(*mapMetatilePtr & METATILE_ID_MASK, yMode) == 1)
return TRUE;
return FALSE;
}

View File

@ -76,13 +76,13 @@ static void sub_80E1444(u8 taskId)
sub_80E12E8(taskId, gUnknown_08589AC0, 0);
break;
case 2:
sub_80E12E8(taskId, gUnknown_08589AC6, MAP_IMPASSABLE_MASK);
sub_80E12E8(taskId, gUnknown_08589AC6, METATILE_COLLISION_MASK);
break;
case 3:
sub_80E12E8(taskId, gUnknown_08589ACC, 0);
break;
case 4:
sub_80E12E8(taskId, gUnknown_08589AD2, MAP_IMPASSABLE_MASK);
sub_80E12E8(taskId, gUnknown_08589AD2, METATILE_COLLISION_MASK);
break;
case 5:
sub_80E12E8(taskId, gUnknown_08589AD8, 0);

View File

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

View File

@ -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] & MAP_METATILE_ID_MASK) == tile)
if ((mapLayout->map[y * mapLayout->width + x] & 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 | MAP_IMPASSABLE_MASK);
MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | METATILE_COLLISION_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 | MAP_IMPASSABLE_MASK);
MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile1 | METATILE_COLLISION_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 | MAP_IMPASSABLE_MASK);
MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | METATILE_COLLISION_MASK);
break;
}
}
@ -434,7 +434,7 @@ void sub_80E9108(void)
sub_80E8CB0(&x, &y, 0x220);
x += 7;
y += 7;
MapGridSetMetatileIdAt(x, y, 0x220 | MAP_IMPASSABLE_MASK);
MapGridSetMetatileIdAt(x, y, 0x220 | METATILE_COLLISION_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 | MAP_IMPASSABLE_MASK);
MapGridSetMetatileIdAt(x + 7, y + 7, 0x221 | METATILE_COLLISION_MASK);
}
else if (flagIn == 1 && VarGet(VAR_0x4089) == 1)
{
sub_80E8CB0(&x, &y, 0x220);
MapGridSetMetatileIdAt(x + 7, y + 7, 0x20a | MAP_IMPASSABLE_MASK);
MapGridSetMetatileIdAt(x + 7, y + 7, 0x20a | METATILE_COLLISION_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 | MAP_IMPASSABLE_MASK);
MapGridSetMetatileIdAt(events->bgEvents[i].x + 7, events->bgEvents[i].y + 7, gUnknown_0858CFCC[j].tile1 | METATILE_COLLISION_MASK);
break;
}
}

View File

@ -856,7 +856,7 @@ void SetTVMetatilesOnMap(int width, int height, u16 tileId)
{
if (MapGridGetMetatileBehaviorAt(x, y) == MB_TELEVISION)
{
MapGridSetMetatileIdAt(x, y, tileId | MAP_IMPASSABLE_MASK);
MapGridSetMetatileIdAt(x, y, tileId | METATILE_COLLISION_MASK);
}
}
}