From 03a98c72bc435bf92e535de26f21ce0c06df6dd9 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 2 Sep 2022 19:29:35 -0400 Subject: [PATCH] Sync fieldmap --- include/fieldmap.h | 2 +- include/global.fieldmap.h | 10 +++++----- src/fieldmap.c | 13 +++++++------ src/item_use.c | 2 +- src/scrcmd.c | 8 ++++---- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/include/fieldmap.h b/include/fieldmap.h index 7caadfcaa..2f7eaba66 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -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 diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 974fa3382..2be44a5f3 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -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 { diff --git a/src/fieldmap.c b/src/fieldmap.c index 2b981dc6e..8dfa23bf3 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -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); } } } diff --git a/src/item_use.c b/src/item_use.c index e5c78d091..41e888496 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -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); } diff --git a/src/scrcmd.c b/src/scrcmd.c index 6ca02019d..3d67c69e5 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -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; }