diff options
author | ExpoSeed <43502820+ExpoSeed@users.noreply.github.com> | 2021-06-13 16:32:00 -0500 |
---|---|---|
committer | ExpoSeed <43502820+ExpoSeed@users.noreply.github.com> | 2021-06-13 17:02:06 -0500 |
commit | b6b0062bd60eb57d66b6c79fc48bdbb55d8a5bf5 (patch) | |
tree | d88bfad489969bce94fe4db73a8fc1776f606150 | |
parent | f85fb3af8923b7dce601591dede2d3bee0729d1e (diff) |
Change map header flags to use a bitfield
-rw-r--r-- | include/global.fieldmap.h | 16 | ||||
-rw-r--r-- | src/bike.c | 2 | ||||
-rwxr-xr-x | src/item_use.c | 2 | ||||
-rw-r--r-- | src/overworld.c | 6 | ||||
-rw-r--r-- | src/region_map.c | 2 |
5 files changed, 12 insertions, 16 deletions
diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index a3d99ee21..6bafa9747 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -142,19 +142,15 @@ struct MapHeader /* 0x16 */ u8 weather; /* 0x17 */ u8 mapType; /* 0x18 */ u8 filler_18[2]; - /* 0x1A */ u8 flags; + // fields correspond to the arguments in the map_header_flags macro + /* 0x1A */ bool8 allowCycling:1; + bool8 allowEscaping:1; // Escape Rope and Dig + bool8 allowRunning:1; + bool8 showMapName:5; // the last 4 bits are unused + // but the 5 bit sized bitfield is required to match /* 0x1B */ u8 battleType; }; -// Flags for gMapHeader.flags, as defined in the map_header_flags macro -#define MAP_ALLOW_CYCLING (1 << 0) -#define MAP_ALLOW_ESCAPING (1 << 1) // Escape Rope and Dig -#define MAP_ALLOW_RUNNING (1 << 2) -#define MAP_SHOW_MAP_NAME (1 << 3) -#define UNUSED_MAP_FLAGS (1 << 4 | 1 << 5 | 1 << 6 | 1 << 7) - -#define SHOW_MAP_NAME_ENABLED ((gMapHeader.flags & (MAP_SHOW_MAP_NAME | UNUSED_MAP_FLAGS)) == MAP_SHOW_MAP_NAME) - struct ObjectEvent { diff --git a/src/bike.c b/src/bike.c index 62ce3cd44..e97a5e04e 100644 --- a/src/bike.c +++ b/src/bike.c @@ -1053,7 +1053,7 @@ void Bike_HandleBumpySlopeJump(void) bool32 IsRunningDisallowed(u8 metatile) { - if (!(gMapHeader.flags & MAP_ALLOW_RUNNING) || IsRunningDisallowedByMetatile(metatile) == TRUE) + if (!gMapHeader.allowRunning || IsRunningDisallowedByMetatile(metatile) == TRUE) return TRUE; else return FALSE; diff --git a/src/item_use.c b/src/item_use.c index 19f50549e..c9087e929 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -910,7 +910,7 @@ static void ItemUseOnFieldCB_EscapeRope(u8 taskId) bool8 CanUseDigOrEscapeRopeOnCurMap(void) { - if (gMapHeader.flags & MAP_ALLOW_ESCAPING) + if (gMapHeader.allowEscaping) return TRUE; else return FALSE; diff --git a/src/overworld.c b/src/overworld.c index 600333a47..979ebb74c 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -962,7 +962,7 @@ static u16 GetCenterScreenMetatileBehavior(void) bool32 Overworld_IsBikingAllowed(void) { - if (!(gMapHeader.flags & MAP_ALLOW_CYCLING)) + if (!gMapHeader.allowCycling) return FALSE; else return TRUE; @@ -1687,7 +1687,7 @@ void CB2_ReturnToFieldFadeFromBlack(void) static void FieldCB_FadeTryShowMapPopup(void) { - if (SHOW_MAP_NAME_ENABLED && SecretBaseMapPopupEnabled() == TRUE) + if (gMapHeader.showMapName == TRUE && SecretBaseMapPopupEnabled() == TRUE) ShowMapNamePopup(); FieldCB_WarpExitFadeFromBlack(); } @@ -1933,7 +1933,7 @@ static bool32 LoadMapInStepsLocal(u8 *state, bool32 a2) (*state)++; break; case 11: - if (SHOW_MAP_NAME_ENABLED && SecretBaseMapPopupEnabled() == TRUE) + if (gMapHeader.showMapName == TRUE && SecretBaseMapPopupEnabled() == TRUE) ShowMapNamePopup(); (*state)++; break; diff --git a/src/region_map.c b/src/region_map.c index bec51ebf0..27e035199 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -1007,7 +1007,7 @@ static void InitMapBasedOnPlayerLocation(void) break; case MAP_TYPE_UNDERGROUND: case MAP_TYPE_UNKNOWN: - if (gMapHeader.flags & MAP_ALLOW_ESCAPING) + if (gMapHeader.allowEscaping) { mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->escapeWarp.mapGroup, gSaveBlock1Ptr->escapeWarp.mapNum); gRegionMap->mapSecId = mapHeader->regionMapSectionId; |