Compare commits

...

6 Commits

76 changed files with 3857 additions and 2054 deletions

View File

@@ -44,6 +44,18 @@ block_relocations:
- source: .data:0x8165E19C
add_relocations:
- source: .text:0x8152C08C
type: ha
target: __ArenaLo
- source: .text:0x8152C090
type: l
target: __ArenaLo
- source: .text:0x8152C134
type: ha
target: __ArenaLo
- source: .text:0x8152C138
type: l
target: __ArenaLo
- source: .data:0x8165E15C
type: abs
target: csAninationFile__Q29textinput7toolbar

View File

@@ -455,7 +455,7 @@ def IPLSection(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
def ZI8Lib(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
return {
"lib": lib_name,
"mw_version": config.linker_version,
"mw_version": "GC/3.0a5",
"cflags": cflags_zi8,
"progress_category": "rvlmwm",
"objects": objects,
@@ -991,11 +991,11 @@ config.libs = [
Object(Matching, "clib/zi8copy.c"),
Object(Matching, "clib/zi8dawg.c"),
Object(Matching, "clib/zi8getc.c"),
Object(NonMatching, "clib/zi8getc2.c"),
Object(Matching, "clib/zi8getc2.c"),
Object(Matching, "clib/zi8getSW.c"),
Object(Matching, "clib/zi8initd.c"),
Object(Matching, "clib/zi8is.c"),
Object(NonMatching, "clib/zi8match.c"),
Object(Matching, "clib/zi8match.c"),
Object(Matching, "clib/zi8misc.c"),
Object(Matching, "clib/zi8pud2.c"),
Object(Matching, "clib/Zi8punct.c"),
@@ -1003,13 +1003,13 @@ config.libs = [
Object(NonMatching, "clib/zi8uwd.c"),
Object(Matching, "clib/zi8ver.c"),
Object(Matching, "clib/zi8ZHuwd.c"),
Object(NonMatching, "clib/zidawg1.c"),
Object(Matching, "clib/zidawg1.c"),
Object(Matching, "clib/zikorean.c"),
Object(Matching, "clib/ziswordw.c"),
Object(NonMatching, "clib/zkokeyp.c"),
Object(Matching, "clib/zierror.c"),
Object(NonMatching, "clib/zmtkey.c"),
Object(NonMatching, "clib/zoemdata.c"),
Object(Matching, "clib/zmtkey.c"),
Object(Matching, "clib/zoemdata.c"),
Object(NonMatching, "clib/zprepare.c"),
]
),

View File

@@ -1,7 +1,7 @@
# Assembly inventory
Audit of `ad5100a5`, 4.3U, 2026-10-05. 175 functions contain 178 assembly
bodies/blocks: 162 ORIGINAL functions and 13 PLACEHOLDER functions.
4.3U, 2026-10-05. 173 functions contain 175 assembly
bodies/blocks: 162 ORIGINAL functions and 11 PLACEHOLDER functions.
Run `python3 tools/check_asm_inventory.py`. Completion requires exit 0, complete
coverage and zero placeholders. The checker also rejects stale/duplicate rows,
@@ -37,7 +37,6 @@ found. Historical logs absent from this branch have commit IDs and excerpts in
| `libs/NW4R/include/nw4r/math/types.h` | `VEC3Scale` | ORIGINAL | psq_l/ps_muls0/psq_st implements paired-single vector/matrix operations. |
| `libs/NW4R/src/math/math_arithmetic.cpp` | `FrSqrt` | ORIGINAL | frsqrte plus fixed refinement matches the public [NW4R arithmetic assembly][arithmetic-cpp]. |
| `libs/NW4R/src/math/math_types.cpp` | `MTX44Identity` | ORIGINAL | psq_st/ps_merge01/ps_merge10 implements paired-single vector/matrix operations. |
| `libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main.c` | `TMCJPEGDEC_parse_sof` | PLACEHOLDER | JPEG frame parsing; diagnostic C 98.05381%, 223/223 instructions, 34 differences, temporary incomplete extern, [rx19](../tools/decomp-assist/rx19.attempts.md). |
| `libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main.c` | `TMCJPEGDEC_err_restart` | PLACEHOLDER | JPEG marker scan; best C 95.73913%, 114/115 instructions, folded exit branch, [rx19](../tools/decomp-assist/rx19.attempts.md), [rx24][rx24]. |
| `libs/RVL_SDK/include/revolution/os/OSFastCast.h` | `OSInitFastCast` | ORIGINAL | mtspr programs the GQR quantization registers. |
| `libs/RVL_SDK/include/revolution/os/OSFastCast.h` | `__OSu16tof32` | ORIGINAL | psq_l uses a GQR integer conversion format for the fast cast. |
@@ -113,7 +112,6 @@ found. Historical logs absent from this branch have commit IDs and excerpts in
| `libs/RVL_SDK/src/mtx/vec.c` | `PSVECNormalize` | ORIGINAL | psq_l/ps_mul/ps_madd/ps_sum0 implements paired-single vector/matrix operations. |
| `libs/RVL_SDK/src/mtx/vec.c` | `PSVECCrossProduct` | ORIGINAL | psq_l/ps_merge10/ps_mul/ps_muls0 implements paired-single vector/matrix operations. |
| `libs/RVL_SDK/src/os/OS.c` | `__OSFPRInit` | ORIGINAL | mfmsr/mtmsr enable the FPU; psq_l initializes paired registers and mtfsf initializes FPSCR. |
| `libs/RVL_SDK/src/os/OS.c` | `OSInit` | PLACEHOLDER | Two lis/addi blocks pin __ArenaLo to 0x816a9800; C score unrecorded, [rx36 audit][rx36-osinit]. |
| `libs/RVL_SDK/src/os/OS.c` | `__OSDBIntegrator` | ORIGINAL | nofralloc debug-vector fragment changes MSR and transfers through the saved hook LR. |
| `libs/RVL_SDK/src/os/OS.c` | `__OSDBJump` | ORIGINAL | Single absolute bla __OSDBJumpTarget between entry labels copied into exception vectors. |
| `libs/RVL_SDK/src/os/OS.c` | `OSExceptionVector` | ORIGINAL | Saves interrupted state, sets SRR0/SRR1 and executes rfi into the exception handler. |

View File

@@ -52,10 +52,10 @@ namespace ipl {
class Button {
public:
Button(nw4r::lyt::Pane* pane) : unk_0x04(0), mPane(pane) {}
Button(nw4r::lyt::Pane* pane) : mHoverCount(0), mPane(pane) {}
virtual ~Button();
u32 unk_0x04; // 0x04
u32 mHoverCount; // 0x04
nw4r::lyt::Pane* mPane; // 0x08
nw4r::ut::Link mLink; // 0x0C
};
@@ -63,8 +63,8 @@ namespace ipl {
class AnmButton {
public:
AnmButton(const char* name, Anm* anm1, Anm* anm2, Anm* anm3)
: unk_0x04(0), mName(name), mCurrentAnm(NULL), mAnm1(anm1), mAnm2(anm2), mAnm3(anm3),
unk_0x24(0), mLastCmd(0), mpBalloon(NULL) {}
: mHoverCount(0), mName(name), mCurrentAnm(NULL), mAnm1(anm1), mAnm2(anm2), mAnm3(anm3),
mAnimationState(0), mLastCmd(0), mpBalloon(NULL) {}
virtual ~AnmButton();
void calc();
@@ -72,14 +72,14 @@ namespace ipl {
void setBalloon(TextBalloon* balloon);
int unk_0x04; // 0x04
int mHoverCount; // 0x04
const char* mName; // 0x08
Anm* mCurrentAnm; // 0x0C
Anm* mAnm1; // 0x10
Anm* mAnm2; // 0x14
Anm* mAnm3; // 0x18
nw4r::ut::Link mLink; // 0x1C
u32 unk_0x24; // 0x24
u32 mAnimationState; // 0x24
int mLastCmd; // 0x28
TextBalloon* mpBalloon; // 0x2C
};
@@ -92,7 +92,7 @@ namespace ipl {
#ifdef IPL_MEMORYCARD_BASE_CTOR_OUT_OF_LINE
MemoryBase();
#else
MemoryBase() : mpLayout(NULL), unk_0x08(NULL) {
MemoryBase() : mpLayout(NULL), mpLayoutFile(NULL) {
nw4r::ut::List_Init(&mAnmList, offsetof(Anm, mLink));
nw4r::ut::List_Init(&mButtonList, offsetof(Button, mLink));
nw4r::ut::List_Init(&mAnmButtonList, offsetof(AnmButton, mLink));
@@ -136,7 +136,7 @@ namespace ipl {
protected:
layout::Object* mpLayout; // 0x04
nand::LayoutFile* unk_0x08; // 0x08
nand::LayoutFile* mpLayoutFile; // 0x08
gui::PaneManager* mpPaneManager; // 0x0C
nw4r::ut::List mAnmList; // 0x10
nw4r::ut::List mButtonList; // 0x1C

View File

@@ -72,7 +72,7 @@ namespace ipl {
typedef struct MCFile {
u32 fileNo; // 0x00
u32 reserved; // 0x04
u32 unk_0x08; // 0x08
u32 sortKeyHigh; // 0x08
s32 sortKey; // 0x0C
} MCFile; // 0x10
@@ -99,8 +99,8 @@ namespace ipl {
mLastCmd = 0;
__CARDSetDiskID(NULL);
memorycard::initCardThread();
sort_file_array(0);
sort_file_array(1);
sort_file_array(CARD_CHAN_0);
sort_file_array(CARD_CHAN_1);
}
virtual ~MemoryCardManager();
@@ -188,13 +188,13 @@ namespace ipl {
private:
GXTexObj* initBannerTexture(u8 slot, s32 file, void* data) {
GXInitTexObj(&mFileCell[slot][file].banner, data, 0x60, 0x20,
GXInitTexObj(&mFileCell[slot][file].banner, data, CARD_BANNER_WIDTH, CARD_BANNER_HEIGHT,
GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
return &mFileCell[slot][file].banner;
}
void initBannerTextureCI(u8 slot, s32 file, void* data) {
GXInitTexObjCI(&mFileCell[slot][file].banner, data, 0x60, 0x20,
GXInitTexObjCI(&mFileCell[slot][file].banner, data, CARD_BANNER_WIDTH, CARD_BANNER_HEIGHT,
GX_TF_C8, GX_CLAMP, GX_CLAMP, GX_FALSE, GX_TLUT0);
}
@@ -204,8 +204,8 @@ namespace ipl {
}
u32 reserved; // 0x00004
MCFile mFile[2][0x7F]; // 0x00008
MCFileCell mFileCell[2][0x7F]; // 0x00FE8
MCFile mFile[2][CARD_MAX_FILE]; // 0x00008
MCFileCell mFileCell[2][CARD_MAX_FILE]; // 0x00FE8
s32 mLastResult; // 0x16930
s32 mLastCmd; // 0x16934
u32 mReservedResult; // 0x16938

View File

@@ -13,7 +13,7 @@ extern "C" char scLytFatalMsg[] = "Error#004\nAn error has occurred.\nThe system
GXColor front = {*((volatile const u8*)&::scLytFatalColorR), *((volatile const u8*)&::scLytFatalColorG), \
*((volatile const u8*)&::scLytFatalColorB), *((volatile const u8*)&::scLytFatalColorA)}; \
GXColor back = {0, 0, 0, 0}; \
OSFatal((GXColor)front, (GXColor)back, ::scLytFatalMsg); \
OSFatal(front, back, ::scLytFatalMsg); \
} \
}
@@ -22,7 +22,7 @@ extern "C" char scLytFatalMsg[] = "Error#004\nAn error has occurred.\nThe system
if (!(x)) { \
GXColor front = {255, 255, 255, 0}; \
GXColor back = {0, 0, 0, 0}; \
OSFatal((GXColor)front, (GXColor)back, ::scLytFatalMsg); \
OSFatal(front, back, ::scLytFatalMsg); \
} \
}

View File

@@ -49,17 +49,17 @@ typedef struct {
u8 flashVer[4]; // 0x640
s8 flashPixVer[4]; // 0x644
u16 colorSpace; // 0x648
u8 unk_0x64A[0x02];
u8 colorSpacePadding[0x02];
u32 pixelXDim; // 0x64C
u32 pixelYDim; // 0x650
u16 compressionIfd1; // 0x654
u8 unk_0x656[0x02];
u8 compressionPadding[0x02];
u32 xResNumIfd1; // 0x658
u32 xResDenIfd1; // 0x65C
u32 planarConfigIfd1; // 0x660
u32 yResDenIfd1; // 0x664
u16 resUnitIfd1; // 0x668
u8 unk_0x66A[0x02];
u8 resolutionPadding[0x02];
u32 thumbnailOffset; // 0x66C
u32 thumbnailLength; // 0x670
u8* thumbnailData; // 0x674
@@ -67,19 +67,40 @@ typedef struct {
} TMCCJPEGDecExifData;
typedef struct {
u8 unk_0x00[0x04];
u16 posX;
u16 posY;
s32 position; // 0x04
u8 unk_0x08[0x04];
u32 state; // 0x0C
u8 unk_0x10[0x10];
u16 maxX;
u16 maxY;
u8 stepX;
u8 stepY;
u8 stepXExt;
u8 stepYExt;
u32 dataSizeX;
u32 dataSizeY;
u8 exifFlags; // 0x20
u8 thumbFlag; // 0x21
u8 unk_0x22[0x2A];
u8 componentCount;
u8 dimensionPadding;
u16 jpegWidth;
u16 jpegHeight;
u16 outputWidth;
u16 outputHeight;
u32 convWidth;
u32 convHeight;
u32 chromaWidth;
u32 chromaHeight;
u8* pLumaBuffer;
u8* pCbBuffer;
u8* pCrBuffer;
void* pTexBuffer;
TMCCJPEGDecExifData exifData; // 0x4C
TMCCJPEGDecWork* pWorkBuf; // 0x6C8
u8 unk_0x6CC[0x04];
s32 decodeResult;
u8 converterType; // 0x6D0
u8 unk_0x6D1[0x03];
u8 alignmentPadding[0x03];
} TMCCJPEGDecExifInfo;
typedef struct {

View File

@@ -39,43 +39,32 @@ typedef void(TMCConverterFunc)(TMCCJPEGDecWork*, s32 x, s32 y);
extern "C" {
#endif
// TODO: The following two structs are subsets of TMCCJPEGDecWork.
// Their members in TMCCJPEGDecWork should eventually be removed and replaced with these structs as a member.
// Some code accesses scaleFlag, frameWidth and convBuf as a pointer and uses them as a base to do further pointer arithmetic on,
// so they likely were nested structs.
typedef struct {
u8 scaleFlag; // 0x00
u8 unk_0x01[0x3E7];
u8* pDCACPtrs[6]; // 0x03E8-0x03FF
u8 zigzagData[64]; // 0x0400-0x043F
u16* pDCFast; // 0x0440
u32* pDCHuffTbl; // 0x0444
u8* pDCHuffSym; // 0x0448
u32 unk_0x4A4; // 0x044C
u16* pACFast; // 0x0450
u32* pACHuffTbl; // 0x0454
u8* pACHuffSym; // 0x0458
u32 unk_0x4C5;
u8 unk_0x460[0x1B4];
u32 thumbHuffSize[3]; // 0x0614
u8 unk_0x620[0x1E8];
u8 huffDecTblDC1[0x400]; // 0x0808-0x0C07
u8 huffDecTblAC0[0x400]; // 0x0C08-0x1007
u8 huffDecTblAC1[0x400]; // 0x1008-0x1407
u8 valPtrDC0[0x44]; // 0x1408-0x144B
u8 valPtrDC1[0x44]; // 0x144C-0x148F
u8 valPtrAC0[0x44]; // 0x1490-0x14D3
u8 valPtrAC1[0x44]; // 0x14D4-0x1517
u8 maxCodeDC0[0x10]; // 0x1518-0x1527
u8 maxCodeDC1[0x10]; // 0x1528-0x1537
u8 maxCodeAC0[0x100]; // 0x1538-0x1637
u8 maxCodeAC1[0x100]; // 0x1638-0x1737
u8 unk_0x1738[0x04];
u8 huffTblInitFlag[4]; // 0x173C
u8 unk_0x1740[0x50];
u8 quantTblFlag[4]; // 0x1790
u8 dcTblFlag[2]; // 0x1794
u8 acTblFlag[2]; // 0x1796
u32 coefficients[4][64];
u8 zigzagData[64];
u16* pDCFast;
u32* pDCHuffTbl;
u8* pDCHuffSym;
u32 reservedDC;
u16* pACFast;
u32* pACHuffTbl;
u8* pACHuffSym;
u32 reservedAC;
u16 huffDecTblDC0[0x200];
u16 huffDecTblDC1[0x200];
u16 huffDecTblAC0[0x200];
u16 huffDecTblAC1[0x200];
u32 valPtrDC0[17];
u32 valPtrDC1[17];
u32 valPtrAC0[17];
u32 valPtrAC1[17];
u8 maxCodeDC0[0x10];
u8 maxCodeDC1[0x10];
u8 maxCodeAC0[0x100];
u8 maxCodeAC1[0x100];
u8 quantTblFlag[4];
u8 dcTblFlag[2];
u8 acTblFlag[2];
} TMCJpegTableInfo;
typedef struct {
@@ -101,9 +90,18 @@ typedef struct {
u8 maxVSamp; // 0x29
u16 restartInterval; // 0x2A
u8 scanCount; // 0x2C
u8 unk_0x2D[0x03];
u8 alignmentPadding[0x03];
} TMCJpegFrameInfo;
typedef struct {
u8 map[4];
u32 dcPredict[4];
u8 id[4];
u8 quantTable[4];
u8 dcTable[4];
u8 acTable[4];
} TMCFrameComponents;
struct TMCCJPEGDecWork_t {
u32 bitBuf; // 0x00
s32 bitCount; // 0x04
@@ -116,47 +114,11 @@ struct TMCCJPEGDecWork_t {
s32 remaining; // 0x20
TMCCReadCallback* pCallback; // 0x24
void* pCbCtx; // 0x28
u8 compMap[4]; // 0x2C
u32 dcPredict[4]; // 0x30
u8 compId[4]; // 0x40
u8 compQTbl[4]; // 0x44
u8 copDCTbl[4]; // 0x48
u8 copACTbl[4]; // 0x4C
TMCFrameComponents components;
u16 restartCnt; // 0x50
u16 rstMarkerIdx; // 0x52
u32 mcuPos; // 0x54
// Section below is likely a nested struct
u8 scaleFlag; // 0x58
u8 unk_0x59[0x3E7];
u8* pDCACPtrs[6]; // 0x440
u8 zigzagData[64]; // 0x458
u16* pDCFast; // 0x498
u32* pDCHuffTbl; // 0x49C
u8* pDCHuffSym; // 0x4A0
u32 unk_0x4A4;
u16* pACFast; // 0x4A8
u32* pACHuffTbl; // 0x4AC
u8* pACHuffSym; // 0x4B0
u8 unk_0x4B4[0x1B8];
u32 thumbHuffSize[3]; // 0x66C
u8 unk_0x678[0x1E8];
u8 huffDecTblDC1[0x400]; // 0x860-0xC5F
u8 huffDecTblAC0[0x400]; // 0xC60-0x105F
u8 huffDecTblAC1[0x400]; // 0x1060-0x145F
u8 valPtrDC0[0x44]; // 0x1460-0x14A3
u8 valPtrDC1[0x44]; // 0x14A4-0x14E7
u8 valPtrAC0[0x44]; // 0x14E8-0x152B
u8 valPtrAC1[0x44]; // 0x152C-0x156F
u8 maxCodeDC0[0x10]; // 0x1570-0x157F
u8 maxCodeDC1[0x10]; // 0x1580-0x158F
u8 maxCodeAC0[0x100]; // 0x1590-0x168F
u8 maxCodeAC1[0x100]; // 0x1690-0x178F
u8 unk_0x1790[0x04];
u8 huffTblInitFlag[4]; // 0x1794
u8 unk_0x1798[0x50];
u8 quantTblFlag[4]; // 0x17E8
u8 dcTblFlag[2]; // 0x17EC
u8 acTblFlag[2]; // 0x17EE
TMCJpegTableInfo tables;
// Section below is likely a nested struct
u16 frameWidth; // 0x17F0
u16 frameHeight; // 0x17F2
@@ -180,7 +142,7 @@ struct TMCCJPEGDecWork_t {
u8 maxVSamp; // 0x1819
u16 restartInterval; // 0x181A
u8 scanCount; // 0x181C
u8 unk_0x181D[0x03];
u8 framePadding[0x03];
TMCIdctFunc* idctPtr; // 0x1820
TMCIdctFunc* idctLumiPtr; // 0x1824
TMCDecodeFunc* decodePtr; // 0x1828
@@ -191,10 +153,10 @@ struct TMCCJPEGDecWork_t {
u8* pConvRowPtrs[7]; // 0x183C
u8 convBuf[0x184]; // 0x1858
u8 idctMode; // 0x19DC
u8 unk_0x19DD;
u8 pitchPadding;
u16 pitch; // 0x19DE
u8 converterFlags; // 0x19E0
u8 unk_0x19E1[0x03];
u8 statePadding[0x03];
TMCCJPEGDecState* pState; // 0x19E4
};
@@ -213,7 +175,7 @@ s32 TMCJPEGDEC_rewind_ptr(TMCCJPEGDecWork* work);
typedef struct {
u32* huffTable; // 0x00
u8* valptr; // 0x04
u32* valptr; // 0x04
u32* maxCode; // 0x08
u8 count; // 0x0C
} TMCHuffParam;
@@ -228,7 +190,7 @@ s32 TMCJPEGDEC_scanstart(TMCCJPEGDecWork* work);
s32 TMCJPEGDEC_scan_varinit(TMCCJPEGDecWork* work);
s32 TMCJPEGDEC_restart_interval(TMCCJPEGDecWork* work, u32 maxMCU, u32 mcuCount);
s32 TMCJPEGDEC_err_restart(TMCCJPEGDecWork* work);
void TMCJPEGDEC_set_entropytbl(TMCCJPEGDecWork* work, s32 idx, u8 data);
void TMCJPEGDEC_set_entropytbl(TMCJpegTableInfo* work, s32 idx, u8 data);
s32 TMCJPEGDEC_Decompscan(TMCCJPEGDecWork* work);
s32 TMCJPEGDEC_Setsize(TMCCJPEGDecWork* work);
@@ -252,11 +214,15 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work);
s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work);
s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work);
extern const u8 TMCJPEGDEC_SampleH_N[24];
extern const u8 TMCJPEGDEC_SampleV_N[24];
extern const u8 TMCJPEGDEC_SampleH_N[6][4];
extern const u8 TMCJPEGDEC_SampleV_N[6][4];
extern const u8 TMCJPEGDEC_Zigzag_data[64];
extern const u32 TMCJPEGDEC_Zigzag_loop[64];
#ifdef TMC_JPEG_FRAME_PARSER
extern const u8 TMCJPEGDEC_SampleComps[];
#else
extern const u8 TMCJPEGDEC_SampleComps[6];
#endif
#ifdef __cplusplus
}

View File

@@ -140,7 +140,7 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
conv_row = (s32*)conv_row_ptr;
bit_pos = work->bitCount;
dc_fast = work->pDCFast;
dc_fast = work->tables.pDCFast;
if (bit_pos <= 8) {
r = TMCJPEGDEC_load_buff(work);
@@ -161,8 +161,8 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
work->bitCount = bit_pos - r;
r = extra;
} else {
huff_sym = work->pDCHuffSym;
huff_tbl = work->pDCHuffTbl;
huff_sym = work->tables.pDCHuffSym;
huff_tbl = work->tables.pDCHuffTbl;
r = decodeLongHuffman(bit_pos, huff_tbl, huff_sym, work, &dcLimit, &dcDecoded);
if (r < 0) {
return r;
@@ -196,9 +196,9 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
u32* ac_huff_tbl;
u8* ac_huff_sym;
ac_fast = work->pACFast;
ac_huff_tbl = work->pACHuffTbl;
ac_huff_sym = work->pACHuffSym;
ac_fast = work->tables.pACFast;
ac_huff_tbl = work->tables.pACHuffTbl;
ac_huff_sym = work->tables.pACHuffSym;
memset(block + 1, 0, 0xFC);
@@ -279,8 +279,8 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
bit_data = work->bitBuf;
bit_pos = work->bitCount;
t = bit_pos - 8;
tmp = ((bit_data >> t) & 0xFF) << 2;
acEntry = readHuffmanEntry((const TMCHuffmanEntry*)ac_fast, tmp >> 2);
tmp = (bit_data >> t) & 0xFF;
acEntry = readHuffmanEntry((const TMCHuffmanEntry*)ac_fast, tmp);
idx += 16;
}

View File

@@ -12,9 +12,9 @@ s32 TMCJPEGDEC_init_ptr_buff(TMCCJPEGDecWork* work, void* param) {
u32 newRemaining;
const TMCCJPEGDecInitParam* input = (const TMCCJPEGDecInitParam*)((u8*)param - offsetof(TMCCJPEGDecInitParam, pBuf2));
if ((u32)input->pBuf2 & 0x1F)
if ((u32)input->pBuf2 & (DEFAULT_ALIGN - 1))
return -1;
if (input->buf2Size & 0x1F)
if (input->buf2Size & (DEFAULT_ALIGN - 1))
return -1;
if (input->dataSize == 0)
return -1;

View File

@@ -27,7 +27,7 @@ s32 TMCJPEGDEC_init_buff_thumbnail(TMCCJPEGDecWork* work, u8* dst, u8* src) {
endAddress = (u32)buffer->pBufCur + endAddress;
buffer->remaining = 0;
buffer->pBufEnd = (u8*)endAddress;
buffer->pBufMark = (u8*)((u32)endAddress - 0x22);
buffer->pBufMark = (u8*)endAddress - 0x22;
return 0;
}

View File

@@ -1,21 +1,27 @@
#include <string.h>
#include <tmc_jpeg_internal.h>
static s32 clampU8(s32 v) {
s32 ok;
ok = 0;
if (v < 256 && v > -1) {
ok = 1;
}
return ok ? v : (v < 0 ? 0 : 255);
}
static s32 clampS8(s32 v) {
s32 inRange = 0;
if (v < 128 && v > -129) {
static s32 clampU8(s32 value) {
s32 inRange;
inRange = 0;
if (value < 256 && value > -1) {
inRange = 1;
}
return inRange ? v : (v > 0) ? 127 : -128;
if (inRange) {
return value;
}
if (value < 0) {
return 0;
}
return 255;
}
static s32 clampS8(s32 value) {
s32 inRange = 0;
if (value < 128 && value > -129) {
inRange = 1;
}
return inRange ? value : (value > 0) ? 127 : -128;
}
static s32 scalingClampU8(s32 value) {
@@ -26,70 +32,70 @@ static s32 scalingClampU8(s32 value) {
}
void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {
s32 tmp[64];
s32* dst;
s32 d;
s32 t;
s32 i;
s32 y;
s32 b2;
s32 b1;
s32 b4;
s32 b5;
s32 b6;
s32 b7;
s32 n;
s32 workspace[64];
s32* workspaceCursor;
s32 evenBaseSum;
s32 evenRotation;
s32 column;
s32 evenOutput3;
s32 coefficient2;
s32 coefficient1;
s32 coefficient4;
s32 coefficient5;
s32 coefficient6;
s32 coefficient7;
s32 oddOutput0;
s32 m;
s32 a;
s32 done;
s32 evenBaseDifference;
s32 processedCoefficients;
s32 z;
s32 v;
s32 p;
s32 p_part;
s32 m_part;
s32 u;
s32 evenOutput1;
s32 oddOutput3;
s32 oddLowRotation;
s32 oddHighRotation;
s32 evenRotationSum;
s32 r;
s32 o;
s32 x;
s32 x_factor;
s32 z_factor;
s32 iter;
s32 q;
s32 w;
s32 e;
s32 b3;
s32 oddOutput1;
s32 oddSumRotation;
s32 oddSumDifference;
s32 oddDifferenceSum;
s32 columnsRemaining;
s32 oddOutput2;
s32 evenOutput0;
s32 evenOutput2;
s32 coefficient3;
r = (zigzag >> 4) * 8;
dst = tmp;
done = 0;
workspaceCursor = workspace;
processedCoefficients = 0;
{
for (; done < r; done += 8) {
u32 ac;
b4 = block[4];
b6 = block[6];
b2 = block[2];
b1 = block[1];
b7 = block[7];
b5 = block[5];
b3 = block[3];
for (; processedCoefficients < r; processedCoefficients += 8) {
u32 acBits;
coefficient4 = block[4];
coefficient6 = block[6];
coefficient2 = block[2];
coefficient1 = block[1];
coefficient7 = block[7];
coefficient5 = block[5];
coefficient3 = block[3];
ac = (u32)b4;
ac |= (u32)b6;
ac |= (u32)b2;
ac |= (u32)b1;
ac |= (u32)b7;
ac |= (u32)b5;
ac |= (u32)b3;
if (ac == 0) {
s32 val = block[0];
dst[7] = val;
dst[6] = val;
dst[5] = val;
dst[4] = val;
dst[3] = val;
dst[2] = val;
dst[1] = val;
dst[0] = val;
acBits = (u32)coefficient4;
acBits |= (u32)coefficient6;
acBits |= (u32)coefficient2;
acBits |= (u32)coefficient1;
acBits |= (u32)coefficient7;
acBits |= (u32)coefficient5;
acBits |= (u32)coefficient3;
if (acBits == 0) {
s32 sample = block[0];
workspaceCursor[7] = sample;
workspaceCursor[6] = sample;
workspaceCursor[5] = sample;
workspaceCursor[4] = sample;
workspaceCursor[3] = sample;
workspaceCursor[2] = sample;
workspaceCursor[1] = sample;
workspaceCursor[0] = sample;
} else {
s32 oddLowSum;
s32 oddHighSum;
@@ -97,242 +103,242 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
s32 oddHighDifference;
s32 dcValue;
t = b2 - b6;
oddLowSum = b5 + b3;
oddLowDifference = b5 - b3;
oddHighSum = b1 + b7;
oddHighDifference = b1 - b7;
u = b6 + b2;
t = t * 0xB5 >> 8;
x_factor = oddHighSum - oddLowSum;
z_factor = oddLowDifference + oddHighDifference;
evenRotation = coefficient2 - coefficient6;
oddLowSum = coefficient5 + coefficient3;
oddLowDifference = coefficient5 - coefficient3;
oddHighSum = coefficient1 + coefficient7;
oddHighDifference = coefficient1 - coefficient7;
evenRotationSum = coefficient6 + coefficient2;
evenRotation = evenRotation * 0xB5 >> 8;
oddSumDifference = oddHighSum - oddLowSum;
oddDifferenceSum = oddLowDifference + oddHighDifference;
dcValue = block[0];
a = dcValue - b4;
x = x_factor * 0xB5 >> 8;
d = dcValue + b4;
u = t + u;
v = a + t;
z = z_factor * 0x62 >> 8;
w = d + u;
y = d - u;
m_part = oddHighDifference * 0x14E >> 8;
e = a - t;
m = m_part - z;
evenBaseDifference = dcValue - coefficient4;
oddSumRotation = oddSumDifference * 0xB5 >> 8;
evenBaseSum = dcValue + coefficient4;
evenRotationSum = evenRotation + evenRotationSum;
evenOutput1 = evenBaseDifference + evenRotation;
z = oddDifferenceSum * 0x62 >> 8;
evenOutput0 = evenBaseSum + evenRotationSum;
evenOutput3 = evenBaseSum - evenRotationSum;
oddHighRotation = oddHighDifference * 0x14E >> 8;
evenOutput2 = evenBaseDifference - evenRotation;
m = oddHighRotation - z;
oddLowSum += m;
n = oddHighSum + oddLowSum;
o = x + m;
dst[0] = w + n;
p_part = oddLowDifference * 0x8B;
dst[7] = w - n;
p_part >>= 8;
dst[1] = v + o;
p = z + p_part;
q = p + x;
dst[6] = v - o;
dst[2] = e + q;
dst[5] = e - q;
dst[3] = y + p;
dst[4] = y - p;
oddOutput0 = oddHighSum + oddLowSum;
oddOutput1 = oddSumRotation + m;
workspaceCursor[0] = evenOutput0 + oddOutput0;
oddLowRotation = oddLowDifference * 0x8B;
workspaceCursor[7] = evenOutput0 - oddOutput0;
oddLowRotation >>= 8;
workspaceCursor[1] = evenOutput1 + oddOutput1;
oddOutput3 = z + oddLowRotation;
oddOutput2 = oddOutput3 + oddSumRotation;
workspaceCursor[6] = evenOutput1 - oddOutput1;
workspaceCursor[2] = evenOutput2 + oddOutput2;
workspaceCursor[5] = evenOutput2 - oddOutput2;
workspaceCursor[3] = evenOutput3 + oddOutput3;
workspaceCursor[4] = evenOutput3 - oddOutput3;
}
block += 8;
dst += 8;
workspaceCursor += 8;
}
}
dst = tmp + done;
for (; done <= 0x38; done += 8) {
memset(dst, 0, 0x20);
dst += 8;
workspaceCursor = workspace + processedCoefficients;
for (; processedCoefficients <= 0x38; processedCoefficients += 8) {
memset(workspaceCursor, 0, 0x20);
workspaceCursor += 8;
}
r = pitch * 8 - pitch;
z = pitch * 4;
m = pitch * 2;
dst = tmp + 7;
for (iter = 8, i = 7; iter > 0; iter--, i--) {
u32 ac;
u8* out;
workspaceCursor = workspace + 7;
for (columnsRemaining = 8, column = 7; columnsRemaining > 0; columnsRemaining--, column--) {
u32 acBits;
u8* output;
b4 = dst[0x20];
b6 = dst[0x30];
b2 = dst[0x10];
b1 = dst[8];
b7 = dst[0x38];
b5 = dst[0x28];
b3 = dst[0x18];
coefficient4 = workspaceCursor[0x20];
coefficient6 = workspaceCursor[0x30];
coefficient2 = workspaceCursor[0x10];
coefficient1 = workspaceCursor[8];
coefficient7 = workspaceCursor[0x38];
coefficient5 = workspaceCursor[0x28];
coefficient3 = workspaceCursor[0x18];
ac = (u32)b4;
ac |= (u32)b6;
ac |= (u32)b2;
ac |= (u32)b1;
ac |= (u32)b7;
ac |= (u32)b5;
ac |= (u32)b3;
out = conv_row_ptr + i;
if (ac == 0) {
u8 val = clampU8((*dst >> 11) + 0x80);
out[r] = val;
out[pitch * 6] = val;
out[z + pitch] = val;
out[z] = val;
out[z - pitch] = val;
out[m] = val;
out[pitch] = val;
out[0] = val;
acBits = (u32)coefficient4;
acBits |= (u32)coefficient6;
acBits |= (u32)coefficient2;
acBits |= (u32)coefficient1;
acBits |= (u32)coefficient7;
acBits |= (u32)coefficient5;
acBits |= (u32)coefficient3;
output = conv_row_ptr + column;
if (acBits == 0) {
u8 sample = clampU8((*workspaceCursor >> 11) + 0x80);
output[r] = sample;
output[pitch * 6] = sample;
output[z + pitch] = sample;
output[z] = sample;
output[z - pitch] = sample;
output[m] = sample;
output[pitch] = sample;
output[0] = sample;
} else {
s32 oddLowSum;
s32 oddHighSum;
s32 dcValue;
t = b2 - b6;
oddLowSum = b5 + b3;
b5 = b5 - b3;
oddHighSum = b1 + b7;
b1 = b1 - b7;
u = b6 + b2;
b2 = t * 0xB5 >> 8;
x_factor = oddHighSum - oddLowSum;
z_factor = b5 + b1;
dcValue = *dst + 0x40000;
a = dcValue - b4;
x = x_factor * 0xB5 >> 8;
d = dcValue + b4;
u = b2 + u;
v = a + b2;
z_factor = z_factor * 0x62 >> 8;
w = d + u;
y = d - u;
m_part = b1 * 0x14E >> 8;
e = a - b2;
m_part = m_part - z_factor;
oddLowSum += m_part;
n = oddHighSum + oddLowSum;
o = x + m_part;
p_part = b5 * 0x8B >> 8;
p = z_factor + p_part;
q = p + x;
out[0] = scalingClampU8(w + n);
out[r] = scalingClampU8(w - n);
out[pitch] = scalingClampU8(v + o);
out[pitch * 6] = scalingClampU8(v - o);
out[m] = scalingClampU8(e + q);
out[z + pitch] = scalingClampU8(e - q);
out[z - pitch] = scalingClampU8(y + p);
out[z] = scalingClampU8(y - p);
evenRotation = coefficient2 - coefficient6;
oddLowSum = coefficient5 + coefficient3;
coefficient5 = coefficient5 - coefficient3;
oddHighSum = coefficient1 + coefficient7;
coefficient1 = coefficient1 - coefficient7;
evenRotationSum = coefficient6 + coefficient2;
coefficient2 = evenRotation * 0xB5 >> 8;
oddSumDifference = oddHighSum - oddLowSum;
oddDifferenceSum = coefficient5 + coefficient1;
dcValue = *workspaceCursor + 0x40000;
evenBaseDifference = dcValue - coefficient4;
oddSumRotation = oddSumDifference * 0xB5 >> 8;
evenBaseSum = dcValue + coefficient4;
evenRotationSum = coefficient2 + evenRotationSum;
evenOutput1 = evenBaseDifference + coefficient2;
oddDifferenceSum = oddDifferenceSum * 0x62 >> 8;
evenOutput0 = evenBaseSum + evenRotationSum;
evenOutput3 = evenBaseSum - evenRotationSum;
oddHighRotation = coefficient1 * 0x14E >> 8;
evenOutput2 = evenBaseDifference - coefficient2;
oddHighRotation = oddHighRotation - oddDifferenceSum;
oddLowSum += oddHighRotation;
oddOutput0 = oddHighSum + oddLowSum;
oddOutput1 = oddSumRotation + oddHighRotation;
oddLowRotation = coefficient5 * 0x8B >> 8;
oddOutput3 = oddDifferenceSum + oddLowRotation;
oddOutput2 = oddOutput3 + oddSumRotation;
output[0] = scalingClampU8(evenOutput0 + oddOutput0);
output[r] = scalingClampU8(evenOutput0 - oddOutput0);
output[pitch] = scalingClampU8(evenOutput1 + oddOutput1);
output[pitch * 6] = scalingClampU8(evenOutput1 - oddOutput1);
output[m] = scalingClampU8(evenOutput2 + oddOutput2);
output[z + pitch] = scalingClampU8(evenOutput2 - oddOutput2);
output[z - pitch] = scalingClampU8(evenOutput3 + oddOutput3);
output[z] = scalingClampU8(evenOutput3 - oddOutput3);
}
dst--;
workspaceCursor--;
}
}
void TMCJPEGDEC_IdctBlock_Col(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {
s32 tmp[64];
s32* dst;
s32 a;
s32 iter;
s32 d;
s32 b1;
s32 b2;
s32 b3;
s32 b4;
s32 b5;
s32 b6;
s32 b7;
s32 workspace[64];
s32* workspaceCursor;
s32 evenBaseDifference;
s32 columnsRemaining;
s32 evenBaseSum;
s32 coefficient1;
s32 coefficient2;
s32 coefficient3;
s32 coefficient4;
s32 coefficient5;
s32 coefficient6;
s32 coefficient7;
s32 v;
s32 r;
s32 done;
s32 i;
s32 rowCoefficientCount;
s32 processedCoefficients;
s32 column;
s32 m;
s32 n;
s32 o;
s32 x;
s32 q;
s32 e;
s32 oddOutput1;
s32 oddSumRotation;
s32 oddOutput2;
s32 evenOutput2;
s32 u;
s32 w;
s32 p;
s32 t;
s32 evenOutput0;
s32 oddOutput3;
s32 rotation45;
s32 z;
s32 x_factor;
s32 z_factor;
s32 m_part;
s32 p_part;
s32 y;
s32 oddSumDifference;
s32 oddDifferenceSum;
s32 oddHighRotation;
s32 oddLowRotation;
s32 evenOutput3;
if (zigzag == 0x11) {
s32 val;
val = clampS8(block[0] >> 11);
memset(conv_row_ptr, (s8)val, 0x40);
s32 sample;
sample = clampS8(block[0] >> 11);
memset(conv_row_ptr, (s8)sample, 0x40);
return;
}
r = (zigzag >> 4) * 8;
rowCoefficientCount = (zigzag >> 4) * 8;
if ((zigzag & 0xF) > 2) {
goto mode_gt_2;
goto fullRowTransform;
}
dst = tmp;
done = 0;
for (; done < r; done += 8) {
workspaceCursor = workspace;
processedCoefficients = 0;
for (; processedCoefficients < rowCoefficientCount; processedCoefficients += 8) {
s32 dcValue;
s32 oddCoefficient;
oddCoefficient = block[1];
dcValue = block[0];
t = oddCoefficient * 0xB5 >> 8;
rotation45 = oddCoefficient * 0xB5 >> 8;
v = oddCoefficient * 0x62 >> 8;
u = v + t;
u = v + rotation45;
z = (oddCoefficient * 0x14E >> 8) - v;
m = oddCoefficient + z;
n = t + z;
dst[0] = dcValue + m;
dst[7] = dcValue - m;
dst[1] = dcValue + n;
dst[6] = dcValue - n;
dst[2] = dcValue + u;
dst[5] = dcValue - u;
dst[3] = dcValue + v;
dst[4] = dcValue - v;
dst += 8;
n = rotation45 + z;
workspaceCursor[0] = dcValue + m;
workspaceCursor[7] = dcValue - m;
workspaceCursor[1] = dcValue + n;
workspaceCursor[6] = dcValue - n;
workspaceCursor[2] = dcValue + u;
workspaceCursor[5] = dcValue - u;
workspaceCursor[3] = dcValue + v;
workspaceCursor[4] = dcValue - v;
workspaceCursor += 8;
block += 8;
}
dst = tmp + done;
for (; done <= 0x38; done += 8) {
memset(dst, 0, 0x20);
dst += 8;
workspaceCursor = workspace + processedCoefficients;
for (; processedCoefficients <= 0x38; processedCoefficients += 8) {
memset(workspaceCursor, 0, 0x20);
workspaceCursor += 8;
}
goto epilogue;
goto columnTransform;
mode_gt_2:
dst = tmp;
done = 0;
for (; done < r; done += 8) {
u32 ac;
b4 = block[4];
b6 = block[6];
b2 = block[2];
b1 = block[1];
b7 = block[7];
b5 = block[5];
b3 = block[3];
fullRowTransform:
workspaceCursor = workspace;
processedCoefficients = 0;
for (; processedCoefficients < rowCoefficientCount; processedCoefficients += 8) {
u32 acBits;
coefficient4 = block[4];
coefficient6 = block[6];
coefficient2 = block[2];
coefficient1 = block[1];
coefficient7 = block[7];
coefficient5 = block[5];
coefficient3 = block[3];
ac = (u32)b4;
ac |= (u32)b6;
ac |= (u32)b2;
ac |= (u32)b1;
ac |= (u32)b7;
ac |= (u32)b5;
ac |= (u32)b3;
if (ac == 0) {
s32 val;
val = block[0];
dst[7] = val;
dst[6] = val;
dst[5] = val;
dst[4] = val;
dst[3] = val;
dst[2] = val;
dst[1] = val;
dst[0] = val;
acBits = (u32)coefficient4;
acBits |= (u32)coefficient6;
acBits |= (u32)coefficient2;
acBits |= (u32)coefficient1;
acBits |= (u32)coefficient7;
acBits |= (u32)coefficient5;
acBits |= (u32)coefficient3;
if (acBits == 0) {
s32 sample;
sample = block[0];
workspaceCursor[7] = sample;
workspaceCursor[6] = sample;
workspaceCursor[5] = sample;
workspaceCursor[4] = sample;
workspaceCursor[3] = sample;
workspaceCursor[2] = sample;
workspaceCursor[1] = sample;
workspaceCursor[0] = sample;
} else {
s32 oddLowSum;
s32 oddLowDifference;
@@ -340,86 +346,86 @@ mode_gt_2:
s32 oddHighDifference;
s32 dcValue;
t = b2 - b6;
oddLowSum = b5 + b3;
oddLowDifference = b5 - b3;
oddHighSum = b1 + b7;
oddHighDifference = b1 - b7;
u = b6 + b2;
t = t * 0xB5 >> 8;
x_factor = oddHighSum - oddLowSum;
z_factor = oddLowDifference + oddHighDifference;
rotation45 = coefficient2 - coefficient6;
oddLowSum = coefficient5 + coefficient3;
oddLowDifference = coefficient5 - coefficient3;
oddHighSum = coefficient1 + coefficient7;
oddHighDifference = coefficient1 - coefficient7;
u = coefficient6 + coefficient2;
rotation45 = rotation45 * 0xB5 >> 8;
oddSumDifference = oddHighSum - oddLowSum;
oddDifferenceSum = oddLowDifference + oddHighDifference;
dcValue = block[0];
a = dcValue - b4;
x = x_factor * 0xB5 >> 8;
d = dcValue + b4;
u = t + u;
v = a + t;
z = z_factor * 0x62 >> 8;
w = d + u;
y = d - u;
m_part = oddHighDifference * 0x14E >> 8;
e = a - t;
m = m_part - z;
evenBaseDifference = dcValue - coefficient4;
oddSumRotation = oddSumDifference * 0xB5 >> 8;
evenBaseSum = dcValue + coefficient4;
u = rotation45 + u;
v = evenBaseDifference + rotation45;
z = oddDifferenceSum * 0x62 >> 8;
evenOutput0 = evenBaseSum + u;
evenOutput3 = evenBaseSum - u;
oddHighRotation = oddHighDifference * 0x14E >> 8;
evenOutput2 = evenBaseDifference - rotation45;
m = oddHighRotation - z;
oddLowSum += m;
n = oddHighSum + oddLowSum;
o = x + m;
dst[0] = w + n;
p_part = oddLowDifference * 0x8B;
dst[7] = w - n;
p_part >>= 8;
dst[1] = v + o;
p = z + p_part;
q = p + x;
dst[6] = v - o;
dst[2] = e + q;
dst[5] = e - q;
dst[3] = y + p;
dst[4] = y - p;
oddOutput1 = oddSumRotation + m;
workspaceCursor[0] = evenOutput0 + n;
oddLowRotation = oddLowDifference * 0x8B;
workspaceCursor[7] = evenOutput0 - n;
oddLowRotation >>= 8;
workspaceCursor[1] = v + oddOutput1;
oddOutput3 = z + oddLowRotation;
oddOutput2 = oddOutput3 + oddSumRotation;
workspaceCursor[6] = v - oddOutput1;
workspaceCursor[2] = evenOutput2 + oddOutput2;
workspaceCursor[5] = evenOutput2 - oddOutput2;
workspaceCursor[3] = evenOutput3 + oddOutput3;
workspaceCursor[4] = evenOutput3 - oddOutput3;
}
block += 8;
dst += 8;
workspaceCursor += 8;
}
dst = tmp + done;
for (; done <= 0x38; done += 8) {
memset(dst, 0, 0x20);
dst += 8;
workspaceCursor = workspace + processedCoefficients;
for (; processedCoefficients <= 0x38; processedCoefficients += 8) {
memset(workspaceCursor, 0, 0x20);
workspaceCursor += 8;
}
epilogue:
columnTransform:
dst = tmp + 7;
for (iter = 8, i = 7; iter > 0; iter--, i--) {
u32 ac;
workspaceCursor = workspace + 7;
for (columnsRemaining = 8, column = 7; columnsRemaining > 0; columnsRemaining--, column--) {
u32 acBits;
u8* output;
b4 = dst[0x20];
output = conv_row_ptr + i;
b6 = dst[0x30];
b2 = dst[0x10];
b1 = dst[8];
b7 = dst[0x38];
b5 = dst[0x28];
b3 = dst[0x18];
coefficient4 = workspaceCursor[0x20];
output = conv_row_ptr + column;
coefficient6 = workspaceCursor[0x30];
coefficient2 = workspaceCursor[0x10];
coefficient1 = workspaceCursor[8];
coefficient7 = workspaceCursor[0x38];
coefficient5 = workspaceCursor[0x28];
coefficient3 = workspaceCursor[0x18];
ac = (u32)b4;
ac |= (u32)b6;
ac |= (u32)b2;
ac |= (u32)b1;
ac |= (u32)b7;
ac |= (u32)b5;
ac |= (u32)b3;
if (ac == 0) {
s32 val;
val = clampS8(*dst >> 11);
output[56] = (u8)val;
output[48] = (u8)val;
output[40] = (u8)val;
output[32] = (u8)val;
output[24] = (u8)val;
output[16] = (u8)val;
output[8] = (u8)val;
output[0] = (u8)val;
acBits = (u32)coefficient4;
acBits |= (u32)coefficient6;
acBits |= (u32)coefficient2;
acBits |= (u32)coefficient1;
acBits |= (u32)coefficient7;
acBits |= (u32)coefficient5;
acBits |= (u32)coefficient3;
if (acBits == 0) {
s32 sample;
sample = clampS8(*workspaceCursor >> 11);
output[56] = (u8)sample;
output[48] = (u8)sample;
output[40] = (u8)sample;
output[32] = (u8)sample;
output[24] = (u8)sample;
output[16] = (u8)sample;
output[8] = (u8)sample;
output[0] = (u8)sample;
} else {
s32 oddLowSum;
s32 oddLowDifference;
@@ -427,42 +433,42 @@ epilogue:
s32 oddHighDifference;
s32 dcValue;
t = b2 - b6;
oddLowSum = b5 + b3;
oddLowDifference = b5 - b3;
oddHighSum = b1 + b7;
oddHighDifference = b1 - b7;
u = b6 + b2;
t = t * 0xB5 >> 8;
x_factor = oddHighSum - oddLowSum;
z_factor = oddLowDifference + oddHighDifference;
dcValue = *dst;
a = dcValue - b4;
x = x_factor * 0xB5 >> 8;
d = dcValue + b4;
u = t + u;
v = a + t;
z = z_factor * 0x62 >> 8;
w = d + u;
y = d - u;
m_part = oddHighDifference * 0x14E >> 8;
e = a - t;
m = m_part - z;
rotation45 = coefficient2 - coefficient6;
oddLowSum = coefficient5 + coefficient3;
oddLowDifference = coefficient5 - coefficient3;
oddHighSum = coefficient1 + coefficient7;
oddHighDifference = coefficient1 - coefficient7;
u = coefficient6 + coefficient2;
rotation45 = rotation45 * 0xB5 >> 8;
oddSumDifference = oddHighSum - oddLowSum;
oddDifferenceSum = oddLowDifference + oddHighDifference;
dcValue = *workspaceCursor;
evenBaseDifference = dcValue - coefficient4;
oddSumRotation = oddSumDifference * 0xB5 >> 8;
evenBaseSum = dcValue + coefficient4;
u = rotation45 + u;
v = evenBaseDifference + rotation45;
z = oddDifferenceSum * 0x62 >> 8;
evenOutput0 = evenBaseSum + u;
evenOutput3 = evenBaseSum - u;
oddHighRotation = oddHighDifference * 0x14E >> 8;
evenOutput2 = evenBaseDifference - rotation45;
m = oddHighRotation - z;
oddLowSum += m;
n = oddHighSum + oddLowSum;
o = x + m;
p_part = oddLowDifference * 0x8B >> 8;
p = z + p_part;
q = p + x;
output[0] = (u8)clampS8((w + n) >> 11);
output[56] = (u8)clampS8((w - n) >> 11);
output[8] = (u8)clampS8((v + o) >> 11);
output[48] = (u8)clampS8((v - o) >> 11);
output[16] = (u8)clampS8((e + q) >> 11);
output[40] = (u8)clampS8((e - q) >> 11);
output[24] = (u8)clampS8((y + p) >> 11);
output[32] = (u8)clampS8((y - p) >> 11);
oddOutput1 = oddSumRotation + m;
oddLowRotation = oddLowDifference * 0x8B >> 8;
oddOutput3 = z + oddLowRotation;
oddOutput2 = oddOutput3 + oddSumRotation;
output[0] = (u8)clampS8((evenOutput0 + n) >> 11);
output[56] = (u8)clampS8((evenOutput0 - n) >> 11);
output[8] = (u8)clampS8((v + oddOutput1) >> 11);
output[48] = (u8)clampS8((v - oddOutput1) >> 11);
output[16] = (u8)clampS8((evenOutput2 + oddOutput2) >> 11);
output[40] = (u8)clampS8((evenOutput2 - oddOutput2) >> 11);
output[24] = (u8)clampS8((evenOutput3 + oddOutput3) >> 11);
output[32] = (u8)clampS8((evenOutput3 - oddOutput3) >> 11);
}
dst--;
workspaceCursor--;
}
}

View File

@@ -121,7 +121,7 @@ s32 TMCJPEGDEC_make_huffdec(const u8* dht, u8* tb, TMCHuffParam* hp) {
void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCJpegTableInfo* info) {
TMCCJPEGDecWork* work = (TMCCJPEGDecWork*)info;
TMCJpegTableInfo* work = info;
void* hufftable;
void* maxcode;
void* valptr;
@@ -129,15 +129,15 @@ void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCJ
if (tblType == 0) {
switch (tblID) {
case 0: {
hufftable = &work->zigzagData[8];
hufftable = work->huffDecTblDC0;
maxcode = work->maxCodeDC0;
tbl->huffTable = hufftable;
tbl->maxCode = maxcode;
tbl->valptr = work->valPtrDC0;
work->huffTblInitFlag[0] = 1;
memset(hufftable, 0, 0x400);
memset(work->maxCodeDC0, 0, 0x10);
memset(work->valPtrDC0, 0, 0x44);
work->dcTblFlag[0] = 1;
memset(hufftable, 0, sizeof(work->huffDecTblDC0));
memset(work->maxCodeDC0, 0, sizeof(work->maxCodeDC0));
memset(work->valPtrDC0, 0, sizeof(work->valPtrDC0));
break;
}
case 1: {
@@ -147,10 +147,10 @@ void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCJ
tbl->huffTable = hufftable;
tbl->maxCode = maxcode;
tbl->valptr = valptr;
work->huffTblInitFlag[1] = 1;
memset(hufftable, 0, 0x400);
memset(work->maxCodeDC1, 0, 0x10);
memset(work->valPtrDC1, 0, 0x44);
work->dcTblFlag[1] = 1;
memset(hufftable, 0, sizeof(work->huffDecTblDC1));
memset(work->maxCodeDC1, 0, sizeof(work->maxCodeDC1));
memset(work->valPtrDC1, 0, sizeof(work->valPtrDC1));
break;
}
}
@@ -163,10 +163,10 @@ void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCJ
tbl->huffTable = hufftable;
tbl->maxCode = maxcode;
tbl->valptr = valptr;
work->huffTblInitFlag[2] = 1;
memset(hufftable, 0, 0x400);
memset(work->maxCodeAC0, 0, 0x100);
memset(work->valPtrAC0, 0, 0x44);
work->acTblFlag[0] = 1;
memset(hufftable, 0, sizeof(work->huffDecTblAC0));
memset(work->maxCodeAC0, 0, sizeof(work->maxCodeAC0));
memset(work->valPtrAC0, 0, sizeof(work->valPtrAC0));
break;
}
case 1: {
@@ -176,10 +176,10 @@ void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCJ
tbl->huffTable = hufftable;
tbl->maxCode = maxcode;
tbl->valptr = valptr;
work->huffTblInitFlag[3] = 1;
memset(hufftable, 0, 0x400);
memset(work->maxCodeAC1, 0, 0x100);
memset(work->valPtrAC1, 0, 0x44);
work->acTblFlag[1] = 1;
memset(hufftable, 0, sizeof(work->huffDecTblAC1));
memset(work->maxCodeAC1, 0, sizeof(work->maxCodeAC1));
memset(work->valPtrAC1, 0, sizeof(work->valPtrAC1));
break;
}
}

View File

@@ -33,9 +33,16 @@ enum TMCExifTag {
TMC_EXIF_TAG_PIXEL_Y_DIMENSION = 0xA003,
};
typedef struct {
u8 tag[2];
u8 type[2];
u8 count[4];
u8 value[4];
} TMCExifEntry;
static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData* pInfo);
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry);
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry);
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, TMCExifEntry* entry);
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const TMCExifEntry* entry);
static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExifInfo* info, u32 totalSize);
static u16 readU16(const u8* p, u16 byteOrder) {
@@ -316,8 +323,8 @@ static s32 TMCJPEGDEC_exif_parse(const u8* entries, u32 size, TMCCJPEGDecExifDat
return -161;
}
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (u8*)entries);
entries += 12;
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (TMCExifEntry*)entries);
entries += sizeof(TMCExifEntry);
}
remaining -= (s32)count * 12;
if (remaining < 4) {
@@ -344,8 +351,8 @@ static s32 TMCJPEGDEC_exif_parse(const u8* entries, u32 size, TMCCJPEGDecExifDat
return -161;
}
for (ifd1Index = 0; ifd1Index < ifd1Count; ifd1Index++) {
TMCJPEGDEC_IFD1_tag_parse(pInfo, byteOrder, ifd1Entries);
ifd1Entries += 12;
TMCJPEGDEC_IFD1_tag_parse(pInfo, byteOrder, (const TMCExifEntry*)ifd1Entries);
ifd1Entries += sizeof(TMCExifEntry);
}
}
ifdOffset = pInfo->nextIfdOffset;
@@ -365,19 +372,19 @@ static s32 TMCJPEGDEC_exif_parse(const u8* entries, u32 size, TMCCJPEGDecExifDat
return -161;
}
for (exifIndex = 0; exifIndex < exifCount; exifIndex++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (u8*)exifEntries);
exifEntries += 12;
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (TMCExifEntry*)exifEntries);
exifEntries += sizeof(TMCExifEntry);
}
}
return 0;
}
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry) {
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, TMCExifEntry* entry) {
s32 tag;
u32 type;
tag = readExifU16(entry, byteOrder);
type = readExifU16(entry + 2, byteOrder);
tag = readExifU16(entry->tag, byteOrder);
type = readExifU16(entry->type, byteOrder);
switch (tag) {
case TMC_EXIF_TAG_COMPRESSION:
@@ -387,11 +394,11 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
break;
}
case TMC_EXIF_TAG_ORIENTATION: {
pInfo->orientation = readU16(entry + 8, byteOrder);
pInfo->orientation = readU16(entry->value, byteOrder);
return;
}
case TMC_EXIF_TAG_X_RESOLUTION: {
u32 offset = readU32(entry + 8, byteOrder);
u32 offset = readU32(entry->value, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
@@ -400,7 +407,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
pInfo->xResNum = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + 4);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
return;
}
@@ -411,7 +418,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
case TMC_EXIF_TAG_Y_RESOLUTION: {
u32 offset = readU32(entry + 8, byteOrder);
u32 offset = readU32(entry->value, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
@@ -420,7 +427,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
pInfo->yResNum = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + 4);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
return;
}
@@ -431,11 +438,11 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
case TMC_EXIF_TAG_RESOLUTION_UNIT: {
pInfo->resUnit = readU16(entry + 8, byteOrder);
pInfo->resUnit = readU16(entry->value, byteOrder);
return;
}
case TMC_EXIF_TAG_TRANSFER_FUNCTION: {
u32 offset = readU32(entry + 8, byteOrder);
u32 offset = readU32(entry->value, byteOrder);
u32 channel;
u32 index;
for (channel = 0; channel < 3; channel++) {
@@ -444,87 +451,87 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
if (pInfo->thumbnailData > p) {
break;
}
if (p > pInfo->dataEnd - 2) {
if (p > pInfo->dataEnd - sizeof(u16)) {
break;
}
pInfo->transferFunc[channel][index] = readU16(p, byteOrder);
offset += 2;
offset += sizeof(u16);
}
}
return;
}
case TMC_EXIF_TAG_DATE_TIME: {
u32 offset = readU32(entry + 8, byteOrder);
u32 offset = readU32(entry->value, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - 20) {
if (p > pInfo->dataEnd - sizeof(pInfo->dateTime)) {
return;
}
{
u32 index;
for (index = 0; index < 20; index++) {
for (index = 0; index < sizeof(pInfo->dateTime); index++) {
pInfo->dateTime[index] = p[index];
}
}
return;
}
case TMC_EXIF_TAG_YCBCR_POSITIONING: {
pInfo->yCbCrPos = readU16(entry + 8, byteOrder);
pInfo->yCbCrPos = readU16(entry->value, byteOrder);
return;
}
case TMC_EXIF_TAG_EXIF_IFD: {
pInfo->nextIfdOffset = readU32(entry + 8, byteOrder);
pInfo->nextIfdOffset = readU32(entry->value, byteOrder);
return;
}
case TMC_EXIF_TAG_EXIF_VERSION: {
pInfo->exifVer[0] = entry[8];
pInfo->exifVer[1] = entry[9];
pInfo->exifVer[2] = entry[10];
pInfo->exifVer[3] = entry[11];
pInfo->exifVer[0] = entry->value[0];
pInfo->exifVer[1] = entry->value[1];
pInfo->exifVer[2] = entry->value[2];
pInfo->exifVer[3] = entry->value[3];
return;
}
case TMC_EXIF_TAG_COMPONENTS_CONFIGURATION: {
pInfo->flashVer[0] = entry[8];
pInfo->flashVer[1] = entry[9];
pInfo->flashVer[2] = entry[10];
pInfo->flashVer[3] = entry[11];
pInfo->flashVer[0] = entry->value[0];
pInfo->flashVer[1] = entry->value[1];
pInfo->flashVer[2] = entry->value[2];
pInfo->flashVer[3] = entry->value[3];
return;
}
case TMC_EXIF_TAG_FLASHPIX_VERSION: {
pInfo->flashPixVer[0] = entry[8];
pInfo->flashPixVer[1] = entry[9];
pInfo->flashPixVer[2] = entry[10];
pInfo->flashPixVer[3] = entry[11];
pInfo->flashPixVer[0] = entry->value[0];
pInfo->flashPixVer[1] = entry->value[1];
pInfo->flashPixVer[2] = entry->value[2];
pInfo->flashPixVer[3] = entry->value[3];
return;
}
case TMC_EXIF_TAG_COLOR_SPACE: {
pInfo->colorSpace = readU16(entry + 8, byteOrder);
pInfo->colorSpace = readU16(entry->value, byteOrder);
return;
}
case TMC_EXIF_TAG_PIXEL_X_DIMENSION: {
if (type == TMC_EXIF_TYPE_SHORT) {
pInfo->pixelXDim = readU16(entry + 8, byteOrder);
pInfo->pixelXDim = readU16(entry->value, byteOrder);
} else if (type == TMC_EXIF_TYPE_LONG) {
pInfo->pixelXDim = readU32(entry + 8, byteOrder);
pInfo->pixelXDim = readU32(entry->value, byteOrder);
}
return;
}
case TMC_EXIF_TAG_PIXEL_Y_DIMENSION: {
if (type == TMC_EXIF_TYPE_SHORT) {
pInfo->pixelYDim = readU16(entry + 8, byteOrder);
pInfo->pixelYDim = readU16(entry->value, byteOrder);
} else if (type == TMC_EXIF_TYPE_LONG) {
pInfo->pixelYDim = readU32(entry + 8, byteOrder);
pInfo->pixelYDim = readU32(entry->value, byteOrder);
}
return;
}
}
}
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry) {
s32 tag = readU16(entry, byteOrder);
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const TMCExifEntry* entry) {
s32 tag = readU16(entry->tag, byteOrder);
switch (tag) {
case TMC_EXIF_TAG_DATE_TIME:
@@ -545,7 +552,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
case TMC_EXIF_TAG_X_RESOLUTION: {
u32 offset;
const u8* p;
offset = readU32(entry + 8, byteOrder);
offset = readU32(entry->value, byteOrder);
p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
@@ -554,7 +561,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
pInfo->xResNumIfd1 = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + 4);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
return;
}
@@ -567,7 +574,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
case TMC_EXIF_TAG_Y_RESOLUTION: {
u32 offset;
const u8* p;
offset = readU32(entry + 8, byteOrder);
offset = readU32(entry->value, byteOrder);
p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
@@ -576,7 +583,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
pInfo->planarConfigIfd1 = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + 4);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
return;
}
@@ -587,19 +594,19 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
case TMC_EXIF_TAG_RESOLUTION_UNIT: {
pInfo->resUnitIfd1 = readU16(entry + 8, byteOrder);
pInfo->resUnitIfd1 = readU16(entry->value, byteOrder);
return;
}
case TMC_EXIF_TAG_COMPRESSION: {
pInfo->compressionIfd1 = readU16(entry + 8, byteOrder);
pInfo->compressionIfd1 = readU16(entry->value, byteOrder);
return;
}
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT: {
pInfo->thumbnailOffset = readU32(entry + 8, byteOrder);
pInfo->thumbnailOffset = readU32(entry->value, byteOrder);
return;
}
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH: {
pInfo->thumbnailLength = readU32(entry + 8, byteOrder);
pInfo->thumbnailLength = readU32(entry->value, byteOrder);
return;
}
}

View File

@@ -1,3 +1,4 @@
#define TMC_JPEG_FRAME_PARSER
#include <tmc_jpeg_internal.h>
extern void* memset(void* dest, s32 val, u32 count);
@@ -17,7 +18,7 @@ static s32 TMCJPEGDEC_parse_sof(TMCCJPEGDecWork* work);
static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work);
s32 TMCJPEGDEC_decompmcu(u32 maxMCU, u32 mcuCount, TMCCJPEGDecWork* work, void* buf) {
u8* compMapBase;
TMCFrameComponents* compMapBase;
u8* compMapPtr;
u32* mcuDataInfo;
@@ -33,7 +34,7 @@ s32 TMCJPEGDEC_decompmcu(u32 maxMCU, u32 mcuCount, TMCCJPEGDecWork* work, void*
u16 pitch;
u8* frameInfo;
u8* scaleInfo;
TMCJpegTableInfo* scaleInfo;
u8** convRowPtrs;
TMCCJPEGDecState* state;
@@ -43,12 +44,12 @@ s32 TMCJPEGDEC_decompmcu(u32 maxMCU, u32 mcuCount, TMCCJPEGDecWork* work, void*
TMCDecodeFunc* decodeFunc;
state = work->pState;
compMapBase = work->compMap;
compMapBase = &work->components;
frameInfo = (u8*)&work->frameWidth;
compMapPtr = compMapBase;
scaleInfo = &work->scaleFlag;
compMapPtr = compMapBase->map;
scaleInfo = &work->tables;
convRowPtrs = work->pConvRowPtrs;
mcuDataInfo = (u32*)(compMapBase + 4);
mcuDataInfo = compMapBase->dcPredict;
mcuIdx = 0;
decodeFunc = work->decodePtr;
@@ -59,15 +60,15 @@ s32 TMCJPEGDEC_decompmcu(u32 maxMCU, u32 mcuCount, TMCCJPEGDecWork* work, void*
while (mcuIdx < ((TMCJpegFrameInfo*)frameInfo)->scanCompCount) {
compIdx = *compMapPtr;
entTblBase = scaleInfo + ((u32) * (compMapBase + compIdx + 0x18) << 8);
TMCJPEGDEC_set_entropytbl((TMCCJPEGDecWork*)scaleInfo, *(compMapBase + compIdx + 0x1c), *(compMapBase + compIdx + 0x20));
entTblBase = (u8*)scaleInfo->coefficients[compMapBase->quantTable[compIdx]];
TMCJPEGDEC_set_entropytbl(scaleInfo, compMapBase->dcTable[compIdx], compMapBase->acTable[compIdx]);
curBlockInfo = convRowPtrs;
specificConvRowPtr = convRowPtrs + compIdx;
blockCountPtr = frameInfo + mcuIdx;
blockIdx = 0;
while (blockIdx < (s32) * (blockCountPtr + 0x1c)) {
while (blockIdx < *(blockCountPtr + 0x1c)) {
s32 stackBlock[64];
s32 ret;
@@ -112,7 +113,7 @@ static inline void initZigzag(TMCCJPEGDecWork* work) {
work->restartInterval = 0;
work->scanCount = 0;
for (i = 0; i < 64; i++) {
work->zigzagData[i] = *zigzag++ << 2;
work->tables.zigzagData[i] = *zigzag++ << 2;
}
}
@@ -198,10 +199,10 @@ s32 TMCJPEGDEC_scanstart(TMCCJPEGDecWork* work) {
return r;
}
work->dcPredict[0] = 0;
work->dcPredict[1] = 0;
work->dcPredict[2] = 0;
work->dcPredict[3] = 0;
work->components.dcPredict[0] = 0;
work->components.dcPredict[1] = 0;
work->components.dcPredict[2] = 0;
work->components.dcPredict[3] = 0;
work->restartCnt = 0;
r = TMCJPEGDEC_init_buff(work);
if (r < 0) {
@@ -229,11 +230,11 @@ s32 TMCJPEGDEC_scan_varinit(TMCCJPEGDecWork* work) {
u8 component;
hSamp = p->maxHSamp;
component = work->compMap[0];
component = work->components.map[0];
qTblH = p->hSampFactor[component];
hMul8 = hSamp * 8;
p->mcuXCount = (u8)(hMul8 / qTblH);
p->mcuXRem = (u8)(p->maxVSamp * 8 / p->vSampFactor[component]);
p->mcuXCount = hMul8 / qTblH;
p->mcuXRem = p->maxVSamp * 8 / p->vSampFactor[component];
p->mcuYCount = p->frameWidth / p->mcuXCount;
p->mcuXCount2 = p->frameHeight / p->mcuXRem;
} else {
@@ -254,15 +255,15 @@ s32 TMCJPEGDEC_scan_varinit(TMCCJPEGDecWork* work) {
p->remX = remX;
p->remY = remY;
p->mcuYCount = p->mcuYCount + ((u8)remX != 0 ? 1 : 0);
p->mcuXCount2 = p->mcuXCount2 + ((u8)remY != 0 ? 1 : 0);
p->mcuTotal = (u32)p->mcuYCount * (u32)p->mcuXCount2;
p->mcuYCount = p->mcuYCount + ((u8)remX != 0);
p->mcuXCount2 = p->mcuXCount2 + ((u8)remY != 0);
p->mcuTotal = (u32)p->mcuYCount * p->mcuXCount2;
for (idx = 0; idx < p->scanCompCount; idx++) {
u8 compId;
u32 blocks;
compId = work->compMap[idx];
compId = work->components.map[idx];
if (p->scanCompCount == 1) {
blocks = 1;
} else {
@@ -294,10 +295,10 @@ static inline void restartMcuPosition(TMCCJPEGDecWork* work, TMCCJPEGDecState* s
blockCount = mcuCount / stepY;
column = maxMCU / stepX;
position = blockCount * pitch + column + 1;
work->dcPredict[0] = 0;
work->dcPredict[1] = 0;
work->dcPredict[2] = 0;
work->dcPredict[3] = 0;
work->components.dcPredict[0] = 0;
work->components.dcPredict[1] = 0;
work->components.dcPredict[2] = 0;
work->components.dcPredict[3] = 0;
work->restartCnt = 0;
row = position / pitch;
remainder = position - row * pitch;
@@ -515,7 +516,7 @@ static s32 TMCJPEGDEC_parse_dht(s32 first, TMCCJPEGDecWork* work) {
s32 r;
TMCHuffParam tblSet;
scaleInfo = (TMCJpegTableInfo*)&work->scaleFlag;
scaleInfo = &work->tables;
memset(countBuf, 0, sizeof(countBuf));
@@ -591,8 +592,7 @@ static s32 TMCJPEGDEC_parse_dqt(TMCCJPEGDecWork* work) {
u32 data[64];
} CopyBlock64;
typedef struct { u32 coefficients[4][64]; } QuantizationTables;
QuantizationTables* scaleInfo;
TMCJpegTableInfo* scaleInfo;
u32 tblCopy[64];
u32* d;
u16 len;
@@ -601,7 +601,7 @@ static s32 TMCJPEGDEC_parse_dqt(TMCCJPEGDecWork* work) {
d = tblCopy;
*(CopyBlock64*)d = *(CopyBlock64*)scJpegAanScale;
scaleInfo = (QuantizationTables*)&work->scaleFlag;
scaleInfo = &work->tables;
r = TMCJPEGDEC_get_wbyte(&len, work);
if (r < 0) {
@@ -627,7 +627,7 @@ static s32 TMCJPEGDEC_parse_dqt(TMCCJPEGDecWork* work) {
return -0x41;
}
((TMCJpegTableInfo*)scaleInfo)->quantTblFlag[qtInfo] = 1;
scaleInfo->quantTblFlag[qtInfo] = 1;
zigPtr = TMCJPEGDEC_Zigzag_data;
for (zzIdx = 0; zzIdx < 64; zzIdx++) {
@@ -642,7 +642,7 @@ static s32 TMCJPEGDEC_parse_dqt(TMCCJPEGDecWork* work) {
return r;
}
val = (u32)byte * tblCopy[zz];
val = byte * tblCopy[zz];
scaleInfo->coefficients[qtInfo][zz] = val;
if (val == 0) {
return -0x41;
@@ -655,498 +655,168 @@ static s32 TMCJPEGDEC_parse_dqt(TMCCJPEGDecWork* work) {
return 0;
}
#ifdef __MWERKS__
static asm s32 TMCJPEGDEC_parse_sof(register TMCCJPEGDecWork* work) {
nofralloc
stwu r1, -0x30(r1)
mflr r0
stw r0, 0x34(r1)
stmw r25, 0x14(r1)
mr r27, r3
addi r29, r3, 0x17f0
addi r28, r3, 0x2c
addi r3, r1, 0xa
mr r4, r27
bl TMCJPEGDEC_get_wbyte
cmpwi r3, 0
bge _parse_sof_have_length
b _parse_sof_return
_parse_sof_have_length:
lhz r0, 0xa(r1)
cmplwi r0, 2
bge _parse_sof_have_precision
li r3, -0x50
b _parse_sof_return
_parse_sof_have_precision:
mr r4, r27
addi r3, r1, 8
bl TMCJPEGDEC_get_byte
cmpwi r3, 0
bge _parse_sof_check_precision
b _parse_sof_return
_parse_sof_check_precision:
lbz r0, 8(r1)
cmplwi r0, 8
beq _parse_sof_get_height
li r3, -0x50
b _parse_sof_return
_parse_sof_get_height:
mr r4, r27
addi r3, r1, 0xa
bl TMCJPEGDEC_get_wbyte
cmpwi r3, 0
bge _parse_sof_store_height
b _parse_sof_return
_parse_sof_store_height:
lhz r0, 0xa(r1)
mr r4, r27
addi r3, r1, 0xa
sth r0, 2(r29)
bl TMCJPEGDEC_get_wbyte
cmpwi r3, 0
bge _parse_sof_store_width
b _parse_sof_return
_parse_sof_store_width:
lhz r0, 0xa(r1)
mr r4, r27
addi r3, r1, 8
sth r0, 0(r29)
bl TMCJPEGDEC_get_byte
cmpwi r3, 0
bge _parse_sof_store_components
b _parse_sof_return
_parse_sof_store_components:
lbz r0, 8(r1)
cmpwi r0, 0
stb r0, 0x1a(r29)
ble _parse_sof_bad_header
cmpwi r0, 4
ble _parse_sof_components_valid
_parse_sof_bad_header:
li r3, -0x50
b _parse_sof_return
_parse_sof_components_valid:
li r30, 0
li r31, 0
li r25, 0
b _parse_sof_component_condition
_parse_sof_component_loop:
mr r4, r27
addi r3, r1, 8
bl TMCJPEGDEC_get_byte
cmpwi r3, 0
bge _parse_sof_have_component_id
b _parse_sof_return
_parse_sof_have_component_id:
lbz r0, 8(r1)
add r26, r28, r25
mr r4, r27
addi r3, r1, 8
stb r0, 0x14(r26)
bl TMCJPEGDEC_get_byte
cmpwi r3, 0
bge _parse_sof_have_sampling
b _parse_sof_return
_parse_sof_have_sampling:
lbz r0, 8(r1)
add r4, r29, r25
srawi r3, r0, 4
clrlwi r0, r0, 0x1c
stb r3, 0x20(r4)
cmpw r3, r31
stb r0, 0x24(r4)
ble _parse_sof_check_v_sampling
mr r31, r3
_parse_sof_check_v_sampling:
lbz r0, 0x24(r4)
cmpw r0, r30
ble _parse_sof_get_qtable
mr r30, r0
_parse_sof_get_qtable:
mr r4, r27
addi r3, r1, 8
bl TMCJPEGDEC_get_byte
cmpwi r3, 0
bge _parse_sof_store_qtable
b _parse_sof_return
_parse_sof_store_qtable:
lbz r0, 8(r1)
addi r25, r25, 1
stb r0, 0x18(r26)
_parse_sof_component_condition:
lbz r0, 0x1a(r29)
cmpw r25, r0
blt _parse_sof_component_loop
clrlwi. r0, r31, 0x10
beq _parse_sof_bad_sampling
clrlwi. r0, r30, 0x10
bne _parse_sof_sampling_valid
_parse_sof_bad_sampling:
li r3, -0x50
b _parse_sof_return
_parse_sof_sampling_valid:
li r0, 6
lis r6, TMCJPEGDEC_SampleComps@ha
lis r7, TMCJPEGDEC_SampleH_N@ha
lis r8, TMCJPEGDEC_SampleV_N@ha
stb r31, 0x28(r29)
addi r6, r6, TMCJPEGDEC_SampleComps@l
addi r7, r7, TMCJPEGDEC_SampleH_N@l
addi r8, r8, TMCJPEGDEC_SampleV_N@l
stb r30, 0x29(r29)
li r10, 0
stb r0, 0xc(r29)
_parse_sof_sample_loop:
lbz r5, 0x1a(r29)
lbz r0, 0(r6)
cmplw r5, r0
bne _parse_sof_sample_next
mr r4, r7
mr r3, r8
li r11, 0
mtctr r5
cmpwi r5, 0
ble _parse_sof_sample_match
_parse_sof_sample_compare:
add r9, r29, r11
lbz r0, 0(r4)
lbz r5, 0x20(r9)
cmplw r5, r0
bne _parse_sof_sample_next
lbz r5, 0x24(r9)
lbz r0, 0(r3)
cmplw r5, r0
bne _parse_sof_sample_next
addi r11, r11, 1
addi r3, r3, 1
addi r4, r4, 1
bdnz _parse_sof_sample_compare
_parse_sof_sample_match:
stb r10, 0xc(r29)
_parse_sof_sample_next:
addi r10, r10, 1
addi r7, r7, 4
cmpwi r10, 6
addi r8, r8, 4
addi r6, r6, 1
blt _parse_sof_sample_loop
lbz r0, 0xc(r29)
cmplwi r0, 6
bne _parse_sof_setup_mcu
li r3, -0x70
b _parse_sof_return
_parse_sof_setup_mcu:
lhz r9, 0(r29)
rlwinm r8, r31, 3, 0x18, 0x1c
rlwinm r12, r30, 3, 0x18, 0x1c
lhz r11, 2(r29)
divw r6, r9, r8
stb r8, 0xd(r29)
lbz r5, 0x180a(r27)
addi r3, r27, 0x17f0
addi r0, r27, 0x2c
stb r12, 0xe(r29)
clrlwi r10, r6, 0x10
li r4, 0
mullw r6, r6, r8
divw r7, r11, r12
subf r6, r6, r9
stb r6, 0x18(r29)
mullw r9, r7, r12
clrlwi r8, r7, 0x10
clrlwi r7, r6, 0x18
neg r6, r7
subf r11, r9, r11
or r9, r6, r7
stb r11, 0x19(r29)
clrlwi r7, r11, 0x18
neg r6, r7
srwi r9, r9, 0x1f
or r6, r6, r7
add r9, r10, r9
srwi r6, r6, 0x1f
sth r9, 0x10(r29)
add r8, r8, r6
clrlwi r7, r9, 0x10
clrlwi r6, r8, 0x10
sth r8, 0x12(r29)
mullw r6, r7, r6
stw r6, 0x14(r29)
mtctr r5
cmpwi r5, 0
ble _parse_sof_component_check_done
_parse_sof_component_check:
add r5, r3, r4
lbz r6, 0x20(r5)
cmplwi r6, 1
blt _parse_sof_bad_component
cmplwi r6, 4
ble _parse_sof_check_v_factor
_parse_sof_bad_component:
li r3, -0x50
b _parse_sof_return
_parse_sof_check_v_factor:
lbz r5, 0x24(r5)
cmplwi r5, 1
blt _parse_sof_bad_v_factor
cmplwi r5, 4
ble _parse_sof_check_qtable
_parse_sof_bad_v_factor:
li r3, -0x50
b _parse_sof_return
_parse_sof_check_qtable:
add r5, r0, r4
lbz r5, 0x18(r5)
cmplwi r5, 4
ble _parse_sof_next_check
li r3, -0x50
b _parse_sof_return
_parse_sof_next_check:
addi r4, r4, 1
bdnz _parse_sof_component_check
_parse_sof_component_check_done:
li r3, 0
_parse_sof_return:
lmw r25, 0x14(r1)
lwz r0, 0x34(r1)
mtlr r0
addi r1, r1, 0x30
blr
static inline void initFrameGeometry(TMCJpegFrameInfo* frameInfo, s32 maxHSamp, s32 maxVSamp) {
u8 mcuWidth;
u8 mcuHeight;
u16 frameWidth;
u16 frameHeight;
s32 columnQuotient;
s32 rowQuotient;
u16 columns;
u16 rows;
mcuWidth = maxHSamp * 8;
mcuHeight = maxVSamp * 8;
frameWidth = frameInfo->frameWidth;
frameHeight = frameInfo->frameHeight;
columnQuotient = frameWidth / mcuWidth;
rowQuotient = frameHeight / mcuHeight;
columns = columnQuotient;
rows = rowQuotient;
frameInfo->mcuXCount = mcuWidth;
frameInfo->mcuXRem = mcuHeight;
frameInfo->remX = frameWidth - columnQuotient * mcuWidth;
frameInfo->remY = frameHeight - rowQuotient * mcuHeight;
frameInfo->mcuYCount = columns + (frameInfo->remX != 0);
frameInfo->mcuXCount2 = rows + (frameInfo->remY != 0);
frameInfo->mcuTotal = (u32)frameInfo->mcuYCount * frameInfo->mcuXCount2;
}
#else
static s32 TMCJPEGDEC_parse_sof(TMCCJPEGDecWork* work) {
TMCJpegFrameInfo* frameInfo = (TMCJpegFrameInfo*)&work->frameWidth;
u16 len;
u8 precision;
u16 height;
u16 width;
u8 compCount;
s32 r;
static inline s32 storeSampling(TMCJpegFrameInfo* frame, s32 index, u8 packed) {
s32 horizontal = packed >> 4;
frame->hSampFactor[index] = horizontal;
frame->vSampFactor[index] = packed & 15;
return horizontal;
}
static inline s32 validateFrameComponents(TMCCJPEGDecWork* work) {
s32 idx;
TMCJpegFrameInfo* frameInfo = (TMCJpegFrameInfo*)&work->frameWidth;
TMCFrameComponents* components = &work->components;
for (idx = 0; idx < frameInfo->compCount; idx++) {
if (frameInfo->hSampFactor[idx] < 1 || frameInfo->hSampFactor[idx] > 4) {
return TMCC_ERROR_HEADER;
}
if (frameInfo->vSampFactor[idx] < 1 || frameInfo->vSampFactor[idx] > 4) {
return TMCC_ERROR_HEADER;
}
if (components->quantTable[idx] > 4) {
return TMCC_ERROR_HEADER;
}
}
return 0;
}
static s32 TMCJPEGDEC_parse_sof(TMCCJPEGDecWork* work) {
s32 maxHSamp;
s32 maxVSamp;
u32 idx;
TMCJpegFrameInfo* frameInfo = (TMCJpegFrameInfo*)&work->frameWidth;
TMCFrameComponents* components = &work->components;
u16 value;
u8 byte;
s32 r;
s32 idx;
r = TMCJPEGDEC_get_wbyte(&value, work);
if (r < 0) {
return r;
}
if (value < 2) {
return TMCC_ERROR_HEADER;
}
r = TMCJPEGDEC_get_byte(&byte, work);
if (r < 0) {
return r;
}
if (byte != 8) {
return TMCC_ERROR_HEADER;
}
r = TMCJPEGDEC_get_wbyte(&value, work);
if (r < 0) {
return r;
}
frameInfo->frameHeight = value;
r = TMCJPEGDEC_get_wbyte(&value, work);
if (r < 0) {
return r;
}
frameInfo->frameWidth = value;
r = TMCJPEGDEC_get_byte(&byte, work);
if (r < 0) {
return r;
}
frameInfo->compCount = byte;
if ((s32)frameInfo->compCount <= 0 || (s32)frameInfo->compCount > 4) {
return TMCC_ERROR_HEADER;
}
maxHSamp = 0;
maxVSamp = 0;
r = TMCJPEGDEC_get_wbyte(&len, work);
if (r < 0) {
return r;
}
if (len < 2) {
return TMCC_ERROR_HEADER;
}
r = TMCJPEGDEC_get_byte(&precision, work);
if (r < 0) {
return r;
}
if (precision != 8) {
return TMCC_ERROR_HEADER;
}
r = TMCJPEGDEC_get_wbyte(&height, work);
if (r < 0) {
return r;
}
frameInfo->frameHeight = height;
r = TMCJPEGDEC_get_wbyte(&width, work);
if (r < 0) {
return r;
}
frameInfo->frameWidth = width;
r = TMCJPEGDEC_get_byte(&compCount, work);
if (r < 0) {
return r;
}
if (compCount <= 0 || compCount > 4) {
return TMCC_ERROR_HEADER;
}
frameInfo->compCount = compCount;
for (idx = 0; idx < compCount; idx++) {
u8 compId;
u8 hSamp;
u8 vSamp;
u8 qTbl;
r = TMCJPEGDEC_get_byte(&compId, work);
maxHSamp = 0;
for (idx = 0; idx < frameInfo->compCount; idx++) {
s32 hSamp;
s32 vSamp;
r = TMCJPEGDEC_get_byte(&byte, work);
if (r < 0) {
return r;
}
work->compId[idx] = compId;
r = TMCJPEGDEC_get_byte(&hSamp, work);
components->id[idx] = byte;
r = TMCJPEGDEC_get_byte(&byte, work);
if (r < 0) {
return r;
}
vSamp = hSamp & 0xF;
hSamp = hSamp >> 4;
frameInfo->hSampFactor[idx] = hSamp;
frameInfo->vSampFactor[idx] = vSamp;
if (hSamp > maxHSamp)
hSamp = storeSampling(frameInfo, idx, byte);
if (hSamp > maxHSamp) {
maxHSamp = hSamp;
if (vSamp > maxVSamp)
}
vSamp = frameInfo->vSampFactor[idx];
if (vSamp > maxVSamp) {
maxVSamp = vSamp;
r = TMCJPEGDEC_get_byte(&qTbl, work);
}
r = TMCJPEGDEC_get_byte(&byte, work);
if (r < 0) {
return r;
}
work->compQTbl[idx] = qTbl;
components->quantTable[idx] = byte;
}
if (maxHSamp == 0 || maxVSamp == 0) {
if ((u16)maxHSamp == 0 || (u16)maxVSamp == 0) {
return TMCC_ERROR_HEADER;
}
frameInfo->maxHSamp = maxHSamp;
frameInfo->maxVSamp = maxVSamp;
frameInfo->componentCount = 6;
{
u32 sampleIdx;
for (sampleIdx = 0; sampleIdx < 6; sampleIdx++) {
u32 c;
u8 match;
if (frameInfo->compCount != TMCJPEGDEC_SampleComps[sampleIdx]) {
continue;
}
match = TRUE;
for (c = 0; c < frameInfo->compCount; c++) {
if (frameInfo->hSampFactor[c] != TMCJPEGDEC_SampleH_N[sampleIdx * 4 + c] ||
frameInfo->vSampFactor[c] != TMCJPEGDEC_SampleV_N[sampleIdx * 4 + c]) {
match = FALSE;
break;
s32 sample;
for (sample = 0; sample < 6; sample++) {
s32 component;
u32 factor;
if (frameInfo->compCount == TMCJPEGDEC_SampleComps[sample]) {
for (component = 0; component < frameInfo->compCount; component++) {
factor = frameInfo->hSampFactor[component];
if (factor != TMCJPEGDEC_SampleH_N[sample][component]) {
goto nextSample;
}
factor = frameInfo->vSampFactor[component];
if (factor != TMCJPEGDEC_SampleV_N[sample][component]) {
goto nextSample;
}
}
frameInfo->componentCount = sample;
}
if (match) {
frameInfo->componentCount = sampleIdx;
break;
}
nextSample:
continue;
}
}
if (frameInfo->componentCount == 6) {
return -0x70;
return TMCC_ERROR_FORMAT;
}
{
u16 fw = frameInfo->frameWidth;
u16 fh = frameInfo->frameHeight;
u8 mcuX = (maxHSamp & 0x07) << 3;
u8 mcuY = (maxVSamp & 0x07) << 3;
u16 mcuCountX;
u16 mcuCountY;
u16 remX;
u16 remY;
u32 compCount2;
frameInfo->mcuXCount = mcuX;
frameInfo->mcuXRem = mcuY;
mcuCountX = fw / mcuX;
mcuCountY = fh / mcuY;
remX = fw - mcuCountX * mcuX;
remY = fh - mcuCountY * mcuY;
work->remX = remX;
work->remY = remY;
{
u16 xr = (remX != 0) ? 1 : 0;
u16 yr = (remY != 0) ? 1 : 0;
mcuCountX += xr;
mcuCountY += yr;
frameInfo->mcuYCount = mcuCountX;
frameInfo->mcuXCount2 = mcuCountY;
work->mcuTotal = (u32)mcuCountX * (u32)mcuCountY;
}
compCount2 = frameInfo->compCount;
for (idx = 0; idx < compCount2; idx++) {
u8 hSamp2;
u8 vSamp2;
u8 qTbl2;
hSamp2 = frameInfo->hSampFactor[idx];
if (hSamp2 < 1 || hSamp2 > 4) {
return TMCC_ERROR_HEADER;
}
vSamp2 = frameInfo->vSampFactor[idx];
if (vSamp2 < 1 || vSamp2 > 4) {
return TMCC_ERROR_HEADER;
}
qTbl2 = work->compQTbl[idx];
if (qTbl2 > 4) {
return TMCC_ERROR_HEADER;
}
}
}
return 0;
initFrameGeometry(frameInfo, maxHSamp, maxVSamp);
return validateFrameComponents(work);
}
#endif
static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work) {
typedef struct {
u8 map[4];
u32 dcPredict[4];
u8 id[4];
u8 quantTable[4];
u8 dcTable[4];
u8 acTable[4];
} TMCComponentInfo;
s32 idx;
TMCComponentInfo* components;
TMCFrameComponents* components;
TMCJpegTableInfo* scalePtr;
TMCComponentInfo* mapPtr;
TMCFrameComponents* mapPtr;
s32 dcTbl;
s32 acTbl;
@@ -1157,8 +827,8 @@ static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work) {
s32 ci;
u8 scanByte;
components = (TMCComponentInfo*)work->compMap;
scalePtr = (TMCJpegTableInfo*)&work->scaleFlag;
components = &work->components;
scalePtr = &work->tables;
r = TMCJPEGDEC_get_wbyte(&len, work);
if (r < 0) {
@@ -1188,7 +858,7 @@ static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work) {
for (ci = 0; ci < work->compCount; ci++) {
if ((s32)scanByte == (s32)components->id[ci]) {
components->map[idx] = ci;
mapPtr = (TMCComponentInfo*)&components->map[idx];
mapPtr = (TMCFrameComponents*)&components->map[idx];
goto componentFound;
}
}
@@ -1437,10 +1107,10 @@ s32 TMCJPEGDEC_err_restart(TMCCJPEGDecWork* work) {
pitch = state->maxX;
val = work->mcuPos;
work->dcPredict[0] = 0;
work->dcPredict[1] = 0;
work->dcPredict[2] = 0;
work->dcPredict[3] = 0;
work->components.dcPredict[0] = 0;
work->components.dcPredict[1] = 0;
work->components.dcPredict[2] = 0;
work->components.dcPredict[3] = 0;
work->restartCnt = 0;
next = (u8)(val & 0xFF) * (s32)pitch + (val >> 16) + (s32)(u8)(rstDiff * interval);
@@ -1462,18 +1132,18 @@ s32 TMCJPEGDEC_err_restart(TMCCJPEGDecWork* work) {
}
#endif
void TMCJPEGDEC_set_entropytbl(TMCCJPEGDecWork* work, s32 idx, u8 data) {
void TMCJPEGDEC_set_entropytbl(TMCJpegTableInfo* work, s32 idx, u8 data) {
switch (idx) {
case 0: {
work->pDCACPtrs[0] = &work->zigzagData[8];
work->pDCACPtrs[2] = work->maxCodeDC0;
work->pDCACPtrs[1] = work->valPtrDC0;
work->pDCFast = work->huffDecTblDC0;
work->pDCHuffSym = work->maxCodeDC0;
work->pDCHuffTbl = work->valPtrDC0;
break;
}
case 1: {
work->pDCACPtrs[0] = work->huffDecTblDC1;
work->pDCACPtrs[2] = work->maxCodeDC1;
work->pDCACPtrs[1] = work->valPtrDC1;
work->pDCFast = work->huffDecTblDC1;
work->pDCHuffSym = work->maxCodeDC1;
work->pDCHuffTbl = work->valPtrDC1;
break;
}
}
@@ -1482,14 +1152,14 @@ void TMCJPEGDEC_set_entropytbl(TMCCJPEGDecWork* work, s32 idx, u8 data) {
goto ac1;
}
if ((s32)data < 1 && (s32)data >= 0) {
work->pDCACPtrs[4] = work->huffDecTblAC0;
*(void**)work->zigzagData = work->maxCodeAC0;
work->pDCACPtrs[5] = work->valPtrAC0;
work->pACFast = work->huffDecTblAC0;
work->pACHuffSym = work->maxCodeAC0;
work->pACHuffTbl = work->valPtrAC0;
}
return;
ac1:
work->pDCACPtrs[4] = work->huffDecTblAC1;
*(void**)work->zigzagData = work->maxCodeAC1;
work->pDCACPtrs[5] = work->valPtrAC1;
work->pACFast = work->huffDecTblAC1;
work->pACHuffSym = work->maxCodeAC1;
work->pACHuffTbl = work->valPtrAC1;
}

View File

@@ -1,22 +1,22 @@
#include <tmc_jpeg_internal.h>
// clang-format off
const u8 TMCJPEGDEC_SampleH_N[24] = {
4, 1, 1, 0,
2, 1, 1, 0,
2, 1, 1, 0,
1, 1, 1, 0,
1, 1, 1, 0,
1, 0, 0, 0
const u8 TMCJPEGDEC_SampleH_N[6][4] = {
{4, 1, 1, 0},
{2, 1, 1, 0},
{2, 1, 1, 0},
{1, 1, 1, 0},
{1, 1, 1, 0},
{1, 0, 0, 0}
};
const u8 TMCJPEGDEC_SampleV_N[24] = {
1, 1, 1, 0,
1, 1, 1, 0,
2, 1, 1, 0,
2, 1, 1, 0,
1, 1, 1, 0,
1, 0, 0, 0
const u8 TMCJPEGDEC_SampleV_N[6][4] = {
{1, 1, 1, 0},
{1, 1, 1, 0},
{2, 1, 1, 0},
{2, 1, 1, 0},
{1, 1, 1, 0},
{1, 0, 0, 0}
};
const u8 TMCJPEGDEC_Zigzag_data[64] = {

View File

@@ -10,7 +10,7 @@ static u8 clampU8(s32 v) {
}
static s8 clampS8(s32 v) {
return (v < 128 && v > -129) ? (s8)v : (v > 0) ? 127 : -128;
return (v < 128 && v > -129) ? v : (v > 0) ? 127 : -128;
}
void TMCJPEGDEC_IdctBlock4x4(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {

View File

@@ -38,7 +38,7 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
s32* conv_row;
conv_row = (s32*)conv_row_ptr;
dcf = work->pDCFast;
dcf = work->tables.pDCFast;
if (work->bitCount <= 8) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
@@ -54,7 +54,7 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
work->bitCount -= val;
val = tmp;
} else {
val = TMCJPEGDEC_vl_decode_rc(work->pDCHuffTbl, work->pDCHuffSym, work);
val = TMCJPEGDEC_vl_decode_rc(work->tables.pDCHuffTbl, work->tables.pDCHuffSym, work);
if (val < 0) {
return val;
}
@@ -73,9 +73,9 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
*block = dc_predict_row_ptr[0] * conv_row[0];
ac_fast = work->pACFast;
ac_vl = work->pACHuffTbl;
ac_sym = work->pACHuffSym;
ac_fast = work->tables.pACFast;
ac_vl = work->tables.pACHuffTbl;
ac_sym = work->tables.pACHuffSym;
blk_size = work->blockSize;
blk_mul = work->blockSizeMul;

View File

@@ -240,14 +240,14 @@ vowel:
}
ziBool Zi8ITspecialExclusion(ziWChar* ending, ziS32 length, ziU32 candidateLength) {
ziPtr beginning;
ziWChar* beginning;
const ZiExclusionPair* pair;
int index;
beginning = ending - length--;
pair = IT_EXCLUDE_PAIRS;
for (; pair->replacement != 0; ++pair) {
for (index = 0; index < length; ++index) {
if (((ziWChar*)beginning)[index] != pair->prefix[index]) break;
if (beginning[index] != pair->prefix[index]) break;
}
if (index >= length && pair->prefix[index] == 0) {
if (!Zi8IsVowel(47, *ending)) return ZI8_TRUE;
@@ -258,14 +258,14 @@ ziBool Zi8ITspecialExclusion(ziWChar* ending, ziS32 length, ziU32 candidateLengt
}
ziBool Zi8_814659E8(ziWChar* ending, ziS32 length, ziU32 candidateLength) {
ziPtr beginning;
ziWChar* beginning;
const ZiExclusionPair* pair;
int index;
beginning = ending - length--;
pair = FrenchExcludePairs;
for (; pair->replacement != 0; ++pair) {
for (index = 0; index < length; ++index) {
if (((ziWChar*)beginning)[index] != pair->prefix[index]) break;
if (beginning[index] != pair->prefix[index]) break;
}
if (index >= length && pair->prefix[index] == 0) {
if (!Zi8IsVowel(88, *ending)) return ZI8_TRUE;

View File

@@ -187,7 +187,8 @@ unsigned int Zi8MatchROMdata1(ziWChar *elements, ziU8 count, ziU8 language, ziWC
ZI_WORK->groupPtr = (ziU8*)group;
if (ZI_WORK->groupPtr == 0) {
if (Zi8GetTableSize(language & 0xff,0xb,ZI_WORK) != 0) {
ZI_WORK->groupPtr = (ziU8*)(tableAddress = Zi8GetTableAddress(language & 0xff,0xb,ZI_WORK));
tableAddress = Zi8GetTableAddress(language & 0xff,0xb,ZI_WORK);
ZI_WORK->groupPtr = (ziU8*)tableAddress;
}
}
if (ZI_WORK->groupPtr != 0) {

View File

@@ -765,8 +765,7 @@ ziU8 Zi8GetBpmfPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final,
*initial = 0x7E00;
*final = ((ziU16)Zi8BpmfInitials[value] & 0x7F) << 9;
resultCount++;
count--;
if (count == 0) {
if (--count == 0) {
*bestInitial = *initial;
*bestFinal = *final;
if ((value >= 0xE) && (value <= 0x14)) {
@@ -778,8 +777,7 @@ ziU8 Zi8GetBpmfPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final,
text++;
if (*text == 0xF360) {
resultCount++;
count--;
if (count == 0) {
if (--count == 0) {
return resultCount;
}
Zi8ReplaceLastError(0x156, ZI_WORK);
@@ -805,8 +803,7 @@ bpmf_value_22:
*final |= 0x80;
*initial |= 0x180;
resultCount++;
count--;
if (count == 0) {
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
@@ -817,8 +814,7 @@ bpmf_value_23:
*final |= 0x100;
*initial |= 0x180;
resultCount++;
count--;
if (count == 0) {
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
@@ -829,8 +825,7 @@ bpmf_value_24:
*final |= 0x180;
*initial |= 0x180;
resultCount++;
count--;
if (count == 0) {
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
@@ -848,8 +843,7 @@ after_bpmf_initial:
*final |= (ziU16)Zi8BpmfInitials[value] << 3;
*initial |= 0x78;
resultCount++;
count--;
if (count == 0) {
if (--count == 0) {
*bestInitial = *initial;
*bestFinal = *final;
return resultCount;
@@ -875,8 +869,7 @@ after_bpmf_initial:
*bestInitial = *initial;
*bestFinal = *final;
resultCount++;
count--;
if (count != 0) {
if (--count != 0) {
Zi8ReplaceLastError(0x157, ZI_WORK);
return 0;
}

View File

@@ -18,8 +18,8 @@ ziBool Zi8_81480224(ziUserWord* word ZI_NEED_WORK) {
ziUwdNode* previous;
ziUwdNode* current;
ziUwdNode* added;
ziUserWord* candidate;
ziU8 position;
ziUserWord* candidate;
if (ZI_WORK->uwdCount >= 32) {
Zi8LogError(0x19D, __zi8_work_data);
return 0;
@@ -41,7 +41,7 @@ ziBool Zi8_81480224(ziUserWord* word ZI_NEED_WORK) {
current = ZI_WORK->uwdList;
while (current != 0) {
candidate = (ziUserWord*)current->word;
if (ZI_WORK->uwdPrioritySort == 1 && candidate->priority < word->priority) break;
if (ZI_WORK->uwdPrioritySort == 1 && word->priority > candidate->priority) break;
if (candidate->length == length) {
position = 0;
while (position < length) {

View File

@@ -1,3 +1,4 @@
#include <stddef.h>
#include <zi8clib/zierror.h>
extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
@@ -12,8 +13,8 @@ typedef struct {
} ZiKoreanKeyEntry;
ziU16 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) {
ziU32 value;
ziU16 count;
ziU16 value;
ziU16 i;
count = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
@@ -306,7 +307,7 @@ ziU32 Zi8GetKOcandidates(ziGetParam* param, ZiKoreanCandidateOptions* options ZI
if (param->wordCharCount == 0) goto scan_key_table;
{
if (((search.keyIndex = Zi8_8148302C(param->currentWord[0], keyTable, ZI_WORK)) != 0xFFFF) &&
((((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->keyBytes[4] & 8) != 0)) {
((keyTable[(search.keyIndex << 3) + search.keyIndex + offsetof(ZiKoreanKeyEntry, keyBytes[4])] & 8) != 0)) {
search.wordOffset = ((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childLow |
((((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->keyBytes[4] & 3) << 16 |
((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childHigh << 8);

View File

@@ -92,8 +92,7 @@ tables_ready:
return 0;
}
tableCount = 0;
keyIndex = tableCount;
keyIndex = tableCount = 0;
for (; (ziU16)keyIndex < key; keyIndex++) {
tableCount += dataAddress[(ziU16)keyIndex];
}

View File

@@ -27,8 +27,7 @@ ziU8 Zi8MatchOEMdata(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* word
ziU32 position;
ziU32 fallback = 0;
if (!continuation) ZI_WORK->oemIdx = 0;
index = ZI_WORK->oemIdx;
if ((ziS32)index >= ZI_WORK->oemLen) goto failed;
if ((index = ZI_WORK->oemIdx) >= ZI_WORK->oemLen) goto failed;
if (ZI_WORK->oemMatch == 0) goto failed;
if ((ziS32)length >= (ziS32)--capacity) {
failed:
@@ -53,8 +52,7 @@ posEntry:
}
if ((ziS32)position < length) {
if (complete) word[length] = 1; else word[length] = 0;
index++;
if ((ziS32)index >= ZI_WORK->oemLen) goto oemFailed;
if (++index >= ZI_WORK->oemLen) goto oemFailed;
goto matchRetry;
}
if (fallback) {
@@ -62,8 +60,7 @@ posEntry:
*word = *pattern;
return 1;
}
index++;
ZI_WORK->oemIdx = index;
ZI_WORK->oemIdx = ++index;
while (word[position] != 0) position++;
return position;
matchRetry:

View File

@@ -46,50 +46,50 @@ FAError FAAttach(u32 device, char* nand_path, u32 nand_size, FADrvTbl* table) {
if (table == NULL) {
return -2;
}
if (device == 2 && nand_path == NULL) {
if (device == FA_DEVICE_NAND && nand_path == NULL) {
return -2;
}
if (device == 3 && table->pPart == NULL) {
return -2;
}
if (device <= 2) {
if (device <= FA_DEVICE_NAND) {
if (pdm_open_disk(&drvInitFunc.entries[(u8)device], &disk) != 0) {
return -1;
return FA_ERR_SYSTEM;
}
if (pdm_open_partition(disk, 0, &table->pPart) != 0) {
return -1;
return FA_ERR_SYSTEM;
}
}
drives[0] = table;
drives[1] = NULL;
if (device == 2) {
if (device == FA_DEVICE_NAND) {
memcpy(nand.path, nand_path, 78);
nand.size = nand_size;
}
if (device == 2) {
if (device == FA_DEVICE_NAND) {
error = pfstub_attach(drives, &nand);
} else {
error = pfstub_attach(drives, NULL);
}
if (error != 0) {
return -1;
return FA_ERR_SYSTEM;
}
index = table->drive - 'A';
if (device <= 2) {
if (device <= FA_DEVICE_NAND) {
gOpenDisk[index] = disk;
gOpenPartition[index] = table->pPart;
if (device == 0) {
if (device == FA_DEVICE_SD) {
if (pfd_sddrv_is_media_insert()) {
drives[0]->stat |= 0x10;
drives[0]->stat |= FA_DRV_TBL_STAT_INSERTED;
}
} else if (device == 1) {
} else if (device == FA_DEVICE_USB) {
if (pfd_mscdrv_is_media_insert(disk)) {
drives[0]->stat |= 0x10;
drives[0]->stat |= FA_DRV_TBL_STAT_INSERTED;
}
}
} else {
gOpenDisk[index] = NULL;
gOpenPartition[index] = NULL;
}
return 0;
return FA_ERR_SUCCESS;
}

View File

@@ -10,15 +10,15 @@ FAError FADetach(s8 drive) {
FADisk* disk = gOpenDisk[drive - 'A'];
FAPartition* partition = gOpenPartition[drive - 'A'];
if (pfstub_detach(drive) != 0) {
return -1;
return FA_ERR_SYSTEM;
}
if (disk != NULL && partition != NULL) {
if (pdm_close_partition(partition) != 0) {
return -1;
return FA_ERR_SYSTEM;
}
if (pdm_close_disk(disk) != 0) {
return -1;
return FA_ERR_SYSTEM;
}
}
return 0;
return FA_ERR_SUCCESS;
}

View File

@@ -4,8 +4,8 @@ extern s32 pfstub_errnum(void);
FAError FAErrnum(void) {
s32 error = pfstub_errnum();
if (error == 5) {
return 5;
if (error == FA_ERR_EIO) {
return FA_ERR_EIO;
}
return error == 0 ? 0 : error;
return error == FA_ERR_SUCCESS ? FA_ERR_SUCCESS : error;
}

View File

@@ -11,7 +11,7 @@ extern s32 pfstub_init_prfile2(s32 config, void* parameter);
FAError FAInit(int flag) {
s32 error;
if (FAInInitializing == 1) {
return -1;
return FA_ERR_SYSTEM;
}
FAInInitializing = 1;
if (!FADiskInitialized) {
@@ -19,7 +19,7 @@ FAError FAInit(int flag) {
FADiskInitialized = error == 0;
if (error != 0) {
FAInInitializing = 0;
return -1;
return FA_ERR_SYSTEM;
}
}
if (!FAFileSysInitialized) {
@@ -27,10 +27,10 @@ FAError FAInit(int flag) {
FAFileSysInitialized = error == 0;
if (error == -1) {
FAInInitializing = 0;
return -1;
return FA_ERR_SYSTEM;
}
}
FAInInitializing = 0;
OSRegisterVersion(__FAVersion[0]);
return 0;
return FA_ERR_SUCCESS;
}

View File

@@ -19,12 +19,12 @@ void FANotifyUSBEject(s8 drive);
FAError FARegistCB(s32 device, FAInsertCallback insert, FAEjectCallback eject) {
s32 error;
switch (device) {
case 0:
case FA_DEVICE_SD:
gMediaInOutCallback.sd_insert = insert;
gMediaInOutCallback.sd_eject = eject;
error = pfd_sddrv_registar_callback(FANotifySDInsert, FANotifySDEject);
break;
case 1:
case FA_DEVICE_USB:
gMediaInOutCallback.usb_insert = insert;
gMediaInOutCallback.usb_eject = eject;
error = pfd_mscdrv_registar_callback(FANotifyUSBInsert, FANotifyUSBEject);
@@ -33,9 +33,9 @@ FAError FARegistCB(s32 device, FAInsertCallback insert, FAEjectCallback eject) {
return -2;
}
if (error != 0) {
return -1;
return FA_ERR_SYSTEM;
}
return 0;
return FA_ERR_SUCCESS;
}
void FANotifySDInsert(s8 drive) {

View File

@@ -85,18 +85,18 @@ static s32 fa_nanddrv_physical_write(u32, const u8*, u32, u32, u32*, PDM_DISK*);
static s32 fa_nanddrv_RelateNANDFileToDsk(PDM_DISK* disk, NAND_DISK_INFO* info, s32 format) {
s32 error = NANDChangeDir(NAND_Org_Path);
if (error != 0) { return error; }
if (info->flags & 4) { error = 0; }
else { error = NANDOpen(info->path, &info->file, 3); }
if (format) { error = -12; }
if (error != NAND_RESULT_OK) { return error; }
if (info->flags & 4) { error = NAND_RESULT_OK; }
else { error = NANDOpen(info->path, &info->file, NAND_ACCESS_RW); }
if (format) { error = NAND_RESULT_NOEXISTS; }
switch (error) {
case -12:
case NAND_RESULT_NOEXISTS:
error = fa_nanddrv_CreateNANDFileForDsk(info);
if (error == 0) { info->disk = disk; }
if (error == NAND_RESULT_OK) { info->disk = disk; }
break;
case 0:
info->disk = disk;
error = 0;
error = NAND_RESULT_OK;
break;
}
return error;
@@ -110,28 +110,28 @@ static s32 fa_nanddrv_CreateNANDFileForDsk(NAND_DISK_INFO* info) {
s32 error;
u32 remaining;
error = fa_nanddrv_ParseCreateNANDFile(info);
if (error != 0) { return error; }
if (error != NAND_RESULT_OK) { return error; }
pf_memset(boot, 0, 512);
clusters = 0;
fa_nanddrv_BuildUpBootSector(info, boot, &type, 0);
if (type != fa_nanddrv_VerifyBPB(boot, &clusters)) { fa_nanddrv_BuildUpBootSector(info, boot, &type, clusters); }
error = NANDWrite(&info->file, boot, 512);
if (error < 0) { NANDClose(&info->file); NANDDelete(info->path); return error; }
if (error < NAND_RESULT_OK) { NANDClose(&info->file); NANDDelete(info->path); return error; }
remaining = info->file_size - 512;
if (type == PDM_FAT_32) {
fa_nanddrv_BuildUpFSInfoSector(fsinfo);
error = NANDWrite(&info->file, fsinfo, 512);
if (error < 0) { NANDClose(&info->file); NANDDelete(info->path); return error; }
if (error < NAND_RESULT_OK) { NANDClose(&info->file); NANDDelete(info->path); return error; }
remaining -= 512;
}
pf_memset(zeros, 0, 512);
for (; remaining >= 512; remaining -= 512) {
error = NANDWrite(&info->file, zeros, 512);
if (error < 0) { NANDClose(&info->file); NANDDelete(info->path); return error; }
if (error < NAND_RESULT_OK) { NANDClose(&info->file); NANDDelete(info->path); return error; }
}
if (remaining) {
error = NANDWrite(&info->file, zeros, remaining);
if (error < 0) { NANDClose(&info->file); NANDDelete(info->path); return error; }
if (error < NAND_RESULT_OK) { NANDClose(&info->file); NANDDelete(info->path); return error; }
}
return 0;
}
@@ -150,25 +150,25 @@ static s32 fa_nanddrv_ParseCreateNANDFile(NAND_DISK_INFO* info) {
switch (*path) {
case '/':
if (length == 0) {
if (position == 0) { error = NANDChangeDir("/"); if (error != 0) { return error; } }
if (position == 0) { error = NANDChangeDir("/"); if (error != NAND_RESULT_OK) { return error; } }
path++;
break;
}
if (path[1] == 0) {
if (length > 12) { return -20; }
error = NANDCreate(name, 0x30, 0);
if (error == 0 || error == -6) {
NANDOpen(name, &info->file, 3);
error = NANDCreate(name, NAND_PERM_USER, 0);
if (error == NAND_RESULT_OK || error == NAND_RESULT_EXISTS) {
NANDOpen(name, &info->file, NAND_ACCESS_RW);
error = NANDChangeDir(NAND_Org_Path);
}
return error;
}
if (length > 11) { return -20; }
if (pf_strcmp(name, "..") != 0) { error = NANDCreateDir(name, 0x30, 0); }
else { error = 0; }
if (error == 0 || error == -6 || error == -1) {
if (pf_strcmp(name, "..") != 0) { error = NANDCreateDir(name, NAND_PERM_USER, 0); }
else { error = NAND_RESULT_OK; }
if (error == NAND_RESULT_OK || error == NAND_RESULT_EXISTS || error == NAND_RESULT_ACCESS) {
error = NANDChangeDir(name);
if (error != 0) { return error; }
if (error != NAND_RESULT_OK) { return error; }
} else {
return error;
}
@@ -179,9 +179,9 @@ static s32 fa_nanddrv_ParseCreateNANDFile(NAND_DISK_INFO* info) {
break;
case 0:
if (length > 12) { return -20; }
error = NANDCreate(name, 0x30, 0);
if (error == 0 || error == -6) {
NANDOpen(name, &info->file, 3);
error = NANDCreate(name, NAND_PERM_USER, 0);
if (error == NAND_RESULT_OK || error == NAND_RESULT_EXISTS) {
NANDOpen(name, &info->file, NAND_ACCESS_RW);
error = NANDChangeDir(NAND_Org_Path);
}
return error;
@@ -220,7 +220,7 @@ static s32 fa_nanddrv_VerifyBPB(u8* buf, u32* clusters) {
total = (u32)(total - first) >> cluster_log;
if (total < 4085) { return 0; }
result = PDM_FAT_32;
if ((u32)total < 65525) { result = PDM_FAT_16; }
if (total < 65525) { result = PDM_FAT_16; }
return result;
}
#pragma dont_inline on
@@ -279,8 +279,8 @@ static s32 fa_nanddrv_BuildUpBootSector(NAND_DISK_INFO* info, u8* buf, PDM_FAT_T
s32 fa_nanddrv_init(PDM_DISK* disk) {
if (disk == 0) { return -20; }
if (NAND_Init == 0) {
if (NANDInit() != 0) { return -21; }
if (NANDGetCurrentDir(NAND_Org_Path) != 0) { return -21; }
if (NANDInit() != NAND_RESULT_OK) { return -21; }
if (NANDGetCurrentDir(NAND_Org_Path) != NAND_RESULT_OK) { return -21; }
NAND_Init++;
}
pdm_disk_notify_media_insert(disk);
@@ -350,9 +350,9 @@ s32 fa_nanddrv_unmount(PDM_DISK* disk) {
if (error != 0) { result = error; goto flush_done; }
error = NANDClose(&info->file);
if (error < 0) { result = error; goto flush_done; }
error = NANDOpen(info->path, &info->file, 3);
error = NANDOpen(info->path, &info->file, NAND_ACCESS_RW);
if (error < 0) { result = error; goto flush_done; }
error = NANDSeek(&info->file, position, 0);
error = NANDSeek(&info->file, position, NAND_SEEK_BEG);
result = error < 0 ? error : 0;
flush_done:
error = result;
@@ -443,7 +443,7 @@ static s32 fa_nanddrv_physical_read(u32 count, u8* buf, u32 block, u32 bps, u32*
remaining = count * bps;
file_size = info->file_size;
wanted = block * bps;
if (NANDTell(&info->file, &position) != 0 || position != wanted) { error = NANDSeek(&info->file, wanted, 0); }
if (NANDTell(&info->file, &position) != NAND_RESULT_OK || position != wanted) { error = NANDSeek(&info->file, wanted, NAND_SEEK_BEG); }
else { error = 0; }
if (error >= 0) {
if (wanted + remaining > file_size) {
@@ -497,7 +497,7 @@ static s32 fa_nanddrv_physical_write(u32 count, const u8* buf, u32 block, u32 bp
remaining = count * bps;
file_size = info->file_size;
wanted = block * bps;
if (NANDTell(&info->file, &position) != 0 || position != wanted) { error = NANDSeek(&info->file, wanted, 0); }
if (NANDTell(&info->file, &position) != NAND_RESULT_OK || position != wanted) { error = NANDSeek(&info->file, wanted, NAND_SEEK_BEG); }
else { error = 0; }
if (error >= 0) {
if (wanted + remaining > file_size) {

View File

@@ -940,7 +940,7 @@ s32 pfd_sddrv_store_bpb_buf(PFD_SDDRV_FORMAT_DATA* format_data, u8* sector_buffe
pfd_sddrv_store_le16(sector_buffer, boot_sector->reserved_sector_count, offsetof(PFD_SDDRV_BPB, reserved_sector_count), 1);
boot_sector->fat_count = 2;
pfd_sddrv_store_le16(sector_buffer, boot_sector->root_entry_count, offsetof(PFD_SDDRV_BPB, root_entry_count), 0x200);
pfd_sddrv_store_le16(sector_buffer, boot_sector->total_sectors_16, offsetof(PFD_SDDRV_BPB, total_sectors_16), (u16)sectors_16);
pfd_sddrv_store_le16(sector_buffer, boot_sector->total_sectors_16, offsetof(PFD_SDDRV_BPB, total_sectors_16), sectors_16);
boot_sector->media_descriptor = 0xf8;
pfd_sddrv_store_le16(sector_buffer, boot_sector->sectors_per_fat_16, offsetof(PFD_SDDRV_BPB, sectors_per_fat_16), (u16)format_data->sectors_per_fat);
pfd_sddrv_store_le16(sector_buffer, boot_sector->sectors_per_track, offsetof(PFD_SDDRV_BPB, sectors_per_track), (u16)settings.root_entries);
@@ -1245,11 +1245,11 @@ s32 pfd_sddrv_store_fat32_mbr_buf(PFD_SDDRV_FORMAT_DATA* format_data, u8* sector
master_boot_record = (PFD_SDDRV_MBR*)sector_buffer;
partition = &master_boot_record->partitions[0];
partition->boot_indicator = 0;
partition->start_head = (u8)start_head;
partition->start_head = start_head;
pfd_sddrv_store_le16(sector_buffer, partition->start_sector_cylinder, offsetof(PFD_SDDRV_MBR, partitions) + offsetof(PFD_SDDRV_PARTITION_ENTRY, start_sector_cylinder),
((start_cylinder & 0xff) << 8) + ((start_sector & 0x3f) | ((start_cylinder & 0x300) >> 2)));
partition->partition_type = partition_type;
partition->end_head = (u8)end_head;
partition->end_head = end_head;
pfd_sddrv_store_le16(sector_buffer, partition->end_sector_cylinder, offsetof(PFD_SDDRV_MBR, partitions) + offsetof(PFD_SDDRV_PARTITION_ENTRY, end_sector_cylinder),
((end_cylinder & 0xff) << 8) + ((end_sector & 0x3f) | ((end_cylinder & 0x300) >> 2)));
pfd_sddrv_store_le32(sector_buffer, partition->first_sector, offsetof(PFD_SDDRV_MBR, partitions) + offsetof(PFD_SDDRV_PARTITION_ENTRY, first_sector), format_data->partition_start_sector);

View File

@@ -1,7 +1,7 @@
#include <private/fa/pdm.h>
extern void* pf_memset(void*, pf_u8, pf_u32);
PDM_DISK_SET pdm_disk_set;
PDM_DISK_TBL pdm_drv_tbl[26];
PDM_DISK_TBL pdm_drv_tbl[PDM_DRIVE_COUNT];
pf_s32 pdm_disk_convert_sector_into_block(PDM_DISK* p_disk, pf_u32 start, pf_u32 count, pf_u32 bytes_per_sector, pf_u32* p_start, pf_u32* p_count) {
pf_u32 ratio;
@@ -44,11 +44,11 @@ pf_s32 pdm_disk_add_disk(PDM_INIT_DISK* p_init_disk_tbl, PDM_DISK** pp_disk) {
pf_u16 disk_no;
PDM_DISK* p_disk;
*pp_disk = PF_NULL;
if (pdm_disk_set.num_allocated_disk >= 26) { return 8; }
for (disk_no = 0; disk_no < 26; disk_no++) {
if (pdm_disk_set.num_allocated_disk >= PDM_DRIVE_COUNT) { return 8; }
for (disk_no = 0; disk_no < PDM_DRIVE_COUNT; disk_no++) {
if (!(pdm_disk_set.disk[disk_no].status & 1)) { break; }
}
if (disk_no >= 26) { return 8; }
if (disk_no >= PDM_DRIVE_COUNT) { return 8; }
p_driver = &pdm_drv_tbl[disk_no];
p_init_disk_tbl->p_func(p_driver, p_init_disk_tbl->ui_ext);
p_disk = &pdm_disk_set.disk[disk_no];

View File

@@ -177,11 +177,11 @@ pf_s32 pdm_part_get_partition(PDM_DISK* p_disk, pf_u32 id, PDM_PARTITION** pp_pa
pf_s32 err;
pf_u16 index;
*pp_part = PF_NULL;
if (pdm_disk_set.num_partition >= 26) { return 10; }
for (index = 0; index < 26; index++) {
if (pdm_disk_set.num_partition >= PDM_DRIVE_COUNT) { return 10; }
for (index = 0; index < PDM_DRIVE_COUNT; index++) {
if (!(pdm_disk_set.partition[index].status & 1)) { break; }
}
if (index == 26) { return 10; }
if (index == PDM_DRIVE_COUNT) { return 10; }
err = pdm_disk_set_disk(p_disk, &pdm_disk_set.partition[index]);
if (err != 0) { return err; }
pdm_disk_set.num_partition++;
@@ -298,7 +298,7 @@ pf_s32 pdm_part_unregister_callback(PDM_PARTITION* p_part) {
}
void pdm_part_set_change_media_state(PDM_DISK* p_disk, pf_bool is_inserted) {
pf_u16 index;
for (index = 0; index < 26; index++) {
for (index = 0; index < PDM_DRIVE_COUNT; index++) {
if ((pdm_disk_set.partition[index].status & 1) && pdm_disk_set.partition[index].p_disk == p_disk) {
PDM_PARTITION* p_part = &pdm_disk_set.partition[index];
p_part->status |= 2;

View File

@@ -150,8 +150,8 @@ pf_u16* pf_w_strcpy(pf_u16* dst, const pf_u16* src) {
}
pf_s32 pf_w_strcmp(const pf_u16* s1, const pf_u16* s2) {
const pf_u16* p1 = (pf_u16*)s1;
const pf_u16* p2 = (pf_u16*)s2;
const pf_u16* p1 = s1;
const pf_u16* p2 = s2;
while (*p1 != 0 && *p2 != 0 && *p1 == *p2) {
p1++;
@@ -162,8 +162,8 @@ pf_s32 pf_w_strcmp(const pf_u16* s1, const pf_u16* s2) {
}
pf_s32 pf_w_strncmp(const pf_u16* s1, const pf_u16* s2, pf_u32 length) {
const pf_u16* p1 = (pf_u16*)s1;
const pf_u16* p2 = (pf_u16*)s2;
const pf_u16* p1 = s1;
const pf_u16* p2 = s2;
while (length-- != 0) {
if (*p1 == 0 || *p2 == 0 || *p1 != *p2) {

View File

@@ -129,12 +129,12 @@ pf_s32 VFiPFCODE_CP932_Unicode2OEM(const pf_u16* uc_src, pf_s8* cp932_dst) {
}
pf_s32 VFiPFCODE_CP932_OEMCharWidth(const pf_s8* buf) {
pf_u16 tmp;
pf_u16 unicode;
pf_s32 width;
pf_s16 oem_width;
pf_s16 uni_width;
width = VFiPFCODE_CP932_OEM2Unicode(buf, &tmp);
width = VFiPFCODE_CP932_OEM2Unicode(buf, &unicode);
VFiPFCODE_Divide_Width(width, &oem_width, &uni_width);
return (pf_s32)oem_width;
}
@@ -163,11 +163,11 @@ pf_bool VFiPFCODE_CP932_isOEMMBchar(pf_s8 cp932, pf_u32 num) {
}
pf_s32 VFiPFCODE_CP932_UnicodeCharWidth(const pf_u16* buf) {
pf_s8 tmp[2];
pf_s8 encoded[2];
pf_s32 width;
pf_s16 oem_width;
pf_s16 uni_width;
width = VFiPFCODE_CP932_Unicode2OEM(buf, tmp);
width = VFiPFCODE_CP932_Unicode2OEM(buf, encoded);
VFiPFCODE_Divide_Width(width, &oem_width, &uni_width);
return uni_width;
}

View File

@@ -214,7 +214,7 @@ pf_s32 PFENT_searchEmptyTailSFN(PFENTRY_FFD* p_ffd, pf_u32 tail_index, const pf_
pf_memset(p_tail_bit, 0, p_vol->tail_entry.tracker_size * 4);
iter.ffd = *p_ffd;
for (err = PFENT_ITER_IteratorInitialize(&iter, 0); PFENT_ITER_IsAtLogicalEnd(&iter) == PF_FALSE;
for (err = PFENT_ITER_IteratorInitialize(&iter, 0); !PFENT_ITER_IsAtLogicalEnd(&iter);
err = PFENT_ITER_Advance(&iter, PF_FALSE)) {
if (err != 0) {
return err;

View File

@@ -274,7 +274,7 @@ pf_s32 PFENT_ITER_DoFindEntry(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_STR
goto finish;
}
}
for (; PFENT_ITER_IsAtLogicalEnd(p_iter) == PF_FALSE; err = AdvanceIterator(p_iter, 0)) {
for (; !PFENT_ITER_IsAtLogicalEnd(p_iter); err = AdvanceIterator(p_iter, 0)) {
pf_s32 attr;
if (err != 0) return err;
if (p_iter->buf[0] == 0) break;
@@ -614,7 +614,7 @@ pf_s32 PFENT_ITER_FindDirEntryFromCluster(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p
p_ent->ordinal = 0;
p_ent->check_sum = 0;
if ((p_ent->attr & 0x10) && p_ent->start_cluster == 1) return 2;
for (; PFENT_ITER_IsAtLogicalEnd(p_iter) == PF_FALSE; err = AdvanceIterator(p_iter, PF_FALSE)) {
for (; !PFENT_ITER_IsAtLogicalEnd(p_iter); err = AdvanceIterator(p_iter, PF_FALSE)) {
if (err != 0) {
return err;
}

View File

@@ -153,7 +153,7 @@ pf_s32 PFFAT12_WriteFATEntryWithBuf(PF_VOLUME* p_vol, pf_s16 cluster, pf_u16 val
p_page->sector = next_sector;
p_page->p_buf[0] = value >> 4;
} else {
*(p_page->p_buf + ((pf_u16)offset_in_sector + 1)) = value >> 4;
p_page->p_buf[(pf_u16)offset_in_sector + 1] = value >> 4;
}
} else {
p_page->p_buf[(pf_u16)offset_in_sector] = value;
@@ -165,7 +165,7 @@ pf_s32 PFFAT12_WriteFATEntryWithBuf(PF_VOLUME* p_vol, pf_s16 cluster, pf_u16 val
p_page->sector = next_sector;
p_page->p_buf[0] = (p_page->p_buf[0] & 0xF0) | ((pf_u8)(value >> 8));
} else {
*(p_page->p_buf + ((pf_u16)offset_in_sector + 1)) = (*(p_page->p_buf + ((pf_u16)offset_in_sector + 1)) & 0xF0) | ((pf_u8)(value >> 8));
p_page->p_buf[(pf_u16)offset_in_sector + 1] = (p_page->p_buf[(pf_u16)offset_in_sector + 1] & 0xF0) | ((pf_u8)(value >> 8));
}
}
if (err != 0) { result = err; }
@@ -220,7 +220,7 @@ pf_s32 PFFAT12_ReadFATEntryWithBuf(PF_VOLUME* p_vol , pf_u16 cluster , pf_u32* p
LOAD_FAT_SECTOR(0);
state.offset &= p_vol->bpb.bytes_per_sector - 1;
if (state.offset == (p_vol->bpb.bytes_per_sector - 1)) {
*p_value = *(p_page->p_buf + state.offset);
*p_value = p_page->p_buf[state.offset];
if (p_page->option == 1) {
for (state.err = 0; (pf_u16)state.err < p_vol->bpb.num_active_FATs; state.err++) {
VFiPFSEC_WriteFAT(p_vol, p_page->p_buf, p_page->sector + (pf_u16)state.err * p_vol->bpb.sectors_per_FAT, 0, p_vol->bpb.bytes_per_sector);
@@ -231,7 +231,7 @@ pf_s32 PFFAT12_ReadFATEntryWithBuf(PF_VOLUME* p_vol , pf_u16 cluster , pf_u32* p
p_page->sector = state.sector + 1;
*p_value += (pf_u16)(*p_page->p_buf) << 8;
} else {
*p_value = ((pf_u16)p_page->p_buf[state.offset + 1] << 8) + *(p_page->p_buf + state.offset);
*p_value = ((pf_u16)p_page->p_buf[state.offset + 1] << 8) + p_page->p_buf[state.offset];
}
}
break;

View File

@@ -1,5 +1,6 @@
#define PF_FA_STR_LAYOUT
#include <decomp/utils.h>
#include <revolution/fa/types.h>
#include <private/vf/PrFILE2/fatfs/pf_volume.h>
#include <private/vf/PrFILE2/fatfs/pf_dir.h>
#include <private/vf/PrFILE2/fatfs/pf_path.h>
@@ -1717,13 +1718,13 @@ pf_s32 PFFILE_fseek(PFFILE_FILE* file, pf_s32 offset, pf_s32 origin) {
return 0x26;
}
switch (origin) {
case 1:
case FA_SEEK_ORIGIN_CURRENT:
file_io = file->cursor.position;
break;
case 0:
case FA_SEEK_ORIGIN_BEGIN:
file_io = 0;
break;
case 2:
case FA_SEEK_ORIGIN_END:
file_io = file->p_sfd->dir_entry.file_size;
break;
default:

View File

@@ -149,7 +149,7 @@ static pf_u32 PFPATH_UNI_ConvertFWchar(pf_u16 src, pf_u16* dst) {
}
static pf_u32 PFPATH_OEM_ConvertFWchar(const pf_s8* src, pf_u16* dst) {
pf_vol_set.codeset.oem2unicode((pf_s8*)src, dst);
pf_vol_set.codeset.oem2unicode(src, dst);
if (PFPATH_UNI_ConvertFWchar((pf_u16)*dst, dst) == 1) {
pf_vol_set.codeset.unicode2oem(dst, (pf_s8*)dst);
*dst = (pf_u16)*dst;
@@ -201,9 +201,9 @@ static pf_u16 PFPATH_GetNextCharOfFileName(PF_FILE_NAME_ITER* p_name) {
pf_u16 PFPATH_GetNextCharOfPattern(PF_STR* p_pattern, pf_u32 name_kind) {
pf_u16 wc;
pf_u16 tmp_wc;
pf_u16 oem_character;
pf_s8 pattern[3];
pf_u16 twc;
pf_u16 fullwidth_character;
if (p_pattern->code_mode == 1) {
pattern[0] = *p_pattern->p_head++;
@@ -236,12 +236,11 @@ pf_u16 PFPATH_GetNextCharOfPattern(PF_STR* p_pattern, pf_u32 name_kind) {
if (name_kind == 0) {
PF_PATH_VOLUME_SET* volume = &pf_vol_set;
volume->codeset.unicode2oem(&wc, (pf_s8*)&tmp_wc);
tmp_wc = (pf_u16)tmp_wc;
if (volume->codeset.is_oem_mb_char((pf_u8)(tmp_wc >> 8), 1) != 0) {
wc = tmp_wc;
volume->codeset.unicode2oem(&wc, (pf_s8*)&oem_character);
if (volume->codeset.is_oem_mb_char((pf_u8)(oem_character >> 8), 1) != 0) {
wc = oem_character;
} else {
pattern[0] = (pf_u8)(tmp_wc >> 8);
pattern[0] = (pf_u8)(oem_character >> 8);
if ((volume->config & 0x10000) != 0 || VALID_PATH_CHAR(pattern[0], 0x02)) {
wc = (pf_u8)pattern[0];
} else {
@@ -252,8 +251,8 @@ pf_u16 PFPATH_GetNextCharOfPattern(PF_STR* p_pattern, pf_u32 name_kind) {
}
wc = (wc >= 'a') && (wc <= 'z') ? wc - ' ' : wc;
if (name_kind != 0) {
if (PFPATH_UNI_ConvertFWchar((pf_u16)wc, &twc) == 1) {
wc = twc;
if (PFPATH_UNI_ConvertFWchar((pf_u16)wc, &fullwidth_character) == 1) {
wc = fullwidth_character;
}
} else {
if ((pf_u8)(wc >> 8) == 0) {
@@ -263,8 +262,8 @@ pf_u16 PFPATH_GetNextCharOfPattern(PF_STR* p_pattern, pf_u32 name_kind) {
pattern[0] = (pf_u8)(wc >> 8);
pattern[1] = (pf_u8)wc;
}
if (PFPATH_OEM_ConvertFWchar(pattern, &twc) == 1) {
wc = twc;
if (PFPATH_OEM_ConvertFWchar(pattern, &fullwidth_character) == 1) {
wc = fullwidth_character;
}
}
return wc;
@@ -339,13 +338,13 @@ pf_s32 PFPATH_cmpNameImpl(const pf_s8* name, const pf_s8* pattern, pf_u32* match
if (pattern_width == 1) {
read_char = pf_toupper(*pattern);
} else {
read_char = (pf_u16)PF_GET_LE_U16((const pf_u8*)pattern);
read_char = PF_GET_LE_U16((const pf_u8*)pattern);
}
pattern_char = (pf_u16)read_char;
if (name_width == 1) {
read_char = pf_toupper(*name);
} else {
read_char = (pf_u16)PF_GET_LE_U16((const pf_u8*)name);
read_char = PF_GET_LE_U16((const pf_u8*)name);
}
name_char = (pf_u16)read_char;
if (pattern_width == 2 && PFPATH_OEM_ConvertFWchar(pattern, &converted_pattern) == 1) {
@@ -368,7 +367,7 @@ pf_s32 PFPATH_cmpNameImpl(const pf_s8* name, const pf_s8* pattern, pf_u32* match
if (pattern_width == 1) {
read_char = pf_toupper(*pattern);
} else {
read_char = (pf_u16)PF_GET_LE_U16((const pf_u8*)pattern);
read_char = PF_GET_LE_U16((const pf_u8*)pattern);
}
pattern_char = (pf_u16)read_char;
pattern += pattern_width;
@@ -377,7 +376,7 @@ pf_s32 PFPATH_cmpNameImpl(const pf_s8* name, const pf_s8* pattern, pf_u32* match
name += name_width;
name_width = pf_vol_set.codeset.oem_char_width(name);
if (name_width == 1) { read_char = pf_toupper(*name); }
else { read_char = (pf_u16)PF_GET_LE_U16((const pf_u8*)name); }
else { read_char = PF_GET_LE_U16((const pf_u8*)name); }
name_char = (pf_u16)read_char;
}
} while (pattern_char == '?' || pattern_char == '*');
@@ -397,7 +396,7 @@ pf_s32 PFPATH_cmpNameImpl(const pf_s8* name, const pf_s8* pattern, pf_u32* match
if (name_width == 1) {
read_char = pf_toupper(*name);
} else {
read_char = (pf_u16)PF_GET_LE_U16((const pf_u8*)name);
read_char = PF_GET_LE_U16((const pf_u8*)name);
}
name_char = (pf_u16)read_char;
}

View File

@@ -30,7 +30,7 @@ pf_s32 VFiPFSEC_ReadFAT(PF_VOLUME* p_vol, pf_u8* p_buf, pf_u32 sector, pf_u16 of
PF_CACHE_PAGE* p_page;
pf_s32 err;
if ((p_vol->flags & 0x01) == 0 || VFiPFDRV_IsInserted(p_vol) == PF_FALSE) {
if ((p_vol->flags & 0x01) == 0 || !VFiPFDRV_IsInserted(p_vol)) {
return 9;
}
if (sector >= p_vol->bpb.total_sectors || offset >= p_vol->bpb.bytes_per_sector || offset + size > p_vol->bpb.bytes_per_sector) {
@@ -53,7 +53,7 @@ pf_s32 VFiPFSEC_ReadData(PF_VOLUME* p_vol, pf_u8* p_buf, pf_u32 sector, pf_u16 o
pf_s32 err;
*p_success_size = 0;
if ((p_vol->flags & 0x01) == 0 || VFiPFDRV_IsInserted(p_vol) == PF_FALSE) {
if ((p_vol->flags & 0x01) == 0 || !VFiPFDRV_IsInserted(p_vol)) {
return 9;
}
if ((sector >= p_vol->bpb.total_sectors || offset >= p_vol->bpb.bytes_per_sector || offset + size > p_vol->bpb.bytes_per_sector) && offset != 0) {

View File

@@ -14,8 +14,8 @@ void VFiPF_LE16_TO_U16_STR(pf_u8* sSrc, pf_u32 num) {
pf_s8* p = (pf_s8*)sSrc + cnt;
tmp_src = *p;
#ifdef DEBUG
*((pf_u8*)sSrc + cnt) = *((pf_u8*)sSrc + cnt + 1);
*((pf_u8*)sSrc + cnt + 1) = tmp_src;
*(sSrc + cnt) = *(sSrc + cnt + 1);
*(sSrc + cnt + 1) = tmp_src;
#else
sSrc[cnt] = sSrc[cnt + 1];
sSrc[cnt + 1] = tmp_src;

View File

@@ -134,19 +134,19 @@ pf_u16 PFSTR_StrNumChar(PF_STR* p_str, pf_u32 target) {
pf_s32 PFSTR_StrCmp(const PF_STR* p_str, const pf_s8* s) {
pf_u16 wc;
const pf_u16* wp;
const pf_s8* p1;
const pf_s8* p2;
const pf_s8* stringCursor;
const pf_s8* compareCursor;
pf_s32 ret;
if (p_str->code_mode == 1) {
p1 = p_str->p_head;
p2 = s;
ret = pf_strcmp(p1, p2);
stringCursor = p_str->p_head;
compareCursor = s;
ret = pf_strcmp(stringCursor, compareCursor);
} else {
wp = (pf_u16*)p_str->p_head;
do {
pf_vol_set.codeset.oem2unicode((pf_s8*)s, &wc);
pf_vol_set.codeset.oem2unicode(s, &wc);
s++;
if (*wp++ != wc) {
@@ -164,20 +164,20 @@ pf_s32 PFSTR_StrCmp(const PF_STR* p_str, const pf_s8* s) {
pf_s32 PFSTR_StrNCmp(PF_STR* p_str, const pf_s8* s, pf_u32 target, pf_s16 offset, pf_u16 num) {
pf_u16 wc;
const pf_u16* wp;
const pf_s8* p1;
const pf_s8* p2;
const pf_s8* stringCursor;
const pf_s8* compareCursor;
pf_s32 ret;
if (p_str->code_mode == 1 || target == 3) {
if (target == 1) {
p1 = &p_str->p_head[offset];
stringCursor = &p_str->p_head[offset];
} else if (target == 2) {
p1 = &p_str->p_tail[offset];
stringCursor = &p_str->p_tail[offset];
} else {
p1 = &p_str->p_current[offset];
stringCursor = &p_str->p_current[offset];
}
p2 = s;
ret = pf_strncmp(p1, p2, num);
compareCursor = s;
ret = pf_strncmp(stringCursor, compareCursor, num);
} else {
if (target == 1) {
wp = (pf_u16*)p_str->p_head + offset;
@@ -186,7 +186,7 @@ pf_s32 PFSTR_StrNCmp(PF_STR* p_str, const pf_s8* s, pf_u32 target, pf_s16 offset
}
do {
pf_vol_set.codeset.oem2unicode((pf_s8*)s, &wc);
pf_vol_set.codeset.oem2unicode(s, &wc);
s++;
num--;

View File

@@ -577,15 +577,7 @@ void OSInit() {
arenaAddr = RAMReadPtr(OSPhysicalToCached(OS_ADDR_AVAILABLE_MEM1_START));
if (arenaAddr == NULL) {
register void* arenaLo;
#ifdef __MWERKS__
asm {
lis arenaLo, -0x7E95
addi arenaLo, arenaLo, -0x6800
}
#else
arenaLo = __ArenaLo;
#endif
void* arenaLo = __ArenaLo;
if (OSIsMEM1Region(arenaLo)) {
void* tmp = BootInfo->arenaLo;
arenaAddr = tmp == NULL ? arenaLo : tmp;
@@ -612,15 +604,7 @@ void OSInit() {
arenaAddr = RAMReadPtr(OSPhysicalToCached(OS_ADDR_AVAILABLE_MEM2_START));
if (arenaAddr != NULL) {
register void* arenaLo;
#ifdef __MWERKS__
asm {
lis arenaLo, -0x7E95
addi arenaLo, arenaLo, -0x6800
}
#else
arenaLo = __ArenaLo;
#endif
void* arenaLo = __ArenaLo;
if (OSIsMEM2Region(arenaLo)) {
arenaAddr = arenaLo;

View File

@@ -169,28 +169,28 @@ static const u32 AESiDecryptTable[] = {
};
#define ROTATE(x,n) (((x) << (n)) | ((x) >> (32 - (n))))
#define ENCRYPT(a,b,c,d) (((ROTATE(AESiEncryptTable[((b)>>16)&255],16) ^ ROTATE(AESiEncryptTable[(a)>>24],24)) ^ AESiEncryptTable[(d)&255]) ^ ROTATE(AESiEncryptTable[((c)>>8)&255],8))
#define DECRYPT(a,b,c,d) (((ROTATE(AESiDecryptTable[((b)>>16)&255],16) ^ AESiDecryptTable[(d)&255]) ^ ROTATE(AESiDecryptTable[(a)>>24],24)) ^ ROTATE(AESiDecryptTable[((c)>>8)&255],8))
#define SUBSTITUTE(table,a,b,c,d) ((((u32)table[(a)>>24]<<24) | table[(d)&255]) | (((u32)table[((b)>>16)&255]<<16) | ((u32)table[((c)>>8)&255]<<8)))
#define ENCRYPT(state0,state1,state2,state3) (((ROTATE(AESiEncryptTable[((state1)>>16)&255],16) ^ ROTATE(AESiEncryptTable[(state0)>>24],24)) ^ AESiEncryptTable[(state3)&255]) ^ ROTATE(AESiEncryptTable[((state2)>>8)&255],8))
#define DECRYPT(state0,state1,state2,state3) (((ROTATE(AESiDecryptTable[((state1)>>16)&255],16) ^ AESiDecryptTable[(state3)&255]) ^ ROTATE(AESiDecryptTable[(state0)>>24],24)) ^ ROTATE(AESiDecryptTable[((state2)>>8)&255],8))
#define SUBSTITUTE(table,state0,state1,state2,state3) ((((u32)table[(state0)>>24]<<24) | table[(state3)&255]) | (((u32)table[((state1)>>16)&255]<<16) | ((u32)table[((state2)>>8)&255]<<8)))
#define DECRYPT_FINAL(table,a,b,c,d,key) ((table[(d)&255] ^ ((u32)table[((c)>>8)&255]<<8)) ^ (((u32)table[((b)>>16)&255]<<16) ^ ((key) ^ ((u32)table[(a)>>24]<<24))))
#define DECRYPT_FINAL(table,state0,state1,state2,state3,key) ((table[(state3)&255] ^ ((u32)table[((state2)>>8)&255]<<8)) ^ (((u32)table[((state1)>>16)&255]<<16) ^ ((key) ^ ((u32)table[(state0)>>24]<<24))))
void AESiEncryptBlock(AESContext* context, u32* output, const u32* input) {
u32 rounds = context->rounds;
const u32* key = context->keys + 4;
u32 a=input[0]^context->keys[0], b=input[1]^context->keys[1], c=input[2]^context->keys[2], d=input[3]^context->keys[3];
u32 state0=input[0]^context->keys[0], state1=input[1]^context->keys[1], state2=input[2]^context->keys[2], state3=input[3]^context->keys[3];
while (--rounds != 0) {
u32 nextA=ENCRYPT(a,b,c,d);
u32 nextB=ENCRYPT(b,c,d,a);
u32 nextC=ENCRYPT(c,d,a,b);
u32 nextD=ENCRYPT(d,a,b,c);
a=nextA^key[0]; b=nextB^key[1]; c=nextC^key[2]; d=nextD^key[3];
u32 nextState0=ENCRYPT(state0,state1,state2,state3);
u32 nextState1=ENCRYPT(state1,state2,state3,state0);
u32 nextState2=ENCRYPT(state2,state3,state0,state1);
u32 nextState3=ENCRYPT(state3,state0,state1,state2);
state0=nextState0^key[0]; state1=nextState1^key[1]; state2=nextState2^key[2]; state3=nextState3^key[3];
key += 4;
}
output[0] = SUBSTITUTE(AESiSubShiftTable,a,b,c,d)^key[0];
output[1] = SUBSTITUTE(AESiSubShiftTable,b,c,d,a)^key[1];
output[2] = SUBSTITUTE(AESiSubShiftTable,c,d,a,b)^key[2];
output[3] = SUBSTITUTE(AESiSubShiftTable,d,a,b,c)^key[3];
output[0] = SUBSTITUTE(AESiSubShiftTable,state0,state1,state2,state3)^key[0];
output[1] = SUBSTITUTE(AESiSubShiftTable,state1,state2,state3,state0)^key[1];
output[2] = SUBSTITUTE(AESiSubShiftTable,state2,state3,state0,state1)^key[2];
output[3] = SUBSTITUTE(AESiSubShiftTable,state3,state0,state1,state2)^key[3];
}
#define DOUBLE_BYTES(x) ((((x)&0x7f7f7f7f)<<1) ^ ((((x)&0x80808080)>>7)*0x1b))
@@ -198,10 +198,10 @@ 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;
u32 b;
u32 a;
u32 c;
u32 d;
u32 state1;
u32 state0;
u32 state2;
u32 state3;
key += rounds*4;
if (context->needsTransform) {
u32 round;
@@ -209,31 +209,31 @@ void AESiDecryptBlock(AESContext* context, u32* output, const u32* input) {
u32 word;
for (word=0; word<4; ++word) {
u32 value=context->keys[round*4 + word];
u32 twice=DOUBLE_BYTES(value);
u32 four=DOUBLE_BYTES(twice);
u32 eight=DOUBLE_BYTES(four)^value;
u32 mixed=(ROTATE(eight,8) ^ (eight ^ four));
mixed=(ROTATE(mixed,8) ^ (mixed ^ twice));
u32 timesTwo=DOUBLE_BYTES(value);
u32 timesFour=DOUBLE_BYTES(timesTwo);
u32 timesNine=DOUBLE_BYTES(timesFour)^value;
u32 mixed=(ROTATE(timesNine,8) ^ (timesNine ^ timesFour));
mixed=(ROTATE(mixed,8) ^ (mixed ^ timesTwo));
mixed=(ROTATE(mixed,8) ^ (mixed ^ value));
context->keys[round*4 + word]=mixed;
}
}
context->needsTransform=0;
}
a=input[0]^key[0]; b=input[1]^key[1]; c=input[2]^key[2]; d=input[3]^key[3];
state0=input[0]^key[0]; state1=input[1]^key[1]; state2=input[2]^key[2]; state3=input[3]^key[3];
key-=4;
while (--rounds != 0) {
u32 nextA=DECRYPT(a,d,c,b);
u32 nextB=DECRYPT(b,a,d,c);
u32 nextC=DECRYPT(c,b,a,d);
u32 nextD=DECRYPT(d,c,b,a);
a=nextA^key[0]; b=nextB^key[1]; c=nextC^key[2]; d=nextD^key[3];
u32 nextState0=DECRYPT(state0,state3,state2,state1);
u32 nextState1=DECRYPT(state1,state0,state3,state2);
u32 nextState2=DECRYPT(state2,state1,state0,state3);
u32 nextState3=DECRYPT(state3,state2,state1,state0);
state0=nextState0^key[0]; state1=nextState1^key[1]; state2=nextState2^key[2]; state3=nextState3^key[3];
key-=4;
}
output[0]=DECRYPT_FINAL(AESiInvSubShiftTable,a,d,c,b,key[0]);
output[1]=DECRYPT_FINAL(AESiInvSubShiftTable,b,a,d,c,key[1]);
output[2]=DECRYPT_FINAL(AESiInvSubShiftTable,c,b,a,d,key[2]);
output[3]=DECRYPT_FINAL(AESiInvSubShiftTable,d,c,b,a,key[3]);
output[0]=DECRYPT_FINAL(AESiInvSubShiftTable,state0,state3,state2,state1,key[0]);
output[1]=DECRYPT_FINAL(AESiInvSubShiftTable,state1,state0,state3,state2,key[1]);
output[2]=DECRYPT_FINAL(AESiInvSubShiftTable,state2,state1,state0,state3,key[2]);
output[3]=DECRYPT_FINAL(AESiInvSubShiftTable,state3,state2,state1,state0,key[3]);
}
BOOL NETAESCreateEx(AESContext* context, const void* key, u32 keyLength, const void* iv, const AESBlockMode* mode) {
@@ -248,7 +248,7 @@ BOOL NETAESCreateEx(AESContext* context, const void* key, u32 keyLength, const v
context->needsTransform = 1;
context->rounds = (keyLength * 8) / 32 + 6;
context->mode = mode;
memcpy(context->chain, iv, 16);
memcpy(context->chain, iv, sizeof(context->chain));
schedule = context->keys;
words = keyLength / 4;
memcpy(schedule, key, keyLength);
@@ -326,8 +326,8 @@ static void NETiAESEncryptoBlock(AESContext* context, u32* output, const u32* in
}
static void NETiAESDecryptoBlock(AESContext* context, u32* output, const u32* input) {
u32 a=context->chain[0], b=context->chain[1], c=context->chain[2], d=context->chain[3];
u32 state0=context->chain[0], state1=context->chain[1], state2=context->chain[2], state3=context->chain[3];
context->chain[0]=input[0]; context->chain[1]=input[1]; context->chain[2]=input[2]; context->chain[3]=input[3];
AESiDecryptBlock(context,output,input);
output[0]^=a; output[1]^=b; output[2]^=c; output[3]^=d;
output[0]^=state0; output[1]^=state1; output[2]^=state2; output[3]^=state3;
}

View File

@@ -4,26 +4,26 @@ void* NHTTPi_memcpy(void*, const void*, u32);
s32 NHTTPi_SocRecv(void*, NHTTPRequestInfo*, s32, void*, s32, s32);
static void FindHeaderBlock(const NHTTPResponseInfo* response, s32 position, NHTTPi_HDRBUFLIST** block, s32* offset) {
if(position<1024) { *offset=position; *block=NULL; }
if(position<NHTTP_HDRRECVBUF_INILEN) { *offset=position; *block=NULL; }
else {
s32 blocks=(position-1024)>>9;
s32 blocks=(position-NHTTP_HDRRECVBUF_INILEN)>>NHTTP_HDRRECVBUF_BLOCKSHIFT;
*block=response->hdrBufBlock_p;
while(blocks--) *block=(*block)->next_p;
*offset=(position-1024)&511;
*offset=(position-NHTTP_HDRRECVBUF_INILEN)&NHTTP_HDRRECVBUF_BLOCKMASK;
}
}
static int ReadHeaderChar(const NHTTPResponseInfo* response, NHTTPi_HDRBUFLIST** block, s32* offset) {
if(!*block) {
if(*offset<1024) return (s8)response->hdrBufFirst[(*offset)++];
if(*offset<NHTTP_HDRRECVBUF_INILEN) return (s8)response->hdrBufFirst[(*offset)++];
*block=response->hdrBufBlock_p;
*offset=0;
} else if(*offset==512) { *offset=0; *block=(*block)->next_p; }
} else if(*offset==NHTTP_HDRRECVBUF_BLOCKLEN) { *offset=0; *block=(*block)->next_p; }
return (*block)->block[(*offset)++];
}
static int LowerCase(int character) {
return ((character >= 'A') & (character <= 'Z')) ? character + 32 : character;
return ((character >= 'A') & (character <= 'Z')) ? character + ('a' - 'A') : character;
}
s32 NHTTPi_findNextLineHdrRecvBuf(const NHTTPResponseInfo* response, s32 position, s32 limit, s32* colon, s32* newlineLength) {
@@ -96,25 +96,25 @@ s32 NHTTPi_loadFromHdrRecvBuf(NHTTPResponseInfo* response, char* destination, s3
NHTTPi_HDRBUFLIST* block;
if (position + length <= response->headerLen) {
if(length) {
if(position<1024) {
if(position<NHTTP_HDRRECVBUF_INILEN) {
amount=length;
if(length>1024-position) amount=1024-position;
if(length>NHTTP_HDRRECVBUF_INILEN-position) amount=NHTTP_HDRRECVBUF_INILEN-position;
NHTTPi_memcpy(destination,response->hdrBufFirst+position,amount);
position+=amount; length-=amount; destination+=amount;
}
if(length) {
s32 blocks;
position-=1024;
position-=NHTTP_HDRRECVBUF_INILEN;
block=response->hdrBufBlock_p;
blocks=position>>9;
position&=511;
blocks=position>>NHTTP_HDRRECVBUF_BLOCKSHIFT;
position&=NHTTP_HDRRECVBUF_BLOCKMASK;
while(blocks--) block=block->next_p;
while(length) {
amount=length;
if(length>512-position) amount=512-position;
if(length>NHTTP_HDRRECVBUF_BLOCKLEN-position) amount=NHTTP_HDRRECVBUF_BLOCKLEN-position;
NHTTPi_memcpy(destination,block->block+position,amount);
position+=amount;
position&=511;
position&=NHTTP_HDRRECVBUF_BLOCKMASK;
block=block->next_p;
length-=amount; destination+=amount;
}
@@ -135,12 +135,12 @@ s32 NHTTPi_RecvBuf(void* mutex, NHTTPRequestInfo* request, s32 socket, u32 offse
s32 NHTTPi_RecvBufN(void* mutex, NHTTPRequestInfo* request, s32 socket, u32 offset, s32 length, s32 flags) {
s32 available;
NHTTPResponseInfo* response=request->response;
void* buf;
void* receiveCursor;
if(response->recvBufLen<=offset) return -1003;
available=response->recvBufLen;
buf=response->recvBuf_p;
receiveCursor=response->recvBuf_p;
available=available-offset;
buf=(u8*)buf+offset;
receiveCursor=(u8*)receiveCursor+offset;
if(length>available) length=available;
return NHTTPi_SocRecv(mutex,request,socket,buf,length,flags);
return NHTTPi_SocRecv(mutex,request,socket,receiveCursor,length,flags);
}

View File

@@ -73,7 +73,7 @@ void BS2UpdateInit(void* allocator) {
memset(Flags1, 0, sizeof(Flags1));
BS2Report("Create update thread\n");
OSCreateThread(&Thread, UpdateThread, NULL, ThreadStack + sizeof(ThreadStack),
sizeof(ThreadStack), 31, 1);
sizeof(ThreadStack), 31, OS_THREAD_ATTR_DETACH);
OSResumeThread(&Thread);
}
@@ -113,37 +113,37 @@ static inline u32 BS2SelectUpdateEntries(void) {
selectedSeatCount = 0;
State = 0;
ContainsSeatTitles = FALSE;
if (ES_GetTitleId(&scratch.titleId) != 0) {
if (ES_GetTitleId(&scratch.titleId) != ES_ERR_OK) {
regionValid = FALSE;
} else {
titleRegion = (u8)scratch.titleId;
switch (SCGetProductArea()) {
case 0:
case 5:
case SC_PRODUCT_AREA_JPN:
case SC_PRODUCT_AREA_TWN:
if (titleRegion == 'J' || titleRegion == 'D') {
regionValid = TRUE;
goto product_region_checked;
}
goto invalid_product_region;
case 1:
case SC_PRODUCT_AREA_USA:
if (titleRegion == 'E' || titleRegion == 'D') {
regionValid = TRUE;
goto product_region_checked;
}
goto invalid_product_region;
case 2:
case SC_PRODUCT_AREA_EUR:
if (titleRegion == 'P' || titleRegion == 'D') {
regionValid = TRUE;
goto product_region_checked;
}
goto invalid_product_region;
case 6:
case SC_PRODUCT_AREA_KOR:
if (titleRegion == 'K') {
regionValid = TRUE;
goto product_region_checked;
}
goto invalid_product_region;
case 11:
case SC_PRODUCT_AREA_CHN:
if (titleRegion == 'C') {
regionValid = TRUE;
goto product_region_checked;
@@ -347,7 +347,7 @@ product_region_checked:
if (seatEntries[index].type != 7) {
continue;
}
if (ES_GetTicketViews(seatEntries[index].titleId, NULL, &scratch.ticketCount) != 0) {
if (ES_GetTicketViews(seatEntries[index].titleId, NULL, &scratch.ticketCount) != ES_ERR_OK) {
BS2Report("Faild to get eTicket views.\n");
continue;
}
@@ -378,7 +378,7 @@ product_region_checked:
BS2Report("Error: cannot get channel count.");
goto seats_done;
}
if (NANDSecretGetUserAvailableArea(&scratch.freeBlocks, &scratch.freeInodes) != 0) {
if (NANDSecretGetUserAvailableArea(&scratch.freeBlocks, &scratch.freeInodes) != NAND_RESULT_OK) {
BS2Report("Error: cannot get free user blocks.");
goto seats_done;
}

View File

@@ -150,15 +150,15 @@ namespace www {
extern const char* strProps[FORM_ID_MAX];
int getStringPropertyIdx(const char* targetStr) {
const char* names[ARRAY_LENGTH(strProps)];
const char** __pDst = names - 1;
const char* const* __pSrc = strProps - 1;
const char** destinationName = names - 1;
const char* const* sourceName = strProps - 1;
for (int i = 0; i < (ARRAY_LENGTH(names) >> 1); i++) {
*(++__pDst) = *(++__pSrc);
*(++__pDst) = *(++__pSrc);
*(++destinationName) = *(++sourceName);
*(++destinationName) = *(++sourceName);
}
if (ARRAY_LENGTH(names) & 1) {
*(++__pDst) = *(++__pSrc);
*(++destinationName) = *(++sourceName);
}
for (int i = 0; i < (int)ARRAY_LENGTH(names) >> 1 << 1; i++) {
@@ -704,7 +704,7 @@ namespace www {
break;
}
case WB_ID_COUNTRY_SAVE: {
sWiiData.data[0x3C] = ipl::parental::Parental::getCountry();
sWiiData.data[WB_ID_COUNTRY] = ipl::parental::Parental::getCountry();
break;
}
case WB_ID_FLUSH: {
@@ -933,11 +933,11 @@ namespace www {
int getBytePropIndex(const char* targetStr) {
const char* names[ARRAY_LENGTH(byteProps)];
const char** __pDst = names - 1;
const char* const* __pSrc = byteProps - 1;
const char** destinationName = names - 1;
const char* const* sourceName = byteProps - 1;
for (int i = 0; i < (ARRAY_LENGTH(names) >> 1); i++) {
*(++__pDst) = *(++__pSrc);
*(++__pDst) = *(++__pSrc);
*(++destinationName) = *(++sourceName);
*(++destinationName) = *(++sourceName);
}
for (int i = 0; i < (int)ARRAY_LENGTH(names); i++) {

View File

@@ -147,37 +147,37 @@ namespace textinput {
mpPaneManager->setAllBoundingBoxComponentTriggerTarget(true);
for (u16 i = 0; i < ARRAY_LENGTH(csPaneToAnimation); i++) {
const PaneToAnimation& p = csPaneToAnimation[i];
const PaneToAnimation& paneAnimations = csPaneToAnimation[i];
AnmPane* pane = NULL;
switch (p.type) {
switch (paneAnimations.type) {
case KT_Whole: {
void* pBtnBuf = MEMAllocFromAllocator(allocator, sizeof(WholeAnmPane));
pane = new (pBtnBuf) WholeAnmPane(getPane(p.paneName), this);
pane = new (pBtnBuf) WholeAnmPane(getPane(paneAnimations.paneName), this);
break;
}
case KT_NormalButton: {
void* pBtnBuf = MEMAllocFromAllocator(allocator, sizeof(NormalButtonAnmPane));
pane = new (pBtnBuf) NormalButtonAnmPane(getPane(p.paneName), NULL);
pane = new (pBtnBuf) NormalButtonAnmPane(getPane(paneAnimations.paneName), NULL);
break;
}
case KT_ChangeButton: {
void* pBtnBuf = MEMAllocFromAllocator(allocator, sizeof(ChangeButtonAnmPane));
pane = new (pBtnBuf) ChangeButtonAnmPane(getPane(p.paneName), NULL, this);
pane = new (pBtnBuf) ChangeButtonAnmPane(getPane(paneAnimations.paneName), NULL, this);
break;
}
}
nw4r::ut::List_Append(&mAnmPanes, pane);
for (u16 j = 0; j < p.count; j++) {
void* pResource = mpMultiArcResourceAccessor->GetResource(0, p.pAnims[j]->fileName);
for (u16 j = 0; j < paneAnimations.count; j++) {
void* pResource = mpMultiArcResourceAccessor->GetResource(0, paneAnimations.pAnims[j]->fileName);
AnimTransformPane* transform =
static_cast<AnimTransformPane*>(getLayout()->CreateAnimTransform(pResource, mpMultiArcResourceAccessor));
if (p.forceAddName == NULL) {
pane->addAnimation(allocator, p.pAnims[j]->id, transform, false, true);
if (paneAnimations.forceAddName == NULL) {
pane->addAnimation(allocator, paneAnimations.pAnims[j]->id, transform, false, true);
} else {
pane->forceAddAnimation(allocator, p.pAnims[j]->id, transform, p.forceAddName, false, true);
pane->forceAddAnimation(allocator, paneAnimations.pAnims[j]->id, transform, paneAnimations.forceAddName, false, true);
}
}
}
@@ -374,7 +374,7 @@ namespace textinput {
if (pane != NULL) {
switch (event) {
case ON_TRIG: {
if ((input->trigger & 0x800)) {
if ((input->trigger & WPAD_BUTTON_A)) {
pane->onAnmEvent(nw4rmanager::AnmPane::PE_0);
}
break;
@@ -391,7 +391,7 @@ namespace textinput {
}
}
if (event == ON_TRIG && (input->trigger & 0x800)) {
if (event == ON_TRIG && (input->trigger & WPAD_BUTTON_A)) {
char paneName[17];
// open-coded util::replaceChar
memset(paneName, 0, 17);

View File

@@ -242,16 +242,16 @@ void Decolated::inputString(const wchar_t* string) {
void Decolated::inputString(const wchar_t* string, TranslateMode mode) {
TranslateMode oldMode = static_cast<TranslateMode>(mTranslateMode);
if (oldMode != mode) {
if (!isKanaFix() && mode == 0) {
if (!isKanaFix() && mode == TM_Direct) {
confirmKana();
}
mTranslateMode = mode;
switch (mode) {
case 1:
mKanaStream.mQueue.mode = static_cast<KPRMode>(4);
case TM_Kana:
mKanaStream.mQueue.mode = KPR_MODE_JP_ROMAJI_HIRAGANA;
break;
case 2:
mKanaStream.mQueue.mode = static_cast<KPRMode>(8);
case TM_Roman:
mKanaStream.mQueue.mode = KPR_MODE_JP_ROMAJI_KATAKANA;
break;
default:
break;
@@ -259,16 +259,16 @@ void Decolated::inputString(const wchar_t* string, TranslateMode mode) {
}
inputString(string);
if (mTranslateMode != oldMode) {
if (!isKanaFix() && oldMode == 0) {
if (!isKanaFix() && oldMode == TM_Direct) {
confirmKana();
}
mTranslateMode = oldMode;
switch (oldMode) {
case 1:
mKanaStream.mQueue.mode = static_cast<KPRMode>(4);
case TM_Kana:
mKanaStream.mQueue.mode = KPR_MODE_JP_ROMAJI_HIRAGANA;
break;
case 2:
mKanaStream.mQueue.mode = static_cast<KPRMode>(8);
case TM_Roman:
mKanaStream.mQueue.mode = KPR_MODE_JP_ROMAJI_KATAKANA;
break;
default:
break;
@@ -457,9 +457,9 @@ bool Decolated::atTheBeginningOfASentence() {
}
s32 ch = getWCharAtCursor();
switch (ch) {
case 0x2e:
case 0x21:
case 0x3f:
case L'.':
case L'!':
case L'?':
return true;
default:
return false;
@@ -468,16 +468,16 @@ bool Decolated::atTheBeginningOfASentence() {
void Decolated::setTranslateMode(TranslateMode mode) {
if (mTranslateMode != mode) {
if (!isKanaFix() && mode == 0) {
if (!isKanaFix() && mode == TM_Direct) {
confirmKana();
}
mTranslateMode = mode;
switch (mode) {
case 1:
mKanaStream.mQueue.mode = static_cast<KPRMode>(4);
case TM_Kana:
mKanaStream.mQueue.mode = KPR_MODE_JP_ROMAJI_HIRAGANA;
break;
case 2:
mKanaStream.mQueue.mode = static_cast<KPRMode>(8);
case TM_Roman:
mKanaStream.mQueue.mode = KPR_MODE_JP_ROMAJI_KATAKANA;
break;
default:
break;
@@ -487,15 +487,15 @@ void Decolated::setTranslateMode(TranslateMode mode) {
void Decolated::initKanaConverter() {
KPRInitQueue(&mKanaStream.mQueue);
KPRSetMode(&mKanaStream.mQueue, 0);
KPRSetMode(&mKanaStream.mQueue, KPR_MODE_NONE);
mKanaStream.mOutput[0] = 0;
s32 mode = mTranslateMode;
switch (mode) {
case 1:
mKanaStream.mQueue.mode = static_cast<KPRMode>(4);
case TM_Kana:
mKanaStream.mQueue.mode = KPR_MODE_JP_ROMAJI_HIRAGANA;
break;
case 2:
mKanaStream.mQueue.mode = static_cast<KPRMode>(8);
case TM_Roman:
mKanaStream.mQueue.mode = KPR_MODE_JP_ROMAJI_KATAKANA;
break;
default:
break;

View File

@@ -45,24 +45,24 @@ namespace textinput {
"P_BT_cancel",
5,
NULL,
{&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[4]}},
{&csAninationFile[ANM_Normal], &csAninationFile[ANM_FocusIn], &csAninationFile[ANM_FocusOut], &csAninationFile[ANM_RollOver], &csAninationFile[ANM_Pushed]}},
{KT_NormalButton,
"P_BT_confirm",
5,
COMMON_BUTTON_ANIM,
{&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[4]}},
{&csAninationFile[ANM_Normal], &csAninationFile[ANM_FocusIn], &csAninationFile[ANM_FocusOut], &csAninationFile[ANM_RollOver], &csAninationFile[ANM_Pushed]}},
{KT_ToggleButton,
"P_kyChng_QWERTY",
7,
NULL,
{&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[4], &csAninationFile[5],
&csAninationFile[6], &csAninationFile[7]}},
{&csAninationFile[ANM_Normal], &csAninationFile[ANM_FocusIn], &csAninationFile[ANM_FocusOut], &csAninationFile[ANM_RollOver], &csAninationFile[ANM_Pushed], &csAninationFile[ANM_ToggleOn],
&csAninationFile[ANM_ToggleOff], &csAninationFile[7]}},
{KT_ToggleButton,
"P_kyChng_CP",
7,
COMMON_CHG_ANIM,
{&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3], &csAninationFile[4], &csAninationFile[5],
&csAninationFile[6], &csAninationFile[7]}},
{&csAninationFile[ANM_Normal], &csAninationFile[ANM_FocusIn], &csAninationFile[ANM_FocusOut], &csAninationFile[ANM_RollOver], &csAninationFile[ANM_Pushed], &csAninationFile[ANM_ToggleOn],
&csAninationFile[ANM_ToggleOff], &csAninationFile[7]}},
};
void Base::setQwerty(bool qwerty) {
@@ -95,32 +95,32 @@ namespace textinput {
mpPaneManager->setAllBoundingBoxComponentTriggerTarget(true);
for (u16 i = 0; i < ARRAY_LENGTH(csPaneToAnimation); i++) {
const PaneToAnimation& p = csPaneToAnimation[i];
const PaneToAnimation& paneAnimations = csPaneToAnimation[i];
AnmPane* pane = NULL;
switch (p.type) {
switch (paneAnimations.type) {
case KT_NormalButton: {
void* pBtnBuf = MEMAllocFromAllocator(allocator, sizeof(NormalButtonAnmPane));
pane = new (pBtnBuf) NormalButtonAnmPane(getPane(p.paneName), NULL);
pane = new (pBtnBuf) NormalButtonAnmPane(getPane(paneAnimations.paneName), NULL);
break;
}
case KT_ToggleButton: {
void* pBtnBuf = MEMAllocFromAllocator(allocator, sizeof(ToggleButtonAnmPane));
pane = new (pBtnBuf) ToggleButtonAnmPane(getPane(p.paneName), NULL);
pane = new (pBtnBuf) ToggleButtonAnmPane(getPane(paneAnimations.paneName), NULL);
break;
}
}
nw4r::ut::List_Append(&mAnmPanes, pane);
for (u16 j = 0; j < p.count; j++) {
void* pResource = mpMultiArcResourceAccessor->GetResource(0, p.pAnims[j]->fileName);
for (u16 j = 0; j < paneAnimations.count; j++) {
void* pResource = mpMultiArcResourceAccessor->GetResource(0, paneAnimations.pAnims[j]->fileName);
AnimTransformPane* transform =
static_cast<AnimTransformPane*>(getLayout()->CreateAnimTransform(pResource, mpMultiArcResourceAccessor));
if (p.forceAddName == NULL) {
pane->addAnimation(allocator, p.pAnims[j]->id, transform, false, true);
if (paneAnimations.forceAddName == NULL) {
pane->addAnimation(allocator, paneAnimations.pAnims[j]->id, transform, false, true);
} else {
pane->forceAddAnimation(allocator, p.pAnims[j]->id, transform, p.forceAddName, false, true);
pane->forceAddAnimation(allocator, paneAnimations.pAnims[j]->id, transform, paneAnimations.forceAddName, false, true);
}
}
}
@@ -383,7 +383,7 @@ namespace textinput {
if (pane != NULL) {
switch (event) {
case ON_TRIG: {
if ((input->trigger & 0x800)) {
if ((input->trigger & WPAD_BUTTON_A)) {
pane->onAnmEvent(nw4rmanager::AnmPane::PE_0);
}
break;
@@ -400,19 +400,19 @@ namespace textinput {
}
}
}
if (event == ON_TRIG && (input->trigger & 0x800)) {
if (event == ON_TRIG && (input->trigger & WPAD_BUTTON_A)) {
if (util::strcmp(paneName, "P_BT_confirm")) {
mpLayoutByNW4R->onOK();
} else if (util::strcmp(paneName, "P_BT_cancel")) {
mpLayoutByNW4R->onCancel();
} else if (util::strcmp(paneName, "P_kyChng_QWERTY")) {
if (!mpLayoutByNW4R->isQwerty()) {
mpLayoutByNW4R->searchAnmPane("P_kyChng_CP")->changeAnimation(6);
mpLayoutByNW4R->searchAnmPane("P_kyChng_CP")->changeAnimation(ANM_ToggleOff);
}
mpLayoutByNW4R->setQwertyWithSE(true);
} else if (util::strcmp(paneName, "P_kyChng_CP")) {
if (mpLayoutByNW4R->isQwerty()) {
mpLayoutByNW4R->searchAnmPane("P_kyChng_QWERTY")->changeAnimation(6);
mpLayoutByNW4R->searchAnmPane("P_kyChng_QWERTY")->changeAnimation(ANM_ToggleOff);
}
mpLayoutByNW4R->setQwertyWithSE(false);
}

View File

@@ -61,7 +61,7 @@ void WithZi::ChangeDictionaryLanguage(u8 language) {
u32 attached;
entryIndex = -1;
baseIndex = 0;
dictionaryTable = (EZTXLanguageEntry*)mpDictionaries;
dictionaryTable = mpDictionaries;
entry = dictionaryTable;
for (s32 groups = 2; groups != 0; --groups) {
for (s32 column = 0; column < 6; ++column) {
@@ -104,8 +104,8 @@ void WithZi::init() {
mbContextChanged = 0;
clearCandidates();
memset(LatestWord, 0, 0x80);
LatestWord[0] = 0x20;
if (getPredictLanguage() == 1) {
LatestWord[0] = L' ';
if (getPredictLanguage() == ZI8_LANG_ZH) {
update();
}
}
@@ -132,7 +132,7 @@ void WithZi::clearCandidates() {
mSearch.maxCandidates = 0x28;
mSearch.elementCount = 0;
mSearch.firstCandidate = 0;
if (getPredictLanguage() == 1) {
if (getPredictLanguage() == ZI8_LANG_ZH) {
mSearch.getMode = 1;
mSearch.context = 0x10;
}
@@ -319,7 +319,7 @@ void WithZi::update() {
mSearch.completion = 0;
mSearch.scratch = 0;
if (getPredictLanguage() == 1) {
if (getPredictLanguage() == ZI8_LANG_ZH) {
mSearch.getMode = 1;
mSearch.context = 0x11;
if (mbKoreanPartialConfirm != 0) {
@@ -335,8 +335,8 @@ void WithZi::update() {
}
else if (elementCount == 1 &&
(0xeff1 <= ElementBuffer[0] && ElementBuffer[0] <= 0xeff9) &&
mpHoldingKey != NULL && getPredictLanguage() != 0x12) {
CandidatedWord[0] = 0x3e;
mpHoldingKey != NULL && getPredictLanguage() != ZI8_LANG_KO) {
CandidatedWord[0] = L'>';
CandidatedWord[1] = 0;
mCandidateCount = 1;
u16* output = CandidatedWord + 0x40;
@@ -355,7 +355,7 @@ void WithZi::update() {
memcpy(PredictionBuffer, CandidatesBuffer, 0x200);
ChangeDictionaryLanguage(getPredictLanguage());
u32 count = EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff;
if (getPredictLanguage() == 1 && count == 0x61) {
if (getPredictLanguage() == ZI8_LANG_ZH && count == 0x61) {
wchar_t* candidateOutput = reinterpret_cast<wchar_t*>(PredictionBuffer);
mSearch.firstCandidate = 0x61;
mSearch.candidates = candidateOutput + 0xC2;
@@ -367,7 +367,7 @@ void WithZi::update() {
if (static_cast<s32>(count) > 0x28) {
count = 0x28;
}
if (getPredictLanguage() == 1 && mbContextChanged != 0 &&
if (getPredictLanguage() == ZI8_LANG_ZH && mbContextChanged != 0 &&
(mbContextChanged = 0, mSearch.count == 0)) {
u32 length = mCurrentWordLength;
u32 wordLength = wcslen((wchar_t*)LatestWord) & 0xff;
@@ -380,8 +380,8 @@ void WithZi::update() {
count = EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff;
}
if (count == 0) {
if (getPredictLanguage() != 1) {
if (getPredictLanguage() == 0x12) {
if (getPredictLanguage() != ZI8_LANG_ZH) {
if (getPredictLanguage() == ZI8_LANG_KO) {
backSpace();
return;
}
@@ -395,12 +395,12 @@ void WithZi::update() {
u16* source = reinterpret_cast<u16*>(mSearch.candidates);
u16* destination = CandidatedWord;
for (s32 index = 0; index < static_cast<s32>(count); index++) {
if (getPredictLanguage() == 1) {
if (getPredictLanguage() == ZI8_LANG_ZH) {
u16* output;
s32 length;
length = 0;
output = destination;
for (; *source != 0x20 && *source != 0; source++) {
for (; *source != L' ' && *source != 0; source++) {
*output++ = *source;
++length;
}
@@ -409,7 +409,7 @@ void WithZi::update() {
} else if (mPredictLanguage == PL_11) {
*destination = *source++;
destination[1] = 0;
} else if (getPredictLanguage() == 0x12) {
} else if (getPredictLanguage() == ZI8_LANG_KO) {
u16* output = destination;
u16 character;
while ((character = *source) >= 0x100) {
@@ -535,10 +535,10 @@ u32 WithZi::setElementBuffer() {
while ((inputCharacter = buffers.read(static_cast<u16>(count))) != 0 && static_cast<u16>(count) < 0xff) {
u16 index = count;
buffers.element(index) = inputCharacter;
if (getPredictLanguage() == 1) {
if (getPredictLanguage() == ZI8_LANG_ZH) {
s32 character = buffers.element(index);
if (0x30 <= character && character <= 0x39) buffers.element(index) = character + 0xf300;
else if ((0x61 <= character && character <= 0x7a) || (0x41 <= character && character <= 0x5a)) buffers.element(index) += 0xf300;
if (L'0' <= character && character <= L'9') buffers.element(index) = character + 0xf300;
else if ((L'a' <= character && character <= L'z') || (L'A' <= character && character <= L'Z')) buffers.element(index) += 0xf300;
}
++count;
}
@@ -569,7 +569,7 @@ u8 WithZi::getPredictLanguage() {
void WithZi::setCurrentWord(const wchar_t* word) {
if (word == NULL) {
LatestWord[0] = 0x20;
LatestWord[0] = L' ';
LatestWord[1] = 0;
return;
}
@@ -580,7 +580,7 @@ void WithZi::setCurrentWord(const wchar_t* word) {
mbContextChanged = 1;
length = 0;
currentWord = reinterpret_cast<wchar_t*>(LatestWord);
for (; *currentWord != 0 && *currentWord != 0x20;
for (; *currentWord != 0 && *currentWord != L' ';
currentWord++, ++length) {
if (length == 0x3f) {
LatestWord[length] = 0;

View File

@@ -1981,11 +1981,11 @@ namespace ipl {
}
void FriendListCache::swap(u32 index1, u32 index2) {
NWC24FriendInfo temp ATTRIBUTE_ALIGN(32);
NWC24FriendInfo savedFriend ATTRIBUTE_ALIGN(32);
memcpy(&temp, &mInfos[index1], sizeof(NWC24FriendInfo));
memcpy(&savedFriend, &mInfos[index1], sizeof(NWC24FriendInfo));
memcpy(&mInfos[index1], &mInfos[index2], sizeof(NWC24FriendInfo));
memcpy(&mInfos[index2], &temp, sizeof(NWC24FriendInfo));
memcpy(&mInfos[index2], &savedFriend, sizeof(NWC24FriendInfo));
u8 bThere = mbThere[index1];
mbThere[index1] = mbThere[index2];
@@ -2026,10 +2026,10 @@ namespace ipl {
manager->initMsgObj(&msgObj, NWC24_MSGTYPE_PUBLIC);
manager->setMsgToAddr(&msgObj, info.addr.mailAddr, strlen(info.addr.mailAddr));
const wchar_t* subject = System::getMessage(385);
const wchar_t* subject = System::getMessage(MESG_FRIEND_CACHE_EMAIL_TITLE);
wchar_t text[0x400];
wcscpy(text, System::getMessage(386));
wcscpy(text, System::getMessage(MESG_FRIEND_CACHE_EMAIL_BODY));
if (mMyUserId != 1234567890123456ULL) {
wchar_t idStr[17];

File diff suppressed because it is too large Load Diff

View File

@@ -13,7 +13,7 @@ namespace memorycard {
struct CardThreadState {
CardState slots[2];
FileInfo files[2][127];
FileInfo files[2][CARD_MAX_FILE];
void* mountBuffers[2];
s32 mounted[2];
OSMessageQueue responses;
@@ -26,9 +26,9 @@ struct CardThreadState {
CARDFileInfo sourceFile;
CARDFileInfo destinationFile;
void* transferBuffer;
IconState icons[2][127];
u8* images[2][127];
char* comments[2][127];
IconState icons[2][CARD_MAX_FILE];
u8* images[2][CARD_MAX_FILE];
char* comments[2][CARD_MAX_FILE];
u8 commentBuffer[0x400] ATTRIBUTE_ALIGN(32);
u8* imageReadBuffer;
s32 lastCommand;
@@ -150,31 +150,31 @@ done:
extern "C" s32 mapCardErrorCode(s32 result) {
switch (result) {
case 0:
case CARD_RESULT_READY:
return 0;
case -2:
case CARD_RESULT_WRONGDEVICE:
return -28;
case -3:
case CARD_RESULT_NOCARD:
return -28;
case -4:
case CARD_RESULT_NOFILE:
return -28;
case -5:
case CARD_RESULT_IOERROR:
return -28;
case -6:
case CARD_RESULT_BROKEN:
return -28;
case -7:
case CARD_RESULT_EXIST:
return -24;
case -8:
case CARD_RESULT_NOENT:
return -25;
case -9:
case CARD_RESULT_INSSPACE:
return -25;
case -10:
case CARD_RESULT_NOPERM:
return -28;
case -11:
case CARD_RESULT_LIMIT:
return -28;
case -12:
case CARD_RESULT_NAMETOOLONG:
return -28;
case -13:
case CARD_RESULT_ENCODING:
return -28;
case -27:
return -27;
@@ -212,34 +212,34 @@ checkCommand:
switch ((s8)(((u32)message << 16) >> 24)) {
case -27:
case -7:
case 0:
case CARD_RESULT_EXIST:
case CARD_RESULT_READY:
OSReport("ready or exit\n");
sThread->slots[slot].state = 4;
break;
case -9:
case -8:
case CARD_RESULT_INSSPACE:
case CARD_RESULT_NOENT:
OSReport("Card hasn't enough space\n");
sThread->slots[slot].state = 4;
break;
case -2:
case CARD_RESULT_WRONGDEVICE:
OSReport("Wrong Device\n");
sThread->slots[slot].state = 5;
break;
case -6:
case CARD_RESULT_BROKEN:
OSReport("Broken Card\n");
sThread->slots[slot].state = 6;
break;
case -13:
case CARD_RESULT_ENCODING:
OSReport("Other Language\n");
sThread->slots[slot].state = 8;
break;
case -3:
case CARD_RESULT_NOCARD:
OSReport("Detach Card\n");
sThread->slots[slot].state = 0;
@@ -281,23 +281,23 @@ void initCardThread() {
MEMInitAllocatorForExpHeap(&sAllocator_, handle, 32);
sAllocator_.heapParam2 = (u32)memory;
OSReport("HEAP CREATE: %p %d\n", memory, size);
sThread = (CardThreadState*)MEMAllocFromAllocator(&sAllocator_, sizeof(CardThreadState));
sThread = static_cast<CardThreadState*>(MEMAllocFromAllocator(&sAllocator_, sizeof(CardThreadState)));
memset(sThread, 0, sizeof(CardThreadState));
sThread->images[0][0] = (u8*)MEMAllocFromAllocator(&sAllocator_, 0x594C00);
sThread->comments[0][0] = (char*)MEMAllocFromAllocator(&sAllocator_, 0x3F80);
sThread->imageReadBuffer = (u8*)MEMAllocFromAllocator(&sAllocator_, 0x5A00);
sThread->images[0][0] = static_cast<u8*>(MEMAllocFromAllocator(&sAllocator_, 0x594C00));
sThread->comments[0][0] = static_cast<char*>(MEMAllocFromAllocator(&sAllocator_, 0x3F80));
sThread->imageReadBuffer = static_cast<u8*>(MEMAllocFromAllocator(&sAllocator_, 0x5A00));
sThread->transferBuffer = MEMAllocFromAllocator(&sAllocator_, 0x40000);
sThread->mountBuffers[0] = MEMAllocFromAllocator(&sAllocator_, 0xA000);
sThread->mountBuffers[1] = MEMAllocFromAllocator(&sAllocator_, 0xA000);
sThread->mountBuffers[0] = MEMAllocFromAllocator(&sAllocator_, CARD_WORKAREA_SIZE);
sThread->mountBuffers[1] = MEMAllocFromAllocator(&sAllocator_, CARD_WORKAREA_SIZE);
}
for (index = 0; index < 127; index++) {
for (index = 0; index < CARD_MAX_FILE; index++) {
sThread->images[0][index] = sThread->images[0][0] + index * 0x5A00;
sThread->comments[0][index] = sThread->comments[0][0] + index * 0x40;
sThread->comments[0][index] = sThread->comments[0][0] + index * CARD_COMMENT_SIZE;
}
for (index = 0; index < 127; index++) {
sThread->images[1][index] = sThread->images[0][0] + (index + 127) * 0x5A00;
sThread->comments[1][index] = sThread->comments[0][0] + (index + 127) * 0x40;
for (index = 0; index < CARD_MAX_FILE; index++) {
sThread->images[1][index] = sThread->images[0][0] + (index + CARD_MAX_FILE) * 0x5A00;
sThread->comments[1][index] = sThread->comments[0][0] + (index + CARD_MAX_FILE) * CARD_COMMENT_SIZE;
}
OSInitMessageQueue(&sThread->responses, sThread->responseMessages, 0x10);
@@ -329,7 +329,7 @@ BOOL shutdownCardThread() {
MEMFreeToAllocator(&sAllocator_, sThread->comments[0][0]);
MEMFreeToAllocator(&sAllocator_, sThread);
sThread = 0;
MEMDestroyExpHeap((MEMHeapHandle)sAllocator_.heap);
MEMDestroyExpHeap(static_cast<MEMHeapHandle>(sAllocator_.heap));
System::createMem1AppHeap()->free((void*)sAllocator_.heapParam2);
System::destroyMem1AppHeap();
OSReport("HEAP DESTROY\n");
@@ -366,21 +366,21 @@ extern "C" void refreshCardSlotInfo(s32 slot) {
s32 freeBytes;
s32 freeFiles;
s32 result = CARDGetMemSize(slot, &memSize);
if (result < 0) {
if (result < CARD_RESULT_READY) {
OSReport("Get Memsize Error-%d: %d: %d\n", slot, result, memSize);
}
result = CARDGetSectorSize(slot, &sectorSize);
if (result < 0) {
if (result < CARD_RESULT_READY) {
OSReport("Get Sector Error- %d: %d\n", result, sectorSize);
}
result = CARDFreeBlocks(slot, &freeBytes, &freeFiles);
if (result < 0) {
if (result < CARD_RESULT_READY) {
OSReport("Get FreeBlocks Error- %d %d\n", result, freeBytes);
}
if (CARDGetResultCode(slot) >= 0) {
if (CARDGetResultCode(slot) >= CARD_RESULT_READY) {
BOOL interrupts = OSDisableInterrupts();
sThread->slots[slot].unk_0x0C = ((u32)memSize << 17) / sectorSize - 5;
sThread->slots[slot].unk_0x0C = ((u32)memSize << 17) / sectorSize - CARD_NUM_SYSTEM_BLOCK;
sThread->slots[slot].key = sectorSize;
sThread->slots[slot].unk_0x0E = freeFiles;
sThread->slots[slot].freeBlocks = freeBytes / sectorSize;
@@ -405,7 +405,7 @@ static inline void sendValidityResponse(u32 command, u32 valid) {
} reply;
reply.value = command;
reply.fields.valid = valid;
OSSendMessage(&sThread->responses, (OSMessage)reply.value, 1);
OSSendMessage(&sThread->responses, (OSMessage)reply.value, OS_MESSAGE_BLOCK);
}
extern "C" void* cardThreadMain(void*) {
@@ -434,7 +434,7 @@ extern "C" void* cardThreadMain(void*) {
sThread->mounted[1] = 0;
goto loopCheck;
loopStart:
OSReceiveMessage(&sThread->requests, (OSMessage*)&local.message, 1);
OSReceiveMessage(&sThread->requests, (OSMessage*)&local.message, OS_MESSAGE_BLOCK);
OSReport("CARD THREAD: Message received %d\n", (s8)(u8)local.message);
if (validState != TRUE) {
goto loopCheck;
@@ -454,25 +454,25 @@ loopStart:
slot = (local.message >> 16) & 1;
command = (local.message >> 14) & 4;
result = CARDMount(slot, sThread->mountBuffers[command / 4], 0);
if (result < 0) {
if (result < CARD_RESULT_READY) {
result = handleCardMountResult(slot, result);
if (result != 0) {
if (result != CARD_RESULT_READY) {
goto mountContinue;
}
break;
}
result = CARDCheck(slot);
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto mountError;
}
mountContinue:
clearAllCardFileEntries(slot);
for (file = 0; file < 0x7F; ++file) {
for (file = 0; file < CARD_MAX_FILE; ++file) {
result = __CARDGetStatusEx(slot, (s16)file, &local.mountDir);
if (result < 0) {
if (result < CARD_RESULT_READY) {
result = handleCardMountResult(slot, result);
if (result != 0) {
if (result != CARD_RESULT_READY) {
continue;
}
goto loopCheck;
@@ -492,12 +492,12 @@ loopStart:
}
if (brokenFile) {
result = CARDFastDelete(slot, (s16)file);
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto mountError;
}
} else {
result = loadCardFileIcons(slot, (s16)file, &local.mountDir);
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto mountError;
}
}
@@ -507,10 +507,10 @@ loopStart:
sThread->mounted[command / 4] = 1;
sendCardSlotState(slot, 0, 0);
OSReport("Slot %c\n", sCardSlotName[slot]);
for (listingFile = 0; listingFile < 0x7F; ++listingFile) {
if (__CARDGetStatusEx(slot, (u16)listingFile, &local.listingDir) == 0) {
memcpy(local.fileName, local.listingDir.fileName, 0x20);
local.fileName[0x20] = 0;
for (listingFile = 0; listingFile < CARD_MAX_FILE; ++listingFile) {
if (__CARDGetStatusEx(slot, (u16)listingFile, &local.listingDir) == CARD_RESULT_READY) {
memcpy(local.fileName, local.listingDir.fileName, CARD_FILENAME_MAX);
local.fileName[CARD_FILENAME_MAX] = 0;
OSReport("%d - %s: %d blocks\n", (u16)listingFile, local.fileName,
local.listingDir.length);
}
@@ -523,12 +523,12 @@ loopStart:
break;
}
case 9:
reportCardThreadError((local.message >> 16) & 1, 9, -3);
reportCardThreadError((local.message >> 16) & 1, 9, CARD_RESULT_NOCARD);
break;
case 1: {
slot = (local.message >> 16) & 1;
result = CARDFormat(slot);
if (result < 0) {
if (result < CARD_RESULT_READY) {
reportCardThreadError(slot, 1, result);
} else {
sThread->mounted[slot] = 1;
@@ -549,7 +549,7 @@ loopStart:
slot = (local.message >> 16) & 1;
fileNo = (s16)(local.message >> 24);
result = CARDFastDelete(slot, fileNo);
if (result < 0) {
if (result < CARD_RESULT_READY) {
reportCardThreadError(slot, 4, result);
} else {
clearCardFileEntry(slot, fileNo);
@@ -564,13 +564,13 @@ loopStart:
do {
if (sThread->mounted[outerSlot] != 0) {
freeBlocks = 0;
for (freeFile = 0; freeFile < 0x7F; ++freeFile) {
for (freeFile = 0; freeFile < CARD_MAX_FILE; ++freeFile) {
result = __CARDGetStatusEx(outerSlot, freeFile, &local.freeDir);
if (result < 0 && result != -4) {
if (result < CARD_RESULT_READY && result != CARD_RESULT_NOFILE) {
freeBlocks = -1;
break;
}
if (result == 0 &&
if (result == CARD_RESULT_READY &&
memcmp(local.freeDir.gameName, (void*)0x80000000, 4) == 0 &&
memcmp(local.freeDir.company, (void*)0x80000004, 2) == 0) {
freeBlocks += local.freeDir.length;
@@ -612,26 +612,26 @@ extern "C" void markAllCardFilesDirty() {
}
++fileNo;
} while (fileNo < 0x7F);
} while (fileNo < CARD_MAX_FILE);
++slot;
} while ((s32)slot < 2);
}
extern "C" s32 handleCardMountResult(s32 slot, s32 result) {
if (result == -5) {
if (result == CARD_RESULT_IOERROR) {
goto reportError;
}
if (result >= -5) {
if (result >= CARD_RESULT_IOERROR) {
goto positiveResult;
}
if (result >= -6) {
if (result >= CARD_RESULT_BROKEN) {
goto repairedCard;
}
goto reportError;
positiveResult:
if (result < -3) {
if (result < CARD_RESULT_NOCARD) {
return 1;
}
goto reportError;
@@ -639,7 +639,7 @@ positiveResult:
repairedCard:
{
result = CARDCheck(slot);
if (result < 0) {
if (result < CARD_RESULT_READY) {
return reportCardThreadError(slot, 0, result);
}
OSReport("CardThread:Broken Card Repaired\n");
@@ -651,8 +651,8 @@ reportError:
}
extern "C" s32 reportCardThreadError(s32 slot, s32 state, s32 result) {
if (result != -7 && result != -27 && result != -8 && result != -9 &&
(clearAllCardFileEntries(slot), result != -6) && result != -13) {
if (result != CARD_RESULT_EXIST && result != -27 && result != CARD_RESULT_NOENT && result != CARD_RESULT_INSSPACE &&
(clearAllCardFileEntries(slot), result != CARD_RESULT_BROKEN) && result != CARD_RESULT_ENCODING) {
OSReport("DEBUG: UnmountCard %d \n", slot);
CARDUnmount(slot);
sThread->mounted[slot & 0xFF] = 0;
@@ -660,7 +660,7 @@ extern "C" s32 reportCardThreadError(s32 slot, s32 state, s32 result) {
OSReport("DEBUG: CardThread error %d %d\n", state, result);
markAllCardFilesDirty();
OSSendMessage(&sThread->responses,
(OSMessage)(((slot & 1) << 16) | ((result & 0xFF) << 8) | (state & 0xFF)), 1);
(OSMessage)(((slot & 1) << 16) | ((result & 0xFF) << 8) | (state & 0xFF)), OS_MESSAGE_BLOCK);
return 0;
}
@@ -680,7 +680,7 @@ extern "C" void sendCardSlotState(s32 slot, s32 state, s32 fileNo) {
message.value = (u32)fileNo << 24;
message.fields.slot = slot;
message.fields.state = state;
OSSendMessage(queue, (OSMessage)message.value, 1);
OSSendMessage(queue, (OSMessage)message.value, OS_MESSAGE_BLOCK);
}
extern "C" void clearAllCardFileEntries(s32 slot) {
@@ -688,7 +688,7 @@ extern "C" void clearAllCardFileEntries(s32 slot) {
do {
clearCardFileEntry(slot, (s16)file);
file = file + 1;
} while (file < 0x7F);
} while (file < CARD_MAX_FILE);
}
extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
@@ -701,21 +701,21 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
u32 iconAddressBase;
s32 result;
result = CARDFastOpen(slot, fileNo, &local.fileInfo);
if (result < 0) {
if (result < CARD_RESULT_READY) {
return result;
}
s32 bannerImageSize = 0;
u8 format = dir->bannerFormat & 3;
u8 format = dir->bannerFormat & CARD_STAT_BANNER_MASK;
u32 iconAddress = dir->iconAddr;
iconAddressBase = iconAddress & 0xFFFFFE00;
iconAddressOffset = iconAddress - iconAddressBase;
switch (format) {
case 1: {
case CARD_STAT_BANNER_C8: {
bannerImageSize = 0xE00;
sThread->icons[slot][fileNo].bannerEnable = 1;
sThread->icons[slot][fileNo].bannerType = 9;
sThread->icons[slot][fileNo].bannerType = GX_TF_C8;
sThread->icons[slot][fileNo].bannerOffset =
(s32)sThread->images[slot][fileNo] -
(s32)&sThread->icons[slot][fileNo];
@@ -725,10 +725,10 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
sThread->icons[slot][fileNo].bannerTlutOffset + 0x200;
break;
}
case 2: {
case CARD_STAT_BANNER_RGB5A3: {
bannerImageSize = 0x1800;
sThread->icons[slot][fileNo].bannerEnable = 1;
sThread->icons[slot][fileNo].bannerType = 5;
sThread->icons[slot][fileNo].bannerType = GX_TF_RGB5A3;
sThread->icons[slot][fileNo].bannerOffset =
(s32)sThread->images[slot][fileNo] -
(s32)&sThread->icons[slot][fileNo];
@@ -754,9 +754,9 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
sThread->icons[slot][fileNo].anmMax = 0;
sThread->icons[slot][fileNo].anmFrameBits = dir->iconSpeed;
sThread->icons[slot][fileNo].unk_0x06 =
(dir->iconSpeed & 3) << 2;
for (icon = 0; icon < 8; ++icon) {
s32 iconSpeed = (dir->iconSpeed >> shift) & 3;
(dir->iconSpeed & CARD_STAT_SPEED_MASK) << 2;
for (icon = 0; icon < CARD_ICON_MAX; ++icon) {
s32 iconSpeed = (dir->iconSpeed >> shift) & CARD_STAT_SPEED_MASK;
if (iconSpeed != 0) {
sThread->icons[slot][fileNo].anmMax =
sThread->icons[slot][fileNo].anmMax + (iconSpeed << 2);
@@ -769,31 +769,31 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
shift = shift + 2;
}
sThread->icons[slot][fileNo].unk_0x07 =
((u16)dir->iconSpeed >> 0xC) & 0xC;
(dir->iconSpeed >> 0xC) & 0xC;
iconSpeedDone:
if ((dir->iconSpeed & 3) == 0 || (dir->iconFormat & 3) == 0) {
if ((dir->iconSpeed & CARD_STAT_SPEED_MASK) == 0 || (dir->iconFormat & CARD_STAT_ICON_MASK) == 0) {
iconImageSize = 0;
sThread->icons[slot][fileNo].unk_0x01 = 0;
} else {
BOOL hasTlut = FALSE;
iconCount = 0;
shift = 0;
for (icon = 0; icon < 8; ++icon) {
if (((dir->iconSpeed >> shift) & 3) != 0) {
s32 iconFormat = (dir->iconFormat >> shift) & 3;
for (icon = 0; icon < CARD_ICON_MAX; ++icon) {
if (((dir->iconSpeed >> shift) & CARD_STAT_SPEED_MASK) != 0) {
s32 iconFormat = (dir->iconFormat >> shift) & CARD_STAT_ICON_MASK;
s32 paletteSize;
switch (iconFormat) {
case 1:
case CARD_STAT_ICON_C8:
paletteSize = 0x400;
hasTlut = TRUE;
sThread->icons[slot][fileNo].iconFmt[iconCount] = 9;
sThread->icons[slot][fileNo].iconFmt[iconCount] = GX_TF_C8;
break;
case 2:
case CARD_STAT_ICON_RGB5A3:
paletteSize = 0x800;
sThread->icons[slot][fileNo].iconFmt[iconCount] = 5;
sThread->icons[slot][fileNo].iconFmt[iconCount] = GX_TF_RGB5A3;
break;
case 0: {
case CARD_STAT_ICON_NONE: {
paletteSize = 0;
u8* iconPalette =
&sThread->icons[slot][fileNo].iconFmt[iconCount];
@@ -833,7 +833,7 @@ iconSpeedDone:
s32 totalImageSize = iconImageSize + bannerImageSize;
u32 transferSize = (totalImageSize + iconAddressOffset + 0x1FF) & 0xFFFFFE00;
result = CARDGetSectorSize(slot, (u32*)&local.sectorSize);
if (result < 0) {
if (result < CARD_RESULT_READY) {
result = 0;
sThread->icons[slot][fileNo].bannerEnable = 0;
sThread->icons[slot][fileNo].unk_0x01 = 0;
@@ -850,18 +850,18 @@ iconSpeedDone:
} else if (totalImageSize > 0) {
result = CARDRead(&local.fileInfo, sThread->imageReadBuffer,
transferSize, iconAddressBase);
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto closeFile;
}
memcpy(sThread->images[slot][fileNo],
(u8*)sThread->imageReadBuffer + iconAddressOffset,
sThread->imageReadBuffer + iconAddressOffset,
totalImageSize);
DCStoreRange(sThread->images[slot][fileNo], transferSize);
result = 0;
}
}
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto closeFile;
}
@@ -870,7 +870,7 @@ iconSpeedDone:
s32 commentDataOffset = iconAddress - iconAddressBase;
s32 imageSize = ((iconAddress + 0x23F) & 0xFFFFFE00) - iconAddressBase;
result = CARDGetSectorSize(slot, (u32*)&local.commentSectorSize);
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto clearComment;
}
{
@@ -886,22 +886,22 @@ iconSpeedDone:
}
result = CARDRead(&local.fileInfo, sThread->commentBuffer, imageSize,
iconAddressBase);
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto clearComment;
}
memset(sThread->comments[slot][fileNo], 0, 0x40);
memset(sThread->comments[slot][fileNo], 0, CARD_COMMENT_SIZE);
memcpy(sThread->comments[slot][fileNo],
sThread->commentBuffer + commentDataOffset, 0x40);
sThread->commentBuffer + commentDataOffset, CARD_COMMENT_SIZE);
result = 0;
goto commentDone;
}
}
clearComment:
memset(sThread->comments[slot][fileNo], 0, 0x40);
memset(sThread->comments[slot][fileNo], 0, CARD_COMMENT_SIZE);
commentDone:
if (result >= 0) {
if (result >= CARD_RESULT_READY) {
goto closeFileSuccess;
}
closeFile:
@@ -909,7 +909,7 @@ closeFile:
closeFileSuccess:
result = CARDClose(&local.fileInfo);
if (result < 0) {
if (result < CARD_RESULT_READY) {
return result;
}
@@ -929,23 +929,23 @@ extern "C" s32 checkCardFileDuplicate(s32 slot, s16 fileNo) {
CARDDir sourceDir;
CARDDir otherDir;
s32 result = __CARDGetStatusEx(slot, fileNo, &sourceDir);
if (result < 0) {
if (result < CARD_RESULT_READY) {
return result;
}
s32 file = 0;
do {
s32 otherResult = __CARDGetStatusEx(slot ^ 1, file, &otherDir);
if (otherResult < 0 && otherResult != -4) {
if (otherResult < CARD_RESULT_READY && otherResult != CARD_RESULT_NOFILE) {
return otherResult;
}
if (otherResult == 0 && memcmp(sourceDir.gameName, otherDir.gameName, 4) == 0 &&
if (otherResult == CARD_RESULT_READY && memcmp(sourceDir.gameName, otherDir.gameName, 4) == 0 &&
memcmp(sourceDir.company, otherDir.company, 2) == 0 &&
memcmp(sourceDir.fileName, otherDir.fileName, 0x20) == 0) {
return -7;
memcmp(sourceDir.fileName, otherDir.fileName, CARD_FILENAME_MAX) == 0) {
return CARD_RESULT_EXIST;
}
file = file + 1;
} while (file < 0x7F);
} while (file < CARD_MAX_FILE);
return 0;
}
@@ -962,16 +962,16 @@ static inline s16 createCardTemporaryFile(s32 destinationSlot, const CARDDir& so
sprintf(sThread->temporaryFileName, "Broken File%03d", attempt);
result = CARDCreate(destinationSlot, sThread->temporaryFileName,
fileSize, &sThread->destinationFile);
if (result < 0 && result != -7) {
if (result < CARD_RESULT_READY && result != CARD_RESULT_EXIST) {
OSReport("Can't Create temp File with Error.");
return (s16)result;
}
++attempt;
} while (result != 0 && attempt < 0x80);
} while (result != CARD_RESULT_READY && attempt < 0x80);
if (attempt < 0x80) {
destinationFileNo = sThread->destinationFile.fileNo;
} else {
destinationFileNo = -0x80;
destinationFileNo = CARD_RESULT_FATAL_ERROR;
}
return destinationFileNo;
}
@@ -1008,19 +1008,19 @@ extern "C" void runCardMoveOrCopy(u8 slot, s16 fileNo, s32 command) {
result = checkCardFileDuplicate(slot, fileNo);
if (result < 0) {
if (result < CARD_RESULT_READY) {
reportCardThreadError(slot, command, result);
goto finish;
}
commonSectorSize = 0;
result = CARDGetSectorSize(0, &sourceSectorSize);
if (result < 0) {
if (result < CARD_RESULT_READY) {
sectorError = result;
goto sectorSizeCheck;
}
result = CARDGetSectorSize(1, &destinationSectorSize);
if (result < 0) {
if (result < CARD_RESULT_READY) {
sectorError = result;
goto sectorSizeCheck;
}
@@ -1031,7 +1031,7 @@ extern "C" void runCardMoveOrCopy(u8 slot, s16 fileNo, s32 command) {
sectorError = 0;
}
sectorSizeCheck:
if (sectorError >= 0) {
if (sectorError >= CARD_RESULT_READY) {
goto sectorSizeDone;
}
sectorSizeError:
@@ -1043,30 +1043,30 @@ sectorSizeDone:
{
s32 permissionResult = 0;
statusResult = __CARDGetStatusEx(slot, fileNo, &checkedStatus);
if (statusResult >= 0) {
if (statusResult >= CARD_RESULT_READY) {
switch (command) {
case 2:
if (checkedStatus.permission & 8) {
permissionResult = -10;
if (checkedStatus.permission & CARD_ATTR_NO_COPY) {
permissionResult = CARD_RESULT_NOPERM;
}
break;
case 3:
if (checkedStatus.permission & 0x10) {
permissionResult = -10;
if (checkedStatus.permission & CARD_ATTR_NO_MOVE) {
permissionResult = CARD_RESULT_NOPERM;
}
break;
}
} else {
permissionResult = CARDGetResultCode(slot);
}
if (permissionResult < 0) {
if (permissionResult < CARD_RESULT_READY) {
reportCardThreadError(slot, command, permissionResult);
goto finish;
}
}
result = __CARDGetStatusEx(slot, fileNo, &createStatus);
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto cleanup;
}
@@ -1084,18 +1084,18 @@ sectorSizeDone:
u32 sectorSize;
ioResult = __CARDGetStatusEx(slot, fileNo, &ioStatus);
if (ioResult < 0) {
if (ioResult < CARD_RESULT_READY) {
goto copyIoFailure;
}
stage = 1;
ioResult = CARDGetSectorSize(slot, &sectorSize);
if (ioResult < 0) {
if (ioResult < CARD_RESULT_READY) {
goto copyIoFailure;
}
maxBlocks = 0x40000 / sectorSize;
stage = 2;
ioResult = CARDFastOpen(slot, fileNo, &sThread->sourceFile);
if (ioResult < 0) {
if (ioResult < CARD_RESULT_READY) {
goto copyIoFailure;
}
block = 0;
@@ -1106,14 +1106,14 @@ sectorSizeDone:
size = blocks * sectorSize;
ioResult = CARDRead(&sThread->sourceFile,
sThread->transferBuffer, size, offset);
if (ioResult < 0) {
if (ioResult < CARD_RESULT_READY) {
goto copyIoFailure;
}
sThread->writePending = 1;
ioResult = CARDWriteAsync(&sThread->destinationFile,
sThread->transferBuffer, size, offset,
clearCardWritePending);
if (ioResult < 0) {
if (ioResult < CARD_RESULT_READY) {
goto copyIoFailure;
}
while (sThread->writePending != 0) {
@@ -1125,12 +1125,12 @@ sectorSizeDone:
}
stage = 4;
ioResult = CARDClose(&sThread->sourceFile);
if (ioResult < 0) {
if (ioResult < CARD_RESULT_READY) {
goto copyIoFailure;
}
stage = 5;
ioResult = CARDClose(&sThread->destinationFile);
if (ioResult >= 0) {
if (ioResult >= CARD_RESULT_READY) {
result = 0;
goto copyIoDone;
}
@@ -1162,38 +1162,38 @@ copyIoDone:
;
}
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto cleanup;
}
if (command == 2) {
copyResult = __CARDGetStatusEx(slot, fileNo, &sourceStatus);
if (copyResult < 0) {
if (copyResult < CARD_RESULT_READY) {
OSReport("Can't get status for src file\n");
} else {
++sourceStatus.copyTimes;
copyResult = __CARDSetStatusEx(slot, fileNo, &sourceStatus);
if (copyResult < 0) {
if (copyResult < CARD_RESULT_READY) {
OSReport("Can't set status for src file %d\n", copyResult);
} else {
oldTime = sourceStatus.time;
sourceStatus.time = (u32)(OSGetTime() / (*(u32*)0x800000F8 >> 2));
copyResult = __CARDSetStatusEx(destinationSlot, destinationFileNo,
&sourceStatus);
if (copyResult < 0) {
if (copyResult < CARD_RESULT_READY) {
OSReport("Can't set status for dst file (src file copyTimes--)\n");
if (copyResult != -3) {
if (copyResult != CARD_RESULT_NOCARD) {
--sourceStatus.copyTimes;
}
sourceStatus.time = oldTime;
s32 restoreResult = __CARDSetStatusEx(slot, fileNo, &sourceStatus);
if (restoreResult < 0) {
if (restoreResult < CARD_RESULT_READY) {
OSReport("Can't set status for src file(src file copyTimes--)\n");
}
} else {
metadataCopied = TRUE;
copyResult = loadCardFileIcons(destinationSlot, destinationFileNo,
&sourceStatus);
if (copyResult < 0) {
if (copyResult < CARD_RESULT_READY) {
OSReport("Can't read icon for move dstfile\n");
} else {
copyResult = 0;
@@ -1202,38 +1202,38 @@ copyIoDone:
}
}
result = copyResult;
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto cleanup;
}
} else if (command == 3) {
renameAttempt = 0;
moveStage = 0;
moveResult = __CARDGetStatusEx(slot, fileNo, &moveStatus);
if (moveResult >= 0) {
if (moveResult >= CARD_RESULT_READY) {
++moveStage;
renamedStatus = moveStatus;
memset(renamedStatus.company, 0, 2);
memset(renamedStatus.gameName, 0, 4);
do {
memset(renamedStatus.fileName, 0, 0x20);
memset(renamedStatus.fileName, 0, CARD_FILENAME_MAX);
sprintf((char*)renamedStatus.fileName, "Broken File%03d", renameAttempt);
moveResult = __CARDSetStatusEx(slot, fileNo, &renamedStatus);
if (moveResult < 0 && moveResult != -7) {
if (moveResult < CARD_RESULT_READY && moveResult != CARD_RESULT_EXIST) {
goto moveStatusError;
}
++renameAttempt;
} while (moveResult != 0 && renameAttempt < 0x80);
} while (moveResult != CARD_RESULT_READY && renameAttempt < 0x80);
moveStage = 2;
moveResult = __CARDSetStatusEx(destinationSlot, destinationFileNo,
&moveStatus);
if (moveResult < 0) {
if (moveResult < CARD_RESULT_READY) {
s32 setResult = moveResult;
if (moveResult == -3) {
if (moveResult == CARD_RESULT_NOCARD) {
CARDFastDelete(slot, fileNo);
clearCardFileEntry(slot, fileNo);
} else {
s32 restoreResult = __CARDSetStatusEx(slot, fileNo, &moveStatus);
if (restoreResult < 0) {
if (restoreResult < CARD_RESULT_READY) {
OSReport("Can't repair src file - carddir\n");
}
}
@@ -1242,12 +1242,12 @@ copyIoDone:
metadataCopied = TRUE;
moveStage = 3;
moveResult = CARDFastDelete(slot, fileNo);
if (moveResult >= 0) {
if (moveResult >= CARD_RESULT_READY) {
clearCardFileEntry(slot, fileNo);
moveStage = 4;
moveResult = __CARDGetStatusEx(destinationSlot,
destinationFileNo, &moveStatus);
if (moveResult >= 0) {
if (moveResult >= CARD_RESULT_READY) {
moveStage = 5;
if ((moveResult = loadCardFileIcons(
destinationSlot, destinationFileNo, &moveStatus)) < 0) {
@@ -1281,7 +1281,7 @@ moveStatusError:
break;
}
moveStatusDone:
if (moveResult < 0) {
if (moveResult < CARD_RESULT_READY) {
goto cleanup;
}
}
@@ -1295,7 +1295,7 @@ moveStatusDone:
cleanup:
destinationSlot = slot ^ 1;
result = CARDGetResultCode(destinationSlot);
if (result < 0) {
if (result < CARD_RESULT_READY) {
reportCardThreadError(destinationSlot, command, result);
} else {
if (temporaryCreated && !metadataCopied) {
@@ -1303,7 +1303,7 @@ cleanup:
}
if (metadataCopied) {
if (__CARDGetStatusEx(destinationSlot, destinationFileNo,
&createStatus) == 0) {
&createStatus) == CARD_RESULT_READY) {
loadCardFileIcons(destinationSlot, destinationFileNo, &createStatus);
}
}
@@ -1311,7 +1311,7 @@ cleanup:
sendCardSlotState(destinationSlot, 0, fileNo & 0xFF);
}
result = CARDGetResultCode(slot);
if (result < 0) {
if (result < CARD_RESULT_READY) {
reportCardThreadError(slot, command, result);
} else {
refreshCardSlotInfo(slot);

View File

@@ -49,9 +49,9 @@ namespace ipl {
nw4r::lyt::Material* material = pane->FindMaterialByName("DataBanner_00");
pane->SetVisible(true);
if (static_cast<MemoryCard*>(System::getScene(0xE))->getManager()->isIconValidate(mSlot, mIndex) &&
static_cast<MemoryCard*>(System::getScene(0xE))->getManager()->create_icon(mSlot, mIndex) != NULL) {
material->SetTexture(0, *static_cast<MemoryCard*>(System::getScene(0xE))
if (static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))->getManager()->isIconValidate(mSlot, mIndex) &&
static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))->getManager()->create_icon(mSlot, mIndex) != NULL) {
material->SetTexture(0, *static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))
->getManager()
->create_icon(mSlot, mIndex));
} else {
@@ -80,12 +80,12 @@ namespace ipl {
void GCSaveData::onPoint(const char* paneName, controller::Interface* controller) {
AnmButton* button = get_anmbutton(paneName);
if (button != NULL) {
if (button->unk_0x04 == 0) {
if (System::getScene(0xE) != NULL) {
if (static_cast<MemoryCard*>(System::getScene(0xE))
if (button->mHoverCount == 0) {
if (System::getScene(SCENE_MEMORY_CARD) != NULL) {
if (static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))
->getManager()
->isIconValidate(mSlot, mIndex)) {
mpBalloon->init(static_cast<MemoryCard*>(System::getScene(0xE))
mpBalloon->init(static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))
->getManager()
->getComment(mSlot, mIndex, 0),
0);
@@ -100,25 +100,25 @@ namespace ipl {
}
button->onCmdRecv(1);
}
button->unk_0x04++;
button->mHoverCount++;
}
}
void GCSaveData::onLeft(const char* paneName) {
AnmButton* button = get_anmbutton(paneName);
if (button != NULL) {
if (button->unk_0x04 == 1) {
if (button->mHoverCount == 1) {
button->onCmdRecv(2);
}
button->unk_0x04--;
button->mHoverCount--;
}
}
void GCSaveData::onTrig(const char* paneName) {
if (static_cast<MemoryCard*>(System::getScene(0xE)) != NULL &&
static_cast<MemoryCard*>(System::getScene(0xE))->getManager()->isIconValidate(mSlot, mIndex) &&
if (System::getScene(SCENE_MEMORY_CARD) != NULL &&
static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))->getManager()->isIconValidate(mSlot, mIndex) &&
get_anmbutton(paneName) != NULL) {
static_cast<MemoryCard*>(System::getScene(0xE))->onFocus(this);
static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))->onFocus(this);
}
}

View File

@@ -80,7 +80,7 @@ GCWindow::GCWindow(EGG::Heap* heap, nand::LayoutFile* layoutFile, const char* di
}
MemoryBase::MemoryBase() : mpLayout(NULL), unk_0x08(NULL) {
MemoryBase::MemoryBase() : mpLayout(NULL), mpLayoutFile(NULL) {
nw4r::ut::List_Init(&mAnmList, offsetof(Anm, mLink));
nw4r::ut::List_Init(&mButtonList, offsetof(Button, mLink));
nw4r::ut::List_Init(&mAnmButtonList, offsetof(AnmButton, mLink));
@@ -143,7 +143,7 @@ void GCWindow::calc() {
mpPaneManager->calc();
void* button = NULL;
while ((button = nw4r::ut::List_GetNext(&mAnmButtonList, button)) != NULL) {
((MemoryBase::AnmButton*)button)->calc();
static_cast<MemoryBase::AnmButton*>(button)->calc();
}
switch (mState) {
case 0:
@@ -246,7 +246,7 @@ void GCWindow::draw() {
}
void GCWindow::destroy() {
((MemoryCard*)System::getScene(0xe))->onRelease();
static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))->onRelease();
for (int i = 0; i < 3; i++) {
clear_button(scButtonName[i]);
}
@@ -260,24 +260,24 @@ void GCWindow::destroy() {
void GCWindow::onPoint(const char* name, controller::Interface* controller) {
MemoryBase::AnmButton* button = get_anmbutton(name);
if (button != NULL) {
if (button->unk_0x04 == 0) {
if (button->mHoverCount == 0) {
button->onCmdRecv(1);
snd::sSystem.startSE("WIPL_SE_BT_TARGETTING");
if (controller != NULL) {
controller->rumble(0);
}
}
button->unk_0x04++;
button->mHoverCount++;
}
}
void GCWindow::onLeft(const char* name) {
MemoryBase::AnmButton* button = get_anmbutton(name);
if (button != NULL) {
if (button->unk_0x04 == 1) {
if (button->mHoverCount == 1) {
button->onCmdRecv(2);
}
button->unk_0x04--;
button->mHoverCount--;
}
}
@@ -302,7 +302,7 @@ void GCWindow::onTrig(const char* name) {
void GCWindow::on_wait() {
for (int i = 0; i < 2; i++) {
if (mFlags0[i] != 0) {
((MemoryCard*)System::getScene(0xe))->onFocus(NULL);
static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))->onFocus(NULL);
System::getDialog()->callBtn2(i == 0 ? 0xec : 0xed, 0x142, 0x141, true);
mFlags0[i] = 0;
mCardState = i;
@@ -820,7 +820,7 @@ void SavedataEditWindow::calc() {
mpPaneManager->calc();
void* button = NULL;
while ((button = nw4r::ut::List_GetNext(&mAnmButtonList, button)) != NULL) {
((MemoryBase::AnmButton*)button)->calc();
static_cast<MemoryBase::AnmButton*>(button)->calc();
}
switch (mState) {
case 0:

View File

@@ -128,7 +128,7 @@ namespace ipl {
};
MemoryCard::MemoryCard(EGG::Heap* heap)
: Base(heap), MemoryBase(), mState(2), mPrevState(2), mSlot(0), mIconIndex(-15), mIconCount(0),
: Base(heap), MemoryBase(), mState(2), mPrevState(2), mSlot(SLOT_A), mIconIndex(-15), mIconCount(0),
mShowArwR(0), mShowArwL(0), mpEvent(NULL), mpFocusSaveData(NULL) {
System::getMem2App()->dump();
nw4r::ut::List_Init(&mSaveDataList, offsetof(GCSaveData, mLink));
@@ -138,7 +138,7 @@ namespace ipl {
void MemoryCard::prepare() {
System::getBS2Manager()->abort();
unk_0x08 = System::getNandManager()->readLayoutAsync(getSceneHeap(), "gcMem.ash");
mpLayoutFile = System::getNandManager()->readLayoutAsync(getSceneHeap(), "gcMem.ash");
mBalloonLayoutFile = System::getNandManager()->readLayoutAsync(getSceneHeap(), "balloon.ash");
}
@@ -153,10 +153,10 @@ namespace ipl {
OSReport("*** BS2 abort costs: %dms\n", OSTicksToMilliseconds(end - start));
ES_SetUid((u64(1) << 32) | 2);
mpLayout = new layout::Object(getSceneHeap(), unk_0x08, "arc", "it_ObjCubeEdit_a.brlyt");
mpLayout = new layout::Object(getSceneHeap(), mpLayoutFile, "arc", "it_ObjCubeEdit_a.brlyt");
add_animation(scAnmName, 0x1B);
get_animation(7)->mAnim->setAnmType(1);
get_animation(10)->mAnim->setAnmType(1);
get_animation(7)->mAnim->setAnmType(ANIM_TYPE_BACKWARD);
get_animation(10)->mAnim->setAnmType(ANIM_TYPE_BACKWARD);
mpLayout->finishBinding();
do_animation(0);
do_animation(1);
@@ -187,7 +187,7 @@ namespace ipl {
set_textbox(scTextboxToMessageID[i].paneName, scTextboxToMessageID[i].messageId);
}
mpGCWindow = new GCWindow(getSceneHeap(), unk_0x08, "arc", "it_CubeDetail_a.brlyt");
mpGCWindow = new GCWindow(getSceneHeap(), mpLayoutFile, "arc", "it_CubeDetail_a.brlyt");
mpGCWindow->do_animation(0);
MemoryCardManager* manager = new MemoryCardManagerImpl();
@@ -198,9 +198,9 @@ namespace ipl {
for (int i = 0; i < 0x2D; i++) {
nw4r::lyt::Pane* pane = mpLayout->FindPaneByName(scSavedataPaneName[i]);
nw4r::math::VEC3 position(0.0f, 0.0f, 0.0f);
PSMTXMultVec(pane->GetGlobalMtx(), reinterpret_cast<const Vec*>(&position), reinterpret_cast<Vec*>(&position));
PSMTXMultVec(pane->GetGlobalMtx(), position, position);
GCSaveData* saveData =
new GCSaveData(getSceneHeap(), unk_0x08, "arc", "it_ObjCubeEdit_b.brlyt", position);
new GCSaveData(getSceneHeap(), mpLayoutFile, "arc", "it_ObjCubeEdit_b.brlyt", position);
saveData->set_visible("N_Data_00", false);
nw4r::ut::List_Append(&mSaveDataList, saveData);
if (i >= 0xF && i < 0x1E) {
@@ -345,9 +345,9 @@ namespace ipl {
}
controller::Interface* controller = System::getYoungController();
if (controller != NULL) {
if (controller->down(0x30001000)) {
if (controller->down(controller::BTN_NEXT_LEFT)) {
start_scroll_l();
} else if (controller->down(0x06000010)) {
} else if (controller->down(controller::BTN_NEXT_RIGHT)) {
start_scroll_r();
}
}
@@ -466,19 +466,19 @@ namespace ipl {
}
void MemoryCard::start_errormessage_fadein() {
if (mpManager->isSlotWrongDevice(mSlot) != 0) {
if (mpManager->isSlotWrongDevice(mSlot)) {
mSlotState[mSlot] = 3;
set_textbox("T_Error_00", mSlot == 0 ? 0xE8 : 0xE9);
set_textbox("T_Error_00", mSlot == SLOT_A ? 0xE8 : 0xE9);
} else {
mSlotState[mSlot] = 2;
set_textbox("T_Error_00", mSlot == 0 ? 0xE6 : 0xE7);
set_textbox("T_Error_00", mSlot == SLOT_A ? 0xE6 : 0xE7);
}
set_visible("T_Error_00", true);
do_animation(0x19);
}
int MemoryCard::update_slot() {
if (mSlotState[mSlot] != 1 && mpManager->isSlotReady(mSlot) != 0) {
if (mSlotState[mSlot] != 1 && mpManager->isSlotReady(mSlot)) {
for (u16 i = 0xF; i < 0x1E; i++) {
static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i))->init();
}
@@ -490,7 +490,7 @@ namespace ipl {
mState = 0xB;
return true;
}
if (mSlotState[mSlot] != 2 && mpManager->isSlotNoCard(mSlot) != 0) {
if (mSlotState[mSlot] != 2 && mpManager->isSlotNoCard(mSlot)) {
for (u16 i = 0xF; i < 0x1E; i++) {
static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i))->init();
}
@@ -501,7 +501,7 @@ namespace ipl {
mState = 0xC;
return true;
}
if ((mSlotState[mSlot] != 3 && mpManager->isSlotWrongDevice(mSlot) != 0) || mSlotState[mSlot] == 0) {
if ((mSlotState[mSlot] != 3 && mpManager->isSlotWrongDevice(mSlot)) || mSlotState[mSlot] == 0) {
for (u16 i = 0xF; i < 0x1E; i++) {
static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i))->init();
}
@@ -579,7 +579,7 @@ namespace ipl {
nw4r::lyt::Pane* pane = mpLayout->FindPaneByName(scSavedataPaneName[i]);
GCSaveData* saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i));
nw4r::math::VEC3 position(0.0f, 0.0f, 0.0f);
PSMTXMultVec(pane->GetGlobalMtx(), reinterpret_cast<const Vec*>(&position), reinterpret_cast<Vec*>(&position));
PSMTXMultVec(pane->GetGlobalMtx(), position, position);
saveData->setTranslate(position);
saveData->init();
}
@@ -642,28 +642,28 @@ namespace ipl {
void MemoryCard::onPoint(const char* paneName, controller::Interface* controller) {
MemoryBase::AnmButton* button = get_anmbutton(paneName);
if (button != NULL) {
if (button->unk_0x04 == 0 &&
(strcmp(paneName, scTriggerPaneName[2]) != 0 || mSlot != 0) &&
(strcmp(paneName, scTriggerPaneName[3]) != 0 || mSlot != 1)) {
if (button->mHoverCount == 0 &&
(strcmp(paneName, scTriggerPaneName[2]) != 0 || mSlot != SLOT_A) &&
(strcmp(paneName, scTriggerPaneName[3]) != 0 || mSlot != SLOT_B)) {
button->onCmdRecv(1);
snd::getSystem()->startSE("WIPL_SE_BT_TARGETTING");
if (controller != NULL) {
controller->rumble(0);
}
}
button->unk_0x04++;
button->mHoverCount++;
}
}
void MemoryCard::onLeft(const char* paneName) {
MemoryBase::AnmButton* button = get_anmbutton(paneName);
if (button != NULL) {
if (button->unk_0x04 == 1 &&
(strcmp(paneName, scTriggerPaneName[2]) != 0 || mSlot != 0) &&
(strcmp(paneName, scTriggerPaneName[3]) != 0 || mSlot != 1)) {
if (button->mHoverCount == 1 &&
(strcmp(paneName, scTriggerPaneName[2]) != 0 || mSlot != SLOT_A) &&
(strcmp(paneName, scTriggerPaneName[3]) != 0 || mSlot != SLOT_B)) {
button->onCmdRecv(2);
}
button->unk_0x04--;
button->mHoverCount--;
}
}
@@ -676,7 +676,7 @@ namespace ipl {
do_animation(0xF);
start_scroll_l();
} else if (strcmp(paneName, scTriggerPaneName[2]) == 0) {
if (mSlot == 1) {
if (mSlot == SLOT_B) {
do_animation(0xB);
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
@@ -689,7 +689,7 @@ namespace ipl {
mState = 5;
}
} else if (strcmp(paneName, scTriggerPaneName[3]) == 0) {
if (mSlot == 0) {
if (mSlot == SLOT_A) {
do_animation(8);
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {

View File

@@ -25,7 +25,7 @@ void MemoryBaseEvent::onEvent(u32 componentID, u32 event, void* data) {
mpBase->onMove(name);
break;
case ::gui::EventHandler::ON_TRIG:
if (static_cast<controller::Interface*>(data)->downTrg(0x100800)) {
if (static_cast<controller::Interface*>(data)->downTrg(controller::BTN_INTERACT)) {
mpBase->onTrig(name);
}
break;
@@ -53,10 +53,10 @@ void MemoryBase::clear_button(const char* paneName) {
AnmButton* button = get_anmbutton(paneName);
nw4r::lyt::Pane* pane = mpLayout->getNW4RLyt()->GetRootPane()->FindPaneByName(paneName, true);
mpPaneManager->initPane(pane);
if (button->unk_0x04 >= 1) {
if (button->mHoverCount >= 1) {
button->onCmdRecv(2);
}
button->unk_0x04 = 0;
button->mHoverCount = 0;
}
MemoryBase::Button* MemoryBase::get_button(const char* paneName) {
@@ -102,9 +102,9 @@ void MemoryBase::do_animation(int index) {
void MemoryBase::do_animation(int index, bool flag) {
Anm* animation = static_cast<Anm*>(nw4r::ut::List_GetNth(&mAnmList, index));
if (flag) {
animation->mAnim->setAnmType(1);
animation->mAnim->setAnmType(ANIM_TYPE_BACKWARD);
} else {
animation->mAnim->setAnmType(0);
animation->mAnim->setAnmType(ANIM_TYPE_FORWARD);
}
animation->mAnim->play();
mpLayout->calc();
@@ -165,21 +165,21 @@ SettingButton* MemoryBase::get_setting_button() {
}
void MemoryBase::change_button_text_close() {
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(2, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(3, 0xFC);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(1, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_HIDE_BTN, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_SET_TEXT, 0xFC);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_SHOW_BTN, 0);
}
void MemoryBase::change_button_text_return() {
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(2, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(3, 0x13B);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(1, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_HIDE_BTN, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_SET_TEXT, 0x13B);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_SHOW_BTN, 0);
}
void MemoryBase::change_button_text_ok() {
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(2, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(3, 0x2E);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(1, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_HIDE_BTN, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_SET_TEXT, 0x2E);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_SHOW_BTN, 0);
}
void MemoryBase::show_button_return() {
@@ -207,38 +207,38 @@ void MemoryBase::AnmButton::onCmdRecv(int command) {
if (mLastCmd == 3) {
mCurrentAnm = mAnm3;
mCurrentAnm->mAnim->play();
unk_0x24 = 3;
mAnimationState = 3;
}
switch (unk_0x24) {
switch (mAnimationState) {
case 0:
if (command == 1) {
mCurrentAnm = mAnm1;
mCurrentAnm->mAnim->play();
unk_0x24 = 1;
mAnimationState = 1;
} else if (command == 2) {
mCurrentAnm = mAnm2;
mCurrentAnm->mAnim->play();
unk_0x24 = 2;
mAnimationState = 2;
}
break;
case 1:
if (command == 4) {
if (mLastCmd == 1) mLastCmd = 0;
if (mpBalloon != NULL) mpBalloon->fadein();
unk_0x24 = 0;
mAnimationState = 0;
}
break;
case 2:
if (command == 4) {
if (mLastCmd == 2) mLastCmd = 0;
if (mpBalloon != NULL) mpBalloon->fadeout();
unk_0x24 = 0;
mAnimationState = 0;
}
break;
case 3:
if (command == 4) {
if (mLastCmd == 3) mLastCmd = 0;
unk_0x24 = 0;
mAnimationState = 0;
}
break;
}

View File

@@ -34,8 +34,8 @@ extern "C" int compareMemoryCardSortEntries(const void* first, const void* secon
namespace ipl {
namespace scene {
typedef memorycard::FileInfo CardDirectory[0x7f];
typedef memorycard::IconState CardIcons[0x7f];
typedef memorycard::FileInfo CardDirectory[CARD_MAX_FILE];
typedef memorycard::IconState CardIcons[CARD_MAX_FILE];
void MemoryCardManager::calc() {
memorycard::probeCard();
@@ -82,18 +82,18 @@ long MemoryCardManager::isSlotWrongDevice(u8 slot) {
void MemoryCardManager::sort_file_array(u8 slot) {
CardDirectory* dirs = reinterpret_cast<CardDirectory*>(memorycard::getCardDirState());
for (long file = 0; file < 0x7f; file++) {
for (long file = 0; file < CARD_MAX_FILE; file++) {
if (dirs[slot][file].fileNo != 0) {
mFile[slot][file].fileNo = file;
mFile[slot][file].sortKey = dirs[slot][file].key;
mFile[slot][file].unk_0x08 = 0;
mFile[slot][file].sortKeyHigh = 0;
} else {
mFile[slot][file].fileNo = file;
mFile[slot][file].sortKey = -1 - file;
mFile[slot][file].unk_0x08 = 0;
mFile[slot][file].sortKeyHigh = 0;
}
}
qsort(mFile[slot], 0x7f, sizeof(MCFile), compareMemoryCardSortEntries);
qsort(mFile[slot], CARD_MAX_FILE, sizeof(MCFile), compareMemoryCardSortEntries);
}
void MemoryCardManager::sendCardCmdMove(u8 slot, s16 index) {
@@ -223,11 +223,11 @@ bool MemoryCardManager::isCopyEnable(u8 slot, u32 index, long* code) {
bool MemoryCardManager::isIconValidate(u8 slot, s16 index) {
u32 cardSlot = slot;
if (cardSlot > 1 || index < 0 || index >= 0x7f) {
if (cardSlot > 1 || index < 0 || index >= CARD_MAX_FILE) {
return false;
}
CardDirectory* dirs = reinterpret_cast<CardDirectory*>(memorycard::getCardDirState());
if (mFile[cardSlot][index].fileNo >= 0x7f) {
if (mFile[cardSlot][index].fileNo >= CARD_MAX_FILE) {
return false;
}
return dirs[cardSlot][mFile[cardSlot][index].fileNo].fileNo != 0;
@@ -244,9 +244,9 @@ void MemoryCardManager::update_icon_anm() {
int slot = 0;
do {
int index = 0;
for (int remaining = 0x7f; remaining > 0; remaining--, index++) {
for (int remaining = CARD_MAX_FILE; remaining > 0; remaining--, index++) {
u32 file = mFile[slot][index].fileNo;
if (file < 0x7f && dirs[slot][file].fileNo != 0) {
if (file < CARD_MAX_FILE && dirs[slot][file].fileNo != 0) {
memorycard::IconState* icon = icons[slot] + file;
s8 delta = icon->anmDelta;
s16 currentFrame = mFileCell[slot][file].iconAnmCounter;
@@ -290,21 +290,21 @@ void MemoryCardManager::update_file_array(u8 slot) {
}
if (mLastResult == 0) {
switch (mLastCmd) {
case 3:
case Move:
mpEventHandler->onMemEvent(2, slot);
mLastCmd = 6;
mLastCmd = MoveComplete;
break;
case 2:
case Copy:
mpEventHandler->onMemEvent(1, slot);
mLastCmd = 5;
mLastCmd = CopyComplete;
break;
case 4:
case Delete:
mpEventHandler->onMemEvent(3, slot);
mLastCmd = 7;
mLastCmd = DeleteComplete;
break;
case 1:
case Format:
mpEventHandler->onMemEvent(4, slot);
mLastCmd = 8;
mLastCmd = FormatComplete;
break;
}
}
@@ -327,10 +327,10 @@ void MemoryCardManager::update_change_cardstate(u8 slot) {
slot == memorycard::getCardLastSrcSlot()) {
mpEventHandler->onMemEvent(5, slot);
states[slot].changed = 0;
for (int file = 0; file < 0x7f; file++) {
for (int file = 0; file < CARD_MAX_FILE; file++) {
mFile[slot][file].fileNo = -1;
mFile[slot][file].sortKey = -1;
mFile[slot][file].unk_0x08 = 0;
mFile[slot][file].sortKeyHigh = 0;
mFileCell[slot][file].iconAnmCounter = 0;
wmemset(mFileCell[slot][file].comment[0], 0, 0x40);
}
@@ -342,7 +342,7 @@ void MemoryCardManager::update_change_cardstate(u8 slot) {
}
GXTexObj* MemoryCardManager::create_icon(u8 slot, s16 index) {
memorycard::IconState (*icons)[0x7f] = reinterpret_cast<memorycard::IconState(*)[0x7f]>(memorycard::getIconStateArray());
memorycard::IconState (*icons)[CARD_MAX_FILE] = reinterpret_cast<memorycard::IconState(*)[CARD_MAX_FILE]>(memorycard::getIconStateArray());
int total = 0;
s16 frame = 0;
u32 file = mFile[slot][index].fileNo;
@@ -369,10 +369,10 @@ GXTexObj* MemoryCardManager::_create_icon(u8 slot, s16 file, long start) {
CardIcons* icons = reinterpret_cast<CardIcons*>(memorycard::getIconStateArray());
memorycard::IconState* icon = &icons[slot][file];
if ((int)icon->iconFmt[start] == GX_TF_RGB5A3) {
GXInitTexObj(&mFileCell[slot][file].icon, reinterpret_cast<u8*>(icon) + icon->iconOffset[start], 0x20, 0x20, GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
GXInitTexObj(&mFileCell[slot][file].icon, reinterpret_cast<u8*>(icon) + icon->iconOffset[start], CARD_ICON_WIDTH, CARD_ICON_HEIGHT, GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
GXLoadTexObj(&mFileCell[slot][file].icon, GX_TEXMAP0);
} else if ((int)icon->iconFmt[start] == GX_TF_C8) {
GXInitTexObjCI(&mFileCell[slot][file].icon, reinterpret_cast<u8*>(icon) + icon->iconOffset[start], 0x20, 0x20, GX_TF_C8, GX_CLAMP, GX_CLAMP, GX_FALSE, GX_TLUT0);
GXInitTexObjCI(&mFileCell[slot][file].icon, reinterpret_cast<u8*>(icon) + icon->iconOffset[start], CARD_ICON_WIDTH, CARD_ICON_HEIGHT, GX_TF_C8, GX_CLAMP, GX_CLAMP, GX_FALSE, GX_TLUT0);
GXInitTlutObj(&mFileCell[slot][file].iconTlut, reinterpret_cast<u8*>(icon) + icons[slot][file].iconTlutOffset, GX_TL_RGB5A3, 0x100);
GXLoadTlut(&mFileCell[slot][file].iconTlut, GX_TLUT0);
GXLoadTexObj(&mFileCell[slot][file].icon, GX_TEXMAP0);
@@ -398,7 +398,7 @@ const wchar_t* MemoryCardManager::getComment(u8 slot, s16 index, int which) {
const char* comments = memorycard::getIconComment(slot, file);
memcpy(comment, comments + which * 0x20, 0x20);
const u8* encoded = trimCardComment(comment);
if (SCGetLanguage() == 0) {
if (SCGetLanguage() == SC_LANG_JAPANESE) {
utility::CharacterCode::shiftJISToUTF16(mFileCell[slot][file].comment[which], encoded, 0x20);
for (int pos = 0x1f;
mFileCell[slot][file].comment[which][pos] == 0x20 ||

View File

@@ -806,7 +806,7 @@ namespace ipl {
}
if (System::getDialog()->getLastResult() != -1) {
if (mpSDChannelSelect->getWorker()->get_async_result() == 0) {
if (mpSDChannelSelect->getWorker()->get_async_result() == NandSDWorker::RESULT_OK) {
mNandTitleCount = mTitleListState.mSecondaryCount;
mTitleNameCount = mTitleListState.mNameCount;
} else {
@@ -958,7 +958,7 @@ namespace ipl {
void SDMemory::onDialogState13() {
if (!mpSDChannelSelect->getWorker()->is_working()) {
s32 result = mpSDChannelSelect->getWorker()->get_async_result();
if (result == 0) {
if (result == NandSDWorker::RESULT_OK) {
ESTitleId titleId = mTitleIds[mCurrentTitle];
if (iplSDMemory_containsTitleId(this, titleId,
mNandTitleIds, mNandTitleCount)) {
@@ -967,7 +967,7 @@ namespace ipl {
mDialogState = 13;
}
} else {
if (result > 0) {
if (result > NandSDWorker::RESULT_OK) {
System::getDialog()->terminate();
mDialogState = 20;
mErrorCode = 2;
@@ -1028,12 +1028,12 @@ namespace ipl {
if (!mpSDChannelSelect->getWorker()->is_working()) {
s32 result = mpSDChannelSelect->getWorker()->get_async_result();
if (result == 0) {
if (result == NandSDWorker::RESULT_OK) {
mDialogState = 15;
} else {
System::getDialog()->terminate();
mDialogState = 20;
if (result == -7) {
if (result == NandSDWorker::RESULT_OUT_OF_SPACE) {
mErrorCode = 2;
mMessageId = 0xB5;
} else {
@@ -1069,7 +1069,7 @@ namespace ipl {
const ESTitleId* titleEntry = &mTitleIds[mCurrentTitle];
System::getChannelManager()->unloadBanner(*titleEntry);
if (mpSDChannelSelect->getWorker()->get_async_result() == 0) {
if (mpSDChannelSelect->getWorker()->get_async_result() == NandSDWorker::RESULT_OK) {
mCurrentTitle++;
if (mTitleCount > mCurrentTitle) {
ESTitleId nextTitleId = mTitleIds[mCurrentTitle];
@@ -1114,7 +1114,7 @@ namespace ipl {
void SDMemory::onDialogState19() {
if (!mpSDChannelSelect->getWorker()->is_working()) {
if (mpSDChannelSelect->getWorker()->get_async_result() == 0) {
if (mpSDChannelSelect->getWorker()->get_async_result() == NandSDWorker::RESULT_OK) {
mDialogState = 13;
} else {
System::getDialog()->terminate();

View File

@@ -285,10 +285,10 @@ FaderSceneCommand SDChannelTitle::calcFadein() {
}
if (!mpFade->isPlaying()) {
iplSDChannelTitle_playBannerIntro(this);
SDButton* button = static_cast<SDButton*>(System::getScene(0x24));
SDButton* button = static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON));
button->setEventHandler(mpButtonEventHandler);
button->animation(13);
button->animation(14);
button->animation(SDButton::IDANIM_ARROW_LEFT_APPEAR);
button->animation(SDButton::IDANIM_ARROW_RIGHT_APPEAR);
mState = 1;
return FADER_SCN_NEXT;
} else {
@@ -311,7 +311,7 @@ FaderSceneCommand SDChannelTitle::calcNormal() {
case 15: iplSDChannelTitle_updateCopyStart(this); break;
case 16: iplSDChannelTitle_updateAfterClearTmp(this); break;
case 17: SCSetTmpTitleID(mTitleId); SCFlushAsync(NULL); mState = 18; break;
case 18: if (SCCheckStatus() != 1) { mState = 21; } break;
case 18: if (SCCheckStatus() != SC_STATUS_BUSY) { mState = 21; } break;
case 19: iplSDChannelTitle_startCopyProgress(this); break;
case 20: iplSDChannelTitle_updateCopyPrepare(this); break;
case 23: iplSDChannelTitle_updateMemoryCalc(this); break;
@@ -339,33 +339,33 @@ FaderSceneCommand SDChannelTitle::calcNormal() {
}
void SDChannelTitle::initCalcFadeout() {
SDButton* button = static_cast<SDButton*>(System::getScene(0x24));
SDButton* button = static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON));
if (mState == 5 || mState == 7 || mState == 31) {
System::getFader()->fadeOut();
snd::getSystem()->stopAllSound(20);
OSReport("sound stopped\n");
} else if (mState == 6) {
button->animation(15);
button->animation(16);
button->animation(SDButton::IDANIM_ARROW_LEFT_DISAPPEAR);
button->animation(SDButton::IDANIM_ARROW_RIGHT_DISAPPEAR);
}
button->setEventHandler(NULL);
}
FaderSceneCommand SDChannelTitle::calcFadeout() {
if (mState == 5) {
if (!mWpadStopTick && WPADGetStatus() == 0) {
if (!mWpadStopTick && WPADGetStatus() == WPAD_LIB_STATUS_0) {
mWpadStopTick = OSGetTick();
}
if (System::getFader()->getStatus() == EGG::Fader::PREPARE_IN && System::isReceiveScheduleStopped() &&
(!System::getNwc24Manager() || System::getNwc24Manager()->isReceivingIdle())) {
OSReport("NWC24 Scheduler stopped.\n");
NandSDWorker* worker = mpChannelSelect->getWorker();
if (mNextScene == 17) {
if (mNextScene == SCENE_UNLOCKED_TITLE) {
if (!nandwall::checkNandCapacityAppBootable()) {
OSReport("Nand full! OSRebootSystem.\n");
iplSDChannelTitle_rebootSystem(this);
}
while (WPADGetStatus() != 0 || System::getBS2Manager()->getIPLState() != bs2::IPL_STATE_8 ||
while (WPADGetStatus() != WPAD_LIB_STATUS_0 || System::getBS2Manager()->getIPLState() != bs2::IPL_STATE_8 ||
!System::getSaveData()->isFinished(mpSaveFile) ||
(mScriptEnabled && mScriptState != 4) || (worker && worker->is_working())) {
snd::getSystem()->calc();
@@ -374,7 +374,7 @@ FaderSceneCommand SDChannelTitle::calcFadeout() {
if (mScriptEnabled == 1) {
iplSDChannelTitle_updateScript(this);
}
if (WPADGetStatus() != 0) {
if (WPADGetStatus() != WPAD_LIB_STATUS_0) {
OSReport("wait for WPAD\n");
}
if (System::getBS2Manager()->getIPLState() != bs2::IPL_STATE_8) {
@@ -537,7 +537,7 @@ extern "C" void iplSDChannelTitle_createBannerLayout(SDChannelTitle* scene) {
scene->mpIconLayout->destroyHeap();
scene->mpIconLayout = NULL;
}
if (scene->mpBannerFiles[scene->mLoadedIndex] && scene->mpBannerFiles[scene->mLoadedIndex]->checkData() == 1) {
if (scene->mpBannerFiles[scene->mLoadedIndex] && scene->mpBannerFiles[scene->mLoadedIndex]->checkData() == nand::RESULT_SUCCESS) {
scene->mpBannerLayout = layout::Object::create(scene->mpBannerHeap, 0x40000,
scene->mpBannerFiles[scene->mLoadedIndex], "arc", "banner.brlyt");
iplSDChannelObj_applyLanguageGroups(scene->mpBannerLayout);
@@ -574,7 +574,7 @@ extern "C" void iplSDChannelTitle_createIconLayout(SDChannelTitle* scene) {
}
extern "C" void iplSDChannelTitle_updateIdleState(SDChannelTitle* scene) {
SDButton* button = static_cast<SDButton*>(System::getScene(0x24));
SDButton* button = static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON));
if (button && button->isActive()) {
button->update();
}
@@ -586,11 +586,11 @@ extern "C" void iplSDChannelTitle_updateIdleState(SDChannelTitle* scene) {
controller::Interface* controller = System::getMasterController();
int page;
int index;
if (controller->down(0x30001000)) {
if (controller->down(controller::BTN_NEXT_LEFT)) {
scene->mpChannelSelect->findAdjacentChannel(1, &page, &index);
iplSDChannelTitle_setPageAndIndex(scene, page, index);
snd::getSystem()->startSE("WSD_SELECT");
} else if (controller->down(0x6000010)) {
} else if (controller->down(controller::BTN_NEXT_RIGHT)) {
scene->mpChannelSelect->findAdjacentChannel(0, &page, &index);
iplSDChannelTitle_setPageAndIndex(scene, page, index);
snd::getSystem()->startSE("WSD_SELECT");
@@ -648,11 +648,11 @@ extern "C" void iplSDChannelTitle_updateChangeWait(SDChannelTitle* scene) {
}
extern "C" void iplSDChannelTitle_updateParentalResult(SDChannelTitle* scene) {
ParentalDialog* parental = static_cast<ParentalDialog*>(System::getScene(0x1b));
ParentalDialog* parental = static_cast<ParentalDialog*>(System::getScene(SCENE_PARENTAL_DIALOG));
if (!parental && !System::getReservedScene()) {
if (scene->mParentalResult == 1) {
if (scene->mNextScene == 0x12) {
scene->reserveAllSceneDestruction(0x12, reinterpret_cast<void*>(1));
if (scene->mNextScene == SCENE_SETTING) {
scene->reserveAllSceneDestruction(SCENE_SETTING, reinterpret_cast<void*>(1));
scene->mState = 7;
} else if (scene->mbCopiedTitle) {
scene->mState = 25;
@@ -663,8 +663,8 @@ extern "C" void iplSDChannelTitle_updateParentalResult(SDChannelTitle* scene) {
scene->mState = 29;
} else {
scene->mpButtonAnimations[1][0]->play();
static_cast<SDButton*>(System::getScene(0x24))->animation(13);
static_cast<SDButton*>(System::getScene(0x24))->animation(14);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_LEFT_APPEAR);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_RIGHT_APPEAR);
for (int button = 0; button < 2; ++button) {
scene->mHoverCounts[button] = 0;
scene->mpPaneManager->initPane(scene->mpLayout->FindPaneByName(sButtonNames[button]));
@@ -698,8 +698,8 @@ extern "C" void iplSDChannelTitle_updateDialogResult(SDChannelTitle* scene) {
if (scene->mbCopiedTitle) {
scene->mState = 29;
} else {
static_cast<SDButton*>(System::getScene(0x24))->animation(13);
static_cast<SDButton*>(System::getScene(0x24))->animation(14);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_LEFT_APPEAR);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_RIGHT_APPEAR);
scene->mpButtonAnimations[1][0]->play();
for (int button = 0; button < 2; ++button) {
scene->mHoverCounts[button] = 0;
@@ -714,7 +714,7 @@ extern "C" void iplSDChannelTitle_updateDialogResult(SDChannelTitle* scene) {
if (iplSDChannelTitle_isParentalEnabled()) {
iplSDChannelTitle_openParentalDialog(scene, reinterpret_cast<void*>(1));
} else {
scene->reserveAllSceneDestruction(0x12, reinterpret_cast<void*>(1));
scene->reserveAllSceneDestruction(SCENE_SETTING, reinterpret_cast<void*>(1));
scene->mState = 7;
}
break;
@@ -755,8 +755,8 @@ extern "C" void iplSDChannelTitle_updateCopyPrepare(SDChannelTitle* scene) {
}
{
int result = scene->mpChannelSelect->getWorker()->get_async_result();
if (result == 0 || result == -6) {
if (scene->mpChannelSelect->isCurrentTitleUsageEnough(reinterpret_cast<const s32*>(&scene->mTitleRange))) {
if (result == NandSDWorker::RESULT_OK || result == NandSDWorker::RESULT_ALREADY_EXISTS) {
if (scene->mpChannelSelect->isCurrentTitleUsageEnough(&scene->mTitleRange.mByteSize)) {
scene->mState = 15;
} else {
SDMemory::TitleRange sdRange;
@@ -778,7 +778,7 @@ extern "C" void iplSDChannelTitle_updateCopyPrepare(SDChannelTitle* scene) {
} else if (static_cast<u32>(result + 15) <= 1) {
scene->mState = 26;
scene->mErrorMessage = 0xaf;
} else if (result == -16) {
} else if (result == NandSDWorker::RESULT_VERSION_ERR) {
scene->mState = 26;
scene->mErrorMessage = 199;
} else {
@@ -802,7 +802,7 @@ extern "C" void iplSDChannelTitle_updateMemoryCalc(SDChannelTitle* scene) {
}
switch (static_cast<s32>(scene->mMemory.mErrorCode)) {
case 4:
scene->reserveAllSceneDestruction(0x15, reinterpret_cast<void*>(2));
scene->reserveAllSceneDestruction(SCENE_SETTING_BG, reinterpret_cast<void*>(2));
scene->mState = 31;
return;
case 1:
@@ -878,7 +878,7 @@ extern "C" void iplSDChannelTitle_updateCopyProgress(SDChannelTitle* scene) {
scene->mpProgressLayout->getAnim(2)->initAnmFrame(NandSDWorker::getCompletionPct());
if (!scene->mpChannelSelect->getWorker()->is_working()) {
int result = scene->mpChannelSelect->getWorker()->get_async_result();
if (result == 0 || result == -6) {
if (result == NandSDWorker::RESULT_OK || result == NandSDWorker::RESULT_ALREADY_EXISTS) {
System::getChannelManager()->loadTmpMetaHeader(scene->mTitleId);
scene->mpProgressLayout->getAnim(3)->stop();
snd::getSystem()->stopSE(scene->mpCopySound, 0);
@@ -890,9 +890,9 @@ extern "C" void iplSDChannelTitle_updateCopyProgress(SDChannelTitle* scene) {
SCSetTmpTitleID(0);
SCFlushAsync(NULL);
scene->mState = 26;
if (result == -15) {
if (result == NandSDWorker::RESULT_NOT_TRANSFERRABLE) {
scene->mErrorMessage = 0xaf;
} else if (result == -16) {
} else if (result == NandSDWorker::RESULT_VERSION_ERR) {
scene->mErrorMessage = 199;
} else {
scene->mErrorMessage = 0xae;
@@ -910,7 +910,7 @@ extern "C" void iplSDChannelTitle_showCopyError(SDChannelTitle* scene) {
}
extern "C" void iplSDChannelTitle_updateCopyErrorDialog(SDChannelTitle* scene) {
if (SCCheckStatus() != 1 && System::getDialog()->getLastResult() != -1) {
if (SCCheckStatus() != SC_STATUS_BUSY && System::getDialog()->getLastResult() != -1) {
scene->mState = 29;
}
}
@@ -928,8 +928,8 @@ extern "C" void iplSDChannelTitle_finishProgressHide(SDChannelTitle* scene) {
scene->mpButtonAnimations[6][5]->play();
scene->mpButtonAnimations[1][0]->initAnmFrame();
scene->mpButtonAnimations[1][0]->play();
static_cast<SDButton*>(System::getScene(0x24))->animation(13);
static_cast<SDButton*>(System::getScene(0x24))->animation(14);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_LEFT_APPEAR);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_RIGHT_APPEAR);
System::startReceiveSchedule();
scene->mState = 30;
}
@@ -987,7 +987,7 @@ extern "C" void iplSDChannelTitle_updateTmdReady(SDChannelTitle* scene) {
scene->mMakerCode = scene->mpTmd->head.groupId;
if (!iplSDChannelTitle_isNetworkAllowed(scene, scene->mpTmd, scene->mTitleId)) {
iplSDChannelTitle_confirmLeaveToSettings(scene, false);
scene->mNextScene = 18;
scene->mNextScene = SCENE_SETTING;
} else if (iplSDChannelTitle_passesParentalCheck(scene, scene->mpTmd)) {
iplSDChannelTitle_prepareSceneExit(scene, scene->mNextScene);
if (scene->mbCopiedTitle) {
@@ -1105,7 +1105,7 @@ extern "C" void iplSDChannelTitle_updateScriptLoad(SDChannelTitle* scene) {
if (!scene->mpScriptFile->isFinished()) {
return;
}
if (scene->mpScriptFile->checkData() != 1 && scene->mpScriptFile->checkData() != 0) {
if (scene->mpScriptFile->checkData() != nand::RESULT_SUCCESS && scene->mpScriptFile->checkData() != nand::RESULT_NONE) {
scene->mScriptFrame = 0;
scene->mbScriptFailed = true;
scene->mScriptState = 0;
@@ -1164,7 +1164,7 @@ extern "C" void iplSDChannelTitle_playBannerIntro(SDChannelTitle* scene) {
}
extern "C" void iplSDChannelTitle_startBannerSound(SDChannelTitle* scene) {
if (scene->mpSoundFiles[scene->mLoadedIndex] && scene->mpSoundFiles[scene->mLoadedIndex]->checkData() == 1) {
if (scene->mpSoundFiles[scene->mLoadedIndex] && scene->mpSoundFiles[scene->mLoadedIndex]->checkData() == nand::RESULT_SUCCESS) {
void* sound = scene->mpSoundFiles[scene->mLoadedIndex]->getBuffer();
u32 size = System::getChannelManager()->getSoundSize(scene->mTitleId);
snd::getSystem()->startBannerSound(sound, size, false);
@@ -1244,11 +1244,11 @@ extern "C" BOOL iplSDChannelTitle_isParentalEnabled() {
extern "C" void iplSDChannelTitle_openParentalDialog(SDChannelTitle* scene, void* arguments) {
System::getHomeButtonMenu()->enable();
scene->mbResetAcceptable = true;
if (static_cast<SDButton*>(System::getScene(0x24))->isLeftArrowVisible()) {
static_cast<SDButton*>(System::getScene(0x24))->animation(15);
static_cast<SDButton*>(System::getScene(0x24))->animation(16);
if (static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->isLeftArrowVisible()) {
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_LEFT_DISAPPEAR);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_RIGHT_DISAPPEAR);
}
scene->createChildScene(0x1b, scene, NULL, arguments);
scene->createChildScene(SCENE_PARENTAL_DIALOG, scene, NULL, arguments);
scene->mParentalResult = 0;
scene->mState = 11;
}
@@ -1283,8 +1283,8 @@ extern "C" void iplSDChannelTitle_beginLaunch(SDChannelTitle* scene, SDChannelOb
extern "C" void iplSDChannelTitle_cleanupAndLeave(SDChannelTitle* scene) {
scene->mParentalResult = 0;
scene->mbStartAnimation = false;
static_cast<SDButton*>(System::getScene(0x24))->animation(15);
static_cast<SDButton*>(System::getScene(0x24))->animation(16);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_LEFT_DISAPPEAR);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_RIGHT_DISAPPEAR);
if (scene->mpBannerFiles[scene->mLoadedIndex]) {
delete scene->mpBannerFiles[scene->mLoadedIndex];
}
@@ -1299,12 +1299,12 @@ extern "C" void iplSDChannelTitle_cleanupAndLeave(SDChannelTitle* scene) {
scene->mpSoundFiles[scene->mLoadedIndex] = NULL;
int page;
int index;
bool hasTitle = System::getChannelManager()->hasChannel(scene->mTitleId, &page, &index) != 0;
bool hasTitle = System::getChannelManager()->hasChannel(scene->mTitleId, &page, &index);
bool hasTemporaryTitle = false;
if (scene->mTitleId == SCGetTmpTitleID() && System::getChannelManager()->isLoadedTmp()) {
hasTemporaryTitle = true;
}
scene->mNextScene = 17;
scene->mNextScene = SCENE_UNLOCKED_TITLE;
scene->mbTmdReady = false;
scene->mMakerCode = 0;
scene->mbResetAcceptable = false;
@@ -1324,12 +1324,12 @@ extern "C" void iplSDChannelTitle_cleanupAndLeave(SDChannelTitle* scene) {
extern "C" void iplSDChannelTitle_confirmLeaveToSettings(SDChannelTitle* scene, bool settings) {
if (settings) {
scene->reserveAllSceneDestruction(0x12, reinterpret_cast<void*>(1));
scene->reserveAllSceneDestruction(SCENE_SETTING, reinterpret_cast<void*>(1));
scene->mState = 7;
} else {
if (static_cast<SDButton*>(System::getScene(0x24))->isLeftArrowVisible()) {
static_cast<SDButton*>(System::getScene(0x24))->animation(15);
static_cast<SDButton*>(System::getScene(0x24))->animation(16);
if (static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->isLeftArrowVisible()) {
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_LEFT_DISAPPEAR);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_RIGHT_DISAPPEAR);
}
System::getDialog()->callBtn2(0x143, 0x146, 0x25, false);
scene->mState = 12;
@@ -1345,7 +1345,7 @@ extern "C" void iplSDChannelTitle_prepareSceneExit(SDChannelTitle* scene, int ne
controller->cancelRumbling();
}
}
if (nextScene == 17) {
if (nextScene == SCENE_UNLOCKED_TITLE) {
System::getHomeButtonMenu()->disable();
scene->mbResetAcceptable = false;
}
@@ -1469,11 +1469,11 @@ extern "C" BOOL iplSDChannelTitle_passesParentalCheck(SDChannelTitle* scene, EST
void SDTitlePaneEventHandler::onEvent(u32 component, u32 event, void* data) {
SDTitlePaneEventHandler* handler = this;
const controller::Interface* controller = static_cast<const controller::Interface*>(data);
controller::Interface* controller = static_cast<controller::Interface*>(data);
const char* paneName = handler->getPane(component)->GetName();
switch (event) {
case ::gui::EventHandler::ON_TRIG: {
if (handler->mpScene->mState == 1 && controller->downTrg(0x100800)) {
if (handler->mpScene->mState == 1 && controller->downTrg(controller::BTN_INTERACT)) {
if (strcmp(paneName, sButtonNames[0]) == 0) {
handler->mpScene->mpButtonAnimations[2][2]->play();
snd::getSystem()->startSE("WIPL_SE_BT_PUSH");
@@ -1500,7 +1500,7 @@ void SDTitlePaneEventHandler::onEvent(u32 component, u32 event, void* data) {
if (handler->mpScene->mHoverCounts[button] <= 1) {
handler->mpScene->mpButtonAnimations[button][1]->play();
snd::getSystem()->startSE("WIPL_SE_BT_TARGETTING");
const_cast<controller::Interface*>(controller)->rumble(0);
controller->rumble(0);
break;
}
}
@@ -1531,21 +1531,21 @@ void SDTitleButtonEventHandler::onEventDerived(u32 component, u32 event, const c
SDTitleButtonEventHandler* handler = this;
const char* name = handler->getPane(component)->GetName();
switch (event) {
case 0:
if (handler->mpScene->mState == 1 && controller->downTrg(0x100800)) {
SDButton* button = static_cast<SDButton*>(System::getScene(0x24));
case ::gui::EventHandler::ON_TRIG:
if (handler->mpScene->mState == 1 && controller->downTrg(controller::BTN_INTERACT)) {
SDButton* button = static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON));
if (strcmp(name, SDButton::getButtonName(SDButton::BTN_ARROW_LEFT)) == 0) {
int page;
int index;
handler->mpScene->mpChannelSelect->findAdjacentChannel(1, &page, &index);
button->animation(7);
button->animation(SDButton::IDANIM_ARROW_LEFT_CLICK);
iplSDChannelTitle_setPageAndIndex(handler->mpScene, page, index);
snd::getSystem()->startSE("WSD_SELECT");
} else if (strcmp(name, SDButton::getButtonName(SDButton::BTN_ARROW_RIGHT)) == 0) {
int page;
int index;
handler->mpScene->mpChannelSelect->findAdjacentChannel(0, &page, &index);
button->animation(8);
button->animation(SDButton::IDANIM_ARROW_RIGHT_CLICK);
iplSDChannelTitle_setPageAndIndex(handler->mpScene, page, index);
snd::getSystem()->startSE("WSD_SELECT");
}

View File

@@ -109,7 +109,7 @@ namespace ipl {
System::getProjectionRect(&proj16x9);
System::getProjectionRect4x3(&proj4x3);
if (mbUse16x9X == 0) {
if (!mbUse16x9X) {
mBalloonPos.x *= proj4x3.GetWidth() / proj16x9.GetWidth();
}
}
@@ -122,7 +122,7 @@ namespace ipl {
System::getProjectionRect(&proj16x9);
System::getProjectionRect4x3(&proj4x3);
if (mbUse16x9X == 0) {
if (!mbUse16x9X) {
mBalloonPos.x *= proj4x3.GetWidth() / proj16x9.GetWidth();
}
@@ -192,7 +192,7 @@ namespace ipl {
}
}
if (mbUse16x9X == 0) {
if (!mbUse16x9X) {
alignmentOffset *= proj4x3.GetWidth() / proj16x9.GetWidth();
}

View File

@@ -130,7 +130,7 @@ BOOL TVRCInit(void* pRsrc) {
return FALSE;
}
if (ARCInitHandle(pRsrc, &_database) == FALSE) {
if (!ARCInitHandle(pRsrc, &_database)) {
_lastError = 4;
return FALSE;
}
@@ -154,10 +154,10 @@ BOOL TVRCSetModelType(int makerID, int typeNo, void* pFileData, int length) {
ARCFileInfo file;
if (_isInitialized == FALSE || _database.archiveStartAddr == NULL) {
if (!_isInitialized || _database.archiveStartAddr == NULL) {
return FALSE;
}
if (((ARCHeader*)_database.archiveStartAddr)->magic != ARC_MAGIC) {
if (static_cast<ARCHeader*>(_database.archiveStartAddr)->magic != ARC_MAGIC) {
return FALSE;
}
if (makerID == _makerID && typeNo == _typeNo) {
@@ -177,7 +177,7 @@ BOOL TVRCSetModelType(int makerID, int typeNo, void* pFileData, int length) {
}
ARCCloseDir(&dir);
if (ARCFastOpen(&_database, dirEntry.entryNum, &file) == FALSE) {
if (!ARCFastOpen(&_database, dirEntry.entryNum, &file)) {
_lastError = 6;
return FALSE;
}
@@ -188,7 +188,7 @@ BOOL TVRCSetModelType(int makerID, int typeNo, void* pFileData, int length) {
}
memcpy(pFileData, ARCGetStartAddrInMem(&file), fileLen);
_tvrcFile = (_FileData*)pFileData;
_tvrcFile = static_cast<_FileData*>(pFileData);
_makerID = makerID;
_typeNo = typeNo;
_database.archiveStartAddr = NULL;
@@ -478,13 +478,13 @@ void LibTVRC::__FTVRCLoop0Handler(OSAlarm* alarm, OSContext* ctx) {
namespace LibTVRC {
void __FTVRCLoop1Handler(OSAlarm *alarm, OSContext *ctx) {
if (_ctCombo != 0 && _isActive != 0) {
if (_ctCombo != 0 && _isActive) {
if (_func1state == -1) {
_unitStartTime = OSGetTime();
_func1state = 0;
}
if (_isLastOnOff != 0) {
if (_isLastOnOff) {
_unitLastTime = OSGetTime();
if (_func1state == 0) {
@@ -494,7 +494,7 @@ namespace LibTVRC {
return;
}
BOOL active = (int)(_unitLastTime - _unitStartTime) < (int)(*(u32*)&_tickT * _ctCombo);
BOOL active = (int)(_unitLastTime - _unitStartTime) < (int)(_tickT * _ctCombo);
WPADSetSensorBarPower(FALSE);
_func1state = 0;
if (active) {
@@ -504,7 +504,7 @@ namespace LibTVRC {
}
} else {
WPADSetSensorBarPower(FALSE);
OSSetAlarm(&_alarm, *(u32*)&_tickT * _ctCombo, __FTVRCLoop0Handler);
OSSetAlarm(&_alarm, _tickT * _ctCombo, __FTVRCLoop0Handler);
}
}
}

View File

@@ -232,14 +232,14 @@ namespace ipl {
int Manager::getNumValidChannel() const {
const ChannelSlot* q;
int dens = 12;
int dens = MAX_CHANNEL_INDEX;
const ChannelPage* p;
int slot;
int count = 0;
int page;
u8 flag;
s32 val;
for (page = 0; page < 4; page++) {
for (page = 0; page < MAX_CHANNEL_PAGE; page++) {
p = (const ChannelPage*)((const u8*)this + page * 0xc0);
for (slot = 0; slot < dens; slot++) {
q = &p->slots[slot];
@@ -471,14 +471,14 @@ namespace ipl {
checkSpecialTitles(titleIds, titleCount);
checkTmpTitle(titleIds, titleCount);
ESTitleId unk[MAX_CHANNEL_TOTAL] = {0};
ESTitleId prioritizedTitleIds[MAX_CHANNEL_TOTAL] = {0};
makePriorTitleIDList(unk, titleIds, titleCount);
integrateTitleIDList(unk, titleIds, titleCount);
makePriorTitleIDList(prioritizedTitleIds, titleIds, titleCount);
integrateTitleIDList(prioritizedTitleIds, titleIds, titleCount);
delete[] titleIds;
return doUpdateChanInfos(unk);
return doUpdateChanInfos(prioritizedTitleIds);
}
void Manager::deleteInvalidTitle(ESTitleId* titleIds, u32 titleCount) {
@@ -925,7 +925,7 @@ namespace ipl {
}
int Manager::getAvailableInList(const ESTitleId* titleIds, u32 titleCount) {
int dens = 12;
int dens = MAX_CHANNEL_INDEX;
u32 i;
for (i = 0; i < titleCount; i++) {
if (titleIds[i] == 0) {

View File

@@ -12,11 +12,11 @@ enum {
enum {
ODH_ERROR_SUCCESS = 0,
ODH_ERROR_80000001 = 0x80000001,
ODH_ERROR_80000002 = 0x80000002,
ODH_ERROR_80000003 = 0x80000003,
ODH_ERROR_80000004 = 0x80000004,
ODH_ERROR_80000005 = 0x80000005,
ODH_ERROR_INVALID_DIMENSIONS = 0x80000001,
ODH_ERROR_INVALID_QUALITY = 0x80000002,
ODH_ERROR_INVALID_BITSTREAM = 0x80000003,
ODH_ERROR_OUTPUT_FULL = 0x80000004,
ODH_ERROR_INVALID_HEADER = 0x80000005,
};
struct SArDeconvTbl {
@@ -41,7 +41,7 @@ struct SArCDJ_OdhMaster {
u16 width;
u16 height;
u8 quality;
u8 field5;
u8 reservedAlignment;
u16 blocksWide;
u16 blocksHigh;
u16 blockX;
@@ -52,9 +52,9 @@ struct SArCDJ_OdhMaster {
u32 bitCount;
u32 outputPos;
u32 remaining;
u32 field20;
u32 field24;
u32 field28;
u32 lumaDCPredictor;
u32 cbDCPredictor;
u32 crDCPredictor;
u8* workBuffer;
u32 dcCoefficients[64];
u32 coefficients[64];
@@ -591,19 +591,19 @@ s32 CArGBAOdh::decompressGbaOdh(u8* src, int srcSize, u8* dest, int destSize, u8
}
s32 result = cdj_d_initializeDecompressOdh(&master, work, src);
if (result != 0) {
if (result != ODH_ERROR_SUCCESS) {
OSReport("decompressGbaOdh : INITIALIZE ERROR %08x\n", result);
return 0;
}
result = cdj_d_decompressLoop(&master, srcSize, workSize);
if (result != 0) {
if (result != ODH_ERROR_SUCCESS) {
OSReport("decompressGbaOdh : DECOMPRESSING ERROR %08x\n", result);
return 0;
}
result = cdj_d_colorDeconv(&master, dest, format);
if (result != 0) {
if (result != ODH_ERROR_SUCCESS) {
OSReport("decompressGbaOdh : COLOR DECONVERSION ERROR %08x\n", result);
return 0;
}
@@ -631,7 +631,7 @@ s32 CArGBAOdh::compressGbaOdh(u8* src, u8* dest, int width, int height, int qual
}
result = cdj_c_compressLoop(&master);
int retry = 1;
while (result == ODH_ERROR_80000004) {
while (result == ODH_ERROR_OUTPUT_FULL) {
OSReport("compressGbaOdh : COMPRESS OVER AND RETRY %d q=%d, %08x\n", retry++, master.quality, result);
quality -= 5;
if (quality > 0) {
@@ -654,10 +654,10 @@ s32 CArGBAOdh::cdj_c_initializeCompressOdh(SArCDJ_OdhMaster* master, u16* dimens
u32 quantizationScale;
s32 result;
if ((((*dimensions == 0) || (0x7FF < *dimensions)) || (dimensions[1] == 0)) || (0x7FF < dimensions[1])) {
result = ODH_ERROR_80000001;
if (*dimensions == 0 || 0x7FF < *dimensions || dimensions[1] == 0 || 0x7FF < dimensions[1]) {
result = ODH_ERROR_INVALID_DIMENSIONS;
} else if (requestedQuality > 0x64) {
result = ODH_ERROR_80000002;
result = ODH_ERROR_INVALID_QUALITY;
} else {
master->workBuffer = workBuffer;
master->data = outputBuffer;
@@ -668,8 +668,8 @@ s32 CArGBAOdh::cdj_c_initializeCompressOdh(SArCDJ_OdhMaster* master, u16* dimens
master->blocksWide = (s32)dimensionMinusOne / 8 + 1;
dimensionMinusOne = dimensions[1] - 1;
master->blocksHigh = (s32)dimensionMinusOne / 8 + 1;
master->luminanceRequest.predictors[0] = &master->field20;
master->luminanceRequest.predictors[1] = &master->field20;
master->luminanceRequest.predictors[0] = &master->lumaDCPredictor;
master->luminanceRequest.predictors[1] = &master->lumaDCPredictor;
master->luminanceRequest.dcTable = (u32*)gArDC_L_Table;
master->luminanceRequest.acTable = (u32*)gArDC_L_Table;
master->luminanceRequest.bitstream = outputBuffer;
@@ -677,8 +677,8 @@ s32 CArGBAOdh::cdj_c_initializeCompressOdh(SArCDJ_OdhMaster* master, u16* dimens
master->luminanceRequest.bitBuffer = &master->bitBuffer;
master->luminanceRequest.bitCount = &master->bitCount;
master->luminanceRequest.bytesConsumed = outputCapacity;
master->chrominanceRequest.predictors[0] = &master->field24;
master->chrominanceRequest.predictors[1] = &master->field28;
master->chrominanceRequest.predictors[0] = &master->cbDCPredictor;
master->chrominanceRequest.predictors[1] = &master->crDCPredictor;
master->chrominanceRequest.dcTable = (u32*)gArDC_C_Table;
master->chrominanceRequest.acTable = (u32*)gArDC_L_Table;
master->chrominanceRequest.bitstream = outputBuffer;
@@ -691,7 +691,7 @@ s32 CArGBAOdh::cdj_c_initializeCompressOdh(SArCDJ_OdhMaster* master, u16* dimens
quality = 1;
}
if (quality < 0x32) {
quantizationScale = 5000U / (u32)quality;
quantizationScale = 5000U / quality;
} else {
quantizationScale = 200 - (quality << 1);
}
@@ -702,9 +702,9 @@ s32 CArGBAOdh::cdj_c_initializeCompressOdh(SArCDJ_OdhMaster* master, u16* dimens
master->bitCount = 0x20;
master->outputPos = outputCapacity;
master->remaining = outputCapacity - 0x10;
master->field20 = 0;
master->field24 = 0;
master->field28 = 0;
master->lumaDCPredictor = 0;
master->cbDCPredictor = 0;
master->crDCPredictor = 0;
result = 0;
}
@@ -720,7 +720,7 @@ s32 CArGBAOdh::cdj_c_compressLoop(SArCDJ_OdhMaster* master) {
int columnOffset = (u32)master->blockX << 3;
workOffset = blocksWide * rowOffset + columnOffset;
u32 stride = (u32)master->blocksWide << 3;
fdct_fast(master->coefficients, (u8*)((u32)master->workBuffer + workOffset), stride,
fdct_fast(master->coefficients, master->workBuffer + workOffset, stride,
master->quantizationTables);
for (int i = 0; i < 0x40; i++) {
u8 index = odh_zigzag_order[i];
@@ -728,8 +728,8 @@ s32 CArGBAOdh::cdj_c_compressLoop(SArCDJ_OdhMaster* master) {
}
master->coefficients[0] = 0x40004000;
statusOrOffset = huffmanCoder((u16*)master->dcCoefficients - 1, &master->luminanceRequest);
if (statusOrOffset == ODH_ERROR_80000004) {
statusOrOffset = ODH_ERROR_80000004;
if (statusOrOffset == ODH_ERROR_OUTPUT_FULL) {
statusOrOffset = ODH_ERROR_OUTPUT_FULL;
goto done;
}
int nextBlocksWide = master->blocksWide;
@@ -738,14 +738,14 @@ s32 CArGBAOdh::cdj_c_compressLoop(SArCDJ_OdhMaster* master) {
statusOrOffset = blocksHigh * rowStride;
workOffset = workOffset + statusOrOffset;
u32 nextStride = (u32)nextBlocksWide << 3;
fdct_fast(master->coefficients, (u8*)((u32)master->workBuffer + workOffset), nextStride,
fdct_fast(master->coefficients, master->workBuffer + workOffset, nextStride,
master->quantizationTables + 64);
for (int i = 0; i < 0x40; i++) {
u8 index = odh_zigzag_order[i];
master->dcCoefficients[index] = master->coefficients[i] & 0xFFFF;
}
workOffset += (u32)master->blocksHigh * ((u32)master->blocksWide << 6);
fdct_fast(master->coefficients, (u8*)((u32)master->workBuffer + workOffset),
fdct_fast(master->coefficients, master->workBuffer + workOffset,
(u32)master->blocksWide << 3, master->quantizationTables + 64);
for (int i = 0; i < 0x40; i++) {
u8 index = odh_zigzag_order[i];
@@ -754,8 +754,8 @@ s32 CArGBAOdh::cdj_c_compressLoop(SArCDJ_OdhMaster* master) {
}
master->coefficients[0] = 0x40004000;
statusOrOffset = huffmanCoder((u16*)master->dcCoefficients, &master->chrominanceRequest);
if (statusOrOffset == ODH_ERROR_80000004) {
statusOrOffset = ODH_ERROR_80000004;
if (statusOrOffset == ODH_ERROR_OUTPUT_FULL) {
statusOrOffset = ODH_ERROR_OUTPUT_FULL;
goto done;
}
int nextBlockX = master->blockX + 1;
@@ -766,8 +766,8 @@ s32 CArGBAOdh::cdj_c_compressLoop(SArCDJ_OdhMaster* master) {
}
} while (master->blockY < master->blocksHigh);
statusOrOffset = cdj_c_flashBuffer(master);
if (statusOrOffset == ODH_ERROR_80000004) {
statusOrOffset = ODH_ERROR_80000004;
if (statusOrOffset == ODH_ERROR_OUTPUT_FULL) {
statusOrOffset = ODH_ERROR_OUTPUT_FULL;
} else {
cdj_c_makeHeader(master, master->outputPos - master->remaining);
statusOrOffset = master->outputPos - master->remaining;
@@ -782,7 +782,7 @@ s32 CArGBAOdh::cdj_c_flashBuffer(SArCDJ_OdhMaster* master) {
while (master->bitCount <= 0x18) {
if (master->remaining == 0) {
return ODH_ERROR_80000004;
return ODH_ERROR_OUTPUT_FULL;
}
master->data[master->outputPos - master->remaining] = master->bitBuffer >> 24;
@@ -869,11 +869,11 @@ s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int for
workPlane = master->workBuffer;
cbPlane = workPlane + (u32)paddedDimensions[0] * (u32)paddedDimensions[1];
crPlane = cbPlane + (u32)paddedDimensions[0] * (u32)paddedDimensions[1];
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
sourceStride = (width & 0xFFFC) << 3;
} else {
sourceStride = (width & 0xFFF8) << 2;
if (format == 1) {
if (format == ODH_FORMAT_RGBA8) {
sourceStride = (width & 0xFFFC) << 4;
}
}
@@ -892,7 +892,7 @@ s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int for
void CArGBAOdh::LineConv11(u8* source, u8* lumaOutput, u8* cbOutput, u8* crOutput, u16 width, u16 height,
const long* conversionTable, int format) {
u32 planeSize = (u32)width * (u32)height;
const s32* table = (const s32*)conversionTable;
const s32* table = conversionTable;
u32 pixelIndex = 0;
for (int i = 0; i < width; i++) {
@@ -900,14 +900,14 @@ void CArGBAOdh::LineConv11(u8* source, u8* lumaOutput, u8* cbOutput, u8* crOutpu
s32 green;
s32 blue;
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
u8* pixelSource = source + (pixelIndex & 0x1FFFFFFC) * 8 + (pixelIndex & 3) * 2;
u16 pixel = pixelSource[1];
pixel |= (u16)pixelSource[0] << 8;
red = (pixel >> 11) & 0x1F;
green = (pixel >> 6) & 0x1F;
blue = pixel & 0x1F;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
int blueOrPixelOffset = (pixelIndex & 0xFFFFFFFC) * 0x10 + (pixelIndex & 3) * 2;
u8* pixel = source + blueOrPixelOffset;
red = pixel[1] >> 3;
@@ -1101,8 +1101,8 @@ s32 CArGBAOdh::huffmanCoder(u16* coefficientInput, SArCDJ_HuffmanRequest* reques
code = request->dcTable[bitCount];
magnitude = (difference & ((1 << bitCount) - 1)) | ((code & 0xFFFFFF) << bitCount);
code = (s32)code >> 24;
if (EmitBit(magnitude, code + bitCount, request) == ODH_ERROR_80000004) {
return ODH_ERROR_80000004;
if (EmitBit(magnitude, code + bitCount, request) == ODH_ERROR_OUTPUT_FULL) {
return ODH_ERROR_OUTPUT_FULL;
}
while (true) {
@@ -1132,8 +1132,8 @@ s32 CArGBAOdh::huffmanCoder(u16* coefficientInput, SArCDJ_HuffmanRequest* reques
code = request->acTable[bitCount];
magnitude = (runLength & ((1 << bitCount) - 1)) | ((code & 0xFFFFFF) << bitCount);
code = (s32)code >> 24;
if (EmitBit(magnitude, code + bitCount, request) == ODH_ERROR_80000004) {
return ODH_ERROR_80000004;
if (EmitBit(magnitude, code + bitCount, request) == ODH_ERROR_OUTPUT_FULL) {
return ODH_ERROR_OUTPUT_FULL;
}
if (value < 0) {
@@ -1153,15 +1153,15 @@ s32 CArGBAOdh::huffmanCoder(u16* coefficientInput, SArCDJ_HuffmanRequest* reques
code = request->dcTable[bitCount];
magnitude = (value & ((1 << bitCount) - 1)) | ((code & 0xFFFFFF) << bitCount);
code = (s32)code >> 24;
if (EmitBit(magnitude, code + bitCount, request) == ODH_ERROR_80000004) {
return ODH_ERROR_80000004;
if (EmitBit(magnitude, code + bitCount, request) == ODH_ERROR_OUTPUT_FULL) {
return ODH_ERROR_OUTPUT_FULL;
}
}
if (runLength != 0) {
code = request->acTable[7];
if (EmitBit(code & 0xFFFFFF, (s32)code >> 24, request) == ODH_ERROR_80000004) {
return ODH_ERROR_80000004;
if (EmitBit(code & 0xFFFFFF, (s32)code >> 24, request) == ODH_ERROR_OUTPUT_FULL) {
return ODH_ERROR_OUTPUT_FULL;
}
}
@@ -1181,7 +1181,7 @@ s32 CArGBAOdh::EmitBit(long bits, long bitCount, SArCDJ_HuffmanRequest* request)
while (*request->bitCount <= 0x18) {
if (*request->remaining == 0) {
return ODH_ERROR_80000004;
return ODH_ERROR_OUTPUT_FULL;
}
*this->outputCursor = (u8)(*request->bitBuffer >> 0x18);
@@ -1204,9 +1204,9 @@ s32 CArGBAOdh::cdj_d_initializeDecompressOdh(SArCDJ_OdhMaster* master, u8* workB
s32 result;
u32 width;
if (!(((sourceData[0] == 'A') && (sourceData[1] == 'J')) &&
((sourceData[2] == 'P') && (sourceData[3] == 'G')))) {
return ODH_ERROR_80000005;
if (sourceData[0] != 'A' || sourceData[1] != 'J' ||
sourceData[2] != 'P' || sourceData[3] != 'G') {
return ODH_ERROR_INVALID_HEADER;
}
const u32* headerWords = (const u32*)sourceData;
@@ -1222,11 +1222,11 @@ s32 CArGBAOdh::cdj_d_initializeDecompressOdh(SArCDJ_OdhMaster* master, u8* workB
headerQuality = headerWords[1];
master->quality = (u8)(headerQuality >> 0x18);
if (((width == 0) || (0x7FF < width)) ||
((height == 0) || (0x7FF < height))) {
result = ODH_ERROR_80000001;
if (width == 0 || 0x7FF < width ||
height == 0 || 0x7FF < height) {
result = ODH_ERROR_INVALID_DIMENSIONS;
} else if ((headerQuality >> 0x18) > 0x64) {
result = ODH_ERROR_80000002;
result = ODH_ERROR_INVALID_QUALITY;
} else {
master->workBuffer = workBuffer;
sourceData += 0x10;
@@ -1237,16 +1237,16 @@ s32 CArGBAOdh::cdj_d_initializeDecompressOdh(SArCDJ_OdhMaster* master, u8* workB
master->blockX = 0;
master->blockY = 0;
master->bitCount = 0;
master->field20 = 0;
master->field24 = 0;
master->field28 = 0;
master->luminanceRequest.predictors[0] = &master->field20;
master->luminanceRequest.predictors[1] = &master->field20;
master->lumaDCPredictor = 0;
master->cbDCPredictor = 0;
master->crDCPredictor = 0;
master->luminanceRequest.predictors[0] = &master->lumaDCPredictor;
master->luminanceRequest.predictors[1] = &master->lumaDCPredictor;
master->luminanceRequest.bitstream = sourceData;
master->luminanceRequest.bitCount = &master->bitCount;
master->luminanceRequest.bytesConsumed = 0x10;
master->chrominanceRequest.predictors[0] = &master->field24;
master->chrominanceRequest.predictors[1] = &master->field28;
master->chrominanceRequest.predictors[0] = &master->cbDCPredictor;
master->chrominanceRequest.predictors[1] = &master->crDCPredictor;
master->chrominanceRequest.bitstream = sourceData;
master->chrominanceRequest.bitCount = &master->bitCount;
master->chrominanceRequest.bytesConsumed = 0x10;
@@ -1290,7 +1290,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
master->chrominanceRequest.bitstream = master->luminanceRequest.bitstream;
master->chrominanceRequest.bytesConsumed = master->luminanceRequest.bytesConsumed;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1307,7 +1307,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
rowStride);
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 1, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1327,7 +1327,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 2, sourceLimit);
master->luminanceRequest.bitstream = master->chrominanceRequest.bitstream;
master->luminanceRequest.bytesConsumed = master->chrominanceRequest.bytesConsumed;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1347,7 +1347,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
else if ((xSampling == 2U) && (master->ySampling == 1U)) {
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1366,7 +1366,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
master->chrominanceRequest.bitstream = master->luminanceRequest.bitstream;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1381,7 +1381,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
(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;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1400,7 +1400,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 2, sourceLimit);
master->luminanceRequest.bitstream = master->chrominanceRequest.bitstream;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1420,7 +1420,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
else if ((xSampling == 1U) && (master->ySampling == 2U)) {
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1438,7 +1438,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
master->chrominanceRequest.bitstream = master->luminanceRequest.bitstream;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1454,7 +1454,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
,rowStride);
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 1, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1473,7 +1473,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 2, sourceLimit);
master->luminanceRequest.bitstream = master->chrominanceRequest.bitstream;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1493,7 +1493,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
else if ((xSampling == 2U) && (master->ySampling == 2U)) {
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1511,7 +1511,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
, ((u32)blockWidth << 4));
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1528,7 +1528,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
, ((u32)blockWidth << 4));
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1547,7 +1547,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
master->chrominanceRequest.bitstream = master->luminanceRequest.bitstream;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1562,7 +1562,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
(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;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1581,7 +1581,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 2, sourceLimit);
master->luminanceRequest.bitstream = master->chrominanceRequest.bitstream;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1646,11 +1646,11 @@ s32 CArGBAOdh::cdj_d_colorDeconv(SArCDJ_OdhMaster* master, u8* destination, int
s32 lineStride;
s32 format = outputFormat;
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
lineStride = (width & 0xFFFC) << 3;
} else {
lineStride = (width & 0xFFF8) << 2;
if (format == 1) {
if (format == ODH_FORMAT_RGBA8) {
lineStride = (width & 0xFFFC) << 4;
}
}
@@ -1730,12 +1730,12 @@ void CArGBAOdh::LineDeconv11(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
pixelOutput = dest + (pixelIndex & 0x1FFFFFFC) * 8 + (pixelIndex & 3) * 2;
*pixelOutput = (u8)(redValue >> 8);
pixelOutput[1] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
pixelOutput = dest + (pixelIndex & 0x0FFFFFFC) * 0x10 + (pixelIndex & 3) * 2;
*pixelOutput = 0xFF;
pixelOutput[1] = (u8)redValue;
@@ -1786,13 +1786,13 @@ void CArGBAOdh::LineDeconv21(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
offset = (pixelIndex & 0x1FFFFFFC) * 8 + (pixelIndex & 3) * 2;
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
dest[offset] = (u8)(redValue >> 8);
pixelOutput = dest + offset;
pixelOutput[1] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
offset = (pixelIndex & 0x0FFFFFFC) * 0x10 + (pixelIndex & 3) * 2;
dest[offset] = 0xFF;
pixelOutput = dest + offset;
@@ -1812,11 +1812,11 @@ void CArGBAOdh::LineDeconv21(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
pixelOutput[2] = (u8)(redValue >> 8);
pixelOutput[3] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
pixelOutput[2] = 0xFF;
pixelOutput[3] = (u8)redValue;
pixelOutput[0x22] = (u8)greenValue;
@@ -1852,12 +1852,12 @@ void CArGBAOdh::LineDeconv12(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
offset = (pixelIndex & 0x1FFFFFFC) * 8 + (pixelIndex & 3) * 2;
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
dest[offset] = (u8)(redValue >> 8);
dest[offset + 1] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
offset = (pixelIndex & 0x0FFFFFFC) * 0x10 + (pixelIndex & 3) * 2;
dest[offset] = 0xFF;
dest[offset + 1] = (u8)redValue;
@@ -1875,11 +1875,11 @@ void CArGBAOdh::LineDeconv12(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
dest[offset + 8] = (u8)(redValue >> 8);
dest[offset + 9] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
dest[offset + 8] = 0xFF;
dest[offset + 9] = (u8)redValue;
dest[offset + 0x28] = (u8)greenValue;
@@ -1918,12 +1918,12 @@ void CArGBAOdh::LineDeconv22(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
offset = (pixelIndex & 0x1FFFFFFC) * 8 + (pixelIndex & 3) * 2;
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
dest[offset] = (u8)(redValue >> 8);
dest[offset + 1] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
offset = (pixelIndex & 0x0FFFFFFC) * 0x10 + (pixelIndex & 3) * 2;
dest[offset] = 0xFF;
dest[offset + 1] = (u8)redValue;
@@ -1941,11 +1941,11 @@ void CArGBAOdh::LineDeconv22(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
dest[offset + 2] = (u8)(redValue >> 8);
dest[offset + 3] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
dest[offset + 2] = 0xFF;
dest[offset + 3] = (u8)redValue;
dest[offset + 0x22] = (u8)greenValue;
@@ -1964,11 +1964,11 @@ void CArGBAOdh::LineDeconv22(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
dest[offset + 8] = (u8)(redValue >> 8);
dest[offset + 9] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
dest[offset + 8] = 0xFF;
dest[offset + 9] = (u8)redValue;
dest[offset + 0x28] = (u8)greenValue;
@@ -1985,11 +1985,11 @@ void CArGBAOdh::LineDeconv22(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
dest[offset + 10] = (u8)(redValue >> 8);
dest[offset + 11] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
dest[offset + 10] = 0xFF;
dest[offset + 11] = (u8)redValue;
dest[offset + 0x2a] = (u8)greenValue;
@@ -2026,7 +2026,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
sourceCursor = request->bitstream;
u32 bitOffset = *request->bitCount;
if ((u32)(bytesConsumed + 4) > sourceLimit) {
decodeResult = 0x80000003;
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
} else {
maximumBitLength = 0xB;
bitBuffer = ((u32)*sourceCursor << 0x18) | ((u32)sourceCursor[1] << 0x10) | ((u32)sourceCursor[2] << 8) | sourceCursor[3];
@@ -2056,7 +2056,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
}
}
if (bitIndex > maxHuffmanBits) {
decodeResult = 0x80000003;
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
} else {
if (valueCategory > 0) {
bitCountAndMask = (1 << (valueCategory)) - 1;
@@ -2070,7 +2070,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
u32** predictors = request->predictors;
u32* predictor = predictors[component >> 1];
bitCountAndMask = bitOffset + bitIndex + valueCategory;
tableIndex = (u32)(bitCountAndMask >> 3);
tableIndex = (bitCountAndMask >> 3);
decodedSymbol = 1;
bitIndex = (int)bitBuffer + *predictor;
*coefficientOutput = bitIndex;
@@ -2082,7 +2082,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
}
do {
if ((u32)(bytesConsumed + 4) > sourceLimit) {
decodeResult = 0x80000003;
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
goto finishDecode;
}
bitIndex = 1;
@@ -2109,12 +2109,12 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
bitIndex++;
}
if (bitIndex > 6) {
decodeResult = 0x80000003;
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
goto finishDecode;
}
if (valueCategory == 7) {
bitCountAndMask += bitIndex;
tableIndex = (u32)(bitCountAndMask >> 3);
tableIndex = (bitCountAndMask >> 3);
while (bitCountAndMask >= 8) {
sourceCursor++;
bytesConsumed++;
@@ -2123,10 +2123,10 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
break;
}
if (valueCategory > 0) {
tableIndex = (u32)(u32)(1 << (valueCategory)) - 1 &
(u32)(bitBuffer >> ((0x20 - bitIndex) - valueCategory));
tableIndex = (u32)(1 << (valueCategory)) - 1 &
(bitBuffer >> ((0x20 - bitIndex) - valueCategory));
if ((tableIndex & (u32)(1 << (valueCategory - 1))) == 0) {
decodeResult = 0x80000003;
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
goto finishDecode;
}
} else {
@@ -2137,14 +2137,14 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
decodedSymbol++;
}
bitCountAndMask = bitCountAndMask + bitIndex + valueCategory;
tableIndex = (u32)(bitCountAndMask >> 3);
tableIndex = (bitCountAndMask >> 3);
while (bitCountAndMask >= 8) {
sourceCursor++;
bytesConsumed++;
bitCountAndMask -= 8;
}
if ((u32)(bytesConsumed + 4) > sourceLimit) {
decodeResult = 0x80000003;
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
goto finishDecode;
}
maximumBitLength = 0xB;
@@ -2174,7 +2174,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
}
}
if (bitIndex > maxHuffmanBits) {
decodeResult = 0x80000003;
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
goto finishDecode;
}
if (valueCategory > 0) {
@@ -2188,7 +2188,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
}
bitCountAndMask = bitCountAndMask + bitIndex + valueCategory;
coefficientOutput[decodedSymbol] = bitBuffer;
tableIndex = (u32)(bitCountAndMask >> 3);
tableIndex = (bitCountAndMask >> 3);
decodedSymbol = decodedSymbol + 1;
while (bitCountAndMask >= 8) {
sourceCursor++;

View File

@@ -138,7 +138,7 @@ namespace ipl {
BOOL ESMisc::ContentExist(ESTmdView* tmdView, u32 contentIndex, s32* result) {
u32 numContents;
u32 contents[512] ALIGN32;
u32 contents[ES_MAX_CONTENT] ALIGN32;
ESTitleId titleId = tmdView->head.titleId;
@@ -282,7 +282,7 @@ namespace ipl {
ESTicketView* ticketView;
if (ticket == NULL) {
if (GetTicketViewList(heap, titleId, &ticket, &ticketLength) < 0) {
if (GetTicketViewList(heap, titleId, &ticket, &ticketLength) < ES_ERR_OK) {
if (ticket != NULL) {
heap->free(ticket);
}
@@ -291,9 +291,9 @@ namespace ipl {
allocated = true;
}
ticketView = (ESTicketView*)heap->alloc(0xe0, -32);
ticketView = (ESTicketView*)heap->alloc(0xe0, -DEFAULT_ALIGN);
if (ESP_InitLib() < 0) {
if (ESP_InitLib() < ES_ERR_OK) {
goto error;
}
@@ -307,7 +307,7 @@ namespace ipl {
index = 0;
}
memcpy(ticketView, (u8*)ticket + index * 0xd8, 0xd8);
memcpy(ticketView, &ticket[index], sizeof(ESTicketView));
{
ESFd fd = ES_OpenTitleContentFile(titleId, ticketView, 0);
@@ -315,18 +315,18 @@ namespace ipl {
if (fd < 0) {
OSReport("ESMisc::GetValidTicketIndex: ES_OpenTitleContentFile fd %d\n", fd);
} else {
char* buf = (char*)heap->alloc(0x40, -32);
char* buf = (char*)heap->alloc(0x40, -DEFAULT_ALIGN);
u32 numRead = ES_ReadContentFile(fd, buf, 0x40);
if (numRead != 0x40) {
OSReport("ESMisc::GetValidTicketIndex: ES_ReadContentFile err %d\n", numRead);
heap->free(buf);
if (ES_CloseContentFile(fd) < 0) {
if (ES_CloseContentFile(fd) < ES_ERR_OK) {
goto error;
}
} else {
if (ES_CloseContentFile(fd) < 0) {
if (ES_CloseContentFile(fd) < ES_ERR_OK) {
heap->free(buf);
goto error;
}
@@ -997,7 +997,7 @@ namespace ipl {
goto cleanup;
}
for (u32 j = 0; j < *ticketViewCount; j++) {
memcpy(ticketViews, (u8*)ticketViewList + j * sizeof(ESTicketView), sizeof(ESTicketView));
memcpy(ticketViews, &ticketViewList[j], 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,
@@ -1262,7 +1262,7 @@ namespace ipl {
tmdSize = 0;
ret = Exist(titleId, &tmdOffset, &tmdSize);
if (ret == FALSE) {
if (!ret) {
ret = ES_ERR_NO_TMD_FILE_FOUND;
goto out;
}

View File

@@ -0,0 +1,73 @@
# JPEG sample-array type correction
Current base: `bf65a26b5e38cddaa37b0e12e15e55ba61f57dd9` (43U only).
Original validation base: `e174f2c2bedc4baa28490dcf53989c9a2994bd2e`.
## Source correction
- Declare and define `TMCJPEGDEC_SampleH_N` and `TMCJPEGDEC_SampleV_N`
consistently as `const u8[6][4]`, using six explicitly grouped rows.
- Remove the obsolete H/V declaration conditional. The independent
`TMCJPEGDEC_SampleComps` incomplete-array condition and parser flag remain
unchanged; they are outside this type mismatch.
- Preserve every initializer byte and both existing `[sample][component]`
consumers in `TMCJPEGDEC_parse_sof`. Both tables remain 24 bytes, at
`.rodata` offsets 0 and 24. No flags, dummy state, casts or assembly added.
## Original e174f2c2 validation snapshot
A clean baseline and candidate were built in an isolated leaf with local
copies of the recovered tools and original input. Main's build was untouched.
The comparisons and numbers in this section describe the JPEG correction
relative to the original e174f2c2 baseline, before the disjoint eZiText changes
in bf65a26b. They are not current-main metrics.
- Full `ninja -j4` 43U build passed. The header change rebuilt all 15 dependent
objects, followed by linking and the DOL check.
- Explicit `ninja build/43U/ok`, with the generated stamp removed first,
passed: `build/43U/main.dol: OK`.
- DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`.
- Baseline/candidate full reports are byte-identical, SHA256
`dfe72493ec41da47a3052f4903a2ccddccfa1907002b6831274b76ee0b4844ef`.
All 1,027 units and 12,563 function records are unchanged.
- All 1,027 source objects preserve all 2,717 allocated sections, including
bytes, lengths, types, flags and alignments, and all 117,551 relocation
records (locations, types, target names/sections/offsets/sizes/bindings and
addends). This includes all 15 header-dependent objects.
- `jdec_main`: 13/13 exact functions; 5,604/5,604 code bytes and 256/256 data
bytes matched and linked. Its complete `.text` and `.rodata` match retail;
all 67 relocations have identical canonical destinations and addends.
- `jpformat`: 376/376 data bytes matched and linked. `.rodata` is exactly
368/368 bytes; both H/V tables retain their bytes and addresses. Existing
`.sdata2` remains 6 source bytes versus 8 retail bytes, with identical
contents and two retail zero-padding bytes; alignment remains 8. No
relocations exist in either object.
- `pool_diff.py`: identical pools for all 15 dependents (0/0 strings each).
- `ctxdiff.py`, using the recovered local helper: all 13 `jdec_main`
functions have equal instruction counts and `diffs 0`; 1,401/1,401 total
instructions. `jpformat` contains no functions.
- `decomp_status.py` ran. `check_decomp_complete.py` still returns 1 for the
existing repository-wide incomplete state; its baseline/candidate findings
are identical. This correction makes no repository-completion claim.
- `git diff --check` passed.
Original-snapshot global values were unchanged: 93.996216% exact code, 99.817444% fuzzy,
80.08451% linked code, 99.9941% matched data, 85.36267% linked data,
12,469/12,563 exact functions and 982/1,027 complete units.
Detailed local evidence is in the sibling `wii-jpeg-array-evidence` directory:
`audit.py`, `audit.txt`, baseline/final build logs and reports,
`all-dependent-pools.txt`, `pools-ctxdiff.txt`, `explicit-ok.txt`, and completion
checker outputs. Original input and binary build artifacts remain local.
## Rebased bf65a26b independent verification
After the disjoint eZiText change in PR #1221 landed, the parent mechanically
rebased the correction onto bf65a26b and independently rebuilt both main and
the leaf. The parent reported identical full reports and identical allocated
sections and relocation records across all 1,027 source objects between that
new baseline and the rebased leaf. Both full 43U builds passed and retained
DOL SHA1 `26116613f624061ba99c8d1a299aaa6efa85670d`.
The correction still preserves the separate `SampleComps` conditional. This
audit update changes documentation only; it does not change source or flags.

View File

@@ -0,0 +1,418 @@
# rx35 compiler correction and allocator evidence
Worktree sol-high, branch agent/w1005/rx35, HEAD and fetched origin/main
38ade13d6fb4320b5779d1e6df4b9250a018b7d8. Existing rx4 logs are untracked
and retained. This run owns configure.py and eZiText source only.
Read AGENTS.md, f-round.md, common.md, levers.md including 20-22, and the
mwdbg README before source work. Applied unslop and writing-for-agents.
The task authorizes the ZI8 compiler correction and Matching flips despite
the older common.md matching-only instruction.
Acceptance requires every baseline-exact eZiText function to remain exact,
unchanged or improved data, honest equivalent C, fresh object evidence,
symorder and doldiff for linking, full gate, and DOL SHA1
26116613f624061ba99c8d1a299aaa6efa85670d. A compiler correction and its source
retuning must be committed together only after that gate passes.
The installed mwdbg pins GC/3.0a5.2 and rejects GC/3.0a5 before execution.
Investigating a local debugger mapping under build/rx35; shared tools remain
unchanged. Captures will need independent whole-object identity verification.
The ccsweep2 copy changes only its output directory to keep trial objects here.
Prior rx4 evidence was read for workflow and data-section constraints. Its
GC/3.0a5.2 allocator conclusions are not assumed to hold for GC/3.0a5.
Fresh compiler sweep: EZTX is 7/7 instruction-exact under both versions, so
EZTX stays on GC/3.0a5.2. ZI8 GC/3.0a5 immediately matches both zi81key
spelling helpers, two zi8cgetc helpers, both zi8getc2 helpers, Zi8GetPyFinal,
ZiDAWGgetCHARattribute, and three zkokeyp helpers. The fresh baseline already
has ZiDAWGGetGraphInfo exact. All eZiText string pools are identical.
Regression target maps: Zi8MatchROMdata1 wants elements/count/output/capacity/
mode/acceptPrefix in r20/r21/r22/r23/r24/r25 and the table address in r26.
GC/3.0a5 spills the current unused integer tableAddress to the stack and shifts
those saved registers. Both exclusion functions want ending r27, beginning
r28; current code reverses those. Zi8GetBpmfPhonetic wants count r26, value r27;
current code reverses those. Zi8_81480224 wants candidate r26, position r27,
word-priority evaluated first, and index-first address additions.
The local debugger port maps 24 hooks by unique relocation-masked instruction
sequences, globals by corresponding instruction operands, and all 496 opcode
names by exact table comparison. The after-scheduling hook has the same call
sequence with one x86 local register changed. Runtime capture and whole-object
validation remain required before treating the port as evidence.
Manual source trials restored three exact regressions. Splitting tableAddress
assignment from the groupPtr store restores Zi8MatchROMdata1 to 128/128,
100%, data 120/120; nesting a pointer-typed assignment did not. Using a
ziWChar pointer for beginning and removing the void-pointer indexing cast
restores both exclusions to 51/51 and 100%. Reordering declarations or
splitting the postfix length decrement did not.
Zi8GetBpmfPhonetic restores 309/309 and 100% by combining each count decrement
with its following zero test. These are separate full expressions in the
same sequence; the tested value remains the decremented byte. Per-site
expanded subtraction, declaration order, count-copy and full-width local
controls did not match. No caller or public type changes are retained.
With the split DAWG assignment retained, a fresh link already restores the
required DOL SHA1. doldiff reports zero differing bytes. The other regression
fixes and new Matching flips still need their final gate.
New exact functions under GC/3.0a5: Zi8_8148302C uses a halfword character
value declared after its table count, 59/59 and 100%; changing the type alone
did not fix r27/r28. Zi8getKeyLayout chains keyIndex = tableCount = 0, 182/182
and 100%; this moves tableCount from r27 to target r26 and language from r26
to target r27. Splitting call assignments and declaration-order controls did
not move that pair. The named initialization is semantically unchanged.
The user-word helper improves from the old main 99.52586 to 99.82758 with
position declared before candidate and the word priority tested first.
Its remaining two differences commute the operands of address additions.
Byte-offset and flexible-array controls did not match; none is retained.
All three initial Matching flips pass the linked DOL hash and doldiff with
zero bytes different. symorder's only discrepancies were anonymous table and
exception labels. A second comparison checked every offset, size and named
symbol after normalizing only those anonymous names; all three passed.
Fresh comparison proves the large zi81key functions, Zi8AlphaGetCandidates,
zi8InternalGetZH and Zi8PrepareMatch have identical instruction streams under
GC/3.0a5 and GC/3.0a5.2. Their earlier allocator hypotheses are therefore
being rechecked against new captures, not assumed fixed by the version change.
Zi8MatchOEMdata is now 192/192 and 100%. Combining all three index updates
with their consumers fixes the saved-register cycle: initialize index in its
limit check, test ++index directly, and store ++index into oemIdx. One or two
combinations reach 99.40104 with only index/length swapped; all three put
index r26, length r27, pattern r28 and work r29 as retail requires. Splitting
the capacity decrement is a rejected control. Every index update and read
remains in its original execution order.
Data-preserving source controls were run on the larger functions. The three
initial spelling-control tags accidentally used absent source spellings and
are no-ops, excluded from attempt counts. Corrected postfix, compound and
expanded-index forms were then compiled. New a5 measurements reproduce the
old 1697/1701 instruction behavior. ZH const-input changes add nine
instructions and lose data; native type and compound-mask controls do not
move output. Alpha initialization gains a fuzzy fraction but adds two
instructions and loses data. Prepare's chained first-element assignment,
explicit component-byte cast and split phonetic zero stores were tested
alone and in all seven combinations; none preserves the full data credit.
The shared mwdbg requests stayed queued for over 20 minutes. They were
canceled before capture. A private copy of retrowin32 now listens on localhost
19035, with its own worktree lock. Only the two-byte TCP port immediate changed
in that emulator copy; compiler executables and compiler flags are unchanged.
The shared source-search CPU limiter is unchanged. Port patch hashes and the
verified x86 instruction are saved in build/rx35/emulator-port.json.
First a5 debugger run exposed a real layout difference: the function link-name
field is +0x40, not a5.2's +0x44. The a5 LinkName routine at 0x556400 and the
runtime object both prove +0x40. The mapping was corrected before using any
allocator evidence. Failed diagnostics are retained under build/rx35/private-*.
The corrected a5 debugger capture completed. Its alpha object is byte-identical
to an independent wibo compile. The validator checked reversed simplify order,
assignment events, representative maps and every PCode register rewrite with
zero mismatches. This validates the local port for this capture, not every
unsupported debugger feature.
The exclusion dump exposes an important distinction: ending r28 and beginning
r27 are already physical in backend-00 before graph coloring. The graph pass
only assigns temporaries r32-r41; r39 merges into call-result r3, and the
parameter moves are rejected for interference. Therefore the surviving
callee-saved swap originates in the earlier no-opt variable assignment, not
in simplify degree or graph coalescing. A typed-beginning capture will confirm
the changed preassignment. The earlier heuristic about graph priority alone
does not explain these named-register swaps.
The a5 no-opt selector was traced at 0x46ad60. It scans parameter and local
objects, chooses the greatest reference weight, and replaces a choice on an
equal weight. Named locals are preassigned before the graph pass begins.
Zi8ITspecialExclusion: void beginning has weight 2, below ending 3, so ending
gets r28 and beginning r27. Making beginning ziWChar* raises it to weight 3;
the local wins the parameter tie and gets target r28, leaving ending r27.
The graph priority and call-result coalescing stay unchanged.
Zi8getKeyLayout: separate tableCount=0; keyIndex=tableCount makes tableCount
weight 7, tied with language, and the local wins r27. Chaining their zero
initialization removes the extra tableCount read: weight 6, r26. Language 7
now takes target r27. Both mwdbg objects equal independent wibo objects.
The remaining UWD and Korean-table address additions retain opposite commuted
operands after typed-member, array, integer-address and const controls. No
integer-address or byte-offset experiment is retained. Three 1200-second
search seeds (49,149,249) now also cover these two functions, using the shared
24-slot limiter and immutable source snapshots inside this worktree.
Fresh no-opt trace confirms the DAWG repair: nested tableAddress assignment
has weight 1 and remains on the stack. Splitting the groupPtr assignment
raises tableAddress to weight 2, takes target r26, and shifts six weight-2
parameters down one register. The object is identical to an independent build.
OEM index weight falls 12 -> 9 when its three updates feed their consumers;
work/pattern stay weight 12 and length stays 10. The resulting assignments
are work r29, pattern r28, length r27, index r26, exactly matching retail.
Zi8_814834AC target maps i=r28, tableA load=r4, scaled byte index=r3.
The source pre-color ADD is v115=v112+v114: tableA v112 (degree 11,
priority index 80) resolves r4; offset v114 (degree 9, priority 78) resolves
r3; sum v115 (degree 10, priority 77) resolves r3. The second occurrence is
v122=v119+v121 with the same assignments. These colors already match retail;
the ADD operand order differs before coloring. This is an instruction-
selection difference, not a saved-register swap or coalescing failure.
Twenty further signed/unsigned address-expression controls did not fix it.
Prepare's combined element assignment, explicit halfword component-byte cast,
and separate phonetic zero stores remove all non-register structural changes
except three extra call-result copies (943 vs 940). This candidate loses data
and is not retained. Its mwdbg capture and three additional 1200-second seeds
349/449/549 are queued to investigate the actual coalescing differences.
A 64-shape spelling output-loop experiment did not reach exactness; the best
normal source shape is 1701 instructions and remains an unretained trial.
Debugger transport optimization: stop-local page reads initially missed a
cache invalidation after the debugger called LinkName, so those captures
reported empty names and failed before recording any result. The cache now
clears explicitly after every inferior resume and LinkName call. A repeated
51-instruction exclusion capture produced byte-identical regalloc JSON,
no-opt events, initial PCode and final PCode versus the uncached capture;
the independent object/PCode validator also passes. No failed capture is
included as measurement evidence. For large functions only the selected and
assigned no-opt hooks are enabled; graph priority/degree/coalescing hooks
remain complete. The redundant full candidate-scan ZH capture was interrupted
and requeued with that smaller no-opt hook set.
origin/main advanced externally to 8899a830 during this run. None of its
source edits touch eZiText. The rx35 branch remains on its assigned 38ade13d
baseline; no fetch, rebase, merge or edit outside this worktree was performed
while examining the new ref. Final regression comparisons use the recorded
38ade13d baseline and independent baseline-report.json snapshot.
Transport experiments enabled TCP_NODELAY on only the private emulator/GDB
connection. A temporary native shim changes socket options, never compiler
memory or flags; both the object and allocator output remain unchanged. The
full event trace is still too slow on the 10676-instruction ZH function.
A snapshot mode was therefore validated against the full exclusion capture:
actual compiler priority list, before-simplify graph, final graph, every
register rewrite and final PCode are identical. Large captures retain all
coalescing events and named-register assignments, but skip per-node simplify
and color-event breakpoints. Their validator explicitly marks those skipped
event checks null; graph/PCode and independent-object checks remain required.
The interrupted ZH event trace is partial evidence only, not a validated
capture. Its complete snapshot capture is queued on a separate private port.
All original source-search seeds finished. No candidate from seeds
49/149/249 produced another exact function. Korean state flattening into
normal scalar locals and a real key array was also tested: 682-684 versus
669 target instructions, 93.55-94.49%, data 40/180. None is retained.
Reproduction artifacts: rx35.mwdbg-a5.patch records the private a5 driver,
launcher and optional TCP shim relative to the shared tool versions whose
SHA256 values are in rx35.mwdbg-port.json. Apply it only to copies. The launcher
expects its private files under the current worktree's build/rx35 directory;
its default project is now the current directory. Shared debugger files,
compiler executables, and other worktrees were not edited.
Confirmed Bpmf no-opt weights: count 22 -> 15, value remains 21; value moves
r26 -> target r27 and count r27 -> target r26. Graph priority is descending
v147..v32, max simplify degree 16, with no accepted coalesces in either shape.
The count/value change is therefore entirely in named-register preassignment.
Korean key helper: count/value both weight 2. Their declaration/type order
changes the local tie order from value r28/count r27 to target count r28/value
r27; value's explicit halfword calculation is unchanged.
UWD: position/candidate both weight 7. Declaring position first changes their
local tie order from candidate r27/position r26 to target position r27/
candidate r26. Word is r28, work r31, current r30 and added r29 in both.
The retained priority comparison orders the reads as in retail. Two ADD
operand orders remain; no forced-register source was introduced.
Prepare structural candidate, measured graph evidence: extra copies at source
instruction 87, 646 and 654 are v62->r4, v103->r0 and v104->r4, while retail
stores r3 directly. Before simplification their degrees are 7, 6 and 7;
priority positions are 189, 150 and 149 (zero-based). All have r3 as an
interference neighbor. v62 is also the strokePrefix address in block 117,
live beside an index already coalesced to r3; v103/v104 are also the index
and recordMasks address in block 28, live beside the 0xff value coalesced to
r3. Thus unrelated uses of the same virtual temporary slots block merging
those call-result copies. Sixty-three unsigned-index, typed-constant and
commuted-OR source variants did not remove all three copies. Three further
annealing seeds 349/449/549 completed; only a tiny fuzzy-only candidate was
saved, still 943/940 with data loss. It is not retained.
Korean candidates: retail requires keyTable r28/work r27. Current no-opt
weights are keyTable 13/work 14, so the compiler assigns them r27/r28. The
other saved values match: param r31 (110), options r30 (40), wordNode r29
(27). Removing an identity pointer cast or changing its void view leaves
code unchanged. Flattening the pre-existing state makes keyTable miss the
no-opt eligibility threshold, adds stack loads, and regresses the function.
Reversing real local declarations repairs much of its stack layout, but
produces 683/669. Using a typed table gives 661/669 and loses data. None is
retained; no new carrier structure is added.
The larger functions retain their target saved-register roles. Spelling uses
tableIndex r31, params r30, character r29, work r28, options r27. Its 207-node
priority starts v259,v258,v257; 21 coalesces and 212 interference rejections
remain after the postfix/index trial. The trial changes degrees but keeps
1701/1700 instructions. Retail needs one fewer byte narrowing and a different
pair of support-call copies. Candidates uses params r31, index r30, work r29,
options r28; its 188-node priority starts v258,v257,v256, with 39 coalesces and
182 interference rejections. It remains 2405/2397 with three extra capacity
reloads and a net balance of call-result/index copies.
Alpha uses parameters r31, workData r30, index r29, wordCursor r28,
optionData r27. Chained dictionary initialization changes 171 -> 172 colored
temporaries and 55 -> 56 coalesces; degree graphs and code/data regress, so
it is rejected. ZH uses request r31, work r30 and options r29. Making its
input read-only leaves those named weights 352/277/99 unchanged but changes
206 -> 210 colored temporaries and 31 -> 27 coalesces, adding nine instructions.
The live ZH and Alpha differences include expression/store order as well as
register choices; neither is classified as a proven pure allocator tie.
All degree summaries for snapshot captures refer to the before-simplify graph.
Every PCode register rewrite checked in these captures agrees with the final
graph: Spelling 2979, Candidates 4499, Alpha 6545 and ZH 18821 operands.
Final clean gate: PASS, all 31 eZiText units included; zero baseline-exact
function drops, zero code/data/link regressions, zero forbidden additions,
zero readability warnings. The build was cleaned by gate.py before rebuilding.
The independent stored 38ade13d report also shows zero exact-function drops.
DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
doldiff: 0 differing bytes; both files 3867904 bytes.
New Matching units: zi8getc2, zidawg1, zi8match, zmtkey, zoemdata.
Their symbol order, offsets, sizes and named symbols agree after normalizing
only anonymous @ and jump-table names. Raw symorder logs are in build/rx35.
The actual linked DOL independently validates their placement.
EziText exact functions: 127 -> 141 / 149. Eight functions remain nonexact;
zi81key still accounts for the final 108 unmatched data bytes. The complete-
project checker reports DECOMPLETE_FAIL because code/data/link totals remain
incomplete. No project-completion claim is made. Global worker-baseline code:
94.00436% exact, 99.81261% fuzzy, 79.93427% linked; data 99.99410% matched.
Zi8GetKOcandidates has a disclosed fuzzy-only compiler-version drop,
98.87145 -> 98.72197; it was already nonexact and the required exact-name
regression gate passes. Full per-function before/after values and measures
are in rx35.results.json.
Completed searches:
Zi8MatchOEMdata-249.log: done 827 trials; best-nodrop energy -98.8802
Zi8MatchOEMdata-49.log: done 1382 trials; best-nodrop energy -98.8802
Zi8_81480224-149.log: done 1092 trials; best-nodrop energy -99.8276
zi8InternalGetZH-249.log: done 457 trials; best-nodrop energy -98.3363
Zi8Get1KeyPressCandidates-49.log: done 1139 trials; best-nodrop energy -80.4193
Zi8_81480224-49.log: done 1075 trials; best-nodrop energy -99.8276
Zi8PrepareMatch-249.log: done 792 trials; best-nodrop energy -96.9947
Zi8Get1KeyPressSpelling-249.log: done 713 trials; best-nodrop energy -97.5559
Zi8_814834AC-149.log: done 1066 trials; best-nodrop energy -99.9417
Zi8Get1KeyPressCandidates-149.log: done 1131 trials; best-nodrop energy -80.4193
Zi8_81480224-249.log: done 1072 trials; best-nodrop energy -99.8276
Zi8AlphaGetCandidates-49.log: done 1020 trials; best-nodrop energy -95.6485
zi8InternalGetZH-149.log: done 597 trials; best-nodrop energy -98.3363
Zi8Get1KeyPressCandidates-249.log: done 678 trials; best-nodrop energy -80.4193
Zi8_814834AC-49.log: done 1061 trials; best-nodrop energy -99.9417
Zi8MatchOEMdata-149.log: done 837 trials; best-nodrop energy -98.8802
Zi8PrepareMatch-49.log: done 1312 trials; best-nodrop energy -96.9947
zi8InternalGetZH-49.log: done 746 trials; best-nodrop energy -98.3363
Zi8GetKOcandidates-49.log: done 1284 trials; best-nodrop energy -98.722
Zi8getKeyLayout-49.log: done 1385 trials; best-nodrop energy -99.533
Zi8getKeyLayout-249.log: done 818 trials; best-nodrop energy -99.533
Zi8PrepareMatch-149.log: done 797 trials; best-nodrop energy -96.9947
Zi8GetKOcandidates-149.log: done 1300 trials; best-nodrop energy -98.722
Zi8Get1KeyPressSpelling-49.log: done 1164 trials; best-nodrop energy -97.5559
Zi8_814834AC-249.log: done 1051 trials; best-nodrop energy -99.9417
Zi8Get1KeyPressSpelling-149.log: done 1179 trials; best-nodrop energy -97.5559
Zi8GetKOcandidates-249.log: done 790 trials; best-nodrop energy -98.722
Zi8AlphaGetCandidates-249.log: done 850 trials; best-nodrop energy -95.6485
Zi8getKeyLayout-149.log: done 869 trials; best-nodrop energy -99.533
Zi8AlphaGetCandidates-149.log: done 654 trials; best-nodrop energy -95.6485
prepare-structural-search-349.log: done 1169 trials; best-nodrop energy -91.367
prepare-structural-search-449.log: done 1183 trials; best-nodrop energy -91.367
prepare-structural-search-549.log: done 1173 trials; best-nodrop energy -91.3681
Unit exact-function counts, recorded from the final fresh report:
zi81key: 5 -> 7 / 9
zi8alpha: 11 -> 11 / 12
zi8cgetc: 5 -> 7 / 8
zi8getc2: 15 -> 17 / 17
zi8match: 9 -> 10 / 10
zi8uwd: 3 -> 3 / 4
zidawg1: 5 -> 6 / 6
zkokeyp: 1 -> 5 / 7
zmtkey: 3 -> 4 / 4
zoemdata: 2 -> 3 / 3
zprepare: 0 -> 0 / 1
Final debugger validation:
All 40 completed captures match their independent wibo objects. The two large
zi8InternalGetZH captures contain three conditional branches whose targets
exceed the signed 16-bit branch range. Each becomes an inverted conditional
skip plus an unconditional branch; the apparent three-instruction PCode
alignment failure is fully explained. The supplemental validator checks the
inverted predicate (excluding its prediction hint), CR bit, eight-byte skip,
original out-of-range displacement and exact destination block. It then
checks all ordinary machine-register operands with those three expansions
accounted for: 8604 instructions / 16379 operands for the baseline and 8615 /
16401 for the rejected const-input trial. The original naive alignment result
is retained beside this proof in rx35.allocator.json.
The reproduction patch now includes the snapshot-aware validator and both
far-branch validation scripts. Run validate.py with a local build/tools/wibo,
then check-long-branches.py and validate-expanded-branches.py for the named
ZH captures. No shared debugger or other worktree was modified. All 141 exact
eZiText functions also passed fresh ctxdiff with identical instruction counts
and zero differences (build/rx35/final-ctxdiff.json). No source or configure
change was made after the clean all-unit gate.
## Landing repair: Zi8GetKOcandidates only
Resumed at fed3bdbb after the orchestrator rebased and removed bulky artifacts.
The new acceptance rule compares every function score, including fuzzy ones.
Required minimum: the old-compiler score 98.87145, with every other eZiText
function unchanged from this resumed branch. Only zkokeyp.c and this log are
in scope. All new captures, measurements and rejected trials stay in build/rx35r1.
Fresh source baseline: Zi8GetKOcandidates 98.72197, 669/669 instructions,
zkokeyp data 180/180. Pool identical. The other six function scores match the
accepted branch, including Zi8_814834AC at 99.94169.
Rejected controls: pointer/index association and signed byte views leave the
same output; arithmetic and typed-record subscripts usually change instruction
counts and lose data. Splitting output increments, changing condition forms,
removing redundant casts, and consolidating null-error handling did not meet
the score floor. A real five-byte array initializer reached 98.7728 but moved
stack objects; it is not retained. No carrier, forced register, redundant
operation or compiler change is retained.
Accepted source: read the first packed key flag through the byte table using
offsetof(ZiKoreanKeyEntry, keyBytes[4]). This names the same existing field
instead of casting the computed address to a record and then selecting it.
The row offset is still keyIndex*9; keyIndex is unsigned 16-bit and the 0xffff
sentinel still short-circuits before the read. The additional field offset is
four, so all arithmetic is within signed 32-bit range. The same unsigned byte
and bit 8 are tested, with unchanged calls, side effects and branch condition.
stddef.h supplies offsetof; no layout, symbol, flag or public type changed.
mwdbg confirms keyTable's reference weight rises 13 -> 14. It ties the work
parameter at 14 and wins the local/parameter tie: keyTable r28, work r27, as
retail requires. Param/options/wordNode remain r31/r30/r29 at weights
110/40/27. The 213-node GPR priority order and 14 successful coalesces remain;
52 candidate coalesces are rejected for interference. This is a named-register
preassignment repair, not a different graph coloring priority. The capture
matches an independent wibo object byte-for-byte. All 1224 allocation operand
rewrites and 1027 machine-register operands across 537 instructions pass.
Focused result: Zi8GetKOcandidates 98.72197 -> 98.998505, still 669/669.
All six other function scores are identical and data stays 180/180.
The clean eZiText gate and explicit per-function fuzzy comparisons follow.
The graph priority and coalesced representative pairs compare identical.
Before-simplify degree changes: v59 6->5, v58 8->7.
Focused ctxdiff improves from 103 to 71 differences, both 669 instructions.
There are 214 private compile records, including controls and baseline refreshes.
Final clean gate: GATE PASS across all 31 eZiText units, base 044ab571.
Baseline regressions, forbidden additions and readability warnings are all zero.
Fresh reports compare all 149 eZiText functions: only Zi8GetKOcandidates
changes, 98.72197 -> 98.998505. Every other function score is identical.
All eZiText scores meet or exceed the pre-switch 044ab571 baseline; the
old score for this function was 98.87145. No common function in the full
project report has a fuzzy drop against that baseline either.
DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
Only zkokeyp.c and this .md log are committed; artifacts remain under build/rx35r1.

View File

@@ -0,0 +1,340 @@
# rx40 expression cleanup
Base `d220c7accbcacca7207d851fdd1f27fa353a08c2`, branch `agent/w1005/rx40`.
This round preserves every object byte and all existing objdiff measurements.
The matching-round requirement to gain exact functions does not apply.
Baseline rebuilt before edits. Saved all 1027 source-object SHA256 hashes,
the full objdiff report, and all twelve owned objects under `/tmp/rx40-cleanup`.
## Trials
KEEP requires whole-object byte equality. REVERT restores the source and rebuilds it.
- 1. constants, iplGCSaveData scene identifiers, 9 replacements. KEEP.
- 2. constants, iplGCWindow scene identifiers, 2 replacements. KEEP.
- 3. constants, MemoryBase button masks, animation modes, and setting commands, 12 replacements. REVERT: src/scene/memoryCard/iplMemoryCardBase: .text.
- 4. constants, MemoryCard page button masks and animation modes, 4 replacements. REVERT: src/scene/memoryCard/iplMemoryCard: .text.
- 5. constants, MemoryCardManager SDK file limits, texture formats, dimensions, and language, 14 replacements. KEEP.
- 6. constants, SDChannelTitle scene identifiers, WPAD status, button masks, and SDButton animations, 48 replacements. REVERT: compiler failure, see trial-6.build.txt.
- 7. constants, ODH pixel formats, 24 replacements. KEEP.
- 8. constants, MemoryBase button masks, animation modes, and setting commands with header-verified values, 12 replacements. KEEP.
- 9. constants, MemoryCard page button masks and animation modes with header-verified values, 4 replacements. KEEP.
- 10. constants, SDChannelTitle scene identifiers, WPAD status, button masks, and SDButton animations with header-verified values, 48 replacements. KEEP.
- 11. constants, card SDK results and permission flags, 100 replacements. KEEP.
- 12. casts, GCWindow casts from list void pointers, 2 replacements. KEEP.
- 13. casts, MemoryCard VEC3 conversion operators, 2 replacements. KEEP.
- 14. conditions, MemoryCard boolean readiness calls, 4 replacements. KEEP.
- 15. conditions, TVRC boolean ARC results and initialization flag, 3 replacements. KEEP.
- 16. casts, TVRC cast from file data void pointer, 1 replacements. KEEP.
- 17. conditions, TextBalloon aspect-ratio flags, 3 replacements. KEEP.
- 18. conditions, TextBalloon direct fade-in state condition, 1 replacements. REVERT: src/scene/textBalloon/iplBalloon: .rela.text, .strtab, .symtab, .text.
- 19. conditions, SDChannelTitle channel availability boolean, 1 replacements. KEEP.
- 20. constants, SDChannelTitle remaining scene and event constants, 3 replacements. KEEP.
- 21. casts, SDMemory construct colors through existing GXColor constructor, 6 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .rela.text, .strtab, .symtab, .text.
- 22. casts, ODH already unsigned quality and bit values, 7 replacements. KEEP.
- 23. casts, ODH conversion table already const signed long pointer, 1 replacements. KEEP.
- 24. names, ODH DC predictor fields, 18 replacements. KEEP.
- 25. names, SaveDataManager prioritized title list, 4 replacements. KEEP.
- 26. members, SaveDataManager channel type through existing member, 1 replacements. REVERT: src/system/iplSaveDataManager: .strtab, .text.
- 27. names, MemoryBase hover counts, animation state, and layout file, 34 replacements. KEEP.
- 28. casts, CardSequence redundant icon buffer and speed casts, 2 replacements. KEEP.
- 29. casts, CardSequence casts from allocator void pointers, 5 replacements. KEEP.
- 30. constants, CardSequence blocking queue flags, 4 replacements. KEEP.
- 31. constants, CardSequence banner and icon formats, 16 replacements. KEEP.
- 32. constants, SDChannelTitle exit scene identifiers, 3 replacements. KEEP.
- 33. constants, ODH error codes and success comparisons, 27 replacements. KEEP.
- 34. conditions, TVRC loop boolean flags, 2 replacements. KEEP.
- 35. constants, SaveDataManager channel index limit, 2 replacements. KEEP.
- 36. members, SaveDataManager checksum bytes from the data member, 2 replacements. REVERT: src/system/iplSaveDataManager: .rela.text, .symtab, .text.
- 37. constants, CardSequence SDK file counts and buffer sizes, 26 replacements. KEEP.
- 38. constants, MemoryCard slot enum values, 9 replacements. KEEP.
- 39. conditions, MemoryBase existing child-wait predicate, 1 replacements. REVERT: src/scene/memoryCard/iplMemoryCardBase: .strtab.
- 40. casts, TVRC tick word already u32, 2 replacements. KEEP.
- 41. casts, TVRC archive header from void pointer, 1 replacements. KEEP.
- 42. casts, SDChannelTitle mutable callback controller avoids const cast, 2 replacements. KEEP.
- 43. members, SDChannelTitle usage pointer through first member, 1 replacements. KEEP.
- 44. constants, SDChannelTitle worker results and NAND file readiness, 12 replacements. KEEP.
- 45. constants, SDMemory NAND worker result codes, 7 replacements. KEEP.
- 46. conditions, SDMemory scroller boolean result, 1 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .text.
- 47. casts, ODH direct work-buffer pointer arithmetic, 5 replacements. REVERT: src/system/odh: .text.
- 48. conditions, ODH dimension validation grouping, 2 replacements. KEEP.
- 49. conditions, ODH direct header validation, 1 replacements. KEEP.
- 50. names, ODH named error reasons, 34 replacements. KEEP.
- 51. members, SaveDataManager valid-channel scan through declared channel entries, 6 replacements. REVERT: src/system/iplSaveDataManager: .rela.text, .symtab, .text.
- 52. names, MCFile high word of the comparator sort key, 4 replacements. KEEP.
- 53. constants, MemoryCardManager SDK banner dimensions, file counts, and slot identifiers, 6 replacements. KEEP.
- 54. constants, CardSequence remaining success and storage constants, 7 replacements. KEEP.
- 55. constants, MemoryCardManager existing CardCommand enum in completion dispatch, 8 replacements. KEEP.
- 56. constants, SaveDataManager channel page count, 1 replacements. KEEP.
- 57. conditions, ODH header comparison spacing, 0 replacements. KEEP.
- 58. casts, ODH isolate direct buffer arithmetic at baseline line 723, 1 replacements. KEEP.
- 59. casts, ODH isolate direct buffer arithmetic at baseline line 741, 1 replacements. KEEP.
- 60. casts, ODH isolate direct buffer arithmetic at baseline line 748, 1 replacements. KEEP.
- 61. casts, ODH isolate direct buffer arithmetic at baseline line 1381, 1 replacements. REVERT: src/system/odh: .text.
- 62. casts, ODH isolate direct buffer arithmetic at baseline line 1562, 1 replacements. REVERT: src/system/odh: .text.
- 63. casts, SDMemory isolate GXColor conversion at baseline line 1349, 1 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .strtab.
- 64. casts, SDMemory isolate GXColor conversion at baseline line 1351, 1 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .rela.text, .strtab, .symtab, .text.
- 65. casts, SDMemory isolate GXColor conversion at baseline line 1352, 1 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .rela.text, .strtab, .symtab, .text.
- 66. casts, SDMemory isolate GXColor conversion at baseline line 1356, 1 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .strtab.
- 67. casts, SDMemory isolate GXColor conversion at baseline line 1358, 1 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .rela.text, .strtab, .symtab, .text.
- 68. casts, SDMemory isolate GXColor conversion at baseline line 1359, 1 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .rela.text, .strtab, .symtab, .text.
- 69. casts, GCSaveData null test without downcast, 1 replacements. KEEP.
- 70. casts, GCWindow explicit checked-base casts, 2 replacements. KEEP.
- 71. conditions, MemoryBase direct button command range, 1 replacements. REVERT: src/scene/memoryCard/iplMemoryCardBase: .rela.text, .strtab, .symtab, .text.
- 72. conditions, SDChannelTitle explicit transfer error alternatives, 1 replacements. REVERT: src/scene/sdChannelTitle/iplSDChannelTitle: .strtab.
## Results
Cleaned 12 translation units and two owned headers. Every retained edit preserved
whole-object bytes, including symbol and string tables. Of 72 trials, 51 were
retained and 21 were reverted. Trial 57 only adjusted the spacing of trial 49.
| Category | Retained count |
| --- | ---: |
| Numeric literals replaced with existing named constants | 350 |
| Cast sites simplified or made explicit | 31 |
| Conditions simplified | 16 |
| Pointer access replaced with the existing member | 1 |
| Declarations given descriptive names | 15 |
| Name occurrences changed, including declarations | 94 |
The trial journal counts text replacements. A replacement can contain two
constants or casts. The constant total above counts individual numeric literals;
cast totals count replacement sites. The 15 declarations are four MemoryBase
members, one MCFile member, four ODH members, five ODH error enumerators, and
one SaveDataManager local array.
| File | Constants | Cast sites | Conditions | Member access | Name occurrences |
| --- | ---: | ---: | ---: | ---: | ---: |
| `include/scene/memoryCard/iplMemoryCardBase.h` | 0 | 0 | 0 | 0 | 8 |
| `include/scene/memoryCard/iplMemoryCardManager.h` | 8 | 0 | 0 | 0 | 1 |
| `src/scene/cardSequence/iplCardSequence.cpp` | 153 | 7 | 0 | 0 | 0 |
| `src/scene/memoryCard/iplGCSaveData.cpp` | 9 | 1 | 0 | 0 | 4 |
| `src/scene/memoryCard/iplGCWindow.cpp` | 2 | 4 | 0 | 0 | 5 |
| `src/scene/memoryCard/iplMemoryCard.cpp` | 13 | 2 | 4 | 0 | 8 |
| `src/scene/memoryCard/iplMemoryCardBase.cpp` | 12 | 0 | 0 | 0 | 9 |
| `src/scene/memoryCard/iplMemoryCardManager.cpp` | 24 | 0 | 0 | 0 | 3 |
| `src/scene/sdChannelMemory/iplSDMemory.cpp` | 7 | 0 | 0 | 0 | 0 |
| `src/scene/sdChannelTitle/iplSDChannelTitle.cpp` | 68 | 2 | 1 | 1 | 0 |
| `src/scene/textBalloon/iplBalloon.cpp` | 0 | 0 | 3 | 0 | 0 |
| `src/system/TVRC.cpp` | 0 | 4 | 5 | 0 | 0 |
| `src/system/iplSaveDataManager.cpp` | 3 | 0 | 0 | 0 | 4 |
| `src/system/odh.cpp` | 51 | 11 | 3 | 0 | 52 |
## Rejected edits and scope limits
Trials 3 and 4 initially used the wrong animation enum value. The build caught
the changed instructions; trials 8 and 9 used the verified `ANIM_TYPE_BACKWARD`
value and passed. Trial 6 used an unavailable WPAD name; trial 10 used the
header's `WPAD_LIB_STATUS_0`. These three failures were mapping mistakes, not
proof that the expressions were load-bearing.
The other rejected cleanup candidates changed object bytes:
- `TextBalloon::calc`: replacing the fade-in switch with an if changed code,
relocations, and symbol/string tables.
- `SDMemory::drawTransferTitles`: constructing each of the six GXColor values
through its constructor changed code or `.strtab`. All six were isolated
after the grouped trial failed; none was retained.
- `savedata::Manager::getAvailableInList` and `getNumValidChannel`: direct
`mData.chanInfo` accesses changed instructions or relocations. The original
offset expressions remain.
- `savedata::Manager::initManagerTask`: deriving the checksum address from `mData`
changed instructions and relocations. The original address expression remains.
- `MemoryBase::is_fadein_enable`: using the existing child-wait predicate changed
only `.strtab`, which still fails the whole-object requirement.
- `SDMemory::calc`: removing `== TRUE` from the scroller result changed `.text`.
- `CArGBAOdh::cdj_d_decompressLoop`: both integer-to-pointer work-buffer
simplifications changed `.text`. The three corresponding compressor sites
passed when tested individually and were retained.
- `MemoryBase::AnmButton::onCmdRecv`: replacing the unsigned command-range test
with direct bounds changed code, relocations, and symbol/string tables.
- `iplSDChannelTitle_updateCopyPrepare`: spelling out the two transfer errors
changed only `.strtab`; the unsigned range expression remains.
Remaining `unk_` member names are declared outside the assigned headers:
`FileInfo`, `CardState`, and `IconState` in `include/iplMemoryCardLib.h`, and
`Scroller::unk_0x3C` in `include/utility/iplScroller.h`. Their declarations and
uses remain unchanged. Unused reserved fields remain reserved. The save-data
`padding` array is cleared as serialized reserved storage, with no demonstrated
alternate meaning. The SDMemory double-to-float-to-integer conversions retain
an intermediate rounding step, so they are not redundant casts.
No source comments, assembly, declarations' order, or statement order were added
or rearranged. No configuration, symbol bounds, or other worker files changed.
## Final verification
The baseline was rebuilt from `d220c7accbcacca7207d851fdd1f27fa353a08c2`
before editing. The final non-quick gate used that same base. After its clean
build, a separate report generation and SHA256 comparison established:
- All 1027 source ELF objects equal the saved baseline bytes, including every
translation unit that includes the renamed headers.
- The complete objdiff JSON equals the saved baseline JSON, across all units,
functions, sections, and link measures.
- All 12 owned string pools are identical to their target pools.
- Instruction-exact functions: 408/416 -> 408/416.
- Objdiff matched code bytes: 95204/106872 -> 95204/106872.
- Objdiff matched data bytes: 19800/19800 -> 19800/19800.
- Full 4.3U build and `build/43U/ok` pass.
- DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`.
- Zero regressions, forbidden additions, readability warnings, or whitespace
errors from `git diff --check`.
Reproduce the full gate from this worktree:
```sh
python3 /mnt/drive2/projects/wii-ipl-workers/_restore0928-tools/gate.py \
src/scene/cardSequence/iplCardSequence \
src/scene/memoryCard/iplGCSaveData src/scene/memoryCard/iplGCWindow \
src/scene/memoryCard/iplMemoryCard src/scene/memoryCard/iplMemoryCardBase \
src/scene/memoryCard/iplMemoryCardManager \
src/scene/sdChannelMemory/iplSDMemory src/scene/sdChannelTitle/iplSDChannelTitle \
src/scene/textBalloon/iplBalloon src/system/TVRC \
src/system/iplSaveDataManager src/system/odh \
--base d220c7accbcacca7207d851fdd1f27fa353a08c2
```
The exact baseline/report/hash snapshots and per-trial build output are in
`/tmp/rx40-cleanup`; this log preserves the measurements and rejected trials.
## Existing non-matching functions
These eight functions are unchanged by this cleanup. They are not new
regressions or targets for code-generation changes in this round. Counts below
are source/target instructions from `ctxdiff.py`; equal instruction counts do
not establish a match.
| Function | Objdiff percent | Instructions | Existing difference |
| --- | ---: | --- | --- |
| `LineConv11__9CArGBAOdhFPUcPUcPUcPUcUsUsPCli` | 98.08219 | 146/146 | 12 differing instructions; register use and scheduling |
| `huffmanDecoder__9CArGBAOdhFPUlP21SArCDJ_HuffmanRequestPPUsiUl` | 95.57189 | 306/306 | 171 differing instructions; register use and addressing |
| `_create_icon__Q33ipl5scene17MemoryCardManagerFUcsl` | 87.55 | 100/100 | 37 differing instructions; register use and address calculations |
| `cardThreadMain` | 97.9402 | 301/301 | 78 differing instructions; register use |
| `loadCardFileIcons` | 91.33984 | 509/512 | Instruction count and register use |
| `iplSDChannelTitle_flushSaveBeforeExit` | 98.5946 | 37/37 | 6 differing instructions; register use |
| `create__Q33ipl5scene8SDMemoryFPQ23EGG4HeapPQ33ipl4nand10LayoutFilePQ33ipl5scene15SDChannelSelect` | 99.15884 | 1064/1064 | 175 differing instructions; register use and addressing |
| `drawTransferTitles__Q33ipl5scene8SDMemoryFv` | 93.456764 | 438/451 | Instruction count and register use |
## Full gate output
```text
full build: ok
main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d
[src/scene/cardSequence/iplCardSequence] pool: IDENTICAL
[src/scene/cardSequence/iplCardSequence] objdiff: code 6600/9852 data 1496/1496 functions 28/30 fuzzy 97.9480 linked code 0
[src/scene/cardSequence/iplCardSequence] instruction-exact functions: 28/30
[src/scene/cardSequence/iplCardSequence] section .bss size 16 match 100.0
[src/scene/cardSequence/iplCardSequence] section .data size 1464 match 100.0
[src/scene/cardSequence/iplCardSequence] section .sbss size 8 match 100.0
[src/scene/cardSequence/iplCardSequence] section .sdata size 8 match 100.0
[src/scene/cardSequence/iplCardSequence] section .text size 9852 match 97.94803
[src/scene/cardSequence/iplCardSequence] below 100: cardThreadMain 97.9402
[src/scene/cardSequence/iplCardSequence] below 100: loadCardFileIcons 91.33984
[src/scene/cardSequence/iplCardSequence] baseline: code 6600/9852 data 1496 functions 28 fuzzy 97.9480
[src/scene/memoryCard/iplGCSaveData] pool: IDENTICAL
[src/scene/memoryCard/iplGCSaveData] objdiff: code 2008/2008 data 392/392 functions 12/12 fuzzy 100.0000 linked code 2008
[src/scene/memoryCard/iplGCSaveData] instruction-exact functions: 12/12
[src/scene/memoryCard/iplGCSaveData] section .data size 336 match 100.0
[src/scene/memoryCard/iplGCSaveData] section .rodata size 40 match 100.0
[src/scene/memoryCard/iplGCSaveData] section .sdata size 16 match 100.0
[src/scene/memoryCard/iplGCSaveData] section .text size 2008 match 100.0
[src/scene/memoryCard/iplGCSaveData] baseline: code 2008/2008 data 392 functions 12 fuzzy 100.0000
[src/scene/memoryCard/iplGCWindow] pool: IDENTICAL
[src/scene/memoryCard/iplGCWindow] objdiff: code 9964/9964 data 2032/2032 functions 48/48 fuzzy 100.0000 linked code 9964
[src/scene/memoryCard/iplGCWindow] instruction-exact functions: 48/48
[src/scene/memoryCard/iplGCWindow] section .data size 1784 match 100.0
[src/scene/memoryCard/iplGCWindow] section .rodata size 176 match 100.0
[src/scene/memoryCard/iplGCWindow] section .sdata size 48 match 100.0
[src/scene/memoryCard/iplGCWindow] section .sdata2 size 24 match 100.0
[src/scene/memoryCard/iplGCWindow] section .text size 9964 match 100.0
[src/scene/memoryCard/iplGCWindow] baseline: code 9964/9964 data 2032 functions 48 fuzzy 100.0000
[src/scene/memoryCard/iplMemoryCard] pool: IDENTICAL
[src/scene/memoryCard/iplMemoryCard] objdiff: code 9264/9264 data 2656/2656 functions 41/41 fuzzy 100.0000 linked code 9264
[src/scene/memoryCard/iplMemoryCard] instruction-exact functions: 41/41
[src/scene/memoryCard/iplMemoryCard] section .data size 2320 match 100.0
[src/scene/memoryCard/iplMemoryCard] section .rodata size 280 match 100.0
[src/scene/memoryCard/iplMemoryCard] section .sdata size 40 match 100.0
[src/scene/memoryCard/iplMemoryCard] section .sdata2 size 16 match 100.0
[src/scene/memoryCard/iplMemoryCard] section .text size 9264 match 100.0
[src/scene/memoryCard/iplMemoryCard] baseline: code 9264/9264 data 2656 functions 41 fuzzy 100.0000
[src/scene/memoryCard/iplMemoryCardBase] pool: IDENTICAL
[src/scene/memoryCard/iplMemoryCardBase] objdiff: code 3640/3640 data 160/160 functions 34/34 fuzzy 100.0000 linked code 3640
[src/scene/memoryCard/iplMemoryCardBase] instruction-exact functions: 34/34
[src/scene/memoryCard/iplMemoryCardBase] section .data size 144 match 100.0
[src/scene/memoryCard/iplMemoryCardBase] section .sdata2 size 16 match 100.0
[src/scene/memoryCard/iplMemoryCardBase] section .text size 3640 match 100.0
[src/scene/memoryCard/iplMemoryCardBase] baseline: code 3640/3640 data 160 functions 34 fuzzy 100.0000
[src/scene/memoryCard/iplMemoryCardManager] pool: IDENTICAL
[src/scene/memoryCard/iplMemoryCardManager] objdiff: code 4996/5396 data None/None functions 25/26 fuzzy 99.0771 linked code 0
[src/scene/memoryCard/iplMemoryCardManager] instruction-exact functions: 25/26
[src/scene/memoryCard/iplMemoryCardManager] section .text size 5396 match 99.077095
[src/scene/memoryCard/iplMemoryCardManager] below 100: _create_icon__Q33ipl5scene17MemoryCardManagerFUcsl 87.55
[src/scene/memoryCard/iplMemoryCardManager] baseline: code 4996/5396 data None functions 25 fuzzy 99.0771
[src/scene/sdChannelMemory/iplSDMemory] pool: IDENTICAL
[src/scene/sdChannelMemory/iplSDMemory] objdiff: code 14812/20872 data 3344/3344 functions 64/66 fuzzy 99.2629 linked code 0
[src/scene/sdChannelMemory/iplSDMemory] instruction-exact functions: 64/66
[src/scene/sdChannelMemory/iplSDMemory] section .data size 3144 match 100.0
[src/scene/sdChannelMemory/iplSDMemory] section .sdata size 152 match 100.0
[src/scene/sdChannelMemory/iplSDMemory] section .sdata2 size 48 match 100.0
[src/scene/sdChannelMemory/iplSDMemory] section .text size 20872 match 99.26294
[src/scene/sdChannelMemory/iplSDMemory] below 100: create__Q33ipl5scene8SDMemoryFPQ23EGG4HeapPQ33ipl4nand10LayoutFilePQ33ipl5scene15SDChannelSelect 99.15884
[src/scene/sdChannelMemory/iplSDMemory] below 100: drawTransferTitles__Q33ipl5scene8SDMemoryFv 93.456764
[src/scene/sdChannelMemory/iplSDMemory] baseline: code 14812/20872 data 3344 functions 64 fuzzy 99.2629
[src/scene/sdChannelTitle/iplSDChannelTitle] pool: IDENTICAL
[src/scene/sdChannelTitle/iplSDChannelTitle] objdiff: code 18476/18624 data 1976/1976 functions 68/69 fuzzy 99.9888 linked code 0
[src/scene/sdChannelTitle/iplSDChannelTitle] instruction-exact functions: 68/69
[src/scene/sdChannelTitle/iplSDChannelTitle] section .data size 1696 match 100.0
[src/scene/sdChannelTitle/iplSDChannelTitle] section .rodata size 48 match 100.0
[src/scene/sdChannelTitle/iplSDChannelTitle] section .sdata size 192 match 100.0
[src/scene/sdChannelTitle/iplSDChannelTitle] section .sdata2 size 40 match 100.0
[src/scene/sdChannelTitle/iplSDChannelTitle] section .text size 18624 match 99.98883
[src/scene/sdChannelTitle/iplSDChannelTitle] below 100: iplSDChannelTitle_flushSaveBeforeExit 98.5946
[src/scene/sdChannelTitle/iplSDChannelTitle] baseline: code 18476/18624 data 1976 functions 68 fuzzy 99.9888
[src/scene/textBalloon/iplBalloon] pool: IDENTICAL
[src/scene/textBalloon/iplBalloon] objdiff: code 3084/3084 data 136/136 functions 18/18 fuzzy 100.0000 linked code 3084
[src/scene/textBalloon/iplBalloon] instruction-exact functions: 18/18
[src/scene/textBalloon/iplBalloon] section .data size 80 match 100.0
[src/scene/textBalloon/iplBalloon] section .sdata size 24 match 100.0
[src/scene/textBalloon/iplBalloon] section .sdata2 size 32 match 100.0
[src/scene/textBalloon/iplBalloon] section .text size 3084 match 100.0
[src/scene/textBalloon/iplBalloon] baseline: code 3084/3084 data 136 functions 18 fuzzy 100.0000
[src/system/TVRC] pool: IDENTICAL
[src/system/TVRC] objdiff: code 2312/2312 data 280/280 functions 9/9 fuzzy 100.0000 linked code 2312
[src/system/TVRC] instruction-exact functions: 9/9
[src/system/TVRC] section .bss size 96 match 100.0
[src/system/TVRC] section .sbss size 120 match 100.0
[src/system/TVRC] section .sdata size 32 match 100.0
[src/system/TVRC] section .sdata2 size 32 match 100.0
[src/system/TVRC] section .text size 2312 match 100.0
[src/system/TVRC] baseline: code 2312/2312 data 280 functions 9 fuzzy 100.0000
[src/system/iplSaveDataManager] pool: IDENTICAL
[src/system/iplSaveDataManager] objdiff: code 7172/7172 data 968/968 functions 35/35 fuzzy 100.0000 linked code 7172
[src/system/iplSaveDataManager] instruction-exact functions: 35/35
[src/system/iplSaveDataManager] section .data size 184 match 100.0
[src/system/iplSaveDataManager] section .rodata size 768 match 100.0
[src/system/iplSaveDataManager] section .sdata size 16 match 100.0
[src/system/iplSaveDataManager] section .text size 7172 match 100.0
[src/system/iplSaveDataManager] baseline: code 7172/7172 data 968 functions 35 fuzzy 100.0000
[src/system/odh] pool: IDENTICAL
[src/system/odh] objdiff: code 12876/14684 data 6360/6360 functions 26/28 fuzzy 99.5546 linked code 0
[src/system/odh] instruction-exact functions: 26/28
[src/system/odh] section .data size 464 match 100.0
[src/system/odh] section .rodata size 5856 match 100.0
[src/system/odh] section .sdata2 size 40 match 100.0
[src/system/odh] section .text size 14684 match 99.55462
[src/system/odh] below 100: LineConv11__9CArGBAOdhFPUcPUcPUcPUcUsUsPCli 98.08219
[src/system/odh] below 100: huffmanDecoder__9CArGBAOdhFPUlP21SArCDJ_HuffmanRequestPPUsiUl 95.57189
[src/system/odh] baseline: code 12876/14684 data 6360 functions 26 fuzzy 99.5546
regressions vs baseline: 0
global matched_code_percent: 93.96723 -> 93.96723
global fuzzy_match_percent: 99.81488 -> 99.81488
global complete_code_percent: 80.08451 -> 80.08451
global matched_data_percent: 99.99410 -> 99.99410
forbidden patterns added (net, per file): 0
readability warnings (net, per file; must be 0 in the final result): 0
GATE PASS
```

View File

@@ -0,0 +1,297 @@
# rx41 de-asm attempts
Worktree data-d4, branch agent/w1005/rx41. Starting HEAD and fetched origin/main fef6f996.
Assigned OSInit, _CNTCACHEIsTitleRemovable, _CNTCACHEDeleteContent, TMCJPEGDEC_parse_sof. All three units are Matching.
Existing untracked g2 attempts/baseline/final logs were present before this run and are outside this task.
Acceptance: each conversion needs exact-name objdiff 100.0%, ctxdiff diffs 0, identical pools, full gate with no drops and DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d. Remove its inventory row and run the checker. Commit conversions separately. Preserve asm for every rejected C candidate.
Read AGENTS.md, levers.md, unslop and writing-for-agents. No workers spawned. Source experiments stay in this worktree or /tmp/rx41.
Prior evidence: da5/da7 cache attempts, rx36 extracts of missing rx18 log, rx19/da4b SOF trials. OS reference OS_OS.c in ogws_sdk initializes MEM1/MEM2 using __ArenaLo; its debug-stack fallback is _db_stack_end.
OSInit / os-01-linker-symbol: Use the existing __ArenaLo linker symbol, matching ogws SDK arena initialization. objdiff 99.96296%; 270/270 instructions, 4 positional differences; POOL IDENTICAL up to 29 (mine=29 base=29).
OSInit / os-02-fixed-address: Diagnostic constant address, checking constant folding and address-load form; no source installed. objdiff 90.23704%; 246/270 instructions, 199 positional differences; POOL IDENTICAL up to 29 (mine=29 base=29).
OSInit / os-03-address-helper: Linker address through inline identity helper tests address materialization; expected extraction-only mismatch. objdiff 99.96296%; 270/270 instructions, 4 positional differences; POOL IDENTICAL up to 29 (mine=29 base=29).
TMCJPEGDEC_parse_sof / sof-00-prior: Fresh prior geometry candidate on current unit; incomplete extern remains local to the trial. objdiff 98.05381%; 223/223 instructions, 34 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
## OSInit conversion
The two address pairs at 0x8152C08C/90 and 0x8152C134/38 resolve to 0x816a9800. config/ldscript_ipl2.lcf already defines __ArenaLo as the aligned end of the debugger stack. The linked ELF has _stack_end=0x81699800 and _stack_addr=0x816a7800; adding the linker script's 0x2000 debug stack gives 0x816a9800. The ogws OS_OS.c reference uses __ArenaLo for the same MEM1/MEM2 region checks.
The extracted target was missing four linker-symbol relocations. Added only those HA/LO relocations in config/43U/config.yml. No symbol sizes, sections, labels, linker addresses or flags changed. decomp-toolkit supports an unresolved external target in add_relocations; checked src/cmd/dol.rs apply_add_relocations and src/obj/relocations.rs in encounter/decomp-toolkit. Only OS.o changed among 1027 freshly extracted objects.
After extraction correction, direct __ArenaLo C gives 270/270 instructions, ctxdiff diffs 0, identical 29-string pool. The inline identity helper is unnecessary and was rejected. Ghidra was regenerated in /tmp/rx41 and read; without the missing relocation it folds the address-dependent region branches, confirming why C with a literal cannot represent the original compiler input.
TMCJPEGDEC_parse_sof / sof-01-named-value-0: Name and reuse actual sampling value, or name component count, to change allocator priority without changing reads. objdiff 98.085205%; 223/223 instructions, 34 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-01-named-value-1: Name and reuse actual sampling value, or name component count, to change allocator priority without changing reads. objdiff 98.05381%; 223/223 instructions, 34 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-01-named-value-2: Name and reuse actual sampling value, or name component count, to change allocator priority without changing reads. objdiff 97.807175%; 223/223 instructions, 34 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-02-selection-helper: Move the complete sampling-table selection into one real inline helper. objdiff 97.807175%; 223/223 instructions, 40 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
OSInit full clean gate PASS: OS 21/21 instruction-exact, code 5084/5084, data 1240/1240; cache 5/5, JPEG main 13/13. DOL SHA1 remains 26116613f624061ba99c8d1a299aaa6efa85670d; 0 regressions, 0 forbidden additions, 0 readability warnings. Inventory checker reports complete coverage and 12 remaining placeholders, with no stale/unlisted rows; exit 1 is the expected whole-tree completion failure. OSInit removed from inventory.
_CNTCACHEIsTitleRemovable / rem-00-typed-helper: Reconstruct aligned path/TMD buffers and shared NAND classifier using current SDK types. objdiff 89.60976%; 80/82 instructions, 69 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEDeleteContent / del-00-typed-helper: Reconstruct title/content parsing and typed TMD traversal with cleanup label. objdiff 95.793106%; 143/145 instructions, 90 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
TMCJPEGDEC_parse_sof / sof-03-cursor-scope-0: Outer-scope H/V cursors before table pointers, with component increment made explicit when selected. objdiff 97.97309%; 223/223 instructions, 35 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-03-cursor-scope-1: Outer-scope H/V cursors before table pointers, with component increment made explicit when selected. objdiff 97.97309%; 223/223 instructions, 35 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-03-cursor-scope-2: Outer-scope H/V cursors before table pointers, with component increment made explicit when selected. objdiff 98.01794%; 223/223 instructions, 34 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-03-cursor-scope-3: Outer-scope H/V cursors before table pointers, with component increment made explicit when selected. objdiff 98.01794%; 223/223 instructions, 34 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-04-source-order-0: Initialize sampling table pointers in the target relocation order; explicitly order component increment as selected. objdiff 97.950676%; 223/223 instructions, 38 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-04-source-order-1: Initialize sampling table pointers in the target relocation order; explicitly order component increment as selected. objdiff 97.950676%; 223/223 instructions, 38 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-04-source-order-2: Initialize sampling table pointers in the target relocation order; explicitly order component increment as selected. objdiff 97.90583%; 223/223 instructions, 39 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
_CNTCACHEIsTitleRemovable / rem-01-boundary-0: Pass title by const pointer instead of value, retaining real title ownership. objdiff 89.60976%; 80/82 instructions, 69 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEIsTitleRemovable / rem-01-boundary-1: Initialize NAND sentinel counts from the initial state; diagnostic copy-lifetime test. objdiff 91.92683%; 82/82 instructions, 23 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEDeleteContent / del-01-boundary-0: Const-pointer title argument keeps the usage helper independent of caller mask lifetime. objdiff 95.793106%; 143/145 instructions, 90 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEIsTitleRemovable / rem-01-boundary-2: Pass the initial state through the NAND helper and update it on return. objdiff 89.54878%; 82/82 instructions, 34 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEDeleteContent / del-01-boundary-1: Name the parsed title type before the validity guard to separate masks. objdiff 93.10345%; 143/145 instructions, 91 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEIsTitleRemovable / rem-01-boundary-3: Reuse the formatting result local for the NAND return code. objdiff 89.60976%; 80/82 instructions, 69 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEDeleteContent / del-01-boundary-2: Initial state reuse tests the missing NAND-result copy, keeping target sentinel values. objdiff 95.26897%; 144/145 instructions, 113 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
TMCJPEGDEC_parse_sof / sof-05-row-helper-0: Inline actual sampling-row match, reused factor value, and target increment order; parameter order (0, 1, 2, 3). objdiff 97.92825%; 223/223 instructions, 38 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-05-row-helper-1: Inline actual sampling-row match, reused factor value, and target increment order; parameter order (1, 2, 0, 3). objdiff 97.92825%; 223/223 instructions, 38 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-05-row-helper-2: Inline actual sampling-row match, reused factor value, and target increment order; parameter order (2, 1, 0, 3). objdiff 97.860985%; 223/223 instructions, 40 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-05-row-helper-3: Inline actual sampling-row match, reused factor value, and target increment order; parameter order (3, 0, 1, 2). objdiff 97.92825%; 223/223 instructions, 38 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-05-row-helper-4: Inline actual sampling-row match, reused factor value, and target increment order; parameter order (1, 0, 2, 3). objdiff 97.92825%; 223/223 instructions, 38 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-05-row-helper-5: Inline actual sampling-row match, reused factor value, and target increment order; parameter order (2, 0, 1, 3). objdiff 97.860985%; 223/223 instructions, 40 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
_CNTCACHEIsTitleRemovable / rem-02-enum-state-0: Separate NAND errors from the explicit three-state classification with enum types; width and values preserved. objdiff 89.60976%; 80/82 instructions, 69 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEDeleteContent / del-02-title-fields-0: Equivalent high/low title-word extraction changes mask expression identity at the real path-format boundary. objdiff 95.793106%; 143/145 instructions, 90 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEIsTitleRemovable / rem-02-enum-state-1: Separate NAND errors from the explicit three-state classification with enum types; width and values preserved. objdiff 89.60976%; 80/82 instructions, 69 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEDeleteContent / del-02-title-fields-1: Equivalent high/low title-word extraction changes mask expression identity at the real path-format boundary. objdiff 95.793106%; 143/145 instructions, 90 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEIsTitleRemovable / rem-02-enum-state-2: Separate NAND errors from the explicit three-state classification with enum types; width and values preserved. objdiff 89.60976%; 80/82 instructions, 69 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEDeleteContent / del-02-title-fields-2: Equivalent high/low title-word extraction changes mask expression identity at the real path-format boundary. objdiff 95.793106%; 143/145 instructions, 90 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEIsTitleRemovable / rem-02-enum-state-3: Separate NAND errors from the explicit three-state classification with enum types; width and values preserved. objdiff 89.60976%; 80/82 instructions, 69 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEDeleteContent / del-02-title-fields-3: Equivalent high/low title-word extraction changes mask expression identity at the real path-format boundary. objdiff 95.793106%; 143/145 instructions, 90 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEDeleteContent / del-02-title-fields-4: Equivalent high/low title-word extraction changes mask expression identity at the real path-format boundary. objdiff 95.793106%; 143/145 instructions, 90 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
TMCJPEGDEC_parse_sof / sof-06-direct-inner-0: Remove named inner pointer cursors and use direct indexed sampling arrays, leaving outer table walks unchanged. objdiff 98.37668%; 223/223 instructions, 24 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
_CNTCACHEIsTitleRemovable / rem-03-state-lifetime-0: Try a real state/error lifetime or const title boundary without adding instructions or changing SDK layouts by hand. objdiff 87.71951%; 81/82 instructions, 39 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
TMCJPEGDEC_parse_sof / sof-06-direct-inner-1: Remove named inner pointer cursors and use direct indexed sampling arrays, leaving outer table walks unchanged. objdiff 98.37668%; 223/223 instructions, 24 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
_CNTCACHEIsTitleRemovable / rem-03-state-lifetime-1: Try a real state/error lifetime or const title boundary without adding instructions or changing SDK layouts by hand. objdiff 88.37805%; 81/82 instructions, 45 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
TMCJPEGDEC_parse_sof / sof-06-direct-inner-2: Remove named inner pointer cursors and use direct indexed sampling arrays, leaving outer table walks unchanged. objdiff 98.37668%; 223/223 instructions, 24 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
_CNTCACHEIsTitleRemovable / rem-03-state-lifetime-2: Try a real state/error lifetime or const title boundary without adding instructions or changing SDK layouts by hand. objdiff 89.60976%; 80/82 instructions, 69 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
TMCJPEGDEC_parse_sof / sof-06-direct-inner-3: Remove named inner pointer cursors and use direct indexed sampling arrays, leaving outer table walks unchanged. objdiff 98.37668%; 223/223 instructions, 24 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
_CNTCACHEIsTitleRemovable / rem-03-state-lifetime-3: Try a real state/error lifetime or const title boundary without adding instructions or changing SDK layouts by hand. objdiff 85.085365%; 81/82 instructions, 39 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
TMCJPEGDEC_parse_sof / sof-07-direct-outer-1: Use sample indices directly for selected outer arrays while preserving inner indexed component reads; mask 1. objdiff 98.3991%; 223/223 instructions, 23 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-08-geometry-quotients-0: Name full-width quotient intermediates or alter real geometry integer lifetime without changing bounded arithmetic. objdiff 99.52018%; 223/223 instructions, 15 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-07-direct-outer-2: Use sample indices directly for selected outer arrays while preserving inner indexed component reads; mask 2. objdiff 96.56054%; 224/223 instructions, 124 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-08-geometry-quotients-1: Name full-width quotient intermediates or alter real geometry integer lifetime without changing bounded arithmetic. objdiff 98.37668%; 223/223 instructions, 24 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-07-direct-outer-3: Use sample indices directly for selected outer arrays while preserving inner indexed component reads; mask 3. objdiff 96.65022%; 224/223 instructions, 124 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-08-geometry-quotients-2: Name full-width quotient intermediates or alter real geometry integer lifetime without changing bounded arithmetic. objdiff 98.37668%; 223/223 instructions, 24 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-07-direct-outer-4: Use sample indices directly for selected outer arrays while preserving inner indexed component reads; mask 4. objdiff 96.53812%; 224/223 instructions, 124 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-08-geometry-quotients-3: Name full-width quotient intermediates or alter real geometry integer lifetime without changing bounded arithmetic. objdiff 98.37668%; 223/223 instructions, 24 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-07-direct-outer-5: Use sample indices directly for selected outer arrays while preserving inner indexed component reads; mask 5. objdiff 96.6278%; 224/223 instructions, 124 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-08-geometry-quotients-4: Name full-width quotient intermediates or alter real geometry integer lifetime without changing bounded arithmetic. objdiff 97.4574%; 223/223 instructions, 27 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-07-direct-outer-6: Use sample indices directly for selected outer arrays while preserving inner indexed component reads; mask 6. objdiff 96.59193%; 223/223 instructions, 47 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-07-direct-outer-7: Use sample indices directly for selected outer arrays while preserving inner indexed component reads; mask 7. objdiff 96.70403%; 223/223 instructions, 44 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-09-sampling-boundary-0: Preserve exact geometry while moving only the first differing sampling value across a natural inline/local boundary. objdiff 99.5426%; 223/223 instructions, 14 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-09-sampling-boundary-1: Preserve exact geometry while moving only the first differing sampling value across a natural inline/local boundary. objdiff 99.52018%; 223/223 instructions, 15 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-09-sampling-boundary-2: Preserve exact geometry while moving only the first differing sampling value across a natural inline/local boundary. objdiff 99.52018%; 223/223 instructions, 15 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-09-sampling-boundary-3: Preserve exact geometry while moving only the first differing sampling value across a natural inline/local boundary. objdiff 97.41704%; 225/223 instructions, 119 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-09-sampling-boundary-4: Preserve exact geometry while moving only the first differing sampling value across a natural inline/local boundary. objdiff 99.52018%; 223/223 instructions, 15 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-09-sampling-boundary-5: Preserve exact geometry while moving only the first differing sampling value across a natural inline/local boundary. objdiff 99.52018%; 223/223 instructions, 15 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
_CNTCACHEIsTitleRemovable / rem-04-classification-flow-0: Use structured switch/do-while/early-return classification to test return-copy formation. objdiff 88.268295%; 81/82 instructions, 35 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEDeleteContent / del-03-classification-flow-0: Use structured classifier flow inside the existing content loop to test the missing state copy. objdiff 95.034485%; 144/145 instructions, 90 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEIsTitleRemovable / rem-04-classification-flow-1: Use structured switch/do-while/early-return classification to test return-copy formation. objdiff 89.60976%; 80/82 instructions, 69 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEDeleteContent / del-03-classification-flow-1: Use structured classifier flow inside the existing content loop to test the missing state copy. objdiff 95.793106%; 143/145 instructions, 90 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEIsTitleRemovable / rem-04-classification-flow-2: Use structured switch/do-while/early-return classification to test return-copy formation. objdiff 88.268295%; 81/82 instructions, 38 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEDeleteContent / del-03-classification-flow-2: Use structured classifier flow inside the existing content loop to test the missing state copy. objdiff 95.034485%; 144/145 instructions, 90 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEIsTitleRemovable / rem-04-classification-flow-3: Use structured switch/do-while/early-return classification to test return-copy formation. objdiff 85.87805%; 79/82 instructions, 66 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEDeleteContent / del-03-classification-flow-3: Use structured classifier flow inside the existing content loop to test the missing state copy. objdiff 93.68276%; 142/145 instructions, 89 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
TMCJPEGDEC_parse_sof / sof-10-search-review: Fresh measurement of current no-type-mutation search result; review declaration and loop changes before retaining any result. objdiff 99.58744%; 223/223 instructions, 15 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-11-indexed-selection-helper-0: Move indexed sampling search as a unit across a real helper boundary, with const pointer parameter variant. objdiff 99.40807%; 223/223 instructions, 18 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-11-indexed-selection-helper-1: Move indexed sampling search as a unit across a real helper boundary, with const pointer parameter variant. objdiff 99.340805%; 223/223 instructions, 20 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-11-indexed-selection-helper-2: Move indexed sampling search as a unit across a real helper boundary, with const pointer parameter variant. objdiff 97.91928%; 224/223 instructions, 115 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-11-indexed-selection-helper-3: Move indexed sampling search as a unit across a real helper boundary, with const pointer parameter variant. objdiff 97.85202%; 224/223 instructions, 117 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-12-table-parameters-0: Pass actual sampling tables as selector parameters to move their address-expression register identities; order (0, 1, 2). objdiff 99.565025%; 223/223 instructions, 12 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-12-table-parameters-1: Pass actual sampling tables as selector parameters to move their address-expression register identities; order (0, 2, 1). objdiff 99.565025%; 223/223 instructions, 13 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-12-table-parameters-2: Pass actual sampling tables as selector parameters to move their address-expression register identities; order (1, 0, 2). objdiff 99.565025%; 223/223 instructions, 14 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-12-table-parameters-3: Pass actual sampling tables as selector parameters to move their address-expression register identities; order (1, 2, 0). objdiff 99.632286%; 223/223 instructions, 14 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-12-table-parameters-4: Pass actual sampling tables as selector parameters to move their address-expression register identities; order (2, 0, 1). objdiff 99.49776%; 223/223 instructions, 15 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-12-table-parameters-5: Pass actual sampling tables as selector parameters to move their address-expression register identities; order (2, 1, 0). objdiff 99.565025%; 223/223 instructions, 14 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-13-helper-lifetimes-0: Adjust only actual selector index/factor lifetimes and typed table access; preserve all reads and geometry. objdiff 99.45291%; 223/223 instructions, 16 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-13-helper-lifetimes-1: Adjust only actual selector index/factor lifetimes and typed table access; preserve all reads and geometry. objdiff 99.45291%; 223/223 instructions, 16 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-13-helper-lifetimes-2: Adjust only actual selector index/factor lifetimes and typed table access; preserve all reads and geometry. objdiff 99.565025%; 223/223 instructions, 12 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-13-helper-lifetimes-3: Adjust only actual selector index/factor lifetimes and typed table access; preserve all reads and geometry. objdiff 99.565025%; 223/223 instructions, 12 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-13-helper-lifetimes-4: Adjust only actual selector index/factor lifetimes and typed table access; preserve all reads and geometry. objdiff 96.753365%; 226/223 instructions, 123 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-13-helper-lifetimes-5: Adjust only actual selector index/factor lifetimes and typed table access; preserve all reads and geometry. objdiff 99.565025%; 223/223 instructions, 12 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-14-table-argument-locals-0: Materialize real table arguments in local source order before the selector call; order (0, 1, 2). objdiff 99.565025%; 223/223 instructions, 12 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-14-table-argument-locals-1: Materialize real table arguments in local source order before the selector call; order (0, 2, 1). objdiff 99.565025%; 223/223 instructions, 12 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-14-table-argument-locals-2: Materialize real table arguments in local source order before the selector call; order (1, 0, 2). objdiff 99.565025%; 223/223 instructions, 12 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-14-table-argument-locals-3: Materialize real table arguments in local source order before the selector call; order (1, 2, 0). objdiff 99.565025%; 223/223 instructions, 12 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-14-table-argument-locals-4: Materialize real table arguments in local source order before the selector call; order (2, 0, 1). objdiff 99.565025%; 223/223 instructions, 12 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-14-table-argument-locals-5: Materialize real table arguments in local source order before the selector call; order (2, 1, 0). objdiff 99.565025%; 223/223 instructions, 12 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-15-combined-latch-0: Keep each sampling cursor advance in the for-loop update clause; order (0, 1, 2). objdiff 99.52018%; 223/223 instructions, 15 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-15-combined-latch-1: Keep each sampling cursor advance in the for-loop update clause; order (0, 2, 1). objdiff 99.565025%; 223/223 instructions, 15 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-15-combined-latch-2: Keep each sampling cursor advance in the for-loop update clause; order (1, 0, 2). objdiff 99.52018%; 223/223 instructions, 15 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-15-combined-latch-3: Keep each sampling cursor advance in the for-loop update clause; order (1, 2, 0). objdiff 99.60986%; 223/223 instructions, 14 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-15-combined-latch-4: Keep each sampling cursor advance in the for-loop update clause; order (2, 0, 1). objdiff 99.529144%; 223/223 instructions, 15 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-15-combined-latch-5: Keep each sampling cursor advance in the for-loop update clause; order (2, 1, 0). objdiff 99.57399%; 223/223 instructions, 14 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
_CNTCACHEIsTitleRemovable / rem-05-title-values-0: Make real high/low title words explicit around the diagnostic state initialization; compare allocator lifetime and instruction scheduling. objdiff 93.70731%; 82/82 instructions, 23 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEIsTitleRemovable / rem-05-title-values-1: Make real high/low title words explicit around the diagnostic state initialization; compare allocator lifetime and instruction scheduling. objdiff 87.42683%; 80/82 instructions, 69 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEIsTitleRemovable / rem-05-title-values-2: Make real high/low title words explicit around the diagnostic state initialization; compare allocator lifetime and instruction scheduling. objdiff 93.70731%; 82/82 instructions, 23 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEIsTitleRemovable / rem-05-title-values-3: Make real high/low title words explicit around the diagnostic state initialization; compare allocator lifetime and instruction scheduling. objdiff 87.42683%; 80/82 instructions, 69 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEIsTitleRemovable / rem-05-title-values-4: Make real high/low title words explicit around the diagnostic state initialization; compare allocator lifetime and instruction scheduling. objdiff 89.60976%; 80/82 instructions, 69 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
_CNTCACHEIsTitleRemovable / rem-05-title-values-5: Make real high/low title words explicit around the diagnostic state initialization; compare allocator lifetime and instruction scheduling. objdiff 91.39024%; 80/82 instructions, 69 positional differences; POOL IDENTICAL up to 9 (mine=9 base=9).
TMCJPEGDEC_parse_sof / sof-16-sampling-row-type-0: Model each real four-component sampling row as u8[4] in a private header; no table data or other translation unit changes. objdiff 99.52018%; 223/223 instructions, 15 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-16-sampling-row-type-1: Model each real four-component sampling row as u8[4] in a private header; no table data or other translation unit changes. objdiff 99.529144%; 223/223 instructions, 15 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-16-sampling-row-type-2: Model each real four-component sampling row as u8[4] in a private header; no table data or other translation unit changes. objdiff 99.5426%; 223/223 instructions, 14 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-16-sampling-row-type-3: Model each real four-component sampling row as u8[4] in a private header; no table data or other translation unit changes. objdiff 100.0%; 223/223 instructions, 0 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
TMCJPEGDEC_parse_sof / sof-17-readable-exact: Replace the final empty label with a normal continue statement; preserve the exact row-table C implementation. objdiff 100.0%; 223/223 instructions, 0 positional differences; POOL IDENTICAL up to 0 (mine=0 base=0).
## TMCJPEGDEC_parse_sof conversion
The winning source uses six rows of four components for both sampling-factor tables, with direct [sample][component] access. jpformat.c already writes the 24 bytes as six four-byte rows; SampleComps contains six component counts. The target increments each factor-table base by four and its count-table base by one. This is a recovered array shape, with no object-size, section, initializer, or address change.
The parser-only TMC_JPEG_FRAME_PARSER macro exposes [6][4] table declarations and an incomplete SampleComps extern. The incomplete extern matches the target's lis/addi addressing rather than the small-data optimization of a known six-byte array. All other translation units keep their original declarations. The parser uses the existing work/frame fields and a typed component view matching the contiguous map/DC/id/quantization fields.
Direct inner array indexing removed pointer-cursor register differences. Named signed full-width quotient intermediates fixed MCU geometry scheduling while u16 rows/columns preserve the target narrowing. The 2D sampling rows then resolved every remaining register difference. sof-16-sampling-row-type-3 and its readable continue-statement form sof-17-readable-exact both measure 100.0%, 223/223 instructions, diffs 0, data 256/256, empty identical pools, all 13 unit functions exact. The source object built normally with the guarded live header also has ctxdiff diffs 0.
## Search and coverage
Private srcsearch.py changes only definition selection, skipping prototypes, and disables signedness mutations for runs after the first SOF search. Shared search code and its CPU limiter were unchanged. Search runs completed 224 SOF trials at 98.085205%, 207 removable-helper trials at 89.54878%, 207 delete-content trials at 95.793106%, and 216 improved SOF trials at 99.58744%. The search label SOLUTION means equal instruction counts, not exactness. A later selector-helper search was still queued when the independent row-type source became exact; it was stopped as redundant. No non-exact search candidate was installed.
The allocator trace of the prior SOF source was read: named H/V cursors occupy r10/r11 while table walks occupy r5/r6/r7; direct indexing makes those cursors compiler temporaries and recovers the target r4/r3 allocation. A fresh removable trace request waited on the shared debugger lock without starting the emulator, then was canceled. No new trace was obtained; earlier rx18 coalescing evidence remains advisory. The launcher copy would have written captures only under /tmp/rx41 and acquired the shared lock read-only.
Levers reviewed: natural inline boundaries, signedness/width and enums, const inputs, separate/reused locals, declaration order, block scope, counted loops, prior SDK art, real array shape, no cached element pointers, source search and allocator traces. Ghidra exports were read for every assigned function. OSInit was regenerated with a private project directory. A public search for both cache functions returned no source. The eZiText-only, thunk, extab/jump-table, original uninitialized-value, cross-thread volatile, and BSS-order levers do not apply to these routines. Compiler flags and unrelated source remained unchanged. Only the four documented OS relocation additions modify configuration.
Compiled manual coverage:
- OSInit: 3 compiled trials, 3 distinct sources; best 99.96296%, 270/270 instructions, 4 positional differences. Source /tmp/rx41/os-03-address-helper/.
- TMCJPEGDEC_parse_sof: 74 compiled trials, 74 distinct sources; best 100.0%, 223/223 instructions, 0 positional differences. Source /tmp/rx41/sof-17-readable-exact/.
- _CNTCACHEIsTitleRemovable: 23 compiled trials, 23 distinct sources; best 93.70731%, 82/82 instructions, 23 positional differences. Source /tmp/rx41/rem-05-title-values-2/.
- _CNTCACHEDeleteContent: 13 compiled trials, 13 distinct sources; best 95.793106%, 143/145 instructions, 90 positional differences. Source /tmp/rx41/del-02-title-fields-4/.
OSInit's three temporary-source measurements precede the extraction correction; its installed C is 100.0% after the four proven __ArenaLo relocations. Both remaining functions exceed three distinct compiled attempts. Their original asm stays in place, with no claim that either requires assembly.
_CNTCACHEIsTitleRemovable remains open: best diagnostic 93.70731%, 82/82 instructions, 23 differences. Reusing state for sentinel initialization prevents coalescing but forces state into r7 rather than target r4 and changes initial scheduling. The ordinary helper form remains 89.60976%, 80/82, missing the two copies. Enum/const/classifier/real title-field variants did not resolve the allocation.
_CNTCACHEDeleteContent remains open: best 95.793106%, 143/145 instructions. MWCC shares the all-ones title-word mask across the token loop and removes the classifier's result copy, saving two instructions and shifting saved-register allocation. Signed/unsigned equivalent field expressions, structured classifier control flow, separate title words and helper parameters did not recover the target.
## Final validation
The final full gate, without --quick, passes for all three assigned units. Full output: [rx41.final-gate.txt](rx41.final-gate.txt). All string pools are identical. Regressions, forbidden additions and readability warnings are zero. DOL SHA1 is 26116613f624061ba99c8d1a299aaa6efa85670d.
Fresh exact-name objdiff after that clean build gives OSInit 100.0% and TMCJPEGDEC_parse_sof 100.0%. Fresh ctxdiff gives OSInit 270/270 instructions, diffs 0, and parse_sof 223/223, diffs 0.
Before -> after, including the preserved asm:
| Unit | Instruction-exact functions | Exact code bytes | Data bytes |
| --- | --- | --- | --- |
| OS | 21/21 -> 21/21 | 5084/5084 -> 5084/5084 | 1240/1240 -> 1240/1240 |
| cntcache | 5/5 -> 5/5 | 1828/1828 -> 1828/1828 | 280/280 -> 280/280 |
| jdec_main | 13/13 -> 13/13 | 5604/5604 -> 5604/5604 | 256/256 -> 256/256 |
Totals stay 39/39 instruction-exact, 12516/12516 code and 1776/1776 data because asm already counted as exact. Two of the four assigned functions now use C, removing three asm bodies/blocks. OSInit conversion commit: 5511f305.
The source-object snapshot before the final clean rebuild already contained the accepted JPEG object. All 1027 compiled objects reproduce byte-identically after the clean rebuild and final header guard adjustment. Every other translation unit is unchanged. The cache source has no diff.
The inventory has complete coverage: 173 functions, 175 bodies/blocks, 162 ORIGINAL and 11 PLACEHOLDER. Both converted rows are removed. tools/check_asm_inventory.py exits 1 only for the 11 remaining placeholders; there are no stale, duplicate or unlisted entries. The two cache functions are unresolved C reconstruction, not original-assembly exemptions.
All rejected sources and exact measurement artifacts remain under /tmp/rx41. The pre-existing untracked g2 files are untouched. No push, PR, merge, rebase, other-worktree source edit or subagent was performed.

View File

@@ -0,0 +1,35 @@
full build: ok
main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d
[libs/RVL_SDK/src/os/OS] pool: IDENTICAL
[libs/RVL_SDK/src/os/OS] objdiff: code 5084/5084 data 1240/1240 functions 21/21 fuzzy 100.0000 linked code 5084
[libs/RVL_SDK/src/os/OS] instruction-exact functions: 21/21
[libs/RVL_SDK/src/os/OS] section .bss size 112 match 100.0
[libs/RVL_SDK/src/os/OS] section .data size 1008 match 100.0
[libs/RVL_SDK/src/os/OS] section .sbss size 72 match 100.0
[libs/RVL_SDK/src/os/OS] section .sdata size 48 match 100.0
[libs/RVL_SDK/src/os/OS] section .text size 5084 match 100.0
[libs/RVL_SDK/src/os/OS] baseline: code 5084/5084 data 1240 functions 21 fuzzy 100.0000
[libs/RVL_SDK/src/cntcache/cntcache] pool: IDENTICAL
[libs/RVL_SDK/src/cntcache/cntcache] objdiff: code 1828/1828 data 280/280 functions 5/5 fuzzy 100.0000 linked code 1828
[libs/RVL_SDK/src/cntcache/cntcache] instruction-exact functions: 5/5
[libs/RVL_SDK/src/cntcache/cntcache] section .bss size 24 match 100.0
[libs/RVL_SDK/src/cntcache/cntcache] section .data size 232 match 100.0
[libs/RVL_SDK/src/cntcache/cntcache] section .sbss size 16 match 100.0
[libs/RVL_SDK/src/cntcache/cntcache] section .sdata size 8 match 100.0
[libs/RVL_SDK/src/cntcache/cntcache] section .text size 1828 match 100.0
[libs/RVL_SDK/src/cntcache/cntcache] baseline: code 1828/1828 data 280 functions 5 fuzzy 100.0000
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] objdiff: code 5604/5604 data 256/256 functions 13/13 fuzzy 100.0000 linked code 5604
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] instruction-exact functions: 13/13
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] section .rodata size 256 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] section .text size 5604 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] baseline: code 5604/5604 data 256 functions 13 fuzzy 100.0000
regressions vs baseline: 0
global matched_code_percent: 93.99622 -> 93.99622
global fuzzy_match_percent: 99.81744 -> 99.81744
global complete_code_percent: 80.08451 -> 80.08451
global matched_data_percent: 99.99410 -> 99.99410
forbidden patterns added (net, per file): 0
readability warnings (net, per file; must be 0 in the final result): 0
note: config touched: config/43U/config.yml (orchestrator reviews every config/symbols change)
GATE PASS

View File

@@ -0,0 +1,35 @@
full build: ok
main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d
[libs/RVL_SDK/src/os/OS] pool: IDENTICAL
[libs/RVL_SDK/src/os/OS] objdiff: code 5084/5084 data 1240/1240 functions 21/21 fuzzy 100.0000 linked code 5084
[libs/RVL_SDK/src/os/OS] instruction-exact functions: 21/21
[libs/RVL_SDK/src/os/OS] section .bss size 112 match 100.0
[libs/RVL_SDK/src/os/OS] section .data size 1008 match 100.0
[libs/RVL_SDK/src/os/OS] section .sbss size 72 match 100.0
[libs/RVL_SDK/src/os/OS] section .sdata size 48 match 100.0
[libs/RVL_SDK/src/os/OS] section .text size 5084 match 100.0
[libs/RVL_SDK/src/os/OS] baseline: code 5084/5084 data 1240 functions 21 fuzzy 100.0000
[libs/RVL_SDK/src/cntcache/cntcache] pool: IDENTICAL
[libs/RVL_SDK/src/cntcache/cntcache] objdiff: code 1828/1828 data 280/280 functions 5/5 fuzzy 100.0000 linked code 1828
[libs/RVL_SDK/src/cntcache/cntcache] instruction-exact functions: 5/5
[libs/RVL_SDK/src/cntcache/cntcache] section .bss size 24 match 100.0
[libs/RVL_SDK/src/cntcache/cntcache] section .data size 232 match 100.0
[libs/RVL_SDK/src/cntcache/cntcache] section .sbss size 16 match 100.0
[libs/RVL_SDK/src/cntcache/cntcache] section .sdata size 8 match 100.0
[libs/RVL_SDK/src/cntcache/cntcache] section .text size 1828 match 100.0
[libs/RVL_SDK/src/cntcache/cntcache] baseline: code 1828/1828 data 280 functions 5 fuzzy 100.0000
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] objdiff: code 5604/5604 data 256/256 functions 13/13 fuzzy 100.0000 linked code 5604
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] instruction-exact functions: 13/13
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] section .rodata size 256 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] section .text size 5604 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] baseline: code 5604/5604 data 256 functions 13 fuzzy 100.0000
regressions vs baseline: 0
global matched_code_percent: 93.99622 -> 93.99622
global fuzzy_match_percent: 99.81744 -> 99.81744
global complete_code_percent: 80.08451 -> 80.08451
global matched_data_percent: 99.99410 -> 99.99410
forbidden patterns added (net, per file): 0
readability warnings (net, per file; must be 0 in the final result): 0
note: config touched: config/43U/config.yml (orchestrator reviews every config/symbols change)
GATE PASS

View File

@@ -0,0 +1,659 @@
# rx43 expression cleanup
Baseline: `46618a101c2aabcd39559270fa2fd7344accc872`, branch `agent/w1005/rx43`. Both baseline and final clean 4.3U builds produced DOL SHA1 `26116613f624061ba99c8d1a299aaa6efa85670d`.
This round preserves the baseline output. Existing unmatched functions are not matching assignments. Each retained trial rebuilt its object and compared the complete ELF with a saved baseline, including sections, relocations, and symbols. Every rejected trial restored the previous source and rebuilt before continuing.
Inventoried 193 permitted files: three address sources, three address headers, 175 FA sources, and the twelve other named sources. Saved their source, all 1027 compiled objects, and a fresh objdiff report under `/tmp/rx43`. No shared header, TMC header identifier, excluded file, build configuration, or symbol definition changed.
## Result
Changed 32 source files. Retained cleanup counts: 388 constants or sizes, 33 casts, 8 control-flow sites, 8 member or array expressions, and 128 identifier declarations or labels. Identifier counts include AES macro parameters, but exclude repeated uses.
All 1027 rebuilt object SHA256 values equal the baseline. The complete parsed objdiff JSON is identical, including every function, section, and global metric. All 32 touched-unit pools are identical to retail and produce the same `pool_diff.py` output as the baseline. The gate reports zero regressions, zero added forbidden patterns, and zero readability warnings.
Touched units: instruction-exact functions 659/677 -> 659/677; matched code 168228/190716 -> 168228/190716 bytes; matched data 67384/67384 -> 67384/67384 bytes.
31 representative exact functions also passed `ctxdiff.py` with equal instruction counts and `diffs 0`. The JPEG unit has no exact function in the baseline; its complete object still remains identical. No new exact match is claimed.
## Trials
Counts are replacement sites, except names, which count declarations, macro parameters, or labels. KEEP means complete ELF identity; REVERT means bytes changed; ERROR means compilation failed. All REVERT and ERROR trials were restored. Trial 33 is superseded by the self-assignment deletion in 45. Trial 44 was undone in 105 because deleting the newly unused local in 102 changed bytes. These three rows do not count toward the retained totals.
| Trial | File | Category | Change | Count | Result |
| --- | --- | --- | --- | ---: | --- |
| 1 | `src/scene/address/iplAddressEdit.cpp` | constants | Use existing scene IDs in lookups and scene transitions | 51 | ERROR |
| 2 | `src/scene/address/iplAddressEdit.cpp` | constants | Use Button animation enum names for button animation requests | 68 | KEEP |
| 3 | `src/keyboard/tiToolBar.cpp` | constants | Use WPAD_BUTTON_A for the trigger mask | 2 | KEEP |
| 4 | `src/keyboard/tiPredictLang.cpp` | constants | Use WPAD_BUTTON_A for the trigger mask | 2 | KEEP |
| 5 | `libs/NW4R/src/lyt/lyt_window.cpp` | casts | Pass GXColor values without same-type casts | 4 | KEEP |
| 6 | `libs/RevoEX/src/nhttp/NHTTP_recvbuf.c` | constants | Use existing header-buffer length, shift, and mask definitions | 16 | KEEP |
| 7 | `src/scene/address/iplAddressEdit.cpp` | constants | Use scene IDs from the ipl namespace | 51 | KEEP |
| 8 | `src/scene/address/iplAddressEdit.cpp` | constants | Use confirmed-friend status and add-mode enums | 9 | KEEP |
| 9 | `src/scene/address/iplAddressEdit.cpp` | constants | Name the Korean product area | 2 | KEEP |
| 10 | `src/scene/address/iplAddressEdit.cpp` | casts | Remove same-type casts of string literals | 3 | KEEP |
| 11 | `src/keyboard/tiToolBar.cpp` | constants | Use the toggle-off animation enum | 2 | KEEP |
| 12 | `src/keyboard/tiString.cpp` | constants | Name the KPR kana conversion modes | 8 | KEEP |
| 13 | `src/BS2/BS2Update.c` | constants | Use ES and NAND success results and the detached-thread flag | 4 | ERROR |
| 14 | `src/iplwww/www_wiisetting.cpp` | constants | Use the nonblocking OS message flag | 1 | ERROR |
| 15 | `src/scene/address/iplAddressEdit.cpp` | constants | Use the shared controller interaction mask | 3 | KEEP |
| 16 | `src/scene/address/iplAddressEdit.cpp` | constants | Name keyboard input modes | 8 | KEEP |
| 17 | `src/scene/address/iplAddressEdit.cpp` | casts | Use VEC3 pointer conversions in matrix transforms | 6 | KEEP |
| 18 | `src/keyboard/tiString.cpp` | constants | Name translate modes in switches and direct-input comparisons | 12 | KEEP |
| 19 | `src/BS2/BS2Update.c` | constants | Name ES and NAND success results and the SDK detached-thread flag | 4 | KEEP |
| 20 | `src/utility/iplESMisc.cpp` | members | Copy the indexed ticket through its declared array type | 1 | KEEP |
| 21 | `src/utility/iplESMisc.cpp` | members | Copy a ticket view through the typed list | 1 | KEEP |
| 22 | `src/utility/iplESMisc.cpp` | control | Negate the BOOL result from Exist directly | 1 | KEEP |
| 23 | `libs/RVL_SDK/src/fa/api/FAAttach.c` | constants | Use named FA devices and insertion flags | 9 | KEEP |
| 24 | `libs/RVL_SDK/src/fa/api/FARegistCB.c` | constants | Name the registered SD and USB devices | 2 | KEEP |
| 25 | `libs/RVL_SDK/src/fa/api/FAErrnum.c` | constants | Name the public FA error results | 4 | KEEP |
| 26 | `libs/RVL_SDK/src/fa/kernel/pfk_api.c` | control | Test OS thread BOOL results directly | 2 | REVERT |
| 27 | `libs/RVL_SDK/src/fa/driver/nand_drv.c` | constants | Name NAND file permissions, access, seek origins, and errors | 16 | KEEP |
| 28 | `libs/RVL_SDK/src/fa/pdm_disk.c` | constants | Use the declared disk limit | 4 | KEEP |
| 29 | `libs/RVL_SDK/src/fa/driver/nand_drv.c` | casts | Remove the same-type cast of total | 1 | KEEP |
| 30 | `libs/RVL_SDK/src/fa/driver/sd_drv.c` | casts | Remove the same-type cast of sectors_16 | 1 | KEEP |
| 31 | `libs/RVL_SDK/src/fa/driver/sd_drv.c` | casts | Remove the same-type cast of start_head | 1 | KEEP |
| 32 | `libs/RVL_SDK/src/fa/driver/sd_drv.c` | casts | Remove the same-type cast of end_head | 1 | KEEP |
| 33 | `libs/RVL_SDK/src/fa/pf_path.c` | casts | Remove the same-type cast of tmp_wc | 1 | KEEP (superseded) |
| 34 | `libs/RVL_SDK/src/fa/pf_path.c` | casts | Remove the same-type cast of wc | 1 | REVERT |
| 35 | `libs/RVL_SDK/src/fa/pdm_api.c` | control | Return the error directly without a redundant ternary | 3 | REVERT |
| 36 | `libs/RVL_SDK/src/fa/api/FAErrnum.c` | control | Return the error without an identity ternary | 1 | REVERT |
| 37 | `libs/RVL_SDK/src/fa/api/FAFopen.c` | control | Remove the null pointer self-assignment | 1 | REVERT |
| 38 | `libs/RVL_SDK/src/fa/kernel/pfk_api.c` | control | Test OSIsThreadSuspended directly | 1 | REVERT |
| 39 | `libs/RVL_SDK/src/fa/kernel/pfk_api.c` | control | Test OSSetThreadPriority directly | 1 | REVERT |
| 40 | `libs/RVL_SDK/src/fa/pf_cp932.c` | names | Name the converted character buffers | 2 | KEEP |
| 41 | `src/iplwww/www_wiisetting.cpp` | names | Name the property-name copy cursors | 4 | KEEP |
| 42 | `src/scene/address/iplAddress.cpp` | names | Name the friend saved during swap | 1 | KEEP |
| 43 | `src/keyboard/tiZiString.cpp` | casts | Use the existing typed dictionary-table pointer | 1 | KEEP |
| 44 | `src/keyboard/tiPredictLang.cpp` | control | Return the prediction mode without assigning a discarded local | 1 | KEEP (superseded) |
| 45 | `libs/RVL_SDK/src/fa/pf_path.c` | control | Remove the now-redundant temporary self-assignment | 1 | KEEP |
| 46 | `libs/RVL_SDK/src/fa/pdm_partition.c` | constants | Use the declared partition limit | 4 | KEEP |
| 47 | `src/utility/iplESMisc.cpp` | constants | Use the declared maximum number of title contents | 1 | KEEP |
| 48 | `src/utility/iplESMisc.cpp` | constants | Name ES success checks and the heap alignment | 6 | KEEP |
| 49 | `src/scene/address/iplAddressEdit.cpp` | constants | Use existing common messages in dialog and button calls | 25 | KEEP |
| 50 | `src/scene/address/iplAddressEdit.cpp` | constants | Name network dialog text and button messages | 10 | REVERT |
| 51 | `src/keyboard/tiString.cpp` | constants | Write sentence punctuation as character literals | 3 | KEEP |
| 52 | `src/iplwww/www_wiisetting.cpp` | casts | Pass the DPD callback with its declared function type | 1 | ERROR |
| 53 | `src/scene/address/iplAddressEdit.cpp` | constants | Name network dialog messages with verified numeric values | 9 | KEEP |
| 54 | `src/scene/address/iplAddressEdit.cpp` | constants | Name friend types, the friend limit, and WiiConnect24 enable flag | 6 | KEEP |
| 55 | `src/keyboard/tiZiString.cpp` | constants | Use Zi dictionary language constants | 11 | KEEP |
| 56 | `src/keyboard/tiZiString.cpp` | constants | Write word delimiters and ASCII ranges as character literals | 9 | KEEP |
| 57 | `libs/RevoEX/src/nhttp/NHTTP_recvbuf.c` | constants | Express lowercase conversion using its ASCII character difference | 1 | KEEP |
| 58 | `libs/RevoEX/src/net/aes.c` | constants | Use the CBC chain size when copying its initialization vector | 1 | KEEP |
| 59 | `libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var.c` | control | Express the unsigned clamp as direct range checks | 1 | KEEP |
| 60 | `libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var.c` | control | Express the signed clamp as direct range checks | 1 | REVERT |
| 61 | `libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var.c` | names | Name IDCT workspace, coefficients, butterfly outputs, and loop positions | 60 | KEEP |
| 62 | `libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var.c` | names | Name clamp input values and the unsigned range flag | 3 | KEEP |
| 63 | `libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var.c` | control | Use the original unsigned range condition without a temporary flag | 1 | REVERT |
| 64 | `src/BS2/BS2Update.c` | constants | Name product regions in the region-validation switch | 6 | KEEP |
| 65 | `src/keyboard/tiToolBar.cpp` | constants | Name valid indices in the animation resource table | 24 | KEEP |
| 66 | `libs/RVL_SDK/src/fa/pf_clib.c` | casts | Use typed wide-string pointers without casts that discard const | 4 | KEEP |
| 67 | `libs/RVL_SDK/src/fa/pf_str.c` | casts | Pass a const narrow string directly to the character converter | 2 | KEEP |
| 68 | `libs/RevoEX/src/net/aes.c` | names | Name AES state words and finite-field multiplication intermediates | 39 | KEEP |
| 69 | `libs/RVL_SDK/src/fa/pf_str.c` | names | Name the two compared string cursors | 4 | KEEP |
| 70 | `libs/RVL_SDK/src/fa/pf_path.c` | casts | Pass the declared const OEM input without casting away const | 1 | KEEP |
| 71 | `libs/RVL_SDK/src/fa/pf_clib.c` | control | Use a direct wide-string pointer difference | 1 | REVERT |
| 72 | `libs/RVL_SDK/src/fa/pf_service.c` | casts | Remove casts of an already unsigned-byte buffer | 3 | KEEP |
| 73 | `libs/RVL_SDK/src/fa/driver/nand_drv.c` | control | Test whether the disk search exhausted its array directly | 2 | REVERT |
| 74 | `libs/RevoEX/src/nhttp/NHTTP_recvbuf.c` | control | Use logical conjunction for the ASCII uppercase test | 1 | REVERT |
| 75 | `src/scene/address/iplAddressEdit.cpp` | members | Use the friend-name member size when clearing it | 1 | KEEP |
| 76 | `src/keyboard/tiPredictLang.cpp` | names | Name each pane animation descriptor | 1 | KEEP |
| 77 | `src/keyboard/tiToolBar.cpp` | names | Name each pane animation descriptor | 1 | KEEP |
| 78 | `libs/RVL_SDK/src/fa/pf_entry_iterator.c` | control | Negate the iterator end predicate directly | 2 | KEEP |
| 79 | `libs/RVL_SDK/src/fa/pf_entry.c` | control | Negate the iterator end predicate directly | 1 | KEEP |
| 80 | `libs/RVL_SDK/src/fa/pf_sector.c` | control | Negate the media-inserted predicate directly | 2 | KEEP |
| 81 | `src/scene/address/iplAddress.cpp` | control | Return the drag-state bool directly | 1 | REVERT |
| 82 | `libs/RVL_SDK/src/fa/pf_volume.c` | constants | Use the existing FAT32 enum from the FAT header | 6 | REVERT |
| 83 | `libs/RVL_SDK/src/fa/driver/sd_drv.c` | constants | Use the existing FAT12 format enum | 1 | REVERT |
| 84 | `libs/RVL_SDK/src/fa/api/FAAttach.c` | constants | Name public FA success and general-error returns | 4 | KEEP |
| 85 | `libs/RVL_SDK/src/fa/api/FADetach.c` | constants | Name public FA success and general-error returns | 4 | KEEP |
| 86 | `libs/RVL_SDK/src/fa/api/FAInit.c` | constants | Name public FA success and general-error returns | 4 | KEEP |
| 87 | `libs/RVL_SDK/src/fa/api/FARegistCB.c` | constants | Name public FA success and general-error returns | 2 | KEEP |
| 88 | `libs/RVL_SDK/src/fa/pf_file.c` | constants | Name seek origins with the public FA enum | 3 | KEEP |
| 89 | `libs/RVL_SDK/src/fa/pf_fat12.c` | members | Index the existing FAT byte buffer directly | 5 | KEEP |
| 90 | `libs/RevoEX/src/nhttp/NHTTP_recvbuf.c` | casts | Keep the receive cursor typed as a byte pointer | 1 | ERROR |
| 91 | `libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var.c` | names | Give luminance row-transform values and output strides separate names | 10 | REVERT |
| 92 | `libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var.c` | names | Give sparse and full chroma transform values separate names | 15 | REVERT |
| 93 | `libs/RevoEX/src/nhttp/NHTTP_recvbuf.c` | casts | Use the receive buffer declared char type for its cursor | 1 | REVERT |
| 94 | `libs/RevoEX/src/nhttp/NHTTP_recvbuf.c` | names | Name the body receive cursor | 1 | KEEP |
| 95 | `src/iplwww/www_wiisetting.cpp` | constants | Use the country write-back index enum | 1 | KEEP |
| 96 | `libs/RVL_SDK/src/fa/pf_path.c` | casts | Pass the wide-character member without a same-type cast | 1 | REVERT |
| 97 | `libs/RVL_SDK/src/fa/pf_path.c` | control | Remove the wide-character destination self-assignment | 1 | REVERT |
| 98 | `libs/RVL_SDK/src/fa/pf_path.c` | casts | Use the declared 16-bit little-endian accessor result | 5 | KEEP |
| 99 | `libs/RVL_SDK/src/fa/pf_path.c` | names | Name converted pattern characters | 2 | KEEP |
| 100 | `libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var.c` | names | Name luminance butterfly temporaries without splitting their lifetimes | 4 | KEEP |
| 101 | `libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var.c` | names | Name chroma row extent, shared rotation, and transform phases | 4 | KEEP |
| 102 | `src/keyboard/tiPredictLang.cpp` | control | Remove the prediction mode local made unused by a direct return | 1 | REVERT |
| 103 | `src/keyboard/tiZiString.cpp` | constants | Write the remaining ASCII digit bounds as characters | 2 | KEEP |
| 104 | `libs/RVL_SDK/src/fa/driver/nand_drv.c` | constants | Name NAND helper success values and direct NAND-call checks | 19 | KEEP |
| 105 | `src/keyboard/tiPredictLang.cpp` | control | Restore the original assignment because removing its unused local changes bytes | 1 | KEEP (superseded) |
| 106 | `src/scene/address/iplAddressEdit.cpp` | constants | Name direct button animation requests missed by the first pass | 4 | KEEP |
| 107 | `src/scene/address/iplAddressEdit.cpp` | constants | Name parental messaging restrictions and confirmed friend checks | 4 | KEEP |
| 108 | `src/scene/address/iplAddressEdit.cpp` | constants | Name product regions in keyboard setup switches | 4 | KEEP |
| 109 | `src/scene/address/iplAddressEdit.cpp` | constants | Name friend registration mode switch cases | 2 | KEEP |
| 110 | `src/scene/address/iplAddressEdit.cpp` | constants | Name the Mii attachment message | 1 | KEEP |
| 111 | `src/scene/address/iplAddressEdit.cpp` | names | Name saved friend status as a status rather than an address type | 2 | KEEP |
| 112 | `src/scene/address/iplAddress.cpp` | constants | Name the waiting-friend email subject and body messages | 2 | KEEP |
| 113 | `src/scene/address/iplAddressEdit.cpp` | constants | Name keyboard state bounds where a declared enum exists | 4 | KEEP |
## Rejected candidates and scope decisions
- Trials 1 and 13 used an incorrect namespace or SDK spelling. The corrected scene IDs and `OS_THREAD_ATTR_DETACH` passed in 7 and 19. This SDK has no named nonblocking message flag, so 14 remains literal zero.
- Trial 50 incorrectly mapped message 446 to an enum for 454. The object comparison rejected it. Trial 53 retained only verified values; message 446 remains unchanged because no matching named entry exists.
- Trial 52 could not remove the DPD callback cast: the declared SDK parameter is `KPADCallback*`, whereas the callback is a function pointer. Changing that shared signature is outside this task.
- Trials 26, 38, and 39 changed bytes when simplifying OS thread BOOL checks. Trials 35, 36, 37, 71, 73, and 81 changed bytes when simplifying returns, self-assignment, pointer differences, or ternaries. The original expressions remain.
- The unsigned JPEG clamp accepted direct branches while retaining its range flag. The signed clamp and removing the unsigned range flag changed bytes (60 and 63). Splitting reused JPEG variables into separate lifetimes also changed bytes (91 and 92); accepted renames preserve declarations, statement order, and lifetimes.
- The FAT enums in 82 and 83 have the expected numeric values, but including their headers and using them changed object output. The source was restored.
- The HTTP receive pointer could not be implicitly initialized as `u8*` from the declared `char*` buffer (90). A `char*` cursor compiled but changed bytes (93). Changing the uppercase test from bitwise to logical conjunction also changed bytes (74).
- Remaining same-type narrow-integer casts and destination self-assignment in `pf_path.c` changed bytes in 34, 96, and 97. Accepted accessor casts were removed in 98.
- Address hover counters use `== TRUE` as a count-of-one check and must not become a general truth test. Internal PF errors have different meanings from public FA errno values; numeric-only PF aliases would not improve readability.
- Existing serialized disk offsets and the save-block offset accesses in ESMisc have no verified declared member equivalent. No new struct layout or shared-header guard was introduced.
- `math_types.cpp`, address headers, and `iplAddressAddSel.cpp` had no suitable remaining cleanup from the requested categories. They remain byte-for-byte source-identical. The toolbar table still contains its pre-existing index 7; the animation enum defines only indices 0 through 6.
- Three casts removed from `pf_service.c` occur in its DEBUG branch. The mandated release 4.3U build validates byte preservation; a separate DEBUG configuration was not built.
- Source comments are unchanged in every touched file. A final scan of all 193 permitted files found no Ghidra or m2c placeholder identifiers. Mathematical one-letter temporaries that would require lifetime changes remain where trials rejected those changes.
## Files changed
- `libs/NW4R/src/lyt/lyt_window.cpp`
- `libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var.c`
- `libs/RVL_SDK/src/fa/api/FAAttach.c`
- `libs/RVL_SDK/src/fa/api/FADetach.c`
- `libs/RVL_SDK/src/fa/api/FAErrnum.c`
- `libs/RVL_SDK/src/fa/api/FAInit.c`
- `libs/RVL_SDK/src/fa/api/FARegistCB.c`
- `libs/RVL_SDK/src/fa/driver/nand_drv.c`
- `libs/RVL_SDK/src/fa/driver/sd_drv.c`
- `libs/RVL_SDK/src/fa/pdm_disk.c`
- `libs/RVL_SDK/src/fa/pdm_partition.c`
- `libs/RVL_SDK/src/fa/pf_clib.c`
- `libs/RVL_SDK/src/fa/pf_cp932.c`
- `libs/RVL_SDK/src/fa/pf_entry.c`
- `libs/RVL_SDK/src/fa/pf_entry_iterator.c`
- `libs/RVL_SDK/src/fa/pf_fat12.c`
- `libs/RVL_SDK/src/fa/pf_file.c`
- `libs/RVL_SDK/src/fa/pf_path.c`
- `libs/RVL_SDK/src/fa/pf_sector.c`
- `libs/RVL_SDK/src/fa/pf_service.c`
- `libs/RVL_SDK/src/fa/pf_str.c`
- `libs/RevoEX/src/net/aes.c`
- `libs/RevoEX/src/nhttp/NHTTP_recvbuf.c`
- `src/BS2/BS2Update.c`
- `src/iplwww/www_wiisetting.cpp`
- `src/keyboard/tiPredictLang.cpp`
- `src/keyboard/tiString.cpp`
- `src/keyboard/tiToolBar.cpp`
- `src/keyboard/tiZiString.cpp`
- `src/scene/address/iplAddress.cpp`
- `src/scene/address/iplAddressEdit.cpp`
- `src/utility/iplESMisc.cpp`
## Pre-existing non-matching functions
These 18 baseline functions remain unchanged. They retain their existing code-generation differences from retail. This cleanup intentionally does not alter those bytes.
| Unit | Exact symbol | Objdiff before and after |
| --- | --- | ---: |
| `libs/NW4R/src/lyt/lyt_window` | `DrawFrame__Q34nw4r3lyt6WindowFRCQ34nw4r4math4VEC2RCQ44nw4r3lyt6Window5FrameRCQ34nw4r3lyt15WindowFrameSizeUc` | 98.17819% |
| `libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var` | `TMCJPEGDEC_IdctBlock_Lumi` | 86.178986% |
| `libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var` | `TMCJPEGDEC_IdctBlock_Col` | 92.927315% |
| `libs/RVL_SDK/src/fa/driver/sd_drv` | `pfd_sddrv_init` | 93.125% |
| `libs/RVL_SDK/src/fa/driver/sd_drv` | `pfd_sddrv_finalize` | 92.63158% |
| `libs/RVL_SDK/src/fa/driver/sd_drv` | `pfd_sddrv_build_fat32_mbr_bpb` | 95.202705% |
| `libs/RVL_SDK/src/fa/pdm_partition` | `pdm_part_is_master_boot_sector` | 87.39286% |
| `libs/RevoEX/src/net/aes` | `AESiEncryptBlock` | 65.81013% |
| `libs/RevoEX/src/net/aes` | `AESiDecryptBlock` | 78.95618% |
| `libs/RevoEX/src/nhttp/NHTTP_recvbuf` | `NHTTPi_compareTokenN_HdrRecvBuf` | 97.32258% |
| `src/BS2/BS2Update` | `UpdateThread` | 95.23877% |
| `src/iplwww/www_wiisetting` | `Getter___Q23www10wiisettingFP14WWWJSPluginObjPCcP16WWWJSPluginValue` | 99.86043% |
| `src/keyboard/tiString` | `inputChar__Q39textinput8tistring9DecolatedFw` | 90.757355% |
| `src/keyboard/tiZiString` | `update__Q39textinput8tistring6WithZiFv` | 98.36996% |
| `src/scene/address/iplAddressEdit` | `create__Q33ipl5scene11AddressEditFv` | 97.5561% |
| `src/scene/address/iplAddressEdit` | `get_friendinfo__Q33ipl5scene11AddressEditFv` | 88.03571% |
| `src/scene/address/iplAddressEdit` | `update_friendinfo__Q33ipl5scene11AddressEditFv` | 99.42105% |
| `src/utility/iplESMisc` | `DeleteUnauthorizedData__Q33ipl7utility6ESMiscFPQ23EGG4Heap` | 99.14254% |
## Verification commands
```sh
python3 /mnt/drive2/projects/wii-ipl-workers/_restore0928-tools/gate.py <all 32 changed units> --base 46618a101c2aabcd39559270fa2fd7344accc872
build/tools/objdiff-cli report generate -p . -o /tmp/rx43/after.json -f json
python3 tools/decomp-assist/pool_diff.py build/43U/src/<unit>.o build/43U/obj/<unit>.o
python3 tools/decomp-assist/ctxdiff.py <unit> <exact-symbol>
git diff --check
```
The full gate below is the final non-quick run. Supplemental evidence in `/tmp/rx43` includes baseline/final JSON, complete object hashes, each trial build output, rejected source diffs and objects, pool output, and ctxdiff output.
## Final full gate
```text
full build: ok
main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d
[libs/NW4R/src/lyt/lyt_window] pool: IDENTICAL
[libs/NW4R/src/lyt/lyt_window] objdiff: code 9848/11352 data 316/316 functions 20/21 fuzzy 99.7586 linked code 0
[libs/NW4R/src/lyt/lyt_window] instruction-exact functions: 20/21
[libs/NW4R/src/lyt/lyt_window] section .ctors size 4 match 100.0
[libs/NW4R/src/lyt/lyt_window] section .data size 256 match 100.0
[libs/NW4R/src/lyt/lyt_window] section .sbss size 8 match 100.0
[libs/NW4R/src/lyt/lyt_window] section .sdata2 size 48 match 100.0
[libs/NW4R/src/lyt/lyt_window] section .text size 11352 match 99.75864
[libs/NW4R/src/lyt/lyt_window] below 100: DrawFrame__Q34nw4r3lyt6WindowFRCQ34nw4r4math4VEC2RCQ44nw4r3lyt6Window5FrameRCQ34nw4r3lyt15WindowFrameSizeUc 98.17819
[libs/NW4R/src/lyt/lyt_window] baseline: code 9848/11352 data 316 functions 20 fuzzy 99.7586
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] objdiff: code None/2844 data None/None functions 0/2 fuzzy 90.4880 linked code 0
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] instruction-exact functions: 0/2
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] section .text size 2844 match 90.488045
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] below 100: TMCJPEGDEC_IdctBlock_Lumi 86.178986
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] below 100: TMCJPEGDEC_IdctBlock_Col 92.927315
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] baseline: code None/2844 data None functions 0 fuzzy 90.4880
[libs/RVL_SDK/src/fa/api/FAAttach] pool: IDENTICAL
[libs/RVL_SDK/src/fa/api/FAAttach] objdiff: code 500/500 data 240/240 functions 1/1 fuzzy 100.0000 linked code 500
[libs/RVL_SDK/src/fa/api/FAAttach] instruction-exact functions: 1/1
[libs/RVL_SDK/src/fa/api/FAAttach] section .bss size 208 match 100.0
[libs/RVL_SDK/src/fa/api/FAAttach] section .data size 24 match 100.0
[libs/RVL_SDK/src/fa/api/FAAttach] section .sdata size 8 match 100.0
[libs/RVL_SDK/src/fa/api/FAAttach] section .text size 500 match 100.0
[libs/RVL_SDK/src/fa/api/FAAttach] baseline: code 500/500 data 240 functions 1 fuzzy 100.0000
[libs/RVL_SDK/src/fa/api/FADetach] pool: IDENTICAL
[libs/RVL_SDK/src/fa/api/FADetach] objdiff: code 168/168 data None/None functions 1/1 fuzzy 100.0000 linked code 168
[libs/RVL_SDK/src/fa/api/FADetach] instruction-exact functions: 1/1
[libs/RVL_SDK/src/fa/api/FADetach] section .text size 168 match 100.0
[libs/RVL_SDK/src/fa/api/FADetach] baseline: code 168/168 data None functions 1 fuzzy 100.0000
[libs/RVL_SDK/src/fa/api/FAErrnum] pool: IDENTICAL
[libs/RVL_SDK/src/fa/api/FAErrnum] objdiff: code 64/64 data None/None functions 1/1 fuzzy 100.0000 linked code 64
[libs/RVL_SDK/src/fa/api/FAErrnum] instruction-exact functions: 1/1
[libs/RVL_SDK/src/fa/api/FAErrnum] section .text size 64 match 100.0
[libs/RVL_SDK/src/fa/api/FAErrnum] baseline: code 64/64 data None functions 1 fuzzy 100.0000
[libs/RVL_SDK/src/fa/api/FAInit] pool: IDENTICAL
[libs/RVL_SDK/src/fa/api/FAInit] objdiff: code 208/208 data 88/88 functions 1/1 fuzzy 100.0000 linked code 208
[libs/RVL_SDK/src/fa/api/FAInit] instruction-exact functions: 1/1
[libs/RVL_SDK/src/fa/api/FAInit] section .data size 72 match 100.0
[libs/RVL_SDK/src/fa/api/FAInit] section .sbss size 8 match 100.0
[libs/RVL_SDK/src/fa/api/FAInit] section .sdata size 8 match 100.0
[libs/RVL_SDK/src/fa/api/FAInit] section .text size 208 match 100.0
[libs/RVL_SDK/src/fa/api/FAInit] baseline: code 208/208 data 88 functions 1 fuzzy 100.0000
[libs/RVL_SDK/src/fa/api/FARegistCB] pool: IDENTICAL
[libs/RVL_SDK/src/fa/api/FARegistCB] objdiff: code 300/300 data 24/24 functions 5/5 fuzzy 100.0000 linked code 300
[libs/RVL_SDK/src/fa/api/FARegistCB] instruction-exact functions: 5/5
[libs/RVL_SDK/src/fa/api/FARegistCB] section .bss size 24 match 100.0
[libs/RVL_SDK/src/fa/api/FARegistCB] section .text size 300 match 100.0
[libs/RVL_SDK/src/fa/api/FARegistCB] baseline: code 300/300 data 24 functions 5 fuzzy 100.0000
[libs/RVL_SDK/src/fa/driver/nand_drv] pool: IDENTICAL
[libs/RVL_SDK/src/fa/driver/nand_drv] objdiff: code 6952/6952 data 5696/5696 functions 18/18 fuzzy 100.0000 linked code 6952
[libs/RVL_SDK/src/fa/driver/nand_drv] instruction-exact functions: 18/18
[libs/RVL_SDK/src/fa/driver/nand_drv] section .bss size 5624 match 100.0
[libs/RVL_SDK/src/fa/driver/nand_drv] section .rodata size 32 match 100.0
[libs/RVL_SDK/src/fa/driver/nand_drv] section .sbss size 32 match 100.0
[libs/RVL_SDK/src/fa/driver/nand_drv] section .sdata size 8 match 100.0
[libs/RVL_SDK/src/fa/driver/nand_drv] section .text size 6952 match 100.0
[libs/RVL_SDK/src/fa/driver/nand_drv] baseline: code 6952/6952 data 5696 functions 18 fuzzy 100.0000
[libs/RVL_SDK/src/fa/driver/sd_drv] pool: IDENTICAL
[libs/RVL_SDK/src/fa/driver/sd_drv] objdiff: code 10068/11760 data 3592/3592 functions 23/26 fuzzy 99.1582 linked code 0
[libs/RVL_SDK/src/fa/driver/sd_drv] instruction-exact functions: 23/26
[libs/RVL_SDK/src/fa/driver/sd_drv] section .bss size 608 match 100.0
[libs/RVL_SDK/src/fa/driver/sd_drv] section .data size 2576 match 100.0
[libs/RVL_SDK/src/fa/driver/sd_drv] section .rodata size 368 match 100.0
[libs/RVL_SDK/src/fa/driver/sd_drv] section .sbss size 40 match 100.0
[libs/RVL_SDK/src/fa/driver/sd_drv] section .text size 11760 match 99.158165
[libs/RVL_SDK/src/fa/driver/sd_drv] below 100: pfd_sddrv_init 93.125
[libs/RVL_SDK/src/fa/driver/sd_drv] below 100: pfd_sddrv_finalize 92.63158
[libs/RVL_SDK/src/fa/driver/sd_drv] below 100: pfd_sddrv_build_fat32_mbr_bpb 95.202705
[libs/RVL_SDK/src/fa/driver/sd_drv] baseline: code 10068/11760 data 3592 functions 23 fuzzy 99.1582
[libs/RVL_SDK/src/fa/pdm_disk] pool: IDENTICAL
[libs/RVL_SDK/src/fa/pdm_disk] objdiff: code 2028/2028 data 2504/2504 functions 17/17 fuzzy 100.0000 linked code 2028
[libs/RVL_SDK/src/fa/pdm_disk] instruction-exact functions: 17/17
[libs/RVL_SDK/src/fa/pdm_disk] section .bss size 2504 match 100.0
[libs/RVL_SDK/src/fa/pdm_disk] section .text size 2028 match 100.0
[libs/RVL_SDK/src/fa/pdm_disk] baseline: code 2028/2028 data 2504 functions 17 fuzzy 100.0000
[libs/RVL_SDK/src/fa/pdm_partition] pool: IDENTICAL
[libs/RVL_SDK/src/fa/pdm_partition] objdiff: code 3380/3716 data None/None functions 19/20 fuzzy 98.8601 linked code 0
[libs/RVL_SDK/src/fa/pdm_partition] instruction-exact functions: 19/20
[libs/RVL_SDK/src/fa/pdm_partition] section .text size 3716 match 98.86006
[libs/RVL_SDK/src/fa/pdm_partition] below 100: pdm_part_is_master_boot_sector 87.39286
[libs/RVL_SDK/src/fa/pdm_partition] baseline: code 3380/3716 data None functions 19 fuzzy 98.8601
[libs/RVL_SDK/src/fa/pf_clib] pool: IDENTICAL
[libs/RVL_SDK/src/fa/pf_clib] objdiff: code 1084/1084 data None/None functions 12/12 fuzzy 100.0000 linked code 1084
[libs/RVL_SDK/src/fa/pf_clib] instruction-exact functions: 12/12
[libs/RVL_SDK/src/fa/pf_clib] section .text size 1084 match 100.0
[libs/RVL_SDK/src/fa/pf_clib] baseline: code 1084/1084 data None functions 12 fuzzy 100.0000
[libs/RVL_SDK/src/fa/pf_cp932] pool: IDENTICAL
[libs/RVL_SDK/src/fa/pf_cp932] objdiff: code 1296/1296 data 17016/17016 functions 6/6 fuzzy 100.0000 linked code 1296
[libs/RVL_SDK/src/fa/pf_cp932] instruction-exact functions: 6/6
[libs/RVL_SDK/src/fa/pf_cp932] section .rodata size 17016 match 100.0
[libs/RVL_SDK/src/fa/pf_cp932] section .text size 1296 match 100.0
[libs/RVL_SDK/src/fa/pf_cp932] baseline: code 1296/1296 data 17016 functions 6 fuzzy 100.0000
[libs/RVL_SDK/src/fa/pf_entry] pool: IDENTICAL
[libs/RVL_SDK/src/fa/pf_entry] objdiff: code 6532/6532 data 24/24 functions 20/20 fuzzy 100.0000 linked code 6532
[libs/RVL_SDK/src/fa/pf_entry] instruction-exact functions: 20/20
[libs/RVL_SDK/src/fa/pf_entry] section .data size 16 match 100.0
[libs/RVL_SDK/src/fa/pf_entry] section .sdata2 size 8 match 100.0
[libs/RVL_SDK/src/fa/pf_entry] section .text size 6532 match 100.0
[libs/RVL_SDK/src/fa/pf_entry] baseline: code 6532/6532 data 24 functions 20 fuzzy 100.0000
[libs/RVL_SDK/src/fa/pf_entry_iterator] pool: IDENTICAL
[libs/RVL_SDK/src/fa/pf_entry_iterator] objdiff: code 7880/7880 data 24/24 functions 16/16 fuzzy 100.0000 linked code 7880
[libs/RVL_SDK/src/fa/pf_entry_iterator] instruction-exact functions: 16/16
[libs/RVL_SDK/src/fa/pf_entry_iterator] section .sdata size 24 match 100.0
[libs/RVL_SDK/src/fa/pf_entry_iterator] section .text size 7880 match 100.0
[libs/RVL_SDK/src/fa/pf_entry_iterator] baseline: code 7880/7880 data 24 functions 16 fuzzy 100.0000
[libs/RVL_SDK/src/fa/pf_fat12] pool: IDENTICAL
[libs/RVL_SDK/src/fa/pf_fat12] objdiff: code 2164/2164 data None/None functions 4/4 fuzzy 100.0000 linked code 2164
[libs/RVL_SDK/src/fa/pf_fat12] instruction-exact functions: 4/4
[libs/RVL_SDK/src/fa/pf_fat12] section .text size 2164 match 100.0
[libs/RVL_SDK/src/fa/pf_fat12] baseline: code 2164/2164 data None functions 4 fuzzy 100.0000
[libs/RVL_SDK/src/fa/pf_file] pool: IDENTICAL
[libs/RVL_SDK/src/fa/pf_file] objdiff: code 17820/17820 data None/None functions 45/45 fuzzy 100.0000 linked code 17820
[libs/RVL_SDK/src/fa/pf_file] instruction-exact functions: 45/45
[libs/RVL_SDK/src/fa/pf_file] section .text size 17820 match 100.0
[libs/RVL_SDK/src/fa/pf_file] baseline: code 17820/17820 data None functions 45 fuzzy 100.0000
[libs/RVL_SDK/src/fa/pf_path] pool: IDENTICAL
[libs/RVL_SDK/src/fa/pf_path] objdiff: code 11872/11872 data 56/56 functions 27/27 fuzzy 100.0000 linked code 11872
[libs/RVL_SDK/src/fa/pf_path] instruction-exact functions: 27/27
[libs/RVL_SDK/src/fa/pf_path] section .sdata size 48 match 100.0
[libs/RVL_SDK/src/fa/pf_path] section .sdata2 size 8 match 100.0
[libs/RVL_SDK/src/fa/pf_path] section .text size 11872 match 100.0
[libs/RVL_SDK/src/fa/pf_path] baseline: code 11872/11872 data 56 functions 27 fuzzy 100.0000
[libs/RVL_SDK/src/fa/pf_sector] pool: IDENTICAL
[libs/RVL_SDK/src/fa/pf_sector] objdiff: code 1832/1832 data None/None functions 4/4 fuzzy 100.0000 linked code 1832
[libs/RVL_SDK/src/fa/pf_sector] instruction-exact functions: 4/4
[libs/RVL_SDK/src/fa/pf_sector] section .text size 1832 match 100.0
[libs/RVL_SDK/src/fa/pf_sector] baseline: code 1832/1832 data None functions 4 fuzzy 100.0000
[libs/RVL_SDK/src/fa/pf_service] pool: IDENTICAL
[libs/RVL_SDK/src/fa/pf_service] objdiff: code 312/312 data None/None functions 2/2 fuzzy 100.0000 linked code 312
[libs/RVL_SDK/src/fa/pf_service] instruction-exact functions: 2/2
[libs/RVL_SDK/src/fa/pf_service] section .text size 312 match 100.0
[libs/RVL_SDK/src/fa/pf_service] baseline: code 312/312 data None functions 2 fuzzy 100.0000
[libs/RVL_SDK/src/fa/pf_str] pool: IDENTICAL
[libs/RVL_SDK/src/fa/pf_str] objdiff: code 1380/1380 data None/None functions 11/11 fuzzy 100.0000 linked code 1380
[libs/RVL_SDK/src/fa/pf_str] instruction-exact functions: 11/11
[libs/RVL_SDK/src/fa/pf_str] section .text size 1380 match 100.0
[libs/RVL_SDK/src/fa/pf_str] baseline: code 1380/1380 data None functions 11 fuzzy 100.0000
[libs/RevoEX/src/net/aes] pool: IDENTICAL
[libs/RevoEX/src/net/aes] objdiff: code 1116/2752 data 2800/2800 functions 7/9 fuzzy 84.4709 linked code 0
[libs/RevoEX/src/net/aes] instruction-exact functions: 7/9
[libs/RevoEX/src/net/aes] section .data size 200 match 100.0
[libs/RevoEX/src/net/aes] section .rodata size 2592 match 100.0
[libs/RevoEX/src/net/aes] section .sdata2 size 8 match 100.0
[libs/RevoEX/src/net/aes] section .text size 2752 match 84.47093
[libs/RevoEX/src/net/aes] below 100: AESiEncryptBlock 65.81013
[libs/RevoEX/src/net/aes] below 100: AESiDecryptBlock 78.95618
[libs/RevoEX/src/net/aes] baseline: code 1116/2752 data 2800 functions 7 fuzzy 84.4709
[libs/RevoEX/src/nhttp/NHTTP_recvbuf] pool: IDENTICAL
[libs/RevoEX/src/nhttp/NHTTP_recvbuf] objdiff: code 1196/1692 data None/None functions 6/7 fuzzy 99.2151 linked code 0
[libs/RevoEX/src/nhttp/NHTTP_recvbuf] instruction-exact functions: 6/7
[libs/RevoEX/src/nhttp/NHTTP_recvbuf] section .text size 1692 match 99.21513
[libs/RevoEX/src/nhttp/NHTTP_recvbuf] below 100: NHTTPi_compareTokenN_HdrRecvBuf 97.32258
[libs/RevoEX/src/nhttp/NHTTP_recvbuf] baseline: code 1196/1692 data None functions 6 fuzzy 99.2151
[src/BS2/BS2Update] pool: IDENTICAL
[src/BS2/BS2Update] objdiff: code 400/4052 data 10488/10488 functions 9/10 fuzzy 95.7088 linked code 0
[src/BS2/BS2Update] instruction-exact functions: 9/10
[src/BS2/BS2Update] section .bss size 9056 match 100.0
[src/BS2/BS2Update] section .data size 1328 match 100.0
[src/BS2/BS2Update] section .sbss size 80 match 100.0
[src/BS2/BS2Update] section .sdata size 24 match 100.0
[src/BS2/BS2Update] section .text size 4052 match 95.708786
[src/BS2/BS2Update] below 100: UpdateThread 95.23877
[src/BS2/BS2Update] baseline: code 400/4052 data 10488 functions 9 fuzzy 95.7088
[src/iplwww/www_wiisetting] pool: IDENTICAL
[src/iplwww/www_wiisetting] objdiff: code 3740/6176 data 3856/3856 functions 20/21 fuzzy 99.9450 linked code 0
[src/iplwww/www_wiisetting] instruction-exact functions: 20/21
[src/iplwww/www_wiisetting] section .bss size 104 match 100.0
[src/iplwww/www_wiisetting] section .data size 2576 match 100.0
[src/iplwww/www_wiisetting] section .rodata size 792 match 100.0
[src/iplwww/www_wiisetting] section .sbss size 32 match 100.0
[src/iplwww/www_wiisetting] section .sdata size 320 match 100.0
[src/iplwww/www_wiisetting] section .sdata2 size 32 match 100.0
[src/iplwww/www_wiisetting] section .text size 6176 match 99.94495
[src/iplwww/www_wiisetting] below 100: Getter___Q23www10wiisettingFP14WWWJSPluginObjPCcP16WWWJSPluginValue 99.86043
[src/iplwww/www_wiisetting] baseline: code 3740/6176 data 3856 functions 20 fuzzy 99.9450
[src/keyboard/tiPredictLang] pool: IDENTICAL
[src/keyboard/tiPredictLang] objdiff: code 5536/5536 data 2300/2300 functions 36/36 fuzzy 100.0000 linked code 5536
[src/keyboard/tiPredictLang] instruction-exact functions: 36/36
[src/keyboard/tiPredictLang] section .ctors size 4 match 100.0
[src/keyboard/tiPredictLang] section .data size 1672 match 100.0
[src/keyboard/tiPredictLang] section .rodata size 616 match 100.0
[src/keyboard/tiPredictLang] section .sdata size 8 match 100.0
[src/keyboard/tiPredictLang] section .text size 5536 match 100.0
[src/keyboard/tiPredictLang] baseline: code 5536/5536 data 2300 functions 36 fuzzy 100.0000
[src/keyboard/tiString] pool: IDENTICAL
[src/keyboard/tiString] objdiff: code 4632/5176 data 288/288 functions 41/42 fuzzy 99.0286 linked code 0
[src/keyboard/tiString] instruction-exact functions: 41/42
[src/keyboard/tiString] section .data size 288 match 100.0
[src/keyboard/tiString] section .text size 5176 match 99.028595
[src/keyboard/tiString] below 100: inputChar__Q39textinput8tistring9DecolatedFw 90.757355
[src/keyboard/tiString] baseline: code 4632/5176 data 288 functions 41 fuzzy 99.0286
[src/keyboard/tiToolBar] pool: IDENTICAL
[src/keyboard/tiToolBar] objdiff: code 5464/5464 data 1452/1452 functions 37/37 fuzzy 100.0000 linked code 5464
[src/keyboard/tiToolBar] instruction-exact functions: 37/37
[src/keyboard/tiToolBar] section .ctors size 4 match 100.0
[src/keyboard/tiToolBar] section .data size 944 match 100.0
[src/keyboard/tiToolBar] section .rodata size 480 match 100.0
[src/keyboard/tiToolBar] section .sdata size 24 match 100.0
[src/keyboard/tiToolBar] section .text size 5464 match 100.0
[src/keyboard/tiToolBar] baseline: code 5464/5464 data 1452 functions 37 fuzzy 100.0000
[src/keyboard/tiZiString] pool: IDENTICAL
[src/keyboard/tiZiString] objdiff: code 3720/5504 data 7680/7680 functions 28/29 fuzzy 99.4717 linked code 0
[src/keyboard/tiZiString] instruction-exact functions: 28/29
[src/keyboard/tiZiString] section .bss size 7296 match 100.0
[src/keyboard/tiZiString] section .data size 328 match 100.0
[src/keyboard/tiZiString] section .rodata size 56 match 100.0
[src/keyboard/tiZiString] section .text size 5504 match 99.47166
[src/keyboard/tiZiString] below 100: update__Q39textinput8tistring6WithZiFv 98.36996
[src/keyboard/tiZiString] baseline: code 3720/5504 data 7680 functions 28 fuzzy 99.4717
[src/scene/address/iplAddress] pool: IDENTICAL
[src/scene/address/iplAddress] objdiff: code 23988/23988 data 1964/1964 functions 101/101 fuzzy 100.0000 linked code 23988
[src/scene/address/iplAddress] instruction-exact functions: 101/101
[src/scene/address/iplAddress] section .ctors size 4 match 100.0
[src/scene/address/iplAddress] section .data size 1880 match 100.0
[src/scene/address/iplAddress] section .rodata size 24 match 100.0
[src/scene/address/iplAddress] section .sbss size 8 match 100.0
[src/scene/address/iplAddress] section .sdata size 16 match 100.0
[src/scene/address/iplAddress] section .sdata2 size 32 match 100.0
[src/scene/address/iplAddress] section .text size 23988 match 100.0
[src/scene/address/iplAddress] baseline: code 23988/23988 data 1964 functions 101 fuzzy 100.0000
[src/scene/address/iplAddressEdit] pool: IDENTICAL
[src/scene/address/iplAddressEdit] objdiff: code 23344/27112 data 2560/2560 functions 91/94 fuzzy 99.5528 linked code 0
[src/scene/address/iplAddressEdit] instruction-exact functions: 91/94
[src/scene/address/iplAddressEdit] section .bss size 320 match 100.0
[src/scene/address/iplAddressEdit] section .data size 2152 match 100.0
[src/scene/address/iplAddressEdit] section .rodata size 40 match 100.0
[src/scene/address/iplAddressEdit] section .sdata size 24 match 100.0
[src/scene/address/iplAddressEdit] section .sdata2 size 24 match 100.0
[src/scene/address/iplAddressEdit] section .text size 27112 match 99.55282
[src/scene/address/iplAddressEdit] below 100: create__Q33ipl5scene11AddressEditFv 97.5561
[src/scene/address/iplAddressEdit] below 100: get_friendinfo__Q33ipl5scene11AddressEditFv 88.03571
[src/scene/address/iplAddressEdit] below 100: update_friendinfo__Q33ipl5scene11AddressEditFv 99.42105
[src/scene/address/iplAddressEdit] baseline: code 23344/27112 data 2560 functions 91 fuzzy 99.5528
[src/utility/iplESMisc] pool: IDENTICAL
[src/utility/iplESMisc] objdiff: code 9404/11200 data 4416/4416 functions 30/31 fuzzy 99.8625 linked code 0
[src/utility/iplESMisc] instruction-exact functions: 30/31
[src/utility/iplESMisc] section .data size 4384 match 100.0
[src/utility/iplESMisc] section .sdata size 32 match 100.0
[src/utility/iplESMisc] section .text size 11200 match 99.8625
[src/utility/iplESMisc] below 100: DeleteUnauthorizedData__Q33ipl7utility6ESMiscFPQ23EGG4Heap 99.14254
[src/utility/iplESMisc] baseline: code 9404/11200 data 4416 functions 30 fuzzy 99.8625
regressions vs baseline: 0
global matched_code_percent: 93.99622 -> 93.99622
global fuzzy_match_percent: 99.81744 -> 99.81744
global complete_code_percent: 80.08451 -> 80.08451
global matched_data_percent: 99.99410 -> 99.99410
forbidden patterns added (net, per file): 0
readability warnings (net, per file; must be 0 in the final result): 0
GATE PASS
```
## Pool checks
```text
[libs/NW4R/src/lyt/lyt_window] POOL IDENTICAL up to 1 (mine=1 base=1)
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/api/FAAttach] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/api/FADetach] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/api/FAErrnum] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/api/FAInit] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/api/FARegistCB] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/driver/nand_drv] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/driver/sd_drv] POOL IDENTICAL up to 46 (mine=46 base=46)
[libs/RVL_SDK/src/fa/pdm_disk] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/pdm_partition] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/pf_clib] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/pf_cp932] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/pf_entry] POOL IDENTICAL up to 1 (mine=1 base=1)
[libs/RVL_SDK/src/fa/pf_entry_iterator] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/pf_fat12] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/pf_file] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/pf_path] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/pf_sector] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/pf_service] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RVL_SDK/src/fa/pf_str] POOL IDENTICAL up to 0 (mine=0 base=0)
[libs/RevoEX/src/net/aes] POOL IDENTICAL up to 4 (mine=4 base=4)
[libs/RevoEX/src/nhttp/NHTTP_recvbuf] POOL IDENTICAL up to 0 (mine=0 base=0)
[src/BS2/BS2Update] POOL IDENTICAL up to 55 (mine=55 base=55)
[src/iplwww/www_wiisetting] POOL IDENTICAL up to 72 (mine=72 base=72)
[src/keyboard/tiPredictLang] POOL IDENTICAL up to 14 (mine=14 base=14)
[src/keyboard/tiString] POOL IDENTICAL up to 0 (mine=0 base=0)
[src/keyboard/tiToolBar] POOL IDENTICAL up to 12 (mine=12 base=12)
[src/keyboard/tiZiString] POOL IDENTICAL up to 0 (mine=0 base=0)
[src/scene/address/iplAddress] POOL IDENTICAL up to 81 (mine=81 base=81)
[src/scene/address/iplAddressEdit] POOL IDENTICAL up to 57 (mine=57 base=57)
[src/utility/iplESMisc] POOL IDENTICAL up to 114 (mine=114 base=114)
```
## Representative ctxdiff checks
```text
[libs/NW4R/src/lyt/lyt_window] __ct__Q34nw4r3lyt6WindowFPCQ44nw4r3lyt3res6WindowRCQ34nw4r3lyt11ResBlockSet
src 0x208 base 0x208 insns 130/130
diffs 0: []
[libs/RVL_SDK/src/fa/api/FAAttach] FAAttach
src 0x1f4 base 0x1f4 insns 125/125
diffs 0: []
[libs/RVL_SDK/src/fa/api/FADetach] FADetach
src 0xa8 base 0xa8 insns 42/42
diffs 0: []
[libs/RVL_SDK/src/fa/api/FAErrnum] FAErrnum
src 0x40 base 0x40 insns 16/16
diffs 0: []
[libs/RVL_SDK/src/fa/api/FAInit] FAInit
src 0xd0 base 0xd0 insns 52/52
diffs 0: []
[libs/RVL_SDK/src/fa/api/FARegistCB] FARegistCB
src 0xa0 base 0xa0 insns 40/40
diffs 0: []
[libs/RVL_SDK/src/fa/driver/nand_drv] fa_nanddrv_physical_read
src 0x2ec base 0x2ec insns 187/187
diffs 0: []
[libs/RVL_SDK/src/fa/driver/sd_drv] pfd_sddrv_store_bpb_buf
src 0x51c base 0x51c insns 327/327
diffs 0: []
[libs/RVL_SDK/src/fa/pdm_disk] pdm_disk_convert_sector_into_block
src 0xb0 base 0xb0 insns 44/44
diffs 0: []
[libs/RVL_SDK/src/fa/pdm_partition] pdm_part_unregister_callback
src 0x14 base 0x14 insns 5/5
diffs 0: []
[libs/RVL_SDK/src/fa/pf_clib] pf_w_strcmp
src 0x38 base 0x38 insns 14/14
diffs 0: []
[libs/RVL_SDK/src/fa/pf_cp932] PFCODE_CP932_OEM2Unicode
src 0x1bc base 0x1bc insns 111/111
diffs 0: []
[libs/RVL_SDK/src/fa/pf_entry] PFENT_searchEmptyTailSFN
src 0x370 base 0x370 insns 220/220
diffs 0: []
[libs/RVL_SDK/src/fa/pf_entry_iterator] PFENT_ITER_IsAtLogicalEnd
src 0x10c base 0x10c insns 67/67
diffs 0: []
[libs/RVL_SDK/src/fa/pf_fat12] PFFAT12_WriteFATEntryWithBuf
src 0x2bc base 0x2bc insns 175/175
diffs 0: []
[libs/RVL_SDK/src/fa/pf_file] PFFILE_fseek
src 0x224 base 0x224 insns 137/137
diffs 0: []
[libs/RVL_SDK/src/fa/pf_path] PFPATH_GetNextCharOfPattern
src 0x37c base 0x37c insns 223/223
diffs 0: []
[libs/RVL_SDK/src/fa/pf_sector] PFSEC_ReadFAT
src 0xc4 base 0xc4 insns 49/49
diffs 0: []
[libs/RVL_SDK/src/fa/pf_service] PF_GET_LE_U16
src 0x10 base 0x10 insns 4/4
diffs 0: []
[libs/RVL_SDK/src/fa/pf_str] PFSTR_StrCmp
src 0xa4 base 0xa4 insns 41/41
diffs 0: []
[libs/RevoEX/src/net/aes] NETAESCreateEx
src 0x1b0 base 0x1b0 insns 108/108
diffs 0: []
[libs/RevoEX/src/nhttp/NHTTP_recvbuf] NHTTPi_RecvBufN
src 0x3c base 0x3c insns 15/15
diffs 0: []
[src/BS2/BS2Update] BS2UpdateInit
src 0x120 base 0x120 insns 72/72
diffs 0: []
[src/iplwww/www_wiisetting] DPDCallback2__Q23www10wiisettingFll
src 0x24 base 0x24 insns 9/9
diffs 0: []
[src/keyboard/tiPredictLang] __dt__Q39textinput11predictlang12LayoutByNW4RFv
src 0xe8 base 0xe8 insns 58/58
diffs 0: []
[src/keyboard/tiString] inputString__Q39textinput8tistring9DecolatedFPCw
src 0x64 base 0x64 insns 25/25
diffs 0: []
[src/keyboard/tiToolBar] setQwerty__Q39textinput7toolbar4BaseFb
src 0xd0 base 0xd0 insns 52/52
diffs 0: []
[src/keyboard/tiZiString] init__Q39textinput8tistring6WithZiFv
src 0x8c base 0x8c insns 35/35
diffs 0: []
[src/scene/address/iplAddress] swap__Q33ipl5scene15FriendListCacheFUlUl
src 0xcc base 0xcc insns 51/51
diffs 0: []
[src/scene/address/iplAddressEdit] stt_msg_add_rlt__Q33ipl5scene11AddressEditFv
src 0x68 base 0x68 insns 26/26
diffs 0: []
[src/utility/iplESMisc] GetValidTicketIndex__Q33ipl7utility6ESMiscFPQ23EGG4HeapUxP12ESTicketViewUl
src 0x2dc base 0x2dc insns 183/183
diffs 0: []
```
## Local source commits
- `936619dd441ec7e5eccaddb9c5ec021a1ce87235` clean up address scene expressions
- `6231525de4d35138d4282eb5745b0286b775f2ca` clean up keyboard expressions
- `276caecf786de24c810ec8ae9400c77c399100c6` clarify aes and http buffer expressions
- `7ed84e64f6e57501f09a5b2e54c0e7ec4f9430d1` clarify jpeg transform expressions
- `23e91b1ef26e2dbffa04256d01c9913aac3747e3` remove redundant layout color casts
- `7637bba3716bd5c0c70b71f8869d93e08d345d5e` clean up filesystem expressions
- `b5c7caf7f04205266fb05903b02745fbac01997a` clean up system utility expressions
Each commit contains one source group from the final gate-passing diff. Only the report was added after source validation. No remote operation was performed.

View File

@@ -0,0 +1,291 @@
# rx48 expression cleanup
Base: `7c64b0a1f94be5770d04288c93d0c668f43d4250`, branch `agent/w1005/rx48`.
Scope: TMC_JPEG except texturecvtr and buffer/idct_block_var.c. Excluded files may receive identifier renames only.
Acceptance: preserve complete source object bytes, every objdiff measure and per-function score, identical pools, and the full 43U DOL SHA1 `26116613f624061ba99c8d1a299aaa6efa85670d`. This expression-cleanup assignment supersedes the generic requirement to gain exact matches.
Fresh baseline: 1027 source objects saved under `/tmp/rx48-cleanup`; all 11 owned pools identical. Owned totals are 47/49 exact functions, 17724/20616 matched code bytes, and 632/632 matched data bytes. The two pre-existing EXIF mismatches must stay unchanged. Pre-existing untracked g2 logs are outside this change.
Prior evidence: `rx38.cleanup.md` records rejected direct-work member substitutions, public state field renaming, and control-flow/cast changes. This round tests typed component/table views and remaining independent expressions. Public init fields `unk_0x24` and `unk_0x2C` have out-of-scope users in `src/utility/iplJpegDecoder.cpp`; retain them. Unknown storage gets a semantic name only when uses prove its role.
## Trials
- KEEP component view: move existing TMCFrameComponents definition into internal header: all checked object bytes identical. Trial 001.
- KEEP decompmcu: address DC predictors through existing component view: all checked object bytes identical. Trial 002.
- KEEP decompmcu: quantization selector through component view: all checked object bytes identical. Trial 003.
- KEEP decompmcu: entropy selectors through component view: all checked object bytes identical. Trial 004.
- KEEP decompmcu: component base is a typed pointer throughout: all checked object bytes identical. Trial 005.
- REVERT decompmcu: block-count cursor starts at the frame member: jdec_main: TMCJPEGDEC_decompmcu. Trial 006.
- REVERT typed table layout: replace shifted work casts and overlapping placeholders with quantization and Huffman members: compile failure. Trial 007.
- KEEP typed table layout: replace shifted work casts and overlapping placeholders with quantization and Huffman members: all checked object bytes identical. Trial 008.
- KEEP internal header: name four existing alignment gaps: all checked object bytes identical. Trial 009.
- REVERT decompmcu: preserve typed frame base and use its block-count array: jdec_main: TMCJPEGDEC_decompmcu. Trial 010.
- REVERT decompmcu: direct block-count array instead of byte cursor: jdec_main: TMCJPEGDEC_decompmcu. Trial 011.
- REVERT decompmcu: cursor based on existing work block-count field: jdec_main: TMCJPEGDEC_decompmcu. Trial 012.
- KEEP work components: use a real nested member for all component metadata: all checked object bytes identical. Trial 013.
- KEEP scan parser: share the component type instead of a local duplicate: all checked object bytes identical. Trial 014.
- KEEP public EXIF header: name three proven alignment gaps: all checked object bytes identical. Trial 015.
- KEEP public EXIF info: name alignment after converterType: all checked object bytes identical. Trial 016.
- REVERT decompmcu: const typed frame while preserving byte cursor: jdec_main: TMCJPEGDEC_decompmcu. Trial 017.
- KEEP EXIF decoder state: type fields actually accessed by Setsize, converters and restart handling: all checked object bytes identical. Trial 018.
- REVERT public decoder state: name trailing alignment gap: iplNandSDWorker; iplNandSDCardManager. Trial 019.
## Layout evidence
The old table declaration contained shifted aliases. The table helpers received `work + 0x58` cast as a complete work object. Their apparent `zigzagData + 8`, `huffDecTblDC1`, and `valPtrDC0` accesses therefore addressed table-relative offsets `0x460`, `0x860`, and `0x1460`. The replacement defines those arrays at the actual helper addresses and passes `TMCJpegTableInfo*` throughout. Quantization coefficients occupy four 256-byte tables. Two untouched words retain reserved names because this source never accesses them.
EXIF state fields are proven by the existing `work->pState = (TMCCJPEGDecState*)pInfo` assignment and calls into Setsize, converters, and restart handling. Their offsets equal the public decoder-state members. Four opaque public ranges and the public decoder-state debug layout remain constrained.
Target MWCC compile-time assertions pass:
```text
MWCC layout PASS: 70 sizeof/offsetof assertions
sizeof(TMCCJPEGDecWork) = 0x19e8
sizeof(TMCFrameComponents) = 0x24
sizeof(TMCJpegTableInfo) = 0x1798
sizeof(TMCJpegFrameInfo) = 0x30
sizeof(TMCCJPEGDecInitParam) = 0x30
sizeof(TMCCJPEGDecState) = 0x6d4
sizeof(TMCCJPEGDecExifInfo) = 0x6d4
sizeof(TMCCJPEGDecExifData) = 0x67c
offsetof(TMCCJPEGDecWork, components) = 0x2c
offsetof(TMCCJPEGDecWork, components.dcPredict) = 0x30
offsetof(TMCCJPEGDecWork, components.id) = 0x40
offsetof(TMCCJPEGDecWork, components.quantTable) = 0x44
offsetof(TMCCJPEGDecWork, components.dcTable) = 0x48
offsetof(TMCCJPEGDecWork, components.acTable) = 0x4c
offsetof(TMCCJPEGDecWork, tables) = 0x58
offsetof(TMCCJPEGDecWork, tables.zigzagData) = 0x458
offsetof(TMCCJPEGDecWork, tables.pDCFast) = 0x498
offsetof(TMCCJPEGDecWork, tables.pDCHuffTbl) = 0x49c
offsetof(TMCCJPEGDecWork, tables.pDCHuffSym) = 0x4a0
offsetof(TMCCJPEGDecWork, tables.reservedDC) = 0x4a4
offsetof(TMCCJPEGDecWork, tables.pACFast) = 0x4a8
offsetof(TMCCJPEGDecWork, tables.pACHuffTbl) = 0x4ac
offsetof(TMCCJPEGDecWork, tables.pACHuffSym) = 0x4b0
offsetof(TMCCJPEGDecWork, tables.reservedAC) = 0x4b4
offsetof(TMCCJPEGDecWork, tables.quantTblFlag) = 0x17e8
offsetof(TMCCJPEGDecWork, tables.dcTblFlag) = 0x17ec
offsetof(TMCCJPEGDecWork, tables.acTblFlag) = 0x17ee
offsetof(TMCCJPEGDecWork, frameWidth) = 0x17f0
offsetof(TMCCJPEGDecWork, scanCompCount) = 0x180b
offsetof(TMCCJPEGDecWork, blockCount) = 0x180c
offsetof(TMCCJPEGDecWork, restartInterval) = 0x181a
offsetof(TMCCJPEGDecWork, idctPtr) = 0x1820
offsetof(TMCCJPEGDecWork, pConvRowPtrs) = 0x183c
offsetof(TMCCJPEGDecWork, convBuf) = 0x1858
offsetof(TMCCJPEGDecWork, pitch) = 0x19de
offsetof(TMCCJPEGDecWork, pState) = 0x19e4
offsetof(TMCJpegTableInfo, huffDecTblDC0) = 0x460
offsetof(TMCJpegTableInfo, huffDecTblDC1) = 0x860
offsetof(TMCJpegTableInfo, huffDecTblAC0) = 0xc60
offsetof(TMCJpegTableInfo, huffDecTblAC1) = 0x1060
offsetof(TMCJpegTableInfo, valPtrDC0) = 0x1460
offsetof(TMCJpegTableInfo, valPtrDC1) = 0x14a4
offsetof(TMCJpegTableInfo, valPtrAC0) = 0x14e8
offsetof(TMCJpegTableInfo, valPtrAC1) = 0x152c
offsetof(TMCJpegTableInfo, maxCodeDC0) = 0x1570
offsetof(TMCJpegTableInfo, maxCodeDC1) = 0x1580
offsetof(TMCJpegTableInfo, maxCodeAC0) = 0x1590
offsetof(TMCJpegTableInfo, maxCodeAC1) = 0x1690
offsetof(TMCCJPEGDecExifInfo, posX) - offsetof(TMCCJPEGDecState, posX) = 0x0
offsetof(TMCCJPEGDecExifInfo, posY) - offsetof(TMCCJPEGDecState, posY) = 0x0
offsetof(TMCCJPEGDecExifInfo, position) - offsetof(TMCCJPEGDecState, position) = 0x0
offsetof(TMCCJPEGDecExifInfo, maxX) - offsetof(TMCCJPEGDecState, maxX) = 0x0
offsetof(TMCCJPEGDecExifInfo, maxY) - offsetof(TMCCJPEGDecState, maxY) = 0x0
offsetof(TMCCJPEGDecExifInfo, stepX) - offsetof(TMCCJPEGDecState, stepX) = 0x0
offsetof(TMCCJPEGDecExifInfo, stepY) - offsetof(TMCCJPEGDecState, stepY) = 0x0
offsetof(TMCCJPEGDecExifInfo, stepXExt) - offsetof(TMCCJPEGDecState, stepXExt) = 0x0
offsetof(TMCCJPEGDecExifInfo, stepYExt) - offsetof(TMCCJPEGDecState, stepYExt) = 0x0
offsetof(TMCCJPEGDecExifInfo, dataSizeX) - offsetof(TMCCJPEGDecState, dataSizeX) = 0x0
offsetof(TMCCJPEGDecExifInfo, dataSizeY) - offsetof(TMCCJPEGDecState, dataSizeY) = 0x0
offsetof(TMCCJPEGDecExifInfo, componentCount) - offsetof(TMCCJPEGDecState, componentCount) = 0x0
offsetof(TMCCJPEGDecExifInfo, jpegWidth) - offsetof(TMCCJPEGDecState, jpegWidth) = 0x0
offsetof(TMCCJPEGDecExifInfo, jpegHeight) - offsetof(TMCCJPEGDecState, jpegHeight) = 0x0
offsetof(TMCCJPEGDecExifInfo, outputWidth) - offsetof(TMCCJPEGDecState, outputWidth) = 0x0
offsetof(TMCCJPEGDecExifInfo, outputHeight) - offsetof(TMCCJPEGDecState, outputHeight) = 0x0
offsetof(TMCCJPEGDecExifInfo, convWidth) - offsetof(TMCCJPEGDecState, convWidth) = 0x0
offsetof(TMCCJPEGDecExifInfo, convHeight) - offsetof(TMCCJPEGDecState, convHeight) = 0x0
offsetof(TMCCJPEGDecExifInfo, pTexBuffer) - offsetof(TMCCJPEGDecState, pTexBuffer) = 0x0
offsetof(TMCCJPEGDecExifInfo, pWorkBuf) - offsetof(TMCCJPEGDecState, pWorkBuf) = 0x0
offsetof(TMCCJPEGDecExifInfo, decodeResult) - offsetof(TMCCJPEGDecState, decodeResult) = 0x0
offsetof(TMCCJPEGDecExifInfo, converterType) - offsetof(TMCCJPEGDecState, converterType) = 0x0
```
First group quick gate: GATE PASS; 0 regressions, forbidden patterns, or readability warnings. All 1027 complete source objects still match the fresh baseline.
## Further expression trials
- KEEP IFD0/IFD1 rational values: derive denominator offset from scalar size: all checked object bytes identical. Trial 020.
- KEEP IFD0 transfer/date values: derive read bounds and copy length from field types: all checked object bytes identical. Trial 021.
- REVERT IFD0/IFD1 entries: use typed tag, type and value byte fields: exif_parse: TMCJPEGDEC_IFD0_tag_parse. Trial 022.
- REVERT IFD0/IFD1 ignored tags: return directly from the no-op cases: exif_parse: TMCJPEGDEC_IFD0_tag_parse, TMCJPEGDEC_IFD1_tag_parse. Trial 023.
- KEEP Huffman initialization: size all twelve table clears from typed arrays: all checked object bytes identical. Trial 024.
- KEEP buffer initialization: use SDK DEFAULT_ALIGN for both alignment checks: all checked object bytes identical. Trial 025.
- KEEP thumbnail buffer: do lookbehind arithmetic on the byte pointer: all checked object bytes identical. Trial 026.
- KEEP IFD0/IFD1 entries without changing IFD0 constness: use typed tag, type and value byte fields: all checked object bytes identical. Trial 027.
- KEEP EXIF traversal: derive directory-entry strides from the entry type: all checked object bytes identical. Trial 028.
- KEEP AC lookup: keep the table index without cancelling shifts: all checked object bytes identical. Trial 029.
- KEEP signed IDCT clamp: rely on the declared return type for narrowing: all checked object bytes identical. Trial 030.
- KEEP scan geometry: replace boolean-to-one ternaries with their comparisons: all checked object bytes identical. Trial 031.
- REVERT frame parser: compare component count without redundant signed promotions: jdec_main: TMCJPEGDEC_parse_sof. Trial 032.
- KEEP scan geometry: let byte fields perform assignment narrowing: all checked object bytes identical. Trial 033.
- KEEP scan geometry: remove duplicate unsigned product conversion: all checked object bytes identical. Trial 034.
- KEEP decompmcu: compare byte block count without explicit signed promotion: all checked object bytes identical. Trial 035.
- REVERT decompmcu: typed frame and block cursor after removing count promotion: jdec_main: TMCJPEGDEC_decompmcu. Trial 036.
- KEEP quantization parser: rely on unsigned table entry to promote byte product: all checked object bytes identical. Trial 037.
## Scope audit and remaining expressions
Reviewed all 11 owned units. `jpformat.c` contains fixed sampling and zigzag tables. `decapi.c` and `jdec.c` retain the already-tested rx38 expressions that change bytes. No owned source uses GX, NAND, ES, CARD, button-mask, or scene constants. The two buffer alignment checks now use the SDK's existing `DEFAULT_ALIGN`.
All 17 internal `unk_` declarations are gone. Eight public placeholder declarations became typed EXIF state members or named alignment gaps. Eleven public placeholders remain: two init fields have out-of-scope users, four opaque ranges have no proven role, and five decoder-state fields are constrained by the observed changes to unrelated debug objects. No excluded source file changed.
The table and component members replaced shifted work-pointer casts, quantization offsets, selector offsets, and pointer-slot indexing. The EXIF directory entry uses byte arrays because its values have file-selected endianness and may be unaligned. The IFD0 pointer retains its original mutability; adding const changed instructions.
The remaining `decompmcu` frame byte cursor is load-bearing. Trials 006, 010, 011, 012, 017, and 036 tested different member/cursor forms. Trial 036 has 113/113 instructions but 13 differences, all register allocation. It was reverted. The focused diff is saved in `/tmp/rx48-cleanup/trial-036.txt`.
Both existing nonmatching functions have at least three distinct compiled cleanup trials. IFD0: denominator size 020, transfer/date bounds 021, typed entries 022/027, direct returns 023. IFD1: denominator size 020, typed entries 022/027, direct returns 023. Their original mismatches remain unchanged; this task requires preservation, not new matches.
Accepted counts describe expression sites except layouts and placeholder declarations: four typed layouts, 25 placeholder declarations removed, 25 constant/size substitutions, seven independent cast simplifications, two boolean-ternary simplifications, and one cancelling-shift simplification. Casts and offsets eliminated as part of the typed layouts are counted with those layouts, not again. The 25 size substitutions comprise 12 table clears, two alignment checks, four rational offsets, four transfer/date bounds or increments, and three directory-entry strides.
## Final verification
Full clean gate, without `--quick`, passed for all 11 owned units. No source edits followed it. The fresh report and complete ELF hashes match the starting snapshot across all 1027 source units.
```text
Whole-object SHA256: 1027/1027 unchanged
Objdiff measures/sections/functions: 1027 units unchanged
Pools: 15/15 identical
Ctxdiff: 47/49 exact functions, two original EXIF mismatches unchanged
Owned matched code/data: 17724/632 bytes unchanged
main.dol SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d
BYTE PRESERVATION PASS
MWCC layout PASS: 75 sizeof/offsetof assertions
```
The final layout pass adds EXIF entry checks: size 12, tag offset 0, type offset 2, count offset 4, value offset 8. The public-state overlay checks and internal work offsets above pass unchanged.
Before -> after: instruction-exact functions 47/49 -> 47/49; objdiff code 17724/20616 -> 17724/20616 bytes; data 632/632 -> 632/632 bytes.
Open matching work, unchanged:
- `TMCJPEGDEC_IFD0_tag_parse`: 99.49065%, 480/481 instructions, dispatch and register differences.
- `TMCJPEGDEC_IFD1_tag_parse`: 96.14876%, 239/242 instructions, dispatch and register differences.
Final gate command:
```sh
python3 /mnt/drive2/projects/wii-ipl-workers/_restore0928-tools/gate.py \
libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3 \
libs/RVLMiddleware/TMC_JPEG/src/buffer/buffer_system \
libs/RVLMiddleware/TMC_JPEG/src/buffer/getcode \
libs/RVLMiddleware/TMC_JPEG/src/api/decapi \
libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec \
libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main \
libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jpformat \
libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse \
libs/RVLMiddleware/TMC_JPEG/src/reschange/iqdec_resolution_change_a3 \
libs/RVLMiddleware/TMC_JPEG/src/reschange/idct_resolution_change_var \
libs/RVLMiddleware/TMC_JPEG/src/b65/iqdec_b65_frv32 \
--base 7c64b0a1f94be5770d04288c93d0c668f43d4250
```
```text
full build: ok
main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] objdiff: code 1228/1228 data None/None functions 2/2 fuzzy 100.0000 linked code 1228
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] instruction-exact functions: 2/2
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] section .text size 1228 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] baseline: code 1228/1228 data None functions 2 fuzzy 100.0000
[libs/RVLMiddleware/TMC_JPEG/src/buffer/buffer_system] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/buffer/buffer_system] objdiff: code 2444/2444 data None/None functions 10/10 fuzzy 100.0000 linked code 2444
[libs/RVLMiddleware/TMC_JPEG/src/buffer/buffer_system] instruction-exact functions: 10/10
[libs/RVLMiddleware/TMC_JPEG/src/buffer/buffer_system] section .text size 2444 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/buffer/buffer_system] baseline: code 2444/2444 data None functions 10 fuzzy 100.0000
[libs/RVLMiddleware/TMC_JPEG/src/buffer/getcode] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/buffer/getcode] objdiff: code 316/316 data None/None functions 3/3 fuzzy 100.0000 linked code 316
[libs/RVLMiddleware/TMC_JPEG/src/buffer/getcode] instruction-exact functions: 3/3
[libs/RVLMiddleware/TMC_JPEG/src/buffer/getcode] section .text size 316 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/buffer/getcode] baseline: code 316/316 data None functions 3 fuzzy 100.0000
[libs/RVLMiddleware/TMC_JPEG/src/api/decapi] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/api/decapi] objdiff: code 1100/1100 data None/None functions 3/3 fuzzy 100.0000 linked code 1100
[libs/RVLMiddleware/TMC_JPEG/src/api/decapi] instruction-exact functions: 3/3
[libs/RVLMiddleware/TMC_JPEG/src/api/decapi] section .text size 1100 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/api/decapi] baseline: code 1100/1100 data None functions 3 fuzzy 100.0000
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec] objdiff: code 1020/1020 data None/None functions 3/3 fuzzy 100.0000 linked code 1020
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec] instruction-exact functions: 3/3
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec] section .text size 1020 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec] baseline: code 1020/1020 data None functions 3 fuzzy 100.0000
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] objdiff: code 5604/5604 data 256/256 functions 13/13 fuzzy 100.0000 linked code 5604
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] instruction-exact functions: 13/13
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] section .rodata size 256 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] section .text size 5604 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] baseline: code 5604/5604 data 256 functions 13 fuzzy 100.0000
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jpformat] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jpformat] objdiff: code None/None data 376/376 functions 0/None fuzzy 100.0000 linked code 0
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jpformat] instruction-exact functions: 0/0
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jpformat] section .rodata size 368 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jpformat] section .sdata2 size 8 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jpformat] baseline: code None/None data 376 functions 0 fuzzy 100.0000
[libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse] objdiff: code 2196/5088 data None/None functions 4/6 fuzzy 99.0747 linked code 0
[libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse] instruction-exact functions: 4/6
[libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse] section .text size 5088 match 99.074684
[libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse] below 100: TMCJPEGDEC_IFD0_tag_parse 99.49065
[libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse] below 100: TMCJPEGDEC_IFD1_tag_parse 96.14876
[libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse] baseline: code 2196/5088 data None functions 4 fuzzy 99.0747
[libs/RVLMiddleware/TMC_JPEG/src/reschange/iqdec_resolution_change_a3] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/reschange/iqdec_resolution_change_a3] objdiff: code 908/908 data None/None functions 2/2 fuzzy 100.0000 linked code 908
[libs/RVLMiddleware/TMC_JPEG/src/reschange/iqdec_resolution_change_a3] instruction-exact functions: 2/2
[libs/RVLMiddleware/TMC_JPEG/src/reschange/iqdec_resolution_change_a3] section .text size 908 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/reschange/iqdec_resolution_change_a3] baseline: code 908/908 data None functions 2 fuzzy 100.0000
[libs/RVLMiddleware/TMC_JPEG/src/reschange/idct_resolution_change_var] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/reschange/idct_resolution_change_var] objdiff: code 1804/1804 data None/None functions 6/6 fuzzy 100.0000 linked code 1804
[libs/RVLMiddleware/TMC_JPEG/src/reschange/idct_resolution_change_var] instruction-exact functions: 6/6
[libs/RVLMiddleware/TMC_JPEG/src/reschange/idct_resolution_change_var] section .text size 1804 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/reschange/idct_resolution_change_var] baseline: code 1804/1804 data None functions 6 fuzzy 100.0000
[libs/RVLMiddleware/TMC_JPEG/src/b65/iqdec_b65_frv32] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/b65/iqdec_b65_frv32] objdiff: code 1104/1104 data None/None functions 1/1 fuzzy 100.0000 linked code 1104
[libs/RVLMiddleware/TMC_JPEG/src/b65/iqdec_b65_frv32] instruction-exact functions: 1/1
[libs/RVLMiddleware/TMC_JPEG/src/b65/iqdec_b65_frv32] section .text size 1104 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/b65/iqdec_b65_frv32] baseline: code 1104/1104 data None functions 1 fuzzy 100.0000
regressions vs baseline: 0
global matched_code_percent: 93.99622 -> 93.99622
global fuzzy_match_percent: 99.81744 -> 99.81744
global complete_code_percent: 80.08451 -> 80.08451
global matched_data_percent: 99.99410 -> 99.99410
forbidden patterns added (net, per file): 0
readability warnings (net, per file; must be 0 in the final result): 0
GATE PASS
```
## Files and commits
```text
libs/RVLMiddleware/TMC_JPEG/include/tmc_jpeg.h
libs/RVLMiddleware/TMC_JPEG/include/tmc_jpeg_internal.h
libs/RVLMiddleware/TMC_JPEG/src/b65/iqdec_b65_frv32.c
libs/RVLMiddleware/TMC_JPEG/src/buffer/buffer_system.c
libs/RVLMiddleware/TMC_JPEG/src/buffer/getcode.c
libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3.c
libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse.c
libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main.c
libs/RVLMiddleware/TMC_JPEG/src/reschange/idct_resolution_change_var.c
libs/RVLMiddleware/TMC_JPEG/src/reschange/iqdec_resolution_change_a3.c
tools/decomp-assist/rx48.cleanup.md
```
```text
fee427cd refactor: type jpeg component and entropy table storage
e924ba6e refactor: describe jpeg exif decoder state fields
2fab68f0 refactor: use typed jpeg exif entries and field sizes
50ace99f refactor: derive jpeg buffer alignment and table clear sizes
05f1ddbf refactor: simplify jpeg geometry casts and huffman indexing
```
Final source review: no excluded files, existing assembly, configuration, or link status changed. The two reserved table words preserve existing storage; no padding was added. All 37 trials are logged. Raw frame access, existing public names, and remaining opaque ranges are retained for the measured code-generation, scope, or evidence constraints above.