Compare commits

...

104 Commits

Author SHA1 Message Date
coah
7b219624bc decomp(fat): separate existing and new SD initialization 2026-10-03 02:39:16 -05:00
coah
93e97b7ff1 decomp(bs2): restore disk-presence read before cover reset (#1077) 2026-10-03 02:37:39 -05:00
coah
d170fbb804 decomp(jpeg): refine RGBA420 local declaration order (#1076) 2026-10-03 02:25:22 -05:00
coah
f710d11ff5 decomp(jpeg): refine RGB565420 edge declaration order (#1075) 2026-10-03 02:22:07 -05:00
coah
84d0c74f0a decomp(keyboard): refine existing animation local order (#1074) 2026-10-03 02:06:49 -05:00
coah
bdac66bb07 match(tiCellPhone 84/86) (ult22b) (worker 96a80226) (#1073) 2026-10-03 02:01:40 -05:00
coah
6f96cb5274 decomp(md5): refine verified local declaration order (#1072) 2026-10-03 01:57:35 -05:00
coah
4aafd41e10 link(zi8pud2): mark as Matching (worker 2d8a2a2f) (#1071) 2026-10-03 01:48:17 -05:00
coah
83efd95924 match(zi8pud2 7/7) (ult25) (worker c7cdef3d) (#1070) 2026-10-03 01:46:52 -05:00
coah
43375de179 match(NWC24Download 29/30) (ult20b) (worker 8e26eab8) (#1069) 2026-10-03 01:41:07 -05:00
coah
a4d145c010 match(MemoryCardManager 19/26, tiInputForm 217/221) (ult22) (worker 3363cfb8) (#1068) 2026-10-03 01:30:03 -05:00
coah
e0d3ef0345 match(NWC24Download 28/30) (ult20) (worker 2146dd8f) (#1067) 2026-10-03 01:22:23 -05:00
coah
32be36cb4e decomp(sd-select): align the traversal title declaration lifetime (#1066) 2026-10-03 01:16:20 -05:00
coah
1b5b2da635 decomp(keyboard): group the animation traversal declarations (#1065) 2026-10-03 01:16:15 -05:00
coah
36cbab079f decomp(fat): align MBR traversal declarations (#1064) 2026-10-03 01:15:49 -05:00
coah
b7a06e9d82 decomp(nhttp): distinguish raw token bytes from signed folds (#1063) 2026-10-03 01:03:31 -05:00
coah
b7d9c4fb65 match(ATERM 17/26) (ult15) (worker c46e48b5) (#1062) 2026-10-03 01:01:35 -05:00
coah
e3095dfb97 decomp(jpeg): scope RGB565420 edge pixel values (#1061) 2026-10-03 00:54:15 -05:00
coah
f5a929c9d7 decomp(keyboard): express literal input through an output builder (#1060) 2026-10-03 00:54:10 -05:00
coah
a41f565889 decomp(card): scope the permission-check result (#1059) 2026-10-03 00:52:05 -05:00
coah
d54f8be29a decomp(nwc24): scope writable task validation (#1058) 2026-10-03 00:51:39 -05:00
coah
81ba279958 decomp(fat): clarify reserved-sector initialization success path (#1057) 2026-10-03 00:43:53 -05:00
coah
57ccda3883 fix(chans): assemble integer immediates without signed-shift overflow (#1056) 2026-10-03 00:27:04 -05:00
coah
fd49a94c00 decomp(sd-memory): reconstruct transfer-title scalar lifetimes (#1055) 2026-10-03 00:26:58 -05:00
coah
55ff13a222 decomp(md5): express sequential word consumption (#1054) 2026-10-03 00:26:52 -05:00
coah
d3f5682bc0 link(NWC24DateParser): mark as Matching (worker 566803d4) (#1053) 2026-10-03 00:21:36 -05:00
coah
404a8675f1 refactor(kpad): initialize rotation matrix through its global array (#1051) 2026-10-03 00:20:18 -05:00
coah
878fda2a94 match(NWC24DateParser 8/8) (perm8d) (worker 42a119d6) (#1052) 2026-10-03 00:19:25 -05:00
coah
9131f07806 fix(chans): use the boolean helper's scalar output contract (#1050) 2026-10-03 00:15:35 -05:00
coah
a3e3725c1f match(zi8match 9/10) (ult8) (worker 3f8379ba) (#1049) 2026-10-03 00:08:56 -05:00
coah
fc114afd44 fix(chans): preserve wrapped hex-count rounding without signed overflow (#1048) 2026-10-03 00:01:49 -05:00
coah
409ef82dd8 fix(ezitext): restore Chinese user-dictionary address contract (#1046) 2026-10-02 23:55:35 -05:00
coah
98d8a5220f match(pdm_partition 19/20) (perm8c) (worker 1bb708e7) (#1047) 2026-10-02 23:54:05 -05:00
coah
bb93f1dd8e match(KPAD 28/29) (perm7c) (worker d199502a) (#1045) 2026-10-02 23:52:36 -05:00
coah
140117ea91 fix(keyboard): declare KPRPutChar byte return (#1044) 2026-10-02 23:49:22 -05:00
coah
e58cd9e734 fix(card): match the OS thread entry parameter contract (#1043) 2026-10-02 23:46:07 -05:00
coah
a30b5cecb6 match(NHTTP_stdlib 12/14, NWC24Download 27/30) (perm2b) (worker 26173bfd) (#1042) 2026-10-02 23:44:03 -05:00
coah
5dcbc4372f fix(ezitext): restore version query workspace formals (#1040) 2026-10-02 23:38:24 -05:00
coah
98239e660a match(iplSDChannelSelect 123/129) (ult3) (worker 938cccae) (#1041) 2026-10-02 23:36:12 -05:00
coah
be7ded2fdc match(Texture_MCUtoRGB565 7/13) (tex1) (worker 1a706bf6) (#1039) 2026-10-02 23:26:08 -05:00
coah
fdd68ddd30 fix(aoss): restore WLAN arguments and complete key bounds (#1038) 2026-10-02 23:18:15 -05:00
coah
74dcb16a50 fix(bs2): preserve unsigned local DVD callback contract (#1037) 2026-10-02 23:05:56 -05:00
coah
7c582f0e41 link(FAAttach): mark as Matching (worker 23024341) (#1036) 2026-10-02 23:03:05 -05:00
coah
333eea81e9 match(iplSetting 111/112) (gk1) (worker 9f73134e) (#1035) 2026-10-02 22:57:26 -05:00
coah
a791e598a1 match(iplAddress 98/101) (gk3) (worker 34504409) (#1034) 2026-10-02 22:47:46 -05:00
coah
7654dc33e1 match(NWC24DateParser 7/8) (perm8b) (worker 48b04748) (#1033) 2026-10-02 22:39:49 -05:00
coah
9c7d87ab00 fix(ezitext): recover options receiver and workspace contracts (#1032) 2026-10-02 22:29:31 -05:00
coah
885cdfeee6 fix(fa): align attach adapter pointer contracts (#1031) 2026-10-02 22:22:46 -05:00
coah
cc94a7530c fix(aoss): match scan result output slot contract (#1030) 2026-10-02 22:16:11 -05:00
coah
82da7899a1 fix(fa): preserve the USB disk receiver and match FAAttach (#1029) 2026-10-02 22:14:03 -05:00
coah
bf8ebfa353 fix(chans): declare HMAC helpers with external linkage (#1028) 2026-10-02 21:55:22 -05:00
coah
7649d9b1ec fix(cdb): correct crypt-buffer ownership slot types (#1027) 2026-10-02 21:51:37 -05:00
coah
ce2130f867 fix(ezitext): correct conversion table address return contract (#1026) 2026-10-02 21:49:30 -05:00
coah
20ba34a80f fix(odh): represent Huffman trees as halfword nodes (#1025) 2026-10-02 21:32:37 -05:00
coah
634d8ab6a1 decomp(ezitext): pair current and best phonetic restoration (#1024) 2026-10-02 21:29:22 -05:00
coah
a5e49ea578 decomp(ezitext): recover PUD byte contracts and packed header decoding (#1023) 2026-10-02 21:26:06 -05:00
coah
5e0816c3f1 fix(chansvm): compare parsed indices without signed shift overflow (#1022) 2026-10-02 21:16:47 -05:00
coah
5d7760d341 fix(ezitext): reconcile one-key caller and parameter contracts (#1021) 2026-10-02 21:13:10 -05:00
coah
a894ff5cb7 decomp(aes): recover decrypt final-round dependency tree (#1020) 2026-10-02 21:08:24 -05:00
coah
adea4fb5d1 tools: audit direct call destinations against original DOL (#1019) 2026-10-02 21:05:09 -05:00
coah
e221614209 fix(keyboard): recover original cursor query evaluation order (#1018) 2026-10-02 21:01:53 -05:00
coah
6619098ea7 decomp(kpad): preserve read refinements alongside exact DPD math (#1014) 2026-10-02 20:58:37 -05:00
coah
e9c8986139 link(NWC24MsgSubject) (worker 4edf8de1) (#1017) 2026-10-02 20:42:12 -05:00
coah
b9bda11dea match(NWC24MsgSubject 12/12) (perm8) (worker af25492d) (#1016) 2026-10-02 20:39:46 -05:00
coah
7b8dbf2c96 fix(keyboard): declare cellphone reset on its owning class (#1015) 2026-10-02 20:32:23 -05:00
coah
b7a4105bd6 match(address): reconstruct nullable drag text measurement (#1013) 2026-10-02 20:31:57 -05:00
coah
bc2b18090b match(KPAD 26/29) (perm7, permuter) (worker 7dd8a460) (#1012) 2026-10-02 20:15:24 -05:00
coah
674722c158 decomp(sd): recover scissor projection expressions (#1011) 2026-10-02 20:08:42 -05:00
coah
e81aed2882 fix(sd): restore event metadata predicates (#1010) 2026-10-02 20:08:15 -05:00
coah
7d6057adf6 decomp: reconstruct AddressEdit balloon construction (#1009) 2026-10-02 19:54:25 -05:00
coah
16a170f944 decomp: restore Korean scan entry and lookup widths (#1008) 2026-10-02 19:53:58 -05:00
coah
0904bf9161 match(CHANSVm 222/233) (big1c) (worker bb2bb6af) (#1007) 2026-10-02 19:47:59 -05:00
coah
e5987de5ad fix(nwc24): use a defined unsigned retry mask (#1006) 2026-10-02 19:43:11 -05:00
coah
11bd51b3a9 fix(keyboard): use bounded OEM dictionary accessor (#1005) 2026-10-02 19:42:46 -05:00
coah
e4a9449256 decomp(keyboard): reconstruct candidate animation descriptor lifetimes (#1004) 2026-10-02 19:33:27 -05:00
coah
b940710632 decomp: align Bopomofo consumed-count return contract (#1003) 2026-10-02 19:25:17 -05:00
coah
1fa33882ae decomp(inputform): recover pane lookup and animation slot flow (#1002) 2026-10-02 19:15:58 -05:00
coah
aba50ea278 decomp: recover AOSS initialization guards and request lifetimes (#1001) 2026-10-02 19:15:32 -05:00
coah
14a8b23adb decomp: correct Chinese phonetic contracts and Zhuyin dispatch (#1000) 2026-10-02 19:07:43 -05:00
coah
b8931fae6f decomp: recover card rename retry reset boundary (#999) 2026-10-02 19:07:35 -05:00
coah
bcac23375a decomp(keyboard): correct prediction refresh and character flow (#998) 2026-10-02 19:07:28 -05:00
coah
ed49ada973 decomp: recover ATERM digest and payload lifetimes (#997) 2026-10-02 19:07:02 -05:00
coah
fa0cb9b7b4 decomp(nhttp): recover token loop and Base64 byte flow (#996) 2026-10-02 18:51:40 -05:00
coah
8ffaa9d25a decomp(bs2): preserve update publications and repeated entry reads (#995) 2026-10-02 18:49:17 -05:00
coah
cc812ad30e ci: live README progress badges from a progress-data branch (#994)
The README progress table only changed when a landing commit rewrote it, so
merges outside land.sh left it stale, and the decomp.dev badges showed
upstream's numbers. The progress workflow now publishes shields.io endpoint
JSON to an orphan progress-data branch (one force-pushed commit), so the
badges refresh on every push to main without extra commits on main.
The build badge now points at the workflow that actually builds (Build is
disabled: it needs upstream's private container).
2026-10-02 18:47:05 -05:00
coah
3d3448e3a8 decomp(kbd): reconstruct asynchronous LED dispatch and completion (#993) 2026-10-02 18:42:29 -05:00
coah
654c65dd27 decomp: align EXIF rational denominator address structure (#992) 2026-10-02 18:37:40 -05:00
coah
bb93684b95 decomp: reconstruct alpha boundary and output expressions (#991) 2026-10-02 18:37:35 -05:00
coah
39648c8aa6 decomp(aes): reconstruct final-round word dependencies (#990) 2026-10-02 18:37:29 -05:00
coah
230c3af28f decomp: recover typed partition word decoding (#989) 2026-10-02 18:37:04 -05:00
coah
13881c99fb match(kbd): reconstruct synchronous LED command reservation (#988) 2026-10-02 18:29:15 -05:00
coah
b26e248bb0 decomp: reconstruct BS2 partition and banner paths (#987) 2026-10-02 18:12:23 -05:00
coah
8350f2b4df decomp: recover EXIF entry aliasing and tag semantics (#986) 2026-10-02 18:11:57 -05:00
coah
3851d2cc74 decomp: reconstruct one-key phonetic and result widths (#985) 2026-10-02 18:10:11 -05:00
coah
7bdf4629fd decomp: refine AES table and inverse-key XOR dependencies (#984) 2026-10-02 18:09:45 -05:00
coah
5a222cdec4 match(fa): pfd_sddrv_get_total_sectors byte-identical (#983)
Fold the (max_multiplier - 9) shift count back into max_multiplier so the literal 1 stays in r0 and the count is an in-place clrlwi on r3.
2026-10-02 17:55:54 -05:00
coah
ac8d46d231 fix: model Run stack address independently of printf (#982) 2026-10-02 17:49:33 -05:00
coah
813660b96e match(iplSetting): Setting::draw byte-identical (#980)
draw is 632/632 against retail. The TU stays NonMatching, so the DOL is unchanged.
2026-10-02 17:36:11 -05:00
coah
e82417345a decomp: refine JPEG butterfly and color source structure (#978) 2026-10-02 17:32:07 -05:00
coah
230c2f8d34 decomp: reconstruct typed CHANSVm operands (#977) 2026-10-02 17:31:41 -05:00
coah
524350ed8f decomp: reconstruct alpha output and dictionary scan (#976) 2026-10-02 17:31:14 -05:00
coah
c62453dac9 decomp: recover ESMisc ticket scratch lifetime and cleanup flow (#975) 2026-10-02 17:30:27 -05:00
coah
6b17698b84 match(odh): cdj_c_colorConv byte-identical (#974)
Pad with a named remainder and declare sourceStride after rowIndex so cbPlane stays r22 and the stride stays r29. decompressLoop is unchanged.
2026-10-02 17:28:16 -05:00
devin-ai-integration[bot]
f9358f6e46 Decode BS2Mach Run asm + nup dead-static fossil (stays NonMatching) (#973)
* decomp: BS2Mach Run asm + CoverBlock/state decodes; nup dead-static fossil

- BS2Mach::Run: retail zeroes r0-r31 and installs a custom stack
  (__pformatter+640) before the dcbz/dcbf flush loop and tail jump —
  inexpressible in C, so asm with the exact retail sequence.
- BS2StartGCGame: CoverBlock.state direct member read (orig inlined
  DVDGetCommandBlockStatus accessor).
- BS2StateMachine: GamePartition!=0 polarity fold.
- nup.cpp __nupOp: 'static u32 lo' dead static reproduces orig's second
  .sbss word (orig .sbss=8: rvThread$2389 + 4B dead static).

Verified vs main: BS2Mach 25/29 fns byte-exact, nup 20/23 + .sbss 8=8.
Units stay NonMatching. Full build + DOL sha1 verified.

Co-authored-by: coah80 <usernamecole7@gmail.com>
Co-Authored-By: wch <usernamecole7@gmail.com>

* decomp: drop dead 'static u32 lo' padding from __nupOp

Per review: the extra .sbss word is a padding object — no relocation
references it, and nup data is already exact without it. Left unowned
for the linking pass.

Co-Authored-By: wch <usernamecole7@gmail.com>

---------

Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: coah80 <usernamecole7@gmail.com>
2026-10-02 17:26:43 -05:00
145 changed files with 17943 additions and 1032 deletions

View File

@@ -2,8 +2,8 @@ name: README progress
# runs on the self-hosted runner on cole's server so it doesn't use hosted minutes.
# only push/schedule/manual triggers, never pull_request, so fork PRs can't reach this machine.
# README progress is written inside each landing commit by the orchestrator, so this job never commits;
# it only rebuilds and publishes the current numbers to the job summary.
# it never commits to main: it rebuilds, publishes the numbers to the job summary, and force-pushes
# the README badge JSON as a single commit on the orphan progress-data branch.
on:
push:
branches: [main]
@@ -17,7 +17,7 @@ concurrency:
cancel-in-progress: true
permissions:
contents: read
contents: write
jobs:
progress:
@@ -55,3 +55,17 @@ jobs:
python3 tools/update_readme_progress.py build/43U/report.json README.md "$GITHUB_SHA"
sed -n '/progress:start/,/progress:end/p' README.md >> "$GITHUB_STEP_SUMMARY"
git checkout -- README.md
- name: Publish badges
if: github.ref == 'refs/heads/main'
run: |
out="$RUNNER_TEMP/progress-data"
rm -rf "$out"
python3 tools/progress_badges.py build/43U/report.json "$out"
cd "$out"
git init -q -b progress-data
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -q -m "progress for $GITHUB_SHA"
git push -q -f "https://x-access-token:${{ github.token }}@github.com/$GITHUB_REPOSITORY.git" HEAD:refs/heads/progress-data

View File

@@ -7,23 +7,23 @@
<!--- Github Actions Badge -->
[Build Status]: https://github.com/coah80/wii-ipl/actions/workflows/build.yml/badge.svg
[actions]: https://github.com/coah80/wii-ipl/actions/workflows/build.yml
[Build Status]: https://github.com/coah80/wii-ipl/actions/workflows/readme-progress.yml/badge.svg?branch=main
[actions]: https://github.com/coah80/wii-ipl/actions/workflows/readme-progress.yml
<!--- Discord Badge -->
[Discord Badge]: https://img.shields.io/discord/727908905392275526?color=%237289DA&logo=discord&logoColor=%23FFFFFF
[discord]: https://discord.gg/hKx3FJJgrV
<!-- Progress links -->
<!-- Progress badges: JSON on the progress-data branch, refreshed by the README progress workflow on every push to main -->
[V43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U
<!--- Version 4.3U progress Badge -->
[DecompBadgeV43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U.svg?&measure=code&label=Decompiled&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
[LinkBadgeV43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U.svg?&measure=complete_code&label=Linked&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
[FuncBadgeV43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U.svg?&measure=functions&label=Functions&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
[progress]: https://github.com/coah80/wii-ipl/actions/workflows/readme-progress.yml
[DecompiledBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Fdecompiled.json
[MatchedBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Fmatched.json
[LinkedBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Flinked.json
[DataBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Fdata.json
[FunctionsBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Ffunctions.json
[UnitsBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Funits.json
<!--- Header -->
@@ -43,28 +43,17 @@ Live decomp status
[![Build status]][actions]
Open the latest successful [Build workflow run][actions] and check its summary for the current objdiff metrics. It includes perfect-match/decompiled, fuzzy-match, fully linked, data, function, unit, and category breakdowns. The run also publishes the 43U report artifact and generated decomp-status report.
Every push to `main` rebuilds 4.3U, checks the DOL hash, and refreshes the progress badges below. Open the latest [README progress run][actions] for the full objdiff summary.
Supported versions:
- `43U` - Version **4.3U** (USA)
Progress
========
<!-- progress:start -->
| Decompiled | Matched | Linked | Data |
|:---:|:---:|:---:|:---:|
| 99.59% | 91.16% | 74.57% | 99.56% |
units 964/1027 complete, functions 12378/12563 matched.
[![DecompiledBadge]][progress] [![MatchedBadge]][progress] [![LinkedBadge]][progress] [![DataBadge]][progress]
[![FunctionsBadge]][progress] [![UnitsBadge]][progress]
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
<!-- progress:end -->
| Version | Progress |
|-----------------------|------------------------------------------------------------------------------|
| [Wii Menu 4.3U][V43U] | [![FuncBadgeV43U]][V43U] [![DecompBadgeV43U]][V43U] [![LinkBadgeV43U]][V43U] |
> You can see the full progress and its history by clicking on one of the versions in the table.
Dependencies
============

View File

@@ -37,6 +37,9 @@ force_active:
# textinput::toolbar::csPaneToAnimation points one past the end of csAninationFile.
block_relocations:
# Run establishes a fixed stack at 0x81600000, not __pformatter + 0x280.
- source: .text:0x8137B468
- source: .text:0x8137B46C
- source: .data:0x8165E15C
- source: .data:0x8165E19C

View File

@@ -879,7 +879,7 @@ config.libs = [
Object(NonMatching, "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 off"]),
Object(NonMatching, "scene/setting/ATERM.c", extra_cflags=["-O4,p", "-inline on"]),
]
),
IPLSection("settingSelect", [
@@ -997,7 +997,7 @@ config.libs = [
Object(Matching, "clib/zi8is.c"),
Object(NonMatching, "clib/zi8match.c"),
Object(Matching, "clib/zi8misc.c"),
Object(NonMatching, "clib/zi8pud2.c"),
Object(Matching, "clib/zi8pud2.c"),
Object(Matching, "clib/Zi8punct.c"),
Object(Matching, "clib/zi8space.c"),
Object(NonMatching, "clib/zi8uwd.c"),
@@ -1081,9 +1081,9 @@ config.libs = [
Object(Matching, "nwc24/NWC24Parser.c"),
Object(Matching, "nwc24/NWC24MsgCommit.c"),
Object(Matching, "nwc24/NWC24MsgRead.c"),
Object(NonMatching, "nwc24/NWC24MsgSubject.c"),
Object(Matching, "nwc24/NWC24MsgSubject.c"),
Object(Matching, "nwc24/NWC24Schedule.c"),
Object(NonMatching, "nwc24/NWC24DateParser.c"),
Object(Matching, "nwc24/NWC24DateParser.c"),
Object(Matching, "nwc24/NWC24FriendList.c"),
Object(Matching, "nwc24/NWC24SecretFList.c"),
Object(Matching, "nwc24/NWC24UserId.c"),
@@ -1826,7 +1826,7 @@ config.libs = [
Object(Matching, "fa/pfs_unmount.c"),
Object(Matching, "fa/pf_stub_unicode.c"),
Object(NonMatching, "fa/api/FAAttach.c"),
Object(Matching, "fa/api/FAAttach.c"),
Object(Matching, "fa/api/FABuffering.c"),
Object(Matching, "fa/api/FACreate.c"),
Object(Matching, "fa/api/FACreatedir.c"),

View File

@@ -24,7 +24,7 @@ typedef struct BS2UpdateHeader {
typedef struct BS2UpdateEntry {
// Update Meta Data
u32 type; // 0x00
vu32 type; // 0x00
u32 attr; // 0x04
u32 size; // 0x08
u32 depend; // 0x0C

View File

@@ -142,9 +142,6 @@ namespace textinput {
// TODO enum?
int getInputType() const;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
void resetHoldingButton();
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) && defined(TI_CELLPHONE_IMPLEMENTATION)

View File

@@ -69,6 +69,9 @@
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) override;
virtual bool updateInput(input::HKBManager& hkbManager) override;
#endif
#if defined(TI_CELLPHONE_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
void resetHoldingButton();
#endif
#ifdef TI_CELLPHONE_IMPLEMENTATION
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator) override;
@@ -95,7 +98,6 @@
virtual void changeSpaceKeyTop(const PaneNameToCharCode* keys);
void setUpperCaseJP(bool enabled);
void setLangKeyActive(bool enabled);
void resetHoldingButton();
private:
bool mbLineFeedButton;

View File

@@ -92,18 +92,20 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
dst[0] = val;
} else {
s32 oddLowSum;
s32 oddLowDifference;
s32 oddHighSum;
s32 oddHighDifference;
s32 dcValue;
t = b2 - b6;
oddLowSum = b5 + b3;
b5 = b5 - b3;
oddLowDifference = b5 - b3;
oddHighSum = b1 + b7;
b1 = b1 - b7;
oddHighDifference = b1 - b7;
u = b6 + b2;
t = t * 0xB5 >> 8;
x_factor = oddHighSum - oddLowSum;
z_factor = b5 + b1;
z_factor = oddLowDifference + oddHighDifference;
dcValue = block[0];
a = dcValue - b4;
x = x_factor * 0xB5 >> 8;
@@ -113,14 +115,14 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
z = z_factor * 0x62 >> 8;
w = d + u;
y = d - u;
m_part = b1 * 0x14E >> 8;
m_part = oddHighDifference * 0x14E >> 8;
e = a - t;
m = m_part - z;
oddLowSum += m;
n = oddHighSum + oddLowSum;
o = x + m;
dst[0] = w + n;
p_part = b5 * 0x8B;
p_part = oddLowDifference * 0x8B;
dst[7] = w - n;
p_part >>= 8;
dst[1] = v + o;

View File

@@ -3,7 +3,7 @@
#include <tmc_jpeg_internal.h>
static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData* pInfo);
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry);
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry);
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry);
static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExifInfo* info, u32 totalSize);
@@ -280,7 +280,7 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
return -161;
}
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, entries);
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (u8*)entries);
entries += 12;
}
remaining -= entriesSize;
@@ -331,19 +331,19 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
return -161;
}
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, entries);
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (u8*)entries);
entries += 12;
}
}
return 0;
}
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry) {
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry) {
s32 tag;
u16 type;
u32 type;
tag = readU16(entry, byteOrder);
type = readU16(entry + 2, byteOrder);
tag = readExifU16(entry, byteOrder);
type = readExifU16(entry + 2, byteOrder);
switch (tag) {
case 0x0103:
@@ -366,7 +366,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
pInfo->xResNum = readU32(p, byteOrder);
p = (const u8*)(pInfo->thumbnailData + offset + 4);
p = pInfo->thumbnailData + (offset + 4);
if (pInfo->thumbnailData > p) {
return;
}
@@ -386,7 +386,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
pInfo->yResNum = readU32(p, byteOrder);
p = (const u8*)(pInfo->thumbnailData + offset + 4);
p = pInfo->thumbnailData + (offset + 4);
if (pInfo->thumbnailData > p) {
return;
}
@@ -501,6 +501,10 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
case 0x8769:
case 0x9000:
case 0x9101:
case 0x011C:
case 0xA000:
case 0xA001:
case 0xA002:
case 0xA003: {
break;
}
@@ -516,7 +520,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
pInfo->xResNumIfd1 = readU32(p, byteOrder);
p = (const u8*)(pInfo->thumbnailData + offset + 4);
p = pInfo->thumbnailData + (offset + 4);
if (pInfo->thumbnailData > p) {
return;
}
@@ -538,7 +542,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
pInfo->planarConfigIfd1 = readU32(p, byteOrder);
p = (const u8*)(pInfo->thumbnailData + offset + 4);
p = pInfo->thumbnailData + (offset + 4);
if (pInfo->thumbnailData > p) {
return;
}

View File

@@ -563,26 +563,23 @@ static void TMCJPEGDEC_converterYUV420toRGB565(TMCCJPEGDecWork* work, s32 x, s32
}
static void TMCJPEGDEC_converterYUV420toRGB565edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 chromaSkip;
u16* output;
s8 crValue;
s32 yEnd;
s32 tileRow;
u8* texture;
u8* luminance;
s8* cb;
s32 width;
s8* cb;
s8 crValue;
s8* cr;
s8 cbValue;
s32 column;
s32 xEnd;
s8 cbValue;
s32 yEnd;
s32 red;
s32 blue;
u32 tileWidth;
s32 height;
TMCCJPEGDecState* state;
s32 green;
s32 lumaSkip;
s32 chromaSkip;
u32 tileWidth;
s32 redOffset;
s32 greenOffset;
s32 blueOffset;
@@ -619,16 +616,18 @@ static void TMCJPEGDEC_converterYUV420toRGB565edge(TMCCJPEGDecWork* work, s32 x,
greenOffset = -(cbValue * 88 + crValue * 183) >> 8;
blueOffset = (cbValue * 454) >> 8;
}
blue = *luminance++;
red = blue + redOffset;
green = blue + greenOffset;
blue = blue + blueOffset;
if ((blue | red | green) >> 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;
{
s32 value = *luminance++;
s32 red = value + redOffset;
s32 blue = value + blueOffset;
s32 green = value + greenOffset;
if ((blue | red | green) >> 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;
}
output[(column & 3) + (((column >> 2) + tileRow) << 4)] = ((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
output[(column & 3) + (((column >> 2) + tileRow) << 4)] = ((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
luminance += lumaSkip;
if (y & 1) {
@@ -816,15 +815,11 @@ static void TMCJPEGDEC_converterYUV444toRGB565(TMCCJPEGDecWork* work, s32 x, s32
u8* luminance;
u8* cb;
u8* cr;
s32 value;
s32 column;
s32 xEnd;
s32 cbValue;
s32 yEnd;
u32 tileWidth;
s32 green;
s32 blue;
s32 red;
s32 height;
luminance = work->convBuf + 4;
@@ -844,17 +839,19 @@ static void TMCJPEGDEC_converterYUV444toRGB565(TMCCJPEGDecWork* work, s32 x, s32
for (column = x; column < xEnd; column++) {
cbValue = (s8)*cb++;
crValue = (s8)*cr++;
value = *luminance++;
green = value + (-(cbValue * 88 + crValue * 183) >> 8);
red = value + ((crValue * 359) >> 8);
blue = value + ((cbValue * 454) >> 8);
if ((blue | green | red) >> 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;
{
s32 value = *luminance++;
s32 green = value + (-(cbValue * 88 + crValue * 183) >> 8);
s32 red = value + ((crValue * 359) >> 8);
s32 blue = value + ((cbValue * 454) >> 8);
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;
}
output[(column & 3) + (((column >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + (((red & 0xF8) << 8) + ((green & 0xFC) << 3));
}
output[(column & 3) + (((column >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
luminance += rowSkip;
cb += rowSkip;

View File

@@ -517,9 +517,9 @@ static void TMCJPEGDEC_converterYUV422toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
}
static void TMCJPEGDEC_converterYUV420toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 tileRow;
s8 crValue;
s32 chromaSkip;
s8 crValue;
s32 tileRow;
u8* luminance;
TMCCJPEGDecState* state;
u8* texture;
@@ -528,15 +528,15 @@ static void TMCJPEGDEC_converterYUV420toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
s32 green;
s32 blue;
s32 lumaSkip;
s32 yEnd;
s32 xEnd;
u8* cb;
u8* cr;
s32 value;
s32 column;
u8* cr;
s32 greenOffset;
s32 xEnd;
s32 yEnd;
s32 tileWidth;
s32 redOffset;
u8* cb;
s32 greenOffset;
u16* output;
s32 blueOffset;
s32 red;
@@ -656,10 +656,10 @@ static void TMCJPEGDEC_converterYUV420toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
blueOffset = (cbValue * 454) >> 8;
}
{
s32 value = *luminance++;
s32 green = value + greenOffset;
s32 red = value + redOffset;
s32 blue = value + blueOffset;
s32 red = *luminance++;
s32 green = red + greenOffset;
s32 blue = red + blueOffset;
red = red + redOffset;
if ((green | red | blue) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;

View File

@@ -1,5 +1,20 @@
#include <zi8clib/zitypes.h>
typedef struct {
ziU8 countOnly;
ziU8 maxWordLength;
ziU8 lookupMode;
ziU8 suffixOnly;
ziU8 controls[8];
ziU32 maxCount;
ziU16 capacity;
ziU8 minWordLength;
ziU8 flags;
ziU16 candidateCapacity;
ziU8 checkOnly;
ziU8 reserved;
} ZiCandidateOptions;
const ziWChar Zi8PunctTable[40] = {
0xFF0C, 0x3002, 0x3001, 0xFF1A, 0xFF1F, 0xFF01, 0x3005, 0x2026,
0x2015, 0xFF1B, 0xFF0E, 0x30FB, 0x201C, 0x201D, 0xFF08, 0xFF09,
@@ -8,8 +23,8 @@ const ziWChar Zi8PunctTable[40] = {
0xFFE1, 0x20AC, 0x203B, 0xFF20, 0x0000,
};
ziS32 Zi8Punctuation(ziGetParam* param ZI_NEED_WORK) {
ziS32 limit = ((ziU16*)__zi8_work_data)[8] - 1;
ziU32 Zi8Punctuation(ziGetParam* param, ziPtr options ZI_NEED_WORK) {
ziS32 limit = ((ZiCandidateOptions*)options)->capacity - 1;
ziS32 count = 0;
ziU8 i = 0;
ziU16 fc = param->firstCandidate;
@@ -21,7 +36,7 @@ ziS32 Zi8Punctuation(ziGetParam* param ZI_NEED_WORK) {
}
if (fc == 0) {
count++;
if (ZI_WORK->getcPhase == 0) {
if (((ZiCandidateOptions*)options)->countOnly == 0) {
param->candidates[i++] = Zi8PunctTable[j];
if ((param->context & 0x10) != 0) {
param->candidates[i++] = 0x20;
@@ -33,7 +48,7 @@ ziS32 Zi8Punctuation(ziGetParam* param ZI_NEED_WORK) {
break;
}
} else {
if (count >= (ziS32)ZI_WORK->targetCount) {
if (count >= (ziS32)((ZiCandidateOptions*)options)->maxCount) {
return count;
}
}
@@ -42,7 +57,7 @@ ziS32 Zi8Punctuation(ziGetParam* param ZI_NEED_WORK) {
}
j++;
}
if (ZI_WORK->getcPhase == 0) {
if (((ZiCandidateOptions*)options)->countOnly == 0) {
param->letters = count;
}
return count;

View File

@@ -23,7 +23,7 @@ typedef struct ziConversionTable {
} ziConversionTable;
const ziConversionTables Zi8CvrtTables = {0};
ziU16 Zi8GetTableCount(ziU8, ziU8 ZI_NEED_WORK);
ziPtr Zi8GetTableAddress(ziU8, ziU8 ZI_NEED_WORK);
ziU32 Zi8GetTableAddress(ziU8, ziU8 ZI_NEED_WORK);
ziWChar Zi8ConvertUC2UserKey(ziChar, ziU8 ZI_NEED_WORK);
ziWChar Zi8ConvertUC2WC(ziChar character, ziU8 language ZI_NEED_WORK) {
@@ -37,7 +37,7 @@ ziWChar Zi8ConvertUC2WC(ziChar character, ziU8 language ZI_NEED_WORK) {
return 0;
}
if (Zi8GetTableCount(language, 6, __zi8_work_data) != 0) {
table = Zi8GetTableAddress(language, 6, __zi8_work_data);
table = (ziU8*)Zi8GetTableAddress(language, 6, __zi8_work_data);
if (table == 0) {
Zi8LogError(0x6A4, __zi8_work_data);
return 0;
@@ -77,7 +77,7 @@ ziChar Zi8ConvertWC2UC(ziWChar character, ziU8 language ZI_NEED_WORK) {
return 0;
}
if (Zi8GetTableCount(language, 7, __zi8_work_data) != 0) {
table = Zi8GetTableAddress(language, 7, __zi8_work_data);
table = (ziConversionTable*)Zi8GetTableAddress(language, 7, __zi8_work_data);
if (table == 0) {
Zi8LogError(0x6AE, __zi8_work_data);
return 0;
@@ -137,7 +137,7 @@ ziWChar Zi8ConvertUC2Key(ziChar character, ziU8 language ZI_NEED_WORK) {
if (ZI_WORK->userKeys[language] != 0)
return Zi8ConvertUC2UserKey(character, language, __zi8_work_data);
if (Zi8GetTableCount(language, 8, __zi8_work_data) != 0) {
table = Zi8GetTableAddress(language, 8, __zi8_work_data);
table = (ziConversionTable*)Zi8GetTableAddress(language, 8, __zi8_work_data);
if (table == 0) {
Zi8LogError(0x6B8, __zi8_work_data);
return 0;

View File

@@ -15,28 +15,6 @@ typedef struct {
typedef struct { ziU8 keyLow; ziU8 keyHigh; ziU8 code; ziU8 flags; } Zi8AltSoundRecord;
typedef struct {
ziU8 language;
ziU8 getMode;
ziU8 subLanguage;
ziU8 context;
ziU8 getOptions;
ziWChar* elements;
ziU8 elementCount;
ziWChar* currentWord;
ziU8 wordCharCount;
ziWChar* candidates;
ziU8 maxCandidates;
ziU16 firstCandidate;
ziU8 wordCandidates;
ziU8 count;
ziU8 letters;
ziU8* scratch;
ziPtr workspace;
} Zi8OneKeyParam;
typedef struct {
ziU8 countOnly;
ziU8 maxSpellingLength;
@@ -203,15 +181,15 @@ const ziWChar zi8PYfinalSpelling[64][4] = {
const unsigned long long Zi8SOpinyinArray = 0x0303010705000000ULL;
extern Zi8UInt Zi8Ord2Ord(ziU16, ziPtr);
extern ziU16 Zi8Ord2Ord(ziU16, ziPtr);
extern ziU8 Zi8LangSupported(ziU8, ziPtr);
extern ziU16 Zi8GetTableCount(ziU8,ziU8,ziPtr);
extern Zi8UInt Zi8GetTableAddress(ziU8,ziU8,ziPtr);
extern void Zi8Memset();
extern int _Zi8GetCandidates();
extern void Zi8InitDupWordBuf();
extern ziU16 Zi8GetPInfo(ziU16,ziWChar *,ziU8,ziPtr);
extern ziU16 Zi8GetZInfo(ziU16,ziWChar *,ziU8,ziPtr);
extern ziU32 Zi8GetTableAddress(ziU8,ziU8,ziPtr);
extern void Zi8Memset(ziU8*,ziU32,ziS32);
extern ziU8 _Zi8GetCandidates(ziGetParam*,ziPtr);
extern void Zi8InitDupWordBuf(ziPtr);
extern ziU32 Zi8GetPInfo(ziU32,ziWChar *,ziU8,ziPtr);
extern ziU32 Zi8GetZInfo(ziU32,ziWChar *,ziU8,ziPtr);
extern ziBool Zi8IsDupWordW(ziWChar *,ziU8,ziPtr);
extern ziU8 Zi8GetFormatVersion(ziU8,ziPtr);
extern ziU16 Zi8Uni2Ord(ziWChar,ziPtr);
@@ -219,10 +197,10 @@ extern ziU16 Zi8GetPCode(ziU8 *,ziU8 *);
extern ziU8 Zi8MatchOEMdata(ziWChar *,ziU8,ziU8,ziWChar *,ziU16,ziU8,ziU8,ziPtr);
extern ziU8 Zi8MatchPUDdata(ziWChar *,ziU8,ziU8,ziWChar *,ziU16,ziU8,ziU8,ziPtr);
extern ziWChar Zi8Ord2Uni(ziU16,ziPtr);
extern Zi8UInt Zi8GetZHuwdPtr(ziU8 **,ziU16 *,ziPtr);
extern int Zi8GetPyPhonetic();
extern ziU8 Zi8GetBpmfPhonetic();
extern int _Zi8CheckCandidates();
extern ziU32 Zi8GetZHuwdPtr(ziU32*,ziU16*,ziPtr);
extern ziU8 Zi8GetPyPhonetic(ziWChar*,ziU8,ziU16*,ziU16*,ziU8*,ziU16*,ziU16*,ziPtr);
extern ziU8 Zi8GetBpmfPhonetic(ziWChar*,ziU8,ziU16*,ziU16*,ziU16*,ziU16*,ziPtr);
extern ziU8 _Zi8CheckCandidates(ziGetParam*,ziPtr);
Zi8UInt Zi8SpellingZY(ziU16 *output,Zi8UInt key,ziU8 includeTone)
{
@@ -311,21 +289,21 @@ Zi8UInt Zi8SpellingPY(ziU16 *output,Zi8UInt key,ziU8 includeTone)
return length;
}
ziU8 Zi8IsMatch1Key(ziU16 *input,Zi8UInt inputLength,Zi8UInt key,ziU8 requireFull,ziU8 usePinyin,ziU8 tone)
ziU8 Zi8IsMatch1Key(ziU16 *input,Zi8UInt inputLength,ziU16 key,ziU8 requireFull,ziU8 usePinyin,ziU8 tone)
{
ziU16 spelling[16];
Zi8UInt spellingLength;
if ((key & 0xffff) == 0) {
if (key == 0) {
return 0;
}
if ((inputLength & 0xff) == 0) {
return 1;
}
if (usePinyin != 0) {
spellingLength = Zi8SpellingPY(spelling,key & 0xffff,tone & 0xff);
spellingLength = Zi8SpellingPY(spelling,key,tone & 0xff);
} else {
spellingLength = Zi8SpellingZY(spelling,key & 0xffff,tone & 0xff);
spellingLength = Zi8SpellingZY(spelling,key,tone & 0xff);
}
if ((requireFull != 0) && ((inputLength & 0xff) != (spellingLength & 0xff))) {
return 0;
@@ -462,15 +440,15 @@ BACKWARD_SEARCH:
goto BINARY_SEARCH;
}
}
static Zi8UInt Zi8SetFindCand(ziU8 *foundCandidates,Zi8UInt ordinal,ziPtr work)
static Zi8UInt Zi8SetFindCand(ziU8 *foundCandidates,ziU16 ordinal,ziPtr work)
{
Zi8UInt result;
ordinal = Zi8Ord2Ord(ordinal,work);
result = (ziU8)((1 << ((int)(ordinal & 0xffff) % 8)) &
foundCandidates[(int)(ordinal & 0xffff) / 8]);
foundCandidates[(int)(ordinal & 0xffff) / 8] |=
1 << ((int)(ordinal & 0xffff) % 8);
result = (ziU8)((1 << ((int)ordinal % 8)) &
foundCandidates[(int)ordinal / 8]);
foundCandidates[(int)ordinal / 8] |=
1 << ((int)ordinal % 8);
return result;
}
@@ -506,7 +484,7 @@ LAB_return_false:
return 0;
}
Zi8UInt Zi8Get1KeyPressSpelling(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Zi8OneKeyWork *work)
ziU32 Zi8Get1KeyPressSpelling(ziGetParam *params,Zi8OneKeyOptions *options,Zi8OneKeyWork *work)
{
ziU8 candidateCount;
ziBool exactLength;
@@ -531,18 +509,18 @@ Zi8UInt Zi8Get1KeyPressSpelling(Zi8OneKeyParam *params,Zi8OneKeyOptions *options
ziU16 *output;
ziU8 *savedSearchOrder;
ziU16 spellingBuffer[8];
Zi8OneKeyParam searchParams;
ziGetParam searchParams;
candidateCount = 0;
totalCandidates = 0;
optionsMask = params->getOptions;
params->count = 0;
params->letters = 0;
params->completion = 0;
optionsMask = optionsMask & ~0x10;
optionsMask = optionsMask & ~0x20;
optionsMask = optionsMask & ~0x40;
if (options->maxSpellingLength == '\0') {
params->count = 0;
params->letters = 0;
Zi8LogError(100,work);
return 0;
}
@@ -820,7 +798,7 @@ Zi8UInt Zi8Get1KeyPressSpelling(Zi8OneKeyParam *params,Zi8OneKeyOptions *options
savedSearchCount = work->searchOrderCount;
convertedInput = false;
savedSearchFlags = work->searchFlags;
Zi8Memset(&searchParams,0,0x2c);
Zi8Memset((ziU8*)&searchParams,0,0x2c);
searchParams.getMode = 0;
searchParams.subLanguage = 0x80;
searchParams.context = 1;
@@ -918,7 +896,7 @@ Zi8UInt Zi8Get1KeyPressSpelling(Zi8OneKeyParam *params,Zi8OneKeyOptions *options
work->searchFlags = savedSearchFlags;
work->searchOrder = savedSearchOrder;
work->searchOrderCount = savedSearchCount;
params->count = searchParams.count;
params->letters = searchParams.letters;
work->spellingOnly = 0;
if (convertedInput) {
if (params->getMode == '\x03') {
@@ -937,7 +915,7 @@ Zi8UInt Zi8Get1KeyPressSpelling(Zi8OneKeyParam *params,Zi8OneKeyOptions *options
}
}
if ((options->countOnly == '\0') && (params->getMode == '\x03')) {
for (tableIndex = 0; tableIndex < params->count;) {
for (tableIndex = 0; tableIndex < params->letters;) {
while (*output != 0) {
if (*output != 0x27) {
*output++ |= 0xf300;
@@ -1022,12 +1000,12 @@ nextSpelling:
}
}
finishSpelling:
params->count = candidateCount;
params->letters = candidateCount;
Zi8LogError(100,work);
return totalCandidates;
}
int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Zi8OneKeyWork *work)
ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8OneKeyWork *work)
{
ziU16 wordBuffer [64];
ziU16 spelling [8];
@@ -1046,7 +1024,7 @@ int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Z
ziU8 *phraseEntries;
ziU16 *currentWord;
ziU8 *entryCursor;
ziU8 *userEntries;
ziU32 userEntriesAddress;
int duplicateIndex;
ziU16 alternateCount;
ziU16 ordinalCount;
@@ -1148,8 +1126,8 @@ int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Z
}
languageMask = languageMask << 4;
remaining = params->firstCandidate;
params->count = 0;
params->letters = 0;
params->completion = 0;
inputLength = params->elementCount;
if (inputLength != 0) {
while (inputLength != 0) {
@@ -1271,7 +1249,7 @@ int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Z
tableCursor = Zi8GetTableCount(1,9,work);
}
if (8 < inputLimit) {
params->wordCandidates = 0;
params->count = 0;
goto finishCandidates;
}
for (index = 0; index < (int)(Zi8UInt)inputLimit; index++) {
@@ -1327,7 +1305,7 @@ int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Z
}
if (elementIndex == 0) continue;
if (!emitWords) {
if (trackDuplicates && Zi8SetFindCand(params->scratch,candidateOrdinal,work) != 0) continue;
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,candidateOrdinal,work) != 0) continue;
for (index = 0; index < candidateCount; index++) {
if (candidateCharacter == output[index]) break;
}
@@ -1357,7 +1335,7 @@ int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Z
output[outputIndex++] = candidateCharacter;
}
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) {
params->wordCandidates = candidateCount;
params->count = candidateCount;
goto finishCandidates;
}
} else {
@@ -1396,7 +1374,7 @@ int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Z
}
if (elementIndex == 0) continue;
if (!emitWords) {
if (trackDuplicates && Zi8SetFindCand(params->scratch,candidateOrdinal,work) != 0) continue;
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,candidateOrdinal,work) != 0) continue;
for (index = 0; index < candidateCount; index++) {
if (candidateCharacter == output[index]) break;
}
@@ -1426,7 +1404,7 @@ int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Z
output[outputIndex++] = candidateCharacter;
}
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) {
params->wordCandidates = candidateCount;
params->count = candidateCount;
goto finishCandidates;
}
} else {
@@ -1519,7 +1497,7 @@ int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Z
}
if (elementIndex == 0) goto nextPhrase;
if (!emitWords) {
if (trackDuplicates && Zi8SetFindCand(params->scratch,phraseCharacter,work) != 0) goto nextPhrase;
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,phraseCharacter,work) != 0) goto nextPhrase;
for (index = 0; index < candidateCount; index++) {
if (firstOrdinal == output[index]) goto nextPhrase;
}
@@ -1547,7 +1525,7 @@ int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Z
output[outputIndex++] = firstOrdinal;
}
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) {
params->wordCandidates = candidateCount;
params->count = candidateCount;
goto finishCandidates;
}
} else {
@@ -1568,7 +1546,7 @@ nextPhrase:
else {
finishPhrases:
if (params->wordCharCount != '\0') {
params->wordCandidates = candidateCount;
params->count = candidateCount;
}
}
if ((options->countOnly == '\0') && (tableCursor != 0)) {
@@ -1601,7 +1579,7 @@ finishPhrases:
}
if (elementIndex == 0) goto nextSortedOrdinal;
if (!emitWords) {
if (trackDuplicates && Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextSortedOrdinal;
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextSortedOrdinal;
ordinal = Zi8Ord2Uni(ordinal,work);
for (index = 0; index < candidateCount; index++) {
if (ordinal == output[index]) break;
@@ -1629,11 +1607,11 @@ nextSortedOrdinal:
;
}
}
if ((options->countOnly == '\0') && Zi8GetZHuwdPtr(&userEntries,&userCount,work) != 0)
if ((options->countOnly == '\0') && (ziU8)Zi8GetZHuwdPtr(&userEntriesAddress,&userCount,work) != 0)
{
for (phraseOrdinal = 0; phraseOrdinal < userCount;) {
if ((params->elementCount == '\0') || ((userEntries[1] & 0x80) != 0)) {
userOrdinal = (userEntries[1] & 0x7f) << 8 | (ziU16)userEntries[2];
if ((params->elementCount == '\0') || ((((ziU8*)userEntriesAddress)[1] & 0x80) != 0)) {
userOrdinal = (ziU16)(((ziU8*)userEntriesAddress)[1] & 0x7f) << 8 | (ziU16)((ziU8*)userEntriesAddress)[2];
phraseTable = syllableTable + (Zi8UInt)userOrdinal * 0xc;
if (((*phraseTable & languageMask) != 0) &&
((characterSetTable == 0 || ((characterSet & characterSetTable[(Zi8UInt)userOrdinal]) != 0)))) {
@@ -1654,7 +1632,7 @@ nextSortedOrdinal:
}
if (elementIndex == 0) goto nextUserOrdinal;
if (!emitWords) {
if (trackDuplicates && Zi8SetFindCand(params->scratch,userOrdinal,work) != 0) goto nextUserOrdinal;
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;
@@ -1677,7 +1655,7 @@ nextSortedOrdinal:
}
nextUserOrdinal:
phraseOrdinal++;
userEntries = userEntries + 3;
userEntriesAddress = userEntriesAddress + 3;
}
}
phraseTable = syllableTable;
@@ -1710,7 +1688,7 @@ nextUserOrdinal:
if (unicodeCharacter == previousCharacter) goto nextOrdinal;
previousCharacter = unicodeCharacter;
if (!emitWords) {
if (trackDuplicates && Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextOrdinal;
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextOrdinal;
for (index = 0; index < candidateCount; index++) {
if (unicodeCharacter == output[index]) break;
}
@@ -1738,15 +1716,14 @@ nextOrdinal:
}
finishCandidates:
if ((emitWords) && (outputIndex != 0)) {
output[outputIndex] = 0;
outputIndex++;
output[outputIndex++] = 0;
}
params->count = candidateCount;
params->letters = candidateCount;
Zi8LogError(100,work);
return totalCandidates;
}
Zi8UInt Zi8ZHCheckSpelling(ziU16 *input,ziU16 *spelling,Zi8UInt inputLength,char *work)
ziBool Zi8ZHCheckSpelling(ziWChar *input,ziWChar *spelling,ziU8 inputLength,ziPtr work)
{
int index;
ziU8 result;
@@ -1761,11 +1738,11 @@ Zi8UInt Zi8ZHCheckSpelling(ziU16 *input,ziU16 *spelling,Zi8UInt inputLength,char
int syllableStart;
int syllableLength;
Zi8UInt tableOffset;
ziU8 candidateBuffer [32];
ziU8 phoneticCodes [32];
ziU8 phoneticMasks [32];
ziWChar candidateBuffer [16];
ziU16 phoneticCodes [16];
ziU16 phoneticMasks [16];
ziU16 convertedSpelling [64];
Zi8OneKeyParam getParam;
ziGetParam getParam;
ziU8 maskLow;
ziU8 codeLow;
ziU8 maskHigh;
@@ -1806,7 +1783,7 @@ Zi8UInt Zi8ZHCheckSpelling(ziU16 *input,ziU16 *spelling,Zi8UInt inputLength,char
}
index = 0;
syllableStart = index;
for (; index < (int)(inputLength & 0xff); index = index + 1) {
for (; index < (int)inputLength; index = index + 1) {
switch (spelling[index]) {
case 0xf331:
toneMask = 1;
@@ -1877,7 +1854,7 @@ nextInputCharacter:
}
else {
if ((input[index] == 0x27) || (input[index] == 0xf360)) {
if (index < (int)(inputLength & 0xff)) {
if (index < (int)inputLength) {
convertedSpelling[index] = input[index] = spelling[index];
}
else {
@@ -1919,7 +1896,7 @@ nextInputCharacter:
getParam.elementCount = (ziU8)index;
getParam.currentWord = 0;
getParam.wordCharCount = 0;
getParam.candidates = (ziWChar *)candidateBuffer;
getParam.candidates = candidateBuffer;
getParam.maxCandidates = 1;
getParam.firstCandidate = 0;
if ((ziU8)_Zi8CheckCandidates(&getParam,work) != 0) {

View File

@@ -920,8 +920,7 @@ selectDictionary:
if ((((wordLength == 0) && (*punctuationCursor != 0)) && (dictionaryExact != 0)) &&
((((ZiAlphaWork*)workData)->singleCharacter != 0 && (parameters->elementCount == 2)))) {
*wordCursor = ((ZiAlphaWork*)workData)->singleCharacter;
wordCursor[1] = *punctuationCursor;
punctuationCursor = punctuationCursor + 1;
wordCursor[1] = *punctuationCursor++;
wordCursor[2] = 0;
wordLength = 2;
}
@@ -1139,7 +1138,7 @@ prepareCandidate:
Zi8ChangeWordCase(wordCursor - prefixCount,language,workData);
}
if ((((ZiAlphaOptions*)optionData)->suffixOnly != '\0') &&
((int)((ZiAlphaOptions*)optionData)->maxWordLength < (int)(wordLength + prefixCount))) {
((wordLength + prefixCount) > ((ZiAlphaOptions*)optionData)->maxWordLength)) {
wordLength = ((ZiAlphaOptions*)optionData)->maxWordLength - prefixCount;
wordCursor[wordLength] = 0;
}
@@ -1208,16 +1207,14 @@ emitCandidate:
if (((ZiAlphaOptions*)optionData)->maxResults <= candidateCount) goto finishCandidates;
} else {
if (((ZiAlphaOptions*)optionData)->lookupMode != '\0') {
for (index = 0;
(index <= (int)wordLength &&
(wordCursor[index] == ((ZiAlphaOptions*)optionData)->dictionary[index]));
index = index + 1) {
for (index = 0; index <= wordLength; index++) {
if (wordCursor[index] != ((ZiAlphaOptions*)optionData)->dictionary[index]) break;
}
if ((((((ZiAlphaWork*)workData)->operation != '\0') || ((int)wordLength <= index))
if ((((((ZiAlphaWork*)workData)->operation != '\0') || (index >= wordLength))
&& ((((ZiAlphaWork*)workData)->operation == '\0' ||
((exactLengthOnly == 0 ||
((int)(ziU16)Zi8WCharCount(((ZiAlphaOptions*)optionData)->dictionary,workData) <= index)))))) &&
((exactLengthOnly != 0 || ((int)wordLength <= index)))) {
(index >= (int)(ziU16)Zi8WCharCount(((ZiAlphaOptions*)optionData)->dictionary,workData))))))) &&
((exactLengthOnly != 0 || (index >= wordLength)))) {
candidateCount = 1;
goto finishCandidates;
}
@@ -1376,27 +1373,23 @@ finishDictionaryPass:;
(((parameters->elementCount == 1 &&
(((Zi8GetTableCount(parameters->language,0x1f,workData)) & 0x40) == 0)) &&
(*parameters->elements >= 0xeff1)))))) &&
((*parameters->elements < 0xf011 &&
((*parameters->elements <= 0xf010 &&
((Zi8getKeyLayout(parameters->language,*parameters->elements,&punctuationBuffer[0],1,workData)) != '\0')))) {
punctuationCandidate = ZI8_TRUE;
}
if (((candidateCount == 0) && (punctuationCandidate)) && (firstCandidate == 0)) {
candidateCount = 1;
if ((((ZiAlphaOptions*)optionData)->countOnly == '\0') && ((parameters->getOptions & 0xfd) != 0x81)) {
*encodedOutput = 0x3e;
encodedOutput[2] = 0;
encodedOutput[1] = 0;
}
else {
if (((ZiAlphaOptions*)optionData)->countOnly != 0 || (parameters->getOptions & 0xFD) == 0x81) {
if (parameters->getMode == 1) {
*wordCursor = *elements;
} else {
*wordCursor = 0x3E;
}
else {
*wordCursor = 0x3e;
}
wordCursor[2] = 0;
wordCursor[1] = 0;
wordCursor = wordCursor + 2;
wordCursor[1] = wordCursor[2] = 0;
wordCursor += 2;
} else {
*encodedOutput = 0x3E;
encodedOutput[1] = encodedOutput[2] = 0;
}
if (((ZiAlphaOptions*)optionData)->lookupMode == '\0') {
((ZiAlphaWork*)workData)->singleCharacter = 0;
@@ -1576,17 +1569,17 @@ checkPrefixFields:
finishCandidates:
((ZiAlphaWork*)workData)->usePrefixAsElements = 0;
if (((ZiAlphaOptions*)optionData)->countOnly == '\0') {
parameters->letters = candidateCount;
if (((ZiAlphaOptions*)optionData)->countOnly != '\0') {
parameters->letters = 0;
}
else {
parameters->letters = 0;
parameters->letters = candidateCount;
}
wordCursor[-prefixCount] = 0;
if (((((ZiAlphaOptions*)optionData)->countOnly == '\0') && (((ZiAlphaOptions*)optionData)->lookupMode == '\0')) && (parameters->elementCount != 0)) {
elementIndex = parameters->elementCount - 1;
if (((primaryVowelRestriction) || (secondaryVowelRestriction)) &&
((((ZiAlphaWork*)workData)->prefixEnabled < 2 ||
((((ZiAlphaWork*)workData)->prefixEnabled <= 1 ||
(parameters->elements[elementIndex] == 0xEFF1)))) {
index = 0;
while (elementIndex >= 0) {

View File

@@ -138,11 +138,11 @@ extern ziU16 Zi8GetTableCount(ziU8 language, ziU8 table, ziPtr work);
extern ziU8 Zi8IsDupWChar(ziWChar character, ziPtr work);
extern ziU8 Zi8IsDupWordW(ziWChar* word, ziU8 length, ziPtr work);
extern ziWChar Zi8Ord2Uni(ziU16 ordinal, ziPtr work);
extern ziU8 Zi8MatchPhonetic(ziU8* phonetics, ZiChineseRecord* records,
ziPtr indexTable, ziU16 indexCount, ziPtr dictionary,
ZiChineseRecord* record, ziU16* mask, ziU16* match,
ziU16* length, ZiChineseRecord** matchedRecord,
int* matchedIndex, ziU8 wordMode, ziU8 partial,
extern ziU8 Zi8MatchPhonetic(ziPtr phonetics, ziU8* records,
ziPtr indexTable, ziU16 indexCount, ziU32 dictionary,
ziU8* record, ziU16* mask, ziU16* match,
ziU16* length, ziU8** matchedRecord,
ziU8** matchedString, ziU8 wordMode, ziU8 partial,
ziU8 oneCharacter, ziU16 excludedMask,
ziU16 excludedMatch, ziU8 charset, ziU8 options,
ziU16 ordinal, ziU16* tone, ziU8 spellingOnly,
@@ -160,7 +160,7 @@ extern const ziU8 zi8CangjieCodes[25];
extern const ziWChar ziPuncts[4];
extern const ziWChar ziTones[4];
const ziWChar zi8tones[4];
extern ziU8 Zi8GetZHuwdPtr(ziU8** entries, ziU16* count, ziPtr work);
extern ziU32 Zi8GetZHuwdPtr(ziU32* entries, ziU16* count, ziPtr work);
extern ziBool Zi8IsComponent(ziWChar character, ziPtr work);
extern ziBool Zi8IsCharacter(ziWChar character, ziPtr work);
extern ziU8 Zi8MatchOEMdata(ziWChar* currentWord, ziU8 length, ziU8 language,
@@ -199,7 +199,7 @@ static int zi8InternalGetZH(ziGetParam* request, ZiChineseOptions* options, ziPt
ziU8 matchMode;
int index;
ziWChar* currentWord;
ziU8* userEntries;
ziU32 userEntriesAddress;
ziU16 ordinalIndex;
ziU16 tableIndex;
ziU16 phraseOrdinal;
@@ -614,10 +614,10 @@ static int zi8InternalGetZH(ziGetParam* request, ZiChineseOptions* options, ziPt
case 56: case 59:
if (((ziFuzzyZYPairs*)&((struct __zi8_work_data_s*)work)->unk_0x1B2C.word)->fANDh) ordinalIndex = 0xF9FF;
break;
case 52: case 55:
case 60: case 63:
if (((ziFuzzyZYPairs*)&((struct __zi8_work_data_s*)work)->unk_0x1B2C.word)->bANDp) ordinalIndex = 0xF9FF;
break;
case 60: case 63:
case 52: case 55:
if (((ziFuzzyZYPairs*)&((struct __zi8_work_data_s*)work)->unk_0x1B2C.word)->gANDk) ordinalIndex = 0xF9FF;
break;
case 38:
@@ -1612,9 +1612,9 @@ phonetic_ordinal_search:
record = records + phraseOrdinal * 12;
candidateCount = 0;
phoneticGroups = 0;
if (!Zi8MatchPhonetic(phoneticTable, (ZiChineseRecord*)records, alternateTable, alternateCount,
phraseTable, (ZiChineseRecord*)record, match.phon, match.phon2,
&candidateCount, (ZiChineseRecord**)&record, (int*)&phoneticGroups,
if (!Zi8MatchPhonetic(phoneticTable, records, alternateTable, alternateCount,
(ziU32)phraseTable, record, match.phon, match.phon2,
&candidateCount, &record, &phoneticGroups,
0, 1, match.nCand, phoneticMask, phoneticMatch, charset, requireFull,
phraseOrdinal, &candidateOrdinal, 0, work)) continue;
if (charsetTable) {
@@ -1754,10 +1754,10 @@ tone_candidates:
user_character_search:
if (((struct __zi8_work_data_s*)work)->uwdPtrCount && (getMode != 0 || !firstPhoneticPass) &&
!options->countOnly && (match.nCand <= 1 || (getMode != 1 && getMode != 2)) &&
Zi8GetZHuwdPtr(&userEntries, &userCount, work) && (getMode != 0 || match.nSeg <= 1)) {
(ziU8)Zi8GetZHuwdPtr(&userEntriesAddress, &userCount, work) && (getMode != 0 || match.nSeg <= 1)) {
userIndex = 0;
while (userIndex < userCount) {
candidateOrdinal = (ziU16)(userEntries[1] & 0x7F) << 8 | userEntries[2];
candidateOrdinal = (ziU16)(((ziU8*)userEntriesAddress)[1] & 0x7F) << 8 | ((ziU8*)userEntriesAddress)[2];
record = records + candidateOrdinal * 12;
if (!(record[0] & charset)) goto user_character_next;
character = ((ziU16)record[6] << 8) + record[7];
@@ -1792,7 +1792,7 @@ user_character_search:
(ziU8)Zi8SecMatchChar(record, componentTable, &match, 0, work)) candidateStatus = 1;
break;
case 1: case 2:
if (request->elementCount && !(userEntries[1] & 0x80)) candidateStatus = 0;
if (request->elementCount && !(((ziU8*)userEntriesAddress)[1] & 0x80)) candidateStatus = 0;
else {
candidateStatus = (match.first & (ziU16)Zi8GetPCode(phoneticTable, record)) == match.first2;
if (!candidateStatus && (record[0] & 0x80) && !requireFull &&
@@ -1827,7 +1827,7 @@ user_character_search:
}
user_character_next:
++userIndex;
userEntries += 3;
userEntriesAddress += 3;
}
}
if (!prefixLookup) goto phonetic_alt_continue;
@@ -2323,9 +2323,9 @@ phonetic_ordinals:
candidateCount = recordCount;
phoneticGroups = 0;
while (emittedCount < request->maxCandidates && candidateCount) {
if (!Zi8MatchPhonetic(phoneticTable, (ZiChineseRecord*)records, alternateTable, alternateCount,
phraseTable, (ZiChineseRecord*)record, match.phon, match.phon2,
&candidateCount, (ZiChineseRecord**)&record, (int*)&phoneticGroups,
if (!Zi8MatchPhonetic(phoneticTable, records, alternateTable, alternateCount,
(ziU32)phraseTable, record, match.phon, match.phon2,
&candidateCount, &record, &phoneticGroups,
emitWords, singleCharacterPass, match.nCand, phoneticMask, phoneticMatch, charset,
requireFull, recordCount, &candidateOrdinal, filteringMode, work)) break;
ordinalIndex = recordCount - candidateCount - 1;
@@ -2608,10 +2608,10 @@ static int Zi8NewMatchPhonetic(ziGetParam* request, ZiChineseRecord* records,
ziU8* phonetics;
int totalResults;
int emittedCharacters;
ZiChineseRecord* matchedRecord;
ziU8* matchedRecord;
ziU8* phoneticGroups;
ziU8* candidateGroups;
int matchedIndex;
ziU8* matchedString;
int capacity;
ziU8* groupCandidates;
ziU16 phoneticCount;
@@ -2782,12 +2782,12 @@ next_group_candidate:
}
}
if (stopAfterTone) {
matchedRecord = records + character;
matchedRecord = (ziU8*)(records + character);
matchedLength = 0;
matchedIndex = 0;
if (!Zi8MatchPhonetic(phonetics, records, indexTable, indexCount,
dictionary, matchedRecord, &mask, &match,
&matchedLength, &matchedRecord, &matchedIndex,
matchedString = 0;
if (!Zi8MatchPhonetic(phonetics, (ziU8*)records, indexTable, indexCount,
(ziU32)dictionary, matchedRecord, &mask, &match,
&matchedLength, &matchedRecord, &matchedString,
wordMode, 1, 1, excludedMask, excludedMatch,
charset, request->getOptions & 0x40, character,
&matchedTone, 0, work)) {

View File

@@ -62,7 +62,7 @@ ziU8 Zi8InitializeDynamic(ziLanguageEntry* langEntries ZI_NEED_WORK) {
return 1;
}
ziU8 Zi8IsZicorpSignature(ziU16* p, ziU16 len) {
ziU8 Zi8IsZicorpSignature(ziU16* p, ziU16 len ZI_NEED_WORK) {
if ((ziU16)len > 6 && p[0] == 0x7A && p[1] == 0x69 && p[2] == 0x63 &&
p[3] == 0x6F && p[4] == 0x72 && p[5] == 0x70) {
return 1;

View File

@@ -254,7 +254,7 @@ ziBool Zi8PriMatchNextComp(ziU8* node, ziU8 mask0, ziU8 value0, ziU8 mask1, ziU8
return 0;
}
ziBool Zi8SecMatchComp(ziPtr nodeAddress, ziMatchParam* matchAddress, ziPtr dictionaryAddress) {
ziBool Zi8SecMatchComp(ziPtr nodeAddress, ziMatchParam* matchAddress, ziPtr dictionaryAddress ZI_NEED_WORK) {
int chainIndex;
ziU16 matchCode;
ziU16 targetCode;
@@ -506,7 +506,7 @@ pinyin_initial:
convertedCount = Zi8PinyinInitials[value];
if (convertedCount != 0) {
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
*resultCount += 1;
}
result++;
initial[outputIndex] = 0x7E00;
@@ -526,7 +526,7 @@ pinyin_initial:
value = *current;
if (value != 0x68 && value != 0xF368) goto scan_final;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
*resultCount += 1;
}
final[outputIndex] += 0x200;
*bestInitial = initial[0];
@@ -567,7 +567,7 @@ scan_final:
value -= 0xF361;
if (value > 0x19) {
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
*resultCount += 1;
}
goto finish_final;
}
@@ -577,7 +577,7 @@ scan_final:
pinyin[index] = (ziU8)value + 1;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) == 0) goto try_final_extension;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
*resultCount += 1;
}
current++;
index++;
@@ -592,7 +592,7 @@ try_final_extension:
pinyin[index + 1] = 0xFF;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
*resultCount += 1;
}
pinyin[index + 1] = 0;
current++;
@@ -615,7 +615,7 @@ try_final_extension:
finish_final:
if ((index > 3) && (count != 0) && (((value = *current) == 0x27) || (value == 0xF360) || (value == 0x20))) {
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
*resultCount += 1;
}
current++;
count--;
@@ -705,11 +705,10 @@ finish_final:
}
}
}
outputIndex++;
if (outputIndex > 0xf) break;
if (++outputIndex > 0xf) break;
}
if ((result > 1) && (text[*resultCount - 1] >= 0xF341) && (text[*resultCount - 1] <= 0xF35A)) {
*resultCount = *resultCount - 1;
*resultCount -= 1;
}
return result;
@@ -743,9 +742,9 @@ check_row:
return 0;
}
ziS32 Zi8GetBpmfPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final, ziU16* bestInitial, ziU16* bestFinal ZI_NEED_WORK) {
ziU8 Zi8GetBpmfPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final, ziU16* bestInitial, ziU16* bestFinal ZI_NEED_WORK) {
ziU16 value;
ziU32 resultCount = 0;
ziU8 resultCount = 0;
Zi8LogError(0x64, ZI_WORK);
if (count == 0) {

View File

@@ -17,7 +17,7 @@ typedef struct ziPudHeader {
ziU8 options[4];
ziPudSection sections[1];
} ziPudHeader;
ziU32 Zi8_8147FD7C(ziWChar*, ziU8, ziU8, ziWChar*, ziU16, ziU8, ziU8 ZI_NEED_WORK);
ziU8 Zi8_8147FD7C(ziWChar*, ziU8, ziU8, ziWChar*, ziU16, ziU8, ziU8 ZI_NEED_WORK);
ziU32 ZiIsPhoneticChar(ziWChar character) {
if ((character < 0xF305 || character > 0xF329) && (character < 0xF361 || character > 0xF37A)) return 0;
@@ -56,8 +56,11 @@ ziU8 ZADP_Zi8SetPDremoveOpt(ziU8 option, struct __zi8_work_data_s* __zi8_work_da
Zi8LogError(100, __zi8_work_data);
return previous;
}
ziU32 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziWChar* spelling, ziU16 spellingCapacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
int fallback = 0;
ziU8 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziWChar* spelling, ziU16 spellingCapacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
struct {
int fallback;
ziPtr workspace;
} match;
ziU8* bytePattern;
ziWChar folded;
ziPudSection* section;
@@ -68,6 +71,8 @@ ziU32 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar*
ziU32 entrySize;
ziPudHeader* table;
ziU8* byteOutput;
match.workspace = __zi8_work_data;
match.fallback = 0;
if (!(ZI_WORK->pudCount <= 16 && ZI_WORK->pudCount != 0 && ZI_WORK->pudTable[ZI_WORK->pudCount - 1] != 0)) {
Zi8LogError(0x4B0, __zi8_work_data);
return 0;
@@ -88,8 +93,8 @@ ziU32 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar*
Zi8LogError(0x4F6, __zi8_work_data);
return 0;
}
ZI_WORK->unk_0x314 = section->count[0] * 0x100 + section->count[1];
ZI_WORK->unk_0x310 = (ziU32)table + section->offset[0] * 0x100 + section->offset[1];
ZI_WORK->unk_0x314 = ((ziU16)section->count[0] << 8) + (ziU16)section->count[1];
ZI_WORK->unk_0x310 = (ziU32)table + (((ziU16)section->offset[0] << 8) + (ziU16)section->offset[1]);
ZI_WORK->unk_0x318 = 0;
}
for (;;) {
@@ -130,7 +135,7 @@ matchText:
}
}
matched:
if (fallback) {
if (match.fallback) {
ZI_WORK->unk_0x310 = 0;
ZI_WORK->unk_0x318 = 0;
ZI_WORK->unk_0x314 = 0;
@@ -164,7 +169,7 @@ matched:
}
if (length == 1 && complete != 0 && continuation == 0) {
complete = 0;
fallback = 1;
match.fallback = 1;
ZI_WORK->unk_0x318 = 0;
} else {
ZI_WORK->unk_0x310 = 0;
@@ -174,12 +179,12 @@ matched:
}
}
}
ziU32 Zi8MatchPUDdata(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 complete, ziU8 continuation, struct __zi8_work_data_s* __zi8_work_data) {
ziU32 result;
ziU8 Zi8MatchPUDdata(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 complete, ziU8 continuation, struct __zi8_work_data_s* __zi8_work_data) {
ziU8 result;
if (continuation == 0) __zi8_work_data->pudCount = 1;
for (;;) {
result = Zi8_8147FD7C(pattern, length, language, output, capacity, complete, continuation, __zi8_work_data);
if ((ziU8)result != 0) break;
if (result != 0) break;
if (++__zi8_work_data->pudCount <= 16) {
continuation = 0;
} else {
@@ -189,6 +194,6 @@ ziU32 Zi8MatchPUDdata(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* out
}
return result;
}
ziU32 Zi8_8147FD7C(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
ziU8 Zi8_8147FD7C(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
return Zi8MatchPUDdata_ZHS(pattern, length, language, output, capacity, 0, 0, complete, continuation, __zi8_work_data);
}

View File

@@ -1,13 +1,13 @@
#include <zi8clib/zitypes.h>
ziU16 Zi8GetVersion() {
ziU16 Zi8GetVersion(ziPtr __zi8_work_data) {
return 1802;
}
ziU16 Zi8GetBuildID() {
ziU16 Zi8GetBuildID(ziPtr __zi8_work_data) {
return 41;
}
ziU16 Zi8GetOEMID() {
ziU16 Zi8GetOEMID(ziPtr __zi8_work_data) {
return 249;
}

View File

@@ -11,15 +11,15 @@ typedef struct {
ziU8 characterLow;
} ZiKoreanKeyEntry;
ziU32 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) {
ziU16 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) {
ziU32 value;
ziU16 count;
ziU32 i;
ziU16 i;
count = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
for (i = 0; (ziU16)i < count; i++) {
value = (ziU16)(((ziU16)table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 7] << 8) |
table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 8]);
for (i = 0; i < count; i++) {
value = (ziU16)(((ziU16)table[(i << 3) + i + 7] << 8) |
table[(i << 3) + i + 8]);
if (value == key) {
Zi8LogError(0x64, ZI_WORK);
return i;
@@ -313,7 +313,8 @@ ziU32 Zi8GetKOcandidates(ziGetParam* param, ZiKoreanCandidateOptions* options ZI
param->candidates[0] = 0;
}
Zi8LogError(100, ZI_WORK);
if (param->wordCharCount != 0) {
if (param->wordCharCount == 0) goto scan_key_table;
{
if (((search.keyIndex = Zi8_8148302C(param->currentWord[0], keyTable, ZI_WORK)) != 0xFFFF) &&
((((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->keyBytes[4] & 8) != 0)) {
search.wordOffset = ((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childLow |
@@ -438,6 +439,7 @@ search_table:
param->count = search.candidateCount;
param->letters = search.candidateCount;
}
scan_key_table:
if (param->elementCount > 9) {
param->letters = 0;
return 0;

View File

@@ -280,10 +280,8 @@ savePhonetic:
}
if (buffers.phoneticInput[phoneticLength - 1] == 0xF360) {
match->nCand--;
bestInitial = previousInitial;
bestFinal = previousFinal;
final = bestFinal;
initial = bestInitial;
bestInitial = initial = previousInitial;
bestFinal = final = previousFinal;
goto savePhonetic;
}
if (match->nCand == 1) {

View File

@@ -6,11 +6,6 @@ typedef struct FA_NAND_ATTACH {
u32 size;
} FA_NAND_ATTACH;
typedef struct FA_ATTACH_REQUEST {
FADrvTbl* table;
u32 count;
} FA_ATTACH_REQUEST;
FADisk* gOpenDisk[26];
FAPartition* gOpenPartition[26];
typedef struct FA_DISK_INIT {
@@ -34,13 +29,13 @@ static struct {
} drvInitFunc = {diskInitTbl, 3};
extern s32 pdm_open_disk(FA_DISK_INIT* table, FADisk** disk);
extern s32 pdm_open_partition(FADisk* disk, u32 index, FAPartition** partition);
extern s32 pfstub_attach(FA_ATTACH_REQUEST* request, FA_NAND_ATTACH* nand);
extern s32 pfstub_attach(FADrvTbl** drives, const void* nand_data);
extern s32 pfd_sddrv_is_media_insert(void);
extern s32 pfd_mscdrv_is_media_insert(void);
extern s32 pfd_mscdrv_is_media_insert(FADisk* disk);
FAError FAAttach(u32 device, char* nand_path, u32 nand_size, FADrvTbl* table) {
FADisk* disk;
FA_ATTACH_REQUEST request;
FADrvTbl* drives[2];
FA_NAND_ATTACH nand;
s32 error;
s32 index;
@@ -65,16 +60,16 @@ FAError FAAttach(u32 device, char* nand_path, u32 nand_size, FADrvTbl* table) {
return -1;
}
}
request.table = table;
request.count = 0;
drives[0] = table;
drives[1] = NULL;
if (device == 2) {
memcpy(nand.path, nand_path, 78);
nand.size = nand_size;
}
if (device == 2) {
error = pfstub_attach(&request, &nand);
error = pfstub_attach(drives, &nand);
} else {
error = pfstub_attach(&request, NULL);
error = pfstub_attach(drives, NULL);
}
if (error != 0) {
return -1;
@@ -85,11 +80,11 @@ FAError FAAttach(u32 device, char* nand_path, u32 nand_size, FADrvTbl* table) {
gOpenPartition[index] = table->pPart;
if (device == 0) {
if (pfd_sddrv_is_media_insert()) {
request.table->stat |= 0x10;
drives[0]->stat |= 0x10;
}
} else if (device == 1) {
if (pfd_mscdrv_is_media_insert()) {
request.table->stat |= 0x10;
if (pfd_mscdrv_is_media_insert(disk)) {
drives[0]->stat |= 0x10;
}
}
} else {

View File

@@ -3,7 +3,7 @@
static FAEjectCallback g_detach_func;
static FAInsertCallback g_attach_func;
extern s32 uhf_msc_is_media_insert(void);
extern s32 uhf_msc_is_media_insert(FADisk* disk);
s32 pfd_mscdrv_registar_callback(FAInsertCallback insert, FAEjectCallback eject) {
g_attach_func = insert;
@@ -11,6 +11,6 @@ s32 pfd_mscdrv_registar_callback(FAInsertCallback insert, FAEjectCallback eject)
return 0;
}
s32 pfd_mscdrv_is_media_insert(void) {
return uhf_msc_is_media_insert();
s32 pfd_mscdrv_is_media_insert(FADisk* disk) {
return uhf_msc_is_media_insert(disk);
}

View File

@@ -318,58 +318,58 @@ s32 pfd_sddrv_init(FADisk* disk) {
}
if ((pfd_sddrv_flags(&g_pfd_sddrv_info) & 1) != 0) {
OSReport("INFO SD Card driver is already initialize. pfd_sddrv_init()\n");
if (disk == g_pfd_sddrv_info.disk) {
return 0;
}
return -44;
}
if ((g_pfd_sddrv_info.flags & 4) == 0) {
g_pfd_sddrv_info.bytes_per_sector = 0x200;
pf_memset(&g_pfd_sddev, 0, 0x28);
sd_result = ISD_InitCard();
if (sd_result != 0) {
OSReport("ERR:Failed to init SD Card Driver in pfd_sddrv_init()\n");
return -40;
}
g_pfd_sddrv_info.flags |= 4;
}
pf_memset(&g_pfd_sddev, 0, 0x28);
device = &g_pfd_sddev.device;
sd_result = ISD_MountCard(0, &device);
if (sd_result != 0) {
OSReport("ERR SD card can not mount [ret = 0x%x]. pfd_sddrv_init()\n", sd_result);
return -41;
}
sd_result = ISD_GetDeviceStatus(device, &status);
if (sd_result != 0) {
OSReport("ERR Failed to get sd card status. [ret = 0x%x]\n", sd_result);
return 21;
}
if ((status & 1) != 0) {
g_pfd_sddrv_info.media_inserted = 1;
}
g_pfd_sddrv_info.device = device;
if (g_pfd_sddrv_info.media_inserted != 0) {
g_event = 2;
sd_result = ISD_RegisterDeviceIntrHandler(device, (SDDevIntrCallback)pfd_st_removal_callback, &g_event);
if (sd_result != 0) {
OSReport("ERR:Failed to regist intr handler1 [ret = 0x%x] pfd_sddrv_init()\n", sd_result);
ISD_UnmountCard(device);
g_pfd_sddrv_info.device = 0;
return -42;
if (disk != g_pfd_sddrv_info.disk) {
return -44;
}
} else {
g_event = 1;
sd_result = ISD_RegisterDeviceIntrHandler(device, (SDDevIntrCallback)pfd_st_inter_callback, &g_event);
if (sd_result != 0) {
OSReport("ERR:Failed to regist intr handler1 [ret = 0x%x] pfd_sddrv_init()\n", sd_result);
ISD_UnmountCard(device);
g_pfd_sddrv_info.device = 0;
return -42;
if ((g_pfd_sddrv_info.flags & 4) == 0) {
g_pfd_sddrv_info.bytes_per_sector = 0x200;
pf_memset(&g_pfd_sddev, 0, 0x28);
sd_result = ISD_InitCard();
if (sd_result != 0) {
OSReport("ERR:Failed to init SD Card Driver in pfd_sddrv_init()\n");
return -40;
}
g_pfd_sddrv_info.flags |= 4;
}
pf_memset(&g_pfd_sddev, 0, 0x28);
device = &g_pfd_sddev.device;
sd_result = ISD_MountCard(0, &device);
if (sd_result != 0) {
OSReport("ERR SD card can not mount [ret = 0x%x]. pfd_sddrv_init()\n", sd_result);
return -41;
}
sd_result = ISD_GetDeviceStatus(device, &status);
if (sd_result != 0) {
OSReport("ERR Failed to get sd card status. [ret = 0x%x]\n", sd_result);
return 21;
}
if ((status & 1) != 0) {
g_pfd_sddrv_info.media_inserted = 1;
}
g_pfd_sddrv_info.device = device;
if (g_pfd_sddrv_info.media_inserted != 0) {
g_event = 2;
sd_result = ISD_RegisterDeviceIntrHandler(device, (SDDevIntrCallback)pfd_st_removal_callback, &g_event);
if (sd_result != 0) {
OSReport("ERR:Failed to regist intr handler1 [ret = 0x%x] pfd_sddrv_init()\n", sd_result);
ISD_UnmountCard(device);
g_pfd_sddrv_info.device = 0;
return -42;
}
} else {
g_event = 1;
sd_result = ISD_RegisterDeviceIntrHandler(device, (SDDevIntrCallback)pfd_st_inter_callback, &g_event);
if (sd_result != 0) {
OSReport("ERR:Failed to regist intr handler1 [ret = 0x%x] pfd_sddrv_init()\n", sd_result);
ISD_UnmountCard(device);
g_pfd_sddrv_info.device = 0;
return -42;
}
}
g_pfd_sddrv_info.disk = disk;
g_pfd_sddrv_info.flags |= 1;
}
g_pfd_sddrv_info.disk = disk;
g_pfd_sddrv_info.flags |= 1;
return 0;
}
@@ -749,7 +749,8 @@ s32 pfd_sddrv_get_total_sectors(u32* sectors, u16* bytes_per_sector) {
minimum_multiplier = multiplier >= 9 ? multiplier : 9;
max_multiplier = minimum_multiplier <= 11 ? minimum_multiplier : 11;
multiplier_factor = 1;
multiplier_factor <<= (u16)(max_multiplier - 9);
max_multiplier = (u16)(max_multiplier - 9);
multiplier_factor = (u16)(multiplier_factor << max_multiplier);
*sectors = cluster_blocks * multiplier_factor;
} else {
*sectors = ((csd[1] >> 8 & 0x3fffff) + 1) * 0x400;
@@ -1360,19 +1361,20 @@ s32 pfd_sddrv_store_fat32_bpb_buf(PFD_SDDRV_FORMAT_DATA* format_data, u8* sector
static s32 pfd_sddrv_store_fat32_reserved_buf(u8* sector_buffer) {
PFD_SDDRV_RESERVED_BOOT_SECTOR* reserved_boot_sector;
s32 result = -30;
if (sector_buffer == 0) {
return -30;
if (sector_buffer != 0) {
pf_memset(sector_buffer, 0, 0x200);
reserved_boot_sector = (PFD_SDDRV_RESERVED_BOOT_SECTOR*)sector_buffer;
if (((u32)reserved_boot_sector->signature.bytes & 1) != 0) {
reserved_boot_sector->signature.bytes[0] = 0x55;
reserved_boot_sector->signature.bytes[1] = 0xaa;
} else {
reserved_boot_sector->signature.value = 0x55aa;
}
result = 0;
}
pf_memset(sector_buffer, 0, 0x200);
reserved_boot_sector = (PFD_SDDRV_RESERVED_BOOT_SECTOR*)sector_buffer;
if (((u32)reserved_boot_sector->signature.bytes & 1) != 0) {
reserved_boot_sector->signature.bytes[0] = 0x55;
reserved_boot_sector->signature.bytes[1] = 0xaa;
} else {
reserved_boot_sector->signature.value = 0x55aa;
}
return 0;
return result;
}
s32 pfd_sddrv_build_fat32_mbr_bpb(u32 total_sectors) {

View File

@@ -1,25 +1,32 @@
#include <private/fa/pdm.h>
#include <revolution/types.h>
#define MBR_WORD(buf, offset) (((pf_u32)(buf)[(offset) + 3] << 24) + ((pf_u32)(buf)[(offset) + 2] << 16) + ((pf_u32)(buf)[(offset) + 1] << 8) + (buf)[offset])
#define MBR_WORD(buf, offset) \
((pf_u32)(buf)[offset] + ((pf_u32)(buf)[(offset) + 1] << 8) + \
((pf_u32)(buf)[(offset) + 2] << 16) + ((pf_u32)(buf)[(offset) + 3] << 24))
static inline pf_u16 read_boot_u16(pf_u8* buf, pf_u32 offset) {
if ((pf_u32)&buf[offset] & 1) { return (buf[offset + 1] << 8) | buf[offset]; }
return PF_SWAP_16(*(pf_u16*)&buf[(offset + 1) & ~1]);
}
static inline pf_u32 read_partition_u32(const pf_u8* buf, pf_u32 offset) {
return (((pf_u32)buf[offset + 2] << 16) + buf[offset]) +
(((pf_u32)buf[offset + 3] << 24) + ((pf_u32)buf[offset + 1] << 8));
}
pf_s32 pdm_part_is_master_boot_sector(pf_u8* buf, pf_u32 total, pf_bool* p_is_mbr) {
pf_u32* p_start;
pf_u32* p_count;
pf_s16 index;
pf_u32 start[4];
pf_u32 count[4];
pf_u32* p_start;
pf_u32* p_count;
*p_is_mbr = 0;
if (buf[510] != 0x55 || buf[511] != 0xAA) { return 2; }
p_start = start;
p_count = count;
for (index = 0; index < 4; index++) {
*p_start = 0;
*p_start = (((pf_u32)buf[456] << 16) + buf[454]) + (((pf_u32)buf[457] << 24) + ((pf_u32)buf[455] << 8));
*p_count = (((pf_u32)buf[460] << 16) + buf[458]) + (((pf_u32)buf[461] << 24) + ((pf_u32)buf[459] << 8));
*p_start = read_partition_u32(buf, 454);
*p_count = read_partition_u32(buf, 458);
if (*p_start != 0 && *p_count != 0) {
if (index == 0) { *p_is_mbr = 1; }
} else {
@@ -71,15 +78,20 @@ pf_bool pdm_part_is_boot_sector(pf_u8* buf) {
return is_boot;
}
static inline pf_u32 read_relative_start_sector(pf_u32 base, const pf_u8* buf, pf_u32 offset) {
return base + (buf[offset] + ((unsigned int)buf[offset + 1] << 8) +
((unsigned int)buf[offset + 2] << 16) + ((unsigned int)buf[offset + 3] << 24));
}
pf_s32 pdm_part_get_start_sector(PDM_PARTITION* p_part) {
pf_u32 part_index = 0;
pf_u32 requested = p_part->part_id;
pf_u32 start[4];
pf_u32 count[4];
pf_u32 part_index = 0;
pf_u32 sector;
pf_u32 base;
pf_u16 index;
pf_u16 extended_index;
pf_u32 base;
pf_u32 sector;
pf_u32 length;
pf_bool is_mbr;
pf_u32 success;
@@ -112,14 +124,14 @@ pf_s32 pdm_part_get_start_sector(PDM_PARTITION* p_part) {
sector = base;
for (extended_index = 0; extended_index < 2; extended_index++) {
if (extended_index == 0) {
sector = sector + MBR_WORD(buf, 454);
sector = read_relative_start_sector(sector, buf, 454);
length = MBR_WORD(buf, 458);
err = pdm_disk_physical_read(p_part->p_disk, buf, sector, 1, 512, &success);
if (err != 0) { return err; }
if (requested == part_index) { p_part->start_sector = sector; p_part->total_sector = length; return 0; }
part_index++;
} else {
sector = base + MBR_WORD(buf, 470);
sector = read_relative_start_sector(base, buf, 470);
length = MBR_WORD(buf, 474);
if (sector == 0 || length == 0) { break; }
err = pdm_disk_physical_read(p_part->p_disk, buf, sector, 1, 512, &success);

View File

@@ -1,12 +1,12 @@
#include <revolution/fa/pf_stub.h>
s32 pfstub_attach(FADrvTbl* drives, u32 mode) {
s32 pfstub_attach(FADrvTbl** drives, const void* nand_data) {
PF_STUB_MESSAGE message;
message.operation = 27;
message.object = drives;
message.callback = NULL;
message.data = (void*)mode;
message.data = nand_data;
if (pfstub_com_massage(&message) == -1) {
return -1;
}

View File

@@ -557,15 +557,11 @@ static void kbdSendKey(KBDKeyEventData* event) {
}
}
static inline u32 kbdChannelFlags(u32 channel) {
return kbdData[channel].flags;
}
static void kbd_led_handler(BOOL success, void* callbackArg) {
const KBDLEDCallbackData* callback;
u32 index;
s32 index;
u32 err;
index = (u32)callbackArg;
index = (s32)callbackArg;
callback = &kbdLCBuf[index];
kbdCmdBuf[index].device = 0;
if (callback->callbackAddress == (USBKBDCmdLEDCallback)(u32)kbdCmdBuf[index].device) {
@@ -579,12 +575,11 @@ static void kbd_led_handler(BOOL success, void* callbackArg) {
err = 0;
break;
}
kbdLCBuf[index].callbackAddress(err, kbdLCBuf[index].callbackArg);
kbdLCBuf[(u32)callbackArg].callbackAddress(err, kbdLCBuf[(u32)callbackArg].callbackArg);
}
USBKBDErr KBDSetLedsAsync(u32 channel, u32 leds, USBKBDCmdLEDCallback callback, void* callbackArg) {
s32 index;
u32 ofs;
u32 index;
u8 ledBits;
BOOL interrupts;
USBKBDErr result;
@@ -594,14 +589,18 @@ USBKBDErr KBDSetLedsAsync(u32 channel, u32 leds, USBKBDCmdLEDCallback callback,
if (channel >= 4) {
return 4;
}
if ((s32)kbdChannelFlags(channel) == 1 || (s32)kbdChannelFlags(channel) == 4) {
return 5;
{
KBDChannel* data = &kbdData[(s32)channel];
if ((s32)data->flags == 1 || (s32)data->flags == 4) {
return 5;
}
}
ledBits = leds;
interrupts = OSDisableInterrupts();
for (index = 0, ofs = 0; index < 12; index++, ofs += sizeof(KBDLEDCommand)) {
if (*(u32*)&((u8*)kbdCmdBuf)[ofs] == 0) {
*(u32*)&((u8*)kbdCmdBuf)[ofs] = (u32)kbdData[channel].device;
for (index = 0; index < 12; index++) {
if (kbdCmdBuf[(s32)index].device == 0) {
KBDChannel* data = &kbdData[channel];
kbdCmdBuf[(s32)index].device = (u32)data->device;
break;
}
}
@@ -609,11 +608,14 @@ USBKBDErr KBDSetLedsAsync(u32 channel, u32 leds, USBKBDCmdLEDCallback callback,
if (index == 12) {
return 7;
}
kbdLCBuf[index].callbackAddress = callback;
kbdLCBuf[index].callbackArg = callbackArg;
result = USBKBDSetLEDAsync((u32)kbdData[channel].device, ledBits,
(USBKBDCmdLEDAsync*)&kbdCmdBuf[index],
kbd_led_handler, (void*)index);
{
KBDChannel* data = &kbdData[channel];
kbdLCBuf[index].callbackAddress = callback;
kbdLCBuf[index].callbackArg = callbackArg;
result = USBKBDSetLEDAsync((u32)data->device, ledBits,
(USBKBDCmdLEDAsync*)&kbdCmdBuf[index],
kbd_led_handler, (void*)index);
}
switch (result) {
default:
return 7;
@@ -624,7 +626,6 @@ USBKBDErr KBDSetLedsAsync(u32 channel, u32 leds, USBKBDCmdLEDCallback callback,
USBKBDErr KBDSetLeds(u32 channel, u32 leds) {
u32 index;
KBDLEDCommand* command;
BOOL interrupts;
USBKBDErr result;
u8 ledBits;
@@ -634,20 +635,16 @@ USBKBDErr KBDSetLeds(u32 channel, u32 leds) {
if (channel >= 4) {
return 4;
}
if ((s32)kbdChannelFlags(channel) == 1 || (s32)kbdChannelFlags(channel) == 4) {
if ((s32)kbdData[(s32)channel].flags == 1 || (s32)kbdData[(s32)channel].flags == 4) {
return 5;
}
ledBits = leds & 0xff;
interrupts = OSDisableInterrupts();
index = 0;
command = kbdCmdBuf;
while (index < 12) {
if (command->device == 0) {
command->device = (u32)kbdData[channel].device;
for (index = 0; index < 12; index++) {
if (kbdCmdBuf[(s32)index].device == 0) {
kbdCmdBuf[(s32)index].device = (u32)kbdData[channel].device;
break;
}
index++;
command++;
}
OSRestoreInterrupts(interrupts);
if (index == 12) {
@@ -655,7 +652,7 @@ USBKBDErr KBDSetLeds(u32 channel, u32 leds) {
}
result = USBKBDSetLED((u32)kbdData[channel].device, ledBits,
(USBKBDCmdLED*)&kbdCmdBuf[index]);
kbdCmdBuf[index].device = 0;
kbdCmdBuf[(s32)index].device = 0;
switch (result) {
default:
return 7;

View File

@@ -571,8 +571,14 @@ static inline f32 clamp_acc_value(f32 value, f32 limit) {
}
static inline void smooth_acc_value(KPADInside* kpad, f32 value, f32* result) {
f32 delta = value - *result;
f32 amount = delta < 0.0f ? -delta : delta;
f32 amount;
f32 delta;
delta = value - *result;
if (delta < 0.0f) {
amount = -delta;
} else {
amount = delta;
}
if (amount >= kpad->value9C) {
amount = 1.0f;
} else {
@@ -612,12 +618,16 @@ static void read_kpad_acc(KPADInside* kpad, KPADSample* status) {
kpad->status.acc_speed = (f32)sqrt(previous.z * previous.z + (previous.x * previous.x + previous.y * previous.y));
calc_acc_horizon(kpad);
calc_acc_vertical(kpad);
if (status->error != 0 || status->device != 1) {
return;
}
if (status->dataFormat != 4 && status->dataFormat != 5) {
return;
if (status->error == 0 && status->device == 1) {
if (status->dataFormat == 4) {
goto read_extension_acceleration;
}
if (status->dataFormat == 5) {
goto read_extension_acceleration;
}
}
return;
read_extension_acceleration:
{
Vec extensionPrevious;
raw.x = clamp_acc_value((f32)-(s32)status->extension.fs.accX * kpad->value4E8, kp_fs_acc_max);
@@ -939,15 +949,20 @@ static void calc_dpd_variable(KPADInside* kpad, s8 valid) {
f32 dx;
f32 next;
dx = value - kpad->status.dist;
magnitude = dx < 0.0f ? -dx : dx;
if (dx < 0.0f) {
magnitude = -dx;
} else {
magnitude = dx;
}
if (magnitude >= kpad->value94) {
magnitude = 1.0f;
} else {
magnitude = magnitude / kpad->value94;
magnitude /= kpad->value94;
magnitude *= magnitude;
magnitude *= magnitude;
}
next = magnitude * kpad->value98 * dx;
magnitude *= kpad->value98;
next = magnitude * dx;
kpad->status.dist_vec = next;
if (next < 0.0f) {
kpad->status.dist_speed = -next;
@@ -958,12 +973,15 @@ static void calc_dpd_variable(KPADInside* kpad, s8 valid) {
}
}
{
f32 rotatedX = kpad->horizonTangent.x * kpad->dpdObjectDirection.x + kpad->horizonTangent.y * kpad->dpdObjectDirection.y;
f32 midpointFactor = 0.5f;
f32 scaleX = midpointFactor * (kpad->dpdState.candidates[0].x + kpad->dpdState.candidates[1].x);
f32 scaleY = midpointFactor * (kpad->dpdState.candidates[0].y + kpad->dpdState.candidates[1].y);
f32 rotatedX = kpad->dpdObjectDirection.x * kpad->horizonTangent.x + kpad->dpdObjectDirection.y * kpad->horizonTangent.y;
f32 rotatedY = -kpad->dpdObjectDirection.y * kpad->horizonTangent.x + kpad->dpdObjectDirection.x * kpad->horizonTangent.y;
f32 scaleX = 0.5f * (kpad->dpdState.candidates[0].x + kpad->dpdState.candidates[1].x);
f32 scaleY = 0.5f * (kpad->dpdState.candidates[0].y + kpad->dpdState.candidates[1].y);
delta.x = kpad->sensorBarScale * (kpad->sensorBarCenter.x - (rotatedX * scaleX - rotatedY * scaleY));
delta.y = kpad->sensorBarScale * (kpad->sensorBarCenter.y - (rotatedY * scaleX + rotatedX * scaleY));
f32 transformedX = rotatedX * scaleX - rotatedY * scaleY;
f32 transformedY = rotatedY * scaleX + rotatedX * scaleY;
delta.x = kpad->sensorBarScale * (kpad->sensorBarCenter.x - transformedX);
delta.y = kpad->sensorBarScale * (kpad->sensorBarCenter.y - transformedY);
point.x = -kpad->accelNormal.y * delta.x + kpad->accelNormal.x * delta.y;
point.y = -kpad->accelNormal.x * delta.x - kpad->accelNormal.y * delta.y;
if (kpad->status.dpd_valid_fg == 0) {
@@ -1296,6 +1314,9 @@ static void read_kpad_stick(KPADInside* kpad, KPADSample* status) {
}
s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
u32 changed;
u16 heldButtons;
KPADStatus* output;
KPADInside* kpad = &inside_kpads[chan];
s32 probe;
BOOL interruptState;
@@ -1303,17 +1324,15 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
u32 ringCount;
s32 start;
s32 sampleIndex;
u32 remaining;
s32 remaining;
u32 remainingSamples;
u32 buttons;
u16 previousButtons;
u32 changed;
u32 extensionButtons;
u32 coreButtons;
u32 extensionButtons;
u8 device;
KPADSample latestSample;
KPADSample* sample;
KPADStatus* output;
if (WPADGetStatus() != 3) {
return 0;
}
@@ -1347,19 +1366,19 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
if (available > count) {
available = count;
}
remaining = available;
kpad->ringCount = 0;
output = statuses + remaining;
start = kpad->ringIndex - available;
if (start < 0) {
start += 16;
}
--output;
{
KPADStatus* copyOutput;
sampleIndex = start;
remaining = available;
copyOutput = statuses + (available - 1);
while (--remaining != 0) {
copyOutput--;
*(KPADSample*)copyOutput = kpad->ringData[sampleIndex];
output--;
*(KPADSample*)output = kpad->ringData[sampleIndex];
sampleIndex++;
if (sampleIndex >= 16) {
sampleIndex = 0;
@@ -1372,7 +1391,7 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
WPADAccGravityUnit gravity = {1, 1, 1};
WPADAccGravityUnit extensionGravity = {1, 1, 1};
WPADGetAccGravityUnit(chan, WPAD_ACC_GRAVITY_UNIT_CORE, &gravity);
if (gravity.z * gravity.x * gravity.y != 0) {
if (gravity.x * gravity.y * gravity.z != 0) {
kpad->value4DC = 1.0f / gravity.x;
kpad->value4E0 = 1.0f / gravity.y;
kpad->value4E4 = 1.0f / gravity.z;
@@ -1382,7 +1401,7 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
kpad->value4E4 = 0.01f;
}
WPADGetAccGravityUnit(chan, WPAD_ACC_GRAVITY_UNIT_FS, &extensionGravity);
if (extensionGravity.z * extensionGravity.x * extensionGravity.y != 0) {
if (extensionGravity.x * extensionGravity.y * extensionGravity.z != 0) {
kpad->value4E8 = 1.0f / extensionGravity.x;
kpad->value4EC = 1.0f / extensionGravity.y;
kpad->value4F0 = 1.0f / extensionGravity.z;
@@ -1395,8 +1414,8 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
output = statuses + available;
--output;
device = 0xFD;
coreButtons = 0xFFFF;
extensionButtons = 0xFFFF;
coreButtons = 0xFFFF;
buttons = 0xFFFF;
do {
output--;
@@ -1433,18 +1452,20 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
if (extensionButtons == 0xFFFF) {
extensionButtons = kpad->status.ex_status.cl.hold;
}
buttons = (buttons & 0x9FFF) | (coreButtons & 0x6000);
previousButtons = kpad->status.hold;
changed = previousButtons ^ buttons;
kpad->status.hold = buttons;
kpad->status.trig = changed & buttons;
heldButtons = (buttons & 0x9FFF) | (coreButtons & 0x6000);
changed = heldButtons ^ previousButtons;
kpad->status.hold = heldButtons;
kpad->status.trig = changed & heldButtons;
kpad->status.release = changed & previousButtons;
if (device == 2) {
previousButtons = kpad->status.ex_status.cl.hold;
kpad->status.ex_status.cl.hold = (u16)extensionButtons;
changed = previousButtons ^ (u16)extensionButtons;
u16 previousExtensionButtons;
previousExtensionButtons = kpad->status.ex_status.cl.hold;
extensionButtons = (u16)extensionButtons;
kpad->status.ex_status.cl.hold = extensionButtons;
changed = extensionButtons ^ previousExtensionButtons;
kpad->status.ex_status.cl.trig = changed & extensionButtons;
kpad->status.ex_status.cl.release = changed & previousButtons;
kpad->status.ex_status.cl.release = changed & previousExtensionButtons;
}
calc_button_repeat(kpad, device, ringCount);
remainingSamples = available;
@@ -1489,7 +1510,6 @@ void KPADInit(void) {
f32 zero;
f32 degreesToRadians;
f32 one;
f32* matrix;
u32 i;
s32 chan;
BOOL enabled;
@@ -1500,7 +1520,6 @@ void KPADInit(void) {
one = 1.0f;
zero = 0.0f;
degreesToRadians = 0.017453292f;
matrix = initial_rotation_matrix;
kpad = inside_kpads;
do {
kpad->dpdEnable = 1;
@@ -1528,9 +1547,9 @@ void KPADInit(void) {
}
referenceWidth = referenceWidth < referenceHeight ? referenceWidth : referenceHeight;
initial_rotation_matrix[0] = one;
matrix[1] = zero;
matrix[2] = zero;
matrix[3] = zero;
initial_rotation_matrix[1] = zero;
initial_rotation_matrix[2] = zero;
initial_rotation_matrix[3] = zero;
kpad->sensorBarScale = sensorDistance / referenceWidth;
kpad->value9C = zero;
kpad->value94 = zero;
@@ -1549,18 +1568,18 @@ void KPADInit(void) {
kpad->sensorHeightPending = 1;
kpad->sensorBarPosition = 1;
kpad->freeStyleAccelRotation = 0;
matrix[4] = zero;
initial_rotation_matrix[4] = zero;
rotationElement = (f32)cos(degreesToRadians * sensor_bar_angle_degrees);
matrix[5] = rotationElement;
initial_rotation_matrix[5] = rotationElement;
rotationElement = (f32)-sin(degreesToRadians * sensor_bar_angle_degrees);
matrix[7] = zero;
matrix[8] = zero;
matrix[6] = rotationElement;
initial_rotation_matrix[7] = zero;
initial_rotation_matrix[8] = zero;
initial_rotation_matrix[6] = rotationElement;
rotationElement = (f32)sin(degreesToRadians * sensor_bar_angle_degrees);
matrix[9] = rotationElement;
initial_rotation_matrix[9] = rotationElement;
rotationElement = (f32)cos(degreesToRadians * sensor_bar_angle_degrees);
matrix[10] = rotationElement;
matrix[11] = zero;
initial_rotation_matrix[10] = rotationElement;
initial_rotation_matrix[11] = zero;
{
i = 0;
do {

View File

@@ -8,13 +8,11 @@ void CDBCryptBufSysInit(CDBCryptBuf* cryptBuf) {
cryptBuf->allocated = FALSE;
}
// Some weird crap is going on with these functions.
CDBErr CDBCryptBufAllocate(CDBCryptBuf* cryptBuf) {
CDBErr CDBCryptBufAllocate(CDBCryptBuf** cryptBuf) {
CDBErr err = CDB_ERROR_OK;
if (s_cryptBuf->allocated == FALSE) {
cryptBuf->buffer32[0] = (u32)&s_cryptBuf[err];
*cryptBuf = &s_cryptBuf[err];
s_cryptBuf[err].allocated = TRUE;
return CDB_ERROR_OK;
} else {
@@ -23,12 +21,12 @@ CDBErr CDBCryptBufAllocate(CDBCryptBuf* cryptBuf) {
}
}
CDBErr CDBCryptBufFree(CDBCryptBuf* cryptBuf) {
CDBErr CDBCryptBufFree(CDBCryptBuf** cryptBuf) {
CDBErr err = CDB_ERROR_OK;
if ((CDBCryptBuf*)*cryptBuf->buffer32 == s_cryptBuf) {
if (*cryptBuf == s_cryptBuf) {
s_cryptBuf[err].allocated = FALSE;
*cryptBuf->buffer32 = 0;
*cryptBuf = NULL;
return CDB_ERROR_OK;
} else {
CDBReportError("failed to free crypt buffer\n");

View File

@@ -169,11 +169,11 @@ static const u32 AESiDecryptTable[] = {
};
#define ROTATE(x,n) (((x) << (n)) | ((x) >> (32 - (n))))
#define ENCRYPT(a,b,c,d) (ROTATE(AESiEncryptTable[(a)>>24],24) ^ ROTATE(AESiEncryptTable[((b)>>16)&255],16) ^ ROTATE(AESiEncryptTable[((c)>>8)&255],8) ^ AESiEncryptTable[(d)&255])
#define DECRYPT(a,b,c,d) (ROTATE(AESiDecryptTable[(a)>>24],24) ^ ROTATE(AESiDecryptTable[((b)>>16)&255],16) ^ ROTATE(AESiDecryptTable[((c)>>8)&255],8) ^ AESiDecryptTable[(d)&255])
#define SUBSTITUTE(table,a,b,c,d) (((u32)table[(a)>>24]<<24) | ((u32)table[((b)>>16)&255]<<16) | ((u32)table[((c)>>8)&255]<<8) | table[(d)&255])
#define ENCRYPT(a,b,c,d) (((ROTATE(AESiEncryptTable[((b)>>16)&255],16) ^ ROTATE(AESiEncryptTable[(a)>>24],24)) ^ AESiEncryptTable[(d)&255]) ^ ROTATE(AESiEncryptTable[((c)>>8)&255],8))
#define DECRYPT(a,b,c,d) (((ROTATE(AESiDecryptTable[((b)>>16)&255],16) ^ AESiDecryptTable[(d)&255]) ^ ROTATE(AESiDecryptTable[(a)>>24],24)) ^ ROTATE(AESiDecryptTable[((c)>>8)&255],8))
#define SUBSTITUTE(table,a,b,c,d) ((((u32)table[(a)>>24]<<24) | table[(d)&255]) | (((u32)table[((b)>>16)&255]<<16) | ((u32)table[((c)>>8)&255]<<8)))
#define SUBSTITUTE_XOR(table,a,b,c,d) (((u32)table[(a)>>24]<<24) ^ ((u32)table[((b)>>16)&255]<<16) ^ ((u32)table[((c)>>8)&255]<<8) ^ table[(d)&255])
#define DECRYPT_FINAL(table,a,b,c,d,key) ((table[(d)&255] ^ ((u32)table[((c)>>8)&255]<<8)) ^ (((u32)table[((b)>>16)&255]<<16) ^ ((key) ^ ((u32)table[(a)>>24]<<24))))
void AESiEncryptBlock(AESContext* context, u32* output, const u32* input) {
u32 rounds = context->rounds;
@@ -204,16 +204,15 @@ void AESiDecryptBlock(AESContext* context, u32* output, const u32* input) {
u32 round;
for (round=1; round<context->rounds; ++round) {
u32 word;
u32* keys=context->keys + round*4;
for (word=0; word<4; ++word) {
u32 value=keys[word];
u32 value=context->keys[round*4 + word];
u32 twice=DOUBLE_BYTES(value);
u32 four=DOUBLE_BYTES(twice);
u32 eight=DOUBLE_BYTES(four)^value;
u32 mixed=eight ^ (four ^ ROTATE(eight,8));
mixed ^= twice ^ ROTATE(mixed,8);
mixed ^= value ^ ROTATE(mixed,8);
keys[word]=mixed;
u32 mixed=(ROTATE(eight,8) ^ (eight ^ four));
mixed=(ROTATE(mixed,8) ^ (mixed ^ twice));
mixed=(ROTATE(mixed,8) ^ (mixed ^ value));
context->keys[round*4 + word]=mixed;
}
}
context->needsTransform=0;
@@ -228,10 +227,10 @@ void AESiDecryptBlock(AESContext* context, u32* output, const u32* input) {
a=nextA^key[0]; b=nextB^key[1]; c=nextC^key[2]; d=nextD^key[3];
key-=4;
}
output[0]=SUBSTITUTE_XOR(AESiInvSubShiftTable,a,d,c,b)^key[0];
output[1]=SUBSTITUTE_XOR(AESiInvSubShiftTable,b,a,d,c)^key[1];
output[2]=SUBSTITUTE_XOR(AESiInvSubShiftTable,c,b,a,d)^key[2];
output[3]=SUBSTITUTE_XOR(AESiInvSubShiftTable,d,c,b,a)^key[3];
output[0]=DECRYPT_FINAL(AESiInvSubShiftTable,a,d,c,b,key[0]);
output[1]=DECRYPT_FINAL(AESiInvSubShiftTable,b,a,d,c,key[1]);
output[2]=DECRYPT_FINAL(AESiInvSubShiftTable,c,b,a,d,key[2]);
output[3]=DECRYPT_FINAL(AESiInvSubShiftTable,d,c,b,a,key[3]);
}
BOOL NETAESCreateEx(AESContext* context, const void* key, u32 keyLength, const void* iv, const AESBlockMode* mode) {

View File

@@ -75,25 +75,34 @@ static inline u32 rotateSum(u32 state, const u32* word, u32 constant, int shift)
return ((state + (constant + left)) << shift) | ((constant + (state + right)) >> (32 - shift));
}
static inline u32 rotateNextSum(u32 state, u32** cursor, u32 constant, int shift) {
const u32* word = *cursor;
u32 right = __lwbrx((void*)word, 0);
u32 left = __lwbrx((void*)word, 0);
++*cursor;
return ((state + (constant + left)) << shift) | ((constant + (state + right)) >> (32 - shift));
}
#define STEP_NEXT(a, b, c, d, f, word, n) ((a) = (b) + rotateNextSum((a) + (f), &(word), *constant, n))
#define STEP(a, b, c, d, f, word, n) ((a) = (b) + rotateSum((a) + (f), word, *constant, n))
static void ProcessBlock(NETMD5Context* context) {
static u32 constants[64] = {0xD76AA478, 0xE8C7B756, 0x242070DB, 0xC1BDCEEE, 0xF57C0FAF, 0x4787C62A, 0xA8304613, 0xFD469501, 0x698098D8, 0x8B44F7AF, 0xFFFF5BB1, 0x895CD7BE, 0x6B901122, 0xFD987193, 0xA679438E, 0x49B40821, 0xF61E2562, 0xC040B340, 0x265E5A51, 0xE9B6C7AA, 0xD62F105D, 0x02441453, 0xD8A1E681, 0xE7D3FBC8, 0x21E1CDE6, 0xC33707D6, 0xF4D50D87, 0x455A14ED, 0xA9E3E905, 0xFCEFA3F8, 0x676F02D9, 0x8D2A4C8A, 0xFFFA3942, 0x8771F681, 0x6D9D6122, 0xFDE5380C, 0xA4BEEA44, 0x4BDECFA9, 0xF6BB4B60, 0xBEBFBC70, 0x289B7EC6, 0xEAA127FA, 0xD4EF3085, 0x04881D05, 0xD9D4D039, 0xE6DB99E5, 0x1FA27CF8, 0xC4AC5665, 0xF4292244, 0x432AFF97, 0xAB9423A7, 0xFC93A039, 0x655B59C3, 0x8F0CCC92, 0xFFEFF47D, 0x85845DD1, 0x6FA87E4F, 0xFE2CE6E0, 0xA3014314, 0x4E0811A1, 0xF7537E82, 0xBD3AF235, 0x2AD7D2BB, 0xEB86D391};
static u32 indices[48] = {0x00000001, 0x00000006, 0x0000000B, 0x00000000, 0x00000005, 0x0000000A, 0x0000000F, 0x00000004, 0x00000009, 0x0000000E, 0x00000003, 0x00000008, 0x0000000D, 0x00000002, 0x00000007, 0x0000000C, 0x00000005, 0x00000008, 0x0000000B, 0x0000000E, 0x00000001, 0x00000004, 0x00000007, 0x0000000A, 0x0000000D, 0x00000000, 0x00000003, 0x00000006, 0x00000009, 0x0000000C, 0x0000000F, 0x00000002, 0x00000000, 0x00000007, 0x0000000E, 0x00000005, 0x0000000C, 0x00000003, 0x0000000A, 0x00000001, 0x00000008, 0x0000000F, 0x00000006, 0x0000000D, 0x00000004, 0x0000000B, 0x00000002, 0x00000009};
u32 a = context->a, b = context->b, c = context->c, d = context->d;
u32* word;
u32* constant;
u32* index;
int round;
u32* block;
u32* constant;
int round;
u32* word;
block = context->buffer32;
word = block;
constant = constants;
for (round = 0; round < 4; ++round) {
STEP(a,b,c,d,(b & c) | (~b & d),word++,7); ++constant;
STEP(d,a,b,c,(a & b) | (~a & c),word++,12); ++constant;
STEP(c,d,a,b,(d & a) | (~d & b),word++,17); ++constant;
STEP(b,c,d,a,(c & d) | (~c & a),word++,22); ++constant;
STEP_NEXT(a,b,c,d,(b & c) | (~b & d),word,7); ++constant;
STEP_NEXT(d,a,b,c,(a & b) | (~a & c),word,12); ++constant;
STEP_NEXT(c,d,a,b,(d & a) | (~d & b),word,17); ++constant;
STEP_NEXT(b,c,d,a,(c & d) | (~c & a),word,22); ++constant;
}
index = indices;
for (round = 0; round < 4; ++round) {

View File

@@ -7,8 +7,7 @@ s32 NHTTPi_strcmp(const char* left, const char* right) { return strcmp(left,righ
void* NHTTPi_memclr(void* destination, u32 size) { return memset(destination,0,size); }
static int LowerCase(int character) {
if((character>='A') & (character<='Z')) character+=32;
return character;
return ((character >= 'A') & (character <= 'Z')) ? character + 32 : character;
}
s32 NHTTPi_strnicmp(const char* left, const char* right, s32 length) {
@@ -127,12 +126,13 @@ s32 NHTTPi_intToStr(char* destination, u32 value) {
}
s32 NHTTPi_compareToken(const char* left, const char* right) {
for (;;) {
int rightCharacter=LowerCase(*right);
int leftCharacter=LowerCase(*left);
if(leftCharacter!=rightCharacter) break;
if(*left==0 || *left==' ') return 0;
++left; ++right;
u32 rawLeft;
while (LowerCase((s8)(rawLeft = *(const u8*)left)) == LowerCase((s8)*(const u8*)right)) {
if ((s8)rawLeft == 0 || (s8)rawLeft == ' ') {
return 0;
}
++left;
++right;
}
return -1;
}
@@ -158,20 +158,24 @@ s32 NHTTPi_strtonum(const char* string, u32 length) {
}
s32 NHTTPi_Base64Encode(char* destination, const char* source) {
static char alphabet[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const char* table=alphabet;
char* output=destination;
u32 length=strlen(source);
s32 consumed=0;
for(; consumed<(s32)length; consumed+=3) {
output[0]=table[source[0]>>2];
output[1]=table[((source[0]&3)<<4)+(source[1]>>4)];
output[2]=table[((source[1]&15)<<2)+(source[2]>>6)];
output[3]=table[source[2]&63];
source+=3; output+=4;
const char* table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
char* output = destination;
s32 length = strlen(source);
s32 consumed = 0;
for (; consumed < length; consumed += 3) {
output[0] = table[source[0] >> 2];
output[1] = table[((source[0] & 3) << 4) + (source[1] >> 4)];
output[2] = table[((source[1] & 15) << 2) + (source[2] >> 6)];
output[3] = table[source[2] & 63];
source += 3;
output += 4;
}
if(consumed==length+1) output[-1]='=';
else if(consumed==length+2) { output[-2]='='; output[-1]='='; }
*output=0;
if (consumed == length + 1) output[-1] = '=';
else if (consumed == length + 2) {
output[-2] = '=';
output[-1] = '=';
}
*output = 0;
return strlen(destination);
}

View File

@@ -7,8 +7,9 @@ s32 ConvertDateToDays(u16 year, u8 month, u8 day);
void ConvertDaysToDate(u16* year, u8* month, u8* day, s32 days);
static inline BOOL IsLeapYear(u16 year) {
s32 calendarYear = year;
BOOL leap = FALSE;
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
if ((calendarYear % 4 == 0 && calendarYear % 100 != 0) || calendarYear % 400 == 0)
leap = TRUE;
return leap;
}
@@ -152,7 +153,7 @@ NWC24Err NWC24iIsValidDate(u16 year, u8 month, u8 day) {
s32 ConvertDateToDays(u16 year, u8 month, u8 day) {
s32 daysOfYear;
s32 yearOffset;
s32 centuryLeapDays;
s32 totalDays;
s32 commonLeapDays;
BOOL isLeapYear;
@@ -190,11 +191,10 @@ validDate:
}
yearOffset = year - 1900;
centuryLeapDays = (yearOffset + 299) / 400;
daysOfYear += yearOffset * 365;
daysOfYear += centuryLeapDays;
totalDays = daysOfYear + (yearOffset + 299) / 400;
commonLeapDays = (yearOffset - 1) / 4 - (yearOffset - 1) / 100;
return daysOfYear + commonLeapDays;
return totalDays + commonLeapDays;
}
void ConvertDaysToDate(u16* year, u8* month, u8* day, s32 days) {
@@ -231,7 +231,7 @@ void ConvertDaysToDate(u16* year, u8* month, u8* day, s32 days) {
const u8* parsedMonth = month;
previousDays = days;
currentMonth = *parsedMonth;
if (currentMonth == 2 && IsLeapYear(*year)) {
if (*parsedMonth == 2 && IsLeapYear(*year)) {
days -= 29;
} else {
days -= DAYS_OF_MONTH[currentMonth - 1];

View File

@@ -687,10 +687,10 @@ NWC24Err NWC24IterateDlTaskEx(NWC24DlIterateWork* dlIterateWork, NWC24DlId* dlIt
return NWC24_ERR_DONE;
}
static inline NWC24Err SetDlTaskAccessTime(NWC24DlTask* dlTask, OSTime time) {
static inline NWC24Err SetDlTaskAccessTime(const NWC24DlTask* dlTask, OSTime time) {
NWC24Work* work = NWC24WorkP;
DlTaskListHeader* header = work != NULL ? (DlTaskListHeader*)work->dlHead : NULL;
DlTaskData* task = (DlTaskData*)dlTask;
const DlTaskData* task = (const DlTaskData*)dlTask;
NWC24Err result;
u16 taskId;
if (task == NULL) { result = NWC24_ERR_INVALID_VALUE; }
@@ -706,19 +706,39 @@ static inline NWC24Err SetDlTaskAccessTime(NWC24DlTask* dlTask, OSTime time) {
return NWC24_OK;
}
static inline NWC24Err CheckDlTaskRetry(NWC24DlTask* dlTask, u8 retryCount) {
DlTaskData* task = (DlTaskData*)dlTask;
NWC24Err result = ValidateDlTask(dlTask, FALSE);
u32 retryMask;
if (result != NWC24_OK) { return result; }
if (task->retryEnabled == 0) { return NWC24_ERR_INVALID_OPERATION; }
retryMask = task->retryMask;
if (retryMask == 0) { return NWC24_ERR_FATAL; }
if (retryCount > 31) { return NWC24_ERR_INVALID_VALUE; }
if ((retryMask & (1 << retryCount)) == 0) { return NWC24_ERR_DISABLED; }
static inline NWC24Err CheckDlTaskForRetry(const DlTaskData* task) {
DlTaskListHeader* header = NWC24WorkP == NULL ? NULL : (DlTaskListHeader*)NWC24WorkP->dlHead;
if (task == NULL) {
return NWC24_ERR_INVALID_VALUE;
}
if (header == NULL) {
return NWC24_ERR_LIB_NOT_OPENED;
}
if (task->id != 0xffff && task->id >= header->maxTaskCount) {
return NWC24_ERR_INVALID_VALUE;
}
return NWC24_OK;
}
static inline NWC24Err UpdateDlTaskAccessTime(NWC24DlTask* dlTask) {
static inline NWC24Err CheckDlTaskRetry(const NWC24DlTask* dlTask, u8 retryCount) {
const DlTaskData* task = (const DlTaskData*)dlTask;
NWC24Err result;
result = CheckDlTaskForRetry(task);
if (result != NWC24_OK) {
return result;
}
if (task->retryEnabled == 0) {
return NWC24_ERR_INVALID_OPERATION;
}
if (task->retryMask == 0) {
return NWC24_ERR_FATAL;
}
if (retryCount > 31) {
return NWC24_ERR_INVALID_VALUE;
}
return ((1U << retryCount) & task->retryMask) == 0 ? NWC24_ERR_DISABLED : NWC24_OK;
}
static inline NWC24Err UpdateDlTaskAccessTime(const NWC24DlTask* dlTask) {
OSTime universalTime;
NWC24Err result = NWC24iGetUniversalTime(&universalTime);
if (result >= NWC24_OK) {
@@ -728,24 +748,61 @@ static inline NWC24Err UpdateDlTaskAccessTime(NWC24DlTask* dlTask) {
return result;
}
static inline BOOL IsDlTaskWritableGroup(u32 groupId, u32 flags) {
BOOL allowed = FALSE;
if (flags & 0x40) {
if (groupId == NWC24GetGroupId()) {
allowed = TRUE;
}
}
return allowed;
}
static inline NWC24Err ValidateWritableDlTask(const NWC24DlTask* dlTask) {
const DlTaskData* task = (const DlTaskData*)dlTask;
DlTaskListHeader* header = GetCachedDlHeader();
if (task == NULL) {
return NWC24_ERR_INVALID_VALUE;
}
if (header == NULL) {
return NWC24_ERR_LIB_NOT_OPENED;
}
if (!NWC24IsMsgLibOpenedByTool() && !IsDlTaskOwner(task->appId)) {
BOOL allowed = IsDlTaskWritableGroup(task->groupId, task->flags);
if (!allowed) {
return NWC24_ERR_PROTECTED;
}
}
if (task->id != 0xffff && task->id >= header->maxTaskCount) {
return NWC24_ERR_INVALID_VALUE;
}
return NWC24_OK;
}
static inline NWC24Err ClearDlTaskError(NWC24DlTask* dlTask) {
DlTaskData* task = (DlTaskData*)dlTask;
NWC24Err result;
result = ValidateWritableDlTask(dlTask);
if (result != NWC24_OK) {
return result;
}
task->unknown_0x20 = 0;
task->unknown_0x1a = 0;
return NWC24_OK;
}
NWC24Err NWC24UpdateDlTask(NWC24DlTask* dlTask) {
DlTaskData* task = (DlTaskData*)dlTask;
DlTaskListHeader* header;
u16 taskId;
OSTime universalTime;
NWC24Err result;
result = ValidateDlTask(dlTask, TRUE);
result = ValidateWritableDlTask(dlTask);
if (result != NWC24_OK) { return result; }
taskId = task->id;
if (taskId == 0xffff || taskId >= GetCachedDlHeader()->maxTaskCount) { return NWC24_ERR_INVALID_VALUE; }
result = UpdateDlTaskAccessTime(dlTask);
if (result < NWC24_OK) { return result; }
result = ValidateDlTask(dlTask, TRUE);
if (result == NWC24_OK) {
task->unknown_0x20 = 0;
task->unknown_0x1a = 0;
}
ClearDlTaskError(dlTask);
if (task->retryEnabled == 1) {
while ((result = CheckDlTaskRetry(dlTask, task->retryCount)) == NWC24_ERR_DISABLED) {
task->retryCount = (task->retryCount + 1) & 0x1f;
@@ -1044,6 +1101,7 @@ closeList:
NWC24Err NWC24iCheckDlHeaderConsistency(DlTaskListHeader* header, BOOL repair) {
NWC24DlTask task;
NWC24DlTask* taskPointer = &task;
NWC24DlTask* readTask = &task;
NWC24DlId taskId;
NWC24Err result;
DlTaskListHeader* currentHeader;
@@ -1060,7 +1118,7 @@ NWC24Err NWC24iCheckDlHeaderConsistency(DlTaskListHeader* header, BOOL repair) {
if (currentHeader->entries[taskId].appId == 0) { result = NWC24_ERR_NOT_FOUND; }
}
if (result != NWC24_OK || !shouldRepair) { continue; }
result = ReadDlTaskInline(taskPointer, taskId);
result = ReadDlTaskInline(readTask, taskId);
if (result < NWC24_OK) {
if (ValidateDlTask(taskPointer, FALSE) == NWC24_OK) {
result = DeleteDlTask(taskPointer);
@@ -1227,32 +1285,44 @@ NWC24Err StoreDlTask(NWC24DlTask* dlTask) {
return closeResult;
}
static inline NWC24Err ValidateDlTaskUrl(NWC24DlTask* dlTask) {
DlTaskData* task = (DlTaskData*)dlTask;
DlTaskListHeader* header = GetCachedDlHeader();
static inline NWC24Err CheckDlUrl(const DlTaskData* task) {
const char* url = task->url;
NWC24Err result;
if (task->id >= header->maxTaskCount && task->id != 0xffff) { return NWC24_ERR_INVALID_VALUE; }
{
const char* url = task->url;
result = NWC24iCheckStringLength(url, 7, 0x100);
if (result >= NWC24_OK) {
if (strncmp(url, "http://", 7) != 0 && strncmp(url, "https://", 8) != 0) { result = NWC24_ERR_FORMAT; }
else { result = NWC24_OK; }
}
if (result < NWC24_OK) { return result; }
return NWC24_OK;
result = NWC24iCheckStringLength(url, 7, 0x100);
if (result < NWC24_OK) {
return result;
}
if (strncmp(url, "http://", 7) != 0 && strncmp(url, "https://", 8) != 0) {
return NWC24_ERR_FORMAT;
}
return NWC24_OK;
}
static inline NWC24Err FindFreeDlTask(NWC24DlTask* dlTask, u16 taskCount, u16 maxTaskCount) {
static inline DlTaskEntry* GetDlTaskEntryHeader(u16 taskId) {
return &GetCachedDlHeader()->entries[taskId];
}
static inline NWC24Err ValidateDlTaskUrl(const NWC24DlTask* dlTask) {
const DlTaskData* task = (const DlTaskData*)dlTask;
NWC24Err result;
if (task->id >= GetCachedDlHeader()->maxTaskCount && task->id != 0xffff) {
return NWC24_ERR_INVALID_VALUE;
}
result = CheckDlUrl(task);
if (result < NWC24_OK) {
return result;
}
return NWC24_OK;
}
static inline NWC24Err FindFreeDlTask(NWC24DlTask* dlTask, u32 taskCount, u32 maxTaskCount) {
DlTaskListHeader* header = GetCachedDlHeader();
NWC24DlId taskId;
if (dlTask == NULL || taskCount > maxTaskCount || taskCount >= header->maxTaskCount || maxTaskCount > header->maxTaskCount) {
return NWC24_ERR_INVALID_VALUE;
}
for (taskId = taskCount; taskId < maxTaskCount; taskId++) {
header = GetCachedDlHeader();
if (header->entries[taskId].appId == 0) {
if (GetDlTaskEntryHeader(taskId)->appId == 0) {
((DlTaskData*)dlTask)->id = taskId;
return NWC24_OK;
}
@@ -1260,24 +1330,10 @@ static inline NWC24Err FindFreeDlTask(NWC24DlTask* dlTask, u16 taskCount, u16 ma
return NWC24_ERR_FULL;
}
static inline NWC24Err UpdateDlTaskInline(NWC24DlTask* dlTask) {
DlTaskData* task = (DlTaskData*)dlTask;
DlTaskListHeader* header;
u16 taskId;
OSTime universalTime;
NWC24Err result;
result = ValidateDlTask(dlTask, TRUE);
if (result != NWC24_OK) { return result; }
taskId = task->id;
if (taskId == 0xffff || taskId >= GetCachedDlHeader()->maxTaskCount) { return NWC24_ERR_INVALID_VALUE; }
result = UpdateDlTaskAccessTime(dlTask);
if (result < NWC24_OK) { return result; }
result = ValidateDlTask(dlTask, TRUE);
if (result == NWC24_OK) {
task->unknown_0x20 = 0;
task->unknown_0x1a = 0;
}
static inline NWC24Err RetryAndStoreDlTask(NWC24DlTask* dlTask) {
DlTaskData* task = (DlTaskData*)dlTask;
NWC24Err result;
if (task->retryEnabled == 1) {
while ((result = CheckDlTaskRetry(dlTask, task->retryCount)) == NWC24_ERR_DISABLED) {
task->retryCount = (task->retryCount + 1) & 0x1f;
@@ -1286,6 +1342,19 @@ static inline NWC24Err UpdateDlTaskInline(NWC24DlTask* dlTask) {
}
return StoreDlTask(dlTask);
}
static inline NWC24Err UpdateDlTaskInline(NWC24DlTask* dlTask) {
DlTaskData* task = (DlTaskData*)dlTask;
NWC24Err result;
result = ValidateWritableDlTask(dlTask);
if (result != NWC24_OK) { return result; }
if (task->id == 0xffff || task->id >= GetCachedDlHeader()->maxTaskCount) { return NWC24_ERR_INVALID_VALUE; }
result = UpdateDlTaskAccessTime(dlTask);
if (result < NWC24_OK) { return result; }
ClearDlTaskError(dlTask);
return RetryAndStoreDlTask(dlTask);
}
NWC24Err AddTaskInternal(NWC24DlTask* dlTask, u16 taskCount, u16 maxTaskCount) {
DlTaskData* task = (DlTaskData*)dlTask;
NWC24Err result;

View File

@@ -73,22 +73,28 @@ NWC24Err NWC24ReadMsgSubjectPublic(const NWC24MsgObj* msg, u16* subject, u32* su
truncated = TRUE;
}
result = NWC24ReadMsgSubject(msg, (char*)work, subjectDataSize);
if (result != NWC24_OK) {
if (result == NWC24_ERR_OVERFLOW) {
truncated = TRUE;
} else {
goto done;
}
switch (result) {
case NWC24_OK:
break;
default:
if (result == NWC24_ERR_OVERFLOW) {
truncated = TRUE;
break;
}
return result;
}
charsetBuffer = NWC24WorkP->stringWork;
result =
NWC24DecodeMIMEHeaderFieldBody((u8*)charsetBuffer, 0x40, decodedData, decodedCapacity, &decodedSize, work, subjectDataSize);
if (result != NWC24_OK) {
if (result == NWC24_ERR_OVERFLOW) {
truncated = TRUE;
} else {
goto done;
}
switch (result) {
case NWC24_OK:
break;
default:
if (result == NWC24_ERR_OVERFLOW) {
truncated = TRUE;
break;
}
return result;
}
*subjectSize = originalSize;
result =
@@ -140,11 +146,15 @@ NWC24Err NWC24ReadMsgTextPublic(const NWC24MsgObj* msg, u16* text, u32* textSize
}
charsetBuffer = NWC24WorkP->stringWork + 0x20;
result = NWC24ReadMsgTextEx(msg, (char*)work, textDataSize, charsetBuffer, 0x40);
if (result != NWC24_OK) {
if (result != NWC24_ERR_OVERFLOW) {
goto done;
}
truncated = TRUE;
switch (result) {
case NWC24_OK:
break;
default:
if (result == NWC24_ERR_OVERFLOW) {
truncated = TRUE;
break;
}
return result;
}
*textSize = originalSize;
@@ -233,11 +243,12 @@ NWC24Err NWC24SetMsgSubjectAndTextPublic(NWC24MsgObj* msg, const u16* subject, u
NWC24MsgObjPrivate* privateMsg = (NWC24MsgObjPrivate*)msg;
NWC24Work* nwcWork;
u32 textSourceSize;
u32 textCapacity;
u32 textWorkSize;
BOOL is7Bit;
NWC24Charset charset;
u32 subjectWorkSize;
u8* subjectWork;
u32 subjectWorkSize;
NWC24Err result;
if (((privateMsg->type & 0x100) == 0) || ((privateMsg->type & 0x200) != 0)) {
@@ -273,7 +284,8 @@ NWC24Err NWC24SetMsgSubjectAndTextPublic(NWC24MsgObj* msg, const u16* subject, u
if (NWC24ParseCharsetStr(&charset, nwcWork->stringWork) != NWC24_OK) {
charset = 0;
}
textWorkSize = (workSize * textSize) / (textSize + subjectSize * 4);
textCapacity = (workSize * textSize) / (textSize + subjectSize * 4);
textWorkSize = textCapacity;
subjectWorkSize = workSize - textWorkSize;
subjectWork = work + textWorkSize;
textSourceSize = textSize;

View File

@@ -242,14 +242,63 @@ BOOL BS2IsDiagDisc() { return (u8)(*(u8 *)OSPhysicalToCached(OS_ADDR_BOOT_INFO)
extern vu32 BS2VideoMode;
extern vu32 __DVDLayoutFormat;
void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
u8 *block = start;
for (; blockCount != 0; --blockCount) {
__dcbz(block, 0);
__dcbf(block, 0);
block += 32;
}
((void (*)(u32))entryPoint)(argument);
asm void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
// clang-format off
#ifdef __MWERKS__
nofralloc
mtctr r5
mtlr r3
li r0, 0
li r2, 0
li r3, 0
li r5, 0
li r7, 0
li r8, 0
li r9, 0
li r10, 0
li r11, 0
li r12, 0
li r13, 0
li r14, 0
li r15, 0
li r16, 0
li r17, 0
li r18, 0
li r19, 0
li r20, 0
li r21, 0
li r22, 0
li r23, 0
li r24, 0
li r25, 0
li r26, 0
li r27, 0
li r28, 0
li r29, 0
li r30, 0
li r31, 0
// The application stack is fixed; it is unrelated to the formatter.
lis r1, 0x8160
ori r1, r1, 0
li r6, 0
b Run_loop_entry
Run_loop:
dcbz r4, r0
dcbf r4, r0
addi r4, r4, 0x20
bdnz Run_loop
b Run_done
Run_done:
li r4, 0
blr
Run_loop_entry:
b Run_loop
#endif
// clang-format on
}
BOOL BS2GetLockedTitles(ESTitleId *pTitleIds, u32 *count) {
@@ -439,7 +488,7 @@ BOOL BS2StartLoadingTitle(ESTitleId titleId, ESTicketView *pTicketView) {
return FALSE;
}
void callback(s32 result) { LowReadResult = result; }
static void callback(u32 result) { LowReadResult = result; }
ESError BS2ESGetTicketViews(IOSFd *descriptor, ESTitleId titleId, ESTicketView *views, u32 *count) {
struct {
@@ -676,7 +725,7 @@ void BS2StartGame() {
BS2Report("DVDLowInit done\n");
LowReadResult = 0;
DVDLowReadDiskID(&DiskID, (DVDLowCallback)callback);
DVDLowReadDiskID(&DiskID, callback);
while (LowReadResult == 0) {
}
@@ -690,7 +739,7 @@ void BS2StartGame() {
} else {
OSReport("\nDisk error(%d) has occurred", LowReadResult);
LowReadResult = 0;
DVDLowRequestError((DVDLowCallback)callback);
DVDLowRequestError(callback);
while (LowReadResult == 0) {
}
driveError = DVDLowGetImmBufferReg() & 0xFF000000;
@@ -720,10 +769,10 @@ disk_done:
if (PartitionParams.numTmdBytes != 0) {
DVDLowOpenPartitionWithTmdAndTicketView((u32)((DVDPartitionInfo *)GamePartition)->partition, &PartitionParams.ticketView,
PartitionParams.numTmdBytes, &PartitionParams.tmd, PartitionParams.numCertBytes,
PartitionParams.certificates, (DVDLowCallback)callback);
PartitionParams.certificates, callback);
} else {
DVDLowOpenPartition((u32)((DVDPartitionInfo *)GamePartition)->partition, NULL, 0, NULL, &PartitionParams.tmd,
(DVDLowCallback)callback);
callback);
}
while (LowReadResult == 0) {
}
@@ -741,7 +790,7 @@ disk_done:
} else {
OSReport("\nDisk error(%d) has occurred", LowReadResult);
LowReadResult = 0;
DVDLowRequestError((DVDLowCallback)callback);
DVDLowRequestError(callback);
while (LowReadResult == 0) {
}
driveError = DVDLowGetImmBufferReg() & 0xFF000000;
@@ -803,7 +852,7 @@ void BS2StartGCGame() {
OSTime time;
StartingGame = TRUE;
while (DVDGetCommandBlockStatus(&CoverBlock) != DVD_STATE_IDLE) {
while (CoverBlock.state != DVD_STATE_IDLE) {
}
soundMode = SCGetSoundMode();
@@ -1308,9 +1357,10 @@ BS2State BS2Tick() {
(*(u32 *)0x800030d4) = 0;
DvdTransferred = 0;
DvdTransferLength = 0;
status = BS2NoDisk;
AudioBufferUnconfigured = 1;
CoverBlock.state = 0;
if (BS2NoDisk != 0)
if (status != 0)
State = BS2_STT_NO_DISK;
else if (BS2DriveReset != 0)
State = BS2_STT_2;
@@ -1796,21 +1846,24 @@ invalidRvlRegion:
State = BS2_STT_RESET_SYSTEM;
break;
}
if (GamePartition == 0) {
if (GamePartition != 0) {
State = BS2_STT_37;
} else {
State = BS2_STT_54;
break;
}
State = BS2_STT_37;
case 0x25:
case 0x25: {
u32 partitionOffset = (u32)((DVDPartitionInfo *)GamePartition)->partition;
if (BS2BootFromCache != 0) {
BS2Report("Open partition from cache.dat\n");
NandPending = 1;
BS2NANDDivideReadAsync(&BS2CacheFileInfo, &PartitionParams.tmd, 0x4a00, BS2NANDCallback, &BS2NandBlock);
} else
DVDOpenPartitionAsync(&Block, &PartitionParams.tmd, (u32)((DVDPartitionInfo *)GamePartition)->partition, BS2DVDCallback);
DVDOpenPartitionAsync(&Block, &PartitionParams.tmd, partitionOffset, BS2DVDCallback);
PartitionOpen = 1;
State = BS2_STT_38;
break;
}
case 0x26: {
status = CheckBS2CommandStatus();
if (status == 0)
@@ -1837,13 +1890,16 @@ invalidRvlRegion:
titlePrefix = titleCode >> 0x18;
titleCharacters[3] = (u8)titleCode;
titleCharacters[0] = (char)(titleCode >> 0x18);
if (titlePrefix < 'R') {
if (titlePrefix == 'D')
goto check_title_region;
} else if (titlePrefix < 'U')
switch (titlePrefix) {
case 'D':
case 'R':
case 'S':
case 'T':
goto check_title_region;
regionMatches = TRUE;
goto title_region_checked;
default:
regionMatches = TRUE;
goto title_region_checked;
}
{
check_title_region:
if (titleCharacters[3] == 0x41) {
@@ -2001,8 +2057,8 @@ invalidRvlRegion:
if (status == 0)
OSPanic("BS2Mach.c", 0x12c8, "BS2 ERROR >>> Cannnot alloc 0x%08x from MEMAllocator", bannerFile.length);
BannerLength = bannerFile.length;
BannerBuffer = OSRoundDown32B(BannerAllocation) + 32;
BS2Report("BannerBufferAddr : %08X\n");
BannerBuffer = BannerAllocation + 32 - BannerAllocation % 32;
BS2Report("BannerBufferAddr : %08X\n", BannerBuffer);
} else {
if ((BannerBuffer != 0) && (BannerLength != 0)) {
if (BannerLength < ((bannerFile.length + 0x1fU) & 0xffffffe0))

View File

@@ -23,10 +23,10 @@ s32 WADImportDVDForBS(const char* path, void* buffer, u32 length);
s32 WADImportDVDExForBS(const char* path, void* buffer, u32 length);
static BS2UpdateEntry* pEntries = NULL;
static u32 EntriesCount = 0;
static volatile u32 EntriesCount = 0;
static u32* pFlags = NULL;
static void* MemAllocator = NULL;
int State = 0;
volatile int State = 0;
BS2UpdateEntry* CurrentEntry = 0;
static u32 RebootRequired = 0;
static BOOL ContainsSeatTitles = 0;
@@ -77,7 +77,8 @@ void BS2UpdateInit(void* allocator) {
OSResumeThread(&Thread);
}
static void* UpdateThread(void* argument) {
static inline u32 BS2SelectUpdateEntries(void) {
BOOL missingFile;
u32 selectedCount;
u32 requiredBytes;
@@ -89,7 +90,6 @@ static void* UpdateThread(void* argument) {
u32 selectedSeatCount;
BOOL regionValid;
u32 titleRegion;
s32 importResult;
struct {
u32 freeChannels;
u32 freeBlocks;
@@ -102,9 +102,6 @@ static void* UpdateThread(void* argument) {
DVDFileInfo file;
} scratch;
BS2Report("Start update thread\n");
StartUpdate = 0;
CancelUpdate = 0;
missingFile = FALSE;
selectedCount = 0;
requiredBytes = 0;
@@ -162,12 +159,12 @@ product_region_checked:
if (!regionValid) {
BS2Report("Error: failed to check product region.");
selectedCount = 0;
goto selection_done;
goto selection_complete;
}
if (!SCGetProductAreaString(scratch.productArea, sizeof(scratch.productArea))) {
BS2Report("Error: failed to get product information.");
selectedCount = 0;
goto selection_done;
goto selection_complete;
}
strcpy(scratch.updatePath, "__update.inf");
strcat(scratch.updatePath, ".");
@@ -183,46 +180,46 @@ product_region_checked:
if (DVDConvertPathToEntrynum(scratch.updatePath) < 0) {
BS2Report("Error: update information file is not found.");
selectedCount = 0;
goto selection_done;
goto selection_complete;
}
break;
default:
BS2Report("Error: update information file is not found.");
selectedCount = 0;
goto selection_done;
goto selection_complete;
}
}
BS2Report("%s is found.\n", scratch.updatePath);
if (!DVDOpen(scratch.updatePath, &scratch.file)) {
BS2Report("Error: failed to open update information file.");
selectedCount = 0;
goto selection_done;
goto selection_complete;
}
if (DVDReadPrio(&scratch.file, &UpdateHeader0, sizeof(UpdateHeader0), 0, 2) < 0) {
BS2Report("Error: failed to read update information header.");
selectedCount = 0;
goto selection_done;
goto selection_complete;
}
if (UpdateHeader0.wadCount == 0) {
BS2Report("Error: no entry.");
selectedCount = 0;
goto selection_done;
goto selection_complete;
}
if (UpdateHeader0.wadCount > 32) {
BS2Report("Error: found too many entries.");
selectedCount = 0;
goto selection_done;
goto selection_complete;
}
UpdateHeader0.wadCount += UpdateHeader0.extraCount;
if (UpdateHeader0.wadCount > BS2_UPDATE_ENTRY_COUNT) {
BS2Report("Error: found too many extra entries.");
selectedCount = 0;
goto selection_done;
goto selection_complete;
}
if (DVDReadPrio(&scratch.file, UPDATE_DISC_ENTRIES, UpdateHeader0.wadCount * sizeof(BS2UpdateEntry), 32, 2) < 0) {
BS2Report("Error: failed to read update information.");
selectedCount = 0;
goto selection_done;
goto selection_complete;
}
{
BS2UpdateEntry *discEntries = UPDATE_DISC_ENTRIES;
@@ -245,7 +242,7 @@ product_region_checked:
BS2Report("Cannot get physical MEM2 size\n");
State = 5;
selectedCount = 0;
goto selection_done;
goto selection_complete;
}
if (DVDOpen(discEntries[index].path, &scratch.file) < 0) {
BS2Report("%s is not found\n", discEntries[index].path);
@@ -305,8 +302,10 @@ product_region_checked:
BS2Report("Error: found too many extra entries.");
goto seats_done;
}
seatEntries = &UPDATE_DISC_ENTRIES[UpdateHeader0.wadCount];
selectedSeats = &EntriesToImport[selectedCount];
seatEntries = UPDATE_DISC_ENTRIES;
seatEntries += UpdateHeader0.wadCount;
selectedSeats = EntriesToImport;
selectedSeats += selectedCount;
if (DVDReadPrio(&scratch.file, seatEntries, UpdateHeader1.wadCount * sizeof(BS2UpdateEntry), 32, 2) < 0) {
BS2Report("Error: failed to read update information.");
goto seats_done;
@@ -408,7 +407,7 @@ seats_done:
if (missingFile) {
State = 5;
selectedCount = 0;
goto selection_done;
goto selection_complete;
}
pEntries = EntriesToImport;
pFlags = Flags1;
@@ -424,8 +423,17 @@ seats_done:
}
}
}
selection_done:
EntriesCount = selectedCount;
selection_complete:
return selectedCount;
}
static void* UpdateThread(void* argument) {
u32 index;
s32 importResult;
BS2Report("Start update thread\n");
StartUpdate = 0;
CancelUpdate = 0;
EntriesCount = BS2SelectUpdateEntries();
if (EntriesCount == 0) {
State = 5;
StartUpdate = 0;
@@ -449,7 +457,7 @@ selection_done:
UpdateProgress++;
continue;
}
if (discEntries[UpdateProgress].type == 1) {
if (((const BS2UpdateEntry *)discEntries)[UpdateProgress].type == 1) {
BS2Report("BS2WADImportDVD : ");
index = UpdateProgress;
if (strcmp(getSuffix(discEntries[index].path), "wad") == 0) {
@@ -502,8 +510,8 @@ selection_done:
} else {
State = 3;
}
UpdateProgress++;
CurrentEntry = NULL;
UpdateProgress++;
break;
}
} else if (CancelUpdate != 0) {

View File

@@ -19,10 +19,10 @@
typedef struct {
u64 work[0xD0 / sizeof(u64)];
} NETHMACContext;
static const void* NETGetSHA1Interface(void);
static void NETHMACInit(NETHMACContext* ctx, const void* interface, const void* key, u32 keyLen);
static void NETHMACUpdate(NETHMACContext* ctx, const void* data, u32 len);
static void NETHMACGetDigest(NETHMACContext* ctx, void* digest);
extern const void* NETGetSHA1Interface(void);
extern void NETHMACInit(NETHMACContext* ctx, const void* interface, const void* key, u32 keyLen);
extern void NETHMACUpdate(NETHMACContext* ctx, const void* data, u32 len);
extern void NETHMACGetDigest(NETHMACContext* ctx, void* digest);
extern char VmReportFormat[];
#define CHANSVmDebugLength 1024
@@ -54,7 +54,6 @@ const u64 VmMinusInf = 0xFFF0000000000000ULL;
#define VM_READ_BE_U16(b, o) ((u16)((b)[(o)] << 8 | (b)[(o) + 1]))
#define VM_READ_BE_U24(b, o) ((u32)((b)[(o)] << 16 | (b)[(o) + 1] << 8 | (b)[(o) + 2]))
#define VM_MAKE_U64(hi, lo) ((u64)(u32)(hi) << 32 | (u64)(lo))
#define VM_S64_FROM_U64(v) ((s64)(u32)((v) >> 32) << 32 | (u64)(u32)(v))
void CHANSVmDebugPrintf(const vmString format, ...) {
va_list args;
@@ -1414,7 +1413,7 @@ CHANSVmErr VmCmpGeq(CHANSVm* vm, CHANSVmObjType type, CHANSVmObjHdr* ret, CHANSV
return VmCmpLeq(vm, type, ret, right, left);
}
CHANSVmErr CHANSVmGetBoolean(CHANSVmObjHdr* ret, CHANSVmObjHdr* val) {
CHANSVmErr CHANSVmGetBoolean(vmBoolInt* ret, CHANSVmObjHdr* val) {
vmBoolInt result;
switch (val->type) {
case CHANS_VM_OBJ_TYPE_BLANK: {
@@ -1448,7 +1447,7 @@ CHANSVmErr CHANSVmGetBoolean(CHANSVmObjHdr* ret, CHANSVmObjHdr* val) {
}
}
if (ret != vmNull) {
ret->value.bool_v = result;
*ret = result;
}
return CHANS_VM_OK;
}
@@ -3070,20 +3069,22 @@ VmMethodDefine(String, Search) {
return VmStringObjectIndex(VmInst, VmParentObj, VmReturnObj, 1, 1);
}
VmMethodDefine(String, Replace) {
static inline vmBoolInt VmReplaceStringContents(CHANSVm *VmInst, const CHANSVmObjHdr *VmParentObj, CHANSVmObjHdr *VmReturnObj) {
CHANSVmObjHdr* arg0;
CHANSVmObjHdr* arg1;
vmString parentStr;
vmString searchStr;
vmString replaceStr;
u32 parentLen;
u32 srcOffs;
u32 dstOffs;
u32 searchLen;
u32 replaceLen;
u32 dstBufLen;
vmString searchStr;
vmString parentStr;
vmString newStr;
u32 dstBufLen;
u32 replaceLen;
u32 dstOffs;
CHANSVmObjHdr* arg1;
u32 searchLen;
u32 srcOffs;
u32 parentLen;
u32 segLen;
const vmStringObjVal *parentValue;
const vmStringObjVal *searchValue;
if (((CHANSVmPrivate*)VmInst)->pActiveCtx->argc < 2) {
goto return_input;
@@ -3098,10 +3099,12 @@ VmMethodDefine(String, Replace) {
goto return_input;
}
parentLen = VmParentObj->value.string_v->len;
searchLen = arg0->value.string_v->len;
parentStr = VmParentObj->value.string_v->spData;
searchStr = arg0->value.string_v->spData;
parentValue = VmParentObj->value.string_v;
searchValue = arg0->value.string_v;
parentLen = parentValue->len;
searchLen = searchValue->len;
parentStr = parentValue->spData;
searchStr = searchValue->spData;
replaceStr = arg1->value.string_v->spData;
replaceLen = arg1->value.string_v->len;
@@ -3169,12 +3172,16 @@ VmMethodDefine(String, Replace) {
return VmReturnObj->value.string_v->len == dstOffs ? vmTrue : vmFalse;
return_input:
return VmStringObjectDup(VmInst, VmReturnObj, VmParentObj) ? vmTrue : vmFalse;
return VmStringObjectDup(VmInst, VmReturnObj, (CHANSVmObjHdr *)VmParentObj) ? vmTrue : vmFalse;
error:
return 0;
}
VmMethodDefine(String, Replace) {
return VmReplaceStringContents(VmInst, VmParentObj, VmReturnObj);
}
VmMethodDefine(String, Splice) {
CHANSVmObjHdr* arg0;
CHANSVmObjHdr* arg1;
@@ -5133,7 +5140,7 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
goto error;
}
argCount++;
totalSize += (count + 1) / 2;
totalSize += (s32)((u32)count + 1U) / 2;
break;
}
}
@@ -5423,7 +5430,7 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
goto error;
}
bufSize = (count + 1) / 2;
bufSize = (s32)((u32)count + 1U) / 2;
if (!CHANSVmBlobHasSpace(parentBlob, bufSize)) {
goto error;
}
@@ -6929,7 +6936,7 @@ static u8* VmGetOperand(CHANSVm* vm, u32 num, u32 offset) {
}
static CHANSVmErr VmLoadImmInteger(CHANSVm* vm, CHANSVmObjHdr* obj, u8* buf, s32 count) {
s64 acc = 0;
u64 acc = 0;
u8* p = buf;
while (count != 0) {
@@ -6939,7 +6946,7 @@ static CHANSVmErr VmLoadImmInteger(CHANSVm* vm, CHANSVmObjHdr* obj, u8* buf, s32
count--;
}
return CHANSVmSetInteger(vm, obj, acc);
return CHANSVmSetInteger(vm, obj, (vmInteger)acc);
}
CHANSVmErr VmStore(CHANSVm* vm, CHANSVmObjHdr* dest, CHANSVmObjHdr* src) {
@@ -7207,7 +7214,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
u32 cmpLow;
struct {
CHANSVmObjType operandTypes[2];
u64 floatBits;
double floatLiteral;
CHANSVmObjHdr copies[2];
CHANSVmObjHdr load;
CHANSVmObjHdr operand;
@@ -7234,7 +7241,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
CHANSVmErr result;
u32 newPos;
u32 isTypeMatch;
u32 shouldBranch;
vmBoolInt shouldBranch;
if (pVm->bSignalUpdated != vmFalse && pVm->bSignalBlocked == vmFalse) {
pVm->bSignalUpdated = vmFalse;
@@ -7291,8 +7298,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
case CHANS_VM_OP_LOAD_FLOAT: {
opSize = 9;
operandBuf = VmGetOperand(vm, 1, 9);
memcpy(&scratch.floatBits, operandBuf, 8);
result = CHANSVmSetFloat(vm, &pVm->accumulator, *(double*)&scratch.floatBits);
memcpy(&scratch.floatLiteral, operandBuf, 8);
result = CHANSVmSetFloat(vm, &pVm->accumulator, scratch.floatLiteral);
break;
}
@@ -7623,8 +7630,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
case CHANS_VM_OP_LOG_NOT: {
CHANSVmObjHdr* pAcc = &pVm->accumulator;
u32 bResult;
CHANSVmErr booleanResult = CHANSVmGetBoolean((CHANSVmObjHdr*)&bResult, pAcc);
vmBoolInt bResult;
CHANSVmErr booleanResult = CHANSVmGetBoolean(&bResult, pAcc);
if (booleanResult == CHANS_VM_OK) {
s32 boolVal = bResult ? 0 : 1;
booleanResult = CHANSVmSetInteger(vm, pAcc, boolVal);
@@ -7769,8 +7776,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
arrayIdx = (u32)stackPtr->value.int_v;
goto set_index_ok;
case CHANS_VM_OBJ_TYPE_FLOAT: {
double stackFloat = *(double*)stackPtr;
if (stackFloat <= 4294967294.0 && 0.0 <= stackFloat) {
double stackFloat = stackPtr->value.float_v;
if (stackFloat >= 0.0 && stackFloat <= 4294967294.0) {
arrayIdx = (u32)stackFloat;
goto set_index_ok;
}
@@ -7781,8 +7788,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
cmpHigh = 0;
cmpLow = -2;
cmpVal = VM_MAKE_U64(cmpHigh, cmpLow);
fullVal = VM_S64_FROM_U64(tmp64);
if ((u64)fullVal <= cmpVal) {
if (tmp64 <= cmpVal) {
arrayIdx = (u32)tmp64;
goto set_index_ok;
}
@@ -8004,34 +8010,27 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
if (pVm->pActiveCtx->stackDepth != 0 && pVm->pObjStackTopBuf + sizeof(CHANSVmObjHdr) <= pVm->pHeapEnd) {
CHANSVmObjHdr* stackTop = (CHANSVmObjHdr*)pVm->pObjStackTopBuf;
isTypeMatch = 0;
if (pVm->accumulator.type == stackTop->type) {
if (stackTop->type == pVm->accumulator.type) {
switch (stackTop->type) {
case CHANS_VM_OBJ_TYPE_INTEGER: {
u32 low1 = *(u32*)stackTop;
u32 low2 = *(u32*)&pVm->accumulator;
u32 high1 = *((u32*)stackTop + 1);
u32 high2 = *((u32*)&pVm->accumulator + 1);
u32 xor1 = low1 ^ low2;
u32 xor2 = high1 ^ high2;
isTypeMatch = !(xor1 | xor2);
isTypeMatch = stackTop->value.int_v == pVm->accumulator.value.int_v;
goto end_branch_check;
}
case CHANS_VM_OBJ_TYPE_FLOAT: {
double stackFloat = stackTop->value.float_v;
double accFloat = pVm->accumulator.value.float_v;
isTypeMatch = stackFloat == accFloat ? 1 : 0;
isTypeMatch = stackTop->value.float_v == pVm->accumulator.value.float_v;
goto end_branch_check;
}
case CHANS_VM_OBJ_TYPE_STRING: {
u32 len1, len2;
CHANSVmObjHdr* stackObj = (CHANSVmObjHdr*)pVm->pObjStackTopBuf;
const vmWStringObjVal* accumulatorString = pVm->accumulator.value.wstring_v;
const vmWStringObjVal* stackString = stackTop->value.wstring_v;
u32 strEqual;
isTypeMatch = 0;
len1 = stackObj->value.wstring_v->len;
len2 = pVm->accumulator.value.wstring_v->len;
len1 = stackString->len;
len2 = accumulatorString->len;
if (len1 == len2) {
strEqual = 0;
if (len1 == 0 || memcmp(stackObj->value.wstring_v->spData, pVm->accumulator.value.wstring_v->spData, len1) == 0) {
if (len1 == 0 || memcmp(stackString->spData, accumulatorString->spData, len1) == 0) {
strEqual = 1;
}
if (strEqual) {
@@ -8072,14 +8071,14 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
break;
}
case CHANS_VM_OP_BRANCH_FALSE: {
result = CHANSVmGetBoolean((CHANSVmObjHdr*)&shouldBranch, &pVm->accumulator);
result = CHANSVmGetBoolean(&shouldBranch, &pVm->accumulator);
if (result == CHANS_VM_OK) {
shouldBranch = !shouldBranch;
}
break;
}
case CHANS_VM_OP_BRANCH_TRUE: {
result = CHANSVmGetBoolean((CHANSVmObjHdr*)&shouldBranch, &pVm->accumulator);
result = CHANSVmGetBoolean(&shouldBranch, &pVm->accumulator);
break;
}
case CHANS_VM_OP_BRANCH_ALWAYS: {

View File

@@ -404,7 +404,9 @@ namespace textinput {
void LayoutByNW4R::createAnmPane_(MEMAllocator* allocator) {
CandidateTextAnmPane* pane;
for (u16 i = 0; i < ARRAY_LENGTH(scCandidatePaneData.panes); i++) {
u16 j;
u16 i;
for (i = 0; i < ARRAY_LENGTH(scCandidatePaneData.panes); i++) {
pane = NULL;
const PaneToAnimation& p = scCandidatePaneData.panes[i];
switch (p.type) {
@@ -433,16 +435,18 @@ namespace textinput {
nw4r::ut::List_Append(&mAnmPanes, pane);
for (u16 j = 0; j < p.count; j++) {
const AnimationFile* animation = p.pAnims[j];
void* pResource = mpMultiArcResourceAccessor->GetResource(0, p.pAnims[j]->fileName);
const char* forceAddName = p.forceAddName;
u32 animationCount = p.count;
for (j = 0; j < animationCount; j++) {
const AnimationFile* const& animation = p.pAnims[j];
void* pResource = mpMultiArcResourceAccessor->GetResource(0, animation->fileName);
AnimTransformPane* transform =
static_cast<AnimTransformPane*>(getLayout()->CreateAnimTransform(pResource, mpMultiArcResourceAccessor));
if (p.forceAddName == NULL) {
if (forceAddName == NULL) {
pane->addAnimation(allocator, animation->id, transform, false, true);
} else {
pane->forceAddAnimation(allocator, animation->id, transform, p.forceAddName, false, true);
pane->forceAddAnimation(allocator, animation->id, transform, forceAddName, false, true);
}
}
}
@@ -1082,7 +1086,7 @@ namespace textinput {
nw4r::lyt::TextBox* textPane = mpTextBoxPane[i]->getTextPane();
nw4r::lyt::Bounding* boundPane = mpBoundingPane[i]->getBoundPane();
nw4r::lyt::Size sz1 = textPane->GetSize();
textPane->SetString(L"");
textPane->SetString(scEmptyWChars);
textPane->SetVisible(false);
boundPane->SetSize(nw4r::lyt::Size(0.0f, sz1.height));
}
@@ -1683,9 +1687,9 @@ namespace textinput {
void UIOnOffButton::Create(nw4rmanager::Layout* layout) {
gui::PaneManager* mgr = layout->getPaneManager();
mpOnPictPane = mgr->searchPaneComponent("P_OnBtn");
mpOnBoundPane = mgr->searchPaneComponent("B_OnBtn");
mpOnAnmPane = static_cast<OnOffAnmPane*>(layout->searchAnmPane("P_OnBtn"));
mpOnPictPane = mgr->searchPaneComponent(scP_OnBtn);
mpOnBoundPane = mgr->searchPaneComponent(scB_OnBtn);
mpOnAnmPane = static_cast<OnOffAnmPane*>(layout->searchAnmPane(scP_OnBtn));
mpOffPictPane = mgr->searchPaneComponent(scCandidatePaneData.tail);
mpOffBoundPane = mgr->searchPaneComponent(scPaneNameTable);
mpOffAnmPane = static_cast<OnOffAnmPane*>(layout->searchAnmPane(scCandidatePaneData.tail));

View File

@@ -651,6 +651,24 @@ namespace textinput {
setLanguage(getLanguage());
}
static inline void initializeTogglePane(nw4rmanager::Layout& layout, void* const& inputModeTable,
int inputMode, const char* paneName) {
char textPaneName[17];
memset(textPaneName, 0, sizeof(textPaneName));
strncpy(textPaneName, paneName, strlen(paneName));
textPaneName[0] = 'T';
nw4r::lyt::TextBox* textPane = static_cast<nw4r::lyt::TextBox*>(layout.getPane(textPaneName));
nw4r::lyt::Pane* buttonPane = layout.getPane(paneName);
const KeySet* keySet = static_cast<const LanguageDependencyData*>(inputModeTable)->keySets[inputMode];
if (keySet == NULL) {
buttonPane->SetVisible(false);
} else {
buttonPane->SetVisible(true);
textPane->SetString(static_cast<const LanguageDependencyData*>(inputModeTable)->keySets[inputMode]->szKeySetName, 0);
}
}
void LayoutByNW4R::init() {
Base::init();
@@ -670,21 +688,7 @@ namespace textinput {
setVisible("W_ChngTag_03", true);
for (int i = 0; i < 4; ++i) {
const char* paneName = csPaneNameToggleAnimationKey[i].name;
char textPaneName[17];
memset(textPaneName, 0, sizeof(textPaneName));
strncpy(textPaneName, paneName, strlen(paneName));
textPaneName[0] = 'T';
nw4r::lyt::TextBox* textPane = static_cast<nw4r::lyt::TextBox*>(getPane(textPaneName));
nw4r::lyt::Pane* buttonPane = getPane(paneName);
const KeySet* keySet = static_cast<const LanguageDependencyData*>(mpInputModeTable)->keySets[i];
if (keySet == NULL) {
buttonPane->SetVisible(false);
} else {
buttonPane->SetVisible(true);
textPane->SetString(static_cast<const LanguageDependencyData*>(mpInputModeTable)->keySets[i]->szKeySetName, 0);
}
initializeTogglePane(*this, mpInputModeTable, i, csPaneNameToggleAnimationKey[i].name);
}
if (getLanguage() == JP) {

View File

@@ -1169,7 +1169,7 @@ void LayoutByNW4R::create(MEMAllocator* allocator, EditBuffer* editBuffer) {
setVisible("N_2line", true);
mpPaneManager->setAllComponentTriggerTarget(false);
mpPaneManager->setAllBoundingBoxComponentTriggerTarget(true);
nw4r::lyt::Pane* pane = getPane(static_cast<const LanguagePaneData*>(mpLanguageData)->textBox);
nw4r::lyt::Pane* pane = mpLayout->GetRootPane()->FindPaneByName(static_cast<const LanguagePaneData*>(mpLanguageData)->textBox, true);
if (!pane) pane = mpLayout->GetRootPane()->FindPaneByName(getLanguageTextPane() ? static_cast<const LanguagePaneData*>(mpLanguageData)->textBox : "T_2l_TextBox", true);
mpPaneManager->getPaneComponentByPane(pane)->setTriggerTarget(true);
for (u32 buttonIndex = 0; buttonIndex < 2; ++buttonIndex) {
@@ -1187,7 +1187,7 @@ void LayoutByNW4R::create(MEMAllocator* allocator, EditBuffer* editBuffer) {
const char* bindingName = button.bindingName;
count = button.count;
for (u16 animationIndex = 0; animationIndex < count; ++animationIndex) {
const InputFormAnimationFile* file = button.files[animationIndex];
const InputFormAnimationFile* const& file = button.files[animationIndex];
void* resource = mpMultiArcResourceAccessor->GetResource(0, file->fileName, NULL);
AnimTransformPane* transform = static_cast<AnimTransformPane*>(getLayout()->CreateAnimTransform(resource, mpMultiArcResourceAccessor));
if (!bindingName) animationPane->addAnimation(allocator, file->id, transform, false, true);
@@ -1254,6 +1254,13 @@ void LayoutByNW4R::calc() {
}
}
}
static inline const char* selectInputTextName(const nw4rmanager::Layout& layout, const void* const& languageData) {
if (layout.getPane(static_cast<const LanguagePaneData*>(languageData)->textBox)) {
return static_cast<const LanguagePaneData*>(languageData)->textBox;
}
return "T_2l_TextBox";
}
void LayoutByNW4R::setLanguage(Language language) {
Base::setLanguage(language);
if (language == CN) mpLanguageData = &csLanguageDependencyDataCHN__Q29textinput9inputform;
@@ -1264,12 +1271,12 @@ void LayoutByNW4R::setLanguage(Language language) {
else textName = static_cast<const LanguagePaneData*>(mpLanguageData)->textBox;
mpLayoutData = textName;
if (::strcmp(static_cast<const char*>(mpLayoutData), "T_2l_TextBox") != 0) setVisible("T_2l_TextBox", false);
nw4r::lyt::Pane* pane = mpLayout->GetRootPane()->FindPaneByName(getLanguageTextPane() ? static_cast<const LanguagePaneData*>(mpLanguageData)->textBox : "T_2l_TextBox", true);
nw4r::lyt::Pane* pane = mpLayout->GetRootPane()->FindPaneByName(selectInputTextName(*this, mpLanguageData), true);
static_cast<nw4r::lyt::TextBox*>(pane)->SetString(L"", 0);
const VisiblePanes* visibility = static_cast<const LanguagePaneData*>(mpLanguageData)->visibility;
for (u16 index = 0; index < visibility->visibleCount; ++index) setVisible(visibility->visibleNames[index], true);
for (u16 index = 0; index < visibility->hiddenCount; ++index) setVisible(visibility->hiddenNames[index], false);
pane = mpLayout->GetRootPane()->FindPaneByName(getLanguageTextPane() ? static_cast<const LanguagePaneData*>(mpLanguageData)->textBox : "T_2l_TextBox", true);
pane = mpLayout->GetRootPane()->FindPaneByName(selectInputTextName(*this, mpLanguageData), true);
mpPaneManager->getPaneComponentByPane(pane)->setTriggerTarget(true);
if (getPane("T_title_text")) {
nw4r::lyt::TextBox* title = nw4r::ut::DynamicCast<nw4r::lyt::TextBox*>(getPane("T_title_text"));
@@ -3071,7 +3078,9 @@ bool Base::onCursor(CursorPos* cursor) {
f32 left = glyph.rect.left + GetCursorX();
f32 top = glyph.rect.top + GetCursorY();
f32 right = glyph.rect.right + GetCursorX();
f32 bottomEdge = GetCursorY() + GetFontHeight();
f32 cursorY = GetCursorY();
f32 fontHeight = GetFontHeight();
f32 bottomEdge = fontHeight + cursorY;
candidateBackground.a = muGlobalAlpha;
debug::drawBox_(left, top, right, bottomEdge, 0.0f, 1.0f, candidateBackground);
SetupGX();
@@ -3131,7 +3140,9 @@ bool Base::onCursor(CursorPos* cursor) {
f32 left = glyph.rect.left + GetCursorX();
f32 top = glyph.rect.top + GetCursorY();
f32 right = glyph.rect.right + GetCursorX();
f32 bottomEdge = GetCursorY() + GetFontHeight();
f32 cursorY = GetCursorY();
f32 fontHeight = GetFontHeight();
f32 bottomEdge = fontHeight + cursorY;
kanaBackground.a = muGlobalAlpha;
debug::drawBox_(left, top, right, bottomEdge, 0.0f, 1.0f, kanaBackground);
SetupGX();
@@ -3177,7 +3188,7 @@ u32 Base::calcCursorPos(f32 x, f32 y) {
info.character = *string;
calcRect(info);
lineBottom = lineTop + scale.y * (info.rect.bottom - info.rect.top);
f32 right = cursorX + scale.x * (info.rect.right - info.rect.left);
f32 right = cursorX + scale.x * info.rect.GetWidth();
if (doWordWrap(mpString->getWCString(), pos, cursorX)) {
if (localY >= lineTop && localY <= lineBottom) {
if (pos != 0) return pos - 1;
@@ -3186,14 +3197,14 @@ u32 Base::calcCursorPos(f32 x, f32 y) {
lineTop += scale.y * getLineHeight();
cursorX = getScale().x;
lineBottom = lineTop + scale.y * (info.rect.bottom - info.rect.top);
right = cursorX + scale.x * (info.rect.right - info.rect.left);
right = cursorX + scale.x * info.rect.GetWidth();
}
if (right >= scale.x * (mRect.right - mRect.left)) {
if (right >= scale.x * mRect.GetWidth()) {
if (localY >= lineTop && localY <= lineBottom) return pos;
lineTop += scale.y * getLineHeight();
cursorX = getScale().x;
lineBottom = lineTop + scale.y * (info.rect.bottom - info.rect.top);
right = cursorX + scale.x * (info.rect.right - info.rect.left);
right = cursorX + scale.x * info.rect.GetWidth();
}
if (x <= info.rect.left && localY >= lineTop && localY <= lineBottom) return pos;
if (*string == L'\n') {
@@ -3207,7 +3218,7 @@ u32 Base::calcCursorPos(f32 x, f32 y) {
if (cursorX + 0.5f * (right - cursorX) > x) return pos;
return pos + 1;
}
cursorX += scale.x * (info.rect.right - info.rect.left);
cursorX += scale.x * info.rect.GetWidth();
}
++string;
++pos;

View File

@@ -5,7 +5,7 @@
extern "C" {
u8 KPRLookAhead(KPRQueue*, wchar_t*, u32);
u32 KPRPutChar(KPRQueue*, wchar_t);
u8 KPRPutChar(KPRQueue*, wchar_t);
wchar_t KPRGetChar(KPRQueue*);
void KPRClearQueue(KPRQueue*);
void KPRInitQueue(KPRQueue*);
@@ -141,6 +141,28 @@ wchar_t StringBase::getLastWChar() {
return 0;
}
namespace {
class CharacterOutput {
public:
CharacterOutput(wchar_t* output) : mpOutput(output), mCount(0) {
mpOutput[0] = 0;
}
void append(wchar_t ch) {
mpOutput[mCount++] = ch;
}
u16 finish() {
mpOutput[mCount] = 0;
return mCount;
}
private:
wchar_t* mpOutput;
u32 mCount;
};
}
void Decolated::inputChar(wchar_t ch) {
if (ch != 0xfffe) {
wchar_t input[8];
@@ -173,9 +195,9 @@ void Decolated::inputChar(wchar_t ch) {
}
nonKana:
if (mTranslateMode == 3) {
input[0] = ch;
input[1] = 0;
count = 1;
CharacterOutput output(input);
output.append(ch);
count = output.finish();
mKanaStream.mOutput[0] = 0;
} else {
count = 1;

View File

@@ -298,7 +298,6 @@ void WithZi::update() {
return;
}
wchar_t* candidateOutput = reinterpret_cast<wchar_t*>(&CandidatesBuffer[0x200]);
mSelectedCandidate = 0;
s32 elementCount = static_cast<u16>(setElementBuffer());
mSearch.language = getPredictLanguage();
@@ -307,7 +306,7 @@ void WithZi::update() {
mSearch.context = 1;
mSearch.getOptions = 0x81;
mSearch.elements = reinterpret_cast<wchar_t*>(ElementBuffer);
mSearch.candidates = candidateOutput;
mSearch.candidates = reinterpret_cast<wchar_t*>(&CandidatesBuffer[0x200]);
mSearch.maxCandidates = 0x28;
mSearch.elementCount = static_cast<u8>(elementCount);
mSearch.firstCandidate = 0;
@@ -355,25 +354,24 @@ void WithZi::update() {
ChangeDictionaryLanguage(getPredictLanguage());
u32 count = EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff;
if (getPredictLanguage() == 1 && count == 0x61) {
wchar_t* candidateOutput = reinterpret_cast<wchar_t*>(&CandidatesBuffer[0x200]);
mSearch.firstCandidate = 0x61;
mSearch.candidates = reinterpret_cast<wchar_t*>(&CandidatesBuffer[0x2c2]);
mSearch.candidates = candidateOutput + 0xC2;
mSearch.maxCandidates = 199;
count = EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff;
count += EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff;
mSearch.firstCandidate = 0;
count += 0x61;
mSearch.candidates = candidateOutput;
}
if (static_cast<s32>(count) > 0x28) {
count = 0x28;
}
if (getPredictLanguage() == 1 && mbContextChanged != 0 &&
(mbContextChanged = 0, mSearch.wordCharCount == 0)) {
(mbContextChanged = 0, mSearch.count == 0)) {
u32 length = mCurrentWordLength;
u32 wordLength = wcslen((wchar_t*)LatestWord) & 0xff;
u32 copied;
u16* source = LatestWord + wordLength - length;
for (copied = 0; copied < length; ++copied) {
LatestWord[copied] = source[copied];
LatestWord[copied] = LatestWord[(wordLength - length) + copied];
}
LatestWord[copied] = 0;
mSearch.wordCharCount = wcslen((wchar_t*)LatestWord);
@@ -409,8 +407,10 @@ void WithZi::update() {
destination[1] = 0;
} else if (getPredictLanguage() == 0x12) {
u16* output = destination;
while (*source >= 0x100) {
*output++ = *source++;
u16 character;
while ((character = *source) >= 0x100) {
*output++ = character;
++source;
}
} else if (EZTXCopy(reinterpret_cast<wchar_t*>(destination), &mSearch, index & 0xff, mpDictionaryWork) == 0) {
goto nextCandidate;
@@ -430,6 +430,8 @@ void WithZi::update() {
if (position == 0) *candidate = util::toWUpper(*candidate);
else *candidate = util::toWLower(*candidate);
break;
case LM_3:
break;
default:
break;
}

View File

@@ -1778,30 +1778,38 @@ namespace ipl {
}
}
static inline f32 GetDragNameWidth(nw4r::lyt::TextBox* textBox, const NWC24FriendInfo& info) {
f32 width = 0.0f;
if (textBox == NULL) {
return width;
}
const u16* name = info.attr.name;
if (name == NULL) {
return width;
}
textBox->GetFont()->GetWidth();
for (; *name != 0; ++name) {
width += textBox->GetFont()->GetCharWidth(*name);
}
return 0.01f + width;
}
void Address::movePane_onDrag() {
nw4r::math::VEC3 baseTrans = mpLayout->FindPaneByName("N_base_move")->GetTranslate();
math::VEC2 pos = System::getControllerManager()->getController(mDrag.mChan)->getDpdProjectionPos();
nw4r::lyt::TextBox* textBox = static_cast<nw4r::lyt::TextBox*>(mpLayout->FindPaneByName("T_name_move"));
nw4r::lyt::TextBox* textBox = static_cast<nw4r::lyt::TextBox*>(mpLayout->GetRootPane()->FindPaneByName("T_name_move", true));
f32 width = 0.0f;
if (textBox != NULL) {
const u16* name = mpFriendCache->getInfo(mDrag.mButton + mDrag.mPage * BTN_MAX).attr.name;
if (name != NULL) {
textBox->GetFont()->GetWidth();
for (; *name != 0; name++) {
width += textBox->GetFont()->GetCharWidth(*name);
}
}
}
width += 0.01f;
f32 width = GetDragNameWidth(textBox, mpFriendCache->getInfo(mDrag.mButton + mDrag.mPage * BTN_MAX));
nw4r::ut::Rect rect;
nw4r::ut::Rect rect4x3;
System::getProjectionRect(&rect);
System::getProjectionRect4x3(&rect4x3);
if (baseTrans.x + width < pos.x) {
mDragOffsetX = -((baseTrans.x + width) * (rect4x3.GetWidth() / rect.GetWidth()));
f32 rightEdge = baseTrans.x + width;
if (rightEdge < pos.x) {
rightEdge *= rect4x3.GetWidth() / rect.GetWidth();
mDragOffsetX = -rightEdge;
} else {
pos.x *= rect4x3.GetWidth() / rect.GetWidth();
mDragOffsetX = -pos.x;
@@ -1950,7 +1958,7 @@ namespace ipl {
mInfos[index].attr.fdId = fdId;
memset(mInfos[index].attr.name, 0, sizeof(mInfos[index].attr.name));
wcsncpy((wchar_t*)getInfo(index).attr.name, name, 10);
System::getNwc24Manager()->updateFriendInfo(&getInfo(index), index);
System::getNwc24Manager()->updateFriendInfo(&mInfos[static_cast<s32>(index)], index);
}
void FriendListCache::del(u32 index) {

View File

@@ -140,7 +140,6 @@ void ipl::scene::AddressEdit::reset_gui() {
}
extern "C" void* __nw__FUl(u32);
extern "C" BOOL RFLSearchOfficialData(const RFLCreateID*, u16*);
namespace ipl {
@@ -584,15 +583,10 @@ create_mode_done:
ipl::System::getKeyboard()->init();
ipl::scene::TextBalloon* balloon = reinterpret_cast<ipl::scene::TextBalloon*>(__nw__FUl(0x3c));
if (balloon != NULL) {
f32 balloonWidth = 30.0f;
f32 balloonHeight = 120.0f;
EGG::Heap* heap = getHeap();
ipl::math::VEC3 position(0.0f, 0.0f, 0.0f);
balloon = new (balloon) ipl::scene::TextBalloon(heap, mpBalloonFile, "arc", "my_IplTopBalloon_a.brlyt", position, balloonHeight, balloonWidth);
}
mpBalloon = balloon;
f32 margin4x3 = 30.0f;
f32 margin16x9 = 120.0f;
mpBalloon = new ipl::scene::TextBalloon(getHeap(), mpBalloonFile, "arc",
"my_IplTopBalloon_a.brlyt", ipl::math::VEC3(0.0f, 0.0f, 0.0f), margin16x9, margin4x3);
}
void ipl::scene::AddressEdit::stt_wait_decide_anm() {

View File

@@ -45,7 +45,7 @@ struct CardThreadState {
MEMAllocator sAllocator_;
static CardThreadState* sThread;
extern "C" void* cardThreadMain();
extern "C" void* cardThreadMain(void*);
static char sCardSlotName[3] = "AB";
FileInfo* getCardDirState() {
@@ -302,7 +302,7 @@ void initCardThread() {
OSInitMessageQueue(&sThread->responses, sThread->responseMessages, 0x10);
OSInitMessageQueue(&sThread->requests, sThread->requestMessages, 0x10);
OSCreateThread(&sThread->thread, (void* (*)(void*))cardThreadMain, 0,
OSCreateThread(&sThread->thread, cardThreadMain, 0,
sThread->stack + sizeof(sThread->stack), 0x8000, 0x11, 0);
OSResumeThread(&sThread->thread);
OSSendMessage(&sThread->requests, (OSMessage)10, 0);
@@ -408,7 +408,7 @@ static inline void sendValidityResponse(u32 command, u32 valid) {
OSSendMessage(&sThread->responses, (OSMessage)reply.value, 1);
}
extern "C" void* cardThreadMain() {
extern "C" void* cardThreadMain(void*) {
struct CardThreadLocals {
u8 compareName[6];
u32 message;
@@ -1004,27 +1004,29 @@ sectorSizeError:
sectorSizeDone:
;
result = 0;
statusResult = __CARDGetStatusEx(slot, fileNo, &checkedStatus);
if (statusResult >= 0) {
switch (command) {
case 2:
if (checkedStatus.permission & 8) {
result = -10;
{
s32 permissionResult = 0;
statusResult = __CARDGetStatusEx(slot, fileNo, &checkedStatus);
if (statusResult >= 0) {
switch (command) {
case 2:
if (checkedStatus.permission & 8) {
permissionResult = -10;
}
break;
case 3:
if (checkedStatus.permission & 0x10) {
permissionResult = -10;
}
break;
}
break;
case 3:
if (checkedStatus.permission & 0x10) {
result = -10;
}
break;
} else {
permissionResult = CARDGetResultCode(slot);
}
if (permissionResult < 0) {
reportCardThreadError(slot, command, permissionResult);
goto finish;
}
} else {
result = CARDGetResultCode(slot);
}
if (result < 0) {
reportCardThreadError(slot, command, result);
goto finish;
}
result = __CARDGetStatusEx(slot, fileNo, &createStatus);
@@ -1198,8 +1200,8 @@ copyIoDone:
renamedStatus = moveStatus;
memset(renamedStatus.company, 0, 2);
memset(renamedStatus.gameName, 0, 4);
memset(renamedStatus.fileName, 0, 0x20);
do {
memset(renamedStatus.fileName, 0, 0x20);
sprintf((char*)renamedStatus.fileName, "Broken File%03d", attempt);
result = __CARDSetStatusEx(slot, fileNo, &renamedStatus);
if (result < 0 && result != -7) {

View File

@@ -281,7 +281,11 @@ void MemoryCardManager::update_file_array(u8 slot) {
memorycard::CardState* states = memorycard::getCardSlotState();
states[slot].changed = 0;
sort_file_array(slot);
long command = mLastCmd;
enum CardCommand {
NoCommand, Format, Copy, Move, Delete,
CopyComplete, MoveComplete, DeleteComplete, FormatComplete
};
CardCommand command = static_cast<CardCommand>(mLastCmd);
if ((u32)(command - 1) <= 3) {
if (mLastResult == -0x15) {
mLastResult = memorycard::getCardLastCMDFCmdResult();

View File

@@ -1266,10 +1266,9 @@ namespace ipl {
memoPosition.x = translation.x;
memoPosition.y = translation.y;
memoPosition.z = translation.z;
f32 bodyY = memoPosition.y;
mpDialogLayout->FindPaneByName("header_header");
nw4r::lyt::Pane* bodyPane = mpDialogLayout->FindPaneByName("header_body");
f32 bodyY = memoPosition.y;
if (bodyY < 500.0f) {
mpDialogLayout->draw("header_header");
}
@@ -1282,11 +1281,11 @@ namespace ipl {
++child;
}
s32 lineCount = 0;
f32 messageOffset = 0.0f;
f32 bodyHeight = bodyPane->GetSize().height;
if (mNandTitleCount != 0) {
const wchar_t* messageForCount = System::getMessage(0xCB);
s32 lineCount = 0;
const wchar_t* newline = wcsstr(messageForCount, L"\n");
while (newline != NULL) {
++lineCount;

View File

@@ -1406,10 +1406,10 @@ namespace ipl {
getCurrentTitleUsage(&bytes, &blocks);
*titleCount = 0;
ESTitleId titleId;
for (int page = MAX_CHANNEL_PAGE - 1; page >= 0; --page) {
for (int order = 0; order < MAX_CHANNEL_INDEX; ++order) {
int channelIndex = channelOrder[order];
ESTitleId titleId;
const channel::SEntry& channelInfo =
System::getChannelManager()->mChannels[page][channelIndex];
if (channelInfo.loadedBnr) {
@@ -2710,23 +2710,19 @@ namespace ipl {
nw4r::ut::Rect projection;
System::getProjectionRect(&projection);
GXRenderModeObj* renderMode = System::getRenderModeObj();
f32 scissorWidth;
f32 scissorY;
f32 scissorX;
f32 scissorY;
f32 scissorWidth;
f32 scissorHeight;
u16 framebufferWidth;
u16 framebufferHeight;
if (mState == 7 || mState == 12 || mState == 14) {
nw4r::math::MTX44 matrix;
f32 rightScale = projection.right / mScale.x;
f32 leftScale = projection.left / mScale.x;
f32 bottomScale = projection.bottom / mScale.y;
f32 topScale = projection.top / mScale.y;
f32 bottom = mPosition.y - bottomScale;
f32 right = mPosition.x + rightScale;
f32 left = mPosition.x + leftScale;
f32 top = mPosition.y - topScale;
f32 right = mPosition.x + projection.right / mScale.x;
f32 left = mPosition.x + projection.left / mScale.x;
f32 bottom = mPosition.y - projection.bottom / mScale.y;
f32 top = mPosition.y - projection.top / mScale.y;
MTXOrtho(matrix, top, bottom, left, right, -100.0f, 100.0f);
nw4r::math::VEC4 input(position.x, position.y, 0.0f, 1.0f);
@@ -2734,14 +2730,13 @@ namespace ipl {
nw4r::math::VEC4Transform(&transformed, &matrix, &input);
framebufferWidth = renderMode->fbWidth;
framebufferHeight = renderMode->efbHeight;
scissorWidth = projection.GetWidth();
const f32 projectionWidth = projection.GetWidth();
scissorX = ((1.0f + transformed.x) * framebufferWidth / 2) -
((mThumbOffsetX * mScale.x) * (framebufferWidth / projectionWidth));
scissorY = (framebufferHeight - ((1.0f + transformed.y) * framebufferHeight / 2)) -
(mThumbOffsetY * mScale.y);
f32 widthScale = framebufferWidth / scissorWidth;
scissorX = ((1.0f + transformed.x) * framebufferWidth / 2) -
((mThumbOffsetX * mScale.x) * widthScale);
scissorWidth = 2.0f * (mThumbOffsetX * mScale.x) *
(framebufferWidth / scissorWidth);
(framebufferWidth / projectionWidth);
scissorHeight = 2.0f * (mThumbOffsetY * mScale.y);
} else {
framebufferWidth = renderMode->fbWidth;
@@ -3411,7 +3406,7 @@ namespace ipl {
case ::gui::EventHandler::ON_TRIG:
if (mpScene->mState == 1 && controller != NULL) {
BOOL writeProtected = mpScene->mpSDWorker->is_sd_write_protected();
if (controller->pinchTrg() && SDChannelSelect::isChannelReady(channel) &&
if (controller->pinchTrg() && iplSDChannelObj_hasAppMeta(channel) &&
!mpScene->mbSDCardBroken) {
if (!writeProtected) {
mpScene->startDrag(controller, mpScene->mCurrentPage, index);
@@ -3425,20 +3420,20 @@ namespace ipl {
break;
case ::gui::EventHandler::ON_DRAG:
if (mpScene->mState == 1 && controller != NULL && controller->decide() &&
SDChannelSelect::isChannelReady(channel)) {
iplSDChannelObj_hasAppMeta(channel)) {
mpScene->selectChannel(channel->getPage(), channel->getIndex());
TVRCManager::getHandle()->setEnable(FALSE);
}
break;
case ::gui::EventHandler::ON_POINT:
if (mpScene->mState == 1 && SDChannelSelect::isChannelReady(channel)) {
if (mpScene->mState == 1 && iplSDChannelObj_hasAppMeta(channel)) {
iplSDChannelObj_startAppear(channel, 0);
snd::getSystem()->startSE("WIPL_SE_CH_TARGETTING");
controller->rumble(1);
}
break;
case ::gui::EventHandler::ON_LEFT:
if (mpScene->mState == 1 && SDChannelSelect::isChannelReady(channel)) {
if (mpScene->mState == 1 && iplSDChannelObj_hasAppMeta(channel)) {
iplSDChannelObj_startDisappear(channel, 0);
}
break;

View File

@@ -167,6 +167,11 @@ typedef struct AOSSKeySchedule {
u32 length;
} AOSSKeySchedule;
typedef struct AOSSKeyMaterial {
u8 nonce[2];
u8 address[8];
} AOSSKeyMaterial;
typedef struct AOSSReceiveBuffer {
s32 socket;
u32 length;
@@ -257,8 +262,7 @@ static AOSSRuntimeState s_runtime;
static AOSSConfigData s_configData;
static u8 s_networkBuffer[0x280];
static struct {
u8 keyNonce[2];
u8 keyAddress[8];
AOSSKeyMaterial key;
u8 payload[0x5e];
} s_packetState;
static u32 s_crcTable[0x100];
@@ -284,7 +288,9 @@ extern int AOSSi_WLANGetBSSList(void** list);
extern int AOSSi_Status(int status);
extern int AOSSi_SetNCDIPAddr(u32 ipAddress, u32 netmask, u32 gateway, u32 dns1, u32 dns2);
extern int AOSSi_Sleep(u32 duration);
extern int AOSSi_WLANConnect(void);
struct AOSSConnection;
struct AOSSConnectionStatus;
extern int AOSSi_WLANConnect(struct AOSSConnection* connection, struct AOSSConnectionStatus* status);
extern int SOPoll(AOSSPollDescriptor* descriptors, int count, s32 timeoutHigh, s32 timeoutLow);
extern int SORecvFrom(int socket, void* buffer, int length, int flags, void* address);
extern int SOSendTo(int socket, const void* buffer, int length, int flags, const void* address);
@@ -617,6 +623,20 @@ int AOSS_Init_old(AOSSInitInput* input)
}
resultCode = 0xffffffff;
} else {
/* The original initialization path repeats this status check. */
if (state != 0) {
input->status = 0xf;
if (s_accessPointConfig) {
AOSSi_Free(s_accessPointConfig);
s_accessPointConfig = 0;
}
if (s_accessPointList) {
AOSSi_Free(s_accessPointList);
s_accessPointList = 0;
}
resultCode = 0xffffffff;
goto finish_initialization;
}
s_accessPointConfig = (int *)AOSSi_Alloc(0x58);
if (s_accessPointConfig == 0) {
input->status = 0xf;
@@ -724,19 +744,15 @@ handle_initial_link:
AOSSi_Free(s_accessPointList);
s_accessPointList = 0;
}
requestResult = 0;
state = 0;
do {
AOSSRequestRecord* currentRecord = &requestRecords.records[requestResult];
u16 transactionId;
memcpy(requestRecords.bytes + state,input->optionData,6);
transactionId = rand();
currentRecord->transactionId = transactionId;
receivedLength = SOHtoNs(transactionId);
currentRecord->transactionId = receivedLength;
requestResult++;
state += sizeof(AOSSRequestRecord);
} while (requestResult < 3);
{
int recordIndex;
for (recordIndex = 0; recordIndex < 3; recordIndex++) {
memcpy(requestRecords.records[recordIndex].address, input->optionData, 6);
requestRecords.records[recordIndex].transactionId = rand();
requestRecords.records[recordIndex].transactionId =
SOHtoNs(requestRecords.records[recordIndex].transactionId);
}
}
s_socket = SOSocket(2,2,0);
if (s_socket < 0) {
input->status = 0xf;
@@ -801,7 +817,7 @@ perform_request:
if (s_socketStarted == 1) {
s_socketStarted = 0;
requestResult = SOCleanup();
if (-1 < requestResult) goto request_socket_cleanup_complete;
if (requestResult >= 0) goto request_socket_cleanup_complete;
requestResult = -1;
}
else {
@@ -890,7 +906,6 @@ request_socket_cleanup_complete:
resultCode = 0xffffffff;
goto finish_initialization;
}
initialSleep = remainingWait <= 100 ? remainingWait : 100;
AOSSi_Sleep(remainingWait > 100 ? 100 : remainingWait);
if (remainingWait > 100) initialSleep = 100;
else initialSleep = remainingWait;
@@ -943,73 +958,76 @@ request_socket_cleanup_complete:
goto finish_initialization;
}
}
requestResult = s_socket;
switch (protocolState) {
case 0:
if (s_operationState != 2) {
s_operationState = 2;
AOSSi_Status(2);
}
requestResult = AOSSSendDiscoveryRequest(networkAddresses,&requestRecords,requestResult);
break;
case 1:
if (s_operationState != 3) {
s_operationState = 3;
AOSSi_Status(3);
}
requestResult = AOSSSendHelloRequest(networkAddresses,&requestRecords,requestResult);
{
int sendResult;
int requestSocket = s_socket;
switch (protocolState) {
case 0:
if (s_operationState != 2) {
s_operationState = 2;
AOSSi_Status(2);
}
sendResult = AOSSSendDiscoveryRequest(networkAddresses,&requestRecords,requestSocket);
break;
case 1:
if (s_operationState != 3) {
s_operationState = 3;
AOSSi_Status(3);
}
sendResult = AOSSSendHelloRequest(networkAddresses,&requestRecords,requestSocket);
break;
case 2:
if (s_operationState != 5) {
s_operationState = 5;
AOSSi_Status(5);
}
packetWords = s_responseBuffer;
memset(s_responseBuffer,0,0x5dc);
memcpy(messageIdentity,&requestRecords.records[2],8);
manufacturerLength = strlen(s_manufacturer);
AOSSXorBufferWithKey(messageIdentity,8,s_manufacturer,manufacturerLength);
receivedLength = SOHtoNs(1);
packetWords->initialLength = receivedLength;
packetWords->initialType = 0;
packetWords->initialSequence = 0;
packetWords->responseLength = SOHtoNs(0x3000);
packetWords->responseType = 0;
packetWords->finalLength = SOHtoNs(0);
packetWords->finalSequence = SOHtoNs(0);
packetWords->reserved = 0;
packetWords->messageType = 0x11;
memcpy(packetWords->messageIdentity,messageIdentity,8);
memset(&replyAddress,0,8);
replyAddress.family = 2;
replyAddress.port = SOHtoNs(0x5790);
replyAddress.address = SOHtoNl(s_runtime.ipAddress);
if ((s8)s_runtime.active == 0) {
replyAddress.address = 0xffffffff;
}
replyAddress.length = 8;
SOSendTo(requestResult,packetWords,0x18,0,&replyAddress);
requestResult = 0;
break;
case 2:
if (s_operationState != 5) {
s_operationState = 5;
AOSSi_Status(5);
}
packetWords = s_responseBuffer;
memset(s_responseBuffer,0,0x5dc);
memcpy(messageIdentity,&requestRecords.records[2],8);
manufacturerLength = strlen(s_manufacturer);
AOSSXorBufferWithKey(messageIdentity,8,s_manufacturer,manufacturerLength);
receivedLength = SOHtoNs(1);
packetWords->initialLength = receivedLength;
packetWords->initialType = 0;
packetWords->initialSequence = 0;
packetWords->responseLength = SOHtoNs(0x3000);
packetWords->responseType = 0;
packetWords->finalLength = SOHtoNs(0);
packetWords->finalSequence = SOHtoNs(0);
packetWords->reserved = 0;
packetWords->messageType = 0x11;
memcpy(packetWords->messageIdentity,messageIdentity,8);
memset(&replyAddress,0,8);
replyAddress.family = 2;
replyAddress.port = SOHtoNs(0x5790);
replyAddress.address = SOHtoNl(s_runtime.ipAddress);
if ((s8)s_runtime.active == 0) {
replyAddress.address = 0xffffffff;
}
replyAddress.length = 8;
SOSendTo(requestSocket,packetWords,0x18,0,&replyAddress);
sendResult = 0;
break;
default:
requestResult = -1;
break;
}
if (requestResult == -1) {
s_errorCode = protocolState + 0x1000;
input->status = 0xf;
if (s_accessPointConfig) {
AOSSi_Free(s_accessPointConfig);
s_accessPointConfig = (int *)0x0;
break;
default:
sendResult = -1;
break;
}
if (s_accessPointList) {
AOSSi_Free(s_accessPointList);
s_accessPointList = 0;
if (sendResult == -1) {
s_errorCode = protocolState + 0x1000;
input->status = 0xf;
if (s_accessPointConfig) {
AOSSi_Free(s_accessPointConfig);
s_accessPointConfig = (int *)0x0;
}
if (s_accessPointList) {
AOSSi_Free(s_accessPointList);
s_accessPointList = 0;
}
resultCode = 0xffffffff;
goto finish_initialization;
}
resultCode = 0xffffffff;
goto finish_initialization;
}
memset(packetBuffer,0,0x5f8);
pollTime.seconds = timeoutMilliseconds / 1000;
@@ -1028,10 +1046,12 @@ request_socket_cleanup_complete:
if (0 < requestResult) goto process_received_packet;
receivedPackets = receivedPackets + 1;
if (receivedPackets > attemptCount) {
switch (protocolState) {
case 0: s_errorCode = 0xf; break;
case 1: s_errorCode = 0x10; break;
default: s_errorCode = 0x11; break;
if (protocolState == 0) {
s_errorCode = 0xf;
} else if (protocolState == 1) {
s_errorCode = 0x10;
} else {
s_errorCode = 0x11;
}
protocolResult = -1;
goto close_protocol_socket;
@@ -1098,8 +1118,7 @@ process_received_packet:
}
else {
if (protocolState != requestResult) {
protocolState = requestResult;
if (requestResult != 2) goto perform_request;
if (requestResult != 2) goto advance_protocol_state;
if (s_socket != -1) {
SOClose(s_socket);
}
@@ -1237,7 +1256,8 @@ wait_for_packet:
goto finish_initialization;
}
AOSSi_Sleep(remainingWait > 100 ? 100 : remainingWait);
initialSleep = remainingWait <= 100 ? remainingWait : 100;
if (remainingWait > 100) initialSleep = 100;
else initialSleep = remainingWait;
}
if (AOSSi_cancel_flag == 1) {
input->status = 0xf;
@@ -1294,15 +1314,18 @@ wait_for_packet:
resultCode = 0xffffffff;
goto finish_initialization;
}
advance_protocol_state:
protocolState = requestResult;
goto perform_request;
}
protocolState = requestResult;
if (receivedPackets > waitSettings.halfwords.high) {
switch (requestResult) {
case 0: s_errorCode = 0xf; break;
case 1: s_errorCode = 0x10; break;
default: s_errorCode = 0x11; break;
if (requestResult == 0) {
s_errorCode = 0xf;
} else if (requestResult == 1) {
s_errorCode = 0x10;
} else {
s_errorCode = 0x11;
}
protocolResult = -1;
goto close_protocol_socket;
@@ -1322,8 +1345,7 @@ wait_for_packet:
resultCode = 0xffffffff;
goto finish_initialization;
}
if (retryDelay > 100) AOSSi_Sleep(100);
else AOSSi_Sleep(retryDelay);
AOSSi_Sleep(retryDelay > 100 ? 100 : retryDelay);
if (retryDelay > 100) delayStep = 100;
else delayStep = retryDelay;
}
@@ -1350,7 +1372,7 @@ close_protocol_socket:
if (s_socketStarted == 1) {
s_socketStarted = 0;
state = SOCleanup();
if (-1 < state) goto protocol_socket_cleanup_complete;
if (state >= 0) goto protocol_socket_cleanup_complete;
state = -1;
}
else {
@@ -1884,10 +1906,9 @@ int AOSSDecryptMessage(AOSSDecryptionMessage* message) {
s_errorCode = 2;
result = -1;
} else {
memcpy(s_packetState.keyNonce, &encrypted->keyNonce, sizeof(encrypted->keyNonce));
memcpy(s_packetState.keyAddress, s_accessPointName, sizeof(s_accessPointName));
AOSSInitKeySchedule(&schedule, s_packetState.keyNonce,
sizeof(s_packetState.keyNonce) + sizeof(s_packetState.keyAddress), dataLength);
memcpy(s_packetState.key.nonce, &encrypted->keyNonce, sizeof(encrypted->keyNonce));
memcpy(s_packetState.key.address, s_accessPointName, sizeof(s_accessPointName));
AOSSInitKeySchedule(&schedule, (const u8*)&s_packetState.key, sizeof(s_packetState.key), dataLength);
outputCursor = decryptedData;
inputCursor = encrypted->data;
@@ -2359,10 +2380,9 @@ int AOSSSendHelloRequest(void* packet, void* request, int socket) {
if (construction.schedule.bytes != 0) {
nonce = (u16)rand();
memcpy(&payload->encrypted.key.nonce, &nonce, 2);
memcpy(s_packetState.keyNonce, payload->encrypted.key.nonceBytes, 2);
memcpy(s_packetState.keyAddress, s_accessPointName, 8);
AOSSInitKeySchedule(&construction.schedule, s_packetState.keyNonce,
sizeof(s_packetState.keyNonce) + sizeof(s_packetState.keyAddress), 8);
memcpy(s_packetState.key.nonce, payload->encrypted.key.nonceBytes, 2);
memcpy(s_packetState.key.address, s_accessPointName, 8);
AOSSInitKeySchedule(&construction.schedule, (const u8*)&s_packetState.key, sizeof(s_packetState.key), 8);
for (index = 0; index < 8; index++) {
state = construction.schedule.bytes;
firstIndex = (construction.schedule.i + 1) % construction.schedule.length & 0xff;
@@ -2546,7 +2566,7 @@ int AOSSConnectAndAwaitHost(void* settings, void* config) {
s32 connectionAttempts = 0;
u32 ticksPerMillisecond;
if (AOSSi_WLANConnect() != 0) {
if (AOSSi_WLANConnect(settings, config) != 0) {
return -1;
}

View File

@@ -126,7 +126,7 @@ int AOSSi_EndLocal(void) {
return 0;
}
int AOSSi_WLANGetBSSList(struct AOSSAccessPointList** output) {
int AOSSi_WLANGetBSSList(void** output) {
int result = -1;
int startupRetries = 0;
WDScanParam scan ATTRIBUTE_ALIGN(32);

View File

@@ -542,7 +542,7 @@ s32 gAtermState;
void ATERMAlarmWakeQueue(OSAlarm* alarm, OSContext* context);
s32 ATERMRunConfigProtocol(void);
void ATERMMd5Update(AtermMd5Context* context, void* input, u32 length);
void ATERMMd5Update(AtermMd5Context* context, u8* input, u32 length);
extern u8 gAtermDigestFill[64];
extern u8* gAtermRequestOptions;
int ATERMAesKeyWrap(u16* destination, u16* source, u32 length, void* key, u32 keyLength);
@@ -1442,8 +1442,6 @@ s32 ATERMRunConfigProtocol(void) {
AtermSocketAddress peerAddress;
AtermThreadBuffer* response = (AtermThreadBuffer*)&gAtermConfigurationResult.responseLength;
void* sessionKey = gAtermResponseBuffer.session.keyMaterial;
AtermMd5Context digestContext;
u8 digestLength[8];
s32 socket = 0;
s32 result = -5;
s32 failed = 0;
@@ -1617,13 +1615,11 @@ s32 ATERMRunConfigProtocol(void) {
u32 checksum = 0;
u8* cursor = gAtermConfigurationResult.packetBuffer;
u8* packetEnd = packet->payload + payloadLength;
u8* payload = packet->payload;
u8* payload;
for (; cursor < packetEnd; cursor++) {
checksum += *cursor;
}
if ((u16)checksum != SONtoHs(*(u16*)packetEnd)) {
payload = NULL;
}
payload = (u16)checksum == SONtoHs(*(u16*)packetEnd) ? packet->payload : NULL;
if (payload == NULL) {
payloadLength = 0;
} else if (sequence != 3) {
@@ -1652,6 +1648,8 @@ s32 ATERMRunConfigProtocol(void) {
}
{
AtermProgress progress;
AtermMd5Context digestContext;
u8 digestLength[8];
u32 authenticationTime = (u32)(OSGetTime() /
(__mulhwu(reciprocal, OS_BUS_CLOCK >> 2) >> 6));
u32 index;
@@ -1664,7 +1662,7 @@ s32 ATERMRunConfigProtocol(void) {
digestContext.state[1] = 0xEFCDAB89;
digestContext.state[2] = 0x98BADCFE;
digestContext.state[3] = 0x10325476;
ATERMMd5Update(&digestContext, &authenticationTime, sizeof(authenticationTime));
ATERMMd5Update(&digestContext, (u8*)&authenticationTime, sizeof(authenticationTime));
digestLength[0] = digestContext.bitCountLow;
digestLength[1] = digestContext.bitCountLow >> 8;
digestLength[2] = digestContext.bitCountLow >> 16;
@@ -1677,22 +1675,13 @@ s32 ATERMRunConfigProtocol(void) {
ATERMMd5Update(&digestContext, gAtermDigestFill,
digestBytes < 56 ? 56 - digestBytes : 120 - digestBytes);
ATERMMd5Update(&digestContext, digestLength, sizeof(digestLength));
response->authentication.digest[0] = digestContext.state[0];
response->authentication.digest[1] = digestContext.state[0] >> 8;
response->authentication.digest[2] = digestContext.state[0] >> 16;
response->authentication.digest[3] = digestContext.state[0] >> 24;
response->authentication.digest[4] = digestContext.state[1];
response->authentication.digest[5] = digestContext.state[1] >> 8;
response->authentication.digest[6] = digestContext.state[1] >> 16;
response->authentication.digest[7] = digestContext.state[1] >> 24;
response->authentication.digest[8] = digestContext.state[2];
response->authentication.digest[9] = digestContext.state[2] >> 8;
response->authentication.digest[10] = digestContext.state[2] >> 16;
response->authentication.digest[11] = digestContext.state[2] >> 24;
response->authentication.digest[12] = digestContext.state[3];
response->authentication.digest[13] = digestContext.state[3] >> 8;
response->authentication.digest[14] = digestContext.state[3] >> 16;
response->authentication.digest[15] = digestContext.state[3] >> 24;
for (index = 0; index < 4; index++) {
u32 word = digestContext.state[index];
response->authentication.digest[index * 4] = word;
response->authentication.digest[index * 4 + 1] = word >> 8;
response->authentication.digest[index * 4 + 2] = word >> 16;
response->authentication.digest[index * 4 + 3] = word >> 24;
}
{
u8* contextByte = (u8*)&digestContext;
for (index = 0; index < sizeof(digestContext); index++) {
@@ -1750,13 +1739,11 @@ s32 ATERMRunConfigProtocol(void) {
u32 checksum = 0;
u8* cursor = gAtermConfigurationResult.packetBuffer;
u8* packetEnd = packet->payload + payloadLength;
u8* payload = packet->payload;
u8* payload;
for (; cursor < packetEnd; cursor++) {
checksum += *cursor;
}
if ((u16)checksum != SONtoHs(*(u16*)packetEnd)) {
payload = NULL;
}
payload = (u16)checksum == SONtoHs(*(u16*)packetEnd) ? packet->payload : NULL;
if (payload == NULL) {
payloadLength = 0;
} else if (sequence != 5) {
@@ -2325,12 +2312,17 @@ void ATERMAesDecryptBlock(const u32* expandedKey, u32 rounds, const u8* input, u
void ATERMMd5Transform(u32 state[4], const u8 block[64]);
void ATERMMd5Update(AtermMd5Context* context, void* input, u32 length) {
u8* data = (u8*)input;
static inline void atermMd5Copy(void* output, const void* input, u32 length) {
u32 index;
for (index = 0; index < length; index++) {
((u8*)output)[index] = ((const u8*)input)[index];
}
}
void ATERMMd5Update(AtermMd5Context* context, u8* input, u32 length) {
u32 bufferIndex = (context->bitCountLow >> 3) & 0x3F;
u32 bytesToFill;
u32 copiedBytes;
u32 index;
context->bitCountLow += length << 3;
if (context->bitCountLow < (length << 3)) {
@@ -2339,20 +2331,16 @@ void ATERMMd5Update(AtermMd5Context* context, void* input, u32 length) {
context->bitCountHigh += length >> 29;
bytesToFill = 64 - bufferIndex;
if (length >= bytesToFill) {
for (copiedBytes = 0; copiedBytes < bytesToFill; copiedBytes++) {
context->buffer8[bufferIndex + copiedBytes] = data[copiedBytes];
}
atermMd5Copy(&context->buffer8[bufferIndex], input, bytesToFill);
ATERMMd5Transform(context->state, context->buffer8);
for (copiedBytes = bytesToFill; copiedBytes + 63 < length; copiedBytes += 64) {
ATERMMd5Transform(context->state, data + copiedBytes);
ATERMMd5Transform(context->state, input + copiedBytes);
}
bufferIndex = 0;
} else {
copiedBytes = 0;
}
for (index = 0; index < length - copiedBytes; index++) {
context->buffer8[bufferIndex + index] = data[copiedBytes + index];
}
atermMd5Copy(&context->buffer8[bufferIndex], &input[copiedBytes], length - copiedBytes);
}
#define ATERM_MD5_STEP(A, B, C, D, WORD, CONSTANT, SHIFT, F) \

View File

@@ -1379,30 +1379,34 @@ namespace ipl {
return;
}
ext_ead::www::BrowserThread* browser = surface->GetBrowserThread();
if (browser == NULL) {
// One pointer, overwritten by the standard-buffer fetch, so the
// browser `this` and standardBuffer share a callee-saved reg.
void* held = surface->GetBrowserThread();
if (held == NULL) {
return;
}
if (browser->GetTextureBuffer(0, NULL) == NULL) {
if (static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(0, NULL) == NULL) {
return;
}
ext_ead::www::BrowserWindow* browserWindow =
static_cast<ext_ead::www::BrowserWindow*>(browser->mpBrowserWindows[0]);
if ((browserWindow != NULL ? browserWindow->unk_0x2C4[3] : 0) != 0) {
static_cast<ext_ead::www::BrowserWindow*>(static_cast<ext_ead::www::BrowserThread*>(held)->mpBrowserWindows[0]);
if ((browserWindow == NULL ? 0 : browserWindow->unk_0x2C4[3]) != 0) {
unk_0x91C[2] = 1;
mState = 0;
browserWindow = static_cast<ext_ead::www::BrowserWindow*>(browser->mpBrowserWindows[0]);
browserWindow = static_cast<ext_ead::www::BrowserWindow*>(static_cast<ext_ead::www::BrowserThread*>(held)->mpBrowserWindows[0]);
if (browserWindow != NULL) {
browserWindow->unk_0x2C4[3] = 0;
}
www::trasition::ScrollState scrollState = www::trasition::GetScrollState();
browserScrollDirection = scrollState == www::trasition::SCROLL_LEFT
? 1
: (scrollState == www::trasition::SCROLL_RIGHT ? -1 : 0);
if (scrollState == www::trasition::SCROLL_LEFT) {
browserScrollDirection = 1;
} else {
browserScrollDirection = scrollState == www::trasition::SCROLL_RIGHT ? -1 : 0;
}
www::trasition::ResetScrollState();
void* changedWideBuffer = browser->GetTextureBuffer(1, NULL);
void* changedStandardBuffer = browser->GetTextureBuffer(0, NULL);
void* changedWideBuffer = static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(1, NULL);
void* changedStandardBuffer = static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(0, NULL);
OSReport("changed %p %p\n", changedStandardBuffer, changedWideBuffer);
ext_ead::www::Heap::reportLeaHeap();
}
@@ -1415,8 +1419,9 @@ namespace ipl {
WWWRect* standardRect;
WWWRect* wideRect;
void* wideBuffer = browser->GetTextureBuffer(1, &wideRect);
void* standardBuffer = browser->GetTextureBuffer(0, &standardRect);
void* wideBuffer = static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(1, &wideRect);
held = static_cast<ext_ead::www::BrowserThread*>(held)->GetTextureBuffer(0, &standardRect);
void* standardBuffer = held;
nw4r::ut::Rect projection4x3;
System::getProjectionRect4x3(&projection4x3);
int screenWidth = abs(static_cast<int>(projection4x3.GetWidth()));
@@ -1443,33 +1448,33 @@ namespace ipl {
int wideWidth = abs(static_cast<int>(projection16x9.GetWidth()));
int wideHeight = abs(static_cast<int>(projection16x9.GetHeight()));
f32 wideLeft = -wideWidth / 2;
f32 wideTop = wideHeight / 2;
f32 wideTopL = wideHeight / 2;
f32 wideRight = wideWidth / 2;
nw4r::ut::Rect leftSide(wideLeft, wideTop,
f32 wideTopR = wideHeight / 2;
nw4r::ut::Rect leftSide(wideLeft, wideTopL,
wideLeft + sideDescriptor->textureHeader->width,
wideTop - sideDescriptor->textureHeader->height);
wideTopL - sideDescriptor->textureHeader->height);
nw4r::ut::Rect rightSide(wideRight - sideDescriptor->textureHeader->width,
wideTop, wideRight, wideTop - sideDescriptor->textureHeader->height);
wideTopR, wideRight, wideTopR - sideDescriptor->textureHeader->height);
if (browserScrollDirection != 0) {
nw4r::lyt::Material* wideMaterial =
void* wideMaterial =
mpChangeLayout->FindPaneByName("N_Tra0")->FindMaterialByName("Tex0");
nw4r::lyt::Material* firstStandardMaterial =
mpChangeLayout->FindPaneByName("N_Tra0")->FindMaterialByName("Tex1");
nw4r::lyt::Material* secondStandardMaterial =
mpChangeLayout->FindPaneByName("N_Tra0")->FindMaterialByName("Tex2");
wideMaterial->SetTexture(0, wideTexture);
static_cast<nw4r::lyt::Material*>(wideMaterial)->SetTexture(0, wideTexture);
firstStandardMaterial->SetTexture(0, standardTexture);
secondStandardMaterial->SetTexture(0, standardTexture);
mpChangeLayout->FindPaneByName("N_Tra0")->SetVisible(true);
if (browserScrollDirection == 1) {
utility::FrameController* animation = mpSecondAnimation;
animation->initFrame();
animation->restart();
wideMaterial = mpSecondAnimation;
static_cast<utility::FrameController*>(wideMaterial)->initFrame();
static_cast<utility::FrameController*>(wideMaterial)->restart();
} else {
utility::FrameController* animation = mpFirstAnimation;
animation->initFrame();
animation->restart();
wideMaterial = mpFirstAnimation;
static_cast<utility::FrameController*>(wideMaterial)->initFrame();
static_cast<utility::FrameController*>(wideMaterial)->restart();
}
mpChangeLayout->calc();
browserScrollDirection = 0;
@@ -1509,13 +1514,44 @@ namespace ipl {
}
if (mpWiiSettingFlag->smthMsgData >= 2 && mpWiiSettingFlag->smthMsgData <= 7) {
GXRenderModeObj renderMode = *System::getRenderModeObj();
GXRenderModeObj* pRmode = System::getRenderModeObj();
GXRenderModeObj renderMode;
volatile GXRenderModeObj* srcMode = pRmode;
volatile GXRenderModeObj* dstMode = &renderMode;
int n = 12;
u8* src;
u8* dst = &renderMode.aa;
src = &pRmode->aa;
dstMode->viTVmode = srcMode->viTVmode;
dstMode->fbWidth = srcMode->fbWidth;
dstMode->efbHeight = srcMode->efbHeight;
dstMode->xfbHeight = srcMode->xfbHeight;
dstMode->viXOrigin = srcMode->viXOrigin;
dstMode->viYOrigin = srcMode->viYOrigin;
dstMode->viWidth = srcMode->viWidth;
dstMode->viHeight = srcMode->viHeight;
dstMode->xFBmode = srcMode->xFBmode;
dstMode->field_rendering = srcMode->field_rendering;
dstMode->aa = srcMode->aa;
for (; n != 0; n--) {
dst[1] = src[1];
dst[2] = src[2];
src += 2;
dst += 2;
}
dstMode->vfilter[0] = srcMode->vfilter[0];
dstMode->vfilter[1] = srcMode->vfilter[1];
dstMode->vfilter[2] = srcMode->vfilter[2];
dstMode->vfilter[3] = srcMode->vfilter[3];
dstMode->vfilter[4] = srcMode->vfilter[4];
dstMode->vfilter[5] = srcMode->vfilter[5];
dstMode->vfilter[6] = srcMode->vfilter[6];
u32 left;
u32 top;
u32 width;
u32 height;
GXGetScissor(&left, &top, &width, &height);
GXSetScissor(0, renderMode.efbHeight / 2 - 0xA4, renderMode.fbWidth, 0x132);
GXSetScissor(0, dstMode->efbHeight / 2 - 0xA4, dstMode->fbWidth, 0x132);
mpMainLayout->draw();
GXSetScissor(left, top, width, height);
}
@@ -2445,25 +2481,28 @@ namespace ipl {
void Setting::convertRevIP(u8* destination, const char* address) {
char ascii[20];
int count = 0;
int index;
int componentStart;
int count = 0;
u32 value;
u8 character;
memset(ascii, 0, sizeof(ascii));
utility::CharacterCode::UTF8ToANSI(reinterpret_cast<u8*>(ascii), address);
int componentStart = 0;
u8* output = destination;
for (index = 0; index < 0x10; ++index) {
u8 character = static_cast<u8>(ascii[index]);
index = 0;
componentStart = 0;
for (; index < 0x10; ++index) {
character = static_cast<u8>(ascii[index]);
if (character == '.' || character == 0) {
if (character == 0) {
index = 0x10;
}
ascii[index] = 0;
u32 value = atoi(ascii + componentStart);
value = atoi(ascii + componentStart);
if (value > 0xff) {
value = 0xff;
}
if (count == 0) {
*output = value;
destination[count] = value;
} else {
destination[1] = destination[2];
destination[2] = destination[3];
@@ -2471,7 +2510,6 @@ namespace ipl {
}
componentStart = index + 1;
++count;
++output;
if (count == 3 && index != 0x10) {
value = atoi(ascii + componentStart);
if (value > 0xff) {
@@ -2668,6 +2706,7 @@ namespace ipl {
}
void Setting::scanAP() {
BOOL playing = FALSE;
switch (unk_0x78) {
case 1:
memset(&mAPScanList.count, 0, 0x800);
@@ -2716,7 +2755,8 @@ namespace ipl {
case 6: {
int animationIndex = unk_0x918;
unk_0xB9C = 1;
if (!mpMainLayout->getAnim(animationIndex)->isPlaying()) {
playing |= mpMainLayout->getAnim(animationIndex)->isPlaying();
if (!playing) {
unk_0x78 = 5;
setAPDraw();
if (unk_0x91C[0] != 0) {
@@ -2739,19 +2779,23 @@ namespace ipl {
}
break;
}
case 7:
case 7: {
int animationIndex = unk_0x918;
unk_0xB9C = 1;
if (!mpMainLayout->getAnim(unk_0x918)->isPlaying()) {
playing |= mpMainLayout->getAnim(animationIndex)->isPlaying();
if (!playing) {
updateScroll();
unk_0x78 = 6;
}
break;
}
case 8:
resetAP();
unk_0x91C[2] = 0;
break;
case 9:
if (!mpMainLayout->getAnim(unk_0x918)->isPlaying()) {
playing |= mpMainLayout->getAnim(unk_0x918)->isPlaying();
if (!playing) {
resetFuncMsgQ();
unk_0x78 = 1;
unk_0x918 = -1;

View File

@@ -211,13 +211,13 @@ namespace ipl {
systemDict = System::getZiDicData(i);
}
if (oemDict == NULL && System::getZiDicData(i) != NULL) {
oemDict = System::getZiDicData(oemIndex);
oemDict = System::getZiOemDicData(oemIndex - EZTX_LANG_MAX);
}
}
for (int i = 0, oemIndex = EZTX_LANG_MAX; i < EZTX_LANG_MAX; i++, oemIndex++) {
u8* usedSystemDict = System::getZiDicData(i);
u8* usedOemDict = System::getZiDicData(oemIndex);
u8* usedOemDict = System::getZiOemDicData(oemIndex - EZTX_LANG_MAX);
usedSystemDict = usedSystemDict != NULL ? usedSystemDict : systemDict;
if (usedOemDict == NULL) {

View File

@@ -466,19 +466,21 @@ static const u8 gArDeconvPlttTbl[3072] = {
0x00, 0xD5, 0x00, 0xD6, 0x00, 0xD8, 0x00, 0xDA, 0x00, 0xDC, 0x00, 0xDE, 0x00, 0xDF, 0x00, 0xE1
};
static const u32 gArDc_luminance_huffTable[] = {
0x00018002, 0x00030000, 0xC003C004, 0x80050001, 0x00020003, 0x00040005,
0x80010006, 0x80010007, 0x80010008, 0x80010009, 0x8001000A, 0x8001000B,
static const u16 gArDc_luminance_huffTable[] = {
0x0001, 0x8002, 0x0003, 0x0000, 0xC003, 0xC004, 0x8005, 0x0001,
0x0002, 0x0003, 0x0004, 0x0005, 0x8001, 0x0006, 0x8001, 0x0007,
0x8001, 0x0008, 0x8001, 0x0009, 0x8001, 0x000A, 0x8001, 0x000B,
};
static const u32 gArDc_chrominance_huffTable[] = {
0x0001C002, 0x80030000, 0x00010002, 0x80010003, 0x80010004, 0x80010005,
0x80010006, 0x80010007, 0x80010008, 0x80010009, 0x8001000A, 0x8001000B,
static const u16 gArDc_chrominance_huffTable[] = {
0x0001, 0xC002, 0x8003, 0x0000, 0x0001, 0x0002, 0x8001, 0x0003,
0x8001, 0x0004, 0x8001, 0x0005, 0x8001, 0x0006, 0x8001, 0x0007,
0x8001, 0x0008, 0x8001, 0x0009, 0x8001, 0x000A, 0x8001, 0x000B,
};
#pragma pack(1)
struct HufftreeData {
const u32* tables[4];
const u16* tables[4];
char messages[0x1BB];
};
#pragma pack()
@@ -931,17 +933,15 @@ void CArGBAOdh::cdj_c_makeHeader(SArCDJ_OdhMaster* master, u32 size) {
}
s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int format) {
u32 paddedWidth;
u16 width;
u16 height;
u8* workPlane;
int sourceStride;
u8* crPlane;
u8* cbPlane;
u8* crPlane;
u16* dimensions;
int rowIndex;
int sourceStride;
int i;
u16 dimension;
u16 paddedDimensions[2];
dimensions = &master->width;
@@ -952,11 +952,11 @@ s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int for
height = dimensions[1];
for (i = 0; i < 2; i++) {
dimension = dimensions[i];
if ((dimension & 7) != 0) {
paddedDimensions[i] = (dimension + 8) - (dimension & 7);
u16 remainder = dimensions[i] & 7;
if (remainder != 0) {
paddedDimensions[i] = (dimensions[i] + 8) - remainder;
} else {
paddedDimensions[i] = dimension;
paddedDimensions[i] = dimensions[i];
}
}
@@ -972,13 +972,12 @@ s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int for
}
}
paddedWidth = paddedDimensions[0];
for (rowIndex = 0; rowIndex < (s32)height; rowIndex++) {
LineConv11(sourceData + (rowIndex & 3) * 8 + rowIndex / 4 * sourceStride, workPlane, cbPlane, crPlane,
dimensions[0], dimensions[1], (const long*)gArConvPlttTbl, format);
workPlane += paddedWidth;
cbPlane += paddedWidth;
crPlane += paddedWidth;
workPlane += paddedDimensions[0];
cbPlane += paddedDimensions[0];
crPlane += paddedDimensions[0];
}
return 0;

View File

@@ -978,33 +978,37 @@ namespace ipl {
ESMisc::ChangeUid(SYSMENU_TITLE_ID);
}
static inline void DeleteTicketsForce(EGG::Heap* heap, ESTitleId titleId, u8* ticketViews, u32* ticketViewCount) {
static inline s32 DeleteTicketsForce(EGG::Heap* heap, ESTitleId titleId, u8* ticketViews, u32* ticketViewCount) {
ESTicketView* ticketViewList = NULL;
s32 ret;
memset(ticketViews, 0, OSRoundUp32B(sizeof(ESTicketView)));
ret = ES_GetTicketViews(titleId, NULL, ticketViewCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret, titleId);
} else if (*ticketViewCount != 0) {
ticketViewList = (ESTicketView*)heap->alloc(*ticketViewCount * OSRoundUp32B(sizeof(ESTicketView)), -DEFAULT_ALIGN);
ret = ES_GetTicketViews(titleId, ticketViewList, ticketViewCount);
goto cleanup;
}
if (*ticketViewCount == 0) {
return ret;
}
ticketViewList = (ESTicketView*)heap->alloc(*ticketViewCount * OSRoundUp32B(sizeof(ESTicketView)), -DEFAULT_ALIGN);
ret = ES_GetTicketViews(titleId, ticketViewList, ticketViewCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret, titleId);
goto cleanup;
}
for (u32 j = 0; j < *ticketViewCount; j++) {
memcpy(ticketViews, (u8*)ticketViewList + j * sizeof(ESTicketView), sizeof(ESTicketView));
ret = ES_DeleteTicket((ESTicketView*)ticketViews);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret, titleId);
} else {
for (u32 j = 0; j < *ticketViewCount; j++) {
memcpy(ticketViews, (u8*)ticketViewList + j * sizeof(ESTicketView), sizeof(ESTicketView));
ret = ES_DeleteTicket((ESTicketView*)ticketViews);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_DeleteTicket failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret,
((ESTicketView*)ticketViews)->ticketId);
}
}
OSReport("%s::%s: ES_DeleteTicket failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret,
((ESTicketView*)ticketViews)->ticketId);
}
}
cleanup:
if (ticketViewList != NULL) {
heap->free(ticketViewList);
}
return ret;
}
static inline s32 InitSavedata(EGG::Heap* heap) {
@@ -1032,20 +1036,23 @@ namespace ipl {
goto cleanup;
}
for (u32 i = 0; i < titleCount; i++) {
if ((titleIds[i] & 0xFFFFFFFFFFFFFF00ULL) == 0x00010000525A4400ULL) {
verifySavedataZD(heap, titleIds[i], &fileInfo);
continue;
}
switch (titleIds[i]) {
case 0x0001000844495343ULL:
case 0x000100014A4F4449ULL:
case 0x0001000148415858ULL:
case 0x0001000844564458ULL:
case 0x000100084449534BULL:
ES_DeleteTitle(titleIds[i]);
DeleteTicketsForce(heap, titleIds[i], ticketViews, &ticketViewCount);
break;
{
u8* ticketScratch = ticketViews;
for (u32 i = 0; i < titleCount; i++) {
if ((titleIds[i] & 0xFFFFFFFFFFFFFF00ULL) == 0x00010000525A4400ULL) {
verifySavedataZD(heap, titleIds[i], &fileInfo);
continue;
}
switch (titleIds[i]) {
case 0x0001000844495343ULL:
case 0x000100014A4F4449ULL:
case 0x0001000148415858ULL:
case 0x0001000844564458ULL:
case 0x000100084449534BULL:
ES_DeleteTitle(titleIds[i]);
DeleteTicketsForce(heap, titleIds[i], ticketScratch, &ticketViewCount);
break;
}
}
}

View File

@@ -0,0 +1,76 @@
# BS2 low-level DVD completion callback contract
Base: `9c7d87ab008df7e35558321e3ca297a887d35c44`.
Leaf: `agent/bittle/bs2-dvd-callback-contract`, 43U only.
## Source evidence
`DVDLowCallback` is `void (*)(u32 intType)`. BS2Mach defined its completion
callback with a signed s32 parameter and cast it to the unsigned function
pointer type at five registration sites. DVDLowContext stores DVDLowCallback,
and the original exact doTransactionCallback dispatches through that type.
The callback simply publishes the received word to volatile u32 LowReadResult.
Use the unsigned parameter directly and remove the five casts.
The original callback symbol at 0x8137BA1C is local, while baseline source
emitted it globally. All references are private to BS2Mach.c. Restore static
linkage in a separate measured follow-on; no other function/global changes.
Original evidence was checked independently against the DOL:
- Five registration sites contain ten address-materialization relocations
resolving to callback 0x8137BA1C
- The callback stores the entire r3 word to LowReadResult 0x81698A54, then
returns; the actual SDA base is 0x8169E040
- Original dispatcher invocation is at 0x8154F8C8; doTransactionCallback
remains instruction-exact, 46/46 instructions
- All 123 direct calls in BS2StartGame and BS2StartGCGame agree with original
raw destinations; their request-buffer widths/offsets and ABI inputs agree
- Ordinary NAND completion has its separate signed-result/block contract
and is untouched
## Separately measured trials
1. Unsigned callback parameter and removal of five casts only. Entire MWCC
object byte-identical to baseline, SHA256
`b853f8e58ead247dd8d333f4a7413e56b9c9e92341ad1bf54034fdf2f2be93b6`.
Full report byte-identical across 1,027 units.
2. Add static linkage. Only callback's symbol binding changes, global to
local, matching the original. Every other symbol record and all 1,461
relocation sites/types/target identities/addends remain unchanged.
All five allocated sections retain identical contents, extents, flags
and alignment, including BSS/SBSS extents. Final object SHA256
`154cd050a7295a1178de648a2abacf311cc2b4c96548926eb6d77eedb177c2e4`.
Full report again byte-identical to baseline.
Whole-object identity is claimed only for trial 1; trial 2 changes metadata.
No matching/fuzzy percentage gain or change in boot behavior is claimed.
## Tests and gates
- Fresh baseline configured with `python3 configure.py --version 43U
--wrapper ../toolchain/wibo-build/wibo`; full source/report/DOL build passes
- Candidate object built separately for both trials; final full invocation
`WIBO_SJIS_MISSING_IMPORTS=1 ../.venv/bin/ninja all_source
build/43U/report.json build/43U/ok` passes
- Pool identical: 91/91 strings
- All 25 exact functions independently retain zero instruction differences;
callback remains 2/2 instructions at .text+0xA68, STB_LOCAL as original
- Unit unchanged: 25/29 exact functions, 5,112/16,980 matched code bytes,
155,504/158,528 matched data bytes, fuzzy 99.09658%
- Literal advisory: 28 functions, 97 arguments, no candidates or errors;
skips only BS2Tick because its extents differ
- DOL SHA1 `26116613f624061ba99c8d1a299aaa6efa85670d`
- `git diff --check` passes
Host compiler test extracts the baseline and final callback definitions with
fixed-width host equivalents. Direct assignment to DVDLowCallback fails for
the signed baseline under -Werror=incompatible-pointer-types and succeeds for
the final definition. The final callback preserves 200,007 tested words under
UBSan, including 0, 1, 2, 0x40, INT32_MAX, 0x80000000 and UINT32_MAX.
This is a compile-time function-type counterexample; GCC UBSan is not claimed
to detect the baseline's incompatible indirect call.
Private evidence: `/tmp/bs2-boot-contract/` and workspace-parent
`validation/bs2-boot-contract-20261003/`. Original binary/disassembly is not
committed. No shared header, volatility, Run body, state, or linking change.

View File

@@ -0,0 +1,53 @@
# CHANSVm boolean output contract
Base: `fc114afd44065fb99f9ff2fe2969f393a504fe03` (43U).
Leaf: `agent/bittle/chans-scalar-contracts`.
## Correction and evidence
`CHANSVmGetBoolean` writes an optional four-byte `vmBoolInt` result, but its
source formal described a `CHANSVmObjHdr*`. All three callers cast addresses
of scalar locals to that object pointer. The original helper's only output
write is a word store at `0x8144C664`. Its Step call destinations at
`0x81456B08`, `0x81457584`, and `0x814575B0` were verified directly in the
original DOL, as were 48 nonrelocated helper words and its direct callees.
The actual MWCC layout probe confirms object alignment/size 8/16 and scalar
alignment/size 4/4. Step's two conditional-branch callers pass sp+0x0C, which
has scalar alignment but not object alignment. Declaring a whole object at
that address is an incorrect source contract even though the generated
helper only performs one word store.
Use `vmBoolInt*` as the output formal, assign through `*ret`, make both
receiving locals `vmBoolInt`, and remove all three casts. No shared header
contains a declaration, and no header changed. A repository-wide source
search found exactly this definition and these three calls. A complete
original-object relocation scan found only those calls plus ten labels in
the helper's own switch table; no additional callback was found.
## Tests and gates
- Source-extracted baseline reproduces a UBSan misaligned-object access when
passed a four-byte-aligned, non-eight-byte-aligned scalar destination.
- Candidate passes 1,283 typed-output cases, corresponding null-output calls,
and surrounding-byte canaries. Coverage includes all 256 discriminator
values, signed integer boundaries, zero/nonzero string lengths, finite
floating values, signed zero, infinities, NaN, and error/no-write paths.
- This is a focused host helper harness with a modeled object layout and
`isnan` shim, not full VM or Wii runtime execution. Target layout was
independently checked with the configured MWCC compiler.
- Entire compiled object is byte-identical, including code, data, symbols
and relocations. SHA256:
`5bf3f4a0a404e2a574287c16de81d702a1402d9fca416455e84dc1df67c9eb76`.
- All 1,027 report units unchanged. Exact CHANS functions 222/233; exact code
38,136/53,564; data 6,904/6,904. GetBoolean remains 100%; Step 96.98723%.
- Pool: 125/125 identical. `git diff --check` passes.
- Full 43U `all_source`, report, and `ok` gates pass with the existing cached
tools selected through documented configure overrides. DOL SHA1:
`26116613f624061ba99c8d1a299aaa6efa85670d`.
Artifacts: `/tmp/chans-step-abi/`, including `test_boolean.py`, the MWCC
alignment probe, `check_boolean_original.py`, and build/test results.
No original binary or disassembly is committed.
GATE: coherent scalar-output source correction; no fuzzy/exact/data/link gain.

View File

@@ -0,0 +1,79 @@
# CHANSVm HMAC external declarations
Base: `20ba34a80f9d0a09c4a8fad51352f0dd97d84be0` (43U).
Leaf: `agent/bittle/chans-hmac-linkage`.
## Source evidence
The four HMAC/SHA1 helper declarations at the top of `CHANSVm.c` had
`static` linkage but no definitions in that translation unit. A fresh MWCC
compile emitted four warning 10532 diagnostics. The definitions in
`libs/RevoEX/src/net/sha1.c` and `hmac.c` have external linkage;
`CDBRecord.c` already declares these imports `extern`.
The original CHANS object imports all four as `STB_GLOBAL`, `SHN_UNDEF`.
The baseline source object instead imported them as `STB_LOCAL`,
`SHN_UNDEF`. Change only the four declaration storage classes to `extern`.
Do not change the context, parameter types, shared headers, or linking flags.
Independent original-DOL call decoding agrees with the extracted relocations:
| Caller | Call address | Destination | Import |
| --- | --- | --- | --- |
| VmBlobCalcHMAC | 0x81452720 | 0x81494144 | NETGetSHA1Interface |
| VmBlobCalcHMAC | 0x81452734 | 0x814944EC | NETHMACInit |
| VmBlobCalcHMAC | 0x81452744 | 0x81494728 | NETHMACUpdate |
| VmBlobCalcHMAC | 0x81452750 | 0x81494738 | NETHMACGetDigest |
| VmBlobCalcRangeHMAC | 0x814528F4 | 0x81494144 | NETGetSHA1Interface |
| VmBlobCalcRangeHMAC | 0x81452908 | 0x814944EC | NETHMACInit |
| VmBlobCalcRangeHMAC | 0x81452918 | 0x81494728 | NETHMACUpdate |
| VmBlobCalcRangeHMAC | 0x81452924 | 0x81494738 | NETHMACGetDigest |
The ABI contracts agree: Init takes context/interface/key/u32 length in
r3-r6, Update takes context/data/u32 length, and GetDigest takes
context/output. The interface helper returns its pointer in r3.
Original caller context addresses are sp+8 and sp+0x10. The exact HMAC
implementation uses the interface at 0x00-0x1B, key length at 0x1C,
96-byte digest state at 0x20, and 64-byte key at 0x80, totaling 0xC0.
The existing CHANS opaque context reserves 0xD0 with 8-byte alignment.
That storage is unchanged. Caller opaque types and callee named types
remain separate declarations; this change fixes linkage only, not complete
cross-translation-unit type compatibility.
## Validation
- Configured 43U with `../toolchain/wibo-build/wibo`; fresh baseline full
source/report/DOL build passed, followed by a forced owned-object rebuild.
- Baseline emitted exactly four warning 10532 diagnostics; candidate emitted
none. No other compiler warning appeared in the candidate object build.
- The four imports now have exactly the original symbol records, including
global undefined binding. Every other symbol record is unchanged.
- All six allocated sections retain identical contents, extents, alignment,
type and flags, including the NOBITS section's extent.
- All 2,010 relocation sites, types, symbol identities and addends are
unchanged. Comparison resolves symbol indexes because binding changes
can reorder the ELF symbol table.
- All 1,027 unit report records are unchanged. CHANS: fuzzy 99.4341%,
exact code 38,136/53,564 bytes, exact functions 222/233,
matched data 6,904/6,904 bytes.
- Independently compared all 222 exact functions against original
instruction streams, with zero differences.
- The two HMAC callers remain 64/64 and 119/119 instructions, diffs 0.
- Pool: identical 125/125 entries. Literal advisory: 233 functions,
40 arguments, no candidates, errors, or skips.
- Eight call destinations and 392 nonrelocated instruction words across
the two callers and four helpers agree with original DOL bytes.
- Final `WIBO_SJIS_MISSING_IMPORTS=1 ../.venv/bin/ninja all_source
build/43U/report.json build/43U/ok` passes; DOL SHA1 remains
`26116613f624061ba99c8d1a299aaa6efa85670d`. `git diff --check` passes.
Whole-object identity is intentionally not claimed: symbol bindings changed.
SHA256 before:
`f971cabf817dba7e5cb240df01e1e8f814bb0a973e357a594d031046a56e691b`.
SHA256 after:
`5bf3f4a0a404e2a574287c16de81d702a1402d9fca416455e84dc1df67c9eb76`.
Private reproducibility artifacts are under
`validation/chans-hmac-linkage-20261003/` in the workspace parent and
`/tmp/chans-hmac-linkage/`. No original binary or disassembly is committed.
This is a source declaration correction with no decompilation percentage gain.

View File

@@ -0,0 +1,57 @@
# CHANSVm immediate integer accumulation
Base: `a52b3390` on `agent/bittle/chans-scalar-contracts` (43U).
This isolated commit follows, but does not alter, the boolean-output correction.
## Correction
`VmLoadImmInteger` assembled bytes by repeatedly left-shifting a signed
64-bit accumulator. An eight-byte immediate beginning with 0x80 through
0xFF can overflow that signed shift on the final iteration. Use an unsigned
64-bit accumulator, then convert the final word to the existing signed
`vmInteger` argument of `CHANSVmSetInteger`.
The original helper at `0x81455D88` shifts and combines high/low 32-bit words
modulo 64 bits. It reads unsigned bytes in big-endian order. Short immediate
widths do not sign-extend: one-byte 0xFF is 255, not -1. The target tail call
preserves VM/object in r3/r4 and supplies high/low value words in r5/r6.
Step's two call sites supply counts 1, 2, 4, or 8 for immediate loads, and
1 for binary immediate operations. No negative-width caller was found.
Unsigned shifts are defined. The final out-of-range unsigned-to-signed
conversion is implementation-defined in C; configured MWCC probes verify
bit-preserving conversion for bit 63, all bits set, and dynamic input.
The dynamic conversion emits only a return instruction. Host GCC tests
independently verify the selected implementation's behavior. No universal
portable-C conversion claim is made.
## Verification
- Source-extracted baseline UBSan fails while assembling `80 00 00 00 00
00 00 00`. The candidate passes 315,813 cases: every combination of
0x00/0x7F/0x80/0xFF at widths 1/2/4/8, generated inputs, and zero width.
Tests check value bits, VM/object callback arguments, and propagated result.
- A bounded interpreter executes the original helper's 16 nonbranch-tail
instruction words, independently checked against the original DOL.
The tail branch destination is verified as `CHANSVmSetInteger`.
All 165,813 original-DOL cases agree with an independent big-endian
unsigned reference and with r3/r4/r5:r6 call contracts.
- These are focused host/helper-slice tests, not complete VM or Wii runtime
execution. Counts outside the observed 1/2/4/8 contract are not generally
validated; zero was checked as an additional no-read boundary.
- VmLoadImmInteger remains exact: 17/17 instructions, ctxdiff 0 differences.
- Entire CHANSVm.o remains byte-identical to both the preceding commit and
initial branch baseline, including code/data/symbols/relocations. SHA256:
`5bf3f4a0a404e2a574287c16de81d702a1402d9fca416455e84dc1df67c9eb76`.
- All 1,027 report units remain unchanged. All 222 exact functions were
independently compared with the original and have zero differences.
- Pool: 125/125. Literal advisory: 233 functions, 40 arguments, no
candidates/errors/skips. `git diff --check` passes.
- Full 43U `all_source`, report, and `ok` gate passes with existing cached
tooling. DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`.
Artifacts: `/tmp/chans-step-abi/test_immediate.py`,
`check_immediate_original.py`, conversion probe, and build/test results.
No original binary or disassembly is committed.
GATE: source-width correctness correction; no fuzzy/exact/data/link gain.

View File

@@ -0,0 +1,71 @@
# CHANSVm string-index width correction
Baseline: `7b8dbf2c96aa9b4490df35932850c59886f76be3` in the prepared
`agent/bittle/chinese-code-width` leaf. Before editing, the owned CHANSVm source
was also identical to the available `origin/main` at `6619098e`. The earlier
Chinese investigation remains unchanged. Only CHANSVm.c and this log change.
## Correction
The SET_INDEX string path parsed into a `u64`, reconstructed that value through
`VM_S64_FROM_U64`, then cast it back to `u64` for the bound check. The macro's
signed 64-bit high-word left shift overflows when the parsed value has bit 63
set. For example, parsing "-1" reaches a signed shift of 4294967295 by 32.
Compare the original `u64` directly against the existing `0xFFFFFFFE` bound.
Remove the now-unused macro. The integer and floating paths are unchanged.
This removes undefined source behavior; it does not claim a change to the
current MWCC executable, a fuzzy gain, or a new exact function.
## Original evidence
- Original CHANSVmStep is at `0x81456354`, with extent `0x1394`.
- `0x814563B8` and `0x814563BC` establish the bound's high and low words as
zero and `0xFFFFFFFE`.
- The parsed-string check at `0x81456E90` through `0x81456EB4` reads the two
parsed words and performs an unsigned two-word comparison. Values greater
than the bound select the existing SET_INDEX error; accepted values forward
their low word as the index.
- These instruction words were checked directly against the original DOL,
independently of relocation matching. The DOL has the required SHA1 below.
- CHANSVmParseInt calls `strtoull` and stores its unsigned result. The local MSL
implementation (`strtoul.c`, lines 327–348) explicitly applies a negative sign
in unsigned width. Both helpers are already exact in the live report.
- Prior CHANSVm attempt logs were checked; the typed integer/float comparison
work did not address this signed reconstruction in the parsed-string path.
## Tests and measurements
- Baseline source-extracted UBSan harness fails on "-1" with signed left-shift
overflow. The candidate passes 300,028 parsed-value and unsigned-boundary
cases without a sanitizer error.
- Inputs include zero, `0xFFFFFFFE`, `0xFFFFFFFF`, `0x100000000`, signed-64
boundaries, maximum unsigned-64, negative decimal strings, parse failures,
and deterministic generated values. The unusual unsigned parsing of
"-18446744073709551615" to 1 remains accepted, matching the existing parser.
- A separate bounded interpreter executes the original DOL comparison slice
for 300,010 values, checking its error branch and accepted index against an
independent high-word/low-word bound reference. Every case passes.
- These are focused host/slice tests, not complete VM or Wii runtime tests.
The parser harness uses a UTF-16-to-ASCII shim and host `strtoull`; MSL's
negative-sign behavior was also checked in its local source.
- Entire compiled object, including all code, data and relocations, is
byte-identical before/after. SHA256:
`f971cabf817dba7e5cb240df01e1e8f814bb0a973e357a594d031046a56e691b`.
- Complete 1,027-unit report is unchanged. CHANSVmStep remains 96.98723%,
1,253/1,253 instructions. Unit fuzzy remains 99.4341%.
- Exact functions remain 222/233, each individually checked with ctxdiff:
zero differences. Exact code remains 38,136/53,564 bytes; data 6,904/6,904.
- Pool: 125/125 strings identical. Literal advisory: 233 functions, 40 arguments,
no candidates, skips or errors.
- Full 43U `all_source`, report and `ok` gates pass using the assigned wrapper
and WIBO_SJIS_MISSING_IMPORTS=1. `git diff --check` passes.
- DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`.
Private local reproduction files are in `/tmp/chans-index-width/`, including
baseline/candidate sources and objects, test_width.py, check_original.py,
sanitizer output, original-address checks, pool/literal results and build logs.
No original binary or disassembly is committed. No header, metadata, compiler,
linking, other-region, remote, or register-allocation change was made.
GATE: source-width correctness fix; compiler output and all progress preserved.

View File

@@ -0,0 +1,88 @@
# CHANSVm packed-hex count rounding
Base: `a30b5cecb68f4549ef83565a567cc5dd7bd4c0de` (43U).
Leaf: `agent/bittle/chans-pack-union`.
## Retained source-width correction
The sizing and writing passes of `VmBlobPackCommon` both computed
`(count + 1) / 2` in signed 32-bit arithmetic for hexadecimal strings.
The existing parser accepts `H2147483647`, making the addition overflow.
Both sites now add in unsigned 32-bit width, convert the wrapped word to
`s32`, then perform the existing signed division.
This preserves the target's unusual boundary behavior. It does not change
`INT_MAX` into a positive rounded-up size. The original result is
`-1073741824`; the writing pass forwards its signed extension to the existing
`CHANSVmBlobHasSpace` check, which rejects negative sizes. All surrounding
count, size, allocation, and error checks are unchanged.
Unsigned addition is defined modulo 2^32. Converting an out-of-range `u32`
to `s32` is implementation-defined in C, not signed-overflow undefined
behavior. Separate MWCC probes confirm the configured 32-bit compiler's
bit-preserving conversion: `0x80000000` becomes `INT_MIN`, and `0xffffffff`
becomes -1. Its dynamic rounding probe emits the same add, arithmetic-shift,
and carry-add sequence as the original. The host GCC harness uses explicit
32-bit typedefs and independently confirms that conversion behavior.
This is not a claim of portable behavior for every possible C implementation.
## Original and prior-work evidence
- Original `VmBlobPackCommon`: address `0x81453670`, extent `0xA70`.
- Sizing-pass rounding: relative `+0x320` through `+0x330`.
- Writing-pass rounding and signed call argument: `+0x940` through `+0x954`.
- Those words agree directly with the original DOL, independently of the
extracted object's relocations.
- Earlier CHANS logs covered count validation, padding, parser locals,
declaration orders, loop structure, and source/getter types. No earlier
packed-hex `count + 1` wrap correction was found.
## Validation
- Source-extracted baseline arithmetic fails UBSan at `INT_MAX + 1`.
- Candidate passes 1,000,022 direct arithmetic inputs and 11 source-extracted
parser cases, including `H2147483647`, neighboring odd/even limits, zero,
ordinary counts, `H*` (-1), and the existing overflowing-digit rejection.
Star-derived string lengths include zero and the largest u32 byte lengths.
- Two bounded original-DOL instruction interpreters each pass 1,000,013
inputs against an independent widened-arithmetic reference, including
INT_MAX neighbors, negative boundaries, and generated nonnegative counts.
The second slice also verifies signed 64-bit argument extension.
- These are focused parser/arithmetic/slice tests, not complete VM or Wii
runtime tests. The parser is unchanged and is not generally proven free
from other arithmetic issues.
- Entire CHANSVm object is byte-identical before/after, including code,
data, symbols and relocations. SHA256:
`5bf3f4a0a404e2a574287c16de81d702a1402d9fca416455e84dc1df67c9eb76`.
- All 1,027 report units are unchanged. CHANS exact functions: 222/233;
exact code: 38,136/53,564; exact data: 6,904/6,904.
- All 222 objdiff-exact functions independently have identical original
instruction streams. PackCommon remains 97.949104%, 668/668 instructions;
CHANSVmStep remains 96.98723%, 1,253/1,253 instructions.
- Pool: 125/125 identical. Literal advisory: 233 functions, 40 arguments,
no candidates, errors, or skips. `git diff --check` passes.
- Final full 43U `all_source`, report, and `ok` gates pass. DOL SHA1:
`26116613f624061ba99c8d1a299aaa6efa85670d`.
- The initial final-build run stopped when an automatic BSTool refresh was
blocked. Its resume attempt found that the process had ended. The final
build used configure.py's supported explicit paths to the existing cached
compiler, binutils, DTK, objdiff, sjiswrap, and BSTool. No executable was
replaced and no download was needed. All 1,027 source objects were rebuilt.
- The final object and complete report remain identical to their fresh
baseline after that full rebuild.
GATE: source-width correctness correction; zero fuzzy, exact, data, or linking
metric changes. The unit remains NonMatching and no linking flags changed.
## Rejected separate scratch-buffer trial
Before the overflow change, one bounded trial replaced PackCommon's cast-based
scratch array with a union whose integer-width members were all used.
MWCC removed two scratch-clearing stores: 668 -> 666 instructions, fuzzy
97.949104% -> 97.500000%. The trial was fully restored; the restored whole
object was verified byte-identical before starting the overflow change.
No union change is retained, and no declaration or register sweep was run.
Reproduction artifacts are in `/tmp/chans-pack-rounding/` and
`/tmp/chans-pack-union/`. No original binary or disassembly is committed.

View File

@@ -0,0 +1,52 @@
# CHANSVm typed comparison reconstruction
Baseline: ec75ddb0. This candidate is separate from the accepted load-string and opcode-error-path work. Those commits and their logs are unchanged. Only CHANSVm.c and this log changed; no headers, linking classifications, metadata, or original assets changed.
## Retained reconstruction
- LOAD_FLOAT copies the eight-byte literal into a double scratch member and passes that value directly. This replaces a u64 temporary followed by a double-pointer reinterpretation. Scratch alignment, member offsets, and emitted code are unchanged.
- SET_INDEX reads the floating operand through its union member and checks its lower bound before its upper bound, matching the target's comparison order. The accepted interval remains [0, 4294967294], with NaN and infinities rejected.
- Strict integer equality uses the declared 64-bit integer values rather than four offset-based u32 loads and manual XOR/OR expressions.
- Strict floating equality uses the declared floating values directly.
- Strict string equality uses named, read-only payload pointers rather than recreating a header pointer. The stack operand is consistently first in the outer type comparison, following the target.
This is structural/type reconstruction, not a newly discovered behavior fix. No register forcing, declaration sweep, or alignment padding was introduced.
## Target evidence
After rebuilding, the integer-comparison block (Step instructions 1093-1102), floating-comparison block (1103-1108), string-comparison block (1109-1128), and floating-index block (703-712) have the same instructions, control flow, constants, and memory offsets as the target after register names are normalized. This comparison is advisory: register differences remain, and Step is not exact.
The floating range's instruction forms now use the target's lower-bound-first order. Integer equality emits the same target ten-instruction two-word equality sequence naturally from the 64-bit value comparison. LOAD_FLOAT retains its original eight-byte copy and call sequence without a pointer reinterpretation.
## Measurements
- Instruction-exact functions: 221/233 -> 221/233; no previously exact function regressed.
- Unit Decompiled/fuzzy: 99.406320% -> 99.413185%.
- Step: 96.913800% -> 96.987230%; 1253/1253 instructions; differing positions 285 -> 276.
- Exact code: unchanged at 37608/53564 bytes (70.211334%).
- Exact data: unchanged at 6904/6904 bytes (100%).
- Per-function score regressions: zero.
- Unit remains NonMatching/unlinked, with twelve non-exact functions.
## Attempts
- Direct 64-bit equality alone: Step 96.933760%, data 100%; retained for combination.
- Typed integer/float/string comparison paths: 96.971270%, data 100%; retained.
- Those typed paths plus a separate strict-comparison local error result: 1254 instructions, table relocations moved; rejected.
- Floating index member access alone preserves the typed-comparison score. Lower-bound-first range checking raises it to 96.983240%, data 100%; retained.
- A union literal temporary produced the same code; simplified to a direct double member instead, also with identical code.
- Stack-first type comparison raises Step to 96.987230% with unchanged data; retained.
## Verification
- Full 43U build passed with the assigned wrapper and WIBO_SJIS_MISSING_IMPORTS=1.
- DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
- pool_diff: all 125 strings identical.
- .data: 4672/4672 raw bytes and 352/352 canonical relocations identical.
- .rodata: 1432/1432 raw bytes and 258/258 canonical relocations identical.
- All 233 functions checked with ctxdiff/odiff: 221 instruction-exact; no falsely exact objdiff functions.
- Literal-reference audit: 233 functions analyzed, 40 resolvable call-string arguments checked, no candidates/errors/skips.
- Source-extracted host C harnesses passed 20 strict-comparison cases, nine floating-index-bound cases, and eight floating-literal bit patterns. Coverage includes signed integer extremes, differing high words, signed zero, NaN, infinities, strings, references, deletion errors, and literal payload preservation. They stub surrounding dependencies and do not constitute Wii runtime execution.
- git diff --check passed.
Source is paused for independent parent verification.

View File

@@ -0,0 +1,79 @@
# Address drag-width reconstruction, 2026-10-03 UTC
Base `e4a94492`, branch `agent/bittle/address-drag-reconstruction`, 43U only.
Only `src/scene/address/iplAddress.cpp` and this log changed. Headers, metadata,
linking flags, other worktrees and earlier attempt logs are untouched.
## Recovered behavior and source structure
The original movePane_onDrag null-text-box and null-name exits skip the 0.01f
text-width margin. The baseline incorrectly added that margin unconditionally.
This was visible in the original branch destinations and also documented in
older fz10 attempts, but the incomplete correction had not been retained.
The new typed inline GetDragNameWidth helper receives the text box and a reference
to the real friend record. It evaluates the record address before entering the
measurement path, checks the text box, then derives/checks the name address.
This recovers the target's two early-exit regions, delayed name-member address,
font calls, character-width loop, and successful-only margin. An empty but valid
name still receives the margin, as the target does. The existing unused GetWidth
call and per-character GetFont lookup remain present.
The text box lookup now spells out the root-pane FindPaneByName call already
used by layout::Object's wrapper. An explicit right-edge value preserves the
existing single-precision add, ratio multiply, and negation sequence; it does
not combine ratios, reassociate operations, or change the comparison. Together,
these source boundaries make the complete function instruction-exact.
## Attempts
- Read scene4, data-d7, sol-med and fz10 drag-width evidence before iterating.
- Moving only the margin to the measured branch improved 92.451614 -> 93.741936%.
The target's margin-first addition reached 93.80645%.
- Computing the typed friend-record reference before the guard reached 98.064514%.
- A nullable name-pointer helper reached 98.741936% but 156/155 instructions.
The friend-record-reference helper recovered 155/155 and 99.80645%.
- An explicit projected right-edge accumulator recovered the target FP register
lifetime and reached 99.870964%. Mutating the translation vector instead grew
the function and was rejected.
- Direct root-pane lookup resolved the last four receiver/literal register
operands, reaching 100.0%. No parameter or declaration sweep was used.
- No new assembly, use-site volatile, dummy storage, padding, uninitialized
values, compiler-option changes or linking experiments were introduced.
## Verification
Before -> after:
- movePane_onDrag: 92.451614 -> 100.0% objdiff; 153 -> 155 instructions against
target 155; ctxdiff diffs 0 across the whole 0x26C-byte function.
- Unit fuzzy: 99.69818 -> 99.89328%.
- Exact functions 97/101 -> 98/101; matched code 21236 -> 21856 / 23988 bytes.
- Data 1964/1964 (100%) and linked status unchanged.
- Fresh baseline/candidate object comparison: all 97 previously objdiff-exact
function streams are unchanged. Raw .data, .rodata, .sbss, .sdata, .sdata2 and
.ctors bytes/extents are unchanged.
- Pool: all 81 strings identical to target.
- Literal audit: 86 arguments checked across 100 functions, no candidates or
errors. FriendListCache::update is skipped for its pre-existing size mismatch.
- Full 1027-unit report has no exact-function/code/data/fuzzy regressions.
- Full 43U build and build/43U/ok passed. DOL SHA1 remains
`26116613f624061ba99c8d1a299aaa6efa85670d`.
Host behavior verification extracts the production helper and method bodies and
uses deterministic UI/controller/font stubs. With -fno-fast-math,
-ffp-contract=off and undefined-behavior/bounds sanitizers, all 200,000 geometry
cases agree bit-for-bit with an independent target-ordered FP reference. Coverage
includes 66,667 null-text-box cases, empty/nonempty UTF-16 names, page offsets,
varied projection widths, both clamp branches and comparison boundaries. Font
lookup/width/character-call counts are also checked. Embedded name arrays are
valid objects; invalid-record/null-name pointer execution and Wii runtime UI
behavior are not claimed.
Private evidence: `/tmp/address-drag-reconstruction/` contains baseline/final
reports and source objects, drag-final.ctx, pool/literal audits, full-build.log,
validate_drag.py and drag-tests.log, plus the rejected source experiments. No
retail assembly or binary is included in this commit.
GATE: movePane_onDrag exact, behavior correction verified, all prior exact/data
metrics preserved. Other unit remainders and linking remain open. Frozen for
independent parent validation.

View File

@@ -0,0 +1,83 @@
# AES final-round word reconstruction, 2026-10-02
Base: `813660b9` plus local cherry-pick `97035641` of the parent's already queued
`fce31442`. The imported candidate and its log are unchanged. This follow-on
changes only two final-round expression lines in `libs/RevoEX/src/net/aes.c`
and this new log. 43U only; no configuration, metadata, headers or linking edits.
## Retained reconstruction
The last cipher round substitutes four bytes, places them in distinct unsigned
word lanes, and combines them before AddRoundKey. Encryption combines the high
and low lanes, combines the two middle lanes, then ORs those pieces. Decryption
combines high/low first, then the lower-middle and upper-middle lanes by XOR.
These expressions preserve byte indices, shifts, S-box identity, key traversal,
output order and all input/state reads. The four lane contributions are disjoint;
all operands are unsigned and have no side effects. No value, algorithmic path,
or table is newly invented. This is arithmetic-dependency reconstruction rather
than a new implementation or an exact-match claim.
The target evidence is the original split object's final substitution and
packing regions in `AESiEncryptBlock` and `AESiDecryptBlock`. Those regions
contain the same sixteen byte loads and word-lane insertion/XOR operations.
The retained grouping improves the whole-function instruction similarity at
the target's existing body sizes. It does not reproduce every target dependency
or register assignment: exact matching remains open, and positional ctxdiff
counts are slightly worse despite the improved aligned objdiff scores.
## Explored alternatives
- MD5 third-round Boolean grouping and four typed step helpers were tested.
The best small Boolean change only reached 94.37255% from 94.30719%; a larger
helper reached 94.43791%. Both were discarded as too little benefit for the
added change. MD5 source is byte-for-byte unchanged.
- Typed inverse-key word, round and complete-schedule helper scopes were tested.
A round helper reached 69.72908% decrypt similarity, but interacted poorly
with the better final-round grouping. No helper is retained.
- Fusing AddRoundKey into each intermediate column regressed both directions.
- Typed final-substitution helpers, packed-byte intermediates, and explicit
T-table column helpers were evaluated. Their source complexity was unnecessary
or they scored below the two retained macro changes.
- Twelve unsigned lane-combination expressions were checked for each final-round
macro. Two independently improving forms are retained. No register/declaration
sweep, assembly, volatile qualifier, undefined value, padding or compiler-option
change was used.
## Verification
Before -> after:
- AESiEncryptBlock: 62.58228 -> 65.81013% fuzzy; 158/158 instructions unchanged;
final ctxdiff 137 positional differences (baseline 133).
- AESiDecryptBlock: 67.64143 -> 69.69323% fuzzy; 251/251 instructions unchanged;
final ctxdiff 227 positional differences (baseline 224).
- AES unit: 79.601746 -> 81.09157% fuzzy; exact functions 7/9 and exact code
1116/2752 bytes unchanged. Data 2800/2800 (100%) and linking unchanged.
- All seven exact AES APIs/CBC functions retain objdiff 100% and ctxdiff diffs 0:
NETAESCreateEx 108/108, NETAESCreate 2/2, NETAESDelete 1/1, NETAESEncrypt 46/46,
NETAESDecrypt 46/46, NETiAESEncryptoBlock 39/39, NETiAESDecryptoBlock 37/37.
- AES pool: all four strings identical. .rodata 2592 bytes and .sdata2 8 bytes
identical. .data has the same 197-byte prefix of the 200-byte target, retaining
the existing three-byte target alignment extent; no padding was introduced.
- MD5 remains unit 96.179825%, ProcessBlock 94.30719% (306/306 instructions),
exact functions 3/4, exact code 600/1824, data 456/456. Its three exact APIs
retain ctxdiff diffs 0. All 448 .data bytes are identical; .sdata retains its
existing one-byte source/seven-byte target-alignment extent difference.
- Full 1027-unit report: no exact-function, exact-code, data or fuzzy regression
versus the locally imported parent candidate.
- Full 43U build and build/43U/ok passed. DOL SHA1 remains
`26116613f624061ba99c8d1a299aaa6efa85670d`.
Host tests compile production source unchanged with private copies of the existing
PPC type/intrinsic shims. Both final AES and the imported parent baseline passed
all 2,406 AES-128/192/256 known-answer and seeded randomized CBC checks, including
separate/in-place buffers and single/incremental calls. Unchanged MD5 passed all
3,088 known-answer/random/chunking checks. The MD5 test supplies RFC1321 padding
externally; GetDigest's target-endian length stores remain outside host coverage.
Private local evidence: `/tmp/crypto-reconstruction-next/` contains baseline/final
reports, pool/section/ctxdiff results, full-build.log, host validation scripts and
results, and the rejected experiments. No retail assembly or binary is committed
or uploaded. Prior worker logs under `/tmp/crypto-remainder/` are untouched.
GATE: validated partial arithmetic reconstruction with no report regressions.
Exact matching and linking remain open. Candidate frozen for parent validation.

View File

@@ -0,0 +1,71 @@
# AES round-expression reconstruction, 2026-10-02
Separate follow-on to AES key-cursor candidate `2a537c14`. Frozen MD5 candidate
`8a6461f9` and prior logs are untouched. This commit changes five expression
lines in `libs/RevoEX/src/net/aes.c`, plus this log. 43U only; no linking changes.
## Evidence and reconstruction
Target evidence remains the original split `aes.o`, AESiEncryptBlock and
AESiDecryptBlock. Both round bodies use four cyclic T-table columns: rotations
of 24, 16 and 8 bits plus the unrotated low-byte column. Their XOR dependencies
and the inverse-key transform's successive rotate/XOR dependencies lower in a
different order from the previous source. The retained expressions associate
these same unsigned contributions so compiler scheduling moves closer to the
target. Byte indices, rotation counts, table identity, key traversal, row order,
loop conditions and final substitution are unchanged.
The inverse-key transform still computes doubled/four-times/eight-times byte
values in the same GF(2^8) representation. Each subsequent stage combines its
old mixed value, its 8-bit rotation and the same added contribution. Explicit
XOR assignment replaces the compound assignment; all RHS values are evaluated
before the assignment, with no side effects or undefined evaluation order.
No source body or algorithm was missing. This is further instruction-shape
reconstruction, not a new functional path or an exact-match claim.
## Attempts
- Eight staged column/round helpers and six explicit table-load stages did not
improve both functions; reverted.
- Tested 120 associative/permutation forms of four T-table contributions,
retaining the independent improving expression for each cipher direction.
- Tested twelve uniform inverse-key XOR forms plus per-stage refinements. The
retained rotate-first XOR form improves all three stages without new helpers.
- Array/struct state views, a 15-by-4 round-key view, initial-key cursor forms,
and typed table helpers were evaluated. Small gains that required larger
changes were rejected, along with all regressions.
- No register declaration sweep, inline assembly, volatile qualifier, padding,
undefined input, compiler-option change or table change was used.
## Verification
Before -> after:
- AESiEncryptBlock fuzzy 60.348103 -> 62.58228%; 158/158 instructions unchanged;
final ctxdiff has 133 positional differences.
- AESiDecryptBlock fuzzy 63.836655 -> 67.64143%; 251/251 instructions unchanged;
final ctxdiff has 224 positional differences.
- Unit fuzzy 77.700584 -> 79.601746%.
- Exact functions 7/9, exact code 1116/2752 bytes, data 2800/2800 (100%), and
linked status are unchanged. All seven exact functions retain ctxdiff diffs 0.
- All four pool strings match. Table and data source is unchanged.
- Frozen MD5 source/metrics are unchanged: unit96.179825%, ProcessBlock94.30719%.
- The full 1027-unit report has zero exact-function/code/data/fuzzy regressions
against the immediately preceding frozen MD5/AES source report.
- Full 43U build and build/43U/ok passed. DOL SHA1 remains
`26116613f624061ba99c8d1a299aaa6efa85670d`.
`python3 /tmp/crypto-remainder/validate_aes.py` passed all 2,406 production-source
known-answer/randomized AES-128/192/256 CBC checks, including in-place buffers
and incremental calls. The frozen AES parent source independently passed the
same coverage in the same run. Input/key/IV words carry their PPC big-endian
numeric values in the native host harness; production source is unmodified.
Local evidence, not committed or uploaded: `/tmp/crypto-remainder/` contains
`aes.xor-results.json`, `aes.invmix-results.json`, `aes-rounds-final.json`,
`aes-rounds-AESiEncryptBlock.ctx`, `aes-rounds-AESiDecryptBlock.ctx`,
`aes-rounds-vectors.log`, `aes-rounds-full-build.log`, and `validate_aes.py`.
No original retail assembly or binary is included in this commit.
GATE: validated partial arithmetic/data-flow candidate; no regressions. Exact
matching and linking remain open.

View File

@@ -0,0 +1,20 @@
# AOSS WLAN connection argument contract
Base 9c7d87ab, 43U. This correction is separate from the key-material representation work.
AOSSConnectAndAwaitHost receives settings and config pointers but previously called AOSSi_WLANConnect through a false no-argument declaration. The actual callee takes a connection record and status output. In the original caller, incoming r3/r4 are forwarded untouched to the first call; the callee preserves r3/r4 and consumes both. The compiler happened to retain the same register contents despite the missing source arguments, hiding this defect behind exact generated code.
The local declaration now uses forward-declared struct AOSSConnection and struct AOSSConnectionStatus, matching the existing tags in AOSSLink.c. The wrapper explicitly passes settings and config. No shared header or AOSSLink.c edit. All three original outer callsites supply r3 = sp+0xb8 (settings) and r4 = s_accessPointConfig, matching the source caller expressions. No arguments are reordered or synthesized.
Validation:
- Configured/built 43U using the approved wibo wrapper and WIBO_SJIS_MISSING_IMPORTS=1
- AOSSConnectAndAwaitHost remains 60/60 instructions, ctxdiff zero
- Every code/data/relocation section, section header, and symbol record is byte-identical to baseline; only five compiler-generated anonymous local symbol spellings change in .strtab
- Full-project objdiff report unchanged: AOSS unit 97.71665% fuzzy, 16/21 exact, 6436 exact code bytes and 3928/3928 data bytes; no matching gain claimed
- Pool identical, 1/1 strings; literal audit checks 12 arguments across 19 functions, no candidates/errors; AOSS_Init_old and AOSSSendHelloRequest are skipped for their existing unequal sizes
- ASan/UBSan extracted-production wrapper harness passes 30,600 cases, asserting actual typed callee pointer identities, driver/startup failures, host readiness, cancellation, all retry boundaries and the original timeout behavior (cleanup and status clear, then return zero). No network calls occur; platform functions are controlled stubs
- LeakSanitizer disabled for ptrace restriction; address/undefined instrumentation enabled
- Full 43U build and ok gate pass; DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d
- git diff --check passes
Private reproducible evidence: /tmp/aoss-key-call-contracts, with original caller/callee disassembly retained privately under /tmp/aoss-decrypt-audit.

View File

@@ -0,0 +1,26 @@
# AOSS contiguous key-material representation
Base candidate: 00b02c27 (the separate WLAN argument-contract correction). Original branch base: 9c7d87ab. 43U only.
## Evidence and focused change
The original decryptor copies two raw nonce bytes and eight access-point bytes into consecutive positions of s_packetState, then passes that base and length 10 to AOSSInitKeySchedule. The original hello sender builds the same key. The key-schedule helper actually indexes all ten bytes; its instruction stream and resolved calls match the source exactly.
Previously the caller passed keyNonce[2] with length sizeof(keyNonce)+sizeof(keyAddress), relying on indexing beyond the first array member. AOSSKeyMaterial now represents the complete key as named nonce[2] and address[8] members. s_packetState embeds this key object, followed by its unchanged payload[0x5e]. Each schedule call uses a const u8 byte view of the complete key object with sizeof(key), so the byte span belongs to the object being viewed.
Only the two nonce copies, two address copies, and two key-schedule calls in AOSSDecryptMessage/AOSSSendHelloRequest are updated. No other packet representation, algorithm, checksum, byte order, allocation, validation, state transition, header or protocol change. No added storage, alignment, padding or assembly.
## Layout and gates
- Key size 10, nonce offset 0, address offset 2, packet payload offset 10, packet-state size 104, natural byte alignment unchanged
- Entire compiled AOSS.o is byte-identical to 00b02c27, including all payloads, symbol spellings and relocations
- Full-project objdiff unchanged from branch baseline: unit 97.71665% fuzzy, 16/21 exact, 6436 exact code bytes, 3928/3928 data bytes; no matching gain claimed
- DecryptMessage remains 97.74143%, 321/321 instructions and the same 87 allocation/operand differences
- Pool identical, 1/1; literal-reference audit still checks 12 arguments in 19 functions without candidates/errors, with the same two unequal-size skips (AOSS_Init_old and AOSSSendHelloRequest)
- ASan/UBSan extracted-production harness passes 68,423 cases: all 65,536 nonce byte combinations with varied addresses against an independent schedule model; every valid payload length 0..0x5c0; checksum/allocation/manufacturer/control error paths; 1,024 hello sender encryption round trips. It asserts key layout/content, unchanged trailing payload, output copy/checksum order and allocation cleanup. The production decryptor, sender, key scheduling, CRC table and name check execute; manufacturer scrambling and transport are controlled stubs, with no network activity
- The separate 30,600-case WLAN pointer/host-wait validator is rerun and passes
- LeakSanitizer disabled for ptrace restriction; address and undefined-behavior instrumentation enabled
- Full 43U build and ok gate pass; DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d
- git diff --check passes
Private reproducible validators, reports and build logs: /tmp/aoss-key-call-contracts. Original disassembly remains private in /tmp/aoss-decrypt-audit.

View File

@@ -0,0 +1,28 @@
# AOSS scan-result output-slot contract
Base: bf8ebfa3; 43U. One source line changed in AOSSLink.c.
## Evidence
Both actual callers are in AOSS.c. They declare AOSSi_WLANGetBSSList(void**) and pass &s_accessPointList, whose type is void*. The former definition instead accepted AOSSAccessPointList**, a different cross-translation-unit function type and an incompatible lvalue for publishing through that void* slot.
The definition now accepts void**. Internal list allocation, record types, parsing, callbacks, retries and ownership are unchanged. Assigning the typed internal list to *output now performs the ordinary C object-pointer-to-void* conversion. No AOSS.c/header or protocol change.
The read-only scan audit found no missing behavior: 227/227 instructions, 25 differences explained by real counter/descriptor register allocation plus independent constant/channel-store scheduling. Count and descriptor fields are unsigned halfwords; descriptor length scales by two. Scan capacity is 0x3200 bytes, output records are 84 bytes, and all 12 rate-mask entries fit the 16-byte rate array. Output remains published even if later cleanup/unlock failure changes the return value, as the target and callers require. No missing validation or unused-field initialization was invented.
Call-boundary verification pins actual ABI inputs, not just names or freely renamed registers: WD_Startup consumes flags in r3; WD_GetInfo the info pointer in r3; WD_Scan the scan pointer, buffer and length in r3/r4/r5; NCDUnlockWirelessDriver the saved positive driver ID in r3; the release callback receives 0/buffer/0 in r3/r4/r5. NCDLockWirelessDriver and WD_Cleanup genuinely take no caller arguments. Implementations were inspected, and all nine named AOSS/NCD/WD helper bodies additionally compare exactly with original instructions and resolved relocation destinations.
## Gates
- Baseline configured with the 43U wibo wrapper and built with WIBO_SJIS_MISSING_IMPORTS=1
- Entire AOSSLink.o is byte-identical before/after, including payload, symbols and relocations
- Full-project objdiff reports identical; no matching gain claimed
- Unit remains 99.007286% fuzzy, 12/14 exact functions, 668 exact code bytes, 2432/2432 data bytes
- GetBSSList remains 98.48018%, 227/227 instructions, same 25 differences
- Pool empty and identical; literal audit examines all 14 functions with no candidates/errors/skips (zero string arguments)
- ASan/UBSan host harness uses the extracted production scan/allocation/free functions and actual source structure declarations. Passes 18,825 scenarios: every 12-bit rate mask with all four mode-bit values, 200 variable-length descriptors exactly filling scan capacity, SSID width boundaries, callback/driver/allocation failures, retry limits, cancellation, partial-scan status, publication followed by cleanup/unlock failures, and actual void* output-slot canaries. Expected results and published fields are checked independently
- LeakSanitizer disabled for the execution environment's ptrace restriction; address and undefined-behavior instrumentation remain enabled
- Full build, build/43U/ok and git diff --check pass
- DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d
Private evidence and reproducible host validator: /tmp/aoss-scan-output-contract. Earlier original disassembly/call evidence remains private in /tmp/aoss-bss-audit.

View File

@@ -0,0 +1,62 @@
# BS2Tick control-flow reconstruction, 2026-10-02
Baseline BS2Mach source is 449529d9. This candidate changes only BS2Tick in
src/BS2/BS2Mach.c. Existing ESMisc and AOSSLink commits remain separate.
Initial pool_diff: 91/91 strings identical. Read the BS2 round-two/round-three
and fz1 attempt records, and compared the current five open functions with
fresh target objects. The Run hardware-handoff deficit is separate and is not
changed or represented as complete here.
## Retained source reconstruction
1. Express the title-family dispatch as the actual sparse set D/R/S/T.
The target compares D below R, then dispatches the contiguous R-through-T
group using an upper boundary U. The switch restores its branch pair and
makes the family set explicit. Exhaustively checked all 256 prefix values.
2. Restore the positive game-partition state transition and capture the
partition offset at entry to state 0x25, before either cache or disc path.
The target loads the partition member before choosing the cache branch;
the old source only read it on the disc path. The incoming partition
existence check and the state-37 fallthrough remain explicit.
3. Restore the banner address diagnostic's missing variadic argument.
Target BS2Tick object offsets 0x39B4–0x39D8 compute the aligned banner
pointer in r4, store it as BannerBuffer and pass it to BS2Report. The old
source supplied the %08X format with no argument on the allocation path.
4. Express the same next-cache-line calculation as allocation + 32 minus its
remainder modulo 32. This retains the target's strictly-next-line behavior,
including when the allocation is already aligned. It does not add padding
storage. Checked 196608 address samples including all low 16-bit values at
zero, 0x80000000 and near u32 wrap.
Measured attempts, all retained and individually nonregressing:
| Attempt | BS2Tick fuzzy | Unit fuzzy |
| --- | ---: | ---: |
| Baseline | 98.230415% | 98.159485% |
| Actual title-family switch | 98.35567% | 98.21673% |
| Partition entry and typed member snapshot | 98.58763% | 98.32273% |
| Banner diagnostic argument | 98.59278% | 98.32509% |
| Explicit next-cache-line remainder | 98.639175% | 98.34629% |
BS2Tick grows from 1934 to 1937 instructions; target is 1940. The remaining
three missing instructions are address-materialization differences, with
additional register and instruction-scheduling differences. This is partial
reconstruction/matching progress, not an exact function.
## Verification
- Full all_source / fresh report / build/43U/ok requested after focused build
- DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d
- Exact functions unchanged: 24/29; exact code unchanged: 4940/16980
- Data unchanged: 155504/158528 (98.092445%)
- Every other unit's report unchanged
- The 91-string pool is identical; literal reference audit checks 37 arguments
across 24 exact functions with no candidates or errors
- Compared all 1027 source objects with the initial snapshot: only previously
committed ESMisc and this BS2Mach object differ. BS2Mach .text 16828 -> 16840
bytes, 1306 relocations on both sides; .data stays 3020 bytes and 155 jump-table
relocations; all other allocated sections/objects are unchanged
- git diff --check passes
No BS2Update, shared-header, metadata, link-flag or assembly change is included.

View File

@@ -0,0 +1,26 @@
# CDB crypt-buffer ownership contract
Base: 20ba34a8, 43U. Focused source correction after the read-only CDBRecordEncrypt audit found only register-allocation differences in that function.
## Evidence and change
CDBRecord.c already declares CDBCryptBufAllocate and CDBCryptBufFree with CDBCryptBuf** parameters. Its callers supply the address of the record's crypt-buffer pointer slot. CDBCrypt.c instead declared CDBCryptBuf* and accessed buffer32[0] as a u32-encoded pointer, producing incompatible cross-translation-unit function types and describing the caller's pointer slot as an entire crypt-buffer object.
Both definitions now take CDBCryptBuf** and use direct typed pointer loads/stores. Allocation assigns the pool pointer; free compares the owned pointer and clears the slot to NULL. The existing pool-index expression, flag update order, diagnostics and failure behavior are retained. The obsolete placeholder comment is removed. No header, payload layout, pool extent, Encrypt implementation, or linking change.
## Validation
- Configure: `python3 configure.py --version 43U --wrapper ../toolchain/wibo-build/wibo`
- Build: `WIBO_SJIS_MISSING_IMPORTS=1 ../.venv/bin/ninja`
- Entire compiled CDBCrypt.o is byte-identical to the baseline, including all code/data, symbols and relocations
- CDBCryptBufAllocate: 36/36 instructions, ctxdiff zero
- CDBCryptBufFree: 33/33 instructions, ctxdiff zero
- Unit remains 100% fuzzy, 3/3 exact functions, 296/296 code bytes and 80/80 data bytes
- Full-project before/after objdiff reports are identical; no metric gain is claimed
- Pool identical: 2/2 strings; literal-reference audit: 2 arguments across all 3 functions, no candidates/errors/skips
- Host test compiles the production source with the actual CDBCryptBuf layout and minimal platform/error stubs. AddressSanitizer and UBSan pass 50,036 ownership transitions, including every combination of six representative allocation flags and null/owned/foreign pointer slots, 10,000 randomized state cases, and 10,000 allocate/reallocate/free/refree cycles. Checks cover pointer-slot canaries, complete payload preservation, allocation flag, return value and diagnostic count
- LeakSanitizer is disabled because it cannot run under this execution environment's ptrace; the harness makes no heap allocations. Address and undefined-behavior instrumentation remain enabled
- Full 43U build and build/43U/ok pass; DOL SHA1 is 26116613f624061ba99c8d1a299aaa6efa85670d
- git diff --check passes
Private reproducible evidence is in /tmp/cdb-buffer-ownership (baseline object, full reports, host validator and build log). Original objects/disassembly from the preceding read-only audit remain private under /tmp/cdb-record-encrypt-audit.

View File

@@ -0,0 +1,99 @@
# Alpha comparison and output boundary follow-on, 2026-10-02
Base: 813660b9 plus unchanged one-key candidate 2ec4a57e, locally fe647fe4.
Changed source: libs/RVLMiddleware/eZiText/src/clib/zi8alpha.c only.
No ABI, shared header, linking flag or other source change is included.
## Retained target source structure
- At function +0x25A8, the suffix truncation condition compares the combined
word/prefix length first and branches on less-or-equal. Recovered that
operand order. The separate bound check at +0x25E0 has the opposite operand
order and is deliberately preserved.
- The dictionary lookup comparisons at +0x2948, +0x2978 and +0x2990 compare
the dictionary scan index first against word length or the halfword-narrowed
dictionary count. Recovered those three relational expressions without
changing the count helper's declaration or its halfword conversion.
- The punctuation fallback at +0x30F8 compares against 0xF010 and uses a
strict greater-than failure branch. Replaced the equivalent < 0xF011 test
with <= 0xF010.
- The output-count branch at +0x3B08 falls through to clear letters when
countOnly is true, and branches to the actual-count store otherwise.
Restored that original arm order.
- Prefix selection at +0x3B84 compares against 1 and uses less-or-equal.
Recovered <= 1 instead of the equivalent < 2.
These are demonstrated control-flow and expression reconstructions, not
register/declaration permutations. No new volatile, assembly, forced register,
padding, artificial storage, or undefined value is introduced.
## Isolated trials and rejected work
Trials used the live 43U Ninja compiler command, separate source/objects and
reports under /tmp/ezi-next, without changing the worktree before selection.
Columns: unit fuzzy / matched data bytes / exact functions.
- Output-count arm order: 96.47729 / 516 / 11
- Both inclusive boundary expressions: 96.3798 / 516 / 11
- Both maximum-length comparison orders: 96.38128 / 516 / 11
- Dictionary comparison order: 96.38405 / 516 / 11
- Initial four-group combination: 96.48966 / 516 / 11
- Final reviewed combination, preserving the second length comparison's
original operand order: 96.52474 / 516 / 11
Further target-evidenced trials were rejected rather than committed:
- Safe temporary plus postfix prefix append: 94.71085 / 336 / 11
- Safe temporary plus postfix highlighted append: 94.60377 / 336 / 11
- Dictionary-kind switches: 96.364845 / 408 / 11
- Early candidate skip: 96.451996 / 408 / 11
- Combined candidate-count limits: 96.402695 / 408 / 11
- Full dictionary source structure plus initial boundary combination:
96.78767 / 408 / 11; function extent 0x3DB8 versus 0x3DA8
- Explicit prefix-mode byte: 96.40805 / 408 / 11
- Explicit element-count byte: 96.3582 / 408 / 11
- Skip/count/byte combinations retained extent mismatches and were rejected.
One-key spelling compound count assignment was codegen-neutral. Prefix
increment removed the redundant byte narrowing but worsened allocation:
unit 98.23523 -> 97.36198. Neither trial is retained.
Chinese explicit halfword casts at the two paired phonetic comparisons and
an alternative proper halfword return declaration with redundant casts removed
both reproduce the previously parked result: unit 96.848755, matched data
144 -> 72. Adding the demonstrated component-cursor reload gives 96.489876
with the same loss. All remain scratch experiments, with no Chinese edit or
neutral PUD ABI commit included.
## Validation
Fresh full report: /tmp/ezi-next-alpha-full-report.json.
Full-build log: /tmp/ezi-next-alpha-full-build.log.
Baseline report: /tmp/ezi-next-baseline.json.
Zi8AlphaGetCandidates: 95.02813% -> 95.23011%.
Unit fuzzy: 96.37759% -> 96.52474%, about 31.88 weighted bytes gained.
Exact functions remain 11/12; exact code remains 5880/21664;
matched data remains 516/564. No complete unit or new exact function claimed.
All 1027 units were compared for fuzzy, matched-code, matched-data and exact
function measures: the alpha fuzzy improvement is the sole changed measure,
with no regressions.
Pool checked first: identical and empty. Main function stays 3946/3946
instructions and 0x3DA8 bytes, with the same 0x2B0 frame. Strict ctxdiff is
nonzero (3738 differences); existing scalar-stack displacement and register
allocation remain. Each of the 11 existing exact functions retains identical
instruction counts and ctxdiff diffs 0.
Baseline/candidate .rodata, .data, extab and extabindex have identical payloads
and canonical relocations. Relative to the target, extab and extabindex remain
byte-identical; the unchanged generated switch relocations remain unmatched.
The source rodata's pre-existing 330-byte size versus target 336 is unchanged;
objdiff still reports 100% for that section and the same exact-data accounting.
Advisory branch mapping checks 709 same-mnemonic branch pairs with zero
mapped destination mismatches, and 73/73 helper calls. It is not an exactness
or formal equivalence claim.
Full 43U build passes with the approved wrapper and WIBO_SJIS_MISSING_IMPORTS=1.
DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
git diff --check passes. No remote actions were performed.

View File

@@ -0,0 +1,65 @@
# Alpha output and scan reconstruction follow-on, 2026-10-02
Parent candidate: `94b7f57e`. Its source/log were left unchanged during
independent side experiments. No ABI/header/linking changes are included.
Changed source: `libs/RVLMiddleware/eZiText/src/clib/zi8alpha.c` only.
## Target evidence and retained changes
- At `Zi8AlphaGetCandidates +0x3178`, the original emits wide-character
output before the encoded-byte alternative. The wide path assigns the
same zero to output elements 2 and 1 (+0x31A4/+0x31A8), then advances by
two characters. The encoded path likewise shares its zero assignment.
Restored that positive branch and ordinary chained zero assignments.
- The dictionary comparison loop branches from +0x2904 to its bound check
at +0x292C. The comparison body exits on a character mismatch at +0x2924;
a matched character increments the index at +0x2928. Replaced the merged
`for` condition with the corresponding bounded loop and explicit break.
- The punctuation output block at +0x1B0C..+0x1B1C reads the current cursor,
emits its character and advances that same cursor. Expressed this with
`wordCursor[1] = *punctuationCursor++`. It does not reuse a mutated index
in another operand or introduce an unsequenced read/write.
## Independently compiled, isolated trials
Each trial used the exact 43U MWCC flags from the live Ninja command and a
separate object/report under `/tmp/ezi-side`, without altering the reviewed
worktree candidate. Report columns below are function fuzzy, unit fuzzy,
matched data bytes and exact-function count:
- Early candidate-skip block: 94.65585, 96.10635, 408, 11; excluded
- Wide output first: 94.887985, 96.27548, 516, 11; retained
- Next-dictionary switches: 94.4037, 95.92264, 408, 11; excluded
- Explicit dictionary-scan break: 94.62088, 96.08087, 516, 11; retained
- Combined candidate-count limit: 94.35884, 95.88995, 408, 11; excluded
- Punctuation cursor increment: 94.4782, 95.97692, 516, 11; retained
- Wide output plus scan: 95.02306, 96.37389, 516, 11
- Final three-change subset: 95.02813, 96.37759, 516, 11
## Full current-worktree validation
Fresh report: `/tmp/ezi-alpha-followup.json`.
Full build log: `/tmp/ezi-alpha-followup-build.log`.
Exact functions 11/12 unchanged; exact code 5880/21664 unchanged;
exact data 516/564 unchanged. Unit fuzzy 95.97323% -> 96.37759%.
Function fuzzy 94.47314% -> 95.02813%, about 88 additional weighted bytes.
Relative to initial 449529d9, unit fuzzy improves 94.17892% -> 96.37759%.
Pool first: identical (no narrow strings in either pool).
Main function: 3946/3946 instructions, 0x3DA8 bytes each, frame 0x2B0.
Strict ctxdiff remains nonzero (3745 differences), dominated by the known
scalar-stack displacement, instruction placement and GPR allocation. No
new exact function is claimed. Each of the existing 11 exact functions
retains identical instruction counts and ctxdiff diffs 0.
All non-text section scores match the parent: .rodata, extab and extabindex
remain 100%; the existing 48-byte generated switch table remains unmatched.
The advisory register-normalized/control-flow alignment checked 701 branch
pairs with zero destination mismatches and 73/73 helper calls. This is a
coverage check, not an exactness claim.
Full 43U build succeeds with the approved wrapper and
`WIBO_SJIS_MISSING_IMPORTS=1`. DOL SHA1:
`26116613f624061ba99c8d1a299aaa6efa85670d`.
`git diff --check` succeeds. No new assembly, volatile workaround, register
forcing, undefined value, dummy storage, prototype or shared-header change.

View File

@@ -0,0 +1,55 @@
# Bpmf consumed-count return contract, 2026-10-03
Base: 029dd7ea on the Chinese source-reconstruction leaf. Previous candidates
are unchanged. Owned source: zi8match.c / Zi8GetBpmfPhonetic only.
This is type-correctness reconstruction with zero percentage gain.
## Evidence and change
All three source callers declare Zi8GetBpmfPhonetic as returning ziU8:
zi81key.c, zi8space.c and zprepare.c. The definition instead returned ziS32
and used a ziU32 resultCount. Its result is the consumed Bopomofo character
count: the four sequential initial/medial/final/tone stages can increment it
at most four times, and all failure paths return zero. There is no negative
result or full-word quantity to communicate.
Changing only the return type to ziU8 introduced return narrowing and made
the previously exact function nonexact (98.64078%, exact count8 ->7). That
isolated trial was rejected. Recovering the counter's own byte type along
with the byte return restored the entire309-instruction exact function.
The retained two-line change therefore aligns all caller declarations and
the bounded consumed-count representation without explicit casts or masks.
No caller, shared header, parameter or control flow is changed.
## Other remaining-helper inspection
A fresh Zi8GetPyPhonetic audit found718/718 instructions. One fixed bijection
among its six differing callee-saved registers makes every instruction,
branch destination, call and relocation identical. It remains nonexact;
the register map is diagnostic only and was not encoded in source.
Zi8GetPyFinal remains53/53 instructions with eight differences in two table
row-address calculations. Each computes the same table +8*row address into
the same result register, uses identical byte-column offsets4 and5, and has
no live-out dependence on the differing temporary. No type/access/flow defect
was found in either nonexact helper, and no allocation sweep was performed.
## Validation
Baseline object: /tmp/ezi-pinyin-contract/baseline.o.
Fresh full report: /tmp/ezi-bpmf-byte-full-report.json.
Full build: /tmp/ezi-bpmf-byte-full-build.log.
Detailed checks: /tmp/ezi-bpmf-byte-verification.txt.
All1027 full-report unit measures are unchanged. zi8match remains99.53004%
fuzzy,8/10 exact functions,5172/8256 exact code and728/728 exact data.
All emitted .text/.rodata/extab/extabindex lengths, payload bytes and canonical
relocations are baseline-identical. No new exact function or percentage gain
is claimed. Each of the eight existing exact functions has ctxdiff diffs0
and identical instruction counts; Zi8GetBpmfPhonetic remains309/309.
Pool first: identical and empty. Full43U build passes with the approved
wrapper and WIBO_SJIS_MISSING_IMPORTS=1. DOL SHA1:
26116613f624061ba99c8d1a299aaa6efa85670d.
git diff --check passes. No remote, linking, shared-header, metadata, assembly,
volatile, artificial storage, forced-register or undefined-value change.

View File

@@ -0,0 +1,75 @@
# Chinese phonetic callee contract, 2026-10-02
Base: 654c65dd; branch agent/bittle/chinese-source-reconstruction.
Changed source: libs/RVLMiddleware/eZiText/src/clib/zi8cgetc.c only.
This is type-correctness work with zero code-generation or percentage gain.
## Callee evidence
The actual Zi8MatchPhonetic definition in zi8match.c takes a byte-addressed
12-byte dictionary, a native-width ziU32 dictionary address, a byte record
pointer, and two byte-pointer outputs. In particular its stringOffset output
is ziU8**: it tests *stringOffset, compares a sound cursor against it, and
writes the sound cursor to it. It is not an integer index output.
The old zi8cgetc declaration instead described records and the record output
with a different struct-pointer type, the dictionary address as ziPtr, and
the string output as int*. The two engine calls cast &phoneticGroups to
int*. The third call, in Zi8NewMatchPhonetic, supplied an address-taken int
matchedIndex even though the callee wrote a pointer through it.
The corrected local declaration now has exactly the callee's parameter
representations and compatible C types:
- ziPtr for the opaque phonetic table
- ziU8* for the dictionary and current record
- ziU32 for the packed-table address
- ziU8** for the current-record and string-cursor outputs
- the unchanged matching halfword, byte and workspace parameter types
All three call sites were inspected and updated. The engine's real byte
pointer variables can now be passed by address directly, without incompatible
pointer-to-pointer casts. The small exact helper retains its typed dictionary
array but passes its byte address and uses actual byte-pointer output locals;
matchedString names the recovered cursor role. No shared header or callee
implementation is changed, and the pointer-to-native-word cast is explicit
only at the callee's existing native-address argument boundary.
## Isolated investigation
- Native 12-byte dictionary table indexing: codegen/metrics unchanged
- Named dictionary-record stride: codegen/metrics unchanged
- String-pointer output correction alone: codegen/metrics unchanged
- Complete callee contract, all three call sites: codegen/metrics unchanged
Only the callee-contract correction is retained. These are source-type
checks, not register/declaration-order permutations. The previously parked
halfword-result and component-cursor experiments were not repeated in this
candidate or combined incidentally.
## Validation
Baseline: /tmp/ezi-chinese-recon-baseline.json.
Final full report: /tmp/ezi-chinese-contract-full-report.json.
Full build: /tmp/ezi-chinese-contract-full-build.log.
Detailed checks: /tmp/ezi-chinese-contract-verification.txt.
All 1027 full-report unit measures are unchanged. Unit fuzzy remains
96.65468%; zi8InternalGetZH remains 96.27482%. Exact functions remain 5/8,
exact code 4168/47816, and exact data 144/536. No metric gain is claimed.
Compared with a preserved baseline object, every owned code/data section has
identical length, payload bytes and canonical relocation tuples:
.text 47816, .sdata2 16, .sbss2 8, .data 392, extab 48, extabindex 72.
The NOBITS section is checked by extent; all other payloads compare bytewise.
Pool first: identical and empty. All five baseline exact functions retain
ctxdiff diffs 0 with identical instruction counts:
Zi8SetFindCand 50, ZiGetNextPhonetic 31, ZiPartialMatch 51,
Zi8NewMatchPhonetic 755, Zi8GetChineseCandidates 155.
The unmatched engine remains 10676/10676 instructions; its code payload and
relocations are baseline-identical as well.
Full 43U build passes with the approved wrapper and WIBO_SJIS_MISSING_IMPORTS=1.
DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
git diff --check passes. No linking, remote, metadata, shared-header, assembly,
volatile, artificial storage or register-forcing changes.

View File

@@ -0,0 +1,75 @@
# Chinese user-dictionary address contract, 2026-10-03
Base: `5dcbc437`; branch `agent/bittle/chinese-uwd-address-contract`.
Changed source: `libs/RVLMiddleware/eZiText/src/clib/zi8cgetc.c` only.
This is a type-correctness correction with no matching-percentage gain.
## Source and target evidence
The exact `Zi8GetZHuwdPtr` definition in `zi8ZHuwd.c` returns `ziU32` and
writes a native `ziU32` address through its first argument. It clears that
word on failure, or stores the selected dictionary address and adds its
eight-byte header on success. Its second output is a halfword entry count;
its third argument is the workspace. Both return paths produce zero or one.
The original objects contain exactly two executable references, from
`Zi8Get1KeyPressCandidates` and `zi8InternalGetZH`, plus the callee's own
exception-index reference. The accepted one-key source already uses the
definition's native address representation and explicitly narrows status.
The Chinese caller passes its stack word at 0x10C in r3, its halfword at
0x9A in r4, and the workspace in r5. After the call it explicitly narrows
the returned status to a byte. It loads the address word to decode bytes
at offsets one and two, checks a flag through the same address, and advances
that address by three for each entry. The address output does not escape
anywhere else.
The correction agrees with the real definition: the local extern returns
`ziU32` and takes `ziU32*`; `userEntriesAddress` has that native unsigned
word type. The three byte reads use explicit byte-pointer views, the loop
keeps its increment by three, and the status test has an explicit byte cast.
No additional local, helper, shared-header change, control-flow change or
unrelated prototype correction is included.
## Validation
Fresh baseline: `/tmp/ezi-chinese-uwd-baseline.json`.
Fresh final report: `/tmp/ezi-chinese-uwd-final.json`.
Full build: `/tmp/ezi-chinese-uwd-full-build.log`.
Detailed checks: `/tmp/ezi-chinese-uwd-verification.txt`.
All 1027 complete source objects are byte-identical to the fresh baseline,
including `zi8cgetc.o` and its symbol/relocation metadata. The entire decoded
1027-unit report is identical. Unit fuzzy remains 96.65468%; engine fuzzy
remains 96.27482%, with 10676/10676 instructions. Exact functions remain 5/8,
exact code 4168/47816 bytes, and matched data 144/536 bytes.
Pool checked first: identical and empty. All five exact functions retain
ctxdiff diffs zero: Zi8SetFindCand 50 instructions, ZiGetNextPhonetic 31,
ZiPartialMatch 51, Zi8NewMatchPhonetic 755, Zi8GetChineseCandidates 155.
The existing advisory flow audit still agrees on 168 ordered calls, 1594
mapped direct branches and all 98 generated switch destinations. This
normalization is diagnostic, not an exact-match claim for the engine.
Full 43U build passes with the approved wrapper and
`WIBO_SJIS_MISSING_IMPORTS=1`. DOL SHA1 remains
`26116613f624061ba99c8d1a299aaa6efa85670d`. `git diff --check` passes.
No return-width experiments, artificial storage, assembly, volatile use,
linking changes or remote operations were performed.
## Read-only remainder review
Both large engines were compared with current main before editing. Their
sources were unchanged. Chinese's remaining normalized instruction gaps
are return-copy placement, the already-tested component-cursor reload,
and the two previously parked paired-phonetic halfword conversions. Those
experiments were not repeated.
Alpha's early initialized dictionary index remains necessary in the
reconstructed source: highlighted-output capacity exits reach optional
dictionary-count finalization before the dictionary loop. The target's
unused workspace store supplies no demonstrated source lifetime. Previous
attempts already cover separate/direct exclusion results, dictionary-kind
switches, candidate-skip order, updated-count comparisons and prefix append
forms. This pass found no new supported alpha lifetime or control-flow
representation to trial, and left alpha unchanged.

View File

@@ -0,0 +1,67 @@
# Chinese Zhuyin initial dispatch correction, 2026-10-02
Parent: 1b1a944a on base 654c65dd. The pointer-contract candidate is unchanged.
Changed source: two case-label lines in zi8cgetc.c / zi8InternalGetZH.
This is a demonstrated behavioral correction; aggregate metrics are neutral.
## Discovery
A complete fresh flow audit checked the compiler-generated switch tables as
well as direct branches. All 1594 mapped direct branches and all 168 ordered
helper calls agreed before this change. However, four of the 98 generated
switch relocation entries dispatched to the wrong semantic bodies. A direct
branch-only audit cannot see that defect, and the linear effect audit compares
both bodies without knowing which switch cases reach them.
The relevant switch uses the phonetic initial (match.phon2[index] >> 9),
subtracts case 24 for its 40-entry table and rejects indexes greater than39.
The table starts at .data+0x58. Its four incorrect entries were:
- .data+0xC8, case52: source selected bANDp; target selects gANDk
- .data+0xD4, case55: source selected bANDp; target selects gANDk
- .data+0xE8, case60: source selected gANDk; target selects bANDp
- .data+0xF4, case63: source selected gANDk; target selects bANDp
The bodies are identified by their actual tests of the workspace word at
0x1B2C: bANDp tests the bit at MSB-relative position10, while gANDk tests
position11. Both successful bodies store the same phonetic mask0xF9FF, but
they consult independent user fuzzy-pair settings. Crossing the labels
therefore changes behavior, even though both body instruction shapes match.
Target cases52/55 enter function+0x1288 (position11), while60/63 enter+0x1264
(position10). Current compiled bodies are four bytes later, and the corrected
entries now select their corresponding semantic bodies.
The fix swaps only the two case-label pairs, preserving body/source order,
header layout, tests, masks, all other cases and function size. It does not
change shared bitfield names to compensate for the bad dispatch.
## Verification
Fresh report: /tmp/ezi-chinese-switch-full-report.json.
Full build: /tmp/ezi-chinese-switch-full-build.log.
Detailed gates: /tmp/ezi-chinese-switch-verification.txt.
Switch/direct-flow audit: /tmp/ezi-chinese-switch-flow-audit.txt.
After correction, all 98 switch entries have corresponding target semantic
destinations, with zero destination mismatches. The four table extents remain
44,44,160,144 bytes. The 1594 mapped direct branches and168 ordered helper
calls also still agree. This is an advisory relocation/control-flow check,
not formal whole-program equivalence or a claim of exact assembly.
Every code/data section size and payload is baseline-identical. All normalized
relocations are unchanged except exactly the four corrected .data entries.
The .text section, extab and extabindex are unchanged byte-for-byte. The
engine stays10676/10676 instructions with the same0x4E0 frame.
All1027 unit measures are unchanged with no regressions. Unit fuzzy remains
96.65468%; engine fuzzy96.27482%. Exact functions5/8, code4168/47816 and
matched data144/536 are preserved. The switch section remains unmatched
because case body addresses still differ from the target; no percentage or
new exact function is claimed.
All five previously exact functions still have ctxdiff diffs0 and identical
instruction counts. Pool first: identical and empty. Full43U build passes
with the approved wrapper and WIBO_SJIS_MISSING_IMPORTS=1. DOL SHA1:
26116613f624061ba99c8d1a299aaa6efa85670d.
git diff --check passes. No shared header, metadata, link flag, assembly,
volatile, register/storage workaround, or remote action was changed.

View File

@@ -0,0 +1,57 @@
# Secondary component matcher workspace formal, 2026-10-02
Parent: bfcc8a44. Scope extension to zi8match.c was coordinated before editing.
Changed source: the Zi8SecMatchComp definition's parameter list only.
This is an interface correction with no percentage or code-generation gain.
## All-caller and callee evidence
A source-wide search finds one caller, in zi8InternalGetZH, and its explicit
four-argument declaration. A scan of every extracted43U object's relocation
tables likewise finds exactly one text reference, in zi8cgetc.o. The only
other direct symbol reference is the function's own extabindex entry.
No function-pointer data reference or second callsite was found.
The target caller at zi8InternalGetZH+0x8380 supplies the component cursor,
match object, dictionary base and workspace in argument registers3..6.
The workspace is the same saved incoming pointer used by the surrounding
engine helpers. This agrees with the reconstructed caller and its declaration.
The target callee is68 instructions /0x110 bytes and does not consume the
incoming fourth argument. Every path that reads register6 first defines a
new temporary there; no incoming workspace load or use is present. The
missing fourth formal is therefore an unused workspace parameter, consistent
with neighboring component matchers' ZI_NEED_WORK convention. Removing the
caller argument would contradict the target call sequence.
Added ZI_NEED_WORK to the existing definition, preserving its first three
formals and entire body. No local or storage was added, no value was made
volatile, and no register/spill was forced. The existing shared macro simply
expands to the same ziPtr workspace formal already declared by the caller.
No shared header or caller change was needed.
## Validation
Before-object: /tmp/ezi-chinese-reconstruction/zi8match-before-work-formal.o.
Fresh full report: /tmp/ezi-component-contract-full-report.json.
Build log: /tmp/ezi-component-contract-full-build.log.
Detailed checks: /tmp/ezi-component-contract-verification.txt.
All owned emitted sections have identical lengths, payloads and normalized
relocations: .text8256, .rodata528, extab80, extabindex120. The compiler
comment section is also unchanged. Symbol entries, relocation records and
section extents are unchanged; only compiler-generated anonymous extab names
in .strtab advance numerically after the additional formal. The entire object
file is therefore not byte-identical, but its emitted code/data and relocation
meaning are identical. No symbol-metadata edits were made to hide this.
All1027 full-report unit measures are unchanged. zi8match remains8/10 exact,
5172/8256 exact code,728/728 exact data and99.53004% unit fuzzy. All eight
baseline exact functions have ctxdiff diffs0 and identical instruction counts;
Zi8SecMatchComp remains68/68 instructions,0x110 bytes and exact100%.
Pool first: identical and empty. Full43U build passes with the approved
wrapper and WIBO_SJIS_MISSING_IMPORTS=1. DOL SHA1:
26116613f624061ba99c8d1a299aaa6efa85670d.
git diff --check passes. No remote, linking, shared-header, assembly, metadata,
artificial storage or undefined-value change.

View File

@@ -0,0 +1,78 @@
# Conversion table-address contract, 2026-10-03
Base: 20ba34a8. Owned source: zconvert.c only. This candidate corrects a
cross-unit declaration; it has no percentage gain.
## Definition-backed correction
zaddress.c defines Zi8GetTableAddress as returning ziU32. It forwards the
ziU32 result of Zi8GetTableData, whose address case explicitly converts the
computed dictionary pointer to an integer address. Its target wrapper
forwards the full register result without a byte or halfword narrowing.
zconvert.c instead declared the same function as returning ziPtr. Correct
that local declaration to ziU32 and explicitly convert the returned address
at the three existing table-pointer assignments: ziU8* for UC2WC, and
ziConversionTable* for WC2UC and UC2Key. These are the only four source-line
changes. No callee, shared header, lookup representation or control flow is
changed.
## Read-only UC2Key investigation
The original remaining function is 207 instructions / 828 bytes, with 18
register-operand differences. Exchanging the two diagnostic work/key register
names makes every instruction, branch destination, memory operand, call and
relocation annotation identical. The mapping is only used by the audit and
is not expressed in source.
The existing packed representation agrees with target accesses:
- Serialized header count is a big-endian byte pair at offsets 0 and 1.
- Serialized entries have an eight-byte stride. First/last/value are byte
pairs at offsets 0/2/6; the intervening flags pair is not read here.
- A ranged mapped-key result is another big-endian byte pair, reached via
header + 8 + entry value + 2 * (character - first).
- The native fallback range instead uses halfword first/last fields at 0/2
and a word pointer-or-character union at 4. A singleton explicitly keeps
the low byte of the word; mapped keys use native halfword loads.
- The native default object is exactly 32 zero bytes, with no target data
content or relocation supporting a different field layout.
The declared halfword result is also correct. The original reference scan
finds only three executable callers plus the function's exception-index
reference. PUD and UWD pass a byte character and narrow the return to a
halfword before comparing their halfword pattern. WC2Key forwards the result
without additional narrowing. The user-key helper definition likewise
returns a halfword, including the EFFx key range. GetTableCount's declaration
already agrees with its halfword-returning definition and target narrowing.
Prior fz2/fz21 attempts already cover const views, key widths, pointer/local
lifetimes, result initialization, expression grouping, and declaration order.
No new packed-width or control-flow defect was found. No allocation trial
was repeated.
## Verification
Fresh configure and baseline full build used 43U, the approved wibo wrapper,
and WIBO_SJIS_MISSING_IMPORTS=1. Pool checked first: identical and empty.
After the four-line correction, all 1,027 source objects are entirely
byte-identical to their baseline hashes, and the complete 1,027-unit report
is identical. The owned .text, .rodata, extab and extabindex payloads and
canonical relocations were additionally compared explicitly.
Unchanged unit: 99.83696% fuzzy, 3/4 exact functions, 1,380/2,208 exact code
bytes, and 112/112 exact data bytes. UC2Key remains 99.565216%.
All existing exact functions retain ctxdiff zero differences:
UC2WC 124 instructions; WC2UC 199; WC2Key 22.
Final full 43U build passes. DOL SHA1:
26116613f624061ba99c8d1a299aaa6efa85670d.
git diff --check passes. No assembly, artificial storage, volatile, metadata,
linking flags, shared-header edits, other-region builds or remote writes.
Private local verification artifacts:
- /tmp/ezi-conversion-baseline.json
- /tmp/ezi-conversion-final-report.json
- /tmp/ezi-conversion-final-build.log
- /tmp/ezi-conversion-verification.txt
- /tmp/ezi-conversion-caller-audit.txt

View File

@@ -0,0 +1,51 @@
# Korean empty-context flow recovery, 2026-10-03
Base: 1fa33882; branch agent/bittle/korean-candidate-reconstruction.
Owned source: zkokeyp.c / Zi8GetKOcandidates only.
## Target evidence
The first context-length test at target function+0x158 sends an empty current
word directly to+0x730, the input-length/key-table scan setup. The compiled
source instead sent this case to its+0x6C8, the prefix-search result copy and
candidate cleanup. That block corresponds to target+0x6BC, which is reached
only after a nonempty context lookup attempt or word-table search.
Added an explicit empty-context guard to a label immediately before the
existing input-length check. The nonempty prefix-search paths still enter
search_table and perform the original result/candidate cleanup. The change
recovers the target control-flow edge without moving any body or introducing
storage, helper calls, or artificial register constraints. The old edge did
not necessarily change visible output for initialized empty context; this
is a target-flow correction, not a claim of a newly demonstrated user bug.
## Validation
Fresh baseline: /tmp/ezi-korean-recon-baseline.json.
Fresh final report: /tmp/ezi-korean-flow-full-report.json.
Full build: /tmp/ezi-korean-flow-full-build.log.
Detailed gates: /tmp/ezi-korean-flow-verification.txt.
Zi8GetKOcandidates: 97.96712% ->97.97459%.
Unit fuzzy: 98.65385% ->98.65769%.
Exact functions remain1/7, exact code332/5200, matched data96/180.
All1027 units were checked: the unit fuzzy gain is the only changed measure,
with no code/data/function or fuzzy regressions. No new exact function claimed.
The source object differs from its preserved baseline at exactly one .text
payload byte, the corrected branch displacement. All section sizes and all
canonical relocation tuples remain unchanged. .data40, extab56 and
extabindex84 are byte-identical to baseline. The unit's existing exact
Zi8_81483118 remains83/83 instructions and ctxdiff diffs0, with its exact
10-entry generated switch table unchanged.
Pool first: identical and empty. Main still673/669 instructions; the known
extra zero materialization, two lookup-result narrowings and return-value
move remain. All92 mapped direct main branches now preserve their target
destinations; the17 ordered helper calls agree. The filter's43 direct branches
also agree. These are advisory correspondence checks, not an exactness claim.
Full43U build passes with the approved wrapper and WIBO_SJIS_MISSING_IMPORTS=1.
DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
git diff --check passes. No header, metadata, linking, remote, assembly,
volatile, dummy-storage or forced-register changes.

View File

@@ -0,0 +1,76 @@
# Korean lookup halfword contract, 2026-10-03
Parent: dea3851e; its empty-context correction is unchanged.
Owned source: zkokeyp.c / Zi8_8148302C and its two local callers.
## Recovered type boundary
The lookup traverses a table whose count is ziU16, comparing and addressing
records through a halfword index, and returns either that index or0xFFFF.
For countN<=65535, successful indexes are0..N-1. The loop exits atN; a
halfword index cannot wrap on any traversed iteration. There is no need for
a full-word index or return value in this contract.
Both callers store the result into the halfword search.keyIndex. The target
stores the returned register directly through the halfword store. The first
caller then narrows for its assignment-value comparison, while the second
reloads the halfword for comparison. The current full-word declaration made
MWCC emit an additional narrowing before both stores.
Recovered the helper's ziU16 return and ziU16 loop index together, then used
the typed index directly in the loop condition and nine-byte address
expressions. The old explicit masks were the reconstruction of those same
halfword promotions while the local had the wrong full-word type. They are
not stripped from a full-word value or replaced by register constraints.
The resulting helper body is byte-for-byte identical to its previous body,
including its59 instructions and resolved calls. This demonstrates that the
same lookup operations and return representation are preserved while its
callers recover the target halfword assignment boundary. Both source callers
are in this unit. A scan of all extracted target objects found the same two
text references and only the helper's own extabindex reference otherwise.
No shared declaration or header changes are needed.
## Separate trials
A native unsigned-int return alone and explicit caller-store casts were
codegen-neutral and were not retained. The coherent halfword index/return
pair is the sole selected candidate. No old Chinese ABI experiment or
arbitrary declaration/register sweep was repeated.
## Validation
Baseline: /tmp/ezi-korean-flow-full-report.json.
Fresh full report: /tmp/ezi-korean-lookup-full-report.json.
Full build: /tmp/ezi-korean-lookup-full-build.log.
Detailed gates: /tmp/ezi-korean-lookup-verification.txt.
Zi8GetKOcandidates: 97.97459% ->98.146484%.
Unit fuzzy: 98.65769% ->98.746155%.
Relative to initial1fa33882, unit98.65385% ->98.746155%.
Exact functions remain1/7, exact code332/5200, matched data96/180.
All1027 unit measures and all per-function fuzzy scores were checked: the
Korean unit/main-function gains are the only metric changes, with no
regressions. No new exact function or complete unit is claimed.
Every other function's disassembly is baseline-identical, including the
changed lookup helper. The existing exact packing helper remains83/83
instructions and ctxdiff diffs0. Main shrinks673 ->671 instructions versus
target669, from0xA84 to0xA7C versus target0xA74. Its0x60 frame is preserved.
The remaining normalized differences are one zero materialization and one
call-result move; no further width or flow difference is identified.
.data40 and extab56 retain identical payloads and canonical relocations.
The already-unmatched84-byte extabindex changes only its main-function size
byte at0x4F,0x84 ->0x7C; its score remains97.61904%, and exact-data accounting
is unchanged. No real data object or section extent was changed.
Pool first: identical and empty. All92 mapped main branches preserve their
corrected target destinations; all17 helper calls correspond. An associative,
register-value-aware advisory audit pairs all163 store/call/branch effects
without differences. These checks are not formal equivalence or exactness
claims. Full43U build passes with the approved wrapper and
WIBO_SJIS_MISSING_IMPORTS=1. DOL SHA1:
26116613f624061ba99c8d1a299aaa6efa85670d.
git diff --check passes. No linking, remote, header, assembly, volatile,
dummy-storage, undefined-value or forced-register change.

View File

@@ -0,0 +1,108 @@
# One-key candidate boundary reconstruction, 2026-10-02
Parent commits: alpha 94b7f57e and 35677806, neutral Chinese ABI 105f3b45.
This pass changes only `libs/RVLMiddleware/eZiText/src/clib/zi81key.c`.
Alpha source/logs and Chinese source/log are unchanged.
## Retained target-defined boundaries
- `Zi8IsMatch1Key` consumes a halfword key. Six candidate calls narrow that
argument after Zi8GetPCode: target +0x0B0C, +0x0F30, +0x16C0, +0x1BA4,
+0x1F4C and +0x22A8. Restored the ziU16 formal and removed its three
redundant key masks. The helper itself remains 97/97 instructions,
objdiff 100%, ctxdiff diffs 0. All source call sites are in this same unit.
- Each of the six duplicate-bit checks consumes a byte result in the target.
Made the byte conversion explicit at these call boundaries rather than
changing the already-exact full-width duplicate helper.
- The user-dictionary availability result is narrowed to a byte at target
+0x1E00. The existing full-width declaration remains; the caller now
performs the demonstrated conversion explicitly.
- User ordinal decoding narrows the masked high byte to a halfword before
its shift at target +0x1E44. Recovered that type boundary.
- Final output termination stores through the current output index and then
increments that index without reloading it (+0x2524..+0x2534). Recovered
the ordinary postfix-index store. Its right-hand side is constant zero,
so there is no unsequenced index read/write.
These are source/ABI shape reconstructions with demonstrated target
conversions; no callee-saved-register or declaration-order sweep was used.
## Isolated source trials
Each trial used the exact 43U Ninja compiler command in `/tmp/ezi-onekey-pass`,
without modifying the worktree until the final candidate was selected.
Below: candidate-function fuzzy / unit fuzzy / matched data / exact functions.
- Halfword formal retaining old masks: 95.26784 / 97.65741 / 1232 / 4; rejected
- Byte duplicate-helper return: 94.73383 / 97.4822 / 1232 / 5; rejected
- Explicit duplicate-result bytes alone: same as preceding; not retained alone
- User-dictionary result byte alone: 95.240715 / 97.708664 / 1280 / 5
- User ordinal halfword alone: 95.30121 / 97.735695 / 1280 / 5
- Combined count-limit increments: 95.106384 / 97.64865 / 1232 / 5; rejected
- Terminal postfix index alone: 95.4368 / 97.79627 / 1280 / 5
- Halfword formal/old masks + duplicate bytes + limits:
95.984566 / 97.97763 / 1232 / 4; rejected
- Halfword formal with ordinary typed uses:
95.26784 / 97.72078 / 1232 / 5; restores the exact helper
- Typed key + duplicate bytes: 95.83312 / 97.97334 / 1280 / 5
- Typed key + duplicate bytes + count limits:
95.984566 / 98.04101 / 1232 / 5; excluded for data regression
- Preceding plus terminal postfix: 96.01794 / 98.055916 / 1232 / 5; excluded
- Preceding plus user-dictionary/ordinal conversions:
95.926155 / 98.01491 / 1232 / 5; excluded
- Typed key + duplicate bytes + terminal postfix:
95.858154 / 97.98453 / 1280 / 5
- Typed key + duplicate bytes + user-dictionary byte:
95.87484 / 97.99198 / 1280 / 5
- Typed key + duplicate bytes + ordinal halfword:
95.93533 / 98.01901 / 1280 / 5
- Typed key + duplicate bytes + terminal postfix + user-dictionary byte:
95.86858 / 97.98919 / 1280 / 5
- Typed key + duplicate bytes + terminal postfix + ordinal halfword:
95.98957 / 98.04324 / 1280 / 5
- Final complete boundary subset: 96.41927 / 98.23523 / 1280 / 5
After selecting that subset, the three count-limit blocks were tested
individually against it. OEM: 96.17564 / 98.12637 / 1280 / 5; PUD:
95.725075 / 97.92507 / 1232 / 5; phrase: 95.93575 / 98.019196 / 1280 / 5.
All three were rejected. No count-limit rewrite remains in the candidate.
## Full validation and exact data disclosure
Fresh report `/tmp/ezi-onekey-boundary.json`; full-build log
`/tmp/ezi-onekey-boundary-build.log`.
Unit fuzzy 97.778564% -> 98.23523%. Candidate-function fuzzy
95.39716% -> 96.41927%, about 98 fewer weighted deficit bytes.
Exact functions remain 5/9; exact code remains 3952/21460;
matched data remains 1280/1388. All five baseline exact functions have
ctxdiff diffs 0 and identical instruction counts.
Candidate instructions: 2387 -> 2405 versus target 2397; size
0x254C -> 0x2594 versus target 0x2574. Frame remains 0x140.
It is not exact, and no new exact function is claimed.
The spelling tables remain 1152 byte-identical bytes. .sdata2 and extab
remain byte-identical at 8 and 72 bytes. The switch table's source is 44
bytes versus target 48, the pre-existing four-byte section-alignment tail;
all 44 bytes and all eleven canonical relocation targets/addends match.
No real data object was resized or renamed and no padding was added.
The already-unmatched 108-byte extabindex still has two differing bytes at
0x4F and 0x5B, with the same 98.14815% section score. They are the function
extent words: spelling remains 0x1A94 versus target 0x1A90; candidate extent
changes from 0x254C to 0x2594 versus target 0x2574. This is changed unmatched
metadata, not a claim that all data bytes are unchanged.
Pool check: identical (no narrow strings). Advisory branch mapping: all 351
pairs preserve their destination and all 71 helper calls correspond. A
register-value-aware linear audit pairs 621 observable store/call/branch
effects. The seven missing byte-boundary differences are resolved; its
remaining three differences are the unchanged count-limit reloads, not a
formal proof or an exactness claim.
Full 43U build succeeds with the approved wrapper and
WIBO_SJIS_MISSING_IMPORTS=1. DOL SHA1:
26116613f624061ba99c8d1a299aaa6efa85670d.
`git diff --check` succeeds. No remote, linking, shared-header, assembly,
volatile, register-forcing, dummy-storage or undefined-value changes.

View File

@@ -0,0 +1,96 @@
# One-key call and parameter contracts, 2026-10-03
Base: 674722c1; branch agent/bittle/onekey-contract-reconstruction.
Owned source: zi81key.c only. This is source-type correctness work with no
percentage gain. No callee implementation or shared header was changed.
## Retained, definition-backed boundaries
- Replaced the private ziGetParam replica with the existing shared type.
The old replica's bytes at 0x20/0x21/0x22 were named
wordCandidates/count/letters. The established shared type names those
count/letters/completion. All accesses were renamed by their offsets;
no field was moved or read/written at a different address. The unused last
word retains the same target size. Dispatcher return declarations and the
two public candidate-count return types now agree on their byte/full-word
roles, respectively.
- Added the actual _Zi8GetCandidates and _Zi8CheckCandidates prototypes,
using ziGetParam pointers. Their explicit byte-result handling is preserved.
- Recovered Zi8Ord2Ord's actual ziU16 return together with the local duplicate
helper's ziU16 ordinal parameter. Ordinary typed uses replace the explicit
halfword masks of the former full-word local. Correcting only the external
return lost the exact helper; this coherent pair preserves all 50 of its
instructions and every caller instruction.
- Zi8GetPInfo and Zi8GetZInfo actually accept a ziU32 phonetic code and return
ziU32. Corrected their local declarations; the existing caller's explicit
byte result conversion remains.
- Added the actual Py/Bpmf phonetic prototypes. This exposed two scratch
arrays declared as 32 bytes despite receiving 16 halfword outputs. They
are now 16-element ziU16 arrays, preserving their 32-byte extents. The
candidate output buffer is likewise 16 ziWChars instead of 32 bytes plus
a cast. No new storage or alignment directive was added.
- Zi8GetZHuwdPtr writes a native ziU32 address through its first parameter.
Its local declaration and address-taken receiving variable now use that
actual type. Byte decoding uses an explicit view of userEntriesAddress;
address stepping remains three bytes. This removes the incompatible
pointer-to-pointer/integer-output contract without an extra temporary.
- Zi8GetTableAddress, Zi8Memset and Zi8InitDupWordBuf local declarations now
agree with their actual definitions. The parameter object is cleared
through the memset callee's byte view.
- Zi8ZHCheckSpelling now agrees with its caller in zi8alpha.c: byte Boolean
return, byte input count, and opaque workspace pointer. Its result was
already a byte; removing the input's redundant full-word masks preserves
the entire existing exact body.
The authoritative definitions are in zi8getc2.c, zi8misc.c, zi8cinfo.c,
zi8match.c and zi8ZHuwd.c. The public count-return declarations are in
zi8getc2.c; the spelling-check declaration is in zi8alpha.c. Only the owned
file was edited. The private option/work views remain in place; this is not
an attempt to consolidate every library type or repair every declaration.
## Isolated trials
- PInfo/ZInfo actual declaration pair: neutral
- Bare Py/Bpmf prototypes: compile error exposing byte-array/halfword-pointer
disagreement; fixed by correctly typed same-size output buffers
- Ord2Ord return only: duplicate helper 100 -> 98.8%; rejected
- Ord2Ord return plus typed ordinal: original exact helper restored, neutral
- Shared request type and offset-preserving field names: neutral
- Typed dispatcher prototypes with shared request type: neutral
- Phonetic and candidate halfword output buffers: neutral
- Native user-dictionary address contract: neutral
- Public return/input boundaries: neutral
- Final retained combined contracts: all code/data and metrics unchanged
Other coherent local spelling/alternate-phonetic parameter-width trials were
neutral and are not included without an external declaration disagreement.
The PUD return/caller-byte trial on the new baseline dropped unit fuzzy to
97.782295% and exact data 1280 -> 1232; it was rejected and is not included.
No blanket byte-cast, declaration-order or register-allocation sweep was used.
## Verification
Baseline report: /tmp/ezi-onekey-contract-baseline.json.
Baseline object: /tmp/ezi-onekey-contract/baseline.o.
Final report: /tmp/ezi-onekey-focused-full-report.json.
Full build: /tmp/ezi-onekey-focused-final-build.log.
Detailed gates: /tmp/ezi-onekey-focused-verification.txt.
All 1027 unit measures are unchanged. Unit fuzzy remains 98.23523%; main
candidate engine remains 96.41927%. Exact functions remain 5/9, exact code
3952/21460, and matched data 1280/1388. No new exact function or percentage
gain is claimed.
All owned emitted sections have baseline-identical lengths, payloads and
canonical relocations: .text 21496, .rodata 1152, .data 44, .sdata2 8,
extab 72 and extabindex 108. All nine functions have baseline-identical
disassembly, not only equivalent scores. Each of the five existing exact
functions still has ctxdiff diffs 0 and identical instruction counts:
Zi8IsMatch1Key 97, MatchAltSound1Key 341, Zi8SetFindCand 50,
ZiIsSupportedPhonetic 81, Zi8ZHCheckSpelling 419.
Pool first: identical and empty. Full 43U build passes with the approved
wrapper and WIBO_SJIS_MISSING_IMPORTS=1. DOL SHA1:
26116613f624061ba99c8d1a299aaa6efa85670d.
git diff --check passes. No linking, remote, metadata, new assembly, volatile
workaround, dummy storage, undefined value or forced-register change.

View File

@@ -0,0 +1,51 @@
# PUD byte-return producer contract, 2026-10-03
Base: a894ff5c; branch agent/bittle/pud-return-contract.
Owned source: zi8pud2.c only. The copied cache was refreshed by a configured
full 43U build before recording the baseline. No caller or header changed.
## Producer and caller evidence
Every Zi8MatchPUDdata_ZHS exit returns zero, one, or an explicitly byte-cast
copied count. Zi8_8147FD7C forwards that result directly. Zi8MatchPUDdata
receives it, tests its byte value, and returns it; it never consumes any
higher result bits. The target wrapper retains exactly this data flow.
All external callers use byte-return declarations: zi8alpha.c and zi81key.c
for Zi8MatchPUDdata, and zi8cgetc.c for Zi8MatchPUDdata_ZHS. The previously
attempted caller-side full-word corrections were therefore based on a
misreconstructed producer chain rather than a demonstrated wide result.
Recovered ziU8 returns for all three functions and their local forward
declaration, plus ziU8 for the wrapper result local. Its test now uses the
typed byte directly. The explicit cast of copied in the actual producer
remains. Changing the coherent chain preserves the complete compiled object;
no compensating caller masks, local aliases, storage or register constraints
are required.
## Validation
Baseline report: /tmp/ezi-pud-baseline.json.
Baseline object: /tmp/ezi-pud-return-contract/baseline.o.
Final report: /tmp/ezi-pud-return-full-report.json.
Full build: /tmp/ezi-pud-return-full-build.log.
Detailed gates: /tmp/ezi-pud-return-verification.txt.
The complete zi8pud2.o file is byte-identical to baseline, including symbol
strings. Every function's disassembly is unchanged. All 1027 full-report
unit measures are unchanged: unit fuzzy 98.88764%, ZHS 98.32204%, exact
functions 6/7, exact code 720/2136 and exact data 48/120. This is a contract
correction, not a percentage gain or a new exact function.
All six existing exact functions retain ctxdiff diffs 0 and identical counts:
ZiIsPhoneticChar 16, ZiGetZHWordSize 31, Zi8CopyZHSpelling 33,
ZADP_Zi8SetPDremoveOpt 21, Zi8MatchPUDdata 50, Zi8_8147FD7C 29.
The unmatched producer remains 349/354 instructions. Allocated section sizes,
payloads and canonical relocations are unchanged: .text 2116, extab 48,
extabindex 72.
Pool first: identical and empty. Full 43U build passes with the approved
wrapper and WIBO_SJIS_MISSING_IMPORTS=1. DOL SHA1:
26116613f624061ba99c8d1a299aaa6efa85670d.
git diff --check passes. No remote, linking, metadata, header, caller,
assembly, volatile, dummy-storage or undefined-value change.

View File

@@ -0,0 +1,77 @@
# PUD packed-header halfword decoding, 2026-10-03
Parent: a71dfa9c; its byte-return correction is unchanged.
Owned source: two expressions in zi8pud2.c / Zi8MatchPUDdata_ZHS.
## Recovered arithmetic and widths
The eight-byte PUD section record contains two-byte big-endian count and
offset fields. The target separately promotes each of their four component
bytes through a halfword boundary before shifting or adding. The source
previously expressed plain byte arithmetic and omitted those four target
conversions.
Restored explicit ziU16 promotions for count[0], count[1], offset[0] and
offset[1]. The offset is now decoded as one grouped big-endian value before
adding the table base. This reproduces the target's base/high/low load and
addition order, without a new local, helper, casted memory access or storage.
Bounded isolated trials, all retaining 6 exact functions and 48 exact data:
- Halfword promotions with the existing offset association:
ZHS 98.52542%, unit 99.02247%
- Conventional grouped high/low offset sum:
ZHS 99.717514%, unit 99.81274%; selected
- Grouped low/high offset sum:
ZHS 99.10452%, unit 99.406364%; rejected
- Grouped multiplication form:
ZHS 99.10452%, unit 99.406364%; rejected
All 65,536 possible packed values preserve the decoded count. Another
524,288 offset/base combinations, covering eight bases including 32-bit
wrap boundaries for every packed value, preserve the computed address.
These arithmetic tests supplement the target instruction correspondence.
## Remaining workspace snapshot
The target stores its incoming workspace pointer once into frame 0x24 at
function +0x3C. A width-aware access and address-provenance audit finds no
read, overlapping use, or address escape for that slot. The workspace stays
in its existing saved register. The only ordinary local whose address is
passed to a helper is the halfword at frame 0x0E. Save/restore addresses the
separate upper frame region. No source-visible distinct alias role was found.
That single dead store remains absent. No unused local, dummy assignment,
padding, volatile or forced spill was added to manufacture it.
## Validation
Fresh final report: /tmp/ezi-pud-packed-full-report.json.
Full build: /tmp/ezi-pud-packed-full-build.log.
Detailed gates: /tmp/ezi-pud-packed-verification.txt.
Snapshot audit: /tmp/ezi-pud-work-snapshot-audit.txt.
Zi8MatchPUDdata_ZHS: 98.32204% -> 99.717514%.
Unit fuzzy: 98.88764% -> 99.81274%, about 19.76 weighted bytes gained.
Exact functions remain 6/7, exact code 720/2136, exact data 48/120.
All 1027 units and their per-function fuzzy scores were checked with no
regressions; this unit/producer improvement is the only measure change.
Producer instructions: 349 -> 353 versus target 354.
Producer size: 0x574 -> 0x584 versus target 0x588; frame remains 0x60.
After accounting solely for the missing dead store and its four-byte branch
destination displacement, every remaining instruction is identical, including
registers, immediates, calls and memory operands. All 65 direct branches and
13 calls correspond. This is not an exact match: the missing instruction
and function extent are explicitly retained as unresolved.
All six existing exact functions retain ctxdiff diffs 0 and identical counts.
The 48-byte extab is baseline-identical. The already-unmatched 72-byte
extabindex changes only the producer extent byte at 0x2B, 0x74 -> 0x84;
canonical relocations and its 98.61111% score are unchanged. No real data
object, section extent or metadata declaration was changed.
Pool first: identical and empty. Full 43U build passes with the approved
wrapper and WIBO_SJIS_MISSING_IMPORTS=1. DOL SHA1:
26116613f624061ba99c8d1a299aaa6efa85670d.
git diff --check passes. No remote, linking, header, new assembly, volatile,
dummy-storage, undefined-value or forced-register changes.

View File

@@ -0,0 +1,83 @@
# Punctuation options receiver, 2026-10-03
Base: bf8ebfa3. Owned source: Zi8punct.c only. This is a source-contract
correction with unchanged generated code and no percentage gain.
## Actual call and receiver
All original-object references show exactly one executable caller,
Zi8GetCandidatesOrCount, plus the punctuation function's exception-index
reference. At that call the fixed ABI positions are:
- r3: the candidate request
- r4: the candidate options object
- r5: the workspace
The dispatcher preserves these three incoming pointers separately. Its
_GetCandidates/_CheckCandidates producers create the existing 24-byte
ZiCandidateOptions object, initialize capacity from the workspace, and pass
its address as the second argument. The dispatcher then writes maxCount
from the workspace before calling the punctuation helper.
The punctuation target reads a byte at options +0, a word at options +0x0C,
and a halfword at options +0x10. These are countOnly, maxCount and capacity.
It overwrites incoming r5 before reading it, so the third workspace formal
is present in the caller contract but unused by this implementation.
The reconstructed definition previously omitted that third formal and named
the second argument workspace. It consequently described options accesses
using unrelated workspace fields at coincidentally equal offsets.
## Minimal correction
Copy the existing private ZiCandidateOptions type verbatim from zi8getc2.c;
no shared header or producer is changed. Its complete layout is reused,
including its established fields, without introducing any object, extra
storage or invented padding. A fixed-target-width layout check confirms
size 24 and the three accessed offsets 0/0x0C/0x10.
The definition now takes request, opaque options and workspace, and accesses
the real options fields through the private view. Its ziU32 result agrees
with the sole caller's declaration. All locals, comparisons, loops, output
stores and branch directions remain unchanged. The unused workspace formal
recovers an argument already supplied by the target caller; it does not
manufacture state or instructions.
## Verification
Fresh configured 43U baseline and candidate full builds pass with the approved
wrapper and WIBO_SJIS_MISSING_IMPORTS=1. Pool first: identical and empty.
All allocated payloads and canonical relocations are baseline-identical:
.text 300, .rodata 80, extab 8 and extabindex 12 bytes. The only complete-object
difference is two anonymous symbol-number characters in nonallocated .strtab.
All other 1,026 source objects are byte-identical to baseline.
Zi8Punctuation stays 75/75 instructions with ctxdiff zero differences. Unit
code 300/300, data 100/100, and 1/1 exact functions remain 100%. The entire
1,027-unit objdiff report is unchanged. Full 43U DOL SHA1 remains
26116613f624061ba99c8d1a299aaa6efa85670d. git diff --check passes.
Private evidence: /tmp/ezi-options-punct-{report.json,build.log,verification.txt},
/tmp/ezi-options-baseline.json and /tmp/ezi-new-receiver-refs.txt.
No remote changes, other-region builds, assembly, linking flags, forced
registers, volatile, dummy assignments or shared-header edits.
## Broader read-only ABI audit
The original-object call inventory covered 20 remaining nonexact functions,
excluding the already resolved one-key/PUD/conversion work: 337 direct calls
and one OEM callback. A symbolic-expression comparison pins each value to
its actual ABI argument register and outgoing stack slot; it does not apply
a global argument-register permutation. After applying only the previously
proven alpha scalar-frame offset mapping, all 338 call argument expressions
agree. The callback's four arguments and stored callback target also agree.
No external tail branch was found; indirect non-call branches are switches.
A separate incoming-register/stack-use audit found no additional live
argument beyond a callee's reconstructed parameter list. These are diagnostic
checks, not a formal whole-program equivalence proof.
The declaration/definition scan identified the separate missing workspace
formal on Zi8IsZicorpSignature. Three exact version-query helpers also have
old-style empty definitions despite receiving an unused workspace in their
exact caller; those are outside this candidate. No allocation experiments
were performed.

View File

@@ -0,0 +1,35 @@
# Signature-check workspace formal, 2026-10-03
Parent: 8a0aa7ce; its punctuation-options correction is preserved unchanged.
Owned source: zi8initd.c / Zi8IsZicorpSignature only.
The local declaration in zi8alpha.c takes word, halfword length and workspace.
An original-object reference scan finds exactly one caller and no function
pointer or other address escape. The target AlphaGetCandidates call puts the
word in r3, narrows the length into r4, and moves its preserved workspace into
r5 immediately before calling Zi8IsZicorpSignature.
The callee's current definition omitted the third formal. Its target reads
only r3/r4; r5 never appears anywhere in its 48 instructions. It has no calls
or tail target. Add the existing ZI_NEED_WORK formal to align the definition
with the actual caller and its declaration. The argument is genuinely passed
but unused. No local, assignment, storage, volatility or forced spill is added.
The body and all other declarations remain unchanged.
Validation after this separate change:
- The complete zi8initd object is byte-identical to the fresh baseline
- Zi8IsZicorpSignature remains 48/48 instructions, ctxdiff zero differences
- Zi8InitializeDynamic remains 128/128 instructions, ctxdiff zero differences
- Unit code 704/704, data 20/20 and 2/2 exact functions remain 100%
- The complete 1,027-unit report is identical to baseline and the preceding
punctuation-only report; all source objects except punctuation's already
documented nonallocated symbol-name difference are byte-identical
- Owned allocated sections and canonical relocations are unchanged
- Pool is identical and empty; full configured 43U build passes
- DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d
- git diff --check passes
This is contract reconstruction only, with no percentage gain. No shared
header, caller, linking flag, assembly, other-region build or remote change.
Private evidence: /tmp/ezi-options-signature-{report.json,build.log,verification.txt}
and /tmp/ezi-new-receiver-refs.txt.

View File

@@ -0,0 +1,41 @@
# Version-query workspace formals, 2026-10-03
Base: 9c7d87ab. Owned source: zi8ver.c only. This is source-contract
reconstruction with no percentage gain.
The local declarations in zi8getc2.c already describe Zi8GetVersion,
Zi8GetOEMID and Zi8GetBuildID as taking one ziPtr workspace. The definitions
instead had old-style empty parameter lists. Add only the existing workspace
formal to those three definitions. Bodies, constants, return types, callers
and headers are unchanged.
A fresh scan of all original objects finds exactly four executable references:
Zi8GetEngineSignature calls GetVersion twice, GetOEMID once and GetBuildID
once. There are no other address references or function-pointer escapes.
That caller preserves its incoming second argument, workspace, in r28 and
moves it to the fixed first-argument register r3 immediately before each call.
The workspace register is not redefined between its incoming copy and the
final restore. No argument-register permutation is used for this check.
Each original callee consists of exactly two instructions: load its existing
constant into r3, then return. Thus each overwrites r3 before any read of its
incoming value. There is no helper or tail target. The formal is unused in
this implementation but is established by every declaration and target call;
it adds no local state, storage or assignment.
Fresh configure and baseline/final full 43U builds used the approved wrapper
and WIBO_SJIS_MISSING_IMPORTS=1. Pool first: identical and empty. The entire
owned object, all 1,027 source objects, and the complete 1,027-unit objdiff
report are byte-for-byte / structurally identical to baseline. All allocated
payloads and canonical relocations also match the original target.
Each helper remains 2/2 instructions with ctxdiff-equivalent zero differences.
Unit exact code remains 24/24 bytes and functions 3/3; there are no allocated
data bytes. Full build passes and DOL SHA1 remains
26116613f624061ba99c8d1a299aaa6efa85670d. git diff --check passes.
Private evidence: /tmp/ezi-version-baseline.json,
/tmp/ezi-version-final-report.json, /tmp/ezi-version-final-build.log and
/tmp/ezi-version-verification.txt. No linking, assembly, volatile, forced
registers, dummy assignments, shared-header edits, other-region builds or
remote writes.

View File

@@ -0,0 +1,102 @@
# Input-form source reconstruction, 2026-10-02/03 UTC
Base `cc812ad3`, branch `agent/bittle/input-form-reconstruction`, 43U only.
Only `src/keyboard/tiInputForm.cpp` and this log are changed. Existing attempt
logs, headers, metadata, compiler settings, linking flags and assembly bodies
are untouched.
## Retained changes and target evidence
### LayoutByNW4R::create
The first language text-pane lookup in the target loads the layout's root pane
and invokes FindPaneByName with the recursive flag. The old source instead
invoked the Layout virtual getPane slot. The retained source directly expresses
the root-pane lookup, recovering two missing instructions and the correct call
receiver path. The later const getLanguageTextPane fallback remains intact.
The animation loop in the target keeps the address of the selected files[] slot.
It loads the file for GetResource, then reloads that slot after the resource and
animation-transform calls to obtain the animation ID. The old source captured
the file pointer once. A const reference to the existing typed pointer slot now
expresses the target's lifetime and recovers the other two missing loads. No
new storage, qualifier forcing, table entry, or helper was introduced.
Together these changes restore the target's 356-instruction body. The fallback
name-selection block still schedules some receiver loads differently, and most
remaining differences concern register allocation. This is not an exact match.
### Base::calcCursorPos
The source now uses the already defined Rect::GetWidth accessor for glyph and
form widths. That existing accessor computes exactly right minus left. The
change preserves the arithmetic, hit-test inequalities, wrap/newline paths,
scroll handling, recursive fallback, and all helper calls. It recovers more of
the target's rectangle-expression boundaries at unchanged body size. Height
accessors and midpoint operand reversal did not improve the result and were not
retained. No new geometry abstraction or arithmetic reassociation was added.
## Attempts and rejected alternatives
- Read the previous sol-high-inputform and data-d4 logs. Revisited their concrete
root-query and file-slot defects under the user's current partial-decompilation
priority; did not repeat the historical declaration searches.
- Tested the two create corrections independently and together. Explicit fallback
selector locals produced the same code. Duplicating the root lookup in both
fallback branches grew the function to 363 instructions and was rejected.
- Tested small inline fallback-lookup wrappers; they added source complexity
without improving the retained result. A trial binding the derived layout
pointer to a base pointer reference did not compile and was restored.
- Existing width and height accessors and midpoint operand order were tested
independently. Only the width accessor change is retained.
- No artificial allocation sweep, new assembly, use-site volatile, dummy storage,
undefined input, padding, header edit, or linking experiment was used.
## Gates
Before -> after:
- calcCursorPos: 91.622696 -> 93.05215% fuzzy, 326/326 instructions unchanged;
final raw ctxdiff 50 differences (baseline 52, including existing relocation
aliases and floating-point scheduling/allocation differences).
- LayoutByNW4R::create: 95.02809 -> 96.40169% fuzzy, 352 -> 356 instructions against
target 356; final ctxdiff 155 differences.
- Unit fuzzy: 99.578094 -> 99.6535%.
- Existing objdiff-exact symbols: 218/221 unchanged; exact code 46980/50656 bytes;
matched data 3772/3772 (100%); linked status unchanged.
- Independently rebuilt the baseline and candidate objects. All 218 previously
objdiff-100 symbols have identical baseline/candidate instruction streams.
This preserves the pre-existing distinction between objdiff and raw ctxdiff
exactness rather than claiming every alias-normalized symbol has diffs 0.
- Baseline/candidate raw .data, .rodata, .bss, .sdata, .sbss, .sdata2 and .ctors
section bytes and extents are identical. All 20 pool strings match the target.
- Literal audit: 20 arguments checked, 221 functions analyzed, no candidates,
skips or errors. Target-sized create is now included in that audit.
- Full 1027-unit report: no exact-function, exact-code, data or fuzzy regressions.
- Full 43U build and build/43U/ok passed, again after rebuilding the baseline and
restoring the candidate. DOL SHA1:
`26116613f624061ba99c8d1a299aaa6efa85670d`.
## Focused behavior coverage and limits
A private host harness extracts the production baseline/candidate calcCursorPos
bodies without rewriting them, supplies the same Rect::GetWidth expression, and
uses deterministic font/scale/wrap stubs. Compiled with single-precision float,
-fno-fast-math and -ffp-contract=off, it checks returned positions, helper-call
traces and wrap counters across empty text, newlines, forced word wraps, width
wraps, boundary hits, scale, non-positive scroll and recursive fallback.
159,320 terminating cases agreed. Another 680 synthetic font/wrap states reached
the same 1,000-scale-call model budget with identical traces in both versions;
no termination claim is made for those states. The initial unrestricted harness
also reached its budget in the baseline, so this is equivalence coverage for the
accessor change, not proof of general termination or a newly diagnosed Wii bug.
The layout/resource creation path is validated by target call/load evidence and
the real 43U compile; no Wii UI/runtime execution is claimed.
Private local evidence: `/tmp/input-form-reconstruction/` contains baseline/final
reports and object copies, pool/literal audits, both final ctxdiffs, build logs,
validate_cursor.py and cursor-tests.log, plus rejected experiments. No retail
assembly or binary is committed or uploaded.
GATE: validated partial source/control/data-flow reconstruction; no regressions.
Exact matching and linking remain open. Candidate frozen for parent validation.

View File

@@ -0,0 +1,238 @@
# RGB565420 edge bounded declaration search
Base: `32be36cb4e57bdaf05af9bbccc0a4ff6a63cb1aa`; branch
`agent/bittle/jpeg-edge-declaration-search`; 43U only.
The function at entry exactly matched the merged pixel-lifetime candidate
from #1061. Its function-text SHA256 was
`b0117318407c1fb445baef7534c6f0d28908412e0e8c26bc113efc4ed956f57f`.
The contiguous leading block at source lines 566..585 contains twenty existing
uninitialized scalar/pointer declarations. Initialized pixel locals at 620..623
were excluded. Earlier tex1 coverage used the older function-wide RGB locals;
the #1061 evidence explicitly records no declaration search on its new body.
## Authorized search and stop
Ran the unchanged repository tool exactly once:
```sh
WIBO_SJIS_MISSING_IMPORTS=1 NINJA=../.venv/bin/ninja \
PYTHONPATH=../local-tools ../.venv/bin/python \
tools/decomp-assist/declsearch.py \
libs/RVLMiddleware/TMC_JPEG/src/texturecvtr/Texture_MCUtoRGB565 \
TMCJPEGDEC_converterYUV420toRGB565edge --lines 566 585 --max-evals 32
```
Structural/positional trajectory: `(4,65)` -> `(4,58)`.
The tool stopped at 32 distinct scored orders, then rebuilt its retained order.
This was the finite evaluation cap, not exhaustion of the final neighborhood.
There was no custom search, extra variant, helper edit, or initializer move.
The sole retained source change swaps the leading declarations of `column`
(s32) and `crValue` (s8). Both are genuinely used uninitialized scalar locals.
All expression tokens, initialization statements, scopes, helper bodies,
clamps, arithmetic, and pointer steps remain byte-for-byte unchanged.
There are no floating-point operations in this converter.
## Fresh official result
- Function fuzzy: 95.570175 -> 95.96491%
- Instruction count: 114/114; ctxdiff differences: 65 -> 58
- Unit fuzzy: 96.58538 -> 96.61449%
- Exact remains 7/13; matched code remains 2648/6184 bytes
- No allocated non-code sections; data remains 100%
- Global fuzzy: 99.71971 -> 99.71977%; all exact/link/data totals unchanged
- Full report: zero function/unit regressions; only this unit changes
- Only this function's bytes change; all twelve sibling bodies are identical
to the saved pre-search object
- All seven existing exact siblings remain objdiff 100% and ctxdiff zero
This is partial fuzzy progress, not an exact or linking result.
## Gates
Full 43U build and `ninja build/43U/ok`: PASS.
DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`.
Pool before and after: identical, zero strings. `git diff --check`: PASS.
Literal audit: no candidates/errors; twelve functions analyzed, unchanged
setter skipped for unequal function sizes.
The unchanged prior pixel oracle passed 8,721 vectors / 26,163 object executions
against the candidate, original, and its saved pre-#1061 baseline: 808 edge-size
cases, 256 dimension-branch cases, 6,400 saturation cases, and 1,257 aligned
input/output overlaps wholly inside the actual conversion buffer. Every one of
114 instructions was exercised in each object. The interpreter checks every
non-stack byte, LR, stack pointer, and preserved GPRs. Valid rows exercise both
column parities; odd input x remains outside the existing asserted contract.
The prior oracle's bounded-input and interpreter limitations still apply;
this is not formal equivalence or Wii runtime validation.
## Unsearched neighborhood, read-only count
For twenty declarations, the retained order has:
- 190 distinct pair-swap neighbors
- 361 distinct remove/insert move neighbors
- 19 neighbors common to both sets
- 532 distinct neighbors in their union
The tool's deterministic enumeration reaches the sole improvement at evaluation
27: swapping zero-based positions 1 and 8. Five new final-order neighbors are
then scored before reaching 32. The initial order is also a final-order neighbor
(the inverse swap), giving 6 covered and 526 unscored final-order neighbors.
This count was reproduced without compiling any additional order. It is inferred
from the unchanged tool, its logged single improvement and final 32-build count.
A fresh official run lacks the prior cache and would repeat those six neighbors;
533 total evaluations can cover one fixed order plus its entire neighborhood if
no intervening improvement causes the tool to restart from another order.
No continuation run was performed.
## Evidence
`/tmp/jpeg-edge-declaration-search/` contains `search-output.txt`, baseline and
candidate reports, the saved pre-search object, `candidate.ctx`, `full-build.log`,
`verification.txt`, `audit-output.txt`, `audit-results.json`, and `neighborhood.json`.
The read-only `verify.py` asserts the source consists of exactly the two-line
swap and compares reports, allocated sections, and sibling object bytes.
The prior oracle remains `/tmp/jpeg-pixel-lifetime/audit.py`, unchanged.
No remote writes, link flags, shared headers, or tool changes.
## Separately authorized 533-evaluation continuation
The preceding 32-evaluation candidate was preserved on its own branch. A new
branch, `agent/bittle/jpeg-edge-order-finish`, starts at base `32be36cb` with that
candidate cherry-picked as `81df2b4e26f36c1b63a74840754ea720dc4f1c72`.
The 95.96491% baseline was rebuilt and freshly measured before proceeding.
Ran the unchanged official command above exactly once more, changing only
`--max-evals 32` to `--max-evals 533`. The same twenty leading uninitialized
declarations remained the complete writable search range. All source outside
that block was checked byte-for-byte against the entry source, and the block's
declaration multiset was unchanged. No initialized local, scope, expression,
helper, type, array, or evaluation-order edit occurred.
The structural/positional trajectory was:
```text
(4,58) -> (4,57) -> (4,56) -> (4,55) -> (4,52) -> (4,49)
-> (4,48) -> (4,44) -> (4,43) -> (4,39) -> (4,35)
```
The tool stopped after 533 distinct scored orders and rebuilt its retained
order. The evaluation cap stopped this run; a local fixed point was not reached.
There was no extra search or source variant afterward.
### Final measured result and repeated gates
- Function fuzzy: 95.96491 -> 97.850876%; compared with merged #1061: 95.570175%
- Unit fuzzy: 96.61449 -> 96.753555%; compared with merged #1061: 96.58538%
- 114/114 instructions; ctxdiff differences: 58 -> 35
- Global fuzzy on this branch: 99.71977 -> 99.72007%
- Exact remains 7/13; matched code 2648/6184 bytes; link/data totals unchanged
- Zero full-report function/unit regressions; only this unit changes
- Only the targeted function body changes; all twelve siblings remain
byte-identical to the saved 95.96491% entry object
- All seven exact siblings remain objdiff 100% and ctxdiff zero
- Empty allocated non-code sections and empty string pool unchanged
- Full 43U build, `ninja build/43U/ok`, and `git diff --check`: PASS
- DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`
- Literal audit: no candidates/errors; twelve functions analyzed; unchanged
setter skipped for unequal size
- The unchanged prior oracle again passes all 8,721 vectors / 26,163 object
executions with complete 114-instruction coverage in all three objects
The same bounded-oracle limitations listed above apply. This is partial fuzzy
progress and does not add an exact function or change linking.
Final source SHA256:
`3b0ed19e076c09dfbcd841fc63b79e48ef0ae84703bd4148fdac56c8cfd2c6d3`.
### Final neighborhood coverage
The new final order again has 532 distinct one-swap/one-move neighbors. The
official tool restarts its neighborhood after an improvement; ten improvements
therefore moved the center during the finite run.
An exact final-neighbor coverage count is unavailable: the unchanged tool logs
score improvements and its final declaration order, but does not retain the
identity of each intermediate tested order. No identities were invented.
Read-only enumeration establishes these conservative bounds:
- The final order itself, the starting order, and the first tested swap are
three scored orders outside the final neighbor set
- The last improving parent is a scored final-order neighbor
- Between 1 and 530 of 532 final neighbors were scored in this continuation
- At least 2 final neighbors remain unscored; the neighborhood is not exhausted
These bounds concern the continuation, not a claim of cumulative coverage
across other runs. No further continuation was performed or implied.
### Continuation artifacts
`/tmp/jpeg-edge-order-finish/` contains the complete score trajectory, freshly
rebuilt baseline report/object/source, candidate report, `candidate.ctx`, full
build log, independent verification output, unchanged-oracle output/results,
and read-only neighborhood calculation results. Its `verify.py` checks that
only the leading-declaration order changes, then checks full reports, exact
siblings, all sibling bytes and allocated non-code sections.
The separately preserved 32-evaluation branch is unchanged. The final source
and this combined evidence log are ready for independent review as one PR.
No remote writes occurred.
## Final authorized fixed-point check
A final separate branch, `agent/bittle/jpeg-edge-order-fixedpoint`, preserves
the validated source on current main `a4d145c0` through cherry-picked commits
`8b2366be` and `a4f3d380`. The 97.850876% baseline was rebuilt and freshly
measured before the search. Its source is identical to the preceding frozen
candidate `7423b762`.
Ran the same unchanged official command once with `--max-evals 1200`, still
restricted to source lines 566..585 and the same twenty uninitialized
scalar/pointer declarations. No other source region was writable by this run.
Actual result:
```text
start (4, 35)
best (4, 35) after 533 builds; source restored
```
There were zero improvements. The run stopped at a local fixed point before
its 1200-evaluation cap. Its 533 scored orders comprise the baseline plus all
532 distinct pair-swap/remove-insert neighbors of that baseline. The center
never moved, so complete final-neighborhood coverage is established directly
from the unchanged deterministic tool and its count. No inferred intermediate
permutations are needed.
This is a fixed point under declsearch's structural/positional comparator.
Official objdiff fuzzy was measured at entry and exit, both 97.850876%; the
tool does not measure official fuzzy for each intermediate neighbor. No claim
of globally optimal fuzzy score or exhaustion of multi-step permutations is made.
No additional run followed the fixed point.
### Retained-source verification on current main
The complete source and whole RGB565 object are byte-identical to the freshly
rebuilt 97.850876% entry baseline. The complete 1027-unit report is identical
before and after the final full rebuild, with zero function/unit regressions.
- Function fuzzy remains 97.850876%; unit fuzzy remains 96.753555%
- 114/114 instructions, 35 ctxdiff differences; exact remains 7/13
- All seven exact siblings remain objdiff 100% and ctxdiff zero
- Allocated non-code sections remain empty; pool identical, zero strings
- Full 43U build, `ninja build/43U/ok`, and `git diff --check`: PASS
- DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`
- Literal audit: no candidates/errors; twelve functions analyzed, unchanged
setter skipped for unequal size
- Unchanged pixel oracle: all 8,721 vectors / 26,163 object executions pass,
with full 114-instruction coverage and the previously documented limitations
- Current-base global fuzzy: 99.72187%; this neutral search changes no totals
Final evidence is in `/tmp/jpeg-edge-order-fixedpoint/`: baseline report,
object and source; full trajectory; candidate report; full build log; verification
output; pixel-oracle output/results; and exact neighborhood counts. Source SHA256
remains `3b0ed19e076c09dfbcd841fc63b79e48ef0ae84703bd4148fdac56c8cfd2c6d3`.
Only this evidence append is new in the final check; the best source is retained.
No remote writes, new variants, helper changes, or initialized-local edits.

View File

@@ -0,0 +1,99 @@
# RGB565420 edge pixel lifetime
Base: `57ccda3883537a308568c03924af2cebf2d8a789`, branch
`agent/bittle/jpeg-pixel-lifetime`, 43U only. One authorized source trial;
no additional variants, header/configuration changes, or remote writes.
## Source reconstruction
The existing exact RGB565444 sibling has a pixel-scoped independent luminance
value and pixel-scoped RGB locals. Apply that lifetime boundary to RGB565420
edge, retaining its current chroma sampling and every address/step expression.
Initialize red, blue, then green, matching original instructions 60..62 after
the luminance load at 58. The original overflow reduction at 63..64 is
blue/red/green; that existing source expression remains unchanged, as do clamps
and the RGB565 packing expression. No declaration-permutation search was used.
Chroma products are bounded signed integer arithmetic. For signed byte Cb/Cr,
red/green/blue offsets stay within [-180,178], [-135,135], and [-227,225]. Adding
an unsigned luminance byte cannot overflow s32. There are no floating-point
operations. Removing the blue variable's temporary ownership of luminance and
limiting RGB lifetimes to the pixel does not add or remove input reads or output
writes. The arithmetic order changes only among independent initialized scalars.
The historical tex1 log records a different sibling-template trial at
96.00877%, discarded for being nonexact. Its original source is unavailable;
this candidate is an independently measured reconstruction, not that artifact.
## Measured result
- `TMCJPEGDEC_converterYUV420toRGB565edge`: 94.692986 -> 95.570175%
- 114/114 instructions; ctxdiff differences 73 -> 65
- Unit fuzzy: 96.5207 -> 96.58538%
- Exact functions remain 7/13; matched code remains 2648/6184 bytes
- No allocated non-code sections in source or original; data remains 100%
- Global fuzzy: 99.71608 -> 99.7162%; all exact/link/data totals unchanged
- No function- or unit-level regressions across the full 1027-unit report
- Only this function's body differs from the saved baseline object; all twelve
sibling function bodies are byte-identical to baseline
- Seven existing exact functions remain objdiff 100% and ctxdiff zero
This is partial fuzzy progress, not an exact match or linking result.
## Validation
Pool checks before the trial and after the full build: identical, zero strings.
The full 43U build passed. `ninja build/43U/ok` passed with no work pending.
DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`.
`git diff --check` passed. Literal-reference audit: no candidates/errors;
twelve functions analyzed, unchanged nonexact setter skipped for unequal size.
A focused independent scalar pixel model was compared with the compiled
candidate, original, and saved baseline through the existing bounded PPC
interpreter. All 8,721 vectors passed (26,163 object executions):
- 808 cases covering every valid edge width and height for scales 1/2/4/8,
both starting-row parities, and even-column residues 0/2 within a tile
- 256 cases covering both width/height selection branches, zero/full/partial
extents, row parity and column residues
- 6,400 saturation cases: all 256 luminance values crossed with all Cb/Cr
pairs from {-128,-1,0,1,127}
- 1,257 aligned input/output overlaps; every output byte stays inside the
actual 0x184-byte convBuf backing array and state remains separate
All 114 instructions in candidate, original, and baseline were exercised.
Every non-stack byte, including guards, was compared against the scalar model.
The interpreter also checked LR, stack pointer, and GPR14..GPR31 preservation.
Odd input x is excluded by the existing entry assertion; valid multi-pixel
rows exercise both odd/even column paths. Unsupported scales and invalid
pointers are not asserted valid API inputs. These are bounded interpreter
checks, not formal equivalence or Wii runtime validation. The existing integer
interpreter's limitations remain; no FPU, MMIO, exception or timing model is used.
## Reproduction artifacts
Local evidence directory: `/tmp/jpeg-pixel-lifetime/`.
- `baseline-report.json`, `baseline-rgb.o`: saved before source edits
- `candidate-report.json`, `candidate.ctx`: focused candidate measurements
- `full-build.log`: full build output
- `audit.py`, `audit-results.json`, `audit-output.txt`: independent pixel model
and targeted differential evidence
The test script reads the current candidate object, current original object,
and saved baseline object. It does not write repository source or original
binary bytes. Re-run from this worktree:
```sh
PYTHONPATH=../local-tools ../.venv/bin/python /tmp/jpeg-pixel-lifetime/audit.py
```
Build configuration uses cached approved tools:
```sh
../.venv/bin/python configure.py --version 43U \
--wrapper ../toolchain/wibo-build/wibo --compilers build/compilers \
--dtk build/tools/dtk --objdiff build/tools/objdiff-cli \
--sjiswrap build/tools/sjiswrap.exe
WIBO_SJIS_MISSING_IMPORTS=1 ../.venv/bin/ninja
build/tools/objdiff-cli report generate -p . -o build/43U/report.json -f json
```

View File

@@ -0,0 +1,70 @@
# Keyboard dictionary accessor contract, 2026-10-03 UTC
Base `1fa33882`, branch `agent/bittle/keyboard-manager-reconstruction`.
Only two calls in `src/system/iplKeyboard.cpp` and this log are changed. 43U only;
no header, metadata, compiler-setting, assembly, linking or data edits.
## Source defect and retained correction
Manager::create's two dictionary loops use an OEM index in the range 10..19.
They passed that index to System::getZiDicData(int), which is currently defined
as `smArg.mZiDicData.sys[i]`. The sys subarray has ten elements. Thus the source
expressed the OEM reads beyond that subarray's bounds, despite landing at the
intended adjacent OEM bytes on the target compiler.
The retained calls use the already existing System::getZiOemDicData accessor,
passing the OEM-relative index `oemIndex - EZTX_LANG_MAX` (0..9). This accessor
indexes the actual ten-element oem subarray. The target loads from the combined
system/OEM table base plus four times the absolute OEM index; the corrected
accessor computes the same addresses through the proper object member.
No shared accessor or data layout is changed. The existing system-dictionary
presence check governing fallback selection is preserved, as the target proves.
This is a source-correctness improvement, not a new exact match or a matching-
percentage gain. The entire generated source .text section remains byte-identical.
## Other investigations
- Read the prior fz1 and data-d1 construction/index/memo-copy attempts.
- The existing zero-argument twenty-entry dictionary accessor also preserved
the baseline score. The dedicated OEM accessor was preferred for its explicit
index domain and object-member contract.
- Using the system index directly for OEM lookup or changing to an independent
zero-based OEM counter changed induction lowering and reduced similarity;
those forms were not retained.
- Explicit allocation followed by placement construction was tried for the arc
link, resource accessor and allocator. It did not improve output, so those
larger changes and the extra include were discarded.
- No declaration/register sweep, artificial storage, volatile cast, padding,
assembly, header change or linking experiment was used.
## Verification
Baseline -> candidate:
- Manager::create: 94.00944 -> 94.00944%, 318/318 instructions unchanged.
- Unit fuzzy: 98.73506 -> 98.73506%.
- Exact functions 31/32, exact code 4752/6024, data 1184/1184 (100%), and linked
status unchanged. Exact matching of create remains open.
- Fresh baseline and candidate object builds: all 32 reported function instruction
streams are identical. Entire source .text (6240 bytes), .data (1161 bytes),
.sdata (6 bytes) and .sdata2 (8 bytes) are byte-identical.
- Pool: all 28 strings identical to target.
- Literal audit: 25 arguments, 32 functions, no candidates, skips or errors.
- Full 1027-unit report has no exact-function/code/data/fuzzy regressions.
- Full 43U build and build/43U/ok passed. DOL SHA1:
`26116613f624061ba99c8d1a299aaa6efa85670d`.
A host harness extracts the actual production dictionary loops and uses bounded
system/OEM accessor stubs. Compiled with undefined-behavior/bounds sanitizers,
it passes all 1,048,576 combinations of ten system and ten OEM availability bits.
The independent reference checks the target's fallback-selection rule, every
result pointer, the preserved language IDs and both final table sentinels.
No Wii resource-loading or UI runtime execution is claimed.
Private evidence: `/tmp/keyboard-manager-reconstruction/` contains baseline/final
reports and object copies, pool/literal audits, full-build.log, source experiments,
validate_dictionaries.py and dictionary-tests.log. No retail assembly or binary
is included in this commit.
GATE: source accessor bounds corrected with byte-identical generated code and
no matching/data regressions. Frozen for parent validation; no completion claim.

View File

@@ -0,0 +1,82 @@
# MD5 sequential word consumption, 2026-10-03
Base: `fc114afd`. Source scope: `libs/RevoEX/src/net/md5.c` only. This is a
validated partial reconstruction under the user's decompiled-first priority,
not an exact match or linking change. Prior accepted source and logs remain.
## Selected source form
The first sixteen MD5 steps consume the existing sixteen-word context block
sequentially. Each step reads the selected word twice with the byte-reversed
intrinsic, then advances its local cursor by one word. The original performs
those paired loads before each four-byte cursor increment. `rotateNextSum`
expresses that consumption through the actual cursor's address, and is used
only by the four first-round step sites. The cursor begins at `buffer32`, ends
one-past its sixteen words and never escapes. No additional state is stored.
The other three rounds select nonsequential words through the existing index
table and therefore retain the non-consuming `rotateSum` helper. Both helpers
use the same unsigned arithmetic and paired endian loads. The small duplicated
rotation expression supports these two different pointer contracts; duplication
is not itself a reason for the gain. There are no new helper families, XOR
regroupings, arbitrary ordering hints, volatile qualifiers or register forcing.
This exact source form was previously measured at 94.98366% in the grouping
work, but rejected because it duplicated the small rotation body for a partial
gain. Fresh review selected it under the current acceptance priority. Only this
archived form was compiled; no new variant sweep was performed.
## Pinned contracts and scoped instruction audit
Original ProcessBlock consumes only incoming r3. State occupies context bytes
0..15, the untouched u64 byte count 16..23, and the owned block 24..87.
The exact Update API copies each complete block there; exact GetDigest builds
its final block there. ProcessBlock has no calls, external buffer, callback or
count dependency. No missing input or width defect was found.
Both compiled streams have four CTR=4 loops and reduce to the same independent
64-step MD5 recurrence in a private symbolic PPC instruction model. Arbitrary
initial state words and arbitrary message words are retained symbolically;
normalization uses only unsigned addition/XOR identities, commutative Boolean
operations and the observed split-rotation identity. Both streams execute
1,107 instructions, 128 paired little-endian message loads, 64 constant loads
and 48 index loads. The selected addresses match all four MD5 word schedules.
All 64 constants and 48 indices match their standard formulas. The only object
writes are the four final state words, at offsets 0,4,8,12. This scoped model
is additional evidence, not a general compiler-equivalence proof.
## Fresh gates
- ProcessBlock: 94.30719 -> 94.98366% fuzzy, 306/306 instructions.
Positional ctxdiff differences decrease 215 -> 212; it is still nonexact.
- Unit: 96.179825 -> 96.63377%; exact functions 3/4 and exact code 600/1824
unchanged. Data remains 456/456 (100%), with no linking change.
- All three public APIs remain byte-identical to baseline and instruction-exact
against original: Init 16/16, Update 60/60, GetDigest 74/74, diffs 0.
- All 448 .data bytes are unchanged and identical to original. The .sdata byte
remains 0x80; the existing source size 1 / target size 8 alignment difference
is unchanged. No padding or section changes were introduced.
- Empty pools identical. Literal-reference audit analyzes all four functions,
with zero candidates/errors and no string arguments to check.
- Full 1,027-unit before/after report: only MD5 changes; no exact function,
exact code, data or fuzzy regression. Post-build final report equals the
candidate report.
- 3,088 production-C digest/chunking comparisons against hashlib pass, including
standard vectors, one million `a` bytes, 1,500 seeded messages and block/final
padding boundaries. Padding is supplied externally; host testing does not
exercise GetDigest's PPC-endian length stores.
- 20,000 direct production ProcessBlock checks against an independent scalar
compression recurrence pass with ASan/UBSan. Arbitrary initial states and
blocks cover unsigned overflow; count, input block and surrounding canaries
stay unchanged. Leak detection is disabled because it is unsupported under
this environment's ptrace; address and undefined-behavior checks are enabled.
- Full 43U build and build/43U/ok pass. DOL SHA1 remains
`26116613f624061ba99c8d1a299aaa6efa85670d`.
Private evidence: `/tmp/md5-cursor-revalidation/` contains the reports, source
snapshots, instruction audit, host tests, sanitizer output, pool/literal/ctxdiff
results and build logs. Read-only preselection audit is preserved separately in
`/tmp/md5-processblock-audit/`. No original assembly or binary is committed.
GATE: passing partial instruction-structure gain, frozen for independent review;
exact matching and linking remain open.

View File

@@ -0,0 +1,104 @@
# MD5 bounded declaration-order continuation, 2026-10-03
Base: `b7a06e9d`, after the accepted sequential cursor helper from `55ff13a2`.
Only `libs/RevoEX/src/net/md5.c` and this log change. The parent authorized one
bounded official declaration search after confirming this source had not been
searched. No remote operation, extra search or custom variant was performed.
## Authorized range and run
Original lines 93..97 contain only five existing uninitialized declarations:
word, constant, index, round, block. The initialized state words on line 92,
static arrays, all assignments, expressions, scopes and both helpers stay
byte-for-byte unchanged. These independent scalar/pointer declarations have
no initialization side effects; every value is still assigned before use.
The earlier four-leaves-r11 search used different rotation code and a larger
block containing initialized state declarations. The accepted grouping and
cursor-helper attempts explicitly did not search this exact source.
After a fresh 43U baseline build and pool check, ran exactly once:
WIBO_SJIS_MISSING_IMPORTS=1 NINJA=../.venv/bin/ninja \
PYTHONPATH=../local-tools ../.venv/bin/python -u \
tools/decomp-assist/declsearch.py libs/RevoEX/src/net/md5 ProcessBlock \
--version 43U --lines 93 97 --max-evals 23
The official structural/positional score trajectory was:
(5,212) -> (5,209) -> (5,202) -> (5,197).
The selected order is index, block, constant, round, word.
The run stopped at its 23-unique-evaluation bound, not a proven local fixed
point. The final order has 22 distinct swap/move neighbors, and the original
order is outside that neighborhood. Covering the final order, its entire
neighborhood and the already-tested original would require at least 24
unique evaluations. A later separately authorized finite continuation could
therefore be useful; none was run here. The tool's final rebuild is additional
to its 23 evaluations. This is not an exhaustive search of all 120 orders.
## Fresh retention gates
- ProcessBlock: 94.98366 -> 95.55556% fuzzy, 306/306 instructions. Positional
ctxdiff decreases 212 -> 197; the official structural score remains 5.
- Unit: 96.63377 -> 97.01755%. Exact functions 3/4, code 600/1824 and data
456/456 remain unchanged. This is a partial matching gain; linking is unchanged.
- NETMD5Init 16/16, NETMD5Update 60/60 and NETMD5GetDigest 74/74 remain literally
instruction-exact against original and unchanged from baseline.
- .data 448 bytes and the existing .sdata byte/extent are unchanged. Empty
pools identical. Literal advisory analyzes all four functions without
candidates, skips or errors; there are no string arguments to check.
- Full 1,027-unit reports show only MD5 improved, with no fuzzy, exact-function,
exact-code or data regression. The final report equals the candidate report.
- A fresh symbolic PPC instruction audit reduces the compiled candidate and
original to the same unsigned 64-step MD5 recurrence, with identical selected
addresses for 128 LE message loads, 64 constants and 48 indices. Only the four
state words are written; count and block remain untouched.
- Production C passes 3,088 known-answer/seeded digest and chunking checks.
RFC1321 padding is supplied externally; GetDigest's platform-endian stores
remain instruction-exact and outside little-endian host test coverage.
- Production ProcessBlock passes 20,000 arbitrary-state/block comparisons with
ASan/UBSan, preserving count, input block and canaries. Leak detection is
disabled for ptrace; address and undefined-behavior instrumentation is enabled.
- Full 43U build and build/43U/ok pass. DOL SHA1 remains
`26116613f624061ba99c8d1a299aaa6efa85670d`. git diff --check passes.
Private evidence: `/tmp/md5-declaration-order/` contains the exact search log,
source/object snapshots, reports, symbolic/host/sanitizer checks, pool/ctxdiff/
literal output and build logs. The read-only eligibility screen is separately
preserved in `/tmp/md5-declaration-screen/`. Original assembly/objects stay private.
GATE: passing bounded five-declaration-only partial gain, frozen for independent
review. No initializer, expression, statement, type, scope or helper changed.
## Finite continuation: local fixed point
Prepared base `32be36cb` plus cherry-picked source candidate `31dffe1b`.
Fresh configure/build verified ProcessBlock 95.55556% before the continuation.
The parent authorized exactly one further official run over the same five
uninitialized declarations, with --lines 93 97 --max-evals 120. No source type,
initializer, assignment, expression, scope or helper was changed.
The run started and finished at (5,197), without any intermediate improvement.
It stopped after 23 unique evaluations: the selected order and all 22 distinct
swap/move neighbors. This is a local fixed point of the official tool's scoring
and neighborhood, not the 120-evaluation cap or an exhaustive global optimum.
No additional run is authorized or planned.
The tool restored its initial source byte-for-byte. The complete rebuilt MD5
object and full 1,027-unit before/after/final reports are also byte-identical.
ProcessBlock remains 95.55556%, 306/306 instructions, 197 positional differences;
unit 97.01755%, exact APIs 3/4, code 600/1824 and data 456/456 are preserved.
Pool remains identical and all three public APIs remain instruction-exact.
Fresh full 43U build and build/43U/ok pass, with DOL SHA1 unchanged at
`26116613f624061ba99c8d1a299aaa6efa85670d`.
No semantic harness was rerun for the neutral continuation: both the entire
source and compiled object are identical to its already-validated baseline.
The earlier symbolic, 3,088-vector and 20,000-sanitizer gates therefore remain
applicable without claiming new test runs. This continuation changes only this
log; the source candidate from `31dffe1b` is preserved for consolidated review.
Private continuation evidence: `/tmp/md5-order-finish/`, including search.log,
source/object baseline, identical reports, pool/ctxdiff results and full gates.
GATE: neutral finite continuation closed at local fixed point; prior source gain
preserved, no further declaration search performed.

View File

@@ -0,0 +1,99 @@
# NHTTP stdlib source reconstruction, 2026-10-02
Base `b26e248b`, branch `agent/bittle/nhttp-source-reconstruction`, 43U only.
Owned source: `libs/RevoEX/src/nhttp/NHTTP_stdlib_RVL.c`. No headers, metadata,
configuration, linking flags, binary data, or other source files changed.
The earlier `four-leaves-r9.attempts.md` and other worker logs are untouched.
## Target-grounded changes
### NHTTPi_compareToken
The target enters through its case-folded equality test, then checks the raw left
byte for NUL/space before advancing the two pointers. It retains the unsigned
byte separately and sign-extends it for both the case fold and termination check.
The baseline unconditional loop placed that control-flow boundary differently
and compiled to 44 instructions rather than the target's 45.
The retained while condition captures the raw u8 load and explicitly sign-extends
it into LowerCase. The body reuses that captured byte for termination. LowerCase
returns its conditional value directly, preserving the target's separate folded
value lifetime. This recovers the complete 45-instruction control-flow shape.
The common helper's other callers remain unchanged at the instruction level.
A separate token-only helper gave the same result; it was removed to avoid
unnecessary duplication.
Remaining differences: two initial constant loads are reversed, and eight
instruction operands use different scratch/callee-saved registers. This is not
an exact match.
### NHTTPi_Base64Encode
The target retains signed length/padding comparisons. The length local is now
s32, matching those comparisons without the previous mixed-sign comparisons.
Each quartet snapshots its three signed input bytes before writing the output,
then combines each later byte's high fragment with the preceding byte's masked
low fragment. This expresses the target's byte-load and index dependency
structure more closely, preserving the 119-instruction body size.
The target and existing implementation use signed byte shifts, a NUL-terminated
input, and full three-byte reads even for a short final group. This candidate does
not broaden the API to arbitrary binary data or repair those original constraints.
The repository's caller supplies a separate temporary source and authorization
output buffer (`d_nhttp.c`, NHTTP_CreateRequest proxy authorization path).
## Experiments
- Recovered the previously logged loop-test/raw-byte/ternary-fold approach rather
than repeat register/declaration searches. Local conditional-loop alternatives
were measured against the target before retaining the compact while condition.
- One exploratory assignment/read condition was found to be unsequenced. It was
withdrawn, never behavior-tested, and is not part of the retained source.
- Signed/unsigned/raw byte representations and explicit sextet fragments were
checked against target load/sign-extension evidence. Signed byte snapshots
with the retained index grouping gave the best compact source.
- Stream-cursor forms generated identical code and were not retained.
- A separate quartet helper improved Base64 only 67.63025 -> 67.79832%; it was
discarded as unnecessary source expansion. There is no new helper in the diff.
- No declaration/register sweep, inline assembly, use-site volatile, dummy value,
padding, compiler-option change, or linking experiment was performed.
## Verification
Before -> after:
- NHTTPi_compareToken: 54.622223 -> 98.844444% fuzzy; 44 -> 45 instructions against
target 45. Final ctxdiff: 10 positional differences.
- NHTTPi_Base64Encode: 60.285713 -> 67.63025% fuzzy; 119/119 instructions unchanged.
Final ctxdiff: 67 positional differences (baseline 58); aligned objdiff improves
despite that positional metric. Exact dependency scheduling remains open.
- Unit fuzzy: 87.93594 -> 93.03203%.
- Exact functions 11/14, exact code 1388/2248, data 112/112 (100%) and linked status
are unchanged. All 11 previously exact functions have ctxdiff diffs 0.
- The unchanged strnicmp remains 99.76471%, 51/51 instructions, two constant-order
differences. LowerCase's other exact users remain exact.
- Pool: the one alphabet string is identical. .data's 65 bytes and .rodata's
36 bytes equal the prefixes of their 72-byte/40-byte target sections. Existing
trailing target alignment extents are unchanged; no padding was introduced.
- Literal-reference audit: 14 functions analyzed, no candidates, skips or errors;
zero statically addressed call arguments, so this is not a separate proof of
complete data matching.
- Full 1027-unit report: zero exact-function/code/data/fuzzy regressions.
- Full 43U build and build/43U/ok passed. DOL SHA1 remains
`26116613f624061ba99c8d1a299aaa6efa85670d`.
Host behavior validation compiles both unchanged production sources (baseline
and candidate) with -fsigned-char and fixed-width SDK type shims:
- 75,536 compareToken cases: all 65,536 first-byte pairs plus 10,000 seeded
multi-byte/case-fold/mismatch cases, against an independent token reference.
- 3,033 Base64 cases: known answers, every length 0..1024, and 2,000 seeded ASCII
strings up to 4096 bytes, against Python base64. Return length, NUL terminator
and a 16-byte output canary are checked. Inputs have readable zero tail bytes
for the original full-triplet reads. High-bit/binary inputs are not claimed.
Private local evidence: `/tmp/nhttp-source-reconstruction/` contains baseline and
final reports, all function ctxdiffs, pool/literal audits, full-build.log,
validate_nhttp.py, vectors.log, and the rejected local experiments. No retail
assembly or binary is included in this commit.
GATE: validated partial control/data-flow/type reconstruction; no regressions.
Exact matching and linking remain open. Frozen for independent parent validation.

View File

@@ -0,0 +1,75 @@
# NHTTP token byte-role recovery, 2026-10-03
Base: `81ba2799`. One authorized two-line trial in
`libs/RevoEX/src/nhttp/NHTTP_stdlib_RVL.c`. No other function, shared helper,
header, compiler setting or linking configuration was changed.
## Source roles and historical evidence
NHTTPi_compareToken retains the raw left byte across its folded comparison,
then signs that raw value again for the matched NUL/space termination test.
The target loads the right byte and folds its signed value first, then loads
the left byte into a separate zero-extended word before signing/folding it.
The raw left word remains separate from both folded comparison results.
Use u32 for that actual zero-extended raw-left value, and express the right
input through the same explicit u8-load/s8-conversion boundary as the left.
No extra local, helper, load, dummy use or register-forcing construct is added.
The shared LowerCase helper and literal termination tests are unchanged.
This is data-representation reconstruction, not a changed byte-domain contract.
The perm2 attempt log had measured 99.51111% for the word-lived raw left byte
and 99.73333% with the right raw-byte conversion, but discarded both solely
because they were nonexact. Those old temporary sources are unavailable here;
the minimal form was independently reconstructed from current source and
original instructions. Only that one two-line form was compiled this round.
## Byte, ordering and termination proof
- All 256 byte values were checked against the target's actual carry-based
signed comparisons. Only ASCII A..Z gain 32; bytes 128..255 remain signed
negative values for comparison, preserving equality with the same raw byte.
- A private interpreter executes the original 45-instruction function on all
65,536 byte pairs plus five multi-byte/high-bit/termination cases. Return
values and ordered byte-read traces agree with the proposed semantics.
- The compiled candidate differs from original only at two initial li
instructions: zero and 'Z' are initialized in the opposite order. They write
distinct registers before either value is used and do not change condition
state. After commuting those two independent instructions, all 45 match
literally, including right-before-left loads, both signed conversions,
folded comparisons, pointer advances and the saved raw-byte stop test.
- A matched NUL or literal space returns 0; every mismatch returns -1. Other
whitespace bytes are ordinary token data. The comparison still happens
before termination, and no new dereference or store is introduced.
## Fresh gates
- NHTTPi_compareToken: 98.844444 -> 99.73333%, 45/45 instructions, two residual
constant-scheduling differences. This is not an exact match.
- Unit: 99.88612 -> 99.9573%; exact functions 12/14 and code 1864/2248 preserved;
data 112/112 preserved. Linking unchanged.
- All 13 unrelated functions' instruction streams and resolved relocations are
identical to baseline, including the 12 exact functions. Every allocated data
byte and section extent is unchanged. Pool 1/1 identical.
- Literal-reference advisory: all 14 functions analyzed, no candidates, skips
or errors; this function has no string arguments at external calls.
- Full 1,027-unit reports show only compareToken improved, with no fuzzy,
exact-function, exact-code or data regression. Post-build final report equals
the candidate report.
- Production C: 75,536 exhaustive byte-pair and seeded token comparisons pass
against an independent ASCII-fold/literal-termination reference for both
baseline and candidate.
- ASan/UBSan: 95,504 byte-pair, seeded token, aliased and overlapping-input
comparisons pass; all input bytes remain unchanged. The harness extracts
actual production function/helper bodies and uses signed-char host settings.
Leak detection is disabled for ptrace; address/UB instrumentation is enabled.
- Full 43U build and build/43U/ok pass. DOL SHA1 remains
`26116613f624061ba99c8d1a299aaa6efa85670d`. git diff --check passes.
Private evidence: `/tmp/nhttp-token-byte-roles/` contains source/object snapshots,
reports, host/sanitizer harnesses and results, pool/literal/ctxdiff and build logs.
The prior read-only byte proof and proposed diff are preserved separately in
`/tmp/nhttp-token-recovery-screen/`. Original assembly and objects remain private.
GATE: passing two-line partial recovery, frozen for independent review.
No additional constant-order or register trial was attempted.

View File

@@ -0,0 +1,89 @@
# NWC24 writable-task validation recovery, 2026-10-03
Base: `57ccda38`. One bounded source trial in
`libs/RevoEX/src/nwc24/NWC24Download.c`; 43U only. This is a partial
instruction-structure gain, not an exact match, behavior fix or linking change.
## Recovery screening and source rationale
Older exact-only attempts had restored valid partials: pk2 records a task-view
permission helper at 98.695656%; structural round12 records more extensive
permission/access/retry forms up to 99.48617%. Their temporary source artifacts
are absent in this workspace. This candidate was reconstructed from current
source and original instructions, not copied from an unavailable best snapshot.
Only the smallest writable validation operation was tried; no retry helper,
AddTaskInternal, compareToken or ATERM variant was mixed into it.
The new private `ValidateWritableDlTask(const NWC24DlTask*)` returns the same
NWC24Err as the existing validator with write=TRUE. It reads the actual task
view and snapshots its cached header. In the owner-mismatch fallback, it reads
flags and the u16 group ID into operation-local values, initializes a real
permission result false, and makes it true only when bit 0x40 permits the group
query and the IDs match. These values belong to that validation operation;
none is dummy state, an optimization barrier or artificial spill.
Only NWC24UpdateDlTask's two existing writable validation calls use this helper.
The shared validator and all other callers stay unchanged. The second call
reacquires the current header and repeats tool/owner/group permission checks
after the time update. Its failure deliberately suppresses only the two reset
stores, rather than returning early; the original retry/store behavior remains.
No object is allocated, freed or written by the new helper. No pointer escapes,
public type changes, flags, assembly, padding or forced register use is added.
## Original call/data-flow checks
- Target and candidate place all nine direct calls at identical instruction
indices: tool/app/group queries, universal-time query, signed divide helper,
repeated tool/app/group queries, final StoreDlTask.
- Tool query precedes owner query, and group query occurs only after both fail
and flags bit 0x40 is set. The three query callees consume no incoming argument;
their actual implementations read process/library metadata.
- Both group IDs are loaded before NWC24GetGroupId and compared as u16 after
the call. Flags are u32; the permission result is BOOL. The task/header are
read-only, and the cached header lifetime survives the query sequence.
- Null task/header return -3/-9 before metadata queries. Permission failure is
-7. The 0xFFFF sentinel and u16 maximum-count checks retain their ordering.
- The time-output pointer remains the same eight-byte stack slot; __div2i still
receives the high/low time words and signed divisor 60. StoreDlTask receives
the original task pointer. No file/resource cleanup is owned by this helper.
- Current unsigned retry-mask semantics, retry loop, time helper, ID rechecks
and second-failure behavior are unchanged.
## Fresh measurements and validation
- NWC24UpdateDlTask: 95.00395 -> 98.695656%; source 249 -> 253 instructions,
target 253. Frame 0x30 -> target 0x20. Positional ctxdiff 250 -> 43 differences.
- Unit: 99.252884 -> 99.55186%; exact functions 27/30 and exact code 9304/12496
preserved; data 80/80 preserved. No linking changes.
- Every other one of the 29 functions has identical instructions and resolved
relocations versus the baseline, including all 27 exact functions.
- Every allocated data byte and section extent is unchanged. Existing source/
target alignment extents (.data 49/56 and .sbss 4/8) are unchanged; .sdata 16/16.
- Pool 3/3 identical. Literal advisory: 29 functions, 5 arguments, no candidates
or errors; unchanged AddTaskInternal is skipped because its size differs
from original. It remains 97.7182% and was not edited.
- Full 1,027-unit reports show only UpdateDlTask improved and no exact-function,
code, data or fuzzy regressions. Final post-build report equals candidate.
- ASan/UBSan: 262,144 exhaustive u16 group/flag cases, mutating the task group
during the group query to verify captured-value semantics. Seven directed
cases check nulls, sentinel/range behavior, tool/owner short-circuiting and
successful/failed second-validation stores.
- ASan/UBSan: 60,000 baseline/candidate Update scenarios compare return values,
task/header bytes, selected work pointer and ordered external call traces.
They cover metadata-query/time/store statuses, ID boundaries, group/owner
mismatches, retry counts/masks including bit 31, signed times, and controlled
task/header/work mutations at query boundaries. Actual production helper
bodies are extracted unchanged; metadata/time/store I/O is stubbed. No network
or file operation is performed. Leak detection is disabled for ptrace;
address and undefined-behavior instrumentation remain enabled.
- Full 43U build and build/43U/ok pass. DOL SHA1:
`26116613f624061ba99c8d1a299aaa6efa85670d`.
- git diff --check passes.
Private evidence: `/tmp/nwc24-write-permission/` contains baseline/candidate
sources and objects, reports, disassembly audit, host test generator/harness,
pool/ctxdiff/literal results and build logs. The preceding read-only screen is
in `/tmp/network-partial-recovery-screen/`. No retail assembly/binary is committed.
GATE: single justified partial recovery passes; frozen for independent review.
Historical 99.48617% is not claimed. Exact matching and linking remain open.

View File

@@ -0,0 +1,79 @@
# ODH Huffman node-type reconstruction, 2026-10-03 UTC
Base `a894ff5c`, branch `agent/bittle/odh-huffman-node-types`, 43U only.
Changed only the two tree declarations/initializers and their local pointer
record in `src/system/odh.cpp`, plus this log. No headers, public signatures,
metadata, linking flags, forced alignment or padding changed.
## Evidence and source correction
The decoder reads its tree entries and leaf categories with zero-extending
16-bit loads. Edges use the low 14 bits as relative halfword indices, while the
top two bits indicate terminal left/right branches. Leaves hold categories0..11.
The earlier source represented each pair of entries as one packed const u32 and
then accessed it through u16 pointers. HufftreeData likewise described the trees
as const u32 pointers, although every decoder use expects halfword entries.
Both tables are now explicit const u16 arrays, each with 24 actual entries.
HufftreeData::tables holds const u16 pointers. This removes the mismatched u32
object/u16 access representation, rather than changing the Huffman algorithm.
Every original word was split into its high and low halfwords in the target's
big-endian order; no value, tree edge or byte was added, removed or reordered.
The decoder's existing u16** parameter, its exact mangled public symbol, the C
ODH entry points and every caller are unchanged. The existing caller casts retain
the established ABI; no decoder writes a tree entry. Component0 uses the luma
value tree, components1/2 the chroma value tree, and all use the existing luma
prefix tree for zero-run categories. Request initialization starts at byte16,
bit offset0; successful decoding commits normalized offsets0..7.
## Read-only decoder audit
Prior sol-low, sol-high and fz10 attempts were reviewed. The existing decoder is
306/306 instructions with register allocation differences. Four-byte lookahead,
big-endian word assembly, unsigned bit-buffer operations, predictor selection,
DC/AC sign reconstruction, zero-run writes, EOB, success-only cursor/bit-count
commit, and error-path partial coefficient/predictor writes agree with target.
No additional algorithmic or stream-boundary behavior was invented.
Malformed overlong zero runs can exceed a nominal64-coefficient block in both
the source and original target; changing that behavior is outside this focused
type correction. Arbitrary table contents or invalid request states are likewise
not claimed to have acquired validation.
## Verification
- Each tree remains exactly48 bytes. Fresh source bytes, old packed-u32 bytes,
and original split-object payloads agree byte-for-byte.
- Exhaustive tree-path validation: all512 nine-bit luma prefixes and all2048
eleven-bit chroma prefixes agree with independent canonical Huffman codes,
including each valid leaf and the depth-limit invalid path.
- Fresh baseline/candidate builds: all28 reported function instruction streams
are unchanged. Entire .text14964, .data459, .rodata5856 and .sdata2 40 bytes
are identical, with the same section alignments. Defined function/object
symbol names, bindings, types and sizes are unchanged.
- Decoder remains95.57189%,306/306; unit remains99.55462%; exact26/28 and code
12876/14684; data6360/6360 (100%) and linking unchanged. No matching gain claimed.
- Pool: all10 strings identical to target.
- Literal audit:14 arguments across28 functions, no candidates, skips or errors.
- Full1027-unit report: zero exact-function/code/data/fuzzy regressions.
- Full43U build and build/43U/ok passed. DOL SHA1:
`26116613f624061ba99c8d1a299aaa6efa85670d`.
A host harness compiles the actual production decoder body and the new u16 table
initializers with fixed-width types and strict aliasing enabled. It passes24000
cases against an independent canonical-code bit reader:6657 successes and17343
truncation/malformed-code failures. Coverage includes components0/1/2, starting
bit offsets0..7, positive/negative DC and AC values, zero runs, EOB, full blocks,
4-byte-lookahead boundaries, invalid tree codes and run signs, output canaries,
predictors and request-state commit. Malformed overlong zero runs are excluded;
whole-image/Wii runtime execution is not claimed.
Private evidence: `/tmp/odh-node-types/` contains baseline/final reports and
source objects, tree-proof.log, pool/literal audits, full-build.log,
validate_decoder.py and decoder-tests.log. The earlier read-only decoder audit
is in `/tmp/odh-decoder-audit/`. No retail assembly or binary is committed or
uploaded.
GATE: real halfword node types reconstructed, ABI and all compiled bytes/metrics
preserved, tree and decoder behavior verified. Frozen for parent validation.

View File

@@ -127,3 +127,73 @@ The harness is supplemental behavioral validation, not a retail runtime test.
GATE: focused decompilation improvement; full 43U/DOL and no-regression checks
pass; exact-matching gate remains incomplete at 30/31. No linking claimed.
## Follow-on: recover the last ESMisc structural differences
Baseline for this follow-on is the accepted reconstruction `1f9db89d`:
30/31 exact functions, function 95.830734%, unit 99.33143%, 446/449 instructions,
data 4416/4416. The source/header correction remains intact.
Natural source attempts, in order:
| Attempt | Instructions | Function fuzzy | Disposition |
| --- | ---: | ---: | --- |
| Ticket helper uses error-first cleanup and returns early with no tickets | 446/449 | 95.830734% | Same generated code |
| Caller gives aligned ticket scratch an explicit pointer lifetime | 448/449 | 98.004456% | Improved |
| Move aligned ticket scratch into the ticket helper | 446/449 | 95.817375% | Rejected |
| Scope caller's scratch pointer to successful title enumeration | 448/449 | 98.89755% | Retained |
| Restore nested ticket helper with scoped scratch | 448/449 | 98.89755% | Same generated code |
| Ticket helper returns its actual ES operation status | 449/449 | 99.14254% | Retained |
The scratch pointer is initialized only in the block reached after successful
second enumeration, and remains live across the title loop. This restores the
saved scratch cursor and per-iteration 64-bit mask materialization. No pointer
is used before initialization and no artificial use extends its lifetime.
The private ticket helper now returns the status already obtained from
ES_GetTicketViews or ES_DeleteTicket, including its zero-ticket early return
and normal cleanup. Its caller intentionally discards that status. The return
contract of an independently emitted original helper cannot be established
because this helper was fully inlined; this is a natural equivalent source
form whose zero-ticket branch structure is confirmed by the target. It does
not overwrite the outer enumeration status or change the public ABI further.
Final ctxdiff: 449/449 instructions, 74 differences. Every mnemonic,
non-register operand, stack offset, resolved call target and branch target
agrees. The remaining differences are register substitutions, including the
title list, scratch cursor, title index, verifier flags and title halves. No
register/declaration permutation search was performed after reaching this
structural agreement.
Measurements after a fresh full report:
- ESMisc exact functions 30/31 -> 30/31
- ESMisc exact code 9404/11200 -> 9404/11200
- ESMisc fuzzy 99.33143% -> 99.8625%
- DeleteUnauthorizedData fuzzy 95.830734% -> 99.14254%
- Matched data 4416/4416 -> 4416/4416
- Pool: all 114 strings identical
- Literal audit: 204 arguments in 30 exact functions, no candidates/errors
- Every other unit's full report is unchanged
- Full 43U build/check and DOL SHA1 pass:
26116613f624061ba99c8d1a299aaa6efa85670d
- The same 12 ASan/UBSan host control-flow scenarios pass on helper bodies
freshly extracted from this final candidate (LeakSanitizer disabled only
for the environment limitation already noted)
- git diff --check passes
This remains a partial matching improvement, not an exact function or unit.
### Rejected ATERM ownership experiment
Read-only target evidence identified that the old typed reply view spans the
last eight bytes of one BSS object and the following option-buffer allocation.
With parent approval, tried a real two-object protocol-workspace aggregate and
corresponding narrow metadata consolidation. It preserved storage, addresses,
all 17 exact functions and matched data, and reduced the main protocol from
972 to 959 instructions (target 951). However, its unit fuzzy regressed from
96.624664% to 96.49781%; wider grouping and a decoder-helper experiment also
failed the no-regression condition. All ATERM source and symbol metadata were
restored. Fresh report after restoration was identical to the accepted ESMisc
baseline, and the DOL hash passed. Detailed rejected source/metadata and
address evidence were kept privately for future work; none is in this commit.

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