Compare commits
1 Commits
cleanup/se
...
agent/w092
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e836d123be |
@@ -53,9 +53,9 @@ Progress
|
||||
<!-- progress:start -->
|
||||
| Decompiled | Matched | Linked | Data |
|
||||
|:---:|:---:|:---:|:---:|
|
||||
| 94.28% | 82.29% | 58.19% | 89.44% |
|
||||
| 94.96% | 82.42% | 58.19% | 89.46% |
|
||||
|
||||
units 777/1027 complete, functions 11931/12563 matched.
|
||||
units 777/1027 complete, functions 11954/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
|
||||
<!-- progress:end -->
|
||||
|
||||
177
libs/RVLMiddleware/eZiText/src/clib/zconvert.c
Normal file
177
libs/RVLMiddleware/eZiText/src/clib/zconvert.c
Normal file
@@ -0,0 +1,177 @@
|
||||
#include <zi8clib/zconvert.h>
|
||||
#include <zi8clib/zierror.h>
|
||||
|
||||
typedef struct ziConversionRange {
|
||||
ziU16 first, last;
|
||||
union { ziPtr table; ziU32 character; } result;
|
||||
} ziConversionRange;
|
||||
typedef struct ziConversionRangeTable {
|
||||
ziU16 count, flags;
|
||||
ziConversionRange* entries;
|
||||
} ziConversionRangeTable;
|
||||
typedef struct ziConversionTables {
|
||||
ziU16 first, last;
|
||||
ziWChar* unicode;
|
||||
ziConversionRangeTable reverse, keys, cases;
|
||||
} ziConversionTables;
|
||||
typedef struct ziConversionEntry {
|
||||
ziU8 first[2], last[2], flags[2], value[2];
|
||||
} ziConversionEntry;
|
||||
typedef struct ziConversionTable {
|
||||
ziU8 count[2], flags[2], minimum[2], maximum[2];
|
||||
ziConversionEntry entries[1];
|
||||
} ziConversionTable;
|
||||
const ziConversionTables Zi8CvrtTables = {0};
|
||||
ziU16 Zi8GetTableCount(ziU8, ziU8 ZI_NEED_WORK);
|
||||
ziPtr Zi8GetTableAddress(ziU8, ziU8 ZI_NEED_WORK);
|
||||
ziWChar Zi8ConvertUC2UserKey(ziChar, ziU8 ZI_NEED_WORK);
|
||||
|
||||
ziWChar Zi8ConvertUC2WC(ziChar character, ziU8 language ZI_NEED_WORK) {
|
||||
ziU8* table;
|
||||
ziWChar* mapped;
|
||||
ziU8* cursor;
|
||||
ziU16 first, last;
|
||||
const ziConversionTables* defaults;
|
||||
if (character == 0) {
|
||||
Zi8LogError(0x133, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
if (Zi8GetTableCount(language, 6, __zi8_work_data) != 0) {
|
||||
table = Zi8GetTableAddress(language, 6, __zi8_work_data);
|
||||
if (table == 0) {
|
||||
Zi8LogError(0x6A4, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
cursor = table;
|
||||
first = (ziU16)cursor[0] << 8 | cursor[1];
|
||||
last = (ziU16)cursor[2] << 8 | cursor[3];
|
||||
if (character < first || character > last) {
|
||||
Zi8LogError(0x132, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
cursor += (character - first) * 2 + 8;
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
return (ziU16)cursor[0] << 8 | cursor[1];
|
||||
}
|
||||
defaults = &Zi8CvrtTables;
|
||||
if (defaults == 0) {
|
||||
Zi8LogError(0x6A4, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
if (character < defaults->first || character > defaults->last) {
|
||||
Zi8LogError(0x132, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
mapped = defaults->unicode;
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
return mapped[character - defaults->first];
|
||||
}
|
||||
ziChar Zi8ConvertWC2UC(ziWChar character, ziU8 language ZI_NEED_WORK) {
|
||||
ziU16 index, count, first, last, value;
|
||||
ziConversionTable* table;
|
||||
const ziConversionRangeTable* defaults;
|
||||
ziConversionRange* ranges;
|
||||
ziConversionEntry* entry;
|
||||
ziU8* cursor;
|
||||
if (character == 0) {
|
||||
Zi8LogError(0x133, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
if (Zi8GetTableCount(language, 7, __zi8_work_data) != 0) {
|
||||
table = Zi8GetTableAddress(language, 7, __zi8_work_data);
|
||||
if (table == 0) {
|
||||
Zi8LogError(0x6AE, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
entry = table->entries;
|
||||
count = (ziU16)table->count[0] << 8 | table->count[1];
|
||||
for (index = 0; index < count; index++) {
|
||||
first = ((ziU16)entry->first[0] << 8 | entry->first[1]);
|
||||
last = (ziU16)entry->last[0] << 8 | entry->last[1];
|
||||
if (first <= character && character <= last) {
|
||||
value = ((ziU16)entry->value[0] << 8 | entry->value[1]);
|
||||
if (first == last) {
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
return value & 0xFF;
|
||||
}
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
return ((ziU8*)table->entries)[character + value - first];
|
||||
}
|
||||
entry++;
|
||||
}
|
||||
} else {
|
||||
defaults = &Zi8CvrtTables.reverse;
|
||||
if (defaults == 0) {
|
||||
Zi8LogError(0x6AE, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
ranges = defaults->entries;
|
||||
for (index = 0; index < defaults->count; index++) {
|
||||
if (ranges[index].first <= character && character <= ranges[index].last) {
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
if (ranges[index].first == ranges[index].last) return ranges[index].result.character & 0xFF;
|
||||
return ((ziU8*)ranges[index].result.table)[character - ranges[index].first];
|
||||
}
|
||||
}
|
||||
}
|
||||
Zi8LogError(0x6C2, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
ziWChar Zi8ConvertUC2Key(ziChar character, ziU8 language ZI_NEED_WORK) {
|
||||
ziU16 count, index, first, last;
|
||||
ziU32 key = 0;
|
||||
ziConversionTable* table;
|
||||
const ziConversionRangeTable* defaults;
|
||||
ziConversionRange* ranges;
|
||||
ziConversionEntry* entry;
|
||||
ziU8* cursor;
|
||||
if (character == 0) {
|
||||
Zi8LogError(0x133, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
if (ZI_WORK->userKeys[language] != 0) return Zi8ConvertUC2UserKey(character, language, __zi8_work_data);
|
||||
if (Zi8GetTableCount(language, 8, __zi8_work_data) != 0) {
|
||||
table = Zi8GetTableAddress(language, 8, __zi8_work_data);
|
||||
if (table == 0) {
|
||||
Zi8LogError(0x6B8, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
entry = table->entries;
|
||||
count = (ziU16)table->count[0] << 8 | table->count[1];
|
||||
for (index = 0; index < count; index++) {
|
||||
first = ((ziU16)entry->first[0] << 8 | entry->first[1]);
|
||||
last = (ziU16)entry->last[0] << 8 | entry->last[1];
|
||||
if (first <= character && character <= last) {
|
||||
key = ((ziU16)entry->value[0] << 8 | entry->value[1]);
|
||||
if (first != last) {
|
||||
cursor = (ziU8*)table->entries + key + (character - first) * 2;
|
||||
key = (ziU16)cursor[0] << 8 | cursor[1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
entry++;
|
||||
}
|
||||
} else {
|
||||
defaults = &Zi8CvrtTables.keys;
|
||||
if (defaults == 0) {
|
||||
Zi8LogError(0x6B8, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
ranges = defaults->entries;
|
||||
for (index = 0; index < defaults->count; index++) {
|
||||
if (ranges[index].first <= character && character <= ranges[index].last) {
|
||||
if (ranges[index].first == ranges[index].last) key = ranges[index].result.character & 0xFF;
|
||||
else key = ((ziWChar*)ranges[index].result.table)[character - ranges[index].first];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (key == 0) {
|
||||
Zi8LogError(0x6C2, __zi8_work_data);
|
||||
key = 0xEFF1;
|
||||
} else Zi8LogError(100, __zi8_work_data);
|
||||
return key;
|
||||
}
|
||||
ziWChar Zi8ConvertWC2Key(ziWChar character, ziU8 language ZI_NEED_WORK) {
|
||||
return Zi8ConvertUC2Key(Zi8ConvertWC2UC(character, language, __zi8_work_data), language, __zi8_work_data);
|
||||
}
|
||||
180
libs/RVLMiddleware/eZiText/src/clib/zi8pud2.c
Normal file
180
libs/RVLMiddleware/eZiText/src/clib/zi8pud2.c
Normal file
@@ -0,0 +1,180 @@
|
||||
#include <stddef.h>
|
||||
#include <zi8clib/zitypes.h>
|
||||
#include <zi8clib/zierror.h>
|
||||
#include <zi8clib/zconvert.h>
|
||||
#include <zi8clib/zmtkey.h>
|
||||
|
||||
typedef struct ziPudSection {
|
||||
ziU8 flags;
|
||||
ziU8 language;
|
||||
ziU8 offset[2];
|
||||
ziU8 count[2];
|
||||
ziU8 reserved[2];
|
||||
} ziPudSection;
|
||||
typedef struct ziPudHeader {
|
||||
ziU8 format[3];
|
||||
ziU8 languageCount;
|
||||
ziU8 options[4];
|
||||
ziPudSection sections[1];
|
||||
} ziPudHeader;
|
||||
ziU32 Zi8_8147FD7C(ziWChar*, ziU8, ziU8, ziWChar*, ziU16, ziU8, ziU8 ZI_NEED_WORK);
|
||||
|
||||
ziU32 ZiIsPhoneticChar(ziWChar character) {
|
||||
if ((character < 0xF305 || character > 0xF329) && (character < 0xF361 || character > 0xF37A)) return 0;
|
||||
return 1;
|
||||
}
|
||||
int ZiGetZHWordSize(ziWChar* word, int size) {
|
||||
int bytes;
|
||||
ziWChar* cursor;
|
||||
bytes = 0;
|
||||
for (bytes = 0; bytes < size;) {
|
||||
cursor = word;
|
||||
if (ZiIsPhoneticChar(*cursor)) return bytes;
|
||||
bytes += 2;
|
||||
word++;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
void Zi8CopyZHSpelling(ziU8* source, ziWChar* output, ziU16 capacity, int size, int start) {
|
||||
int offset;
|
||||
ziU8* cursor;
|
||||
if (output != 0 && capacity != 0) {
|
||||
*output = 0;
|
||||
if (size > start) {
|
||||
for (offset = 0; offset < size - start && offset < (int)((ziU32)capacity << 1); offset += 2) {
|
||||
cursor = source + start + offset;
|
||||
*output++ = *(ziWChar*)cursor;
|
||||
}
|
||||
*output = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
ziU8 ZADP_Zi8SetPDremoveOpt(ziU8 option ZI_NEED_WORK) {
|
||||
ziU8 previous;
|
||||
previous = ZI_WORK->pdRemoveOpt;
|
||||
ZI_WORK->pdRemoveOpt = option;
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
return previous;
|
||||
}
|
||||
ziU32 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziWChar* spelling, ziU16 spellingCapacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
|
||||
ziWChar folded;
|
||||
ziU32 entrySize, wordSize, copied;
|
||||
ziU8* entry;
|
||||
ziU8* word;
|
||||
int index;
|
||||
int fallback = 0;
|
||||
ziPudHeader* table;
|
||||
ziPudSection* section;
|
||||
if (!(ZI_WORK->pudCount <= 16 && ZI_WORK->pudCount != 0 && ZI_WORK->pudTable[ZI_WORK->pudCount - 1] != 0)) {
|
||||
Zi8LogError(0x4B0, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
if (language == 1) {
|
||||
length &= 0x7F;
|
||||
length *= 2;
|
||||
}
|
||||
if (continuation == 0) {
|
||||
table = (ziPudHeader*)ZI_WORK->pudTable[ZI_WORK->pudCount - 1];
|
||||
index = 0;
|
||||
section = table->sections;
|
||||
while (index < table->languageCount && section->language != language) {
|
||||
index++;
|
||||
section++;
|
||||
}
|
||||
if (table->languageCount <= index) {
|
||||
Zi8LogError(0x4F6, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
ZI_WORK->unk_0x314 = section->count[0] * 0x100 + section->count[1];
|
||||
ZI_WORK->unk_0x310 = (ziU32)table + section->offset[0] * 0x100 + section->offset[1];
|
||||
ZI_WORK->unk_0x318 = 0;
|
||||
}
|
||||
while ((entry = (ziU8*)ZI_WORK->unk_0x310) != 0) {
|
||||
while ((ziS32)ZI_WORK->unk_0x318 < (ziS32)ZI_WORK->unk_0x314) {
|
||||
word = entry + 1;
|
||||
wordSize = *entry;
|
||||
entrySize = wordSize;
|
||||
if (language == 1) {
|
||||
if (*word < ZI_WORK->unk_0x17) goto next;
|
||||
entrySize = wordSize - 1;
|
||||
word = entry + 2;
|
||||
wordSize = ZiGetZHWordSize((ziWChar*)word, entrySize);
|
||||
} else if (ZI_WORK->unk_0x31E != 0 && complete != 0 && wordSize > length && word[length] == 0x20) goto matchText;
|
||||
if ((ziS32)length > (ziS32)wordSize || (complete != 0 && wordSize != length) || (complete == 0 && wordSize == length)) goto next;
|
||||
if (language == 1) {
|
||||
for (index = 0; index < length; index++) {
|
||||
if (word[index] != ((ziU8*)pattern)[index]) goto next;
|
||||
}
|
||||
goto matched;
|
||||
}
|
||||
matchText:
|
||||
for (index = 0; index < length; index++) {
|
||||
if (pattern[index] < 0xEFF1 || pattern[index] > 0xF37F) {
|
||||
folded = Zi8ConvertUC2WC(word[index], language, __zi8_work_data);
|
||||
if (folded != pattern[index] && (!ZI_WORK->unk_0x1F || !Zi8ChangeCharCase(0, &folded, language, __zi8_work_data) || folded != pattern[index])) goto next;
|
||||
} else if (pattern[index] != Zi8ConvertUC2Key(word[index], language, __zi8_work_data)) goto next;
|
||||
}
|
||||
matched:
|
||||
if (fallback) {
|
||||
ZI_WORK->unk_0x310 = 0;
|
||||
ZI_WORK->unk_0x318 = 0;
|
||||
ZI_WORK->unk_0x314 = 0;
|
||||
if (*pattern < 0xEFF1) *output = Zi8ConvertWC2Key(*pattern, language, __zi8_work_data);
|
||||
else *output = *pattern;
|
||||
return 1;
|
||||
}
|
||||
if (language == 1) {
|
||||
index = 0;
|
||||
for (copied = 0; index < (ziS32)wordSize && copied < capacity; copied++) {
|
||||
((ziU8*)output)[index] = word[index];
|
||||
((ziU8*)output)[index + 1] = word[index + 1];
|
||||
index += 2;
|
||||
}
|
||||
Zi8CopyZHSpelling(word, spelling, spellingCapacity, entrySize, wordSize);
|
||||
} else {
|
||||
for (copied = 0; copied < wordSize && copied < capacity; copied++) {
|
||||
output[copied] = Zi8ConvertUC2WC(word[copied], language, __zi8_work_data);
|
||||
if (ZI_WORK->unk_0x31E != 0 && copied >= length && output[copied] == 0x20) {
|
||||
if (complete != 0 || copied >= length) break;
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
}
|
||||
ZI_WORK->unk_0x318++;
|
||||
ZI_WORK->unk_0x310 = (ziU32)(word + entrySize);
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
return (ziU8)copied;
|
||||
next:
|
||||
ZI_WORK->unk_0x318++;
|
||||
entry = word + entrySize;
|
||||
}
|
||||
if (length != 1 || complete == 0 || continuation != 0) {
|
||||
ZI_WORK->unk_0x310 = 0;
|
||||
ZI_WORK->unk_0x318 = 0;
|
||||
ZI_WORK->unk_0x314 = 0;
|
||||
return 0;
|
||||
}
|
||||
complete = 0;
|
||||
fallback = 1;
|
||||
ZI_WORK->unk_0x318 = 0;
|
||||
}
|
||||
Zi8LogError(0x4B3, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
ziU32 Zi8MatchPUDdata(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
|
||||
ziU32 result;
|
||||
if (continuation == 0) ZI_WORK->pudCount = 1;
|
||||
for (;;) {
|
||||
result = Zi8_8147FD7C(pattern, length, language, output, capacity, complete, continuation, __zi8_work_data);
|
||||
if ((ziU8)result != 0) break;
|
||||
if ((ZI_WORK->pudCount = ZI_WORK->pudCount + 1) > 16) {
|
||||
ZI_WORK->pudCount = 1;
|
||||
break;
|
||||
}
|
||||
continuation = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
ziU32 Zi8_8147FD7C(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
|
||||
return Zi8MatchPUDdata_ZHS(pattern, length, language, output, capacity, 0, 0, complete, continuation, __zi8_work_data);
|
||||
}
|
||||
207
libs/RVLMiddleware/eZiText/src/clib/zi8uwd.c
Normal file
207
libs/RVLMiddleware/eZiText/src/clib/zi8uwd.c
Normal file
@@ -0,0 +1,207 @@
|
||||
#include <zi8clib/zitypes.h>
|
||||
#include <zi8clib/zierror.h>
|
||||
#include <zi8clib/zconvert.h>
|
||||
#include <zi8clib/zmtkey.h>
|
||||
|
||||
typedef struct ziUserWord {
|
||||
ziU8 size, language, length, priority;
|
||||
ziU8 text[1];
|
||||
} ziUserWord;
|
||||
typedef struct ziUserDictionary {
|
||||
ziU16 flags, end, current, boundary;
|
||||
ziU8 entries[1];
|
||||
} ziUserDictionary;
|
||||
void Zi8Memset(ziPtr, ziU32, ziU32);
|
||||
|
||||
ziBool Zi8_81480224(ziUserWord* word ZI_NEED_WORK) {
|
||||
ziU8 length;
|
||||
ziU8 position;
|
||||
ziUwdNode* previous;
|
||||
ziUwdNode* current;
|
||||
ziUwdNode* added;
|
||||
ziUserWord* candidate;
|
||||
if (ZI_WORK->uwdCount >= 32) {
|
||||
Zi8LogError(0x19D, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
if (word == 0) {
|
||||
Zi8LogError(0x19F, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
length = word->length;
|
||||
if (length == 0) {
|
||||
Zi8LogError(0x193, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
if (length > 63) {
|
||||
Zi8LogError(0x194, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
previous = 0;
|
||||
current = ZI_WORK->uwdList;
|
||||
while (current != 0) {
|
||||
candidate = (ziUserWord*)current->word;
|
||||
if (ZI_WORK->unk_0x12E == 1 && word->priority > candidate->priority) break;
|
||||
if (candidate->length == length) {
|
||||
position = 0;
|
||||
while (position < length) {
|
||||
if ((ziU8)candidate->text[position] != (ziU8)word->text[position]) break;
|
||||
position++;
|
||||
}
|
||||
if (position == length) {
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
previous = current;
|
||||
current = current->next;
|
||||
}
|
||||
length = ZI_WORK->uwdCount;
|
||||
ZI_WORK->uwdCount = length + 1;
|
||||
added = &ZI_WORK->uwdNodes[length];
|
||||
if (previous == 0) {
|
||||
ZI_WORK->uwdList = added;
|
||||
added->next = current;
|
||||
} else {
|
||||
previous->next = added;
|
||||
added->next = current;
|
||||
}
|
||||
added->word = (ziU8*)word;
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
return 1;
|
||||
}
|
||||
ziUserWord* Zi8_814803F4(ziPtr __zi8_work_data) {
|
||||
ziUserWord* word;
|
||||
if (ZI_WORK->uwdCount != 0) {
|
||||
ZI_WORK->uwdCount--;
|
||||
word = (ziUserWord*)ZI_WORK->uwdList->word;
|
||||
ZI_WORK->uwdList = ZI_WORK->uwdList->next;
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
return word;
|
||||
}
|
||||
Zi8LogError(0x19E, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
void Zi8_8148047C(ziPtr __zi8_work_data) {
|
||||
Zi8Memset(ZI_WORK->uwdNodes, 0, sizeof(ZI_WORK->uwdNodes));
|
||||
ZI_WORK->uwdCount = 0;
|
||||
ZI_WORK->uwdList = 0;
|
||||
}
|
||||
ziU8 Zi8MatchUWDdata(ziWChar* pattern, ziU8 length, ziWChar* currentWord, ziU16 currentLength, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
|
||||
ziWChar folded;
|
||||
int fallback = 0;
|
||||
int visited = 0;
|
||||
int position, prefixLength, previousOffset;
|
||||
ziU32 size, entryLanguage, entryLength;
|
||||
ziU8* cursor;
|
||||
ziU8* begin;
|
||||
ziU8* boundary;
|
||||
ziU8* end;
|
||||
ziUserWord* candidate;
|
||||
ziUserWord* previous;
|
||||
ziUserWord* result;
|
||||
ziUserDictionary* dictionary;
|
||||
int firstSegment;
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
if (!(ZI_WORK->unk_0x138 < 3 && ZI_WORK->unk_0x138 != 0 && ZI_WORK->unk_0x130[ZI_WORK->unk_0x138 - 1] != 0)) {
|
||||
Zi8ReplaceLastError(0x19C, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
dictionary = ZI_WORK->unk_0x130[ZI_WORK->unk_0x138 - 1];
|
||||
if (continuation == 0) {
|
||||
Zi8_8148047C(__zi8_work_data);
|
||||
ZI_WORK->unk_0x13C = 0;
|
||||
if (currentWord == 0 || currentLength == 0 || currentWord[currentLength - 1] != 0x20) ZI_WORK->unk_0x140 = 0;
|
||||
else {
|
||||
prefixLength = 0;
|
||||
for (position = currentLength - 2; position >= 0 && currentWord[position] != 0x20; position--) prefixLength++;
|
||||
if (prefixLength == 0 || prefixLength > 63) ZI_WORK->unk_0x140 = 0;
|
||||
else {
|
||||
ZI_WORK->unk_0x140 = 1;
|
||||
ZI_WORK->unk_0x141[0] = prefixLength + 5;
|
||||
ZI_WORK->unk_0x141[prefixLength + 4] = prefixLength + 5;
|
||||
ZI_WORK->unk_0x141[1] = language;
|
||||
ZI_WORK->unk_0x141[2] = prefixLength;
|
||||
previousOffset = 4;
|
||||
for (; ++position, prefixLength > 0; prefixLength--) {
|
||||
folded = currentWord[position];
|
||||
ZI_WORK->unk_0x141[previousOffset] = Zi8ConvertWC2UC(folded, language, __zi8_work_data);
|
||||
ZI_WORK->unk_0x184[previousOffset] = 0;
|
||||
if (ZI_WORK->unk_0x1F != 0) {
|
||||
if (!Zi8ChangeCharCase(1, &folded, language, __zi8_work_data)) Zi8ChangeCharCase(0, &folded, language, __zi8_work_data);
|
||||
ZI_WORK->unk_0x184[previousOffset] = Zi8ConvertWC2UC(folded, language, __zi8_work_data);
|
||||
}
|
||||
if (ZI_WORK->unk_0x141[previousOffset] == 0) {
|
||||
ZI_WORK->unk_0x140 = 0;
|
||||
previousOffset++;
|
||||
break;
|
||||
}
|
||||
previousOffset++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ZI_WORK->unk_0x140 == 0 && length == 0) return 0;
|
||||
rescan:
|
||||
begin = dictionary->entries + dictionary->current;
|
||||
boundary = (ziU8*)dictionary + dictionary->boundary + 7;
|
||||
end = (ziU8*)dictionary + dictionary->end + 7;
|
||||
cursor = begin;
|
||||
firstSegment = begin < boundary;
|
||||
while (firstSegment ? cursor < boundary : cursor < end) {
|
||||
size = *cursor;
|
||||
candidate = (ziUserWord*)cursor;
|
||||
position = visited++;
|
||||
if ((ziS32)ZI_WORK->unk_0x13C <= position && (size & 0xC0) == 0) {
|
||||
previous = (ziUserWord*)(cursor + size);
|
||||
if ((ziU8*)previous > end) previous = (ziUserWord*)(cursor + ((ziU8*)dictionary - end) + 7);
|
||||
entryLanguage = candidate->language;
|
||||
entryLength = candidate->length;
|
||||
if (entryLanguage == language && length <= entryLength && entryLength < capacity && (complete == 0 || entryLength == length) && (complete != 0 || entryLength != length)) {
|
||||
for (position = 0; position < length; position++) {
|
||||
if (pattern[position] < 0xEFF1 || pattern[position] > 0xF010) {
|
||||
folded = Zi8ConvertUC2WC(candidate->text[position], language, __zi8_work_data);
|
||||
if (folded != pattern[position] && (!ZI_WORK->unk_0x1F || !Zi8ChangeCharCase(0, &folded, language, __zi8_work_data) || folded != pattern[position])) goto next;
|
||||
} else if (pattern[position] != Zi8ConvertUC2Key(candidate->text[position], language, __zi8_work_data)) goto next;
|
||||
}
|
||||
if (ZI_WORK->unk_0x140 != 0) {
|
||||
if (ZI_WORK->unk_0x141[0] != previous->size || ZI_WORK->unk_0x141[1] != previous->language || ZI_WORK->unk_0x141[2] != previous->length) goto next;
|
||||
for (position = 4; position < ZI_WORK->unk_0x141[2] + 4; position++) {
|
||||
if (ZI_WORK->unk_0x141[position] != ((ziU8*)previous)[position] && ZI_WORK->unk_0x184[position] != ((ziU8*)previous)[position]) goto next;
|
||||
}
|
||||
}
|
||||
Zi8_81480224(candidate, __zi8_work_data);
|
||||
}
|
||||
}
|
||||
next:
|
||||
cursor += size;
|
||||
if (end < cursor) {
|
||||
if (firstSegment) break;
|
||||
firstSegment = 1;
|
||||
cursor = dictionary->entries + (cursor - end - 1);
|
||||
}
|
||||
}
|
||||
if (ZI_WORK->unk_0x140 != 0 && length != 0) {
|
||||
ZI_WORK->unk_0x140 = 0;
|
||||
visited = 0;
|
||||
goto rescan;
|
||||
}
|
||||
if (complete != 0 && length == 1) {
|
||||
complete = 0;
|
||||
fallback = 1;
|
||||
visited = 0;
|
||||
goto rescan;
|
||||
}
|
||||
}
|
||||
result = Zi8_814803F4(__zi8_work_data);
|
||||
entryLength = 0;
|
||||
if (result != 0) {
|
||||
entryLanguage = result->language;
|
||||
entryLength = result->length;
|
||||
if (entryLength >= capacity) {
|
||||
Zi8_8148047C(__zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
for (position = 0; position < (ziS32)entryLength; position++) output[position] = Zi8ConvertUC2WC(result->text[position], entryLanguage, __zi8_work_data);
|
||||
}
|
||||
return entryLength;
|
||||
}
|
||||
222
libs/RVLMiddleware/eZiText/src/clib/zidawg1.c
Normal file
222
libs/RVLMiddleware/eZiText/src/clib/zidawg1.c
Normal file
@@ -0,0 +1,222 @@
|
||||
#include <zi8clib/zierror.h>
|
||||
#include <zi8clib/zitypes.h>
|
||||
|
||||
extern ziU16 nodeHeaderTable[16];
|
||||
|
||||
ziU32 ZiDAWGGetChild(ziU32 node) {
|
||||
ziU32 base;
|
||||
ziU16 header;
|
||||
ziS32 offset;
|
||||
|
||||
base = node;
|
||||
header = nodeHeaderTable[*(ziU8*)node >> 4];
|
||||
if (((ziU32)header & 1) == 0) {
|
||||
node = 0;
|
||||
} else {
|
||||
if ((*(ziU8*)node & 0xf) == 0xf) {
|
||||
offset = 2;
|
||||
} else {
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
node += offset;
|
||||
if (((ziU32)header & 2) != 0) {
|
||||
if ((*(ziU8*)node & 0x80) != 0) {
|
||||
offset = *((ziU8*)node + 2) + ((*(ziU8*)node & 0x7f) * 0x10000 + ((ziU32)*((ziU8*)node + 1) & 0xffff) * 0x100 + 0x8000);
|
||||
} else {
|
||||
offset = ((ziU32)*(ziU8*)node & 0xffff) * 0x100;
|
||||
offset += (ziU32)*((ziU8*)node + 1);
|
||||
}
|
||||
} else if (((ziU32)header & 8) != 0) {
|
||||
if ((*(ziU8*)node & 0x80) != 0) {
|
||||
offset += 3;
|
||||
} else {
|
||||
offset += 2;
|
||||
}
|
||||
}
|
||||
|
||||
node = base + offset;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
ziU8* ZiDAWGGetSibling(ziU8* node) {
|
||||
ziU16 header;
|
||||
ziU8* cursor;
|
||||
ziS32 depth;
|
||||
ziS32 offset;
|
||||
|
||||
depth = 0;
|
||||
offset = 0;
|
||||
header = nodeHeaderTable[node[0] >> 4];
|
||||
if ((header & 4) == 0) {
|
||||
node = 0;
|
||||
} else {
|
||||
cursor = node;
|
||||
if ((header & 8) != 0) {
|
||||
if ((node[0] & 0xf) == 0xf) {
|
||||
cursor = node + 2;
|
||||
} else {
|
||||
cursor = node + 1;
|
||||
}
|
||||
|
||||
if ((header & 2) != 0) {
|
||||
if ((*cursor & 0x80) == 0) {
|
||||
cursor += 2;
|
||||
} else {
|
||||
cursor += 3;
|
||||
}
|
||||
}
|
||||
|
||||
if ((*cursor & 0x80) == 0) {
|
||||
node += (ziU32)cursor[1] + (ziU32)*cursor * 0x100;
|
||||
} else {
|
||||
node += (*cursor & 0x7f) * 0x10000 + (ziU32)cursor[1] * 0x100 +
|
||||
0x8000 + (ziU32)cursor[2];
|
||||
}
|
||||
} else {
|
||||
do {
|
||||
header = nodeHeaderTable[cursor[0] >> 4];
|
||||
if ((cursor[0] & 0xf) == 0xf) {
|
||||
cursor += 2;
|
||||
offset += 2;
|
||||
} else {
|
||||
cursor++;
|
||||
offset++;
|
||||
}
|
||||
|
||||
if ((header & 1) != 0) {
|
||||
if ((header & 2) == 0) {
|
||||
depth++;
|
||||
} else if ((*cursor & 0x80) == 0) {
|
||||
cursor += 2;
|
||||
offset += 2;
|
||||
} else {
|
||||
cursor += 3;
|
||||
offset += 3;
|
||||
}
|
||||
}
|
||||
|
||||
if ((header & 4) == 0) {
|
||||
depth--;
|
||||
} else if ((header & 8) != 0) {
|
||||
if ((*cursor & 0x80) == 0) {
|
||||
cursor += 2;
|
||||
offset += 2;
|
||||
} else {
|
||||
cursor += 3;
|
||||
offset += 3;
|
||||
}
|
||||
depth--;
|
||||
}
|
||||
} while (0 < depth);
|
||||
|
||||
node += offset;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
ziU8 ZiDAWGgetEOWattribute(ziU32 node) {
|
||||
return (nodeHeaderTable[*(ziU8*)node >> 4] & 0x10) > 0;
|
||||
}
|
||||
|
||||
ziU32 ZiDAWGgetCHARattribute(ziPtr context, ziU32 node, ziPtr __zi8_work_data) {
|
||||
ziU8 key;
|
||||
ziU32 attribute;
|
||||
|
||||
if ((*(ziU8*)node & 0xf) == 0xf) {
|
||||
key = (ziU32)*((ziU8*)node + 1) + 0xf;
|
||||
} else {
|
||||
key = (ziU32)*(ziU8*)node & 0xf;
|
||||
}
|
||||
|
||||
if (key > ((zi8DawgCtx*)context)->cap) {
|
||||
Zi8LogError(0x138b, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
attribute = key << 24;
|
||||
attribute |= ((ziU8*)((zi8DawgCtx*)context)->p0C)[key] << 16;
|
||||
attribute += ((ziU32)((ziU8*)((zi8DawgCtx*)context)->p08)[key * 2] & 0xFFFF) << 8;
|
||||
attribute += ((ziU8*)((zi8DawgCtx*)context)->p08)[key * 2 + 1];
|
||||
Zi8LogError(0x64, __zi8_work_data);
|
||||
return attribute;
|
||||
}
|
||||
|
||||
ziU32 ZiDAWGGetGraph(ziPtr context) {
|
||||
return (((ziU32)((zi8DawgCtx*)context)->table[2] & 0xFFFF) << 8) +
|
||||
((zi8DawgCtx*)context)->table[3] +
|
||||
((ziU32)((zi8DawgCtx*)context)->table + 4);
|
||||
}
|
||||
|
||||
ziU32 ZiDAWGGetGraphInfo(zi8DawgCtx* context, ziU8* entry, ziU16* keys) {
|
||||
ziU32 graph;
|
||||
ziS32 result;
|
||||
ziU32 end;
|
||||
ziU8 depth;
|
||||
ziU32 pair;
|
||||
|
||||
graph = ZiDAWGGetGraph(context);
|
||||
result = 0;
|
||||
pair = (((ziU16)entry[0] << 8) + entry[1]);
|
||||
if (pair != 0) {
|
||||
goto graph_invalid;
|
||||
}
|
||||
pair = (((ziU16)entry[2] << 8) + entry[3]);
|
||||
if (pair == 0) {
|
||||
goto graph_valid;
|
||||
}
|
||||
graph_invalid:
|
||||
result = 0;
|
||||
goto graph_done;
|
||||
graph_valid:
|
||||
end = (ziU32)(entry + (((ziU16)entry[4] << 8) + entry[5] + 1) * 10);
|
||||
entry += 10;
|
||||
depth = 0;
|
||||
while ((depth < 2) && (*keys != 0)) {
|
||||
if ((*keys < 0xeff1) || (0xf010 < *keys)) {
|
||||
break;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if (*keys == (ziU16)(entry[3] + ((ziU16)entry[2] << 8))) {
|
||||
break;
|
||||
}
|
||||
entry += (entry[1] + ((ziU16)entry[0] << 8)) * 10 + 10;
|
||||
if ((end <= (ziU32)entry) ||
|
||||
(*keys == (ziU16)(entry[3] + ((ziU16)entry[2] << 8)))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (end <= (ziU32)entry) {
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
result = graph + (ziU32)entry[4] * 0x10000 + ((ziU16)entry[5] << 8) +
|
||||
entry[6];
|
||||
((zi8DawgCtx*)context)->unk_0x338 =
|
||||
graph + (ziU32)entry[7] * 0x10000 + ((ziU16)entry[8] << 8) +
|
||||
entry[9];
|
||||
if (((zi8DawgCtx*)context)->unk_0x338 == graph) {
|
||||
((zi8DawgCtx*)context)->unk_0x338 = 0;
|
||||
}
|
||||
|
||||
if ((entry[1] + ((ziU16)entry[0] << 8)) == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
end = (ziU32)(entry + (entry[1] + ((ziU16)entry[0] << 8)) * 10 + 10);
|
||||
entry += 10;
|
||||
depth++;
|
||||
keys++;
|
||||
}
|
||||
|
||||
|
||||
graph_done:
|
||||
return result;
|
||||
}
|
||||
165
libs/RVLMiddleware/eZiText/src/clib/ziswordw.c
Normal file
165
libs/RVLMiddleware/eZiText/src/clib/ziswordw.c
Normal file
@@ -0,0 +1,165 @@
|
||||
#include <stddef.h>
|
||||
#include <zi8clib/zitypes.h>
|
||||
#include <zi8clib/zierror.h>
|
||||
|
||||
typedef struct ziSearchState {
|
||||
ziU32 flags;
|
||||
ziWChar* word;
|
||||
ziU32 length;
|
||||
ziU32 position;
|
||||
ziU32 capacity;
|
||||
ziU32 options;
|
||||
} ziSearchState;
|
||||
typedef struct ziUserKeys {
|
||||
ziWChar* upper[32];
|
||||
ziWChar* lower[32];
|
||||
} ziUserKeys;
|
||||
typedef struct ziChineseEntry {
|
||||
ziU8 data[9];
|
||||
ziU8 offsetHigh;
|
||||
ziU16 offsetLow;
|
||||
} ziChineseEntry;
|
||||
|
||||
ziU8 Zi8GetCandidatesOrCount(ziGetParam*, ziSearchState* ZI_NEED_WORK);
|
||||
ziU8 Zi8GetFormatVersion(ziU8 ZI_NEED_WORK);
|
||||
ziPtr Zi8GetTableAddress(ziU8, ziU8 ZI_NEED_WORK);
|
||||
ziU16 Zi8Uni2Ord(ziWChar ZI_NEED_WORK);
|
||||
|
||||
ziBool Zi8IsWordW(ziWChar* word, ziU8 language ZI_NEED_WORK) {
|
||||
ziU8 remaining, group;
|
||||
ziU16 value = 0;
|
||||
ziWChar* cursor;
|
||||
ziU8 formats[8] = {1, 5, 0, 0, 0, 0, 0, 0};
|
||||
ziSearchState search;
|
||||
ziGetParam request;
|
||||
ziWChar ordinals[65];
|
||||
ziU32 savedFormats = ZI_WORK->unk_0x1410;
|
||||
ziU8 savedCount = ZI_WORK->unk_0x1418;
|
||||
int length, count, offset;
|
||||
int unmatched;
|
||||
ziChineseEntry* entry;
|
||||
ziU8* data;
|
||||
search.flags = 0;
|
||||
search.word = 0;
|
||||
search.length = 0;
|
||||
search.position = 0;
|
||||
search.capacity = 0;
|
||||
search.options = 0;
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
if (word == 0 || *word == 0) {
|
||||
Zi8ReplaceLastError(300, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
if (language != 1) {
|
||||
for (length = 0; word[length] != 0; length++) {
|
||||
if (word[length] > 0xEFF0 || length == 64) return 0;
|
||||
}
|
||||
((ziU8*)&search.length)[0] = length;
|
||||
((ziU8*)&search.flags)[2] = 1;
|
||||
((ziU16*)&search.capacity)[0] = 64;
|
||||
search.word = word;
|
||||
request.language = language;
|
||||
request.getMode = 0;
|
||||
request.subLanguage = 7;
|
||||
request.context = 1;
|
||||
request.getOptions = 0x81;
|
||||
request.elements = word;
|
||||
request.elementCount = length;
|
||||
request.currentWord = 0;
|
||||
request.wordCharCount = 0;
|
||||
request.candidates = ordinals;
|
||||
request.maxCandidates = 1;
|
||||
request.firstCandidate = 0;
|
||||
ZI_WORK->unk_0x1410 = (ziU32)formats;
|
||||
if (ZI_WORK->unk_0x1C[0] == 2) {
|
||||
ZI_WORK->unk_0x1418 = 0;
|
||||
if (ZI_WORK->unk_0x09 & 1) formats[ZI_WORK->unk_0x1418++] = 1;
|
||||
if (ZI_WORK->unk_0x09 & 4) formats[ZI_WORK->unk_0x1418++] = 2;
|
||||
if (ZI_WORK->unk_0x09 & 2) formats[ZI_WORK->unk_0x1418++] = 3;
|
||||
if (ZI_WORK->unk_0x09 & 8) formats[ZI_WORK->unk_0x1418++] = 4;
|
||||
if (ZI_WORK->unk_0x09 & 1) formats[ZI_WORK->unk_0x1418++] = 5;
|
||||
if (ZI_WORK->unk_0x09 & 4) formats[ZI_WORK->unk_0x1418++] = 6;
|
||||
if (ZI_WORK->unk_0x09 & 2) formats[ZI_WORK->unk_0x1418++] = 7;
|
||||
if (ZI_WORK->unk_0x09 & 8) formats[ZI_WORK->unk_0x1418++] = 8;
|
||||
} else if (ZI_WORK->unk_0x1C[0] == 0) ZI_WORK->unk_0x1418 = 1;
|
||||
else ZI_WORK->unk_0x1418 = 2;
|
||||
count = Zi8GetCandidatesOrCount(&request, &search, __zi8_work_data);
|
||||
ZI_WORK->unk_0x1410 = savedFormats;
|
||||
ZI_WORK->unk_0x1418 = savedCount;
|
||||
if (count != 0) return 1;
|
||||
}
|
||||
if (language == 1) {
|
||||
length = 0;
|
||||
do {
|
||||
if (word[length] == 0) {
|
||||
count = length - 1;
|
||||
if (length == 1) return 1;
|
||||
ordinals[count] |= 0x8000;
|
||||
ZI_WORK->unk_0x16 = Zi8GetFormatVersion(1, __zi8_work_data) & 2;
|
||||
entry = (ziChineseEntry*)Zi8GetTableAddress(1, 0, __zi8_work_data) + ordinals[0];
|
||||
data = (ziU8*)Zi8GetTableAddress(1, 1, __zi8_work_data) + ((entry->offsetHigh & 15) << 16 | entry->offsetLow);
|
||||
if (ZI_WORK->unk_0x16 != 0) {
|
||||
group = *data & 7;
|
||||
if (group == 5) offset = 4;
|
||||
else if (group < 5) {
|
||||
if (group == 2) offset = 2;
|
||||
else if (group < 2) offset = 1;
|
||||
else offset = 3;
|
||||
} else offset = 1;
|
||||
data += offset;
|
||||
}
|
||||
if ((*data & 0x80) == 0) return 0;
|
||||
group = 0;
|
||||
data += ((*data & 0x7F) >> 4) + 1;
|
||||
while ((group & 0x80) == 0) {
|
||||
group = *data++;
|
||||
for (remaining = group & 15; remaining != 0; remaining--) {
|
||||
unmatched = count;
|
||||
cursor = ordinals;
|
||||
while (unmatched > 0) {
|
||||
value = data[0] | (data[1] << 8);
|
||||
data += 2;
|
||||
cursor++;
|
||||
if (value != *cursor) break;
|
||||
unmatched--;
|
||||
if (value & 0x8000) break;
|
||||
}
|
||||
if (unmatched == 0) return 1;
|
||||
if (!(value & 0x8000)) {
|
||||
data++;
|
||||
while (!(*data & 0x80)) data += 2;
|
||||
data++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Zi8LogError(0x2BD, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
ordinals[length] = Zi8Uni2Ord(word[length], __zi8_work_data);
|
||||
if (ordinals[length] == 0xFFFF) return 0;
|
||||
length++;
|
||||
} while (length != 64);
|
||||
} else Zi8ReplaceLastError(0x26C, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
ziWChar Zi8ConvertUC2UserKey(ziChar character, ziU8 language ZI_NEED_WORK) {
|
||||
ziUserKeys* keys;
|
||||
ziU16 key;
|
||||
ziWChar* cursor;
|
||||
if (character == 0 || language > 0x82 || (keys = ZI_WORK->userKeys[language]) == 0) return 0;
|
||||
for (key = 0; key < 32; key++) {
|
||||
for (cursor = keys->lower[key]; cursor != 0 && *cursor != 0; cursor++) {
|
||||
if ((ziU16)*cursor == (ziU16)character) goto found;
|
||||
}
|
||||
for (cursor = keys->upper[key]; cursor != 0 && *cursor != 0; cursor++) {
|
||||
if ((ziU16)*cursor == (ziU16)character) goto found;
|
||||
}
|
||||
}
|
||||
found:
|
||||
if (key < 32) {
|
||||
if (key == 0) return 0xEFFA;
|
||||
if (key >= 1 && key <= 9) return key + 0xEFF0;
|
||||
if (key <= 31) return key + 0xEFF1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
215
libs/RVLMiddleware/eZiText/src/clib/zmtkey.c
Normal file
215
libs/RVLMiddleware/eZiText/src/clib/zmtkey.c
Normal file
@@ -0,0 +1,215 @@
|
||||
#include <zi8clib/zconvert.h>
|
||||
#include <zi8clib/zierror.h>
|
||||
#include <zi8clib/zmtkey.h>
|
||||
|
||||
typedef struct ziUserKeyMap { ziWChar* upper[32]; ziWChar* lower[32]; } ziUserKeyMap;
|
||||
|
||||
ziU16 Zi8GetTableCount(ziU8 language, ziU8 tableIndex, ziPtr __zi8_work_data);
|
||||
ziU32 Zi8GetTableAddress(ziU8 language, ziU8 tableIndex, ziPtr __zi8_work_data);
|
||||
ziU8 Zi8getKeyLayout(ziU8 language, ziWChar key, ziWChar* chars, ziU8 mode, ziPtr __zi8_work_data);
|
||||
|
||||
ziBool Zi8_81484484(ziWChar character, ziWChar* output, ziPtr __zi8_work_data) {
|
||||
if (character == 0xeffa) {
|
||||
*output = 0;
|
||||
} else if ((character >= 0xeff1) && (character <= 0xeff9)) {
|
||||
*output = character - 0xeff0;
|
||||
} else if ((character >= 0xeffb) && (character <= 0xf010)) {
|
||||
*output = character - 0xeff1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static ziU8 ziNumKeysWithChars(ziU8 language, ziPtr __zi8_work_data) {
|
||||
ziU16 tableCount;
|
||||
ziU8* table;
|
||||
ziU32 totalCharacters;
|
||||
ziU32 keyIndex;
|
||||
|
||||
tableCount = Zi8GetTableCount(language, 0x1e, __zi8_work_data);
|
||||
table = (ziU8*)Zi8GetTableAddress(language, 0x1e, __zi8_work_data);
|
||||
if (tableCount == 0) {
|
||||
return 0x0c;
|
||||
}
|
||||
|
||||
keyIndex = totalCharacters = 0;
|
||||
for (; (ziU16)keyIndex < 0x20; keyIndex++) {
|
||||
totalCharacters += table[(ziU16)keyIndex];
|
||||
}
|
||||
if ((ziS32)tableCount >= (((ziS32)(totalCharacters & 0xffff) * 4) + 0x20)) {
|
||||
return 0x20;
|
||||
}
|
||||
return 0x0c;
|
||||
}
|
||||
|
||||
ziBool Zi8getKeyLayout(ziU8 language, ziWChar key, ziWChar* chars, ziU8 mode, ziPtr __zi8_work_data) {
|
||||
ziU8 numKeys;
|
||||
ziU16 tableCount;
|
||||
ziU8* dataAddress;
|
||||
ziUserKeyMap* customTable;
|
||||
ziU32 totalCharacters;
|
||||
ziU16 charCount;
|
||||
ziU32 keyIndex;
|
||||
ziWChar* keyChars;
|
||||
|
||||
dataAddress = 0;
|
||||
numKeys = ziNumKeysWithChars(language, __zi8_work_data);
|
||||
Zi8LogError(0x64, __zi8_work_data);
|
||||
*chars = 0;
|
||||
if (ZI_WORK->userKeys[language] != 0) {
|
||||
customTable = ZI_WORK->userKeys[language];
|
||||
if (!Zi8_81484484(key, &key, __zi8_work_data)) {
|
||||
return 0;
|
||||
}
|
||||
keyChars = customTable->lower[key];
|
||||
for (keyIndex = 0; keyChars[(ziU16)keyIndex] != 0; keyIndex++) {
|
||||
chars[(ziU16)keyIndex] = keyChars[(ziU16)keyIndex];
|
||||
}
|
||||
chars[(ziU16)keyIndex] = 0;
|
||||
return 1;
|
||||
} else {
|
||||
if (mode == 1) {
|
||||
goto table_1e;
|
||||
}
|
||||
if ((tableCount = Zi8GetTableCount(language, 0x1d, __zi8_work_data)) == 0) {
|
||||
goto table_1e;
|
||||
}
|
||||
{
|
||||
dataAddress = (ziU8*)Zi8GetTableAddress(language, 0x1d, __zi8_work_data);
|
||||
goto tables_ready;
|
||||
}
|
||||
table_1e:
|
||||
if ((tableCount = Zi8GetTableCount(language, 0x1e, __zi8_work_data)) != 0) {
|
||||
dataAddress = (ziU8*)Zi8GetTableAddress(language, 0x1e, __zi8_work_data);
|
||||
}
|
||||
tables_ready:
|
||||
if (dataAddress == 0) {
|
||||
Zi8ReplaceLastError(0x962, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
if (!Zi8_81484484(key, &key, __zi8_work_data) || (key >= numKeys)) {
|
||||
Zi8ReplaceLastError(300, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
totalCharacters = 0;
|
||||
keyIndex = totalCharacters;
|
||||
for (; (ziU16)keyIndex < key; keyIndex++) {
|
||||
totalCharacters += dataAddress[(ziU16)keyIndex];
|
||||
}
|
||||
if ((charCount = (ziU8)dataAddress[key]) == 0) {
|
||||
return 0;
|
||||
}
|
||||
dataAddress = dataAddress + numKeys + ((totalCharacters & 0xffff) * 2);
|
||||
keyIndex = 0;
|
||||
for (; (ziU16)keyIndex < charCount; keyIndex++) {
|
||||
chars[(ziU16)keyIndex] = (ziU16)dataAddress[(ziU16)keyIndex * 2] |
|
||||
((ziU16)dataAddress[((ziU16)keyIndex * 2) + 1] << 8);
|
||||
}
|
||||
chars[(ziU16)keyIndex] = 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
ziBool Zi8ChangeCharCase(ziBool upper, ziWChar* character, ziU8 language ZI_NEED_WORK) {
|
||||
ziU8 changed;
|
||||
ziU16 total;
|
||||
ziU16 tableCount;
|
||||
ziU8* dataAddress;
|
||||
ziUserKeyMap* customTables;
|
||||
ziU8 numKeys;
|
||||
ziS16 direction;
|
||||
ziU16 result;
|
||||
ziS32 keyIndex;
|
||||
ziPtr from;
|
||||
ziPtr to;
|
||||
ziS32 characterIndex;
|
||||
|
||||
customTables = 0;
|
||||
dataAddress = 0;
|
||||
changed = 0;
|
||||
numKeys = 0x20;
|
||||
Zi8LogError(0x64, ZI_WORK);
|
||||
if (ZI_WORK->userKeys[language] != 0) {
|
||||
customTables = (ziUserKeyMap*)ZI_WORK->userKeys[language];
|
||||
} else if (ZI_WORK->unk_0x11FC != 0) {
|
||||
customTables = (ziUserKeyMap*)ZI_WORK->unk_0x11FC;
|
||||
} else {
|
||||
tableCount = Zi8GetTableCount(language, 0x1e, ZI_WORK);
|
||||
if (tableCount != 0) {
|
||||
dataAddress = (ziU8*)Zi8GetTableAddress(language, 0x1e, ZI_WORK);
|
||||
numKeys = ziNumKeysWithChars(language, ZI_WORK);
|
||||
} else {
|
||||
Zi8ReplaceLastError(0x138d, ZI_WORK);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (customTables != 0) {
|
||||
for (keyIndex = 0; (changed == 0) && (keyIndex < (ziS32)(ziU32)numKeys); keyIndex++) {
|
||||
if (upper != 0) {
|
||||
from = (ziPtr)customTables->lower[keyIndex];
|
||||
to = (ziPtr)customTables->upper[keyIndex];
|
||||
} else {
|
||||
from = (ziPtr)customTables->upper[keyIndex];
|
||||
to = (ziPtr)customTables->lower[keyIndex];
|
||||
}
|
||||
if ((from != 0) && (to != 0)) {
|
||||
for (characterIndex = 0; ((ziU16)((ziS16*)from)[characterIndex]) != 0; characterIndex++) {
|
||||
if ((ziU16)((ziS16*)from)[characterIndex] == *character) {
|
||||
*character = (ziU16)((ziWChar*)to)[characterIndex];
|
||||
changed = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dataAddress != 0) {
|
||||
total = 0;
|
||||
for (keyIndex = 0; keyIndex < (ziS32)(ziU32)numKeys; keyIndex++) {
|
||||
total += dataAddress[keyIndex];
|
||||
}
|
||||
dataAddress = dataAddress + numKeys;
|
||||
direction = 1;
|
||||
if (upper == 0) {
|
||||
dataAddress = dataAddress + ((ziU32)total * 2);
|
||||
direction = -1;
|
||||
}
|
||||
for (keyIndex = 0; keyIndex < (ziS32)(ziU32)total; keyIndex++) {
|
||||
tableCount = (ziU16)(dataAddress[(keyIndex * 2)] |
|
||||
((ziU16)dataAddress[(keyIndex * 2) + 1] << 8));
|
||||
if (tableCount == *character) {
|
||||
dataAddress = dataAddress + ((ziS32)direction * ((ziU32)total * 2));
|
||||
*character = (ziU16)(dataAddress[(keyIndex * 2)] |
|
||||
((ziU16)dataAddress[(keyIndex * 2) + 1] << 8));
|
||||
changed = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed == 0) {
|
||||
result = 0;
|
||||
if (upper != 0) {
|
||||
if (((*character >= 0x61) && (*character <= 0x7a)) || ((*character >= 0xf1) && (*character <= 0xf6)) ||
|
||||
((*character >= 0xf8) && (*character <= 0xfe)) || ((*character >= 0xe0) && (*character <= 0xef))) {
|
||||
result = *character - 0x20;
|
||||
} else if (*character == 0xff) {
|
||||
result = 0x178;
|
||||
}
|
||||
} else {
|
||||
if (((*character >= 0x41) && (*character <= 0x5a)) || ((*character >= 0xd1) && (*character <= 0xd6)) ||
|
||||
((*character >= 0xd8) && (*character <= 0xde)) || ((*character >= 0xc0) && (*character <= 0xcf))) {
|
||||
result = *character + 0x20;
|
||||
} else if (*character == 0x178) {
|
||||
result = 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
if ((result != 0) && Zi8ConvertWC2UC(result, language, ZI_WORK)) {
|
||||
*character = result;
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
70
libs/RVLMiddleware/eZiText/src/clib/zoemdata.c
Normal file
70
libs/RVLMiddleware/eZiText/src/clib/zoemdata.c
Normal file
@@ -0,0 +1,70 @@
|
||||
#include <stddef.h>
|
||||
#include <zi8clib/zitypes.h>
|
||||
#include <zi8clib/zierror.h>
|
||||
#include <zi8clib/zconvert.h>
|
||||
#include <zi8clib/zmtkey.h>
|
||||
|
||||
ziU8 Zi8AttachOEMdata(ziU8 (*match)(ziU16, ziWChar*, ziU8, ziPtr), ziU16 count, ziPtr data ZI_NEED_WORK) {
|
||||
ZI_WORK->oemMatch = match;
|
||||
ZI_WORK->oemLen = count;
|
||||
ZI_WORK->oemData = data;
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
return 1;
|
||||
}
|
||||
ziU8 Zi8DetachOEMdata(ziU8 id ZI_NEED_WORK) {
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
if (id != 1 || ZI_WORK->oemMatch == 0) return 0;
|
||||
{
|
||||
ZI_WORK->oemMatch = 0;
|
||||
ZI_WORK->oemLen = 0;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
ziU8 Zi8MatchOEMdata(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* word, ziU16 capacity, ziBool complete, ziBool continuation ZI_NEED_WORK) {
|
||||
ziWChar folded;
|
||||
ziU8 fallback = 0;
|
||||
ziU32 index;
|
||||
ziU32 position;
|
||||
if (!continuation) ZI_WORK->oemIdx = 0;
|
||||
index = ZI_WORK->oemIdx;
|
||||
if ((ziS32)index >= ZI_WORK->oemLen || ZI_WORK->oemMatch == 0) goto noMatch;
|
||||
capacity--;
|
||||
if (length >= capacity) goto noMatch;
|
||||
word[capacity] = 0;
|
||||
word[length] = complete ? 1 : 0;
|
||||
for (;;) {
|
||||
if ((ziS32)index >= ZI_WORK->oemLen || !ZI_WORK->oemMatch(index, word, capacity, ZI_WORK->oemData)) {
|
||||
if (length != 1 || !complete || continuation) goto noMatch;
|
||||
complete = 0;
|
||||
fallback = 1;
|
||||
index = 0;
|
||||
continue;
|
||||
}
|
||||
position = 0;
|
||||
if ((complete && word[length] == 0) || (!complete && word[length] != 0)) {
|
||||
for (; (ziS32)position < length; position++) {
|
||||
if (pattern[position] < 0xEFF1 || pattern[position] > 0xF37F) {
|
||||
if (word[position] != pattern[position]) {
|
||||
if (!ZI_WORK->unk_0x1F || language == 1) break;
|
||||
folded = pattern[position];
|
||||
if (!Zi8ChangeCharCase(1, &folded, language, __zi8_work_data) || folded != word[position]) break;
|
||||
}
|
||||
} else if (pattern[position] != Zi8ConvertWC2Key(word[position], language, __zi8_work_data)) break;
|
||||
}
|
||||
}
|
||||
if ((ziS32)position >= length) {
|
||||
if (fallback) {
|
||||
*word = *pattern;
|
||||
return 1;
|
||||
}
|
||||
ZI_WORK->oemIdx = index + 1;
|
||||
while (word[position] != 0) position++;
|
||||
return position;
|
||||
}
|
||||
word[length] = complete ? 1 : 0;
|
||||
index++;
|
||||
}
|
||||
noMatch:
|
||||
return 0;
|
||||
}
|
||||
397
libs/RVLMiddleware/eZiText/src/clib/zprepare.c
Normal file
397
libs/RVLMiddleware/eZiText/src/clib/zprepare.c
Normal file
@@ -0,0 +1,397 @@
|
||||
#include <zi8clib/zitypes.h>
|
||||
|
||||
void Zi8Memset(ziPtr, ziU32, ziU32);
|
||||
void Zi8Memcpy(ziPtr, ziPtr, ziU32);
|
||||
ziBool Zi8IsComponent(ziWChar ZI_NEED_WORK);
|
||||
ziPtr 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);
|
||||
|
||||
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;
|
||||
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];
|
||||
|
||||
stroke = 0;
|
||||
Zi8Memset(match,0,0x1ee);
|
||||
nibbles = 0;
|
||||
elementIndex = 0;
|
||||
elementCount = request->elementCount;
|
||||
while (elementCount != 0) {
|
||||
if (request->elements[elementCount - 1] != 0xEF09) break;
|
||||
elementCount = elementCount - 1;
|
||||
}
|
||||
match->count = elementCount;
|
||||
for (nextElement = 0; nextElement < elementCount; nextElement = nextElement + 1) {
|
||||
if (request->elements[nextElement] != 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;
|
||||
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;
|
||||
component += (ziU32)match->field22 * 8;
|
||||
switch(*component & 0xf) {
|
||||
case 0:
|
||||
case 9:
|
||||
case 10:
|
||||
default:
|
||||
break;
|
||||
case 1:
|
||||
match->comp = 0xEF00 + 4;
|
||||
break;
|
||||
case 2:
|
||||
match->comp = 0xEF00 + 1;
|
||||
break;
|
||||
case 3:
|
||||
case 0xb:
|
||||
match->comp = 0xEF00 + 7;
|
||||
break;
|
||||
case 4:
|
||||
match->comp = 0xEF00 + 6;
|
||||
break;
|
||||
case 5:
|
||||
match->comp = 0xEF00 + 3;
|
||||
break;
|
||||
case 6:
|
||||
match->comp = 0xEF00 + 5;
|
||||
break;
|
||||
case 7:
|
||||
match->comp = 0xEF00 + 8;
|
||||
break;
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
nibbles = (ziU8)(component[5] + 1);
|
||||
nextElement = 1;
|
||||
if (8 < nibbles) {
|
||||
nibbles = (ziU8)(component[5] + 2);
|
||||
nextElement = elementIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
elementIndex = nextElement;
|
||||
match->arr1[0] = match->arr1[0] & 0xf;
|
||||
match->arrD[0] = match->arrD[0] & 0xf;
|
||||
if (skipMode == '\0') {
|
||||
mode = 0;
|
||||
if (((request->subLanguage & 0x80) == 0) && ((request->subLanguage & 0x40) == 0)) {
|
||||
if ((request->subLanguage & 8) == 0) {
|
||||
if (((request->subLanguage & 0x20) != 0) || ((request->subLanguage & 0x10) != 0)) {
|
||||
mode = 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mode = 4;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mode = 1;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (nibbles == 0) {
|
||||
nibbles = 1;
|
||||
}
|
||||
if (((request->getMode == '\0') || (request->getMode == '\x10')) ||
|
||||
(request->getMode == '\x05')) {
|
||||
Zi8Memcpy(masks,match->arr1,0xc);
|
||||
Zi8Memcpy(strokes,match->arrD,0xc);
|
||||
do {
|
||||
while (elementIndex < elementCount) {
|
||||
nextElement = elementIndex + 1;
|
||||
element = request->elements[elementIndex];
|
||||
if (element == 0xef07) {
|
||||
stroke = 3;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (nibbles == 8) {
|
||||
nibbles = 9;
|
||||
}
|
||||
if ((nibbles & 1) == 0) {
|
||||
strokes[(int)(ziU32)nibbles >> 1] = strokes[(int)(ziU32)nibbles >> 1] | stroke << 4;
|
||||
if (element == 0xef0b) {
|
||||
masks[(int)(ziU32)nibbles >> 1] = masks[(int)(ziU32)nibbles >> 1] | 0x80;
|
||||
}
|
||||
else if (element == 0xef0a) {
|
||||
masks[(int)(ziU32)nibbles >> 1] = masks[(int)(ziU32)nibbles >> 1] | 0x40;
|
||||
}
|
||||
else if (element != 0xef00) {
|
||||
masks[(int)(ziU32)nibbles >> 1] = masks[(int)(ziU32)nibbles >> 1] | 0x70;
|
||||
}
|
||||
}
|
||||
else {
|
||||
strokes[(int)(ziU32)nibbles >> 1] = strokes[(int)(ziU32)nibbles >> 1] | stroke;
|
||||
if (element == 0xef0b) {
|
||||
masks[(int)(ziU32)nibbles >> 1] = masks[(int)(ziU32)nibbles >> 1] | 8;
|
||||
}
|
||||
else if (element == 0xef0a) {
|
||||
masks[(int)(ziU32)nibbles >> 1] = masks[(int)(ziU32)nibbles >> 1] | 4;
|
||||
}
|
||||
else if (element != 0xef00) {
|
||||
masks[(int)(ziU32)nibbles >> 1] = masks[(int)(ziU32)nibbles >> 1] | 7;
|
||||
}
|
||||
}
|
||||
nibbles = nibbles + 1;
|
||||
}
|
||||
for (nextElement = 0; nextElement < 4; nextElement = nextElement + 1) {
|
||||
maskPrefix[nextElement] = masks[nextElement];
|
||||
strokePrefix[nextElement] = strokes[nextElement];
|
||||
}
|
||||
if ((1 < nibbles) && (nibbles < 8)) {
|
||||
componentTable = (int)(ziU32)nibbles >> 1;
|
||||
if ((nibbles & 1) == 0) {
|
||||
maskPrefix[componentTable] = maskPrefix[componentTable] | 0xf0;
|
||||
strokePrefix[componentTable] = strokePrefix[componentTable] | 0xf0;
|
||||
}
|
||||
else {
|
||||
maskPrefix[componentTable] = maskPrefix[componentTable] | 0xf;
|
||||
strokePrefix[componentTable] = strokePrefix[componentTable] | 0xf;
|
||||
}
|
||||
}
|
||||
if (match->nSeg == 0) {
|
||||
Zi8Memcpy(match->arr1,masks,0xc);
|
||||
Zi8Memcpy(match->arrD,strokes,0xc);
|
||||
Zi8Memcpy(match->arr19,maskPrefix,4);
|
||||
Zi8Memcpy(match->arr1D,strokePrefix,4);
|
||||
match->length = nibbles;
|
||||
}
|
||||
Zi8Memcpy(match->segs1 + match->nSeg * 12,masks,0xc);
|
||||
Zi8Memcpy(match->segsD + match->nSeg * 12,strokes,0xc);
|
||||
match->nSeg = match->nSeg + 1;
|
||||
if (((stroke != 0xff) || (elementCount <= elementIndex)) || (0xf < match->nSeg)) goto complete;
|
||||
Zi8Memset(masks,0,0xc);
|
||||
Zi8Memset(strokes,0,0xc);
|
||||
masks[0] = match->arr1[0] & 0xf0;
|
||||
strokes[0] = match->arrD[0] & 0xf0;
|
||||
nibbles = 1;
|
||||
} while (1);
|
||||
}
|
||||
match->length = nibbles;
|
||||
if (elementCount != 0) {
|
||||
if ((request->getMode == '\x01') || (request->getMode == '\f')) {
|
||||
phoneticTable = (ziU8*)Zi8GetTableAddress(1,3,__zi8_work_data);
|
||||
phoneticCount = Zi8GetTableCount(1,3,__zi8_work_data);
|
||||
}
|
||||
else {
|
||||
phoneticTable = (ziU8*)Zi8GetTableAddress(1,4,__zi8_work_data);
|
||||
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;
|
||||
}
|
||||
else {
|
||||
initial = 0;
|
||||
final = 0;
|
||||
bestInitial = 0;
|
||||
bestFinal = 0;
|
||||
previousInitial = 0;
|
||||
previousFinal = 0;
|
||||
phoneticInput = request->elements;
|
||||
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) ||
|
||||
((((1 < phoneticLength && (phoneticInput[phoneticLength - 2] == 0xF360)) &&
|
||||
(phoneticInput[phoneticLength - 1] == 0xF360)) ||
|
||||
(nextElement = match->nCand, match->nCand = nextElement + 1, (ziU8)(nextElement + 1) == 0x10)))) {
|
||||
initial = 0xffff;
|
||||
final = 0xffff;
|
||||
bestInitial = 0xffff;
|
||||
bestFinal = 0xffff;
|
||||
match->nCand = 0;
|
||||
break;
|
||||
}
|
||||
if (phoneticInput[phoneticLength - 1] == 0xF360) {
|
||||
match->nCand = match->nCand - 1;
|
||||
bestInitial = previousInitial;
|
||||
bestFinal = previousFinal;
|
||||
final = bestFinal;
|
||||
initial = bestInitial;
|
||||
goto savePhonetic;
|
||||
}
|
||||
if (match->nCand == 1) {
|
||||
request->count = (ziS8)phoneticLength + -1;
|
||||
}
|
||||
phoneticInput = phoneticInput + phoneticLength - 1;
|
||||
phoneticLength = 0;
|
||||
nibbles = nibbles - 1;
|
||||
}
|
||||
else {
|
||||
savePhonetic:
|
||||
match->phon[match->nCand] = initial;
|
||||
match->phon2[match->nCand] = final;
|
||||
previousFinal = bestFinal;
|
||||
previousInitial = bestInitial;
|
||||
if (match->nCand == 0) {
|
||||
match->first = bestInitial;
|
||||
match->first2 = bestFinal;
|
||||
}
|
||||
}
|
||||
phoneticLength = phoneticLength + 1;
|
||||
}
|
||||
if (elementCount != 0) {
|
||||
match->phon[match->nCand] = initial;
|
||||
match->phon2[match->nCand] = final;
|
||||
if (match->nCand == 0) {
|
||||
match->first = bestInitial;
|
||||
match->first2 = bestFinal;
|
||||
}
|
||||
match->nCand = match->nCand + 1;
|
||||
}
|
||||
}
|
||||
if (((request->context & 0x20) != 0) &&
|
||||
((1 < match->nCand || (request->count != elementCount)))) {
|
||||
match->phon[0] = 0xFFFF;
|
||||
match->phon2[0] = 0xFFFF;
|
||||
match->nCand = 0;
|
||||
}
|
||||
if (((request->getOptions & 0x20) == 0) &&
|
||||
((match->phon[0] != 0xFFFF || (match->phon2[0] != 0xFFFF)))) {
|
||||
if (match->nCand < 2) {
|
||||
phoneticInitial = match->phon[0];
|
||||
phoneticMask = match->phon2[0];
|
||||
}
|
||||
else {
|
||||
phoneticInitial = match->phon[match->nCand - 1];
|
||||
phoneticMask = match->phon2[match->nCand - 1];
|
||||
}
|
||||
phoneticInitial = phoneticInitial & 0xfff8;
|
||||
phoneticMask = phoneticMask & 0xfff8;
|
||||
phoneticLength = 0;
|
||||
while ((phoneticLength < phoneticCount &&
|
||||
(phoneticCode = (phoneticTable[phoneticLength * 2 + 1] << 8) | phoneticTable[phoneticLength * 2],
|
||||
phoneticMask != (phoneticCode & phoneticInitial)))) {
|
||||
phoneticLength = phoneticLength + 1;
|
||||
}
|
||||
if (phoneticLength == phoneticCount) {
|
||||
match->phon[0] = 0xFFFF;
|
||||
match->phon2[0] = 0xFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
result = 1;
|
||||
done:
|
||||
return result;
|
||||
complete:
|
||||
result = 1;
|
||||
goto done;
|
||||
}
|
||||
220
libs/RVL_SDK/src/axfx/AXFXChorusExp.c
Normal file
220
libs/RVL_SDK/src/axfx/AXFXChorusExp.c
Normal file
@@ -0,0 +1,220 @@
|
||||
#include <private/axfx.h>
|
||||
#include <revolution/axfx.h>
|
||||
#include <revolution/os.h>
|
||||
#include <string.h>
|
||||
|
||||
static BOOL __InitParams(AXFX_CHORUS_EXP* fx);
|
||||
static void __CalcLFO(s32* output, AXFX_CHORUS_EXP_LFO* lfo);
|
||||
|
||||
static BOOL __AllocDelayLine(AXFX_CHORUS_EXP* fx) {
|
||||
u32 channel;
|
||||
for (channel = 0; channel < 3; channel++) {
|
||||
fx->delay.line[channel] = __AXFXAlloc(fx->delay.size * sizeof(f32));
|
||||
if (fx->delay.line[channel] == NULL) return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
static BOOL __BzeroDelayLine(AXFX_CHORUS_EXP* fx) {
|
||||
u32 channel;
|
||||
for (channel = 0; channel < 3; channel++) {
|
||||
if (fx->delay.line[channel] == NULL) return FALSE;
|
||||
memset(fx->delay.line[channel], 0, fx->delay.size * sizeof(f32));
|
||||
}
|
||||
fx->delay.inPos = 0;
|
||||
fx->delay.outPos = (fx->delay.size - (u32)(32.0f * fx->delayTime)) << 16;
|
||||
fx->delay.lastPos = fx->delay.outPos;
|
||||
fx->delay.sizeFP = fx->delay.size << 16;
|
||||
return TRUE;
|
||||
}
|
||||
u32 AXFXChorusExpGetMemSize(const AXFX_CHORUS_EXP* fx) {
|
||||
return 0x9600;
|
||||
}
|
||||
BOOL AXFXChorusExpInit(AXFX_CHORUS_EXP* fx) {
|
||||
BOOL enabled = OSDisableInterrupts();
|
||||
fx->active |= 1;
|
||||
fx->delay.size = 3200;
|
||||
if (!__AllocDelayLine(fx)) {
|
||||
AXFXChorusExpShutdown(fx);
|
||||
OSRestoreInterrupts(enabled);
|
||||
return FALSE;
|
||||
}
|
||||
if (!__BzeroDelayLine(fx)) {
|
||||
AXFXChorusExpShutdown(fx);
|
||||
OSRestoreInterrupts(enabled);
|
||||
return FALSE;
|
||||
}
|
||||
if (!__InitParams(fx)) {
|
||||
AXFXChorusExpShutdown(fx);
|
||||
OSRestoreInterrupts(enabled);
|
||||
return FALSE;
|
||||
}
|
||||
fx->active &= ~1;
|
||||
OSRestoreInterrupts(enabled);
|
||||
return TRUE;
|
||||
}
|
||||
BOOL AXFXChorusExpSettings(AXFX_CHORUS_EXP* fx) {
|
||||
BOOL result;
|
||||
BOOL enabled = OSDisableInterrupts();
|
||||
fx->active |= 1;
|
||||
AXFXChorusExpShutdown(fx);
|
||||
result = AXFXChorusExpInit(fx);
|
||||
if (!result) {
|
||||
AXFXChorusExpShutdown(fx);
|
||||
OSRestoreInterrupts(enabled);
|
||||
return FALSE;
|
||||
}
|
||||
fx->active = (fx->active | 2) & ~1;
|
||||
OSRestoreInterrupts(enabled);
|
||||
return result;
|
||||
}
|
||||
void AXFXChorusExpShutdown(AXFX_CHORUS_EXP* fx) {
|
||||
BOOL enabled = OSDisableInterrupts();
|
||||
u32 channel;
|
||||
fx->active |= 1;
|
||||
for (channel = 0; channel < 3; channel++) {
|
||||
if (fx->delay.line[channel] != NULL) __AXFXFree(fx->delay.line[channel]);
|
||||
fx->delay.line[channel] = NULL;
|
||||
}
|
||||
OSRestoreInterrupts(enabled);
|
||||
}
|
||||
void AXFXChorusExpCallback(AXFX_BUFFERUPDATE* update, AXFX_CHORUS_EXP* fx) {
|
||||
s32* output[3];
|
||||
s32* input[3];
|
||||
s32* send[3];
|
||||
s32 modulation[96];
|
||||
u32 sample;
|
||||
if (fx->active != 0) {
|
||||
fx->active &= ~2;
|
||||
return;
|
||||
}
|
||||
output[0] = update->left;
|
||||
output[1] = update->right;
|
||||
output[2] = update->surround;
|
||||
if (fx->busIn != NULL) {
|
||||
input[0] = fx->busIn->left;
|
||||
input[1] = fx->busIn->right;
|
||||
input[2] = fx->busIn->surround;
|
||||
}
|
||||
if (fx->busOut != NULL) {
|
||||
send[0] = fx->busOut->left;
|
||||
send[1] = fx->busOut->right;
|
||||
send[2] = fx->busOut->surround;
|
||||
}
|
||||
__CalcLFO(modulation, &fx->lfo);
|
||||
for (sample = 0; sample < 96; sample++) {
|
||||
s32 position = fx->delay.outPos + modulation[sample];
|
||||
u32 distance;
|
||||
u32 whole, fraction, source, history, channel;
|
||||
f32* coefficients;
|
||||
if (position >= (s32)fx->delay.sizeFP) position -= fx->delay.sizeFP;
|
||||
else if (position < 0) position += fx->delay.sizeFP;
|
||||
distance = position - fx->delay.lastPos;
|
||||
if ((s32)distance < 0) distance += fx->delay.sizeFP;
|
||||
whole = (u32)distance >> 16;
|
||||
fraction = distance & 0xFFFF;
|
||||
source = fx->delay.lastPos >> 16;
|
||||
history = fx->histIndex;
|
||||
while (whole != 0) {
|
||||
fx->history[0][history] = fx->delay.line[0][source];
|
||||
fx->history[1][history] = fx->delay.line[1][source];
|
||||
fx->history[2][history] = fx->delay.line[2][source];
|
||||
history = (history + 1) & 3;
|
||||
source++;
|
||||
if (source >= fx->delay.size) source = 0;
|
||||
whole--;
|
||||
}
|
||||
fx->delay.lastPos = position & 0xFFFF0000;
|
||||
coefficients = __AXFXGetSrcCoef((fraction >> 9) & 0x7F);
|
||||
for (channel = 0; channel < 3; channel++) {
|
||||
f32 filtered = 0.0f;
|
||||
f32 dry;
|
||||
filtered += coefficients[0] * fx->history[channel][history];
|
||||
history = (history + 1) & 3;
|
||||
filtered += coefficients[1] * fx->history[channel][history];
|
||||
history = (history + 1) & 3;
|
||||
filtered += coefficients[2] * fx->history[channel][history];
|
||||
history = (history + 1) & 3;
|
||||
filtered += coefficients[3] * fx->history[channel][history];
|
||||
history = (history + 1) & 3;
|
||||
if (fx->busIn != NULL) dry = *input[channel]++ + *output[channel];
|
||||
else dry = *output[channel];
|
||||
fx->delay.line[channel][fx->delay.inPos] = dry + filtered * fx->feedback;
|
||||
*output[channel]++ = filtered * fx->outGain;
|
||||
if (fx->busOut != NULL) *send[channel]++ = filtered * fx->sendGain;
|
||||
}
|
||||
fx->histIndex = history;
|
||||
fx->delay.inPos++;
|
||||
if (fx->delay.inPos >= fx->delay.size) fx->delay.inPos = 0;
|
||||
fx->delay.outPos += 0x10000;
|
||||
if (fx->delay.outPos >= fx->delay.sizeFP) fx->delay.outPos = 0;
|
||||
}
|
||||
}
|
||||
static BOOL __InitParams(AXFX_CHORUS_EXP* fx) {
|
||||
f32 delay, depth, step;
|
||||
if (fx->delayTime < 0.1f || fx->delayTime > 50.0f) return FALSE;
|
||||
if (fx->depth < 0.0f || fx->depth > 1.0f) return FALSE;
|
||||
if (fx->rate < 0.1f || fx->rate > 2.0f) return FALSE;
|
||||
if (fx->feedback < 0.0f || fx->feedback >= 1.0f) return FALSE;
|
||||
if (fx->outGain < 0.0f || fx->outGain > 1.0f) return FALSE;
|
||||
if (fx->sendGain < 0.0f || fx->sendGain > 1.0f) return FALSE;
|
||||
fx->lfo.table = __AXFXGetLfoSinTable();
|
||||
delay = 32.0f * fx->delayTime;
|
||||
depth = delay * fx->depth;
|
||||
if (delay <= depth) {
|
||||
depth -= 1.0f;
|
||||
if (depth < 0.0f) depth = 0.0f;
|
||||
}
|
||||
fx->lfo.depthSamp = 65536.0f * depth;
|
||||
fx->lfo.phaseAdd = 65536.0f * (256.0f * fx->rate / 32000.0f);
|
||||
step = (32000.0f / fx->rate) * (1.0f / 256.0f);
|
||||
fx->lfo.stepSamp = 65536.0f * step;
|
||||
fx->lfo.gradFactor = 65536.0f * (depth / step);
|
||||
fx->lfo.lastNum = -1;
|
||||
fx->lfo.phase = 0;
|
||||
fx->lfo.sign = 0;
|
||||
fx->lfo.lastValue = 0;
|
||||
fx->lfo.grad = 0;
|
||||
fx->history[0][0] = 0.0f;
|
||||
fx->history[0][1] = 0.0f;
|
||||
fx->history[0][2] = 0.0f;
|
||||
fx->history[0][3] = 0.0f;
|
||||
fx->history[1][0] = 0.0f;
|
||||
fx->history[1][1] = 0.0f;
|
||||
fx->history[1][2] = 0.0f;
|
||||
fx->history[1][3] = 0.0f;
|
||||
fx->history[2][0] = 0.0f;
|
||||
fx->history[2][1] = 0.0f;
|
||||
fx->history[2][2] = 0.0f;
|
||||
fx->history[2][3] = 0.0f;
|
||||
fx->histIndex = 0;
|
||||
return TRUE;
|
||||
}
|
||||
static void __CalcLFO(s32* output, AXFX_CHORUS_EXP_LFO* lfo) {
|
||||
u32 remaining = 96;
|
||||
do {
|
||||
s32 value;
|
||||
u32 phase = lfo->phase & 0xFFFF0000;
|
||||
if (phase != lfo->lastNum) {
|
||||
s32 start, difference;
|
||||
s64 product;
|
||||
lfo->lastNum = phase;
|
||||
phase >>= 16;
|
||||
start = lfo->table[phase];
|
||||
difference = lfo->table[(phase + 1) & 0x7F] - start;
|
||||
product = (s64)start * lfo->depthSamp;
|
||||
value = ((u32)(product >> 32) << 8) | ((u32)product >> 24);
|
||||
product = (s64)difference * lfo->gradFactor;
|
||||
lfo->grad = ((u32)(product >> 32) << 8) | ((u32)product >> 24);
|
||||
}
|
||||
else value = lfo->lastValue + lfo->grad;
|
||||
lfo->lastValue = value;
|
||||
if (lfo->sign != 0) value = -value;
|
||||
lfo->phase += lfo->phaseAdd;
|
||||
if (lfo->phase & 0xFF800000) {
|
||||
lfo->phase &= 0x7FFFFF;
|
||||
lfo->sign ^= 1;
|
||||
}
|
||||
*output++ = value;
|
||||
remaining--;
|
||||
} while (remaining != 0);
|
||||
}
|
||||
@@ -244,8 +244,8 @@ u8 KPRLookAhead(KPRQueue* queue, u16* destination, u32 capacity) {
|
||||
|
||||
BOOL KPRProcessAltKeypad(KPRQueue* queue, u16 character) {
|
||||
if (queue->altVal != 0) {
|
||||
u32 leadingZero = queue->altVal & 0x80000000;
|
||||
u32 accumulator = queue->altVal;
|
||||
u32 leadingZero = accumulator & 0x80000000;
|
||||
u32 value;
|
||||
accumulator &= 0x7FFFFFFF;
|
||||
queue->altVal = accumulator;
|
||||
@@ -273,8 +273,9 @@ BOOL KPRProcessAltKeypad(KPRQueue* queue, u16 character) {
|
||||
value = converted;
|
||||
}
|
||||
{
|
||||
u16* destination;
|
||||
int index = queue->oCount + queue->iCount;
|
||||
u16* destination = &queue->text[index];
|
||||
destination = &queue->text[index];
|
||||
for (; index > queue->oCount; --index, --destination) {
|
||||
*destination = destination[-1];
|
||||
}
|
||||
|
||||
256
libs/RVL_SDK/src/nup/nup_nhttp.cpp
Normal file
256
libs/RVL_SDK/src/nup/nup_nhttp.cpp
Normal file
@@ -0,0 +1,256 @@
|
||||
#include <revolution/os.h>
|
||||
#include <revolution/ncd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
namespace nup {
|
||||
void* __nupMalloc(unsigned long size);
|
||||
void __nupFree(void* block);
|
||||
}
|
||||
|
||||
enum NHTTPReqMethod { NHTTP_GET, NHTTP_POST };
|
||||
typedef void (*ProgressCallback)(void*, unsigned long);
|
||||
typedef long (*FlushCallback)(u8*, unsigned long, unsigned long, void*);
|
||||
struct HttpState {
|
||||
int error;
|
||||
unsigned long limit;
|
||||
unsigned long received;
|
||||
ProgressCallback progress;
|
||||
void* progressContext;
|
||||
FlushCallback flush;
|
||||
void* flushContext;
|
||||
void* response;
|
||||
int done;
|
||||
int result;
|
||||
OSTime lastActivity;
|
||||
};
|
||||
struct HttpString {
|
||||
u8* buffer;
|
||||
unsigned long capacity;
|
||||
unsigned long length;
|
||||
unsigned long growth;
|
||||
unsigned long maximumGrowth;
|
||||
};
|
||||
extern "C" {
|
||||
void* NHTTPCreateRequestEx(char*, NHTTPReqMethod, void*, u32, void (*)(int, void*, HttpState*), HttpState*, u8* (*)(u8**, unsigned long*, unsigned long, void*, void*, HttpState*), void (*)(void*));
|
||||
int NHTTPGetError();
|
||||
int NHTTPSetSocketBufferSize(void*, u32);
|
||||
int NHTTPAddHeaderField(void*, const char*, const char*);
|
||||
int NHTTPSetClientCertDefault(void*);
|
||||
int NHTTPSetRootCADefault(void*);
|
||||
int NHTTPSetVerifyOption(void*, u32);
|
||||
int NHTTPSetProxyDefault(void*);
|
||||
int NHTTPAddPostDataRaw(void*, u8*, unsigned long);
|
||||
int NHTTPSendRequestAsync(void*);
|
||||
void NHTTPDeleteRequest(void*);
|
||||
int NHTTPGetProgress(unsigned long*, unsigned long*);
|
||||
int NHTTPGetBodyAll(void*, u8**);
|
||||
int NHTTPGetHeaderAll(void*, char**);
|
||||
void NHTTPCancelRequestAsync(int);
|
||||
void NHTTPDestroyResponse(void*);
|
||||
|
||||
static u8* __nupNhttpBufFull(u8** buffer, unsigned long* length, unsigned long requested, void*, void*, HttpState* state) {
|
||||
u8* next = NULL;
|
||||
if (state->progress != NULL && *length != 0) {
|
||||
state->progress(state->progressContext, *length);
|
||||
}
|
||||
if ((state->received + *length) < state->received) {
|
||||
if (state->error == 0) state->error = -5012;
|
||||
}
|
||||
state->received += *length;
|
||||
if (state->error == 0) {
|
||||
if (state->limit != 0 && state->received > state->limit) {
|
||||
state->error = -5012;
|
||||
goto done;
|
||||
} else {
|
||||
if (*buffer != NULL && state->flush != NULL) {
|
||||
state->error = state->flush(*buffer, *length, requested, state->flushContext);
|
||||
if (state->error != 0) goto done;
|
||||
}
|
||||
next = *buffer;
|
||||
if (next == NULL) {
|
||||
if (requested != 0 && requested < 0x8000) {} else requested = 0x8000;
|
||||
next = (u8*)nup::__nupMalloc(requested);
|
||||
if (next == NULL) {
|
||||
state->error = -5000;
|
||||
goto done;
|
||||
}
|
||||
*length = requested;
|
||||
}
|
||||
if (*length != 0) state->lastActivity = OSGetTime();
|
||||
}
|
||||
}
|
||||
done:
|
||||
if (state->error != 0) {
|
||||
next = NULL;
|
||||
*length = 0;
|
||||
}
|
||||
return next;
|
||||
}
|
||||
static void __nupNhttpBufFree(void* block) {
|
||||
if (block != NULL) nup::__nupFree(block);
|
||||
}
|
||||
static void __nupNhttpReqDone(int result, void* response, HttpState* state) {
|
||||
if (state != NULL) {
|
||||
state->response = response;
|
||||
state->done = 1;
|
||||
state->result = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int __nupNhttpOp(char* url, NHTTPReqMethod method, char* headers, u8* body, unsigned long bodyLength, unsigned long limit, ProgressCallback progress, void* progressContext, FlushCallback flush, void* flushContext) {
|
||||
unsigned long transferred, expected;
|
||||
int length;
|
||||
char* responseHeaders = NULL;
|
||||
u8* responseBody = NULL;
|
||||
HttpState state;
|
||||
int status;
|
||||
state.error = 0;
|
||||
state.limit = limit;
|
||||
state.received = 0;
|
||||
state.progress = progress;
|
||||
state.progressContext = progressContext;
|
||||
state.flush = flush;
|
||||
state.flushContext = flushContext;
|
||||
state.response = NULL;
|
||||
state.done = 0;
|
||||
state.result = 0;
|
||||
state.lastActivity = 0;
|
||||
int result = 0;
|
||||
int requestId = 0;
|
||||
char* headerCopy = NULL;
|
||||
void* request = NHTTPCreateRequestEx(url, method, NULL, 0, __nupNhttpReqDone, &state, __nupNhttpBufFull, __nupNhttpBufFree);
|
||||
if (request == NULL) { result = -7000 - NHTTPGetError(); goto cleanup; }
|
||||
if (NHTTPSetSocketBufferSize(request, 0x8000) != 0) { result = -7000 - NHTTPGetError(); goto cleanup; }
|
||||
if (headers != NULL) {
|
||||
unsigned long size = strlen(headers) + 1;
|
||||
headerCopy = (char*)nup::__nupMalloc(size);
|
||||
if (headerCopy == NULL) { result = -5000; goto cleanup; }
|
||||
memcpy(headerCopy, headers, size);
|
||||
char* field = headerCopy;
|
||||
while (*field != 0) {
|
||||
char* colon = strchr(field, ':');
|
||||
if (colon == NULL) break;
|
||||
char* end = strstr(colon, "\r\n");
|
||||
if (end == NULL) break;
|
||||
*colon = 0;
|
||||
*end = 0;
|
||||
while (*field && isspace(*field)) field++;
|
||||
do { colon++; } while (*colon && isspace(*colon));
|
||||
if (NHTTPAddHeaderField(request, field, colon) != 0) { result = -7000 - NHTTPGetError(); goto cleanup; }
|
||||
field = end + 2;
|
||||
}
|
||||
}
|
||||
if (NHTTPAddHeaderField(request, "Accept", "text/html, image/gif, image/jpeg, */*") != 0) { result = -7000 - NHTTPGetError(); goto cleanup; }
|
||||
if (NHTTPAddHeaderField(request, "Content-type", "text/xml; charset=utf-8") != 0) { result = -7000 - NHTTPGetError(); goto cleanup; }
|
||||
if (NHTTPAddHeaderField(request, "Connection", "Keep-Alive") != 0) { result = -7000 - NHTTPGetError(); goto cleanup; }
|
||||
if (NHTTPSetClientCertDefault(request) != 0) { result = -7000 - NHTTPGetError(); goto cleanup; }
|
||||
if (NHTTPSetRootCADefault(request) != 0) { result = -7000 - NHTTPGetError(); goto cleanup; }
|
||||
if (NHTTPSetVerifyOption(request, 11) != 0) { result = -7000 - NHTTPGetError(); goto cleanup; }
|
||||
NHTTPSetProxyDefault(request);
|
||||
if (method == NHTTP_POST && body != NULL && bodyLength != 0 && NHTTPAddPostDataRaw(request, body, bodyLength) != 0) { result = -7000 - NHTTPGetError(); goto cleanup; }
|
||||
requestId = NHTTPSendRequestAsync(request);
|
||||
if (requestId < 0) {
|
||||
int error = NHTTPGetError();
|
||||
NHTTPDeleteRequest(request);
|
||||
result = -7000 - error;
|
||||
goto cleanup;
|
||||
}
|
||||
state.lastActivity = OSGetTime();
|
||||
for (;;) {
|
||||
if (NHTTPGetProgress(&expected, &transferred) != 0 && state.done != 0) {
|
||||
if (state.result != 0) { result = -7000 - state.result; goto cleanup; }
|
||||
if (state.response != NULL) {
|
||||
length = NHTTPGetBodyAll(state.response, &responseBody);
|
||||
if (length < 0) { result = -5007; goto cleanup; }
|
||||
__nupNhttpBufFull(&responseBody, (unsigned long*)&length, 0, NULL, NULL, &state);
|
||||
}
|
||||
result = state.error;
|
||||
if (result != 0 || state.response == NULL) goto cleanup;
|
||||
length = NHTTPGetHeaderAll(state.response, &responseHeaders);
|
||||
if (length < 0) { result = -5007; goto cleanup; }
|
||||
char* protocol = strstr(responseHeaders, "HTTP/");
|
||||
if (protocol != NULL && sscanf(protocol, "HTTP/%*d.%*d %d", &status) == 1) {
|
||||
if (status != 200 && status != 202) result = -5000 - status;
|
||||
goto cleanup;
|
||||
}
|
||||
result = -5007;
|
||||
goto cleanup;
|
||||
}
|
||||
if (OSGetTime() - state.lastActivity >= OSMillisecondsToTicks(90000)) break;
|
||||
NCDSleep(OSMillisecondsToTicks(100));
|
||||
}
|
||||
if (requestId >= 0) {
|
||||
NHTTPCancelRequestAsync(requestId);
|
||||
NCDSleep(OSMillisecondsToTicks(100));
|
||||
}
|
||||
result = -5009;
|
||||
cleanup:
|
||||
if (state.response != NULL || result == -5009) NHTTPDestroyResponse(state.response);
|
||||
if (headerCopy != NULL) nup::__nupFree(headerCopy);
|
||||
return result;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
static long __nupHttpStringFlush(u8* data, unsigned long length, unsigned long requested, void* context) {
|
||||
HttpString* text = (HttpString*)context;
|
||||
unsigned long total;
|
||||
total = length + text->length;
|
||||
long result = 0;
|
||||
if (total > text->capacity) {
|
||||
if (requested >= total) {} else {
|
||||
requested = text->growth + total;
|
||||
text->growth <<= 1;
|
||||
if (text->growth < text->maximumGrowth) {} else text->growth = text->maximumGrowth;
|
||||
}
|
||||
u8* next = (u8*)nup::__nupMalloc(requested);
|
||||
if (next == NULL) { result = -5000; goto done; }
|
||||
if (text->buffer != NULL) {
|
||||
memcpy(next, text->buffer, text->length);
|
||||
nup::__nupFree(text->buffer);
|
||||
}
|
||||
text->buffer = next;
|
||||
}
|
||||
memcpy(text->buffer + text->length, data, length);
|
||||
text->length += length;
|
||||
done:
|
||||
return result;
|
||||
}
|
||||
}
|
||||
static int __nupNhttpOpString(u8** output, unsigned long* outputLength, char* url, NHTTPReqMethod method, char* headers, u8* body, unsigned long bodyLength, unsigned long limit, ProgressCallback progress, void* context) NO_INLINE;
|
||||
static int __nupNhttpOpString(u8** output, unsigned long* outputLength, char* url, NHTTPReqMethod method, char* headers, u8* body, unsigned long bodyLength, unsigned long limit, ProgressCallback progress, void* context) {
|
||||
HttpString text;
|
||||
text.buffer = *output;
|
||||
text.capacity = *outputLength;
|
||||
text.growth = 0x400;
|
||||
text.maximumGrowth = 0x10000;
|
||||
text.length = 0;
|
||||
int result = __nupNhttpOp(url, method, headers, body, bodyLength, limit, progress, context, __nupHttpStringFlush, &text);
|
||||
if (result == 0) {
|
||||
*output = text.buffer;
|
||||
*outputLength = text.length;
|
||||
}
|
||||
if (result != 0) {
|
||||
if (text.buffer != NULL) nup::__nupFree(text.buffer);
|
||||
*output = NULL;
|
||||
*outputLength = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
int __nupHttpGetFull(char* url, u8** output, unsigned long* length, unsigned long limit, ProgressCallback progress, void* context) {
|
||||
return __nupNhttpOpString(output, length, url, NHTTP_GET, NULL, NULL, 0, limit, progress, context);
|
||||
}
|
||||
int __nupHttpPostFull(char* url, char* headers, char* body, u8** output, unsigned long* length, unsigned long limit, ProgressCallback progress, void* context) {
|
||||
int result = __nupNhttpOpString(output, length, url, NHTTP_POST, headers, (u8*)body, strlen(body), limit, progress, context);
|
||||
if (result != 0) {
|
||||
if (*output != NULL) nup::__nupFree(*output);
|
||||
*output = NULL;
|
||||
*length = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
int __nupHttpGetIncr(char* url, unsigned long limit, ProgressCallback progress, void* progressContext, FlushCallback flush, void* context) {
|
||||
return __nupNhttpOp(url, NHTTP_GET, NULL, NULL, 0, limit, progress, progressContext, flush, context);
|
||||
}
|
||||
116
libs/RVL_SDK/src/vi/i2c.c
Normal file
116
libs/RVL_SDK/src/vi/i2c.c
Normal file
@@ -0,0 +1,116 @@
|
||||
#include <revolution/os.h>
|
||||
#include <private/os/OSTime.h>
|
||||
#include <private/bus.h>
|
||||
|
||||
static int __i2c_ident_flag = 1;
|
||||
static u32 __i2c_ident_first;
|
||||
|
||||
#define I2C_OUT 0xCD8000C0
|
||||
#define I2C_DIR 0xCD8000C4
|
||||
#define I2C_IN 0xCD8000C8
|
||||
|
||||
static inline void delay(void) {
|
||||
OSTime start = __OSGetSystemTime();
|
||||
while (OSTicksToMicroseconds(__OSGetSystemTime() - start) < 2) {}
|
||||
}
|
||||
|
||||
static inline void setData(int high) {
|
||||
if (high) {
|
||||
if (__i2c_ident_flag == 0) {
|
||||
BUSWrite32(I2C_OUT, BUSRead32(I2C_OUT) & ~0x8000);
|
||||
} else {
|
||||
BUSWrite32(I2C_OUT, (BUSRead32(I2C_OUT) & ~0x8000) | 0x8000);
|
||||
}
|
||||
} else {
|
||||
if (__i2c_ident_flag == 0) {
|
||||
BUSWrite32(I2C_OUT, (BUSRead32(I2C_OUT) & ~0x8000) | 0x8000);
|
||||
} else {
|
||||
BUSWrite32(I2C_OUT, BUSRead32(I2C_OUT) & ~0x8000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int sendSlaveAddr(u8 address) {
|
||||
int bit;
|
||||
if (__i2c_ident_flag == 0) {
|
||||
BUSWrite32(I2C_OUT, (BUSRead32(I2C_OUT) & ~0x8000) | 0x8000);
|
||||
} else {
|
||||
BUSWrite32(I2C_OUT, BUSRead32(I2C_OUT) & ~0x8000);
|
||||
}
|
||||
delay();
|
||||
BUSWrite32(I2C_OUT, BUSRead32(I2C_OUT) & ~0x4000);
|
||||
for (bit = 0; bit < 8; bit++) {
|
||||
setData(address & 0x80);
|
||||
delay();
|
||||
BUSWrite32(I2C_OUT, (BUSRead32(I2C_OUT) & ~0x4000) | 0x4000);
|
||||
delay();
|
||||
BUSWrite32(I2C_OUT, BUSRead32(I2C_OUT) & ~0x4000);
|
||||
address = (address & 0x7F) << 1;
|
||||
}
|
||||
BUSWrite32(I2C_DIR, (BUSRead32(I2C_DIR) & ~0x8000) | 0x4000);
|
||||
delay();
|
||||
BUSWrite32(I2C_OUT, (BUSRead32(I2C_OUT) & ~0x4000) | 0x4000);
|
||||
delay();
|
||||
if ((u32)__i2c_ident_flag == 1) {
|
||||
if ((BUSRead32(I2C_IN) >> 15) & 1) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
setData(0);
|
||||
BUSWrite32(I2C_DIR, (BUSRead32(I2C_DIR) & ~0x8000) | 0xC000);
|
||||
BUSWrite32(I2C_OUT, BUSRead32(I2C_OUT) & ~0x4000);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int __VISendI2CData(u8 address, u8* data, int length) {
|
||||
int enabled;
|
||||
if (__i2c_ident_first == 0) {
|
||||
__i2c_ident_flag = 1;
|
||||
__i2c_ident_first = 1;
|
||||
}
|
||||
enabled = OSDisableInterrupts();
|
||||
BUSWrite32(I2C_DIR, (BUSRead32(I2C_DIR) & ~0x8000) | 0xC000);
|
||||
BUSWrite32(I2C_OUT, (BUSRead32(I2C_OUT) & ~0x4000) | 0x4000);
|
||||
setData(1);
|
||||
delay();
|
||||
delay();
|
||||
if (!sendSlaveAddr(address)) {
|
||||
OSRestoreInterrupts(enabled);
|
||||
return 0;
|
||||
}
|
||||
BUSWrite32(I2C_DIR, (BUSRead32(I2C_DIR) & ~0x8000) | 0xC000);
|
||||
while (length != 0) {
|
||||
int bit;
|
||||
u8 value = *data++;
|
||||
for (bit = 0; bit < 8; bit++) {
|
||||
setData(value & 0x80);
|
||||
delay();
|
||||
BUSWrite32(I2C_OUT, (BUSRead32(I2C_OUT) & ~0x4000) | 0x4000);
|
||||
delay();
|
||||
BUSWrite32(I2C_OUT, BUSRead32(I2C_OUT) & ~0x4000);
|
||||
value = (value & 0x7F) << 1;
|
||||
}
|
||||
BUSWrite32(I2C_DIR, (BUSRead32(I2C_DIR) & ~0x8000) | 0x4000);
|
||||
delay();
|
||||
BUSWrite32(I2C_OUT, (BUSRead32(I2C_OUT) & ~0x4000) | 0x4000);
|
||||
delay();
|
||||
if ((u32)__i2c_ident_flag == 1) {
|
||||
if ((BUSRead32(I2C_IN) >> 15) & 1) {
|
||||
OSRestoreInterrupts(enabled);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
setData(0);
|
||||
BUSWrite32(I2C_DIR, (BUSRead32(I2C_DIR) & ~0x8000) | 0xC000);
|
||||
BUSWrite32(I2C_OUT, BUSRead32(I2C_OUT) & ~0x4000);
|
||||
length--;
|
||||
}
|
||||
BUSWrite32(I2C_DIR, (BUSRead32(I2C_DIR) & ~0x8000) | 0xC000);
|
||||
setData(0);
|
||||
delay();
|
||||
BUSWrite32(I2C_OUT, (BUSRead32(I2C_OUT) & ~0x4000) | 0x4000);
|
||||
delay();
|
||||
setData(1);
|
||||
OSRestoreInterrupts(enabled);
|
||||
return 1;
|
||||
}
|
||||
@@ -85,4 +85,130 @@ Seven functions have exact instructions after using a byte for the initializatio
|
||||
2. Initialize fallbacks after the single-character case and load the second character inside the matching condition: 91/90.
|
||||
3. A moving mapping pointer: 91/90 with more register differences. Restored variant two. The original reads an unset fallback register on invalid input; this source deliberately initializes that fallback rather than adding an uninitialized value to obtain a match.
|
||||
|
||||
Not attempted: vi/i2c, nup/nup_nhttp, axfx/AXFXChorusExp, and all eight requested eZiText units. This is a partial batch, not completion.
|
||||
The continuation below attempts the eleven previously skipped units.
|
||||
|
||||
## Continuation at dcc384b7
|
||||
|
||||
vi/i2c, sendSlaveAddr and __VISendI2CData:
|
||||
1. Inlined clock/data/delay helpers, signed flags and combined ACK condition: 236/237 and 371/372 instructions; initial data polarity and ACK shifts differed.
|
||||
2. Correct initial polarity, unsigned flags and explicit ACK bit shift: same counts; only ACK flag reuse and its dependent branches remain.
|
||||
3. Nested ACK condition: same counts and differences.
|
||||
4. Expanded data helper into source blocks: same counts and differences; restored readable helper.
|
||||
5. Signed flag with unsigned ACK comparison: same counts; original reloads the flag after GPIO sampling, compiler retains it. No artificial volatile/barrier added. Pools identical; data 16/16.
|
||||
|
||||
nup/nup_nhttp:
|
||||
- BufFull: direct nested translation 94/97; invert limit branch and use explicit valid-request branch 94/97; nested overflow test 94/97. Residual redundant branches, comparison orientation and error-zero store.
|
||||
- Op: direct cleanup-label translation 341/348; correct NHTTPCreateRequestEx to ten actual arguments and preserve OpString call 339/348; reorder status/state declarations 339/348, stack locals and register/control-flow differences remain. Pool identical.
|
||||
- StringFlush: direct growth calculation 55/56; invert capacity/growth comparisons 55/56; reverse sum operand order 55/56, extra target branch and registers remain.
|
||||
- OpString: direct else produced 55/56; preserve call with NO_INLINE; separate error if gives 56/56 exact. GetFull and PostFull also exact after preserving the call. BufFree, ReqDone and GetIncr exact.
|
||||
|
||||
axfx/AXFXChorusExp:
|
||||
- Init and Settings: inline shutdown helper initially swapped saved mask/counter; change shutdown declaration order fixes Init; OR-before-AND active bits fixes Settings, both exact. GetMemSize exact; the declaration change leaves Shutdown with a register permutation.
|
||||
- Callback: direct three-channel implementation 216/216, 78 differences; reverse array declarations and unsigned distance shift 216/216, 70 differences; unsigned distance variable 216/216, same remaining allocation/scheduling differences.
|
||||
- InitParams: direct formulas 126/126, 56 differences; invert depth comparison and initialize LFO state before conversion formulas 126/126, 55 differences; explicit rateStep temporary leaves floating scheduling/register differences. No data placement: ordinary literal constants yield all 48 data bytes exact.
|
||||
- CalcLFO: signed 64-bit shift 51/65; explicit high/low shift expression 51/65; union product words 57/65 adds stack stores, worse; restore scalar product, invert phase branch and derive table index from masked phase 51/65. Target uses generic signed multiply corrections; ours uses mulhw. All real algorithms retained.
|
||||
|
||||
## eZiText continuation
|
||||
|
||||
All eight expected source paths were absent and have now been implemented. These units use the existing unoptimized compiler settings. The following are distinct source experiments, not exact-match claims.
|
||||
|
||||
zoemdata:
|
||||
- MatchOEMdata: structured early returns produced 196/192 instructions; decrement the capacity parameter rather than a maximum temporary produced 194/192; share the no-match exit produced 189/192. Pointer-zero comparisons retained that count. Remaining stack, register and branch differences. Attach and Detach exact after inverting the detach rejection condition.
|
||||
|
||||
zidawg1:
|
||||
- GetChild: u16 header and separate offset expression 68/68; u32 header with combined offset 65/68; restore u16 and reorder long offset 68/68, 93.29 percent.
|
||||
- GetSibling: u16 header and zero-bit outer branch 127/131; u32 header changed masks and reduced instructions; restore u16 and reverse outer cases 127/131, 81.58 percent.
|
||||
- GetCHAR: combined attributes 59/60; reverse key/attribute declarations and mask 60/60; sequential OR/add 60/60, 95.5 percent, remaining registers.
|
||||
- GetGraphInfo: original field translation 134/134; reorder declarations 134/134; typed context and combined pair shift 134/134, 80.77 percent, remaining stack/register differences.
|
||||
- EOW: nonzero expression, explicit repeated mask and local mask differed; positive mask test exact. Graph: direct offset, local table and reordered table variants differed; addition grouped with the table base exact.
|
||||
|
||||
ziswordw:
|
||||
- IsWordW: aggregate search initialization and packed byte fields introduced a frame pointer; explicit six-word initialization removed aggregate copying; move the unmatched counter to function scope produced 423/416, 71.03 percent. Removed an unused seventh search-state field after checking the original six initialized words; the final full gate gives 71.08414 percent. Default format array corrected to the original ordinary eight bytes.
|
||||
- ConvertUC2UserKey: initial pointer/character tests 88/91; zero-pointer tests and explicit halfword character casts 89/91; inclusive key bounds 89/91, 97.69 percent. Remaining branches/registers.
|
||||
|
||||
zi8pud2:
|
||||
- SetPDremoveOpt: initialized byte previous option 21/21; separate declaration/assignment unchanged; word previous option added a return mask. Restored byte, 98.57 percent, saved-register assignment differs.
|
||||
- MatchPUDdata_ZHS: direct typed dictionary traversal 72.45 percent; split normalization and reverse threshold branch 72.16 percent; word return type with explicit final byte-length conversion removes an implicit caller mask. Remaining control-flow and register differences.
|
||||
- MatchPUDdata: byte return with early exit 52/50; break and next-dictionary block 53/50; word return and function-scope locals 53/50; assignment condition instead of next-dictionary temporary 52/50. Remaining redundant branches and masks.
|
||||
- Phonetic helper: positive branch, negative branch and word return type; final exact. Word-size helper: combined loop, explicit inner test, function-scope cursor and for initialization; final exact. Copy helper: divided index, shifted index, typed cursor and positive size branch; final exact. Dictionary-length helper exact.
|
||||
|
||||
zconvert:
|
||||
- UC2WC: native dynamic halfword fields 101/124; serialized byte fields and reversed default branch 123/124; capture default unicode pointer before error call 124/124, 99.68 percent. Remaining cyclic saved-register assignment.
|
||||
- WC2UC: native dynamic fields and pointer-entry default test 179/199; byte fields and branch inversion 201/199; recovered default header address check and range snapshot 189/199, 77.70 percent. Remaining control flow and scheduling.
|
||||
- UC2Key: initial dynamic fields 186/207; serialized fields and branch inversion 207/207; recovered default header address and captured range pointer 200/207, 83.90 percent. Original empty default header exists even when its entries pointer is zero.
|
||||
- WC2Key: temporary conversion added instructions; nested conversion call gives 22/22 exact. All conversion tables are ordinary typed zero initializers.
|
||||
|
||||
zmtkey:
|
||||
- GetKeyLayout: byte tables and halfword count 182/182, four differences; word count eliminates sth but introduces stw/mask and regresses two exact functions; reuse the character count retains four differences. Restored the halfword-count version and all three exact functions. Remaining count storage/register choice.
|
||||
|
||||
zi8uwd:
|
||||
- Attach: early rejection and combined comparison loop 116/116, 90.47 percent; reordered position, bounded length and explicit inner break 117/116; split insertion counter updates 117/116, 97.24 percent. Remaining extra comparison and saved registers.
|
||||
- MatchUWDdata: typed ring traversal 61.84 percent; capture visited index before filtering and reverse fallback 60.95 percent; segment endpoint conditional in ring loop remains 60.95 percent. Remaining shared-return control flow and stack/register differences.
|
||||
- Pop: zero-first branch differed; reverse count branch exact. Clear: byte memset fill added mask; word fill exact.
|
||||
|
||||
zprepare:
|
||||
- PrepareMatch: typed request/match translation 1062/940, 58 percent, missing switch table; word memset argument, native component stores and wildcard loop with break 1047/940; explicit dense gap cases and word computational nibble count 1019/940, 64.76 percent. Compiler now emits the ordinary 48-byte switch table. Remaining stack, loop, branch and register differences.
|
||||
|
||||
## Fresh attempts on the first eight units
|
||||
|
||||
USBAPThread::Init:
|
||||
1. Unsigned priority: 32/32, the same two immediate-load differences.
|
||||
2. Separate current-thread pointer and priority increment: unchanged.
|
||||
3. Named null callback argument: unchanged. Restored the existing source, 99.6875 percent.
|
||||
|
||||
USBAP::DoRegistration:
|
||||
1. Declare failed before found: 161/161, 35 differences.
|
||||
2. Use the existing registered pointer for insertion: 159/161.
|
||||
3. While-form address lookup: 161/161, 35 differences. Restored the existing source, 98.72671 percent; remaining registers and scheduling.
|
||||
|
||||
SensitivityDrawing::draw constant data:
|
||||
1. Move background initialization after scales: 278/278, 41 differences; colors still precede floating constants.
|
||||
2. Compute both texture scales once from the projection before background: 277/278, floats partly reorder but colors still first.
|
||||
3. Compute horizontal texture scale first: 277/278 and different float ordering. Restored exact instructions; the original 56-byte constant section still differs from the compiler's 48-byte section. No placement objects added.
|
||||
|
||||
RakuRakuThread::start:
|
||||
1. Declare socket config before interrupt mask: 97/96.
|
||||
2. Explicit progress pointer: 97/96.
|
||||
3. Separate thread and priority locals: 97/96. Restored existing source, 88.635414 percent; additional global address generation remains.
|
||||
|
||||
RakuRakuThread::finish:
|
||||
1. Direct terminal-state tests: 138/133.
|
||||
2. Unsigned key-loop counters: 135/133.
|
||||
3. Advance typed WEP source pointers: 133/133, 116 differences, 81.1203 percent. Restored the better existing 86.56391 percent source; global address generation and register allocation remain.
|
||||
|
||||
AOSSi_WLANGetBSSList:
|
||||
1. Reverse scan/info declaration order: 227/227, 202 differences.
|
||||
2. Separate retry increment from comparison: unchanged.
|
||||
3. Traverse rates using a typed rate pointer: initially rejected for a C89 declaration after statements; moving it to the block declarations gives 225/227. Restored the existing 81.14978 percent source, with stack/register and scheduling differences.
|
||||
|
||||
AOSSi_WLANConnect:
|
||||
1. Declare result before retries: 156/155.
|
||||
2. Reuse interface pointer for NCDSetIfConfig: 155/155, 98 differences, 95.090324 percent.
|
||||
3. Combine cancellation and timeout rejection: 154/155. Restored existing 96.12258 percent source; pointer lifetimes and branches remain.
|
||||
|
||||
nup_mem::__nupRegisterAllocator:
|
||||
1. Early null return: 17/19.
|
||||
2. Positive validity branch: 19/19, 14 differences; compiler emits a Boolean value rather than repeated magic loads.
|
||||
3. Typed heap and early invalid return: 14/19. Restored existing 89.47369 percent source; target repeats the magic load that this compiler removes.
|
||||
|
||||
KPRProcessAltKeypad:
|
||||
1. Leading flag before accumulator: 96/96, 15 differences, improves from 25.
|
||||
2. Explicit digit temporary: initially rejected for C89 declaration placement; function-block declaration gives 96/96, 25 differences.
|
||||
3. While insertion loop: 96/96, 25 differences.
|
||||
4. Derive high flag after masking through a raw value: 96/96, 25 differences.
|
||||
5. Declare insertion pointer before index: 96/96, seven differences, 99.635414 percent; retained with the leading-flag variation.
|
||||
6. Combine raw mask ordering with insertion ordering: 96/96, 21 differences. Remaining seven differences are register assignments.
|
||||
|
||||
KPRProcessDeadKeys:
|
||||
1. Initialize fallback declarations before single-character branch: 92/90.
|
||||
2. Capture the second character per iteration: 88/90.
|
||||
3. Typed current mapping entry: 87/90. Restored existing 97.388885 percent source, with its safe fallback initialization and one extra instruction. No uninitialized matching trick introduced.
|
||||
|
||||
kbd_lib_map_us has no non-exact functions; its one function and all 3240 data bytes remain exact.
|
||||
|
||||
AXFXChorusExpShutdown additional attempts:
|
||||
1. Signed channel index: 36/36, five register differences.
|
||||
2. Clear via a typed channel pointer: 36/36, same five differences.
|
||||
3. Explicit null/free branches: 38/36. Restored the variant that preserves exact Init and Settings; Shutdown remains 99.166664 percent.
|
||||
|
||||
All nineteen requested units now have implementations and measured attempts. Remaining functions and data are partial matches, not completion.
|
||||
|
||||
Reference in New Issue
Block a user