Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
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
2 changes: 1 addition & 1 deletion config/SOUE01/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21372,7 +21372,7 @@ __ct__23dSndSourceHarpRelated_cFlP9dAcBase_cPCcP17dSndSourceGroup_c = .text:0x80
__dt__23dSndSourceHarpRelated_cFv = .text:0x80390B30; // type:function size:0xA8
postCalc__23dSndSourceHarpRelated_cFv = .text:0x80390BE0; // type:function size:0x2F8
setPause__23dSndSourceHarpRelated_cFbi = .text:0x80390EE0; // type:function size:0xFC
fn_80390FE0 = .text:0x80390FE0; // type:function size:0x5C
harpSoundRelated__23dSndSourceHarpRelated_cFv = .text:0x80390FE0; // type:function size:0x5C
d_s_harp_vt_0x1F0__23dSndSourceHarpRelated_cFv = .text:0x80391040; // type:function size:0xA8
fn_803910F0 = .text:0x803910F0; // type:function size:0x7C
fn_80391170 = .text:0x80391170; // type:function size:0xA0
Expand Down
2 changes: 1 addition & 1 deletion include/d/snd/d_snd_harp_song_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class dSndHarpSongMgr_c {

void activate();
void deactivate();
bool isPlayingHarpRelated();

nw4r::snd::SoundHandle &getFiSingHandle() {
return mFiSingHandle;
Expand All @@ -32,7 +33,6 @@ class dSndHarpSongMgr_c {
void resetFloatArr1();
void resetFloatArr2();
bool isContinuousStrumming();
bool isPlayingHarpRelated();
bool fn_80381150();

/* 0x010 */ u8 field_0x010;
Expand Down
1 change: 1 addition & 0 deletions include/d/snd/d_snd_source_harp_related.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class dSndSourceHarpRelated_c : public dSoundSource_c {

/* 0x18C */ virtual void postCalc() override;
/* 0x1D0 */ virtual void setPause(bool flag, int fadeFrames) override;
virtual bool harpSoundRelated(); // fn_80390FE0

/* 0x1EC */ virtual UNKWORD d_s_harp_vt_0x1EC() const {
return 0;
Expand Down
20 changes: 17 additions & 3 deletions include/d/t/d_t_harp.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#ifndef D_T_HARP_H
#define D_T_HARP_H

#include "d/a/d_a_base.h"
#include "common.h"
#include "d/snd/d_snd_source_harp_related.h"
#include "d/t/d_tg.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.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,6 +15,19 @@ class dTgHarp_c : public dAcBase_c {

private:
/* 0x??? */ STATE_MGR_DECLARE(dTgHarp_c);
/* 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
106 changes: 105 additions & 1 deletion src/REL/d/t/d_t_harp.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +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);

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;
}

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

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() {}
9 changes: 9 additions & 0 deletions src/d/snd/d_snd_source_harp_related.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "d/snd/d_snd_source_harp_related.h"

#include "d/snd/d_snd_harp_song_mgr.h"
#include "d/snd/d_snd_source.h"

dSndSourceHarpRelated_c::dSndSourceHarpRelated_c(
Expand All @@ -20,3 +21,11 @@ void dSndSourceHarpRelated_c::postCalc() {
void dSndSourceHarpRelated_c::setPause(bool flag, int fadeFrames) {
// TODO
}

bool dSndSourceHarpRelated_c::harpSoundRelated() {
bool isHarpSoundRelated = false;
if (checkFlag(1) && dSndHarpSongMgr_c::sInstance->isPlayingHarpRelated()) {
isHarpSoundRelated = true;
}
return isHarpSoundRelated;
}
Loading