move and use enums

This commit is contained in:
robojumper
2025-06-07 23:03:20 +02:00
parent 58819744c4
commit fbc58cd78a
9 changed files with 139 additions and 72 deletions
+1 -1
View File
@@ -20948,7 +20948,7 @@ fn_80382400 = .text:0x80382400; // type:function size:0xC
fn_80382410 = .text:0x80382410; // type:function size:0xC0
fn_803824D0 = .text:0x803824D0; // type:function size:0x24
fn_80382500 = .text:0x80382500; // type:function size:0x90
fn_80382590 = .text:0x80382590; // type:function size:0xB0
getSourceCategoryForSourceType__15dSndSourceMgr_cFlPCc = .text:0x80382590; // type:function size:0xB0
soundForActorInitRelated_80382640 = .text:0x80382640; // type:function size:0xFD8
fn_80383620 = .text:0x80383620; // type:function size:0x94
fn_803836C0 = .text:0x803836C0; // type:function size:0x98
+2 -2
View File
@@ -66,7 +66,7 @@ public:
// the vtable, so the order is not certain. May have to reorder for weak
// function order.
virtual s32 getCategory() const override {
return field_0x0FC;
return mSourceCategory;
}
virtual const nw4r::math::VEC3 &getListenerPosition() const override;
@@ -90,7 +90,7 @@ private:
/* 0x0F0 */ const char *mpName;
/* 0x0F4 */ UNKWORD field_0x0F4;
/* 0x0F8 */ dAcBase_c *mpPlayer;
/* 0x0FC */ u8 field_0x0FC;
/* 0x0FC */ u8 mSourceCategory;
/* 0x0FD */ u8 mSourceType;
/* 0x0FE */ u8 field_0x0FE;
/* 0x0FF */ u8 field_0x0FF;
+74
View File
@@ -0,0 +1,74 @@
#ifndef D_SND_SOURCE_ENUMS_H
#define D_SND_SOURCE_ENUMS_H
// TODO: Expand when we figure out what the other entries have in common
enum SoundSourceType_e {
// 0-1: Player (0)
SND_SOURCE_PLAYER = 0,
SND_SOURCE_PLAYER_HEAD = 1,
// 2-9: Equipment (1)
SND_SOURCE_NET = 2,
SND_SOURCE_BLADE = 3,
SND_SOURCE_SHIELD = 4,
SND_SOURCE_WHIP = 5,
SND_SOURCE_BOOMERANG = 6,
SND_SOURCE_ARROW = 7,
SND_SOURCE_BOMB = 8,
SND_SOURCE_HOOKSHOT = 9,
// 10-31: Enemy? (2)
SND_SOURCE_ENEMY_10 = 10,
SND_SOURCE_BIGBOSS = 20,
SND_SOURCE_GIRAHUMU_3 = 24,
SND_SOURCE_BULLET = 29,
SND_SOURCE_ENEMY_31 = 31,
// 32-42: Object? (3)
SND_SOURCE_OBJECT = 32,
SND_SOURCE_BAMBOO = 34,
SND_SOURCE_ITEM = 35,
SND_SOURCE_TERRY_SHOP = 36,
SND_SOURCE_TIME_STONE = 37,
SND_SOURCE_CLEF = 38,
SND_SOURCE_SHUTTER = 39,
SND_SOURCE_OBJECT_42 = 42,
// 43-52: Npc (4)
SND_SOURCE_NPC_43 = 43,
SND_SOURCE_KENSEI = 44,
SND_SOURCE_PLAYER_BIRD = 45,
SND_SOURCE_NPC_48 = 48,
SND_SOURCE_INSECT = 49,
SND_SOURCE_NPC_NRM = 51,
SND_SOURCE_NPC_DRAGON = 52,
// 53: TagSound (5)
SND_SOURCE_TG_SOUND = 53,
// 54-57: Harp Related (6)
SND_SOURCE_54 = 54,
SND_SOURCE_OBJECT_WARP = 55,
SND_SOURCE_SW_HARP = 56,
SND_SOURCE_57 = 57,
// 58: ? (7)
SND_SOURCE_58 = 58,
// 59: ? (9)
SND_SOURCE_59 = 59,
};
enum SoundSourceCategory_e {
SND_SOURCE_CATEGORY_PLAYER = 0,
SND_SOURCE_CATEGORY_EQUIPMENT = 1,
SND_SOURCE_CATEGORY_ENEMY = 2,
SND_SOURCE_CATEGORY_OBJECT = 3,
SND_SOURCE_CATEGORY_NPC = 4,
SND_SOURCE_CATEGORY_TG_SOUND = 5,
SND_SOURCE_CATEGORY_6 = 6,
SND_SOURCE_CATEGORY_7 = 7,
SND_SOURCE_CATEGORY_9 = 9,
};
#endif
+1
View File
@@ -33,6 +33,7 @@ public:
void unregisterSource(dSoundSource_c *source);
void playFlowSound(u32 id);
static s32 getSourceCategoryForSourceType(s32 sourceType, const char *name);
private:
static bool isCertainEnemyType(dSoundSource_c *source);
-49
View File
@@ -3,55 +3,6 @@
#include "common.h"
// TODO: Expand when we figure out what the other entries have in common
enum SoundSourceType_e {
// 0-1: Player (0)
SND_SOURCE_PLAYER = 0,
SND_SOURCE_PLAYER_HEAD = 1,
// 2-9: Equipment (1)
SND_SOURCE_NET = 2,
SND_SOURCE_BLADE = 3,
SND_SOURCE_SHIELD = 4,
SND_SOURCE_WHIP = 5,
SND_SOURCE_BOOMERANG = 6,
SND_SOURCE_ARROW = 7,
SND_SOURCE_BOMB = 8,
SND_SOURCE_HOOKSHOT = 9,
// 10-31: Enemy? (2)
SND_SOURCE_BIGBOSS = 20,
SND_SOURCE_GIRAHUMU_3 = 24,
SND_SOURCE_BULLET = 29,
// 32-42: Object? (3)
SND_SOURCE_OBJECT = 32,
SND_SOURCE_BAMBOO = 34,
SND_SOURCE_ITEM = 35,
SND_SOURCE_TERRY_SHOP = 36,
SND_SOURCE_TIME_STONE = 37,
SND_SOURCE_CLEF = 38,
SND_SOURCE_SHUTTER = 39,
// 43-52: Npc (4)
SND_SOURCE_KENSEI = 44,
SND_SOURCE_PLAYER_BIRD = 45,
SND_SOURCE_INSECT = 49,
SND_SOURCE_NPC_NRM = 51,
SND_SOURCE_NPC_DRAGON = 52,
// 53: TagSound (5)
SND_SOURCE_TG_SOUND = 53,
// 54-57: Harp Related (6)
SND_SOURCE_OBJECT_WARP = 55,
SND_SOURCE_SW_HARP = 56,
// 58: ? (7)
// 59: ? (9)
};
/**
* profileId and profileId2 are always the same.
*/
+1 -3
View File
@@ -11,8 +11,6 @@
#include "nw4r/ut/ut_list.h"
#include "sized_string.h"
extern "C" u8 fn_80382590(u8, const char*);
struct d_snd_mgr_unk_6_sinit {
d_snd_mgr_unk_6_sinit() : field_0x00(0), field_0x04(0.0f) {}
@@ -45,7 +43,7 @@ dSoundSource_c::dSoundSource_c(u8 sourceType, dAcBase_c *player, const char *nam
field_0x154(0),
field_0x158(-1),
field_0x15A(-1) {
field_0x0FC = fn_80382590(sourceType, name);
mSourceCategory = dSndSourceMgr_c::getSourceCategoryForSourceType(sourceType, name);
// TODO: Offsetof
nw4r::ut::List_Init(&field_0x110, 0xEC);
nw4r::ut::List_Init(&field_0x120, 0x04);
+7 -7
View File
@@ -3,6 +3,7 @@
#include "common.h"
#include "d/snd/d_snd_source.h"
#include "d/snd/d_snd_source_enums.h"
#include "nw4r/ut/ut_list.h"
#include <cmath>
@@ -10,18 +11,17 @@
extern "C" bool isInStage(const char *stageName);
void dSndSourceGroup_c::set(s32 sourceType, const char *name) {
// TODO enums
resetSoundSourceParam();
bool assignedParam = false;
switch (mSourceCategory) {
case 0: {
case SND_SOURCE_CATEGORY_PLAYER: {
assignedParam = true;
mParam.field_0x10 = INFINITY;
break;
}
case 1:
if (sourceType == 7) {
case SND_SOURCE_CATEGORY_EQUIPMENT:
if (sourceType == SND_SOURCE_ARROW) {
assignedParam = true;
mParam.field_0x00 = 1500.0f;
mParam.field_0x10 = INFINITY;
@@ -29,7 +29,7 @@ void dSndSourceGroup_c::set(s32 sourceType, const char *name) {
break;
}
if (!assignedParam && (sourceType == 44 || sourceType == 58)) {
if (!assignedParam && (sourceType == SND_SOURCE_KENSEI || sourceType == SND_SOURCE_58)) {
assignedParam = true;
mParam.field_0x10 = INFINITY;
}
@@ -40,13 +40,13 @@ void dSndSourceGroup_c::set(s32 sourceType, const char *name) {
if (!assignedParam) {
switch (sourceType) {
case 51: {
case SND_SOURCE_NPC_NRM: {
mParam.field_0x00 = 300.0f;
mParam.field_0x04 = 800.0;
mParam.field_0x10 = 2200.0;
break;
}
case 48: {
case SND_SOURCE_NPC_48: {
if (isInStage("F401")) {
mParam.field_0x00 = 500.0f;
mParam.field_0x04 = 4000.0;
+52 -10
View File
@@ -2,10 +2,53 @@
#include "common.h"
#include "d/snd/d_snd_source.h"
#include "d/snd/d_snd_source_enums.h"
#include "nw4r/ut/ut_list.h"
#include <cmath>
s32 dSndSourceMgr_c::getSourceCategoryForSourceType(s32 sourceType, const char *name) {
// This might be a full-on switch statement but I don't want to write out
// all the unknown entries yet and this matches anyway
if (sourceType >= SND_SOURCE_PLAYER && sourceType <= SND_SOURCE_PLAYER_HEAD) {
return SND_SOURCE_CATEGORY_PLAYER;
}
if (sourceType >= SND_SOURCE_NET && sourceType <= SND_SOURCE_HOOKSHOT) {
return SND_SOURCE_CATEGORY_EQUIPMENT;
}
if (sourceType >= SND_SOURCE_ENEMY_10 && sourceType <= SND_SOURCE_ENEMY_31) {
return SND_SOURCE_CATEGORY_ENEMY;
}
if (sourceType >= SND_SOURCE_OBJECT && sourceType <= SND_SOURCE_OBJECT_42) {
return SND_SOURCE_CATEGORY_OBJECT;
}
if (sourceType >= SND_SOURCE_NPC_43 && sourceType <= SND_SOURCE_NPC_DRAGON) {
return SND_SOURCE_CATEGORY_NPC;
}
if (sourceType == SND_SOURCE_TG_SOUND) {
return SND_SOURCE_CATEGORY_TG_SOUND;
}
if (sourceType >= SND_SOURCE_54 && sourceType <= SND_SOURCE_57) {
return SND_SOURCE_CATEGORY_6;
}
switch (sourceType) {
case SND_SOURCE_58:
return SND_SOURCE_CATEGORY_7;
case SND_SOURCE_59:
return SND_SOURCE_CATEGORY_9;
default:
return -1;
}
}
SND_DISPOSER_DEFINE(dSndSourceMgr_c);
dSndSourceMgr_c::dSndSourceMgr_c()
@@ -43,38 +86,37 @@ dSndSourceMgr_c::dSndSourceMgr_c()
void dSndSourceMgr_c::registerSource(dSoundSource_c *source) {
if (source != nullptr) {
nw4r::ut::List_Append(&mAllSources, source);
// TODO enums
switch (source->getCategory()) {
case 0: {
if (source->getActorType() == 0 && mpPlayerSource == nullptr) {
case SND_SOURCE_CATEGORY_PLAYER: {
if (source->getActorType() == SND_SOURCE_PLAYER && mpPlayerSource == nullptr) {
mpPlayerSource = source;
}
break;
}
case 1: {
if (source->getActorType() == 6) {
case SND_SOURCE_CATEGORY_EQUIPMENT: {
if (source->getActorType() == SND_SOURCE_BOOMERANG) {
mpBoomerangSource = source;
}
break;
}
case 2: {
case SND_SOURCE_CATEGORY_ENEMY: {
if (isCertainEnemyType(source)) {
nw4r::ut::List_Append(&field_0x3848, source);
}
break;
}
case 6: {
case SND_SOURCE_CATEGORY_6: {
nw4r::ut::List_Append(&field_0x3854, source);
break;
}
case 3: {
case SND_SOURCE_CATEGORY_OBJECT: {
if (source->isName("TBoat") && mpTBoatSource == nullptr) {
mpTBoatSource = source;
}
break;
}
case 4: {
if (source->getActorType() == 44) {
case SND_SOURCE_CATEGORY_NPC: {
if (source->getActorType() == SND_SOURCE_KENSEI) {
mpKenseiSource = source;
}
break;
+1
View File
@@ -1,6 +1,7 @@
#include "toBeSorted/actor_info.h"
#include "common.h"
#include "d/snd/d_snd_source_enums.h"
#include "f/f_profile_name.h"
#include <cstring>