diff --git a/include/iplMemoryCardLib.h b/include/iplMemoryCardLib.h index d7ba0e14..a79647d7 100644 --- a/include/iplMemoryCardLib.h +++ b/include/iplMemoryCardLib.h @@ -10,7 +10,7 @@ namespace ipl { volatile u16 size; // 0x02 u8 canCopy; // 0x04 u8 canMove; // 0x05 - u16 unk_0x06; // 0x06 + u16 transferBlocked; // 0x06 u32 key; // 0x08 } FileInfo; // 0x0C @@ -21,21 +21,21 @@ namespace ipl { vu16 reservedSlot; // 0x04 vu16 reservedCommand; // 0x06 vu32 key; // 0x08 - vu16 unk_0x0C; // 0x0C - vu16 unk_0x0E; // 0x0E + vu16 totalBlocks; // 0x0C + vu16 freeFiles; // 0x0E vu16 freeBlocks; // 0x10 - vu16 unk_0x12; // 0x12 + vu16 titleBlocks; // 0x12 } CardState; // 0x14 typedef struct IconState { volatile u8 bannerEnable; // 0x00 - u8 unk_0x01; // 0x01 - u8 unk_0x02; // 0x02 + u8 iconEnable; // 0x01 + u8 iconCount; // 0x02 u8 bannerType; // 0x03 s8 anmDelta; // 0x04 u8 anmType; // 0x05 - u8 unk_0x06; // 0x06 - u8 unk_0x07; // 0x07 + u8 anmFirstFrameDuration; // 0x06 + u8 anmLastFrameDuration; // 0x07 u8 iconFmt[8]; // 0x08 #ifdef IPL_MEMORY_CARD_MANAGER_CPP volatile u16 anmFrameBits; diff --git a/include/utility/iplScroller.h b/include/utility/iplScroller.h index b856b815..64f1fb94 100644 --- a/include/utility/iplScroller.h +++ b/include/utility/iplScroller.h @@ -55,7 +55,7 @@ namespace ipl { void init() { mState = 0; mScroll = 0.0f; - unk_0x3C = 0.0f; + mScrollVelocity = 0.0f; mUpLimit = 0.0f; mDownLimit = 0.0f; } @@ -92,7 +92,7 @@ namespace ipl { int mState; // 0x30 f32 mDownLimit; // 0x34 f32 mUpLimit; // 0x38 - f32 unk_0x3C; + f32 mScrollVelocity; f32 mScroll; // 0x40 f32 mButtonScrollOrigin; f32 mVelocityDecay; diff --git a/src/scene/cardSequence/iplCardSequence.cpp b/src/scene/cardSequence/iplCardSequence.cpp index 808bbe59..084db560 100644 --- a/src/scene/cardSequence/iplCardSequence.cpp +++ b/src/scene/cardSequence/iplCardSequence.cpp @@ -353,8 +353,8 @@ extern "C" void clearCardFileEntry(s32 slot, s32 index) { sThread->files[slot][index].size = 0; sThread->files[slot][index].canCopy = 1; sThread->files[slot][index].canMove = 1; - sThread->files[slot][index].unk_0x06 = 0; - sThread->icons[slot][index].unk_0x01 = 0; + sThread->files[slot][index].transferBlocked = 0; + sThread->icons[slot][index].iconEnable = 0; sThread->icons[slot][index].bannerEnable = 0; OSRestoreInterrupts(interrupts); } @@ -379,14 +379,14 @@ extern "C" void refreshCardSlotInfo(s32 slot) { if (CARDGetResultCode(slot) >= CARD_RESULT_READY) { BOOL interrupts = OSDisableInterrupts(); - sThread->slots[slot].unk_0x0C = ((u32)memSize << 17) / sectorSize - CARD_NUM_SYSTEM_BLOCK; + sThread->slots[slot].totalBlocks = ((u32)memSize << 17) / sectorSize - CARD_NUM_SYSTEM_BLOCK; sThread->slots[slot].key = sectorSize; - sThread->slots[slot].unk_0x0E = freeFiles; + sThread->slots[slot].freeFiles = freeFiles; sThread->slots[slot].freeBlocks = freeBytes / sectorSize; OSRestoreInterrupts(interrupts); OSReport("%d:%dbytes sectorsize , %d blocks , %d freeEntry\n", slot, sThread->slots[slot].key, sThread->slots[slot].freeBlocks, - sThread->slots[slot].unk_0x0E); + sThread->slots[slot].freeFiles); } } @@ -582,7 +582,7 @@ extern "C" void* cardThreadMain(void*) { do { if (sThread->mounted[outerSlot] != 0) { freeBlocks = countCardTitleBlocks(outerSlot, &freeDir); - sThread->slots[outerSlot].unk_0x12 = freeBlocks; + sThread->slots[outerSlot].titleBlocks = freeBlocks; } ++outerSlot; } while (outerSlot < 2); @@ -607,11 +607,11 @@ extern "C" void markAllCardFilesDirty() { fileNo = 0; do { - sThread->files[slot][fileNo].unk_0x06 = 0; + sThread->files[slot][fileNo].transferBlocked = 0; if (sThread->mounted[slot] != 0 && sThread->mounted[slot ^ 1] != 0 && checkCardFileDuplicate((u8)slot, (s16)fileNo) < 0) { - sThread->files[slot][fileNo].unk_0x06 = flagValue; + sThread->files[slot][fileNo].transferBlocked = flagValue; } ++fileNo; @@ -701,19 +701,19 @@ static inline s32 readCardImages(s32 slot, s32 fileNo, CARDDir* dir, CARDFileInf s32 sectorSize; if (CARDGetSectorSize(slot, (u32*)§orSize) < CARD_RESULT_READY) { sThread->icons[slot][fileNo].bannerEnable = 0; - sThread->icons[slot][fileNo].unk_0x01 = 0; + sThread->icons[slot][fileNo].iconEnable = 0; return 0; } u32 fileSize = (u32)dir->length * sectorSize; if (address > fileSize) { sThread->icons[slot][fileNo].bannerEnable = 0; - sThread->icons[slot][fileNo].unk_0x01 = 0; + sThread->icons[slot][fileNo].iconEnable = 0; return 0; } if (address + transferSize > fileSize) { sThread->icons[slot][fileNo].bannerEnable = 0; - sThread->icons[slot][fileNo].unk_0x01 = 0; + sThread->icons[slot][fileNo].iconEnable = 0; return 0; } @@ -818,10 +818,10 @@ static inline s32 loadCardIconImages(s32 slot, s32 fileNo, CARDDir* dir, CARDFil shift = 0; hasTlut = FALSE; iconImageSize = 0; - sThread->icons[slot][fileNo].unk_0x02 = 0; + sThread->icons[slot][fileNo].iconCount = 0; sThread->icons[slot][fileNo].anmMax = 0; sThread->icons[slot][fileNo].anmFrameBits = dir->iconSpeed; - sThread->icons[slot][fileNo].unk_0x06 = (dir->iconSpeed & CARD_STAT_SPEED_MASK) << 2; + sThread->icons[slot][fileNo].anmFirstFrameDuration = (dir->iconSpeed & CARD_STAT_SPEED_MASK) << 2; icon = 0; iconCount = 0; while (icon < CARD_ICON_MAX) { @@ -829,7 +829,7 @@ static inline s32 loadCardIconImages(s32 slot, s32 fileNo, CARDDir* dir, CARDFil if (iconSpeed != 0) { sThread->icons[slot][fileNo].anmMax += iconSpeed << 2; } else { - sThread->icons[slot][fileNo].unk_0x07 = + sThread->icons[slot][fileNo].anmLastFrameDuration = (u8)(((dir->iconSpeed >> ((iconCount - 1) * 2)) << 2) & 0xC); goto animationDone; } @@ -837,10 +837,10 @@ static inline s32 loadCardIconImages(s32 slot, s32 fileNo, CARDDir* dir, CARDFil shift = shift + 2; ++icon; } - sThread->icons[slot][fileNo].unk_0x07 = (dir->iconSpeed >> 0xC) & 0xC; + sThread->icons[slot][fileNo].anmLastFrameDuration = (dir->iconSpeed >> 0xC) & 0xC; animationDone: if ((dir->iconSpeed & CARD_STAT_SPEED_MASK) == 0 || (dir->iconFormat & CARD_STAT_ICON_MASK) == 0) { - sThread->icons[slot][fileNo].unk_0x01 = 0; + sThread->icons[slot][fileNo].iconEnable = 0; iconImageSize = 0; } else { for (iconCount = 0; iconCount < CARD_ICON_MAX; ++iconCount) { @@ -873,8 +873,8 @@ animationDone: iconFrameSize + sThread->icons[slot][fileNo].iconOffset[iconCount]; } iconImageSize += iconFrameSize; - sThread->icons[slot][fileNo].unk_0x02 = - sThread->icons[slot][fileNo].unk_0x02 + 1; + sThread->icons[slot][fileNo].iconCount = + sThread->icons[slot][fileNo].iconCount + 1; } else { sThread->icons[slot][fileNo].iconTlutOffset = sThread->icons[slot][fileNo].iconOffset[iconCount]; @@ -884,7 +884,7 @@ animationDone: if (hasTlut) { iconImageSize += 0x200; } - sThread->icons[slot][fileNo].unk_0x01 = 1; + sThread->icons[slot][fileNo].iconEnable = 1; sThread->icons[slot][fileNo].anmType = dir->bannerFormat & 4; sThread->icons[slot][fileNo].anmDelta = 1; } diff --git a/src/scene/memoryCard/iplMemoryCardManager.cpp b/src/scene/memoryCard/iplMemoryCardManager.cpp index 1e9f2ad8..199b4faf 100644 --- a/src/scene/memoryCard/iplMemoryCardManager.cpp +++ b/src/scene/memoryCard/iplMemoryCardManager.cpp @@ -152,8 +152,8 @@ bool MemoryCardManager::isMoveEnable(u8 slot, u32 index, long* code) { if (isDistSlot(slot, NULL) && dirs[slot][file].canMove != 0 && states[slot].key == states[slot ^ 1].key && - states[slot ^ 1].freeBlocks >= dirs[slot][file].size && states[slot ^ 1].unk_0x0E != 0 && - dirs[slot][file].unk_0x06 == 0) { + states[slot ^ 1].freeBlocks >= dirs[slot][file].size && states[slot ^ 1].freeFiles != 0 && + dirs[slot][file].transferBlocked == 0) { result = -0x15; enabled = true; } else { @@ -170,9 +170,9 @@ bool MemoryCardManager::isMoveEnable(u8 slot, u32 index, long* code) { result = -0x1a; } else if (states[slot].key != states[slot ^ 1].key) { result = -0x1b; - } else if (states[slot ^ 1].freeBlocks < dirs[slot][file].size || states[slot ^ 1].unk_0x0E == 0) { + } else if (states[slot ^ 1].freeBlocks < dirs[slot][file].size || states[slot ^ 1].freeFiles == 0) { result = -0x19; - } else if (dirs[slot][file].unk_0x06 != 0) { + } else if (dirs[slot][file].transferBlocked != 0) { result = -0x18; } } @@ -191,8 +191,8 @@ bool MemoryCardManager::isCopyEnable(u8 slot, u32 index, long* code) { if (isDistSlot(slot, NULL) && dirs[slot][file].canCopy != 0 && states[slot].key == states[slot ^ 1].key && - states[slot ^ 1].freeBlocks >= dirs[slot][file].size && states[slot ^ 1].unk_0x0E != 0 && - dirs[slot][file].unk_0x06 == 0) { + states[slot ^ 1].freeBlocks >= dirs[slot][file].size && states[slot ^ 1].freeFiles != 0 && + dirs[slot][file].transferBlocked == 0) { result = -0x15; enabled = true; } else { @@ -209,9 +209,9 @@ bool MemoryCardManager::isCopyEnable(u8 slot, u32 index, long* code) { result = -0x1a; } else if (states[slot].key != states[slot ^ 1].key) { result = -0x1b; - } else if (states[slot ^ 1].freeBlocks < dirs[slot][file].size || states[slot ^ 1].unk_0x0E == 0) { + } else if (states[slot ^ 1].freeBlocks < dirs[slot][file].size || states[slot ^ 1].freeFiles == 0) { result = -0x19; - } else if (dirs[slot][file].unk_0x06 != 0) { + } else if (dirs[slot][file].transferBlocked != 0) { result = -0x18; } } @@ -254,7 +254,7 @@ void MemoryCardManager::update_icon_anm() { mFileCell[slot][file].iconAnmCounter = frame; if ((s16)frame >= icons[slot][file].anmMax) { if (icon->anmType == 4) { - mFileCell[slot][file].iconAnmCounter = icons[slot][file].anmMax - icon->unk_0x07 - 1; + mFileCell[slot][file].iconAnmCounter = icons[slot][file].anmMax - icon->anmLastFrameDuration - 1; icon->anmDelta = -1; } else { mFileCell[slot][file].iconAnmCounter = 0; @@ -263,7 +263,7 @@ void MemoryCardManager::update_icon_anm() { } if (mFileCell[slot][file].iconAnmCounter < 0) { if (icon->anmType == 4) { - mFileCell[slot][file].iconAnmCounter = icon->unk_0x06; + mFileCell[slot][file].iconAnmCounter = icon->anmFirstFrameDuration; } else { mFileCell[slot][file].iconAnmCounter = 0; } diff --git a/src/scene/sdChannelMemory/iplSDMemory.cpp b/src/scene/sdChannelMemory/iplSDMemory.cpp index a039d121..fd6ae153 100644 --- a/src/scene/sdChannelMemory/iplSDMemory.cpp +++ b/src/scene/sdChannelMemory/iplSDMemory.cpp @@ -277,7 +277,7 @@ namespace ipl { void Scroller::init() { mState = 0; mScroll = 0.0f; - unk_0x3C = 0.0f; + mScrollVelocity = 0.0f; mUpLimit = 0.0f; mDownLimit = 0.0f; } diff --git a/src/utility/iplUtility.cpp b/src/utility/iplUtility.cpp index 6a69e0f9..75a4dda3 100644 --- a/src/utility/iplUtility.cpp +++ b/src/utility/iplUtility.cpp @@ -293,7 +293,7 @@ namespace ipl { mState = 0; mDownLimit = 0.0f; mUpLimit = 0.0f; - unk_0x3C = 0.0f; + mScrollVelocity = 0.0f; mScroll = 0.0f; mButtonScrollOrigin = 0.0f; mVelocityDecay = 0.6f; @@ -321,21 +321,21 @@ namespace ipl { switch (mState) { case Pointer::SCROLL_CON_UP: { - unk_0x3C = unk_0x3C * mVelocityDecay - mScrollAcceleration; - if (unk_0x3C > 0.0f) { - unk_0x3C = 0.0f; + mScrollVelocity = mScrollVelocity * mVelocityDecay - mScrollAcceleration; + if (mScrollVelocity > 0.0f) { + mScrollVelocity = 0.0f; } - mScroll += unk_0x3C; + mScroll += mScrollVelocity; mState = Pointer::SCROLL; break; } case Pointer::SCROLL_CON_DOWN: { - unk_0x3C = unk_0x3C * mVelocityDecay; - unk_0x3C += mScrollAcceleration; - if (unk_0x3C < 0.0f) { - unk_0x3C = 0.0f; + mScrollVelocity = mScrollVelocity * mVelocityDecay; + mScrollVelocity += mScrollAcceleration; + if (mScrollVelocity < 0.0f) { + mScrollVelocity = 0.0f; } - mScroll += unk_0x3C; + mScroll += mScrollVelocity; mState = Pointer::SCROLL; break; } @@ -360,7 +360,7 @@ namespace ipl { mScroll = mButtonScrollOrigin + anim.get(); if (!anim.isPlaying()) { - unk_0x3C = 0.0f; + mScrollVelocity = 0.0f; anim.initFrame(); anim.calc(); mState = Pointer::SCROLL; diff --git a/tools/decomp-assist/cleanup2-x11.attempts.md b/tools/decomp-assist/cleanup2-x11.attempts.md new file mode 100644 index 00000000..3446f9cf --- /dev/null +++ b/tools/decomp-assist/cleanup2-x11.attempts.md @@ -0,0 +1,67 @@ +# cleanup2-x11 attempts + +Worktree `/mnt/drive2/projects/wii-ipl-workers/data-d12`, branch `agent/w1009/cleanup2-x11`, baseline `f2006bdd`. +Scope: meaningful names for placeholder data members declared under `include/`, with every compiled use updated in the same focused commit. +Read cleanup-common.md fully, including wave-2 guidance, repository AGENTS.md, unslop, and writing-for-agents. + +## Baseline + +Initial full 43U build passed. All 1028 units and 12563 functions are exact and fully linked; data is 100% matched and linked. +Completion checker returned `DECOMPLETE_OK`. DOL SHA1 is `26116613f624061ba99c8d1a299aaa6efa85670d`. +Saved the report and SHA256 hashes of all 1028 source objects under `/tmp/cleanup2-x11-baseline-*`. + +## Inspection + +Headers ranked by placeholder declarations: iplMemoryCardLib.h has eight, vmPrivate.h has seven, VmTypes.h has three, then Scroller and Exception. +Memory-card capacity fields are assigned from CARDGetMemSize, CARDFreeBlocks, and countCardTitleBlocks. Icon fields are set by loadCardFileIcons and consumed by update_icon_anm. +Scroller's remaining unknown float is accelerated, decayed, and added to its scroll position in calc; it is scroll velocity. Earlier cleanup2-x3 preserved it because that worker only examined the SDMemory initialization use. +Acceptance for each commit: full build, DOL hash, freshly regenerated report, DECOMPLETE_OK, and no changed source-object bytes against the baseline. The final gate covers every object rebuilt because of the changed headers. + +## Renames + +- KEEP CardState `unk_0x0C` -> `totalBlocks`, the usable card capacity after system blocks; `unk_0x0E` -> `freeFiles`, assigned directly from CARDFreeBlocks and tested before copy/move; `unk_0x12` -> `titleBlocks`, assigned from countCardTitleBlocks. Updated the header and exact uses in CardSequence and MemoryCardManager. Full build and DECOMPLETE_OK passed; all 1028 source objects remained byte-identical. Commit `18c20470`. +- KEEP FileInfo `unk_0x06` -> `transferBlocked`. markAllCardFilesDirty sets it when checkCardFileDuplicate returns a negative result, covering duplicates and lookup failures; isCopyEnable and isMoveEnable reject transfers when it is set. The name does not assume every failure means a duplicate exists. Updated the header and exact uses in CardSequence and MemoryCardManager. Full build and DECOMPLETE_OK passed; all 1028 source objects remained byte-identical. Commit `d70e1631`. +- KEEP IconState `unk_0x01` -> `iconEnable`, `unk_0x02` -> `iconCount`, `unk_0x06` -> `anmFirstFrameDuration`, and `unk_0x07` -> `anmLastFrameDuration`. loadCardIconImages disables absent or invalid images, enables a loaded icon sequence, counts populated animation entries, and derives both endpoint durations from CARDDir.iconSpeed. update_icon_anm skips those endpoint holds when reversing a ping-pong animation. Updated the header and exact uses in CardSequence and MemoryCardManager. Full build and DECOMPLETE_OK passed; all 1028 source objects remained byte-identical. Commit `f0a8a213`. +- KEEP Scroller `unk_0x3C` -> `mScrollVelocity`. calc multiplies it by mVelocityDecay, adds or subtracts mScrollAcceleration, and adds the result to mScroll. Updated the header, constructor and calc in iplUtility, and the out-of-line init in SDMemory. Full build and DECOMPLETE_OK passed; all 1028 source objects remained byte-identical. Commit `511384ac`. + +## Kept names + +- vmPrivate.h: all seven pad members have no named uses in the source tree. Their runtime meaning cannot be established from use; keep them. +- VmTypes.h: all three pad declarations have no named uses. Keep their layout names. +- Exception: unk_0x04 and unk_0x0C only appear in zero initialization. That does not establish a purpose. +- System::Arg: unk_0x1C is only assigned NULL. Keep it. +- SDChannelTitle: mUnknownTitleWork and the alternate opaque unk_0x58 storage have no member uses establishing a purpose. Keep both. +- APScanThread's unk_0x2C is a virtual function, and CHANSVm.h's unk0 names function parameters. They are outside this data-member scope. +- Checked pad, padding, unused, and reserved declarations across include. SaveDataManager.padding is zeroed reserved save-file storage; actual layout padding and zero-only unused fields retain their names. No additional used placeholder member has a clear role. + +Nine data members renamed across two headers; all four source users updated. Each rename commit contains only its header and exact use sites. No types, offsets, comments, statement order, compiler workarounds, or configuration changed. + +## Final verification + +Gate ran once with `--quick`, as required by cleanup-common.md, over all 33 units rebuilt after the header edits. These include the four edited source units and 29 dependent units. Every pool is identical; every section is 100%; all 1337 functions are instruction-exact. Full build passed, with zero regressions, forbidden patterns, or readability warnings. + +| Edited source unit | Exact functions before -> after | Code bytes | Data bytes | +| --- | --- | --- | --- | +| src/scene/cardSequence/iplCardSequence | 30/30 -> 30/30 | 9852/9852 | 1496/1496 | +| src/scene/memoryCard/iplMemoryCardManager | 26/26 -> 26/26 | 5396/5396 | 0/0 | +| src/utility/iplUtility | 45/45 -> 45/45 | 5932/5932 | 304/304 | +| src/scene/sdChannelMemory/iplSDMemory | 66/66 -> 66/66 | 20872/20872 | 3344/3344 | + +Final regeneration of build/43U/report.json and the completion checker passed. Compared the regenerated report with the initial baseline: measures, exact-name function records, and section records are identical for all 1028 units. All 1028 source objects remain byte-identical. Normalizing the nine documented renames reproduces the original six files exactly, including whitespace and comments. + +```text +full build: ok +main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d +regressions vs baseline: 0 +forbidden patterns added (net, per file): 0 +readability warnings (net, per file; must be 0 in the final result): 0 +GATE PASS +DECOMPLETE_OK +``` + +Gate transcript: `/tmp/cleanup2-x11-final-gate.log`. +Affected-unit list: `/tmp/cleanup2-x11-affected-units.json`. +Per-commit full-build logs: `/tmp/cleanup2-x11-capacity-build.log`, `/tmp/cleanup2-x11-transfer-build.log`, `/tmp/cleanup2-x11-icons-build.log`, `/tmp/cleanup2-x11-scroller-build.log`. +Baseline report and object hashes: `/tmp/cleanup2-x11-baseline-report.json`, `/tmp/cleanup2-x11-baseline-objects.json`. + +origin/main advanced during the run; the leaf keeps its assigned baseline. No push, PR, merge, rebase, subagents, or edits to other worktrees. All attempted renames were retained; none changed object bytes.