Sync fieldmap

This commit is contained in:
GriffinR 2023-05-09 14:06:40 -04:00
parent af019d660f
commit 28b53dc44b
31 changed files with 516 additions and 596 deletions

View File

@ -242,4 +242,6 @@
#define MB_UNUSED_EE 0xEE #define MB_UNUSED_EE 0xEE
#define MB_UNUSED_EF 0xEF #define MB_UNUSED_EF 0xEF
#define MB_INVALID 0xFF
#endif // GUARD_METATILE_BEHAVIORS #endif // GUARD_METATILE_BEHAVIORS

View File

@ -378,7 +378,7 @@ u8 AddCameraObject(u8);
void CameraObjectReset1(void); void CameraObjectReset1(void);
const u8 *GetObjectEventScriptPointerByObjectEventId(u8); const u8 *GetObjectEventScriptPointerByObjectEventId(u8);
u8 ObjectEventGetBerryTreeId(u8); u8 ObjectEventGetBerryTreeId(u8);
struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8); const struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8);
void OverrideTemplateCoordsForObjectEvent(struct ObjectEvent *pObject); void OverrideTemplateCoordsForObjectEvent(struct ObjectEvent *pObject);
void OverrideMovementTypeForObjectEvent(struct ObjectEvent *, u8); void OverrideMovementTypeForObjectEvent(struct ObjectEvent *, u8);
void TryOverrideTemplateCoordsForObjectEvent(u8, u8, u8); void TryOverrideTemplateCoordsForObjectEvent(u8, u8, u8);

View File

@ -29,7 +29,7 @@ int ProcessPlayerFieldInput(struct FieldInput *pStruct);
const u8 *GetInteractedLinkPlayerScript(struct MapPosition *, u8, u8); const u8 *GetInteractedLinkPlayerScript(struct MapPosition *, u8, u8);
void ClearPoisonStepCounter(void); void ClearPoisonStepCounter(void);
void RestartWildEncounterImmunitySteps(void); void RestartWildEncounterImmunitySteps(void);
u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *); const u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *);
const u8 *GetObjectEventScriptPointerPlayerFacing(void); const u8 *GetObjectEventScriptPointerPlayerFacing(void);
u8 TrySetDiveWarp(void); u8 TrySetDiveWarp(void);
bool8 dive_warp(struct MapPosition*, u16); bool8 dive_warp(struct MapPosition*, u16);

View File

@ -2,7 +2,7 @@
#define GUARD_FIELDMAP2_H #define GUARD_FIELDMAP2_H
#include "event_object_movement.h" #include "event_object_movement.h"
#define NUM_TILES_IN_PRIMARY 512 #define NUM_TILES_IN_PRIMARY 512 // NOTE: CopyTilesetToVram assumes the number of primary and secondary tiles is the same
#define NUM_TILES_TOTAL 1024 #define NUM_TILES_TOTAL 1024
#define NUM_METATILES_IN_PRIMARY 512 #define NUM_METATILES_IN_PRIMARY 512
#define NUM_METATILES_TOTAL 1024 #define NUM_METATILES_TOTAL 1024
@ -10,43 +10,41 @@
#define NUM_PALS_TOTAL 12 #define NUM_PALS_TOTAL 12
#define MAX_MAP_DATA_SIZE 0x2800 #define MAX_MAP_DATA_SIZE 0x2800
extern struct BackupMapLayout gBackupMapLayout; #define NUM_TILES_PER_METATILE 8
struct MapHeader *mapconnection_get_mapheader(struct MapConnection *connection);
int GetMapBorderIdAt(int x, int y);
int CanCameraMoveInDirection(int direction);
u16 GetBehaviorByMetatileId(u16 metatile);
void MapGridSetMetatileEntryAt(int, int, u16);
void not_trainer_hill_battle_pyramid(void); // Map coordinates are offset by 7 when using the map
void sub_8055FC0(void); // buffer because it needs to load sufficient border
void mapheader_copy_mapdata_with_padding(struct MapHeader *mapHeader); // metatiles to fill the player's view (the player has
void map_copy_with_padding(u16 *map, u16 width, u16 height); // 7 metatiles of view horizontally in either direction).
void sub_80560AC(struct MapHeader *); #define MAP_OFFSET 7
void fillSouthConnection(struct MapHeader *, struct MapHeader *, s32); #define MAP_OFFSET_W (MAP_OFFSET * 2 + 1)
void fillNorthConnection(struct MapHeader *, struct MapHeader *, s32); #define MAP_OFFSET_H (MAP_OFFSET * 2)
void fillWestConnection(struct MapHeader *, struct MapHeader *, s32);
void fillEastConnection(struct MapHeader *, struct MapHeader *, s32); extern struct BackupMapLayout gBackupMapLayout;
u8 MapGridGetZCoordAt(int s, int y);
u8 MapGridIsImpassableAt(int, int); u32 MapGridGetMetatileIdAt(int x, int y);
u32 MapGridGetMetatileIdAt(int, int); u32 MapGridGetMetatileBehaviorAt(int x, int y);
u32 MapGridGetMetatileBehaviorAt(int x, int y); // return: (u8|u16|int) args: (int|s16|s32) void MapGridSetMetatileIdAt(int x, int y, u16 metatile);
u8 MapGridGetMetatileLayerTypeAt(int, int); void MapGridSetMetatileEntryAt(int x, int y, u16 metatile);
void MapGridSetMetatileIdAt(int, int, u16); void GetCameraCoords(u16 * x, u16 * y);
u16 GetBehaviorByMetatileId(u16 metatile); u8 MapGridGetCollisionAt(int x, int y);
void save_serialize_map(void); int GetMapBorderIdAt(int x, int y);
void sub_8056670(); bool32 CanCameraMoveInDirection(int direction);
bool8 CameraMove(int, int); u16 GetMetatileAttributesById(u16 metatile);
struct MapConnection *sub_8056A64(u8 direction, int x, int y); void GetCameraFocusCoords(u16 *x, u16 *y);
bool8 sub_8056ABC(u8 direction, int x, int y, struct MapConnection *connection); u8 MapGridGetMetatileLayerTypeAt(int x, int y);
bool8 sub_8056B20(int x, int src_width, int dest_width, int offset); u8 MapGridGetElevationAt(int x, int y);
struct MapConnection *sub_8056BA0(s16 x, s16 y); // fieldmap.c bool8 CameraMove(int x, int y);
void sub_8056C50(u16, u16); void SaveMapView(void);
void sav1_camera_get_focus_coords(u16 *x, u16 *y); void SetCameraFocusCoords(u16 x, u16 y);
void GetCameraCoords(u16*, u16*); void InitMap(void);
void sub_8056D28(struct MapLayout *pData); void InitMapFromSavedGame(void);
void sub_8056D38(struct MapLayout *pData); void CopyMapTilesetsToVram(struct MapLayout const *mapLayout);
void apply_map_tileset2_palette(struct MapLayout *pData); void LoadMapTilesetPalettes(struct MapLayout const *mapLayout);
void copy_map_tileset1_tileset2_to_vram(/*TODO: arg types*/); void LoadSecondaryTilesetPalette(struct MapLayout const *mapLayout);
void apply_map_tileset1_tileset2_palette(/*TODO: arg types*/); void CopyPrimaryTilesetToVram(const struct MapLayout *);
void CopySecondaryTilesetToVram(const struct MapLayout *);
const struct MapHeader *const GetMapHeaderFromConnection(const struct MapConnection *connection);
const struct MapConnection *GetMapConnectionAtPos(s16 x, s16 y);
#endif #endif

View File

@ -58,6 +58,12 @@
#define TOTAL_OBJ_TILE_COUNT 1024 #define TOTAL_OBJ_TILE_COUNT 1024
#define PLTT_SIZEOF(n) ((n) * sizeof(u16))
#define PLTT_SIZE_4BPP PLTT_SIZEOF(16)
#define PLTT_SIZE_8BPP PLTT_SIZEOF(256)
#define PLTT_OFFSET_4BPP(n) ((n) * PLTT_SIZE_4BPP)
#define RGB(r, g, b) ((r) | ((g) << 5) | ((b) << 10)) #define RGB(r, g, b) ((r) | ((g) << 5) | ((b) << 10))
#define RGB_BLACK RGB(0, 0, 0) #define RGB_BLACK RGB(0, 0, 0)

View File

@ -1,31 +1,48 @@
#ifndef GUARD_GLOBAL_FIELDMAP_H #ifndef GUARD_GLOBAL_FIELDMAP_H
#define GUARD_GLOBAL_FIELDMAP_H #define GUARD_GLOBAL_FIELDMAP_H
#define COLLISION_DIR_SOUTH 0 // Masks/shifts for blocks in the map grid
#define COLLISION_DIR_NORTH 1 // Map grid blocks consist of a 10 bit metatile id, a 2 bit collision value, and a 4 bit elevation value
#define COLLISION_DIR_WEST 2 // This is the data stored in each data/layouts/*/map.bin file
#define COLLISION_DIR_EAST 3 #define MAPGRID_METATILE_ID_MASK 0x03FF // Bits 0-9
#define COLLISION_DIR_ALL (COLLISION_DIR_NORTH | COLLISION_DIR_SOUTH | COLLISION_DIR_EAST | COLLISION_DIR_WEST) #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
#define METATILE_COLLISION_MASK 0x0C00 // An undefined map grid block has all metatile id bits set and nothing else
#define METATILE_ID_MASK 0x03FF #define MAPGRID_UNDEFINED MAPGRID_METATILE_ID_MASK
#define METATILE_ID_UNDEFINED 0x03FF
#define METATILE_ELEVATION_SHIFT 0x000C // Masks/shifts for metatile attributes
#define METATILE_COLLISION_SHIFT 0x000A // Metatile attributes consist of an 8 bit behavior value, 4 unused bits, and a 4 bit layer type value
#define METATILE_ELEVATION_MASK 0xF000 // This is the data stored in each data/tilesets/*/*/metatile_attributes.bin file
#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 {
METATILE_LAYER_TYPE_NORMAL, // Metatile uses middle and top bg layers
METATILE_LAYER_TYPE_COVERED, // Metatile uses bottom and middle bg layers
METATILE_LAYER_TYPE_SPLIT, // Metatile uses bottom and top bg layers
};
#define METATILE_ID(tileset, name) (METATILE_##tileset##_##name) #define METATILE_ID(tileset, name) (METATILE_##tileset##_##name)
// Rows of metatiles do not actually have a strict width.
// This constant is used for calculations for finding the next row of metatiles
// for constructing large tiles, such as the Battle Pike's curtain tile.
#define METATILE_ROW_WIDTH 8
typedef void (*TilesetCB)(void); typedef void (*TilesetCB)(void);
struct Tileset struct Tileset
{ {
/*0x00*/ bool8 isCompressed; /*0x00*/ bool8 isCompressed;
/*0x01*/ bool8 isSecondary; /*0x01*/ bool8 isSecondary;
/*0x04*/ void *tiles; /*0x04*/ const u32 *tiles;
/*0x08*/ void *palettes; /*0x08*/ const u16 (*palettes)[16];
/*0x0c*/ void *metatiles; /*0x0c*/ const u16 *metatiles;
/*0x10*/ void *metatileAttributes; /*0x10*/ const u16 *metatileAttributes;
/*0x14*/ TilesetCB callback; /*0x14*/ TilesetCB callback;
}; };
@ -33,10 +50,10 @@ struct MapLayout
{ {
/*0x00*/ s32 width; /*0x00*/ s32 width;
/*0x04*/ s32 height; /*0x04*/ s32 height;
/*0x08*/ u16 *border; /*0x08*/ const u16 *border;
/*0x0c*/ u16 *map; /*0x0c*/ const u16 *map;
/*0x10*/ struct Tileset *primaryTileset; /*0x10*/ const struct Tileset *primaryTileset;
/*0x14*/ struct Tileset *secondaryTileset; /*0x14*/ const struct Tileset *secondaryTileset;
}; };
struct BackupMapLayout struct BackupMapLayout
@ -50,7 +67,7 @@ struct ObjectEventTemplate
{ {
/*0x00*/ u8 localId; /*0x00*/ u8 localId;
/*0x01*/ u8 graphicsId; /*0x01*/ u8 graphicsId;
/*0x02*/ u8 unk2; /*0x02*/ u8 kind; // Always OBJ_KIND_NORMAL in Ruby/Sapphire.
/*0x04*/ s16 x; /*0x04*/ s16 x;
/*0x06*/ s16 y; /*0x06*/ s16 y;
/*0x08*/ u8 elevation; /*0x08*/ u8 elevation;
@ -59,7 +76,7 @@ struct ObjectEventTemplate
u8 movementRangeY:4; u8 movementRangeY:4;
/*0x0C*/ u16 trainerType; /*0x0C*/ u16 trainerType;
/*0x0E*/ u16 trainerRange_berryTreeId; /*0x0E*/ u16 trainerRange_berryTreeId;
/*0x10*/ u8 *script; /*0x10*/ const u8 *script;
/*0x14*/ u16 flagId; /*0x14*/ u16 flagId;
}; };
@ -78,8 +95,7 @@ struct CoordEvent
u8 elevation; u8 elevation;
u16 trigger; u16 trigger;
u16 index; u16 index;
u8 filler_A[0x2]; const u8 *script;
u8 *script;
}; };
struct BgEvent struct BgEvent
@ -88,7 +104,7 @@ struct BgEvent
u8 elevation; u8 elevation;
u8 kind; // The "kind" field determines how to access bgUnion union below. u8 kind; // The "kind" field determines how to access bgUnion union below.
union { union {
u8 *script; const u8 *script;
struct { struct {
u16 item; u16 item;
u16 hiddenItemId; u16 hiddenItemId;
@ -104,10 +120,10 @@ struct MapEvents
u8 coordEventCount; u8 coordEventCount;
u8 bgEventCount; u8 bgEventCount;
struct ObjectEventTemplate *objectEvents; const struct ObjectEventTemplate *objectEvents;
struct WarpEvent *warps; const struct WarpEvent *warps;
struct CoordEvent *coordEvents; const struct CoordEvent *coordEvents;
struct BgEvent *bgEvents; const struct BgEvent *bgEvents;
}; };
struct MapConnection struct MapConnection
@ -121,15 +137,15 @@ struct MapConnection
struct MapConnections struct MapConnections
{ {
s32 count; s32 count;
struct MapConnection *connections; const struct MapConnection *connections;
}; };
struct MapHeader struct MapHeader
{ {
/* 0x00 */ struct MapLayout *mapLayout; /* 0x00 */ const struct MapLayout *mapLayout;
/* 0x04 */ struct MapEvents *events; /* 0x04 */ const struct MapEvents *events;
/* 0x08 */ u8 *mapScripts; /* 0x08 */ const u8 *mapScripts;
/* 0x0C */ struct MapConnections *connections; /* 0x0C */ const struct MapConnections *connections;
/* 0x10 */ u16 music; /* 0x10 */ u16 music;
/* 0x12 */ u16 mapLayoutId; /* 0x12 */ u16 mapLayoutId;
/* 0x14 */ u8 regionMapSectionId; /* 0x14 */ u8 regionMapSectionId;

View File

@ -13,7 +13,7 @@ void ItemUseOnFieldCB_Itemfinder(u8);
void ItemUseOutOfBattle_Berry(u8); void ItemUseOutOfBattle_Berry(u8);
void RunItemfinderResults(u8); void RunItemfinderResults(u8);
void ExitItemfinder(u8); void ExitItemfinder(u8);
bool8 ItemfinderCheckForHiddenItems(struct MapEvents *, u8); bool8 ItemfinderCheckForHiddenItems(const struct MapEvents *, u8);
void sub_80C9720(u8); void sub_80C9720(u8);
void sub_80C9838(u8, s16, s16); void sub_80C9838(u8, s16, s16);
u8 GetPlayerDirectionTowardsHiddenItem(s16, s16); u8 GetPlayerDirectionTowardsHiddenItem(s16, s16);

View File

@ -69,7 +69,7 @@ void gpu_sync_bg_hide();
// GetMapConnection // GetMapConnection
bool8 SetDiveWarpEmerge(u16 x, u16 y); bool8 SetDiveWarpEmerge(u16 x, u16 y);
bool8 SetDiveWarpDive(u16 x, u16 y); bool8 SetDiveWarpDive(u16 x, u16 y);
void sub_80538F0(u8 mapGroup, u8 mapNum); void LoadMapFromCameraTransition(u8 mapGroup, u8 mapNum);
// sub_8053994 // sub_8053994
void ResetInitialPlayerAvatarState(void); void ResetInitialPlayerAvatarState(void);
void StoreInitialPlayerAvatarState(void); void StoreInitialPlayerAvatarState(void);
@ -177,7 +177,7 @@ u16 sub_805559C(void);
void sub_80555B0(int linkPlayerId, int a2, struct UnkStruct_8054FF8 *a3); void sub_80555B0(int linkPlayerId, int a2, struct UnkStruct_8054FF8 *a3);
bool32 sub_8055618(struct UnkStruct_8054FF8 *); bool32 sub_8055618(struct UnkStruct_8054FF8 *);
bool32 sub_8055630(struct UnkStruct_8054FF8 *); bool32 sub_8055630(struct UnkStruct_8054FF8 *);
u8 *sub_8055648(struct UnkStruct_8054FF8 *); const u8 *sub_8055648(struct UnkStruct_8054FF8 *);
bool32 sub_8055660(struct UnkStruct_8054FF8 *); bool32 sub_8055660(struct UnkStruct_8054FF8 *);
const u8 *sub_805568C(struct UnkStruct_8054FF8 *); const u8 *sub_805568C(struct UnkStruct_8054FF8 *);
void sub_80557E8(void); void sub_80557E8(void);

View File

@ -8,6 +8,17 @@
#define FADE_COLOR_WHITE (RGB(31, 31, 31) | 0x8000) #define FADE_COLOR_WHITE (RGB(31, 31, 31) | 0x8000)
#define PALETTES_BG 0x0000FFFF
#define PALETTES_OBJECTS 0xFFFF0000
#define PALETTES_ALL (PALETTES_BG | PALETTES_OBJECTS)
#define PLTT_ID(n) ((n) * 16)
#define BG_PLTT_OFFSET 0x000
#define OBJ_PLTT_OFFSET 0x100
#define BG_PLTT_ID(n) (BG_PLTT_OFFSET + PLTT_ID(n))
#define OBJ_PLTT_ID(n) (OBJ_PLTT_OFFSET + PLTT_ID(n))
#define OBJ_PLTT_ID2(n) (PLTT_ID((n) + 16))
enum enum
{ {
FAST_FADE_IN_FROM_WHITE, FAST_FADE_IN_FROM_WHITE,

View File

@ -8,11 +8,11 @@ void ResetSecretBases(void);
void SetCurrentSecretBaseVar(void); void SetCurrentSecretBaseVar(void);
void CheckPlayerHasSecretBase(void); void CheckPlayerHasSecretBase(void);
void SetOpenedSecretBaseMetatile(void); void SetOpenedSecretBaseMetatile(void);
void sub_80BB970(struct MapEvents *events); void SetOccupiedSecretBaseEntranceMetatiles(const struct MapEvents *events);
u8 sub_80BBB24(void); u8 sub_80BBB24(void);
void sub_80BBCCC(u8 flagIn); void InitSecretBaseAppearance(u8 flagIn);
void SetCurrentSecretBaseFromPosition(struct MapPosition *, struct MapEvents *); void SetCurrentSecretBaseFromPosition(struct MapPosition *, const struct MapEvents *);
void sub_80BC038(struct MapPosition *, struct MapEvents *); void sub_80BC038(struct MapPosition *, const struct MapEvents *);
u8 sub_80BC050(); u8 sub_80BC050();
u8 *GetSecretBaseMapName(u8 *dest); u8 *GetSecretBaseMapName(u8 *dest);
void SetPlayerSecretBaseRecordMixingParty(); void SetPlayerSecretBaseRecordMixingParty();

View File

@ -46,9 +46,9 @@ void DoBrailleDigEffect(void)
MapGridSetMetatileIdAt(16, 8, METATILE_ID(Cave, SealedChamberEntrance_TopLeft)); MapGridSetMetatileIdAt(16, 8, METATILE_ID(Cave, SealedChamberEntrance_TopLeft));
MapGridSetMetatileIdAt(17, 8, METATILE_ID(Cave, SealedChamberEntrance_TopMid)); MapGridSetMetatileIdAt(17, 8, METATILE_ID(Cave, SealedChamberEntrance_TopMid));
MapGridSetMetatileIdAt(18, 8, METATILE_ID(Cave, SealedChamberEntrance_TopRight)); MapGridSetMetatileIdAt(18, 8, METATILE_ID(Cave, SealedChamberEntrance_TopRight));
MapGridSetMetatileIdAt(16, 9, METATILE_ID(Cave, SealedChamberEntrance_BottomLeft) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(16, 9, METATILE_ID(Cave, SealedChamberEntrance_BottomLeft) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(17, 9, METATILE_ID(Cave, SealedChamberEntrance_BottomMid)); MapGridSetMetatileIdAt(17, 9, METATILE_ID(Cave, SealedChamberEntrance_BottomMid));
MapGridSetMetatileIdAt(18, 9, METATILE_ID(Cave, SealedChamberEntrance_BottomRight) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(18, 9, METATILE_ID(Cave, SealedChamberEntrance_BottomRight) | MAPGRID_COLLISION_MASK);
DrawWholeMapView(); DrawWholeMapView();
PlaySE(SE_BANG); PlaySE(SE_BANG);
FlagSet(FLAG_SYS_BRAILLE_DIG); FlagSet(FLAG_SYS_BRAILLE_DIG);
@ -89,9 +89,9 @@ void DoBrailleStrengthEffect(void)
MapGridSetMetatileIdAt(14, 26, METATILE_ID(Cave, SealedChamberEntrance_TopLeft)); MapGridSetMetatileIdAt(14, 26, METATILE_ID(Cave, SealedChamberEntrance_TopLeft));
MapGridSetMetatileIdAt(15, 26, METATILE_ID(Cave, SealedChamberEntrance_TopMid)); MapGridSetMetatileIdAt(15, 26, METATILE_ID(Cave, SealedChamberEntrance_TopMid));
MapGridSetMetatileIdAt(16, 26, METATILE_ID(Cave, SealedChamberEntrance_TopRight)); MapGridSetMetatileIdAt(16, 26, METATILE_ID(Cave, SealedChamberEntrance_TopRight));
MapGridSetMetatileIdAt(14, 27, METATILE_ID(Cave, SealedChamberEntrance_BottomLeft) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(14, 27, METATILE_ID(Cave, SealedChamberEntrance_BottomLeft) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(15, 27, METATILE_ID(Cave, SealedChamberEntrance_BottomMid)); MapGridSetMetatileIdAt(15, 27, METATILE_ID(Cave, SealedChamberEntrance_BottomMid));
MapGridSetMetatileIdAt(16, 27, METATILE_ID(Cave, SealedChamberEntrance_BottomRight) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(16, 27, METATILE_ID(Cave, SealedChamberEntrance_BottomRight) | MAPGRID_COLLISION_MASK);
DrawWholeMapView(); DrawWholeMapView();
PlaySE(SE_BANG); PlaySE(SE_BANG);
FlagSet(FLAG_SYS_BRAILLE_STRENGTH); FlagSet(FLAG_SYS_BRAILLE_STRENGTH);
@ -135,9 +135,9 @@ void UseFlyAncientTomb_Finish(void)
MapGridSetMetatileIdAt(14, 26, METATILE_ID(Cave, SealedChamberEntrance_TopLeft)); MapGridSetMetatileIdAt(14, 26, METATILE_ID(Cave, SealedChamberEntrance_TopLeft));
MapGridSetMetatileIdAt(15, 26, METATILE_ID(Cave, SealedChamberEntrance_TopMid)); MapGridSetMetatileIdAt(15, 26, METATILE_ID(Cave, SealedChamberEntrance_TopMid));
MapGridSetMetatileIdAt(16, 26, METATILE_ID(Cave, SealedChamberEntrance_TopRight)); MapGridSetMetatileIdAt(16, 26, METATILE_ID(Cave, SealedChamberEntrance_TopRight));
MapGridSetMetatileIdAt(14, 27, METATILE_ID(Cave, SealedChamberEntrance_BottomLeft) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(14, 27, METATILE_ID(Cave, SealedChamberEntrance_BottomLeft) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(15, 27, METATILE_ID(Cave, SealedChamberEntrance_BottomMid)); MapGridSetMetatileIdAt(15, 27, METATILE_ID(Cave, SealedChamberEntrance_BottomMid));
MapGridSetMetatileIdAt(16, 27, METATILE_ID(Cave, SealedChamberEntrance_BottomRight) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(16, 27, METATILE_ID(Cave, SealedChamberEntrance_BottomRight) | MAPGRID_COLLISION_MASK);
DrawWholeMapView(); DrawWholeMapView();
PlaySE(SE_BANG); PlaySE(SE_BANG);
FlagSet(FLAG_SYS_BRAILLE_FLY); FlagSet(FLAG_SYS_BRAILLE_FLY);

View File

@ -842,7 +842,7 @@ void DebugMenu_8077238(void)
u16 sp14 = 0; u16 sp14 = 0;
PlayerGetDestCoords(&x, &y); PlayerGetDestCoords(&x, &y);
z = MapGridGetZCoordAt(x, y); z = MapGridGetElevationAt(x, y);
x -= 7; x -= 7;
y -= 7; y -= 7;
@ -2222,7 +2222,7 @@ void DebugMenu_80787EC(void)
ConvertIntToHexStringN(gStringVar1, gSpecialVar_Result, STR_CONV_MODE_LEADING_ZEROS, 4); ConvertIntToHexStringN(gStringVar1, gSpecialVar_Result, STR_CONV_MODE_LEADING_ZEROS, 4);
gSpecialVar_Result = MapGridGetMetatileIdAt(x, y); gSpecialVar_Result = MapGridGetMetatileIdAt(x, y);
ConvertIntToHexStringN(gStringVar2, gSpecialVar_Result, STR_CONV_MODE_LEADING_ZEROS, 4); ConvertIntToHexStringN(gStringVar2, gSpecialVar_Result, STR_CONV_MODE_LEADING_ZEROS, 4);
gSpecialVar_Result = MapGridGetZCoordAt(x, y); gSpecialVar_Result = MapGridGetElevationAt(x, y);
ConvertIntToHexStringN(gStringVar3, gSpecialVar_Result, STR_CONV_MODE_LEADING_ZEROS, 4); ConvertIntToHexStringN(gStringVar3, gSpecialVar_Result, STR_CONV_MODE_LEADING_ZEROS, 4);
StringExpandPlaceholders(gStringVar4, Str_839C414); StringExpandPlaceholders(gStringVar4, Str_839C414);
} }

View File

@ -358,7 +358,7 @@ void InitWatanabeDebugMenu(void)
{ {
default: default:
case 0: case 0:
save_serialize_map(); SaveMapView();
sub_8125E2C(); sub_8125E2C();
gMain.state = 1; gMain.state = 1;
break; break;

View File

@ -2089,7 +2089,7 @@ void sub_80FF1EC(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decIdx)
for (j=0; j<decWidth; j++) for (j=0; j<decWidth; j++)
{ {
x = mapX + j; x = mapX + j;
behavior = GetBehaviorByMetatileId(0x200 + gDecorations[decIdx].tiles[i * decWidth + j]); behavior = GetMetatileAttributesById(0x200 + gDecorations[decIdx].tiles[i * decWidth + j]);
if (MetatileBehavior_IsSecretBaseImpassable(behavior) == TRUE || (gDecorations[decIdx].permission != DECORPERM_PASS_FLOOR && (behavior >> 12) != 0)) if (MetatileBehavior_IsSecretBaseImpassable(behavior) == TRUE || (gDecorations[decIdx].permission != DECORPERM_PASS_FLOOR && (behavior >> 12) != 0))
collision = 0xc00; // impassable collision collision = 0xc00; // impassable collision
else else
@ -2426,7 +2426,7 @@ bool8 sub_80FFC24(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);
layerType = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & 0xf000; layerType = GetMetatileAttributesById(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & 0xf000;
if (!sub_80FFBDC(behaviorAt, decoration)) if (!sub_80FFBDC(behaviorAt, decoration))
{ {
return FALSE; return FALSE;
@ -2451,7 +2451,7 @@ bool8 sub_80FFC24(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);
layerType = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & 0xf000; layerType = GetMetatileAttributesById(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & 0xf000;
if (!MetatileBehavior_IsNormal(behaviorAt) && !sub_80FFB6C(behaviorAt, layerType)) if (!MetatileBehavior_IsNormal(behaviorAt) && !sub_80FFB6C(behaviorAt, layerType))
{ {
return FALSE; return FALSE;
@ -2471,7 +2471,7 @@ bool8 sub_80FFC24(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);
layerType = GetBehaviorByMetatileId(0x200 + decoration->tiles[j]) & 0xf000; layerType = GetMetatileAttributesById(0x200 + decoration->tiles[j]) & 0xf000;
if (!MetatileBehavior_IsNormal(behaviorAt) && !MetatileBehavior_IsSecretBaseNorthWall(behaviorAt)) if (!MetatileBehavior_IsNormal(behaviorAt) && !MetatileBehavior_IsSecretBaseNorthWall(behaviorAt))
{ {
return FALSE; return FALSE;

View File

@ -59,14 +59,14 @@ static void CameraObject_1(struct Sprite *);
static void CameraObject_2(struct Sprite *); static void CameraObject_2(struct Sprite *);
static void ObjectCB_CameraObject(struct Sprite *sprite); static void ObjectCB_CameraObject(struct Sprite *sprite);
static bool8 ObjectEventDoesZCoordMatch(struct ObjectEvent *, u8); static bool8 ObjectEventDoesZCoordMatch(struct ObjectEvent *, u8);
static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8, struct ObjectEventTemplate*, u8); static const struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8, const struct ObjectEventTemplate*, u8);
static void UpdateObjectEventSpriteSubpriorityAndVisibility(struct Sprite *); static void UpdateObjectEventSpriteSubpriorityAndVisibility(struct Sprite *);
static void InitObjectPriorityByZCoord(struct Sprite *sprite, u8 z); static void InitObjectPriorityByZCoord(struct Sprite *sprite, u8 z);
static void CreateReflectionEffectSprites(void); static void CreateReflectionEffectSprites(void);
static u8 GetObjectEventIdByLocalIdAndMapInternal(u8, u8, u8); static u8 GetObjectEventIdByLocalIdAndMapInternal(u8, u8, u8);
static u8 GetObjectEventIdByLocalId(u8); static u8 GetObjectEventIdByLocalId(u8);
static void RemoveObjectEventInternal(struct ObjectEvent *); static void RemoveObjectEventInternal(struct ObjectEvent *);
static void MakeObjectTemplateFromObjectEventTemplate(struct ObjectEventTemplate *objEventTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables); static void MakeObjectTemplateFromObjectEventTemplate(const struct ObjectEventTemplate *objEventTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables);
static void RemoveObjectEventIfOutsideView(struct ObjectEvent *objectEvent); static void RemoveObjectEventIfOutsideView(struct ObjectEvent *objectEvent);
static void SetPlayerAvatarObjectEventIdAndObjectId(u8, u8); static void SetPlayerAvatarObjectEventIdAndObjectId(u8, u8);
static void sub_805B914(struct ObjectEvent *); static void sub_805B914(struct ObjectEvent *);
@ -1149,7 +1149,7 @@ static u8 GetObjectEventIdByLocalId(u8 localId)
return OBJECT_EVENTS_COUNT; return OBJECT_EVENTS_COUNT;
} }
static u8 InitObjectEventStateFromTemplate(struct ObjectEventTemplate *template, u8 mapNum, u8 mapGroup) static u8 InitObjectEventStateFromTemplate(const struct ObjectEventTemplate *template, u8 mapNum, u8 mapGroup)
{ {
struct ObjectEvent *objectEvent; struct ObjectEvent *objectEvent;
u8 objectEventId; u8 objectEventId;
@ -1280,7 +1280,7 @@ void RemoveAllObjectEventsExceptPlayer(void)
} }
} }
static u8 TrySetupObjectEventSprite(struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, u8 mapNum, u8 mapGroup, s16 cameraDeltaX, s16 cameraDeltaY) static u8 TrySetupObjectEventSprite(const struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, u8 mapNum, u8 mapGroup, s16 cameraDeltaX, s16 cameraDeltaY)
{ {
u8 spriteId; u8 spriteId;
u8 objectEventId; u8 objectEventId;
@ -1336,7 +1336,7 @@ static u8 TrySetupObjectEventSprite(struct ObjectEventTemplate *objectEventTempl
return objectEventId; return objectEventId;
} }
static u8 TrySpawnObjectEvent(struct ObjectEventTemplate *objectEventTemplate, u8 mapNum, u8 mapGroup, s16 cameraDeltaX, s16 cameraDeltaY) static u8 TrySpawnObjectEvent(const struct ObjectEventTemplate *objectEventTemplate, u8 mapNum, u8 mapGroup, s16 cameraDeltaX, s16 cameraDeltaY)
{ {
u8 objectEventId; u8 objectEventId;
struct SpriteTemplate spriteTemplate; struct SpriteTemplate spriteTemplate;
@ -1378,7 +1378,7 @@ u8 SpawnSpecialObjectEventParametrized(u8 graphicsId, u8 movementType, u8 localI
y -= 7; y -= 7;
objectEventTemplate.localId = localId; objectEventTemplate.localId = localId;
objectEventTemplate.graphicsId = graphicsId; objectEventTemplate.graphicsId = graphicsId;
objectEventTemplate.unk2 = 0; objectEventTemplate.kind = OBJ_KIND_NORMAL;
objectEventTemplate.x = x; objectEventTemplate.x = x;
objectEventTemplate.y = y; objectEventTemplate.y = y;
objectEventTemplate.elevation = elevation; objectEventTemplate.elevation = elevation;
@ -1392,7 +1392,7 @@ u8 SpawnSpecialObjectEventParametrized(u8 graphicsId, u8 movementType, u8 localI
u8 show_sprite(u8 localId, u8 mapNum, u8 mapGroup) u8 show_sprite(u8 localId, u8 mapNum, u8 mapGroup)
{ {
struct ObjectEventTemplate *objectEventTemplate; const struct ObjectEventTemplate *objectEventTemplate;
s16 x; s16 x;
s16 y; s16 y;
@ -1424,7 +1424,7 @@ static void MakeObjectTemplateFromObjectEventGraphicsInfoWithCallbackIndex(u16 g
MakeObjectTemplateFromObjectEventGraphicsInfo(graphicsId, sMovementTypeCallbacks[movementType], spriteTemplate, subspriteTables); MakeObjectTemplateFromObjectEventGraphicsInfo(graphicsId, sMovementTypeCallbacks[movementType], spriteTemplate, subspriteTables);
} }
static void MakeObjectTemplateFromObjectEventTemplate(struct ObjectEventTemplate *objEventTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) static void MakeObjectTemplateFromObjectEventTemplate(const struct ObjectEventTemplate *objEventTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables)
{ {
MakeObjectTemplateFromObjectEventGraphicsInfoWithCallbackIndex(objEventTemplate->graphicsId, objEventTemplate->movementType, spriteTemplate, subspriteTables); MakeObjectTemplateFromObjectEventGraphicsInfoWithCallbackIndex(objEventTemplate->graphicsId, objEventTemplate->movementType, spriteTemplate, subspriteTables);
} }
@ -2256,7 +2256,7 @@ u8 ObjectEventGetBerryTreeId(u8 objectEventId)
return gObjectEvents[objectEventId].trainerRange_berryTreeId; return gObjectEvents[objectEventId].trainerRange_berryTreeId;
} }
struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) const struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
{ {
if (gSaveBlock1.location.mapNum == mapNum && gSaveBlock1.location.mapGroup == mapGroup) if (gSaveBlock1.location.mapNum == mapNum && gSaveBlock1.location.mapGroup == mapGroup)
return FindObjectEventTemplateByLocalId(localId, gSaveBlock1.objectEventTemplates, gMapHeader.events->objectEventCount); return FindObjectEventTemplateByLocalId(localId, gSaveBlock1.objectEventTemplates, gMapHeader.events->objectEventCount);
@ -2268,7 +2268,7 @@ struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 localId, u8
} }
} }
static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8 localId, struct ObjectEventTemplate *templates, u8 count) static const struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8 localId, const struct ObjectEventTemplate *templates, u8 count)
{ {
u8 i; u8 i;
@ -4466,7 +4466,7 @@ u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dirn)
direction = dirn; direction = dirn;
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y)) if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
return 1; return 1;
else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction)) else if (MapGridGetCollisionAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction))
return 2; return 2;
else if (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)) else if (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction))
return 2; return 2;
@ -4483,7 +4483,7 @@ u8 GetCollisionFlagsAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 d
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y)) if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
flags |= 1; flags |= 1;
if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction) || (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction))) if (MapGridGetCollisionAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction) || (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)))
flags |= 2; flags |= 2;
if (IsZCoordMismatchAt(objectEvent->currentElevation, x, y)) if (IsZCoordMismatchAt(objectEvent->currentElevation, x, y))
flags |= 4; flags |= 4;
@ -7532,7 +7532,7 @@ bool8 IsZCoordMismatchAt(u8 z, s16 x, s16 y)
if (z == 0) if (z == 0)
return FALSE; return FALSE;
mapZ = MapGridGetZCoordAt(x, y); mapZ = MapGridGetElevationAt(x, y);
if (mapZ == 0 || mapZ == 0xF) if (mapZ == 0 || mapZ == 0xF)
return FALSE; return FALSE;
@ -7585,8 +7585,8 @@ u8 ZCoordToPriority(u8 z)
void ObjectEventUpdateZCoord(struct ObjectEvent *objEvent) void ObjectEventUpdateZCoord(struct ObjectEvent *objEvent)
{ {
u8 z = MapGridGetZCoordAt(objEvent->currentCoords.x, objEvent->currentCoords.y); u8 z = MapGridGetElevationAt(objEvent->currentCoords.x, objEvent->currentCoords.y);
u8 z2 = MapGridGetZCoordAt(objEvent->previousCoords.x, objEvent->previousCoords.y); u8 z2 = MapGridGetElevationAt(objEvent->previousCoords.x, objEvent->previousCoords.y);
if (z == 0xF || z2 == 0xF) if (z == 0xF || z2 == 0xF)
return; return;

View File

@ -28,15 +28,15 @@ struct FieldCamera gFieldCamera;
u16 gTotalCameraPixelOffsetY; u16 gTotalCameraPixelOffsetY;
u16 gTotalCameraPixelOffsetX; u16 gTotalCameraPixelOffsetX;
static void RedrawMapSliceNorth(struct FieldCameraOffset*, struct MapLayout*); static void RedrawMapSliceNorth(struct FieldCameraOffset*, const struct MapLayout*);
static void RedrawMapSliceSouth(struct FieldCameraOffset*, struct MapLayout*); static void RedrawMapSliceSouth(struct FieldCameraOffset*, const struct MapLayout*);
static void RedrawMapSliceEast(struct FieldCameraOffset*, struct MapLayout*); static void RedrawMapSliceEast(struct FieldCameraOffset*, const struct MapLayout*);
static void RedrawMapSliceWest(struct FieldCameraOffset*, struct MapLayout*); static void RedrawMapSliceWest(struct FieldCameraOffset*, const struct MapLayout*);
static s32 MapPosToBgTilemapOffset(struct FieldCameraOffset*, s32, s32); static s32 MapPosToBgTilemapOffset(struct FieldCameraOffset*, s32, s32);
static void DrawWholeMapViewInternal(int x, int y, struct MapLayout*); static void DrawWholeMapViewInternal(int x, int y, const struct MapLayout*);
static void DrawMetatileAt(struct MapLayout*, u16, int, int); static void DrawMetatileAt(const struct MapLayout*, u16, int, int);
static void DrawMetatile(s32, u16*, u16); static void DrawMetatile(s32, const u16*, u16);
static void CameraPanningCB_PanAhead(void); static void CameraPanningCB_PanAhead(void);
static void move_tilemap_camera_to_upper_left_corner_(struct FieldCameraOffset *cameraOffset) static void move_tilemap_camera_to_upper_left_corner_(struct FieldCameraOffset *cameraOffset)
@ -100,7 +100,7 @@ void DrawWholeMapView(void)
sFieldCameraOffset.copyBGToVRAM = TRUE; sFieldCameraOffset.copyBGToVRAM = TRUE;
} }
static void DrawWholeMapViewInternal(int x, int y, struct MapLayout *mapLayout) static void DrawWholeMapViewInternal(int x, int y, const struct MapLayout *mapLayout)
{ {
u8 i; u8 i;
u8 j; u8 j;
@ -125,7 +125,7 @@ static void DrawWholeMapViewInternal(int x, int y, struct MapLayout *mapLayout)
static void RedrawMapSlicesForCameraUpdate(struct FieldCameraOffset *cameraOffset, int x, int y) static void RedrawMapSlicesForCameraUpdate(struct FieldCameraOffset *cameraOffset, int x, int y)
{ {
struct MapLayout *mapLayout = gMapHeader.mapLayout; const struct MapLayout *mapLayout = gMapHeader.mapLayout;
if (x > 0) if (x > 0)
RedrawMapSliceWest(cameraOffset, mapLayout); RedrawMapSliceWest(cameraOffset, mapLayout);
@ -138,7 +138,7 @@ static void RedrawMapSlicesForCameraUpdate(struct FieldCameraOffset *cameraOffse
cameraOffset->copyBGToVRAM = TRUE; cameraOffset->copyBGToVRAM = TRUE;
} }
static void RedrawMapSliceNorth(struct FieldCameraOffset *cameraOffset, struct MapLayout *mapLayout) static void RedrawMapSliceNorth(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout)
{ {
u8 i; u8 i;
u8 temp; u8 temp;
@ -157,7 +157,7 @@ static void RedrawMapSliceNorth(struct FieldCameraOffset *cameraOffset, struct M
} }
} }
static void RedrawMapSliceSouth(struct FieldCameraOffset *cameraOffset, struct MapLayout *mapLayout) static void RedrawMapSliceSouth(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout)
{ {
u8 i; u8 i;
u8 temp; u8 temp;
@ -172,7 +172,7 @@ static void RedrawMapSliceSouth(struct FieldCameraOffset *cameraOffset, struct M
} }
} }
static void RedrawMapSliceEast(struct FieldCameraOffset *cameraOffset, struct MapLayout *mapLayout) static void RedrawMapSliceEast(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout)
{ {
u8 i; u8 i;
u8 temp; u8 temp;
@ -187,7 +187,7 @@ static void RedrawMapSliceEast(struct FieldCameraOffset *cameraOffset, struct Ma
} }
} }
static void RedrawMapSliceWest(struct FieldCameraOffset *cameraOffset, struct MapLayout *mapLayout) static void RedrawMapSliceWest(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout)
{ {
u8 i; u8 i;
u8 temp; u8 temp;
@ -226,9 +226,9 @@ void DrawDoorMetatileAt(int x, int y, u16 *arr)
} }
} }
static void DrawMetatileAt(struct MapLayout *mapLayout, u16 offset, int x, int y) static void DrawMetatileAt(const struct MapLayout *mapLayout, u16 offset, int x, int y)
{ {
u16 *metatiles; const u16 *metatiles;
u16 metatileId = MapGridGetMetatileIdAt(x, y); u16 metatileId = MapGridGetMetatileIdAt(x, y);
if (metatileId > NUM_METATILES_TOTAL) if (metatileId > NUM_METATILES_TOTAL)
@ -247,7 +247,7 @@ static void DrawMetatileAt(struct MapLayout *mapLayout, u16 offset, int x, int y
DrawMetatile(MapGridGetMetatileLayerTypeAt(x, y), metatiles + metatileId * 8, offset); DrawMetatile(MapGridGetMetatileLayerTypeAt(x, y), metatiles + metatileId * 8, offset);
} }
static void DrawMetatile(s32 metatileLayerType, u16 *metatiles, u16 offset) static void DrawMetatile(s32 metatileLayerType, const u16 *metatiles, u16 offset)
{ {
switch (metatileLayerType) switch (metatileLayerType)
{ {

View File

@ -88,9 +88,9 @@ static u16 GetPlayerCurMetatileBehavior(int);
static bool8 TryStartInteractionScript(struct MapPosition*, u16, u8); static bool8 TryStartInteractionScript(struct MapPosition*, u16, u8);
static const u8 *GetInteractionScript(struct MapPosition*, u8, u8); static const u8 *GetInteractionScript(struct MapPosition*, u8, u8);
static const u8 *GetInteractedObjectEventScript(struct MapPosition *, u8, u8); static const u8 *GetInteractedObjectEventScript(struct MapPosition *, u8, u8);
static u8 *GetInteractedBackgroundEventScript(struct MapPosition *, u8, u8); static const u8 *GetInteractedBackgroundEventScript(struct MapPosition *, u8, u8);
static u8 *GetInteractedMetatileScript(struct MapPosition *, u8, u8); static const u8 *GetInteractedMetatileScript(struct MapPosition *, u8, u8);
static u8 *GetInteractedWaterScript(struct MapPosition *, u8, u8); static const u8 *GetInteractedWaterScript(struct MapPosition *, u8, u8);
static bool32 TrySetupDiveDownScript(void); static bool32 TrySetupDiveDownScript(void);
static bool32 TrySetupDiveEmergeScript(void); static bool32 TrySetupDiveEmergeScript(void);
static bool8 TryStartStepBasedScript(struct MapPosition *, u16, u16); static bool8 TryStartStepBasedScript(struct MapPosition *, u16, u16);
@ -104,8 +104,8 @@ static s8 GetWarpEventAtMapPosition(struct MapHeader *, struct MapPosition *);
static void sub_8068C30(struct MapHeader *, s8, struct MapPosition *); static void sub_8068C30(struct MapHeader *, s8, struct MapPosition *);
static bool8 map_warp_consider_2_to_inside(struct MapPosition *, u16, u8); static bool8 map_warp_consider_2_to_inside(struct MapPosition *, u16, u8);
static s8 GetWarpEventAtPosition(struct MapHeader *, u16, u16, u8); static s8 GetWarpEventAtPosition(struct MapHeader *, u16, u16, u8);
static u8 *GetCoordEventScriptAtPosition(struct MapHeader *, u16, u16, u8); static const u8 *GetCoordEventScriptAtPosition(struct MapHeader *, u16, u16, u8);
static struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *, u16, u16, u8); static const struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *, u16, u16, u8);
static bool8 TryStartCoordEventScript(struct MapPosition *); static bool8 TryStartCoordEventScript(struct MapPosition *);
static bool8 TryStartWarpEventScript(struct MapPosition *, u16); static bool8 TryStartWarpEventScript(struct MapPosition *, u16);
static bool8 TryStartCrackedFloorHoleScript(u16); static bool8 TryStartCrackedFloorHoleScript(u16);
@ -295,7 +295,7 @@ static void GetInFrontOfPlayerPosition(struct MapPosition *position)
GetXYCoordsOneStepInFrontOfPlayer(&position->x, &position->y); GetXYCoordsOneStepInFrontOfPlayer(&position->x, &position->y);
PlayerGetDestCoords(&x, &y); PlayerGetDestCoords(&x, &y);
if (MapGridGetZCoordAt(x, y) != 0) if (MapGridGetElevationAt(x, y) != 0)
position->height = PlayerGetZCoord(); position->height = PlayerGetZCoord();
else else
position->height = 0; position->height = 0;
@ -398,9 +398,9 @@ static const u8 *GetInteractedObjectEventScript(struct MapPosition *position, u8
return script; return script;
} }
static u8 *GetInteractedBackgroundEventScript(struct MapPosition *position, u8 metatileBehavior, u8 direction) static const u8 *GetInteractedBackgroundEventScript(struct MapPosition *position, u8 metatileBehavior, u8 direction)
{ {
struct BgEvent *bgEvent = GetBackgroundEventAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height); const struct BgEvent *bgEvent = GetBackgroundEventAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height);
if (bgEvent == NULL) if (bgEvent == NULL)
return NULL; return NULL;
@ -449,7 +449,7 @@ static u8 *GetInteractedBackgroundEventScript(struct MapPosition *position, u8 m
return bgEvent->bgUnion.script; return bgEvent->bgUnion.script;
} }
static u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 metatileBehavior, u8 direction) static const u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 metatileBehavior, u8 direction)
{ {
s8 height; s8 height;
@ -485,7 +485,7 @@ static u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 metatile
return EventScript_Blueprint; return EventScript_Blueprint;
height = position->height; height = position->height;
if (height == MapGridGetZCoordAt(position->x, position->y)) if (height == MapGridGetElevationAt(position->x, position->y))
{ {
if (MetatileBehavior_IsSecretBasePC(metatileBehavior) == TRUE) if (MetatileBehavior_IsSecretBasePC(metatileBehavior) == TRUE)
return SecretBase_EventScript_PC; return SecretBase_EventScript_PC;
@ -500,7 +500,7 @@ static u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 metatile
return NULL; return NULL;
} }
static u8 *GetInteractedWaterScript(struct MapPosition *unused1, u8 metatileBehavior, u8 direction) static const u8 *GetInteractedWaterScript(struct MapPosition *unused1, u8 metatileBehavior, u8 direction)
{ {
if (FlagGet(FLAG_BADGE05_GET) == TRUE && PartyHasMonWithSurf() == TRUE && IsPlayerFacingSurfableFishableWater() == TRUE) if (FlagGet(FLAG_BADGE05_GET) == TRUE && PartyHasMonWithSurf() == TRUE && IsPlayerFacingSurfableFishableWater() == TRUE)
return EventScript_UseSurf; return EventScript_UseSurf;
@ -552,7 +552,7 @@ static bool8 TryStartStepBasedScript(struct MapPosition *position, u16 metatileB
bool8 TryStartCoordEventScript(struct MapPosition *position) bool8 TryStartCoordEventScript(struct MapPosition *position)
{ {
u8 *script = GetCoordEventScriptAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height); const u8 *script = GetCoordEventScriptAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height);
if (script == NULL) if (script == NULL)
return FALSE; return FALSE;
@ -764,7 +764,7 @@ static s8 GetWarpEventAtMapPosition(struct MapHeader *mapHeader, struct MapPosit
static void sub_8068C30(struct MapHeader *unused, s8 warpEventId, struct MapPosition *position) static void sub_8068C30(struct MapHeader *unused, s8 warpEventId, struct MapPosition *position)
{ {
struct WarpEvent *warpEvent = &gMapHeader.events->warps[warpEventId]; const struct WarpEvent *warpEvent = &gMapHeader.events->warps[warpEventId];
if (warpEvent->mapNum == MAP_NUM(DYNAMIC)) if (warpEvent->mapNum == MAP_NUM(DYNAMIC))
{ {
@ -811,7 +811,7 @@ static bool8 map_warp_consider_2_to_inside(struct MapPosition *position, u16 met
static s8 GetWarpEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation) static s8 GetWarpEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation)
{ {
s32 i; s32 i;
struct WarpEvent *warpEvent = mapHeader->events->warps; const struct WarpEvent *warpEvent = mapHeader->events->warps;
u8 warpCount = mapHeader->events->warpCount; u8 warpCount = mapHeader->events->warpCount;
for (i = 0; i < warpCount; i++, warpEvent++) for (i = 0; i < warpCount; i++, warpEvent++)
@ -825,7 +825,7 @@ static s8 GetWarpEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 e
return -1; return -1;
} }
static u8 *TryRunCoordEventScript(struct CoordEvent *coordEvent) static const u8 *TryRunCoordEventScript(const struct CoordEvent *coordEvent)
{ {
if (coordEvent != NULL) if (coordEvent != NULL)
{ {
@ -845,10 +845,10 @@ static u8 *TryRunCoordEventScript(struct CoordEvent *coordEvent)
return NULL; return NULL;
} }
static u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation) static const u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation)
{ {
s32 i; s32 i;
struct CoordEvent *coordEvents = mapHeader->events->coordEvents; const struct CoordEvent *coordEvents = mapHeader->events->coordEvents;
u8 coordEventCount = mapHeader->events->coordEventCount; u8 coordEventCount = mapHeader->events->coordEventCount;
for (i = 0; i < coordEventCount; i++) for (i = 0; i < coordEventCount; i++)
@ -857,7 +857,7 @@ static u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16 x, u16
{ {
if (coordEvents[i].elevation == elevation || coordEvents[i].elevation == 0) if (coordEvents[i].elevation == elevation || coordEvents[i].elevation == 0)
{ {
u8 *script = TryRunCoordEventScript(&coordEvents[i]); const u8 *script = TryRunCoordEventScript(&coordEvents[i]);
if (script != NULL) if (script != NULL)
return script; return script;
} }
@ -866,15 +866,15 @@ static u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16 x, u16
return NULL; return NULL;
} }
u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position) const u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position)
{ {
return GetCoordEventScriptAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height); return GetCoordEventScriptAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height);
} }
static struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation) static const struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation)
{ {
u8 i; u8 i;
struct BgEvent *bgEvents = mapHeader->events->bgEvents; const struct BgEvent *bgEvents = mapHeader->events->bgEvents;
u8 bgEventCount = mapHeader->events->bgEventCount; u8 bgEventCount = mapHeader->events->bgEventCount;
for (i = 0; i < bgEventCount; i++) for (i = 0; i < bgEventCount; i++)

View File

@ -1024,7 +1024,7 @@ static void sub_812800C(struct ObjectEvent *objectEvent, struct Sprite *sprite)
for (i = DIR_SOUTH; i <= DIR_EAST; i++, x = sprite->data[6], y = sprite->data[7]) for (i = DIR_SOUTH; i <= DIR_EAST; i++, x = sprite->data[6], y = sprite->data[7])
{ {
MoveCoords(i, &x, &y); MoveCoords(i, &x, &y);
if (MapGridGetZCoordAt(x, y) == 3) if (MapGridGetElevationAt(x, y) == 3)
{ {
sprite->data[5] ++; sprite->data[5] ++;
break; break;

View File

@ -616,7 +616,7 @@ u8 CheckForObjectEventCollision(struct ObjectEvent *a, s16 x, s16 y, u8 directio
static bool8 sub_8058EF0(s16 x, s16 y, u8 direction) static bool8 sub_8058EF0(s16 x, s16 y, u8 direction)
{ {
if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
&& MapGridGetZCoordAt(x, y) == 3 && MapGridGetElevationAt(x, y) == 3
&& GetObjectEventIdByXYZ(x, y, 3) == 16) && GetObjectEventIdByXYZ(x, y, 3) == 16)
{ {
sub_805A20C(direction); sub_805A20C(direction);

View File

@ -430,10 +430,10 @@ void MauvilleGymSpecial2(void)
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH2_On)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH2_On));
break; break;
case METATILE_ID(MauvilleGym, GreenBeamH3_Off): case METATILE_ID(MauvilleGym, GreenBeamH3_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH3_On) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH3_On) | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_ID(MauvilleGym, GreenBeamH4_Off): case METATILE_ID(MauvilleGym, GreenBeamH4_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH4_On) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH4_On) | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_ID(MauvilleGym, RedBeamH1_On): case METATILE_ID(MauvilleGym, RedBeamH1_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH1_Off)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH1_Off));
@ -454,41 +454,41 @@ void MauvilleGymSpecial2(void)
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH2_On)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH2_On));
break; break;
case METATILE_ID(MauvilleGym, RedBeamH3_Off): case METATILE_ID(MauvilleGym, RedBeamH3_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH3_On) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH3_On) | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_ID(MauvilleGym, RedBeamH4_Off): case METATILE_ID(MauvilleGym, RedBeamH4_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH4_On) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH4_On) | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_ID(MauvilleGym, GreenBeamV1_On): case METATILE_ID(MauvilleGym, GreenBeamV1_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleBottom_On) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleBottom_On) | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_ID(MauvilleGym, GreenBeamV2_On): case METATILE_ID(MauvilleGym, GreenBeamV2_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, FloorTile)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, FloorTile));
break; break;
case METATILE_ID(MauvilleGym, RedBeamV1_On): case METATILE_ID(MauvilleGym, RedBeamV1_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleBottom_Off) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleBottom_Off) | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_ID(MauvilleGym, RedBeamV2_On): case METATILE_ID(MauvilleGym, RedBeamV2_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, FloorTile)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, FloorTile));
break; break;
case METATILE_ID(MauvilleGym, PoleBottom_On): case METATILE_ID(MauvilleGym, PoleBottom_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamV1_On) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamV1_On) | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_ID(MauvilleGym, FloorTile): case METATILE_ID(MauvilleGym, FloorTile):
if (MapGridGetMetatileIdAt(x, y - 1) == METATILE_ID(MauvilleGym, GreenBeamV1_On)) if (MapGridGetMetatileIdAt(x, y - 1) == METATILE_ID(MauvilleGym, GreenBeamV1_On))
{ {
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamV2_On) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamV2_On) | MAPGRID_COLLISION_MASK);
} }
else else
{ {
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamV2_On) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamV2_On) | MAPGRID_COLLISION_MASK);
} }
break; break;
case METATILE_ID(MauvilleGym, PoleBottom_Off): case METATILE_ID(MauvilleGym, PoleBottom_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamV1_On) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamV1_On) | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_ID(MauvilleGym, PoleTop_Off): case METATILE_ID(MauvilleGym, PoleTop_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleTop_On) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleTop_On) | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_ID(MauvilleGym, PoleTop_On): case METATILE_ID(MauvilleGym, PoleTop_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleTop_Off)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleTop_Off));
@ -538,10 +538,10 @@ void MauvilleGymSpecial3(void)
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH4_Off)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH4_Off));
break; break;
case METATILE_ID(MauvilleGym, GreenBeamV1_On): case METATILE_ID(MauvilleGym, GreenBeamV1_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleBottom_On) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleBottom_On) | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_ID(MauvilleGym, RedBeamV1_On): case METATILE_ID(MauvilleGym, RedBeamV1_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleBottom_Off) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleBottom_Off) | MAPGRID_COLLISION_MASK);
break; break;
case METATILE_ID(MauvilleGym, GreenBeamV2_On): case METATILE_ID(MauvilleGym, GreenBeamV2_On):
case METATILE_ID(MauvilleGym, RedBeamV2_On): case METATILE_ID(MauvilleGym, RedBeamV2_On):
@ -913,7 +913,7 @@ static void PCTurnOffEffect(void)
{ {
tileId = METATILE_ID(BrendansMaysHouse, MayPC_Off); tileId = METATILE_ID(BrendansMaysHouse, MayPC_Off);
} }
MapGridSetMetatileIdAt(gSaveBlock1.pos.x + dx + 7, gSaveBlock1.pos.y + dy + 7, tileId | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(gSaveBlock1.pos.x + dx + 7, gSaveBlock1.pos.y + dy + 7, tileId | MAPGRID_COLLISION_MASK);
DrawWholeMapView(); DrawWholeMapView();
} }
@ -949,13 +949,13 @@ static void LotteryCornerComputerEffect(struct Task *task)
task->data[3] = 0; task->data[3] = 0;
if (task->data[4] != 0) if (task->data[4] != 0)
{ {
MapGridSetMetatileIdAt(18, 8, METATILE_ID(Shop, Laptop1_Normal) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(18, 8, METATILE_ID(Shop, Laptop1_Normal) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(18, 9, METATILE_ID(Shop, Laptop2_Normal) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(18, 9, METATILE_ID(Shop, Laptop2_Normal) | MAPGRID_COLLISION_MASK);
} }
else else
{ {
MapGridSetMetatileIdAt(18, 8, METATILE_ID(Shop, Laptop1_Flash) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(18, 8, METATILE_ID(Shop, Laptop1_Flash) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(18, 9, METATILE_ID(Shop, Laptop2_Flash) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(18, 9, METATILE_ID(Shop, Laptop2_Flash) | MAPGRID_COLLISION_MASK);
} }
DrawWholeMapView(); DrawWholeMapView();
task->data[4] ^= 1; task->data[4] ^= 1;
@ -969,8 +969,8 @@ static void LotteryCornerComputerEffect(struct Task *task)
void EndLotteryCornerComputerEffect(void) void EndLotteryCornerComputerEffect(void)
{ {
MapGridSetMetatileIdAt(18, 8, METATILE_ID(Shop, Laptop1_Normal) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(18, 8, METATILE_ID(Shop, Laptop1_Normal) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(18, 9, METATILE_ID(Shop, Laptop2_Normal) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(18, 9, METATILE_ID(Shop, Laptop2_Normal) | MAPGRID_COLLISION_MASK);
DrawWholeMapView(); DrawWholeMapView();
} }
@ -1302,33 +1302,33 @@ void sub_810ED60(struct Task *task)
task->data[3] = 0; task->data[3] = 0;
if (task->data[4] != 0) if (task->data[4] != 0)
{ {
MapGridSetMetatileIdAt( 7, 7, METATILE_BattleTower_Elevator_Top0 | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 7, 7, METATILE_BattleTower_Elevator_Top0 | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 8, 7, METATILE_BattleTower_Elevator_Top1 | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 8, 7, METATILE_BattleTower_Elevator_Top1 | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 9, 7, METATILE_BattleTower_Elevator_Top1 | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 9, 7, METATILE_BattleTower_Elevator_Top1 | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(10, 7, METATILE_BattleTower_Elevator_Top2 | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(10, 7, METATILE_BattleTower_Elevator_Top2 | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 7, 8, METATILE_BattleTower_Elevator_Mid0 | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 7, 8, METATILE_BattleTower_Elevator_Mid0 | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 8, 8, METATILE_BattleTower_Elevator_Mid1 | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 8, 8, METATILE_BattleTower_Elevator_Mid1 | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 9, 8, METATILE_BattleTower_Elevator_Mid1 | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 9, 8, METATILE_BattleTower_Elevator_Mid1 | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(10, 8, METATILE_BattleTower_Elevator_Mid2 | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(10, 8, METATILE_BattleTower_Elevator_Mid2 | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 7, 9, METATILE_BattleTower_Elevator_Bottom0 | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 7, 9, METATILE_BattleTower_Elevator_Bottom0 | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 8, 9, METATILE_BattleTower_Elevator_Bottom1 | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 8, 9, METATILE_BattleTower_Elevator_Bottom1 | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 9, 9, METATILE_BattleTower_Elevator_Bottom1 | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 9, 9, METATILE_BattleTower_Elevator_Bottom1 | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(10, 9, METATILE_BattleTower_Elevator_Bottom2 | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(10, 9, METATILE_BattleTower_Elevator_Bottom2 | MAPGRID_COLLISION_MASK);
} }
else else
{ {
MapGridSetMetatileIdAt( 7, 7, (METATILE_BattleTower_Elevator_Top0 + 3) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 7, 7, (METATILE_BattleTower_Elevator_Top0 + 3) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 8, 7, (METATILE_BattleTower_Elevator_Top1 + 3) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 8, 7, (METATILE_BattleTower_Elevator_Top1 + 3) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 9, 7, (METATILE_BattleTower_Elevator_Top1 + 3) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 9, 7, (METATILE_BattleTower_Elevator_Top1 + 3) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(10, 7, (METATILE_BattleTower_Elevator_Top2 + 3) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(10, 7, (METATILE_BattleTower_Elevator_Top2 + 3) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 7, 8, (METATILE_BattleTower_Elevator_Mid0 + 3) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 7, 8, (METATILE_BattleTower_Elevator_Mid0 + 3) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 8, 8, (METATILE_BattleTower_Elevator_Mid1 + 3) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 8, 8, (METATILE_BattleTower_Elevator_Mid1 + 3) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 9, 8, (METATILE_BattleTower_Elevator_Mid1 + 3) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 9, 8, (METATILE_BattleTower_Elevator_Mid1 + 3) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(10, 8, (METATILE_BattleTower_Elevator_Mid2 + 3) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(10, 8, (METATILE_BattleTower_Elevator_Mid2 + 3) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 7, 9, (METATILE_BattleTower_Elevator_Bottom0 + 3) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 7, 9, (METATILE_BattleTower_Elevator_Bottom0 + 3) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 8, 9, (METATILE_BattleTower_Elevator_Bottom1 + 3) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 8, 9, (METATILE_BattleTower_Elevator_Bottom1 + 3) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt( 9, 9, (METATILE_BattleTower_Elevator_Bottom1 + 3) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt( 9, 9, (METATILE_BattleTower_Elevator_Bottom1 + 3) | MAPGRID_COLLISION_MASK);
MapGridSetMetatileIdAt(10, 9, (METATILE_BattleTower_Elevator_Bottom2 + 3) | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(10, 9, (METATILE_BattleTower_Elevator_Bottom2 + 3) | MAPGRID_COLLISION_MASK);
} }
DrawWholeMapView(); DrawWholeMapView();
task->data[4] ^= 1; task->data[4] ^= 1;

File diff suppressed because it is too large Load Diff

View File

@ -106,7 +106,7 @@ void Debug_SetUpFieldMove_Cut(void)
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
{ {
x = j - 1 + gPlayerFacingPosition.x; x = j - 1 + gPlayerFacingPosition.x;
if (MapGridGetZCoordAt(x, y) == gPlayerFacingPosition.height) if (MapGridGetElevationAt(x, y) == gPlayerFacingPosition.height)
{ {
metatileBehavior = MapGridGetMetatileBehaviorAt(x, y); metatileBehavior = MapGridGetMetatileBehaviorAt(x, y);
if (MetatileBehavior_IsPokeGrass(metatileBehavior) == TRUE if (MetatileBehavior_IsPokeGrass(metatileBehavior) == TRUE
@ -147,7 +147,7 @@ bool8 SetUpFieldMove_Cut(void)
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
{ {
x = j - 1 + gPlayerFacingPosition.x; x = j - 1 + gPlayerFacingPosition.x;
if (MapGridGetZCoordAt(x, y) == gPlayerFacingPosition.height) if (MapGridGetElevationAt(x, y) == gPlayerFacingPosition.height)
{ {
tileBehavior = MapGridGetMetatileBehaviorAt(x, y); tileBehavior = MapGridGetMetatileBehaviorAt(x, y);
if(MetatileBehavior_IsPokeGrass(tileBehavior) == TRUE if(MetatileBehavior_IsPokeGrass(tileBehavior) == TRUE
@ -219,7 +219,7 @@ bool8 FldEff_CutGrass(void)
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
{ {
x = j - 1 + gPlayerFacingPosition.x; x = j - 1 + gPlayerFacingPosition.x;
if (MapGridGetZCoordAt(x, y) == (s8)gPlayerFacingPosition.height) if (MapGridGetElevationAt(x, y) == (s8)gPlayerFacingPosition.height)
{ {
tileBehavior = MapGridGetMetatileBehaviorAt(x, y); tileBehavior = MapGridGetMetatileBehaviorAt(x, y);
if (MetatileBehavior_IsCuttableGrass(tileBehavior) == TRUE) if (MetatileBehavior_IsCuttableGrass(tileBehavior) == TRUE)

View File

@ -110,13 +110,13 @@ void sub_80B4710(u8 taskId)
sub_80B45B4(taskId, sEscalatorMetatiles_1F_1, 0); sub_80B45B4(taskId, sEscalatorMetatiles_1F_1, 0);
break; break;
case 2: case 2:
sub_80B45B4(taskId, sEscalatorMetatiles_1F_2, (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); sub_80B45B4(taskId, sEscalatorMetatiles_1F_2, MAPGRID_COLLISION_MASK);
break; break;
case 3: case 3:
sub_80B45B4(taskId, sEscalatorMetatiles_1F_3, 0); sub_80B45B4(taskId, sEscalatorMetatiles_1F_3, 0);
break; break;
case 4: case 4:
sub_80B45B4(taskId, sEscalatorMetatiles_2F_0, (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); sub_80B45B4(taskId, sEscalatorMetatiles_2F_0, MAPGRID_COLLISION_MASK);
break; break;
case 5: case 5:
sub_80B45B4(taskId, sEscalatorMetatiles_2F_1, 0); sub_80B45B4(taskId, sEscalatorMetatiles_2F_1, 0);

View File

@ -239,7 +239,7 @@ bool32 CanFish(void)
} }
else else
{ {
if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior) && !MapGridIsImpassableAt(x, y)) if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior) && MapGridGetCollisionAt(x, y) == 0)
return TRUE; return TRUE;
if (MetatileBehavior_IsBridge(tileBehavior) == TRUE) if (MetatileBehavior_IsBridge(tileBehavior) == TRUE)
return TRUE; return TRUE;
@ -326,7 +326,7 @@ void ExitItemfinder(u8 taskId)
DestroyTask(taskId); DestroyTask(taskId);
} }
bool8 ItemfinderCheckForHiddenItems(struct MapEvents *events, u8 taskId) bool8 ItemfinderCheckForHiddenItems(const struct MapEvents *events, u8 taskId)
{ {
int distanceX, distanceY; int distanceX, distanceY;
u16 x, y; u16 x, y;
@ -359,10 +359,10 @@ bool8 ItemfinderCheckForHiddenItems(struct MapEvents *events, u8 taskId)
return FALSE; return FALSE;
} }
bool8 HiddenItemAtPos(struct MapEvents *events, s16 x, s16 y) bool8 HiddenItemAtPos(const struct MapEvents *events, s16 x, s16 y)
{ {
u8 bgEventCount = events->bgEventCount; u8 bgEventCount = events->bgEventCount;
struct BgEvent *bgEvent = events->bgEvents; const struct BgEvent *bgEvent = events->bgEvents;
int i; int i;
for (i = 0; i < bgEventCount; i++) for (i = 0; i < bgEventCount; i++)
@ -378,14 +378,14 @@ bool8 HiddenItemAtPos(struct MapEvents *events, s16 x, s16 y)
return FALSE; return FALSE;
} }
bool8 sub_80C9688(struct MapConnection *connection, int x, int y) bool8 sub_80C9688(const struct MapConnection *connection, int x, int y)
{ {
struct MapHeader *mapHeader; const struct MapHeader *mapHeader;
u16 localX, localY; u16 localX, localY;
u32 localOffset; u32 localOffset;
s32 localLength; s32 localLength;
mapHeader = mapconnection_get_mapheader(connection); mapHeader = GetMapHeaderFromConnection(connection);
switch (connection->direction) switch (connection->direction)
{ {
@ -441,7 +441,7 @@ void sub_80C9720(u8 taskId)
|| var2 > curY || var2 > curY
|| curY >= height) || curY >= height)
{ {
struct MapConnection *conn = sub_8056BA0(curX, curY); const struct MapConnection *conn = GetMapConnectionAtPos(curX, curY);
if (conn && sub_80C9688(conn, curX, curY) == TRUE) if (conn && sub_80C9688(conn, curX, curY) == TRUE)
sub_80C9838(taskId, curX - x, curY - y); sub_80C9838(taskId, curX - x, curY - y);
} }

View File

@ -352,8 +352,8 @@ void Overworld_SetObjEventTemplateMovementType(u8 localId, u8 movementType)
static void mapdata_load_assets_to_gpu_and_full_redraw(void) static void mapdata_load_assets_to_gpu_and_full_redraw(void)
{ {
move_tilemap_camera_to_upper_left_corner(); move_tilemap_camera_to_upper_left_corner();
copy_map_tileset1_tileset2_to_vram(gMapHeader.mapLayout); CopyMapTilesetsToVram(gMapHeader.mapLayout);
apply_map_tileset1_tileset2_palette(gMapHeader.mapLayout); LoadMapTilesetPalettes(gMapHeader.mapLayout);
DrawWholeMapView(); DrawWholeMapView();
cur_mapheader_run_tileset_funcs_after_some_cpuset(); cur_mapheader_run_tileset_funcs_after_some_cpuset();
} }
@ -602,7 +602,7 @@ bool8 SetDiveWarpDive(u16 x, u16 y)
return SetDiveWarp(CONNECTION_DIVE, x, y); return SetDiveWarp(CONNECTION_DIVE, x, y);
} }
void sub_80538F0(u8 mapGroup, u8 mapNum) void LoadMapFromCameraTransition(u8 mapGroup, u8 mapNum)
{ {
s32 paletteIndex; s32 paletteIndex;
@ -621,9 +621,9 @@ void sub_80538F0(u8 mapGroup, u8 mapNum)
SetDefaultFlashLevel(); SetDefaultFlashLevel();
Overworld_ClearSavedMusic(); Overworld_ClearSavedMusic();
RunOnTransitionMapScript(); RunOnTransitionMapScript();
not_trainer_hill_battle_pyramid(); InitMap();
sub_8056D38(gMapHeader.mapLayout); CopySecondaryTilesetToVram(gMapHeader.mapLayout);
apply_map_tileset2_palette(gMapHeader.mapLayout); LoadSecondaryTilesetPalette(gMapHeader.mapLayout);
for (paletteIndex = 6; paletteIndex < 12; paletteIndex++) for (paletteIndex = 6; paletteIndex < 12; paletteIndex++)
ApplyWeatherGammaShiftToPal(paletteIndex); ApplyWeatherGammaShiftToPal(paletteIndex);
@ -661,11 +661,11 @@ void sub_8053994(u32 a1)
RunOnTransitionMapScript(); RunOnTransitionMapScript();
UpdateLocationHistoryForRoamer(); UpdateLocationHistoryForRoamer();
RoamerMoveToOtherLocationSet(); RoamerMoveToOtherLocationSet();
not_trainer_hill_battle_pyramid(); InitMap();
if (a1 != 1 && v3) if (a1 != 1 && v3)
{ {
UpdateTVScreensOnMap(gBackupMapLayout.width, gBackupMapLayout.height); UpdateTVScreensOnMap(gBackupMapLayout.width, gBackupMapLayout.height);
sub_80BBCCC(1); InitSecretBaseAppearance(TRUE);
} }
} }
@ -1476,7 +1476,7 @@ void CB2_ContinueSavedGame(void)
UnfreezeObjectEvents(); UnfreezeObjectEvents();
DoTimeBasedEvents(); DoTimeBasedEvents();
sub_805308C(); sub_805308C();
sub_8055FC0(); InitMapFromSavedGame();
PlayTimeCounter_Start(); PlayTimeCounter_Start();
ScriptContext1_Init(); ScriptContext1_Init();
ScriptContext2_Disable(); ScriptContext2_Disable();
@ -1570,15 +1570,15 @@ static bool32 sub_805483C(u8 *state)
(*state)++; (*state)++;
break; break;
case 6: case 6:
sub_8056D28(gMapHeader.mapLayout); CopyPrimaryTilesetToVram(gMapHeader.mapLayout);
(*state)++; (*state)++;
break; break;
case 7: case 7:
sub_8056D38(gMapHeader.mapLayout); CopySecondaryTilesetToVram(gMapHeader.mapLayout);
(*state)++; (*state)++;
break; break;
case 8: case 8:
apply_map_tileset1_tileset2_palette(gMapHeader.mapLayout); LoadMapTilesetPalettes(gMapHeader.mapLayout);
(*state)++; (*state)++;
break; break;
case 9: case 9:
@ -1636,15 +1636,15 @@ bool32 sub_805493C(u8 *state, u32 a2)
(*state)++; (*state)++;
break; break;
case 6: case 6:
sub_8056D28(gMapHeader.mapLayout); CopyPrimaryTilesetToVram(gMapHeader.mapLayout);
(*state)++; (*state)++;
break; break;
case 7: case 7:
sub_8056D38(gMapHeader.mapLayout); CopySecondaryTilesetToVram(gMapHeader.mapLayout);
(*state)++; (*state)++;
break; break;
case 8: case 8:
apply_map_tileset1_tileset2_palette(gMapHeader.mapLayout); LoadMapTilesetPalettes(gMapHeader.mapLayout);
(*state)++; (*state)++;
break; break;
case 9: case 9:
@ -1726,15 +1726,15 @@ bool32 sub_8054A9C(u8 *state)
(*state)++; (*state)++;
break; break;
case 5: case 5:
sub_8056D28(gMapHeader.mapLayout); CopyPrimaryTilesetToVram(gMapHeader.mapLayout);
(*state)++; (*state)++;
break; break;
case 6: case 6:
sub_8056D38(gMapHeader.mapLayout); CopySecondaryTilesetToVram(gMapHeader.mapLayout);
(*state)++; (*state)++;
break; break;
case 7: case 7:
apply_map_tileset1_tileset2_palette(gMapHeader.mapLayout); LoadMapTilesetPalettes(gMapHeader.mapLayout);
(*state)++; (*state)++;
break; break;
case 8: case 8:
@ -1848,7 +1848,7 @@ void mli4_mapscripts_and_other(void)
gTotalCameraPixelOffsetX = 0; gTotalCameraPixelOffsetX = 0;
gTotalCameraPixelOffsetY = 0; gTotalCameraPixelOffsetY = 0;
ResetObjectEvents(); ResetObjectEvents();
sav1_camera_get_focus_coords(&x, &y); GetCameraFocusCoords(&x, &y);
initialPlayerAvatarState = GetInitialPlayerAvatarState(); initialPlayerAvatarState = GetInitialPlayerAvatarState();
InitPlayerAvatar(x, y, initialPlayerAvatarState->direction, gSaveBlock2.playerGender); InitPlayerAvatar(x, y, initialPlayerAvatarState->direction, gSaveBlock2.playerGender);
SetPlayerAvatarTransitionFlags(initialPlayerAvatarState->transitionFlags); SetPlayerAvatarTransitionFlags(initialPlayerAvatarState->transitionFlags);
@ -1883,8 +1883,8 @@ void sub_8054E7C(void)
void sub_8054E98(void) void sub_8054E98(void)
{ {
u16 x, y; u16 x, y;
sav1_camera_get_focus_coords(&x, &y); GetCameraFocusCoords(&x, &y);
sub_8056C50(x + gUnknown_03004860, y); SetCameraFocusCoords(x + gUnknown_03004860, y);
} }
void sub_8054EC8(void) void sub_8054EC8(void)
@ -1892,7 +1892,7 @@ void sub_8054EC8(void)
u16 i; u16 i;
u16 x, y; u16 x, y;
sav1_camera_get_focus_coords(&x, &y); GetCameraFocusCoords(&x, &y);
x -= gUnknown_03004860; x -= gUnknown_03004860;
for (i = 0; i < gFieldLinkPlayerCount; i++) for (i = 0; i < gFieldLinkPlayerCount; i++)
@ -2312,7 +2312,7 @@ bool32 sub_8055630(struct UnkStruct_8054FF8 *a1)
return FALSE; return FALSE;
} }
u8 *sub_8055648(struct UnkStruct_8054FF8 *a1) const u8 *sub_8055648(struct UnkStruct_8054FF8 *a1)
{ {
if (a1->c != 2) if (a1->c != 2)
return 0; return 0;
@ -2720,7 +2720,7 @@ static u8 LinkPlayerDetectCollision(u8 selfObjEventId, u8 a2, s16 x, s16 y)
} }
} }
} }
return MapGridIsImpassableAt(x, y); return MapGridGetCollisionAt(x, y);
} }
static void CreateLinkPlayerSprite(u8 linkPlayerId) static void CreateLinkPlayerSprite(u8 linkPlayerId)

View File

@ -906,7 +906,7 @@ int RotatingGate_CanRotate(u8 gateId, int rotationDirection)
if (sRotatingGate_ArmLayout[shape][i * 2 + j]) if (sRotatingGate_ArmLayout[shape][i * 2 + j])
{ {
if (MapGridIsImpassableAt(x + armPos[armIndex].deltaX, y + armPos[armIndex].deltaY) == 1) if (MapGridGetCollisionAt(x + armPos[armIndex].deltaX, y + armPos[armIndex].deltaY) == 1)
return 0; return 0;
} }
} }

View File

@ -1909,7 +1909,7 @@ bool8 ScrCmd_setmetatile(struct ScriptContext *ctx)
if (!impassable) if (!impassable)
MapGridSetMetatileIdAt(x, y, metatileId); MapGridSetMetatileIdAt(x, y, metatileId);
else else
MapGridSetMetatileIdAt(x, y, metatileId | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, metatileId | MAPGRID_COLLISION_MASK);
return FALSE; return FALSE;
} }

View File

@ -239,7 +239,7 @@ void ScriptContext2_RunNewScript(const u8 *ptr)
static u8 *mapheader_get_tagged_pointer(u8 tag) static u8 *mapheader_get_tagged_pointer(u8 tag)
{ {
u8 *mapScripts = gMapHeader.mapScripts; const u8 *mapScripts = gMapHeader.mapScripts;
if (mapScripts == NULL) if (mapScripts == NULL)
return NULL; return NULL;

View File

@ -324,7 +324,7 @@ void sub_80BB8CC(void)
VarSet(VAR_SECRET_BASE_MAP, gMapHeader.regionMapSectionId); VarSet(VAR_SECRET_BASE_MAP, gMapHeader.regionMapSectionId);
} }
void sub_80BB970(struct MapEvents *events) void SetOccupiedSecretBaseEntranceMetatiles(const struct MapEvents *events)
{ {
u16 bgevidx, idx, jdx; u16 bgevidx, idx, jdx;
s16 tile_id; s16 tile_id;
@ -450,7 +450,7 @@ bool8 CurrentMapIsSecretBase(void)
return FALSE; return FALSE;
} }
void sub_80BBCCC(u8 flagIn) void InitSecretBaseAppearance(u8 flagIn)
{ {
u16 curBaseId; u16 curBaseId;
u16 x, y; u16 x, y;
@ -546,7 +546,7 @@ void SetSecretBaseOwnerGfxId(void)
VarSet(VAR_OBJ_GFX_ID_F, sSecretBaseOwnerGfxIds[GetSecretBaseOwnerType(curBase)]); VarSet(VAR_OBJ_GFX_ID_F, sSecretBaseOwnerGfxIds[GetSecretBaseOwnerType(curBase)]);
} }
void SetCurrentSecretBaseFromPosition(struct MapPosition *position, struct MapEvents *events) void SetCurrentSecretBaseFromPosition(struct MapPosition *position, const struct MapEvents *events)
{ {
s16 i; s16 i;
@ -561,7 +561,7 @@ void SetCurrentSecretBaseFromPosition(struct MapPosition *position, struct MapEv
} }
} }
void sub_80BC038(struct MapPosition *position, struct MapEvents *events) void sub_80BC038(struct MapPosition *position, const struct MapEvents *events)
{ {
SetCurrentSecretBaseFromPosition(position, events); SetCurrentSecretBaseFromPosition(position, events);
SetCurrentSecretBaseVar(); SetCurrentSecretBaseVar();
@ -726,7 +726,7 @@ void MoveOutOfSecretBase(void)
void sub_80BC474(void) void sub_80BC474(void)
{ {
u16 eventId; u16 eventId;
struct MapEvents *mapEvents = gMapHeader.events; const struct MapEvents *mapEvents = gMapHeader.events;
for (eventId = 0; eventId < mapEvents->bgEventCount; eventId++) for (eventId = 0; eventId < mapEvents->bgEventCount; eventId++)
{ {

View File

@ -597,7 +597,7 @@ static u8 SaveCallback2(void)
static void sub_807160C(void) static void sub_807160C(void)
{ {
save_serialize_map(); SaveMapView();
saveDialogCallback = SaveDialogCB_DisplayConfirmMessage; saveDialogCallback = SaveDialogCB_DisplayConfirmMessage;
savingComplete = FALSE; savingComplete = FALSE;
} }

View File

@ -567,7 +567,7 @@ 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) if (MapGridGetMetatileBehaviorAt(x, y) == 0x86)
MapGridSetMetatileIdAt(x, y, tileId | (COLLISION_DIR_ALL << METATILE_COLLISION_SHIFT)); MapGridSetMetatileIdAt(x, y, tileId | MAPGRID_COLLISION_MASK);
} }
} }
} }