mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Add macros for metatile manipulation
This commit is contained in:
parent
9ed0f77528
commit
189d387f01
@ -1163,12 +1163,12 @@
|
|||||||
.endm
|
.endm
|
||||||
|
|
||||||
@ Changes the metatile at (x, y) on the current map.
|
@ 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
|
.byte 0xa2
|
||||||
.2byte \x
|
.2byte \x
|
||||||
.2byte \y
|
.2byte \y
|
||||||
.2byte \metatile_number
|
.2byte \metatile_number
|
||||||
.2byte \tile_attrib
|
.2byte \is_impassable
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
@ Queues a weather change to the default weather for the map.
|
@ Queues a weather change to the default weather for the map.
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
#ifndef GUARD_GLOBAL_FIELDMAP_H
|
#ifndef GUARD_GLOBAL_FIELDMAP_H
|
||||||
#define 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
|
enum
|
||||||
{
|
{
|
||||||
CONNECTION_SOUTH = 1,
|
CONNECTION_SOUTH = 1,
|
||||||
@ -19,8 +26,8 @@ struct Tileset
|
|||||||
/*0x01*/ bool8 isSecondary;
|
/*0x01*/ bool8 isSecondary;
|
||||||
/*0x04*/ void *tiles;
|
/*0x04*/ void *tiles;
|
||||||
/*0x08*/ void *palettes;
|
/*0x08*/ void *palettes;
|
||||||
/*0x0c*/ void *metatiles;
|
/*0x0c*/ u16 *metatiles;
|
||||||
/*0x10*/ void *metatileAttributes;
|
/*0x10*/ u16 *metatileAttributes;
|
||||||
/*0x14*/ TilesetCB callback;
|
/*0x14*/ TilesetCB callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1267,7 +1267,7 @@ static u8 GetPostBattleDirectionHintTextIndex(int *hintType, u8 minDistanceForEx
|
|||||||
{
|
{
|
||||||
for (x = 0; x < 32; x++)
|
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;
|
x += 7 - gEventObjects[gSelectedEventObject].initialCoords.x;
|
||||||
y += 7 - gEventObjects[gSelectedEventObject].initialCoords.y;
|
y += 7 - gEventObjects[gSelectedEventObject].initialCoords.y;
|
||||||
@ -1568,7 +1568,7 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio
|
|||||||
{
|
{
|
||||||
for (x = 0; x < mapLayout->width; x++)
|
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];
|
map[x] = layoutMap[x];
|
||||||
}
|
}
|
||||||
|
4
src/bg.c
4
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++)
|
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 & 0xFC00) + ((firstTileNum + tileNumDelta) & 0x3FF);
|
firstTileNum = (firstTileNum & 0xFC00) + ((firstTileNum + tileNumDelta) & MAP_METATILE_ID_MASK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1067,7 +1067,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 & 0xFC00) + ((firstTileNum + tileNumDelta) & 0x3FF);
|
firstTileNum = (firstTileNum & 0xFC00) + ((firstTileNum + tileNumDelta) & MAP_METATILE_ID_MASK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1158,7 +1158,7 @@ void sub_8127B90(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decor)
|
|||||||
u16 i;
|
u16 i;
|
||||||
u16 j;
|
u16 j;
|
||||||
u16 behavior;
|
u16 behavior;
|
||||||
u16 flags;
|
u16 impassableFlag;
|
||||||
u16 v0;
|
u16 v0;
|
||||||
u16 v1;
|
u16 v1;
|
||||||
s16 decLeft;
|
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]);
|
behavior = GetBehaviorByMetatileId(0x200 + gDecorations[decor].tiles[i * decWidth + j]);
|
||||||
if (MetatileBehavior_IsSecretBaseImpassable(behavior) == TRUE || (gDecorations[decor].permission != DECORPERM_PASS_FLOOR && (behavior >> 12)))
|
if (MetatileBehavior_IsSecretBaseImpassable(behavior) == TRUE || (gDecorations[decor].permission != DECORPERM_PASS_FLOOR && (behavior >> 12)))
|
||||||
{
|
{
|
||||||
flags = 0xc00;
|
impassableFlag = MAP_IMPASSABLE_MASK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flags = 0x000;
|
impassableFlag = 0x000;
|
||||||
}
|
}
|
||||||
if (gDecorations[decor].permission != DECORPERM_NA_WALL && MetatileBehavior_IsSecretBaseNorthWall(MapGridGetMetatileBehaviorAt(decLeft, decBottom)) == TRUE)
|
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);
|
v1 = sub_8127B54(gDecorations[decor].id, i * decWidth + j);
|
||||||
if (v1 != 0xFFFF)
|
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
|
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;
|
curX = gTasks[taskId].data[0] + j;
|
||||||
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
|
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))
|
if (!sub_81284F4(behaviorAt, decoration))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1527,7 +1527,7 @@ bool8 sub_812853C(u8 taskId, const struct Decoration *decoration)
|
|||||||
{
|
{
|
||||||
curX = gTasks[taskId].data[0] + j;
|
curX = gTasks[taskId].data[0] + j;
|
||||||
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
|
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))
|
if (!MetatileBehavior_IsNormal(behaviorAt) && !sub_8128484(behaviorAt, behaviorBy))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1547,7 +1547,7 @@ bool8 sub_812853C(u8 taskId, const struct Decoration *decoration)
|
|||||||
{
|
{
|
||||||
curX = gTasks[taskId].data[0] + j;
|
curX = gTasks[taskId].data[0] + j;
|
||||||
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
|
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))
|
if (!MetatileBehavior_IsNormal(behaviorAt) && !MetatileBehavior_IsSecretBaseNorthWall(behaviorAt))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -2620,7 +2620,7 @@ static void sub_80B8874(u16 offs)
|
|||||||
dest = (u16 *)(VRAM + 0x140 + offs);
|
dest = (u16 *)(VRAM + 0x140 + offs);
|
||||||
for (i = 0; i < 0x140; i++, dest++)
|
for (i = 0; i < 0x140; i++, dest++)
|
||||||
{
|
{
|
||||||
*dest = gFieldMoveStreaksTilemap[i] | 0xf000;
|
*dest = gFieldMoveStreaksTilemap[i] | MAP_TILE_ELEVATION_MASK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -887,8 +887,8 @@ static void PetalburgGymFunc(u8 a0, u16 a1)
|
|||||||
}
|
}
|
||||||
for (i = 0; i < nDoors; i++)
|
for (i = 0; i < nDoors; i++)
|
||||||
{
|
{
|
||||||
MapGridSetMetatileIdAt(x[i] + 7, y[i] + 7, a1 | 0xc00);
|
MapGridSetMetatileIdAt(x[i] + 7, y[i] + 7, a1 | MAP_IMPASSABLE_MASK);
|
||||||
MapGridSetMetatileIdAt(x[i] + 7, y[i] + 8, (a1 + 8) | 0xc00);
|
MapGridSetMetatileIdAt(x[i] + 7, y[i] + 8, (a1 + 8) | MAP_IMPASSABLE_MASK);
|
||||||
}
|
}
|
||||||
DrawWholeMapView();
|
DrawWholeMapView();
|
||||||
}
|
}
|
||||||
@ -1100,7 +1100,7 @@ static void PCTurnOnEffect_1(s16 flag, s8 dx, s8 dy)
|
|||||||
tileId = 0x27e;
|
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)
|
void DoPCTurnOffEffect(void)
|
||||||
@ -1141,7 +1141,7 @@ static void PCTurnOffEffect(void)
|
|||||||
{
|
{
|
||||||
tileId = 0x259;
|
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();
|
DrawWholeMapView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1892,7 +1892,7 @@ static void sub_8139C80(u8 taskId)
|
|||||||
{
|
{
|
||||||
for (x = 0; x < 3; x++)
|
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++)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,15 +383,15 @@ u8 MapGridGetZCoordAt(int x, int y)
|
|||||||
i = (x + 1) & 1;
|
i = (x + 1) & 1;
|
||||||
i += ((y + 1) & 1) * 2;
|
i += ((y + 1) & 1) * 2;
|
||||||
block = gMapHeader.mapLayout->border[i];
|
block = gMapHeader.mapLayout->border[i];
|
||||||
block |= 0xc00;
|
block |= MAP_IMPASSABLE_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block == 0x3ff)
|
if (block == MAP_UNDEFINED_METATILE_ID)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return block >> 12;
|
return block >> MAP_TILE_ELEVATION_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 MapGridIsImpassableAt(int x, int y)
|
u8 MapGridIsImpassableAt(int x, int y)
|
||||||
@ -411,13 +411,13 @@ u8 MapGridIsImpassableAt(int x, int y)
|
|||||||
i = (x + 1) & 1;
|
i = (x + 1) & 1;
|
||||||
i += ((y + 1) & 1) * 2;
|
i += ((y + 1) & 1) * 2;
|
||||||
block = gMapHeader.mapLayout->border[i];
|
block = gMapHeader.mapLayout->border[i];
|
||||||
block |= 0xc00;
|
block |= MAP_IMPASSABLE_MASK;
|
||||||
}
|
}
|
||||||
if (block == 0x3ff)
|
if (block == MAP_UNDEFINED_METATILE_ID)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return (block & 0xc00) >> 10;
|
return (block & MAP_IMPASSABLE_MASK) >> MAP_IMPASSABLE_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 MapGridGetMetatileIdAt(int x, int y)
|
u32 MapGridGetMetatileIdAt(int x, int y)
|
||||||
@ -439,18 +439,19 @@ u32 MapGridGetMetatileIdAt(int x, int y)
|
|||||||
mapLayout = gMapHeader.mapLayout;
|
mapLayout = gMapHeader.mapLayout;
|
||||||
i = (x + 1) & 1;
|
i = (x + 1) & 1;
|
||||||
i += ((y + 1) & 1) * 2;
|
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;
|
border = gMapHeader.mapLayout->border;
|
||||||
j = (x + 1) & 1;
|
j = (x + 1) & 1;
|
||||||
j += ((y + 1) & 1) * 2;
|
j += ((y + 1) & 1) * 2;
|
||||||
block2 = gMapHeader.mapLayout->border[j];
|
block2 = gMapHeader.mapLayout->border[j];
|
||||||
block2 |= 0xc00;
|
// This OR is completely pointless.
|
||||||
return block2 & block;
|
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)
|
u32 MapGridGetMetatileBehaviorAt(int x, int y)
|
||||||
@ -464,7 +465,7 @@ u8 MapGridGetMetatileLayerTypeAt(int x, int y)
|
|||||||
{
|
{
|
||||||
u16 metatile;
|
u16 metatile;
|
||||||
metatile = MapGridGetMetatileIdAt(x, y);
|
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)
|
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)
|
&& y >= 0 && y < gBackupMapLayout.height)
|
||||||
{
|
{
|
||||||
i = x + y * gBackupMapLayout.width;
|
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 = gBackupMapLayout.width;
|
||||||
i *= y;
|
i *= y;
|
||||||
block = gBackupMapLayout.map[x + i];
|
block = gBackupMapLayout.map[x + i];
|
||||||
if (block == 0x3ff)
|
if (block == MAP_UNDEFINED_METATILE_ID)
|
||||||
{
|
{
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -664,8 +665,8 @@ int GetMapBorderIdAt(int x, int y)
|
|||||||
mapLayout = gMapHeader.mapLayout;
|
mapLayout = gMapHeader.mapLayout;
|
||||||
j = (x + 1) & 1;
|
j = (x + 1) & 1;
|
||||||
j += ((y + 1) & 1) * 2;
|
j += ((y + 1) & 1) * 2;
|
||||||
block2 = 0xc00 | mapLayout->border[j];
|
block2 = MAP_IMPASSABLE_MASK | mapLayout->border[j];
|
||||||
if (block2 == 0x3ff)
|
if (block2 == MAP_UNDEFINED_METATILE_ID)
|
||||||
{
|
{
|
||||||
goto fail;
|
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 (x >= 0 && x < gBackupMapLayout.width && y >= 0 && y < gBackupMapLayout.height)
|
||||||
{
|
{
|
||||||
if (a2 != 0)
|
if (a2 != 0)
|
||||||
gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= 0xC00;
|
gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= MAP_IMPASSABLE_MASK;
|
||||||
else
|
else
|
||||||
gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= 0xF3FF;
|
gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= 0xF3FF;
|
||||||
}
|
}
|
||||||
@ -937,7 +938,7 @@ static bool8 SkipCopyingMetatileFromSavedMap(u16* mapMetatilePtr, u16 mapWidth,
|
|||||||
else
|
else
|
||||||
mapMetatilePtr += mapWidth;
|
mapMetatilePtr += mapWidth;
|
||||||
|
|
||||||
if (sub_80FADE4(*mapMetatilePtr & 0x3FF, yMode) == 1)
|
if (sub_80FADE4(*mapMetatilePtr & MAP_METATILE_ID_MASK, yMode) == 1)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
static EWRAM_DATA u8 sEscalatorAnim_TaskId = 0;
|
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 r5 = gTasks[taskId].data[4] - 1;
|
||||||
s16 r3 = gTasks[taskId].data[5] - 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 (list[r4] == metatileId)
|
||||||
{
|
{
|
||||||
if (r4 != 2)
|
if (r4 != 2)
|
||||||
MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[r4 + 1]);
|
MapGridSetMetatileIdAt(r5 + x, r3 + y, isImpassableFlag | list[r4 + 1]);
|
||||||
else
|
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 (list[2 - r4] == metatileId)
|
||||||
{
|
{
|
||||||
if (r4 != 2)
|
if (r4 != 2)
|
||||||
MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[1 - r4]);
|
MapGridSetMetatileIdAt(r5 + x, r3 + y, isImpassableFlag | list[1 - r4]);
|
||||||
else
|
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);
|
sub_80E12E8(taskId, gUnknown_08589AC0, 0);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
sub_80E12E8(taskId, gUnknown_08589AC6, 0xC00);
|
sub_80E12E8(taskId, gUnknown_08589AC6, MAP_IMPASSABLE_MASK);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
sub_80E12E8(taskId, gUnknown_08589ACC, 0);
|
sub_80E12E8(taskId, gUnknown_08589ACC, 0);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
sub_80E12E8(taskId, gUnknown_08589AD2, 0xC00);
|
sub_80E12E8(taskId, gUnknown_08589AD2, MAP_IMPASSABLE_MASK);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
sub_80E12E8(taskId, gUnknown_08589AD8, 0);
|
sub_80E12E8(taskId, gUnknown_08589AD8, 0);
|
||||||
|
@ -2028,14 +2028,14 @@ bool8 ScrCmd_setmetatile(struct ScriptContext *ctx)
|
|||||||
u16 x = VarGet(ScriptReadHalfword(ctx));
|
u16 x = VarGet(ScriptReadHalfword(ctx));
|
||||||
u16 y = VarGet(ScriptReadHalfword(ctx));
|
u16 y = VarGet(ScriptReadHalfword(ctx));
|
||||||
u16 tileId = VarGet(ScriptReadHalfword(ctx));
|
u16 tileId = VarGet(ScriptReadHalfword(ctx));
|
||||||
u16 v8 = VarGet(ScriptReadHalfword(ctx));
|
u16 isImpassable = VarGet(ScriptReadHalfword(ctx));
|
||||||
|
|
||||||
x += 7;
|
x += 7;
|
||||||
y += 7;
|
y += 7;
|
||||||
if (!v8)
|
if (!isImpassable)
|
||||||
MapGridSetMetatileIdAt(x, y, tileId);
|
MapGridSetMetatileIdAt(x, y, tileId);
|
||||||
else
|
else
|
||||||
MapGridSetMetatileIdAt(x, y, tileId | 0xC00);
|
MapGridSetMetatileIdAt(x, y, tileId | MAP_IMPASSABLE_MASK);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ void sub_80E8CB0(s16 *xPtr, s16 *yPtr, u16 tile)
|
|||||||
{
|
{
|
||||||
for (x = 0; x < mapLayout->width; x ++)
|
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;
|
*xPtr = x;
|
||||||
*yPtr = y;
|
*yPtr = y;
|
||||||
@ -282,7 +282,7 @@ void sub_80E8D4C(void)
|
|||||||
{
|
{
|
||||||
if (gUnknown_0858CFCC[i].tile1 == tile)
|
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);
|
CurrentMapDrawMetatileAt(x, y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ void sub_80E8D4C(void)
|
|||||||
{
|
{
|
||||||
if (gUnknown_0858CFCC[i].tile2 == tile)
|
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);
|
CurrentMapDrawMetatileAt(x, y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ void sub_80E8EE0(struct MapEvents const *events)
|
|||||||
{
|
{
|
||||||
if (gUnknown_0858CFCC[i].tile1 == tile_id)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -434,7 +434,7 @@ void sub_80E9108(void)
|
|||||||
sub_80E8CB0(&x, &y, 0x220);
|
sub_80E8CB0(&x, &y, 0x220);
|
||||||
x += 7;
|
x += 7;
|
||||||
y += 7;
|
y += 7;
|
||||||
MapGridSetMetatileIdAt(x, y, 0x220 | 0xC00);
|
MapGridSetMetatileIdAt(x, y, 0x220 | MAP_IMPASSABLE_MASK);
|
||||||
CurrentMapDrawMetatileAt(x, y);
|
CurrentMapDrawMetatileAt(x, y);
|
||||||
pal_fill_black();
|
pal_fill_black();
|
||||||
CreateTask(sub_80E90C8, 0);
|
CreateTask(sub_80E90C8, 0);
|
||||||
@ -492,12 +492,12 @@ void sub_80E9238(u8 flagIn)
|
|||||||
if (curBaseId != 0)
|
if (curBaseId != 0)
|
||||||
{
|
{
|
||||||
sub_80E8CB0(&x, &y, 0x220);
|
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)
|
else if (flagIn == 1 && VarGet(VAR_0x4089) == 1)
|
||||||
{
|
{
|
||||||
sub_80E8CB0(&x, &y, 0x220);
|
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)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
src/tv.c
5
src/tv.c
@ -39,6 +39,7 @@
|
|||||||
#include "tv.h"
|
#include "tv.h"
|
||||||
#include "data2.h"
|
#include "data2.h"
|
||||||
#include "constants/layouts.h"
|
#include "constants/layouts.h"
|
||||||
|
#include "constants/metatile_behaviors.h"
|
||||||
|
|
||||||
// Static type declarations
|
// Static type declarations
|
||||||
|
|
||||||
@ -853,9 +854,9 @@ void SetTVMetatilesOnMap(int width, int height, u16 tileId)
|
|||||||
{
|
{
|
||||||
for (x = 0; x < width; x ++)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user