Conversation
Report for SOUE01 (79bc8e9 - a6eeeed)📈 Matched code: 24.04% (+0.00%, +136 bytes) ✅ 6 new matches
📈 4 improvements in unmatched items
|
elijah-thomas774
left a comment
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
see comment in source file
| void fn_494_C0(); | |
| static void getDungeonFlagIndex(u32 &outFlagIdx); |
| u16 getStoryflag(); | ||
| u16 fn_494_380(); | ||
| void fn_494_C0(); | ||
| bool fn_494_D0(); |
There was a problem hiding this comment.
When seeing getCounterOrFlag and it is an immediate comparision, it usually means its checking if its active.
| bool fn_494_D0(); | |
| bool checkDungeonFlag(); |
|
|
||
| } | ||
|
|
||
| u16 dTgDefeatBoss_c::getStoryflag() { |
There was a problem hiding this comment.
u32 return type effects the caller
| u16 dTgDefeatBoss_c::getStoryflag() { | |
| u32 dTgDefeatBoss_c::getStoryflag() { |
| 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; | ||
|
|
||
| } |
There was a problem hiding this comment.
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
| 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; | |
| } |
|
|
||
| } | ||
|
|
||
| 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; | ||
|
|
||
| } |
There was a problem hiding this comment.
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
| } | |
| 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; | |
| } |
| #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" |
There was a problem hiding this comment.
Include ordering will be automatic on format
| #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(); |
There was a problem hiding this comment.
| 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
|
|
||
| /* 0xFC */ u8 var8_1;//area? | ||
| /* 0xFD */ u8 var8_2;//scene flag? I assume this is only 2 byte |
There was a problem hiding this comment.
function renaming based on insights in cpp
| /* 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(); |
|
|
||
| private: | ||
| }; | ||
|
|
There was a problem hiding this comment.
variable naming and signedness due to -1 comparison in source.
private since these shouldnt be access by other classes
| private: | |
| }; | |
| private: | |
| /* 0xFC */ s8 mSceneflagPolarity; | |
| /* 0xFD */ s8 mStoryflagPolarity; | |
| }; | |
| 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 |
There was a problem hiding this comment.
renaming
| 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 |
No description provided.