Sync fieldmap

This commit is contained in:
GriffinR 2022-09-02 19:29:35 -04:00
parent 0516f94837
commit 03a98c72bc
5 changed files with 18 additions and 17 deletions

View File

@ -47,7 +47,7 @@ void CopySecondaryTilesetToVramUsingHeap(struct MapLayout const *mapLayout);
void CopyPrimaryTilesetToVram(const struct MapLayout *);
void CopySecondaryTilesetToVram(const struct MapLayout *);
struct MapHeader const *const GetMapHeaderFromConnection(struct MapConnection *connection);
struct MapConnection *GetConnectionAtCoords(s16 x, s16 y);
struct MapConnection *GetMapConnectionAtPos(s16 x, s16 y);
void MapGridSetMetatileImpassabilityAt(int x, int y, bool32 impassable);
// field_region_map.c

View File

@ -4,9 +4,9 @@
// Masks/shifts for blocks in the map grid
// Map grid blocks consist of a 10 bit metatile id, a 2 bit collision value, and a 4 bit elevation value
// This is the data stored in each data/layouts/*/map.bin file
#define MAPGRID_METATILE_ID_MASK 0x03FF // Bits 1-10
#define MAPGRID_COLLISION_MASK 0x0C00 // Bits 11-12
#define MAPGRID_ELEVATION_MASK 0xF000 // Bits 13-16
#define MAPGRID_METATILE_ID_MASK 0x03FF // Bits 0-9
#define MAPGRID_COLLISION_MASK 0x0C00 // Bits 10-11
#define MAPGRID_ELEVATION_MASK 0xF000 // Bits 12-15
#define MAPGRID_COLLISION_SHIFT 10
#define MAPGRID_ELEVATION_SHIFT 12
@ -16,8 +16,8 @@
// Masks/shifts for metatile attributes
// Metatile attributes consist of an 8 bit behavior value, 4 unused bits, and a 4 bit layer type value
// This is the data stored in each data/tilesets/*/*/metatile_attributes.bin file
#define METATILE_ATTR_BEHAVIOR_MASK 0x00FF // Bits 1-8
#define METATILE_ATTR_LAYER_MASK 0xF000 // Bits 13-16
#define METATILE_ATTR_BEHAVIOR_MASK 0x00FF // Bits 0-7
#define METATILE_ATTR_LAYER_MASK 0xF000 // Bits 12-15
#define METATILE_ATTR_LAYER_SHIFT 12
enum {

View File

@ -753,7 +753,7 @@ static int IsPosInConnectingMap(struct MapConnection *connection, int x, int y)
return FALSE;
}
struct MapConnection *GetConnectionAtCoords(s16 x, s16 y)
struct MapConnection *GetMapConnectionAtPos(s16 x, s16 y)
{
int count;
struct MapConnection *connection;
@ -860,12 +860,13 @@ static void CopyTilesetToVramUsingHeap(struct Tileset const *tileset, u16 numTil
}
}
static void FieldmapPaletteDummy(u16 offset, u16 size)
// Below two are dummied functions from FRLG, used to tint the overworld palettes for the Quest Log
static void ApplyGlobalTintToPaletteEntries(u16 offset, u16 size)
{
}
static void FieldmapUnkDummy(void)
static void ApplyGlobalTintToPaletteSlot(void)
{
}
@ -880,17 +881,17 @@ void LoadTilesetPalette(struct Tileset const *tileset, u16 destOffset, u16 size)
{
LoadPalette(&black, destOffset, 2);
LoadPalette(((u16 *)tileset->palettes) + 1, destOffset + 1, size - 2);
FieldmapPaletteDummy(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);
FieldmapPaletteDummy(destOffset, size >> 1);
ApplyGlobalTintToPaletteEntries(destOffset, size >> 1);
}
else
{
LoadCompressedPalette((u32 *)tileset->palettes, destOffset, size);
FieldmapPaletteDummy(destOffset, size >> 1);
ApplyGlobalTintToPaletteEntries(destOffset, size >> 1);
}
}
}

View File

@ -456,7 +456,7 @@ static void CheckForHiddenItemsInMapConnection(u8 taskId)
|| var2 > y
|| y >= height)
{
struct MapConnection *conn = GetConnectionAtCoords(x, y);
struct MapConnection *conn = GetMapConnectionAtPos(x, y);
if (conn && IsHiddenItemPresentInConnection(conn, x, y) == TRUE)
SetDistanceOfClosestHiddenItem(taskId, x - playerX, y - playerY);
}

View File

@ -2038,15 +2038,15 @@ bool8 ScrCmd_setmetatile(struct ScriptContext *ctx)
{
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
u16 tileId = VarGet(ScriptReadHalfword(ctx));
u16 isImpassable = 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 | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(x, y, metatileId | MAPGRID_COLLISION_MASK);
return FALSE;
}