summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm/non_matching/sub_08054524.inc8
-rw-r--r--include/droptables.h17
-rw-r--r--include/room.h5
-rw-r--r--linker.ld1
-rw-r--r--src/code_0805436C.c25
-rw-r--r--src/droptables.c8
-rw-r--r--src/room.c7
7 files changed, 33 insertions, 38 deletions
diff --git a/asm/non_matching/sub_08054524.inc b/asm/non_matching/sub_08054524.inc
index cb7ea49e..05ac3f4e 100644
--- a/asm/non_matching/sub_08054524.inc
+++ b/asm/non_matching/sub_08054524.inc
@@ -16,9 +16,9 @@ _0805453A:
adds r0, r1, r0
ldrb r1, [r0]
lsls r0, r1, #5
- ldr r1, _0805455C @ =gDroptablesAreas
+ ldr r1, _0805455C @ =gAreaDroptables
adds r0, r0, r1
- ldr r1, _08054560 @ =gCurrentAreaDroptable
+ ldr r1, _08054560 @ =gRoomVars+0x48
movs r2, #0x20
bl MemCopy
pop {pc}
@@ -26,6 +26,6 @@ _0805453A:
_08054550: .4byte gArea
_08054554: .4byte gRoomTransition
_08054558: .4byte gUnk_080FE1C6
-_0805455C: .4byte gDroptablesAreas
-_08054560: .4byte gCurrentAreaDroptable
+_0805455C: .4byte gAreaDroptables
+_08054560: .4byte gRoomVars+0x48
.syntax divided
diff --git a/include/droptables.h b/include/droptables.h
index b659e18e..f05ae94e 100644
--- a/include/droptables.h
+++ b/include/droptables.h
@@ -24,14 +24,15 @@ typedef union {
} Droptable;
static_assert(sizeof(Droptable) == 0x20);
-extern const Droptable gDroptablesEnemies[];
-extern const Droptable gDroptablesAreas[];
-extern const Droptable gDroptablesObjects[];
+extern const Droptable gEnemyDroptables[];
+extern const Droptable gAreaDroptables[];
+extern const Droptable gObjectDroptables[];
extern const Droptable gUnk_0800191C[];
-extern const Droptable gDroptablesModifiers[];
-
-#define gDroptableModifierNone gDroptablesModifiers[0]
-#define gDroptableModifierNoShells gDroptablesModifiers[1]
-#define gDroptableModifierNoKinstones gDroptablesModifiers[2]
+enum {
+ DROPTABLE_NONE,
+ DROPTABLE_NO_SHELLS,
+ DROPTABLE_NO_KINSTONES,
+};
+extern const Droptable gDroptableModifiers[];
#endif // TMC_DROPTABLES_H
diff --git a/include/room.h b/include/room.h
index 1c0c5f82..56d1fa9b 100644
--- a/include/room.h
+++ b/include/room.h
@@ -3,6 +3,7 @@
#include "global.h"
#include "entity.h"
+#include "droptables.h"
enum RoomTransition {
TRANSITION_DEFAULT,
@@ -72,8 +73,8 @@ typedef struct {
/* 0x10 */ u8 unk_10[4];
/* 0x14 */ u32 flags;
/* 0x18 */ u32 unk3;
- /* 0x1c */ u8 filler4[48];
- /* 0x4c */ u8 filler5[28];
+ /* 0x1c */ u8 filler4[44];
+ /* 0x48 */ Droptable currentAreaDroptable;
/* 0x68 */ u32 animFlags;
/* 0x6c */ void* field_0x6c[8];
/* 0x8c */ void* field_0x8c[8];
diff --git a/linker.ld b/linker.ld
index 59c2a67c..0bf73d29 100644
--- a/linker.ld
+++ b/linker.ld
@@ -116,7 +116,6 @@ SECTIONS {
. = 0x000342F8; gUnk_020342F8 = .;
. = 0x00034330; gUnk_02034330 = .;
. = 0x00034350; gRoomVars = .;
- . = 0x00034398; gCurrentAreaDroptable = .;
. = 0x00034480; gUnk_02034480 = .;
. = 0x00034490; gUnk_02034490 = .;
. = 0x00034492; gUnk_02034492 = .;
diff --git a/src/code_0805436C.c b/src/code_0805436C.c
index 0ca1c468..be43c45b 100644
--- a/src/code_0805436C.c
+++ b/src/code_0805436C.c
@@ -46,7 +46,6 @@ extern u8 gUnk_080FE1C6[];
0x8u,
};
*/
-extern Droptable gCurrentAreaDroptable;
extern void (*const gUnk_080FE2A0[])(void);
void ForceEquipItem(u32, u8);
@@ -184,7 +183,7 @@ NONMATCH("asm/non_matching/sub_08054524.inc", void sub_08054524(void)) {
bVar1 = 0;
}
- MemCopy(&gDroptablesAreas[0] + gUnk_080FE1C6[bVar1] * 0x8, &gCurrentAreaDroptable, 0x20);
+ MemCopy(&gAreaDroptables[0] + gUnk_080FE1C6[bVar1] * 0x8, &gRoomVars.currentAreaDroptable, 0x20);
}
END_NONMATCH
@@ -212,11 +211,11 @@ u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) {
Droptable droptable;
r3 = arg1;
if (gRoomVars.field_0x2 != 1) {
- ptr2 = &gDroptableModifierNone;
+ ptr2 = &gDroptableModifiers[DROPTABLE_NONE];
ptr4 = NULL;
switch (r3) {
case 1 ... 12:
- ptr4 = &gDroptablesEnemies[r3];
+ ptr4 = &gEnemyDroptables[r3];
break;
#ifndef EU
case 24:
@@ -232,9 +231,9 @@ u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) {
#ifdef EU
case 24:
#endif
- ptr2 = &gDroptablesObjects[r3 - 16];
+ ptr2 = &gObjectDroptables[r3 - 16];
case 15:
- ptr4 = &gCurrentAreaDroptable;
+ ptr4 = &gRoomVars.currentAreaDroptable;
break;
case 0:
default:
@@ -243,12 +242,12 @@ u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) {
if (ptr4 != 0) {
if ((r1 = gSave.stats.unkB) == 0) {
// nop
- ptr3 = &gDroptableModifierNone;
+ ptr3 = &gDroptableModifiers[DROPTABLE_NONE];
} else {
#ifdef EU
- ptr3 = &gDroptablesEnemies[r1 + 9];
+ ptr3 = &gEnemyDroptables[r1 + 9];
#else
- ptr3 = &gDroptablesEnemies[r1 + 6];
+ ptr3 = &gEnemyDroptables[r1 + 6];
#endif
}
// vector addition, s0 = ptr4 + ptr2 + ptr3
@@ -265,16 +264,16 @@ u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) {
if (gSave.stats.rupees <= 10) {
droptable.s.rupee5 += 1;
}
- ptr2 = &gDroptableModifierNone;
+ ptr2 = &gDroptableModifiers[DROPTABLE_NONE];
r0 = gSave.stats.hasAllFigurines;
- ptr3 = &gDroptableModifierNone;
+ ptr3 = &gDroptableModifiers[DROPTABLE_NONE];
// don't drop shells anymore
if (r0 != 0) {
- ptr2 = &gDroptableModifierNoShells;
+ ptr2 = &gDroptableModifiers[DROPTABLE_NO_SHELLS];
}
// don't drop kinstones anymore
if (gSave.didAllFusions != 0) {
- ptr3 = &gDroptableModifierNoKinstones;
+ ptr3 = &gDroptableModifiers[DROPTABLE_NO_KINSTONES];
}
// vector addition, s0 = s0 + ptr2 + ptr3
// resulting values are clamped to be >= 0
diff --git a/src/droptables.c b/src/droptables.c
index cad1e9ec..d239a80d 100644
--- a/src/droptables.c
+++ b/src/droptables.c
@@ -1,7 +1,7 @@
#include "global.h"
#include "droptables.h"
-const Droptable gDroptablesEnemies[] = {
+const Droptable gEnemyDroptables[] = {
[0] = { {
.none = -999,
.rupee1 = -999,
@@ -328,7 +328,7 @@ const Droptable gDroptablesEnemies[] = {
} },
};
-const Droptable gDroptablesAreas[] = {
+const Droptable gAreaDroptables[] = {
[0] = { {
.none = 920,
.rupee1 = 15,
@@ -676,7 +676,7 @@ const Droptable gDroptablesAreas[] = {
.none5 = 0,
} },
};
-const Droptable gDroptablesObjects[] = {
+const Droptable gObjectDroptables[] = {
[0] = { {
.none = 0,
.rupee1 = 10,
@@ -1065,7 +1065,7 @@ const Droptable gUnk_0800191C[] = {
};
// special treatment for shells and kinstones after finishing figurines/fusions
-const Droptable gDroptablesModifiers[] = {
+const Droptable gDroptableModifiers[] = {
// nop
{ {
.none = 0,
diff --git a/src/room.c b/src/room.c
index 59fd4c6f..b12dbea4 100644
--- a/src/room.c
+++ b/src/room.c
@@ -39,11 +39,6 @@ static void LoadDestructibleTile(TileEntity*);
static void LoadGrassDropTile(TileEntity*);
static void LoadLocationTile(TileEntity*);
-typedef struct {
- u8 filler[0x20];
-} VarStruct;
-extern VarStruct gDroptablesAreas[];
-
void LoadRoomEntityList(EntityData* listPtr) {
if (listPtr != NULL) {
while (listPtr->kind != 0xFF) {
@@ -302,7 +297,7 @@ void LoadRoomTileEntities(TileEntity* list) {
}
static void LoadGrassDropTile(TileEntity* tile) {
- MemCopy(&gDroptablesAreas[tile->_1], &gRoomVars.filler4[44], 0x20);
+ MemCopy(&gAreaDroptables[tile->_1], &gRoomVars.currentAreaDroptable, 0x20);
}
static void LoadLocationTile(TileEntity* tile) {