Compare commits
1 Commits
cleanup/ip
...
agent/w092
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38117e48f7 |
@@ -53,9 +53,9 @@ Progress
|
||||
<!-- progress:start -->
|
||||
| Decompiled | Matched | Linked | Data |
|
||||
|:---:|:---:|:---:|:---:|
|
||||
| 85.47% | 75.70% | 56.76% | 86.72% |
|
||||
| 85.47% | 75.72% | 56.76% | 86.72% |
|
||||
|
||||
units 748/1027 complete, functions 11024/12563 matched.
|
||||
units 748/1027 complete, functions 11027/12563 matched.
|
||||
|
||||
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
|
||||
<!-- progress:end -->
|
||||
|
||||
@@ -22,13 +22,12 @@ namespace input {
|
||||
HKBManager HKBManager::sInstance;
|
||||
|
||||
// KBD callbacks encode the device in the first byte of the opaque pointer value.
|
||||
union LedCallbackData {
|
||||
void* pointer;
|
||||
u8 device;
|
||||
struct {
|
||||
struct LedCallbackData {
|
||||
union {
|
||||
void* pointer;
|
||||
u8 device;
|
||||
u32 leds;
|
||||
} request;
|
||||
};
|
||||
u32 leds;
|
||||
};
|
||||
|
||||
void HKBManager::SetLedCB(_KBDEc result, void* userData) {
|
||||
@@ -36,9 +35,8 @@ void HKBManager::SetLedCB(_KBDEc result, void* userData) {
|
||||
LedCallbackData received;
|
||||
received.pointer = userData;
|
||||
LedCallbackData callback;
|
||||
callback.request.device = received.device;
|
||||
callback.request.leds = 0;
|
||||
const u8 leds = callback.request.leds;
|
||||
callback.device = received.device;
|
||||
const u8 leds = callback.leds = 0;
|
||||
u32 interrupts = OSDisableInterrupts();
|
||||
u32 mask = 1 << received.device;
|
||||
sInstance.retryDevices &= ~mask;
|
||||
@@ -59,9 +57,8 @@ void HKBManager::KBDListenerOwn::OnAttach(KBDDevEvent* event) {
|
||||
device = event->device;
|
||||
owner = manager;
|
||||
LedCallbackData callback;
|
||||
callback.request.device = device;
|
||||
callback.request.leds = 0;
|
||||
const u8 leds = callback.request.leds;
|
||||
callback.device = device;
|
||||
const u8 leds = callback.leds = 0;
|
||||
u32 interrupts = OSDisableInterrupts();
|
||||
u32 mask = 1 << device;
|
||||
owner->retryDevices &= ~mask;
|
||||
@@ -244,9 +241,8 @@ void HKBManager::Update() {
|
||||
mask = 1 << shiftIndex;
|
||||
if ((retryDevices & mask) != 0) {
|
||||
LedCallbackData callback;
|
||||
callback.request.device = static_cast<u8>(device);
|
||||
callback.request.leds = 0;
|
||||
const u8 leds = callback.request.leds;
|
||||
callback.device = static_cast<u8>(device);
|
||||
const u8 leds = callback.leds = 0;
|
||||
u32 interrupts = OSDisableInterrupts();
|
||||
retryDevices &= ~mask;
|
||||
OSRestoreInterrupts(interrupts);
|
||||
@@ -329,22 +325,10 @@ void HKBManager::KeyState_::Update() {
|
||||
u32 interrupts = OSDisableInterrupts();
|
||||
previous = current;
|
||||
current = pending;
|
||||
previousKeys[0] = currentKeys[0];
|
||||
currentKeys[0] = pendingKeys[0];
|
||||
previousKeys[1] = currentKeys[1];
|
||||
currentKeys[1] = pendingKeys[1];
|
||||
previousKeys[2] = currentKeys[2];
|
||||
currentKeys[2] = pendingKeys[2];
|
||||
previousKeys[3] = currentKeys[3];
|
||||
currentKeys[3] = pendingKeys[3];
|
||||
previousKeys[4] = currentKeys[4];
|
||||
currentKeys[4] = pendingKeys[4];
|
||||
previousKeys[5] = currentKeys[5];
|
||||
currentKeys[5] = pendingKeys[5];
|
||||
previousKeys[6] = currentKeys[6];
|
||||
currentKeys[6] = pendingKeys[6];
|
||||
previousKeys[7] = currentKeys[7];
|
||||
currentKeys[7] = pendingKeys[7];
|
||||
for (u32 slot = 0; slot < 8; slot++) {
|
||||
previousKeys[slot] = currentKeys[slot];
|
||||
currentKeys[slot] = pendingKeys[slot];
|
||||
}
|
||||
OSRestoreInterrupts(interrupts);
|
||||
UpdateModState_();
|
||||
u32 bit;
|
||||
@@ -448,8 +432,8 @@ u8 HKBManager::KeySet::GetKey() const {
|
||||
}
|
||||
|
||||
u32 HKBManager::KeySet::GetWChar() const {
|
||||
u32 code = GetVCode();
|
||||
if ((code & 0xffff) >= 0xf130 && (code & 0xffff) <= 0xf139) {
|
||||
s32 code = GetVCode();
|
||||
if (static_cast<u16>(code) >= 0xf130 && static_cast<u16>(code) <= 0xf139) {
|
||||
code = code - 0xf100 & 0xffff;
|
||||
} else {
|
||||
u32 lowCode = code & 0xffff;
|
||||
@@ -457,24 +441,25 @@ u32 HKBManager::KeySet::GetWChar() const {
|
||||
code = 0xf1cd;
|
||||
} else if (lowCode >= 0xf100 && lowCode <= 0xf13f) {
|
||||
code = code - 0xf100 & 0xffff;
|
||||
} else if ((code & 0xffff) >= 0xf140 && (code & 0xffff) <= 0xf17f) {
|
||||
} else if ((static_cast<u32>(code) & 0xffff) >= 0xf140 && (static_cast<u32>(code) & 0xffff) <= 0xf17f) {
|
||||
code = code + 0x40 & 0xffff;
|
||||
}
|
||||
}
|
||||
u16 character = code;
|
||||
if ((character & 0xf000) == 0xf000) {
|
||||
code = 0;
|
||||
} else if ((code & 0xffff) == 0xeeee) {
|
||||
} else if ((static_cast<u32>(code) & 0xffff) == 0xeeee) {
|
||||
code = 0;
|
||||
} else if ((code & 0xffff) < 0x20) {
|
||||
} else if ((static_cast<u32>(code) & 0xffff) < 0x20) {
|
||||
code = 0;
|
||||
}
|
||||
u32 index = 0;
|
||||
const HKBManager* owner = manager;
|
||||
if (owner->allowedCharacters == 0) return code;
|
||||
u32 count = owner->allowedCharacterCount;
|
||||
if (count == 0) return code;
|
||||
for (u32 index = 0; index < count; index++) {
|
||||
if ((code & 0xffff) == owner->allowedCharacters[index]) return code;
|
||||
for (; index < count; index++) {
|
||||
if ((static_cast<u32>(code) & 0xffff) == owner->allowedCharacters[index]) return code;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ The pool is empty and identical from the first object build. All fields and
|
||||
calls use typed keyboard declarations. Only TIHKBMANAGER_IMPLEMENTATION selects
|
||||
the added layouts; existing keyboard guard branches remain unchanged.
|
||||
|
||||
## Remaining functions, in object order
|
||||
## First pass attempts, in object order
|
||||
|
||||
### SetLedCB
|
||||
1. Initialized pointer union followed by device byte: 41/41 instructions,
|
||||
@@ -76,7 +76,7 @@ the added layouts; existing keyboard guard branches remain unchanged.
|
||||
5. Inline the same CheckValidity helper used by GetKey/GetVCode:
|
||||
70/70, 12 differences, retained. Index/device registers are exchanged.
|
||||
|
||||
## Exact functions
|
||||
## First pass exact functions
|
||||
|
||||
All other functions are C++ and instruction-exact. Important successful
|
||||
changes: sequential Clear stores; callback traversal compares its next node
|
||||
@@ -104,3 +104,73 @@ Changed files:
|
||||
- include/keyboard/tiHKBManager.h
|
||||
- libs/RVL_SDK/include/revolution/kbd.h
|
||||
- tools/decomp-assist/tiHKBManager.attempts.md
|
||||
|
||||
## Continuation at 21/29 exact
|
||||
|
||||
Baseline code 3664/6116, data 292/292. The empty string pool remains identical.
|
||||
The five still-open functions were visited closest first; each has at least
|
||||
three new source variations in this pass.
|
||||
|
||||
### KeyState_::UpdateModState_ — still open
|
||||
1. Signed loop counter: 104/104 instructions, same seven register differences.
|
||||
2. Initialize key mask and widened byte slot in one declaration each:
|
||||
104/104, ten differences.
|
||||
3. Hoist key mask and byte slot outside the loop: 104/104, ten differences.
|
||||
Retained the original seven-difference version.
|
||||
|
||||
### KeySet::IsValid — still open
|
||||
1. Direct validity body with the shifted bit as the left operand:
|
||||
70/70, 18 register differences.
|
||||
2. Declare the signed index before the owner alias: 70/70, 12 differences.
|
||||
3. Widen device/index to signed words and compare device as unsigned:
|
||||
70/70, 14 differences.
|
||||
Retained the shared CheckValidity helper, 12 differences.
|
||||
|
||||
### KBDListenerOwn::OnDetach — still open
|
||||
1. Widen device to u32: 22/22, four register differences, unchanged.
|
||||
2. Inline DetachDevice helper combining attached flag and state clearing:
|
||||
22/22, five differences.
|
||||
3. Name the state reference inside that helper before flag clearing:
|
||||
22/22, six differences.
|
||||
Removed the experimental helper and retained the four-difference version.
|
||||
|
||||
### KeyState_::Update — still open
|
||||
1. Replace the eight explicit key snapshots with a normal loop:
|
||||
183/183, same 44 register differences. Retained for readability.
|
||||
2. Signed event/repeat loop index: 183/183, same 44 differences.
|
||||
3. Local bit temporaries and negated unchanged-key predicates:
|
||||
183/183, 47 differences.
|
||||
|
||||
### KeySet::GetWChar — improved, still open
|
||||
1. Signed virtual code with explicitly unsigned mask comparisons:
|
||||
76/77 instructions, one repeated narrowing still absent.
|
||||
2. Inline normalization helper returning each normalized value:
|
||||
75/77, unchanged from baseline.
|
||||
3. u16 intermediate character and do/while whitelist traversal:
|
||||
74/77, rejected.
|
||||
4. Distinguish the initial 16-bit key range from the signed normalization
|
||||
intermediate and subsequent unsigned masks: 77/77, nine whitelist-loop
|
||||
register differences. Retained.
|
||||
5. Hoist whitelist index declaration: 77/77, unchanged.
|
||||
6. Initialize that index before the owner alias: 77/77, unchanged.
|
||||
7. Signed whitelist index: 77/77, unchanged.
|
||||
8. Count down remaining whitelist entries: 76/77, rejected.
|
||||
9. Unsigned main code and signed normalization intermediate:
|
||||
77/77, same nine differences, rejected in favor of attempt 4.
|
||||
|
||||
### LED operations — three new exact functions
|
||||
1. Widen the asynchronous LED argument and snapshot to u32:
|
||||
SetLedCB 41/41 with two differences, OnAttach 61/61 with three,
|
||||
HKBManager::Update 55/55 with three.
|
||||
2. Move the LED mask outside the opaque-pointer/device union, making the
|
||||
request a struct: identical differences and counts.
|
||||
3. Snapshot the value assigned when clearing the request's LED mask:
|
||||
all three functions reach zero differences.
|
||||
4. Restore the original byte API argument and byte snapshot:
|
||||
all three remain exact, without emitted LED constant objects.
|
||||
The mask field supplies the call argument through the assignment result;
|
||||
there is no separate literal argument or unused request-mask initialization.
|
||||
|
||||
Data sections remain 100%. No shared header changes are retained in this
|
||||
continuation. A quick gate reports 24/29 exact, code 4292/6116,
|
||||
data 292/292, fuzzy 99.7057, and zero regressions or source warnings.
|
||||
|
||||
Reference in New Issue
Block a user