decomp: pair array destructor, name StandData, real Queue push/pop (section scores 100%) #1335

Merged
coah80 merged 1 commits from agent/w0929/o-sections-land into main 2026-10-09 14:27:07 +00:00
7 changed files with 106 additions and 51 deletions

View File

@@ -2524,7 +2524,7 @@ __ct__Q33ipl3snd10tagSSeInfoFv = .text:0x8136C63C; // type:function size:0x30
__ct__Q34nw4r3snd11SoundHandleFv = .text:0x8136C66C; // type:function size:0xC
__dt__Q34nw4r3snd11SoundHandleFv = .text:0x8136C678; // type:function size:0x54
__dt__Q33ipl3snd10tagSSeInfoFv = .text:0x8136C6CC; // type:function size:0x58
__dt__Q33ipl3snd6UnkClsFv = .text:0x8136C724; // type:function size:0x1C scope:local
__arraydtor$15982 = .text:0x8136C724; // type:function size:0x1C scope:local
__ct__Q33ipl3snd11tagSBgmInfoFv = .text:0x8136C740; // type:function size:0x30 scope:local
__dt__Q33ipl3snd11tagSBgmInfoFv = .text:0x8136C770; // type:function size:0x58
__ct__Q33ipl3snd6SystemFv = .text:0x8136C7C8; // type:function size:0x4C
@@ -3223,7 +3223,7 @@ __dt__Q33ipl5scene5BoardFv = .text:0x81393CA4; // type:function size:0x68
__ct__Q33ipl5scene11BoardObjectFv = .text:0x81393D1C; // type:function size:0x140
__dt__Q33ipl4math28LinearIntp<Q33ipl4math4VEC2>Fv = .text:0x81393E5C; // type:function size:0x40
__dt__Q33ipl4math31Interporation<Q33ipl4math4VEC2>Fv = .text:0x81393E9C; // type:function size:0x40
init__Q43ipl5scene11BoardObject29@class$8157iplBoardObject_cppFv = .text:0x81393EDC; // type:function size:0x18
init__Q43ipl5scene11BoardObject9StandDataFv = .text:0x81393EDC; // type:function size:0x18
make_icon_cb___Q23ipl5sceneFPQ33ipl6nigaoe6ObjectPv = .text:0x81393EF4; // type:function size:0x80
create__Q33ipl5scene11BoardObjectFPQ33ipl4nand10LayoutFilePUcUlRC6_CDBIdRC13_CDBRecordKeyRCQ33ipl7utility4Date = .text:0x81393F74; // type:function size:0x84
init__Q33ipl5scene11BoardObjectFv = .text:0x81393FF8; // type:function size:0xA4

View File

@@ -159,7 +159,7 @@ namespace ipl {
RBRRecordType mRecordType; // 0xDC
u32 mOptOutFlag; // 0xE0
class {
class StandData {
public:
void init() {
mAngleIdx = -1;

View File

@@ -12,7 +12,6 @@
namespace ipl {
namespace scene {
extern "C" BOOL push_button_queue(void*, const void*);
class ButtonEventHandlerBase;
class OptOutButtonEventHandlerBase;
class SDMenuEventHandlerBase;
@@ -315,7 +314,6 @@ namespace ipl {
}
protected:
friend BOOL push_button_queue(void*, const void*);
typedef struct Command {
enum {
TYPE_ANIM = 0,

View File

@@ -10,31 +10,9 @@ namespace ipl {
public:
inline Queue<T, c>() : count(c), current(0), popped(0), pushed(0) {}
BOOL push(const T& item) {
if (count == current) {
return FALSE;
}
items[pushed] = item;
if (++pushed >= count) {
pushed = 0;
}
current++;
return TRUE;
}
BOOL push(const T& item);
BOOL pop() {
BOOL result = TRUE;
if (current == 0) {
result = FALSE;
goto done;
}
if (++popped >= count) {
popped = 0;
}
current--;
done:
return result;
}
BOOL pop();
int get_current_index() { return current; }
T& get_current_item() { return items[get_current_index()]; }
@@ -55,6 +33,34 @@ namespace ipl {
int current; // (sizeof(items) * count) + 0x04
int popped, pushed; // (sizeof(items) * count) + 0x08
};
template <typename T, int c>
BOOL Queue<T, c>::push(const T& item) {
if (count == current) {
return FALSE;
}
items[pushed] = item;
if (++pushed >= count) {
pushed = 0;
}
current++;
return TRUE;
}
template <typename T, int c>
BOOL Queue<T, c>::pop() {
BOOL result = TRUE;
if (current == 0) {
result = FALSE;
goto done;
}
if (++popped >= count) {
popped = 0;
}
current--;
done:
return result;
}
} // namespace utility
} // namespace ipl

View File

@@ -9,7 +9,6 @@
extern char scPaneName_B_Stop[7];
extern char scPaneName_T_Stop[];
extern "C" BOOL push_button_queue(void*, const void*);
namespace ipl {
namespace scene {
@@ -828,7 +827,7 @@ namespace ipl {
Command command;
command.type = Command::TYPE_ANIM;
command.animId = animId;
push_button_queue(&mReservedCmd, &command);
mReservedCmd.push(command);
}
void Button::reserveText(int paneId, u32 msgId) {
@@ -836,7 +835,7 @@ namespace ipl {
command.type = Command::TYPE_TEXT;
command.paneId = paneId;
command.msgId = msgId;
push_button_queue(&mReservedCmd, &command);
mReservedCmd.push(command);
}
/* ============== */
@@ -968,22 +967,6 @@ namespace ipl {
void OptOutButtonEventHandlerBase::onEventDerived(u32 compId, u32 event, const controller::Interface* con) {
}
extern "C" BOOL push_button_queue(void* storage, const void* item) {
typedef utility::Queue<Button::Command, 8> CommandQueue;
CommandQueue* queue = static_cast<CommandQueue*>(storage);
const Button::Command* command = static_cast<const Button::Command*>(item);
if (queue->count == queue->current) {
return FALSE;
}
queue->items[queue->pushed] = *command;
if (++queue->pushed >= queue->count) {
queue->pushed = 0;
}
queue->current++;
return TRUE;
}
} // namespace scene
} // namespace ipl

View File

@@ -3,9 +3,6 @@
#include "titledb.h"
// actually needed to match.
#pragma sym on
namespace ipl {
namespace scene {
#define COMMAND_FN(FUNCTION_HEADER, TAG, APP_BOX, SAVE_BOX, WII_TITLE_ID, SD_TITLE_ID) \

View File

@@ -0,0 +1,71 @@
# o-sections: linked units with .text section below 100%
Task: `check_decomp_complete.py` failed on three linked units whose functions were
all 100% but whose `.text` section score was not: iplSound 99.49785,
iplBoardObject 99.73868, iplButton 98.53095.
## Cause
objdiff 3.4.5 scores a code section as the size-weighted mean of the target
symbols' match percent, with an unpaired target symbol counted as 0
(`diff_generic_section` in objdiff-core/src/diff/data.rs). The per-function list
in the report hides this: for a `complete` unit, `report.rs` falls back to 100%
when a target symbol has no partner. Pairing is by exact name, plus
`name$<digits>` against `name$<digits>` (`symbol_name_matches`). The report
ignores objdiff.json `symbol_mappings` (it uses `MappingConfig::default()`).
Each unit had exactly one unpaired target function, equal to the missing bytes:
| unit | target symbol | built symbol | bytes |
|------|---------------|--------------|-------|
| iplSound | `__dt__Q33ipl3snd6UnkClsFv` | `__arraydtor$15981` | 0x1c |
| iplBoardObject | `init__Q43ipl5scene11BoardObject29@class$8157iplBoardObject_cppFv` | `...30@class$12470...` | 0x18 |
| iplButton | `push__Q33ipl7utility36Queue<Q43ipl5scene6Button7Command,8>FRCQ43ipl5scene6Button7Command` | `push_button_queue` | 0x70 |
Extra weak or dead-stripped functions in the built objects do not affect the
score (only target symbols count).
## Fixes
- iplSound: the target function is `__destroy_arr(_seBlk, ~tagSSeInfo, 0xc, 16)`,
the compiler's array destructor for `tagSSeInfo _seBlk[16]`; `UnkCls` was a
placeholder. Renamed in symbols.txt to `__arraydtor$15982`. The `$<digits>`
rule pairs it with any number, so header churn cannot break it.
- iplBoardObject: the `@class$NNNN<file>` id is a TU-wide counter that moves
with any earlier header change (30039 -> 8157 upstream, now 12470; my
iplQueue.h change alone moved it to 12471). objdiff cannot pair it unless the
number is exact, so a symbols.txt resync would go stale on the next header
edit. Named the class `StandData` (identical code) and renamed the symbol to
`init__Q43ipl5scene11BoardObject9StandDataFv`.
- iplButton: `push_button_queue` was an extern "C" stand-in (first asm, then C)
for `mReservedCmd.push(command)`, added because the in-class `Queue::push`
instance is emitted right after `reserveAnm` (DOL mismatch). In the target,
`push` is the last function before the `@20@` dtor thunk, and in
NandSDCardManager all Queue instances sit at the end of the TU in first-use
order (push<Thumb,15>, pop<Thumb,15>, push<Command,4>), with single-caller
pop<Command,4> inlined. That is deferred template instantiation: `push` and
`pop` were defined outside the class. Moved both out of class in
`utility/iplQueue.h` and restored `mReservedCmd.push(command)`.
- iplNandSDCardManager: its `#pragma sym on` ("actually needed to match") was
the old workaround for the same placement. With out-of-class push/pop the
pragma splits three ordinary functions into a second `.text`; without it the
layout matches the target. Removed it. Same 72 functions, identical bytes.
## Results
- `.text`: iplSound 100, iplBoardObject 100, iplButton 100; NandSDCardManager,
iplBoard and iplSceneManager still 100 in every section.
- Pools identical in all five touched units; DOL SHA1 unchanged.
- check_decomp_complete.py: only remaining failure is main/src/keyboard/tiString
(`inputChar__Q39textinput8tistring9DecolatedFw` 93.55882, unit not linked).
## Tried and rejected
- Template `push` in-class (da7 queue-01): exact bytes but placed after
reserveAnm, DOL changes.
- Out-of-class push with `#pragma sym on` kept in NandSDCardManager:
on_get_thumbnail, clean_command_queue and getAsyncResult move into the
second `.text`; layout breaks.
- Out-of-class push only (pop in-class), no sym pragma: push instances at the
end but pop<Thumb,15> stays mid-file; target needs it between the pushes.
- symbols.txt resync to `@class$12470`: works now, breaks on the next header edit.