Compare commits

...

15 Commits

Author SHA1 Message Date
coah
379c84d5f6 fix(TMC_JPEG): use consistent two-dimensional sampling tables 2026-10-05 09:32:25 -05:00
coah
bf65a26b5e build(eZiText): compile zi8clib with GC/3.0a5 like the original middleware; link five more units (rx35 astra max) (worker 1c1f2f35) (#1221) 2026-10-05 09:21:23 -05:00
coah
e174f2c2be refactor(TMC_JPEG): typed work-structure layouts instead of raw offsets (rx48) (worker dc2dd450) (#1220) 2026-10-05 09:01:37 -05:00
coah
044ab57149 refactor: named constants and descriptive names in address, keyboard, FA, AES, HTTP and BS2 files (rx43) (worker 217e90ad) (#1219) 2026-10-05 08:37:16 -05:00
coah
7c64b0a1f9 decomp(os,TMC_JPEG): write OSInit arena setup and parse_sof in C (rx41 astra max) (worker 42ac90a1) (#1218) 2026-10-05 08:33:55 -05:00
coah
f0722e8397 refactor(scene,system): named constants and cast cleanup in memory card, SD memory and system files (rx40) (worker 7ff7f6b8) (#1217) 2026-10-05 08:17:56 -05:00
coah
92f6177e64 refactor(libs): named constants and descriptive names in EGG, RFL, MSL, runtime, homebutton and SDK leftovers (rx39) (worker d7795368) (#1216) 2026-10-05 08:14:12 -05:00
coah
8899a8300c refactor(TMC_JPEG): name JPEG markers and EXIF tags, replace raw offsets (rx38) (worker c693132e) (#1215) 2026-10-05 08:01:41 -05:00
coah
46618a101c refactor(channelScript): use VM type and result constants, drop redundant casts (rx37) (worker 395bc9dc) (#1214) 2026-10-05 07:57:40 -05:00
coah
fef6f996d7 decomp(TMC_JPEG): match the YUV411 RGB565 converter (rx13 astra max) (worker 3c1dcd73) (#1213) 2026-10-05 07:51:24 -05:00
coah
78bfceef9f docs: inventory every assembly body and add a placeholder checker (rx36) (worker e3e4dedf) (#1212) 2026-10-05 07:47:05 -05:00
coah
d220c7accb refactor(keyboard,www,utility,sound,nw4r): named constants and cast cleanup (rx34) (worker 924a779f) (#1211) 2026-10-05 07:42:29 -05:00
coah
e8911343c6 refactor(sdk): use SDK result codes and flags, drop redundant casts (rx33) (worker 75928f09) (#1210) 2026-10-05 07:37:14 -05:00
coah
5a2113c1b1 refactor: give generic tmp/arg locals descriptive names (rx31) (worker 603061bb) (#1209) 2026-10-05 07:27:33 -05:00
coah
85a25256ce refactor(scene,system): use named constants, drop redundant casts and comparisons (rx32) (worker a3860f5f) (#1208) 2026-10-05 07:24:34 -05:00
260 changed files with 11343 additions and 4609 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"),
]
),

211
docs/asm-inventory.md Normal file
View File

@@ -0,0 +1,211 @@
# Assembly inventory
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,
invalid classifications and syntax it cannot inspect. This audit supersedes the
historical inventory in `tools/decomp-assist/asm-inventory.md`.
Scope: C/C++ sources and headers in `src/` and `libs/`, including inactive
platform branches, plus standalone assembly there or referenced by
`configure.py`. There are currently no standalone assembly files in that scope.
One row covers all blocks in a function; runtime save/restore entry labels belong
to their enclosing assembly body. Names use their source spelling. Declarations,
comments and string contents do not count.
ORIGINAL requires hardware, startup, runtime or original SDK assembly evidence.
An SDK path, `nofralloc` alone or an exact assembled object proves no C conversion.
The rvl_dec family follows the original decoder convention specified for this
audit; ASH/ASR also show unsigned `lis @h`/`ori @l` address construction and
hand-built `stmw` frames. C scores below are recorded rejected trials, not fresh
measurements or scores of the retained assembly. Unrecorded means no C score was
found. Historical logs absent from this branch have commit IDs and excerpts in
[the audit log](../tools/decomp-assist/rx36.attempts.md).
| File | Function | Classification | Evidence |
| --- | --- | --- | --- |
| `libs/MetroTRK/src/Export/targsupp.c` | `TRKAccessFile` | ORIGINAL | twi 31,r0,0 is the debugger file-service trap, with debugger-controlled return registers. |
| `libs/MetroTRK/src/Export/targsupp.c` | `TRKOpenFile` | ORIGINAL | twi 31,r0,0 is the debugger file-service trap, with debugger-controlled return registers. |
| `libs/MetroTRK/src/Export/targsupp.c` | `TRKCloseFile` | ORIGINAL | twi 31,r0,0 is the debugger file-service trap, with debugger-controlled return registers. |
| `libs/MetroTRK/src/Export/targsupp.c` | `TRKPositionFile` | ORIGINAL | twi 31,r0,0 is the debugger file-service trap, with debugger-controlled return registers. |
| `libs/NW4R/include/nw4r/math/arithmetic.h` | `FSelect` | ORIGINAL | fsel inline assembly matches the public [NW4R arithmetic header][arithmetic-h]. |
| `libs/NW4R/include/nw4r/math/arithmetic.h` | `FAbs` | ORIGINAL | fabs inline assembly matches the public [NW4R arithmetic header][arithmetic-h]. |
| `libs/NW4R/include/nw4r/math/types.h` | `VEC3Add` | ORIGINAL | psq_l/ps_add/psq_st implements paired-single vector/matrix operations. |
| `libs/NW4R/include/nw4r/math/types.h` | `VEC3Sub` | ORIGINAL | psq_l/ps_sub/psq_st implements paired-single vector/matrix operations. |
| `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_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. |
| `libs/RVL_SDK/include/revolution/os/OSFastCast.h` | `__OSf32tou8` | ORIGINAL | psq_st uses a GQR integer conversion format for the fast cast. |
| `libs/RVL_SDK/include/revolution/os/OSFastCast.h` | `__OSf32tou16` | ORIGINAL | psq_st uses a GQR integer conversion format for the fast cast. |
| `libs/RVL_SDK/include/revolution/os/OSFastCast.h` | `__OSs16tof32` | ORIGINAL | psq_l uses a GQR integer conversion format for the fast cast. |
| `libs/RVL_SDK/include/revolution/os/OSFastCast.h` | `__OSf32tos16` | ORIGINAL | psq_st uses a GQR integer conversion format for the fast cast. |
| `libs/RVL_SDK/src/ai/ai.c` | `__AICallbackStackSwitch` | ORIGINAL | Saves r1 to __OldStack, installs __CallbackStack, calls through LR, then restores r1. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfmsr` | ORIGINAL | Special-register or synchronization operation: `mfmsr r3`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMtmsr` | ORIGINAL | Special-register or synchronization operation: `mtmsr newMSR`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCOrMsr` | ORIGINAL | Special-register or synchronization operation: `mfmsr r4`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCAndMsr` | ORIGINAL | Special-register or synchronization operation: `mfmsr r4`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCAndCMsr` | ORIGINAL | Special-register or synchronization operation: `mfmsr r4`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfhid0` | ORIGINAL | Special-register or synchronization operation: `mfspr r3, HID0`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMthid0` | ORIGINAL | Special-register or synchronization operation: `mtspr HID0, newHID0`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfhid1` | ORIGINAL | Special-register or synchronization operation: `mfspr r3, HID1`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfl2cr` | ORIGINAL | Special-register or synchronization operation: `mfspr r3, L2CR`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMtl2cr` | ORIGINAL | Special-register or synchronization operation: `mtspr L2CR, newL2cr`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMtdec` | ORIGINAL | Special-register or synchronization operation: `mtdec newDec`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfdec` | ORIGINAL | Special-register or synchronization operation: `mfdec r3`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCSync` | ORIGINAL | Special-register or synchronization operation: `sc`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCEieio` | ORIGINAL | Special-register or synchronization operation: `mfmsr r5`, `mtmsr r6`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCHalt` | ORIGINAL | Special-register or synchronization operation: `sync`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfmmcr0` | ORIGINAL | Special-register or synchronization operation: `mfspr r3, MMCR0`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMtmmcr0` | ORIGINAL | Special-register or synchronization operation: `mtspr MMCR0, newMmcr0`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfmmcr1` | ORIGINAL | Special-register or synchronization operation: `mfspr r3, MMCR1`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMtmmcr1` | ORIGINAL | Special-register or synchronization operation: `mtspr MMCR1, newMmcr1`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfpmc1` | ORIGINAL | Special-register or synchronization operation: `mfspr r3, PMC1`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMtpmc1` | ORIGINAL | Special-register or synchronization operation: `mtspr PMC1, newPmc1`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfpmc2` | ORIGINAL | Special-register or synchronization operation: `mfspr r3, PMC2`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMtpmc2` | ORIGINAL | Special-register or synchronization operation: `mtspr PMC2, newPmc2`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfpmc3` | ORIGINAL | Special-register or synchronization operation: `mfspr r3, PMC3`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMtpmc3` | ORIGINAL | Special-register or synchronization operation: `mtspr PMC3, newPmc3`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfpmc4` | ORIGINAL | Special-register or synchronization operation: `mfspr r3, PMC4`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMtpmc4` | ORIGINAL | Special-register or synchronization operation: `mtspr PMC4, newPmc4`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMffpscr` | ORIGINAL | Special-register or synchronization operation: `mffs fp31`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfsia` | ORIGINAL | Special-register or synchronization operation: `mfspr r3, SIA`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMtsia` | ORIGINAL | Special-register or synchronization operation: `mtspr SIA, newSia`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMtfpscr` | ORIGINAL | Special-register or synchronization operation: `mtfsf 0xff, fp31`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfhid2` | ORIGINAL | Special-register or synchronization operation: `mfspr r3, HID2`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMthid2` | ORIGINAL | Special-register or synchronization operation: `mtspr HID2, newhid2`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfwpar` | ORIGINAL | Special-register or synchronization operation: `sync`, `mfspr r3, WPAR`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMtwpar` | ORIGINAL | Special-register or synchronization operation: `mtspr WPAR, newwpar`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfdmaU` | ORIGINAL | Special-register or synchronization operation: `mfspr r3, DMA_U`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfdmaL` | ORIGINAL | Special-register or synchronization operation: `mfspr r3, DMA_L`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMtdmaU` | ORIGINAL | Special-register or synchronization operation: `mtspr DMA_U, newdmau`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMtdmaL` | ORIGINAL | Special-register or synchronization operation: `mtspr DMA_L, newdmal`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMfpvr` | ORIGINAL | Special-register or synchronization operation: `mfspr r3, PVR`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCSetFpIEEEMode` | ORIGINAL | Special-register or synchronization operation: `mtfsb0 FPSCR_NI_BIT`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCSetFpNonIEEEMode` | ORIGINAL | Special-register or synchronization operation: `mtfsb1 FPSCR_NI_BIT`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMthid4` | ORIGINAL | Both branches write HID4 with mtspr; the fallback preserves the Broadway H4A bit. |
| `libs/RVL_SDK/src/cntcache/cntcache.c` | `CNTCACHEClear` | PLACEHOLDER | NAND/token logic; best C 93.364235%, 147/151 instructions, four missing pool literals, [rx30][rx30]. |
| `libs/RVL_SDK/src/cntcache/cntcache.c` | `_CNTCACHEIsTitleRemovable` | PLACEHOLDER | NAND/TMD checks; best diagnostic C 93.70731%, 82/82 instructions, status-register interference, [rx18][rx18]. |
| `libs/RVL_SDK/src/cntcache/cntcache.c` | `_CNTCACHEDeleteContent` | PLACEHOLDER | Token parsing and ES deletion; best C 95.793106%, 143/145 instructions, missing reload/copy, [rx18][rx18]. |
| `libs/RVL_SDK/src/db/db.c` | `__DBExceptionDestination` | ORIGINAL | mfmsr/mtmsr enable address translation before the exception-handler tail branch. |
| `libs/RVL_SDK/src/gx/GXLight.c` | `PushLight` | ORIGINAL | psq_l/psq_st transfers paired-single values for the GX command stream. |
| `libs/RVL_SDK/src/gx/GXTransform.c` | `WriteProjPS` | ORIGINAL | psq_l/psq_st transfers paired-single values for the GX command stream. |
| `libs/RVL_SDK/src/gx/GXTransform.c` | `Copy6Floats` | ORIGINAL | psq_l/psq_st copies three pairs of floats. |
| `libs/RVL_SDK/src/gx/GXTransform.c` | `WriteMTXPS4x3` | ORIGINAL | psq_l/psq_st transfers paired-single values for the GX command stream. |
| `libs/RVL_SDK/src/gx/GXTransform.c` | `WriteMTXPS3x3from3x4` | ORIGINAL | psq_l/psq_st transfers paired-single values for the GX command stream. |
| `libs/RVL_SDK/src/gx/GXTransform.c` | `WriteMTXPS4x2` | ORIGINAL | psq_l/psq_st transfers paired-single values for the GX command stream. |
| `libs/RVL_SDK/src/mtx/mtx.c` | `PSMTXIdentity` | ORIGINAL | psq_st/ps_merge01/ps_merge10 implements paired-single vector/matrix operations. |
| `libs/RVL_SDK/src/mtx/mtx.c` | `PSMTXCopy` | ORIGINAL | psq_l/psq_st implements paired-single vector/matrix operations. |
| `libs/RVL_SDK/src/mtx/mtx.c` | `PSMTXConcat` | ORIGINAL | psq_l/ps_muls0/ps_madds1/ps_madds0 implements paired-single vector/matrix operations. |
| `libs/RVL_SDK/src/mtx/mtx.c` | `PSMTXInverse` | ORIGINAL | psq_l/ps_merge10/ps_mul/ps_msub implements paired-single vector/matrix operations. |
| `libs/RVL_SDK/src/mtx/mtx.c` | `PSMTXInvXpose` | ORIGINAL | psq_l/ps_merge10/ps_mul/ps_msub implements paired-single vector/matrix operations. |
| `libs/RVL_SDK/src/mtx/mtx.c` | `PSMTXRotTrig` | ORIGINAL | Two blocks use frsp, ps_neg, ps_merge00 and psq_st to construct a paired-single rotation. |
| `libs/RVL_SDK/src/mtx/mtx.c` | `PSMTXTrans` | ORIGINAL | psq_st implements paired-single vector/matrix operations. |
| `libs/RVL_SDK/src/mtx/mtx.c` | `PSMTXTransApply` | ORIGINAL | psq_l/psq_st/ps_sum1 implements paired-single vector/matrix operations. |
| `libs/RVL_SDK/src/mtx/mtx.c` | `PSMTXScale` | ORIGINAL | psq_st implements paired-single vector/matrix operations. |
| `libs/RVL_SDK/src/mtx/mtx.c` | `PSMTXScaleApply` | ORIGINAL | psq_l/ps_muls0/psq_st implements paired-single vector/matrix operations. |
| `libs/RVL_SDK/src/mtx/mtxvec.c` | `PSMTXMultVec` | ORIGINAL | psq_l/ps_mul/ps_madd/ps_sum0 implements paired-single vector/matrix operations. |
| `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` | `__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. |
| `libs/RVL_SDK/src/os/OS.c` | `OSDefaultExceptionHandler` | ORIGINAL | Captures GQR1..7 with mfspr and interrupted r13..31 with stmw before dispatch. |
| `libs/RVL_SDK/src/os/OS.c` | `__OSPSInit` | ORIGINAL | mtspr initializes GQR0..7 for paired-single quantization. |
| `libs/RVL_SDK/src/os/OSAlarm.c` | `DecrementerExceptionHandler` | ORIGINAL | Saves interrupted GPRs and GQR1..7 via stmw/mfspr before the C callback. |
| `libs/RVL_SDK/src/os/OSCache.c` | `DCEnable` | ORIGINAL | sync and HID0 mfspr/mtspr enable the data cache. |
| `libs/RVL_SDK/src/os/OSCache.c` | `DCInvalidateRange` | ORIGINAL | dcbi invalidates each cache line. |
| `libs/RVL_SDK/src/os/OSCache.c` | `DCFlushRange` | ORIGINAL | dcbf flushes cache lines; sc invokes the synchronization vector. |
| `libs/RVL_SDK/src/os/OSCache.c` | `DCStoreRange` | ORIGINAL | dcbst writes cache lines; sc invokes the synchronization vector. |
| `libs/RVL_SDK/src/os/OSCache.c` | `DCFlushRangeNoSync` | ORIGINAL | dcbf flushes cache lines without the synchronization call. |
| `libs/RVL_SDK/src/os/OSCache.c` | `DCZeroRange` | ORIGINAL | dcbz zeroes each cache line. |
| `libs/RVL_SDK/src/os/OSCache.c` | `ICInvalidateRange` | ORIGINAL | icbi invalidates instructions, followed by sync/isync. |
| `libs/RVL_SDK/src/os/OSCache.c` | `ICFlashInvalidate` | ORIGINAL | HID0 mfspr/mtspr triggers instruction-cache flash invalidation. |
| `libs/RVL_SDK/src/os/OSCache.c` | `ICEnable` | ORIGINAL | isync and HID0 mfspr/mtspr enable the instruction cache. |
| `libs/RVL_SDK/src/os/OSCache.c` | `LCDisable` | ORIGINAL | dcbi clears locked-cache lines; HID2 mfspr/mtspr disables the locked cache. |
| `libs/RVL_SDK/src/os/OSContext.c` | `__OSLoadFPUContext` | ORIGINAL | Restores caller FPRs, FPSCR and paired-single halves using mtfsf/psq_l. |
| `libs/RVL_SDK/src/os/OSContext.c` | `__OSSaveFPUContext` | ORIGINAL | Captures caller FPSCR/FPRs and paired-single halves using mffs/psq_st. |
| `libs/RVL_SDK/src/os/OSContext.c` | `OSLoadFPUContext` | ORIGINAL | Moves context to r4 and tail-branches to __OSLoadFPUContext, which replaces caller FPRs. |
| `libs/RVL_SDK/src/os/OSContext.c` | `OSSaveFPUContext` | ORIGINAL | Moves context to r5 and tail-branches to __OSSaveFPUContext before caller FPRs change. |
| `libs/RVL_SDK/src/os/OSContext.c` | `OSSetCurrentContext` | ORIGINAL | mfmsr/mtmsr/isync change the FPU-enable bit while installing context pointers. |
| `libs/RVL_SDK/src/os/OSContext.c` | `OSSaveContext` | ORIGINAL | Captures caller r1/r2, GPRs, GQR1..7, CR, LR, XER and MSR for a later nonlocal return. |
| `libs/RVL_SDK/src/os/OSContext.c` | `OSLoadContext` | ORIGINAL | Restores GPRs and GQR1..7, sets SRR0/SRR1 and resumes interrupted execution with rfi. |
| `libs/RVL_SDK/src/os/OSContext.c` | `OSGetStackPointer` | ORIGINAL | nofralloc leaf returns the caller stack pointer directly with mr r3,r1. |
| `libs/RVL_SDK/src/os/OSContext.c` | `OSSwitchStack` | ORIGINAL | Returns the old r1 and installs the supplied stack pointer directly. |
| `libs/RVL_SDK/src/os/OSContext.c` | `OSSwitchFiber` | ORIGINAL | Installs another r1 and calls the supplied PC through LR; restores the old stack afterward. |
| `libs/RVL_SDK/src/os/OSContext.c` | `OSSwitchFiberEx` | ORIGINAL | Preserves r3..r6 arguments while switching r1 and calling the supplied PC through LR. |
| `libs/RVL_SDK/src/os/OSContext.c` | `OSInitContext` | ORIGINAL | Copies live ABI registers r2/r13 directly and seeds SRR state for a new execution context. |
| `libs/RVL_SDK/src/os/OSContext.c` | `OSSwitchFPUContext` | ORIGINAL | mfmsr/mtmsr/isync enable the FPU; the exception path restores SRR state and uses rfi. |
| `libs/RVL_SDK/src/os/OSContext.c` | `OSFillFPUContext` | ORIGINAL | mfmsr/mtmsr/isync enable the FPU before mffs and paired-single register saves. |
| `libs/RVL_SDK/src/os/OSInterrupt.c` | `OSDisableInterrupts` | ORIGINAL | mfmsr/mtmsr read and clear MSR_EE atomically within the restartable sequence. |
| `libs/RVL_SDK/src/os/OSInterrupt.c` | `OSEnableInterrupts` | ORIGINAL | mfmsr/mtmsr read and set MSR_EE. |
| `libs/RVL_SDK/src/os/OSInterrupt.c` | `OSRestoreInterrupts` | ORIGINAL | mfmsr/mtmsr replace MSR_EE with the saved interrupt state. |
| `libs/RVL_SDK/src/os/OSInterrupt.c` | `ExternalInterruptHandler` | ORIGINAL | Captures interrupted GPRs and GQR1..7 with stmw/mfspr before C interrupt dispatch. |
| `libs/RVL_SDK/src/os/OSMemory.c` | `ConfigMEM1_24MB` | ORIGINAL | isync and mtspr program IBAT/DBAT mappings; SRR0/SRR1 and rfi return with translation enabled. |
| `libs/RVL_SDK/src/os/OSMemory.c` | `ConfigMEM1_48MB` | ORIGINAL | isync and mtspr program IBAT/DBAT mappings; SRR0/SRR1 and rfi return with translation enabled. |
| `libs/RVL_SDK/src/os/OSMemory.c` | `ConfigMEM2_52MB` | ORIGINAL | isync and mtspr program IBAT/DBAT mappings; SRR0/SRR1 and rfi return with translation enabled. |
| `libs/RVL_SDK/src/os/OSMemory.c` | `ConfigMEM2_56MB` | ORIGINAL | isync and mtspr program IBAT/DBAT mappings; SRR0/SRR1 and rfi return with translation enabled. |
| `libs/RVL_SDK/src/os/OSMemory.c` | `ConfigMEM2_64MB` | ORIGINAL | isync and mtspr program IBAT/DBAT mappings; SRR0/SRR1 and rfi return with translation enabled. |
| `libs/RVL_SDK/src/os/OSMemory.c` | `ConfigMEM2_112MB` | ORIGINAL | isync and mtspr program IBAT/DBAT mappings; SRR0/SRR1 and rfi return with translation enabled. |
| `libs/RVL_SDK/src/os/OSMemory.c` | `ConfigMEM2_128MB` | ORIGINAL | isync and mtspr program IBAT/DBAT mappings; SRR0/SRR1 and rfi return with translation enabled. |
| `libs/RVL_SDK/src/os/OSMemory.c` | `ConfigMEM_ES1_0` | ORIGINAL | isync and mtspr program IBAT/DBAT mappings; SRR0/SRR1 and rfi return with translation enabled. |
| `libs/RVL_SDK/src/os/OSMemory.c` | `RealMode` | ORIGINAL | Writes SRR0/SRR1 and executes rfi with address translation disabled. |
| `libs/RVL_SDK/src/os/OSSync.c` | `SystemCallVector` | ORIGINAL | Changes HID0 with mfspr/mtspr around sync/isync, then returns with rfi. |
| `libs/RVL_SDK/src/os/OSTime.c` | `OSGetTime` | ORIGINAL | mftbu/mftb/mftbu retries until the upper time-base word is stable. |
| `libs/RVL_SDK/src/os/OSTime.c` | `OSGetTick` | ORIGINAL | mftb reads the hardware time-base register. |
| `libs/RVL_SDK/src/os/OSTime.c` | `__SetTime` | ORIGINAL | mttbl/mttbu/mttbl updates the hardware time base in a fixed sequence. |
| `libs/RVL_SDK/src/os/__ppc_eabi_init.cpp` | `__init_hardware` | ORIGINAL | Before normal C startup, mfmsr/mtmsr enables the FPU and r31 holds LR across init calls. |
| `libs/RVL_SDK/src/os/__ppc_eabi_init.cpp` | `__flush_cache` | ORIGINAL | dcbst/sync/icbi/isync make freshly initialized code visible to instruction fetch. |
| `libs/RVL_SDK/src/os/__ppc_eabi_init.cpp` | `__init_user` | ORIGINAL | fralloc/bl __init_cpp/frfree/blr matches the public [SDK startup assembly][sdk-init]. |
| `libs/RevoEX/src/nwc24/NWC24UserId.c` | `getUnScrambleId` | PLACEHOLDER | Integer byte permutation; best C 76.27329%, 161/161 instructions, 97 register/scheduling differences, [rx30][rx30]. |
| `libs/Runtime/src/Gecko_setjmp.c` | `__setjmp` | ORIGINAL | Saves or restores caller GPRs/FPRs, LR, CR, and stack state across nonlocal returns. |
| `libs/Runtime/src/Gecko_setjmp.c` | `longjmp` | ORIGINAL | Saves or restores caller GPRs/FPRs, LR, CR, and stack state across nonlocal returns. |
| `libs/Runtime/src/__init_cpp_exceptions.cpp` | `__exception_info_constants` | ORIGINAL | Reads the caller ABI TOC register r2 directly for exception registration. |
| `libs/Runtime/src/ptmf.c` | `__ptmf_scall` | ORIGINAL | Special compiler ABI takes the member-function descriptor in r12 and tail-dispatches through CTR. |
| `libs/Runtime/src/runtime.c` | `__cvt_fp2unsigned` | ORIGINAL | Unsigned conversion runtime helper with explicit CR0/CR6/CR7 tests; [public runtime assembly][runtime]. |
| `libs/Runtime/src/runtime.c` | `__save_fpr` | ORIGINAL | Entry labels _savefpr_14..31 store caller FPRs relative to r11 without an ABI call frame. |
| `libs/Runtime/src/runtime.c` | `__restore_fpr` | ORIGINAL | Entry labels _restfpr_14..31 reload caller FPRs relative to r11 without an ABI call frame. |
| `libs/Runtime/src/runtime.c` | `__save_gpr` | ORIGINAL | Entry labels _savegpr_14..31 store caller GPRs relative to r11 without an ABI call frame. |
| `libs/Runtime/src/runtime.c` | `__restore_gpr` | ORIGINAL | Entry labels _restgpr_14..31 reload caller GPRs relative to r11 without an ABI call frame. |
| `libs/Runtime/src/runtime.c` | `__div2u` | ORIGINAL | 64-bit compiler division helper uses r3:r4/r5:r6 and carry chains; [public assembly][runtime]. |
| `libs/Runtime/src/runtime.c` | `__div2i` | ORIGINAL | Signed 64-bit compiler division helper manages register-pair signs/carry; [public assembly][runtime]. |
| `libs/Runtime/src/runtime.c` | `__mod2u` | ORIGINAL | 64-bit compiler remainder helper uses register-pair restoring division; [public assembly][runtime]. |
| `libs/Runtime/src/runtime.c` | `__mod2i` | ORIGINAL | Signed 64-bit compiler remainder helper manages register-pair signs/carry; [public assembly][runtime]. |
| `libs/Runtime/src/runtime.c` | `__shl2i` | ORIGINAL | Compiler helper shifts r3:r4 by r5 without recursively calling the 64-bit shift helper. |
| `libs/Runtime/src/runtime.c` | `__shr2u` | ORIGINAL | Compiler helper shifts unsigned r3:r4 by r5 across the word boundary. |
| `libs/Runtime/src/runtime.c` | `__shr2i` | ORIGINAL | Compiler helper shifts signed r3:r4 by r5, explicitly propagating the sign. |
| `libs/Runtime/src/runtime.c` | `__cvt_sll_dbl` | ORIGINAL | Compiler conversion ABI uses r3:r4 input and f1 result with explicit carry/rounding. |
| `libs/Runtime/src/runtime.c` | `__cvt_ull_dbl` | ORIGINAL | Compiler conversion ABI uses r3:r4 input and f1 result with explicit carry/rounding. |
| `libs/Runtime/src/runtime.c` | `__cvt_ull_flt` | ORIGINAL | Compiler conversion ABI uses r3:r4 input and f1 result with explicit single-precision rounding. |
| `libs/Runtime/src/runtime.c` | `__cvt_dbl_usll` | ORIGINAL | Compiler conversion ABI uses f1 input and r3:r4 result without a recursive conversion call. |
| `libs/Runtime/src/runtime.c` | `__cvt_dbl_ull` | ORIGINAL | Compiler conversion helper decodes f1 into r3:r4; [public runtime assembly][runtime]. |
| `src/BS2/BS2Init.c` | `ClearOtherBATs` | ORIGINAL | isync and direct IBAT/DBAT register writes. |
| `src/BS2/BS2Mach.c` | `Run` | ORIGINAL | Clears ABI registers, replaces r1, uses dcbz/dcbf, and jumps via LR. |
| `src/BS2/BS2Start.c` | `__start` | ORIGINAL | Runs before the C stack and ABI registers exist; constructs the initial stack. |
| `src/BS2/BS2Start.c` | `__init_registers` | ORIGINAL | Initializes GPRs, r1, r2, and r13 for the C runtime. |
| `src/scene/nakamuraTest/gamespy/common/gsPlatformUtil.c` | `GetTicks` | ORIGINAL | Inactive PS2 branch reads the CP0 Count register with mfc0 $9. |
| `src/system/TVRC.cpp` | `TVRCSendStartAsync` | PLACEHOLDER | IR command setup; best recorded C 99.77273%, 198/198 instructions, seven differences, [rx2](../tools/decomp-assist/rx2.attempts.md); newer [rx17][rx17] 99.747475%. |
| `src/system/iplChannelManager.cpp` | `getTitleName__Q33ipl7channel7ManagerCFiii` | PLACEHOLDER | Channel-name copying; best C 99.57746%, 71/71 instructions, four address-order differences, [rx17][rx17]. |
| `src/system/iplSaveDataManager.cpp` | `Manager::hasChannel` | PLACEHOLDER | Title-slot search; best C 98.87324%, 71/71 instructions, 14 mask/base register differences, [rx30][rx30]. |
| `src/system/iplSaveDataManager.cpp` | `Manager::makePriorTitleIDList` | PLACEHOLDER | Title filtering; best recorded C 80.22556%, 124/133 instructions, address CSE, [da1](../tools/decomp-assist/da1.attempts.md); newer [rx17][rx17] 79.827065%. |
| `src/system/iplSaveDataManager.cpp` | `Manager::doUpdateChanInfos` | PLACEHOLDER | Channel metadata updates; best C 93.35821%, 68/67 instructions, extra memset base, [rx17][rx17]. |
| `src/system/iplSystem.cpp` | `System::warning_run` | PLACEHOLDER | Scene/render calls; best C 98.66477%, 176/176 instructions, 47 saved-register differences, [rx17][rx17]. |
| `src/system/rvl_dec.c` | `Rvl_decode` | ORIGINAL | Direct beq decoder entries preserve r3/r4 and LR; lis/ori builds the format signatures. |
| `src/system/rvl_dec.c` | `Rvl_decode_szs` | ORIGINAL | Original SZS decoder convention: nofralloc, r0 retains output length, fixed r3..r10/CTR byte-copy pipeline. |
| `src/system/rvl_dec.c` | `Rvl_decode_ash` | ORIGINAL | nofralloc hand-built 0x40 frame saves r21..31 with stmw; work address uses lis @h/ori @l. |
| `src/system/rvl_dec.c` | `Rvl_decode_asr` | ORIGINAL | nofralloc hand-built 0x40 frame saves r21..31 with stmw; work address uses lis @h/ori @l. |
[rx17]: ../tools/decomp-assist/rx36.attempts.md#rx17
[rx18]: ../tools/decomp-assist/rx36.attempts.md#rx18
[rx24]: ../tools/decomp-assist/rx36.attempts.md#rx24
[rx30]: ../tools/decomp-assist/rx36.attempts.md#rx30
[rx36-osinit]: ../tools/decomp-assist/rx36.attempts.md#osinit
[sdk-init]: https://github.com/doldecomp/ogws/blob/master/src/revolution/OS/__ppc_eabi_init.c
[runtime]: https://github.com/doldecomp/ogws/blob/master/src/runtime/runtime.c
[arithmetic-h]: https://github.com/doldecomp/ogws/blob/master/include/nw4r/math/math_arithmetic.h
[arithmetic-cpp]: https://github.com/doldecomp/ogws/blob/master/src/nw4r/math/math_arithmetic.cpp

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

@@ -202,7 +202,7 @@ namespace EGG {
return false;
}
return mSoundArchivePlayer.LoadGroup((int)id, pHeap, 0);
return mSoundArchivePlayer.LoadGroup(id, pHeap, 0);
}
bool ArcPlayer::loadGroup(const char* pName, nw4r::snd::SoundHeap* pHeap) {

View File

@@ -15,14 +15,14 @@ namespace EGG {
AudioFxMgr::AudioFxMgrArg unused1;
}
void SimpleAudioMgrWithFx::initialize(IAudioMgr::Arg* arg) {
SimpleAudioMgr::initialize(arg);
void SimpleAudioMgrWithFx::initialize(IAudioMgr::Arg* audioArgs) {
SimpleAudioMgr::initialize(audioArgs);
if (arg != NULL) {
arg = (IAudioMgr::Arg*)&((ArgWithFx*)arg)->fxArg;
if (audioArgs != NULL) {
audioArgs = (IAudioMgr::Arg*)&((ArgWithFx*)audioArgs)->fxArg;
}
initializeFx(&mHeap, (AudioFxMgrArg*)arg);
initializeFx(&mHeap, (AudioFxMgrArg*)audioArgs);
setFxReverbHi(nw4r::snd::AUX_A, AudioFxMgr::getDefaultFxReverbHi());
setFxChorus(nw4r::snd::AUX_B, AudioFxMgr::getDefaultFxChorus());

View File

@@ -37,7 +37,7 @@ namespace EGG {
mpOSThread = static_cast<OSThread*>(Heap::alloc(sizeof(OSThread), 32, mpContainHeap));
OSCreateThread(mpOSThread, Thread::start, this, reinterpret_cast<u8*>(mpStackMemory) + mStackSize, mStackSize, priority,
OSCreateThread(mpOSThread, Thread::start, this, static_cast<u8*>(mpStackMemory) + mStackSize, mStackSize, priority,
OS_THREAD_ATTR_DETACH);
setCommonMesgQueue(capacity, mpContainHeap);

View File

@@ -54,7 +54,7 @@ typedef struct {
int precision;
} print_format;
static const char* parse_format(const char* format_string, va_list* arg, print_format* format) {
static const char* parse_format(const char* format_string, va_list* args, print_format* format) {
print_format f;
const char* s = format_string;
int c;
@@ -109,7 +109,7 @@ static const char* parse_format(const char* format_string, va_list* arg, print_f
}
if (c == '*') {
if ((f.field_width = va_arg(*arg, int)) < 0) {
if ((f.field_width = va_arg(*args, int)) < 0) {
f.justification_options = left_justification;
f.field_width = -f.field_width;
}
@@ -132,7 +132,7 @@ static const char* parse_format(const char* format_string, va_list* arg, print_f
f.precision_specified = 1;
if ((c = *++s) == '*') {
if ((f.precision = va_arg(*arg, int)) < 0) {
if ((f.precision = va_arg(*args, int)) < 0) {
f.precision_specified = 0;
}
@@ -960,7 +960,7 @@ static char* float2str(long double num, char* buff, print_format format) {
}
int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* WriteProcArg,
const char* format_str, va_list arg
const char* format_str, va_list args
)
{
@@ -1000,27 +1000,27 @@ int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* WriteProc
}
format_ptr = curr_format;
format_ptr = parse_format(format_ptr, (va_list*)arg, &format);
format_ptr = parse_format(format_ptr, (va_list*)args, &format);
switch (format.conversion_char) {
case 'd':
case 'i':
if (format.argument_options == long_argument) {
long_num = va_arg(arg, signed long);
long_num = va_arg(args, signed long);
} else if (format.argument_options == long_long_argument) {
long_long_num = va_arg(arg, signed long long);
long_long_num = va_arg(args, signed long long);
}
else if (format.argument_options == intmax_argument) {
long_long_num = va_arg(arg, intmax_t);
long_long_num = va_arg(args, intmax_t);
}
else if (format.argument_options == size_t_argument) {
long_num = va_arg(arg, size_t);
long_num = va_arg(args, size_t);
}
else if (format.argument_options == ptrdiff_argument) {
long_num = va_arg(arg, ptrdiff_t);
long_num = va_arg(args, ptrdiff_t);
}
else {
long_num = va_arg(arg, int);
long_num = va_arg(args, int);
}
if (format.argument_options == short_argument) {
@@ -1052,21 +1052,21 @@ int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* WriteProc
case 'x':
case 'X':
if (format.argument_options == long_argument) {
long_num = va_arg(arg, unsigned long);
long_num = va_arg(args, unsigned long);
} else if (format.argument_options == long_long_argument) {
long_long_num = va_arg(arg, signed long long);
long_long_num = va_arg(args, signed long long);
}
else if (format.argument_options == intmax_argument) {
long_long_num = va_arg(arg, intmax_t);
long_long_num = va_arg(args, intmax_t);
}
else if (format.argument_options == size_t_argument) {
long_num = va_arg(arg, size_t);
long_num = va_arg(args, size_t);
}
else if (format.argument_options == ptrdiff_argument) {
long_num = va_arg(arg, ptrdiff_t);
long_num = va_arg(args, ptrdiff_t);
}
else {
long_num = va_arg(arg, unsigned int);
long_num = va_arg(args, unsigned int);
}
if (format.argument_options == short_argument) {
@@ -1100,9 +1100,9 @@ int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* WriteProc
case 'g':
case 'G':
if (format.argument_options == long_double_argument) {
long_double_num = va_arg(arg, long double);
long_double_num = va_arg(args, long double);
} else {
long_double_num = va_arg(arg, double);
long_double_num = va_arg(args, double);
}
if (!(buff_ptr = float2str(long_double_num, buff + 512, *fmt_ptr))) {
@@ -1115,9 +1115,9 @@ int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* WriteProc
case 'a':
case 'A':
if (format.argument_options == long_double_argument) {
long_double_num = va_arg(arg, long double);
long_double_num = va_arg(args, long double);
} else {
long_double_num = va_arg(arg, double);
long_double_num = va_arg(args, double);
}
if (!(buff_ptr = double2hex(long_double_num, buff + 512, *fmt_ptr))) {
@@ -1129,7 +1129,7 @@ int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* WriteProc
case 's':
if (format.argument_options == wchar_argument) {
wchar_t* wcs_ptr = va_arg(arg, wchar_t*);
wchar_t* wcs_ptr = va_arg(args, wchar_t*);
if (wcs_ptr == NULL) {
wcs_ptr = L"";
@@ -1141,7 +1141,7 @@ int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* WriteProc
buff_ptr = &buff[0];
} else {
buff_ptr = va_arg(arg, char*);
buff_ptr = va_arg(args, char*);
}
if (buff_ptr == NULL) {
@@ -1167,7 +1167,7 @@ int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* WriteProc
break;
case 'n':
buff_ptr = va_arg(arg, char*);
buff_ptr = va_arg(args, char*);
switch (format.argument_options) {
case normal_argument:
@@ -1197,7 +1197,7 @@ int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* WriteProc
case 'c':
buff_ptr = buff;
*buff_ptr = va_arg(arg, int);
*buff_ptr = va_arg(args, int);
num_chars = 1;
break;
@@ -1294,7 +1294,7 @@ int printf(const char* format, ...) {
{
va_list args;
va_start(args, format);
res = __pformatter(&__FileWrite, (void*)stdout, format, args);
res = __pformatter(&__FileWrite, stdout, format, args);
}
return res;
}
@@ -1308,18 +1308,18 @@ int fprintf(FILE* file, const char* format, ...) {
{
va_list args;
va_start(args, format);
res = __pformatter(&__FileWrite, (void*)file, format, args);
res = __pformatter(&__FileWrite, file, format, args);
}
return res;
}
int vprintf(const char* format, va_list arg) {
int vprintf(const char* format, va_list args) {
int ret;
if (fwide(stdout, -1) >= 0) {
return -1;
}
ret = __pformatter(&__FileWrite, (void*)stdout, format, arg);
ret = __pformatter(&__FileWrite, stdout, format, args);
return ret;
}
@@ -1345,8 +1345,8 @@ int vsnprintf(char* s, size_t n, const char* fmt, va_list args) {
return end;
}
int vsprintf(char *s, const char *format, va_list arg) {
return vsnprintf(s, 0xFFFFFFFF, format, arg);
int vsprintf(char *s, const char *format, va_list args) {
return vsnprintf(s, 0xFFFFFFFF, format, args);
}
int snprintf(char* s, size_t n, const char* format, ...) {

View File

@@ -5,11 +5,11 @@
char* p; \
char* q; \
size_t n = cnt; \
unsigned long tmp; \
unsigned long savedWord; \
for (p = (char*)src - 1, q = (char*)dst - 1, n++; --n;) { \
tmp = *++q; \
savedWord = *++q; \
*q = *++p; \
*p = tmp; \
*p = savedWord; \
} \
} while (0)

View File

@@ -257,7 +257,7 @@ static const char* parse_format(const char* format_string, scan_format* format)
return s + 1;
}
int __sformatter(int (*ReadProc)(void*, int, int), void* ReadProcArg, const char* format_str, va_list arg,
int __sformatter(int (*ReadProc)(void*, int, int), void* ReadProcArg, const char* format_str, va_list args,
int is_secure) {
int num_chars, chars_read, items_assigned, conversions;
int base, negative, overflow;
@@ -319,7 +319,7 @@ int __sformatter(int (*ReadProc)(void*, int, int), void* ReadProcArg, const char
format_ptr = parse_format(format_ptr, &format);
if (!format.suppress_assignment && format.conversion_char != '%') {
arg_ptr = va_arg(arg, char*);
arg_ptr = va_arg(args, char*);
} else {
arg_ptr = 0;
}
@@ -552,7 +552,7 @@ int __sformatter(int (*ReadProc)(void*, int, int), void* ReadProcArg, const char
if (arg_ptr) {
if (is_secure) {
elem_valid = 1;
elem_maxsize = va_arg(arg, size_t);
elem_maxsize = va_arg(args, size_t);
}
num_chars = 0;
@@ -648,7 +648,7 @@ int __sformatter(int (*ReadProc)(void*, int, int), void* ReadProcArg, const char
if (arg_ptr) {
if (is_secure) {
elem_valid = 1;
elem_maxsize = va_arg(arg, size_t) - 1;
elem_maxsize = va_arg(args, size_t) - 1;
}
num_chars = 0;
@@ -797,7 +797,7 @@ int __StringRead(void* pPtr, int ch, int act) {
return 0;
}
inline int vsscanf(const char* s, const char* format, va_list arg) {
inline int vsscanf(const char* s, const char* format, va_list args) {
__InStrCtrl isc;
isc.NextChar = (char*)s;
@@ -806,7 +806,7 @@ inline int vsscanf(const char* s, const char* format, va_list arg) {
}
isc.NullCharDetected = 0;
return __sformatter(&__StringRead, (void*)&isc, format, arg, 0);
return __sformatter(&__StringRead, (void*)&isc, format, args, 0);
}
int sscanf(const char* s, const char* pFormat, ...) {

View File

@@ -55,7 +55,7 @@ typedef struct {
static const wchar_t* parse_format(const wchar_t* format_string, va_list* arg, print_format* format) {
static const wchar_t* parse_format(const wchar_t* format_string, va_list* args, print_format* format) {
print_format f;
const wchar_t* s = format_string;
wchar_t c;
@@ -110,14 +110,14 @@ static const wchar_t* parse_format(const wchar_t* format_string, va_list* arg, p
}
if (c == '*') {
if ((f.field_width = va_arg(*arg, int)) < 0) {
if ((f.field_width = va_arg(*args, int)) < 0) {
f.justification_options = left_justification;
f.field_width = -f.field_width;
}
c = *++s;
} else {
while ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & 0x8) != 0) {
while ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & __MSL_ISDIGIT_MAP) != 0) {
f.field_width = f.field_width * 10 + (c - '0');
c = *++s;
}
@@ -133,13 +133,13 @@ static const wchar_t* parse_format(const wchar_t* format_string, va_list* arg, p
f.precision_specified = 1;
if ((c = *++s) == '*') {
if ((f.precision = va_arg(*arg, int)) < 0) {
if ((f.precision = va_arg(*args, int)) < 0) {
f.precision_specified = 0;
}
c = *++s;
} else {
while ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & 0x8) != 0)
while ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & __MSL_ISDIGIT_MAP) != 0)
{
f.precision = f.precision * 10 + (c - '0');
c = *++s;
@@ -769,7 +769,7 @@ static wchar_t* float2str(double num, wchar_t* buff, print_format format) {
c = format.conversion_char;
p = buff - 5;
if ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & 0x200) != 0) {
if ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & __MSL_ISUPPER_MAP) != 0) {
wcscpy(p, L"-INF");
} else {
wcscpy(p, L"-inf");
@@ -777,7 +777,7 @@ static wchar_t* float2str(double num, wchar_t* buff, print_format format) {
} else {
c = format.conversion_char;
p = buff - 4;
if ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & 0x200) != 0) {
if ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & __MSL_ISUPPER_MAP) != 0) {
wcscpy(p, L"INF");
} else {
wcscpy(p, L"inf");
@@ -790,7 +790,7 @@ static wchar_t* float2str(double num, wchar_t* buff, print_format format) {
if (dec.sign) {
c = format.conversion_char;
p = buff - 5;
if ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & 0x200) != 0) {
if ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & __MSL_ISUPPER_MAP) != 0) {
wcscpy(p, L"-NAN");
} else {
wcscpy(p, L"-nan");
@@ -798,7 +798,7 @@ static wchar_t* float2str(double num, wchar_t* buff, print_format format) {
} else {
c = format.conversion_char;
p = buff - 4;
if ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & 0x200) != 0) {
if ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & __MSL_ISUPPER_MAP) != 0) {
wcscpy(p, L"NAN");
} else {
wcscpy(p, L"nan");
@@ -958,8 +958,8 @@ static wchar_t* float2str(double num, wchar_t* buff, print_format format) {
break;
}
p = buff - strlen((char*)p2) - 1;
mbstowcs(p, p2, strlen((char*)p2));
p = buff - strlen(p2) - 1;
mbstowcs(p, p2, strlen(p2));
return p;
}
@@ -1290,7 +1290,7 @@ void* __wStringWrite(void* wosc, const wchar_t* buffer, size_t numchars) {
void* res;
__wOutStrCtrl* wOscp = (__wOutStrCtrl*)wosc;
tobewritten = ((wOscp->CharsWritten + numchars) <= wOscp->MaxCharCount) ? numchars : wOscp->MaxCharCount - wOscp->CharsWritten;
res = (void*)wmemcpy(wOscp->wCharStr + wOscp->CharsWritten, buffer, tobewritten);
res = wmemcpy(wOscp->wCharStr + wOscp->CharsWritten, buffer, tobewritten);
wOscp->CharsWritten += tobewritten;
return res;
}

View File

@@ -1,3 +1,3 @@
#include <math.h>
double nan(const char* arg) {}
double nan(const char* tag) {}

View File

@@ -37,14 +37,14 @@ inline DSIOResult __access_file(unsigned int handle, unsigned char* buffer, int*
}
DSIOResult __read_console(unsigned int handle, unsigned char* buffer, int* count, void* ref_con) {
if (GetUseSerialIO() == FALSE) {
if (!GetUseSerialIO()) {
return DS_IOError;
}
return __read_file(DS_Stdin, buffer, count, ref_con);
}
DSIOResult __TRK_write_console(unsigned int handle, unsigned char* buffer, int* count, void* ref_con) {
if (GetUseSerialIO() == 0) {
if (!GetUseSerialIO()) {
return DS_IOError;
}
return __write_file(DS_Stdout, buffer, count, ref_con);

View File

@@ -79,7 +79,7 @@ namespace nw4r {
sException.frameMemory = NULL;
sException.exceptionRenderObj = NULL;
OSCreateThread(&sException.thread, RunThread_, NULL, sThreadBuffer + 0x4000, 0x4000, 0, 1);
OSCreateThread(&sException.thread, RunThread_, NULL, sThreadBuffer + 0x4000, 0x4000, 0, OS_THREAD_ATTR_DETACH);
OSInitMessageQueue(&sException.queue, sMessageBuffer, 1);
OSResumeThread(&sException.thread);
@@ -98,7 +98,7 @@ namespace nw4r {
sException.FPCSR_COPY = context->fpscr;
OSFillFPUContext(context);
OSSetErrorHandler(error, NULL);
if (error == 0xf) {
if (error == OS_EXCEPTION_MEMORY_PROTECTION) {
OSProtectRange(0, 0, 0, 3);
OSProtectRange(1, 0, 0, 3);
OSProtectRange(2, 0, 0, 3);
@@ -111,7 +111,7 @@ namespace nw4r {
param.dsisr = dsisr;
param.dar = dar;
OSSendMessage(&sException.queue, &param, 1);
OSSendMessage(&sException.queue, &param, OS_MESSAGE_BLOCK);
OSEnableScheduler();
OSYieldThread();
@@ -138,7 +138,7 @@ namespace nw4r {
u32 msr = PPCMfmsr();
PPCMtmsr(msr & ~(MSR_FE0 | MSR_FE1));
OSReceiveMessage(&sException.queue, &message, 1);
OSReceiveMessage(&sException.queue, &message, OS_MESSAGE_BLOCK);
OSDisableInterrupts();
VISetPreRetraceCallback(NULL);
@@ -303,46 +303,46 @@ namespace nw4r {
if (error == OS_EXCEPTION_FLOATING_POINT_EXCEPTION) {
u32 fpcsr = sException.FPCSR_COPY;
fpcsr &= (((fpcsr & 0xf8) << 0x16) | 0x01f80700);
if ((fpcsr & 0x20000000) != 0) {
if ((fpcsr & FPSCR_VX) != 0) {
Exception_Printf_(" FPE: Invalid operation\n");
if ((sException.FPCSR_COPY & 0x1000000) != 0) {
if ((sException.FPCSR_COPY & FPSCR_VXSNAN) != 0) {
Exception_Printf_(" SNaN\n");
}
if ((sException.FPCSR_COPY & 0x800000) != 0) {
if ((sException.FPCSR_COPY & FPSCR_VXISI) != 0) {
Exception_Printf_(" Infinity - Infinity\n");
}
if ((sException.FPCSR_COPY & 0x400000) != 0) {
if ((sException.FPCSR_COPY & FPSCR_VXIDI) != 0) {
Exception_Printf_(" Infinity / Infinity\n");
}
if ((sException.FPCSR_COPY & 0x200000) != 0) {
if ((sException.FPCSR_COPY & FPSCR_VXZDZ) != 0) {
Exception_Printf_(" 0 / 0\n");
}
if ((sException.FPCSR_COPY & 0x100000) != 0) {
if ((sException.FPCSR_COPY & FPSCR_VXIMZ) != 0) {
Exception_Printf_(" Infinity * 0\n");
}
if ((sException.FPCSR_COPY & 0x80000) != 0) {
if ((sException.FPCSR_COPY & FPSCR_VXVC) != 0) {
Exception_Printf_(" Invalid compare\n");
}
if ((sException.FPCSR_COPY & 0x400) != 0) {
if ((sException.FPCSR_COPY & FPSCR_VXSOFT) != 0) {
Exception_Printf_(" Software request\n");
}
if ((sException.FPCSR_COPY & 0x200) != 0) {
if ((sException.FPCSR_COPY & FPSCR_VXSQRT) != 0) {
Exception_Printf_(" Invalid square root\n");
}
if ((sException.FPCSR_COPY & 0x100) != 0) {
if ((sException.FPCSR_COPY & FPSCR_VXCVI) != 0) {
Exception_Printf_(" Invalid integer convert\n");
}
}
if ((fpcsr & 0x10000000) != 0) {
if ((fpcsr & FPSCR_OX) != 0) {
Exception_Printf_(" FPE: Overflow\n");
}
if ((fpcsr & 0x8000000) != 0) {
if ((fpcsr & FPSCR_UX) != 0) {
Exception_Printf_(" FPE: Underflow\n");
}
if ((fpcsr & 0x4000000) != 0) {
if ((fpcsr & FPSCR_ZX) != 0) {
Exception_Printf_(" FPE: Zero division\n");
}
if ((fpcsr & 0x2000000) != 0) {
if ((fpcsr & FPSCR_XX) != 0) {
Exception_Printf_(" FPE: Inexact result\n");
}
}

View File

@@ -135,12 +135,12 @@ namespace nw4r {
for (int i = 0; i < texCoordNum; i++) {
GXSetVtxDesc(static_cast<GXAttr>(GX_VA_TEX0 + i), GX_DIRECT);
}
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGB, GX_F32, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_F32, 0);
if (bModulate) {
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
}
for (int i = 0; i < texCoordNum; i++) {
GXSetVtxAttrFmt(GX_VTXFMT0, static_cast<GXAttr>(GX_VA_TEX0 + i), GX_CLR_RGBA, GX_F32, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, static_cast<GXAttr>(GX_VA_TEX0 + i), GX_TEX_ST, GX_F32, 0);
}
}

View File

@@ -968,8 +968,8 @@ namespace nw4r {
for (u8 id = 0; id < tevStageNum; id++) {
GXTevStageID tevStage = static_cast<GXTevStageID>(id);
GXSetTevColorOp(tevStage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevAlphaOp(tevStage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevColorOp(tevStage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevAlphaOp(tevStage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevDirect(tevStage);
GXSetTevSwapMode(tevStage, GX_TEV_SWAP0, GX_TEV_SWAP0);

View File

@@ -411,8 +411,8 @@ namespace nw4r {
mtxPtr = mGlbMtx;
}
GXLoadPosMtxImm(mtxPtr, 0);
GXSetCurrentMtx(0);
GXLoadPosMtxImm(mtxPtr, GX_PNMTX0);
GXSetCurrentMtx(GX_PNMTX0);
}
math::VEC2 Pane::GetVtxPos() const {

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

@@ -25,16 +25,16 @@ namespace nw4r {
}
VEC4* VEC4Transform(VEC4* pOut, const MTX44* pM, const VEC4* pV) {
VEC4 tmp;
tmp.x = pM->_00 * pV->x + pM->_01 * pV->y + pM->_02 * pV->z + pM->_03 * pV->w;
tmp.y = pM->_10 * pV->x + pM->_11 * pV->y + pM->_12 * pV->z + pM->_13 * pV->w;
tmp.z = pM->_20 * pV->x + pM->_21 * pV->y + pM->_22 * pV->z + pM->_23 * pV->w;
tmp.w = pM->_30 * pV->x + pM->_31 * pV->y + pM->_32 * pV->z + pM->_33 * pV->w;
VEC4 transformed;
transformed.x = pM->_00 * pV->x + pM->_01 * pV->y + pM->_02 * pV->z + pM->_03 * pV->w;
transformed.y = pM->_10 * pV->x + pM->_11 * pV->y + pM->_12 * pV->z + pM->_13 * pV->w;
transformed.z = pM->_20 * pV->x + pM->_21 * pV->y + pM->_22 * pV->z + pM->_23 * pV->w;
transformed.w = pM->_30 * pV->x + pM->_31 * pV->y + pM->_32 * pV->z + pM->_33 * pV->w;
pOut->x = tmp.x;
pOut->y = tmp.y;
pOut->z = tmp.z;
pOut->w = tmp.w;
pOut->x = transformed.x;
pOut->y = transformed.y;
pOut->z = transformed.z;
pOut->w = transformed.w;
return pOut;
}
} // namespace math

View File

@@ -808,7 +808,7 @@ namespace nw4r {
} else {
u16 a0, b0;
if (mVpb[0][0]->pb.lpf.on == TRUE) {
if (mVpb[0][0]->pb.lpf.on == AX_PB_LPF_ON) {
AXGetLpfCoefs(freq, &a0, &b0);
for (int j = 0; j < mChannelCount; j++) {
@@ -817,7 +817,7 @@ namespace nw4r {
} else {
AXPBLPF lpf;
lpf.on = TRUE;
lpf.on = AX_PB_LPF_ON;
lpf.yn1 = 0;
AXGetLpfCoefs(freq, &lpf.a0, &lpf.b0);

View File

@@ -148,7 +148,7 @@ namespace nw4r {
return NULL;
}
pSub = reinterpret_cast<const BankFile::DataRegion*>(pIndexTable->ref + (splitKey - pIndexTable->min));
pSub = pIndexTable->ref + (splitKey - pIndexTable->min);
break;
}
}

View File

@@ -61,9 +61,9 @@ namespace nw4r {
if (mPlayFlag) {
if (playFlag) {
wencMode = 1;
wencMode = WENC_FLAG_USER_INFO;
} else {
wencMode = 1;
wencMode = WENC_FLAG_USER_INFO;
lastFlag = true;
}
} else {
@@ -71,7 +71,7 @@ namespace nw4r {
if (mFirstEncodeFlag) {
wencMode = 0;
} else {
wencMode = 1;
wencMode = WENC_FLAG_USER_INFO;
}
mFirstEncodeFlag = false;

View File

@@ -58,7 +58,7 @@ namespace nw4r {
OSMessage message;
while (true) {
OSReceiveMessage(&mMsgQueue, &message, 1);
OSReceiveMessage(&mMsgQueue, &message, OS_MESSAGE_BLOCK);
if (reinterpret_cast<u32>(message) == MSG_AX_CALLBACK) {
ut::AutoMutexLock autoMutex(mMutex);

View File

@@ -52,7 +52,7 @@ namespace nw4r {
u8 mask = 1 << 0;
for (int j = 0; j < 8; j++, mask <<= 1) {
for (int j = 0; j < BITS_PER_BYTE; j++, mask <<= 1) {
// Block represented by this bit is in use
if (flag & mask) {
continue;

View File

@@ -718,7 +718,7 @@ namespace nw4r {
}
void StrmPlayer::NotifyStrmHeaderAsyncEndCallback(bool result, const StrmHeader* header, void* userData) {
StrmPlayer* player = reinterpret_cast<StrmPlayer*>(userData);
StrmPlayer* player = static_cast<StrmPlayer*>(userData);
if (result) {
player->Setup(header);
} else {

View File

@@ -33,7 +33,7 @@ namespace nw4r {
void* TaskThread::ThreadFunc(void* arg) {
TaskThread* thread = static_cast<TaskThread*>(arg);
OSInitMessageQueue(&thread->mMsgQueue, thread->mMsgBuffer, 8);
OSInitMessageQueue(&thread->mMsgQueue, thread->mMsgBuffer, MSG_QUEUE_CAPACITY);
thread->ThreadProc();
@@ -44,7 +44,7 @@ namespace nw4r {
OSMessage msg;
while (true) {
OSReceiveMessage(&mMsgQueue, &msg, 1);
OSReceiveMessage(&mMsgQueue, &msg, OS_MESSAGE_BLOCK);
if (reinterpret_cast<u32>(msg) == MSG_EXECUTE) {
TaskManager::GetInstance().Execute();

View File

@@ -160,7 +160,7 @@ namespace nw4r {
void WavePlayer::Pause(bool flag) {
ut::AutoInterruptLock lock;
if (mStartFlag == false) {
if (!mStartFlag) {
return;
}
@@ -224,7 +224,7 @@ namespace nw4r {
}
void WavePlayer::VoiceCallbackFunc(detail::AxVoice* voice, detail::AxVoice::CallbackStatus status, void* arg) {
WavePlayer* wavePlayer = reinterpret_cast<WavePlayer*>(arg);
WavePlayer* wavePlayer = static_cast<WavePlayer*>(arg);
switch (status) {
case detail::AxVoice::CALLBACK_STATUS_FINISH_WAVE:
case detail::AxVoice::CALLBACK_STATUS_INVALIDATE_WAVE: {

View File

@@ -250,7 +250,7 @@ namespace nw4r {
}
if (!mPauseFlag && !mSkipFlag) {
if (mHomeButtonMenuFlag || !AxManager::GetInstance().IsHomeButtonMenu()) {
if (ParseNextTick(true) != 0) {
if (ParseNextTick(true)) {
FinishPlayer();
return;
}

View File

@@ -109,7 +109,7 @@ namespace nw4r {
}
Color CharWriter::GetTextColor() const {
return *reinterpret_cast<const Color*>(&mTextColor);
return mTextColor.start;
}
void CharWriter::SetScale(f32 hScale, f32 vScale) {
@@ -274,8 +274,8 @@ namespace nw4r {
if (loadInfo != mLoadingTexture) {
GXTexObj tobj;
GXInitTexObj(&tobj, glyph.pTexture, glyph.texWidth, glyph.texHeight, glyph.texFormat, GX_CLAMP, GX_CLAMP, 0);
GXInitTexObjLOD(&tobj, mFilter.atSmall, mFilter.atLarge, 0.0f, 0.0f, 0.0f, false, false, GX_ANISO_1);
GXInitTexObj(&tobj, glyph.pTexture, glyph.texWidth, glyph.texHeight, glyph.texFormat, GX_CLAMP, GX_CLAMP, GX_FALSE);
GXInitTexObjLOD(&tobj, mFilter.atSmall, mFilter.atLarge, 0.0f, 0.0f, 0.0f, GX_FALSE, GX_FALSE, GX_ANISO_1);
GXLoadTexObj(&tobj, slot);
mLoadingTexture = loadInfo;
@@ -333,14 +333,14 @@ namespace nw4r {
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_C0, GX_CC_C1, GX_CC_TEXC, GX_CC_ZERO);
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A0, GX_CA_A1, GX_CA_TEXA, GX_CA_ZERO);
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
GXSetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_CPREV, GX_CC_RASC, GX_CC_ZERO);
GXSetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_APREV, GX_CA_RASA, GX_CA_ZERO);
GXSetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
SetupVertexFormat();
}
@@ -354,8 +354,8 @@ namespace nw4r {
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_RASC);
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_TEXA, GX_CA_RASA, GX_CA_ZERO);
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
SetupVertexFormat();
}

View File

@@ -200,10 +200,10 @@ namespace nw4r {
glyph->pTexture = pSheet;
glyph->widths = GetCharWidthsFromIndex(index);
glyph->height = static_cast<u8>(tg.cellHeight);
glyph->height = tg.cellHeight;
glyph->texFormat = static_cast<GXTexFmt>(tg.sheetFormat);
glyph->texWidth = static_cast<u16>(tg.sheetWidth);
glyph->texHeight = static_cast<u16>(tg.sheetHeight);
glyph->texWidth = tg.sheetWidth;
glyph->texHeight = tg.sheetHeight;
glyph->cellX = cellPixelX + 1;
glyph->cellY = cellPixelY + 1;
}

View File

@@ -590,7 +590,7 @@ static void replacebuffer_(s32 chan, RFLiCtrlBuffer* buffer, u8 count) {
offset = (count * sizeof(RFLiCtrlBuffer)) + OFFSET;
write = WPADWriteFaceData(chan, ((u8*)walker + OFFSET), 4, WPAD_FACE_ADDR + offset, replacecallback_);
write = WPADWriteFaceData(chan, (walker + OFFSET), 4, WPAD_FACE_ADDR + offset, replacecallback_);
if (write != WPAD_ERR_OK) {
RFLiEndWorkingReason(RFLErrcode_Controllerfail, write);
}

View File

@@ -98,7 +98,7 @@ void loadopencallback_() {
}
}
RFLErrcode RFLiLoadHiddenDataAsync(RFLiHiddenCharData* data, u16 index, RFLSimpleCBArg cb, u32 arg) {
RFLErrcode RFLiLoadHiddenDataAsync(RFLiHiddenCharData* data, u16 index, RFLSimpleCBArg cb, u32 callbackArg) {
RFLiHiddenDBManager* manager = NULL;
RFLi_ASSERTLINE_RANGE(index, 0, RFL_MAX_HIDDEN_DB, 203);
@@ -126,7 +126,7 @@ RFLErrcode RFLiLoadHiddenDataAsync(RFLiHiddenCharData* data, u16 index, RFLSimpl
manager->loadDst = data;
manager->loadIndex = index;
manager->loadCallback = cb;
manager->loadArg = arg;
manager->loadArg = callbackArg;
return RFLiOpenAsync(RFLiFileType_Database, NAND_ACCESS_READ, loadopencallback_);
}

View File

@@ -35,7 +35,7 @@ void RFLiSetupCopyTex(GXTexFmt texFmt, u16 width, u16 height, void* buf, GXColor
GXSetPixelFmt(GX_PF_RGBA6_Z24, GX_ZC_LINEAR);
GXSetCopyFilter(GX_FALSE, NULL, GX_FALSE, NULL);
GXSetCopyClamp(GX_CLAMP_TOP + GX_CLAMP_BOTTOM);
GXSetCopyClamp(GX_CLAMP_TOP | GX_CLAMP_BOTTOM);
GXSetTexCopySrc(0, 0, width, height);
GXSetTexCopyDst(width, height, texFmt, GX_FALSE);
@@ -541,8 +541,8 @@ void RFLiSetTev4Mole() {
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0);
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA);
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevColor(GX_TEVREG0, RFLi_MOLE_COLOR0);
}
@@ -556,22 +556,22 @@ void RFLiSetTev4Mouth(u32 mouthColor) {
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_C0, GX_CC_TEXC, GX_CC_ZERO);
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA);
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP3, GX_TEV_SWAP2);
GXSetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GXSetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_C1, GX_CC_TEXC, GX_CC_CPREV);
GXSetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_APREV);
GXSetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevSwapMode(GX_TEVSTAGE2, GX_TEV_SWAP2, GX_TEV_SWAP3);
GXSetTevOrder(GX_TEVSTAGE2, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GXSetTevColorIn(GX_TEVSTAGE2, GX_CC_ZERO, GX_CC_ONE, GX_CC_TEXC, GX_CC_CPREV);
GXSetTevAlphaIn(GX_TEVSTAGE2, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_APREV);
GXSetTevColorOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
GXSetTevColorOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
color0 = RFLi_MOUTH_COLOR0[mouthColor];
color1 = RFLi_MOUTH_COLOR1[mouthColor];

View File

@@ -103,15 +103,15 @@ static BOOL checkHiddenData_(RFLiHiddenCharData* data) {
RFLiConvertHRaw2Info(data, &info);
if (RFLiCheckValidInfo(&info) == FALSE) {
if (!RFLiCheckValidInfo(&info)) {
return FALSE;
}
return TRUE;
}
static void updateHDBcallback_(u32 arg) {
RFLiMiddleDatabase* db = (RFLiMiddleDatabase*)arg;
static void updateHDBcallback_(u32 databaseAddr) {
RFLiMiddleDatabase* db = (RFLiMiddleDatabase*)databaseAddr;
RFL_NEW_OLD_PARAM* param = (RFL_NEW_OLD_PARAM*)&db->userdata1;
if (RFLGetAsyncStatus() == RFLErrcode_Success || RFLGetAsyncStatus() == RFLErrcode_Broken) {
@@ -299,8 +299,8 @@ static void loadHiddenRandomSync_(RFLiMiddleDatabase* db) {
RFLiGetManager()->mLastErrcode = db->storedSize < db->size ? RFLErrcode_DBNodata : RFLErrcode_Success;
}
static void updateHDBRandcallback_(u32 arg) {
RFLiMiddleDatabase* db = (RFLiMiddleDatabase*)arg;
static void updateHDBRandcallback_(u32 databaseAddr) {
RFLiMiddleDatabase* db = (RFLiMiddleDatabase*)databaseAddr;
RFL_HIDDEN_RANDOM_PARAM* param = (RFL_HIDDEN_RANDOM_PARAM*)&db->userdata1;
if (RFLGetAsyncStatus() == RFLErrcode_Success || RFLGetAsyncStatus() == RFLErrcode_Broken) {
@@ -387,7 +387,7 @@ static void updateHiddenRandom_(RFLiMiddleDatabase* db, BOOL use_cache) {
RFLi_ASSERTLINE(aidx == count, 514);
for (i = 0; i < (count - 1); i++) {
u16 tmp;
u16 shuffledIndex;
u16 target;
target = (((rand >> 0x10) + rand) & 0xFFFF) % (count - 1);
@@ -395,9 +395,9 @@ static void updateHiddenRandom_(RFLiMiddleDatabase* db, BOOL use_cache) {
target++;
}
tmp = array[target];
shuffledIndex = array[target];
array[target] = array[i];
array[i] = tmp;
array[i] = shuffledIndex;
rand = 0x04F8BB63 * (rand + 0x046AC055);
}
@@ -586,12 +586,12 @@ RFLMiddleDBType RFLGetMiddleDBType(const RFLMiddleDatabase* db) {
u16 RFLGetMiddleDBSize(const RFLMiddleDatabase* db) {
RFLi_ASSERTLINE_NULL(db, 772);
return (u16)((RFLiMiddleDatabase*)db)->size;
return ((RFLiMiddleDatabase*)db)->size;
}
u16 RFLGetMiddleDBStoredSize(const RFLMiddleDatabase* db) {
RFLi_ASSERTLINE_NULL(db, 789);
return (u16)((RFLiMiddleDatabase*)db)->storedSize;
return ((RFLiMiddleDatabase*)db)->storedSize;
}
BOOL RFLiGetCharInfoMiddleDB(RFLiCharInfo* info, const RFLMiddleDatabase* db, u16 index) {

View File

@@ -607,123 +607,123 @@ void RFLiInitCharModelRes(RFLiCharModelRes* charModelRes, const RFLiCharInfo* in
// Init faceline shape
{
RFLiCharShapeRes arg;
RFLiCharShapeRes shapeRes;
arg.parts = RFLiPartsShp_Faceline;
arg.index = info->faceline.type;
arg.vtxPosBuf = charModelRes->vtxPosFaceline;
arg.vtxNrmBuf = charModelRes->vtxNrmFaceline;
arg.vtxTxcBuf = charModelRes->vtxTxcFaceline;
arg.dlBuf = charModelRes->dlFaceline;
arg.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosFaceline));
arg.vtxNrmBufSize = NUM_VTX_NRM(sizeof(charModelRes->vtxNrmFaceline));
arg.vtxTxcBufSize = NUM_VTX_TXC(sizeof(charModelRes->vtxTxcFaceline));
arg.dlBufSize = sizeof(charModelRes->dlFaceline);
arg.noseTrans = &noseTrans;
arg.beardTrans = &beardTrans;
arg.hairTrans = &hairTrans;
arg.flipX = FALSE;
arg.transform = FALSE;
RFLiInitShapeRes(&arg);
shapeRes.parts = RFLiPartsShp_Faceline;
shapeRes.index = info->faceline.type;
shapeRes.vtxPosBuf = charModelRes->vtxPosFaceline;
shapeRes.vtxNrmBuf = charModelRes->vtxNrmFaceline;
shapeRes.vtxTxcBuf = charModelRes->vtxTxcFaceline;
shapeRes.dlBuf = charModelRes->dlFaceline;
shapeRes.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosFaceline));
shapeRes.vtxNrmBufSize = NUM_VTX_NRM(sizeof(charModelRes->vtxNrmFaceline));
shapeRes.vtxTxcBufSize = NUM_VTX_TXC(sizeof(charModelRes->vtxTxcFaceline));
shapeRes.dlBufSize = sizeof(charModelRes->dlFaceline);
shapeRes.noseTrans = &noseTrans;
shapeRes.beardTrans = &beardTrans;
shapeRes.hairTrans = &hairTrans;
shapeRes.flipX = FALSE;
shapeRes.transform = FALSE;
RFLiInitShapeRes(&shapeRes);
charModelRes->dlSizeFaceline = arg.dlSize;
charModelRes->dlSizeFaceline = shapeRes.dlSize;
}
// Init cap shape
{
RFLiCharShapeRes arg;
RFLiCharShapeRes shapeRes;
arg.parts = RFLiPartsShp_Cap;
arg.index = info->hair.type;
arg.vtxPosBuf = charModelRes->vtxPosCap;
arg.vtxNrmBuf = charModelRes->vtxNrmCap;
arg.vtxTxcBuf = charModelRes->vtxTxcCap;
arg.dlBuf = charModelRes->dlCap;
arg.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosCap));
arg.vtxNrmBufSize = NUM_VTX_NRM(sizeof(charModelRes->vtxNrmCap));
arg.vtxTxcBufSize = NUM_VTX_TXC(sizeof(charModelRes->vtxTxcCap));
arg.dlBufSize = sizeof(charModelRes->dlCap);
arg.flipX = info->hair.flip;
arg.transform = TRUE;
arg.posScale = 1.0f;
arg.posTrans = &hairTrans;
RFLiInitShapeRes(&arg);
shapeRes.parts = RFLiPartsShp_Cap;
shapeRes.index = info->hair.type;
shapeRes.vtxPosBuf = charModelRes->vtxPosCap;
shapeRes.vtxNrmBuf = charModelRes->vtxNrmCap;
shapeRes.vtxTxcBuf = charModelRes->vtxTxcCap;
shapeRes.dlBuf = charModelRes->dlCap;
shapeRes.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosCap));
shapeRes.vtxNrmBufSize = NUM_VTX_NRM(sizeof(charModelRes->vtxNrmCap));
shapeRes.vtxTxcBufSize = NUM_VTX_TXC(sizeof(charModelRes->vtxTxcCap));
shapeRes.dlBufSize = sizeof(charModelRes->dlCap);
shapeRes.flipX = info->hair.flip;
shapeRes.transform = TRUE;
shapeRes.posScale = 1.0f;
shapeRes.posTrans = &hairTrans;
RFLiInitShapeRes(&shapeRes);
charModelRes->dlSizeCap = arg.dlSize;
charModelRes->vtxPosHair = &charModelRes->vtxPosCap[arg.vtxPosSize * VTX_COORDS_IN_POS];
charModelRes->vtxNrmHair = &charModelRes->vtxNrmCap[arg.vtxNrmSize * VTX_COORDS_IN_NRM];
charModelRes->dlHair = charModelRes->dlNose + OSRoundUp32B(arg.dlSize) + offsetof(RFLiCharModelRes, dlCap);
charModelRes->dlSizeCap = shapeRes.dlSize;
charModelRes->vtxPosHair = &charModelRes->vtxPosCap[shapeRes.vtxPosSize * VTX_COORDS_IN_POS];
charModelRes->vtxNrmHair = &charModelRes->vtxNrmCap[shapeRes.vtxNrmSize * VTX_COORDS_IN_NRM];
charModelRes->dlHair = charModelRes->dlNose + OSRoundUp32B(shapeRes.dlSize) + offsetof(RFLiCharModelRes, dlCap);
}
// Init hair shape
{
RFLiCharShapeRes arg;
RFLiCharShapeRes shapeRes;
arg.parts = RFLiPartsShp_Hair;
arg.index = info->hair.type;
arg.vtxPosBuf = charModelRes->vtxPosHair;
arg.vtxNrmBuf = charModelRes->vtxNrmHair;
arg.dlBuf = charModelRes->dlHair;
arg.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosCap)) -
shapeRes.parts = RFLiPartsShp_Hair;
shapeRes.index = info->hair.type;
shapeRes.vtxPosBuf = charModelRes->vtxPosHair;
shapeRes.vtxNrmBuf = charModelRes->vtxNrmHair;
shapeRes.dlBuf = charModelRes->dlHair;
shapeRes.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosCap)) -
(((u32)charModelRes->vtxPosHair - (u32)charModelRes->vtxPosCap) / VTX_COORD_SIZE) / VTX_COORDS_IN_POS;
arg.vtxNrmBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxNrmCap)) -
shapeRes.vtxNrmBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxNrmCap)) -
(((u32)charModelRes->vtxNrmHair - (u32)charModelRes->vtxNrmCap) / VTX_COORD_SIZE) / VTX_COORDS_IN_NRM;
arg.dlBufSize = sizeof(charModelRes->dlCap) - ((u32)charModelRes->dlHair - (u32)charModelRes->dlCap);
arg.flipX = info->hair.flip;
arg.transform = TRUE;
arg.posScale = 1.0f;
arg.posTrans = &hairTrans;
RFLiInitShapeRes(&arg);
shapeRes.dlBufSize = sizeof(charModelRes->dlCap) - ((u32)charModelRes->dlHair - (u32)charModelRes->dlCap);
shapeRes.flipX = info->hair.flip;
shapeRes.transform = TRUE;
shapeRes.posScale = 1.0f;
shapeRes.posTrans = &hairTrans;
RFLiInitShapeRes(&shapeRes);
charModelRes->dlSizeHair = arg.dlSize;
charModelRes->vtxPosForehead = &charModelRes->vtxPosHair[arg.vtxPosSize * VTX_COORDS_IN_POS];
charModelRes->vtxNrmForehead = &charModelRes->vtxNrmHair[arg.vtxNrmSize * VTX_COORDS_IN_NRM];
charModelRes->dlForehead = charModelRes->dlHair + OSRoundUp32B(arg.dlSize);
charModelRes->dlSizeHair = shapeRes.dlSize;
charModelRes->vtxPosForehead = &charModelRes->vtxPosHair[shapeRes.vtxPosSize * VTX_COORDS_IN_POS];
charModelRes->vtxNrmForehead = &charModelRes->vtxNrmHair[shapeRes.vtxNrmSize * VTX_COORDS_IN_NRM];
charModelRes->dlForehead = charModelRes->dlHair + OSRoundUp32B(shapeRes.dlSize);
charModelRes->flipHair = info->hair.flip;
}
// Init forehead shape
{
RFLiCharShapeRes arg;
RFLiCharShapeRes shapeRes;
arg.parts = RFLiPartsShp_Forehead;
arg.index = info->hair.type;
arg.vtxPosBuf = charModelRes->vtxPosForehead;
arg.vtxNrmBuf = charModelRes->vtxNrmForehead;
arg.dlBuf = charModelRes->dlForehead;
arg.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosCap)) -
shapeRes.parts = RFLiPartsShp_Forehead;
shapeRes.index = info->hair.type;
shapeRes.vtxPosBuf = charModelRes->vtxPosForehead;
shapeRes.vtxNrmBuf = charModelRes->vtxNrmForehead;
shapeRes.dlBuf = charModelRes->dlForehead;
shapeRes.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosCap)) -
(((u32)charModelRes->vtxPosForehead - (u32)charModelRes->vtxPosCap) / VTX_COORD_SIZE) / VTX_COORDS_IN_POS;
arg.vtxNrmBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxNrmCap)) -
shapeRes.vtxNrmBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxNrmCap)) -
(((u32)charModelRes->vtxNrmForehead - (u32)charModelRes->vtxNrmCap) / VTX_COORD_SIZE) / VTX_COORDS_IN_NRM;
arg.dlBufSize = sizeof(charModelRes->dlCap) - ((u32)charModelRes->dlForehead - (u32)charModelRes->dlCap);
arg.flipX = info->hair.flip;
arg.transform = TRUE;
arg.posScale = 1.0f;
arg.posTrans = &hairTrans;
RFLiInitShapeRes(&arg);
shapeRes.dlBufSize = sizeof(charModelRes->dlCap) - ((u32)charModelRes->dlForehead - (u32)charModelRes->dlCap);
shapeRes.flipX = info->hair.flip;
shapeRes.transform = TRUE;
shapeRes.posScale = 1.0f;
shapeRes.posTrans = &hairTrans;
RFLiInitShapeRes(&shapeRes);
charModelRes->dlSizeForehead = arg.dlSize;
charModelRes->dlSizeForehead = shapeRes.dlSize;
}
// Init beard shape
{
RFLiCharShapeRes arg;
RFLiCharShapeRes shapeRes;
arg.parts = RFLiPartsShp_Beard;
arg.index = info->beard.type;
arg.vtxPosBuf = charModelRes->vtxPosBeard;
arg.vtxNrmBuf = charModelRes->vtxNrmBeard;
arg.dlBuf = charModelRes->dlBeard;
arg.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosBeard));
arg.vtxNrmBufSize = NUM_VTX_NRM(sizeof(charModelRes->vtxNrmBeard));
arg.dlBufSize = sizeof(charModelRes->dlBeard);
arg.flipX = FALSE;
arg.transform = TRUE;
arg.posScale = 1.0f;
arg.posTrans = &beardTrans;
RFLiInitShapeRes(&arg);
shapeRes.parts = RFLiPartsShp_Beard;
shapeRes.index = info->beard.type;
shapeRes.vtxPosBuf = charModelRes->vtxPosBeard;
shapeRes.vtxNrmBuf = charModelRes->vtxNrmBeard;
shapeRes.dlBuf = charModelRes->dlBeard;
shapeRes.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosBeard));
shapeRes.vtxNrmBufSize = NUM_VTX_NRM(sizeof(charModelRes->vtxNrmBeard));
shapeRes.dlBufSize = sizeof(charModelRes->dlBeard);
shapeRes.flipX = FALSE;
shapeRes.transform = TRUE;
shapeRes.posScale = 1.0f;
shapeRes.posTrans = &beardTrans;
RFLiInitShapeRes(&shapeRes);
charModelRes->dlSizeBeard = arg.dlSize;
charModelRes->dlSizeBeard = shapeRes.dlSize;
}
// Init nose shape
@@ -731,7 +731,7 @@ void RFLiInitCharModelRes(RFLiCharModelRes* charModelRes, const RFLiCharInfo* in
f32 scale;
RFLiPositionData trans;
{
RFLiCharShapeRes arg;
RFLiCharShapeRes shapeRes;
scale = 0.4f + 0.175f * info->nose.scale;
@@ -739,69 +739,69 @@ void RFLiInitCharModelRes(RFLiCharModelRes* charModelRes, const RFLiCharInfo* in
trans.y = +noseTrans.y + -1.5f * (info->nose.y - 8);
trans.z = noseTrans.z;
arg.parts = RFLiPartsShp_Nose;
arg.index = info->nose.type;
arg.vtxPosBuf = charModelRes->vtxPosNose;
arg.vtxNrmBuf = charModelRes->vtxNrmNose;
arg.dlBuf = charModelRes->dlNose;
arg.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosNose));
arg.vtxNrmBufSize = NUM_VTX_NRM(sizeof(charModelRes->vtxNrmNose));
arg.dlBufSize = sizeof(charModelRes->dlNose);
arg.flipX = FALSE;
arg.transform = TRUE;
arg.posScale = scale;
arg.posTrans = &trans;
RFLiInitShapeRes(&arg);
shapeRes.parts = RFLiPartsShp_Nose;
shapeRes.index = info->nose.type;
shapeRes.vtxPosBuf = charModelRes->vtxPosNose;
shapeRes.vtxNrmBuf = charModelRes->vtxNrmNose;
shapeRes.dlBuf = charModelRes->dlNose;
shapeRes.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosNose));
shapeRes.vtxNrmBufSize = NUM_VTX_NRM(sizeof(charModelRes->vtxNrmNose));
shapeRes.dlBufSize = sizeof(charModelRes->dlNose);
shapeRes.flipX = FALSE;
shapeRes.transform = TRUE;
shapeRes.posScale = scale;
shapeRes.posTrans = &trans;
RFLiInitShapeRes(&shapeRes);
charModelRes->dlSizeNose = arg.dlSize;
charModelRes->dlSizeNose = shapeRes.dlSize;
}
{
RFLiCharShapeRes arg;
RFLiCharShapeRes shapeRes;
arg.parts = RFLiPartsShp_Noseline;
arg.index = info->nose.type;
arg.vtxPosBuf = charModelRes->vtxPosNoseline;
arg.vtxNrmBuf = charModelRes->vtxNrmNoseline;
arg.vtxTxcBuf = charModelRes->vtxTxcNoseline;
arg.dlBuf = charModelRes->dlNoseline;
arg.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosNoseline));
arg.vtxNrmBufSize = NUM_VTX_NRM(sizeof(charModelRes->vtxNrmNoseline));
arg.vtxTxcBufSize = NUM_VTX_TXC(sizeof(charModelRes->vtxTxcNoseline));
arg.dlBufSize = sizeof(charModelRes->dlNoseline);
arg.flipX = FALSE;
arg.transform = TRUE;
arg.posScale = scale;
arg.posTrans = &trans;
RFLiInitShapeRes(&arg);
shapeRes.parts = RFLiPartsShp_Noseline;
shapeRes.index = info->nose.type;
shapeRes.vtxPosBuf = charModelRes->vtxPosNoseline;
shapeRes.vtxNrmBuf = charModelRes->vtxNrmNoseline;
shapeRes.vtxTxcBuf = charModelRes->vtxTxcNoseline;
shapeRes.dlBuf = charModelRes->dlNoseline;
shapeRes.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosNoseline));
shapeRes.vtxNrmBufSize = NUM_VTX_NRM(sizeof(charModelRes->vtxNrmNoseline));
shapeRes.vtxTxcBufSize = NUM_VTX_TXC(sizeof(charModelRes->vtxTxcNoseline));
shapeRes.dlBufSize = sizeof(charModelRes->dlNoseline);
shapeRes.flipX = FALSE;
shapeRes.transform = TRUE;
shapeRes.posScale = scale;
shapeRes.posTrans = &trans;
RFLiInitShapeRes(&shapeRes);
charModelRes->dlSizeNoseline = arg.dlSize;
charModelRes->dlSizeNoseline = shapeRes.dlSize;
}
}
// Init mask shape
{
RFLiCharShapeRes arg;
RFLiCharShapeRes shapeRes;
arg.parts = RFLiPartsShp_Mask;
arg.index = info->faceline.type;
arg.vtxPosBuf = charModelRes->vtxPosMask;
arg.vtxNrmBuf = charModelRes->vtxNrmMask;
arg.vtxTxcBuf = charModelRes->vtxTxcMask;
arg.dlBuf = charModelRes->dlMask;
arg.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosMask));
arg.vtxNrmBufSize = NUM_VTX_NRM(sizeof(charModelRes->vtxNrmMask));
arg.vtxTxcBufSize = NUM_VTX_TXC(sizeof(charModelRes->vtxTxcMask));
arg.dlBufSize = sizeof(charModelRes->dlMask);
arg.flipX = FALSE;
arg.transform = FALSE;
RFLiInitShapeRes(&arg);
shapeRes.parts = RFLiPartsShp_Mask;
shapeRes.index = info->faceline.type;
shapeRes.vtxPosBuf = charModelRes->vtxPosMask;
shapeRes.vtxNrmBuf = charModelRes->vtxNrmMask;
shapeRes.vtxTxcBuf = charModelRes->vtxTxcMask;
shapeRes.dlBuf = charModelRes->dlMask;
shapeRes.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosMask));
shapeRes.vtxNrmBufSize = NUM_VTX_NRM(sizeof(charModelRes->vtxNrmMask));
shapeRes.vtxTxcBufSize = NUM_VTX_TXC(sizeof(charModelRes->vtxTxcMask));
shapeRes.dlBufSize = sizeof(charModelRes->dlMask);
shapeRes.flipX = FALSE;
shapeRes.transform = FALSE;
RFLiInitShapeRes(&shapeRes);
charModelRes->dlSizeMask = arg.dlSize;
charModelRes->dlSizeMask = shapeRes.dlSize;
}
// Init glass shape
{
RFLiCharShapeRes arg;
RFLiCharShapeRes shapeRes;
f32 scale;
RFLiPositionData trans;
@@ -811,23 +811,23 @@ void RFLiInitCharModelRes(RFLiCharModelRes* charModelRes, const RFLiCharInfo* in
trans.y = 5.0f + noseTrans.y + -1.5f * (info->glass.y - 11);
trans.z = 2.0f + noseTrans.z;
arg.parts = RFLiPartsShp_Glass;
arg.index = 0;
arg.vtxPosBuf = charModelRes->vtxPosGlass;
arg.vtxNrmBuf = charModelRes->vtxNrmGlass;
arg.vtxTxcBuf = charModelRes->vtxTxcGlass;
arg.dlBuf = charModelRes->dlGlass;
arg.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosGlass));
arg.vtxNrmBufSize = NUM_VTX_NRM(sizeof(charModelRes->vtxNrmGlass));
arg.vtxTxcBufSize = NUM_VTX_TXC(sizeof(charModelRes->vtxTxcGlass));
arg.dlBufSize = sizeof(charModelRes->dlGlass);
arg.flipX = FALSE;
arg.transform = TRUE;
arg.posScale = scale;
arg.posTrans = &trans;
RFLiInitShapeRes(&arg);
shapeRes.parts = RFLiPartsShp_Glass;
shapeRes.index = 0;
shapeRes.vtxPosBuf = charModelRes->vtxPosGlass;
shapeRes.vtxNrmBuf = charModelRes->vtxNrmGlass;
shapeRes.vtxTxcBuf = charModelRes->vtxTxcGlass;
shapeRes.dlBuf = charModelRes->dlGlass;
shapeRes.vtxPosBufSize = NUM_VTX_POS(sizeof(charModelRes->vtxPosGlass));
shapeRes.vtxNrmBufSize = NUM_VTX_NRM(sizeof(charModelRes->vtxNrmGlass));
shapeRes.vtxTxcBufSize = NUM_VTX_TXC(sizeof(charModelRes->vtxTxcGlass));
shapeRes.dlBufSize = sizeof(charModelRes->dlGlass);
shapeRes.flipX = FALSE;
shapeRes.transform = TRUE;
shapeRes.posScale = scale;
shapeRes.posTrans = &trans;
RFLiInitShapeRes(&shapeRes);
charModelRes->dlSizeGlass = arg.dlSize;
charModelRes->dlSizeGlass = shapeRes.dlSize;
}
// Init faceline texture
@@ -856,38 +856,38 @@ void RFLiInitCharModelRes(RFLiCharModelRes* charModelRes, const RFLiCharInfo* in
}
// DEBUG NON MATCH (https://decomp.me/scratch/mQdEd)
void RFLiInitShapeRes(RFLiCharShapeRes* arg /* r30 */) {
void RFLiInitShapeRes(RFLiCharShapeRes* shapeRes /* r30 */) {
void* res; // r31+0xE8
u8* ptr8; // r29
BOOL skipTxc; // r31+0xE4
static const u32 csHeader[RFLiPartsShp_Max] = {'nose', 'frhd', 'face', 'hair', 'cap_', 'berd', 'nsln', 'mask', 'glas'};
RFLi_ASSERTLINE_NULL(arg, 1261);
RFLi_ASSERTLINE_NULL(arg->vtxPosBuf, 1262);
RFLi_ASSERTLINE_NULL(arg->vtxNrmBuf, 1263);
RFLi_ASSERTLINE_NULL(arg->dlBuf, 1264);
RFLi_ASSERTLINE_ALIGN(arg->dlBuf, 32, 1265);
RFLi_ASSERTLINE_NULL(shapeRes, 1261);
RFLi_ASSERTLINE_NULL(shapeRes->vtxPosBuf, 1262);
RFLi_ASSERTLINE_NULL(shapeRes->vtxNrmBuf, 1263);
RFLi_ASSERTLINE_NULL(shapeRes->dlBuf, 1264);
RFLi_ASSERTLINE_ALIGN(shapeRes->dlBuf, 32, 1265);
skipTxc =
arg->parts == RFLiPartsShp_Nose || arg->parts == RFLiPartsShp_Forehead || arg->parts == RFLiPartsShp_Hair || arg->parts == RFLiPartsShp_Beard;
shapeRes->parts == RFLiPartsShp_Nose || shapeRes->parts == RFLiPartsShp_Forehead || shapeRes->parts == RFLiPartsShp_Hair || shapeRes->parts == RFLiPartsShp_Beard;
if (!skipTxc) {
RFLi_ASSERTLINE_NULL(arg->vtxTxcBuf, 1273);
RFLi_ASSERTLINE_NULL(shapeRes->vtxTxcBuf, 1273);
}
if (arg->transform) {
RFLi_ASSERTLINE_NULL(arg->posTrans, 1277);
if (shapeRes->transform) {
RFLi_ASSERTLINE_NULL(shapeRes->posTrans, 1277);
}
{
u32 fileSize = RFLiGetShapeSize(arg->parts, arg->index); // r31+0xE0
u32 fileSize = RFLiGetShapeSize(shapeRes->parts, shapeRes->index); // r31+0xE0
res = RFLiAlloc32(fileSize);
RFLi_ASSERTLINE_NULL(res, 1287);
}
{
void* result = RFLiLoadShape(arg->parts, arg->index, res); // r31+0xDC
void* result = RFLiLoadShape(shapeRes->parts, shapeRes->index, res); // r31+0xDC
RFLi_ASSERTLINE_MSG(result, 1290, "ファイルの読み込みに失敗しました。"); // "Failed to read file."
}
@@ -896,61 +896,61 @@ void RFLiInitShapeRes(RFLiCharShapeRes* arg /* r30 */) {
ptr8 = res;
header = *(u32*)ptr8; // r31+0xD8
RFLi_ASSERTLINE_MSG(header == csHeader[arg->parts], 1304, "ヘッダとpartsが一致しません"); // "Header and "parts" do not match"
RFLi_ASSERTLINE_MSG(header == csHeader[shapeRes->parts], 1304, "ヘッダとpartsが一致しません"); // "Header and "parts" do not match"
ptr8 += sizeof(header);
}
if (arg->parts == RFLiPartsShp_Faceline) {
RFLi_ASSERTLINE_NULL(arg->noseTrans, 1310);
RFLi_ASSERTLINE_NULL(arg->beardTrans, 1311);
if (shapeRes->parts == RFLiPartsShp_Faceline) {
RFLi_ASSERTLINE_NULL(shapeRes->noseTrans, 1310);
RFLi_ASSERTLINE_NULL(shapeRes->beardTrans, 1311);
// Missing assert for arg->hairTrans?
memcpy(arg->noseTrans, ptr8, sizeof(RFLiPositionData));
memcpy(shapeRes->noseTrans, ptr8, sizeof(RFLiPositionData));
ptr8 += sizeof(RFLiPositionData);
memcpy(arg->beardTrans, ptr8, sizeof(RFLiPositionData));
memcpy(shapeRes->beardTrans, ptr8, sizeof(RFLiPositionData));
ptr8 += sizeof(RFLiPositionData);
memcpy(arg->hairTrans, ptr8, sizeof(RFLiPositionData));
memcpy(shapeRes->hairTrans, ptr8, sizeof(RFLiPositionData));
ptr8 += sizeof(RFLiPositionData);
}
{
u16 size = *(u16*)ptr8; // r31+0xA
if (size == 0) {
arg->vtxPosSize = 0;
arg->vtxNrmSize = 0;
arg->vtxTxcSize = 0;
shapeRes->vtxPosSize = 0;
shapeRes->vtxNrmSize = 0;
shapeRes->vtxTxcSize = 0;
arg->dlSize = 0;
shapeRes->dlSize = 0;
RFLiFree(res);
return;
}
}
arg->vtxPosSize = *(u16*)ptr8;
RFLi_ASSERTLINE_MSG(arg->vtxPosSize <= arg->vtxPosBufSize, 1351, "vtxPosSize(%d) > vtxPosBufSize(%d) parts:%d index:%d", arg->vtxPosSize,
arg->vtxPosBufSize, arg->parts, arg->index);
ptr8 += sizeof(arg->vtxPosSize);
shapeRes->vtxPosSize = *(u16*)ptr8;
RFLi_ASSERTLINE_MSG(shapeRes->vtxPosSize <= shapeRes->vtxPosBufSize, 1351, "vtxPosSize(%d) > vtxPosBufSize(%d) parts:%d index:%d", shapeRes->vtxPosSize,
shapeRes->vtxPosBufSize, shapeRes->parts, shapeRes->index);
ptr8 += sizeof(shapeRes->vtxPosSize);
{
u32 byteSize; // r31+0xD4
s16* ptr16; // r31+0xD0
ptr16 = (s16*)ptr8;
byteSize = SIZE_VTX_POS(arg->vtxPosSize);
byteSize = SIZE_VTX_POS(shapeRes->vtxPosSize);
if (arg->transform) {
if (shapeRes->transform) {
int i; // r31+0xCC
s32 s = 256.0f * arg->posScale; // r31+0xC8
s32 tx = 256.0f * arg->posTrans->x; // r31+0xC4
s32 ty = 256.0f * arg->posTrans->y; // r31+0xC0
s32 tz = 256.0f * arg->posTrans->z; // r31+0xBC
s32 s = 256.0f * shapeRes->posScale; // r31+0xC8
s32 tx = 256.0f * shapeRes->posTrans->x; // r31+0xC4
s32 ty = 256.0f * shapeRes->posTrans->y; // r31+0xC0
s32 tz = 256.0f * shapeRes->posTrans->z; // r31+0xBC
for (i = 0; i < arg->vtxPosSize; i++) {
for (i = 0; i < shapeRes->vtxPosSize; i++) {
s16 temp[3]; // r31+0xFC
if (arg->flipX) {
if (shapeRes->flipX) {
temp[0] = tx + ((-ptr16[0] * s) >> 8);
} else {
temp[0] = tx + ((ptr16[0] * s) >> 8);
@@ -959,27 +959,27 @@ void RFLiInitShapeRes(RFLiCharShapeRes* arg /* r30 */) {
temp[1] = ty + ((ptr16[1] * s) >> 8);
temp[2] = tz + ((ptr16[2] * s) >> 8);
RFLiTransformCoordinate(&arg->vtxPosBuf[i * VTX_COORDS_IN_POS], temp);
RFLiTransformCoordinate(&shapeRes->vtxPosBuf[i * VTX_COORDS_IN_POS], temp);
ptr16 += VTX_COORDS_IN_POS;
}
} else if (arg->flipX) {
} else if (shapeRes->flipX) {
int i; // r31+0xB8
for (i = 0; i < arg->vtxPosSize; i++) {
for (i = 0; i < shapeRes->vtxPosSize; i++) {
s16 temp[3]; // r31+0xF4
temp[0] = -ptr16[0];
temp[1] = ptr16[1];
temp[2] = ptr16[2];
RFLiTransformCoordinate(&arg->vtxPosBuf[i * VTX_COORDS_IN_POS], temp);
RFLiTransformCoordinate(&shapeRes->vtxPosBuf[i * VTX_COORDS_IN_POS], temp);
ptr16 += VTX_COORDS_IN_POS;
}
} else {
int i; // r31+0xB4
for (i = 0; i < arg->vtxPosSize; i++) {
RFLiTransformCoordinate(&arg->vtxPosBuf[i * VTX_COORDS_IN_POS], ptr16);
for (i = 0; i < shapeRes->vtxPosSize; i++) {
RFLiTransformCoordinate(&shapeRes->vtxPosBuf[i * VTX_COORDS_IN_POS], ptr16);
ptr16 += VTX_COORDS_IN_POS;
}
}
@@ -987,9 +987,9 @@ void RFLiInitShapeRes(RFLiCharShapeRes* arg /* r30 */) {
ptr8 += byteSize;
}
arg->vtxNrmSize = *(u16*)ptr8;
RFLi_ASSERTLINE_MSG(arg->vtxNrmSize <= arg->vtxNrmBufSize, 1415, "vtxNrmSize(%d) > vtxNrmBufSize(%d) parts:%d index:%d", arg->vtxNrmSize,
arg->vtxNrmBufSize, arg->parts, arg->index);
shapeRes->vtxNrmSize = *(u16*)ptr8;
RFLi_ASSERTLINE_MSG(shapeRes->vtxNrmSize <= shapeRes->vtxNrmBufSize, 1415, "vtxNrmSize(%d) > vtxNrmBufSize(%d) parts:%d index:%d", shapeRes->vtxNrmSize,
shapeRes->vtxNrmBufSize, shapeRes->parts, shapeRes->index);
ptr8 += sizeof(u16);
{
@@ -997,25 +997,25 @@ void RFLiInitShapeRes(RFLiCharShapeRes* arg /* r30 */) {
s16* ptr16; // r31+0xAC
ptr16 = (s16*)ptr8;
byteSize = SIZE_VTX_NRM(arg->vtxNrmSize);
byteSize = SIZE_VTX_NRM(shapeRes->vtxNrmSize);
if (arg->flipX) {
if (shapeRes->flipX) {
int i; // r31+0xA8
for (i = 0; i < arg->vtxNrmSize; i++) {
for (i = 0; i < shapeRes->vtxNrmSize; i++) {
s16 temp[3]; // r31+0xEC
temp[0] = -ptr16[0];
temp[1] = ptr16[1];
temp[2] = ptr16[2];
RFLiTransformCoordinate(&arg->vtxNrmBuf[i * VTX_COORDS_IN_NRM], temp);
RFLiTransformCoordinate(&shapeRes->vtxNrmBuf[i * VTX_COORDS_IN_NRM], temp);
ptr16 += VTX_COORDS_IN_NRM;
}
} else {
int i; // r31+0xA4
for (i = 0; i < arg->vtxNrmSize; i++) {
RFLiTransformCoordinate(&arg->vtxNrmBuf[i * VTX_COORDS_IN_NRM], ptr16);
for (i = 0; i < shapeRes->vtxNrmSize; i++) {
RFLiTransformCoordinate(&shapeRes->vtxNrmBuf[i * VTX_COORDS_IN_NRM], ptr16);
ptr16 += VTX_COORDS_IN_NRM;
}
}
@@ -1027,15 +1027,15 @@ void RFLiInitShapeRes(RFLiCharShapeRes* arg /* r30 */) {
u32 byteSize; // r31+0xA0
if (skipTxc) {
arg->vtxTxcSize = 0;
shapeRes->vtxTxcSize = 0;
} else {
arg->vtxTxcSize = *(u16*)ptr8;
RFLi_ASSERTLINE_MSG(arg->vtxTxcSize <= arg->vtxTxcBufSize, 1460, "vtxTxcSize(%d) > vtxTxcBufSize(%d) parts:%d index:%d", arg->vtxTxcSize,
arg->vtxTxcBufSize, arg->parts, arg->index);
shapeRes->vtxTxcSize = *(u16*)ptr8;
RFLi_ASSERTLINE_MSG(shapeRes->vtxTxcSize <= shapeRes->vtxTxcBufSize, 1460, "vtxTxcSize(%d) > vtxTxcBufSize(%d) parts:%d index:%d", shapeRes->vtxTxcSize,
shapeRes->vtxTxcBufSize, shapeRes->parts, shapeRes->index);
ptr8 += sizeof(u16);
byteSize = SIZE_VTX_TXC(arg->vtxTxcSize);
memcpy(arg->vtxTxcBuf, ptr8, byteSize);
byteSize = SIZE_VTX_TXC(shapeRes->vtxTxcSize);
memcpy(shapeRes->vtxTxcBuf, ptr8, byteSize);
ptr8 += byteSize;
}
}
@@ -1044,8 +1044,8 @@ void RFLiInitShapeRes(RFLiCharShapeRes* arg /* r30 */) {
int primitiveNum = *ptr8++; // r31+0x9C
int i, j; // r31+0x94
DCInvalidateRange(arg->dlBuf, arg->dlBufSize);
GXBeginDisplayList(arg->dlBuf, arg->dlBufSize);
DCInvalidateRange(shapeRes->dlBuf, shapeRes->dlBufSize);
GXBeginDisplayList(shapeRes->dlBuf, shapeRes->dlBufSize);
for (i = 0; i < primitiveNum; i++) {
u16 vtxNum = *ptr8++; // r31+0x8
@@ -1065,7 +1065,7 @@ void RFLiInitShapeRes(RFLiCharShapeRes* arg /* r30 */) {
GXEnd();
}
arg->dlSize = GXEndDisplayList();
shapeRes->dlSize = GXEndDisplayList();
}
RFLiFree(res);

View File

@@ -408,7 +408,7 @@ RFLErrcode RFLiOpenAsync(RFLiFileType type, u8 openmode, RFLSimpleCB cb) {
strncpy(info->openinfo.filename, filename, NAND_MAX_PATH);
info->openinfo.filename[NAND_MAX_PATH] = 0;
info->openinfo.openmode = (u8)openmode;
info->openinfo.openmode = openmode;
info->openinfo.permission = scFilePermissions[type];
info->openinfo.attribute = scFileAttributes[type];
@@ -626,8 +626,8 @@ RFLErrcode RFLiReadAsync(RFLiFileType type, void* dst, u32 size, RFLSimpleCB cb,
static void writecallback_(s32 result, NANDCommandBlock* block);
static void retryWrite_(u32 arg) {
RFLiFileType type = (RFLiFileType)arg;
static void retryWrite_(u32 fileType) {
RFLiFileType type = (RFLiFileType)fileType;
RFLiNANDAccessInfo* info = RFLiGetAccInfo(type);
{
@@ -734,8 +734,8 @@ static s32 writestart_(RFLiFileType type) {
static void writeseekcallback_(s32 result, NANDCommandBlock* block);
static void retryWriteSeek_(u32 arg) {
RFLiFileType type = (RFLiFileType)arg;
static void retryWriteSeek_(u32 fileType) {
RFLiFileType type = (RFLiFileType)fileType;
RFLiNANDAccessInfo* info = RFLiGetAccInfo(type);
{

View File

@@ -349,7 +349,7 @@ RFLErrcode makeNWC24MsgforExchange_(NWC24MsgObj* obj, RFLCharData* sendTarget, B
RFLi_ASSERTLINE(aidx <= count, 407);
for (i = 0; i < aidx - 1; i++) {
u16 tmp;
u16 shuffledIndex;
u16 target;
target = (((rand >> 0x10) + rand) & 0xFFFF) % (aidx - 1);
@@ -357,9 +357,9 @@ RFLErrcode makeNWC24MsgforExchange_(NWC24MsgObj* obj, RFLCharData* sendTarget, B
target++;
}
tmp = array[target];
shuffledIndex = array[target];
array[target] = array[i];
array[i] = tmp;
array[i] = shuffledIndex;
rand = (rand + 0x02ED47B1) * 0x032ED8B7;
}
@@ -447,14 +447,14 @@ RFLErrcode makeNWC24MsgforExchange_(NWC24MsgObj* obj, RFLCharData* sendTarget, B
int k;
for (k = 0; k < friendsNum; k++) {
NWC24FriendInfo* tmp;
NWC24FriendInfo* shuffledFriend;
u32 l;
rand = (rand + 0x02ED47B1) * 0x032ED8B7;
l = rand % friendsNum;
tmp = lists[k];
shuffledFriend = lists[k];
lists[k] = lists[l];
lists[l] = tmp;
lists[l] = shuffledFriend;
}
for (i = 0; i < (int)GET_ARRAY_LENGTH(receiver); i++) {

View File

@@ -86,7 +86,7 @@ RFLErrcode RFLInitResAsync(void* workBuffer, void* resBuffer, u32 resSize, BOOL
} else {
size = (RFLi_WORK_SIZE - sizeof(RFLiSysManager));
}
RFLiGetManager()->mRootHeap = MEMCreateExpHeapEx(RFLiGetManager()->mWorkBuffer, size, 1);
RFLiGetManager()->mRootHeap = MEMCreateExpHeapEx(RFLiGetManager()->mWorkBuffer, size, MEM_HEAP_OPT_CLEAR_ALLOC);
RFLi_REPORT(" rootHeap : 0x%08x - 0x%08x (%6dByte)\n", (u8*)RFLiGetManager()->mWorkBuffer,
(size + (u32)RFLiGetManager()->mWorkBuffer), size);
}

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

@@ -5,6 +5,32 @@
#include <tmc_jpeg.h>
enum TMCCJPEGOutputFormat {
TMCC_JPEG_OUTPUT_RGB565 = 0,
TMCC_JPEG_OUTPUT_RGBA8 = 1,
TMCC_JPEG_OUTPUT_Y8U8V8 = 2
};
enum TMCJpegMarker {
TMC_JPEG_MARKER_SOF0 = 0xFFC0,
TMC_JPEG_MARKER_SOF2 = 0xFFC2,
TMC_JPEG_MARKER_DHT = 0xFFC4,
TMC_JPEG_MARKER_RST0 = 0xFFD0,
TMC_JPEG_MARKER_RST7 = 0xFFD7,
TMC_JPEG_MARKER_SOI = 0xFFD8,
TMC_JPEG_MARKER_EOI = 0xFFD9,
TMC_JPEG_MARKER_SOS = 0xFFDA,
TMC_JPEG_MARKER_DQT = 0xFFDB,
TMC_JPEG_MARKER_DNL = 0xFFDC,
TMC_JPEG_MARKER_DRI = 0xFFDD,
TMC_JPEG_MARKER_APP0 = 0xFFE0,
TMC_JPEG_MARKER_APP1 = 0xFFE1,
TMC_JPEG_MARKER_APP15 = 0xFFEF,
TMC_JPEG_MARKER_COM = 0xFFFE,
TMC_JPEG_MARKER_PREFIX = 0xFF00,
TMC_JPEG_MARKER_FILL = 0xFFFF,
};
typedef s32(TMCDecodeFunc)(s32* block, u8* conv_row_ptr, u32* dcPredictRowPtr, TMCCJPEGDecWork* work);
typedef void(TMCIdctFunc)(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag);
typedef void(TMCConverterFunc)(TMCCJPEGDecWork*, s32 x, s32 y);
@@ -13,44 +39,33 @@ 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
} TMCUnknownInfo;
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 {
u16 frameWidth; // 0x00
@@ -75,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
@@ -90,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
@@ -154,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
@@ -165,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
};
@@ -187,13 +175,13 @@ s32 TMCJPEGDEC_rewind_ptr(TMCCJPEGDecWork* work);
typedef struct {
u32* huffTable; // 0x00
u8* valptr; // 0x04
u32* valptr; // 0x04
u32* maxCode; // 0x08
u8 count; // 0x0C
} TMCHuffParam;
s32 TMCJPEGDEC_make_huffdec(const u8* dht_spec, u8* tbl, TMCHuffParam* hp);
void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCUnknownInfo* work);
void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCJpegTableInfo* work);
s32 TMCJPEGDEC_decompmcu(u32 maxMCU, u32 mcuCount, TMCCJPEGDecWork* work, void* buf);
s32 TMCJPEGDEC_imagestart(TMCCJPEGDecWork* work);
@@ -202,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);
@@ -226,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

@@ -17,7 +17,8 @@ s32 TMCCJPEGDecInit(TMCCJPEGDecState* state, TMCCJPEGDecInitParam* param) {
if (param->unk_0x24 != 0) {
result = -1;
} else if (param->unk_0x2C != 0 && param->unk_0x2C != 1 && param->unk_0x2C != 2) {
} else if (param->unk_0x2C != TMCC_JPEG_OUTPUT_RGB565 && param->unk_0x2C != TMCC_JPEG_OUTPUT_RGBA8 &&
param->unk_0x2C != TMCC_JPEG_OUTPUT_Y8U8V8) {
result = -1;
} else {
state->unk_0x21 = param->unk_0x24;
@@ -58,19 +59,19 @@ s32 TMCCJPEGDecInit(TMCCJPEGDecState* state, TMCCJPEGDecInitParam* param) {
result = TMCJPEGDEC_Setsize(work);
if (result >= 0) {
switch (state->converterType) {
case 0:
case TMCC_JPEG_OUTPUT_RGB565:
result = TMCJPEGDEC_set_converterRGB565(work);
if (result < 0) {
goto error;
}
break;
case 1:
case TMCC_JPEG_OUTPUT_RGBA8:
result = TMCJPEGDEC_set_converterRGBA8(work);
if (result < 0) {
goto error;
}
break;
case 2:
case TMCC_JPEG_OUTPUT_Y8U8V8:
result = TMCJPEGDEC_set_converterY8U8V8(work);
if (result < 0) {
goto error;
@@ -104,7 +105,7 @@ s32 TMCCJPEGDecodeRGB565(TMCCJPEGDecState* state, s32 initResult, void* texBuffe
return -1;
}
if (state->converterType != 0) {
if (state->converterType != TMCC_JPEG_OUTPUT_RGB565) {
return -4;
}
@@ -173,19 +174,19 @@ s32 TMCCJPEGDecSetResolution(TMCCJPEGDecState* state, u32 scale) {
}
switch (state->converterType) {
case 0:
case TMCC_JPEG_OUTPUT_RGB565:
result = TMCJPEGDEC_set_converterRGB565(work);
if (result < 0) {
return result;
}
break;
case 1:
case TMCC_JPEG_OUTPUT_RGBA8:
result = TMCJPEGDEC_set_converterRGBA8(work);
if (result < 0) {
return result;
}
break;
case 2:
case TMCC_JPEG_OUTPUT_Y8U8V8:
result = TMCJPEGDEC_set_converterY8U8V8(work);
if (result < 0) {
return result;

View File

@@ -52,7 +52,7 @@ static inline s32 decodeLongHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TM
limit->bitLength = entry[0];
limit->symbol = entry[1];
*decoded = *limit;
if (code > (u32)decoded->bitLength) {
if (code > decoded->bitLength) {
continue;
}
{
@@ -101,7 +101,7 @@ static inline s32 decodeACHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TMCC
limit->bitLength = entry[0];
limit->symbol = entry[1];
*decoded = *limit;
if (code > (u32)decoded->bitLength) {
if (code > decoded->bitLength) {
continue;
}
{
@@ -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;
@@ -173,7 +173,8 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
if (r != 0) {
if (work->bitCount <= r) {
s32 load_ret;
if (load_ret = TMCJPEGDEC_load_buff(work), load_ret < 0) {
load_ret = TMCJPEGDEC_load_buff(work);
if (load_ret < 0) {
return load_ret;
}
}
@@ -195,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);
@@ -278,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

@@ -1,3 +1,4 @@
#include <stddef.h>
#include <tmc_jpeg_internal.h>
static s32 refillJpegBufferAfterFF(TMCCJPEGDecWork* work);
@@ -9,23 +10,24 @@ s32 TMCJPEGDEC_init_ptr_buff(TMCCJPEGDecWork* work, void* param) {
u8* newEnd;
u8* bufOrg;
u32 newRemaining;
const TMCCJPEGDecInitParam* input = (const TMCCJPEGDecInitParam*)((u8*)param - offsetof(TMCCJPEGDecInitParam, pBuf2));
if (((u32*)param)[0] & 0x1F)
if ((u32)input->pBuf2 & (DEFAULT_ALIGN - 1))
return -1;
if (((u32*)param)[1] & 0x1F)
if (input->buf2Size & (DEFAULT_ALIGN - 1))
return -1;
if (((u32*)param)[2] == 0)
if (input->dataSize == 0)
return -1;
if (((u32*)param)[1] < 0x10040)
if (input->buf2Size < 0x10040)
return -1;
work->pBufOrg = (u8*)((u32*)param)[0];
work->pBufOrg = input->pBuf2;
dest = work->pBufOrg + 0x20;
work->bufLen = ((u32*)param)[1] - 0x20;
readSize = ((u32*)param)[2];
work->bufLen = input->buf2Size - 0x20;
readSize = input->dataSize;
work->remaining = readSize;
work->pCallback = (void*)((u32*)param)[3];
work->pCbCtx = (void*)((u32*)param)[4];
work->pCallback = input->pCallback;
work->pCbCtx = input->pContext;
if (work->bufLen - 0x20 < readSize) {
readSize = work->bufLen - 0x20;
}

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;
}
@@ -48,8 +48,11 @@ s32 TMCJPEGDEC_rewind_ptr(TMCCJPEGDecWork* work) {
return r;
}
if ((u8)bitBuf == 0xFF && (r = TMCJPEGDEC_move_ptr(-1, work), r < 0)) {
return r;
if ((u8)bitBuf == 0xFF) {
r = TMCJPEGDEC_move_ptr(-1, work);
if (r < 0) {
return r;
}
}
bitBuf >>= 8;

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

@@ -120,8 +120,8 @@ s32 TMCJPEGDEC_make_huffdec(const u8* dht, u8* tb, TMCHuffParam* hp) {
void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCUnknownInfo* info) {
TMCCJPEGDecWork* work = (TMCCJPEGDecWork*)info;
void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCJpegTableInfo* info) {
TMCJpegTableInfo* work = info;
void* hufftable;
void* maxcode;
void* valptr;
@@ -129,15 +129,15 @@ void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCU
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, TMCU
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, TMCU
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, TMCU
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

@@ -2,30 +2,68 @@
#include <tmc_jpeg.h>
#include <tmc_jpeg_internal.h>
enum TMCExifFormat {
TMC_EXIF_LITTLE_ENDIAN = 0x4949,
TMC_EXIF_BIG_ENDIAN = 0x4D4D,
TMC_EXIF_TIFF_MAGIC = 42,
TMC_EXIF_TYPE_SHORT = 3,
TMC_EXIF_TYPE_LONG = 4,
TMC_EXIF_COMPRESSION_JPEG = 6
};
enum TMCExifTag {
TMC_EXIF_TAG_COMPRESSION = 0x0103,
TMC_EXIF_TAG_STRIP_OFFSETS = 0x0111,
TMC_EXIF_TAG_ORIENTATION = 0x0112,
TMC_EXIF_TAG_X_RESOLUTION = 0x011A,
TMC_EXIF_TAG_Y_RESOLUTION = 0x011B,
TMC_EXIF_TAG_PLANAR_CONFIGURATION = 0x011C,
TMC_EXIF_TAG_RESOLUTION_UNIT = 0x0128,
TMC_EXIF_TAG_TRANSFER_FUNCTION = 0x012D,
TMC_EXIF_TAG_DATE_TIME = 0x0132,
TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT = 0x0201,
TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH = 0x0202,
TMC_EXIF_TAG_YCBCR_POSITIONING = 0x0213,
TMC_EXIF_TAG_EXIF_IFD = 0x8769,
TMC_EXIF_TAG_EXIF_VERSION = 0x9000,
TMC_EXIF_TAG_COMPONENTS_CONFIGURATION = 0x9101,
TMC_EXIF_TAG_FLASHPIX_VERSION = 0xA000,
TMC_EXIF_TAG_COLOR_SPACE = 0xA001,
TMC_EXIF_TAG_PIXEL_X_DIMENSION = 0xA002,
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) {
u32 raw = p[1] << 8 | p[0];
if (byteOrder == 0x4949) {
return (u16)raw;
if (byteOrder == TMC_EXIF_LITTLE_ENDIAN) {
return raw;
}
return (u16)(raw >> 8 & 0xFF | (raw & 0xFF) << 8);
return raw >> 8 & 0xFF | (raw & 0xFF) << 8;
}
static u16 readExifU16(const u8* data, u16 byteOrder) {
u16 value = data[0] | data[1] << 8;
if (byteOrder == 0x4949) {
if (byteOrder == TMC_EXIF_LITTLE_ENDIAN) {
return (u16)value;
}
return (u16)(value >> 8 & 255 | (value & 255) << 8);
return value >> 8 & 255 | (value & 255) << 8;
}
static u32 readU32(const u8* p, u16 byteOrder) {
u32 raw = p[1] << 8 | p[0] | p[2] << 16 | p[3] << 24;
if (byteOrder == 0x4949) {
if (byteOrder == TMC_EXIF_LITTLE_ENDIAN) {
return raw;
}
return (raw >> 24) | ((raw >> 8) & 0xFF00) | ((raw & 0xFF00) << 8) | ((raw & 0xFF) << 24);
@@ -46,7 +84,7 @@ s32 TMCCJPEGDecGetOffsetEXIF(u32* pOffset, u32* pSize, TMCCJPEGDecInitParam* pPa
return -1;
}
memset(work, 0, 0x19E8);
memset(work, 0, sizeof(TMCCJPEGDecWork));
result = TMCJPEGDEC_init_ptr_buff(work, &pParam->pBuf2);
if (result < 0) {
@@ -61,7 +99,7 @@ s32 TMCCJPEGDecGetOffsetEXIF(u32* pOffset, u32* pSize, TMCCJPEGDecInitParam* pPa
return result;
}
if (soi != 0xFFD8) {
if (soi != TMC_JPEG_MARKER_SOI) {
return -0x20;
}
}
@@ -72,7 +110,7 @@ s32 TMCCJPEGDecGetOffsetEXIF(u32* pOffset, u32* pSize, TMCCJPEGDecInitParam* pPa
return result;
}
if (marker == 0xFFE1) {
if (marker == TMC_JPEG_MARKER_APP1) {
result = TMCJPEGDEC_get_wbyte(&segSize, work);
if (result < 0) {
return result;
@@ -87,7 +125,7 @@ s32 TMCCJPEGDecGetOffsetEXIF(u32* pOffset, u32* pSize, TMCCJPEGDecInitParam* pPa
return result;
}
if (sig[0] == 0x45 && sig[1] == 0x78 && sig[2] == 0x69 && sig[3] == 0x66) {
if (sig[0] == 'E' && sig[1] == 'x' && sig[2] == 'i' && sig[3] == 'f') {
*pOffset = dataSize - work->remaining - TMCJPEGDEC_chk_possible_size(work) - 8;
*pSize = segSize + 2;
return 0;
@@ -107,7 +145,7 @@ s32 TMCCJPEGDecGetOffsetEXIF(u32* pOffset, u32* pSize, TMCCJPEGDecInitParam* pPa
segSize -= 2;
if (marker >= 0xFFE0 && marker <= 0xFFEF) {
if (marker >= TMC_JPEG_MARKER_APP0 && marker <= TMC_JPEG_MARKER_APP15) {
result = TMCJPEGDEC_move_ptr(segSize, work);
if (result < 0) {
return result;
@@ -116,21 +154,21 @@ s32 TMCCJPEGDecGetOffsetEXIF(u32* pOffset, u32* pSize, TMCCJPEGDecInitParam* pPa
}
switch (marker) {
case 0xFFC0:
case 0xFFC2:
case 0xFFC4:
case 0xFFDB:
case 0xFFDC:
case 0xFFDD:
case 0xFFFE:
case TMC_JPEG_MARKER_SOF0:
case TMC_JPEG_MARKER_SOF2:
case TMC_JPEG_MARKER_DHT:
case TMC_JPEG_MARKER_DQT:
case TMC_JPEG_MARKER_DNL:
case TMC_JPEG_MARKER_DRI:
case TMC_JPEG_MARKER_COM:
result = TMCJPEGDEC_move_ptr(segSize, work);
if (result < 0) {
return result;
}
break;
case 0xFFDA:
case TMC_JPEG_MARKER_SOS:
return -2;
case 0xFFD9:
case TMC_JPEG_MARKER_EOI:
return -2;
default:
return -0x2F;
@@ -150,18 +188,18 @@ s32 TMCCJPEGDecGetInfoEXIF(TMCCJPEGDecExifInfo* pInfo, TMCCJPEGDecInitParam* pPa
return -1;
}
memset(pInfo, 0, 0x6D4);
memset(work, 0, 0x19E8);
memset(pInfo, 0, sizeof(TMCCJPEGDecExifInfo));
memset(work, 0, sizeof(TMCCJPEGDecWork));
// TODO: this seems wrong. wrong parameter type?
work->pState = (TMCCJPEGDecState*)pInfo;
pInfo->pWorkBuf = work;
if (readU16(pParam->pBuf2, 0x4D4D) != 0xFFE1) {
if (readU16(pParam->pBuf2, TMC_EXIF_BIG_ENDIAN) != TMC_JPEG_MARKER_APP1) {
return -0x45;
}
segSize = readU16((const u8*)pParam->pBuf2 + 2, 0x4D4D);
segSize = readU16((const u8*)pParam->pBuf2 + 2, TMC_EXIF_BIG_ENDIAN);
if (segSize < 2) {
return -0x45;
}
@@ -186,7 +224,7 @@ s32 TMCCJPEGDecGetInfoEXIF(TMCCJPEGDecExifInfo* pInfo, TMCCJPEGDecInitParam* pPa
return -1;
}
result = TMCJPEGDEC_init_buff_thumbnail((TMCCJPEGDecWork*)&pInfo->exifData, (u8*)work, (u8*)pParam + 0x10);
result = TMCJPEGDEC_init_buff_thumbnail((TMCCJPEGDecWork*)&pInfo->exifData, (u8*)work, (u8*)&pParam->pBuf2);
if (result < 0) {
return result;
}
@@ -211,19 +249,19 @@ s32 TMCCJPEGDecGetInfoEXIF(TMCCJPEGDecExifInfo* pInfo, TMCCJPEGDecInitParam* pPa
}
switch (pInfo->converterType) {
case 0:
case TMCC_JPEG_OUTPUT_RGB565:
result = TMCJPEGDEC_set_converterRGB565(work);
if (result < 0) {
goto _error;
}
break;
case 1:
case TMCC_JPEG_OUTPUT_RGBA8:
result = TMCJPEGDEC_set_converterRGBA8(work);
if (result < 0) {
goto _error;
}
break;
case 2:
case TMCC_JPEG_OUTPUT_Y8U8V8:
result = TMCJPEGDEC_set_converterY8U8V8(work);
if (result < 0) {
goto _error;
@@ -262,10 +300,10 @@ static s32 TMCJPEGDEC_exif_parse(const u8* entries, u32 size, TMCCJPEGDecExifDat
return -161;
}
byteOrder = data[0] | data[1] << 8;
if (byteOrder != 0x4D4D && byteOrder != 0x4949) {
if (byteOrder != TMC_EXIF_BIG_ENDIAN && byteOrder != TMC_EXIF_LITTLE_ENDIAN) {
return -161;
}
if (readExifU16(data + 2, byteOrder) != 42) {
if (readExifU16(data + 2, byteOrder) != TMC_EXIF_TIFF_MAGIC) {
return -161;
}
ifdOffset = readU32(data + 4, byteOrder);
@@ -285,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) {
@@ -313,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;
@@ -334,77 +372,77 @@ 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 0x0103:
case 0x0111:
case 0x0201:
case 0x0202: {
case TMC_EXIF_TAG_COMPRESSION:
case TMC_EXIF_TAG_STRIP_OFFSETS:
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT:
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH: {
break;
}
case 0x0112: {
pInfo->orientation = readU16(entry + 8, byteOrder);
case TMC_EXIF_TAG_ORIENTATION: {
pInfo->orientation = readU16(entry->value, byteOrder);
return;
}
case 0x011A: {
u32 offset = readU32(entry + 8, byteOrder);
case TMC_EXIF_TAG_X_RESOLUTION: {
u32 offset = readU32(entry->value, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - 4) {
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
pInfo->xResNum = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + 4);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - 4) {
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
pInfo->xResDen = readU32(p, byteOrder);
return;
}
case 0x011B: {
u32 offset = readU32(entry + 8, byteOrder);
case TMC_EXIF_TAG_Y_RESOLUTION: {
u32 offset = readU32(entry->value, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - 4) {
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
pInfo->yResNum = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + 4);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - 4) {
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
pInfo->yResDen = readU32(p, byteOrder);
return;
}
case 0x0128: {
pInfo->resUnit = readU16(entry + 8, byteOrder);
case TMC_EXIF_TAG_RESOLUTION_UNIT: {
pInfo->resUnit = readU16(entry->value, byteOrder);
return;
}
case 0x012D: {
u32 offset = readU32(entry + 8, byteOrder);
case TMC_EXIF_TAG_TRANSFER_FUNCTION: {
u32 offset = readU32(entry->value, byteOrder);
u32 channel;
u32 index;
for (channel = 0; channel < 3; channel++) {
@@ -413,162 +451,162 @@ 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 0x0132: {
u32 offset = readU32(entry + 8, byteOrder);
case TMC_EXIF_TAG_DATE_TIME: {
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 0x0213: {
pInfo->yCbCrPos = readU16(entry + 8, byteOrder);
case TMC_EXIF_TAG_YCBCR_POSITIONING: {
pInfo->yCbCrPos = readU16(entry->value, byteOrder);
return;
}
case 0x8769: {
pInfo->nextIfdOffset = readU32(entry + 8, byteOrder);
case TMC_EXIF_TAG_EXIF_IFD: {
pInfo->nextIfdOffset = readU32(entry->value, byteOrder);
return;
}
case 0x9000: {
pInfo->exifVer[0] = entry[8];
pInfo->exifVer[1] = entry[9];
pInfo->exifVer[2] = entry[10];
pInfo->exifVer[3] = entry[11];
case TMC_EXIF_TAG_EXIF_VERSION: {
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 0x9101: {
pInfo->flashVer[0] = entry[8];
pInfo->flashVer[1] = entry[9];
pInfo->flashVer[2] = entry[10];
pInfo->flashVer[3] = entry[11];
case TMC_EXIF_TAG_COMPONENTS_CONFIGURATION: {
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 0xA000: {
pInfo->flashPixVer[0] = entry[8];
pInfo->flashPixVer[1] = entry[9];
pInfo->flashPixVer[2] = entry[10];
pInfo->flashPixVer[3] = entry[11];
case TMC_EXIF_TAG_FLASHPIX_VERSION: {
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 0xA001: {
pInfo->colorSpace = readU16(entry + 8, byteOrder);
case TMC_EXIF_TAG_COLOR_SPACE: {
pInfo->colorSpace = readU16(entry->value, byteOrder);
return;
}
case 0xA002: {
if (type == 3) {
pInfo->pixelXDim = readU16(entry + 8, byteOrder);
} else if (type == 4) {
pInfo->pixelXDim = readU32(entry + 8, byteOrder);
case TMC_EXIF_TAG_PIXEL_X_DIMENSION: {
if (type == TMC_EXIF_TYPE_SHORT) {
pInfo->pixelXDim = readU16(entry->value, byteOrder);
} else if (type == TMC_EXIF_TYPE_LONG) {
pInfo->pixelXDim = readU32(entry->value, byteOrder);
}
return;
}
case 0xA003: {
if (type == 3) {
pInfo->pixelYDim = readU16(entry + 8, byteOrder);
} else if (type == 4) {
pInfo->pixelYDim = readU32(entry + 8, byteOrder);
case TMC_EXIF_TAG_PIXEL_Y_DIMENSION: {
if (type == TMC_EXIF_TYPE_SHORT) {
pInfo->pixelYDim = readU16(entry->value, byteOrder);
} else if (type == TMC_EXIF_TYPE_LONG) {
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 0x0132:
case 0x0111:
case 0x0112:
case 0x012D:
case 0x0213:
case 0x8769:
case 0x9000:
case 0x9101:
case 0x011C:
case 0xA000:
case 0xA001:
case 0xA002:
case 0xA003: {
case TMC_EXIF_TAG_DATE_TIME:
case TMC_EXIF_TAG_STRIP_OFFSETS:
case TMC_EXIF_TAG_ORIENTATION:
case TMC_EXIF_TAG_TRANSFER_FUNCTION:
case TMC_EXIF_TAG_YCBCR_POSITIONING:
case TMC_EXIF_TAG_EXIF_IFD:
case TMC_EXIF_TAG_EXIF_VERSION:
case TMC_EXIF_TAG_COMPONENTS_CONFIGURATION:
case TMC_EXIF_TAG_PLANAR_CONFIGURATION:
case TMC_EXIF_TAG_FLASHPIX_VERSION:
case TMC_EXIF_TAG_COLOR_SPACE:
case TMC_EXIF_TAG_PIXEL_X_DIMENSION:
case TMC_EXIF_TAG_PIXEL_Y_DIMENSION: {
break;
}
case 0x011A: {
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;
}
if (p > pInfo->dataEnd - 4) {
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
pInfo->xResNumIfd1 = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + 4);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - 4) {
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
pInfo->xResDenIfd1 = readU32(p, byteOrder);
return;
}
case 0x011B: {
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;
}
if (p > pInfo->dataEnd - 4) {
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
pInfo->planarConfigIfd1 = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + 4);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - 4) {
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
pInfo->yResDenIfd1 = readU32(p, byteOrder);
return;
}
case 0x0128: {
pInfo->resUnitIfd1 = readU16(entry + 8, byteOrder);
case TMC_EXIF_TAG_RESOLUTION_UNIT: {
pInfo->resUnitIfd1 = readU16(entry->value, byteOrder);
return;
}
case 0x0103: {
pInfo->compressionIfd1 = readU16(entry + 8, byteOrder);
case TMC_EXIF_TAG_COMPRESSION: {
pInfo->compressionIfd1 = readU16(entry->value, byteOrder);
return;
}
case 0x0201: {
pInfo->thumbnailOffset = readU32(entry + 8, byteOrder);
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT: {
pInfo->thumbnailOffset = readU32(entry->value, byteOrder);
return;
}
case 0x0202: {
pInfo->thumbnailLength = readU32(entry + 8, byteOrder);
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH: {
pInfo->thumbnailLength = readU32(entry->value, byteOrder);
return;
}
}
@@ -589,7 +627,7 @@ static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExi
return -0xA0;
}
if (info->exifData.compressionIfd1 != 6) {
if (info->exifData.compressionIfd1 != TMC_EXIF_COMPRESSION_JPEG) {
return -0xA0;
}
@@ -612,7 +650,8 @@ static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExi
info->thumbFlag = 0;
if (param->unk_0x2C != 0 && param->unk_0x2C != 1 && param->unk_0x2C != 2) {
if (param->unk_0x2C != TMCC_JPEG_OUTPUT_RGB565 && param->unk_0x2C != TMCC_JPEG_OUTPUT_RGBA8 &&
param->unk_0x2C != TMCC_JPEG_OUTPUT_Y8U8V8) {
return -1;
}

View File

@@ -2,7 +2,13 @@
s32 TMCJPEGDEC_Decompscan(TMCCJPEGDecWork* work) {
s32 r = TMCJPEGDEC_scanstart(work);
return r < 0 ? r : (work->scanCount == 1) ? 0 : r;
if (r < 0) {
return r;
}
if (work->scanCount == 1) {
return 0;
}
return r;
}
s32 TMCJPEGDEC_Setsize(TMCCJPEGDecWork* work) {

File diff suppressed because it is too large Load Diff

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) {
@@ -76,7 +76,7 @@ void TMCJPEGDEC_IdctBlock4x4(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag
bp[0] = clampU8((evsum + oddrot) >> 11);
bp[pitch] = clampU8((cd + rot) >> 11);
bp[pitch * 2] = clampU8((cd - rot) >> 11);
bp[pitch * 4 - pitch] = clampU8((evsum - oddrot) >> 11);
bp[pitch * 3] = clampU8((evsum - oddrot) >> 11);
idx -= 1;
}
@@ -99,10 +99,10 @@ void TMCJPEGDEC_IdctBlock2x2(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag
even_diff = a0b - a1;
odd_sum = b0 + b1;
rot = b0 - b1;
bp[0] = (u8)clampU8((even_sum + odd_sum) >> 11);
bp[pitch] = (u8)clampU8((even_sum - odd_sum) >> 11);
bp[1] = (u8)clampU8((even_diff + rot) >> 11);
(bp + pitch)[1] = (u8)clampU8((even_diff - rot) >> 11);
bp[0] = clampU8((even_sum + odd_sum) >> 11);
bp[pitch] = clampU8((even_sum - odd_sum) >> 11);
bp[1] = clampU8((even_diff + rot) >> 11);
(bp + pitch)[1] = clampU8((even_diff - rot) >> 11);
}
void TMCJPEGDEC_IdctBlock1x1(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {

View File

@@ -38,9 +38,10 @@ 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) {
if (r = TMCJPEGDEC_load_buff(work), r < 0) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
}
@@ -53,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;
}
@@ -61,7 +62,8 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
if (val != 0) {
if (work->bitCount <= val) {
if (r = TMCJPEGDEC_load_buff(work), r < 0) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
}
@@ -71,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;
@@ -82,7 +84,8 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
idx = 1;
do {
if (work->bitCount <= 8) {
if (r = TMCJPEGDEC_load_buff(work), r < 0) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
}
@@ -92,10 +95,11 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
val = *ac_entry;
if (val != 0) {
tmp = val;
val = *(ac_entry + 1);
val = ac_entry[1];
work->bitCount -= tmp;
} else {
if (val = TMCJPEGDEC_vl_decode_rc(ac_vl, ac_sym, work), val < 0) {
val = TMCJPEGDEC_vl_decode_rc(ac_vl, ac_sym, work);
if (val < 0) {
return val;
}
}
@@ -107,7 +111,8 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
idx += val;
if (work->bitCount <= t) {
if (r = TMCJPEGDEC_load_buff(work), r < 0) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
}
@@ -156,7 +161,7 @@ static s32 TMCJPEGDEC_vl_decode_rc(u32* huff_tbl, u8* huff_sym, TMCCJPEGDecWork*
}
bit_pos = work->bitCount;
entry = (u16*)((u8*)huff_tbl + 0x24);
entry = (u16*)(huff_tbl + 9);
bit_data = work->bitBuf;
i = 9;
bit_pos -= 9;
@@ -186,11 +191,10 @@ static s32 TMCJPEGDEC_vl_decode_rc(u32* huff_tbl, u8* huff_sym, TMCCJPEGDecWork*
} HuffEnt;
HuffEnt local = *(HuffEnt*)entry;
u32 combined = *(u32*)&local;
u32 combined2 = combined;
u16 th = *(u16*)&combined2;
u16 th = *(u16*)&combined;
s32 tmp;
if (code > (u32)th) {
if (code > th) {
continue;
}

View File

@@ -166,16 +166,15 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
}
static void TMCJPEGDEC_converterYUV411toRGB565(TMCCJPEGDecWork* work, s32 x, s32 y) {
u16* output;
s32 tileRow;
s32 cbValue;
s32 blue;
TMCCJPEGDecState* state;
s32 lumaSkip;
s32 crValue;
s32 width;
s32 height;
s32 chromaSkip;
s32 tileColumn;
s32 red;
s32 secondGreen;
s32 thirdGreen;
s32 fourthGreen;
s32 green;
s32 secondRed;
s32 thirdRed;
s32 fourthRed;
u8* texture;
u8* luminance;
u8* cb;
@@ -183,13 +182,17 @@ static void TMCJPEGDEC_converterYUV411toRGB565(TMCCJPEGDecWork* work, s32 x, s32
s32 column;
s32 xEnd;
s32 yEnd;
u8 value;
u32 tileWidth;
s32 greenOffset;
s32 tileWidth;
s32 redOffset;
s32 red;
s32 greenOffset;
s32 blueOffset;
s32 green;
s32 blue;
s32 value;
TMCCJPEGDecState* state;
s32 width;
s32 height;
s32 crValue;
s32 cbValue;
luminance = work->convBuf + 4;
cb = &work->convBuf[260];
@@ -201,12 +204,9 @@ static void TMCJPEGDEC_converterYUV411toRGB565(TMCCJPEGDecWork* work, s32 x, s32
height = 8 / state->scaleFactor;
xEnd = x + width;
yEnd = y + height;
lumaSkip = 32 - width;
chromaSkip = lumaSkip >> 2;
for (; y < yEnd; y++) {
tileRow = (y >> 2) * tileWidth;
output = (u16*)(texture + ((y & 3) << 3));
for (column = x; column < xEnd; column += 4) {
tileColumn = column >> 2;
cbValue = (s8)*cb++;
crValue = (s8)*cr++;
redOffset = (crValue * 359) >> 8;
@@ -216,46 +216,50 @@ static void TMCJPEGDEC_converterYUV411toRGB565(TMCCJPEGDecWork* work, s32 x, s32
red = value + redOffset;
green = value + greenOffset;
blue = value + blueOffset;
if ((blue | red | green) >> 8) {
if ((red | green | blue) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
}
output[(column & 3) + (((column >> 2) + tileRow) << 4)] = ((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
((u16*)(texture + ((y & 3) << 3)))[(column & 3) + ((tileColumn + (y >> 2) * tileWidth) << 4)] =
((blue & 0xF8) >> 3) + (((red & 0xF8) << 8) + ((green & 0xFC) << 3));
value = *luminance++;
red = value + redOffset;
green = value + greenOffset;
secondRed = value + redOffset;
secondGreen = value + greenOffset;
blue = value + blueOffset;
if ((blue | red | green) >> 8) {
if ((secondRed | secondGreen | blue) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
secondGreen = secondGreen > 255 ? 255 : secondGreen < 0 ? 0 : secondGreen;
secondRed = secondRed > 255 ? 255 : secondRed < 0 ? 0 : secondRed;
}
output[((column + 1) & 3) + ((((column + 1) >> 2) + tileRow) << 4)] = ((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
((u16*)(texture + ((y & 3) << 3)))[((column + 1) & 3) + ((((column + 1) >> 2) + (y >> 2) * tileWidth) << 4)] =
((blue & 0xF8) >> 3) + (((secondRed & 0xF8) << 8) + ((secondGreen & 0xFC) << 3));
value = *luminance++;
red = value + redOffset;
green = value + greenOffset;
thirdRed = value + redOffset;
thirdGreen = value + greenOffset;
blue = value + blueOffset;
if ((blue | red | green) >> 8) {
if ((thirdRed | thirdGreen | blue) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
thirdGreen = thirdGreen > 255 ? 255 : thirdGreen < 0 ? 0 : thirdGreen;
thirdRed = thirdRed > 255 ? 255 : thirdRed < 0 ? 0 : thirdRed;
}
output[((column + 2) & 3) + ((((column + 2) >> 2) + tileRow) << 4)] = ((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
((u16*)(texture + ((y & 3) << 3)))[((column + 2) & 3) + ((((column + 2) >> 2) + (y >> 2) * tileWidth) << 4)] =
((blue & 0xF8) >> 3) + (((thirdRed & 0xF8) << 8) + ((thirdGreen & 0xFC) << 3));
value = *luminance++;
red = value + redOffset;
green = value + greenOffset;
fourthRed = value + redOffset;
fourthGreen = value + greenOffset;
blue = value + blueOffset;
if ((blue | red | green) >> 8) {
if ((fourthRed | fourthGreen | blue) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
fourthGreen = fourthGreen > 255 ? 255 : fourthGreen < 0 ? 0 : fourthGreen;
fourthRed = fourthRed > 255 ? 255 : fourthRed < 0 ? 0 : fourthRed;
}
output[((column + 3) & 3) + ((((column + 3) >> 2) + tileRow) << 4)] = ((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
((u16*)(texture + ((y & 3) << 3)))[((column + 3) & 3) + ((((column + 3) >> 2) + (y >> 2) * tileWidth) << 4)] =
((blue & 0xF8) >> 3) + (((fourthRed & 0xF8) << 8) + ((fourthGreen & 0xFC) << 3));
}
luminance += lumaSkip;
cb += chromaSkip;
cr += chromaSkip;
luminance += 32 - width;
cb += (32 - width) >> 2;
cr += (32 - width) >> 2;
}
}

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

@@ -899,8 +899,8 @@ void AXSetVoiceSrcRatio(AXVPB* vpb, float ratio) {
old = OSDisableInterrupts();
r = 65536.0f * ratio;
vpb->pb.src.ratioHi = ((u32)r >> 0x10);
vpb->pb.src.ratioLo = ((u32)r);
vpb->pb.src.ratioHi = (r >> 0x10);
vpb->pb.src.ratioLo = r;
vpb->sync |= AX_PBSYNC_SRC_RATIO;
OSRestoreInterrupts(old);
}

View File

@@ -113,7 +113,7 @@ void AXFXChorusExpCallback(AXFX_BUFFERUPDATE* update, AXFX_CHORUS_EXP* fx) {
else if (position < 0) position += fx->delay.sizeFP;
distance = position - fx->delay.lastPos;
if ((s32)distance < 0) distance += fx->delay.sizeFP;
whole = (u32)distance >> 16;
whole = distance >> 16;
fraction = distance & 0xFFFF;
source = fx->delay.lastPos >> 16;
history = fx->histIndex;

View File

@@ -599,7 +599,7 @@ void *GKI_dequeue(BUFFER_Q *p_q)
GKI_enable();
return (BUFFER_HDR_T *)p_hdr + 1;
return p_hdr + 1;
}
void *GKI_remove_from_queue(BUFFER_Q *p_q, void *p_buf)

View File

@@ -233,13 +233,13 @@ static void SetupTimeoutAlarm(CARDControl* card) {
break;
}
case 0xF4: {
if (card->pageSize > 0x80) {
if (card->pageSize > CARD_PAGE_SIZE) {
OSSetAlarm(&card->alarm, OSSecondsToTicks((OSTime)2) * (card->cBlock / 0x40), TimeoutHandler);
break;
}
}
case 0xF1: {
OSSetAlarm(&card->alarm, OSSecondsToTicks((OSTime)2) * (card->sectorSize / 0x2000), TimeoutHandler);
OSSetAlarm(&card->alarm, OSSecondsToTicks((OSTime)2) * (card->sectorSize / CARD_SYSTEM_BLOCK_SIZE), TimeoutHandler);
break;
}
}
@@ -408,7 +408,7 @@ s32 __CARDWritePage(s32 chan, CARDCallback callback) {
card = &__CARDBlock[chan];
card->cmd[0] = 0xF2;
if (card->pageSize > 0x80) {
if (card->pageSize > CARD_PAGE_SIZE) {
card->cmd[1] = AD1(card->addr) | 0x80;
} else {
card->cmd[1] = AD1(card->addr);
@@ -444,11 +444,11 @@ s32 __CARDEraseSector(s32 chan, u32 addr, CARDCallback callback) {
card = &__CARDBlock[chan];
if (card->pageSize > 0x80) {
if (card->pageSize > CARD_PAGE_SIZE) {
if (callback) {
callback(chan, 0);
callback(chan, CARD_RESULT_READY);
}
return 0;
return CARD_RESULT_READY;
}
card->cmd[0] = 0xF1;
@@ -496,7 +496,7 @@ void CARDInit() {
OSInitThreadQueue(&card->threadQueue);
OSCreateAlarm(&card->alarm);
}
__CARDSetDiskID((void*)OSPhysicalToCached(OS_ADDR_BOOT_INFO));
__CARDSetDiskID(OSPhysicalToCached(OS_ADDR_BOOT_INFO));
OSRegisterShutdownFunction(&ShutdownFunctionInfo);
}

View File

@@ -28,10 +28,10 @@ static void WriteCallback(s32 chan, s32 result) {
if (card->currentFat == fat0) {
card->currentFat = fat1;
memcpy(fat1, fat0, 0x2000);
memcpy(fat1, fat0, CARD_SYSTEM_BLOCK_SIZE);
} else {
card->currentFat = fat0;
memcpy(fat0, fat1, 0x2000);
memcpy(fat0, fat1, CARD_SYSTEM_BLOCK_SIZE);
}
}
@@ -90,25 +90,25 @@ s32 __CARDAllocBlock(s32 chan, u32 cBlock, CARDCallback callback) {
}
fat = __CARDGetFatBlockU16(card);
if (fat[3] < cBlock) {
if (fat[CARD_FAT_FREEBLOCKS] < cBlock) {
return CARD_RESULT_INSSPACE;
}
fat[3] -= cBlock;
fat[CARD_FAT_FREEBLOCKS] -= cBlock;
startBlock = 0xFFFF;
iBlock = fat[4];
iBlock = fat[CARD_FAT_LASTSLOT];
count = 0;
while (0 < cBlock) {
if (card->cBlock - 5 < ++count) {
if (card->cBlock - CARD_NUM_SYSTEM_BLOCK < ++count) {
return CARD_RESULT_BROKEN;
}
iBlock++;
if (!CARDIsValidBlockNo(card, iBlock)) {
iBlock = 5;
iBlock = CARD_NUM_SYSTEM_BLOCK;
}
if (fat[iBlock] == 0x0000u) {
if (fat[iBlock] == CARD_FAT_AVAIL) {
if (startBlock == 0xFFFF) {
startBlock = iBlock;
} else {
@@ -120,7 +120,7 @@ s32 __CARDAllocBlock(s32 chan, u32 cBlock, CARDCallback callback) {
}
}
fat[4] = iBlock;
fat[CARD_FAT_LASTSLOT] = iBlock;
card->startBlock = startBlock;
return __CARDUpdateFatBlock(chan, fat, callback);
}
@@ -142,9 +142,9 @@ s32 __CARDFreeBlock(s32 chan, u16 nBlock, CARDCallback callback) {
}
nextBlock = fat[nBlock];
fat[nBlock] = 0;
fat[nBlock] = CARD_FAT_AVAIL;
nBlock = nextBlock;
++fat[3];
++fat[CARD_FAT_FREEBLOCKS];
}
return __CARDUpdateFatBlock(chan, fat, callback);
@@ -155,9 +155,9 @@ s32 __CARDUpdateFatBlock(s32 chan, u16* fat, CARDCallback callback) {
u32 addr;
card = &__CARDBlock[chan];
++fat[2];
__CARDCheckSum(fat + 2, 0x1FFC, fat, fat + 1);
DCStoreRange(fat, 0x2000);
++fat[CARD_FAT_CHECKCODE];
__CARDCheckSum(fat + CARD_FAT_CHECKCODE, CARD_SYSTEM_BLOCK_SIZE - sizeof(u32), fat, fat + CARD_FAT_CHECKSUMINV);
DCStoreRange(fat, CARD_SYSTEM_BLOCK_SIZE);
card->eraseCallback = callback;
addr = ((u32)fat - (u32)card->workArea) / CARD_SYSTEM_BLOCK_SIZE * card->sectorSize;
return __CARDEraseSector(chan, addr, EraseCallback);

View File

@@ -14,16 +14,16 @@ static void WriteCallback(s32 chan, s32 result) {
CARDControl* card = &__CARDBlock[chan];
CARDCallback callback;
if (result >= 0) {
CARDDir* dir0 = (CARDDir*)((u8*)card->workArea + 0x2000);
if (result >= CARD_RESULT_READY) {
CARDDir* dir0 = (CARDDir*)((u8*)card->workArea + CARD_SYSTEM_BLOCK_SIZE);
CARDDir* dir1 = (CARDDir*)((u8*)card->workArea + 0x4000);
if (card->currentDir == dir0) {
card->currentDir = dir1;
memcpy(dir1, dir0, 0x2000);
memcpy(dir1, dir0, CARD_SYSTEM_BLOCK_SIZE);
} else {
card->currentDir = dir0;
memcpy(dir0, dir1, 0x2000);
memcpy(dir0, dir1, CARD_SYSTEM_BLOCK_SIZE);
}
}
@@ -44,11 +44,11 @@ static void EraseCallback(s32 chan, s32 result) {
CARDDir* dir;
u32 addr;
if (result >= 0) {
if (result >= CARD_RESULT_READY) {
dir = __CARDGetDirBlock(card);
addr = ((u32)dir - (u32)card->workArea) / 0x2000 * card->sectorSize;
result = __CARDWrite(chan, addr, 0x2000, dir, WriteCallback);
if (result >= 0) {
addr = ((u32)dir - (u32)card->workArea) / CARD_SYSTEM_BLOCK_SIZE * card->sectorSize;
result = __CARDWrite(chan, addr, CARD_SYSTEM_BLOCK_SIZE, dir, WriteCallback);
if (result >= CARD_RESULT_READY) {
return;
}
}
@@ -78,10 +78,10 @@ s32 __CARDUpdateDir(s32 chan, CARDCallback callback) {
dir = __CARDGetDirBlock(card);
check = CARDGetDirCheck(dir);
++check->checkCode;
__CARDCheckSum(dir, 0x2000 - sizeof(u32), &check->checkSum, &check->checkSumInv);
DCStoreRange(dir, 0x2000);
__CARDCheckSum(dir, CARD_SYSTEM_BLOCK_SIZE - sizeof(u32), &check->checkSum, &check->checkSumInv);
DCStoreRange(dir, CARD_SYSTEM_BLOCK_SIZE);
card->eraseCallback = callback;
addr = ((u32)dir - (u32)card->workArea) / 0x2000 * card->sectorSize;
addr = ((u32)dir - (u32)card->workArea) / CARD_SYSTEM_BLOCK_SIZE * card->sectorSize;
return __CARDEraseSector(chan, addr, EraseCallback);
}

View File

@@ -79,7 +79,7 @@ static s32 DoMount(s32 chan) {
card = &__CARDBlock[chan];
if (card->mountStep == 0) {
if (EXIGetID(chan, 0, &id) == 0) {
if (!EXIGetID(chan, 0, &id)) {
result = CARD_RESULT_NOCARD;
} else if (IsCard(id)) {
result = CARD_RESULT_READY;

View File

@@ -2,4 +2,4 @@
#include <revolution/card.h>
u16 __CARDVendorID = -1;
u8 __CARDPermMask = 0x1C;
u8 __CARDPermMask = CARD_ATTR_PUBLIC | CARD_ATTR_NO_COPY | CARD_ATTR_NO_MOVE;

View File

@@ -45,10 +45,10 @@ s32 __CARDIsWritable(CARDControl* card, CARDDir* ent) {
result = __CARDAccess(card, ent);
if (result == CARD_RESULT_NOPERM) {
perm = ent->permission & __CARDPermMask;
if (perm & 0x20 && (memcmp(ent->gameName, __CARDDiskNone.gameName, sizeof(ent->gameName)) == 0 &&
if (perm & CARD_ATTR_GLOBAL && (memcmp(ent->gameName, __CARDDiskNone.gameName, sizeof(ent->gameName)) == 0 &&
memcmp(ent->company, __CARDDiskNone.company, sizeof(ent->company)) == 0)) {
return CARD_RESULT_READY;
} else if (perm & 0x40 && (memcmp(ent->gameName, __CARDDiskNone.gameName, sizeof(ent->gameName)) == 0 &&
} else if (perm & CARD_ATTR_COMPANY && (memcmp(ent->gameName, __CARDDiskNone.gameName, sizeof(ent->gameName)) == 0 &&
memcmp(ent->company, diskID->company, sizeof(ent->company)) == 0)) {
return CARD_RESULT_READY;
}
@@ -59,7 +59,7 @@ s32 __CARDIsWritable(CARDControl* card, CARDDir* ent) {
s32 __CARDIsReadable(CARDControl* card, CARDDir* ent) {
s32 result = __CARDIsWritable(card, ent);
if (result == CARD_RESULT_NOPERM && (ent->permission & 0x4)) {
if (result == CARD_RESULT_NOPERM && (ent->permission & CARD_ATTR_PUBLIC)) {
return CARD_RESULT_READY;
}

View File

@@ -62,27 +62,27 @@ s32 __CARDSetStatusExAsync(s32 chan, s32 fileNo, CARDDir* dirent, CARDCallback c
break;
}
if (dirent->permission & 0x20) {
if (dirent->permission & CARD_ATTR_GLOBAL) {
memset(dirent->gameName, 0, sizeof(dirent->gameName));
memset(dirent->company, 0, sizeof(dirent->company));
}
if (dirent->permission & 0x40) {
if (dirent->permission & CARD_ATTR_COMPANY) {
memset(dirent->gameName, 0, sizeof(dirent->gameName));
}
if ((memcmp(&ent->fileName, &dirent->fileName, 32) != 0) || (memcmp(ent->gameName, dirent->gameName, 4) != 0) ||
if ((memcmp(&ent->fileName, &dirent->fileName, CARD_FILENAME_MAX) != 0) || (memcmp(ent->gameName, dirent->gameName, 4) != 0) ||
(memcmp(ent->company, dirent->company, 2) != 0)) {
for (i = 0; i < CARD_MAX_FILE; i++) {
if (i != fileNo) {
CARDDir* ent = &dir[i];
if (((u8)ent->gameName[0] != 0xFF) && (memcmp(&ent->gameName, &dirent->gameName, 4) == 0) &&
(memcmp(&ent->company, &dirent->company, 2) == 0) && (memcmp(&ent->fileName, &dirent->fileName, 0x20) == 0)) {
return __CARDPutControlBlock(card, -7);
(memcmp(&ent->company, &dirent->company, 2) == 0) && (memcmp(&ent->fileName, &dirent->fileName, CARD_FILENAME_MAX) == 0)) {
return __CARDPutControlBlock(card, CARD_RESULT_EXIST);
}
}
}
memcpy(&ent->fileName, &dirent->fileName, 0x20);
memcpy(&ent->fileName, &dirent->fileName, CARD_FILENAME_MAX);
memcpy(&ent->gameName, &dirent->gameName, 4);
memcpy(&ent->company, &dirent->company, 2);
}

View File

@@ -104,7 +104,7 @@ static s32 ReadArrayUnlock(s32 chan, u32 data, void* rbuf, s32 rlen, int mode) {
u8 cmd[5];
card = &__CARDBlock[chan];
if (!EXISelect(chan, 0, CARDFreq)) {
if (!EXISelect(chan, EXI_DEV_EXT, CARDFreq)) {
return CARD_RESULT_NOCARD;
}
@@ -122,59 +122,59 @@ static s32 ReadArrayUnlock(s32 chan, u32 data, void* rbuf, s32 rlen, int mode) {
}
err = FALSE;
err |= !EXIImmEx(chan, cmd, 5, 1);
err |= !EXIImmEx(chan, (u8*)card->workArea + (u32)sizeof(CARDID), card->latency, 1);
err |= !EXIImmEx(chan, rbuf, rlen, 0);
err |= !EXIImmEx(chan, cmd, 5, EXI_WRITE);
err |= !EXIImmEx(chan, (u8*)card->workArea + (u32)sizeof(CARDID), card->latency, EXI_WRITE);
err |= !EXIImmEx(chan, rbuf, rlen, EXI_READ);
err |= !EXIDeselect(chan);
return err ? CARD_RESULT_NOCARD : CARD_RESULT_READY;
}
static u32 GetInitVal(void) {
u32 tmp;
u32 unlockAddress;
u32 tick;
tick = OSGetTick();
CARDSrand(tick);
tmp = 0x7fec8000;
tmp |= CARDRand();
tmp &= 0xfffff000;
return tmp;
unlockAddress = 0x7fec8000;
unlockAddress |= CARDRand();
unlockAddress &= 0xfffff000;
return unlockAddress;
}
static s32 DummyLen(void) {
u32 tick;
u32 wk;
s32 tmp;
u32 max;
u32 seedShift;
s32 extraReadLength;
u32 retryCount;
wk = 1;
max = 0;
seedShift = 1;
retryCount = 0;
tick = OSGetTick();
CARDSrand(tick);
tmp = CARDRand();
tmp &= 0x0000001f;
tmp += 1;
while ((tmp < 4) && (max < 10)) {
extraReadLength = CARDRand();
extraReadLength &= 0x0000001f;
extraReadLength += 1;
while ((extraReadLength < 4) && (retryCount < 10)) {
tick = OSGetTick();
tmp = (s32)(tick << wk);
wk++;
if (wk > 16) {
wk = 1;
extraReadLength = (s32)(tick << seedShift);
seedShift++;
if (seedShift > 16) {
seedShift = 1;
}
CARDSrand((u32)tmp);
tmp = CARDRand();
tmp &= 0x0000001f;
tmp += 1;
max++;
CARDSrand((u32)extraReadLength);
extraReadLength = CARDRand();
extraReadLength &= 0x0000001f;
extraReadLength += 1;
retryCount++;
}
if (tmp < 4) {
tmp = 4;
if (extraReadLength < 4) {
extraReadLength = 4;
}
return tmp;
return extraReadLength;
}
s32 __CARDUnlock(s32 chan, u8 flashID[12]) {

View File

@@ -107,7 +107,7 @@ CNTError contentOpenNAND(CNTHandleNAND* cntHandle, const char* path, CNTFileInfo
return CNT_RESULT_INVALID;
}
if (ARCFastOpen(&cntHandle->ArcHandle, entryNum, &arcFile) == FALSE) {
if (!ARCFastOpen(&cntHandle->ArcHandle, entryNum, &arcFile)) {
return CNT_RESULT_INVALID;
}
@@ -130,7 +130,7 @@ s32 contentOpenDVD(CNTHandleDVD* cntHandle, const char* path, CNTFileInfoDVD* cn
return CNT_RESULT_INVALID;
}
if (DVDFastOpen(entryNum, &cntFileInfo->fileInfo) == FALSE) {
if (!DVDFastOpen(entryNum, &cntFileInfo->fileInfo)) {
return CNT_RESULT_INVALID;
}
@@ -144,7 +144,7 @@ CNTError contentFastOpenNAND(CNTHandleNAND* cntHandle, s32 entryNum, CNTFileInfo
ARCFileInfo arcFile;
if (ARCFastOpen(&cntHandle->ArcHandle, entryNum, &arcFile) == FALSE) {
if (!ARCFastOpen(&cntHandle->ArcHandle, entryNum, &arcFile)) {
return CNT_RESULT_INVALID;
}

View File

@@ -45,8 +45,8 @@ void _CNTCACHEDeleteTitle();
void _CNTCACHEDeleteContent();
void CNTCACHEInit(int unk0, int unk1) {
if (_CNTCACHEInitialized == FALSE) {
void CNTCACHEInit(int cacheValue, int cacheHighWord) {
if (!_CNTCACHEInitialized) {
BOOL old;
OSRegisterVersion(__CNTCACHEVersion);
@@ -60,8 +60,8 @@ void CNTCACHEInit(int unk0, int unk1) {
}
CNTCACHEClear();
_CNTCACHEUnused816997A4 = unk0;
*((int*)&_CNTCACHEUnused816997A8) = unk1;
_CNTCACHEUnused816997A4 = cacheValue;
*((int*)&_CNTCACHEUnused816997A8) = cacheHighWord;
}
asm void CNTCACHEClear() {
clrlwi r11, r1, 0x1b

View File

@@ -31,21 +31,21 @@ void DSPSendMailToDSP(u32 mail) {
void DSPAssertInt() {
BOOL old;
u16 tmp;
u16 controlStatus;
old = OSDisableInterrupts();
tmp = DSP_READ_REG(DSP_CONTROL_STATUS);
CLEAR_FLAG(tmp, 0xA8);
SET_FLAG(tmp, 2);
DSP_WRITE_REG(DSP_CONTROL_STATUS, tmp);
controlStatus = DSP_READ_REG(DSP_CONTROL_STATUS);
CLEAR_FLAG(controlStatus, 0xA8);
SET_FLAG(controlStatus, 2);
DSP_WRITE_REG(DSP_CONTROL_STATUS, controlStatus);
OSRestoreInterrupts(old);
}
void DSPInit() {
BOOL old;
u16 tmp;
u16 controlStatus;
__DSP_debug_printf("DSPInit(): Build Date: %s %s\n", "Apr 20 2010", "11:19:06");
@@ -60,15 +60,15 @@ void DSPInit() {
__OSUnmaskInterrupts(OS_INTERRUPTMASK_DSP_DSP);
// Reset DSP
tmp = DSP_READ_REG(DSP_CONTROL_STATUS);
CLEAR_FLAG(tmp, ((1 << DSP_CONTROL_STATUS_AIDINT) | (1 << DSP_CONTROL_STATUS_ARINT) | (1 << DSP_CONTROL_STATUS_DSPINT)));
SET_FLAG(tmp, (1 << DSP_CONTROL_STATUS_RESET));
DSP_WRITE_REG(DSP_CONTROL_STATUS, tmp);
controlStatus = DSP_READ_REG(DSP_CONTROL_STATUS);
CLEAR_FLAG(controlStatus, ((1 << DSP_CONTROL_STATUS_AIDINT) | (1 << DSP_CONTROL_STATUS_ARINT) | (1 << DSP_CONTROL_STATUS_DSPINT)));
SET_FLAG(controlStatus, (1 << DSP_CONTROL_STATUS_RESET));
DSP_WRITE_REG(DSP_CONTROL_STATUS, controlStatus);
tmp = DSP_READ_REG(DSP_CONTROL_STATUS);
CLEAR_FLAG(tmp, ((1 << DSP_CONTROL_STATUS_AIDINT) | (1 << DSP_CONTROL_STATUS_ARINT) | (1 << DSP_CONTROL_STATUS_DSPINT)) |
controlStatus = DSP_READ_REG(DSP_CONTROL_STATUS);
CLEAR_FLAG(controlStatus, ((1 << DSP_CONTROL_STATUS_AIDINT) | (1 << DSP_CONTROL_STATUS_ARINT) | (1 << DSP_CONTROL_STATUS_DSPINT)) |
(1 << DSP_CONTROL_STATUS_HALT));
DSP_WRITE_REG(DSP_CONTROL_STATUS, tmp);
DSP_WRITE_REG(DSP_CONTROL_STATUS, controlStatus);
__DSP_first_task = __DSP_last_task = __DSP_curr_task = __DSP_tmp_task = NULL;

View File

@@ -54,13 +54,13 @@ BOOL __DSP_rude_task_pending;
void __DSPHandler(__OSInterrupt intr, OSContext* context) {
OSContext exceptionContext;
u16 tmp;
u16 controlStatus;
u32 mail;
tmp = DSP_READ_REG(DSP_CONTROL_STATUS);
CLEAR_FLAG(tmp, ((1 << DSP_CONTROL_STATUS_AIDINT) | (1 << DSP_CONTROL_STATUS_ARINT)));
SET_FLAG(tmp, (1 << DSP_CONTROL_STATUS_DSPINT));
DSP_WRITE_REG(DSP_CONTROL_STATUS, tmp);
controlStatus = DSP_READ_REG(DSP_CONTROL_STATUS);
CLEAR_FLAG(controlStatus, ((1 << DSP_CONTROL_STATUS_AIDINT) | (1 << DSP_CONTROL_STATUS_ARINT)));
SET_FLAG(controlStatus, (1 << DSP_CONTROL_STATUS_DSPINT));
DSP_WRITE_REG(DSP_CONTROL_STATUS, controlStatus);
OSClearContext(&exceptionContext);
OSSetCurrentContext(&exceptionContext);

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

@@ -102,8 +102,8 @@ void GXSetDispCopyFrame2Field(GXCopyMode mode) {
}
void GXSetCopyClamp(GXFBClamp clamp) {
u8 clmpT = (clamp & GX_CLAMP_TOP) == 1;
u8 clmpB = (clamp & GX_CLAMP_BOTTOM) == 2;
u8 clmpT = (clamp & GX_CLAMP_TOP) == GX_CLAMP_TOP;
u8 clmpB = (clamp & GX_CLAMP_BOTTOM) == GX_CLAMP_BOTTOM;
SET_REG_FIELD(__GXData->cpDisp, 1, 0, clmpT);
SET_REG_FIELD(__GXData->cpDisp, 1, 1, clmpB);
@@ -315,7 +315,7 @@ void GXCopyDisp(void* dest, GXBool clear) {
changePeCtrl = FALSE;
if ((clear || (u32)GET_REG_FIELD(__GXData->peCtrl, 3, 0) == 3) && (u32)GET_REG_FIELD(__GXData->peCtrl, 1, 6) == 1) {
if ((clear || (u32)GET_REG_FIELD(__GXData->peCtrl, 3, 0) == GX_PF_Z24) && (u32)GET_REG_FIELD(__GXData->peCtrl, 1, 6) == 1) {
changePeCtrl = TRUE;
tempPeCtrl = __GXData->peCtrl;
SET_REG_FIELD(tempPeCtrl, 1, 6, 0);
@@ -370,12 +370,12 @@ void GXCopyTex(void* dest, GXBool clear) {
changePeCtrl = 0;
tempPeCtrl = __GXData->peCtrl;
if (__GXData->cpTexZ && ((tempPeCtrl & 7) != 3)) {
if (__GXData->cpTexZ && ((tempPeCtrl & 7) != GX_PF_Z24)) {
changePeCtrl = 1;
SET_REG_FIELD(tempPeCtrl, 3, 0, 3);
SET_REG_FIELD(tempPeCtrl, 3, 0, GX_PF_Z24);
}
if ((clear || ((u32)(tempPeCtrl & 7) == 3)) && ((u32)((tempPeCtrl >> 6) & 1) == 1)) {
if ((clear || ((tempPeCtrl & 7) == GX_PF_Z24)) && (((tempPeCtrl >> 6) & 1) == 1)) {
changePeCtrl = 1;
SET_REG_FIELD(tempPeCtrl, 1, 6, 0);
}

View File

@@ -373,14 +373,14 @@ void __GXInitGX() {
}
GXSetCopyClear(clear, 0xFFFFFF);
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 0x3C);
GXSetTexCoordGen(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX1, 0x3C);
GXSetTexCoordGen(GX_TEXCOORD2, GX_TG_MTX2x4, GX_TG_TEX2, 0x3C);
GXSetTexCoordGen(GX_TEXCOORD3, GX_TG_MTX2x4, GX_TG_TEX3, 0x3C);
GXSetTexCoordGen(GX_TEXCOORD4, GX_TG_MTX2x4, GX_TG_TEX4, 0x3C);
GXSetTexCoordGen(GX_TEXCOORD5, GX_TG_MTX2x4, GX_TG_TEX5, 0x3C);
GXSetTexCoordGen(GX_TEXCOORD6, GX_TG_MTX2x4, GX_TG_TEX6, 0x3C);
GXSetTexCoordGen(GX_TEXCOORD7, GX_TG_MTX2x4, GX_TG_TEX7, 0x3C);
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
GXSetTexCoordGen(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX1, GX_IDENTITY);
GXSetTexCoordGen(GX_TEXCOORD2, GX_TG_MTX2x4, GX_TG_TEX2, GX_IDENTITY);
GXSetTexCoordGen(GX_TEXCOORD3, GX_TG_MTX2x4, GX_TG_TEX3, GX_IDENTITY);
GXSetTexCoordGen(GX_TEXCOORD4, GX_TG_MTX2x4, GX_TG_TEX4, GX_IDENTITY);
GXSetTexCoordGen(GX_TEXCOORD5, GX_TG_MTX2x4, GX_TG_TEX5, GX_IDENTITY);
GXSetTexCoordGen(GX_TEXCOORD6, GX_TG_MTX2x4, GX_TG_TEX6, GX_IDENTITY);
GXSetTexCoordGen(GX_TEXCOORD7, GX_TG_MTX2x4, GX_TG_TEX7, GX_IDENTITY);
GXSetNumTexGens(1);
GXClearVtxDesc();
GXInvalidateVtxCache();
@@ -395,14 +395,14 @@ void __GXInitGX() {
GXSetLineWidth(6, GX_TO_ZERO);
GXSetPointSize(6, GX_TO_ZERO);
GXEnableTexOffsets(GX_TEXCOORD0, 0, 0);
GXEnableTexOffsets(GX_TEXCOORD1, 0, 0);
GXEnableTexOffsets(GX_TEXCOORD2, 0, 0);
GXEnableTexOffsets(GX_TEXCOORD3, 0, 0);
GXEnableTexOffsets(GX_TEXCOORD4, 0, 0);
GXEnableTexOffsets(GX_TEXCOORD5, 0, 0);
GXEnableTexOffsets(GX_TEXCOORD6, 0, 0);
GXEnableTexOffsets(GX_TEXCOORD7, 0, 0);
GXEnableTexOffsets(GX_TEXCOORD0, GX_FALSE, GX_FALSE);
GXEnableTexOffsets(GX_TEXCOORD1, GX_FALSE, GX_FALSE);
GXEnableTexOffsets(GX_TEXCOORD2, GX_FALSE, GX_FALSE);
GXEnableTexOffsets(GX_TEXCOORD3, GX_FALSE, GX_FALSE);
GXEnableTexOffsets(GX_TEXCOORD4, GX_FALSE, GX_FALSE);
GXEnableTexOffsets(GX_TEXCOORD5, GX_FALSE, GX_FALSE);
GXEnableTexOffsets(GX_TEXCOORD6, GX_FALSE, GX_FALSE);
GXEnableTexOffsets(GX_TEXCOORD7, GX_FALSE, GX_FALSE);
identity_mtx[0][0] = 1.0f;
identity_mtx[0][1] = 0.0f;
identity_mtx[0][2] = 0.0f;
@@ -436,10 +436,10 @@ void __GXInitGX() {
GXSetChanAmbColor(GX_COLOR1A1, black);
GXSetChanMatColor(GX_COLOR1A1, white);
GXInvalidateTexAll();
GXSetTexRegionCallback((GXTexRegionCallback)__GXDefaultTexRegionCallback);
GXSetTexRegionCallback(__GXDefaultTexRegionCallback);
GXSetTlutRegionCallback(__GXDefaultTlutRegionCallback);
GXInitTexObj(&tex_obj, DefaultTexData, 4, 4, GX_TF_IA8, GX_CLAMP, GX_CLAMP, 0);
GXInitTexObj(&tex_obj, DefaultTexData, 4, 4, GX_TF_IA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
GXLoadTexObj(&tex_obj, GX_TEXMAP0);
GXLoadTexObj(&tex_obj, GX_TEXMAP1);
GXLoadTexObj(&tex_obj, GX_TEXMAP2);

View File

@@ -23,7 +23,7 @@ static u8 GX2HWFiltConv[6] = {0x00, 0x04, 0x01, 0x05, 0x02, 0x06};
static void __GXGetTexTileShift(GXTexFmt fmt, u32* rowTileS, u32* colTileS) {
switch (fmt) {
case GX_TF_I4:
case 0x8:
case GX_TF_C4:
case GX_TF_CMPR:
case GX_CTF_R4:
case GX_CTF_Z4: {
@@ -33,7 +33,7 @@ static void __GXGetTexTileShift(GXTexFmt fmt, u32* rowTileS, u32* colTileS) {
}
case GX_TF_I8:
case GX_TF_IA4:
case 0x9:
case GX_TF_C8:
case GX_TF_Z8:
case GX_CTF_RA4:
case GX_TF_A8:
@@ -50,7 +50,7 @@ static void __GXGetTexTileShift(GXTexFmt fmt, u32* rowTileS, u32* colTileS) {
case GX_TF_RGB565:
case GX_TF_RGB5A3:
case GX_TF_RGBA8:
case 0xA:
case GX_TF_C14X2:
case GX_TF_Z16:
case GX_TF_Z24X8:
case GX_CTF_RA8:
@@ -141,7 +141,7 @@ void GXInitTexObj(const GXTexObj* obj, void* image_ptr, u16 width, u16 height, G
u8 lmax;
t->flags |= 1;
if (format == 8 || format == 9 || format == 10) {
if (format == GX_TF_C4 || format == GX_TF_C8 || format == GX_TF_C14X2) {
SET_REG_FIELD(t->mode0, 3, 5, 5);
} else {
SET_REG_FIELD(t->mode0, 3, 5, 6);
@@ -163,12 +163,12 @@ void GXInitTexObj(const GXTexObj* obj, void* image_ptr, u16 width, u16 height, G
SET_REG_FIELD(t->image0, 10, 0, width - 1);
SET_REG_FIELD(t->image0, 10, 10, height - 1);
SET_REG_FIELD(t->image0, 4, 20, format & 0xF);
imageBase = (u32)((u32)image_ptr >> 5) & 0x01FFFFFF;
imageBase = ((u32)image_ptr >> 5) & 0x01FFFFFF;
SET_REG_FIELD(t->image3, 24, 0, imageBase);
switch (format & 0xF) {
case GX_TF_I4:
case 8: {
case GX_TF_C4: {
t->loadFmt = 1;
rowT = 3;
colT = 3;
@@ -176,7 +176,7 @@ void GXInitTexObj(const GXTexObj* obj, void* image_ptr, u16 width, u16 height, G
}
case GX_TF_I8:
case GX_TF_IA4:
case 9: {
case GX_TF_C8: {
t->loadFmt = 2;
rowT = 3;
colT = 2;
@@ -185,7 +185,7 @@ void GXInitTexObj(const GXTexObj* obj, void* image_ptr, u16 width, u16 height, G
case GX_TF_IA8:
case GX_TF_RGB565:
case GX_TF_RGB5A3:
case 10: {
case GX_TF_C14X2: {
t->loadFmt = 2;
rowT = 2;
colT = 2;
@@ -510,8 +510,8 @@ void __SetSURegs(u32 tmap, u32 tcoord) NO_INLINE {
SET_REG_FIELD(__GXData->suTs0[tcoord], 16, 0, w);
SET_REG_FIELD(__GXData->suTs1[tcoord], 16, 0, h);
s_bias = GET_REG_FIELD(__GXData->tMode0[tmap], 2, 0) == 1;
t_bias = GET_REG_FIELD(__GXData->tMode0[tmap], 2, 2) == 1;
s_bias = GET_REG_FIELD(__GXData->tMode0[tmap], 2, 0) == GX_REPEAT;
t_bias = GET_REG_FIELD(__GXData->tMode0[tmap], 2, 2) == GX_REPEAT;
SET_REG_FIELD(__GXData->suTs0[tcoord], 1, 16, s_bias);
SET_REG_FIELD(__GXData->suTs1[tcoord], 1, 16, t_bias);
@@ -566,13 +566,13 @@ void __GXSetSUTexRegs() {
for (i = 0; i < nStages; i++) {
ptref = &__GXData->tref[i / 2];
map = __GXData->texmapId[i];
tmap = map & 0xFFFFFEFF;
tmap = map & ~GX_TEX_DISABLE;
if (i & 1) {
coord = GET_REG_FIELD(*ptref, 3, 15);
} else {
coord = GET_REG_FIELD(*ptref, 3, 3);
}
if ((tmap != 0xFF) && !(__GXData->tcsManEnab & (1 << coord)) && (__GXData->tevTcEnab & (1 << i))) {
if ((tmap != GX_TEXMAP_NULL) && !(__GXData->tcsManEnab & (1 << coord)) && (__GXData->tevTcEnab & (1 << i))) {
__SetSURegs(tmap, coord);
}
}

View File

@@ -765,7 +765,7 @@ IOSError IOS_IoctlvReboot(IOSFd fd, s32 cmd, u32 readCount, u32 writeCount, IOSI
if (__relnchFl) {
OSRestoreInterrupts(inten);
ret = -10;
ret = IPC_RESULT_NOTREADY;
goto finish;
}

View File

@@ -128,7 +128,11 @@ static KPADInside inside_kpads[4];
f32 initial_rotation_matrix[16];
const char* __KPADVersion = "<< RVL_SDK - KPAD \trelease build: Apr 20 2010 11:20:37 (0x4199_60831) >>";
static u8 dpdModeTable[12] = {0, 1, 3, 2, 0, 4, 1, 5, 0, 7, 1, 8};
static u8 dpdModeTable[12] = {
WPAD_DPD_DISABLE, WPAD_FMT_CORE_BTN_ACC, WPAD_DPD_STANDARD, WPAD_FMT_CORE_BTN_ACC_DPD,
WPAD_DPD_DISABLE, WPAD_FMT_FS_BTN_ACC, WPAD_DPD_BASIC, WPAD_FMT_FS_BTN_ACC_DPD,
WPAD_DPD_DISABLE, WPAD_FMT_CLASSIC_BTN_ACC, WPAD_DPD_BASIC, WPAD_FMT_CLASSIC_BTN_ACC_DPD,
};
static f32 idist_org = 1.0f;
static Vec2 iaccXY_nrm_hori = {0.0f, -1.0f};
@@ -170,17 +174,17 @@ static void* get_ring_buffer_by_kpad1_style(s32 chan, void* buffer, s32 style);
void* KPADGetWPADRingBuffer(s32 chan) {
static u8 status[0x2A0];
return get_ring_buffer_by_kpad1_style(chan, status, 0);
return get_ring_buffer_by_kpad1_style(chan, status, WPAD_DEV_CORE);
}
void* KPADGetWPADFSRingBuffer(s32 chan) {
static u8 status[0x320];
return get_ring_buffer_by_kpad1_style(chan, status, 1);
return get_ring_buffer_by_kpad1_style(chan, status, WPAD_DEV_FREESTYLE);
}
void* KPADGetWPADCLRingBuffer(s32 chan) {
static u8 status[0x360];
return get_ring_buffer_by_kpad1_style(chan, status, 2);
return get_ring_buffer_by_kpad1_style(chan, status, WPAD_DEV_CLASSIC);
}
static void* get_ring_buffer_by_kpad1_style(s32 chan, void* buffer, s32 style) {
@@ -192,13 +196,13 @@ static void* get_ring_buffer_by_kpad1_style(s32 chan, void* buffer, s32 style) {
s32 size;
u32 type;
switch (style) {
case 0:
case WPAD_DEV_CORE:
size = 0x2A;
goto process;
case 1:
case WPAD_DEV_FREESTYLE:
size = 0x32;
goto process;
case 2:
case WPAD_DEV_CLASSIC:
size = 0x36;
goto process;
default:
@@ -217,25 +221,25 @@ process:
}
type = kpad->ringData[index].device;
switch (type) {
case 0:
case 0xFB:
case 0xFC:
case 0xFF:
type = 0;
case WPAD_DEV_CORE:
case WPAD_DEV_FUTURE:
case WPAD_DEV_NOT_SUPPORTED:
case WPAD_DEV_UNKNOWN:
type = WPAD_DEV_CORE;
break;
case 1:
type = 1;
case WPAD_DEV_FREESTYLE:
type = WPAD_DEV_FREESTYLE;
break;
case 2:
type = 2;
case WPAD_DEV_CLASSIC:
type = WPAD_DEV_CLASSIC;
break;
default:
type = 0xFF;
type = WPAD_DEV_UNKNOWN;
break;
}
if (type == style) {
if (WPADGetStatus() != 3) {
kpad->ringData[index].error = 0xFC;
kpad->ringData[index].error = WPAD_ERR_INVALID;
}
memcpy((u8*)buffer + latest * size, &kpad->ringData[index], size);
}
@@ -438,7 +442,7 @@ static void calc_button_repeat(KPADInside* kpad, u8 extension, s32 elapsed) {
u16 extensionThreshold;
u16 extensionCurrent;
u32 extensionNext;
if (extension == 2) {
if (extension == WPAD_DEV_CLASSIC) {
if (kpad->status.ex_status.cl.trig != 0 || kpad->status.ex_status.cl.release != 0) {
kpad->repeatCurrent = 0;
kpad->repeatCurrent2 = kpad->repeatDelay;
@@ -594,12 +598,12 @@ static void read_kpad_acc(KPADInside* kpad, KPADSample* status) {
Vec raw;
Vec previous;
switch (status->dataFormat) {
case 1:
case 2:
case 4:
case 5:
case 7:
case 8:
case WPAD_FMT_CORE_BTN_ACC:
case WPAD_FMT_CORE_BTN_ACC_DPD:
case WPAD_FMT_FS_BTN_ACC:
case WPAD_FMT_FS_BTN_ACC_DPD:
case WPAD_FMT_CLASSIC_BTN_ACC:
case WPAD_FMT_CLASSIC_BTN_ACC_DPD:
break;
default:
return;
@@ -618,11 +622,11 @@ static void read_kpad_acc(KPADInside* kpad, KPADSample* status) {
kpad->status.acc_speed = (f32)sqrt(previous.z * previous.z + (previous.x * previous.x + previous.y * previous.y));
calc_acc_horizon(kpad);
calc_acc_vertical(kpad);
if (status->error == 0 && status->device == 1) {
if (status->dataFormat == 4) {
if (status->error == WPAD_ERR_OK && status->device == WPAD_DEV_FREESTYLE) {
if (status->dataFormat == WPAD_FMT_FS_BTN_ACC) {
goto read_extension_acceleration;
}
if (status->dataFormat == 5) {
if (status->dataFormat == WPAD_FMT_FS_BTN_ACC_DPD) {
goto read_extension_acceleration;
}
}
@@ -1017,7 +1021,7 @@ static void read_kpad_dpd(KPADInside* kpad, KPADSample* status) {
DPDObject* source;
KPADDPDObject* object;
s8 selected;
if (format == 2 || format == 5 || format == 8) {
if (format == WPAD_FMT_CORE_BTN_ACC_DPD || format == WPAD_FMT_FS_BTN_ACC_DPD || format == WPAD_FMT_CLASSIC_BTN_ACC_DPD) {
source = &status->objects[3];
object = kpad->dpdState.objects + 3;
for (;;) {
@@ -1255,7 +1259,7 @@ static void read_kpad_stick(KPADInside* kpad, KPADSample* status) {
clamp = clamp_stick_circle;
}
device = status->device;
if (device == 1) {
if (device == WPAD_DEV_FREESTYLE) {
format = status->dataFormat;
if ((u8)(format + 0xFD) <= 2) {
if (kpad->extensionResetPending != 0) {
@@ -1271,7 +1275,7 @@ static void read_kpad_stick(KPADInside* kpad, KPADSample* status) {
return;
}
}
if (device == 2) {
if (device == WPAD_DEV_CLASSIC) {
format = status->dataFormat;
if ((u8)(format + 0xFA) > 2) {
return;
@@ -1343,7 +1347,7 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
}
kpad->samplingInProgress = 1;
probe = WPADProbe(chan, 0);
if (probe == -1 && kpad->dpdCallback != 0 && kpad->dpdCallbackFired != 0 && kpad->dpdCallbackPending == 0) {
if (probe == WPAD_ERR_NO_CONTROLLER && kpad->dpdCallback != 0 && kpad->dpdCallbackFired != 0 && kpad->dpdCallbackPending == 0) {
if (kpad->dpdCallback != 0 && kpad->dpdCallbackPending == 0) {
kpad->dpdCallbackPending = 1;
kpad->dpdCallback(chan, 1);
@@ -1413,7 +1417,7 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
remainingSamples = available;
output = statuses + available;
--output;
device = 0xFD;
device = WPAD_DEV_NOT_FOUND;
extensionButtons = 0xFFFF;
coreButtons = 0xFFFF;
buttons = 0xFFFF;
@@ -1421,20 +1425,20 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
output--;
sample = remainingSamples > 1 ? (KPADSample*)output : &latestSample;
switch (sample->error) {
case 0:
case WPAD_ERR_OK:
device = sample->device;
if (device == 1) {
if (device == WPAD_DEV_FREESTYLE) {
coreButtons = sample->buttons;
extensionButtons = 0;
} else if (device == 2) {
} else if (device == WPAD_DEV_CLASSIC) {
extensionButtons = sample->extension.cl.buttons;
coreButtons = 0;
} else {
extensionButtons = 0;
coreButtons = 0;
}
case -2:
case -7:
case WPAD_ERR_COMMUNICATION_ERROR:
case WPAD_ERR_CORRUPTED:
buttons = sample->buttons;
break;
}
@@ -1458,7 +1462,7 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
kpad->status.hold = heldButtons;
kpad->status.trig = changed & heldButtons;
kpad->status.release = changed & previousButtons;
if (device == 2) {
if (device == WPAD_DEV_CLASSIC) {
u16 previousExtensionButtons;
previousExtensionButtons = kpad->status.ex_status.cl.hold;
extensionButtons = (u16)extensionButtons;
@@ -1481,9 +1485,9 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
}
kpad->status.data_format = sample->dataFormat;
switch (sample->error) {
case 0:
case WPAD_ERR_OK:
read_kpad_stick(kpad, sample);
case -7:
case WPAD_ERR_CORRUPTED:
read_kpad_acc(kpad, sample);
read_kpad_dpd(kpad, sample);
break;
@@ -1526,10 +1530,10 @@ void KPADInit(void) {
do {
kpad->dpdEnable = 1;
referenceWidth = 1.0f;
kpad->dpdFormat = 0;
kpad->dpdFormat = WPAD_DPD_DISABLE;
referenceHeight = 0.75f;
kpad->status.dev_type = 0xFD;
kpad->status.data_format = 0;
kpad->status.dev_type = WPAD_DEV_NOT_FOUND;
kpad->status.data_format = WPAD_FMT_CORE_BTN;
kpad->referenceDistance = idist_org;
kpad->accelNormal = iaccXY_nrm_hori;
kpad->horizonTangent = isec_nrm_hori;
@@ -1587,7 +1591,7 @@ void KPADInit(void) {
i = 0;
do {
i++;
kpad->ringData[i - 1].error = -1;
kpad->ringData[i - 1].error = WPAD_ERR_NO_CONTROLLER;
} while (i < 16);
}
chan++;
@@ -1604,7 +1608,7 @@ void KPADInit(void) {
kpad = &inside_kpads[3];
do {
if (WPADGetStatus() == 3) {
WPADControlMotor(chan, 0);
WPADControlMotor(chan, WPAD_MOTOR_STOP);
}
chan--;
kpad->resetPending = 1;
@@ -1654,7 +1658,7 @@ static void KPADiSamplingCallback(s32 chan) {
f32 distance;
f32 x;
if (kpad->sensorBarPosition != 0) {
if (WPADGetSensorBarPosition() == 1) {
if (WPADGetSensorBarPosition() == WPAD_SENSOR_BAR_TOP) {
sensor = 0.2f;
} else {
sensor = -0.2f;
@@ -1683,16 +1687,16 @@ static void KPADiSamplingCallback(s32 chan) {
kpad->sensorHeightPending = 0;
}
switch (device) {
case 0:
case 0xFB:
case 0xFC:
case 0xFF:
case WPAD_DEV_CORE:
case WPAD_DEV_FUTURE:
case WPAD_DEV_NOT_SUPPORTED:
case WPAD_DEV_UNKNOWN:
tier = 0;
break;
case 1:
case WPAD_DEV_FREESTYLE:
tier = 2;
break;
case 2:
case WPAD_DEV_CLASSIC:
tier = 4;
break;
default:
@@ -1701,7 +1705,7 @@ static void KPADiSamplingCallback(s32 chan) {
if (kpad->dpdEnable != 0) {
tier++;
}
enabled = WPADIsDpdEnabled(chan) != 0 ? kpad->dpdFormat : 0;
enabled = WPADIsDpdEnabled(chan) ? kpad->dpdFormat : 0;
tableIndex = tier * 2;
if (enabled != dpdModeTable[tableIndex]) {
if (kpad->dpdCallback != 0 && kpad->dpdCallbackFired == 0) {
@@ -1711,7 +1715,7 @@ static void KPADiSamplingCallback(s32 chan) {
}
if (kpad->dpdCommandPending == 0) {
kpad->dpdCommandPending = 1;
if (WPADControlDpd(chan, dpdModeTable[tableIndex], KPADiControlDpdCallback) == 0) {
if (WPADControlDpd(chan, dpdModeTable[tableIndex], KPADiControlDpdCallback) == WPAD_ERR_OK) {
kpad->dpdFormat = dpdModeTable[tableIndex];
}
}

Some files were not shown because too many files have changed in this diff Show More