diff --git a/README.md b/README.md index 697ec541..cb37b0ff 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,9 @@ Progress | Decompiled | Matched | Linked | Data | |:---:|:---:|:---:|:---:| -| 97.69% | 84.10% | 58.20% | 90.31% | +| 97.84% | 84.31% | 58.20% | 90.33% | -units 778/1027 complete, functions 12051/12563 matched. +units 778/1027 complete, functions 12057/12563 matched. decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data diff --git a/libs/RVLMiddleware/eZiText/src/clib/zi8dawg.c b/libs/RVLMiddleware/eZiText/src/clib/zi8dawg.c index 3283d646..dce44ce3 100644 --- a/libs/RVLMiddleware/eZiText/src/clib/zi8dawg.c +++ b/libs/RVLMiddleware/eZiText/src/clib/zi8dawg.c @@ -12,153 +12,140 @@ ziU8 ZiDAWGgetEOWattribute(ziU8* graph); ziU8* ZiDAWGGetChild(ziU8* graph); ziU8* ZiDAWGGetSibling(ziU8* graph); -ziU32 Zi8MatchROMdata0(ziWChar* elements, ziU32 count, ziU8 language, +ziU32 Zi8MatchROMdata0(ziWChar* elements, ziU8 count, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 mode, ziU8 status, ziU8 graphTable, ziU8 keyTable, ziU8 acceptPrefix, ziU8* prefixLength, zi8DawgCtx* context, ziU8* search, ziPtr __zi8_work_data) { - ziBool searching; - ziS32 tableSize; - ziU8* graph; - ziU16 key; - ziU8 endOfWord; - zi8DawgRec* current; - ziU16 index; - ziU16 depth; - zi8DawgRec* records = context->recs; ziU8 result = 0; - ziU32 keyCount; - ziU8* table; + ziU8* graphData; + ziU8* keyData; + ziS32 keyCount; + ziS32 convertedKey; + ziU16 searching; + ziU16 key; ziU16 keys[3]; + ziU16 index; + zi8DawgRec* current; + zi8DawgRec* records = context->recs; - if (language != context->lang || graphTable != context->key) { - records[0].key = 0; - } - if ((ziU8)count != 1 || mode == 0 || graphTable != 0xe) { - if (status != 0) { - if (records[context->cnt - 1].node == (ziU8*)context->unk_0x338) goto finish_graph; - for (index = 0; (ziU16)index < (ziU8)count; index++) { - if (records[(ziU16)index].key != elements[(ziU16)index] && - (records[(ziU16)index].attr & 0xffff) != elements[(ziU16)index]) goto finish_graph; - } - if (mode == 1) acceptPrefix = 0; + if (language != context->lang || graphTable != context->key) records[0].key = 0; + if (count == 1 && mode != 0 && graphTable == 0xe) goto finish_graph; + if (status != 0) { + if (records[context->cnt - 1].node == (ziU8*)context->unk_0x338) goto finish_graph; + for (index = 0; index < count; index++) { + if (records[index].key != elements[index] && + (ziU16)records[index].attr != elements[index]) goto finish_graph; + } + if (mode == 1) acceptPrefix = 0; + } else { + if (ZI_WORK->unk_0x141E != 0 && graphTable == 0xc && + Zi8GetTableSize(language, ZI_WORK->unk_0x141E, ZI_WORK) != 0) { + graphData = (ziU8*)Zi8GetTableAddress(language, ZI_WORK->unk_0x141E, ZI_WORK); + keyTable = ZI_WORK->unk_0x141E + 1; } else { - if (ZI_WORK->unk_0x141E == 0 || graphTable != 0xc || - (tableSize = Zi8GetTableSize(language, ZI_WORK->unk_0x141E, ZI_WORK)) == 0) { - tableSize = Zi8GetTableSize(language, graphTable, ZI_WORK); - if (tableSize == 0) { - Zi8LogError(0x961, ZI_WORK); - goto finish_graph; - } - table = (ziU8*)Zi8GetTableAddress(language, graphTable, ZI_WORK); - } else { - table = (ziU8*)Zi8GetTableAddress(language, ZI_WORK->unk_0x141E, ZI_WORK); - keyTable = ZI_WORK->unk_0x141E + 1; - } - context->table = table; - context->cap = (((ziU16)context->table[2] << 8) + (ziU16)context->table[3]) / 3; - context->p08 = context->table + 4; - context->p0C = context->table + context->cap * 2 + 4; - context->lang = language; - context->key = graphTable; - index = 0; - while ((ziU16)index < (ziU8)count && records[(ziU16)index].key == elements[(ziU16)index]) { - index++; - } - if ((ziU16)index < 2) { - key = Zi8GetTableSize(language, keyTable, ZI_WORK); - if (key == 0 || ZI_WORK->userKeys[language] != 0) { - graph = ZiDAWGGetGraph(context); - records[0].node = graph; - context->unk_0x338 = 0; - context->p14 = 0; - } else { - index = 0; - while (1) { - if ((ziU8)count < 2) keyCount = (ziU8)count; - else keyCount = 2; - if (keyCount <= (ziU16)index) break; - key = Zi8ConvertWC2Key(elements[(ziU16)index], language, ZI_WORK); - keys[(ziU16)index] = key; - if (keys[(ziU16)index] == 0) keys[(ziU16)index] = elements[(ziU16)index]; - index++; - } - keys[(ziU16)index] = 0; - table = (ziU8*)Zi8GetTableAddress(language, keyTable, ZI_WORK); - context->p14 = table + 2; - records[0].node = ZiDAWGGetGraphInfo(context, table + context->cap * 2 + 2, (ziS16*)keys); - } - records[0].key = 0; - if (records[0].node == 0) goto finish_graph; - } else { - records[0].node = records[(ziU16)index - 1].back; - } - context->cnt = 1; - search[1] = count; - search[0] = 0; - if (mode == 1) { - search[0] = 1; - acceptPrefix = 0; - } else if (mode == 0 && acceptPrefix == 0) { - search[1]++; + if (Zi8GetTableSize(language, graphTable, ZI_WORK) == 0) { + Zi8LogError(0x961, ZI_WORK); + goto finish_graph; } + graphData = (ziU8*)Zi8GetTableAddress(language, graphTable, ZI_WORK); } - searching = 1; - depth = context->cnt; - while ((current = &records[depth - 1], searching) && context->cnt != 0 && - current->node != (ziU8*)context->unk_0x338 && context->cnt <= capacity) { - current->attr = ZiDAWGgetCHARattribute(context, current->node, ZI_WORK); - if ((ziU8)count < context->cnt) { -check_word: - if (context->cnt < search[1]) goto descend; - if (search[0] == 0 || context->cnt <= search[1]) { - if (acceptPrefix != 0 || (endOfWord = ZiDAWGgetEOWattribute(current->node)) != 0) { - for (depth = 0; depth < context->cnt; depth++) { - output[depth] = records[depth].attr; - } - result = context->cnt; - searching = 0; - if (acceptPrefix != 0) goto next_sibling; - } - if (search[0] == 0 || context->cnt < search[1]) goto descend; - } -next_sibling: - while (context->cnt != 0) { - graph = ZiDAWGGetSibling(records[context->cnt - 1].node); - records[context->cnt - 1].node = graph; - if (records[context->cnt - 1].node != 0) break; - context->cnt--; + context->table = graphData; + context->cap = (((ziU16)context->table[2] << 8) + context->table[3]) / 3; + context->p08 = context->table + 4; + context->p0C = context->table + context->cap * 2 + 4; + context->lang = language; + context->key = graphTable; + index = 0; + while (index < count && records[index].key == elements[index]) index++; + if (index >= 2) { + records[0].node = records[index - 1].back; + } else { + key = Zi8GetTableSize(language, keyTable, ZI_WORK); + if (key != 0 && ZI_WORK->userKeys[language] == 0) { + index = 0; + goto check_keys; +next_key: + { + keys[index] = Zi8ConvertWC2Key(elements[index], language, ZI_WORK); + if (keys[index] == 0) keys[index] = elements[index]; + index++; } +check_keys: + if (count < 2) keyCount = count; + else keyCount = 2; + if (index < keyCount) goto next_key; + keys[index] = 0; + keyData = (ziU8*)Zi8GetTableAddress(language, keyTable, ZI_WORK); + context->p14 = keyData + 2; + keyData += context->cap * 2 + 2; + records[0].node = ZiDAWGGetGraphInfo(context, keyData, (ziS16*)keys); } else { - if (context->p14 == 0) { - key = Zi8ConvertWC2Key(current->attr & 0xffff, language, ZI_WORK); - } else { - key = (ziU16)context->p14[(current->attr >> 24) * 2] * 0x100 + - (ziU16)context->p14[(current->attr >> 24) * 2 + 1]; - } - if (key != elements[context->cnt - 1] && - (current->attr & 0xffff) != elements[context->cnt - 1]) goto next_sibling; - if (current->key != elements[context->cnt - 1]) { - current->key = elements[context->cnt - 1]; - current->back = records[0].node; - depth = context->cnt; - records[depth].key = 0; - } - if (prefixLength != 0 && *prefixLength < context->cnt && - (endOfWord = ZiDAWGgetEOWattribute(current->node)) != 0) { - *prefixLength = context->cnt; - for (depth = 0; depth < context->cnt; depth++) output[depth] = records[depth].attr; - } - if ((ziU8)count <= context->cnt) goto check_word; + records[0].node = ZiDAWGGetGraph(context); + context->unk_0x338 = 0; + context->p14 = 0; + } + records[0].key = 0; + if (records[0].node == (ziU8*)0) goto finish_graph; + } + context->cnt = 1; + search[1] = count; + search[0] = 0; + if (mode == 1) { + search[0] = 1; + acceptPrefix = 0; + } else if (mode == 0 && acceptPrefix == 0) search[1]++; + } + searching = 1; + current = &records[context->cnt - 1]; + while (searching && context->cnt != 0 && current->node != (ziU8*)context->unk_0x338) { + if (capacity < context->cnt) goto finish_graph; + current->attr = ZiDAWGgetCHARattribute(context, current->node, ZI_WORK); + if (context->cnt <= count) { + if (context->p14 == 0) { + convertedKey = Zi8ConvertWC2Key((ziU16)current->attr, language, ZI_WORK); + } else { + convertedKey = ((ziU16)context->p14[(current->attr >> 24) * 2] << 8) + + (context->p14 + (current->attr >> 24) * 2)[1]; + } + key = convertedKey; + if (key != elements[context->cnt - 1] && + (ziU16)current->attr != elements[context->cnt - 1]) goto next_sibling; + if (current->key != elements[context->cnt - 1]) { + current->key = elements[context->cnt - 1]; + current->back = records[0].node; + records[context->cnt].key = 0; + } + if (prefixLength != 0 && *prefixLength < context->cnt && + ZiDAWGgetEOWattribute(current->node) != 0) { + *prefixLength = context->cnt; + for (index = 0; index < context->cnt; index++) output[index] = (ziU16)records[index].attr; + } + if (context->cnt < count) goto descend; + } + if (context->cnt < search[1]) goto descend; + if (search[0] != 0 && context->cnt > search[1]) goto next_sibling; + 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; + if (acceptPrefix != 0) goto next_sibling; + } + if (search[0] != 0 && context->cnt >= search[1]) goto next_sibling; descend: - graph = ZiDAWGGetChild(records[context->cnt - 1].node); - records[context->cnt].node = graph; - if (records[context->cnt].node == 0) goto next_sibling; - context->cnt++; - if (ZI_WORK->unk_0x141F < context->cnt) ZI_WORK->unk_0x141F = context->cnt; - } - depth = context->cnt; + records[context->cnt].node = ZiDAWGGetChild(records[context->cnt - 1].node); + if (records[context->cnt].node == (ziU8*)0) goto next_sibling; + context->cnt++; + if (ZI_WORK->unk_0x141F < context->cnt) ZI_WORK->unk_0x141F = context->cnt; + goto update_current; +next_sibling: + while (context->cnt != 0) { + records[context->cnt - 1].node = ZiDAWGGetSibling(records[context->cnt - 1].node); + if (records[context->cnt - 1].node != (ziU8*)0) break; + context->cnt--; } +update_current: + current = &records[context->cnt - 1]; } finish_graph: return result; @@ -190,13 +177,13 @@ ziU8* NextDawgGroup(ziU8* group, ziU8 language, ziPtr __zi8_work_data) return 0; } -unsigned int Zi8MatchROMdata1(ziWChar *elements, ziU8 count, ziU8 language, ziWChar *output, ziU16 capacity, ziU8 mode, unsigned int status, ziU32 groupIndex, char *group, ziU8 acceptPrefix, ziPtr __zi8_work_data) +unsigned int Zi8MatchROMdata1(ziWChar *elements, ziU8 count, ziU8 language, ziWChar *output, ziU16 capacity, ziU8 mode, ziU8 status, ziU32 groupIndex, char *group, ziU8 acceptPrefix, ziPtr __zi8_work_data) { unsigned int result; ziU32 tableAddress; result = 0; - if ((status & 0xff) == 0) { + if (status == 0) { ZI_WORK->unk_0x1764 = (ziU8*)group; if (ZI_WORK->unk_0x1764 == 0) { if (Zi8GetTableSize(language & 0xff,0xb,ZI_WORK) != 0) { @@ -234,163 +221,139 @@ unsigned int Zi8MatchROMdata1(ziWChar *elements, ziU8 count, ziU8 language, ziWC return result; } -unsigned int Zi8MatchROMdata2(ziWChar *elements, unsigned int count, unsigned int language, ziWChar *output, unsigned int capacity, unsigned int mode, unsigned int status, ziU8 reservedMode, ziU8 *group, ziU8 acceptPrefix, ziPtr __zi8_work_data) -{ - ziU16 character; - unsigned int result; - ziU8 prefixCount; - unsigned int index; - unsigned int remaining; +unsigned int Zi8MatchROMdata2(ziWChar* elements, ziU8 count, ziU8 language, + ziWChar* output, ziU16 capacity, ziU8 mode, + ziU8 status, ziU8 reservedMode, ziU8* group, + ziU8 acceptPrefix, ziPtr __zi8_work_data) { + unsigned int result = 0; + ziU8 index; - result = 0; - if (reservedMode != 0) return 0; - if ((status & 0xff) == 0) { - ZI_WORK->unk_0x1768 = 0; - ZI_WORK->unk_0x17EA = 0; - if ((((group == 0) || (*group != '\f')) || ((language & 0xff) != 10)) || - (ZI_WORK->unk_0x141C == '\0')) { - ZI_WORK->unk_0x141E = 0; - } - else { - ZI_WORK->unk_0x141E = 0x10; - } + if (reservedMode != 0) return 0; + if (status == 0) { + ZI_WORK->unk_0x1768 = 0; + ZI_WORK->unk_0x17EA = 0; + if (group != 0 && *group == 0xc && language == 10 && ZI_WORK->unk_0x141C != 0) { + ZI_WORK->unk_0x141E = 0x10; + } else { + ZI_WORK->unk_0x141E = 0; + } } search_segment: ZI_WORK->unk_0x141F = 1; - result = Zi8MatchROMdata1(elements + (unsigned int)ZI_WORK->unk_0x17EA, - count - ZI_WORK->unk_0x17EA & 0xff,language & 0xff, - &ZI_WORK->unk_0x17F4[ZI_WORK->unk_0x17EA], - capacity & 0xffff,mode & 0xff,status & 0xff, - ZI_WORK->unk_0x1768,(char *)group,acceptPrefix,ZI_WORK); - if ((result & 0xff) == 0) { - if ((((status & 0xff) != 0) || ((count & 0xff) == 1)) || - (((mode & 0xff) == 1 && - ((ZI_WORK->unk_0x1768 == 0 && - (prefixCount = Zi8MatchROMdata1(elements + (unsigned int)ZI_WORK->unk_0x17EA, - count - ZI_WORK->unk_0x17EA & 0xff,language & 0xff, - &ZI_WORK->unk_0x17F4[ZI_WORK->unk_0x17EA], - capacity & 0xffff,0,status & 0xff, - ZI_WORK->unk_0x1768,(char *)group,acceptPrefix,ZI_WORK), - prefixCount != '\0')))))) goto finish_segments; - index = Zi8GetTableCount(language & 0xff,0x1f,ZI_WORK); - if ((index & 4) == 0) { - for (index = 0; (index & 0xff) < (count & 0xff); index = index + 1) { - if (elements[index & 0xff] == 0xeff1) goto finish_segments; + result = Zi8MatchROMdata1(elements + ZI_WORK->unk_0x17EA, + count - ZI_WORK->unk_0x17EA, language, + &ZI_WORK->unk_0x17F4[ZI_WORK->unk_0x17EA], capacity, + mode, status, ZI_WORK->unk_0x1768, (char*)group, + acceptPrefix, ZI_WORK); + if ((ziU8)result != 0) { + for (index = (ziU8)(ZI_WORK->unk_0x17EA + result); index != 0; index--) { + output[index - 1] = ZI_WORK->unk_0x17F4[index - 1]; } - } - if ((capacity & 0xffff) < (unsigned int)ZI_WORK->unk_0x141F) goto finish_segments; - prefixCount = ZI_WORK->unk_0x141F; - for (; prefixCount != 0; prefixCount--) { - result = Zi8MatchROMdata1(elements + (unsigned int)ZI_WORK->unk_0x17EA,prefixCount, - language & 0xff, - &ZI_WORK->unk_0x17F4[ZI_WORK->unk_0x17EA], - capacity & 0xffff,1,0,ZI_WORK->unk_0x1768,(char *)group, - acceptPrefix,ZI_WORK); - if ((result & 0xff) != 0) break; - } - if (prefixCount == 0) goto finish_segments; - ZI_WORK->unk_0x17EA = ZI_WORK->unk_0x17EA + ((ziU16)result & 0xff); - if ((unsigned int)ZI_WORK->unk_0x17EA == (count & 0xff)) { - result = 0; - goto finish_segments; - } - ZI_WORK->unk_0x1768 = ZI_WORK->unk_0x1768 + 1; - status = 0; - ZI_WORK->unk_0x141E = 0; - if ((ZI_WORK->dawgCtx.key == 0) && ((language & 0xff) == 10)) { - for (result = 0; (result & 0xff) < (unsigned int)ZI_WORK->unk_0x17EA; result = result + 1) { - character = ZI_WORK->unk_0x17F4[result & 0xff]; - if (character == 0x61 || character == 0x6f || character == 0x75) { - ZI_WORK->unk_0x141E = 0x10; - break; - } + result = (ziU8)(result + ZI_WORK->unk_0x17EA); + } else { + if (status != 0 || count == 1) goto finish_segments; + if (mode == 1 && ZI_WORK->unk_0x1768 == 0 && + (ziU8)Zi8MatchROMdata1(elements + ZI_WORK->unk_0x17EA, + count - ZI_WORK->unk_0x17EA, language, + &ZI_WORK->unk_0x17F4[ZI_WORK->unk_0x17EA], capacity, + 0, status, ZI_WORK->unk_0x1768, (char*)group, + acceptPrefix, ZI_WORK) != 0) goto finish_segments; + if ((Zi8GetTableCount(language, 0x1f, ZI_WORK) & 4) == 0) { + for (index = 0; index < count; index++) { + if (elements[index] == 0xeff1) goto finish_segments; + } + } + if (ZI_WORK->unk_0x141F > capacity) goto finish_segments; + for (index = ZI_WORK->unk_0x141F; index != 0; index--) { + result = Zi8MatchROMdata1(elements + ZI_WORK->unk_0x17EA, index, language, + &ZI_WORK->unk_0x17F4[ZI_WORK->unk_0x17EA], capacity, + 1, 0, ZI_WORK->unk_0x1768, (char*)group, + acceptPrefix, ZI_WORK); + if ((ziU8)result != 0) { + ZI_WORK->unk_0x17EA += (ziU8)result; + if (ZI_WORK->unk_0x17EA == count) return 0; + ZI_WORK->unk_0x1768++; + status = 0; + ZI_WORK->unk_0x141E = 0; + if (ZI_WORK->dawgCtx.key == 0 && language == 10) { + for (index = 0; index < ZI_WORK->unk_0x17EA; index++) { + switch (ZI_WORK->unk_0x17F4[index]) { + case 0x61: + case 0x6f: + case 0x75: + ZI_WORK->unk_0x141E = 0x10; + goto search_segment; + } + } + } + goto search_segment; + } } - } - goto search_segment; } - for (remaining = ZI_WORK->unk_0x17EA + result & 0xff; (remaining & 0xff) != 0; - remaining = remaining - 1) { - output[(remaining & 0xff) - 1] = ZI_WORK->unk_0x17F4[(remaining & 0xff) - 1]; - } - result = result + ZI_WORK->unk_0x17EA & 0xff; finish_segments: - return result; + return result; } -ziU8 Zi8MatchROMdata(ziWChar *elements, ziU8 count, ziU8 language, ziWChar *output, ziU16 capacity, ziU8 mode, ziU8 status, ziU8 reservedMode, ziU8 acceptPrefix, ziPtr __zi8_work_data) -{ - ziU8* group; - int tableSize; - ziU8 found; - unsigned int elementCount; - unsigned int result; +ziU32 Zi8MatchROMdata(ziWChar* elements, ziU8 count, ziU8 language, + ziWChar* output, ziU16 capacity, ziU8 mode, ziU8 status, + ziU8 reservedMode, ziU8 acceptPrefix, ziPtr __zi8_work_data) { + ziU32 result = 0; + ziS32 tableSize = 0; - elementCount = (unsigned int)count; - result = 0; - if ((capacity & 0xffff) < (elementCount & 0xff)) { - Zi8LogError(0x321,ZI_WORK); - } - else if ((status & 0xff) == 2) { - Zi8LogError(100,ZI_WORK); - } - else { - if ((status & 0xff) == 0) { - ZI_WORK->unk_0x17EC = 0; - group = NextDawgGroup(0,language & 0xff,ZI_WORK); - ZI_WORK->unk_0x17F0 = group; - } - else if (ZI_WORK->unk_0x17EC != '\0') { - Zi8LogError(100,ZI_WORK); - goto finish_match; - } - tableSize = Zi8GetTableSize(language & 0xff,0x1c,ZI_WORK); - if (tableSize == 0) { - result = Zi8MatchROMdata2(elements,elementCount & 0xff,language & 0xff,output,capacity & 0xffff, - mode & 0xff,status & 0xff,reservedMode & 0xff,0,acceptPrefix,ZI_WORK); - } - else { - while (((ZI_WORK->unk_0x17F0 != 0 && - (result = Zi8MatchROMdata2(elements,elementCount & 0xff,language & 0xff,output,capacity & 0xffff, - mode & 0xff,status & 0xff,reservedMode & 0xff, - (ziU8 *)ZI_WORK->unk_0x17F0,acceptPrefix,ZI_WORK), - (result & 0xff) == 0)) && - ((status = 0, 1 < (elementCount & 0xff) || ((language & 0xff) != 0x36))))) { - group = NextDawgGroup(ZI_WORK->unk_0x17F0,language & 0xff,ZI_WORK); - ZI_WORK->unk_0x17F0 = group; - } - } - if (((((result & 0xff) == 0) && ((status & 0xff) == 0)) && ((mode & 0xff) == 1)) && - (((elementCount & 0xff) == 1 && ((capacity & 0xffff) != 0)))) { - ZI_WORK->unk_0x17EC = 1; - if (tableSize == 0) { - found = Zi8MatchROMdata2(elements,elementCount & 0xff,language & 0xff,output,capacity & 0xffff,0, - status & 0xff,reservedMode & 0xff,0,acceptPrefix,ZI_WORK); - if (found != '\0') { - *output = *elements; - result = 1; + if (capacity < count) { + Zi8LogError(0x321, ZI_WORK); + } else if (status == 2) { + Zi8LogError(100, ZI_WORK); + } else { + if (status == 0) { + ZI_WORK->unk_0x17EC = 0; + ZI_WORK->unk_0x17F0 = NextDawgGroup(0, language, ZI_WORK); + } else if (ZI_WORK->unk_0x17EC != 0) { + Zi8LogError(100, ZI_WORK); + goto finish_match; } - } - else { - group = NextDawgGroup(0,language & 0xff,ZI_WORK); - ZI_WORK->unk_0x17F0 = group; - while (ZI_WORK->unk_0x17F0 != 0) { - found = Zi8MatchROMdata2(elements,elementCount & 0xff,language & 0xff,output,capacity & 0xffff,0, - status & 0xff,reservedMode & 0xff,(ziU8 *)ZI_WORK->unk_0x17F0, - acceptPrefix,ZI_WORK); - if (found != '\0') { - *output = *elements; - result = 1; - break; - } - group = NextDawgGroup(ZI_WORK->unk_0x17F0,language & 0xff,ZI_WORK); - ZI_WORK->unk_0x17F0 = group; + tableSize = Zi8GetTableSize(language, 0x1c, ZI_WORK); + if (tableSize == 0) { + result = Zi8MatchROMdata2(elements, count, language, output, capacity, + mode, status, reservedMode, 0, acceptPrefix, ZI_WORK); + } else { + while (ZI_WORK->unk_0x17F0 != 0) { + result = Zi8MatchROMdata2(elements, count, language, output, capacity, + mode, status, reservedMode, ZI_WORK->unk_0x17F0, + acceptPrefix, ZI_WORK); + if ((ziU8)result != 0) break; + status = 0; + if (count <= 1 && language == 0x36) break; + ZI_WORK->unk_0x17F0 = NextDawgGroup(ZI_WORK->unk_0x17F0, language, ZI_WORK); + } } - } + if ((ziU8)result == 0 && status == 0 && mode == 1 && count == 1 && capacity >= 1) { + mode = 0; + ZI_WORK->unk_0x17EC = 1; + if (tableSize != 0) { + ZI_WORK->unk_0x17F0 = NextDawgGroup(0, language, ZI_WORK); + while (ZI_WORK->unk_0x17F0 != 0) { + if ((ziU8)Zi8MatchROMdata2(elements, count, language, output, capacity, + mode, status, reservedMode, ZI_WORK->unk_0x17F0, + acceptPrefix, ZI_WORK) != 0) { + *output = *elements; + result = 1; + break; + } + ZI_WORK->unk_0x17F0 = NextDawgGroup(ZI_WORK->unk_0x17F0, language, ZI_WORK); + } + } else { + if ((ziU8)Zi8MatchROMdata2(elements, count, language, output, capacity, + mode, status, reservedMode, 0, acceptPrefix, ZI_WORK) != 0) { + *output = *elements; + result = 1; + } + } + } + Zi8LogError(100, ZI_WORK); } - Zi8LogError(100,ZI_WORK); - } finish_match: - return (ziU8)result; + return result; } void Zi8SyllablesROMdata(ziWChar *elements, ziU8 count, ziU8 language, ziWChar *output, ziU16 capacity, ziU8 status, ziU8* prefixLength, ziU8 reverseOrder, ziPtr __zi8_work_data) diff --git a/libs/RVLMiddleware/eZiText/src/clib/zi8getc2.c b/libs/RVLMiddleware/eZiText/src/clib/zi8getc2.c index 0dd1046e..06b4334e 100644 --- a/libs/RVLMiddleware/eZiText/src/clib/zi8getc2.c +++ b/libs/RVLMiddleware/eZiText/src/clib/zi8getc2.c @@ -114,173 +114,167 @@ static ziU16 Zi8GetEngineSignature(ziU8* destination, ziPtr work) { static ziBool Zi8AlphaSignature(ziGetParam* parameters, ziBool countOnly ZI_NEED_WORK) { ziU16 secondLength; - ziU16 firstLength; - ziU8* second; - ziU8* first; - ziU8 engine[32]; + struct { ziU16 length; ziU8* second; ziU8* first; } signatures; ziU8 dictionary[32]; + ziU8 engine[32]; ziU16 length; - ziU16 candidateCount; + ziU8* current; ziWChar* output = parameters->candidates; - second = 0; - firstLength = 0; + + signatures.first = 0; + signatures.second = 0; + signatures.length = 0; secondLength = 0; Zi8LogError(100, ZI_WORK); parameters->letters = 0; length = Zi8GetDataSignature(dictionary, 0x20, parameters->language, ZI_WORK); - if (length == 0 || length < parameters->elementCount) { - first = engine; + if (length != 0 && parameters->elementCount <= length) { + signatures.first = dictionary; + signatures.second = engine; + signatures.length = length; } else { - first = dictionary; - second = engine; - firstLength = length; + signatures.first = engine; } length = Zi8GetEngineSignature(engine, ZI_WORK); if (length < parameters->elementCount) { - if (firstLength == 0) { + if (signatures.length != 0) { + signatures.second = 0; + length = 1; + } else { Zi8ReplaceLastError(500, ZI_WORK); return 0; } - second = 0; - candidateCount = 1; - } else if (firstLength == 0) { - candidateCount = 1; - firstLength = length; - } else { - candidateCount = 2; + } else if (signatures.length != 0) { secondLength = length; + length = 2; + } else { + signatures.length = length; + length = 1; } - if (parameters->firstCandidate < candidateCount) { - candidateCount -= parameters->firstCandidate; - if (!countOnly) { - if (parameters->maxCandidates < candidateCount) { - candidateCount = parameters->maxCandidates; - } - parameters->letters = candidateCount; - if (!(parameters->getOptions & 0x80)) { - ZI_WORK->unk_0x538 = parameters->language; - parameters->candidates[0] = 0xfff0; - output = (ziWChar*)&ZI_WORK->unk_0x338; - } - if (parameters->firstCandidate != 0) { - first = second; - firstLength = secondLength; - } - if (ZI_WORK->unk_0x0A < firstLength) { - firstLength = ZI_WORK->unk_0x0A; - } - if ((parameters->elementCount < ZI_WORK->unk_0x140C[0] || - (parameters->getOptions & 0x7e) == 2) && - parameters->elementCount < firstLength) { - firstLength = parameters->elementCount; - } - while (firstLength-- != 0) { - *output++ = *first++; - } - *output++ = 0; - if (parameters->letters == 2) { - if (ZI_WORK->unk_0x0A < secondLength) { - secondLength = ZI_WORK->unk_0x0A; - } - if ((parameters->elementCount < ZI_WORK->unk_0x140C[0] || - (parameters->getOptions & 0x7e) == 2) && - parameters->elementCount < secondLength) { - secondLength = parameters->elementCount; - } - while (secondLength-- != 0) { - *output++ = *second++; - } - *output++ = 0; - } - *output = 0; - ZI_WORK->unk_0x0A = 0xff; - return 1; - } - parameters->letters = candidateCount; + if (parameters->firstCandidate >= length) { + Zi8ReplaceLastError(501, ZI_WORK); + return 0; + } + length = length - parameters->firstCandidate; + if (countOnly != 0) { + parameters->letters = length; ZI_WORK->unk_0x0A = 0xff; return 1; } - Zi8ReplaceLastError(501, ZI_WORK); - return 0; + if (parameters->maxCandidates < length) length = parameters->maxCandidates; + parameters->letters = length; + if ((parameters->getOptions & 0x80) == 0) { + ZI_WORK->unk_0x538 = parameters->language; + parameters->candidates[0] = 0xfff0; + output = (ziWChar*)&ZI_WORK->unk_0x338; + } + if (parameters->firstCandidate != 0) { + current = signatures.second; + length = secondLength; + } else { + current = signatures.first; + length = signatures.length; + } + if (length > ZI_WORK->unk_0x0A) length = ZI_WORK->unk_0x0A; + if ((parameters->elementCount < ZI_WORK->unk_0x140C[0] || + (parameters->getOptions & 0x7e) == 2) && length > parameters->elementCount) { + length = parameters->elementCount; + } + while (length-- != 0) *output++ = (ziU8)*current++; + *output++ = 0; + if (parameters->letters == 2) { + current = signatures.second; + length = secondLength; + if (length > ZI_WORK->unk_0x0A) length = ZI_WORK->unk_0x0A; + if ((parameters->elementCount < ZI_WORK->unk_0x140C[0] || + (parameters->getOptions & 0x7e) == 2) && length > parameters->elementCount) { + length = parameters->elementCount; + } + while (length-- != 0) *output++ = (ziU8)*current++; + *output++ = 0; + } + *output++ = 0; + ZI_WORK->unk_0x0A = 0xff; + return 1; } static ziBool Zi8ZhSignature(ziGetParam* parameters, ziBool countOnly ZI_NEED_WORK) { ziWChar* output = parameters->candidates; ziU8* current = 0; ziU16 copied; - ziU8 engine[32]; ziU8 dictionary[32]; + ziU8 engine[32]; ziU16 dataLength; - ziU32 engineLength; - ziU32 candidateCount; - ziU8 available; + ziU16 engineLength; + ziU16 length; + Zi8LogError(100, ZI_WORK); parameters->letters = 0; dataLength = Zi8GetDataSignature(dictionary, 0x20, parameters->language, ZI_WORK); engineLength = Zi8GetEngineSignature(engine, ZI_WORK); - if (!(parameters->context & 0x10)) { - candidateCount = dataLength + engineLength; + if ((parameters->context & 0x10) != 0) { + length = 0; + if (dataLength != 0) length++; + if (engineLength != 0) length++; } else { - candidateCount = dataLength != 0; - if (engineLength != 0) candidateCount++; + length = dataLength + engineLength; } - if (parameters->firstCandidate < candidateCount) { - available = candidateCount - parameters->firstCandidate; - if (!countOnly) { - if (parameters->maxCandidates < (ziU16)(candidateCount - parameters->firstCandidate)) { - available = parameters->maxCandidates; - } - parameters->letters = available; - if (!(parameters->context & 0x10)) { - copied = 0; - if (dataLength != 0) { - if (parameters->firstCandidate < dataLength) { - candidateCount = dataLength - parameters->firstCandidate; - current = dictionary + parameters->firstCandidate; - } else { - candidateCount = 0; - } - if (parameters->letters < candidateCount) candidateCount = parameters->letters; - copied = candidateCount; - while (candidateCount-- != 0) *output++ = *current++; - } - current = engine; - if (dataLength <= parameters->firstCandidate) { - dataLength += engineLength - parameters->firstCandidate; - current += engineLength - dataLength; - engineLength = dataLength; - } - if ((int)(parameters->letters - copied) < (int)engineLength) { - engineLength = parameters->letters - copied; - } - while (engineLength-- != 0) *output++ = *current++; - } else { - if (parameters->firstCandidate == 0 && dataLength != 0) { - current = dictionary; - } else { - if (parameters->firstCandidate != 0 && dataLength == 0) { - Zi8ReplaceLastError(500, ZI_WORK); - return 0; - } - current = engine; - dataLength = engineLength; - } - while (dataLength-- != 0) *output++ = *current++; - *output = 0x20; - if (parameters->letters == 2) { - current = engine; - while (++output, engineLength-- != 0) *output = *current++; - *output = 0x20; - } - } - return 1; - } - parameters->letters = available; + if (parameters->firstCandidate >= length) { + Zi8ReplaceLastError(502, ZI_WORK); + return 0; + } + length = length - parameters->firstCandidate; + if (countOnly != 0) { + parameters->letters = length; ZI_WORK->unk_0x0A = 0xff; return 1; } - Zi8ReplaceLastError(502, ZI_WORK); - return 0; + if (parameters->maxCandidates < length) length = parameters->maxCandidates; + parameters->letters = length; + if ((parameters->context & 0x10) != 0) { + if (parameters->firstCandidate != 0 || dataLength == 0) { + if (parameters->firstCandidate != 0 && dataLength == 0) { + Zi8ReplaceLastError(500, ZI_WORK); + return 0; + } + current = engine; + length = engineLength; + } else { + current = dictionary; + length = dataLength; + } + while (length-- != 0) *output++ = (ziU8)*current++; + *output++ = 0x20; + if (parameters->letters == 2) { + current = engine; + length = engineLength; + while (length-- != 0) *output++ = (ziU8)*current++; + *output++ = 0x20; + } + } else { + copied = 0; + if (dataLength != 0) { + if (parameters->firstCandidate >= dataLength) { + length = 0; + } else { + length = dataLength - parameters->firstCandidate; + current = dictionary + parameters->firstCandidate; + } + if (parameters->letters < length) length = parameters->letters; + copied = length; + while (length-- != 0) *output++ = (ziU8)*current++; + } + current = engine; + if (parameters->firstCandidate >= dataLength) { + length = dataLength + (engineLength - parameters->firstCandidate); + current += engineLength - length; + } else { + length = engineLength; + } + if (parameters->letters - copied < length) length = parameters->letters - copied; + while (length-- != 0) *output++ = (ziU8)*current++; + } + return 1; } ziU8 _Zi8GetCandidates(ziGetParam* parameters ZI_NEED_WORK) { @@ -313,7 +307,7 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option ziU16 savedCharacter; ziWChar* savedElements; ziBool restoreCandidates; - ziU8 elementCount; + int elementCount; int error; unsigned int candidateCount; ziU8 savedOptions; @@ -665,9 +659,8 @@ ziBool Zi8IsDupWChar(ziWChar character ZI_NEED_WORK) { } ziBool Zi8IsDupWordW(ziWChar* word, ziU8 length ZI_NEED_WORK) { - ziU8 slot; + unsigned int slot; ziBool duplicate = 0; - unsigned int position; int index; int character; if (word == 0 || length == 0) { @@ -681,21 +674,19 @@ ziBool Zi8IsDupWordW(ziWChar* word, ziU8 length ZI_NEED_WORK) { for (index = 0; index < ZI_WORK->unk_0x539; index++) { slot = ZI_WORK->unk_0x53A[index]; for (character = 0; character < length; character++) { - if (word[character] != ZI_WORK->unk_0x57A[slot * 21 + character]) break; + if (word[character] != ((ziWChar (*)[21])ZI_WORK->unk_0x57A)[slot][character]) break; } - if (character >= length && ZI_WORK->unk_0x57A[slot * 21 + character] == 0) { + if (character >= length && ((ziWChar (*)[21])ZI_WORK->unk_0x57A)[slot][character] == 0) { duplicate = 1; break; } } if (!duplicate) { if (ZI_WORK->unk_0x539 < 64) { - position = ZI_WORK->unk_0x539; - ZI_WORK->unk_0x53A[ZI_WORK->unk_0x539] = ZI_WORK->unk_0x539; + slot = ZI_WORK->unk_0x53A[ZI_WORK->unk_0x539] = ZI_WORK->unk_0x539; ZI_WORK->unk_0x539++; } else { slot = ZI_WORK->unk_0x53A[0]; - position = slot; for (index = 1; index < ZI_WORK->unk_0x539; index++) { ZI_WORK->unk_0x53A[index - 1] = ZI_WORK->unk_0x53A[index]; } @@ -703,16 +694,15 @@ ziBool Zi8IsDupWordW(ziWChar* word, ziU8 length ZI_NEED_WORK) { } } else { slot = ZI_WORK->unk_0x53A[index]; - position = slot; for (; index < ZI_WORK->unk_0x539 - 1; index++) { ZI_WORK->unk_0x53A[index] = ZI_WORK->unk_0x53A[index + 1]; } ZI_WORK->unk_0x53A[index] = slot; } - for (index = 0; index < length; index++) { - ZI_WORK->unk_0x57A[position * 21 + index] = word[index]; + for (character = 0; character < length; character++) { + ((ziWChar (*)[21])ZI_WORK->unk_0x57A)[slot][character] = word[character]; } - ZI_WORK->unk_0x57A[position * 21 + index] = 0; + ((ziWChar (*)[21])ZI_WORK->unk_0x57A)[slot][character] = 0; Zi8LogError(100, ZI_WORK); return duplicate; } diff --git a/libs/RVLMiddleware/eZiText/src/clib/zi8match.c b/libs/RVLMiddleware/eZiText/src/clib/zi8match.c index dea41717..99ac5809 100644 --- a/libs/RVLMiddleware/eZiText/src/clib/zi8match.c +++ b/libs/RVLMiddleware/eZiText/src/clib/zi8match.c @@ -290,138 +290,139 @@ extern ziU16 Zi8MatchAltSound(ziPtr soundTable, ziU16 soundCode, ziPtr pCodeTabl ziU16 Zi8GetPCode(ziU8* table, ziU8* node); ziBool Zi8MatchPhonetic(ziPtr pCodeTable, ziPtr dictionary, ziPtr soundTable, ziU16 soundCode, ziU32 tableAddress, ziU8* node, ziU16* masks, ziU16* values, ziU16* count, ziU8** resultNode, ziU8** stringOffset, ziS8 partialMode, ziU8 strictMode, ziU8 numParts, ziU16 partMask, ziU16 partValue, ziU8 flag, ziU8 altMode, ziU16 initialCode, ziU16* resultCode, ziU8 lastMode ZI_NEED_WORK) { - ziBool hasString; - ziU32 matchedParts; - ziU32 altModeActive; - ziU8 partCode; - ziU8 partCount; - ziU8 partIndex; - ziU16 soundIndex; - ziU16 remaining; - ziU16 code; - ziU16 dictionaryIndex; - ziU8 nextCode; + struct { + ziBool hasString; + ziU8 partIndex; + ziU8 partCount; + ziU8 nextCode; + ziU8 matchedParts; + ziU16 dictionaryIndex; + ziU16 soundIndex; + ziU16 remaining; + ziU16 code; + } traversal; ziU8* sound; - ziU8* nextPart; if (*stringOffset != 0) { - hasString = 1; + traversal.hasString = 1; } else { - hasString = 0; + traversal.hasString = 0; } - if (*count == 0) { - remaining = 1; + if (*count != 0) { + traversal.remaining = *count; } else { - remaining = *count; + traversal.remaining = 1; } - matchedParts = 0; - altModeActive = altMode; + traversal.matchedParts = 0; if ((lastMode != 0) && (numParts > 1)) { - altModeActive = 1; + altMode = 1; } - while (remaining-- != 0) { - if ((node[0] & flag) != 0) { - code = Zi8GetPCode((ziU8*)pCodeTable, node); - if ((*values != (code & *masks)) && (altModeActive == 0) && ((node[0] & 0x80) != 0)) { - if (*count != 0) { - soundIndex = (initialCode - remaining) - 1; - } else { - soundIndex = initialCode; - } - code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, soundIndex, *masks, *values, flag, ZI_WORK); - } - if ((*values == (code & *masks)) && (partValue != (code & partMask))) { - matchedParts = 1; - sound = (ziU8*)((tableAddress + ((node[9] & 0xF) * 0x10000)) + node[0xB] + node[0xA] * 0x100); - if (ZI_WORK->unk_0x16 != 0) { - switch (sound[0] & 7) { - case 2: - sound += 2; - break; - case 3: - case 4: - sound += 3; - break; - case 5: - sound += 4; - break; - default: - sound++; - break; - } - } - if ((sound[0] & 0x80) != 0) { - sound += ((sound[0] & 0x7F) >> 4) + 1; - } else if (numParts > 1) { - goto next_node; - } - if (((ziU8)matchedParts == numParts) || (numParts == 0)) { - *resultNode = node; - *resultCode = ((ziU16)node[6] << 8) + node[7]; - *count = remaining; - return 1; - } - do { - nextCode = *sound++; - partCount = nextCode & 0xF; - if ((nextCode & flag) == 0) { - for (; partCount != 0; partCount--) { - for (sound++; (*sound & 0x80) == 0; sound += 2) { - } - sound++; - } - } - for (; partCount != 0; partCount--) { - partIndex = 1; - if (hasString && (*stringOffset < sound)) { - hasString = 0; - } - nextPart = sound; - if (!hasString) { - *stringOffset = sound; - } - do { - partCode = nextPart[1]; - dictionaryIndex = ((ziU16)partCode << 8) | nextPart[0]; - sound = nextPart + 2; - if (hasString) { - goto phonetic_skip; - } - code = Zi8GetPCode((ziU8*)pCodeTable, (ziU8*)dictionary + (dictionaryIndex & 0x7FFF) * 0xC); - if (((code & masks[partIndex]) != values[partIndex]) && (altModeActive == 0) && (((ziU8*)dictionary)[(dictionaryIndex & 0x7FFF) * 0xC] & 0x80) != 0) { - code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, dictionaryIndex & 0x7FFF, masks[partIndex], values[partIndex], flag, ZI_WORK); - } - if ((code & masks[partIndex]) != values[partIndex]) { - goto phonetic_skip; - } - partIndex++; - if (partIndex == numParts) { - if ((partialMode != 0) && ((strictMode == 0 && (partCode & 0x80) != 0) || (strictMode != 0 && (partCode & 0x80) == 0))) { - goto phonetic_skip; - } - *resultNode = node; - code = ((ziU16)node[6] << 8) + node[7]; - *resultCode = code; - *count = remaining; - return 1; - } - nextPart = sound; - } while ((partCode & 0x80) == 0); - continue; -phonetic_skip: - if ((partCode & 0x80) == 0) { - nextPart += 3; - while ((*nextPart & 0x80) == 0) { - nextPart += 2; - } - sound = nextPart + 1; - } - } - } while ((nextCode & 0x80) == 0); - } - } + while (traversal.remaining-- != 0) { + if ((node[0] & flag) != 0) goto decode_node; next_node: node += 0xC; + continue; +decode_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; + } else { + traversal.soundIndex = initialCode; + } + traversal.code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, traversal.soundIndex, *masks, *values, flag, ZI_WORK); + } + goto check_code; +match_code: + if (partValue == (traversal.code & partMask)) goto next_node; + traversal.matchedParts = 1; + sound = (ziU8*)(((node[9] & 0xF) * 0x10000 + node[0xB]) + (tableAddress + node[0xA] * 0x100)); + if (ZI_WORK->unk_0x16 != 0) { + switch (sound[0] & 7) { + case 2: + sound += 2; + break; + case 3: + case 4: + sound += 3; + break; + case 5: + sound += 4; + break; + default: + sound++; + break; + } + } + if ((sound[0] & 0x80) != 0) { + sound += ((sound[0] & 0x7F) >> 4) + 1; + } else if (numParts > 1) { + goto next_node; + } + if (((ziU8)traversal.matchedParts == numParts) || (numParts == 0)) { + *resultNode = node; + *resultCode = ((ziU16)node[6] << 8) + node[7]; + *count = traversal.remaining; + return 1; + } + do { + traversal.nextCode = *sound++; + traversal.partCount = traversal.nextCode & 0xF; + if ((traversal.nextCode & flag) == 0) { + for (; traversal.partCount != 0; traversal.partCount--) { + for (sound++; (*sound & 0x80) == 0; sound += 2) { + } + sound++; + } + } + for (; traversal.partCount != 0; traversal.partCount--) { + traversal.partIndex = 1; + if (traversal.hasString && (*stringOffset < sound)) { + traversal.hasString = 0; + } + if (!traversal.hasString) { + *stringOffset = sound; + } + do { + traversal.dictionaryIndex = sound[0] | ((ziU16)sound[1] << 8); + sound += 2; + if (traversal.hasString) { + goto phonetic_skip; + } + traversal.code = Zi8GetPCode((ziU8*)pCodeTable, (ziU8*)dictionary + (traversal.dictionaryIndex & 0x7FFF) * 0xC); + if (((traversal.code & masks[traversal.partIndex]) != values[traversal.partIndex]) && (altMode == 0) && (((ziU8*)dictionary)[(traversal.dictionaryIndex & 0x7FFF) * 0xC] & 0x80) != 0) { + traversal.code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, traversal.dictionaryIndex & 0x7FFF, masks[traversal.partIndex], values[traversal.partIndex], flag, ZI_WORK); + } + if ((traversal.code & masks[traversal.partIndex]) != values[traversal.partIndex]) { + goto phonetic_skip; + } + traversal.partIndex++; + if (traversal.partIndex == numParts) { + if ((partialMode != 0) && ((strictMode == 0 && (traversal.dictionaryIndex & 0x8000) != 0) || (strictMode != 0 && (traversal.dictionaryIndex & 0x8000) == 0))) { + goto phonetic_skip; + } + *resultNode = node; + *resultCode = ((ziU16)node[6] << 8) + node[7]; + *count = traversal.remaining; + return 1; + } + } while ((traversal.dictionaryIndex & 0x8000) == 0); + continue; +phonetic_skip: + if ((traversal.dictionaryIndex & 0x8000) == 0) { + sound++; + while ((*sound & 0x80) == 0) { + sound += 2; + } + sound++; + } + } + } while ((traversal.nextCode & 0x80) == 0); + + goto next_node; +check_code: + if (*values == (traversal.code & *masks)) goto match_code; + goto next_node; } return 0; } @@ -436,7 +437,6 @@ ziU8 Zi8GetPyPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final, z ziBool partial; ziU8 result; ziU8 outputIndex; - ziU8 partCount; ziU16 value; ziU8 index; ziWChar converted[256]; @@ -445,13 +445,15 @@ ziU8 Zi8GetPyPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final, z current = converted; result = 0; + partial = 0; *resultCount = 0; if (count == 0) { Zi8LogError(0x135, ZI_WORK); return 0; } - convertedCount = 0; - for (index = 0; index < count; index++) { + index = 0; + convertedCount = index; + for (; index < count; index++) { if (((text[index] >= 0xF341) && (text[index] <= 0xF35A)) || ((text[index] >= 0x41) && (text[index] <= 0x5A))) { if ((convertedCount != 0) && (current[convertedCount - 1] != 0xF360) && (current[convertedCount - 1] != 0x27)) { current[convertedCount] = 0x27; diff --git a/libs/RVLMiddleware/eZiText/src/clib/zikorean.c b/libs/RVLMiddleware/eZiText/src/clib/zikorean.c index 889b4f25..574199ad 100644 --- a/libs/RVLMiddleware/eZiText/src/clib/zikorean.c +++ b/libs/RVLMiddleware/eZiText/src/clib/zikorean.c @@ -31,7 +31,6 @@ ziU8 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument, ziU8 characterIndex; ziU8 matched; ziU8 elementIndex; - ziU8 reserved; ziU16 index; ziU16 currentCandidate; ziU16 inputIndex; @@ -53,9 +52,7 @@ ziU8 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument, result = 0; state.characterIndex = 0xFF; state.currentCandidate = params->firstCandidate; - params->unk_0x20 = 0; - params->count = 0; - params->letters = 0; + params->unk_0x20 = params->count = params->letters = 0; if ((argument != 0) && (*argument != 0)) { Zi8LogError(0x7D0, workData); return 0; @@ -87,24 +84,23 @@ ziU8 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument, for (; state.table2[state.matched * 3] != 0; state.matched++) { if (currentCharacter == state.table2[state.matched * 3]) break; } - if (state.table2[(state.matched * 3)] == 0) { + if (state.table2[state.matched * 3] != 0) { + buffer[state.elementIndex] = + ((ziU16)state.table2[state.matched * 3 + 1] << 8) | + state.table2[state.matched * 3 + 2]; + } else { Zi8LogError(0x161, workData); return 0; } - buffer[state.elementIndex] = - (state.table2[(state.matched * 3) + 1] << 8) | - state.table2[(state.matched * 3) + 2]; } } + result = 0; for (currentCharacter = 0; currentCharacter < state.elementIndex; currentCharacter++) { - state.inputIndex = 0; - if (Zi8_814813FC(buffer[currentCharacter], (ziU8*)&state.characterIndex, - (ziU16*)&state.inputIndex, workData) == 0) { - state.matched = 0; - } else { - state.matched = Zi8_81481E6C((ziU16*)&state.nextIndex, - &buffer[currentCharacter + 1], + if (Zi8_814813FC(buffer[currentCharacter], &state.characterIndex, + &state.inputIndex, workData) != 0) { + state.matched = Zi8_81481E6C(&state.nextIndex, + buffer + currentCharacter + 1, state.characterIndex, (state.elementIndex - currentCharacter) - 1, workData); @@ -171,6 +167,8 @@ ziU8 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument, break; } } + } else { + state.matched = 0; } if (state.matched == 0) { if (state.currentCandidate == 0) { diff --git a/libs/RVLMiddleware/eZiText/src/clib/zkokeyp.c b/libs/RVLMiddleware/eZiText/src/clib/zkokeyp.c index 620ed669..f9236a96 100644 --- a/libs/RVLMiddleware/eZiText/src/clib/zkokeyp.c +++ b/libs/RVLMiddleware/eZiText/src/clib/zkokeyp.c @@ -3,6 +3,14 @@ extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK); extern ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK); +typedef struct { + ziU8 keyBytes[5]; + ziU8 childHigh; + ziU8 childLow; + ziU8 characterHigh; + ziU8 characterLow; +} ZiKoreanKeyEntry; + ziU32 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) { ziU32 value; ziU16 count; @@ -12,7 +20,7 @@ ziU32 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) { for (i = 0; (ziU16)i < count; i++) { value = (ziU16)(((ziU16)table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 7] << 8) | table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 8]); - if (key == value) { + if (value == key) { Zi8LogError(0x64, ZI_WORK); return i; } @@ -112,21 +120,24 @@ ziBool Zi8_814833F0(const ziGetParam* param, ziU16 key ZI_NEED_WORK) { ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count, ziU8* inserted ZI_NEED_WORK) { ziBool matches; - ziS32 entry; - ziS32 tableA; - ziS32 tableB; + ZiKoreanKeyEntry* entry; + ziU8* tableA; + ziU8* tableB; ziU16 tableCount; ziU8 matched; ziU32 j; ziS32 i; + ziS32 candidate; ziU8 candidateIndex; union { - ziU32 words[13]; - ziU8 bytes[52]; + ziU32 firstWord; + ziU8 bytes[5]; } local; + j = 0; + candidateIndex = 0; matched = 0; - local.words[0] = 0; + local.firstWord = 0; local.bytes[4] = 0; Zi8LogError(0x64, ZI_WORK); if (param->elementCount == 0) { @@ -141,15 +152,15 @@ ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count, Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK); } for (i = 0; i < ((ziS32)*count - (ziS32)*remaining); i++) { - param->candidates[i] = param->candidates[(ziU32)*remaining + i]; + param->candidates[i] = param->candidates[*remaining + i]; } *count = *count - (ziU8)*remaining; *remaining = 0; } return 1; } else if (param->elementCount <= 9) { - tableA = Zi8GetTableAddress(param->language, 9, ZI_WORK); - tableB = Zi8GetTableAddress(param->language, 10, ZI_WORK); + tableA = (ziU8*)Zi8GetTableAddress(param->language, 9, ZI_WORK); + tableB = (ziU8*)Zi8GetTableAddress(param->language, 10, ZI_WORK); if (tableA == 0) { Zi8ReplaceLastError(0x76C, ZI_WORK); return 0; @@ -162,24 +173,24 @@ ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count, i = 0; while (i < tableCount && matched < *count) { matches = ZI8_TRUE; - entry = (i << 3) + tableA + i; + entry = (ZiKoreanKeyEntry*)&tableA[(i << 3) + i]; j = 0; if (param->elementCount > 1) { - for (j = 0; (j & 0xFF) < (ziU32)(param->elementCount >> 1); j++) { - if (local.bytes[j & 0xFF] != *((ziU8*)entry + (j & 0xFF))) { + for (j = 0; (j & 0xFF) < (int)param->elementCount / 2; j++) { + if (local.bytes[j & 0xFF] != entry->keyBytes[j & 0xFF]) { matches = ZI8_FALSE; break; } } } - if (matches && (param->elementCount & 1) != 0 && - ((local.bytes[j & 0xFF] & 0xF0) != (*((ziU8*)entry + (j & 0xFF)) & 0xF0))) { + if (matches && (param->elementCount % 2) != 0 && + ((local.bytes[j & 0xFF] & 0xF0) != (entry->keyBytes[j & 0xFF] & 0xF0))) { matches = ZI8_FALSE; } if (matches) { for (candidateIndex = 0; candidateIndex < *count; candidateIndex++) { if (param->candidates[candidateIndex] == - (ziU16)((*((ziU8*)entry + 7) << 8) | *((ziU8*)entry + 8))) { + (((ziU16)((ZiKoreanKeyEntry*)tableA)[i].characterHigh << 8) | (ziU16)((ZiKoreanKeyEntry*)tableA)[i].characterLow)) { matched++; param->candidates[candidateIndex] = param->candidates[candidateIndex] & 0x7FFF; @@ -189,32 +200,32 @@ ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count, } i++; } - if ((ziU16)matched >= *remaining) { + if (matched >= *remaining) { matched = *count; *count = 0; - for (i = 0; i < matched; i++) { - if ((param->candidates[i] & 0x8000) == 0) { - param->candidates[i] = param->candidates[i] | 0x8000; - if (*remaining == 0) { - if (*count != i) { - param->candidates[*count] = param->candidates[i]; + for (candidate = 0; candidate < matched; candidate++) { + if ((param->candidates[candidate] & 0x8000) == 0) { + param->candidates[candidate] = param->candidates[candidate] | 0x8000; + if (*remaining != 0) { + *remaining = *remaining - 1; + Zi8_81483308(param, param->candidates[candidate], inserted, ZI_WORK); + } else { + if (*count != candidate) { + param->candidates[*count] = param->candidates[candidate]; } *count = *count + 1; - } else { - *remaining = *remaining - 1; - Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK); } } } *remaining = 0; } else { - for (i = 0; i < *count; i++) { - if ((param->candidates[i] & 0x8000) == 0) { - param->candidates[i] = param->candidates[i] | 0x8000; - Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK); + for (candidate = 0; candidate < *count; candidate++) { + if ((param->candidates[candidate] & 0x8000) == 0) { + param->candidates[candidate] = param->candidates[candidate] | 0x8000; + Zi8_81483308(param, param->candidates[candidate], inserted, ZI_WORK); } } - *remaining = *remaining - (ziU16)matched; + *remaining = *remaining - (ziU8)matched; *count = 0; } } @@ -226,309 +237,314 @@ ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count, return 0; } -ziU32 Zi8GetKOcandidates(ziGetParam* param, ziU8* options ZI_NEED_WORK) { - ziBool bVar1; - ziU8 bVar2; - ziS32 iVar4; - ziU32 uVar6; - ziU8* pbVar7; - union { - ziU32 words[10]; - ziU8 bytes[40]; - } local_28; - ziU8 local_57; - ziU8 local_56; - ziU8 local_55; - ziU8 local_54; - ziU8 local_53; - ziS8 local_52; - ziU16 local_50; - ziU16 local_4E; - ziU16 local_4C; - ziU16 local_4A; - ziU16 local_48; - ziS32 local_44; - ziS32 local_2C; - ziS32 local_30; - ziU32 local_34; - ziU32 local_38; - ziU32 local_3C; - ziU32 local_40; +typedef struct { + ziU8 countOnly; + ziU8 maxWordLength; + ziU8 lookupMode; + ziU8 suffixOnly; + ziU8 controls[8]; + ziU32 maxCount; + ziU16 capacity; + ziU8 minWordLength; + ziU8 flags; + ziU16 candidateCapacity; + ziU8 checkOnly; + ziU8 reserved; +} ZiKoreanCandidateOptions; - local_4E = 0xFFFF; - local_34 = 0; - local_28.words[0] = 0; - local_28.bytes[4] = 0; - local_52 = 0; - local_53 = 0; - local_54 = 0; - local_55 = 0; - local_50 = param->firstCandidate; - local_3C = 0; - local_40 = 0; - local_57 = 0; +ziU32 Zi8GetKOcandidates(ziGetParam* param, ZiKoreanCandidateOptions* options ZI_NEED_WORK) { + ziBool matches; + ziU8 letterCount; + ziU8* keyTable; + ziU32 result; + ziU8* wordNode; + union { + ziU32 firstWord; + ziU8 bytes[5]; + } packedKeys; + ziU8 inserted; + ziU8 matchPass; + ziU8 keyByte; + ziU8 candidateCount; + ziU8 wordIndex; + ziS8 remainingLetters; + ziU16 remainingCandidates; + ziU16 previousIndex; + ziU16 character; + ziU16 tableCount; + ziU16 keyIndex; + ZiKoreanKeyEntry* entry; + ziU8* wordTable; + ziS32 tableIndex; + ziU32 resultCount; + ziU32 wordOffset; + ziU32 prefixCount; + ziU32 candidateIndex; + + previousIndex = 0xFFFF; + resultCount = 0; + packedKeys.firstWord = 0; + packedKeys.bytes[4] = 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); - iVar4 = Zi8GetTableAddress(ZI8_LANG_KO, 9, ZI_WORK); - local_2C = Zi8GetTableAddress(ZI8_LANG_KO, 10, ZI_WORK); - if (iVar4 == 0) { + 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); - uVar6 = 0; + return 0; } else { - if (local_2C == 0) { + if (wordTable == 0) { Zi8ReplaceLastError(0x776, ZI_WORK); - uVar6 = 0; - goto LAB_000114C4; + return 0; } - if (*options == 0) { + if (options->countOnly == 0) { param->letters = 0; param->count = 0; param->candidates[0] = 0; } Zi8LogError(100, ZI_WORK); if (param->wordCharCount != 0) { - local_48 = Zi8_8148302C(param->currentWord[0], (ziU8*)iVar4, ZI_WORK); - if ((local_48 != 0xFFFF) && - ((((ziU8*)iVar4)[((ziU32)local_48 * 9) + 4] & 8) != 0)) { - local_38 = (ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 6] | - ((ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 4] & 3) << 16 | - (ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 5] << 8; - local_52 = param->wordCharCount - 1; - local_53 = 1; - pbVar7 = (ziU8*)(local_2C + local_38); -LAB_00010D44: - if (local_52 != 0) { - local_48 = Zi8_8148302C(param->currentWord[local_53], (ziU8*)iVar4, ZI_WORK); - if (local_48 == (ziU16)((*pbVar7 & 0x1F) << 8 | pbVar7[1])) { - local_52 = local_52 - 1; - local_53 = local_53 + 1; - if ((*pbVar7 & 0x40) == 0) { - pbVar7 = pbVar7 + 2; - goto LAB_00010D44; + keyIndex = Zi8_8148302C(param->currentWord[0], (ziU8*)keyTable, ZI_WORK); + if ((keyIndex != 0xFFFF) && + ((((ZiKoreanKeyEntry*)&keyTable[(keyIndex << 3) + keyIndex])->keyBytes[4] & 8) != 0)) { + wordOffset = (ziU32)((ZiKoreanKeyEntry*)&keyTable[(keyIndex << 3) + keyIndex])->childLow | + ((ziU32)((ZiKoreanKeyEntry*)&keyTable[(keyIndex << 3) + keyIndex])->keyBytes[4] & 3) << 16 | + (ziU32)((ZiKoreanKeyEntry*)&keyTable[(keyIndex << 3) + keyIndex])->childHigh << 8; + remainingLetters = param->wordCharCount - 1; + wordIndex = 1; + wordNode = wordTable + wordOffset; +match_word: + if (remainingLetters != 0) { + keyIndex = Zi8_8148302C(param->currentWord[wordIndex], (ziU8*)keyTable, ZI_WORK); + if (keyIndex == (ziU16)((*wordNode & 0x1F) << 8 | wordNode[1])) { + remainingLetters = remainingLetters - 1; + wordIndex = wordIndex + 1; + if ((*wordNode & 0x40) == 0) { + wordNode = wordNode + 2; + goto match_word; } - local_52 = param->wordCharCount - 1; - local_53 = 1; + remainingLetters = param->wordCharCount - 1; + wordIndex = 1; } else { - local_53 = 1; - local_52 = param->wordCharCount - 1; + wordIndex = 1; + remainingLetters = param->wordCharCount - 1; } } - if (local_52 == 0) { - local_48 = (*pbVar7 & 0x1F) << 8 | pbVar7[1]; - local_4C = (ziU16)(((ziU8*)((ziU32)local_48 * 9 + (ziU32)local_48 + (ziU32)iVar4))[7] << 8 | - ((ziU8*)((ziU32)local_48 * 9 + (ziU32)local_48 + (ziU32)iVar4))[8]); + if (remainingLetters == 0) { + keyIndex = (*wordNode & 0x1F) << 8 | wordNode[1]; + character = (ziU16)(((ZiKoreanKeyEntry*)&keyTable[(keyIndex << 3) + keyIndex])->characterHigh << 8 | + ((ZiKoreanKeyEntry*)&keyTable[(keyIndex << 3) + keyIndex])->characterLow); if (param->wordCharCount == 1) { - if (local_48 == local_4E) { - for (; (*pbVar7 & 0x40) == 0; pbVar7 = pbVar7 + 2) { + if (keyIndex == previousIndex) { + for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) { } - local_52 = param->wordCharCount; - goto LAB_00011114; + remainingLetters = param->wordCharCount; + goto next_word; } - local_4E = local_48; + previousIndex = keyIndex; if (param->elementCount == 0) { - if (local_50 == 0) { - if (*options != 0) { - local_3C = local_3C + 1; - if ((ziS32)local_3C < *(ziS32*)(options + 0xC)) { - goto LAB_000110E8; + if (remainingCandidates == 0) { + if (options->countOnly != 0) { + prefixCount = prefixCount + 1; + if ((ziS32)prefixCount < (ziS32)options->maxCount) { + goto skip_word; } - uVar6 = *(ziU32*)(options + 0xC); - goto LAB_000114C4; + return options->maxCount; } - param->candidates[local_54] = local_4C; - local_54 = local_54 + 1; + param->candidates[candidateCount] = character; + candidateCount = candidateCount + 1; param->count = param->count + 1; - bVar2 = param->letters + 1; - param->letters = bVar2; - if (param->maxCandidates <= bVar2) { - uVar6 = param->letters; - goto LAB_000114C4; + letterCount = param->letters + 1; + param->letters = letterCount; + if (param->maxCandidates <= letterCount) { + return param->letters; } } else { - local_50 = local_50 + -1; + remainingCandidates = remainingCandidates + -1; } } else { - param->candidates[local_54] = local_4C; - local_54 = local_54 + 1; + param->candidates[candidateCount] = character; + candidateCount = candidateCount + 1; param->count = param->count + 1; - bVar2 = param->letters + 1; - param->letters = bVar2; - if (param->maxCandidates <= bVar2) { - Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK); - param->count = local_54; - param->letters = local_54; - if (param->maxCandidates <= local_54) { - if (*options == 0) { - uVar6 = local_54; - goto LAB_000114C4; + letterCount = param->letters + 1; + param->letters = letterCount; + if (param->maxCandidates <= letterCount) { + Zi8_814834AC(param, &remainingCandidates, &candidateCount, &inserted, ZI_WORK); + param->count = candidateCount; + param->letters = candidateCount; + if (param->maxCandidates <= candidateCount) { + if (options->countOnly == 0) { + return candidateCount; } - local_3C = local_3C + local_54; - if (*(ziS32*)(options + 0xC) <= (ziS32)local_3C) { - uVar6 = *(ziU32*)(options + 0xC); - goto LAB_000114C4; + prefixCount = prefixCount + candidateCount; + if ((ziS32)options->maxCount <= (ziS32)prefixCount) { + return options->maxCount; } param->count = 0; param->letters = 0; - local_54 = 0; + candidateCount = 0; } } } } else { - for (local_40 = 0; - (local_40 < local_54 && - (local_4C != param->candidates[local_40])); - local_40 = local_40 + 1) { + for (candidateIndex = 0; + (candidateIndex < candidateCount && + (character != param->candidates[candidateIndex])); + candidateIndex = candidateIndex + 1) { } - if ((local_40 == local_54) && - (Zi8_814833F0(param, local_4C, ZI_WORK) == 0)) { - param->candidates[local_54] = local_4C; - local_54 = local_54 + 1; + if ((candidateIndex == candidateCount) && + (Zi8_814833F0(param, character, ZI_WORK) == 0)) { + param->candidates[candidateCount] = character; + candidateCount = candidateCount + 1; param->count = param->count + 1; - bVar2 = param->letters + 1; - param->letters = bVar2; - if (bVar2 < param->maxCandidates) { - goto LAB_000110E8; + letterCount = param->letters + 1; + param->letters = letterCount; + if (letterCount < param->maxCandidates) { + goto skip_word; } - Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK); - param->count = local_54; - param->letters = local_54; - if (param->maxCandidates <= local_54) { - if (*options == 0) { - uVar6 = local_54; - goto LAB_000114C4; + Zi8_814834AC(param, &remainingCandidates, &candidateCount, &inserted, ZI_WORK); + param->count = candidateCount; + param->letters = candidateCount; + if (param->maxCandidates <= candidateCount) { + if (options->countOnly == 0) { + return candidateCount; } - local_3C = local_3C + local_54; - if (*(ziS32*)(options + 0xC) <= (ziS32)local_3C) { - uVar6 = *(ziU32*)(options + 0xC); - goto LAB_000114C4; + prefixCount = prefixCount + candidateCount; + if ((ziS32)options->maxCount <= (ziS32)prefixCount) { + return options->maxCount; } param->count = 0; param->letters = 0; - local_54 = 0; + candidateCount = 0; } } } } -LAB_000110E8: - for (; (*pbVar7 & 0x40) == 0; pbVar7 = pbVar7 + 2) { +skip_word: + for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) { } - local_52 = param->wordCharCount; -LAB_00011114: - local_52 = local_52 + -1; - local_53 = 1; - pbVar7 = pbVar7 + 2; - if ((*pbVar7 & 0x80) != 0) { - goto LAB_00011124; + remainingLetters = param->wordCharCount; +next_word: + remainingLetters = remainingLetters + -1; + wordIndex = 1; + wordNode = wordNode + 2; + if ((*wordNode & 0x80) != 0) { + goto search_table; } - goto LAB_00010D44; + goto match_word; } } -LAB_00011124: - local_34 = local_3C; - if (local_54 != 0) { - Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK); - uVar6 = local_34; - if ((*options != 0) && - (local_3C = local_3C + local_54, uVar6 = local_3C, - *(ziS32*)(options + 0xC) <= (ziS32)local_3C)) { - uVar6 = *(ziU32*)(options + 0xC); - goto LAB_000114C4; +search_table: + resultCount = prefixCount; + if (candidateCount != 0) { + Zi8_814834AC(param, &remainingCandidates, &candidateCount, &inserted, ZI_WORK); + result = resultCount; + if ((options->countOnly != 0) && + (prefixCount = prefixCount + candidateCount, result = prefixCount, + (ziS32)options->maxCount <= (ziS32)prefixCount)) { + return options->maxCount; } - local_34 = uVar6; - param->count = local_54; - param->letters = local_54; + resultCount = result; + param->count = candidateCount; + param->letters = candidateCount; } if (param->elementCount < 10) { - if ((param->elementCount == 0) || (*options != 0)) { - local_56 = 1; + if ((param->elementCount == 0) || (options->countOnly != 0)) { + matchPass = 1; } else { - local_56 = 0; + matchPass = 0; } - local_4A = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK); - Zi8_81483118(param, local_28.bytes); + tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK); + Zi8_81483118(param, packedKeys.bytes); do { - for (local_30 = 0; local_30 < (ziS32)(ziU32)local_4A; local_30 = local_30 + 1) { - bVar1 = ZI8_TRUE; - local_44 = iVar4 + local_30 * 9; - local_55 = 0; + for (tableIndex = 0; tableIndex < (ziS32)(ziU32)tableCount; tableIndex = tableIndex + 1) { + matches = ZI8_TRUE; + entry = (ZiKoreanKeyEntry*)&keyTable[(tableIndex << 3) + tableIndex]; + keyByte = 0; if (1 < param->elementCount) { - for (local_55 = 0; - (ziU32)local_55 < (ziU32)((ziS32)(ziU32)param->elementCount >> 1); - local_55 = local_55 + 1) { - if (local_28.bytes[local_55] != *(ziU8*)(local_44 + local_55)) { - bVar1 = ZI8_FALSE; + for (keyByte = 0; + (ziU32)keyByte < (int)param->elementCount / 2; + keyByte = keyByte + 1) { + if (packedKeys.bytes[keyByte] != entry->keyBytes[keyByte]) { + matches = ZI8_FALSE; break; } } } - if ((bVar1 && ((param->elementCount & 1) != 0)) && - ((local_28.bytes[local_55] & 0xF0) != - (*(ziU8*)(local_44 + local_55) & 0xF0))) { - bVar1 = ZI8_FALSE; + if ((matches && ((param->elementCount % 2) != 0)) && + ((packedKeys.bytes[keyByte] & 0xF0) != + (entry->keyBytes[keyByte] & 0xF0))) { + matches = ZI8_FALSE; } - if (bVar1) { - bVar2 = local_56; - if ((param->elementCount & 1) == 0) { - if ((*(ziU8*)(local_44 + local_55) & 0xF0) == 0) { - if (local_56 == 0) { - goto LAB_000113B0; + if (matches) { + letterCount = matchPass; + if ((param->elementCount % 2) == 0) { + if ((entry->keyBytes[keyByte] & 0xF0) == 0) { + if (matchPass == 0) { + goto add_candidate; } - bVar2 = *options; + letterCount = options->countOnly; } - if (bVar2 == 0) { - goto LAB_00011478; + if (letterCount == 0) { + goto next_entry; } } else { - if ((*(ziU8*)(local_44 + local_55) & 0xF) != 0) { - goto LAB_000113AC; + if ((entry->keyBytes[keyByte] & 0xF) != 0) { + goto check_pass; } - if (local_56 != 0) { - bVar2 = *options; - goto LAB_000113AC; + if (matchPass != 0) { + letterCount = options->countOnly; + goto check_pass; } } -LAB_000113AC: - if (bVar2 == 0) { - goto LAB_00011478; +check_pass: + if (letterCount == 0) { + goto next_entry; } -LAB_000113B0: - if (local_50 == 0) { - if (*options == 0) { - param->candidates[local_54] = - (ziU16)((*(ziU8*)(local_30 * 9 + iVar4 + 7) << 8) | - *(ziU8*)(local_30 * 9 + iVar4 + 8)); - local_54 = local_54 + 1; - bVar2 = param->letters + 1; - param->letters = bVar2; - if (param->maxCandidates <= bVar2) { - uVar6 = param->letters; - goto LAB_000114C4; +add_candidate: + if (remainingCandidates == 0) { + if (options->countOnly == 0) { + param->candidates[candidateCount] = + (ziU16)((((ZiKoreanKeyEntry*)&keyTable[(tableIndex << 3) + tableIndex])->characterHigh << 8) | + ((ZiKoreanKeyEntry*)&keyTable[(tableIndex << 3) + tableIndex])->characterLow); + candidateCount = candidateCount + 1; + letterCount = param->letters + 1; + param->letters = letterCount; + if (param->maxCandidates <= letterCount) { + return param->letters; } } else { - local_34 = local_34 + 1; - if (*(ziS32*)(options + 0xC) <= (ziS32)local_34) { - uVar6 = *(ziU32*)(options + 0xC); - goto LAB_000114C4; + resultCount = resultCount + 1; + if ((ziS32)options->maxCount <= (ziS32)resultCount) { + return options->maxCount; } } } else { - local_50 = local_50 + -1; + remainingCandidates = remainingCandidates + -1; } } -LAB_00011478: +next_entry: ; } - local_56 = local_56 + 1; - } while (local_56 < 2); - uVar6 = local_34; - if (*options == 0) { - uVar6 = param->letters; + matchPass = matchPass + 1; + } while (matchPass < 2); + result = resultCount; + if (options->countOnly == 0) { + result = param->letters; } } else { param->letters = 0; - uVar6 = 0; + return 0; } } -LAB_000114C4: - return uVar6; +finish_candidates: + return result; } diff --git a/libs/RVLMiddleware/eZiText/src/clib/zprepare.c b/libs/RVLMiddleware/eZiText/src/clib/zprepare.c index f3b34352..cf3b112a 100644 --- a/libs/RVLMiddleware/eZiText/src/clib/zprepare.c +++ b/libs/RVLMiddleware/eZiText/src/clib/zprepare.c @@ -3,7 +3,7 @@ void Zi8Memset(ziPtr, ziU32, ziU32); void Zi8Memcpy(ziPtr, ziPtr, ziU32); ziBool Zi8IsComponent(ziWChar ZI_NEED_WORK); -ziPtr Zi8GetTableAddress(ziU8, ziU8 ZI_NEED_WORK); +ziU32 Zi8GetTableAddress(ziU8, ziU8 ZI_NEED_WORK); ziU16 Zi8GetTableCount(ziU8, ziU8 ZI_NEED_WORK); ziU8 Zi8GetPyPhonetic(ziWChar*, ziU8, ziWChar*, ziWChar*, ziU8*, ziWChar*, ziWChar* ZI_NEED_WORK); ziU8 Zi8GetBpmfPhonetic(ziWChar*, ziU8, ziWChar*, ziWChar*, ziWChar*, ziWChar* ZI_NEED_WORK); @@ -11,65 +11,59 @@ ziU8 Zi8GetBpmfPhonetic(ziWChar*, ziU8, ziWChar*, ziWChar*, ziWChar*, ziWChar* Z ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode ZI_NEED_WORK) { - ziU32 lastByte; - ziU8 nextElement; - ziS8 valid; - int componentTable; - ziU32 result; - ziU32 nibbles; - ziU32 copyIndex; - ziU8 mode; - ziU8 stroke; - ziU8 elementIndex; - ziU8 elementCount; + ziU8 masks[12]; + ziU8 strokes[12]; + ziU8* component; + ziU8* componentIndex; + ziU8 strokePrefix[4]; + ziU8 maskPrefix[4]; + ziU8* phoneticTable; + ziWChar* phoneticInput; + ziU16 element; + ziU16 phoneticCount; + ziU16 phoneticInitial; + ziU16 phoneticMask; + ziU16 phoneticCode; + ziU16 phoneticLength; + ziWChar initial; + ziWChar final; + ziWChar bestInitial; + ziWChar bestFinal; ziWChar previousFinal; ziWChar previousInitial; - ziWChar bestFinal; - ziWChar bestInitial; - ziWChar final; - ziWChar initial; - ziU16 phoneticLength; - ziU16 phoneticCode; - ziU16 phoneticMask; - ziU16 phoneticInitial; - ziU16 phoneticCount; - ziU16 element; - ziWChar* phoneticInput; - ziU8* phoneticTable; - ziU8 strokePrefix [4]; - ziU8 maskPrefix [4]; - ziU8 *componentIndex; - ziU8 *component; - ziU8 strokes [12]; - ziU8 masks [12]; - + ziU8 elementCount; + ziU8 elementIndex; + ziU8 stroke; + ziU8 contextMask; + ziU8 mode; + ziU8 nibbles; + ziU8 index; + stroke = 0; + contextMask = 0x20; Zi8Memset(match,0,0x1ee); nibbles = 0; elementIndex = 0; elementCount = request->elementCount; while (elementCount != 0) { if (request->elements[elementCount - 1] != 0xEF09) break; - elementCount = elementCount - 1; + elementCount--; } match->count = elementCount; - for (nextElement = 0; nextElement < elementCount; nextElement = nextElement + 1) { - if (request->elements[nextElement] != 0xEF00) { + for (index = 0; index < elementCount; index++) { + if (request->elements[index] != 0xEF00) { match->count = 0; break; } } - nextElement = elementIndex; if (elementCount != 0) { - element = request->elements[0]; - match->comp = element; - valid = Zi8IsComponent(element,__zi8_work_data); - if (valid != '\0') { - elementIndex = 1; + match->comp = element = request->elements[0]; + if (Zi8IsComponent(element,__zi8_work_data) != 0) { + elementIndex++; component = (ziU8*)Zi8GetTableAddress(1,2,__zi8_work_data); - componentTable = (ziU32)Zi8GetTableAddress(1,6,__zi8_work_data); - componentIndex = (ziU8 *)(componentTable + (element - 0xef10) * 2); - match->field22 = (componentIndex[1] & 0x3f) * 0x100 + (ziU16)*componentIndex; + componentIndex = (ziU8*)Zi8GetTableAddress(1,6,__zi8_work_data); + componentIndex += (element - 0xef10) * 2; + match->field22 = (((ziU16)componentIndex[1] & 0x3f) << 8) + *componentIndex; component += (ziU32)match->field22 * 8; switch(*component & 0xf) { case 0: @@ -102,29 +96,25 @@ ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode Z case 8: match->comp = 0xEF00 + 2; } - for (copyIndex = 0; (copyIndex & 0xff) < ((int)(ziU32)component[5] >> 1) + 1U; copyIndex = copyIndex + 1) { - if ((copyIndex & 0xff) < 4) { - match->arrD[copyIndex & 0xFF] = component[copyIndex & 0xff]; - match->arr1[copyIndex & 0xFF] = 0xff; + for (index = 0; index < (component[5] >> 1) + 1; index++) { + if (index < 4) { + match->arrD[index] = component[index]; + match->arr1[index] = 0xff; } } - if (((copyIndex & 0xff) != 0) && ((component[5] & 1) == 0)) { - lastByte = copyIndex - 1 & 0xff; - match->arrD[lastByte] = match->arrD[lastByte] & 0xf0; - copyIndex = copyIndex - 1 & 0xff; - match->arr1[copyIndex] = match->arr1[copyIndex] & 0xf0; + if ((index != 0) && ((component[5] & 1) == 0)) { + index--; + match->arrD[index] &= 0xf0; + match->arr1[index] = match->arr1[index] & 0xf0; } nibbles = (ziU8)(component[5] + 1); - nextElement = 1; if (8 < nibbles) { - nibbles = (ziU8)(component[5] + 2); - nextElement = elementIndex; + nibbles++; } } } - elementIndex = nextElement; - match->arr1[0] = match->arr1[0] & 0xf; - match->arrD[0] = match->arrD[0] & 0xf; + match->arr1[0] &= 0xf; + match->arrD[0] &= 0xf; if (skipMode == '\0') { mode = 0; if (((request->subLanguage & 0x80) == 0) && ((request->subLanguage & 0x40) == 0)) { @@ -143,15 +133,13 @@ ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode Z if (mode == 0) { mode = request->subLanguage; } - if (mode != 3) { - if (mode < 3) { - if (mode != 0) { -setMode: - match->arr1[0] = match->arr1[0] | mode << 4; - match->arrD[0] = match->arrD[0] | mode << 4; - } - } - else if (mode < 5) goto setMode; + switch (mode) { + case 1: + case 2: + case 4: + match->arr1[0] |= (ziU8)(mode << 4); + match->arrD[0] |= (ziU8)(mode << 4); + break; } } if (nibbles == 0) { @@ -163,102 +151,66 @@ setMode: Zi8Memcpy(strokes,match->arrD,0xc); do { while (elementIndex < elementCount) { - nextElement = elementIndex + 1; - element = request->elements[elementIndex]; - if (element == 0xef07) { - stroke = 3; + element = request->elements[elementIndex++]; + switch (element) { + case 0xef02: stroke = 0; break; + case 0xef04: stroke = 1; break; + case 0xef01: stroke = 2; break; + case 0xef07: stroke = 3; break; + case 0xef06: stroke = 4; break; + case 0xef03: stroke = 5; break; + case 0xef05: stroke = 6; break; + case 0xef08: stroke = 7; break; + case 0xef0b: stroke = 8; break; + case 0xef0a: stroke = 4; break; + case 0xf360: stroke = 0xff; break; + default: stroke = 0; break; } - else if (element < 0xef07) { - if (element == 0xef03) { - stroke = 5; - } - else if (element < 0xef03) { - if (element == 0xef01) { - stroke = 2; - } - else { - if (element < 0xef01) goto wildcard; - stroke = 0; - } - } - else if (element == 0xef05) { - stroke = 6; - } - else if (element < 0xef05) { - stroke = 1; - } - else { - stroke = 4; - } - } - else if (element == 0xef0b) { - stroke = 8; - } - else if (element < 0xef0b) { - if (element == 0xef09) { -wildcard: - stroke = 0; - } - else if (element < 0xef09) { - stroke = 7; - } - else { - stroke = 4; - } - } - else { - if (element != 0xf360) goto wildcard; - stroke = 0xff; - } - elementIndex = nextElement; if (stroke == 0xff) break; if (0x17 < nibbles) { match->length = 0x18; - result = 0; - goto done; + return 0; } if (nibbles == 8) { - nibbles = 9; + nibbles++; } - if ((nibbles & 1) == 0) { - strokes[(int)(ziU32)nibbles >> 1] = strokes[(int)(ziU32)nibbles >> 1] | stroke << 4; + if ((nibbles & 1) != 0) { + strokes[nibbles >> 1] = strokes[nibbles >> 1] | stroke; if (element == 0xef0b) { - masks[(int)(ziU32)nibbles >> 1] = masks[(int)(ziU32)nibbles >> 1] | 0x80; + masks[nibbles >> 1] = masks[nibbles >> 1] | 8; } else if (element == 0xef0a) { - masks[(int)(ziU32)nibbles >> 1] = masks[(int)(ziU32)nibbles >> 1] | 0x40; + masks[nibbles >> 1] = masks[nibbles >> 1] | 4; } else if (element != 0xef00) { - masks[(int)(ziU32)nibbles >> 1] = masks[(int)(ziU32)nibbles >> 1] | 0x70; + masks[nibbles >> 1] = masks[nibbles >> 1] | 7; } - } - else { - strokes[(int)(ziU32)nibbles >> 1] = strokes[(int)(ziU32)nibbles >> 1] | stroke; + } else { + strokes[nibbles >> 1] = strokes[nibbles >> 1] | (ziU8)(stroke << 4); if (element == 0xef0b) { - masks[(int)(ziU32)nibbles >> 1] = masks[(int)(ziU32)nibbles >> 1] | 8; + masks[nibbles >> 1] = masks[nibbles >> 1] | 0x80; } else if (element == 0xef0a) { - masks[(int)(ziU32)nibbles >> 1] = masks[(int)(ziU32)nibbles >> 1] | 4; + masks[nibbles >> 1] = masks[nibbles >> 1] | 0x40; } else if (element != 0xef00) { - masks[(int)(ziU32)nibbles >> 1] = masks[(int)(ziU32)nibbles >> 1] | 7; + masks[nibbles >> 1] = masks[nibbles >> 1] | 0x70; } - } - nibbles = nibbles + 1; + } + nibbles++; } - for (nextElement = 0; nextElement < 4; nextElement = nextElement + 1) { - maskPrefix[nextElement] = masks[nextElement]; - strokePrefix[nextElement] = strokes[nextElement]; + for (index = 0; index < 4; index++) { + maskPrefix[index] = masks[index]; + strokePrefix[index] = strokes[index]; } if ((1 < nibbles) && (nibbles < 8)) { - componentTable = (int)(ziU32)nibbles >> 1; if ((nibbles & 1) == 0) { - maskPrefix[componentTable] = maskPrefix[componentTable] | 0xf0; - strokePrefix[componentTable] = strokePrefix[componentTable] | 0xf0; + maskPrefix[nibbles >> 1] = maskPrefix[nibbles >> 1] | 0xf0; + strokePrefix[nibbles >> 1] = strokePrefix[nibbles >> 1] | 0xf0; } else { - maskPrefix[componentTable] = maskPrefix[componentTable] | 0xf; - strokePrefix[componentTable] = strokePrefix[componentTable] | 0xf; + maskPrefix[nibbles >> 1] = maskPrefix[nibbles >> 1] | 0xf; + strokePrefix[nibbles >> 1] = strokePrefix[nibbles >> 1] | 0xf; } } if (match->nSeg == 0) { @@ -270,7 +222,7 @@ wildcard: } Zi8Memcpy(match->segs1 + match->nSeg * 12,masks,0xc); Zi8Memcpy(match->segsD + match->nSeg * 12,strokes,0xc); - match->nSeg = match->nSeg + 1; + match->nSeg++; if (((stroke != 0xff) || (elementCount <= elementIndex)) || (0xf < match->nSeg)) goto complete; Zi8Memset(masks,0,0xc); Zi8Memset(strokes,0,0xc); @@ -290,9 +242,8 @@ wildcard: phoneticCount = Zi8GetTableCount(1,4,__zi8_work_data); } if ((request->getMode == '\x01') || (request->getMode == '\f')) { - nibbles = Zi8GetPyPhonetic(request->elements,elementCount,match->phon,match->phon2, - &request->count,&match->first,&match->first2,__zi8_work_data); - match->nCand = nibbles; + match->nCand = Zi8GetPyPhonetic(request->elements,elementCount,match->phon,match->phon2, + &request->count,&match->first,&match->first2,__zi8_work_data); } else { initial = 0; @@ -305,14 +256,13 @@ wildcard: match->nCand = 0; request->count = request->elementCount; phoneticLength = 1; - for (nibbles = 0; nibbles < elementCount; nibbles = nibbles + 1) { - valid = Zi8GetBpmfPhonetic(phoneticInput,phoneticLength & 0xff,&initial,&final,&bestInitial,&bestFinal, - __zi8_work_data); - if (valid == '\0') { - if ((nibbles == 0) || + for (index = 0; index < elementCount; index++) { + if (Zi8GetBpmfPhonetic(phoneticInput,phoneticLength & 0xff,&initial,&final,&bestInitial,&bestFinal, + __zi8_work_data) == 0) { + if ((index == 0) || ((((1 < phoneticLength && (phoneticInput[phoneticLength - 2] == 0xF360)) && (phoneticInput[phoneticLength - 1] == 0xF360)) || - (nextElement = match->nCand, match->nCand = nextElement + 1, (ziU8)(nextElement + 1) == 0x10)))) { + (++match->nCand == 0x10)))) { initial = 0xffff; final = 0xffff; bestInitial = 0xffff; @@ -321,7 +271,7 @@ wildcard: break; } if (phoneticInput[phoneticLength - 1] == 0xF360) { - match->nCand = match->nCand - 1; + match->nCand--; bestInitial = previousInitial; bestFinal = previousFinal; final = bestFinal; @@ -333,7 +283,7 @@ wildcard: } phoneticInput = phoneticInput + phoneticLength - 1; phoneticLength = 0; - nibbles = nibbles - 1; + index--; } else { savePhonetic: @@ -346,7 +296,7 @@ savePhonetic: match->first2 = bestFinal; } } - phoneticLength = phoneticLength + 1; + phoneticLength++; } if (elementCount != 0) { match->phon[match->nCand] = initial; @@ -355,10 +305,10 @@ savePhonetic: match->first = bestInitial; match->first2 = bestFinal; } - match->nCand = match->nCand + 1; + match->nCand++; } } - if (((request->context & 0x20) != 0) && + if (((request->context & contextMask) != 0) && ((1 < match->nCand || (request->count != elementCount)))) { match->phon[0] = 0xFFFF; match->phon2[0] = 0xFFFF; @@ -380,7 +330,7 @@ savePhonetic: while ((phoneticLength < phoneticCount && (phoneticCode = (phoneticTable[phoneticLength * 2 + 1] << 8) | phoneticTable[phoneticLength * 2], phoneticMask != (phoneticCode & phoneticInitial)))) { - phoneticLength = phoneticLength + 1; + phoneticLength++; } if (phoneticLength == phoneticCount) { match->phon[0] = 0xFFFF; @@ -388,10 +338,6 @@ savePhonetic: } } } - result = 1; -done: - return result; complete: - result = 1; - goto done; + return 1; } diff --git a/tools/decomp-assist/ezi3.attempts.md b/tools/decomp-assist/ezi3.attempts.md new file mode 100644 index 00000000..38b0f717 --- /dev/null +++ b/tools/decomp-assist/ezi3.attempts.md @@ -0,0 +1,162 @@ +# eZiText matching attempts, 2026-09-30 + +Six source units; local matching only. All final string pools are identical. Six additional instruction-exact functions; remaining functions are partial. + +## Before -> after + +| Unit | Instruction exact | Fuzzy code | Matched code bytes | Matched data bytes | +| --- | --- | --- | --- | --- | +| zi8dawg | 2/6 -> 5/6 | 51.9523% -> 99.9754% | 536 -> 4356/4868 | 0 -> 120/120 | +| zprepare | 0/1 -> 0/1 | 64.7575% -> 82.4734% | 0 -> 0/3760 | 0 -> 8/68 | +| zkokeyp | 1/7 -> 1/7 | 76.1862% -> 81.0346% | 332 -> 332/5200 | 0 -> 0/140 | +| zi8getc2 | 11/17 -> 14/17 | 81.5273% -> 94.7933% | 1380 -> 3584/6888 | 24 -> 112/332 | +| zi8match | 7/10 -> 7/10 | 87.4123% -> 89.0165% | 3720 -> 3720/8256 | 608 -> 608/728 | +| zikorean | 2/3 -> 2/3 | 85.0925% -> 86.8605% | 2712 -> 2712/5188 | 24 -> 24/348 | + +## Remaining functions + +- Zi8MatchROMdata1: 99.765625%; Register allocation only (group index and table address swap registers). Logged attempts: 11. +- Zi8PrepareMatch: 82.473404%; Stack layout, stroke/phonetic basic blocks and temporaries remain different; 973 versus 940 instructions. Logged attempts: 5. +- Zi8_8148302C: 99.491520%; Register allocation only: work pointer and table count exchange r27/r29. Logged attempts: 4. +- Zi8_81483264: 98.902435%; Register allocation only: parameter pointer and byte counter exchange r30/r31. Logged attempts: 4. +- Zi8_81483308: 99.137930%; Register allocation only: insertion count pointer and byte index exchange r29/r30. Logged attempts: 4. +- Zi8_814833F0: 99.042560%; Register allocation only: parameter pointer and byte index exchange r30/r31. Logged attempts: 4. +- Zi8_814834AC: 87.938774%; 343/343 instructions, but registers, stack accesses and branch operands differ (268 changed instructions). Logged attempts: 3. +- Zi8GetKOcandidates: 69.584460%; Candidate traversal blocks and temporaries remain different; 727 versus 669 instructions. Logged attempts: 4. +- Zi8GetDataSignature: 99.347824%; Register allocation only: destination, language and signature pointer cycle through r27/r28/r29. Logged attempts: 3. +- Zi8GetCandidatesOrCount: 87.203170%; Stack frame 0x50 versus 0x60 and signature dispatch/early return order remain different; 693 versus 694 instructions. Logged attempts: 3. +- Zi8IsDupWChar: 99.365080%; Register allocation only: character and duplicate flag exchange r27/r28. Logged attempts: 3. +- Zi8MatchPhonetic: 85.950420%; Dictionary/mask registers, stack descriptor placement and nested branch order remain different; 358 versus 363 instructions. Logged attempts: 9. +- Zi8GetPyPhonetic: 75.584960%; Stack byte placement, conversion loop scheduling and phonetic branches remain different; 727 versus 718 instructions. Logged attempts: 3. +- Zi8GetPyFinal: 99.245285%; Register allocation only in final output row-address expressions (eight changed instructions). Logged attempts: 3. +- Zi8GetKoreanCandidates: 72.468500%; 621/619 instructions; expression scheduling and table/candidate branch ordering differ. Logged attempts: 3. + +## Exact gains + +- zi8dawg: Zi8MatchROMdata0 (522/522), Zi8MatchROMdata2 (236/236), Zi8MatchROMdata (197/197). +- zi8getc2: Zi8AlphaSignature (204/204), Zi8ZhSignature (208/208), Zi8IsDupWordW (139/139). +- Each has objdiff 100.0 and ctxdiff diffs 0 from independent final object checks. + +## Scope and uncertainty + +zprepare, zkokeyp, zi8match and zikorean have fuzzy improvements without increased exact-function counts. They remain partial; GATE PASS does not assert completion. Register-only differences are observed; the compiler choice causing them is unresolved. Data scores remain partial in five units. No linking changes were attempted. Runtime behavior was not tested separately; target disassembly and object comparison were the matching authority. + +## Files changed + +- libs/RVLMiddleware/eZiText/src/clib/zi8dawg.c +- libs/RVLMiddleware/eZiText/src/clib/zprepare.c +- libs/RVLMiddleware/eZiText/src/clib/zkokeyp.c +- libs/RVLMiddleware/eZiText/src/clib/zi8getc2.c +- libs/RVLMiddleware/eZiText/src/clib/zi8match.c +- libs/RVLMiddleware/eZiText/src/clib/zikorean.c +- tools/decomp-assist/ezi3.attempts.md +- tools/decomp-assist/ezi3.final-gate.txt + +## Local source commits + +``` +38961b58 match dawg graph traversal +dc29ae80 match dawg segmented search +14156024 match dawg group search +cd667fb6 restore prepare match block structure +e575012c restore korean candidate filter frame and branches +a22a9876 restore korean key table traversal and options +b063bccc match latin data signature output +b36ad4ce match chinese data signature output +d004c9bc restore signed candidate language dispatch +e3d4e836 match duplicate word slot management +8b57b56d restore phonetic and korean search blocks +``` + +## Attempt log + +Build failures are preserved. Candidate variants that failed to improve the best score were restored. The old pool tool raises KeyError on objects without .data; the gate string-reader fallback and final full gate verified their empty pools. A blank pool field in early attempts reflects that tool error, not an asserted match. + +``` +zi8dawg Zi8MatchROMdata0 attempt 1: translate graph traversal blocks in address order; separate key and graph tables; u8 count and u16 search state; fuzzy 98.005745; src 0x824 base 0x828 insns 521/522; --- replace mine 40:41 base 40:41; +zi8dawg Zi8MatchROMdata0 attempt 2: unsigned key array eliminates sign extension; explicit null pointer comparisons and key-table expression order; fuzzy 99.93104; src 0x828 base 0x828 insns 522/522; diffs 18: [99, 119, 120, 179, 180, 219, 222, 224, 243, 287, 316, 329, 332, 333, 335, 336, 443, 505]; +zi8dawg Zi8MatchROMdata0 attempt 3: reverse scalar declarations to match stack offsets; explicit signed key-count local and graph table update order; fuzzy 95.72797; src 0x828 base 0x828 insns 522/522; diffs 39: [190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209]; +zi8dawg Zi8MatchROMdata0 attempt 4: retain for-loop ternary, reorder used scalar locals to match reverse stack allocation; fuzzy 99.950195; src 0x828 base 0x828 insns 522/522; diffs 8: [219, 222, 224, 243, 316, 329, 332, 333]; +zi8dawg Zi8MatchROMdata0 attempt 5: explicit tail-tested key loop removes compiler temporary; compound key table update and grouped character table access; fuzzy 100.0; src 0x828 base 0x828 insns 522/522; diffs 0: []; +zi8dawg Zi8MatchROMdata1 attempt 1: widen group index to byte type; fuzzy 98.203125; src 0x208 base 0x200 insns 130/128; --- replace mine 12:13 base 12:13; +zi8dawg Zi8MatchROMdata1 attempt 2: inline table-address assignment; fuzzy 98.47656; src 0x1fc base 0x200 insns 127/128; --- replace mine 5:7 base 5:7; +zi8dawg Zi8MatchROMdata1 attempt 3: use pointer local for table address; fuzzy 99.765625; src 0x200 base 0x200 insns 128/128; diffs 5: [12, 36, 37, 52, 57]; +zi8dawg Zi8MatchROMdata2 attempt 1: translate success-copy then failure-prefix blocks in target order; byte loop and parameter types; switch vowel test; fuzzy 99.15254; src 0x3b0 base 0x3b0 insns 236/236; diffs 10: [172, 173, 174, 175, 176, 177, 178, 179, 180, 181]; +zi8dawg Zi8MatchROMdata2 attempt 2: byte status prototype restores call narrowing; use unsigned result mask for segment accumulation; fuzzy 99.57627; src 0x3b4 base 0x3b0 insns 237/236; --- replace mine 21:22 base 21:22; +zi8dawg Zi8MatchROMdata1 attempt 4: byte status parameter retains callee narrowing semantics; fuzzy 98.984375; src 0x204 base 0x200 insns 129/128; --- replace mine 12:13 base 12:13; +zi8dawg Zi8MatchROMdata1 attempt 5: avoid duplicate byte-status mask at entry; fuzzy 99.765625; src 0x200 base 0x200 insns 128/128; diffs 5: [12, 36, 37, 52, 57]; +zi8dawg Zi8MatchROMdata2 attempt 3: compound segment-length update avoids redundant conversion; fuzzy 100.0; src 0x3b0 base 0x3b0 insns 236/236; diffs 0: []; +zi8dawg Zi8MatchROMdata attempt 1: translate group iteration and fallback in address order; explicit mode reuse and table-size initialization; fuzzy 100.0; src 0x314 base 0x314 insns 197/197; diffs 0: []; +zi8dawg Zi8MatchROMdata1 attempt 6: declare table address before result; fuzzy 99.765625; src 0x200 base 0x200 insns 128/128; diffs 5: [12, 36, 37, 52, 57]; +zi8dawg Zi8MatchROMdata1 attempt 7: test group index before group terminator; fuzzy 95.11719; src 0x200 base 0x200 insns 128/128; diffs 10: [12, 36, 37, 52, 53, 54, 55, 56, 57, 58]; +zi8dawg Zi8MatchROMdata1 attempt 8: compare group index through byte conversion; fuzzy 99.765625; src 0x200 base 0x200 insns 128/128; diffs 5: [12, 36, 37, 52, 57]; +zprepare Zi8PrepareMatch attempt 1: translate component setup and loop indices from target blocks; reconstruct byte locals and stack arrays; fuzzy 72.98404; src 0xfa4 base 0xeb0 insns 1001/940; --- replace mine 0:1 base 0:1; POOL IDENTICAL up to 0 (mine=0 base=0) +zprepare Zi8PrepareMatch attempt 2: remove cached returns and result local; restore shared byte loop index register and direct phonetic result storage; fuzzy 74.75319; src 0xf74 base 0xeb0 insns 989/940; --- replace mine 0:1 base 0:1; POOL IDENTICAL up to 0 (mine=0 base=0) +zprepare Zi8PrepareMatch attempt 3: restore independent nibble counter test; u32 nibble arithmetic, array declaration order and aligned mode scalar; fuzzy 74.42021; src 0xefc base 0xeb0 insns 959/940; --- replace mine 0:1 base 0:1; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8dawg Zi8MatchROMdata1 attempt 9: group countdown name; fuzzy 99.765625; src 0x200 base 0x200 insns 128/128; diffs 5: [12, 36, 37, 52, 57]; +zi8dawg Zi8MatchROMdata1 attempt 10: table pointer name; fuzzy 99.765625; src 0x200 base 0x200 insns 128/128; diffs 5: [12, 36, 37, 52, 57]; +zi8dawg Zi8MatchROMdata1 attempt 11: remaining group counter name; fuzzy 99.765625; src 0x200 base 0x200 insns 128/128; diffs 5: [12, 36, 37, 52, 57]; +zprepare Zi8PrepareMatch attempt 4: replace stroke decisions with target switch and odd-nibble-first blocks; remove unused component flag, use compound byte increments; fuzzy 81.4617; src 0xf48 base 0xeb0 insns 978/940; --- replace mine 0:1 base 0:1; POOL IDENTICAL up to 0 (mine=0 base=0) +zprepare Zi8PrepareMatch attempt 5: switch for component mode; use integer table-address ABI like matched siblings; fuzzy 82.473404; src 0xf34 base 0xeb0 insns 973/940; --- replace mine 0:1 base 0:1; POOL IDENTICAL up to 0 (mine=0 base=0) +zkokeyp Zi8_8148302C attempt 1: reverse value comparison to target operand order; fuzzy 99.49152; src 0xec base 0xec insns 59/59; diffs 6: [7, 12, 32, 34, 38, 49]; +zkokeyp Zi8_8148302C attempt 2: scope decoded table value inside loop; fuzzy 89.81356; src 0xf8 base 0xec insns 62/59; --- replace mine 5:9 base 5:8; +zkokeyp Zi8_8148302C attempt 3: use byte table index directly as u16; fuzzy 90.50848; src 0xfc base 0xec insns 63/59; --- replace mine 7:8 base 7:8; +zkokeyp Zi8_8148302C attempt 4: reduce key-table arithmetic to nine-byte entries; fuzzy 94.40678; src 0xe4 base 0xec insns 57/59; --- replace mine 7:8 base 7:8; +zkokeyp Zi8_81483264 attempt 1: widen loop variable and narrow at table accesses; fuzzy 98.902435; src 0xa4 base 0xa4 insns 41/41; diffs 8: [6, 8, 17, 20, 21, 24, 25, 26]; +zkokeyp Zi8_81483264 attempt 2: initialize loop index in declaration and use while loop; fuzzy 86.82927; src 0xa4 base 0xa4 insns 41/41; diffs 18: [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 28]; +zkokeyp Zi8_81483308 attempt 1: widen loop variable and narrow at table accesses; fuzzy 99.13793; src 0xe8 base 0xe8 insns 58/58; diffs 9: [7, 22, 26, 33, 34, 39, 42, 44, 50]; +zkokeyp Zi8_81483308 attempt 2: initialize loop index in declaration and use while loop; fuzzy 93.86207; src 0xe4 base 0xe8 insns 57/58; --- replace mine 7:8 base 7:8; +zkokeyp Zi8_814833F0 attempt 1: widen loop variable and narrow at table accesses; fuzzy 99.04256; src 0xbc base 0xbc insns 47/47; diffs 8: [6, 13, 22, 26, 27, 34, 35, 36]; +zkokeyp Zi8_814833F0 attempt 2: initialize loop index in declaration and use while loop; fuzzy 92.53191; src 0xb8 base 0xbc insns 46/47; --- replace mine 6:7 base 6:7; +zkokeyp Zi8_81483264 attempt 3: C99 scoped for counter rejected by C89 compiler; restored original. +zkokeyp Zi8_81483308 attempt 3: C99 scoped for counter rejected by C89 compiler; restored original. +zkokeyp Zi8_814833F0 attempt 3: C99 scoped for counter rejected by C89 compiler; restored original. +zkokeyp Zi8_81483264 attempt 4: C89 scope encloses scratch loop and counter; fuzzy 81.12195; src 0xb8 base 0xa4 insns 46/41; --- replace mine 6:11 base 6:9; POOL IDENTICAL, no strings +zkokeyp Zi8_81483308 attempt 4: C89 scope encloses scratch loop and counter; fuzzy 89.55173; src 0xf4 base 0xe8 insns 61/58; --- replace mine 5:10 base 5:9; POOL IDENTICAL, no strings +zkokeyp Zi8_814833F0 attempt 4: C89 scope encloses scratch loop and counter; fuzzy 83.319145; src 0xd0 base 0xbc insns 52/47; --- replace mine 6:11 base 6:9; POOL IDENTICAL, no strings +zkokeyp Zi8_814834AC attempt 1: replace oversized scratch union with five packed key bytes evidenced by frame and stores; fuzzy 77.472305; src 0x53c base 0x55c insns 335/343; --- replace mine 0:1 base 0:1; POOL IDENTICAL, no strings +zkokeyp Zi8_814834AC attempt 2: translate frame-sized packed key buffer, candidate index initialization, signed divide and modulo, typed nine-byte entries; fuzzy 80.90087; src 0x55c base 0x55c insns 343/343; diffs 290: [6, 7, 11, 12, 13, 14, 15, 16, 23, 24, 25, 28, 32, 37, 38, 39, 41, 42, 45, 47]; POOL IDENTICAL, no strings +zkokeyp Zi8_814834AC attempt 3: separate filtering and compaction indices; emit remaining-candidate branch first like target; fuzzy 87.938774; src 0x55c base 0x55c insns 343/343; diffs 268: [8, 9, 10, 11, 12, 13, 14, 15, 16, 19, 23, 34, 35, 48, 55, 56, 78, 79, 80, 81]; POOL IDENTICAL, no strings +zkokeyp Zi8GetKOcandidates attempt 1: translate typed key table and options; correct nine-byte character stride and five-byte packed key frame; name traversal state; fuzzy 64.93572; src 0xb44 base 0xa74 insns 721/669; --- replace mine 3:7 base 3:5; POOL IDENTICAL, no strings +zkokeyp Zi8GetKOcandidates attempt 2: direct early returns remove unnecessary result lifetimes; shift-plus-index entry addressing follows target blocks; BUILD FAILED, see Zi8GetKOcandidates-2.build +zkokeyp Zi8GetKOcandidates attempt 3: direct early returns and literal shift-plus-index addressing preserve live intermediate counts; fuzzy 69.149475; src 0xb3c base 0xa74 insns 719/669; --- replace mine 3:7 base 3:5; POOL IDENTICAL, no strings +zkokeyp Zi8GetKOcandidates attempt 4: signed division and modulo for packed key comparisons mirror original basic blocks; fuzzy 69.58446; src 0xb5c base 0xa74 insns 727/669; --- replace mine 3:7 base 3:5; POOL IDENTICAL, no strings +zi8getc2 Zi8GetDataSignature attempt 1: decode signature address into integer local; fuzzy 99.347824; src 0x114 base 0x114 insns 69/69; diffs 9: [5, 7, 9, 28, 32, 33, 51, 52, 57]; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8GetDataSignature attempt 2: split capacity test from empty signature; fuzzy 90.434784; src 0x114 base 0x114 insns 69/69; diffs 16: [5, 7, 9, 28, 32, 33, 38, 39, 40, 41, 42, 43, 44, 51, 52, 57]; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8GetDataSignature attempt 3: keep table selector separate from signature length; fuzzy 99.05797; src 0x114 base 0x114 insns 69/69; diffs 13: [5, 7, 9, 25, 27, 28, 29, 32, 33, 34, 51, 52, 57]; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8AlphaSignature attempt 1: translate signature validation and copy blocks; keep first/second descriptors and one active cursor/length; fuzzy 97.97059; src 0x32c base 0x330 insns 203/204; --- replace mine 10:11 base 10:11; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8AlphaSignature attempt 2: keep dictionary descriptor length in aggregate storage and reverse array declarations for target stack layout; BUILD FAILED, see Zi8AlphaSignature-2.build +zi8getc2 Zi8AlphaSignature attempt 3: use aggregate descriptor length consistently in first signature copy; fuzzy 99.90196; src 0x330 base 0x330 insns 204/204; diffs 20: [0, 2, 3, 12, 16, 23, 37, 39, 40, 43, 45, 57, 69, 118, 119, 158, 159, 198, 200, 202]; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8AlphaSignature attempt 4: group persistent signature descriptors into one typed state structure; fuzzy 100.0; src 0x330 base 0x330 insns 204/204; diffs 0: []; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8ZhSignature attempt 1: translate context-selected signature copy paths in address order; common u16 length and independent source lengths; fuzzy 99.01923; src 0x340 base 0x340 insns 208/208; diffs 6: [133, 147, 148, 155, 181, 187]; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8ZhSignature attempt 2: ordinary copied length scalar and combined dictionary cursor expression restore target stack and statement ordering; fuzzy 100.0; src 0x340 base 0x340 insns 208/208; diffs 0: []; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8GetCandidatesOrCount attempt 1: direct signature returns keep candidate count lifetime out of dispatcher; fuzzy 87.18588; src 0xb18 base 0xad8 insns 710/694; --- replace mine 0:1 base 0:1; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8GetCandidatesOrCount attempt 2: promote language selector to signed int for target dispatch comparisons; fuzzy 87.20317; src 0xad4 base 0xad8 insns 693/694; --- replace mine 0:1 base 0:1; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8GetCandidatesOrCount attempt 3: separate character-info buffer and saved call fields in typed state; fuzzy 86.7608; src 0xb0c base 0xad8 insns 707/694; --- replace mine 8:9 base 8:9; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8IsDupWChar attempt 1: signed reverse scan index; fuzzy 99.36508; src 0xfc base 0xfc insns 63/63; diffs 8: [5, 7, 14, 25, 30, 41, 49, 56]; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8IsDupWChar attempt 2: invert equality into continue branch; fuzzy 99.36508; src 0xfc base 0xfc insns 63/63; diffs 8: [5, 7, 14, 25, 30, 41, 49, 56]; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8IsDupWChar attempt 3: move duplicate initialization after buffer setup; fuzzy 97.53968; src 0xfc base 0xfc insns 63/63; diffs 9: [5, 7, 8, 14, 25, 30, 41, 49, 56]; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8IsDupWordW attempt 1: reconstruct word slots as 21-character rows; reuse slot and character counters; fuzzy 99.244606; src 0x230 base 0x22c insns 140/139; --- replace mine 19:20 base 19:20; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8IsDupWordW attempt 2: keep selected slot as byte; fuzzy 94.71223; src 0x238 base 0x22c insns 142/139; --- replace mine 19:20 base 19:20; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8IsDupWordW attempt 3: reverse duplicate branch into matched-first order; fuzzy 97.94964; src 0x230 base 0x22c insns 140/139; --- replace mine 19:20 base 19:20; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8getc2 Zi8IsDupWordW attempt 4: reuse assigned mapping byte as selected slot without an extra work count load; fuzzy 100.0; src 0x22c base 0x22c insns 139/139; diffs 0: []; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8match Zi8MatchPhonetic attempt 1: restore byte traversal fields and typed stack state; nonzero count branch first; BUILD FAILED, see Zi8MatchPhonetic-1.build +zi8match Zi8MatchPhonetic attempt 2: group sound offset in target operand order and signed header division; BUILD FAILED, see Zi8MatchPhonetic-2.build +zi8match Zi8MatchPhonetic attempt 3: use one sound cursor and packed dictionary entry terminator, as original blocks do; BUILD FAILED, see Zi8MatchPhonetic-3.build +zi8match Zi8GetPyPhonetic attempt 1: restore initial partial flag and conversion-count initialization ordering; fuzzy 75.58496; src 0xb5c base 0xb38 insns 727/718; --- replace mine 7:10 base 7:10; POOL IDENTICAL, no strings +zi8match Zi8GetPyPhonetic attempt 2: group phonetic result and conversion descriptors in meaningful stack state; fuzzy 75.58218; src 0xb5c base 0xb38 insns 727/718; --- replace mine 7:10 base 7:10; POOL IDENTICAL, no strings +zi8match Zi8GetPyPhonetic attempt 3: reverse scratch array declarations and express extension normalization by subtraction; fuzzy 75.144844; src 0xb64 base 0xb38 insns 729/718; --- replace mine 7:10 base 7:10; POOL IDENTICAL, no strings +zi8match Zi8GetPyFinal attempt 1: select row base before final output columns; fuzzy 99.245285; src 0xd4 base 0xd4 insns 53/53; diffs 8: [26, 27, 28, 29, 34, 35, 36, 37]; POOL IDENTICAL, no strings +zi8match Zi8GetPyFinal attempt 2: use wider row counter to remove redundant narrowing; fuzzy 99.245285; src 0xd4 base 0xd4 insns 53/53; diffs 8: [26, 27, 28, 29, 34, 35, 36, 37]; POOL IDENTICAL, no strings +zi8match Zi8GetPyFinal attempt 3: tail tested index loop with explicit initialization; fuzzy 99.245285; src 0xd4 base 0xd4 insns 53/53; diffs 8: [26, 27, 28, 29, 34, 35, 36, 37]; POOL IDENTICAL, no strings +zi8match Zi8MatchPhonetic attempt 4: typed traversal state with all actual fields and count initialization; fuzzy 78.10193; src 0x5a0 base 0x5ac insns 360/363; --- replace mine 5:10 base 5:10; POOL IDENTICAL, no strings +zi8match Zi8MatchPhonetic attempt 5: target grouped offset arithmetic and signed header shift; fuzzy 77.804405; src 0x5a4 base 0x5ac insns 361/363; --- replace mine 5:10 base 5:10; POOL IDENTICAL, no strings +zikorean Zi8GetKoreanCandidates attempt 1: restore grouped output reset, successful character lookup first, candidate loop reset; helper owns input index; fuzzy 71.52342; src 0x9b4 base 0x9ac insns 621/619; --- replace mine 8:10 base 8:10; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8match Zi8MatchPhonetic attempt 6: single cursor and packed dictionary terminator state; fuzzy 82.55923; src 0x58c base 0x5ac insns 355/363; --- replace mine 6:10 base 6:10; POOL IDENTICAL, no strings +zikorean Zi8GetKoreanCandidates attempt 2: invert Korean helper success block into target address order and direct typed out parameters; fuzzy 72.4685; src 0x9b4 base 0x9ac insns 621/619; --- replace mine 8:10 base 8:10; POOL IDENTICAL up to 0 (mine=0 base=0) +zikorean Zi8GetKoreanCandidates attempt 3: widen reusable character loop counter and express special-table upper bound literally; fuzzy 72.063; src 0x95c base 0x9ac insns 599/619; --- replace mine 13:19 base 13:19; POOL IDENTICAL up to 0 (mine=0 base=0) +zi8match Zi8MatchPhonetic attempt 7: reuse mutable alternate-mode parameter; header shift without signed division correction; fuzzy 82.74104; src 0x588 base 0x5ac insns 354/363; --- replace mine 5:10 base 5:10; POOL IDENTICAL, no strings +zi8match Zi8MatchPhonetic attempt 8: place node advance block before decoding and branch back on every skip; fuzzy 83.58127; src 0x590 base 0x5ac insns 356/363; --- replace mine 5:10 base 5:10; POOL IDENTICAL, no strings +zi8match Zi8MatchPhonetic attempt 9: place phonetic equality dispatch after nested traversal, preserving target basic block order; fuzzy 85.95042; src 0x598 base 0x5ac insns 358/363; --- replace mine 5:10 base 5:10; POOL IDENTICAL, no strings +``` + diff --git a/tools/decomp-assist/ezi3.final-gate.txt b/tools/decomp-assist/ezi3.final-gate.txt new file mode 100644 index 00000000..6f0f4309 --- /dev/null +++ b/tools/decomp-assist/ezi3.final-gate.txt @@ -0,0 +1,74 @@ +full build: ok +main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d +[libs/RVLMiddleware/eZiText/src/clib/zi8dawg] pool: IDENTICAL +[libs/RVLMiddleware/eZiText/src/clib/zi8dawg] objdiff: code 4356/4868 data 120/120 functions 5/6 fuzzy 99.9754 linked code 0 +[libs/RVLMiddleware/eZiText/src/clib/zi8dawg] instruction-exact functions: 5/6 +[libs/RVLMiddleware/eZiText/src/clib/zi8dawg] section .text size 4868 match 99.97535 +[libs/RVLMiddleware/eZiText/src/clib/zi8dawg] section extab size 48 match 100.0 +[libs/RVLMiddleware/eZiText/src/clib/zi8dawg] section extabindex size 72 match 100.0 +[libs/RVLMiddleware/eZiText/src/clib/zi8dawg] below 100: Zi8MatchROMdata1 99.765625 +[libs/RVLMiddleware/eZiText/src/clib/zi8dawg] baseline: code 536/4868 data None functions 2 fuzzy 51.9523 +[libs/RVLMiddleware/eZiText/src/clib/zprepare] pool: IDENTICAL +[libs/RVLMiddleware/eZiText/src/clib/zprepare] objdiff: code None/3760 data 8/68 functions 0/1 fuzzy 82.4734 linked code 0 +[libs/RVLMiddleware/eZiText/src/clib/zprepare] instruction-exact functions: 0/1 +[libs/RVLMiddleware/eZiText/src/clib/zprepare] section .data size 48 match None +[libs/RVLMiddleware/eZiText/src/clib/zprepare] section .text size 3760 match 82.473404 +[libs/RVLMiddleware/eZiText/src/clib/zprepare] section extab size 8 match 100.0 +[libs/RVLMiddleware/eZiText/src/clib/zprepare] section extabindex size 12 match 83.33333 +[libs/RVLMiddleware/eZiText/src/clib/zprepare] below 100: Zi8PrepareMatch 82.473404 +[libs/RVLMiddleware/eZiText/src/clib/zprepare] baseline: code None/3760 data None functions 0 fuzzy 64.7575 +[libs/RVLMiddleware/eZiText/src/clib/zkokeyp] pool: IDENTICAL +[libs/RVLMiddleware/eZiText/src/clib/zkokeyp] objdiff: code 332/5200 data None/140 functions 1/7 fuzzy 81.0346 linked code 0 +[libs/RVLMiddleware/eZiText/src/clib/zkokeyp] instruction-exact functions: 1/7 +[libs/RVLMiddleware/eZiText/src/clib/zkokeyp] section .text size 5200 match 81.034615 +[libs/RVLMiddleware/eZiText/src/clib/zkokeyp] section extab size 56 match 96.42857 +[libs/RVLMiddleware/eZiText/src/clib/zkokeyp] section extabindex size 84 match 97.61904 +[libs/RVLMiddleware/eZiText/src/clib/zkokeyp] below 100: Zi8_8148302C 99.49152 +[libs/RVLMiddleware/eZiText/src/clib/zkokeyp] below 100: Zi8_81483264 98.902435 +[libs/RVLMiddleware/eZiText/src/clib/zkokeyp] below 100: Zi8_81483308 99.13793 +[libs/RVLMiddleware/eZiText/src/clib/zkokeyp] below 100: Zi8_814833F0 99.04256 +[libs/RVLMiddleware/eZiText/src/clib/zkokeyp] below 100: Zi8_814834AC 87.938774 +[libs/RVLMiddleware/eZiText/src/clib/zkokeyp] below 100: Zi8GetKOcandidates 69.58446 +[libs/RVLMiddleware/eZiText/src/clib/zkokeyp] baseline: code 332/5200 data None functions 1 fuzzy 76.1862 +[libs/RVLMiddleware/eZiText/src/clib/zi8getc2] pool: IDENTICAL +[libs/RVLMiddleware/eZiText/src/clib/zi8getc2] objdiff: code 3584/6888 data 112/332 functions 14/17 fuzzy 94.7933 linked code 0 +[libs/RVLMiddleware/eZiText/src/clib/zi8getc2] instruction-exact functions: 14/17 +[libs/RVLMiddleware/eZiText/src/clib/zi8getc2] section .data size 80 match None +[libs/RVLMiddleware/eZiText/src/clib/zi8getc2] section .rodata size 16 match 100.0 +[libs/RVLMiddleware/eZiText/src/clib/zi8getc2] section .sbss2 size 8 match 50.0 +[libs/RVLMiddleware/eZiText/src/clib/zi8getc2] section .sdata2 size 8 match 100.0 +[libs/RVLMiddleware/eZiText/src/clib/zi8getc2] section .text size 6888 match 94.79327 +[libs/RVLMiddleware/eZiText/src/clib/zi8getc2] section extab size 88 match 100.0 +[libs/RVLMiddleware/eZiText/src/clib/zi8getc2] section extabindex size 132 match 99.242424 +[libs/RVLMiddleware/eZiText/src/clib/zi8getc2] below 100: Zi8GetDataSignature 99.347824 +[libs/RVLMiddleware/eZiText/src/clib/zi8getc2] below 100: Zi8GetCandidatesOrCount 87.20317 +[libs/RVLMiddleware/eZiText/src/clib/zi8getc2] below 100: Zi8IsDupWChar 99.36508 +[libs/RVLMiddleware/eZiText/src/clib/zi8getc2] baseline: code 1380/6888 data 24 functions 11 fuzzy 81.5273 +[libs/RVLMiddleware/eZiText/src/clib/zi8match] pool: IDENTICAL +[libs/RVLMiddleware/eZiText/src/clib/zi8match] objdiff: code 3720/8256 data 608/728 functions 7/10 fuzzy 89.0165 linked code 0 +[libs/RVLMiddleware/eZiText/src/clib/zi8match] instruction-exact functions: 7/10 +[libs/RVLMiddleware/eZiText/src/clib/zi8match] section .rodata size 528 match 100.0 +[libs/RVLMiddleware/eZiText/src/clib/zi8match] section .text size 8256 match 89.01647 +[libs/RVLMiddleware/eZiText/src/clib/zi8match] section extab size 80 match 100.0 +[libs/RVLMiddleware/eZiText/src/clib/zi8match] section extabindex size 120 match 98.333336 +[libs/RVLMiddleware/eZiText/src/clib/zi8match] below 100: Zi8MatchPhonetic 85.95042 +[libs/RVLMiddleware/eZiText/src/clib/zi8match] below 100: Zi8GetPyPhonetic 75.58496 +[libs/RVLMiddleware/eZiText/src/clib/zi8match] below 100: Zi8GetPyFinal 99.245285 +[libs/RVLMiddleware/eZiText/src/clib/zi8match] baseline: code 3720/8256 data 608 functions 7 fuzzy 87.4123 +[libs/RVLMiddleware/eZiText/src/clib/zikorean] pool: IDENTICAL +[libs/RVLMiddleware/eZiText/src/clib/zikorean] objdiff: code 2712/5188 data 24/348 functions 2/3 fuzzy 86.8605 linked code 0 +[libs/RVLMiddleware/eZiText/src/clib/zikorean] instruction-exact functions: 2/3 +[libs/RVLMiddleware/eZiText/src/clib/zikorean] section .data size 288 match None +[libs/RVLMiddleware/eZiText/src/clib/zikorean] section .text size 5188 match 86.86045 +[libs/RVLMiddleware/eZiText/src/clib/zikorean] section extab size 24 match 100.0 +[libs/RVLMiddleware/eZiText/src/clib/zikorean] section extabindex size 36 match 97.22222 +[libs/RVLMiddleware/eZiText/src/clib/zikorean] below 100: Zi8GetKoreanCandidates 72.4685 +[libs/RVLMiddleware/eZiText/src/clib/zikorean] baseline: code 2712/5188 data 24 functions 2 fuzzy 85.0925 +regressions vs baseline: 0 +global matched_code_percent: 83.85455 -> 84.05567 +global fuzzy_match_percent: 97.62925 -> 97.77593 +global complete_code_percent: 58.20100 -> 58.20100 +global matched_data_percent: 90.15434 -> 90.16612 +forbidden patterns added (net, per file): 0 +readability warnings (net, per file; must be 0 in the final result): 0 +GATE PASS