Sync fieldmap
This commit is contained in:
@@ -4854,7 +4854,7 @@ u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir)
|
||||
u8 direction = dir;
|
||||
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
|
||||
return COLLISION_OUTSIDE_RANGE;
|
||||
else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction))
|
||||
else if (MapGridGetCollisionAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction))
|
||||
return COLLISION_IMPASSABLE;
|
||||
else if (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction))
|
||||
return COLLISION_IMPASSABLE;
|
||||
@@ -4871,7 +4871,7 @@ u8 GetCollisionFlagsAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 d
|
||||
|
||||
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
|
||||
flags |= 1;
|
||||
if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction) || (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)))
|
||||
if (MapGridGetCollisionAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction) || (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)))
|
||||
flags |= 2;
|
||||
if (IsZCoordMismatchAt(objectEvent->currentElevation, x, y))
|
||||
flags |= 4;
|
||||
@@ -8380,7 +8380,7 @@ bool8 IsZCoordMismatchAt(u8 z, s16 x, s16 y)
|
||||
if (z == 0)
|
||||
return FALSE;
|
||||
|
||||
mapZ = MapGridGetZCoordAt(x, y);
|
||||
mapZ = MapGridGetElevationAt(x, y);
|
||||
|
||||
if (mapZ == 0 || mapZ == 0xF)
|
||||
return FALSE;
|
||||
@@ -8433,8 +8433,8 @@ u8 ZCoordToPriority(u8 z)
|
||||
|
||||
void ObjectEventUpdateZCoord(struct ObjectEvent *objEvent)
|
||||
{
|
||||
u8 z = MapGridGetZCoordAt(objEvent->currentCoords.x, objEvent->currentCoords.y);
|
||||
u8 z2 = MapGridGetZCoordAt(objEvent->previousCoords.x, objEvent->previousCoords.y);
|
||||
u8 z = MapGridGetElevationAt(objEvent->currentCoords.x, objEvent->currentCoords.y);
|
||||
u8 z2 = MapGridGetElevationAt(objEvent->previousCoords.x, objEvent->previousCoords.y);
|
||||
|
||||
if (z == 0xF || z2 == 0xF)
|
||||
return;
|
||||
|
||||
+30
-30
@@ -211,13 +211,13 @@ void CurrentMapDrawMetatileAt(int x, int y)
|
||||
}
|
||||
}
|
||||
|
||||
void DrawDoorMetatileAt(int x, int y, const u16 *arr)
|
||||
void DrawDoorMetatileAt(int x, int y, const u16 *tiles)
|
||||
{
|
||||
int offset = MapPosToBgTilemapOffset(&sFieldCameraOffset, x, y);
|
||||
|
||||
if (offset >= 0)
|
||||
{
|
||||
DrawMetatile(1, arr, offset);
|
||||
DrawMetatile(1, tiles, offset);
|
||||
// sFieldCameraOffset.copyBGToVRAM = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -239,16 +239,16 @@ static void DrawMetatileAt(const struct MapLayout *mapLayout, u16 offset, int x,
|
||||
DrawMetatile(MapGridGetMetatileLayerTypeAt(x, y), metatiles + metatileId * 8, offset);
|
||||
}
|
||||
|
||||
static void DrawMetatile(s32 metatileLayerType, const u16 *metatiles, u16 offset)
|
||||
static void DrawMetatile(s32 metatileLayerType, const u16 *tiles, u16 offset)
|
||||
{
|
||||
switch (metatileLayerType)
|
||||
{
|
||||
case 2: // LAYER_TYPE_
|
||||
case METATILE_LAYER_TYPE_SPLIT:
|
||||
// Draw metatile's bottom layer to the bottom background layer.
|
||||
gBGTilemapBuffers3[offset] = metatiles[0];
|
||||
gBGTilemapBuffers3[offset + 1] = metatiles[1];
|
||||
gBGTilemapBuffers3[offset + 0x20] = metatiles[2];
|
||||
gBGTilemapBuffers3[offset + 0x21] = metatiles[3];
|
||||
gBGTilemapBuffers3[offset] = tiles[0];
|
||||
gBGTilemapBuffers3[offset + 1] = tiles[1];
|
||||
gBGTilemapBuffers3[offset + 0x20] = tiles[2];
|
||||
gBGTilemapBuffers3[offset + 0x21] = tiles[3];
|
||||
|
||||
// Draw transparent tiles to the middle background layer.
|
||||
gBGTilemapBuffers1[offset] = 0;
|
||||
@@ -257,23 +257,23 @@ static void DrawMetatile(s32 metatileLayerType, const u16 *metatiles, u16 offset
|
||||
gBGTilemapBuffers1[offset + 0x21] = 0;
|
||||
|
||||
// Draw metatile's top layer to the top background layer.
|
||||
gBGTilemapBuffers2[offset] = metatiles[4];
|
||||
gBGTilemapBuffers2[offset + 1] = metatiles[5];
|
||||
gBGTilemapBuffers2[offset + 0x20] = metatiles[6];
|
||||
gBGTilemapBuffers2[offset + 0x21] = metatiles[7];
|
||||
gBGTilemapBuffers2[offset] = tiles[4];
|
||||
gBGTilemapBuffers2[offset + 1] = tiles[5];
|
||||
gBGTilemapBuffers2[offset + 0x20] = tiles[6];
|
||||
gBGTilemapBuffers2[offset + 0x21] = tiles[7];
|
||||
break;
|
||||
case 1: // LAYER_TYPE_COVERED_BY_OBJECTS
|
||||
case METATILE_LAYER_TYPE_COVERED:
|
||||
// Draw metatile's bottom layer to the bottom background layer.
|
||||
gBGTilemapBuffers3[offset] = metatiles[0];
|
||||
gBGTilemapBuffers3[offset + 1] = metatiles[1];
|
||||
gBGTilemapBuffers3[offset + 0x20] = metatiles[2];
|
||||
gBGTilemapBuffers3[offset + 0x21] = metatiles[3];
|
||||
gBGTilemapBuffers3[offset] = tiles[0];
|
||||
gBGTilemapBuffers3[offset + 1] = tiles[1];
|
||||
gBGTilemapBuffers3[offset + 0x20] = tiles[2];
|
||||
gBGTilemapBuffers3[offset + 0x21] = tiles[3];
|
||||
|
||||
// Draw metatile's top layer to the middle background layer.
|
||||
gBGTilemapBuffers1[offset] = metatiles[4];
|
||||
gBGTilemapBuffers1[offset + 1] = metatiles[5];
|
||||
gBGTilemapBuffers1[offset + 0x20] = metatiles[6];
|
||||
gBGTilemapBuffers1[offset + 0x21] = metatiles[7];
|
||||
gBGTilemapBuffers1[offset] = tiles[4];
|
||||
gBGTilemapBuffers1[offset + 1] = tiles[5];
|
||||
gBGTilemapBuffers1[offset + 0x20] = tiles[6];
|
||||
gBGTilemapBuffers1[offset + 0x21] = tiles[7];
|
||||
|
||||
// Draw transparent tiles to the top background layer.
|
||||
gBGTilemapBuffers2[offset] = 0;
|
||||
@@ -281,7 +281,7 @@ static void DrawMetatile(s32 metatileLayerType, const u16 *metatiles, u16 offset
|
||||
gBGTilemapBuffers2[offset + 0x20] = 0;
|
||||
gBGTilemapBuffers2[offset + 0x21] = 0;
|
||||
break;
|
||||
case 0: // LAYER_TYPE_NORMAL
|
||||
case METATILE_LAYER_TYPE_NORMAL:
|
||||
// Draw garbage to the bottom background layer.
|
||||
gBGTilemapBuffers3[offset] = 0x3014;
|
||||
gBGTilemapBuffers3[offset + 1] = 0x3014;
|
||||
@@ -289,16 +289,16 @@ static void DrawMetatile(s32 metatileLayerType, const u16 *metatiles, u16 offset
|
||||
gBGTilemapBuffers3[offset + 0x21] = 0x3014;
|
||||
|
||||
// Draw metatile's bottom layer to the middle background layer.
|
||||
gBGTilemapBuffers1[offset] = metatiles[0];
|
||||
gBGTilemapBuffers1[offset + 1] = metatiles[1];
|
||||
gBGTilemapBuffers1[offset + 0x20] = metatiles[2];
|
||||
gBGTilemapBuffers1[offset + 0x21] = metatiles[3];
|
||||
gBGTilemapBuffers1[offset] = tiles[0];
|
||||
gBGTilemapBuffers1[offset + 1] = tiles[1];
|
||||
gBGTilemapBuffers1[offset + 0x20] = tiles[2];
|
||||
gBGTilemapBuffers1[offset + 0x21] = tiles[3];
|
||||
|
||||
// Draw metatile's top layer to the top background layer, which covers object event sprites.
|
||||
gBGTilemapBuffers2[offset] = metatiles[4];
|
||||
gBGTilemapBuffers2[offset + 1] = metatiles[5];
|
||||
gBGTilemapBuffers2[offset + 0x20] = metatiles[6];
|
||||
gBGTilemapBuffers2[offset + 0x21] = metatiles[7];
|
||||
gBGTilemapBuffers2[offset] = tiles[4];
|
||||
gBGTilemapBuffers2[offset + 1] = tiles[5];
|
||||
gBGTilemapBuffers2[offset + 0x20] = tiles[6];
|
||||
gBGTilemapBuffers2[offset + 0x21] = tiles[7];
|
||||
break;
|
||||
}
|
||||
ScheduleBgCopyTilemapToVram(1);
|
||||
|
||||
@@ -200,7 +200,7 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
|
||||
ResetFacingNpcOrSignPostVars();
|
||||
playerDirection = GetPlayerFacingDirection();
|
||||
GetPlayerPosition(&position);
|
||||
metatileAttributes = MapGridGetMetatileAttributeAt(position.x, position.y, 0xFF);
|
||||
metatileAttributes = MapGridGetMetatileAttributeAt(position.x, position.y, METATILE_ATTRIBUTES_ALL);
|
||||
metatileBehavior = MapGridGetMetatileBehaviorAt(position.x, position.y);
|
||||
|
||||
FieldClearPlayerInput(&gInputToStoreInQuestLogMaybe);
|
||||
@@ -354,7 +354,7 @@ static void GetInFrontOfPlayerPosition(struct MapPosition *position)
|
||||
|
||||
GetXYCoordsOneStepInFrontOfPlayer(&position->x, &position->y);
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
if (MapGridGetZCoordAt(x, y) != 0)
|
||||
if (MapGridGetElevationAt(x, y) != 0)
|
||||
position->height = PlayerGetZCoord();
|
||||
else
|
||||
position->height = 0;
|
||||
|
||||
+1
-3
@@ -2740,9 +2740,7 @@ static void LoadFieldMoveStreaksTilemapToVram(u16 screenbase)
|
||||
u16 *dest;
|
||||
dest = (u16 *)(VRAM + (10 * 32) + screenbase);
|
||||
for (i = 0; i < (10 * 32); i++, dest++)
|
||||
{
|
||||
*dest = sFieldMoveStreaksOutdoors_Tilemap[i] | METATILE_ELEVATION_MASK;
|
||||
}
|
||||
*dest = sFieldMoveStreaksOutdoors_Tilemap[i] | 0xF000;
|
||||
}
|
||||
|
||||
static void (*const sShowMonIndoorsEffectFuncs[])(struct Task *) = {
|
||||
|
||||
@@ -1041,7 +1041,7 @@ void SynchroniseSurfPosition(struct ObjectEvent *playerObject, struct Sprite *su
|
||||
for (i = DIR_SOUTH; i <= DIR_EAST; i++, x = surfBlobSprite->data[6], y = surfBlobSprite->data[7])
|
||||
{
|
||||
MoveCoords(i, &x, &y);
|
||||
if (MapGridGetZCoordAt(x, y) == 3)
|
||||
if (MapGridGetElevationAt(x, y) == 3)
|
||||
{
|
||||
surfBlobSprite->data[5]++;
|
||||
break;
|
||||
|
||||
@@ -597,7 +597,7 @@ static const u8 sQuestLogSurfDismountActionIds[] = {
|
||||
static bool8 CanStopSurfing(s16 x, s16 y, u8 direction)
|
||||
{
|
||||
if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
|
||||
&& MapGridGetZCoordAt(x, y) == 3
|
||||
&& MapGridGetElevationAt(x, y) == 3
|
||||
&& GetObjectEventIdByXYZ(x, y, 3) == OBJECT_EVENTS_COUNT)
|
||||
{
|
||||
QuestLogRecordPlayerAvatarGfxTransitionWithDuration(sQuestLogSurfDismountActionIds[direction], 16);
|
||||
|
||||
+8
-12
@@ -280,7 +280,7 @@ static void PcTurnOnUpdateMetatileId(bool16 flickerOff)
|
||||
else if (gSpecialVar_0x8004 == 2)
|
||||
metatileId = METATILE_GenericBuilding1_PlayersPCOn;
|
||||
}
|
||||
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + deltaX + 7, gSaveBlock1Ptr->pos.y + deltaY + 7, metatileId | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + deltaX + MAP_OFFSET, gSaveBlock1Ptr->pos.y + deltaY + MAP_OFFSET, metatileId | MAPGRID_COLLISION_MASK);
|
||||
}
|
||||
|
||||
void AnimatePcTurnOff()
|
||||
@@ -311,13 +311,13 @@ void AnimatePcTurnOff()
|
||||
metatileId = METATILE_GenericBuilding1_PlayersPCOff;
|
||||
else if (gSpecialVar_0x8004 == 2)
|
||||
metatileId = METATILE_GenericBuilding1_PlayersPCOff;
|
||||
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + deltaX + 7, gSaveBlock1Ptr->pos.y + deltaY + 7, metatileId | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + deltaX + MAP_OFFSET, gSaveBlock1Ptr->pos.y + deltaY + MAP_OFFSET, metatileId | MAPGRID_COLLISION_MASK);
|
||||
DrawWholeMapView();
|
||||
}
|
||||
|
||||
void SpawnCameraObject(void)
|
||||
{
|
||||
u8 objectEventId = SpawnSpecialObjectEventParameterized(OBJ_EVENT_GFX_YOUNGSTER, 8, OBJ_EVENT_ID_CAMERA, gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7, 3);
|
||||
u8 objectEventId = SpawnSpecialObjectEventParameterized(OBJ_EVENT_GFX_YOUNGSTER, 8, OBJ_EVENT_ID_CAMERA, gSaveBlock1Ptr->pos.x + MAP_OFFSET, gSaveBlock1Ptr->pos.y + MAP_OFFSET, 3);
|
||||
gObjectEvents[objectEventId].invisible = TRUE;
|
||||
CameraObjectSetFollowedObjectId(gObjectEvents[objectEventId].spriteId);
|
||||
}
|
||||
@@ -1139,9 +1139,7 @@ static void Task_AnimateElevatorWindowView(u8 taskId)
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
MapGridSetMetatileIdAt(j + 8, i + 7, sElevatorWindowMetatilesGoingUp[i][data[0] % 3] | METATILE_COLLISION_MASK);
|
||||
}
|
||||
MapGridSetMetatileIdAt(j + 1 + MAP_OFFSET, i + MAP_OFFSET, sElevatorWindowMetatilesGoingUp[i][data[0] % 3] | MAPGRID_COLLISION_MASK);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1149,9 +1147,7 @@ static void Task_AnimateElevatorWindowView(u8 taskId)
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
MapGridSetMetatileIdAt(j + 8, i + 7, sElevatorWindowMetatilesGoingDown[i][data[0] % 3] | METATILE_COLLISION_MASK);
|
||||
}
|
||||
MapGridSetMetatileIdAt(j + 1 + MAP_OFFSET, i + MAP_OFFSET, sElevatorWindowMetatilesGoingDown[i][data[0] % 3] | MAPGRID_COLLISION_MASK);
|
||||
}
|
||||
}
|
||||
DrawWholeMapView();
|
||||
@@ -2153,7 +2149,7 @@ void DoPokemonLeagueLightingEffect(void)
|
||||
LoadPalette(sEliteFourLightingPalettes[0], 0x70, 0x20);
|
||||
}
|
||||
data[1] = 0;
|
||||
Fieldmap_ApplyGlobalTintToPaletteSlot(7, 1);
|
||||
ApplyGlobalTintToPaletteSlot(7, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2180,7 +2176,7 @@ static void Task_RunPokemonLeagueLightingEffect(u8 taskId)
|
||||
data[0] = sEliteFourLightingTimers[data[1]];
|
||||
LoadPalette(sEliteFourLightingPalettes[data[1]], 0x70, 0x20);
|
||||
}
|
||||
Fieldmap_ApplyGlobalTintToPaletteSlot(7, 1);
|
||||
ApplyGlobalTintToPaletteSlot(7, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2197,7 +2193,7 @@ static void Task_CancelPokemonLeagueLightingEffect(u8 taskId)
|
||||
{
|
||||
LoadPalette(sEliteFourLightingPalettes[11], 0x70, 0x20);
|
||||
}
|
||||
Fieldmap_ApplyGlobalTintToPaletteSlot(7, 1);
|
||||
ApplyGlobalTintToPaletteSlot(7, 1);
|
||||
if (gPaletteFade.active)
|
||||
{
|
||||
BlendPalettes(0x00000080, 16, RGB_BLACK);
|
||||
|
||||
+100
-98
@@ -14,6 +14,15 @@ struct ConnectionFlags
|
||||
u8 east:1;
|
||||
};
|
||||
|
||||
struct BackupMapLayout VMap;
|
||||
EWRAM_DATA u16 gBackupMapData[VIRTUAL_MAP_SIZE] = {};
|
||||
EWRAM_DATA struct MapHeader gMapHeader = {};
|
||||
EWRAM_DATA struct Camera gCamera = {};
|
||||
static EWRAM_DATA struct ConnectionFlags gMapConnectionFlags = {};
|
||||
EWRAM_DATA u8 gGlobalFieldTintMode = QL_TINT_NONE;
|
||||
|
||||
static const struct ConnectionFlags sDummyConnectionFlags = {};
|
||||
|
||||
static void InitMapLayoutData(struct MapHeader *);
|
||||
static void InitBackupMapLayoutData(u16 *, u16, u16);
|
||||
static void InitBackupMapLayoutConnections(struct MapHeader *);
|
||||
@@ -27,46 +36,39 @@ static bool8 IsPosInIncomingConnectingMap(u8, s32, s32, struct MapConnection *);
|
||||
static bool8 IsCoordInIncomingConnectingMap(s32, s32, s32, s32);
|
||||
static u32 GetAttributeByMetatileIdAndMapLayout(const struct MapLayout *, u16, u8);
|
||||
|
||||
#define MapGridGetBorderTileAt(x, y) ({ \
|
||||
u16 block; \
|
||||
s32 xprime; \
|
||||
s32 yprime; \
|
||||
\
|
||||
const struct MapLayout *mapLayout = gMapHeader.mapLayout; \
|
||||
\
|
||||
xprime = x - 7; \
|
||||
xprime += 8 * mapLayout->borderWidth; \
|
||||
xprime %= mapLayout->borderWidth; \
|
||||
\
|
||||
yprime = y - 7; \
|
||||
yprime += 8 * mapLayout->borderHeight; \
|
||||
yprime %= mapLayout->borderHeight; \
|
||||
\
|
||||
block = mapLayout->border[xprime + yprime * mapLayout->borderWidth] | METATILE_COLLISION_MASK; \
|
||||
#define GetBorderBlockAt(x, y) ({ \
|
||||
u16 block; \
|
||||
s32 xprime; \
|
||||
s32 yprime; \
|
||||
\
|
||||
const struct MapLayout *mapLayout = gMapHeader.mapLayout; \
|
||||
\
|
||||
xprime = x - MAP_OFFSET; \
|
||||
xprime += 8 * mapLayout->borderWidth; \
|
||||
xprime %= mapLayout->borderWidth; \
|
||||
\
|
||||
yprime = y - MAP_OFFSET; \
|
||||
yprime += 8 * mapLayout->borderHeight; \
|
||||
yprime %= mapLayout->borderHeight; \
|
||||
\
|
||||
block = mapLayout->border[xprime + yprime * mapLayout->borderWidth] | MAPGRID_COLLISION_MASK; \
|
||||
})
|
||||
|
||||
#define AreCoordsWithinMapGridBounds(x, y) (x >= 0 && x < VMap.Xsize && y >= 0 && y < VMap.Ysize)
|
||||
|
||||
#define MapGridGetTileAt(x, y) (AreCoordsWithinMapGridBounds(x, y) ? VMap.map[x + VMap.Xsize * y] : MapGridGetBorderTileAt(x, y))
|
||||
|
||||
struct BackupMapLayout VMap;
|
||||
EWRAM_DATA u16 gBackupMapData[VIRTUAL_MAP_SIZE] = {};
|
||||
EWRAM_DATA struct MapHeader gMapHeader = {};
|
||||
EWRAM_DATA struct Camera gCamera = {};
|
||||
static EWRAM_DATA struct ConnectionFlags gMapConnectionFlags = {};
|
||||
EWRAM_DATA u8 gGlobalFieldTintMode = QL_TINT_NONE;
|
||||
|
||||
static const struct ConnectionFlags sDummyConnectionFlags = {};
|
||||
#define GetMapGridBlockAt(x, y) (AreCoordsWithinMapGridBounds(x, y) ? VMap.map[x + VMap.Xsize * y] : GetBorderBlockAt(x, y))
|
||||
|
||||
// Masks/shifts for metatile attributes
|
||||
// This is the format of the data stored in each data/tilesets/*/*/metatile_attributes.bin file
|
||||
static const u32 sMetatileAttrMasks[METATILE_ATTRIBUTE_COUNT] = {
|
||||
[METATILE_ATTRIBUTE_BEHAVIOR] = 0x000001ff,
|
||||
[METATILE_ATTRIBUTE_TERRAIN] = 0x00003e00,
|
||||
[METATILE_ATTRIBUTE_2] = 0x0003c000,
|
||||
[METATILE_ATTRIBUTE_3] = 0x00fc0000,
|
||||
[METATILE_ATTRIBUTE_ENCOUNTER_TYPE] = 0x07000000,
|
||||
[METATILE_ATTRIBUTE_5] = 0x18000000,
|
||||
[METATILE_ATTRIBUTE_LAYER_TYPE] = 0x60000000,
|
||||
[METATILE_ATTRIBUTE_7] = 0x80000000
|
||||
[METATILE_ATTRIBUTE_BEHAVIOR] = 0x000001ff, // Bits 0-8
|
||||
[METATILE_ATTRIBUTE_TERRAIN] = 0x00003e00, // Bits 9-13
|
||||
[METATILE_ATTRIBUTE_2] = 0x0003c000, // Bits 14-17
|
||||
[METATILE_ATTRIBUTE_3] = 0x00fc0000, // Bits 18-23
|
||||
[METATILE_ATTRIBUTE_ENCOUNTER_TYPE] = 0x07000000, // Bits 24-26
|
||||
[METATILE_ATTRIBUTE_5] = 0x18000000, // Bits 27-28
|
||||
[METATILE_ATTRIBUTE_LAYER_TYPE] = 0x60000000, // Bits 29-30
|
||||
[METATILE_ATTRIBUTE_7] = 0x80000000 // Bit 31
|
||||
};
|
||||
|
||||
static const u8 sMetatileAttrShifts[METATILE_ATTRIBUTE_COUNT] = {
|
||||
@@ -101,10 +103,10 @@ void InitMapFromSavedGame(void)
|
||||
static void InitMapLayoutData(struct MapHeader * mapHeader)
|
||||
{
|
||||
const struct MapLayout * mapLayout = mapHeader->mapLayout;
|
||||
CpuFastFill(METATILE_ID_UNDEFINED << 16 | METATILE_ID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData));
|
||||
CpuFastFill(MAPGRID_UNDEFINED << 16 | MAPGRID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData));
|
||||
VMap.map = gBackupMapData;
|
||||
VMap.Xsize = mapLayout->width + 15;
|
||||
VMap.Ysize = mapLayout->height + 14;
|
||||
VMap.Xsize = mapLayout->width + MAP_OFFSET_W;
|
||||
VMap.Ysize = mapLayout->height + MAP_OFFSET_H;
|
||||
AGB_ASSERT_EX(VMap.Xsize * VMap.Ysize <= VIRTUAL_MAP_SIZE, ABSPATH("fieldmap.c"), 158);
|
||||
InitBackupMapLayoutData(mapLayout->map, mapLayout->width, mapLayout->height);
|
||||
InitBackupMapLayoutConnections(mapHeader);
|
||||
@@ -114,12 +116,12 @@ static void InitBackupMapLayoutData(u16 *map, u16 width, u16 height)
|
||||
{
|
||||
s32 y;
|
||||
u16 *dest = VMap.map;
|
||||
dest += VMap.Xsize * 7 + 7;
|
||||
dest += VMap.Xsize * 7 + MAP_OFFSET;
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
CpuCopy16(map, dest, width * sizeof(u16));
|
||||
dest += width + 15;
|
||||
dest += width + MAP_OFFSET_W;
|
||||
map += width;
|
||||
}
|
||||
}
|
||||
@@ -197,8 +199,8 @@ static void FillSouthConnection(struct MapHeader const *mapHeader, struct MapHea
|
||||
if (connectedMapHeader)
|
||||
{
|
||||
cWidth = connectedMapHeader->mapLayout->width;
|
||||
x = offset + 7;
|
||||
y = mapHeader->mapLayout->height + 7;
|
||||
x = offset + MAP_OFFSET;
|
||||
y = mapHeader->mapLayout->height + MAP_OFFSET;
|
||||
if (x < 0)
|
||||
{
|
||||
x2 = -x;
|
||||
@@ -222,7 +224,7 @@ static void FillSouthConnection(struct MapHeader const *mapHeader, struct MapHea
|
||||
x, y,
|
||||
connectedMapHeader,
|
||||
x2, /*y2*/ 0,
|
||||
width, /*height*/ 7);
|
||||
width, /*height*/ MAP_OFFSET);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,8 +239,8 @@ static void FillNorthConnection(struct MapHeader const *mapHeader, struct MapHea
|
||||
{
|
||||
cWidth = connectedMapHeader->mapLayout->width;
|
||||
cHeight = connectedMapHeader->mapLayout->height;
|
||||
x = offset + 7;
|
||||
y2 = cHeight - 7;
|
||||
x = offset + MAP_OFFSET;
|
||||
y2 = cHeight - MAP_OFFSET;
|
||||
if (x < 0)
|
||||
{
|
||||
x2 = -x;
|
||||
@@ -262,7 +264,7 @@ static void FillNorthConnection(struct MapHeader const *mapHeader, struct MapHea
|
||||
x, /*y*/ 0,
|
||||
connectedMapHeader,
|
||||
x2, y2,
|
||||
width, /*height*/ 7);
|
||||
width, /*height*/ MAP_OFFSET);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -277,8 +279,8 @@ static void FillWestConnection(struct MapHeader const *mapHeader, struct MapHead
|
||||
{
|
||||
cWidth = connectedMapHeader->mapLayout->width;
|
||||
cHeight = connectedMapHeader->mapLayout->height;
|
||||
y = offset + 7;
|
||||
x2 = cWidth - 7;
|
||||
y = offset + MAP_OFFSET;
|
||||
x2 = cWidth - MAP_OFFSET;
|
||||
if (y < 0)
|
||||
{
|
||||
y2 = -y;
|
||||
@@ -301,7 +303,7 @@ static void FillWestConnection(struct MapHeader const *mapHeader, struct MapHead
|
||||
/*x*/ 0, y,
|
||||
connectedMapHeader,
|
||||
x2, y2,
|
||||
/*width*/ 7, height);
|
||||
/*width*/ MAP_OFFSET, height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,8 +316,8 @@ static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHead
|
||||
if (connectedMapHeader)
|
||||
{
|
||||
cHeight = connectedMapHeader->mapLayout->height;
|
||||
x = mapHeader->mapLayout->width + 7;
|
||||
y = offset + 7;
|
||||
x = mapHeader->mapLayout->width + MAP_OFFSET;
|
||||
y = offset + MAP_OFFSET;
|
||||
if (y < 0)
|
||||
{
|
||||
y2 = -y;
|
||||
@@ -338,43 +340,43 @@ static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHead
|
||||
x, y,
|
||||
connectedMapHeader,
|
||||
/*x2*/ 0, y2,
|
||||
/*width*/ 8, height);
|
||||
/*width*/ MAP_OFFSET + 1, height);
|
||||
}
|
||||
}
|
||||
|
||||
u8 MapGridGetZCoordAt(s32 x, s32 y)
|
||||
u8 MapGridGetElevationAt(s32 x, s32 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;
|
||||
}
|
||||
|
||||
u8 MapGridIsImpassableAt(s32 x, s32 y)
|
||||
u8 MapGridGetCollisionAt(s32 x, s32 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(s32 x, s32 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 ExtractMetatileAttribute(u32 attributes, u8 attributeType)
|
||||
{
|
||||
if (attributeType >= METATILE_ATTRIBUTE_COUNT)
|
||||
if (attributeType >= METATILE_ATTRIBUTE_COUNT) // Check for METATILE_ATTRIBUTES_ALL
|
||||
return attributes;
|
||||
|
||||
return (attributes & sMetatileAttrMasks[attributeType]) >> sMetatileAttrShifts[attributeType];
|
||||
@@ -402,7 +404,7 @@ void MapGridSetMetatileIdAt(s32 x, s32 y, u16 metatile)
|
||||
if (AreCoordsWithinMapGridBounds(x, y))
|
||||
{
|
||||
i = x + y * VMap.Xsize;
|
||||
VMap.map[i] = (VMap.map[i] & METATILE_ELEVATION_MASK) | (metatile & ~METATILE_ELEVATION_MASK);
|
||||
VMap.map[i] = (VMap.map[i] & MAPGRID_ELEVATION_MASK) | (metatile & ~MAPGRID_ELEVATION_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,9 +423,9 @@ void MapGridSetMetatileImpassabilityAt(s32 x, s32 y, bool32 impassable)
|
||||
if (AreCoordsWithinMapGridBounds(x, y))
|
||||
{
|
||||
if (impassable)
|
||||
VMap.map[x + VMap.Xsize * y] |= METATILE_COLLISION_MASK;
|
||||
VMap.map[x + VMap.Xsize * y] |= MAPGRID_COLLISION_MASK;
|
||||
else
|
||||
VMap.map[x + VMap.Xsize * y] &= ~METATILE_COLLISION_MASK;
|
||||
VMap.map[x + VMap.Xsize * y] &= ~MAPGRID_COLLISION_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,9 +459,9 @@ void SaveMapView(void)
|
||||
width = VMap.Xsize;
|
||||
x = gSaveBlock1Ptr->pos.x;
|
||||
y = gSaveBlock1Ptr->pos.y;
|
||||
for (i = y; i < y + 14; i++)
|
||||
for (i = y; i < y + MAP_OFFSET_H; i++)
|
||||
{
|
||||
for (j = x; j < x + 15; j++)
|
||||
for (j = x; j < x + MAP_OFFSET_W; j++)
|
||||
*mapView++ = gBackupMapData[width * i + j];
|
||||
}
|
||||
}
|
||||
@@ -501,9 +503,9 @@ static void LoadSavedMapView(void)
|
||||
width = VMap.Xsize;
|
||||
x = gSaveBlock1Ptr->pos.x;
|
||||
y = gSaveBlock1Ptr->pos.y;
|
||||
for (i = y; i < y + 14; i++)
|
||||
for (i = y; i < y + MAP_OFFSET_H; i++)
|
||||
{
|
||||
for (j = x; j < x + 15; j++)
|
||||
for (j = x; j < x + MAP_OFFSET_W; j++)
|
||||
{
|
||||
gBackupMapData[j + width * i] = *mapView;
|
||||
mapView++;
|
||||
@@ -536,19 +538,19 @@ static void MoveMapViewToBackup(u8 direction)
|
||||
{
|
||||
case CONNECTION_NORTH:
|
||||
y0 += 1;
|
||||
y2 = 13;
|
||||
y2 = MAP_OFFSET_H - 1;
|
||||
break;
|
||||
case CONNECTION_SOUTH:
|
||||
r8 = 1;
|
||||
y2 = 13;
|
||||
y2 = MAP_OFFSET_H - 1;
|
||||
break;
|
||||
case CONNECTION_WEST:
|
||||
x0 += 1;
|
||||
x2 = 14;
|
||||
x2 = MAP_OFFSET_W - 1;
|
||||
break;
|
||||
case CONNECTION_EAST:
|
||||
r9 = 1;
|
||||
x2 = 14;
|
||||
x2 = MAP_OFFSET_W - 1;
|
||||
break;
|
||||
}
|
||||
for (y = 0; y < y2; y++)
|
||||
@@ -558,7 +560,7 @@ static void MoveMapViewToBackup(u8 direction)
|
||||
for (x = 0; x < x2; x++)
|
||||
{
|
||||
desti = width * (y + y0);
|
||||
srci = (y + r8) * 15 + r9;
|
||||
srci = (y + r8) * MAP_OFFSET_W + r9;
|
||||
src = &mapView[srci + i];
|
||||
dest = &gBackupMapData[x0 + desti + j];
|
||||
*dest = *src;
|
||||
@@ -571,10 +573,10 @@ static void MoveMapViewToBackup(u8 direction)
|
||||
|
||||
s32 GetMapBorderIdAt(s32 x, s32 y)
|
||||
{
|
||||
if (MapGridGetTileAt(x, y) == METATILE_ID_UNDEFINED)
|
||||
if (GetMapGridBlockAt(x, y) == MAPGRID_UNDEFINED)
|
||||
return CONNECTION_INVALID;
|
||||
|
||||
if (x >= VMap.Xsize - 8)
|
||||
if (x >= VMap.Xsize - (MAP_OFFSET + 1))
|
||||
{
|
||||
if (!gMapConnectionFlags.east)
|
||||
return CONNECTION_INVALID;
|
||||
@@ -582,7 +584,7 @@ s32 GetMapBorderIdAt(s32 x, s32 y)
|
||||
return CONNECTION_EAST;
|
||||
}
|
||||
|
||||
if (x < 7)
|
||||
if (x < MAP_OFFSET)
|
||||
{
|
||||
if (!gMapConnectionFlags.west)
|
||||
return CONNECTION_INVALID;
|
||||
@@ -590,7 +592,7 @@ s32 GetMapBorderIdAt(s32 x, s32 y)
|
||||
return CONNECTION_WEST;
|
||||
}
|
||||
|
||||
if (y >= VMap.Ysize - 7)
|
||||
if (y >= VMap.Ysize - MAP_OFFSET)
|
||||
{
|
||||
if (!gMapConnectionFlags.south)
|
||||
return CONNECTION_INVALID;
|
||||
@@ -598,7 +600,7 @@ s32 GetMapBorderIdAt(s32 x, s32 y)
|
||||
return CONNECTION_SOUTH;
|
||||
}
|
||||
|
||||
if (y < 7)
|
||||
if (y < MAP_OFFSET)
|
||||
{
|
||||
if (!gMapConnectionFlags.north)
|
||||
return CONNECTION_INVALID;
|
||||
@@ -611,14 +613,14 @@ s32 GetMapBorderIdAt(s32 x, s32 y)
|
||||
|
||||
static s32 GetPostCameraMoveMapBorderId(s32 x, s32 y)
|
||||
{
|
||||
return GetMapBorderIdAt(gSaveBlock1Ptr->pos.x + 7 + x, gSaveBlock1Ptr->pos.y + 7 + y);
|
||||
return GetMapBorderIdAt(gSaveBlock1Ptr->pos.x + MAP_OFFSET + x, gSaveBlock1Ptr->pos.y + MAP_OFFSET + y);
|
||||
}
|
||||
|
||||
bool32 CanCameraMoveInDirection(s32 direction)
|
||||
{
|
||||
s32 x, y;
|
||||
x = gSaveBlock1Ptr->pos.x + 7 + gDirectionToVectors[direction].x;
|
||||
y = gSaveBlock1Ptr->pos.y + 7 + gDirectionToVectors[direction].y;
|
||||
x = gSaveBlock1Ptr->pos.x + MAP_OFFSET + gDirectionToVectors[direction].x;
|
||||
y = gSaveBlock1Ptr->pos.y + MAP_OFFSET + gDirectionToVectors[direction].y;
|
||||
|
||||
if (GetMapBorderIdAt(x, y) == CONNECTION_INVALID)
|
||||
return FALSE;
|
||||
@@ -774,15 +776,15 @@ struct MapConnection *GetMapConnectionAtPos(s16 x, s16 y)
|
||||
{
|
||||
direction = connection->direction;
|
||||
if ((direction == CONNECTION_DIVE || direction == CONNECTION_EMERGE)
|
||||
|| (direction == CONNECTION_NORTH && y > 6)
|
||||
|| (direction == CONNECTION_SOUTH && y < gMapHeader.mapLayout->height + 7)
|
||||
|| (direction == CONNECTION_WEST && x > 6)
|
||||
|| (direction == CONNECTION_EAST && x < gMapHeader.mapLayout->width + 7))
|
||||
|| (direction == CONNECTION_NORTH && y > MAP_OFFSET - 1)
|
||||
|| (direction == CONNECTION_SOUTH && y < gMapHeader.mapLayout->height + MAP_OFFSET)
|
||||
|| (direction == CONNECTION_WEST && x > MAP_OFFSET - 1)
|
||||
|| (direction == CONNECTION_EAST && x < gMapHeader.mapLayout->width + MAP_OFFSET))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IsPosInConnectingMap(connection, x - 7, y - 7) == TRUE)
|
||||
if (IsPosInConnectingMap(connection, x - MAP_OFFSET, y - MAP_OFFSET) == TRUE)
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
@@ -791,14 +793,14 @@ struct MapConnection *GetMapConnectionAtPos(s16 x, s16 y)
|
||||
|
||||
void SetCameraFocusCoords(u16 x, u16 y)
|
||||
{
|
||||
gSaveBlock1Ptr->pos.x = x - 7;
|
||||
gSaveBlock1Ptr->pos.y = y - 7;
|
||||
gSaveBlock1Ptr->pos.x = x - MAP_OFFSET;
|
||||
gSaveBlock1Ptr->pos.y = y - MAP_OFFSET;
|
||||
}
|
||||
|
||||
void GetCameraFocusCoords(u16 *x, u16 *y)
|
||||
{
|
||||
*x = gSaveBlock1Ptr->pos.x + 7;
|
||||
*y = gSaveBlock1Ptr->pos.y + 7;
|
||||
*x = gSaveBlock1Ptr->pos.x + MAP_OFFSET;
|
||||
*y = gSaveBlock1Ptr->pos.y + MAP_OFFSET;
|
||||
}
|
||||
|
||||
// Unused
|
||||
@@ -836,7 +838,7 @@ static void CopyTilesetToVramUsingHeap(struct Tileset const *tileset, u16 numTil
|
||||
}
|
||||
}
|
||||
|
||||
static void Fieldmap_ApplyGlobalTintToPaletteEntries(u16 offset, u16 size)
|
||||
static void ApplyGlobalTintToPaletteEntries(u16 offset, u16 size)
|
||||
{
|
||||
switch (gGlobalFieldTintMode)
|
||||
{
|
||||
@@ -858,7 +860,7 @@ static void Fieldmap_ApplyGlobalTintToPaletteEntries(u16 offset, u16 size)
|
||||
CpuCopy16(gPlttBufferUnfaded + offset, gPlttBufferFaded + offset, size * sizeof(u16));
|
||||
}
|
||||
|
||||
void Fieldmap_ApplyGlobalTintToPaletteSlot(u8 slot, u8 count)
|
||||
void ApplyGlobalTintToPaletteSlot(u8 slot, u8 count)
|
||||
{
|
||||
switch (gGlobalFieldTintMode)
|
||||
{
|
||||
@@ -890,17 +892,17 @@ static void LoadTilesetPalette(struct Tileset const *tileset, u16 destOffset, u1
|
||||
{
|
||||
LoadPalette(&black, destOffset, 2);
|
||||
LoadPalette(((u16 *)tileset->palettes) + 1, destOffset + 1, size - 2);
|
||||
Fieldmap_ApplyGlobalTintToPaletteEntries(destOffset + 1, (size - 2) >> 1);
|
||||
ApplyGlobalTintToPaletteEntries(destOffset + 1, (size - 2) >> 1);
|
||||
}
|
||||
else if (tileset->isSecondary == TRUE)
|
||||
{
|
||||
LoadPalette(((u16 *)tileset->palettes) + (NUM_PALS_IN_PRIMARY * 16), destOffset, size);
|
||||
Fieldmap_ApplyGlobalTintToPaletteEntries(destOffset, size >> 1);
|
||||
ApplyGlobalTintToPaletteEntries(destOffset, size >> 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadCompressedPalette((u32 *)tileset->palettes, destOffset, size);
|
||||
Fieldmap_ApplyGlobalTintToPaletteEntries(destOffset, size >> 1);
|
||||
ApplyGlobalTintToPaletteEntries(destOffset, size >> 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -145,7 +145,7 @@ bool8 SetUpFieldMove_Cut(void)
|
||||
for (j = 0; j < CUT_SIDE; j++)
|
||||
{
|
||||
x = gPlayerFacingPosition.x - 1 + j;
|
||||
if (MapGridGetZCoordAt(x, y) == gPlayerFacingPosition.height)
|
||||
if (MapGridGetElevationAt(x, y) == gPlayerFacingPosition.height)
|
||||
{
|
||||
if (MetatileAtCoordsIsGrassTile(x, y) == TRUE)
|
||||
{
|
||||
@@ -214,7 +214,7 @@ bool8 FldEff_CutGrass(void)
|
||||
for (j = 0; j < CUT_SIDE; j++)
|
||||
{
|
||||
x = gPlayerFacingPosition.x - 1 + j;
|
||||
if (MapGridGetZCoordAt(x, y) == gPlayerFacingPosition.height)
|
||||
if (MapGridGetElevationAt(x, y) == gPlayerFacingPosition.height)
|
||||
{
|
||||
if (MetatileAtCoordsIsGrassTile(x, y) == TRUE)
|
||||
{
|
||||
|
||||
+1
-1
@@ -312,7 +312,7 @@ static bool8 ItemUseCheckFunc_Rod(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MetatileBehavior_IsSurfable(behavior) && !MapGridIsImpassableAt(x, y))
|
||||
if (MetatileBehavior_IsSurfable(behavior) && MapGridGetCollisionAt(x, y) == 0)
|
||||
return TRUE;
|
||||
if (MetatileBehavior_IsBridge(behavior) == TRUE)
|
||||
return TRUE;
|
||||
|
||||
+1
-1
@@ -3499,7 +3499,7 @@ static bool8 LinkPlayerDetectCollision(u8 selfObjEventId, u8 a2, s16 x, s16 y)
|
||||
}
|
||||
}
|
||||
}
|
||||
return MapGridIsImpassableAt(x, y);
|
||||
return MapGridGetCollisionAt(x, y);
|
||||
}
|
||||
|
||||
static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion)
|
||||
|
||||
+3
-3
@@ -2091,15 +2091,15 @@ bool8 ScrCmd_setmetatile(struct ScriptContext * ctx)
|
||||
{
|
||||
u16 x = VarGet(ScriptReadHalfword(ctx));
|
||||
u16 y = VarGet(ScriptReadHalfword(ctx));
|
||||
u16 tileId = VarGet(ScriptReadHalfword(ctx));
|
||||
u16 metatileId = VarGet(ScriptReadHalfword(ctx));
|
||||
bool16 isImpassable = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
x += MAP_OFFSET;
|
||||
y += MAP_OFFSET;
|
||||
if (!isImpassable)
|
||||
MapGridSetMetatileIdAt(x, y, tileId);
|
||||
MapGridSetMetatileIdAt(x, y, metatileId);
|
||||
else
|
||||
MapGridSetMetatileIdAt(x, y, tileId | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(x, y, metatileId | MAPGRID_COLLISION_MASK);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
+3
-7
@@ -751,13 +751,9 @@ static void BuyMenuDrawMapBg(void)
|
||||
metatileLayerType = MapGridGetMetatileLayerTypeAt(x + i, y + j);
|
||||
|
||||
if (metatile < NUM_METATILES_IN_PRIMARY)
|
||||
{
|
||||
BuyMenuDrawMapMetatile(i, j, (u16 *)mapLayout->primaryTileset->metatiles + metatile * 8, metatileLayerType);
|
||||
}
|
||||
else
|
||||
{
|
||||
BuyMenuDrawMapMetatile(i, j, (u16 *)mapLayout->secondaryTileset->metatiles + ((metatile - NUM_METATILES_IN_PRIMARY) * 8), metatileLayerType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -769,15 +765,15 @@ static void BuyMenuDrawMapMetatile(s16 x, s16 y, const u16 *src, u8 metatileLaye
|
||||
|
||||
switch (metatileLayerType)
|
||||
{
|
||||
case 0:
|
||||
case METATILE_LAYER_TYPE_NORMAL:
|
||||
BuyMenuDrawMapMetatileLayer(*gShopTilemapBuffer4, offset1, offset2, src);
|
||||
BuyMenuDrawMapMetatileLayer(*gShopTilemapBuffer2, offset1, offset2, src + 4);
|
||||
break;
|
||||
case 1:
|
||||
case METATILE_LAYER_TYPE_COVERED:
|
||||
BuyMenuDrawMapMetatileLayer(*gShopTilemapBuffer3, offset1, offset2, src);
|
||||
BuyMenuDrawMapMetatileLayer(*gShopTilemapBuffer4, offset1, offset2, src + 4);
|
||||
break;
|
||||
case 2:
|
||||
case METATILE_LAYER_TYPE_SPLIT:
|
||||
BuyMenuDrawMapMetatileLayer(*gShopTilemapBuffer3, offset1, offset2, src);
|
||||
BuyMenuDrawMapMetatileLayer(*gShopTilemapBuffer2, offset1, offset2, src + 4);
|
||||
break;
|
||||
|
||||
+12
-12
@@ -137,13 +137,13 @@ static void Task_DrawEscalator(u8 taskId)
|
||||
SetEscalatorMetatile(taskId, sEscalatorMetatiles_BottomRail, 0);
|
||||
break;
|
||||
case 2:
|
||||
SetEscalatorMetatile(taskId, sEscalatorMetatiles_BottomNext, METATILE_COLLISION_MASK);
|
||||
SetEscalatorMetatile(taskId, sEscalatorMetatiles_BottomNext, MAPGRID_COLLISION_MASK);
|
||||
break;
|
||||
case 3:
|
||||
SetEscalatorMetatile(taskId, sEscalatorMetatiles_Bottom, 0);
|
||||
break;
|
||||
case 4:
|
||||
SetEscalatorMetatile(taskId, sEscalatorMetatiles_TopNext, METATILE_COLLISION_MASK);
|
||||
SetEscalatorMetatile(taskId, sEscalatorMetatiles_TopNext, MAPGRID_COLLISION_MASK);
|
||||
break;
|
||||
case 5:
|
||||
SetEscalatorMetatile(taskId, sEscalatorMetatiles_Top, 0);
|
||||
@@ -254,13 +254,13 @@ static void Task_DrawTeleporterHousing(u8 taskId)
|
||||
// Alternate the teleporter light / brightness of the teleporter door
|
||||
if ((tState & 1) == 0)
|
||||
{
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_Light_Yellow | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 2, METATILE_SeaCottage_Teleporter_Door_HalfGlowing | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_Light_Yellow | MAPGRID_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 2, METATILE_SeaCottage_Teleporter_Door_HalfGlowing | MAPGRID_COLLISION_MASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_Light_Red | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 2, METATILE_SeaCottage_Teleporter_Door_FullGlowing | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_Light_Red | MAPGRID_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 2, METATILE_SeaCottage_Teleporter_Door_FullGlowing | MAPGRID_COLLISION_MASK);
|
||||
}
|
||||
CurrentMapDrawMetatileAt(tX, tY);
|
||||
CurrentMapDrawMetatileAt(tX, tY + 2);
|
||||
@@ -275,8 +275,8 @@ static void Task_DrawTeleporterHousing(u8 taskId)
|
||||
if (tState != 13)
|
||||
return;
|
||||
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_Light_Green | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 2, METATILE_SeaCottage_Teleporter_Door | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_Light_Green | MAPGRID_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 2, METATILE_SeaCottage_Teleporter_Door | MAPGRID_COLLISION_MASK);
|
||||
CurrentMapDrawMetatileAt(tX, tY);
|
||||
CurrentMapDrawMetatileAt(tX, tY + 2);
|
||||
DestroyTask(taskId);
|
||||
@@ -305,8 +305,8 @@ static void Task_DrawTeleporterCable(u8 taskId)
|
||||
if (tState != 0)
|
||||
{
|
||||
// Set default cable tiles to clear the ball
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_Cable_Top | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 1, METATILE_SeaCottage_Teleporter_Cable_Bottom | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_Cable_Top | MAPGRID_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 1, METATILE_SeaCottage_Teleporter_Cable_Bottom | MAPGRID_COLLISION_MASK);
|
||||
CurrentMapDrawMetatileAt(tX, tY);
|
||||
CurrentMapDrawMetatileAt(tX, tY + 1);
|
||||
|
||||
@@ -321,8 +321,8 @@ static void Task_DrawTeleporterCable(u8 taskId)
|
||||
}
|
||||
|
||||
// Draw the cable ball
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_CableBall_Top | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 1, METATILE_SeaCottage_Teleporter_CableBall_Bottom | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_CableBall_Top | MAPGRID_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 1, METATILE_SeaCottage_Teleporter_CableBall_Bottom | MAPGRID_COLLISION_MASK);
|
||||
CurrentMapDrawMetatileAt(tX, tY);
|
||||
CurrentMapDrawMetatileAt(tX, tY + 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user