Compare commits

..

21 Commits

Author SHA1 Message Date
coah
306ff59554 fix: model Run stack address independently of printf 2026-10-02 17:46:45 -05:00
coah
813660b96e match(iplSetting): Setting::draw byte-identical (#980)
draw is 632/632 against retail. The TU stays NonMatching, so the DOL is unchanged.
2026-10-02 17:36:11 -05:00
coah
e82417345a decomp: refine JPEG butterfly and color source structure (#978) 2026-10-02 17:32:07 -05:00
coah
230c2f8d34 decomp: reconstruct typed CHANSVm operands (#977) 2026-10-02 17:31:41 -05:00
coah
524350ed8f decomp: reconstruct alpha output and dictionary scan (#976) 2026-10-02 17:31:14 -05:00
coah
c62453dac9 decomp: recover ESMisc ticket scratch lifetime and cleanup flow (#975) 2026-10-02 17:30:27 -05:00
coah
6b17698b84 match(odh): cdj_c_colorConv byte-identical (#974)
Pad with a named remainder and declare sourceStride after rowIndex so cbPlane stays r22 and the stride stays r29. decompressLoop is unchanged.
2026-10-02 17:28:16 -05:00
devin-ai-integration[bot]
f9358f6e46 Decode BS2Mach Run asm + nup dead-static fossil (stays NonMatching) (#973)
* decomp: BS2Mach Run asm + CoverBlock/state decodes; nup dead-static fossil

- BS2Mach::Run: retail zeroes r0-r31 and installs a custom stack
  (__pformatter+640) before the dcbz/dcbf flush loop and tail jump —
  inexpressible in C, so asm with the exact retail sequence.
- BS2StartGCGame: CoverBlock.state direct member read (orig inlined
  DVDGetCommandBlockStatus accessor).
- BS2StateMachine: GamePartition!=0 polarity fold.
- nup.cpp __nupOp: 'static u32 lo' dead static reproduces orig's second
  .sbss word (orig .sbss=8: rvThread$2389 + 4B dead static).

Verified vs main: BS2Mach 25/29 fns byte-exact, nup 20/23 + .sbss 8=8.
Units stay NonMatching. Full build + DOL sha1 verified.

Co-authored-by: coah80 <usernamecole7@gmail.com>
Co-Authored-By: wch <usernamecole7@gmail.com>

* decomp: drop dead 'static u32 lo' padding from __nupOp

Per review: the extra .sbss word is a padding object — no relocation
references it, and nup data is already exact without it. Left unowned
for the linking pass.

Co-Authored-By: wch <usernamecole7@gmail.com>

---------

Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: coah80 <usernamecole7@gmail.com>
2026-10-02 17:26:43 -05:00
devin-ai-integration[bot]
3aa9daf94a decomp: emission gates for iplSDChannelTitle + MemoryCardManager decodes (#972)
IPL_SD_CHANNEL_TITLE_CPP gates move inline members to declarations so the
TU emits non-inlined calls like retail (same dedup-loss pattern as
#834's vtable restoration): iplInterporation::get, math::VEC3 ctor,
FaderSceneBase::initCalcNormal/calcCommonAfter, SceneBase::isReady/
isResetProcessDone/getParent/getChild/getNext/getPrev, NANDTask::
isFinished/checkData, Graphics::setOrthoTrans/setOrthoScale,
ut::Rect/RuntimeTypeInfo.

Verified vs main: iplSDChannelTitle 68/69 fns byte-exact (152B tail
residual in iplSDChannelTitle_flushSaveBeforeExit), iplMemoryCardManager
18/26. Units stay NonMatching; documented walls in revisit.attempts.md.

Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: coah80 <usernamecole7@gmail.com>
2026-10-02 17:22:10 -05:00
coah
dc48b109b0 match(odh): cdj_d_decompressLoop byte-identical (#971)
Keep the updated 2x2 plane in requiredBlockEnd so MWCC uses r15 for the
plane and r16 for the block end. 899/899, 0 diffs.
2026-10-02 17:15:30 -05:00
devin-ai-integration[bot]
b6f2304efc decomp(scene4): nested-switch guards + dead-store fossils (address/sdChannelSelect) (#970)
Decodes:
- start_drag_event: nested single-case switch emits the b<cond>+b
  two-branch guard (insn-identical, 7-word web-home residual)
- onEventDerived: no-break TRIG->ON_POINT fallthrough + || polarity fold
  (insn-identical, regname residuals)
- set_err_msg: default arm reads uninitialized messageId register,
  matching the orig's uninit-r4 retail bug (verified in base asm)
- movePane_onDrag width-accumulate scoping, FriendListCache::update
  member-chain regroup, AddressEdit::create/get_friendinfo arg marshals

All three units stay NonMatching; data 100% on all; documented walls in
tools/decomp-assist/scene4.attempts.md.

Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: coah80 <usernamecole7@gmail.com>
2026-10-02 17:13:22 -05:00
coah
7fac2b91ec decomp: refine MD5 rotation sums and word consumption (#969) 2026-10-02 17:09:45 -05:00
coah
6456e33a4c decomp: reconstruct AES last-round key cursor (#968) 2026-10-02 17:09:20 -05:00
coah
3244c6d7ff decomp: reconstruct CHANSVm opcode-local error paths (#967) 2026-10-02 16:59:59 -05:00
coah
b2089fbdba decomp: reconstruct alpha restriction gates and suffix fallback (#966) 2026-10-02 16:53:19 -05:00
coah
580b79f40d decomp: reconstruct MD5 endian-loaded rotation operands (#965) 2026-10-02 16:47:00 -05:00
coah
255f3e0530 decomp: reconstruct ESMisc cleanup helpers and return ABI (#964) 2026-10-02 16:42:08 -05:00
coah
d0e5483630 decomp: preserve CHANSVm string-load deletion errors (#963) 2026-10-02 16:35:31 -05:00
coah
d725e02301 link(ut_ArchiveFontBase): Matching after 23/23 code match (#962)
Flip NonMatching→Matching after #961 match(ut_ArchiveFontBase 23/23).
Full 43U rebuild keeps DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d.

Co-authored-by: linker <linker@users.noreply.github.com>
2026-10-02 16:27:44 -05:00
devin-ai-integration[bot]
87eaad4a42 decomp(CDBRecord): dead-fn literal fossils + Encrypt 284/284 insn-equal (#960)
Restores ~15 link-deadstripped retail fns whose emitted .data fossil
literals exist in the orig object; DOL-verified byte-identical at the
expected vaddrs. CDBRecordEncrypt auto-inlines dead CDBRecordGetFileSize:
284/284 instructions identical. Unit stays NonMatching: Encrypt's 57-byte
residual is an equal-cost register-packing tie-break (18 source probes
documented in tools/decomp-assist/CDBRecord.attempts.md).

Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: coah80 <usernamecole7@gmail.com>
2026-10-02 16:25:40 -05:00
coah
e32aad81fb match(ut_ArchiveFontBase 23/23) (rt7f, prior-art ref) (worker 2fe052a9) (#961) 2026-10-02 16:23:57 -05:00
47 changed files with 4620 additions and 525 deletions

View File

@@ -53,9 +53,9 @@ Progress
<!-- progress:start -->
| Decompiled | Matched | Linked | Data |
|:---:|:---:|:---:|:---:|
| 99.59% | 91.12% | 74.40% | 99.42% |
| 99.59% | 91.16% | 74.57% | 99.56% |
units 963/1027 complete, functions 12376/12563 matched.
units 964/1027 complete, functions 12378/12563 matched.
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
<!-- progress:end -->

View File

@@ -37,6 +37,9 @@ force_active:
# textinput::toolbar::csPaneToAnimation points one past the end of csAninationFile.
block_relocations:
# Run establishes a fixed stack at 0x81600000, not __pformatter + 0x280.
- source: .text:0x8137B468
- source: .text:0x8137B46C
- source: .data:0x8165E15C
- source: .data:0x8165E19C

View File

@@ -1299,7 +1299,7 @@ config.libs = [
Object(Matching, "ut/ut_RomFont.cpp"),
Object(Matching, "ut/ut_ResFontBase.cpp"),
Object(Matching, "ut/ut_ResFont.cpp"),
Object(NonMatching, "ut/ut_ArchiveFontBase.cpp"),
Object(Matching, "ut/ut_ArchiveFontBase.cpp"),
Object(Matching, "ut/ut_ArchiveFont.cpp"),
Object(Matching, "ut/ut_CharWriter.cpp"),
Object(Matching, "ut/ut_TextWriterBase.cpp"),

View File

@@ -163,6 +163,9 @@ namespace ipl {
void init(const f32& start, const f32& end, f32 maxFrame, f32 startTangent, f32 endTangent, int playback = ANIM_TYPE_FORWARD,
f32 speed = 1.0f);
#ifdef IPL_SD_CHANNEL_TITLE_CPP
f32 get() const;
#else
f32 get() const {
f32 var_f27 = mFrame;
f32 var_f28 = 1.0f / mMaxFrame;
@@ -181,6 +184,7 @@ namespace ipl {
return r;
}
#endif
protected:
f32 mStart;

View File

@@ -103,7 +103,7 @@ namespace ipl {
y = r.y;
z = 0.0f;
}
#if defined(IPL_ADDRESS_EDIT_CPP) || defined(IPL_SD_CHANNEL_SELECT_CPP) || defined(IPL_GC_WINDOW_CPP)
#if defined(IPL_ADDRESS_EDIT_CPP) || defined(IPL_SD_CHANNEL_SELECT_CPP) || defined(IPL_GC_WINDOW_CPP) || defined(IPL_SD_CHANNEL_TITLE_CPP)
VEC3(f32 fx, f32 fy, f32 fz);
#else
VEC3(f32 fx, f32 fy, f32 fz) {

View File

@@ -31,8 +31,12 @@ namespace ipl {
virtual void calc();
#ifdef IPL_SD_CHANNEL_TITLE_CPP
virtual void initCalcNormal();
#else
virtual void initCalcNormal() {
} // 0x4C
#endif
virtual void initCalcFadeout() {
} // 0x50
@@ -49,8 +53,12 @@ namespace ipl {
return FADER_SCN_NEXT;
} // 0x60
#ifdef IPL_SD_CHANNEL_TITLE_CPP
virtual void calcCommonAfter();
#else
virtual void calcCommonAfter() {
} // 0x64
#endif
int getSceneFadeState() {
return mScnFadeState;

View File

@@ -62,7 +62,11 @@ namespace ipl {
virtual ~Base();
/** @brief If the scene is ready */
#ifdef IPL_SD_CHANNEL_TITLE_CPP
virtual BOOL isReady() const;
#else
virtual BOOL isReady() const { return FALSE; }
#endif
/** @brief If the user can power off/reset the system */
#ifdef IPL_SD_CHANNEL_TITLE_CPP
@@ -73,7 +77,11 @@ namespace ipl {
/** @brief The scene running code when powering off/resetting the system */
virtual void startResetting() {}
/** @brief If the scene has finished its powering off/resetting task */
#ifdef IPL_SD_CHANNEL_TITLE_CPP
virtual BOOL isResetProcessDone();
#else
virtual BOOL isResetProcessDone() { return TRUE; }
#endif
/** @brief Prepare to create scene */
virtual void prepare() {}
@@ -86,10 +94,17 @@ namespace ipl {
/** @brief Destroy the scene and clear from memory */
virtual void destroy() {}
#ifdef IPL_SD_CHANNEL_TITLE_CPP
virtual Base* getParent();
virtual Base* getChild();
virtual Base* getNext();
virtual Base* getPrev();
#else
virtual Base* getParent() { return (Base*)mpParent; }
virtual Base* getChild() { return (Base*)mpChild; }
virtual Base* getNext() { return (Base*)mpNext; }
virtual Base* getPrev() { return (Base*)mpPrev; }
#endif
/** @brief Check if scene has been created.*/
bool isSceneCreated() const { return (mScnState & SCN_STATE_CREATED); }

View File

@@ -65,8 +65,13 @@ namespace ipl {
/** @brief Writes the file contents. */
virtual void write(); // 0x10
#ifdef IPL_SD_CHANNEL_TITLE_CPP
virtual bool isFinished();
virtual int checkData();
#else
virtual bool isFinished() { return mbDoneTask; } // 0x14
virtual int checkData() { return mResult; } // 0x18
#endif
virtual bool isFatalError(); // 0x1C
u8* getBuffer() const { return mpBuffer; }

View File

@@ -50,7 +50,7 @@ namespace ipl {
static BOOL IsLastTicketExpired(ESTitleId* titleId);
static void DeleteExpiredFlagFile();
static void DeleteUnauthorizedData(EGG::Heap* heap);
static s32 DeleteUnauthorizedData(EGG::Heap* heap);
static u32 CheckTmdCountryCode(ESTmdView* tmdView);
static u32 CheckTmdParentalControl(ESTmdView* tmdView);

View File

@@ -51,12 +51,17 @@ namespace ipl {
mArg.mOrthoScale = scale;
}
#ifdef IPL_SD_CHANNEL_TITLE_CPP
static void setOrthoTrans(const math::VEC3& translate);
static void setOrthoScale(const math::VEC2& scale);
#else
static void setOrthoTrans(const math::VEC3& translate) { mArg.mOrthoTrans = translate; }
static void setOrthoScale(const math::VEC2& scale) NO_INLINE {
mArg.mOrthoScale.x = scale.x;
mArg.mOrthoScale.y = scale.y;
}
#endif
private:
static Arg mArg;

View File

@@ -9,7 +9,7 @@ namespace nw4r {
namespace ut {
class Rect {
public:
#ifdef IPL_SOUND_RECT_OUT_OF_LINE
#if defined(IPL_SOUND_RECT_OUT_OF_LINE) || defined(IPL_SD_CHANNEL_TITLE_CPP)
Rect();
#else
Rect() : left(), top(), right(), bottom() {}
@@ -20,7 +20,7 @@ namespace nw4r {
Rect(f32 l, f32 t, f32 r, f32 b) : left(l), top(t), right(r), bottom(b) {}
#endif
#if !defined(IPL_CONTROLLER_TRIVIAL_RECT_DTOR) && !defined(IPL_MEMORYCARD_BASE_CPP)
#if !defined(IPL_CONTROLLER_TRIVIAL_RECT_DTOR) && !defined(IPL_MEMORYCARD_BASE_CPP) && !defined(IPL_SD_CHANNEL_TITLE_CPP)
~Rect() {}
#endif

View File

@@ -37,7 +37,7 @@ namespace nw4r {
} // namespace detail
template <typename TDerived, typename TBase>
#if defined(IPL_BOARD_OBJECT_EXTERNAL_DYNAMIC_CAST) || defined(IPL_MEMORYCARD_BASE_CPP)
#if defined(IPL_BOARD_OBJECT_EXTERNAL_DYNAMIC_CAST) || defined(IPL_MEMORYCARD_BASE_CPP) || defined(IPL_SD_CHANNEL_TITLE_CPP)
TDerived DynamicCast(TBase* pPtr);
#else
inline TDerived DynamicCast(TBase* pPtr) {

View File

@@ -252,14 +252,17 @@ namespace nw4r {
}
inline void updateSheetFlags(const void* glgrHdr, u32 groupIdx, u16* sheetOffsets, u32 flagsStep, const u32* sheetFlags) {
const GlyphGroups* glgr = (GlyphGroups*)((u8*)glgrHdr + sizeof(BinaryBlockHeader));
for (int sheetI = 0; sheetI < glgr->sheetCount; sheetI++) {
u32 groupBitIdx = sheetI + groupIdx * flagsStep * 8;
const GlyphGroups* glgr = (const GlyphGroups*)((const u8*)glgrHdr + sizeof(BinaryBlockHeader));
int sheetIndex;
u32 groupBitOffset;
u16* sheetOffset = sheetOffsets;
groupBitOffset = groupIdx * flagsStep * 8;
for (sheetIndex = 0; sheetIndex < glgr->sheetCount; sheetOffset++, sheetIndex++) {
u32 groupBitIdx = sheetIndex + groupBitOffset;
const u32* bitBlockPtr = sheetFlags + (groupBitIdx & ~0x1F) / 32;
u32 bitBlock = *(u32*)bitBlockPtr;
u32 bitBlock = *bitBlockPtr;
if (((bitBlock << (groupBitIdx & 0x1F)) & 0x80000000) != 0) {
sheetOffsets[sheetI] = 1;
*sheetOffset = 1;
}
}
}
@@ -268,14 +271,16 @@ namespace nw4r {
const u32* bitBlocksPtr, u32 sheetFlagsSize) {
HeaderedGlyphGroups* pGlgr = (HeaderedGlyphGroups*)glgrHdr;
for (int i = 0; i < pGlgr->inner.sheetCount; i++) {
sheetOffsets[i] = 0;
int i;
u16* sheetOffset;
for (i = 0, sheetOffset = sheetOffsets; i < pGlgr->inner.sheetCount; sheetOffset++, i++) {
*sheetOffset = 0;
}
for (int i = 0; i < pGlgr->inner.nameCount; i++) {
const char* includedGroups = ctx->pIncludedGroups;
u16 offset = pGlgr->inner.nameOffsets[i];
char* name = (char*)((u8*)hdr + offset);
char* name = (char*)(offset + (u32)hdr);
if (*includedGroups != 0) {
if (!ArchiveFontBase::IncludeName(includedGroups, name)) {
continue;
@@ -288,21 +293,23 @@ namespace nw4r {
inline void convertSheetOffsetBooleansToOffsets(const void* glgrHdr, u16* sheetOffsets) {
HeaderedGlyphGroups* pGlgr = (HeaderedGlyphGroups*)glgrHdr;
int i;
u16 glyphIdxOffset = 0;
for (int i = 0; i < pGlgr->inner.sheetCount; i++) {
if (sheetOffsets[i] == 1) {
sheetOffsets[i] = glyphIdxOffset;
u16* sheetOffset;
for (i = 0, sheetOffset = sheetOffsets; i < pGlgr->inner.sheetCount; sheetOffset++, i++) {
if (*sheetOffset == 1) {
*sheetOffset = glyphIdxOffset;
} else {
sheetOffsets[i] = -1;
*sheetOffset = -1;
glyphIdxOffset += pGlgr->inner.sheetGlyphCount;
}
}
}
inline void copyFlagOffsets(ArchiveFontBase::ConstructContext* ctx, u16* sheetOffsetsScratch, u32 workSize, u32 scratchSize) {
inline void copyFlagOffsets(ArchiveFontBase::ConstructContext* ctx, u16* sheetOffsetsScratch, u32 workSize, const u16* sheetOffsetsScratchEnd) {
u8* sheetOffsets = ctx->pWorkCurr;
ctx->pWorkCurr = sheetOffsets + workSize;
memmove(sheetOffsets, sheetOffsetsScratch, scratchSize);
memmove(sheetOffsets, sheetOffsetsScratch, (sheetOffsetsScratchEnd - sheetOffsetsScratch) * sizeof(u16));
ctx->pSheetOffsets = (u16*)sheetOffsets;
}
@@ -311,31 +318,64 @@ namespace nw4r {
// *sheetOffsetsScratch = (u16*)ROUNDDOWN((u32)((u8*)fontData + remWorkSpace) - sheetOffsetsSize, 2);
// return sheetOffsetsSize;
// }
ArchiveFontBase::ConstructState ArchiveFontBase::ConstructOpAnalyzeGLGR(ConstructContext* ctx, CachedStreamReader* reader) {
u32 glgrInnerLen;
HeaderedGlyphGroups* pGlgr;
const ArchiveFontBinaryLayout* font;
u8* glgrEnd;
class FontGlyphGroupsAcs {
public:
explicit FontGlyphGroupsAcs(const ArchiveFontBinaryLayout* font)
: mFont(font), mGroups(&font->glgr) {}
const GlyphGroups& GetGroups() const { return mGroups->inner; }
void SetSheetFlags(u32 flagsStep, const u32* sheetFlags) {
mFlagsStep = flagsStep;
mSheetFlags = sheetFlags;
}
u16 GetNumSheet() const { return mGroups->inner.sheetCount; }
int GetGlyphsPerSheet() const { return mGroups->inner.sheetGlyphCount; }
u16 GetNumSet() const { return mGroups->inner.nameCount; }
const char* GetSetName(int groupIndex) const {
const u16 nameOffset = mGroups->inner.nameOffsets[groupIndex];
return (const char*)(nameOffset + (u32)mFont);
}
bool IsUseSheet(int groupIndex, int sheetIndex) const {
const u32 groupBitIndex = sheetIndex + groupIndex * mFlagsStep * 8;
const u32* bitBlock = mSheetFlags + (groupBitIndex & ~0x1F) / 32;
return ((*bitBlock << (groupBitIndex & 0x1F)) & 0x80000000) != 0;
}
private:
const ArchiveFontBinaryLayout* mFont;
const HeaderedGlyphGroups* mGroups;
u32 mFlagsStep;
const u32* mSheetFlags;
};
ArchiveFontBase::ConstructState ArchiveFontBase::ConstructOpAnalyzeGLGR(ConstructContext* ctx, CachedStreamReader* reader) {
const u32* flagsSheets;
u32 sheetOffsetsSize;
u32 flagsSheetsOff;
u32 glgrInnerLen;
const ArchiveFontBinaryLayout* font;
u16 sheetGlyphCount;
u32 countSheet;
HeaderedGlyphGroups* pGlgr;
u8* glgrEnd;
u32 expectedMaxSize;
u32 dataBlockCount;
u16* sheetOffsetsScratch;
int groupIndex;
font = (ArchiveFontBinaryLayout*)ctx->pWorkCurr;
glgrInnerLen = ctx->mNextBlockHdr.size - sizeof(BinaryBlockHeader);
// Check for RFNA
if (font->hdr.signature != SIGNATURE_FONT_ARCHIVE) {
return CONSTRUCT_STATE_FATAL_ERR;
}
// Check that there's enough data available, and the space to
// put that data
ENSURE_READER_HAS_SIZE(ctx, reader, glgrInnerLen);
ENSURE_WORK_HAS_SIZE(ctx, glgrInnerLen);
expectedMaxSize = ctx->mNextBlockHdr.size + sizeof(BinaryFileHeader);
// Copy the glgr to work
{
pGlgr = (HeaderedGlyphGroups*)&font->glgr;
glgrEnd = (u8*)pGlgr + (u32)ctx->mNextBlockHdr.size;
@@ -348,80 +388,45 @@ namespace nw4r {
return CONSTRUCT_STATE_FATAL_ERR;
}
// Before here is fine (other than regswaps)
// u16 sheetGlyphCount = FORCE_REACCESS_2(font->glgr.inner.sheetGlyphCount, u16); // 0x1C
// u16 dataBlockCount = FORCE_REACCESS_2(font->hdr.dataBlocks, u16); // 0x0E
// FORCE_REACCESS_2(font->glgr.inner.sheetCount, u16);
// return ConstructOpAnalyzeGLGRInner(ctx, font, pGlgr, glgrEnd);
FontGlyphGroupsAcs gg(font);
sheetGlyphCount = gg.GetGlyphsPerSheet();
dataBlockCount = font->hdr.dataBlocks;
countSheet = gg.GetNumSheet();
const u32 stepSheetFlags = detail::CalcSizeFlagSet(countSheet);
flagsSheetsOff = detail::CalcOffsetSheetFlags(gg.GetGroups().nameCount, countSheet, gg.GetGroups().smthCount_0x0a,
gg.GetGroups().smthCount_0x0c);
flagsSheets = (const u32*)((flagsSheetsOff & ~3) + (u32)font);
gg.SetSheetFlags(stepSheetFlags, flagsSheets);
// u32 fontSizeToEndOfGlgr;
u16 countSheet;
u16 sheetGlyphCount, dataBlockCount;
u32 stepSheetFlags;
u32 flagsSheetsOff;
const u32* flagsSheets;
u32 sheetOffsetsSize;
u16* sheetOffsetsScratch;
u32 sheetOffsetsScratchSize;
sheetGlyphCount = font->glgr.inner.sheetGlyphCount; // 0x1C
dataBlockCount = font->hdr.dataBlocks; // 0x0E
// countName = font->glgr.inner.nameCount;
countSheet = font->glgr.inner.sheetCount;
// count0A = font->glgr.inner.smthCount_0x0a;
// count0C = font->glgr.inner.smthCount_0x0c;
stepSheetFlags = detail::CalcSizeFlagSet(countSheet);
flagsSheetsOff = detail::CalcOffsetSheetFlags(font->glgr.inner.nameCount, countSheet, font->glgr.inner.smthCount_0x0a,
font->glgr.inner.smthCount_0x0c);
flagsSheets = (const u32*)font + (flagsSheetsOff >> 2);
sheetOffsetsSize = ROUNDUP(countSheet * sizeof(u16), 4);
sheetOffsetsSize = (RoundUp)(countSheet * sizeof(u16), 4);
sheetOffsetsScratch = (u16*)ROUNDDOWN((u32)((u8*)font + ctx->remWorkSpace()) - sheetOffsetsSize, 2);
pGlgr = (HeaderedGlyphGroups*)&font->glgr;
ENSURE_WORK_HAS_SIZE(ctx, glgrEnd - (u8*)font + sheetOffsetsSize);
// if (ctx->pWorkEnd - workCurr < fontSizeToEndOfGlgr + sheetOffsetsSize) {
// return CONSTRUCT_STATE_FATAL_ERR;
// }
// Clear sheet offsets scratch
// for (s32 i = 0; i < pGlgr->inner.sheetCount; i++) {
// sheetOffsetsScratch[i] = 0;
// }
{
u16* sheetOffset;
int sheetIndex;
for (sheetIndex = 0, sheetOffset = sheetOffsetsScratch; sheetIndex < gg.GetNumSheet(); sheetOffset++, sheetIndex++) {
*sheetOffset = 0;
}
for (groupIndex = 0; groupIndex < gg.GetNumSet(); groupIndex++) {
const char* includedGroups = ctx->pIncludedGroups;
const char* name = gg.GetSetName(groupIndex);
if (*includedGroups && !ArchiveFontBase::IncludeName(includedGroups, name)) {
continue;
}
for (int sheetIndex = 0; sheetIndex < gg.GetNumSheet(); sheetIndex++) {
if (gg.IsUseSheet(groupIndex, sheetIndex)) {
sheetOffsetsScratch[sheetIndex] = 1;
}
}
}
}
// for (s32 i = 0; i < pGlgr->inner.nameCount; i++) {
// // const char* includedGroups = ctx->pIncludedGroups;
// u16 offset = pGlgr->inner.nameOffsets[i];
// const char* name = (char*)((u8*)font + offset);
// if (*ctx->pIncludedGroups != 0) {
// if (!ArchiveFontBase::IncludeName(ctx->pIncludedGroups, name)) {
// continue;
// }
// }
// updateSheetFlags(pGlgr, i, sheetOffsetsScratch, stepSheetFlags, flagsSheets);
// }
setSheetOffsetBooleans(ctx, pGlgr, font, sheetOffsetsScratch, flagsSheets, stepSheetFlags);
// u16 glyphIdxOffset = 0;
// for (s32 i = 0; i < pGlgr->inner.sheetCount; i++) {
// if (sheetOffsetsScratch[i] == 1) {
// sheetOffsetsScratch[i] = glyphIdxOffset;
// } else {
// sheetOffsetsScratch[i] = -1;
// glyphIdxOffset += pGlgr->inner.sheetGlyphCount;
// }
// }
convertSheetOffsetBooleansToOffsets(pGlgr, sheetOffsetsScratch);
sheetOffsetsScratchSize = (u32)countSheet << 1;
sheetOffsetsScratchSize += (sheetOffsetsScratchSize >> 31);
sheetOffsetsScratchSize &= ~1;
copyFlagOffsets(ctx, sheetOffsetsScratch, sheetOffsetsSize, sheetOffsetsScratchSize);
copyFlagOffsets(ctx, sheetOffsetsScratch, sheetOffsetsSize, sheetOffsetsScratch + (u16)countSheet);
ctx->mSheetCount = countSheet;
ctx->mGlyphsPerSheet = sheetGlyphCount;

View File

@@ -92,18 +92,20 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
dst[0] = val;
} else {
s32 oddLowSum;
s32 oddLowDifference;
s32 oddHighSum;
s32 oddHighDifference;
s32 dcValue;
t = b2 - b6;
oddLowSum = b5 + b3;
b5 = b5 - b3;
oddLowDifference = b5 - b3;
oddHighSum = b1 + b7;
b1 = b1 - b7;
oddHighDifference = b1 - b7;
u = b6 + b2;
t = t * 0xB5 >> 8;
x_factor = oddHighSum - oddLowSum;
z_factor = b5 + b1;
z_factor = oddLowDifference + oddHighDifference;
dcValue = block[0];
a = dcValue - b4;
x = x_factor * 0xB5 >> 8;
@@ -113,14 +115,14 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
z = z_factor * 0x62 >> 8;
w = d + u;
y = d - u;
m_part = b1 * 0x14E >> 8;
m_part = oddHighDifference * 0x14E >> 8;
e = a - t;
m = m_part - z;
oddLowSum += m;
n = oddHighSum + oddLowSum;
o = x + m;
dst[0] = w + n;
p_part = b5 * 0x8B;
p_part = oddLowDifference * 0x8B;
dst[7] = w - n;
p_part >>= 8;
dst[1] = v + o;

View File

@@ -816,7 +816,6 @@ static void TMCJPEGDEC_converterYUV444toRGB565(TMCCJPEGDecWork* work, s32 x, s32
u8* luminance;
u8* cb;
u8* cr;
s32 value;
s32 column;
s32 xEnd;
s32 cbValue;
@@ -844,17 +843,17 @@ static void TMCJPEGDEC_converterYUV444toRGB565(TMCCJPEGDecWork* work, s32 x, s32
for (column = x; column < xEnd; column++) {
cbValue = (s8)*cb++;
crValue = (s8)*cr++;
value = *luminance++;
green = value + (-(cbValue * 88 + crValue * 183) >> 8);
red = value + ((crValue * 359) >> 8);
blue = value + ((cbValue * 454) >> 8);
red = *luminance++;
green = red + (-(cbValue * 88 + crValue * 183) >> 8);
blue = red + ((cbValue * 454) >> 8);
red = red + ((crValue * 359) >> 8);
if ((blue | green | red) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
}
output[(column & 3) + (((column >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
((blue & 0xF8) >> 3) + (((red & 0xF8) << 8) + ((green & 0xFC) << 3));
}
luminance += rowSkip;
cb += rowSkip;

View File

@@ -656,10 +656,10 @@ static void TMCJPEGDEC_converterYUV420toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
blueOffset = (cbValue * 454) >> 8;
}
{
s32 value = *luminance++;
s32 green = value + greenOffset;
s32 red = value + redOffset;
s32 blue = value + blueOffset;
s32 red = *luminance++;
s32 green = red + greenOffset;
s32 blue = red + blueOffset;
red = red + redOffset;
if ((green | red | blue) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;

View File

@@ -920,8 +920,7 @@ selectDictionary:
if ((((wordLength == 0) && (*punctuationCursor != 0)) && (dictionaryExact != 0)) &&
((((ZiAlphaWork*)workData)->singleCharacter != 0 && (parameters->elementCount == 2)))) {
*wordCursor = ((ZiAlphaWork*)workData)->singleCharacter;
wordCursor[1] = *punctuationCursor;
punctuationCursor = punctuationCursor + 1;
wordCursor[1] = *punctuationCursor++;
wordCursor[2] = 0;
wordLength = 2;
}
@@ -1068,7 +1067,7 @@ filterVowelCandidate:
(((ZiAlphaWork*)workData)->requiredLength != parameters->elementCount)) &&
(((((ZiAlphaWork*)workData)->prefixLength == '\0' ||
(((ZiAlphaWork*)workData)->prefixLength + 1 >= parameters->elementCount)) && (dictionaryExact != 0)))
))) && ((((completionAllowed && (prefixCount == 0)) && (dictionaryKind != 0xb)) &&
))) && ((((currentVowelRestriction && (prefixCount == 0)) && (dictionaryKind != 0xb)) &&
((((int)dictionaryIndex < (int)(unsigned int)((ZiAlphaWork*)workData)->dictionaryCount &&
(((ZiAlphaOptions*)optionData)->lookupMode == '\0')) &&
(((ZiAlphaWork*)workData)->dictionaries[language] == 0)))))) {
@@ -1084,7 +1083,7 @@ filterVowelCandidate:
goto retryDictionary;
}
}
if ((((((dictionaryExact == 0) || (!completionAllowed)) || (prefixCount != 0)) ||
if ((((((dictionaryExact == 0) || (!currentVowelRestriction)) || (prefixCount != 0)) ||
((dictionaryKind == 0xb ||
(dictionaryIndex >= ((ZiAlphaWork*)workData)->dictionaryCount)))) ||
(elements == 0)) ||
@@ -1208,10 +1207,8 @@ emitCandidate:
if (((ZiAlphaOptions*)optionData)->maxResults <= candidateCount) goto finishCandidates;
} else {
if (((ZiAlphaOptions*)optionData)->lookupMode != '\0') {
for (index = 0;
(index <= (int)wordLength &&
(wordCursor[index] == ((ZiAlphaOptions*)optionData)->dictionary[index]));
index = index + 1) {
for (index = 0; index <= wordLength; index++) {
if (wordCursor[index] != ((ZiAlphaOptions*)optionData)->dictionary[index]) break;
}
if ((((((ZiAlphaWork*)workData)->operation != '\0') || ((int)wordLength <= index))
&& ((((ZiAlphaWork*)workData)->operation == '\0' ||
@@ -1367,7 +1364,7 @@ emitCandidate:
}
}
retryDictionary:;
} while (dictionaryKind != 0);
} while (dictionaryIndex != 0);
}
finishDictionaryPass:;
}
@@ -1382,21 +1379,17 @@ finishDictionaryPass:;
}
if (((candidateCount == 0) && (punctuationCandidate)) && (firstCandidate == 0)) {
candidateCount = 1;
if ((((ZiAlphaOptions*)optionData)->countOnly == '\0') && ((parameters->getOptions & 0xfd) != 0x81)) {
*encodedOutput = 0x3e;
encodedOutput[2] = 0;
encodedOutput[1] = 0;
}
else {
if (((ZiAlphaOptions*)optionData)->countOnly != 0 || (parameters->getOptions & 0xFD) == 0x81) {
if (parameters->getMode == 1) {
*wordCursor = *elements;
} else {
*wordCursor = 0x3E;
}
else {
*wordCursor = 0x3e;
}
wordCursor[2] = 0;
wordCursor[1] = 0;
wordCursor = wordCursor + 2;
wordCursor[1] = wordCursor[2] = 0;
wordCursor += 2;
} else {
*encodedOutput = 0x3E;
encodedOutput[1] = encodedOutput[2] = 0;
}
if (((ZiAlphaOptions*)optionData)->lookupMode == '\0') {
((ZiAlphaWork*)workData)->singleCharacter = 0;
@@ -1406,13 +1399,13 @@ finishDictionaryPass:;
secondLanguagePass = ZI8_TRUE;
languagePassCount = 0;
language = parameters->subLanguage;
completionAllowed = secondaryCompletionAllowed;
currentVowelRestriction = secondaryVowelRestriction;
dictionaryStatus[9] = 0;
dictionaryStatus[5] = 0;
dictionaryStatus[6] = 0;
dictionaryStatus[7] = 0;
dictionaryStatus[8] = 0;
completionAllowed = secondaryCompletionAllowed;
currentVowelRestriction = secondaryVowelRestriction;
if (switchedLanguage) {
secondLanguagePass = ZI8_FALSE;
dictionaryStatus[1] = 0;
@@ -1426,14 +1419,15 @@ finishDictionaryPass:;
if (language == 0) {
language = parameters->language;
}
completionAllowed = secondaryCompletionAllowed;
currentVowelRestriction = secondaryVowelRestriction;
if (language == parameters->language) {
completionAllowed = primaryCompletionAllowed;
currentVowelRestriction = primaryVowelRestriction;
} else {
completionAllowed = secondaryCompletionAllowed;
currentVowelRestriction = secondaryVowelRestriction;
}
if ((((ZiAlphaOptions*)optionData)->lookupMode != '\0') || ((!currentVowelRestriction && (!completionAllowed)))) goto finishCandidates;
if ((completionAllowed) &&
if ((((ZiAlphaOptions*)optionData)->lookupMode != '\0') || ((!completionAllowed && (!currentVowelRestriction)))) goto finishCandidates;
if ((currentVowelRestriction) &&
((((((ZiAlphaWork*)workData)->suffixMode == '\0' && (2 < (int)elementCount)) &&
(elements[elementCount - 2] == 0xeff1)) &&
((int)((ZiAlphaWork*)workData)->prefixCount == elementCount - 2)))) {
@@ -1444,66 +1438,65 @@ finishDictionaryPass:;
prefixPrepared = ZI8_TRUE;
goto preparePrefix;
}
if (!((((completionAllowed) && (((ZiAlphaWork*)workData)->suffixMode != '\0')) &&
((((ZiAlphaWork*)workData)->suffixLocked == '\0' && (2 < (int)elementCount)))) &&
(((elements[elementCount - 2] == 0xeff1 &&
((int)((ZiAlphaWork*)workData)->suffixCount == elementCount - 2)) ||
(((int)((ZiAlphaWork*)workData)->suffixCount == elementCount - 1 &&
((Zi8IsAlphaPunct(elements[elementCount - 1])) != '\0'))))))) {
tryAlternatePrefix:
if ((prefixPrepared) && (1 < ((ZiAlphaWork*)workData)->alternatePrefixCount)) {
if (language == parameters->language) {
if (primaryMatched) {
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
}
}
else if (secondaryMatched) {
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
}
if (((ZiAlphaWork*)workData)->alternatePrefixCount != '\0') {
if (currentVowelRestriction && ((ZiAlphaWork*)workData)->suffixMode != 0 &&
((ZiAlphaWork*)workData)->suffixLocked == 0 && elementCount > 2 &&
((elements[elementCount - 2] == 0xEFF1 &&
((ZiAlphaWork*)workData)->suffixCount == elementCount - 2) ||
(((ZiAlphaWork*)workData)->suffixCount == elementCount - 1 &&
Zi8IsAlphaPunct(elements[elementCount - 1]) != 0))) {
if (((ZiAlphaWork*)workData)->prefixEnabled >= 1 && elements[elementCount - 1] == 0xEFF1) {
goto checkPrefixPunctuation;
}
if (!primaryMatched && !secondaryMatched) {
((ZiAlphaWork*)workData)->suffixLocked = 1;
((ZiAlphaWork*)workData)->suffixElementCount = parameters->elementCount - 1;
if (prefixCount != 0) {
wordCursor -= prefixCount;
elements -= prefixCount;
elementCount = elementCount + prefixCount;
wordCapacity = wordCapacity + prefixCount;
prefixCount = 0;
prefixPrepared = ZI8_FALSE;
((ZiAlphaWork*)workData)->suffixMode = 0;
((ZiAlphaWork*)workData)->suffixLocked = 0;
((ZiAlphaWork*)workData)->suffixCount = 0;
for (index = 0; index < (int)(unsigned int)((ZiAlphaWork*)workData)->alternatePrefixCount; index = index + 1) {
((ZiAlphaWork*)workData)->prefix[index] =
((ZiAlphaWork*)workData)->alternatePrefix[index];
}
((ZiAlphaWork*)workData)->prefixCount = (ziU8)index;
if (((ZiAlphaWork*)workData)->language == parameters->language) {
((ZiAlphaWork*)workData)->language = parameters->subLanguage;
}
else {
((ZiAlphaWork*)workData)->language = parameters->language;
}
}
goto preparePrefix;
}
}
if ((prefixPrepared) && (1 < ((ZiAlphaWork*)workData)->alternatePrefixCount)) {
if (language == parameters->language) {
if (primaryMatched) {
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
}
}
if ((((primaryMatched) && (secondaryMatched)) || (elementCount == 0)) ||
(((language == parameters->language && (primaryMatched)) || ((language == parameters->subLanguage && (secondaryMatched))))))
goto finishCandidates;
if (completionAllowed) goto checkPrefixPunctuation;
} else {
if ((((ZiAlphaWork*)workData)->prefixEnabled == '\0') || (elements[elementCount - 1] != 0xeff1)) {
if ((!primaryMatched) && (!secondaryMatched)) {
((ZiAlphaWork*)workData)->suffixLocked = 1;
((ZiAlphaWork*)workData)->suffixElementCount = parameters->elementCount - 1;
if (prefixCount != 0) {
wordCursor -= prefixCount;
elements -= prefixCount;
elementCount = elementCount + prefixCount;
wordCapacity = wordCapacity + prefixCount;
prefixCount = 0;
}
goto preparePrefix;
}
goto tryAlternatePrefix;
else if (secondaryMatched) {
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
}
if (((ZiAlphaWork*)workData)->alternatePrefixCount != '\0') {
wordCursor -= prefixCount;
elements -= prefixCount;
elementCount = elementCount + prefixCount;
wordCapacity = wordCapacity + prefixCount;
prefixCount = 0;
prefixPrepared = ZI8_FALSE;
((ZiAlphaWork*)workData)->suffixMode = 0;
((ZiAlphaWork*)workData)->suffixLocked = 0;
((ZiAlphaWork*)workData)->suffixCount = 0;
for (index = 0; index < (int)(unsigned int)((ZiAlphaWork*)workData)->alternatePrefixCount; index = index + 1) {
((ZiAlphaWork*)workData)->prefix[index] =
((ZiAlphaWork*)workData)->alternatePrefix[index];
}
((ZiAlphaWork*)workData)->prefixCount = (ziU8)index;
if (((ZiAlphaWork*)workData)->language == parameters->language) {
((ZiAlphaWork*)workData)->language = parameters->subLanguage;
}
else {
((ZiAlphaWork*)workData)->language = parameters->language;
}
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
}
}
if ((((primaryMatched) && (secondaryMatched)) || (elementCount == 0)) ||
(((language == parameters->language && (primaryMatched)) || ((language == parameters->subLanguage && (secondaryMatched))))))
goto finishCandidates;
if (currentVowelRestriction) {
checkPrefixPunctuation:
if ((1 < ((ZiAlphaWork*)workData)->prefixEnabled) &&
(parameters->elements[parameters->elementCount - 1] != 0xEFF1))

View File

@@ -197,8 +197,9 @@ void AESiEncryptBlock(AESContext* context, u32* output, const u32* input) {
void AESiDecryptBlock(AESContext* context, u32* output, const u32* input) {
u32 rounds=context->rounds;
u32* key=context->keys + rounds*4;
u32* key=context->keys;
u32 a,b,c,d;
key += rounds*4;
if (context->needsTransform) {
u32 round;
for (round=1; round<context->rounds; ++round) {

View File

@@ -68,8 +68,14 @@ void NETMD5GetDigest(NETMD5Context* context, void* digest) {
memset(context, 0, sizeof(*context));
}
#define ROTATE(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
#define STEP(a, b, c, d, f, word, n) ((a) += (f), (a) = (b) + ROTATE(__lwbrx(0, (int)(word)) + (*constant + (a)), n))
static inline u32 rotateSum(u32 state, const u32* word, u32 constant, int shift) {
// Each rotation half reads its own byte-reversed message word.
u32 right = __lwbrx((void*)word, 0);
u32 left = __lwbrx((void*)word, 0);
return ((state + (constant + left)) << shift) | ((constant + (state + right)) >> (32 - shift));
}
#define STEP(a, b, c, d, f, word, n) ((a) = (b) + rotateSum((a) + (f), word, *constant, n))
static void ProcessBlock(NETMD5Context* context) {
static u32 constants[64] = {0xD76AA478, 0xE8C7B756, 0x242070DB, 0xC1BDCEEE, 0xF57C0FAF, 0x4787C62A, 0xA8304613, 0xFD469501, 0x698098D8, 0x8B44F7AF, 0xFFFF5BB1, 0x895CD7BE, 0x6B901122, 0xFD987193, 0xA679438E, 0x49B40821, 0xF61E2562, 0xC040B340, 0x265E5A51, 0xE9B6C7AA, 0xD62F105D, 0x02441453, 0xD8A1E681, 0xE7D3FBC8, 0x21E1CDE6, 0xC33707D6, 0xF4D50D87, 0x455A14ED, 0xA9E3E905, 0xFCEFA3F8, 0x676F02D9, 0x8D2A4C8A, 0xFFFA3942, 0x8771F681, 0x6D9D6122, 0xFDE5380C, 0xA4BEEA44, 0x4BDECFA9, 0xF6BB4B60, 0xBEBFBC70, 0x289B7EC6, 0xEAA127FA, 0xD4EF3085, 0x04881D05, 0xD9D4D039, 0xE6DB99E5, 0x1FA27CF8, 0xC4AC5665, 0xF4292244, 0x432AFF97, 0xAB9423A7, 0xFC93A039, 0x655B59C3, 0x8F0CCC92, 0xFFEFF47D, 0x85845DD1, 0x6FA87E4F, 0xFE2CE6E0, 0xA3014314, 0x4E0811A1, 0xF7537E82, 0xBD3AF235, 0x2AD7D2BB, 0xEB86D391};
@@ -83,13 +89,13 @@ static void ProcessBlock(NETMD5Context* context) {
block = context->buffer32;
word = block;
constant = constants;
index = indices;
for (round = 0; round < 4; ++round) {
STEP(a,b,c,d,(b & c) | (~b & d),word,7); ++word; ++constant;
STEP(d,a,b,c,(a & b) | (~a & c),word,12); ++word; ++constant;
STEP(c,d,a,b,(d & a) | (~d & b),word,17); ++word; ++constant;
STEP(b,c,d,a,(c & d) | (~c & a),word,22); ++word; ++constant;
STEP(a,b,c,d,(b & c) | (~b & d),word++,7); ++constant;
STEP(d,a,b,c,(a & b) | (~a & c),word++,12); ++constant;
STEP(c,d,a,b,(d & a) | (~d & b),word++,17); ++constant;
STEP(b,c,d,a,(c & d) | (~c & a),word++,22); ++constant;
}
index = indices;
for (round = 0; round < 4; ++round) {
STEP(a,b,c,d,(b & d) | (c & ~d),block + *index,5); ++index; ++constant;
STEP(d,a,b,c,(a & c) | (b & ~c),block + *index,9); ++index; ++constant;

View File

@@ -242,14 +242,63 @@ BOOL BS2IsDiagDisc() { return (u8)(*(u8 *)OSPhysicalToCached(OS_ADDR_BOOT_INFO)
extern vu32 BS2VideoMode;
extern vu32 __DVDLayoutFormat;
void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
u8 *block = start;
for (; blockCount != 0; --blockCount) {
__dcbz(block, 0);
__dcbf(block, 0);
block += 32;
}
((void (*)(u32))entryPoint)(argument);
asm void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
// clang-format off
#ifdef __MWERKS__
nofralloc
mtctr r5
mtlr r3
li r0, 0
li r2, 0
li r3, 0
li r5, 0
li r7, 0
li r8, 0
li r9, 0
li r10, 0
li r11, 0
li r12, 0
li r13, 0
li r14, 0
li r15, 0
li r16, 0
li r17, 0
li r18, 0
li r19, 0
li r20, 0
li r21, 0
li r22, 0
li r23, 0
li r24, 0
li r25, 0
li r26, 0
li r27, 0
li r28, 0
li r29, 0
li r30, 0
li r31, 0
// The application stack is fixed; it is unrelated to the formatter.
lis r1, 0x8160
ori r1, r1, 0
li r6, 0
b Run_loop_entry
Run_loop:
dcbz r4, r0
dcbf r4, r0
addi r4, r4, 0x20
bdnz Run_loop
b Run_done
Run_done:
li r4, 0
blr
Run_loop_entry:
b Run_loop
#endif
// clang-format on
}
BOOL BS2GetLockedTitles(ESTitleId *pTitleIds, u32 *count) {
@@ -803,7 +852,7 @@ void BS2StartGCGame() {
OSTime time;
StartingGame = TRUE;
while (DVDGetCommandBlockStatus(&CoverBlock) != DVD_STATE_IDLE) {
while (CoverBlock.state != DVD_STATE_IDLE) {
}
soundMode = SCGetSoundMode();
@@ -1796,11 +1845,12 @@ invalidRvlRegion:
State = BS2_STT_RESET_SYSTEM;
break;
}
if (GamePartition == 0) {
if (GamePartition != 0)
State = BS2_STT_37;
else {
State = BS2_STT_54;
break;
}
State = BS2_STT_37;
case 0x25:
if (BS2BootFromCache != 0) {
BS2Report("Open partition from cache.dat\n");

View File

@@ -7207,7 +7207,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
u32 cmpLow;
struct {
CHANSVmObjType operandTypes[2];
u64 floatBits;
double floatLiteral;
CHANSVmObjHdr copies[2];
CHANSVmObjHdr load;
CHANSVmObjHdr operand;
@@ -7291,8 +7291,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
case CHANS_VM_OP_LOAD_FLOAT: {
opSize = 9;
operandBuf = VmGetOperand(vm, 1, 9);
memcpy(&scratch.floatBits, operandBuf, 8);
result = CHANSVmSetFloat(vm, &pVm->accumulator, *(double*)&scratch.floatBits);
memcpy(&scratch.floatLiteral, operandBuf, 8);
result = CHANSVmSetFloat(vm, &pVm->accumulator, scratch.floatLiteral);
break;
}
@@ -7441,8 +7441,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
}
if (leftOp == vmNull || rightOp == vmNull) {
result = CHANS_VM_ERR_RESULT_TYPE;
break;
return CHANS_VM_ERR_RESULT_TYPE;
}
result = opFunc(vm, convTypeIdx, &pVm->accumulator, leftOp, rightOp);
@@ -7717,30 +7716,27 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
CHANSVmObjHdr* pAcc;
CHANSVmExecutionCtx* ctx;
CHANSVmModule* dbg;
CHANSVmErr loadResult;
opSize = 3;
operandBuf = VmGetOperand(vm, 1, 3);
if (operandBuf == vmNull) {
return CHANS_VM_ERR_CODE_RANGE;
}
pAcc = &pVm->accumulator;
result = CHANSVmDeleteObject(vm, pAcc);
if (result == CHANS_VM_OK) {
loadResult = CHANSVmDeleteObject(vm, pAcc);
if (loadResult == CHANS_VM_OK) {
imm16Val = VM_READ_BE_U16(operandBuf, 0);
ctx = pVm->pActiveCtx;
dbg = ctx->pDbg;
if (imm16Val < dbg->stringCount) {
if (dbg->pStringTbl[imm16Val].pStringData != vmNull) {
goto load_str_ok;
}
if (imm16Val >= dbg->stringCount || dbg->pStringTbl[imm16Val].pStringData == vmNull) {
loadResult = CHANS_VM_ERR_LOAD_STRING_CONST;
} else {
pAcc->type = CHANS_VM_OBJ_TYPE_STRING;
pAcc->hasData = vmTrue;
pAcc->value.wstring_v = (vmWStringObjVal*)&ctx->pDbg->pStringTbl[imm16Val];
}
}
result = CHANS_VM_ERR_LOAD_STRING_CONST;
break;
load_str_ok:
pAcc->type = CHANS_VM_OBJ_TYPE_STRING;
pAcc->hasData = vmTrue;
pAcc->value.wstring_v = (vmWStringObjVal*)&ctx->pDbg->pStringTbl[imm16Val];
result = loadResult;
break;
}
@@ -7773,8 +7769,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
arrayIdx = (u32)stackPtr->value.int_v;
goto set_index_ok;
case CHANS_VM_OBJ_TYPE_FLOAT: {
double stackFloat = *(double*)stackPtr;
if (stackFloat <= 4294967294.0 && 0.0 <= stackFloat) {
double stackFloat = stackPtr->value.float_v;
if (stackFloat >= 0.0 && stackFloat <= 4294967294.0) {
arrayIdx = (u32)stackFloat;
goto set_index_ok;
}
@@ -7885,8 +7881,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
computedAddr += pVm->pActiveCtx->pc + 5;
}
if (computedAddr < 1 || computedAddr >= pVm->pActiveCtx->pDbg->codeSize) {
result = CHANS_VM_ERR_CODE_RANGE;
break;
return CHANS_VM_ERR_CODE_RANGE;
}
pVm->pActiveCtx->pc = computedAddr;
opSize = 0;
@@ -7934,8 +7929,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
computedAddr += pVm->pActiveCtx->pc + 4;
}
if (computedAddr < 1 || computedAddr >= pVm->pActiveCtx->pDbg->codeSize) {
result = CHANS_VM_ERR_CODE_RANGE;
break;
return CHANS_VM_ERR_CODE_RANGE;
}
pVm->pActiveCtx->pc = computedAddr;
opSize = 0;
@@ -7960,11 +7954,13 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
}
case CHANS_VM_OP_DELETE_INDIRECT: {
result = CHANS_VM_ERR_DELETE_INDIRECT;
if (pVm->accumulator.type == CHANS_VM_TYPE_INDEX_REF) {
foundObj = VmGetArrayElement(vm, &pVm->accumulator, *((u32*)&pVm->accumulator.value + 1), vmFalse);
result = VmDeleteCommon(vm, foundObj);
CHANSVmObjHdr* accumulator = &pVm->accumulator;
CHANSVmErr deleteResult = CHANS_VM_ERR_DELETE_INDIRECT;
if (accumulator->type == CHANS_VM_TYPE_INDEX_REF) {
foundObj = VmGetArrayElement(vm, accumulator, accumulator->value.data.len, vmFalse);
deleteResult = VmDeleteCommon(vm, foundObj);
}
result = deleteResult;
break;
}
@@ -8008,34 +8004,27 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
if (pVm->pActiveCtx->stackDepth != 0 && pVm->pObjStackTopBuf + sizeof(CHANSVmObjHdr) <= pVm->pHeapEnd) {
CHANSVmObjHdr* stackTop = (CHANSVmObjHdr*)pVm->pObjStackTopBuf;
isTypeMatch = 0;
if (pVm->accumulator.type == stackTop->type) {
if (stackTop->type == pVm->accumulator.type) {
switch (stackTop->type) {
case CHANS_VM_OBJ_TYPE_INTEGER: {
u32 low1 = *(u32*)stackTop;
u32 low2 = *(u32*)&pVm->accumulator;
u32 high1 = *((u32*)stackTop + 1);
u32 high2 = *((u32*)&pVm->accumulator + 1);
u32 xor1 = low1 ^ low2;
u32 xor2 = high1 ^ high2;
isTypeMatch = !(xor1 | xor2);
isTypeMatch = stackTop->value.int_v == pVm->accumulator.value.int_v;
goto end_branch_check;
}
case CHANS_VM_OBJ_TYPE_FLOAT: {
double stackFloat = stackTop->value.float_v;
double accFloat = pVm->accumulator.value.float_v;
isTypeMatch = stackFloat == accFloat ? 1 : 0;
isTypeMatch = stackTop->value.float_v == pVm->accumulator.value.float_v;
goto end_branch_check;
}
case CHANS_VM_OBJ_TYPE_STRING: {
u32 len1, len2;
CHANSVmObjHdr* stackObj = (CHANSVmObjHdr*)pVm->pObjStackTopBuf;
const vmWStringObjVal* accumulatorString = pVm->accumulator.value.wstring_v;
const vmWStringObjVal* stackString = stackTop->value.wstring_v;
u32 strEqual;
isTypeMatch = 0;
len1 = stackObj->value.wstring_v->len;
len2 = pVm->accumulator.value.wstring_v->len;
len1 = stackString->len;
len2 = accumulatorString->len;
if (len1 == len2) {
strEqual = 0;
if (len1 == 0 || memcmp(stackObj->value.wstring_v->spData, pVm->accumulator.value.wstring_v->spData, len1) == 0) {
if (len1 == 0 || memcmp(stackString->spData, accumulatorString->spData, len1) == 0) {
strEqual = 1;
}
if (strEqual) {

View File

@@ -1179,10 +1179,10 @@ namespace ipl {
return;
}
if (mState != STATE_NORMAL || mMode != 0) {
return;
}
switch (mState) {
case STATE_NORMAL:
switch (mMode) {
case 0:
if (!mpFriendCache->isThere(buttonNo + mPage * BTN_MAX)) {
return;
}
@@ -1240,6 +1240,8 @@ namespace ipl {
snd::getSystem()->startSEwithPos("WIPL_SE_CH_HOLD", mDrag.mPos.x);
mState = STATE_DRAG;
}
}
}
void Address::start_drag_point_event(const char* paneName, controller::Interface* con) {
@@ -1425,10 +1427,7 @@ namespace ipl {
if (con->downTrg(controller::BTN_INTERACT)) {
Button* button = static_cast<Button*>(System::getScene(SCENE_BUTTON));
if (mState != STATE_COVER_NORMAL && mState != STATE_NORMAL) {
break;
}
if (mState == STATE_COVER_NORMAL || mState == STATE_NORMAL) {
if (Button::cmpButtonName(paneName, Button::BTN_EXIT) == 0) {
MailAddressSelect* mailAddrSel = static_cast<MailAddressSelect*>(System::getScene(SCENE_MAIL_ADDRESS_SELECT));
button->animation(Button::IDANIM_SELECT_CALENDAR_EXIT);
@@ -1477,7 +1476,7 @@ namespace ipl {
snd::getSystem()->startSE("WIPL_SE_FL_PAGE_DEC");
onPreviousPage();
}
break;
}
}
// fallthrough
}
@@ -1783,13 +1782,15 @@ namespace ipl {
nw4r::math::VEC3 baseTrans = mpLayout->FindPaneByName("N_base_move")->GetTranslate();
math::VEC2 pos = System::getControllerManager()->getController(mDrag.mChan)->getDpdProjectionPos();
nw4r::lyt::TextBox* textBox = static_cast<nw4r::lyt::TextBox*>(mpLayout->FindPaneByName("T_name_move"));
const u16* name = mpFriendCache->getInfo(mDrag.mButton + mDrag.mPage * BTN_MAX).attr.name;
f32 width = 0.0f;
if (textBox != NULL && name != NULL) {
textBox->GetFont()->GetWidth();
for (; *name != 0; name++) {
width += textBox->GetFont()->GetCharWidth(*name);
if (textBox != NULL) {
const u16* name = mpFriendCache->getInfo(mDrag.mButton + mDrag.mPage * BTN_MAX).attr.name;
if (name != NULL) {
textBox->GetFont()->GetWidth();
for (; *name != 0; name++) {
width += textBox->GetFont()->GetCharWidth(*name);
}
}
}
width += 0.01f;
@@ -1946,11 +1947,10 @@ namespace ipl {
}
void FriendListCache::update(u32 index, const wchar_t* name, u64 fdId) {
NWC24FriendInfo* info = &mInfos[index];
info->attr.fdId = fdId;
memset(info->attr.name, 0, sizeof(info->attr.name));
wcsncpy((wchar_t*)info->attr.name, name, 10);
System::getNwc24Manager()->updateFriendInfo(info, index);
mInfos[index].attr.fdId = fdId;
memset(mInfos[index].attr.name, 0, sizeof(mInfos[index].attr.name));
wcsncpy((wchar_t*)getInfo(index).attr.name, name, 10);
System::getNwc24Manager()->updateFriendInfo(&getInfo(index), index);
}
void FriendListCache::del(u32 index) {

View File

@@ -521,7 +521,8 @@ void ipl::scene::AddressEdit::create() {
set_textbox(textPane, friendText);
textPane = (mpCodeLayout)
->getNW4RLyt()->GetRootPane()->FindPaneByName("T_frnd_crd_00", true);
set_textbox(textPane, mString.mDisplayText);
friendText = mString.mDisplayText;
set_textbox(textPane, friendText);
mState = 0;
break;
}
@@ -2779,7 +2780,7 @@ void ipl::scene::AddressEdit::set_err_msg(wchar_t* outErrMsg, u32 outErrMsgLen,
swprintf(nwc24ErrStr, sizeof(nwc24ErrStr) / sizeof(wchar_t), L"%06d\n", errorCode);
wcsncat(outErrMsg, nwc24ErrStr, outErrMsgLen - wcslen(outErrMsg));
u32 messageId = MESG_ERROR_NWC24_SERVER;
u32 messageId;
switch (nwc24Err) {
case NWC24_ERR_NETWORK:
messageId = MESG_ERROR_NWC24_NETWORK;
@@ -2865,10 +2866,7 @@ void ipl::scene::AddressEdit::get_friendinfo() {
memcpy(&ipl::scene::sFriendInfo, &mpFriendCache->getInfo(mSelectedFriend),
sizeof(ipl::scene::sFriendInfo));
mString.setName(reinterpret_cast<const wchar_t*>(ipl::scene::sFriendInfo.attr.name));
const wchar_t* name = mString.mName;
nw4r::lyt::Pane* namePane =
mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_name_00", true);
set_textbox(namePane, name);
set_textbox(mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_name_00", true), mString.mName);
wchar_t wiiNo[0x100];
wchar_t email[0x102];
@@ -2881,10 +2879,7 @@ void ipl::scene::AddressEdit::get_friendinfo() {
ipl::utility::CharacterCode::ANSIToUTF16(email, reinterpret_cast<const u8*>(&ipl::scene::sFriendInfo.addr), 0x102);
mString.setEMail(email);
}
const wchar_t* displayText = mString.mDisplayText;
nw4r::lyt::Pane* friendCodePane =
mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_frnd_crd_00", true);
set_textbox(friendCodePane, displayText);
set_textbox(mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_frnd_crd_00", true), mString.mDisplayText);
memcpy(&mCreateID, &ipl::scene::sFriendInfo.attr.fdId, sizeof(mCreateID));
}

View File

@@ -237,10 +237,7 @@ bool MemoryCardManager::isIconValidate(u8 slot, s16 index) {
bool MemoryCardManager::isBannerEnable(u8 slot, s16 index) {
CardIcons* icons = reinterpret_cast<CardIcons*>(memorycard::getIconStateArray());
u32 file = mFile[slot][index].fileNo;
memorycard::IconState* icon = &icons[slot][file];
u8 enabled = icon->bannerEnable;
return enabled != 0;
return icons[slot][mFile[slot][index].fileNo].bannerEnable != 0;
}
void MemoryCardManager::update_icon_anm() {

View File

@@ -1341,13 +1341,11 @@ namespace ipl {
wchar_t* titleName = System::getChannelManager()->getTitleName(
page, channelIndex, 0);
memcpy(titleNames + *titleCount * 0x2a, titleName, 0x2a);
u32 nextTitleCount = *titleCount + 1;
*titleCount = nextTitleCount;
++*titleCount;
if (bytes < secondUsage[0] || blocks < secondUsage[1]) {
continue;
if (bytes >= secondUsage[0] && blocks >= secondUsage[1]) {
return true;
}
return true;
}
}
}

View File

@@ -3,6 +3,10 @@
#define IPL_SDMEMORY_DIALOG_STATE_ACCESSOR
#define IPL_SDMEMORY_COMPLETION_PCT_ACCESSOR
#define IPL_CHANNEL_TITLE_NOVTABLE
#include "math/iplInterporation.h"
#undef IPL_CHANNEL_TITLE_NOVTABLE
#include "scene/sdChannelTitle/iplSDChannelTitle.h"
#include "scene/sdChannelSelect/iplSDChannelSelect.h"
#include "system/iplSystem.h"
@@ -1554,15 +1558,5 @@ void SDChannelTitle::startResetting() {
snd::getSystem()->resetAllSound();
}
extern "C" void iplSDChannelTitle_onTitleButtonEvent(SDTitleButtonEventHandler* handler, u32 component,
u32 event, const controller::Interface* controller) {
handler->onEventDerived(component, event, controller);
}
extern "C" void iplSDChannelTitle_onTitlePaneEvent(SDTitlePaneEventHandler* handler, u32 component,
u32 event, const controller::Interface* controller) {
handler->onEvent(component, event, const_cast<controller::Interface*>(controller));
}
}
}

View File

@@ -1379,30 +1379,34 @@ namespace ipl {
return;
}
ext_ead::www::BrowserThread* browser = surface->GetBrowserThread();
if (browser == NULL) {
// One pointer, overwritten by the standard-buffer fetch, so the
// browser `this` and standardBuffer share a callee-saved reg.
void* held = surface->GetBrowserThread();
if (held == NULL) {
return;
}
if (browser->GetTextureBuffer(0, NULL) == NULL) {
if (static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(0, NULL) == NULL) {
return;
}
ext_ead::www::BrowserWindow* browserWindow =
static_cast<ext_ead::www::BrowserWindow*>(browser->mpBrowserWindows[0]);
if ((browserWindow != NULL ? browserWindow->unk_0x2C4[3] : 0) != 0) {
static_cast<ext_ead::www::BrowserWindow*>(static_cast<ext_ead::www::BrowserThread*>(held)->mpBrowserWindows[0]);
if ((browserWindow == NULL ? 0 : browserWindow->unk_0x2C4[3]) != 0) {
unk_0x91C[2] = 1;
mState = 0;
browserWindow = static_cast<ext_ead::www::BrowserWindow*>(browser->mpBrowserWindows[0]);
browserWindow = static_cast<ext_ead::www::BrowserWindow*>(static_cast<ext_ead::www::BrowserThread*>(held)->mpBrowserWindows[0]);
if (browserWindow != NULL) {
browserWindow->unk_0x2C4[3] = 0;
}
www::trasition::ScrollState scrollState = www::trasition::GetScrollState();
browserScrollDirection = scrollState == www::trasition::SCROLL_LEFT
? 1
: (scrollState == www::trasition::SCROLL_RIGHT ? -1 : 0);
if (scrollState == www::trasition::SCROLL_LEFT) {
browserScrollDirection = 1;
} else {
browserScrollDirection = scrollState == www::trasition::SCROLL_RIGHT ? -1 : 0;
}
www::trasition::ResetScrollState();
void* changedWideBuffer = browser->GetTextureBuffer(1, NULL);
void* changedStandardBuffer = browser->GetTextureBuffer(0, NULL);
void* changedWideBuffer = static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(1, NULL);
void* changedStandardBuffer = static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(0, NULL);
OSReport("changed %p %p\n", changedStandardBuffer, changedWideBuffer);
ext_ead::www::Heap::reportLeaHeap();
}
@@ -1415,8 +1419,9 @@ namespace ipl {
WWWRect* standardRect;
WWWRect* wideRect;
void* wideBuffer = browser->GetTextureBuffer(1, &wideRect);
void* standardBuffer = browser->GetTextureBuffer(0, &standardRect);
void* wideBuffer = static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(1, &wideRect);
held = static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(0, &standardRect);
void* standardBuffer = held;
nw4r::ut::Rect projection4x3;
System::getProjectionRect4x3(&projection4x3);
int screenWidth = abs(static_cast<int>(projection4x3.GetWidth()));
@@ -1443,33 +1448,33 @@ namespace ipl {
int wideWidth = abs(static_cast<int>(projection16x9.GetWidth()));
int wideHeight = abs(static_cast<int>(projection16x9.GetHeight()));
f32 wideLeft = -wideWidth / 2;
f32 wideTop = wideHeight / 2;
f32 wideTopL = wideHeight / 2;
f32 wideRight = wideWidth / 2;
nw4r::ut::Rect leftSide(wideLeft, wideTop,
f32 wideTopR = wideHeight / 2;
nw4r::ut::Rect leftSide(wideLeft, wideTopL,
wideLeft + sideDescriptor->textureHeader->width,
wideTop - sideDescriptor->textureHeader->height);
wideTopL - sideDescriptor->textureHeader->height);
nw4r::ut::Rect rightSide(wideRight - sideDescriptor->textureHeader->width,
wideTop, wideRight, wideTop - sideDescriptor->textureHeader->height);
wideTopR, wideRight, wideTopR - sideDescriptor->textureHeader->height);
if (browserScrollDirection != 0) {
nw4r::lyt::Material* wideMaterial =
void* wideMaterial =
mpChangeLayout->FindPaneByName("N_Tra0")->FindMaterialByName("Tex0");
nw4r::lyt::Material* firstStandardMaterial =
mpChangeLayout->FindPaneByName("N_Tra0")->FindMaterialByName("Tex1");
nw4r::lyt::Material* secondStandardMaterial =
mpChangeLayout->FindPaneByName("N_Tra0")->FindMaterialByName("Tex2");
wideMaterial->SetTexture(0, wideTexture);
static_cast<nw4r::lyt::Material*>(wideMaterial)->SetTexture(0, wideTexture);
firstStandardMaterial->SetTexture(0, standardTexture);
secondStandardMaterial->SetTexture(0, standardTexture);
mpChangeLayout->FindPaneByName("N_Tra0")->SetVisible(true);
if (browserScrollDirection == 1) {
utility::FrameController* animation = mpSecondAnimation;
animation->initFrame();
animation->restart();
wideMaterial = mpSecondAnimation;
static_cast<utility::FrameController*>(wideMaterial)->initFrame();
static_cast<utility::FrameController*>(wideMaterial)->restart();
} else {
utility::FrameController* animation = mpFirstAnimation;
animation->initFrame();
animation->restart();
wideMaterial = mpFirstAnimation;
static_cast<utility::FrameController*>(wideMaterial)->initFrame();
static_cast<utility::FrameController*>(wideMaterial)->restart();
}
mpChangeLayout->calc();
browserScrollDirection = 0;
@@ -1509,13 +1514,44 @@ namespace ipl {
}
if (mpWiiSettingFlag->smthMsgData >= 2 && mpWiiSettingFlag->smthMsgData <= 7) {
GXRenderModeObj renderMode = *System::getRenderModeObj();
GXRenderModeObj* pRmode = System::getRenderModeObj();
GXRenderModeObj renderMode;
volatile GXRenderModeObj* srcMode = pRmode;
volatile GXRenderModeObj* dstMode = &renderMode;
int n = 12;
u8* src;
u8* dst = &renderMode.aa;
src = &pRmode->aa;
dstMode->viTVmode = srcMode->viTVmode;
dstMode->fbWidth = srcMode->fbWidth;
dstMode->efbHeight = srcMode->efbHeight;
dstMode->xfbHeight = srcMode->xfbHeight;
dstMode->viXOrigin = srcMode->viXOrigin;
dstMode->viYOrigin = srcMode->viYOrigin;
dstMode->viWidth = srcMode->viWidth;
dstMode->viHeight = srcMode->viHeight;
dstMode->xFBmode = srcMode->xFBmode;
dstMode->field_rendering = srcMode->field_rendering;
dstMode->aa = srcMode->aa;
for (; n != 0; n--) {
dst[1] = src[1];
dst[2] = src[2];
src += 2;
dst += 2;
}
dstMode->vfilter[0] = srcMode->vfilter[0];
dstMode->vfilter[1] = srcMode->vfilter[1];
dstMode->vfilter[2] = srcMode->vfilter[2];
dstMode->vfilter[3] = srcMode->vfilter[3];
dstMode->vfilter[4] = srcMode->vfilter[4];
dstMode->vfilter[5] = srcMode->vfilter[5];
dstMode->vfilter[6] = srcMode->vfilter[6];
u32 left;
u32 top;
u32 width;
u32 height;
GXGetScissor(&left, &top, &width, &height);
GXSetScissor(0, renderMode.efbHeight / 2 - 0xA4, renderMode.fbWidth, 0x132);
GXSetScissor(0, dstMode->efbHeight / 2 - 0xA4, dstMode->fbWidth, 0x132);
mpMainLayout->draw();
GXSetScissor(left, top, width, height);
}

View File

@@ -931,17 +931,15 @@ void CArGBAOdh::cdj_c_makeHeader(SArCDJ_OdhMaster* master, u32 size) {
}
s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int format) {
u32 paddedWidth;
u16 width;
u16 height;
u8* workPlane;
int sourceStride;
u8* crPlane;
u8* cbPlane;
u8* crPlane;
u16* dimensions;
int rowIndex;
int sourceStride;
int i;
u16 dimension;
u16 paddedDimensions[2];
dimensions = &master->width;
@@ -952,11 +950,11 @@ s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int for
height = dimensions[1];
for (i = 0; i < 2; i++) {
dimension = dimensions[i];
if ((dimension & 7) != 0) {
paddedDimensions[i] = (dimension + 8) - (dimension & 7);
u16 remainder = dimensions[i] & 7;
if (remainder != 0) {
paddedDimensions[i] = (dimensions[i] + 8) - remainder;
} else {
paddedDimensions[i] = dimension;
paddedDimensions[i] = dimensions[i];
}
}
@@ -972,13 +970,12 @@ s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int for
}
}
paddedWidth = paddedDimensions[0];
for (rowIndex = 0; rowIndex < (s32)height; rowIndex++) {
LineConv11(sourceData + (rowIndex & 3) * 8 + rowIndex / 4 * sourceStride, workPlane, cbPlane, crPlane,
dimensions[0], dimensions[1], (const long*)gArConvPlttTbl, format);
workPlane += paddedWidth;
cbPlane += paddedWidth;
crPlane += paddedWidth;
workPlane += paddedDimensions[0];
cbPlane += paddedDimensions[0];
crPlane += paddedDimensions[0];
}
return 0;
@@ -1362,12 +1359,10 @@ s32 CArGBAOdh::cdj_d_initializeDecompressOdh(SArCDJ_OdhMaster* master, u8* workB
}
s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int workSize) {
int blockStride;
int workBufferSize = workSize;
u8 xSampling;
u8 coefficientIndex;
u16 blockWidth;
int blockRowStride;
int planeOffset;
u32 sourceLimit = srcSize;
int statusOrOffset;
@@ -1380,8 +1375,6 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
blockWidth = master->blocksWide;
blockRowSize = (u32)blockWidth * 0x38;
rowStride = (u32)blockWidth << 3;
blockRowStride = blockRowSize * 2;
blockStride = (u32)blockWidth << 4;
do {
xSampling = master->xSampling;
if ((xSampling == 1U) && (master->ySampling == 1U)) {
@@ -1412,9 +1405,9 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
coefficientIndex = odh_natural_order[naturalIndex];
master->coefficients[coefficientIndex] = master->dcCoefficients[naturalIndex];
}
statusOrOffset = ((u32)master->blockY << 6) * (u32)master->blocksWide +
((u32)master->blocksHigh * ((u32)master->blocksWide << 6) +
(u32)master->blockX * 8);
statusOrOffset = (u32)master->blockX * 8 +
(u32)master->blocksWide * ((u32)master->blockY << 6) +
(u32)master->blocksHigh * ((u32)master->blocksWide << 6);
if (statusOrOffset + blockRowSize + 8 > workBufferSize) {
statusOrOffset = -0x7ffffffa;
goto finishBlock;
@@ -1454,14 +1447,14 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
}
planeOffset = (u32)master->blockX * 0x10 +
(u32)master->blocksWide * ((u32)master->blockY << 6) * 2;
requiredBlockEnd = planeOffset + blockRowStride + 8;
requiredBlockEnd = planeOffset + (blockRowSize * 2) + 8;
if (requiredBlockEnd > workBufferSize) {
statusOrOffset = -0x7ffffffa;
goto finishBlock;
}
idct_fast
(range_limit,master->quantizationTables,master->coefficients,master->workBuffer + planeOffset
,blockStride);
, ((u32)blockWidth << 4));
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
master->chrominanceRequest.bitstream = master->luminanceRequest.bitstream;
@@ -1477,7 +1470,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
}
idct_fast
(range_limit,master->quantizationTables,master->coefficients,
planeOffset + master->workBuffer + 8,blockStride);
(u8*)((u32)planeOffset + (u32)master->workBuffer) + 8, ((u32)blockWidth << 4));
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 1, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
@@ -1543,7 +1536,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
coefficientIndex = odh_natural_order[naturalIndex];
master->coefficients[coefficientIndex] = master->dcCoefficients[naturalIndex];
}
planeOffset = planeOffset + (u32)master->blocksWide * 0x40;
planeOffset += (u32)master->blocksWide << 6;
if (planeOffset + blockRowSize + 8 > workBufferSize) {
statusOrOffset = -0x7ffffffa;
goto finishBlock;
@@ -1600,14 +1593,14 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
}
planeOffset = (u32)master->blockX * 0x10 +
(u32)master->blocksWide * ((u32)master->blockY << 6) * 4;
requiredBlockEnd = planeOffset + blockRowStride + 8;
requiredBlockEnd = planeOffset + (blockRowSize * 2) + 8;
if (requiredBlockEnd > workBufferSize) {
statusOrOffset = -0x7ffffffa;
goto finishBlock;
}
idct_fast
(range_limit,master->quantizationTables,master->coefficients,master->workBuffer + planeOffset
,blockStride);
, ((u32)blockWidth << 4));
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
@@ -1618,13 +1611,13 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
}
int nextOffset = planeOffset + 8;
planeOffset = nextOffset;
if (nextOffset + blockRowStride + 8 > workBufferSize) {
if (nextOffset + (blockRowSize * 2) + 8 > workBufferSize) {
statusOrOffset = -0x7ffffffa;
goto finishBlock;
}
idct_fast
(range_limit,master->quantizationTables,master->coefficients,master->workBuffer + nextOffset
,blockStride);
, ((u32)blockWidth << 4));
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
@@ -1633,15 +1626,16 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
coefficientIndex = odh_natural_order[naturalIndex];
master->coefficients[coefficientIndex] = master->dcCoefficients[naturalIndex];
}
planeOffset = planeOffset + (u32)master->blocksWide * 0x80 + -8;
requiredBlockEnd = planeOffset + blockRowStride + 8;
if (requiredBlockEnd > workBufferSize) {
// Store the updated plane in requiredBlockEnd so MWCC keeps it in r15.
requiredBlockEnd = planeOffset + (u32)master->blocksWide * 0x80 + -8;
planeOffset = requiredBlockEnd + (blockRowSize * 2) + 8;
if (planeOffset > workBufferSize) {
statusOrOffset = -0x7ffffffa;
goto finishBlock;
}
idct_fast
(range_limit,master->quantizationTables,master->coefficients,master->workBuffer + planeOffset
,blockStride);
(range_limit,master->quantizationTables,master->coefficients,master->workBuffer + requiredBlockEnd
, ((u32)blockWidth << 4));
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
master->chrominanceRequest.bitstream = master->luminanceRequest.bitstream;
@@ -1651,13 +1645,13 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
coefficientIndex = odh_natural_order[naturalIndex];
master->coefficients[coefficientIndex] = master->dcCoefficients[naturalIndex];
}
if (requiredBlockEnd + 8 > workBufferSize) {
if (planeOffset + 8 > workBufferSize) {
statusOrOffset = -0x7ffffffa;
goto finishBlock;
}
idct_fast
(range_limit,master->quantizationTables,master->coefficients,
planeOffset + master->workBuffer + 8,blockStride);
(u8*)((u32)requiredBlockEnd + (u32)master->workBuffer) + 8, ((u32)blockWidth << 4));
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 1, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
@@ -1696,9 +1690,9 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
(range_limit,master->quantizationTables + 64,master->coefficients,master->workBuffer + statusOrOffset,
rowStride);
}
blockX = master->blockX + 1;
master->blockX = blockX;
if (blockX == master->blocksWide) {
int nextBlockX = master->blockX + 1;
master->blockX = nextBlockX;
if ((u16)nextBlockX == master->blocksWide) {
master->blockX = 0;
master->blockY = master->blockY + 1;
}

View File

@@ -884,172 +884,187 @@ namespace ipl {
return ret;
}
void ESMisc::DeleteUnauthorizedData(EGG::Heap* heap) {
u32 titleCount = 0;
ESTitleId* titleIds = NULL;
char path[88];
static inline void verifySavedataZD(EGG::Heap* heap, ESTitleId titleId, NANDFileInfo* fileInfo) {
char path[NAND_MAX_PATH];
s32 ret;
u8* saveData = NULL;
BOOL fileOpen = FALSE;
BOOL deleteSaveData = FALSE;
sprintf(path, "/title/%08x/%08x/data/%s", (u32)((titleId & 0x00FFFFFFFFFFFFFFULL) >> 32), (u32)(titleId & 0x00FFFFFFFFFFFFFFULL), "zeldaTp.dat");
if (!ESMisc::ChangeUid(titleId)) {
OSReport("%s::%s: ChangeUid failed\n", __FILE__, __FUNCTION__);
ESMisc::DeleteTitle(heap, titleId);
} else {
ret = NANDPrivateOpen(path, fileInfo, NAND_ACCESS_READ);
if (ret == NAND_RESULT_NOEXISTS) {
OSReport("%s::%s: Does not exist %s: %d\n", __FILE__, __FUNCTION__, path, ret);
} else if (ret != NAND_RESULT_OK) {
OSReport("%s::%s: Open save data file failed: %d\n", __FILE__, __FUNCTION__, ret);
} else {
fileOpen = TRUE;
saveData = (u8*)heap->alloc(0x4000, -DEFAULT_ALIGN);
if (saveData == NULL) {
OSReport("%s::%s: Alloc failed: %d\n", __FILE__, __FUNCTION__, -2);
} else {
memset(saveData, 0, 0x4000);
ret = NANDRead(fileInfo, saveData, 0x4000);
if (ret < 0) {
OSReport("%s::%s: Read file failed: %d\n", __FILE__, __FUNCTION__, ret);
goto cleanup;
} else if (ret != 0x4000) {
OSReport("%s::%s: File size is not correct: %d\n", __FILE__, __FUNCTION__, ret);
deleteSaveData = TRUE;
} else {
u32 offset = 8;
u32 j = 0;
BOOL valid = FALSE;
while (j < 3) {
u8* block = saveData + offset;
if (!checkForNullTermination((char*)block + 0x4e, 8) ||
!checkForNullTermination((char*)block + 0x58, 8) ||
!checkForNullTermination((char*)block + 0x72, 8) ||
!checkForNullTermination((char*)block + 0x8e, 8) ||
!checkForNullTermination((char*)block + 0x1b4, 0x11) ||
!checkForNullTermination((char*)block + 0x1c5, 0x11)) {
goto verify_failed;
}
j++;
offset += 0xa94;
}
offset = 0x2008;
j = 0;
while (j < 3) {
u8* block = saveData + offset;
if (!checkForNullTermination((char*)block + 0x4e, 8) ||
!checkForNullTermination((char*)block + 0x58, 8) ||
!checkForNullTermination((char*)block + 0x72, 8) ||
!checkForNullTermination((char*)block + 0x8e, 8) ||
!checkForNullTermination((char*)block + 0x1b4, 0x11) ||
!checkForNullTermination((char*)block + 0x1c5, 0x11)) {
goto verify_failed;
}
j++;
offset += 0xa94;
}
valid = TRUE;
verify_failed:
if (!valid) {
OSReport("%s::%s: Verify failed for %016llx\n", __FILE__, __FUNCTION__,
titleId);
deleteSaveData = TRUE;
}
}
NANDClose(fileInfo);
fileOpen = FALSE;
if (deleteSaveData) {
ESMisc::DeleteSavedata(titleId, heap);
}
}
}
}
cleanup:
if (saveData != NULL) {
heap->free(saveData);
}
if (fileOpen) {
NANDClose(fileInfo);
}
ESMisc::ChangeUid(SYSMENU_TITLE_ID);
}
static inline s32 DeleteTicketsForce(EGG::Heap* heap, ESTitleId titleId, u8* ticketViews, u32* ticketViewCount) {
ESTicketView* ticketViewList = NULL;
s32 ret;
memset(ticketViews, 0, OSRoundUp32B(sizeof(ESTicketView)));
ret = ES_GetTicketViews(titleId, NULL, ticketViewCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret, titleId);
goto cleanup;
}
if (*ticketViewCount == 0) {
return ret;
}
ticketViewList = (ESTicketView*)heap->alloc(*ticketViewCount * OSRoundUp32B(sizeof(ESTicketView)), -DEFAULT_ALIGN);
ret = ES_GetTicketViews(titleId, ticketViewList, ticketViewCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret, titleId);
goto cleanup;
}
for (u32 j = 0; j < *ticketViewCount; j++) {
memcpy(ticketViews, (u8*)ticketViewList + j * sizeof(ESTicketView), sizeof(ESTicketView));
ret = ES_DeleteTicket((ESTicketView*)ticketViews);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_DeleteTicket failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret,
((ESTicketView*)ticketViews)->ticketId);
}
}
cleanup:
if (ticketViewList != NULL) {
heap->free(ticketViewList);
}
return ret;
}
static inline s32 InitSavedata(EGG::Heap* heap) {
u8 ticketViews[OSRoundUp32B(sizeof(ESTicketView))] ALIGN32;
NANDFileInfo fileInfo ALIGN32;
u8 ticketViews[0xe0] ALIGN32;
u32 ticketViewCount;
ESTicketView* ticketViewList;
ESTitleId* titleIds = NULL;
u32 titleCount = 0;
s32 ret = ES_ListTitlesOnCard(NULL, &titleCount);
if (ret == ES_ERR_OK) {
titleIds = (ESTitleId*)heap->alloc(OSRoundUp32B(titleCount * sizeof(ESTitleId)), -DEFAULT_ALIGN);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard1: %d\n", __FILE__, __FUNCTION__, ret);
goto cleanup;
}
titleIds = (ESTitleId*)heap->alloc(OSRoundUp32B(titleCount * sizeof(ESTitleId)), -DEFAULT_ALIGN);
if (titleIds == NULL) {
OSReport("%s::%s: Unable to allocate\n", __FILE__, "InitSavedata");
} else {
ret = ES_ListTitlesOnCard(titleIds, &titleCount);
if (ret == ES_ERR_OK) {
u32 titleIdOffset = 0;
for (u32 i = 0; i < titleCount; i++) {
u32 titleIdHi = *(u32*)((u8*)titleIds + titleIdOffset);
u32 titleIdLo = *(u32*)((u8*)titleIds + titleIdOffset + 4);
if ((titleIdLo & 0xffffff00) == 0x525a4400 && titleIdHi == 0x10000) {
u8* saveData = NULL;
BOOL fileOpen = FALSE;
BOOL deleteSaveData = FALSE;
sprintf(path - 8, "/title/%08x/%08x/data/%s", titleIdHi & 0xffffff, titleIdLo, "zeldaTp.dat");
if (!ChangeUid(((ESTitleId)titleIdHi << 32) | titleIdLo)) {
OSReport("%s::%s: ChangeUid failed\n", __FILE__, "verifySavedataZD");
DeleteTitle(heap, ((ESTitleId)titleIdHi << 32) | titleIdLo);
} else {
ret = NANDPrivateOpen(path - 8, (NANDFileInfo*)((u8*)&fileInfo - 0x20), NAND_ACCESS_READ);
if (ret == NAND_RESULT_NOEXISTS) {
OSReport("%s::%s: Does not exist %s: %d\n", __FILE__, "verifySavedataZD", path - 8, ret);
} else if (ret != NAND_RESULT_OK) {
OSReport("%s::%s: Open save data file failed: %d\n", __FILE__, "verifySavedataZD", ret);
} else {
fileOpen = TRUE;
saveData = (u8*)heap->alloc(0x4000, -DEFAULT_ALIGN);
if (saveData == NULL) {
OSReport("%s::%s: Alloc failed: %d\n", __FILE__, "verifySavedataZD", -2);
} else {
memset(saveData, 0, 0x4000);
ret = NANDRead((NANDFileInfo*)((u8*)&fileInfo - 0x20), saveData, 0x4000);
if (ret < 0) {
OSReport("%s::%s: Read file failed: %d\n", __FILE__, "verifySavedataZD", ret);
} else if (ret != 0x4000) {
OSReport("%s::%s: File size is not correct: %d\n", __FILE__, "verifySavedataZD", ret);
deleteSaveData = TRUE;
} else {
u32 offset = 8;
u32 j = 0;
BOOL valid = FALSE;
while (j < 3) {
u8* block = saveData + offset;
if (!checkForNullTermination((char*)block + 0x4e, 8) ||
!checkForNullTermination((char*)block + 0x58, 8) ||
!checkForNullTermination((char*)block + 0x72, 8) ||
!checkForNullTermination((char*)block + 0x8e, 8) ||
!checkForNullTermination((char*)block + 0x1b4, 0x11) ||
!checkForNullTermination((char*)block + 0x1c5, 0x11)) {
goto verify_failed;
}
j++;
offset += 0xa94;
}
offset = 0x2008;
j = 0;
while (j < 3) {
u8* block = saveData + offset;
if (!checkForNullTermination((char*)block + 0x4e, 8) ||
!checkForNullTermination((char*)block + 0x58, 8) ||
!checkForNullTermination((char*)block + 0x72, 8) ||
!checkForNullTermination((char*)block + 0x8e, 8) ||
!checkForNullTermination((char*)block + 0x1b4, 0x11) ||
!checkForNullTermination((char*)block + 0x1c5, 0x11)) {
goto verify_failed;
}
j++;
offset += 0xa94;
}
valid = TRUE;
verify_failed:
if (!valid) {
OSReport("%s::%s: Verify failed for %016llx\n", __FILE__, "verifySavedataZD",
((ESTitleId)titleIdHi << 32) | titleIdLo);
deleteSaveData = TRUE;
}
}
NANDClose((NANDFileInfo*)((u8*)&fileInfo - 0x20));
fileOpen = FALSE;
if (deleteSaveData) {
DeleteSavedata(((ESTitleId)titleIdHi << 32) | titleIdLo, heap);
}
}
}
}
if (saveData != NULL) {
heap->free(saveData);
}
if (fileOpen) {
NANDClose((NANDFileInfo*)((u8*)&fileInfo - 0x20));
}
ChangeUid(SYSMENU_TITLE_ID);
continue;
}
if ((((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x0001000844495343ULL ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) < 0x0001000844495343ULL &&
((((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x000100014a4f4449ULL ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) > 0x000100014a4f4449ULL &&
(((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x0001000148415858ULL))) ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) > 0x0001000844495343ULL &&
((((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x0001000844564458ULL ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) > 0x0001000844564458ULL &&
(((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x000100084449534bULL)))) {
ESTitleId titleId = *(ESTitleId*)((u8*)titleIds + titleIdOffset);
ES_DeleteTitle(titleId);
ticketViewList = NULL;
memset(ticketViews, 0, sizeof(ticketViews));
ret = ES_GetTicketViews(titleId, NULL, &ticketViewCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", ret, titleId);
} else if (ticketViewCount != 0) {
ticketViewList = (ESTicketView*)heap->alloc(ticketViewCount * 0xe0, -DEFAULT_ALIGN);
ret = ES_GetTicketViews(titleId, ticketViewList, &ticketViewCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", ret, titleId);
} else {
for (u32 j = 0; j < ticketViewCount; j++) {
memcpy(ticketViews, (u8*)ticketViewList + j * sizeof(ESTicketView), 0xd8);
ret = ES_DeleteTicket((ESTicketView*)ticketViews);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_DeleteTicket failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", ret,
((ESTicketView*)ticketViews)->ticketId);
}
}
}
}
if (ticketViewList != NULL) {
heap->free(ticketViewList);
}
}
titleIdOffset += 8;
OSReport("%s::%s: Unable to allocate\n", __FILE__, __FUNCTION__);
goto cleanup;
}
} else {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard2: %d\n", __FILE__, "InitSavedata", ret);
}
}
} else {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard1: %d\n", __FILE__, "InitSavedata", ret);
ret = ES_ListTitlesOnCard(titleIds, &titleCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard2: %d\n", __FILE__, __FUNCTION__, ret);
goto cleanup;
}
{
u8* ticketScratch = ticketViews;
for (u32 i = 0; i < titleCount; i++) {
if ((titleIds[i] & 0xFFFFFFFFFFFFFF00ULL) == 0x00010000525A4400ULL) {
verifySavedataZD(heap, titleIds[i], &fileInfo);
continue;
}
switch (titleIds[i]) {
case 0x0001000844495343ULL:
case 0x000100014A4F4449ULL:
case 0x0001000148415858ULL:
case 0x0001000844564458ULL:
case 0x000100084449534BULL:
ES_DeleteTitle(titleIds[i]);
DeleteTicketsForce(heap, titleIds[i], ticketScratch, &ticketViewCount);
break;
}
}
}
cleanup:
if (titleIds != NULL) {
heap->free(titleIds);
}
return;
return ret;
}
s32 ESMisc::DeleteUnauthorizedData(EGG::Heap* heap) {
return InitSavedata(heap);
}
BOOL checkForNullTermination(char* str, u32 len) {

View File

@@ -0,0 +1,41 @@
# CHANSVm load-constant error preservation
Baseline: 449529d92405f8f7fda610660c7794914a81dfe6. Scope: CHANSVm.c only; no linking classifications or headers changed.
## Retained correction
LOAD_STRING_CONST must preserve a failure from CHANSVmDeleteObject. The original object tests the deletion return and branches directly to the local result merge when it is nonzero. The load-string error is selected only after deletion succeeds and the constant index is out of range or has no string payload. The prior C instead overwrote every deletion error with CHANS_VM_ERR_LOAD_STRING_CONST.
A native destructor that returns false is a concrete error-producing path through CHANSVmDeleteObject; this distinction is observable, not merely a compiler-scheduling preference.
The new local loadResult preserves that error, keeps constant validation and installation inside the successful-deletion block, and merges the result afterward. Target and rebuilt blocks have the same instruction count and control-flow destinations; remaining operand differences are registers. No strings, data layout, or generated jump-table destinations changed.
## Measurements
- All 233 target functions have compiled C implementations; this is not a claim that all are exact or independently behavior-proven.
- Instruction-exact functions: 221/233 -> 221/233; every objdiff-exact function also passes ctxdiff.
- Unit decompiled/fuzzy: 99.364426% -> 99.383840%.
- Exact code: 37608/53564 bytes -> 37608/53564 bytes (70.211334%).
- Exact data: 6904/6904 bytes -> 6904/6904 bytes (100%).
- CHANSVmStep: 96.466080% -> 96.673584%; 1253/1253 instructions; ctxdiff differing positions 314 -> 297.
- Per-function score regressions relative to the fresh baseline report: zero.
- The unit remains NonMatching/unlinked; no link flags were changed.
## Attempts
1. Read previous round/wave logs and recent local trials; establish live baseline and run pool_diff first: 125 strings identical.
2. Replace the load-string shared error/goto path with a typed local error result and successful-deletion-only constant validation. Retained: correct error behavior, higher fuzzy score, unchanged exact code/data.
3. Separately tried consolidating GET_PROPERTY_NAME's local found flag and removing two unused array-index assignments. Rejected and restored completely: Step shrank to 1249 instructions and data dropped to 2232/6904. This unrelated trial is absent from the final source.
## Validation
- Full 43U build passed with the assigned wibo wrapper and WIBO_SJIS_MISSING_IMPORTS=1.
- DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
- pool_diff: 125/125 identical strings.
- .data: 4672/4672 bytes identical; all 352 canonical relocations identical.
- .rodata: 1432/1432 bytes identical; all 258 canonical relocations identical.
- All 233 functions compared with ctxdiff/odiff: 221 exact; no falsely exact objdiff functions.
- git diff --check passed.
- Source-extracted host C harness passed six load-constant cases: missing operand; deletion failure with valid index; deletion failure with invalid index; invalid index after successful deletion; null payload; successful installation. The harness stubs surrounding VM dependencies and checks C behavior only; no Wii runtime execution is claimed.
Source is paused after this focused candidate for parent review. The remaining 12 functions are still non-exact.

View File

@@ -0,0 +1,49 @@
# CHANSVm opcode error-path reconstruction
Baseline: 2f399716. This is a separate structural-reconstruction candidate; it preserves the preceding LOAD_STRING_CONST behavior fix. Only CHANSVm.c changed apart from this log. No headers, linking flags, remote branches, or original assets were changed.
## Retained changes and target evidence
- Failed binary-operand conversion returns CHANS_VM_ERR_RESULT_TYPE directly. Target Step relative +0x410 selects the error and +0x414 returns through +0x1364.
- Invalid GET_PROPERTY_NAME and JUMP destinations return CHANS_VM_ERR_CODE_RANGE directly. Target error tails are +0xd90/+0xd94 and +0xefc/+0xf00, respectively, both ending at +0x1364.
- DELETE_INDIRECT has a typed accumulator and a local deletion result, and reads the index through value.data.len rather than an offset-based u32 pointer cast. SET_INDEX elsewhere in the same function establishes this field as the index-reference index. The target holds the opcode-local result until the merge at +0xfb0, then assigns the common interpreter status. The rebuilt +0xf80 through +0xfb4 block is instruction-identical to the target.
These preserve existing C behavior. Unlike the preceding deletion-error fix, no new behavioral defect is claimed.
## Measurements
- Exact functions: 221/233 -> 221/233. Every previously exact function remains instruction-exact, not merely objdiff-exact.
- Decompiled/fuzzy unit: 99.383840% -> 99.406320%.
- CHANSVmStep: 96.673584% -> 96.913800%; 1253/1253 instructions; differing positions 297 -> 285.
- Exact code: unchanged, 37608/53564 bytes (70.211334%).
- Exact data: unchanged, 6904/6904 bytes (100%).
- Per-function score regressions: zero.
- Unit remains NonMatching/unlinked; twelve functions remain non-exact.
## Rejected investigations
All rejected source changes were restored, and no register forcing or declaration-order sweep was used.
- GET_PROPERTY_NAME output-state separation: a local found flag, initialized flag, shared index/output, and inline helper. These produced 1251-1253 instructions but moved generated data-table destinations; rejected.
- Direct result-type-table accesses, an explicit zero-count normalization/pretested loop, and indexed operand-type enumeration: 1254-1257 instructions; generated data-table destinations moved; rejected.
- Internal linkage for result-type or constant-header tables, individually and together, did not change those results; restored.
- CASE strict-comparison result separation, case-local match state, byte-sized operand types, and indexed operand enumeration: improved some local structure but introduced an operand-type spill and 1254-1255 instructions; generated tables moved; rejected.
- Direct exceptional returns alone: retained for combination, 96.697525%, data 100%.
- Typed DELETE_INDIRECT and local result alone: retained for combination, 96.889860%, data 100%.
- Combined direct returns and typed deletion result: accepted candidate, 96.913800%, data 100%.
- A first combination script used an obsolete substring end offset and did not compile; restored, corrected, and rerun. No source from the malformed attempt remains.
- Adding strict-comparison restructuring to the retained combination still produced 1254 instructions and data regression; rejected.
## Validation
- Full 43U build passed with the assigned wrapper and WIBO_SJIS_MISSING_IMPORTS=1.
- DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
- pool_diff: 125/125 strings identical.
- .data: 4672/4672 raw bytes and 352/352 canonical relocations identical.
- .rodata: 1432/1432 raw bytes and 258/258 canonical relocations identical.
- All 233 target functions compared: 221 instruction-exact; zero falsely exact objdiff functions; zero per-function score regressions from 2f399716.
- Narrow-string-reference audit: all 233 functions analyzed, 40 arguments checked, no candidates/errors/skips.
- Source-extracted host C tests: four DELETE_INDIRECT cases passed (wrong type, successful deletion, deletion failure, and null element forwarding), including exact unsigned index forwarding. The six prior LOAD_STRING_CONST cases also passed unchanged. These stub surrounding VM dependencies and are not Wii runtime tests.
- git diff --check passed.
The focused candidate is paused for independent parent review.

View File

@@ -0,0 +1,52 @@
# CHANSVm typed comparison reconstruction
Baseline: ec75ddb0. This candidate is separate from the accepted load-string and opcode-error-path work. Those commits and their logs are unchanged. Only CHANSVm.c and this log changed; no headers, linking classifications, metadata, or original assets changed.
## Retained reconstruction
- LOAD_FLOAT copies the eight-byte literal into a double scratch member and passes that value directly. This replaces a u64 temporary followed by a double-pointer reinterpretation. Scratch alignment, member offsets, and emitted code are unchanged.
- SET_INDEX reads the floating operand through its union member and checks its lower bound before its upper bound, matching the target's comparison order. The accepted interval remains [0, 4294967294], with NaN and infinities rejected.
- Strict integer equality uses the declared 64-bit integer values rather than four offset-based u32 loads and manual XOR/OR expressions.
- Strict floating equality uses the declared floating values directly.
- Strict string equality uses named, read-only payload pointers rather than recreating a header pointer. The stack operand is consistently first in the outer type comparison, following the target.
This is structural/type reconstruction, not a newly discovered behavior fix. No register forcing, declaration sweep, or alignment padding was introduced.
## Target evidence
After rebuilding, the integer-comparison block (Step instructions 1093-1102), floating-comparison block (1103-1108), string-comparison block (1109-1128), and floating-index block (703-712) have the same instructions, control flow, constants, and memory offsets as the target after register names are normalized. This comparison is advisory: register differences remain, and Step is not exact.
The floating range's instruction forms now use the target's lower-bound-first order. Integer equality emits the same target ten-instruction two-word equality sequence naturally from the 64-bit value comparison. LOAD_FLOAT retains its original eight-byte copy and call sequence without a pointer reinterpretation.
## Measurements
- Instruction-exact functions: 221/233 -> 221/233; no previously exact function regressed.
- Unit Decompiled/fuzzy: 99.406320% -> 99.413185%.
- Step: 96.913800% -> 96.987230%; 1253/1253 instructions; differing positions 285 -> 276.
- Exact code: unchanged at 37608/53564 bytes (70.211334%).
- Exact data: unchanged at 6904/6904 bytes (100%).
- Per-function score regressions: zero.
- Unit remains NonMatching/unlinked, with twelve non-exact functions.
## Attempts
- Direct 64-bit equality alone: Step 96.933760%, data 100%; retained for combination.
- Typed integer/float/string comparison paths: 96.971270%, data 100%; retained.
- Those typed paths plus a separate strict-comparison local error result: 1254 instructions, table relocations moved; rejected.
- Floating index member access alone preserves the typed-comparison score. Lower-bound-first range checking raises it to 96.983240%, data 100%; retained.
- A union literal temporary produced the same code; simplified to a direct double member instead, also with identical code.
- Stack-first type comparison raises Step to 96.987230% with unchanged data; retained.
## Verification
- Full 43U build passed with the assigned wrapper and WIBO_SJIS_MISSING_IMPORTS=1.
- DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
- pool_diff: all 125 strings identical.
- .data: 4672/4672 raw bytes and 352/352 canonical relocations identical.
- .rodata: 1432/1432 raw bytes and 258/258 canonical relocations identical.
- All 233 functions checked with ctxdiff/odiff: 221 instruction-exact; no falsely exact objdiff functions.
- Literal-reference audit: 233 functions analyzed, 40 resolvable call-string arguments checked, no candidates/errors/skips.
- Source-extracted host C harnesses passed 20 strict-comparison cases, nine floating-index-bound cases, and eight floating-literal bit patterns. Coverage includes signed integer extremes, differing high words, signed zero, NaN, infinities, strings, references, deletion errors, and literal payload preservation. They stub surrounding dependencies and do not constitute Wii runtime execution.
- git diff --check passed.
Source is paused for independent parent verification.

View File

@@ -0,0 +1,78 @@
# AES key-schedule cursor reconstruction, 2026-10-02
Source baseline: `449529d9`. This separate candidate follows the frozen MD5
commit `521056a9`; it changes only `libs/RevoEX/src/net/aes.c` and this log.
43U only. No linking flags, configuration, tables, or public API edits.
## Target evidence and retained change
`AESiDecryptBlock` in `build/43U/obj/libs/RevoEX/src/net/aes.o` is 0x3EC bytes /
251 instructions. Its entry first forms the key-schedule base at context+0x10
(function-relative offset 0x18), extracts the last-round offset from the flags
word (offset 0x24), and adds that offset to the already formed base (offset
0x28). The baseline combined initializer produced 249 instructions. Explicitly
initializing the typed key pointer to `context->keys` before advancing it by
`rounds*4` recovers the target's two-stage pointer construction and body size.
The retained change is two added source lines and one removed line. All AES
round expressions, lazy inverse key transformation, tables and CBC chaining
remain unchanged.
This is a structural matching improvement, not a newly implemented AES path.
Both existing block algorithms were already present and pass the behavior tests.
## Explored and rejected alternatives
- Inlined single-word round helpers, byte-typed table lookups and table-rotation
helpers changed scheduling but regressed encryption or added source complexity.
- Staging four inverse-mix column outputs through a typed round helper improved
decrypt similarity but required substantially more source and still did not
match. Not retained.
- Alternate inverse-key-transform local lifetimes and an inverse-key helper
gave only small extra fuzzy movement, without new algorithm reconstruction.
- Context-relative key indexing and row/word loop variants did not improve the
minimal key-base candidate.
- Moving next-state locals outside the round loop did not change codegen.
- Reordering key-base declarations produced a negligible score change; the
original natural declaration order was kept.
- Two exploratory C89-incompatible mixed-declaration variants failed to compile
and were immediately discarded. No failed source is retained.
## Verification
Before -> after:
- AESiDecryptBlock: 249 -> 251 instructions against target 251;
fuzzy 61.49004 -> 63.836655%. Final ctxdiff: 224 positional differences.
- AESiEncryptBlock: unchanged, 158/158 instructions and 60.348103% fuzzy.
- Unit fuzzy: 76.844475 -> 77.700584%.
- Exact functions: 7/9 -> 7/9. Exact code: 1116/2752 bytes unchanged.
- Data: objdiff 2800/2800, 100%, unchanged. Linked status unchanged.
- All seven exact functions have ctxdiff diffs 0: NETAESCreateEx 108/108,
NETAESCreate 2/2, NETAESDelete 1/1, NETAESEncrypt 46/46, NETAESDecrypt 46/46,
NETiAESEncryptoBlock 39/39, NETiAESDecryptoBlock 37/37.
- String pool: all four strings identical.
- .rodata: 2592 identical bytes; .sdata2: 8 identical bytes. Source .data is
197 bytes with the same prefix as the 200-byte target section; three target
alignment bytes are an existing extent difference. No padding was added.
- The full 1027-unit report has no regressions in exact functions/code/data or
fuzzy score against the baseline report. Frozen MD5 metrics are unchanged.
- Full 43U build passed with the configured wibo wrapper; build/43U/ok passed.
DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`.
Host validation: `python3 /tmp/crypto-remainder/validate_aes.py` compiles the
production C unchanged with minimal types/OSReport shims. Input, key and IV
words are represented with their PPC big-endian numeric values, so native host
byte order does not change the algorithm. Known-answer tests cover AES-128,
AES-192 and AES-256; seeded randomized CBC tests compare against cryptography's
AES implementation for all three key sizes. Each tests separate/in-place
buffers and single/incremental calls.
Result: all 2,406 production-source known-answer/randomized checks passed. The
original baseline had independently passed the same coverage before changes.
A separate saved helper experiment also passed but is not part of this commit.
Local evidence, not committed or uploaded: `/tmp/crypto-remainder/aes-final.ctx`,
`aes-final.json`, `aes-full-build.log`, `aes-vectors.log`, `aes-decrypt.target`,
and `validate_aes.py` plus its header shims. No retail assembly is included.
GATE: validated partial structural candidate; no regressions. Exact matching
and linking remain open.

View File

@@ -0,0 +1,65 @@
# Alpha output and scan reconstruction follow-on, 2026-10-02
Parent candidate: `94b7f57e`. Its source/log were left unchanged during
independent side experiments. No ABI/header/linking changes are included.
Changed source: `libs/RVLMiddleware/eZiText/src/clib/zi8alpha.c` only.
## Target evidence and retained changes
- At `Zi8AlphaGetCandidates +0x3178`, the original emits wide-character
output before the encoded-byte alternative. The wide path assigns the
same zero to output elements 2 and 1 (+0x31A4/+0x31A8), then advances by
two characters. The encoded path likewise shares its zero assignment.
Restored that positive branch and ordinary chained zero assignments.
- The dictionary comparison loop branches from +0x2904 to its bound check
at +0x292C. The comparison body exits on a character mismatch at +0x2924;
a matched character increments the index at +0x2928. Replaced the merged
`for` condition with the corresponding bounded loop and explicit break.
- The punctuation output block at +0x1B0C..+0x1B1C reads the current cursor,
emits its character and advances that same cursor. Expressed this with
`wordCursor[1] = *punctuationCursor++`. It does not reuse a mutated index
in another operand or introduce an unsequenced read/write.
## Independently compiled, isolated trials
Each trial used the exact 43U MWCC flags from the live Ninja command and a
separate object/report under `/tmp/ezi-side`, without altering the reviewed
worktree candidate. Report columns below are function fuzzy, unit fuzzy,
matched data bytes and exact-function count:
- Early candidate-skip block: 94.65585, 96.10635, 408, 11; excluded
- Wide output first: 94.887985, 96.27548, 516, 11; retained
- Next-dictionary switches: 94.4037, 95.92264, 408, 11; excluded
- Explicit dictionary-scan break: 94.62088, 96.08087, 516, 11; retained
- Combined candidate-count limit: 94.35884, 95.88995, 408, 11; excluded
- Punctuation cursor increment: 94.4782, 95.97692, 516, 11; retained
- Wide output plus scan: 95.02306, 96.37389, 516, 11
- Final three-change subset: 95.02813, 96.37759, 516, 11
## Full current-worktree validation
Fresh report: `/tmp/ezi-alpha-followup.json`.
Full build log: `/tmp/ezi-alpha-followup-build.log`.
Exact functions 11/12 unchanged; exact code 5880/21664 unchanged;
exact data 516/564 unchanged. Unit fuzzy 95.97323% -> 96.37759%.
Function fuzzy 94.47314% -> 95.02813%, about 88 additional weighted bytes.
Relative to initial 449529d9, unit fuzzy improves 94.17892% -> 96.37759%.
Pool first: identical (no narrow strings in either pool).
Main function: 3946/3946 instructions, 0x3DA8 bytes each, frame 0x2B0.
Strict ctxdiff remains nonzero (3745 differences), dominated by the known
scalar-stack displacement, instruction placement and GPR allocation. No
new exact function is claimed. Each of the existing 11 exact functions
retains identical instruction counts and ctxdiff diffs 0.
All non-text section scores match the parent: .rodata, extab and extabindex
remain 100%; the existing 48-byte generated switch table remains unmatched.
The advisory register-normalized/control-flow alignment checked 701 branch
pairs with zero destination mismatches and 73/73 helper calls. This is a
coverage check, not an exactness claim.
Full 43U build succeeds with the approved wrapper and
`WIBO_SJIS_MISSING_IMPORTS=1`. DOL SHA1:
`26116613f624061ba99c8d1a299aaa6efa85670d`.
`git diff --check` succeeds. No new assembly, volatile workaround, register
forcing, undefined value, dummy storage, prototype or shared-header change.

View File

@@ -0,0 +1,89 @@
# eZiText remainder reconstruction, 2026-10-02
Base: `449529d9`; branch `agent/bittle/allhands-ezi-decompile`.
Only 43U was configured, using `../toolchain/wibo-build/wibo` and
`WIBO_SJIS_MISSING_IMPORTS=1 ../.venv/bin/ninja`. No linking flags, shared
headers, remote refs, or upstream resources were changed.
## Baseline and first candidate: alpha engine
Fresh baseline report: `/tmp/ezi-baseline.json`.
`zi8alpha`: 11/12 exact functions, 5880/21664 exact code bytes,
516/564 exact data bytes; unit fuzzy 94.17892%.
`Zi8AlphaGetCandidates`: 3946/3946 instructions, function fuzzy 92.01039%.
These function and unit percentages are deliberately distinguished.
The scalar layout is four bytes lower in source than in the target because
of the target's existing workspace snapshot at stack 0x20. No dummy alias,
padding, or unused local was added to occupy that slot.
Six semantic corrections were established from definitions and uses, not
from equal-looking raw offsets:
- The flag initialized at target stack 0x84 is the current vowel/punctuation
restriction. At function +0x0798, the table-31 flag test for bit 4 clears
target 0x84 and its primary-language snapshot at 0x8C. Source uses 0x80
and 0x88 for those same definitions.
- The different completion flag is at target 0x88. The table-31 bit-2 test
at +0x07C8 clears target 0x88 and primary snapshot 0x90. Its source slots
are 0x84 and 0x8C. Language-pass restoration confirms both identities.
- Target reads of 0x84 at +0x2114, +0x2214, +0x32F4, +0x3384 and +0x3664
gate punctuation retries, suffix activation, suffix locking and prefix
punctuation. The source incorrectly read the completion flag in all five
places. The candidate uses the traced current-restriction variable.
- At +0x1430 the target loads the dictionary-order index from 0x64, uses it
to select a byte dictionary kind, and stores that kind at 0x60. The retry
condition at +0x3060 reads 0x64, also used by the following outer-loop
increment. Source incorrectly tested dictionaryKind; it now tests
dictionaryIndex. The safe existing early dictionaryIndex initialization
was preserved.
The isolated six-line semantic patch is preserved at
`/tmp/ezi-alpha-six-conditions.patch`. Alone it gives function 92.009125%,
unit 94.17799%, with code/data/exact counts unchanged. This tiny fuzzy
fluctuation does not invalidate the traced variable corrections.
The first handed-off candidate also restores the original address-order
suffix-lock block before alternate-prefix fallback, restores positive branch
conditions, and places each language's restriction snapshots at its actual
control-flow position. No helper prototype change is included in this first
candidate.
First-candidate fresh report: `/tmp/ezi-alpha-minimal.json`.
`Zi8AlphaGetCandidates`: 94.47314%, 3946/3946 instructions.
Unit fuzzy: 94.17892% -> 95.97323% (about 389 fewer weighted deficit bytes).
Exact functions: 11/12 -> 11/12. Exact code: 5880 -> 5880 bytes.
Exact data: 516 -> 516 bytes. All non-text section scores are unchanged.
Both pools contain no strings and compare identical.
## Separate later research, not part of the first candidate
- Further emission/cursor/comparison/switch reconstruction reached function
95.63913%, unit 96.82275%, 3950/3946 instructions. Existing exact functions
remain exact, but extabindex accounting drops by 108 bytes. Preserved at
`/tmp/ezi-alpha-deliver.c`; not included in the first candidate.
- Matching PUD return declarations to zi8pud2.c's ziU32 definitions, with
explicit caller byte narrowing, leaves alpha's score unchanged but moves
one-key candidates 95.39716% -> 95.32416%. Its 5 exact functions and data
1280/1388 remain unchanged. Held separately for ABI review.
- Matching Chinese Zi8GetPCode to zi8match.c's ziU16 definition restores the
two target halfword narrowings in paired-phonetic lookup. Together with the
explicit PUD ABI correction: engine 96.27482% -> 96.492134%, unit
96.65468% -> 96.848755%, 10678/10676 instructions, 5 exact unchanged.
extabindex accounting drops 72 bytes. Held for section/relocation audit.
- Splitting the Chinese component cursor/table chained assignment reproduces
the target's intermediate reload but lowers the engine to 96.090294%;
rejected and restored.
- Replacing the spelling candidate-count assignment with postfix increment
lowers spelling 99.555885% -> 96.8%; rejected and restored.
The larger scratch candidate's branch-destination audit found no mapped
branch-target differences over 720 alpha, 351 one-key and 1594 Chinese
branches. Helper-call counts are respectively 73/73, 71/71 and 168/168.
This audit ignores register choices and accounts for the known stack shift;
it is evidence of control-flow coverage, not a claim of exact matching.
First-candidate validation: full 43U build succeeds; DOL SHA1 is
`26116613f624061ba99c8d1a299aaa6efa85670d`. Every one of the 11 baseline
exact alpha functions has identical instruction counts and ctxdiff diffs 0.
`git diff --check` succeeds. No new exact function or complete unit is claimed.

View File

@@ -0,0 +1,62 @@
# MD5 unsigned arithmetic and cursor reconstruction, 2026-10-02
Separate follow-on to accepted MD5 commit `521056a9`. AES commit `2a537c14`
and both prior logs are unchanged. Only 43U was configured or built.
## Target-grounded changes
The target ProcessBlock rotation halves retain independently grouped additions
of the unsigned state, round constant and separately byte-reversed message
words. Reassociating those three u32 operands inside the accepted helper brings
the compiler's data-flow closer to the target while preserving modulo-2^32
arithmetic. The first MD5 round consumes sequential message words; expressing
that consumption with `word++` as the helper's pointer argument improves its
schedule. STEP evaluates this pointer argument exactly once; the helper still
uses that captured pointer for both byte-reversed reads. No evaluation-order
ambiguity, extra read, undefined value, or new helper is introduced.
Experiments enumerated 144 valid addition operand/grouping combinations for
the two halves. The best target-sized arithmetic expression reached 93.447716%
ProcessBlock fuzzy. Five cursor/loop variants and eight independent cursor-
consumption combinations then identified the minimal `word++` form, reaching
94.30719%. A larger by-reference cursor helper reached 94.98366% but duplicated
rotation code for a small gain and was rejected. Three explicit feed-forward
variants did not improve the retained result. No declaration/register sweep,
assembly, volatile qualifier, padding or linking change was used.
## Verification
Accepted MD5 -> this candidate:
- ProcessBlock: 81.82026 -> 94.30719% fuzzy; 306/306 instructions unchanged.
- Unit fuzzy: 87.80044 -> 96.179825%.
- Exact functions 3/4 and exact code 600/1824 are unchanged.
- Data 456/456 (100%) and linking status are unchanged.
- NETMD5Init 16/16, NETMD5Update 60/60 and NETMD5GetDigest 74/74 still have
ctxdiff diffs 0 and objdiff 100%.
- ProcessBlock has 215 positional differences. An advisory comparison that
ignores GPR names leaves five opcode/immediate-order differences: three
sequential cursor offsets and two final state-load positions. This is not
an exact match or a proof that every remaining difference is register-only.
- Empty string pools remain identical. Constants/index tables and end-marker
data are unchanged from the accepted candidate.
- AES metrics and source are unchanged from commit 2a537c14.
- Full 1027-unit report: zero exact-function/code/data/fuzzy regressions versus
baseline449529d9; additionally both owned units preserve the immediately
preceding candidate's exact/data scores and improve or preserve fuzzy scores.
- Full 43U build and build/43U/ok passed. DOL SHA1:
`26116613f624061ba99c8d1a299aaa6efa85670d`.
All 3,088 MD5 known-answer/random/chunking comparisons passed again against
Python hashlib. Run `python3 /tmp/crypto-remainder/validate_md5.py`. The test
compiles production C unchanged with PPC intrinsic shims, supplies RFC1321
padding externally, and exercises ProcessBlock through NETMD5Update. The
instruction-exact GetDigest platform-endian stores are not host-tested.
Local evidence (not committed/uploaded): `/tmp/crypto-remainder/` contains
`md5.grouping-results.json`, `md5-grouping-final.json`,
`md5-grouping-ProcessBlock.ctx`, `md5-grouping-vectors.log`, and
`md5-grouping-full-build.log`. Original target evidence remains in the local
split object and disassembly; no retail assembly is included in this commit.
GATE: validated partial structural candidate; no regressions. Exact matching
and linking remain open.

View File

@@ -0,0 +1,86 @@
# MD5 rotation-expression reconstruction, 2026-10-02
Baseline: `449529d9`, 43U only. Owned source: `libs/RevoEX/src/net/md5.c`.
The current user priority permits validated structural/fuzzy improvements before
exact matching and linking. This is a partial matching candidate, not an exact
match or a linking change. AES experiments were saved outside the checkout and
AES was restored to the baseline before this candidate was validated.
## Source evidence
- Ground truth: `build/43U/obj/libs/RevoEX/src/net/md5.o`, `ProcessBlock`.
- The target is 0x4C8 bytes / 306 instructions, with a 0x20-byte stack frame.
- Each of the sixteen unrolled MD5 steps contains two byte-reversed word loads.
The first pair is at function-relative offsets 0x3C and 0x40. The right-shift
half consumes the first value, and the left-shift half consumes the second.
- The target retains four additions across the two rotation halves: the
right-shift half adds the message word to (round constant + state), and the
left-shift half adds the state to (message word + round constant). The state
includes the round Boolean function. The first rotation uses right shift 25
and left shift 7; the remaining shifts follow the existing MD5 round schedule.
- The index-table address is first materialized after the first sixteen steps,
rather than before the sequential-word round.
- The inline helper expresses these real unsigned 32-bit operands and restores
the target-sized body. It introduces no assembly, volatile qualifier,
uninitialized value, fake storage, padding, or compiler-option change.
- All four round algorithms, all 64 constants, all 48 indices, and all public
API bodies are otherwise unchanged. The old ROTATE macro became unused and
was removed.
## Attempts
1. Direct pointer-form byte-reversed loads and alternate ordinary arithmetic
groupings: 274-294 instructions, at best near the starting score. Rejected.
2. A typed inline endian-load wrapper: improved instruction similarity but
retained 276 instructions and insufficient target operation boundaries.
3. Rotation-expression helpers without independent load results: 288-290
instructions, approximately 41-44% ProcessBlock fuzzy. Rejected.
4. Explicitly named byte-reversed operands for the two rotation halves:
306 instructions / 81.82026% fuzzy. Retained the target's first-read/right-
shift ordering. Reversing those loads reached 82.0% but added two instructions
and contradicted the target's operand ordering, so it was rejected.
5. Sequential partial-sum statements and equivalent regroupings did not
improve the retained structural form. No register-only declaration sweep.
## Validation
Command setup:
`python3 configure.py --version 43U --wrapper ../toolchain/wibo-build/wibo`
`WIBO_SJIS_MISSING_IMPORTS=1 ../.venv/bin/ninja`
- `pool_diff.py`: identical empty MD5 string pool, 0/0 strings.
- `.data`: all 448 bytes identical. The source `.sdata` is the one-byte
end marker (0x80); the target has the same byte followed by seven alignment
zeros. This existing section-size difference is unchanged, and objdiff
reports `.sdata` and unit data at 100%. No padding was added.
- `NETMD5Init`: 16/16 instructions, ctxdiff diffs 0, objdiff 100%.
- `NETMD5Update`: 60/60 instructions, ctxdiff diffs 0, objdiff 100%.
- `NETMD5GetDigest`: 74/74 instructions, ctxdiff diffs 0, objdiff 100%.
- `ProcessBlock`: 294 -> 306 instructions against target 306;
43.290848 -> 81.82026% fuzzy. Final ctxdiff has 255 positional differences,
primarily allocation, scheduling and remaining arithmetic grouping. Not exact.
- MD5 unit: 61.945175 -> 87.80044% fuzzy; exact 3/4 -> 3/4;
exact code 600/1824 unchanged; data 456/456 (100%) unchanged; unlinked unchanged.
- Full 1027-unit report: no unit regressed in exact functions, exact code,
exact data or fuzzy score versus the baseline report. Overall fuzzy moved
99.588615 -> 99.60437%; exact code and linking did not change.
- Full 43U build passed. `build/43U/ok` passed. DOL SHA1:
`26116613f624061ba99c8d1a299aaa6efa85670d`.
Host algorithm validation: `/tmp/crypto-remainder/validate_md5.py` compiles the
production source unchanged with host shims for PPC byte-reversed intrinsics.
It verifies ProcessBlock through NETMD5Update with externally supplied RFC1321
padding, comparing state words with Python hashlib. The host test deliberately
does not exercise GetDigest's platform-specific big-endian length stores.
Result: 3,088 successful digest/chunking comparisons, covering the seven RFC1321
example strings, one million `a` bytes, 1,500 seeded messages, lengths around
55/56/63/64/65 and larger block boundaries, and fixed/random chunk sizes.
Run: `python3 /tmp/crypto-remainder/validate_md5.py`.
Local evidence (not committed or uploaded): `/tmp/crypto-remainder/md5.target`,
`md5-final.ctx`, `md5-final.json`, `baseline.json`, `full-build.log`, and the
host test plus its header shim. Only source and this summary are committed.
GATE: partial decompilation candidate validated; no regressions; exact matching
and linking remain open. No claim of all-100% completion.

View File

@@ -0,0 +1,199 @@
# System remainder decompilation, 2026-10-02
Baseline: `449529d92405f8f7fda610660c7794914a81dfe6`.
Branch: `agent/bittle/allhands-system-decompile`.
Owned units: `src/utility/iplESMisc.cpp`, `src/scene/setting/AOSS.c`,
`src/scene/setting/ATERM.c`. Parent additionally approved the single ESMisc
return-type declaration change in `include/utility/iplESMisc.h`.
The current user priority is complete source reconstruction first, exact code
matching second, linking last. This candidate is decompilation progress, not an
exact match or a linking change. No configuration, symbol, split, or link flag
was changed. AOSS and ATERM are unchanged.
## Initial audit
- Read AGENTS.md, CONTRIBUTING.md, local skill inventory, AOSS/ATERM attempt
histories, and ESMisc rounds 9/11. The sole local skill is unrelated TypeSafe
integration guidance.
- Configured and built only 43U with the approved Wibo wrapper.
- Before source work, pool_diff found ATERM 0/0 strings and AOSS 1/1 identical.
ESMisc first diverged at string 83; both contained 114 strings.
- ESMisc's 30 exact functions were preserved in earlier rounds, but a meaningful
helper reconstruction had been discarded solely because it was not exact.
Reconstructed it from the current C++ and target object, without importing an
old experimental source or altering linker behavior.
## ESMisc reconstruction
Restored three ordinary inline boundaries named by the target's diagnostic
literals: `verifySavedataZD`, `DeleteTicketsForce`, and `InitSavedata`.
`ESMisc::DeleteUnauthorizedData` returns the initializer status.
Concrete correctness corrections:
1. Use a real NAND_MAX_PATH buffer and a real caller-owned, 32-byte-aligned
NANDFileInfo. Removed the out-of-object `path - 8` and `fileInfo - 0x20`
accesses. The caller also owns the aligned, rounded ticket-view scratch.
2. Traverse `ESTitleId` values by typed array index, with one unconditional loop
increment for every title. The old verifier branch continued without
advancing its separate byte offset and could repeat the same title.
3. Replace the handwritten nested 64-bit switch-lowering expression with the
five actual title cases and the independently masked save-title predicate.
4. Preserve the two ES_ListTitlesOnCard results independently of inlined file
and ticket operation status. The public declaration now returns s32.
5. A negative NANDRead result jumps to cleanup, which frees the save buffer
before closing the still-open file. The old source took the success-path
close before freeing it. Successful or invalid-size reads retain their
close-before-delete/free path.
6. Use sizeof(ESTicketView) for the 0xD8-byte copy and OSRoundUp32B for the 0xE0
scratch/allocation extent, preserving the target's distinct sizes.
### ABI and control-flow evidence
Target function: address 0x813673E0, size 0x704 (449 instructions).
At original object offsets 0x1D20 and 0x1D9C, the two enumeration return values
are saved in r27. Calls through both verifier/ticket paths leave that saved
value independent. At 0x23C0 it is copied to return register r3 after the
optional title-list free. The prior void declaration discarded this ABI.
The only declaration is in include/utility/iplESMisc.h. The only call is
src/system/iplSystem.cpp:680; it intentionally ignores the result. The symbol
name is unchanged because the return type is not encoded in this member name.
All 1027 compiled source objects were compared after a forced full rebuild;
iplSystem and every unit except iplESMisc were byte/relocation unchanged.
The target's verifier branch joins the common increment at 0x238C (index +1,
byte offset +8). Its negative-read path joins cleanup at 0x2104, whereas its
successful close begins at 0x20E0. The reconstruction restores these distinct
paths instead of compensating with stack offsets or register tricks.
### Measurements
| Unit / measure | Before | After |
| --- | ---: | ---: |
| ESMisc exact functions | 30/31 | 30/31 |
| ESMisc exact code | 9404/11200 | 9404/11200 |
| ESMisc fuzzy | 96.76036% | 99.33143% |
| DeleteUnauthorizedData fuzzy | 79.797325% | 95.830734% |
| Function instructions | 434/449 | 446/449 |
| ESMisc matched data | 4416/4416 | 4416/4416 |
| ATERM exact / fuzzy / data | 17/26; 96.624664%; 18584/18864 | unchanged |
| AOSS exact / fuzzy / data | 16/21; 96.777916%; 3928/3928 | unchanged |
| Whole-report fuzzy | 99.588615% | 99.598236% |
pool_diff now reports all 114 strings identical. The source .data is 4378
bytes and exactly equals the original section's first 4378 bytes. The target
section is 4384 bytes and ends in six zero alignment bytes. No synthetic
padding was added. The objdiff data score remains 100%, and the literal audit
checks 204 arguments in all 30 exact functions with zero candidates or errors.
The candidate remains non-exact. ctxdiff shows 446/449 instructions and
remaining register allocation, -1 mask materialization, and scratch-pointer
lifetime differences. No brute-force declaration/register search was run.
## Validation
Commands:
- python3 configure.py --version 43U --wrapper ../toolchain/wibo-build/wibo
- Delete generated native `build/43U/src/**/*.o`, retaining a private baseline
object snapshot for comparison.
- WIBO_SJIS_MISSING_IMPORTS=1 ../.venv/bin/ninja all_source build/43U/report.json build/43U/ok
- PYTHONPATH=../local-tools ../.venv/bin/python tools/decomp-assist/pool_diff.py
- PYTHONPATH=../local-tools ../.venv/bin/python tools/decomp-assist/ctxdiff.py src/utility/iplESMisc DeleteUnauthorizedData__Q33ipl7utility6ESMiscFPQ23EGG4Heap
- PYTHONPATH=../local-tools ../.venv/bin/python tools/decomp-assist/literal_reference_diff.py src/utility/iplESMisc
- Compare every unit in the fresh report and all 1027 source objects' allocated
bytes and normalized relocations against the baseline.
- git diff --check
Full rebuild passed (1031 Ninja steps). DOL SHA1:
`26116613f624061ba99c8d1a299aaa6efa85670d`.
Only the ESMisc report changed: its fuzzy and one function's fuzzy improved.
No report metric regressed. Only ESMisc's allocated .text and .data changed:
.text 11360 -> 11408 bytes (390 relocations on both sides), .data 4378 -> 4378
bytes (zero relocations). Every other allocated section/object is unchanged.
A temporary host harness extracted the actual reconstructed helper bodies,
substituted fake Wii/heap calls, and exercised 12 control-flow scenarios:
first and second enumeration errors, title-list allocation failure, mixed
Zelda/blocked/ordinary title traversal, negative read, short read, second-save
verification failure, absent file, save-buffer allocation failure, ChangeUid
failure, ticket enumeration failure, and zero-ticket handling. Tests ran with
AddressSanitizer and UndefinedBehaviorSanitizer. LeakSanitizer is unavailable
under the execution environment's ptrace, so only that component was disabled.
The harness is supplemental behavioral validation, not a retail runtime test.
GATE: focused decompilation improvement; full 43U/DOL and no-regression checks
pass; exact-matching gate remains incomplete at 30/31. No linking claimed.
## Follow-on: recover the last ESMisc structural differences
Baseline for this follow-on is the accepted reconstruction `1f9db89d`:
30/31 exact functions, function 95.830734%, unit 99.33143%, 446/449 instructions,
data 4416/4416. The source/header correction remains intact.
Natural source attempts, in order:
| Attempt | Instructions | Function fuzzy | Disposition |
| --- | ---: | ---: | --- |
| Ticket helper uses error-first cleanup and returns early with no tickets | 446/449 | 95.830734% | Same generated code |
| Caller gives aligned ticket scratch an explicit pointer lifetime | 448/449 | 98.004456% | Improved |
| Move aligned ticket scratch into the ticket helper | 446/449 | 95.817375% | Rejected |
| Scope caller's scratch pointer to successful title enumeration | 448/449 | 98.89755% | Retained |
| Restore nested ticket helper with scoped scratch | 448/449 | 98.89755% | Same generated code |
| Ticket helper returns its actual ES operation status | 449/449 | 99.14254% | Retained |
The scratch pointer is initialized only in the block reached after successful
second enumeration, and remains live across the title loop. This restores the
saved scratch cursor and per-iteration 64-bit mask materialization. No pointer
is used before initialization and no artificial use extends its lifetime.
The private ticket helper now returns the status already obtained from
ES_GetTicketViews or ES_DeleteTicket, including its zero-ticket early return
and normal cleanup. Its caller intentionally discards that status. The return
contract of an independently emitted original helper cannot be established
because this helper was fully inlined; this is a natural equivalent source
form whose zero-ticket branch structure is confirmed by the target. It does
not overwrite the outer enumeration status or change the public ABI further.
Final ctxdiff: 449/449 instructions, 74 differences. Every mnemonic,
non-register operand, stack offset, resolved call target and branch target
agrees. The remaining differences are register substitutions, including the
title list, scratch cursor, title index, verifier flags and title halves. No
register/declaration permutation search was performed after reaching this
structural agreement.
Measurements after a fresh full report:
- ESMisc exact functions 30/31 -> 30/31
- ESMisc exact code 9404/11200 -> 9404/11200
- ESMisc fuzzy 99.33143% -> 99.8625%
- DeleteUnauthorizedData fuzzy 95.830734% -> 99.14254%
- Matched data 4416/4416 -> 4416/4416
- Pool: all 114 strings identical
- Literal audit: 204 arguments in 30 exact functions, no candidates/errors
- Every other unit's full report is unchanged
- Full 43U build/check and DOL SHA1 pass:
26116613f624061ba99c8d1a299aaa6efa85670d
- The same 12 ASan/UBSan host control-flow scenarios pass on helper bodies
freshly extracted from this final candidate (LeakSanitizer disabled only
for the environment limitation already noted)
- git diff --check passes
This remains a partial matching improvement, not an exact function or unit.
### Rejected ATERM ownership experiment
Read-only target evidence identified that the old typed reply view spans the
last eight bytes of one BSS object and the following option-buffer allocation.
With parent approval, tried a real two-object protocol-workspace aggregate and
corresponding narrow metadata consolidation. It preserved storage, addresses,
all 17 exact functions and matched data, and reduced the main protocol from
972 to 959 instructions (target 951). However, its unit fuzzy regressed from
96.624664% to 96.49781%; wider grouping and a decoder-helper experiment also
failed the no-regression condition. All ATERM source and symbol metadata were
restored. Fresh report after restoration was identical to the accepted ESMisc
baseline, and the DOL hash passed. Detailed rejected source/metadata and
address evidence were kept privately for future work; none is in this commit.

View File

@@ -0,0 +1,23 @@
# iplSetting worker3 — Setting::draw (Oct 2 2026)
Worktree: `/workspace/worktrees/iplSetting-draw`
Branch: `agent/grok/decomp-worker-3/draw`
Unit: `src/scene/setting/iplSetting.cpp` `Setting::draw` only.
`scanAP` / `convertRevIP` source not touched. File stays `NonMatching` (not linked).
## Result
**632/632 byte-identical** to retail (`draw__Q33ipl5scene7SettingFv`, 2528 bytes, 0 diffs).
A HEAD compile of the same TU differs from this object only in `draw`. No sibling codegen change (`-ipa file`).
## Levers that closed it
1. `wideTopL` / `wideTopR` as separate locals (no CSE of the int-to-float). Gets `xoris r6,r6` and `fsubs f2`.
2. One `void* held` is the browser thread, then overwritten by the standard-buffer fetch, so browser and `standardBuffer` share r31.
3. Tex0 material pointer reused as the scroll `FrameController*` (`wideMaterial`), with `initFrame`/`restart` duplicated in each arm.
4. Field copy through `volatile GXRenderModeObj*` so loads and stores interleave on r4/r0.
5. Sample-pattern loop is direct `dst[1]=src[1]; dst[2]=src[2]` with `src` declared before `dst` is assigned (`u8* src; u8* dst = ...; src = ...`).
## Not linked
`configure.py` still has `Object(NonMatching, "scene/setting/iplSetting.cpp")`. DOL SHA1 is unchanged because this TU is not linked. Do not flip the object to Matching until `scanAP` / `convertRevIP` (and the rest of the TU) match.

View File

@@ -0,0 +1,26 @@
# odh `cdj_d_decompressLoop` (worker-2) 2026-10-02
Claim was only `cdj_d_decompressLoop`. colorConv, huffmanDecoder, and LineConv11 were not modified in the committed diff.
## Result
`cdj_d_decompressLoop` **899/899, 0 diffs, byte-identical** (3596 bytes) to retail. Was 43, then 7.
## What matched
- Inlined `(blockRowSize * 2)` and `((u32)blockWidth << 4)` (init `slwi r18` / `slwi r17`).
- `planeOffset += (u32)master->blocksWide << 6` coalesces the 1x2 update into `add r15, r15, r0`.
- `int nextBlockX = master->blockX + 1` with `(u16)` compare (same shape as compressLoop).
- Second 1x1 chroma sum written blockX term first.
- idct destinations that need plane-first `add` use `(u8*)((u32)planeOffset + (u32)master->workBuffer) + 8`.
- 2x2 tail stores the updated plane in `requiredBlockEnd` and the end pointer in `planeOffset`. That is what puts the plane in r15 and the end in r16 (`addi r15, r3, -8` / `add r16, r15, r18`). Assigning the plane back to `planeOffset` left those two callee-saves swapped (7 diffs). Splitting the `-8` let MWCC cancel it against the later `+8` and dropped to 897.
colorConv left at the 18 pairwise wall. Not in this diff.
## colorConv (2026-10-02)
`cdj_c_colorConv` **77/77, 0 diffs, byte-identical** (308 bytes). Was 18, then 13, then 8.
- Drop `paddedWidth`. The row loop adds `paddedDimensions[0]`, which hoists `lhz r24` and `lis r23` / `addi r10, r23, 0`.
- Pad loop: `u16 remainder = dimensions[i] & 7`, then `(dimensions[i] + 8) - remainder`. Width stays r8, the indexed load stays r7, the mask stays r9. Naming both a dimension and a remainder swaps width off r8.
- Declare `sourceStride` after `rowIndex` (cb/cr stay above it). That assigns stride r29 and `cbPlane` r22. Computing stride before the planes shortens the function to 76 and shifts the callee-saves. huffmanDecoder and LineConv11 were not edited. `cdj_d_decompressLoop` stays 899/899.

View File

@@ -0,0 +1,276 @@
# JPEG remainder: semantic audit and source-shape reconstruction
Baseline: `449529d9`, branch `agent/bittle/allhands-jpeg-decompile`, 4.3U only.
No remote writes, header changes, configuration changes, linking changes, assembly,
volatile forcing, padding, or edits to the separately owned entropy decoder.
## Result
All 28 owned functions were already implemented. No semantic mismatch was found
in a bounded differential comparison of their current compiled PPC against their
original ELF function bodies. This is additional test evidence, not a formal
proof of equivalence and not a Wii runtime test.
Three natural source-shape changes improved the report without a function-score
regression:
- Luminance IDCT now uses explicit odd-coefficient sum/difference temporaries,
matching the existing chroma first-pass butterfly. Function fuzzy
82.31518 -> 83.05058; 257/257 instructions, 187 ctxdiff differences remain
- RGB444 consumes the luminance temporary as the red channel and uses the
existing exact edge sibling's red/green packing association. Function fuzzy
97.96703 -> 98.71429; 91/91 instructions, 13 ctxdiff differences remain
- RGBA420 edge consumes the luminance temporary as red after calculating the
other channels. Function fuzzy 87.4 -> 87.458336; 120/120 instructions,
77 ctxdiff differences remain
No new exact matches. This candidate is not an exact-matching or linking result.
| Unit | Exact before -> after | Fuzzy before -> after | Allocated data |
| --- | --- | --- | --- |
| Texture_MCUtoRGBA8 | 2/13 -> 2/13 | 90.318985 -> 90.32323 | 0 bytes; 100% |
| Texture_MCUtoRGB565 | 6/13 -> 6/13 | 96.40103 -> 96.44502 | 0 bytes; 100% |
| idct_block_var | 0/2 -> 0/2 | 88.80309 -> 89.06892 | 0 bytes; 100% |
All eight previously exact functions still have exact-name objdiff 100% and
ctxdiff zero differences. Each setter remains 169/170 instructions, with one
folded buffer-base address operation; the other 26 functions retain their
original instruction counts. Every owned function and both input objects were
checked for allocated non-code sections: none. Pool checks were run before tuning and after the final build; all three were
identical, with zero strings.
The baseline comparison was regenerated by rebuilding saved unmodified versions
of the three owned sources, reporting them, then restoring/rebuilding the final
sources. All 28 function scores were compared; zero regressions.
Full build: PASS. `git diff --check`: PASS.
DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`.
Commands used:
```sh
python3 configure.py --version 43U --wrapper ../toolchain/wibo-build/wibo
WIBO_SJIS_MISSING_IMPORTS=1 ../.venv/bin/ninja
build/tools/objdiff-cli report generate -p . -o build/43U/report.json -f json
PYTHONPATH=../local-tools ../.venv/bin/python tools/decomp-assist/pool_diff.py <source-object> <original-object>
PYTHONPATH=../local-tools ../.venv/bin/python tools/decomp-assist/ctxdiff.py <unit> <symbol>
../.venv/bin/python tools/decomp-assist/jpeg_differential_audit.py
sha1sum build/43U/main.dol
```
## Differential test scope and limitations
The committed `jpeg_differential_audit.py` is a bounded integer PPC interpreter
and deterministic test generator. It reads the locally available source/original
ELF objects and does not distribute original executable bytes. Capstone and
pyelftools are required. Run it from the repository root after building the
three objects; do not run Python with assertions disabled.
- 9,456 paired calls across all 28 functions, seed 449529
- Normal and edge converters: scales 1, 2, 4, 8; multiple MCU origins; both
edge-dimension branches; zero, partial and full extents; constant and random
luminance/chroma bytes, including negative signed chroma and clipping
- Setters: all 256 component selectors and four supported IDCT sizes;
randomized 16-bit image dimensions; return values, converter identities and
non-stack side effects compared
- IDCT: all row extents 1..8 and column-mode representatives 1, 2, 3, 8;
DC-only, sparse and dense coefficients; positive/negative coefficients and
clipping-boundary DC values; pitches 8, 16, 32
- Every non-stack byte is compared, including guard regions, along with setter
return values. Stack pointer, LR and GPR14..GPR31 restoration are checked
- Full instruction-address coverage was reached for all 20 non-grayscale
converter bodies and both IDCT functions. This does not mean exhaustive
branch/path/input coverage. Four grayscale bodies retain 19 unvisited
instructions each in saturation paths that follow an unsigned byte load;
each setter has one unvisited negative-selector branch instruction
- Function address relocations are normalized to deterministic symbol tokens,
with collision checks. Real linked addresses and integration are not tested
- Only the observed integer instruction subset is implemented. Unsupported
instructions/relocations/callees fail closed. No FPU, exceptions, cache/MMIO,
timing, alignment faults, XER behavior or complete condition-register model
- `memset` is modeled by its memory effects and ABI-permitted volatile-register
clobbers; its actual library machine code is not executed
- Inputs are bounded samples. Invalid pointers, zero scale, arbitrary invalid
IDCT descriptors, all 32-bit coefficient patterns, concurrency, real JPEG
streams and other units are not covered
- This custom interpreter is itself test tooling rather than a formally verified
CPU implementation. Official objdiff, ctxdiff and full-DOL checks remain the
matching/integration authority
Exact run output is preserved in `jpeg-remainder-differential-results.txt`.
## Attempts
Only strictly improved candidates without other function regressions were kept.
No declaration-order permutation search was performed. Failed/equal candidates
were restored. The one temporary compile error in the luminance-consumption
script was a duplicate local declaration; it was corrected and no broken
candidate was retained.
### type-trials
```text
TMCJPEGDEC_converterYUV411toRGBA8 signed-chroma-pointers: 82.603300 -> 82.500000; restore
TMCJPEGDEC_converterYUV411toRGBA8 signed-chroma-coefficients: 82.603300 -> 82.603300; restore
TMCJPEGDEC_converterYUV411toRGBA8 signed-chroma-domain: 82.603300 -> 81.570250; restore
TMCJPEGDEC_converterYUV411toRGBA8edge signed-chroma-pointers: 93.883930 -> 91.964290; restore
TMCJPEGDEC_converterYUV411toRGBA8edge signed-chroma-coefficients: 93.883930 -> 93.750000; restore
TMCJPEGDEC_converterYUV411toRGBA8edge signed-chroma-domain: 93.883930 -> 92.187500; restore
TMCJPEGDEC_converterYUV422toRGBA8 signed-chroma-pointers: 87.722980 -> 87.722980; restore
TMCJPEGDEC_converterYUV422toRGBA8 signed-chroma-coefficients: 87.722980 -> 87.722980; restore
TMCJPEGDEC_converterYUV422toRGBA8 signed-chroma-domain: 87.722980 -> 87.722980; restore
TMCJPEGDEC_converterYUV422toRGBA8 byte-luminance: 87.722980 -> 87.689186; restore
TMCJPEGDEC_converterYUV422toRGBA8edge signed-chroma-pointers: 90.088490 -> 90.088490; restore
TMCJPEGDEC_converterYUV422toRGBA8edge signed-chroma-coefficients: 90.088490 -> 90.088490; restore
TMCJPEGDEC_converterYUV422toRGBA8edge signed-chroma-domain: 90.088490 -> 88.628320; restore
TMCJPEGDEC_converterYUV422toRGBA8edge byte-luminance: 90.088490 -> 90.088490; restore
TMCJPEGDEC_converterYUV420toRGBA8 signed-chroma-pointers: 89.405230 -> 89.176470; restore
TMCJPEGDEC_converterYUV420toRGBA8 signed-chroma-coefficients: 89.405230 -> 89.307190; restore
TMCJPEGDEC_converterYUV420toRGBA8 signed-chroma-domain: 89.405230 -> 86.464050; restore
TMCJPEGDEC_converterYUV420toRGBA8 byte-luminance: 89.405230 -> 87.379080; restore
TMCJPEGDEC_converterYUV420toRGBA8edge signed-chroma-pointers: 87.400000 -> 80.666664; restore
TMCJPEGDEC_converterYUV420toRGBA8edge signed-chroma-domain: 87.400000 -> 80.666664; restore
TMCJPEGDEC_converterYUV211toRGBA8 signed-chroma-pointers: 91.153850 -> 91.153850; restore
TMCJPEGDEC_converterYUV211toRGBA8 signed-chroma-coefficients: 91.153850 -> 91.153850; restore
TMCJPEGDEC_converterYUV211toRGBA8 signed-chroma-domain: 91.153850 -> 91.153850; restore
TMCJPEGDEC_converterYUV211toRGBA8 byte-luminance: 91.153850 -> 91.153850; restore
TMCJPEGDEC_converterYUV211toRGBA8edge signed-chroma-pointers: 92.000000 -> 91.869570; restore
TMCJPEGDEC_converterYUV211toRGBA8edge signed-chroma-coefficients: 92.000000 -> 91.869570; restore
TMCJPEGDEC_converterYUV211toRGBA8edge signed-chroma-domain: 92.000000 -> 91.869570; restore
TMCJPEGDEC_converterYUV444toRGBA8 signed-chroma-pointers: 90.670105 -> 90.515465; restore
TMCJPEGDEC_converterYUV444toRGBA8 signed-chroma-coefficients: 90.670105 -> 90.515465; restore
TMCJPEGDEC_converterYUV444toRGBA8 signed-chroma-domain: 90.670105 -> 90.618550; restore
TMCJPEGDEC_converterYUV444toRGBA8 byte-luminance: 90.670105 -> 90.670105; restore
TMCJPEGDEC_converterYUV444toRGBA8edge signed-chroma-pointers: 88.909090 -> 88.909090; restore
TMCJPEGDEC_converterYUV444toRGBA8edge signed-chroma-coefficients: 88.909090 -> 88.909090; restore
TMCJPEGDEC_converterYUV444toRGBA8edge signed-chroma-domain: 88.909090 -> 87.645454; restore
TMCJPEGDEC_converterYUV444toRGBA8edge byte-luminance: 88.909090 -> 88.909090; restore
TMCJPEGDEC_converterYUV411toRGB565 signed-chroma-pointers: 90.599075 -> 90.599075; restore
TMCJPEGDEC_converterYUV411toRGB565 signed-chroma-coefficients: 90.599075 -> 90.599075; restore
TMCJPEGDEC_converterYUV411toRGB565 signed-chroma-domain: 90.599075 -> 90.599075; restore
TMCJPEGDEC_converterYUV422toRGB565 signed-chroma-pointers: 96.691180 -> 96.691180; restore
TMCJPEGDEC_converterYUV422toRGB565 signed-chroma-coefficients: 96.691180 -> 96.691180; restore
TMCJPEGDEC_converterYUV422toRGB565 signed-chroma-domain: 96.691180 -> 96.691180; restore
TMCJPEGDEC_converterYUV420toRGB565 signed-chroma-pointers: 94.609930 -> 94.609930; restore
TMCJPEGDEC_converterYUV420toRGB565 signed-chroma-coefficients: 94.609930 -> 94.609930; restore
TMCJPEGDEC_converterYUV420toRGB565 signed-chroma-domain: 94.609930 -> 94.609930; restore
TMCJPEGDEC_converterYUV420toRGB565 byte-luminance: 94.609930 -> 92.907800; restore
TMCJPEGDEC_converterYUV444toRGB565 signed-chroma-pointers: 97.967030 -> 97.362640; restore
TMCJPEGDEC_converterYUV444toRGB565 signed-chroma-coefficients: 97.967030 -> 97.802200; restore
TMCJPEGDEC_converterYUV444toRGB565 signed-chroma-domain: 97.967030 -> 97.340660; restore
TMCJPEGDEC_converterYUV444toRGB565 byte-luminance: 97.967030 -> 91.373630; restore
```
### idct-trials
```text
TMCJPEGDEC_IdctBlock_Lumi nested-odd-output-sum: 82.315180 -> 79.708170; restore
TMCJPEGDEC_IdctBlock_Lumi explicit-ac-or-tree: 82.315180 -> 74.984436; restore
TMCJPEGDEC_IdctBlock_Lumi ac-coefficients-direct-condition: 82.315180 -> 74.984436; restore
TMCJPEGDEC_IdctBlock_Lumi nested-even-output-sum: 82.315180 -> 82.315180; restore
TMCJPEGDEC_IdctBlock_Lumi direct-product-shifts: 82.315180 -> 82.315180; restore
TMCJPEGDEC_IdctBlock_Col nested-odd-output-sum: 92.475770 -> 87.907486; restore
TMCJPEGDEC_IdctBlock_Col explicit-ac-or-tree: 92.475770 -> 90.651985; restore
TMCJPEGDEC_IdctBlock_Col ac-coefficients-direct-condition: 92.475770 -> 90.651985; restore
TMCJPEGDEC_IdctBlock_Col nested-even-output-sum: 92.475770 -> 92.475770; restore
TMCJPEGDEC_IdctBlock_Col direct-product-shifts: 92.475770 -> 92.475770; restore
```
### packing-trials
```text
TMCJPEGDEC_converterYUV411toRGBA8 explicit-channel-clamp-branches: 82.603300 -> 61.962810; restore
TMCJPEGDEC_converterYUV411toRGBA8 structured-nonnegative-clamp: 82.603300 -> 68.442150; restore
TMCJPEGDEC_converterYUV411toRGBA8edge explicit-channel-clamp-branches: 93.883930 -> 80.008930; restore
TMCJPEGDEC_converterYUV411toRGBA8edge structured-nonnegative-clamp: 93.883930 -> 85.714290; restore
TMCJPEGDEC_converterYUV422toRGBA8 explicit-channel-clamp-branches: 87.722980 -> 71.222980; restore
TMCJPEGDEC_converterYUV422toRGBA8 structured-nonnegative-clamp: 87.722980 -> 75.533780; restore
TMCJPEGDEC_converterYUV422toRGBA8edge explicit-channel-clamp-branches: 90.088490 -> 76.097340; restore
TMCJPEGDEC_converterYUV422toRGBA8edge structured-nonnegative-clamp: 90.088490 -> 82.123890; restore
TMCJPEGDEC_converterYUV420toRGBA8 explicit-channel-clamp-branches: 89.405230 -> 73.372550; restore
TMCJPEGDEC_converterYUV420toRGBA8 structured-nonnegative-clamp: 89.405230 -> 76.797386; restore
TMCJPEGDEC_converterYUV420toRGBA8edge explicit-channel-clamp-branches: 87.400000 -> 77.841670; restore
TMCJPEGDEC_converterYUV420toRGBA8edge structured-nonnegative-clamp: 87.400000 -> 82.400000; restore
TMCJPEGDEC_converterYUV211toRGBA8 explicit-channel-clamp-branches: 91.153850 -> 74.701920; restore
TMCJPEGDEC_converterYUV211toRGBA8 structured-nonnegative-clamp: 91.153850 -> 82.211540; restore
TMCJPEGDEC_converterYUV211toRGBA8edge explicit-channel-clamp-branches: 92.000000 -> 77.730440; restore
TMCJPEGDEC_converterYUV211toRGBA8edge structured-nonnegative-clamp: 92.000000 -> 84.043480; restore
TMCJPEGDEC_converterYUV444toRGBA8 explicit-channel-clamp-branches: 90.670105 -> 73.030930; restore
TMCJPEGDEC_converterYUV444toRGBA8 structured-nonnegative-clamp: 90.670105 -> 81.082470; restore
TMCJPEGDEC_converterYUV444toRGBA8edge explicit-channel-clamp-branches: 88.909090 -> 75.463640; restore
TMCJPEGDEC_converterYUV444toRGBA8edge structured-nonnegative-clamp: 88.909090 -> 81.000000; restore
TMCJPEGDEC_converterYUV411toRGB565 normalize-packed-channels: 90.599075 -> 87.004610; restore
TMCJPEGDEC_converterYUV411toRGB565 group-red-green-packing: 90.599075 -> 88.755760; restore
TMCJPEGDEC_converterYUV411toRGB565 pack-before-output-address: 90.599075 -> 90.599075; restore
TMCJPEGDEC_converterYUV411toRGB565 explicit-channel-clamp-branches: 90.599075 -> 59.511520; restore
TMCJPEGDEC_converterYUV411toRGB565 structured-nonnegative-clamp: 90.599075 -> 71.640560; restore
TMCJPEGDEC_converterYUV411toRGB565edge normalize-packed-channels: 95.377360 -> 93.820755; restore
TMCJPEGDEC_converterYUV411toRGB565edge group-red-green-packing: 95.377360 -> 93.613205; restore
TMCJPEGDEC_converterYUV411toRGB565edge pack-before-output-address: 95.377360 -> 95.377360; restore
TMCJPEGDEC_converterYUV411toRGB565edge explicit-channel-clamp-branches: 95.377360 -> 79.801890; restore
TMCJPEGDEC_converterYUV411toRGB565edge structured-nonnegative-clamp: 95.377360 -> 86.179245; restore
TMCJPEGDEC_converterYUV422toRGB565 explicit-channel-clamp-branches: 96.691180 -> 78.507355; restore
TMCJPEGDEC_converterYUV422toRGB565 structured-nonnegative-clamp: 96.691180 -> 79.044120; restore
TMCJPEGDEC_converterYUV420toRGB565 normalize-packed-channels: 94.609930 -> 90.248230; restore
TMCJPEGDEC_converterYUV420toRGB565 group-red-green-packing: 94.609930 -> 91.560290; restore
TMCJPEGDEC_converterYUV420toRGB565 pack-before-output-address: 94.609930 -> 94.609930; restore
TMCJPEGDEC_converterYUV420toRGB565 explicit-channel-clamp-branches: 94.609930 -> 73.127660; restore
TMCJPEGDEC_converterYUV420toRGB565 structured-nonnegative-clamp: 94.609930 -> 76.751770; restore
TMCJPEGDEC_converterYUV420toRGB565edge normalize-packed-channels: 94.692986 -> 89.912280; restore
TMCJPEGDEC_converterYUV420toRGB565edge group-red-green-packing: 94.692986 -> 91.798250; restore
TMCJPEGDEC_converterYUV420toRGB565edge pack-before-output-address: 94.692986 -> 94.692986; restore
TMCJPEGDEC_converterYUV420toRGB565edge explicit-channel-clamp-branches: 94.692986 -> 81.894740; restore
TMCJPEGDEC_converterYUV420toRGB565edge structured-nonnegative-clamp: 94.692986 -> 86.315790; restore
TMCJPEGDEC_converterYUV444toRGB565 normalize-packed-channels: 97.967030 -> 96.648350; restore
TMCJPEGDEC_converterYUV444toRGB565 group-red-green-packing: 97.967030 -> 98.681320; RETAIN
TMCJPEGDEC_converterYUV444toRGB565 explicit-channel-clamp-branches: 98.681320 -> 85.120880; restore
TMCJPEGDEC_converterYUV444toRGB565 structured-nonnegative-clamp: 98.681320 -> 82.802200; restore
```
### control-trials
```text
structured-col-low-mode-first: {'TMCJPEGDEC_IdctBlock_Lumi': 82.31518, 'TMCJPEGDEC_IdctBlock_Col': 92.47577} -> {'TMCJPEGDEC_IdctBlock_Lumi': 82.31518, 'TMCJPEGDEC_IdctBlock_Col': 92.47577}; restore
structured-col-high-mode-first: {'TMCJPEGDEC_IdctBlock_Lumi': 82.31518, 'TMCJPEGDEC_IdctBlock_Col': 92.47577} -> {'TMCJPEGDEC_IdctBlock_Lumi': 82.31518, 'TMCJPEGDEC_IdctBlock_Col': 50.55066}; restore
shared-full-row-butterfly: {'TMCJPEGDEC_IdctBlock_Lumi': 82.31518, 'TMCJPEGDEC_IdctBlock_Col': 92.47577} -> {'TMCJPEGDEC_IdctBlock_Lumi': 83.05058, 'TMCJPEGDEC_IdctBlock_Col': 92.47577}; RETAIN
```
### luma-reuse-trials
```text
TMCJPEGDEC_converterYUV422toRGBA8edge consume-luminance-as-blue: 90.088490 -> 90.088490; restore
TMCJPEGDEC_converterYUV422toRGBA8edge consume-luminance-as-red: 90.088490 -> 89.955750; restore
TMCJPEGDEC_converterYUV422toRGBA8edge consume-luminance-as-green: 90.088490 -> 90.088490; restore
TMCJPEGDEC_converterYUV420toRGBA8edge consume-luminance-as-blue: 87.400000 -> 87.400000; restore
TMCJPEGDEC_converterYUV420toRGBA8edge consume-luminance-as-red: 87.400000 -> 87.458336; RETAIN
TMCJPEGDEC_converterYUV211toRGBA8 consume-luminance-as-blue: 91.153850 -> 91.153850; restore
TMCJPEGDEC_converterYUV211toRGBA8 consume-luminance-as-red: 91.153850 -> 86.067310; restore
TMCJPEGDEC_converterYUV211toRGBA8 consume-luminance-as-green: 91.153850 -> 78.307690; restore
TMCJPEGDEC_converterYUV211toRGBA8edge consume-luminance-as-blue: 92.000000 -> 91.565216; restore
TMCJPEGDEC_converterYUV211toRGBA8edge consume-luminance-as-red: 92.000000 -> 87.617390; restore
TMCJPEGDEC_converterYUV211toRGBA8edge consume-luminance-as-green: 92.000000 -> 79.547830; restore
TMCJPEGDEC_converterYUV444toRGBA8 consume-luminance-as-blue: 90.670105 -> 90.670105; restore
TMCJPEGDEC_converterYUV444toRGBA8 consume-luminance-as-red: 90.670105 -> 85.216490; restore
TMCJPEGDEC_converterYUV444toRGBA8 consume-luminance-as-green: 90.670105 -> 74.577320; restore
TMCJPEGDEC_converterYUV444toRGBA8edge consume-luminance-as-blue: 88.909090 -> 88.909090; restore
TMCJPEGDEC_converterYUV444toRGBA8edge consume-luminance-as-red: 88.909090 -> 85.645454; restore
TMCJPEGDEC_converterYUV444toRGBA8edge consume-luminance-as-green: 88.909090 -> 78.772730; restore
TMCJPEGDEC_converterYUV411toRGB565edge consume-luminance-as-blue: 95.377360 -> 91.396225; restore
TMCJPEGDEC_converterYUV411toRGB565edge consume-luminance-as-red: 95.377360 -> 93.707550; restore
TMCJPEGDEC_converterYUV411toRGB565edge consume-luminance-as-green: 95.377360 -> 95.330185; restore
TMCJPEGDEC_converterYUV444toRGB565 consume-luminance-as-blue: 98.681320 -> 98.681320; restore
TMCJPEGDEC_converterYUV444toRGB565 consume-luminance-as-red: 98.681320 -> 98.714290; RETAIN
```
### rgb444-trials
```text
TMCJPEGDEC_converterYUV444toRGB565 reused-luminance-green-red-group: 98.714290 -> 89.923080; restore
TMCJPEGDEC_converterYUV444toRGB565 reused-luminance-blue-green-group: 98.714290 -> 98.549450; restore
TMCJPEGDEC_converterYUV444toRGB565 reused-luminance-red-blue-group: 98.714290 -> 90.945050; restore
TMCJPEGDEC_converterYUV444toRGB565 reused-luminance-red-green-group: 98.714290 -> 98.714290; restore
TMCJPEGDEC_converterYUV444toRGB565 separate-luminance-green-red-group: 98.714290 -> 98.131870; restore
TMCJPEGDEC_converterYUV444toRGB565 separate-luminance-blue-green-group: 98.714290 -> 98.516490; restore
TMCJPEGDEC_converterYUV444toRGB565 separate-luminance-red-blue-group: 98.714290 -> 91.406590; restore
TMCJPEGDEC_converterYUV444toRGB565 separate-luminance-red-green-group: 98.714290 -> 98.681320; restore
```

View File

@@ -0,0 +1,29 @@
TMCJPEGDEC_converterYUV411toRGBA8: 100 cases PASS; instruction coverage source 242/242, original 242/242
TMCJPEGDEC_converterYUV411toRGBA8edge: 400 cases PASS; instruction coverage source 112/112, original 112/112
TMCJPEGDEC_converterYUV422toRGBA8: 100 cases PASS; instruction coverage source 148/148, original 148/148
TMCJPEGDEC_converterYUV422toRGBA8edge: 400 cases PASS; instruction coverage source 113/113, original 113/113
TMCJPEGDEC_converterYUV420toRGBA8: 100 cases PASS; instruction coverage source 153/153, original 153/153
TMCJPEGDEC_converterYUV420toRGBA8edge: 400 cases PASS; instruction coverage source 120/120, original 120/120
TMCJPEGDEC_converterYUV211toRGBA8: 100 cases PASS; instruction coverage source 104/104, original 104/104
TMCJPEGDEC_converterYUV211toRGBA8edge: 400 cases PASS; instruction coverage source 115/115, original 115/115
TMCJPEGDEC_converterYUV444toRGBA8: 100 cases PASS; instruction coverage source 97/97, original 97/97
TMCJPEGDEC_converterYUV444toRGBA8edge: 400 cases PASS; instruction coverage source 110/110, original 110/110
TMCJPEGDEC_converterYUV400toRGBA8: 100 cases PASS; instruction coverage source 57/76, original 57/76
TMCJPEGDEC_converterYUV400toRGBA8edge: 400 cases PASS; instruction coverage source 70/89, original 70/89
TMCJPEGDEC_set_converterRGBA8: 1024 cases PASS; instruction coverage source 168/169, original 169/170
TMCJPEGDEC_converterYUV411toRGB565: 100 cases PASS; instruction coverage source 217/217, original 217/217
TMCJPEGDEC_converterYUV411toRGB565edge: 400 cases PASS; instruction coverage source 106/106, original 106/106
TMCJPEGDEC_converterYUV422toRGB565: 100 cases PASS; instruction coverage source 136/136, original 136/136
TMCJPEGDEC_converterYUV422toRGB565edge: 400 cases PASS; instruction coverage source 107/107, original 107/107
TMCJPEGDEC_converterYUV420toRGB565: 100 cases PASS; instruction coverage source 141/141, original 141/141
TMCJPEGDEC_converterYUV420toRGB565edge: 400 cases PASS; instruction coverage source 114/114, original 114/114
TMCJPEGDEC_converterYUV211toRGB565: 100 cases PASS; instruction coverage source 98/98, original 98/98
TMCJPEGDEC_converterYUV211toRGB565edge: 400 cases PASS; instruction coverage source 109/109, original 109/109
TMCJPEGDEC_converterYUV444toRGB565: 100 cases PASS; instruction coverage source 91/91, original 91/91
TMCJPEGDEC_converterYUV444toRGB565edge: 400 cases PASS; instruction coverage source 104/104, original 104/104
TMCJPEGDEC_converterYUV400toRGB565: 100 cases PASS; instruction coverage source 51/70, original 51/70
TMCJPEGDEC_converterYUV400toRGB565edge: 400 cases PASS; instruction coverage source 64/83, original 64/83
TMCJPEGDEC_set_converterRGB565: 1024 cases PASS; instruction coverage source 168/169, original 169/170
TMCJPEGDEC_IdctBlock_Lumi: 704 cases PASS; instruction coverage source 257/257, original 257/257
TMCJPEGDEC_IdctBlock_Col: 704 cases PASS; instruction coverage source 454/454, original 454/454
TOTAL: 9456 differential cases PASS; GPR14-GPR31, stack pointer and LR preserved

View File

@@ -0,0 +1,319 @@
#!/usr/bin/env python3
"""Read-only, bounded PPC integer interpreter for differential JPEG checks.
Loads source and original ELF .text; never copies original code into sources.
Only memset is external. No FPU/system instructions are supported.
"""
import random
import re
import struct
import zlib
import capstone
from elftools.elf.elffile import ELFFile
U32 = 0xFFFFFFFF
def signed(x):
x &= U32
return x - 0x100000000 if x & 0x80000000 else x
def rotate(x, n):
return (x << n | x >> (32 - n if n else 32)) & U32
def mask(b, e):
return sum((1 << 31 - i for i in range(32) if b <= i <= e or (b > e and (i >= b or i <= e))))
def load_object(path):
with open(path, 'rb') as f:
e = ELFFile(f)
section = e.get_section_by_name('.text')
data = bytearray(section.data())
syms = e.get_section_by_name('.symtab')
calls = {}
symbol_addresses = {}
rel = e.get_section_by_name('.rela.text')
if rel:
for r in rel.iter_relocations():
name = syms.get_symbol(r['r_info_sym']).name
off = r['r_offset']
typ = r['r_info_type']
addr = 0x800000 + (zlib.crc32(name.encode()) & 0x7FFF) * 4 + r['r_addend']
assert addr not in symbol_addresses or symbol_addresses[addr] == name
symbol_addresses[addr] = name
if typ == 10:
calls[off] = name
elif typ == 4:
data[off:off + 2] = struct.pack('>H', addr & 65535)
elif typ == 6:
data[off:off + 2] = struct.pack('>H', addr + 0x8000 >> 16 & 65535)
else:
raise ValueError(('relocation', typ))
dis = capstone.Cs(capstone.CS_ARCH_PPC, capstone.CS_MODE_32 | capstone.CS_MODE_BIG_ENDIAN)
funcs = {}
for sym in syms.iter_symbols():
if sym['st_info']['type'] != 'STT_FUNC' or not sym['st_size']:
continue
start = sym['st_value']
size = sym['st_size']
inst = {}
for i in dis.disasm(bytes(data[start:start + size]), start):
ops = []
for o in i.op_str.split(', '):
if not o:
continue
if o.startswith('cr'):
ops.append(('cr', int(o[2:])))
elif o.startswith('r'):
ops.append(int(o[1:]))
elif '(' in o:
off, reg = o.split('(')
ops.append((int(off, 0), int(reg[1:-1])))
else:
ops.append(int(o, 0))
inst[i.address] = (i.mnemonic, ops)
funcs[sym.name] = (start, inst, calls)
return funcs
def run(fn, initial, args):
pc, ins, calls = fn
mem = bytearray(initial)
r = [i * 1122867 & U32 for i in range(32)]
r[1] = 0x3F000
r[3:3 + len(args)] = args
saved_registers = r[14:].copy()
cr = [0] * 8
ctr = 0
lr = 0
steps = 0
coverage = set()
def ld(a, n):
assert 0 <= a <= len(mem) - n, hex(a)
return int.from_bytes(mem[a:a + n], 'big')
def st(a, v, n):
assert 0 <= a <= len(mem) - n, hex(a)
mem[a:a + n] = (v & (1 << 8 * n) - 1).to_bytes(n, 'big')
while True:
steps += 1
if steps > 100000:
raise RuntimeError('step bound')
coverage.add(pc)
op, a = ins[pc]
pc += 4
dot = op.endswith('.')
op = op.rstrip('.')
val = None
if op == 'blr':
break
elif op == 'bl':
assert calls.get(pc - 4) == 'memset', calls.get(pc - 4)
assert r[3] + r[5] <= len(mem)
mem[r[3]:r[3] + r[5]] = bytes([r[4] & 255]) * r[5]
# Model ABI-permitted call clobbers rather than preserving temporaries.
for reg in [0] + list(range(4, 13)):
r[reg] = (0xBAD00000 + reg) & U32
for field in [0, 1, 5, 6, 7]:
cr[field] = -1
lr = pc
elif op == 'b':
pc = a[0]
elif op == 'bdnz':
ctr = ctr - 1 & U32
if ctr:
pc = a[0]
elif op in ['beq', 'bne', 'ble', 'bge', 'blt', 'bgt']:
c = cr[a[0][1]] if len(a) > 1 else cr[0]
if {'beq': c == 0, 'bne': c != 0, 'ble': c <= 0, 'bge': c >= 0, 'blt': c < 0, 'bgt': c > 0}[op]:
pc = a[-1]
elif op in ['cmpwi', 'cmpw', 'cmplw']:
c = a[0][1] if isinstance(a[0], tuple) else 0
a = ins[pc - 4][1]
if isinstance(a[0], tuple):
a = a[1:]
x = r[a[0]]
y = a[1] if op == 'cmpwi' else r[a[1]]
if op != 'cmplw':
x = signed(x)
y = signed(y)
cr[c] = (x > y) - (x < y)
elif op in ['lbz', 'lhz', 'lwz', 'lmw']:
off, reg = a[1]
addr = (r[reg] if reg else 0) + off & U32
if op == 'lmw':
for j in range(a[0], 32):
r[j] = ld(addr + (j - a[0]) * 4, 4)
else:
r[a[0]] = ld(addr, {'lbz': 1, 'lhz': 2, 'lwz': 4}[op])
elif op in ['stb', 'sth', 'stw', 'stwu', 'stmw']:
off, reg = a[1]
addr = (r[reg] if reg else 0) + off & U32
if op == 'stmw':
for j in range(a[0], 32):
st(addr + (j - a[0]) * 4, r[j], 4)
else:
st(addr, r[a[0]], {'stb': 1, 'sth': 2, 'stw': 4, 'stwu': 4}[op])
if op == 'stwu':
r[reg] = addr
elif op in ['stbx', 'sthx']:
st((r[a[1]] if a[1] else 0) + r[a[2]] & U32, r[a[0]], 1 if op == 'stbx' else 2)
elif op == 'mflr':
r[a[0]] = lr
elif op == 'mtlr':
lr = r[a[0]]
elif op == 'mtctr':
ctr = r[a[0]]
else:
d = a[0]
if op == 'li':
val = a[1]
elif op == 'lis':
val = a[1] << 16
elif op == 'mr':
val = r[a[1]]
elif op == 'add':
val = r[a[1]] + r[a[2]]
elif op == 'addi':
val = (r[a[1]] if a[1] else 0) + a[2]
elif op == 'addis':
val = (r[a[1]] if a[1] else 0) + (a[2] << 16)
elif op == 'subf':
val = r[a[2]] - r[a[1]]
elif op == 'subfic':
val = a[2] - r[a[1]]
elif op == 'mulli':
val = r[a[1]] * a[2]
elif op == 'mullw':
val = r[a[1]] * r[a[2]]
elif op == 'divw':
x = signed(r[a[1]])
y = signed(r[a[2]])
val = abs(x) // abs(y) * (-1 if (x < 0) != (y < 0) else 1)
elif op == 'or':
val = r[a[1]] | r[a[2]]
elif op == 'andc':
val = r[a[1]] & ~r[a[2]]
elif op == 'andi':
val = r[a[1]] & a[2]
elif op == 'neg':
val = -r[a[1]]
elif op == 'extsb':
val = (r[a[1]] & 255) - (256 if r[a[1]] & 128 else 0)
elif op == 'srawi':
val = signed(r[a[1]]) >> a[2]
elif op == 'srwi':
val = r[a[1]] >> a[2]
elif op == 'slwi':
val = r[a[1]] << a[2]
elif op == 'clrlwi':
val = r[a[1]] & (1 << 32 - a[2]) - 1
elif op == 'rotlwi':
val = rotate(r[a[1]], a[2])
elif op == 'rlwinm':
val = rotate(r[a[1]], a[2]) & mask(a[3], a[4])
else:
raise ValueError((hex(pc - 4), op, a))
r[d] = val & U32
if dot:
cr[0] = (signed(val) > 0) - (signed(val) < 0)
assert r[1] == 0x3F000, 'Stack pointer not restored'
assert lr == 0, 'Link register not restored'
assert r[14:] == saved_registers, 'Nonvolatile registers not restored'
return (mem, r[3], coverage)
def put(m, a, v, n=4):
m[a:a + n] = (v & (1 << 8 * n) - 1).to_bytes(n, 'big')
def compare(src, orig, name, m, args, case, returns=False):
a, ra, ca = run(src[name], m, args)
b, rb, cb = run(orig[name], m, args)
# The stack can differ because each implementation owns its frame.
if a[:0x3E000] != b[:0x3E000]:
diff = [hex(i) for i in range(0x3E000) if a[i] != b[i]][:12]
raise AssertionError((name, case, 'memory mismatch', diff))
if returns and ra != rb:
raise AssertionError((name, case, 'return', ra, rb))
return (ca, cb)
def main():
total_cases = 0
rng = random.Random(449529)
root = 'build/43U/{}/libs/RVLMiddleware/TMC_JPEG/src/{}'
for unit in ['texturecvtr/Texture_MCUtoRGBA8', 'texturecvtr/Texture_MCUtoRGB565', 'buffer/idct_block_var']:
src = load_object(root.format('src', unit) + '.o')
orig = load_object(root.format('obj', unit) + '.o')
assert src.keys() == orig.keys(), (unit, 'Function sets differ')
assert len(src) == (2 if unit.startswith('buffer/') else 13)
for name in src:
n = 0
sa = set()
sb = set()
if 'IdctBlock' in name:
for rows in range(1, 9):
for cols in [1, 2, 3, 8]:
for pattern in range(22):
m = bytearray([0xA5]) * 0x40000
block = [0] * 64
for y in range(rows):
for x in range(cols):
if pattern < 6:
block[y * 8 + x] = [0, 1, -1, 0x3FFFF, 0x40000, -0x40000][pattern] if x == 0 and y == 0 else 0
elif pattern < 14:
block[y * 8 + x] = rng.randrange(-10000, 10001) if rng.randrange(4) == 0 else 0
else:
block[y * 8 + x] = rng.randrange(-150000, 150001)
for i, v in enumerate(block):
put(m, 0x1000 + i * 4, v)
pitch = [8, 16, 32][pattern % 3]
args = [0x1000, 0x2000, pitch, rows << 4 | cols]
ca, cb = compare(src, orig, name, m, args, (rows, cols, pattern))
sa |= ca
sb |= cb
n += 1
elif 'set_converter' in name:
for component in range(256):
for mode in [1, 2, 4, 8]:
m = bytearray([0xA5]) * 0x40000
work = 0x1000
state = 0x4000
put(m, work + 0x17FC, component, 1)
put(m, work + 0x19DC, mode, 1)
put(m, work + 0x19E4, state)
put(m, state + 0x24, rng.randrange(65536), 2)
put(m, state + 0x26, rng.randrange(65536), 2)
ca, cb = compare(src, orig, name, m, [work], (component, mode), True)
sa |= ca
sb |= cb
n += 1
else:
sampling = re.search('YUV(\\d+)to', name)[1]
w, h = {'411': (32, 8), '422': (16, 8), '420': (16, 16), '211': (8, 16), '444': (8, 8), '400': (8, 8)}[sampling]
for scale in [1, 2, 4, 8]:
for pattern in range(25):
for border in range(4 if name.endswith('edge') else 1):
m = bytearray([0xA5]) * 0x40000
work = 0x1000
state = 0x4000
tex = 0x8000
x = 32 * (pattern % 2)
y = 16 * (pattern % 3)
ww = w // scale
hh = h // scale
put(m, work + 0x19E4, state)
put(m, state + 0x20, scale, 1)
put(m, state + 0x2C, 96)
put(m, state + 0x48, tex)
put(m, state + 0x18, x if border & 1 else x + 1)
put(m, state + 0x1C, y if border & 2 else y + 1)
put(m, state + 0x16, pattern % (ww + 1), 1)
put(m, state + 0x17, pattern % (hh + 1), 1)
for i in range(0x184):
m[work + 0x1858 + i] = [0, 127, 128, 255][pattern % 4] if pattern < 4 else rng.randrange(256)
ca, cb = compare(src, orig, name, m, [work, x, y], (scale, pattern, border))
sa |= ca
sb |= cb
n += 1
total_cases += n
print(f'{name}: {n} cases PASS; instruction coverage source {len(sa)}/{len(src[name][1])}, original {len(sb)}/{len(orig[name][1])}', flush=True)
print(f'TOTAL: {total_cases} differential cases PASS; GPR14-GPR31, stack pointer and LR preserved')
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,130 @@
# revisit leaf — second-pass evidence (agent/w1007/revisit @ origin/main 29fe1efa)
Scope: iplSDChannelTitle (99.98883), ut_ArchiveFontBase (98.52), lyt_window (99.76),
iplMemoryCardManager (97.88). Post-#834 (linkgap emit gates + .data object names).
## iplSDChannelTitle — all gates landed
Per-TU `IPL_SD_CHANNEL_TITLE_CPP` declared-only gates applied to:
RuntimeTypeInfo.h DynamicCast, iplMathTypes.h VEC3 3-arg ctor, GUIManager.h
(EventHandler setManager/setLatestEventCtrlNo/getLatestEventCtrlNo,
Component setTriggerTarget, PaneComponent setPane/getPane), iplGraphics.h
setOrthoTrans/setOrthoScale, iplSceneBase.h isReady/isResetProcessDone/getParent/
getChild/getNext/getPrev, iplFaderSceneBase.h initCalcNormal/calcCommonAfter,
iplNand.h File::isFinished/checkData, iplInterporation.h HermiteIntp<f32>::get
(nested under IPL_CHANNEL_TITLE_NOVTABLE spec), Rect.h 0-arg ctor
(IPL_SOUND_RECT_OUT_OF_LINE gate), iplGuiManager.h ~PaneManager.
Deleted 2 unreferenced extern "C" trampolines (onTitleButtonEvent/onTitlePaneEvent)
orig lacks. Result: all data sections 100%; .text 99.98883.
### VERIFIED WALL — dtor emission policy (decl-immune)
Residual .text gap = 2 unreferenced weak deleting-dtor bodies
(~FaderSceneBase 88B + ~FrameController 64B) + ~5 dangling no-reloc UNDs
(__vt__LangFile, __vt__SDButtonEventHandlerBase, __vt__FrameController,
mArg/typeInfo syms — symtab noise, no relocs). Orig's TU had these dtors
trivial/implicit: ~SDChannelTitle calls ~Base directly (28 insns), Rect
temporaries carry no dtor calls, so correct forms are `virtual ~X() {}`
inline or NO decl at all. Declaring them out-of-line adds real `bl` calls →
fuzzy dropped 99.98883→99.55799. Implicit/non-virtual variants still emit the
weak bodies AND slightly regress — front-end-level MWCC instantiation drag,
no decl form eliminates it. Remaining fn wall: flushSaveBeforeExit 98.59 —
&smArg materialization register choice (orig r3→scratch r4, mine r4/r5→recv-first);
8+ source forms all shift the home, never to r3.
## ut_ArchiveFontBase — ConstructOpAnalyzeGLGR 92.09 (956B)
20 normalized diffs, insns 116-147 of 239 — issue-order inside the
ready-set around the CalcOffsetSheetFlags/CalcSizeFlagSet scratch math.
Orig hoists lhz 0x1c (sheetGlyphCount) / lhz 0x24 (sheetCount) / lhz 0xe
(dataBlockCount) + lwz 0x4c(r20) into the marshal block.
FAILED variants: decl-order swap of the three u16s (identical 20 diffs —
scheduler ignores decl order); moving ctx->m* tail stores adjacent to the
u16 loads (regressed 20→108, whole-web rotation). Conclusion: pure list-
scheduling tie, same family as before.
## lyt_window — DrawFrame 98.18 (1504B)
376=376 insns. One callee-window permutation: orig numbers the static
flipInfos[] array base early (r21, first materialized at insn 36) pushing
arg webs to r27-r31; mine puts it deepest (r31), args r26-r30. Same web
count (12 callee webs r20-r31 both), identical prologue/epilogue; only the
allocator's numbering differs. Plus a repeated stfsx/fadds store-weave in
the 4 DRAW_QUAD_FOR_FRAME_1 corner blocks.
FAILED variants: scoping polPt/polSize inside the macro (385 insns,
worse); moving texSize decl after polPt/polSize (372 insns, worse).
NOTE: paired-single ops — capstone can't decode psq_*/ps_* insns, so
ndiff.py/disasm_fn.py truncate at the first one; use raw-word diffs.
## iplMemoryCardManager — 8 sub-100 fns all decomposed
- isMoveEnable/isCopyEnable (99.83), update_file_array (99.72),
getComment (98.94): 0 normalized diffs — pure regname webs.
- isBannerEnable (92.31, 26 insns, 7 diffs) + getBlocks (92.0, 25 insns,
6 diffs): single diff = `addi r11,r1,0x20` restgpr-setup placement —
orig emits it at tail (after the full member-chain load), mine hoists
to slot 11. Folded-return variant (`return icons[slot][mFile..]` no
locals) emits identical code — scheduler-internal, decl-form insensitive.
Folded form kept (same output, terser).
- _create_icon (87.55) + create_banner (90.42): `(base+const)+var`
member-chain regroup — orig computes (&mFileCell + memberOffs) +
(slot*row + file*0x15C combined index) with `this+0x10EC`/`this+0x110C`
bases cached in callee regs reused across both GX_TF branches, and
rematerializes &cell.icon per call (`add r3,...` then `add r24,...`
post-bl) while mine pins it; marshal order `li r4,0` before `mr r3`
in orig. FAILED variants: `MCFileCell* cell = &mFileCell[slot][file]`
(90 insns — MWCC folded the pointer, worse); `mFileCell[0] +
slot*0x7F + file` flat-index (89 insns — aggressive CSE, worse).
Same documented mcard2 wall.
All units stay NonMatching — no shims, no flips. Every residual is a
verified allocator/scheduler/emission-policy tie with source-form evidence.
## Round 2 (post-#834 rebase @11c75ddb) — sdChannelTitle emit-parity probe
Investigated per orchestrator hint whether the 152B weak-dtor + dangling-UND
residual was the same dedup-loss family as channelTitle's symbols.txt fix.
VERDICT: NOT a naming issue and NOT a flip blocker.
- orig iplSDChannelTitle.o: ZERO weak FUNC syms. Mine emits 2 unreferenced
weak deleting-dtor bodies: `__dt__FaderSceneBase` (88B @0x1f4) +
`__dt__FrameController` (64B @0xb30), plus 3 zero-reloc UND vtable refs
(`__vt__FrameController`, `__vt__SDButtonEventHandlerBase`, `__vt__LangFile`).
- orig iplFaderSceneBase.o's own view: `~FaderSceneBase` is DECLARED-ONLY
(its `__dt__` is UND there, defined in another TU).
- Tried `__declspec(novtable)` on all 4 classes under
IPL_SD_CHANNEL_TITLE_CPP: removed the 3 dangling `__vt__` UNDs (correct
mechanism — orig stores only most-derived vt) but weak bodies persisted.
- Tried implicit-trivial dtor (removing decl): `__dt__FrameController` emit
STOPPED (64B gone), but `calc()` vtable slot shifted 0x0c→0x08 →
calcFadein/calcFadeout single-word diffs (`lwz r12,0x0c(r12)` vs 0x08)
→ REVERTED everything.
- CRITICAL PROOF these bodies are harmless: main's iplChannelTitle.o
(unit fuzzy 100.0 post-#834) emits the IDENTICAL `__dt__FaderSceneBase`
88B + `__dt__FrameController` 64B weak bodies that orig's .o lacks.
They are linker-stripped dead emission; objdiff fn-pairing ignores them.
=> The 152B was never the blocker. Real residual = flushSaveBeforeExit
98.59 only.
## flushSaveBeforeExit — 6-diff → 2-diff minimum
Window is the `sm` (System globals) base web: orig binds &sm to r3 and
loads +0x94→r4 (store), +0x28→r4 (heap arg), +0x94→r3 (recv); mine binds
r4 and marshals recv before arg. Variants:
- saveHeap decl hoisted above getSDPrevPage store: 2 diffs (base→r5,
+0x28 load moved early) — closer but not orig's order.
- `flushAsync(System::getMem2App())` inline: same 2 diffs, base→r4.
Residual = base-web home + marshal eval order — allocator tie.
## GLGR — ready-set issue-order re-probes
- def-move (sheetGlyphCount/dataBlockCount to tail): 20→99 diffs, REGRESSION.
- `u32 remWorkSpace = ctx->remWorkSpace()` hoist: 20→25, REGRESSION.
- stepSheetFlags after flagsSheetsOff (dependency-chain reorder): identical
20 diffs — MWCC issue-order insensitive to stmt order here. Wall stands.
## DrawFrame / MCManager re-verified
DrawFrame 376=376: flipInfos base pinned r21(orig)/r31(mine) + stfsx weave
— callee-numbering tie unchanged. create_banner/_create_icon: `(base+const)
+var` regroup + recompute-vs-CSE (`add r3,r29,r25` remat per call in orig)
— same documented wall.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
# Run fixed-stack relocation correction
This is a narrow follow-up to #973, not another Run implementation or a new
match. The existing assembly, cache loop, register clearing, labels and handoff
remain intact. No linking flag changes.
## Evidence
The hash-verified original DOL and linked ELF contain Run at 0x8137B3EC,
size 0xAC (43 instructions). Its instructions at 0x8137B468/0x8137B46C establish
SP as 0x81600000. This architectural stack value should not depend on placement
of an unrelated formatted-output routine.
Automatic extraction had attached two relocations to __pformatter + 0x280:
R_PPC_ADDR16_HI at Run+0x7E and R_PPC_ADDR16_LO at Run+0x82. The linked formatter
address happens to make this expression equal 0x81600000 in this target, but
that is a false semantic dependency in the reconstruction.
DTK block_relocations uses instruction addresses, not ELF halfword offsets.
The two exclusions are therefore .text:0x8137B468 and .text:0x8137B46C.
The source removes the unrelated extern and uses the fixed high/low immediate.
No other source instructions or original bytes are replaced.
## Independent validation
- Full 43U all_source, progress, report and DOL check pass.
- Original app and rebuilt DOL SHA1 both remain
26116613f624061ba99c8d1a299aaa6efa85670d.
- Run remains 100%, 43/43 instructions, ctxdiff zero. No new match attribution.
- Whole report is unchanged: no code, data, function, linking or fuzzy delta.
- Pool: all 91 strings identical.
- All 1027 native source objects compared: only BS2Mach .text changes; size
16960 is unchanged. Exactly the two false text relocations are removed.
All other allocated objects and data sections are unchanged.
- All 1027 active extracted objects compared, plus the same obsolete cached
tiManager.o in both trees. Only BS2Mach .text changes: size 16980 unchanged;
only Run's high immediate placeholder bytes at +0x7E/+0x7F become 0x81,0x60.
Exactly the two formatter relocations disappear, with no added relocations.
Defined target symbols and non-text sections stay unchanged.
- Supplemental integer-PPC contract model checks the compiled source for 1,
4 and 131072 cache lines, preserved LR entry, SP 0x81600000, cleared GPRs and
alternating dcbz/dcbf events. The zero-count prefix retains the original CTR
wrap to 0xFFFFFFFF; the full 2^32-iteration path is not executed. This is an
abstract contract test, not actual cache/MMIO or console execution.
- Workflow/literal/jump-table/pool tests: 8/36/27/8 passed.
- Diff check passes.
Assembly was already introduced by #973. The original isolated full-Run
experiment is deliberately not included here. This correction adds no new
assembly instructions, forced register uses, retail .s objects or padding.
Please review the metadata/source constant attribution explicitly.

View File

@@ -0,0 +1,86 @@
# scene4 leaf — decode attempts & evidence
Branch `agent/w1008/scene4` off origin/main@e3457d11.
Scope: iplAddress, iplAddressEdit, iplSDChannelSelect are the only sub-100 units in
the scene/address + sdChannelSelect remainder (iplAddressAddSel, iplAddressInputName,
iplAddressSelect, addressHelpers, addressInputHelpers, agreeSettings, agreeHttp,
iplFaceSelect, iplNCDSetting all verified already 100% on main; no open PR claims).
## Decodes that landed (this leaf)
### Single-case `switch` produces the `b<eq> caseblock; b after` 2-branch guard
`switch (x) { case C:` emits `cmp; beq caseblock; b exit` — MWCC keeps the
dispatch's second `b` because the case-block is a separate labelled region.
Equivalent `if`, `if||`, `if&&`, `goto`-goto, `if/else`-goto all get normalized
to a single fused `beq`/`bne`. Used in:
- `Address::start_drag_event` (892B): outer `switch (mState) { case STATE_NORMAL:`
+ inner `switch (mMode) { case 0:` reproduces orig's two nested 2-branch guards.
Residual: 7 word diffs, pure regname — nigaoe web pinned r26 (orig) vs r29
(mine), miiPane web r29 vs r26. Allocator home-order tie; decl-hoist of
miiPane above the `if` was a no-op (web homes unchanged).
- `Address::onEventDerived` (1080B): TRIG case falls through to ON_POINT
(orig has NO `break`); the `mState == COVER_NORMAL || mState == NORMAL`
guard folds to `beq`+`bne` inside the TRIG case. Residual: 81 word diffs,
all regname — insn sequence identical.
### `addic.` fusion for `ptr = base + const` NULL-tested members
`record->attr.name` tested `!= 0` fuses into `addic.` only when the pointer is
materialized lazily at the compare — decl the local inside the `if`. Hoisted
decls emit `addi`+`cmpwi`. (movePane_onDrag `name` web.)
## Walls re-verified (evidence)
### `Address::movePane_onDrag` 92.45 (620 orig vs 612 mine)
- Orig emits `bne next; b exit` 2-branch guards for both `textBox != NULL` and
`name != NULL` (the `b` skips to the shared `width += 0.01f` block).
- This is switch-dispatch-shaped, but every legal polarity fails:
`switch(ptr) { case NULL: break; default: body }` bool-materializes
(`addic/subfe/cmpwi 1` — +3 insns); `switch (p != NULL) { case true:` also
bool-materializes; `do { if (!x) break; } while (0)` folds to single `beq`.
- Orig computes the record math (`lwz 0x70 / mulli 5 / lwz 0x274 / mulli 0x140`)
before the textBox branch — scheduler interleave around the guard.
- Residual also regname r27↔r29 (textBox web) + loop `name` web.
### `FriendListCache::update` 95.5 (160 orig vs 156 mine)
Orig remats `mInfos + index*0x140` per use site (memset, wcsncpy,
updateFriendInfo = 3 `mulli`+`add` pairs). Mine CSEs into callee r31.
`getInfo(index)` vs `mInfos[index]` vs `(int)index` cast — all VN-identical,
still CSE. Remat-vs-pin in the unusual remat-is-orig direction; no lever.
### `AddressEdit::create` 97.45 (3280B)
Two distinct residuals:
- Wholesale r30↔r31 web-order swap: orig pins string-table const web in r31
and `boardFile` (getScene+0xd20) in r30; mine the reverse. Webs born in the
same source order — allocator processing order tie.
- `friendText` (this+0x2b4 / this+0x2cc) pin: orig materializes
`addi r25, r29, 0x2b4` at decl point between `initFrame()` and `restart()`,
reassigns `addi r25, r29, 0x2cc` mid-block — the reg+const web is pinned.
Mine remats `addi r5, r29, 0x2b4` at each marshal. Variants tried: non-const
`wchar_t*`, decl moved before `animator =` — both no-op. Same this+const
pin family as get_friendinfo.
### `AddressEdit::get_friendinfo` 88.04 (336 orig vs 328 mine)
Orig: this→r28, `this+0x2b4` (mName) pinned in r29 materialized before the
FindPaneByName marshal — 2 extra insns vs mine's marshal-site remats, and one
more callee web (savegpr_28 vs my _29 window differs). Same `this+const`
pin-vs-remat wall as create's friendText.
### `AddressEdit::update_friendinfo` 99.42 (152B)
Single 2-insn scheduling swap: `addi r4,r30,0x2b4` vs `addi r3,r31,8` order
in the wcsncpy marshal.
### iplSDChannelSelect 99.58 — 7 fns
- `create` 97.74: regname r29↔r30 swap + marshal interleaves around `bl`s
(scheduler family); insn count equal.
- `collectTitles*` ×4 (97.29–97.83): documented ties — callee-web rotations
around the same ES_GetTitleCount/ES_GetTitles marshal blocks.
- `flushSaveDataAndMountSD` 99.66 (140B): marshal order tie.
- `setChannelScissor` 93.47 (932B): fp/scheduling family (DrawFrame-class).
## Notes
- ndiff.py NORMALIZES register names — "diffs 0" can hide regname-only
diffs. Always confirm with raw byte-compare of `.text` (readelf -sW for
addr/size, -SW for file offset).
- `objdiff-cli diff` is interactive-only (fails headless); use disasm_fn.py
+ byte-compare.