From 551cb7209393d06e302a5bda489c341f38efd1f3 Mon Sep 17 00:00:00 2001 From: octorock <79596758+octorock@users.noreply.github.com> Date: Sat, 10 Jun 2023 15:12:51 +0200 Subject: Extract some map data definitions --- include/asm.h | 30 ++++++++++++++++++++++++--- include/common.h | 1 - include/entity.h | 2 ++ include/functions.h | 5 ----- include/game.h | 2 +- include/global.h | 6 ++---- include/main.h | 4 ++-- include/manager/diggingCaveEntranceManager.h | 31 ++++++++++++++++++++++++---- include/manager/manager29.h | 2 +- include/manager/miscManager.h | 4 ++-- include/map.h | 29 ++++++++++++++++---------- include/physics.h | 2 +- include/room.h | 7 ++++--- include/roomid.h | 6 +++--- include/save.h | 3 ++- 15 files changed, 92 insertions(+), 42 deletions(-) (limited to 'include') diff --git a/include/asm.h b/include/asm.h index f6592f82..b9ffccbf 100644 --- a/include/asm.h +++ b/include/asm.h @@ -11,7 +11,6 @@ extern u32 GetTileTypeByPos(s32 x, s32 y, u32 layer); extern u32 GetTileType(u32 position, u32 layer); extern void SetTile(u32 index, u32 position, u32 layer); extern void UpdateScrollVram(void); -extern u32 sub_080B1B0C(struct Entity_*); extern u32 sub_080B1BA4(u32, u32, u32); extern void LoadResourceAsync(const void* src, u32 dest, u32 size); extern void GenericConfused(struct Entity_*); @@ -37,9 +36,34 @@ extern u32 sub_0800442E(struct Entity_*); extern u32 sub_08007DD6(u32, const u16*); extern void SoundReqClipped(struct Entity_*, u32); extern u32 sub_0800132C(struct Entity_*, struct Entity_*); -extern u32 sub_080B1B44(u32, u32); + +/** + * Sets the collision data for one metatile. + */ +extern void SetCollisionData(u32 collisionData, u32 metaTilePos, u32 layer); +/** + * Returns the collision data for one metatile. + */ +extern u32 GetCollisionData(u32 metaTilePos, u32 layer); +/** + * Returns the collision data for one metatile. (x, y in metatiles relative to the room) + */ +extern u32 sub_080B1B3C(u32 x, u32 y, u32 layer); +/** + * Returns the collision data for one metatile. (x, y in pixels relative to the room) + */ +extern u32 sub_080B1B2C(u32 x, u32 y, u32 layer); +/** + * Returns the collision data for one metatile. (x, y in pixels relative to the world) + */ +extern u32 sub_080B1B18(u32 x, u32 y, u32 layer); + +extern u32 sub_080B1B0C(struct Entity_* entity); + +// Get CollisionData for entity (relative to entity?) +extern u32 sub_080B1AF0(struct Entity_*, s32 xOffset, s32 yOffset); + extern u32 sub_080B1A48(u32, u32, u32); -extern u32 sub_080B1B18(s32, s32, u32); extern u32 sub_080B1AE0(u16, u8); extern u32 GetTileUnderEntity(struct Entity_*); extern u32 sub_0800445C(struct Entity_*); diff --git a/include/common.h b/include/common.h index cf01adf5..ea3a1e39 100644 --- a/include/common.h +++ b/include/common.h @@ -135,7 +135,6 @@ typedef struct { extern const DungeonFloorMetadata gDungeonFloorMetadatas[]; - typedef struct { u8 area; u8 room; diff --git a/include/entity.h b/include/entity.h index 78dcde47..dda579a0 100644 --- a/include/entity.h +++ b/include/entity.h @@ -519,6 +519,8 @@ extern u8 gManagerCount; /** @name Tile Macros */ /// @{ #define TILE(x, y) (((((x)-gRoomControls.origin_x) >> 4) & 0x3F) | ((((y)-gRoomControls.origin_y) >> 4) & 0x3F) << 6) +// Calculate metatilePosition from x and y coordinates where x and y are already relative to the current room. +#define TILE_LOCAL(x, y) ((((x) >> 4) & 0x3F) | (((y) >> 4) & 0x3F) << 6) #define TILE_POS(x, y) (x + (y << 6)) #define TILE_POS_X_COMPONENT 0x3f #define TILE_POS_Y_COMPONENT 0xfc0 diff --git a/include/functions.h b/include/functions.h index 28b03c4a..0356cccd 100644 --- a/include/functions.h +++ b/include/functions.h @@ -23,7 +23,6 @@ extern void CreateMinishEntrance(u32 tile); extern u32 CreateRandomItemDrop(Entity*, u32); extern void DrawDirect(u32 spriteIndex, u32 frameIndex); extern void DrawEntities(void); -extern bool32 EntityWithinDistance(Entity*, s32, s32, s32); extern void FlushSprites(void); extern LayerStruct* GetLayerByIndex(u32); extern u32 GetTileIndex(u32 tilePos, u32 layer); @@ -49,12 +48,8 @@ extern void ClearBgAnimations(void); extern void SetBGDefaults(void); // Unidentified -extern void sub_08000148(u32, u32, u32); extern u32 sub_080B1A0C(Entity*, s32, s32); extern u32 sub_080B1AE0(u16, u8); -extern u32 sub_080B1AF0(Entity*, s32, s32); -extern u32 sub_080B1B18(s32, s32, u32); -extern u32 sub_080B1B44(u32, u32); extern s32 sub_080012DC(Entity*); extern void sub_08001318(Entity*); extern void sub_080027EA(Entity*, u32, u32); diff --git a/include/game.h b/include/game.h index 6be63ee2..9e1bc655 100644 --- a/include/game.h +++ b/include/game.h @@ -295,7 +295,7 @@ typedef struct { u8 maxX; u8 maxY; u8 windcrestId; /**< Id to set in gSave.windcrests when the user entered a room in the boundaries specified above.*/ - //u8 pad; + // u8 pad; u16 textIndex; /**< The text to show for this area.*/ } OverworldLocation; extern const OverworldLocation gOverworldLocations[]; diff --git a/include/global.h b/include/global.h index 9b3557ce..fbed1b4f 100644 --- a/include/global.h +++ b/include/global.h @@ -78,10 +78,8 @@ #if NON_MATCHING #define ASM_FUNC(path, decl) #else -#define ASM_FUNC(path, decl) \ - NAKED decl { \ - asm(".include " #path); \ - } +#define ASM_FUNC(path, decl) \ + NAKED decl { asm(".include " #path); } #endif #if NON_MATCHING diff --git a/include/main.h b/include/main.h index a5680d10..f2a229ea 100644 --- a/include/main.h +++ b/include/main.h @@ -64,8 +64,8 @@ typedef struct { u8 pauseFrames; /**< Number of frames to pause. */ u8 pauseCount; /**< Number of pauses to make. */ u8 pauseInterval; /**< Number of frames to play between each pause. */ - u8 pad; - u16 ticks; /**< Current time. */ + u8 pad; // TODO actually used in CopyOAM() + u16 ticks; /**< Current time. */ } Main; /** diff --git a/include/manager/diggingCaveEntranceManager.h b/include/manager/diggingCaveEntranceManager.h index 6f9c8914..959b5397 100644 --- a/include/manager/diggingCaveEntranceManager.h +++ b/include/manager/diggingCaveEntranceManager.h @@ -7,12 +7,35 @@ typedef struct { Manager base; } DiggingCaveEntranceManager; +enum DiggingCaveEntranceType { + CAVE_LAKE_WOODS_ENTER, + CAVE_LAKE_WOODS_LEAVE, + CAVE_HYRULE_TOWN_ENTER, + CAVE_HYRULE_TOWN_LEAVE, + CAVE_EASTERN_HILL_ENTER, + CAVE_EASTERN_HILL_LEAVE, + CAVE_CRENEL_ENTER, + CAVE_CRENEL_LEAVE, + CAVE_VEIL_FALLS_ENTER, + CAVE_VEIL_FALLS_LEAVE, + CAVE_TRILBY_HIGHLANDS_ENTER, + CAVE_TRILBY_HIGHLANDS_LEAVE, + CAVE_CASTOR_WILDS_ENTER, + CAVE_CASTOR_WILDS_LEAVE, + CAVE_LAKE_HYLIA_NORTH_ENTER, + CAVE_LAKE_HYLIA_NORTH_LEAVE, + CAVE_LON_LON_RANCH_ENTER, + CAVE_LON_LON_RANCH_LEAVE, + CAVE_LAKE_HYLIA_CENTER_ENTER, + CAVE_LAKE_HYLIA_CENTER_LEAVE, +}; + typedef struct { u16 sourceTilePosition; /**< Tile position for the entrance in the source room. */ - u8 sourceRoom; - u8 type; // TODO some sort of type that is used to index gUnk_08109194 - u8 targetArea; - u8 targetRoom; + u8 sourceRoom; /**< @see RoomID */ + u8 type; /**< @see DiggingCaveEntranceType */ + u8 targetArea; /**< @see AreaID */ + u8 targetRoom; /**< @see RoomID */ u16 targetTilePosition; /**< Tile position for the entrance in the target room. */ } DiggingCaveEntrance; diff --git a/include/manager/manager29.h b/include/manager/manager29.h index a26f291c..c7d99b69 100644 --- a/include/manager/manager29.h +++ b/include/manager/manager29.h @@ -9,7 +9,7 @@ typedef struct { u16* unk_28; u16* unk_2c; u8 filler[0x4]; - u8 unk_34; + u8 layer; u8 unk_35; u8 unk_36; u8 unk_37; diff --git a/include/manager/miscManager.h b/include/manager/miscManager.h index bde8388b..44047584 100644 --- a/include/manager/miscManager.h +++ b/include/manager/miscManager.h @@ -6,8 +6,8 @@ typedef struct { Manager base; u8 unk_20[0x18]; - s16 unk_38; - s16 unk_3a; + s16 x; + s16 y; u16 unk_3c; u16 flags; } MiscManager; diff --git a/include/map.h b/include/map.h index 201346e9..adb447b8 100644 --- a/include/map.h +++ b/include/map.h @@ -6,14 +6,18 @@ typedef struct { /*0x0000*/ BgSettings* bgSettings; - /*0x0004*/ u16 mapData[0x40*0x40]; /**< MetaTileIndex for each tile on the current layer. */ // tilemap data? <-- gMapDataTop / gMapDataBottom - /*0x2004*/ u8 collisionData[0x40*0x40]; // more tilemap data? <-- gUnk_0200D654 / gUnk_02027EB4 - /*0x3004*/ u16 mapDataClone[0x40*0x40]; // more tilemap data? <-- gUnk_0200E654 / gUnk_02028EB4 - // Tileset - /*0x5004*/ u16 metatileTypes[0x800]; /**< Maps from the MetaTileIndex to the MetaTileType. */ // gMetatileTypesTop, gMetatileTypesBottom - /*0x6004*/ u16 unkData2[0x800]; /**< Maps from a MetaTileType to a MetaTileIndex. */ // gUnk_02011654,gUnk_0202BEB4 // TODO metatile index for the metatile type?? - /*0x7004*/ u16 metatiles[0x800 * 4]; /**< Mapping from a metatile to the four tile_attrs it consists of.*/ // gMetatilesTop, gMetatilesBottom - + /*0x0004*/ u16 mapData[0x40 * 0x40]; + /**< MetaTileIndex for each tile on the current layer. */ // tilemap data? <-- gMapDataTop / gMapDataBottom + /*0x2004*/ u8 collisionData[0x40 * 0x40]; // more tilemap data? <-- gUnk_0200D654 / gUnk_02027EB4 + /*0x3004*/ u16 mapDataClone[0x40 * 0x40]; // more tilemap data? <-- gUnk_0200E654 / gUnk_02028EB4 + // Tileset + /*0x5004*/ u16 metatileTypes[0x800]; + /**< Maps from the MetaTileIndex to the MetaTileType. */ // gMetatileTypesTop, gMetatileTypesBottom + /*0x6004*/ u16 unkData2[0x800]; + /**< Maps from a MetaTileType to a MetaTileIndex. */ // gUnk_02011654,gUnk_0202BEB4 // TODO metatile index for + // the metatile type?? + /*0x7004*/ u16 metatiles[0x800 * 4]; + /**< Mapping from a metatile to the four tile_attrs it consists of.*/ // gMetatilesTop, gMetatilesBottom /*0xb004*/ u8 unkData3[0x40*0x40]; /**< Some sort of special behavior for tiles? Falling into holes or jumping off walls does not work when this is all zero.*/ // gUnk_02016654, gUnk_02030EB4 // TODO check with debugger what accesses this @@ -33,12 +37,11 @@ extern LayerStruct gMapTop; extern LayerStruct gMapBottom; // Rendered tilemaps https://www.coranac.com/tonc/text/regbg.htm#sec-map -//extern u16 gMapDataTopSpecial[0x4000]; -//extern u16 gMapDataBottomSpecial[0x4000]; +// extern u16 gMapDataTopSpecial[0x4000]; +// extern u16 gMapDataBottomSpecial[0x4000]; LayerStruct* GetLayerByIndex(u32); - /* Definition where some map data is found and where it should be copied to. Defined using the map_data asm macro, e.g. in map_headers.s @@ -49,5 +52,9 @@ typedef struct { u32 size; } MapDataDefinition; +// There is another map data definition following. +#define MAP_MULTIPLE 0x80000000 +// The src is compressed. +#define MAP_COMPRESSED 0x80000000 #endif // MAP_H diff --git a/include/physics.h b/include/physics.h index 9afd0f9e..74cefa41 100644 --- a/include/physics.h +++ b/include/physics.h @@ -21,7 +21,7 @@ void SortEntityBelow(Entity* above_ent, Entity* below_ent); void LinearMoveDirection(Entity* ent, u32 a, u32 b); void LinearMoveAngle(Entity* ent, u32 a, u32 b); -bool32 EntityWithinDistance(Entity*, s32, s32, s32); +bool32 EntityWithinDistance(Entity* entity, s32 x, s32 y, s32 distance); u32 sub_0806FCA0(Entity*, Entity*); u32 sub_0806F58C(Entity*, Entity*); u32 PointInsideRadius(s32 x, s32 y, s32 radius); diff --git a/include/room.h b/include/room.h index 8158146a..bb2c03d0 100644 --- a/include/room.h +++ b/include/room.h @@ -45,8 +45,8 @@ typedef struct { /*0x18*/ u16 unk_18; // progress during transition in same area? /*0x1A*/ u16 unk_1a; // calculated from unk_18 /*0x1C*/ u16 unk_1c; // 0, 0xff - /*0x1E*/ u16 width; - /*0x20*/ u16 height; + /*0x1E*/ u16 width; /**< Width in pixels. */ + /*0x20*/ u16 height; /**< Height in pixels. */ /*0x22*/ u16 unk_22; // so far always 0xffff /*0x24*/ s8 aff_x; /*0x25*/ s8 aff_y; @@ -91,7 +91,8 @@ typedef struct { u8 area; u8 room; u16 unk_02; - u32 flags; /**< Flags that can be set on the tracked rooms. Used e.g. by the door mimic. (TODO probably to start in the discovered state?)*/ + u32 flags; /**< Flags that can be set on the tracked rooms. Used e.g. by the door mimic. (TODO probably to start in + the discovered state?)*/ } RoomMemory; extern RoomMemory* gRoomMemoryPtr; diff --git a/include/roomid.h b/include/roomid.h index 14bc46c9..84a64c39 100644 --- a/include/roomid.h +++ b/include/roomid.h @@ -14,9 +14,9 @@ typedef enum { // AREA_HYRULE_FIELD ROOM_HYRULE_FIELD_WESTERN_WOODS_SOUTH = 0, ROOM_HYRULE_FIELD_SOUTH_HYRULE_FIELD, - ROOM_HYRULE_FIELD_EASTERN_HILLLS_SOUTH, - ROOM_HYRULE_FIELD_EASTERN_HILLLS_CENTER, - ROOM_HYRULE_FIELD_EASTERN_HILLLS_NORTH, + ROOM_HYRULE_FIELD_EASTERN_HILLS_SOUTH, + ROOM_HYRULE_FIELD_EASTERN_HILLS_CENTER, + ROOM_HYRULE_FIELD_EASTERN_HILLS_NORTH, ROOM_HYRULE_FIELD_LON_LON_RANCH, ROOM_HYRULE_FIELD_NORTH_HYRULE_FIELD, ROOM_HYRULE_FIELD_TRILBY_HIGHLANDS, diff --git a/include/save.h b/include/save.h index fc3e9bdd..50c2dc3c 100644 --- a/include/save.h +++ b/include/save.h @@ -44,7 +44,8 @@ typedef struct { /*0x009*/ u8 field_0x9[0x17]; /*0x020*/ u16 field_0x20; /*0x022*/ u8 field_0x22[0x1e]; - /*0x040*/ u32 windcrests; /**< Windcrest flags. bits 0 - 0x10: Visited area of the overworld. Above 0x18: windcrest activated. */ + /*0x040*/ u32 windcrests; /**< Windcrest flags. bits 0 - 0x10: Visited area of the overworld. Above 0x18: windcrest + activated. */ /*0x044*/ u8 filler44[0xC]; /*0x050*/ u32 unk50; /*0x054*/ u8 filler54[0x8]; -- cgit v1.2.3