From 7c8b94ac86a887a4ff997e22709aaddb4c1ca9dd Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Thu, 1 Oct 2026 08:25:57 +0000 Subject: [PATCH] AOSS 96.8, zi8alpha 94.2 (worker 5906998c) --- README.md | 2 +- .../RVLMiddleware/eZiText/src/clib/zi8alpha.c | 34 +++--- src/scene/setting/AOSS.c | 103 +++++++++--------- tools/decomp-assist/fix-board-r4.attempts.md | 82 ++++++++++++++ .../decomp-assist/fix-board-r4.final-gate.txt | 36 ++++++ 5 files changed, 191 insertions(+), 66 deletions(-) create mode 100644 tools/decomp-assist/fix-board-r4.attempts.md create mode 100644 tools/decomp-assist/fix-board-r4.final-gate.txt diff --git a/README.md b/README.md index 6ff61ffc..8593e142 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Progress | Decompiled | Matched | Linked | Data | |:---:|:---:|:---:|:---:| -| 99.31% | 86.76% | 60.61% | 91.11% | +| 99.32% | 86.76% | 60.61% | 91.12% | units 911/1027 complete, functions 12176/12563 matched. diff --git a/libs/RVLMiddleware/eZiText/src/clib/zi8alpha.c b/libs/RVLMiddleware/eZiText/src/clib/zi8alpha.c index b1dd1d18..64d243a6 100644 --- a/libs/RVLMiddleware/eZiText/src/clib/zi8alpha.c +++ b/libs/RVLMiddleware/eZiText/src/clib/zi8alpha.c @@ -1161,13 +1161,14 @@ checkKeyLayout: keyLayoutCursor = keyLayout; candidateCharacterCount = wordLength + prefixCount; for (index = 0; (int)index < (int)(unsigned int)keyLayoutCount; index = index + 1) { - if (*keyLayoutCursor >= candidateCharacterCount) { + if (*keyLayoutCursor < candidateCharacterCount) { + keyLayoutCursor = keyLayoutCursor + *keyLayoutCursor + 1; + } else { if (*keyLayoutCursor++ > candidateCharacterCount) { index = (unsigned int)keyLayoutCount; } break; } - keyLayoutCursor = keyLayoutCursor + *keyLayoutCursor + 1; } if ((int)index < (int)(unsigned int)keyLayoutCount) { for (elementIndex = 0; (int)elementIndex < (int)(unsigned int)candidateCharacterCount; @@ -1196,7 +1197,7 @@ emitCandidate: if (firstCandidate == 0) { if (((ZiAlphaOptions*)optionData)->countOnly != '\0') { if (((ZiAlphaOptions*)optionData)->suffixOnly != '\0') { - if ((int)(wordLength + prefixCount) < (int)((ZiAlphaOptions*)optionData)->shortestWord) { + if ((int)((ZiAlphaOptions*)optionData)->shortestWord > (int)(wordLength + prefixCount)) { ((ZiAlphaOptions*)optionData)->shortestWord = wordLength + prefixCount; } if ((int)((ZiAlphaOptions*)optionData)->longestWord < (int)(wordLength + prefixCount)) { @@ -1223,23 +1224,17 @@ emitCandidate: } else { if (((((ZiAlphaWork*)workData)->suffixMode == '\0') && (wordCursor[1] == 0)) && (candidateCount == 0)) { - if ((*wordCursor < 0xeff1) || (0xf010 < *wordCursor)) { - ((ZiAlphaWork*)workData)->singleCharacter = *wordCursor; - } - else { + if (*wordCursor >= 0xeff1 && *wordCursor <= 0xf010) { ((ZiAlphaWork*)workData)->singleCharacter = 0; } - } - if (((dictionaryExact == 0) || (parameters->elementCount != ((ZiAlphaWork*)workData)->rememberedCount)) - || ((parameters->maxCandidates != 1 && - ((candidateCount != 0 || (parameters->firstCandidate != 0)))))) { - if (((dictionaryExact == 0) && (parameters->elementCount == ((ZiAlphaWork*)workData)->rememberedCount)) - && ((parameters->maxCandidates == 1 || - ((candidateCount == 0 && (parameters->firstCandidate == 0)))))) { - ((ZiAlphaWork*)workData)->rememberedWord[0] = 0; + else { + ((ZiAlphaWork*)workData)->singleCharacter = *wordCursor; } } - else { + if (dictionaryExact != 0 && + parameters->elementCount == ((ZiAlphaWork*)workData)->rememberedCount && + (parameters->maxCandidates == 1 || + (candidateCount == 0 && parameters->firstCandidate == 0))) { for (index = 0; (int)index < (int)prefixCount; index = index + 1) { ((ZiAlphaWork*)workData)->rememberedWord[index] = wordCursor[index - prefixCount]; @@ -1250,6 +1245,13 @@ emitCandidate: } ((ZiAlphaWork*)workData)->rememberedWord[index + prefixCount] = 0; } + else { + if (((dictionaryExact == 0) && (parameters->elementCount == ((ZiAlphaWork*)workData)->rememberedCount)) + && ((parameters->maxCandidates == 1 || + ((candidateCount == 0 && (parameters->firstCandidate == 0)))))) { + ((ZiAlphaWork*)workData)->rememberedWord[0] = 0; + } + } if ((((ZiAlphaWork*)workData)->suffixMode == '\0') && ((((((dictionaryKind == 1 && ((((ZiAlphaWork*)workData)->dictionaryFlags & 1) != 0)) || ((dictionaryKind == 3 && ((((ZiAlphaWork*)workData)->dictionaryFlags & 2) != 0)))) || diff --git a/src/scene/setting/AOSS.c b/src/scene/setting/AOSS.c index 73b6ac3c..5b1553bf 100644 --- a/src/scene/setting/AOSS.c +++ b/src/scene/setting/AOSS.c @@ -399,7 +399,9 @@ int AOSS_Init_old(AOSSInitInput* input) u32 initialSleep; u32 nextSleep; u32 resultCode; + u32 flags; int state; + int protocolState; u32 retryWait; u16 retryDelay; u32 delayStep; @@ -442,6 +444,7 @@ int AOSS_Init_old(AOSSInitInput* input) waitIntervals.defaults.response = defaultResponse; waitSettings.value = 0; receivedPackets = 0; + protocolState = 0; memset(&requestRecords,0,0x18); waitIntervals.limits.connection = input->options[0]; if (waitIntervals.limits.connection == -1) { @@ -468,12 +471,13 @@ int AOSS_Init_old(AOSSInitInput* input) memset(&s_runtime,0,0x1c); s_runtime.config = input->ssid; s_runtime.configLength = (u32)input->ssidLength; - s_runtime.flags = input->flags & 0xf; + flags = input->flags; + s_runtime.flags = flags & 0xf; s_runtime.interfaceType = input->mode; s_runtime.state = 0; s_runtime.ipAddress = 0xc0a80b01; s_runtime.active = '\0'; - if ((input->flags & 1) != 1) { + if ((flags & 1u) != 1u) { s_errorCode = 0x13; input->status = 0xf; if (s_accessPointConfig) { @@ -628,7 +632,7 @@ int AOSS_Init_old(AOSSInitInput* input) } else { memset(s_accessPointConfig,0,0x58); initialWait = waitIntervals.limits.connection; - remainingWait = 0; + attemptCount = 0; goto test_initial_link; } } @@ -662,8 +666,8 @@ wait_for_initial_link: resultCode = 0xffffffff; goto finish_initialization; } + if ((state == 0) && ((u32)*s_accessPointConfig == 1u)) goto handle_initial_link; remainingWait = (u16)waitIntervals.limits.response; - if ((state == 0) && (*s_accessPointConfig == 1)) goto handle_initial_link; for (; remainingWait != 0; remainingWait = (u16)(remainingWait - nextSleep)) { if (AOSSi_cancel_flag == 1) { input->status = 0xf; @@ -695,11 +699,11 @@ wait_for_initial_link: resultCode = 0xffffffff; goto finish_initialization; } - remainingWait++; + attemptCount++; test_initial_link: - if ((short)remainingWait < initialWait) goto wait_for_initial_link; + if (attemptCount < initialWait) goto wait_for_initial_link; handle_initial_link: - if (remainingWait == waitIntervals.limits.connection) { + if (attemptCount == waitIntervals.limits.connection) { input->status = 0xf; if (s_accessPointConfig) { AOSSi_Free(s_accessPointConfig); @@ -783,14 +787,13 @@ handle_initial_link: attemptCount = waitSettings.halfwords.high; settings.gatewayAddress = 0xc0a80b65; settings.ipAddress = 0xc0a80b01; - state = 0; perform_request: packetBuffer = s_responseBuffer; memset(networkAddresses,0,0x14); networkAddresses[4] = settings.gatewayAddress; networkAddresses[0] = settings.ipAddress; do { - if ((state == 1) && ((s8)s_runtime.active != 1)) { + if ((protocolState == 1) && ((s8)s_runtime.active != 1)) { if (s_socket != -1) { SOClose(s_socket); } @@ -941,7 +944,7 @@ request_socket_cleanup_complete: } } requestResult = s_socket; - switch (state) { + switch (protocolState) { case 0: if (s_operationState != 2) { s_operationState = 2; @@ -995,7 +998,7 @@ request_socket_cleanup_complete: break; } if (requestResult == -1) { - s_errorCode = state + 0x1000; + s_errorCode = protocolState + 0x1000; input->status = 0xf; if (s_accessPointConfig) { AOSSi_Free(s_accessPointConfig); @@ -1025,7 +1028,7 @@ request_socket_cleanup_complete: if (0 < requestResult) goto process_received_packet; receivedPackets = receivedPackets + 1; if (receivedPackets > attemptCount) { - switch (state) { + switch (protocolState) { case 0: s_errorCode = 0xf; break; case 1: s_errorCode = 0x10; break; default: s_errorCode = 0x11; break; @@ -1086,7 +1089,7 @@ process_received_packet: packetBuffer->socket = s_socket; retryWait = SONtoHs(receivedLength); packetBuffer->length = retryWait & 0xffff; - requestResult = AOSS_814001B4(state,packetBuffer,&receivedPackets,&requestRecords,s_socket); + requestResult = AOSS_814001B4(protocolState,packetBuffer,&receivedPackets,&requestRecords,s_socket); if (requestResult == 100) { protocolResult = 0; } @@ -1094,8 +1097,8 @@ process_received_packet: protocolResult = -1; } else { - if (state != requestResult) { - state = requestResult; + if (protocolState != requestResult) { + protocolState = requestResult; if (requestResult != 2) goto perform_request; if (s_socket != -1) { SOClose(s_socket); @@ -1291,10 +1294,10 @@ wait_for_packet: resultCode = 0xffffffff; goto finish_initialization; } - state = requestResult; + protocolState = requestResult; goto perform_request; } - state = requestResult; + protocolState = requestResult; if (receivedPackets > waitSettings.halfwords.high) { switch (requestResult) { case 0: s_errorCode = 0xf; break; @@ -2303,10 +2306,12 @@ int AOSS_81401778(void* packet, void* request, int socket) { AOSSHelloPacket* response = (AOSSHelloPacket*)s_responseBuffer; AOSSHelloPayload* payload; AOSSRequestRecords* requestRecords = (AOSSRequestRecords*)request; - AOSSSocketAddress destination; - AOSSKeySchedule schedule; - AOSSHelloRecord hello; - u8 accessPointName[8]; + struct { + AOSSSocketAddress destination; + AOSSHelloRecord hello; + u8 accessPointName[8]; + AOSSKeySchedule schedule; + } construction; u32 checksum; u16 nonce; u32 stateLength; @@ -2324,14 +2329,14 @@ int AOSS_81401778(void* packet, void* request, int socket) { checksum = 0; sequence = 0; - memset(&hello, 0, sizeof(hello)); + memset(&construction.hello, 0, sizeof(construction.hello)); memset(response, 0, 0x5dc); payload = &response->payload; - hello.data.fields.type = 2; - hello.data.fields.reserved01 = 0; - hello.data.fields.length = SOHtoNs(4); - hello.data.fields.supportedModes = s_runtime.flags; - hello.data.fields.supportedModes = SOHtoNl(hello.data.fields.supportedModes); + construction.hello.data.fields.type = 2; + construction.hello.data.fields.reserved01 = 0; + construction.hello.data.fields.length = SOHtoNs(4); + construction.hello.data.fields.supportedModes = s_runtime.flags; + construction.hello.data.fields.supportedModes = SOHtoNl(construction.hello.data.fields.supportedModes); responseLength = 8; if ((s32)s_connectionState == 1) { @@ -2344,44 +2349,44 @@ int AOSS_81401778(void* packet, void* request, int socket) { u32 part; for (part = 0; part < 4; part++) { for (index = 0; index < 2; index++) { - checksum = (checksum >> 8) ^ crcTable[(checksum ^ hello.data.bytes[part * 2 + index]) & 0xff]; + checksum = (checksum >> 8) ^ crcTable[(checksum ^ construction.hello.data.bytes[part * 2 + index]) & 0xff]; } } } checksum = (checksum ^ 0xffffffff) & 0xff; - schedule.bytes = (u8*)AOSSi_Alloc(8); - if (schedule.bytes != 0) { + construction.schedule.bytes = (u8*)AOSSi_Alloc(8); + 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); - AOSS_81401C9C(&schedule, s_packetState.keyNonce, + AOSS_81401C9C(&construction.schedule, s_packetState.keyNonce, sizeof(s_packetState.keyNonce) + sizeof(s_packetState.keyAddress), 8); for (index = 0; index < 8; index++) { - state = schedule.bytes; - firstIndex = (schedule.i + 1) % schedule.length & 0xff; + state = construction.schedule.bytes; + firstIndex = (construction.schedule.i + 1) % construction.schedule.length & 0xff; firstByte = state[firstIndex]; - secondIndex = (firstByte + schedule.j) % schedule.length & 0xff; + secondIndex = (firstByte + construction.schedule.j) % construction.schedule.length & 0xff; swap = state[secondIndex]; stateLength = firstByte + swap; - schedule.i = firstIndex; - schedule.j = secondIndex; + construction.schedule.i = firstIndex; + construction.schedule.j = secondIndex; state[secondIndex] = (u8)firstByte; state[firstIndex] = swap; - value = state[stateLength % schedule.length] ^ hello.data.bytes[index]; + value = state[stateLength % construction.schedule.length] ^ construction.hello.data.bytes[index]; payload->bytes[index + 4] = value; } - AOSSi_Free(schedule.bytes); + AOSSi_Free(construction.schedule.bytes); } payload->encrypted.length = SOHtoNs(8); responseLength = 0x0c; } else { - memcpy(payload->bytes, &hello, 8); + memcpy(payload->bytes, &construction.hello, 8); } - memcpy(accessPointName, &requestRecords->records[1], 8); - encryptionResult = AOSS_81401E80(accessPointName, 8, s_manufacturer, 6); + memcpy(construction.accessPointName, &requestRecords->records[1], 8); + encryptionResult = AOSS_81401E80(construction.accessPointName, 8, s_manufacturer, 6); if (encryptionResult != 0) { s_errorCode = 2; return -1; @@ -2396,17 +2401,17 @@ int AOSS_81401778(void* packet, void* request, int socket) { response->header.finalSequence = SOHtoNs(sequence); response->header.reserved = checksum; response->header.messageType = 0x11; - memcpy(response->header.messageIdentity, accessPointName, 8); + memcpy(response->header.messageIdentity, construction.accessPointName, 8); sendLength = (s16)(responseLength + 0x18); - memset(&destination, 0, sizeof(destination)); - destination.family = 2; - destination.port = SOHtoNs(0x5790); - destination.address = SOHtoNl(s_runtime.ipAddress); + memset(&construction.destination, 0, sizeof(construction.destination)); + construction.destination.family = 2; + construction.destination.port = SOHtoNs(0x5790); + construction.destination.address = SOHtoNl(s_runtime.ipAddress); if ((s8)s_runtime.active == 0) { - destination.address = 0xffffffff; + construction.destination.address = 0xffffffff; } - destination.length = 8; - SOSendTo(socket, response, sendLength, 0, &destination); + construction.destination.length = 8; + SOSendTo(socket, response, sendLength, 0, &construction.destination); return 0; } diff --git a/tools/decomp-assist/fix-board-r4.attempts.md b/tools/decomp-assist/fix-board-r4.attempts.md new file mode 100644 index 00000000..217b84e6 --- /dev/null +++ b/tools/decomp-assist/fix-board-r4.attempts.md @@ -0,0 +1,82 @@ +# AOSS and zi8alpha continuation, 2026-10-01 + +Entry 905c45b9. Object-order structural review; only measured improvements retained. +No configuration changes, upstream contact, inline assembly, stack placeholders or data placement. + +src/scene/setting/AOSS entry measures: {"fuzzy_match_percent": 96.50445, "matched_code": "6436", "matched_code_percent": 39.748024, "matched_data": "3896", "matched_data_percent": 99.18533, "matched_functions": 16, "matched_functions_percent": 76.190475, "total_code": "16192", "total_data": "3928", "total_functions": 21, "total_units": 1} +AOSS_Init_old entry: {"deficit": 8, "fuzzy": 93.14899, "measures": {"fuzzy_match_percent": 96.50445, "matched_code": "6436", "matched_code_percent": 39.748024, "matched_data": "3896", "matched_data_percent": 99.18533, "matched_functions": 16, "matched_functions_percent": 76.190475, "total_code": "16192", "total_data": "3928", "total_functions": 21, "total_units": 1}, "mine": 1576, "positional": 1479, "strict_diffs": 1471, "structural": 1151, "target": 1584} +AOSS_81400830 entry: {"deficit": 0, "fuzzy": 97.74143, "measures": {"fuzzy_match_percent": 96.50445, "matched_code": "6436", "matched_code_percent": 39.748024, "matched_data": "3896", "matched_data_percent": 99.18533, "matched_functions": 16, "matched_functions_percent": 76.190475, "total_code": "16192", "total_data": "3928", "total_functions": 21, "total_units": 1}, "mine": 321, "positional": 87, "strict_diffs": 89, "structural": 0, "target": 321} +AOSS_814013AC entry: {"deficit": 0, "fuzzy": 98.77193, "measures": {"fuzzy_match_percent": 96.50445, "matched_code": "6436", "matched_code_percent": 39.748024, "matched_data": "3896", "matched_data_percent": 99.18533, "matched_functions": 16, "matched_functions_percent": 76.190475, "total_code": "16192", "total_data": "3928", "total_functions": 21, "total_units": 1}, "mine": 114, "positional": 22, "strict_diffs": 22, "structural": 0, "target": 114} +AOSS_81401778 entry: {"deficit": 2, "fuzzy": 91.83883, "measures": {"fuzzy_match_percent": 96.50445, "matched_code": "6436", "matched_code_percent": 39.748024, "matched_data": "3896", "matched_data_percent": 99.18533, "matched_functions": 16, "matched_functions_percent": 76.190475, "total_code": "16192", "total_data": "3928", "total_functions": 21, "total_units": 1}, "mine": 271, "positional": 254, "strict_diffs": 252, "structural": 39, "target": 273} +AOSS_81401E80 entry: {"deficit": 0, "fuzzy": 98.605446, "measures": {"fuzzy_match_percent": 96.50445, "matched_code": "6436", "matched_code_percent": 39.748024, "matched_data": "3896", "matched_data_percent": 99.18533, "matched_functions": 16, "matched_functions_percent": 76.190475, "total_code": "16192", "total_data": "3928", "total_functions": 21, "total_units": 1}, "mine": 147, "positional": 34, "strict_diffs": 36, "structural": 0, "target": 147} +libs/RVLMiddleware/eZiText/src/clib/zi8alpha entry measures: {"fuzzy_match_percent": 93.149185, "matched_code": "5704", "matched_code_percent": 26.329395, "matched_data": "72", "matched_data_percent": 12.765958, "matched_functions": 10, "matched_functions_percent": 83.33333, "total_code": "21664", "total_data": "564", "total_functions": 12, "total_units": 1} +Zi8ChangeWordCase entry: {"deficit": 0, "fuzzy": 99.09091, "measures": {"fuzzy_match_percent": 93.149185, "matched_code": "5704", "matched_code_percent": 26.329395, "matched_data": "72", "matched_data_percent": 12.765958, "matched_functions": 10, "matched_functions_percent": 83.33333, "total_code": "21664", "total_data": "564", "total_functions": 12, "total_units": 1}, "mine": 44, "positional": 8, "strict_diffs": 8, "structural": 0, "target": 44} +Zi8AlphaGetCandidates entry: {"deficit": 1, "fuzzy": 90.6072, "measures": {"fuzzy_match_percent": 93.149185, "matched_code": "5704", "matched_code_percent": 26.329395, "matched_data": "72", "matched_data_percent": 12.765958, "matched_functions": 10, "matched_functions_percent": 83.33333, "total_code": "21664", "total_data": "564", "total_functions": 12, "total_units": 1}, "mine": 3945, "positional": 3809, "strict_diffs": 3808, "structural": 1228, "target": 3946} +- AOSS_Init_old init.split.default.waits: recover independent constant connection and response defaults. Deficit 8 -> 9; fuzzy 93.14899 -> 93.15278; structural 1151 -> 1144; positional 1479 -> 1353. Restored. +- AOSS_Init_old init.defaults.store.order: store the connection default before loading the response default. Deficit 8 -> 8; fuzzy 93.14899 -> 93.14899; structural 1151 -> 1151; positional 1479 -> 1479. Restored. +- AOSS_Init_old init.defaults.direct.fields: initialize default wait fields directly from their constant array. Deficit 8 -> 8; fuzzy 93.14899 -> 93.14899; structural 1151 -> 1151; positional 1479 -> 1479. Restored. +- AOSS_Init_old init.flags.word.capture: load the unsigned input flag word once for publication and enable validation. Deficit 8 -> 9; fuzzy 93.14899 -> 93.443184; structural 1151 -> 1144; positional 1479 -> 1301. Kept, full GATE PASS. +- AOSS_Init_old init.link.retry.counter: keep initial link attempts separate from the response sleep countdown as target r18 and r17 show. Deficit 9 -> 9; fuzzy 93.443184 -> 93.61048; structural 1144 -> 1143; positional 1301 -> 1301. Kept, full GATE PASS. +- AOSS_Init_old init.link.delay.after.success: read the response delay only after rejecting a successful initial connection. Deficit 9 -> 9; fuzzy 93.61048 -> 93.64836; structural 1143 -> 1141; positional 1301 -> 1302. Kept, full GATE PASS. +- AOSS_Init_old init.link.status.unsigned: compare the initial configuration status as the unsigned target word. Deficit 9 -> 9; fuzzy 93.64836 -> 93.65467; structural 1141 -> 1140; positional 1302 -> 1302. Kept, full GATE PASS. +- AOSS_Init_old init.scan.separate.delay: use a scan-local countdown rather than extending the link countdown lifetime. Deficit 9 -> 9; fuzzy 93.65467 -> 93.65467; structural 1140 -> 1140; positional 1302 -> 1302. Restored. +- AOSS_Init_old init.protocol.distinct.state: retain protocol progress from entry separately from scan and cleanup results. Deficit 9 -> 9; fuzzy 93.65467 -> 93.78725; structural 1140 -> 1141; positional 1302 -> 1524. Kept, full GATE PASS. +- AOSS_81400830 decrypt.checksum.byte: keep the packet checksum in its actual byte width. Deficit 0 -> 0; fuzzy 97.74143 -> 97.74143; structural 0 -> 0; positional 87 -> 87. Restored. +- AOSS_81400830 decrypt.state.byte.values: retain permutation values as bytes instead of promoted words. Deficit 0 -> 0; fuzzy 97.74143 -> 97.74143; structural 0 -> 0; positional 87 -> 87. Restored. +- AOSS_81400830 decrypt.state.store.order: store the swapped permutation bytes before updating its cursor fields. Deficit 0 -> 0; fuzzy 97.74143 -> 91.94704; structural 0 -> 23; positional 87 -> 95. Restored. +- AOSS_81400830 decrypt.declarations.search: automatic detection selected a call site, not the function. No trials ran; excluded. +- AOSS_81400830 decrypt.declarations.search.valid: AOSSEncryptedPayload* encrypted = &message->payload.encrypted; u8* decryptedData; u32 controlFlags; u32 dataLength; u32 i; s32 crcIndex; u32 firstIndex; u32 secondIndex; u32 firstValue; u32 secondValue; u32 stateIndex; u32 crc; const u8* inputCursor; u8* state; u8* outputCursor; int result; start (0, 87) best (0, 87) after 120 builds; source restored; best order was: u32 checksum; u8 manufacturerAddress[8]; AOSSKeySchedule schedule; AOSSEncryptedPayload* encrypted = &message->payload.encrypted; u8* decryptedData; u32 controlFlags; u32 dataLength; u32 i; s32 crcIndex; u32 firstIndex; u32 secondIndex; u32 firstValue; u32 secondValue; u32 stateIndex; u32 crc; const u8* inputCursor; u8* state; u8* outputCursor; int result; +- AOSS_814013AC options.same.cursor: advance one response cursor from the outer record through the nested option records. Deficit 0 -> 0; fuzzy 98.77193 -> 96.18421; structural 0 -> 2; positional 22 -> 38. Restored. +- AOSS_814013AC options.formal.cursor: advance the input response pointer through outer and nested records. Deficit 0 -> 0; fuzzy 98.77193 -> 95.08772; structural 0 -> 5; positional 22 -> 28. Restored. +- AOSS_814013AC options.length.declaration.first: declare the response-length capture before the accumulated option flags. Deficit 0 -> 0; fuzzy 98.77193 -> 98.070175; structural 0 -> 0; positional 22 -> 33. Restored. +- AOSS_814013AC options.selected.state: capture the selected response state before response-length validation. Build rejected; restored. ne 77, in main output = import_d_file(args.d_file) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/mnt/drive2/projects/wii-ipl-workers/w0929-fix-board/tools/transform_dep.py", line 31, in import_d_file with open(in_file) as file: ^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'build/43U/src/src/scene/setting/AOSS.d' ninja: build stopped: subcommand failed. +- AOSS_814013AC options.declarations.search: Option* responseRecord; AOSSConfigRecord* configRecord; AOSSStoredConfig* wep40Config; AOSSStoredConfig* wep104Config; AOSSStoredConfig* tkipConfig; AOSSStoredConfig* aesConfig; u8* networkSettings; const AOSSReplyOption* option; u32 length; s32 remainingLength = responseLength; int result; start (0, 22) best (0, 22) after 130 builds; source restored; best order was: u32 flags = 0; const AOSSReplyOption* responseRecord; AOSSConfigRecord* configRecord; AOSSStoredConfig* wep40Config; AOSSStoredConfig* wep104Config; AOSSStoredConfig* tkipConfig; AOSSStoredConfig* aesConfig; u8* networkSettings; const AOSSReplyOption* option; u32 length; s32 remainingLength = responseLength; int result; +- Correction: options.selected.state above overlapped a pending declaration sweep, causing a missing dependency file. Excluded; source was restored to the committed state. The sweep found no better candidate and is advisory. Retry below is exclusive. +- AOSS_814013AC options.selected.state.retry: capture the selected state before validating the response length. Deficit 0 -> 0; fuzzy 98.77193 -> 98.77193; structural 0 -> 0; positional 22 -> 22. Restored. +- AOSS_81401778 hello.crc.flat.record: traverse the complete hello record in a single byte loop. Deficit 2 -> 3; fuzzy 91.83883 -> 86.67033; structural 39 -> 49; positional 254 -> 266. Restored. +- AOSS_81401778 hello.crc.explicit.pairs: process the two bytes of each protocol halfword directly. Deficit 2 -> 3; fuzzy 91.83883 -> 86.67033; structural 39 -> 49; positional 254 -> 266. Restored. +- AOSS_81401778 hello.crc.byte.cursor: traverse the record with a byte cursor while retaining the same CRC recurrence. Deficit 2 -> 3; fuzzy 91.83883 -> 84.509155; structural 39 -> 51; positional 254 -> 257. Restored. +- AOSS_81401778 hello.construction.state: keep the destination, hello record, identity and cipher schedule together as packet construction state. Deficit 2 -> 2; fuzzy 91.83883 -> 92.190475; structural 39 -> 33; positional 254 -> 254. Kept, full GATE PASS. +- AOSS_81401E80 cipher.mask.byte.result: retain the input and key bytes separately and publish their xor through the key value. Deficit 0 -> 0; fuzzy 98.605446 -> 97.517006; structural 0 -> 0; positional 34 -> 52. Restored. +- AOSS_81401E80 cipher.direct.packet.xor: publish the packet and key xor directly without a reassigned byte local. Deficit 0 -> 0; fuzzy 98.605446 -> 98.5034; structural 0 -> 0; positional 34 -> 37. Restored. +- AOSS_81401E80 cipher.mask.compound.result: retain both bytes and xor the packet into the key byte before publishing it. Deficit 0 -> 0; fuzzy 98.605446 -> 98.57143; structural 0 -> 0; positional 34 -> 29. Restored. +- AOSS_81401778 hello.runtime.external.binding: recover a separate runtime object address instead of the common private BSS base. Deficit 2 -> 2; fuzzy 92.190475 -> 92.190475; structural 33 -> 33; positional 254 -> 254. Restored. +- AOSS_81401E80 cipher.declarations.search: declaration block: u8* temporaryHalf; s32 halfLength = length / 2; u8* packetHalf; s32 round; u8* keyMask; u8* temporary; s32 keyIndex; s32 index; int result = -1; u8* packetBytes; start (0, 34) best (0, 34) after 118 builds; source restored; best order was: u8* temporaryHalf; s32 halfLength = length / 2; u8* packetHalf; s32 round; u8* keyMask; u8* temporary; s32 keyIndex; s32 index; int result = -1; u8* packetBytes; +- Zi8ChangeWordCase wordcase.work.typed.formal: use the recovered workspace structure type for the word-case argument. Deficit 0 -> 0; fuzzy 99.09091 -> 98.52273; structural 0 -> 0; positional 8 -> 11. Restored. +- Zi8ChangeWordCase wordcase.work.field.view: use a typed workspace view for both mode reads while preserving helper arguments. Deficit 0 -> 3; fuzzy 99.09091 -> 84.318184; structural 0 -> 8; positional 8 -> 41. Restored. +- Zi8ChangeWordCase wordcase.selector.signed.byte: retain the case selector as a signed byte with its actual zero/one values. Deficit 0 -> 0; fuzzy 99.09091 -> 99.09091; structural 0 -> 0; positional 8 -> 8. Restored. +- Zi8AlphaGetCandidates alpha.work.typed.argument: use the recovered workspace structure directly as the formal argument. Deficit 1 -> 1; fuzzy 90.6072 -> 89.9521; structural 1228 -> 1228; positional 3809 -> 3825. Restored. +- Zi8AlphaGetCandidates alpha.context.mask.byte: test the primary context-table flag through its low byte. Deficit 1 -> 1; fuzzy 90.6072 -> 90.60593; structural 1228 -> 1229; positional 3809 -> 3809. Restored. +- Zi8AlphaGetCandidates alpha.normalize.post.increment: express normalization cursor advancement with the native postfix loop update. Deficit 1 -> 1; fuzzy 90.6072 -> 90.6072; structural 1228 -> 1228; positional 3809 -> 3809. Restored. +- Zi8AlphaGetCandidates alpha.prefix.next.dictionary.switch: dispatch next-dictionary punctuation recovery with its recovered case range. Deficit 1 -> -1; fuzzy 90.6072 -> 90.571465; structural 1228 -> 1220; positional 3809 -> 3812. Restored. +- Zi8AlphaGetCandidates alpha.suffix.next.dictionary.switch: dispatch the suffix punctuation fallback through the five supported dictionary kinds. Deficit 1 -> 1; fuzzy 90.6072 -> 90.57425; structural 1228 -> 1228; positional 3809 -> 3809. Restored. +- Zi8ChangeWordCase wordcase.typed.call.workspace: use the recovered case workspace for both field reads and helper calls. Deficit 0 -> -1; fuzzy 99.09091 -> 95.0; structural 0 -> 2; positional 8 -> 37. Restored. +- Zi8AlphaGetCandidates alpha.limit.sum.first: evaluate the candidate length before the maximum word length at both truncation and rejection checks. Deficit 1 -> 1; fuzzy 90.6072 -> 90.6072; structural 1228 -> 1225; positional 3809 -> 3810. Restored. +- Zi8AlphaGetCandidates alpha.truncate.sum.first: evaluate the candidate length before the truncation limit, matching the target compare and skip branch. Deficit 1 -> 1; fuzzy 90.6072 -> 90.56893; structural 1228 -> 1223; positional 3809 -> 3810. Restored. +- Zi8AlphaGetCandidates alpha.keylayout.advance.first: put the shorter key-layout entry advance before the terminal entry branch. Deficit 1 -> 0; fuzzy 90.6072 -> 90.94526; structural 1228 -> 1184; positional 3809 -> 3735. Restored. +- Correction: alpha.keylayout.advance.first increased matched data 72 -> 180; a string-valued byte comparison incorrectly rejected it. Retrying with numeric comparisons. +- Zi8AlphaGetCandidates alpha.keylayout.advance.first.retry: put the shorter key-layout entry advance before the terminal entry branch. Deficit 1 -> 0; fuzzy 90.6072 -> 90.94526; structural 1228 -> 1184; positional 3809 -> 3735. Kept, full GATE PASS. +- Zi8AlphaGetCandidates alpha.skip.candidate.first: advance the skipped-candidate count before handling emitted candidates, matching the target entry branch. Deficit 0 -> 0; fuzzy 90.94526 -> 90.835785; structural 1184 -> 1263; positional 3735 -> 3675. Restored. +- Zi8AlphaGetCandidates alpha.remembered.copy.first: place the exact remembered-word copy before the inexact invalidation fallback. Deficit 0 -> 0; fuzzy 90.94526 -> 91.81044; structural 1184 -> 1142; positional 3735 -> 3739. Kept, full GATE PASS. +- Zi8AlphaGetCandidates alpha.shortest.bound.first: load the current shortest-word bound before comparing the candidate length. Deficit 0 -> 0; fuzzy 91.81044 -> 91.88672; structural 1142 -> 1143; positional 3739 -> 3739. Kept, full GATE PASS. +- Zi8AlphaGetCandidates alpha.count.limit.forward: compare the updated result count directly against the configured limit. Deficit 0 -> 0; fuzzy 91.88672 -> 91.88647; structural 1143 -> 1143; positional 3739 -> 3739. Restored. +- Zi8AlphaGetCandidates alpha.single.punctuation.first: clear single-character state for punctuation before storing an ordinary character. Deficit 0 -> 0; fuzzy 91.88672 -> 92.01039; structural 1143 -> 1135; positional 3739 -> 3739. Kept, full GATE PASS. + +## Final attempt coverage and remaining evidence +AOSS_Init_old: 9 distinct completed trials; instruction deficit 9; fuzzy 93.14899 -> 93.78725; ctxdiff reports 1515 positional differences. +AOSS_81400830: 3 distinct completed trials; instruction deficit 0; fuzzy 97.74143 -> 97.74143; ctxdiff reports 89 positional differences. +AOSS_814013AC: 4 distinct completed trials; instruction deficit 0; fuzzy 98.77193 -> 98.77193; ctxdiff reports 22 positional differences. +AOSS_81401778: 5 distinct completed trials; instruction deficit 2; fuzzy 91.83883 -> 92.190475; ctxdiff reports 252 positional differences. +AOSS_81401E80: 3 distinct completed trials; instruction deficit 0; fuzzy 98.605446 -> 98.605446; ctxdiff reports 36 positional differences. +Zi8ChangeWordCase: 4 distinct completed trials; instruction deficit 0; fuzzy 99.09091 -> 99.09091; ctxdiff reports 8 positional differences. +Zi8AlphaGetCandidates: 13 distinct completed trials; instruction deficit 0; fuzzy 90.6072 -> 92.01039; ctxdiff reports 3739 positional differences. +AOSS_Init_old: target has independent constant halfword relocations, a negative r14 guard before a defined assignment, additional cleanup, and scheduling differences. Constant folding of independent scalars reduced matched data; no uninitialized guard was introduced. +AOSS_81400830/AOSS_814013AC/AOSS_81401E80: target instruction counts and non-register streams agree; three real source variants plus bounded declaration searches found no improvement. Register differences remain 87/22/34. +AOSS_81401778: real packet construction state now has the target stack offsets. A common BSS address, CRC scheduling and the r24-versus-r25 saved range still differ; target 273, build 271 instructions. +Zi8ChangeWordCase: target work r30/case r29 remain exchanged with build work r29/case r30; eight positional register differences, no non-register difference. +Zi8AlphaGetCandidates: entry target stores work at +0x20 without any later load; no dead spill or placeholder was added. Scalar slots remain four bytes low. The target skips an initial dictionary-index assignment, but early completion uses the index, so initialized storage was preserved. Other call-result moves, dispatch branches and retry regions still differ. Both instruction totals now equal 3946. +No new exact function was obtained; the higher instruction-exact-count acceptance condition remains unmet. All seven objdiff-unmatched functions have at least three distinct completed source trials. Retained source changes each passed the full gate and were committed individually. +Final full gate: clean 43U build passed; main.dol SHA1 26116613f624061ba99c8d1a299aaa6efa85670d; both pools identical; regressions/forbidden/readability counts all zero. Complete output: fix-board-r4.final-gate.txt. +Instruction-exact counts AOSS 15/21 -> 15/21, zi8alpha 10/12 -> 10/12. Objdiff exact functions AOSS 16/21 -> 16/21, zi8alpha 10/12 -> 10/12. Matched code AOSS 6436 -> 6436, zi8alpha 5704 -> 5704; matched data AOSS 3896 -> 3896, zi8alpha 72 -> 180. +Instruction deficits at entry -> final: Init 8 -> 9; Decrypt 0 -> 0; Options 0 -> 0; Hello 2 -> 2; Cipher 0 -> 0; WordCase 0 -> 0; Candidates 1 -> 0. The gate strict-count difference from objdiff for AOSS_81400E0C remains its CR1 branch normalization limitation; objdiff reports 100.0. +Source review: only AOSS_Init_old, AOSS_81401778 and Zi8AlphaGetCandidates changed. No new comments, raw-offset field accesses, assembly, uninitialized locals, hand-placed data, configuration edits, external mutations or other translation-unit changes. Final git diff --check passed after trimming log whitespace. diff --git a/tools/decomp-assist/fix-board-r4.final-gate.txt b/tools/decomp-assist/fix-board-r4.final-gate.txt new file mode 100644 index 00000000..e17b12fe --- /dev/null +++ b/tools/decomp-assist/fix-board-r4.final-gate.txt @@ -0,0 +1,36 @@ +full build: ok +main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d +[src/scene/setting/AOSS] pool: IDENTICAL +[src/scene/setting/AOSS] objdiff: code 6436/16192 data 3896/3928 functions 16/21 fuzzy 96.7779 linked code 0 +[src/scene/setting/AOSS] instruction-exact functions: 15/21 +[src/scene/setting/AOSS] section .bss size 3496 match 100.0 +[src/scene/setting/AOSS] section .data size 368 match 100.0 +[src/scene/setting/AOSS] section .sbss size 32 match 42.857143 +[src/scene/setting/AOSS] section .sdata size 24 match 100.0 +[src/scene/setting/AOSS] section .sdata2 size 8 match 100.0 +[src/scene/setting/AOSS] section .text size 16192 match 96.777916 +[src/scene/setting/AOSS] below 100: AOSS_Init_old 93.78725 +[src/scene/setting/AOSS] below 100: AOSS_81400830 97.74143 +[src/scene/setting/AOSS] below 100: AOSS_814013AC 98.77193 +[src/scene/setting/AOSS] below 100: AOSS_81401778 92.190475 +[src/scene/setting/AOSS] below 100: AOSS_81401E80 98.605446 +[src/scene/setting/AOSS] baseline: code 6436/16192 data 3896 functions 16 fuzzy 96.5045 +[libs/RVLMiddleware/eZiText/src/clib/zi8alpha] pool: IDENTICAL +[libs/RVLMiddleware/eZiText/src/clib/zi8alpha] objdiff: code 5704/21664 data 180/564 functions 10/12 fuzzy 94.1715 linked code 0 +[libs/RVLMiddleware/eZiText/src/clib/zi8alpha] instruction-exact functions: 10/12 +[libs/RVLMiddleware/eZiText/src/clib/zi8alpha] section .data size 48 match None +[libs/RVLMiddleware/eZiText/src/clib/zi8alpha] section .rodata size 336 match 99.0991 +[libs/RVLMiddleware/eZiText/src/clib/zi8alpha] section .text size 21664 match 94.17153 +[libs/RVLMiddleware/eZiText/src/clib/zi8alpha] section extab size 72 match 100.0 +[libs/RVLMiddleware/eZiText/src/clib/zi8alpha] section extabindex size 108 match 100.0 +[libs/RVLMiddleware/eZiText/src/clib/zi8alpha] below 100: Zi8ChangeWordCase 99.09091 +[libs/RVLMiddleware/eZiText/src/clib/zi8alpha] below 100: Zi8AlphaGetCandidates 92.01039 +[libs/RVLMiddleware/eZiText/src/clib/zi8alpha] baseline: code 5704/21664 data 72 functions 10 fuzzy 93.1492 +regressions vs baseline: 0 +global matched_code_percent: 86.68724 -> 86.68724 +global fuzzy_match_percent: 99.30809 -> 99.31698 +global complete_code_percent: 60.61288 -> 60.61288 +global matched_data_percent: 91.11031 -> 91.11620 +forbidden patterns added (net, per file): 0 +readability warnings (net, per file; must be 0 in the final result): 0 +GATE PASS -- 2.49.1