Compare commits

..

255 Commits

Author SHA1 Message Date
coah
176208ed7d cleanup(www_surface): name CreateManager arcPath parameter
Align the header parameter with the Matching implementation name.
2026-10-01 17:14:31 -05:00
coah
2368a9a774 cleanup(tiHwKeyboard): name EU/non-EU country map tables (#515)
Rename Matching-only setLanguage country lookup tables and
symbols.txt entries.
2026-10-01 17:13:57 -05:00
coah
90399bb6cf cleanup(iplDate): name calendar date pane/string labels (#518)
Matching-only renames in scene/calendar/iplDate (+ symbols.txt).
2026-10-01 17:13:54 -05:00
coah
fc831357ea CDBDatabase: convert Close and FindByKey to matching C (#491)
* CDBDatabase: convert Close and FindByKey to matching C

Replace asm bodies for CDBDatabaseClose and CDBDatabaseFindByKey with
equivalent C that matches instruction-exact (ctxdiff diffs 0). Unit stays
33/33 matched with 100% code and data.

* CDBDatabase: reuse labeled error strings for Close/FindByKey

Point CDBReportError at the existing lbl_ string pool entries so the
linked DOL matches baserom SHA1 26116613f624061ba99c8d1a299aaa6efa85670d.
2026-10-01 17:13:50 -05:00
coah
e2191ae933 cleanup(TVRC): name timing constants and file header (#509)
lbl_816945C8/D0/D8/E0 → scTvrcMsPerSec/NsecPerSec/One/FloatMagic;
lbl_81696230 → scTvrcFileHeader ("TVR0").
2026-10-01 17:11:51 -05:00
coah
7d77c095c0 cleanup(iplSystem): name ortho viewport float constants (#508)
lbl_81694424..38 → scOrthoLeft/Right/Bottom/Top and scWideOrthoLeft/Right.
2026-10-01 17:10:58 -05:00
coah
db8ff7e141 cleanup(www_window): name debug/error format strings (#507)
lbl_816962F8 → scWwwErrorQ, lbl_81643B40 → scWwwTexBufFmt,
lbl_81643B5E → scWwwNoBrowserWin.
2026-10-01 17:10:19 -05:00
github-actions[bot]
2cb6c2dfae docs: update progress [skip ci] 2026-10-01 22:09:43 +00:00
coah
6f96235605 cleanup(tiGUIManager): name sdata2 zero/half/line-color constants (#506)
lbl_81694EE8 → scGuiZeroF, lbl_81694EF0 → scGuiHalfF,
lbl_81694EEC..F → scGuiLineColorR/G/B/A.
2026-10-01 17:09:30 -05:00
coah
367b042e63 Restore memo input vtable declarations and emission order (#505) 2026-10-01 17:08:19 -05:00
coah
feb7ba400d cleanup(Contest): rename NHTTP callback error; drop dead locals (#504)
param_1 → error in sNHTTPReqCallback; remove unused Ghidra locals
from IPLContestInitialize.
2026-10-01 17:07:39 -05:00
coah
20f4af8beb cleanup(NakamuraTest): rename Ghidra locals (#503)
iVar8 → nupResult, iVar7 → startupErr; drop unused iVar1 in conntestthread.
2026-10-01 17:06:56 -05:00
coah
dca6cd9aef cleanup(HermiteIntp): name start/end tangents (#502)
Rename Ghidra param_5/param_6 and unkVal0/unkVal1 to startTangent/endTangent
and mStartTangent/mEndTangent across the HermiteIntp header and users.
2026-10-01 17:05:40 -05:00
coah
a0700bf908 cleanup(NetSetup): rename param_1 → connType (#501)
iSOStartupEXThread arg is mConnType (passed to NETGetStartupErrorCodeEx).
2026-10-01 17:04:56 -05:00
coah
de058b4298 cleanup(NCDSetting): rename uVar1 → privacyMode (#500)
Local mapped privacy mode in setWDPrivacyMode; Matching-only rename.
2026-10-01 17:04:38 -05:00
github-actions[bot]
c5468cbe50 docs: update progress [skip ci] 2026-10-01 22:04:12 +00:00
coah
62591733eb cleanup(BoardObject): rename local_28 → truncatedThumb (#499)
Local wchar temporary used when truncating thumbnail text; Matching-only rename.
2026-10-01 17:03:10 -05:00
coah
e2488b073a cleanup: rename OptOutButton pane name strings (#498)
Rename lbl_816966F9/lbl_816967B5 to scPaneName_B_Stop/T_Stop.
DOL sha1 unchanged.
2026-10-01 17:02:53 -05:00
coah
9a8de22195 Link fully matched letter input form (#497) 2026-10-01 17:01:45 -05:00
coah
a6bf0e5f4f cleanup: rename AOSSThread SO alloc/free callbacks (#495)
Rename AOSSThread_813FCC8C/E4 to aossAlloc/aossFree. DOL sha1 unchanged.
2026-10-01 17:00:23 -05:00
coah
d434f5b897 cleanup: rename CdbBackup progress percent helper (#494)
Rename fn_8135B1C0 to getProgressPercent. DOL sha1 unchanged.
2026-10-01 17:00:18 -05:00
github-actions[bot]
0adc759b42 docs: update progress [skip ci] 2026-10-01 21:58:44 +00:00
coah
9c55b47c1d Emit hardware keyboard country tables after input template (#493) 2026-10-01 16:57:52 -05:00
coah
081329daa8 cleanup: rename TVRCManager start-delay counter (#492)
Rename lbl_8169877C to sTvrcStartDelay. DOL sha1 unchanged.
2026-10-01 16:57:46 -05:00
coah
a348c9777a cleanup: rename HBMController alarm-created flag (#490)
Rename lbl_816989BC to sAlarmCreated. DOL sha1 unchanged.
2026-10-01 16:55:12 -05:00
github-actions[bot]
d5204f5c62 docs: update progress [skip ci] 2026-10-01 21:54:05 +00:00
coah
cedc1f1390 cleanup: rename SaveDataManager title-cache helpers (#488)
Rename address-suffixed title-cache helpers to readable names without
changing codegen. DOL sha1 unchanged.
2026-10-01 16:54:01 -05:00
coah
ff0cce33f6 Correct concatenated cursor-cache method symbol (#487) 2026-10-01 16:53:27 -05:00
github-actions[bot]
2beeb23a47 docs: update progress [skip ci] 2026-10-01 21:53:24 +00:00
coah
35d9ed53b1 Fix letter animation rodata ownership boundary (#486) 2026-10-01 16:52:47 -05:00
coah
015d50906c Match tiTextDrawer Base::beginDraw height half via / 2.0f (#485)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: coah <coah80@users.noreply.github.com>
2026-10-01 16:52:23 -05:00
github-actions[bot]
348da5bd89 docs: update progress [skip ci] 2026-10-01 21:52:04 +00:00
coah
cdceb82200 tiInputForm 214/221, 3 asm bodies left (worker 756360e6) (#489) 2026-10-01 16:50:38 -05:00
coah
1b56ea5051 Fix Korean jump-table ownership and link zikorean (#483)
* Correct Korean jump-table ownership and link the exact unit

* Correct Korean jump-table ownership and link the exact unit
2026-10-01 16:50:22 -05:00
coah
3946983f96 KPAD 19/29, kbd_lib 15/21 (objdiff) (worker 2ecd44fa) (#482) 2026-10-01 16:29:36 -05:00
github-actions[bot]
85d75cd0cf docs: update progress [skip ci] 2026-10-01 21:27:27 +00:00
coah
af39f2678f Match SD disk-info success return and restore its epilogue extent (#481)
* Restore the SD disk-info function's original epilogue extent

* Match explicit SD disk-info success return and update code total

* Match explicit SD disk-info success return and update code total
2026-10-01 16:26:40 -05:00
github-actions[bot]
d613662c54 docs: update progress [skip ci] 2026-10-01 21:17:45 +00:00
coah
0e6e235004 Correct PFSYS_TimeStamp's truncated symbol extent (#479)
* Include original stack restore and return in PFSYS_TimeStamp extent

* Account for timestamp epilogue in verified code-byte total
2026-10-01 16:17:08 -05:00
coah
020e1b6f0b iplSetting 105/112 (worker e1b8983d) (#480) 2026-10-01 16:16:23 -05:00
coah
3440aab039 Handle objects without .data in pool_diff (#478)
* Treat absent .data sections as empty string pools

* Test absent and unequal string pools
2026-10-01 16:11:01 -05:00
coah
dab806eaa2 Correct the 43U completion guard's expected unit count (#477) 2026-10-01 16:10:57 -05:00
github-actions[bot]
f4fd16f88f docs: update progress [skip ci] 2026-10-01 21:04:39 +00:00
coah
3d8de1a356 Link the exact-matching NAND driver (#476)
* Link NAND driver with verified storage layout

* Link NAND driver with verified storage layout

* Link NAND driver with verified storage layout
2026-10-01 16:03:40 -05:00
coah
8e43db0528 tiInputForm 210/221 (+8 KB matched code) (worker dad5faf7) (#475) 2026-10-01 16:00:46 -05:00
coah
21c9b95b1b NWC24Download 23/30 (worker 58d80e3c) (#474) 2026-10-01 15:41:52 -05:00
coah
d4bdd3462c iplAddress 94/101 (worker 98388c1d) (#473) 2026-10-01 15:40:46 -05:00
coah
f7d81a0196 CHANSVm 220/233 (worker 2f51b24f) (#472) 2026-10-01 12:31:21 -05:00
coah
4f35874d02 fix: drop unreferenced lbl_ double pinned in iplMemoryCard (#471) 2026-10-01 10:55:24 -05:00
coah
0a5cbaf78e iplAddress 93/101 (worker 81732f71) (#470) 2026-10-01 10:53:32 -05:00
coah
6e7c016ae3 CHANSVm 218/233 (worker 19444f58) (#469) 2026-10-01 10:52:18 -05:00
github-actions[bot]
e60306db62 docs: update progress [skip ci] 2026-10-01 14:03:51 +00:00
devin-ai-integration[bot]
5d0ced6a15 Link scene/memoryCard/iplMemoryCardBase (clean subset) (#468)
Gate Rect.~Rect and RuntimeTypeInfo.DynamicCast behind
IPL_MEMORYCARD_BASE_CPP so this TU emits the weak destructors and the
out-of-line dynamic cast the original object contains.

Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: coah80 <usernamecole7@gmail.com>
2026-10-01 14:03:09 +00:00
github-actions[bot]
858a507ddf docs: update progress [skip ci] 2026-10-01 12:54:41 +00:00
devin-ai-integration[bot]
ce424f1a3e Link scene/memoryCard/iplMemoryCard (clean subset) (#467)
Model MemCardEventListener as a novtable abstract base and give
MemCardEventHandler its full pure-virtual surface so the GCWindow and
MemoryCardManager vtables reproduce the original zero-slot layout.
Declare lbl_81694A78 as a file-scope const so the object exports the
u64->f64 conversion constant that iplMemoryCardBase.o references.

Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: coah80 <usernamecole7@gmail.com>
2026-10-01 12:54:08 +00:00
github-actions[bot]
bcb37e07ef docs: update progress [skip ci] 2026-10-01 11:41:02 +00:00
devin-ai-integration[bot]
11094c638a Link clib/zi8cinfo (#466)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-10-01 11:40:25 +00:00
coah
cb49bde9c6 NWC24Download 21/30 (worker b7c38d52) (#465) 2026-10-01 05:43:26 -05:00
coah
df9fd72e87 iplAddress 91/101, tiZiString 26/29 (worker 5e1635f3) (#464) 2026-10-01 05:37:54 -05:00
coah
0c554a1602 CHANSVm 217/233 (worker e7171d72) (#463) 2026-10-01 05:08:52 -05:00
coah
f00336cc8b NWC24Download 19/30, nup 18/23 (worker 1ac4946e) (#462) 2026-10-01 05:07:41 -05:00
coah
842bbc6942 tiCandidateBox 108/112, iplSDChannelSelect 117/129 (worker 993eabbf) (#461) 2026-10-01 05:06:29 -05:00
coah
ab01520044 CHANSVm: small fuzzy gains (worker b60f5370) (#460) 2026-10-01 03:31:36 -05:00
coah
5f948d3f3a AOSS 96.8, zi8alpha 94.2 (worker 5906998c) (#459) 2026-10-01 03:26:27 -05:00
coah
699f844395 CHANSVm 216/233 (worker b8f00dfb) (#458) 2026-10-01 03:05:28 -05:00
coah
3afb9d8425 iplSDChannelSelect 116/129, tiCandidateBox 104/112 (worker f7b4ed19) (#457) 2026-10-01 02:58:57 -05:00
coah
72c3f4ba2d zi8cgetc: tiny gains (worker 4e5688ba) (#456) 2026-10-01 02:45:50 -05:00
coah
905c45b998 AOSS 96.5, zi8alpha 93.1 (worker 58992861) (#455) 2026-10-01 02:41:34 -05:00
coah
5a849425b1 zi8cgetc: GetZH fuzzy 85 -> 96.4% (worker 68034ea8) (#454) 2026-10-01 02:16:35 -05:00
coah
fd11ddb195 AOSS fuzzy 96.3 (worker fc04bcfa) (#453) 2026-10-01 02:03:34 -05:00
coah
d9b51418b9 CHANSVm: blob unpack, hmac, slice, float parse (worker e953cfc4) (#452) 2026-10-01 02:02:26 -05:00
coah
87e7ab6922 iplSDChannelSelect, tiCandidateBox: structural fixes (worker d5dcdbc0) (#451) 2026-10-01 02:01:17 -05:00
github-actions[bot]
d186251506 docs: update progress [skip ci] 2026-10-01 05:27:53 +00:00
devin-ai-integration[bot]
cb58211725 Link cdb/CDBIntArray (#450)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-10-01 05:27:17 +00:00
github-actions[bot]
2dbf80c418 docs: update progress [skip ci] 2026-10-01 04:38:36 +00:00
devin-ai-integration[bot]
faee1f779d Link fa msc units + msc_drv (#449)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-10-01 04:37:58 +00:00
github-actions[bot]
a324e9a843 docs: update progress [skip ci] 2026-10-01 04:37:27 +00:00
devin-ai-integration[bot]
2bddfcde52 Link pfk_api, pfd_cmn, pf_cp932, pf_fat16, pf_stub (#448)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-10-01 04:36:51 +00:00
coah
776b7981df declsearch tool; odh/wad/KPAD/pf_dir closer (worker 8e7ae0d1) (#447) 2026-09-30 22:42:40 -05:00
coah
539693c76a AOSS fuzzy 88 -> 95, zi8alpha 93 (worker 3d36d663) (#446) 2026-09-30 22:25:48 -05:00
coah
3134c4c05a zi8cgetc: GetZH 81 -> 83% (worker ca7cac87) (#445) 2026-09-30 22:18:17 -05:00
coah
d60d10868a asm to C: CDBDatabase 33 -> 15 asm bodies, iplSound 14 -> 3 (worker d04fb346) (#444) 2026-09-30 22:16:35 -05:00
coah
735b0ab878 odh 22/28 (idct_fast, fdct_fast, LineDeconv* exact) (worker 8060e828) (#443) 2026-09-30 22:15:03 -05:00
coah
ea8d4d3b8a zi8cgetc: GetZH instruction count now matches (deficit 0), 81.4% (worker 04fae432) (#442) 2026-09-30 21:36:48 -05:00
coah
7329402a2c BS2Mach 24/29: NAND state globals volatile at definition (worker ddd698b1) (#441) 2026-09-30 21:34:55 -05:00
coah
e46168062b kbd_lib: kbdProcMod 63 -> 99.9%, data 100% (worker aef57ff5) (#440) 2026-09-30 21:27:26 -05:00
coah
b2074a70d7 regalloc sweep 2: CDBRecord 27/29 (worker 03558e7c) (#439) 2026-09-30 21:24:09 -05:00
coah
98648d19bb AOSS, zi8alpha: deficits shrinking (worker 59064877) (#438) 2026-09-30 21:00:22 -05:00
coah
d03219249b regalloc sweep: pf_dir 35/38, NWC24Mime 12/16 (worker edd57acb) (#437) 2026-09-30 20:50:49 -05:00
coah
3c23585249 zi8cgetc: GetZH deficit 78 -> 62 insns (worker 7d22ea37) (#436) 2026-09-30 20:44:21 -05:00
coah
b4745ba2da pf_path, iplAddressEdit closer (worker 1bceaa8f) (#435) 2026-09-30 20:36:41 -05:00
coah
fb3e7bd49a sub-90 functions: SDChannelSelect, AddressEdit closer (worker 35852f84) (#434) 2026-09-30 20:34:31 -05:00
coah
e34eac26ef ATERM/AOSS: small fuzzy gains (worker 52d046e2) (#433) 2026-09-30 20:29:11 -05:00
coah
565d039c01 zconvert 2/4 (worst 78 -> 99.6%) (worker 9f5c4222) (#432) 2026-09-30 20:27:10 -05:00
coah
46d7bc07cf wad: small fuzzy gains (worker ca7a1e52) (#431) 2026-09-30 20:18:01 -05:00
coah
6ec48a1b9a TMC_JPEG: RGB565 6/13 (worker c0724c9e) (#430) 2026-09-30 20:01:28 -05:00
coah
07b3a2b579 ATERM 14/26 (fuzzy 92 -> 96) (worker 8f2e6497) (#429) 2026-09-30 19:59:08 -05:00
coah
e1b46d09e8 wad 34/40 (worker cfd01890) (#428) 2026-09-30 19:48:56 -05:00
coah
a4d46cf340 NWC24Download 18/30, iplSetting 105/112 (worker 363488f7) (#427) 2026-09-30 19:44:27 -05:00
github-actions[bot]
46e8217f2f docs: update progress [skip ci] 2026-10-01 00:07:00 +00:00
devin-ai-integration[bot]
028e36cce2 Link kbd_lib_map_us (#426)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-10-01 00:06:18 +00:00
github-actions[bot]
6abc1f9bd8 docs: update progress [skip ci] 2026-09-30 23:37:01 +00:00
devin-ai-integration[bot]
b004e2be89 Link net sha1 + neterrorcode (#425)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 23:36:27 +00:00
coah
5c1794ef25 wad 32/40 (fuzzy 98.5) (worker 37d1b10e) (#424) 2026-09-30 18:07:25 -05:00
coah
c393274640 sweep: kbd_lib, tiZiString, exif closer (worker 374f661e) (#423) 2026-09-30 17:57:39 -05:00
coah
3bfbb0c9c3 zi8alpha/zi81key: small fuzzy gains (worker 004853ec) (#422) 2026-09-30 17:54:43 -05:00
coah
cdc22045a7 TMC_JPEG: RGB565 3/13 (96%), RGBA8 89%, idct 88%, iqdec 99% (worker 7b4f8d49) (#421) 2026-09-30 17:43:46 -05:00
github-actions[bot]
976fbeb804 docs: update progress [skip ci] 2026-09-30 22:37:48 +00:00
devin-ai-integration[bot]
725599dba0 Link 28 fa tail units (pdm + pf stubs + pfs_*) (#420)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 22:37:10 +00:00
coah
4d0c9e70d6 odh/AOSS: small fuzzy gains (worker f272e078) (#419) 2026-09-30 17:24:56 -05:00
coah
131d8f743c sd_drv round 4 (worker d3d9dcba) (#418) 2026-09-30 17:17:34 -05:00
coah
23067a3477 wad 29/40 (fuzzy 92 -> 97) (worker 2a411d12) (#417) 2026-09-30 17:04:12 -05:00
coah
c7958e9f67 sd_drv round 3 (worker 503a78aa) (#416) 2026-09-30 16:50:52 -05:00
coah
d9ee532e07 vi 28/30 (data 100%), nup 17/23 (worker 53f0591e) (#415) 2026-09-30 16:49:32 -05:00
github-actions[bot]
1d5184b30e docs: update progress [skip ci] 2026-09-30 21:38:54 +00:00
devin-ai-integration[bot]
a27b6aa96e Link 47 fa units (finfo..xdivide + pf_w_* batch) (#414)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 21:38:17 +00:00
coah
112149c8e5 KPAD 18/29 (fuzzy 84 -> 98.5) (worker e7585e33) (#413) 2026-09-30 16:09:46 -05:00
coah
45a6d499ec pfd_cmn 1/1, sd_drv 15/26 (worker 64325785) (#412) 2026-09-30 16:06:22 -05:00
github-actions[bot]
813110e681 docs: update progress [skip ci] 2026-09-30 20:40:48 +00:00
devin-ai-integration[bot]
f4a48bd996 Link 15 fa pf units (cdelete..fconcat) (#411)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 20:40:01 +00:00
coah
f1590c832e wad 27/40 (fuzzy 86 -> 92) (worker c964c352) (#410) 2026-09-30 15:30:30 -05:00
coah
d6cafeab4d zi8cgetc: GetZH closer, data 24 -> 72 (worker bb87205d) (#409) 2026-09-30 15:18:11 -05:00
coah
c047b544c1 nand_drv 18/18, sd_drv 13/26 (no volatile casts) (worker 26ae07cf) (#408) 2026-09-30 15:16:57 -05:00
coah
82dbaac35d CHANSVm: CHANSVmStep 96.4% (worker 87e5a30c) (#407) 2026-09-30 14:46:29 -05:00
coah
e8d4107b11 BS2Mach/BS2Update: closer (fuzzy only) (worker fb7be869) (#406) 2026-09-30 14:33:27 -05:00
coah
1b96b3956b tiInputForm: fuzzy 97 -> 99.5, 3 more asm bodies to C (worker d126d226) (#405) 2026-09-30 14:30:55 -05:00
github-actions[bot]
81c36c4db0 docs: update progress [skip ci] 2026-09-30 19:12:04 +00:00
devin-ai-integration[bot]
355564cd77 Link pf_fat32, pf_sector, pf_volume_apiadd, pf_buffering (#404)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 19:11:15 +00:00
coah
17b5d5946b Texture_MCUtoY8U8V8: nine functions ~50% -> 99% (registers only) (worker b2970e86) (#403) 2026-09-30 13:55:41 -05:00
github-actions[bot]
ed5a62397d docs: update progress [skip ci] 2026-09-30 18:50:46 +00:00
coah
2a34d3703b Revert "Link fa/driver nand_drv + msc_drv (#400)" (#402)
This reverts commit 787aa9d334.
2026-09-30 13:50:09 -05:00
coah
3f5248be4c CHANSVm: data 100%, all 121 jump-table relocations match (worker 7c42cd13) (#401) 2026-09-30 13:48:47 -05:00
github-actions[bot]
59e127f89a docs: update progress [skip ci] 2026-09-30 18:41:42 +00:00
devin-ai-integration[bot]
787aa9d334 Link fa/driver nand_drv + msc_drv (#400)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 18:41:06 +00:00
coah
30809a5b05 BS2Mach: BS2Tick 77 -> 98% (worker 86b254ad) (#399) 2026-09-30 13:34:56 -05:00
coah
c21ae517d5 fix: replace lbl_ string pin in FAInit with a literal (#398) 2026-09-30 13:19:03 -05:00
coah
5c7d7ca74a zi8match 8/10 (data 100%) (worker 5d91f712) (#397) 2026-09-30 13:17:06 -05:00
github-actions[bot]
7a94e90a6e docs: update progress [skip ci] 2026-09-30 18:11:32 +00:00
devin-ai-integration[bot]
cec99e3cf8 Link vi/i2c + vi3in1 (#396)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 18:10:55 +00:00
github-actions[bot]
6172b57647 docs: update progress [skip ci] 2026-09-30 18:10:40 +00:00
devin-ai-integration[bot]
bed8e32e57 Link 18 fa/api units (#395)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 18:10:01 +00:00
coah
930e8f4ecf CHANSVm 208/233 (worker 662bd0e0) (#394) 2026-09-30 12:45:06 -05:00
coah
c835bedbc1 zikorean 3/3; zkokeyp 98.6, zprepare 96 (worker 58c15bd8) (#393) 2026-09-30 12:35:36 -05:00
coah
5981234728 scene units: small fuzzy gains (worker 0eaf4057) (#392) 2026-09-30 12:13:13 -05:00
github-actions[bot]
3b2304bd75 docs: update progress [skip ci] 2026-09-30 17:12:29 +00:00
devin-ai-integration[bot]
6ade163015 Link 7 MSL units (ansi_fp, locale, file_io, printf, scanf, strtold, time) (#391)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 17:11:03 +00:00
coah
e6496cc6a8 KPAD 14/29; BS2Mach/wad closer (worker e55f27dd) (#390) 2026-09-30 12:10:14 -05:00
coah
99cfa80f99 TMC_JPEG: Y8U8V8 fuzzy 58 -> 61 (worker cb27699d) (#389) 2026-09-30 11:36:28 -05:00
coah
dfb64b9747 zkokeyp fuzzy 81 -> 94, zprepare 86 (worker 57cfe99f) (#388) 2026-09-30 11:33:53 -05:00
coah
94e6d86223 iplAddressEdit 86/94 (worker 92e1ef1b) (#387) 2026-09-30 11:22:37 -05:00
coah
c923937c3b TMC_JPEG converters round (worker 268299bc) (#386) 2026-09-30 11:05:52 -05:00
coah
bf90a97c1a iplSetting 104/112 (fuzzy 93 -> 98) (worker e82cba45) (#385) 2026-09-30 11:04:42 -05:00
coah
884952a19b zi8dawg 5/6 (fuzzy 52 -> 100), zprepare 65 -> 82 (worker fc5440bc) (#384) 2026-09-30 10:44:22 -05:00
coah
70b04f1d72 iplAddressEdit 85/94, www_wiisetting 20/21 (worker 7ecb61e6) (#383) 2026-09-30 10:35:02 -05:00
coah
95d895d71a NWC24Mime 11/16 (fuzzy 90 -> 99) (worker 5c10efc5) (#382) 2026-09-30 10:14:38 -05:00
coah
6a2a3dd67f iplSDChannelSelect 102/129, iplSDMemory 63/66 (worker 68e4d339) (#381) 2026-09-30 10:01:16 -05:00
coah
341354dce2 zi81key 5/9 (MatchAltSound1Key exact) (worker c23b5c16) (#380) 2026-09-30 09:47:39 -05:00
coah
a22313e57e iplAddressEdit 81/94, iplAddress 90/101 (worker c3ba9e6a) (#379) 2026-09-30 09:43:25 -05:00
coah
91e65d765b tiCellPhone 83/86 (data 100%), NWC24Download 17/30 (worker b5116e0e) (#378) 2026-09-30 09:03:41 -05:00
coah
dc93ab5777 ATERM/AOSS: small fuzzy gains (worker 256344db) (#377) 2026-09-30 09:02:01 -05:00
coah
a3b04ad9ea zi81key and zi8alpha: big functions fully written (60/54/44% -> 97/95/82%) (worker 092b8946) (#376) 2026-09-30 08:54:35 -05:00
coah
55fd34f972 iplSDChannelSelect 98/129, iplSetting 102/112 (worker 1cf3ee73) (#375) 2026-09-30 08:40:18 -05:00
coah
7f055a587e AOSS: fuzzy 69 -> 88 (worker bee49f36) (#374) 2026-09-30 08:14:54 -05:00
coah
7a6efe8a2c pf_dir 34/38, NWC24Download 16/30, tiCellPhone 79/86 (worker 6e98b375) (#373) 2026-09-30 07:49:35 -05:00
github-actions[bot]
de2c8c4688 docs: update progress [skip ci] 2026-09-30 12:48:52 +00:00
devin-ai-integration[bot]
d08d7dec60 nup: link nup_mem (objdiff 100%) (#372)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 12:48:13 +00:00
coah
f20fc7b8e9 zi8cgetc: zi8InternalGetZH 77.5% (worker 7ee3b136) (#371) 2026-09-30 07:11:39 -05:00
coah
03ed29ccee ATERM 11/26, AOSS 15/21 (worker c09611c2) (#370) 2026-09-30 07:09:34 -05:00
coah
2058b121cc iplSetting 100/112, iplSDMemory 62/66 (worker dee954b8) (#369) 2026-09-30 06:57:39 -05:00
coah
4588eee6a9 KPAD data 7712/8032; odh, BS2Mach closer (worker 3e273fb5) (#368) 2026-09-30 06:38:39 -05:00
coah
ad3da3bb76 zi8cgetc: zi8InternalGetZH (42.7KB) translated, 77% fuzzy (worker 9b342d48) (#367) 2026-09-30 06:30:02 -05:00
coah
f9bd6755ba KPAD 13/29 (worker a6808c6c) (#366) 2026-09-30 05:58:34 -05:00
coah
4f78910f8b iplSetting 97/112, iplSDChannelSelect 94/129, iplSDMemory (worker 5693252e) (#365) 2026-09-30 05:55:11 -05:00
coah
9189c9bb9f ATERM 6/26 (fuzzy 89), AOSS 13/21 (worker abd0b0b9) (#364) 2026-09-30 05:53:15 -05:00
coah
eccd5f8c45 SDK: wad fuzzy 81 -> 86, nup +1 (worker 5f3d84f6) (#363) 2026-09-30 05:18:45 -05:00
coah
038cd6f939 zi8cgetc: 5/8 functions (worker 51eaab11) (#362) 2026-09-30 05:06:59 -05:00
coah
1c505b9708 ATERM: fuzzy 64 -> 83; AOSS 9/21 (worker 102f9d07) (#361) 2026-09-30 04:29:38 -05:00
coah
b646f1caaf TMC_JPEG: RGB565 grayscale converter 99.2% (worker e382e38c) (#360) 2026-09-30 04:24:51 -05:00
coah
46066115ab misc: 11 small SDK/eZiText units, 23 exact functions (worker 6d0baf10) (#359) 2026-09-30 04:23:36 -05:00
coah
bc6d67e3f5 SDK: sd_drv, wad 23/40, vi, nup round (worker 73e619c5) (#358) 2026-09-30 03:59:50 -05:00
github-actions[bot]
d399446f10 docs: update progress [skip ci] 2026-09-30 08:56:48 +00:00
devin-ai-integration[bot]
5c690a7da3 nwc24: link NWC24System (objdiff 100%) (#357)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 08:55:55 +00:00
github-actions[bot]
59a3bfc3b2 docs: update progress [skip ci] 2026-09-30 08:55:13 +00:00
devin-ai-integration[bot]
547c2f508f fa: link 6 dir/entry units (objdiff 100%) (#356)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 08:54:38 +00:00
coah
f34c0b3aa7 TMC_JPEG: exif_parse 3/6; partial texture converters, idct, iqdec (worker c8e8d278) (#355) 2026-09-30 03:29:46 -05:00
coah
dcc384b7fa misc: 8 small setting/SDK units, 45/54 functions (worker 4db219ff) (#354) 2026-09-30 03:03:53 -05:00
github-actions[bot]
3fef1bd99e docs: update progress [skip ci] 2026-09-30 07:47:12 +00:00
devin-ai-integration[bot]
fd30e881a1 sdk: link ncdsleep + WPADHIDParser (objdiff 100%) (#353)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 07:46:35 +00:00
coah
213a6bee9b ATERM: fuzzy 51 -> 64, AOSS closer (worker 86f2d53a) (#352) 2026-09-30 02:45:40 -05:00
coah
e758673de1 RevoEX round 2: md5 3/4, d_nhttp_private 6/7 (worker 5ffa5e9e) (#351) 2026-09-30 02:44:11 -05:00
coah
c4f51491a3 fa: 109 small filesystem units fully exact (156 functions) (worker 9aaaf7fc) (#350) 2026-09-30 02:30:48 -05:00
coah
675a831828 iplMemoryCardManager 16/26; vi3in1, kbd_lib closer (worker f3122e89) (#349) 2026-09-30 02:22:48 -05:00
coah
cbeb2dee76 RevoEX net/so/nhttp/ncd: 63 exact functions across 13 units (worker d4343581) (#348) 2026-09-30 02:21:40 -05:00
coah
e744a24c1f iplMemoryCardBase 34/34, ATERM 5/26, AOSS 8/21 (worker 260cca0c) (#347) 2026-09-30 01:59:10 -05:00
github-actions[bot]
1ec6dda7ad docs: update progress [skip ci] 2026-09-30 06:48:36 +00:00
devin-ai-integration[bot]
97ceae0874 fa: link pf_attach/detach/mkdir/mount/remove/rename/rmdir/unmount (#346)
pf_mount.c and pf_rename.c implemented; all 8 units objdiff 100%
(text + relocs identical) and flipped to Matching. DOL hash verified.

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 06:47:46 +00:00
coah
e81a2616cd vi3in1, kbd_lib, iplMemoryCardManager: closer non-exact functions (worker 04cfeb7d) (#345) 2026-09-30 01:43:30 -05:00
coah
4830a26101 fa: pf_dir 30/38, pf_file 44/45 (worker 886e3b81) (#344) 2026-09-30 01:30:53 -05:00
github-actions[bot]
ba7b9fa6ea docs: update progress [skip ci] 2026-09-30 06:26:50 +00:00
devin-ai-integration[bot]
9845b3d75e axfx: link AXFXReverbHiExpDpl2 + AXFXReverbStdExp (objdiff 100%) (#343)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 06:26:06 +00:00
coah
88ab8325db eZiText round 2: zi8getc2 11/17 (worker 2384260a) (#342) 2026-09-30 01:23:32 -05:00
coah
2060db15f6 MSL: locale data, file_io 4/4 (worker f5f4a391) (#341) 2026-09-30 01:17:04 -05:00
coah
eaee2295cc vi3in1 15/18, kbd_lib 12/21, iplMemoryCardManager (worker feba9540) (#340) 2026-09-30 01:04:27 -05:00
coah
856a31f8c9 MSL: printf, wprintf, ansi_fp, time, scanf, strtold (worker 969bc2aa) (#339) 2026-09-30 00:55:53 -05:00
coah
9ea683dd61 eZiText: zi8match, zi8getc2, zikorean, zi8dawg (worker 1f628177) (#338) 2026-09-30 00:54:06 -05:00
github-actions[bot]
ea4ec10115 docs: update progress [skip ci] 2026-09-30 05:46:33 +00:00
devin-ai-integration[bot]
97a2eb1f23 fa: link 6 more pf units (service,fopen,fseek,fsfirst,fsnext,fstat) - objdiff 100% (#337)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 05:45:42 +00:00
coah
3cbf4bb3e9 fa: pf_volume 33/37, pf_dir 29/38, pf_fat 29/35, pf_file 43/45 (worker 4c6c5008) (#336) 2026-09-30 00:38:19 -05:00
coah
033b33a486 tiCellPhone: 72/86 functions (worker 1ccf7e1f) (#335) 2026-09-30 00:18:48 -05:00
coah
6b6215ad3e CDBRecord 26/29, CDBIntArray 13/13, NWC24Download (worker 231065dc) (#334) 2026-09-30 00:15:46 -05:00
coah
9ad0863dbf tiHwKeyboard 10/10, tiCandidateBox 105/112, MyTiManager 91/91 (worker 913d06d4) (#333) 2026-09-30 00:14:18 -05:00
coah
41877f03dc NWC24MsgRead 11/16, DateParser 5/8, System 4/4 (worker 5e5e6e1d) (#332) 2026-09-29 23:33:10 -05:00
coah
bc95aa48e9 fa: decompile 29 filesystem units from vf leads (worker dd4743d9) (#331) 2026-09-29 23:20:36 -05:00
coah
64018b3b33 tiTextDrawer 23/24, MyTiLetterForm 26/26 (worker ea883a22) (#330) 2026-09-29 23:19:04 -05:00
coah
2748f29a98 tiString 41/42, tiZiString 24/29 (worker aa0ab97c) (#329) 2026-09-29 22:58:25 -05:00
coah
e6ef163648 NWC24Mime 9/16, NWC24MsgSubject 7/12 (worker eb06c45d) (#328) 2026-09-29 22:57:06 -05:00
github-actions[bot]
c765bd2eca docs: update progress [skip ci] 2026-09-30 03:49:39 +00:00
devin-ai-integration[bot]
c65c722932 fa: link pf_clib, pf_code, pf_str, pf_driver (objdiff 100% code+data) (#327)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-30 03:49:01 +00:00
coah
df54d9a348 NWC24Mime 8/16, NWC24MsgSubject 5/12 (worker fd8d384c) (#326) 2026-09-29 22:27:26 -05:00
coah
b983deeb07 tiHKBManager: 24/29 functions (worker 2e1dbe5d) (#325) 2026-09-29 22:23:10 -05:00
coah
b615148895 fa/pf_entry 20/20, pf_cluster 5/8 (worker 5fc6d9c5) (#324) 2026-09-29 22:08:46 -05:00
coah
95c685534e tiHKBManager: 21/29 functions, data 100% (worker adbf6056) (#323) 2026-09-29 22:05:27 -05:00
coah
68f1674a5d NWC24MsgCommit: 15/18 exact (worker fc42b29c) (#322) 2026-09-29 21:56:26 -05:00
coah
5875521928 NWC24MsgCommit: 11/18 exact (worker 93b2e6b0) (#321) 2026-09-29 21:37:52 -05:00
coah
0e4f2c726f fa/pf_entry_iterator: 14/16 functions (worker 9b46afc6) (#320) 2026-09-29 21:36:34 -05:00
coah
620a8a6814 tiSignWindow: 55/56 functions, data 100% (worker ba6ad09d) (#319) 2026-09-29 21:28:25 -05:00
coah
84972cb9f1 fa/pf_cache: 35/36 functions (worker 242b3d5c) (#318) 2026-09-29 21:16:08 -05:00
coah
54d865f151 tiManager: 61/62 functions (worker db16fa0c) (#317) 2026-09-29 21:08:29 -05:00
coah
0e31a5b37c NWC24MBoxCtrl: 23/25 functions (worker cdaba1ae) (#316) 2026-09-29 21:00:52 -05:00
coah
8b568557b0 iplSDChannelObj: 36/38 exact (worker 0b3375b0) (#315) 2026-09-29 20:55:45 -05:00
coah
19f6c82a98 iplCardSequence: 27/30 functions (worker da89d61f) (#314) 2026-09-29 20:41:01 -05:00
coah
3e81c24a0c tiInputForm: 207/221 exact, 9 asm bodies left (worker a5ca5fd2) (#313) 2026-09-29 20:39:33 -05:00
coah
5e0fbb88f0 NWC24MBoxCtrl: 20/25 functions (worker 1f47cc11) (#312) 2026-09-29 20:35:19 -05:00
coah
32da26fae0 iplCardSequence: 24/30 functions (worker 05134dbe) (#311) 2026-09-29 20:28:03 -05:00
coah
413e6c483b tiInputForm: convert 29 more asm bodies to C (12 left) (worker 99756b60) (#310) 2026-09-29 20:16:30 -05:00
coah
d76c36462f iplCardSequence: 23/30 functions, data 100% (worker 68c1c3b9) (#309) 2026-09-29 20:15:21 -05:00
coah
f1cc81a228 CHANSVm: interpreter case layout (98 of 108 table mismatches left) (worker ff01ec49) (#308) 2026-09-29 20:07:08 -05:00
coah
ca4339eece iplMemoryCard: 41/41 functions (worker 4d184a0a) (#307) 2026-09-29 19:59:56 -05:00
coah
0107230f11 iplGCWindow: 47/48 functions, pool identical (worker c44639cd) (#306) 2026-09-29 19:48:44 -05:00
coah
c77b866ed4 iplGCWindow: 46/48 functions (worker a046844b) (#305) 2026-09-29 19:28:12 -05:00
coah
550c5f19c1 tiInputForm: convert 11 asm bodies to C (worker 392d5810) (#304) 2026-09-29 19:25:34 -05:00
coah
e00d7aefd6 CHANSVm: 207/233 functions (worker 6abd3e30) (#303) 2026-09-29 19:16:21 -05:00
coah
92f10a65fa tiPcKeyboard: 135/141 functions (worker d836d531) (#302) 2026-09-29 19:13:54 -05:00
coah
e858a9362d tiInputForm: 208/221 functions (worker 66d51a87) (#301) 2026-09-29 19:02:36 -05:00
coah
bd1885f9be tiPcKeyboard: 131/141 functions (worker 9de5a728) (#300) 2026-09-29 18:53:51 -05:00
coah
42647c75c1 CHANSVm: 206/233 functions, rodata 100% (worker 9f9055e9) (#299) 2026-09-29 18:51:35 -05:00
coah
83a55a20a0 tiPcKeyboard: 129/141 functions (worker 13286b26) (#298) 2026-09-29 18:38:17 -05:00
coah
46f34f11f5 CHANSVm: 205/233 functions (worker 585bcf56) (#297) 2026-09-29 18:28:33 -05:00
coah
1bc8f49115 tiPcKeyboard: 123/141 functions (worker 51e4c318) (#296) 2026-09-29 18:14:49 -05:00
github-actions[bot]
f055c43c22 docs: update progress [skip ci] 2026-09-29 23:12:58 +00:00
coah
985bae5d42 ci: drop per-run timestamp from readme progress block (#295) 2026-09-29 18:12:24 -05:00
github-actions[bot]
d4696caeaf docs: update progress [skip ci] 2026-09-29 23:09:44 +00:00
coah
2b4ed18122 CHANSVm: 204/233 functions (worker 5e97a5b0) (#294) 2026-09-29 18:09:11 -05:00
github-actions[bot]
02e50d2dc2 docs: update progress [skip ci] 2026-09-29 23:00:27 +00:00
coah
46d7abf8c0 ci: self-hosted job that keeps readme progress numbers updated (#293) 2026-09-29 17:58:51 -05:00
581 changed files with 170438 additions and 23741 deletions

View File

@@ -53,9 +53,9 @@ Progress
<!-- progress:start -->
| Decompiled | Matched | Linked | Data |
|:---:|:---:|:---:|:---:|
| 80.98% | 72.11% | 56.76% | 86.16% |
| 99.37% | 87.69% | 61.93% | 91.37% |
units 748/1027 complete, functions 10570/12563 matched. updated 2026-09-29 22:58 UTC from `test` by the self-hosted progress job
units 917/1027 complete, functions 12211/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 -->

293
agent/sol-med-attempts.md Normal file
View File

@@ -0,0 +1,293 @@
# sol-med matching attempts
ATERM pool was identical before iteration. Initial gate: 3/26 instruction-exact, code 72/19204, data 18440/18864, no regressions.
ATERM_814021BC: (1) combined network settings and access-point name, moved member-pointer initialization after clears, bottom-tested host loop: 153/154 instructions, register and addressing differences; (2) aligned the name member and explicit settings pointer: same instruction count and differences; (3) initialized IP pointer before clear: no improvement. Restored original to avoid unrelated aggregate changes.
ATERM_81402424: (1) aligned scan parameters to 32, swapped message/buffer declarations, preserved scan exit result test: 210/210, three condition-register differences; (2) tested scan result != retry error: one branch difference; (3) tested scan result == retry error: 210/210, diffs 0. Retained.
ATERM_8140276C: (1) initialized previous record cursor before outer loop, reset at outer tail, separated result flag, scoped AOSS flags: 174/174, 31 register differences; (2) reordered result/found declarations and scoped previous index: 174/174, 27 register differences. Further experiments below.
ATERM_81403614: (1) switch over hex character ranges, signed index and indexed output: 49/49, two division differences; (2) explicit signed truncation for index/2: one operand-order difference; (3) reversed addition operands: diffs 0. Retained.
ATERMi_AutoConfigThread: (1) real three-field progress object and conditional terminal state: 39/40 instructions; (2) signed equality mask: 40/40, three scheduling/register differences; (3) read progress result before deadline assignment: eight differences. Further experiments below.
ATERMi_ApConfigStart: (1) inclusive state bounds, use stored stack size and callback: 103/103, twelve differences; (2) restore source order of global initialization: six clock-register differences. Further experiments below.
ATERMi_ApConfigEnd: (1) capture initial state only inside active-thread branch, swap message declarations, compute 500ms alarm instead of reciprocal literal: 125/129 instructions, frame/scheduling differences. Further experiments below.
ATERMi_ApConfigGetState: (1) reciprocal first in multiply-high: four register differences; (2) load bus clock in multiply expression: unchanged; (3) direct time conversion expression: unchanged. Restored original, 35/35 instructions with three register differences.
ATERM_8140276C initial 99.166664%
- previous cursor declaration before current cursor: 99.5115%; src 0x2b8 base 0x2b8 insns 174/174; diffs 15: [8, 9, 82, 84, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]; 8 M addi r27, r4, 4; B addi r31, r3, 4
- signed record indices: 99.166664%; src 0x2b8 base 0x2b8 insns 174/174; diffs 27: [8, 9, 18, 29, 34, 41, 50, 54, 55, 60, 61, 68, 74, 75, 82, 84, 87, 88, 89, 90]; 8 M addi r27, r3, 4; B addi r31, r3, 4
- AOSS flags initialized after clear: 99.54023%; src 0x2b8 base 0x2b8 insns 174/174; diffs 14: [8, 9, 18, 29, 34, 41, 50, 54, 55, 60, 61, 68, 74, 75]; 8 M addi r27, r3, 4; B addi r31, r3, 4
Retained original
ATERM_81402A24 initial 72.47529%
- record capacity includes final descriptor: 71.30038%; src 0x3d4 base 0x41c insns 245/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
- allocate nullable buffers before handling failure: 72.380226%; src 0x3cc base 0x41c insns 243/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
- multiply-high tick conversion: 75.76426%; src 0x3f4 base 0x41c insns 253/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
Retained original
ATERM_81402E40 initial 99.791664%
- payload clear through byte alias: 99.791664%; src 0x180 base 0x180 insns 96/96; diffs 4: [9, 10, 47, 52]; 9 M mr r29, r7; B mr r3, r27
- natural checksum loop: 65.208336%; src 0x108 base 0x180 insns 66/96; --- replace mine 5:12 base 5:12; M 5 mr r28, r5; M 6 mr r26, r3
- end length as packet byte extent: 95.572914%; src 0x180 base 0x180 insns 96/96; diffs 6: [9, 10, 42, 44, 47, 52]; 9 M mr r29, r7; B mr r3, r27
Retained original
ATERM_81402FC0 initial 67.28148%
- full-width checksum accumulator: 64.76296%; src 0x20c base 0x21c insns 131/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
- bottom-tested option loop: compile failed
- early return for bad checksum: 66.94074%; src 0x20c base 0x21c insns 131/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
Retained original
ATERM_814031DC initial 85.7218%
- MAC text uses equal-sized buffers: 85.766914%; src 0x1f4 base 0x214 insns 125/133; --- replace mine 47:48 base 47:48; M 47 beq 288; B 47 beq 320
- nibble conversion advances output cursor: 84.293236%; src 0x204 base 0x214 insns 129/133; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x70(r1); B 0 stwu r1, -0x60(r1)
- inclusive digit bound and pointer-based MAC scan: 85.90225%; src 0x1f4 base 0x214 insns 125/133; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x70(r1); B 0 stwu r1, -0x60(r1)
Retained original
ATERM_814033F0 initial 65.868614%
- option fields retain converted word width: 67.39416%; src 0x214 base 0x224 insns 133/137; --- replace mine 5:6 base 5:6; M 5 addi r30, r3, 8; B 5 addi r29, r3, 8
- bottom-tested parser dispatch: 65.79562%; src 0x21c base 0x224 insns 135/137; --- replace mine 5:6 base 5:6; M 5 addi r28, r3, 8; B 5 addi r29, r3, 8
- signed nibble comparisons: 65.32117%; src 0x21c base 0x224 insns 135/137; --- insert mine 7:7 base 7:8; B 7 li r24, 0; --- replace mine 10:29 base 11:17
Retained original
ATERM_814036D8 initial 73.92742%
- security switch matches original decision tree: 85.22581%; src 0x1ec base 0x1f0 insns 123/124; --- replace mine 14:15 base 14:15; M 14 beq 340; B 14 beq 344
- key text passed through one cursor: 87.0%; src 0x1e4 base 0x1f0 insns 121/124; --- replace mine 14:24 base 14:16; M 14 bne 36; M 15 addi r3, r25, 0
- counted loop over key records: 73.92742%; src 0x1e0 base 0x1f0 insns 120/124; --- replace mine 14:24 base 14:16; M 14 bne 36; M 15 addi r3, r25, 0
Retained original
ATERM_814038C8 initial 35.28917%
- one-shot 500ms wait replaces repeated alarm: 35.700314%; src 0x788 base 0xedc insns 482/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0xe0(r1); B 0 stwu r1, -0x180(r1)
- bottom-tested state machine and wait buffer order: 35.288116%; src 0x784 base 0xedc insns 481/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0xe0(r1); B 0 stwu r1, -0x180(r1)
- progress uses semantic structure: 35.28917%; src 0x784 base 0xedc insns 481/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0xe0(r1); B 0 stwu r1, -0x180(r1)
Retained original
ATERM_81404844 initial 19.615385%
- signed RFC3394 counters: 16.34188%; src 0x1a0 base 0x1d4 insns 104/117; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x190(r1)
- counter represented as big-endian bytes: compile failed
- RFC3394 initial value and block output order: 18.264957%; src 0x1b0 base 0x1d4 insns 108/117; --- replace mine 6:9 base 6:13; M 6 mr r27, r3; M 7 mr r20, r4
Retained original
ATERM_81404A18 initial 51.107437%
ATERM_81404844 initial 19.615385%
- signed RFC3394 counters: 16.34188%; src 0x1a0 base 0x1d4 insns 104/117; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x190(r1)
ATERM_81404844 initial 16.34188%
- signed RFC3394 counters: 16.34188%; src 0x1a0 base 0x1d4 insns 104/117; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x190(r1)
- counter represented as big-endian bytes: compile failed
- RFC3394 initial value and block output order: 18.264957%; src 0x1b0 base 0x1d4 insns 108/117; --- replace mine 6:9 base 6:13; M 6 mr r27, r3; M 7 mr r20, r4
Retained original
ATERM_81404A18 initial 51.107437%
- signed RFC3394 counters: 52.05785%; src 0x1c8 base 0x1e4 insns 114/121; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x1a0(r1)
- counter represented as big-endian bytes: compile failed
- RFC3394 initial value and block output order: 54.991737%; src 0x1c4 base 0x1e4 insns 113/121; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x190(r1); B 0 stwu r1, -0x1a0(r1)
Retained original
ATERM_81404BFC initial 36.869404%
- AES byte assembly uses XOR instead of OR: 37.063435%; src 0x400 base 0x430 insns 256/268; --- replace mine 0:6 base 0:20; M 0 lbz r7, 1(r4); M 1 cmplwi r5, 0x80
- key schedule reads preceding round and chains fourth key word: 36.925373%; src 0x3dc base 0x430 insns 247/268; --- replace mine 0:6 base 0:20; M 0 lbz r7, 1(r4); M 1 cmplwi r5, 0x80
- signed round count drives key expansion termination: 49.21642%; src 0x3e0 base 0x430 insns 248/268; --- replace mine 0:3 base 0:47; M 0 lbz r8, 1(r4); M 1 cmplwi r5, 0x80
Retained original
ATERM_8140502C initial 35.666668%
- interleaved key-word swaps: 42.355072%; src 0x280 base 0x228 insns 160/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0
- signed indexed round reversal: 38.746376%; src 0x290 base 0x228 insns 164/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0
- counted transformation loop: 11.731884%; src 0x288 base 0x228 insns 162/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0
Retained original
ATERM_81405254 initial 30.464945%
- AES byte assembly uses XOR: 34.23247%; src 0x3c4 base 0x43c insns 241/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- two-round loop with final round exit: compile failed
- signed round count with separately combined key XOR: compile failed
Retained original
ATERM_81405690 initial 26.601477%
- AES byte assembly uses XOR: 34.64945%; src 0x3d4 base 0x43c insns 245/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- two-round loop with final round exit: compile failed
- signed round count with separately combined key XOR: compile failed
Retained original
ATERM_81405ACC initial 0%
- natural byte copy instead of explicit eight-byte loop: 0%; src 0x10c base 0x240 insns 67/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:12 base 4:10
- separate 32-bit count carry updates: 0%; src 0x184 base 0x240 insns 97/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:5 base 4:11
- indexed full-block walk retains input length: 0%; src 0x17c base 0x240 insns 95/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:12 base 4:10
Retained original
ATERM_81405D0C initial 32.62639%
- decode words with XOR: 25.144444%; src 0xa5c base 0xb40 insns 663/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1)
- MD5 first-round select expressed as xor mask: 30.945833%; src 0x9fc base 0xb40 insns 639/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1)
- flat byte-to-word decode loop: 27.13889%; src 0x904 base 0xb40 insns 577/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1)
Retained original
ATERMi_AutoConfigThread initial 91.325%
- remaining time assigned before terminal state: 91.475%; src 0xa0 base 0xa0 insns 40/40; diffs 7: [20, 22, 23, 26, 28, 29, 30]; 20 M nor r0, r3, r0; B nor r3, r3, r0
- terminal mask reuses result variable: 85.075%; src 0xa0 base 0xa0 insns 40/40; diffs 9: [21, 22, 23, 25, 26, 28, 29, 30, 31]; 21 M lwz r4, 0(0); B li r4, -1
- state stores preceding deadline store: 85.2%; src 0xa0 base 0xa0 insns 40/40; diffs 8: [21, 22, 23, 25, 26, 29, 30, 31]; 21 M lwz r4, 0(0); B li r4, -1
Retained original
ATERMi_ApConfigStart initial 99.70874%
- allocate via stored callback: 99.70874%; src 0x19c base 0x19c insns 103/103; diffs 6: [46, 47, 48, 49, 75, 76]; 46 M lis r31, -0x8000; B lis r30, -0x8000
- tick multiplier commutes operands: 97.76699%; src 0x19c base 0x19c insns 103/103; diffs 7: [48, 49, 51, 75, 76, 77, 78]; 48 M lwz r6, 0xf8(r30); B lwz r0, 0xf8(r30)
- progress state populated before zeroing result buffer: 90.72816%; src 0x19c base 0x19c insns 103/103; diffs 18: [46, 47, 48, 49, 56, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 75, 76]; 46 M lis r31, -0x8000; B lis r30, -0x8000
Retained original
ATERMi_ApConfigEnd initial 93.94574%
- message queues declared within their wait scopes: 91.89922%; src 0x1f4 base 0x204 insns 125/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0
- join loop expressed as do-while: 91.54263%; src 0x200 base 0x204 insns 128/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0
- time conversion evaluated directly: 93.94574%; src 0x1f4 base 0x204 insns 125/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0
Retained original
ATERM_81404844 initial 19.615385%
- big-endian counter union assigned after declarations: 23.931623%; src 0x1a0 base 0x1d4 insns 104/117; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x190(r1)
Retained original
ATERM_81404A18 initial 51.107437%
- big-endian counter union assigned after declarations: 57.677685%; src 0x1c8 base 0x1e4 insns 114/121; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x1a0(r1)
Retained original
ATERM_81405254 initial 30.464945%
- two-round iteration with scoped second round: 25.00369%; src 0x4b8 base 0x43c insns 302/271; --- replace mine 5:42 base 5:230; M 5 lbz r9, 1(r5); M 6 lis r12, 0
- signed round index: 30.464945%; src 0x3a4 base 0x43c insns 233/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- round key XOR before table combination: 30.464945%; src 0x3a4 base 0x43c insns 233/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
Retained original
ATERM_81405690 initial 26.601477%
- two-round iteration with scoped second round: 23.239853%; src 0x4d8 base 0x43c insns 310/271; --- replace mine 5:13 base 5:7; M 5 lbz r10, 1(r5); M 6 lis r7, 0
- signed round index: 26.601477%; src 0x3b4 base 0x43c insns 237/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- round key XOR before table combination: 26.601477%; src 0x3b4 base 0x43c insns 237/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
Retained original
ATERM_81402FC0 initial 67.28148%
- option loop with explicit continuation test: 67.28148%; src 0x210 base 0x21c insns 132/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
Retained original
ATERM final source retains only exact scan and hex-conversion changes. All unsuccessful experiments restored. Remaining 21 functions are open; their instruction counts and experiment outcomes are recorded above. Cryptographic routines require substantial reconstruction, not just register allocation.
AOSS initial gate: 7/21 instruction-exact; code 2540/16192; data 3896/3928. String pool identical.
AOSS_814001B4: early returns and opcode switch: 75/79, remaining differences are save/restore helper versus individual stores.
AOSS_81401BBC: (1) reverse rounding addition: same one operand-order difference; (2) signed rounding temporary: same difference; (3) inline signed rounding expression: 56/56, diffs 0. Retained.
AOSS_81401DC0: (1) reuse seed parameter: 48/48, four last-step register differences; (2) split shift/XOR statements: 64/48 instructions; (3) eight-iteration CRC loop: 16/48 instructions. Restored original.
AOSS_Init_old initial 28.42298%
- full-width wait counters instead of narrowing every update: 28.546717%; src 0x1758 base 0x18c0 insns 1494/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b
AOSS_Init_old initial 28.42298%
- full-width wait counters instead of narrowing every update: 28.546717%; src 0x1758 base 0x18c0 insns 1494/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b
- packet length conversion retains full width: 28.42298%; src 0x1794 base 0x18c0 insns 1509/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b
- poll arguments given semantic socket events structure: 28.42298%; src 0x1794 base 0x18c0 insns 1509/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b
Retained original
AOSS_813FFD68 initial 96.981735%
- validation loops use signed char: 93.69406%; src 0x364 base 0x36c insns 217/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
- return failure immediately on invalid character: 82.05023%; src 0x2ec base 0x36c insns 187/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
- ascending validation cursor loop: 94.76712%; src 0x374 base 0x36c insns 221/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
Retained original
AOSS_814001B4 initial 88.78481%
- converted packet length stays full width: 88.78481%; src 0x12c base 0x13c insns 75/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
- direct opcode return cases: 83.27848%; src 0x124 base 0x13c insns 73/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
- full-width validation and branch nesting: 88.78481%; src 0x12c base 0x13c insns 75/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
Retained original
AOSS_814002F0 initial 79.525%
- read manufacturer only after state validation: 85.058334%; src 0x1c4 base 0x1e0 insns 113/120; --- replace mine 6:8 base 6:8; M 6 mr r30, r3; M 7 mr r26, r4
- packet sequence values remain full-width: 76.441666%; src 0x1c4 base 0x1e0 insns 113/120; --- replace mine 5:7 base 5:8; M 5 mr r30, r3; M 6 mr r26, r4
- direct address error branch: 79.525%; src 0x1c8 base 0x1e0 insns 114/120; --- replace mine 5:7 base 5:8; M 5 mr r30, r3; M 6 mr r26, r4
Retained original
AOSS_81400830 initial 77.619934%
- single-byte RC4 generation loop instead of manual pairs: 65.65109%; src 0x3c0 base 0x504 insns 240/321; --- insert mine 6:6 base 6:7; B 6 addi r29, r3, 0x18; --- insert mine 7:7 base 8:9
- natural CRC byte loop: 60.13084%; src 0x3c4 base 0x504 insns 241/321; --- replace mine 5:6 base 5:7; M 5 mr r27, r3; B 5 mr r26, r3
- narrow RC4 state indices at assignment: 77.619934%; src 0x4b8 base 0x504 insns 302/321; --- insert mine 6:6 base 6:7; B 6 addi r29, r3, 0x18; --- insert mine 7:7 base 8:9
Retained original
AOSS_81400E0C initial 77.52105%
- signed option lengths and iteration indices: 77.778946%; src 0x2bc base 0x2f8 insns 175/190; --- insert mine 5:5 base 5:6; B 5 mr r29, r4; --- replace mine 6:8 base 7:8
- natural integer byte decode for both address options: 44.963158%; src 0x188 base 0x2f8 insns 98/190; --- insert mine 5:5 base 5:6; B 5 mr r29, r4; --- replace mine 6:8 base 7:8
- address decode accumulation uses OR: 61.963158%; src 0x284 base 0x2f8 insns 161/190; --- replace mine 5:8 base 5:8; M 5 mr r29, r3; M 6 mr r30, r4
Retained original
AOSS_814013AC initial 91.70175%
- signed option lengths: 91.70175%; src 0x1cc base 0x1c8 insns 115/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
- apply flags after successful parser call: 84.68421%; src 0x1ec base 0x1c8 insns 123/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
- bounded while loop over selected reply payload: 88.2807%; src 0x1d4 base 0x1c8 insns 117/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
Retained original
AOSS_81401574 initial 92.558136%
- semantic payload extent expression: 92.558136%; src 0x1fc base 0x204 insns 127/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4
- request length remains full-width: 92.209305%; src 0x1f8 base 0x204 insns 126/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4
- initialize destination length before port conversion: 88.31783%; src 0x1fc base 0x204 insns 127/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4
Retained original
AOSS_81401778 initial 71.93407%
- CRC checksum stays full width until header store: 71.93407%; src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0)
- signed RC4 byte loop index: 71.93407%; src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0)
- copy hello payload before manufacturer encoding: 71.91575%; src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0)
Retained original
AOSS_81401C9C initial 71.9315%
- natural RC4 state initialization loop: 43.342464%; src 0x98 base 0x124 insns 38/73; --- replace mine 0:1 base 0:2; M 0 li r9, 0; B 0 stwu r1, -0x10(r1)
- schedule state reset before obtaining byte pointer: 71.9315%; src 0x12c base 0x124 insns 75/73; --- replace mine 0:6 base 0:2; M 0 stwu r1, -0x20(r1); M 1 mflr r0
- signed key and state indices: 71.9315%; src 0x12c base 0x124 insns 75/73; --- replace mine 0:6 base 0:2; M 0 stwu r1, -0x20(r1); M 1 mflr r0
Retained original
AOSS_81401E80 initial 91.80272%
- natural XOR loop over half-packet: 56.455784%; src 0x168 base 0x24c insns 90/147; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x30(r1); B 0 stwu r1, -0x40(r1)
- half-length via signed division: 87.04082%; src 0x240 base 0x24c insns 144/147; --- replace mine 5:19 base 5:13; M 5 srawi r0, r4, 1; M 6 mr r28, r3
- count-down rounds: 88.734695%; src 0x244 base 0x24c insns 145/147; --- replace mine 6:7 base 6:7; M 6 mr r28, r3; B 6 mr r21, r3
Retained original
AOSS_814020CC initial 76.066666%
- sleep tick product stays 64-bit: 67.51667%; src 0xfc base 0xf0 insns 63/60; --- replace mine 3:6 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
- tick duration via explicit multiply-high: 81.65%; src 0xe4 base 0xf0 insns 57/60; --- replace mine 3:5 base 3:6; M 3 addi r11, r1, 0x20; M 4 bl 0
- do-while host acquisition loop: 65.066666%; src 0xf8 base 0xf0 insns 62/60; --- replace mine 3:6 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
Retained original
AOSS final: retained exact packet builder AOSS_81401BBC only. Other experiments restored; remaining differences include loop expansion, register allocation, missing original compiler control flow.
## src/scene/memoryCard/iplMemoryCardBase
Baseline absent source: 0/34, code 0/3640, data 0/152. Implemented all real functions in target address order from original disassembly using typed classes and fields. Initial build: 33/34 exact, code 3240/3640, data 144/152; pool identical.
onCmdRecv initial 96.35%: 101/100 instructions.
- Signed lower/upper bounds for command range: extra comparison and branch.
- Switch cases 1/2/3: 95.35%, 102/100 instructions, compiler produces signed comparison tree.
- Unsigned command range distance: 100%, 100/100 instructions, diffs 0. Retained.
Data limitation: original .sdata2 contains -1.0 plus trailing alignment, while source also emits the required integer-to-float conversion double constant. No forced data or padding added. Full DOL gate determines acceptance; no configure Matching changes.
## Remaining functions at final handoff
src/scene/setting/ATERM: ATERM_814021BC 67.655846% — src 0x264 base 0x268 insns 153/154; --- insert mine 7:7 base 7:9; B 7 addi r30, r30, 0; B 8 li r4, 0; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_8140276C 92.10345% — src 0x2ac base 0x2b8 insns 171/174; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0x80(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81402A24 72.47529% — src 0x3d0 base 0x41c insns 244/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81402E40 99.791664% — src 0x180 base 0x180 insns 96/96; diffs 4: [9, 10, 47, 52]; 9 M mr r29, r7; B mr r3, r27; remaining register/scheduling differences
src/scene/setting/ATERM: ATERM_81402FC0 67.28148% — src 0x210 base 0x21c insns 132/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_814031DC 85.7218% — src 0x1f4 base 0x214 insns 125/133; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x70(r1); B 0 stwu r1, -0x60(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_814033F0 65.868614% — src 0x21c base 0x224 insns 135/137; --- insert mine 7:7 base 7:8; B 7 li r24, 0; --- replace mine 10:29 base 11:17; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_814036D8 73.92742% — src 0x1e0 base 0x1f0 insns 120/124; --- replace mine 14:24 base 14:16; M 14 bne 36; M 15 addi r3, r25, 0; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_814038C8 35.28917% — src 0x784 base 0xedc insns 481/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0xe0(r1); B 0 stwu r1, -0x180(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERMi_AutoConfigThread 94.6% — src 0xa0 base 0xa0 insns 40/40; diffs 9: [0, 2, 3, 20, 22, 23, 34, 36, 38]; 0 M stwu r1, -0x30(r1); B stwu r1, -0x20(r1); remaining register/scheduling differences
src/scene/setting/ATERM: ATERM_81404844 19.615385% — src 0x19c base 0x1d4 insns 103/117; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x190(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81404A18 51.107437% — src 0x1c4 base 0x1e4 insns 113/121; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x1a0(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81404BFC 36.869404% — src 0x3dc base 0x430 insns 247/268; --- replace mine 0:6 base 0:20; M 0 lbz r7, 1(r4); M 1 cmplwi r5, 0x80; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_8140502C 35.666668% — src 0x280 base 0x228 insns 160/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81405254 30.464945% — src 0x3a4 base 0x43c insns 233/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81405690 26.601477% — src 0x3b4 base 0x43c insns 237/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81405ACC None% — src 0x17c base 0x240 insns 95/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:12 base 4:10; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81405D0C 32.62639% — src 0x9e4 base 0xb40 insns 633/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERMi_ApConfigStart 86.49515% — src 0x1a4 base 0x19c insns 105/103; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x30(r1); B 0 stwu r1, -0x20(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERMi_ApConfigEnd 87.54263% — src 0x1dc base 0x204 insns 119/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERMi_ApConfigGetState 99.42857% — src 0x8c base 0x8c insns 35/35; diffs 3: [17, 18, 20]; 17 M lwz r6, 0xf8(r6); B lwz r0, 0xf8(r6); remaining register/scheduling differences
src/scene/setting/AOSS: AOSS_Init_old 28.42298% — src 0x1794 base 0x18c0 insns 1509/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_813FFD68 96.981735% — src 0x364 base 0x36c insns 217/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_814001B4 41.518986% — src 0x118 base 0x13c insns 70/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_814002F0 79.525% — src 0x1c8 base 0x1e0 insns 114/120; --- replace mine 5:7 base 5:8; M 5 mr r30, r3; M 6 mr r26, r4; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_81400830 77.619934% — src 0x4b8 base 0x504 insns 302/321; --- insert mine 6:6 base 6:7; B 6 addi r29, r3, 0x18; --- insert mine 7:7 base 8:9; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_81400E0C 77.52105% — src 0x2c4 base 0x2f8 insns 177/190; --- insert mine 5:5 base 5:6; B 5 mr r29, r4; --- replace mine 6:8 base 7:8; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_814013AC 91.70175% — src 0x1cc base 0x1c8 insns 115/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_81401574 92.558136% — src 0x1fc base 0x204 insns 127/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_81401778 71.93407% — src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0); remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_81401C9C 71.9315% — src 0x12c base 0x124 insns 75/73; --- replace mine 0:6 base 0:2; M 0 stwu r1, -0x20(r1); M 1 mflr r0; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_81401DC0 99.375% — src 0xc0 base 0xc0 insns 48/48; diffs 4: [39, 41, 42, 43]; 39 M srwi r0, r3, 1; B srwi r3, r3, 1; remaining register/scheduling differences
src/scene/setting/AOSS: AOSS_81401E80 91.80272% — src 0x244 base 0x24c insns 145/147; --- replace mine 6:7 base 6:7; M 6 mr r28, r3; B 6 mr r21, r3; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_814020CC 76.066666% — src 0xf0 base 0xf0 insns 60/60; diffs 39: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 26]; 3 M addi r11, r1, 0x20; B stw r31, 0x1c(r1); remaining register/scheduling differences
MemoryBase full clean gate: 34/34 instruction-exact, code 3640/3640, data 144/152, pool identical, regressions 0, forbidden patterns 0, readability warnings 0, DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d, GATE PASS. Data remains incomplete in objdiff; no artificial fix attempted.

326
agent/sol-med-round2.md Normal file
View File

@@ -0,0 +1,326 @@
# ATERM and AOSS continuation
Baseline ATERM: 5/26, code 1108/19204, data 18440/18864, fuzzy 50.973755. Baseline AOSS: 8/21, code 2764/16192, data 3896/3928, fuzzy 63.720604. All functions have bodies; existing large state machine and crypto bodies remain incomplete reconstructions. No absent symbols or empty bodies found.
ATERM_8140276C initial 92.10345%
- previous cursor declaration before current cursor: no source change; skipped
- signed record indices: 92.10345%; src 0x2ac base 0x2b8 insns 171/174; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0x80(r1)
- AOSS flags initialized after clear: 91.72988%; src 0x2ac base 0x2b8 insns 171/174; --- replace mine 5:10 base 5:13; M 5 mr r25, r3; M 6 mr r26, r4
Retained best candidate
ATERM_81402A24 initial 72.47529%
- record byte count kept signed: no source change; skipped
- allocate nullable buffers before handling failure: 72.380226%; src 0x3cc base 0x41c insns 243/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
- multiply-high tick conversion: 75.76426%; src 0x3f4 base 0x41c insns 253/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
Retained best candidate
ATERM_81402E40 initial 99.791664%
- payload clear through byte alias: 99.791664%; src 0x180 base 0x180 insns 96/96; diffs 4: [9, 10, 47, 52]; 9 M mr r29, r7; B mr r3, r27
- natural checksum loop: 65.208336%; src 0x108 base 0x180 insns 66/96; --- replace mine 5:12 base 5:12; M 5 mr r28, r5; M 6 mr r26, r3
- end length as packet byte extent: 95.572914%; src 0x180 base 0x180 insns 96/96; diffs 6: [9, 10, 42, 44, 47, 52]; 9 M mr r29, r7; B mr r3, r27
Retained best candidate
ATERM_81402FC0 initial 67.28148%
- full-width checksum accumulator: 64.76296%; src 0x20c base 0x21c insns 131/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
- bottom-tested option loop: compile failed
- early return for bad checksum: 66.94074%; src 0x20c base 0x21c insns 131/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
Retained best candidate
ATERM_814031DC initial 85.7218%
- MAC text uses equal-sized buffers: 85.766914%; src 0x1f4 base 0x214 insns 125/133; --- replace mine 47:48 base 47:48; M 47 beq 288; B 47 beq 320
- nibble conversion advances output cursor: 84.293236%; src 0x204 base 0x214 insns 129/133; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x70(r1); B 0 stwu r1, -0x60(r1)
- inclusive digit bound and pointer-based MAC scan: 85.90225%; src 0x1f4 base 0x214 insns 125/133; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x70(r1); B 0 stwu r1, -0x60(r1)
Retained best candidate
ATERM_814033F0 initial 65.868614%
- option fields retain converted word width: 67.39416%; src 0x214 base 0x224 insns 133/137; --- replace mine 5:6 base 5:6; M 5 addi r30, r3, 8; B 5 addi r29, r3, 8
- bottom-tested parser dispatch: 65.79562%; src 0x21c base 0x224 insns 135/137; --- replace mine 5:6 base 5:6; M 5 addi r28, r3, 8; B 5 addi r29, r3, 8
- signed nibble comparisons: 65.32117%; src 0x21c base 0x224 insns 135/137; --- insert mine 7:7 base 7:8; B 7 li r24, 0; --- replace mine 10:29 base 11:17
Retained best candidate
ATERM_814036D8 initial 73.92742%
- security switch matches original decision tree: 85.22581%; src 0x1ec base 0x1f0 insns 123/124; --- replace mine 14:15 base 14:15; M 14 beq 340; B 14 beq 344
- key text passed through one cursor: 87.0%; src 0x1e4 base 0x1f0 insns 121/124; --- replace mine 14:24 base 14:16; M 14 bne 36; M 15 addi r3, r25, 0
- counted loop over key records: 73.92742%; src 0x1e0 base 0x1f0 insns 120/124; --- replace mine 14:24 base 14:16; M 14 bne 36; M 15 addi r3, r25, 0
Retained best candidate
ATERM_814038C8 initial 35.28917%
- one-shot 500ms wait replaces repeated alarm: 35.700314%; src 0x788 base 0xedc insns 482/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0xe0(r1); B 0 stwu r1, -0x180(r1)
- bottom-tested state machine and wait buffer order: 35.288116%; src 0x784 base 0xedc insns 481/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0xe0(r1); B 0 stwu r1, -0x180(r1)
- progress uses semantic structure: 35.28917%; src 0x784 base 0xedc insns 481/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0xe0(r1); B 0 stwu r1, -0x180(r1)
Retained best candidate
ATERM_81404844 initial 19.615385%
- complete RFC3394 block handling with target initial value and byte counter: 89.89744%; src 0x1bc base 0x1d4 insns 111/117; --- replace mine 6:13 base 6:13; M 6 lwz r8, 0(0); M 7 lwz r0, 0(0)
- hoist signed pass product outside block loop: 89.89744%; src 0x1bc base 0x1d4 insns 111/117; --- replace mine 6:13 base 6:13; M 6 lwz r8, 0(0); M 7 lwz r0, 0(0)
- natural bytewise counter XOR loop: 62.299145%; src 0x178 base 0x1d4 insns 94/117; --- replace mine 6:13 base 6:13; M 6 lwz r8, 0(0); M 7 lwz r0, 0(0)
Retained best candidate
ATERM_81404A18 initial 51.107437%
- complete RFC3394 block handling with target initial value and byte counter: 74.38843%; src 0x1c0 base 0x1e4 insns 112/121; --- replace mine 6:13 base 6:14; M 6 lwz r8, 0(0); M 7 lwz r0, 0(0)
- hoist signed pass product outside block loop: 74.38843%; src 0x1c0 base 0x1e4 insns 112/121; --- replace mine 6:13 base 6:14; M 6 lwz r8, 0(0); M 7 lwz r0, 0(0)
- natural bytewise counter XOR loop: 55.96694%; src 0x180 base 0x1e4 insns 96/121; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x190(r1); B 0 stwu r1, -0x1a0(r1)
Retained best candidate
ATERM_81404BFC initial 36.869404%
- complete AES schedules with bounded final expansion for all three key sizes: 52.50746%; src 0x408 base 0x430 insns 258/268; --- replace mine 0:6 base 0:20; M 0 lbz r7, 1(r4); M 1 cmplwi r5, 0x80
- direct expanded-key parameter used as advancing cursor: 52.50746%; src 0x408 base 0x430 insns 258/268; --- replace mine 0:6 base 0:20; M 0 lbz r7, 1(r4); M 1 cmplwi r5, 0x80
- round limit at loop bottom for 128-bit key: 53.074627%; src 0x404 base 0x430 insns 257/268; --- replace mine 0:6 base 0:20; M 0 lbz r7, 1(r4); M 1 cmplwi r5, 0x80
Retained best candidate
ATERM_8140502C initial 35.666668%
- interleaved key-word swaps: 42.355072%; src 0x280 base 0x228 insns 160/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0
- signed indexed round reversal: 38.746376%; src 0x290 base 0x228 insns 164/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0
- counted transformation loop: 11.731884%; src 0x288 base 0x228 insns 162/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0
Retained best candidate
ATERM_81405254 initial 30.464945%
- AES byte assembly uses XOR: 34.23247%; src 0x3c4 base 0x43c insns 241/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- two-round loop with final round exit: compile failed
- signed round count with separately combined key XOR: compile failed
Retained best candidate
ATERM_81405690 initial 26.601477%
- AES byte assembly uses XOR: 34.64945%; src 0x3d4 base 0x43c insns 245/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- two-round loop with final round exit: compile failed
- signed round count with separately combined key XOR: compile failed
Retained best candidate
ATERM_81405254 initial 34.23247%
- two-round AES loop with final round exit matching target structure: 16.295202%; src 0x4a8 base 0x43c insns 298/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- signed remaining round-pair count: 16.295202%; src 0x4a8 base 0x43c insns 298/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- separate round exit before key advancement: 17.630997%; src 0x4a8 base 0x43c insns 298/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
Retained best candidate
ATERM_81405690 initial 34.64945%
- two-round AES loop with final round exit matching target structure: 33.738007%; src 0x4c8 base 0x43c insns 306/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- signed remaining round-pair count: 33.738007%; src 0x4c8 base 0x43c insns 306/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- separate round exit before key advancement: 31.90037%; src 0x4c8 base 0x43c insns 306/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
Retained best candidate
ATERM_81405D0C initial 32.62639%
- complete MD5 accumulator rotation with per-step argument-relative selectors: 53.851387%; src 0xa50 base 0xb40 insns 660/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1)
- MD5 selectors expressed as XOR masks: 44.879166%; src 0xa48 base 0xb40 insns 658/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1)
- natural sixteen-word little-endian block decode: 47.679165%; src 0x970 base 0xb40 insns 604/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1)
Retained best candidate
ATERMi_ApConfigGetState initial 99.42857%
- read bus clock before current time call: 72.942856%; src 0x94 base 0x8c insns 37/35; --- replace mine 4:6 base 4:5; M 4 stw r30, 8(r1); M 5 mr r30, r3
- direct timer division using clock conversion expression: 99.42857%; src 0x8c base 0x8c insns 35/35; diffs 3: [17, 18, 20]; 17 M lwz r6, 0xf8(r6); B lwz r0, 0xf8(r6)
- timer load narrowed to native clock register width: 99.42857%; src 0x8c base 0x8c insns 35/35; diffs 4: [15, 16, 17, 18]; 15 M lis r5, -0x8000; B lis r6, -0x8000
Retained best candidate
ATERM_81402E40 initial 99.791664%
- checksum terminal pointer declared before byte length: 99.791664%; src 0x180 base 0x180 insns 96/96; diffs 4: [9, 10, 47, 52]; 9 M mr r29, r7; B mr r3, r27
- payload encryption size retained as signed integer: 99.791664%; src 0x180 base 0x180 insns 96/96; diffs 4: [9, 10, 47, 52]; 9 M mr r29, r7; B mr r3, r27
- end pointer assigned only after header conversion: 94.947914%; src 0x180 base 0x180 insns 96/96; diffs 8: [9, 10, 42, 44, 45, 46, 47, 52]; 9 M mr r29, r7; B mr r3, r27
Retained best candidate
ATERMi_AutoConfigThread initial 94.6%
- callback progress uses three-field structure: 94.75%; src 0xa0 base 0xa0 insns 40/40; diffs 3: [20, 22, 23]; 20 M nor r0, r3, r0; B nor r3, r3, r0
- signed completion state mask in correctly sized progress buffer: 94.75%; src 0xa0 base 0xa0 insns 40/40; diffs 3: [20, 22, 23]; 20 M nor r0, r3, r0; B nor r3, r3, r0
- explicit completion state branch in progress structure: 85.25%; src 0x9c base 0xa0 insns 39/40; --- replace mine 18:21 base 18:22; M 18 addi r0, r31, -1; M 19 li r5, -1
Retained best candidate
ATERM_814021BC initial 67.655846%
- interface configuration pointer initialized before IP setup: 64.266235%; src 0x264 base 0x268 insns 153/154; --- replace mine 7:8 base 7:8; M 7 addi r28, r30, 0; B 7 addi r30, r30, 0
- wait queue message and buffer order follows target stack slots: 67.64286%; src 0x264 base 0x268 insns 153/154; --- insert mine 7:7 base 7:9; B 7 addi r30, r30, 0; B 8 li r4, 0
- host wait expressed as while with shared converted host value: 92.77922%; src 0x274 base 0x268 insns 157/154; --- replace mine 5:8 base 5:8; M 5 lis r31, 0; M 6 li r28, 0
Retained best candidate
ATERM_8140276C initial 92.10345%
- previous-record cursor reset at outer loop tail and scoped fallback flags: 94.04023%; src 0x2b0 base 0x2b8 insns 172/174; --- replace mine 5:11 base 5:13; M 5 mr r25, r3; M 6 mr r26, r4
- previous record initialized before current record: 94.0115%; src 0x2b0 base 0x2b8 insns 172/174; --- replace mine 5:11 base 5:13; M 5 mr r25, r3; M 6 mr r26, r4
- fallback flags set after SSID clear: 94.04023%; src 0x2b0 base 0x2b8 insns 172/174; --- replace mine 5:11 base 5:13; M 5 mr r25, r3; M 6 mr r26, r4
Retained best candidate
ATERM_81405ACC initial 0%
- complete two-phase update copy with target eight-byte group bounds: 55.54861%; src 0x21c base 0x240 insns 135/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:7 base 4:10
- signed byte-copy loop cursors: 55.54861%; src 0x21c base 0x240 insns 135/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:7 base 4:10
- cursor-pair copies instead of repeated indexed addresses: 55.54861%; src 0x21c base 0x240 insns 135/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:7 base 4:10
Retained best candidate
Retained complete update implementation: objdiff 55.54861%, 135/144 instructions. Older source had no reported function score; no exact claim.
ATERMi_ApConfigStart initial 86.49515%
- allocate via stored callback: 86.49515%; src 0x1a4 base 0x19c insns 105/103; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x30(r1); B 0 stwu r1, -0x20(r1)
- tick multiplier commutes operands: 84.11651%; src 0x1a4 base 0x19c insns 105/103; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x30(r1); B 0 stwu r1, -0x20(r1)
- progress callback loaded from installed function pointer: 93.718445%; src 0x1a0 base 0x19c insns 104/103; --- delete mine 4:5 base 4:4; M 4 mr r31, r3; --- replace mine 6:7 base 5:6
Retained best candidate
ATERMi_ApConfigEnd initial 87.54263%
- message queues declared within their wait scopes: 85.496124%; src 0x1dc base 0x204 insns 119/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0
- join loop expressed as do-while: 85.28682%; src 0x1e8 base 0x204 insns 122/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0
- time conversion evaluated directly: 87.54263%; src 0x1dc base 0x204 insns 119/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0
Retained best candidate
ATERM_81402FC0 initial 67.28148%
- signed option payload cursor length: no source change; skipped
- checksum receive pointer read after length decode: 67.28148%; src 0x210 base 0x21c insns 132/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
- option traversal explicit continuation: 67.28148%; src 0x210 base 0x21c insns 132/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
Retained best candidate
ATERM_81402A24 initial 75.76426%
- record allocation size held as size_t: no source change; skipped
Retained best candidate
ATERM_81402FC0 initial 67.28148%
- packet and option values stay full-width until usage: 68.577774%; src 0x208 base 0x21c insns 130/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- delete mine 15:16 base 16:16
- full-width checksum accumulated before explicit final narrowing: 67.28148%; src 0x210 base 0x21c insns 132/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
- option lengths retained as signed word count: 67.28148%; src 0x210 base 0x21c insns 132/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
Retained best candidate
ATERM_81402A24 initial 75.76426%
- record allocation byte count stored in size_t: 75.76426%; src 0x3f4 base 0x41c insns 253/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
- iteration counter narrowed to signed timer range: 76.20532%; src 0x3f4 base 0x41c insns 253/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
- record pointer walk and indexed record walk share cursor: 75.76426%; src 0x3f4 base 0x41c insns 253/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
Retained best candidate
ATERM reconstruction evidence: all 26 target function names have source bodies. Reconstructed RFC3394 wrap/unwrap initial value, signed counters, block writeback and unwrap ordering; corrected all three AES key schedules; corrected MD5 per-step accumulator/selector semantics and low/high bit counts; reconstructed the missing authentication timestamp digest and protocol option-id bytes in the main state machine. These are partial instruction matches, not completion.
Native validation of extracted unchanged crypto implementations: NIST AES 128/192/256 encryption and decryption vectors passed. MD5 messages of length 0, 1, 3, 55, 56, 64, 130 matched hashlib. Native correctness is supplemental evidence only; MWCC objdiff remains the matching authority.
Data attempts: ordinary local option-id initialization restored the real seven-byte constant sequence; .sdata2 reached 100%. Genuine MD5 fill array emitted locally, then as an ordinary named global after the state-machine function to preserve jump-table/source order. .data remains incomplete because the three generated jump tables still differ. AES tables and round constants remain byte-identical .rodata.
Data attempt: restored the genuine request-options pointer initializer shown in target .sdata; it completed .sdata but moved the response buffer before the thread in .bss and caused objdiff .bss 100 -> 83.33333 and a matched-data regression. Tried source declaration order, original thread name, and original section-aligned network buffer declaration; none passed the regression gate. Restored the pointer attempt and kept the existing BSS layout. No artificial padding, address symbols, or forced sections retained. .sdata and .sbss remain open.
Initial AOSS trial batch failed to compile because of a mistaken message-length field name in the packet dispatcher; corrected the field and reran all trials successfully. Failed batch not counted as attempts.
AOSS_Init_old initial 28.42298%
- full-width wait counters instead of narrowing every update: 28.546717%; src 0x1758 base 0x18c0 insns 1494/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b
- packet length conversion retains full width: 28.42298%; src 0x1794 base 0x18c0 insns 1509/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b
- poll arguments given semantic socket events structure: 28.42298%; src 0x1794 base 0x18c0 insns 1509/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b
Retained best candidate
AOSS_813FFD68 initial 96.981735%
- validation loops use signed char: 93.69406%; src 0x364 base 0x36c insns 217/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
- return failure immediately on invalid character: 82.05023%; src 0x2ec base 0x36c insns 187/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
- ascending validation cursor loop: 94.76712%; src 0x374 base 0x36c insns 221/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
Retained best candidate
AOSS_814001B4 initial 88.78481%
- converted packet length stays full width: 88.78481%; src 0x12c base 0x13c insns 75/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
- direct opcode return cases: 83.27848%; src 0x124 base 0x13c insns 73/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
- full-width validation and branch nesting: no source change; skipped
Retained best candidate
AOSS_814002F0 initial 79.525%
- read manufacturer only after state validation: 85.058334%; src 0x1c4 base 0x1e0 insns 113/120; --- replace mine 6:8 base 6:8; M 6 mr r30, r3; M 7 mr r26, r4
- packet sequence values remain full-width: 76.441666%; src 0x1c4 base 0x1e0 insns 113/120; --- replace mine 5:7 base 5:8; M 5 mr r30, r3; M 6 mr r26, r4
- direct address error branch: 79.525%; src 0x1c8 base 0x1e0 insns 114/120; --- replace mine 5:7 base 5:8; M 5 mr r30, r3; M 6 mr r26, r4
Retained best candidate
AOSS_81400830 initial 77.619934%
- single-byte RC4 generation loop instead of manual pairs: 65.65109%; src 0x3c0 base 0x504 insns 240/321; --- insert mine 6:6 base 6:7; B 6 addi r29, r3, 0x18; --- insert mine 7:7 base 8:9
- natural CRC byte loop: 60.13084%; src 0x3c4 base 0x504 insns 241/321; --- replace mine 5:6 base 5:7; M 5 mr r27, r3; B 5 mr r26, r3
- narrow RC4 state indices at assignment: 77.619934%; src 0x4b8 base 0x504 insns 302/321; --- insert mine 6:6 base 6:7; B 6 addi r29, r3, 0x18; --- insert mine 7:7 base 8:9
Retained best candidate
AOSS_81400E0C initial 77.52105%
- signed option lengths and iteration indices: 77.778946%; src 0x2bc base 0x2f8 insns 175/190; --- insert mine 5:5 base 5:6; B 5 mr r29, r4; --- replace mine 6:8 base 7:8
- natural integer byte decode for both address options: 44.963158%; src 0x188 base 0x2f8 insns 98/190; --- insert mine 5:5 base 5:6; B 5 mr r29, r4; --- replace mine 6:8 base 7:8
- address decode accumulation uses OR: 61.963158%; src 0x284 base 0x2f8 insns 161/190; --- replace mine 5:8 base 5:8; M 5 mr r29, r3; M 6 mr r30, r4
Retained best candidate
AOSS_814013AC initial 91.70175%
- signed option lengths: 91.70175%; src 0x1cc base 0x1c8 insns 115/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
- apply flags after successful parser call: 84.68421%; src 0x1ec base 0x1c8 insns 123/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
- bounded while loop over selected reply payload: 88.2807%; src 0x1d4 base 0x1c8 insns 117/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
Retained best candidate
AOSS_81401574 initial 92.558136%
- semantic payload extent expression: 92.558136%; src 0x1fc base 0x204 insns 127/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4
- request length remains full-width: 92.209305%; src 0x1f8 base 0x204 insns 126/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4
- initialize destination length before port conversion: 88.31783%; src 0x1fc base 0x204 insns 127/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4
Retained best candidate
AOSS_81401778 initial 71.93407%
- CRC checksum stays full width until header store: 71.93407%; src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0)
- signed RC4 byte loop index: 71.93407%; src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0)
- copy hello payload before manufacturer encoding: 71.91575%; src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0)
Retained best candidate
AOSS_81401C9C initial 71.9315%
- natural RC4 state initialization loop: 43.342464%; src 0x98 base 0x124 insns 38/73; --- replace mine 0:1 base 0:2; M 0 li r9, 0; B 0 stwu r1, -0x10(r1)
- schedule state reset before obtaining byte pointer: 71.9315%; src 0x12c base 0x124 insns 75/73; --- replace mine 0:6 base 0:2; M 0 stwu r1, -0x20(r1); M 1 mflr r0
- signed key and state indices: 71.9315%; src 0x12c base 0x124 insns 75/73; --- replace mine 0:6 base 0:2; M 0 stwu r1, -0x20(r1); M 1 mflr r0
Retained best candidate
AOSS_81401E80 initial 91.80272%
- natural XOR loop over half-packet: 56.455784%; src 0x168 base 0x24c insns 90/147; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x30(r1); B 0 stwu r1, -0x40(r1)
- half-length via signed division: 87.04082%; src 0x240 base 0x24c insns 144/147; --- replace mine 5:19 base 5:13; M 5 srawi r0, r4, 1; M 6 mr r28, r3
- count-down rounds: 88.734695%; src 0x244 base 0x24c insns 145/147; --- replace mine 6:7 base 6:7; M 6 mr r28, r3; B 6 mr r21, r3
Retained best candidate
AOSS_814020CC initial 76.066666%
- sleep tick product stays 64-bit: 67.51667%; src 0xfc base 0xf0 insns 63/60; --- replace mine 3:6 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
- tick duration via explicit multiply-high: 81.65%; src 0xe4 base 0xf0 insns 57/60; --- replace mine 3:5 base 3:6; M 3 addi r11, r1, 0x20; M 4 bl 0
- do-while host acquisition loop: 65.066666%; src 0xf8 base 0xf0 insns 62/60; --- replace mine 3:6 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
Retained best candidate
AOSS_81401DC0 initial 99.375%
- CRC output accumulator reuses incoming seed value: 99.375%; src 0xc0 base 0xc0 insns 48/48; diffs 4: [39, 41, 42, 43]; 39 M srwi r0, r3, 1; B srwi r3, r3, 1
- last CRC bit combined with conditional polynomial: 80.916664%; src 0xc8 base 0xc0 insns 50/48; --- delete mine 0:1 base 0:0; M 0 lis r3, -0x1247; --- replace mine 2:4 base 1:2
- ordinary counted loop for eight CRC polynomial steps: 24.833334%; src 0x40 base 0xc0 insns 16/48; --- insert mine 0:0 base 0:1; B 0 li r0, 0x100; --- delete mine 1:3 base 2:2
Retained best candidate
AOSS_Init_old initial 28.546717%
- network settings alignment follows target 32-byte stack contract: 24.69697%; src 0x17f8 base 0x18c0 insns 1534/1584; --- replace mine 8:9 base 8:11; M 8 li r14, 0; B 8 lhz r4, 0(0)
- request records alignment follows target stack offset a0: 24.69697%; src 0x17f8 base 0x18c0 insns 1534/1584; --- replace mine 8:9 base 8:11; M 8 li r14, 0; B 8 lhz r4, 0(0)
- both network settings and request records use observed stack alignment: 24.69697%; src 0x17f8 base 0x18c0 insns 1534/1584; --- replace mine 8:9 base 8:11; M 8 li r14, 0; B 8 lhz r4, 0(0)
Retained best candidate
AOSS_814001B4 initial 88.78481%
- opcode uses full-width switch expression after conversion: 88.78481%; src 0x12c base 0x13c insns 75/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
- rejection increments written as explicit count stores: 88.78481%; src 0x12c base 0x13c insns 75/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
- validation represented by a named result before rejection: 88.78481%; src 0x12c base 0x13c insns 75/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
Retained best candidate
AOSS_814013AC initial 91.70175%
- outer response stride evaluated once before cursor advancement: 91.70175%; src 0x1cc base 0x1c8 insns 115/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
- one option cursor serves outer and inner traversal: 91.70175%; src 0x1cc base 0x1c8 insns 115/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
- config flags initialization delayed until matching response is located: 89.60526%; src 0x1cc base 0x1c8 insns 115/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
Retained best candidate
AOSS .sbss source-order reconstruction: moved real existing address/status declarations into original address order; 28.57143 -> 57.14286.
- explicit zero initialization of owned pointer globals: 42.857143%; original source restored if no improvement.
- explicit zero initialization of runtime status globals: 57.14286%; original source restored if no improvement.
- ordinary zero initialization of access-point address bytes: 28.57143%; original source restored if no improvement.
AOSS dispatch reconstruction: rejected empty/type/validation failures return immediately and opcode dispatch uses a switch; 41.518986 -> 88.78481%, 75/79 instructions. Remaining four instructions are prologue/epilogue save helpers versus individual register saves; three additional real source variations did not change them.
AOSS_Init_old has a body for every observed state path; six distinct attempts logged. Restored narrow wait counters despite a small fuzzy gain from widening, because the original performs signed 16-bit wrapping assignments. Observed 32-byte stack alignment trials all worsened codegen and were restored. Renamed existing decompiler labels to meaningful state/cleanup names.
AOSS .data/.bss/.sdata/.sdata2 remain 100%; ordinary source declaration reordering improves .sbss to 57.14286 but does not finish its symbol associations. Three normal initialization forms produced no further improvement and were restored. No forced sections, padding, address-pinning symbols, or table blobs added.
Current handoff: remaining functions and instruction evidence
ATERM_814021BC 92.77922%: src 0x274 base 0x268 insns 157/154; --- replace mine 5:8 base 5:8; M 5 lis r31, 0; M 6 li r28, 0; M 7 addi r3, r31, 0
ATERM_8140276C 94.04023%: src 0x2b0 base 0x2b8 insns 172/174; --- replace mine 5:11 base 5:13; M 5 mr r25, r3; M 6 mr r26, r4; M 7 mr r27, r5
ATERM_81402A24 76.20532%: src 0x3f4 base 0x41c insns 253/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1); --- replace mine 2:4 base 2:4
ATERM_81402E40 99.791664%: src 0x180 base 0x180 insns 96/96; diffs 4: [9, 10, 47, 52]; 9 M mr r29, r7; B mr r3, r27; 10 M mr r3, r27
ATERM_81402FC0 68.577774%: src 0x208 base 0x21c insns 130/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- delete mine 15:16 base 16:16; M 15 li r31, 0
ATERM_814031DC 85.90225%: src 0x1f4 base 0x214 insns 125/133; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x70(r1); B 0 stwu r1, -0x60(r1); --- replace mine 4:6 base 4:6
ATERM_814033F0 67.39416%: src 0x214 base 0x224 insns 133/137; --- replace mine 5:6 base 5:6; M 5 addi r30, r3, 8; B 5 addi r29, r3, 8; --- insert mine 7:7 base 7:8
ATERM_814036D8 87.0%: src 0x1e4 base 0x1f0 insns 121/124; --- replace mine 14:24 base 14:16; M 14 bne 36; M 15 addi r3, r25, 0; M 16 li r0, 4
ATERM_814038C8 41.043114%: src 0x9b4 base 0xedc insns 621/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x140(r1); B 0 stwu r1, -0x180(r1); --- replace mine 2:4 base 2:4
ATERMi_AutoConfigThread 94.75%: src 0xa0 base 0xa0 insns 40/40; diffs 3: [20, 22, 23]; 20 M nor r0, r3, r0; B nor r3, r3, r0; 22 M srawi r3, r0, 0x1f
ATERM_81404844 92.62393%: src 0x1bc base 0x1d4 insns 111/117; --- replace mine 8:13 base 8:13; M 8 mr r29, r3; M 9 mr r22, r4; M 10 mr r23, r5
ATERM_81404A18 75.82645%: src 0x1c0 base 0x1e4 insns 112/121; --- replace mine 8:13 base 8:14; M 8 mr r29, r3; M 9 mr r21, r4; M 10 mr r22, r5
ATERM_81404BFC 74.36194%: src 0x46c base 0x430 insns 283/268; --- replace mine 6:7 base 6:7; M 6 cmplwi r5, 0x80; B 6 cmpwi r5, 0x80; --- delete mine 38:40 base 38:38
ATERM_8140502C 42.355072%: src 0x280 base 0x228 insns 160/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0; B 7 addi r30, r30, 0
ATERM_81405254 34.23247%: src 0x3c4 base 0x43c insns 241/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1); --- replace mine 2:4 base 2:4
ATERM_81405690 34.64945%: src 0x3d4 base 0x43c insns 245/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1); --- replace mine 2:4 base 2:4
ATERM_81405ACC 55.54861%: src 0x21c base 0x240 insns 135/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:7 base 4:10; M 3 addi r11, r1, 0x20
ATERM_81405D0C 53.851387%: src 0xa50 base 0xb40 insns 660/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1); --- replace mine 2:4 base 2:4
ATERMi_ApConfigStart 93.718445%: src 0x1a0 base 0x19c insns 104/103; --- delete mine 4:5 base 4:4; M 4 mr r31, r3; --- replace mine 6:7 base 5:6; M 6 mr r30, r8
ATERMi_ApConfigEnd 87.54263%: src 0x1dc base 0x204 insns 119/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0; B 3 stw r31, 0xdc(r1)
ATERMi_ApConfigGetState 99.42857%: src 0x8c base 0x8c insns 35/35; diffs 3: [17, 18, 20]; 17 M lwz r6, 0xf8(r6); B lwz r0, 0xf8(r6); 18 M addi r0, r5, 0x4dd3
AOSS_Init_old 28.42298%: src 0x1794 base 0x18c0 insns 1509/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b; B 1 mr r12, r1
AOSS_813FFD68 96.981735%: src 0x364 base 0x36c insns 217/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0; B 3 stw r31, 0x1c(r1)
AOSS_814001B4 88.78481%: src 0x12c base 0x13c insns 75/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0; B 3 stw r31, 0x1c(r1)
AOSS_814002F0 85.058334%: src 0x1c4 base 0x1e0 insns 113/120; --- replace mine 6:8 base 6:8; M 6 mr r30, r3; M 7 mr r26, r4; B 6 mr r26, r3
AOSS_81400830 77.619934%: src 0x4b8 base 0x504 insns 302/321; --- insert mine 6:6 base 6:7; B 6 addi r29, r3, 0x18; --- insert mine 7:7 base 8:9; B 8 li r5, 8
AOSS_81400E0C 77.778946%: src 0x2bc base 0x2f8 insns 175/190; --- insert mine 5:5 base 5:6; B 5 mr r29, r4; --- replace mine 6:8 base 7:8; M 6 mr r29, r4
AOSS_814013AC 91.70175%: src 0x1cc base 0x1c8 insns 115/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8; M 7 mr r27, r3
AOSS_81401574 92.558136%: src 0x1fc base 0x204 insns 127/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4; B 5 lwz r27, 0(0)
AOSS_81401778 71.93407%: src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0); B 5 lwz r28, 0(0)
AOSS_81401C9C 71.9315%: src 0x12c base 0x124 insns 75/73; --- replace mine 0:6 base 0:2; M 0 stwu r1, -0x20(r1); M 1 mflr r0; M 2 stw r0, 0x24(r1)
AOSS_81401DC0 99.375%: src 0xc0 base 0xc0 insns 48/48; diffs 4: [39, 41, 42, 43]; 39 M srwi r0, r3, 1; B srwi r3, r3, 1; 41 M xoris r0, r0, 0xedb8
AOSS_81401E80 91.80272%: src 0x244 base 0x24c insns 145/147; --- replace mine 6:7 base 6:7; M 6 mr r28, r3; B 6 mr r21, r3; --- replace mine 8:20 base 8:13
AOSS_814020CC 81.65%: src 0xe4 base 0xf0 insns 57/60; --- replace mine 3:5 base 3:6; M 3 addi r11, r1, 0x20; M 4 bl 0; B 3 stw r31, 0x1c(r1)
Supplemental native crypto validation: NIST AES-128/192/256 encrypt/decrypt vectors passed; MD5 lengths 0, 1, 3, 55, 56, 64, 130 and streaming chunks 1, 7, 55, 63, 64, 65, 127 over 512 bytes passed against hashlib. RFC3394 wrap/unwrap passed using a temporary native test copy that explicitly emulates Wii big-endian counter bytes; unchanged x86 union byte order does not emulate the target. Tests reside under /tmp; MWCC object and gate remain matching authority.

View File

@@ -11,12 +11,23 @@ splits: 'config/43U/splits.txt'
ldscript_template: 'config/ldscript_ipl2.lcf'
force_active:
- fprintf
- leap_days
- __msl_time2tm
- __tm2time
- clock
- mktime
- localtime
- emit
- __MSL_ISO8601NewYear
- __MSL_ISO8601Week
- strftime
- labs
- atol
- itoa
- strpbrk
- strspn
- strcspn
- atol
- padding__Q23ipl5scene
- lbl_81695063
- lbl_81695067

View File

@@ -1111,7 +1111,7 @@ src/keyboard/MyTiInputForm.cpp:
src/keyboard/MyTiLetterForm.cpp:
.text start:0x81444730 end:0x814454D8
.rodata start:0x816168B8 end:0x81616B88
.rodata start:0x816168B8 end:0x81616BC8
.data start:0x81668860 end:0x81668CD8
.sdata2 start:0x81694EB0 end:0x81694ED0
.sdata start:0x81697528 end:0x81697570
@@ -1138,7 +1138,7 @@ src/keyboard/tiHKBManager.cpp:
src/keyboard/tiHwKeyboard.cpp:
.bss start:0x810C8940 end:0x810C8950
.text start:0x81448AA4 end:0x81449C98
.rodata start:0x81616B88 end:0x81616C78
.rodata start:0x81616BC8 end:0x81616C78
.data start:0x81668EF8 end:0x81669018
.sdata2 start:0x81694EF8 end:0x81694F08
.sdata start:0x81697570 end:0x81697578
@@ -1405,7 +1405,7 @@ libs/RVLMiddleware/eZiText/src/clib/zikorean.c:
extab start:0x81330748 end:0x81330760
extabindex start:0x8133147C end:0x813314A0
.text start:0x814813FC end:0x81482840
.data start:0x8166B2B0 end:0x8166B3D0
.data start:0x8166B2B0 end:0x8166B3A8
libs/RVLMiddleware/eZiText/src/clib/ziswordw.c:
extab start:0x81330760 end:0x81330770
@@ -1417,6 +1417,7 @@ libs/RVLMiddleware/eZiText/src/clib/zkokeyp.c:
extab start:0x81330770 end:0x813307A8
extabindex start:0x813314B8 end:0x8133150C
.text start:0x8148302C end:0x8148447C
.data start:0x8166B3A8 end:0x8166B3D0
libs/RVLMiddleware/eZiText/src/clib/zierror.c:
.text start:0x8148447C end:0x81484484
@@ -4192,11 +4193,11 @@ libs/RVL_SDK/src/fa/driver/nand_drv.c:
.sbss start:0x816996C0 end:0x816996E0
libs/RVL_SDK/src/fa/driver/sd_drv.c:
.bss start:0x811AF460 end:0x811AF6C0
.bss start:0x811AF460 end:0x811AF6C0 align:32
.text start:0x815EA41C end:0x815ED20C
.rodata start:0x816329E8 end:0x81632B58
.data start:0x81690D18 end:0x81691728
.sbss start:0x816996E0 end:0x81699708
.sbss start:0x816996E0 end:0x81699708 align:32
libs/RVL_SDK/src/fa/driver/pfd_cmn.c:
.text start:0x815ED20C end:0x815ED324

View File

@@ -2042,8 +2042,8 @@ isEqualChannel__Q33ipl8savedata7ManagerFUxUx = .text:0x813594B0; // type:functio
isDefaultChannel__Q33ipl8savedata7ManagerFUlUl = .text:0x8135954C; // type:function size:0x50
updateVersion__Q33ipl8savedata7ManagerFUlUl = .text:0x8135959C; // type:function size:0xD4
setDefaultSDMenu__Q33ipl8savedata7ManagerFv = .text:0x81359670; // type:function size:0x48 scope:local
iplSavedata_813596B8__Q33ipl8savedata7ManagerFUx = .text:0x813596B8; // type:function size:0xE8
iplSavedata_813597A0 = .text:0x813597A0; // type:function size:0x40 scope:local
pushTitleCache__Q33ipl8savedata7ManagerFUx = .text:0x813596B8; // type:function size:0xE8
isTitleCached = .text:0x813597A0; // type:function size:0x40
nand_error_handling__Q33ipl8savedata7ManagerFi = .text:0x813597E0; // type:function size:0xDC
__ct__Q33ipl7channel9RsoThreadFPQ23EGG4Heap = .text:0x813598BC; // type:function size:0x6C
__dt__Q33ipl7channel9RsoThreadFv = .text:0x81359928; // type:function size:0x70
@@ -2095,7 +2095,7 @@ stt_wait_fns_msg__Q23ipl9CdbBackupFv = .text:0x8135B004; // type:function size:0
stt_clean_up_back__Q23ipl9CdbBackupFv = .text:0x8135B030; // type:function size:0x60
stt_wait_terminate__Q23ipl9CdbBackupFv = .text:0x8135B090; // type:function size:0x60
error_handling__Q23ipl9CdbBackupFv = .text:0x8135B0F0; // type:function size:0xD0
fn_8135B1C0__Q23ipl9CdbBackupFv = .text:0x8135B1C0; // type:function size:0x28
getProgressPercent__Q23ipl9CdbBackupFv = .text:0x8135B1C0; // type:function size:0x28
cdb_backup_delete_search_cb___3iplFPvP10_CDBRecord = .text:0x8135B1E8; // type:function size:0x8C
cdb_backup_delete_task___3iplFPv = .text:0x8135B274; // type:function size:0xDC
cdb_backup_move_search_cb___3iplFPvP10_CDBRecord = .text:0x8135B350; // type:function size:0xBC
@@ -5126,8 +5126,8 @@ __ct__Q33ipl5scene10AOSSThreadFPQ23EGG4Heap = .text:0x813FCA0C; // type:function
destroy__Q33ipl5scene10AOSSThreadFi = .text:0x813FCAA0; // type:function size:0x84
__dt__Q33ipl5scene10AOSSThreadFv = .text:0x813FCB24; // type:function size:0x70
start__Q33ipl5scene10AOSSThreadFv = .text:0x813FCB94; // type:function size:0xF8
AOSSThread_813FCC8C__Q33ipl5scene10AOSSThreadFv = .text:0x813FCC8C; // type:function size:0x58
AOSSThread_813FCCE4__Q33ipl5scene10AOSSThreadFv = .text:0x813FCCE4; // type:function size:0x50
aossAlloc__Q33ipl5scene10AOSSThreadFv = .text:0x813FCC8C; // type:function size:0x58
aossFree__Q33ipl5scene10AOSSThreadFv = .text:0x813FCCE4; // type:function size:0x50
Run__Q33ipl5scene10AOSSThreadFv = .text:0x813FCD34; // type:function size:0xEC
cancel__Q33ipl5scene10AOSSThreadFv = .text:0x813FCE20; // type:function size:0x50
finish__Q33ipl5scene10AOSSThreadFP13NCDAossConfigPi = .text:0x813FCE70; // type:function size:0x2FC
@@ -5829,7 +5829,7 @@ doAfterDrawProcess__Q39textinput9inputform4BaseFPCwUlRCQ49textinput10textdrawer4
finishDraw__Q39textinput9inputform4BaseFUl = .text:0x81427DC0; // type:function size:0x4
addSender__Q29textinput15CommandReceiverFPQ29textinput13CommandSender = .text:0x81427DC4; // type:function size:0x8
getDrawModifyStartLine__Q39textinput10textdrawer4BaseCFv = .text:0x81427DCC; // type:function size:0x8
isEnableCursorCache__Q39textinput10textdrawer4BaseCFvgetStartPos__Q39textinput10textdrawer4BaseCFv = .text:0x81427DD4; // type:function size:0x8
isEnableCursorCache__Q39textinput10textdrawer4BaseCFv = .text:0x81427DD4; // type:function size:0x8
getStartPos__Q39textinput10textdrawer4BaseCFv = .text:0x81427DDC; // type:function size:0x8
setVIWidth__Q39textinput10textdrawer4BaseFf = .text:0x81427DE4; // type:function size:0x8
setCandidateBox__Q39textinput12candidatebox18CandidateBoxCallerFPQ39textinput12candidatebox4Base = .text:0x81427DEC; // type:function size:0x8
@@ -13113,7 +13113,7 @@ pfstub_com_massage = .text:0x815E6C40; // type:function size:0xE4
pfstub_store_result = .text:0x815E6D24; // type:function size:0xC4
PFSYS_initializeSYS = .text:0x815E6DE8; // type:function size:0x4
PFSYS_GetCurrentContextID = .text:0x815E6DEC; // type:function size:0x18
PFSYS_TimeStamp = .text:0x815E6E04; // type:function size:0x74
PFSYS_TimeStamp = .text:0x815E6E04; // type:function size:0x7C
pfstub_call_function_standard = .text:0x815E6E80; // type:function size:0x584
pfstub_attach = .text:0x815E7404; // type:function size:0x50
pfstub_buffering = .text:0x815E7454; // type:function size:0x50
@@ -13202,7 +13202,7 @@ pfd_sddrv_pread = .text:0x815EAADC; // type:function size:0x38
pfd_sddrv_pwrite = .text:0x815EAB14; // type:function size:0x38
pfd_sddrv_unmount = .text:0x815EAB4C; // type:function size:0x34
pfd_sddrv_finalize = .text:0x815EAB80; // type:function size:0xE4
pfd_sddrv_get_disk_info = .text:0x815EAC64; // type:function size:0x180
pfd_sddrv_get_disk_info = .text:0x815EAC64; // type:function size:0x188
pfd_sddrv_init_drv_tbl = .text:0x815EADEC; // type:function size:0x18
pfd_sddrv_registar_callback = .text:0x815EAE04; // type:function size:0x10
pfd_sddrv_is_media_insert = .text:0x815EAE14; // type:function size:0x98
@@ -13986,8 +13986,8 @@ lbl_81616AE4 = .rodata:0x81616AE4; // type:object size:0x30
lbl_81616B14 = .rodata:0x81616B14; // type:object size:0x74
lbl_81616B88 = .rodata:0x81616B88; // type:object size:0x40
lbl_81616BC8 = .rodata:0x81616BC8; // type:object size:0x10 data:4byte
lbl_81616BD8 = .rodata:0x81616BD8; // type:object size:0xC
lbl_81616BE4 = .rodata:0x81616BE4; // type:object size:0xC
scCountryMap_EU = .rodata:0x81616BD8; // type:object size:0xC
scCountryMap_NonEU = .rodata:0x81616BE4; // type:object size:0xC
lbl_81616BF0 = .rodata:0x81616BF0; // type:object size:0x88
CHANSVmConstStringObjectUndefined = .rodata:0x81616C78; // type:object size:0x10
lbl_81616C88 = .rodata:0x81616C88; // type:object size:0x10
@@ -14994,8 +14994,8 @@ __vt__Q37ext_ead3www14SurfaceManager = .data:0x81643AA0; // type:object size:0xC
@1183 = .data:0x81643AB8; // type:object size:0x21 scope:local data:string
__vt__Q37ext_ead3www9ut_thread = .data:0x81643ADC; // type:object size:0x28
lbl_81643B08 = .data:0x81643B08; // type:object size:0x38
lbl_81643B40 = .data:0x81643B40; // type:object size:0x1E data:string
lbl_81643B5E = .data:0x81643B5E; // type:object size:0x24 data:string
scWwwTexBufFmt = .data:0x81643B40; // type:object size:0x1E data:string
scWwwNoBrowserWin = .data:0x81643B5E; // type:object size:0x24 data:string
lbl_81643B82 = .data:0x81643B82; // type:object size:0x1B data:string
lbl_81643B9D = .data:0x81643B9D; // type:object size:0x2B data:string
lbl_81643BC8 = .data:0x81643BC8; // type:object size:0x12 data:string
@@ -15673,11 +15673,11 @@ lbl_8164C54E = .data:0x8164C54E; // type:object size:0x18
lbl_8164C566 = .data:0x8164C566; // type:object size:0xC
lbl_8164C572 = .data:0x8164C572; // type:object size:0xA
__vt__Q33ipl5scene8Calendar = .data:0x8164C57C; // type:object size:0xA4
lbl_8164C620 = .data:0x8164C620; // type:object size:0xB data:string
lbl_8164C62C = .data:0x8164C62C; // type:object size:0x14 data:4byte
lbl_8164C640 = .data:0x8164C640; // type:object size:0x12 data:string
lbl_8164C652 = .data:0x8164C652; // type:object size:0xB data:string
lbl_8164C65D = .data:0x8164C65D; // type:object size:0x13 data:string
scN_CalDay_r = .data:0x8164C620; // type:object size:0xB data:string
scDateAnimPaneNames = .data:0x8164C62C; // type:object size:0x14 data:4byte
scMyIplTopFBrlan = .data:0x8164C640; // type:object size:0x12 data:string
scN_CalDay_t = .data:0x8164C652; // type:object size:0xB data:string
scSEDateFocus = .data:0x8164C65D; // type:object size:0x13 data:string
__vt__Q33ipl5scene4Date = .data:0x8164C670; // type:object size:0x18
@12712 = .data:0x8164C688; // type:object size:0xC scope:local data:string
...data.0 = .data:0x8164C688; // type:label scope:local
@@ -20107,12 +20107,12 @@ gDBCommTable = .data:0x816943C8; // type:object size:0x28
lbl_81694410 = .sdata2:0x81694410; // type:object size:0x4 align:4 data:float
lbl_81694418 = .sdata2:0x81694418; // type:object size:0x8 align:8 data:double
lbl_81694420 = .sdata2:0x81694420; // type:object size:0x4 align:4 data:float
lbl_81694424 = .sdata2:0x81694424; // type:object size:0x4 align:4 data:float
lbl_81694428 = .sdata2:0x81694428; // type:object size:0x4 align:4 data:float
lbl_8169442C = .sdata2:0x8169442C; // type:object size:0x4 align:4 data:float
lbl_81694430 = .sdata2:0x81694430; // type:object size:0x4 align:4 data:float
lbl_81694434 = .sdata2:0x81694434; // type:object size:0x4 align:4 data:float
lbl_81694438 = .sdata2:0x81694438; // type:object size:0x4 align:4 data:float
scOrthoLeft = .sdata2:0x81694424; // type:object size:0x4 align:4 data:float
scOrthoRight = .sdata2:0x81694428; // type:object size:0x4 align:4 data:float
scOrthoBottom = .sdata2:0x8169442C; // type:object size:0x4 align:4 data:float
scOrthoTop = .sdata2:0x81694430; // type:object size:0x4 align:4 data:float
scWideOrthoLeft = .sdata2:0x81694434; // type:object size:0x4 align:4 data:float
scWideOrthoRight = .sdata2:0x81694438; // type:object size:0x4 align:4 data:float
lbl_81694440 = .sdata2:0x81694440; // type:object size:0x4 align:4 data:float
lbl_81694444 = .sdata2:0x81694444; // type:object size:0x4 align:4 data:float
lbl_81694448 = .sdata2:0x81694448; // type:object size:0x8 align:8 data:double
@@ -20201,10 +20201,10 @@ lbl_816945B0 = .sdata2:0x816945B0; // type:object size:0x4 align:4 data:float
lbl_816945B4 = .sdata2:0x816945B4; // type:object size:0x4 align:4 data:float
lbl_816945B8 = .sdata2:0x816945B8; // type:object size:0x8 align:8 data:double
lbl_816945C0 = .sdata2:0x816945C0; // type:object size:0x8 align:8 data:double
lbl_816945C8 = .sdata2:0x816945C8; // type:object size:0x4 align:4 data:float
lbl_816945D0 = .sdata2:0x816945D0; // type:object size:0x8 align:8 data:double
lbl_816945D8 = .sdata2:0x816945D8; // type:object size:0x8 align:8 data:double
lbl_816945E0 = .sdata2:0x816945E0; // type:object size:0x8 align:8 data:double
scTvrcMsPerSec = .sdata2:0x816945C8; // type:object size:0x4 align:4 data:float
scTvrcNsecPerSec = .sdata2:0x816945D0; // type:object size:0x8 align:8 data:double
scTvrcOne = .sdata2:0x816945D8; // type:object size:0x8 align:8 data:double
scTvrcFloatMagic = .sdata2:0x816945E0; // type:object size:0x8 align:8 data:double
lbl_816945E8 = .sdata2:0x816945E8; // type:object size:0x4 align:4 data:float
lbl_816945EC = .sdata2:0x816945EC; // type:object size:0x4 align:4 data:float
lbl_816945F0 = .sdata2:0x816945F0; // type:object size:0x4 align:4 data:float
@@ -20710,12 +20710,12 @@ lbl_81694ECC = .sdata2:0x81694ECC; // type:object size:0x4 align:4 data:float
@880 = .sdata2:0x81694ED4; // type:object size:0x4 scope:local align:4 data:float
@885 = .sdata2:0x81694ED8; // type:object size:0x4 scope:local align:4 data:float
@888 = .sdata2:0x81694EE0; // type:object size:0x8 scope:local align:8 data:double
lbl_81694EE8 = .sdata2:0x81694EE8; // type:object size:0x4 align:4 data:float
lbl_81694EEC = .sdata2:0x81694EEC; // type:object size:0x1 data:byte
lbl_81694EED = .sdata2:0x81694EED; // type:object size:0x1 data:byte
lbl_81694EEE = .sdata2:0x81694EEE; // type:object size:0x1 data:byte
lbl_81694EEF = .sdata2:0x81694EEF; // type:object size:0x1 data:byte
lbl_81694EF0 = .sdata2:0x81694EF0; // type:object size:0x4 align:4 data:float
scGuiZeroF = .sdata2:0x81694EE8; // type:object size:0x4 align:4 data:float
scGuiLineColorR = .sdata2:0x81694EEC; // type:object size:0x1 data:byte
scGuiLineColorG = .sdata2:0x81694EED; // type:object size:0x1 data:byte
scGuiLineColorB = .sdata2:0x81694EEE; // type:object size:0x1 data:byte
scGuiLineColorA = .sdata2:0x81694EEF; // type:object size:0x1 data:byte
scGuiHalfF = .sdata2:0x81694EF0; // type:object size:0x4 align:4 data:float
lbl_81694EF8 = .sdata2:0x81694EF8; // type:object size:0x8 data:4byte
lbl_81694F00 = .sdata2:0x81694F00; // type:object size:0x4 data:4byte
lbl_81694F08 = .sdata2:0x81694F08; // type:object size:0x8 align:8 data:double
@@ -21552,7 +21552,7 @@ lbl_8169622C = .sdata:0x8169622C; // type:object size:0x1 data:byte
lbl_8169622D = .sdata:0x8169622D; // type:object size:0x1 data:byte
lbl_8169622E = .sdata:0x8169622E; // type:object size:0x1 data:byte
lbl_8169622F = .sdata:0x8169622F; // type:object size:0x1 data:byte
lbl_81696230 = .sdata:0x81696230; // type:object size:0x5 data:string
scTvrcFileHeader = .sdata:0x81696230; // type:object size:0x5 data:string
TVRC_FILE_HEADER__7LibTVRC = .sdata:0x81696238; // type:object size:0x4 data:4byte
__tienHoseiNsec__7LibTVRC = .sdata:0x8169623C; // type:object size:0x4 data:4byte
_limitMilli__7LibTVRC = .sdata:0x81696240; // type:object size:0x4 data:4byte
@@ -21589,7 +21589,7 @@ lbl_816962DB = .sdata:0x816962DB; // type:object size:0x8 data:string
lbl_816962E3 = .sdata:0x816962E3; // type:object size:0x1
lbl_816962E4 = .sdata:0x816962E4; // type:object size:0x8 data:string
lbl_816962F0 = .sdata:0x816962F0; // type:object size:0x8 data:string
lbl_816962F8 = .sdata:0x816962F8; // type:object size:0x8 data:string
scWwwErrorQ = .sdata:0x816962F8; // type:object size:0x8 data:string
globalNames__Q23www9trasition = .sdata:0x81696300; // type:object size:0x8 scope:local
@1425 = .sdata:0x81696308; // type:object size:0x1 scope:local
gEnableDpd = .sdata:0x81696310; // type:object size:0x4 data:4byte
@@ -21753,7 +21753,7 @@ lbl_816966E1 = .sdata:0x816966E1; // type:object size:0x6 data:string
lbl_816966E7 = .sdata:0x816966E7; // type:object size:0x7 data:string
lbl_816966EE = .sdata:0x816966EE; // type:object size:0x7 data:string
lbl_816966F5 = .sdata:0x816966F5; // type:object size:0x4 data:string
lbl_816966F9 = .sdata:0x816966F9; // type:object size:0x7 data:string
scPaneName_B_Stop = .sdata:0x816966F9; // type:object size:0x7 data:string
lbl_81696700 = .sdata:0x81696700; // type:object size:0x6 data:string
lbl_81696706 = .sdata:0x81696706; // type:object size:0x5 data:string
lbl_8169670B = .sdata:0x8169670B; // type:object size:0x6 data:string
@@ -21781,15 +21781,15 @@ lbl_81696797 = .sdata:0x81696797; // type:object size:0x8 data:string
lbl_8169679F = .sdata:0x8169679F; // type:object size:0x8 data:string
lbl_816967A7 = .sdata:0x816967A7; // type:object size:0x7 data:string
lbl_816967AE = .sdata:0x816967AE; // type:object size:0x7 data:string
lbl_816967B5 = .sdata:0x816967B5; // type:object size:0x7 data:string
scPaneName_T_Stop = .sdata:0x816967B5; // type:object size:0x7 data:string
lbl_816967C0 = .sdata:0x816967C0; // type:object size:0x4 data:string
lbl_816967C4 = .sdata:0x816967C4; // type:object size:0x6 data:string
lbl_816967CA = .sdata:0x816967CA; // type:object size:0x7 data:string
lbl_816967D8 = .sdata:0x816967D8; // type:object size:0x6 data:string
lbl_816967DE = .sdata:0x816967DE; // type:object size:0x6 data:string
lbl_816967E4 = .sdata:0x816967E4; // type:object size:0x7 data:string
lbl_816967EB = .sdata:0x816967EB; // type:object size:0x7 data:string
lbl_816967F2 = .sdata:0x816967F2; // type:object size:0x6 data:string
scW_Cal = .sdata:0x816967D8; // type:object size:0x6 data:string
scT_Cal = .sdata:0x816967DE; // type:object size:0x6 data:string
scCal_Ac = .sdata:0x816967E4; // type:object size:0x7 data:string
scInfo_a = .sdata:0x816967EB; // type:object size:0x7 data:string
scB_Cal = .sdata:0x816967F2; // type:object size:0x6 data:string
@16087 = .sdata:0x816967F8; // type:object size:0x4 scope:local data:string
@16350 = .sdata:0x816967FC; // type:object size:0x7 scope:local data:string
@16351 = .sdata:0x81696803; // type:object size:0x7 scope:local data:string
@@ -23191,7 +23191,7 @@ _repeatBitLength__7LibTVRC = .sbss:0x81698768; // type:object size:0x4 data:4byt
_repeatBitArray__7LibTVRC = .sbss:0x8169876C; // type:object size:0x4 data:4byte
_tickT__7LibTVRC = .sbss:0x81698770; // type:object size:0x4 data:4byte
m_handle__Q23ipl11TVRCManager = .sbss:0x81698778; // type:object size:0x4 data:4byte
lbl_8169877C__3ipl = .sbss:0x8169877C; // type:object size:0x4 data:4byte
sTvrcStartDelay__3ipl = .sbss:0x8169877C; // type:object size:0x4 data:4byte
suIDCounter__Q23gui11PaneManager = .sbss:0x81698780; // type:object size:0x4 data:4byte
_bgmBlk__Q23ipl3snd = .sbss:0x81698788; // type:object size:0x4
_mainBGMHandle__Q23ipl3snd = .sbss:0x8169878C; // type:object size:0x4 data:4byte
@@ -23331,7 +23331,7 @@ opera_callbacks__Q23www10wiisetting = .sbss:0x816989A0; // type:object size:0x4
sStatus__Q23www9arcreader = .sbss:0x816989A8; // type:object size:0x4 scope:local data:4byte
lbl_816989B0 = .sbss:0x816989B0; // type:object size:0x4 data:4byte
sBatteryFlag__Q210homebutton10Controller = .sbss:0x816989B8; // type:object size:0x4
lbl_816989BC__Q210homebutton10Controller = .sbss:0x816989BC; // type:object size:0x4
sAlarmCreated__Q210homebutton10Controller = .sbss:0x816989BC; // type:object size:0x4
suIDCounter__Q310homebutton3gui11PaneManager = .sbss:0x816989C0; // type:object size:0x4 data:4byte
spInstance__Q210homebutton9RemoteSpk = .sbss:0x816989C8; // type:object size:0x4 data:4byte
InvalidShutdown = .sbss:0x816989D0; // type:object size:0x4 data:4byte

View File

@@ -812,8 +812,8 @@ config.libs = [
]
),
IPLSection("memoryCard", [
Object(NonMatching, "scene/memoryCard/iplMemoryCard.cpp"),
Object(NonMatching, "scene/memoryCard/iplMemoryCardBase.cpp"),
Object(Matching, "scene/memoryCard/iplMemoryCard.cpp"),
Object(Matching, "scene/memoryCard/iplMemoryCardBase.cpp"),
Object(NonMatching, "scene/memoryCard/iplMemoryCardManager.cpp"),
Object(Matching, "scene/memoryCard/iplGCSaveData.cpp"),
Object(NonMatching, "scene/memoryCard/iplGCWindow.cpp"),
@@ -878,8 +878,8 @@ config.libs = [
Object(Matching, "scene/setting/iplAOSSThread.cpp"),
Object(NonMatching, "scene/setting/AOSSLink.c"),
Object(NonMatching, "scene/setting/iplRakuRakuThread.cpp"),
Object(NonMatching, "scene/setting/AOSS.c"),
Object(NonMatching, "scene/setting/ATERM.c"),
Object(NonMatching, "scene/setting/AOSS.c", extra_cflags=["-O4,p", "-inline off"]),
Object(NonMatching, "scene/setting/ATERM.c", extra_cflags=["-O4,p", "-inline off"]),
]
),
IPLSection("settingSelect", [
@@ -929,7 +929,7 @@ config.libs = [
Object(Matching, "keyboard/tiTextInputBase.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/MyTiManager.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/MyTiInputForm.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/MyTiLetterForm.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/MyTiLetterForm.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/MyTiBg.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiDebug.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiGUIManager.cpp", extra_cflags=["-O4,p"]),
@@ -987,7 +987,7 @@ config.libs = [
Object(NonMatching, "clib/zi8alpha.c"),
Object(Matching, "clib/zi8alts.c"),
Object(NonMatching, "clib/zi8cgetc.c"),
Object(NonMatching, "clib/zi8cinfo.c"),
Object(Matching, "clib/zi8cinfo.c"),
Object(Matching, "clib/zi8copy.c"),
Object(NonMatching, "clib/zi8dawg.c"),
Object(Matching, "clib/zi8getc.c"),
@@ -1004,7 +1004,7 @@ config.libs = [
Object(Matching, "clib/zi8ver.c"),
Object(Matching, "clib/zi8ZHuwd.c"),
Object(NonMatching, "clib/zidawg1.c"),
Object(NonMatching, "clib/zikorean.c"),
Object(Matching, "clib/zikorean.c"),
Object(NonMatching, "clib/ziswordw.c"),
Object(NonMatching, "clib/zkokeyp.c"),
Object(Matching, "clib/zierror.c"),
@@ -1025,7 +1025,7 @@ config.libs = [
Object(NonMatching, "cdb/CDBRecord.c"),
Object(Matching, "cdb/CDBRecordFile.c"),
Object(Matching, "cdb/CDBRecordKey.c"),
Object(NonMatching, "cdb/CDBIntArray.c"),
Object(Matching, "cdb/CDBIntArray.c"),
Object(Matching, "cdb/CDBSystem.c"),
Object(Matching, "cdb/CDBAttr.c"),
Object(Matching, "cdb/CDBFBridge.c"),
@@ -1037,16 +1037,16 @@ config.libs = [
),
RevoEXLib("ncd", [
Object(Matching, "ncd/ncdsystem.c"),
Object(NonMatching, "ncd/ncdsleep.c"),
Object(Matching, "ncd/ncdsleep.c"),
]
),
RevoEXLib("net", [
Object(Matching, "net/nettime.c"),
Object(Matching, "net/crc.c"),
Object(NonMatching, "net/md5.c"),
Object(NonMatching, "net/sha1.c"),
Object(Matching, "net/sha1.c"),
Object(NonMatching, "net/hmac.c"),
Object(NonMatching, "net/neterrorcode.c"),
Object(Matching, "net/neterrorcode.c"),
Object(Matching, "net/NETVersion.c"),
Object(NonMatching, "net/aes.c"),
Object(Matching, "net/wireless_macaddr.c"),
@@ -1091,7 +1091,7 @@ config.libs = [
Object(Matching, "nwc24/NWC24Ipc.c"),
Object(Equivalent, "nwc24/NWC24Download.c"),
Object(Matching, "nwc24/NWC24CHJump.c"),
Object(NonMatching, "nwc24/NWC24System.c"),
Object(Matching, "nwc24/NWC24System.c"),
]
),
RevoEXLib("so", [
@@ -1389,8 +1389,8 @@ config.libs = [
),
RVLSDKLib("vi", [
Object(NonMatching, "vi/vi.c"),
Object(NonMatching, "vi/i2c.c"),
Object(NonMatching, "vi/vi3in1.c"),
Object(Matching, "vi/i2c.c"),
Object(Matching, "vi/vi3in1.c"),
]
),
RVLSDKLib("mtx", [
@@ -1448,10 +1448,10 @@ config.libs = [
Object(Matching, "axfx/AXFXReverbHi.c"),
Object(Matching, "axfx/AXFXReverbHiDpl2.c"),
Object(Matching, "axfx/AXFXReverbHiExp.c"),
Object(NonMatching, "axfx/AXFXReverbHiExpDpl2.c"),
Object(Matching, "axfx/AXFXReverbHiExpDpl2.c"),
Object(Matching, "axfx/AXFXDelay.c"),
Object(Matching, "axfx/AXFXReverbStd.c"),
Object(NonMatching, "axfx/AXFXReverbStdExp.c"),
Object(Matching, "axfx/AXFXReverbStdExp.c"),
Object(Matching, "axfx/AXFXChorus.c"),
Object(NonMatching, "axfx/AXFXChorusExp.c"),
Object(Matching, "axfx/AXFXLfoTable.c"),
@@ -1552,7 +1552,7 @@ config.libs = [
),
RVLSDKLib("wpad", [
Object(Matching, "wpad/WPAD.c"),
Object(NonMatching, "wpad/WPADHIDParser.c"),
Object(Matching, "wpad/WPADHIDParser.c"),
Object(Matching, "wpad/WPADMem.c"),
Object(Matching, "wpad/WPADEncrypt.c"),
Object(Matching, "wpad/debug_msg.c"),
@@ -1682,184 +1682,184 @@ config.libs = [
]
),
RVLSDKLib("fa", [
Object(NonMatching, "fa/pf_clib.c"),
Object(NonMatching, "fa/pf_code.c"),
Object(NonMatching, "fa/pf_service.c"),
Object(NonMatching, "fa/pf_str.c"),
Object(NonMatching, "fa/pf_driver.c"),
Object(NonMatching, "fa/pdm_api.c"),
Object(NonMatching, "fa/pdm_bpb.c"),
Object(NonMatching, "fa/pdm_disk.c"),
Object(Matching, "fa/pf_clib.c"),
Object(Matching, "fa/pf_code.c"),
Object(Matching, "fa/pf_service.c"),
Object(Matching, "fa/pf_str.c"),
Object(Matching, "fa/pf_driver.c"),
Object(Matching, "fa/pdm_api.c"),
Object(Matching, "fa/pdm_bpb.c"),
Object(Matching, "fa/pdm_disk.c"),
Object(NonMatching, "fa/pdm_partition.c"),
Object(NonMatching, "fa/pf_cache.c"),
Object(NonMatching, "fa/pf_cluster.c"),
Object(NonMatching, "fa/pf_dir.c"),
Object(NonMatching, "fa/pf_entry.c"),
Object(Matching, "fa/pf_entry.c"),
Object(NonMatching, "fa/pf_entry_iterator.c"),
Object(NonMatching, "fa/pf_fat.c"),
Object(NonMatching, "fa/pf_fat12.c"),
Object(NonMatching, "fa/pf_fat16.c"),
Object(NonMatching, "fa/pf_fat32.c"),
Object(Matching, "fa/pf_fat16.c"),
Object(Matching, "fa/pf_fat32.c"),
Object(Matching, "fa/pf_fatfs.c"),
Object(NonMatching, "fa/pf_file.c"),
Object(NonMatching, "fa/pf_path.c"),
Object(NonMatching, "fa/pf_sector.c"),
Object(Matching, "fa/pf_sector.c"),
Object(NonMatching, "fa/pf_volume.c"),
Object(NonMatching, "fa/pf_volume_apiadd.c"),
Object(NonMatching, "fa/pf_cp932.c"),
Object(Matching, "fa/pf_volume_apiadd.c"),
Object(Matching, "fa/pf_cp932.c"),
Object(Matching, "fa/pf_api_util.c"),
Object(NonMatching, "fa/pf_attach.c"),
Object(NonMatching, "fa/pf_buffering.c"),
Object(NonMatching, "fa/pf_cdelete.c"),
Object(NonMatching, "fa/pf_chdir.c"),
Object(NonMatching, "fa/pf_chdmod.c"),
Object(NonMatching, "fa/pf_chmod.c"),
Object(NonMatching, "fa/pf_cinsert.c"),
Object(Matching, "fa/pf_attach.c"),
Object(Matching, "fa/pf_buffering.c"),
Object(Matching, "fa/pf_cdelete.c"),
Object(Matching, "fa/pf_chdir.c"),
Object(Matching, "fa/pf_chdmod.c"),
Object(Matching, "fa/pf_chmod.c"),
Object(Matching, "fa/pf_cinsert.c"),
Object(Matching, "fa/pf_closedir.c"),
Object(NonMatching, "fa/pf_combine.c"),
Object(NonMatching, "fa/pf_create.c"),
Object(NonMatching, "fa/pf_createdir.c"),
Object(NonMatching, "fa/pf_cut.c"),
Object(NonMatching, "fa/pf_derrnum.c"),
Object(NonMatching, "fa/pf_detach.c"),
Object(NonMatching, "fa/pf_divide.c"),
Object(Matching, "fa/pf_combine.c"),
Object(Matching, "fa/pf_create.c"),
Object(Matching, "fa/pf_createdir.c"),
Object(Matching, "fa/pf_cut.c"),
Object(Matching, "fa/pf_derrnum.c"),
Object(Matching, "fa/pf_detach.c"),
Object(Matching, "fa/pf_divide.c"),
Object(Matching, "fa/pf_errnum.c"),
Object(NonMatching, "fa/pf_fadjust.c"),
Object(NonMatching, "fa/pf_fappend.c"),
Object(NonMatching, "fa/pf_fchdir.c"),
Object(Matching, "fa/pf_fadjust.c"),
Object(Matching, "fa/pf_fappend.c"),
Object(Matching, "fa/pf_fchdir.c"),
Object(Matching, "fa/pf_fclose.c"),
Object(NonMatching, "fa/pf_fconcat.c"),
Object(Matching, "fa/pf_fconcat.c"),
Object(Matching, "fa/pf_feof.c"),
Object(Matching, "fa/pf_ferror.c"),
Object(NonMatching, "fa/pf_finfo.c"),
Object(Matching, "fa/pf_finfo.c"),
Object(Matching, "fa/pf_flock.c"),
Object(NonMatching, "fa/pf_fopen.c"),
Object(NonMatching, "fa/pf_format.c"),
Object(Matching, "fa/pf_fopen.c"),
Object(Matching, "fa/pf_format.c"),
Object(Matching, "fa/pf_fread.c"),
Object(NonMatching, "fa/pf_fseek.c"),
Object(NonMatching, "fa/pf_fsetclstlink.c"),
Object(NonMatching, "fa/pf_fsexec.c"),
Object(NonMatching, "fa/pf_fsfirst.c"),
Object(NonMatching, "fa/pf_fsnext.c"),
Object(NonMatching, "fa/pf_fstat.c"),
Object(Matching, "fa/pf_fseek.c"),
Object(Matching, "fa/pf_fsetclstlink.c"),
Object(Matching, "fa/pf_fsexec.c"),
Object(Matching, "fa/pf_fsfirst.c"),
Object(Matching, "fa/pf_fsnext.c"),
Object(Matching, "fa/pf_fstat.c"),
Object(Matching, "fa/pf_fsync.c"),
Object(Matching, "fa/pf_fwrite.c"),
Object(NonMatching, "fa/pf_getdev.c"),
Object(NonMatching, "fa/pf_getvol.c"),
Object(NonMatching, "fa/pf_getvolcfg.c"),
Object(NonMatching, "fa/pf_init_prfile2.c"),
Object(NonMatching, "fa/pf_insert.c"),
Object(NonMatching, "fa/pf_iswriteprotected.c"),
Object(NonMatching, "fa/pf_mkdir.c"),
Object(NonMatching, "fa/pf_mount.c"),
Object(NonMatching, "fa/pf_move.c"),
Object(NonMatching, "fa/pf_opendir.c"),
Object(NonMatching, "fa/pf_readdir.c"),
Object(NonMatching, "fa/pf_regctx.c"),
Object(NonMatching, "fa/pf_remove.c"),
Object(NonMatching, "fa/pf_rename.c"),
Object(NonMatching, "fa/pf_rewinddir.c"),
Object(NonMatching, "fa/pf_rmdir.c"),
Object(NonMatching, "fa/pf_rmvvol.c"),
Object(NonMatching, "fa/pf_seekdir.c"),
Object(NonMatching, "fa/pf_setclstlink.c"),
Object(NonMatching, "fa/pf_setcode.c"),
Object(NonMatching, "fa/pf_setencode.c"),
Object(NonMatching, "fa/pf_settailbuf.c"),
Object(NonMatching, "fa/pf_setupfsi.c"),
Object(NonMatching, "fa/pf_setvol.c"),
Object(NonMatching, "fa/pf_setvolcfg.c"),
Object(NonMatching, "fa/pf_sync.c"),
Object(NonMatching, "fa/pf_telldir.c"),
Object(NonMatching, "fa/pf_unmount.c"),
Object(NonMatching, "fa/pf_unregctx.c"),
Object(NonMatching, "fa/pf_xdivide.c"),
Object(Matching, "fa/pf_getdev.c"),
Object(Matching, "fa/pf_getvol.c"),
Object(Matching, "fa/pf_getvolcfg.c"),
Object(Matching, "fa/pf_init_prfile2.c"),
Object(Matching, "fa/pf_insert.c"),
Object(Matching, "fa/pf_iswriteprotected.c"),
Object(Matching, "fa/pf_mkdir.c"),
Object(Matching, "fa/pf_mount.c"),
Object(Matching, "fa/pf_move.c"),
Object(Matching, "fa/pf_opendir.c"),
Object(Matching, "fa/pf_readdir.c"),
Object(Matching, "fa/pf_regctx.c"),
Object(Matching, "fa/pf_remove.c"),
Object(Matching, "fa/pf_rename.c"),
Object(Matching, "fa/pf_rewinddir.c"),
Object(Matching, "fa/pf_rmdir.c"),
Object(Matching, "fa/pf_rmvvol.c"),
Object(Matching, "fa/pf_seekdir.c"),
Object(Matching, "fa/pf_setclstlink.c"),
Object(Matching, "fa/pf_setcode.c"),
Object(Matching, "fa/pf_setencode.c"),
Object(Matching, "fa/pf_settailbuf.c"),
Object(Matching, "fa/pf_setupfsi.c"),
Object(Matching, "fa/pf_setvol.c"),
Object(Matching, "fa/pf_setvolcfg.c"),
Object(Matching, "fa/pf_sync.c"),
Object(Matching, "fa/pf_telldir.c"),
Object(Matching, "fa/pf_unmount.c"),
Object(Matching, "fa/pf_unregctx.c"),
Object(Matching, "fa/pf_xdivide.c"),
Object(Matching, "fa/pf_w_api_util.c"),
Object(NonMatching, "fa/pf_w_cdelete.c"),
Object(NonMatching, "fa/pf_w_chdir.c"),
Object(NonMatching, "fa/pf_w_chdmod.c"),
Object(NonMatching, "fa/pf_w_chmod.c"),
Object(NonMatching, "fa/pf_w_cinsert.c"),
Object(NonMatching, "fa/pf_w_combine.c"),
Object(NonMatching, "fa/pf_w_create.c"),
Object(NonMatching, "fa/pf_w_createdir.c"),
Object(NonMatching, "fa/pf_w_cut.c"),
Object(NonMatching, "fa/pf_w_divide.c"),
Object(NonMatching, "fa/pf_w_fconcat.c"),
Object(NonMatching, "fa/pf_w_fopen.c"),
Object(NonMatching, "fa/pf_w_fsexec.c"),
Object(NonMatching, "fa/pf_w_fsfirst.c"),
Object(NonMatching, "fa/pf_w_fsnext.c"),
Object(NonMatching, "fa/pf_w_fstat.c"),
Object(NonMatching, "fa/pf_w_insert.c"),
Object(NonMatching, "fa/pf_w_mkdir.c"),
Object(NonMatching, "fa/pf_w_move.c"),
Object(NonMatching, "fa/pf_w_opendir.c"),
Object(NonMatching, "fa/pf_w_remove.c"),
Object(NonMatching, "fa/pf_w_rename.c"),
Object(NonMatching, "fa/pf_w_rmdir.c"),
Object(NonMatching, "fa/pf_w_xdivide.c"),
Object(NonMatching, "fa/pf_filelock.c"),
Object(NonMatching, "fa/pf_stub.c"),
Object(NonMatching, "fa/pf_system.c"),
Object(NonMatching, "fa/pf_stub_standard.c"),
Object(NonMatching, "fa/pfs_attach.c"),
Object(NonMatching, "fa/pfs_buffering.c"),
Object(NonMatching, "fa/pfs_create.c"),
Object(NonMatching, "fa/pfs_createdir.c"),
Object(NonMatching, "fa/pfs_detach.c"),
Object(NonMatching, "fa/pfs_errnum.c"),
Object(NonMatching, "fa/pfs_fclose.c"),
Object(NonMatching, "fa/pfs_finfot.c"),
Object(NonMatching, "fa/pfs_fopen.c"),
Object(NonMatching, "fa/pfs_format.c"),
Object(NonMatching, "fa/pfs_fread.c"),
Object(NonMatching, "fa/pfs_fseek.c"),
Object(NonMatching, "fa/pfs_fsfirst.c"),
Object(NonMatching, "fa/pfs_fsnext.c"),
Object(NonMatching, "fa/pfs_fstat.c"),
Object(NonMatching, "fa/pfs_fwrite.c"),
Object(NonMatching, "fa/pfs_getdev.c"),
Object(NonMatching, "fa/pfs_init_prfile2.c"),
Object(NonMatching, "fa/pfs_mount.c"),
Object(NonMatching, "fa/pfs_remove.c"),
Object(NonMatching, "fa/pfs_unmount.c"),
Object(NonMatching, "fa/pf_stub_unicode.c"),
Object(Matching, "fa/pf_w_cdelete.c"),
Object(Matching, "fa/pf_w_chdir.c"),
Object(Matching, "fa/pf_w_chdmod.c"),
Object(Matching, "fa/pf_w_chmod.c"),
Object(Matching, "fa/pf_w_cinsert.c"),
Object(Matching, "fa/pf_w_combine.c"),
Object(Matching, "fa/pf_w_create.c"),
Object(Matching, "fa/pf_w_createdir.c"),
Object(Matching, "fa/pf_w_cut.c"),
Object(Matching, "fa/pf_w_divide.c"),
Object(Matching, "fa/pf_w_fconcat.c"),
Object(Matching, "fa/pf_w_fopen.c"),
Object(Matching, "fa/pf_w_fsexec.c"),
Object(Matching, "fa/pf_w_fsfirst.c"),
Object(Matching, "fa/pf_w_fsnext.c"),
Object(Matching, "fa/pf_w_fstat.c"),
Object(Matching, "fa/pf_w_insert.c"),
Object(Matching, "fa/pf_w_mkdir.c"),
Object(Matching, "fa/pf_w_move.c"),
Object(Matching, "fa/pf_w_opendir.c"),
Object(Matching, "fa/pf_w_remove.c"),
Object(Matching, "fa/pf_w_rename.c"),
Object(Matching, "fa/pf_w_rmdir.c"),
Object(Matching, "fa/pf_w_xdivide.c"),
Object(Matching, "fa/pf_filelock.c"),
Object(Matching, "fa/pf_stub.c"),
Object(Matching, "fa/pf_system.c"),
Object(Matching, "fa/pf_stub_standard.c"),
Object(Matching, "fa/pfs_attach.c"),
Object(Matching, "fa/pfs_buffering.c"),
Object(Matching, "fa/pfs_create.c"),
Object(Matching, "fa/pfs_createdir.c"),
Object(Matching, "fa/pfs_detach.c"),
Object(Matching, "fa/pfs_errnum.c"),
Object(Matching, "fa/pfs_fclose.c"),
Object(Matching, "fa/pfs_finfot.c"),
Object(Matching, "fa/pfs_fopen.c"),
Object(Matching, "fa/pfs_format.c"),
Object(Matching, "fa/pfs_fread.c"),
Object(Matching, "fa/pfs_fseek.c"),
Object(Matching, "fa/pfs_fsfirst.c"),
Object(Matching, "fa/pfs_fsnext.c"),
Object(Matching, "fa/pfs_fstat.c"),
Object(Matching, "fa/pfs_fwrite.c"),
Object(Matching, "fa/pfs_getdev.c"),
Object(Matching, "fa/pfs_init_prfile2.c"),
Object(Matching, "fa/pfs_mount.c"),
Object(Matching, "fa/pfs_remove.c"),
Object(Matching, "fa/pfs_unmount.c"),
Object(Matching, "fa/pf_stub_unicode.c"),
Object(NonMatching, "fa/api/FAAttach.c"),
Object(NonMatching, "fa/api/FABuffering.c"),
Object(NonMatching, "fa/api/FACreate.c"),
Object(NonMatching, "fa/api/FACreatedir.c"),
Object(NonMatching, "fa/api/FADetach.c"),
Object(NonMatching, "fa/api/FAErrnum.c"),
Object(Matching, "fa/api/FABuffering.c"),
Object(Matching, "fa/api/FACreate.c"),
Object(Matching, "fa/api/FACreatedir.c"),
Object(Matching, "fa/api/FADetach.c"),
Object(Matching, "fa/api/FAErrnum.c"),
Object(Matching, "fa/api/FAFclose.c"),
Object(Matching, "fa/api/FAFinfo.c"),
Object(NonMatching, "fa/api/FAFopen.c"),
Object(NonMatching, "fa/api/FAFormat.c"),
Object(Matching, "fa/api/FAFopen.c"),
Object(Matching, "fa/api/FAFormat.c"),
Object(Matching, "fa/api/FAFread.c"),
Object(NonMatching, "fa/api/FAFseek.c"),
Object(NonMatching, "fa/api/FAFsfirst.c"),
Object(NonMatching, "fa/api/FAFsnext.c"),
Object(NonMatching, "fa/api/FAFstat.c"),
Object(Matching, "fa/api/FAFseek.c"),
Object(Matching, "fa/api/FAFsfirst.c"),
Object(Matching, "fa/api/FAFsnext.c"),
Object(Matching, "fa/api/FAFstat.c"),
Object(Matching, "fa/api/FAFwrite.c"),
Object(NonMatching, "fa/api/FAGetdev.c"),
Object(NonMatching, "fa/api/FAInit.c"),
Object(Matching, "fa/api/FAGetdev.c"),
Object(Matching, "fa/api/FAInit.c"),
Object(Matching, "fa/api/FAInitDiskManager.c"),
Object(NonMatching, "fa/api/FAMount.c"),
Object(NonMatching, "fa/api/FARegistCB.c"),
Object(NonMatching, "fa/api/FARemove.c"),
Object(NonMatching, "fa/api/FASetThreadPriority.c"),
Object(NonMatching, "fa/api/FAUnmount.c"),
Object(Matching, "fa/api/FAMount.c"),
Object(Matching, "fa/api/FARegistCB.c"),
Object(Matching, "fa/api/FARemove.c"),
Object(Matching, "fa/api/FASetThreadPriority.c"),
Object(Matching, "fa/api/FAUnmount.c"),
Object(NonMatching, "fa/kernel/pfk_api.c"),
Object(Matching, "fa/kernel/pfk_api.c"),
Object(NonMatching, "fa/driver/nand_drv.c"),
Object(Matching, "fa/driver/nand_drv.c"),
Object(NonMatching, "fa/driver/sd_drv.c"),
Object(NonMatching, "fa/driver/pfd_cmn.c"),
Object(NonMatching, "fa/driver/msc_drv.c"),
Object(Matching, "fa/driver/pfd_cmn.c"),
Object(Matching, "fa/driver/msc_drv.c"),
Object(NonMatching, "fa/msc/puh_msc.c"),
Object(NonMatching, "fa/msc/puh_msc_cmd.c"),
Object(Matching, "fa/msc/puh_msc.c"),
Object(Matching, "fa/msc/puh_msc_cmd.c"),
Object(NonMatching, "fa/msc/puh_msc_blk.c"),
]
),
@@ -1870,7 +1870,7 @@ config.libs = [
RVLSDKLib("nup", [
Object(NonMatching, "nup/nup.cpp"),
Object(NonMatching, "nup/nup_nhttp.cpp"),
Object(NonMatching, "nup/nup_mem.cpp"),
Object(Matching, "nup/nup_mem.cpp"),
]
),
RVLSDKLib("scutil", [
@@ -1887,7 +1887,7 @@ config.libs = [
RVLSDKLib("kbd", [
Object(NonMatching, "kbd/kbd_lib.c"),
Object(NonMatching, "kbd/kbd_lib_map_jp.c"),
Object(NonMatching, "kbd/kbd_lib_map_us.c"),
Object(Matching, "kbd/kbd_lib_map_us.c"),
Object(NonMatching, "kbd/kbd_lib_map_eu.c"),
]
),
@@ -1944,33 +1944,33 @@ config.libs = [
Object(Matching, "MSL_Common/alloc.c"),
Object(Matching, "MSL_Common/errno.c"),
Object(Matching, "MSL_Common/ansi_files.c"),
Object(NonMatching, "MSL_Common_Embedded/ansi_fp.c"),
Object(Matching, "MSL_Common_Embedded/ansi_fp.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/ctype.c"),
Object(NonMatching, "MSL_Common/locale.c"),
Object(Matching, "MSL_Common/locale.c"),
Object(Matching, "MSL_Common/arith.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/bsearch.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/buffer_io.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/direct_io.c", extra_cflags=["-Cpp_exceptions on"]),
Object(NonMatching, "MSL_Common/file_io.c"),
Object(Matching, "MSL_Common/file_io.c"),
Object(Matching, "MSL_Common/FILE_POS.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/mbstring.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/mem.c"),
Object(Matching, "MSL_Common/mem_funcs.c"),
Object(Matching, "MSL_Common/math_api.c"),
Object(Matching, "MSL_Common/misc_io.c"),
Object(NonMatching, "MSL_Common/printf.c"),
Object(Matching, "MSL_Common/printf.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/qsort.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/rand.c"),
Object(NonMatching, "MSL_Common/scanf.c"),
Object(Matching, "MSL_Common/scanf.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/signal.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/string.c"),
Object(Matching, "MSL_Common/float.c"),
Object(NonMatching, "MSL_Common/strtold.c"),
Object(Matching, "MSL_Common/strtold.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/strtoul.c", extra_cflags=["-Cpp_exceptions on"]),
Object(NonMatching, "MSL_Common/time.c"),
Object(Matching, "MSL_Common/time.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/wctype.c"),
Object(Matching, "MSL_Common/wmem.c"),
Object(NonMatching, "MSL_Common/wprintf.c"),
Object(NonMatching, "MSL_Common/wprintf.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/wstring.c"),
Object(Matching, "MSL_Common/wchar_io.c"),
Object(Matching, "PPC_EABI/time.dolphin.c"),

View File

@@ -14,7 +14,12 @@ enum {
typedef struct BS2UpdateHeader {
char timestamp[16]; // 0x00
u32 wadCount; // 0x10
#ifdef BS2_UPDATE_SOURCE
u32 extraCount;
u32 reserved[2];
#else
u32 reserved[3]; // 0x14
#endif
} BS2UpdateHeader;
typedef struct BS2UpdateEntry {
@@ -29,7 +34,12 @@ typedef struct BS2UpdateEntry {
u64 titleId; // 0x50
u16 titleVersion; // 0x58
#ifdef BS2_UPDATE_SOURCE
u16 reservedTitle;
u32 inodes;
#else
u8 padding[6]; // 0x5A
#endif
// Update Data
char dataName[0x40]; // 0x60

View File

@@ -96,7 +96,7 @@ CHANSVmNativeClass* CHANSVmAddNativeClass(CHANSVm* vm, const char* clsName, CHAN
/*** CHANS Image ***/
/************************/
typedef vmBoolInt (*CHANSVmImageCtorCallback)(CHANSVm* vm);
typedef vmBoolInt (*CHANSVmImageCtorCallback)(CHANSVm* vm, vmPtr data);
typedef vmPtr (*CHANSVmImageAllocatorCallback)(CHANSVm* vm, u32 size);
void CHANSVmImageRegisterAllocator(CHANSVmImageAllocatorCallback allocCb, CHANSVmImageCtorCallback ctorCb);

View File

@@ -75,7 +75,7 @@ namespace homebutton {
private:
static bool sBatteryFlag[WPAD_MAX_CONTROLLERS];
static bool lbl_816989BC[WPAD_MAX_CONTROLLERS];
static bool sAlarmCreated[WPAD_MAX_CONTROLLERS];
static OSAlarm sAlarm[WPAD_MAX_CONTROLLERS];
static OSAlarm sAlarmSoundOff[WPAD_MAX_CONTROLLERS];

View File

@@ -61,7 +61,11 @@ namespace ipl {
const char* getIconComment(u8 slot, s16 fileNo);
void initCardThread();
#if defined(IPL_MEMORY_CARD_CPP) || defined(IPL_CARD_SEQUENCE_CPP)
BOOL shutdownCardThread();
#else
bool shutdownCardThread();
#endif
} // namespace memorycard
} // namespace ipl

View File

@@ -36,7 +36,7 @@ namespace ext_ead {
class SurfaceManager {
public:
static void CreateManager(int rectW0, int rectH0, int rectW1, int rectH1, void* mem1Buf, u32 mem1BufSize, void* mem2Buf, u32 mem2BufSize,
void* libBuf, const char* param_10);
void* libBuf, const char* arcPath);
static void DisposeManager();
static void RegisterArcFile(void* fileBuf);

View File

@@ -18,7 +18,9 @@ namespace textinput {
LayoutByNW4R(nw4r::lyt::MultiArcResourceAccessor* multiArc, const char* layoutName, EventObserver* event)
: nw4rmanager::Layout(multiArc, layoutName, event) {}
#endif
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_MATCHING)
virtual ~LayoutByNW4R() {}
#elif defined(MYTIMANAGER_IMPLEMENTATION)
virtual ~LayoutByNW4R();
#else
virtual ~LayoutByNW4R() {}

View File

@@ -20,7 +20,7 @@ namespace textinput {
virtual void moveNigaoeButton() {}
};
#ifdef MYTIINPUTFORM_IMPLEMENTATION
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
class ScrollButton;
#endif
@@ -48,7 +48,7 @@ namespace textinput {
#endif
~InputForm();
#ifdef MYTIINPUTFORM_IMPLEMENTATION
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
virtual void moveCursorUp();
virtual void moveCursorDown();
virtual void onCommand(INPUT_COMMAND command, void* data);
@@ -131,7 +131,7 @@ namespace textinput {
void setEditScrollDown(bool editScrollDown) { mbEditScrollUp = editScrollDown; }
void setCloseWithSend(bool closeWithSend) { mbCloseWithSend = closeWithSend; }
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
void setEditMode(EditMode editMode);
#else
void setEditMode(EditMode editMode) { meEditMode = editMode; }
@@ -147,8 +147,12 @@ namespace textinput {
tistring::Decolated* getSendString() { return mpSendString; }
#ifdef MYTILETTERFORM_IMPLEMENTATION
protected:
#else
private:
#ifdef MYTIINPUTFORM_IMPLEMENTATION
#endif
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
nw4r::lyt::Pane* mpMemoPane;
nw4r::lyt::Pane* mpMemoRootPane;
nw4r::lyt::Pane* mpBoundPane;
@@ -172,7 +176,7 @@ namespace textinput {
nw4r::lyt::Size mDefaultBoundSize; // 0x358
Mtx mDrawMtx; // 0x360
Mtx mBoundMtx; // 0x390
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
util::Animation mExScrollAnm; // 0x3C0
#else
u8 /*todo*/ mExScrollAnm[32]; // 0x3C0
@@ -186,7 +190,7 @@ namespace textinput {
bool mbEditScrollDown; // 0x3EF
bool mbCloseWithSend; // 0x3F0
u8 padding[3]; // 0x3F1
#ifdef MYTIINPUTFORM_IMPLEMENTATION
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
ScrollButton* mpScrollButton;
#else
undefined4* mpScrollButton;

View File

@@ -23,6 +23,15 @@ namespace textinput {
unk_0x400(0), mbPhotoDraw(false), meType(T_MailAddressSel) {}
#endif
#ifdef MYTILETTERFORM_IMPLEMENTATION
virtual ~InputForm();
virtual void create(MEMAllocator*, inputform::EditBuffer*);
virtual void drawBody();
virtual void drawFooter();
virtual void open();
virtual void close();
virtual bool isWholePaneInAnimation();
#endif
virtual nw4r::lyt::Material* getPhotoPaneMaterial();
virtual void onPhotoTrig();
@@ -38,7 +47,11 @@ namespace textinput {
void resizePhotoPane(f32 width, f32 height);
private:
#ifdef MYTILETTERFORM_IMPLEMENTATION
bool mbPhotoScaledUp;
#else
u8 unk_0x400;
#endif
bool mbPhotoDraw; // 0x401
Type meType; // 0x404
};

View File

@@ -167,6 +167,25 @@ namespace textinput {
void setManager(Manager* manager) { mpManager = manager; }
#endif
virtual ~State();
#ifdef MYTIMANAGER_MATCHING
virtual Manager::StateType getStateType() = 0;
virtual void create() = 0;
virtual void init() = 0;
virtual void draw() = 0;
virtual void memoDraw() = 0;
virtual void calc() = 0;
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release) = 0;
virtual bool updateInput(input::HKBManager& hkbManager) = 0;
virtual void start() = 0;
virtual void end() = 0;
#else
virtual Manager::StateType getStateType();
virtual void create();
@@ -184,6 +203,7 @@ namespace textinput {
virtual void start();
virtual void end();
#endif
#ifdef MYTIMANAGER_IMPLEMENTATION
virtual InputForm* InputForm();
virtual keyboard::hwkey::HWKeyboard* HWKeyboard();

View File

@@ -48,6 +48,9 @@ namespace textinput {
class CandidateBoxCaller {
public:
#ifdef TIINPUTFORM_IMPLEMENTATION
CandidateBoxCaller() : mpCandidateBox(NULL) {}
#endif
// This candidate thing is a bit different from the dwarf
class Candidates {
public:
@@ -74,6 +77,9 @@ namespace textinput {
class Base : public CommandSender {
public:
#ifdef TIMANAGER_IMPLEMENTATION
Base(Manager* manager) : mpCandidates(NULL), mpAllocator(NULL), mbOn(false), mbInvalid(true), meLanguage(USA), mpManager(manager) {}
#endif
virtual ~Base();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override {}
@@ -108,6 +114,9 @@ namespace textinput {
class EventHandler : public nw4rmanager::TiEventHandler {
public:
#ifdef TIMANAGER_IMPLEMENTATION
EventHandler(LayoutByNW4R* layout) : mpLayoutByNW4R(layout) {}
#endif
virtual void onTiEvent(gui::PaneComponent* paneComponent, u32 event, Input* input) override; // 0x18
LayoutByNW4R* mpLayoutByNW4R; // 0xC
@@ -178,7 +187,19 @@ namespace textinput {
void SetFocusedText(s32 pane) { mnFocusedIdx = pane; }
s32 GetFocusedText() { return mnFocusedIdx; }
f32 GetWidthScale_() const { return 608.0f / mfScreenWidth; }
#ifdef TI_CANDIDATEBOX_IMPLEMENTATION
f32 GetMargin_() const {
f32 margin;
if (mfScreenWidth > 700.0f) {
margin = 10.0f;
} else {
margin = 20.0f;
}
return margin;
}
#else
f32 GetMargin_() const { return mfScreenWidth > 700.0f ? 10.0f : 20.0f; }
#endif
s32 GetNextPageIdx_(s32 page) const;
s32 GetPrevPageIdx_(s32 page) const;
s32 GetDispNum() const;
@@ -281,6 +302,13 @@ namespace textinput {
// TODO
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public UIObj::Listener {
public:
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mEventHandler(this), mpTiString(NULL),
mTextArea(0, this, this), mLeftScroll(1, this, this), mRightScroll(2, this, this), mOnOffButton(3, this, this),
mTextWindow(4, this, this), mbActive(true) {}
const UIOnOffButton& getOnOffButton() const { return mOnOffButton; }
#endif
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override;
@@ -323,6 +351,9 @@ namespace textinput {
virtual void cancelStateFocusIn(); // 0x128
virtual void onEvent(UIObj*, u32, void*) override; // 0x12C
#ifdef TIINPUTFORM_IMPLEMENTATION
UITextArea& getTextArea() { return mTextArea; }
#endif
void onPressedShift(bool shift);
void onReleasedShift();
void startTurnOn(bool);

View File

@@ -2,20 +2,58 @@
#define TEXTINPUT_CELL_PHONE_H
#include "tiNw4rManager.h"
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#include "tiKeyboard.h"
#endif
#ifdef TI_CELLPHONE_IMPLEMENTATION
#include <revolution/gx.h>
#endif
namespace textinput {
class Manager;
#ifdef TI_CELLPHONE_SAMPLE_CLASS
class EventObserver;
#endif
namespace predictlang {
class LayoutByNW4R;
}
namespace keyboard {
#ifdef TI_CELLPHONE_IMPLEMENTATION
enum VKeyCode {
VK_LINE_FEED = 0,
VK_DELETE = 1,
VK_SIGN_INPUT = 9,
VK_PREDICT_LANGUAGE = 10,
VK_INPUT_MODE_02 = 11,
VK_INPUT_MODE_03 = 13,
VK_INPUT_MODE_00 = 18,
VK_INPUT_MODE_01 = 19,
VK_TOGGLE_ABC_MODE = 23,
};
#endif
namespace signwindow {
class LayoutByNW4R;
}
}
namespace keyboard {
namespace cellphonetype {
#ifdef MYTIMANAGER_IMPLEMENTATION
class EventHandler;
#ifdef TI_CELLPHONE_IMPLEMENTATION
class CellPhoneAnmPane;
struct PaneNameToCharCode;
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
class Base : public textinput::keyboard::KeyboardBase {
#else
class Base {
#endif
public:
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) && defined(TI_CELLPHONE_SAMPLE_CLASS)
Base(Manager* manager) : mPreviousInputMode(0), mCurrentInputMode(0), mpManager(manager) {}
#endif
enum InputMode {
IM_00,
IM_01,
@@ -29,7 +67,18 @@ namespace textinput {
virtual void init() override;
virtual void updateFromReceiver(u32, void*) override;
virtual void onKey(u32, void*) override;
#ifdef TIMANAGER_IMPLEMENTATION
Base(Manager* manager) : mpManager(manager) {}
#endif
#if defined(TI_CELLPHONE_IMPLEMENTATION)
virtual u32 getType() override;
#elif defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
virtual int getType() override;
#elif defined(TIHWKEYBOARD_IMPLEMENTATION)
virtual int getType() override;
#else
virtual void getType() override;
#endif
virtual void onActive() override;
virtual void calc();
virtual void draw();
@@ -52,6 +101,9 @@ namespace textinput {
virtual bool isAtokActive();
virtual void doInput();
virtual void updateFixMode();
#ifdef TI_CELLPHONE_IMPLEMENTATION
wchar_t convertToZiCellphoneInput_(wchar_t value);
#endif
#else
virtual void vt_0x08();
virtual void vt_0x0C();
@@ -74,7 +126,7 @@ namespace textinput {
virtual void vt_0x4C();
virtual void vt_0x50();
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual void doNumericMode(bool);
#else
virtual void vt_0x54();
@@ -90,9 +142,16 @@ namespace textinput {
// TODO enum?
int getInputType() const;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
void resetHoldingButton();
#endif
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) && defined(TI_CELLPHONE_IMPLEMENTATION)
protected:
#else
private:
#endif
u32 mPreviousInputMode;
u32 mCurrentInputMode;
bool mbInputModeLocked;
@@ -101,34 +160,115 @@ namespace textinput {
bool mbUpperCaseMode;
bool mbAbcMode;
bool mbLanguageKeyMode;
#ifdef TI_CELLPHONE_IMPLEMENTATION
const PaneNameToCharCode* mHoldingButton;
#else
u32 mHoldingButton;
#endif
void* mpInputModeTable;
MEMAllocator* mpAllocator;
#ifdef TI_CELLPHONE_IMPLEMENTATION
Manager* mpManager;
bool mInputState;
#elif defined(TIMANAGER_IMPLEMENTATION)
Manager* mpManager;
u32 mInputState;
#else
void* mpInputSettings;
u32 mInputState;
#endif
#ifdef TI_CELLPHONE_IMPLEMENTATION
void onCtrlKey_(VKeyCode keyCode);
#endif
#endif
};
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
#ifndef TI_CELLPHONE_MATCH_LAYOUT
#include "tiCellPhoneLayout.h"
#else
class LayoutByNW4R;
#endif
#ifdef TI_CELLPHONE_IMPLEMENTATION
enum Animation {
ANM_Normal,
ANM_FocusIn,
ANM_FocusOut,
ANM_RollOver,
ANM_Pushed,
ANM_05,
ANM_06,
ANM_ToggleOff,
ANM_Last,
};
enum KeyType {
KT_NormalButton,
KT_ControlButton,
};
#ifdef TI_CELLPHONE_MATCH_LAYOUT
class EventHandler : public nw4rmanager::TiEventHandler {
public:
#ifdef MYTIMANAGER_IMPLEMENTATION
virtual void doNumericMode(bool);
virtual void setPredictLanguageDialog(void*);
virtual void setSignWindow(void*);
virtual void doNumericWithDotMode(bool);
virtual void setLineFeedButton(bool);
virtual void setPredictLanguageButton(bool);
virtual void setSignWindowButton(bool);
#endif
virtual bool onClose();
EventHandler(LayoutByNW4R* layout) : mpLayoutByNW4R(layout) {}
virtual ~EventHandler();
virtual void onTiEvent(gui::PaneComponent* pane, u32 event, Input* input) override;
void onPressedShift(bool shift);
void onReleasedShift();
#ifdef MYTIMANAGER_IMPLEMENTATION
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) override;
virtual bool updateInput(input::HKBManager& hkbManager) override;
#endif
private:
LayoutByNW4R* mpLayoutByNW4R;
};
#endif
class CellPhoneAnmPane : public nw4rmanager::AnmPane {
public:
CellPhoneAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
#ifdef TI_CELLPHONE_MATCH_LAYOUT
: nw4rmanager::AnmPane(pane, observer), meState(ANM_Normal), meKeyType(KT_NormalButton) {
init();
changeAnimation(meState);
}
#else
: nw4rmanager::AnmPane(pane, observer), meState(ANM_Normal), meKeyType(KT_NormalButton) {}
#endif
virtual void init() override;
virtual void onAnmEvent(AnmPaneEvent event) override;
virtual void changeAnimation(u32 id) override;
virtual KeyType getKeyType() const;
u32 getAnimationState() const { return meState; }
virtual ~CellPhoneAnmPane();
protected:
Animation meState;
KeyType meKeyType;
};
class CellPhoneControlAnmPane : public CellPhoneAnmPane {
public:
CellPhoneControlAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: CellPhoneAnmPane(pane, observer) { meKeyType = KT_ControlButton; }
virtual void onAnmEvent(AnmPaneEvent event) override;
virtual ~CellPhoneControlAnmPane();
};
#ifndef TI_CELLPHONE_MATCH_LAYOUT
class EventHandler : public nw4rmanager::TiEventHandler {
public:
EventHandler(LayoutByNW4R* layout) : mpLayoutByNW4R(layout) {}
virtual ~EventHandler();
virtual void onTiEvent(gui::PaneComponent* pane, u32 event, Input* input) override;
private:
LayoutByNW4R* mpLayoutByNW4R;
};
#endif
#endif
#ifdef TI_CELLPHONE_MATCH_LAYOUT
#include "tiCellPhoneLayout.h"
#endif
} // namespace cellphonetype
} // namespace keyboard

View File

@@ -0,0 +1,126 @@
#ifndef TEXTINPUT_CELL_PHONE_LAYOUT_H
#define TEXTINPUT_CELL_PHONE_LAYOUT_H
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
public:
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mpEventHandler(NULL) {}
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual void setCommandReceiver(CommandReceiver* receiver);
virtual void updateFromReceiver(u32 command, void* data);
virtual void onKey(u32 event, void* data);
virtual void setLanguage(Language language);
virtual void update();
virtual void onActive();
virtual void calc();
virtual void draw();
virtual void changeInputMode(InputMode mode);
virtual void setInputMode(InputMode mode);
virtual void setUpperCaseJP(bool upper);
virtual void setLangKeyActive(bool active);
virtual void goSignInputMode();
virtual void changePredictLanguage();
virtual void setAbcMode(bool abc);
virtual void doNumericMode(bool);
virtual void setPredictLanguageDialog(predictlang::LayoutByNW4R* dialog);
virtual void setSignWindow(signwindow::LayoutByNW4R* window);
#else
#if defined(MYTIMANAGER_IMPLEMENTATION) && defined(TI_CELLPHONE_SAMPLE_CLASS)
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, "fs_VK_cellPhone_a.brlyt", observer), mpSignWindow(NULL) {}
#endif
virtual void doNumericMode(bool);
#ifdef TI_CELLPHONE_IMPLEMENTATION
virtual void setPredictLanguageDialog(predictlang::LayoutByNW4R*);
virtual void setSignWindow(signwindow::LayoutByNW4R*);
#else
virtual void setPredictLanguageDialog(void*);
virtual void setSignWindow(void*);
#endif
#endif
virtual void doNumericWithDotMode(bool);
virtual void setLineFeedButton(bool);
virtual void setPredictLanguageButton(bool);
virtual void setSignWindowButton(bool);
#endif
virtual bool onClose();
void onPressedShift(bool shift);
void onReleasedShift();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
bool hasLineFeedButton() const { return mbLineFeedButton; }
private:
bool mbLineFeedButton;
#ifdef TIMANAGER_IMPLEMENTATION
GXTexObj mSpaceTexture;
GXTexObj mSpaceTextureCN;
GXTexObj mSpaceTextureKR;
nw4rmanager::TiEventHandler* mpEventHandler;
predictlang::LayoutByNW4R* mpPredictDialog;
signwindow::LayoutByNW4R* mpSignWindow;
#endif
public:
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) override;
virtual bool updateInput(input::HKBManager& hkbManager) override;
#endif
#ifdef TI_CELLPHONE_IMPLEMENTATION
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override;
virtual void draw() override;
virtual void calc() override;
virtual void update() override;
virtual void onKey(u32 key, void* data) override;
virtual void onActive() override;
virtual void updateFromReceiver(u32 command, void* data) override;
virtual void changeInputMode(InputMode mode) override;
virtual void changePredictLanguage() override;
virtual void setAbcMode(bool enabled) override;
virtual void goSignInputMode() override;
virtual void setInputMode(InputMode mode) override;
virtual void setLanguage(Language language) override;
virtual void setCommandReceiver(CommandReceiver* receiver) override;
virtual CellPhoneAnmPane* getAnmPane(InputMode mode);
virtual void throwReleaseForAll();
virtual void changeAnimationAllToNormal();
virtual void updatePredictLanguage(CommandReceiver::ChangePredictMode* mode);
virtual void changeKeyTop(const PaneNameToCharCode* keys);
virtual void changeSpaceKeyTop(const PaneNameToCharCode* keys);
void setUpperCaseJP(bool enabled);
void setLangKeyActive(bool enabled);
void resetHoldingButton();
private:
bool mbLineFeedButton;
GXTexObj mTextures[3];
EventHandler* mpEventHandler;
predictlang::LayoutByNW4R* mpPredictLanguageDialog;
signwindow::LayoutByNW4R* mpSignWindow;
#elif defined(TIMANAGER_IMPLEMENTATION)
virtual nw4rmanager::AnmPane* getAnmPane(InputMode mode);
virtual void throwReleaseForAll();
virtual void changeAnimationAllToNormal();
virtual void updatePredictLanguage(CommandReceiver::ChangePredictMode* mode);
virtual void changeKeyTop(const struct PaneNameToCharCode* table);
virtual void changeSpaceKeyTop(const struct PaneNameToCharCode* table);
#endif
};
#ifdef TI_CELLPHONE_SAMPLE_CLASS
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, observer) {}
virtual ~Sample() {}
};
#endif
#endif

View File

@@ -93,8 +93,13 @@ namespace textinput {
extern const KeySet csKeySetCNPinyin;
extern const KeySet csKeySetHangul;
#ifdef TI_CELLPHONE_MATCH_LAYOUT
extern const wchar_t* csSpaceZero;
extern const wchar_t* csSpace;
#else
extern const wchar_t csSpaceZero[3];
extern const wchar_t csSpace[3];
#endif
}
}
}

View File

@@ -92,6 +92,9 @@ namespace textinput {
EVENT_RELEASE
};
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual void init();
#else
virtual void init() { // 0x10
for (int i = 0; i < GUI_POINTS_MAX; i++) {
mbPointed[i] = false;
@@ -100,6 +103,7 @@ namespace textinput {
mFlightDuration[i] = 0;
}
}
#endif
GUIComponent(u32 id)
: GUIInterface(), mbInitialize(false), mDraggingButton(0xFFFF), mID(id), mbTriggerTarget(false), mpManager(NULL), mpListener(NULL) {

View File

@@ -6,11 +6,143 @@
#include <revolution/mem/allocator.h>
#include "keyboard/tiCpData.h"
#ifdef TIHKBMANAGER_IMPLEMENTATION
#include <revolution/kbd.h>
enum _KBDEc { KBD_EC_BUSY = 7 };
#endif
namespace textinput {
namespace input {
#ifdef TIHKBMANAGER_IMPLEMENTATION
class HKBManager {
public:
class KeyState_ {
public:
void NotifyEvent(u8 down, u8 code);
void Update();
void UpdateModState_();
void Clear() {
held = 0;
triggered = 0;
released = 0;
repeated = 0;
current = 0;
pending = 0;
modifiers &= 0x700;
forceMask = 0;
forceState = 0;
retryLeds = 0;
}
void Initialize(u8 channel) {
held = 0;
triggered = 0;
released = 0;
repeated = 0;
current = 0;
pending = 0;
forceMask = 0;
forceState = 0;
retryLeds = 0;
device = channel;
country = 0xf;
modifiers = 0;
}
u8 device;
u32 held, triggered, released, repeated;
u32 previous, current, pending;
u32 modifiers, forceState, forceMask;
s32 country;
u8 retryLeds;
u8 previousKeys[8], currentKeys[8], pendingKeys[8];
u32 repeatDelay[8];
};
class KeySet {
public:
KeySet() {}
KeySet(const HKBManager* owner, u8 kind)
: manager(owner), type(kind), index(-1), device(0), vcode(0) {}
u8 GetKey() const;
u32 GetWChar() const;
u32 GetVCode() const;
u32 IsValid() const;
bool CheckValidity() const {
if (!manager) return false;
s8 keyIndex = index;
if (keyIndex < 0 || keyIndex >= 8) return false;
u8 keyDevice = device;
if (keyDevice >= 2) return false;
switch (type) {
case 0: return (manager->states[keyDevice].held & (1 << keyIndex)) != 0;
case 1: return (manager->states[keyDevice].triggered & (1 << keyIndex)) != 0;
case 2: return (manager->states[keyDevice].released & (1 << keyIndex)) != 0;
case 3: return (manager->states[keyDevice].repeated & (1 << keyIndex)) != 0;
}
return false;
}
KeySet GetNext() const;
const HKBManager* manager;
u8 type;
s8 index;
u8 device;
mutable u16 vcode;
};
class KBDListenerOwn;
class KBDListenerLinks {
public:
KBDListenerLinks() : previous(0), next(0) {}
virtual ~KBDListenerLinks() {}
virtual void OnAttach(KBDDevEvent*) = 0;
virtual void OnDetach(KBDDevEvent*) = 0;
virtual void OnKeyEvent(KBDKeyEvent*) = 0;
KBDListenerOwn* previous;
KBDListenerOwn* next;
};
class KBDListenerOwn : public KBDListenerLinks {
public:
KBDListenerOwn(HKBManager* owner) : manager(owner) {}
virtual ~KBDListenerOwn();
virtual void OnAttach(KBDDevEvent* event);
virtual void OnDetach(KBDDevEvent* event);
virtual void OnKeyEvent(KBDKeyEvent* event);
HKBManager* manager;
};
HKBManager() __attribute__((never_inline));
~HKBManager();
static HKBManager& getInstance() { return sInstance; }
void Initialize();
void ClearState();
u32 GetModifierState() const;
void SetCountry(u8 country);
void SetModifierState(u32 state, u32 mask);
void SetForceModifierState(u32 state, u32 mask);
void Update();
KeySet GetTriggeredKeySet() const;
KeySet GetReleasedKeySet() const;
KeySet GetRepeatedKeySet() const;
#ifdef TIHWKEYBOARD_IMPLEMENTATION
KeySet GetReleasedKeySet() const;
#endif
static void SetLedCB(_KBDEc result, void* userData);
static void AttachCB(KBDDevEvent* event);
static void DetachCB(KBDDevEvent* event);
static void KeyEventCB(KBDKeyEvent* event);
private:
u8 initialized;
u8 attached[2];
u32 lockState;
u32 retryDevices;
const wchar_t* allowedCharacters;
u32 allowedCharacterCount;
KeyState_ states[2];
KBDListenerOwn listener;
static HKBManager sInstance;
};
#else
class HKBManager {
public:
#ifdef TIMANAGER_IMPLEMENTATION
void ClearState();
#endif
static HKBManager& getInstance() { return sInstance; }
void Initialize();
@@ -19,13 +151,16 @@ namespace textinput {
u32 GetModifierState() const;
void SetModifierState(u32, u32);
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
#if defined(TI_CELLPHONE_HKB_KEYSET)
class KeySet {
public:
u8 GetKey() const;
wchar_t GetWChar() const;
u32 GetWChar() const;
bool IsValid() const;
KeySet GetNext() const;
KeySet(const KeySet& other)
: mpManager(other.mpManager), mKind(other.mKind), mIndex(other.mIndex),
mDevice(other.mDevice), mCharacter(other.mCharacter) {}
private:
const HKBManager* mpManager;
u8 mKind;
@@ -35,6 +170,35 @@ namespace textinput {
};
KeySet GetTriggeredKeySet() const;
KeySet GetRepeatedKeySet() const;
#else
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)
class KeySet {
public:
u8 GetKey() const;
#ifdef TIHWKEYBOARD_IMPLEMENTATION
u32 GetWChar() const;
#else
wchar_t GetWChar() const;
#endif
bool IsValid() const;
KeySet GetNext() const;
KeySet(const KeySet& other)
: mpManager(other.mpManager), mKind(other.mKind), mIndex(other.mIndex), mDevice(other.mDevice), mCharacter(other.mCharacter) {}
#ifdef TIHWKEYBOARD_IMPLEMENTATION
KeySet() : mpManager(NULL), mKind(0), mIndex(-1), mDevice(0), mCharacter(0) {}
#endif
private:
const HKBManager* mpManager;
u8 mKind;
s8 mIndex;
u8 mDevice;
u16 mCharacter;
};
KeySet GetTriggeredKeySet() const;
KeySet GetRepeatedKeySet() const;
#ifdef TIHWKEYBOARD_IMPLEMENTATION
KeySet GetReleasedKeySet() const;
#endif
void SetForceModifierState(u32 mask, u32 state);
#else
class KeySet {
@@ -43,14 +207,29 @@ namespace textinput {
wchar_t szKeySetName[17]; // 0x04
u16 uNum; // 0x26
u16 uType; // 0x28
#ifdef TI_CELLPHONE_IMPLEMENTATION
public:
bool IsValid() const;
u32 GetKey() const;
wchar_t GetWChar() const;
KeySet GetNext() const;
#endif
};
#ifdef TI_CELLPHONE_IMPLEMENTATION
KeySet GetTriggeredKeySet() const;
KeySet GetRepeatedKeySet() const;
#endif
#endif
#endif
private:
u8 unk_0x00[0xFC];
static HKBManager sInstance;
};
#endif
} // namespace input
} // namespace textinput

View File

@@ -8,24 +8,43 @@ namespace textinput {
class Manager;
namespace keyboard {
namespace hwkey {
#ifdef TIMANAGER_IMPLEMENTATION
class HWKeyboard : public CommandSender {
#else
class HWKeyboard : CommandSender {
#endif
public:
HWKeyboard(Manager *);
#ifdef TIMANAGER_IMPLEMENTATION
inline ~HWKeyboard();
#else
~HWKeyboard();
#endif
#ifdef TIMANAGER_IMPLEMENTATION
void setLanguage(Destination destination, Language language);
#endif
virtual void init();
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)
wchar_t convertWCCode(wchar_t code) const;
#endif
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
void updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
#else
virtual void updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
#endif
virtual bool updateInput(input::HKBManager& hkbManager);
#ifdef TIINPUTFORM_IMPLEMENTATION
void resetQuoteState() { mbSingleQuoteClosing = 0; mbDoubleQuoteClosing = 0; }
#endif
private:
#ifdef TIHWKEYBOARD_IMPLEMENTATION
bool updateRepeatKey_(input::HKBManager&);
bool updateTriggerKey_(input::HKBManager&);
bool updateTappingShift_(input::HKBManager&);
#endif
void updateShift(input::HKBManager& hkbManager);
void controlKeyTriggeredHandler(input::HKBManager);
@@ -33,8 +52,18 @@ namespace textinput {
Manager* mpManager; // 0x10
u8 field_0x14; // 0x14
#ifdef TIINPUTFORM_IMPLEMENTATION
u8 mbSingleQuoteClosing;
u8 mbDoubleQuoteClosing;
#else
#ifdef TIHWKEYBOARD_IMPLEMENTATION
bool field_0x15;
bool field_0x16;
#else
u8 field_0x15; // 0x15
u8 field_0x16; // 0x16
#endif
#endif
};

View File

@@ -13,14 +13,43 @@
#include "tiZiString.h"
#include "tiSEId.h"
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
extern "C" wchar_t KPRGetChar(KPRQueue* queue);
extern "C" void KPRPutChar(KPRQueue* queue, wchar_t character);
extern "C" void KPRClearQueue(KPRQueue* queue);
extern "C" void KPRInitRegionUS();
extern "C" u8 KPRLookAhead(KPRQueue* queue, wchar_t* character, wchar_t* combining);
#endif
namespace textinput {
#ifdef TIMANAGER_IMPLEMENTATION
class Manager;
#endif
namespace inputform {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
class Base;
class EventHandler;
class LayoutByNW4R;
#endif
class EditBuffer {
#ifdef TIMANAGER_IMPLEMENTATION
friend class textinput::Manager;
public:
EditBuffer() : mpString(NULL), mpUnfixString(NULL), mpZiString(NULL), mpAllocator(NULL) {}
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
friend class LayoutByNW4R;
friend class Base;
#endif
public:
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
void create(MEMAllocator* allocator);
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual ~EditBuffer();
#else
~EditBuffer();
#endif
private:
void* mpString; // 0x04
@@ -30,7 +59,24 @@ namespace textinput {
};
class DeadKeyStream {
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
public:
DeadKeyStream() { KPRInitRegionUS(); init(); }
static wchar_t ToCombineClass(Language language, wchar_t code);
static wchar_t ToIndependentClass(wchar_t code);
inline wchar_t getChar();
void init();
u8 lookAhead() { return KPRLookAhead(&mKPRQueue, NULL, NULL); }
void putChar(wchar_t character) { KPRPutChar(&mKPRQueue, character); }
bool isEmpty() const { return mKPRQueue.oCount == 0; }
void clear() { KPRClearQueue(&mKPRQueue); }
private:
#ifdef TIMANAGER_IMPLEMENTATION
friend class textinput::Manager;
#endif
static bool sbCompatibleFilterEnabled;
static inline bool isCompatible(wchar_t character);
#elif defined(TI_PC_KEYBOARD_IMPLEMENTATION)
public:
static wchar_t ToIndependentClass(wchar_t code);
#endif
@@ -82,13 +128,57 @@ namespace textinput {
// TODO - location
class RowInfoManager {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
friend class LayoutByNW4R;
friend class Base;
public:
RowInfoManager(u16 maxLength) : mpInfo(NULL), mMaxLength(maxLength), mpAllocator(NULL) {}
void init();
~RowInfoManager();
#endif
private:
Info_* mpInfo; // 0x00
u16 mMaxLength; // 0x04
MEMAllocator* mpAllocator; // 0x08
};
#ifdef TISIGNWINDOW_IMPLEMENTATION
bool isAtokActive() const;
#endif
#if defined(MYTILETTERFORM_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual void onCommand(INPUT_COMMAND command, void* data);
#endif
virtual ~Base();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
Base(Manager* manager);
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual void onCommand(INPUT_COMMAND command, void* data);
void setCursorPos(tistring::Decolated* string, u32 pos);
void calcCursorTimer();
bool isAtokActive() const;
bool isVacancy() const;
void dirtyCacheAll();
tistring::Decolated* getCurrentString(bool inputting);
void moveCandidateToIdx(s32 index);
void onPressDownHWKB();
void onPressLeftHWKB();
void onPressRightHWKB();
void toggleAtokMode_(u8 operation);
void onSpaceKeyHWKB(u32 modifiers);
void onHKBCtrlCode(HVKCode code, u32 modifiers);
void confirmInput_();
void confirmInputting_(wchar_t character, bool direct, u16 letterMode, bool confirmOnly, void* holdingKey);
void inputCharZi_(wchar_t character, u32 modifiers);
void inputCharDefault_(wchar_t character, u32 modifiers);
void inputInputting_(wchar_t character);
inline bool hasZiPredictions() const;
inline bool usesZiPrediction() const;
inline void resetPredictionContext();
inline void resetInputRelation();
#endif
virtual void create(MEMAllocator* allocator, EditBuffer* editBuffer);
@@ -199,15 +289,17 @@ namespace textinput {
virtual void makeUpCursorPos(CursorPos* cursorPos, u32 pos, s32 startLine, s32 endLine);
#ifdef MYTIINPUTFORM_IMPLEMENTATION
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
protected:
#if !defined(TIINPUTFORM_IMPLEMENTATION) && !defined(TIMANAGER_IMPLEMENTATION)
void setCursorPos(tistring::Decolated* string, u32 pos);
void resetRelation();
void calcCursorTimer();
#endif
void resetRelation();
#else
private:
#endif
#ifdef MYTIINPUTFORM_IMPLEMENTATION
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
nw4r::ut::Rect mRect;
#else
Rect mRect;
@@ -219,6 +311,9 @@ namespace textinput {
tistring::WithZi* mpZiString; // 0x16C
InputMode meInputMode; // 0x170
PredictMode mePredictMode; // 0x174
#ifdef TIMANAGER_IMPLEMENTATION
friend class textinput::Manager;
#endif
bool mbPredictOn; // 0x178
bool mbDoWordWrap; // 0x179
bool mbRightWithSpace; // 0x17A
@@ -254,8 +349,12 @@ namespace textinput {
};
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
friend class EventHandler;
inline const nw4r::lyt::Pane* getLanguageTextPane() const;
#endif
public:
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
LayoutByNW4R(textinput::Manager*, nw4r::lyt::MultiArcResourceAccessor*, const char*, EventObserver*, const char*);
#endif
~LayoutByNW4R();
@@ -272,6 +371,9 @@ namespace textinput {
virtual nw4r::math::VEC2 getScale() const;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
void updateRepeatInput(u32 trig, u32 hold);
#endif
virtual void updateInputCommon(int chan, u32 trig, u32 hold, u32 release, void* data);
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
virtual bool updateInput(textinput::input::HKBManager& hkbManager);
@@ -282,9 +384,13 @@ namespace textinput {
virtual void setRootPaneScaleFor16x9();
virtual void setRootPaneScaleFor4x3();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
virtual void onSE(sound::SE seId);
#endif
virtual void visibleSeparator(bool flag);
#ifdef MYTIINPUTFORM_IMPLEMENTATION
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
protected:
const void* mpLayoutData;
const void* mpLanguageData;

View File

@@ -8,27 +8,45 @@ namespace textinput {
class KeyboardBase : public CommandSender {
public:
#ifdef TIMANAGER_IMPLEMENTATION
KeyboardBase() : meLanguage(JP) {}
#endif
virtual ~KeyboardBase() {}
#ifndef TI_PC_KEYBOARD_IMPLEMENTATION
#if !(defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)) && !defined(TIMANAGER_IMPLEMENTATION) && !defined(TISIGNWINDOW_IMPLEMENTATION)
virtual void create(MEMAllocator* alloc) override;
virtual void init() override;
#ifndef TI_CELLPHONE_MATCH_LAYOUT
virtual void setCommandReceiver(CommandReceiver* receiver) override;
virtual void sendCommand(u32 command, void*) override;
#endif
#endif
#if !defined(TIMANAGER_IMPLEMENTATION) && !defined(TISIGNWINDOW_IMPLEMENTATION)
virtual void updateFromReceiver(u32, void*) override;
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TI_PC_KEYBOARD_IMPLEMENTATION)
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || (defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
virtual void onKey(u32, void*);
#else
virtual void onKey(u32);
#endif
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
#ifdef TI_CELLPHONE_IMPLEMENTATION
virtual u32 getType();
#elif (defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
virtual int getType();
#else
virtual void getType();
#endif
#ifdef TI_CELLPHONE_IMPLEMENTATION
virtual void setLanguage(Language language) { meLanguage = language; }
#else
virtual void setLanguage(Language language);
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
#endif
#if (defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
#ifdef TISIGNWINDOW_IMPLEMENTATION
virtual Language getLanguage() const;
#else
virtual Language getLanguage() const { return meLanguage; }
#endif
virtual void update() {}
#else
virtual Language getLanguage() const;

View File

@@ -28,11 +28,20 @@ namespace textinput {
virtual void onEvent(nw4r::lyt::Pane* pane, u32 event) {} // 0x10
virtual void onSE(sound::SE seId) {}
#ifdef TIMANAGER_IMPLEMENTATION
virtual void onOK();
virtual void onCancel();
virtual void onOutOfLength();
#else
virtual void onOK() { printf("OK!\n"); }
virtual void onCancel() { printf("Cancel!\n"); }
virtual void onOutOfLength() { printf("OutOfLength\n"); }
#endif
};
#ifdef TIMANAGER_IMPLEMENTATION
namespace predictlang { class LayoutByNW4R; }
#endif
class Manager : public Base {
public:
Manager(MEMAllocator* allocator, nw4r::lyt::MultiArcResourceAccessor* multiArc, textinput::EventObserver* event);
@@ -94,18 +103,26 @@ namespace textinput {
#endif
virtual void setSecretInputMode(bool secretInputMode) { mpInputForm->setSecretModeOn(secretInputMode); }
#ifdef IPL_ADDRESS_EDIT_CPP
#if defined(IPL_ADDRESS_EDIT_CPP) || defined(TIMANAGER_IMPLEMENTATION)
void enableKSXFilter(bool compatibleFilter);
#endif
virtual void setDefaultPredictionJP(int num, const char** predicts);
virtual void setFixedPredictionJP(int num, const char** predicts);
#ifdef TIMANAGER_IMPLEMENTATION
virtual void setTitleText(wchar_t* titleText);
void initAspect();
#else
virtual void setTitleText(const wchar_t* titleText);
#endif
virtual void start() {}
virtual void end() {}
#ifdef TIHWKEYBOARD_IMPLEMENTATION
EventObserver* getEventObserverForHardware() const { return mpEventObserver; }
#endif
virtual InputForm* getInputForm() { return mpInputForm; }
virtual const InputForm* getInputForm() const { return mpInputForm; }
@@ -146,6 +163,10 @@ namespace textinput {
void enableCompatibleFilter(bool compatibleFilter);
bool isVacancy() const;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
bool isPredictTurning() const;
void startPredictTurnOn(bool enabled);
#endif
private:
MEMAllocator* mpAllocator; // 0x04
@@ -159,9 +180,14 @@ namespace textinput {
InputForm* mpInputForm; // 0x1C
candidatebox::LayoutByNW4R* mpCandidateBox; // 0x20
toolbar::LayoutByNW4R* mpToolBar; // 0x24
#ifdef TIMANAGER_IMPLEMENTATION
predictlang::LayoutByNW4R* mpPredictLanguageDialog;
keyboard::signwindow::LayoutByNW4R* mpSignWindow;
#else
void* mpPredictLanguageDialog; // 0x28
void* mpSignWindow; // 0x2C
#endif
EventObserver* mpEventObserver; // 0x30
Destination meDestination; // 0x34

View File

@@ -14,12 +14,22 @@ namespace textinput {
class TiEventHandler : public gui::EventHandler {
public:
typedef struct Input {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
u32 controller;
f32 x;
f32 y;
u32 trigger;
u32 hold;
u32 release;
u8 remaining[8];
#else
// todo
u32 field_0x00; // 0x00
u8 dummy[8];
u32 field_0x0C; // 0x0C
u32 field_0x10; // 0x10
u8 dummy2[12];
#endif
} Input;
virtual void onEvent(gui::GUIComponent& comp, u32 event, void* data); // 0x0C

View File

@@ -1,13 +1,13 @@
#ifndef TEXTINPUT_PC_KEYBOARD_H
#define TEXTINPUT_PC_KEYBOARD_H
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
#if (defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
#include "tiPcKeyboardImpl.h"
#else
#include "tiNw4rManager.h"
#include "tiTextInputBase.h"
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
#include "tiKeyboard.h"
#endif
@@ -18,7 +18,7 @@ namespace textinput {
namespace pctype {
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
class UIObj {
public:
class Listener {
@@ -29,7 +29,7 @@ namespace textinput {
#endif
// TODO
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
class Base : public textinput::keyboard::KeyboardBase {
#else
class Base : public CommandSender {
@@ -37,6 +37,10 @@ namespace textinput {
public:
enum TranslateMode {
TM_00,
#ifdef TIINPUTFORM_IMPLEMENTATION
TM_Kana,
TM_Roman,
#endif
};
enum InputType {
@@ -47,7 +51,7 @@ namespace textinput {
IT_04,
};
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
enum InputMode {
IM_00,
IM_01,
@@ -61,7 +65,11 @@ namespace textinput {
virtual void init() override;
virtual void updateFromReceiver(u32, void*) override;
virtual void onKey(u32, void*) override;
#ifdef TI_CELLPHONE_IMPLEMENTATION
virtual u32 getType() override;
#else
virtual void getType() override;
#endif
virtual void setLanguage(Language) override;
virtual void onActive() override;
virtual void inputCharCode(u16);
@@ -126,7 +134,7 @@ namespace textinput {
virtual void updateFixMode();
#endif
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
private:
u8 mKeyboardInputFlags[8];
const void* mpKeyStateTable;
@@ -136,6 +144,9 @@ namespace textinput {
u32 mCurrentInputType;
u32 mInputState;
const void* mpLanguageData;
#ifdef TIINPUTFORM_IMPLEMENTATION
MEMAllocator* mpAllocator;
#endif
bool mbOnlyQwerty;
bool mbLanguageKeyActive;
u16 mKeyboardFlags;
@@ -143,6 +154,10 @@ namespace textinput {
void* mpCurrentKeyState;
public:
#ifdef TIINPUTFORM_IMPLEMENTATION
bool isQwertyOnly() const { return mbOnlyQwerty; }
bool isLanguageKeyActive() const { return mbLanguageKeyActive; }
#endif
u32 getTranslateModeForMemo() const { return mTranslateMode; }
u32 getABCInputModeForMemo() const { return mABCInputMode; }
u32 getAIUInputModeForMemo() const { return mAIUInputMode; }
@@ -151,14 +166,14 @@ namespace textinput {
// TODO
class LayoutByNW4R : public Base, public nw4rmanager::Layout
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
, public UIObj::Listener
#endif
{
public:
// TODO - ...
#ifdef MYTIMANAGER_IMPLEMENTATION
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
virtual void draw();
virtual void calc();
virtual void setPredictLanguageDialog(void*);
@@ -171,7 +186,15 @@ namespace textinput {
void onPressedShift(bool shift);
void onReleasedShift();
#ifdef MYTIMANAGER_IMPLEMENTATION
#ifdef TIINPUTFORM_IMPLEMENTATION
bool hasLineFeedButton() const { return mbLineFeedButton; }
private:
void* mpPredictLanguageDialog;
void* mpSignWindow;
bool mbLineFeedButton;
public:
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) override;
virtual bool updateInput(input::HKBManager& hkbManager) override;
#endif

View File

@@ -17,6 +17,62 @@ namespace textinput {
}
namespace keyboard {
namespace signwindow {
#ifndef TISIGNWINDOW_IMPLEMENTATION
#ifdef TIMANAGER_IMPLEMENTATION
struct LanguageDependencyData;
class Base : public KeyboardBase {
public:
Base(Manager* manager) : mpAllocator(NULL), mpManager(manager) {}
virtual ~Base();
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual int getType();
virtual void setLanguage(Language language);
virtual bool isLocked();
virtual void setPage(u8 page);
virtual u8 getPage();
virtual void movePrevSignPage();
virtual void moveNextSignPage();
virtual void close();
private:
u32 mInputState;
const LanguageDependencyData* mpLanguageData;
MEMAllocator* mpAllocator;
Manager* mpManager;
};
class EventHandler;
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public nw4rmanager::AnmObserver {
public:
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mbActive(false), mbInput(false), mpEventHandler(NULL), mpCaller(NULL) {}
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual void onKey(u32 event, void* data);
virtual void movePrevSignPage();
virtual void moveNextSignPage();
virtual void close();
virtual void draw();
virtual void open(KeyboardBase* keyboard, bool repeat);
virtual bool isActive();
virtual void onChangeAnmState(AnmEvent event, nw4rmanager::AnmPane* pane, nw4rmanager::Anim* animation);
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
virtual bool updateInput(input::HKBManager& hkb);
virtual void throwReleaseForAll();
virtual void resetAnmSignWindow();
virtual void setSignKeyTop(u16 first, u16 count);
virtual void setPageNumber(u16 page);
virtual void endToClose();
virtual void startToInput();
virtual void movePrevSignWindow();
virtual void moveNextSignWindow();
private:
bool mbActive;
bool mbInput;
EventHandler* mpEventHandler;
KeyboardBase* mpCaller;
};
#else
class Base : public KeyboardBase {
public:
virtual bool isLocked();
@@ -32,7 +88,10 @@ namespace textinput {
virtual void open(KeyboardBase* keyboard, bool repeat);
virtual bool isActive();
};
#endif
#endif
}
namespace pctype {
struct GridKey {
@@ -94,8 +153,10 @@ namespace textinput {
void refresh_();
void refreshText(nw4r::lyt::Pane* root);
void setABCFlag(u32 flags);
u32 getABCFlag() const { return abcFlags & ~15; }
u32 getABCMode() const { return abcFlags & 15; }
wchar_t getWCCode(u32 index);
wchar_t getWCCode(char* paneName);
wchar_t getWCCode(char* paneName) NO_INLINE;
void setABCMode(u32 mode) {
if ((abcFlags & 15) != mode) {
abcFlags = (abcFlags & ~15) | (mode & 15);
@@ -115,9 +176,22 @@ namespace textinput {
const LanguageData* data;
Base* owner;
};
#ifdef TIMANAGER_IMPLEMENTATION
Base(Manager* manager) {
mKeyState.abcFlags = 0;
mKeyState.inputType = 0;
mKeyState.aiuFlags = 0;
mKeyState.language = USA;
mKeyState.data = NULL;
mKeyState.owner = this;
mpAllocator = NULL;
mbOnlyQwerty = false;
mpManager = manager;
}
#endif
virtual ~Base();
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual inline void init();
virtual void updateFromReceiver(u32 command, void* data);
virtual void onKey(u32 event, void* data);
virtual int getType();
@@ -152,6 +226,12 @@ namespace textinput {
State mState;
const LanguageData* mpInitialLanguageData;
KeyState mKeyState;
#ifdef TIHWKEYBOARD_IMPLEMENTATION
public:
KeyState& hardwareKeyState() { return mKeyState; }
bool hardwareLanguageKeyActive() const { return mbLanguageKeyActive; }
protected:
#endif
MEMAllocator* mpAllocator;
bool mbOnlyQwerty;
bool mbLanguageKeyActive;
@@ -159,46 +239,15 @@ namespace textinput {
};
class LayoutByNW4R;
class AnmPane : public nw4rmanager::AnmPane {
class AnmPane;
class EventHandler : public nw4rmanager::TiEventHandler {
public:
AnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : nw4rmanager::AnmPane(pane, observer), mAnimation(0) {}
virtual void init();
virtual void changeAnimation(u32 animation);
virtual ~AnmPane();
virtual int getState() const { return mAnimation; }
virtual int getKeyType() const { return mKeyType; }
protected:
int mAnimation;
int mKeyType;
};
class NormalButtonAnmPane : public AnmPane {
public:
NormalButtonAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) { mKeyType = 0; }
virtual ~NormalButtonAnmPane();
virtual void onAnmEvent(AnmPaneEvent event);
};
class ShiftCapsAnmPane : public AnmPane {
public:
ShiftCapsAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer), mbOn(false) { mKeyType = 1; }
virtual ~ShiftCapsAnmPane();
virtual void onAnmEvent(AnmPaneEvent event);
bool isFocused() const;
EventHandler(LayoutByNW4R* layout) : mpKeyboard(layout) {}
virtual ~EventHandler();
virtual void onTiEvent(gui::PaneComponent* component, u32 event, Input* input);
private:
bool mbOn;
};
class ToggleButtonAnmPane : public AnmPane {
public:
ToggleButtonAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) { mKeyType = 2; }
virtual ~ToggleButtonAnmPane();
virtual void onAnmEvent(AnmPaneEvent event);
};
class OnOffButtonAnmPane : public AnmPane {
public:
OnOffButtonAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) { mKeyType = 3; }
virtual ~OnOffButtonAnmPane();
virtual void onAnmEvent(AnmPaneEvent event);
LayoutByNW4R* mpKeyboard;
};
class UIObj : public gui::EventHandler {
public:
@@ -219,6 +268,8 @@ namespace textinput {
class UIModifierButton : public UIObj {
public:
UIModifierButton(u32 id, LayoutByNW4R* layout, Listener* listener);
inline void Create(nw4rmanager::Layout* layout, const char* pane, const char* bounding);
inline void SetState(bool enabled, u32 inactiveAnimation);
virtual ~UIModifierButton();
virtual void onGUIEvent(gui::PaneComponent& component, u32 event, nw4rmanager::TiEventHandler::Input* input);
gui::PaneComponent* mpPaneComponent;
@@ -244,17 +295,13 @@ namespace textinput {
GXTexObj mEnglishTexture;
GXTexObj mHangulTexture;
};
class EventHandler : public nw4rmanager::TiEventHandler {
public:
EventHandler(LayoutByNW4R* layout) : mpKeyboard(layout) {}
virtual ~EventHandler();
virtual void onTiEvent(gui::PaneComponent* component, u32 event, Input* input);
private:
LayoutByNW4R* mpKeyboard;
};
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public UIObj::Listener {
public:
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mpKeyboardEventHandler(NULL),
mShiftButton(1, this, this), mCapsButton(0, this, this), mModePanel(2, this, this) {}
#endif
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator);
virtual void init();
@@ -305,6 +352,48 @@ namespace textinput {
UIModePanel mModePanel;
};
class AnmPane : public nw4rmanager::AnmPane {
public:
AnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : nw4rmanager::AnmPane(pane, observer), mAnimation(0) {}
virtual void init();
virtual void changeAnimation(u32 animation);
virtual ~AnmPane();
virtual int getState() const { return mAnimation; }
virtual int getKeyType() const { return mKeyType; }
protected:
int mAnimation;
int mKeyType;
};
class NormalButtonAnmPane : public AnmPane {
public:
NormalButtonAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) { mKeyType = 0; }
virtual ~NormalButtonAnmPane();
virtual void onAnmEvent(AnmPaneEvent event);
};
class ShiftCapsAnmPane : public AnmPane {
public:
ShiftCapsAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer), mbOn(false) { mKeyType = 1; }
virtual ~ShiftCapsAnmPane();
virtual void onAnmEvent(AnmPaneEvent event);
bool isFocused() const;
private:
bool mbOn;
};
class ToggleButtonAnmPane : public AnmPane {
public:
ToggleButtonAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) { mKeyType = 2; }
virtual ~ToggleButtonAnmPane();
virtual void onAnmEvent(AnmPaneEvent event);
};
class OnOffButtonAnmPane : public AnmPane {
public:
OnOffButtonAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) { mKeyType = 3; }
virtual ~OnOffButtonAnmPane();
virtual void onAnmEvent(AnmPaneEvent event);
};
}
}
}

View File

@@ -14,11 +14,17 @@ namespace textinput {
class Base : public CommandSender {
public:
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
#if defined(TI_PREDICTLANG_SAMPLE_CLASS) || defined(TIMANAGER_IMPLEMENTATION)
Base(Manager* manager) : mePredictMode(inputform::Base::PM_USEn), mpAllocator(NULL), mpManager(manager) {}
#endif
#ifdef TIMANAGER_IMPLEMENTATION
virtual ~Base();
virtual void init();
virtual void create(MEMAllocator* allocator) override;
#else
virtual void create(MEMAllocator* allocator) override { mpAllocator = allocator; }
#endif
virtual void setPredictMode(inputform::Base::PredictMode mode) { mePredictMode = mode; }
protected:
@@ -32,7 +38,11 @@ namespace textinput {
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public nw4rmanager::AnmObserver {
public:
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(resAccessor, layoutName, observer), mbActive(false), mbInput(false),
mpEventHandler(NULL), meDestination(DST_US), mpCaller(NULL) {}
#elif defined(TI_PREDICTLANG_SAMPLE_CLASS)
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, "fs_prdicSelWidw_a.brlyt", observer), mbActive(false), mbInput(false),
mpEventHandler(NULL), meDestination(DST_US), mpCaller(NULL) {}
@@ -68,12 +78,21 @@ namespace textinput {
keyboard::KeyboardBase* mpCaller; // 0xD4
};
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
#if defined(TI_PREDICTLANG_SAMPLE_CLASS) || defined(TIMANAGER_IMPLEMENTATION)
class Sample : public LayoutByNW4R {
public:
#ifdef TIMANAGER_IMPLEMENTATION
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, resAccessor, observer, layoutName) {}
#else
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, observer) {}
#endif
#ifdef TIMANAGER_IMPLEMENTATION
virtual ~Sample();
#else
virtual ~Sample() {}
#endif
};
#endif

View File

@@ -0,0 +1,134 @@
#ifndef TEXTINPUT_SIGN_WINDOW_H
#define TEXTINPUT_SIGN_WINDOW_H
#include "tiKeyboard.h"
#include "tiNw4rManager.h"
#include "tiSwData.h"
namespace textinput {
class Manager;
namespace keyboard {
namespace signwindow {
struct LanguageDependency {
u8 count;
const PaneNameToCharCodeInSignMode* keys;
};
class Base : public KeyboardBase {
public:
virtual ~Base();
virtual void create(MEMAllocator*) override;
virtual void init() override;
virtual void onKey(u32, void*) override;
virtual bool isLocked();
virtual void setPage(u8);
virtual u8 getPage();
virtual void movePrevSignPage();
virtual void moveNextSignPage();
virtual void close();
virtual int getType() override;
virtual void setLanguage(Language) override;
protected:
u8 mInputFlags;
bool mbLocked;
bool mbRepeat;
u8 muPage;
const LanguageDependency* mpLanguageDependency;
MEMAllocator* mpAllocator;
Manager* mpManager;
};
class EventHandler;
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public nw4rmanager::AnmObserver {
public:
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator*) override;
virtual void init() override;
virtual void onKey(u32, void*) override;
virtual void movePrevSignPage() override;
virtual void moveNextSignPage() override;
virtual void close() override;
virtual void draw() override;
virtual void open(KeyboardBase*, bool);
virtual bool isActive();
virtual void onChangeAnmState(AnmEvent, nw4rmanager::AnmPane*, nw4rmanager::Anim*) override;
virtual bool updateInput(int, f32, f32, u32, u32, u32, void*) override;
virtual bool updateInput(input::HKBManager&) override;
virtual void throwReleaseForAll();
virtual void resetAnmSignWindow();
virtual void setSignKeyTop(u16, u16);
virtual void setPageNumber(u16);
virtual void endToClose();
virtual void startToInput();
virtual void movePrevSignWindow();
virtual void moveNextSignWindow();
bool mbActive;
bool mbInput;
EventHandler* mpEventHandler;
KeyboardBase* mpKeyboard;
};
class Sample : public LayoutByNW4R {
public:
virtual ~Sample();
};
class EventHandler : public nw4rmanager::TiEventHandler {
public:
explicit EventHandler(LayoutByNW4R* layout) : mpLayoutByNW4R(layout) {}
virtual ~EventHandler();
virtual void onTiEvent(gui::PaneComponent*, u32, Input*) override;
LayoutByNW4R* mpLayoutByNW4R;
};
class AnmPane : public nw4rmanager::AnmPane {
public:
AnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: nw4rmanager::AnmPane(pane, observer), muAnimation(0) {}
inline virtual ~AnmPane();
virtual void init() override;
virtual void changeAnimation(u32) override;
virtual u32 getKeyType() const;
protected:
s32 muAnimation;
u32 muKeyType;
};
class CellPhoneSignAllAnmPane : public AnmPane {
public:
CellPhoneSignAllAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: AnmPane(pane, observer) { muKeyType = 0; }
virtual ~CellPhoneSignAllAnmPane();
virtual void init() override;
virtual void onAnmEvent(AnmPaneEvent) override;
};
class CellPhoneSignScrollAnmPane : public AnmPane {
public:
CellPhoneSignScrollAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: AnmPane(pane, observer) { muKeyType = 1; }
virtual ~CellPhoneSignScrollAnmPane();
virtual void init() override;
virtual void onAnmEvent(AnmPaneEvent) override;
};
class CellPhoneSignButtonPane : public AnmPane {
public:
CellPhoneSignButtonPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: AnmPane(pane, observer) { muKeyType = 2; }
virtual ~CellPhoneSignButtonPane();
virtual void init() override;
virtual void onAnmEvent(AnmPaneEvent) override;
};
}
}
}
#endif

View File

@@ -3,6 +3,9 @@
#include <revolution/types.h>
#include <revolution/mem/allocator.h>
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
#include <revolution/kpr.h>
#endif
namespace textinput {
namespace tistring {
@@ -36,12 +39,20 @@ namespace textinput {
virtual wchar_t* getWCString() const { return mpszString; }
virtual void setCandidate(wchar_t candidate) { mwcCandidate = candidate; }
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
virtual wchar_t getCandidate() const { return mwcCandidate; }
#else
virtual wchar_t getCandidate() { return mwcCandidate; }
#endif
virtual bool hasCandidate() const;
virtual wchar_t getLastWChar();
#if defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
protected:
#else
private:
#endif
u16 muMaxLength; // 0x04
u16 muLength; // 0x06
@@ -54,14 +65,71 @@ namespace textinput {
};
class KanaStream {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
public:
KPRQueue mQueue;
wchar_t mPending;
wchar_t mOutput[5];
#else
private:
u8 field_0x00[0x24];
#endif
};
class Decolated : public StringBase {
public:
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
Decolated(u16 maxLen) : StringBase(maxLen), mCursorStart(0), mCursorEnd(0), mbSustain(false), mTranslateMode(0) { initKanaConverter(); }
#else
Decolated(u16 maxLen) : StringBase(maxLen), field_0x18(0), field_0x1C(0), field_0x20(0), field_0x24(0) { initKanaConverter(); }
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
virtual ~Decolated();
enum TranslateMode { TM_Direct, TM_Kana, TM_Roman, TM_Hangul };
virtual void clear();
virtual void set(const wchar_t* string);
virtual void setLength(u16 length);
void setTranslateMode(TranslateMode mode);
TranslateMode getTranslateMode() const { return static_cast<TranslateMode>(mTranslateMode); }
void inputString(const wchar_t* string, TranslateMode mode);
virtual void inputChar(wchar_t ch);
virtual void inputString(const wchar_t* string);
virtual void deleteChar();
virtual void backSpace();
virtual void confirm(const wchar_t* string);
virtual bool moveCursorRight();
virtual bool moveCursorLeft();
virtual void setCursorPos(u32 pos);
virtual void onSustain();
virtual void offSustain();
virtual bool isOnSustain();
virtual u32 getCursorPos() const;
virtual void getCursorPos(u32* start, u32* end);
virtual bool canBackSpace();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
virtual bool deleteForward();
#else
virtual void deleteForward();
#endif
virtual void getSelected(u32& start, u32& end);
virtual wchar_t getWCharAtCursor();
virtual void replaceAtCursor(wchar_t ch);
virtual bool isDakuten();
virtual void converDakuten();
virtual bool isHandaku();
virtual void converHandaku();
virtual void convertAll();
virtual bool isSmall();
virtual void converSmall();
virtual bool atTheBeginningOfASentence();
virtual void initKanaConverter();
virtual wchar_t* getKanaBuffer();
virtual bool isKanaFix() const;
virtual void confirmKana();
virtual void clearKana();
virtual void EnableKSXFilter(bool enable);
#else
virtual void inputChar();
virtual void inputString();
virtual void deleteChar();
@@ -95,15 +163,84 @@ namespace textinput {
virtual void clearKana();
virtual void EnableKSXFilter();
#endif
#if defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
protected:
#else
private:
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
u32 mCursorStart;
u32 mCursorEnd;
#if defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
u8 mbSustain;
s32 mTranslateMode;
#else
bool mbSustain;
u32 mTranslateMode;
#endif
#else
u32 field_0x18; // 0x18
u32 field_0x1C; // 0x1C
u8 field_0x20; // 0x20
u32 field_0x24; // 0x24
#endif
KanaStream mKanaStream; // 0x28
};
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
class WithAtok : public Decolated {
public:
WithAtok(u16 maxLength) : Decolated(maxLength) {}
virtual ~WithAtok();
virtual void pushBack(wchar_t ch);
virtual void popBack();
virtual void inputChar(wchar_t ch);
virtual void backSpace();
virtual void confirm(const wchar_t* string);
virtual bool moveCursorRight();
virtual bool moveCursorLeft();
virtual void getCursorPos(u32* start, u32* end);
struct DrawInfo {
const wchar_t* string;
u32 start;
u32 end;
u32 selectedStart;
u32 selectedEnd;
};
virtual bool isFix();
virtual void setFix(bool fix);
virtual void initConverting();
virtual bool isConverting();
virtual wchar_t* getConfirmedWCString() const;
virtual int getCurrentNumPredicted();
virtual void getPredicted(int index, wchar_t* string);
virtual void commitPredicted(int index);
virtual void setSelectedCandidate(s32 index);
virtual bool isCandidateSelected();
virtual s32 getSelectedCandidate();
virtual void init();
virtual void setInputting(wchar_t ch);
virtual void getDrawString(DrawInfo& info);
virtual void openDictionary(void* atok, int atokSize, void* apot, int apotSize, void* nintendo, int nintendoSize);
virtual void closeDictionary();
virtual bool hasConfirmedString();
virtual void enableConfirmedString(bool enable);
virtual void startConverting();
virtual bool isDictionaryOpened();
virtual void changeKanaMode(bool kana);
virtual wchar_t getInputStringLength();
virtual void resetRelation();
virtual void setFixMode(bool fixed);
virtual void setFixPrediction(int count, const char** predictions);
virtual void setDefaultPrediction(int count, const char** predictions);
virtual s16 getSelectedConverting();
virtual s32 getFixedPredictionNum();
};
#else
class WithAtok : public StringBase {};
#endif
}
}

View File

@@ -6,10 +6,13 @@
#include <nw4r/ut/CharWriter.h>
#include <nw4r/ut/Rect.h>
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
#include <string.h>
#endif
namespace textinput {
namespace textdrawer {
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
class Base : public nw4r::ut::CharWriter {
#else
class Base : nw4r::ut::CharWriter {
@@ -31,9 +34,23 @@ namespace textinput {
} CursorPos;
typedef struct DrawInfo {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
nw4r::ut::Rect rect;
wchar_t character;
#else
u8 unk_0x00[32];
#endif
} DrawInfo;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
Base() : mpDrawAllocator(NULL), mfViewX(0.0f), mfViewY(0.0f), mfViewWidth(0.0f), mfViewHeight(0.0f),
mfVIWidth(640.0f), mbAspect4x3(false), mbDrawClipped(false), muLine(0), mfLineSpacing(0.0f),
mfCharacterSpacing(0.0f), mfFontWidth(0.0f), mfFontHeight(0.0f), mfModifyStartY(0.0f), mfMinScrollY(0.0f),
muDrawStartPos(0), muDrawEndPos(65535), mbSecretMode(false), muDrawModifyStartLine(0), muDrawModifyEndLine(0),
muDrawModifyStartPos(0), muDrawModifyEndPos(0), muCachedStartPos(0), muCachedEndPos(0), mbDrawCache(false),
mfCachedCursorX(0.0f), mfCachedCursorY(0.0f), mfDrawScrollY(0.0f), muCachedCursorPosition(0),
mbCursorCache(false), mbMaintainCursorCache(true) { memset(&mCachedCursor, 0, sizeof(mCachedCursor)); }
#endif
virtual void create(MEMAllocator* allocator);
virtual void draw(CursorPos* cursorPos);
virtual void draw();
@@ -77,26 +94,115 @@ namespace textinput {
virtual u32 getEndPos() const;
// todo
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
virtual void setDrawModifyScopeLine(s32 startLine, s32 endLine);
virtual void setDrawCacheScopeLine(s32 startLine, s32 endLine);
virtual void modifyCursorCache(s32 line, u32 position, f32 x, f32 y, f32 width, f32 height);
#else
virtual void setDrawModifyScopeLine();
virtual void setDrawCacheScopeLine();
virtual void modifyCursorCache();
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
virtual bool isEnableCursorCache() const;
#else
virtual void isEnableCursorCache();
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
virtual u32 getDrawModifyStartLine() const;
virtual u32 getDrawModifyEndLine() const;
#else
virtual void getDrawModifyStartLine();
virtual void getDrawModifyEndLine();
#endif
virtual u32 getDrawCacheStartPos() const;
virtual void dirtyDrawCache();
virtual void dirtyCursorCache();
#ifdef TITEXTDRAWER_IMPLEMENTATION
protected:
const wchar_t* mpDrawString;
ViewPort mSavedViewport;
f32 mSavedProjection[7];
nw4r::ut::Rect mProjectionRect;
f32 mfVIWidth;
bool mbAspect4x3;
bool mbDrawClipped;
s32 muLine;
f32 mfLineSpacing;
f32 mfCharacterSpacing;
f32 mfFontWidth;
f32 mfFontHeight;
f32 mfModifyStartY;
f32 mfMinScrollY;
u32 muDrawStartPos;
u32 muDrawEndPos;
u32 muDrawCacheStartPos;
bool mbSecretMode;
s32 muDrawModifyStartLine;
s32 muDrawModifyEndLine;
s32 muDrawModifyStartPos;
s32 muDrawModifyEndPos;
u32 muCachedStartPos;
u32 muCachedEndPos;
bool mbDrawCache;
f32 mfCachedCursorX;
f32 mfCachedCursorY;
f32 mfDrawScrollY;
s32 mnCachedCursorLine;
CursorPos mCachedCursor;
bool mbCursorCache;
bool mbMaintainCursorCache;
#else
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
protected:
MEMAllocator* mpDrawAllocator;
u8 mDrawConfiguration[0x34];
f32 mfViewX;
f32 mfViewY;
f32 mfViewWidth;
f32 mfViewHeight;
f32 mfVIWidth;
bool mbAspect4x3;
bool mbDrawClipped;
u32 muLine;
f32 mfLineSpacing;
f32 mfCharacterSpacing;
f32 mfFontWidth;
f32 mfFontHeight;
f32 mfModifyStartY;
f32 mfMinScrollY;
u32 muDrawStartPos;
u32 muDrawEndPos;
u32 muDrawCacheStartPos;
#else
private:
u8 unk_0x50[0x78];
#endif
bool mbSecretMode; // 0xC8
#ifdef MYTIINPUTFORM_IMPLEMENTATION
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
u32 muDrawModifyStartLine;
u32 muDrawModifyEndLine;
u32 muDrawModifyStartPos;
u32 muDrawModifyEndPos;
u32 muCachedStartPos;
u32 muCachedEndPos;
bool mbDrawCache;
f32 mfCachedCursorX;
f32 mfCachedCursorY;
f32 mfDrawScrollY;
u32 muCachedCursorPosition;
CursorPos mCachedCursor;
bool mbCursorCache;
bool mbMaintainCursorCache;
#elif defined(MYTIINPUTFORM_IMPLEMENTATION)
protected:
u8 mDrawState[0x27];
f32 mfDrawScrollY;
u8 mDrawCacheState[0x14];
#else
u8 unk_0xCC[0x3C];
#endif
#endif
};
}

View File

@@ -39,6 +39,10 @@ namespace textinput {
f32 y; // 0x08
} Scroll;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
enum HVKCode { HVK_None = 0 };
#endif
class Base {
public :
virtual ~Base() {}
@@ -50,7 +54,14 @@ namespace textinput {
class CommandSender;
class CommandReceiver : public Base {
public:
#ifdef MYTIINPUTFORM_IMPLEMENTATION
#ifdef TI_CELLPHONE_IMPLEMENTATION
struct ChangePredictMode;
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
CommandReceiver() { clearSender(); }
virtual ~CommandReceiver();
#endif
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
struct Scroll {
bool absY;
f32 x;
@@ -62,7 +73,7 @@ namespace textinput {
INPUT_COMMAND_37 = 37,
} INPUT_COMMAND;
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
#if (defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
struct ChangePredictMode { u32 mode; bool enabled; };
#endif
virtual void clearSender();
@@ -78,7 +89,7 @@ namespace textinput {
CommandSender() : mpCommandReceiver(NULL) {}
virtual void setCommandReceiver(CommandReceiver* cmdRecv);
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
#if (defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION)) || defined(TIMANAGER_IMPLEMENTATION)
virtual void sendCommand(u32 command, void* data) {
if (mpCommandReceiver != NULL) mpCommandReceiver->onCommand(static_cast<CommandReceiver::INPUT_COMMAND>(command), data);
}

View File

@@ -10,7 +10,7 @@ namespace textinput {
namespace toolbar {
class Base {
public:
#ifdef TI_TOOLBAR_SAMPLE_CLASS
#if defined(TI_TOOLBAR_SAMPLE_CLASS) || defined(TIMANAGER_IMPLEMENTATION)
Base(Manager* manager) : mQwerty(true), meLanguage(USA), mpAllocator(NULL), mpManager(manager) {}
#endif
@@ -35,7 +35,11 @@ namespace textinput {
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
public:
#ifdef TI_TOOLBAR_SAMPLE_CLASS
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(resAccessor, layoutName, observer), mpEventHandler(NULL),
mbIsEnableQwertyChg(false) {}
#elif defined(TI_TOOLBAR_SAMPLE_CLASS)
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, "fs_VK_toolbar_a.brlyt", observer), mpEventHandler(NULL),
mbIsEnableQwertyChg(false) {}
@@ -52,10 +56,19 @@ namespace textinput {
virtual void onOK();
virtual void onCancel();
virtual void setQwertyWithSE(bool qwerty);
#ifdef TI_CELLPHONE_IMPLEMENTATION
virtual bool isEnableKeytopChange() const { return mbIsEnableQwertyChg; }
#else
virtual bool isEnableKeytopChange() const;
#endif
virtual void enableKeytopChange(bool enable);
#ifdef MYTIMANAGER_MATCHING
virtual nw4r::lyt::Pane* getDownArea();
virtual nw4r::lyt::Pane* getUpArea();
#else
virtual nw4r::lyt::Pane* getUpArea();
virtual nw4r::lyt::Pane* getDownArea();
#endif
virtual void setOKButtonVisible(bool visible);
virtual void setCancelButtonVisible(bool visible);
virtual void setOKButtonCaption(const wchar_t* caption);
@@ -117,12 +130,21 @@ namespace textinput {
KeyType meKeyType; // 0x30
};
#ifdef TI_TOOLBAR_SAMPLE_CLASS
#if defined(TI_TOOLBAR_SAMPLE_CLASS) || defined(TIMANAGER_IMPLEMENTATION)
class Sample : public LayoutByNW4R {
public:
#ifdef TIMANAGER_IMPLEMENTATION
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, resAccessor, observer, layoutName) {}
#else
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, observer) {}
#endif
#ifdef TIMANAGER_IMPLEMENTATION
virtual ~Sample();
#else
virtual ~Sample() {}
#endif
};
#else
class Sample {};

View File

@@ -7,6 +7,9 @@
namespace textinput {
namespace util {
#ifdef TIINPUTFORM_IMPLEMENTATION
wchar_t HankakuToZenkaku(wchar_t ch);
#endif
wchar_t toWLower(wchar_t ch);
wchar_t toWUpper(wchar_t ch);
@@ -17,9 +20,15 @@ namespace textinput {
wchar_t KBD_ConvertSmall(wchar_t ch);
wchar_t KBD_ConvertAll(wchar_t ch);
#ifdef TISTRING_IMPLEMENTATION
u32 KBD_IsDakuten(wchar_t ch);
u32 KBD_IsHandaku(wchar_t ch);
u32 KBD_IsSmall(wchar_t ch);
#else
bool KBD_IsDakuten(wchar_t ch);
bool KBD_IsHandaku(wchar_t ch);
bool KBD_IsSmall(wchar_t ch);
#endif
bool strcmp(const char* s1, const char* s2);
void replaceChar(char* dest, u32 destLen, const char* src, int replaceIdx, char newCh);
@@ -46,7 +55,11 @@ namespace textinput {
public:
Animation() : mfAnimationTime(0.0f), mbInAnimation(false), mbSE(false), mpAnimObserver(NULL) {}
virtual void startAnm(AnimObserver*, f32, f32, f32, void*); // 0x08
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual void startAnm(f32 start, f32 end, f32 duration, AnimObserver* observer, void* data);
#else
virtual void startAnm(AnimObserver*, f32, f32, f32, void*);
#endif // 0x08
virtual void calc(); // 0x0C
virtual f32 getValue(); // 0x10
virtual bool isActive(); // 0x14

View File

@@ -1,14 +1,159 @@
#ifndef TEXTINPUT_ZI_STRING_H
#define TEXTINPUT_ZI_STRING_H
#if defined(TIZISTRING_IMPLEMENTATION)
#include "tiString.h"
extern "C" {
#include <eztx.h>
}
#elif defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#include "tiString.h"
#include <eztx.h>
#endif
namespace textinput {
namespace tistring {
#if defined(TIZISTRING_IMPLEMENTATION)
class WithZi : public Decolated {
public:
enum PredictLanguage {
PL_0,
PL_1,
PL_2,
PL_3,
PL_4,
PL_5,
PL_6,
PL_7,
PL_8,
PL_9,
PL_10,
PL_11
};
enum LetterMode {
LM_0,
LM_1,
LM_2,
LM_3
};
static u16 ElementBuffer[0x100];
static u16 CandidatesBuffer[0x300];
static u16 CandidatedWord[0xa00];
static u16 LatestWord[0x40];
virtual ~WithZi();
virtual void create(MEMAllocator*);
virtual void pushBack(wchar_t);
virtual void popBack();
virtual void clear();
virtual void inputChar(wchar_t);
virtual void backSpace();
virtual void confirm(const wchar_t*);
virtual bool moveCursorRight();
virtual bool moveCursorLeft();
virtual bool canBackSpace();
virtual void EnableKSXFilter(bool);
virtual void init();
virtual void setInputting(wchar_t);
virtual u32 getCurrentNumPredicted();
virtual void getPredicted(int, wchar_t*);
virtual wchar_t* getCurrentSelected();
virtual u16 getInputStringLength();
virtual void setSelectedCandidate(s32);
virtual bool isFix();
virtual void setPredictLaunguage(PredictLanguage);
virtual void changeLetterMode(LetterMode);
virtual void ChangeDictionaryLanguage(u8);
virtual void setCellPhoneHoldingkey(void*);
virtual u32 setElementBuffer();
virtual u8 getPredictLanguage();
void openDictionary(void*, void*);
void clearCandidates();
void partialConfirmForKR();
void update();
u32 complementsCandidates_(s32);
void setCurrentWord(const wchar_t*);
u32 getCurrentInput(wchar_t*, u32);
wchar_t* getCurrentInput();
private:
EZTXGetParam mSearch;
u32 mSearchState;
u8 mbDictionaryOpen;
u8 mbContextChanged;
u32 mCurrentWordLength;
EZTXLanguageEntry* mpDictionaries;
void* mpDictionaryWork;
u16 mInputLength;
u32 mCandidateCount;
u32 mOemDictionaryId;
u8 mDictionaryLanguage;
s32 mSelectedCandidate;
PredictLanguage mPredictLanguage;
LetterMode mLetterMode;
void* mpHoldingKey;
u8 mbKoreanPartialConfirm;
};
#elif defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
class WithZi : public Decolated {
public:
enum PredictLanguage { PL_Default };
enum LetterMode { LM_Lower, LM_Normal, LM_Upper };
WithZi(u16 maxLength) : Decolated(maxLength), mbDictionaryOpen(false), mbContextChanged(false),
mCurrentWordLength(0), mpDictionaries(NULL), mpDictionaryWork(NULL), mInputLength(0),
mCandidateCount(0), mOemDictionaryId(0), mDictionaryLanguage(0xff), mSelectedCandidate(0),
mPredictLanguage(0), mLetterMode(2), mpHoldingKey(NULL), mbKoreanPartialConfirm(false) {}
virtual ~WithZi();
virtual void init();
virtual void setInputting(wchar_t ch);
virtual int getCurrentNumPredicted();
virtual void getPredicted(int index, wchar_t* string);
virtual const wchar_t* getCurrentSelected();
virtual u16 getInputStringLength();
virtual void setSelectedCandidate(s32 index);
virtual bool isFix();
virtual void setPredictLaunguage(PredictLanguage language);
virtual void changeLetterMode(LetterMode mode);
virtual void ChangeDictionaryLanguage(u8 language);
virtual void setCellPhoneHoldingkey(void* key);
virtual void setElementBuffer();
virtual u8 getPredictLanguage();
s32 getSelectedCandidateIndex() const { return mSelectedCandidate; }
void openDictionary(void* ziDict, void* ziOemDict);
void setCurrentWord(const wchar_t* string);
void update();
const wchar_t* getCurrentInput();
s32 getCurrentInput(wchar_t* buffer, u32 length);
void clearCandidates();
void partialConfirmForKR();
private:
EZTXGetParam mSearch;
u32 mSearchState;
bool mbDictionaryOpen;
bool mbContextChanged;
u32 mCurrentWordLength;
EZTXLanguageEntry* mpDictionaries;
void* mpDictionaryWork;
u16 mInputLength;
s32 mCandidateCount;
u32 mOemDictionaryId;
u8 mDictionaryLanguage;
s32 mSelectedCandidate;
u32 mPredictLanguage;
u32 mLetterMode;
void* mpHoldingKey;
bool mbKoreanPartialConfirm;
};
#else
class WithZi {
public:
virtual ~WithZi();
void openDictionary(void* ziDict, void* ziOemDict);
};
#endif
}
}

View File

@@ -20,7 +20,11 @@ namespace gui {
class Manager;
class EventHandler;
#if defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE)
class __declspec(novtable) Interface {
#else
class Interface {
#endif
public:
virtual void create() {} // 0x08 (0x02)
@@ -30,14 +34,14 @@ namespace gui {
virtual void draw(Mtx& mtx) {} // 0x14 (0x05)
virtual void draw() {} // 0x18 (0x06)
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
#if defined(IPL_CHANNEL_TITLE_NOVTABLE) || defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE)
virtual ~Interface(); // 0x1C (0x07)
#else
virtual ~Interface() {} // 0x1C (0x07)
#endif
};
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
#if defined(IPL_CHANNEL_TITLE_NOVTABLE) || defined(IPL_GC_WINDOW_NOVTABLE) || defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE)
class __declspec(novtable) EventHandler {
#else
class EventHandler {

View File

@@ -24,7 +24,7 @@ namespace ipl {
mbDisableCon(bDisableCon) {}
#endif
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
#if defined(IPL_CHANNEL_TITLE_NOVTABLE) || defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE)
virtual ~PaneManager();
#else
virtual ~PaneManager() {}

View File

@@ -44,9 +44,12 @@ namespace ipl {
#ifdef IPL_GCW_INTP_CTOR_OUT_OF_LINE
LinearIntp() NO_INLINE;
#endif
#ifdef IPL_BOARD_OBJECT_INLINE_INTERPOLATION_DTORS
#if defined(IPL_BOARD_OBJECT_INLINE_INTERPOLATION_DTORS) || defined(IPL_GC_WINDOW_CPP)
virtual ~LinearIntp();
#endif
#ifdef IPL_GC_WINDOW_CPP
T get() const;
#else
T get() const {
T r = mEnd * getCurrentFrame();
T b = mStart * (mMaxFrame - mFrame);
@@ -54,6 +57,7 @@ namespace ipl {
return b * (f64)(1.0f / getMaxFrame());
}
#endif
T get2() const { return (((mStart * (mMaxFrame - mFrame)) + (mEnd * mFrame)) / mMaxFrame); }
};
@@ -65,7 +69,7 @@ namespace ipl {
HermiteIntp() {}
virtual ~HermiteIntp();
void init(const T& start, const T& end, f32 maxFrame, f32 param_5, f32 param_6, int playback = ANIM_TYPE_FORWARD, f32 speed = 1.0f);
void init(const T& start, const T& end, f32 maxFrame, f32 startTangent, f32 endTangent, int playback = ANIM_TYPE_FORWARD, f32 speed = 1.0f);
T get() const {
f32 var_f27 = mFrame;
@@ -77,11 +81,11 @@ namespace ipl {
(mEnd * ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) -
(var_f28 * (var_f28 * (3.0f * var_f27 * var_f27)))));
r +=
(unkVal0 *
(mStartTangent *
(var_f27 +
((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) -
(var_f28 * (2.0f * var_f27 * var_f27))))) +
(unkVal1 * ((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) -
(mEndTangent * ((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) -
(var_f28 * (var_f27 * var_f27))));
return r;
@@ -97,7 +101,7 @@ namespace ipl {
f32 temp_f4 = var_f27 * var_f27;
f32 temp_f7 = var_f28 * (var_f28 * (var_f27 * temp_f4));
f32 temp_f3 =
(unkVal0 * (var_f27 + (temp_f7 - (var_f28 * (2.0f * var_f27 * var_f27))))) + (unkVal1 * (temp_f7 - (var_f28 * temp_f4)));
(mStartTangent * (var_f27 + (temp_f7 - (var_f28 * (2.0f * var_f27 * var_f27))))) + (mEndTangent * (temp_f7 - (var_f28 * temp_f4)));
r = r + temp_f3;
return r;*/
}
@@ -105,8 +109,8 @@ namespace ipl {
protected:
T mStart;
T mEnd;
f32 unkVal0;
f32 unkVal1;
f32 mStartTangent;
f32 mEndTangent;
};
template <>
@@ -115,7 +119,7 @@ namespace ipl {
HermiteIntp() {}
virtual ~HermiteIntp();
void init(const f32& start, const f32& end, f32 maxFrame, f32 param_5, f32 param_6, int playback = ANIM_TYPE_FORWARD,
void init(const f32& start, const f32& end, f32 maxFrame, f32 startTangent, f32 endTangent, int playback = ANIM_TYPE_FORWARD,
f32 speed = 1.0f);
f32 get() const {
@@ -128,10 +132,10 @@ namespace ipl {
(mEnd * ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) -
(var_f28 * (var_f28 * (3.0f * var_f27 * var_f27)))));
r +=
(unkVal0 *
(mStartTangent *
(var_f27 + ((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) -
(var_f28 * (2.0f * var_f27 * var_f27))))) +
(unkVal1 * ((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) -
(mEndTangent * ((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) -
(var_f28 * (var_f27 * var_f27))));
return r;
@@ -140,8 +144,8 @@ namespace ipl {
protected:
f32 mStart;
f32 mEnd;
f32 unkVal0;
f32 unkVal1;
f32 mStartTangent;
f32 mEndTangent;
};
#pragma dont_instantiate HermiteIntp<float>
@@ -151,14 +155,36 @@ namespace ipl {
public:
HermiteIntp() {}
void init(const T& start, const T& end, f32 maxFrame, f32 param_5, f32 param_6, int playback = ANIM_TYPE_FORWARD, f32 speed = 1.0f) {
void init(const T& start, const T& end, f32 maxFrame, f32 startTangent, f32 endTangent, int playback = ANIM_TYPE_FORWARD, f32 speed = 1.0f) {
mStart = start;
mEnd = end;
utility::FrameController::init(playback, maxFrame, 0.0f, speed);
unkVal0 = param_5;
unkVal1 = param_6;
mStartTangent = startTangent;
mEndTangent = endTangent;
}
#ifdef IPL_SD_CHANNEL_SELECT_CPP
T get() const {
f32 frame = mFrame;
f32 inverseDuration = 1.0f / mMaxFrame;
T result =
(mStart * (1.0f + (inverseDuration * (inverseDuration *
(inverseDuration * (frame * (2.0f * frame * frame)))) -
inverseDuration * (inverseDuration * (3.0f * frame * frame))))) -
(mEnd * (inverseDuration * (inverseDuration *
(inverseDuration * (frame * (2.0f * frame * frame)))) -
inverseDuration * (inverseDuration * (3.0f * frame * frame))));
f32 frameSquared = frame * frame;
f32 cubic = inverseDuration * (inverseDuration * (frame * frameSquared));
f32 tangent = mStartTangent * (frame + (cubic -
inverseDuration * (2.0f * frame * frame))) +
mEndTangent * (cubic - inverseDuration * frameSquared);
result.x += tangent;
result.y += tangent;
result.z += tangent;
return result;
}
#else
T get() const {
f32 var_f27 = mFrame;
f32 var_f28 = 1.0f / mMaxFrame;
@@ -170,7 +196,7 @@ namespace ipl {
f32 temp_f4 = var_f27 * var_f27;
f32 temp_f7 = var_f28 * (var_f28 * (var_f27 * temp_f4));
f32 temp_f3 =
(unkVal0 * (var_f27 + (temp_f7 - (var_f28 * (2.0f * var_f27 * var_f27))))) + (unkVal1 * (temp_f7 - (var_f28 * temp_f4)));
(mStartTangent * (var_f27 + (temp_f7 - (var_f28 * (2.0f * var_f27 * var_f27))))) + (mEndTangent * (temp_f7 - (var_f28 * temp_f4)));
r = r + temp_f3;
@@ -187,14 +213,55 @@ namespace ipl {
f32 temp_f4 = var_f27 * var_f27;
f32 temp_f7 = var_f28 * (var_f28 * (var_f27 * temp_f4));
f32 temp_f3 =
(unkVal0 * (var_f27 + (temp_f7 - (var_f28 * (2.0f * var_f27 * var_f27))))) + (unkVal1 * (temp_f7 - (var_f28 * temp_f4)));
(mStartTangent * (var_f27 + (temp_f7 - (var_f28 * (2.0f * var_f27 * var_f27))))) + (mEndTangent * (temp_f7 - (var_f28 * temp_f4)));
r = r + temp_f3;
return r;*/
}
#endif
protected:
f32 unkVal0;
f32 unkVal1;
f32 mStartTangent;
f32 mEndTangent;
};
#endif
#ifdef IPL_SD_CHANNEL_SELECT_CPP
} // namespace math
} // namespace ipl
#include "math/iplMathTypes.h"
namespace ipl {
namespace math {
template <>
class HermiteIntp<VEC3> : public utility::FrameController {
public:
HermiteIntp() {}
virtual ~HermiteIntp();
void init(const VEC3& start, const VEC3& end, f32 maxFrame, f32 startTangent, f32 endTangent, int playback = ANIM_TYPE_FORWARD, f32 speed = 1.0f);
VEC3 get() const {
f32 frame = mFrame;
f32 inverseDuration = 1.0f / mMaxFrame;
VEC3 result =
(mStart * (1.0f + (inverseDuration * (inverseDuration *
(inverseDuration * (frame * (2.0f * frame * frame)))) -
inverseDuration * (inverseDuration * (3.0f * frame * frame))))) -
(mEnd * (inverseDuration * (inverseDuration *
(inverseDuration * (frame * (2.0f * frame * frame)))) -
inverseDuration * (inverseDuration * (3.0f * frame * frame))));
f32 frameSquared = frame * frame;
f32 cubic = inverseDuration * (inverseDuration * (frame * frameSquared));
f32 tangent = mStartTangent * (frame + (cubic -
inverseDuration * (2.0f * frame * frame))) +
mEndTangent * (cubic - inverseDuration * frameSquared);
result.x += tangent;
result.y += tangent;
result.z += tangent;
return result;
}
protected:
VEC3 mStart;
VEC3 mEnd;
f32 mStartTangent;
f32 mEndTangent;
};
#endif

View File

@@ -103,7 +103,7 @@ namespace ipl {
y = r.y;
z = 0.0f;
}
#if defined(IPL_ADDRESS_EDIT_CPP) || defined(IPL_SD_CHANNEL_SELECT_CPP)
#if defined(IPL_ADDRESS_EDIT_CPP) || defined(IPL_SD_CHANNEL_SELECT_CPP) || defined(IPL_GC_WINDOW_CPP)
VEC3(f32 fx, f32 fy, f32 fz);
#else
VEC3(f32 fx, f32 fy, f32 fz) {
@@ -134,7 +134,15 @@ namespace ipl {
VEC3& operator/=(f32 val) { return operator*=(1.f / val); }
VEC3 operator+(const VEC3& rhs) const { return VEC3(x + rhs.x, y + rhs.y, z + rhs.z); }
VEC3 operator+(f32 v) const { return VEC3(x + v, y + v, z + v); }
#ifdef IPL_SD_CHANNEL_SELECT_CPP
nw4r::math::VEC3 operator-(const VEC3& rhs) const {
nw4r::math::VEC3 difference;
nw4r::math::VEC3Sub(&difference, this, &rhs);
return difference;
}
#else
VEC3 operator-(const VEC3& rhs) const { return VEC3(x - rhs.x, y - rhs.y, z - rhs.z); }
#endif
VEC3 operator*(f32 val) const { return VEC3(x * val, y * val, z * val); }
VEC3 operator*(f64 val) const {
nw4r::math::VEC3 vecOut;

View File

@@ -86,6 +86,7 @@ namespace ipl {
const utility::BScroller& getBInst() { return mBScroller; }
#ifdef IPL_SDMEMORY_SCROLLER_BINST_RESET
void initScroll() { mScroller.init(); }
void resetBInst() { mBScroller.reset(); }
#endif

View File

@@ -0,0 +1,118 @@
#ifndef IPL_SCENE_GC_WINDOW_H
#define IPL_SCENE_GC_WINDOW_H
#include "scene/memoryCard/iplMemoryCardBase.h"
#include "scene/memoryCard/iplMemoryCardManager.h"
#include "math/iplMathTypes.h"
#include "math/iplInterporation.h"
namespace ipl {
namespace scene {
class GCWindow : public MemoryBase, public MemCardEventListener {
#ifdef IPL_MEMORY_CARD_CPP
friend class MemoryCard;
#endif
public:
GCWindow(EGG::Heap*, nand::LayoutFile*, const char*, const char*);
virtual ~GCWindow();
void init(const math::VEC3&, MemoryCardManager*, u8, short);
void calc();
void draw();
void destroy();
void onPoint(const char*, controller::Interface*);
void onLeft(const char*);
void onTrig(const char*);
private:
void on_wait();
void on_fadein();
void on_normal();
void on_fadeout1st();
void on_fadeout_yes1st();
void on_focus_move();
void on_focus_copy();
void on_focus_del();
void on_select_out();
void on_dialog();
void on_error_message();
void on_process();
void on_error_message1st();
void on_error_message2nd();
void on_error_message3rd();
void on_format1st();
void on_format2nd();
void on_format3rd();
void on_format4th();
void on_format_error();
void change_textbox_doing();
void change_textbox_done();
void set_texture(const char*, const GXTexObj&);
public:
virtual void onMemEvent(long, u8);
#ifdef IPL_GC_WINDOW_CPP
virtual void on_wait_anim() = 0;
virtual void on_exit() = 0;
virtual void on_error() = 0;
virtual void on_format() = 0;
virtual void on_dialog_result() = 0;
virtual void on_select_in() = 0;
virtual void on_message_done() = 0;
virtual void on_button_trig() = 0;
#else
virtual void on_wait_anim();
virtual void on_exit();
virtual void on_error();
virtual void on_format();
virtual void on_dialog_result();
virtual void on_select_in();
virtual void on_message_done();
virtual void on_button_trig();
#endif
bool isProcess();
void stop_wait_anim();
private:
int mState;
MemoryBaseEvent* mpEvent;
MemoryCardManager* mpMemoryCardManager;
math::LinearIntp<math::VEC3> mLinearInterp;
math::VEC3 mTranslate;
u8 mCardState;
short mCardIndex;
int mOperation;
bool mActive;
bool mWaiting;
u8 mFlags0[2];
u8 mFlags1[2];
};
class SavedataEditWindow : public MemoryBase {
public:
SavedataEditWindow(EGG::Heap* heap, nand::LayoutFile* layoutFile, const char* directory, const char* fileName);
virtual void init();
virtual void calc();
virtual void draw();
virtual void destroy();
private:
void add_animation(const char* fileName, const char* groupName) {
AnmName animation = {fileName, groupName};
MemoryBase::add_animation(&animation, 1);
}
void on_normal();
void on_fadein();
void on_fadeout1st();
void on_focus_del();
void on_select_out();
void on_fadeout_yes1st();
int mState;
MemoryBaseEvent* mpEvent;
math::LinearIntp<math::VEC3> mLinearInterp;
math::VEC3 mTranslate;
bool mActive;
};
}
}
#endif

View File

@@ -59,6 +59,10 @@ namespace ipl {
void start_errormessage_fadein();
int update_slot();
#ifdef IPL_MEMORY_CARD_CPP
bool can_scroll_r() const { return mIconCount > 30 && mState == 2; }
bool can_scroll_l() const { return mIconIndex >= 0 && mState == 2; }
#endif
void show_arw();
void show_capacity(u8 slot);

View File

@@ -35,7 +35,11 @@ namespace ipl {
MemoryBase* mpBase; // 0x0C
};
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
class __declspec(novtable) MemoryBase {
#else
class MemoryBase {
#endif
public:
class Anm {
public:

View File

@@ -12,13 +12,61 @@
namespace ipl {
namespace scene {
class MemCardEventHandler {
class __declspec(novtable) MemCardEventListener {
public:
MemCardEventListener() {}
virtual ~MemCardEventListener() {}
virtual void onMemEvent(long event, u8 slot);
};
class MemCardEventHandler : public MemCardEventListener {
public:
MemCardEventHandler() {}
virtual ~MemCardEventHandler();
virtual void onMemEvent(long event, u8 slot);
virtual void onMount(u8 slot) = 0;
virtual void onUnmount(u8 slot) = 0;
virtual void onAttach(u8 slot) = 0;
virtual void onDetach(u8 slot) = 0;
virtual void onCheck(u8 slot) = 0;
virtual void onFormat(u8 slot) = 0;
virtual void onRepair(u8 slot) = 0;
virtual void onRead(u8 slot) = 0;
virtual void onWrite(u8 slot) = 0;
virtual void onOpen(u8 slot) = 0;
virtual void onClose(u8 slot) = 0;
virtual void onCreate(u8 slot) = 0;
virtual void onDelete(u8 slot) = 0;
virtual void onCopy(u8 slot) = 0;
virtual void onMove(u8 slot) = 0;
virtual void onRename(u8 slot) = 0;
virtual void onVerify(u8 slot) = 0;
virtual void onCommit(u8 slot) = 0;
virtual void onProbe(u8 slot) = 0;
virtual void onMountAsync(u8 slot) = 0;
virtual void onUnmountAsync(u8 slot) = 0;
virtual void onCheckAsync(u8 slot) = 0;
virtual void onFormatAsync(u8 slot) = 0;
virtual void onReadAsync(u8 slot) = 0;
virtual void onWriteAsync(u8 slot) = 0;
virtual void onCreateAsync(u8 slot) = 0;
virtual void onDeleteAsync(u8 slot) = 0;
virtual void onCopyAsync(u8 slot) = 0;
virtual void onMoveAsync(u8 slot) = 0;
virtual void onRenameAsync(u8 slot) = 0;
virtual void onVerifyAsync(u8 slot) = 0;
virtual void onCommitAsync(u8 slot) = 0;
virtual void onProbeAsync(u8 slot) = 0;
virtual void onFreeBlocks(u8 slot) = 0;
virtual void onGetLength(u8 slot) = 0;
virtual void onSetAttrib(u8 slot) = 0;
virtual void onGetAttrib(u8 slot) = 0;
virtual void onSlotStatus(u8 slot) = 0;
};
typedef struct MCFile {
@@ -56,6 +104,44 @@ namespace ipl {
}
virtual ~MemoryCardManager();
virtual void onMount(u8 slot) = 0;
virtual void onUnmount(u8 slot) = 0;
virtual void onAttach(u8 slot) = 0;
virtual void onDetach(u8 slot) = 0;
virtual void onCheck(u8 slot) = 0;
virtual void onFormat(u8 slot) = 0;
virtual void onRepair(u8 slot) = 0;
virtual void onRead(u8 slot) = 0;
virtual void onWrite(u8 slot) = 0;
virtual void onOpen(u8 slot) = 0;
virtual void onClose(u8 slot) = 0;
virtual void onCreate(u8 slot) = 0;
virtual void onDelete(u8 slot) = 0;
virtual void onCopy(u8 slot) = 0;
virtual void onMove(u8 slot) = 0;
virtual void onRename(u8 slot) = 0;
virtual void onVerify(u8 slot) = 0;
virtual void onCommit(u8 slot) = 0;
virtual void onProbe(u8 slot) = 0;
virtual void onMountAsync(u8 slot) = 0;
virtual void onUnmountAsync(u8 slot) = 0;
virtual void onCheckAsync(u8 slot) = 0;
virtual void onFormatAsync(u8 slot) = 0;
virtual void onReadAsync(u8 slot) = 0;
virtual void onWriteAsync(u8 slot) = 0;
virtual void onCreateAsync(u8 slot) = 0;
virtual void onDeleteAsync(u8 slot) = 0;
virtual void onCopyAsync(u8 slot) = 0;
virtual void onMoveAsync(u8 slot) = 0;
virtual void onRenameAsync(u8 slot) = 0;
virtual void onVerifyAsync(u8 slot) = 0;
virtual void onCommitAsync(u8 slot) = 0;
virtual void onProbeAsync(u8 slot) = 0;
virtual void onFreeBlocks(u8 slot) = 0;
virtual void onGetLength(u8 slot) = 0;
virtual void onSetAttrib(u8 slot) = 0;
virtual void onGetAttrib(u8 slot) = 0;
void calc();
bool isSlotReady(u8 slot);
@@ -85,10 +171,18 @@ namespace ipl {
GXTexObj* _create_icon(u8 slot, s16 fileNo, long start);
const wchar_t* getComment(u8 slot, s16 index, int which);
GXTexObj* create_banner(u8 slot, s16 index);
#ifdef IPL_GC_WINDOW_CPP
u32 getBlocks(u8 slot, s16 index);
#else
u16 getBlocks(u8 slot, s16 index);
#endif
#ifdef IPL_MEMORY_CARD_CPP
u32 getFreeBlocks(u8 slot);
#else
u16 getFreeBlocks(u8 slot);
#endif
void setEventHandler(MemCardEventHandler* eventHandler) {
void setEventHandler(MemCardEventListener* eventHandler) {
mpEventHandler = eventHandler;
}
@@ -99,7 +193,7 @@ namespace ipl {
s32 mLastResult; // 0x16930
s32 mLastCmd; // 0x16934
u32 unk_0x16938; // 0x16938
MemCardEventHandler* mpEventHandler; // 0x1693C
MemCardEventListener* mpEventHandler; // 0x1693C
};
} // namespace scene
} // namespace ipl

View File

@@ -28,7 +28,7 @@ namespace ipl {
int getIndex() const { return mIndex; }
nw4r::math::VEC3& getTranslate() const;
#ifdef IPL_SD_CHANNEL_TITLE_CPP
#if defined(IPL_SD_CHANNEL_TITLE_CPP) || defined(IPL_SD_CHANNEL_OBJ_CPP)
public:
#else
private:
@@ -39,12 +39,20 @@ namespace ipl {
EGG::ExpHeap* mpDialogHeap;
EGG::ExpHeap* mpChannelHeap;
EGG::Heap* mpHeap;
#ifdef IPL_SD_CHANNEL_OBJ_CPP
int mState;
#else
u32 mState;
#endif
int mPage;
int mIndex;
nand::LayoutFile* mpLayoutFile;
nw4r::lyt::Pane* mpPane;
#ifdef IPL_SD_CHANNEL_OBJ_CPP
nand::File* mpPaneAnimator;
#else
layout::Animator* mpPaneAnimator;
#endif
layout::Object* mpBaseLayout;
layout::Animator* mpBaseAnimator;
layout::Object* mpPageLayout;
@@ -58,7 +66,11 @@ namespace ipl {
int mDialogTimer;
int mAnimationState;
nw4r::lyt::Group* mpNewMessageGroup;
#ifdef IPL_SD_CHANNEL_OBJ_CPP
layout::Animator* mpNewMessageAnimator;
#else
int mNewMessageCount;
#endif
u8 mbNewMessageGroupActive;
int mNewMessageState;
int mNewMessageFrame;
@@ -176,7 +188,7 @@ namespace ipl {
static const char* mscClockPaneNames[3];
static const char* mscMaskPaneName;
#ifdef IPL_SD_CHANNEL_TITLE_CPP
#if defined(IPL_SD_CHANNEL_TITLE_CPP) || defined(IPL_SD_CHANNEL_OBJ_CPP)
public:
#else
private:
@@ -300,6 +312,33 @@ namespace ipl {
void setLayoutFrame(int state);
BOOL tellStartingZoomAnm();
void initPageAnimations(const math::VEC3& position, int direction);
#ifdef IPL_SD_CHANNEL_SELECT_CPP
void removeNandTitleInfo(ESTitleId titleId) {
u32 titleCount = mNandTitleCount;
u32 index = 0;
for (; index < titleCount; ++index) {
if (mpNandTitleInfo[index].curTitleId == titleId) {
break;
}
}
if (index < mNandTitleCount) {
for (; index < mNandTitleCount - 1; ++index) {
NandSDWorker::TitleUsage& nextTitle = mpNandTitleInfo[index + 1];
NandSDWorker::TitleUsage& currentTitle = mpNandTitleInfo[index];
currentTitle.curTitleId = nextTitle.curTitleId;
currentTitle.size = nextTitle.size;
currentTitle.inode = nextTitle.inode;
}
--mNandTitleCount;
}
}
nw4r::math::VEC3 getPageTransitionPosition(int index) const {
nw4r::math::VEC3 position(0.0f, 0.0f, 0.0f);
nw4r::lyt::Pane* pane = getCenterChannelPane(index);
PSMTXMultVec(pane->GetGlobalMtx(), position, position);
return position;
}
#endif
static BOOL isChannelReady(const SDChannelObj* channel);
nw4r::ut::List mChannelObjects;
nand::LayoutFile* mpLayoutFile;
@@ -356,9 +395,9 @@ namespace ipl {
NandSDWorker* mpSDWorker;
ESTitleId32* mpSDTitleIds;
SDChannelSelectTitleInfo* mpSDTitleInfo;
NandSDWorker::TitleUsage* mpNandTitleInfo;
s32 mFirstTitleCount;
s32 mSecondTitleCount;
mutable NandSDWorker::TitleUsage* mpNandTitleInfo;
mutable s32 mFirstTitleCount;
mutable s32 mSecondTitleCount;
SDChannelObj* mpCurrentLoadedChannel;
u32 mSDTitleCount;
u32 mNandTitleCount;

View File

@@ -29,6 +29,9 @@ namespace ipl {
class Setting;
class APScanThread;
#ifdef IPL_SETTING_IMPLEMENTATION
class APEvent;
#else
class APEvent : public ::gui::EventHandler {
public:
APEvent(Setting* setting) : ::gui::EventHandler(), mpSetting(setting) {}
@@ -38,16 +41,17 @@ namespace ipl {
private:
Setting* mpSetting;
};
struct SettingAnimation {
u8 unknown[0x14];
int state;
};
#endif
struct SettingAPScanList {
u8 unknown[0x14];
u16 count;
u8 entries[0x7fe];
union {
struct {
u16 count;
u8 entries[0x7fe];
};
u8 recordBuffer[0x800];
};
union {
WDBssDesc_* currentDescriptor;
u16* currentDescriptorWords;
@@ -86,7 +90,7 @@ namespace ipl {
void initHTMLText();
void initMessage();
void initKeyboard(const char* text);
bool checkInputString(const wchar_t* text);
bool checkInputString(const wchar_t* text) NO_INLINE;
int checkIPString(const wchar_t* text);
void setDefaultBackString();
void calcKeyboard();
@@ -158,7 +162,6 @@ namespace ipl {
virtual void destroy();
virtual void prepare();
virtual void create();
virtual void calc();
virtual void draw();
virtual FaderSceneCommand calcFadein();
virtual FaderSceneCommand calcNormal();
@@ -208,8 +211,8 @@ namespace ipl {
layout::Object* mpChangeLayout;
layout::Object* mpMainLayout;
layout::Object* mpWaitLayout;
SettingAnimation* mpFirstAnimation;
SettingAnimation* mpSecondAnimation;
utility::FrameController* mpFirstAnimation;
utility::FrameController* mpSecondAnimation;
APEvent* mpEventHandler;
gui::PaneManager* mpPaneManager;
void* mpUSBAPThread;
@@ -262,6 +265,17 @@ namespace ipl {
#endif
};
#ifdef IPL_SETTING_IMPLEMENTATION
class APEvent : public ::gui::EventHandler {
public:
APEvent(Setting* setting) : ::gui::EventHandler(), mpSetting(setting) {}
virtual void onEvent(u32 componentID, u32 event, void* data);
private:
Setting* mpSetting;
};
#endif
} // namespace scene
} // namespace ipl

View File

@@ -20,6 +20,10 @@ namespace ipl {
return mState == STATE_WAIT_CHILD;
}
#ifdef IPL_MEMORYCARD_BASE_IMPLEMENTATION
int getMemoryCardTransitionState() const { return mState; }
#endif
private:
enum {
// Base

View File

@@ -38,21 +38,49 @@ namespace ipl {
int holdSE(const char* sndName);
int holdSEwithPosDis(const char* sndName, f32 x, f32 y);
#ifdef IPL_SOUND_MATCHING
void stopBGM(int unk = 0);
#else
int stopBGM(int unk = 0);
#endif
int stopBGM(nw4r::snd::SoundHandle* handle, int unk = 0);
int stopSE(nw4r::snd::SoundHandle* handle, int unk = 0);
void stopAllSound(int unk = 0);
int resetAllSound();
#ifdef IPL_SOUND_MATCHING
void muteOffBGM(int);
#else
int muteOffBGM(int);
#endif
#ifdef IPL_SOUND_MATCHING
void muteOnBGM(int);
#else
int muteOnBGM(int);
#endif
#ifdef IPL_SOUND_MATCHING
void pauseOnBGM();
#else
int pauseOnBGM();
#endif
#ifdef IPL_SOUND_MATCHING
void pauseOffBGM();
#else
int pauseOffBGM();
#endif
#ifdef IPL_SOUND_MATCHING
void pauseOnSE();
#else
int pauseOnSE();
#endif
#ifdef IPL_SOUND_MATCHING
void pauseOffSE();
#else
int pauseOffSE();
#endif
void setOutputMode(EAudioOutputMode mode);

View File

@@ -39,7 +39,7 @@ namespace ipl {
void stt_wait_fns_msg();
void stt_wait_terminate();
int fn_8135B1C0();
int getProgressPercent();
void error_handling();

View File

@@ -37,23 +37,41 @@ namespace ipl {
LETTER,
PHOTO_LETTER,
NUMERIC,
#ifdef IPL_SETTING_IMPLEMENTATION
NORMAL_WITHOUT_LINEFEED = 2,
NORMAL_WITHOUT_LINEFEED_WITH_SIGN = 4,
NORMAL_BIGTEXT_WITHOUT_LINEFEED = 6,
#else
NORMAL_WITHOUT_LINEFEED,
NORMAL_WITHOUT_LINEFEED_WITH_SIGN,
NORMAL_BIGTEXT_WITHOUT_LINEFEED,
#endif
ONLY_QWERTY_WITHOUT_LINEFEED_AND_SIGN,
ONLY_QWERTY_BIGTEXT_WITHOUT_LINEFEED_AND_SIGN,
#ifdef IPL_SETTING_IMPLEMENTATION
NUMERIC_WITH_DOT = 16,
NUMERIC_BIGTEXT_WITH_DOT = 10,
#else
NUMERIC_WITH_DOT,
NUMERIC_BIGTEXT_WITH_DOT,
#endif
NORMAL_BIGTEXT_WITHOUT_LINEFEED_WITH_SIGN,
NUMERIC_WITH_SEPERATOR,
PREDICT_WITHOUT_LINEFEED,
} KeyboardType;
typedef struct KeyboardSetting {
#ifdef IPL_SETTING_IMPLEMENTATION
u32 rowLimit;
const wchar_t* wcString;
u32 stringLimit;
KeyboardType type;
#else
KeyboardType type; // 0x00
const wchar_t* wcString; // 0x04
u32 stringLimit; // 0x08
u32 rowLimit; // 0x0C
#endif
#ifdef IPL_ADDRESS_EDIT_CPP
KeyboardSetting(KeyboardType keyboardType, const wchar_t* value, u32 limit, u32 rows);
#endif

View File

@@ -6,6 +6,9 @@
#include "system/iplMessage.h"
namespace ipl {
#ifdef IPL_SETTING_IMPLEMENTATION
namespace scene { class Setting; }
#endif
namespace message {
class Manager {
public:
@@ -16,6 +19,9 @@ namespace ipl {
void setResource(u8* msgData) const { mpMessage->setResource(msgData); }
private:
#ifdef IPL_SETTING_IMPLEMENTATION
friend class scene::Setting;
#endif
void initMessage();
Message* mpMessage; // 0x00

View File

@@ -24,7 +24,7 @@ namespace ipl {
class Manager;
}
namespace savedata {
extern "C" BOOL iplSavedata_813597A0(void* manager, ESTitleId titleId);
extern "C" BOOL isTitleCached(void* manager, ESTitleId titleId);
class Manager {
public:
@@ -65,6 +65,19 @@ namespace ipl {
void setDidntGotoSDMenu(BOOL value) { mData.didntGotoSDMenu = value; }
#endif
#ifdef IPL_SDMEMORY_TITLE_CACHE_ACCESS
const ESTitleId* getTitleCache() const { return &mData.titleCache[0][0]; }
ESTitleId getTitleCacheEntry(int index) const { return (&mData.titleCache[0][0])[index]; }
#endif
#ifdef IPL_SD_CHANNEL_SELECT_CPP
ESTitleId getCachedTitle(int index) const {
if (index < 0 || index >= MAX_CHANNEL_TOTAL) {
return 0;
}
return (&mData.titleCache[0][0])[index];
}
#endif
bool hasPhotoMP3Dummy() { return mbPhotoMP3; }
bool hasPhoto2Title() { return mbPhoto2; }
bool hasPhoto2DummyCheck() { return mbPhoto2Check; }
@@ -74,7 +87,7 @@ namespace ipl {
channel::SInfo& getChanInfo(int page, int index) { return mData.chanInfo[page][index]; }
textinput::extend::savedata::MemoSetting getMemoSetting() { return mData.memoSetting; }
void iplSavedata_813596B8(ESTitleId titleId);
void pushTitleCache(ESTitleId titleId);
private:
#ifdef IPL_SD_CHANNEL_SELECT_ACCESS
@@ -171,7 +184,7 @@ namespace ipl {
u8 unused_0x504[28];
friend class channel::Manager;
friend BOOL iplSavedata_813597A0(void* manager, ESTitleId titleId);
friend BOOL isTitleCached(void* manager, ESTitleId titleId);
};
} // namespace savedata
} // namespace ipl

View File

@@ -48,10 +48,14 @@ namespace EGG {
virtual bool prepareSound(nw4r::snd::SoundHandle* pHandle, u32 id) { return mSoundArchivePlayer.PrepareSound(pHandle, id); } // 0x44
virtual bool prepareSound(nw4r::snd::SoundHandle* pHandle, unsigned int id) { return mSoundArchivePlayer.PrepareSound(pHandle, id); } // 0x44
virtual bool prepareSound(nw4r::snd::SoundHandle* pHandle, const char* pName) {
#ifdef IPL_SOUND_MATCHING
u32 id = changeNameToId(pName);
#else
u32 id = nw4r::snd::SoundArchive::INVALID_ID;
if (mpArchive != NULL) {
id = changeNameToId(pName);
}
#endif
return mSoundArchivePlayer.PrepareSound(pHandle, id);
} // 0x48

View File

@@ -20,9 +20,13 @@ namespace EGG {
~SoundHeapMgr() { destroySoundHeap(); }
virtual bool loadState(s32 id) {
#ifdef IPL_SOUND_MATCHING
if (id > 0 && mHeap.GetCurrentLevel() >= id) {
#else
s32 level = mHeap.GetCurrentLevel();
if (id > 0 && level >= id) {
#endif
mHeap.LoadState(id);
return true;
}

View File

@@ -0,0 +1,41 @@
#ifndef MSL_FORMAT_RUNTIME_H
#define MSL_FORMAT_RUNTIME_H
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <errno.h>
#include <internal/locale.h>
#define SIGDIGLEN 36
#define LDBL_MANT_DIG 53
#define LDBL_MAX_EXP 1024
#define LDBL_MIN_EXP (-1021)
#define DBL_MAX 1.7976931348623157e308
#define DBL_MIN 2.2250738585072014e-308
#define DBL_EPSILON 2.2204460492503131e-16
#define EOF (-1)
typedef long ptrdiff_t;
typedef long long intmax_t;
typedef unsigned long long uintmax_t;
typedef struct {
char sign;
short exp;
struct { unsigned char length; unsigned char text[SIGDIGLEN]; } sig;
} decimal;
typedef struct { char style; short digits; } decform;
enum __ReadProcActions { __GetAChar, __UngetAChar, __TestForError };
typedef struct { char* CharStr; size_t MaxCharCount; size_t CharsWritten; } __OutStrCtrl;
typedef struct { char* NextChar; int NullCharDetected; } __InStrCtrl;
void __num2dec(const decform*, double, decimal*);
double __dec2num(const decimal*);
size_t __fwrite(const void*, size_t, size_t, FILE*);
int __StringRead(void*, int, int);
unsigned long __strtoul(int, int, int (*)(void*, int, int), void*, int*, int*, int*);
unsigned long long __strtoull(int, int, int (*)(void*, int, int), void*, int*, int*, int*);
long double __strtold(int, int (*)(void*, int, int), void*, int*, int*);
int wctomb(char*, wchar_t);
double nan(const char*);
#define signbit(x) __signbitd(x)
#endif

View File

@@ -0,0 +1,88 @@
MSL restoration, 43U, baseline 0 exact functions and 0 matched code/data in all six units.
Sources: zeldaret/tp MSL printf/wprintf; public Mario Strikers Charged MSL decimal/scanning/strtold references in /tmp/mscharged-new; time reference experiments in /tmp. All measurements were rebuilt locally.
printf long2str: corrected 32-bit minimum constant; 138/138 instructions, zero differences.
printf float2str: removed unnecessary short narrowing from exponent update; 500/500 instructions, zero differences.
printf double2hex:
1. Deferred output pointer initialization until after width validation: 242/242, 97 differences.
2. Moved output pointer declaration after decimal: 242/242, same 97 differences.
3. Copied incoming format into a local format: 244/242 and larger frame; rejected.
4. Reconstructed the actual zero-value path and ordinary literal 0x0p0 from target assembly.
5. Corrected unconditional exponent subtraction and explicit byte narrowing based on target assembly. Remaining struct argument copies use floating loads/stores instead of integer loads/stores; conversion-loop scheduling differs.
printf __pformatter:
1. Moved format declaration after buffers: 535/535, same 321 differences.
2. Initialized format to zero: 540/535, additional stores; rejected.
3. Copied parsed format before dispatch, with both locals declared at function entry: 515/535 after target semantic fixes, larger frame; rejected.
4. Removed hex-prefix zero-fill handling absent from this binary. Remaining mismatch is by-value struct copy code generation; target has 535 instructions, source 511.
wprintf double2hex:
1. Used the Charged reference implementation: 246/242, different frame/scheduling; rejected.
2. Deferred output pointer initialization: 243/242, register and copy differences remained.
3. Moved output pointer declaration after decimal: 243/242, unchanged differences.
4. Reconstructed zero-value output and unconditional exponent subtraction from target assembly. Explicit byte narrowing improved conversion instructions; struct-copy and loop scheduling remain open.
wprintf __wpformatter:
1. Initialized local format: 596/593, additional stores; rejected.
2. Moved format declaration after buffers: 591/593, changed scheduling; rejected.
3. Copied parsed format before dispatch: 595/593, larger frame; rejected.
4. Corrected the imported narrow Pascal-string branch to read and advance its actual input pointer, eliminating an uninitialized output-pointer read.
5. Removed hex-prefix zero-fill handling absent from the target. Remaining struct-copy code generation and register scheduling differ.
wprintf __wStringWrite: used the real callback result from wmemcpy; 27/27 instructions, zero differences.
ansi_fp: all ten functions have zero ctxdiff differences. Exception metadata enabled for this unit, using the same setting as matching MSL siblings. Code 6512/6512 and data 780/780.
time strftime:
1. Assigned default calendar fields individually: 906/913, scheduling differences; rejected.
2. Initialized the default calendar at declaration: 913/913, 34 remaining string-offset differences; retained.
3. Moved format-pointer declaration before locale: 913/913, 76 differences; rejected.
4. Replaced imported pooled-string address arithmetic with ordinary literals. Reconstructed real asctime/ctime formatting to account for the original literals, rather than retaining fake calls with missing format arguments.
5. With ordinary source-token order restored, strftime has 913/913 instructions and zero ctxdiff differences. Keeping the shared asctime result local to asctime restored the target BSS symbols; exception records for the additional real library functions still differ at unit level. No padding or forced placement was added.
scanf: all four functions have zero ctxdiff differences, code 5484/5484 and data 388/388. The formatter retains its actual secure-mode parameter.
strtold: __strtold has 1277/1277 instructions and strtod 44/44, both zero differences. Removed the imported inline qualifier from the public strtod wrapper so the real target symbol is emitted. Code 5284/5284 and data 112/112.
Exception metadata settings change only owned NonMatching units; configure.py status flags remain NonMatching. Clean gates require the original DOL SHA1 and zero baseline regressions. Raw instruction-exact counts can be lower than objdiff exact counts because the varargs conditional branch to an external register-save helper is compared without relocation normalization by gate.py. These counts are reported separately; they were not patched or hidden.
printf::double2hex: aggregate exponent format initialized at declaration: 238/242 instructions, 227 positional diffs; restored.
printf::double2hex: initialize exponent integer fields before byte flags: 241/242 instructions, 127 positional diffs; restored.
printf::double2hex: use integer nibble temporary with explicit final narrowing: 239/242 instructions, 123 positional diffs; restored.
printf::__pformatter: move parsed format declaration after output buffer: 511/535 instructions, 367 positional diffs; restored.
printf::__pformatter: initialize parsed format before first parse: 516/535 instructions, 505 positional diffs; restored.
printf::__pformatter: separate next-format pointer from parsed cursor: 511/535 instructions, 367 positional diffs; restored.
wprintf::double2hex: aggregate exponent format initialized at declaration: 238/242 instructions, 227 positional diffs; restored.
wprintf::double2hex: initialize exponent integer fields before byte flags: 241/242 instructions, 127 positional diffs; restored.
wprintf::double2hex: use integer nibble temporary with explicit final narrowing: 239/242 instructions, 123 positional diffs; restored.
wprintf::__wpformatter: move parsed format declaration after output buffer: 567/593 instructions, 519 positional diffs; restored.
wprintf::__wpformatter: initialize parsed format before first parse: 572/593 instructions, 562 positional diffs; restored.
wprintf::__wpformatter: separate next-format pointer from parsed cursor: 567/593 instructions, 519 positional diffs; restored.
printf::printf: finish varargs lifetime with va_end: compile rejected: ninja: build stopped: subcommand failed.; restored.
printf::printf: return through named result temporary: compile rejected: ninja: build stopped: subcommand failed.; restored.
printf::printf: move va_start to first actual formatting use: 50/50 instructions, 1 positional diffs; restored.
printf::fprintf: finish varargs lifetime with va_end: compile rejected: ninja: build stopped: subcommand failed.; restored.
printf::fprintf: return through named result temporary: compile rejected: ninja: build stopped: subcommand failed.; restored.
printf::fprintf: move va_start to first actual formatting use: 49/49 instructions, 1 positional diffs; restored.
printf::printf: finish varargs lifetime / initialize controller first: 50/50 instructions, 1 positional diffs; restored.
printf::printf: hoist argument list / named result: 50/50 instructions, 1 positional diffs; restored.
printf::printf: argument-list pointer / delay va_start: 50/50 instructions, 1 positional diffs; restored.
printf::fprintf: finish varargs lifetime / initialize controller first: 49/49 instructions, 1 positional diffs; restored.
printf::fprintf: hoist argument list / named result: 49/49 instructions, 1 positional diffs; restored.
printf::fprintf: argument-list pointer / delay va_start: 49/49 instructions, 1 positional diffs; restored.
printf::snprintf: finish varargs lifetime / initialize controller first: 54/54 instructions, 1 positional diffs; restored.
printf::snprintf: hoist argument list / named result: 54/54 instructions, 1 positional diffs; restored.
printf::snprintf: argument-list pointer / delay va_start: 54/54 instructions, 1 positional diffs; restored.
printf::sprintf: finish varargs lifetime / initialize controller first: 52/52 instructions, 1 positional diffs; restored.
printf::sprintf: hoist argument list / named result: 52/52 instructions, 1 positional diffs; restored.
printf::sprintf: argument-list pointer / delay va_start: 52/52 instructions, 1 positional diffs; restored.
wprintf::swprintf: finish varargs lifetime / initialize controller first: 55/55 instructions, 1 positional diffs; restored.
wprintf::swprintf: hoist argument list / named result: 55/55 instructions, 1 positional diffs; restored.
wprintf::swprintf: argument-list pointer / delay va_start: 55/55 instructions, 11 positional diffs; restored.
time::emit: finish varargs lifetime / initialize controller first: 43/43 instructions, 1 positional diffs; restored.
time::emit: hoist argument list / named result: 43/43 instructions, 1 positional diffs; restored.
time::emit: argument-list pointer / delay va_start: 42/43 instructions, 34 positional diffs; restored.
printf data: 139/148 relocation entries agree by target function and addend; dispatch-table entries in the unmatched formatter still differ. Generated jump-table data is retained, without manual entries or symbol mappings.
wprintf data: 139/148 relocation entries agree by target function and addend; dispatch-table entries in the unmatched formatter still differ. Generated jump-table data is retained, without manual entries or symbol mappings.
printf double2hex: moved exponent-format initialization after exponent extraction: 241/242 instructions; FP aggregate copies remained; restored.
wprintf double2hex: moved exponent-format initialization after exponent extraction: 241/242 instructions; FP aggregate copies remained; restored.
printf data: changed zero comparison literal to long double, matching the argument type and sharing its zero constant with float2str. .sdata2 now 8 bytes, 100%, versus 16 emitted bytes previously. Instruction scores unchanged.
time data: literal pool, calendar tables and BSS already agree. Target has nine exception-index records; source includes exception records for real public asctime/ctime functions absent in the extracted target. Retained the functions rather than suppressing output.
locale: restored the C locale components, collation table and ordinary literals in source order; all 792 data bytes exact. No target code functions exist.
file_io: implemented fclose, fflush, __msl_strnicmp and __msl_itoa in object order using FILE fields and named arithmetic temporaries; all four have zero ctxdiff differences, 928 code bytes and 60 metadata bytes exact.

View File

@@ -0,0 +1,160 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
enum file_kinds { file_closed, file_disk, file_console, file_unavailable };
enum io_states { neutral, writing, reading, rereading };
enum io_modes { io_read = 1, io_write = 2, io_append = 4 };
extern int __flush_all(void);
extern int __flush_buffer(FILE*, size_t*);
#pragma exceptions on
int fclose(FILE* file)
{
int flush_result, close_result;
if (file == NULL)
return -1;
if (file->mode.file_kind == file_closed)
return 0;
flush_result = fflush(file);
close_result = (*file->close_proc)(file->handle);
file->mode.file_kind = file_closed;
file->handle = 0;
if (file->state.free_buffer)
free((FILE*)file->buffer);
return (flush_result || close_result) ? -1 : 0;
}
int fflush(FILE* file)
{
int pos;
if (file == NULL)
{
return __flush_all();
}
if (file->state.error != 0 || file->mode.file_kind == file_closed)
{
return -1;
}
if (file->mode.io_mode == io_read)
{
return 0;
}
if (file->state.io_state >= rereading)
{
file->state.io_state = reading;
}
if (file->state.io_state == reading)
{
file->buffer_len = 0;
}
if (file->state.io_state != writing)
{
file->state.io_state = neutral;
return 0;
}
if (file->mode.file_kind != file_disk)
{
pos = 0;
}
else
{
pos = ftell(file);
}
if (__flush_buffer(file, NULL) != 0)
{
file->state.error = 1;
file->buffer_len = 0;
return -1;
}
file->state.io_state = neutral;
file->pos = pos;
file->buffer_len = 0;
return 0;
}
int __msl_strnicmp(const char* str1, const char* str2, int n)
{
int i;
char c1, c2;
for (i = 0; i < n; i++)
{
c1 = tolower(*str1++);
c2 = tolower(*str2++);
if (c1 < c2)
return -1;
if (c1 > c2)
return 1;
if (c1 == '\0')
return 0;
}
return 0;
}
char* __msl_itoa(int value, char* str, unsigned int base)
{
int negative;
int length;
char c;
int start;
int end;
negative = 0;
length = 0;
if (value < 0)
{
value = -value;
negative = 1;
}
do
{
int digit = value % base;
if (digit > 9)
str[length++] = digit + 0x37;
else
str[length++] = digit + 0x30;
value /= base;
} while (value != 0);
if (negative != 0)
str[length++] = '-';
str[length++] = '\0';
start = 0;
end = strlen(str) - 1;
while (start < end)
{
c = str[start];
str[start++] = str[end];
str[end--] = c;
}
return str;
}

View File

@@ -0,0 +1,123 @@
#include <internal/locale.h>
#include <limits.h>
#include <stddef.h>
extern int __mbtowc_noconv(wchar_t*, const char*, size_t);
extern int __wctomb_noconv(char*, wchar_t);
struct lconv __lconv = {
".",
"",
"",
"",
"",
"",
"",
"",
"",
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
"",
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
};
extern const unsigned short __ctype_mapC[256];
extern const unsigned char __upper_mapC[256];
extern const unsigned char __lower_mapC[256];
extern const unsigned short __wctype_mapC[256];
extern const wchar_t __wupper_mapC[256];
extern const wchar_t __wlower_mapC[256];
struct _loc_ctype_cmpt _loc_ctyp_C = {
"C",
__ctype_mapC,
__upper_mapC,
__lower_mapC,
__wctype_mapC,
__wupper_mapC,
__wlower_mapC,
__mbtowc_noconv,
__wctomb_noconv
};
unsigned short char_coll_tableC[96] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 17, 18, 19, 20, 21, 22, 23, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71,
73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 24, 25, 26, 27, 28, 0, 44, 46, 48, 50, 52, 54, 56,
58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 29, 30, 31, 32, 0,
};
struct _loc_coll_cmpt _loc_coll_C = {
"C",
' ',
110,
0,
char_coll_tableC,
NULL
};
struct _loc_mon_cmpt _loc_mon_C = {
"C",
"",
"",
"",
"",
"",
"",
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
"",
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX
};
struct _loc_num_cmpt _loc_num_C = {
"C",
".",
"",
""
};
struct _loc_time_cmpt _loc_tim_C = {
"C",
"AM|PM",
"%a %b %e %T %Y",
"%I:%M:%S %p",
"%m/%d/%y",
"%T",
"Sun|Sunday|Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thu|Thursday|Fri|Friday|Sat|Saturday",
"Jan|January|Feb|February|Mar|March|Apr|April|May|May|Jun|June|Jul|July|Aug|August|Sep|September|Oct|October|Nov|"
"November|Dec|December",
""
};
struct __locale _current_locale = {
NULL,
"C",
&_loc_coll_C,
&_loc_ctyp_C,
&_loc_mon_C,
&_loc_num_C,
&_loc_tim_C
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,817 @@
#include <internal/format_runtime.h>
typedef long long intmax_t;
enum argument_options {
normal_argument,
char_argument,
short_argument,
long_argument,
intmax_argument,
size_t_argument,
ptrdiff_argument,
long_long_argument,
double_argument,
long_double_argument,
wchar_argument
};
typedef unsigned char char_map[32];
typedef struct {
unsigned char suppress_assignment;
unsigned char field_width_specified;
unsigned char argument_options;
unsigned char conversion_char;
int field_width;
char_map char_set;
} scan_format;
#define set_char_map(map, ch) map[(unsigned char)ch >> 3] |= (1 << (ch & 7))
#define tst_char_map(map, ch) (map[(unsigned char)ch >> 3] & (1 << (ch & 7)))
static const char* parse_format(const char* format_string, scan_format* format) {
const char* s = format_string;
int c;
int flag_found, invert;
scan_format f = {0, 0, normal_argument, 0, 2147483647, {0}};
if (((c = *++s) == '%')) {
f.conversion_char = c;
*format = f;
return s + 1;
}
if (c == '*') {
f.suppress_assignment = 1;
c = *++s;
}
if (isdigit(c)) {
f.field_width = 0;
do {
f.field_width = (f.field_width * 10) + (c - '0');
c = *++s;
} while (isdigit(c));
if (f.field_width == 0) {
f.conversion_char = 0xFF;
*format = f;
return s + 1;
}
f.field_width_specified = 1;
}
flag_found = 1;
switch (c) {
case 'h':
f.argument_options = short_argument;
if (s[1] == 'h') {
f.argument_options = char_argument;
c = *++s;
}
break;
case 'l':
f.argument_options = long_argument;
if (s[1] == 'l') {
f.argument_options = long_long_argument;
c = *++s;
}
break;
case 'L':
f.argument_options = long_double_argument;
break;
case 'j':
f.argument_options = intmax_argument;
break;
case 'z':
f.argument_options = size_t_argument;
break;
case 't':
f.argument_options = ptrdiff_argument;
break;
default:
flag_found = 0;
}
if (flag_found) {
c = *++s;
}
f.conversion_char = c;
switch (c) {
case 'd':
case 'i':
case 'u':
case 'o':
case 'x':
case 'X':
if (f.argument_options == long_double_argument) {
f.conversion_char = 0xFF;
break;
}
break;
case 'a':
case 'A':
case 'f':
case 'F':
case 'e':
case 'E':
case 'g':
case 'G':
if (f.argument_options == char_argument || f.argument_options == short_argument ||
f.argument_options == intmax_argument || f.argument_options == size_t_argument ||
f.argument_options == ptrdiff_argument || f.argument_options == long_long_argument) {
f.conversion_char = 0xFF;
break;
}
if (f.argument_options == long_argument) {
f.argument_options = double_argument;
}
break;
case 'p':
f.argument_options = long_argument;
f.conversion_char = 'x';
break;
case 'c':
if (f.argument_options == long_argument) {
f.argument_options = wchar_argument;
} else {
if (f.argument_options != normal_argument) {
f.conversion_char = 0xFF;
}
}
break;
case 's':
if (f.argument_options == long_argument) {
f.argument_options = wchar_argument;
} else {
if (f.argument_options != normal_argument) {
f.conversion_char = 0xFF;
}
}
{
int i;
unsigned char* p;
for (i = sizeof(f.char_set), p = f.char_set; i; --i) {
*p++ = 0xFF;
}
f.char_set[1] = 0xC1;
f.char_set[4] = 0xFE;
}
break;
case 'n':
break;
case '[':
if (f.argument_options == long_argument) {
f.argument_options = wchar_argument;
} else {
if (f.argument_options != normal_argument) {
f.conversion_char = 0xFF;
}
}
c = *++s;
invert = 0;
if (c == '^') {
invert = 1;
c = *++s;
}
if (c == ']') {
set_char_map(f.char_set, ']');
c = *++s;
}
while (c && c != ']') {
int d;
set_char_map(f.char_set, c);
if (*(s + 1) == '-' && (d = *(s + 2)) != 0 && d != ']') {
while (++c <= d) {
set_char_map(f.char_set, c);
}
c = *(s += 3);
} else {
c = *++s;
}
}
if (!c) {
f.conversion_char = 0xFF;
break;
}
if (invert) {
int i;
unsigned char* p;
for (i = sizeof(f.char_set), p = f.char_set; i; --i, ++p) {
*p = ~*p;
}
break;
}
break;
default:
f.conversion_char = 0xFF;
break;
}
*format = f;
return s + 1;
}
int __sformatter(int (*ReadProc)(void*, int, int), void* ReadProcArg, const char* format_str, va_list arg,
int is_secure) {
int num_chars, chars_read, items_assigned, conversions;
int base, negative, overflow;
int rval;
const char* format_ptr;
char format_char;
char c;
scan_format format;
long long_num;
unsigned long u_long_num;
long long long_long_num = 0;
unsigned long long u_long_long_num;
long double long_double_num;
char* arg_ptr;
int elem_valid;
size_t elem_maxsize;
int match_failure = 0;
int terminate = 0;
format_ptr = format_str;
chars_read = 0;
items_assigned = 0;
conversions = 0;
while (!terminate && (format_char = *format_ptr) != 0) {
if (isspace(format_char)) {
do {
format_char = *++format_ptr;
} while (isspace(format_char));
if (!match_failure) {
while (isspace(c = (*ReadProc)(ReadProcArg, 0, __GetAChar))) {
++chars_read;
}
(*ReadProc)(ReadProcArg, c, __UngetAChar);
}
continue;
}
if ((format_char != '%') && (!match_failure)) {
if ((c = (*ReadProc)(ReadProcArg, 0, __GetAChar)) != (unsigned char)format_char) {
(*ReadProc)(ReadProcArg, c, __UngetAChar);
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
++format_ptr;
continue;
}
}
chars_read++;
format_ptr++;
continue;
}
format_ptr = parse_format(format_ptr, &format);
if (!format.suppress_assignment && format.conversion_char != '%') {
arg_ptr = va_arg(arg, char*);
} else {
arg_ptr = 0;
}
if ((format.conversion_char != 'n') && (!match_failure) && (*ReadProc)(ReadProcArg, 0, __TestForError)) {
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
}
}
switch (format.conversion_char) {
case 'd':
base = 10;
goto signed_int;
case 'i':
base = 0;
signed_int:
if (match_failure) {
long_num = 0;
long_long_num = 0;
} else {
if ((format.argument_options == long_long_argument) ||
(format.argument_options == intmax_argument)) {
u_long_long_num = __strtoull(base, format.field_width, ReadProc, ReadProcArg, &num_chars,
&negative, &overflow);
} else {
u_long_num = __strtoul(base, format.field_width, ReadProc, ReadProcArg, &num_chars, &negative,
&overflow);
}
if (!num_chars) {
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
long_num = 0;
long_long_num = 0;
goto signed_int_assign;
}
}
chars_read += num_chars;
if ((format.argument_options == long_long_argument) ||
(format.argument_options == intmax_argument)) {
long_long_num = (negative ? -u_long_long_num : u_long_long_num);
} else {
long_num = (negative ? -u_long_num : u_long_num);
}
}
signed_int_assign:
if (arg_ptr) {
switch (format.argument_options) {
case normal_argument:
*(int*)arg_ptr = long_num;
break;
case char_argument:
*(signed char*)arg_ptr = long_num;
break;
case short_argument:
*(short*)arg_ptr = long_num;
break;
case long_argument:
*(long*)arg_ptr = long_num;
break;
case intmax_argument:
*(intmax_t*)arg_ptr = long_long_num;
break;
case size_t_argument:
*(size_t*)arg_ptr = long_num;
break;
case ptrdiff_argument:
*(ptrdiff_t*)arg_ptr = long_num;
break;
case long_long_argument:
*(long long*)arg_ptr = long_long_num;
break;
}
if (!match_failure) {
items_assigned++;
}
}
conversions++;
break;
case 'o':
base = 8;
goto unsigned_int;
case 'u':
base = 10;
goto unsigned_int;
case 'x':
case 'X':
base = 16;
unsigned_int:
if (match_failure) {
u_long_num = 0;
u_long_long_num = 0;
} else {
if ((format.argument_options == long_long_argument) ||
(format.argument_options == intmax_argument)) {
u_long_long_num = __strtoull(base, format.field_width, ReadProc, ReadProcArg, &num_chars,
&negative, &overflow);
} else {
u_long_num = __strtoul(base, format.field_width, ReadProc, ReadProcArg, &num_chars, &negative,
&overflow);
}
if (!num_chars) {
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
u_long_num = 0;
u_long_long_num = 0;
goto unsigned_int_assign;
}
}
chars_read += num_chars;
if (negative) {
if (format.argument_options == long_long_argument) {
u_long_long_num = -u_long_long_num;
} else {
u_long_num = -u_long_num;
}
}
}
unsigned_int_assign:
if (arg_ptr) {
switch (format.argument_options) {
case normal_argument:
*(unsigned int*)arg_ptr = u_long_num;
break;
case char_argument:
*(unsigned char*)arg_ptr = u_long_num;
break;
case short_argument:
*(unsigned short*)arg_ptr = u_long_num;
break;
case long_argument:
*(unsigned long*)arg_ptr = u_long_num;
break;
case intmax_argument:
*(intmax_t*)arg_ptr = u_long_long_num;
break;
case size_t_argument:
*(size_t*)arg_ptr = u_long_num;
break;
case ptrdiff_argument:
*(ptrdiff_t*)arg_ptr = u_long_num;
break;
case long_long_argument:
*(unsigned long long*)arg_ptr = u_long_long_num;
break;
}
if (!match_failure) {
items_assigned++;
}
}
conversions++;
break;
case 'a':
case 'A':
case 'f':
case 'F':
case 'e':
case 'E':
case 'g':
case 'G':
flt:
if (match_failure) {
long_double_num = NAN;
} else {
long_double_num = __strtold(format.field_width, ReadProc, ReadProcArg, &num_chars, &overflow);
if (!num_chars) {
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
long_double_num = NAN;
goto assign_float;
}
}
chars_read += num_chars;
}
assign_float:
if (arg_ptr) {
switch (format.argument_options) {
case normal_argument:
*(float*)arg_ptr = long_double_num;
break;
case double_argument:
*(double*)arg_ptr = long_double_num;
break;
case long_double_argument:
*(long double*)arg_ptr = long_double_num;
break;
}
if (!match_failure) {
items_assigned++;
}
}
conversions++;
break;
case 'c':
if (!format.field_width_specified) {
format.field_width = 1;
}
if (arg_ptr) {
if (is_secure) {
elem_valid = 1;
elem_maxsize = va_arg(arg, size_t);
}
num_chars = 0;
if (match_failure) {
if (elem_maxsize > 0) {
*arg_ptr = 0;
}
continue;
} else {
char* arg_start = arg_ptr;
while (format.field_width-- &&
(!is_secure || ((elem_valid = (elem_maxsize > num_chars)) != 0)) &&
((rval = ((*ReadProc)(ReadProcArg, 0, __GetAChar))) != -1)) {
c = rval;
if (format.argument_options == wchar_argument) {
mbtowc(((wchar_t*)arg_ptr), (char*)(&c), 1);
arg_ptr += sizeof(char);
} else {
*arg_ptr++ = c;
}
num_chars++;
}
c = rval;
if (!num_chars || (is_secure && !elem_valid)) {
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
if (elem_maxsize > 0) {
*arg_start = 0;
}
continue;
}
}
chars_read += num_chars;
items_assigned++;
}
} else {
num_chars = 0;
while (format.field_width-- && ((rval = ((*ReadProc)(ReadProcArg, 0, __GetAChar))) != -1)) {
c = rval;
num_chars++;
}
c = rval;
if (!num_chars) {
goto exit;
}
}
conversions++;
break;
case '%':
if (match_failure) {
continue;
} else {
while (isspace(c = (*ReadProc)(ReadProcArg, 0, __GetAChar))) {
chars_read++;
}
if (c != '%') {
(*ReadProc)(ReadProcArg, c, __UngetAChar);
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
continue;
}
}
chars_read++;
}
break;
case 's':
if (!match_failure) {
c = (*ReadProc)(ReadProcArg, 0, __GetAChar);
while (isspace(c)) {
chars_read++;
c = (*ReadProc)(ReadProcArg, 0, __GetAChar);
}
(*ReadProc)(ReadProcArg, c, __UngetAChar);
}
case '[':
if (arg_ptr) {
if (is_secure) {
elem_valid = 1;
elem_maxsize = va_arg(arg, size_t) - 1;
}
num_chars = 0;
if (match_failure) {
if (elem_maxsize > 0) {
*arg_ptr = 0;
}
continue;
} else {
char* arg_start = arg_ptr;
while (format.field_width-- &&
(!is_secure || ((elem_valid = (elem_maxsize >= num_chars)) != 0)) &&
((rval = ((*ReadProc)(ReadProcArg, 0, __GetAChar))) != -1)) {
c = rval;
if (!tst_char_map(format.char_set, c)) {
break;
}
if (format.argument_options == wchar_argument) {
mbtowc(((wchar_t*)arg_ptr), (char*)&c, 1);
arg_ptr = (char*)((wchar_t*)arg_ptr + 1);
} else {
*arg_ptr++ = c;
}
num_chars++;
}
c = rval;
if (!num_chars || (is_secure && !elem_valid)) {
(*ReadProc)(ReadProcArg, c, __UngetAChar);
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
if (elem_maxsize > 0) {
*arg_start = 0;
}
continue;
}
}
chars_read += num_chars;
if (format.argument_options == wchar_argument) {
*(wchar_t*)arg_ptr = L'\0';
} else {
*arg_ptr = 0;
}
items_assigned++;
}
} else {
num_chars = 0;
while (format.field_width-- && ((rval = ((*ReadProc)(ReadProcArg, 0, __GetAChar))) != -1)) {
c = rval;
if (!tst_char_map(format.char_set, c)) {
break;
}
num_chars++;
}
c = rval;
if (!num_chars) {
(*ReadProc)(ReadProcArg, c, __UngetAChar);
break;
}
chars_read += num_chars;
}
if (format.field_width >= 0) {
(*ReadProc)(ReadProcArg, c, __UngetAChar);
}
conversions++;
break;
case 'n':
if (arg_ptr) {
switch (format.argument_options) {
case normal_argument:
*(int*)arg_ptr = chars_read;
break;
case short_argument:
*(short*)arg_ptr = chars_read;
break;
case long_argument:
*(long*)arg_ptr = chars_read;
break;
case char_argument:
*(char*)arg_ptr = chars_read;
break;
case long_long_argument:
*(long long*)arg_ptr = chars_read;
break;
}
}
continue;
case 0xFF:
default:
goto exit;
}
}
exit:
if ((*ReadProc)(ReadProcArg, 0, __TestForError) && conversions == 0) {
return -1;
}
return items_assigned;
}
int __StringRead(void* pPtr, int ch, int act) {
char ret;
__InStrCtrl* Iscp = (__InStrCtrl*)pPtr;
switch (act) {
case __GetAChar:
ret = *(Iscp->NextChar);
if (ret == '\0') {
Iscp->NullCharDetected = 1;
return -1;
} else {
Iscp->NextChar++;
return (unsigned char)ret;
}
case __UngetAChar:
if (Iscp->NullCharDetected == 0) {
Iscp->NextChar--;
} else {
Iscp->NullCharDetected = 0;
}
return ch;
case __TestForError:
return Iscp->NullCharDetected;
}
return 0;
}
inline int vsscanf(const char* s, const char* format, va_list arg) {
__InStrCtrl isc;
isc.NextChar = (char*)s;
if ((s == 0) || (*isc.NextChar == '\0')) {
return -1;
}
isc.NullCharDetected = 0;
return __sformatter(&__StringRead, (void*)&isc, format, arg, 0);
}
int sscanf(const char* s, const char* pFormat, ...) {
va_list args;
va_start(args, pFormat);
return vsscanf(s, pFormat, args);
}

View File

@@ -0,0 +1,659 @@
#include <internal/format_runtime.h>
#define DBL_MAX_10_EXP 308
#define DBL_MIN_10_EXP (-307)
#define LDBL_MIN DBL_MIN
#define LDBL_MAX DBL_MAX
#define TARGET_FLOAT_BITS 64
#define TARGET_FLOAT_BYTES (TARGET_FLOAT_BITS / 8)
#define TARGET_FLOAT_MAX_EXP LDBL_MAX_EXP
#define TARGET_FLOAT_MANT_DIG LDBL_MANT_DIG
#define TARGET_FLOAT_IMPLICIT_J_BIT 1
#define TARGET_FLOAT_MANT_BITS (TARGET_FLOAT_MANT_DIG - TARGET_FLOAT_IMPLICIT_J_BIT)
#define TARGET_FLOAT_EXP_BITS (TARGET_FLOAT_BITS - TARGET_FLOAT_MANT_BITS - 1)
enum scan_states {
start = 0x0001,
sig_start = 0x0002,
leading_sig_zeroes = 0x0004,
int_digit_loop = 0x0008,
frac_start = 0x0010,
frac_digit_loop = 0x0020,
sig_end = 0x0040,
exp_start = 0x0080,
leading_exp_digit = 0x0100,
leading_exp_zeroes = 0x0200,
exp_digit_loop = 0x0400,
finished = 0x0800,
failure = 0x1000,
nan_state = 0x2000,
infin_state = 0x4000,
hex_state = 0x8000
};
enum hex_scan_states {
not_hex = 0x0000,
hex_start = 0x0001,
hex_leading_sig_zeroes = 0x0002,
hex_int_digit_loop = 0x0004,
hex_frac_digit_loop = 0x0008,
hex_sig_end = 0x0010,
hex_exp_start = 0x0020,
hex_leading_exp_digit = 0x0040,
hex_leading_exp_zeroes = 0x0080,
hex_exp_digit_loop = 0x0100
};
#define final_state(scan_state) (scan_state & (finished | failure))
#define success(scan_state) \
(scan_state & \
(leading_sig_zeroes | int_digit_loop | frac_digit_loop | leading_exp_zeroes | exp_digit_loop | finished))
#define hex_success(count, scan_state) \
(count - 1 > 2 && scan_state & (hex_leading_sig_zeroes | hex_int_digit_loop | hex_frac_digit_loop | \
hex_leading_exp_zeroes | hex_exp_digit_loop))
#define fetch() (count++, (*ReadProc)(ReadProcArg, 0, __GetAChar))
#define unfetch(c) (*ReadProc)(ReadProcArg, c, __UngetAChar)
long double __strtold(int max_width, int (*ReadProc)(void*, int, int), void* ReadProcArg, int* chars_scanned,
int* overflow) {
int scan_state = start;
int hex_scan_state = not_hex;
int count = 0;
int spaces = 0;
int c;
decimal d = {0, 0, {0, ""}};
int sig_negative = 0;
int exp_negative = 0;
long exp_value = 0;
int exp_adjust = 0;
long double result = 0.0;
int sign_detected = 0;
int radix_marker = *(unsigned char*)(__lconv).decimal_point;
unsigned char* chptr;
unsigned char mantissa[TARGET_FLOAT_BYTES];
unsigned mantissa_digits;
unsigned long exponent = 0;
int ui;
unsigned char uch, uch1;
int NibbleIndex;
int expsign = 0;
int exp_digits = 0;
unsigned intdigits = 0;
*overflow = 0;
c = fetch();
while (count <= max_width && c != -1 && !final_state(scan_state)) {
switch (scan_state) {
case start:
if (isspace(c)) {
c = fetch();
count--;
spaces++;
break;
}
switch (toupper(c)) {
case '-':
sig_negative = 1;
case '+':
c = fetch();
sign_detected = 1;
break;
case 'I':
c = fetch();
scan_state = infin_state;
break;
case 'N':
c = fetch();
scan_state = nan_state;
break;
default:
scan_state = sig_start;
break;
}
break;
case infin_state: {
int i = 1;
char model[] = "INFINITY";
while ((i < 8) && (toupper(c) == model[i])) {
i++;
c = fetch();
}
if ((i == 3) || (i == 8)) {
if (sig_negative) {
result = (float)-(double)INFINITY;
} else {
result = INFINITY;
}
*chars_scanned = spaces + i + sign_detected;
return result;
} else {
scan_state = failure;
}
break;
}
case nan_state: {
int i = 1, j = 0;
char model[] = "NAN(";
char nan_arg[32] = "";
while ((i < 4) && (toupper(c) == model[i])) {
i++;
c = fetch();
}
if ((i == 3) || (i == 4)) {
if (i == 4) {
while ((j < 32) && (isdigit(c) || isalpha(c) || (c == radix_marker))) {
nan_arg[j++] = (char)c;
c = fetch();
}
if (c != ')') {
scan_state = failure;
break;
} else {
j++;
}
}
nan_arg[j] = '\0';
if (sig_negative) {
result = -nan(nan_arg);
} else {
result = nan(nan_arg);
}
*chars_scanned = spaces + i + j + sign_detected;
return result;
} else {
scan_state = failure;
}
break;
}
case sig_start:
if (c == radix_marker) {
scan_state = frac_start;
c = fetch();
break;
}
if (!isdigit(c)) {
scan_state = failure;
break;
}
if (c == '0') {
c = fetch();
if (toupper(c) == 'X') {
scan_state = hex_state;
hex_scan_state = hex_start;
} else {
scan_state = leading_sig_zeroes;
}
break;
}
scan_state = int_digit_loop;
break;
case leading_sig_zeroes:
if (c == '0') {
c = fetch();
break;
}
scan_state = int_digit_loop;
break;
case int_digit_loop:
if (!isdigit(c)) {
if (c == radix_marker) {
scan_state = frac_digit_loop;
c = fetch();
} else {
scan_state = sig_end;
}
break;
}
if (d.sig.length < 20) {
d.sig.text[d.sig.length++] = (unsigned char)c;
} else {
exp_adjust++;
}
c = fetch();
break;
case frac_start:
if (!isdigit(c)) {
scan_state = failure;
break;
}
scan_state = frac_digit_loop;
break;
case frac_digit_loop:
if (!isdigit(c)) {
scan_state = sig_end;
break;
}
if (d.sig.length < 20) {
if (c != '0' || d.sig.length) {
d.sig.text[d.sig.length++] = (unsigned char)c;
}
exp_adjust--;
}
c = fetch();
break;
case sig_end:
if (toupper(c) == 'E') {
scan_state = exp_start;
c = fetch();
break;
}
scan_state = finished;
break;
case exp_start:
if (c == '+') {
c = fetch();
} else if (c == '-') {
c = fetch();
exp_negative = 1;
}
scan_state = leading_exp_digit;
break;
case leading_exp_digit:
if (!isdigit(c)) {
scan_state = failure;
break;
}
if (c == '0') {
scan_state = leading_exp_zeroes;
c = fetch();
break;
}
scan_state = exp_digit_loop;
break;
case leading_exp_zeroes:
if (c == '0') {
c = fetch();
break;
}
scan_state = exp_digit_loop;
break;
case exp_digit_loop:
if (!isdigit(c)) {
scan_state = finished;
break;
}
exp_value = exp_value * 10 + (c - '0');
if (exp_value > 0x7FFF) {
*overflow = 1;
}
c = fetch();
break;
case hex_state: {
switch (hex_scan_state) {
case hex_start:
memset(mantissa, 0, sizeof(mantissa));
chptr = mantissa;
mantissa_digits = (53 + 3) / 4;
intdigits = 0;
NibbleIndex = 0;
hex_scan_state = hex_leading_sig_zeroes;
c = fetch();
break;
case hex_leading_sig_zeroes:
if (c == '0') {
c = fetch();
break;
}
hex_scan_state = hex_int_digit_loop;
break;
case hex_int_digit_loop:
if (!isxdigit(c)) {
if (c == radix_marker) {
hex_scan_state = hex_frac_digit_loop;
c = fetch();
}
else {
hex_scan_state = hex_sig_end;
}
break;
}
if (intdigits < mantissa_digits) {
intdigits++;
uch = *(chptr + NibbleIndex / 2);
ui = toupper(c);
if (ui >= 'A') {
ui = ui - 'A' + 10;
} else {
ui -= '0';
}
uch1 = (unsigned char)ui;
if ((NibbleIndex % 2) != 0) {
uch |= uch1;
} else {
uch |= (unsigned char)(uch1 << 4);
}
*(chptr + NibbleIndex++ / 2) = uch;
c = fetch();
}
else {
c = fetch();
}
break;
case hex_frac_digit_loop:
if (!isxdigit(c)) {
hex_scan_state = hex_sig_end;
break;
}
if (intdigits < mantissa_digits) {
uch = *(chptr + NibbleIndex / 2);
ui = toupper(c);
if (ui >= 'A') {
ui = ui - 'A' + 10;
} else {
ui -= '0';
}
uch1 = (unsigned char)ui;
if ((NibbleIndex % 2) != 0) {
uch |= uch1;
} else {
uch |= (unsigned char)(uch1 << 4);
}
*(chptr + NibbleIndex++ / 2) = uch;
c = fetch();
} else {
c = fetch();
}
break;
case hex_sig_end:
if (toupper(c) == 'P') {
hex_scan_state = hex_exp_start;
exp_digits++;
c = fetch();
} else {
scan_state = finished;
}
break;
case hex_exp_start:
exp_digits++;
if (c == '-') {
expsign = 1;
} else if (c != '+') {
c = unfetch(c);
count--;
exp_digits--;
}
hex_scan_state = hex_leading_exp_digit;
c = fetch();
break;
case hex_leading_exp_digit:
if (!isdigit(c)) {
scan_state = failure;
break;
}
if (c == '0') {
exp_digits++;
hex_scan_state = hex_leading_exp_zeroes;
c = fetch();
break;
}
hex_scan_state = hex_exp_digit_loop;
break;
case hex_leading_exp_zeroes:
if (c == '0') {
c = fetch();
break;
}
hex_scan_state = hex_exp_digit_loop;
break;
case hex_exp_digit_loop:
if (!isdigit(c)) {
scan_state = finished;
break;
}
exponent = exponent * 10 + (c - '0');
if (exp_value > SHRT_MAX) {
*overflow = 1;
}
exp_digits++;
c = fetch();
break;
}
} break;
}
}
if (scan_state != 32768 ? !success(scan_state) : !hex_success(count, hex_scan_state)) {
count = 0;
*chars_scanned = 0;
} else {
count--;
*chars_scanned = count + spaces;
}
unfetch(c);
if (hex_scan_state == not_hex) {
if (exp_negative) {
exp_value = -exp_value;
}
{
int n = d.sig.length;
unsigned char* p = &d.sig.text[n];
while (n-- && *--p == '0') {
exp_adjust++;
}
d.sig.length = (unsigned char)(n + 1);
if (d.sig.length == 0) {
d.sig.text[d.sig.length++] = '0';
}
}
exp_value += exp_adjust;
if (exp_value < -0x8000 || exp_value > 0x7FFF) {
*overflow = 1;
}
if (*overflow) {
if (exp_negative) {
return 0.0;
} else {
return sig_negative ? -HUGE_VAL : HUGE_VAL;
}
}
d.exp = (short)exp_value;
result = __dec2num(&d);
if (result != 0.0 && result < LDBL_MIN) {
*overflow = 1;
} else if (result > LDBL_MAX) {
*overflow = 1;
result = HUGE_VAL;
}
if (sig_negative && success(scan_state)) {
result = -result;
}
return result;
} else {
unsigned mantissa_bit, dbl_bit;
unsigned one_bit;
long double dbl_bits_storage;
unsigned char* dbl_bits = (unsigned char*)&dbl_bits_storage;
if (expsign) {
exponent = -exponent;
}
exponent += intdigits * 4;
one_bit = 0;
while (one_bit < 4 && !(mantissa[0] & (0x80 >> one_bit))) {
one_bit++;
exponent--;
}
if (TARGET_FLOAT_IMPLICIT_J_BIT) {
one_bit++;
}
if (one_bit) {
unsigned char carry = 0;
for (chptr = mantissa + sizeof(mantissa) - 1; chptr >= mantissa; chptr--) {
unsigned char a = *chptr;
*chptr = (unsigned char)((a << one_bit) | carry);
carry = (unsigned char)(a >> (8 - one_bit));
}
}
memset(dbl_bits, 0, sizeof(dbl_bits_storage));
dbl_bit = (TARGET_FLOAT_BITS - TARGET_FLOAT_MANT_BITS);
for (mantissa_bit = 0; mantissa_bit < TARGET_FLOAT_MANT_BITS; mantissa_bit += 8) {
unsigned char ui = mantissa[mantissa_bit >> 3];
int halfbits;
if (mantissa_bit + 8 > TARGET_FLOAT_MANT_BITS) {
ui &= 0xff << (TARGET_FLOAT_MANT_BITS - mantissa_bit);
}
halfbits = (dbl_bit & 7);
dbl_bits[dbl_bit >> 3] |= (unsigned char)(ui >> halfbits);
dbl_bit += 8;
dbl_bits[dbl_bit >> 3] |= (unsigned char)(ui << (8 - halfbits));
}
exponent += TARGET_FLOAT_MAX_EXP - 2;
if ((exponent & ~(TARGET_FLOAT_MAX_EXP * 2 - 1))) {
*overflow = 1;
return 0.0;
}
exponent <<= 32 - TARGET_FLOAT_EXP_BITS;
dbl_bits[0] |= exponent >> 25;
if (TARGET_FLOAT_EXP_BITS > 7) {
dbl_bits[1] |= exponent >> 17;
}
if (TARGET_FLOAT_EXP_BITS > 15) {
dbl_bits[2] |= exponent >> 9;
}
if (TARGET_FLOAT_EXP_BITS > 23) {
dbl_bits[3] |= exponent >> 1;
}
if (sig_negative) {
dbl_bits[0] |= 0x80;
}
result = *(long double*)dbl_bits;
return result;
}
}
double strtod(const char* str, char** end) {
__InStrCtrl isc;
double value, abs_value;
int count, overflow;
isc.NextChar = (char*)str;
isc.NullCharDetected = 0;
value = __strtold(INT_MAX, &__StringRead, (void*)&isc, &count, &overflow);
if (end) {
*end = (char*)str + count;
}
abs_value = fabs(value);
if (overflow || (value != 0.0 && (abs_value < DBL_MIN || abs_value > DBL_MAX))) {
errno = ERANGE;
}
return value;
}

View File

@@ -0,0 +1,727 @@
#include <limits.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stddef.h>
#include <internal/locale.h>
#include <string.h>
typedef struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
} tm;
extern int __msl_mod(int, int);
extern div_t __msl_div(long, long);
extern int __msl_add(int*, int);
extern int __msl_ladd(long*, long);
extern int __msl_lmul(long*, long);
static int __leap_year(int year) {
return __msl_mod(year, 4) == 0 && (__msl_mod(year, 100) != 0 || __msl_mod(year, 400) == 100);
}
static int leap_days(int year, int month) {
int n;
div_t q;
q = div(year, 4);
n = q.quot;
q = div(year, 100);
n -= q.quot;
if (year < 100) {
q = __msl_div(year + 899, 1000);
n += q.quot;
} else {
q = __msl_div(year - 100, 1000);
n += q.quot + 1;
}
if (__leap_year(year)) {
if (year < 0) {
if (month > 1) {
n++;
}
} else if (month <= 1) {
n--;
}
}
return n;
}
#define seconds_per_minute (60L)
#define seconds_per_hour (60L * seconds_per_minute)
#define seconds_per_day (24L * seconds_per_hour)
#define seconds_1900_to_1970 (((365 * 70UL) + 17) * 24 * 60 * 60)
const short __msl_month_to_days[2][13] = {
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
{0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}
};
extern int __isdst(void);
extern time_t __get_time(void);
extern int __to_gm_time(time_t*);
void __msl_time2tm(time_t in_time, tm* tm) {
unsigned long years, months, days, seconds;
int is_leap_year;
unsigned long time = in_time + seconds_1900_to_1970;
if (!tm) {
return;
}
tm->tm_isdst = __isdst();
days = time / seconds_per_day;
seconds = time % seconds_per_day;
tm->tm_wday = (days + 1) % 7;
years = 0;
for (;;) {
unsigned long days_this_year = __leap_year(years) ? 366 : 365;
if (days < days_this_year) {
break;
}
days -= days_this_year;
years += 1;
}
tm->tm_year = years;
tm->tm_yday = days;
months = 0;
is_leap_year = __leap_year(years);
for (;;) {
unsigned long days_thru_this_month = __msl_month_to_days[is_leap_year][months + 1];
if (days < days_thru_this_month) {
days -= __msl_month_to_days[is_leap_year][months];
break;
}
++months;
}
tm->tm_mon = months;
tm->tm_mday = days + 1;
tm->tm_hour = seconds / seconds_per_hour;
seconds %= seconds_per_hour;
tm->tm_min = seconds / seconds_per_minute;
tm->tm_sec = seconds % seconds_per_minute;
}
static int adjust(int* x, int y, int* z) {
div_t q;
q = __msl_div(*x, y);
*x = q.rem;
return __msl_add(z, q.quot);
}
static int __tm2time(tm* tm, time_t* time) {
long days;
time_t seconds, day_secs;
if (!tm || !time) {
return 0;
}
--tm->tm_mday;
if (!adjust(&tm->tm_sec, 60, &tm->tm_min)) {
goto no_exit;
}
if (!adjust(&tm->tm_min, 60, &tm->tm_hour)) {
goto no_exit;
}
if (!adjust(&tm->tm_hour, 24, &tm->tm_mday)) {
goto no_exit;
}
if (!adjust(&tm->tm_mon, 12, &tm->tm_year)) {
goto no_exit;
}
days = tm->tm_year;
if (!__msl_lmul(&days, 365)) {
goto no_exit;
}
if (!__msl_ladd(&days, leap_days(tm->tm_year, tm->tm_mon))) {
goto no_exit;
}
if (!__msl_ladd(&days, __msl_month_to_days[0][tm->tm_mon])) {
goto no_exit;
}
if (!__msl_ladd(&days, tm->tm_mday)) {
goto no_exit;
}
if (days < 0 || days > (ULONG_MAX / seconds_per_day)) {
goto no_exit;
}
day_secs = days * seconds_per_day;
seconds = (tm->tm_hour * seconds_per_hour) + (tm->tm_min * seconds_per_minute) + tm->tm_sec;
if (seconds > ULONG_MAX - day_secs) {
goto no_exit;
}
seconds += day_secs;
seconds -= seconds_1900_to_1970;
*time = seconds;
__msl_time2tm(seconds, tm);
return 1;
no_exit:
return 0;
}
extern clock_t __get_clock(void);
clock_t clock(void) {
return __get_clock();
}
time_t mktime(tm* timeptr) {
struct tm tm = *timeptr;
time_t time;
if (!__tm2time(&tm, &time)) {
return (time_t)-1;
}
*timeptr = tm;
return time;
}
static void clear_tm(struct tm* tm) {
tm->tm_sec = 0;
tm->tm_min = 0;
tm->tm_hour = 0;
tm->tm_mday = 1;
tm->tm_mon = 0;
tm->tm_year = 0;
tm->tm_wday = 1;
tm->tm_yday = 0;
tm->tm_isdst = -1;
}
static char* find_name(const char* names, int index) {
static char extracted_name[32];
int i;
const char* start = names;
const char* end;
for (i = 0; i <= index; i++) {
end = strchr(start, '|');
if (i == index) {
if (end == NULL) {
strcpy(extracted_name, start);
} else {
strncpy(extracted_name, start, end - start);
extracted_name[end - start] = '\0';
}
break;
}
start = end + 1;
}
return extracted_name;
}
#pragma exceptions off
char* asctime(const struct tm* timeptr) {
static char asctime_result[26];
char* result = asctime_result;
if (!timeptr) {
strcpy(result, "xxx xxx xx xx:xx:xx xxxx\n");
} else {
char day[4];
char month[4];
strncpy(day, find_name(_current_locale.time_cmpt_ptr->Day_Names, timeptr->tm_wday * 2), 3);
day[3] = 0;
strncpy(month, find_name(_current_locale.time_cmpt_ptr->MonthNames, timeptr->tm_mon * 2), 3);
month[3] = 0;
sprintf(result, "%s %s%3d %.2d:%.2d:%.2d %d\n", day, month, timeptr->tm_mday,
timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec, timeptr->tm_year + 1900);
}
return result;
}
struct tm* localtime(const time_t* timer);
char* ctime(const time_t* timer) {
struct tm* calendar = localtime(timer);
char* result = asctime(calendar);
char day[4];
char month[4];
strncpy(day, find_name(_current_locale.time_cmpt_ptr->Day_Names, calendar->tm_wday * 2), 3);
day[3] = 0;
strncpy(month, find_name(_current_locale.time_cmpt_ptr->MonthNames, calendar->tm_mon * 2), 3);
month[3] = 0;
sprintf(result, "%.3s %.3s %2d %.2d:%.2d:%.2d %4d\n", day, month,
calendar->tm_mday, calendar->tm_hour, calendar->tm_min, calendar->tm_sec,
calendar->tm_year + 1900);
return result;
}
#pragma exceptions on
static time_t time(time_t* timer) {
time_t result = __get_time();
if (timer) {
*timer = result;
}
return result;
}
static struct tm* gmtime(const time_t* timer) {
static struct tm gmtime_tm;
time_t time;
if (!timer) {
clear_tm(&gmtime_tm);
return &gmtime_tm;
}
time = *timer;
if (!__to_gm_time(&time)) {
return NULL;
}
__msl_time2tm(time, &gmtime_tm);
gmtime_tm.tm_isdst = 0;
return &gmtime_tm;
}
#pragma exceptions on
struct tm* localtime(const time_t* timer) {
static struct tm localtime_tm;
if (!timer) {
clear_tm(&localtime_tm);
localtime_tm.tm_isdst = __isdst();
return &localtime_tm;
} else {
__msl_time2tm(*timer, &localtime_tm);
localtime_tm.tm_isdst = __isdst();
return &localtime_tm;
}
}
static int emit(char* str, size_t size, size_t* max_size, const char* format_str, ...) {
va_list args;
va_start(args, format_str);
if (size > *max_size) {
return 0;
}
*max_size -= size;
return vsprintf(str, format_str, args);
}
time_t __MSL_ISO8601NewYear(int year) {
struct tm ts0;
time_t timeval;
short StartMday[7] = {2, 3, 4, 29, 30, 31, 1};
ts0.tm_sec = 0;
ts0.tm_min = 0;
ts0.tm_hour = 0;
ts0.tm_mon = 0;
ts0.tm_isdst = -1;
ts0.tm_mday = 0;
ts0.tm_wday = 7;
ts0.tm_year = year;
while ((ts0.tm_wday != 0) && (ts0.tm_mday <= 7)) {
ts0.tm_mday++;
timeval = mktime(&ts0);
}
ts0.tm_mday = StartMday[ts0.tm_mday - 1];
if (ts0.tm_mday >= 29) {
ts0.tm_mon = 11;
ts0.tm_year--;
}
return mktime(&ts0);
}
static double difftime(time_t time1, time_t time0) {
time_t diff;
if (time1 >= time0) {
return time1 - time0;
}
diff = time0 - time1;
return -(double)diff;
}
extern const double msl_seconds_per_day;
extern const double msl_days_per_week;
extern const double msl_seconds_per_minute;
int __MSL_ISO8601Week(const struct tm* tmptr, int* WYear) {
struct WeekYear {
int Year;
time_t Start;
};
struct WeekYear LastYear, ThisYear, NextYear;
struct WeekYear* WyPtr;
struct tm Localtm = *tmptr;
double Days;
int WeekNo;
time_t GivenTimeVal;
LastYear.Year = tmptr->tm_year - 1;
LastYear.Start = __MSL_ISO8601NewYear(LastYear.Year);
ThisYear.Year = tmptr->tm_year;
ThisYear.Start = __MSL_ISO8601NewYear(ThisYear.Year);
NextYear.Year = tmptr->tm_year + 1;
NextYear.Start = __MSL_ISO8601NewYear(NextYear.Year);
GivenTimeVal = mktime(&Localtm);
if ((LastYear.Start <= GivenTimeVal) && (GivenTimeVal < ThisYear.Start)) {
WyPtr = &LastYear;
} else if ((ThisYear.Start <= GivenTimeVal) && (GivenTimeVal < NextYear.Start)) {
WyPtr = &ThisYear;
} else {
WyPtr = &NextYear;
}
*WYear = WyPtr->Year;
{
double diff;
if (GivenTimeVal >= WyPtr->Start) {
diff = (double)(GivenTimeVal - WyPtr->Start);
} else {
diff = -(double)(WyPtr->Start - GivenTimeVal);
}
Days = diff / msl_seconds_per_day;
}
WeekNo = (int)(Days / msl_days_per_week) + 1;
return WeekNo;
}
static int week_num(const struct tm* tm, int starting_day) {
int days = tm->tm_yday;
days -= __msl_mod(tm->tm_wday - starting_day, 7);
if (days < 0) {
return 0;
}
return (days / 7) + 1;
}
static int emit_string(char* str, size_t size, size_t* max_size, const char* value) {
return emit(str, size, max_size, "%s", value);
}
size_t strftime(char* str, size_t max_size, const char* format_str, const struct tm* timeptr) {
char name[32];
size_t num_chars, chars_written, space_remaining;
struct __locale* locale = &_current_locale;
const char* format_ptr;
const char* curr_format;
int n, ISO8601Year, ISO8601WeekNo;
struct tm tm;
struct tm defaults = {0, 0, 0, 1, 0, 0, 1, 0, -1};
if ((space_remaining = --max_size) <= 0) {
return 0;
}
tm = defaults;
if (timeptr) {
tm = *timeptr;
if (mktime(&tm) == (time_t)-1) {
tm = defaults;
}
}
format_ptr = format_str;
chars_written = 0;
while (*format_ptr) {
if (!(curr_format = strchr(format_ptr, '%'))) {
if ((num_chars = strlen(format_ptr)) != 0) {
if (num_chars <= space_remaining) {
memcpy(str, format_ptr, num_chars);
chars_written += num_chars;
str += num_chars;
space_remaining -= num_chars;
} else {
return 0;
}
}
break;
}
if ((num_chars = curr_format - format_ptr) != 0) {
if (num_chars <= space_remaining) {
memcpy(str, format_ptr, num_chars);
chars_written += num_chars;
str += num_chars;
space_remaining -= num_chars;
} else {
return 0;
}
}
format_ptr = curr_format;
if (format_ptr[1] == 'E' || format_ptr[1] == 'O') {
++format_ptr;
}
switch (*++format_ptr) {
case 'a':
strcpy(name, find_name(locale->time_cmpt_ptr->Day_Names, tm.tm_wday * 2));
num_chars = emit_string(str, strlen(name), &space_remaining, name);
break;
case 'A':
strcpy(name, find_name(locale->time_cmpt_ptr->Day_Names, tm.tm_wday * 2 + 1));
num_chars = emit_string(str, strlen(name), &space_remaining, name);
break;
case 'b':
case 'h': {
num_chars =
emit(str, 3, &space_remaining, "%.3s",
find_name(locale->time_cmpt_ptr->MonthNames, tm.tm_mon * 2));
break;
}
case 'B':
strcpy(name, find_name(locale->time_cmpt_ptr->MonthNames, tm.tm_mon * 2 + 1));
num_chars = emit_string(str, strlen(name), &space_remaining, name);
break;
case 'c':
num_chars = strftime(str, space_remaining + 1, locale->time_cmpt_ptr->DateTime_Format, &tm);
space_remaining -= num_chars;
break;
case 'd':
num_chars = emit(str, 2, &space_remaining, "%.2d", tm.tm_mday);
break;
case 'D':
num_chars = strftime(str, space_remaining + 1, "%m/%d/%y", &tm);
break;
case 'e':
num_chars = emit(str, 2, &space_remaining, "%2d", tm.tm_mday);
break;
case 'F':
num_chars =
emit(str, 10, &space_remaining, "%.4d-%.2d-%.2d", tm.tm_year + 1900, tm.tm_mon + 1,
tm.tm_mday);
break;
case 'g':
ISO8601WeekNo = __MSL_ISO8601Week(timeptr, &ISO8601Year);
num_chars = emit(str, 2, &space_remaining, "%.2d", ISO8601Year % 100);
break;
case 'G':
ISO8601WeekNo = __MSL_ISO8601Week(timeptr, &ISO8601Year);
num_chars = emit(str, 4, &space_remaining, "%.4d", ISO8601Year + 1900);
break;
case 'H':
num_chars = emit(str, 2, &space_remaining, "%.2d", tm.tm_hour);
break;
case 'I':
num_chars = emit(str, 2, &space_remaining, "%.2d",
(n = tm.tm_hour % 12) ? n : 12);
break;
case 'j':
num_chars = emit(str, 3, &space_remaining, "%.3d", tm.tm_yday + 1);
break;
case 'm':
num_chars = emit(str, 2, &space_remaining, "%.2d", tm.tm_mon + 1);
break;
case 'M':
num_chars = emit(str, 2, &space_remaining, "%.2d", tm.tm_min);
break;
case 'n':
num_chars = emit(str, 2, &space_remaining, "\n");
break;
case 'p': {
char* name;
name = find_name(locale->time_cmpt_ptr->am_pm, tm.tm_hour < 12 ? 0 : 1);
num_chars = emit_string(str, strlen(name), &space_remaining, name);
break;
}
case 'r':
num_chars = strftime(str, space_remaining + 1, locale->time_cmpt_ptr->Twelve_hr_format, &tm);
space_remaining -= num_chars;
break;
case 'R':
num_chars = strftime(str, space_remaining + 1, "%H:%M", &tm);
space_remaining -= num_chars;
break;
case 'S':
num_chars = emit(str, 2, &space_remaining, "%.2d", tm.tm_sec);
break;
case 't':
num_chars = emit(str, 2, &space_remaining, "\t");
break;
case 'T':
num_chars = strftime(str, space_remaining + 1, "%H:%M:%S", &tm);
space_remaining -= num_chars;
break;
case 'u':
if (tm.tm_wday == 0) {
num_chars = emit(str, 1, &space_remaining, "7");
} else {
num_chars = emit(str, 1, &space_remaining, "%.1d", tm.tm_wday);
}
break;
case 'U':
num_chars = emit(str, 2, &space_remaining, "%.2d", week_num(&tm, 0));
break;
case 'V':
ISO8601WeekNo = __MSL_ISO8601Week(timeptr, &ISO8601Year);
num_chars = emit(str, 2, &space_remaining, "%.2d", ISO8601WeekNo);
break;
case 'w':
num_chars = emit(str, 1, &space_remaining, "%.1d", tm.tm_wday);
break;
case 'W':
num_chars = emit(str, 2, &space_remaining, "%.2d", week_num(&tm, 1));
break;
case 'x':
num_chars = strftime(str, space_remaining + 1, locale->time_cmpt_ptr->Date_Format, &tm);
space_remaining -= num_chars;
break;
case 'X':
num_chars = strftime(str, space_remaining + 1, locale->time_cmpt_ptr->Time_Format, &tm);
space_remaining -= num_chars;
break;
case 'y':
case 'C':
num_chars = emit(str, 2, &space_remaining, "%.2d", tm.tm_year % 100);
break;
case 'Y':
num_chars = emit(str, 4, &space_remaining, "%.4d", tm.tm_year + 1900);
break;
case 'z': {
time_t local, utc, now;
struct tm localtm, *utctmptr;
double diff, diffmins, diffhours;
now = time(NULL);
utctmptr = gmtime(&now);
if (utctmptr == NULL) {
num_chars = emit(str, 4, &space_remaining, "0000");
} else {
localtm = *localtime(&now);
local = mktime(&localtm);
utc = mktime(utctmptr);
diff = difftime(local, utc);
diffhours = (int)diff / 3600;
diffmins = __abs(diff / msl_seconds_per_minute - msl_seconds_per_minute * diffhours);
num_chars = emit(str, 5, &space_remaining, "%+03.0f%02.0f", diffhours, diffmins);
}
break;
}
case 'Z': {
char* TimeZone = locale->time_cmpt_ptr->TimeZone;
if (*TimeZone == '\0') {
num_chars = 0;
*str = '\0';
} else {
num_chars = emit_string(str, strlen(TimeZone), &space_remaining, TimeZone);
}
break;
}
case '%':
num_chars = emit(str, 2, &space_remaining, "%%", *format_ptr);
break;
default:
num_chars = emit(str, 2, &space_remaining, "%%%c", *format_ptr);
break;
}
if (!num_chars) {
return 0;
}
chars_written += num_chars;
str += num_chars;
++format_ptr;
}
*str = 0;
if (max_size < chars_written) {
return 0;
} else {
return chars_written;
}
}
const double msl_seconds_per_day = 86400.0;
const double msl_days_per_week = 7.0;
const double msl_seconds_per_minute = 60.0;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,671 @@
#include <internal/format_runtime.h>
#define LDBL_MAX DBL_MAX
typedef unsigned long long d_int;
static inline int __count_trailing_zerol(unsigned long x) { return 32 - __cntlzw(~x & (x - 1)); }
static int __count_trailing_zero(double n) {
unsigned long* array = (unsigned long*)&n;
unsigned long hi = array[0] | 0x100000;
unsigned long lo = array[1];
int zeros = __count_trailing_zerol(lo);
if (lo == 0) {
return 32 + __count_trailing_zerol(hi);
}
return zeros;
}
static int __must_round(const decimal* d, int digits) {
unsigned char const* i = d->sig.text + digits;
if (*i > 5) {
return 1;
}
if (*i < 5) {
return -1;
}
{
unsigned char const* e = d->sig.text + d->sig.length;
for (i++; i < e; i++) {
if (*i != 0) {
return 1;
}
}
}
if (d->sig.text[digits - 1] & 1) {
return 1;
}
return -1;
}
static void __dorounddecup(decimal* d, int digits) {
unsigned char* b = d->sig.text;
unsigned char* i = b + digits - 1;
while (1) {
if (*i < 9) {
*i += 1;
break;
}
if (i == b) {
*i = 1;
d->exp++;
break;
}
*i-- = 0;
}
}
static void __rounddec(decimal* d, int digits) {
if (digits > 0 && digits < d->sig.length) {
int unkBool = __must_round(d, digits);
d->sig.length = digits;
if (unkBool >= 0) {
__dorounddecup(d, digits);
}
}
}
static void __ull2dec(decimal* result, unsigned long long val) {
result->sign = 0;
result->sig.length = 0;
for (; val != 0; val /= 10) {
result->sig.text[result->sig.length++] = (unsigned char)(val % 10);
}
{
unsigned char* i = result->sig.text;
unsigned char* j = result->sig.text + result->sig.length;
for (; i < --j; ++i) {
unsigned char t = *i;
*i = *j;
*j = t;
}
}
result->exp = result->sig.length - 1;
}
static void __timesdec(decimal* result, const decimal* x, const decimal* y) {
unsigned long accumulator = 0;
unsigned char mantissa[SIGDIGLEN * 2];
int i = x->sig.length + y->sig.length - 1;
unsigned char* pDigit;
unsigned char* ip = mantissa + i + 1;
unsigned char* ep = ip;
result->sign = 0;
for (; i > 0; i--) {
int k = y->sig.length - 1;
int j = i - k - 1;
int l;
int t;
const unsigned char* jp;
const unsigned char* kp;
if (j < 0) {
j = 0;
k = i - 1;
}
jp = x->sig.text + j;
kp = y->sig.text + k;
l = k + 1;
t = x->sig.length - j;
if (l > t)
l = t;
for (; l > 0; l--, jp++, kp--) {
accumulator += *jp * *kp;
}
*--ip = (unsigned char)(accumulator % 10);
accumulator /= 10;
}
result->exp = (short)(x->exp + y->exp);
if (accumulator) {
*--ip = (unsigned char)(accumulator);
result->exp++;
}
for (i = 0; i < SIGDIGLEN && ip < ep; i++, ip++) {
result->sig.text[i] = *ip;
}
result->sig.length = (unsigned char)(i);
if (ip < ep && *ip >= 5) {
if (*ip == 5) {
unsigned char* jp = ip + 1;
for (; jp < ep; jp++) {
if (*jp != 0)
goto round;
}
if ((ip[-1] & 1) == 0)
return;
}
round:
__dorounddecup(result, result->sig.length);
}
}
static void __str2dec(decimal* d, const char* s, short exp) {
int i;
d->exp = exp;
d->sign = 0;
for (i = 0; i < SIGDIGLEN && *s;) {
d->sig.text[i++] = *s++ - '0';
}
d->sig.length = i;
if (*s != 0) {
if (*s < 5)
return;
if (*s > 5)
goto round;
{
const char* p = s + 1;
for (; *p != 0; p++) {
if (*p != '0')
goto round;
}
if ((d->sig.text[i - 1] & 1) == 0)
return;
}
round:
__dorounddecup(d, d->sig.length);
}
}
static void __two_exp(decimal* result, long exp) {
switch (exp) {
case -64:
__str2dec(result, "542101086242752217003726400434970855712890625", -20);
return;
case -53:
__str2dec(result, "11102230246251565404236316680908203125", -16);
return;
case -32:
__str2dec(result, "23283064365386962890625", -10);
return;
case -16:
__str2dec(result, "152587890625", -5);
return;
case -8:
__str2dec(result, "390625", -3);
return;
case -7:
__str2dec(result, "78125", -3);
return;
case -6:
__str2dec(result, "15625", -2);
return;
case -5:
__str2dec(result, "3125", -2);
return;
case -4:
__str2dec(result, "625", -2);
return;
case -3:
__str2dec(result, "125", -1);
return;
case -2:
__str2dec(result, "25", -1);
return;
case -1:
__str2dec(result, "5", -1);
return;
case 0:
__str2dec(result, "1", 0);
return;
case 1:
__str2dec(result, "2", 0);
return;
case 2:
__str2dec(result, "4", 0);
return;
case 3:
__str2dec(result, "8", 0);
return;
case 4:
__str2dec(result, "16", 1);
return;
case 5:
__str2dec(result, "32", 1);
return;
case 6:
__str2dec(result, "64", 1);
return;
case 7:
__str2dec(result, "128", 2);
return;
case 8:
__str2dec(result, "256", 2);
return;
}
{
decimal x2, temp;
__two_exp(&x2, exp / 2);
__timesdec(result, &x2, &x2);
if (exp & 1) {
temp = *result;
if (exp > 0) {
__str2dec(&x2, "2", 0);
} else {
__str2dec(&x2, "5", -1);
}
__timesdec(result, &temp, &x2);
}
}
}
static int __equals_dec(const decimal* x, const decimal* y) {
if (x->sig.text[0] == 0) {
return y->sig.text[0] == 0;
}
if (y->sig.text[0] == 0) {
return x->sig.text[0] == 0;
}
if (x->exp == y->exp) {
int i;
int l = x->sig.length;
if (l > y->sig.length) {
l = y->sig.length;
}
for (i = 0; i < l; i++) {
if (x->sig.text[i] != y->sig.text[i]) {
return 0;
}
}
if (l == x->sig.length) {
x = y;
}
for (; i < x->sig.length; i++) {
if (x->sig.text[i] != 0) {
return 0;
}
}
return 1;
}
return 0;
}
static int __less_dec(const decimal* x, const decimal* y) {
if (x->sig.text[0] == 0) {
unsigned char leading_digit = y->sig.text[0];
return ((unsigned long)(-leading_digit | leading_digit) >> 31);
}
if (y->sig.text[0] == 0) {
return 0;
}
if (x->exp == y->exp) {
int i;
int l = x->sig.length;
if (l > y->sig.length) {
l = y->sig.length;
}
for (i = 0; i < l; i++) {
if (x->sig.text[i] < y->sig.text[i]) {
return 1;
} else if (y->sig.text[i] < x->sig.text[i]) {
return 0;
}
}
if (l == x->sig.length) {
for (; i < y->sig.length; i++) {
if (y->sig.text[i] != 0) {
return 1;
}
}
}
return 0;
}
return x->exp < y->exp;
}
static void __minus_dec(decimal* z, const decimal* x, const decimal* y) {
int zlen, dexp;
unsigned char *ib, *i, *ie;
unsigned char const *jb, *j, *jn;
*z = *x;
if (y->sig.text[0] == 0)
return;
zlen = z->sig.length;
if (zlen < y->sig.length)
zlen = y->sig.length;
dexp = z->exp - y->exp;
zlen += dexp;
if (zlen > SIGDIGLEN)
zlen = SIGDIGLEN;
while (z->sig.length < zlen) {
z->sig.text[z->sig.length++] = 0;
}
ib = z->sig.text;
i = ib + zlen;
if (y->sig.length + dexp < zlen) {
i = ib + (y->sig.length + dexp);
}
jb = y->sig.text;
j = jb + (i - ib - dexp);
jn = j;
while (i > ib && j > jb) {
i--;
j--;
if (*i < *j) {
unsigned char* k = i - 1;
while (*k == 0)
k--;
while (k != i) {
--*k;
*++k += 10;
}
}
*i -= *j;
}
if (jn - jb < y->sig.length) {
int round_down = 0;
if (*jn < 5)
round_down = 1;
else if (*jn == 5) {
unsigned char const* ibPtr = y->sig.text + y->sig.length;
for (j = jn + 1; j < ibPtr; j++) {
if (*j != 0)
goto done;
}
i = ib + (jn - jb) + dexp - 1;
if (*i & 1)
round_down = 1;
}
if (round_down) {
if (*i < 1) {
unsigned char* k = i - 1;
while (*k == 0)
k--;
while (k != i) {
--*k;
*++k += 10;
}
}
*i -= 1;
}
}
done:
for (i = ib; *i == 0; ++i) {}
if (i > ib) {
unsigned char dl = (unsigned char)(i - ib);
z->exp -= dl;
ie = ib + z->sig.length;
for (; i < ie; ++i, ++ib)
*ib = *i;
z->sig.length -= dl;
}
ib = z->sig.text;
for (i = ib + z->sig.length; i > ib;) {
i--;
if (*i != 0)
break;
}
z->sig.length = (unsigned char)(i - ib + 1);
}
static void __num2dec_internal(decimal* d, double x) {
signed char sign = (signed char)(__signbitd(x) != 0);
if (x == 0) {
d->sign = sign;
d->exp = 0;
d->sig.length = 1;
d->sig.text[0] = 0;
return;
}
if (!isfinite(x)) {
d->sign = sign;
d->exp = 0;
d->sig.length = 1;
d->sig.text[0] = fpclassify(x) == 1 ? 'N' : 'I';
return;
}
if (sign != 0) {
x = -x;
}
{
int exp;
double frac = frexp(x, &exp);
int num_bits_extract = LDBL_MANT_DIG - __count_trailing_zero(frac);
decimal int_d, pow2_d;
__two_exp(&pow2_d, exp - num_bits_extract);
__ull2dec(&int_d, ldexp(frac, num_bits_extract));
__timesdec(d, &int_d, &pow2_d);
d->sign = sign;
}
}
void __num2dec(const decform* form, double x, decimal* d) {
short digits = form->digits;
int i;
__num2dec_internal(d, x);
if (d->sig.text[0] > 9) {
return;
}
if (digits > SIGDIGLEN) {
digits = SIGDIGLEN;
}
__rounddec(d, digits);
while (d->sig.length < digits) {
d->sig.text[d->sig.length++] = 0;
}
d->exp -= d->sig.length - 1;
for (i = 0; i < d->sig.length; i++) {
d->sig.text[i] += '0';
}
}
double __dec2num(const decimal* d) {
if (d->sig.length <= 0) {
return copysign(0.0, d->sign == 0 ? 1.0 : -1.0);
}
switch (d->sig.text[0]) {
case '0':
return copysign(0.0, d->sign == 0 ? 1.0 : -1.0);
case 'I':
return copysign((double)INFINITY, d->sign == 0 ? 1.0 : -1.0);
case 'N': {
double result;
d_int* ll = (d_int*)&result;
*ll = 0x7FF0000000000000;
if (d->sign)
*ll |= 0x8000000000000000;
*ll |= 0x8000000000000;
return result;
}
}
{
static double pow_10[8] = {1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8};
decimal dec = *d;
unsigned char* i = dec.sig.text;
unsigned char* e = i + dec.sig.length;
double first_guess;
int exponent;
for (; i < e; ++i)
*i -= '0';
dec.exp += dec.sig.length - 1;
exponent = dec.exp;
{
decimal max;
__str2dec(&max, "179769313486231580793728714053034151", 308);
if (__less_dec(&max, &dec)) {
return copysign((double)INFINITY, d->sign == 0 ? 1.0 : -1.0);
}
}
i = dec.sig.text;
first_guess = *i++;
while (i < e) {
unsigned long ival = 0;
int j;
double temp1, temp2;
int ndig = (int)(e - i) % 8;
if (ndig == 0)
ndig = 8;
for (j = 0; j < ndig; ++j, ++i) {
ival = ival * 10 + *i;
}
temp1 = first_guess * pow_10[ndig - 1];
temp2 = temp1 + ival;
if (ival != 0 && temp1 == temp2)
break;
first_guess = temp2;
exponent -= ndig;
}
if (exponent < 0) {
first_guess /= pow(5.0, -exponent);
} else {
first_guess *= pow(5.0, exponent);
}
first_guess = ldexp(first_guess, exponent);
if (fpclassify(first_guess) == 2) {
first_guess = LDBL_MAX;
}
{
decimal feedback1, feedback2, difflow, diffhigh;
double next_guess;
d_int* ull = (d_int*)&next_guess;
int guessed_low = 0;
__num2dec_internal(&feedback1, first_guess);
if (__equals_dec(&feedback1, &dec)) {
goto done;
}
if (__less_dec(&feedback1, &dec)) {
guessed_low = 1;
}
next_guess = first_guess;
while (1) {
if (guessed_low) {
++*ull;
if (fpclassify(next_guess) == 2) {
goto done;
}
} else {
--*ull;
}
__num2dec_internal(&feedback2, next_guess);
if (guessed_low && !__less_dec(&feedback2, &dec)) {
break;
} else if (!guessed_low && !__less_dec(&dec, &feedback2)) {
difflow = feedback1;
feedback1 = feedback2;
feedback2 = difflow;
{
double temp = first_guess;
first_guess = next_guess;
next_guess = temp;
}
break;
}
feedback1 = feedback2;
first_guess = next_guess;
}
__minus_dec(&difflow, &dec, &feedback1);
__minus_dec(&diffhigh, &feedback2, &dec);
if (__equals_dec(&difflow, &diffhigh)) {
if (*(unsigned long long*)&first_guess & 1) {
first_guess = next_guess;
}
} else if (!__less_dec(&difflow, &diffhigh)) {
first_guess = next_guess;
}
}
done:
if (dec.sign) {
first_guess = -first_guess;
}
return first_guess;
}
}

View File

@@ -93,7 +93,11 @@ namespace nw4r {
#else
void SetTranslate(const math::VEC3& translate) { mTranslate = translate; }
#endif
#ifdef IPL_SDMEMORY_SET_TRANSLATE_OUT_OF_LINE
void SetTranslate(const math::VEC2& translate);
#else
void SetTranslate(const math::VEC2& translate) { SetTranslate(math::VEC3(translate.x, translate.y, 0.0f)); }
#endif
const math::VEC3& GetRotate() const { return mRotate; }
void SetRotate(const math::VEC3& rotate) { mRotate = rotate; }

View File

@@ -11,7 +11,11 @@ namespace nw4r {
namespace snd {
class SoundHandle : private ut::NonCopyable {
public:
#ifdef IPL_SOUND_MATCHING
SoundHandle() NO_INLINE;
#else
SoundHandle() NO_INLINE : mSound(NULL) {}
#endif
~SoundHandle() { DetachSound(); }
void detail_AttachSound(detail::BasicSound* sound);

View File

@@ -31,7 +31,14 @@ namespace nw4r {
ut::detail::AutoLock<OSMutex> lock(mMutex);
return mFrameHeap.SaveState();
}
#ifdef IPL_SOUND_MATCHING
void LoadState(int id) {
ut::detail::AutoLock<OSMutex> lock(mMutex);
mFrameHeap.LoadState(id);
}
#else
void LoadState(int id);
#endif
bool IsValid() { return mFrameHeap.IsValid(); }

View File

@@ -14,9 +14,13 @@ namespace nw4r {
#else
Rect() : left(), top(), right(), bottom() {}
#endif
#ifdef IPL_SETTING_RECT_OUT_OF_LINE
Rect(f32 l, f32 t, f32 r, f32 b);
#else
Rect(f32 l, f32 t, f32 r, f32 b) : left(l), top(t), right(r), bottom(b) {}
#endif
#ifndef IPL_CONTROLLER_TRIVIAL_RECT_DTOR
#if !defined(IPL_CONTROLLER_TRIVIAL_RECT_DTOR) && !defined(IPL_MEMORYCARD_BASE_CPP)
~Rect() {}
#endif

View File

@@ -37,7 +37,7 @@ namespace nw4r {
} // namespace detail
template <typename TDerived, typename TBase>
#ifdef IPL_BOARD_OBJECT_EXTERNAL_DYNAMIC_CAST
#if defined(IPL_BOARD_OBJECT_EXTERNAL_DYNAMIC_CAST) || defined(IPL_MEMORYCARD_BASE_CPP)
TDerived DynamicCast(TBase* pPtr);
#else
inline TDerived DynamicCast(TBase* pPtr) {

View File

@@ -106,7 +106,15 @@ typedef struct {
u16 outputHeight; // 0x2A
u32 convWidth; // 0x2C
u32 convHeight; // 0x30
#ifdef TMC_JPEG_PLANAR_OUTPUT
u32 chromaWidth;
u32 chromaHeight;
u8* pLumaBuffer;
u8* pCbBuffer;
u8* pCrBuffer;
#else
u8 unk_0x34[0x14]; // 0x34
#endif
void* pTexBuffer; // 0x48
u8 unk_0x4C[0x67C];
TMCCJPEGDecWork* pWorkBuf; // 0x6C8

View File

@@ -1,13 +1,118 @@
#include <string.h>
#include <tmc_jpeg_internal.h>
typedef struct {
u16 bitLength;
u16 symbol;
} TMCHuffmanEntry;
static TMCHuffmanEntry readHuffmanEntry(const TMCHuffmanEntry* entries, u32 index) {
return entries[index];
}
static TMCHuffmanEntry readHuffmanLimit(const TMCHuffmanEntry* entries) {
TMCHuffmanEntry limit;
limit.bitLength = entries->bitLength;
limit.symbol = entries->symbol;
return limit;
}
static inline s32 decodeLongHuffman(s32 bitCount, const TMCHuffmanEntry* table, const u8* symbols, TMCCJPEGDecWork* work) {
u32 bitData;
u32 code;
u32 length;
const TMCHuffmanEntry* entry;
if (bitCount <= 17) {
s32 result = TMCJPEGDEC_load_buff(work);
if (result < 0) {
return result;
}
}
bitCount = work->bitCount;
bitData = work->bitBuf;
bitCount -= 9;
code = (bitData >> bitCount) & 0x1FF;
work->bitCount = bitCount;
length = 9;
entry = table + 9;
goto read_entry;
while (1) {
length++;
entry++;
if (length > 16) {
return TMCC_ERROR_OVERFLOW;
}
bitCount = work->bitCount;
code <<= 1;
bitData = work->bitBuf;
bitCount--;
work->bitCount = bitCount;
code |= (bitData >> bitCount) & 1;
read_entry:
{
TMCHuffmanEntry decoded = readHuffmanLimit(entry);
if (code > (u32)decoded.bitLength) {
continue;
}
code = code - entry->bitLength + entry->symbol;
return symbols[code & 0xFF];
}
}
}
static inline s32 decodeACHuffman(s32 bitCount, const TMCHuffmanEntry* entry, const u8* symbols, TMCCJPEGDecWork* work) {
u32 bitData;
u32 code;
u32 length;
if (bitCount <= 17) {
s32 result = TMCJPEGDEC_load_buff(work);
if (result < 0) {
return result;
}
}
bitCount = work->bitCount;
bitData = work->bitBuf;
bitCount -= 9;
code = (bitData >> bitCount) & 0x1FF;
work->bitCount = bitCount;
length = 9;
entry += 9;
goto read_entry;
while (1) {
length++;
entry++;
if (length > 16) {
return TMCC_ERROR_OVERFLOW;
}
bitCount = work->bitCount;
code <<= 1;
bitData = work->bitBuf;
bitCount--;
work->bitCount = bitCount;
code |= (bitData >> bitCount) & 1;
read_entry:
{
TMCHuffmanEntry decoded = readHuffmanLimit(entry);
if (code > (u32)decoded.bitLength) {
continue;
}
code = code - entry->bitLength + entry->symbol;
return symbols[code & 0xFF];
}
}
}
s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_ptr, TMCCJPEGDecWork* work) {
volatile u32 ac_comb;
u16* ac_fast;
TMCHuffmanEntry dcEntry;
TMCHuffmanEntry acEntry;
const TMCHuffmanEntry* ac_fast;
u8* huff_sym;
u32* huff_tbl;
s32 bit_pos;
u32 bit_data;
u16* dc_fast;
const TMCHuffmanEntry* dc_fast;
s32 r;
s32 blk0;
s32 idx;
@@ -19,29 +124,23 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
const u8* zztbl;
bit_pos = work->bitCount;
dc_fast = work->pDCFast;
dc_fast = (const TMCHuffmanEntry*)work->pDCFast;
if (bit_pos <= 8) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
bit_pos = work->bitCount;
}
bit_pos = work->bitCount;
bit_data = work->bitBuf;
tmp = bit_pos - 8;
tmp = ((bit_data >> tmp) & 0xFF) << 2;
{
u16* dc_entry = (u16*)((u8*)dc_fast + tmp);
r = dc_entry[0];
extra = dc_entry[1];
}
{
volatile u32 dc_comb;
*(u16*)&dc_comb = r;
*((u16*)&dc_comb + 1) = extra;
dcEntry = readHuffmanEntry(dc_fast, tmp >> 2);
r = dcEntry.bitLength;
extra = dcEntry.symbol;
}
if (r != 0) {
@@ -49,74 +148,9 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
work->bitCount = bit_pos;
r = extra;
} else {
u32 code;
unsigned int i;
u16* entry;
s32 thresh;
s32 offs;
huff_sym = work->pDCHuffSym;
huff_tbl = work->pDCHuffTbl;
if (bit_pos <= 17) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
}
bit_pos = work->bitCount;
bit_data = work->bitBuf;
bit_pos -= 9;
code = (bit_data >> bit_pos) & 0x1FF;
work->bitCount = bit_pos;
i = 9;
entry = (u16*)((u8*)huff_tbl + 0x24);
goto dc_entry;
while (1) {
i++;
entry += 2;
if (i > 16) {
r = TMCC_ERROR_OVERFLOW;
goto dc_end;
}
bit_pos = work->bitCount;
code <<= 1;
bit_data = work->bitBuf;
bit_pos--;
work->bitCount = bit_pos;
code |= (bit_data >> bit_pos) & 1;
dc_entry:
thresh = entry[0];
offs = entry[1];
{
volatile u16 p[2];
p[0] = thresh;
p[1] = offs;
tmp = *(u32*)p;
}
{
volatile u32 cw;
cw = tmp;
thresh = *(u16*)&cw;
}
if (code > (u32)thresh) {
continue;
}
code = code - entry[0] + offs;
r = huff_sym[code & 0xFF];
break;
}
dc_end:
r = decodeLongHuffman(bit_pos, (const TMCHuffmanEntry*)huff_tbl, huff_sym, work);
if (r < 0) {
return r;
}
@@ -130,203 +164,120 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
if (load_ret < 0) {
return load_ret;
}
bit_pos = work->bitCount;
}
bit_pos = work->bitCount;
bit_data = work->bitBuf;
tmp = 1 << r;
extra = tmp - 1;
bit_pos -= r;
work->bitCount = bit_pos;
extra = extra & (bit_data >> bit_pos);
if ((s32)tmp >> 1 <= extra) {
extra = extra;
} else {
extra = extra - (tmp - 1);
if (((s32)tmp >> 1) > extra) {
extra -= tmp - 1;
}
dc_predict_row_ptr[0] += extra;
}
*block = dc_predict_row_ptr[0] * blk0;
ac_fast = work->pACFast;
huff_tbl = work->pACHuffTbl;
huff_sym = work->pACHuffSym;
memset((u8*)block + 4, 0, 0xFC);
bit_pos = work->bitCount;
idx = 1;
if (bit_pos <= 8) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0)
return r;
}
bit_pos = work->bitCount;
zztbl = TMCJPEGDEC_Zigzag_data;
bit_data = work->bitBuf;
t = bit_pos - 8;
{
u32 tbl_idx = ((bit_data >> t) & 0xFF) << 2;
s32 thresh_val = ac_fast[tbl_idx >> 1];
s32 offs_val = *(u16*)((u8*)ac_fast + tbl_idx + 2);
*(u16*)&ac_comb = thresh_val;
*((u16*)&ac_comb + 1) = offs_val;
}
ac_fast = (const TMCHuffmanEntry*)work->pACFast;
huff_tbl = work->pACHuffTbl;
huff_sym = work->pACHuffSym;
while (idx < 64) {
s32 ac_thresh = *(u16*)&ac_comb;
if (ac_thresh != 0) {
bit_pos = work->bitCount;
bit_pos -= ac_thresh;
work->bitCount = bit_pos;
r = *((u16*)&ac_comb + 1);
} else {
u32 code;
unsigned int i;
u16* entry;
s32 thresh;
s32 offs;
memset(block + 1, 0, 0xFC);
bit_pos = work->bitCount;
if (bit_pos <= 17) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
bit_pos = work->bitCount;
}
bit_data = work->bitBuf;
bit_pos -= 9;
code = (bit_data >> bit_pos) & 0x1FF;
work->bitCount = bit_pos;
i = 9;
entry = (u16*)((u8*)work->pACHuffTbl + 0x24);
goto ac_entry_huff;
while (1) {
i++;
entry += 2;
if (i > 16) {
r = TMCC_ERROR_OVERFLOW;
goto ac_end;
}
bit_pos = work->bitCount;
code <<= 1;
bit_data = work->bitBuf;
bit_pos--;
work->bitCount = bit_pos;
code |= (bit_data >> bit_pos) & 1;
ac_entry_huff:
thresh = entry[0];
offs = entry[1];
{
volatile u16 p[2];
p[0] = thresh;
p[1] = offs;
tmp = *(u32*)p;
}
{
volatile u32 cw;
cw = tmp;
thresh = *(u16*)&cw;
}
if (code > (u32)thresh) {
continue;
}
code = code - entry[0] + offs;
r = huff_sym[code & 0xFF];
break;
}
ac_end:
if (r < 0) {
bit_pos = work->bitCount;
idx = 1;
if (bit_pos <= 8) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0)
return r;
}
}
t = r & 0x0F;
if (t != 0) {
r >>= 4;
idx += r;
bit_pos = work->bitCount;
zztbl = TMCJPEGDEC_Zigzag_data;
bit_data = work->bitBuf;
t = bit_pos - 8;
acEntry = readHuffmanEntry(ac_fast, (bit_data >> t) & 0xFF);
if (idx >= 64) {
return TMCC_ERROR_OVERFLOW;
}
zz = zztbl[idx];
bit_pos = work->bitCount;
if (bit_pos <= t + 8) {
r = TMCJPEGDEC_load_buff(work);
do {
s32 ac_thresh = acEntry.bitLength;
if (ac_thresh != 0) {
bit_pos = work->bitCount;
bit_pos -= ac_thresh;
work->bitCount = bit_pos;
r = acEntry.symbol;
} else {
bit_pos = work->bitCount;
r = decodeACHuffman(bit_pos, (const TMCHuffmanEntry*)huff_tbl, huff_sym, work);
if (r < 0) {
return r;
}
}
t = r & 0x0F;
if (t != 0) {
r >>= 4;
idx += r;
if (idx >= 64) {
return TMCC_ERROR_OVERFLOW;
}
zz = zztbl[idx];
bit_pos = work->bitCount;
if (bit_pos <= t + 8) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
}
bit_pos = work->bitCount;
}
tmp = 1 << t;
bit_data = work->bitBuf;
extra = tmp - 1;
bit_pos -= t;
work->bitCount = bit_pos;
t = bit_pos - 8;
{
u32 next_tbl = ((bit_data >> t) & 0xFF) << 2;
s32 next_th = ac_fast[next_tbl >> 1];
s32 next_of = *(u16*)((u8*)ac_fast + next_tbl + 2);
tmp = 1 << t;
bit_data = work->bitBuf;
extra = tmp - 1;
bit_pos -= t;
work->bitCount = bit_pos;
t = bit_pos - 8;
extra = extra & (bit_data >> bit_pos);
*(u16*)&ac_comb = next_th;
*((u16*)&ac_comb + 1) = next_of;
}
q = ((s32*)conv_row_ptr)[(u8)zz];
acEntry = readHuffmanEntry(ac_fast, (bit_data >> t) & 0xFF);
if ((s32)tmp >> 1 <= extra) {
extra = extra;
} else {
extra = extra - (tmp - 1);
}
q = ((s32*)conv_row_ptr)[zz];
block[zz] = extra * q;
idx++;
} else {
if (r == 0) {
break;
}
bit_pos = work->bitCount;
if (bit_pos <= 8) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
if (((s32)tmp >> 1) > extra) {
extra -= tmp - 1;
}
}
bit_data = work->bitBuf;
bit_pos = work->bitCount;
t = bit_pos - 8;
tmp = ((bit_data >> t) & 0xFF) << 2;
{
s32 next_thresh = ac_fast[tmp >> 1];
s32 next_offs = *(u16*)((u8*)ac_fast + tmp + 2);
*(u16*)&ac_comb = next_thresh;
*((u16*)&ac_comb + 1) = next_offs;
}
idx += 16;
block[(u8)zz] = extra * q;
idx++;
} else {
if (r == 0) {
break;
}
bit_pos = work->bitCount;
if (bit_pos <= 8) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
}
bit_data = work->bitBuf;
bit_pos = work->bitCount;
t = bit_pos - 8;
tmp = ((bit_data >> t) & 0xFF) << 2;
acEntry = readHuffmanEntry(ac_fast, tmp >> 2);
idx += 16;
}
} while (idx < 64);
if (idx > 64) {
return TMCC_ERROR_OVERFLOW;
}
}
if (idx > 64) {
return TMCC_ERROR_OVERFLOW;
idx--;
return TMCJPEGDEC_Zigzag_loop[idx];
}
idx--;
return TMCJPEGDEC_Zigzag_loop[idx];
}

View File

@@ -1,26 +1,28 @@
#include <string.h>
#include <tmc_jpeg_internal.h>
static u8 clampU8(s32 v) {
static s32 clampU8(s32 v) {
s32 ok;
ok = 0;
if (v < 256 && v > -1) {
ok = 1;
}
return (ok) ? v : ((v < 0) ? 0 : 255);
return ok ? v : (v < 0 ? 0 : 255);
}
static s8 clampS8(s32 v) {
return (v < 128 && v > -129) ? (s8)v : (v > 0) ? 127 : -128;
static s32 clampS8(s32 v) {
s32 inRange = 0;
if (v < 128 && v > -129) {
inRange = 1;
}
return inRange ? v : (v > 0) ? 127 : -128;
}
static s32 scalingClampU8(s32 val) {
s32 result = 0;
if (val >> 19 != 0)
result &= ~(val >> 31) & 0xFF;
else
result = (val >> 11);
return result;
static s32 scalingClampU8(s32 value) {
if ((value >> 19) == 0) {
return value >> 11;
}
return value < 0 ? 0 : 255;
}
void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {
@@ -29,17 +31,39 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
s32 done;
s32 iter;
s32 i;
s32 b1, b2, b3, b4, b5, b6, b7;
s32 v, e, a, d, n, o, p, q, t, u, w, x, y;
s32 x_factor, z_factor, m_part, p_part;
s32 r, z, m;
s32 e;
s32 b2;
s32 b3;
s32 b4;
s32 b5;
s32 b6;
s32 b7;
s32 v;
s32 m;
s32 a;
s32 d;
s32 z;
s32 o;
s32 p;
s32 p_part;
s32 t;
s32 u;
s32 r;
s32 n;
s32 y;
s32 x_factor;
s32 z_factor;
s32 m_part;
s32 q;
s32 w;
s32 x;
s32 b1;
r = (zigzag >> 4) * 8;
iter = (u32)(r + 7) >> 3;
dst = tmp;
done = 0;
if (r > 0) {
for (; iter > 0; iter--) {
{
for (; done < r; done += 8) {
u32 ac;
b4 = block[4];
b6 = block[6];
@@ -49,7 +73,13 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
b5 = block[5];
b3 = block[3];
ac = (u32)b4 | (u32)b6 | (u32)b2 | (u32)b1 | (u32)b7 | (u32)b5 | (u32)b3;
ac = (u32)b4;
ac |= (u32)b6;
ac |= (u32)b2;
ac |= (u32)b1;
ac |= (u32)b7;
ac |= (u32)b5;
ac |= (u32)b3;
if (ac == 0) {
s32 val = block[0];
dst[7] = val;
@@ -61,23 +91,39 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
dst[1] = val;
dst[0] = val;
} else {
t = (b2 - b6) * 0xB5 >> 8;
a = block[0] - b4;
d = block[0] + b4;
u = t + b6 + b2;
v = a + t;
e = a - t;
w = d + u;
x_factor = (b1 + b7) - (b5 + b3);
y = d - u;
z_factor = (b5 - b3) + (b1 - b7);
m_part = (b1 - b7) * 0x14E >> 8;
p_part = (b5 - b3) * 0x8B >> 8;
s32 oddLowSum;
s32 oddHighSum;
s32 dcValue;
t = b2 - b6;
oddLowSum = b5 + b3;
b5 = b5 - b3;
oddHighSum = b1 + b7;
b1 = b1 - b7;
u = b6 + b2;
t = t * 0xB5 >> 8;
x_factor = oddHighSum - oddLowSum;
z_factor = b5 + b1;
dcValue = block[0];
a = dcValue - b4;
x = x_factor * 0xB5 >> 8;
d = dcValue + b4;
u = t + u;
v = a + t;
z = z_factor * 0x62 >> 8;
w = d + u;
y = d - u;
m_part = b1 * 0x14E >> 8;
e = a - t;
m = m_part - z;
n = b1 + b7 + b5 + b3 + m;
oddLowSum += m;
n = oddHighSum + oddLowSum;
o = x + m;
dst[0] = w + n;
p_part = b5 * 0x8B;
dst[7] = w - n;
p_part >>= 8;
dst[1] = v + o;
p = z + p_part;
q = p + x;
dst[6] = v - o;
@@ -88,12 +134,11 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
}
block += 8;
dst += 8;
done += 8;
}
}
dst = tmp + done;
for (; done < 0x38; done += 8) {
for (; done <= 0x38; done += 8) {
memset(dst, 0, 0x20);
dst += 8;
}
@@ -114,7 +159,13 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
b5 = dst[0x28];
b3 = dst[0x18];
ac = (u32)b4 | (u32)b6 | (u32)b2 | (u32)b1 | (u32)b7 | (u32)b5 | (u32)b3;
ac = (u32)b4;
ac |= (u32)b6;
ac |= (u32)b2;
ac |= (u32)b1;
ac |= (u32)b7;
ac |= (u32)b5;
ac |= (u32)b3;
out = conv_row_ptr + i;
if (ac == 0) {
u8 val = clampU8((*dst >> 11) + 0x80);
@@ -127,24 +178,37 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
out[pitch] = val;
out[0] = val;
} else {
t = (b2 - b6) * 0xB5 >> 8;
a = *dst - b4;
d = *dst + b4;
u = t + b6 + b2;
v = a + t;
e = a - t;
s32 oddLowSum;
s32 oddHighSum;
s32 dcValue;
t = b2 - b6;
oddLowSum = b5 + b3;
b5 = b5 - b3;
oddHighSum = b1 + b7;
b1 = b1 - b7;
u = b6 + b2;
b2 = t * 0xB5 >> 8;
x_factor = oddHighSum - oddLowSum;
z_factor = b5 + b1;
dcValue = *dst + 0x40000;
a = dcValue - b4;
x = x_factor * 0xB5 >> 8;
d = dcValue + b4;
u = b2 + u;
v = a + b2;
z_factor = z_factor * 0x62 >> 8;
w = d + u;
x = ((b1 + b7) - (b5 + b3)) * 0xB5 >> 8;
y = d - u;
z_factor = ((b5 - b3) + (b1 - b7)) * 0x62 >> 8;
m_part = ((b1 - b7) * 0x14E >> 8) - z_factor;
n = b1 + b7 + b5 + b3 + m_part;
m_part = b1 * 0x14E >> 8;
e = a - b2;
m_part = m_part - z_factor;
oddLowSum += m_part;
n = oddHighSum + oddLowSum;
o = x + m_part;
p = z_factor + ((b5 - b3) * 0x8B >> 8);
p_part = b5 * 0x8B >> 8;
p = z_factor + p_part;
q = p + x;
out[0] = scalingClampU8(w + n);
out[r] = scalingClampU8(w - n);
out[pitch] = scalingClampU8(v + o);
@@ -163,11 +227,34 @@ void TMCJPEGDEC_IdctBlock_Col(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigza
s32* dst;
s32 done;
s32 iter;
s32 i;
s32 b1, b2, b3, b4, b5, b6, b7;
s32 v, e, a, d, m, n, o, p, q, t, u, w, x, y, z;
s32 x_factor, z_factor, m_part, p_part;
s32 d;
s32 b1;
s32 b2;
s32 b3;
s32 b4;
s32 b5;
s32 b6;
s32 b7;
s32 v;
s32 r;
s32 a;
s32 i;
s32 m;
s32 n;
s32 o;
s32 x;
s32 q;
s32 y;
s32 u;
s32 w;
s32 p;
s32 t;
s32 z;
s32 x_factor;
s32 z_factor;
s32 m_part;
s32 p_part;
s32 e;
if (zigzag == 0x11) {
s32 val;
@@ -181,90 +268,42 @@ void TMCJPEGDEC_IdctBlock_Col(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigza
goto mode_gt_2;
}
{
s32 inner;
dst = tmp;
done = 0;
for (; done < r; done += 8) {
s32 dcValue;
s32 oddCoefficient;
dst = tmp;
done = 0;
iter = (r + 7) >> 3;
if (r > 0) {
inner = (r + 7) >> 4;
done = iter << 3;
if (inner != 0) {
for (; inner > 0; inner--) {
t = block[1] * 0xB5 >> 8;
v = block[1] * 0x62 >> 8;
u = v + t;
z = (block[1] * 0x14E >> 8) - v;
m = block[1] + z;
n = t + z;
b1 = block[0] + m;
dst[0] = b1;
dst[7] = block[0] - m;
dst[1] = block[0] + n;
dst[6] = block[0] - n;
dst[2] = block[0] + u;
dst[5] = block[0] - u;
dst[3] = block[0] + v;
dst[4] = block[0] - v;
t = block[9] * 0xB5 >> 8;
v = block[9] * 0x62 >> 8;
u = v + t;
z = (block[9] * 0x14E >> 8) - v;
m = block[9] + z;
n = t + z;
b2 = block[8] + m;
dst[8] = b2;
dst[15] = block[8] - m;
dst[9] = block[8] + n;
dst[14] = block[8] - n;
dst[10] = block[8] + u;
dst[13] = block[8] - u;
dst[11] = block[8] + v;
dst[12] = block[8] - v;
dst += 0x10;
block += 0x10;
}
iter = iter & 1;
if (iter == 0) {
goto zero_fill;
}
}
for (; iter > 0; iter--) {
t = block[1] * 0xB5 >> 8;
v = block[1] * 0x62 >> 8;
u = v + t;
z = (block[1] * 0x14E >> 8) - v;
m = block[1] + z;
n = t + z;
b1 = block[0] + m;
dst[0] = b1;
dst[7] = block[0] - m;
dst[1] = block[0] + n;
dst[6] = block[0] - n;
dst[2] = block[0] + u;
dst[5] = block[0] - u;
dst[3] = block[0] + v;
dst[4] = block[0] - v;
dst += 8;
block += 8;
}
}
zero_fill:
dst = tmp + done;
for (; done < 0x39; done += 8) {
memset(dst, 0, 0x20);
dst += 8;
}
oddCoefficient = block[1];
dcValue = block[0];
t = oddCoefficient * 0xB5 >> 8;
v = oddCoefficient * 0x62 >> 8;
u = v + t;
z = (oddCoefficient * 0x14E >> 8) - v;
m = oddCoefficient + z;
n = t + z;
dst[0] = dcValue + m;
dst[7] = dcValue - m;
dst[1] = dcValue + n;
dst[6] = dcValue - n;
dst[2] = dcValue + u;
dst[5] = dcValue - u;
dst[3] = dcValue + v;
dst[4] = dcValue - v;
dst += 8;
block += 8;
}
dst = tmp + done;
for (; done <= 0x38; done += 8) {
memset(dst, 0, 0x20);
dst += 8;
}
goto epilogue;
mode_gt_2:
dst = tmp;
done = 0;
if (r > 0) {
for (iter = (r + 7) >> 3; iter > 0; iter--) {
for (; done < r; done += 8) {
u32 ac;
b4 = block[4];
b6 = block[6];
@@ -293,23 +332,41 @@ mode_gt_2:
dst[1] = val;
dst[0] = val;
} else {
t = (b2 - b6) * 0xB5 >> 8;
a = block[0] - b4;
d = block[0] + b4;
u = t + b6 + b2;
v = a + t;
e = a - t;
w = d + u;
x_factor = (b1 + b7) - (b5 + b3);
y = d - u;
z_factor = (b5 - b3) + (b1 - b7);
m_part = (b1 - b7) * 0x14E >> 8;
p_part = (b5 - b3) * 0x8B >> 8;
s32 oddLowSum;
s32 oddLowDifference;
s32 oddHighSum;
s32 oddHighDifference;
s32 dcValue;
t = b2 - b6;
oddLowSum = b5 + b3;
oddLowDifference = b5 - b3;
oddHighSum = b1 + b7;
oddHighDifference = b1 - b7;
u = b6 + b2;
t = t * 0xB5 >> 8;
x_factor = oddHighSum - oddLowSum;
z_factor = oddLowDifference + oddHighDifference;
dcValue = block[0];
a = dcValue - b4;
x = x_factor * 0xB5 >> 8;
d = dcValue + b4;
u = t + u;
v = a + t;
z = z_factor * 0x62 >> 8;
w = d + u;
y = d - u;
m_part = oddHighDifference * 0x14E >> 8;
e = a - t;
m = m_part - z;
n = b1 + b7 + b5 + b3 + m;
oddLowSum += m;
n = oddHighSum + oddLowSum;
o = x + m;
dst[0] = w + n;
p_part = oddLowDifference * 0x8B;
dst[7] = w - n;
p_part >>= 8;
dst[1] = v + o;
p = z + p_part;
q = p + x;
dst[6] = v - o;
@@ -320,12 +377,10 @@ mode_gt_2:
}
block += 8;
dst += 8;
done += 8;
}
}
dst = tmp + done;
for (; done < 0x39; done += 8) {
for (; done <= 0x38; done += 8) {
memset(dst, 0, 0x20);
dst += 8;
}
@@ -335,7 +390,9 @@ epilogue:
dst = tmp + 7;
for (iter = 8, i = 7; iter > 0; iter--, i--) {
u32 ac;
u8* output;
b4 = dst[0x20];
output = conv_row_ptr + i;
b6 = dst[0x30];
b2 = dst[0x10];
b1 = dst[8];
@@ -353,40 +410,56 @@ epilogue:
if (ac == 0) {
s32 val;
val = clampS8(*dst >> 11);
conv_row_ptr[i + 56] = (u8)val;
conv_row_ptr[i + 48] = (u8)val;
conv_row_ptr[i + 40] = (u8)val;
conv_row_ptr[i + 32] = (u8)val;
conv_row_ptr[i + 24] = (u8)val;
conv_row_ptr[i + 16] = (u8)val;
conv_row_ptr[i + 8] = (u8)val;
conv_row_ptr[i] = (u8)val;
output[56] = (u8)val;
output[48] = (u8)val;
output[40] = (u8)val;
output[32] = (u8)val;
output[24] = (u8)val;
output[16] = (u8)val;
output[8] = (u8)val;
output[0] = (u8)val;
} else {
t = (b2 - b6) * 0xB5 >> 8;
a = *dst - b4;
d = *dst + b4;
u = t + b6 + b2;
s32 oddLowSum;
s32 oddLowDifference;
s32 oddHighSum;
s32 oddHighDifference;
s32 dcValue;
t = b2 - b6;
oddLowSum = b5 + b3;
oddLowDifference = b5 - b3;
oddHighSum = b1 + b7;
oddHighDifference = b1 - b7;
u = b6 + b2;
t = t * 0xB5 >> 8;
x_factor = oddHighSum - oddLowSum;
z_factor = oddLowDifference + oddHighDifference;
dcValue = *dst;
a = dcValue - b4;
x = x_factor * 0xB5 >> 8;
d = dcValue + b4;
u = t + u;
v = a + t;
e = a - t;
z = z_factor * 0x62 >> 8;
w = d + u;
x = ((b1 + b7) - (b5 + b3)) * 0xB5 >> 8;
y = d - u;
z = ((b5 - b3) + (b1 - b7)) * 0x62 >> 8;
m = ((b1 - b7) * 0x14E >> 8) - z;
n = b1 + b7 + b5 + b3 + m;
m_part = oddHighDifference * 0x14E >> 8;
e = a - t;
m = m_part - z;
oddLowSum += m;
n = oddHighSum + oddLowSum;
o = x + m;
p = z + ((b5 - b3) * 0x8B >> 8);
p_part = oddLowDifference * 0x8B >> 8;
p = z + p_part;
q = p + x;
conv_row_ptr[i] = (u8)clampS8((w + n) >> 11);
conv_row_ptr[i + 56] = (u8)clampS8((w - n) >> 11);
conv_row_ptr[i + 8] = (u8)clampS8((v + o) >> 11);
conv_row_ptr[i + 48] = (u8)clampS8((v - o) >> 11);
conv_row_ptr[i + 16] = (u8)clampS8((e + q) >> 11);
conv_row_ptr[i + 40] = (u8)clampS8((e - q) >> 11);
conv_row_ptr[i + 24] = (u8)clampS8((y + p) >> 11);
conv_row_ptr[i + 32] = (u8)clampS8((y - p) >> 11);
output[0] = (u8)clampS8((w + n) >> 11);
output[56] = (u8)clampS8((w - n) >> 11);
output[8] = (u8)clampS8((v + o) >> 11);
output[48] = (u8)clampS8((v - o) >> 11);
output[16] = (u8)clampS8((e + q) >> 11);
output[40] = (u8)clampS8((e - q) >> 11);
output[24] = (u8)clampS8((y + p) >> 11);
output[32] = (u8)clampS8((y - p) >> 11);
}
dst--;
}

View File

@@ -15,9 +15,16 @@ static u16 readU16(const u8* p, u16 byteOrder) {
return (u16)(raw >> 8 & 0xFF | (raw & 0xFF) << 8);
}
static u16 readExifU16(const u8* data, u16 byteOrder) {
u32 value = data[0] | data[1] << 8;
if (byteOrder == 0x4949) {
return (u16)value;
}
return (u16)(value >> 8 & 255 | (value & 255) << 8);
}
static u32 readU32(const u8* p, u16 byteOrder) {
u32 raw = p[0] | p[1] << 8;
raw = raw | p[3] << 24 | p[2] << 16;
u32 raw = p[1] << 8 | p[0] | p[2] << 16 | p[3] << 24;
if (byteOrder == 0x4949) {
return raw;
}
@@ -26,9 +33,9 @@ static u32 readU32(const u8* p, u16 byteOrder) {
s32 TMCCJPEGDecGetOffsetEXIF(u32* pOffset, u32* pSize, TMCCJPEGDecInitParam* pParam) {
TMCCJPEGDecWork* work;
u16 marker;
u32 dataSize;
u16 segSize;
u32 dataSize;
u16 marker;
s32 result;
u8 sig[4];
@@ -108,62 +115,26 @@ s32 TMCCJPEGDecGetOffsetEXIF(u32* pOffset, u32* pSize, TMCCJPEGDecInitParam* pPa
continue;
}
if (marker >= 0xFFD9) {
if (marker == 0xFFD9) {
switch (marker) {
case 0xFFC0:
case 0xFFC2:
case 0xFFC4:
case 0xFFDB:
case 0xFFDC:
case 0xFFDD:
case 0xFFFE:
result = TMCJPEGDEC_move_ptr(segSize, work);
if (result < 0) {
return result;
}
break;
case 0xFFDA:
return -2;
}
if (marker == 0xFFFE) {
result = TMCJPEGDEC_move_ptr(segSize, work);
if (result < 0) {
return result;
}
continue;
}
if (marker >= 0xFFDE)
case 0xFFD9:
return -2;
default:
return -0x2F;
if (marker >= 0xFFDB) {
result = TMCJPEGDEC_move_ptr(segSize, work);
if (result < 0) {
return result;
}
continue;
}
return -2;
}
if (marker >= 0xFFC2) {
if (marker == 0xFFC2) {
result = TMCJPEGDEC_move_ptr(segSize, work);
if (result < 0) {
return result;
}
continue;
}
if (marker == 0xFFC4) {
result = TMCJPEGDEC_move_ptr(segSize, work);
if (result < 0) {
return result;
}
continue;
}
return -0x2F;
}
if (marker == 0xFFC0) {
result = TMCJPEGDEC_move_ptr(segSize, work);
if (result < 0) {
return result;
}
continue;
}
return -0x2F;
}
}
@@ -271,114 +242,99 @@ _error:
}
static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData* pInfo) {
u32 ifd0Offset;
u32 ifd1Offset;
u32 exifIfdOffset;
u16 count;
u32 entriesSize;
u32 i;
const u8* p;
s32 sval;
u16 byteOrder;
u32 raw;
u32 ifdOffset;
const u8* entries;
u16 remaining;
u16 count;
s32 entriesSize;
u16 index;
pInfo->thumbnailData = (u8*)data;
pInfo->dataEnd = (u8*)data + size;
pInfo->nextIfdOffset = 0;
if (size < 8) {
return -161;
}
raw = data[0] | data[1] << 8;
byteOrder = raw;
byteOrder = data[0] | data[1] << 8;
if (byteOrder != 0x4D4D && byteOrder != 0x4949) {
return -161;
}
if (readU16(data + 2, byteOrder) != 0x002A) {
if (readExifU16(data + 2, byteOrder) != 42) {
return -161;
}
ifd0Offset = readU32(data + 4, byteOrder);
if (ifd0Offset > size) {
ifdOffset = readU32(data + 4, byteOrder);
if (size < ifdOffset) {
return -161;
}
sval = size - (u16)ifd0Offset;
if (sval < 2) {
return -161;
}
p = data + (u16)ifd0Offset;
count = readU16(p, byteOrder);
entriesSize = count * 12;
sval = (u32)(sval - 2);
if (sval < entriesSize) {
return -161;
}
p += 2;
for (i = 0; i < count; i++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, p);
p += 12;
}
sval -= entriesSize;
if (sval < 4) {
return -161;
}
ifd1Offset = readU32(p, byteOrder);
if (ifd1Offset != 0) {
if (ifd1Offset > size) {
{
entries = data + ifdOffset;
remaining = size - (u16)ifdOffset;
if (remaining < 2) {
return -161;
}
sval = size - (u16)ifd1Offset;
if (sval < 2) {
return -161;
}
p = data + (u16)ifd1Offset;
count = readU16(p, byteOrder);
count = readExifU16(entries, byteOrder);
entriesSize = count * 12;
sval = (u32)(sval - 2);
if (sval < entriesSize) {
entries += 2;
remaining -= 2;
if (remaining < entriesSize) {
return -161;
}
p += 2;
for (i = 0; i < count; i++) {
TMCJPEGDEC_IFD1_tag_parse(pInfo, byteOrder, p);
p += 12;
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, entries);
entries += 12;
}
remaining -= entriesSize;
if (remaining < 4) {
return -161;
}
ifdOffset = readU32(entries, byteOrder);
}
if (ifdOffset == 0) {
return 0;
}
if (size < ifdOffset) {
return -161;
}
{
entries = data + ifdOffset;
remaining = size - (u16)ifdOffset;
if (remaining < 2) {
return -161;
}
count = readExifU16(entries, byteOrder);
entriesSize = count * 12;
entries += 2;
remaining -= 2;
if (remaining < entriesSize) {
return -161;
}
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD1_tag_parse(pInfo, byteOrder, entries);
entries += 12;
}
}
exifIfdOffset = pInfo->nextIfdOffset;
if (exifIfdOffset == 0 || exifIfdOffset > size) {
ifdOffset = pInfo->nextIfdOffset;
if (size < ifdOffset) {
return -161;
}
sval = size - (u16)exifIfdOffset;
if (sval < 2) {
return -161;
{
entries = data + ifdOffset;
remaining = size - (u16)ifdOffset;
if (remaining < 2) {
return -161;
}
count = readExifU16(entries, byteOrder);
entriesSize = count * 12;
entries += 2;
remaining -= 2;
if (remaining < entriesSize) {
return -161;
}
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, entries);
entries += 12;
}
}
p = data + (u16)exifIfdOffset;
count = readU16(p, byteOrder);
entriesSize = count * 12;
sval = (u32)(sval - 2);
if (sval < entriesSize) {
return -161;
}
p += 2;
for (i = 0; i < count; i++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, p);
p += 12;
}
return 0;
}
@@ -391,8 +347,10 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
switch (tag) {
case 0x0103:
case 0x0111: {
return;
case 0x0111:
case 0x0201:
case 0x0202: {
break;
}
case 0x0112: {
pInfo->orientation = readU16(entry + 8, byteOrder);
@@ -401,18 +359,18 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
case 0x011A: {
u32 offset = readU32(entry + 8, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (p < pInfo->thumbnailData) {
if (pInfo->thumbnailData > p) {
return;
}
if (p + 4 > pInfo->dataEnd) {
if (p > pInfo->dataEnd - 4) {
return;
}
pInfo->xResNum = readU32(p, byteOrder);
p = (const u8*)(pInfo->thumbnailData + offset + 4);
if (p < pInfo->thumbnailData) {
if (pInfo->thumbnailData > p) {
return;
}
if (p + 4 > pInfo->dataEnd) {
if (p > pInfo->dataEnd - 4) {
return;
}
pInfo->xResDen = readU32(p, byteOrder);
@@ -421,18 +379,18 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
case 0x011B: {
u32 offset = readU32(entry + 8, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (p < pInfo->thumbnailData) {
if (pInfo->thumbnailData > p) {
return;
}
if (p + 4 > pInfo->dataEnd) {
if (p > pInfo->dataEnd - 4) {
return;
}
pInfo->yResNum = readU32(p, byteOrder);
p = (const u8*)(pInfo->thumbnailData + offset + 4);
if (p < pInfo->thumbnailData) {
if (pInfo->thumbnailData > p) {
return;
}
if (p + 4 > pInfo->dataEnd) {
if (p > pInfo->dataEnd - 4) {
return;
}
pInfo->yResDen = readU32(p, byteOrder);
@@ -444,19 +402,19 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
}
case 0x012D: {
u32 offset = readU32(entry + 8, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
u32 j;
u32 i;
for (j = 0; j < 3; j++) {
for (i = 0; i < 256; i++) {
if (p < pInfo->thumbnailData) {
return;
u32 channel;
u32 index;
for (channel = 0; channel < 3; channel++) {
for (index = 0; index < 256; index++) {
const u8* p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
break;
}
if (p + 2 > pInfo->dataEnd) {
return;
if (p > pInfo->dataEnd - 2) {
break;
}
pInfo->transferFunc[j][i] = readU16(p, byteOrder);
p += 2;
pInfo->transferFunc[channel][index] = readU16(p, byteOrder);
offset += 2;
}
}
return;
@@ -464,17 +422,18 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
case 0x0132: {
u32 offset = readU32(entry + 8, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (p < pInfo->thumbnailData) {
if (pInfo->thumbnailData > p) {
return;
}
if (p + 20 > pInfo->dataEnd) {
if (p > pInfo->dataEnd - 20) {
return;
}
*(u32*)(pInfo->dateTime + 0) = *(u32*)(p + 0);
*(u32*)(pInfo->dateTime + 4) = *(u32*)(p + 4);
*(u32*)(pInfo->dateTime + 8) = *(u32*)(p + 8);
*(u32*)(pInfo->dateTime + 12) = *(u32*)(p + 12);
*(u32*)(pInfo->dateTime + 16) = *(u32*)(p + 16);
{
u32 index;
for (index = 0; index < 20; index++) {
pInfo->dateTime[index] = p[index];
}
}
return;
}
case 0x0213: {
@@ -511,21 +470,19 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
case 0xA002: {
u32 offset = readU32(entry + 8, byteOrder);
if (type == 4) {
pInfo->pixelXDim = offset;
} else if (type == 3) {
if (type == 3) {
pInfo->pixelXDim = readU16(entry + 8, byteOrder);
} else if (type == 4) {
pInfo->pixelXDim = readU32(entry + 8, byteOrder);
}
return;
}
case 0xA003: {
u32 offset = readU32(entry + 8, byteOrder);
if (type == 4) {
pInfo->pixelYDim = offset;
} else if (type == 3) {
if (type == 3) {
pInfo->pixelYDim = readU16(entry + 8, byteOrder);
} else if (type == 4) {
pInfo->pixelYDim = readU32(entry + 8, byteOrder);
}
return;
}
@@ -538,52 +495,54 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
switch (tag) {
case 0x0132:
case 0x0111:
case 0x0112:
case 0x012D:
case 0x0213:
case 0x8769:
case 0x9000:
case 0x9101: {
return;
}
case 0x0103: {
pInfo->compressionIfd1 = readU16(entry + 8, byteOrder);
return;
case 0x9101:
case 0xA003: {
break;
}
case 0x011A: {
u32 offset = readU32(entry + 8, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (p < pInfo->thumbnailData) {
u32 offset;
const u8* p;
offset = readU32(entry + 8, byteOrder);
p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
}
if (p + 4 > pInfo->dataEnd) {
if (p > pInfo->dataEnd - 4) {
return;
}
pInfo->xResNumIfd1 = readU32(p, byteOrder);
p = (const u8*)(pInfo->thumbnailData + offset + 4);
if (p < pInfo->thumbnailData) {
if (pInfo->thumbnailData > p) {
return;
}
if (p + 4 > pInfo->dataEnd) {
if (p > pInfo->dataEnd - 4) {
return;
}
pInfo->xResDenIfd1 = readU32(p, byteOrder);
return;
}
case 0x011B: {
u32 offset = readU32(entry + 8, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (p < pInfo->thumbnailData) {
u32 offset;
const u8* p;
offset = readU32(entry + 8, byteOrder);
p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
}
if (p + 4 > pInfo->dataEnd) {
if (p > pInfo->dataEnd - 4) {
return;
}
pInfo->planarConfigIfd1 = readU32(p, byteOrder);
p = (const u8*)(pInfo->thumbnailData + offset + 4);
if (p < pInfo->thumbnailData) {
if (pInfo->thumbnailData > p) {
return;
}
if (p + 4 > pInfo->dataEnd) {
if (p > pInfo->dataEnd - 4) {
return;
}
pInfo->yResDenIfd1 = readU32(p, byteOrder);
@@ -593,6 +552,10 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
pInfo->resUnitIfd1 = readU16(entry + 8, byteOrder);
return;
}
case 0x0103: {
pInfo->compressionIfd1 = readU16(entry + 8, byteOrder);
return;
}
case 0x0201: {
pInfo->thumbnailOffset = readU32(entry + 8, byteOrder);
return;

View File

@@ -1411,131 +1411,22 @@ static s32 TMCJPEGDEC_parse_dht(s32 first, TMCCJPEGDecWork* work) {
}
#endif
#ifdef __MWERKS__
static asm s32 TMCJPEGDEC_parse_dqt(register TMCCJPEGDecWork* work) {
nofralloc
stwu r1, -0x130(r1)
mflr r0
lis r4, lbl_8161E080@ha
stw r0, 0x134(r1)
addi r4, r4, lbl_8161E080@l
li r0, 0x20
addi r6, r1, 0xc
stmw r24, 0x110(r1)
mr r30, r3
addi r5, r4, -4
mtctr r0
_parse_dqt_copy:
lwz r4, 4(r5)
lwzu r0, 8(r5)
stw r4, 4(r6)
stwu r0, 8(r6)
bdnz _parse_dqt_copy
addi r31, r3, 0x58
mr r4, r30
addi r3, r1, 0xa
bl TMCJPEGDEC_get_wbyte
cmpwi r3, 0
bge _parse_dqt_have_length
b _parse_dqt_return
_parse_dqt_have_length:
lhz r3, 0xa(r1)
addi r29, r1, 0x10
li r27, 1
lis r28, TMCJPEGDEC_Zigzag_data@ha
addi r0, r3, -2
sth r0, 0xa(r1)
_parse_dqt_table:
lhz r5, 0xa(r1)
mr r4, r30
addi r3, r1, 9
addi r0, r5, -0x41
sth r0, 0xa(r1)
bl TMCJPEGDEC_get_byte
cmpwi r3, 0
bge _parse_dqt_have_qt_info
b _parse_dqt_return
_parse_dqt_have_qt_info:
lbz r0, 9(r1)
cmplwi r0, 4
ble _parse_dqt_valid_qt_info
li r3, -0x41
b _parse_dqt_return
_parse_dqt_valid_qt_info:
add r3, r31, r0
addi r26, r28, TMCJPEGDEC_Zigzag_data@l
stb r27, 0x1790(r3)
li r25, 0
_parse_dqt_coeff:
lbz r24, 0(r26)
cmpwi r24, 0x3f
ble _parse_dqt_valid_coeff
li r3, -0x41
b _parse_dqt_return
_parse_dqt_valid_coeff:
mr r4, r30
addi r3, r1, 8
bl TMCJPEGDEC_get_byte
cmpwi r3, 0
bge _parse_dqt_have_coeff
b _parse_dqt_return
_parse_dqt_have_coeff:
slwi r4, r24, 2
lbz r3, 9(r1)
add r0, r4, r31
lbz r5, 8(r1)
lwzx r4, r29, r4
slwi r3, r3, 8
mullw. r4, r5, r4
stwx r4, r3, r0
bne _parse_dqt_nonzero
li r3, -0x41
b _parse_dqt_return
_parse_dqt_nonzero:
addi r25, r25, 1
addi r26, r26, 1
cmpwi r25, 0x40
blt _parse_dqt_coeff
lhz r0, 0xa(r1)
cmpwi r0, 0
bne _parse_dqt_table
li r3, 0
_parse_dqt_return:
lmw r24, 0x110(r1)
lwz r0, 0x134(r1)
mtlr r0
addi r1, r1, 0x130
blr
}
#else
static s32 TMCJPEGDEC_parse_dqt(TMCCJPEGDecWork* work) {
typedef struct {
u32 data[64];
} CopyBlock64;
u8* scaleInfo;
u32 tblCopy[65];
u32* tblPtr;
typedef struct { u32 coefficients[4][64]; } QuantizationTables;
QuantizationTables* scaleInfo;
u32 tblCopy[64];
u32* d;
u16 len;
s32 r;
d = tblCopy;
*(CopyBlock64*)(d + 1) = *(CopyBlock64*)lbl_8161E080;
*(CopyBlock64*)d = *(CopyBlock64*)lbl_8161E080;
scaleInfo = (u8*)work + 0x58;
scaleInfo = (QuantizationTables*)&work->scaleFlag;
r = TMCJPEGDEC_get_wbyte(&len, work);
if (r < 0) {
@@ -1543,8 +1434,6 @@ static s32 TMCJPEGDEC_parse_dqt(TMCCJPEGDecWork* work) {
}
len -= 2;
tblPtr = &tblCopy[1];
do {
u8 qtInfo;
const u8* zigPtr;
@@ -1563,11 +1452,10 @@ static s32 TMCJPEGDEC_parse_dqt(TMCCJPEGDecWork* work) {
return -0x41;
}
scaleInfo[qtInfo + 0x1790] = 1; // quantTblFlag[0..3]
((TMCUnknownInfo*)scaleInfo)->quantTblFlag[qtInfo] = 1;
zigPtr = TMCJPEGDEC_Zigzag_data;
for (zzIdx = 0; zzIdx < 64; zzIdx++) {
u32 tmp;
zz = *zigPtr;
if (zz > 0x3F) {
@@ -1579,9 +1467,8 @@ static s32 TMCJPEGDEC_parse_dqt(TMCCJPEGDecWork* work) {
return r;
}
tmp = (zz << 2) + ((u32)qtInfo << 8);
val = (u32)byte * tblPtr[zz];
*(u32*)(tmp + scaleInfo) = val;
val = (u32)byte * tblCopy[zz];
scaleInfo->coefficients[qtInfo][zz] = val;
if (val == 0) {
return -0x41;
}
@@ -1592,7 +1479,6 @@ static s32 TMCJPEGDEC_parse_dqt(TMCCJPEGDecWork* work) {
return 0;
}
#endif
#ifdef __MWERKS__
static asm s32 TMCJPEGDEC_parse_sof(register TMCCJPEGDecWork* work) {

View File

@@ -1,5 +1,874 @@
#define TMC_JPEG_PLANAR_OUTPUT
#include <tmc_jpeg_internal.h>
static void TMCJPEG_814EFEAC(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F043C(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F0A58(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F11C4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F17E0(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F1F48(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F2570(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F2B50(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F3158(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F32E4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F34A4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F372C(TMCCJPEGDecWork*, s32, s32);
s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
u8* buffer;
s32 componentCount;
TMCCJPEGDecState* state;
buffer = work->convBuf;
componentCount = work->componentCount;
state = work->pState;
switch (componentCount) {
case 0: {
u8 mode;
u8* firstRow;
u8* secondRow;
u8* thirdRow;
u8* fourthRow;
u8* cbBlock;
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
work->pConverterFunc = TMCJPEG_814EFEAC;
work->pConverterFuncEdge = TMCJPEG_814F043C;
secondRow = firstRow + mode;
thirdRow = secondRow + mode;
fourthRow = thirdRow + mode;
cbBlock = buffer + 260;
crBlock = buffer + 324;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[2] = thirdRow;
work->pConvRowPtrs[3] = fourthRow;
work->pConvRowPtrs[5] = cbBlock;
work->pConvRowPtrs[6] = crBlock;
work->pitch = 32;
work->converterFlags = 0;
break;
}
case 1: {
u8 mode;
u8* firstRow;
u8* secondRow;
u8* cbBlock;
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
work->pConverterFunc = TMCJPEG_814F0A58;
work->pConverterFuncEdge = TMCJPEG_814F11C4;
secondRow = firstRow + mode;
cbBlock = buffer + 132;
crBlock = buffer + 196;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
work->pConvRowPtrs[6] = crBlock;
work->pitch = 16;
work->converterFlags = 0;
break;
}
case 2: {
u8 mode;
u8* firstRow;
u8* secondRow;
u8* thirdRow;
u8* fourthRow;
u8* cbBlock;
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
work->pConverterFunc = TMCJPEG_814F17E0;
work->pConverterFuncEdge = TMCJPEG_814F1F48;
secondRow = firstRow + mode;
thirdRow = firstRow + mode * 16;
fourthRow = thirdRow + mode;
cbBlock = buffer + 260;
crBlock = buffer + 324;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[2] = thirdRow;
work->pConvRowPtrs[3] = fourthRow;
work->pConvRowPtrs[5] = cbBlock;
work->pConvRowPtrs[6] = crBlock;
work->pitch = 16;
work->converterFlags = 0;
break;
}
case 3: {
u8 mode;
u8* firstRow;
u8* secondRow;
u8* cbBlock;
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
work->pConverterFunc = TMCJPEG_814F2570;
work->pConverterFuncEdge = TMCJPEG_814F2B50;
secondRow = firstRow + mode * 8;
cbBlock = buffer + 132;
crBlock = buffer + 196;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
work->pConvRowPtrs[6] = crBlock;
work->pitch = 8;
work->converterFlags = 0;
break;
}
case 4: {
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
converter = TMCJPEG_814F3158;
edgeConverter = TMCJPEG_814F32E4;
work->pConvRowPtrs[0] = buffer + 4;
work->pConvRowPtrs[5] = buffer + 0x44;
work->pConvRowPtrs[6] = buffer + 0x84;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pitch = 0x08;
work->converterFlags = 0;
break;
}
case 5: {
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
converter = TMCJPEG_814F34A4;
edgeConverter = TMCJPEG_814F372C;
work->pConvRowPtrs[0] = buffer + 4;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pitch = 0x08;
work->converterFlags = 0;
break;
}
default: {
return TMCC_ERROR_FORMAT;
}
}
{
s32 width = state->jpegWidth;
s32 height = state->jpegHeight;
state->convWidth = ((u32)width / 8 + (width % 8 != 0)) * 8;
state->convHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
width = state->outputWidth;
height = state->outputHeight;
state->chromaWidth = ((u32)width / 8 + (width % 8 != 0)) * 8;
state->chromaHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
}
return 0;
}
static void TMCJPEG_814EFEAC(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 rowSkip;
u8* output;
s32 chromaXEnd;
u32 tileRow;
u32 chromaTileWidth;
s32 chromaYEnd;
u8* lumaTexture;
TMCCJPEGDecState* state;
u8* luminance;
s32 column;
s32 row;
u8* cbTexture;
s32 xEnd;
s32 height;
u8* crTexture;
s32 yEnd;
u8* cb;
u8* cr;
u32 tileWidth;
s32 width;
row = y;
luminance = work->convBuf + 4;
cb = &work->convBuf[260];
cr = &work->convBuf[324];
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
cbTexture = state->pCbBuffer;
crTexture = state->pCrBuffer;
width = 32 / state->scaleFactor;
height = 8 / state->scaleFactor;
xEnd = x + width;
yEnd = y + height;
rowSkip = 32 - width;
for (; row < yEnd; row++) {
output = lumaTexture + ((row & 3) << 3);
tileRow = (row >> 2) * tileWidth;
for (column = x; column < xEnd; column += 4) {
(output + (column & 7))[(s32)(((column >> 3) + tileRow) << 5)] = luminance[0];
(output + ((column + 1) & 7))[(s32)((((column + 1) >> 3) + tileRow) << 5)] = luminance[1];
(output + ((column + 2) & 7))[(s32)((((column + 2) >> 3) + tileRow) << 5)] = luminance[2];
(output + ((column + 3) & 7))[(s32)((((column + 3) >> 3) + tileRow) << 5)] = luminance[3];
luminance += 4;
}
luminance += rowSkip;
}
chromaTileWidth = state->chromaWidth >> 3;
x = (u32)x >> 2;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
chromaXEnd = x + width;
chromaYEnd = y + height;
for (; y < chromaYEnd; y++) {
for (column = x; column < chromaXEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
cr += 8 - width;
}
}
static void TMCJPEG_814F043C(TMCCJPEGDecWork* work, s32 x, s32 y) {
u32 chromaTileWidth;
TMCCJPEGDecState* state;
u8* lumaTexture;
u8* luminance;
s32 column;
s32 row;
s32 chromaEnd;
u8* cbTexture;
u8* crTexture;
u32 tileRow;
s32 height;
s32 yEnd;
u8* output;
u8* cb;
u8* cr;
s32 xEnd;
s32 tileOffset;
s32 width;
u32 tileWidth;
luminance = work->convBuf + 4;
cb = &work->convBuf[260];
cr = &work->convBuf[324];
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
cbTexture = state->pCbBuffer;
crTexture = state->pCrBuffer;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 32 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 8 / state->scaleFactor;
}
xEnd = x + width;
yEnd = y + height;
for (row = y; row < yEnd; row++) {
for (column = x; column < xEnd; column += 1) {
tileRow = (row >> 2) * tileWidth;
tileOffset = ((column >> 3) + tileRow) << 5;
output = lumaTexture + ((row & 3) << 3) + (column & 7);
output[tileOffset] = *luminance++;
}
luminance += 32 - width;
}
x = (u32)x >> 2;
width = (width + 3) >> 2;
xEnd = x + width;
chromaTileWidth = state->chromaWidth >> 3;
chromaEnd = y + height;
for (; y < chromaEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
cr += 8 - width;
}
}
static void TMCJPEG_814F0A58(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 chromaYEnd;
u8* lumaTexture;
u8* luminance;
s32 column;
s32 chromaXEnd;
s32 row;
u32 chromaTileWidth;
TMCCJPEGDecState* state;
s32 width;
s32 height;
u8* cbTexture;
s32 xEnd;
u8* crTexture;
s32 yEnd;
u8* cb;
u32 tileWidth;
u8* cr;
s32 chromaRowSkip;
row = y;
luminance = work->convBuf + 4;
cb = &work->convBuf[132];
cr = &work->convBuf[196];
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
cbTexture = state->pCbBuffer;
crTexture = state->pCrBuffer;
width = 16 / state->scaleFactor;
height = 8 / state->scaleFactor;
xEnd = x + width;
yEnd = y + height;
for (; row < yEnd; row++) {
for (column = x; column < xEnd; column += 2) {
(lumaTexture + ((row & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (row >> 2) * tileWidth) << 5)] = *luminance++;
(lumaTexture + ((row & 3) << 3) + ((column + 1) & 7))[(s32)((((column + 1) >> 3) + (row >> 2) * tileWidth) << 5)] = *luminance++;
}
luminance += 16 - width;
}
x = (u32)x >> 1;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
chromaXEnd = x + width;
chromaYEnd = y + height;
chromaTileWidth = state->chromaWidth >> 3;
chromaRowSkip = 8 - width;
for (; y < chromaYEnd; y++) {
for (column = x; column < chromaXEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += chromaRowSkip;
cr += 8 - width;
}
}
static void TMCJPEG_814F11C4(TMCCJPEGDecWork* work, s32 x, s32 y) {
u32 chromaTileWidth;
TMCCJPEGDecState* state;
u8* lumaTexture;
u8* luminance;
s32 column;
s32 row;
s32 chromaEnd;
u8* cbTexture;
u8* crTexture;
u32 tileRow;
s32 height;
s32 yEnd;
u8* output;
u8* cb;
u8* cr;
s32 xEnd;
s32 tileOffset;
s32 width;
u32 tileWidth;
luminance = work->convBuf + 4;
cb = &work->convBuf[132];
cr = &work->convBuf[196];
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
cbTexture = state->pCbBuffer;
crTexture = state->pCrBuffer;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 16 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 8 / state->scaleFactor;
}
xEnd = x + width;
yEnd = y + height;
for (row = y; row < yEnd; row++) {
for (column = x; column < xEnd; column += 1) {
tileRow = (row >> 2) * tileWidth;
tileOffset = ((column >> 3) + tileRow) << 5;
output = lumaTexture + ((row & 3) << 3) + (column & 7);
output[tileOffset] = *luminance++;
}
luminance += 16 - width;
}
x = (u32)x >> 1;
width = (width + 1) >> 1;
xEnd = x + width;
chromaTileWidth = state->chromaWidth >> 3;
chromaEnd = y + height;
for (; y < chromaEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
cr += 8 - width;
}
}
static void TMCJPEG_814F17E0(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 height;
s32 chromaYEnd;
s32 column;
u8* lumaTexture;
s32 chromaXEnd;
u8* luminance;
u32 chromaTileWidth;
u8* cbTexture;
s32 width;
u8* crTexture;
u32 tileWidth;
u8* cb;
TMCCJPEGDecState* state;
s32 yEnd;
s32 xEnd;
u8* cr;
s32 row;
row = y;
luminance = work->convBuf + 4;
cb = &work->convBuf[260];
cr = &work->convBuf[324];
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
cbTexture = state->pCbBuffer;
crTexture = state->pCrBuffer;
width = 16 / state->scaleFactor;
height = 16 / state->scaleFactor;
xEnd = x + width;
yEnd = y + height;
for (; row < yEnd; row++) {
for (column = x; column < xEnd; column += 2) {
(lumaTexture + ((row & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (row >> 2) * tileWidth) << 5)] = *luminance++;
(lumaTexture + ((row & 3) << 3) + ((column + 1) & 7))[(s32)((((column + 1) >> 3) + (row >> 2) * tileWidth) << 5)] = *luminance++;
}
luminance += 16 - width;
}
x = (u32)x >> 1;
y = (u32)y >> 1;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
chromaXEnd = x + width;
chromaYEnd = y + height;
chromaTileWidth = state->chromaWidth >> 3;
for (; y < chromaYEnd; y++) {
for (column = x; column < chromaXEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
cr += 8 - width;
}
}
static void TMCJPEG_814F1F48(TMCCJPEGDecWork* work, s32 x, s32 y) {
u32 chromaTileWidth;
TMCCJPEGDecState* state;
u8* lumaTexture;
u8* luminance;
s32 column;
s32 row;
s32 chromaEnd;
u8* cbTexture;
u8* crTexture;
u32 tileRow;
s32 height;
s32 yEnd;
u8* output;
u8* cb;
u8* cr;
s32 xEnd;
s32 tileOffset;
s32 width;
u32 tileWidth;
luminance = work->convBuf + 4;
cb = &work->convBuf[260];
cr = &work->convBuf[324];
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
cbTexture = state->pCbBuffer;
crTexture = state->pCrBuffer;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 16 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 16 / state->scaleFactor;
}
xEnd = x + width;
yEnd = y + height;
for (row = y; row < yEnd; row++) {
for (column = x; column < xEnd; column += 1) {
tileRow = (row >> 2) * tileWidth;
tileOffset = ((column >> 3) + tileRow) << 5;
output = lumaTexture + ((row & 3) << 3) + (column & 7);
output[tileOffset] = *luminance++;
}
luminance += 16 - width;
}
y = (u32)y >> 1;
x = (u32)x >> 1;
width = (width + 1) >> 1;
xEnd = x + width;
chromaTileWidth = state->chromaWidth >> 3;
chromaEnd = y + ((height + 1) >> 1);
for (; y < chromaEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
cr += 8 - width;
}
}
static void TMCJPEG_814F2570(TMCCJPEGDecWork* work, s32 x, s32 y) {
u32 chromaTileWidth;
TMCCJPEGDecState* state;
u8* lumaTexture;
u8* luminance;
s32 column;
s32 row;
s32 chromaEnd;
u8* cbTexture;
u8* crTexture;
u32 tileRow;
s32 height;
s32 yEnd;
u8* output;
u8* cb;
u8* cr;
s32 xEnd;
s32 tileOffset;
s32 width;
u32 tileWidth;
luminance = work->convBuf + 4;
cb = &work->convBuf[132];
cr = &work->convBuf[196];
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
cbTexture = state->pCbBuffer;
crTexture = state->pCrBuffer;
width = 8 / state->scaleFactor;
height = 16 / state->scaleFactor;
xEnd = x + width;
yEnd = y + height;
for (row = y; row < yEnd; row++) {
for (column = x; column < xEnd; column += 1) {
tileRow = (row >> 2) * tileWidth;
tileOffset = ((column >> 3) + tileRow) << 5;
output = lumaTexture + ((row & 3) << 3) + (column & 7);
output[tileOffset] = *luminance++;
}
luminance += 8 - width;
}
y = (u32)y >> 1;
chromaTileWidth = state->chromaWidth >> 3;
chromaEnd = y + 8 / state->scaleFactor;
for (; y < chromaEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
cr += 8 - width;
}
}
static void TMCJPEG_814F2B50(TMCCJPEGDecWork* work, s32 x, s32 y) {
u32 chromaTileWidth;
TMCCJPEGDecState* state;
u8* lumaTexture;
u8* luminance;
s32 column;
s32 row;
s32 chromaEnd;
u8* cbTexture;
u8* crTexture;
u32 tileRow;
s32 height;
s32 yEnd;
u8* output;
u8* cb;
u8* cr;
s32 xEnd;
s32 tileOffset;
s32 width;
u32 tileWidth;
luminance = work->convBuf + 4;
cb = &work->convBuf[132];
cr = &work->convBuf[196];
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
cbTexture = state->pCbBuffer;
crTexture = state->pCrBuffer;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 8 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 16 / state->scaleFactor;
}
xEnd = x + width;
yEnd = y + height;
for (row = y; row < yEnd; row++) {
for (column = x; column < xEnd; column += 1) {
tileRow = (row >> 2) * tileWidth;
tileOffset = ((column >> 3) + tileRow) << 5;
output = lumaTexture + ((row & 3) << 3) + (column & 7);
output[tileOffset] = *luminance++;
}
luminance += 8 - width;
}
y = (u32)y >> 1;
chromaTileWidth = state->chromaWidth >> 3;
chromaEnd = y + ((height + 1) >> 1);
for (; y < chromaEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
cr += 8 - width;
}
}
static void TMCJPEG_814F3158(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 rowSkip;
u8* output;
s32 height;
s32 tileRow;
u8* cbOutput;
TMCCJPEGDecState* state;
u8* crOutput;
s32 pixelOffset;
s32 tileOffset;
u8* lumaTexture;
s32 width;
u32 rowOffset;
u8* cbTexture;
u8* crTexture;
u8* luminance;
u8* cb;
u8* cr;
s32 column;
s32 xEnd;
s32 yEnd;
u32 tileWidth;
luminance = work->convBuf + 4;
cb = &work->convBuf[68];
cr = &work->convBuf[132];
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
cbTexture = state->pCbBuffer;
crTexture = state->pCrBuffer;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
xEnd = x + width;
yEnd = y + height;
rowSkip = 8 - width;
for (; y < yEnd; y++) {
tileRow = (y >> 2) * tileWidth;
rowOffset = (y & 3) << 3;
output = lumaTexture + rowOffset;
cbOutput = cbTexture + rowOffset;
crOutput = crTexture + rowOffset;
for (column = x; column < xEnd;) {
tileOffset = ((column >> 3) + tileRow) << 5;
pixelOffset = column++ & 7;
(output + pixelOffset)[tileOffset] = *luminance++;
(cbOutput + pixelOffset)[tileOffset] = *cb++ + 128;
(crOutput + pixelOffset)[tileOffset] = *cr++ + 128;
}
luminance += rowSkip;
cb += rowSkip;
cr += rowSkip;
}
}
static void TMCJPEG_814F32E4(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 rowSkip;
u8* output;
s32 height;
s32 tileRow;
u8* cbOutput;
TMCCJPEGDecState* state;
u8* crOutput;
s32 pixelOffset;
s32 tileOffset;
u8* lumaTexture;
s32 width;
u32 rowOffset;
u8* cbTexture;
u8* crTexture;
u8* luminance;
u8* cb;
u8* cr;
s32 column;
s32 xEnd;
s32 yEnd;
u32 tileWidth;
luminance = work->convBuf + 4;
cb = &work->convBuf[68];
cr = &work->convBuf[132];
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
cbTexture = state->pCbBuffer;
crTexture = state->pCrBuffer;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 8 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 8 / state->scaleFactor;
}
xEnd = x + width;
yEnd = y + height;
rowSkip = 8 - width;
for (; y < yEnd; y++) {
tileRow = (y >> 2) * tileWidth;
rowOffset = (y & 3) << 3;
output = lumaTexture + rowOffset;
cbOutput = cbTexture + rowOffset;
crOutput = crTexture + rowOffset;
for (column = x; column < xEnd;) {
tileOffset = ((column >> 3) + tileRow) << 5;
pixelOffset = column++ & 7;
(output + pixelOffset)[tileOffset] = *luminance++;
(cbOutput + pixelOffset)[tileOffset] = *cb++ + 128;
(crOutput + pixelOffset)[tileOffset] = *cr++ + 128;
}
luminance += rowSkip;
cb += rowSkip;
cr += rowSkip;
}
}
static void TMCJPEG_814F34A4(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 height;
u8* lumaTexture;
u8* luminance;
s32 column;
s32 xEnd;
s32 yEnd;
u8* output;
s32 width;
TMCCJPEGDecState* state;
u32 tileRow;
u32 tileWidth;
s32 tileOffset;
s32 row;
luminance = work->convBuf + 4;
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
{
xEnd = x + width;
yEnd = y + height;
for (row = y; row < yEnd; row++) {
for (column = x; column < xEnd; column += 1) {
tileRow = (row >> 2) * tileWidth;
tileOffset = ((column >> 3) + tileRow) << 5;
output = lumaTexture + ((row & 3) << 3) + (column & 7);
output[tileOffset] = *luminance++;
}
luminance += 8 - width;
}
}
}
static void TMCJPEG_814F372C(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 height;
u8* lumaTexture;
u8* luminance;
s32 column;
s32 xEnd;
s32 yEnd;
u8* output;
s32 width;
TMCCJPEGDecState* state;
u32 tileRow;
u32 tileWidth;
s32 tileOffset;
s32 row;
luminance = work->convBuf + 4;
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 8 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 8 / state->scaleFactor;
}
{
xEnd = x + width;
yEnd = y + height;
for (row = y; row < yEnd; row++) {
for (column = x; column < xEnd; column += 1) {
tileRow = (row >> 2) * tileWidth;
tileOffset = ((column >> 3) + tileRow) << 5;
output = lumaTexture + ((row & 3) << 3) + (column & 7);
output[tileOffset] = *luminance++;
}
luminance += 8 - width;
}
}
}

View File

@@ -130,11 +130,18 @@ typedef struct EZTXGetParam {
wchar_t* candidates; // 0x18
u8 maxCandidates; // 0x1C
wchar_t firstCandidate; // 0x1E
#ifndef TIZISTRING_IMPLEMENTATION
u8 wordCandidates; // 0x1F
#endif
u8 count; // 0x20
u8 letters; // 0x21
#ifdef TIZISTRING_IMPLEMENTATION
u8 completion;
u8* scratch;
#else
u8* scratch; // 0x22
#endif
} EZTXGetParam;
u16 EZTXGetGlobalDataSize();

View File

@@ -142,6 +142,9 @@ typedef struct ziFuzzyZYPairs {
int rANDn : 1;
int bANDp : 1;
int gANDk : 1;
int dANDt : 1;
int reserved : 20;
} ziFuzzyZYPairs;
typedef struct _ziGetParam {
@@ -357,8 +360,8 @@ typedef struct ziMatchParam {
ziWChar first2; // 0x68
ziWChar comp; // 0x6A
ziU8 nSeg; // 0x6C
ziU8 segs1[0xC0]; // 0x6D
ziU8 segsD[0xC0]; // 0x12D
ziU8 segs1[16][12]; // 0x6D
ziU8 segsD[16][12]; // 0x12D
ziU8 pad_0x1ED; // 0x1ED
} ziMatchParam;

View File

@@ -0,0 +1,191 @@
#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, value, first, last;
ziU8* cursor;
ziConversionTable* table;
ziConversionRange* ranges;
ziConversionEntry* entry;
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 = (ziConversionEntry*)table;
count = (ziU16)entry->first[0] << 8 | entry->first[1];
entry++;
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 (character < first || character > last) {
entry++;
continue;
}
value = (ziU16)entry->value[0] << 8 | entry->value[1];
if (first == last) {
Zi8LogError(100, __zi8_work_data);
return value & 0xFF;
}
entry = (ziConversionEntry*)((ziU8*)table + value + character - first + 8);
Zi8LogError(100, __zi8_work_data);
return *(ziU8*)entry;
}
Zi8LogError(0x6C2, __zi8_work_data);
return 0;
} else {
ranges = Zi8CvrtTables.reverse.entries;
if (ranges == 0) {
Zi8LogError(0x6AE, __zi8_work_data);
return 0;
}
count = Zi8CvrtTables.reverse.count;
for (index = 0; index < count; index++) {
if (character >= ranges[index].first && character <= ranges[index].last) {
Zi8LogError(100, __zi8_work_data);
if (ranges[index].first == ranges[index].last)
return ranges[index].result.character & 0xFF;
cursor = ranges[index].result.table;
return cursor[character - ranges[index].first];
}
}
Zi8LogError(0x6C2, __zi8_work_data);
return 0;
}
}
ziWChar Zi8ConvertUC2Key(ziChar character, ziU8 language ZI_NEED_WORK) {
ziU16 key = 0;
ziU16 index, count, first, last;
ziConversionTable* table;
ziWChar* mapped;
ziConversionRange* ranges;
ziConversionEntry* entry;
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 = (ziConversionEntry*)table;
count = (ziU16)entry->first[0] << 8 | entry->first[1];
entry++;
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 (character < first || character > last) {
entry++;
continue;
}
key = (ziU16)entry->value[0] << 8 | entry->value[1];
if (first == last) break;
entry = (ziConversionEntry*)((ziU8*)table + key + (character - first) * 2);
entry = (ziConversionEntry*)((ziU8*)entry + 8);
key = (ziU16)entry->first[0] << 8 | entry->first[1];
break;
}
} else {
ranges = Zi8CvrtTables.keys.entries;
if (ranges == 0) {
Zi8LogError(0x6B8, __zi8_work_data);
return 0;
}
count = Zi8CvrtTables.keys.count;
for (index = 0; index < count; index++) {
if (character >= ranges[index].first && character <= ranges[index].last) {
if (ranges[index].first == ranges[index].last) {
key = (ziU8)ranges[index].result.character;
break;
}
mapped = ranges[index].result.table;
key = mapped[character - ranges[index].first];
break;
}
}
}
if (key == 0) {
Zi8LogError(0x6C2, __zi8_work_data);
return 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);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -643,7 +643,7 @@ ziU32 Zi8GetSInfo(ziU8* strokes, ziU8* extraStrokes, ziWChar* outputBuffer, ziU8
{
int strokeIndex;
int outputCount;
int extraCount;
volatile int extraCount;
outputCount = 0;
Zi8LogError(100, work);
@@ -660,8 +660,7 @@ ziU32 Zi8GetSInfo(ziU8* strokes, ziU8* extraStrokes, ziWChar* outputBuffer, ziU8
goto lowStroke;
}
badStroke:
outputCount--;
outputBuffer[(ziU8)outputCount] = 0;
outputBuffer[(ziU8)--outputCount] = 0;
return outputCount;
lowStroke:
outputBuffer[(ziU8)outputCount] = zi8StrokeCode(strokes[strokeIndex] & 0xf, work);

View File

@@ -0,0 +1,386 @@
#include <zi8clib/zitypes.h>
#include <zi8clib/zierror.h>
#include <zi8clib/zconvert.h>
ziU32 Zi8GetTableSize(ziU8 language, ziU8 table, ziPtr work);
ziU32 Zi8GetTableAddress(ziU8 language, ziU8 table, ziPtr work);
ziU16 Zi8GetTableCount(ziU8 language, ziU8 table, ziPtr work);
ziU8* ZiDAWGGetGraph(zi8DawgCtx* context);
ziU8* ZiDAWGGetGraphInfo(zi8DawgCtx* context, ziU8* table, ziS16* keys);
ziU32 ZiDAWGgetCHARattribute(zi8DawgCtx* context, ziU8* graph, ziPtr work);
ziU8 ZiDAWGgetEOWattribute(ziU8* graph);
ziU8* ZiDAWGGetChild(ziU8* graph);
ziU8* ZiDAWGGetSibling(ziU8* graph);
ziU32 Zi8MatchROMdata0(ziWChar* elements, ziU8 count, ziU8 language,
ziWChar* output, ziU16 capacity, ziU8 mode, ziU8 status,
ziU8 graphTable, ziU8 keyTable, ziU8 acceptPrefix,
ziU8* prefixLength, zi8DawgCtx* context, ziU8* search,
ziPtr __zi8_work_data) {
ziU8 result = 0;
ziU8* graphData;
ziU8* keyData;
ziS32 keyCount;
ziS32 convertedKey;
ziU16 searching;
ziU16 key;
ziU16 keys[3];
ziU16 index;
zi8DawgRec* current;
zi8DawgRec* records = context->recs;
if (language != context->lang || graphTable != context->key) records[0].key = 0;
if (count == 1 && mode != 0 && graphTable == 0xe) goto finish_graph;
if (status != 0) {
if (records[context->cnt - 1].node == (ziU8*)context->unk_0x338) goto finish_graph;
for (index = 0; index < count; index++) {
if (records[index].key != elements[index] &&
(ziU16)records[index].attr != elements[index]) goto finish_graph;
}
if (mode == 1) acceptPrefix = 0;
} else {
if (ZI_WORK->unk_0x141E != 0 && graphTable == 0xc &&
Zi8GetTableSize(language, ZI_WORK->unk_0x141E, ZI_WORK) != 0) {
graphData = (ziU8*)Zi8GetTableAddress(language, ZI_WORK->unk_0x141E, ZI_WORK);
keyTable = ZI_WORK->unk_0x141E + 1;
} else {
if (Zi8GetTableSize(language, graphTable, ZI_WORK) == 0) {
Zi8LogError(0x961, ZI_WORK);
goto finish_graph;
}
graphData = (ziU8*)Zi8GetTableAddress(language, graphTable, ZI_WORK);
}
context->table = graphData;
context->cap = (((ziU16)context->table[2] << 8) + context->table[3]) / 3;
context->p08 = context->table + 4;
context->p0C = context->table + context->cap * 2 + 4;
context->lang = language;
context->key = graphTable;
index = 0;
while (index < count && records[index].key == elements[index]) index++;
if (index >= 2) {
records[0].node = records[index - 1].back;
} else {
key = Zi8GetTableSize(language, keyTable, ZI_WORK);
if (key != 0 && ZI_WORK->userKeys[language] == 0) {
index = 0;
goto check_keys;
next_key:
{
keys[index] = Zi8ConvertWC2Key(elements[index], language, ZI_WORK);
if (keys[index] == 0) keys[index] = elements[index];
index++;
}
check_keys:
if (count < 2) keyCount = count;
else keyCount = 2;
if (index < keyCount) goto next_key;
keys[index] = 0;
keyData = (ziU8*)Zi8GetTableAddress(language, keyTable, ZI_WORK);
context->p14 = keyData + 2;
keyData += context->cap * 2 + 2;
records[0].node = ZiDAWGGetGraphInfo(context, keyData, (ziS16*)keys);
} else {
records[0].node = ZiDAWGGetGraph(context);
context->unk_0x338 = 0;
context->p14 = 0;
}
records[0].key = 0;
if (records[0].node == (ziU8*)0) goto finish_graph;
}
context->cnt = 1;
search[1] = count;
search[0] = 0;
if (mode == 1) {
search[0] = 1;
acceptPrefix = 0;
} else if (mode == 0 && acceptPrefix == 0) search[1]++;
}
searching = 1;
current = &records[context->cnt - 1];
while (searching && context->cnt != 0 && current->node != (ziU8*)context->unk_0x338) {
if (capacity < context->cnt) goto finish_graph;
current->attr = ZiDAWGgetCHARattribute(context, current->node, ZI_WORK);
if (context->cnt <= count) {
if (context->p14 == 0) {
convertedKey = Zi8ConvertWC2Key((ziU16)current->attr, language, ZI_WORK);
} else {
convertedKey = ((ziU16)context->p14[(current->attr >> 24) * 2] << 8) +
(context->p14 + (current->attr >> 24) * 2)[1];
}
key = convertedKey;
if (key != elements[context->cnt - 1] &&
(ziU16)current->attr != elements[context->cnt - 1]) goto next_sibling;
if (current->key != elements[context->cnt - 1]) {
current->key = elements[context->cnt - 1];
current->back = records[0].node;
records[context->cnt].key = 0;
}
if (prefixLength != 0 && *prefixLength < context->cnt &&
ZiDAWGgetEOWattribute(current->node) != 0) {
*prefixLength = context->cnt;
for (index = 0; index < context->cnt; index++) output[index] = (ziU16)records[index].attr;
}
if (context->cnt < count) goto descend;
}
if (context->cnt < search[1]) goto descend;
if (search[0] != 0 && context->cnt > search[1]) goto next_sibling;
if (acceptPrefix != 0 || ZiDAWGgetEOWattribute(current->node) != 0) {
for (index = 0; index < context->cnt; index++) output[index] = (ziU16)records[index].attr;
result = context->cnt;
searching = 0;
if (acceptPrefix != 0) goto next_sibling;
}
if (search[0] != 0 && context->cnt >= search[1]) goto next_sibling;
descend:
records[context->cnt].node = ZiDAWGGetChild(records[context->cnt - 1].node);
if (records[context->cnt].node == (ziU8*)0) goto next_sibling;
context->cnt++;
if (ZI_WORK->unk_0x141F < context->cnt) ZI_WORK->unk_0x141F = context->cnt;
goto update_current;
next_sibling:
while (context->cnt != 0) {
records[context->cnt - 1].node = ZiDAWGGetSibling(records[context->cnt - 1].node);
if (records[context->cnt - 1].node != (ziU8*)0) break;
context->cnt--;
}
update_current:
current = &records[context->cnt - 1];
}
finish_graph:
return result;
}
ziU8* NextDawgGroup(ziU8* group, ziU8 language, ziPtr __zi8_work_data)
{
if (Zi8GetTableSize(language,0x1c,ZI_WORK) != 0) {
if (group == 0) {
group = (ziU8*)Zi8GetTableAddress(language,0x1c,ZI_WORK);
if (group == 0) {
Zi8LogError(0x962,ZI_WORK);
return 0;
}
if (ZI_WORK->unk_0x141D == 0) {
return group;
}
}
while (group[0] != 0xff || group[1] != 0xff) {
group = group + 1;
}
group = group + 2;
if (group[0] == 0xff) {
Zi8LogError(0x963,ZI_WORK);
return 0;
}
return group;
}
Zi8LogError(0x961,ZI_WORK);
return 0;
}
unsigned int Zi8MatchROMdata1(ziWChar *elements, ziU8 count, ziU8 language, ziWChar *output, ziU16 capacity, ziU8 mode, ziU8 status, ziU32 groupIndex, char *group, ziU8 acceptPrefix, ziPtr __zi8_work_data)
{
unsigned int result;
ziU32 tableAddress;
result = 0;
if (status == 0) {
ZI_WORK->unk_0x1764 = (ziU8*)group;
if (ZI_WORK->unk_0x1764 == 0) {
if (Zi8GetTableSize(language & 0xff,0xb,ZI_WORK) != 0) {
tableAddress = Zi8GetTableAddress(language & 0xff,0xb,ZI_WORK);
ZI_WORK->unk_0x1764 = (ziU8*)tableAddress;
}
}
if (ZI_WORK->unk_0x1764 != 0) {
for (; (*ZI_WORK->unk_0x1764 != 0xff && ((groupIndex & 0xff) != 0));
groupIndex = groupIndex - 1) {
while (*ZI_WORK->unk_0x1764 != 0xff) {
ZI_WORK->unk_0x1764 += 2;
}
ZI_WORK->unk_0x1764++;
}
}
}
if (ZI_WORK->unk_0x1764 == 0) {
result = Zi8MatchROMdata0(elements,count,language & 0xff,output,capacity & 0xffff,
mode & 0xff,status & 0xff,0,1,acceptPrefix,0,&ZI_WORK->dawgCtx,
ZI_WORK->unk_0x1760,ZI_WORK);
}
else {
while (*ZI_WORK->unk_0x1764 != 0xff) {
result = Zi8MatchROMdata0(elements,count,language & 0xff,output,
capacity & 0xffff,mode & 0xff,status & 0xff,
*ZI_WORK->unk_0x1764,
ZI_WORK->unk_0x1764[1],acceptPrefix,0,
&ZI_WORK->dawgCtx,ZI_WORK->unk_0x1760,ZI_WORK);
if ((result & 0xff) != 0) break;
ZI_WORK->unk_0x1764 += 2;
status = 0;
}
}
return result;
}
unsigned int Zi8MatchROMdata2(ziWChar* elements, ziU8 count, ziU8 language,
ziWChar* output, ziU16 capacity, ziU8 mode,
ziU8 status, ziU8 reservedMode, ziU8* group,
ziU8 acceptPrefix, ziPtr __zi8_work_data) {
unsigned int result = 0;
ziU8 index;
if (reservedMode != 0) return 0;
if (status == 0) {
ZI_WORK->unk_0x1768 = 0;
ZI_WORK->unk_0x17EA = 0;
if (group != 0 && *group == 0xc && language == 10 && ZI_WORK->unk_0x141C != 0) {
ZI_WORK->unk_0x141E = 0x10;
} else {
ZI_WORK->unk_0x141E = 0;
}
}
search_segment:
ZI_WORK->unk_0x141F = 1;
result = Zi8MatchROMdata1(elements + ZI_WORK->unk_0x17EA,
count - ZI_WORK->unk_0x17EA, language,
&ZI_WORK->unk_0x17F4[ZI_WORK->unk_0x17EA], capacity,
mode, status, ZI_WORK->unk_0x1768, (char*)group,
acceptPrefix, ZI_WORK);
if ((ziU8)result != 0) {
for (index = (ziU8)(ZI_WORK->unk_0x17EA + result); index != 0; index--) {
output[index - 1] = ZI_WORK->unk_0x17F4[index - 1];
}
result = (ziU8)(result + ZI_WORK->unk_0x17EA);
} else {
if (status != 0 || count == 1) goto finish_segments;
if (mode == 1 && ZI_WORK->unk_0x1768 == 0 &&
(ziU8)Zi8MatchROMdata1(elements + ZI_WORK->unk_0x17EA,
count - ZI_WORK->unk_0x17EA, language,
&ZI_WORK->unk_0x17F4[ZI_WORK->unk_0x17EA], capacity,
0, status, ZI_WORK->unk_0x1768, (char*)group,
acceptPrefix, ZI_WORK) != 0) goto finish_segments;
if ((Zi8GetTableCount(language, 0x1f, ZI_WORK) & 4) == 0) {
for (index = 0; index < count; index++) {
if (elements[index] == 0xeff1) goto finish_segments;
}
}
if (ZI_WORK->unk_0x141F > capacity) goto finish_segments;
for (index = ZI_WORK->unk_0x141F; index != 0; index--) {
result = Zi8MatchROMdata1(elements + ZI_WORK->unk_0x17EA, index, language,
&ZI_WORK->unk_0x17F4[ZI_WORK->unk_0x17EA], capacity,
1, 0, ZI_WORK->unk_0x1768, (char*)group,
acceptPrefix, ZI_WORK);
if ((ziU8)result != 0) {
ZI_WORK->unk_0x17EA += (ziU8)result;
if (ZI_WORK->unk_0x17EA == count) return 0;
ZI_WORK->unk_0x1768++;
status = 0;
ZI_WORK->unk_0x141E = 0;
if (ZI_WORK->dawgCtx.key == 0 && language == 10) {
for (index = 0; index < ZI_WORK->unk_0x17EA; index++) {
switch (ZI_WORK->unk_0x17F4[index]) {
case 0x61:
case 0x6f:
case 0x75:
ZI_WORK->unk_0x141E = 0x10;
goto search_segment;
}
}
}
goto search_segment;
}
}
}
finish_segments:
return result;
}
ziU32 Zi8MatchROMdata(ziWChar* elements, ziU8 count, ziU8 language,
ziWChar* output, ziU16 capacity, ziU8 mode, ziU8 status,
ziU8 reservedMode, ziU8 acceptPrefix, ziPtr __zi8_work_data) {
ziU32 result = 0;
ziS32 tableSize = 0;
if (capacity < count) {
Zi8LogError(0x321, ZI_WORK);
} else if (status == 2) {
Zi8LogError(100, ZI_WORK);
} else {
if (status == 0) {
ZI_WORK->unk_0x17EC = 0;
ZI_WORK->unk_0x17F0 = NextDawgGroup(0, language, ZI_WORK);
} else if (ZI_WORK->unk_0x17EC != 0) {
Zi8LogError(100, ZI_WORK);
goto finish_match;
}
tableSize = Zi8GetTableSize(language, 0x1c, ZI_WORK);
if (tableSize == 0) {
result = Zi8MatchROMdata2(elements, count, language, output, capacity,
mode, status, reservedMode, 0, acceptPrefix, ZI_WORK);
} else {
while (ZI_WORK->unk_0x17F0 != 0) {
result = Zi8MatchROMdata2(elements, count, language, output, capacity,
mode, status, reservedMode, ZI_WORK->unk_0x17F0,
acceptPrefix, ZI_WORK);
if ((ziU8)result != 0) break;
status = 0;
if (count <= 1 && language == 0x36) break;
ZI_WORK->unk_0x17F0 = NextDawgGroup(ZI_WORK->unk_0x17F0, language, ZI_WORK);
}
}
if ((ziU8)result == 0 && status == 0 && mode == 1 && count == 1 && capacity >= 1) {
mode = 0;
ZI_WORK->unk_0x17EC = 1;
if (tableSize != 0) {
ZI_WORK->unk_0x17F0 = NextDawgGroup(0, language, ZI_WORK);
while (ZI_WORK->unk_0x17F0 != 0) {
if ((ziU8)Zi8MatchROMdata2(elements, count, language, output, capacity,
mode, status, reservedMode, ZI_WORK->unk_0x17F0,
acceptPrefix, ZI_WORK) != 0) {
*output = *elements;
result = 1;
break;
}
ZI_WORK->unk_0x17F0 = NextDawgGroup(ZI_WORK->unk_0x17F0, language, ZI_WORK);
}
} else {
if ((ziU8)Zi8MatchROMdata2(elements, count, language, output, capacity,
mode, status, reservedMode, 0, acceptPrefix, ZI_WORK) != 0) {
*output = *elements;
result = 1;
}
}
}
Zi8LogError(100, ZI_WORK);
}
finish_match:
return result;
}
void Zi8SyllablesROMdata(ziWChar *elements, ziU8 count, ziU8 language, ziWChar *output, ziU16 capacity, ziU8 status, ziU8* prefixLength, ziU8 reverseOrder, ziPtr __zi8_work_data)
{
ziU32 keyTable;
ziU8 graphTable;
graphTable = 0x1a;
keyTable = 0x1b;
if (prefixLength != 0) {
*prefixLength = 0;
}
if (reverseOrder != 0) {
graphTable = 0x18;
keyTable = 0x19;
}
if (Zi8GetTableSize(language & 0xff,graphTable,ZI_WORK) == 0) {
if (graphTable == 0x1a) {
graphTable = 0x18;
keyTable = 0x19;
}
else {
graphTable = 0x1a;
keyTable = 0x1b;
}
}
Zi8MatchROMdata0(elements,count,language & 0xff,output,capacity,1,status,graphTable,keyTable,0,(ziU8 *)prefixLength,
&ZI_WORK->dawgCtx,ZI_WORK->unk_0x1760,ZI_WORK);
return;
}

View File

@@ -0,0 +1,716 @@
#include <zi8clib/zitypes.h>
#include <zi8clib/zierror.h>
#include <zi8clib/zi8getc2.h>
typedef struct {
ziU8 countOnly;
ziU8 maxWordLength;
ziU8 lookupMode;
ziU8 suffixOnly;
ziU8 controls[8];
ziU32 maxCount;
ziU16 capacity;
ziU8 minWordLength;
ziU8 flags;
ziU16 candidateCapacity;
ziU8 checkOnly;
ziU8 reserved;
} ZiCandidateOptions;
const ziU8 Zi8SOdefaultArray[16] = {1, 4, 3, 2, 1, 8, 7, 6, 5, 0};
const ziFuzzyPYPairs Zi8PYdefaultFuzzyPairs = {0, 1, 1, 1, 1, 1, 1};
const ziFuzzyZYPairs Zi8ZYdefaultFuzzyPairs = {0};
ziU8 Zi8GetFormatVersion(ziU8 language, ziPtr work);
ziU32 Zi8GetTableAddress(ziU8 language, ziU8 table, ziPtr work);
ziU16 Zi8GetTableCount(ziU8 language, ziU8 table, ziPtr work);
ziU16 Zi8GetVersion(ziPtr work);
ziU16 Zi8GetOEMID(ziPtr work);
ziU16 Zi8GetBuildID(ziPtr work);
void Zi8Memcpy(ziU8* destination, ziU8* source, ziS32 count);
ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* options, ziPtr work);
ziBool Zi8ZHsetPYfuzzyPairs(ziFuzzyPYPairs pairs ZI_NEED_WORK) {
if (pairs.ziDefault) {
ZI_WORK->unk_0x1B28.word = *(const ziU32*)&Zi8PYdefaultFuzzyPairs;
} else {
ZI_WORK->unk_0x1B28.word = *(ziU32*)&pairs;
}
return 1;
}
ziBool Zi8ZHsetZYfuzzyPairs(ziFuzzyZYPairs pairs ZI_NEED_WORK) {
if (pairs.ziDefault) {
ZI_WORK->unk_0x1B2C.word = *(const ziU32*)&Zi8ZYdefaultFuzzyPairs;
} else {
ZI_WORK->unk_0x1B2C.word = *(ziU32*)&pairs;
}
return 1;
}
ziBool Zi8SetLatinSearchOrder(ziU8* searchArray, ziU8 searchSize ZI_NEED_WORK) {
if (searchArray == 0 || *searchArray == 0) {
ZI_WORK->unk_0x1410 = (ziU32)Zi8SOdefaultArray;
ZI_WORK->unk_0x1418 = 9;
} else {
ZI_WORK->unk_0x1410 = (ziU32)searchArray;
ZI_WORK->unk_0x1418 = searchSize;
}
return 1;
}
ziU16 Zi8GetGlobalDataSize(void) {
return sizeof(struct __zi8_work_data_s);
}
static ziU16 Zi8GetDataSignature(ziU8* destination, ziU16 capacity, ziU8 language, ziPtr work) {
ziU8* signature;
ziU16 length;
if (language == 1) {
if (Zi8GetFormatVersion(1, work) < 8) {
Zi8LogError(0x26f, work);
return 0;
}
length = 0x1e;
} else {
length = 3;
}
signature = (ziU8*)Zi8GetTableAddress(language, (ziU8)length, work);
length = Zi8GetTableCount(language, (ziU8)length, work);
if (length == 0 || length > capacity) {
Zi8LogError(0x961, work);
return 0;
}
Zi8Memcpy(destination, signature, length);
destination[length] = 0;
Zi8LogError(100, work);
return length;
}
static ziU16 Zi8GetEngineSignature(ziU8* destination, ziPtr work) {
ziU16 index = 0;
struct { ziU16 minor; } version;
ziU16 number;
destination[index++] = 'v';
number = (Zi8GetVersion(work) & 0xff00) >> 8;
version.minor = Zi8GetVersion(work) & 0xff;
destination[index++] = (ziU8)(number / 10 + '0');
destination[index++] = (ziU8)(number % 10 + '0');
destination[index++] = (ziU8)(version.minor / 10 + '0');
destination[index++] = (ziU8)(version.minor % 10 + '0');
destination[index++] = 'o';
number = Zi8GetOEMID(work);
destination[index++] = (ziU8)(number / 100 + '0');
destination[index++] = (ziU8)((number % 100) / 10 + '0');
destination[index++] = (ziU8)((number % 100) % 10 + '0');
destination[index++] = 'b';
number = Zi8GetBuildID(work);
destination[index++] = (ziU8)(number / 100 + '0');
destination[index++] = (ziU8)((number % 100) / 10 + '0');
destination[index++] = (ziU8)((number % 100) % 10 + '0');
destination[index] = 0;
return index;
}
static ziBool Zi8AlphaSignature(ziGetParam* parameters, ziBool countOnly ZI_NEED_WORK) {
ziU16 secondLength;
struct { ziU16 length; ziU8* second; ziU8* first; } signatures;
ziU8 dictionary[32];
ziU8 engine[32];
ziU16 length;
ziU8* current;
ziWChar* output = parameters->candidates;
signatures.first = 0;
signatures.second = 0;
signatures.length = 0;
secondLength = 0;
Zi8LogError(100, ZI_WORK);
parameters->letters = 0;
length = Zi8GetDataSignature(dictionary, 0x20, parameters->language, ZI_WORK);
if (length != 0 && parameters->elementCount <= length) {
signatures.first = dictionary;
signatures.second = engine;
signatures.length = length;
} else {
signatures.first = engine;
}
length = Zi8GetEngineSignature(engine, ZI_WORK);
if (length < parameters->elementCount) {
if (signatures.length != 0) {
signatures.second = 0;
length = 1;
} else {
Zi8ReplaceLastError(500, ZI_WORK);
return 0;
}
} else if (signatures.length != 0) {
secondLength = length;
length = 2;
} else {
signatures.length = length;
length = 1;
}
if (parameters->firstCandidate >= length) {
Zi8ReplaceLastError(501, ZI_WORK);
return 0;
}
length = length - parameters->firstCandidate;
if (countOnly != 0) {
parameters->letters = length;
ZI_WORK->unk_0x0A = 0xff;
return 1;
}
if (parameters->maxCandidates < length) length = parameters->maxCandidates;
parameters->letters = length;
if ((parameters->getOptions & 0x80) == 0) {
ZI_WORK->unk_0x538 = parameters->language;
parameters->candidates[0] = 0xfff0;
output = (ziWChar*)&ZI_WORK->unk_0x338;
}
if (parameters->firstCandidate != 0) {
current = signatures.second;
length = secondLength;
} else {
current = signatures.first;
length = signatures.length;
}
if (length > ZI_WORK->unk_0x0A) length = ZI_WORK->unk_0x0A;
if ((parameters->elementCount < ZI_WORK->unk_0x140C[0] ||
(parameters->getOptions & 0x7e) == 2) && length > parameters->elementCount) {
length = parameters->elementCount;
}
while (length-- != 0) *output++ = (ziU8)*current++;
*output++ = 0;
if (parameters->letters == 2) {
current = signatures.second;
length = secondLength;
if (length > ZI_WORK->unk_0x0A) length = ZI_WORK->unk_0x0A;
if ((parameters->elementCount < ZI_WORK->unk_0x140C[0] ||
(parameters->getOptions & 0x7e) == 2) && length > parameters->elementCount) {
length = parameters->elementCount;
}
while (length-- != 0) *output++ = (ziU8)*current++;
*output++ = 0;
}
*output++ = 0;
ZI_WORK->unk_0x0A = 0xff;
return 1;
}
static ziBool Zi8ZhSignature(ziGetParam* parameters, ziBool countOnly ZI_NEED_WORK) {
ziWChar* output = parameters->candidates;
ziU8* current = 0;
ziU16 copied;
ziU8 dictionary[32];
ziU8 engine[32];
ziU16 dataLength;
ziU16 engineLength;
ziU16 length;
Zi8LogError(100, ZI_WORK);
parameters->letters = 0;
dataLength = Zi8GetDataSignature(dictionary, 0x20, parameters->language, ZI_WORK);
engineLength = Zi8GetEngineSignature(engine, ZI_WORK);
if ((parameters->context & 0x10) != 0) {
length = 0;
if (dataLength != 0) length++;
if (engineLength != 0) length++;
} else {
length = dataLength + engineLength;
}
if (parameters->firstCandidate >= length) {
Zi8ReplaceLastError(502, ZI_WORK);
return 0;
}
length = length - parameters->firstCandidate;
if (countOnly != 0) {
parameters->letters = length;
ZI_WORK->unk_0x0A = 0xff;
return 1;
}
if (parameters->maxCandidates < length) length = parameters->maxCandidates;
parameters->letters = length;
if ((parameters->context & 0x10) != 0) {
if (parameters->firstCandidate != 0 || dataLength == 0) {
if (parameters->firstCandidate != 0 && dataLength == 0) {
Zi8ReplaceLastError(500, ZI_WORK);
return 0;
}
current = engine;
length = engineLength;
} else {
current = dictionary;
length = dataLength;
}
while (length-- != 0) *output++ = (ziU8)*current++;
*output++ = 0x20;
if (parameters->letters == 2) {
current = engine;
length = engineLength;
while (length-- != 0) *output++ = (ziU8)*current++;
*output++ = 0x20;
}
} else {
copied = 0;
if (dataLength != 0) {
if (parameters->firstCandidate >= dataLength) {
length = 0;
} else {
length = dataLength - parameters->firstCandidate;
current = dictionary + parameters->firstCandidate;
}
if (parameters->letters < length) length = parameters->letters;
copied = length;
while (length-- != 0) *output++ = (ziU8)*current++;
}
current = engine;
if (parameters->firstCandidate >= dataLength) {
length = dataLength + (engineLength - parameters->firstCandidate);
current += engineLength - length;
} else {
length = engineLength;
}
if (parameters->letters - copied < length) length = parameters->letters - copied;
while (length-- != 0) *output++ = (ziU8)*current++;
}
return 1;
}
ziU8 _Zi8GetCandidates(ziGetParam* parameters ZI_NEED_WORK) {
ZiCandidateOptions options = {0};
options.capacity = ZI_WORK->unk_0x141A;
return Zi8GetCandidatesOrCount(parameters, &options, ZI_WORK);
}
ziU8 _Zi8CheckCandidates(ziGetParam* parameters ZI_NEED_WORK) {
ZiCandidateOptions options = {0};
options.capacity = ZI_WORK->unk_0x141A;
options.flags = 1;
return Zi8GetCandidatesOrCount(parameters, &options, ZI_WORK);
}
ziU8 Zi8LangSupported(ziU8 language, ziPtr work);
ziBool Zi8IsCharacter(ziWChar character, ziPtr work);
ziU8 Zi8GetCharInfo(ziWChar character, ziWChar* output, ziU8 capacity, ziU8 type, ziPtr work);
ziU32 Zi8GetKOcandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8GetKoreanCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8Punctuation(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8GetChineseCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8Get1KeyPressCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8Get1KeyPressSpelling(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8GetSyllablesCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* options ZI_NEED_WORK) {
ziU16 characterInfo[16];
struct {
ziU8 savedGetMode;
ziU8 savedElementCount;
ziU8 convertedElementCount;
ziBool restoreCandidates;
ziU8 savedOptions;
ziU16 savedCharacter;
ziU16 lastInfoCharacter;
ziWChar* savedElements;
ziWChar* savedCandidates;
} saved;
ziU8 outputIndex;
ziU16 error;
unsigned int candidateCount;
error = 0;
saved.savedOptions = 0;
saved.savedCandidates = 0;
saved.restoreCandidates = 0;
if (options->lookupMode == '\0') {
if (((ZI_WORK->unk_0x00 == '\t') && (parameters->elementCount != 0)) &&
(((parameters->elements[parameters->elementCount - 1] == 0xEFF8 &&
((ziU8)Zi8AlphaSignature(parameters,options->countOnly,ZI_WORK) != 0)) ||
((parameters->elements[parameters->elementCount - 1] == 0xEF04 &&
((ziU8)Zi8ZhSignature(parameters,options->countOnly,ZI_WORK) != 0)))))) {
candidateCount = (unsigned int)parameters->letters;
if (options->countOnly != '\0') {
parameters->letters = 0;
}
Zi8LogError(100,ZI_WORK);
return candidateCount;
}
if ((parameters->elementCount == 1) && (parameters->firstCandidate == 0)) {
switch (parameters->language) {
case 1:
if ((ZI_WORK->unk_0x00 == '\0') || (ZI_WORK->unk_0x01 == options->countOnly)) {
switch(ZI_WORK->unk_0x00) {
case '\0':
if (parameters->elements[0] == 0xEF04) {
ZI_WORK->unk_0x01 = options->countOnly;
ZI_WORK->unk_0x00 = '\x01';
}
break;
case '\x02':
case '\x04':
case '\x06':
if (parameters->elements[0] == 0xEF04) {
++ZI_WORK->unk_0x00;
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\x01':
case '\x03':
case '\x05':
case '\a':
if (parameters->elements[0] == 0xEF01) {
++ZI_WORK->unk_0x00;
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\b':
case '\t':
if ((parameters->elements[0] == 0xEF04) &&
((ziU8)Zi8ZhSignature(parameters,options->countOnly,ZI_WORK) != 0)) {
ZI_WORK->unk_0x00 = '\t';
candidateCount = (unsigned int)parameters->letters;
if (options->countOnly != '\0') {
parameters->letters = 0;
}
Zi8LogError(100,ZI_WORK);
return candidateCount;
}
default:
ZI_WORK->unk_0x00 = '\0';
}
if ((ZI_WORK->unk_0x00 == '\0') && (parameters->elements[0] == 0xEF04)) {
ZI_WORK->unk_0x00 = '\x01';
}
}
break;
case 0x10:
case 0x12:
case 0x77:
case 0x78:
case 0x79:
case 0x7A:
case 0x7B:
case 0x7C:
case 0x7D:
break;
case 0x11:
default:
if ((ZI_WORK->unk_0x00 == '\0') || (ZI_WORK->unk_0x01 == options->countOnly)) {
switch(ZI_WORK->unk_0x00) {
case '\0':
if (parameters->elements[0] == 0xEFF2) {
ZI_WORK->unk_0x01 = options->countOnly;
ZI_WORK->unk_0x00 = '\x01';
}
break;
case '\x01':
if (parameters->elements[0] == 0xEFF3) {
ZI_WORK->unk_0x00 = '\x02';
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\x02':
if (parameters->elements[0] == 0xEFF5) {
ZI_WORK->unk_0x00 = '\x03';
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\x03':
if (parameters->elements[0] == 0xEFF7) {
ZI_WORK->unk_0x00 = '\x04';
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\x04':
if (parameters->elements[0] == 0xEFF8) {
ZI_WORK->unk_0x00 = '\x05';
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\x05':
if (parameters->elements[0] == 0xEFF9) {
ZI_WORK->unk_0x00 = '\x06';
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\x06':
if (parameters->elements[0] == 0xEFF2) {
ZI_WORK->unk_0x00 = '\a';
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\a':
if (parameters->elements[0] == 0xEFF5) {
ZI_WORK->unk_0x00 = '\b';
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\b':
case '\t':
if ((parameters->elements[0] == 0xEFF8) &&
((ziU8)Zi8AlphaSignature(parameters,options->countOnly,ZI_WORK) != 0)) {
ZI_WORK->unk_0x00 = '\t';
candidateCount = (unsigned int)parameters->letters;
if (options->countOnly != '\0') {
parameters->letters = 0;
}
Zi8LogError(100,ZI_WORK);
return candidateCount;
}
default:
ZI_WORK->unk_0x00 = '\0';
}
if ((ZI_WORK->unk_0x00 == '\0') && (parameters->elements[0] == 0xEFF2)) {
ZI_WORK->unk_0x00 = '\x01';
}
}
break;
}
}
else if (1 < parameters->elementCount) {
ZI_WORK->unk_0x00 = '\0';
}
}
ZI_WORK->unk_0x18 = parameters->subLanguage;
ZI_WORK->unk_0x16 = Zi8GetFormatVersion(1,ZI_WORK) & 2;
options->maxCount = ZI_WORK->unk_0x10;
options->maxWordLength = ZI_WORK->unk_0x0A;
ZI_WORK->unk_0x0A = -1;
if ((ziU8)Zi8LangSupported(parameters->language,ZI_WORK) == 0) {
Zi8LogError(0x163,ZI_WORK);
return 0;
}
else {
if (parameters->language == 0x10) {
error = 0x2c1;
candidateCount = 0;
}
else if (parameters->language == 0x12) {
if ((parameters->elementCount == 0) || (parameters->elements[0] >= 0xeff1)) {
candidateCount = Zi8GetKOcandidates(parameters,options,ZI_WORK);
}
else {
candidateCount = Zi8GetKoreanCandidates(parameters,options,ZI_WORK);
}
}
else if ((parameters->language == 1) && ((parameters->context & 8) != 0)) {
candidateCount = Zi8Punctuation(parameters,options,ZI_WORK);
error = 100;
}
else if ((parameters->language == 1) &&
((((parameters->getOptions & 0xbf) == 4 && (parameters->elementCount != 0)) &&
((ziU8)Zi8IsCharacter(parameters->elements[0],ZI_WORK) != 0)))) {
saved.convertedElementCount = Zi8GetCharInfo(parameters->elements[0],characterInfo,0x10,1,ZI_WORK);
if (saved.convertedElementCount == 0) {
parameters->letters = parameters->count = parameters->unk_0x20 = 0;
candidateCount = 0;
error = 900;
}
else {
saved.lastInfoCharacter = characterInfo[saved.convertedElementCount - 1];
if ((saved.lastInfoCharacter >= 0xf331) && (saved.lastInfoCharacter <= 0xf335)) {
characterInfo[saved.convertedElementCount - 1] = 0xf360;
}
saved.savedElements = parameters->elements;
parameters->elements = characterInfo;
saved.savedElementCount = parameters->elementCount;
parameters->elementCount = saved.convertedElementCount;
saved.savedGetMode = parameters->getMode;
parameters->getMode = 1;
candidateCount = Zi8GetChineseCandidates(parameters,options,ZI_WORK);
parameters->elements = saved.savedElements;
parameters->elementCount = saved.savedElementCount;
parameters->getMode = saved.savedGetMode;
parameters->count = 1;
}
}
else if ((parameters->language == 1) && (parameters->getMode == 0xf)) {
error = 0x2d0;
candidateCount = 0;
}
else if ((parameters->language == 1) && ((parameters->getMode == 3 || (parameters->getMode == 4)))) {
if ((parameters->getOptions & 0x80) != 0) {
candidateCount = Zi8Get1KeyPressSpelling(parameters,options,ZI_WORK);
} else if (parameters->elementCount == 0) {
candidateCount = Zi8GetChineseCandidates(parameters,options,ZI_WORK);
} else {
candidateCount = Zi8Get1KeyPressCandidates(parameters,options,ZI_WORK);
}
}
else if ((parameters->language == 1) &&
((((parameters->getMode == 7 || (parameters->getMode == 8)) || (parameters->getMode == 10)) || (parameters->getMode == 9)))) {
if (ZI_WORK->unk_0x16 != '\0') {
candidateCount = Zi8GetChineseCandidates(parameters,options,ZI_WORK);
} else {
error = 0x708;
candidateCount = 0;
}
}
else if ((parameters->language == 1) && ((parameters->getMode == 0xb || (parameters->getMode == 0xe)))) {
error = 0x2ee;
candidateCount = 0;
}
else if (parameters->language == 1) {
candidateCount = Zi8GetChineseCandidates(parameters,options,ZI_WORK);
if ((((candidateCount == 0) && ((parameters->getOptions & 0x20) == 0)) && ((parameters->getMode == 1 && (parameters->elementCount != 0))))
&& (((parameters->elements[parameters->elementCount - 1] == 0xF37A ||
(parameters->elements[parameters->elementCount - 1] == 0xF363)) ||
(parameters->elements[parameters->elementCount - 1] == 0xF373)))) {
saved.savedCharacter = parameters->elements[parameters->elementCount];
parameters->elements[parameters->elementCount++] = 0xf368;
candidateCount = Zi8GetChineseCandidates(parameters,options,ZI_WORK);
parameters->elements[--parameters->elementCount] = saved.savedCharacter;
}
}
else {
ZI_WORK->unk_0x538 = parameters->language;
if ((parameters->getOptions & 0x80) == 0) {
saved.restoreCandidates = 1;
saved.savedOptions = parameters->getOptions;
saved.savedCandidates = parameters->candidates;
parameters->getOptions |= 0x81;
parameters->candidates = (ziWChar*)&ZI_WORK->unk_0x338;
options->capacity = 0x100;
}
if (parameters->getMode == 2) {
if ((Zi8GetTableCount(parameters->language,0x1f,ZI_WORK) & 0x200) != 0) {
candidateCount = Zi8GetSyllablesCandidates(parameters,options,ZI_WORK);
} else {
error = 0x44c;
candidateCount = 0;
}
}
else {
candidateCount = Zi8AlphaGetCandidates(parameters,options,ZI_WORK);
}
}
if (saved.restoreCandidates) {
parameters->getOptions = saved.savedOptions;
parameters->candidates = saved.savedCandidates;
for (outputIndex = 0; outputIndex < parameters->letters; outputIndex++) {
parameters->candidates[outputIndex] = 0xFFF0 + outputIndex;
}
}
if (error != 0) {
Zi8LogError(error,ZI_WORK);
}
}
return candidateCount;
}
void Zi8InitDupWordBuf(ziPtr __zi8_work_data) {
ZI_WORK->unk_0x539 = 0;
}
ziBool Zi8IsDupWChar(ziWChar character ZI_NEED_WORK) {
ziBool duplicate;
ziU16* buffer;
unsigned int index;
duplicate = 0;
buffer = ZI_WORK->unk_0x57A;
if (ZI_WORK->unk_0x539 == 0) {
buffer[0] = 2;
buffer[1] = character;
ZI_WORK->unk_0x539 = 1;
Zi8LogError(0x8fd, ZI_WORK);
return 0;
}
for (index = ZI_WORK->unk_0x539; index != 0; index--) {
if (character == buffer[index]) {
duplicate = 1;
break;
}
}
ZI_WORK->unk_0x539++;
buffer[(*buffer)++] = character;
if (*buffer > 100) {
*buffer = 2;
buffer[1] = character;
ZI_WORK->unk_0x539 = 1;
}
Zi8LogError(100, ZI_WORK);
return duplicate;
}
ziBool Zi8IsDupWordW(ziWChar* word, ziU8 length ZI_NEED_WORK) {
unsigned int slot;
ziBool duplicate = 0;
int index;
int character;
if (word == 0 || length == 0) {
Zi8LogError(300, ZI_WORK);
return 0;
}
if (length > 20) {
word += length - 20;
length = 20;
}
for (index = 0; index < ZI_WORK->unk_0x539; index++) {
slot = ZI_WORK->unk_0x53A[index];
for (character = 0; character < length; character++) {
if (word[character] != ((ziWChar (*)[21])ZI_WORK->unk_0x57A)[slot][character]) break;
}
if (character >= length && ((ziWChar (*)[21])ZI_WORK->unk_0x57A)[slot][character] == 0) {
duplicate = 1;
break;
}
}
if (!duplicate) {
if (ZI_WORK->unk_0x539 < 64) {
slot = ZI_WORK->unk_0x53A[ZI_WORK->unk_0x539] = ZI_WORK->unk_0x539;
ZI_WORK->unk_0x539++;
} else {
slot = ZI_WORK->unk_0x53A[0];
for (index = 1; index < ZI_WORK->unk_0x539; index++) {
ZI_WORK->unk_0x53A[index - 1] = ZI_WORK->unk_0x53A[index];
}
ZI_WORK->unk_0x53A[index - 1] = slot;
}
} else {
slot = ZI_WORK->unk_0x53A[index];
for (; index < ZI_WORK->unk_0x539 - 1; index++) {
ZI_WORK->unk_0x53A[index] = ZI_WORK->unk_0x53A[index + 1];
}
ZI_WORK->unk_0x53A[index] = slot;
}
for (character = 0; character < length; character++) {
((ziWChar (*)[21])ZI_WORK->unk_0x57A)[slot][character] = word[character];
}
((ziWChar (*)[21])ZI_WORK->unk_0x57A)[slot][character] = 0;
Zi8LogError(100, ZI_WORK);
return duplicate;
}
void Zi8Memset(ziU8* destination, ziU32 value, ziS32 count) {
ziS32 index;
for (index = 0; index < count; index++) destination[index] = (ziU8)value;
}
void Zi8Memcpy(ziU8* destination, ziU8* source, ziS32 count) {
ziS32 index;
for (index = 0; index < count; index++) destination[index] = source[index];
}
ziBool Zi8SetMaxWordLength(ziU8 length ZI_NEED_WORK) {
ZI_WORK->unk_0x0A = length;
return 1;
}

View File

@@ -0,0 +1,890 @@
#include <zi8clib/zierror.h>
#include <zi8clib/zitypes.h>
extern ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
const ziU8 Zi8PinyinInitials[0x1C] = {
0x00, 0x3C, 0x98, 0x02, 0x00, 0x38, 0x34, 0x3B, 0x00, 0x06, 0x37, 0x2B,
0x0C, 0x26, 0x00, 0x3F, 0x09, 0x2C, 0x9A, 0x05, 0x00, 0x00, 0x11, 0x0A,
0x0D, 0x9C, 0x00, 0x00
};
const ziU8 Zi8BpmfInitials[0x24] = {
0x3C, 0x3F, 0x0C, 0x38, 0x02, 0x05, 0x26, 0x2B, 0x34, 0x37, 0x3B, 0x06,
0x09, 0x0A, 0x1D, 0x19, 0x1B, 0x2C, 0x1C, 0x18, 0x1A, 0x01, 0x02, 0x03,
0x05, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0E, 0x0D, 0x0F, 0x04, 0x00, 0x00
};
const ziU8 Zi8PinyinFinals[0x36][8] = {
{0x0F, 0xFF, 0x00, 0x00, 0x3C, 0x28, 0x00, 0x00},
{0x0F, 0x00, 0x00, 0x00, 0x3F, 0x2B, 0x00, 0x00},
{0x0F, 0x0E, 0xFF, 0x00, 0x3F, 0x28, 0x00, 0x00},
{0x0F, 0x0E, 0x07, 0x00, 0x3F, 0x28, 0x00, 0x00},
{0x0F, 0x15, 0x00, 0x00, 0x3F, 0x2A, 0x00, 0x00},
{0x09, 0xFF, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00},
{0x09, 0x00, 0x00, 0x00, 0x3F, 0x08, 0x00, 0x00},
{0x09, 0x01, 0xFF, 0x00, 0x38, 0x00, 0x00, 0x00},
{0x09, 0x01, 0x00, 0x00, 0x3F, 0x04, 0x00, 0x00},
{0x09, 0x01, 0x0F, 0x00, 0x3F, 0x01, 0x00, 0x00},
{0x09, 0x01, 0x0E, 0xFF, 0x3E, 0x02, 0x00, 0x00},
{0x09, 0x01, 0x0E, 0x00, 0x3F, 0x02, 0x00, 0x00},
{0x09, 0x01, 0x0E, 0x07, 0x3F, 0x03, 0x00, 0x00},
{0x09, 0x05, 0x00, 0x00, 0x3F, 0x09, 0x00, 0x00},
{0x09, 0x15, 0x00, 0x00, 0x3F, 0x0B, 0x00, 0x00},
{0x09, 0x0E, 0xFF, 0x00, 0x3E, 0x0C, 0x00, 0x00},
{0x09, 0x0E, 0x00, 0x00, 0x3F, 0x0C, 0x00, 0x00},
{0x09, 0x0E, 0x07, 0x00, 0x3F, 0x0D, 0x00, 0x00},
{0x09, 0x0F, 0xFF, 0x00, 0x3E, 0x0E, 0x00, 0x00},
{0x09, 0x0F, 0x15, 0x00, 0x3F, 0x0E, 0x00, 0x00},
{0x09, 0x0F, 0x0E, 0xFF, 0x3F, 0x0F, 0x00, 0x00},
{0x09, 0x0F, 0x0E, 0x07, 0x3F, 0x0F, 0x00, 0x00},
{0x15, 0xFF, 0x00, 0x00, 0x30, 0x10, 0x00, 0x00},
{0x15, 0x00, 0x00, 0x00, 0x3F, 0x18, 0x00, 0x00},
{0x15, 0x01, 0xFF, 0x00, 0x38, 0x10, 0x00, 0x00},
{0x15, 0x01, 0x00, 0x00, 0x3F, 0x17, 0x00, 0x00},
{0x15, 0x01, 0x0E, 0xFF, 0x3E, 0x10, 0x00, 0x00},
{0x15, 0x01, 0x0E, 0x00, 0x3F, 0x10, 0x00, 0x00},
{0x15, 0x01, 0x0E, 0x07, 0x3F, 0x11, 0x00, 0x00},
{0x15, 0x01, 0x09, 0x00, 0x3F, 0x13, 0x00, 0x00},
{0x15, 0x0E, 0x00, 0x00, 0x3F, 0x1C, 0x00, 0x00},
{0x15, 0x09, 0x00, 0x00, 0x3F, 0x1D, 0x00, 0x00},
{0x15, 0x0F, 0x00, 0x00, 0x3F, 0x1E, 0x00, 0x00},
{0x15, 0x05, 0x00, 0x00, 0x3F, 0x1F, 0x00, 0x00},
{0x01, 0xFF, 0x00, 0x00, 0x38, 0x20, 0x00, 0x00},
{0x01, 0x00, 0x00, 0x00, 0x3F, 0x23, 0x00, 0x00},
{0x01, 0x0E, 0xFF, 0x00, 0x3E, 0x20, 0x00, 0x00},
{0x01, 0x0E, 0x00, 0x00, 0x3F, 0x20, 0x00, 0x00},
{0x01, 0x0E, 0x07, 0x00, 0x3F, 0x21, 0x00, 0x00},
{0x01, 0x09, 0x00, 0x00, 0x3F, 0x25, 0x00, 0x00},
{0x01, 0x0F, 0x00, 0x00, 0x3F, 0x26, 0x00, 0x00},
{0x05, 0xFF, 0x00, 0x00, 0x38, 0x30, 0x00, 0x00},
{0x05, 0x00, 0x00, 0x00, 0x3F, 0x34, 0x00, 0x00},
{0x05, 0x0E, 0xFF, 0x00, 0x3E, 0x30, 0x00, 0x00},
{0x05, 0x0E, 0x00, 0x00, 0x3F, 0x30, 0x00, 0x00},
{0x05, 0x0E, 0x07, 0x00, 0x3F, 0x31, 0x00, 0x00},
{0x05, 0x09, 0x00, 0x00, 0x3F, 0x35, 0x00, 0x00},
{0x05, 0x12, 0x00, 0x00, 0x3F, 0x33, 0x00, 0x00},
{0x16, 0xFF, 0x00, 0x00, 0x3C, 0x38, 0x00, 0x00},
{0x16, 0x00, 0x00, 0x00, 0x3F, 0x38, 0x00, 0x00},
{0x16, 0x01, 0xFF, 0x00, 0x3F, 0x39, 0x00, 0x00},
{0x16, 0x01, 0x0E, 0x00, 0x3F, 0x39, 0x00, 0x00},
{0x16, 0x05, 0x00, 0x00, 0x3F, 0x1F, 0x00, 0x00},
{0x16, 0x0E, 0x00, 0x00, 0x3F, 0x3B, 0x00, 0x00}
};
const ziU8 nodeHeaderTable[0x20] = {
0x00, 0x10, 0x00, 0x01, 0x00, 0x03, 0x00, 0x14, 0x00, 0x05, 0x00, 0x07,
0x00, 0x1C, 0x00, 0x0D, 0x00, 0x0F, 0x00, 0x11, 0x00, 0x13, 0x00, 0x15,
0x00, 0x17, 0x00, 0x1D, 0x00, 0x1F, 0x00, 0x35
};
ziBool Zi8PriMatchNextChar(ziU8* node, ziU8 mask0, ziU8 value0, ziU8 mask1, ziU8 value1, ziU8 mask2, ziU8 value2, ziU8 mask3, ziU8 value3, ziU16* count, ziU8** result, ziU16* code ZI_NEED_WORK) {
ziU16 remaining = *count;
while (remaining-- != 0) {
if ((value0 == (node[0] & mask0)) && (value3 == (node[3] & mask3)) && (value2 == (node[2] & mask2)) && (value1 == (node[1] & mask1))) {
*result = node;
*code = ((ziU16)node[6] << 8) + (ziU16)node[7];
*count = remaining;
Zi8LogError(0x64, ZI_WORK);
return 1;
}
node += 0xC;
}
Zi8LogError(0x12E, ZI_WORK);
return 0;
}
ziBool Zi8ExactMatchNextChar(ziU8* node, ziU8 mask0, ziU8 value0, ziU8 mask1, ziU8 value1, ziU8 mask2, ziU8 value2, ziU8 mask3, ziU8 value3, ziU16* count, ziU8** result, ziU16* code ZI_NEED_WORK) {
ziU16 remaining = *count;
ziU8* current = node;
while (remaining-- != 0) {
if ((value0 == (current[0] & mask0)) && (value3 == (current[3] & mask3)) && (value2 == (current[2] & mask2)) && (value1 == (current[1] & mask1))) {
*result = current;
*code = ((ziU16)current[6] << 8) + (ziU16)current[7];
*count = remaining;
Zi8LogError(0x64, ZI_WORK);
return 1;
}
current += 0xC;
}
Zi8LogError(0x12E, ZI_WORK);
return 0;
}
ziU32 Zi8SecMatchChar(ziPtr nodeAddress, ziU8* dictionaryAddress, ziMatchParam* match, ziU16* code ZI_NEED_WORK) {
ziBool isPartial = 0;
ziU16 matchCode;
ziU8* data;
ziU8 value;
struct {
ziU8 remaining;
ziU8 dataIndex;
ziU16 targetCode;
} state;
if (match->field22 != 0) {
state.targetCode = match->field22;
matchCode = ((ziU16)(((ziU8*)nodeAddress)[4] & 3) << 8) | ((ziU8*)nodeAddress)[5];
value = 0;
while (value++ < 6) {
if (state.targetCode == matchCode) {
break;
}
matchCode = ((ziU16)(*(dictionaryAddress + matchCode * 8 + 6) & 3) << 8) | *(dictionaryAddress + matchCode * 8 + 7);
if (matchCode == 0) {
break;
}
}
if (state.targetCode != matchCode) {
return 0;
}
}
data = (ziU8*)Zi8GetTableAddress(1, 1, ZI_WORK);
data += ((ziU8*)nodeAddress)[0xB] + (((ziU8*)nodeAddress)[0xA] << 8) + ((((ziU8*)nodeAddress)[9] & 0xF) << 16);
if (ZI_WORK->unk_0x16 != 0) {
switch (data[0] & 7) {
case 2:
data += 2;
break;
case 3:
case 4:
data += 3;
break;
case 5:
data += 4;
break;
default:
data++;
break;
}
}
value = data[0];
value = (value >> 4) & 7;
if (value * 2 + 10 < match->length) {
return 0;
}
if (match->length < 9) {
if (match->length == 8) {
if ((data[0] & 0xF) == 0xF) {
isPartial = 1;
}
} else if ((match->length & 1) != 0) {
if ((((ziU8*)nodeAddress)[match->length >> 1] & 0xF) == 0xF) {
isPartial = 1;
}
} else {
if ((((ziU8*)nodeAddress)[match->length >> 1] & 0xF0) == 0xF0) {
isPartial = 1;
}
}
if (match->length > 2) {
if ((match->length & 1) != 0) {
if (((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF0) == 0) || ((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF0) == 0xF0)) {
return 0;
}
} else {
if (((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF) == 0) || ((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF) == 0xF)) {
return 0;
}
}
}
if (code != 0) {
*code = ((ziU16)((ziU8*)nodeAddress)[6] << 8) + (ziU16)((ziU8*)nodeAddress)[7];
}
if (isPartial) {
return 2;
}
return 1;
}
if ((match->length & 1) != 0) {
if (((data[((match->length - 1) >> 1) - 4] & 0xF0) == 0) || ((data[((match->length - 1) >> 1) - 4] & 0xF0) == 0xF0)) {
return 0;
}
} else {
if (((data[((match->length - 1) >> 1) - 4] & 0xF) == 0) || ((data[((match->length - 1) >> 1) - 4] & 0xF) == 0xF)) {
return 0;
}
}
state.dataIndex = 4;
state.remaining = ((match->length + 1) >> 1) - 4;
if (((ziU8)value + 1) < (int)state.remaining) {
return 0;
}
if ((match->length & 1) != 0) {
if ((data[(match->length >> 1) - 4] & 0xF) == 0xF) {
isPartial = 1;
}
} else {
if ((data[(match->length >> 1) - 4] & 0xF0) == 0xF0) {
isPartial = 1;
}
}
if (match->count == 0) {
while (state.remaining != 0) {
if ((data[0] & match->arr1[state.dataIndex]) != match->arrD[state.dataIndex]) {
return 0;
}
state.dataIndex++;
state.remaining--;
data++;
}
}
if (code != 0) {
*code = ((ziU16)((ziU8*)nodeAddress)[6] << 8) + (ziU16)((ziU8*)nodeAddress)[7];
}
if (isPartial) {
return 2;
}
return 1;
}
ziBool Zi8PriMatchNextComp(ziU8* node, ziU8 mask0, ziU8 value0, ziU8 mask1, ziU8 value1, ziU8 mask2, ziU8 value2, ziU8 mask3, ziU8 value3, ziU16* count, ziU8** result ZI_NEED_WORK) {
ziU16 remaining = *count;
while (remaining-- != 0) {
if ((value0 == (node[0] & mask0)) && (value1 == (node[1] & mask1)) && (value2 == (node[2] & mask2)) && (value3 == (node[3] & mask3))) {
*result = node;
*count = remaining;
Zi8LogError(0x64, ZI_WORK);
return 1;
}
node += 8;
}
Zi8LogError(0x12E, ZI_WORK);
return 0;
}
ziBool Zi8SecMatchComp(ziPtr nodeAddress, ziMatchParam* matchAddress, ziPtr dictionaryAddress) {
int chainIndex;
ziU16 matchCode;
ziU16 targetCode;
if (matchAddress->field22 != 0) {
targetCode = matchAddress->field22;
matchCode = ((ziU16)(((ziU8*)nodeAddress)[6] & 3) << 8) | ((ziU8*)nodeAddress)[7];
chainIndex = 0;
while (chainIndex++ < 6) {
if (targetCode == matchCode) {
break;
}
matchCode = ((ziU16)(*((ziU8*)dictionaryAddress + matchCode * 8 + 6) & 3) << 8) | *((ziU8*)dictionaryAddress + matchCode * 8 + 7);
if (matchCode == 0) {
break;
}
}
if (targetCode != matchCode) {
return 0;
}
}
if (matchAddress->length > 8) {
if ((int)((ziU8*)nodeAddress)[5] < (int)(matchAddress->length - 2)) {
return 0;
}
} else if ((int)((ziU8*)nodeAddress)[5] < (int)(matchAddress->length - 1)) {
return 0;
}
return 1;
}
extern ziU16 Zi8MatchAltSound(ziPtr soundTable, ziU16 soundCode, ziPtr pCodeTable, ziU16 index, ziU16 mask, ziU16 value, ziU8 flag ZI_NEED_WORK);
ziU16 Zi8GetPCode(ziU8* table, ziU8* node);
ziBool Zi8MatchPhonetic(ziPtr pCodeTable, ziU8* dictionary, ziPtr soundTable, ziU16 soundCode, ziU32 tableAddress, ziU8* node, ziU16* masks, ziU16* values, ziU16* count, ziU8** resultNode, ziU8** stringOffset, ziU8 partialMode, ziU8 strictMode, ziU8 numParts, ziU16 partMask, ziU16 partValue, ziU8 flag, ziU8 altMode, ziU16 initialCode, ziU16* resultCode, ziU8 lastMode ZI_NEED_WORK) {
struct {
ziBool hasString;
ziU8 partIndex;
ziU8 partCount;
ziU8 nextCode;
ziU8 matchedParts;
ziU16 dictionaryIndex;
ziU16 soundIndex;
ziU16 remaining;
ziU16 code;
} traversal;
ziU8* sound;
typedef struct {
ziU8 header;
ziU8 content[11];
} DictionaryNode;
if (*stringOffset != 0) {
traversal.hasString = 1;
} else {
traversal.hasString = 0;
}
if (*count != 0) {
traversal.remaining = *count;
} else {
traversal.remaining = 1;
}
traversal.matchedParts = 0;
if ((lastMode != 0) && (numParts > 1)) {
altMode = 1;
}
while (traversal.remaining-- != 0) {
if ((node[0] & flag) != 0) goto decode_node;
next_node:
node += 0xC;
continue;
decode_node:
traversal.code = Zi8GetPCode((ziU8*)pCodeTable, node);
if ((*values != (traversal.code & *masks)) && (altMode == 0) && ((node[0] & 0x80) != 0)) {
if (*count != 0) {
traversal.soundIndex = (initialCode - traversal.remaining) - 1;
} else {
traversal.soundIndex = initialCode;
}
traversal.code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, traversal.soundIndex, *masks, *values, flag, ZI_WORK);
}
goto check_code;
match_code:
if (partValue == (traversal.code & partMask)) goto next_node;
traversal.matchedParts = 1;
if (*count != 0) {
traversal.soundIndex = (initialCode - traversal.remaining) - 1;
} else {
traversal.soundIndex = initialCode;
}
sound = (ziU8*)(tableAddress + ((node[9] & 0xF) * 0x10000 + (node[0xB] + node[0xA] * 0x100)));
if (ZI_WORK->unk_0x16 != 0) {
switch (sound[0] & 7) {
case 2:
sound += 2;
break;
case 3:
case 4:
sound += 3;
break;
case 5:
sound += 4;
break;
default:
sound++;
break;
}
}
if ((sound[0] & 0x80) != 0) {
sound += ((sound[0] & 0x7F) >> 4) + 1;
} else if (numParts > 1) {
goto next_node;
}
if (((ziU8)traversal.matchedParts == numParts) || (numParts == 0)) {
*resultNode = node;
*resultCode = ((ziU16)node[6] << 8) + node[7];
*count = traversal.remaining;
return 1;
}
next_group:
{
traversal.nextCode = *sound++;
traversal.partCount = traversal.nextCode & 0xF;
if ((traversal.nextCode & flag) == 0) {
for (; traversal.partCount != 0; traversal.partCount--) {
for (sound++; (*sound & 0x80) == 0; sound += 2) {
}
sound++;
}
}
for (; traversal.partCount != 0; traversal.partCount--) {
traversal.partIndex = 1;
if (traversal.hasString && (sound > *stringOffset)) {
traversal.hasString = 0;
}
if (!traversal.hasString) {
*stringOffset = sound;
}
do {
traversal.dictionaryIndex = sound[0] | ((ziU16)sound[1] << 8);
sound += 2;
if (traversal.hasString) {
goto phonetic_skip;
}
traversal.code = Zi8GetPCode((ziU8*)pCodeTable, dictionary + (traversal.dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode));
if (((traversal.code & masks[traversal.partIndex]) != values[traversal.partIndex]) && (altMode == 0) && (dictionary[(traversal.dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode)] & 0x80) != 0) {
traversal.code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, traversal.dictionaryIndex & 0x7FFF, masks[traversal.partIndex], values[traversal.partIndex], flag, ZI_WORK);
}
if ((traversal.code & masks[traversal.partIndex]) == values[traversal.partIndex]) {
goto phonetic_matched;
}
phonetic_skip:
if ((traversal.dictionaryIndex & 0x8000) == 0) {
sound++;
while ((*sound & 0x80) == 0) {
sound += 2;
}
sound++;
}
break;
phonetic_matched:
if (++traversal.partIndex == numParts) {
if (partialMode != 0) {
if (strictMode == 0 && (traversal.dictionaryIndex & 0x8000) != 0) goto phonetic_skip;
if (strictMode != 0 && (traversal.dictionaryIndex & 0x8000) == 0) goto phonetic_skip;
}
*resultNode = node;
*resultCode = ((ziU16)node[6] << 8) + node[7];
*count = traversal.remaining;
return 1;
}
} while ((traversal.dictionaryIndex & 0x8000) == 0);
}
}
if ((traversal.nextCode & 0x80) != 0) goto next_node;
goto next_group;
check_code:
if (*values == (traversal.code & *masks)) goto match_code;
goto next_node;
}
return 0;
}
ziBool Zi8GetPyFinal(ziU8* pinyin, ziU8* initial, ziU8* final);
ziU8 Zi8GetPyPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final, ziU8* resultCount, ziU16* bestInitial, ziU16* bestFinal ZI_NEED_WORK) {
ziU8 pyInitial;
ziU8 pyFinal;
ziU8 convertedCount;
ziU8 result;
ziBool partial;
ziBool alternateInitial;
ziU8 outputIndex;
ziU8 index;
ziU16 value;
ziWChar converted[256];
ziU8 pinyin[12];
ziWChar* current;
current = converted;
alternateInitial = 0;
result = 0;
*resultCount = 0;
if (count == 0) {
Zi8LogError(0x135, ZI_WORK);
return 0;
}
index = 0;
convertedCount = index;
for (; index < count; index++) {
if (((text[index] >= 0xF341) && (text[index] <= 0xF35A)) || ((text[index] >= 0x41) && (text[index] <= 0x5A))) {
if ((convertedCount != 0) && (current[convertedCount - 1] != 0xF360) && (current[convertedCount - 1] != 0x27)) {
current[convertedCount++] = 0x27;
}
current[convertedCount++] = (text[index] & 0xFF) + 0x20;
} else {
current[convertedCount++] = text[index];
}
}
count = convertedCount;
outputIndex = 0;
*bestInitial = 0;
*bestFinal = 0;
while (count != 0) {
initial[outputIndex] = 0;
final[outputIndex] = 0;
value = *current;
if (value < 0x61) {
goto check_pinyin_extension;
}
if (value <= 0x7A) {
goto pinyin_ascii;
}
check_pinyin_extension:
if (value < 0xF361) {
goto invalid_pinyin;
}
if (value <= 0xF37A) goto pinyin_extension;
invalid_pinyin:
*bestInitial = *bestFinal = initial[0] = final[0] = 0xFFFF;
return 1;
pinyin_extension:
value -= 0xF361;
goto pinyin_initial;
pinyin_ascii:
value -= 0x61;
pinyin_initial:
convertedCount = Zi8PinyinInitials[value];
if (convertedCount != 0) {
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
result++;
initial[outputIndex] = 0x7E00;
final[outputIndex] = (ziU16)(convertedCount & 0x7f) << 9;
*bestInitial = initial[0];
*bestFinal = final[0];
count--;
if (count == 0) {
break;
}
current += 1;
if ((convertedCount & 0x80) != 0) {
if (alternateInitial) {
initial[outputIndex] &= 0xfdff;
final[outputIndex] &= 0xfdff;
}
value = *current;
if (value != 0x68 && value != 0xF368) goto scan_final;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
final[outputIndex] += 0x200;
*bestInitial = initial[0];
*bestFinal = final[0];
count--;
if (count == 0) {
break;
}
current += 1;
}
} else if ((*current == 0xF369) || (*current == 0x69)) {
goto invalid_pinyin;
}
scan_final:
partial = 0;
for (index = 0; index < 4; index++) {
pinyin[index] = 0;
}
index = 0;
while (index < 4) {
value = *current;
if ((value == 0x27) || (value == 0xF360) || (value == 0x20)) {
if (index != 0) {
partial = 1;
}
goto finish_final;
}
if ((value >= 0xF331) && (value < 0xF336)) {
if (index != 0) {
partial = 1;
}
goto finish_final;
}
if ((value < 0x61) || (value > 0x7A)) {
if (value < 0xF361) {
goto finish_final;
}
value -= 0xF361;
if (value > 0x19) {
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
goto finish_final;
}
} else {
value -= 0x61;
}
pinyin[index] = (ziU8)value + 1;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) == 0) goto try_final_extension;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
current++;
index++;
count--;
if (count == 0) {
goto finish_final;
}
continue;
try_final_extension:
if (index < 3) {
pinyin[index + 1] = 0xFF;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
pinyin[index + 1] = 0;
current++;
index++;
count--;
if (count == 0) break;
} else {
pinyin[index + 1] = 0;
pinyin[index] = 0;
partial = 1;
break;
}
} else {
pinyin[index] = 0;
partial = 1;
break;
}
}
finish_final:
if ((index > 3) && (count != 0) && (((value = *current) == 0x27) || (value == 0xF360) || (value == 0x20))) {
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
current++;
count--;
}
if (index > 3) {
partial = 1;
}
if (partial && alternateInitial == 0) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
final[outputIndex] = 0x200;
}
initial[outputIndex] |= (ziU16)pyInitial << 3;
final[outputIndex] |= (ziU16)pyFinal << 3;
*bestInitial = initial[0];
*bestFinal = final[0];
} else {
if ((index != 0) && (count != 0)) {
goto invalid_pinyin;
}
}
} else {
pinyin[index] = 0xFF;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
final[outputIndex] = 0x200;
}
initial[outputIndex] |= (ziU16)pyInitial << 3;
final[outputIndex] |= (ziU16)pyFinal << 3;
*bestInitial = initial[0];
*bestFinal = final[0];
if ((outputIndex == 0) && (count == 0)) {
pinyin[index] = 0;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
*bestInitial = 0x7E00;
*bestFinal = 0x200;
}
*bestInitial |= (ziU16)pyInitial << 3;
*bestFinal |= (ziU16)pyFinal << 3;
}
}
} else {
pinyin[index] = 0;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
final[outputIndex] = 0x200;
}
initial[outputIndex] |= (ziU16)pyInitial << 3;
final[outputIndex] |= (ziU16)pyFinal << 3;
*bestInitial = initial[0];
*bestFinal = final[0];
}
}
}
if (count != 0) {
value = *current;
if ((value == 0x27) || (value == 0xF360) || (value == 0x20)) {
current++;
count--;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
} else if ((value >= 0xF331) && ((value -= 0xF331) <= 4)) {
value++;
initial[outputIndex] |= 7;
final[outputIndex] |= value;
*bestInitial = initial[0];
*bestFinal = final[0];
count--;
current++;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
if ((count != 0) && (((value = *current) == 0x27) || (value == 0xF360) || (value == 0x20))) {
count--;
current++;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
}
}
}
outputIndex++;
if (outputIndex > 0xf) break;
}
if ((result > 1) && (text[*resultCount - 1] >= 0xF341) && (text[*resultCount - 1] <= 0xF35A)) {
*resultCount = *resultCount - 1;
}
return result;
}
ziBool Zi8GetPyFinal(ziU8* pinyin, ziU8* initial, ziU8* final) {
ziU8 index = 0;
ziU8 row;
row = 0;
goto check_row;
scan_row:
while (index < 4) {
if (pinyin[index] != Zi8PinyinFinals[row][index]) {
break;
}
index++;
}
if (index < 4) {
goto next_row;
}
*initial = Zi8PinyinFinals[row][4];
*final = Zi8PinyinFinals[row][5];
return 1;
next_row:
row++;
index = 0;
check_row:
if (row < 0x36) {
goto scan_row;
}
return 0;
}
ziS32 Zi8GetBpmfPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final, ziU16* bestInitial, ziU16* bestFinal ZI_NEED_WORK) {
ziU16 value;
ziU32 resultCount = 0;
Zi8LogError(0x64, ZI_WORK);
if (count == 0) {
Zi8ReplaceLastError(0x135, ZI_WORK);
return 0;
}
value = text[0];
if (value < 0xF305) {
Zi8ReplaceLastError(0x154, ZI_WORK);
return 0;
}
value -= 0xF305;
if (value >= 0x25) {
Zi8ReplaceLastError(0x154, ZI_WORK);
return 0;
}
if (value < 0x15) {
*initial = 0x7E00;
*final = ((ziU16)Zi8BpmfInitials[value] & 0x7F) << 9;
resultCount++;
count--;
if (count == 0) {
*bestInitial = *initial;
*bestFinal = *final;
if ((value >= 0xE) && (value <= 0x14)) {
*bestInitial |= 0x1F8;
*bestFinal |= 0x38;
}
return resultCount;
}
text++;
if (*text == 0xF360) {
resultCount++;
count--;
if (count == 0) {
return resultCount;
}
Zi8ReplaceLastError(0x156, ZI_WORK);
return 0;
}
} else {
*initial = 0x7E00;
*final = 0x200;
}
value = *text - 0xF305;
switch ((ziS32)value) {
case 0x22:
goto bpmf_value_22;
case 0x23:
goto bpmf_value_23;
case 0x24:
goto bpmf_value_24;
default:
goto set_bpmf_initial;
}
bpmf_value_22:
*final |= 0x80;
*initial |= 0x180;
resultCount++;
count--;
if (count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
goto after_bpmf_initial;
bpmf_value_23:
*final |= 0x100;
*initial |= 0x180;
resultCount++;
count--;
if (count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
goto after_bpmf_initial;
bpmf_value_24:
*final |= 0x180;
*initial |= 0x180;
resultCount++;
count--;
if (count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
goto after_bpmf_initial;
set_bpmf_initial:
if ((*text < 0xF331) || (*text > 0xF335)) {
*initial |= 0x180;
}
after_bpmf_initial:
value = *text - 0xF305;
if ((value > 0x14) && (value < 0x22)) {
*final |= (ziU16)Zi8BpmfInitials[value] << 3;
*initial |= 0x78;
resultCount++;
count--;
if (count == 0) {
*bestInitial = *initial;
*bestFinal = *final;
return resultCount;
}
text++;
} else if ((*text < 0xF331) || (*text > 0xF335) || ((*initial & 0x180) == 0x180)) {
*final |= 0x38;
*initial |= 0x78;
}
value = *text;
if (value < 0xF331) {
Zi8ReplaceLastError(0x155, ZI_WORK);
return 0;
}
value -= 0xF330;
if (value > 5) {
Zi8ReplaceLastError(0x155, ZI_WORK);
return 0;
}
*initial |= 7;
*final |= value;
*bestInitial = *initial;
*bestFinal = *final;
resultCount++;
count--;
if (count != 0) {
Zi8ReplaceLastError(0x157, ZI_WORK);
return 0;
}
return resultCount;
}
ziU16 Zi8GetPCode(ziU8* table, ziU8* node) {
ziU16 index = ((ziU16)node[8] << 2) | (((ziU16)node[9] & 0x80) >> 6);
return ((((ziU16)node[9] >> 4) & 7) | (ziU16)table[index] | ((ziU16)table[index + 1] << 8));
}

View File

@@ -0,0 +1,184 @@
#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;
}
for (;;) {
entry = (ziU8*)ZI_WORK->unk_0x310;
if (entry == 0) {
Zi8LogError(0x4B3, __zi8_work_data);
return 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;
}
}
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 <= 16) {
continuation = 0;
} else {
ZI_WORK->pudCount = 1;
break;
}
}
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);
}

View File

@@ -0,0 +1,223 @@
#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 (candidate->text[position] != word->text[position]) break;
position++;
}
if (position == length) {
Zi8LogError(100, __zi8_work_data);
return 0;
}
}
previous = current;
current = current->next;
}
length = ZI_WORK->uwdCount++;
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 prefixLength;
int position, previousOffset;
ziU32 size;
ziU8 entryLanguage;
ziU32 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 <= 2 && 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) {
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;
}
{
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; currentWord[position] != 0x20 && position >= 0; position--) prefixLength++;
position++;
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 (; prefixLength > 0; prefixLength--, position++) {
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;
break;
}
}
}
}
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;
if (begin < boundary) firstSegment = 1;
else firstSegment = 0;
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 == 1 && length != 0 && continuation == 0) {
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;
}

View File

@@ -0,0 +1,215 @@
#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 & 0x7f) * 0x10000 + ((ziU32)*((ziU8*)node + 1) & 0xffff) * 0x100 + 0x8000;
offset += *((ziU8*)node + 2);
} 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 = node;
ziS32 depth;
ziS32 offset;
depth = 0;
offset = 0;
header = nodeHeaderTable[node[0] >> 4];
if ((header & 4) == 0) {
node = 0;
} else {
if ((header & 8) != 0) {
if ((node[0] & 0xf) == 0xf) {
node += 2;
} else {
node += 1;
}
if ((header & 2) != 0) {
if ((*node & 0x80) == 0) {
node += 2;
} else {
node += 3;
}
}
if ((*node & 0x80) != 0) {
node += (*node & 0x7f) * 0x10000 + (ziU32)node[1] * 0x100 +
(ziU32)node[2] + 0x8000;
} else {
node += (ziU16)*node * 0x100 + (ziU32)node[1];
}
} else {
cursor = node;
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 += 3;
offset += 3;
} else {
cursor += 2;
offset += 2;
}
}
if ((header & 4) == 0) {
depth--;
} else if ((header & 8) != 0) {
if ((*cursor & 0x80) != 0) {
cursor += 3;
offset += 3;
} else {
cursor += 2;
offset += 2;
}
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) {
return 0;
}
pair = (((ziU16)entry[2] << 8) + entry[3]);
if (pair == 0) {
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 == (ziS32)(entry[3] + ((ziU16)entry[2] << 8))) {
break;
}
entry += (entry[1] + ((ziU16)entry[0] << 8)) * 10 + 10;
if (((ziU32)entry >= end) ||
(*keys == (ziS32)(entry[3] + ((ziU16)entry[2] << 8)))) {
break;
}
}
if ((ziU32)entry >= end) {
return 0;
}
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++;
}
}
return result;
}

View File

@@ -0,0 +1,419 @@
#include <zi8clib/zierror.h>
#include <zi8clib/zitypes.h>
ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx, ziPtr workData);
ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx, ziPtr workData);
ziU8 Zi8_814813FC(ziWChar character, ziU8* result, ziU16* index, ziPtr workData) {
ziU16 i;
ziU8* table;
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 5, workData);
i = 0;
while (table[i] != 0) {
if (character == table[i]) {
*index = i;
*result = table[i];
Zi8LogError(0x64, workData);
return 1;
}
i++;
}
Zi8LogError(0x2A8, workData);
return 0;
}
ziU8 Zi8_81481E6C(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, ziPtr workData);
ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
ziPtr workData) {
struct {
ziU8 characterIndex;
ziU8 matched;
ziU8 elementIndex;
ziU16 index;
ziU16 currentCandidate;
ziU16 inputIndex;
ziU16 nextIndex;
ziU16 tableCount31;
ziU16 tableCount6;
ziU16 tableCount3;
ziU16 tableCount0;
ziU8* table31;
ziU8* table2;
ziU8* table1;
} state;
ziU16 buffer[100];
ziU8 result;
ziU16 currentCharacter;
ziU8* selectedTable;
state.nextIndex = 0;
result = 0;
state.characterIndex = 0xFF;
state.currentCandidate = params->firstCandidate;
params->letters = params->count = params->unk_0x20 = 0;
if ((argument != 0) && (*argument != 0)) {
Zi8LogError(0x7D0, workData);
return 0;
}
if ((params->elementCount == 0) || (params->elementCount > 100)) {
Zi8LogError(0x64, workData);
return 0;
}
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 4, workData);
state.table1 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 1, workData);
state.table2 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 2, workData);
state.table31 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x31, workData);
state.tableCount0 = Zi8GetTableCount(ZI8_LANG_KO, 0, workData);
state.tableCount3 = Zi8GetTableCount(ZI8_LANG_KO, 3, workData);
state.tableCount6 = Zi8GetTableCount(ZI8_LANG_KO, 6, workData);
state.tableCount31 = Zi8GetTableCount(ZI8_LANG_KO, 0x31, workData);
for (state.elementIndex = 0; state.elementIndex < params->elementCount;
state.elementIndex++) {
currentCharacter = params->elements[state.elementIndex];
if ((currentCharacter >= 0x61) && (currentCharacter <= 0x7A)) {
buffer[state.elementIndex] = state.table1[(currentCharacter - 0x61) * 2];
} else if ((currentCharacter >= 0x41) && (currentCharacter <= 0x5A)) {
buffer[state.elementIndex] = (state.table1 + (currentCharacter - 0x41) * 2)[1];
} else {
state.matched = 0;
for (; state.table2[state.matched * 3] != 0; state.matched++) {
if (currentCharacter == state.table2[state.matched * 3]) break;
}
if (state.table2[state.matched * 3] != 0) {
buffer[state.elementIndex] =
((ziU16)(state.table2 + state.matched * 3)[1] << 8) |
(state.table2 + state.matched * 3)[2];
} else {
Zi8LogError(0x161, workData);
return 0;
}
}
}
result = 0;
for (currentCharacter = 0; currentCharacter < state.elementIndex; currentCharacter++) {
if (Zi8_814813FC(buffer[currentCharacter], &state.characterIndex,
&state.inputIndex, workData) != 0) {
state.matched = Zi8_81481E6C(&state.nextIndex,
buffer + currentCharacter + 1,
state.characterIndex,
(state.elementIndex - currentCharacter) - 1,
workData);
if ((((struct __zi8_work_data_s*)workData)->unk_0x1B30 == 1)) {
switch (state.characterIndex) {
case 1:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1E, workData);
break;
case 2:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1F, workData);
break;
case 4:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x20, workData);
break;
case 7:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x21, workData);
break;
case 8:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x22, workData);
break;
case 9:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x23, workData);
break;
case 0x11:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x24, workData);
break;
case 0x12:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x25, workData);
break;
case 0x13:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x26, workData);
break;
case 0x15:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x27, workData);
break;
case 0x16:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x28, workData);
break;
case 0x17:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x29, workData);
break;
case 0x18:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x2A, workData);
break;
case 0x19:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x2B, workData);
break;
case 0x1A:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x2C, workData);
break;
case 0x1B:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x2D, workData);
break;
case 0x1C:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x2E, workData);
break;
case 0x1D:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x2F, workData);
break;
case 0x1E:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x30, workData);
break;
default:
break;
}
}
} else {
state.matched = 0;
}
if (state.matched != 0) {
if (state.tableCount6 == 0) {
state.nextIndex += state.inputIndex * state.tableCount3;
}
if (state.currentCandidate != 0) {
state.currentCandidate--;
} else {
params->candidates[(ziU8)result] =
((ziU16)selectedTable[state.nextIndex * 2] << 8) | (selectedTable + state.nextIndex * 2)[1];
if ((state.tableCount6 != 0) && (((struct __zi8_work_data_s*)workData)->unk_0x1B30 == 0)) {
params->candidates[(ziU8)result] += state.inputIndex * state.tableCount3;
}
result++;
}
if (currentCharacter == 0) {
params->count = state.matched + 1;
}
currentCharacter += state.matched;
} else {
if (state.currentCandidate != 0) {
state.index = 0;
for (; state.index < state.tableCount31; state.index++) {
if (state.table31[state.index * 3] == buffer[currentCharacter] &&
(state.table31 + state.index * 3)[1] == buffer[currentCharacter + 1]) break;
}
if (state.index == state.tableCount31) {
state.currentCandidate--;
}
if (currentCharacter == 0) {
params->count = 1;
}
} else {
for (state.index = 0; state.index < state.tableCount31; state.index++) {
if ((state.table31[(state.index * 3)] == buffer[currentCharacter]) &&
((state.table31 + state.index * 3)[1] == buffer[currentCharacter + 1])) {
if (currentCharacter == 0) {
params->count = 1;
}
params->candidates[(ziU8)result] =
state.tableCount0 + (state.table31 + state.index * 3)[2];
result++;
currentCharacter++;
break;
}
}
if (state.index == state.tableCount31) {
if ((params->candidates[(ziU8)result] = buffer[currentCharacter]) < 0xFF) {
if (currentCharacter == 0) {
params->count = 1;
}
params->candidates[(ziU8)result] += state.tableCount0;
result++;
}
}
}
}
if (result >= params->maxCandidates) {
break;
}
}
params->letters = result;
Zi8LogError(0x64, workData);
return result;
}
ziU8 Zi8_81481E6C(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, ziPtr workData) {
ziU16 nestedScratch;
ziU16 nestedIndexStorage;
ziU16 index1;
ziU16 index2;
ziU16 index3;
ziU16 index4;
ziU16 firstCharacter;
ziU16 tableCount;
ziU8 mappedCharacter;
ziU8* table;
firstCharacter = input[0];
mappedCharacter = 0xFF;
if (((struct __zi8_work_data_s*)workData)->unk_0x1B30 == 0) {
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 3, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 3, workData);
} else {
switch (type) {
case 1:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0xB, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0xB, workData);
break;
case 2:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0xC, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0xC, workData);
break;
case 4:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0xD, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0xD, workData);
break;
case 7:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0xE, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0xE, workData);
break;
case 8:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0xF, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0xF, workData);
break;
case 9:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x10, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x10, workData);
break;
case 0x11:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x11, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x11, workData);
break;
case 0x12:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x12, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x12, workData);
break;
case 0x13:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x13, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x13, workData);
break;
case 0x15:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x14, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x14, workData);
break;
case 0x16:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x15, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x15, workData);
break;
case 0x17:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x16, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x16, workData);
break;
case 0x18:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x17, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x17, workData);
break;
case 0x19:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x18, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x18, workData);
break;
case 0x1A:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x19, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x19, workData);
break;
case 0x1B:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1A, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x1A, workData);
break;
case 0x1C:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1B, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x1B, workData);
break;
case 0x1D:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1C, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x1C, workData);
break;
case 0x1E:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1D, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x1D, workData);
break;
}
}
*resultIndex = 0;
if ((count < 1) || (firstCharacter >= 0xFF)) {
return 0;
}
index1 = *resultIndex;
for (; index1 < tableCount; index1++) {
if (table[index1 * 4] >= firstCharacter) {
break;
}
}
if ((index1 >= tableCount) || (firstCharacter != table[index1 * 4])) {
return 0;
}
if ((count < 2) || ((firstCharacter = input[1]) >= 0xFF)) {
*resultIndex = index1;
return 1;
}
index2 = index1;
for (; index2 < tableCount; index2++) {
if ((table + index2 * 4)[1] >= firstCharacter) {
break;
}
}
if ((index2 >= tableCount) || (firstCharacter != (table + index2 * 4)[1]) ||
(input[0] != table[index2 * 4])) {
*resultIndex = index1;
return 1;
}
if ((count < 3) || ((firstCharacter = input[2]) >= 0xFF)) {
*resultIndex = index2;
return 2;
}
index3 = index2;
for (; index3 < tableCount; index3++) {
if ((table + index3 * 4)[2] >= firstCharacter) {
break;
}
}
if ((index3 >= tableCount) || (firstCharacter != (table + index3 * 4)[2]) ||
(input[1] != (table + index3 * 4)[1]) || (input[0] != table[index3 * 4])) {
if ((Zi8_814813FC(input[1], &mappedCharacter, &nestedScratch, workData) != 0) &&
(Zi8_81481E6C(&nestedIndexStorage, input + 2, mappedCharacter, 1, workData) != 0)) {
*resultIndex = index1;
return 1;
}
*resultIndex = index2;
return 2;
}
if ((count < 4) || ((firstCharacter = input[3]) >= 0xFF)) {
*resultIndex = index3;
return 3;
}
index4 = index3;
for (; index4 < tableCount; index4++) {
if ((table + index4 * 4)[3] >= firstCharacter) {
break;
}
}
if ((index4 >= tableCount) || (firstCharacter != (table + index4 * 4)[3]) ||
(input[2] != (table + index4 * 4)[2]) || (input[1] != (table + index4 * 4)[1]) ||
(input[0] != table[index4 * 4])) {
if ((Zi8_814813FC(input[2], &mappedCharacter, &nestedScratch, workData) != 0) &&
(Zi8_81481E6C(&nestedIndexStorage, input + 3, mappedCharacter, 1, workData) != 0)) {
*resultIndex = index2;
return 2;
}
*resultIndex = index3;
return 3;
}
if ((count < 5) || ((firstCharacter = input[4]) >= 0xFF)) {
*resultIndex = index4;
return 4;
}
if ((Zi8_814813FC(input[3], &mappedCharacter, &nestedScratch, workData) != 0) &&
(Zi8_81481E6C(&nestedIndexStorage, input + 4, mappedCharacter, 1, workData) != 0)) {
*resultIndex = index3;
return 3;
}
*resultIndex = index4;
return 4;
}

View File

@@ -0,0 +1,176 @@
#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;
ziU8 offsetLow[2];
} 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) {
int count;
int offset;
ziU8 group;
ziU8 remaining;
ziU16 value;
ziWChar* cursor;
ziSearchState search;
ziGetParam request;
ziWChar ordinals[65];
int length;
int unmatched;
ziChineseEntry* entry;
ziU8* data;
ziU8 formats[8] = {1, 5, 0, 0, 0, 0, 0, 0};
ziU32 savedFormats = ZI_WORK->unk_0x1410;
ziU8 savedCount = ZI_WORK->unk_0x1418;
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] >= 0xEFF1 || 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 {
ordinals[length] = Zi8Uni2Ord(word[length], __zi8_work_data);
if (ordinals[length] == 0xFFFF) return 0;
length++;
if (length == 64) return 0;
} while (word[length] != 0);
{
if (length == 1) return 1;
count = --length;
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[0] << 8) | entry->offsetLow[1]));
if (ZI_WORK->unk_0x16 != 0) {
switch (*data & 7) {
case 2:
offset = 2;
break;
case 3:
case 4:
offset = 3;
break;
case 5:
offset = 4;
break;
default:
offset = 1;
break;
}
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;
}
} 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) return 0;
if (key == 0) return 0xEFFA;
if (key >= 1 && key <= 9) return key + 0xEFF0;
if (key <= 31) return key + 0xEFF1;
return 0;
}

View File

@@ -3,6 +3,14 @@
extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
typedef struct {
ziU8 keyBytes[5];
ziU8 childHigh;
ziU8 childLow;
ziU8 characterHigh;
ziU8 characterLow;
} ZiKoreanKeyEntry;
ziU32 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) {
ziU32 value;
ziU16 count;
@@ -12,7 +20,7 @@ ziU32 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) {
for (i = 0; (ziU16)i < count; i++) {
value = (ziU16)(((ziU16)table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 7] << 8) |
table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 8]);
if (key == value) {
if (value == key) {
Zi8LogError(0x64, ZI_WORK);
return i;
}
@@ -91,7 +99,7 @@ ziU32 Zi8_81483308(ziGetParam* param, ziU16 key, ziU8* count ZI_NEED_WORK) {
return 0;
}
ziBool Zi8_814833F0(const ziGetParam* param, ziU16 key ZI_NEED_WORK) {
ziU32 Zi8_814833F0(const ziGetParam* param, ziU16 key ZI_NEED_WORK) {
ziU8 i;
Zi8LogError(0x64, ZI_WORK);
@@ -111,23 +119,28 @@ ziBool Zi8_814833F0(const ziGetParam* param, ziU16 key ZI_NEED_WORK) {
ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count,
ziU8* inserted ZI_NEED_WORK) {
ziBool matches;
ziS32 entry;
ziS32 tableA;
ziS32 tableB;
ziU16 tableCount;
ziU8 matched;
struct {
ziBool matches;
ziU8 candidateIndex;
ziU16 tableCount;
ziS32 compactIndex;
ZiKoreanKeyEntry* entry;
ziU8* tableB;
ziU8* tableA;
union {
ziU32 firstWord;
ziU8 bytes[5];
} keys;
} filter;
ziU32 j;
ziS32 i;
ziU8 candidateIndex;
union {
ziU32 words[13];
ziU8 bytes[52];
} local;
ziS32 candidate;
ziU8 matched;
j = 0;
filter.candidateIndex = 0;
matched = 0;
local.words[0] = 0;
local.bytes[4] = 0;
filter.keys.bytes[4] = filter.keys.firstWord = 0;
Zi8LogError(0x64, ZI_WORK);
if (param->elementCount == 0) {
if (*remaining >= *count) {
@@ -141,394 +154,354 @@ ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count,
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
for (i = 0; i < ((ziS32)*count - (ziS32)*remaining); i++) {
param->candidates[i] = param->candidates[(ziU32)*remaining + i];
param->candidates[i] = param->candidates[*remaining + i];
}
*count = *count - (ziU8)*remaining;
*count -= *remaining;
*remaining = 0;
}
return 1;
} else if (param->elementCount <= 9) {
tableA = Zi8GetTableAddress(param->language, 9, ZI_WORK);
tableB = Zi8GetTableAddress(param->language, 10, ZI_WORK);
if (tableA == 0) {
}
if (param->elementCount > 9) {
*count = 0;
return 0;
}
filter.tableA = (ziU8*)Zi8GetTableAddress(param->language, 9, ZI_WORK);
filter.tableB = (ziU8*)Zi8GetTableAddress(param->language, 10, ZI_WORK);
if (filter.tableA == 0) {
Zi8ReplaceLastError(0x76C, ZI_WORK);
return 0;
} else if (tableB == 0) {
} else if (filter.tableB == 0) {
Zi8ReplaceLastError(0x776, ZI_WORK);
return 0;
} else {
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, local.bytes);
filter.tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, filter.keys.bytes);
i = 0;
while (i < tableCount && matched < *count) {
matches = ZI8_TRUE;
entry = (i << 3) + tableA + i;
while (i < filter.tableCount && matched < *count) {
filter.matches = ZI8_TRUE;
filter.entry = (ZiKoreanKeyEntry*)&filter.tableA[(i << 3) + i];
j = 0;
if (param->elementCount > 1) {
for (j = 0; (j & 0xFF) < (ziU32)(param->elementCount >> 1); j++) {
if (local.bytes[j & 0xFF] != *((ziU8*)entry + (j & 0xFF))) {
matches = ZI8_FALSE;
for (j = 0; (int)(j & 0xFF) < (int)param->elementCount / 2; j++) {
if (filter.keys.bytes[j & 0xFF] != filter.entry->keyBytes[j & 0xFF]) {
filter.matches = ZI8_FALSE;
break;
}
}
}
if (matches && (param->elementCount & 1) != 0 &&
((local.bytes[j & 0xFF] & 0xF0) != (*((ziU8*)entry + (j & 0xFF)) & 0xF0))) {
matches = ZI8_FALSE;
if (filter.matches && (param->elementCount % 2) != 0 &&
((filter.keys.bytes[j & 0xFF] & 0xF0) != (filter.entry->keyBytes[j & 0xFF] & 0xF0))) {
filter.matches = ZI8_FALSE;
}
if (matches) {
for (candidateIndex = 0; candidateIndex < *count; candidateIndex++) {
if (param->candidates[candidateIndex] ==
(ziU16)((*((ziU8*)entry + 7) << 8) | *((ziU8*)entry + 8))) {
if (filter.matches) {
for (filter.candidateIndex = 0; filter.candidateIndex < *count; filter.candidateIndex++) {
if (param->candidates[filter.candidateIndex] ==
(((ziU16)((ZiKoreanKeyEntry*)filter.tableA)[i].characterHigh << 8) | (ziU16)((ZiKoreanKeyEntry*)filter.tableA)[i].characterLow)) {
matched++;
param->candidates[candidateIndex] =
param->candidates[candidateIndex] & 0x7FFF;
param->candidates[filter.candidateIndex] &= 0x7FFF;
break;
}
}
}
i++;
}
if ((ziU16)matched >= *remaining) {
if (matched >= *remaining) {
matched = *count;
*count = 0;
for (i = 0; i < matched; i++) {
if ((param->candidates[i] & 0x8000) == 0) {
param->candidates[i] = param->candidates[i] | 0x8000;
if (*remaining == 0) {
if (*count != i) {
param->candidates[*count] = param->candidates[i];
}
*count = *count + 1;
for (candidate = 0; candidate < matched; candidate++) {
if ((param->candidates[candidate] & 0x8000) == 0) {
param->candidates[candidate] |= 0x8000;
if (*remaining != 0) {
--*remaining;
Zi8_81483308(param, param->candidates[candidate], inserted, ZI_WORK);
} else {
*remaining = *remaining - 1;
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
if (*count != candidate) {
param->candidates[*count] = param->candidates[candidate];
}
++*count;
}
}
}
*remaining = 0;
} else {
for (i = 0; i < *count; i++) {
if ((param->candidates[i] & 0x8000) == 0) {
param->candidates[i] = param->candidates[i] | 0x8000;
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
for (filter.compactIndex = 0; filter.compactIndex < *count; filter.compactIndex++) {
if ((param->candidates[filter.compactIndex] & 0x8000) == 0) {
param->candidates[filter.compactIndex] |= 0x8000;
Zi8_81483308(param, param->candidates[filter.compactIndex], inserted, ZI_WORK);
}
}
*remaining = *remaining - (ziU16)matched;
*remaining = *remaining - matched;
*count = 0;
}
}
} else {
*count = 0;
return 0;
}
return 0;
}
ziU32 Zi8GetKOcandidates(ziGetParam* param, ziU8* options ZI_NEED_WORK) {
ziBool bVar1;
ziU8 bVar2;
ziS32 iVar4;
ziU32 uVar6;
ziU8* pbVar7;
union {
ziU32 words[10];
ziU8 bytes[40];
} local_28;
ziU8 local_57;
ziU8 local_56;
ziU8 local_55;
ziU8 local_54;
ziU8 local_53;
ziS8 local_52;
ziU16 local_50;
ziU16 local_4E;
ziU16 local_4C;
ziU16 local_4A;
ziU16 local_48;
ziS32 local_44;
ziS32 local_2C;
ziS32 local_30;
ziU32 local_34;
ziU32 local_38;
ziU32 local_3C;
ziU32 local_40;
typedef struct {
ziU8 countOnly;
ziU8 maxWordLength;
ziU8 lookupMode;
ziU8 suffixOnly;
ziU8 controls[8];
ziU32 maxCount;
ziU16 capacity;
ziU8 minWordLength;
ziU8 flags;
ziU16 candidateCapacity;
ziU8 checkOnly;
ziU8 reserved;
} ZiKoreanCandidateOptions;
local_4E = 0xFFFF;
local_34 = 0;
local_28.words[0] = 0;
local_28.bytes[4] = 0;
local_52 = 0;
local_53 = 0;
local_54 = 0;
local_55 = 0;
local_50 = param->firstCandidate;
local_3C = 0;
local_40 = 0;
local_57 = 0;
ziU32 Zi8GetKOcandidates(ziGetParam* param, ZiKoreanCandidateOptions* options ZI_NEED_WORK) {
struct {
ziBool matches;
ziU8 inserted;
ziU8 matchPass;
ziU8 keyByte;
ziU8 candidateCount;
ziU8 wordIndex;
ziU8 remainingLetters;
ziU16 remainingCandidates;
ziU16 previousIndex;
ziU16 character;
ziU16 tableCount;
ziU16 keyIndex;
ZiKoreanKeyEntry* entry;
ziS32 candidateIndex;
ziS32 prefixCount;
ziU32 wordOffset;
ziS32 resultCount;
ziS32 tableIndex;
ziU8* wordTable;
union {
ziU32 firstWord;
ziU8 bytes[5];
} packedKeys;
} search;
ziU8* keyTable;
ziU8* wordNode;
search.previousIndex = 0xFFFF;
search.resultCount = 0;
search.packedKeys.firstWord = 0;
search.packedKeys.bytes[4] = 0;
search.remainingLetters = 0;
search.wordIndex = 0;
search.candidateCount = 0;
search.keyByte = 0;
search.remainingCandidates = param->firstCandidate;
search.prefixCount = 0;
search.candidateIndex = 0;
search.inserted = 0;
Zi8LogError(100, ZI_WORK);
Zi8_81483264(param, ZI_WORK);
iVar4 = Zi8GetTableAddress(ZI8_LANG_KO, 9, ZI_WORK);
local_2C = Zi8GetTableAddress(ZI8_LANG_KO, 10, ZI_WORK);
if (iVar4 == 0) {
keyTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 9, ZI_WORK);
search.wordTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 10, ZI_WORK);
if (keyTable == 0) {
Zi8ReplaceLastError(0x76C, ZI_WORK);
uVar6 = 0;
return 0;
} else {
if (local_2C == 0) {
if (search.wordTable == 0) {
Zi8ReplaceLastError(0x776, ZI_WORK);
uVar6 = 0;
goto LAB_000114C4;
return 0;
}
if (*options == 0) {
if (options->countOnly == 0) {
param->letters = 0;
param->count = 0;
param->unk_0x20 = 0;
param->candidates[0] = 0;
}
Zi8LogError(100, ZI_WORK);
if (param->wordCharCount != 0) {
local_48 = Zi8_8148302C(param->currentWord[0], (ziU8*)iVar4, ZI_WORK);
if ((local_48 != 0xFFFF) &&
((((ziU8*)iVar4)[((ziU32)local_48 * 9) + 4] & 8) != 0)) {
local_38 = (ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 6] |
((ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 4] & 3) << 16 |
(ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 5] << 8;
local_52 = param->wordCharCount - 1;
local_53 = 1;
pbVar7 = (ziU8*)(local_2C + local_38);
LAB_00010D44:
if (local_52 != 0) {
local_48 = Zi8_8148302C(param->currentWord[local_53], (ziU8*)iVar4, ZI_WORK);
if (local_48 == (ziU16)((*pbVar7 & 0x1F) << 8 | pbVar7[1])) {
local_52 = local_52 - 1;
local_53 = local_53 + 1;
if ((*pbVar7 & 0x40) == 0) {
pbVar7 = pbVar7 + 2;
goto LAB_00010D44;
if (((search.keyIndex = Zi8_8148302C(param->currentWord[0], keyTable, ZI_WORK)) != 0xFFFF) &&
((((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->keyBytes[4] & 8) != 0)) {
search.wordOffset = ((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childLow |
((((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->keyBytes[4] & 3) << 16 |
((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childHigh << 8);
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
wordNode = search.wordTable + search.wordOffset;
match_word:
while (search.remainingLetters != 0) {
search.keyIndex = Zi8_8148302C(param->currentWord[search.wordIndex], (ziU8*)keyTable, ZI_WORK);
if (search.keyIndex == (((ziU16)*wordNode & 0x1F) << 8 | (ziU16)wordNode[1])) {
--search.remainingLetters;
++search.wordIndex;
if ((*wordNode & 0x40) != 0) {
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
break;
}
local_52 = param->wordCharCount - 1;
local_53 = 1;
wordNode += 2;
} else {
local_53 = 1;
local_52 = param->wordCharCount - 1;
search.wordIndex = 1;
search.remainingLetters = param->wordCharCount - 1;
break;
}
}
if (local_52 == 0) {
local_48 = (*pbVar7 & 0x1F) << 8 | pbVar7[1];
local_4C = (ziU16)(((ziU8*)((ziU32)local_48 * 9 + (ziU32)local_48 + (ziU32)iVar4))[7] << 8 |
((ziU8*)((ziU32)local_48 * 9 + (ziU32)local_48 + (ziU32)iVar4))[8]);
if (search.remainingLetters == 0) {
search.keyIndex = ((ziU16)*wordNode & 0x1F) << 8 | (ziU16)wordNode[1];
search.character = (ziU16)((ziU16)((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->characterHigh << 8 |
((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->characterLow);
if (param->wordCharCount == 1) {
if (local_48 == local_4E) {
for (; (*pbVar7 & 0x40) == 0; pbVar7 = pbVar7 + 2) {
if (search.keyIndex == search.previousIndex) {
for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) {
}
local_52 = param->wordCharCount;
goto LAB_00011114;
wordNode += 2;
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
goto next_word;
}
local_4E = local_48;
search.previousIndex = search.keyIndex;
if (param->elementCount == 0) {
if (local_50 == 0) {
if (*options != 0) {
local_3C = local_3C + 1;
if ((ziS32)local_3C < *(ziS32*)(options + 0xC)) {
goto LAB_000110E8;
}
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
uVar6 = param->letters;
goto LAB_000114C4;
}
if (search.remainingCandidates != 0) {
--search.remainingCandidates;
} else {
local_50 = local_50 + -1;
if (options->countOnly != 0) {
if (++search.prefixCount < (ziS32)options->maxCount) {
goto skip_word;
}
return options->maxCount;
}
param->candidates[search.candidateCount++] = search.character;
++param->unk_0x20;
if (++param->letters >= param->maxCandidates) {
return param->letters;
}
}
} else {
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
param->count = local_54;
param->letters = local_54;
if (param->maxCandidates <= local_54) {
if (*options == 0) {
uVar6 = local_54;
goto LAB_000114C4;
}
local_3C = local_3C + local_54;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_3C) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->count = 0;
param->candidates[search.candidateCount++] = search.character;
++param->unk_0x20;
if (++param->letters >= param->maxCandidates) {
Zi8_814834AC(param, &search.remainingCandidates, &search.candidateCount, &search.inserted, ZI_WORK);
param->unk_0x20 = search.candidateCount;
param->letters = search.candidateCount;
if (search.candidateCount < param->maxCandidates) goto skip_word;
if (options->countOnly != 0) {
if ((search.prefixCount += search.candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
param->unk_0x20 = 0;
param->letters = 0;
local_54 = 0;
search.candidateCount = 0;
} else {
return search.candidateCount;
}
}
}
} else {
for (local_40 = 0;
(local_40 < local_54 &&
(local_4C != param->candidates[local_40]));
local_40 = local_40 + 1) {
for (search.candidateIndex = 0; search.candidateIndex < search.candidateCount; search.candidateIndex++) {
if (search.character == param->candidates[search.candidateIndex]) break;
}
if ((local_40 == local_54) &&
(Zi8_814833F0(param, local_4C, ZI_WORK) == 0)) {
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (bVar2 < param->maxCandidates) {
goto LAB_000110E8;
if ((search.candidateIndex == search.candidateCount) &&
(Zi8_814833F0(param, search.character, ZI_WORK) == 0)) {
param->candidates[search.candidateCount++] = search.character;
++param->unk_0x20;
if (++param->letters < param->maxCandidates) {
goto skip_word;
}
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
param->count = local_54;
param->letters = local_54;
if (param->maxCandidates <= local_54) {
if (*options == 0) {
uVar6 = local_54;
goto LAB_000114C4;
}
local_3C = local_3C + local_54;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_3C) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->count = 0;
Zi8_814834AC(param, &search.remainingCandidates, &search.candidateCount, &search.inserted, ZI_WORK);
param->unk_0x20 = search.candidateCount;
param->letters = search.candidateCount;
if (search.candidateCount < param->maxCandidates) goto skip_word;
if (options->countOnly != 0) {
if ((search.prefixCount += search.candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
param->unk_0x20 = 0;
param->letters = 0;
local_54 = 0;
search.candidateCount = 0;
} else {
return search.candidateCount;
}
}
}
}
LAB_000110E8:
for (; (*pbVar7 & 0x40) == 0; pbVar7 = pbVar7 + 2) {
skip_word:
for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) {
}
local_52 = param->wordCharCount;
LAB_00011114:
local_52 = local_52 + -1;
local_53 = 1;
pbVar7 = pbVar7 + 2;
if ((*pbVar7 & 0x80) != 0) {
goto LAB_00011124;
wordNode += 2;
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
next_word:
if ((*wordNode & 0x80) != 0) {
goto search_table;
}
goto LAB_00010D44;
goto match_word;
}
}
LAB_00011124:
local_34 = local_3C;
if (local_54 != 0) {
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
uVar6 = local_34;
if ((*options != 0) &&
(local_3C = local_3C + local_54, uVar6 = local_3C,
*(ziS32*)(options + 0xC) <= (ziS32)local_3C)) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
search_table:
search.resultCount = search.prefixCount;
if (search.candidateCount != 0) {
Zi8_814834AC(param, &search.remainingCandidates, &search.candidateCount, &search.inserted, ZI_WORK);
if (options->countOnly != 0) {
if ((search.prefixCount += search.candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
search.resultCount = search.prefixCount;
}
local_34 = uVar6;
param->count = local_54;
param->letters = local_54;
param->unk_0x20 = search.candidateCount;
param->letters = search.candidateCount;
}
if (param->elementCount < 10) {
if ((param->elementCount == 0) || (*options != 0)) {
local_56 = 1;
if (param->elementCount > 9) {
param->letters = 0;
return 0;
}
{
if (param->elementCount != 0 && options->countOnly == 0) {
search.matchPass = 0;
} else {
local_56 = 0;
search.matchPass = 1;
}
local_4A = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, local_28.bytes);
search.tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, search.packedKeys.bytes);
do {
for (local_30 = 0; local_30 < (ziS32)(ziU32)local_4A; local_30 = local_30 + 1) {
bVar1 = ZI8_TRUE;
local_44 = iVar4 + local_30 * 9;
local_55 = 0;
for (search.tableIndex = 0; search.tableIndex < search.tableCount; search.tableIndex = search.tableIndex + 1) {
search.matches = ZI8_TRUE;
search.entry = (ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable);
search.keyByte = 0;
if (1 < param->elementCount) {
for (local_55 = 0;
(ziU32)local_55 < (ziU32)((ziS32)(ziU32)param->elementCount >> 1);
local_55 = local_55 + 1) {
if (local_28.bytes[local_55] != *(ziU8*)(local_44 + local_55)) {
bVar1 = ZI8_FALSE;
for (search.keyByte = 0;
(ziS32)search.keyByte < (int)param->elementCount / 2;
search.keyByte++) {
if (search.packedKeys.bytes[search.keyByte] != search.entry->keyBytes[search.keyByte]) {
search.matches = ZI8_FALSE;
break;
}
}
}
if ((bVar1 && ((param->elementCount & 1) != 0)) &&
((local_28.bytes[local_55] & 0xF0) !=
(*(ziU8*)(local_44 + local_55) & 0xF0))) {
bVar1 = ZI8_FALSE;
if ((search.matches && ((param->elementCount % 2) != 0)) &&
((search.packedKeys.bytes[search.keyByte] & 0xF0) !=
(search.entry->keyBytes[search.keyByte] & 0xF0))) {
search.matches = ZI8_FALSE;
}
if (bVar1) {
bVar2 = local_56;
if ((param->elementCount & 1) == 0) {
if ((*(ziU8*)(local_44 + local_55) & 0xF0) == 0) {
if (local_56 == 0) {
goto LAB_000113B0;
}
bVar2 = *options;
}
if (bVar2 == 0) {
goto LAB_00011478;
if (search.matches) {
if (param->elementCount % 2 != 0) {
if ((search.entry->keyBytes[search.keyByte] & 0xF) != 0) {
if (search.matchPass == 0) goto next_entry;
} else if (search.matchPass != 0 && options->countOnly == 0) {
goto next_entry;
}
} else {
if ((*(ziU8*)(local_44 + local_55) & 0xF) != 0) {
goto LAB_000113AC;
}
if (local_56 != 0) {
bVar2 = *options;
goto LAB_000113AC;
if ((search.entry->keyBytes[search.keyByte] & 0xF0) != 0) {
if (search.matchPass == 0) goto next_entry;
} else if (search.matchPass != 0 && options->countOnly == 0) {
goto next_entry;
}
}
LAB_000113AC:
if (bVar2 == 0) {
goto LAB_00011478;
}
LAB_000113B0:
if (local_50 == 0) {
if (*options == 0) {
param->candidates[local_54] =
(ziU16)((*(ziU8*)(local_30 * 9 + iVar4 + 7) << 8) |
*(ziU8*)(local_30 * 9 + iVar4 + 8));
local_54 = local_54 + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
uVar6 = param->letters;
goto LAB_000114C4;
}
} else {
local_34 = local_34 + 1;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_34) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
}
if (search.remainingCandidates != 0) {
--search.remainingCandidates;
} else if (options->countOnly != 0) {
if (++search.resultCount >= (ziS32)options->maxCount) return options->maxCount;
} else {
local_50 = local_50 + -1;
param->candidates[search.candidateCount++] =
(ziU16)((ziU16)((ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable))->characterHigh << 8 |
((ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable))->characterLow);
if (++param->letters >= param->maxCandidates) return param->letters;
}
}
LAB_00011478:
next_entry:
;
}
local_56 = local_56 + 1;
} while (local_56 < 2);
uVar6 = local_34;
if (*options == 0) {
uVar6 = param->letters;
}
} else {
param->letters = 0;
uVar6 = 0;
} while (++search.matchPass < 2);
}
if (options->countOnly != 0) return search.resultCount;
return param->letters;
}
LAB_000114C4:
return uVar6;
return 0;
}

View File

@@ -0,0 +1,214 @@
#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) {
ziU16 tableCount;
ziU8 numKeys;
ziU8* dataAddress;
ziUserKeyMap* customTable;
ziU16 charCount;
ziU16 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;
}
tableCount = 0;
keyIndex = tableCount;
for (; (ziU16)keyIndex < key; keyIndex++) {
tableCount += dataAddress[(ziU16)keyIndex];
}
if ((charCount = (ziU8)dataAddress[key]) == 0) {
return 0;
}
dataAddress = dataAddress + numKeys + (tableCount * 2);
keyIndex = 0;
for (; (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;
}

View File

@@ -0,0 +1,82 @@
#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;
ziS32 index;
ziU32 position;
ziU32 fallback = 0;
if (!continuation) ZI_WORK->oemIdx = 0;
index = ZI_WORK->oemIdx;
if ((ziS32)index >= ZI_WORK->oemLen) goto failed;
if (ZI_WORK->oemMatch == 0) goto failed;
capacity--;
if ((ziS32)length >= (ziS32)capacity) {
failed:
return 0;
}
word[capacity] = 0;
if (complete) word[length] = 1; else word[length] = 0;
goto matchRetry;
posEntry:
position = 0;
if ((complete && word[length] == 0) || (!complete && word[length] != 0)) {
for (; (ziS32)position < length; position++) {
if (pattern[position] >= 0xEFF1 && pattern[position] <= 0xF37F) {
if (pattern[position] == Zi8ConvertWC2Key(word[position], language, __zi8_work_data)) continue;
break;
} else 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;
}
}
}
if ((ziS32)position < length) {
if (complete) word[length] = 1; else word[length] = 0;
index++;
if ((ziS32)index >= ZI_WORK->oemLen) goto oemFailed;
goto matchRetry;
}
if (fallback) {
index = 0;
*word = *pattern;
return 1;
}
index++;
ZI_WORK->oemIdx = index;
while (word[position] != 0) position++;
return position;
matchRetry:
if ((ziS32)index >= ZI_WORK->oemLen) goto oemFailed;
if (!ZI_WORK->oemMatch(index, word, capacity, ZI_WORK->oemData)) goto oemFailed;
goto posEntry;
oemFailed:
if (length != 1 || !complete || continuation) goto tail0;
complete = 0;
fallback = 1;
index = 0;
goto matchRetry;
tail0:
return 0;
}

View File

@@ -0,0 +1,336 @@
#include <zi8clib/zitypes.h>
void Zi8Memset(ziPtr, ziU32, ziU32);
void Zi8Memcpy(ziPtr, ziPtr, ziU32);
ziBool Zi8IsComponent(ziWChar ZI_NEED_WORK);
ziU32 Zi8GetTableAddress(ziU8, ziU8 ZI_NEED_WORK);
ziU16 Zi8GetTableCount(ziU8, ziU8 ZI_NEED_WORK);
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) {
ziU16 element;
ziU16 phoneticCount;
ziU16 phoneticInitial;
ziU16 phoneticMask;
ziU16 phoneticCode;
ziU16 phoneticLength;
ziWChar initial;
ziWChar final;
ziWChar bestInitial;
ziWChar bestFinal;
ziWChar previousInitial;
ziWChar previousFinal;
ziU8 elementCount;
ziU8 elementIndex;
ziU8 stroke;
ziU8 contextMask;
ziU8 mode;
ziU8 savedNibbles;
struct {
ziWChar* phoneticInput;
ziU8* phoneticTable;
ziU8 strokePrefix[4];
ziU8 maskPrefix[4];
ziU8* componentIndex;
ziU8* component;
ziU8 strokes[12];
ziU8 masks[12];
} buffers;
ziU8 nibbles;
ziU8 index;
stroke = 0;
contextMask = 0x20;
Zi8Memset(match,0,0x1ee);
nibbles = 0;
elementIndex = 0;
elementCount = request->elementCount;
while (elementCount != 0) {
if (request->elements[elementCount - 1] != 0xEF09) break;
elementCount--;
}
match->count = elementCount;
for (index = 0; index < elementCount; index++) {
if (request->elements[index] != 0xEF00) {
match->count = 0;
break;
}
}
if (elementCount != 0) {
match->comp = element = request->elements[0];
if (Zi8IsComponent(element,__zi8_work_data) != 0) {
elementIndex++;
buffers.component = (ziU8*)Zi8GetTableAddress(1,2,__zi8_work_data);
buffers.componentIndex = (ziU8*)Zi8GetTableAddress(1,6,__zi8_work_data);
buffers.componentIndex += (element - 0xef10) * 2;
match->field22 = (((ziU16)buffers.componentIndex[1] & 0x3f) << 8) + *buffers.componentIndex;
buffers.component += (ziU32)match->field22 * 8;
switch(*buffers.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 (index = 0; index < (buffers.component[5] >> 1) + 1; index++) {
if (index < 4) {
match->arrD[index] = buffers.component[index];
match->arr1[index] = 0xff;
}
}
if ((index != 0) && ((buffers.component[5] & 1) == 0)) {
index--;
match->arrD[index] &= 0xf0;
match->arr1[index] &= 0xf0;
}
nibbles = (ziU8)(buffers.component[5] + 1);
if (8 < nibbles) {
nibbles++;
}
}
}
match->arr1[0] &= 0xf;
match->arrD[0] &= 0xf;
if (skipMode == '\0') {
mode = 0;
if ((request->subLanguage & 0x80) != 0 || (request->subLanguage & 0x40) != 0) {
mode = 1;
} else if ((request->subLanguage & 8) != 0) {
mode = 4;
} else if ((request->subLanguage & 0x20) != 0 || (request->subLanguage & 0x10) != 0) {
mode = 2;
}
if (mode == 0) {
mode = request->subLanguage;
}
switch (mode) {
case 1:
case 2:
case 4:
match->arr1[0] |= (ziU8)(mode << 4);
match->arrD[0] |= (ziU8)(mode << 4);
break;
}
}
if (nibbles == 0) {
nibbles = 1;
}
if (((request->getMode == '\0') || (request->getMode == '\x10')) ||
(request->getMode == '\x05')) {
Zi8Memcpy(buffers.masks,match->arr1,0xc);
Zi8Memcpy(buffers.strokes,match->arrD,0xc);
do {
while (elementIndex < elementCount) {
element = request->elements[elementIndex++];
switch (element) {
case 0xef02: stroke = 0; break;
case 0xef04: stroke = 1; break;
case 0xef01: stroke = 2; break;
case 0xef07: stroke = 3; break;
case 0xef06: stroke = 4; break;
case 0xef03: stroke = 5; break;
case 0xef05: stroke = 6; break;
case 0xef08: stroke = 7; break;
case 0xef0b: stroke = 8; break;
case 0xef0a: stroke = 4; break;
case 0xf360: stroke = 0xff; break;
default: stroke = 0; break;
}
if (stroke == 0xff) break;
if (0x17 < nibbles) {
match->length = 0x18;
return 0;
}
if (nibbles == 8) {
nibbles++;
}
if ((nibbles & 1) != 0) {
buffers.strokes[nibbles >> 1] |= stroke;
if (element == 0xef0b) {
buffers.masks[nibbles >> 1] |= 8;
}
else if (element == 0xef0a) {
buffers.masks[nibbles >> 1] |= 4;
}
else if (element != 0xef00) {
buffers.masks[nibbles >> 1] |= 7;
}
} else {
buffers.strokes[nibbles >> 1] |= stroke << 4;
if (element == 0xef0b) {
buffers.masks[nibbles >> 1] |= 0x80;
}
else if (element == 0xef0a) {
buffers.masks[nibbles >> 1] |= 0x40;
}
else if (element != 0xef00) {
buffers.masks[nibbles >> 1] |= 0x70;
}
}
nibbles++;
}
savedNibbles = nibbles;
for (index = 0; index < 4; index++) {
buffers.maskPrefix[index] = buffers.masks[index];
buffers.strokePrefix[index] = buffers.strokes[index];
}
if ((1 < nibbles) && (nibbles < 8)) {
index = nibbles >> 1;
if ((nibbles & 1) != 0) {
buffers.maskPrefix[index] = buffers.maskPrefix[index] | 0xf;
buffers.strokePrefix[index] = buffers.strokePrefix[index] | 0xf;
} else {
buffers.maskPrefix[index] = buffers.maskPrefix[index] | 0xf0;
buffers.strokePrefix[index] = buffers.strokePrefix[index] | 0xf0;
}
}
if (match->nSeg == 0) {
Zi8Memcpy(match->arr1,buffers.masks,0xc);
Zi8Memcpy(match->arrD,buffers.strokes,0xc);
Zi8Memcpy(match->arr19,buffers.maskPrefix,4);
Zi8Memcpy(match->arr1D,buffers.strokePrefix,4);
match->length = savedNibbles;
}
Zi8Memcpy((ziU8 (*)[12])match->segs1 + match->nSeg,buffers.masks,0xc);
Zi8Memcpy((ziU8 (*)[12])match->segsD + match->nSeg,buffers.strokes,0xc);
match->nSeg++;
if (stroke != 0xff || elementIndex >= elementCount || match->nSeg >= 0x10) goto complete;
Zi8Memset(buffers.masks,0,0xc);
Zi8Memset(buffers.strokes,0,0xc);
buffers.masks[0] = match->arr1[0] & 0xf0;
buffers.strokes[0] = match->arrD[0] & 0xf0;
nibbles = 1;
} while (1);
}
match->length = nibbles;
if (elementCount != 0) {
if ((request->getMode == '\x01') || (request->getMode == '\f')) {
buffers.phoneticTable = (ziU8*)Zi8GetTableAddress(1,3,__zi8_work_data);
phoneticCount = Zi8GetTableCount(1,3,__zi8_work_data);
}
else {
buffers.phoneticTable = (ziU8*)Zi8GetTableAddress(1,4,__zi8_work_data);
phoneticCount = Zi8GetTableCount(1,4,__zi8_work_data);
}
if ((request->getMode == '\x01') || (request->getMode == '\f')) {
match->nCand = Zi8GetPyPhonetic(request->elements,elementCount,match->phon,match->phon2,
&request->count,&match->first,&match->first2,__zi8_work_data);
}
else {
initial = 0;
final = 0;
bestInitial = 0;
bestFinal = 0;
previousInitial = 0;
previousFinal = 0;
buffers.phoneticInput = request->elements;
match->nCand = 0;
request->count = request->elementCount;
phoneticLength = 1;
for (index = 0; index < elementCount; index++) {
stroke = Zi8GetBpmfPhonetic(buffers.phoneticInput,phoneticLength,&initial,&final,&bestInitial,&bestFinal,
__zi8_work_data);
if (stroke != 0) {
previousInitial = bestInitial;
previousFinal = bestFinal;
savePhonetic:
match->phon[match->nCand] = initial;
match->phon2[match->nCand] = final;
if (match->nCand == 0) {
match->first = bestInitial;
match->first2 = bestFinal;
}
}
else {
if ((index == 0) ||
((((1 < phoneticLength && (buffers.phoneticInput[phoneticLength - 2] == 0xF360)) &&
(buffers.phoneticInput[phoneticLength - 1] == 0xF360)) ||
(++match->nCand == 0x10)))) {
initial = 0xffff;
final = 0xffff;
bestInitial = 0xffff;
bestFinal = 0xffff;
match->nCand = 0;
break;
}
if (buffers.phoneticInput[phoneticLength - 1] == 0xF360) {
match->nCand--;
bestInitial = previousInitial;
bestFinal = previousFinal;
final = bestFinal;
initial = bestInitial;
goto savePhonetic;
}
if (match->nCand == 1) {
request->count = phoneticLength - 1;
}
buffers.phoneticInput = buffers.phoneticInput + phoneticLength - 1;
phoneticLength = 0;
index--;
}
phoneticLength++;
}
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++;
}
}
if (((request->context & contextMask) != 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 > 1) {
phoneticInitial = match->phon[match->nCand - 1] & 0xfff8;
phoneticMask = match->phon2[match->nCand - 1] & 0xfff8;
}
else {
phoneticInitial = match->phon[0] & 0xfff8;
phoneticMask = match->phon2[0] & 0xfff8;
}
for (phoneticLength = 0; phoneticLength < phoneticCount; phoneticLength++) {
phoneticCode = buffers.phoneticTable[phoneticLength * 2] | ((ziU16)buffers.phoneticTable[phoneticLength * 2 + 1] << 8);
if (phoneticMask == (phoneticCode & phoneticInitial)) break;
}
if (phoneticLength == phoneticCount) {
match->phon[0] = 0xFFFF;
match->phon2[0] = 0xFFFF;
}
}
}
complete:
return 1;
}

View File

@@ -0,0 +1,53 @@
#ifndef PF_FA_PDM_H
#define PF_FA_PDM_H
#include <private/vf/PrFILE2/dskmng/pdm_types.h>
typedef struct PDM_PARTITION PDM_PARTITION;
typedef struct PDM_CALLBACK {
void (*insert)(PDM_PARTITION*);
void (*eject)(PDM_PARTITION*);
} PDM_CALLBACK;
struct PDM_PARTITION {
pf_u32 status;
PDM_DISK* p_disk;
pf_u32 part_id;
pf_u32 start_sector;
pf_u32 total_sector;
pf_s32 driver_last_error;
pf_u32 lock_state[2];
PDM_CALLBACK callbacks;
};
struct PDM_DISK {
pf_u32 status;
PDM_DISK_TBL disk_tbl;
pf_s16 init_count;
pf_s16 mount_count;
PDM_DISK* lock_handle;
pf_u32 lock_count;
PDM_DISK_INFO disk_info;
PDM_PARTITION* p_cur_part;
};
typedef struct PDM_DISK_SET {
pf_u16 num_partition;
pf_u16 num_allocated_disk;
PDM_DISK disk[26];
PDM_PARTITION partition[26];
} PDM_DISK_SET;
extern PDM_DISK_SET pdm_disk_set;
extern PDM_DISK_TBL pdm_drv_tbl[26];
void pdm_part_set_driver_error_code(PDM_PARTITION*, pf_s32);
void pdm_part_set_change_media_state(PDM_DISK*, pf_bool);
pf_s32 pdm_disk_convert_sector_into_block(PDM_DISK*, pf_u32, pf_u32, pf_u32, pf_u32*, pf_u32*);
pf_s32 pdm_disk_convert_block_into_sector(PDM_DISK*, pf_u32, pf_u32, pf_u32, pf_u32*, pf_u32*);
pf_s32 pdm_disk_add_disk(PDM_INIT_DISK*, PDM_DISK**);
pf_s32 pdm_disk_del_disk(PDM_DISK*);
pf_s32 pdm_disk_set_disk(PDM_DISK*, PDM_PARTITION*);
pf_s32 pdm_disk_get_media_attribute(PDM_DISK*, PDM_DISK_INFO*);
pf_s32 pdm_disk_get_media_bps(PDM_DISK*, pf_u16*);
pf_s32 pdm_disk_init(PDM_DISK*);
pf_s32 pdm_disk_mount(PDM_DISK*);
pf_s32 pdm_disk_format(PDM_DISK*, const pf_u8*);
pf_s32 pdm_disk_physical_read(PDM_DISK*, pf_u8*, pf_u32, pf_u32, pf_u32, pf_u32*);
pf_s32 pdm_disk_physical_write(PDM_DISK*, const pf_u8*, pf_u32, pf_u32, pf_u32, pf_u32*);
pf_s32 pdm_disk_unmount(PDM_DISK*, pf_u32);
pf_s32 pdm_disk_finalize(PDM_DISK*);
#endif

View File

@@ -0,0 +1,39 @@
#ifndef FA_PF_KERNEL_H
#define FA_PF_KERNEL_H
#include <revolution/os.h>
typedef struct PFK_TASK_CONFIG {
void* (*entry)(void*);
void* argument;
u32 stack_size;
void* stack;
s32 priority;
OSThread* thread;
} PFK_TASK_CONFIG;
typedef struct PFK_MAILBOX_CONFIG {
OSMessageQueue* queue;
OSMessage* messages;
s32 count;
} PFK_MAILBOX_CONFIG;
typedef struct PFK_SEMAPHORE_CONFIG {
u32 initial_count;
u32 maximum_count;
OSSemaphore* semaphore;
} PFK_SEMAPHORE_CONFIG;
s32 pfk_create_task(PFK_TASK_CONFIG* config);
s32 pfk_start_task(s32 task_id);
s32 pfk_get_task_id(s32* task_id);
s32 pfk_set_task_priority(s32 task_id, s32 priority);
s32 pfk_create_mailbox(PFK_MAILBOX_CONFIG* config);
s32 pfk_receive_message(s32 mailbox, OSMessage* message);
s32 pfk_send_message(s32 mailbox, OSMessage message);
s32 pfk_create_semaphore(PFK_SEMAPHORE_CONFIG* config);
s32 pfk_delete_semaphore(s32 semaphore);
s32 pfk_get_semaphore(s32 semaphore);
s32 pfk_release_semaphore(s32 semaphore);
#endif

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