Compare commits

...

90 Commits

Author SHA1 Message Date
Devin AI
cdfa42f57b AOSS_81400830: scoped schedBytes local per PRGA half-iter (326->320/321)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 23:54:43 +00:00
Devin AI
8f546b4127 ATERM_814038C8: single-anchor bss clustering + MD5 digest state-word hoist (979->958/951)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 23:52:49 +00:00
Devin AI
47e2fca14d iplSetting data: sBackgroundColor as GXColor quad, errorFormat[6] sdata tail, sdata2 tail const
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 23:42:51 +00:00
Devin AI
a7959ad5c6 814036D8: switch dispatch on selectedSecurity (123/124)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 23:29:43 +00:00
Devin AI
a01b3eb034 ApConfigStart: range cmp + global-reload args + store order (103/103 insn-equal)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 23:27:44 +00:00
Devin AI
59310eec2e 814021BC: rotated while-loop + memset-first ordering + global-anchor +0 folds (153/154)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 23:25:47 +00:00
Devin AI
5063340c0a 81402FC0: s32 locals + messageType/|| guard clauses + if/else store (132/135)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 23:20:25 +00:00
Devin AI
5f700048d0 match 81403614 (49/49 diffs 0): goto add-blocks + signed /2 idiom
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 23:12:40 +00:00
Devin AI
69575ef7b0 ATERM_814033F0: option-parse loop to insn-equality (137/137)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 23:09:42 +00:00
Devin AI
bce8e09407 ATERM: 81402FC0 loop rotation via if(value!=NULL) + u16 store casts
- checksum decl-init hoists li before SONtoHs calls
- !=/NULL-first if/else matches base's beq+li0 layout
- (u16)SONtoHs cast emits base's clrlwi-at-store
- option loop switch wrapped in if(value!=NULL): produces base's
  r3-sentinel rotated loop (133/135, addic./cmpwi fusion residual tb)

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 23:03:49 +00:00
Devin AI
c0ea9c8b5e ATERM: 814021BC AP-name via (&gNetworkSettings + 1) pointer math
- original references the buffer after the settings struct as
  r30+0x924 anchored on the struct symbol, not via its own
  gAccessPointName symbol (that symbol stays for .bss layout)
- 153/154; residual is fold-vs-materialize store-addressing tb

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 23:00:36 +00:00
Devin AI
da09f7459b ATERM: match 81402424 (210/210 diffs 0)
- scan_failed reached only via goto; re-tests -0x7FFF7FFC and emits
  the dead 'li -6' trampoline on shared dispatch flags
- scanStatus local removed: *scanBuffer load stays in r0

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 22:53:43 +00:00
Devin AI
668abf4b8f ATERM: 8140276C cursor hoisting + temp trimming; 81403614 'G'-split cascade
- hoist previousRecords->entries pointer to fn top like base (172/174)
- drop redundant ssidLength/compareLength/resultIndex temps
- 81403614: nested <'G'/':'/'A'/'g'/'a' cascade matching base's test
  order (45/49; block-placement residual)

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 22:49:41 +00:00
Devin AI
2ca72f20f7 ATERM: 81402A24 alloc guards, MAC-text loop, result-tail layout
- alloc+memset guards as if(p!=NULL)/if(p==NULL) pairs like base
- missing selectedMacText hex loop added (same *next++ idiom),
  selectedMacText[48]
- result tail via goto-found/neg3 label layout matching base's
  ble/-3-then-res block order (262/263; residual spilled-buffer reload)

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 22:44:47 +00:00
Devin AI
0ba7888699 ATERM: fix join alarm to 500ms; decode MAC-text loop in 814031DC
- ATERMi_ApConfigEnd: join alarm duration is reciprocal*500 like base,
  not raw 0x10624DD3 (125/129, residual manual-vs-savegpr)
- ATERM_814031DC: *nextText++ digit stores, *next=0/if(i<5)*next++=':'
  colon logic, textCursor += nextText - textCursor ptr resync, >9 tests,
  stack layout interfaceMac/scanAddress/scanText[32]/macText[24] (133/133
  insn-equal, residual callee window rotation)

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 22:39:36 +00:00
Devin AI
190b11df6b iplSetting: emit .sdata2 color bytes as named u8 globals, un-static browserScrollDirection
- 11 sdata2 u8 objects (black 00,00,00,FF + white FF*4 + fade FF*3) matching
  base's per-byte emission; zero components as const so they stay in .sdata2
- draw builds GXColor via *(GXColor*)&sX like iplSensitivity (lbz/stb per byte)
- browserScrollDirection global (base has a global dword at .sbss+8)
- drop unused statics; all data sections now at 100%

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 22:31:37 +00:00
Devin AI
b946e40dda AOSS_Init_old block-order attempts + iplSensitivity sdata2/dtor emission work
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 20:42:23 +00:00
Devin AI
9f10bd3f0f AOSS_Init_old: frame layout + tautological else-if chains
- Aggregate decl-order + ATTRIBUTE_ALIGN gives trio at 0x30/0x38/0x40
- else if (state != 0) emits base's unreachable else block (chained beq)
- state==0 && (state!=0 || *config==1) gives base's second bne-to-success
- u16 attemptCount

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 16:53:26 +00:00
Devin AI
e21d4626ea iplSetting: fix initScroll pane names, ctor/dtor field order, arrow-name array
- initScroll: case 0 hides N_AP2 not N_ArwB; the two NULL sites are N_ArwB
- replace extern lbl_81697010 shim with real sSettingArrowNames array
- header: mpSettingHTMLFile@0x64, mpWWWArchiveFile@0x68 (was swapped)
- ctor/dtor/createBrowser field-order fixes

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 16:26:08 +00:00
Devin AI
ca8fe833e4 iplSetting scanAP: volatile-receiver materialization for isPlaying
FrameController::isPlaying gains a const-volatile overload; scanAP's three
anim checks use a volatile Animator* receiver, producing the base's
addi/cntlzw/rlwinm./bne sequence instead of the folded cmpwi. The index
load is pulled into a temp so unk_0xB9C's store interleaves as in base.
scanAP is now instruction-equal (272/272) with a 4-insn scheduling
residual in case 9.

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 15:52:07 +00:00
Devin AI
243e914ab0 iplSetting: initKeyboard 100% via TU-variant KeyboardSetting layout; scanAP update() call; errorFormat sdata
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 15:07:35 +00:00
Devin AI
3611c932a1 AOSSLink: restructure WLANGetBSSList rescan/retry blocks (227/227 insn-equal)
- rescan block moved after the alloc+copy path via goto-label (base emits
  count!=0 fallthrough first)
- cleanup/unlock retry loops: while(call != 0) bottom-test form
- alloc NULL checks use == 0 (cmpwi not cmplw)
- remaining: regalloc renames + minor scheduling (tie-break)

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 13:40:00 +00:00
Devin AI
c687c940fa AOSS_Init_old: fix SOPoll timeout math to 64-bit product-first form
- tickRemainder: usecs * (bus>>2) / 1e6 as s64 product (was freq/125000 first,
  which emitted divwu)
- pollSubseconds via % 1000; tail restructured: guarded status=0xf, cfg-free
  under block-local cleanupResult
- remaining: signed /1000 still divw vs base magic-mult; tail else-arm merge;
  interleaved block order + regalloc (tie-break family)

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 13:33:15 +00:00
Devin AI
aa05001ce6 setting: reconstruct iplSensitivity::draw — insn-equal 278/278 (1 layout b)
- mode copied via direct struct assign (word-loop form)
- scissor args: ws=fbWidth/(r-l), hs=efbHeight/(b-t), fw2/fh2 named halves,
  w/h via (ext * 0.5f) recompute to defeat CSE
- GXColor constants via extern __declspec(.sdata2) decls + defs between
  draw and the inlined drawDpdObjects helper (matches base sdata2 emission)
- signed (obj->size + 0x19) cvt, -sy fneg pos forms
- remaining: 1 stray b (block-placement tie-break) + sdata2 intern order

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 13:15:25 +00:00
Devin AI
96b8b71a6d AOSS: reorder AOSS_Init_old error blocks + call order (1578/1584 insns)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 12:15:14 +00:00
Devin AI
cc5048eca1 setting: initScroll exact via lbl_81697010 sdata pane-name table
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 11:42:37 +00:00
Devin AI
0933fb4dab setting: match validateEULA_, prepare, calcNormal; updateScroll insn-equal via extern lbl_81697010 sdata table
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 11:40:48 +00:00
Devin AI
7050f7033e setting: match prepare/calcNormal/validateEULA_ — member order, %s arg, treasure heap, filename log args
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 11:31:19 +00:00
Devin AI
e4632c60d2 setting: match setAPDraw (171/171) — animator reuse, unrolled stops, count-based descriptor offset, u8 getRadioLevel
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 11:26:54 +00:00
Devin AI
5877d598d9 AOSS_Init_old: relocate LAB_00012088 recv block after socket builds (matches base block emission order); config-request loop as bottom-checked while (attemptCount vs connectWait); u32 *config deref
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 11:13:43 +00:00
Devin AI
4c2a6ef4e1 AOSS_Init_old: runtime-state member order (flags@+8), flags!=1 guard inversion, retry-loop restructure (u16 remainingWait, connectWait limit-check, inline cancel-error)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 11:06:21 +00:00
Devin AI
ff7155ea15 ATERM: .bss object order via explicit-zero inits + ATTRIBUTE_ALIGN(32) on gAtermResponseBuffer
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 10:27:39 +00:00
Devin AI
a1ad43a516 setting: setUSBAP volatile-reload idiom -> fn matches (57/57)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 10:20:23 +00:00
Devin AI
b484456d2b setting: iplSetting member-init order fixes + dead-float .sdata2 solve; AOSS ptr-as-int null checks
- iplSetting: swap mpWWWArchiveFile/mpSettingHTMLFile init+dtor order (+0x64 before +0x68) -> __ct__/__dt__ match; dead 'f32 x = 0.0f' init interns missing .sdata2 literal -> updateController_ matches (124/124)
- AOSS: compare pointer globals as (s32) to get per-site cmpwi instead of CSE'd-zero cmplw (49->3 cmplw); standalone tail goto to stop stb-0xf cleanup fusing into SOClose block

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 10:18:41 +00:00
Devin AI
61032b94a8 setting: iplSetting .sdata2/.data/.bss/.rodata byte-identical; iplSensitivity literal fixes; AOSS/ATERM tweaks
- iplSetting: Rect projection(0.0f,...) dead-init interns the missing 0.0f pool slot -> .sdata2 byte-identical; .data/.bss/.rodata already identical; .sdata off by one dead trailing dword
- iplSetting.h: member order swap to match base layout
- iplSetting: createBrowser rework (switch dispatch, 4x3 projection)
- iplSensitivity: -45.0f scale fixes + GXColor const arrays; literal SET now matches base (order still open)
- AOSS: AOSS_Init_old tail SOC cleanup/state expr rework
- ATERM: sAtermOptionName/gAtermProductName const fixes, .bss decl reordering

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 10:05:07 +00:00
Devin AI
679b249d0e ATERM: fix .data/.sdata2 layout — MD5 padding via inlined static helper, option name as 7-byte array
- Extract MD5 finalize block into static AtermMd5Finalize (MWCC fully
  inlines it into ATERM_814038C8); its fn-local static padding lands at
  .data tail 0xd8-0x117 matching orig emission order
- sAtermOptionName: [8] w/ trailing 0 -> [7] (orig emitted 7 bytes + pad)
- Result: .data, .sdata, .sdata2, .rodata all section-exact;
  .bss buffer/thread order + .sbss fuzzy remain open

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 08:48:04 +00:00
Devin AI
9f68f59195 setting: strip shared-header inline bodies in iplSetting TU; AOSSProcess switch dispatch
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 08:19:07 +00:00
Devin AI
a496d77426 setting: AOSS_Init_old - s_errorCode s32 + switch dispatch (insn-identical cascade)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 07:47:58 +00:00
Devin AI
6754dcef5c setting: AOSS_Init_old frame packing - waitSettings last-decl + sdata2 split
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 07:43:52 +00:00
Devin AI
5da9e5abdb setting: move LAB_000126f0 tail block to end of AOSS_Init_old
Base emits the socket-cleanup + error-table + final-call sequence as a
goto target at the tail (0x1948); restructuring source order so it lands
after the do-while region. fuzzy 24 -> 34.

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 06:55:24 +00:00
Devin AI
5eebf39964 setting: optionBuffer points at response buffer; replyLength to sbss tail
Base .sdata+0x28 is a pointer relocated to gAtermResponseBuffer — the
original initializes gAtermOptionBuffer to it (not NULL). .sbss now
matches base layout exactly (0x50, same size sequence); .sdata gains
the reloc'd pointer at 0x28.

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 06:43:54 +00:00
Devin AI
eb50f578f5 setting: ATERM_81405D0C MD5 transform - rotating F args + indexed stores (720/720 insns)
- Fix semantically-wrong round function args: F/G/H/I must rotate with the
  (a,b,c,d) call positions; identical literal args caused ~b CSE -> nor+and
  instead of andc/orc folding
- Pack loop uses words[j++] post-increment -> stwx indexed stores
- Standard non-rotating macro: A = B + rotl(A + F + word + K)
Residual: 715 diffs are scheduling/regalloc renames (equal insn count, tie-break)

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 05:54:47 +00:00
Devin AI
7c7b0569bf setting: AOSS_81400830 guard-family + RC4 restructure (326/321)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 05:37:37 +00:00
Devin AI
79a654a64b setting: ATERM_81405ACC + AOSS_81400E0C structural fixes (insn-equal)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 05:25:27 +00:00
Devin AI
2e8d3579df iplSetting: pad Setting vtable with 37 pure virtuals (unkv_0x68-0xF8)
The original class declares 37 pure virtuals after isResetAcceptable,
emitted as zero vtable slots. Restores .data to 0xfb0 matching base.

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 05:09:01 +00:00
Devin AI
4b035b954b AOSS_Init_old: 32-aligned frame, waitSettings as 8B option union, s16 option reads, restructured tail (1565/1584 insns)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 04:55:28 +00:00
Devin AI
eac956b1b6 AOSS_81401C9C: walking u8* cur pointer — marginally closer regalloc (tie-break)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 04:43:22 +00:00
Devin AI
332f58508f iplSetting draw: fix GXTexObj stack-slot order (declare standardTexture first)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 03:47:37 +00:00
Devin AI
52576c6bc6 iplSetting calcNormal: reorder both switches to base emit order, fix lvalues/casts — 99.99% (2-insn regalloc tie-break)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 03:45:02 +00:00
Devin AI
8e5787f568 setting: sdata pool fixes (L"" literal, errorFormat, dead statics, vtable-order browserScrollDirection)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 03:25:22 +00:00
Devin AI
3e5411f37d ATERM: hex-key decode loop + option-parse while-form + AP-scan clock/divisor reconstruction; AOSS key-schedule leaf body matched
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 00:07:11 +00:00
Devin AI
600048402a ATERM: nibble-decode shape + signed-idiom index math, hex-parse loop guard, record-set header size, bus-clock reciprocal division
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 00:02:00 +00:00
Devin AI
67ba5e3663 ATERM: paired-round AES encrypt/decrypt blocks + inverse key schedule (5254 270/271, 5690 271/271, 0502C 139/138)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 23:52:49 +00:00
Devin AI
3f2af2a919 ATERM 81404BFC: T-table key expansion, xor trees, counter loops (269/268)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 23:46:29 +00:00
Devin AI
f57e48be09 ATERM: reconstruct RFC3394 AES key wrap/unwrap (81404844 insn-equal, 81404A18 near)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 23:38:49 +00:00
Devin AI
728624da2a ATERM_81405ACC/5D0C: loop-bound gates, j-partLen forms, zero-tail unroll (131/144, 672/720)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 23:33:35 +00:00
Devin AI
6deff4fdc0 ATERM_814038C8: full state-machine rewrite (10 cases, digest encode, per-case scoping; 969/951 insns)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 23:27:35 +00:00
Devin AI
a87c7b1ca1 AOSS_81401C9C: schedule->length reload + base swap order (76/73, callee-reg tb)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 22:47:45 +00:00
Devin AI
d506be5a50 AOSS_81401778: s8 active, s32 connState, reserved01 store, double ip store, CRC unroll, s16 len, payload CSE (273/273, pooling tb)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 22:44:21 +00:00
Devin AI
4f449d73be AOSSLink: ==0 ptr checks; rescan-block reorder attempt (tb)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:22:57 +00:00
Devin AI
7f215a6261 AOSSLink WLANGetBSSList: ==0 ptr checks + count==0 block (227/227 tb)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:17:52 +00:00
Devin AI
43f2bc33d8 remove stray empty ctxdiff2.py
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:14 +00:00
Devin AI
9bf797ecc7 ATERM_81403614: >=-tree + indexed dst store + %2 parity (47/49, leaf-shape tb)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:14 +00:00
Devin AI
9b3c98122d ATERM_81402424: scanParameters align, msg/buf decl order, -6 edge block (208/210)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:14 +00:00
Devin AI
ed0a012a22 AOSS.c: roundedLength operand order (01BBC add order tie-break)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:14 +00:00
Devin AI
b00e235438 iplRakuRakuThread: start() alloc hoist + block order (96/96, 1 mr/addi tie-break)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:14 +00:00
Devin AI
f99704f4d0 iplUSBAPThread: Init result temp (32/32, li-schedule tie-break)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:14 +00:00
Devin AI
056ece032e iplSetting: updateScroll fused pre-decrement test (183/179, sdata pooling tie-break)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:14 +00:00
Devin AI
be8eeb9d70 iplSetting: scanAP — literal pane names + if/else anim select (269/272, isPlaying normalize tie-break)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:14 +00:00
Devin AI
508f449ccc iplSetting: exact setInitializeResult (switch on error, literal -2 log arg)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:14 +00:00
Devin AI
9ded6e6496 iplSetting: validateEULA_ 94/94 (shared result var, early valid init)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:14 +00:00
Devin AI
3e3bf3422e iplSetting: exact checkTextNum (switch dispatch + inverted len arms)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:14 +00:00
Devin AI
22e7459a57 iplSetting: exact cancelUSBAP (case order), checkIPString, calcFadeout structure
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:14 +00:00
Devin AI
20bffa1ec2 iplKeyboard: restore KeyboardSetting field order (type@0,rowLimit@0xC) — fixes parentalDialog link
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
861a326a67 iplSetting: exact checkIPString (goto block layout)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
b20a59205a iplSetting: exact calcKeyboard (switch dispatch + case-range filter)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
7dff4b031b setting: initKeyboard decoded (jump table, dict block, KeyboardSetting layout)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
9f06a5bb96 setting: iplSetting — initScroll decoded (N_AP literals, sdata arrow table, fallthrough switch)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
467cc7835f setting: iplSetting — scanAP init() vtbl calls + unk_0xB9C, setAPDraw DynamicCast (169/171 parked)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
847a3f3e7d setting: iplSetting — setUseEULA_ switch, setUSBAP switch (56/57 parked), RakuProcess 100%
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
173e87526a setting: iplSetting — checkIPString dont_inline + if-form, validateEULA_ contentResult init
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
93a4f33eb1 setting: iplSetting — AOSSProcess !=3 order, validateEULA_ !=0 order, setConnectTestResult switch (matched)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
cd13dd9c59 setting: iplSensitivity draw — named sx/sy temps + negated-add form (278/278, scheduling tie-break)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
28f7d5f62a setting: ATERM.c — 5ACC MD5_Update rewrite (AtermMd5Context, x8 unrolled copies)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
51cc6bdba3 setting: AOSS.c — 81400830 RC4+CRC decode (311/321, tie-break parked)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
59a683f651 setting: AOSS.c progress — 814004D0 exact, 1B4/2F0/13AC/1574 structural fixes
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
5b3bd9524e setting: AOSSLink.c 12/14 fns exact + data matched (GetBSSList/Connect regalloc tie-breaks)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
3a5249d356 setting: iplRakuRakuThread 12/14 fns exact + all data (start/finish regalloc tie-breaks)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
af48f0a19f wip: USBAP/USBAPThread/Sensitivity partial matches (regalloc tie-breaks)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
Devin AI
dd74a9d314 match iplAOSSThread.cpp (10/10 fns, 100% code+data)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 21:14:13 +00:00
21 changed files with 4324 additions and 2099 deletions

View File

@@ -5126,8 +5126,8 @@ __ct__Q33ipl5scene10AOSSThreadFPQ23EGG4Heap = .text:0x813FCA0C; // type:function
destroy__Q33ipl5scene10AOSSThreadFi = .text:0x813FCAA0; // type:function size:0x84
__dt__Q33ipl5scene10AOSSThreadFv = .text:0x813FCB24; // type:function size:0x70
start__Q33ipl5scene10AOSSThreadFv = .text:0x813FCB94; // type:function size:0xF8
AOSSThread_813FCC8C__Q33ipl5scene10AOSSThreadFv = .text:0x813FCC8C; // type:function size:0x58
AOSSThread_813FCCE4__Q33ipl5scene10AOSSThreadFv = .text:0x813FCCE4; // type:function size:0x50
AOSSThread_813FCC8C__Q33ipl5scene10AOSSThreadFUll = .text:0x813FCC8C; // type:function size:0x58
AOSSThread_813FCCE4__Q33ipl5scene10AOSSThreadFUlPvl = .text:0x813FCCE4; // type:function size:0x50
Run__Q33ipl5scene10AOSSThreadFv = .text:0x813FCD34; // type:function size:0xEC
cancel__Q33ipl5scene10AOSSThreadFv = .text:0x813FCE20; // type:function size:0x50
finish__Q33ipl5scene10AOSSThreadFP13NCDAossConfigPi = .text:0x813FCE70; // type:function size:0x2FC
@@ -5146,7 +5146,7 @@ AOSSi_WLANConnect = .text:0x813FD72C; // type:function size:0x26C
AOSSi_Sleep = .text:0x813FD998; // type:function size:0x4
AOSSi_Status = .text:0x813FD99C; // type:function size:0x34
AOSS_SetCallback = .text:0x813FD9D0; // type:function size:0x34
RakuRakuThread_813FDA04__Q33ipl5scene14RakuRakuThreadFv = .text:0x813FDA04; // type:function size:0x6C scope:local
RakuRakuThread_813FDA04__Q33ipl5scene14RakuRakuThreadFPUl = .text:0x813FDA04; // type:function size:0x6C scope:local
__ct__Q33ipl5scene14RakuRakuThreadFPQ23EGG4Heap = .text:0x813FDA70; // type:function size:0xD8
__dt__Q33ipl5scene14RakuRakuThreadFv = .text:0x813FDB48; // type:function size:0xA4
destroy__Q33ipl5scene14RakuRakuThreadFv = .text:0x813FDBEC; // type:function size:0xD8
@@ -17078,7 +17078,7 @@ lbl_81657B18 = .data:0x81657B18; // type:object size:0x1A data:string
lbl_81657B32 = .data:0x81657B32; // type:object size:0x18 data:string
lbl_81657B4A = .data:0x81657B4A; // type:object size:0x16 data:string
__vt__Q33ipl5scene10AOSSThread = .data:0x81657B60; // type:object size:0x30
lbl_81657B90 = .data:0x81657B90; // type:object size:0x30
sRateTable = .data:0x81657B90; // type:object size:0x30
lbl_81657BC0 = .data:0x81657BC0; // type:object size:0x38 data:string
jumptable_81657BF8 = .data:0x81657BF8; // type:object size:0x20 scope:local
__vt__Q33ipl5scene14RakuRakuThread = .data:0x81657C18; // type:object size:0x30
@@ -23472,14 +23472,14 @@ lbl_81698C28 = .sbss:0x81698C28; // type:object size:0x4 data:4byte
lbl_81698C2C = .sbss:0x81698C2C; // type:object size:0x4 data:4byte
lbl_81698C30 = .sbss:0x81698C30; // type:object size:0x4 data:4byte
AOSSi_cancel_flag = .sbss:0x81698C38; // type:object size:0x4 data:4byte
lbl_81698C3C = .sbss:0x81698C3C; // type:object size:0x4
lbl_81698C40 = .sbss:0x81698C40; // type:object size:0x4
lbl_81698C44 = .sbss:0x81698C44; // type:object size:0x4
lbl_81698C48 = .sbss:0x81698C48; // type:object size:0x4
lbl_81698C4C = .sbss:0x81698C4C; // type:object size:0x4
lbl_81698C50 = .sbss:0x81698C50; // type:object size:0x4 data:4byte
lbl_81698C54 = .sbss:0x81698C54; // type:object size:0x4 data:4byte
lbl_81698C58 = .sbss:0x81698C58; // type:object size:0x4 data:4byte
AOSSi_ipAddr = .sbss:0x81698C3C; // type:object size:0x4
AOSSi_netmask = .sbss:0x81698C40; // type:object size:0x4
AOSSi_gateway = .sbss:0x81698C44; // type:object size:0x4
AOSSi_dns1 = .sbss:0x81698C48; // type:object size:0x4
AOSSi_dns2 = .sbss:0x81698C4C; // type:object size:0x4
AOSSi_alloc = .sbss:0x81698C50; // type:object size:0x4 data:4byte
AOSSi_free = .sbss:0x81698C54; // type:object size:0x4 data:4byte
AOSSi_callback = .sbss:0x81698C58; // type:object size:0x4 data:4byte
lbl_81698C60 = .sbss:0x81698C60; // type:object size:0x4 data:4byte
lbl_81698C64 = .sbss:0x81698C64; // type:object size:0x4 data:4byte
lbl_81698C68 = .sbss:0x81698C68; // type:object size:0x1 data:byte

View File

@@ -93,7 +93,11 @@ namespace textinput {
void initAspect();
#endif
#ifdef IPL_TI_MANAGER_OUT_OF_LINE
virtual void setSecretInputMode(bool secretInputMode);
#else
virtual void setSecretInputMode(bool secretInputMode) { mpInputForm->setSecretModeOn(secretInputMode); }
#endif
#ifdef IPL_ADDRESS_EDIT_CPP
void enableKSXFilter(bool compatibleFilter);
#endif
@@ -106,7 +110,11 @@ namespace textinput {
virtual void start() {}
virtual void end() {}
#ifdef IPL_TI_MANAGER_OUT_OF_LINE
virtual InputForm* getInputForm();
#else
virtual InputForm* getInputForm() { return mpInputForm; }
#endif
virtual const InputForm* getInputForm() const { return mpInputForm; }
virtual keyboard::hwkey::HWKeyboard* getHWKeyboard() { return mpHWKeyboard; }

View File

@@ -55,7 +55,11 @@ namespace textinput {
virtual nw4r::math::VEC2 getScale() const = 0;
#ifdef IPL_TI_TEXTDRAWER_OUT_OF_LINE
virtual void setSecretModeOn(bool secretMode);
#else
virtual void setSecretModeOn(bool secretMode) { mbSecretMode = secretMode; }
#endif
virtual void doBeforeDrawProcess(const wchar_t*, u32, const DrawInfo& drawInfo);
virtual void doAfterDrawProcess(const wchar_t*, u32, const DrawInfo& drawInfo);

View File

@@ -56,10 +56,16 @@ namespace gui {
virtual void onEvent(u32 compId, u32 event, void* data) {} // 0x08 (0x02)
#ifdef IPL_GUI_VIRTS_OUT_OF_LINE
virtual void setManager(Manager* manager); // 0x0C (0x03)
virtual void setLatestEventCtrlNo(int ctrlNo); // 0x10 (0x04)
virtual int getLatestEventCtrlNo(); // 0x14 (0x05)
#else
virtual void setManager(Manager* manager) { mpManager = manager; } // 0x0C (0x03)
virtual void setLatestEventCtrlNo(int ctrlNo) { mLatestCtrlNum = ctrlNo; } // 0x10 (0x04)
virtual int getLatestEventCtrlNo() { return mLatestCtrlNum; } // 0x14 (0x05)
#endif
protected:
Manager* mpManager; // 0x04
@@ -85,7 +91,11 @@ namespace gui {
virtual bool isPointed(int point) { return mbPointed[point]; } // 0x24 (0x09)
virtual bool isDragging(int point) { return mbDragging[point]; } // 0x28 (0x0A)
#ifdef IPL_GUI_VIRTS_OUT_OF_LINE
virtual void setPointed(int point, bool bEnable); // 0x2C (0x0B)
#else
virtual void setPointed(int point, bool bEnable) { mbPointed[point] = bEnable; } // 0x2C (0x0B)
#endif
virtual void onPoint(int point) { mFlightDuration[point] = 0; } // 0x30 (0x0C)
virtual void offPoint(int point) { mFlightDuration[point] = 0; } // 0x34 (0x0D)
@@ -252,7 +262,11 @@ namespace gui {
virtual bool contain(f32 x, f32 y); // 0x68 (0x1A)
virtual void setPane(nw4r::lyt::Pane* pane) { mpPane = pane; } // 0x6C (0x1B)
#ifdef IPL_GUI_VIRTS_OUT_OF_LINE
virtual nw4r::lyt::Pane* getPane(); // 0x70 (0x1C)
#else
virtual nw4r::lyt::Pane* getPane() { return mpPane; } // 0x70 (0x1C)
#endif
private:
nw4r::lyt::Pane* mpPane; // 0x88

View File

@@ -31,6 +31,11 @@ namespace ipl {
virtual void calc();
#ifdef IPL_FADER_SCENE_BASE_VIRTS_OUT_OF_LINE
virtual void initCalcNormal(); // 0x4C
virtual void initCalcFadeout(); // 0x50
virtual void calcCommon(); // 0x54
#else
virtual void initCalcNormal() {
} // 0x4C
virtual void initCalcFadeout() {
@@ -38,6 +43,7 @@ namespace ipl {
virtual void calcCommon() {
} // 0x54
#endif
virtual FaderSceneCommand calcFadein() {
return FADER_SCN_NEXT;
@@ -49,8 +55,12 @@ namespace ipl {
return FADER_SCN_NEXT;
} // 0x60
#ifdef IPL_FADER_SCENE_BASE_VIRTS_OUT_OF_LINE
virtual void calcCommonAfter(); // 0x64
#else
virtual void calcCommonAfter() {
} // 0x64
#endif
int getSceneFadeState() {
return mScnFadeState;

View File

@@ -62,14 +62,26 @@ namespace ipl {
virtual ~Base();
/** @brief If the scene is ready */
#ifdef IPL_SCENE_BASE_VIRTS_OUT_OF_LINE
virtual BOOL isReady() const;
#else
virtual BOOL isReady() const { return FALSE; }
#endif
/** @brief If the user can power off/reset the system */
virtual BOOL isResetAcceptable() const { return TRUE; }
/** @brief The scene running code when powering off/resetting the system */
#ifdef IPL_SCENE_BASE_VIRTS_OUT_OF_LINE
virtual void startResetting();
#else
virtual void startResetting() {}
#endif
/** @brief If the scene has finished its powering off/resetting task */
#ifdef IPL_SCENE_BASE_VIRTS_OUT_OF_LINE
virtual BOOL isResetProcessDone();
#else
virtual BOOL isResetProcessDone() { return TRUE; }
#endif
/** @brief Prepare to create scene */
virtual void prepare() {}
@@ -82,10 +94,17 @@ namespace ipl {
/** @brief Destroy the scene and clear from memory */
virtual void destroy() {}
#ifdef IPL_SCENE_BASE_VIRTS_OUT_OF_LINE
virtual Base* getParent();
virtual Base* getChild();
virtual Base* getNext();
virtual Base* getPrev();
#else
virtual Base* getParent() { return (Base*)mpParent; }
virtual Base* getChild() { return (Base*)mpChild; }
virtual Base* getNext() { return (Base*)mpNext; }
virtual Base* getPrev() { return (Base*)mpPrev; }
#endif
/** @brief Check if scene has been created.*/
bool isSceneCreated() const { return (mScnState & SCN_STATE_CREATED); }

View File

@@ -28,16 +28,7 @@ namespace ipl {
#ifdef IPL_SETTING_IMPLEMENTATION
class Setting;
class APScanThread;
class APEvent : public ::gui::EventHandler {
public:
APEvent(Setting* setting) : ::gui::EventHandler(), mpSetting(setting) {}
virtual void onEvent(u32 componentID, u32 event, void* data);
private:
Setting* mpSetting;
};
class APEvent;
struct SettingAnimation {
u8 unknown[0x14];
@@ -116,7 +107,7 @@ namespace ipl {
void initScroll();
void updateScroll();
void setAPDraw();
int getRadioLevel(const WDBssDesc_* descriptor);
u8 getRadioLevel(const WDBssDesc_* descriptor);
void setUseEULA_Init_();
void setUseEULA_Cancel_();
void setUseEULA_Start_();
@@ -158,12 +149,48 @@ namespace ipl {
virtual void destroy();
virtual void prepare();
virtual void create();
virtual void calc();
virtual void draw();
virtual FaderSceneCommand calcFadein();
virtual FaderSceneCommand calcNormal();
virtual FaderSceneCommand calcFadeout();
virtual BOOL isResetAcceptable() const;
virtual void unkv_0x68() = 0;
virtual void unkv_0x6C() = 0;
virtual void unkv_0x70() = 0;
virtual void unkv_0x74() = 0;
virtual void unkv_0x78() = 0;
virtual void unkv_0x7C() = 0;
virtual void unkv_0x80() = 0;
virtual void unkv_0x84() = 0;
virtual void unkv_0x88() = 0;
virtual void unkv_0x8C() = 0;
virtual void unkv_0x90() = 0;
virtual void unkv_0x94() = 0;
virtual void unkv_0x98() = 0;
virtual void unkv_0x9C() = 0;
virtual void unkv_0xA0() = 0;
virtual void unkv_0xA4() = 0;
virtual void unkv_0xA8() = 0;
virtual void unkv_0xAC() = 0;
virtual void unkv_0xB0() = 0;
virtual void unkv_0xB4() = 0;
virtual void unkv_0xB8() = 0;
virtual void unkv_0xBC() = 0;
virtual void unkv_0xC0() = 0;
virtual void unkv_0xC4() = 0;
virtual void unkv_0xC8() = 0;
virtual void unkv_0xCC() = 0;
virtual void unkv_0xD0() = 0;
virtual void unkv_0xD4() = 0;
virtual void unkv_0xD8() = 0;
virtual void unkv_0xDC() = 0;
virtual void unkv_0xE0() = 0;
virtual void unkv_0xE4() = 0;
virtual void unkv_0xE8() = 0;
virtual void unkv_0xEC() = 0;
virtual void unkv_0xF0() = 0;
virtual void unkv_0xF4() = 0;
virtual void unkv_0xF8() = 0;
#endif
u16 getProfileID();
@@ -262,6 +289,18 @@ namespace ipl {
#endif
};
#ifdef IPL_SETTING_IMPLEMENTATION
class APEvent : public ::gui::EventHandler {
public:
APEvent(Setting* setting) : ::gui::EventHandler(), mpSetting(setting) {}
virtual void onEvent(u32 componentID, u32 event, void* data);
private:
Setting* mpSetting;
};
#endif
} // namespace scene
} // namespace ipl

View File

@@ -50,10 +50,17 @@ namespace ipl {
} KeyboardType;
typedef struct KeyboardSetting {
#ifdef IPL_SETTING_IMPLEMENTATION
u32 rowLimit; // 0x00
const wchar_t* wcString; // 0x04
u32 stringLimit; // 0x08
KeyboardType type; // 0x0C
#else
KeyboardType type; // 0x00
const wchar_t* wcString; // 0x04
u32 stringLimit; // 0x08
u32 rowLimit; // 0x0C
#endif
#ifdef IPL_ADDRESS_EDIT_CPP
KeyboardSetting(KeyboardType keyboardType, const wchar_t* value, u32 limit, u32 rows);
#endif

View File

@@ -15,9 +15,10 @@ namespace ipl {
const wchar_t* getMessage(u32 id) const { return mpMessage->getMessage(id); }
void setResource(u8* msgData) const { mpMessage->setResource(msgData); }
private:
void initMessage();
private:
Message* mpMessage; // 0x00
};
} // namespace message

View File

@@ -56,6 +56,7 @@ namespace ipl {
void stop() { mState = ANIM_STATE_STOP; }
bool isPlaying() const { return mState == ANIM_STATE_PLAY; }
bool isPlaying() const volatile { return mState == ANIM_STATE_PLAY; }
protected:
f32 mMaxFrame; // 0x04

View File

@@ -48,7 +48,12 @@ namespace nw4r {
Pane(const res::Pane* pBlock);
virtual ~Pane(); // 0x08
#ifdef IPL_LYT_PANE_RTTI_OUT_OF_LINE
virtual const nw4r::ut::detail::RuntimeTypeInfo* GetRuntimeTypeInfo() const;
static const nw4r::ut::detail::RuntimeTypeInfo typeInfo;
#else
NW4R_UT_RUNTIME_TYPEINFO;
#endif
virtual void CalculateMtx(const DrawInfo& drawInfo); // 0x10
@@ -105,7 +110,11 @@ namespace nw4r {
void SetSize(const Size& size) { mSize = size; }
bool IsVisible() { return detail::TestBit(mFlag, BIT_VISIBLE); };
#ifdef IPL_LYT_PANE_SETVISIBLE_OUT_OF_LINE
void SetVisible(bool visible);
#else
void SetVisible(bool visible) { detail::SetBit(&mFlag, BIT_VISIBLE, visible); };
#endif
bool IsInfluencedAlpha() { return detail::TestBit(mFlag, BIT_INFLUENCED_ALPHA); };
void SetInfluencedAlpha(bool visible) { detail::SetBit(&mFlag, BIT_INFLUENCED_ALPHA, visible); };

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,425 @@
#include <string.h>
#include <revolution/types.h>
#include <revolution/os.h>
#include <revolution/soex.h>
void OSSetAlarm();
s32 NCDLockWirelessDriver(void);
s32 NCDUnlockWirelessDriver(s32 id);
s32 NCDSetIpConfig(void* ipConfig);
s32 NCDSetIfConfig(void* ifConfig);
BOOL NCDIsInterfaceDecided(void);
s32 WD_Startup(u32 flags);
s32 WD_Cleanup(void);
s32 WD_Scan(void* params, u8* buffer, u32 bufferLen);
s32 WD_GetInfo(void* info);
static u8 sConf[352];
static u8 sIpConfig[1992];
static void (*AOSSi_callback)(void);
static void (*AOSSi_free)(u32 id, void* ptr, s32 size);
static void* (*AOSSi_alloc)(u32 id, s32 size);
static u32 AOSSi_dns2;
static u32 AOSSi_dns1;
static u32 AOSSi_gateway;
static u32 AOSSi_netmask;
static u32 AOSSi_ipAddr;
static s32 AOSSi_cancel_flag;
static u16 sRateTable[12][2] = {
{0x0001, 0x0200}, {0x0002, 0x0400}, {0x0004, 0x0B00},
{0x0008, 0x0C00}, {0x0010, 0x1200}, {0x0020, 0x1600},
{0x0040, 0x1800}, {0x0080, 0x2400}, {0x0100, 0x3000},
{0x0200, 0x4800}, {0x0400, 0x6000}, {0x0800, 0x6C00},
};
void AOSSi_Cancel(void) {
AOSSi_cancel_flag = 1;
}
static void AOSS_813FD17C(OSAlarm* alarm, OSContext* context) {
OSSendMessage((OSMessageQueue*)alarm->tag, NULL, FALSE);
}
static void AOSS_813FD18C(u32 ms) {
OSMessage queueBuffer;
OSMessage message;
OSMessageQueue queue;
OSAlarm alarm;
OSInitMessageQueue(&queue, &queueBuffer, 1);
OSCreateAlarm(&alarm);
OSSetAlarmTag(&alarm, (u32)&queue);
OSSetAlarm(&alarm, *(u32*)0x800000F8 >> 2, 0, ms * (OS_TIMER_CLOCK / 1000), AOSS_813FD17C);
OSReceiveMessage(&queue, &message, TRUE);
}
typedef struct WD_Info_ {
u8 MAC[6];
u16 enableChannel;
u16 NTRallowedChannel;
u8 countryCode[4];
u8 channel;
u8 initialized;
u8 version[80];
u8 unk_0x60[0x30];
} WD_Info;
typedef struct WDScanParam_ {
u16 channelBit;
u16 maxChannelTime;
u8 bssid[6];
u16 type;
u16 ssidLength;
u8 ssid[32];
u8 ssidMask[32];
} WDScanParam;
typedef struct WDBssDesc_ {
u16 length;
u16 rssi;
u8 bssid[6];
u16 ssidLength;
u8 ssid[32];
u16 capabilities;
struct {
u16 basic;
u16 support;
} rateSet;
u16 beaconPeriod;
u16 dtimPeriod;
u16 channel;
u16 cfPeriod;
u16 cfMaxDuration;
u16 ieLength;
} WDBssDesc;
void* AOSSi_Alloc(s32 size) {
if (AOSSi_alloc != NULL) {
return AOSSi_alloc(0, size);
}
return NULL;
}
void AOSSi_Free(void* ptr) {
if (AOSSi_free != NULL) {
AOSSi_free(0, ptr, 0);
}
}
static void AOSS_813FD25C(u8* dst, u32 val) {
int i;
for (i = 0; i < 4; i++) {
dst[i] = val >> ((3 - i) * 8);
}
}
s32 AOSSi_SetNCDIPAddr(u32 ip, u32 mask, u32 gateway, u32 dns1, u32 dns2) {
AOSS_813FD25C((u8*)&AOSSi_ipAddr, ip);
AOSS_813FD25C((u8*)&AOSSi_netmask, mask);
AOSS_813FD25C((u8*)&AOSSi_gateway, gateway);
AOSS_813FD25C((u8*)&AOSSi_dns1, dns1);
AOSS_813FD25C((u8*)&AOSSi_dns2, dns2);
return 0;
}
s32 AOSSi_InitLocal(void* (*alloc)(u32 id, s32 size),
void (*free_)(u32 id, void* ptr, s32 size)) {
BOOL level;
if (alloc == NULL || free_ == NULL) {
return -1;
}
level = OSDisableInterrupts();
AOSSi_alloc = alloc;
AOSSi_free = free_;
AOSSi_cancel_flag = 0;
OSRestoreInterrupts(level);
return 0;
}
s32 AOSSi_EndLocal(void) {
BOOL level;
level = OSDisableInterrupts();
AOSSi_alloc = NULL;
AOSSi_free = NULL;
OSRestoreInterrupts(level);
return 0;
}
s32 AOSSi_WLANGetBSSList(u32** out) {
u8 mac[6];
WDScanParam ATTRIBUTE_ALIGN(32) req;
WD_Info ATTRIBUTE_ALIGN(32) info;
u8* buf;
u32* list;
u8* src;
u8* dst;
int count;
int i;
int j;
int n;
s32 result = -1;
int retry = 0;
int uretry = 0;
int cretry = 0;
int rescan = 0;
s32 lock;
s32 err;
if (AOSSi_alloc == 0 || AOSSi_free == 0) {
return -1;
}
lock = NCDLockWirelessDriver();
if (lock <= 0) {
return -1;
}
for (;;) {
if (WD_Startup(3) == 0) {
break;
}
if (retry > 10) {
goto unlock;
}
retry++;
AOSS_813FD18C(10);
}
if (WD_GetInfo(&info) == 0) {
memcpy(mac, info.MAC, 6);
}
buf = AOSSi_Alloc(0x3200);
if (buf == 0) {
goto cleanup;
}
memset(buf, 0, 0x3200);
req.channelBit = info.enableChannel;
req.maxChannelTime = 0x28;
memset(req.bssid, 0xFF, 6);
req.type = 0;
req.ssidLength = 0;
memset(req.ssid, 0, 0x20);
memset(req.ssidMask, 0xFF, 0x20);
scan:
err = WD_Scan(&req, buf, 0x3200);
if (err != 0 && (u32)(err - 0x80000000) != 0x8004) {
goto free;
}
count = *(u16*)buf;
if (count == 0) {
goto rescan;
}
list = AOSSi_Alloc((count - 1) * 0x54 + 0x58);
if (list == 0) {
result = -1;
goto free;
}
list[0] = count;
src = buf + 2;
dst = (u8*)list;
for (i = 0; i < count; i++) {
u32 off = i * 0x54;
*(u32*)(dst + off + 4) = ((WDBssDesc*)src)->ssidLength;
memcpy(dst + off + 8, ((WDBssDesc*)src)->ssid, 0x20);
*(u32*)(dst + off + 0x28) = ((WDBssDesc*)src)->channel;
memcpy(dst + off + 0x34, ((WDBssDesc*)src)->bssid, 6);
n = 0;
for (j = 0; j < 12; j++) {
if (((WDBssDesc*)src)->rateSet.support & sRateTable[j][0]) {
dst[off + 0x40 + n] = ((u8*)sRateTable)[j * 4 + 2];
if (((WDBssDesc*)src)->rateSet.basic & sRateTable[j][0]) {
dst[off + 0x40 + n] |= 0x80;
}
n++;
}
}
*(u32*)(dst + off + 0x3C) = n;
*(u32*)(dst + off + 0x50) = ((WDBssDesc*)src)->beaconPeriod;
if ((((WDBssDesc*)src)->capabilities & 3) == 1) {
*(u32*)(dst + off + 0x54) = 1;
}
else if ((((WDBssDesc*)src)->capabilities & 3) == 2) {
*(u32*)(dst + off + 0x54) = 2;
}
else {
*(u32*)(dst + off + 0x54) = 0;
}
src += ((WDBssDesc*)src)->length * 2;
}
*out = list;
result = 0;
goto free;
rescan:
if (AOSSi_cancel_flag == 1) {
result = -1;
goto free;
}
rescan++;
if (rescan > 10) {
list = AOSSi_Alloc(0x58);
if (list == 0) {
result = -1;
goto free;
}
list[0] = 0;
result = 0;
*out = list;
goto free;
}
AOSS_813FD18C(100);
goto scan;
free:
if (AOSSi_free != 0) {
AOSSi_free(0, buf, 0);
}
cleanup:
while (WD_Cleanup() != 0) {
if (cretry > 10) {
result = -1;
break;
}
cretry++;
AOSS_813FD18C(10);
}
unlock:
while (NCDUnlockWirelessDriver(lock) != 0) {
if (uretry > 10) {
result = -1;
break;
}
uretry++;
AOSS_813FD18C(10);
}
return result;
}
s32 AOSSi_WLANConnect(u32* in, u32* out) {
WD_Info ATTRIBUTE_ALIGN(32) info;
int count = 0;
int ret;
u8* conf = sConf;
u8* ipcfg;
memset(conf, 0, 0x15E);
conf[0] = 1;
*(u16*)(conf + 2) = 0;
conf[4] = 0;
if (in[0x28 / 4] == 0) {
*(u16*)(conf + 0x2A) = 0;
}
if (in[0x28 / 4] == 5) {
*(u16*)(conf + 0x2A) = 1;
*(u16*)(conf + 0x2E) = 0;
memcpy(conf + 0x32, (u8*)in + 0x2C, in[0x28 / 4]);
}
else if (in[0x28 / 4] == 0xD) {
*(u16*)(conf + 0x2A) = 2;
*(u16*)(conf + 0x2E) = 0;
memcpy(conf + 0x32, (u8*)in + 0x2C, in[0x28 / 4]);
}
else if (in[0x28 / 4] == 0x10) {
return -1;
}
else {
return -1;
}
*(u16*)(conf + 0x26) = in[0] & 0xFF;
memcpy(conf + 6, (u8*)in + 4, in[0]);
ipcfg = sIpConfig;
ret = 0;
memset(ipcfg, 0, 0x7C4);
*(u32*)(ipcfg + 0x1C) = 0x514;
*(u32*)(ipcfg + 0x20) = 0x64;
*(u32*)(ipcfg + 0x24) = 4;
*(u32*)(ipcfg + 0) = 0;
*(u32*)(ipcfg + 4) = 0;
memcpy(ipcfg + 8, &AOSSi_ipAddr, 4);
memcpy(ipcfg + 0xC, &AOSSi_netmask, 4);
memcpy(ipcfg + 0x10, &AOSSi_gateway, 4);
memcpy(ipcfg + 0x14, &AOSSi_dns1, 4);
memcpy(ipcfg + 0x18, &AOSSi_dns2, 4);
if (NCDSetIpConfig(sIpConfig) != 0) {
ret = -1;
}
if (ret == 0 && NCDSetIfConfig(sConf) != 0) {
ret = -1;
}
if (ret == 0) {
while (!NCDIsInterfaceDecided()) {
if (AOSSi_cancel_flag == 1) {
ret = -1;
break;
}
if (count > 0x258) {
ret = -1;
break;
}
count++;
AOSS_813FD18C(10);
}
}
if (ret == 0) {
out[0] = 1;
if (WD_GetInfo(&info) == 0) {
out[0x28 / 4] = info.channel;
}
{
u32 len = *(u16*)(conf + 0x26);
out[4 / 4] = len;
memcpy((u8*)out + 8, conf + 6, len);
}
}
else {
out[0] = 0;
}
return ret;
}
void AOSSi_Sleep(u32 ms) {
AOSS_813FD18C(ms);
}
s32 AOSSi_Status(void) {
if (AOSSi_callback != NULL) {
AOSSi_callback();
}
return 0;
}
void AOSS_SetCallback(void (*callback)(void)) {
BOOL level;
level = OSDisableInterrupts();
AOSSi_callback = callback;
OSRestoreInterrupts(level);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,361 @@
#include <revolution/os.h>
#include <revolution/soex.h>
#include <revolution/mem.h>
#include <cstring>
#include <revolution/ncd/NCDTypes.h>
#include "utility/iplThread.h"
#include "egg/core/eggHeap.h"
extern "C" {
u32 ATERMi_ApConfigGetVersion(void);
s32 ATERMi_ApConfigStart(s32 priority, u32 size, void (*callback)(u32* data),
void* (*alloc)(u32 size), void (*free_)(u32 size),
u32 stackSize);
s32 ATERMi_ApConfigGetState(u32* state);
s32 ATERMi_ApConfigEnd(void);
s32 ATERMi_ApConfigGetResult(void* result);
}
namespace ipl {
namespace scene {
extern "C" {
static void* RakuRakuThread_813FDEF0(u32 id, s32 size);
static void RakuRakuThread_813FDEFC(u32 id, void* ptr, s32 align);
static void* RakuRakuThread_813FDF08(u32 size);
static void RakuRakuThread_813FDF18(u32 size);
}
typedef struct ATERMResult {
char ssid[0x20]; // 0x00
s32 type; // 0x20
u32 keyId; // 0x24
u8 keys[4][0x20]; // 0x28
char key[0x40]; // 0xA8
} ATERMResult; // 0xE8
typedef struct RakuRakuWork {
u32 state; // 0x00
u32 unk_0x04; // 0x04
s32 result; // 0x08
ATERMResult data; // 0x0C
} RakuRakuWork; // 0xF4
typedef struct QueueWork {
OSMessageQueue queue; // 0x00
OSMessage msg; // 0x20
} QueueWork; // 0x24
MEMAllocator mAllocator;
RakuRakuWork mWork;
QueueWork mQueue;
static u32 sStartTimeHi;
static u32 sStartTimeLo;
static u8 sStarted;
static OSMessage sMsgArray;
static s32 sState = 1;
class RakuRakuThread : public utility::ut_thread {
public:
RakuRakuThread(EGG::Heap* heap);
virtual ~RakuRakuThread(); // 0x08
virtual void* Run(); // 0x0C
virtual void unk_0x2C() = 0; // 0x2C
static void RakuRakuThread_813FDA04(u32* data);
void destroy();
int start();
int getState();
void cancel();
int finish(NCDApConfig* config, int* result);
void printInfo();
private:
s32 mUnk_0x32C; // 0x32C
s32 mEndFlag; // 0x330
s32 mCreated; // 0x334
s32 mThreadPriority; // 0x338
u8* mpWorkBuffer; // 0x33C
u8* mpStackBuffer; // 0x340
MEMHeapHandle mpExpHeap; // 0x344
};
void RakuRakuThread::RakuRakuThread_813FDA04(u32* data) {
BOOL level = OSDisableInterrupts();
mWork.state = data[0];
mWork.unk_0x04 = data[1];
mWork.result = data[2];
OSTime t = OSGetTime();
sStartTimeLo = (u32)t;
sStartTimeHi = (u32)(t >> 32);
OSRestoreInterrupts(level);
}
RakuRakuThread::RakuRakuThread(EGG::Heap* heap) : utility::ut_thread() {
u32 version = ATERMi_ApConfigGetVersion();
if ((((version >> 12) & 0xF) * 10 + ((version >> 8) & 0xF)) != 1) {
mpWorkBuffer = NULL;
}
else {
mpWorkBuffer = (u8*)heap->alloc(0x40000, 0x20);
mpStackBuffer = (u8*)heap->alloc(0x1000, 0x20);
}
mpExpHeap = NULL;
sStarted = 0;
mEndFlag = 0;
mCreated = 0;
OSInitMessageQueue(&mQueue.queue, &sMsgArray, 1);
}
RakuRakuThread::~RakuRakuThread() {
if (mCreated != 0) {
OSJamMessage(&mQueue.queue, (OSMessage)2, TRUE);
WaitForThreadExit();
}
destroy();
}
void RakuRakuThread::destroy() {
if (sStarted != 0) {
OSSendMessage(&mQueue.queue, (OSMessage)1, FALSE);
u32 tick = OSGetTick();
while ((u32)(OSGetTick() - tick) / (OS_TIMER_CLOCK / 1000)
< 0x7D0)
{
u32 state[4];
if (ATERMi_ApConfigGetState(state) == 1 && (s32)state[0] == 7) {
break;
}
}
SOFinish();
sStarted = 0;
}
if (mpExpHeap != NULL) {
MEMDestroyExpHeap(mpExpHeap);
memset(&mAllocator, 0, 0x10);
mpExpHeap = NULL;
}
}
int RakuRakuThread::start() {
SOLibraryConfig config;
MEMAllocator* alloc = &mAllocator;
if (sStarted != 0 || mpWorkBuffer == NULL) {
return 0;
}
BOOL level = OSDisableInterrupts();
OSTime t = OSGetTime();
sStartTimeLo = (u32)t;
sStartTimeHi = (u32)(t >> 32);
mpExpHeap = MEMCreateExpHeapEx(mpWorkBuffer, 0x40000, 2);
MEMInitAllocatorForExpHeap(&mAllocator, mpExpHeap, 0x20);
mThreadPriority = OSGetThreadPriority(OSGetCurrentThread()) - 1;
sStarted = 1;
mEndFlag = 0;
memset((u8*)alloc + 0x1C, 0, 0xE8);
memset((u8*)alloc + 0x10, 0, 0xC);
config.alloc = RakuRakuThread_813FDEF0;
config.free = RakuRakuThread_813FDEFC;
SOInit(&config);
ATERMi_ApConfigStart(mThreadPriority, 0xC8,
RakuRakuThread_813FDA04,
RakuRakuThread_813FDF08,
RakuRakuThread_813FDF18, 0x1000);
if (mCreated == 0) {
mCreated = 1;
memset(mpStackBuffer, 0, 4);
Create(mpStackBuffer, 0x1000, mThreadPriority - 1, TRUE);
OSReport("RakuRakuThread (for End function) start with prio(%d) \n",
mThreadPriority);
}
OSRestoreInterrupts(level);
return 1;
}
void* RakuRakuThread::Run() {
u32 magic = 0x97654321;
OSMessage msg;
for (;;) {
while (OSReceiveMessage(&mQueue.queue, &msg, FALSE) != FALSE) {
if ((s32)msg == 2) {
return this;
}
}
OSReceiveMessage(&mQueue.queue, &msg, TRUE);
if ((s32)msg == 2) {
break;
}
*(u32*)(mpStackBuffer + 0x3FC0) = magic;
ATERMi_ApConfigEnd();
mEndFlag = 1;
if (mCreated == 0) {
break;
}
}
return this;
}
extern "C" {
static void* RakuRakuThread_813FDEF0(u32 id, s32 size) {
return MEMAllocFromAllocator(&mAllocator, size);
}
static void RakuRakuThread_813FDEFC(u32 id, void* ptr, s32 align) {
MEMFreeToAllocator(&mAllocator, ptr);
}
static void* RakuRakuThread_813FDF08(u32 size) {
return MEMAllocFromAllocator(&mAllocator, size);
}
static void RakuRakuThread_813FDF18(u32 size) {
MEMFreeToAllocator(&mAllocator, (void*)size);
}
}
int RakuRakuThread::getState() {
if (sStarted == 0) {
return 0;
}
BOOL level = OSDisableInterrupts();
switch (mWork.state) {
case 1:
sState = 1;
break;
case 2:
sState = 2;
break;
case 3:
sState = 2;
break;
case 4:
sState = 4;
break;
case 5:
sState = 5;
break;
case 6:
sState = 6;
break;
case 7:
sState = 7;
break;
default:
sState = 1;
break;
}
if (sState != 6 && sState != 7) {
if (((u32)OSGetTime() - (u32)sStartTimeLo)
/ (OS_TIMER_CLOCK / 1000)
>= 90000)
{
OSSendMessage(&mQueue.queue, (OSMessage)1, FALSE);
}
}
OSRestoreInterrupts(level);
return sState;
}
void RakuRakuThread::cancel() {
OSSendMessage(&mQueue.queue, (OSMessage)1, FALSE);
}
int RakuRakuThread::finish(NCDApConfig* config, int* result) {
u8* ws = (u8*)&mAllocator;
RakuRakuWork* wk = (RakuRakuWork*)(ws + 0x10);
if (sStarted == 0) {
if (result != NULL) {
*result = -0x63;
}
return 1;
}
if ((u32)(wk->state - 6) <= 1) {
if (mEndFlag == 0) {
if ((s32)wk->state == 6) {
ATERMi_ApConfigGetResult(&wk->data);
printInfo();
}
OSSendMessage((OSMessageQueue*)(ws + 0x104), (OSMessage)1, FALSE);
return 0;
}
else {
SOFinish();
sStarted = 0;
destroy();
}
}
else {
return 0;
}
if (config != NULL) {
memcpy(config->ssid, wk->data.ssid, 0x20);
config->ssidLength = strlen(wk->data.ssid);
ATERMResult* data = &wk->data;
if (data->type == 1) {
config->privacy.mode = 1;
config->privacy.wep40.keyId = data->keyId;
for (int i = 0; i < 4; i++) {
memcpy(config->privacy.wep40.key[i],
data->keys[i], 5);
}
}
else if (data->type == 2) {
config->privacy.mode = 2;
config->privacy.wep104.keyId = data->keyId;
for (int i = 0; i < 4; i++) {
memcpy(config->privacy.wep104.key[i],
data->keys[i], 0xD);
}
}
else if (data->type == 4) {
config->privacy.mode = 4;
memcpy(config->privacy.tkip.key, data->key, 0x40);
config->privacy.tkip.keyLen = strlen(data->key);
}
else if (data->type == 5) {
config->privacy.mode = 6;
memcpy(config->privacy.aes.key, data->key, 0x40);
config->privacy.aes.keyLen = strlen(data->key);
}
}
if (result != NULL) {
*result = wk->result;
}
return 1;
}
#pragma dont_inline on
void RakuRakuThread::printInfo() {
}
#pragma dont_inline reset
} // namespace scene
} // namespace ipl

View File

@@ -0,0 +1,150 @@
#define IPL_CONTROLLER_TRIVIAL_RECT_DTOR
#include <nw4r/ut/Rect.h>
extern "C" {
#include <revolution/gx.h>
#include <revolution/tpl.h>
#include <revolution/wpad.h>
}
#include <system/iplController.h>
#include <system/iplNand.h>
#include <system/iplSystem.h>
#include <utility/iplGraphics.h>
extern "C" void* KPADGetWPADRingBuffer(s32 chan);
extern "C" void* KPADGetWPADFSRingBuffer(s32 chan);
extern "C" void* KPADGetWPADCLRingBuffer(s32 chan);
extern __declspec(section ".sdata2") u8 sFrameColorR;
extern __declspec(section ".sdata2") u8 sFrameColorG;
extern __declspec(section ".sdata2") u8 sFrameColorB;
extern __declspec(section ".sdata2") u8 sFrameColorA;
extern __declspec(section ".sdata2") u8 sPointColorR;
extern __declspec(section ".sdata2") u8 sPointColorG;
extern __declspec(section ".sdata2") u8 sPointColorB;
extern __declspec(section ".sdata2") u8 sPointColorA;
extern __declspec(section ".sdata2") const f32 sPosZero;
extern __declspec(section ".sdata2") f32 sDpdOffsetY;
extern __declspec(section ".sdata2") f32 sDpdScale;
namespace ipl {
typedef struct DPDObj {
s16 x; // 0x0
s16 y; // 0x2
u16 size; // 0x4
s16 id; // 0x6
} DPDObj;
class SensitivityDrawing {
public:
static void draw(nand::File* file);
};
void SensitivityDrawing::draw(nand::File* file) {
GXRenderModeObj mode = *System::getRenderModeObj();
nw4r::ut::Rect rect(sPosZero, sPosZero, sPosZero, sPosZero);
System::getProjectionRect(&rect);
GXColor frameColor = {sFrameColorR, sFrameColorG, sFrameColorB,
sFrameColorA};
u32 left;
u32 top;
u32 width;
u32 height;
GXGetScissor(&left, &top, &width, &height);
f32 fw2 = 0.5f * (rect.right - rect.left);
f32 ys = (0.5f * (rect.bottom - rect.top)) / 768.0f;
f32 xs = (0.5f * (rect.right - rect.left)) * 0.0009765625f;
f32 ws = mode.fbWidth / (rect.right - rect.left);
f32 hs = mode.efbHeight / (rect.bottom - rect.top);
f32 fh2 = 0.5f * (rect.bottom - rect.top);
utility::Graphics::setDefaultOrtho(0);
GXSetScissor((u32)(ws * (0.5f * rect.left + fw2)),
(u32)(hs * (0.5f * rect.top + fh2 + sDpdOffsetY)),
(u32)(ws * ((rect.right - rect.left) * 0.5f)),
(u32)(hs * ((rect.bottom - rect.top) * 0.5f)));
utility::Graphics::drawPolygon(rect, frameColor);
controller::Interface* controller = System::getYoungController();
if (controller != NULL && controller->getKPADStatus() != NULL) {
GXTexObj texObj;
TPLGetGXTexObjFromPalette((TPLPalette*)file->getBuffer(), &texObj, 1);
GXInitTexObjWrapMode(&texObj, GX_MIRROR, GX_MIRROR);
s32 index = WPADGetLatestIndexInBuf(controller->getChannel());
DPDObj* first;
DPDObj* last;
switch (controller->getType()) {
case 0: {
u8* base = (u8*)KPADGetWPADRingBuffer(
controller->getChannel()) +
index * 0x2A;
last = (DPDObj*)(base + 0x20);
first = (DPDObj*)(base + 8);
break;
}
case 1: {
u8* base = (u8*)KPADGetWPADFSRingBuffer(
controller->getChannel()) +
index * 0x32;
last = (DPDObj*)(base + 0x20);
first = (DPDObj*)(base + 8);
break;
}
case 2: {
u8* base = (u8*)KPADGetWPADCLRingBuffer(
controller->getChannel()) +
index * 0x36;
last = (DPDObj*)(base + 0x20);
first = (DPDObj*)(base + 8);
break;
}
}
DPDObj* obj = last;
do {
if (obj->size != 0) {
s32 x = obj->x - 0x200;
s32 y = obj->y - 0x180;
f32 s = sDpdScale * (obj->size + 0x19);
nw4r::ut::Rect pos(sPosZero, sPosZero, sPosZero, sPosZero);
f32 sx = xs * x;
f32 sy = ys * y;
pos.left = sx - s;
pos.top = (-sy + s) - sDpdOffsetY;
pos.right = sx + s;
pos.bottom = (-sy - s) - sDpdOffsetY;
utility::Graphics::drawTexture(pos, texObj,
*(GXColor*)&sPointColorR, 2,
utility::Graphics::ORI_NONE);
}
obj--;
} while (obj >= first);
}
GXSetScissor(left, top, width, height);
}
} // namespace ipl
extern __declspec(section ".sdata2") u8 sFrameColorR = 0x60;
extern __declspec(section ".sdata2") u8 sFrameColorG = 0x60;
extern __declspec(section ".sdata2") u8 sFrameColorB = 0x60;
extern __declspec(section ".sdata2") u8 sFrameColorA = 0xC0;
extern __declspec(section ".sdata2") u8 sPointColorR = 0xFF;
extern __declspec(section ".sdata2") u8 sPointColorG = 0xFF;
extern __declspec(section ".sdata2") u8 sPointColorB = 0xFF;
extern __declspec(section ".sdata2") u8 sPointColorA = 0xFF;
extern __declspec(section ".sdata2") const f32 sPosZero = 0.0f;
extern __declspec(section ".sdata2") f32 sDpdOffsetY = -45.0f;
extern __declspec(section ".sdata2") f32 sDpdScale = 0.15f;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,190 @@
extern "C" {
#include <private/wd.h>
}
#include <revolution/os.h>
#include <revolution/wd.h>
#include <string.h>
#define USBAP_STACK_SIZE 0x1000
#define USBAP_NICKNAME_LEN 0x14
#define USBAP_MAC_TABLE_MAX 0x14
#define USBAP_MAC_LENGTH 6
#define USBAP_SSID "NWCUSBAP"
#define USBAP_SSID_LENGTH 8
typedef void (*USBAPCallback)(int result);
static OSThread usbapThread;
static u8 usbapStack[USBAP_STACK_SIZE];
static OSMessageQueue usbapMessageQ;
static u16 usbapNickname[12];
static OSMessage usbapMsg;
static USBAPCallback usbapCallback;
static s32 usbapUseNickname;
static u16 usbapEnableChannel;
static u8* usbapScanBuffer;
static u8* usbapMacTable;
u8* gUSBAPResult;
extern "C" void* DoRegistration(void* param);
extern "C" int USBAPStartRegistration(void* unused1, void* unused2,
u32 priority, s32 useNickname, const u16* nickname,
USBAPCallback callback, u8* scanBuffer, u8* macTable) {
s32 level;
level = OSDisableInterrupts();
usbapScanBuffer = scanBuffer;
usbapMacTable = macTable;
if (usbapThread.state != 0 && !OSIsThreadTerminated(&usbapThread)) {
OSRestoreInterrupts(level);
return 0;
}
if (priority > 0x1F || nickname == NULL || callback == NULL) {
OSRestoreInterrupts(level);
return 0;
}
usbapUseNickname = useNickname;
usbapCallback = callback;
memcpy(usbapNickname, nickname, USBAP_NICKNAME_LEN);
OSInitMessageQueue(&usbapMessageQ, &usbapMsg, 1);
if (OSCreateThread(&usbapThread, DoRegistration, NULL,
usbapStack + sizeof(usbapStack), sizeof(usbapStack), priority, 1)
== 1)
{
OSRestoreInterrupts(level);
while (OSResumeThread(&usbapThread) > 1) {
}
return 1;
}
OSRestoreInterrupts(level);
return 0;
}
extern "C" int USBAPCancelRegistration(void) {
return OSSendMessage(&usbapMessageQ, NULL, 0);
}
extern "C" int USBAPIsThreadTerminated(void) {
return OSIsThreadTerminated(&usbapThread);
}
extern "C" void* DoRegistration(void* param) {
OSMessage msg;
WDScanParam req;
s32 ret;
s32 result;
BOOL found;
BOOL empty;
u16 count;
s32 i;
s32 j;
s32 joff;
WDBssDesc* entry;
if (WDCheckEnableChannel(&usbapEnableChannel) != 0) {
ret = 0;
if (usbapCallback != NULL) {
usbapCallback(0);
}
}
else {
for (;;) {
OSYieldThread();
if (OSReceiveMessage(&usbapMessageQ, &msg, 0) == TRUE) {
ret = 0;
if (usbapCallback != NULL) {
usbapCallback(0);
}
break;
}
result = 0;
req.channelBit = usbapEnableChannel;
req.maxChannelTime = 0x64;
memset(req.bssid, 0xFF, WD_BSSID_LENGTH);
req.type = 0;
req.ssidLength = 0x20;
memcpy(req.ssid, USBAP_SSID, USBAP_SSID_LENGTH);
req.ssid[8] = 0;
req.ssid[9] = 1;
if (usbapUseNickname == 1) {
req.ssid[9] |= 2;
}
req.ssid[10] = 1;
req.ssid[11] = 0;
memcpy(&req.ssid[12], usbapNickname, USBAP_NICKNAME_LEN);
memset(&req.ssidMask[0], 0, 8);
memset(&req.ssidMask[8], 0xFF, 0x18);
if (WDScanOnce(usbapScanBuffer, 0x800, &req) == 0) {
found = 0;
empty = 0;
count = *(u16*)usbapScanBuffer;
entry = (WDBssDesc*)(usbapScanBuffer + 2);
for (i = 0; i < count; i++) {
if (entry->ssidLength == 0x20
&& strncmp((char*)entry->ssid, USBAP_SSID,
USBAP_SSID_LENGTH)
== 0)
{
for (j = 0, joff = 0; j < USBAP_MAC_TABLE_MAX;
j++, joff += USBAP_MAC_LENGTH)
{
if (memcmp(entry->bssid,
&usbapMacTable[1 + joff],
USBAP_MAC_LENGTH)
== 0)
{
break;
}
}
if (j == USBAP_MAC_TABLE_MAX) {
if (entry->ssid[9] == 1) {
memcpy(&usbapMacTable[1 + usbapMacTable[0]
* USBAP_MAC_LENGTH],
entry->bssid, USBAP_MAC_LENGTH);
usbapMacTable[0]++;
found = 1;
}
else if (entry->ssid[9] == 0) {
empty = 1;
}
}
}
entry = (WDBssDesc*)((u8*)entry + entry->length * 2);
}
if (found) {
result = empty ? 2 : 1;
}
}
if (result != 0) {
ret = result == 1;
if (usbapCallback != NULL) {
usbapCallback(ret);
}
break;
}
}
}
return (void*)(u32)ret;
}

View File

@@ -0,0 +1,71 @@
#include <revolution/os.h>
#include <cstring>
#include "utility/iplCharacterCode.h"
extern "C" int USBAPStartRegistration(void* arg1, void* arg2, s32 priority,
void* arg4, void* arg5, void* callback, void* arg7, void* arg8);
extern "C" int USBAPCancelRegistration(void);
extern "C" int USBAPIsThreadTerminated(void);
extern u8* gUSBAPResult;
namespace ipl {
namespace scene {
class USBAPThread {
public:
USBAPThread();
void Init(u16* pData, u8* pBuf);
void cancel();
void is();
void setData(const wchar_t* pData, u8* pBuf);
void callback();
private:
wchar_t mData[10];
};
USBAPThread::USBAPThread() {
}
void USBAPRegisterCallback(int result) {
if (result == 1) {
*gUSBAPResult = 1;
OSReport("Registration completed !\n");
}
else {
*gUSBAPResult = 2;
OSReport("Registration failed...\n");
}
}
void USBAPThread::Init(u16* pData, u8* pBuf) {
s32 priority = OSGetThreadPriority(OSGetCurrentThread()) + 1;
s32 result = USBAPStartRegistration(NULL, NULL, priority, NULL, this,
USBAPRegisterCallback, pData, pBuf);
if (result == 1)
{
OSReport("Registration started\n");
}
}
void USBAPThread::cancel() {
USBAPCancelRegistration();
}
void USBAPThread::is() {
USBAPIsThreadTerminated();
}
void USBAPThread::setData(const wchar_t* pData, u8* pBuf) {
gUSBAPResult = pBuf;
std::memcpy(mData, pData, sizeof(mData));
utility::CharacterCode::changeEndian(
reinterpret_cast<wchar_t*>(mData), 0xA);
}
void USBAPThread::callback() {
}
} // namespace scene
} // namespace ipl

View File

@@ -1,10 +1,11 @@
#!/usr/bin/env python3
"""Compact function diff with context: python ctxdiff.py <unit> <symbol> [--full]"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, "/home/cole/projects/tests")
from odiff import dis, sym
import os
import itertools

View File

@@ -0,0 +1,166 @@
#!/usr/bin/env python3
"""odiff: symbol lookup + normalized disassembly for object files.
Recreated for this environment (original lived on the author's machine).
"""
import re
from capstone import CS_ARCH_PPC, CS_MODE_32, CS_MODE_BIG_ENDIAN, Cs
from elftools.elf.elffile import ELFFile
_cache = {}
def _load(path):
if path in _cache:
return _cache[path]
with open(path, "rb") as f:
e = ELFFile(f)
st = e.get_section_by_name(".symtab")
names = [s.name for s in st.iter_symbols()]
syms = {s.name: (s["st_value"], s["st_size"]) for s in st.iter_symbols()}
data = {}
for sec in e.iter_sections():
data[sec.name] = (sec["sh_offset"], sec.data())
relocs = {}
for sec in e.iter_sections():
if sec.name.startswith(".rela"):
target = sec.name[5:]
for r in sec.iter_relocations():
relocs[(target, r["r_offset"])] = names[r["r_info_sym"]]
_cache[path] = (data, syms, relocs)
return _cache[path]
def sym(path, name):
_, syms, _ = _load(path)
return syms[name]
_PS_ARITH = {
40: "ps_sum0", 41: "ps_sum1", 20: "ps_sum0", 21: "ps_sum1",
32: "ps_muls0", 33: "ps_muls1", 28: "ps_madds0", 29: "ps_madds1",
12: "ps_mul", 14: "ps_div", 10: "ps_add", 11: "ps_sub",
26: "ps_madd", 30: "ps_nmsub", 31: "ps_msub", 28 >> 2: "x",
18: "ps_merge00", 528: "ps_merge00", 560: "ps_merge01",
592: "ps_merge10", 624: "ps_merge11", 25: "ps_mul",
}
def _ps_decode(w):
major = w >> 26
if major in (56, 57, 60, 61): # psq_l psq_lu psq_st psq_stu
names = {56: "psq_l", 57: "psq_lu", 60: "psq_st", 61: "psq_stu"}
fd = (w >> 21) & 31
ra = (w >> 16) & 31
w_ = (w >> 15) & 1
i = (w >> 12) & 7
d = w & 0xFFF
if d & 0x800:
d -= 0x1000
return "%s f%d, %d(r%d), %d, %d" % (names[major], fd, d, ra, w_, i)
if major in (6, 7): # psq_lx psq_stx
names = {6: "psq_lx", 7: "psq_stx"}
fd = (w >> 21) & 31
ra = (w >> 16) & 31
rb = (w >> 11) & 31
w_ = (w >> 10) & 1
i = (w >> 7) & 7
return "%s f%d, r%d, r%d, %d, %d" % (names[major], fd, ra, rb, w_, i)
if major == 4: # ps_* arithmetic
xo = (w >> 1) & 0x3FF
rc = w & 1
fd = (w >> 21) & 31
fa = (w >> 16) & 31
fb = (w >> 11) & 31
fc = (w >> 6) & 31
names = {18: "ps_div", 20: "ps_sub", 21: "ps_add", 23: "ps_sel",
24: "ps_res", 25: "ps_mul", 26: "ps_rsqrte", 28: "ps_msub",
29: "ps_madd", 30: "ps_nmsub", 31: "ps_nmadd", 10: "ps_sum0",
11: "ps_sum1", 12: "ps_muls0", 13: "ps_muls1",
14: "ps_madds0", 15: "ps_madds1", 16: "ps_cmpu0",
32: "ps_cmpo0", 40: "ps_cmpu1", 48: "ps_cmpo1",
66: "ps_neg", 34: "ps_mr", 136: "ps_nabs", 264: "ps_abs",
528: "ps_merge00", 560: "ps_merge01", 592: "ps_merge10",
624: "ps_merge11", 1014: "dcbz_l"}
n = names.get(xo)
if n is None:
return None
if xo in (34, 66, 136, 264):
return "%s%s f%d, f%d" % (n, "." if rc else "", fd, fb)
if xo in (528, 560, 592, 624):
return "%s%s f%d, f%d, f%d" % (n, "." if rc else "", fd, fa, fb)
if xo in (16, 32, 40, 48):
return "%s cr%d, f%d, f%d" % (n, fd >> 2, fa, fb)
if xo in (10, 11):
return "%s%s f%d, f%d, f%d, f%d" % (n, "." if rc else "", fd, fc, fa, fb)
return "%s%s f%d, f%d, f%d, f%d" % (n, "." if rc else "", fd, fa, fc, fb)
return None
def dis(path, off, size, section=".text"):
data, syms, relocs = _load(path)
sec_data = data[section][1]
# Word-granular disassembly: capstone with paired-single fallback.
class _I:
__slots__ = ("address", "mnemonic", "op_str")
def __init__(self, a, m, o):
self.address = a
self.mnemonic = m
self.op_str = o
insns = []
pos = off
end = off + size
md = Cs(CS_ARCH_PPC, CS_MODE_32 + CS_MODE_BIG_ENDIAN)
while pos < end:
w = int.from_bytes(sec_data[pos:pos + 4], "big")
major = w >> 26
is_ps = major in (4, 56, 57, 60, 61) or (
major in (6, 7) and ((w >> 1) & 0x3FF) == 18)
if is_ps:
t = _ps_decode(w)
if t is None:
insns.append(_I(pos, ".long", hex(w)))
else:
parts = t.split(" ", 1)
insns.append(_I(pos, parts[0], parts[1]))
pos += 4
continue
chunk = sec_data[pos:end]
done = False
for i in md.disasm(chunk, pos):
insns.append(i)
done = True
break
if not done:
w = int.from_bytes(sec_data[pos:pos + 4], "big")
t = _ps_decode(w)
if t is None:
insns.append(_I(pos, ".long", hex(w)))
else:
parts = t.split(" ", 1)
insns.append(_I(pos, parts[0], parts[1]))
pos += 4
out = []
for i in insns:
text = i.mnemonic + " " + i.op_str
m = re.search(r"0x[0-9a-fA-F]+", i.op_str)
if (section, i.address) in relocs:
# External reference: show the symbol, drop the raw addend
text = i.mnemonic + " " + re.sub(r"0x[0-9a-fA-F]+",
"<" + relocs[(section, i.address)] + ">",
i.op_str)
elif m and i.mnemonic.startswith("b"):
val = int(m.group(0), 16)
if off <= val < off + size:
# Intra-function branch: normalize to function-relative
text = i.mnemonic + " " + (i.op_str[:m.start()] +
"+" + hex(val - off) +
i.op_str[m.end():])
out.append((i.address - off, text))
return out