summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornotyourav <65437533+notyourav@users.noreply.github.com>2023-01-10 15:14:12 -0800
committerGitHub <noreply@github.com>2023-01-10 15:14:12 -0800
commit58dff2ea06e89ef72634fc51e6f55fa515d894f7 (patch)
tree0e73717420bd3faf800202a68ac33ac3ad77d411 /src
parent19c9c2b54b0bae2848c539c8a98f52c00b4a1154 (diff)
parentf81167f6d7341911d0a7a21b645fa698ea23fd2a (diff)
Merge pull request #596 from nonmatch/patch-66
Diffstat (limited to 'src')
-rw-r--r--src/common.c87
1 files changed, 86 insertions, 1 deletions
diff --git a/src/common.c b/src/common.c
index 909dd944..a5f8d2d7 100644
--- a/src/common.c
+++ b/src/common.c
@@ -85,6 +85,24 @@ u32 sub_0801DF60(u32 a1, u8* p);
u32 sub_0801DF78(u32 a1, u32 a2);
void sub_0801DF28(u32 x, u32 y, s32 color);
+extern void* GetRoomProperty(u32, u32, u32);
+
+enum DungeonMapObjectTypes {
+ DMO_TYPE_NONE,
+ DMO_TYPE_PLAYER,
+ DMO_TYPE_CHEST,
+ DMO_TYPE_ENTRY,
+ DMO_TYPE_BOSS,
+};
+
+typedef struct {
+ u8 type; /**< @see DungeonMapObjectTypes */
+ u8 x;
+ u8 y;
+} PACKED DungeonMapObject;
+
+// More like PrepareTileEntitesForDungeonMap or so
+
u32 DecToHex(u32 value) {
u32 result;
register u32 r1 asm("r1");
@@ -406,7 +424,74 @@ u32 sub_0801DB94(void) {
return gRoomTransition.player_status.dungeon_map_y >> 11;
}
-ASM_FUNC("asm/non_matching/common/DrawDungeonMap.inc", void DrawDungeonMap(u32 floor, void* data, u32 size));
+void DrawDungeonMap(u32 floor, DungeonMapObject* specialData, u32 size) {
+ DungeonLayout* floorMapData;
+ TileEntity* tileEntity;
+ u32 flagBankOffset;
+ RoomHeader* roomHeader;
+ s32 tmp1;
+ s32 tmp3;
+
+ MemClear(specialData, size);
+ specialData->type = DMO_TYPE_PLAYER;
+ specialData->x = (gRoomTransition.player_status.dungeon_map_x >> 4) & 0x7f;
+ specialData->y = (gRoomTransition.player_status.dungeon_map_y >> 4) & 0x7f;
+ specialData++;
+ floorMapData = (DungeonLayout*)gUnk_080C9C50[gArea.dungeon_idx][floor];
+ while (floorMapData->area != 0) {
+ tileEntity = (TileEntity*)GetRoomProperty(floorMapData->area, floorMapData->room, 3);
+ if (tileEntity == NULL) {
+ floorMapData++;
+ } else {
+ flagBankOffset = sub_0801DF10(floorMapData);
+ if (HasDungeonBigKey()) {
+ while (tileEntity->type != 0) {
+ switch (tileEntity->type) {
+ case SMALL_CHEST:
+ case BIG_CHEST:
+ if (!CheckLocalFlagByBank(flagBankOffset, tileEntity->localFlag)) {
+ roomHeader = gAreaRoomHeaders[floorMapData->area] + floorMapData->room;
+ specialData->type = DMO_TYPE_CHEST;
+ if (tileEntity->type == SMALL_CHEST) {
+ specialData->x =
+ ((((tileEntity->tilePos << 4 & 0x3f0) | 8) + (roomHeader->map_x % 0x800)) >> 4);
+ specialData->y =
+ ((((tileEntity->tilePos >> 2 & 0x3f0) | 8) + (roomHeader->map_y % 0x800)) >> 4);
+ } else {
+ specialData->x = (((roomHeader->map_x % 0x800) + tileEntity->tilePos) >> 4);
+ specialData->y = (((roomHeader->map_y % 0x800) + (*(u16*)&tileEntity->_6)) >> 4);
+ }
+ specialData++;
+ }
+ break;
+ }
+ tileEntity++;
+ }
+ }
+ if ((HasDungeonBigKey() && ((floorMapData->unk_2 & 2) != 0)) && (!CheckGlobalFlag(gArea.dungeon_idx + 1))) {
+ roomHeader = gAreaRoomHeaders[floorMapData->area] + floorMapData->room;
+ specialData->type = DMO_TYPE_BOSS;
+ tmp1 = ((roomHeader->pixel_width / 2) + roomHeader->map_x) / 16;
+ if (tmp1 < 0) {
+ tmp1 = tmp1 + 0x7f;
+ }
+ specialData->x = tmp1 + (tmp1 / 128) * -128;
+ tmp3 = ((roomHeader->pixel_height / 2) + roomHeader->map_y) / 16;
+ specialData->y = tmp3 + (tmp3 / 128) * -128;
+ specialData++;
+ }
+ if (floorMapData->area == gRoomTransition.player_status.dungeon_area &&
+ floorMapData->room == gRoomTransition.player_status.dungeon_room) {
+ specialData->type = DMO_TYPE_ENTRY;
+ // TODO rename dungeon_x and dungeon_y to dungeonEntryX/Y?
+ specialData->x = ((u16)gRoomTransition.player_status.dungeon_x >> 4) & 0x7f;
+ specialData->y = ((u16)gRoomTransition.player_status.dungeon_y >> 4) & 0x7f;
+ specialData++;
+ }
+ floorMapData++;
+ }
+ }
+}
void sub_0801DD58(u32 area, u32 room) {
RoomHeader* hdr = gAreaRoomHeaders[area] + room;