Compare commits

..

1 Commits

Author SHA1 Message Date
coah
379c84d5f6 fix(TMC_JPEG): use consistent two-dimensional sampling tables 2026-10-05 09:32:25 -05:00
142 changed files with 1348 additions and 13890 deletions

View File

@@ -144,7 +144,7 @@ lbl_810C8A80 = .bss:0x810C8A80; // type:object size:0x40 align:32
lbl_810C8AC0 = .bss:0x810C8AC0; // type:object size:0x40 align:32
s_mutex = .bss:0x810C8B00; // type:object size:0x18 scope:local
s_cdbWiiId = .bss:0x810C8B20; // type:object size:0x40 scope:local
ncdMutex = .bss:0x810C8B60; // type:object size:0x18
ncdMutex = .bss:0x810C8B60; // type:object size:0x20
ncdCommonResult = .bss:0x810C8B80; // type:object size:0x20 align:32 data:4byte
ncdCommonVector = .bss:0x810C8BA0; // type:object size:0x20 align:32 data:4byte
NHTTPiStaticResource = .bss:0x810C8BC0; // type:object size:0x40 data:4byte
@@ -15632,7 +15632,7 @@ __vt__Q33ipl4math28LinearIntp<Q33ipl4math4VEC2> = .data:0x8164B5E0; // type:obje
__vt__Q33ipl4math31Interporation<Q33ipl4math4VEC2> = .data:0x8164B5F0; // type:object size:0x10
@10018 = .data:0x8164B698; // type:object size:0xB scope:local data:string
@10019 = .data:0x8164B6A3; // type:object size:0xF scope:local data:string
__vt__Q33ipl5scene12UrlProcessor = .data:0x8164B6B8; // type:object size:0x14
__vt__Q33ipl5scene12UrlProcessor = .data:0x8164B6B8; // type:object size:0x18
lbl_8164B6D0 = .data:0x8164B6D0; // type:object size:0x10 data:string
lbl_8164B6E0 = .data:0x8164B6E0; // type:object size:0x1D data:string
lbl_8164B6FD = .data:0x8164B6FD; // type:object size:0x1B data:string
@@ -15765,8 +15765,7 @@ lbl_8164C53A = .data:0x8164C53A; // type:object size:0x14
lbl_8164C54E = .data:0x8164C54E; // type:object size:0x18
lbl_8164C566 = .data:0x8164C566; // type:object size:0xC
lbl_8164C572 = .data:0x8164C572; // type:object size:0xA
__vt__Q33ipl5scene8Calendar = .data:0x8164C57C; // type:object size:0x88
__vt__Q23gui12EventHandler = .data:0x8164C604; // type:object size:0x18 scope:weak
__vt__Q33ipl5scene8Calendar = .data:0x8164C57C; // type:object size:0xA4
scN_CalDay_r = .data:0x8164C620; // type:object size:0xB data:string
scDateAnimPaneNames = .data:0x8164C62C; // type:object size:0x14 data:4byte
scMyIplTopFBrlan = .data:0x8164C640; // type:object size:0x12 data:string

View File

@@ -983,10 +983,10 @@ config.libs = [
ZI8Lib("zi8clib", [
Object(Matching, "clib/zaddress.c"),
Object(Matching, "clib/zconvert.c"),
Object(Matching, "clib/zi81key.c"),
Object(NonMatching, "clib/zi81key.c"),
Object(NonMatching, "clib/zi8alpha.c"),
Object(Matching, "clib/zi8alts.c"),
Object(Matching, "clib/zi8cgetc.c"),
Object(NonMatching, "clib/zi8cgetc.c"),
Object(Matching, "clib/zi8cinfo.c"),
Object(Matching, "clib/zi8copy.c"),
Object(Matching, "clib/zi8dawg.c"),
@@ -1000,17 +1000,17 @@ config.libs = [
Object(Matching, "clib/zi8pud2.c"),
Object(Matching, "clib/Zi8punct.c"),
Object(Matching, "clib/zi8space.c"),
Object(Matching, "clib/zi8uwd.c"),
Object(NonMatching, "clib/zi8uwd.c"),
Object(Matching, "clib/zi8ver.c"),
Object(Matching, "clib/zi8ZHuwd.c"),
Object(Matching, "clib/zidawg1.c"),
Object(Matching, "clib/zikorean.c"),
Object(Matching, "clib/ziswordw.c"),
Object(Matching, "clib/zkokeyp.c"),
Object(NonMatching, "clib/zkokeyp.c"),
Object(Matching, "clib/zierror.c"),
Object(Matching, "clib/zmtkey.c"),
Object(Matching, "clib/zoemdata.c"),
Object(Matching, "clib/zprepare.c"),
Object(NonMatching, "clib/zprepare.c"),
]
),
# RevoEX

View File

@@ -1,7 +1,7 @@
# Assembly inventory
4.3U, 2026-10-05. 173 functions contain 175 assembly
bodies/blocks: 162 ORIGINAL functions and 10 PLACEHOLDER functions.
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,
@@ -189,6 +189,7 @@ found. Historical logs absent from this branch have commit IDs and excerpts in
| `src/BS2/BS2Start.c` | `__start` | ORIGINAL | Runs before the C stack and ABI registers exist; constructs the initial stack. |
| `src/BS2/BS2Start.c` | `__init_registers` | ORIGINAL | Initializes GPRs, r1, r2, and r13 for the C runtime. |
| `src/scene/nakamuraTest/gamespy/common/gsPlatformUtil.c` | `GetTicks` | ORIGINAL | Inactive PS2 branch reads the CP0 Count register with mfc0 $9. |
| `src/system/TVRC.cpp` | `TVRCSendStartAsync` | PLACEHOLDER | IR command setup; best recorded C 99.77273%, 198/198 instructions, seven differences, [rx2](../tools/decomp-assist/rx2.attempts.md); newer [rx17][rx17] 99.747475%. |
| `src/system/iplChannelManager.cpp` | `getTitleName__Q33ipl7channel7ManagerCFiii` | PLACEHOLDER | Channel-name copying; best C 99.57746%, 71/71 instructions, four address-order differences, [rx17][rx17]. |
| `src/system/iplSaveDataManager.cpp` | `Manager::hasChannel` | PLACEHOLDER | Title-slot search; best C 98.87324%, 71/71 instructions, 14 mask/base register differences, [rx30][rx30]. |
| `src/system/iplSaveDataManager.cpp` | `Manager::makePriorTitleIDList` | PLACEHOLDER | Title filtering; best recorded C 80.22556%, 124/133 instructions, address CSE, [da1](../tools/decomp-assist/da1.attempts.md); newer [rx17][rx17] 79.827065%. |

View File

@@ -96,11 +96,7 @@ namespace textinput {
#else
virtual void sendCommand(u32, void*);
#endif
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
virtual void updateFromReceiver(u32, void*);
#else
virtual void updateFromReceiver(u32, void*) {}
#endif
nw4r::ut::Link mLink; // 0x00

View File

@@ -432,8 +432,8 @@ static void* allocate_from_var_pools(__mem_pool_obj* pool, unsigned int size, un
}
static void* soft_allocate_from_var_pools(__mem_pool_obj* pool, unsigned int size, unsigned int* out) {
Block* bp;
SubBlock* ptr;
register Block* bp;
register SubBlock* ptr;
size = (size + 15) & ~7;
if (size < 0x50) {
@@ -681,9 +681,9 @@ static unsigned int __pool_allocate_resize(__mem_pool_obj* pool, void* ptr, unsi
return 0;
}
void* malloc(unsigned int size) {
void* malloc(register unsigned int size) {
void* rv;
__mem_pool_obj* pool_obj;
register __mem_pool_obj* pool_obj;
if (size == 0) {
goto null_return;
@@ -712,8 +712,8 @@ void free(void* ptr) {
}
void* realloc(void* ptr, unsigned int size) {
unsigned int rv = size;
__mem_pool_obj* pool;
register unsigned int rv = size;
register __mem_pool_obj* pool;
unsigned int current_size;
unsigned int orig_size;
@@ -773,8 +773,8 @@ void* realloc(void* ptr, unsigned int size) {
}
void* calloc(unsigned int nmemb, unsigned int size) {
void* ptr;
unsigned int total;
register void* ptr;
register unsigned int total;
__mem_pool_obj* pool_obj;
pool_obj = (__mem_pool_obj*)get_malloc_pool();

View File

@@ -742,7 +742,7 @@ int __sformatter(int (*ReadProc)(void*, int, int), void* ReadProcArg, const char
*(long*)arg_ptr = chars_read;
break;
case char_argument:
*arg_ptr = chars_read;
*(char*)arg_ptr = chars_read;
break;
case long_long_argument:
*(long long*)arg_ptr = chars_read;

View File

@@ -552,6 +552,8 @@ long double __strtold(int max_width, int (*ReadProc)(void*, int, int), void* Rea
if (sig_negative && success(scan_state)) {
result = -result;
}
return result;
} else {
unsigned mantissa_bit, dbl_bit;
unsigned one_bit;
@@ -628,8 +630,9 @@ long double __strtold(int max_width, int (*ReadProc)(void*, int, int), void* Rea
}
result = *(long double*)dbl_bits;
return result;
}
return result;
}
double strtod(const char* str, char** end) {

View File

@@ -17,7 +17,7 @@ wchar_t* wmemset(wchar_t* dest, wchar_t ch, size_t num) {
wchar_t* wmemchr(wchar_t* ptr, wchar_t ch, size_t num) {
while (num != 0) {
if (*ptr == ch) {
return ptr;
return (wchar_t*)ptr;
}
ptr++;

View File

@@ -28,7 +28,7 @@ namespace nw4r {
}
void WsdTrack::Start(const void* wsdData, int index) {
mWsdData = wsdData;
mWsdData = (void*)wsdData;
mIndex = index;
}

View File

@@ -77,17 +77,17 @@ namespace nw4r {
dataSheetsOff = ROUNDUP(offsetof(ArchiveFontBinaryLayout, glgr.inner.nameOffsets) + countName * sizeof(u16), 4);
data0AOff = ROUNDUP(dataSheetsOff + countSheet * sizeof(u32), 4);
data0COff = ROUNDUP(data0AOff + count0A * sizeof(u32), 4);
dataSheets = (const u32*)(dataSheetsOff + (u32)fontData);
data0A = (const u32*)(data0AOff + (u32)fontData);
data0C = (const u32*)(data0COff + (u32)fontData);
dataSheets = (const u32*)((u32)dataSheetsOff + (u32)fontData);
data0A = (const u32*)((u32)data0AOff + (u32)fontData);
data0C = (const u32*)((u32)data0COff + (u32)fontData);
flagsSheetsOff = ROUNDUP(data0COff + count0CWork * sizeof(u32), 4);
flags0AOff = ROUNDUP(flagsSheetsOff + stepSheets * countName, 4);
flags0COff = ROUNDUP(flags0AOff + step0A * countName, 4);
flagsSheets = (const u32*)(flagsSheetsOff + (u32)fontData);
flags0A = (const u32*)(flags0AOff + (u32)fontData);
flags0C = (const u32*)(flags0COff + (u32)fontData);
flagsSheets = (const u32*)((u32)flagsSheetsOff + (u32)fontData);
flags0A = (const u32*)((u32)flags0AOff + (u32)fontData);
flags0C = (const u32*)((u32)flags0COff + (u32)fontData);
loadedSheetCount = 0;
loadedSmth0ASize = 0;
@@ -102,7 +102,7 @@ namespace nw4r {
offsetPGlgr = (const HeaderedGlyphGroups*)((const u8*)offsetPGlgr + 2), j++) {
groupName = (const char*)((u32)offsetPGlgr->inner.nameOffsets[0] + (u32)fontData);
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
flagWord |= *(const u32*)(offsetFlags + ROUNDDOWN(j * stepSheets, 4));
flagWord |= *(const u32*)((const u8*)offsetFlags + ROUNDDOWN(j * stepSheets, 4));
}
}
@@ -119,11 +119,11 @@ namespace nw4r {
groupOffset = pGlgr->inner.nameOffsets[j];
groupName = (const char*)(groupOffset + (u32)fontData);
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
flagWord |= *(const u32*)(offsetFlags + ROUNDDOWN(j * step0A, 4));
flagWord |= *(const u32*)((const u8*)offsetFlags + ROUNDDOWN(j * step0A, 4));
}
}
offsetData = data0A + i * 32;
offsetData = (const u32*)data0A + i * 32;
for (j = 0; j < 32; j++) {
if ((flagWord << j) & 0x80000000U) {
loadedSmth0ASize += offsetData[j] - sizeof(BinaryBlockHeader);
@@ -140,11 +140,11 @@ namespace nw4r {
groupOffset = pGlgr->inner.nameOffsets[j];
groupName = (const char*)(groupOffset + (u32)fontData);
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
flagWord |= *(const u32*)(offsetFlags + ROUNDDOWN(j * step0C, 4));
flagWord |= *(const u32*)((const u8*)offsetFlags + ROUNDDOWN(j * step0C, 4));
}
}
offsetData = data0C + i * 32;
offsetData = (const u32*)data0C + i * 32;
for (j = 0; j < 32; j++) {
if ((flagWord << j) & 0x80000000U) {
loadedSmth0CSize += offsetData[j] - sizeof(BinaryBlockHeader);

View File

@@ -23,8 +23,8 @@ const ziWChar Zi8PunctTable[40] = {
0xFFE1, 0x20AC, 0x203B, 0xFF20, 0x0000,
};
ziU32 Zi8Punctuation(ziGetParam* param, ZiCandidateOptions* options ZI_NEED_WORK) {
ziS32 limit = options->capacity - 1;
ziU32 Zi8Punctuation(ziGetParam* param, ziPtr options ZI_NEED_WORK) {
ziS32 limit = ((ZiCandidateOptions*)options)->capacity - 1;
ziS32 count = 0;
ziU8 i = 0;
ziU16 fc = param->firstCandidate;
@@ -36,11 +36,11 @@ ziU32 Zi8Punctuation(ziGetParam* param, ZiCandidateOptions* options ZI_NEED_WORK
}
if (fc == 0) {
count++;
if (options->countOnly == 0) {
if (((ZiCandidateOptions*)options)->countOnly == 0) {
param->candidates[i++] = Zi8PunctTable[j];
if ((param->context & 0x10) != 0) {
param->candidates[i++] = 0x20;
if (i >= limit) {
if ((ziU8)i >= limit) {
break;
}
}
@@ -48,7 +48,7 @@ ziU32 Zi8Punctuation(ziGetParam* param, ZiCandidateOptions* options ZI_NEED_WORK
break;
}
} else {
if (count >= (ziS32)options->maxCount) {
if (count >= (ziS32)((ZiCandidateOptions*)options)->maxCount) {
return count;
}
}
@@ -57,7 +57,7 @@ ziU32 Zi8Punctuation(ziGetParam* param, ZiCandidateOptions* options ZI_NEED_WORK
}
j++;
}
if (options->countOnly == 0) {
if (((ZiCandidateOptions*)options)->countOnly == 0) {
param->letters = count;
}
return count;

View File

@@ -10,21 +10,21 @@ ziU8 Zi8LangSupported(ziU8 lang ZI_NEED_WORK) {
return 0;
}
for (i = 0; ZI_WORK->langEntries[i].language != ZI8_LANG_NONE; i++) {
for (i = 0; ZI_WORK->langEntries[i].language != 0; i++) {
if (lang == ZI_WORK->langEntries[i].language) {
break;
}
}
if (ZI_WORK->langEntries[i].language == ZI8_LANG_NONE) {
for (i = 0; ZI_WORK->langEntries[i].language != ZI8_LANG_NONE; i++) {
if (ZI_WORK->langEntries[i].language == 0) {
for (i = 0; ZI_WORK->langEntries[i].language != 0; i++) {
if ((ZI_WORK->langEntries[i].tableData != ZI8_NULL) && (lang == ZI_WORK->langEntries[i].tableData[0])) {
break;
}
}
}
if (ZI_WORK->langEntries[i].language != ZI8_LANG_NONE) {
if (ZI_WORK->langEntries[i].language != 0) {
return i + 1;
} else {
Zi8ReplaceLastError(0x582, ZI_WORK);
@@ -89,19 +89,19 @@ ziU32 Zi8GetTableData(ziU8 lang, ziU8 tableIdx, ziU8 memberId ZI_NEED_WORK) {
}
ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK) {
return Zi8GetTableData(lang, tableIdx, ziTableAddress, ZI_WORK);
return Zi8GetTableData(lang, tableIdx, 1, ZI_WORK);
}
ziU32 Zi8GetTableSize(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK) {
return Zi8GetTableData(lang, tableIdx, ziTableSize, ZI_WORK);
return Zi8GetTableData(lang, tableIdx, 2, ZI_WORK);
}
ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK) {
return Zi8GetTableData(lang, tableIdx, ziTableSize, ZI_WORK);
return Zi8GetTableData(lang, tableIdx, 2, ZI_WORK);
}
ziU8 Zi8GetFormatVersion(ziU8 lang ZI_NEED_WORK) {
return Zi8GetTableData(lang, 0, ziTableFormatVersion, ZI_WORK);
return Zi8GetTableData(lang, 0, 4, ZI_WORK);
}
ziU32 Zi8WCharCount(ziWChar* str ZI_NEED_WORK) {

View File

@@ -104,7 +104,7 @@ ziChar Zi8ConvertWC2UC(ziWChar character, ziU8 language ZI_NEED_WORK) {
}
entry = (ziConversionEntry*)((ziU8*)table + value + character - first + 8);
Zi8LogError(100, __zi8_work_data);
return entry->first[0];
return *(ziU8*)entry;
}
Zi8LogError(0x6C2, __zi8_work_data);
return 0;

View File

@@ -185,7 +185,7 @@ extern ziU16 Zi8Ord2Ord(ziU16, ziPtr);
extern ziU8 Zi8LangSupported(ziU8, ziPtr);
extern ziU16 Zi8GetTableCount(ziU8,ziU8,ziPtr);
extern ziU32 Zi8GetTableAddress(ziU8,ziU8,ziPtr);
extern ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
extern void Zi8Memset(ziU8*,ziU32,ziS32);
extern ziU8 _Zi8GetCandidates(ziGetParam*,ziPtr);
extern void Zi8InitDupWordBuf(ziPtr);
extern ziU32 Zi8GetPInfo(ziU32,ziWChar *,ziU8,ziPtr);
@@ -778,7 +778,7 @@ ziU32 Zi8Get1KeyPressSpelling(ziGetParam *params,Zi8OneKeyOptions *options,Zi8On
if (options->countOnly == '\0') {
*output++ = spellingBuffer[spellingIndex];
*output++ = 0;
++candidateCount;
candidateCount = candidateCount + 1;
}
else if ((int)totalCandidates >= options->maxCount) goto finishSpelling;
if (candidateCount >= params->maxCandidates) goto finishSpelling;
@@ -1321,7 +1321,8 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
wordBuffer[params->wordCharCount + wordLength] = 0;
}
if (optionsMask == 5) {
if (++totalCandidates >= options->maxCount) goto finishCandidates;
totalCandidates++;
if (totalCandidates >= options->maxCount) goto finishCandidates;
} else if (remaining == 0) {
totalCandidates++;
candidateCount++;
@@ -1389,7 +1390,8 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
wordBuffer[params->wordCharCount + wordLength] = 0;
}
if (optionsMask == 5) {
if (++totalCandidates >= options->maxCount) goto finishCandidates;
totalCandidates++;
if (totalCandidates >= options->maxCount) goto finishCandidates;
} else if (remaining == 0) {
totalCandidates++;
candidateCount++;
@@ -1429,7 +1431,7 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
}
if ((*phraseEntries & 0x80) != 0) {
entryRemaining = 0;
phraseEntries += ((int)(*phraseEntries & 0x7f) >> 4) + 1;
phraseEntries = phraseEntries + ((int)(*phraseEntries & 0x7f) >> 4) + 1;
} else {
entryRemaining = 0x80;
}
@@ -1511,7 +1513,8 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
output[outputIndex + wordLength] = 0;
}
if (optionsMask == 5) {
if (++totalCandidates >= options->maxCount) goto finishCandidates;
totalCandidates++;
if (totalCandidates >= options->maxCount) goto finishCandidates;
} else if (remaining == 0) {
totalCandidates++;
candidateCount++;

View File

@@ -10,7 +10,7 @@ ziU16 Zi8MatchAltSound(ziU8* elements, ziU16 count, ziU8* table, ziU16 ch,
ziU16 off;
ziU16 w;
hi = (ziU8)(ch >> 8);
hi = (ziU8)((ziU16)ch >> 8);
lo = (ziU8)ch;
flags = (ziU8)(flags >> 3);
if (count == 0) {
@@ -28,22 +28,25 @@ ziU16 Zi8MatchAltSound(ziU8* elements, ziU16 count, ziU8* table, ziU16 ch,
goto search;
up:
i = j;
do {
if (((elements + i * 4)[3] & 0xE) == 0 ||
((elements + i * 4)[3] & flags) != 0) {
off = (ziU16)(((ziU16)(elements + i * 4)[2] |
(((ziU16)(elements + i * 4)[3] & 1) << 8)) << 1);
w = (ziU16)((((ziU16)(elements + i * 4)[3] & 0xF0) >> 4) |
(table[off] | ((ziU16)table[off + 1] << 8)));
if (target == (w & (ziU16)mask)) {
return w;
}
body:
if (((elements + i * 4)[3] & 0xE) == 0 ||
((elements + i * 4)[3] & flags) != 0) {
off = (ziU16)(((ziU16)(elements + i * 4)[2] |
(((ziU16)(elements + i * 4)[3] & 1) << 8)) << 1);
w = (ziU16)((((ziU16)(elements + i * 4)[3] & 0xF0) >> 4) |
(table[off] | ((ziU16)table[off + 1] << 8)));
if (target == (w & (ziU16)mask)) {
return w;
}
i++;
if (i >= count) {
break;
}
} while ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo);
}
i++;
if (i >= count) {
goto down_start;
}
if ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo) {
goto body;
}
down_start:
i = j;
goto dec;
down_body:

View File

@@ -138,7 +138,7 @@ extern ziU16 Zi8GetTableCount(ziU8 language, ziU8 table, ziPtr work);
extern ziU8 Zi8IsDupWChar(ziWChar character, ziPtr work);
extern ziU8 Zi8IsDupWordW(ziWChar* word, ziU8 length, ziPtr work);
extern ziWChar Zi8Ord2Uni(ziU16 ordinal, ziPtr work);
extern ziBool Zi8MatchPhonetic(ziU8* phonetics, ziU8* records,
extern ziU8 Zi8MatchPhonetic(ziPtr phonetics, ziU8* records,
ziPtr indexTable, ziU16 indexCount, ziU32 dictionary,
ziU8* record, ziU16* mask, ziU16* match,
ziU16* length, ziU8** matchedRecord,
@@ -169,15 +169,15 @@ extern ziU16 Zi8Uni2Ord(ziWChar character, ziPtr work);
extern ziU16 Zi8GetPCode(ziU8* table, ziU8* record);
extern ziU16 Zi8MatchAltSound(ziPtr table, ziU16 count, ziPtr phonetics,
ziU16 ordinal, ziU16 mask, ziU16 value, ziU8 flags, ziPtr work);
extern ziU32 Zi8SecMatchChar(ziU8* record, ziU8* dictionary, ziMatchParam* match, ziU16* code, ziPtr work);
extern ziU32 Zi8SecMatchChar(ziPtr record, ziU8* dictionary, ziMatchParam* match, ziU16* code, ziPtr work);
extern ziBool Zi8PriMatchNextChar(ziU8* record, ziU8 firstByteMask, ziU8 firstByteValue, ziU8 secondByteMask, ziU8 secondByteValue, ziU8 thirdByteMask, ziU8 thirdByteValue, ziU8 fourthByteMask, ziU8 fourthByteValue, ziU16* count, ziU8** result, ziU16* code, ziPtr work);
extern ziBool Zi8ExactMatchNextChar(ziU8* record, ziU8 firstByteMask, ziU8 firstByteValue, ziU8 secondByteMask, ziU8 secondByteValue, ziU8 thirdByteMask, ziU8 thirdByteValue, ziU8 fourthByteMask, ziU8 fourthByteValue, ziU16* count, ziU8** result, ziU16* code, ziPtr work);
extern ziBool Zi8PriMatchNextComp(ziU8* component, ziU8 firstByteMask, ziU8 firstByteValue, ziU8 secondByteMask, ziU8 secondByteValue, ziU8 thirdByteMask, ziU8 thirdByteValue, ziU8 fourthByteMask, ziU8 fourthByteValue, ziU16* count, ziU8** result, ziPtr work);
extern ziBool Zi8SecMatchComp(ziU8* component, ziMatchParam* match, ziU8* dictionary, ziPtr work);
extern ziBool Zi8SecMatchComp(ziPtr component, ziMatchParam* match, ziPtr dictionary, ziPtr work);
extern void Zi8InitDupWordBuf(ziPtr work);
extern ziU8 Zi8MatchPUDdata_ZHS(ziWChar* word, ziU8 length, ziU8 language, ziWChar* spelling, ziU16 spellingCapacity, ziWChar* candidate, ziU16 candidateCapacity, ziU8 mode, ziU8 next, ziPtr work);
extern ziPtr Zi8Memcpy(ziPtr destination, ziPtr source, ziS32 count);
extern ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
extern ziPtr Zi8Memcpy(ziPtr destination, ziPtr source, ziS32 length);
extern void Zi8Memset(ziPtr destination, int value, ziU32 size);
static int Zi8NewMatchPhonetic(ziGetParam* request, ZiChineseRecord* records,
ziPtr indexTable, ziU16 indexCount, ziPtr dictionary,
@@ -753,11 +753,10 @@ static int zi8InternalGetZH(ziGetParam* request, ZiChineseOptions* options, ziPt
if (!componentTable) {
componentCount = Zi8GetTableCount(1, 7, work);
componentOrdinals = (ziU8*)Zi8GetTableAddress(1, 7, work);
componentCursor = (ziU8*)Zi8GetTableAddress(1, 2, work);
componentTable = componentCursor;
componentTable = componentCursor = (ziU8*)Zi8GetTableAddress(1, 2, work);
componentCursor += 8;
componentIndex = componentCount - 1;
--componentCount;
componentIndex = componentCount;
alternateCharacter = 0;
phoneticRetry = 1;
}
@@ -1300,8 +1299,8 @@ context_word_lookup:
if (emitWords) {
++emittedCount;
outputIndex += emittedWords;
output[outputIndex++] = ' ';
if (outputIndex > outputLimit) {
output[outputIndex] = ' ';
if (++outputIndex > outputLimit) {
request->letters = emittedCount;
request->count = emittedCount;
goto engine_finish;
@@ -1435,8 +1434,8 @@ candidate_dictionary_search:
if (emitWords) {
++emittedCount;
output[outputIndex++] = character;
output[outputIndex++] = ' ';
if (outputIndex > outputLimit) goto engine_finish;
output[outputIndex] = ' ';
if (++outputIndex > outputLimit) goto engine_finish;
} else output[emittedCount++] = character;
if (emittedCount >= request->maxCandidates) goto engine_finish;
}
@@ -1500,7 +1499,7 @@ character_range_next:
record += 12;
continue;
character_range_accept:
ordinalIndex = firstOrdinal + (remainingOrdinals - candidateCount - 1);
ordinalIndex = remainingOrdinals - candidateCount + firstOrdinal - 1;
((ZiChineseWork*)work)->duplicateOrdinals[((ZiChineseWork*)work)->duplicateIndex] = ordinalIndex;
((ZiChineseWork*)work)->duplicateCharacters[((ZiChineseWork*)work)->duplicateIndex] = candidateOrdinal;
if (charsetTable) {
@@ -1677,8 +1676,8 @@ tone_candidates:
if (emitWords) {
++emittedCount;
output[outputIndex++] = character;
output[outputIndex++] = ' ';
if (outputIndex > outputLimit) goto engine_finish;
output[outputIndex] = ' ';
if (++outputIndex > outputLimit) goto engine_finish;
} else output[emittedCount++] = character;
if (emittedCount >= request->maxCandidates) goto engine_finish;
} else if (totalResults >= options->maxResults) goto engine_finish;
@@ -1958,7 +1957,7 @@ component_retry:
goto character_pass_done;
}
if (!(ziU8)Zi8SecMatchChar(record, componentTable, &match, &candidateOrdinal, work)) goto component_record_next;
ordinalIndex = firstOrdinal + (remainingOrdinals - candidateCount - 1);
ordinalIndex = remainingOrdinals - candidateCount + firstOrdinal - 1;
if (charsetTable) charsetEntry = charsetTable + ordinalIndex;
if (charsetTable && !(charsetEntry[0] & charsetFilter)) goto component_record_next;
currentSpelling[0] = ((ZiChineseWork*)work)->duplicateCharacters[((ZiChineseWork*)work)->duplicateIndex] = candidateOrdinal;
@@ -2053,7 +2052,7 @@ component_record_next:
if (getMode != 5) {
while (exactPhrase) {
while (match.count) {
if (candidateCount-- == 0) goto frequency_range_retry;
if ((candidateCount -= 1) == 0xFFFF) goto frequency_range_retry;
if (match.recordValues[0] == (record[0] & match.recordMasks[0]) &&
(ziU8)Zi8SecMatchChar(record, componentTable, &match, &candidateOrdinal, work)) goto frequency_accept;
record += 12;
@@ -2073,7 +2072,7 @@ frequency_range_retry:
continue;
}
frequency_accept:
ordinalIndex = firstOrdinal + (remainingOrdinals - candidateCount - 1);
ordinalIndex = remainingOrdinals - candidateCount + firstOrdinal - 1;
if (charsetTable) charsetEntry = charsetTable + ordinalIndex;
if (charsetTable && !(charsetEntry[0] & charsetFilter)) goto frequency_record_next;
((ZiChineseWork*)work)->duplicateOrdinals[((ZiChineseWork*)work)->duplicateIndex] = ordinalIndex;
@@ -2299,7 +2298,7 @@ phonetic_pair_next:
alternateCursor += 4;
}
phonetic_group_next:
ordinalIndex++;
ordinalIndex += 1;
frequencyCursor += 5;
}
}

View File

@@ -25,7 +25,7 @@ const ziU8 zi8CangjieCodes[32] = {
21, 22, 23, 25, 26, 27, 29, 30, 31
};
ziU32 Zi8GetCJInfo(ziU8* input, ziWChar* output, ziU8 outputSize, ziPtr __zi8_work_data)
ziU32 Zi8GetCJInfo(ziU8* input, ziWChar* output, ziU8 outputSize, ziPtr work)
{
ziS32 packedCodes;
ziS32 code;
@@ -33,13 +33,13 @@ ziU32 Zi8GetCJInfo(ziU8* input, ziWChar* output, ziU8 outputSize, ziPtr __zi8_wo
ziS32 codeCount;
ziS32 index;
ZI_WORK->cangjieEnabled = Zi8GetFormatVersion(ZI8_LANG_ZH, __zi8_work_data) & 2;
if (ZI_WORK->cangjieEnabled == 0) {
Zi8LogError(0x8fc, __zi8_work_data);
((ZiInfoWork*)work)->cangjieEnabled = Zi8GetFormatVersion(1, work) & 2;
if (((ZiInfoWork*)work)->cangjieEnabled == 0) {
Zi8LogError(0x8fc, work);
return 0;
}
if (outputSize < 6) {
Zi8LogError(0x322, __zi8_work_data);
Zi8LogError(0x322, work);
return 0;
}
@@ -57,14 +57,14 @@ ziU32 Zi8GetCJInfo(ziU8* input, ziWChar* output, ziU8 outputSize, ziPtr __zi8_wo
}
}
if (index >= 0x19) {
Zi8LogError(0x26d, __zi8_work_data);
Zi8LogError(0x26d, work);
return 0;
}
output[outputCount] = index + 0x41;
outputCount++;
}
output[outputCount] = 0;
Zi8LogError(100, __zi8_work_data);
Zi8LogError(100, work);
return (ziU8)outputCount;
}
@@ -858,7 +858,7 @@ ziPtr work)
return;
}
ziU32 ZiCharInfo2(ziWChar ch, ziWChar* charInfoBuffer, ziU8 maxInfoBufSize, ziU32 hetMode, ziWChar* elements, ziU32 elementCount, ZiInfoWork* work)
ziU32 ZiCharInfo2(ziWChar ch, ziWChar* charInfoBuffer, ziU8 maxInfoBufSize, ziU32 hetMode, ziWChar* elements, ziU32 elementCount, ziPtr work)
{
union {
@@ -892,22 +892,22 @@ ziU32 ZiCharInfo2(ziWChar ch, ziWChar* charInfoBuffer, ziU8 maxInfoBufSize, ziU3
}
if (((ziU8)hetMode & 0x80) != 0) {
hetMode = (ziU8)(hetMode & 0x7f);
if (Zi8GetFormatVersion(ZI8_LANG_ZH,work) >= 4) {
charTableCount = Zi8GetTableCount(ZI8_LANG_ZH,0x19,work);
tablePtr = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH,0x19,work);
if (Zi8GetFormatVersion(1,work) >= 4) {
charTableCount = Zi8GetTableCount(1,0x19,work);
tablePtr = (ziU8*)Zi8GetTableAddress(1,0x19,work);
}
else {
charTableCount = 0;
tablePtr = ZI8_NULL;
tablePtr = (ziU8*)0;
}
if ((hetMode & 0xff) == 1) {
tableBase = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH,3,work);
tableBase = (ziU8*)Zi8GetTableAddress(1,3,work);
}
else {
tableBase = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH,4,work);
tableBase = (ziU8*)Zi8GetTableAddress(1,4,work);
}
if ((hetMode & 0xff) != 1 && (hetMode & 0xff) != 2) goto lookupCharacter;
if (charTableCount <= Zi8GetTableCount(ZI8_LANG_ZH,8,work)) {
if (charTableCount <= Zi8GetTableCount(1,8,work)) {
highByte = (ziU8)((ch >> 8) & 0xff);
lowByte = (ziU8)ch;
index = 0;
@@ -917,10 +917,10 @@ ziU32 ZiCharInfo2(ziWChar ch, ziWChar* charInfoBuffer, ziU8 maxInfoBufSize, ziU3
charIndex = (ziU16)(((ziU32)tablePtr[2] >> 5) & 7) + tableBase[codeOffset] +
(ziU16)(((ziU32)tableBase[codeOffset + 1] & 0xffff) << 8);
if ((hetMode & 0xff) == 1) {
count = Zi8GetPInfo(charIndex,charInfoBuffer,maxInfoBufSize,work);
count = Zi8GetPInfo(charIndex,(ziU16*)charInfoBuffer,maxInfoBufSize,work);
}
else {
count = Zi8GetZInfo(charIndex,charInfoBuffer,maxInfoBufSize,work);
count = Zi8GetZInfo(charIndex,(ziU16*)charInfoBuffer,maxInfoBufSize,work);
}
normalizeStrokes:
if ((hetMode & 0xff) == 0x11) {
@@ -953,10 +953,10 @@ lookupCharacter:
count = 0;
}
else {
tablePtr = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH,1,work);
tablePtr = (ziU8*)Zi8GetTableAddress(1,1,work);
tablePtr += ((uniInfoBuffer[9] & 0xf) << 0x10 | (uniInfoBuffer[11] | ((ziU32)uniInfoBuffer[10] << 8)));
work->cangjieEnabled = Zi8GetFormatVersion(ZI8_LANG_ZH,work) & 2;
if ((((work->cangjieEnabled != 0) && ((hetMode & 0xff) != 7)) && ((hetMode & 0xff) != 10))
((ZiInfoWork*)work)->cangjieEnabled = Zi8GetFormatVersion(1,work) & 2;
if ((((((ZiInfoWork*)work)->cangjieEnabled != 0) && ((hetMode & 0xff) != 7)) && ((hetMode & 0xff) != 10))
&& (((hetMode & 0xff) != 8 && ((hetMode & 0xff) != 9)))) {
switch (*tablePtr & 7) {
case 2:
@@ -974,12 +974,12 @@ lookupCharacter:
break;
}
}
switch(hetMode & 0xff) {
switch((ziU32)hetMode & 0xff) {
case 7:
case 8:
case 9:
case 10:
count = Zi8GetCJInfo(tablePtr,charInfoBuffer,maxInfoBufSize,work);
count = (ziU32)Zi8GetCJInfo(tablePtr,charInfoBuffer,maxInfoBufSize,work);
if ((((hetMode & 0xff) == 9) || ((hetMode & 0xff) == 10)) && (2 < (count & 0xff))) {
charInfoBuffer[1] = charInfoBuffer[(count & 0xff) - 1];
charInfoBuffer[2] = 0;
@@ -993,15 +993,15 @@ lookupCharacter:
break;
case 1:
case 3:
tableBase = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH,3,work);
tableBase = (ziU8*)Zi8GetTableAddress(1,3,work);
charIndex = Zi8GetPCode((ziU32)tableBase,uniInfoBuffer);
count = Zi8GetPInfo(charIndex,charInfoBuffer,maxInfoBufSize,work);
count = Zi8GetPInfo(charIndex,(ziU16*)charInfoBuffer,maxInfoBufSize,work);
break;
case 2:
case 4:
tableBase = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH,4,work);
tableBase = (ziU8*)Zi8GetTableAddress(1,4,work);
charIndex = Zi8GetPCode((ziU32)tableBase,uniInfoBuffer);
count = Zi8GetZInfo(charIndex,charInfoBuffer,maxInfoBufSize,work);
count = Zi8GetZInfo(charIndex,(ziU16*)charInfoBuffer,maxInfoBufSize,work);
break;
default:
count = 0;
@@ -1009,8 +1009,8 @@ lookupCharacter:
}
if ((((elementCount & 0xff) != 0) && ((uniInfoBuffer[0] & 0x80) != 0)) &&
(((hetMode & 0xff) == 3 || ((hetMode & 0xff) == 4)))) {
alternateTable = (ziU8 *)Zi8GetTableAddress(ZI8_LANG_ZH,5,work);
alternatesRemaining = Zi8GetTableCount(ZI8_LANG_ZH,5,work);
alternateTable = (ziU8 *)Zi8GetTableAddress(1,5,work);
alternatesRemaining = Zi8GetTableCount(1,5,work);
while (alternatesRemaining != 0) {
if (codeOffset == (((ziU16)alternateTable[1] << 8) | (ziU16)alternateTable[0])) break;
alternatesRemaining--;
@@ -1042,10 +1042,10 @@ lookupCharacter:
alternatesRemaining--;
alternateTable = alternateTable + 4;
if ((hetMode & 0xff) == 3) {
count = Zi8GetPInfo(charIndex,charInfoBuffer,maxInfoBufSize,work);
count = Zi8GetPInfo(charIndex,(ziU16*)charInfoBuffer,maxInfoBufSize,work);
}
else {
count = Zi8GetZInfo(charIndex,charInfoBuffer,maxInfoBufSize,work);
count = Zi8GetZInfo(charIndex,(ziU16*)charInfoBuffer,maxInfoBufSize,work);
}
goto checkElements;
}

View File

@@ -117,7 +117,7 @@ check_keys:
records[context->cnt].key = 0;
}
if (prefixLength != 0 && *prefixLength < context->cnt &&
ZiDAWGgetEOWattribute(current->node)) {
ZiDAWGgetEOWattribute(current->node) != 0) {
*prefixLength = context->cnt;
for (index = 0; index < context->cnt; index++) output[index] = (ziU16)records[index].attr;
}
@@ -125,7 +125,7 @@ check_keys:
}
if (context->cnt < search[1]) goto descend;
if (search[0] != 0 && context->cnt > search[1]) goto next_sibling;
if (acceptPrefix != 0 || ZiDAWGgetEOWattribute(current->node)) {
if (acceptPrefix != 0 || ZiDAWGgetEOWattribute(current->node) != 0) {
for (index = 0; index < context->cnt; index++) output[index] = (ziU16)records[index].attr;
result = context->cnt;
searching = 0;
@@ -232,7 +232,7 @@ unsigned int Zi8MatchROMdata2(ziWChar* elements, ziU8 count, ziU8 language,
if (status == 0) {
ZI_WORK->dawgGroupIndex = 0;
ZI_WORK->matchOffset = 0;
if (group != 0 && *group == 0xc && language == ZI8_LANG_FI && ZI_WORK->forceAltGraph != 0) {
if (group != 0 && *group == 0xc && language == 10 && ZI_WORK->forceAltGraph != 0) {
ZI_WORK->graphTableId = 0x10;
} else {
ZI_WORK->graphTableId = 0;
@@ -275,7 +275,7 @@ search_segment:
ZI_WORK->dawgGroupIndex++;
status = 0;
ZI_WORK->graphTableId = 0;
if (ZI_WORK->dawgCtx.key == 0 && language == ZI8_LANG_FI) {
if (ZI_WORK->dawgCtx.key == 0 && language == 10) {
for (index = 0; index < ZI_WORK->matchOffset; index++) {
switch (ZI_WORK->dawgWord[index]) {
case 0x61:
@@ -323,7 +323,7 @@ ziU32 Zi8MatchROMdata(ziWChar* elements, ziU8 count, ziU8 language,
acceptPrefix, ZI_WORK);
if ((ziU8)result != 0) break;
status = 0;
if (count <= 1 && language == ZI8_LANG_SW) break;
if (count <= 1 && language == 0x36) break;
ZI_WORK->dawgGroup = NextDawgGroup(ZI_WORK->dawgGroup, language, ZI_WORK);
}
}
@@ -380,7 +380,7 @@ void Zi8SyllablesROMdata(ziWChar *elements, ziU8 count, ziU8 language, ziWChar *
keyTable = 0x1b;
}
}
Zi8MatchROMdata0(elements,count,language & 0xff,output,capacity,1,status,graphTable,keyTable,0,prefixLength,
Zi8MatchROMdata0(elements,count,language & 0xff,output,capacity,1,status,graphTable,keyTable,0,(ziU8 *)prefixLength,
&ZI_WORK->dawgCtx,ZI_WORK->dawgSearchState,ZI_WORK);
return;
}

View File

@@ -62,7 +62,7 @@ ziU32 Zi8GetSyllablesCandidates(ziGetParam* param, ziSwParam* sw ZI_NEED_WORK) {
out = buf;
rem = 0x40;
} else {
out = param->candidates;
out = (ziWChar*)param->candidates;
rem = sw->capacity - 1;
}
if ((param->getOptions & 0xFD) == 0x80) {

View File

@@ -27,7 +27,7 @@ ziU16 Zi8GetTableCount(ziU8 language, ziU8 table, ziPtr work);
ziU16 Zi8GetVersion(ziPtr work);
ziU16 Zi8GetOEMID(ziPtr work);
ziU16 Zi8GetBuildID(ziPtr work);
ziPtr Zi8Memcpy(ziPtr destination, ziPtr source, ziS32 count);
void Zi8Memcpy(ziU8* destination, ziU8* source, ziS32 count);
ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* options, ziPtr work);
ziBool Zi8ZHsetPYfuzzyPairs(ziFuzzyPYPairs pairs ZI_NEED_WORK) {
@@ -66,8 +66,8 @@ ziU16 Zi8GetGlobalDataSize(void) {
static ziU16 Zi8GetDataSignature(ziU8* destination, ziU16 capacity, ziU8 language, ziPtr work) {
ziU8* signature;
ziU16 length;
if (language == ZI8_LANG_ZH) {
if (Zi8GetFormatVersion(ZI8_LANG_ZH, work) < 8) {
if (language == 1) {
if (Zi8GetFormatVersion(1, work) < 8) {
Zi8LogError(0x26f, work);
return 0;
}
@@ -293,8 +293,8 @@ ziU8 Zi8LangSupported(ziU8 language, ziPtr work);
ziBool Zi8IsCharacter(ziWChar character, ziPtr work);
ziU8 Zi8GetCharInfo(ziWChar character, ziWChar* output, ziU8 capacity, ziU8 type, ziPtr work);
ziU32 Zi8GetKOcandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8GetKoreanCandidates(ziGetParam* parameters, ziU8* countOnly, struct __zi8_work_data_s* work);
ziU32 Zi8Punctuation(ziGetParam* parameters, ZiCandidateOptions* options, ziPtr work);
ziU32 Zi8GetKoreanCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8Punctuation(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8GetChineseCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8Get1KeyPressCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8Get1KeyPressSpelling(ziGetParam* parameters, ziPtr options, ziPtr work);
@@ -324,11 +324,11 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
saved.savedCandidates = 0;
saved.restoreCandidates = 0;
if (options->lookupMode == '\0') {
if (ZI_WORK->getcPhase == '\t' && parameters->elementCount != 0 &&
((parameters->elements[parameters->elementCount - 1] == 0xEFF8 &&
Zi8AlphaSignature(parameters,options->countOnly,ZI_WORK)) ||
(parameters->elements[parameters->elementCount - 1] == 0xEF04 &&
Zi8ZhSignature(parameters,options->countOnly,ZI_WORK)))) {
if (((ZI_WORK->getcPhase == '\t') && (parameters->elementCount != 0)) &&
(((parameters->elements[parameters->elementCount - 1] == 0xEFF8 &&
((ziU8)Zi8AlphaSignature(parameters,options->countOnly,ZI_WORK) != 0)) ||
((parameters->elements[parameters->elementCount - 1] == 0xEF04 &&
((ziU8)Zi8ZhSignature(parameters,options->countOnly,ZI_WORK) != 0)))))) {
candidateCount = (unsigned int)parameters->letters;
if (options->countOnly != '\0') {
parameters->letters = 0;
@@ -338,7 +338,7 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
}
if ((parameters->elementCount == 1) && (parameters->firstCandidate == 0)) {
switch (parameters->language) {
case ZI8_LANG_ZH:
case 1:
if ((ZI_WORK->getcPhase == '\0') || (ZI_WORK->countOnly == options->countOnly)) {
switch(ZI_WORK->getcPhase) {
case '\0':
@@ -371,7 +371,7 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
case '\b':
case '\t':
if ((parameters->elements[0] == 0xEF04) &&
Zi8ZhSignature(parameters,options->countOnly,ZI_WORK)) {
((ziU8)Zi8ZhSignature(parameters,options->countOnly,ZI_WORK) != 0)) {
ZI_WORK->getcPhase = '\t';
candidateCount = (unsigned int)parameters->letters;
if (options->countOnly != '\0') {
@@ -388,15 +388,15 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
}
}
break;
case ZI8_LANG_JP:
case ZI8_LANG_KO:
case ZI8_LANG_PYP:
case ZI8_LANG_PYS:
case ZI8_LANG_ZYP:
case ZI8_LANG_ZYS:
case ZI8_LANG_SP2:
case ZI8_LANG_PY2:
case ZI8_LANG_ZY2:
case 0x10:
case 0x12:
case 0x77:
case 0x78:
case 0x79:
case 0x7A:
case 0x7B:
case 0x7C:
case 0x7D:
break;
case 0x11:
default:
@@ -467,7 +467,7 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
case '\b':
case '\t':
if ((parameters->elements[0] == 0xEFF8) &&
Zi8AlphaSignature(parameters,options->countOnly,ZI_WORK)) {
((ziU8)Zi8AlphaSignature(parameters,options->countOnly,ZI_WORK) != 0)) {
ZI_WORK->getcPhase = '\t';
candidateCount = (unsigned int)parameters->letters;
if (options->countOnly != '\0') {
@@ -491,34 +491,34 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
}
}
ZI_WORK->subLanguage = parameters->subLanguage;
ZI_WORK->cangjieEnabled = Zi8GetFormatVersion(ZI8_LANG_ZH,ZI_WORK) & 2;
ZI_WORK->cangjieEnabled = Zi8GetFormatVersion(1,ZI_WORK) & 2;
options->maxCount = ZI_WORK->maxCandidateCount;
options->maxWordLength = ZI_WORK->maxWordLength;
ZI_WORK->maxWordLength = -1;
if (Zi8LangSupported(parameters->language,ZI_WORK) == 0) {
if ((ziU8)Zi8LangSupported(parameters->language,ZI_WORK) == 0) {
Zi8LogError(0x163,ZI_WORK);
return 0;
}
else {
if (parameters->language == ZI8_LANG_JP) {
if (parameters->language == 0x10) {
error = 0x2c1;
candidateCount = 0;
}
else if (parameters->language == ZI8_LANG_KO) {
else if (parameters->language == 0x12) {
if ((parameters->elementCount == 0) || (parameters->elements[0] >= 0xeff1)) {
candidateCount = Zi8GetKOcandidates(parameters,options,ZI_WORK);
}
else {
candidateCount = Zi8GetKoreanCandidates(parameters,&options->countOnly,ZI_WORK);
candidateCount = Zi8GetKoreanCandidates(parameters,options,ZI_WORK);
}
}
else if ((parameters->language == ZI8_LANG_ZH) && ((parameters->context & 8) != 0)) {
else if ((parameters->language == 1) && ((parameters->context & 8) != 0)) {
candidateCount = Zi8Punctuation(parameters,options,ZI_WORK);
error = 100;
}
else if ((parameters->language == ZI8_LANG_ZH) &&
((parameters->getOptions & 0xbf) == 4 && parameters->elementCount != 0 &&
Zi8IsCharacter(parameters->elements[0],ZI_WORK))) {
else if ((parameters->language == 1) &&
((((parameters->getOptions & 0xbf) == 4 && (parameters->elementCount != 0)) &&
((ziU8)Zi8IsCharacter(parameters->elements[0],ZI_WORK) != 0)))) {
saved.convertedElementCount = Zi8GetCharInfo(parameters->elements[0],characterInfo,0x10,1,ZI_WORK);
if (saved.convertedElementCount == 0) {
parameters->letters = parameters->completion = parameters->count = 0;
@@ -543,11 +543,11 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
parameters->completion = 1;
}
}
else if ((parameters->language == ZI8_LANG_ZH) && (parameters->getMode == 0xf)) {
else if ((parameters->language == 1) && (parameters->getMode == 0xf)) {
error = 0x2d0;
candidateCount = 0;
}
else if ((parameters->language == ZI8_LANG_ZH) && ((parameters->getMode == 3 || (parameters->getMode == 4)))) {
else if ((parameters->language == 1) && ((parameters->getMode == 3 || (parameters->getMode == 4)))) {
if ((parameters->getOptions & 0x80) != 0) {
candidateCount = Zi8Get1KeyPressSpelling(parameters,options,ZI_WORK);
} else if (parameters->elementCount == 0) {
@@ -556,7 +556,7 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
candidateCount = Zi8Get1KeyPressCandidates(parameters,options,ZI_WORK);
}
}
else if ((parameters->language == ZI8_LANG_ZH) &&
else if ((parameters->language == 1) &&
((((parameters->getMode == 7 || (parameters->getMode == 8)) || (parameters->getMode == 10)) || (parameters->getMode == 9)))) {
if (ZI_WORK->cangjieEnabled != '\0') {
candidateCount = Zi8GetChineseCandidates(parameters,options,ZI_WORK);
@@ -565,11 +565,11 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
candidateCount = 0;
}
}
else if ((parameters->language == ZI8_LANG_ZH) && ((parameters->getMode == 0xb || (parameters->getMode == 0xe)))) {
else if ((parameters->language == 1) && ((parameters->getMode == 0xb || (parameters->getMode == 0xe)))) {
error = 0x2ee;
candidateCount = 0;
}
else if (parameters->language == ZI8_LANG_ZH) {
else if (parameters->language == 1) {
candidateCount = Zi8GetChineseCandidates(parameters,options,ZI_WORK);
if ((((candidateCount == 0) && ((parameters->getOptions & 0x20) == 0)) && ((parameters->getMode == 1 && (parameters->elementCount != 0))))
&& (((parameters->elements[parameters->elementCount - 1] == 0xF37A ||
@@ -700,16 +700,14 @@ ziBool Zi8IsDupWordW(ziWChar* word, ziU8 length ZI_NEED_WORK) {
return duplicate;
}
ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count) {
void Zi8Memset(ziU8* destination, ziU32 value, ziS32 count) {
ziS32 index;
for (index = 0; index < count; index++) ((ziU8*)destination)[index] = (ziU8)value;
return destination;
for (index = 0; index < count; index++) destination[index] = (ziU8)value;
}
ziPtr Zi8Memcpy(ziPtr destination, ziPtr source, ziS32 count) {
void Zi8Memcpy(ziU8* destination, ziU8* source, ziS32 count) {
ziS32 index;
for (index = 0; index < count; index++) ((ziU8*)destination)[index] = ((ziU8*)source)[index];
return destination;
for (index = 0; index < count; index++) destination[index] = source[index];
}
ziBool Zi8SetMaxWordLength(ziU8 length ZI_NEED_WORK) {

View File

@@ -1,7 +1,7 @@
#include <zi8clib/zitypes.h>
#include <zi8clib/zierror.h>
extern ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
extern void Zi8Memset(ziPtr p, ziU32 v, ziU32 len);
extern void Zi8SetLatinSearchOrder(ziU32 a, ziU8 b ZI_NEED_WORK);
extern void ZADP_Zi8SetPDremoveOpt(ziU8 a ZI_NEED_WORK);
extern ziU16 Zi8GetFormatVersion(ziU8 a ZI_NEED_WORK);
@@ -37,18 +37,18 @@ ziU8 Zi8InitializeDynamic(ziLanguageEntry* langEntries ZI_NEED_WORK) {
Zi8LogError(0x578, ZI_WORK);
return 0;
}
if (ZI_WORK->langEntries->language == ZI8_LANG_NONE) {
if (ZI_WORK->langEntries->language == 0) {
Zi8LogError(0x582, ZI_WORK);
return 0;
}
ZI_WORK->letterHyphen = 0x2D;
ZI_WORK->language = ZI8_LANG_NONE;
ZI_WORK->language = 0;
ZI_WORK->searchModes[3] = 0;
ZI_WORK->capacity = 0x100;
Zi8SetLatinSearchOrder(0, 0, ZI_WORK);
ZADP_Zi8SetPDremoveOpt(1, ZI_WORK);
ZI_WORK->zhPudMinPrefix = 5;
ZI_WORK->cangjieEnabled = Zi8GetFormatVersion(ZI8_LANG_ZH, ZI_WORK) & 2;
ZI_WORK->cangjieEnabled = Zi8GetFormatVersion(1, ZI_WORK) & 2;
ZI_WORK->pyFuzzy.bits.msb = 1;
ZI_WORK->zyFuzzy.bits.msb = 1;
zyFuzzy = ZI_WORK->zyFuzzy.word;
@@ -63,11 +63,11 @@ ziU8 Zi8InitializeDynamic(ziLanguageEntry* langEntries ZI_NEED_WORK) {
}
ziU8 Zi8IsZicorpSignature(ziU16* p, ziU16 len ZI_NEED_WORK) {
if (len > 6 && p[0] == 0x7A && p[1] == 0x69 && p[2] == 0x63 &&
if ((ziU16)len > 6 && p[0] == 0x7A && p[1] == 0x69 && p[2] == 0x63 &&
p[3] == 0x6F && p[4] == 0x72 && p[5] == 0x70) {
return 1;
}
if (len > 6 && p[0] == 0x39 && p[1] == 0x34 && p[2] == 0x32 &&
if ((ziU16)len > 6 && p[0] == 0x39 && p[1] == 0x34 && p[2] == 0x32 &&
p[3] == 0x36 && p[4] == 0x37 && p[5] == 0x37) {
return 1;
}

View File

@@ -5,9 +5,9 @@ extern ziU8 Zi8LangSupported(ziU8 lang ZI_NEED_WORK);
extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU8 _Zi8GetCandidates(ziGetParam* getParam ZI_NEED_WORK);
extern ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
extern void Zi8Memset(ziPtr p, ziU32 v, ziU32 len);
ziU8 Zi8GetZHCharSet(ziPtr __zi8_work_data) {
ziU8 Zi8GetZHCharSet(ziPtr workData) {
ziU8 charSet = 0;
ziU8 bak;
ziU16 v0;
@@ -18,23 +18,23 @@ ziU8 Zi8GetZHCharSet(ziPtr __zi8_work_data) {
ziWChar candBuf[0x10];
ziGetParam getParam;
Zi8LogError(0x64, __zi8_work_data);
if (Zi8LangSupported(ZI8_LANG_ZH, __zi8_work_data) == 0) {
Zi8ReplaceLastError(0x26C, __zi8_work_data);
Zi8LogError(0x64, workData);
if (Zi8LangSupported(1, workData) == 0) {
Zi8ReplaceLastError(0x26C, workData);
return 0;
}
if (Zi8GetTableCount(ZI8_LANG_ZH, 10, __zi8_work_data) != 0) {
bak = ZI_WORK->subLanguage;
ZI_WORK->subLanguage = 1;
addr = Zi8GetTableAddress(ZI8_LANG_ZH, 10, __zi8_work_data);
if (Zi8GetTableCount(1, 10, workData) != 0) {
bak = ((struct __zi8_work_data_s*)workData)->subLanguage;
((struct __zi8_work_data_s*)workData)->subLanguage = 1;
addr = Zi8GetTableAddress(1, 10, workData);
p = (ziU8*)addr;
v0 = (ziU16)((ziU16)p[0] | ((ziU16)p[1] << 8));
ZI_WORK->subLanguage = 0;
addr = Zi8GetTableAddress(ZI8_LANG_ZH, 10, __zi8_work_data);
((struct __zi8_work_data_s*)workData)->subLanguage = 0;
addr = Zi8GetTableAddress(1, 10, workData);
p = (ziU8*)addr;
v1 = (ziU16)((ziU16)p[2] | ((ziU16)p[3] << 8));
v2 = (ziU16)((ziU16)p[4] | ((ziU16)p[5] << 8));
ZI_WORK->subLanguage = bak;
((struct __zi8_work_data_s*)workData)->subLanguage = bak;
if (v0 != 0) {
if (v0 > 0x4E20) {
charSet |= 8;
@@ -56,7 +56,7 @@ ziU8 Zi8GetZHCharSet(ziPtr __zi8_work_data) {
}
Zi8Memset(&getParam, 0, 0x2C);
getParam.language = ZI8_LANG_ZH;
getParam.language = 1;
getParam.context = 1;
getParam.getOptions = 0;
getParam.candidates = candBuf;
@@ -64,17 +64,17 @@ ziU8 Zi8GetZHCharSet(ziPtr __zi8_work_data) {
getParam.subLanguage = 1;
retry:
getParam.getMode = 0;
if (_Zi8GetCandidates(&getParam, __zi8_work_data) != 0) {
if (_Zi8GetCandidates(&getParam, workData) != 0) {
charSet |= getParam.subLanguage;
goto next;
}
getParam.getMode = 1;
if (_Zi8GetCandidates(&getParam, __zi8_work_data) != 0) {
if (_Zi8GetCandidates(&getParam, workData) != 0) {
charSet |= getParam.subLanguage;
goto next;
}
getParam.getMode = 2;
if (_Zi8GetCandidates(&getParam, __zi8_work_data) != 0) {
if (_Zi8GetCandidates(&getParam, workData) != 0) {
charSet |= getParam.subLanguage;
}
next:
@@ -123,10 +123,10 @@ ziBool Zi8IsCharacter(ziWChar ch ZI_NEED_WORK) {
case 0xFF1F:
return 1;
}
hi = (ziU8)((ch >> 8) & 0xFF);
hi = (ziU8)(((ziU16)ch >> 8) & 0xFF);
lo = (ziU8)ch;
count = Zi8GetTableCount(ZI8_LANG_ZH, 0, ZI_WORK);
addr = Zi8GetTableAddress(ZI8_LANG_ZH, 0, ZI_WORK);
count = Zi8GetTableCount(1, 0, ZI_WORK);
addr = Zi8GetTableAddress(1, 0, ZI_WORK);
table = (ziU8*)addr;
for (i = 0; i < count; i++) {
if (table[6] == hi && table[7] == lo) {

View File

@@ -108,7 +108,7 @@ ziBool Zi8ExactMatchNextChar(ziU8* node, ziU8 firstByteMask, ziU8 firstByteValue
return 0;
}
ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam* match, ziU16* code ZI_NEED_WORK) {
ziU32 Zi8SecMatchChar(ziPtr nodeAddress, ziU8* dictionaryAddress, ziMatchParam* match, ziU16* code ZI_NEED_WORK) {
ziBool isPartial = 0;
ziU16 matchCode;
ziU8* data;
@@ -121,7 +121,7 @@ ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
if (match->componentIndex != 0) {
state.targetCode = match->componentIndex;
matchCode = ((ziU16)(nodeAddress[4] & 3) << 8) | nodeAddress[5];
matchCode = ((ziU16)(((ziU8*)nodeAddress)[4] & 3) << 8) | ((ziU8*)nodeAddress)[5];
value = 0;
while (value++ < 6) {
if (state.targetCode == matchCode) {
@@ -137,8 +137,8 @@ ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
}
}
data = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH, 1, ZI_WORK);
data += nodeAddress[0xB] + (nodeAddress[0xA] << 8) + ((nodeAddress[9] & 0xF) << 16);
data = (ziU8*)Zi8GetTableAddress(1, 1, ZI_WORK);
data += ((ziU8*)nodeAddress)[0xB] + (((ziU8*)nodeAddress)[0xA] << 8) + ((((ziU8*)nodeAddress)[9] & 0xF) << 16);
if (ZI_WORK->cangjieEnabled != 0) {
switch (data[0] & 7) {
case 2:
@@ -168,27 +168,27 @@ ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
isPartial = 1;
}
} else if ((match->length & 1) != 0) {
if ((nodeAddress[match->length >> 1] & 0xF) == 0xF) {
if ((((ziU8*)nodeAddress)[match->length >> 1] & 0xF) == 0xF) {
isPartial = 1;
}
} else {
if ((nodeAddress[match->length >> 1] & 0xF0) == 0xF0) {
if ((((ziU8*)nodeAddress)[match->length >> 1] & 0xF0) == 0xF0) {
isPartial = 1;
}
}
if (match->length > 2) {
if ((match->length & 1) != 0) {
if (((nodeAddress[(match->length - 1) >> 1] & 0xF0) == 0) || ((nodeAddress[(match->length - 1) >> 1] & 0xF0) == 0xF0)) {
if (((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF0) == 0) || ((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF0) == 0xF0)) {
return 0;
}
} else {
if (((nodeAddress[(match->length - 1) >> 1] & 0xF) == 0) || ((nodeAddress[(match->length - 1) >> 1] & 0xF) == 0xF)) {
if (((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF) == 0) || ((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF) == 0xF)) {
return 0;
}
}
}
if (code != 0) {
*code = ((ziU16)nodeAddress[6] << 8) + (ziU16)nodeAddress[7];
*code = ((ziU16)((ziU8*)nodeAddress)[6] << 8) + (ziU16)((ziU8*)nodeAddress)[7];
}
if (isPartial) {
return 2;
@@ -208,7 +208,7 @@ ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
state.dataIndex = 4;
state.remaining = ((match->length + 1) >> 1) - 4;
if ((value + 1) < state.remaining) {
if (((ziU8)value + 1) < (int)state.remaining) {
return 0;
}
if ((match->length & 1) != 0) {
@@ -231,7 +231,7 @@ ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
}
}
if (code != 0) {
*code = ((ziU16)nodeAddress[6] << 8) + (ziU16)nodeAddress[7];
*code = ((ziU16)((ziU8*)nodeAddress)[6] << 8) + (ziU16)((ziU8*)nodeAddress)[7];
}
if (isPartial) {
return 2;
@@ -254,20 +254,20 @@ ziBool Zi8PriMatchNextComp(ziU8* node, ziU8 firstByteMask, ziU8 firstByteValue,
return 0;
}
ziBool Zi8SecMatchComp(ziU8* nodeAddress, ziMatchParam* matchAddress, ziU8* dictionaryAddress ZI_NEED_WORK) {
ziBool Zi8SecMatchComp(ziPtr nodeAddress, ziMatchParam* matchAddress, ziPtr dictionaryAddress ZI_NEED_WORK) {
int chainIndex;
ziU16 matchCode;
ziU16 targetCode;
if (matchAddress->componentIndex != 0) {
targetCode = matchAddress->componentIndex;
matchCode = ((ziU16)(nodeAddress[6] & 3) << 8) | nodeAddress[7];
matchCode = ((ziU16)(((ziU8*)nodeAddress)[6] & 3) << 8) | ((ziU8*)nodeAddress)[7];
chainIndex = 0;
while (chainIndex++ < 6) {
if (targetCode == matchCode) {
break;
}
matchCode = ((ziU16)(*(dictionaryAddress + matchCode * 8 + 6) & 3) << 8) | *(dictionaryAddress + matchCode * 8 + 7);
matchCode = ((ziU16)(*((ziU8*)dictionaryAddress + matchCode * 8 + 6) & 3) << 8) | *((ziU8*)dictionaryAddress + matchCode * 8 + 7);
if (matchCode == 0) {
break;
}
@@ -277,10 +277,10 @@ ziBool Zi8SecMatchComp(ziU8* nodeAddress, ziMatchParam* matchAddress, ziU8* dict
}
}
if (matchAddress->length > 8) {
if (nodeAddress[5] < (matchAddress->length - 2)) {
if ((int)((ziU8*)nodeAddress)[5] < (int)(matchAddress->length - 2)) {
return 0;
}
} else if (nodeAddress[5] < (matchAddress->length - 1)) {
} else if ((int)((ziU8*)nodeAddress)[5] < (int)(matchAddress->length - 1)) {
return 0;
}
return 1;
@@ -289,7 +289,7 @@ ziBool Zi8SecMatchComp(ziU8* nodeAddress, ziMatchParam* matchAddress, ziU8* dict
extern ziU16 Zi8MatchAltSound(ziPtr soundTable, ziU16 soundCode, ziPtr pCodeTable, ziU16 index, ziU16 mask, ziU16 value, ziU8 flag ZI_NEED_WORK);
ziU16 Zi8GetPCode(ziU8* table, ziU8* node);
ziBool Zi8MatchPhonetic(ziU8* pCodeTable, ziU8* dictionary, ziPtr soundTable, ziU16 soundCode, ziU32 tableAddress, ziU8* node, ziU16* masks, ziU16* values, ziU16* count, ziU8** resultNode, ziU8** stringOffset, ziU8 partialMode, ziU8 strictMode, ziU8 numParts, ziU16 partMask, ziU16 partValue, ziU8 flag, ziU8 altMode, ziU16 initialCode, ziU16* resultCode, ziU8 lastMode ZI_NEED_WORK) {
ziBool Zi8MatchPhonetic(ziPtr pCodeTable, ziU8* dictionary, ziPtr soundTable, ziU16 soundCode, ziU32 tableAddress, ziU8* node, ziU16* masks, ziU16* values, ziU16* count, ziU8** resultNode, ziU8** stringOffset, ziU8 partialMode, ziU8 strictMode, ziU8 numParts, ziU16 partMask, ziU16 partValue, ziU8 flag, ziU8 altMode, ziU16 initialCode, ziU16* resultCode, ziU8 lastMode ZI_NEED_WORK) {
struct {
ziBool hasString;
ziU8 partIndex;
@@ -327,7 +327,7 @@ next_node:
node += 0xC;
continue;
decode_node:
traversal.code = Zi8GetPCode(pCodeTable, node);
traversal.code = Zi8GetPCode((ziU8*)pCodeTable, node);
if ((*values != (traversal.code & *masks)) && (altMode == 0) && ((node[0] & 0x80) != 0)) {
if (*count != 0) {
traversal.soundIndex = (initialCode - traversal.remaining) - 1;
@@ -399,7 +399,7 @@ next_group:
if (traversal.hasString) {
goto phonetic_skip;
}
traversal.code = Zi8GetPCode(pCodeTable, dictionary + (traversal.dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode));
traversal.code = Zi8GetPCode((ziU8*)pCodeTable, dictionary + (traversal.dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode));
if (((traversal.code & masks[traversal.partIndex]) != values[traversal.partIndex]) && (altMode == 0) && (dictionary[(traversal.dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode)] & 0x80) != 0) {
traversal.code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, traversal.dictionaryIndex & 0x7FFF, masks[traversal.partIndex], values[traversal.partIndex], flag, ZI_WORK);
}
@@ -575,7 +575,7 @@ scan_final:
value -= 0x61;
}
pinyin[index] = (ziU8)value + 1;
if (!Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) goto try_final_extension;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) == 0) goto try_final_extension;
if (outputIndex == 0) {
*resultCount += 1;
}
@@ -590,7 +590,7 @@ try_final_extension:
if (index < 3) {
pinyin[index + 1] = 0xFF;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (outputIndex == 0) {
*resultCount += 1;
}
@@ -624,7 +624,7 @@ finish_final:
partial = 1;
}
if (partial && alternateInitial == 0) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
@@ -641,7 +641,7 @@ finish_final:
}
} else {
pinyin[index] = 0xFF;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
@@ -653,7 +653,7 @@ finish_final:
*bestFinal = final[0];
if ((outputIndex == 0) && (count == 0)) {
pinyin[index] = 0;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
*bestInitial = 0x7E00;
*bestFinal = 0x200;
@@ -664,7 +664,7 @@ finish_final:
}
} else {
pinyin[index] = 0;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;

View File

@@ -6,6 +6,8 @@ extern ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
typedef struct { ziU8 b[0xC]; } ziE12;
#define WORKP ((struct __zi8_work_data_s*)__zi8_work_data)
ziU16 Zi8Uni2Ptr(ziU16 ch, ziE12* buf ZI_NEED_WORK) {
ziU8 hi;
ziU8 lo;
@@ -16,15 +18,15 @@ ziU16 Zi8Uni2Ptr(ziU16 ch, ziE12* buf ZI_NEED_WORK) {
ziU8* e;
ziU8* p;
hi = (ziU8)((ch >> 8) & 0xFF);
hi = (ziU8)(((ziU16)ch >> 8) & 0xFF);
lo = (ziU8)ch;
count = Zi8GetTableCount(ZI8_LANG_ZH, 0, __zi8_work_data);
table = Zi8GetTableAddress(ZI8_LANG_ZH, 0, __zi8_work_data);
table2 = Zi8GetTableAddress(ZI8_LANG_ZH, 1, __zi8_work_data);
count = Zi8GetTableCount(1, 0, __zi8_work_data);
table = Zi8GetTableAddress(1, 0, __zi8_work_data);
table2 = Zi8GetTableAddress(1, 1, __zi8_work_data);
if (buf == ZI8_NULL) {
for (i = 0; i < 0x40; i++) {
if (ch == ZI_WORK->duplicateCharacters[i]) {
i = ZI_WORK->duplicateOrdinalCache[i];
if (ch == WORKP->duplicateCharacters[i]) {
i = WORKP->duplicateOrdinalCache[i];
e = (ziU8*)table + i * 0xC;
if (i >= count) {
break;
@@ -35,7 +37,7 @@ ziU16 Zi8Uni2Ptr(ziU16 ch, ziE12* buf ZI_NEED_WORK) {
p = (ziU8*)(table2 +
(((e[9] & 0xF) << 16) |
(e[0xB] | (e[0xA] << 8))));
if (ZI_WORK->cangjieEnabled != 0) {
if (WORKP->cangjieEnabled != 0) {
switch (p[0] & 7) {
case 2:
p += 2;
@@ -63,19 +65,19 @@ ziU16 Zi8Uni2Ptr(ziU16 ch, ziE12* buf ZI_NEED_WORK) {
}
}
e = (ziU8*)table;
if (ZI_WORK->unicodeMap != ZI8_NULL && ZI_WORK->unicodeMapSubLang == ZI_WORK->subLanguage) {
if (ch >= ZI_WORK->unicodeRange1Min && ch <= ZI_WORK->unicodeRange1Max) {
i = (ziU16)(ch - ZI_WORK->unicodeRange1Min);
if (WORKP->unicodeMap != ZI8_NULL && WORKP->unicodeMapSubLang == WORKP->subLanguage) {
if ((ziU16)ch >= WORKP->unicodeRange1Min && (ziU16)ch <= WORKP->unicodeRange1Max) {
i = (ziU16)(ch - WORKP->unicodeRange1Min);
goto map;
}
if (ch >= ZI_WORK->unicodeRange2Min && ch <= ZI_WORK->unicodeRange2Max) {
i = (ziU16)(ZI_WORK->unicodeRange1Max + (ch - ZI_WORK->unicodeRange2Min) -
ZI_WORK->unicodeRange1Min + 1);
if ((ziU16)ch >= WORKP->unicodeRange2Min && (ziU16)ch <= WORKP->unicodeRange2Max) {
i = (ziU16)(WORKP->unicodeRange1Max + (ch - WORKP->unicodeRange2Min) -
WORKP->unicodeRange1Min + 1);
goto map;
}
return 0xFFFF;
map:
i = ZI_WORK->unicodeMap[i];
i = WORKP->unicodeMap[i];
if (i != 0xFFFF) {
e = (ziU8*)table + i * 0xC;
if (hi == e[6] && lo == e[7]) {
@@ -108,11 +110,11 @@ ziU16 Zi8Uni2Ord(ziU16 ch ZI_NEED_WORK) {
ziU16 Zi8Ord2Uni(ziU16 ord ZI_NEED_WORK) {
ziU8* p;
if (ord >= Zi8GetTableCount(ZI8_LANG_ZH, 0, __zi8_work_data)) {
if ((ziU16)ord >= Zi8GetTableCount(1, 0, __zi8_work_data)) {
Zi8LogError(0x132, __zi8_work_data);
return 0;
}
p = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH, 0, __zi8_work_data);
p = (ziU8*)Zi8GetTableAddress(1, 0, __zi8_work_data);
p += ord * 0xC;
Zi8LogError(0x64, __zi8_work_data);
return (ziU16)(((ziU16)p[6] << 8) + p[7]);
@@ -123,9 +125,9 @@ ziU16 Zi8Ord2Ord(ziU16 ord ZI_NEED_WORK) {
ziU16 count;
ziU8* p;
count = Zi8GetTableCount(ZI8_LANG_ZH, 0, __zi8_work_data);
table = Zi8GetTableAddress(ZI8_LANG_ZH, 0, __zi8_work_data);
if (ord == 0 || ord >= count) {
count = Zi8GetTableCount(1, 0, __zi8_work_data);
table = Zi8GetTableAddress(1, 0, __zi8_work_data);
if (ord == 0 || (ziU16)ord >= count) {
Zi8LogError(0x132, __zi8_work_data);
return ord;
}

View File

@@ -77,7 +77,7 @@ ziU8 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar*
Zi8LogError(0x4B0, __zi8_work_data);
return 0;
}
if (language == ZI8_LANG_ZH) {
if (language == 1) {
length *= 2;
}
if (continuation == 0) {
@@ -106,7 +106,7 @@ ziU8 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar*
while ((ziS32)ZI_WORK->pudWordIndex < (ziS32)ZI_WORK->pudWordCount) {
wordSize = *word++;
entrySize = wordSize;
if (language == ZI8_LANG_ZH) {
if (language == 1) {
if (ZI_WORK->zhPudMinPrefix > *word) goto next;
wordSize--;
entrySize--;
@@ -118,7 +118,7 @@ next:
ZI_WORK->pudWordIndex++;
word += entrySize;
} else {
if (language == ZI8_LANG_ZH) {
if (language == 1) {
bytePattern = (ziU8*)pattern;
for (index = 0; index < length; index++) {
if (word[index] != bytePattern[index]) goto next;
@@ -143,7 +143,7 @@ matched:
else *output = Zi8ConvertWC2Key(*pattern, language, __zi8_work_data);
return 1;
}
if (language == ZI8_LANG_ZH) {
if (language == 1) {
byteOutput = (ziU8*)output;
for (index = copied = 0; index < (ziS32)wordSize && copied < capacity; copied++) {
byteOutput[index] = word[index];

View File

@@ -87,7 +87,7 @@ ziU8 Zi8ZHaddSpace(ziWChar* src, ziU8 count, ziWChar* dst,
return 1;
fail:
if (count >= maxLen) {
if ((ziU8)count >= (ziU16)maxLen) {
count = (ziU8)(maxLen - 1);
}
for (i = 0; i < count; i++) {

View File

@@ -1,4 +1,3 @@
#include <stddef.h>
#include <zi8clib/zitypes.h>
#include <zi8clib/zierror.h>
#include <zi8clib/zconvert.h>
@@ -8,25 +7,19 @@ typedef struct ziUserWord {
ziU8 size, language, length, priority;
ziU8 text[1];
} ziUserWord;
enum {
ZI_UWD_LENGTH_OFFSET = offsetof(ziUserWord, length),
ZI_UWD_PRIORITY_OFFSET = offsetof(ziUserWord, priority),
ZI_UWD_TEXT_OFFSET = offsetof(ziUserWord, text),
};
typedef struct ziUserDictionary {
ziU16 flags, end, current, boundary;
ziU8 entries[1];
} ziUserDictionary;
ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
void Zi8Memset(ziPtr, ziU32, ziU32);
ziBool Zi8_81480224(ziU8* word ZI_NEED_WORK) {
ziBool Zi8_81480224(ziUserWord* word ZI_NEED_WORK) {
ziU8 length;
ziUwdNode* previous;
ziUwdNode* current;
ziUwdNode* added;
ziU8 position;
ziU8* candidate;
ziUserWord* candidate;
if (ZI_WORK->uwdCount >= 32) {
Zi8LogError(0x19D, __zi8_work_data);
return 0;
@@ -35,7 +28,7 @@ ziBool Zi8_81480224(ziU8* word ZI_NEED_WORK) {
Zi8LogError(0x19F, __zi8_work_data);
return 0;
}
length = word[ZI_UWD_LENGTH_OFFSET];
length = word->length;
if (length == 0) {
Zi8LogError(0x193, __zi8_work_data);
return 0;
@@ -47,12 +40,12 @@ ziBool Zi8_81480224(ziU8* word ZI_NEED_WORK) {
previous = 0;
current = ZI_WORK->uwdList;
while (current != 0) {
candidate = current->word;
if (ZI_WORK->uwdPrioritySort == 1 && word[ZI_UWD_PRIORITY_OFFSET] > candidate[ZI_UWD_PRIORITY_OFFSET]) break;
if (candidate[ZI_UWD_LENGTH_OFFSET] == length) {
candidate = (ziUserWord*)current->word;
if (ZI_WORK->uwdPrioritySort == 1 && word->priority > candidate->priority) break;
if (candidate->length == length) {
position = 0;
while (position < length) {
if (candidate[position + ZI_UWD_TEXT_OFFSET] != word[position + ZI_UWD_TEXT_OFFSET]) break;
if (candidate->text[position] != word->text[position]) break;
position++;
}
if (position == length) {
@@ -210,7 +203,7 @@ next:
if (ZI_WORK->uwdContextRecord[prefixLength] != ((ziU8*)previous)[prefixLength] && ZI_WORK->uwdContextAlternateCase[prefixLength] != ((ziU8*)previous)[prefixLength]) goto next;
}
}
Zi8_81480224(cursor, __zi8_work_data);
Zi8_81480224((ziUserWord*)cursor, __zi8_work_data);
}
goto next;
}

View File

@@ -129,8 +129,8 @@ ziU8* ZiDAWGGetSibling(ziU8* cursor) {
}
ziU8 ZiDAWGgetEOWattribute(ziU8* node) {
return (nodeHeaderTable[*node >> 4] & 0x10) > 0;
ziU8 ZiDAWGgetEOWattribute(ziU32 node) {
return (nodeHeaderTable[*(ziU8*)node >> 4] & 0x10) > 0;
}
ziU32 ZiDAWGgetCHARattribute(zi8DawgCtx* context, ziU32 node, ziPtr __zi8_work_data) {
@@ -149,17 +149,17 @@ ziU32 ZiDAWGgetCHARattribute(zi8DawgCtx* context, ziU32 node, ziPtr __zi8_work_d
}
attribute = key << 24;
attribute |= context->characterFlags[key] << 16;
attribute |= (((ziU32)context->characters[key * 2] & 0xFFFF) << 8) +
(context->characters + key * 2)[1];
attribute |= ((ziU8*)context->characterFlags)[key] << 16;
attribute |= (((ziU32)((ziU8*)context->characters)[key * 2] & 0xFFFF) << 8) +
((ziU8*)context->characters + key * 2)[1];
Zi8LogError(0x64, __zi8_work_data);
return attribute;
}
ziU32 ZiDAWGGetGraph(zi8DawgCtx* context) {
return (((ziU32)context->table[2] & 0xFFFF) << 8) +
context->table[3] +
((ziU32)context->table + 4);
ziU32 ZiDAWGGetGraph(ziPtr context) {
return (((ziU32)((zi8DawgCtx*)context)->table[2] & 0xFFFF) << 8) +
((zi8DawgCtx*)context)->table[3] +
((ziU32)((zi8DawgCtx*)context)->table + 4);
}
ziU32 ZiDAWGGetGraphInfo(zi8DawgCtx* context, ziU8* entry, ziU16* keys) {

View File

@@ -23,10 +23,10 @@ ziU8 Zi8LookupKoreanChar(ziWChar character, ziU8* result, ziU16* index, ziPtr wo
return 0;
}
ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, struct __zi8_work_data_s* workData);
ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, ziPtr workData);
ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
struct __zi8_work_data_s* workData) {
ziPtr workData) {
struct {
ziU8 characterIndex;
ziU8 matched;
@@ -104,7 +104,7 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
state.characterIndex,
(state.elementIndex - currentCharacter) - 1,
workData);
if (workData->koAltTables == 1) {
if ((((struct __zi8_work_data_s*)workData)->koAltTables == 1)) {
switch (state.characterIndex) {
case 1:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1E, workData);
@@ -177,10 +177,10 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
if (state.currentCandidate != 0) {
state.currentCandidate--;
} else {
params->candidates[result] =
params->candidates[(ziU8)result] =
((ziU16)selectedTable[state.nextIndex * 2] << 8) | (selectedTable + state.nextIndex * 2)[1];
if ((state.tableCount6 != 0) && (workData->koAltTables == 0)) {
params->candidates[result] += state.inputIndex * state.tableCount3;
if ((state.tableCount6 != 0) && (((struct __zi8_work_data_s*)workData)->koAltTables == 0)) {
params->candidates[(ziU8)result] += state.inputIndex * state.tableCount3;
}
result++;
}
@@ -208,7 +208,7 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
if (currentCharacter == 0) {
params->completion = 1;
}
params->candidates[result] =
params->candidates[(ziU8)result] =
state.tableCount0 + (state.table31 + state.index * 3)[2];
result++;
currentCharacter++;
@@ -216,11 +216,11 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
}
}
if (state.index == state.tableCount31) {
if ((params->candidates[result] = buffer[currentCharacter]) < 0xFF) {
if ((params->candidates[(ziU8)result] = buffer[currentCharacter]) < 0xFF) {
if (currentCharacter == 0) {
params->completion = 1;
}
params->candidates[result] += state.tableCount0;
params->candidates[(ziU8)result] += state.tableCount0;
result++;
}
}
@@ -235,7 +235,7 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
return result;
}
ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, struct __zi8_work_data_s* workData) {
ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, ziPtr workData) {
ziU16 nestedScratch;
ziU16 nestedIndexStorage;
ziU16 index1;
@@ -249,7 +249,7 @@ ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 c
firstCharacter = input[0];
mappedCharacter = 0xFF;
if (workData->koAltTables == 0) {
if (((struct __zi8_work_data_s*)workData)->koAltTables == 0) {
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 3, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 3, workData);
} else {

View File

@@ -53,7 +53,7 @@ ziBool Zi8IsWordW(ziWChar* word, ziU8 language ZI_NEED_WORK) {
Zi8ReplaceLastError(300, __zi8_work_data);
return 0;
}
if (language != ZI8_LANG_ZH) {
if (language != 1) {
for (count = 0; word[count] != 0; count++) {
if (word[count] >= 0xEFF1 || count == 64) return 0;
}
@@ -91,7 +91,7 @@ ziBool Zi8IsWordW(ziWChar* word, ziU8 language ZI_NEED_WORK) {
ZI_WORK->formatCount = savedCount;
if (count != 0) return 1;
}
if (language != ZI8_LANG_ZH) {
if (language != 1) {
Zi8ReplaceLastError(0x26C, __zi8_work_data);
return 0;
}
@@ -106,10 +106,10 @@ ziBool Zi8IsWordW(ziWChar* word, ziU8 language ZI_NEED_WORK) {
{
if (count-- == 1) return 1;
ordinals[count] |= 0x8000;
ZI_WORK->cangjieEnabled = Zi8GetFormatVersion(ZI8_LANG_ZH, __zi8_work_data) & 2;
table = Zi8GetTableAddress(ZI8_LANG_ZH, 0, __zi8_work_data);
ZI_WORK->cangjieEnabled = Zi8GetFormatVersion(1, __zi8_work_data) & 2;
table = (ziChineseEntry*)Zi8GetTableAddress(1, 0, __zi8_work_data);
entry = table + ordinals[0];
baseData = Zi8GetTableAddress(ZI8_LANG_ZH, 1, __zi8_work_data);
baseData = (ziU8*)Zi8GetTableAddress(1, 1, __zi8_work_data);
baseData += ((entry->offsetHigh & 15) << 16 | (entry->offsetLow[1] | (entry->offsetLow[0] << 8)));
data = baseData;
if (ZI_WORK->cangjieEnabled != 0) {
@@ -168,10 +168,10 @@ ziWChar Zi8ConvertUC2UserKey(ziChar character, ziU8 language ZI_NEED_WORK) {
if (character == 0 || language > 0x82 || (keys = ZI_WORK->userKeys[language]) == 0) return 0;
for (key = 0; key < 32; key++) {
for (cursor = keys->lower[key]; cursor != 0 && *cursor != 0; cursor++) {
if (*cursor == (ziU16)character) goto found;
if ((ziU16)*cursor == (ziU16)character) goto found;
}
for (cursor = keys->upper[key]; cursor != 0 && *cursor != 0; cursor++) {
if (*cursor == (ziU16)character) goto found;
if ((ziU16)*cursor == (ziU16)character) goto found;
}
}
found:

View File

@@ -189,8 +189,7 @@ ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count,
if (matches) {
for (candidateIndex = 0; candidateIndex < *count; candidateIndex++) {
if (param->candidates[candidateIndex] ==
(((ziU16)tableA[i * sizeof(ZiKoreanKeyEntry) + offsetof(ZiKoreanKeyEntry, characterHigh)] << 8) |
(ziU16)tableA[i * sizeof(ZiKoreanKeyEntry) + offsetof(ZiKoreanKeyEntry, characterLow)])) {
(((ziU16)((ZiKoreanKeyEntry*)tableA)[i].characterHigh << 8) | (ziU16)((ZiKoreanKeyEntry*)tableA)[i].characterLow)) {
matched++;
param->candidates[candidateIndex] &= 0x7FFF;
break;
@@ -248,251 +247,254 @@ typedef struct {
} ZiKoreanCandidateOptions;
ziU32 Zi8GetKOcandidates(ziGetParam* param, ZiKoreanCandidateOptions* options ZI_NEED_WORK) {
ziU8* wordTable;
ziS32 tableIndex;
ziS32 resultCount;
ziU32 wordOffset;
ziS32 prefixCount;
ziS32 candidateIndex;
ZiKoreanKeyEntry* entry;
ziU16 keyIndex;
ziU16 tableCount;
ziU16 character;
ziU16 previousIndex;
ziU16 remainingCandidates;
ziU8 remainingLetters;
ziU8 wordIndex;
ziU8 candidateCount;
ziU8 keyByte;
ziU8 matchPass;
ziU8 inserted;
ziBool matches;
struct {
ziBool matches;
ziU8 inserted;
ziU8 matchPass;
ziU8 keyByte;
ziU8 candidateCount;
ziU8 wordIndex;
ziU8 remainingLetters;
ziU16 remainingCandidates;
ziU16 previousIndex;
ziU16 character;
ziU16 tableCount;
ziU16 keyIndex;
ZiKoreanKeyEntry* entry;
ziS32 candidateIndex;
ziS32 prefixCount;
ziU32 wordOffset;
ziS32 resultCount;
ziS32 tableIndex;
ziU8* wordTable;
union {
ziU32 firstWord;
ziU8 bytes[5];
} packedKeys;
} search;
ziU8* keyTable;
ziU8* wordNode;
previousIndex = 0xFFFF;
resultCount = 0;
{
ziU8 packedKeys[5] = {0};
remainingLetters = 0;
wordIndex = 0;
candidateCount = 0;
keyByte = 0;
remainingCandidates = param->firstCandidate;
prefixCount = 0;
candidateIndex = 0;
inserted = 0;
Zi8LogError(100, ZI_WORK);
Zi8_81483264(param, ZI_WORK);
keyTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 9, ZI_WORK);
wordTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 10, ZI_WORK);
if (keyTable == 0) {
Zi8ReplaceLastError(0x76C, ZI_WORK);
search.previousIndex = 0xFFFF;
search.resultCount = 0;
search.packedKeys.firstWord = 0;
search.packedKeys.bytes[4] = 0;
search.wordIndex = search.remainingLetters = 0;
search.candidateCount = 0;
search.keyByte = 0;
search.remainingCandidates = param->firstCandidate;
search.prefixCount = 0;
search.candidateIndex = 0;
search.inserted = 0;
Zi8LogError(100, ZI_WORK);
Zi8_81483264(param, ZI_WORK);
keyTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 9, ZI_WORK);
search.wordTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 10, ZI_WORK);
if (keyTable == 0) {
Zi8ReplaceLastError(0x76C, ZI_WORK);
return 0;
} else {
if (search.wordTable == 0) {
Zi8ReplaceLastError(0x776, ZI_WORK);
return 0;
} else {
if (wordTable == 0) {
Zi8ReplaceLastError(0x776, ZI_WORK);
return 0;
}
if (options->countOnly == 0) {
param->letters = 0;
param->count = 0;
param->candidates[0] = 0;
}
Zi8LogError(100, ZI_WORK);
if (param->wordCharCount == 0) goto scan_key_table;
{
if (((keyIndex = Zi8_8148302C(param->currentWord[0], keyTable, ZI_WORK)) != 0xFFFF) &&
((keyTable[(keyIndex << 3) + keyIndex + offsetof(ZiKoreanKeyEntry, keyBytes[4])] & 8) != 0)) {
wordOffset = keyTable[(keyIndex << 3) + keyIndex + offsetof(ZiKoreanKeyEntry, childLow)] |
((keyTable[(keyIndex << 3) + keyIndex + offsetof(ZiKoreanKeyEntry, keyBytes[4])] & 3) << 16 |
keyTable[(keyIndex << 3) + keyIndex + offsetof(ZiKoreanKeyEntry, childHigh)] << 8);
remainingLetters = param->wordCharCount - 1;
wordIndex = 1;
wordNode = wordTable + wordOffset;
}
if (options->countOnly == 0) {
param->letters = 0;
param->count = 0;
param->candidates[0] = 0;
}
Zi8LogError(100, ZI_WORK);
if (param->wordCharCount == 0) goto scan_key_table;
{
if (((search.keyIndex = Zi8_8148302C(param->currentWord[0], keyTable, ZI_WORK)) != 0xFFFF) &&
((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);
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
wordNode = search.wordTable + search.wordOffset;
match_word:
while (remainingLetters != 0) {
keyIndex = Zi8_8148302C(param->currentWord[wordIndex], keyTable, ZI_WORK);
if (keyIndex == (((ziU16)*wordNode & 0x1F) << 8 | (ziU16)wordNode[1])) {
--remainingLetters;
++wordIndex;
if ((*wordNode & 0x40) != 0) {
remainingLetters = param->wordCharCount - 1;
wordIndex = 1;
break;
}
wordNode += 2;
} else {
wordIndex = 1;
remainingLetters = param->wordCharCount - 1;
while (search.remainingLetters != 0) {
search.keyIndex = Zi8_8148302C(param->currentWord[search.wordIndex], (ziU8*)keyTable, ZI_WORK);
if (search.keyIndex == (((ziU16)*wordNode & 0x1F) << 8 | (ziU16)wordNode[1])) {
--search.remainingLetters;
++search.wordIndex;
if ((*wordNode & 0x40) != 0) {
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
break;
}
wordNode += 2;
} else {
search.wordIndex = 1;
search.remainingLetters = param->wordCharCount - 1;
break;
}
if (remainingLetters == 0) {
keyIndex = ((ziU16)*wordNode & 0x1F) << 8 | (ziU16)wordNode[1];
character = (ziU16)((ziU16)keyTable[(keyIndex << 3) + keyIndex + offsetof(ZiKoreanKeyEntry, characterHigh)] << 8 |
keyTable[(keyIndex << 3) + keyIndex + offsetof(ZiKoreanKeyEntry, characterLow)]);
if (param->wordCharCount == 1) {
if (keyIndex == previousIndex) {
for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) {
}
wordNode += 2;
remainingLetters = param->wordCharCount - 1;
wordIndex = 1;
goto next_word;
}
if (search.remainingLetters == 0) {
search.keyIndex = ((ziU16)*wordNode & 0x1F) << 8 | (ziU16)wordNode[1];
search.character = (ziU16)((ziU16)((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->characterHigh << 8 |
((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->characterLow);
if (param->wordCharCount == 1) {
if (search.keyIndex == search.previousIndex) {
for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) {
}
previousIndex = keyIndex;
if (param->elementCount == 0) {
if (remainingCandidates != 0) {
--remainingCandidates;
} else {
if (options->countOnly != 0) {
if (++prefixCount < (ziS32)options->maxCount) {
goto skip_word;
}
return options->maxCount;
}
param->candidates[candidateCount++] = character;
++param->count;
if (++param->letters >= param->maxCandidates) {
return param->letters;
}
}
wordNode += 2;
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
goto next_word;
}
search.previousIndex = search.keyIndex;
if (param->elementCount == 0) {
if (search.remainingCandidates != 0) {
--search.remainingCandidates;
} else {
param->candidates[candidateCount++] = character;
if (options->countOnly != 0) {
if (++search.prefixCount < (ziS32)options->maxCount) {
goto skip_word;
}
return options->maxCount;
}
param->candidates[search.candidateCount++] = search.character;
++param->count;
if (++param->letters >= param->maxCandidates) {
Zi8_814834AC(param, &remainingCandidates, &candidateCount, &inserted, ZI_WORK);
param->count = candidateCount;
param->letters = candidateCount;
if (candidateCount < param->maxCandidates) goto skip_word;
if (options->countOnly != 0) {
if ((prefixCount += candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
param->count = 0;
param->letters = 0;
candidateCount = 0;
} else {
return candidateCount;
}
return param->letters;
}
}
} else {
for (candidateIndex = 0; candidateIndex < candidateCount; candidateIndex++) {
if (character == param->candidates[candidateIndex]) break;
}
if ((candidateIndex == candidateCount) &&
(Zi8_814833F0(param, character, ZI_WORK) == 0)) {
param->candidates[candidateCount++] = character;
++param->count;
if (++param->letters < param->maxCandidates) {
goto skip_word;
}
Zi8_814834AC(param, &remainingCandidates, &candidateCount, &inserted, ZI_WORK);
param->count = candidateCount;
param->letters = candidateCount;
if (candidateCount < param->maxCandidates) goto skip_word;
param->candidates[search.candidateCount++] = search.character;
++param->count;
if (++param->letters >= param->maxCandidates) {
Zi8_814834AC(param, &search.remainingCandidates, &search.candidateCount, &search.inserted, ZI_WORK);
param->count = search.candidateCount;
param->letters = search.candidateCount;
if (search.candidateCount < param->maxCandidates) goto skip_word;
if (options->countOnly != 0) {
if ((prefixCount += candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
if ((search.prefixCount += search.candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
param->count = 0;
param->letters = 0;
candidateCount = 0;
search.candidateCount = 0;
} else {
return candidateCount;
return search.candidateCount;
}
}
}
} else {
for (search.candidateIndex = 0; search.candidateIndex < search.candidateCount; search.candidateIndex++) {
if (search.character == param->candidates[search.candidateIndex]) break;
}
if ((search.candidateIndex == search.candidateCount) &&
(Zi8_814833F0(param, search.character, ZI_WORK) == 0)) {
param->candidates[search.candidateCount++] = search.character;
++param->count;
if (++param->letters < param->maxCandidates) {
goto skip_word;
}
Zi8_814834AC(param, &search.remainingCandidates, &search.candidateCount, &search.inserted, ZI_WORK);
param->count = search.candidateCount;
param->letters = search.candidateCount;
if (search.candidateCount < param->maxCandidates) goto skip_word;
if (options->countOnly != 0) {
if ((search.prefixCount += search.candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
param->count = 0;
param->letters = 0;
search.candidateCount = 0;
} else {
return search.candidateCount;
}
}
}
}
skip_word:
for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) {
}
wordNode += 2;
remainingLetters = param->wordCharCount - 1;
wordIndex = 1;
for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) {
}
wordNode += 2;
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
next_word:
if ((*wordNode & 0x80) != 0) {
goto search_table;
}
goto match_word;
if ((*wordNode & 0x80) != 0) {
goto search_table;
}
goto match_word;
}
search_table:
resultCount = prefixCount;
if (candidateCount != 0) {
Zi8_814834AC(param, &remainingCandidates, &candidateCount, &inserted, ZI_WORK);
if (options->countOnly != 0) {
if ((prefixCount += candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
resultCount = prefixCount;
}
param->count = candidateCount;
param->letters = candidateCount;
}
scan_key_table:
if (param->elementCount > 9) {
param->letters = 0;
return 0;
}
{
if (param->elementCount != 0 && options->countOnly == 0) {
matchPass = 0;
} else {
matchPass = 1;
}
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, packedKeys);
do {
for (tableIndex = 0; tableIndex < tableCount; tableIndex = tableIndex + 1) {
matches = ZI8_TRUE;
entry = (ZiKoreanKeyEntry*)(((tableIndex << 3) + tableIndex) + keyTable);
keyByte = 0;
if (1 < param->elementCount) {
for (keyByte = 0;
(ziS32)keyByte < (int)param->elementCount / 2;
keyByte++) {
if (packedKeys[keyByte] != entry->keyBytes[keyByte]) {
matches = ZI8_FALSE;
break;
}
}
}
if ((matches && ((param->elementCount % 2) != 0)) &&
((packedKeys[keyByte] & 0xF0) !=
(entry->keyBytes[keyByte] & 0xF0))) {
matches = ZI8_FALSE;
}
if (matches) {
if (param->elementCount % 2 != 0) {
if ((entry->keyBytes[keyByte] & 0xF) != 0) {
if (matchPass == 0) goto next_entry;
} else if (matchPass != 0 && options->countOnly == 0) {
goto next_entry;
}
} else {
if ((entry->keyBytes[keyByte] & 0xF0) != 0) {
if (matchPass == 0) goto next_entry;
} else if (matchPass != 0 && options->countOnly == 0) {
goto next_entry;
}
}
if (remainingCandidates != 0) {
--remainingCandidates;
} else if (options->countOnly != 0) {
if (++resultCount >= (ziS32)options->maxCount) return options->maxCount;
} else {
param->candidates[candidateCount++] =
(ziU16)((ziU16)keyTable[(tableIndex << 3) + tableIndex + offsetof(ZiKoreanKeyEntry, characterHigh)] << 8 |
keyTable[(tableIndex << 3) + tableIndex + offsetof(ZiKoreanKeyEntry, characterLow)]);
if (++param->letters >= param->maxCandidates) return param->letters;
}
}
next_entry:
;
}
} while (++matchPass < 2);
}
if (options->countOnly != 0) return resultCount;
return param->letters;
}
return 0;
search_table:
search.resultCount = search.prefixCount;
if (search.candidateCount != 0) {
Zi8_814834AC(param, &search.remainingCandidates, &search.candidateCount, &search.inserted, ZI_WORK);
if (options->countOnly != 0) {
if ((search.prefixCount += search.candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
search.resultCount = search.prefixCount;
}
param->count = search.candidateCount;
param->letters = search.candidateCount;
}
scan_key_table:
if (param->elementCount > 9) {
param->letters = 0;
return 0;
}
{
if (param->elementCount != 0 && options->countOnly == 0) {
search.matchPass = 0;
} else {
search.matchPass = 1;
}
search.tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, search.packedKeys.bytes);
do {
for (search.tableIndex = 0; search.tableIndex < search.tableCount; search.tableIndex = search.tableIndex + 1) {
search.matches = ZI8_TRUE;
search.entry = (ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable);
search.keyByte = 0;
if (1 < param->elementCount) {
for (search.keyByte = 0;
(ziS32)search.keyByte < (int)param->elementCount / 2;
search.keyByte++) {
if (search.packedKeys.bytes[search.keyByte] != search.entry->keyBytes[search.keyByte]) {
search.matches = ZI8_FALSE;
break;
}
}
}
if ((search.matches && ((param->elementCount % 2) != 0)) &&
((search.packedKeys.bytes[search.keyByte] & 0xF0) !=
(search.entry->keyBytes[search.keyByte] & 0xF0))) {
search.matches = ZI8_FALSE;
}
if (search.matches) {
if (param->elementCount % 2 != 0) {
if ((search.entry->keyBytes[search.keyByte] & 0xF) != 0) {
if (search.matchPass == 0) goto next_entry;
} else if (search.matchPass != 0 && options->countOnly == 0) {
goto next_entry;
}
} else {
if ((search.entry->keyBytes[search.keyByte] & 0xF0) != 0) {
if (search.matchPass == 0) goto next_entry;
} else if (search.matchPass != 0 && options->countOnly == 0) {
goto next_entry;
}
}
if (search.remainingCandidates != 0) {
--search.remainingCandidates;
} else if (options->countOnly != 0) {
if (++search.resultCount >= (ziS32)options->maxCount) return options->maxCount;
} else {
param->candidates[search.candidateCount++] =
(ziU16)((ziU16)((ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable))->characterHigh << 8 |
((ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable))->characterLow);
if (++param->letters >= param->maxCandidates) return param->letters;
}
}
next_entry:
;
}
} while (++search.matchPass < 2);
}
if (options->countOnly != 0) return search.resultCount;
return param->letters;
}
return 0;
}

View File

@@ -62,10 +62,10 @@ ziBool Zi8getKeyLayout(ziU8 language, ziWChar key, ziWChar* chars, ziU8 mode, zi
return 0;
}
keyChars = customTable->lower[key];
for (keyIndex = 0; keyChars[keyIndex] != 0; keyIndex++) {
chars[keyIndex] = keyChars[keyIndex];
for (keyIndex = 0; keyChars[(ziU16)keyIndex] != 0; keyIndex++) {
chars[(ziU16)keyIndex] = keyChars[(ziU16)keyIndex];
}
chars[keyIndex] = 0;
chars[(ziU16)keyIndex] = 0;
return 1;
} else {
if (mode == 1) {
@@ -93,19 +93,19 @@ tables_ready:
}
keyIndex = tableCount = 0;
for (; keyIndex < key; keyIndex++) {
tableCount += dataAddress[keyIndex];
for (; (ziU16)keyIndex < key; keyIndex++) {
tableCount += dataAddress[(ziU16)keyIndex];
}
if ((charCount = (ziU8)dataAddress[key]) == 0) {
return 0;
}
dataAddress = dataAddress + numKeys + (tableCount * 2);
keyIndex = 0;
for (; keyIndex < charCount; keyIndex++) {
chars[keyIndex] = (ziU16)dataAddress[keyIndex * 2] |
((ziU16)dataAddress[(keyIndex * 2) + 1] << 8);
for (; (ziU16)keyIndex < charCount; keyIndex++) {
chars[(ziU16)keyIndex] = (ziU16)dataAddress[(ziU16)keyIndex * 2] |
((ziU16)dataAddress[((ziU16)keyIndex * 2) + 1] << 8);
}
chars[keyIndex] = 0;
chars[(ziU16)keyIndex] = 0;
return 1;
}
}
@@ -121,7 +121,7 @@ ziBool Zi8ChangeCharCase(ziBool upper, ziWChar* character, ziU8 language ZI_NEED
ziU16 result;
ziS32 keyIndex;
ziPtr from;
ziWChar* to;
ziPtr to;
ziS32 characterIndex;
customTables = 0;
@@ -130,9 +130,9 @@ ziBool Zi8ChangeCharCase(ziBool upper, ziWChar* character, ziU8 language ZI_NEED
numKeys = 0x20;
Zi8LogError(0x64, ZI_WORK);
if (ZI_WORK->userKeys[language] != 0) {
customTables = ZI_WORK->userKeys[language];
customTables = (ziUserKeyMap*)ZI_WORK->userKeys[language];
} else if (ZI_WORK->customKeyMap != 0) {
customTables = ZI_WORK->customKeyMap;
customTables = (ziUserKeyMap*)ZI_WORK->customKeyMap;
} else {
tableCount = Zi8GetTableCount(language, 0x1e, ZI_WORK);
if (tableCount != 0) {
@@ -144,18 +144,18 @@ ziBool Zi8ChangeCharCase(ziBool upper, ziWChar* character, ziU8 language ZI_NEED
}
}
if (customTables != 0) {
for (keyIndex = 0; (changed == 0) && (keyIndex < (ziS32)numKeys); keyIndex++) {
for (keyIndex = 0; (changed == 0) && (keyIndex < (ziS32)(ziU32)numKeys); keyIndex++) {
if (upper != 0) {
from = customTables->lower[keyIndex];
to = customTables->upper[keyIndex];
from = (ziPtr)customTables->lower[keyIndex];
to = (ziPtr)customTables->upper[keyIndex];
} else {
from = customTables->upper[keyIndex];
to = customTables->lower[keyIndex];
from = (ziPtr)customTables->upper[keyIndex];
to = (ziPtr)customTables->lower[keyIndex];
}
if ((from != 0) && (to != 0)) {
for (characterIndex = 0; ((ziU16)((ziS16*)from)[characterIndex]) != 0; characterIndex++) {
if ((ziU16)((ziS16*)from)[characterIndex] == *character) {
*character = (ziU16)to[characterIndex];
*character = (ziU16)((ziWChar*)to)[characterIndex];
changed = 1;
break;
}
@@ -165,7 +165,7 @@ ziBool Zi8ChangeCharCase(ziBool upper, ziWChar* character, ziU8 language ZI_NEED
}
else if (dataAddress != 0) {
total = 0;
for (keyIndex = 0; keyIndex < (ziS32)numKeys; keyIndex++) {
for (keyIndex = 0; keyIndex < (ziS32)(ziU32)numKeys; keyIndex++) {
total += dataAddress[keyIndex];
}
dataAddress = dataAddress + numKeys;
@@ -174,7 +174,7 @@ ziBool Zi8ChangeCharCase(ziBool upper, ziWChar* character, ziU8 language ZI_NEED
dataAddress = dataAddress + ((ziU32)total * 2);
direction = -1;
}
for (keyIndex = 0; keyIndex < (ziS32)total; keyIndex++) {
for (keyIndex = 0; keyIndex < (ziS32)(ziU32)total; keyIndex++) {
tableCount = (ziU16)(dataAddress[(keyIndex * 2)] |
((ziU16)dataAddress[(keyIndex * 2) + 1] << 8));
if (tableCount == *character) {

View File

@@ -44,7 +44,7 @@ posEntry:
if (pattern[position] == Zi8ConvertWC2Key(word[position], language, __zi8_work_data)) continue;
break;
} else if (word[position] != pattern[position]) {
if (!ZI_WORK->ignoreCase || language == ZI8_LANG_ZH) break;
if (!ZI_WORK->ignoreCase || language == 1) break;
folded = pattern[position];
if (!Zi8ChangeCharCase(1, &folded, language, __zi8_work_data) || folded != word[position]) break;
}
@@ -64,7 +64,7 @@ posEntry:
while (word[position] != 0) position++;
return position;
matchRetry:
if (index >= ZI_WORK->oemLen) goto oemFailed;
if ((ziS32)index >= ZI_WORK->oemLen) goto oemFailed;
if (!ZI_WORK->oemMatch(index, word, capacity, ZI_WORK->oemData)) goto oemFailed;
goto posEntry;
oemFailed:

View File

@@ -1,7 +1,7 @@
#include <zi8clib/zitypes.h>
ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
ziPtr Zi8Memcpy(ziPtr destination, ziPtr source, ziS32 count);
void Zi8Memset(ziPtr, ziU32, ziU32);
void Zi8Memcpy(ziPtr, ziPtr, ziU32);
ziBool Zi8IsComponent(ziWChar ZI_NEED_WORK);
ziU32 Zi8GetTableAddress(ziU8, ziU8 ZI_NEED_WORK);
ziU16 Zi8GetTableCount(ziU8, ziU8 ZI_NEED_WORK);
@@ -60,14 +60,15 @@ ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode Z
}
}
if (elementCount != 0) {
match->comp = element = request->elements[0];
element = request->elements[0];
match->comp = element;
if (Zi8IsComponent(element,__zi8_work_data) != 0) {
elementIndex++;
hasComponent = 1;
buffers.component = (ziU8*)Zi8GetTableAddress(1,2,__zi8_work_data);
buffers.componentIndex = (ziU8*)Zi8GetTableAddress(1,6,__zi8_work_data);
buffers.componentIndex += (element - 0xef10) * 2;
match->componentIndex = (((ziU16)buffers.componentIndex[1] & 0x3f) << 8) + *buffers.componentIndex;
match->componentIndex = ((buffers.componentIndex[1] & 0x3f) << 8) + *buffers.componentIndex;
buffers.component += (ziU32)match->componentIndex * 8;
switch(*buffers.component & 0xf) {
case 0:
@@ -248,10 +249,8 @@ ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode Z
else {
initial = 0;
final = 0;
bestInitial = 0;
bestFinal = 0;
previousInitial = 0;
previousFinal = 0;
bestFinal = bestInitial = 0;
previousFinal = previousInitial = 0;
buffers.phoneticInput = request->elements;
match->nCand = 0;
request->completion = request->elementCount;

View File

@@ -38,7 +38,7 @@ typedef struct CXUncompContextLZ {
} CXUncompContextLZ;
typedef union CXHuffmanDecodeTableEntry {
volatile u8 raw;
u8 raw;
struct {
u8 leafR : 1; // 10000000
u8 leafL : 1; // 01000000

View File

@@ -72,7 +72,11 @@ struct DVDCommandBlock {
DVDCommandBlock* prev; // 0x04
u32 command; // 0x08
#ifdef BS2_MACH_VOLATILE_DVD_STATE
volatile s32 state;
#else
s32 state; // 0x0C
#endif
u32 offset; // 0x10
u32 length; // 0x14

View File

@@ -8,7 +8,7 @@ extern "C" {
#endif
typedef struct OSSemaphore {
volatile s32 count;
s32 count;
OSThreadQueue queue;
} OSSemaphore;

View File

@@ -1,7 +1,7 @@
#include <private/axfx.h>
#include <revolution/axfx.h>
#include <revolution/mem.h>
#include <revolution/os.h>
#include <revolution/AXFX.h>
#include <revolution/MEM.h>
#include <revolution/OS.h>
#include <math.h>
#include <string.h>
@@ -371,9 +371,10 @@ static void __FreeDelayLine(AXFX_REVERBHI_EXP* fx) {
}
}
DECOMP_FORCE_LITERAL(AXFXReverbHiExp_c, -3.0f, 10.0);
static BOOL __InitParams(AXFX_REVERBHI_EXP* reverb) {
u32 ch, i;
f32 attenuation;
if (reverb->earlyMode >= 8)
return FALSE;
@@ -420,8 +421,7 @@ static BOOL __InitParams(AXFX_REVERBHI_EXP* reverb) {
for (i = 0; i < 3; i++) {
reverb->combPos[i] = 0;
reverb->combLength[i] = __FilterSizeTable[reverb->fusedMode][i];
attenuation = -3.0f * (f32)reverb->combLength[i] / (reverb->fusedTime * 32000);
reverb->combCoef[i] = pow(10.0, attenuation);
reverb->combCoef[i] = pow(10.0f, (-3.0f * (f32)(reverb->combLength[i]) / (f32)(reverb->fusedTime * 32000)));
}
for (i = 0; i < 2; i++) {

View File

@@ -1,7 +1,7 @@
#include <private/axfx.h>
#include <revolution/axfx.h>
#include <revolution/mem.h>
#include <revolution/os.h>
#include <revolution/AXFX.h>
#include <revolution/MEM.h>
#include <revolution/OS.h>
#include <revolution/ax.h>
#include <math.h>
@@ -385,9 +385,10 @@ static void __FreeDelayLine(AXFX_REVERBHI_EXP_DPL2* fx) {
}
}
DECOMP_FORCE_LITERAL(AXFXReverbHiExpDpl2_c, -3.0f, 10.0);
static BOOL __InitParams(AXFX_REVERBHI_EXP_DPL2* reverb) {
u32 ch, i;
f32 attenuation;
if (reverb->earlyMode >= 8)
return FALSE;
@@ -434,8 +435,7 @@ static BOOL __InitParams(AXFX_REVERBHI_EXP_DPL2* reverb) {
for (i = 0; i < 3; i++) {
reverb->combPos[i] = 0;
reverb->combLength[i] = __FilterSizeTable[reverb->fusedMode][i];
attenuation = -3.0f * (f32)reverb->combLength[i] / (reverb->fusedTime * 32000);
reverb->combCoef[i] = pow(10.0, attenuation);
reverb->combCoef[i] = pow(10.0f, (-3.0f * (f32)(reverb->combLength[i]) / (f32)(reverb->fusedTime * 32000)));
}
for (i = 0; i < 2; i++) {

View File

@@ -94,9 +94,9 @@ s32 CARDWriteAsync(CARDFileInfo* fileInfo, void* buf, s32 length, s32 offset, CA
if (result < 0)
return __CARDPutControlBlock(card, result);
DCStoreRange(buf, (u32)length);
DCStoreRange((void*)buf, (u32)length);
card->apiCallback = callback ? callback : __CARDDefaultApiCallback;
card->buffer = buf;
card->buffer = (void*)buf;
result = __CARDEraseSector(fileInfo->chan, card->sectorSize * (u32)fileInfo->iBlock, EraseCallback);
if (result < 0) {

View File

@@ -359,7 +359,7 @@ CXStreamingResult CXReadUncompHuffman(CXUncompContextHuffman* context, const voi
while (context->bitsLeft) {
BOOL currBit = context->bits >> 31;
int c = (context->decodeTable->raw << currBit) & 0x80;
int c = (*(vu8*)context->decodeTable << currBit) & 0x80; // ?
context->decodeTable = GetNextNode((CXHuffmanDecodeTableEntry*)context->decodeTable, currBit);
context->bits <<= 1;

View File

@@ -597,10 +597,11 @@ static void cbForStateGettingError(u32 intType) {
if (error == REQUEST_ERROR_053000h) {
StampCommand(COMMAND_STOP_MOTOR, 0, 0);
DVDLowStopMotor(FALSE, FALSE, cbForStateCheckID1);
return;
} else {
stateError(NAND_ERROR_GENERIC);
return;
}
return;
} else {
stateError(NAND_ERROR_GENERIC);
return;
@@ -1707,11 +1708,12 @@ static void cbForStateBusy(u32 intType) {
NumInternalRetry = 0;
stateReady();
return;
} else {
StampCommand(COMMAND_STOP_MOTOR, 0, 0);
DVDLowStopMotor(FALSE, FALSE, cbForStateCheckID1);
return;
}
return;
}
if (CurrCommand == COMMAND_GET_PARTITION_PARAMS) {
@@ -1892,9 +1894,9 @@ s32 DVDGetCommandBlockStatus(const DVDCommandBlock* block) {
enabled = OSDisableInterrupts();
if (block->state == DVD_STATE_COVER_CLOSED) {
if (((volatile DVDCommandBlock*)block)->state == DVD_STATE_COVER_CLOSED) {
retVal = DVD_STATE_BUSY;
} else if (block->state == DVD_STATE_COVER_OPENED) {
} else if (((volatile DVDCommandBlock*)block)->state == DVD_STATE_COVER_OPENED) {
retVal = DVD_STATE_NO_DISK;
} else if (executing == &__DVDStopMotorCommandBlock) {
next = __DVDGetNextWaitingQueue();
@@ -1902,17 +1904,17 @@ s32 DVDGetCommandBlockStatus(const DVDCommandBlock* block) {
if (block == next) {
retVal = DVD_STATE_BUSY;
} else {
retVal = block->state;
retVal = ((volatile DVDCommandBlock*)block)->state;
}
} else {
if (block == &__DVDStopMotorCommandBlock) {
retVal = DVD_STATE_IDLE;
} else {
retVal = block->state;
retVal = ((volatile DVDCommandBlock*)block)->state;
}
}
} else {
retVal = block->state;
retVal = ((volatile DVDCommandBlock*)block)->state;
}
OSRestoreInterrupts(enabled);
@@ -2175,14 +2177,14 @@ s32 DVDCancel(DVDCommandBlock* block) {
enabled = OSDisableInterrupts();
while (TRUE) {
state = block->state;
state = ((volatile DVDCommandBlock*)block)->state;
if (state == DVD_STATE_IDLE || state == DVD_STATE_FATAL || state == DVD_STATE_CANCELED) {
break;
}
if (state == DVD_STATE_COVER_CLOSED) {
command = block->command;
command = ((volatile DVDCommandBlock*)block)->command;
if (command == COMMAND_BSREAD || command == COMMAND_READID || command == COMMAND_AUDIO_BUFFER_CONFIG ||
command == COMMAND_READ_UNENCRYPTED || command == COMMAND_OPEN_PARTITION || command == COMMAND_GET_PARTITION_PARAMS ||

View File

@@ -39,29 +39,6 @@ enum {
DVD_IOCTLV_GET_NO_DISC_BUFFER_SIZE = 0x92,
};
typedef struct DVDVideoPhysical {
u8 data[2048];
} DVDVideoPhysical;
typedef struct DVDVideoDiscKey {
u8 data[2048];
} DVDVideoDiscKey;
typedef struct DVDDiskBca {
u8 optionalInfo[52];
u8 manufacturerCode[2];
u8 recorderDeviceCode[2];
u8 APMRecorderDeviceCode[1];
u8 discManufactureDate[2];
u8 discManufactureTime[2];
u8 discNumber[3];
} DVDDiskBca;
typedef struct DVDLowDriveSer {
u8 data[12];
u8 reserved[20];
} DVDLowDriveSer;
typedef struct DVDLowContext {
DVDLowCallback callback;
int callbackType;
@@ -97,7 +74,7 @@ static u32 statusRegister[8] ALIGN32;
static u32 coverStatus[8] ALIGN32;
static u32 statusRegister[8] ALIGN32;
static DVDLowContext dvdContexts[4] ALIGN32 = {0};
static DVDLowContext dvdContexts[4] ALIGN32;
static DVDLowRegValues diRegValCache ALIGN32;
static u32 registerBuf[8] ALIGN32;
static IOSIoVector ioVec[10] ALIGN32;
@@ -122,6 +99,8 @@ static bool requestInProgress;
#define IS_ALIGNED(addr) (((u32)(addr) & 0x1F) == 0)
DECOMP_FORCE_ACTIVE(dvd_broadway_c, dvdContexts);
IOSError doTransactionCallback(IOSError ret, void* context) {
DVDLowContext* dvdContext = context;
@@ -156,32 +135,7 @@ out:
return 0;
}
static IOSError doCoverCallback(IOSError ret, void* context) {
DVDLowContext* dvdContext;
requestInProgress = false;
dvdContext = (DVDLowContext*)context;
if (dvdContext->contextMagic != 0xfeebdaed) {
OSReport("(doCoverCallback) Error - context mangled!\n");
dvdContext->contextMagic = 0xfeebdaed;
goto out;
}
if (dvdContext->callback != NULL) {
s32 callbackArg;
callbackInProgress = true;
callbackArg = ret;
if (breakRequested == true) {
breakRequested = false;
callbackArg |= 0x00000008;
}
dvdContext->callback((u32)callbackArg);
callbackInProgress = false;
}
out:
dvdContext->inUse = false;
return 0;
}
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(doCoverCallback) Error - context mangled!\n");
IOSError doPrepareCoverRegisterCallback(IOSError ret, void* context) {
DVDLowContext* dvdContext;
@@ -425,7 +379,7 @@ bool DVDLowOpenPartition(u32 partitionWordOffset, ESTicket* eTicket, u32 numCert
ioVec[1].length = sizeof(ESTicket);
}
ioVec[2].base = certificates;
ioVec[2].base = (u8*)certificates;
if (certificates == 0) {
ioVec[2].length = 0;
} else {
@@ -448,65 +402,14 @@ bool DVDLowOpenPartition(u32 partitionWordOffset, ESTicket* eTicket, u32 numCert
return true;
}
DECOMP_FORCE_ACTIVE(dvd_broadway_c, coverStatus);
DECOMP_FORCE_ACTIVE(dvd_broadway_c, coverRegister);
bool DVDLowOpenPartitionWithTmdAndTicket(const u32 partitionWordOffset, const ESTicket* const eTicket, const u32 numTmdBytes,
const ESTitleMeta* const tmd, const u32 numCertBytes, const u8* const certificates,
DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
if (eTicket != NULL && !(((u32)(eTicket) & 0x1F) == 0)) {
OSReport("(%s) eTicket memory is unaligned\n", __FUNCTION__);
return false;
}
if (certificates != NULL && !(((u32)(certificates) & 0x1F) == 0)) {
return false;
}
if (tmd == NULL) {
OSReport("(%s) tmd parameter cannot be NULL\n", __FUNCTION__);
return false;
} else if (!(((u32)(tmd) & 0x1F) == 0)) {
OSReport("(%s) tmd memory is unaligned\n", __FUNCTION__);
return false;
}
if (eTicket == NULL) {
OSReport("(%s) eTicket parameter cannot be NULL\n", __FUNCTION__);
return false;
} else if (!(((u32)(eTicket) & 0x1F) == 0)) {
OSReport("(%s) eTicket memory is unaligned\n", __FUNCTION__);
return false;
}
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x93;
diCommand[freeCommandBuf].arg[0] = partitionWordOffset;
ioVec[0].base = (u8*)&(diCommand[freeCommandBuf]);
ioVec[0].length = sizeof(DVDLowCommand);
ioVec[1].base = (u8*)eTicket;
ioVec[1].length = sizeof(ESTicket);
ioVec[2].base = (u8*)tmd;
ioVec[2].length = numTmdBytes;
ioVec[3].base = (u8*)certificates;
if (certificates == NULL) {
ioVec[3].length = 0;
} else {
ioVec[3].length = numCertBytes;
}
ioVec[4].base = (u8*)&(lastTicketError[0]);
ioVec[4].length = sizeof(lastTicketError);
rv = IOS_IoctlvAsync(DiFD, 0x93, 4, 1, ioVec, doTransactionCallback, dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowOpenPartition) IOS_IoctlvAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "DVDLowOpenPartitionWithTmdAndTicket");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(%s) eTicket memory is unaligned\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(%s) tmd parameter cannot be NULL\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(%s) tmd memory is unaligned\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(%s) eTicket parameter cannot be NULL\n");
bool DVDLowOpenPartitionWithTmdAndTicketView(u32 partitionWordOffset, ESTicketView* eTicketView, u32 numTmdBytes, ESTitleMeta* tmd, u32 numCertBytes,
u8* certificates, DVDLowCallback callback) {
@@ -550,7 +453,7 @@ bool DVDLowOpenPartitionWithTmdAndTicketView(u32 partitionWordOffset, ESTicketVi
ioVec[2].base = (u8*)tmd;
ioVec[2].length = numTmdBytes;
ioVec[3].base = certificates;
ioVec[3].base = (u8*)certificates;
if (certificates == 0) {
ioVec[3].length = 0;
} else {
@@ -678,49 +581,7 @@ bool DVDLowGetNoDiscOpenPartitionParams(const u32 partitionWordOffset, ESTicket*
return true;
}
bool DVDLowNoDiscOpenPartition(const ESTicket* const eTicket, const u32 numTmdBytes, const ESTitleMeta* const tmd, const u32 numCertBytes,
const u8* const certificates, const u32 dataWordOffset, const u8* const h3HashPtr, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
if (eTicket == NULL || tmd == NULL || certificates == NULL) {
OSReport("(%s) Error: NULL pointer argument\n", __FUNCTION__);
return false;
}
if (!(((u32)(eTicket) & 0x1F) == 0) || !(((u32)(tmd) & 0x1F) == 0) || !(((u32)(certificates) & 0x1F) == 0) ||
!(((u32)(dataWordOffset) & 0x1F) == 0) || !(((u32)(h3HashPtr) & 0x1F) == 0)) {
OSReport("(%s) pointer argument is unaligned\n", __FUNCTION__);
return false;
}
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x91;
diCommand[freeCommandBuf].arg[0] = dataWordOffset;
ioVec[0].base = (u8*)&(diCommand[freeCommandBuf]);
ioVec[0].length = sizeof(DVDLowCommand);
ioVec[1].base = (u8*)eTicket;
ioVec[1].length = sizeof(ESTicket);
ioVec[2].base = (u8*)tmd;
ioVec[2].length = numTmdBytes;
ioVec[3].base = (u8*)certificates;
ioVec[3].length = numCertBytes;
ioVec[4].base = (u8*)h3HashPtr;
ioVec[4].length = (96 * 1024);
ioVec[5].base = (u8*)&(lastTicketError[0]);
ioVec[5].length = sizeof(u32);
rv = IOS_IoctlvAsync(DiFD, 0x91, 5, 1, ioVec, doTransactionCallback, dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (%s) IOS_IoctlvAsync returned error: %d\n", __FUNCTION__, rv);
dvdContext->inUse = false;
return false;
}
return true;
}
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "DVDLowNoDiscOpenPartition");
bool DVDLowClosePartition(DVDLowCallback callback) {
DVDLowContext* dvdContext;
@@ -791,49 +652,12 @@ bool DVDLowStopMotor(bool eject, bool saving, DVDLowCallback callback) {
return true;
}
bool DVDLowWaitForCoverClose(DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 2);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x79;
rv = IOS_IoctlAsync(DiFD, 0x79, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), NULL, 0, doCoverCallback, dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowWaitForCoverClose) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
static char inquiryErrorMessage[] = "@@@ (DVDLowInquiry) IOS_IoctlAsync returned error: %d\n";
static char requestErrorMessage[] = "@@@ (DVDLowRequestError) IOS_IoctlAsync returned error: %d\n";
bool DVDLowNotifyReset(void) {
IOSError rv;
if (callbackInProgress == true) {
OSReport("(DVDLowSetSpinupFlag): Synch functions can't be called in callbacks\n");
return false;
}
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x7E;
rv = IOS_Ioctl(DiFD, 0x7E, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), NULL, 0);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowNotifyReset) IOS_IoctlAsync returned error: %d\n", rv);
return false;
}
return true;
}
static char resetErrorMessage[] = "@@@ (DVDLowReset) IOS_IoctlAsync returned error: %d\n";
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowWaitForCoverClose) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowInquiry) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowRequestError) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(DVDLowSetSpinupFlag): Synch functions can't be called in callbacks\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowNotifyReset) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReset) IOS_IoctlAsync returned error: %d\n");
bool DVDLowInquiry(DVDDriveInfo* info, DVDLowCallback callback) {
DVDLowContext* dvdContext;
@@ -849,7 +673,7 @@ bool DVDLowInquiry(DVDDriveInfo* info, DVDLowCallback callback) {
ret = IOS_IoctlAsync(DiFD, DVD_IOCTL_INQUIRY, &diCommand[freeCommandBuf], sizeof(DVDLowCommand), info, sizeof(DVDDriveInfo),
doTransactionCallback, dvdContext);
if (ret != IPC_RESULT_OK) {
OSReport(inquiryErrorMessage, ret);
OSReport("@@@ (DVDLowInquiry) IOS_IoctlAsync returned error: %d\n", ret);
dvdContext->inUse = false;
return false;
}
@@ -871,7 +695,7 @@ bool DVDLowRequestError(DVDLowCallback callback) {
ret = IOS_IoctlAsync(DiFD, DVD_IOCTL_REQUEST_ERROR, &diCommand[freeCommandBuf], sizeof(DVDLowCommand), &diRegValCache, sizeof(DVDLowRegValues),
doTransactionCallback, dvdContext);
if (ret != IPC_RESULT_OK) {
OSReport(requestErrorMessage, ret);
OSReport("@@@ (DVDLowRequestError) IOS_IoctlAsync returned error: %d\n", ret);
dvdContext->inUse = false;
return false;
}
@@ -898,7 +722,7 @@ bool DVDLowReset(DVDLowCallback callback) {
ret = IOS_IoctlAsync(DiFD, DVD_IOCTL_RESET, &diCommand[freeCommandBuf], sizeof(DVDLowCommand), 0, 0, doTransactionCallback, dvdContext);
if (ret != IPC_RESULT_OK) {
OSReport(resetErrorMessage, ret);
OSReport("@@@ (DVDLowReset) IOS_IoctlAsync returned error: %d\n", ret);
dvdContext->inUse = false;
return false;
}
@@ -930,305 +754,20 @@ bool DVDLowAudioBufferConfig(BOOL enable, u32 size, DVDLowCallback callback) {
return true;
}
u32 DVDLowGetCoverStatus(void) {
IOSError rv;
if (callbackInProgress == true) {
OSReport("(DVDLowGetCoverStatus): Synch functions can't be called in callbacks\n");
return false;
}
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x88;
rv = IOS_Ioctl(DiFD, 0x88, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), coverStatus, sizeof(u32) * 8);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowGetCoverStatus) IOS_Ioctl returned error: %d\n", rv);
return 0xdeaddead;
}
return coverStatus[0];
}
bool DVDLowReadDvd(u32 strm, u32 retry, void* destAddr, u32 lengthInSectors, u32 lsn, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xD0;
if (strm == 0) {
diCommand[freeCommandBuf].arg[0] = 0x0;
} else {
diCommand[freeCommandBuf].arg[0] = 0x1;
}
if (retry == 0) {
diCommand[freeCommandBuf].arg[1] = 0x0;
} else {
diCommand[freeCommandBuf].arg[1] = 0x1;
}
diCommand[freeCommandBuf].arg[2] = lengthInSectors;
diCommand[freeCommandBuf].arg[3] = lsn;
readLength = lengthInSectors * 2048;
rv = IOS_IoctlAsync(DiFD, 0xD0, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), destAddr, lengthInSectors * 2048, doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowReadDVD) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowReadDvdConfig(bool set, u32 type, u32 config, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xD1;
diCommand[freeCommandBuf].arg[0] = set;
diCommand[freeCommandBuf].arg[1] = type;
diCommand[freeCommandBuf].arg[2] = config;
rv = IOS_IoctlAsync(DiFD, 0xD1, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), &diRegValCache, sizeof(DVDLowRegValues), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowReadDVDConfig) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowReadDvdCopyright(u32 layer, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x81;
diCommand[freeCommandBuf].arg[0] = layer;
rv = IOS_IoctlAsync(DiFD, 0x81, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), &diRegValCache, sizeof(DVDLowRegValues), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowReadDvdCopyright) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowReadDvdPhysical(DVDVideoPhysical* physical, u32 layer, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x80;
diCommand[freeCommandBuf].arg[0] = layer;
rv = IOS_IoctlAsync(DiFD, 0x80, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), physical, sizeof(DVDVideoPhysical), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowReadDvdPhysical) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowReadDvdDiscKey(DVDVideoDiscKey* diskKey, u32 layer, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x82;
diCommand[freeCommandBuf].arg[0] = layer;
rv = IOS_IoctlAsync(DiFD, 0x82, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), diskKey, sizeof(DVDVideoDiscKey), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowReadDvdDiscKey) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowReportKey(DVDVideoReportKey* reportKey, u32 format, u32 lsn, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xA4;
diCommand[freeCommandBuf].arg[0] = format >> 16;
diCommand[freeCommandBuf].arg[1] = lsn;
rv = IOS_IoctlAsync(DiFD, 0xA4, &diCommand[freeCommandBuf], sizeof(DVDLowCommand), reportKey, sizeof(DVDVideoReportKey), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowReportKey) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowOffset(u32 subcmd, u32 offset_4_byte, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xD9;
if (subcmd == 0) {
diCommand[freeCommandBuf].arg[0] = 0x0;
} else {
diCommand[freeCommandBuf].arg[0] = 0x1;
}
diCommand[freeCommandBuf].arg[1] = offset_4_byte;
rv = IOS_IoctlAsync(DiFD, 0xD9, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), &diRegValCache, sizeof(DVDLowRegValues), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowOffset) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowStopLaser(DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xD2;
rv = IOS_IoctlAsync(DiFD, 0xD2, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), &diRegValCache, sizeof(DVDLowRegValues), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowStopLaser) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowReadDiskBca(DVDDiskBca* diskBca, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xDA;
rv =
IOS_IoctlAsync(DiFD, 0xDA, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), diskBca, sizeof(DVDDiskBca), doTransactionCallback, dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowReadDiskBca) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowSerMeasControl(DVDLowDriveSer* ser, bool clear, bool enable, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xDF;
diCommand[freeCommandBuf].arg[0] = clear;
diCommand[freeCommandBuf].arg[1] = enable;
rv =
IOS_IoctlAsync(DiFD, 0xDF, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), ser, sizeof(DVDLowDriveSer), doTransactionCallback, dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowSerMeasControl) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowRequestDiscStatus(DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xDB;
rv = IOS_IoctlAsync(DiFD, 0xDB, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), &diRegValCache, sizeof(DVDLowRegValues), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowRequestDiscStatus) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowRequestRetryNumber(DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xDC;
rv = IOS_IoctlAsync(DiFD, 0xDC, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), &diRegValCache, sizeof(DVDLowRegValues), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowRequestRetryNumber) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(DVDLowGetCoverStatus): Synch functions can't be called in callbacks\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowGetCoverStatus) IOS_Ioctl returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReadDVD) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReadDVDConfig) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReadDvdCopyright) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReadDvdPhysical) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReadDvdDiscKey) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReportKey) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowOffset) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowStopLaser) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReadDiskBca) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowSerMeasControl) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowRequestDiscStatus) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowRequestRetryNumber) IOS_IoctlAsync returned error: %d\n");
bool DVDLowSetMaximumRotation(u32 subcmd, DVDLowCallback callback) {
DVDLowContext* dvdContext;
@@ -1305,26 +844,8 @@ bool DVDLowSeek(u32 wordOffset, DVDLowCallback callback) {
return true;
}
u32 DVDLowGetCoverReg(void) {
IOSError rv;
if (callbackInProgress == true) {
OSReport("(DVDLowGetCoverReg): Synch functions can't be called in callbacks\n");
return false;
}
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x7A;
rv = IOS_Ioctl(DiFD, 0x7A, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), coverRegister, sizeof(u32) * 8);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowGetCoverReg) IOS_Ioctl returned error: %d\n", rv);
return false;
}
return coverRegister[0];
}
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(DVDLowGetCoverReg): Synch functions can't be called in callbacks\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowGetCoverReg) IOS_Ioctl returned error: %d\n");
u32 DVDLowGetCoverRegister() {
return diRegValCache.diCoverReg;
@@ -1420,23 +941,4 @@ BOOL __DVDLowTestAlarm(OSAlarm* alarm) {
return FALSE;
}
bool DVDLowEnableDvdVideo(const bool enable, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x8E;
diCommand[freeCommandBuf].arg[0] = enable;
requestInProgress = true;
dvdContext = newContext(callback, 1);
rv = IOS_IoctlAsync(DiFD, 0x8E, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), NULL, 0, doTransactionCallback, dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowEnableDvdVideo) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowEnableDvdVideo) IOS_IoctlAsync returned error: %d\n"); // DVD video...

View File

@@ -326,7 +326,7 @@ s32 DVDReadPrio(DVDFileInfo* fileInfo, void* addr, s32 length, s32 offset, s32 p
enabled = OSDisableInterrupts();
while (TRUE) {
state = block->state;
state = ((DVDCommandBlock*)block)->state;
if (state == DVD_STATE_IDLE) {
retVal = block->transferredSize;

View File

@@ -1270,17 +1270,17 @@ ESError ES_Encrypt(u32 keyNum, u8* iv, u8* input, u32 size, u8* output) {
vec[0].length = sizeof(*pKeyNum);
// IV read
vec[1].base = iv;
vec[1].base = (u8*)iv;
vec[1].length = 16;
vec[2].base = input;
vec[2].base = (u8*)input;
vec[2].length = size;
// IV write
vec[3].base = iv;
vec[3].base = (u8*)iv;
vec[3].length = 16;
vec[4].base = output;
vec[4].base = (u8*)output;
vec[4].length = size;
ret = IOS_Ioctlv(__esFd, ES_IOCTLV_ENCRYPT, 3, 2, vec);
@@ -1306,17 +1306,17 @@ ESError ES_Decrypt(u32 keyNum, u8* iv, u8* input, u32 size, u8* output) {
vec[0].length = sizeof(*pKeyNum);
// IV read
vec[1].base = iv;
vec[1].base = (u8*)iv;
vec[1].length = 16;
vec[2].base = input;
vec[2].base = (u8*)input;
vec[2].length = size;
// IV write
vec[3].base = iv;
vec[3].base = (u8*)iv;
vec[3].length = 16;
vec[4].base = output;
vec[4].base = (u8*)output;
vec[4].length = size;
ret = IOS_Ioctlv(__esFd, ES_IOCTLV_DECRYPT, 3, 2, vec);

View File

@@ -7,12 +7,14 @@
static u32 IpcNumPendingReqs = 0;
static u32 IpcNumUnIssuedReqs = 0;
static s32 IpcFdArray[MAX_REQUEST] = {0};
static s32 IpcFdArray[MAX_REQUEST];
static u32 IpcReqPtrArray[MAX_REQUEST];
static void AddReqInfo(void* ptr, s32 fd);
static void DelReqInfo(void* ptr, s32 fd);
DECOMP_FORCE_ACTIVE(ipcProfile_c, IpcFdArray); // Force `IpcFdArray` to be first
void IPCiProfInit() {
u32 i;

View File

@@ -55,11 +55,12 @@ void nandRemoveTailToken(char* newPath, const char* oldPath) {
if (i != 0) {
strncpy(newPath, oldPath, i);
newPath[i] = '\0';
break;
} else {
newPath[0] = '/';
newPath[1] = '\0';
break;
}
break;
}
}
}

View File

@@ -518,7 +518,7 @@ void OSInit() {
void* bi2StartAddr;
void* arenaAddr;
OSExecParams* params = &__OSRebootParams;
volatile OSExecParams* params = (volatile OSExecParams*)&__OSRebootParams;
if (AreWeInitialized == FALSE) {
BOOL enabled;

View File

@@ -19,7 +19,7 @@
/* some string pooling (the first one is used but is just pooled first...)*/
static char execFailure[] = "\nOSExec(): Failed to exec %d in %d\n";
DECOMP_FORCE_ACTIVE(OSExec_c, "\nOSExec(): Failed to exec %d in %d\n");
DECOMP_FORCE_ACTIVE(OSExec_c, "\nOSExec(): The specified game doesn't exist in the disc\n");
extern BOOL __OSInIPL;
@@ -384,13 +384,13 @@ void LaunchCommon(ESTitleId titleId, u32 launchArg, const char** argv, BOOL laun
} else {
ret = ESP_InitLib();
if (ret != ES_ERR_OK) {
OSReport(execFailure, ret, 1712);
OSReport("\nOSExec(): Failed to exec %d in %d\n", ret, 1712);
__OSHotResetForError();
}
ret = ESP_GetTitleId(&title);
if (ret != ES_ERR_OK) {
OSReport(execFailure, ret, 1720);
OSReport("\nOSExec(): Failed to exec %d in %d\n", ret, 1720);
__OSHotResetForError();
}
}

View File

@@ -10,6 +10,8 @@ static NANDFileInfo FileInfo;
static NANDCommandBlock Block;
static OSAlarm PlayRecordAlarm;
DECOMP_FORCE_ACTIVE(OSPlayRecord_c, PlayRecord);
static BOOL PlayRecordGet = FALSE;
static s32 PlayRecordState = OS_RECORD_STATE_STOPPED;
static BOOL PlayRecordError = FALSE;

View File

@@ -63,36 +63,11 @@ vBOOL __OSIsReturnToIdle;
}
// They're used but pooled first.
static char resetSource[] = "OSReset.c";
static char hotResetFailure[] = "__OSHotReset(): Falied to reset system.\n";
DECOMP_FORCE_ACTIVE(OSReset_c, "OSReset.c");
DECOMP_FORCE_ACTIVE(OSReset_c, "__OSHotReset(): Falied to reset system.\n");
DECOMP_FORCE_ACTIVE(OSReset_c, "OSReturnToMenu(): Falied to boot system menu.\n");
void __OSReturnToMenu(u8 menuMode) {
OSStateFlags state;
__OSStopPlayRecord();
__OSUnRegisterStateEvent();
__DVDPrepareReset();
__OSReadStateFlags(&state);
state.discState = __OSGetDiscState(state.discState);
state.shutdownType = OS_STATE_FLAGS_SHUTDOWN_RETURN_MENU;
state.menuMode = menuMode;
__OSClearRTCFlags();
__OSWriteStateFlags(&state);
OSDisableScheduler();
__OSShutdownDevices(OS_SHUTDOWN_RETURN_MENU);
OSEnableScheduler();
__OSLaunchMenu();
OSDisableScheduler();
__VISetRGBModeImm();
__OSHotResetForError();
}
void OSReturnToDataManager(void) {
__OSReturnToMenu(OS_STATE_FLAGS_MENUMODE_DATA_MANAGER);
OSPanic(resetSource, __LINE__, "OSReturnToDataManager(): Falied to boot system menu.\n");
}
DECOMP_FORCE_ACTIVE(OSReset_c, "OSReturnToDataManager(): Falied to boot system menu.\n");
enum {
LAUNCH_ARG_MENU = 0,
@@ -237,7 +212,7 @@ void OSReturnToSetting(u8 setting) {
}
default: {
OSReport("OSReturnToSetting(): You can't specify %d. \n", setting);
OSPanic(resetSource, 910, "");
OSHalt("", 910);
}
}
@@ -259,7 +234,7 @@ void __OSReturnToMenuForError() {
__VISetRGBModeImm();
__OSHotResetForError();
OSPanic(resetSource, 949, "__OSReturnToMenu(): Falied to boot system menu.\n");
OSHalt("__OSReturnToMenu(): Falied to boot system menu.\n", 949);
}
void __OSHotResetForError() {
@@ -267,7 +242,7 @@ void __OSHotResetForError() {
__OSInitSTM();
}
__OSHotReset();
OSPanic(resetSource, 973, hotResetFailure);
OSHalt("__OSHotReset(): Falied to reset system.\n", 973);
}
u32 OSGetResetCode() {
@@ -280,11 +255,5 @@ u32 OSGetResetCode() {
return code;
}
void OSResetSystem(int reset, u32 resetCode, int forceMenu) {
OSPanic(resetSource, __LINE__, "OSResetSystem() is obsoleted. It doesn't work any longer.\n");
}
u32 OSSetBootDol(u32 dolOffset) {
OSPanic(resetSource, __LINE__, "OSSetBootDol() is obsoleted. It doesn't work any longer.\n");
return 0;
}
DECOMP_FORCE_ACTIVE(OSReset_c, "OSResetSystem() is obsoleted. It doesn't work any longer.\n");
DECOMP_FORCE_ACTIVE(OSReset_c, "OSSetBootDol() is obsoleted. It doesn't work any longer.\n");

View File

@@ -13,7 +13,7 @@ s32 OSWaitSemaphore(OSSemaphore* sem) {
BOOL enabled = OSDisableInterrupts();
s32 count;
while ((count = sem->count) <= 0) {
while ((count = ((volatile OSSemaphore*)sem)->count) <= 0) {
OSSleepThread(&sem->queue);
}
sem->count--;
@@ -28,7 +28,7 @@ s32 OSSignalSemaphore(OSSemaphore* sem) {
s32 count;
count = sem->count;
sem->count = count + 1;
sem->count++;
OSWakeupThread(&sem->queue);

View File

@@ -537,7 +537,7 @@ BOOL OSJoinThread(OSThread* thread, void* val) {
}
}
if (thread->state == OS_THREAD_STATE_DEAD) {
if (((volatile OSThread*)thread)->state == OS_THREAD_STATE_DEAD) {
if (val != NULL) {
*(u32*)val = (u32)thread->value;
}

View File

@@ -741,7 +741,7 @@ static void RSORelocate(RSORel* rel, int index, u32 offset) {
x = offset + rel->addend;
y = ((u32)p & ~0x03FFFFFC) | ((((u32)p & 0x03FFFFFC) + (*p & 0x03FFFFFC)) & 0x03FFFFFC);
#if SDK_VERSION > 20090224 && !defined(SDK_IPL)
if ((x != 0) && (x != y)) {
if (((u32)x != 0) && (x != y)) {
*p = (u32)((*p & ~0x03FFFFFC) | 0x03FF0000 | 0xFFFC);
}
#endif

View File

@@ -314,7 +314,7 @@ static IOSFd sduOpenFD(u32 slot) {
switch (ret) {
case IPC_RESULT_ACCESS:
case IPC_RESULT_EXISTS: {
ASSERTLINE(ret >= 0, 314);
int dummy = 0;
}
}
return ret;

View File

@@ -37,42 +37,13 @@ typedef struct USBMsg {
u16 length; // 0x04
} USBMsg;
typedef struct {
u8 bLength;
u8 bDescriptorType;
u16 bcdUSB;
u8 bDeviceClass;
u8 bDeviceSubClass;
u8 bDeviceProtocol;
u8 bMaxPacketSize0;
u16 idVendor;
u16 idProduct;
u16 bcdDevice;
u8 iManufacturer;
u8 iProduct;
u8 iSerialNumber;
u8 bNumConfigurations;
} USBDeviceDescriptor;
typedef struct USBDeviceInfo {
IOSFd fd;
u16 vid;
u16 pid;
} USBDeviceInfo;
typedef struct USBIsoTransfer {
void* buf;
u8 numPackets;
u16* packets;
} USBIsoTransfer;
typedef struct USBCommandBlock {
USBCallback callback; // 0x00
USBIsoCallback isoCallback; // 0x04
void* callbackArg; // 0x08
void* isoArg; // 0x0C
void* spare;
char pad_0x10[0x4];
void* clean[USB_NCLEAN_MAX]; // 0x14
u32 nclean; // 0x34
@@ -80,7 +51,6 @@ typedef struct USBCommandBlock {
union {
char path[FS_MAX_PATH];
USBMsg msg;
USBDeviceDescriptor descriptor;
}; // 0x40
} USBCommandBlock;
@@ -243,40 +213,16 @@ end:
return result;
}
IOSError IUSB_OpenDeviceIdsAsync(const char* interface, u16 vid, u16 pid, USBCallback callback, void* callbackArg) {
IOSError result;
USBCommandBlock* block;
USB_LOG("OpenDevice\n");
block = IOSAlloc(sizeof(USBCommandBlock));
if (block == NULL) {
USB_ERR("OpenDeviceIdsAsync: Not enough memory\n");
return IPC_RESULT_ALLOC_FAILED;
}
memset(block, 0, sizeof(USBCommandBlock));
block->callback = callback;
block->callbackArg = callbackArg;
block->nclean = USB_NCLEAN_CLOSEDEVICE;
snprintf(block->path, sizeof(block->path), "/dev/usb/%s/%x/%x", interface, vid, pid);
USB_LOG("OpenDevice - %s\n", block->path);
result = IOS_OpenAsync(block->path, 0, _intrBlkCtrlIsoCb, block);
USB_LOG("OpenDevice returned: %d\n", result);
if (result < IPC_RESULT_OK) {
IOSFree(block);
}
return result;
}
static char closeDeviceMessage[] = "CloseDevice\n";
static char closeDeviceResult[] = "CloseDevice returned: %d\n";
DECOMP_FORCE_ACTIVE(usb_c, "OpenDevice\n");
DECOMP_FORCE_ACTIVE(usb_c, "OpenDeviceIdsAsync: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "CloseDevice\n");
DECOMP_FORCE_ACTIVE(usb_c, "CloseDevice returned: %d\n");
IOSError IUSB_CloseDeviceAsync(s32 fd, USBCallback callback, void* callbackArg) {
IOSError result;
USBCommandBlock* block;
USB_LOG(closeDeviceMessage);
USB_LOG("CloseDevice\n");
block = IOSAlloc(sizeof(USBCommandBlock));
if (block == NULL) {
@@ -292,7 +238,7 @@ IOSError IUSB_CloseDeviceAsync(s32 fd, USBCallback callback, void* callbackArg)
block->nclean = USB_NCLEAN_CLOSEDEVICE;
result = IOS_CloseAsync(fd, _intrBlkCtrlIsoCb, block);
USB_LOG(closeDeviceResult, result);
USB_LOG("CloseDevice returned: %d\n", result);
if (result < 0) {
IOSFree(block);
@@ -302,83 +248,8 @@ end:
return result;
}
static IOSFd __openDevice(const char* path) {
IOSFd rv;
char* pathBuf;
USBCommandBlock* ctx = IOSAlloc(OSRoundUp32B(sizeof(USBCommandBlock)));
if (ctx == 0) {
USB_ERR("openDevice: Not enough memory\n");
rv = IPC_RESULT_ALLOC_FAILED;
goto done;
}
pathBuf = ctx->path;
strncpy(pathBuf, path, 64);
rv = IOS_Open(pathBuf, 0);
IOSFree(ctx);
done:
return rv;
}
IOSError IUSB_GetDeviceList(const char* path, USBDeviceInfo* deviceList, u8 maxDev, u8 deviceClass, u8* numDev) {
IOSError rv = IPC_RESULT_OK;
IOSIoVector* vector = NULL;
u8* smaxDev = NULL;
u8* sclass = NULL;
u8* snumDev = NULL;
IOSFd fd;
if ((u32)deviceList & 0x1f) {
rv = IPC_RESULT_INVALID;
goto out;
}
if ((fd = __openDevice(path)) < 0) {
rv = fd;
goto out;
}
vector = IOSAlloc(OSRoundUp32B(sizeof(IOSIoVector)) * 4);
smaxDev = IOSAlloc(OSRoundUp32B(sizeof(u8)));
sclass = IOSAlloc(OSRoundUp32B(sizeof(u8)));
snumDev = IOSAlloc(OSRoundUp32B(sizeof(u8)));
if (NULL == smaxDev || NULL == sclass || NULL == snumDev || NULL == vector) {
USB_ERR("getDeviceList: Not enough memory\n");
rv = IPC_RESULT_ALLOC_FAILED;
goto out;
}
*smaxDev = maxDev;
*sclass = deviceClass;
*snumDev = 0;
vector[0].base = smaxDev;
vector[0].length = sizeof(u8);
vector[1].base = sclass;
vector[1].length = sizeof(u8);
vector[2].base = (u8*)snumDev;
vector[2].length = sizeof(u8);
vector[3].base = (u8*)deviceList;
vector[3].length = sizeof(USBDeviceInfo) * maxDev;
DCInvalidateRange(deviceList, sizeof(USBDeviceInfo) * maxDev);
DCInvalidateRange(snumDev, OSRoundUp32B(sizeof(u8)));
DCFlushRange(sclass, OSRoundUp32B(sizeof(u8)));
DCFlushRange(smaxDev, OSRoundUp32B(sizeof(u8)));
DCFlushRange(vector, OSRoundUp32B(sizeof(IOSIoVector)) * 4);
rv = IOS_Ioctlv(fd, 12, 2, 2, vector);
*numDev = *snumDev;
IOS_Close(fd);
out:
IOSFree(snumDev);
IOSFree(smaxDev);
IOSFree(sclass);
IOSFree(vector);
return rv;
}
DECOMP_FORCE_ACTIVE(usb_c, "openDevice: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "getDeviceList: Not enough memory\n");
IOSError __IntrBlkMsgInt(s32 fd, u32 endpoint, u32 length, void* buffer, u8 ioctl, USBCallback callback, void* callbackArg, u8 async) {
IOSError result;
@@ -608,397 +479,44 @@ end_async:
return result;
}
IOSError IUSB_ReadCtrlMsgAsync(IOSFd fd, u8 reqType, u8 request, u16 value, u16 index, u16 buflen, char* buf, USBCallback cb, void* cbArg) {
DCInvalidateRange(buf, buflen);
return __CtrlMsgInt(fd, reqType, request, value, index, buflen, buf, cb, cbArg, 1);
}
IOSError IUSB_WriteCtrlMsgAsync(s32 fd, u8 requestType, u8 request, u16 value, u16 index, u16 length, void* buffer, USBCallback callback,
void* callbackArg) {
DCFlushRange(buffer, length);
return __CtrlMsgInt(fd, requestType, request, value, index, length, buffer, callback, callbackArg, TRUE);
}
static s8 unicode2ascii(char* tbuf, int buflen) {
char buf[128];
s8 di, si;
if (tbuf[1] != 0x03) {
di = -1;
goto out;
}
for (di = 0, si = 2; si < tbuf[0] && si < buflen; si += 2) {
if (di >= (sizeof(buf) - 1))
break;
if (tbuf[si + 1])
buf[di++] = '?';
else
buf[di++] = tbuf[si];
}
buf[di] = 0;
memcpy(tbuf, buf, (u32)di);
out:
return di;
}
static void _GetStrCb(IOSError ret, void* ctxt) {
IOSError rv = ret;
USBCommandBlock* req = (USBCommandBlock*)ctxt;
char* buf;
u16 buflen;
s8 len;
USB_LOG("GetStrCb returned: %d\n", rv);
if (rv <= 0)
goto out;
buf = (char*)req->msg.buffer;
buflen = req->msg.length;
USB_LOG("GetStrCb: buf = 0x%x buflen = %u\n", buf, buflen);
if ((len = unicode2ascii(buf, buflen)) < 0)
USB_ERR("Failed to convert buffer from unicode 2 ascii\n");
else
buf[len] = '\0';
out:
if (req->callback) {
USB_LOG("calling cb 0x%x with arg 0x%x\n", req->callback, req->callbackArg);
req->callback(ret, req->callbackArg);
}
IOSFree(req);
return;
}
IOSError IUSB_GetAsciiStr(IOSFd fd, u8 ep, u16 index, u16 langId, char* buf, u16 buflen) {
IOSError rv = IPC_RESULT_OK;
s8 len;
USB_LOG("GetStr\n");
DCInvalidateRange(buf, (u32)buflen);
rv = __CtrlMsgInt(fd, 0x80, 0x06, (u16)((0x03 << 8) + index), langId, buflen, buf, NULL, NULL, 0);
if (rv <= 0) {
USB_ERR("Failed __CtrlMsg: %d", rv);
goto out;
}
if ((len = unicode2ascii(buf, buflen)) < 0)
USB_ERR("Failed to convert unicode 2 ascii\n");
else
buf[len] = '\0';
out:
return rv;
}
IOSError IUSB_GetAsciiStrAsync(IOSFd fd, u8 ep, u16 index, u16 langId, char* buf, u16 buflen, USBCallback cb, void* cbArg) {
IOSError rv = IPC_RESULT_OK;
USBCommandBlock* req;
USB_LOG("GetStr - _GetStrCb\n");
req = IOSAlloc(OSRoundUp32B(sizeof(*req)));
if (req == 0) {
USB_ERR(" GetAsciiStrAsync: Not enough memory\n");
rv = IPC_RESULT_ALLOC_FAILED;
goto out;
}
memset(req, 0, sizeof(USBCommandBlock));
req->callback = cb;
req->callbackArg = cbArg;
req->nclean = 0;
req->msg.buffer = buf;
req->msg.length = buflen;
DCInvalidateRange(buf, buflen);
rv = __CtrlMsgInt(fd, 0x80, 0x06, (u16)((0x03 << 8) + index), langId, buflen, buf, _GetStrCb, req, 1);
if (rv < 0) {
USB_ERR("__CtrlMsgInt failed %d\n", rv);
IOSFree(req);
goto out;
}
out:
return rv;
}
static void _GetDescrCb(IOSError ret, void* ctxt) {
IOSError rv = ret;
USBCommandBlock* req = (USBCommandBlock*)ctxt;
USB_LOG("GetDescrCb returned: %d\n", rv);
if (rv <= 0)
goto out;
*(USBDeviceDescriptor*)req->spare = req->descriptor;
out:
if (req->callback)
req->callback(ret, req->callbackArg);
IOSFree(req);
return;
}
IOSError IUSB_GetDevDescr(IOSFd fd, USBDeviceDescriptor* des) {
IOSError rv = IPC_RESULT_OK;
USBCommandBlock* req = 0;
USB_LOG("GetDevDescr\n");
req = IOSAlloc(OSRoundUp32B(sizeof(*req)));
if (req == 0) {
USB_ERR("GetDevDescr: Not enough memory\n");
rv = IPC_RESULT_ALLOC_FAILED;
goto out;
}
memset(req, 0, sizeof(USBCommandBlock));
DCInvalidateRange(&req->descriptor, (u32)sizeof(*des));
rv = __CtrlMsgInt(fd, 0x80, 0x06, 0x100, 0, sizeof(*des), &req->descriptor, NULL, NULL, 0);
if (rv < 0) {
USB_ERR("Failed __CtrlMsg: %d", rv);
goto out;
}
USB_LOG("GetDevDescr: %d\n", rv);
*des = req->descriptor;
out:
IOSFree(req);
return rv;
}
IOSError IUSB_GetDevDescrAsync(IOSFd fd, USBDeviceDescriptor* des, USBCallback cb, void* cbArg) {
IOSError rv = IPC_RESULT_OK;
USBCommandBlock* req;
USB_LOG("GetDevDescr - _GetDescrCb\n");
req = IOSAlloc(OSRoundUp32B(sizeof(*req)));
if (req == 0) {
USB_ERR("GetDevDescrAsync: Not enough memory\n");
rv = IPC_RESULT_ALLOC_FAILED;
goto out;
}
memset(req, 0, sizeof(USBCommandBlock));
req->callback = cb;
req->callbackArg = cbArg;
req->nclean = 0;
req->spare = des;
rv = IUSB_ReadCtrlMsgAsync(fd, 0x80, 0x06, 0x100, 0, sizeof(*des), (char*)&req->descriptor, _GetDescrCb, req);
if (rv < 0) {
IOSFree(req);
goto out;
}
out:
return rv;
}
IOSError IUSB_DeviceRemovalNotifyAsync(IOSFd fd, IOSIpcCb cb, void* cbArg) {
IOSError rv;
USB_LOG("DeviceRemovalNotifyAsync\n");
rv = IOS_IoctlAsync(fd, 26, 0, 0, 0, 0, cb, cbArg);
return rv;
}
static IOSError __checkIsoArgs(USBIsoTransfer* xfer, u16* buflen) {
IOSError rv = IPC_RESULT_INVALID;
if (NULL == xfer || NULL == xfer->buf || 0 == xfer->numPackets || xfer->numPackets > 8 || NULL == xfer->packets) {
goto out;
}
{
u32 i;
*buflen = 0;
for (i = 0; i < xfer->numPackets; ++i) {
if (xfer->packets[i] > 1023) {
USB_ERR("packet %u too big: %u\n", i, xfer->packets[i]);
goto out;
}
*buflen += xfer->packets[i];
}
}
rv = IPC_RESULT_OK;
out:
return rv;
}
IOSError IUSB_IsoMsgAsync(IOSFd fd, u8 ep, USBIsoTransfer* xfer, USBIsoCallback cb, void* cbArg) {
IOSError rv = IPC_RESULT_OK;
u8 *sep, *snumPackets;
u16* sbuflen;
IOSIoVector* vector;
USBCommandBlock* req;
u16 buflen;
if (0 == ep || NULL == cb || (__checkIsoArgs(xfer, &buflen) < 0)) {
USB_ERR("Invalid parameters for ISO transfer request\n");
rv = IPC_RESULT_INVALID;
goto out;
}
vector = IOSAlloc(OSRoundUp32B(sizeof(IOSIoVector)) * 5);
sep = IOSAlloc(OSRoundUp32B(sizeof(u8)));
sbuflen = IOSAlloc(OSRoundUp32B(sizeof(u16)));
snumPackets = IOSAlloc(OSRoundUp32B(sizeof(u8)));
req = IOSAlloc(OSRoundUp32B(sizeof(*req)));
if (NULL == vector || NULL == sep || NULL == sbuflen || NULL == req) {
USB_ERR("IUSB_IsoMsgAsync: Not enough memory\n");
rv = IPC_RESULT_ALLOC_FAILED;
IOSFree(req);
goto clean;
}
memset(req, 0, sizeof(USBCommandBlock));
*sep = ep;
*sbuflen = buflen;
*snumPackets = xfer->numPackets;
vector[0].base = (u8*)sep;
vector[0].length = sizeof(u8);
vector[1].base = (u8*)sbuflen;
vector[1].length = sizeof(u16);
vector[2].base = snumPackets;
vector[2].length = sizeof(u8);
vector[3].base = (u8*)xfer->packets;
vector[3].length = sizeof(u16) * xfer->numPackets;
vector[4].base = xfer->buf;
vector[4].length = buflen;
DCFlushRange(sep, OSRoundUp32B(sizeof(u8)));
DCFlushRange(sbuflen, OSRoundUp32B(sizeof(u16)));
DCFlushRange(snumPackets, OSRoundUp32B(sizeof(u8)));
DCFlushRange(vector, OSRoundUp32B(sizeof(IOSIoVector)) * 5);
req->isoCallback = cb;
req->isoArg = xfer;
req->callbackArg = cbArg;
req->nclean = 4;
req->clean[0] = sep;
req->clean[1] = sbuflen;
req->clean[2] = snumPackets;
req->clean[3] = vector;
rv = IOS_IoctlvAsync(fd, 9, 3, 2, vector, _intrBlkCtrlIsoCb, req);
if (rv < 0) {
IOSFree(req);
goto clean;
}
goto out;
clean:
IOSFree(sep);
IOSFree(sbuflen);
IOSFree(snumPackets);
IOSFree(vector);
out:
return rv;
}
IOSError IUSB_DeviceInsertionNotifyAsync(const char* path, u16 vid, u16 pid, USBCallback cb, void* cbArg) {
IOSError rv;
IOSFd fd;
IOSIoVector* vector;
u16 *svid, *spid;
USBCommandBlock* req;
if (NULL == path || 0 == vid || 0 == pid) {
rv = IPC_RESULT_INVALID;
goto done;
}
if ((fd = IOS_Open(path, 0)) < 0) {
rv = fd;
USB_ERR("Open(%s) failed\n", path);
goto done;
}
vector = IOSAlloc(OSRoundUp32B(sizeof(IOSIoVector)) * 2);
spid = IOSAlloc(OSRoundUp32B(sizeof(u16)));
svid = IOSAlloc(OSRoundUp32B(sizeof(u16)));
req = IOSAlloc(OSRoundUp32B(sizeof(*req)));
if (NULL == vector || NULL == spid || NULL == svid || NULL == req) {
USB_ERR("getDeviceList: Not enough memory\n");
rv = IPC_RESULT_ALLOC_FAILED;
goto clean;
}
memset(req, 0, sizeof(USBCommandBlock));
*svid = vid;
*spid = pid;
vector[0].base = (u8*)svid;
vector[0].length = sizeof(u16);
vector[1].base = (u8*)spid;
vector[1].length = sizeof(u16);
DCFlushRange(svid, OSRoundUp32B(sizeof(u16)));
DCFlushRange(spid, OSRoundUp32B(sizeof(u16)));
DCFlushRange(vector, OSRoundUp32B(sizeof(IOSIoVector)) * 2);
req->callback = cb;
req->callbackArg = cbArg;
req->nclean = 3;
req->clean[0] = svid;
req->clean[1] = spid;
req->clean[2] = vector;
rv = IOS_IoctlvAsync(fd, 27, 2, 0, vector, _intrBlkCtrlIsoCb, req);
if (rv < 0) {
goto clean;
}
IOS_Close(fd);
goto done;
clean:
IOSFree(svid);
IOSFree(spid);
IOSFree(vector);
IOSFree(req);
done:
return rv;
}
IOSError IUSB_DeviceClassInsertionNotifyAsync(const char* path, u8 devClass, USBCallback cb, void* cbArg) {
IOSError rv;
IOSFd fd;
IOSIoVector* vector;
u8* sdevClass;
USBCommandBlock* req;
if (NULL == path || 0 == devClass) {
OSReport("Invalid path or devClass in insertion notification call\n");
rv = IPC_RESULT_INVALID;
goto done;
}
if ((fd = IOS_Open(path, 0)) < 0) {
rv = fd;
OSReport("Open(%s) failed\n", path);
goto done;
}
vector = IOSAlloc(OSRoundUp32B(sizeof(IOSIoVector)) * 2);
sdevClass = IOSAlloc(OSRoundUp32B(sizeof(u8)));
req = IOSAlloc(OSRoundUp32B(sizeof(*req)));
*sdevClass = devClass;
vector[0].base = (u8*)sdevClass;
vector[0].length = sizeof(u8);
DCFlushRange(sdevClass, OSRoundUp32B(sizeof(u8)));
DCFlushRange(vector, OSRoundUp32B(sizeof(IOSIoVector)) * 2);
req->callback = cb;
req->callbackArg = cbArg;
req->nclean = 2;
req->clean[0] = sdevClass;
req->clean[1] = vector;
rv = IOS_IoctlvAsync(fd, 28, 1, 0, vector, _intrBlkCtrlIsoCb, req);
IOS_Close(fd);
done:
return rv;
}
// oh my
DECOMP_FORCE_ACTIVE(usb_c, "CloseDeviceAsync: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "openDevice: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "getDeviceList: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "getDeviceList: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "__IntrBlkMsgInt: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "intr/blk ioctl returned: %d\n");
DECOMP_FORCE_ACTIVE(usb_c, "IntBlkMsgInt (async): Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "intrblkmsg: cb = 0x%x cbArg = 0x%x\n");
DECOMP_FORCE_ACTIVE(usb_c, "ctrlmsg: bad data buffer\n");
DECOMP_FORCE_ACTIVE(usb_c, "Ctrl Msg: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "CtrlMsgInt (async): Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "ctrlmsgint: cb = 0x%x cbArg = 0x%x\n");
DECOMP_FORCE_ACTIVE(usb_c, "Ctrl Msg async returned: %d\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetStrCb returned: %d\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetStrCb: buf = 0x%x buflen = %u\n");
DECOMP_FORCE_ACTIVE(usb_c, "Failed to convert buffer from unicode 2 ascii\n");
DECOMP_FORCE_ACTIVE(usb_c, "calling cb 0x%x with arg 0x%x\n");
DECOMP_FORCE_ACTIVE(usb_c, "Failed __CtrlMsg: %d");
DECOMP_FORCE_ACTIVE(usb_c, "Failed to convert unicode 2 ascii\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetStr - _GetStrCb\n");
DECOMP_FORCE_ACTIVE(usb_c, " GetAsciiStrAsync: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "__CtrlMsgInt failed %d\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetDescrCb returned: %d\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetDevDescr\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetDevDescr: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetDevDescr: %d\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetDevDescr - _GetDescrCb\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetDevDescrAsync: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "DeviceRemovalNotifyAsync\n");
DECOMP_FORCE_ACTIVE(usb_c, "packet %u too big: %u\n");
DECOMP_FORCE_ACTIVE(usb_c, "Invalid parameters for ISO transfer request\n");
DECOMP_FORCE_ACTIVE(usb_c, "IUSB_IsoMsgAsync: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "Open(%s) failed\n");
DECOMP_FORCE_ACTIVE(usb_c, "Invalid path or devClass in insertion notification call\n");

View File

@@ -1039,13 +1039,13 @@ void VIConfigure(const GXRenderModeObj* renderMode)
if (HorVer.nonInter == 2 || HorVer.nonInter == 3) {
register1 = ((u32)originalRegister1 & ~4) | (1 << 2);
if (HorVer.tv == 8) {
register54 = originalRegister54 & ~1;
register54 = (u32)originalRegister54 & ~1;
} else {
register54 = (originalRegister54 & ~1) | 1;
register54 = ((u32)originalRegister54 & ~1) | 1;
}
} else {
register1 = ((u32)originalRegister1 & ~4) | ((HorVer.nonInter & 1) << 2);
register54 = originalRegister54 & ~1;
register54 = (u32)originalRegister54 & ~1;
}
register1 = (register1 & ~8) | (HorVer.threeD << 3);
if (HorVer.tv == VI_PAL || HorVer.tv == VI_MPAL || HorVer.tv == 3) {

View File

@@ -2955,7 +2955,7 @@ static void _WADRandPad(void* buffer, u32 size) {
words += sizeof(u32);
}
if (remainder != 0) {
u8* tail = words;
u8* tail = (u8*)words;
u8* randomBytes;
u32 byteIndex;

View File

@@ -396,7 +396,7 @@ void WPADiDecode(s32 chan, u8* data, u16 length, u16 offset) {
u8 tableIndex;
u16 i;
buffer = data;
buffer = (u8*)data;
for (i = 0; i < length; i++) {
tableIndex = (offset + i) % 8;

View File

@@ -238,7 +238,11 @@ static void DeleteFlushCallback(SCStatus status) {
return;
}
p->deleteState = WUD_STATE_DELETE_DONE;
if (status == SC_STATUS_OK) {
p->deleteState = WUD_STATE_DELETE_DONE;
} else {
p->deleteState = WUD_STATE_DELETE_DONE;
}
}
static void ShutFlushCallback(SCStatus status) {
@@ -1050,7 +1054,7 @@ static BOOL WUDiDeviceExists(u8* addr) {
return FALSE;
}
static char deviceNameFormat[] = "name : %s\n";
DECOMP_FORCE_ACTIVE(WUD_c, "name : %s\n")
static WUDInitState WUDiGetRegisteredDevice() {
int i, j;
@@ -1110,7 +1114,7 @@ static WUDInitState WUDiGetRegisteredDevice() {
DEBUGPrint("addr : %02x:%02x:%02x:%02x:%02x:%02x\n", pInfo->devAddr[0], pInfo->devAddr[1], pInfo->devAddr[2], pInfo->devAddr[3],
pInfo->devAddr[4], pInfo->devAddr[5]);
DEBUGPrint(deviceNameFormat, pInfo->conf.devName);
DEBUGPrint("name : %s\n", pInfo->conf.devName);
a++;
arrayNum--;
@@ -1156,7 +1160,7 @@ static WUDInitState WUDiGetRegisteredDevice() {
WUD_DEBUGPrint("addr : %02x:%02x:%02x:%02x:%02x:%02x\n", pInfo->devAddr[0], pInfo->devAddr[1], pInfo->devAddr[2], pInfo->devAddr[3],
pInfo->devAddr[4], pInfo->devAddr[5]);
WUD_DEBUGPrint(deviceNameFormat, pInfo->conf.devName);
WUD_DEBUGPrint("name : %s\n", pInfo->conf.devName);
WUDiMoveTopSmpDevInfoPtr(pInfo);
@@ -1609,25 +1613,7 @@ static BOOL StopSync() {
return success;
}
BOOL WUDStartSyncSpDevice(u8 type) {
WUDCB* p_wcb = &_wcb;
WUDSyncDeviceCallback cb;
BOOL enable;
BOOL busy;
WUD_DEBUGPrint("WUDStartSyncSpDevice()\n");
busy = StartSyncDevice(1, -1, type, FALSE);
enable = OSDisableInterrupts();
cb = p_wcb->syncSmpCB;
OSRestoreInterrupts(enable);
if (!busy && cb) {
cb(-1, 0);
}
return busy;
}
DECOMP_FORCE_ACTIVE(WUD_c1, "WUDStartSyncSpDevice()\n");
DECOMP_FORCE_ACTIVE(WUD_c2, "WUDCancelSyncDevice()\n");
BOOL WUDStopSyncSimple() {
@@ -1995,29 +1981,7 @@ void WUDiAutoSync() {
}
}
void WUDiCancelSync() {
WUDCB* p_wcb = &_wcb;
WUDSyncDeviceCallback callback;
BOOL enable;
WUD_DEBUGPrint("WUDiCancelSync()\n");
enable = OSDisableInterrupts();
if (p_wcb->syncState != 0) {
if (p_wcb->syncState == 3) {
BTA_DmSearchCancel();
}
OSCancelAlarm(&p_wcb->alarm);
callback = (p_wcb->syncType == 0) ? p_wcb->syncStdCB : p_wcb->syncSmpCB;
if (callback) {
callback(1, p_wcb->syncedNum);
}
p_wcb->syncState = 0;
}
OSRestoreInterrupts(enable);
}
DECOMP_FORCE_ACTIVE(WUD_c3, "WUDiCancelSync()\n");
void WUDiDeleteAllLinkKeys() {
WUDCB* p = &_wcb;
@@ -2990,57 +2954,10 @@ u8 _WUDGetLinkNumber() {
return num;
}
BOOL _WUDEnableTestMode() {
tBTM_STATUS status;
BOOL enable;
WUD_DEBUGPrint("_WUDEnableTestMode\n");
status = BTM_EnableTestMode();
enable = (status == BTM_SUCCESS) ? TRUE : FALSE;
return enable;
}
void _WUDStartSyncDevice(BD_ADDR bd_addr, u8* bd_name) {
WUDCB* p_wcb = &_wcb;
BOOL enable;
s32 status;
WUD_DEBUGPrint("_WUDStartSyncDevice()\n");
enable = OSDisableInterrupts();
status = p_wcb->libStatus;
OSRestoreInterrupts(enable);
if (status == 3) {
if (WUDIsBusy() == FALSE) {
WUD_DEBUGPrint("start\n");
enable = OSDisableInterrupts();
p_wcb->syncState = 5;
p_wcb->syncedNum = 0;
memcpy(_discResp.devName, bd_name, 64);
memcpy(_discResp.devAddr, bd_addr, BD_ADDR_LEN);
OSCreateAlarm(&p_wcb->alarm);
OSSetPeriodicAlarm(&p_wcb->alarm, OSGetTime(), OSMillisecondsToTicks(20), SyncHandler0);
OSRestoreInterrupts(enable);
}
}
}
void _WUDDeleteStoredDevice() {
WUDCB* p_wcb = &_wcb;
WUD_DEBUGPrint("_WUDDeleteStoreDevice()\n");
WUDiDeleteAllLinkKeys();
do {
;
} while (p_wcb->deleteState != 0);
WUD_DEBUGPrint("dev number = %d\n", WUDiGetDevNumber());
}
DECOMP_FORCE_ACTIVE(WUD_c4, "_WUDEnableTestMode\n")
DECOMP_FORCE_ACTIVE(WUD_c5, "_WUDStartSyncDevice()\n")
DECOMP_FORCE_ACTIVE(WUD_c6, "_WUDDeleteStoreDevice()\n")
DECOMP_FORCE_ACTIVE(WUD_c7, "dev number = %d\n")
static u8 reset_auth_count_cmd[] = {0x30, 0x36, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
@@ -3049,21 +2966,4 @@ void WUDResetAuthFailCount() {
BTM_VendorSpecificCommand(BT_VSC_NINTENDO_WRITE_PATCH, (u8)sizeof(reset_auth_count_cmd), reset_auth_count_cmd, NULL);
}
WUDDevInfo* WUDiGetRemoveWbcDevice() {
WUDCB* p_wcb = &_wcb;
WUDDevInfo* p_info = NULL;
WUDDevInfoList* ptr;
BOOL enable;
enable = OSDisableInterrupts();
ptr = p_wcb->stdListHead;
while (ptr != NULL) {
if (!memcmp(ptr->devInfo->conf.devName, "Nintendo RVL-WBC", 16)) {
p_info = ptr->devInfo;
}
ptr = ptr->next;
}
OSRestoreInterrupts(enable);
return p_info;
}
DECOMP_FORCE_ACTIVE(WUD_c8, "Nintendo RVL-WBC")

View File

@@ -131,7 +131,7 @@ void CDBConvMinuteValueToMinuteStr(char* minuteStr, int minute) {
sprintf(minuteStr, "%02d", minute);
}
static char wiiIdFormat[] = "%08X";
DECOMP_FORCE_ACTIVE(CDBConv_c, "%08X");
void CDBGenRootPath(char* rootPath, CDBLocation location, u64* wiiId) {
u32 wiiIdHi, wiiIdLo;
@@ -153,8 +153,8 @@ void CDBGenRootPath(char* rootPath, CDBLocation location, u64* wiiId) {
strcpy(rootPath, CDB_SD_ROOT_PATH_LS);
sprintf(wiiIdHiPath, wiiIdFormat, wiiIdHi);
sprintf(wiiIdLoPath, wiiIdFormat, wiiIdLo);
sprintf(wiiIdHiPath, "%08X", wiiIdHi);
sprintf(wiiIdLoPath, "%08X", wiiIdLo);
CDBFSConcatenatePath(rootPath, wiiIdHiPath);
CDBFSConcatenatePath(rootPath, wiiIdLoPath);
@@ -326,8 +326,7 @@ CDBErr CDBConvKeyToFullPath(CDBRecordKey* recordKey, char* fullPath) {
}
void CDBConvKeyStrToFullPath_(char* keyString, char* fullPath, CDBLocation location, u64* wiiId) {
char epochString[CDB_KEYSTR_EPOCH_SIZE + 1];
char fileNameStr[sizeof("00000000.000")];
char fileNameStr[8];
char yearStr[8];
char monthStr[8];
char dayStr[8];
@@ -346,9 +345,18 @@ void CDBConvKeyStrToFullPath_(char* keyString, char* fullPath, CDBLocation locat
CDBDate fileEpoch;
char fileEpochStr[40];
strncpy(epochString, CDBKeyStrEpoch(keyString), CDB_KEYSTR_EPOCH_SIZE);
epochString[CDB_KEYSTR_EPOCH_SIZE] = 0;
sscanf(epochString, "%ul", &epoch);
{
union {
char storage[20];
struct {
char prefix[8];
char value[12];
} epoch;
} epochBuffer;
strncpy(epochBuffer.epoch.value, CDBKeyStrEpoch(keyString), CDB_KEYSTR_EPOCH_SIZE);
epochBuffer.epoch.value[CDB_KEYSTR_EPOCH_SIZE] = 0;
sscanf(epochBuffer.epoch.value, "%ul", &epoch);
}
CDBConvEpochValueToDate(epoch, &year, &month, &day, &hour, &min, NULL);
CDBConvYearValueToYearStr(yearStr, year);

View File

@@ -78,7 +78,7 @@ extern void _restgpr_24();
extern void _restgpr_25();
extern void _restgpr_26();
extern int atoi();
#pragma section sdata_type ".sdata"
typedef struct {
char path[256];
CDBFindData find;
@@ -350,23 +350,25 @@ CDBErr CDBDatabaseFindByKey(CDBDatabase* database, CDBRecord* record, CDBRecordK
}
CDBErr CDBDatabaseSearchConditionsIsMatch(CDBSearchConditions* conditions, char* key) {
char type[CDB_RECORD_KEY_STRING_LEN - offsetof(CDBRecordKey, keyStrStruct.type)];
CDBDate date;
u32 gameCode;
u16 makerCode;
CDBConvKeyStrToEpochValue(key, &date);
if (conditions->beginDate > date || date > conditions->endDate) return CDB_ERROR_OK;
struct {
u16 makerCode;
u32 gameCode;
CDBDate date;
char type[8];
} decoded;
CDBConvKeyStrToEpochValue(key, &decoded.date);
if (conditions->beginDate > decoded.date || decoded.date > conditions->endDate) return CDB_ERROR_OK;
if (conditions->makerCode != 0xFFFF) {
CDBConvKeyStrToMakerCode(key, (u32*)&makerCode);
if (conditions->makerCode != makerCode) return CDB_ERROR_OK;
CDBConvKeyStrToMakerCode(key, (u32*)&decoded.makerCode);
if (conditions->makerCode != decoded.makerCode) return CDB_ERROR_OK;
}
if (conditions->gameCode != 0xFFFFFFFF) {
CDBConvKeyStrToGameCode(key, &gameCode);
if (conditions->gameCode != gameCode) return CDB_ERROR_OK;
CDBConvKeyStrToGameCode(key, &decoded.gameCode);
if (conditions->gameCode != decoded.gameCode) return CDB_ERROR_OK;
}
if (conditions->type != NULL) {
CDBConvKeyStrToType(key, type);
if (CDBCompareTypeStr(conditions->type, type)) return CDB_ERROR_OK;
CDBConvKeyStrToType(key, decoded.type);
if (CDBCompareTypeStr(conditions->type, decoded.type)) return CDB_ERROR_OK;
}
return CDB_ERROR_1;
}
@@ -1370,6 +1372,7 @@ CDBErr CDBDatabaseCleanUpEmptyDirectories(CDBDatabase* database, CDBRecordLocati
return CDB_ERROR_OK;
}
#pragma section data_type ".data"
#pragma align 8
extern char scCdbMsg_DatabaseClosed[] = "CDBDatabaseClose database is closed\n";
#pragma align 8

View File

@@ -19,13 +19,13 @@ DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "(other-group-owner)\n");
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "nocopy/cdbwiiid.dat");
// These ones are used but they are pooled somewhere else
static char mountError[] = "VFMountDriveNANDFlashEx VFErr=%d(%s)\n";
static char homeDirectory[] = "home=%s\n";
static char createFileError[] = "VFCreateSystemFileNANDFlashEx DEVErr=%d\n";
static char retryMountError[] = "VFMountDriveNANDFlashEx VFErr=%d\n";
static char formatError[] = "VFFormatDrive VFErr=%d\n";
static char mountSuccess[] = "VFMountDriveNANDFlashEx %s->%s succeeded\n";
static char changeDirectoryError[] = "VFChangeDir %s %s\n";
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "VFMountDriveNANDFlashEx VFErr=%d(%s)\n");
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "home=%s\n");
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "VFCreateSystemFileNANDFlashEx DEVErr=%d\n");
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "VFMountDriveNANDFlashEx VFErr=%d\n");
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "VFFormatDrive VFErr=%d\n");
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "VFMountDriveNANDFlashEx %s->%s succeeded\n");
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "VFChangeDir %s %s\n");
static inline CDBErr CDBFSInitVFFile(void* cacheBuffer, u32 cacheSize) {
VFErr vfErr;
@@ -33,7 +33,7 @@ static inline CDBErr CDBFSInitVFFile(void* cacheBuffer, u32 cacheSize) {
vfErr = VFMountDriveNANDFlashCacheEx(CDB_CFG_VF_DRIVE_LETTER, CDB_VFF_FILE_NAME, cacheBuffer, cacheSize);
if (vfErr != VF_ERR_SUCCESS) {
CDBReportInfo(mountError, vfErr, VFGetApiErrorString(vfErr));
CDBReportInfo("VFMountDriveNANDFlashEx VFErr=%d(%s)\n", vfErr, VFGetApiErrorString(vfErr));
if (vfErr == VF_ERR_NOT_EXIST_FILE) {
u32 nandCheck;
@@ -65,33 +65,33 @@ static inline CDBErr CDBFSInitVFFile(void* cacheBuffer, u32 cacheSize) {
char nandHomeDir[64];
NANDGetHomeDir(nandHomeDir);
CDBReportFatal(homeDirectory, nandHomeDir);
CDBReportFatal(createFileError, vfErr);
CDBReportFatal("home=%s\n", nandHomeDir);
CDBReportFatal("VFCreateSystemFileNANDFlashEx DEVErr=%d\n", vfErr);
return CDBOnNANDErrorOccured(vfErr);
}
vfErr = VFMountDriveNANDFlashCacheEx(CDB_CFG_VF_DRIVE_LETTER, CDB_VFF_FILE_NAME, cacheBuffer, cacheSize);
if (vfErr != VF_ERR_SUCCESS) {
CDBReportFatal(retryMountError, vfErr);
CDBReportFatal("VFMountDriveNANDFlashEx VFErr=%d\n", vfErr);
return CDBOnVFErrorOccured(vfErr);
}
vfErr = VFFormatDrive(CDB_CFG_VF_DRIVE_LETTER);
if (vfErr != VF_ERR_SUCCESS) {
CDBReportFatal(formatError, vfErr);
CDBReportFatal("VFFormatDrive VFErr=%d\n", vfErr);
return CDBOnVFErrorOccured(vfErr);
}
} else {
CDBReportFatal(mountError, vfErr, VFGetApiErrorString(vfErr));
CDBReportFatal("VFMountDriveNANDFlashEx VFErr=%d(%s)\n", vfErr, VFGetApiErrorString(vfErr));
return CDBOnVFErrorOccured(vfErr);
}
}
CDBReportInfo(mountSuccess, CDB_VFF_FILE_NAME, CDB_CFG_VF_DRIVE_LETTER);
CDBReportInfo("VFMountDriveNANDFlashEx %s->%s succeeded\n", CDB_VFF_FILE_NAME, CDB_CFG_VF_DRIVE_LETTER);
vfErr = VFChangeDir(CDB_CFG_VF_DRIVE_ROOT "/");
if (vfErr != VF_ERR_SUCCESS) {
CDBReportFatal(changeDirectoryError, CDB_CFG_VF_DRIVE_ROOT "/", VFGetApiErrorString(vfErr));
CDBReportFatal("VFChangeDir %s %s\n", CDB_CFG_VF_DRIVE_ROOT "/", VFGetApiErrorString(vfErr));
return CDBOnVFErrorOccured(vfErr);
}

View File

@@ -283,3 +283,5 @@ BOOL CDBFSSDIsEjected() {
BOOL CDBFSSDIsInserted() {
return s_fssdWork.isInserted;
}
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, CDB_SD_VFF_FILE_NAME); // Unused but linked

View File

@@ -29,23 +29,25 @@ BOOL CDBRecordKeyIsValid(CDBRecordKey* recordKey) {
}
void CDBRecordKeyInit(CDBRecordKey* recordKey, CDBDate epoch, int gameCode, u16 makerCode, int serialNumber, char* fileType, int recordLocation) {
char gcStr[CDB_KEYSTR_GAME_CODE_SIZE + 1];
char typeStr[6];
char mcStr[CDB_KEYSTR_MAKER_CODE_SIZE + 1];
struct {
char mcStr[4];
char typeStr[8];
char gcStr[8];
} strings;
u32 typeLength;
CDBConvMCValueToMCStr(makerCode, mcStr);
CDBConvGCValueToGCStr(gameCode, gcStr);
CDBConvMCValueToMCStr(makerCode, strings.mcStr);
CDBConvGCValueToGCStr(gameCode, strings.gcStr);
recordKey->wiiId = CDBGetWiiId();
recordKey->location = recordLocation;
typeLength = strlen(fileType);
strcpy(typeStr, fileType);
CDBToLower(typeStr, typeLength);
strcpy(strings.typeStr, fileType);
CDBToLower(((char*)strings.typeStr), typeLength);
sprintf(recordKey->keyString, "%010u_%s_%s_%03d.%s", epoch, gcStr, mcStr, serialNumber, typeStr);
sprintf(recordKey->keyString, "%010u_%s_%s_%03d.%s", epoch, strings.gcStr, strings.mcStr, serialNumber, strings.typeStr);
}
void CDBRecordKeySetSerialNumber(CDBRecordKey* recordKey, int serialNum) {

View File

@@ -12,7 +12,10 @@
static NCDConfig* ncdCommonBuffer;
static u32 ncdInitialized;
OSMutex ncdMutex;
struct NCDMutex {
OSMutex mutex;
u8 padding[8];
} ncdMutex;
s32 ncdCommonResult[8] ATTRIBUTE_ALIGN(32);
IOSIoVector ncdCommonVector[4] ATTRIBUTE_ALIGN(32);
@@ -48,25 +51,24 @@ NCDErr NCDWriteConfig(const NCDConfig* config) {
return ExecConfigCommand("NCDWriteConfig", (NCDConfig*)config, 6);
}
static inline void RegisterUnofficialVersion(void) {
BOOL enabled;
enabled = OSDisableInterrupts();
if (!(ncdInitialized & 2)) {
OSRegisterVersion(__NCDUnofficialVersion);
ncdInitialized |= 2;
}
OSRestoreInterrupts(enabled);
}
NCDErr NCDSetIfConfig(NCDIfConfig* ifConfig) {
NCDConfig* config;
union {
BOOL enabled;
NCDConfig* config;
} state;
NCDErr lockErr;
NCDProfile* profile;
NCDErr result;
s32 i;
u32 count;
RegisterUnofficialVersion();
state.enabled = OSDisableInterrupts();
if (!(ncdInitialized & 2)) {
OSRegisterVersion(__NCDUnofficialVersion);
ncdInitialized |= 2;
}
OSRestoreInterrupts(state.enabled);
if (ifConfig == NULL) {
return -3;
@@ -80,25 +82,25 @@ NCDErr NCDSetIfConfig(NCDIfConfig* ifConfig) {
if (lockErr == 0) {
result = ExecConfigCommand("NCDSetIfConfig", NULL, 3);
if (result == 0) {
config = ncdCommonBuffer;
state.config = ncdCommonBuffer;
if (ifConfig->selectedMedia != 1 && ifConfig->selectedMedia != 2) {
config->selectedMedia = 0;
state.config->selectedMedia = 0;
} else {
config->selectedMedia = ifConfig->selectedMedia;
profile = config->profiles;
state.config->selectedMedia = ifConfig->selectedMedia;
profile = state.config->profiles;
i = 0;
config->linkTimeout = ifConfig->linkTimeout;
state.config->linkTimeout = ifConfig->linkTimeout;
count = 0;
for (; i < NCD_MAX_PROFILE; i++, profile++) {
if (config->profiles[i].flags & 0x80) {
if (state.config->profiles[i].flags & 0x80) {
switch (ifConfig->selectedMedia) {
case 1:
config->profiles[i].flags &= ~1;
state.config->profiles[i].flags &= ~1;
memcpy(&profile->netif, &ifConfig->netif, 0x15c);
break;
case 2:
config->profiles[i].flags |= 1;
state.config->profiles[i].flags |= 1;
memcpy(&profile->netif, &ifConfig->netif, 4);
break;
}
@@ -107,22 +109,22 @@ NCDErr NCDSetIfConfig(NCDIfConfig* ifConfig) {
}
if (count == 0) {
config->profiles[0].flags |= 0x80;
state.config->profiles[0].flags |= 0x80;
switch (ifConfig->selectedMedia) {
case 1:
config->profiles[0].flags &= ~1;
memcpy(&config->profiles[0].netif.wireless, &ifConfig->netif, 0x15c);
state.config->profiles[0].flags &= ~1;
memcpy(&state.config->profiles[0].netif.wireless, &ifConfig->netif, 0x15c);
break;
case 2:
config->profiles[0].flags |= 1;
memcpy(&config->profiles[0].netif.wired, &ifConfig->netif, 4);
state.config->profiles[0].flags |= 1;
memcpy(&state.config->profiles[0].netif.wired, &ifConfig->netif, 4);
break;
}
memset(&config->profiles[0].adjust, 0, 0xc);
config->profiles[0].flags |= 6;
memset(&config->profiles[0].ip, 0, 0x14);
config->profiles[0].flags &= ~0x10;
memset(&config->profiles[0].proxy, 0, 0x79c);
memset(&state.config->profiles[0].adjust, 0, 0xc);
state.config->profiles[0].flags |= 6;
memset(&state.config->profiles[0].ip, 0, 0x14);
state.config->profiles[0].flags &= ~0x10;
memset(&state.config->profiles[0].proxy, 0, 0x79c);
}
}
result = ExecConfigCommand("NCDSetIfConfig", NULL, 4);
@@ -135,7 +137,7 @@ NCDErr NCDSetIfConfig(NCDIfConfig* ifConfig) {
} else {
result = -2;
}
OSUnlockMutex(&ncdMutex);
OSUnlockMutex(&ncdMutex.mutex);
return result;
}
@@ -222,7 +224,7 @@ NCDErr NCDSetIpConfig(NCDIpConfig* ipConfig) {
} else {
err = -2;
}
OSUnlockMutex(&ncdMutex);
OSUnlockMutex(&ncdMutex.mutex);
return err;
}
@@ -264,7 +266,7 @@ NCDErr NCDGetCurrentIpConfig(NCDIpConfig* ipConfig) {
}
}
OSUnlockMutex(&ncdMutex);
OSUnlockMutex(&ncdMutex.mutex);
return err;
}
@@ -300,7 +302,7 @@ NCDErr NCDGetLinkStatus(void) {
err = -1;
}
}
OSUnlockMutex(&ncdMutex);
OSUnlockMutex(&ncdMutex.mutex);
return err;
}
@@ -357,7 +359,7 @@ NCDErr NCDiGetWirelessMacAddress(u8* macAddr) {
err = -1;
}
}
OSUnlockMutex(&ncdMutex);
OSUnlockMutex(&ncdMutex.mutex);
return err;
}
@@ -393,7 +395,7 @@ NCDErr NCDLockWirelessDriver(void) {
err = -1;
}
}
OSUnlockMutex(&ncdMutex);
OSUnlockMutex(&ncdMutex.mutex);
return err;
}
@@ -431,7 +433,7 @@ NCDErr NCDUnlockWirelessDriver(s32 id) {
err = -1;
}
}
OSUnlockMutex(&ncdMutex);
OSUnlockMutex(&ncdMutex.mutex);
return err;
}
@@ -457,7 +459,7 @@ s32 NCDRestoreConfig(void) {
} else {
err = -2;
}
OSUnlockMutex(&ncdMutex);
OSUnlockMutex(&ncdMutex.mutex);
return err;
}
@@ -491,7 +493,7 @@ NCDErr NCDiGetEnabledConfigList(u32* list0, u32* list1, u32* list2) {
}
}
}
OSUnlockMutex(&ncdMutex);
OSUnlockMutex(&ncdMutex.mutex);
if (list0 != NULL) {
*list0 = mask0;
@@ -555,7 +557,7 @@ static NCDErr ExecConfigCommand(const char* name, NCDConfig* config, u32 command
err = -1;
}
}
OSUnlockMutex(&ncdMutex);
OSUnlockMutex(&ncdMutex.mutex);
return err;
}
@@ -566,7 +568,7 @@ static void LockRight(void) {
enabled = OSDisableInterrupts();
if (!(ncdInitialized & 1)) {
OSRegisterVersion(__NCDVersion);
OSInitMutex(&ncdMutex);
OSInitMutex(&ncdMutex.mutex);
lo = (void*)OSRoundUp32B(IPCGetBufferLo());
if ((u32)IPCGetBufferHi() - (u32)lo < NCD_IPC_HEAP_SIZE) {
OSPanic("ncdsystem.c", 0x5B1, "Could not reserve heap for NCD library from IPC arena");
@@ -579,5 +581,5 @@ static void LockRight(void) {
ncdInitialized |= 1;
}
OSRestoreInterrupts(enabled);
OSLockMutex(&ncdMutex);
OSLockMutex(&ncdMutex.mutex);
}

View File

@@ -661,6 +661,13 @@ s32 NHTTPDisableVerifyOptionForDebug(NHTTPRequest* handle, u32 option)
"NHTTPDisableVerifyOptionForDebug");
return -1;
}
{
static s32 debugSet;
if (debugSet == 0)
{
debugSet = 1;
}
}
request->verifyOption &= ~option;
return 0;
}

View File

@@ -561,27 +561,29 @@ static inline void GetOldestMsgId(const MBCHeader* header, volatile u32* id) {
NWC24Err NWC24iMBoxCheck(NWC24MBoxType type, u32 size) {
u32 required;
MBCHeader* header;
volatile u32 oldestId;
struct {
volatile u32 oldestId;
MBCHeader* header;
} mailbox;
NWC24Err err;
if (size >= 0x31C00)
return NWC24_ERR_OVERFLOW;
required = size + 0x4000;
err = GetCachedMBCHeader(type, &header);
err = GetCachedMBCHeader(type, &mailbox.header);
if (err != NWC24_OK)
return err;
if (type == NWC24_MBOX_TYPE_SEND) {
if (header->numMessages >= header->capacity)
if (mailbox.header->numMessages >= mailbox.header->capacity)
return NWC24_ERR_FULL;
if (header->freeBytes <= required)
if (mailbox.header->freeBytes <= required)
return NWC24_ERR_FULL;
} else if (type == NWC24_MBOX_TYPE_RECV) {
while (header->numMessages >= header->capacity || header->freeBytes <= required) {
GetOldestMsgId(header, &oldestId);
err = DeleteMsg(type, oldestId, FALSE);
while (mailbox.header->numMessages >= mailbox.header->capacity || mailbox.header->freeBytes <= required) {
GetOldestMsgId(mailbox.header, &mailbox.oldestId);
err = DeleteMsg(type, mailbox.oldestId, FALSE);
if (err != NWC24_OK)
return err;
err = GetCachedMBCHeader(type, &header);
err = GetCachedMBCHeader(type, &mailbox.header);
if (err != NWC24_OK)
return err;
}

View File

@@ -642,11 +642,11 @@ NWC24Err NWC24DecodeMIMEHeaderFieldBody(u8* charsetData, u32 charsetDataSize, u8
inputSize = encodedSize;
output = decoded;
remainingCapacity = decodedCapacity;
while (inputSize > 0 && remainingCapacity > 0 && *input != '\0') {
while ((s32)inputSize > 0 && remainingCapacity > 0 && *input != '\0') {
u32 copiedSize = 0;
u32 consumedSize;
result =
DecodeWord((char*)charsetData, charsetDataSize, (char*)output, remainingCapacity, &copiedSize, input, inputSize, &consumedSize);
DecodeWord((char*)charsetData, charsetDataSize, (char*)output, remainingCapacity, &copiedSize, (char*)input, inputSize, &consumedSize);
if (copiedSize == 0) {
break;
}

View File

@@ -202,41 +202,40 @@ static inline NWC24Err WriteMBNoReplyField(NWC24MsgObjPrivate* msg) {
return err;
}
static inline u32 GetMBFlags(const NWC24MsgObjPrivate* msg, u32 mask) {
return msg->msgBoardFlags.raw & mask;
}
static inline NWC24Err WriteMBRegDateField(NWC24MsgObjPrivate* msg) {
typedef struct {
u32 flags;
char* buffer;
} MBFieldWork;
static inline NWC24Err WriteMBRegDateField(NWC24MsgObjPrivate* msg) {
MBFieldWork field;
NWC24Err err;
s32 length;
flags = GetMBFlags(msg, 0xFFFF);
if (!flags)
field.flags = msg->msgBoardFlags.raw & 0xFFFF;
if (!field.flags)
return NWC24_OK;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "X-Wii-MB-RegDate: %04X\r\n", flags);
length = STD_strnlen(buffer, 1024);
err = NWC24FWrite(buffer, length, m_pFile);
field.buffer = NWC24WorkP->stringWork;
Mail_memset(field.buffer, 0, 1024);
Mail_sprintf(field.buffer, "X-Wii-MB-RegDate: %04X\r\n", field.flags);
length = STD_strnlen(field.buffer, 1024);
err = NWC24FWrite(field.buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static inline NWC24Err WriteMBDelayField(NWC24MsgObjPrivate* msg) {
u32 flags;
char* buffer;
MBFieldWork field;
NWC24Err err;
s32 length;
flags = GetMBFlags(msg, 0xFF0000);
if (!flags)
field.flags = msg->msgBoardFlags.raw & 0xFF0000;
if (!field.flags)
return NWC24_OK;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "X-Wii-MB-Delay: %02X\r\n", flags >> 16);
length = STD_strnlen(buffer, 1024);
err = NWC24FWrite(buffer, length, m_pFile);
field.buffer = NWC24WorkP->stringWork;
Mail_memset(field.buffer, 0, 1024);
Mail_sprintf(field.buffer, "X-Wii-MB-Delay: %02X\r\n", field.flags >> 16);
length = STD_strnlen(field.buffer, 1024);
err = NWC24FWrite(field.buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;

View File

@@ -182,7 +182,8 @@ NWC24Err NWC24ExecDownloadTask(u32 flags, u16 taskId, u32 subTaskMask) {
if (result >= NWC24_OK && saveMail) {
result = NWC24iSaveMailNow();
} else if (result == NWC24_ERR_PROTECTED) {
ASSERTLINE(result != NWC24_ERR_PROTECTED, 184);
// Stripped out but left out if statement
u32 dummy = 0;
}
if (result < NWC24_OK) {

View File

@@ -547,3 +547,10 @@ static u32 SSL_strnlen(const char* s, u32 n) {
}
return t - s;
}
#pragma push
#pragma section data_type ".data"
#pragma pop
#pragma push
#pragma section data_type ".sdata"
#pragma pop

View File

@@ -11,8 +11,8 @@ void VFiPF_LE16_TO_U16_STR(pf_u8* sSrc, pf_u32 num) {
for (cnt = 0; cnt < num; cnt += sizeof(pf_u16)) {
tmp_src = sSrc[cnt];
#ifdef DEBUG
*(sSrc + cnt) = *(sSrc + cnt + 1);
*(sSrc + cnt + 1) = tmp_src;
*((pf_u8*)sSrc + cnt) = *((pf_u8*)sSrc + cnt + 1);
*((pf_u8*)sSrc + cnt + 1) = tmp_src;
#else
sSrc[cnt] = sSrc[cnt + 1];
sSrc[cnt + 1] = tmp_src;

View File

@@ -120,7 +120,7 @@ pf_s32 VFiPFSTR_StrCmp(const PF_STR* p_str, const pf_s8* s) {
wp = (pf_u16*)p_str->p_head;
do {
VFipf_vol_set.codeset.oem2unicode(s, &wc);
VFipf_vol_set.codeset.oem2unicode((pf_s8*)s, &wc);
s++;
if (*wp++ != wc) {
@@ -158,7 +158,7 @@ pf_s32 VFiPFSTR_StrNCmp(PF_STR* p_str, const pf_s8* s, pf_u32 target, pf_s16 off
}
do {
VFipf_vol_set.codeset.oem2unicode(s, &wc);
VFipf_vol_set.codeset.oem2unicode((pf_s8*)s, &wc);
s++;
num--;

View File

@@ -20,8 +20,8 @@ pf_u16* VFipf_w_strcpy(pf_u16* dst, const pf_u16* src) {
}
pf_s32 VFipf_w_strncmp(const pf_u16* s1, const pf_u16* s2, pf_u32 length) {
const pf_u16* p1 = s1;
const pf_u16* p2 = s2;
const pf_u16* p1 = (pf_u16*)s1;
const pf_u16* p2 = (pf_u16*)s2;
while (length-- != 0) {
if (*p1 == 0 || *p2 == 0 || *p1 != *p2) {

View File

@@ -352,7 +352,7 @@ pf_s32 VFipdm_disk_format(PDM_DISK* p_disk, const pf_u8* param) {
return err;
}
lp_disk = &VFipdm_disk_set.disk[PDM_DISK_GET_NO(p_disk)];
err = lp_disk->disk_tbl.p_func->format(p_disk, param);
err = lp_disk->disk_tbl.p_func->format(p_disk, (pf_u8*)param);
if (err != 0) {
if (lp_disk->p_cur_part != PF_NULL) {
VFipdm_part_set_driver_error_code(lp_disk->p_cur_part, err);

View File

@@ -79,7 +79,7 @@ static pf_s32 VFiPFENT_ITER_GetEntry(PF_DIR_ENT* p_ent, PF_ENT_ITER* p_iter, PF_
if ((attr & 0xF) == 0xF) {
is_match = 1;
} else {
is_valid = VFiPFENT_CompareAttr(attr, attr_required);
is_valid = VFiPFENT_CompareAttr(attr, (pf_u8)attr_required);
if (is_valid == 0) {
is_match = 1;
} else {

View File

@@ -597,15 +597,29 @@ static pf_s32 VFiPFFILE_createEmptyFile(PF_VOLUME* p_vol, PF_DIR_ENT* p_ent, PF_
(void)namelength;
// stinky fakematch
#ifdef DEBUG
err = 0;
#endif
if (p_vol->num_opened_files >= 5) {
return 0x15;
}
#ifdef DEBUG
err = VFiPFENT_InitENT(p_ent, p_fname, 0x20U, 1U, p_parent_ent, p_vol);
if (err == 0) {
if (err == 0)
#else
if (VFiPFENT_InitENT(p_ent, p_fname, 0x20U, 1U, p_parent_ent, p_vol) == 0)
#endif
{
VFiPFFAT_InitFFD(&ffd, &hint, p_vol, &p_parent_ent->start_cluster);
#ifdef DEBUG
err = VFiPFENT_allocateEntry(p_ent, (p_ent->num_entry_LFNs + 1), &ffd, prev_chain, p_fname, 0x77U, &pos);
if (err == 0) {
if (err == 0)
#else
if (VFiPFENT_allocateEntry(p_ent, (p_ent->num_entry_LFNs + 1), &ffd, prev_chain, p_fname, 0x77U, &pos) == 0)
#endif
{
p_ent->start_cluster = 0;
if ((p_ent->long_name[0] != 0) && ((VFipf_vol_set.setting & 2) == 2)) {
VFiPFPATH_AdjustExtShortName(p_ent->short_name, pos);

View File

@@ -86,7 +86,7 @@ static pf_u32 VFiPFPATH_UNI_ConvertFWchar(pf_u16 src, pf_u16* dst) {
}
static pf_u32 VFiPFPATH_OEM_ConvertFWchar(const pf_s8* src, pf_u16* dst) {
VFipf_vol_set.codeset.oem2unicode(src, dst);
VFipf_vol_set.codeset.oem2unicode((pf_s8*)src, dst);
if (VFiPFPATH_UNI_ConvertFWchar((pf_u16)*dst, dst) == 1) {
VFipf_vol_set.codeset.unicode2oem(dst, (pf_s8*)dst);
*dst = (pf_u16)*dst;
@@ -169,6 +169,7 @@ static pf_u16 VFiPFPATH_GetNextCharOfPattern(PF_STR* p_pattern, pf_u16 name_kind
wc = ((pf_u8)pattern[1] << 8) + (pf_u8)pattern[0];
if (name_kind == 0) {
VFipf_vol_set.codeset.unicode2oem(&wc, (pf_s8*)&tmp_wc);
tmp_wc = (pf_u16)tmp_wc;
if (VFipf_vol_set.codeset.is_oem_mb_char((pf_u8)(tmp_wc >> 8), 1) != 0) {
wc = tmp_wc;
} else {
@@ -178,7 +179,7 @@ static pf_u16 VFiPFPATH_GetNextCharOfPattern(PF_STR* p_pattern, pf_u16 name_kind
}
wc = (wc >= 'a') && (wc <= 'z') ? wc - ' ' : wc;
if (name_kind == 1) {
if (VFiPFPATH_UNI_ConvertFWchar(wc, &twc) == 1) {
if (VFiPFPATH_UNI_ConvertFWchar((pf_u16)wc, &twc) == 1) {
wc = twc;
}
} else if (VFiPFPATH_OEM_ConvertFWchar(pattern, &twc) == 1) {

View File

@@ -8,6 +8,8 @@
#include <string.h>
#pragma push
#pragma section sconst_type ".sdata2"
const u8 scRsnOui0 = 0;
const u8 scRsnOui1 = 0x0F;
const u8 scRsnOui2 = 0xAC;
@@ -16,6 +18,7 @@ const u8 scWpaOui0 = 0;
const u8 scWpaOui1 = 0x50;
const u8 scWpaOui2 = 0xF2;
const u8 scWpaOuiPad = 0;
#pragma pop
#pragma push
#pragma section sconst_type ".sdata"
const u8 scWpaFindOui0 = 0;
@@ -279,7 +282,7 @@ BOOL WDFindInformationElement(WDInfoElement** outIE, u32* outIELength, WDBssDesc
WDInfoElement* infoElement;
for (offset = 0; offset < bssDesc->ieLength; offset = (infoElement->length + offset) + sizeof(WDInfoElement)) {
infoElement = (WDInfoElement*)(ptr + offset);
infoElement = (WDInfoElement*)((u8*)ptr + offset);
if (infoElement->id == id) {
break;
}

View File

@@ -82,7 +82,7 @@ loop:
image[j + 16] = 0;
}
string = OSGetFontTexel(string, image, 0, 6, &width);
string = OSGetFontTexel((char*)string, image, 0, 6, &width);
for (i = 0; i < 24; i++) {
j = (i & 7) + ((i >> 3) * 24);

View File

@@ -42,6 +42,7 @@ static u32 VersionES = 0;
static u32 ConsoleType = 0;
static void* FatalFunc = NULL;
#pragma force_active on
char* getSuffix(const char* path) {
char* suffix = strrchr(path, '.');
if (suffix != NULL) {
@@ -49,6 +50,7 @@ char* getSuffix(const char* path) {
}
return suffix;
}
#pragma force_active off
static void* UpdateThread(void* argument);

View File

@@ -5,7 +5,8 @@
namespace ipl {
namespace cs {
namespace mtx34 {
static char className[] = "MTX34";
// used but pooled first
DECOMP_FORCE_ACTIVE(iplCSMtx_cpp, "MTX34");
#define PROPERTY_COUNT 13
extern const CHANSVmPropertyList cPropertyList[PROPERTY_COUNT];
@@ -150,7 +151,7 @@ namespace ipl {
BOOL init(CHANSVm* vm) {
BOOL result = FALSE;
// Create class
CHANSVmNativeClass* cls = CHANSVmAddNativeClass(vm, className, ctor, NULL);
CHANSVmNativeClass* cls = CHANSVmAddNativeClass(vm, "MTX34", ctor, NULL);
if (cls != NULL) {
// Add properties
result = CHANSVmAddNativePropertyAccessorsList(vm, cls, cPropertyList, PROPERTY_COUNT) == CHANS_VM_OK;

View File

@@ -1,7 +1,7 @@
#include <revolution/gx/GXStruct.h>
#include <revolution/os/OSError.h>
extern "C" char scCsFatalMsg[];
extern "C" const char scCsFatalMsg[];
extern "C" const u8 scCsFatalColorR;
extern "C" const u8 scCsFatalColorG;
extern "C" const u8 scCsFatalColorB;
@@ -620,7 +620,10 @@ namespace ipl {
namespace ipl {
namespace cs {
namespace pane {
extern "C" char scCsFatalMsg[] = "Error#004\nAn error has occurred.\nThe system files are corrupted.";
#pragma push
#pragma section const_type ".data"
extern "C" const char scCsFatalMsg[] = "Error#004\nAn error has occurred.\nThe system files are corrupted.";
#pragma pop
#pragma push
#pragma section data_type ".sdata"

View File

@@ -618,13 +618,10 @@ namespace ipl {
return result;
}
}
namespace util {
template BOOL get_int<savedata::COMPRESSION_LZ>(CHANSVm*, CHANSVmObjHdr*, CHANSVmObjHdr*);
template BOOL get_int<savedata::COMPRESSION_HUFFMAN>(CHANSVm*, CHANSVmObjHdr*, CHANSVmObjHdr*);
template BOOL get_int<savedata::COMPRESSION_RL>(CHANSVm*, CHANSVmObjHdr*, CHANSVmObjHdr*);
}
namespace savedata {
// Force get_int<N> specializations to be emitted here
DECOMP_FORCE_LITERAL(iplCSSavedata_cpp, util::get_int<COMPRESSION_LZ>)
DECOMP_FORCE_LITERAL(iplCSSavedata_cpp, util::get_int<COMPRESSION_HUFFMAN>)
DECOMP_FORCE_LITERAL(iplCSSavedata_cpp, util::get_int<COMPRESSION_RL>)
template <>
BOOL get<s8>(CHANSVm* vm, CHANSVmObjHdr* parentObj, CHANSVmObjHdr* returnObj);

View File

@@ -43,6 +43,7 @@ void HBMFreeMem(void* pBlock) {
MEMFreeToAllocator(spAllocator, pBlock);
}
#pragma force_active on
static HBMAllocatorType getAllocatorType(const HBMDataInfo* pDataInfo) {
if (pDataInfo->pAllocator != NULL) {
return HBM_ALLOCATOR_APPLI;
@@ -54,6 +55,7 @@ static HBMAllocatorType getAllocatorType(const HBMDataInfo* pDataInfo) {
return HBM_ALLOCATOR_NW4R;
}
#pragma force_active off
void HBMCreate(const HBMDataInfo* pDataInfo) {
MEMiHeapHead* hExpHeap;

View File

@@ -12,16 +12,23 @@ extern "C" void GetFont__Q34nw4r3lyt8TextBoxCFv();
namespace textinput {
namespace candidatebox {
extern "C" char scT_prdc_Text_00[15] = "T_prdc_Text_00";
extern "C" char scP_prdc_scrl_Left[17] = "P_prdc_scrl_Left";
#pragma push
#pragma section const_type ".data"
extern "C" const char scT_prdc_Text_00[15] = "T_prdc_Text_00";
extern "C" const char scP_prdc_scrl_Left[17] = "P_prdc_scrl_Left";
#pragma pop
#pragma push
#pragma section sconst_type ".sdata"
extern "C" const char* scCommonTextAnimName = scT_prdc_Text_00;
extern "C" const char* scCommonScrollAnimName = scP_prdc_scrl_Left;
#pragma explicit_zero_data on
extern "C" wchar_t scEmptyWChars[4] = {0, 0, 0, 0};
extern "C" const wchar_t scEmptyWChars[4] = {0, 0, 0, 0};
#pragma explicit_zero_data reset
extern "C" char scP_OnBtn[8] = "P_OnBtn";
extern "C" char scB_OnBtn[8] = "B_OnBtn";
extern "C" const char scP_OnBtn[8] = "P_OnBtn";
extern "C" const char scB_OnBtn[8] = "B_OnBtn";
#pragma pop
#define COMMON_TEXT_ANIM scCommonTextAnimName
#define COMMON_SCROLL_ANIM scCommonScrollAnimName
@@ -198,7 +205,9 @@ namespace textinput {
{&csAninationFile[0], &csAninationFile[8], &csAninationFile[9], &csAninationFile[10], &csAninationFile[11], &csAninationFile[12]}},
}, {"P_OffBtn"}};
extern "C" char scPaneNameTable[132] =
#pragma push
#pragma section const_type ".data"
extern "C" const char scPaneNameTable[132] =
"B_OffBtn\0\0\0\0"
"P_JPOffBtn\0\0"
"P_CNOffBtn\0\0"
@@ -209,9 +218,10 @@ namespace textinput {
"P_prdc_scrl_Rght\0\0\0\0"
"\0\0\0";
extern "C" char scW_predictWindow[16] = "W_predictWindow";
extern "C" char scN_predictInput[15] = "N_predictInput";
extern "C" char scW_OnOff_Area[13] = "W_OnOff_Area";
extern "C" char scN_prdc_Texts[13] = "N_prdc_Texts";
extern "C" const char scN_predictInput[15] = "N_predictInput";
extern "C" const char scW_OnOff_Area[13] = "W_OnOff_Area";
extern "C" const char scN_prdc_Texts[13] = "N_prdc_Texts";
#pragma pop
void CandidateBoxCaller::Candidates::addCandidate(const wchar_t* wcString) {
wcsncpy(szwcPredicted[mNumCandidate], wcString, ARRAY_LENGTH(szwcPredicted[0]));

View File

@@ -175,6 +175,13 @@ namespace textinput {
return table->keySets[mode]->pPaneNameToCharCode;
}
struct NumericKeyView {
const PaneNameToCharCode& key;
NumericKeyView(const KeySet& set, u16 index) : key(set.pPaneNameToCharCode[index]) {}
bool matches(const char* paneName) const { return util::strcmp(key.szPaneName, paneName); }
wchar_t character() const { return key.wc[0]; }
};
static inline const PaneNameToCharCode* findLowerCaseKey(const LanguageDependencyData* table, const char* paneName) {
u16 index = 0;
const PaneNameToCharCode* keys = table->keySets[Base::IM_01]->pPaneNameToCharCode;
@@ -316,8 +323,9 @@ namespace textinput {
}
} else {
for (u16 index = 0; index < 12; index++) {
if (util::strcmp(csKeySetNumber.pPaneNameToCharCode[index].szPaneName, paneName)) {
wchar_t character = csKeySetNumber.pPaneNameToCharCode[index].wc[0];
const NumericKeyView key(csKeySetNumber, index);
if (key.matches(paneName)) {
wchar_t character = key.character();
ConfirmInput commandData = {0};
commandData.character = character;
commandData.letterMode = mCurrentInputMode;

View File

@@ -3,16 +3,16 @@
namespace textinput {
namespace debug {
struct iVertex {
iVertex(f32 posX, f32 posY, u32 red, u32 green, u32 blue, u32 alpha);
iVertex(f32 posX, f32 posY, f32 posZ, u32 red, u32 green, u32 blue, u32 alpha)
: x(posX), y(posY), z(posZ), r(red), g(green), b(blue), a(alpha) {
}
f32 x, y, z; // 0x00
u32 r, g, b, a; // 0x0C
};
iVertex::iVertex(f32 posX, f32 posY, u32 red, u32 green, u32 blue, u32 alpha)
: x(posX), y(posY), z(0.0f), r(red), g(green), b(blue), a(alpha) {
}
DECOMP_FORCE_LITERAL(tiDebug_cpp, 0.0f);
static void draw_rect(const iVertex& v0, const iVertex& v1, const iVertex& v2, const iVertex& v3) {
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
@@ -59,10 +59,10 @@ namespace textinput {
MTXConcat(mtx, mtxScale, mtx);
GXLoadPosMtxImm(mtx, GX_PNMTX0);
draw_rect(iVertex(left - centerX, top - centerY, color.r, color.g, color.b, color.a),
iVertex(right - centerX, top - centerY, color.r, color.g, color.b, color.a),
iVertex(left - centerX, bottom - centerY, color.r, color.g, color.b, color.a),
iVertex(right - centerX, bottom - centerY, color.r, color.g, color.b, color.a));
draw_rect(iVertex(left - centerX, top - centerY, 0, color.r, color.g, color.b, color.a),
iVertex(right - centerX, top - centerY, 0, color.r, color.g, color.b, color.a),
iVertex(left - centerX, bottom - centerY, 0, color.r, color.g, color.b, color.a),
iVertex(right - centerX, bottom - centerY, 0, color.r, color.g, color.b, color.a));
Mtx mtx2;
MTXIdentity(mtx2);
@@ -110,6 +110,7 @@ namespace textinput {
GXPosition3f32(x1 + realWidth, y0, z);
GXColor1u32(*(u32*)&color);
}
GXEnd();
} else {
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
{
@@ -122,8 +123,8 @@ namespace textinput {
GXPosition3f32(x1, y0 - realWidth, z);
GXColor1u32(*(u32*)&color);
}
GXEnd();
}
GXEnd();
}
} // namespace debug
} // namespace textinput

View File

@@ -514,11 +514,8 @@ namespace textinput {
}
}
}
void CommandSender::updateFromReceiver(u32, void*) {}
namespace predictlang {
// HACK: weak function order
DECOMP_FORCE_ACTIVE(tiPredictLang_cpp, (((CommandSender*)(NULL))->updateFromReceiver(0, NULL), 0))
void LayoutByNW4R::draw() {
nw4rmanager::Layout::draw();

View File

@@ -1625,10 +1625,12 @@ namespace ipl {
void Address::set_err_msg(wchar_t* errMsg, u32 errMsgLen, NWC24Err err) {
memset(errMsg, 0, errMsgLen * sizeof(wchar_t));
const wchar_t* messageText;
u32 messageId;
messageText = System::getMessage(MESG_ERROR_CODE);
wcsncat(errMsg, messageText, errMsgLen - wcslen(errMsg));
union MessageValue {
const wchar_t* text;
u32 id;
} message;
message.text = System::getMessage(MESG_ERROR_CODE);
wcsncat(errMsg, message.text, errMsgLen - wcslen(errMsg));
wchar_t errCode[32];
memset(errCode, 0, sizeof(errCode));
@@ -1637,18 +1639,22 @@ namespace ipl {
switch (err) {
case NWC24_ERR_NETWORK: {
messageId = MESG_ERROR_NWC24_NETWORK;
message.id = MESG_ERROR_NWC24_NETWORK;
break;
}
case NWC24_ERR_SERVER:
case NWC24_ERR_FULL: {
messageId = MESG_ERROR_NWC24_SERVER;
message.id = MESG_ERROR_NWC24_SERVER;
break;
}
default: {
message.id = reinterpret_cast<u32>(message.text);
break;
}
}
messageText = System::getMessage(messageId);
wcsncat(errMsg, messageText, errMsgLen - wcslen(errMsg));
message.text = System::getMessage(message.id);
wcsncat(errMsg, message.text, errMsgLen - wcslen(errMsg));
}
void Address::entry_friend() {

View File

@@ -1326,7 +1326,7 @@ namespace ipl {
ARCFileInfo arcFile;
if (ARCOpen(&arc, "./chjump.bin", &arcFile)) {
mpChJpData = (NWC24CHJumpObj*)(pArc + ARCGetStartOffset(&arcFile));
mpChJpData = (NWC24CHJumpObj*)((u8*)pArc + ARCGetStartOffset(&arcFile));
if (nwc24Mgr->checkCHJumpObj(mpChJpData, ARCGetLength(&arcFile))) {
u64 titleId = 0;

View File

@@ -242,3 +242,12 @@ namespace ipl {
}
} // namespace scene
} // namespace ipl
namespace ipl {
namespace scene {
__declspec(weak) u32 url_processor_data_pad() {
static const u32 pad __attribute__((section(".data"), aligned(1))) = 0;
return *((volatile const u32*)&pad);
}
} // namespace scene
} // namespace ipl

View File

@@ -879,6 +879,7 @@ namespace ipl {
}
BOOL Calendar::is_lower_limit() {
static const f32 pad0 __attribute__((section(".data"), aligned(1), used)) = 0.0f;
return mpBoardDate->year == mscMinDate.year && mpBoardDate->month == mscMinDate.month;
}
} // namespace scene

View File

@@ -13,7 +13,10 @@ namespace ipl {
extern "C" char scInfo_a[];
extern "C" char scB_Cal[];
extern "C" char scN_CalDay_r[] = "N_CalDay_r";
#pragma push
#pragma section const_type ".data"
extern "C" const char scN_CalDay_r[] = "N_CalDay_r";
#pragma pop
// clang-format off
extern "C" const char* scDateAnimPaneNames[Date::ANIM_PANE_MAX] = {
@@ -24,15 +27,21 @@ namespace ipl {
scInfo_a,
};
extern "C" char scMyIplTopFBrlan[] = "my_IplTop_f.brlan";
extern "C" char scN_CalDay_t[] = "N_CalDay_t";
extern "C" char scSEDateFocus[] = "WIPL_SE_DATE_FOCUS";
#pragma push
#pragma section const_type ".data"
extern "C" const char scMyIplTopFBrlan[] = "my_IplTop_f.brlan";
extern "C" const char scN_CalDay_t[] = "N_CalDay_t";
extern "C" const char scSEDateFocus[] = "WIPL_SE_DATE_FOCUS";
#pragma pop
#pragma push
#pragma section const_type ".sdata"
extern "C" char scW_Cal[] = "W_Cal";
extern "C" char scT_Cal[] = "T_Cal";
extern "C" char scCal_Ac[] = "Cal_Ac";
extern "C" char scInfo_a[] = "Info_a";
extern "C" char scB_Cal[] = "B_Cal";
#pragma pop
static const Date::AnmFrame scAnmFrame[] = {
{ Date::ANIM_PANE_BTN_HOVER, 0.0f, 6.0f },
@@ -53,6 +62,10 @@ namespace ipl {
utility::Date Date::mscMinDate(MIN_YEAR, MIN_MONTH, MIN_DAY);
utility::Date Date::mscMaxDate(MAX_YEAR, MAX_MONTH, MAX_DAY);
u8 padding[0x10];
DECOMP_FORCE_ACTIVE(iplDate_cpp, padding);
Date::Date(EGG::Heap* heap, nand::LayoutFile* file, const char* layoutFolder, const char* layoutFileName)
: ::gui::EventHandler(), mbAppearMsg(0), mFocusState(0), mPendingFocusCmd(0), mpLayout(NULL), mpCurrentPaneAnim(0), mPointCount(0) {
// Layout
@@ -171,11 +184,7 @@ namespace ipl {
const char* paneName = component->getPane()->GetName();
controller::Interface* con = static_cast<controller::Interface*>(data);
if (con != NULL) {
con->getChannel();
} else {
getLatestEventCtrlNo();
}
int unused = con != NULL ? con->getChannel() : getLatestEventCtrlNo();
switch (event) {
// Pointer on button
@@ -301,7 +310,9 @@ namespace ipl {
onCmdRecv(3);
}
#pragma push
#pragma section sconst_type ".sdata2"
extern "C" const f32 scDateZeroF = 0.0f;
#pragma pop
} // namespace scene
} // namespace ipl

View File

@@ -2,25 +2,30 @@
#include "scene/channelEdit/iplChannelEdit.h"
extern "C" char scBrlan_SaveDataIn[] = "it_ObjChannelEdit_b_SaveDataIn.brlan";
extern "C" char scBrlan_SaveDataOut[] = "it_ObjChannelEdit_b_SaveDataOut.brlan";
extern "C" char scBrlan_SaveDataFocusIn[] = "it_ObjChannelEdit_b_SaveDataFoucusIn.brlan";
extern "C" char scBrlan_SaveDataFocusOut[] = "it_ObjChannelEdit_b_SaveDataFoucusOut.brlan";
extern "C" char scPaneName_N_Data16x9[] = "N_Data16x9";
extern "C" char scPaneName_N_Data4x3[] = "N_Data4x3";
extern "C" char scPaneName_B_Data_01[] = "B_Data_01";
extern "C" char scPaneName_B_Data_00[] = "B_Data_00";
extern "C" char scPaneName_N_Atari16x9[] = "N_Atari16x9";
extern "C" char scPaneName_N_Data_01[] = "N_Data_01";
extern "C" char scPaneName_N_Atari4x3[] = "N_Atari4x3";
extern "C" char scPaneName_N_Data_00[] = "N_Data_00";
extern "C" char scPaneName_DataBaseCover_00[] = "DataBaseCover_00";
extern "C" char scPaneName_DataBaseCover_01[] = "DataBaseCover_01";
extern "C" char scGroup_G_Data[] = "G_Data";
extern "C" wchar_t scUnknownWstr[] = L"???";
extern "C" const f32 scHalfF = 0.5f;
extern "C" const f32 scTwoF = 2.0f;
extern "C" const f64 scF2IBias = 4503599627370496.0;
#pragma push
#pragma section const_type ".data"
extern "C" const char scBrlan_SaveDataIn[] = "it_ObjChannelEdit_b_SaveDataIn.brlan";
extern "C" const char scBrlan_SaveDataOut[] = "it_ObjChannelEdit_b_SaveDataOut.brlan";
extern "C" const char scBrlan_SaveDataFocusIn[] = "it_ObjChannelEdit_b_SaveDataFoucusIn.brlan";
extern "C" const char scBrlan_SaveDataFocusOut[] = "it_ObjChannelEdit_b_SaveDataFoucusOut.brlan";
extern "C" const char scPaneName_N_Data16x9[] = "N_Data16x9";
extern "C" const char scPaneName_N_Data4x3[] = "N_Data4x3";
extern "C" const char scPaneName_B_Data_01[] = "B_Data_01";
extern "C" const char scPaneName_B_Data_00[] = "B_Data_00";
extern "C" const char scPaneName_N_Atari16x9[] = "N_Atari16x9";
extern "C" const char scPaneName_N_Data_01[] = "N_Data_01";
extern "C" const char scPaneName_N_Atari4x3[] = "N_Atari4x3";
extern "C" const char scPaneName_N_Data_00[] = "N_Data_00";
extern "C" const char scPaneName_DataBaseCover_00[] = "DataBaseCover_00";
extern "C" const char scPaneName_DataBaseCover_01[] = "DataBaseCover_01";
#pragma section const_type ".sdata"
extern "C" __declspec(section ".sdata") const char scGroup_G_Data[] = "G_Data";
extern "C" __declspec(section ".sdata") const wchar_t scUnknownWstr[] = L"???";
#pragma section sconst_type ".sdata2"
extern "C" __declspec(section ".sdata2") const f32 scHalfF = 0.5f;
extern "C" __declspec(section ".sdata2") const f32 scTwoF = 2.0f;
extern "C" __declspec(section ".sdata2") const f64 scF2IBias = 4503599627370496.0;
#pragma pop
namespace ipl {
namespace scene {

View File

@@ -28,6 +28,11 @@ namespace ipl {
{85.f, 48.f},
};
// TODO: Figure out what this might've been/why it isn't inlining
void CHANAPPEDIT_dummyFunctionToKeepAConstructorStuffFromInlining(nw4r::math::VEC3& vec) {
math::VEC3 end(vec);
}
ChanAppEdit::ChanAppEdit(EGG::Heap* heap, nand::LayoutFile* layoutFile, const char* layoutDir, const char* layoutFileName)
: AnmController(heap), ::gui::EventHandler(), mState(STATE_IDLE), mLinearInterp(), mpChanAppBox(NULL), mMsgId(0), mpThumbnail(NULL) {
mpLayout = new (heap) layout::Object(heap, layoutFile, layoutDir, layoutFileName);

View File

@@ -147,6 +147,8 @@ namespace ipl {
extern "C" char scBrlyt_my_DiskCh_a[] = "my_DiskCh_a.brlyt";
extern "C" char scBrlan_my_GCTop_a_BackLoop[] = "my_GCTop_a_BackLoop.brlan";
#pragma push
#pragma section data_type ".sdata"
extern "C" char scPaneName_B_BtnA[] = "B_BtnA";
extern "C" char scPaneName_B_BtnB[] = "B_BtnB";
extern "C" const char* scPaneNames_B_Btn[2] = {
@@ -187,6 +189,7 @@ namespace ipl {
scPaneName_T_BtnA,
scPaneName_T_BtnB,
};
#pragma pop
const char* scWidePanes[3][4] = {
{

View File

@@ -14,9 +14,8 @@
namespace ipl {
namespace scene {
static inline void setLetterHeaderCaption(LetterWriter* writer, const wchar_t* name) {
const wchar_t* caption = writer->makeHeaderCaption(name);
writer->getLetterInputForm()->setHeaderCaption(caption);
static inline wchar_t* letterWriterCaption(wchar_t* caption) {
return caption;
}
LetterWriter::LetterWriter(EGG::Heap* heap, int type)
@@ -146,7 +145,8 @@ namespace ipl {
Address* address = static_cast<Address*>(System::getScene(SCENE_ADDRESS));
memcpy(&mFriendInfo, &address->getFriendCache()->getInfo(address->getChosenFriendIndex()), sizeof(NWC24FriendInfo));
setLetterHeaderCaption(this, (const wchar_t*)mFriendInfo.attr.name);
const wchar_t* caption = letterWriterCaption(makeHeaderCaption((const wchar_t*)mFriendInfo.attr.name));
getLetterInputForm()->setHeaderCaption(caption);
mbToFriend = true;
mLetterState = LETTER_STATE_NORMAL;

View File

@@ -1292,7 +1292,10 @@ int ATERMApplyScanSecuritySettings(void) {
char* keyString;
s32 keyIndex;
size_t keyLength;
char keyText[33];
struct {
char text[32];
char terminator;
} keyText;
strcpy(gAtermConfigurationResult.ssid, gScanSettings.ssid);
switch (gScanSettings.selectedSecurity) {
@@ -1305,14 +1308,14 @@ int ATERMApplyScanSecuritySettings(void) {
} else {
gAtermConfigurationResult.securityMode = gScanSettings.authAlgorithm;
sourceKey = gScanSettings.wirelessKeys[0].key;
keyString = keyText;
keyString = keyText.text;
outputKey = (char*)gAtermConfigurationResult.reserved028;
keyIndex = 0;
do {
memcpy(keyText, sourceKey, 0x20);
keyText[32] = '\0';
keyLength = strlen(keyText);
memcpy(keyText.text, sourceKey, 0x20);
keyText.terminator = '\0';
keyLength = strlen(keyText.text);
switch (keyLength) {
case 0:
break;

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