Skip to content

(WIP) d_t_defeat_boss#299

Draft
coleslaw456 wants to merge 1 commit intozeldaret:mainfrom
coleslaw456:main
Draft

(WIP) d_t_defeat_boss#299
coleslaw456 wants to merge 1 commit intozeldaret:mainfrom
coleslaw456:main

Conversation

@coleslaw456
Copy link

No description provided.

@decomp-dev
Copy link

decomp-dev bot commented Feb 17, 2026

Report for SOUE01 (79bc8e9 - a6eeeed)

📈 Matched code: 24.04% (+0.00%, +136 bytes)

✅ 6 new matches
Unit Item Bytes Before After
d_t_defeat_bossNP/REL/d/t/d_t_defeat_boss dTgDefeatBoss_c::fn_494_C0() +12 0.00% 100.00%
d_t_defeat_bossNP/REL/d/t/d_t_defeat_boss dTgDefeatBoss_c::getSceneflag() +12 0.00% 100.00%
d_t_defeat_bossNP/REL/d/t/d_t_defeat_boss dTgDefeatBoss_c::fn_494_360() +12 0.00% 100.00%
d_t_defeat_bossNP/REL/d/t/d_t_defeat_boss dTgDefeatBoss_c::getStoryflag() +12 0.00% 100.00%
d_t_defeat_bossNP/REL/d/t/d_t_defeat_boss dTgDefeatBoss_c::fn_494_380() +12 0.00% 100.00%
d_t_defeat_bossNP/REL/d/t/d_t_defeat_boss dTgDefeatBoss_c_classInit() +1 99.95% 100.00%
📈 4 improvements in unmatched items
Unit Item Bytes Before After
d_t_defeat_bossNP/REL/d/t/d_t_defeat_boss dTgDefeatBoss_c::update() +280 0.00% 97.50%
d_t_defeat_bossNP/REL/d/t/d_t_defeat_boss dTgDefeatBoss_c::init() +167 0.00% 82.18%
d_t_defeat_bossNP/REL/d/t/d_t_defeat_boss dTgDefeatBoss_c::fn_494_D0() +122 0.00% 93.00%
d_t_defeat_bossNP/REL/d/t/d_t_defeat_boss .data +109 12.12% 94.62%

Copy link
Collaborator

@elijah-thomas774 elijah-thomas774 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let me know if you have questions regarding the changes.
Overall copy pasting ghidra output is Ok to start, but Ghidra acts like c++ is stil c.

Many cases the temparies can be removed and the casting can be ignored.

u16 fn_494_360();
u16 getStoryflag();
u16 fn_494_380();
void fn_494_C0();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment in source file

Suggested change
void fn_494_C0();
static void getDungeonFlagIndex(u32 &outFlagIdx);

u16 getStoryflag();
u16 fn_494_380();
void fn_494_C0();
bool fn_494_D0();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When seeing getCounterOrFlag and it is an immediate comparision, it usually means its checking if its active.

Suggested change
bool fn_494_D0();
bool checkDungeonFlag();


}

u16 dTgDefeatBoss_c::getStoryflag() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u32 return type effects the caller

Suggested change
u16 dTgDefeatBoss_c::getStoryflag() {
u32 dTgDefeatBoss_c::getStoryflag() {

Comment on lines +29 to +65
bool dTgDefeatBoss_c::init() {

u16 uVar1;
u16 uVar2;
u16 iVar3;
u16 bVar4;
u32 uVar5;
u16 counterIdx;

bVar4 = fn_494_D0();
if (bVar4) {
uVar1 = 2;
}
else {
uVar5 = fn_494_360();
var8_1 = uVar5;
uVar2 = getSceneflag();
if ((uVar2 & 0xffff) > 0xfe) {
var8_1 = 0xff;
}
uVar5 = fn_494_380();
var8_2 = uVar5;
counterIdx = getStoryflag();
iVar3 = StoryflagManager::sInstance->checkFlagValid(counterIdx);
if (iVar3 == 0) {
var8_2 = 0xff;
}
if (var8_1 == -1 && var8_2 == -1) {
uVar1 = 2;
}
else {
uVar1 = 1;
}
}
return uVar1;

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function can change to this due to:
1: vtable placement
2: Since its one of the common pack functions, the return enum is known
3: Many of the temporaries can be removed.
4: the names of the unknown variables can be inferred due to the actorExecute function switching the set/unset

Suggested change
bool dTgDefeatBoss_c::init() {
u16 uVar1;
u16 uVar2;
u16 iVar3;
u16 bVar4;
u32 uVar5;
u16 counterIdx;
bVar4 = fn_494_D0();
if (bVar4) {
uVar1 = 2;
}
else {
uVar5 = fn_494_360();
var8_1 = uVar5;
uVar2 = getSceneflag();
if ((uVar2 & 0xffff) > 0xfe) {
var8_1 = 0xff;
}
uVar5 = fn_494_380();
var8_2 = uVar5;
counterIdx = getStoryflag();
iVar3 = StoryflagManager::sInstance->checkFlagValid(counterIdx);
if (iVar3 == 0) {
var8_2 = 0xff;
}
if (var8_1 == -1 && var8_2 == -1) {
uVar1 = 2;
}
else {
uVar1 = 1;
}
}
return uVar1;
}
int dTgDefeatBoss_c::create() {
if (checkDungeonFlag()) {
return FAILED;
}
mSceneflagPolarity = getSceneflagPolarity();
if (getSceneflag() >= 0xFF) {
mSceneflagPolarity = -1;
}
mStoryflagPolarity = getStoryflagPolarity();
if (!StoryflagManager::sInstance->checkFlagValid(getStoryflag())) {
mStoryflagPolarity = -1;
}
if (mSceneflagPolarity == -1 && mStoryflagPolarity == -1) {
return FAILED;
}
return SUCCEEDED;
}

Comment on lines +13 to +27

}

bool dTgDefeatBoss_c::fn_494_D0() {//checks if valid dungeion flag?

DungeonflagManager* pDVar2;
u16 sVar4;

fn_494_C0();
pDVar2 = DungeonflagManager::sInstance;
sVar4 = pDVar2->getCounterOrFlag(mID, (u32)8);

return sVar4 != 0;

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not 100% due to regswap.

The reason this can be changed is because:
1: setting mID is usually never going to happen.
2: the way it was loaded in checkDungeonFlag shows loading a variable offset from r1 into r3 before getDungeonFlagIndex was called.
3: in checkDungeonFlag() - the boolean conversion is implicit due to return type so temporary not needed

Suggested change
}
bool dTgDefeatBoss_c::fn_494_D0() {//checks if valid dungeion flag?
DungeonflagManager* pDVar2;
u16 sVar4;
fn_494_C0();
pDVar2 = DungeonflagManager::sInstance;
sVar4 = pDVar2->getCounterOrFlag(mID, (u32)8);
return sVar4 != 0;
}
void dTgDefeatBoss_c::getDungeonFlagIndex(u32 &outFlagIdx) {
outFlagIdx = 0x3;
}
bool dTgDefeatBoss_c::checkDungeonFlag() {
u32 dungeonFlagIdx;
getDungeonFlagIndex(dungeonFlagIdx);
return DungeonflagManager::sInstance->getCounterOrFlag(dungeonFlagIdx, 8) != 0;
}

Comment on lines 1 to +5
#include "d/t/d_t_defeat_boss.h"
#include "d/flag/storyflag_manager.h"
#include "d/flag/sceneflag_manager.h"
#include "d/flag/dungeonflag_manager.h"
#include "common.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include ordering will be automatic on format

Suggested change
#include "d/t/d_t_defeat_boss.h"
#include "d/flag/storyflag_manager.h"
#include "d/flag/sceneflag_manager.h"
#include "d/flag/dungeonflag_manager.h"
#include "common.h"
#include "d/t/d_t_defeat_boss.h"
#include "common.h"
#include "d/flag/dungeonflag_manager.h"
#include "d/flag/sceneflag_manager.h"
#include "d/flag/storyflag_manager.h"

u16 fn_494_380();
void fn_494_C0();
bool fn_494_D0();
bool init();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool init();
virtual int create() override;
virtual int actorExecute() override;

The vtables in ghidra do not match the name fully, check the offset with the documented offset in the corresponding base.

Most often will be of the following:

create
execute
draw
actorExecute
createHeap

Comment on lines +18 to +20

/* 0xFC */ u8 var8_1;//area?
/* 0xFD */ u8 var8_2;//scene flag? I assume this is only 2 byte
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function renaming based on insights in cpp

Suggested change
/* 0xFC */ u8 var8_1;//area?
/* 0xFD */ u8 var8_2;//scene flag? I assume this is only 2 byte
u16 getSceneflag();
s32 getSceneflagPolarity();
u32 getStoryflag();
s32 getStoryflagPolarity();

Comment on lines 22 to 25

private:
};

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable naming and signedness due to -1 comparison in source.
private since these shouldnt be access by other classes

Suggested change
private:
};
private:
/* 0xFC */ s8 mSceneflagPolarity;
/* 0xFD */ s8 mStoryflagPolarity;
};

Comment on lines +8 to +12
update__15dTgDefeatBoss_cFv = .text:0x00000230; // type:function size:0x120
getSceneflag__15dTgDefeatBoss_cFv = .text:0x00000350; // type:function size:0xC
fn_494_360__15dTgDefeatBoss_cFv = .text:0x00000360; // type:function size:0xC
getStoryflag__15dTgDefeatBoss_cFv = .text:0x00000370; // type:function size:0xC
fn_494_380__15dTgDefeatBoss_cFv = .text:0x00000380; // type:function size:0xC
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renaming

Suggested change
update__15dTgDefeatBoss_cFv = .text:0x00000230; // type:function size:0x120
getSceneflag__15dTgDefeatBoss_cFv = .text:0x00000350; // type:function size:0xC
fn_494_360__15dTgDefeatBoss_cFv = .text:0x00000360; // type:function size:0xC
getStoryflag__15dTgDefeatBoss_cFv = .text:0x00000370; // type:function size:0xC
fn_494_380__15dTgDefeatBoss_cFv = .text:0x00000380; // type:function size:0xC
getDungeonFlagIndex__15dTgDefeatBoss_cFRUl = .text:0x000000C0; // type:function size:0xC
checkDungeonFlag__15dTgDefeatBoss_cFv = .text:0x000000D0; // type:function size:0x84
create__15dTgDefeatBoss_cFv = .text:0x00000160; // type:function size:0xCC
actorExecute__15dTgDefeatBoss_cFv = .text:0x00000230; // type:function size:0x120
getSceneflag__15dTgDefeatBoss_cFv = .text:0x00000350; // type:function size:0xC
getSceneflagPolarity__15dTgDefeatBoss_cFv = .text:0x00000360; // type:function size:0xC
getStoryflag__15dTgDefeatBoss_cFv = .text:0x00000370; // type:function size:0xC
getStoryflagPolarity__15dTgDefeatBoss_cFv = .text:0x00000380; // type:function size:0xC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants