Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: refactor harp actor to new actor base
  • Loading branch information
Asiern committed Nov 24, 2025
commit 5b6f0df1028c98799bc4c9e39c78e41ab9866512
18 changes: 9 additions & 9 deletions config/SOUE01/rels/d_t_harpNP/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ __dt__21sFState_c<9dTgHarp_c>Fv = .text:0x00000200; // type:function size:0x58
__dt__24sFStateFct_c<9dTgHarp_c>Fv = .text:0x00000260; // type:function size:0x6C
__dt__77sStateMgr_c<9dTgHarp_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x000002D0; // type:function size:0xA0
__dt__47sFStateMgr_c<9dTgHarp_c,20sStateMethodUsr_FI_c>Fv = .text:0x00000370; // type:function size:0xA4
fn_536_420 = .text:0x00000420; // type:function size:0x8
fn_536_430 = .text:0x00000430; // type:function size:0xEC
createHeap__9dTgHarp_cFv = .text:0x00000420; // type:function size:0x8
create__9dTgHarp_cFv = .text:0x00000430; // type:function size:0xEC
changeState__77sStateMgr_c<9dTgHarp_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x00000520; // type:function size:0x10
fn_536_530 = .text:0x00000530; // type:function size:0x8
fn_536_540 = .text:0x00000540; // type:function size:0x30
doDelete__9dTgHarp_cFv = .text:0x00000530; // type:function size:0x8
actorExecute__9dTgHarp_cFv = .text:0x00000540; // type:function size:0x30
executeState__77sStateMgr_c<9dTgHarp_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000570; // type:function size:0x10
fn_536_580 = .text:0x00000580; // type:function size:0x8
draw__9dTgHarp_cFv = .text:0x00000580; // type:function size:0x8
initializeState_Wait__9dTgHarp_cFv = .text:0x00000590; // type:function size:0x4
executeState_Wait__9dTgHarp_cFv = .text:0x000005A0; // type:function size:0xE8
fn_536_690 = .text:0x00000690; // type:function size:0x1C
calcTimer<Us>__4sLibFPUs_Us = .text:0x00000690; // type:function size:0x1C
finalizeState_Wait__9dTgHarp_cFv = .text:0x000006B0; // type:function size:0x4
fn_536_6C0 = .text:0x000006C0; // type:function size:0x60
fn_536_720 = .text:0x00000720; // type:function size:0x84
fn_536_7B0 = .text:0x000007B0; // type:function size:0xC8
fn_536_6C0__9dTgHarp_cFv = .text:0x000006C0; // type:function size:0x60
fn_536_720__9dTgHarp_cFP16dSoundSourceIf_c = .text:0x00000720; // type:function size:0x84
__dt__9dTgHarp_cFv = .text:0x000007B0; // type:function size:0xC8
getStateID__77sStateMgr_c<9dTgHarp_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000880; // type:function size:0x10
build__24sFStateFct_c<9dTgHarp_c>FRC12sStateIDIf_c = .text:0x00000890; // type:function size:0x60
dispose__24sFStateFct_c<9dTgHarp_c>FRP10sStateIf_c = .text:0x000008F0; // type:function size:0xC
Expand Down
21 changes: 16 additions & 5 deletions include/d/t/d_t_harp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#define D_T_HARP_H

#include "common.h"
#include "d/a/d_a_base.h"
#include "d/snd/d_snd_source_harp_related.h"
#include "d/t/d_tg.h"
#include "s/s_State.hpp"

class dTgHarp_c : public dAcBase_c {
class dTgHarp_c : public dTg_c {
public:
dTgHarp_c() : mStateMgr(*this, sStateID::null) {}
virtual ~dTgHarp_c() {}
Expand All @@ -14,9 +15,19 @@ class dTgHarp_c : public dAcBase_c {

private:
/* 0x??? */ STATE_MGR_DECLARE(dTgHarp_c);
s16 fn_536_420();
s16 fn_536_530();
s16 fn_536_540();
/* 0x138 */ byte_t field_0x138;
/* 0x139 */ byte_t field_0x139;
/* 0x13A */ s16 field_0x13a;
/* 0x13C */ u16 mTimer_0x13c;
/* 0x13E */ byte_t sceneflag_0x13e;

virtual bool createHeap() override; // fn_536_420
virtual int create() override; // fn_536_430
virtual int doDelete() override; // fn_536_530
virtual int actorExecute() override; // fn_536_540
virtual int draw() override; // fn_536_580
void fn_536_6C0(); // fn_536_6C0
void fn_536_720(dSndSourceHarpRelated_c *soundSource);
};

#endif
99 changes: 95 additions & 4 deletions src/REL/d/t/d_t_harp.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,113 @@
#include "d/t/d_t_harp.h"

#include "common.h"
#include "d/a/d_a_item.h"
#include "d/a/d_a_itembase.h"
#include "d/flag/sceneflag_manager.h"
#include "d/snd/d_snd_source_harp_related.h"
#include "d/snd/d_snd_source_if.h"
#include "s/s_Math.h"

SPECIAL_ACTOR_PROFILE(HARP_TAG, dTgHarp_c, fProfile::HARP_TAG, 0x1A4, 0, 0);

STATE_DEFINE(dTgHarp_c, Wait);

s16 dTgHarp_c::fn_536_420() {
bool dTgHarp_c::createHeap() {
return true;
}

int dTgHarp_c::create() {
u32 tmp = (mParams >> 8) & 0xF;
if (tmp != 0xF) {
field_0x13a = tmp * 0x1E;
} else {
field_0x13a = 0x96;
}

if (initAllocatorWork1Heap(-1, const_cast<char *>("dTgHarp_c::m_allocator"), 0x20) == 0) {
return 2;
}

fn_536_6C0();
mTimer_0x13c = field_0x13a;
byte_t lowByte = mParams & 0xFF;
sceneflag_0x13e = lowByte;

if (lowByte < 0xFF) {
bool flagSet = SceneflagManager::sInstance->checkFlag(mRoomID, mParams & 0xFF);

if (flagSet) {
return 2;
}
}
mStateMgr.changeState(StateID_Wait);
return 1;
}

s16 dTgHarp_c::fn_536_530() {
int dTgHarp_c::doDelete() {
return 1;
}

s16 dTgHarp_c::fn_536_540() {
int dTgHarp_c::actorExecute() {
mStateMgr.executeState();
return 1;
}

int dTgHarp_c::draw() {
return 1;
}

void dTgHarp_c::fn_536_6C0() {
// TODO: soundSource should be of type dSndSourceHarpRelated_c*
dSoundSourceIf_c *soundSource = getSoundSource();
if (soundSource != nullptr) {
soundSource->offFlag(2);
// fn_536_720(soundSource);
}
}

void dTgHarp_c::fn_536_720(dSndSourceHarpRelated_c *soundSource) {
if (field_0x138 == 0 && dAcItem_c::checkFlag(ITEM_GODDESS_HARP)) {
soundSource->onFlag(2);
soundSource->d_s_harp_vt_0x1F0(); // Offset to 0x1F0 is off by 4 bytes
field_0x138 = 1;
}
}

// Actual implementation and definition is located in d/snd/d_snd_source_harp_related.cpp
bool harpSoundRelated() {
return true;
}

void dTgHarp_c::initializeState_Wait() {}
void dTgHarp_c::executeState_Wait() {}

void dTgHarp_c::executeState_Wait() {
// TODO: soundSource should be of type dSndSourceHarpRelated_c*
dSoundSourceIf_c *soundSource = getSoundSource();
if (soundSource != nullptr) {
return;
}

// fn_536_720(soundSource);

if (isWithinPlayerRadius(mScale.x)) {
// TODO: call harpSoundRelated with from d/snd/d_snd_source_harp_related.cpp
if (harpSoundRelated() && !sLib::calcTimer(&mTimer_0x13c)) {
if (sceneflag_0x13e < 0xff) {
bool flagStatus = SceneflagManager::sInstance->checkFlag(mRoomID, sceneflag_0x13e);

if (!flagStatus) {
SceneflagManager::sInstance->setFlag(mRoomID, sceneflag_0x13e);
}
}

deleteRequest();
}

} else {
field_0x13a = 0x96;
mTimer_0x13c = 0x96;
}
}

void dTgHarp_c::finalizeState_Wait() {}
Loading