Compare commits

..

155 Commits

Author SHA1 Message Date
coah
a306fae5c9 chore: remove agent handoff material now that the decompilation is complete (#1379) 2026-10-09 15:49:55 -05:00
coah
6941513d15 cleanup(nup,revoex,sdk): names, gotos, volatile and unused pragmas (worker 1262edba) (#1378) 2026-10-09 15:03:53 -05:00
coah
ea0d6a66d0 cleanup(ezitext): structure 54 decompiler gotos, drop volatile locals (worker 8017758e) (#1377) 2026-10-09 14:55:50 -05:00
coah
a764ab3331 cleanup(chansvm): typed buffers and names (worker 4b37bd69) (#1376) 2026-10-09 14:54:26 -05:00
coah
3b4748da31 cleanup(system,aoss,aterm): AOSS gotos, unused locals, content-count names (worker a6f4c4b7) (#1375) 2026-10-09 14:53:01 -05:00
coah
42edf4032b cleanup(system,scene,bs2): drop volatile casts and decompiler gotos (worker aaadedee) (#1374) 2026-10-09 14:51:33 -05:00
coah
112de090e3 cleanup(bte): split chained assignments, drop inactive config defaults (worker fd3ae621) (#1373) 2026-10-09 14:49:57 -05:00
coah
a2c1cf9c2c cleanup(sdk): wad/fs/usb/ipc/sc/es names, gotos and redundant initializers (worker 0e11525f) (#1372) 2026-10-09 14:48:33 -05:00
coah
f7a0d5b746 cleanup(jpeg): name TMC_JPEG fields and decoder parameters (worker e0c6e69a) (#1371) 2026-10-09 14:45:38 -05:00
coah
8a67b68cf2 docs(agents): record completion state and cleanup-phase policy (#1370) 2026-10-09 14:29:33 -05:00
coah
04d3d1e87d decomp(jpeg): TMCJPEGDEC_err_restart in C (last asm placeholder removed) (worker 25aed309) (#1369) 2026-10-09 14:28:11 -05:00
coah
7a44876cbd decomp(system): warning_run in C (asm placeholder removed) (worker d00a2f20) (#1368) 2026-10-09 14:19:16 -05:00
coah
c628bab36c cleanup(nandsd,esmisc): structured control flow replaces decompiler gotos (worker 76b2d600) (#1367) 2026-10-09 13:27:35 -05:00
coah
ed6f7f6fa5 decomp(cntcache): CNTCACHEClear in C (asm placeholder removed) (worker f91deefd) (#1366) 2026-10-09 13:22:41 -05:00
coah
be309e8f72 cleanup: bannerSound, homebutton, iplwww, layout, sound (worker 70f270c3) (#1365) 2026-10-09 13:16:33 -05:00
coah
f0b3637abe cleanup: RVL SDK (gotos, comma conditions, placeholders) (worker 389d53b9) (#1364) 2026-10-09 13:15:20 -05:00
coah
bc3fd4fe0b cleanup: cleanup2-x8 (gotos, comma conditions, placeholders) (worker cd20e275) (#1363) 2026-10-09 13:13:55 -05:00
coah
f6280e83d3 cleanup: cleanup2-x7 (gotos, comma conditions, placeholders) (worker a2251cc4) (#1362) 2026-10-09 13:12:42 -05:00
coah
c1867e6aa8 cleanup: cleanup2-x9 (gotos, comma conditions, placeholders) (worker a40ed3aa) (#1361) 2026-10-09 13:11:29 -05:00
coah
8f655e0ff6 cleanup: RevoEX (gotos, comma conditions, placeholders) (worker 907584d0) (#1360) 2026-10-09 13:10:05 -05:00
coah
c8b2789812 cleanup: name placeholder struct members in headers (worker 6bc18d30) (#1359) 2026-10-09 13:08:40 -05:00
coah
bdf061817b cleanup(bte): name HCI/UUSB vendorId productId taskId (from #940) (worker 2a498b56) (#1358) 2026-10-09 13:06:20 -05:00
coah
59961aa6a4 fix(jpeg): subtract the column in restart fallback result (#1355) 2026-10-09 13:03:50 -05:00
coah
5ee2a2ee3a cleanup: eZiText (gotos, comma conditions) (worker 0c4d6a91) (#1357) 2026-10-09 13:02:35 -05:00
coah
ec965ad591 cleanup: Bluetooth stack (BTE names, comma conditions) (worker 654140d7) (#1356) 2026-10-09 13:00:42 -05:00
coah
d14d33d0b5 cleanup: src/system and src/utility (gotos, comma conditions, placeholders) (worker 223c077f) (#1354) 2026-10-09 12:59:15 -05:00
coah
8e47db4a27 cleanup: NandSDWorker and ESMisc (gotos, comma conditions) (worker 7a56f54f) (#1353) 2026-10-09 12:57:46 -05:00
coah
2bdc63eab7 fix(checker): enforce section coverage and strict assembly inventory (#1351) 2026-10-09 12:57:16 -05:00
coah
f2006bdd15 cleanup: scenes a-m (gotos, comma conditions, placeholders) (worker 9aa2301a) (#1352) 2026-10-09 12:55:56 -05:00
coah
164de9ceaf decomp(savedata): hasChannel in C (asm placeholder removed) (worker d968b5f2) (#1350) 2026-10-09 12:54:44 -05:00
coah
c3dd1c08c0 cleanup: cleanup2-w6 (gotos, comma conditions, placeholders) (worker 21283535) (#1349) 2026-10-09 12:53:00 -05:00
coah
d5b07803ff cleanup: cleanup2-w5 (gotos, comma conditions, placeholders) (worker 41aa2969) (#1348) 2026-10-09 12:51:47 -05:00
coah
2b4de43971 cleanup: cleanup2-w4 (gotos, comma conditions, placeholders) (worker f8aeb05a) (#1347) 2026-10-09 12:50:34 -05:00
coah
ab9cdd32e1 cleanup: scenes n-z (gotos and comma conditions) (worker 878c30ab) (#1346) 2026-10-09 12:49:03 -05:00
coah
d83fa089e2 cleanup: wad and fs (gotos, dead initializers, casts, named fields) (worker 26f63cb3) (#1345) 2026-10-09 12:46:55 -05:00
coah
aed62d8530 cleanup: CHANSVm, AOSS, CardSequence (typed sizes/offsets, goto and comma removal) (worker 0a69c79c) (#1344) 2026-10-09 12:36:38 -05:00
coah
85d653b0db cleanup: Setting, KitayamaTest, AddressEdit (58 gotos, a pragma), snd_AxManager (worker 5a3e2e70) (#1343) 2026-10-09 12:30:46 -05:00
coah
bf4d1c8130 cleanup: SD scenes and ChannelTitle (comma operators, duplicates, a pragma) (worker 8ff09cff) (#1342) 2026-10-09 12:29:47 -05:00
coah
8a0c882d14 cleanup: ChannelManager, SaveDataManager, Board, Utility (dead code, gotos, comma expressions) (worker df3786ff) (#1341) 2026-10-09 12:28:36 -05:00
coah
361763ad3e cleanup: kbd_lib locals, sd_drv init pragma removed, document remaining SDK/JPEG pragmas (worker cea42b3a) (#1340) 2026-10-09 12:27:08 -05:00
coah
3c8503a947 cleanup: volatile DVD state views instead of casts; document remaining workarounds (worker 810b458d) (#1339) 2026-10-09 12:25:44 -05:00
coah
5cc6dd1a4e cleanup(keyboard): document required Hangul stub, rename stand-in and zero local, drop glyphBottom temp (worker ffc2272c) (#1338) 2026-10-09 12:20:03 -05:00
coah
f1db6b656e fix(checker): aggregate fuzzy f32 rounding when fully matched (worker 375e94d4) (#1337) 2026-10-09 12:10:09 -05:00
coah
c8c8a71e22 decomp(tistring): match inputChar and link tiString (last function) (worker b9cb2697) (#1336) 2026-10-09 12:07:31 -05:00
coah
f7f36d59f8 decomp: pair array destructor, name StandData, real Queue push/pop (section scores 100%) (worker 674f53ed) (#1335) 2026-10-09 09:27:07 -05:00
coah
f1d824acd9 refactor(tistring): structured mode dispatch in inputChar (bytes identical) (worker 475dbc53) (#1334) 2026-10-09 09:21:12 -05:00
coah
f393788bb9 decomp(inputform): anonymous .sdata2 literal symbols (tiInputForm data 100%) (worker 73353bfe) (#1333) 2026-10-09 09:09:12 -05:00
coah
da26714711 decomp(inputform): link tiInputForm (target definition order, vtable ownership, Sample class, dead-stripped helper stand-in) (worker c64933ad) (#1332) 2026-10-09 08:55:57 -05:00
coah
5d4b208246 decomp(aosslink): match AOSSi_WLANConnect and link AOSSLink (worker 00db7515) (#1331) 2026-10-09 08:51:57 -05:00
coah
0cffbfe4bf decomp(aoss): match AOSS_Init_old and link AOSS (worker 314d14fa) (#1330) 2026-10-09 07:40:50 -05:00
coah
12e857a9e2 decomp(inputform): match LayoutByNW4R::create (tiInputForm 221/221 exact) (worker f17f914e) (#1329) 2026-10-09 07:38:59 -05:00
coah
a8ac234de8 decomp(aterm): match ATERMBuildEncryptedMessage and link ATERM (worker 9fa262e0) (#1328) 2026-10-09 07:11:31 -05:00
coah
60febe20c3 decomp(cardseq): match cardThreadMain and loadCardFileIcons, link iplCardSequence (worker 08b78368) (#1327) 2026-10-09 06:45:58 -05:00
coah
b275eb2d99 decomp(chansvm): match CHANSVmStep and link CHANSVm (worker 8450a30c) (#1326) 2026-10-09 06:24:49 -05:00
coah
e47a8e949d decomp(inputform): match calcCursorPos (worker 1e6320d6) (#1325) 2026-10-09 06:20:46 -05:00
coah
fa7f4c26e8 decomp(jpeg): match IdctBlock_Lumi and IdctBlock_Col, link idct_block_var (worker 913878d1) (#1324) 2026-10-09 06:05:24 -05:00
coah
239334ba8d decomp: match pdm_part_is_master_boot_sector and __nupParseServerInfo, link pdm_partition and nup (worker d1576e7c) (#1323) 2026-10-09 05:45:45 -05:00
coah
179cd4e3c3 decomp(jpeg): idct Lumi 97.5 -> 99.7, Col 96.4 -> 97.9 (worker 6ed06b9b) (#1322) 2026-10-09 05:10:49 -05:00
coah
09fc62528e decomp(chansvm): CHANSVmStep structure (262 -> 2 diffs) (worker eb0b9287) (#1321) 2026-10-09 05:00:28 -05:00
coah
dbbdc3dd98 decomp(aoss): AOSS_Init_old 97.39 -> 97.60 (worker af8da67d) (#1320) 2026-10-09 04:21:52 -05:00
coah
4789b7c32f decomp(tistring): inputChar output builder newline handling (73 -> 13) (worker 05e02e12) (#1319) 2026-10-09 04:20:27 -05:00
coah
ad5b9deae3 decomp(cardseq): loadCardFileIcons structure (126 -> 2 diffs) (worker 0deb8cbb) (#1318) 2026-10-09 03:51:54 -05:00
coah
5046adc6da decomp(inputform): calcCursorPos and create structure (93.05 -> 99.88, 96.40 -> 98.16) (worker 00d2d4a1) (#1317) 2026-10-09 03:49:47 -05:00
coah
87214ff944 decomp(aoss): AOSS_Init_old defaults and config structure (96.62 -> 97.39) (worker 43bb6fd6) (#1316) 2026-10-09 03:36:36 -05:00
coah
54ca052b41 decomp(chansvm): VmWinEmuWrite, VmBlobGetHexString, VmBlobPackCommon (worker 8b58ab2f) (#1315) 2026-10-09 03:16:32 -05:00
coah
2ce8487681 decomp(aosslink): match AOSSi_WLANGetBSSList (worker 0f859ab6) (#1314) 2026-10-09 03:15:16 -05:00
coah
47fe453260 decomp(sdmemory): match drawTransferTitles and link iplSDMemory; loadCardFileIcons 213 -> 126 (worker 76898382) (#1313) 2026-10-09 03:14:07 -05:00
coah
2d4cfa7094 decomp(mcm): match _create_icon and link iplMemoryCardManager; pdm MBR reads (worker a7a698b7) (#1312) 2026-10-09 03:12:24 -05:00
coah
e27d9e090a decomp(aes): match AESiEncryptBlock and AESiDecryptBlock, link aes; idct dataflow (worker 33aab024) (#1311) 2026-10-09 03:11:17 -05:00
coah
983a6a2448 decomp(aterm): match DiscoverAccessPoints, BuildAssociationRequest, RunConfigProtocol (worker 228733c3) (#1310) 2026-10-09 01:00:02 -05:00
coah
c1e1157d8b decomp(bs2): match BS2Tick and link BS2Mach (per-use volatile DVDCommandBlock state, Dolphin SDK idiom) (worker 5aba8e21) (#1309) 2026-10-09 00:51:31 -05:00
coah
005d3734f0 decomp(bs2): match CheckBS2CommandStatus, BS2Tick 57 -> 4 (local statics, u64 globals, proven volatile flags) (worker dc077f2a) (#1308) 2026-10-09 00:09:20 -05:00
coah
55891734ae fix(chansvm): use compatible const converter callback types (#1307) 2026-10-08 22:46:39 -05:00
coah
20cf9f9f25 decomp(aterm): GC/3.0a5 build, AutoConfigThread and AES key expansion exact (worker b7300afa) (#1306) 2026-10-08 22:25:25 -05:00
coah
2a7cc791b1 decomp(sdmemory): drawTransferTitles via MSL wcsstr overload and TextBox::SetTextColor (363->50) (worker 9b634499) (#1305) 2026-10-08 22:23:33 -05:00
coah
b2c43f5a66 decomp(chansvm): ConvertToFloatFromStr const source, VmDateDtor scoped tables (worker db63d910) (#1304) 2026-10-08 22:22:23 -05:00
coah
d9b8013644 decomp(aoss): match AOSSXorBufferWithKey (worker 8c6b3076) (#1303) 2026-10-08 22:20:46 -05:00
coah
40b87edd73 fix(odh): preserve unsigned refills and defer planar addressing (#1302) 2026-10-08 21:45:46 -05:00
coah
3d7e767cf7 decomp(odh): match LineConv11 and huffmanDecoder, link odh (worker 9b2c5837) (#1301) 2026-10-08 21:32:36 -05:00
coah
10146c1b5f decomp(candidatebox): match createAnmPane_ and link tiCandidateBox (worker 6dca7c84) (#1300) 2026-10-08 21:23:21 -05:00
coah
82783c6edb decomp(bs2): match UpdateThread and link BS2Update (Flags0 as function-local static) (worker 85186112) (#1299) 2026-10-08 21:19:40 -05:00
coah
72e9c8d658 decomp(kbd): match kbdProcMod and link kbd_lib (worker 86bbfe55) (#1298) 2026-10-08 20:55:10 -05:00
coah
0062d65a27 decomp(chansvm): VmBlobPackCommon per-phase locals (230 -> 47) (worker 69c0cd0d) (#1297) 2026-10-08 20:01:19 -05:00
coah
f67d537e0b decomp(aoss): AOSS_Init_old poll timeout, IPv4 retry and receive setup (worker a98a7fb9) (#1296) 2026-10-08 19:38:50 -05:00
coah
2d169c59cf decomp(bs2): BS2Tick data TOC and banner locals (71 -> 57) (worker 3aedfb87) (#1295) 2026-10-08 19:32:30 -05:00
coah
bbd98e1e4a decomp(cardseq): loadCardFileIcons shift declaration order (219 -> 213) (worker a86634fb) (#1294) 2026-10-08 19:25:17 -05:00
coah
838b6cb941 decomp(aterm): typed progress record and recovered AES/Discovery/Protocol structure (worker 5a9a04c6) (#1293) 2026-10-08 19:23:50 -05:00
coah
9936f0a9ed decomp(sdmemory): drawTransferTitles loop and color structure (93.5% -> 97.4%) (worker 98663b5c) (#1292) 2026-10-08 19:16:09 -05:00
coah
a0659667d9 decomp: replace FAT12 and WAD carrier structs with real structure (worker 08e4cf26) (#1291) 2026-10-08 19:13:50 -05:00
coah
e6837211c1 decomp(cardseq): cardThreadMain stack layout and loadCardFileIcons structure (13->2, 436->219) (worker a52643c9) (#1290) 2026-10-08 19:01:16 -05:00
coah
ebf00fbce2 decomp: remove seven carrier structs (integrity audit) (worker 6bb740cf) (#1289) 2026-10-08 18:52:25 -05:00
coah
a2bc1d564a decomp(candidatebox): createAnmPane_ animation count local (41 -> 6 diffs) (worker 23edcd69) (#1288) 2026-10-08 18:49:24 -05:00
coah
da1c3b7ff8 decomp(address): link iplAddressEdit (definition order, get_button_no table) (worker d1e93825) (#1287) 2026-10-08 18:45:56 -05:00
coah
710174c707 decomp(aoss): match AOSSApplyAuthOptions (worker ee283116) (#1286) 2026-10-08 18:43:52 -05:00
coah
b66bd1ed67 decomp(cardseq): replace loadCardFileIcons carrier struct with ordinary locals (worker 875b5945) (#1285) 2026-10-08 18:41:38 -05:00
coah
ca6529e656 decomp(tmc_jpeg): match YUV411toRGBA8 and link Texture_MCUtoRGBA8 (worker 8b4ebb68) (#1284) 2026-10-08 18:39:40 -05:00
coah
44dea2d510 decomp(chansvm): replace CHANSVmStep scratch carrier with ordinary locals (worker a5c7fcf7) (#1283) 2026-10-08 18:36:34 -05:00
coah
f034087510 decomp(kbd): match KBDSetModState (worker ccab9f40) (#1282) 2026-10-08 18:34:41 -05:00
coah
fa8632368e decomp: replace balloon margin comma-expression hack with TextBalloon::getDefaultMargin getters (worker 383d17df) (#1281) 2026-10-08 18:28:39 -05:00
coah
dc7725eb2d decomp(address): match AddressEdit::create (worker 68baf5e3) (#1280) 2026-10-08 18:26:09 -05:00
coah
0b67e647ba decomp(cardseq): replace cardThreadMain carrier struct with ordinary locals (worker f9bdf29a) (#1279) 2026-10-08 18:23:29 -05:00
coah
b1e911808f decomp(bs2): replace UpdateThread scratch carrier with ordinary locals (worker 7af05191) (#1278) 2026-10-08 18:18:28 -05:00
coah
c723136fb4 decomp(address): match AddressEdit get_friendinfo and update_friendinfo (IRO level 1) (worker f6d94897) (#1277) 2026-10-08 17:58:52 -05:00
coah
a65cd4cb73 decomp(kbd): match kbd_led_handler (IRO level 0) (worker 429bb2a5) (#1276) 2026-10-08 17:44:05 -05:00
coah
2ca94fe4d3 decomp(www): match wiisetting Getter_ and link www_wiisetting (worker 16251338) (#1275) 2026-10-08 17:38:39 -05:00
coah
d558bb14ca decomp(bs2): match BS2StartGame with a typed reset-register view (worker afeef983) (#1274) 2026-10-08 17:31:16 -05:00
coah
6604f7319c decomp(tmc_jpeg): match texture converter setters (optimization_level 1); link RGB565 and Y8U8V8 (worker dd13a763) (#1273) 2026-10-08 17:24:13 -05:00
coah
426c03386e decomp(sdmemory): match SDMemory::create (IRO level 1, cached-title count helper) (worker dc9faaab) (#1272) 2026-10-08 17:23:15 -05:00
coah
7152b04d83 refactor(aterm): write the AutoConfigThread state select as a plain conditional (worker 8747dfc5) (#1271) 2026-10-08 17:07:23 -05:00
devin-ai-integration[bot]
0155de3e71 match(tiPcKeyboard): Base::setTranslateMode byte-identical (#1270)
keyMode must be uninitialized: for mode outside {0,1,2} the switch
leaves it unset and retail provably reads the uninitialized register
(cmplw r31,r0 at 0xd6c executes with r31 never stored). Initializing
keyMode = mode changes the dispatch to an extra branch. Same accepted
uninitialized-read pattern as set_err_msg.

Also documents two probe results in tools/decomp-assist attempts files
(iplSetting scanAP inlined-bool materialization wall; tiString inputChar
indexed-store/dead-compare fossil).

Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: coah80 <usernamecole7@gmail.com>
2026-10-08 17:06:00 -05:00
coah
9321a926cf fix: account for AOSSData in strict completion unit count (#1269) 2026-10-08 16:18:19 -05:00
coah
22e6bbed24 decomp(channel): getTitleName in C (worker 423b68a9) (#1268) 2026-10-08 16:09:07 -05:00
coah
f49f337c6b decomp(aoss): match AOSSSendHelloRequest; move packet state and CRC table into AOSSData.c (proven .bss ownership) (worker 1df7b1d6) (#1267) 2026-10-08 14:52:49 -05:00
coah
c3cad09b66 decomp: match WithZi::update and DeleteUnauthorizedData; link tiZiString and iplESMisc (worker adf0d9ee) (#1266) 2026-10-08 14:46:36 -05:00
coah
11dd7f505a decomp(fa): match sd_drv init/finalize/FAT32 BPB builder and link sd_drv (worker 240c60b4) (#1265) 2026-10-08 14:45:00 -05:00
coah
52c9ea4b70 decomp(keyboard): match CandidateBox LayoutByNW4R::create with real string literals (worker c644f875) (#1264) 2026-10-08 14:39:22 -05:00
coah
eef15925f4 decomp(bs2): match BS2StartGCGame; make target-local BS2Mach symbols static (worker 0dc04259) (#1263) 2026-10-08 14:37:59 -05:00
coah
46baf56e38 docs: mwdbg unblock notes and regsim verdicts for three ties (worker 87a1fd59) (#1262) 2026-10-08 14:29:18 -05:00
coah
23b77a337c decomp(lyt): match Window::DrawFrame and link lyt_window (HBM prior art) (worker 9bd9bdeb) (#1261) 2026-10-08 14:09:03 -05:00
coah
77cf359837 decomp(nhttp): link NHTTP_stdlib_RVL and NHTTP_recvbuf (mscharged prior art, GC/3.0a5) (worker 1fcdff13) (#1260) 2026-10-08 13:51:49 -05:00
coah
af7146a850 decomp: SDChannelSelect collectTitles functions exact; link iplSDChannelSelect (worker 654f9547) (#1259) 2026-10-08 13:45:52 -05:00
coah
16023905ce decomp(nwc24): getUnScrambleId in C (Petari prior art) (worker 0291759e) (#1258) 2026-10-08 13:37:22 -05:00
coah
f9ebd2f4cc refactor: drop per-unit novtable switches that change no object (worker 94d1c9c8) (#1257) 2026-10-08 13:33:40 -05:00
coah
ca98b14ad6 decomp(cntcache): _CNTCACHEIsTitleRemovable and _CNTCACHEDeleteContent in C (worker 34601405) (#1256) 2026-10-08 13:22:56 -05:00
coah
58a1da1cb3 decomp: link iplSDChannelTitle (emit weak LangFile/LayoutFile vtables like iplChannelTitle) (worker ad9dcf3f) (#1255) 2026-10-08 13:12:13 -05:00
coah
8a0436a92f decomp: IRO-off functions in SDChannelSelect, SDChannelTitle, Setting, doUpdateChanInfos; link iplSetting (worker 37ea5c0f) (#1254) 2026-10-08 13:06:57 -05:00
coah
52f4e19325 decomp: makePriorTitleIDList in C (IRO off) (worker f76f9983) (#1253) 2026-10-08 12:57:16 -05:00
coah
77314b30e0 refactor: remove section pragmas, declspecs and padding objects from five units (worker 3edef6a5) (#1252) 2026-10-08 12:37:03 -05:00
coah
a3f8fc2779 decomp(exif): exact IFD0/IFD1 tag parsers and link exif_parse (worker 463beb1e) (#1251) 2026-10-08 12:34:58 -05:00
coah
2df2f8d6c7 decomp(eZiText): match Zi8AlphaGetCandidates and link zi8alpha; eZiText fully linked (opus-alpha) (worker a963b7c0) (#1250) 2026-10-08 12:19:49 -05:00
coah
6a82485817 refactor: write stripped CNT, OSReturnToMenu, CDB date and WUD cancel functions instead of forcing their strings (grok-singles) (worker 11a12532) (#1249) 2026-10-08 12:14:43 -05:00
coah
6d67bbb6eb refactor(cdb): write the stripped NAND logging helpers instead of forcing their strings (grok-cdbfs) (worker 146a4877) (#1248) 2026-10-08 12:13:32 -05:00
coah
c3dbaf8c8e refactor(board): write the stripped URL extension check instead of forcing its strings (grok-focus) (worker a5dca043) (#1245) 2026-10-06 13:52:09 -05:00
coah
7c6393f96c refactor(parental): write the stripped settings dump instead of forcing its strings (grok-parental) (worker 3c180d67) (#1244) 2026-10-06 13:48:10 -05:00
coah
1fd0970728 refactor(ESMisc): write the stripped DeleteSharedContent instead of forcing its strings (grok-esmisc) (worker 30ed7895) (#1243) 2026-10-06 13:42:17 -05:00
coah
712bd2fc11 refactor(os): write OSExec's stripped launch functions instead of forcing their strings (grok-osexec) (worker b08c11d1) (#1242) 2026-10-06 13:40:00 -05:00
coah
75c5997851 refactor(os): write OSNet's weak NWC24 shutdown helpers instead of forcing their strings (grok-osnet) (worker 32669a13) (#1241) 2026-10-06 13:32:10 -05:00
coah
3b9b5e081c decomp(so): match SOGetSockName and link SOBasic (grok-so) (worker 4a959046) (#1240) 2026-10-06 13:27:09 -05:00
coah
e75d7024ab refactor(BS2): BS2Reboot uses the ES work-buffer idiom (swe2-reboot) (worker 14e4a4eb) (#1239) 2026-10-06 13:25:06 -05:00
coah
7c064bc18b refactor(BS2): use the ES work-buffer idiom instead of a carrier struct (swe2-bs2es) (worker e901a8e3) (#1238) 2026-10-06 13:16:05 -05:00
coah
fe7381b4bc fix(WUD): reload asynchronous deletion state while waiting (#1236) 2026-10-05 14:05:01 -05:00
coah
f762dfefbd refactor: replace CDB/NCD carrier structs and unions with real locals (rx65) (worker 8ca90c38) (#1235) 2026-10-05 13:52:30 -05:00
coah
8cddc82c43 refactor: replace volatile casts, dummy locals and fake padding with real source and object extents (rx66) (worker 295d69cd) (#1234) 2026-10-05 13:50:06 -05:00
coah
9925a95779 decomp(eZiText): match the 1-key press, ZH and prepare engines; link zi81key, zi8cgetc, zprepare; data 100% (rx51 astra max) (worker a571c61e) (#1233) 2026-10-05 13:44:13 -05:00
coah
f18082e88b refactor: remove remaining force-retention and placement tricks where the build is unchanged (rx67) (worker 719f7d50) (#1232) 2026-10-05 13:31:52 -05:00
coah
9ca4385ffb refactor: remove force-retention and placement tricks; recover real data order (rx67) (worker f07c21ff) (#1231) 2026-10-05 12:44:18 -05:00
coah
8fd7e1cede refactor: remove fake padding, fake functions, unused state and volatile casts where the build is unchanged (rx64) (worker ce094e4b) (#1230) 2026-10-05 11:33:09 -05:00
coah
73139514df decomp(eZiText): match the user-word insert and link zi8uwd (rx51 astra max) (worker a79cbb93) (#1229) 2026-10-05 11:24:53 -05:00
coah
25326f9774 docs: drop TVRCSendStartAsync from the assembly placeholder list (worker e7bfb1a1) (#1228) 2026-10-05 11:18:45 -05:00
coah
8188d9e3c6 decomp(TVRC): write TVRCSendStartAsync in C (perm4 astra max) (worker 749c53bc) (#1227) 2026-10-05 11:15:57 -05:00
coah
9550ccb3ff refactor: integrity audit fixes (remove register keyword, use-site volatile casts, section pragmas, a carrier struct, duplicated branches, redundant casts) (rx56) (worker c12b2677) (#1226) 2026-10-05 11:08:05 -05:00
coah
38c52baeeb fix(eZiText): align cross-TU candidate and match prototypes (#1225) 2026-10-05 10:54:48 -05:00
coah
55ae09acca refactor(eZiText): drop redundant casts and name language and table constants (rx55) (worker c1242b3a) (#1224) 2026-10-05 10:27:15 -05:00
coah
9d225c150d decomp(eZiText): match Korean candidate search and link zkokeyp (rx53 astra max) (worker f889cb58) (#1223) 2026-10-05 09:57:35 -05:00
coah
5dac1290eb fix(TMC_JPEG): use consistent two-dimensional sampling tables (#1222) 2026-10-05 09:34:02 -05:00
894 changed files with 17650 additions and 270162 deletions

View File

@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2026 TypeSafe AI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,149 +0,0 @@
---
name: typesafe-ai
license: MIT
description: >
Build AI-powered software with TypeSafe: small units of AI intelligence you
can use like programming primitives. Its System One models, including Jev,
turn natural language and application state into typed judgments and
probabilities that code can combine. Use when a feature needs programmable
common sense, when brainstorming what AI could make possible in an app, or
when an LLM prompt-and-parse step could become a structured decision.
Applications include routing, ranking, extraction, verification, and
interactive experiences; these are starting points, not the limits.
Read live docs and cookbooks to find useful patterns and discover new combinations.
---
# Build with TypeSafe
TypeSafe makes units of AI intelligence usable like programming primitives: small
judgments you can compose into larger capabilities. Its **System One models** return
fast, focused judgments that software can consume directly. **Jev** is TypeSafe's
flagship and first System One model. It understands natural language and returns
typed answers and probabilities rather
than generating text or reasoning explanations. Code owns the workflow; the model
supplies programmable common sense where ordinary code needs semantic understanding.
## Read the live docs
**The live TypeSafe docs are the source of truth. Read them as part of the task.**
This skill gives direction; the docs carry current concepts, prompting guidance,
API contracts, SDK usage, models, limits, and worked examples.
- Start with the [documentation index](https://docs.typesafe.ai/llms.txt) to discover
relevant pages and cookbooks. Use targeted reads rather than loading the entire site.
- Mintlify serves Markdown by appending `.md` to a page path, for example
[how to build with TypeSafe](https://docs.typesafe.ai/concepts/how-to-build-with-system-one.md).
Follow links from the index; convert extensionless documentation page links to
`.md` when useful. Resolve relative links against `https://docs.typesafe.ai`.
- Before writing an integration, read the current API or chosen SDK page and the
question guidance relevant to the design. For a new workflow, also inspect the
closest cookbook: it often shows a better decomposition than a generic classifier.
- If the index is unavailable, use the direct links below or the site's navigation.
If Markdown fetching fails, try the normal page. If live access is unavailable,
use available local docs or installed SDK types, state that limitation, and avoid
inventing version-dependent details.
| Task | Start here; follow the relevant details |
| --- | --- |
| Understand the programming model | [System One](https://docs.typesafe.ai/concepts/system-one.md), [building guide](https://docs.typesafe.ai/concepts/how-to-build-with-system-one.md) |
| Explore what to build | [Use-case map](https://docs.typesafe.ai/concepts/use-case-map.md), then relevant cookbooks from the index |
| Prepare inputs and questions | [State](https://docs.typesafe.ai/concepts/state.md), [primitives](https://docs.typesafe.ai/primitives.md), then the chosen primitive's page |
| Decide how to handle uncertainty | [Confidence](https://docs.typesafe.ai/confidence.md) |
| Write API code | [HTTP API](https://docs.typesafe.ai/api.md), [Python SDK](https://docs.typesafe.ai/sdk/python.md), or [JavaScript SDK](https://docs.typesafe.ai/sdk/javascript.md) |
| Update an older integration | [Migration guide](https://docs.typesafe.ai/migrating-to-v1.md) and the installed SDK's current reference |
## Find the useful shape
Start from the behavior the user wants: what will the application show, select,
change, or hand off? Work backward to the judgments it needs. Keep known rules,
calculations, exact lookups, and execution in code. Preserve the user's chosen stack
and scope; add TypeSafe where semantic understanding helps.
When brainstorming or choosing an architecture, consider more than classification.
The patterns below are starting points: combine primitives around the user's goal,
including ideas that do not fit an established recipe.
- **Route and fill known arguments.** A request can select a handler and its typed
parameters. Ask useful branch-specific questions up front and consume only the
relevant answers. Explore [function calling](https://docs.typesafe.ai/cookbooks/function_calling.md)
and [speculative fan-out](https://docs.typesafe.ai/patterns/fan-out.md).
- **Select instead of generate.** Find candidate values or source spans in code,
use a judgment to select the intended one, then copy or normalize it. Code can
also assemble source text into a formatted document or reading guide. Explore
[value extraction](https://docs.typesafe.ai/cookbooks/pre_parsed_value_extraction_cookbook.md)
and [structure recovery](https://docs.typesafe.ai/cookbooks/autoformat.md).
- **Find and judge evidence.** Retrieve candidates, compare their relevance to a
query, and select useful context. Explore [reranking](https://docs.typesafe.ai/cookbooks/rerank_typesafe.md)
and [hierarchical classification](https://docs.typesafe.ai/cookbooks/hierarchical_classification.md).
- **Turn judgments into reusable data.** Score dimensions once, then let code or
user controls change weights, thresholds, rankings, and views. With labeled
outcomes, those signals can become classical ML features. Explore
[composite scoring](https://docs.typesafe.ai/patterns/composite-scoring.md) and
[feature discovery](https://docs.typesafe.ai/cookbooks/autoresearch_feature_discovery.md).
- **Verify and escalate.** Check specific claims or fields against their evidence;
send uncertain or failing cases to a person or reasoning model. Explore
[citation checks](https://docs.typesafe.ai/cookbooks/citation_check.md) and
[extraction cascades](https://docs.typesafe.ai/cookbooks/sde_cascade.md).
- **Respond to changing state.** Code can retain goals and observations while fresh
judgments guide the next bounded step. Keep inferred state distinct from observed
facts, and check freshness before applying a result to a changed situation.
For open-ended requests, offer the few directions that best serve the user's goal
and recommend a starting point. For a concrete request, choose the relevant pattern
and build; a brainstorm is not a mandatory detour.
## Design the judgments
Choose by what the answer means, then read the relevant primitive page:
| Need | Primitive | Important distinction |
| --- | --- | --- |
| One of a defined set | [Choice](https://docs.typesafe.ai/primitives/choice.md) | Picks one option; its distribution compares competing options |
| Whether a condition holds | [Noul](https://docs.typesafe.ai/primitives/noul.md) | Probability of yes; no separate confidence; use one per label when several may apply |
| Degree along a described dimension | [Score](https://docs.typesafe.ai/primitives/score.md) | Probability-weighted position on ordered levels; use comparable per-item Scores for graded ranking |
Give each question enough relevant **state** to answer: source text, identities,
relationships, policies, and current facts. Prefer named JSON fields when context
has several parts. Put the judgment in **instructions** and define its possible
answers in **criteria**. Question IDs are for code and are not sent to the model;
include complete meaning in the question. Reference nested state with backticked
paths such as `ticket.messages[0].text`.
Ask one narrow, coherent judgment per question. Split independently useful dimensions,
without destroying the relationship being judged. A bounded action selection or
contextual interpretation is valid; atomic does not mean literal fact extraction
or a one-sentence limit. Strings work for simple questions. Use structured objects
or arrays when definitions, contrasts, exclusions, or examples clarify instructions
or criteria. Score levels must describe concrete situations and stand on their own.
Keep the needed answers available. Include a no-match outcome when nothing may fit;
use a separate presence judgment when it is independently useful. For source-value
selection, check candidate coverage: the model cannot choose an omitted value.
## Compose and verify
**Ask independent questions over the same state together**, including useful
speculative questions. They run in parallel and cannot see one another's answers.
State each speculative premise explicitly; code consumes the applicable answers.
A second request is warranted when an earlier answer is needed to fetch evidence,
construct new state, or determine the next options. Extra questions still use tokens;
measure actual request budgets, cost, and end-to-end latency.
Use probabilities and confidence to guide behavior, with thresholds evaluated on
the user's data and consequences. Choice/Score confidence summarizes distribution
concentration, not overall workflow correctness or permission to act. A Noul near
0.5 means similar probability for yes and no, not medium intensity. Several
acceptable alternatives can also spread probability; low confidence need not
invalidate a harmless preference choice. Ignore uncertainty on unused branches.
Keep policy explicit and raw judgments reusable. Weighted scores suit compensating
preferences; an “any serious violation” rule needs separate conditions. Changing a
weight or display filter need not rerun inference when evidence and question meanings
are unchanged. Typed output guarantees the interface, not truth. System One models
are trained for calibrated decisions; validate their performance in the target domain.
Test representative cases and the resulting application behavior. For failures,
inspect the exact state, questions, candidates, answers, composition, and observed
outcome. Separate missing evidence, model errors, code errors, and service failures.
Treat cookbook thresholds and demo results as examples to evaluate, not universal
rules or permanent model limitations. Keep API credentials server-side in web apps.

View File

@@ -1 +0,0 @@
../../.agents/skills/typesafe-ai

View File

@@ -6,7 +6,7 @@ on:
workflow_dispatch:
inputs:
require_complete:
description: Fail unless 43U code, data, functions, units, and links are all 100%
description: Fail unless 43U binary matches completely and source inventory is complete
required: false
default: false
type: boolean
@@ -79,6 +79,7 @@ jobs:
python tools/check_decomp_complete.py \
build/${{ matrix.version }}/report.json \
--dol build/${{ matrix.version }}/main.dol
python tools/check_asm_inventory.py
# Upload map files
- name: Upload map

537
AGENTS.md
View File

@@ -1,535 +1,26 @@
# AGENTS.md
Guidance for AI agents working in this repository.
The Wii Menu 4.3U decompilation is finished: every unit matches and links, and
the build reproduces the retail DOL. There is no matching, linking or cleanup
work left to continue. Work only on what the user asks for.
Keep code comments to cases where they are necessary.
## Never touch upstream
## CRITICAL RULE: never touch upstream
Do not push to, open pull requests or issues against, or comment on
`koopthekoopa/wii-ipl`. Its maintainers do not want AI-authored work. `origin`
(`coah80/wii-ipl`) is this fork; `upstream` has its push URL set to
`DISABLED_never_push_to_upstream` on purpose. Never pass
`--repo koopthekoopa/wii-ipl` to `gh`.
**Do not open a pull request against `koopthekoopa/wii-ipl`. Do not push to it.
Do not open issues on it. Do not comment on it. Never. Not once.**
## Keep the build matching
The upstream maintainers do not want AI-authored commits in their history. This
fork exists solely so that AI-assisted matching work has somewhere to live
without disturbing them. Breaking this rule is worse than producing no matches
at all.
Concretely:
- `origin` is this fork, `coah80/wii-ipl`. Only the orchestrator pushes
validated leaf branches here.
- `upstream` is `koopthekoopa/wii-ipl`. Its push URL is intentionally set to
the sentinel `DISABLED_never_push_to_upstream` so an accidental
`git push upstream` fails instead of uploading.
- Never run `gh pr create` with an upstream base, and never pass
`--repo koopthekoopa/wii-ipl` to any `gh` command.
- If a task appears to require contacting upstream, stop and ask the human.
If you are reading this because you are about to open a PR against upstream:
don't. PRs for validated leaf branches belong only to this fork.
## What this repository is
A matching decompilation of the Wii Menu (system menu) 4.3U. "Matching" means
the compiled output must be byte-identical to the original binary, not merely
functionally equivalent. Correct behaviour that compiles to different assembly
is a failure.
## Build and verify
Any source change must keep the output byte-identical:
```
python3 configure.py --version 43U
ninja
sha1sum build/43U/main.dol # 26116613f624061ba99c8d1a299aaa6efa85670d
```
Ninja lives at `/home/cole/projects/tests/.venv/bin/ninja` in the author's
environment.
The acceptance gate for any change is the DOL hash:
```
build/43U/main.dol -> 26116613f624061ba99c8d1a299aaa6efa85670d
```
Objects listed as `NonMatching` in `configure.py` are **not linked** into the
DOL. Editing a `NonMatching` translation unit cannot change the DOL hash, which
makes it safe to iterate on a partial match without breaking the build. Verify
progress against the object file instead of the DOL:
```
build/43U/src/src/<path>.o # what you just built
build/43U/obj/src/<path>.o # the original object, ground truth
```
## Tooling for measuring progress
`objdiff` scores each function:
```
build/tools/objdiff-cli report generate -p . -o report.json -f json
```
A function counts as matched only at `fuzzy_match_percent == 100.0`. Anything
below that is not a match, regardless of how good it looks.
Helper tools live in `tools/decomp-assist/`:
- `ctxdiff.py <unit> <symbol>` — compact instruction-level diff of one function
between your object and the original. This is the main iteration loop.
- `disasm_fn.py <object> <symbol>` — disassembly with relocation-resolved call
names, so you can see which real functions are being called.
- `literal_reference_diff.py [unit ...]` — advisory check of actual narrow-string
bytes passed at corresponding calls, including addresses derived from a shared
data base. Defaults to functions scored 100% in the live report; use
`--all-functions` to include other equal-sized functions. Inspect every
candidate against the assembly. This does not follow mutable pointer globals,
infer compiler aliases, or prove complete data matching; skips are reported.
- `pool_diff.py` — diffs the string pool in `.data` between your object and the
original, string by string. See below; this is the highest-signal tool.
- `export_pyghidra.py` — regenerates `ghidra_decomp.txt`, decompiled C for the
functions still missing.
The final completion assertion is machine-checkable:
```
python3 tools/check_decomp_complete.py build/43U/report.json \
--dol build/43U/main.dol
```
It must pass before claiming full completion. GitHub Actions runs the same
assertion when manually dispatched with `require_complete=true`.
Normal push and pull-request builds publish progress without failing on the
current incomplete state. Use the manual `require_complete=true` dispatch for
the terminal all-100% gate.
`tools/test_workflow_guards.py` exercises the completion checker, and
`tools/worktree_check.py` validates the main, leaf, and cleanup states before
integration.
## The single most useful finding: the string pool
MWCC emits a translation unit's string literals into `.data` in the order the
compiler encounters them, and the compiler encounters them in **source-token
order**, not runtime order. Every later string's offset therefore depends on
every earlier one.
This matters enormously. If a function is missing from a translation unit, or
references its strings in a different order than the original, then every
string after it lands at the wrong offset, and *every function that reads those
strings fails to match* — even functions you have not touched.
Observable evidence: `TMDFile::Open` sat at 99.92 percent purely because a
string several functions earlier was 8 bytes off. Adding the correct
`checkContentsNum` block moved it to 99.96 without touching `Open`.
**Always run `pool_diff.py` and fix the first divergence before tuning register
allocation.** It points at exactly which function block is wrong or missing.
### Which branch you write changes the pool
Because emission follows source-token order, writing
```cpp
if (cond) { A(); } else { B(); }
```
versus
```cpp
if (!cond) { B(); } else { A(); }
```
emits the strings referenced by `A` and `B` in the opposite order. This is a
free lever: if a function's codegen looks right but its strings are swapped,
invert the condition rather than restructuring the logic. It fixed both the
pool and the instruction stream for `GetValidTicketIndex` in one change.
### Missing functions must all be present
A string block cannot be partially correct. A function that is entirely absent
leaves a hole, and everything downstream is shifted. Implement functions in
**object-order** (the order their addresses appear in `config/43U/symbols.txt`
and `splits.txt`), not in whatever order looks convenient.
## Workflow that produced matches
1. Find the next missing function in object order.
2. Get its decompiled C from `ghidra_decomp.txt` (regenerate with
`export_pyghidra.py` if needed).
3. Write it as literally as possible: same order of operations, same branch
direction, same number of temporaries.
4. Insert it at the correct position in the source file.
5. Build only that object: `ninja build/43U/src/src/<path>.o`.
6. `pool_diff.py` first. Fix ordering divergences before anything else.
7. `ctxdiff.py` next. Work through the instruction diff.
8. Only then look at register allocation.
## Subagent and PR workflow
This repository targets only Wii Menu 4.3U. Do not configure or build 43E,
43J, or 43K while doing matching work.
Most workers should pursue exact matching or safe linking; assign the remainder
to decompilation. Keep every worker slot busy (currently four Codex slots; see
"Orchestrator loop" below). Fill completed slots with disjoint tasks. Never duplicate a source file or function
range. Workers return changed paths, exact objdiff measurements, and validation
results. Fuzzy-only results are not accepted.
Workers must do the work through tool calls and avoid conversational messages.
Send findings to the parent only through the collaboration tool, with concise
paths, measurements, and validation evidence. Put PR discussion on the PR when
needed. Do not send user-facing status chatter; the orchestrator follows the
reporting rule below.
### Worker loop
Workers iterate until exact-name `objdiff` reports `100.0%`. They must not stop
at a fuzzy score, push, open a PR, or merge. A local commit is fine. Compiler
tie-breaks should be reported with evidence, not hidden behind artificial
assembly or uninitialized values. Exact matching is the handoff point, not
acceptance. A candidate is incomplete until every owned code and data section
and its link metrics are 100%; matching a few functions alone is not enough.
Write new matches as readable C or C++ and keep new inline assembly out of the
source unless the existing target structure makes it unavoidable.
Worker measurements are advisory. Only a fresh orchestrator verification can
accept, push, open, or merge a candidate. Workers are persistent across
validation. After reaching a candidate result,
the worker enters a paused or awaiting-parent state while the orchestrator
performs its checks. Keep the worker handle and its leaf assignment alive. If
pool, ctxdiff, source review, or any other gate fails, send the failure evidence
back to that same worker and resume it on the same leaf. Do not discard a
near-match and silently replace it with a new worker. A worker may be closed
only after its leaf is accepted, explicitly abandoned, or the orchestrator is
stopping the entire goal. A wait timeout is not worker termination; poll the
same handle or inspect its authoritative status before taking recovery action.
The orchestrator must independently rebuild the owned object and verify:
1. `pool_diff.py` reports identical pools, with no first divergence.
2. Exact-name `objdiff` reports `100.0%` for the requested symbol.
3. `ctxdiff.py` reports `diffs 0` and identical instruction counts.
4. Unit-level code, data, function, and link measures for the owned range are
100%, including every owned section.
5. The focused source diff is minimal, readable, and free of artificial
assembly, uninitialized values, or unrelated edits.
6. The full 4.3U build passes and `build/43U/main.dol` has SHA1
`26116613f624061ba99c8d1a299aaa6efa85670d`.
If any orchestrator gate fails, do not promote, push, open a PR, or merge the
candidate. Restore it or send the same disjoint task back to its worker with
the failing evidence. Stage the candidate branch for a PR only after every
gate passes, then regenerate the live progress report before accepting the
next candidate.
For each candidate, the worker must:
1. Run `pool_diff.py` before tuning code generation.
2. Build the 43U object with `/home/cole/projects/tests/.venv/bin/ninja -C . build/43U/src/src/<path>.o`.
3. Require `objdiff` to report `100.0%` for the function and `ctxdiff.py` to report `diffs 0`.
4. Iterate until exact-name objdiff reaches `100.0%`, while preserving the
pool and source-quality requirements above.
5. Return the focused exact match to the parent agent for review. The parent
reruns every gate, runs `tools/decomp_status.py` and
`tools/check_decomp_complete.py`, and runs `/home/cole/projects/tests/.venv/bin/ninja -C . build/43U/ok`;
the worker does not push, open a PR, or merge.
The main agent reviews every worker result before accepting it. After each
accepted merge, record the new report from `build/43U/report.json` and keep
the DOL hash at `26116613f624061ba99c8d1a299aaa6efa85670d`. Never push to
`upstream`; only the fork's `origin` is in scope.
### Orchestrator ownership boundary
The orchestrator does not perform decompilation or hand-tune worker source.
All source-level reverse engineering, implementation, compiler experiments,
and match iteration belong to the persistent subagents. The orchestrator may
only select disjoint leaves, start and pause workers, resume a worker with
failure evidence, run independent verification commands, review diffs, record
wave state, commit validated leaf-branch changes, push the leaf branch, open
and merge the PR, fast-forward `origin/main`, and publish progress. If a
candidate fails validation, return it to its worker; do not fix the candidate
inline in the orchestrator.
Two exceptions, both set by the human: once a leaf has failed at `max` effort
(see the effort scale below) the orchestrator itself takes a crack at it, and
the orchestrator may finish PRs whose authors are gone (rebase, drop a
forbidden pattern, close with evidence). Record every such attempt in the
policy log, including the ones that fail.
A new thread must begin by reading this file, checking the live 43U report and
remote branch, and dispatching the worker pool. The parent must not claim a
match without fresh independent verification.
### Worktrees, branches, and PR integration
Every leaf gets its own worktree and branch created from the latest
`origin/main`, for example `agent/<wave>/<leaf>`. No two workers may share a
worktree, branch, or source file. A worker may commit locally on its leaf branch
if that is needed to preserve its exact result, but it must not push, open a PR,
or merge.
Use the repository worktree checker before integration and cleanup:
```
python3 tools/worktree_check.py main --synced
python3 tools/worktree_check.py leaf <leaf-worktree> agent/<wave>/<leaf>
python3 tools/worktree_check.py cleanup <leaf-worktree> agent/<wave>/<leaf>
```
The cleanup check is read-only. It succeeds only for a clean leaf branch that
is already an ancestor of `origin/main`; the orchestrator then performs the
explicit `git worktree remove` and local branch deletion.
After the worker reaches its handoff point, the orchestrator validates the
worker's worktree from a fresh build. If every gate passes, the orchestrator
pushes that leaf branch to the fork, opens a PR against `coah80/wii-ipl:main`,
and merges it only after the same gates are recorded in the PR. Never create a
PR against `koopthekoopa/wii-ipl`.
Merge one accepted leaf at a time. After each merge, fetch the new
`origin/main`, regenerate progress, and rebase or recreate all not-yet-merged
leaf branches before their next validation. Re-run objdiff, pool, ctxdiff, the
full build, and the DOL hash after rebasing. The PR itself is not acceptance;
the post-merge main branch is the authority.
The orchestrator may resolve mechanical branch conflicts such as unchanged
context or generated bookkeeping. It must not resolve a semantic source
conflict by inventing decompilation. Send semantic conflicts back to the same
leaf worker, resume it in its worktree, and require the full gates again. Keep
the worktree and worker handle until the leaf is merged, explicitly abandoned,
or the whole goal is stopped; clean them up only after that terminal state.
After a successful merge:
1. Confirm the PR is merged into the fork's `main` and the leaf worktree has no
uncommitted changes.
2. In the integration/main worktree, run `git fetch origin` followed by
`git merge --ff-only origin/main` (or an equivalent non-destructive fast
forward). Do not use `git reset --hard` or overwrite unrelated user work.
3. Re-run the live progress report and the full 4.3U/DOL gates on the updated
main branch.
4. Rebase each still-active leaf branch onto the new `origin/main` in its own
worktree, resolve only mechanical conflicts centrally, and send semantic
conflicts back to that leaf's worker.
5. Only after the leaf is merged, clean, and no longer needed, remove its
worktree and local branch. A failed or conflicted leaf keeps its worktree
and worker alive.
### User-facing progress reports
Keep user-facing messages to a minimum and use as few tokens as possible.
Do not send routine status updates or commentary while workers are running or
PRs are open. After each matching-work PR is merged and the live progress
report has been regenerated, send only the current linked, fuzzy, and data
percentages in this format:
```
Linked: <percent> | Fuzzy: <percent> | Data: <percent>
```
Do not report stale values, unmerged PR results, or add other text to that
update. Continue all required verification and coordination silently.
## Orchestrator loop (Claude orchestrator, Codex workers)
This is the loop currently in use. One Claude session is the orchestrator.
It does not spawn Claude subagents. All decompilation work goes to Codex CLI
workers running `gpt-6.1-sol`. The orchestrator assigns leaves, verifies,
lands, reviews outside PRs, and only decompiles by hand in the cases listed
under the ownership boundary above.
Only one orchestrator session may run at a time. If a second session resumes
the same thread (for example, the same session opened in two windows), close
one of them. Two orchestrators double-merge PRs and fight over the shared
build tree.
### Worker slots and the effort scale
Run four worker slots, each in its own worktree on a fresh branch from
`origin/main`. Every slot gets a disjoint set of three or four leaves (units),
closest-to-matching first. A slot starts at `medium` (or `low`) reasoning
effort and escalates only when a round produces no new exact function:
```
low/medium -> high -> xhigh -> max -> orchestrator attempt -> parked
```
A round that gains at least one exact function is landed, and the remaining
functions go out again at the same effort or one step up. A set that fails at
`max` goes to the orchestrator. If the orchestrator also fails, the function
is parked as a compiler tie-break with its evidence. Fill freed slots from the
live checklist right away; never leave a slot idle.
Before starting a function, a worker fetches `origin/main` and checks it is
not already matched. Outside contributors land work in parallel, and
duplicated matches waste a round.
### Silent mode for workers
Workers run unattended and must not talk. Every turn is tool calls only: no
plans, no progress notes, no summaries. Progress goes into an attempts log
file in `tools/decomp-assist/`. The only text message in a run is the final
report, at most 8-15 short lines:
- exact functions per unit, before and after;
- the final `GATE` line;
- commit hashes;
- a link to the attempts log.
Runs are audited for text messages, and any chatter is a contract
violation. Workers also must not push, open PRs, merge, rebase, touch other
worktrees, or spawn subagents.
Each worker prompt has this layout:
1. the `<task>` block (leaves, current exact counts, method, report format);
2. the shared `common.md` block with `<silent_mode>`, `<forbidden>`,
`<method>` and `<definition_of_done>`.
Resume a stalled worker on the same session with the failure evidence. Don't
replace it with a fresh one.
### Gate, landing and review
- `gate.py <unit...>` is the acceptance check for workers and for outside
PRs. It covers:
- a full 4.3U build and the DOL SHA1;
- per-unit objdiff and instruction-exact counts;
- regressions against a baseline report of `origin/main`;
- a net forbidden-pattern scan and a readability scan (auto-named
identifiers, raw `*(T*)(p + N)` offset casts).
- A function that disappears because it was renamed is not a regression,
unless the unit's exact count, code or data also drops.
- Landing a worker result builds a branch from `origin/main` with the
worker's diff, gates it, pushes it, then opens and squash-merges a PR on
the fork. After that it regenerates the checklist.
- Never run two full builds in the same build tree at once.
- Never land while the review queue is building. Both use the same
verification worktree.
Outside PRs are reviewed by a daemon. It re-runs the gate on any open PR
whose head commit changed since its last review. A PR is merged
automatically only when all of these hold:
- the PR rebases cleanly;
- the full build passes;
- the DOL hash matches;
- the gate passes, or its only failures are renamed-away functions;
- the diff adds no forbidden pattern and no `.s` file.
Everything else is reviewed by hand:
- **Conflicts:** comment asking for a rebase.
- **Forbidden patterns:** request changes with a concrete honest
alternative.
- **"Linking" by swapping in retail assembly or pinned labels:** close and
explain.
- **Proven split/ownership corrections** (relocation evidence, total data
unchanged): merge even if one unit's numbers move to its neighbour.
Policy additions learned in this loop:
- Linking a unit by building the retail `.s` instead of its C/C++ is
forbidden. "Linked" means the C/C++ itself compiles to the exact bytes.
- Definition-level `volatile` (on the field or object declaration) is allowed
when the target proves it, e.g. back-to-back reloads with no store in
between. Check that it changes no other function in the units that use it.
Use-site volatile casts and the `register` keyword stay forbidden.
### Handoff: where the loop lives
The loop's tools and state live outside the repository, in the author's
workers directory `/mnt/drive2/projects/wii-ipl-workers` (`$W` below). A new
orchestrator thread picks up from there.
Tools in `$W/_restore0928-tools/`:
| File | Purpose |
|------|---------|
| `gate.py <unit...> [--base origin/main] [--quick]` | the acceptance gate; `--quick` only skips the clean `rm -rf build/43U` |
| `land.sh <name> <worktree> merge-base <unit...> <title>` | gate a worker's diff on a fresh branch, push, open and squash-merge the PR |
| `luna.sh <worktree> <name> <prompt> <effort> [session]` | start (or resume) one Codex worker; run with `MODEL=gpt-6.1-sol CODEX_BIN=$W/_codex159/bin/codex` |
| `reviewd.sh` | review daemon: queues every open PR whose head changed |
| `revq.sh`, `automerge.py` | the daemon's gate runner and merge decision |
| `checklist.py` | regenerates `$W/CHECKLIST.md` from a report |
| `chatter.py <run-prefix>` | counts worker text messages for the silent-mode audit |
| `baseline-<sha8>.json` | objdiff reports of past `origin/main` commits, used for regressions |
State:
- `$W/_luna-runs/prompts/`: worker prompts. `common.md` is shared; each
task is `<name>.task.md`, and the launched prompt is `<name>.md` = task +
common.
- `$W/_luna-runs/<name>.<time>.jsonl` and `.last.md`: worker transcript and
final report.
- `$W/_luna-runs/effort-policy.txt`: the policy log. Records escalations,
parked functions, and every orchestrator attempt with what was tried.
- `$W/CHECKLIST.md`: units with non-exact code, worst first.
- Worktrees: `verify-fix` is the only verification and landing tree;
`sol-low`, `sol-med`, `sol-high` and `w0929-fix-board` are the four worker
slots; `orch` is orchestrator scratch.
- Logs: `/tmp/reviewd.log`, `/tmp/vfq.log` (current review batch) and
`/tmp/automerge.log` (merge decisions). These are lost on reboot, which
only means open PRs get reviewed again.
- `/tmp/wii-git.lock`: every `git fetch` or checkout in a shared worktree
runs under `flock` on this file, because worktrees share refs.
To pick up the loop:
1. Make sure no other orchestrator session is running.
2. Check `pgrep -af "reviewd.sh|luna.sh|land.sh"` and restart the review
daemon if it isn't running.
3. Read the newest `.last.md` for each slot. Land gains, then relaunch the
slot per the effort scale.
4. Handle every `NEEDS REVIEW` line in `/tmp/automerge.log`.
## Goal completion contract
The decompilation loop does not stop after a successful wave, a convenient
near-match, or a code-only milestone. Keep dispatching and resuming workers
until the live 43U report proves all of the following:
- Code is 100.00% exact-matched, not merely fuzzy-matched.
- Code is 100.00% fully linked, with no remaining unlinked code units.
- Data is 100.00% extracted/decompiled and 100.00% fully linked.
- Every source unit and function in the 4.3U target is accounted for; no
`NonMatching`, missing, fuzzy-only, or unlinked unit remains.
- The final full build passes, the DOL hash remains correct, and the report,
object files, and linked DOL agree.
Until every condition is true and independently verified, the goal remains
active. A worker wave with zero accepted matches is a failed attempt, not a
completion condition; preserve useful workers, resume fixable leaves, and
dispatch the next disjoint batch.
## Things that do NOT work
- **Frame pragmas.** `#pragma ppc_iro_level 0` fixed exactly one function out
of roughly forty attempts and made others worse. A search across pragma
variants produced almost no movement. Do not spend time here.
- **Reverting to pristine upstream to unblock.** The unmodified upstream tree
is needed as a baseline, but it does not help you match anything.
- **Searching other forks for the missing functions.** The eleven unimplemented
`iplESMisc` functions do not exist in any of the twenty-three public forks.
## Known hard cases
Many remaining diffs are pure compiler tie-breaks — register allocation and
floating-point scheduling — with no source-level lever. If `ctxdiff.py` shows
the instruction count already matches and the surviving differences are
callee-saved register names, you are probably looking at a tie-break. Record it
and move on rather than thrashing.
## Current status
Do not copy a progress number from this file. Regenerate the live 43U report
with `ninja -C . progress build/43U/report.json`; the report and DOL hash are
the authority for current status. `iplESMisc.cpp` remains `NonMatching` and
unlinked, so work there is DOL-safe.
## Reference
`tools/decomp-assist/iplESMisc.reference.cpp` is a snapshot of `iplESMisc.cpp`
with the matching work applied, kept as a reference for the string order and
function layout that the pool depends on.
Comments in the source that name a compiler requirement mark code shaped to
match the original binary; changing it changes the bytes.

View File

@@ -1,30 +0,0 @@
# Gates: Wii Menu decompilation progress
OWNS: src/**, include/**, configure.py, GATES.md
Scope: raise the 43U Wii Menu code match from the current baseline toward 99 percent while preserving build and matching-object correctness
- [x] G0: this ledger passes structural lint
CHECK: node /home/cole/.agents/skills/unlazy/scripts/gate-lint.mjs GATES.md
EXPECT: LINT OK
EVIDENCE: LINT OK (2026-09-19)
- [ ] G1: the measured 43U matched-code percentage reaches 99 percent
CHECK: /home/cole/projects/tests/.venv/bin/ninja && build/tools/objdiff-cli report generate -p . -o /tmp/wii-ipl-goal-report.json -f json >/dev/null && python3 -c "import json; x=json.load(open('/tmp/wii-ipl-goal-report.json')); p=float(x['measures']['matched_code_percent']); assert p >= 99.0, p; print('99 percent code match passed: %.6f' % p)"
EXPECT: 99 percent code match passed
EVIDENCE: 57.463276 percent, 1721124 / 2995172 code bytes, 8736 / 12563 functions (2026-09-19); threshold not reached
- [x] G2: the complete 43U build succeeds after each matching change
CHECK: python3 configure.py --version 43U && /home/cole/projects/tests/.venv/bin/ninja && test -s build/43U/main.dol && echo 'full 43U build passed'
EXPECT: full 43U build passed
EVIDENCE: full 43U build passed after ipl::scene::ChannelTitle::draw match (2026-09-19)
- [x] G3: existing matching objects remain byte-identical to the original DOL
CHECK: python3 -c "import hashlib; p='build/43U/main.dol'; h=hashlib.sha1(open(p,'rb').read()).hexdigest(); assert h=='26116613f624061ba99c8d1a299aaa6efa85670d', h; print('baseline DOL hash passed')"
EXPECT: baseline DOL hash passed
EVIDENCE: baseline DOL SHA-1 26116613f624061ba99c8d1a299aaa6efa85670d (2026-09-19)
- [x] G4: the final working tree has no whitespace errors
CHECK: git diff --check && echo 'diff check passed'
EXPECT: diff check passed
EVIDENCE: diff check passed (2026-09-19)

View File

@@ -2,8 +2,8 @@
>
> original doesnt like ai commits, so im forking to not disturb them. :)
>
> This is a personal fork for AI-assisted matching work. No pull requests are
> opened against upstream, ever. See [AGENTS.md](AGENTS.md).
> This is a personal fork for AI-assisted matching work. The 4.3U decompilation
> is complete. No pull requests are opened against upstream, ever.
<!--- Github Actions Badge -->

View File

@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2026 TypeSafe AI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,148 +0,0 @@
---
name: typesafe-ai
description: >
Build AI-powered software with TypeSafe: small units of AI intelligence you
can use like programming primitives. Its System One models, including Jev,
turn natural language and application state into typed judgments and
probabilities that code can combine. Use when a feature needs programmable
common sense, when brainstorming what AI could make possible in an app, or
when an LLM prompt-and-parse step could become a structured decision.
Applications include routing, ranking, extraction, verification, and
interactive experiences; these are starting points, not the limits. Read live
docs and cookbooks to find useful patterns and discover new combinations.
license: MIT
---
# Build with TypeSafe
TypeSafe makes units of AI intelligence usable like programming primitives: small
judgments you can compose into larger capabilities. Its **System One models** return
fast, focused judgments that software can consume directly. **Jev** is TypeSafe's
flagship and first System One model. It understands natural language and returns
typed answers and probabilities rather
than generating text or reasoning explanations. Code owns the workflow; the model
supplies programmable common sense where ordinary code needs semantic understanding.
## Read the live docs
**The live TypeSafe docs are the source of truth. Read them as part of the task.**
This skill gives direction; the docs carry current concepts, prompting guidance,
API contracts, SDK usage, models, limits, and worked examples.
- Start with the [documentation index](https://docs.typesafe.ai/llms.txt) to discover
relevant pages and cookbooks. Use targeted reads rather than loading the entire site.
- Mintlify serves Markdown by appending `.md` to a page path, for example
[how to build with TypeSafe](https://docs.typesafe.ai/concepts/how-to-build-with-system-one.md).
Follow links from the index; convert extensionless documentation page links to
`.md` when useful. Resolve relative links against `https://docs.typesafe.ai`.
- Before writing an integration, read the current API or chosen SDK page and the
question guidance relevant to the design. For a new workflow, also inspect the
closest cookbook: it often shows a better decomposition than a generic classifier.
- If the index is unavailable, use the direct links below or the site's navigation.
If Markdown fetching fails, try the normal page. If live access is unavailable,
use available local docs or installed SDK types, state that limitation, and avoid
inventing version-dependent details.
| Task | Start here; follow the relevant details |
| --- | --- |
| Understand the programming model | [System One](https://docs.typesafe.ai/concepts/system-one.md), [building guide](https://docs.typesafe.ai/concepts/how-to-build-with-system-one.md) |
| Explore what to build | [Use-case map](https://docs.typesafe.ai/concepts/use-case-map.md), then relevant cookbooks from the index |
| Prepare inputs and questions | [State](https://docs.typesafe.ai/concepts/state.md), [primitives](https://docs.typesafe.ai/primitives.md), then the chosen primitive's page |
| Decide how to handle uncertainty | [Confidence](https://docs.typesafe.ai/confidence.md) |
| Write API code | [HTTP API](https://docs.typesafe.ai/api.md), [Python SDK](https://docs.typesafe.ai/sdk/python.md), or [JavaScript SDK](https://docs.typesafe.ai/sdk/javascript.md) |
| Update an older integration | [Migration guide](https://docs.typesafe.ai/migrating-to-v1.md) and the installed SDK's current reference |
## Find the useful shape
Start from the behavior the user wants: what will the application show, select,
change, or hand off? Work backward to the judgments it needs. Keep known rules,
calculations, exact lookups, and execution in code. Preserve the user's chosen stack
and scope; add TypeSafe where semantic understanding helps.
When brainstorming or choosing an architecture, consider more than classification.
The patterns below are starting points: combine primitives around the user's goal,
including ideas that do not fit an established recipe.
- **Route and fill known arguments.** A request can select a handler and its typed
parameters. Ask useful branch-specific questions up front and consume only the
relevant answers. Explore [function calling](https://docs.typesafe.ai/cookbooks/function_calling.md)
and [speculative fan-out](https://docs.typesafe.ai/patterns/fan-out.md).
- **Select instead of generate.** Find candidate values or source spans in code,
use a judgment to select the intended one, then copy or normalize it. Code can
also assemble source text into a formatted document or reading guide. Explore
[value extraction](https://docs.typesafe.ai/cookbooks/pre_parsed_value_extraction_cookbook.md)
and [structure recovery](https://docs.typesafe.ai/cookbooks/autoformat.md).
- **Find and judge evidence.** Retrieve candidates, compare their relevance to a
query, and select useful context. Explore [reranking](https://docs.typesafe.ai/cookbooks/rerank_typesafe.md)
and [hierarchical classification](https://docs.typesafe.ai/cookbooks/hierarchical_classification.md).
- **Turn judgments into reusable data.** Score dimensions once, then let code or
user controls change weights, thresholds, rankings, and views. With labeled
outcomes, those signals can become classical ML features. Explore
[composite scoring](https://docs.typesafe.ai/patterns/composite-scoring.md) and
[feature discovery](https://docs.typesafe.ai/cookbooks/autoresearch_feature_discovery.md).
- **Verify and escalate.** Check specific claims or fields against their evidence;
send uncertain or failing cases to a person or reasoning model. Explore
[citation checks](https://docs.typesafe.ai/cookbooks/citation_check.md) and
[extraction cascades](https://docs.typesafe.ai/cookbooks/sde_cascade.md).
- **Respond to changing state.** Code can retain goals and observations while fresh
judgments guide the next bounded step. Keep inferred state distinct from observed
facts, and check freshness before applying a result to a changed situation.
For open-ended requests, offer the few directions that best serve the user's goal
and recommend a starting point. For a concrete request, choose the relevant pattern
and build; a brainstorm is not a mandatory detour.
## Design the judgments
Choose by what the answer means, then read the relevant primitive page:
| Need | Primitive | Important distinction |
| --- | --- | --- |
| One of a defined set | [Choice](https://docs.typesafe.ai/primitives/choice.md) | Picks one option; its distribution compares competing options |
| Whether a condition holds | [Noul](https://docs.typesafe.ai/primitives/noul.md) | Probability of yes; no separate confidence; use one per label when several may apply |
| Degree along a described dimension | [Score](https://docs.typesafe.ai/primitives/score.md) | Probability-weighted position on ordered levels; use comparable per-item Scores for graded ranking |
Give each question enough relevant **state** to answer: source text, identities,
relationships, policies, and current facts. Prefer named JSON fields when context
has several parts. Put the judgment in **instructions** and define its possible
answers in **criteria**. Question IDs are for code and are not sent to the model;
include complete meaning in the question. Reference nested state with backticked
paths such as `ticket.messages[0].text`.
Ask one narrow, coherent judgment per question. Split independently useful dimensions,
without destroying the relationship being judged. A bounded action selection or
contextual interpretation is valid; atomic does not mean literal fact extraction
or a one-sentence limit. Strings work for simple questions. Use structured objects
or arrays when definitions, contrasts, exclusions, or examples clarify instructions
or criteria. Score levels must describe concrete situations and stand on their own.
Keep the needed answers available. Include a no-match outcome when nothing may fit;
use a separate presence judgment when it is independently useful. For source-value
selection, check candidate coverage: the model cannot choose an omitted value.
## Compose and verify
**Ask independent questions over the same state together**, including useful
speculative questions. They run in parallel and cannot see one another's answers.
State each speculative premise explicitly; code consumes the applicable answers.
A second request is warranted when an earlier answer is needed to fetch evidence,
construct new state, or determine the next options. Extra questions still use tokens;
measure actual request budgets, cost, and end-to-end latency.
Use probabilities and confidence to guide behavior, with thresholds evaluated on
the user's data and consequences. Choice/Score confidence summarizes distribution
concentration, not overall workflow correctness or permission to act. A Noul near
0.5 means similar probability for yes and no, not medium intensity. Several
acceptable alternatives can also spread probability; low confidence need not
invalidate a harmless preference choice. Ignore uncertainty on unused branches.
Keep policy explicit and raw judgments reusable. Weighted scores suit compensating
preferences; an “any serious violation” rule needs separate conditions. Changing a
weight or display filter need not rerun inference when evidence and question meanings
are unchanged. Typed output guarantees the interface, not truth. System One models
are trained for calibrated decisions; validate their performance in the target domain.
Test representative cases and the resulting application behavior. For failures,
inspect the exact state, questions, candidates, answers, composition, and observed
outcome. Separate missing evidence, model errors, code errors, and service failures.
Treat cookbook thresholds and demo results as examples to evaluate, not universal
rules or permanent model limitations. Keep API credentials server-side in web apps.

View File

@@ -1,293 +0,0 @@
# 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.

View File

@@ -1,326 +0,0 @@
# 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,6 +11,9 @@ splits: 'config/43U/splits.txt'
ldscript_template: 'config/ldscript_ipl2.lcf'
force_active:
- SORead
- SOFcntl
- SOInetPtoN
- SOGetSockOpt
- SOSetInterfaceOpt
- fprintf

View File

@@ -897,13 +897,16 @@ src/scene/setting/iplRakuRakuThread.cpp:
.sbss start:0x81698C60 end:0x81698C70
src/scene/setting/AOSS.c:
.bss start:0x810BDEF8 end:0x810BECA0
.bss start:0x810BDEF8 end:0x810BE838
.text start:0x813FE27C end:0x814021BC
.data start:0x81657C48 end:0x81657DB8
.sdata2 start:0x81694C78 end:0x81694C80
.sdata start:0x81697200 end:0x81697218
.sbss start:0x81698C70 end:0x81698C90
src/scene/setting/AOSSData.c:
.bss start:0x810BE838 end:0x810BECA0
src/scene/setting/ATERM.c:
.bss start:0x810BECA0 end:0x810C0C80
.text start:0x814021BC end:0x81406CC0

View File

@@ -42,7 +42,7 @@ AppLoaderHdr = .bss:0x810ABF40; // type:object size:0x20 align:32 data:4byte
bi2 = .bss:0x810ABF60; // type:object size:0x2000 align:32 data:4byte
UpdateDiskID = .bss:0x810ADF60; // type:object size:0x20 align:32 data:4byte
TicketViewsBuf = .bss:0x810ADF80; // type:object size:0x3600 scope:local align:32
Flags0 = .bss:0x810B1580; // type:object size:0x800 scope:local
Flags0$1129 = .bss:0x810B1580; // type:object size:0x800 scope:local
Flags1 = .bss:0x810B1D80; // type:object size:0x800 scope:local
Thread = .bss:0x810B2580; // type:object size:0x318 scope:local
UpdateHeader0 = .bss:0x810B38A0; // type:object size:0x20 scope:local
@@ -93,8 +93,8 @@ sRakuMsgQueue = .bss:0x810BDED4; // type:object size:0x20
AOSS_810BDEF8 = .bss:0x810BDEF8; // type:object size:0x20 data:4byte
AOSS_810BDF18 = .bss:0x810BDF18; // type:object size:0x6A0
AOSS_810BE5B8 = .bss:0x810BE5B8; // type:object size:0x280
AOSS_810BE838 = .bss:0x810BE838; // type:object size:0x68
AOSS_810BE8A0 = .bss:0x810BE8A0; // type:object size:0x400
s_packetState = .bss:0x810BE838; // type:object size:0x68
s_crcTable = .bss:0x810BE8A0; // type:object size:0x400
gAtermIpConfig = .bss:0x810BECA0; // type:object size:0x7C4 data:4byte
gAtermIfConfig = .bss:0x810BF464; // type:object size:0x15E
ATERM_810BF5C4 = .bss:0x810BF5C4; // type:object size:0x24
@@ -144,7 +144,7 @@ lbl_810C8A80 = .bss:0x810C8A80; // type:object size:0x40 align:32
lbl_810C8AC0 = .bss:0x810C8AC0; // type:object size:0x40 align:32
s_mutex = .bss:0x810C8B00; // type:object size:0x18 scope:local
s_cdbWiiId = .bss:0x810C8B20; // type:object size:0x40 scope:local
ncdMutex = .bss:0x810C8B60; // type:object size:0x20
ncdMutex = .bss:0x810C8B60; // type:object size:0x18
ncdCommonResult = .bss:0x810C8B80; // type:object size:0x20 align:32 data:4byte
ncdCommonVector = .bss:0x810C8BA0; // type:object size:0x20 align:32 data:4byte
NHTTPiStaticResource = .bss:0x810C8BC0; // type:object size:0x40 data:4byte
@@ -2524,7 +2524,7 @@ __ct__Q33ipl3snd10tagSSeInfoFv = .text:0x8136C63C; // type:function size:0x30
__ct__Q34nw4r3snd11SoundHandleFv = .text:0x8136C66C; // type:function size:0xC
__dt__Q34nw4r3snd11SoundHandleFv = .text:0x8136C678; // type:function size:0x54
__dt__Q33ipl3snd10tagSSeInfoFv = .text:0x8136C6CC; // type:function size:0x58
__dt__Q33ipl3snd6UnkClsFv = .text:0x8136C724; // type:function size:0x1C scope:local
__arraydtor$15982 = .text:0x8136C724; // type:function size:0x1C scope:local
__ct__Q33ipl3snd11tagSBgmInfoFv = .text:0x8136C740; // type:function size:0x30 scope:local
__dt__Q33ipl3snd11tagSBgmInfoFv = .text:0x8136C770; // type:function size:0x58
__ct__Q33ipl3snd6SystemFv = .text:0x8136C7C8; // type:function size:0x4C
@@ -3223,7 +3223,7 @@ __dt__Q33ipl5scene5BoardFv = .text:0x81393CA4; // type:function size:0x68
__ct__Q33ipl5scene11BoardObjectFv = .text:0x81393D1C; // type:function size:0x140
__dt__Q33ipl4math28LinearIntp<Q33ipl4math4VEC2>Fv = .text:0x81393E5C; // type:function size:0x40
__dt__Q33ipl4math31Interporation<Q33ipl4math4VEC2>Fv = .text:0x81393E9C; // type:function size:0x40
init__Q43ipl5scene11BoardObject29@class$8157iplBoardObject_cppFv = .text:0x81393EDC; // type:function size:0x18
init__Q43ipl5scene11BoardObject9StandDataFv = .text:0x81393EDC; // type:function size:0x18
make_icon_cb___Q23ipl5sceneFPQ33ipl6nigaoe6ObjectPv = .text:0x81393EF4; // type:function size:0x80
create__Q33ipl5scene11BoardObjectFPQ33ipl4nand10LayoutFilePUcUlRC6_CDBIdRC13_CDBRecordKeyRCQ33ipl7utility4Date = .text:0x81393F74; // type:function size:0x84
init__Q33ipl5scene11BoardObjectFv = .text:0x81393FF8; // type:function size:0xA4
@@ -4584,11 +4584,11 @@ enqueueLoadNotice__Q33ipl5scene15SDChannelSelectFv = .text:0x813DB308; // type:f
enqueuePageNotice__Q33ipl5scene15SDChannelSelectFv = .text:0x813DB364; // type:function size:0x5C
enqueueResultNotice__Q33ipl5scene15SDChannelSelectFUl = .text:0x813DB3C0; // type:function size:0x5C
enqueueChannelNotice__Q33ipl5scene15SDChannelSelectFUxUl = .text:0x813DB41C; // type:function size:0x5C
enqueueMoveNotice__Q33ipl5scene15SDChannelSelectFUlUlUl = .text:0x813DB478; // type:function size:0x5C
enqueueMoveNotice__Q33ipl5scene15SDChannelSelectFUx = .text:0x813DB478; // type:function size:0x5C
enqueueStateNotice__Q33ipl5scene15SDChannelSelectFUxUl = .text:0x813DB4D4; // type:function size:0x5C
enqueueErrorNotice__Q33ipl5scene15SDChannelSelectFUlUl = .text:0x813DB530; // type:function size:0x5C
enqueueCommandNotice__Q33ipl5scene15SDChannelSelectFUlUlUl = .text:0x813DB58C; // type:function size:0x60
enqueueDeleteNotice__Q33ipl5scene15SDChannelSelectFUlUlUl = .text:0x813DB5EC; // type:function size:0x60
enqueueErrorNotice__Q33ipl5scene15SDChannelSelectFPQ33ipl12NandSDWorker11TitleIdListPQ33ipl12NandSDWorker11TitleIdList = .text:0x813DB530; // type:function size:0x5C
enqueueCommandNotice__Q33ipl5scene15SDChannelSelectFPQ33ipl12NandSDWorker11TitleIdListPQ33ipl12NandSDWorker11TitleIdListPQ33ipl12NandSDWorker11TitleIdList = .text:0x813DB58C; // type:function size:0x60
enqueueDeleteNotice__Q33ipl5scene15SDChannelSelectFUx = .text:0x813DB5EC; // type:function size:0x60
clearCommandQueue__Q33ipl5scene15SDChannelSelectFv = .text:0x813DB64C; // type:function size:0x40
clearNoticeQueue__Q33ipl5scene15SDChannelSelectFv = .text:0x813DB68C; // type:function size:0x40
processWorkerCommands__Q33ipl5scene15SDChannelSelectFv = .text:0x813DB6CC; // type:function size:0x518
@@ -4617,11 +4617,11 @@ updateDialogAnimation__Q33ipl5scene15SDChannelSelectFv = .text:0x813DCAC4; // ty
setDialogMessage__Q33ipl5scene15SDChannelSelectFUlUl = .text:0x813DCEF0; // type:function size:0x24
isCurrentTitleUsageEnough__Q33ipl5scene15SDChannelSelectCFPCl = .text:0x813DCF14; // type:function size:0xCC
getCurrentTitleUsage__Q33ipl5scene15SDChannelSelectCFPlPl = .text:0x813DCFE0; // type:function size:0xCC
collectTitlesByUsage__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD0AC; // type:function size:0x194
collectTitlesFromNandUsage__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD240; // type:function size:0x198
collectTitlesByChannelOrder__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD3D8; // type:function size:0x1F8
collectTitlesBySpecialChannels__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD5D0; // type:function size:0x5A4
collectTitlesForMode__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUli = .text:0x813DDB74; // type:function size:0x40
collectTitlesByUsage__Q33ipl5scene15SDChannelSelectFPlPlPUxPA21_wPUl = .text:0x813DD0AC; // type:function size:0x194
collectTitlesFromNandUsage__Q33ipl5scene15SDChannelSelectFPlPlPUxPA21_wPUl = .text:0x813DD240; // type:function size:0x198
collectTitlesByChannelOrder__Q33ipl5scene15SDChannelSelectFPlPlPUxPA21_wPUl = .text:0x813DD3D8; // type:function size:0x1F8
collectTitlesBySpecialChannels__Q33ipl5scene15SDChannelSelectFPlPlPUxPA21_wPUl = .text:0x813DD5D0; // type:function size:0x5A4
collectTitlesForMode__Q33ipl5scene15SDChannelSelectFPlPlPUxPA21_wPUli = .text:0x813DDB74; // type:function size:0x40
findAdjacentChannel__Q33ipl5scene15SDChannelSelectCFiPiPi = .text:0x813DDBB4; // type:function size:0xB4
setCurrentPageAndRefresh__Q33ipl5scene15SDChannelSelectFiiPQ33ipl5scene12SDChannelObj = .text:0x813DDC68; // type:function size:0x18
handleFourPageDialog__Q33ipl5scene15SDChannelSelectFv = .text:0x813DDC80; // type:function size:0x58
@@ -4762,7 +4762,7 @@ iplSDChannelTitle_updateParentalResult = .text:0x813E69B4; // type:function size
iplSDChannelTitle_updateDialogResult = .text:0x813E6B88; // type:function size:0x144
iplSDChannelTitle_startCopyProgress = .text:0x813E6CCC; // type:function size:0x158
iplSDChannelTitle_updateCopyPrepare = .text:0x813E6E24; // type:function size:0x17C
iplSDChannelTitle_copyTitleRange = .text:0x813E6FA0; // type:function size:0x14
__as__Q43ipl5scene8SDMemory10TitleRangeFRCQ43ipl5scene8SDMemory10TitleRange = .text:0x813E6FA0; // type:function size:0x14 scope:weak
iplSDChannelTitle_updateMemoryCalc = .text:0x813E6FB4; // type:function size:0xC0
iplSDChannelTitle_updateCopyStart = .text:0x813E7074; // type:function size:0x130
iplSDChannelTitle_updateAfterClearTmp = .text:0x813E71A4; // type:function size:0xA8
@@ -4900,8 +4900,8 @@ onDialogState23__Q33ipl5scene8SDMemoryFv = .text:0x813EEDF8; // type:function si
onDialogState24__Q33ipl5scene8SDMemoryFv = .text:0x813EEE70; // type:function size:0xC0
draw__Q33ipl5scene8SDMemoryFv = .text:0x813EEF30; // type:function size:0x88
drawTransferTitles__Q33ipl5scene8SDMemoryFv = .text:0x813EEFB8; // type:function size:0x70C
writeFourFlagBytes__Q23ipl5sceneFPUcUcUcUcUc = .text:0x813EF6C4; // type:function size:0x14
setTitleRowColors__Q23ipl5sceneFPQ34nw4r3lyt7TextBoxRCQ34nw4r2ut5ColorRCQ34nw4r2ut5Color = .text:0x813EF6D8; // type:function size:0x48
__ct__Q34nw4r2ut5ColorFiiii = .text:0x813EF6C4; // type:function size:0x14
SetTextColor__Q34nw4r3lyt7TextBoxFQ34nw4r2ut5ColorQ34nw4r2ut5Color = .text:0x813EF6D8; // type:function size:0x48
GetBeginIter__Q34nw4r2ut28LinkList<Q34nw4r3lyt4Pane,4>Fv = .text:0x813EF720; // type:function size:0x8
GetEndIter__Q34nw4r2ut28LinkList<Q34nw4r3lyt4Pane,4>Fv = .text:0x813EF728; // type:function size:0x8
__ne__Q24nw4r2utFQ44nw4r2ut28LinkList<Q34nw4r3lyt4Pane,4>8IteratorQ44nw4r2ut28LinkList<Q34nw4r3lyt4Pane,4>8Iterator = .text:0x813EF730; // type:function size:0x18
@@ -13963,7 +13963,7 @@ lbl_816152D0 = .rodata:0x816152D0; // type:object size:0x10 scope:local data:4by
csAninationFile__Q29textinput12candidatebox = .rodata:0x816152E0; // type:object size:0x374 scope:local
lbl_81615658 = .rodata:0x81615658; // type:object size:0xA0 scope:local data:4byte
csAninationFile__Q29textinput7toolbar = .rodata:0x816156F8; // type:object size:0x1DC scope:local data:4byte
csAninationFile__Q29textinput11predictlang = .rodata:0x816158D8; // type:object size:0x268 scope:local
csAninationFile__Q29textinput11predictlang = .rodata:0x816158D8; // type:object size:0x264 scope:local
csAninationFileForSign__Q39textinput8keyboard10signwindow = .rodata:0x81615B40; // type:object size:0x268 scope:local
csPaneNameToControlKey__Q39textinput8keyboard10signwindow = .rodata:0x81615DA8; // type:object size:0x48 scope:local
csLanguageDependencyData__Q39textinput8keyboard10signwindow = .rodata:0x81615DF0; // type:object size:0x50 scope:local
@@ -15632,7 +15632,7 @@ __vt__Q33ipl4math28LinearIntp<Q33ipl4math4VEC2> = .data:0x8164B5E0; // type:obje
__vt__Q33ipl4math31Interporation<Q33ipl4math4VEC2> = .data:0x8164B5F0; // type:object size:0x10
@10018 = .data:0x8164B698; // type:object size:0xB scope:local data:string
@10019 = .data:0x8164B6A3; // type:object size:0xF scope:local data:string
__vt__Q33ipl5scene12UrlProcessor = .data:0x8164B6B8; // type:object size:0x18
__vt__Q33ipl5scene12UrlProcessor = .data:0x8164B6B8; // type:object size:0x14
lbl_8164B6D0 = .data:0x8164B6D0; // type:object size:0x10 data:string
lbl_8164B6E0 = .data:0x8164B6E0; // type:object size:0x1D data:string
lbl_8164B6FD = .data:0x8164B6FD; // type:object size:0x1B data:string
@@ -15765,7 +15765,8 @@ lbl_8164C53A = .data:0x8164C53A; // type:object size:0x14
lbl_8164C54E = .data:0x8164C54E; // type:object size:0x18
lbl_8164C566 = .data:0x8164C566; // type:object size:0xC
lbl_8164C572 = .data:0x8164C572; // type:object size:0xA
__vt__Q33ipl5scene8Calendar = .data:0x8164C57C; // type:object size:0xA4
__vt__Q33ipl5scene8Calendar = .data:0x8164C57C; // type:object size:0x88
__vt__Q23gui12EventHandler = .data:0x8164C604; // type:object size:0x18 scope:weak
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
@@ -17726,12 +17727,20 @@ __vt__Q39textinput4util9Animation = .data:0x8165D258; // type:object size:0x24
@STRING@GetTextColor__Q34nw4r3lyt7TextBoxCFUl = .data:0x8165D28C; // type:object size:0x41 data:string
scT_prdc_Text_00 = .data:0x8165D2D0; // type:object size:0xF data:string
scP_prdc_scrl_Left = .data:0x8165D2E0; // type:object size:0x11 data:string
scCandidatePaneData = .data:0x8165D2F8; // type:object size:0x68C
scPaneNameTable = .data:0x8165D984; // type:object size:0x84
scW_predictWindow = .data:0x8165DA08; // type:object size:0x10 data:string
scN_predictInput = .data:0x8165DA18; // type:object size:0xF data:string
scW_OnOff_Area = .data:0x8165DA28; // type:object size:0xD data:string
scN_prdc_Texts = .data:0x8165DA38; // type:object size:0xD data:string
csPaneToAnimation__Q29textinput12candidatebox = .data:0x8165D2F8; // type:object size:0x680 scope:local
@9934 = .data:0x8165D978; // type:object size:0x9 scope:local data:string
@9935 = .data:0x8165D984; // type:object size:0x9 scope:local data:string
@9936 = .data:0x8165D990; // type:object size:0xB scope:local data:string
@9937 = .data:0x8165D99C; // type:object size:0xB scope:local data:string
@9938 = .data:0x8165D9A8; // type:object size:0xA scope:local data:string
@9939 = .data:0x8165D9B4; // type:object size:0x11 scope:local data:string
@9940 = .data:0x8165D9C8; // type:object size:0x11 scope:local data:string
@9941 = .data:0x8165D9DC; // type:object size:0x11 scope:local data:string
@9942 = .data:0x8165D9F0; // type:object size:0x11 scope:local data:string
@9943 = .data:0x8165DA08; // type:object size:0x10 scope:local data:string
@10036 = .data:0x8165DA18; // type:object size:0xF scope:local data:string
@10037 = .data:0x8165DA28; // type:object size:0xD scope:local data:string
@10041 = .data:0x8165DA38; // type:object size:0xD scope:local data:string
@10530 = .data:0x8165DA48; // type:object size:0x1C scope:local
@6761 = .data:0x8165DA64; // type:object size:0xF scope:local data:string
@6762 = .data:0x8165DA74; // type:object size:0xF scope:local data:string
@@ -20924,31 +20933,28 @@ lbl_81694D18 = .sdata2:0x81694D18; // type:object size:0x4 data:4byte
lbl_81694D1C = .sdata2:0x81694D1C; // type:object size:0x4 data:4byte
lbl_81694D20 = .sdata2:0x81694D20; // type:object size:0x1 data:byte
lbl_81694D24 = .sdata2:0x81694D24; // type:object size:0x1 data:byte
scInputFormZeroF = .sdata2:0x81694D28; // type:object size:0x4 align:4 data:float
scInputForm640F = .sdata2:0x81694D2C; // type:object size:0x4 align:4 data:float
scInputFormF32ConvertMagic = .sdata2:0x81694D30; // type:object size:0x8 align:8 data:double
scInputFormOneF = .sdata2:0x81694D38; // type:object size:0x4 align:4 data:float
scInputFormHalfF = .sdata2:0x81694D3C; // type:object size:0x4 align:4 data:float
scInputFormDegToFIdxF = .sdata2:0x81694D40; // type:object size:0x4 align:4 data:float
scInputForm150F = .sdata2:0x81694D44; // type:object size:0x4 align:4 data:float
scInputForm30F = .sdata2:0x81694D48; // type:object size:0x4 align:4 data:float
scInputForm50F = .sdata2:0x81694D4C; // type:object size:0x4 align:4 data:float
scInputForm10F = .sdata2:0x81694D50; // type:object size:0x4 align:4 data:float
scInputForm52F = .sdata2:0x81694D54; // type:object size:0x4 align:4 data:float
scInputFormTwoF = .sdata2:0x81694D58; // type:object size:0x4 align:4 data:float
scInputForm140F = .sdata2:0x81694D5C; // type:object size:0x4 align:4 data:float
scInputForm90F = .sdata2:0x81694D60; // type:object size:0x4 align:4 data:float
scInputForm253F = .sdata2:0x81694D64; // type:object size:0x4 align:4 data:float
scInputForm20F = .sdata2:0x81694D68; // type:object size:0x4 align:4 data:float
scInputFormColorRU8 = .sdata2:0x81694D6C; // type:object size:0x1 data:byte
scInputFormColorGU8 = .sdata2:0x81694D6D; // type:object size:0x1 data:byte
scInputFormColorBU8 = .sdata2:0x81694D6E; // type:object size:0x1 data:byte
scInputFormColorAU8 = .sdata2:0x81694D6F; // type:object size:0x1 data:byte
scInputForm255F = .sdata2:0x81694D70; // type:object size:0x4 align:4 data:float
scInputForm127F = .sdata2:0x81694D74; // type:object size:0x4 align:4 data:float
scInputForm14592F = .sdata2:0x81694D78; // type:object size:0x4 align:4 data:float
scInputFormF64ConvertMagic = .sdata2:0x81694D80; // type:object size:0x8 align:8 data:double
scInputForm15F = .sdata2:0x81694D88; // type:object size:0x4 align:4 data:float
@13326 = .sdata2:0x81694D28; // type:object size:0x4 scope:local align:4 data:float
@13327 = .sdata2:0x81694D2C; // type:object size:0x4 scope:local align:4 data:float
@13360 = .sdata2:0x81694D30; // type:object size:0x8 scope:local align:8 data:double
@13767 = .sdata2:0x81694D38; // type:object size:0x4 scope:local align:4 data:float
@13772 = .sdata2:0x81694D3C; // type:object size:0x4 scope:local align:4 data:float
@13804 = .sdata2:0x81694D40; // type:object size:0x4 scope:local align:4 data:float
@13805 = .sdata2:0x81694D44; // type:object size:0x4 scope:local align:4 data:float
@13806 = .sdata2:0x81694D48; // type:object size:0x4 scope:local align:4 data:float
@13807 = .sdata2:0x81694D4C; // type:object size:0x4 scope:local align:4 data:float
@13808 = .sdata2:0x81694D50; // type:object size:0x4 scope:local align:4 data:float
@13809 = .sdata2:0x81694D54; // type:object size:0x4 scope:local align:4 data:float
@13810 = .sdata2:0x81694D58; // type:object size:0x4 scope:local align:4 data:float
@13811 = .sdata2:0x81694D5C; // type:object size:0x4 scope:local align:4 data:float
@13812 = .sdata2:0x81694D60; // type:object size:0x4 scope:local align:4 data:float
@13813 = .sdata2:0x81694D64; // type:object size:0x4 scope:local align:4 data:float
@13814 = .sdata2:0x81694D68; // type:object size:0x4 scope:local align:4 data:float
@8131 = .sdata2:0x81694D6C; // type:object size:0x4 scope:local data:byte
@14016 = .sdata2:0x81694D70; // type:object size:0x4 scope:local align:4 data:float
@14017 = .sdata2:0x81694D74; // type:object size:0x4 scope:local align:4 data:float
@14018 = .sdata2:0x81694D78; // type:object size:0x4 scope:local align:4 data:float
@14021 = .sdata2:0x81694D80; // type:object size:0x8 scope:local align:8 data:double
@14117 = .sdata2:0x81694D88; // type:object size:0x4 scope:local align:4 data:float
lbl_81694D90 = .sdata2:0x81694D90; // type:object size:0x4 align:4 data:float
lbl_81694D94 = .sdata2:0x81694D94; // type:object size:0x4 align:4 data:float
lbl_81694D98 = .sdata2:0x81694D98; // type:object size:0x4 align:4 data:float
@@ -22773,10 +22779,7 @@ lbl_81697824 = .sdata:0x81697824; // type:object size:0x8 data:string
lbl_8169782C = .sdata:0x8169782C; // type:object size:0x8 data:string
lbl_81697834 = .sdata:0x81697834; // type:object size:0x8 data:string
lbl_8169783C = .sdata:0x8169783C; // type:object size:0x8 data:string
scCsFatalColorR = .sdata:0x81697844; // type:object size:0x1 data:byte
scCsFatalColorG = .sdata:0x81697845; // type:object size:0x1 data:byte
scCsFatalColorB = .sdata:0x81697846; // type:object size:0x1 data:byte
scCsFatalColorA = .sdata:0x81697847; // type:object size:0x1 data:byte
scCsFatalColor = .sdata:0x81697844; // type:object size:0x4 data:byte
lbl_81697848 = .sdata:0x81697848; // type:object size:0x8 data:string
lbl_81697850 = .sdata:0x81697850; // type:object size:0x6 data:string
lbl_81697858 = .sdata:0x81697858; // type:object size:0x6 data:string
@@ -23675,8 +23678,8 @@ RegionValid = .sbss:0x81698A48; // type:object size:0x4 data:4byte
NandPending = .sbss:0x81698A4C; // type:object size:0x4 scope:local data:4byte
CancelNand = .sbss:0x81698A50; // type:object size:0x4 scope:local data:4byte
LowReadResult = .sbss:0x81698A54; // type:object size:0x4 scope:local data:4byte
CacheCommandComplete = .sbss:0x81698A58; // type:object size:0x4 scope:local data:4byte
AudioBufferUnconfigured = .sbss:0x81698A5C; // type:object size:0x4 scope:local data:4byte
CacheCommandComplete$1963 = .sbss:0x81698A58; // type:object size:0x4 scope:local data:4byte
AudioBufferUnconfigured$2065 = .sbss:0x81698A5C; // type:object size:0x4 scope:local data:4byte
ResetTime = .sbss:0x81698A60; // type:object size:0x8 scope:local data:4byte
SpinupDeadline = .sbss:0x81698A68; // type:object size:0x8 scope:local data:4byte
CoverPollTime = .sbss:0x81698A70; // type:object size:0x8 data:4byte
@@ -23684,15 +23687,13 @@ DriveWasReset = .sbss:0x81698A78; // type:object size:0x4 data:4byte
TitleTicketView = .sbss:0x81698A7C; // type:object size:0x4 scope:local data:4byte
CurrentTmd = .sbss:0x81698A80; // type:object size:0x4 scope:local data:4byte
TitleCode = .sbss:0x81698A84; // type:object size:0x4 data:4byte
RequiredIosHigh = .sbss:0x81698A88; // type:object size:0x4 data:4byte
RequiredIosLow = .sbss:0x81698A8C; // type:object size:0x4 data:4byte
RequiredIos = .sbss:0x81698A88; // type:object size:0x8 data:4byte
GamePartition = .sbss:0x81698A90; // type:object size:0x4 data:4byte
UpdatePartition = .sbss:0x81698A94; // type:object size:0x4 data:4byte
PartitionCursor = .sbss:0x81698A98; // type:object size:0x4 data:4byte
DataToc = .sbss:0x81698A9C; // type:object size:0x4 data:4byte
GameToc = .sbss:0x81698AA0; // type:object size:0x8 data:4byte
CoverOpenTimeHigh = .sbss:0x81698AA8; // type:object size:0x4 data:4byte
CoverOpenTimeLow = .sbss:0x81698AAC; // type:object size:0x4 data:4byte
CoverOpenTime = .sbss:0x81698AA8; // type:object size:0x8 data:4byte
NandTransferred = .sbss:0x81698AB0; // type:object size:0x4 data:4byte
NandLength = .sbss:0x81698AB4; // type:object size:0x4 data:4byte
NandBuffer = .sbss:0x81698AB8; // type:object size:0x4 data:4byte

View File

@@ -658,7 +658,7 @@ config.libs = [
Object(Matching, "system/iplChannelRsoThread.cpp"),
Object(Matching, "system/RsoSystem.cpp"),
Object(Matching, "system/iplCdbBackup.cpp"),
Object(NonMatching, "system/odh.cpp"),
Object(Matching, "system/odh.cpp"),
Object(Matching, "system/iplSDVFWorker.cpp"),
Object(Matching, "system/iplNandWrapper.cpp"),
Object(Matching, "system/main.cpp"),
@@ -678,7 +678,7 @@ config.libs = [
Object(Matching, "utility/iplThread.cpp"),
Object(Matching, "utility/iplMessageBase.cpp"),
Object(Matching, "utility/iplJpegDecoder.cpp"),
Object(NonMatching, "utility/iplESMisc.cpp"),
Object(Matching, "utility/iplESMisc.cpp"),
Object(Matching, "utility/iplCSFlags.cpp"),
]
),
@@ -700,7 +700,7 @@ config.libs = [
Object(Matching, "iplwww/www_print.cpp"),
Object(Matching, "iplwww/www_window.cpp"),
Object(Matching, "iplwww/www_trasition.cpp"),
Object(Equivalent, "iplwww/www_wiisetting.cpp"),
Object(Matching, "iplwww/www_wiisetting.cpp"),
Object(Matching, "iplwww/www_arcreader.cpp"),
]
),
@@ -718,8 +718,8 @@ config.libs = [
Object(Matching, "BS2/BS2Entry.c"),
Object(Matching, "BS2/BS2.c"),
Object(Matching, "BS2/BS2Init.c"),
Object(NonMatching, "BS2/BS2Mach.c"),
Object(NonMatching, "BS2/BS2Update.c"),
Object(Matching, "BS2/BS2Mach.c"),
Object(Matching, "BS2/BS2Update.c"),
Object(Matching, "BS2/BS2ParentalControl.c"),
Object(Matching, "BS2/BS2BringUp.c"),
Object(Matching, "BS2/BS2Reset.c"),
@@ -729,7 +729,7 @@ config.libs = [
IPLSection("address", [
Object(Matching, "scene/address/iplAddress.cpp"),
Object(Matching, "scene/address/iplAddressAddSel.cpp"),
Object(NonMatching, "scene/address/iplAddressEdit.cpp"),
Object(Matching, "scene/address/iplAddressEdit.cpp"),
]
),
IPLSection("backMenu", [
@@ -814,7 +814,7 @@ config.libs = [
IPLSection("memoryCard", [
Object(Matching, "scene/memoryCard/iplMemoryCard.cpp"),
Object(Matching, "scene/memoryCard/iplMemoryCardBase.cpp"),
Object(NonMatching, "scene/memoryCard/iplMemoryCardManager.cpp"),
Object(Matching, "scene/memoryCard/iplMemoryCardManager.cpp"),
Object(Matching, "scene/memoryCard/iplGCSaveData.cpp"),
Object(Matching, "scene/memoryCard/iplGCWindow.cpp"),
]
@@ -824,7 +824,7 @@ config.libs = [
]
),
IPLSection("cardSequence", [
Object(NonMatching, "scene/cardSequence/iplCardSequence.cpp"),
Object(Matching, "scene/cardSequence/iplCardSequence.cpp"),
]
),
IPLSection("nakamuraTest", [
@@ -849,12 +849,12 @@ config.libs = [
]
),
IPLSection("sdChannelSelect", [
Object(NonMatching, "scene/sdChannelSelect/iplSDChannelSelect.cpp"),
Object(Matching, "scene/sdChannelSelect/iplSDChannelSelect.cpp"),
Object(Matching, "scene/sdChannelSelect/iplSDChannelObj.cpp"),
]
),
IPLSection("sdChannelTitle", [
Object(NonMatching, "scene/sdChannelTitle/iplSDChannelTitle.cpp"),
Object(Matching, "scene/sdChannelTitle/iplSDChannelTitle.cpp"),
]
),
IPLSection("sdButton", [
@@ -864,11 +864,11 @@ config.libs = [
]
),
IPLSection("sdChannelMemory", [
Object(NonMatching, "scene/sdChannelMemory/iplSDMemory.cpp"),
Object(Matching, "scene/sdChannelMemory/iplSDMemory.cpp"),
]
),
IPLSection("setting", [
Object(NonMatching, "scene/setting/iplSetting.cpp"),
Object(Matching, "scene/setting/iplSetting.cpp"),
Object(Matching, "scene/setting/iplSensitivity.cpp"),
Object(Matching, "scene/setting/iplNCDSetting.cpp"),
Object(Matching, "scene/setting/iplParental.cpp"),
@@ -876,10 +876,11 @@ config.libs = [
Object(Matching, "scene/setting/iplUSBAP.cpp"),
Object(Matching, "scene/setting/iplUSBAPThread.cpp"),
Object(Matching, "scene/setting/iplAOSSThread.cpp"),
Object(NonMatching, "scene/setting/AOSSLink.c"),
Object(Matching, "scene/setting/AOSSLink.c"),
Object(Matching, "scene/setting/iplRakuRakuThread.cpp"),
Object(NonMatching, "scene/setting/AOSS.c", extra_cflags=["-O4,p", "-inline off"]),
Object(NonMatching, "scene/setting/ATERM.c", extra_cflags=["-O4,p", "-inline on"]),
Object(Matching, "scene/setting/AOSS.c", extra_cflags=["-O4,p", "-inline on,noauto"]),
Object(Matching, "scene/setting/AOSSData.c"),
Object(Matching, "scene/setting/ATERM.c", mw_version="GC/3.0a5", extra_cflags=["-O4,p", "-inline on"]),
]
),
IPLSection("settingSelect", [
@@ -910,14 +911,14 @@ config.libs = [
IPLSection("keyboard", [
Object(Matching, "keyboard/tiPcKeyboard.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiCellPhone.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiInputForm.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiCandidateBox.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiInputForm.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiCandidateBox.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiToolBar.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiPredictLang.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiSignWindow.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiString.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiString.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiAtokString.cpp", extra_cflags=["-O4,p"]), # for 4.3J
Object(NonMatching, "keyboard/tiZiString.cpp", extra_cflags=["-O4,p"]), # for 4.3U and 4.3E
Object(Matching, "keyboard/tiZiString.cpp", extra_cflags=["-O4,p"]), # for 4.3U and 4.3E
Object(Matching, "keyboard/tiTextDrawer.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiNw4rManager.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiKeyboard.cpp", extra_cflags=["-O4,p"]),
@@ -941,7 +942,7 @@ config.libs = [
]
),
IPLSection("channelScript", [
Object(NonMatching, "channelScript/CHANSVm.c"),
Object(Matching, "channelScript/CHANSVm.c"),
Object(Matching, "channelScript/systemmenu/VmSystem.c"),
Object(Matching, "channelScript/systemmenu/iplCSSystem.cpp"),
Object(Matching, "channelScript/systemmenu/iplCSLayout.cpp"),
@@ -983,10 +984,10 @@ config.libs = [
ZI8Lib("zi8clib", [
Object(Matching, "clib/zaddress.c"),
Object(Matching, "clib/zconvert.c"),
Object(NonMatching, "clib/zi81key.c"),
Object(NonMatching, "clib/zi8alpha.c"),
Object(Matching, "clib/zi81key.c"),
Object(Matching, "clib/zi8alpha.c"),
Object(Matching, "clib/zi8alts.c"),
Object(NonMatching, "clib/zi8cgetc.c"),
Object(Matching, "clib/zi8cgetc.c"),
Object(Matching, "clib/zi8cinfo.c"),
Object(Matching, "clib/zi8copy.c"),
Object(Matching, "clib/zi8dawg.c"),
@@ -1000,17 +1001,17 @@ config.libs = [
Object(Matching, "clib/zi8pud2.c"),
Object(Matching, "clib/Zi8punct.c"),
Object(Matching, "clib/zi8space.c"),
Object(NonMatching, "clib/zi8uwd.c"),
Object(Matching, "clib/zi8uwd.c"),
Object(Matching, "clib/zi8ver.c"),
Object(Matching, "clib/zi8ZHuwd.c"),
Object(Matching, "clib/zidawg1.c"),
Object(Matching, "clib/zikorean.c"),
Object(Matching, "clib/ziswordw.c"),
Object(NonMatching, "clib/zkokeyp.c"),
Object(Matching, "clib/zkokeyp.c"),
Object(Matching, "clib/zierror.c"),
Object(Matching, "clib/zmtkey.c"),
Object(Matching, "clib/zoemdata.c"),
Object(NonMatching, "clib/zprepare.c"),
Object(Matching, "clib/zprepare.c"),
]
),
# RevoEX
@@ -1048,7 +1049,7 @@ config.libs = [
Object(Matching, "net/hmac.c"),
Object(Matching, "net/neterrorcode.c"),
Object(Matching, "net/NETVersion.c"),
Object(NonMatching, "net/aes.c"),
Object(Matching, "net/aes.c"),
Object(Matching, "net/wireless_macaddr.c"),
]
),
@@ -1057,11 +1058,11 @@ config.libs = [
Object(Matching, "nhttp/NHTTP_control.c"),
Object(Matching, "nhttp/NHTTP_list.c"),
Object(Matching, "nhttp/NHTTP_os_RVL.c"),
Object(NonMatching, "nhttp/NHTTP_recvbuf.c"),
Object(Matching, "nhttp/NHTTP_recvbuf.c", mw_version="GC/3.0a5"),
Object(Matching, "nhttp/NHTTP_request.c"),
Object(Matching, "nhttp/NHTTP_response.c"),
Object(Matching, "nhttp/NHTTP_socket_RVL.c"),
Object(NonMatching, "nhttp/NHTTP_stdlib_RVL.c"),
Object(Matching, "nhttp/NHTTP_stdlib_RVL.c", mw_version="GC/3.0a5"),
Object(Matching, "nhttp/NHTTP_thread.c"),
Object(Matching, "nhttp/d_nhttp_private.c"),
Object(Matching, "nhttp/d_nhttp.c"),
@@ -1096,7 +1097,7 @@ config.libs = [
),
RevoEXLib("so", [
Object(Matching, "so/SOCommon.c"),
Object(NonMatching, "so/SOBasic.c"),
Object(Matching, "so/SOBasic.c"),
Object(Matching, "so/SOInformation.c"),
Object(Matching, "so/SOOption.c"),
]
@@ -1201,7 +1202,7 @@ config.libs = [
Object(Matching, "buffer/mkhdec3.c"),
Object(Matching, "buffer/buffer_system.c"),
Object(Matching, "buffer/getcode.c"),
Object(NonMatching, "buffer/idct_block_var.c"),
Object(Matching, "buffer/idct_block_var.c"),
Object(Matching, "api/decapi.c"),
@@ -1209,14 +1210,14 @@ config.libs = [
Object(Matching, "jpegdec/jdec_main.c"),
Object(Matching, "jpegdec/jpformat.c"),
Object(NonMatching, "exif/exif_parse.c"),
Object(Matching, "exif/exif_parse.c"),
Object(Matching, "reschange/iqdec_resolution_change_a3.c"),
Object(Matching, "reschange/idct_resolution_change_var.c"),
Object(NonMatching, "texturecvtr/Texture_MCUtoY8U8V8.c"),
Object(NonMatching, "texturecvtr/Texture_MCUtoRGB565.c"),
Object(NonMatching, "texturecvtr/Texture_MCUtoRGBA8.c"),
Object(Matching, "texturecvtr/Texture_MCUtoY8U8V8.c"),
Object(Matching, "texturecvtr/Texture_MCUtoRGB565.c"),
Object(Matching, "texturecvtr/Texture_MCUtoRGBA8.c"),
Object(Matching, "b65/iqdec_b65_frv32.c"),
]
@@ -1323,7 +1324,7 @@ config.libs = [
Object(Matching, "lyt/lyt_layout.cpp"),
Object(Matching, "lyt/lyt_picture.cpp"),
Object(Matching, "lyt/lyt_textBox.cpp"),
Object(Equivalent, "lyt/lyt_window.cpp"),
Object(Matching, "lyt/lyt_window.cpp"),
Object(Matching, "lyt/lyt_bounding.cpp"),
Object(Matching, "lyt/lyt_material.cpp"),
Object(Matching, "lyt/lyt_drawinfo.cpp"),
@@ -1690,7 +1691,7 @@ config.libs = [
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(Matching, "fa/pdm_partition.c"),
Object(Matching, "fa/pf_cache.c"),
Object(Matching, "fa/pf_cluster.c"),
Object(Matching, "fa/pf_dir.c"),
@@ -1854,7 +1855,7 @@ config.libs = [
Object(Matching, "fa/kernel/pfk_api.c"),
Object(Matching, "fa/driver/nand_drv.c"),
Object(NonMatching, "fa/driver/sd_drv.c"),
Object(Matching, "fa/driver/sd_drv.c"),
Object(Matching, "fa/driver/pfd_cmn.c"),
Object(Matching, "fa/driver/msc_drv.c"),
@@ -1868,7 +1869,7 @@ config.libs = [
]
),
RVLSDKLib("nup", [
Object(NonMatching, "nup/nup.cpp"),
Object(Matching, "nup/nup.cpp"),
Object(Matching, "nup/nup_nhttp.cpp"),
Object(Matching, "nup/nup_mem.cpp"),
]
@@ -1885,7 +1886,7 @@ config.libs = [
]
),
RVLSDKLib("kbd", [
Object(NonMatching, "kbd/kbd_lib.c"),
Object(Matching, "kbd/kbd_lib.c"),
Object(NonMatching, "kbd/kbd_lib_map_jp.c"),
Object(Matching, "kbd/kbd_lib_map_us.c"),
Object(NonMatching, "kbd/kbd_lib_map_eu.c"),

View File

@@ -1,12 +1,11 @@
# Assembly inventory
4.3U, 2026-10-05. 173 functions contain 175 assembly
bodies/blocks: 162 ORIGINAL functions and 11 PLACEHOLDER functions.
4.3U, 2026-10-09. 162 functions contain 164 assembly
bodies/blocks: 162 ORIGINAL functions and 0 PLACEHOLDER functions.
Run `python3 tools/check_asm_inventory.py`. Completion requires exit 0, complete
coverage and zero placeholders. The checker also rejects stale/duplicate rows,
invalid classifications and syntax it cannot inspect. This audit supersedes the
historical inventory in `tools/decomp-assist/asm-inventory.md`.
invalid classifications and syntax it cannot inspect.
Scope: C/C++ sources and headers in `src/` and `libs/`, including inactive
platform branches, plus standalone assembly there or referenced by
@@ -21,8 +20,7 @@ The rvl_dec family follows the original decoder convention specified for this
audit; ASH/ASR also show unsigned `lis @h`/`ori @l` address construction and
hand-built `stmw` frames. C scores below are recorded rejected trials, not fresh
measurements or scores of the retained assembly. Unrecorded means no C score was
found. Historical logs absent from this branch have commit IDs and excerpts in
[the audit log](../tools/decomp-assist/rx36.attempts.md).
found. Historical audit logs are in git history.
| File | Function | Classification | Evidence |
| --- | --- | --- | --- |
@@ -37,7 +35,6 @@ found. Historical logs absent from this branch have commit IDs and excerpts in
| `libs/NW4R/include/nw4r/math/types.h` | `VEC3Scale` | ORIGINAL | psq_l/ps_muls0/psq_st implements paired-single vector/matrix operations. |
| `libs/NW4R/src/math/math_arithmetic.cpp` | `FrSqrt` | ORIGINAL | frsqrte plus fixed refinement matches the public [NW4R arithmetic assembly][arithmetic-cpp]. |
| `libs/NW4R/src/math/math_types.cpp` | `MTX44Identity` | ORIGINAL | psq_st/ps_merge01/ps_merge10 implements paired-single vector/matrix operations. |
| `libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main.c` | `TMCJPEGDEC_err_restart` | PLACEHOLDER | JPEG marker scan; best C 95.73913%, 114/115 instructions, folded exit branch, [rx19](../tools/decomp-assist/rx19.attempts.md), [rx24][rx24]. |
| `libs/RVL_SDK/include/revolution/os/OSFastCast.h` | `OSInitFastCast` | ORIGINAL | mtspr programs the GQR quantization registers. |
| `libs/RVL_SDK/include/revolution/os/OSFastCast.h` | `__OSu16tof32` | ORIGINAL | psq_l uses a GQR integer conversion format for the fast cast. |
| `libs/RVL_SDK/include/revolution/os/OSFastCast.h` | `__OSf32tou8` | ORIGINAL | psq_st uses a GQR integer conversion format for the fast cast. |
@@ -88,9 +85,6 @@ found. Historical logs absent from this branch have commit IDs and excerpts in
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCSetFpIEEEMode` | ORIGINAL | Special-register or synchronization operation: `mtfsb0 FPSCR_NI_BIT`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCSetFpNonIEEEMode` | ORIGINAL | Special-register or synchronization operation: `mtfsb1 FPSCR_NI_BIT`. |
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMthid4` | ORIGINAL | Both branches write HID4 with mtspr; the fallback preserves the Broadway H4A bit. |
| `libs/RVL_SDK/src/cntcache/cntcache.c` | `CNTCACHEClear` | PLACEHOLDER | NAND/token logic; best C 93.364235%, 147/151 instructions, four missing pool literals, [rx30][rx30]. |
| `libs/RVL_SDK/src/cntcache/cntcache.c` | `_CNTCACHEIsTitleRemovable` | PLACEHOLDER | NAND/TMD checks; best diagnostic C 93.70731%, 82/82 instructions, status-register interference, [rx18][rx18]. |
| `libs/RVL_SDK/src/cntcache/cntcache.c` | `_CNTCACHEDeleteContent` | PLACEHOLDER | Token parsing and ES deletion; best C 95.793106%, 143/145 instructions, missing reload/copy, [rx18][rx18]. |
| `libs/RVL_SDK/src/db/db.c` | `__DBExceptionDestination` | ORIGINAL | mfmsr/mtmsr enable address translation before the exception-handler tail branch. |
| `libs/RVL_SDK/src/gx/GXLight.c` | `PushLight` | ORIGINAL | psq_l/psq_st transfers paired-single values for the GX command stream. |
| `libs/RVL_SDK/src/gx/GXTransform.c` | `WriteProjPS` | ORIGINAL | psq_l/psq_st transfers paired-single values for the GX command stream. |
@@ -162,7 +156,6 @@ found. Historical logs absent from this branch have commit IDs and excerpts in
| `libs/RVL_SDK/src/os/__ppc_eabi_init.cpp` | `__init_hardware` | ORIGINAL | Before normal C startup, mfmsr/mtmsr enables the FPU and r31 holds LR across init calls. |
| `libs/RVL_SDK/src/os/__ppc_eabi_init.cpp` | `__flush_cache` | ORIGINAL | dcbst/sync/icbi/isync make freshly initialized code visible to instruction fetch. |
| `libs/RVL_SDK/src/os/__ppc_eabi_init.cpp` | `__init_user` | ORIGINAL | fralloc/bl __init_cpp/frfree/blr matches the public [SDK startup assembly][sdk-init]. |
| `libs/RevoEX/src/nwc24/NWC24UserId.c` | `getUnScrambleId` | PLACEHOLDER | Integer byte permutation; best C 76.27329%, 161/161 instructions, 97 register/scheduling differences, [rx30][rx30]. |
| `libs/Runtime/src/Gecko_setjmp.c` | `__setjmp` | ORIGINAL | Saves or restores caller GPRs/FPRs, LR, CR, and stack state across nonlocal returns. |
| `libs/Runtime/src/Gecko_setjmp.c` | `longjmp` | ORIGINAL | Saves or restores caller GPRs/FPRs, LR, CR, and stack state across nonlocal returns. |
| `libs/Runtime/src/__init_cpp_exceptions.cpp` | `__exception_info_constants` | ORIGINAL | Reads the caller ABI TOC register r2 directly for exception registration. |
@@ -189,22 +182,11 @@ found. Historical logs absent from this branch have commit IDs and excerpts in
| `src/BS2/BS2Start.c` | `__start` | ORIGINAL | Runs before the C stack and ABI registers exist; constructs the initial stack. |
| `src/BS2/BS2Start.c` | `__init_registers` | ORIGINAL | Initializes GPRs, r1, r2, and r13 for the C runtime. |
| `src/scene/nakamuraTest/gamespy/common/gsPlatformUtil.c` | `GetTicks` | ORIGINAL | Inactive PS2 branch reads the CP0 Count register with mfc0 $9. |
| `src/system/TVRC.cpp` | `TVRCSendStartAsync` | PLACEHOLDER | IR command setup; best recorded C 99.77273%, 198/198 instructions, seven differences, [rx2](../tools/decomp-assist/rx2.attempts.md); newer [rx17][rx17] 99.747475%. |
| `src/system/iplChannelManager.cpp` | `getTitleName__Q33ipl7channel7ManagerCFiii` | PLACEHOLDER | Channel-name copying; best C 99.57746%, 71/71 instructions, four address-order differences, [rx17][rx17]. |
| `src/system/iplSaveDataManager.cpp` | `Manager::hasChannel` | PLACEHOLDER | Title-slot search; best C 98.87324%, 71/71 instructions, 14 mask/base register differences, [rx30][rx30]. |
| `src/system/iplSaveDataManager.cpp` | `Manager::makePriorTitleIDList` | PLACEHOLDER | Title filtering; best recorded C 80.22556%, 124/133 instructions, address CSE, [da1](../tools/decomp-assist/da1.attempts.md); newer [rx17][rx17] 79.827065%. |
| `src/system/iplSaveDataManager.cpp` | `Manager::doUpdateChanInfos` | PLACEHOLDER | Channel metadata updates; best C 93.35821%, 68/67 instructions, extra memset base, [rx17][rx17]. |
| `src/system/iplSystem.cpp` | `System::warning_run` | PLACEHOLDER | Scene/render calls; best C 98.66477%, 176/176 instructions, 47 saved-register differences, [rx17][rx17]. |
| `src/system/rvl_dec.c` | `Rvl_decode` | ORIGINAL | Direct beq decoder entries preserve r3/r4 and LR; lis/ori builds the format signatures. |
| `src/system/rvl_dec.c` | `Rvl_decode_szs` | ORIGINAL | Original SZS decoder convention: nofralloc, r0 retains output length, fixed r3..r10/CTR byte-copy pipeline. |
| `src/system/rvl_dec.c` | `Rvl_decode_ash` | ORIGINAL | nofralloc hand-built 0x40 frame saves r21..31 with stmw; work address uses lis @h/ori @l. |
| `src/system/rvl_dec.c` | `Rvl_decode_asr` | ORIGINAL | nofralloc hand-built 0x40 frame saves r21..31 with stmw; work address uses lis @h/ori @l. |
[rx17]: ../tools/decomp-assist/rx36.attempts.md#rx17
[rx18]: ../tools/decomp-assist/rx36.attempts.md#rx18
[rx24]: ../tools/decomp-assist/rx36.attempts.md#rx24
[rx30]: ../tools/decomp-assist/rx36.attempts.md#rx30
[rx36-osinit]: ../tools/decomp-assist/rx36.attempts.md#osinit
[sdk-init]: https://github.com/doldecomp/ogws/blob/master/src/revolution/OS/__ppc_eabi_init.c
[runtime]: https://github.com/doldecomp/ogws/blob/master/src/runtime/runtime.c
[arithmetic-h]: https://github.com/doldecomp/ogws/blob/master/include/nw4r/math/math_arithmetic.h

View File

@@ -19,7 +19,7 @@ extern "C" {
#define CHANS_VM_CLASS_NAME_LEN 32
CHANSVmErr CHANSVmInit(CHANSVm* vm, vmPtr work, vmU32 size);
CHANSVmErr CHANSVmLinkModules(CHANSVm* vm, vmS32 unk0);
CHANSVmErr CHANSVmLinkModules(CHANSVm* vm, vmS32 reserved);
void CHANSVmSetSignal(CHANSVm* vm, vmBool* signal);
@@ -30,7 +30,7 @@ void CHANSVmSetSignal(CHANSVm* vm, vmBool* signal);
vmU32 CHANSVmGetFreeExeSize(CHANSVm* vm);
vmPtr CHANSVmGetFreeExeBufp(CHANSVm* vm);
CHANSVmErr CHANSVmAddExe(CHANSVm* vm, vmS32 unk0, CHANSVm* execCtx);
CHANSVmErr CHANSVmAddExe(CHANSVm* vm, vmS32 reserved, CHANSVm* execCtx);
CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount);

View File

@@ -7,7 +7,7 @@
extern "C" {
#endif
typedef CHANSVmObjHdr* (*VmConvertFunc)(CHANSVm*, CHANSVmObjType, CHANSVmObjHdr*);
typedef CHANSVmObjHdr* (*VmConvertFunc)(CHANSVm*, CHANSVmObjType, const CHANSVmObjHdr*);
typedef struct VmConvertEntry {
VmConvertFunc convFunc[6]; // 0x00

View File

@@ -12,6 +12,7 @@ extern void __sync();
extern unsigned int __cntlzw(unsigned int value);
extern void __memclr(void* buffer, int len);
extern unsigned int __rlwimi(unsigned int a, unsigned int b, unsigned int c, unsigned int d, unsigned int e);
extern unsigned int __rlwinm(unsigned int value, unsigned int shift, unsigned int maskBegin, unsigned int maskEnd);
extern void* __alloca(unsigned int blockSize);
extern int __abs(int n);

View File

@@ -10,7 +10,7 @@ namespace ipl {
volatile u16 size; // 0x02
u8 canCopy; // 0x04
u8 canMove; // 0x05
u16 unk_0x06; // 0x06
u16 transferBlocked; // 0x06
u32 key; // 0x08
} FileInfo; // 0x0C
@@ -21,21 +21,21 @@ namespace ipl {
vu16 reservedSlot; // 0x04
vu16 reservedCommand; // 0x06
vu32 key; // 0x08
vu16 unk_0x0C; // 0x0C
vu16 unk_0x0E; // 0x0E
vu16 totalBlocks; // 0x0C
vu16 freeFiles; // 0x0E
vu16 freeBlocks; // 0x10
vu16 unk_0x12; // 0x12
vu16 titleBlocks; // 0x12
} CardState; // 0x14
typedef struct IconState {
volatile u8 bannerEnable; // 0x00
u8 unk_0x01; // 0x01
u8 unk_0x02; // 0x02
u8 iconEnable; // 0x01
u8 iconCount; // 0x02
u8 bannerType; // 0x03
s8 anmDelta; // 0x04
u8 anmType; // 0x05
u8 unk_0x06; // 0x06
u8 unk_0x07; // 0x07
u8 anmFirstFrameDuration; // 0x06
u8 anmLastFrameDuration; // 0x07
u8 iconFmt[8]; // 0x08
#ifdef IPL_MEMORY_CARD_MANAGER_CPP
volatile u16 anmFrameBits;

View File

@@ -77,7 +77,7 @@ namespace textinput {
class Base : public CommandSender {
public:
#ifdef TIMANAGER_IMPLEMENTATION
#if defined(TIMANAGER_IMPLEMENTATION) || defined(TI_CANDIDATEBOX_SAMPLE_CLASS)
Base(Manager* manager) : mpCandidates(NULL), mpAllocator(NULL), mbOn(false), mbInvalid(true), meLanguage(USA), mpManager(manager) {}
#endif
virtual ~Base();
@@ -114,7 +114,7 @@ namespace textinput {
class EventHandler : public nw4rmanager::TiEventHandler {
public:
#ifdef TIMANAGER_IMPLEMENTATION
#if defined(TIMANAGER_IMPLEMENTATION) || defined(TI_CANDIDATEBOX_SAMPLE_CLASS)
EventHandler(LayoutByNW4R* layout) : mpLayoutByNW4R(layout) {}
#endif
virtual void onTiEvent(gui::PaneComponent* paneComponent, u32 event, Input* input) override; // 0x18
@@ -302,7 +302,7 @@ namespace textinput {
// TODO
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public UIObj::Listener {
public:
#ifdef TIMANAGER_IMPLEMENTATION
#if defined(TIMANAGER_IMPLEMENTATION) || defined(TI_CANDIDATEBOX_SAMPLE_CLASS)
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),
@@ -371,6 +371,15 @@ namespace textinput {
bool mbActive;
};
#ifdef TI_CANDIDATEBOX_SAMPLE_CLASS
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, accessor, observer, layoutName) {}
virtual ~Sample() {}
};
#endif
class CandidateTextAnmPane : public nw4rmanager::AnmPane {
public:
CandidateTextAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)

View File

@@ -178,8 +178,14 @@ namespace textinput {
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;
bool hasZiPredictions() const;
bool usesZiPrediction() const;
#ifdef TIINPUTFORM_IMPLEMENTATION
void checkUnfixConverting_();
void setAtokMode_(bool fixMode, bool kanaMode);
void trimString_(u32 length);
void startConverting_();
#endif
inline void resetPredictionContext();
inline void resetInputRelation();
#endif
@@ -356,6 +362,7 @@ namespace textinput {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
friend class EventHandler;
inline const nw4r::lyt::Pane* getLanguageTextPane() const;
inline nw4r::lyt::TextBox* getTextBox() const;
#endif
public:
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)

View File

@@ -129,7 +129,7 @@ namespace textinput {
#ifdef TIHWKEYBOARD_IMPLEMENTATION
EventObserver* getEventObserverForHardware() const { return mpEventObserver; }
#endif
#ifdef TISIGNWINDOW_IMPLEMENTATION
#if defined(TISIGNWINDOW_IMPLEMENTATION) || defined(IPL_ADDRESS_EDIT_CPP)
virtual InputForm* getInputForm();
#else
virtual InputForm* getInputForm() { return mpInputForm; }

View File

@@ -85,10 +85,30 @@ namespace textinput {
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION)
virtual ~Decolated() {}
#else
virtual ~Decolated();
#endif
enum TranslateMode { TM_Direct, TM_Kana, TM_Roman, TM_Hangul };
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION)
virtual void clear() {
StringBase::clear();
mCursorStart = 0;
mCursorEnd = 0;
mbSustain = false;
initKanaConverter();
}
virtual void set(const wchar_t* string) {
StringBase::set(string);
u32 length = getLength();
mCursorStart = length;
mCursorEnd = length;
}
#else
virtual void clear();
virtual void set(const wchar_t* string);
#endif
virtual void setLength(u16 length);
void setTranslateMode(TranslateMode mode);
TranslateMode getTranslateMode() const { return static_cast<TranslateMode>(mTranslateMode); }
@@ -194,6 +214,9 @@ namespace textinput {
public:
WithAtok(u16 maxLength) : Decolated(maxLength) {}
virtual ~WithAtok();
virtual bool isFix();
virtual void setFix(bool fix);
virtual void initConverting();
virtual void pushBack(wchar_t ch);
virtual void popBack();
virtual void inputChar(wchar_t ch);
@@ -209,9 +232,6 @@ namespace textinput {
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();

View File

@@ -47,8 +47,13 @@ namespace textinput {
public :
virtual ~Base() {}
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual void create(MEMAllocator* allocator) {}
virtual void init() {}
#else
virtual void create(MEMAllocator* allocator);
virtual void init();
#endif
};
class CommandSender;
@@ -59,8 +64,12 @@ namespace textinput {
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
CommandReceiver() { clearSender(); }
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual ~CommandReceiver() {}
#else
virtual ~CommandReceiver();
#endif
#endif
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
struct Scroll {
bool absY;
@@ -96,7 +105,11 @@ namespace textinput {
#else
virtual void sendCommand(u32, void*);
#endif
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
virtual void updateFromReceiver(u32, void*);
#else
virtual void updateFromReceiver(u32, void*) {}
#endif
nw4r::ut::Link mLink; // 0x00

View File

@@ -105,7 +105,7 @@ namespace ipl {
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
template <typename T>
class __declspec(novtable) HermiteIntp : public utility::FrameController {
class HermiteIntp : public utility::FrameController {
public:
HermiteIntp() {}
virtual ~HermiteIntp();
@@ -296,45 +296,6 @@ namespace ipl {
};
#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
} // namespace math
} // namespace ipl

View File

@@ -50,6 +50,7 @@ namespace ipl {
void add_friendinfo();
void delete_friendinfo();
void set_textbox(nw4r::lyt::Pane*, const wchar_t*);
void set_textbox(nw4r::lyt::Pane* pane, u32 msgId);
void setDefaultTitleText(const wchar_t*, bool);
static void wiiid_utf16(u64, wchar_t*);
static void nigaoe_create_callback_add(ipl::nigaoe::Object*, void*);

View File

@@ -159,7 +159,7 @@ namespace ipl {
RBRRecordType mRecordType; // 0xDC
u32 mOptOutFlag; // 0xE0
class {
class StandData {
public:
void init() {
mAngleIdx = -1;

View File

@@ -180,6 +180,7 @@ namespace ipl {
BOOL is_url_end_code(wchar_t ch) const;
BOOL is_url_protocol(const wchar_t* url) const;
BOOL is_url_ext(const wchar_t* url) const;
int get_url_end(const wchar_t* url) const;
BOOL is_buffer_over(const wchar_t* text, u32 textLen) const;

View File

@@ -12,7 +12,6 @@
namespace ipl {
namespace scene {
extern "C" BOOL push_button_queue(void*, const void*);
class ButtonEventHandlerBase;
class OptOutButtonEventHandlerBase;
class SDMenuEventHandlerBase;
@@ -315,7 +314,6 @@ namespace ipl {
}
protected:
friend BOOL push_button_queue(void*, const void*);
typedef struct Command {
enum {
TYPE_ANIM = 0,

View File

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

View File

@@ -166,11 +166,11 @@ namespace ipl {
void update_file_array(u8 slot);
void update_change_cardstate(u8 slot);
GXTexObj* create_icon(u8 slot, s16 index);
GXTexObj* create_icon(u8 slot, s16 index, long start);
GXTexObj* _create_icon(u8 slot, s16 fileNo, long start);
const GXTexObj* create_icon(u8 slot, s16 index);
const GXTexObj* create_icon(u8 slot, s16 index, long start);
const 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);
const GXTexObj* create_banner(u8 slot, s16 index);
#ifdef IPL_GC_WINDOW_CPP
u32 getBlocks(u8 slot, s16 index);
#else
@@ -187,7 +187,7 @@ namespace ipl {
}
private:
GXTexObj* initBannerTexture(u8 slot, s32 file, void* data) {
const GXTexObj* initBannerTexture(u8 slot, s32 file, void* data) {
GXInitTexObj(&mFileCell[slot][file].banner, data, CARD_BANNER_WIDTH, CARD_BANNER_HEIGHT,
GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
return &mFileCell[slot][file].banner;
@@ -203,6 +203,22 @@ namespace ipl {
return &mFileCell[slot][file].bannerTlut;
}
const GXTexObj* initIconTexture(u8 slot, s32 file, void* data) {
GXInitTexObj(&mFileCell[slot][file].icon, data, CARD_ICON_WIDTH, CARD_ICON_HEIGHT,
GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
return &mFileCell[slot][file].icon;
}
void initIconTextureCI(u8 slot, s32 file, void* data) {
GXInitTexObjCI(&mFileCell[slot][file].icon, data, CARD_ICON_WIDTH, CARD_ICON_HEIGHT,
GX_TF_C8, GX_CLAMP, GX_CLAMP, GX_FALSE, GX_TLUT0);
}
GXTlutObj* initIconPalette(u8 slot, s32 file, void* data) {
GXInitTlutObj(&mFileCell[slot][file].iconTlut, data, GX_TL_RGB5A3, 0x100);
return &mFileCell[slot][file].iconTlut;
}
u32 reserved; // 0x00004
MCFile mFile[2][CARD_MAX_FILE]; // 0x00008
MCFileCell mFileCell[2][CARD_MAX_FILE]; // 0x00FE8

View File

@@ -142,14 +142,9 @@ namespace ipl {
u32 mTransferStatus;
u64 mTransferStartTime;
s32 mTransferFrame;
struct TitleListState {
ESTitleId* mpTitles;
u32 mCount;
ESTitleId* mpSecondaryTitles;
u32 mSecondaryCount;
ESTitleId* mpNames;
u32 mNameCount;
} mTitleListState;
NandSDWorker::TitleIdList mTitleList;
NandSDWorker::TitleIdList mNandTitleList;
NandSDWorker::TitleIdList mSDTitleList;
scroller mScroller;
s32 mButtonState;
u8 mControllerFlags[4];

View File

@@ -177,8 +177,8 @@ namespace ipl {
const controller::Interface* controller);
BOOL onEventDerived(const char* paneName, u32 event,
controller::Interface* controller);
bool collectTitlesByUsage(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
bool collectTitlesByUsage(s32* firstUsage, s32* secondUsage,
ESTitleId* titleIds, wchar_t (*titleNames)[21],
u32* titleCount);
static const char* mscChannelPaneNames[PAGE_COUNT][MAX_CHANNEL_INDEX];
@@ -197,6 +197,8 @@ namespace ipl {
friend class SDChannelSelectEventHandler;
friend class SDChannelSelectButtonEventHandler;
#endif
friend class SDMemory;
void enqueueStartNotice();
bool enqueueFinishNotice();
bool enqueueNotice(u32 highTitleId, u32 lowTitleId, u32 result);
@@ -204,11 +206,14 @@ namespace ipl {
bool enqueuePageNotice();
bool enqueueResultNotice(u32 result);
bool enqueueChannelNotice(u64 titleId, u32 value);
bool enqueueMoveNotice(u32 controller, u32 page, u32 index);
bool enqueueMoveNotice(ESTitleId titleId);
bool enqueueStateNotice(u64 titleId, u32 state);
bool enqueueErrorNotice(u32 page, u32 index);
bool enqueueCommandNotice(u32 page, u32 index, u32 command);
bool enqueueDeleteNotice(u32 controller, u32 page, u32 index);
bool enqueueErrorNotice(NandSDWorker::TitleIdList* newTitles,
NandSDWorker::TitleIdList* replacingTitles);
bool enqueueCommandNotice(NandSDWorker::TitleIdList* titles,
NandSDWorker::TitleIdList* foundTitles,
NandSDWorker::TitleIdList* badTitles);
bool enqueueDeleteNotice(ESTitleId titleId);
void clearCommandQueue();
void clearNoticeQueue();
void calcChannelObjects();
@@ -221,7 +226,7 @@ namespace ipl {
int getCenterChannelIndex(const char* paneName) const;
nw4r::lyt::Pane* getCenterChannelPane(int index) const;
nw4r::lyt::Pane* getChannelPane(int index) const;
static math::VEC3 getChannelPanePosition(SDChannelSelect* scene, int index);
static nw4r::math::VEC3 getChannelPanePosition(SDChannelSelect* scene, int index);
void calcPageAnimations();
void processNormalInput();
void updateArrowVisibility();
@@ -232,17 +237,17 @@ namespace ipl {
void setChannelScissor(const SDChannelObj* channel) const;
bool isCurrentTitleUsageEnough(const s32* usage) const;
void getCurrentTitleUsage(s32* bytes, s32* blocks) const;
bool collectTitlesByChannelOrder(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
bool collectTitlesByChannelOrder(s32* firstUsage, s32* secondUsage,
ESTitleId* titleIds, wchar_t (*titleNames)[21],
u32* titleCount);
bool collectTitlesFromNandUsage(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
bool collectTitlesFromNandUsage(s32* firstUsage, s32* secondUsage,
ESTitleId* titleIds, wchar_t (*titleNames)[21],
u32* titleCount);
bool collectTitlesBySpecialChannels(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
bool collectTitlesBySpecialChannels(s32* firstUsage, s32* secondUsage,
ESTitleId* titleIds, wchar_t (*titleNames)[21],
u32* titleCount);
bool collectTitlesForMode(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
bool collectTitlesForMode(s32* firstUsage, s32* secondUsage,
ESTitleId* titleIds, wchar_t (*titleNames)[21],
u32* titleCount, int searchMode);
bool findAdjacentChannel(int direction, int* page, int* index) const;
void setStateAndPlaySelectSound(int state) NO_INLINE;

View File

@@ -20,6 +20,19 @@ typedef struct AOSSInitInput {
u8 result[0x154];
} AOSSInitInput;
typedef struct AOSSKeyMaterial {
u8 nonce[2];
u8 address[8];
} AOSSKeyMaterial;
typedef struct AOSSPacketState {
AOSSKeyMaterial key;
u8 payload[0x5e];
} AOSSPacketState;
extern AOSSPacketState s_packetState;
extern u32 s_crcTable[0x100];
int AOSSi_Init(AOSSInitInput* input);
int AOSS_Init_old(AOSSInitInput* input);
void* AOSSi_Alloc(u32 size);

View File

@@ -50,6 +50,7 @@ namespace ipl {
static void makeMasterkey();
static char* getRequestNum();
static void dump();
private:
static void _initRating();

View File

@@ -18,6 +18,15 @@ namespace ipl {
f32 margin16x9 = 120.0f, f32 margin4x3 = 30.0f);
~TextBalloon();
static f32 getDefaultMargin16x9() {
f32 margin = 120.0f;
return margin;
}
static f32 getDefaultMargin4x3() {
f32 margin = 30.0f;
return margin;
}
void calc();
void draw();

View File

@@ -277,6 +277,9 @@ namespace ipl {
/* SEntry */
bool hasLoadedBnr(int page, int index) const { return mChannels[page][index].loadedBnr; }
int getSceneID(int page, int index) const { return mChannels[page][index].loadedBnr ? mChannels[page][index].info.sceneID : 0; }
ESTitleId getEntryTitleID(int page, int index) const {
return mChannels[page][index].loadedBnr ? ES_TITLE_ID(mChannels[page][index].info.titleType, mChannels[page][index].info.titleCode) : 0;
}
/* SMetaBlockHeader */
u32 getIconRSOIdx(int page, int index) const {

View File

@@ -15,7 +15,7 @@ namespace ipl {
Manager(EGG::Heap* heap);
/** @return The message data in use. */
const wchar_t* getMessage(u32 id) const { return mpMessage->getMessage(id); }
wchar_t* getMessage(u32 id) const { return mpMessage->getMessage(id); }
void setResource(u8* msgData) const { mpMessage->setResource(msgData); }
private:

View File

@@ -190,6 +190,7 @@ namespace ipl {
PointerCore mCore; // 0x40
friend class System;
friend class PointerCoreObject;
friend class PointerCore;
friend class utility::BScroller;

View File

@@ -302,7 +302,7 @@ namespace ipl {
}
/** @return The Message ID as a Wide-string. */
static const wchar_t* getMessage(u32 id) { return smArg.mpMessageMgr->getMessage(id); }
static wchar_t* getMessage(u32 id) { return smArg.mpMessageMgr->getMessage(id); }
static message::Manager* getMessageManager() { return smArg.mpMessageMgr; }
static void* getFont();

View File

@@ -47,6 +47,8 @@ namespace ipl {
static ESError GetValidTicketIndex(EGG::Heap* heap, ESTitleId titleId, ESTicketView* ticket = NULL, u32 ticketLength = 0);
static ESError DeleteSharedContent(EGG::Heap* heap);
static BOOL IsLastTicketExpired(ESTitleId* titleId);
static void DeleteExpiredFlagFile();

View File

@@ -10,31 +10,9 @@ namespace ipl {
public:
inline Queue<T, c>() : count(c), current(0), popped(0), pushed(0) {}
BOOL push(const T& item) {
if (count == current) {
return FALSE;
}
items[pushed] = item;
if (++pushed >= count) {
pushed = 0;
}
current++;
return TRUE;
}
BOOL push(const T& item);
BOOL pop() {
BOOL result = TRUE;
if (current == 0) {
result = FALSE;
goto done;
}
if (++popped >= count) {
popped = 0;
}
current--;
done:
return result;
}
BOOL pop();
int get_current_index() { return current; }
T& get_current_item() { return items[get_current_index()]; }
@@ -55,6 +33,34 @@ namespace ipl {
int current; // (sizeof(items) * count) + 0x04
int popped, pushed; // (sizeof(items) * count) + 0x08
};
template <typename T, int c>
BOOL Queue<T, c>::push(const T& item) {
if (count == current) {
return FALSE;
}
items[pushed] = item;
if (++pushed >= count) {
pushed = 0;
}
current++;
return TRUE;
}
template <typename T, int c>
BOOL Queue<T, c>::pop() {
BOOL result = TRUE;
if (current == 0) {
result = FALSE;
goto done;
}
if (++popped >= count) {
popped = 0;
}
current--;
done:
return result;
}
} // namespace utility
} // namespace ipl

View File

@@ -55,7 +55,7 @@ namespace ipl {
void init() {
mState = 0;
mScroll = 0.0f;
unk_0x3C = 0.0f;
mScrollVelocity = 0.0f;
mUpLimit = 0.0f;
mDownLimit = 0.0f;
}
@@ -92,7 +92,7 @@ namespace ipl {
int mState; // 0x30
f32 mDownLimit; // 0x34
f32 mUpLimit; // 0x38
f32 unk_0x3C;
f32 mScrollVelocity;
f32 mScroll; // 0x40
f32 mButtonScrollOrigin;
f32 mVelocityDecay;

View File

@@ -4,7 +4,7 @@
#include <nw4r/snd.h>
#include <revolution/os.h>
#pragma sym on
namespace EGG {
ArcPlayer::ArcPlayer(nw4r::snd::SoundHeap* pHeap) : mpSoundHeap(pHeap) {
mStorage = SARC_STORAGE_NONE;

View File

@@ -74,8 +74,7 @@ namespace EGG {
return MEMAllocFromFrmHeapEx(mHeapHandle, size, align);
}
void FrmHeap::free(void* ptr) {
#pragma unused(ptr)
void FrmHeap::free(void*) {
}
u32 FrmHeap::resizeForMBlock(void* ptr, u32 size) {

View File

@@ -36,8 +36,6 @@ namespace EGG {
}
void* Heap::alloc(u32 size, int align, Heap* heap) {
void* ptr = NULL;
if (sAllocatableHeap != NULL) {
if (sCurrentHeap != NULL && heap == NULL) {
heap = sCurrentHeap;
@@ -53,13 +51,7 @@ namespace EGG {
}
if (sCurrentHeap != NULL) {
ptr = sCurrentHeap->alloc(size, align);
if (ptr == NULL) {
// stripped out EGG_PRINT
}
return ptr;
return sCurrentHeap->alloc(size, align);
}
return NULL;
@@ -170,7 +162,7 @@ void* operator new[](size_t size, EGG::Heap* heap, int align) {
void operator delete(void* ptr) {
EGG::Heap::free(ptr, NULL);
// don't inline. (NO_INLINE did not want to work)
// MWCC needs these no-op statements to keep operator delete out of Heap's destructor.
(void)0;
(void)0;
(void)0;

View File

@@ -22,7 +22,11 @@ int strcmp(const char* s1, const char* s2);
char* strpbrk(const char* s1, const char* s2);
size_t strspn(const char* s1, const char* s2);
char* strtok(char* str, const char* delimiters);
#ifdef __cplusplus
const char* strstr(const char* str, const char* pat);
#else
char* strstr(const char* str, const char* pat);
#endif
char* strncpy(char* dst, const char* src, size_t length);
char* strncat(char* dst, const char* src, size_t length);
@@ -39,4 +43,12 @@ int strcmpi(const char* s1, const char* s2);
}
#endif
#ifdef __cplusplus
extern "C++" {
inline char* strstr(char* str, const char* pat) {
return const_cast<char*>(strstr(static_cast<const char*>(str), pat));
}
}
#endif
#endif // MSL_STRING_H

View File

@@ -27,7 +27,11 @@ wchar_t* wcscat(wchar_t* dest, const wchar_t* src);
wchar_t* wcsncat(wchar_t* dest, const wchar_t* src, size_t num);
int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t num);
wchar_t* wcschr(wchar_t* ws, wchar_t wc);
#ifndef __cplusplus
wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2);
#else
const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2);
#endif
int swprintf(wchar_t* ws, size_t len, const wchar_t* format, ...);
int vswprintf(wchar_t* ws, size_t len, const wchar_t* format, va_list arg);
@@ -36,6 +40,12 @@ int wcsnicmp(const char* dst, const char* src, size_t num);
#ifdef __cplusplus
}
extern "C++" {
inline wchar_t* wcsstr(wchar_t* s1, const wchar_t* s2) {
return const_cast<wchar_t*>(wcsstr(static_cast<const wchar_t*>(s1), s2));
}
}
#endif
#endif // MSL_WCHAR_H

View File

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

View File

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

View File

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

View File

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

View File

@@ -123,7 +123,7 @@ namespace nw4r {
const math::MTX34& GetMtx() const { return mMtx; }
void SetMtx(const math::MTX34& mtx) { mMtx = mtx; }
u8 GetAlpha() { return mAlpha; }
u8 GetAlpha() const { return mAlpha; }
void SetAlpha(u8 alpha) { mAlpha = alpha; }
const char* GetName() const { return mName; }

View File

@@ -55,16 +55,14 @@ namespace nw4r {
NW4R_ASSERT(type < TEXTCOLOR_MAX);
return mTextColors[type];
}
#ifdef IPL_SDMEMORY_SET_TEXT_COLORS
void SetTextColors(const ut::Color& first, const ut::Color& second) {
mTextColors[0] = first;
mTextColors[1] = second;
}
#endif
void SetTextColor(u32 type, ut::Color value) {
NW4R_ASSERT(type < TEXTCOLOR_MAX);
mTextColors[type] = value;
}
void SetTextColor(ut::Color top, ut::Color bottom) {
mTextColors[0] = top;
mTextColors[1] = bottom;
}
void SetTextPositionH(u8 pos) { detail::SetHorizontalPosition(&mTextPosition, pos); }
void SetTextPositionV(u8 pos) { detail::SetVerticalPosition(&mTextPosition, pos); }

View File

@@ -18,29 +18,29 @@ namespace nw4r {
inline u32 CalcOffsetSheetData(u16 countNames) {
return ROUNDUP(CalcOffsetNameOffsetData() + countNames * sizeof(u16), 4);
}
inline u32 CalcOffset0AData(u16 countNames, u16 countSheets) {
inline u32 CalcOffsetCWDHData(u16 countNames, u16 countSheets) {
return ROUNDUP(CalcOffsetSheetData(countNames) + countSheets * sizeof(u32), 4);
}
inline u32 CalcOffset0CData(u16 countNames, u16 countSheets, u16 count0A) {
return ROUNDUP(CalcOffset0AData(countNames, countSheets) + count0A * sizeof(u32), 4);
inline u32 CalcOffsetCMAPData(u16 countNames, u16 countSheets, u16 countCWDH) {
return ROUNDUP(CalcOffsetCWDHData(countNames, countSheets) + countCWDH * sizeof(u32), 4);
}
inline u32 CalcSizeFlagSet(u32 entries) {
return ((s32)entries + 0x1f) / 32 * 4;
}
inline u32 CalcOffsetSheetFlags(u16 countNames, u16 countSheets, u16 count0A, u16 count0C) {
return ROUNDUP(CalcOffset0CData(countNames, countSheets, count0A) + count0C * sizeof(u32), 4);
inline u32 CalcOffsetSheetFlags(u16 countNames, u16 countSheets, u16 countCWDH, u16 countCMAP) {
return ROUNDUP(CalcOffsetCMAPData(countNames, countSheets, countCWDH) + countCMAP * sizeof(u32), 4);
}
inline u32 CalcOffset0AFlags(u16 countNames, u16 countSheets, u16 count0A, u16 count0C) {
u32 offsetSheetFlags = CalcOffsetSheetFlags(countNames, countSheets, count0A, count0C);
inline u32 CalcOffsetCWDHFlags(u16 countNames, u16 countSheets, u16 countCWDH, u16 countCMAP) {
u32 offsetSheetFlags = CalcOffsetSheetFlags(countNames, countSheets, countCWDH, countCMAP);
u32 stepSheet = CalcSizeFlagSet(countSheets);
return ROUNDUP(offsetSheetFlags + stepSheet * countNames, 4);
}
inline u32 CalcOffset0CFlags(u16 countNames, u16 countSheets, u16 count0A, u16 count0C) {
u32 offset0AFlags = CalcOffset0AFlags(countNames, countSheets, count0A, count0C);
u32 step0A = CalcSizeFlagSet(count0A);
return ROUNDUP(offset0AFlags + step0A * countNames, 4);
inline u32 CalcOffsetCMAPFlags(u16 countNames, u16 countSheets, u16 countCWDH, u16 countCMAP) {
u32 offsetCWDHFlags = CalcOffsetCWDHFlags(countNames, countSheets, countCWDH, countCMAP);
u32 stepCWDH = CalcSizeFlagSet(countCWDH);
return ROUNDUP(offsetCWDHFlags + stepCWDH * countNames, 4);
}
inline u32 CalcSizeSheetOffsets(u32 countSheets) {

View File

@@ -92,8 +92,8 @@ namespace nw4r {
u16 sheetGlyphCount; // 0x04
u16 nameCount; // 0x06
u16 sheetCount; // 0x08
u16 smthCount_0x0a; // 0x0A
u16 smthCount_0x0c; // 0x0C
u16 cwdhCount; // 0x0A
u16 cmapCount; // 0x0C
u16 nameOffsets[0];
} GlyphGroups;

View File

@@ -207,56 +207,50 @@ namespace nw4r {
}
static void DoDrawConsole_(ConsoleHandle console, ut::TextWriter* writer) {
{
s32 viewOffset;
u16 line;
u16 printLines;
s32 viewOffset;
u16 line;
u16 printLines;
viewOffset = console->viewTopLine - console->ringTopLineCnt;
printLines = 0;
viewOffset = console->viewTopLine - console->ringTopLineCnt;
printLines = 0;
if (viewOffset < 0) {
viewOffset = 0;
} else if (viewOffset > GetActiveLines_(console)) {
goto end;
}
line = static_cast<u16>(console->ringTop + viewOffset);
if (line >= console->height) {
line -= console->height;
}
while (true) {
if (line == console->printTop && !console->printTopUsed) {
goto end;
}
DoDrawString_(console, printLines, GetTextPtr_(console, line, 0), writer);
printLines++;
if (line == console->printTop) {
goto end;
}
line++;
if (line == console->height) {
if (console->attr & (1 << 1)) {
goto end;
}
line = 0;
}
if (printLines >= console->viewLines) {
goto end;
}
}
if (viewOffset < 0) {
viewOffset = 0;
} else if (viewOffset > GetActiveLines_(console)) {
return;
}
// maybe not, with this end label?
end:
return;
line = static_cast<u16>(console->ringTop + viewOffset);
if (line >= console->height) {
line -= console->height;
}
while (true) {
if (line == console->printTop && !console->printTopUsed) {
break;
}
DoDrawString_(console, printLines, GetTextPtr_(console, line, 0), writer);
printLines++;
if (line == console->printTop) {
break;
}
line++;
if (line == console->height) {
if (console->attr & (1 << 1)) {
break;
}
line = 0;
}
if (printLines >= console->viewLines) {
break;
}
}
}
void Console_DrawDirect(ConsoleHandle console) {

View File

@@ -108,7 +108,7 @@ namespace {
} else if (operation == ut::OPERATION_CHAR_SPACE) {
bCharSpace = true;
} else if (operation == ut::OPERATION_NEXT_LINE) {
goto end_draw;
break;
}
} else {
if (bCharSpace) {
@@ -128,12 +128,11 @@ namespace {
if (pRect->GetWidth() > maxWidth) {
*pbOver = true;
goto end_draw;
break;
}
}
}
end_draw:
if (*pbOver && prStrPos) {
*pRect = prMaxRect;
return prStrPos - str;
@@ -223,7 +222,7 @@ namespace nw4r {
} else if (void* fontRes = resBlockSet.pResAccessor->GetResource('font', fontName, NULL)) {
if (void* pMemFont = Layout::AllocMemory(sizeof(ut::ResFont))) {
ut::ResFont* pResFont = new (pMemFont) ut::ResFont();
bool bSuccess = pResFont->SetResource(fontRes);
pResFont->SetResource(fontRes);
mpFont = pResFont;
mTextBoxFlag.allocFont = true;

View File

@@ -1,31 +1,4 @@
#include <nw4r/db/assert.h>
extern "C" const u8 scLytFatalColorR;
extern "C" const u8 scLytFatalColorG;
extern "C" const u8 scLytFatalColorB;
extern "C" const u8 scLytFatalColorA;
extern "C" char scLytFatalMsg[] = "Error#004\nAn error has occurred.\nThe system files are corrupted.";
#undef NW4R_ASSERT
#define NW4R_GLOBAL_ASSERT(x) \
{ \
if (!(x)) { \
GXColor front = {*((volatile const u8*)&::scLytFatalColorR), *((volatile const u8*)&::scLytFatalColorG), \
*((volatile const u8*)&::scLytFatalColorB), *((volatile const u8*)&::scLytFatalColorA)}; \
GXColor back = {0, 0, 0, 0}; \
OSFatal(front, back, ::scLytFatalMsg); \
} \
}
#define NW4R_ASSERT(x) \
{ \
if (!(x)) { \
GXColor front = {255, 255, 255, 0}; \
GXColor back = {0, 0, 0, 0}; \
OSFatal(front, back, ::scLytFatalMsg); \
} \
}
#include <nw4r/lyt/window.h>
#include <nw4r/lyt/common.h>
@@ -38,6 +11,33 @@ extern "C" char scLytFatalMsg[] = "Error#004\nAn error has occurred.\nThe system
#include <new>
extern "C" const u8 scLytFatalColorR;
extern "C" const u8 scLytFatalColorG;
extern "C" const u8 scLytFatalColorB;
extern "C" const u8 scLytFatalColorA;
extern "C" char scLytFatalMsg[];
#undef NW4R_ASSERT
// MWCC needs byte loads from the named color constants instead of folding their values.
#define NW4R_GLOBAL_ASSERT(x) \
{ \
if (!(x)) { \
GXColor front = {*((volatile const u8*)&::scLytFatalColorR), *((volatile const u8*)&::scLytFatalColorG), \
*((volatile const u8*)&::scLytFatalColorB), *((volatile const u8*)&::scLytFatalColorA)}; \
GXColor back = {0, 0, 0, 0}; \
OSFatal(front, back, ::scLytFatalMsg); \
} \
}
#define NW4R_ASSERT(x) \
{ \
if (!(x)) { \
GXColor front = {255, 255, 255, 0}; \
GXColor back = {0, 0, 0, 0}; \
OSFatal(front, back, ::scLytFatalMsg); \
} \
}
namespace nw4r {
namespace lyt {
NW4R_UT_GET_DERIVED_RUNTIME_TYPEINFO(Window, Pane);
@@ -174,8 +174,22 @@ namespace {
flipInfo.coords[VERTEXCOLOR_RB][iy] +
polSize.height / ((flipInfo.coords[VERTEXCOLOR_RT][iy] - flipInfo.coords[VERTEXCOLOR_RB][iy]) * tSz[iy]);
}
inline void SetFrameTexOrigin(math::VEC2* texCds, int corner, int ix, int iy, u8 originX, u8 originY) {
texCds[corner][ix] = texCds[corner ^ 2][ix] = originX;
texCds[corner][iy] = texCds[corner ^ 1][iy] = originY;
}
inline void SetFrameTexExtent(math::VEC2* texCds, const Size& polSize, const Size& texSize, const TextureFlipInfo& flipInfo, int corner, int ix,
int iy, u8 originX, u8 originY) {
const math::VEC2 tSz(texSize.width, texSize.height);
texCds[corner ^ 3][ix] = texCds[corner ^ 1][ix] = originX + polSize.width / ((flipInfo.coords[corner ^ 1][ix] - originX) * tSz[ix]);
texCds[corner ^ 3][iy] = texCds[corner ^ 2][iy] = originY + polSize.height / ((flipInfo.coords[corner ^ 2][iy] - originY) * tSz[iy]);
}
} // namespace
extern "C" char scLytFatalMsg[] = "Error#004\nAn error has occurred.\nThe system files are corrupted.";
namespace nw4r {
namespace lyt {
Window::Window(const res::Window* pBlock, const ResBlockSet& resBlockSet) : Pane(pBlock) {
@@ -388,7 +402,17 @@ namespace nw4r {
detail::DrawQuad(polPt, polSize, GX_TEXMAP1, texCds, bUseVtxCol ? vtxColors : NULL, alpha); \
}
DRAW_QUAD_FOR_FRAME_1(LT, TEXTUREFLIP_NONE);
GetLTFrameSize(&polPt, &polSize, basePt, mSize, frameSize);
{
TextureFlipInfo& flipInfo = GetTexutreFlipInfo(TEXTUREFLIP_NONE);
int iy = flipInfo.idx[FLIPINDEX_Y];
int ix = flipInfo.idx[FLIPINDEX_X];
const u8 originX = flipInfo.coords[VERTEXCOLOR_LT][ix];
const u8 originY = flipInfo.coords[VERTEXCOLOR_LT][iy];
SetFrameTexOrigin(*texCds, VERTEXCOLOR_LT, ix, iy, originX, originY);
SetFrameTexExtent(*texCds, polSize, texSize, flipInfo, VERTEXCOLOR_LT, ix, iy, originX, originY);
}
detail::DrawQuad(polPt, polSize, GX_TEXMAP1, texCds, bUseVtxCol ? vtxColors : NULL, alpha);
DRAW_QUAD_FOR_FRAME_1(RT, TEXTUREFLIP_H);
DRAW_QUAD_FOR_FRAME_1(RB, TEXTUREFLIP_180);
DRAW_QUAD_FOR_FRAME_1(LB, TEXTUREFLIP_V);

View File

@@ -36,8 +36,9 @@ namespace nw4r {
return instance;
}
// MWCC needs IRO 0 to recompute voice addresses inside the initialization loop.
#pragma push
#pragma ppc_iro_level 0 // uh
#pragma ppc_iro_level 0
void AxManager::Init() {
if (mInitialized) {
return;

View File

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

View File

@@ -20,25 +20,24 @@ namespace nw4r {
const HeaderedGlyphGroups* pGlgr;
const ArchiveFontBinaryLayout* font;
u16 countName, countSheet, count0A, count0C;
u16 countName, countSheet, countCWDH, countCMAP;
u32 stepSheets, step0A, step0C;
u32 stepSheets, stepCWDH, stepCMAP;
u32 dataSheetsOff, data0AOff, data0COff;
const u32* dataSheets;
const u32* data0A;
const u32* data0C;
u32 dataSheetsOff, dataCWDHOff, dataCMAPOff;
const u32* dataCWDH;
const u32* dataCMAP;
u32 flagsSheetsOff, flags0AOff, flags0COff;
u32 flagsSheetsOff, flagsCWDHOff, flagsCMAPOff;
const u32* flagsSheets;
const u32* flags0A;
const u32* flags0C;
const u32* flagsCWDH;
const u32* flagsCMAP;
int i;
int entryI;
const HeaderedGlyphGroups* offsetPGlgr;
const HeaderedGlyphGroups* groupHeaderCursor;
const u8* offsetFlags;
u32 loadedSheetCount, loadedSmth0ASize, loadedSmth0CSize;
u32 loadedSheetCount, loadedCWDHSize, loadedCMAPSize;
u32 flagWord;
const char* groupName;
const u32* offsetData;
@@ -49,11 +48,10 @@ namespace nw4r {
u32 neededCharacterSize;
u32 baseSize;
u32 count0CWork;
// MWCC needs this widened CMAP count for the original temporary allocation.
u32 cmapCountForLayout;
u32& neededCharacterSizeRef = neededCharacterSize;
u32 loadedSizeRef;
u32 loadedCharacterSize;
u32 groupOffset;
@@ -61,107 +59,98 @@ namespace nw4r {
return 0;
}
font = (ArchiveFontBinaryLayout*)fontData;
font = static_cast<const ArchiveFontBinaryLayout*>(fontData);
pGlgr = &font->glgr;
countName = pGlgr->inner.nameCount;
countSheet = pGlgr->inner.sheetCount;
count0A = pGlgr->inner.smthCount_0x0a;
count0C = pGlgr->inner.smthCount_0x0c;
count0CWork = count0C;
countCWDH = pGlgr->inner.cwdhCount;
countCMAP = pGlgr->inner.cmapCount;
cmapCountForLayout = countCMAP;
stepSheets = ((s32)countSheet + 0x1f) / 32 * 4;
step0A = ((s32)count0A + 0x1f) / 32 * 4;
step0C = ((s32)count0CWork + 0x1f) / 32 * 4;
stepCWDH = ((s32)countCWDH + 0x1f) / 32 * 4;
stepCMAP = ((s32)cmapCountForLayout + 0x1f) / 32 * 4;
dataSheetsOff = ROUNDUP(offsetof(ArchiveFontBinaryLayout, glgr.inner.nameOffsets) + countName * sizeof(u16), 4);
data0AOff = ROUNDUP(dataSheetsOff + countSheet * sizeof(u32), 4);
data0COff = ROUNDUP(data0AOff + count0A * sizeof(u32), 4);
dataSheets = (const u32*)((u32)dataSheetsOff + (u32)fontData);
data0A = (const u32*)((u32)data0AOff + (u32)fontData);
data0C = (const u32*)((u32)data0COff + (u32)fontData);
dataCWDHOff = ROUNDUP(dataSheetsOff + countSheet * sizeof(u32), 4);
dataCMAPOff = ROUNDUP(dataCWDHOff + countCWDH * sizeof(u32), 4);
dataCWDH = (const u32*)(dataCWDHOff + (u32)fontData);
dataCMAP = (const u32*)(dataCMAPOff + (u32)fontData);
flagsSheetsOff = ROUNDUP(data0COff + count0CWork * sizeof(u32), 4);
flags0AOff = ROUNDUP(flagsSheetsOff + stepSheets * countName, 4);
flags0COff = ROUNDUP(flags0AOff + step0A * countName, 4);
flagsSheetsOff = ROUNDUP(dataCMAPOff + cmapCountForLayout * sizeof(u32), 4);
flagsCWDHOff = ROUNDUP(flagsSheetsOff + stepSheets * countName, 4);
flagsCMAPOff = ROUNDUP(flagsCWDHOff + stepCWDH * countName, 4);
flagsSheets = (const u32*)((u32)flagsSheetsOff + (u32)fontData);
flags0A = (const u32*)((u32)flags0AOff + (u32)fontData);
flags0C = (const u32*)((u32)flags0COff + (u32)fontData);
flagsSheets = (const u32*)(flagsSheetsOff + (u32)fontData);
flagsCWDH = (const u32*)(flagsCWDHOff + (u32)fontData);
flagsCMAP = (const u32*)(flagsCMAPOff + (u32)fontData);
loadedSheetCount = 0;
loadedSmth0ASize = 0;
loadedSmth0CSize = 0;
loadedCWDHSize = 0;
loadedCMAPSize = 0;
// Get the NUMBER of sheets that should be loaded
for (i = 0, entryI = 0; entryI < pGlgr->inner.sheetCount; entryI += 0x20, i++) {
offsetFlags = (const u8*)flagsSheets + i * sizeof(u32);
flagWord = 0;
for (j = 0, offsetPGlgr = pGlgr; j < pGlgr->inner.nameCount;
offsetPGlgr = (const HeaderedGlyphGroups*)((const u8*)offsetPGlgr + 2), j++) {
groupName = (const char*)((u32)offsetPGlgr->inner.nameOffsets[0] + (u32)fontData);
// MWCC needs the header as the induction base for the name-offset loads.
for (j = 0, groupHeaderCursor = pGlgr; j < pGlgr->inner.nameCount;
groupHeaderCursor = (const HeaderedGlyphGroups*)((const u8*)groupHeaderCursor + 2), j++) {
groupName = (const char*)((u32)groupHeaderCursor->inner.nameOffsets[0] + (u32)fontData);
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
flagWord |= *(const u32*)((const u8*)offsetFlags + ROUNDDOWN(j * stepSheets, 4));
flagWord |= *(const u32*)(offsetFlags + ROUNDDOWN(j * stepSheets, 4));
}
}
loadedSheetCount += math::CntBit1(flagWord);
}
// getLoadedSheetCount(pGlgr, flagsSheets, stepSheets, fontData, includedGroups, &loadedSheetCount);
// Get the SIZE of unk_0x0a that should be loaded
for (i = 0; i * 32 < pGlgr->inner.smthCount_0x0a; i++) {
offsetFlags = (const u8*)flags0A + i * sizeof(u32);
for (i = 0; i * 32 < pGlgr->inner.cwdhCount; i++) {
offsetFlags = (const u8*)flagsCWDH + i * sizeof(u32);
flagWord = 0;
for (j = 0; j < pGlgr->inner.nameCount; j++) {
groupOffset = pGlgr->inner.nameOffsets[j];
groupName = (const char*)(groupOffset + (u32)fontData);
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
flagWord |= *(const u32*)((const u8*)offsetFlags + ROUNDDOWN(j * step0A, 4));
flagWord |= *(const u32*)(offsetFlags + ROUNDDOWN(j * stepCWDH, 4));
}
}
offsetData = (const u32*)data0A + i * 32;
offsetData = dataCWDH + i * 32;
for (j = 0; j < 32; j++) {
if ((flagWord << j) & 0x80000000U) {
loadedSmth0ASize += offsetData[j] - sizeof(BinaryBlockHeader);
loadedCWDHSize += offsetData[j] - sizeof(BinaryBlockHeader);
}
}
}
// Get the SIZE of unk_0x0C that should be loaded
for (i = 0; i * 32 < pGlgr->inner.smthCount_0x0c; i++) {
offsetFlags = (const u8*)flags0C + i * sizeof(u32);
for (i = 0; i * 32 < pGlgr->inner.cmapCount; i++) {
offsetFlags = (const u8*)flagsCMAP + i * sizeof(u32);
flagWord = 0;
for (j = 0; j < pGlgr->inner.nameCount; j++) {
groupOffset = pGlgr->inner.nameOffsets[j];
groupName = (const char*)(groupOffset + (u32)fontData);
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
flagWord |= *(const u32*)((const u8*)offsetFlags + ROUNDDOWN(j * step0C, 4));
flagWord |= *(const u32*)(offsetFlags + ROUNDDOWN(j * stepCMAP, 4));
}
}
offsetData = (const u32*)data0C + i * 32;
offsetData = dataCMAP + i * 32;
for (j = 0; j < 32; j++) {
if ((flagWord << j) & 0x80000000U) {
loadedSmth0CSize += offsetData[j] - sizeof(BinaryBlockHeader);
loadedCMAPSize += offsetData[j] - sizeof(BinaryBlockHeader);
}
}
}
// Calculate the final buffer size based on the three previously
// accessed components
sheetOffsetsSize = ROUNDUP(pGlgr->inner.sheetCount * 2, 4);
loadedSheetsSize = ROUNDUP(loadedSheetCount * pGlgr->inner.uncompSheetSize, 4);
loadedSizeRef = loadedSmth0ASize + loadedSmth0CSize;
neededCharacterSizeRef = sizeof(CXUncompContextHuffman);
if (loadedSizeRef >= sizeof(CXUncompContextHuffman)) {
neededCharacterSize = loadedSizeRef;
}
loadedCharacterSize = loadedCWDHSize + loadedCMAPSize;
neededCharacterSize = ut::Max<u32>(loadedCharacterSize, sizeof(CXUncompContextHuffman));
baseSize = OSRoundUp32B(sizeof(FontInformation) + sizeof(FontTextureGlyph) + sheetOffsetsSize);
return (baseSize + loadedSheetsSize) + neededCharacterSize;

View File

@@ -74,16 +74,6 @@ namespace nw4r {
}
}
// u32 ArchiveFontBase::ConstructContext::updateTextureBlockPtr() {
// u32 imgDataOffset;
// imgDataOffset = (u32)pFontInfo->pGlyph->sheetImage;
// pWorkCurr = (u8*)ROUNDUP((u32)pWorkCurr, 0x20);
// pFontInfo->pGlyph->sheetImage = pWorkCurr;
// return imgDataOffset;
// }
ArchiveFontBase::ArchiveFontBase() : pSheetOffsets(NULL) {
}
@@ -126,24 +116,6 @@ namespace nw4r {
return false;
}
// Check that there is nothing but spaces between the substr
// and the preceeding comma
// - Fails:
// - groupList = "foo, BAD bar, baz"
// - substr ^
// - Succeeds:
// - groupList = "foo, bar, baz"
// - substr ^
// - Succeeds:
// - groupList = "foo,bar,baz"
// - substr ^
// - Succeeds:
// - groupList = "foo,bar,baz"
// - substr ^
// - Fails (I think this is a bug):
// - groupList = " foo, bar, baz"
// - substr ^
// @bug Should allow for leading spaces in groupList (maybe?)
if (substr != groupList) {
const char* backsearchStr = substr - 1;
while (backsearchStr > groupList && *backsearchStr == ' ') {
@@ -154,11 +126,6 @@ namespace nw4r {
}
}
// Get the length of the section up until the next comma or
// the end
// - substr = "foo bar, baz" -> sectionLen = 7
// - substr = "foo , baz" -> sectionLen = 11
// - substr = "foo" -> sectionLen = 3
const char* nextComma = strchr(substr, ',');
u32 sectionLen;
if (nextComma != NULL) {
@@ -167,17 +134,6 @@ namespace nw4r {
sectionLen = strlen(substr);
}
// Check to make sure there is nothing except spaces between
// the end of the group name and the next comma:
// - Fails:
// - substr = "foo bar, baz"
// - group = "foo"
// - Succeeds:
// - substr = "foo , baz"
// - group = "foo"
// - Succeeds:
// - substr = "foo, baz"
// - group = "foo"
const char* sectionEnd = substr + groupLen;
while (sectionEnd < substr + sectionLen && (*sectionEnd == ' ')) {
sectionEnd++;
@@ -313,11 +269,6 @@ namespace nw4r {
ctx->pSheetOffsets = (u16*)sheetOffsets;
}
// inline u32 getOffsetSize(void* fontData, u32 remWorkSpace, u16 countSheet, u16** sheetOffsetsScratch) {
// u32 sheetOffsetsSize = ROUNDUP(countSheet * sizeof(u16), 4);
// *sheetOffsetsScratch = (u16*)ROUNDDOWN((u32)((u8*)fontData + remWorkSpace) - sheetOffsetsSize, 2);
// return sheetOffsetsSize;
// }
class FontGlyphGroupsAcs {
public:
explicit FontGlyphGroupsAcs(const ArchiveFontBinaryLayout* font)
@@ -393,8 +344,8 @@ namespace nw4r {
dataBlockCount = font->hdr.dataBlocks;
countSheet = gg.GetNumSheet();
const u32 stepSheetFlags = detail::CalcSizeFlagSet(countSheet);
flagsSheetsOff = detail::CalcOffsetSheetFlags(gg.GetGroups().nameCount, countSheet, gg.GetGroups().smthCount_0x0a,
gg.GetGroups().smthCount_0x0c);
flagsSheetsOff = detail::CalcOffsetSheetFlags(gg.GetGroups().nameCount, countSheet, gg.GetGroups().cwdhCount,
gg.GetGroups().cmapCount);
flagsSheets = (const u32*)((flagsSheetsOff & ~3) + (u32)font);
gg.SetSheetFlags(stepSheetFlags, flagsSheets);

View File

@@ -343,7 +343,7 @@ void RFLSetExpression(RFLCharModel* charModel, RFLExpression expression) {
}
RFLExpression RFLGetExpression(const RFLCharModel* charModel) {
const RFLiCharModel* charModel_ = (RFLiCharModel*)charModel;
const RFLiCharModel* charModel_ = (const RFLiCharModel*)charModel;
RFLi_ASSERTLINE_NULL(charModel, 499);
@@ -351,7 +351,7 @@ RFLExpression RFLGetExpression(const RFLCharModel* charModel) {
}
BOOL RFLIsAvailableExpression(const RFLCharModel* charModel, RFLExpression expression) {
const RFLiCharModel* charModel_ = (RFLiCharModel*)charModel;
const RFLiCharModel* charModel_ = (const RFLiCharModel*)charModel;
RFLi_ASSERTLINE_NULL(charModel, 518);
@@ -459,13 +459,13 @@ void RFLLoadMaterialSetting(const RFLDrawCoreSetting* setting) {
}
void RFLDrawOpaCore(const RFLCharModel* charModel, const RFLDrawCoreSetting* setting) {
const RFLiCharModel* charModel_ = (RFLiCharModel*)charModel;
const RFLiCharModel* charModel_ = (const RFLiCharModel*)charModel;
const RFLiCharModelRes* charModelRes;
RFLi_ASSERTLINE_NULL(charModel, 760);
RFLi_ASSERTLINE_NULL(setting, 761);
charModelRes = (RFLiCharModelRes*)charModel_->resource;
charModelRes = (const RFLiCharModelRes*)charModel_->resource;
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_KONST);
@@ -550,13 +550,13 @@ void RFLDrawOpaCore(const RFLCharModel* charModel, const RFLDrawCoreSetting* set
}
void RFLDrawXluCore(const RFLCharModel* charModel, const RFLDrawCoreSetting* setting) {
const RFLiCharModel* charModel_ = (RFLiCharModel*)charModel;
const RFLiCharModel* charModel_ = (const RFLiCharModel*)charModel;
const RFLiCharModelRes* charModelRes;
RFLi_ASSERTLINE_NULL(charModel, 897);
RFLi_ASSERTLINE_NULL(setting, 898);
charModelRes = (RFLiCharModelRes*)charModel_->resource;
charModelRes = (const RFLiCharModelRes*)charModel_->resource;
GXSetTevOrder(GX_TEVSTAGE0, setting->txcID, setting->texMapID, GX_COLOR_NULL);
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA);
@@ -1127,7 +1127,7 @@ void RFLiTransformCoordinate(s16* to, const s16* from) {
}
void RFLDrawShape(const RFLCharModel* charModel) {
const RFLiCharModel* charModel_ = (RFLiCharModel*)charModel;
const RFLiCharModel* charModel_ = (const RFLiCharModel*)charModel;
const RFLiCharModelRes* res;
GXCullMode cullMode;

View File

@@ -318,6 +318,7 @@ s32 RFLGetLastReason() {
}
RFLErrcode RFLWaitAsync() {
/* MWCC needs the status spill and reload on each polling iteration. */
volatile RFLErrcode errcode;
do {
errcode = RFLGetAsyncStatus();

View File

@@ -15,26 +15,32 @@ extern "C" {
#define TMCC_JPEG_DEC_WORK_SIZE 0x1C00
enum TMCCJPEGOutputFormat {
TMCC_JPEG_OUTPUT_RGB565 = 0,
TMCC_JPEG_OUTPUT_RGBA8 = 1,
TMCC_JPEG_OUTPUT_Y8U8V8 = 2
};
typedef struct TMCCJPEGDecWork_t TMCCJPEGDecWork;
typedef s32(TMCCReadCallback)(void*, u8*, unsigned int);
typedef struct {
u8 unk_0x00[0x10];
u8 reserved[0x10];
void* pBuf2; // 0x10
u32 buf2Size; // 0x14
u32 dataSize; // 0x18
TMCCReadCallback* pCallback; // 0x1C
void* pContext; // 0x20
u8 unk_0x24; // 0x24
u8 pad_0x25[0x03];
u8 thumbnailMode; // 0x24
u8 workBufferPadding[0x03];
TMCCJPEGDecWork* pBuf1; // 0x28
u8 unk_0x2C; // 0x2C
u8 pad_0x2D[0x03];
u8 outputFormat; // 0x2C
u8 alignmentPadding[0x03];
} TMCCJPEGDecInitParam;
typedef struct {
u8 unk_0x00[0x0C];
u8 reserved[0x0C];
u16 orientation; // 0x0C
u32 xResNum; // 0x10
u32 xResDen; // 0x14
@@ -70,7 +76,7 @@ typedef struct {
u16 posX;
u16 posY;
s32 position; // 0x04
u8 unk_0x08[0x04];
u8 reserved[0x04];
u32 state; // 0x0C
u16 maxX;
u16 maxY;
@@ -80,8 +86,8 @@ typedef struct {
u8 stepYExt;
u32 dataSizeX;
u32 dataSizeY;
u8 exifFlags; // 0x20
u8 thumbFlag; // 0x21
u8 scaleFactor; // 0x20
u8 noEoiCheck; // 0x21
u8 componentCount;
u8 dimensionPadding;
u16 jpegWidth;
@@ -107,7 +113,7 @@ typedef struct {
u16 posX; // 0x00
u16 posY; // 0x02
s32 position; // 0x04
u8 unk_0x08[0x04];
u8 reserved[0x04];
u32 result; // 0x0C
u16 maxX; // 0x10
u16 maxY; // 0x12
@@ -118,30 +124,26 @@ typedef struct {
u32 dataSizeX; // 0x18
u32 dataSizeY; // 0x1C
u8 scaleFactor; // 0x20
u8 unk_0x21; // 0x21
u8 noEoiCheck; // 0x21
u8 componentCount; // 0x22
u8 unk_0x23; // 0x23
u8 dimensionPadding;
u16 jpegWidth; // 0x24
u16 jpegHeight; // 0x26
u16 outputWidth; // 0x28
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];
TMCCJPEGDecExifData exifData; // 0x4C
TMCCJPEGDecWork* pWorkBuf; // 0x6C8
s32 decodeResult; // 0x6CC
u8 converterType; // 0x6D0
u8 unk_0x6D1[0x03];
u8 alignmentPadding[0x03];
} TMCCJPEGDecState;
s32 TMCCJPEGDecInit(TMCCJPEGDecState* state, TMCCJPEGDecInitParam* param);

View File

@@ -5,12 +5,6 @@
#include <tmc_jpeg.h>
enum TMCCJPEGOutputFormat {
TMCC_JPEG_OUTPUT_RGB565 = 0,
TMCC_JPEG_OUTPUT_RGBA8 = 1,
TMCC_JPEG_OUTPUT_Y8U8V8 = 2
};
enum TMCJpegMarker {
TMC_JPEG_MARKER_SOF0 = 0xFFC0,
TMC_JPEG_MARKER_SOF2 = 0xFFC2,

View File

@@ -1,6 +1,28 @@
#include <string.h>
#include <tmc_jpeg_internal.h>
static inline s32 finishImageStart(TMCCJPEGDecWork* work, s32 result) {
if (result < 0) {
return result;
}
if (work->frameWidth == 0) {
return TMCC_ERROR_HEADER;
}
work->mcuCount = work->mcuXCount * work->mcuYCount;
work->mcuRemCount = work->mcuXRem * work->mcuXCount2;
return result;
}
static inline s32 finishScanStart(TMCCJPEGDecWork* work, s32 result) {
if (result < 0) {
return result;
}
if (work->scanCount == 1) {
return 0;
}
return result;
}
s32 TMCCJPEGDecInit(TMCCJPEGDecState* state, TMCCJPEGDecInitParam* param) {
s32 result;
TMCCJPEGDecWork* work;
@@ -15,16 +37,16 @@ s32 TMCCJPEGDecInit(TMCCJPEGDecState* state, TMCCJPEGDecInitParam* param) {
work->pState = state;
state->pWorkBuf = work;
if (param->unk_0x24 != 0) {
if (param->thumbnailMode != 0) {
result = -1;
} else if (param->unk_0x2C != TMCC_JPEG_OUTPUT_RGB565 && param->unk_0x2C != TMCC_JPEG_OUTPUT_RGBA8 &&
param->unk_0x2C != TMCC_JPEG_OUTPUT_Y8U8V8) {
} else if (param->outputFormat != TMCC_JPEG_OUTPUT_RGB565 && param->outputFormat != TMCC_JPEG_OUTPUT_RGBA8 &&
param->outputFormat != TMCC_JPEG_OUTPUT_Y8U8V8) {
result = -1;
} else {
state->unk_0x21 = param->unk_0x24;
state->noEoiCheck = param->thumbnailMode;
result = 0;
state->scaleFactor = 1;
state->converterType = param->unk_0x2C;
state->converterType = param->outputFormat;
}
if (result < 0) {
@@ -37,17 +59,13 @@ s32 TMCCJPEGDecInit(TMCCJPEGDecState* state, TMCCJPEGDecInitParam* param) {
}
result = TMCJPEGDEC_imagestart(work);
result = (result < 0) ?
result :
((work->frameWidth == 0) ?
TMCC_ERROR_HEADER :
((work->mcuCount = work->mcuXCount * work->mcuYCount, work->mcuRemCount = work->mcuXRem * work->mcuXCount2), result));
result = finishImageStart(work, result);
if (result < 0) {
goto error;
}
result = TMCJPEGDEC_scanstart(work);
result = (result < 0) ? result : ((work->scanCount == 1) ? 0 : result);
result = finishScanStart(work, result);
if (result < 0) {
goto error;
}

View File

@@ -10,9 +10,12 @@ static TMCHuffmanEntry readHuffmanEntry(const TMCHuffmanEntry* entries, u32 inde
return entries[index];
}
static void readHuffmanLimit(const TMCHuffmanEntry* entries, TMCHuffmanEntry* limit) {
limit->bitLength = entries->bitLength;
limit->symbol = entries->symbol;
static inline BOOL exceedsHuffmanLimit(u32 code, const u16* entry, TMCHuffmanEntry* limit, TMCHuffmanEntry* decoded) {
limit->bitLength = entry[0];
limit->symbol = entry[1];
/* MWCC needs the entry copy before reloading its bit length. */
*decoded = *limit;
return code > decoded->bitLength;
}
static inline s32 decodeLongHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TMCCJPEGDecWork* work, TMCHuffmanEntry* limit, TMCHuffmanEntry* decoded) {
@@ -34,8 +37,7 @@ static inline s32 decodeLongHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TM
bitCount -= 9;
code = (bitData >> bitCount) & 0x1FF;
work->bitCount = bitCount;
goto read_entry;
while (1) {
while (exceedsHuffmanLimit(code, entry, limit, decoded)) {
length++;
entry += 2;
if (length > 16) {
@@ -47,69 +49,11 @@ static inline s32 decodeLongHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TM
bitCount--;
work->bitCount = bitCount;
code |= (bitData >> bitCount) & 1;
read_entry:
{
limit->bitLength = entry[0];
limit->symbol = entry[1];
*decoded = *limit;
if (code > decoded->bitLength) {
continue;
}
{
u32 relativeCode = code - limit->bitLength;
u32 symbolIndex = relativeCode + limit->symbol;
return symbols[symbolIndex & 0xFF];
}
}
}
}
static inline s32 decodeACHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TMCCJPEGDecWork* work, TMCHuffmanEntry* limit, TMCHuffmanEntry* decoded) {
u16* entry;
u32 bitData;
u32 code;
u32 length;
if (bitCount <= 17) {
s32 result = TMCJPEGDEC_load_buff(work);
if (result < 0) {
return result;
}
}
bitCount = work->bitCount;
entry = (u16*)(huff_tbl + 9);
bitData = work->bitBuf;
length = 9;
bitCount -= 9;
code = (bitData >> bitCount) & 0x1FF;
work->bitCount = bitCount;
goto read_entry;
while (1) {
length++;
entry += 2;
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:
{
limit->bitLength = entry[0];
limit->symbol = entry[1];
*decoded = *limit;
if (code > decoded->bitLength) {
continue;
}
{
u32 relativeCode = code - limit->bitLength;
u32 symbolIndex = relativeCode + limit->symbol;
return symbols[symbolIndex & 0xFF];
}
}
{
u32 relativeCode = code - limit->bitLength;
u32 symbolIndex = relativeCode + limit->symbol;
return symbols[symbolIndex & 0xFF];
}
}
@@ -225,7 +169,7 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
r = acEntry.symbol;
} else {
bit_pos = work->bitCount;
r = decodeACHuffman(bit_pos, ac_huff_tbl, ac_huff_sym, work, &acLimit, &acDecoded);
r = decodeLongHuffman(bit_pos, ac_huff_tbl, ac_huff_sym, work, &acLimit, &acDecoded);
if (r < 0) {
return r;
}

View File

@@ -84,157 +84,139 @@ s32 TMCJPEGDEC_get_byte(u8* dst, TMCCJPEGDecWork* work) {
}
s32 TMCJPEGDEC_get_wbyte(u16* dst, TMCCJPEGDecWork* work) {
u8 byte_val;
u32 byte_shifted;
s32 r;
u8 byte;
u32 highByte;
s32 result;
u8* cur;
u8* end;
u8* next;
if (work->pBufCur >= work->pBufEnd) {
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r < 0) {
goto br;
// MWCC needs the empty else branches to preserve refill branch direction.
do {
if (work->pBufCur >= work->pBufEnd) {
if (work->remaining != 0) {
result = refillJpegBuffer(work);
if (result < 0) {
break;
} else {
}
} else {
// This else-branch is load-bearing...
// Forces bge instead of blt.
result = TMCC_ERROR_UNDERFLOW;
break;
}
} else {
r = TMCC_ERROR_UNDERFLOW;
goto br;
}
{
u8* bufferCursor = work->pBufCur;
end = work->pBufEnd;
cur = bufferCursor;
next = bufferCursor + 1;
}
work->pBufCur = next;
byte = *cur;
if (next >= end) {
if (work->remaining != 0) {
result = refillJpegBuffer(work);
if (result < 0) {
break;
} else {
}
} else {
result = TMCC_ERROR_UNDERFLOW;
break;
}
}
result = 0;
} while (0);
highByte = (u32)byte << 8;
if (result < 0) {
return result;
}
{
u8* tmp = work->pBufCur;
do {
if (work->pBufCur >= work->pBufEnd) {
if (work->remaining != 0) {
result = refillJpegBuffer(work);
if (result < 0) {
break;
} else {
}
} else {
result = TMCC_ERROR_UNDERFLOW;
break;
}
}
cur = work->pBufCur;
end = work->pBufEnd;
cur = tmp;
next = tmp + 1;
}
work->pBufCur = next;
byte_val = *cur;
if (next < end) {
goto o1;
}
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r >= 0) {
goto o1;
next = cur + 1;
work->pBufCur = next;
byte = *cur;
if (next >= end) {
if (work->remaining != 0) {
result = refillJpegBuffer(work);
if (result < 0) {
break;
} else {
}
} else {
result = TMCC_ERROR_UNDERFLOW;
break;
}
}
goto br;
} else {
r = TMCC_ERROR_UNDERFLOW;
goto br;
}
o1:
r = 0;
br:
byte_shifted = (u32)byte_val << 8;
if (r >= 0) {
goto p2;
}
return r;
p2:
if (work->pBufCur < work->pBufEnd) {
goto r2;
}
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r < 0)
goto ez;
else {
// ...
}
} else {
r = TMCC_ERROR_UNDERFLOW;
goto ez;
}
r2:
cur = work->pBufCur;
end = work->pBufEnd;
next = cur + 1;
work->pBufCur = next;
byte_val = *cur;
if (next < end) {
goto o2;
}
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r < 0)
goto ez;
else {
// ...
}
} else {
r = TMCC_ERROR_UNDERFLOW;
goto ez;
}
o2:
r = 0;
ez:
*dst = byte_shifted + byte_val;
return r < 0 ? r : 0;
result = 0;
} while (0);
*dst = highByte + byte;
return result < 0 ? result : 0;
}
s32 TMCJPEGDEC_get_sbyte(u8* dst, u32 count, TMCCJPEGDecWork* work) {
int r = 0;
int result = 0;
u32 i;
u8 byte;
u8* cur;
for (i = 0; i < count; i++) {
if (work->pBufCur >= work->pBufEnd) {
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r < 0) {
goto copy_byte;
// MWCC needs the empty else branches to preserve refill branch direction.
do {
if (work->pBufCur >= work->pBufEnd) {
if (work->remaining != 0) {
result = refillJpegBuffer(work);
if (result < 0) {
break;
} else {
}
} else {
// This else-branch is load-bearing...
// Forces bge instead of blt.
result = TMCC_ERROR_UNDERFLOW;
break;
}
} else {
r = TMCC_ERROR_UNDERFLOW;
goto copy_byte;
}
}
cur = work->pBufCur;
work->pBufCur += 1;
byte = *cur;
cur = work->pBufCur;
work->pBufCur += 1;
byte = *cur;
if (work->pBufCur < work->pBufEnd) {
goto r0;
}
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r >= 0) {
goto r0;
if (work->pBufCur >= work->pBufEnd) {
if (work->remaining != 0) {
result = refillJpegBuffer(work);
if (result < 0) {
break;
} else {
}
} else {
result = TMCC_ERROR_UNDERFLOW;
break;
}
}
goto copy_byte;
} else {
r = TMCC_ERROR_UNDERFLOW;
goto copy_byte;
}
r0:
r = 0;
copy_byte:
result = 0;
} while (0);
*dst = byte;
dst++;
if (r < 0)
return r;
if (result < 0)
return result;
}
return 0;
}
@@ -243,51 +225,41 @@ s32 TMCJPEGDEC_move_ptr(s32 offset, TMCCJPEGDecWork* work) {
s32 avail;
s32 r;
if (offset < 0) {
goto ng;
if (offset >= 0) {
while (work->pBufEnd - work->pBufCur <= offset) {
avail = work->pBufEnd - work->pBufCur;
offset -= avail;
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r >= 0) {
continue;
}
return r;
} else {
return TMCC_ERROR_UNDERFLOW;
}
}
work->pBufCur += offset;
if (work->pBufEnd > work->pBufCur) {
goto done;
}
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r >= 0) {
goto done;
}
return r;
} else {
return TMCC_ERROR_UNDERFLOW;
}
} else {
offset = -offset;
if (work->pBufCur - work->pBufStart < offset) {
return TMCC_ERROR_UNDERFLOW;
}
work->pBufCur -= offset;
}
goto lc;
lp:
offset -= avail;
if (work->remaining == 0) {
goto er1;
}
r = refillJpegBuffer(work);
if (r >= 0) {
goto lc;
}
return r;
er1:
return TMCC_ERROR_UNDERFLOW;
lc:
avail = work->pBufEnd - work->pBufCur;
if (avail <= offset) {
goto lp;
}
work->pBufCur += offset;
if (work->pBufEnd > work->pBufCur) {
goto ret0;
}
if (work->remaining == 0) {
goto er2;
}
r = refillJpegBuffer(work);
if (r >= 0) {
goto ret0;
}
return r;
er2:
return TMCC_ERROR_UNDERFLOW;
ng:
offset = -offset;
if (work->pBufCur - work->pBufStart < offset) {
return TMCC_ERROR_UNDERFLOW;
}
work->pBufCur -= offset;
ret0:
done:
return 0;
}
@@ -314,47 +286,45 @@ s32 TMCJPEGDEC_load_buff(TMCCJPEGDecWork* work) {
work->bitBuf = bitBuf;
work->bitCount = bitCount;
work->pBufCur = cur;
goto ret;
} else {
do {
if (work->pBufEnd <= work->pBufCur) {
if (work->remaining == 0) {
break;
}
r = refillJpegBufferAfterFF(work);
if (r < 0) {
return r;
}
}
{
u32 bb = work->bitBuf;
u8* c = work->pBufCur;
u8* next;
u8 byte = *c;
next = c + 1;
work->pBufCur = next;
work->bitBuf = (bb << 8) + byte;
work->bitCount += 8;
if (byte == 0xFF) {
work->pBufCur = next + 1;
}
}
if (work->pBufEnd <= work->pBufCur) {
if (work->remaining == 0) {
break;
}
r = refillJpegBufferAfterFF(work);
if (r < 0) {
return r;
}
}
} while (work->bitCount <= 24);
}
do {
if (work->pBufEnd <= work->pBufCur) {
if (work->remaining == 0) {
break;
}
r = refillJpegBufferAfterFF(work);
if (r < 0) {
return r;
}
}
{
u32 bb = work->bitBuf;
u8* c = work->pBufCur;
u8* next;
u8 byte = *c;
next = c + 1;
work->pBufCur = next;
work->bitBuf = (bb << 8) + byte;
work->bitCount += 8;
if (byte == 0xFF) {
work->pBufCur = next + 1;
}
}
if (work->pBufEnd <= work->pBufCur) {
if (work->remaining == 0) {
break;
}
r = refillJpegBufferAfterFF(work);
if (r < 0) {
return r;
}
}
} while (work->bitCount <= 24);
ret:
return 0;
}

View File

@@ -31,444 +31,507 @@ static s32 scalingClampU8(s32 value) {
return value < 0 ? 0 : 255;
}
static s32 clampLumaDc(s32 coefficient) {
return clampU8((coefficient >> 11) + 0x80);
}
void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {
s32 workspace[64];
s32* workspaceCursor;
s32 evenBaseSum;
s32 evenRotation;
s32 pitch2;
s32* dst;
s32 rowOddOutput1;
int columnAcBits;
s32 column;
s32 evenOutput3;
s32 coefficient2;
s32 coefficient1;
s32 coefficient4;
s32 coefficient5;
s32 coefficient6;
s32 coefficient7;
s32 oddOutput0;
s32 m;
s32 evenBaseDifference;
s32 processedCoefficients;
s32 z;
s32 evenOutput1;
s32 oddOutput3;
s32 oddLowRotation;
s32 oddHighRotation;
s32 evenRotationSum;
s32 r;
s32 oddOutput1;
s32 oddSumRotation;
s32 oddSumDifference;
s32 oddDifferenceSum;
s32 columnsRemaining;
s32 oddOutput2;
s32 evenOutput0;
s32 evenOutput2;
s32 coefficient3;
s32 rowEvenOutput0;
s32 columnC6;
s32 columnC4;
s32 columnOddSumRotation;
s32 rowDc;
s32 rowEvenOutput1;
s32 columnC1;
s32 columnEvenBaseDifference;
s32 columnEvenOutput0;
s32 columnC2;
s32 columnScaledEvenRotation;
s32 columnEvenOutput1;
s32 columnC5;
s32 rowC4;
s32 rowOddSumRotation;
s32 columnEvenOutput3;
s32 columnOddLowSum;
s32 columnOddLowDifference;
s32 columnOddHighSum;
s32 columnC7;
s32 columnC3;
s32 columnEvenBaseSum;
s32 rowEvenBaseDifference;
s32 rowEvenOutput2;
s32 rowOddOutput0;
s32 rowC1;
s32 columnOddHighDifference;
s32 columnDc;
s32 columnOddDifferenceRotation;
s32 columnOddOutput1;
s32 rowScaledEvenRotation;
s32 columnEvenOutput2;
s32 columnOddMix;
int rowAcBits;
s32 columnEvenRotationSum;
s32 rowEvenBaseSum;
s32 rowC2;
s32 rowEvenRotationSum;
s32 rowEvenOutput3;
s32 rowOddLowDifference;
s32 columnOddOutput0;
u8* columnOutput;
s32 pitch4;
s32* src;
s32 rowC3;
s32 rowOddHighDifference;
s32 rowOddHighSum;
s32 rowOddOutput3;
s32 pitch7;
s32 pitch6;
s32 rowC6;
s32 columnOddOutput2;
u8 columnSample;
s32 processed;
s32 rowOddLowSum;
s32 rowOddDifferenceRotation;
s32 columnOddOutput3;
s32 rowC5;
s32 rowOddMix;
s32 rowSampleDc;
s32 rowOddOutput2;
s32 rowC7;
s32 rowCount;
s32 pitch5;
s32 pitch3;
s32 workspace[64];
s32 rowEvenSum;
s32 rowOddLowRotation;
s32 rowEvenRotation;
s32 rowOddDifferenceSum;
s32 rowOddHighRotation;
s32 rowOddSumDifference;
s32 columnOddDifferenceSum;
s32 columnOddHighRotation;
s32 columnOddLowRotation;
s32 columnEvenRotation;
s32 columnOddSumDifference;
int columnEvenSum;
r = (zigzag >> 4) * 8;
workspaceCursor = workspace;
processedCoefficients = 0;
{
for (; processedCoefficients < r; processedCoefficients += 8) {
u32 acBits;
coefficient4 = block[4];
coefficient6 = block[6];
coefficient2 = block[2];
coefficient1 = block[1];
coefficient7 = block[7];
coefficient5 = block[5];
coefficient3 = block[3];
acBits = (u32)coefficient4;
acBits |= (u32)coefficient6;
acBits |= (u32)coefficient2;
acBits |= (u32)coefficient1;
acBits |= (u32)coefficient7;
acBits |= (u32)coefficient5;
acBits |= (u32)coefficient3;
if (acBits == 0) {
s32 sample = block[0];
workspaceCursor[7] = sample;
workspaceCursor[6] = sample;
workspaceCursor[5] = sample;
workspaceCursor[4] = sample;
workspaceCursor[3] = sample;
workspaceCursor[2] = sample;
workspaceCursor[1] = sample;
workspaceCursor[0] = sample;
} else {
s32 oddLowSum;
s32 oddHighSum;
s32 oddLowDifference;
s32 oddHighDifference;
s32 dcValue;
evenRotation = coefficient2 - coefficient6;
oddLowSum = coefficient5 + coefficient3;
oddLowDifference = coefficient5 - coefficient3;
oddHighSum = coefficient1 + coefficient7;
oddHighDifference = coefficient1 - coefficient7;
evenRotationSum = coefficient6 + coefficient2;
evenRotation = evenRotation * 0xB5 >> 8;
oddSumDifference = oddHighSum - oddLowSum;
oddDifferenceSum = oddLowDifference + oddHighDifference;
dcValue = block[0];
evenBaseDifference = dcValue - coefficient4;
oddSumRotation = oddSumDifference * 0xB5 >> 8;
evenBaseSum = dcValue + coefficient4;
evenRotationSum = evenRotation + evenRotationSum;
evenOutput1 = evenBaseDifference + evenRotation;
z = oddDifferenceSum * 0x62 >> 8;
evenOutput0 = evenBaseSum + evenRotationSum;
evenOutput3 = evenBaseSum - evenRotationSum;
oddHighRotation = oddHighDifference * 0x14E >> 8;
evenOutput2 = evenBaseDifference - evenRotation;
m = oddHighRotation - z;
oddLowSum += m;
oddOutput0 = oddHighSum + oddLowSum;
oddOutput1 = oddSumRotation + m;
workspaceCursor[0] = evenOutput0 + oddOutput0;
oddLowRotation = oddLowDifference * 0x8B;
workspaceCursor[7] = evenOutput0 - oddOutput0;
oddLowRotation >>= 8;
workspaceCursor[1] = evenOutput1 + oddOutput1;
oddOutput3 = z + oddLowRotation;
oddOutput2 = oddOutput3 + oddSumRotation;
workspaceCursor[6] = evenOutput1 - oddOutput1;
workspaceCursor[2] = evenOutput2 + oddOutput2;
workspaceCursor[5] = evenOutput2 - oddOutput2;
workspaceCursor[3] = evenOutput3 + oddOutput3;
workspaceCursor[4] = evenOutput3 - oddOutput3;
}
block += 8;
workspaceCursor += 8;
}
}
workspaceCursor = workspace + processedCoefficients;
for (; processedCoefficients <= 0x38; processedCoefficients += 8) {
memset(workspaceCursor, 0, 0x20);
workspaceCursor += 8;
}
r = pitch * 8 - pitch;
z = pitch * 4;
m = pitch * 2;
workspaceCursor = workspace + 7;
for (columnsRemaining = 8, column = 7; columnsRemaining > 0; columnsRemaining--, column--) {
u32 acBits;
u8* output;
coefficient4 = workspaceCursor[0x20];
coefficient6 = workspaceCursor[0x30];
coefficient2 = workspaceCursor[0x10];
coefficient1 = workspaceCursor[8];
coefficient7 = workspaceCursor[0x38];
coefficient5 = workspaceCursor[0x28];
coefficient3 = workspaceCursor[0x18];
acBits = (u32)coefficient4;
acBits |= (u32)coefficient6;
acBits |= (u32)coefficient2;
acBits |= (u32)coefficient1;
acBits |= (u32)coefficient7;
acBits |= (u32)coefficient5;
acBits |= (u32)coefficient3;
output = conv_row_ptr + column;
if (acBits == 0) {
u8 sample = clampU8((*workspaceCursor >> 11) + 0x80);
output[r] = sample;
output[pitch * 6] = sample;
output[z + pitch] = sample;
output[z] = sample;
output[z - pitch] = sample;
output[m] = sample;
output[pitch] = sample;
output[0] = sample;
rowCount = (zigzag >> 4) * 8;
dst = workspace;
for (processed = 0; processed < rowCount; processed += 8) {
rowC4 = block[4];
rowC6 = block[6];
rowC2 = block[2];
rowC1 = block[1];
rowC7 = block[7];
rowC5 = block[5];
rowC3 = block[3];
rowAcBits = rowC4 | rowC6;
rowAcBits = rowC2 | rowAcBits;
rowAcBits = rowC1 | rowAcBits;
rowAcBits = rowC7 | rowAcBits;
rowAcBits = rowC5 | rowAcBits;
rowAcBits = rowC3 | rowAcBits;
if (rowAcBits == 0) {
rowSampleDc = block[0];
dst[7] = rowSampleDc;
dst[6] = rowSampleDc;
dst[5] = rowSampleDc;
dst[4] = rowSampleDc;
dst[3] = rowSampleDc;
dst[2] = rowSampleDc;
dst[1] = rowSampleDc;
dst[0] = rowSampleDc;
} else {
s32 oddLowSum;
s32 oddHighSum;
s32 dcValue;
evenRotation = coefficient2 - coefficient6;
oddLowSum = coefficient5 + coefficient3;
coefficient5 = coefficient5 - coefficient3;
oddHighSum = coefficient1 + coefficient7;
coefficient1 = coefficient1 - coefficient7;
evenRotationSum = coefficient6 + coefficient2;
coefficient2 = evenRotation * 0xB5 >> 8;
oddSumDifference = oddHighSum - oddLowSum;
oddDifferenceSum = coefficient5 + coefficient1;
dcValue = *workspaceCursor + 0x40000;
evenBaseDifference = dcValue - coefficient4;
oddSumRotation = oddSumDifference * 0xB5 >> 8;
evenBaseSum = dcValue + coefficient4;
evenRotationSum = coefficient2 + evenRotationSum;
evenOutput1 = evenBaseDifference + coefficient2;
oddDifferenceSum = oddDifferenceSum * 0x62 >> 8;
evenOutput0 = evenBaseSum + evenRotationSum;
evenOutput3 = evenBaseSum - evenRotationSum;
oddHighRotation = coefficient1 * 0x14E >> 8;
evenOutput2 = evenBaseDifference - coefficient2;
oddHighRotation = oddHighRotation - oddDifferenceSum;
oddLowSum += oddHighRotation;
oddOutput0 = oddHighSum + oddLowSum;
oddOutput1 = oddSumRotation + oddHighRotation;
oddLowRotation = coefficient5 * 0x8B >> 8;
oddOutput3 = oddDifferenceSum + oddLowRotation;
oddOutput2 = oddOutput3 + oddSumRotation;
output[0] = scalingClampU8(evenOutput0 + oddOutput0);
output[r] = scalingClampU8(evenOutput0 - oddOutput0);
output[pitch] = scalingClampU8(evenOutput1 + oddOutput1);
output[pitch * 6] = scalingClampU8(evenOutput1 - oddOutput1);
output[m] = scalingClampU8(evenOutput2 + oddOutput2);
output[z + pitch] = scalingClampU8(evenOutput2 - oddOutput2);
output[z - pitch] = scalingClampU8(evenOutput3 + oddOutput3);
output[z] = scalingClampU8(evenOutput3 - oddOutput3);
rowDc = block[0];
rowEvenRotation = rowC2 - rowC6;
rowEvenSum = rowC2 + rowC6;
rowEvenBaseSum = rowDc + rowC4;
rowEvenBaseDifference = rowDc - rowC4;
rowScaledEvenRotation = rowEvenRotation * 0xB5 >> 8;
rowEvenRotationSum = rowScaledEvenRotation + rowEvenSum;
rowEvenOutput0 = rowEvenBaseSum + rowEvenRotationSum;
rowEvenOutput1 = rowEvenBaseDifference + rowScaledEvenRotation;
rowEvenOutput2 = rowEvenBaseDifference - rowScaledEvenRotation;
rowEvenOutput3 = rowEvenBaseSum - rowEvenRotationSum;
rowOddHighSum = rowC1 + rowC7;
rowOddHighDifference = rowC1 - rowC7;
rowOddLowSum = rowC5 + rowC3;
rowOddLowDifference = rowC5 - rowC3;
rowOddSumDifference = rowOddHighSum - rowOddLowSum;
rowOddDifferenceSum = rowOddLowDifference + rowOddHighDifference;
rowOddSumRotation = rowOddSumDifference * 0xB5 >> 8;
rowOddDifferenceRotation = rowOddDifferenceSum * 0x62 >> 8;
rowOddHighRotation = rowOddHighDifference * 0x14E >> 8;
rowOddLowRotation = rowOddLowDifference * 0x8B >> 8;
rowOddMix = rowOddHighRotation - rowOddDifferenceRotation;
rowOddLowSum += rowOddMix;
rowOddOutput0 = rowOddHighSum + rowOddLowSum;
rowOddOutput1 = rowOddSumRotation + rowOddMix;
rowOddOutput3 = rowOddDifferenceRotation + rowOddLowRotation;
rowOddOutput2 = rowOddOutput3 + rowOddSumRotation;
dst[0] = rowEvenOutput0 + rowOddOutput0;
dst[7] = rowEvenOutput0 - rowOddOutput0;
dst[1] = rowEvenOutput1 + rowOddOutput1;
dst[6] = rowEvenOutput1 - rowOddOutput1;
dst[2] = rowEvenOutput2 + rowOddOutput2;
dst[5] = rowEvenOutput2 - rowOddOutput2;
dst[3] = rowEvenOutput3 + rowOddOutput3;
dst[4] = rowEvenOutput3 - rowOddOutput3;
}
workspaceCursor--;
block += 8;
dst += 8;
}
dst = workspace + processed;
for (; processed <= 56; processed += 8) {
memset(dst, 0, 32);
dst += 8;
}
src = workspace + 7;
pitch4 = pitch * 4;
pitch5 = pitch4 + pitch;
pitch3 = pitch4 - pitch;
pitch2 = pitch * 2;
pitch6 = pitch * 6;
pitch7 = pitch * 8 - pitch;
for (column = 7; column >= 0; column--) {
columnC4 = src[32];
columnC6 = src[48];
columnC2 = src[16];
columnC1 = src[8];
columnC7 = src[56];
columnC5 = src[40];
columnC3 = src[24];
columnAcBits = columnC4 | columnC6;
columnAcBits = columnC2 | columnAcBits;
columnAcBits = columnC1 | columnAcBits;
columnAcBits = columnC7 | columnAcBits;
columnAcBits = columnC5 | columnAcBits;
columnAcBits = columnC3 | columnAcBits;
columnOutput = conv_row_ptr + column;
if (columnAcBits == 0) {
columnSample = clampLumaDc(*src);
columnOutput[pitch7] = columnSample;
columnOutput[pitch6] = columnSample;
columnOutput[pitch5] = columnSample;
columnOutput[pitch4] = columnSample;
columnOutput[pitch3] = columnSample;
columnOutput[pitch2] = columnSample;
columnOutput[pitch] = columnSample;
columnOutput[0] = columnSample;
} else {
columnEvenSum = columnC6 + columnC2;
columnEvenRotation = columnC2 - columnC6;
columnOddLowSum = columnC5 + columnC3;
columnOddHighDifference = columnC1 - columnC7;
columnOddLowDifference = columnC5 - columnC3;
columnOddHighSum = columnC1 + columnC7;
columnScaledEvenRotation = columnEvenRotation * 0xB5 >> 8;
columnDc = *src + 0x40000;
columnOddDifferenceSum = columnOddLowDifference + columnOddHighDifference;
columnOddSumDifference = columnOddHighSum - columnOddLowSum;
columnOddSumRotation = columnOddSumDifference * 0xB5 >> 8;
columnEvenBaseSum = columnDc + columnC4;
columnOddDifferenceRotation = columnOddDifferenceSum * 0x62 >> 8;
columnOddHighRotation = columnOddHighDifference * 0x14E >> 8;
columnEvenRotationSum = columnScaledEvenRotation + columnEvenSum;
columnOddMix = columnOddHighRotation - columnOddDifferenceRotation;
columnOddLowSum += columnOddMix;
columnEvenOutput0 = columnEvenBaseSum + columnEvenRotationSum;
columnEvenBaseDifference = columnDc - columnC4;
columnEvenOutput3 = columnEvenBaseSum - columnEvenRotationSum;
columnEvenOutput1 = columnEvenBaseDifference + columnScaledEvenRotation;
columnOddOutput0 = columnOddHighSum + columnOddLowSum;
columnOddLowRotation = columnOddLowDifference * 0x8B >> 8;
columnOddOutput3 = columnOddDifferenceRotation + columnOddLowRotation;
columnEvenOutput2 = columnEvenBaseDifference - columnScaledEvenRotation;
columnOddOutput2 = columnOddOutput3 + columnOddSumRotation;
columnOddOutput1 = columnOddSumRotation + columnOddMix;
columnOutput[0] = scalingClampU8(columnEvenOutput0 + columnOddOutput0);
columnOutput[pitch7] = scalingClampU8(columnEvenOutput0 - columnOddOutput0);
columnOutput[pitch] = scalingClampU8(columnEvenOutput1 + columnOddOutput1);
columnOutput[pitch6] = scalingClampU8(columnEvenOutput1 - columnOddOutput1);
columnOutput[pitch2] = scalingClampU8(columnEvenOutput2 + columnOddOutput2);
columnOutput[pitch5] = scalingClampU8(columnEvenOutput2 - columnOddOutput2);
columnOutput[pitch3] = scalingClampU8(columnEvenOutput3 + columnOddOutput3);
columnOutput[pitch4] = scalingClampU8(columnEvenOutput3 - columnOddOutput3);
}
src--;
}
}
static s32 clampChromaDc(s32 value) {
return clampS8(value >> 11);
}
void TMCJPEGDEC_IdctBlock_Col(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {
s32 workspace[64];
s32* workspaceCursor;
s32 evenBaseDifference;
s32 columnsRemaining;
s32 evenBaseSum;
s32 coefficient1;
s32 coefficient2;
s32 coefficient3;
s32 coefficient4;
s32 coefficient5;
s32 coefficient6;
s32 coefficient7;
s32 v;
s32 rowCoefficientCount;
s32 processedCoefficients;
s32 rowCount;
s32 columnOddSumRotation;
s32 rowOddOutput1;
s32 columnC1;
int rowAcBits;
s32 columnEvenBaseDifference;
s32 columnC7;
s32 rowDc;
s32 rowOddSumRotation;
s32 rowEvenBaseSum;
s32 columnOddDifferenceRotation;
s32 columnEvenRotationSum;
s32* dst;
s32 columnOddOutput2;
s32 sparseDc;
s32 rowOddDifferenceRotation;
s32 columnOddOutput1;
s32 rowOddOutput2;
s32 columnDc;
s32 columnEvenBaseSum;
s32* src;
s32 rowOuter;
s32 processed;
s32 columnC6;
s32 rowOdd;
s32 column;
s32 m;
s32 n;
s32 oddOutput1;
s32 oddSumRotation;
s32 oddOutput2;
s32 evenOutput2;
s32 u;
s32 evenOutput0;
s32 oddOutput3;
s32 rotation45;
s32 z;
s32 oddSumDifference;
s32 oddDifferenceSum;
s32 oddHighRotation;
s32 oddLowRotation;
s32 evenOutput3;
s32 columnOddOutput3;
s32 rowSampleDc;
s32 rowOddOutput0;
s32 rowC3;
s32 columnScaledEvenRotation;
s32 rowRotation;
s32 rowEvenOutput2;
s32 rowC2;
s32 rowEvenBaseDifference;
s32 columnC5;
s32 rowEvenRotationSum;
s32 columnOddOutput0;
s32 rowC1;
int columnAcBits;
s32 columnC4;
s32 columnOddMix;
s32 columnOddLowSum;
s32 rowEvenOutput1;
s32 rowLowRotation;
s32 columnC3;
s32 rowOddHighDifference;
s32 rowC5;
s32 columnEvenOutput0;
s32 rowEvenOutput0;
s32 rowOddMix;
s32 rowEvenOutput3;
s32 rowC4;
s32 rowInner;
s32 rowC6;
s32 columnEvenOutput1;
s32 rowScaledEvenRotation;
s32 rowOddLowDifference;
s32 rowC7;
s32 rowOddOutput3;
s32 columnEvenOutput3;
s32 rowMid;
s32 columnOddHighDifference;
s32 columnEvenOutput2;
s32 columnC2;
s32 columnOddLowDifference;
s32 columnOddHighSum;
s32 rowOddHighSum;
s32 rowOddLowSum;
u8* columnOutput;
s32 columnOddLowRotation;
s32 rowEvenSum;
s32 flatDc;
s32 columnEvenRotation;
s32 rowOddDifferenceSum;
s32 rowOddSumDifference;
s32 columnSample;
s32 columnOddDifferenceSum;
int columnEvenSum;
s32 rowOddHighRotation;
s32 workspace[64];
s32 rowOddLowRotation;
s32 rowSample;
s32 rowEvenRotation;
s32 columnOddHighRotation;
s32 columnOddSumDifference;
s32 rowMix;
if (zigzag == 0x11) {
s32 sample;
sample = clampS8(block[0] >> 11);
memset(conv_row_ptr, (s8)sample, 0x40);
flatDc = block[0];
rowSample = clampS8(flatDc >> 11);
memset(conv_row_ptr, (s8)rowSample, 64);
return;
}
rowCoefficientCount = (zigzag >> 4) * 8;
if ((zigzag & 0xF) > 2) {
goto fullRowTransform;
}
workspaceCursor = workspace;
processedCoefficients = 0;
for (; processedCoefficients < rowCoefficientCount; processedCoefficients += 8) {
s32 dcValue;
s32 oddCoefficient;
oddCoefficient = block[1];
dcValue = block[0];
rotation45 = oddCoefficient * 0xB5 >> 8;
v = oddCoefficient * 0x62 >> 8;
u = v + rotation45;
z = (oddCoefficient * 0x14E >> 8) - v;
m = oddCoefficient + z;
n = rotation45 + z;
workspaceCursor[0] = dcValue + m;
workspaceCursor[7] = dcValue - m;
workspaceCursor[1] = dcValue + n;
workspaceCursor[6] = dcValue - n;
workspaceCursor[2] = dcValue + u;
workspaceCursor[5] = dcValue - u;
workspaceCursor[3] = dcValue + v;
workspaceCursor[4] = dcValue - v;
workspaceCursor += 8;
block += 8;
}
workspaceCursor = workspace + processedCoefficients;
for (; processedCoefficients <= 0x38; processedCoefficients += 8) {
memset(workspaceCursor, 0, 0x20);
workspaceCursor += 8;
}
goto columnTransform;
fullRowTransform:
workspaceCursor = workspace;
processedCoefficients = 0;
for (; processedCoefficients < rowCoefficientCount; processedCoefficients += 8) {
u32 acBits;
coefficient4 = block[4];
coefficient6 = block[6];
coefficient2 = block[2];
coefficient1 = block[1];
coefficient7 = block[7];
coefficient5 = block[5];
coefficient3 = block[3];
acBits = (u32)coefficient4;
acBits |= (u32)coefficient6;
acBits |= (u32)coefficient2;
acBits |= (u32)coefficient1;
acBits |= (u32)coefficient7;
acBits |= (u32)coefficient5;
acBits |= (u32)coefficient3;
if (acBits == 0) {
s32 sample;
sample = block[0];
workspaceCursor[7] = sample;
workspaceCursor[6] = sample;
workspaceCursor[5] = sample;
workspaceCursor[4] = sample;
workspaceCursor[3] = sample;
workspaceCursor[2] = sample;
workspaceCursor[1] = sample;
workspaceCursor[0] = sample;
rowCount = (zigzag >> 4) * 8;
if ((zigzag & 0xF) <= 2) {
dst = workspace;
for (processed = 0; processed < rowCount; processed += 8) {
rowOdd = block[1];
rowRotation = rowOdd * 0xB5 >> 8;
rowLowRotation = rowOdd * 0x62 >> 8;
sparseDc = block[0];
rowMix = (rowOdd * 0x14E >> 8) - rowLowRotation;
rowOuter = rowOdd + rowMix;
dst[0] = sparseDc + rowOuter;
rowInner = rowRotation + rowMix;
dst[7] = sparseDc - rowOuter;
dst[1] = sparseDc + rowInner;
rowMid = rowLowRotation + rowRotation;
dst[6] = sparseDc - rowInner;
dst[2] = sparseDc + rowMid;
dst[5] = sparseDc - rowMid;
dst[3] = sparseDc + rowLowRotation;
dst[4] = sparseDc - rowLowRotation;
dst += 8;
block += 8;
}
dst = workspace + processed;
for (; processed <= 56; processed += 8) {
memset(dst, 0, 32);
dst += 8;
}
} else {
dst = workspace;
for (processed = 0; processed < rowCount; processed += 8) {
rowC4 = block[4];
rowC6 = block[6];
rowC2 = block[2];
rowC1 = block[1];
rowC7 = block[7];
rowC5 = block[5];
rowC3 = block[3];
rowAcBits = rowC4 | rowC6;
rowAcBits = rowC2 | rowAcBits;
rowAcBits = rowC1 | rowAcBits;
rowAcBits = rowC7 | rowAcBits;
rowAcBits = rowC5 | rowAcBits;
rowAcBits = rowC3 | rowAcBits;
if (rowAcBits == 0) {
rowSampleDc = block[0];
dst[7] = rowSampleDc;
dst[6] = rowSampleDc;
dst[5] = rowSampleDc;
dst[4] = rowSampleDc;
dst[3] = rowSampleDc;
dst[2] = rowSampleDc;
dst[1] = rowSampleDc;
dst[0] = rowSampleDc;
} else {
s32 oddLowSum;
s32 oddLowDifference;
s32 oddHighSum;
s32 oddHighDifference;
s32 dcValue;
rotation45 = coefficient2 - coefficient6;
oddLowSum = coefficient5 + coefficient3;
oddLowDifference = coefficient5 - coefficient3;
oddHighSum = coefficient1 + coefficient7;
oddHighDifference = coefficient1 - coefficient7;
u = coefficient6 + coefficient2;
rotation45 = rotation45 * 0xB5 >> 8;
oddSumDifference = oddHighSum - oddLowSum;
oddDifferenceSum = oddLowDifference + oddHighDifference;
dcValue = block[0];
evenBaseDifference = dcValue - coefficient4;
oddSumRotation = oddSumDifference * 0xB5 >> 8;
evenBaseSum = dcValue + coefficient4;
u = rotation45 + u;
v = evenBaseDifference + rotation45;
z = oddDifferenceSum * 0x62 >> 8;
evenOutput0 = evenBaseSum + u;
evenOutput3 = evenBaseSum - u;
oddHighRotation = oddHighDifference * 0x14E >> 8;
evenOutput2 = evenBaseDifference - rotation45;
m = oddHighRotation - z;
oddLowSum += m;
n = oddHighSum + oddLowSum;
oddOutput1 = oddSumRotation + m;
workspaceCursor[0] = evenOutput0 + n;
oddLowRotation = oddLowDifference * 0x8B;
workspaceCursor[7] = evenOutput0 - n;
oddLowRotation >>= 8;
workspaceCursor[1] = v + oddOutput1;
oddOutput3 = z + oddLowRotation;
oddOutput2 = oddOutput3 + oddSumRotation;
workspaceCursor[6] = v - oddOutput1;
workspaceCursor[2] = evenOutput2 + oddOutput2;
workspaceCursor[5] = evenOutput2 - oddOutput2;
workspaceCursor[3] = evenOutput3 + oddOutput3;
workspaceCursor[4] = evenOutput3 - oddOutput3;
rowDc = block[0];
rowEvenRotation = rowC2 - rowC6;
rowEvenSum = rowC2 + rowC6;
rowEvenBaseSum = rowDc + rowC4;
rowEvenBaseDifference = rowDc - rowC4;
rowScaledEvenRotation = rowEvenRotation * 0xB5 >> 8;
rowEvenRotationSum = rowScaledEvenRotation + rowEvenSum;
rowEvenOutput0 = rowEvenBaseSum + rowEvenRotationSum;
rowEvenOutput1 = rowEvenBaseDifference + rowScaledEvenRotation;
rowEvenOutput2 = rowEvenBaseDifference - rowScaledEvenRotation;
rowEvenOutput3 = rowEvenBaseSum - rowEvenRotationSum;
rowOddHighSum = rowC1 + rowC7;
rowOddHighDifference = rowC1 - rowC7;
rowOddLowSum = rowC5 + rowC3;
rowOddLowDifference = rowC5 - rowC3;
rowOddSumDifference = rowOddHighSum - rowOddLowSum;
rowOddDifferenceSum = rowOddLowDifference + rowOddHighDifference;
rowOddSumRotation = rowOddSumDifference * 0xB5 >> 8;
rowOddDifferenceRotation = rowOddDifferenceSum * 0x62 >> 8;
rowOddHighRotation = rowOddHighDifference * 0x14E >> 8;
rowOddLowRotation = rowOddLowDifference * 0x8B >> 8;
rowOddMix = rowOddHighRotation - rowOddDifferenceRotation;
rowOddLowSum += rowOddMix;
rowOddOutput0 = rowOddHighSum + rowOddLowSum;
rowOddOutput1 = rowOddSumRotation + rowOddMix;
rowOddOutput3 = rowOddDifferenceRotation + rowOddLowRotation;
rowOddOutput2 = rowOddOutput3 + rowOddSumRotation;
dst[0] = rowEvenOutput0 + rowOddOutput0;
dst[7] = rowEvenOutput0 - rowOddOutput0;
dst[1] = rowEvenOutput1 + rowOddOutput1;
dst[6] = rowEvenOutput1 - rowOddOutput1;
dst[2] = rowEvenOutput2 + rowOddOutput2;
dst[5] = rowEvenOutput2 - rowOddOutput2;
dst[3] = rowEvenOutput3 + rowOddOutput3;
dst[4] = rowEvenOutput3 - rowOddOutput3;
}
block += 8;
workspaceCursor += 8;
}
workspaceCursor = workspace + processedCoefficients;
for (; processedCoefficients <= 0x38; processedCoefficients += 8) {
memset(workspaceCursor, 0, 0x20);
workspaceCursor += 8;
}
columnTransform:
workspaceCursor = workspace + 7;
for (columnsRemaining = 8, column = 7; columnsRemaining > 0; columnsRemaining--, column--) {
u32 acBits;
u8* output;
coefficient4 = workspaceCursor[0x20];
output = conv_row_ptr + column;
coefficient6 = workspaceCursor[0x30];
coefficient2 = workspaceCursor[0x10];
coefficient1 = workspaceCursor[8];
coefficient7 = workspaceCursor[0x38];
coefficient5 = workspaceCursor[0x28];
coefficient3 = workspaceCursor[0x18];
acBits = (u32)coefficient4;
acBits |= (u32)coefficient6;
acBits |= (u32)coefficient2;
acBits |= (u32)coefficient1;
acBits |= (u32)coefficient7;
acBits |= (u32)coefficient5;
acBits |= (u32)coefficient3;
if (acBits == 0) {
s32 sample;
sample = clampS8(*workspaceCursor >> 11);
output[56] = (u8)sample;
output[48] = (u8)sample;
output[40] = (u8)sample;
output[32] = (u8)sample;
output[24] = (u8)sample;
output[16] = (u8)sample;
output[8] = (u8)sample;
output[0] = (u8)sample;
} else {
s32 oddLowSum;
s32 oddLowDifference;
s32 oddHighSum;
s32 oddHighDifference;
s32 dcValue;
rotation45 = coefficient2 - coefficient6;
oddLowSum = coefficient5 + coefficient3;
oddLowDifference = coefficient5 - coefficient3;
oddHighSum = coefficient1 + coefficient7;
oddHighDifference = coefficient1 - coefficient7;
u = coefficient6 + coefficient2;
rotation45 = rotation45 * 0xB5 >> 8;
oddSumDifference = oddHighSum - oddLowSum;
oddDifferenceSum = oddLowDifference + oddHighDifference;
dcValue = *workspaceCursor;
evenBaseDifference = dcValue - coefficient4;
oddSumRotation = oddSumDifference * 0xB5 >> 8;
evenBaseSum = dcValue + coefficient4;
u = rotation45 + u;
v = evenBaseDifference + rotation45;
z = oddDifferenceSum * 0x62 >> 8;
evenOutput0 = evenBaseSum + u;
evenOutput3 = evenBaseSum - u;
oddHighRotation = oddHighDifference * 0x14E >> 8;
evenOutput2 = evenBaseDifference - rotation45;
m = oddHighRotation - z;
oddLowSum += m;
n = oddHighSum + oddLowSum;
oddOutput1 = oddSumRotation + m;
oddLowRotation = oddLowDifference * 0x8B >> 8;
oddOutput3 = z + oddLowRotation;
oddOutput2 = oddOutput3 + oddSumRotation;
output[0] = (u8)clampS8((evenOutput0 + n) >> 11);
output[56] = (u8)clampS8((evenOutput0 - n) >> 11);
output[8] = (u8)clampS8((v + oddOutput1) >> 11);
output[48] = (u8)clampS8((v - oddOutput1) >> 11);
output[16] = (u8)clampS8((evenOutput2 + oddOutput2) >> 11);
output[40] = (u8)clampS8((evenOutput2 - oddOutput2) >> 11);
output[24] = (u8)clampS8((evenOutput3 + oddOutput3) >> 11);
output[32] = (u8)clampS8((evenOutput3 - oddOutput3) >> 11);
dst += 8;
}
workspaceCursor--;
dst = workspace + processed;
for (; processed <= 56; processed += 8) {
memset(dst, 0, 32);
dst += 8;
}
}
src = workspace + 7;
for (column = 7; column >= 0; column--) {
columnC4 = src[32];
columnOutput = conv_row_ptr + column;
columnC6 = src[48];
columnC2 = src[16];
columnC1 = src[8];
columnC7 = src[56];
columnC5 = src[40];
columnC3 = src[24];
columnAcBits = columnC4 | columnC6;
columnAcBits = columnC2 | columnAcBits;
columnAcBits = columnC1 | columnAcBits;
columnAcBits = columnC7 | columnAcBits;
columnAcBits = columnC5 | columnAcBits;
columnAcBits = columnC3 | columnAcBits;
if (columnAcBits == 0) {
columnSample = clampChromaDc(*src);
columnOutput[56] = (u8)columnSample;
columnOutput[48] = (u8)columnSample;
columnOutput[40] = (u8)columnSample;
columnOutput[32] = (u8)columnSample;
columnOutput[24] = (u8)columnSample;
columnOutput[16] = (u8)columnSample;
columnOutput[8] = (u8)columnSample;
columnOutput[0] = (u8)columnSample;
} else {
columnOddHighSum = columnC1 + columnC7;
columnEvenRotation = columnC2 - columnC6;
columnOddLowSum = columnC5 + columnC3;
columnOddSumDifference = columnOddHighSum - columnOddLowSum;
columnEvenSum = columnC6 + columnC2;
columnOddLowDifference = columnC5 - columnC3;
columnScaledEvenRotation = columnEvenRotation * 0xB5 >> 8;
columnOddHighDifference = columnC1 - columnC7;
columnDc = *src;
columnEvenRotationSum = columnScaledEvenRotation + columnEvenSum;
columnOddSumRotation = columnOddSumDifference * 0xB5 >> 8;
columnOddDifferenceSum = columnOddLowDifference + columnOddHighDifference;
columnOddDifferenceRotation = columnOddDifferenceSum * 0x62 >> 8;
columnEvenBaseDifference = columnDc - columnC4;
columnEvenBaseSum = columnDc + columnC4;
columnOddHighRotation = columnOddHighDifference * 0x14E >> 8;
columnOddMix = columnOddHighRotation - columnOddDifferenceRotation;
columnEvenOutput3 = columnEvenBaseSum - columnEvenRotationSum;
columnEvenOutput1 = columnEvenBaseDifference + columnScaledEvenRotation;
columnEvenOutput2 = columnEvenBaseDifference - columnScaledEvenRotation;
columnEvenOutput0 = columnEvenBaseSum + columnEvenRotationSum;
columnOddLowRotation = columnOddLowDifference * 0x8B >> 8;
columnOddOutput3 = columnOddDifferenceRotation + columnOddLowRotation;
columnOddLowSum += columnOddMix;
columnOddOutput1 = columnOddSumRotation + columnOddMix;
columnOddOutput0 = columnOddHighSum + columnOddLowSum;
columnOddOutput2 = columnOddOutput3 + columnOddSumRotation;
columnOutput[0] = (u8)clampS8((columnEvenOutput0 + columnOddOutput0) >> 11);
columnOutput[56] = (u8)clampS8((columnEvenOutput0 - columnOddOutput0) >> 11);
columnOutput[8] = (u8)clampS8((columnEvenOutput1 + columnOddOutput1) >> 11);
columnOutput[48] = (u8)clampS8((columnEvenOutput1 - columnOddOutput1) >> 11);
columnOutput[16] = (u8)clampS8((columnEvenOutput2 + columnOddOutput2) >> 11);
columnOutput[40] = (u8)clampS8((columnEvenOutput2 - columnOddOutput2) >> 11);
columnOutput[24] = (u8)clampS8((columnEvenOutput3 + columnOddOutput3) >> 11);
columnOutput[32] = (u8)clampS8((columnEvenOutput3 - columnOddOutput3) >> 11);
}
src--;
}
}

View File

@@ -13,6 +13,8 @@ enum TMCExifFormat {
enum TMCExifTag {
TMC_EXIF_TAG_COMPRESSION = 0x0103,
TMC_EXIF_TAG_MAKE = 0x010F,
TMC_EXIF_TAG_MODEL = 0x0110,
TMC_EXIF_TAG_STRIP_OFFSETS = 0x0111,
TMC_EXIF_TAG_ORIENTATION = 0x0112,
TMC_EXIF_TAG_X_RESOLUTION = 0x011A,
@@ -69,6 +71,14 @@ static u32 readU32(const u8* p, u16 byteOrder) {
return (raw >> 24) | ((raw >> 8) & 0xFF00) | ((raw & 0xFF00) << 8) | ((raw & 0xFF) << 24);
}
static inline void convertExifWord(u32* result, u32 raw, u16 byteOrder) {
if (byteOrder == TMC_EXIF_LITTLE_ENDIAN) {
*result = raw;
} else {
*result = (raw >> 24) | ((raw >> 8) & 0xFF00) | ((raw & 0xFF00) << 8) | ((raw & 0xFF) << 24);
}
}
s32 TMCCJPEGDecGetOffsetEXIF(u32* pOffset, u32* pSize, TMCCJPEGDecInitParam* pParam) {
TMCCJPEGDecWork* work;
u16 segSize;
@@ -211,11 +221,11 @@ s32 TMCCJPEGDecGetInfoEXIF(TMCCJPEGDecExifInfo* pInfo, TMCCJPEGDecInitParam* pPa
return result;
}
if (pParam->unk_0x24 == 0) {
if (pParam->thumbnailMode == 0) {
return 0;
}
if (pParam->unk_0x24 == 1) {
if (pParam->thumbnailMode == 1) {
result = TMCJPEGDEC_ThumbnailCheck(pParam, pInfo, segSizeP2);
if (result < 0) {
return result;
@@ -388,9 +398,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
switch (tag) {
case TMC_EXIF_TAG_COMPRESSION:
case TMC_EXIF_TAG_STRIP_OFFSETS:
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT:
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH: {
case TMC_EXIF_TAG_STRIP_OFFSETS: {
break;
}
case TMC_EXIF_TAG_ORIENTATION: {
@@ -398,17 +406,27 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
case TMC_EXIF_TAG_X_RESOLUTION: {
u32 offset = readU32(entry->value, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
const u8* base;
const u8* p;
u32 offsetRaw;
u32 offset;
u32 numeratorRaw;
u32 value;
offsetRaw = entry->value[1] << 8 | entry->value[0] | entry->value[2] << 16 | entry->value[3] << 24;
convertExifWord(&offset, offsetRaw, byteOrder);
p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
pInfo->xResNum = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
numeratorRaw = p[1] << 8 | p[0] | p[2] << 16 | p[3] << 24;
convertExifWord(&value, numeratorRaw, byteOrder);
pInfo->xResNum = value;
base = pInfo->thumbnailData;
p = base + (offset + sizeof(u32));
if (base > p) {
return;
}
if (p > pInfo->dataEnd - sizeof(u32)) {
@@ -418,17 +436,27 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
case TMC_EXIF_TAG_Y_RESOLUTION: {
u32 offset = readU32(entry->value, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
const u8* base;
const u8* p;
u32 offsetRaw;
u32 offset;
u32 numeratorRaw;
u32 value;
offsetRaw = entry->value[1] << 8 | entry->value[0] | entry->value[2] << 16 | entry->value[3] << 24;
convertExifWord(&offset, offsetRaw, byteOrder);
p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
pInfo->yResNum = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
numeratorRaw = p[1] << 8 | p[0] | p[2] << 16 | p[3] << 24;
convertExifWord(&value, numeratorRaw, byteOrder);
pInfo->yResNum = value;
base = pInfo->thumbnailData;
p = base + (offset + sizeof(u32));
if (base > p) {
return;
}
if (p > pInfo->dataEnd - sizeof(u32)) {
@@ -525,6 +553,12 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
} else if (type == TMC_EXIF_TYPE_LONG) {
pInfo->pixelYDim = readU32(entry->value, byteOrder);
}
}
case TMC_EXIF_TAG_MAKE:
case TMC_EXIF_TAG_MODEL:
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT:
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH:
default: {
return;
}
}
@@ -534,25 +568,18 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
s32 tag = readU16(entry->tag, byteOrder);
switch (tag) {
case TMC_EXIF_TAG_DATE_TIME:
case TMC_EXIF_TAG_STRIP_OFFSETS:
case TMC_EXIF_TAG_ORIENTATION:
case TMC_EXIF_TAG_TRANSFER_FUNCTION:
case TMC_EXIF_TAG_YCBCR_POSITIONING:
case TMC_EXIF_TAG_EXIF_IFD:
case TMC_EXIF_TAG_EXIF_VERSION:
case TMC_EXIF_TAG_COMPONENTS_CONFIGURATION:
case TMC_EXIF_TAG_PLANAR_CONFIGURATION:
case TMC_EXIF_TAG_FLASHPIX_VERSION:
case TMC_EXIF_TAG_COLOR_SPACE:
case TMC_EXIF_TAG_PIXEL_X_DIMENSION:
case TMC_EXIF_TAG_PIXEL_Y_DIMENSION: {
case TMC_EXIF_TAG_STRIP_OFFSETS: {
break;
}
case TMC_EXIF_TAG_X_RESOLUTION: {
u32 offset;
const u8* base;
const u8* p;
offset = readU32(entry->value, byteOrder);
u32 offsetRaw;
u32 offset;
u32 numeratorRaw;
u32 value;
offsetRaw = entry->value[1] << 8 | entry->value[0] | entry->value[2] << 16 | entry->value[3] << 24;
convertExifWord(&offset, offsetRaw, byteOrder);
p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
@@ -560,9 +587,12 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
pInfo->xResNumIfd1 = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
numeratorRaw = p[1] << 8 | p[0] | p[2] << 16 | p[3] << 24;
convertExifWord(&value, numeratorRaw, byteOrder);
pInfo->xResNumIfd1 = value;
base = pInfo->thumbnailData;
p = base + (offset + sizeof(u32));
if (base > p) {
return;
}
if (p > pInfo->dataEnd - sizeof(u32)) {
@@ -572,9 +602,14 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
case TMC_EXIF_TAG_Y_RESOLUTION: {
u32 offset;
const u8* base;
const u8* p;
offset = readU32(entry->value, byteOrder);
u32 offsetRaw;
u32 offset;
u32 numeratorRaw;
u32 value;
offsetRaw = entry->value[1] << 8 | entry->value[0] | entry->value[2] << 16 | entry->value[3] << 24;
convertExifWord(&offset, offsetRaw, byteOrder);
p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
@@ -582,9 +617,12 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
pInfo->planarConfigIfd1 = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
numeratorRaw = p[1] << 8 | p[0] | p[2] << 16 | p[3] << 24;
convertExifWord(&value, numeratorRaw, byteOrder);
pInfo->planarConfigIfd1 = value;
base = pInfo->thumbnailData;
p = base + (offset + sizeof(u32));
if (base > p) {
return;
}
if (p > pInfo->dataEnd - sizeof(u32)) {
@@ -607,6 +645,21 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
}
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH: {
pInfo->thumbnailLength = readU32(entry->value, byteOrder);
}
case TMC_EXIF_TAG_DATE_TIME:
case TMC_EXIF_TAG_ORIENTATION:
case TMC_EXIF_TAG_TRANSFER_FUNCTION:
case TMC_EXIF_TAG_YCBCR_POSITIONING:
case TMC_EXIF_TAG_EXIF_IFD:
case TMC_EXIF_TAG_EXIF_VERSION:
case TMC_EXIF_TAG_COMPONENTS_CONFIGURATION:
case TMC_EXIF_TAG_FLASHPIX_VERSION:
case TMC_EXIF_TAG_COLOR_SPACE:
case TMC_EXIF_TAG_PIXEL_X_DIMENSION:
case TMC_EXIF_TAG_PIXEL_Y_DIMENSION:
case TMC_EXIF_TAG_MAKE:
case TMC_EXIF_TAG_MODEL:
default: {
return;
}
}
@@ -615,7 +668,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExifInfo* info, u32 totalSize) {
s32 total;
s32 length;
s32 tmp;
s32 thumbnailBufferOffset;
total = (s32)info->exifData.thumbnailOffset;
if (total == 0) {
@@ -631,8 +684,8 @@ static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExi
return -0xA0;
}
tmp = (s32)info->exifData.thumbnailData - (s32)param->pBuf2;
total = length + total + tmp;
thumbnailBufferOffset = (s32)info->exifData.thumbnailData - (s32)param->pBuf2;
total = length + total + thumbnailBufferOffset;
if ((u32)total > param->buf2Size) {
return -0xF1;
@@ -642,19 +695,19 @@ static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExi
return -0xF1;
}
info->exifFlags = 1;
info->scaleFactor = 1;
if (param->unk_0x24 != 1) {
if (param->thumbnailMode != 1) {
return -1;
}
info->thumbFlag = 0;
info->noEoiCheck = 0;
if (param->unk_0x2C != TMCC_JPEG_OUTPUT_RGB565 && param->unk_0x2C != TMCC_JPEG_OUTPUT_RGBA8 &&
param->unk_0x2C != TMCC_JPEG_OUTPUT_Y8U8V8) {
if (param->outputFormat != TMCC_JPEG_OUTPUT_RGB565 && param->outputFormat != TMCC_JPEG_OUTPUT_RGBA8 &&
param->outputFormat != TMCC_JPEG_OUTPUT_Y8U8V8) {
return -1;
}
info->converterType = param->unk_0x2C;
info->converterType = param->outputFormat;
return 0;
}

View File

@@ -1,5 +1,6 @@
#define TMC_JPEG_FRAME_PARSER
#include <tmc_jpeg_internal.h>
#include <stddef.h>
extern void* memset(void* dest, s32 val, u32 count);
@@ -68,7 +69,7 @@ s32 TMCJPEGDEC_decompmcu(u32 maxMCU, u32 mcuCount, TMCCJPEGDecWork* work, void*
blockCountPtr = frameInfo + mcuIdx;
blockIdx = 0;
while (blockIdx < *(blockCountPtr + 0x1c)) {
while (blockIdx < *(blockCountPtr + offsetof(TMCJpegFrameInfo, blockCount))) {
s32 stackBlock[64];
s32 ret;
@@ -146,7 +147,7 @@ s32 TMCJPEGDEC_imagestart(TMCCJPEGDecWork* work) {
}
s32 TMCJPEGDEC_imageend(TMCCJPEGDecWork* work) {
if (work->pState->unk_0x21 == 1)
if (work->pState->noEoiCheck == 1)
return 0;
if (work->scanCount == 0) {
@@ -816,7 +817,7 @@ static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work) {
s32 idx;
TMCFrameComponents* components;
TMCJpegTableInfo* scalePtr;
TMCFrameComponents* mapPtr;
u8* mapPtr;
s32 dcTbl;
s32 acTbl;
@@ -858,7 +859,7 @@ static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work) {
for (ci = 0; ci < work->compCount; ci++) {
if ((s32)scanByte == (s32)components->id[ci]) {
components->map[idx] = ci;
mapPtr = (TMCFrameComponents*)&components->map[idx];
mapPtr = &components->map[idx];
goto componentFound;
}
}
@@ -877,8 +878,8 @@ componentFound:
return -0x51;
}
components->dcTable[mapPtr->map[0]] = dcTbl;
components->acTable[mapPtr->map[0]] = acTbl;
components->dcTable[*mapPtr] = dcTbl;
components->acTable[*mapPtr] = acTbl;
if (scalePtr->dcTblFlag[dcTbl] != 1) {
return -0x40;
@@ -888,7 +889,7 @@ componentFound:
return -0x40;
}
if (scalePtr->quantTblFlag[mapPtr->quantTable[0]] != 1) {
if (scalePtr->quantTblFlag[components->quantTable[idx]] != 1) {
return -0x41;
}
}
@@ -900,237 +901,91 @@ componentFound:
return 0;
}
#ifdef __MWERKS__
asm s32 TMCJPEGDEC_err_restart(register TMCCJPEGDecWork* work) {
nofralloc
static inline s32 restartFromMarker(TMCCJPEGDecWork* work, TMCCJPEGDecState* state, u8 marker) {
u8 skip;
u16 pitch;
u32 pos;
u16 row;
u16 column;
s32 mcuIndex;
u16 y;
u16 x;
s32 result;
stwu r1, -0x20(r1)
mflr r0
stw r0, 0x24(r1)
stw r31, 0x1c(r1)
stw r30, 0x18(r1)
mr r30, r3
stw r29, 0x14(r1)
stw r28, 0x10(r1)
lbz r0, 0x181c(r3)
lwz r31, 0x19e4(r3)
cmplwi r0, 1
bne _err_restart_rewind
li r0, 0
li r3, 0
stw r0, 0x6cc(r31)
b _err_restart_return
_err_restart_rewind:
bl TMCJPEGDEC_rewind_ptr
cmpwi r3, 0
bge _err_restart_load_byte
b _err_restart_return
_err_restart_load_byte:
lwz r3, 0xc(r30)
lbz r0, 0(r3)
stb r0, 8(r1)
b _err_restart_check_byte
_err_restart_read_byte:
mr r4, r30
addi r3, r1, 8
bl TMCJPEGDEC_get_byte
cmpwi r3, 0
bge _err_restart_check_byte
b _err_restart_return
_err_restart_check_byte:
lbz r0, 8(r1)
cmplwi r0, 0xff
bne _err_restart_read_byte
mr r4, r30
addi r3, r1, 8
bl TMCJPEGDEC_get_byte
lbz r6, 8(r1)
cmplwi r6, 0xd9
bne _err_restart_check_result
cmpwi r3, 0
bge _err_restart_eoi
cmpwi r3, -0x90
beq _err_restart_eoi
b _err_restart_return
_err_restart_eoi:
li r3, 0
b _err_restart_return
_err_restart_check_result:
cmpwi r3, 0
bge _err_restart_check_marker
b _err_restart_return
_err_restart_check_marker:
cmplwi r6, 0xd0
blt _err_restart_check_byte
cmplwi r6, 0xd7
ble _err_restart_marker
b _err_restart_check_byte
_err_restart_marker:
lhz r3, 0x52(r30)
addi r0, r6, 8
addi r3, r3, 0xcf
cmpw r6, r3
subf r0, r3, r0
clrlwi r5, r0, 0x18
ble _err_restart_have_diff
subf r0, r3, r6
clrlwi r5, r0, 0x18
_err_restart_have_diff:
lhz r4, 0x181a(r30)
addi r0, r6, 1
clrlwi r3, r0, 0x1d
lhz r7, 0x10(r31)
mullw r5, r5, r4
li r0, 0
lwz r6, 0x54(r30)
sth r3, 0x52(r30)
mr r3, r30
clrlwi r4, r6, 0x18
clrlwi r8, r5, 0x18
srwi r6, r6, 0x10
mullw r5, r4, r7
stw r0, 0x30(r30)
add r4, r8, r6
stw r0, 0x34(r30)
stw r0, 0x38(r30)
add r5, r5, r4
divw r4, r5, r7
stw r0, 0x3c(r30)
sth r0, 0x50(r30)
mullw r0, r4, r7
clrlwi r28, r4, 0x10
subf r4, r0, r5
slwi r0, r4, 0x10
add r0, r0, r28
clrlwi r29, r4, 0x10
stw r0, 0x54(r30)
bl TMCJPEGDEC_init_buff
cmpwi r3, 0
bge _err_restart_store_position
b _err_restart_return
_err_restart_store_position:
sth r29, 0(r31)
mr r3, r30
sth r28, 2(r31)
bl TMCJPEGDEC_get_position
stw r3, 4(r31)
lhz r4, 2(r31)
lhz r3, 0x10(r31)
lwz r0, 0xc(r31)
mullw r3, r4, r3
lhz r4, 0(r31)
subf r0, r3, r0
subf r3, r4, r0
_err_restart_return:
lwz r0, 0x24(r1)
lwz r31, 0x1c(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
lwz r28, 0x10(r1)
mtlr r0
addi r1, r1, 0x20
blr
if (marker > work->rstMarkerIdx + 0xCF) {
skip = marker - (work->rstMarkerIdx + 0xCF);
} else {
skip = (marker + 8) - (work->rstMarkerIdx + 0xCF);
}
skip *= work->restartInterval;
pitch = state->maxX;
pos = work->mcuPos;
row = pos & 0xFF;
column = pos >> 16;
mcuIndex = row * pitch + (skip + column);
work->rstMarkerIdx = (marker + 1) & 7;
y = mcuIndex / pitch;
x = mcuIndex % pitch;
work->components.dcPredict[0] = 0;
work->components.dcPredict[1] = 0;
work->components.dcPredict[2] = 0;
work->components.dcPredict[3] = 0;
work->restartCnt = 0;
work->mcuPos = (x << 16) + y;
result = TMCJPEGDEC_init_buff(work);
if (result < 0) {
return result;
}
state->posX = x;
state->posY = y;
state->position = TMCJPEGDEC_get_position(work);
return state->result - state->posY * state->maxX - state->posX;
}
#else
s32 TMCJPEGDEC_err_restart(TMCCJPEGDecWork* work) {
TMCCJPEGDecState* state;
u16 interval;
u16 pitch;
u32 val;
s32 rem;
s32 div;
s32 next;
u8 rstDiff;
TMCCJPEGDecWork* stream;
s32 result;
u8 byte;
s32 r;
u8 marker;
state = work->pState;
if (work->scanCount == 1) {
state->decodeResult = 0;
return 0;
}
r = TMCJPEGDEC_rewind_ptr(work);
if (r < 0) {
return r;
stream = work;
result = TMCJPEGDEC_rewind_ptr(stream);
if (result < 0) {
return result;
}
byte = *work->pBufCur;
while (TRUE) {
byte = *stream->pBufCur;
for (;;) {
while (byte != 0xFF) {
r = TMCJPEGDEC_get_byte(&byte, work);
if (r < 0) {
return r;
result = TMCJPEGDEC_get_byte(&byte, stream);
if (result < 0) {
return result;
}
}
r = TMCJPEGDEC_get_byte(&byte, work);
if (byte == 0xD9) {
if (r < 0 && r != TMCC_ERROR_UNDERFLOW) {
return r;
result = TMCJPEGDEC_get_byte(&byte, stream);
marker = byte;
if (marker == 0xD9) {
if (result < 0 && result != TMCC_ERROR_UNDERFLOW) {
return result;
}
return 0;
}
if (r < 0) {
return r;
if (result < 0) {
return result;
}
if (byte < 0xD0 || byte > 0xD7) {
continue;
if (marker >= 0xD0 && marker <= 0xD7) {
break;
}
if (byte > work->rstMarkerIdx + 0xCF) {
rstDiff = byte - (work->rstMarkerIdx + 0xCF);
} else {
rstDiff = (byte + 0x08) - (work->rstMarkerIdx + 0xCF);
}
work->rstMarkerIdx = (byte + 1) & 7;
interval = work->restartInterval;
pitch = state->maxX;
val = work->mcuPos;
work->components.dcPredict[0] = 0;
work->components.dcPredict[1] = 0;
work->components.dcPredict[2] = 0;
work->components.dcPredict[3] = 0;
work->restartCnt = 0;
next = (u8)(val & 0xFF) * (s32)pitch + (val >> 16) + (s32)(u8)(rstDiff * interval);
div = next / (s32)pitch;
rem = next - div * (s32)pitch;
work->mcuPos = (rem << 16) + (u16)div;
r = TMCJPEGDEC_init_buff(work);
if (r < 0) {
return r;
}
state->posX = rem;
state->posY = div;
state->position = TMCJPEGDEC_get_position(work);
return state->result - (state->posY * state->maxX) - state->posY;
// MWCC needs the stream reset here to keep the retail loop-exit branch layout.
stream = work;
}
return restartFromMarker(work, state, marker);
}
#endif
void TMCJPEGDEC_set_entropytbl(TMCJpegTableInfo* work, s32 idx, u8 data) {
switch (idx) {
@@ -1148,18 +1003,15 @@ void TMCJPEGDEC_set_entropytbl(TMCJpegTableInfo* work, s32 idx, u8 data) {
}
}
if ((s32)data == 1) {
goto ac1;
if ((s32)data != 1) {
if ((s32)data < 1 && (s32)data >= 0) {
work->pACFast = work->huffDecTblAC0;
work->pACHuffSym = work->maxCodeAC0;
work->pACHuffTbl = work->valPtrAC0;
}
} else {
work->pACFast = work->huffDecTblAC1;
work->pACHuffSym = work->maxCodeAC1;
work->pACHuffTbl = work->valPtrAC1;
}
if ((s32)data < 1 && (s32)data >= 0) {
work->pACFast = work->huffDecTblAC0;
work->pACHuffSym = work->maxCodeAC0;
work->pACHuffTbl = work->valPtrAC0;
}
return;
ac1:
work->pACFast = work->huffDecTblAC1;
work->pACHuffSym = work->maxCodeAC1;
work->pACHuffTbl = work->valPtrAC1;
}

View File

@@ -2,6 +2,18 @@
extern void* memset(void* dest, int value, unsigned long size);
typedef struct {
u16 bitLength;
u16 symbol;
} TMCHuffmanEntry;
static inline BOOL exceedsHuffmanLimit(u32 code, const u16* entry, TMCHuffmanEntry* limit, TMCHuffmanEntry* decoded) {
*limit = *(const TMCHuffmanEntry*)entry;
/* MWCC needs the entry copy before reloading its bit length. */
*decoded = *limit;
return code > decoded->bitLength;
}
static s32 TMCJPEGDEC_vl_decode_rc(u32* huff_tbl, u8* huff_sym, TMCCJPEGDecWork* work);
static inline s32 readCoefficientBits(TMCCJPEGDecWork* work, s32 count) {
@@ -150,6 +162,8 @@ static s32 TMCJPEGDEC_vl_decode_rc(u32* huff_tbl, u8* huff_sym, TMCCJPEGDecWork*
u32 code;
unsigned int i;
s32 r;
TMCHuffmanEntry limit;
TMCHuffmanEntry decoded;
bit_pos = work->bitCount;
@@ -168,9 +182,7 @@ static s32 TMCJPEGDEC_vl_decode_rc(u32* huff_tbl, u8* huff_sym, TMCCJPEGDecWork*
code = (bit_data >> bit_pos) & 0x1FF;
work->bitCount = bit_pos;
goto entry_check;
do {
while (exceedsHuffmanLimit(code, entry, &limit, &decoded)) {
i++;
entry += 2;
if (i > 16) {
@@ -183,24 +195,11 @@ static s32 TMCJPEGDEC_vl_decode_rc(u32* huff_tbl, u8* huff_sym, TMCCJPEGDecWork*
bit_pos--;
work->bitCount = bit_pos;
code |= (bit_data >> bit_pos) & 1;
entry_check: {
typedef struct {
u16 t;
u16 o;
} HuffEnt;
HuffEnt local = *(HuffEnt*)entry;
u32 combined = *(u32*)&local;
u16 th = *(u16*)&combined;
s32 tmp;
if (code > th) {
continue;
}
tmp = code - local.t;
code = tmp + (u32)local.o;
}
return huff_sym[code & 0xFF];
} while (1);
{
s32 relativeCode = code - limit.bitLength;
code = relativeCode + (u32)limit.symbol;
}
return huff_sym[code & 0xFF];
}

View File

@@ -14,7 +14,38 @@ static void TMCJPEGDEC_converterYUV444toRGB565edge(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGB565(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGB565edge(TMCCJPEGDecWork*, s32, s32);
/* MWCC needs level 1 to preserve the shared conversion-buffer base. */
#pragma push
#pragma optimization_level 1
s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
u8 mode411;
u8* crBlock411;
u8* cbBlock411;
u8* fourthRow411;
u8* thirdRow411;
u8* secondRow411;
u8* firstRow411;
TMCConverterFunc* edgeConverter411;
TMCConverterFunc* converter411;
u8 mode422;
u8* crBlock422;
u8* cbBlock422;
u8* secondRow422;
u8* firstRow422;
TMCConverterFunc* edgeConverter422;
TMCConverterFunc* converter422;
u8 mode420;
u8* crBlock420;
u8* cbBlock420;
u8* fourthRow420;
u8* thirdRow420;
u8* secondRow420;
u8* firstRow420;
TMCConverterFunc* edgeConverter420;
TMCConverterFunc* converter420;
u8* buffer;
s32 componentCount;
TMCCJPEGDecState* state;
@@ -25,97 +56,84 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
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 = TMCJPEGDEC_converterYUV411toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV411toRGB565edge;
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;
mode411 = work->idctMode;
firstRow411 = buffer + 4;
converter411 = TMCJPEGDEC_converterYUV411toRGB565;
edgeConverter411 = TMCJPEGDEC_converterYUV411toRGB565edge;
secondRow411 = firstRow411 + mode411;
thirdRow411 = secondRow411 + mode411;
fourthRow411 = thirdRow411 + mode411;
cbBlock411 = buffer + 260;
crBlock411 = buffer + 324;
work->pConverterFunc = converter411;
work->pConverterFuncEdge = edgeConverter411;
work->pConvRowPtrs[0] = firstRow411;
work->pConvRowPtrs[1] = secondRow411;
work->pConvRowPtrs[2] = thirdRow411;
work->pConvRowPtrs[3] = fourthRow411;
work->pConvRowPtrs[5] = cbBlock411;
work->pConvRowPtrs[6] = crBlock411;
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 = TMCJPEGDEC_converterYUV422toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV422toRGB565edge;
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;
mode422 = work->idctMode;
firstRow422 = buffer + 4;
converter422 = TMCJPEGDEC_converterYUV422toRGB565;
edgeConverter422 = TMCJPEGDEC_converterYUV422toRGB565edge;
secondRow422 = firstRow422 + mode422;
cbBlock422 = buffer + 132;
crBlock422 = buffer + 196;
work->pConverterFunc = converter422;
work->pConverterFuncEdge = edgeConverter422;
work->pConvRowPtrs[0] = firstRow422;
work->pConvRowPtrs[1] = secondRow422;
work->pConvRowPtrs[5] = cbBlock422;
work->pConvRowPtrs[6] = crBlock422;
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 = TMCJPEGDEC_converterYUV420toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV420toRGB565edge;
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;
mode420 = work->idctMode;
firstRow420 = buffer + 4;
converter420 = TMCJPEGDEC_converterYUV420toRGB565;
edgeConverter420 = TMCJPEGDEC_converterYUV420toRGB565edge;
secondRow420 = firstRow420 + mode420;
thirdRow420 = firstRow420 + mode420 * 16;
fourthRow420 = thirdRow420 + mode420;
cbBlock420 = buffer + 260;
crBlock420 = buffer + 324;
work->pConverterFunc = converter420;
work->pConverterFuncEdge = edgeConverter420;
work->pConvRowPtrs[0] = firstRow420;
work->pConvRowPtrs[1] = secondRow420;
work->pConvRowPtrs[2] = thirdRow420;
work->pConvRowPtrs[3] = fourthRow420;
work->pConvRowPtrs[5] = cbBlock420;
work->pConvRowPtrs[6] = crBlock420;
work->pitch = 16;
work->converterFlags = 0;
break;
}
case 3: {
u8 mode;
u8* firstRow;
u8* secondRow;
u8* cbBlock;
u32 mode;
u8* crBlock;
u8* cbBlock;
u8* secondRow;
u8* firstRow;
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
mode = work->idctMode;
firstRow = buffer + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV211toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV211toRGB565edge;
converter = TMCJPEGDEC_converterYUV211toRGB565;
edgeConverter = TMCJPEGDEC_converterYUV211toRGB565edge;
secondRow = firstRow + mode * 8;
cbBlock = buffer + 132;
crBlock = buffer + 196;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
@@ -125,27 +143,27 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
break;
}
case 4: {
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
converter = TMCJPEGDEC_converterYUV444toRGB565;
edgeConverter = TMCJPEGDEC_converterYUV444toRGB565edge;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
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;
TMCConverterFunc* converter;
converter = TMCJPEGDEC_converterYUV400toRGB565;
edgeConverter = TMCJPEGDEC_converterYUV400toRGB565edge;
work->pConvRowPtrs[0] = buffer + 4;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = buffer + 4;
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -158,13 +176,19 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
{
s32 width = state->jpegWidth;
s32 height = state->jpegHeight;
state->convWidth = ((u32)width / 4 + (width % 4 != 0)) * 4;
state->convHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
s32 roundedWidth;
s32 heightPadding;
roundedWidth = (u32)width / 4 + (width % 4 != 0);
heightPadding = height % 4 != 0;
state->convWidth = roundedWidth * 4;
state->convHeight = ((u32)height / 4 + heightPadding) * 4;
}
return 0;
}
#pragma pop
static void TMCJPEGDEC_converterYUV411toRGB565(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 tileColumn;
s32 red;

View File

@@ -14,7 +14,38 @@ static void TMCJPEGDEC_converterYUV444toRGBA8edge(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGBA8(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGBA8edge(TMCCJPEGDecWork*, s32, s32);
/* MWCC needs level 1 to preserve the shared conversion-buffer base. */
#pragma push
#pragma optimization_level 1
s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
u8 mode411;
u8* crBlock411;
u8* cbBlock411;
u8* fourthRow411;
u8* thirdRow411;
u8* secondRow411;
u8* firstRow411;
TMCConverterFunc* edgeConverter411;
TMCConverterFunc* converter411;
u8 mode422;
u8* crBlock422;
u8* cbBlock422;
u8* secondRow422;
u8* firstRow422;
TMCConverterFunc* edgeConverter422;
TMCConverterFunc* converter422;
u8 mode420;
u8* crBlock420;
u8* cbBlock420;
u8* fourthRow420;
u8* thirdRow420;
u8* secondRow420;
u8* firstRow420;
TMCConverterFunc* edgeConverter420;
TMCConverterFunc* converter420;
u8* buffer;
s32 componentCount;
TMCCJPEGDecState* state;
@@ -25,97 +56,84 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
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 = TMCJPEGDEC_converterYUV411toRGBA8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV411toRGBA8edge;
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;
mode411 = work->idctMode;
firstRow411 = buffer + 4;
converter411 = TMCJPEGDEC_converterYUV411toRGBA8;
edgeConverter411 = TMCJPEGDEC_converterYUV411toRGBA8edge;
secondRow411 = firstRow411 + mode411;
thirdRow411 = secondRow411 + mode411;
fourthRow411 = thirdRow411 + mode411;
cbBlock411 = buffer + 260;
crBlock411 = buffer + 324;
work->pConverterFunc = converter411;
work->pConverterFuncEdge = edgeConverter411;
work->pConvRowPtrs[0] = firstRow411;
work->pConvRowPtrs[1] = secondRow411;
work->pConvRowPtrs[2] = thirdRow411;
work->pConvRowPtrs[3] = fourthRow411;
work->pConvRowPtrs[5] = cbBlock411;
work->pConvRowPtrs[6] = crBlock411;
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 = TMCJPEGDEC_converterYUV422toRGBA8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV422toRGBA8edge;
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;
mode422 = work->idctMode;
firstRow422 = buffer + 4;
converter422 = TMCJPEGDEC_converterYUV422toRGBA8;
edgeConverter422 = TMCJPEGDEC_converterYUV422toRGBA8edge;
secondRow422 = firstRow422 + mode422;
cbBlock422 = buffer + 132;
crBlock422 = buffer + 196;
work->pConverterFunc = converter422;
work->pConverterFuncEdge = edgeConverter422;
work->pConvRowPtrs[0] = firstRow422;
work->pConvRowPtrs[1] = secondRow422;
work->pConvRowPtrs[5] = cbBlock422;
work->pConvRowPtrs[6] = crBlock422;
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 = TMCJPEGDEC_converterYUV420toRGBA8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV420toRGBA8edge;
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;
mode420 = work->idctMode;
firstRow420 = buffer + 4;
converter420 = TMCJPEGDEC_converterYUV420toRGBA8;
edgeConverter420 = TMCJPEGDEC_converterYUV420toRGBA8edge;
secondRow420 = firstRow420 + mode420;
thirdRow420 = firstRow420 + mode420 * 16;
fourthRow420 = thirdRow420 + mode420;
cbBlock420 = buffer + 260;
crBlock420 = buffer + 324;
work->pConverterFunc = converter420;
work->pConverterFuncEdge = edgeConverter420;
work->pConvRowPtrs[0] = firstRow420;
work->pConvRowPtrs[1] = secondRow420;
work->pConvRowPtrs[2] = thirdRow420;
work->pConvRowPtrs[3] = fourthRow420;
work->pConvRowPtrs[5] = cbBlock420;
work->pConvRowPtrs[6] = crBlock420;
work->pitch = 16;
work->converterFlags = 0;
break;
}
case 3: {
u8 mode;
u8* firstRow;
u8* secondRow;
u8* cbBlock;
u32 mode;
u8* crBlock;
u8* cbBlock;
u8* secondRow;
u8* firstRow;
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
mode = work->idctMode;
firstRow = buffer + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV211toRGBA8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV211toRGBA8edge;
converter = TMCJPEGDEC_converterYUV211toRGBA8;
edgeConverter = TMCJPEGDEC_converterYUV211toRGBA8edge;
secondRow = firstRow + mode * 8;
cbBlock = buffer + 132;
crBlock = buffer + 196;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
@@ -125,27 +143,27 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
break;
}
case 4: {
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
converter = TMCJPEGDEC_converterYUV444toRGBA8;
edgeConverter = TMCJPEGDEC_converterYUV444toRGBA8edge;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
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;
TMCConverterFunc* converter;
converter = TMCJPEGDEC_converterYUV400toRGBA8;
edgeConverter = TMCJPEGDEC_converterYUV400toRGBA8edge;
work->pConvRowPtrs[0] = buffer + 4;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = buffer + 4;
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -158,129 +176,129 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
{
s32 width = state->jpegWidth;
s32 height = state->jpegHeight;
state->convWidth = ((u32)width / 4 + (width % 4 != 0)) * 4;
state->convHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
s32 roundedWidth;
s32 heightPadding;
roundedWidth = (u32)width / 4 + (width % 4 != 0);
heightPadding = height % 4 != 0;
state->convWidth = roundedWidth * 4;
state->convHeight = ((u32)height / 4 + heightPadding) * 4;
}
return 0;
}
#pragma pop
/* MWCC needs the full-width alpha addition before the halfword stores. */
static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
u16* output;
s32 tileRow;
s32 secondGreen;
s32 thirdGreen;
s32 fourthBlue;
s32 columnInTile;
s32 secondColumnInTile;
s32 thirdColumnInTile;
s32 fourthColumnInTile;
s32 red;
s32 secondBlue;
s32 thirdBlue;
s32 fourthGreen;
s32 green;
s32 secondRed;
s32 thirdRed;
s32 fourthRed;
u8* texture;
u8* luminance;
u8* cb;
u8* cr;
TMCCJPEGDecState* state;
u8* texture;
s32 height;
s32 column;
s32 xEnd;
s32 green;
s32 yEnd;
s32 tileWidth;
s32 blueOffset;
s32 greenOffset;
s32 tileRow;
s32 lumaSkip;
s8 crValue;
s32 chromaSkip;
s32 width;
s32 cbValue;
u8 value;
s32 row;
u16* output;
s32 redOffset;
s32 greenOffset;
s32 blueOffset;
s32 blue;
s32 value;
TMCCJPEGDecState* state;
s32 width;
s32 height;
s8 crValue;
s32 cbValue;
luminance = work->convBuf + 4;
cb = work->convBuf + 260;
cr = work->convBuf + 324;
cb = &work->convBuf[260];
cr = &work->convBuf[324];
state = work->pState;
tileWidth = (state->convWidth >> 2) << 1;
texture = state->pTexBuffer;
width = 32 / state->scaleFactor;
height = 8 / state->scaleFactor;
{
yEnd = y + height;
xEnd = x + width;
lumaSkip = 32 - width;
chromaSkip = lumaSkip >> 2;
for (row = y; row < yEnd; row++) {
output = (u16*)(texture + ((row & 3) << 3));
tileRow = (row >> 2) * tileWidth;
for (column = x; column < xEnd; column += 4) {
{
cbValue = (s8)*cb++;
crValue = (s8)*cr++;
redOffset = (crValue * 359) >> 8;
greenOffset = -(crValue * 183 + cbValue * 88) >> 8;
blueOffset = (cbValue * 454) >> 8;
}
{
value = *luminance++;
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
}
red = (u8)red + 0x10000 - 0x100;
output[(column & 3) + (((((column) >> 2) << 1) + tileRow) << 4)] = red;
output[(column & 3) + (((((column) >> 2) << 1) + tileRow + 1) << 4)] = ((green & 255) << 8) + (blue & 255);
}
{
value = *luminance++;
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
}
red = (u8)red + 0x10000 - 0x100;
output[(column + 1 & 3) + (((((column + 1) >> 2) << 1) + tileRow) << 4)] = red;
output[(column + 1 & 3) + (((((column + 1) >> 2) << 1) + tileRow + 1) << 4)] = ((green & 255) << 8) + (blue & 255);
}
{
value = *luminance++;
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
}
red = (u8)red + 0x10000 - 0x100;
output[(column + 2 & 3) + (((((column + 2) >> 2) << 1) + tileRow) << 4)] = red;
output[(column + 2 & 3) + (((((column + 2) >> 2) << 1) + tileRow + 1) << 4)] = ((green & 255) << 8) + (blue & 255);
}
{
value = *luminance++;
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
}
red = (u8)red + 0x10000 - 0x100;
output[(column + 3 & 3) + (((((column + 3) >> 2) << 1) + tileRow) << 4)] = red;
output[(column + 3 & 3) + (((((column + 3) >> 2) << 1) + tileRow + 1) << 4)] = ((green & 255) << 8) + (blue & 255);
}
xEnd = x + width;
yEnd = y + height;
for (; y < yEnd; y++) {
for (column = x; column < xEnd; column += 4) {
cbValue = (s8)*cb++;
crValue = (s8)*cr++;
redOffset = (crValue * 359) >> 8;
greenOffset = -(cbValue * 88 + crValue * 183) >> 8;
blueOffset = (cbValue * 454) >> 8;
value = *luminance++;
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
}
luminance += lumaSkip;
cb += chromaSkip;
cr += chromaSkip;
columnInTile = column & 3;
/* MWCC needs these assignments in the first store to preserve row-address scheduling. */
(output = (u16*)(texture + ((y & 3) << 3)))[
columnInTile + ((((column >> 2) << 1) +
(tileRow = (y >> 2) * tileWidth)) << 4)] = (u8)red + 0x10000 - 0x100;
output[columnInTile + ((((column >> 2) << 1) + (tileRow + 1)) << 4)] = ((green & 255) << 8) + (blue & 255);
value = *luminance++;
secondGreen = value + greenOffset;
secondRed = value + redOffset;
secondBlue = value + blueOffset;
if ((secondRed | secondGreen | secondBlue) >> 8) {
secondBlue = secondBlue > 255 ? 255 : secondBlue < 0 ? 0 : secondBlue;
secondGreen = secondGreen > 255 ? 255 : secondGreen < 0 ? 0 : secondGreen;
secondRed = secondRed > 255 ? 255 : secondRed < 0 ? 0 : secondRed;
}
secondColumnInTile = (column + 1) & 3;
output[secondColumnInTile + (((((column + 1) >> 2) << 1) + tileRow) << 4)] = (u8)secondRed + 0x10000 - 0x100;
output[secondColumnInTile + (((((column + 1) >> 2) << 1) + (tileRow + 1)) << 4)] = ((secondGreen & 255) << 8) + (secondBlue & 255);
value = *luminance++;
thirdGreen = value + greenOffset;
thirdRed = value + redOffset;
thirdBlue = value + blueOffset;
if ((thirdRed | thirdGreen | thirdBlue) >> 8) {
thirdBlue = thirdBlue > 255 ? 255 : thirdBlue < 0 ? 0 : thirdBlue;
thirdGreen = thirdGreen > 255 ? 255 : thirdGreen < 0 ? 0 : thirdGreen;
thirdRed = thirdRed > 255 ? 255 : thirdRed < 0 ? 0 : thirdRed;
}
thirdColumnInTile = (column + 2) & 3;
output[thirdColumnInTile + (((((column + 2) >> 2) << 1) + tileRow) << 4)] = (u8)thirdRed + 0x10000 - 0x100;
output[thirdColumnInTile + (((((column + 2) >> 2) << 1) + (tileRow + 1)) << 4)] = ((thirdGreen & 255) << 8) + (thirdBlue & 255);
value = *luminance++;
fourthGreen = value + greenOffset;
fourthRed = value + redOffset;
fourthBlue = value + blueOffset;
if ((fourthRed | fourthGreen | fourthBlue) >> 8) {
fourthBlue = fourthBlue > 255 ? 255 : fourthBlue < 0 ? 0 : fourthBlue;
fourthGreen = fourthGreen > 255 ? 255 : fourthGreen < 0 ? 0 : fourthGreen;
fourthRed = fourthRed > 255 ? 255 : fourthRed < 0 ? 0 : fourthRed;
}
fourthColumnInTile = (column + 3) & 3;
output[fourthColumnInTile + (((((column + 3) >> 2) << 1) + tileRow) << 4)] = (u8)fourthRed + 0x10000 - 0x100;
output[fourthColumnInTile + (((((column + 3) >> 2) << 1) + (tileRow + 1)) << 4)] = ((fourthGreen & 255) << 8) + (fourthBlue & 255);
}
luminance += (32 - width);
cb += ((32 - width) >> 2);
cr += ((32 - width) >> 2);
}
}

View File

@@ -1,4 +1,3 @@
#define TMC_JPEG_PLANAR_OUTPUT
#include <tmc_jpeg_internal.h>
static void TMCJPEG_814EFEAC(TMCCJPEGDecWork*, s32, s32);
@@ -14,7 +13,38 @@ static void TMCJPEG_814F32E4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F34A4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F372C(TMCCJPEGDecWork*, s32, s32);
/* MWCC needs level 1 to preserve the shared conversion-buffer base. */
#pragma push
#pragma optimization_level 1
s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
u8 mode411;
u8* crBlock411;
u8* cbBlock411;
u8* fourthRow411;
u8* thirdRow411;
u8* secondRow411;
u8* firstRow411;
TMCConverterFunc* edgeConverter411;
TMCConverterFunc* converter411;
u8 mode422;
u8* crBlock422;
u8* cbBlock422;
u8* secondRow422;
u8* firstRow422;
TMCConverterFunc* edgeConverter422;
TMCConverterFunc* converter422;
u8 mode420;
u8* crBlock420;
u8* cbBlock420;
u8* fourthRow420;
u8* thirdRow420;
u8* secondRow420;
u8* firstRow420;
TMCConverterFunc* edgeConverter420;
TMCConverterFunc* converter420;
u8* buffer;
s32 componentCount;
TMCCJPEGDecState* state;
@@ -25,97 +55,84 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
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;
mode411 = work->idctMode;
firstRow411 = buffer + 4;
converter411 = TMCJPEG_814EFEAC;
edgeConverter411 = TMCJPEG_814F043C;
secondRow411 = firstRow411 + mode411;
thirdRow411 = secondRow411 + mode411;
fourthRow411 = thirdRow411 + mode411;
cbBlock411 = buffer + 260;
crBlock411 = buffer + 324;
work->pConverterFunc = converter411;
work->pConverterFuncEdge = edgeConverter411;
work->pConvRowPtrs[0] = firstRow411;
work->pConvRowPtrs[1] = secondRow411;
work->pConvRowPtrs[2] = thirdRow411;
work->pConvRowPtrs[3] = fourthRow411;
work->pConvRowPtrs[5] = cbBlock411;
work->pConvRowPtrs[6] = crBlock411;
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;
mode422 = work->idctMode;
firstRow422 = buffer + 4;
converter422 = TMCJPEG_814F0A58;
edgeConverter422 = TMCJPEG_814F11C4;
secondRow422 = firstRow422 + mode422;
cbBlock422 = buffer + 132;
crBlock422 = buffer + 196;
work->pConverterFunc = converter422;
work->pConverterFuncEdge = edgeConverter422;
work->pConvRowPtrs[0] = firstRow422;
work->pConvRowPtrs[1] = secondRow422;
work->pConvRowPtrs[5] = cbBlock422;
work->pConvRowPtrs[6] = crBlock422;
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;
mode420 = work->idctMode;
firstRow420 = buffer + 4;
converter420 = TMCJPEG_814F17E0;
edgeConverter420 = TMCJPEG_814F1F48;
secondRow420 = firstRow420 + mode420;
thirdRow420 = firstRow420 + mode420 * 16;
fourthRow420 = thirdRow420 + mode420;
cbBlock420 = buffer + 260;
crBlock420 = buffer + 324;
work->pConverterFunc = converter420;
work->pConverterFuncEdge = edgeConverter420;
work->pConvRowPtrs[0] = firstRow420;
work->pConvRowPtrs[1] = secondRow420;
work->pConvRowPtrs[2] = thirdRow420;
work->pConvRowPtrs[3] = fourthRow420;
work->pConvRowPtrs[5] = cbBlock420;
work->pConvRowPtrs[6] = crBlock420;
work->pitch = 16;
work->converterFlags = 0;
break;
}
case 3: {
u8 mode;
u8* firstRow;
u8* secondRow;
u8* cbBlock;
u32 mode;
u8* crBlock;
u8* cbBlock;
u8* secondRow;
u8* firstRow;
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
mode = work->idctMode;
firstRow = buffer + 4;
work->pConverterFunc = TMCJPEG_814F2570;
work->pConverterFuncEdge = TMCJPEG_814F2B50;
converter = TMCJPEG_814F2570;
edgeConverter = TMCJPEG_814F2B50;
secondRow = firstRow + mode * 8;
cbBlock = buffer + 132;
crBlock = buffer + 196;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
@@ -125,27 +142,27 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
break;
}
case 4: {
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
converter = TMCJPEG_814F3158;
edgeConverter = TMCJPEG_814F32E4;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
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;
TMCConverterFunc* converter;
converter = TMCJPEG_814F34A4;
edgeConverter = TMCJPEG_814F372C;
work->pConvRowPtrs[0] = buffer + 4;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = buffer + 4;
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -158,16 +175,25 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
{
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;
s32 roundedWidth;
s32 heightPadding;
roundedWidth = (u32)width / 8 + (width % 8 != 0);
heightPadding = height % 4 != 0;
state->convWidth = roundedWidth * 8;
state->convHeight = ((u32)height / 4 + heightPadding) * 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;
roundedWidth = (u32)width / 8 + (width % 8 != 0);
heightPadding = height % 4 != 0;
state->chromaWidth = roundedWidth * 8;
state->chromaHeight = ((u32)height / 4 + heightPadding) * 4;
}
return 0;
}
#pragma pop
static void TMCJPEG_814EFEAC(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 rowSkip;
u8* output;

View File

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

View File

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

View File

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

View File

@@ -185,7 +185,7 @@ extern ziU16 Zi8Ord2Ord(ziU16, ziPtr);
extern ziU8 Zi8LangSupported(ziU8, ziPtr);
extern ziU16 Zi8GetTableCount(ziU8,ziU8,ziPtr);
extern ziU32 Zi8GetTableAddress(ziU8,ziU8,ziPtr);
extern void Zi8Memset(ziU8*,ziU32,ziS32);
extern ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
extern ziU8 _Zi8GetCandidates(ziGetParam*,ziPtr);
extern void Zi8InitDupWordBuf(ziPtr);
extern ziU32 Zi8GetPInfo(ziU32,ziWChar *,ziU8,ziPtr);
@@ -213,6 +213,7 @@ Zi8UInt Zi8SpellingZY(ziU16 *output,Zi8UInt key,ziU8 includeTone)
initialIndex = (ziU16)(((key & 0xffff) >> 9) & 0x3f);
finalIndex = (ziU16)(((key & 0xffff) >> 3) & 0x3f);
tone = (ziU16)(key & 7);
/* MWCC needs the stored initial character as the branch value. */
if ((output[0] = zi8ZYinitialSpelling[initialIndex]) != 0) {
length = 1;
}
@@ -250,7 +251,7 @@ Zi8UInt Zi8SpellingPY(ziU16 *output,Zi8UInt key,ziU8 includeTone)
Zi8UInt length = 0;
ziU16 initialIndex = (ziU16)(((key & 0xffff) >> 9) & 0x3f);
ziU16 finalIndex = (ziU16)(((key & 0xffff) >> 3) & 0x3f);
volatile ziU16 tone = (ziU16)(key & 7);
ziU16 tone = (ziU16)(key & 7);
output[0] = zi8PYinitialSpelling[initialIndex][0];
output[1] = zi8PYinitialSpelling[initialIndex][1];
@@ -354,16 +355,13 @@ ziU8 MatchAltSound1Key(ziU16 *spelling,Zi8UInt spellingLength,Zi8UInt requireFul
if ((keyHigh == records[recordIndex].keyHigh) &&
(keyLow == records[recordIndex].keyLow)) {
searchIndex = recordIndex;
goto START_PROCESS;
} else {
if (keyHigh != records[searchIndex].keyHigh || keyLow != records[searchIndex].keyLow) {
goto BINARY_SEARCH;
}
}
if ((keyHigh == records[searchIndex].keyHigh) &&
(keyLow == records[searchIndex].keyLow)) {
goto START_PROCESS;
}
goto BINARY_SEARCH;
START_PROCESS:
recordIndex = searchIndex;
PROCESS:
do {
if (((records[recordIndex].flags & 0xeU) == 0) ||
((modifierFlags & records[recordIndex].flags) != 0)) {
@@ -402,7 +400,6 @@ BACKWARD_PROCESS:
}
}
}
goto BACKWARD_TEST;
BACKWARD_TEST:
recordIndex = recordIndex - 1;
if ((((int)recordIndex < 0) || (keyHigh != records[recordIndex].keyHigh)) ||
@@ -458,30 +455,25 @@ static int ZiIsSupportedPhonetic(ziU8 language,ziPtr work)
return 1;
}
switch (language) {
case 0x79:
case 0x7a:
case 0x7d:
goto LAB_group_b;
case 0x77:
case 0x78:
case 0x7c:
goto LAB_group_a;
if ((Zi8LangSupported(0x77,work) != 0) || (Zi8LangSupported(0x78,work) != 0) ||
(Zi8LangSupported(0x7c,work) != 0)) {
return 1;
}
case 0x79:
case 0x7a:
case 0x7d:
if ((Zi8LangSupported(0x79,work) == 0) && (Zi8LangSupported(0x7a,work) == 0) &&
(Zi8LangSupported(0x7d,work) == 0)) {
break;
}
return 1;
default:
goto LAB_return_false;
break;
}
LAB_group_a:
if ((Zi8LangSupported(0x77,work) != 0) || (Zi8LangSupported(0x78,work) != 0) ||
(Zi8LangSupported(0x7c,work) != 0)) {
return 1;
}
LAB_group_b:
if ((Zi8LangSupported(0x79,work) == 0) && (Zi8LangSupported(0x7a,work) == 0) &&
(Zi8LangSupported(0x7d,work) == 0)) {
goto LAB_return_false;
}
return 1;
LAB_return_false:
return 0;
return 0;
}
ziU32 Zi8Get1KeyPressSpelling(ziGetParam *params,Zi8OneKeyOptions *options,Zi8OneKeyWork *work)
@@ -778,7 +770,7 @@ ziU32 Zi8Get1KeyPressSpelling(ziGetParam *params,Zi8OneKeyOptions *options,Zi8On
if (options->countOnly == '\0') {
*output++ = spellingBuffer[spellingIndex];
*output++ = 0;
candidateCount = candidateCount + 1;
++candidateCount;
}
else if ((int)totalCandidates >= options->maxCount) goto finishSpelling;
if (candidateCount >= params->maxCandidates) goto finishSpelling;
@@ -938,6 +930,7 @@ ziU32 Zi8Get1KeyPressSpelling(ziGetParam *params,Zi8OneKeyOptions *options,Zi8On
for (;;) {
if (tableCount == 0) break;
spellingEntry = (ziU8 *)Zi8GetTableAddress(1,0xc,work);
/* MWCC needs the spelling-entry advance in the loop body. */
for (tableIndex = 0; tableIndex < tableCount; tableIndex++) {
if ((*spellingEntry & languageMask) != 0) {
if (usePinyin) entryLength = *spellingEntry & 0xf;
@@ -1321,8 +1314,7 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
wordBuffer[params->wordCharCount + wordLength] = 0;
}
if (optionsMask == 5) {
totalCandidates++;
if (totalCandidates >= options->maxCount) goto finishCandidates;
if (++totalCandidates >= options->maxCount) goto finishCandidates;
} else if (remaining == 0) {
totalCandidates++;
candidateCount++;
@@ -1390,8 +1382,7 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
wordBuffer[params->wordCharCount + wordLength] = 0;
}
if (optionsMask == 5) {
totalCandidates++;
if (totalCandidates >= options->maxCount) goto finishCandidates;
if (++totalCandidates >= options->maxCount) goto finishCandidates;
} else if (remaining == 0) {
totalCandidates++;
candidateCount++;
@@ -1431,7 +1422,7 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
}
if ((*phraseEntries & 0x80) != 0) {
entryRemaining = 0;
phraseEntries = phraseEntries + ((int)(*phraseEntries & 0x7f) >> 4) + 1;
phraseEntries += ((int)(*phraseEntries & 0x7f) >> 4) + 1;
} else {
entryRemaining = 0x80;
}
@@ -1495,41 +1486,41 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
elementIndex = MatchAltSound1Key(spelling,inputLimit,matchFull,(Zi8AltSoundRecord *)alternateTable,phoneticMask,phoneticTable,
phraseCharacter,tone,includeTone,languageMask,work);
}
if (elementIndex == 0) goto nextPhrase;
if (!emitWords) {
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,phraseCharacter,work) != 0) goto nextPhrase;
for (index = 0; index < candidateCount; index++) {
if (firstOrdinal == output[index]) goto nextPhrase;
}
} else {
wordLength = 0;
do {
phraseCharacter = ((ziU16)entryCursor[1] << 8) | *entryCursor;
entryCursor += 2;
output[outputIndex + wordLength++] = Zi8Ord2Uni(phraseCharacter & 0x7fff,work);
} while ((phraseCharacter & 0x8000) == 0);
if (prefixSearch != 0 || params->elementCount != 0) wordLength = 1;
if (Zi8IsDupWordW(output + outputIndex,wordLength,work) != 0) goto nextPhrase;
output[outputIndex + wordLength] = 0;
}
if (optionsMask == 5) {
totalCandidates++;
if (totalCandidates >= options->maxCount) goto finishCandidates;
} else if (remaining == 0) {
totalCandidates++;
candidateCount++;
if (emitWords) {
outputIndex += wordLength;
output[outputIndex++] = 0x20;
if (elementIndex != 0) {
if (!emitWords) {
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,phraseCharacter,work) != 0) goto nextPhrase;
for (index = 0; index < candidateCount; index++) {
if (firstOrdinal == output[index]) goto nextPhrase;
}
} else {
output[outputIndex++] = firstOrdinal;
wordLength = 0;
do {
phraseCharacter = ((ziU16)entryCursor[1] << 8) | *entryCursor;
entryCursor += 2;
output[outputIndex + wordLength++] = Zi8Ord2Uni(phraseCharacter & 0x7fff,work);
} while ((phraseCharacter & 0x8000) == 0);
if (prefixSearch != 0 || params->elementCount != 0) wordLength = 1;
if (Zi8IsDupWordW(output + outputIndex,wordLength,work) != 0) goto nextPhrase;
output[outputIndex + wordLength] = 0;
}
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) {
params->count = candidateCount;
goto finishCandidates;
if (optionsMask == 5) {
if (++totalCandidates >= options->maxCount) goto finishCandidates;
} else if (remaining == 0) {
totalCandidates++;
candidateCount++;
if (emitWords) {
outputIndex += wordLength;
output[outputIndex++] = 0x20;
} else {
output[outputIndex++] = firstOrdinal;
}
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) {
params->count = candidateCount;
goto finishCandidates;
}
} else {
remaining--;
}
} else {
remaining--;
}
}
nextPhrase:
@@ -1560,7 +1551,7 @@ finishPhrases:
for (index = 0; index < 4; index++) {
if (keyValues[index] != (keyMasks[index] & phraseTable[index])) break;
}
if (index < 4) goto nextSortedOrdinal;
if (index < 4) continue;
}
entryFlags = false;
if (work->phoneticFilter != 0) {
@@ -1577,17 +1568,17 @@ finishPhrases:
elementIndex = MatchAltSound1Key(spelling,inputLimit,matchFull,(Zi8AltSoundRecord *)alternateTable,phoneticMask,phoneticTable,ordinal,
tone,includeTone,languageMask,work);
}
if (elementIndex == 0) goto nextSortedOrdinal;
if (elementIndex == 0) continue;
if (!emitWords) {
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextSortedOrdinal;
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,ordinal,work) != 0) continue;
ordinal = Zi8Ord2Uni(ordinal,work);
for (index = 0; index < candidateCount; index++) {
if (ordinal == output[index]) break;
}
if (index < candidateCount) goto nextSortedOrdinal;
if (index < candidateCount) continue;
} else {
ordinal = Zi8Ord2Uni(ordinal,work);
if (Zi8IsDupWordW(&ordinal,1,work) != 0) goto nextSortedOrdinal;
if (Zi8IsDupWordW(&ordinal,1,work) != 0) continue;
}
if (remaining == 0) {
totalCandidates++;
@@ -1603,12 +1594,11 @@ finishPhrases:
remaining--;
}
}
nextSortedOrdinal:
;
}
}
if ((options->countOnly == '\0') && (ziU8)Zi8GetZHuwdPtr(&userEntriesAddress,&userCount,work) != 0)
{
/* MWCC needs both user-entry cursor advances in the loop body. */
for (phraseOrdinal = 0; phraseOrdinal < userCount;) {
if ((params->elementCount == '\0') || ((((ziU8*)userEntriesAddress)[1] & 0x80) != 0)) {
userOrdinal = (ziU16)(((ziU8*)userEntriesAddress)[1] & 0x7f) << 8 | (ziU16)((ziU8*)userEntriesAddress)[2];
@@ -1630,26 +1620,27 @@ nextSortedOrdinal:
elementIndex = MatchAltSound1Key(spelling,inputLimit,matchFull,(Zi8AltSoundRecord *)alternateTable,phoneticMask,phoneticTable,userOrdinal,
tone,includeTone,languageMask,work);
}
if (elementIndex == 0) goto nextUserOrdinal;
if (!emitWords) {
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,userOrdinal,work) != 0) goto nextUserOrdinal;
userCharacter = Zi8Ord2Uni(userOrdinal,work);
for (duplicateIndex = 0; duplicateIndex < candidateCount; duplicateIndex++) {
if (userCharacter == output[duplicateIndex]) break;
if (elementIndex != 0) {
if (!emitWords) {
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,userOrdinal,work) != 0) goto nextUserOrdinal;
userCharacter = Zi8Ord2Uni(userOrdinal,work);
for (duplicateIndex = 0; duplicateIndex < candidateCount; duplicateIndex++) {
if (userCharacter == output[duplicateIndex]) break;
}
if (duplicateIndex < candidateCount) goto nextUserOrdinal;
} else {
userCharacter = Zi8Ord2Uni(userOrdinal,work);
if (Zi8IsDupWordW(&userCharacter,1,work) != 0) goto nextUserOrdinal;
}
if (remaining == 0) {
totalCandidates++;
candidateCount++;
output[outputIndex++] = userCharacter;
if (emitWords) output[outputIndex++] = 0x20;
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) goto finishCandidates;
} else {
remaining--;
}
if (duplicateIndex < candidateCount) goto nextUserOrdinal;
} else {
userCharacter = Zi8Ord2Uni(userOrdinal,work);
if (Zi8IsDupWordW(&userCharacter,1,work) != 0) goto nextUserOrdinal;
}
if (remaining == 0) {
totalCandidates++;
candidateCount++;
output[outputIndex++] = userCharacter;
if (emitWords) output[outputIndex++] = 0x20;
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) goto finishCandidates;
} else {
remaining--;
}
}
}
@@ -1660,6 +1651,7 @@ nextUserOrdinal:
}
phraseTable = syllableTable;
previousCharacter = 0;
/* MWCC needs both ordinal cursor advances in the loop body. */
for (ordinal = 0; ordinal < ordinalCount;) {
if (((*phraseTable & languageMask) != 0) &&
((characterSetTable == 0 || ((characterSet & characterSetTable[(Zi8UInt)ordinal]) != 0)))) {
@@ -1683,31 +1675,33 @@ nextUserOrdinal:
elementIndex = MatchAltSound1Key(spelling,inputLimit,matchFull,(Zi8AltSoundRecord *)alternateTable,phoneticMask,phoneticTable,ordinal,
tone,includeTone,languageMask,work);
}
if (elementIndex == 0) goto nextOrdinal;
unicodeCharacter = ((ziU16)phraseTable[6] << 8) + (ziU16)phraseTable[7];
if (unicodeCharacter == previousCharacter) goto nextOrdinal;
previousCharacter = unicodeCharacter;
if (!emitWords) {
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextOrdinal;
for (index = 0; index < candidateCount; index++) {
if (unicodeCharacter == output[index]) break;
if (elementIndex != 0) {
unicodeCharacter = ((ziU16)phraseTable[6] << 8) + (ziU16)phraseTable[7];
if (unicodeCharacter != previousCharacter) {
previousCharacter = unicodeCharacter;
if (!emitWords) {
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextOrdinal;
for (index = 0; index < candidateCount; index++) {
if (unicodeCharacter == output[index]) break;
}
if (index < candidateCount) goto nextOrdinal;
} else {
if (Zi8IsDupWordW(&unicodeCharacter,1,work) != 0) goto nextOrdinal;
}
if (remaining == 0) {
totalCandidates++;
if (options->countOnly == 0) {
candidateCount++;
output[outputIndex++] = unicodeCharacter;
if (emitWords) output[outputIndex++] = 0x20;
} else {
if (totalCandidates >= options->maxCount) break;
}
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) break;
} else {
remaining--;
}
}
if (index < candidateCount) goto nextOrdinal;
} else {
if (Zi8IsDupWordW(&unicodeCharacter,1,work) != 0) goto nextOrdinal;
}
if (remaining == 0) {
totalCandidates++;
if (options->countOnly == 0) {
candidateCount++;
output[outputIndex++] = unicodeCharacter;
if (emitWords) output[outputIndex++] = 0x20;
} else {
if (totalCandidates >= options->maxCount) break;
}
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) break;
} else {
remaining--;
}
}
nextOrdinal:
@@ -1787,23 +1781,22 @@ ziBool Zi8ZHCheckSpelling(ziWChar *input,ziWChar *spelling,ziU8 inputLength,ziPt
switch (spelling[index]) {
case 0xf331:
toneMask = 1;
goto validateTone;
break;
case 0xf332:
toneMask = 2;
goto validateTone;
break;
case 0xf333:
toneMask = 4;
goto validateTone;
break;
case 0xf334:
toneMask = 8;
goto validateTone;
break;
case 0xf335:
toneMask = 0x10;
goto validateTone;
break;
default:
goto nextInputCharacter;
continue;
}
validateTone:
if (toneTable != 0) {
while( true ) {
syllableLength = (index - syllableStart) + 1;
@@ -1845,8 +1838,6 @@ validateTone:
}
input[index] = spelling[index];
syllableStart = index + 1;
nextInputCharacter:
;
}
for (index = 0; input[index] != 0; index = index + 1) {
if ((input[index] >= 0x61) && (input[index] <= 0x7a)) {

View File

@@ -231,7 +231,7 @@ ziBool Zi8IsVowel(ziU8 language, ziWChar character) {
if (language == 47) return ZI8_FALSE;
switch (character) {
case 0xFF: case 0x152: case 0x153: case 0x178:
goto vowel;
break;
default:
return ZI8_FALSE;
}
@@ -287,6 +287,7 @@ static ziBool ZiIsLetterHyphen(ziWChar character ZI_NEED_WORK) {
void Zi8ChangeWordCase(ziWChar* word, ziU8 language, ZiAlphaWork* work) {
enum { LOWER_CASE, UPPER_CASE } upper = LOWER_CASE;
/* MWCC needs the explicit work cast in the case-mode test below. */
if (work->caseMode == 3) {
Zi8ChangeCharCase(1, word++, language, work);
} else if (((ZiAlphaWork*)work)->caseMode == 1) {
@@ -295,7 +296,7 @@ void Zi8ChangeWordCase(ziWChar* word, ziU8 language, ZiAlphaWork* work) {
while (*word != 0) Zi8ChangeCharCase(upper, word++, language, work);
}
ziU32 Zi8DeTokenization(ziWChar* word, ziU32 length, ziU16 capacity, ziU16 language);
ziU16 Zi8DeTokenization(ziWChar* word, ziU16 length, ziU16 capacity, ziU16 language);
ziU32 Zi8GetTableAddress(ziU8 language, ziU8 table, ziPtr work);
ziU16 Zi8GetTableCount(ziU8 language, ziU8 table, ziPtr work);
void Zi8InitDupWordBuf(ziPtr work);
@@ -306,7 +307,7 @@ ziU8 Zi8MatchOEMdata(ziWChar* elements, ziU8 count, ziU8 language, ziWChar* word
ziU8 Zi8MatchPUDdata(ziWChar* elements, ziU8 count, ziU8 language, ziWChar* word, ziU16 capacity, ziU8 mode, ziU8 status, ziPtr work);
ziU8 Zi8MatchROMdata(ziWChar* elements, ziU8 count, ziU8 language, ziWChar* word, ziU16 capacity, ziU8 mode, ziU8 status, ziBool reservedMode, ziBool exactLength, ziPtr work);
ziU8 Zi8MatchUWDdata(ziWChar* elements, ziU8 count, ziWChar* currentWord, ziU16 currentLength, ziU8 language, ziWChar* word, ziU16 capacity, ziU8 mode, ziU8 status, ziPtr work);
void Zi8Memset(ziPtr destination, ziU32 value, ziU32 count);
ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
ziU16 Zi8WCharCount(ziWChar* word, ziPtr work);
ziBool Zi8ZHCheckSpelling(ziWChar* word, ziWChar* elements, ziU8 count, ziPtr work);
ziU8 Zi8getKeyLayout(ziU8 language, ziWChar key, ziWChar* characters, ziU8 capacity, ziPtr work);
@@ -460,10 +461,14 @@ int Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr optionData, ziPtr workDa
if (((Zi8GetTableCount(parameters->language,0x1f,workData) & 0x80) != 0) && (parameters->subLanguage == 0x80)) {
contextEnabled = ZI8_TRUE;
}
if (!(((((ZiAlphaOptions*)optionData)->lookupMode == '\0') && (parameters->subLanguage != 7)) &&
((parameters->subLanguage != language &&
((((parameters->subLanguage != 0 && (parameters->subLanguage != 1)) && (parameters->subLanguage != 2)) &&
((parameters->subLanguage != 0x80 && ((Zi8LangSupported(parameters->subLanguage,workData)) != '\0'))))))))) {
if (((ZiAlphaOptions*)optionData)->lookupMode != '\0' ||
parameters->subLanguage == 7 ||
parameters->subLanguage == language ||
parameters->subLanguage == 0 ||
parameters->subLanguage == 1 ||
parameters->subLanguage == 2 ||
parameters->subLanguage == 0x80 ||
(Zi8LangSupported(parameters->subLanguage,workData)) == '\0') {
languagePassCount = 0;
if (((ZiAlphaWork*)workData)->language != parameters->language) {
((ZiAlphaWork*)workData)->language = 0;
@@ -550,7 +555,6 @@ int Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr optionData, ziPtr workDa
secondaryCompletionAllowed = 0;
}
Zi8InitDupWordBuf(workData);
dictionaryIndex = 0;
if ((((((ZiAlphaOptions*)optionData)->lookupMode == '\0') && (!phoneticInput)) && (!phoneticSeparator)) &&
((((parameters->getOptions & 0xfd) != 0x80 && (parameters->elementCount != 0)) &&
((parameters->elements[parameters->elementCount - 1] != 0xEFF1 &&
@@ -559,8 +563,7 @@ int Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr optionData, ziPtr workDa
if (((ZiAlphaWork*)workData)->highlightedWord[elementIndex] != parameters->elements[elementIndex]) break;
wordCursor[elementIndex] = ((ZiAlphaWork*)workData)->highlightedWord[elementIndex];
}
wordCursor[elementIndex] = parameters->elements[elementIndex];
elementIndex++;
wordCursor[elementIndex++] = parameters->elements[elementIndex];
if (parameters->elementCount == 1) ((ZiAlphaWork*)workData)->singleCharacter = *wordCursor;
if (elementIndex == parameters->elementCount &&
(firstCandidate == 0 || ((ZiAlphaWork*)workData)->reuseHighlightedWord != 0)) {
@@ -568,10 +571,12 @@ int Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr optionData, ziPtr workDa
switch ((int)((ZiAlphaWork*)workData)->dictionaryKinds[index]) {
case 1:
case 9:
goto foundHighlightedDictionary;
break;
default:
continue;
}
break;
}
foundHighlightedDictionary:
if (firstCandidate == 0 && ((ZiAlphaWork*)workData)->highlightedWord[elementIndex - 1] != 0) {
if (((ZiAlphaWork*)workData)->requiredLength < parameters->elementCount)
((ZiAlphaWork*)workData)->reuseHighlightedWord = 0;
@@ -654,7 +659,7 @@ foundHighlightedDictionary:
}
goto prepareDictionaryOrder;
preparePrefix:
prefixMode = ((ZiAlphaWork*)workData)->suffixMode;
prefixMode = (ziU8)((ZiAlphaWork*)workData)->suffixMode;
prefixTableFlags = Zi8GetTableCount(language,0x1f,workData);
prefixVowelFlags = prefixTableFlags & 0x10;
if (((((language == 0x3f) || (language == 4)) ||
@@ -700,7 +705,6 @@ preparePrefix:
prefixVowelRestriction = ZI8_FALSE;
}
}
goto prepareDictionaryOrder;
prepareDictionaryOrder:
((ZiAlphaWork*)workData)->dictionaryOrder[0] = 0;
if ((Zi8GetTableCount(language,0x1f,workData) & 0x20) != 0) {
@@ -772,11 +776,11 @@ prepareDictionaries:
if (dictionaryIndex != ((ZiAlphaWork*)workData)->dictionaryCount) {
dictionaryKind = ((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex];
if (dictionaryKind == 12) {
if (languagePassCount != 2) goto finishDictionaryPass;
if (languagePassCount != 2) continue;
goto selectDictionary;
}
} else {
if (((ZiAlphaOptions*)optionData)->lookupMode != 0) goto finishDictionaryPass;
if (((ZiAlphaOptions*)optionData)->lookupMode != 0) continue;
dictionaryKind = 10;
}
selectDictionary:
@@ -787,7 +791,7 @@ selectDictionary:
case 3:
case 4:
case 10:
goto finishDictionaryPass;
continue;
}
}
{
@@ -805,7 +809,7 @@ selectDictionary:
((parameters->currentWord == 0 ||
((parameters->wordCharCount == 0 ||
(parameters->currentWord[parameters->wordCharCount - 1] == 0x20))))))))
goto finishDictionaryPass;
continue;
if ((candidateCount == 0) &&
((((!punctuationCandidate && (parameters->firstCandidate == firstCandidate)) &&
((parameters->currentWord == 0 ||
@@ -831,10 +835,10 @@ selectDictionary:
punctuationCandidate = ZI8_FALSE;
break;
case 4:
if (((ZiAlphaOptions*)optionData)->minWordLength > elementCount) goto finishDictionaryPass;
if (((ZiAlphaOptions*)optionData)->minWordLength > elementCount) continue;
break;
case 3:
if (((ZiAlphaOptions*)optionData)->minWordLength > elementCount || elementCount == 1) goto finishDictionaryPass;
if (((ZiAlphaOptions*)optionData)->minWordLength > elementCount || elementCount == 1) continue;
break;
case 9:
if (elementCount == 1 && *elements >= 0xEFF1 && *elements <= 0xF010) {
@@ -843,7 +847,7 @@ selectDictionary:
}
default:
if (elementCount == 1 && prefixCount == 0 && *elements >= 0xEFF1 &&
*elements <= 0xF010 && !contextEnabled) goto finishDictionaryPass;
*elements <= 0xF010 && !contextEnabled) continue;
dictionaryExact = 0;
if (languagePassCount == 2) {
for (index = dictionaryIndex + 1; index < ((ZiAlphaWork*)workData)->dictionaryCount; index++) {
@@ -900,19 +904,19 @@ selectDictionary:
}
else {
if (alternateSingleCharacter != 2) {
wordLength = Zi8MatchROMdata(elements,elementCount & 0xff,language,wordCursor,
wordCapacity & 0xffff,matchMode,
dictionaryStatus[dictionaryKind] & 0xff,0,exactLengthOnly,workData);
wordLength = Zi8MatchROMdata(elements,elementCount,language,wordCursor,
wordCapacity,matchMode,
dictionaryStatus[dictionaryKind],0,exactLengthOnly,workData);
}
if ((alternateSingleCharacter != 0) && ((wordLength == 0 || (*wordCursor == *elements)))) {
if (alternateSingleCharacter == 1) {
alternateSingleCharacter = 2;
wordLength = Zi8MatchROMdata(elements,elementCount & 0xff,parameters->subLanguage,wordCursor,
wordCapacity & 0xffff,1,0,0,exactLengthOnly,workData);
wordLength = Zi8MatchROMdata(elements,elementCount,parameters->subLanguage,wordCursor,
wordCapacity,1,0,0,exactLengthOnly,workData);
}
else {
wordLength = Zi8MatchROMdata(elements,elementCount & 0xff,parameters->subLanguage,wordCursor,
wordCapacity & 0xffff,1,1,0,exactLengthOnly,workData);
wordLength = Zi8MatchROMdata(elements,elementCount,parameters->subLanguage,wordCursor,
wordCapacity,1,1,0,exactLengthOnly,workData);
}
}
}
@@ -922,36 +926,33 @@ selectDictionary:
if ((((wordLength == 0) && (*punctuationCursor != 0)) && (dictionaryExact != 0)) &&
((((ZiAlphaWork*)workData)->singleCharacter != 0 && (parameters->elementCount == 2)))) {
*wordCursor = ((ZiAlphaWork*)workData)->singleCharacter;
wordCursor[2] = 0;
wordCursor[1] = *punctuationCursor++;
wordCursor[2] = 0;
wordLength = 2;
}
if (((apostropheIndex != 0) && (wordLength != 0)) && (elementCount == parameters->elementCount)) {
if (language == 0x2f) {
index = Zi8ITspecialExclusion
(wordCursor + apostropheIndex,apostropheIndex,wordLength - apostropheIndex);
if (index != '\0') {
if (Zi8ITspecialExclusion
(wordCursor + apostropheIndex,apostropheIndex,wordLength - apostropheIndex) != 0) {
wordLength = 0;
}
}
else if (language == 0x58) {
index = Zi8_814659E8(wordCursor + apostropheIndex,apostropheIndex,wordLength - apostropheIndex);
if (index != '\0') {
if (Zi8_814659E8(wordCursor + apostropheIndex,apostropheIndex,wordLength - apostropheIndex) != 0) {
wordLength = 0;
}
}
else {
index = Zi8IsVowel(language,wordCursor[apostropheIndex]);
if (index == '\0') {
if (Zi8IsVowel(language,wordCursor[apostropheIndex]) == 0) {
wordLength = 0;
}
}
if (wordLength != 0) goto filterVowelCandidate;
dictionaryStatus[dictionaryKind] = 1;
if (elements[apostropheIndex] >= 0xEFF1) goto retryDictionary;
goto finishDictionaryPass;
}
filterVowelCandidate:
if (wordLength == 0) {
dictionaryStatus[dictionaryKind] = 1;
if (elements[apostropheIndex] >= 0xEFF1) continue;
goto finishDictionaryPass;
}
}
if ((wordLength != 0) && (prefixVowelRestriction)) {
if ((*wordCursor >= 0x30) && (*wordCursor <= 0x39)) {
wordLength = 0;
@@ -961,20 +962,17 @@ filterVowelCandidate:
goto finishDictionaryPass;
}
if (language == 0x2f) {
index = Zi8ITspecialExclusion(wordCursor,prefixCount,wordLength);
if (index != '\0') {
if (Zi8ITspecialExclusion(wordCursor,prefixCount,wordLength) != 0) {
wordLength = 0;
}
}
else if (language == 0x58) {
index = Zi8_814659E8(wordCursor,prefixCount,wordLength);
if (index != '\0') {
if (Zi8_814659E8(wordCursor,prefixCount,wordLength) != 0) {
wordLength = 0;
}
}
else {
index = Zi8IsVowel(language,*wordCursor);
if (index == '\0') {
if (Zi8IsVowel(language,*wordCursor) == 0) {
wordLength = 0;
}
}
@@ -982,7 +980,7 @@ filterVowelCandidate:
if (wordLength == 0) {
wordLength = 0;
dictionaryStatus[dictionaryKind] = 1;
goto retryDictionary;
continue;
}
}
if (wordLength != 0) {
@@ -998,9 +996,9 @@ filterVowelCandidate:
case 2:
case 6:
if (elementCount != 0) {
wordLength = Zi8MatchPUDdata(elements,elementCount & 0xff,language,wordCursor,
wordCapacity & 0xffff,dictionaryExact,
dictionaryStatus[dictionaryKind] & 0xff,workData);
wordLength = Zi8MatchPUDdata(elements,elementCount,language,wordCursor,
wordCapacity,dictionaryExact,
dictionaryStatus[dictionaryKind],workData);
}
break;
case 3:
@@ -1008,8 +1006,8 @@ filterVowelCandidate:
while( ZI8_TRUE ) {
wordLength = Zi8MatchUWDdata(elements,elementCount,
parameters->currentWord,parameters->wordCharCount,
language,wordCursor,wordCapacity & 0xffff,dictionaryExact,
dictionaryStatus[dictionaryKind] & 0xff,workData);
language,wordCursor,wordCapacity,dictionaryExact,
dictionaryStatus[dictionaryKind],workData);
if (((elementCount != 0) || (wordLength != 1)) || (*wordCursor != 0x20)) break;
dictionaryStatus[dictionaryKind] = 1;
}
@@ -1019,10 +1017,11 @@ filterVowelCandidate:
if (elementCount != 0) {
wordLength = Zi8MatchOEMdata(elements,elementCount,language,wordCursor,
wordCapacity,dictionaryExact,
dictionaryStatus[dictionaryKind] & 0xff,workData);
dictionaryStatus[dictionaryKind],workData);
}
break;
case 10:
/* MWCC needs the stored punctuation character as the branch value. */
if ((*wordCursor = *punctuationCursor) != 0) {
punctuationCursor++;
wordLength = 1;
@@ -1074,15 +1073,19 @@ filterVowelCandidate:
(((ZiAlphaOptions*)optionData)->lookupMode == '\0')) &&
(((ZiAlphaWork*)workData)->dictionaries[language] == 0)))))) {
if (language != ((ZiAlphaWork*)workData)->language) break;
index = ((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex + 1];
if (index == 0xc || (index < 9 && index >= 5)) {
switch (((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex + 1]) {
case 5:
case 6:
case 7:
case 8:
case 12:
if (Zi8getKeyLayout(language,0xeff1,&punctuationBuffer[0],1,workData) == 0) {
punctuationBuffer[0] = 0;
}
punctuationCursor = &punctuationBuffer[0];
dictionaryKind = 0xb;
retryPunctuation = ZI8_TRUE;
goto retryDictionary;
continue;
}
}
if ((((((dictionaryExact == 0) || (!currentVowelRestriction)) || (prefixCount != 0)) ||
@@ -1094,8 +1097,16 @@ filterVowelCandidate:
(((((ZiAlphaWork*)workData)->rememberedWord[0] == 0 || (((ZiAlphaOptions*)optionData)->lookupMode != '\0')) ||
(((ZiAlphaWork*)workData)->dictionaries[language] != 0)))))) ||
(languagePassCount == 2)))) break;
index = ((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex + 1];
if ((index != 0xc) && (((0xb < index || (8 < index)) || (index < 5)))) break;
switch (((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex + 1]) {
case 5:
case 6:
case 7:
case 8:
case 12:
break;
default:
goto finishDictionaryPass;
}
if (Zi8getKeyLayout(language,0xeff1,&punctuationBuffer[0],1,workData) == 0) {
punctuationBuffer[0] = 0;
}
@@ -1104,18 +1115,17 @@ filterVowelCandidate:
}
else if (((ZiAlphaOptions*)optionData)->minWordLength <= wordLength) {
if (prefixVowelRestriction) {
if (*wordCursor >= 0x30 && *wordCursor <= 0x39) goto retryDictionary;
if (*wordCursor >= 0x30 && *wordCursor <= 0x39) continue;
if (language == 0x2f) {
if (Zi8ITspecialExclusion(wordCursor,prefixCount,wordLength) != 0) goto retryDictionary;
if (Zi8ITspecialExclusion(wordCursor,prefixCount,wordLength) != 0) continue;
} else if (language == 0x58) {
if (Zi8_814659E8(wordCursor,prefixCount,wordLength) != 0) goto retryDictionary;
if (Zi8_814659E8(wordCursor,prefixCount,wordLength) != 0) continue;
} else if (Zi8IsVowel(language,*wordCursor) == 0) {
wordLength = 0;
goto retryDictionary;
continue;
}
}
{
prepareCandidate:
if (((elementCount == 1) && (dictionaryKind != 10)) &&
((*wordCursor >= 0xeff1 && *wordCursor <= 0xf010))) {
punctuationCandidate = ZI8_TRUE;
@@ -1127,8 +1137,8 @@ prepareCandidate:
wordLength = elementCount;
wordCursor[wordLength] = 0;
}
wordLength = (ziU16)Zi8DeTokenization(wordCursor,wordLength & 0xffff,wordCapacity & 0xffff,language);
if (((phoneticInput) && ((unsigned int)parameters->elementCount < (wordLength & 0xff))) &&
wordLength = Zi8DeTokenization(wordCursor,wordLength,wordCapacity,language);
if (((phoneticInput) && ((ziU8)parameters->elementCount < (wordLength & 0xffU))) &&
((wordCursor[wordLength - 1] == 0xf360 || (wordCursor[wordLength - 1] == 0x27)))) {
wordLength = wordLength - 1;
wordCursor[wordLength] = 0;
@@ -1145,7 +1155,7 @@ prepareCandidate:
wordCursor[wordLength] = 0;
}
if (((int)((ZiAlphaOptions*)optionData)->maxWordLength < (int)(wordLength + prefixCount)) ||
((Zi8IsDupWordW(wordCursor - prefixCount,wordLength + prefixCount & 0xff,
((Zi8IsDupWordW(wordCursor - prefixCount,wordLength + prefixCount,
workData)) != '\0')) {
if ((prefixCount != 0) && (((ZiAlphaOptions*)optionData)->maxWordLength <= prefixCount)) break;
}
@@ -1158,12 +1168,11 @@ prepareCandidate:
case 5:
case 1:
case 9:
checkKeyLayout:
keyLayoutCursor = keyLayout;
candidateCharacterCount = wordLength + prefixCount;
for (index = 0; (int)index < (int)(unsigned int)keyLayoutCount; index = index + 1) {
if (*keyLayoutCursor < candidateCharacterCount) {
keyLayoutCursor = keyLayoutCursor + *keyLayoutCursor + 1;
keyLayoutCursor += *keyLayoutCursor + 1;
} else {
if (*keyLayoutCursor++ > candidateCharacterCount) {
index = (unsigned int)keyLayoutCount;
@@ -1541,8 +1550,7 @@ checkPrefixPunctuation:
((ZiAlphaWork*)workData)->letterHyphen = 0x2e;
}
if (elements[((ZiAlphaWork*)workData)->prefixCount] != 0xEFF1 && Zi8IsAlphaPunct(elements[((ZiAlphaWork*)workData)->prefixCount]) != 0) {
((ZiAlphaWork*)workData)->prefix[((ZiAlphaWork*)workData)->prefixCount] = elements[((ZiAlphaWork*)workData)->prefixCount];
((ZiAlphaWork*)workData)->prefixCount++;
((ZiAlphaWork*)workData)->prefix[((ZiAlphaWork*)workData)->prefixCount++] = elements[((ZiAlphaWork*)workData)->prefixCount];
} else {
((ZiAlphaWork*)workData)->prefix[((ZiAlphaWork*)workData)->prefixCount++] = ((ZiAlphaWork*)workData)->letterHyphen;
}
@@ -1551,20 +1559,27 @@ checkPrefixPunctuation:
goto preparePrefix;
}
}
if (!completionAllowed && ((ZiAlphaWork*)workData)->suffixMode == 0 && ((ZiAlphaWork*)workData)->prefixCount != 0 &&
elementCount > 2 && ((ZiAlphaWork*)workData)->prefixCount == elementCount - 1 &&
Zi8IsAlphaPunct(parameters->elements[((ZiAlphaWork*)workData)->prefixCount - 1]) != 0) goto checkPrefixFields;
if (!completionAllowed && ((ZiAlphaWork*)workData)->suffixMode == 0 && parameters->elementCount > 1 &&
Zi8IsAlphaPunct(parameters->elements[parameters->elementCount - 1]) == 0) goto finishCandidates;
checkPrefixFields:
if (completionAllowed ||
((ZiAlphaWork*)workData)->suffixMode != 0 ||
((ZiAlphaWork*)workData)->prefixCount == 0 ||
elementCount <= 2 ||
((ZiAlphaWork*)workData)->prefixCount != elementCount - 1 ||
Zi8IsAlphaPunct(parameters->elements[((ZiAlphaWork*)workData)->prefixCount - 1]) == 0) {
if (!completionAllowed && ((ZiAlphaWork*)workData)->suffixMode == 0 && parameters->elementCount > 1 &&
Zi8IsAlphaPunct(parameters->elements[parameters->elementCount - 1]) == 0) goto finishCandidates;
}
prefixMode = ((ZiAlphaWork*)workData)->suffixMode;
prefixLength = ((ZiAlphaWork*)workData)->prefixCount;
if (prefixMode != 0 || prefixLength == 0 || elementCount <= 2 ||
prefixLength != elementCount - 1 || parameters->elements[parameters->elementCount - 1] == 0xEFF1) goto finishCandidates;
((ZiAlphaWork*)workData)->suffixMode = 1;
((ZiAlphaWork*)workData)->prefixElementCount = parameters->elementCount;
prefixPrepared = ZI8_TRUE;
goto preparePrefix;
if (prefixMode == 0 &&
prefixLength != 0 &&
elementCount > 2 &&
prefixLength == elementCount - 1 &&
parameters->elements[parameters->elementCount - 1] != 0xEFF1) {
((ZiAlphaWork*)workData)->suffixMode = 1;
((ZiAlphaWork*)workData)->prefixElementCount = parameters->elementCount;
prefixPrepared = ZI8_TRUE;
goto preparePrefix;
}
finishCandidates:
((ZiAlphaWork*)workData)->usePrefixAsElements = 0;
@@ -1637,7 +1652,7 @@ finishCandidates:
ziU32 Zi8DeTokenization(ziWChar* word, ziU32 length, ziU16 capacity, ziU16 language) {
ziU16 Zi8DeTokenization(ziWChar* word, ziU16 length, ziU16 capacity, ziU16 language) {
ziU16 index;
ziBool changed = ZI8_FALSE;
ziU16 outputCount = 0;

View File

@@ -1,108 +1,95 @@
#include <zi8clib/zitypes.h>
ziU16 Zi8MatchAltSound(ziU8* elements, ziU16 count, ziU8* table, ziU16 ch,
ziU16 Zi8MatchAltSound(ziU8* elements, ziU16 count, ziU8* table, ziU16 ordinal,
ziU32 mask, ziU16 target, ziU8 flags ZI_NEED_WORK) {
ziU8 hi;
ziU8 lo;
ziS32 i;
ziS32 j;
ziS32 mid;
ziU16 off;
ziU16 w;
ziU8 ordinalHigh;
ziU8 ordinalLow;
ziS32 recordIndex;
ziS32 searchIndex;
ziS32 midpoint;
ziU16 phoneticOffset;
ziU16 phoneticCode;
hi = (ziU8)((ziU16)ch >> 8);
lo = (ziU8)ch;
ordinalHigh = (ziU8)(ordinal >> 8);
ordinalLow = (ziU8)ordinal;
flags = (ziU8)(flags >> 3);
if (count == 0) {
return 0;
}
j = 0;
i = count - 1;
if ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo) {
j = i;
goto up;
searchIndex = 0;
recordIndex = count - 1;
if ((elements + recordIndex * 4)[1] == ordinalHigh && (elements + recordIndex * 4)[0] == ordinalLow) {
searchIndex = recordIndex;
} else {
if ((elements + searchIndex * 4)[1] != ordinalHigh || (elements + searchIndex * 4)[0] != ordinalLow) {
goto search;
}
}
if ((elements + j * 4)[1] == hi && (elements + j * 4)[0] == lo) {
goto up;
}
goto search;
up:
i = j;
body:
if (((elements + i * 4)[3] & 0xE) == 0 ||
((elements + i * 4)[3] & flags) != 0) {
off = (ziU16)(((ziU16)(elements + i * 4)[2] |
(((ziU16)(elements + i * 4)[3] & 1) << 8)) << 1);
w = (ziU16)((((ziU16)(elements + i * 4)[3] & 0xF0) >> 4) |
(table[off] | ((ziU16)table[off + 1] << 8)));
if (target == (w & (ziU16)mask)) {
return w;
recordIndex = searchIndex;
do {
if (((elements + recordIndex * 4)[3] & 0xE) == 0 ||
((elements + recordIndex * 4)[3] & flags) != 0) {
phoneticOffset = (ziU16)(((ziU16)(elements + recordIndex * 4)[2] |
(((ziU16)(elements + recordIndex * 4)[3] & 1) << 8)) << 1);
phoneticCode = (ziU16)((((ziU16)(elements + recordIndex * 4)[3] & 0xF0) >> 4) |
(table[phoneticOffset] | ((ziU16)table[phoneticOffset + 1] << 8)));
if (target == (phoneticCode & (ziU16)mask)) {
return phoneticCode;
}
}
recordIndex++;
if (recordIndex >= count) {
break;
}
} while ((elements + recordIndex * 4)[1] == ordinalHigh && (elements + recordIndex * 4)[0] == ordinalLow);
recordIndex = searchIndex;
while (--recordIndex >= 0 && (elements + recordIndex * 4)[1] == ordinalHigh && (elements + recordIndex * 4)[0] == ordinalLow) {
if (((elements + recordIndex * 4)[3] & 0xE) == 0 ||
((elements + recordIndex * 4)[3] & flags) != 0) {
phoneticOffset = (ziU16)(((ziU16)(elements + recordIndex * 4)[2] |
(((ziU16)(elements + recordIndex * 4)[3] & 1) << 8)) << 1);
phoneticCode = (ziU16)((((ziU16)(elements + recordIndex * 4)[3] & 0xF0) >> 4) |
(table[phoneticOffset] | ((ziU16)table[phoneticOffset + 1] << 8)));
if (target == (phoneticCode & (ziU16)mask)) {
return phoneticCode;
}
}
}
i++;
if (i >= count) {
goto down_start;
}
if ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo) {
goto body;
}
down_start:
i = j;
goto dec;
down_body:
if (((elements + i * 4)[3] & 0xE) == 0 ||
((elements + i * 4)[3] & flags) != 0) {
off = (ziU16)(((ziU16)(elements + i * 4)[2] |
(((ziU16)(elements + i * 4)[3] & 1) << 8)) << 1);
w = (ziU16)((((ziU16)(elements + i * 4)[3] & 0xF0) >> 4) |
(table[off] | ((ziU16)table[off + 1] << 8)));
if (target == (w & (ziU16)mask)) {
return w;
}
}
dec:
i--;
if (i < 0) {
goto fail;
}
if ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo) {
goto down_body;
}
fail:
return 0;
search:
if ((elements + j * 4)[1] == hi && (elements + j * 4)[0] == lo) {
if ((elements + searchIndex * 4)[1] == ordinalHigh && (elements + searchIndex * 4)[0] == ordinalLow) {
goto up;
}
if ((((ziU16)(elements + j * 4)[1] << 8) | (ziU16)(elements + j * 4)[0]) > ch) {
if ((((ziU16)(elements + searchIndex * 4)[1] << 8) | (ziU16)(elements + searchIndex * 4)[0]) > ordinal) {
return 0;
}
mid = (j + i) / 2;
if (mid == j) {
midpoint = (searchIndex + recordIndex) / 2;
if (midpoint == searchIndex) {
return 0;
}
if ((((ziU16)(elements + mid * 4)[1] << 8) | (ziU16)(elements + mid * 4)[0]) >= ch) {
i = mid;
goto hi_check;
if ((((ziU16)(elements + midpoint * 4)[1] << 8) | (ziU16)(elements + midpoint * 4)[0]) >= ordinal) {
recordIndex = midpoint;
} else {
searchIndex = midpoint;
goto search;
}
j = mid;
goto search;
hi_check:
if ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo) {
j = i;
if ((elements + recordIndex * 4)[1] == ordinalHigh && (elements + recordIndex * 4)[0] == ordinalLow) {
searchIndex = recordIndex;
goto up;
}
if ((((ziU16)(elements + i * 4)[1] << 8) | (ziU16)(elements + i * 4)[0]) < ch) {
if ((((ziU16)(elements + recordIndex * 4)[1] << 8) | (ziU16)(elements + recordIndex * 4)[0]) < ordinal) {
return 0;
}
mid = (j + i) / 2;
if (mid == j) {
midpoint = (searchIndex + recordIndex) / 2;
if (midpoint == searchIndex) {
return 0;
}
if ((((ziU16)(elements + mid * 4)[1] << 8) | (ziU16)(elements + mid * 4)[0]) >= ch) {
i = mid;
if ((((ziU16)(elements + midpoint * 4)[1] << 8) | (ziU16)(elements + midpoint * 4)[0]) >= ordinal) {
recordIndex = midpoint;
goto hi_check;
}
j = mid;
searchIndex = midpoint;
goto search;
}

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -64,6 +64,7 @@ ziU32 Zi8MatchROMdata0(ziWChar* elements, ziU8 count, ziU8 language,
key = Zi8GetTableSize(language, keyTable, ZI_WORK);
if (key != 0 && ZI_WORK->userKeys[language] == 0) {
index = 0;
/* MWCC needs the key-count branch in the loop test block. */
goto check_keys;
next_key:
{
@@ -99,7 +100,7 @@ check_keys:
searching = 1;
current = &records[context->cnt - 1];
while (searching && context->cnt != 0 && current->node != (ziU8*)context->endNode) {
if (capacity < context->cnt) goto finish_graph;
if (capacity < context->cnt) break;
current->attr = ZiDAWGgetCHARattribute(context, current->node, ZI_WORK);
if (context->cnt <= count) {
if (context->keyCodes == 0) {
@@ -117,36 +118,38 @@ check_keys:
records[context->cnt].key = 0;
}
if (prefixLength != 0 && *prefixLength < context->cnt &&
ZiDAWGgetEOWattribute(current->node) != 0) {
ZiDAWGgetEOWattribute(current->node)) {
*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 (context->cnt >= search[1]) {
if (search[0] != 0 && context->cnt > search[1]) goto next_sibling;
if (acceptPrefix != 0 || ZiDAWGgetEOWattribute(current->node)) {
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;
}
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->maxCnt < context->cnt) ZI_WORK->maxCnt = context->cnt;
goto update_current;
if (records[context->cnt].node != (ziU8*)0) {
context->cnt++;
if (ZI_WORK->maxCnt < context->cnt) ZI_WORK->maxCnt = context->cnt;
} else {
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--;
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;
}
@@ -232,7 +235,7 @@ unsigned int Zi8MatchROMdata2(ziWChar* elements, ziU8 count, ziU8 language,
if (status == 0) {
ZI_WORK->dawgGroupIndex = 0;
ZI_WORK->matchOffset = 0;
if (group != 0 && *group == 0xc && language == 10 && ZI_WORK->forceAltGraph != 0) {
if (group != 0 && *group == 0xc && language == ZI8_LANG_FI && ZI_WORK->forceAltGraph != 0) {
ZI_WORK->graphTableId = 0x10;
} else {
ZI_WORK->graphTableId = 0;
@@ -275,7 +278,7 @@ search_segment:
ZI_WORK->dawgGroupIndex++;
status = 0;
ZI_WORK->graphTableId = 0;
if (ZI_WORK->dawgCtx.key == 0 && language == 10) {
if (ZI_WORK->dawgCtx.key == 0 && language == ZI8_LANG_FI) {
for (index = 0; index < ZI_WORK->matchOffset; index++) {
switch (ZI_WORK->dawgWord[index]) {
case 0x61:
@@ -323,7 +326,7 @@ ziU32 Zi8MatchROMdata(ziWChar* elements, ziU8 count, ziU8 language,
acceptPrefix, ZI_WORK);
if ((ziU8)result != 0) break;
status = 0;
if (count <= 1 && language == 0x36) break;
if (count <= 1 && language == ZI8_LANG_SW) break;
ZI_WORK->dawgGroup = NextDawgGroup(ZI_WORK->dawgGroup, language, ZI_WORK);
}
}
@@ -380,7 +383,7 @@ void Zi8SyllablesROMdata(ziWChar *elements, ziU8 count, ziU8 language, ziWChar *
keyTable = 0x1b;
}
}
Zi8MatchROMdata0(elements,count,language & 0xff,output,capacity,1,status,graphTable,keyTable,0,(ziU8 *)prefixLength,
Zi8MatchROMdata0(elements,count,language & 0xff,output,capacity,1,status,graphTable,keyTable,0,prefixLength,
&ZI_WORK->dawgCtx,ZI_WORK->dawgSearchState,ZI_WORK);
return;
}

View File

@@ -4,7 +4,7 @@ extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU8 Zi8getKeyLayout(ziU8 lang, ziU16 key, ziWChar* layout, ziU8 mode ZI_NEED_WORK);
extern ziChar Zi8ConvertWC2UC(ziWChar ch, ziU8 language ZI_NEED_WORK);
extern ziU32 Zi8AlphaGetCandidates(ziGetParam* param, ziPtr sw ZI_NEED_WORK);
extern ziU8 Zi8SyllablesROMdata(ziWChar* keys, ziU8 count, ziU8 lang, ziWChar* out,
extern ziU8 Zi8SyllablesROMdata(ziWChar* keys, ziU8 keyCount, ziU8 lang, ziWChar* output,
ziU16 a, ziU8 b, ziU8* cntOut, ziU8 c ZI_NEED_WORK);
typedef struct _ziSwParam {
@@ -20,197 +20,191 @@ typedef struct _ziSwParam {
} ziSwParam;
ziU32 Zi8GetSyllablesCandidates(ziGetParam* param, ziSwParam* sw ZI_NEED_WORK) {
ziWChar buf[0x40];
ziWChar buf2[0x32];
ziS32 rem;
ziS32 cur;
ziS32 firstCand;
ziS32 count;
ziWChar* pNext;
ziU16 err;
ziU8 flag14;
ziU8 flag13;
ziU8 flag12;
ziU8 flag11;
ziU8 sylCnt;
ziWChar* out;
ziU8* u28;
ziS32 i;
ziWChar syllableBuffer[0x40];
ziWChar keyLayout[0x32];
ziS32 remainingCapacity;
ziS32 syllableLength;
ziS32 remainingSkip;
ziS32 candidateCount;
ziWChar* nextCharacter;
ziU16 error;
ziU8 allowHyphen;
ziU8 needKeyFallback;
ziU8 nextMatch;
ziU8 reverseOrder;
ziU8 matchedLength;
ziWChar* output;
ziU8* encodedOutput;
ziS32 index;
firstCand = param->firstCandidate;
count = 0;
u28 = 0;
pNext = 0;
flag14 = 1;
flag13 = 1;
flag12 = 0;
flag11 = 0;
sylCnt = 0;
err = 0x64;
remainingSkip = param->firstCandidate;
candidateCount = 0;
encodedOutput = 0;
nextCharacter = 0;
allowHyphen = 1;
needKeyFallback = 1;
nextMatch = 0;
reverseOrder = 0;
matchedLength = 0;
error = 0x64;
if (param->currentWord != 0 && param->wordCharCount != 0 &&
param->currentWord[param->wordCharCount - 1] != 0x20) {
flag11 = 1;
reverseOrder = 1;
}
if (param->elementCount == 0 || (param->elementCount == 1 && flag11 == 0)) {
count = Zi8AlphaGetCandidates(param, sw, ZI_WORK);
if (param->elementCount == 0 || (param->elementCount == 1 && reverseOrder == 0)) {
candidateCount = Zi8AlphaGetCandidates(param, sw, ZI_WORK);
goto end;
}
if (sw->countOnly != 0 || (param->getOptions & 0xFD) != 0x81) {
out = buf;
rem = 0x40;
output = syllableBuffer;
remainingCapacity = 0x40;
} else {
out = (ziWChar*)param->candidates;
rem = sw->capacity - 1;
output = param->candidates;
remainingCapacity = sw->capacity - 1;
}
if ((param->getOptions & 0xFD) == 0x80) {
u28 = (ziU8*)param->candidates;
rem = sw->capacity - 1;
encodedOutput = (ziU8*)param->candidates;
remainingCapacity = sw->capacity - 1;
}
if (rem <= param->elementCount) {
err = 0x168;
if (remainingCapacity <= param->elementCount) {
error = 0x168;
goto end;
}
if ((Zi8GetTableCount(param->language, 0x1F, ZI_WORK) & 8) != 0) {
flag14 = 0;
allowHyphen = 0;
}
if (param->elements[0] == 0xEFF1 && param->elementCount > 1 && flag14 != 0) {
buf[0] = 0x2D;
if (param->elements[0] == 0xEFF1 && param->elementCount > 1 && allowHyphen != 0) {
syllableBuffer[0] = 0x2D;
} else {
Zi8getKeyLayout(param->language, param->elements[0], buf, 1, ZI_WORK);
Zi8getKeyLayout(param->language, param->elements[0], syllableBuffer, 1, ZI_WORK);
}
out[0] = buf[0];
Zi8SyllablesROMdata(param->elements, param->elementCount, param->language, out,
(ziU16)rem, 0, &sylCnt, flag11, ZI_WORK);
if (sylCnt != 0) {
cur = sylCnt;
output[0] = syllableBuffer[0];
Zi8SyllablesROMdata(param->elements, param->elementCount, param->language, output,
(ziU16)remainingCapacity, 0, &matchedLength, reverseOrder, ZI_WORK);
if (matchedLength != 0) {
syllableLength = matchedLength;
} else {
cur = 1;
syllableLength = 1;
}
if (cur == param->elementCount) goto L5dc;
if (firstCand != 0) {
firstCand--;
goto L5dc;
}
if (sw->countOnly != 0) {
if (++count >= sw->maxCount) goto end;
goto L5dc;
}
for (i = cur; i < param->elementCount; i += sylCnt) {
if (param->elements[i] == 0xEFF1 && param->elementCount - i > 1 && flag14 != 0) {
buf2[0] = 0x2D;
if (syllableLength != param->elementCount) {
if (remainingSkip != 0) {
remainingSkip--;
} else if (sw->countOnly != 0) {
if (++candidateCount >= sw->maxCount) goto end;
} else {
Zi8getKeyLayout(param->language, param->elements[i], buf2, 1, ZI_WORK);
}
out[i] = buf2[0];
Zi8SyllablesROMdata(param->elements + i, param->elementCount - i, param->language,
out + i, (ziU16)rem, 0, &sylCnt, 1, ZI_WORK);
if (sylCnt == 0) {
sylCnt = 1;
}
}
if (u28 != 0) {
for (i = 0; i < param->elementCount; i++) {
u28[i] = Zi8ConvertWC2UC(out[i], param->language, ZI_WORK);
}
u28[i++] = 0;
u28[i] = 0;
u28 += i;
} else {
out[i++] = 0;
out[i] = 0;
out += i;
}
rem -= i;
if (++count >= param->maxCandidates) goto end;
if (rem > param->elementCount) goto L5dc;
goto end;
L5dc:
while (cur >= 1) {
flag12 = 0;
goto rom;
found:
flag12 = 1;
if (cur == 1) {
flag13 = 0;
}
L464:
if (out[0] >= 0xEFF1 && out[0] <= 0xF010) {
goto dec;
}
L464b:
if (firstCand != 0) {
firstCand--;
goto L560;
}
if (sw->countOnly != 0) {
if (++count >= sw->maxCount) goto end;
goto L560;
}
if (u28 != 0) {
for (i = 0; i < cur; i++) {
u28[i] = Zi8ConvertWC2UC(out[i], param->language, ZI_WORK);
for (index = syllableLength; index < param->elementCount; index += matchedLength) {
if (param->elements[index] == 0xEFF1 && param->elementCount - index > 1 && allowHyphen != 0) {
keyLayout[0] = 0x2D;
} else {
Zi8getKeyLayout(param->language, param->elements[index], keyLayout, 1, ZI_WORK);
}
output[index] = keyLayout[0];
Zi8SyllablesROMdata(param->elements + index, param->elementCount - index, param->language,
output + index, (ziU16)remainingCapacity, 0, &matchedLength, 1, ZI_WORK);
if (matchedLength == 0) {
matchedLength = 1;
}
}
u28[i++] = 0;
u28[i] = 0;
u28 += i;
} else {
i = cur;
out[i++] = 0;
out[i] = 0;
out += i;
if (encodedOutput != 0) {
for (index = 0; index < param->elementCount; index++) {
encodedOutput[index] = Zi8ConvertWC2UC(output[index], param->language, ZI_WORK);
}
encodedOutput[index++] = 0;
encodedOutput[index] = 0;
encodedOutput += index;
} else {
output[index++] = 0;
output[index] = 0;
output += index;
}
remainingCapacity -= index;
if (++candidateCount >= param->maxCandidates) goto end;
/* MWCC needs the forward capacity branch before the common exit. */
if (remainingCapacity > param->elementCount) goto search_syllables;
goto end;
}
rem -= i;
if (++count >= param->maxCandidates) goto end;
if (rem <= cur) goto end;
L560:
if (pNext != 0) {
if (*pNext == 0) goto end;
out[0] = *pNext++;
goto L464b;
}
rom:
if (Zi8SyllablesROMdata(param->elements, (ziU8)cur, param->language, out,
(ziU16)rem, flag12, 0, flag11, ZI_WORK) != 0) {
goto found;
}
dec:
cur--;
}
if (flag13 == 0) goto end;
if (param->elements[0] == 0xEFF1 && param->elementCount > 1 && flag14 != 0) {
buf2[0] = 0x2D;
buf2[1] = 0;
Zi8getKeyLayout(param->language, param->elements[0], &buf2[1], 1, ZI_WORK);
for (i = 1; buf2[i] != 0; i++) {
if (buf2[i] == 0x2D) break;
search_syllables:
for (; syllableLength >= 1; syllableLength--) {
nextMatch = 0;
goto match_syllable;
syllable_found:
nextMatch = 1;
if (syllableLength == 1) {
needKeyFallback = 0;
}
while (buf2[i] != 0) {
buf2[i] = buf2[i + 1];
i++;
if (output[0] >= 0xEFF1 && output[0] <= 0xF010) {
continue;
}
emit_syllable:
if (remainingSkip != 0) {
remainingSkip--;
} else if (sw->countOnly != 0) {
if (++candidateCount >= sw->maxCount) goto end;
} else {
if (encodedOutput != 0) {
for (index = 0; index < syllableLength; index++) {
encodedOutput[index] = Zi8ConvertWC2UC(output[index], param->language, ZI_WORK);
}
encodedOutput[index++] = 0;
encodedOutput[index] = 0;
encodedOutput += index;
} else {
index = syllableLength;
output[index++] = 0;
output[index] = 0;
output += index;
}
remainingCapacity -= index;
if (++candidateCount >= param->maxCandidates) goto end;
if (remainingCapacity <= syllableLength) goto end;
}
next_syllable:
if (nextCharacter != 0) {
if (*nextCharacter == 0) goto end;
output[0] = *nextCharacter++;
goto emit_syllable;
}
match_syllable:
if (Zi8SyllablesROMdata(param->elements, (ziU8)syllableLength, param->language, output,
(ziU16)remainingCapacity, nextMatch, 0, reverseOrder, ZI_WORK) != 0) {
goto syllable_found;
}
} else {
Zi8getKeyLayout(param->language, param->elements[0], buf2, 1, ZI_WORK);
}
cur = 1;
pNext = buf2;
goto L560;
if (needKeyFallback != 0) {
if (param->elements[0] == 0xEFF1 && param->elementCount > 1 && allowHyphen != 0) {
keyLayout[0] = 0x2D;
keyLayout[1] = 0;
Zi8getKeyLayout(param->language, param->elements[0], &keyLayout[1], 1, ZI_WORK);
for (index = 1; keyLayout[index] != 0; index++) {
if (keyLayout[index] == 0x2D) break;
}
while (keyLayout[index] != 0) {
keyLayout[index] = keyLayout[index + 1];
index++;
}
} else {
Zi8getKeyLayout(param->language, param->elements[0], keyLayout, 1, ZI_WORK);
}
syllableLength = 1;
nextCharacter = keyLayout;
goto next_syllable;
}
end:
if (sw->countOnly != 0) {
param->letters = 0;
} else {
param->letters = (ziU8)count;
param->letters = (ziU8)candidateCount;
}
Zi8LogError(err, ZI_WORK);
return count;
Zi8LogError(error, ZI_WORK);
return candidateCount;
}

View File

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

View File

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

View File

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

View File

@@ -108,23 +108,21 @@ ziBool Zi8ExactMatchNextChar(ziU8* node, ziU8 firstByteMask, ziU8 firstByteValue
return 0;
}
ziU32 Zi8SecMatchChar(ziPtr nodeAddress, ziU8* dictionaryAddress, ziMatchParam* match, ziU16* code ZI_NEED_WORK) {
ziU32 Zi8SecMatchChar(ziU8* 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;
ziU16 targetCode;
ziU8 dataIndex;
ziU8 remaining;
if (match->componentIndex != 0) {
state.targetCode = match->componentIndex;
matchCode = ((ziU16)(((ziU8*)nodeAddress)[4] & 3) << 8) | ((ziU8*)nodeAddress)[5];
targetCode = match->componentIndex;
matchCode = ((ziU16)(nodeAddress[4] & 3) << 8) | nodeAddress[5];
value = 0;
while (value++ < 6) {
if (state.targetCode == matchCode) {
if (targetCode == matchCode) {
break;
}
matchCode = ((ziU16)(*(dictionaryAddress + matchCode * 8 + 6) & 3) << 8) | *(dictionaryAddress + matchCode * 8 + 7);
@@ -132,13 +130,13 @@ ziU32 Zi8SecMatchChar(ziPtr nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
break;
}
}
if (state.targetCode != matchCode) {
if (targetCode != matchCode) {
return 0;
}
}
data = (ziU8*)Zi8GetTableAddress(1, 1, ZI_WORK);
data += ((ziU8*)nodeAddress)[0xB] + (((ziU8*)nodeAddress)[0xA] << 8) + ((((ziU8*)nodeAddress)[9] & 0xF) << 16);
data = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH, 1, ZI_WORK);
data += nodeAddress[0xB] + (nodeAddress[0xA] << 8) + ((nodeAddress[9] & 0xF) << 16);
if (ZI_WORK->cangjieEnabled != 0) {
switch (data[0] & 7) {
case 2:
@@ -168,27 +166,27 @@ ziU32 Zi8SecMatchChar(ziPtr nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
isPartial = 1;
}
} else if ((match->length & 1) != 0) {
if ((((ziU8*)nodeAddress)[match->length >> 1] & 0xF) == 0xF) {
if ((nodeAddress[match->length >> 1] & 0xF) == 0xF) {
isPartial = 1;
}
} else {
if ((((ziU8*)nodeAddress)[match->length >> 1] & 0xF0) == 0xF0) {
if ((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)) {
if (((nodeAddress[(match->length - 1) >> 1] & 0xF0) == 0) || ((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)) {
if (((nodeAddress[(match->length - 1) >> 1] & 0xF) == 0) || ((nodeAddress[(match->length - 1) >> 1] & 0xF) == 0xF)) {
return 0;
}
}
}
if (code != 0) {
*code = ((ziU16)((ziU8*)nodeAddress)[6] << 8) + (ziU16)((ziU8*)nodeAddress)[7];
*code = ((ziU16)nodeAddress[6] << 8) + (ziU16)nodeAddress[7];
}
if (isPartial) {
return 2;
@@ -206,9 +204,9 @@ ziU32 Zi8SecMatchChar(ziPtr nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
}
}
state.dataIndex = 4;
state.remaining = ((match->length + 1) >> 1) - 4;
if (((ziU8)value + 1) < (int)state.remaining) {
dataIndex = 4;
remaining = ((match->length + 1) >> 1) - 4;
if ((value + 1) < remaining) {
return 0;
}
if ((match->length & 1) != 0) {
@@ -221,17 +219,17 @@ ziU32 Zi8SecMatchChar(ziPtr nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
}
}
if (match->count == 0) {
while (state.remaining != 0) {
if ((data[0] & match->recordMasks[state.dataIndex]) != match->recordValues[state.dataIndex]) {
while (remaining != 0) {
if ((data[0] & match->recordMasks[dataIndex]) != match->recordValues[dataIndex]) {
return 0;
}
state.dataIndex++;
state.remaining--;
dataIndex++;
remaining--;
data++;
}
}
if (code != 0) {
*code = ((ziU16)((ziU8*)nodeAddress)[6] << 8) + (ziU16)((ziU8*)nodeAddress)[7];
*code = ((ziU16)nodeAddress[6] << 8) + (ziU16)nodeAddress[7];
}
if (isPartial) {
return 2;
@@ -254,20 +252,20 @@ ziBool Zi8PriMatchNextComp(ziU8* node, ziU8 firstByteMask, ziU8 firstByteValue,
return 0;
}
ziBool Zi8SecMatchComp(ziPtr nodeAddress, ziMatchParam* matchAddress, ziPtr dictionaryAddress ZI_NEED_WORK) {
ziBool Zi8SecMatchComp(ziU8* nodeAddress, ziMatchParam* matchAddress, ziU8* dictionaryAddress ZI_NEED_WORK) {
int chainIndex;
ziU16 matchCode;
ziU16 targetCode;
if (matchAddress->componentIndex != 0) {
targetCode = matchAddress->componentIndex;
matchCode = ((ziU16)(((ziU8*)nodeAddress)[6] & 3) << 8) | ((ziU8*)nodeAddress)[7];
matchCode = ((ziU16)(nodeAddress[6] & 3) << 8) | 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);
matchCode = ((ziU16)(*(dictionaryAddress + matchCode * 8 + 6) & 3) << 8) | *(dictionaryAddress + matchCode * 8 + 7);
if (matchCode == 0) {
break;
}
@@ -277,10 +275,10 @@ ziBool Zi8SecMatchComp(ziPtr nodeAddress, ziMatchParam* matchAddress, ziPtr dict
}
}
if (matchAddress->length > 8) {
if ((int)((ziU8*)nodeAddress)[5] < (int)(matchAddress->length - 2)) {
if (nodeAddress[5] < (matchAddress->length - 2)) {
return 0;
}
} else if ((int)((ziU8*)nodeAddress)[5] < (int)(matchAddress->length - 1)) {
} else if (nodeAddress[5] < (matchAddress->length - 1)) {
return 0;
}
return 1;
@@ -289,18 +287,16 @@ ziBool Zi8SecMatchComp(ziPtr nodeAddress, ziMatchParam* matchAddress, ziPtr dict
extern ziU16 Zi8MatchAltSound(ziPtr soundTable, ziU16 soundCode, ziPtr pCodeTable, ziU16 index, ziU16 mask, ziU16 value, ziU8 flag ZI_NEED_WORK);
ziU16 Zi8GetPCode(ziU8* table, ziU8* node);
ziBool Zi8MatchPhonetic(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;
ziBool Zi8MatchPhonetic(ziU8* pCodeTable, ziU8* dictionary, ziPtr soundTable, ziU16 soundCode, ziU32 tableAddress, ziU8* node, ziU16* masks, ziU16* values, ziU16* count, ziU8** resultNode, ziU8** stringOffset, ziU8 partialMode, ziU8 strictMode, ziU8 numParts, ziU16 partMask, ziU16 partValue, ziU8 flag, ziU8 altMode, ziU16 initialCode, ziU16* resultCode, ziU8 lastMode ZI_NEED_WORK) {
ziU16 code;
ziU16 remaining;
ziU16 soundIndex;
ziU16 dictionaryIndex;
ziU8 matchedParts;
ziU8 nextCode;
ziU8 partCount;
ziU8 partIndex;
ziBool hasString;
ziU8* sound;
typedef struct {
ziU8 header;
@@ -308,42 +304,42 @@ ziBool Zi8MatchPhonetic(ziPtr pCodeTable, ziU8* dictionary, ziPtr soundTable, zi
} DictionaryNode;
if (*stringOffset != 0) {
traversal.hasString = 1;
hasString = 1;
} else {
traversal.hasString = 0;
hasString = 0;
}
if (*count != 0) {
traversal.remaining = *count;
remaining = *count;
} else {
traversal.remaining = 1;
remaining = 1;
}
traversal.matchedParts = 0;
matchedParts = 0;
if ((lastMode != 0) && (numParts > 1)) {
altMode = 1;
}
while (traversal.remaining-- != 0) {
if ((node[0] & flag) != 0) goto decode_node;
while (remaining-- != 0) {
if ((node[0] & flag) == 0) {
next_node:
node += 0xC;
continue;
decode_node:
traversal.code = Zi8GetPCode((ziU8*)pCodeTable, node);
if ((*values != (traversal.code & *masks)) && (altMode == 0) && ((node[0] & 0x80) != 0)) {
node += 0xC;
continue;
}
code = Zi8GetPCode(pCodeTable, node);
if ((*values != (code & *masks)) && (altMode == 0) && ((node[0] & 0x80) != 0)) {
if (*count != 0) {
traversal.soundIndex = (initialCode - traversal.remaining) - 1;
soundIndex = (initialCode - remaining) - 1;
} else {
traversal.soundIndex = initialCode;
soundIndex = initialCode;
}
traversal.code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, traversal.soundIndex, *masks, *values, flag, ZI_WORK);
code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, soundIndex, *masks, *values, flag, ZI_WORK);
}
goto check_code;
match_code:
if (partValue == (traversal.code & partMask)) goto next_node;
traversal.matchedParts = 1;
if (partValue == (code & partMask)) goto next_node;
matchedParts = 1;
if (*count != 0) {
traversal.soundIndex = (initialCode - traversal.remaining) - 1;
soundIndex = (initialCode - remaining) - 1;
} else {
traversal.soundIndex = initialCode;
soundIndex = initialCode;
}
sound = (ziU8*)(tableAddress + ((node[9] & 0xF) * 0x10000 + (node[0xB] + node[0xA] * 0x100)));
if (ZI_WORK->cangjieEnabled != 0) {
@@ -368,46 +364,46 @@ match_code:
} else if (numParts > 1) {
goto next_node;
}
if (((ziU8)traversal.matchedParts == numParts) || (numParts == 0)) {
if (((ziU8)matchedParts == numParts) || (numParts == 0)) {
*resultNode = node;
*resultCode = ((ziU16)node[6] << 8) + node[7];
*count = traversal.remaining;
*count = remaining;
return 1;
}
/* MWCC needs the group-end branch before the backward group jump. */
next_group:
{
traversal.nextCode = *sound++;
traversal.partCount = traversal.nextCode & 0xF;
if ((traversal.nextCode & flag) == 0) {
for (; traversal.partCount != 0; traversal.partCount--) {
nextCode = *sound++;
partCount = nextCode & 0xF;
if ((nextCode & flag) == 0) {
for (; partCount != 0; 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;
for (; partCount != 0; partCount--) {
partIndex = 1;
if (hasString && (sound > *stringOffset)) {
hasString = 0;
}
if (!traversal.hasString) {
if (!hasString) {
*stringOffset = sound;
}
do {
traversal.dictionaryIndex = sound[0] | ((ziU16)sound[1] << 8);
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;
if (!hasString) {
code = Zi8GetPCode(pCodeTable, dictionary + (dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode));
if (((code & masks[partIndex]) != values[partIndex]) && (altMode == 0) && (dictionary[(dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode)] & 0x80) != 0) {
code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, dictionaryIndex & 0x7FFF, masks[partIndex], values[partIndex], flag, ZI_WORK);
}
if ((code & masks[partIndex]) == values[partIndex]) {
goto phonetic_matched;
}
}
phonetic_skip:
if ((traversal.dictionaryIndex & 0x8000) == 0) {
if ((dictionaryIndex & 0x8000) == 0) {
sound++;
while ((*sound & 0x80) == 0) {
sound += 2;
@@ -416,23 +412,23 @@ phonetic_skip:
}
break;
phonetic_matched:
if (++traversal.partIndex == numParts) {
if (++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;
if (strictMode == 0 && (dictionaryIndex & 0x8000) != 0) goto phonetic_skip;
if (strictMode != 0 && (dictionaryIndex & 0x8000) == 0) goto phonetic_skip;
}
*resultNode = node;
*resultCode = ((ziU16)node[6] << 8) + node[7];
*count = traversal.remaining;
*count = remaining;
return 1;
}
} while ((traversal.dictionaryIndex & 0x8000) == 0);
} while ((dictionaryIndex & 0x8000) == 0);
}
}
if ((traversal.nextCode & 0x80) != 0) goto next_node;
if ((nextCode & 0x80) != 0) goto next_node;
goto next_group;
check_code:
if (*values == (traversal.code & *masks)) goto match_code;
if (*values == (code & *masks)) goto match_code;
goto next_node;
}
return 0;
@@ -483,17 +479,14 @@ ziU8 Zi8GetPyPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final, z
initial[outputIndex] = 0;
final[outputIndex] = 0;
value = *current;
if (value < 0x61) {
goto check_pinyin_extension;
if (value >= 0x61) {
if (value <= 0x7A) {
goto pinyin_ascii;
}
}
if (value <= 0x7A) {
goto pinyin_ascii;
if (value >= 0xF361) {
if (value <= 0xF37A) goto pinyin_extension;
}
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;
@@ -524,23 +517,23 @@ pinyin_initial:
final[outputIndex] &= 0xfdff;
}
value = *current;
if (value != 0x68 && value != 0xF368) goto scan_final;
if (outputIndex == 0) {
*resultCount += 1;
if (value == 0x68 || value == 0xF368) {
if (outputIndex == 0) {
*resultCount += 1;
}
final[outputIndex] += 0x200;
*bestInitial = initial[0];
*bestFinal = final[0];
count--;
if (count == 0) {
break;
}
current += 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;
@@ -552,45 +545,45 @@ scan_final:
if (index != 0) {
partial = 1;
}
goto finish_final;
break;
}
if ((value >= 0xF331) && (value < 0xF336)) {
if (index != 0) {
partial = 1;
}
goto finish_final;
break;
}
if ((value < 0x61) || (value > 0x7A)) {
if (value < 0xF361) {
goto finish_final;
break;
}
value -= 0xF361;
if (value > 0x19) {
if (outputIndex == 0) {
*resultCount += 1;
}
goto finish_final;
break;
}
} else {
value -= 0x61;
}
pinyin[index] = (ziU8)value + 1;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) == 0) goto try_final_extension;
if (outputIndex == 0) {
*resultCount += 1;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (outputIndex == 0) {
*resultCount += 1;
}
current++;
index++;
count--;
if (count == 0) {
break;
}
continue;
}
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 (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (outputIndex == 0) {
*resultCount += 1;
}
@@ -612,19 +605,21 @@ try_final_extension:
}
}
finish_final:
if ((index > 3) && (count != 0) && (((value = *current) == 0x27) || (value == 0xF360) || (value == 0x20))) {
if (outputIndex == 0) {
*resultCount += 1;
if (index > 3 && count != 0) {
value = *current;
if (value == 0x27 || value == 0xF360 || value == 0x20) {
if (outputIndex == 0) {
*resultCount += 1;
}
current++;
count--;
}
current++;
count--;
}
if (index > 3) {
partial = 1;
}
if (partial && alternateInitial == 0) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
@@ -641,7 +636,7 @@ finish_final:
}
} else {
pinyin[index] = 0xFF;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
@@ -653,7 +648,7 @@ finish_final:
*bestFinal = final[0];
if ((outputIndex == 0) && (count == 0)) {
pinyin[index] = 0;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (convertedCount == 0) {
*bestInitial = 0x7E00;
*bestFinal = 0x200;
@@ -664,7 +659,7 @@ finish_final:
}
} else {
pinyin[index] = 0;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
@@ -685,23 +680,29 @@ finish_final:
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))) {
} else if (value >= 0xF331) {
value -= 0xF331;
if (value <= 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;
if (value == 0x27 || value == 0xF360 || value == 0x20) {
count--;
current++;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
}
}
}
}
}
@@ -711,33 +712,26 @@ finish_final:
*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;
while (row < 0x36) {
while (index < 4) {
if (pinyin[index] != Zi8PinyinFinals[row][index]) {
break;
}
index++;
}
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;
if (index >= 4) {
*initial = Zi8PinyinFinals[row][4];
*final = Zi8PinyinFinals[row][5];
return 1;
}
row++;
index = 0;
}
return 0;
}
@@ -791,52 +785,43 @@ ziU8 Zi8GetBpmfPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final,
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++;
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
goto after_bpmf_initial;
bpmf_value_23:
*final |= 0x100;
*initial |= 0x180;
resultCount++;
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
goto after_bpmf_initial;
bpmf_value_24:
*final |= 0x180;
*initial |= 0x180;
resultCount++;
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
goto after_bpmf_initial;
set_bpmf_initial:
if ((*text < 0xF331) || (*text > 0xF335)) {
*final |= 0x80;
*initial |= 0x180;
resultCount++;
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
break;
case 0x23:
*final |= 0x100;
*initial |= 0x180;
resultCount++;
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
break;
case 0x24:
*final |= 0x180;
*initial |= 0x180;
resultCount++;
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
break;
default:
if ((*text < 0xF331) || (*text > 0xF335)) {
*initial |= 0x180;
}
}
after_bpmf_initial:
value = *text - 0xF305;
if ((value > 0x14) && (value < 0x22)) {

View File

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

View File

@@ -57,6 +57,7 @@ ziU8 ZADP_Zi8SetPDremoveOpt(ziU8 option, struct __zi8_work_data_s* __zi8_work_da
return previous;
}
ziU8 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziWChar* spelling, ziU16 spellingCapacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
// MWCC needs this aggregate to retain the unread workspace store at SP+0x24.
struct {
int fallback;
ziPtr workspace;
@@ -77,7 +78,7 @@ ziU8 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar*
Zi8LogError(0x4B0, __zi8_work_data);
return 0;
}
if (language == 1) {
if (language == ZI8_LANG_ZH) {
length *= 2;
}
if (continuation == 0) {
@@ -106,7 +107,7 @@ ziU8 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar*
while ((ziS32)ZI_WORK->pudWordIndex < (ziS32)ZI_WORK->pudWordCount) {
wordSize = *word++;
entrySize = wordSize;
if (language == 1) {
if (language == ZI8_LANG_ZH) {
if (ZI_WORK->zhPudMinPrefix > *word) goto next;
wordSize--;
entrySize--;
@@ -118,7 +119,7 @@ next:
ZI_WORK->pudWordIndex++;
word += entrySize;
} else {
if (language == 1) {
if (language == ZI8_LANG_ZH) {
bytePattern = (ziU8*)pattern;
for (index = 0; index < length; index++) {
if (word[index] != bytePattern[index]) goto next;
@@ -143,7 +144,7 @@ matched:
else *output = Zi8ConvertWC2Key(*pattern, language, __zi8_work_data);
return 1;
}
if (language == 1) {
if (language == ZI8_LANG_ZH) {
byteOutput = (ziU8*)output;
for (index = copied = 0; index < (ziS32)wordSize && copied < capacity; copied++) {
byteOutput[index] = word[index];

View File

@@ -76,18 +76,16 @@ ziU8 Zi8ZHaddSpace(ziWChar* src, ziU8 count, ziWChar* dst,
i = 2;
}
if (i-- > m) {
goto fail;
if (i-- <= m) {
for (k = 0; k < i; k++) {
pdst[k] = psrc[k];
}
pdst[k] = 0;
Zi8LogError(0x64, ZI_WORK);
return 1;
}
for (k = 0; k < i; k++) {
pdst[k] = psrc[k];
}
pdst[k] = 0;
Zi8LogError(0x64, ZI_WORK);
return 1;
fail:
if ((ziU8)count >= (ziU16)maxLen) {
if (count >= maxLen) {
count = (ziU8)(maxLen - 1);
}
for (i = 0; i < count; i++) {

View File

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

View File

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

View File

@@ -23,35 +23,33 @@ ziU8 Zi8LookupKoreanChar(ziWChar character, ziU8* result, ziU16* index, ziPtr wo
return 0;
}
ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, ziPtr workData);
ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, struct __zi8_work_data_s* 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;
struct __zi8_work_data_s* workData) {
ziU8* table1;
ziU8* table2;
ziU8* table31;
ziU16 tableCount0;
ziU16 tableCount3;
ziU16 tableCount6;
ziU16 tableCount31;
ziU16 nextIndex;
ziU16 inputIndex;
ziU16 currentCandidate;
ziU16 index;
ziU8 elementIndex;
ziU8 matched;
ziU8 characterIndex;
ziU16 buffer[100];
ziU8 result;
ziU16 currentCharacter;
ziU8* selectedTable;
state.nextIndex = 0;
nextIndex = 0;
result = 0;
state.characterIndex = 0xFF;
state.currentCandidate = params->firstCandidate;
characterIndex = 0xFF;
currentCandidate = params->firstCandidate;
params->letters = params->completion = params->count = 0;
if ((argument != 0) && (*argument != 0)) {
Zi8LogError(0x7D0, workData);
@@ -63,31 +61,31 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
}
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);
table1 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 1, workData);
table2 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 2, workData);
table31 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x31, workData);
tableCount0 = Zi8GetTableCount(ZI8_LANG_KO, 0, workData);
tableCount3 = Zi8GetTableCount(ZI8_LANG_KO, 3, workData);
tableCount6 = Zi8GetTableCount(ZI8_LANG_KO, 6, workData);
tableCount31 = Zi8GetTableCount(ZI8_LANG_KO, 0x31, workData);
for (state.elementIndex = 0; state.elementIndex < params->elementCount;
state.elementIndex++) {
currentCharacter = params->elements[state.elementIndex];
for (elementIndex = 0; elementIndex < params->elementCount;
elementIndex++) {
currentCharacter = params->elements[elementIndex];
if ((currentCharacter >= 0x61) && (currentCharacter <= 0x7A)) {
buffer[state.elementIndex] = state.table1[(currentCharacter - 0x61) * 2];
buffer[elementIndex] = table1[(currentCharacter - 0x61) * 2];
} else if ((currentCharacter >= 0x41) && (currentCharacter <= 0x5A)) {
buffer[state.elementIndex] = (state.table1 + (currentCharacter - 0x41) * 2)[1];
buffer[elementIndex] = (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;
matched = 0;
for (; table2[matched * 3] != 0; matched++) {
if (currentCharacter == table2[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];
if (table2[matched * 3] != 0) {
buffer[elementIndex] =
((ziU16)(table2 + matched * 3)[1] << 8) |
(table2 + matched * 3)[2];
} else {
Zi8LogError(0x161, workData);
return 0;
@@ -96,16 +94,16 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
}
result = 0;
for (currentCharacter = 0; currentCharacter < state.elementIndex; currentCharacter++) {
if (Zi8LookupKoreanChar(buffer[currentCharacter], &state.characterIndex,
&state.inputIndex, workData) != 0) {
state.matched = Zi8MatchKoreanSequence(&state.nextIndex,
for (currentCharacter = 0; currentCharacter < elementIndex; currentCharacter++) {
if (Zi8LookupKoreanChar(buffer[currentCharacter], &characterIndex,
&inputIndex, workData) != 0) {
matched = Zi8MatchKoreanSequence(&nextIndex,
buffer + currentCharacter + 1,
state.characterIndex,
(state.elementIndex - currentCharacter) - 1,
characterIndex,
(elementIndex - currentCharacter) - 1,
workData);
if ((((struct __zi8_work_data_s*)workData)->koAltTables == 1)) {
switch (state.characterIndex) {
if (workData->koAltTables == 1) {
switch (characterIndex) {
case 1:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1E, workData);
break;
@@ -168,59 +166,59 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
}
}
} else {
state.matched = 0;
matched = 0;
}
if (state.matched != 0) {
if (state.tableCount6 == 0) {
state.nextIndex += state.inputIndex * state.tableCount3;
if (matched != 0) {
if (tableCount6 == 0) {
nextIndex += inputIndex * tableCount3;
}
if (state.currentCandidate != 0) {
state.currentCandidate--;
if (currentCandidate != 0) {
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)->koAltTables == 0)) {
params->candidates[(ziU8)result] += state.inputIndex * state.tableCount3;
params->candidates[result] =
((ziU16)selectedTable[nextIndex * 2] << 8) | (selectedTable + nextIndex * 2)[1];
if ((tableCount6 != 0) && (workData->koAltTables == 0)) {
params->candidates[result] += inputIndex * tableCount3;
}
result++;
}
if (currentCharacter == 0) {
params->completion = state.matched + 1;
params->completion = matched + 1;
}
currentCharacter += state.matched;
currentCharacter += 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 (currentCandidate != 0) {
index = 0;
for (; index < tableCount31; index++) {
if (table31[index * 3] == buffer[currentCharacter] &&
(table31 + index * 3)[1] == buffer[currentCharacter + 1]) break;
}
if (state.index == state.tableCount31) {
state.currentCandidate--;
if (index == tableCount31) {
currentCandidate--;
}
if (currentCharacter == 0) {
params->completion = 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])) {
for (index = 0; index < tableCount31; index++) {
if ((table31[(index * 3)] == buffer[currentCharacter]) &&
((table31 + index * 3)[1] == buffer[currentCharacter + 1])) {
if (currentCharacter == 0) {
params->completion = 1;
}
params->candidates[(ziU8)result] =
state.tableCount0 + (state.table31 + state.index * 3)[2];
params->candidates[result] =
tableCount0 + (table31 + index * 3)[2];
result++;
currentCharacter++;
break;
}
}
if (state.index == state.tableCount31) {
if ((params->candidates[(ziU8)result] = buffer[currentCharacter]) < 0xFF) {
if (index == tableCount31) {
if ((params->candidates[result] = buffer[currentCharacter]) < 0xFF) {
if (currentCharacter == 0) {
params->completion = 1;
}
params->candidates[(ziU8)result] += state.tableCount0;
params->candidates[result] += tableCount0;
result++;
}
}
@@ -235,7 +233,7 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
return result;
}
ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, ziPtr workData) {
ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, struct __zi8_work_data_s* workData) {
ziU16 nestedScratch;
ziU16 nestedIndexStorage;
ziU16 index1;
@@ -249,7 +247,7 @@ ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 c
firstCharacter = input[0];
mappedCharacter = 0xFF;
if (((struct __zi8_work_data_s*)workData)->koAltTables == 0) {
if (workData->koAltTables == 0) {
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 3, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 3, workData);
} else {

View File

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

View File

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

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