Compare commits

...

9 Commits

128 changed files with 5932 additions and 2908 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -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,9 +122,9 @@ 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;

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

@@ -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

@@ -30,8 +30,8 @@ static char s_homeDir[NAND_MAX_PATH] ALIGN32;
static BOOL nandOnShutdown(BOOL final, u32 event);
static void nandShutdownCallback(ISFSError result, void* arg);
static void nandChangeDirCallback(ISFSError result, void* arg);
static void nandShutdownCallback(ISFSError result, void* callbackContext);
static void nandChangeDirCallback(ISFSError result, void* callbackContext);
static OSShutdownFunctionInfo s_shutdownFuncInfo = {nandOnShutdown, 0xFF, NULL, NULL};
@@ -360,8 +360,8 @@ static BOOL nandOnShutdown(BOOL final, u32 event) {
}
}
static void nandShutdownCallback(ISFSError result, void* arg) {
*(BOOL*)arg = TRUE;
static void nandShutdownCallback(ISFSError result, void* callbackContext) {
*(BOOL*)callbackContext = TRUE;
}
static ISFSError nandChangeDir(const char* path, NANDCommandBlock* block, BOOL isAsync, BOOL hasPrivateAccess) {
@@ -400,8 +400,8 @@ s32 NANDChangeDir(const char* path) {
return nandConvertErrorCode(nandChangeDir(path, NULL, FALSE, FALSE));
}
static void nandChangeDirCallback(ISFSError result, void* arg) {
NANDCommandBlock* block = (NANDCommandBlock*)arg;
static void nandChangeDirCallback(ISFSError result, void* callbackContext) {
NANDCommandBlock* block = (NANDCommandBlock*)callbackContext;
if (result == ISFS_ERROR_OK) {
BOOL enabled = OSDisableInterrupts();
strcpy(s_currentDir, block->absPath);
@@ -435,12 +435,12 @@ s32 NANDGetHomeDir(char* path) {
return NAND_RESULT_OK;
}
void nandCallback(ISFSError result, void* arg) {
NANDCommandBlock* block = (NANDCommandBlock*)arg;
void nandCallback(ISFSError result, void* callbackContext) {
NANDCommandBlock* block = (NANDCommandBlock*)callbackContext;
block->callback(nandConvertErrorCode(result), block);
}
static void nandGetTypeCallback(ISFSError result, void* arg);
static void nandGetTypeCallback(ISFSError result, void* callbackContext);
static ISFSError nandGetType(const char* path, u8* type, NANDCommandBlock* block, BOOL isAsync, BOOL hasPrivateAccess) {
if (strlen(path) == 0) {
@@ -505,8 +505,8 @@ s32 NANDPrivateGetTypeAsync(const char* path, u8* type, NANDCallback callback, N
return nandConvertErrorCode(nandGetType(path, type, block, TRUE, TRUE));
}
static void nandGetTypeCallback(ISFSError result, void* arg) {
NANDCommandBlock* block = (NANDCommandBlock*)arg;
static void nandGetTypeCallback(ISFSError result, void* callbackContext) {
NANDCommandBlock* block = (NANDCommandBlock*)callbackContext;
if (result == ISFS_ERROR_OK || result == ISFS_ERROR_ACCESS) {
*block->type = NAND_TYPE_DIR;

View File

@@ -27,7 +27,7 @@ static NANDLoggingCallback s_callback = NULL;
if (s_callback) \
s_callback(b)
static void asyncRoutine(ISFSError result, void* arg);
static void asyncRoutine(ISFSError result, void* callbackContext);
static void PrepareLine(char* line, int count, const char* msg) {
int result;
char titleID[64];
@@ -169,7 +169,7 @@ BOOL NANDLoggingAddMessageAsync(NANDLoggingCallback callback, const char* fmt, .
}
}
static void asyncRoutine(ISFSError result, void* arg) {
static void asyncRoutine(ISFSError result, void* callbackContext) {
ISFSError ret;
static char s_rBuf[LINE_MAX_EACH] ATTRIBUTE_ALIGN(LINE_MAX);
static char s_wBuf[LINE_MAX_EACH] ATTRIBUTE_ALIGN(LINE_MAX);

View File

@@ -13,7 +13,7 @@
static BOOL nandInspectPermission(u8 perm);
static void nandSplitPerm(u8 perm, u32* owner, u32* group, u32* others);
static void nandGetStatusCallback(ISFSError result, void* arg);
static void nandGetStatusCallback(ISFSError result, void* callbackContext);
static ISFSError nandCreate(const char* path, u8 perm, u8 attr, NANDCommandBlock* block, BOOL isAsync, BOOL hasPrivateAccess) {
char absPath[NAND_MAX_PATH] = "";
@@ -302,8 +302,8 @@ s32 NANDTell(NANDFileInfo* info, u32* pos) {
return nandConvertErrorCode(nandGetFileStatus(info->fileDescriptor, NULL, pos));
}
static void nandGetFileStatusAsyncCallback(ISFSError result, void* arg) {
NANDCommandBlock* block = (NANDCommandBlock*)arg;
static void nandGetFileStatusAsyncCallback(ISFSError result, void* callbackContext) {
NANDCommandBlock* block = (NANDCommandBlock*)callbackContext;
ISFSFileStats* isfsStats = (ISFSFileStats*)OSRoundUp32B((u32)block->absPath);
if (result == ISFS_ERROR_OK) {
@@ -411,8 +411,8 @@ static ISFSError nandGetStatus(const char* path, NANDStatus* status, NANDCommand
}
}
static void nandGetStatusCallback(ISFSError result, void* arg) {
NANDCommandBlock* block = (NANDCommandBlock*)arg;
static void nandGetStatusCallback(ISFSError result, void* callbackContext) {
NANDCommandBlock* block = (NANDCommandBlock*)callbackContext;
if (result == ISFS_ERROR_OK) {
NANDStatus* status = (NANDStatus*)block->status;
status->attribute = block->attr;

View File

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

View File

@@ -374,7 +374,7 @@ s32 WADGetInstalledVersion(ESTitleId titleId, u16* version) {
}
result = ES_GetTmdView(titleId, 0, &tmdSize);
if (result == -106) {
if (result == ES_ERR_DONT_EXISTS) {
return -3002;
}
if (result != 0) {
@@ -668,7 +668,7 @@ s32 WADImportEx(char* path, MEMAllocator* allocator, WADLocation location, u32 o
goto cleanup;
}
if (ticketViewCount == 0) {
result = -1028;
result = ES_ERR_TICKET_NOT_FOUND;
goto cleanup;
}
}
@@ -1006,20 +1006,20 @@ s32 WADImportEx(char* path, MEMAllocator* allocator, WADLocation location, u32 o
result = 0;
if (_WADCanImportFile(fileHeaderBuffer, transferIdValue,
unpackInfo.fileNames, transferId) == 0) {
if ((fileHeaderBuffer->flags[2] == 1) && (fileHeaderBuffer->fileSize != 0)) {
if ((fileHeaderBuffer->flags[2] == NAND_TYPE_FILE) && (fileHeaderBuffer->fileSize != 0)) {
importedBytes += fileHeaderBuffer->fileSize;
importedBytes = (importedBytes + 0x3F) & ~0x3F;
}
continue;
}
if (fileHeaderBuffer->flags[2] == 1) {
result = NANDPrivateCreate(fileHeaderBuffer->name, fileHeaderBuffer->flags[0] | 0x20,
if (fileHeaderBuffer->flags[2] == NAND_TYPE_FILE) {
result = NANDPrivateCreate(fileHeaderBuffer->name, fileHeaderBuffer->flags[0] | NAND_PERM_USER_WRITE,
fileHeaderBuffer->flags[1]);
if (result != 0) {
goto cleanup;
}
if (fileHeaderBuffer->fileSize != 0) {
result = NANDPrivateOpen(fileHeaderBuffer->name, &backupFile, 2);
result = NANDPrivateOpen(fileHeaderBuffer->name, &backupFile, NAND_ACCESS_WRITE);
if (result != 0) {
goto cleanup;
}
@@ -1066,7 +1066,7 @@ s32 WADImportEx(char* path, MEMAllocator* allocator, WADLocation location, u32 o
}
backupFileOpened = FALSE;
}
if ((fileHeaderBuffer->flags[0] & 0x20) == 0) {
if ((fileHeaderBuffer->flags[0] & NAND_PERM_USER_WRITE) == 0) {
result = NANDPrivateGetStatus(fileHeaderBuffer->name, &fileStatus);
if (result != 0) {
goto cleanup;
@@ -1078,17 +1078,17 @@ s32 WADImportEx(char* path, MEMAllocator* allocator, WADLocation location, u32 o
goto cleanup;
}
}
} else if (fileHeaderBuffer->flags[2] == 2) {
} else if (fileHeaderBuffer->flags[2] == NAND_TYPE_DIR) {
result = NANDPrivateCreateDir(fileHeaderBuffer->name,
fileHeaderBuffer->flags[0] | 0x20,
fileHeaderBuffer->flags[0] | NAND_PERM_USER_WRITE,
fileHeaderBuffer->flags[1]);
if (result == -6) {
if (result == NAND_RESULT_EXISTS) {
result = NANDPrivateGetStatus(fileHeaderBuffer->name, &fileStatus);
if (result != 0) {
goto cleanup;
}
if ((fileStatus.permission & 0x20) == 0) {
fileStatus.permission = fileHeaderBuffer->flags[0] | 0x20;
if ((fileStatus.permission & NAND_PERM_USER_WRITE) == 0) {
fileStatus.permission = fileHeaderBuffer->flags[0] | NAND_PERM_USER_WRITE;
fileStatus.attribute = fileHeaderBuffer->flags[1];
result = NANDPrivateSetStatus(fileHeaderBuffer->name, &fileStatus);
if (result != 0) {
@@ -1126,7 +1126,7 @@ s32 WADImportEx(char* path, MEMAllocator* allocator, WADLocation location, u32 o
if (result != 0) {
goto cleanup;
}
if ((fileHeaderBuffer->flags[0] & 0x20) == 0) {
if ((fileHeaderBuffer->flags[0] & NAND_PERM_USER_WRITE) == 0) {
savedataStatus.permission = fileHeaderBuffer->flags[0];
result = NANDPrivateSetStatus(fileHeaderBuffer->name, &savedataStatus);
if (result != 0) {
@@ -1352,7 +1352,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
}
if ((flags & 1) != 0) {
result = ES_ListTitleContentsOnCard(titleId, 0, &installedContentCount);
if (result == -106) {
if (result == ES_ERR_DONT_EXISTS) {
result = -3002;
goto cleanup;
}
@@ -1651,8 +1651,8 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
if (processCallback != 0) {
processCallback(importedSize, contentDataSize + fileDataSize, FALSE);
}
if ((fileHeaderBuffer->flags[2] == 1) && (fileHeaderBuffer->fileSize != 0)) {
result = NANDPrivateOpen(fileHeaderBuffer->name, &savedFile, 1);
if ((fileHeaderBuffer->flags[2] == NAND_TYPE_FILE) && (fileHeaderBuffer->fileSize != 0)) {
result = NANDPrivateOpen(fileHeaderBuffer->name, &savedFile, NAND_ACCESS_READ);
fileOpened = TRUE;
if (result != 0) {
goto file_done;
@@ -1720,7 +1720,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
processCallback(importedSize, contentDataSize + fileDataSize, FALSE);
}
}
} else if (fileHeaderBuffer->flags[2] == 1) {
} else if (fileHeaderBuffer->flags[2] == NAND_TYPE_FILE) {
byteCount = 0;
}
file_done:
@@ -1771,19 +1771,19 @@ file_done:
}
result = 0;
streamResult = WADWriteStream(&stream, signature, sizeof(signature));
if ((s32)streamResult != (s32)sizeof(signature)) {
if (streamResult != (s32)sizeof(signature)) {
result = -3006;
goto cleanup;
}
result = 0;
streamResult = WADWriteStream(&stream, (void*)ROUNDUP((u32)certificates->device, 64), sizeof(certificates->device));
if ((s32)streamResult != (s32)sizeof(certificates->device)) {
if (streamResult != (s32)sizeof(certificates->device)) {
result = -3006;
goto cleanup;
}
result = 0;
streamResult = WADWriteStream(&stream, (ESCertSignature*)ROUNDUP((u32)&certificates->signer, 64), sizeof(certificates->signer));
if ((s32)streamResult != (s32)sizeof(certificates->signer)) {
if (streamResult != (s32)sizeof(certificates->signer)) {
result = -3006;
goto cleanup;
}
@@ -1841,7 +1841,7 @@ static s32 _WADCheckContents(ESTmdView* titleMeta, ESContentMask* contentMask) {
s32 result;
u32 contentIndex;
if (ES_ListTitleContentsOnCard(titleMeta->head.titleId, 0, &installedContentCount) == -106) {
if (ES_ListTitleContentsOnCard(titleMeta->head.titleId, 0, &installedContentCount) == ES_ERR_DONT_EXISTS) {
result = -3002;
} else {
result = ES_ListTitleContentsOnCard(titleMeta->head.titleId, installedContentIds,
@@ -2006,23 +2006,23 @@ s32 WADOpenStream(WADLocation location, const char* path, WADStream* stream, u32
{
s32 result;
if (write != 0) {
result = NANDPrivateOpen(path, &stream->handle.nand, 3);
if (result == -12) {
result = NANDPrivateOpen(path, &stream->handle.nand, NAND_ACCESS_RW);
if (result == NAND_RESULT_NOEXISTS) {
result = NANDPrivateCreate(path, 0x3F, 0);
if (result != 0) {
return -3004;
}
result = NANDPrivateOpen(path, &stream->handle.nand, 3);
result = NANDPrivateOpen(path, &stream->handle.nand, NAND_ACCESS_RW);
}
if (result != 0) {
return -3004;
}
result = NANDSeek(&stream->handle.nand, offset, 0);
if (result == -8) {
result = NANDSeek(&stream->handle.nand, offset, NAND_SEEK_BEG);
if (result == NAND_RESULT_INVALID) {
u8 zeroes[0x4000] ALIGN32;
u32 fileSize;
fileSize = NANDSeek(&stream->handle.nand, 0, 2);
fileSize = NANDSeek(&stream->handle.nand, 0, NAND_SEEK_END);
if (fileSize >= offset) {
return -3004;
}
@@ -2037,11 +2037,11 @@ s32 WADOpenStream(WADLocation location, const char* path, WADStream* stream, u32
}
fileSize -= writeSize;
}
result = NANDSeek(&stream->handle.nand, offset, 0);
result = NANDSeek(&stream->handle.nand, offset, NAND_SEEK_BEG);
}
return result != offset ? -3004 : 0;
}
result = NANDPrivateOpen(path, &stream->handle.nand, 1);
result = NANDPrivateOpen(path, &stream->handle.nand, NAND_ACCESS_READ);
return result != 0 ? -3004 : result;
}
@@ -2104,7 +2104,7 @@ size_t WADReadStream(WADStream* stream, void** buffer, size_t size, s32 offset)
return DVDReadPrio(&stream->handle.dvd, *buffer, alignedSize, offset, 2);
case WAD_LOCATION_NAND:
result = NANDSeek(&stream->handle.nand, offset, 0);
result = NANDSeek(&stream->handle.nand, offset, NAND_SEEK_BEG);
if ((s32)result >= 0) {
result = NANDRead(&stream->handle.nand, *buffer, alignedSize);
}
@@ -2563,7 +2563,7 @@ static s32 _WADUnpackBackup(WADHeader* header, WADStream* stream, WADUnpackInfo*
goto done;
}
if (currentDeviceId != backupHeader->deviceId) {
return -3008;
return WAD_ERROR_INCORRECT_DEVICE;
}
}
@@ -2588,7 +2588,7 @@ static s32 _WADUnpackBackup(WADHeader* header, WADStream* stream, WADUnpackInfo*
info->titleMetaSize = 1;
result = WADReadStream(stream, (void**)&info->titleMeta, alignedSize,
offset + info->sectionOffset);
if ((s32)result != (s32)alignedSize) {
if (result != (s32)alignedSize) {
return -3005;
}
result = 0;
@@ -2656,7 +2656,7 @@ static s32 _WADGetTransferId(void* transferId) {
s32 result;
valid = FALSE;
result = NANDPrivateOpen("/shared2/succession/transfer.id", &fileInfo, 1);
result = NANDPrivateOpen("/shared2/succession/transfer.id", &fileInfo, NAND_ACCESS_READ);
if (result == 0) {
valid = TRUE;
result = NANDRead(&fileInfo, transferId, 0x20);
@@ -2771,23 +2771,23 @@ static s32 _WADBackupGetFiles(const char* directoryPath, u32 flags, MEMAllocator
if (absolutePaths && strcmp(directoryPath, ".") == 0) {
snprintf(noCopyPath, sizeof(noCopyPath), "%s/%s", currentDirectory, "nocopy");
snprintf(bannerPath, sizeof(bannerPath), "%s/%s", currentDirectory, "banner.bin");
if (strcmp(fullFilePath, noCopyPath) == 0 && fileType == 2) {
if (strcmp(fullFilePath, noCopyPath) == 0 && fileType == NAND_TYPE_DIR) {
goto nextName;
}
if (strcmp(fullFilePath, bannerPath) == 0 && fileType == 1) {
if (strcmp(fullFilePath, bannerPath) == 0 && fileType == NAND_TYPE_FILE) {
goto nextName;
}
} else {
if (strcmp(fullFilePath, "nocopy") == 0 && fileType == 2) {
if (strcmp(fullFilePath, "nocopy") == 0 && fileType == NAND_TYPE_DIR) {
goto nextName;
}
if (strcmp(fullFilePath, "banner.bin") == 0 && fileType == 1) {
if (strcmp(fullFilePath, "banner.bin") == 0 && fileType == NAND_TYPE_FILE) {
goto nextName;
}
}
}
if (fileType == 1) {
result = NANDPrivateOpen(fullFilePath, &fileInfo, 1);
if (fileType == NAND_TYPE_FILE) {
result = NANDPrivateOpen(fullFilePath, &fileInfo, NAND_ACCESS_READ);
closeFile = TRUE;
if (result != 0) {
goto nextName;
@@ -2801,7 +2801,7 @@ static s32 _WADBackupGetFiles(const char* directoryPath, u32 flags, MEMAllocator
if (result != 0) {
goto nextName;
}
} else if (fileType == 2) {
} else if (fileType == NAND_TYPE_DIR) {
if ((flags & 8) == 0) {
goto nextName;
}
@@ -2826,7 +2826,7 @@ static s32 _WADBackupGetFiles(const char* directoryPath, u32 flags, MEMAllocator
if (files != 0) {
file++;
}
if (fileType == 2) {
if (fileType == NAND_TYPE_DIR) {
WADBackupFileHeader* children;
childFileCount = 0;
children = 0;
@@ -3327,7 +3327,7 @@ static s32 _WADVerifySavedataZD(WADSaveDataHeader* header, WADStream* stream,
if (result != 0) {
goto cleanup;
}
result = NANDPrivateOpen(fileHeader->name, &fileInfo, 2);
result = NANDPrivateOpen(fileHeader->name, &fileInfo, NAND_ACCESS_WRITE);
if (result != 0) {
goto cleanup;
}
@@ -3582,7 +3582,7 @@ s32 WADImportDVDExForBS(const char* path, void* buffer, u32 bufferSize) {
goto cleanup;
}
value = DVDReadPrio(&fileInfo, readBuffer, sectionOffset, 0, 2);
if (value != (s32)sectionOffset) {
if (value != sectionOffset) {
result = -3005;
goto cleanup;
}

View File

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

View File

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

View File

@@ -520,7 +520,7 @@ NWC24Err NWC24iInitMsgBoxDir(BOOL force) {
}
result = NANDPrivateReadDir(path, NULL, &num);
if (result == -12) {
if (result == NAND_RESULT_NOEXISTS) {
result = NWC24CreateDir(path);
if (result != NWC24_OK) {
return NWC24_ERR_FATAL;
@@ -531,16 +531,16 @@ NWC24Err NWC24iInitMsgBoxDir(BOOL force) {
if (force) {
result = NANDPrivateDelete(mboxDir);
if (result != 0 && result != -12) {
if (result == -4) {
return -38;
if (result != 0 && result != NAND_RESULT_NOEXISTS) {
if (result == NAND_RESULT_CORRUPT) {
return NWC24_ERR_NAND_CORRUPT;
}
return NWC24_ERR_FATAL;
}
}
result = NWC24CreateDir(mboxDir);
if (result != -15 && result != 0) {
if (result != NWC24_ERR_DONE && result != 0) {
return NWC24_ERR_FATAL;
}

View File

@@ -48,7 +48,7 @@ void* __construct_new_array(void* block, void* ctor, void* dtor, size_t size, si
__partial_array_destructor pad(ptr, size, n, dtor);
char* p;
for (pad.i = 0, p = (char*)ptr; pad.i < n; pad.i++, p += size) {
for (pad.i = 0, p = ptr; pad.i < n; pad.i++, p += size) {
CTORCALL_COMPLETE(ctor, p);
}
}

View File

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

View File

@@ -59,7 +59,7 @@ void SimpleWavePlayer::wavePacketCallback(WavePacketCallbackStatus status, WaveP
return;
}
if (self->mThreadRunning != false) {
if (self->mThreadRunning) {
OSSendMessage(&self->mQueue, packet, 0);
return;
}
@@ -213,11 +213,11 @@ void SimpleWavePlayer::update() {
}
}
void* SimpleWavePlayer::makeWaveProc(void* arg) {
void* SimpleWavePlayer::makeWaveProc(void* context) {
OSMessage msg;
SimpleWavePlayer* self = (SimpleWavePlayer*)arg;
SimpleWavePlayer* self = (SimpleWavePlayer*)context;
while (true) {
OSReceiveMessage(&self->mQueue, &msg, 1);
OSReceiveMessage(&self->mQueue, &msg, OS_MESSAGE_BLOCK);
if (msg == NULL) {
break;
}
@@ -239,15 +239,15 @@ bool SimpleWavePlayer::makeThread(s32 prio, void* stack, u32 stackSize) {
void* SimpleWavePlayer::convertDSPAddr(void* addr, u32 offset, int mode) {
void* out = 0;
switch (mode) {
case 0: {
case AX_SAMPLE_FORMAT_DSP_ADPCM: {
out = (void*)((u32)addr * 2 + offset % 14 + offset / 14 * 16 + 2);
break;
}
case 25: {
case AX_SAMPLE_FORMAT_PCM_S8: {
out = (void*)((u32)addr + offset);
break;
}
case 10: {
case AX_SAMPLE_FORMAT_PCM_S16: {
out = (void*)((u32)addr / 2 + offset);
break;
}

View File

@@ -508,7 +508,7 @@ bool WaveFileAiff::checkFile(const void* _data, u32 _dataLen, bool ignoreSize) {
return false;
}
if (self->mIsLoop != false) {
if (self->mIsLoop) {
// Loop start must be before end, start must be before end of data, end must
// be at or before end of data
if (self->mLoopStart >= self->mLoopEnd) {
@@ -586,7 +586,7 @@ bool WaveFileWav::init(const void* data, u32 dataLen) {
u32 offsetAfterRiffChunk = reader.getOffset();
if (reader.seekChunk('fmt ', fileEnd) == FALSE) {
if (!reader.seekChunk('fmt ', fileEnd)) {
return false;
}
@@ -624,7 +624,7 @@ bool WaveFileWav::init(const void* data, u32 dataLen) {
}
reader.seekTo(offsetAfterRiffChunk);
if (reader.seekChunk('data', fileEnd) == FALSE)
if (!reader.seekChunk('data', fileEnd))
return false;
reader.seekTo(reader.getOffset() - 4);
@@ -658,7 +658,7 @@ bool WaveFileWav::checkFile(const void* data, u32 dataLen, bool ignoreSize) {
u32 offsetAfterRiffChunk = reader.getOffset();
if (reader.seekChunk('fmt ', fileEnd) == FALSE) {
if (!reader.seekChunk('fmt ', fileEnd)) {
return false;
}
@@ -711,7 +711,7 @@ bool WaveFileWav::checkFile(const void* data, u32 dataLen, bool ignoreSize) {
}
reader.seekTo(offsetAfterRiffChunk);
if (reader.seekChunk('data', fileEnd) == FALSE) {
if (!reader.seekChunk('data', fileEnd)) {
return false;
}
@@ -729,7 +729,7 @@ bool WaveFileWav::checkFile(const void* data, u32 dataLen, bool ignoreSize) {
// Loop start must be before end, start must be before end of data, end must
// be at or before end of data
if (mIsLoop != false) {
if (mIsLoop) {
if (mLoopStart >= mLoopEnd) {
return false;
}

View File

@@ -34,7 +34,7 @@ inline u8* getCurrAddr(VoiceInfo* voice) {
inline bool currAddrInZeroBuf(VoiceInfo* currVoice) {
nw4r::ut::AutoInterruptLock lock;
u8* apbCurrAddr = getCurrAddr(currVoice);
u8* zeroBufAddr = (u8*)SimpleWavePlayer::convertDSPAddr(zeroBuffer, 0, 0);
u8* zeroBufAddr = (u8*)SimpleWavePlayer::convertDSPAddr(zeroBuffer, 0, AX_SAMPLE_FORMAT_DSP_ADPCM);
if (zeroBufAddr <= apbCurrAddr && apbCurrAddr < zeroBufAddr + 0x200) {
return true;
} else {
@@ -278,7 +278,7 @@ int AxAdpcmSimplePlayer::start(void* data, u32 length, AxAdpcmHandle* handle) {
coeffsBufB[i] = ADD_OFFSET(AdpcmCoeffs, infoBlockDataBase, chanInfo->coeffOff);
pAxvpbBuf = axVoiceBuf;
pAxvpbBuf[i] = AXAcquireVoice(0x1f, VoiceCallback, 0);
pAxvpbBuf[i] = AXAcquireVoice(AX_PRIORITY_MAX, VoiceCallback, 0);
if (pAxvpbBuf[i] == NULL) {
chanCount = 0;
break;
@@ -293,20 +293,20 @@ int AxAdpcmSimplePlayer::start(void* data, u32 length, AxAdpcmHandle* handle) {
axAdpcmLoop.loop_yn1 = coeffsBufB[i]->cfg.loopYn1;
// @bug Doesn't copy the loop value correctly :(
axAdpcmLoop.loop_yn2 = coeffsBufB[i]->cfg.loopYn1;
loopAddr = SimpleWavePlayer::convertDSPAddr(chanDataBuf[i], infoBlock->loopStart, 0);
loopAddr = SimpleWavePlayer::convertDSPAddr(chanDataBuf[i], infoBlock->loopStart, AX_SAMPLE_FORMAT_DSP_ADPCM);
} else {
loopAddr = SimpleWavePlayer::convertDSPAddr(zeroBuffer, 0, 0);
loopAddr = SimpleWavePlayer::convertDSPAddr(zeroBuffer, 0, AX_SAMPLE_FORMAT_DSP_ADPCM);
}
void* chanData = chanDataBuf[i];
axAddr.loopAddressHi = (u32)loopAddr >> 0x10;
axAddr.loopAddressLo = (u32)loopAddr;
void* endAddr = SimpleWavePlayer::convertDSPAddr(chanData, infoBlock->loopEnd, 0);
void* endAddr = SimpleWavePlayer::convertDSPAddr(chanData, infoBlock->loopEnd, AX_SAMPLE_FORMAT_DSP_ADPCM);
axAddr.endAddressHi = (u32)endAddr >> 0x10;
axAddr.endAddressLo = (u32)endAddr & 0xFFFF;
void* currAddr = SimpleWavePlayer::convertDSPAddr(chanData, 0, 0);
void* currAddr = SimpleWavePlayer::convertDSPAddr(chanData, 0, AX_SAMPLE_FORMAT_DSP_ADPCM);
axAddr.currentAddressHi = (u32)currAddr >> 0x10;
axAddr.currentAddressLo = (u32)currAddr & 0xFFFF;
@@ -337,7 +337,7 @@ int AxAdpcmSimplePlayer::start(void* data, u32 length, AxAdpcmHandle* handle) {
axSrc.last_samples[3] = axSrc.last_samples[2] = axSrc.last_samples[1] = axSrc.last_samples[0] = axSrc.currentAddressFrac = 0;
AXVPB* vpbA = pAxvpbBuf[i];
AXSetVoiceType(vpbA, 0);
AXSetVoiceType(vpbA, AX_VOICE_NORMAL);
AXSetVoiceAddr(vpbA, &axAddr);
AXSetVoiceAdpcm(vpbA, &axAdpcm);
AXSetVoiceAdpcmLoop(vpbA, &axAdpcmLoop);

File diff suppressed because it is too large Load Diff

View File

@@ -125,7 +125,7 @@ namespace ipl {
s32 type = typeArg->value.int_v;
ipl::layout::Animator* anim = *static_cast<ipl::layout::Animator**>(*parentObj->value.ptr_v);
if (anim != NULL) {
if (type >= 0 && type < 4) {
if (type >= ANIM_TYPE_FORWARD && type < ANIM_TYPE_ALTERNATE + 1) {
anim->setAnmType(type);
ret = TRUE;
}
@@ -235,10 +235,10 @@ namespace ipl {
};
const CHANSVmPropertyList cPropertyList[] = {
{"*TYPE_FORWARD", util::get_int<0>, NULL},
{"*TYPE_BACKWARD", util::get_int<1>, NULL},
{"*TYPE_LOOP", util::get_int<2>, NULL},
{"*TYPE_ALTERNATE", util::get_int<3>, NULL},
{"*TYPE_FORWARD", util::get_int<ANIM_TYPE_FORWARD>, NULL},
{"*TYPE_BACKWARD", util::get_int<ANIM_TYPE_BACKWARD>, NULL},
{"*TYPE_LOOP", util::get_int<ANIM_TYPE_LOOP>, NULL},
{"*TYPE_ALTERNATE", util::get_int<ANIM_TYPE_ALTERNATE>, NULL},
};
BOOL init(CHANSVm* vm) {

View File

@@ -93,12 +93,12 @@ namespace ipl {
// clang-format off
const CHANSVmPropertyList cPropertyList[LAYOUT_PROPERTY_COUNT] = {
{"*VERTEXCOLOR_LT", util::get_int<0>, NULL},
{"*VERTEXCOLOR_RT", util::get_int<1>, NULL},
{"*VERTEXCOLOR_LB", util::get_int<2>, NULL},
{"*VERTEXCOLOR_RB", util::get_int<3>, NULL},
{"*TEXTCOLOR_TOP", util::get_int<0>, NULL},
{"*TEXTCOLOR_BOTTOM", util::get_int<1>, NULL},
{"*VERTEXCOLOR_LT", util::get_int<nw4r::lyt::VERTEXCOLOR_LT>, NULL},
{"*VERTEXCOLOR_RT", util::get_int<nw4r::lyt::VERTEXCOLOR_RT>, NULL},
{"*VERTEXCOLOR_LB", util::get_int<nw4r::lyt::VERTEXCOLOR_LB>, NULL},
{"*VERTEXCOLOR_RB", util::get_int<nw4r::lyt::VERTEXCOLOR_RB>, NULL},
{"*TEXTCOLOR_TOP", util::get_int<nw4r::lyt::TEXTCOLOR_TOP>, NULL},
{"*TEXTCOLOR_BOTTOM", util::get_int<nw4r::lyt::TEXTCOLOR_BOTTOM>, NULL},
};
// clang-format on
} // namespace layout

View File

@@ -54,7 +54,7 @@ namespace ipl {
u32 argc = CHANSVmGetArgc(vm);
colorIndexArg = CHANSVmGetArgInteger(vm, 0);
if (mat != NULL && argc == 1 && colorIndexArg != NULL) {
if (colorIndexArg->value.int_v < 3ULL) {
if (colorIndexArg->value.int_v < static_cast<u64>(nw4r::lyt::TEVCOLOR_MAX)) {
result = color_s10::_ctor(vm, returnObj, mat->GetTevColor(colorIndexArg->value.int_v)) == TRUE;
}
}
@@ -74,7 +74,7 @@ namespace ipl {
colorIndexArg = CHANSVmGetArgInteger(vm, 0);
colorArg = CHANSVmGetArg(vm, 1);
if (mat != NULL && argc == 2 && colorIndexArg != NULL && util::is_valid_class(colorArg, "GXColorS10")) {
if (colorIndexArg->value.int_v < 3ULL) {
if (colorIndexArg->value.int_v < static_cast<u64>(nw4r::lyt::TEVCOLOR_MAX)) {
mat->SetTevColor(colorIndexArg->value.int_v, *static_cast<GXColorS10*>(*colorArg->value.ptr_v));
result = TRUE;
}
@@ -93,7 +93,7 @@ namespace ipl {
u32 argc = CHANSVmGetArgc(vm);
colorIndexArg = CHANSVmGetArgInteger(vm, 0);
if (mat != NULL && argc == 1 && colorIndexArg != NULL) {
if (colorIndexArg->value.int_v < 4ULL) {
if (colorIndexArg->value.int_v < static_cast<u64>(GX_MAX_KCOLOR)) {
result = color::_ctor(vm, returnObj, mat->GetTevKColor(colorIndexArg->value.int_v).ToU32()) == TRUE;
}
}
@@ -113,7 +113,7 @@ namespace ipl {
colorIndexArg = CHANSVmGetArgInteger(vm, 0);
colorArg = CHANSVmGetArg(vm, 1);
if (mat != NULL && argc == 2 && colorIndexArg != NULL && util::is_valid_class(colorArg, "Color")) {
if (colorIndexArg->value.int_v < 4ULL) {
if (colorIndexArg->value.int_v < static_cast<u64>(GX_MAX_KCOLOR)) {
mat->SetTevKColor(colorIndexArg->value.int_v, *static_cast<nw4r::ut::Color*>(*colorArg->value.ptr_v));
result = TRUE;
}

View File

@@ -13,7 +13,7 @@ extern "C" const u8 scCsFatalColorA;
if (!(x)) { \
GXColor front = {scCsFatalColorR, scCsFatalColorG, scCsFatalColorB, scCsFatalColorA}; \
GXColor back = {0, 0, 0, 0}; \
OSFatal((GXColor)front, (GXColor)back, scCsFatalMsg); \
OSFatal(front, back, scCsFatalMsg); \
} \
}
@@ -376,7 +376,7 @@ namespace ipl {
u32 argc = CHANSVmGetArgc(VmInst);
CHANSVmObjHdr* vertexIndexArg = CHANSVmGetArgInteger(VmInst, 0);
if (pane != NULL && argc == 1 && vertexIndexArg != NULL) {
if (vertexIndexArg->value.int_v < 4ULL) {
if (vertexIndexArg->value.int_v < static_cast<u64>(nw4r::lyt::VERTEXCOLOR_MAX)) {
result = color::_ctor(VmInst, VmReturnObj, (nw4r::ut::Color) static_cast<u32>(pane->GetVtxColor(vertexIndexArg->value.int_v))) == TRUE;
}
}
@@ -432,7 +432,7 @@ namespace ipl {
CHANSVmObjHdr* colorIndexArg = CHANSVmGetArgInteger(VmInst, 0);
CHANSVmObjHdr* colorArg = CHANSVmGetArg(VmInst, 1);
if (box != NULL && argc == 2 && colorIndexArg != NULL && util::is_valid_class(colorArg, "Color")) {
if (colorIndexArg->value.int_v < 2ULL) {
if (colorIndexArg->value.int_v < static_cast<u64>(nw4r::lyt::TEXTCOLOR_MAX)) {
u8* src = static_cast<u8*>(*colorArg->value.ptr_v);
box->SetTextColor(static_cast<s32>(colorIndexArg->value.int_v), *(nw4r::ut::Color*)src);
result = TRUE;

View File

@@ -73,7 +73,7 @@ namespace ipl {
error = load_vf_(vm, data, heap, offset, size, 0x20);
}
result = (u32)(error - 2) != 0;
result = error != 2;
if (result) {
if (data->pData != NULL || data->size != 0) {
data->flag = 0;
@@ -145,7 +145,7 @@ namespace ipl {
delete[] oldBuf;
}
result = (error - 2) != 0;
result = error != 2;
}
CHANSVmSetInteger(vm, returnObj, error == 0);
@@ -164,9 +164,9 @@ namespace ipl {
get_fullpath(pathBuf, data->sPath);
fileSize = 0;
if (nand::wrapper::PrivateOpen(pathBuf, &fileInfo, 1) == 0) {
if (nand::wrapper::GetLength(&fileInfo, &fileSize) == 0) {
if (offset == 0 || (offset > 0 && offset < fileSize && nand::wrapper::Seek(&fileInfo, offset, 0) > 0)) {
if (nand::wrapper::PrivateOpen(pathBuf, &fileInfo, NAND_ACCESS_READ) == NAND_RESULT_OK) {
if (nand::wrapper::GetLength(&fileInfo, &fileSize) == NAND_RESULT_OK) {
if (offset == 0 || (offset > 0 && offset < fileSize && nand::wrapper::Seek(&fileInfo, offset, NAND_SEEK_BEG) > 0)) {
if (size != 0 && size + offset <= fileSize) {
fileSize = size;
} else {
@@ -187,7 +187,7 @@ namespace ipl {
result = 2;
}
if (nand::wrapper::Close(&fileInfo) != 0) {
if (nand::wrapper::Close(&fileInfo) != NAND_RESULT_OK) {
result = 2;
}
}
@@ -204,15 +204,15 @@ namespace ipl {
s32 fileSize;
memset(mountBuf, 0, sizeof(mountBuf));
get_fullpath(mountBuf, (const char*)data);
if (VFMountDriveNANDFlashEx("@CS", mountBuf) == 0) {
get_fullpath(mountBuf, data->sMountPath);
if (VFMountDriveNANDFlashEx("@CS", mountBuf) == VF_ERR_SUCCESS) {
memset(vfPath, 0, sizeof(vfPath));
snprintf(vfPath, 0x103, "%s:/%s", "@CS", data->sPath);
fd = VFOpenFile(vfPath, "r", 0);
if (fd != NULL) {
fileSize = VFGetFileSizeByFd(fd);
if (fileSize > 0) {
if (offset == 0 || offset > 0 && (u32)offset < fileSize && VFSeekFile(fd, offset, 0) == 0) {
if (offset == 0 || offset > 0 && (u32)offset < fileSize && VFSeekFile(fd, offset, VF_SEEK_ORIGIN_BEGIN) == VF_ERR_SUCCESS) {
if (readSize != 0) {
if (readSize + offset <= fileSize) {
fileSize = readSize;
@@ -220,7 +220,7 @@ namespace ipl {
}
u8* buf = new (heap, align) u8[fileSize];
if (buf != NULL && VFReadFile(fd, buf, fileSize, &readSize) == 0) {
if (buf != NULL && VFReadFile(fd, buf, fileSize, &readSize) == VF_ERR_SUCCESS) {
DCStoreRange(buf, readSize);
data->pData = buf;
@@ -234,11 +234,11 @@ namespace ipl {
result = 2;
}
if (VFCloseFile(fd) != 0) {
if (VFCloseFile(fd) != VF_ERR_SUCCESS) {
result = 2;
}
}
if (VFUnmountDrive("@CS") != 0) {
if (VFUnmountDrive("@CS") != VF_ERR_SUCCESS) {
result = 2;
}
}
@@ -427,7 +427,7 @@ namespace ipl {
u8* src = data->pData + dataOffset;
if (format != 4 && format != 6) {
if (format != GX_TF_RGB565 && format != GX_TF_RGBA8) {
goto exit;
}

View File

@@ -24,7 +24,7 @@ namespace ipl {
}
CHANSVmDefineMethod(start_default_sound) {
System::getCSManager()->setAltBannerSoundState(1);
System::getCSManager()->setAltBannerSoundState(channel::CHANS_VM_ALT_SND_STATE_FALLBACK);
return TRUE;
}

View File

@@ -10,7 +10,7 @@ namespace ipl {
CHANSVmDefineMethod(is_first_call) {
BOOL result = FALSE;
if (util::is_valid_datap(VmParentObj)) {
result = CHANSVmSetInteger(VmInst, VmReturnObj, System::getCSManager()->getData().threadTerminated == false) == CHANS_VM_OK;
result = CHANSVmSetInteger(VmInst, VmReturnObj, !System::getCSManager()->getData().threadTerminated) == CHANS_VM_OK;
}
return result;
}

View File

@@ -19,8 +19,9 @@ namespace ipl {
found = FALSE;
// Cleaning this part breaks the match...
if (!(formatValue > 14)) {
if (1 << formatIndex & 0x407F) {
if (!(formatValue > GX_TF_CMPR)) {
if (1 << formatIndex & ((1 << GX_TF_I4) | (1 << GX_TF_I8) | (1 << GX_TF_IA4) | (1 << GX_TF_IA8) |
(1 << GX_TF_RGB565) | (1 << GX_TF_RGB5A3) | (1 << GX_TF_RGBA8) | (1 << GX_TF_CMPR))) {
found = TRUE;
}
}
@@ -33,7 +34,7 @@ namespace ipl {
BOOL is_valid_wrap(const CHANSVmObjHdr* obj) {
BOOL result = FALSE;
if (obj != NULL && obj->value.int_v <= 2ULL) {
if (obj != NULL && obj->value.int_v <= static_cast<u64>(GX_MIRROR)) {
result = TRUE;
}
return result;
@@ -126,7 +127,7 @@ namespace ipl {
CHANSVmObjHdr* imageArg = CHANSVmGetArg(VmInst, 0);
if (CHANSVmCheckNativeInstance(imageArg, "Image")) {
if (util::is_valid_datap(imageArg)) {
u32 addr = *(u32*)*imageArg->value.ptr_v;
u32 addr = reinterpret_cast<u32>(static_cast<CHANSVmImage*>(*imageArg->value.ptr_v)->pData);
result = init_texobj(VmInst, VmReturnObj, addr);
}
} else {

View File

@@ -1319,7 +1319,7 @@ namespace homebutton {
}
static void MotorCallback(OSAlarm* pAlarm, OSContext* pContext) {
Controller* pController = reinterpret_cast<Controller*>(OSGetAlarmUserData(pAlarm));
Controller* pController = static_cast<Controller*>(OSGetAlarmUserData(pAlarm));
pController->stopMotor();
}
@@ -1444,7 +1444,7 @@ namespace homebutton {
getController(i)->connect();
getController(i)->startMotor();
OSSetAlarmUserData(&mAlarm[i], reinterpret_cast<void*>(getController(i)));
OSSetAlarmUserData(&mAlarm[i], getController(i));
OSCancelAlarm(&mAlarm[i]);
OSSetAlarm(&mAlarm[i], OSMillisecondsToTicks(300), &MotorCallback);
@@ -2582,7 +2582,7 @@ namespace homebutton {
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, 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);
GXSetNumChans(1);
GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE);

View File

@@ -55,7 +55,7 @@ namespace homebutton {
// Animate and alternate direction; Once reaching the maximum frame, it then animates forwards.
// And once reaching the minimum frame, it animates backwards. Then repeat.
case ANIM_TYPE_ALTERNATE: {
if (mbAlternateBack == false) {
if (!mbAlternateBack) {
if ((mFrame += mDelta) >= getLastFrame()) {
mFrame = getLastFrame();
mbAlternateBack = true;

View File

@@ -10,13 +10,13 @@ namespace homebutton {
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
GXSetCullMode(GX_CULL_NONE);
GXSetNumChans(1);
GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE);
GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_VTX, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE);
GXSetNumTexGens(0);
GXSetNumTevStages(1);
@@ -28,7 +28,7 @@ namespace homebutton {
Mtx mtx;
MTXTrans(mtx, 0.0f, 0.0f, 0.0f);
GXLoadPosMtxImm(mtx, 0);
GXLoadPosMtxImm(mtx, GX_PNMTX0);
GXSetLineWidth(width, GX_TO_ZERO);

View File

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

View File

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

View File

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

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