Compare commits

..

1 Commits

Author SHA1 Message Date
coah
65fcc26610 NWC24MsgCommit: 15/18 exact (worker fc42b29c) 2026-09-30 02:56:20 +00:00
451 changed files with 21198 additions and 137573 deletions

View File

@@ -53,9 +53,9 @@ Progress
<!-- progress:start -->
| Decompiled | Matched | Linked | Data |
|:---:|:---:|:---:|:---:|
| 98.27% | 85.37% | 59.71% | 90.53% |
| 84.90% | 75.26% | 56.76% | 86.70% |
units 805/1027 complete, functions 12090/12563 matched.
units 748/1027 complete, functions 10978/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 -->

View File

@@ -1,293 +0,0 @@
# sol-med matching attempts
ATERM pool was identical before iteration. Initial gate: 3/26 instruction-exact, code 72/19204, data 18440/18864, no regressions.
ATERM_814021BC: (1) combined network settings and access-point name, moved member-pointer initialization after clears, bottom-tested host loop: 153/154 instructions, register and addressing differences; (2) aligned the name member and explicit settings pointer: same instruction count and differences; (3) initialized IP pointer before clear: no improvement. Restored original to avoid unrelated aggregate changes.
ATERM_81402424: (1) aligned scan parameters to 32, swapped message/buffer declarations, preserved scan exit result test: 210/210, three condition-register differences; (2) tested scan result != retry error: one branch difference; (3) tested scan result == retry error: 210/210, diffs 0. Retained.
ATERM_8140276C: (1) initialized previous record cursor before outer loop, reset at outer tail, separated result flag, scoped AOSS flags: 174/174, 31 register differences; (2) reordered result/found declarations and scoped previous index: 174/174, 27 register differences. Further experiments below.
ATERM_81403614: (1) switch over hex character ranges, signed index and indexed output: 49/49, two division differences; (2) explicit signed truncation for index/2: one operand-order difference; (3) reversed addition operands: diffs 0. Retained.
ATERMi_AutoConfigThread: (1) real three-field progress object and conditional terminal state: 39/40 instructions; (2) signed equality mask: 40/40, three scheduling/register differences; (3) read progress result before deadline assignment: eight differences. Further experiments below.
ATERMi_ApConfigStart: (1) inclusive state bounds, use stored stack size and callback: 103/103, twelve differences; (2) restore source order of global initialization: six clock-register differences. Further experiments below.
ATERMi_ApConfigEnd: (1) capture initial state only inside active-thread branch, swap message declarations, compute 500ms alarm instead of reciprocal literal: 125/129 instructions, frame/scheduling differences. Further experiments below.
ATERMi_ApConfigGetState: (1) reciprocal first in multiply-high: four register differences; (2) load bus clock in multiply expression: unchanged; (3) direct time conversion expression: unchanged. Restored original, 35/35 instructions with three register differences.
ATERM_8140276C initial 99.166664%
- previous cursor declaration before current cursor: 99.5115%; src 0x2b8 base 0x2b8 insns 174/174; diffs 15: [8, 9, 82, 84, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]; 8 M addi r27, r4, 4; B addi r31, r3, 4
- signed record indices: 99.166664%; src 0x2b8 base 0x2b8 insns 174/174; diffs 27: [8, 9, 18, 29, 34, 41, 50, 54, 55, 60, 61, 68, 74, 75, 82, 84, 87, 88, 89, 90]; 8 M addi r27, r3, 4; B addi r31, r3, 4
- AOSS flags initialized after clear: 99.54023%; src 0x2b8 base 0x2b8 insns 174/174; diffs 14: [8, 9, 18, 29, 34, 41, 50, 54, 55, 60, 61, 68, 74, 75]; 8 M addi r27, r3, 4; B addi r31, r3, 4
Retained original
ATERM_81402A24 initial 72.47529%
- record capacity includes final descriptor: 71.30038%; src 0x3d4 base 0x41c insns 245/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
- allocate nullable buffers before handling failure: 72.380226%; src 0x3cc base 0x41c insns 243/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
- multiply-high tick conversion: 75.76426%; src 0x3f4 base 0x41c insns 253/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
Retained original
ATERM_81402E40 initial 99.791664%
- payload clear through byte alias: 99.791664%; src 0x180 base 0x180 insns 96/96; diffs 4: [9, 10, 47, 52]; 9 M mr r29, r7; B mr r3, r27
- natural checksum loop: 65.208336%; src 0x108 base 0x180 insns 66/96; --- replace mine 5:12 base 5:12; M 5 mr r28, r5; M 6 mr r26, r3
- end length as packet byte extent: 95.572914%; src 0x180 base 0x180 insns 96/96; diffs 6: [9, 10, 42, 44, 47, 52]; 9 M mr r29, r7; B mr r3, r27
Retained original
ATERM_81402FC0 initial 67.28148%
- full-width checksum accumulator: 64.76296%; src 0x20c base 0x21c insns 131/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
- bottom-tested option loop: compile failed
- early return for bad checksum: 66.94074%; src 0x20c base 0x21c insns 131/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
Retained original
ATERM_814031DC initial 85.7218%
- MAC text uses equal-sized buffers: 85.766914%; src 0x1f4 base 0x214 insns 125/133; --- replace mine 47:48 base 47:48; M 47 beq 288; B 47 beq 320
- nibble conversion advances output cursor: 84.293236%; src 0x204 base 0x214 insns 129/133; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x70(r1); B 0 stwu r1, -0x60(r1)
- inclusive digit bound and pointer-based MAC scan: 85.90225%; src 0x1f4 base 0x214 insns 125/133; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x70(r1); B 0 stwu r1, -0x60(r1)
Retained original
ATERM_814033F0 initial 65.868614%
- option fields retain converted word width: 67.39416%; src 0x214 base 0x224 insns 133/137; --- replace mine 5:6 base 5:6; M 5 addi r30, r3, 8; B 5 addi r29, r3, 8
- bottom-tested parser dispatch: 65.79562%; src 0x21c base 0x224 insns 135/137; --- replace mine 5:6 base 5:6; M 5 addi r28, r3, 8; B 5 addi r29, r3, 8
- signed nibble comparisons: 65.32117%; src 0x21c base 0x224 insns 135/137; --- insert mine 7:7 base 7:8; B 7 li r24, 0; --- replace mine 10:29 base 11:17
Retained original
ATERM_814036D8 initial 73.92742%
- security switch matches original decision tree: 85.22581%; src 0x1ec base 0x1f0 insns 123/124; --- replace mine 14:15 base 14:15; M 14 beq 340; B 14 beq 344
- key text passed through one cursor: 87.0%; src 0x1e4 base 0x1f0 insns 121/124; --- replace mine 14:24 base 14:16; M 14 bne 36; M 15 addi r3, r25, 0
- counted loop over key records: 73.92742%; src 0x1e0 base 0x1f0 insns 120/124; --- replace mine 14:24 base 14:16; M 14 bne 36; M 15 addi r3, r25, 0
Retained original
ATERM_814038C8 initial 35.28917%
- one-shot 500ms wait replaces repeated alarm: 35.700314%; src 0x788 base 0xedc insns 482/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0xe0(r1); B 0 stwu r1, -0x180(r1)
- bottom-tested state machine and wait buffer order: 35.288116%; src 0x784 base 0xedc insns 481/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0xe0(r1); B 0 stwu r1, -0x180(r1)
- progress uses semantic structure: 35.28917%; src 0x784 base 0xedc insns 481/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0xe0(r1); B 0 stwu r1, -0x180(r1)
Retained original
ATERM_81404844 initial 19.615385%
- signed RFC3394 counters: 16.34188%; src 0x1a0 base 0x1d4 insns 104/117; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x190(r1)
- counter represented as big-endian bytes: compile failed
- RFC3394 initial value and block output order: 18.264957%; src 0x1b0 base 0x1d4 insns 108/117; --- replace mine 6:9 base 6:13; M 6 mr r27, r3; M 7 mr r20, r4
Retained original
ATERM_81404A18 initial 51.107437%
ATERM_81404844 initial 19.615385%
- signed RFC3394 counters: 16.34188%; src 0x1a0 base 0x1d4 insns 104/117; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x190(r1)
ATERM_81404844 initial 16.34188%
- signed RFC3394 counters: 16.34188%; src 0x1a0 base 0x1d4 insns 104/117; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x190(r1)
- counter represented as big-endian bytes: compile failed
- RFC3394 initial value and block output order: 18.264957%; src 0x1b0 base 0x1d4 insns 108/117; --- replace mine 6:9 base 6:13; M 6 mr r27, r3; M 7 mr r20, r4
Retained original
ATERM_81404A18 initial 51.107437%
- signed RFC3394 counters: 52.05785%; src 0x1c8 base 0x1e4 insns 114/121; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x1a0(r1)
- counter represented as big-endian bytes: compile failed
- RFC3394 initial value and block output order: 54.991737%; src 0x1c4 base 0x1e4 insns 113/121; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x190(r1); B 0 stwu r1, -0x1a0(r1)
Retained original
ATERM_81404BFC initial 36.869404%
- AES byte assembly uses XOR instead of OR: 37.063435%; src 0x400 base 0x430 insns 256/268; --- replace mine 0:6 base 0:20; M 0 lbz r7, 1(r4); M 1 cmplwi r5, 0x80
- key schedule reads preceding round and chains fourth key word: 36.925373%; src 0x3dc base 0x430 insns 247/268; --- replace mine 0:6 base 0:20; M 0 lbz r7, 1(r4); M 1 cmplwi r5, 0x80
- signed round count drives key expansion termination: 49.21642%; src 0x3e0 base 0x430 insns 248/268; --- replace mine 0:3 base 0:47; M 0 lbz r8, 1(r4); M 1 cmplwi r5, 0x80
Retained original
ATERM_8140502C initial 35.666668%
- interleaved key-word swaps: 42.355072%; src 0x280 base 0x228 insns 160/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0
- signed indexed round reversal: 38.746376%; src 0x290 base 0x228 insns 164/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0
- counted transformation loop: 11.731884%; src 0x288 base 0x228 insns 162/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0
Retained original
ATERM_81405254 initial 30.464945%
- AES byte assembly uses XOR: 34.23247%; src 0x3c4 base 0x43c insns 241/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- two-round loop with final round exit: compile failed
- signed round count with separately combined key XOR: compile failed
Retained original
ATERM_81405690 initial 26.601477%
- AES byte assembly uses XOR: 34.64945%; src 0x3d4 base 0x43c insns 245/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- two-round loop with final round exit: compile failed
- signed round count with separately combined key XOR: compile failed
Retained original
ATERM_81405ACC initial 0%
- natural byte copy instead of explicit eight-byte loop: 0%; src 0x10c base 0x240 insns 67/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:12 base 4:10
- separate 32-bit count carry updates: 0%; src 0x184 base 0x240 insns 97/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:5 base 4:11
- indexed full-block walk retains input length: 0%; src 0x17c base 0x240 insns 95/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:12 base 4:10
Retained original
ATERM_81405D0C initial 32.62639%
- decode words with XOR: 25.144444%; src 0xa5c base 0xb40 insns 663/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1)
- MD5 first-round select expressed as xor mask: 30.945833%; src 0x9fc base 0xb40 insns 639/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1)
- flat byte-to-word decode loop: 27.13889%; src 0x904 base 0xb40 insns 577/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1)
Retained original
ATERMi_AutoConfigThread initial 91.325%
- remaining time assigned before terminal state: 91.475%; src 0xa0 base 0xa0 insns 40/40; diffs 7: [20, 22, 23, 26, 28, 29, 30]; 20 M nor r0, r3, r0; B nor r3, r3, r0
- terminal mask reuses result variable: 85.075%; src 0xa0 base 0xa0 insns 40/40; diffs 9: [21, 22, 23, 25, 26, 28, 29, 30, 31]; 21 M lwz r4, 0(0); B li r4, -1
- state stores preceding deadline store: 85.2%; src 0xa0 base 0xa0 insns 40/40; diffs 8: [21, 22, 23, 25, 26, 29, 30, 31]; 21 M lwz r4, 0(0); B li r4, -1
Retained original
ATERMi_ApConfigStart initial 99.70874%
- allocate via stored callback: 99.70874%; src 0x19c base 0x19c insns 103/103; diffs 6: [46, 47, 48, 49, 75, 76]; 46 M lis r31, -0x8000; B lis r30, -0x8000
- tick multiplier commutes operands: 97.76699%; src 0x19c base 0x19c insns 103/103; diffs 7: [48, 49, 51, 75, 76, 77, 78]; 48 M lwz r6, 0xf8(r30); B lwz r0, 0xf8(r30)
- progress state populated before zeroing result buffer: 90.72816%; src 0x19c base 0x19c insns 103/103; diffs 18: [46, 47, 48, 49, 56, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 75, 76]; 46 M lis r31, -0x8000; B lis r30, -0x8000
Retained original
ATERMi_ApConfigEnd initial 93.94574%
- message queues declared within their wait scopes: 91.89922%; src 0x1f4 base 0x204 insns 125/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0
- join loop expressed as do-while: 91.54263%; src 0x200 base 0x204 insns 128/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0
- time conversion evaluated directly: 93.94574%; src 0x1f4 base 0x204 insns 125/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0
Retained original
ATERM_81404844 initial 19.615385%
- big-endian counter union assigned after declarations: 23.931623%; src 0x1a0 base 0x1d4 insns 104/117; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x190(r1)
Retained original
ATERM_81404A18 initial 51.107437%
- big-endian counter union assigned after declarations: 57.677685%; src 0x1c8 base 0x1e4 insns 114/121; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x1a0(r1)
Retained original
ATERM_81405254 initial 30.464945%
- two-round iteration with scoped second round: 25.00369%; src 0x4b8 base 0x43c insns 302/271; --- replace mine 5:42 base 5:230; M 5 lbz r9, 1(r5); M 6 lis r12, 0
- signed round index: 30.464945%; src 0x3a4 base 0x43c insns 233/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- round key XOR before table combination: 30.464945%; src 0x3a4 base 0x43c insns 233/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
Retained original
ATERM_81405690 initial 26.601477%
- two-round iteration with scoped second round: 23.239853%; src 0x4d8 base 0x43c insns 310/271; --- replace mine 5:13 base 5:7; M 5 lbz r10, 1(r5); M 6 lis r7, 0
- signed round index: 26.601477%; src 0x3b4 base 0x43c insns 237/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- round key XOR before table combination: 26.601477%; src 0x3b4 base 0x43c insns 237/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
Retained original
ATERM_81402FC0 initial 67.28148%
- option loop with explicit continuation test: 67.28148%; src 0x210 base 0x21c insns 132/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
Retained original
ATERM final source retains only exact scan and hex-conversion changes. All unsuccessful experiments restored. Remaining 21 functions are open; their instruction counts and experiment outcomes are recorded above. Cryptographic routines require substantial reconstruction, not just register allocation.
AOSS initial gate: 7/21 instruction-exact; code 2540/16192; data 3896/3928. String pool identical.
AOSS_814001B4: early returns and opcode switch: 75/79, remaining differences are save/restore helper versus individual stores.
AOSS_81401BBC: (1) reverse rounding addition: same one operand-order difference; (2) signed rounding temporary: same difference; (3) inline signed rounding expression: 56/56, diffs 0. Retained.
AOSS_81401DC0: (1) reuse seed parameter: 48/48, four last-step register differences; (2) split shift/XOR statements: 64/48 instructions; (3) eight-iteration CRC loop: 16/48 instructions. Restored original.
AOSS_Init_old initial 28.42298%
- full-width wait counters instead of narrowing every update: 28.546717%; src 0x1758 base 0x18c0 insns 1494/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b
AOSS_Init_old initial 28.42298%
- full-width wait counters instead of narrowing every update: 28.546717%; src 0x1758 base 0x18c0 insns 1494/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b
- packet length conversion retains full width: 28.42298%; src 0x1794 base 0x18c0 insns 1509/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b
- poll arguments given semantic socket events structure: 28.42298%; src 0x1794 base 0x18c0 insns 1509/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b
Retained original
AOSS_813FFD68 initial 96.981735%
- validation loops use signed char: 93.69406%; src 0x364 base 0x36c insns 217/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
- return failure immediately on invalid character: 82.05023%; src 0x2ec base 0x36c insns 187/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
- ascending validation cursor loop: 94.76712%; src 0x374 base 0x36c insns 221/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
Retained original
AOSS_814001B4 initial 88.78481%
- converted packet length stays full width: 88.78481%; src 0x12c base 0x13c insns 75/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
- direct opcode return cases: 83.27848%; src 0x124 base 0x13c insns 73/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
- full-width validation and branch nesting: 88.78481%; src 0x12c base 0x13c insns 75/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
Retained original
AOSS_814002F0 initial 79.525%
- read manufacturer only after state validation: 85.058334%; src 0x1c4 base 0x1e0 insns 113/120; --- replace mine 6:8 base 6:8; M 6 mr r30, r3; M 7 mr r26, r4
- packet sequence values remain full-width: 76.441666%; src 0x1c4 base 0x1e0 insns 113/120; --- replace mine 5:7 base 5:8; M 5 mr r30, r3; M 6 mr r26, r4
- direct address error branch: 79.525%; src 0x1c8 base 0x1e0 insns 114/120; --- replace mine 5:7 base 5:8; M 5 mr r30, r3; M 6 mr r26, r4
Retained original
AOSS_81400830 initial 77.619934%
- single-byte RC4 generation loop instead of manual pairs: 65.65109%; src 0x3c0 base 0x504 insns 240/321; --- insert mine 6:6 base 6:7; B 6 addi r29, r3, 0x18; --- insert mine 7:7 base 8:9
- natural CRC byte loop: 60.13084%; src 0x3c4 base 0x504 insns 241/321; --- replace mine 5:6 base 5:7; M 5 mr r27, r3; B 5 mr r26, r3
- narrow RC4 state indices at assignment: 77.619934%; src 0x4b8 base 0x504 insns 302/321; --- insert mine 6:6 base 6:7; B 6 addi r29, r3, 0x18; --- insert mine 7:7 base 8:9
Retained original
AOSS_81400E0C initial 77.52105%
- signed option lengths and iteration indices: 77.778946%; src 0x2bc base 0x2f8 insns 175/190; --- insert mine 5:5 base 5:6; B 5 mr r29, r4; --- replace mine 6:8 base 7:8
- natural integer byte decode for both address options: 44.963158%; src 0x188 base 0x2f8 insns 98/190; --- insert mine 5:5 base 5:6; B 5 mr r29, r4; --- replace mine 6:8 base 7:8
- address decode accumulation uses OR: 61.963158%; src 0x284 base 0x2f8 insns 161/190; --- replace mine 5:8 base 5:8; M 5 mr r29, r3; M 6 mr r30, r4
Retained original
AOSS_814013AC initial 91.70175%
- signed option lengths: 91.70175%; src 0x1cc base 0x1c8 insns 115/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
- apply flags after successful parser call: 84.68421%; src 0x1ec base 0x1c8 insns 123/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
- bounded while loop over selected reply payload: 88.2807%; src 0x1d4 base 0x1c8 insns 117/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
Retained original
AOSS_81401574 initial 92.558136%
- semantic payload extent expression: 92.558136%; src 0x1fc base 0x204 insns 127/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4
- request length remains full-width: 92.209305%; src 0x1f8 base 0x204 insns 126/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4
- initialize destination length before port conversion: 88.31783%; src 0x1fc base 0x204 insns 127/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4
Retained original
AOSS_81401778 initial 71.93407%
- CRC checksum stays full width until header store: 71.93407%; src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0)
- signed RC4 byte loop index: 71.93407%; src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0)
- copy hello payload before manufacturer encoding: 71.91575%; src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0)
Retained original
AOSS_81401C9C initial 71.9315%
- natural RC4 state initialization loop: 43.342464%; src 0x98 base 0x124 insns 38/73; --- replace mine 0:1 base 0:2; M 0 li r9, 0; B 0 stwu r1, -0x10(r1)
- schedule state reset before obtaining byte pointer: 71.9315%; src 0x12c base 0x124 insns 75/73; --- replace mine 0:6 base 0:2; M 0 stwu r1, -0x20(r1); M 1 mflr r0
- signed key and state indices: 71.9315%; src 0x12c base 0x124 insns 75/73; --- replace mine 0:6 base 0:2; M 0 stwu r1, -0x20(r1); M 1 mflr r0
Retained original
AOSS_81401E80 initial 91.80272%
- natural XOR loop over half-packet: 56.455784%; src 0x168 base 0x24c insns 90/147; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x30(r1); B 0 stwu r1, -0x40(r1)
- half-length via signed division: 87.04082%; src 0x240 base 0x24c insns 144/147; --- replace mine 5:19 base 5:13; M 5 srawi r0, r4, 1; M 6 mr r28, r3
- count-down rounds: 88.734695%; src 0x244 base 0x24c insns 145/147; --- replace mine 6:7 base 6:7; M 6 mr r28, r3; B 6 mr r21, r3
Retained original
AOSS_814020CC initial 76.066666%
- sleep tick product stays 64-bit: 67.51667%; src 0xfc base 0xf0 insns 63/60; --- replace mine 3:6 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
- tick duration via explicit multiply-high: 81.65%; src 0xe4 base 0xf0 insns 57/60; --- replace mine 3:5 base 3:6; M 3 addi r11, r1, 0x20; M 4 bl 0
- do-while host acquisition loop: 65.066666%; src 0xf8 base 0xf0 insns 62/60; --- replace mine 3:6 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
Retained original
AOSS final: retained exact packet builder AOSS_81401BBC only. Other experiments restored; remaining differences include loop expansion, register allocation, missing original compiler control flow.
## src/scene/memoryCard/iplMemoryCardBase
Baseline absent source: 0/34, code 0/3640, data 0/152. Implemented all real functions in target address order from original disassembly using typed classes and fields. Initial build: 33/34 exact, code 3240/3640, data 144/152; pool identical.
onCmdRecv initial 96.35%: 101/100 instructions.
- Signed lower/upper bounds for command range: extra comparison and branch.
- Switch cases 1/2/3: 95.35%, 102/100 instructions, compiler produces signed comparison tree.
- Unsigned command range distance: 100%, 100/100 instructions, diffs 0. Retained.
Data limitation: original .sdata2 contains -1.0 plus trailing alignment, while source also emits the required integer-to-float conversion double constant. No forced data or padding added. Full DOL gate determines acceptance; no configure Matching changes.
## Remaining functions at final handoff
src/scene/setting/ATERM: ATERM_814021BC 67.655846% — src 0x264 base 0x268 insns 153/154; --- insert mine 7:7 base 7:9; B 7 addi r30, r30, 0; B 8 li r4, 0; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_8140276C 92.10345% — src 0x2ac base 0x2b8 insns 171/174; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0x80(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81402A24 72.47529% — src 0x3d0 base 0x41c insns 244/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81402E40 99.791664% — src 0x180 base 0x180 insns 96/96; diffs 4: [9, 10, 47, 52]; 9 M mr r29, r7; B mr r3, r27; remaining register/scheduling differences
src/scene/setting/ATERM: ATERM_81402FC0 67.28148% — src 0x210 base 0x21c insns 132/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_814031DC 85.7218% — src 0x1f4 base 0x214 insns 125/133; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x70(r1); B 0 stwu r1, -0x60(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_814033F0 65.868614% — src 0x21c base 0x224 insns 135/137; --- insert mine 7:7 base 7:8; B 7 li r24, 0; --- replace mine 10:29 base 11:17; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_814036D8 73.92742% — src 0x1e0 base 0x1f0 insns 120/124; --- replace mine 14:24 base 14:16; M 14 bne 36; M 15 addi r3, r25, 0; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_814038C8 35.28917% — src 0x784 base 0xedc insns 481/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0xe0(r1); B 0 stwu r1, -0x180(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERMi_AutoConfigThread 94.6% — src 0xa0 base 0xa0 insns 40/40; diffs 9: [0, 2, 3, 20, 22, 23, 34, 36, 38]; 0 M stwu r1, -0x30(r1); B stwu r1, -0x20(r1); remaining register/scheduling differences
src/scene/setting/ATERM: ATERM_81404844 19.615385% — src 0x19c base 0x1d4 insns 103/117; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x190(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81404A18 51.107437% — src 0x1c4 base 0x1e4 insns 113/121; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x150(r1); B 0 stwu r1, -0x1a0(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81404BFC 36.869404% — src 0x3dc base 0x430 insns 247/268; --- replace mine 0:6 base 0:20; M 0 lbz r7, 1(r4); M 1 cmplwi r5, 0x80; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_8140502C 35.666668% — src 0x280 base 0x228 insns 160/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81405254 30.464945% — src 0x3a4 base 0x43c insns 233/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81405690 26.601477% — src 0x3b4 base 0x43c insns 237/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81405ACC None% — src 0x17c base 0x240 insns 95/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:12 base 4:10; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERM_81405D0C 32.62639% — src 0x9e4 base 0xb40 insns 633/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERMi_ApConfigStart 86.49515% — src 0x1a4 base 0x19c insns 105/103; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x30(r1); B 0 stwu r1, -0x20(r1); remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERMi_ApConfigEnd 87.54263% — src 0x1dc base 0x204 insns 119/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0; remaining control-flow/codegen differences
src/scene/setting/ATERM: ATERMi_ApConfigGetState 99.42857% — src 0x8c base 0x8c insns 35/35; diffs 3: [17, 18, 20]; 17 M lwz r6, 0xf8(r6); B lwz r0, 0xf8(r6); remaining register/scheduling differences
src/scene/setting/AOSS: AOSS_Init_old 28.42298% — src 0x1794 base 0x18c0 insns 1509/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_813FFD68 96.981735% — src 0x364 base 0x36c insns 217/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_814001B4 41.518986% — src 0x118 base 0x13c insns 70/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_814002F0 79.525% — src 0x1c8 base 0x1e0 insns 114/120; --- replace mine 5:7 base 5:8; M 5 mr r30, r3; M 6 mr r26, r4; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_81400830 77.619934% — src 0x4b8 base 0x504 insns 302/321; --- insert mine 6:6 base 6:7; B 6 addi r29, r3, 0x18; --- insert mine 7:7 base 8:9; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_81400E0C 77.52105% — src 0x2c4 base 0x2f8 insns 177/190; --- insert mine 5:5 base 5:6; B 5 mr r29, r4; --- replace mine 6:8 base 7:8; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_814013AC 91.70175% — src 0x1cc base 0x1c8 insns 115/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_81401574 92.558136% — src 0x1fc base 0x204 insns 127/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_81401778 71.93407% — src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0); remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_81401C9C 71.9315% — src 0x12c base 0x124 insns 75/73; --- replace mine 0:6 base 0:2; M 0 stwu r1, -0x20(r1); M 1 mflr r0; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_81401DC0 99.375% — src 0xc0 base 0xc0 insns 48/48; diffs 4: [39, 41, 42, 43]; 39 M srwi r0, r3, 1; B srwi r3, r3, 1; remaining register/scheduling differences
src/scene/setting/AOSS: AOSS_81401E80 91.80272% — src 0x244 base 0x24c insns 145/147; --- replace mine 6:7 base 6:7; M 6 mr r28, r3; B 6 mr r21, r3; remaining control-flow/codegen differences
src/scene/setting/AOSS: AOSS_814020CC 76.066666% — src 0xf0 base 0xf0 insns 60/60; diffs 39: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 26]; 3 M addi r11, r1, 0x20; B stw r31, 0x1c(r1); remaining register/scheduling differences
MemoryBase full clean gate: 34/34 instruction-exact, code 3640/3640, data 144/152, pool identical, regressions 0, forbidden patterns 0, readability warnings 0, DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d, GATE PASS. Data remains incomplete in objdiff; no artificial fix attempted.

View File

@@ -1,326 +0,0 @@
# ATERM and AOSS continuation
Baseline ATERM: 5/26, code 1108/19204, data 18440/18864, fuzzy 50.973755. Baseline AOSS: 8/21, code 2764/16192, data 3896/3928, fuzzy 63.720604. All functions have bodies; existing large state machine and crypto bodies remain incomplete reconstructions. No absent symbols or empty bodies found.
ATERM_8140276C initial 92.10345%
- previous cursor declaration before current cursor: no source change; skipped
- signed record indices: 92.10345%; src 0x2ac base 0x2b8 insns 171/174; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0x80(r1)
- AOSS flags initialized after clear: 91.72988%; src 0x2ac base 0x2b8 insns 171/174; --- replace mine 5:10 base 5:13; M 5 mr r25, r3; M 6 mr r26, r4
Retained best candidate
ATERM_81402A24 initial 72.47529%
- record byte count kept signed: no source change; skipped
- allocate nullable buffers before handling failure: 72.380226%; src 0x3cc base 0x41c insns 243/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
- multiply-high tick conversion: 75.76426%; src 0x3f4 base 0x41c insns 253/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
Retained best candidate
ATERM_81402E40 initial 99.791664%
- payload clear through byte alias: 99.791664%; src 0x180 base 0x180 insns 96/96; diffs 4: [9, 10, 47, 52]; 9 M mr r29, r7; B mr r3, r27
- natural checksum loop: 65.208336%; src 0x108 base 0x180 insns 66/96; --- replace mine 5:12 base 5:12; M 5 mr r28, r5; M 6 mr r26, r3
- end length as packet byte extent: 95.572914%; src 0x180 base 0x180 insns 96/96; diffs 6: [9, 10, 42, 44, 47, 52]; 9 M mr r29, r7; B mr r3, r27
Retained best candidate
ATERM_81402FC0 initial 67.28148%
- full-width checksum accumulator: 64.76296%; src 0x20c base 0x21c insns 131/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
- bottom-tested option loop: compile failed
- early return for bad checksum: 66.94074%; src 0x20c base 0x21c insns 131/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
Retained best candidate
ATERM_814031DC initial 85.7218%
- MAC text uses equal-sized buffers: 85.766914%; src 0x1f4 base 0x214 insns 125/133; --- replace mine 47:48 base 47:48; M 47 beq 288; B 47 beq 320
- nibble conversion advances output cursor: 84.293236%; src 0x204 base 0x214 insns 129/133; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x70(r1); B 0 stwu r1, -0x60(r1)
- inclusive digit bound and pointer-based MAC scan: 85.90225%; src 0x1f4 base 0x214 insns 125/133; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x70(r1); B 0 stwu r1, -0x60(r1)
Retained best candidate
ATERM_814033F0 initial 65.868614%
- option fields retain converted word width: 67.39416%; src 0x214 base 0x224 insns 133/137; --- replace mine 5:6 base 5:6; M 5 addi r30, r3, 8; B 5 addi r29, r3, 8
- bottom-tested parser dispatch: 65.79562%; src 0x21c base 0x224 insns 135/137; --- replace mine 5:6 base 5:6; M 5 addi r28, r3, 8; B 5 addi r29, r3, 8
- signed nibble comparisons: 65.32117%; src 0x21c base 0x224 insns 135/137; --- insert mine 7:7 base 7:8; B 7 li r24, 0; --- replace mine 10:29 base 11:17
Retained best candidate
ATERM_814036D8 initial 73.92742%
- security switch matches original decision tree: 85.22581%; src 0x1ec base 0x1f0 insns 123/124; --- replace mine 14:15 base 14:15; M 14 beq 340; B 14 beq 344
- key text passed through one cursor: 87.0%; src 0x1e4 base 0x1f0 insns 121/124; --- replace mine 14:24 base 14:16; M 14 bne 36; M 15 addi r3, r25, 0
- counted loop over key records: 73.92742%; src 0x1e0 base 0x1f0 insns 120/124; --- replace mine 14:24 base 14:16; M 14 bne 36; M 15 addi r3, r25, 0
Retained best candidate
ATERM_814038C8 initial 35.28917%
- one-shot 500ms wait replaces repeated alarm: 35.700314%; src 0x788 base 0xedc insns 482/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0xe0(r1); B 0 stwu r1, -0x180(r1)
- bottom-tested state machine and wait buffer order: 35.288116%; src 0x784 base 0xedc insns 481/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0xe0(r1); B 0 stwu r1, -0x180(r1)
- progress uses semantic structure: 35.28917%; src 0x784 base 0xedc insns 481/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0xe0(r1); B 0 stwu r1, -0x180(r1)
Retained best candidate
ATERM_81404844 initial 19.615385%
- complete RFC3394 block handling with target initial value and byte counter: 89.89744%; src 0x1bc base 0x1d4 insns 111/117; --- replace mine 6:13 base 6:13; M 6 lwz r8, 0(0); M 7 lwz r0, 0(0)
- hoist signed pass product outside block loop: 89.89744%; src 0x1bc base 0x1d4 insns 111/117; --- replace mine 6:13 base 6:13; M 6 lwz r8, 0(0); M 7 lwz r0, 0(0)
- natural bytewise counter XOR loop: 62.299145%; src 0x178 base 0x1d4 insns 94/117; --- replace mine 6:13 base 6:13; M 6 lwz r8, 0(0); M 7 lwz r0, 0(0)
Retained best candidate
ATERM_81404A18 initial 51.107437%
- complete RFC3394 block handling with target initial value and byte counter: 74.38843%; src 0x1c0 base 0x1e4 insns 112/121; --- replace mine 6:13 base 6:14; M 6 lwz r8, 0(0); M 7 lwz r0, 0(0)
- hoist signed pass product outside block loop: 74.38843%; src 0x1c0 base 0x1e4 insns 112/121; --- replace mine 6:13 base 6:14; M 6 lwz r8, 0(0); M 7 lwz r0, 0(0)
- natural bytewise counter XOR loop: 55.96694%; src 0x180 base 0x1e4 insns 96/121; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x190(r1); B 0 stwu r1, -0x1a0(r1)
Retained best candidate
ATERM_81404BFC initial 36.869404%
- complete AES schedules with bounded final expansion for all three key sizes: 52.50746%; src 0x408 base 0x430 insns 258/268; --- replace mine 0:6 base 0:20; M 0 lbz r7, 1(r4); M 1 cmplwi r5, 0x80
- direct expanded-key parameter used as advancing cursor: 52.50746%; src 0x408 base 0x430 insns 258/268; --- replace mine 0:6 base 0:20; M 0 lbz r7, 1(r4); M 1 cmplwi r5, 0x80
- round limit at loop bottom for 128-bit key: 53.074627%; src 0x404 base 0x430 insns 257/268; --- replace mine 0:6 base 0:20; M 0 lbz r7, 1(r4); M 1 cmplwi r5, 0x80
Retained best candidate
ATERM_8140502C initial 35.666668%
- interleaved key-word swaps: 42.355072%; src 0x280 base 0x228 insns 160/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0
- signed indexed round reversal: 38.746376%; src 0x290 base 0x228 insns 164/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0
- counted transformation loop: 11.731884%; src 0x288 base 0x228 insns 162/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0
Retained best candidate
ATERM_81405254 initial 30.464945%
- AES byte assembly uses XOR: 34.23247%; src 0x3c4 base 0x43c insns 241/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- two-round loop with final round exit: compile failed
- signed round count with separately combined key XOR: compile failed
Retained best candidate
ATERM_81405690 initial 26.601477%
- AES byte assembly uses XOR: 34.64945%; src 0x3d4 base 0x43c insns 245/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- two-round loop with final round exit: compile failed
- signed round count with separately combined key XOR: compile failed
Retained best candidate
ATERM_81405254 initial 34.23247%
- two-round AES loop with final round exit matching target structure: 16.295202%; src 0x4a8 base 0x43c insns 298/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- signed remaining round-pair count: 16.295202%; src 0x4a8 base 0x43c insns 298/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- separate round exit before key advancement: 17.630997%; src 0x4a8 base 0x43c insns 298/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
Retained best candidate
ATERM_81405690 initial 34.64945%
- two-round AES loop with final round exit matching target structure: 33.738007%; src 0x4c8 base 0x43c insns 306/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- signed remaining round-pair count: 33.738007%; src 0x4c8 base 0x43c insns 306/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
- separate round exit before key advancement: 31.90037%; src 0x4c8 base 0x43c insns 306/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1)
Retained best candidate
ATERM_81405D0C initial 32.62639%
- complete MD5 accumulator rotation with per-step argument-relative selectors: 53.851387%; src 0xa50 base 0xb40 insns 660/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1)
- MD5 selectors expressed as XOR masks: 44.879166%; src 0xa48 base 0xb40 insns 658/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1)
- natural sixteen-word little-endian block decode: 47.679165%; src 0x970 base 0xb40 insns 604/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1)
Retained best candidate
ATERMi_ApConfigGetState initial 99.42857%
- read bus clock before current time call: 72.942856%; src 0x94 base 0x8c insns 37/35; --- replace mine 4:6 base 4:5; M 4 stw r30, 8(r1); M 5 mr r30, r3
- direct timer division using clock conversion expression: 99.42857%; src 0x8c base 0x8c insns 35/35; diffs 3: [17, 18, 20]; 17 M lwz r6, 0xf8(r6); B lwz r0, 0xf8(r6)
- timer load narrowed to native clock register width: 99.42857%; src 0x8c base 0x8c insns 35/35; diffs 4: [15, 16, 17, 18]; 15 M lis r5, -0x8000; B lis r6, -0x8000
Retained best candidate
ATERM_81402E40 initial 99.791664%
- checksum terminal pointer declared before byte length: 99.791664%; src 0x180 base 0x180 insns 96/96; diffs 4: [9, 10, 47, 52]; 9 M mr r29, r7; B mr r3, r27
- payload encryption size retained as signed integer: 99.791664%; src 0x180 base 0x180 insns 96/96; diffs 4: [9, 10, 47, 52]; 9 M mr r29, r7; B mr r3, r27
- end pointer assigned only after header conversion: 94.947914%; src 0x180 base 0x180 insns 96/96; diffs 8: [9, 10, 42, 44, 45, 46, 47, 52]; 9 M mr r29, r7; B mr r3, r27
Retained best candidate
ATERMi_AutoConfigThread initial 94.6%
- callback progress uses three-field structure: 94.75%; src 0xa0 base 0xa0 insns 40/40; diffs 3: [20, 22, 23]; 20 M nor r0, r3, r0; B nor r3, r3, r0
- signed completion state mask in correctly sized progress buffer: 94.75%; src 0xa0 base 0xa0 insns 40/40; diffs 3: [20, 22, 23]; 20 M nor r0, r3, r0; B nor r3, r3, r0
- explicit completion state branch in progress structure: 85.25%; src 0x9c base 0xa0 insns 39/40; --- replace mine 18:21 base 18:22; M 18 addi r0, r31, -1; M 19 li r5, -1
Retained best candidate
ATERM_814021BC initial 67.655846%
- interface configuration pointer initialized before IP setup: 64.266235%; src 0x264 base 0x268 insns 153/154; --- replace mine 7:8 base 7:8; M 7 addi r28, r30, 0; B 7 addi r30, r30, 0
- wait queue message and buffer order follows target stack slots: 67.64286%; src 0x264 base 0x268 insns 153/154; --- insert mine 7:7 base 7:9; B 7 addi r30, r30, 0; B 8 li r4, 0
- host wait expressed as while with shared converted host value: 92.77922%; src 0x274 base 0x268 insns 157/154; --- replace mine 5:8 base 5:8; M 5 lis r31, 0; M 6 li r28, 0
Retained best candidate
ATERM_8140276C initial 92.10345%
- previous-record cursor reset at outer loop tail and scoped fallback flags: 94.04023%; src 0x2b0 base 0x2b8 insns 172/174; --- replace mine 5:11 base 5:13; M 5 mr r25, r3; M 6 mr r26, r4
- previous record initialized before current record: 94.0115%; src 0x2b0 base 0x2b8 insns 172/174; --- replace mine 5:11 base 5:13; M 5 mr r25, r3; M 6 mr r26, r4
- fallback flags set after SSID clear: 94.04023%; src 0x2b0 base 0x2b8 insns 172/174; --- replace mine 5:11 base 5:13; M 5 mr r25, r3; M 6 mr r26, r4
Retained best candidate
ATERM_81405ACC initial 0%
- complete two-phase update copy with target eight-byte group bounds: 55.54861%; src 0x21c base 0x240 insns 135/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:7 base 4:10
- signed byte-copy loop cursors: 55.54861%; src 0x21c base 0x240 insns 135/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:7 base 4:10
- cursor-pair copies instead of repeated indexed addresses: 55.54861%; src 0x21c base 0x240 insns 135/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:7 base 4:10
Retained best candidate
Retained complete update implementation: objdiff 55.54861%, 135/144 instructions. Older source had no reported function score; no exact claim.
ATERMi_ApConfigStart initial 86.49515%
- allocate via stored callback: 86.49515%; src 0x1a4 base 0x19c insns 105/103; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x30(r1); B 0 stwu r1, -0x20(r1)
- tick multiplier commutes operands: 84.11651%; src 0x1a4 base 0x19c insns 105/103; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x30(r1); B 0 stwu r1, -0x20(r1)
- progress callback loaded from installed function pointer: 93.718445%; src 0x1a0 base 0x19c insns 104/103; --- delete mine 4:5 base 4:4; M 4 mr r31, r3; --- replace mine 6:7 base 5:6
Retained best candidate
ATERMi_ApConfigEnd initial 87.54263%
- message queues declared within their wait scopes: 85.496124%; src 0x1dc base 0x204 insns 119/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0
- join loop expressed as do-while: 85.28682%; src 0x1e8 base 0x204 insns 122/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0
- time conversion evaluated directly: 87.54263%; src 0x1dc base 0x204 insns 119/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0
Retained best candidate
ATERM_81402FC0 initial 67.28148%
- signed option payload cursor length: no source change; skipped
- checksum receive pointer read after length decode: 67.28148%; src 0x210 base 0x21c insns 132/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
- option traversal explicit continuation: 67.28148%; src 0x210 base 0x21c insns 132/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
Retained best candidate
ATERM_81402A24 initial 75.76426%
- record allocation size held as size_t: no source change; skipped
Retained best candidate
ATERM_81402FC0 initial 67.28148%
- packet and option values stay full-width until usage: 68.577774%; src 0x208 base 0x21c insns 130/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- delete mine 15:16 base 16:16
- full-width checksum accumulated before explicit final narrowing: 67.28148%; src 0x210 base 0x21c insns 132/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
- option lengths retained as signed word count: 67.28148%; src 0x210 base 0x21c insns 132/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- replace mine 9:10 base 10:11
Retained best candidate
ATERM_81402A24 initial 75.76426%
- record allocation byte count stored in size_t: 75.76426%; src 0x3f4 base 0x41c insns 253/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
- iteration counter narrowed to signed timer range: 76.20532%; src 0x3f4 base 0x41c insns 253/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
- record pointer walk and indexed record walk share cursor: 75.76426%; src 0x3f4 base 0x41c insns 253/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1)
Retained best candidate
ATERM reconstruction evidence: all 26 target function names have source bodies. Reconstructed RFC3394 wrap/unwrap initial value, signed counters, block writeback and unwrap ordering; corrected all three AES key schedules; corrected MD5 per-step accumulator/selector semantics and low/high bit counts; reconstructed the missing authentication timestamp digest and protocol option-id bytes in the main state machine. These are partial instruction matches, not completion.
Native validation of extracted unchanged crypto implementations: NIST AES 128/192/256 encryption and decryption vectors passed. MD5 messages of length 0, 1, 3, 55, 56, 64, 130 matched hashlib. Native correctness is supplemental evidence only; MWCC objdiff remains the matching authority.
Data attempts: ordinary local option-id initialization restored the real seven-byte constant sequence; .sdata2 reached 100%. Genuine MD5 fill array emitted locally, then as an ordinary named global after the state-machine function to preserve jump-table/source order. .data remains incomplete because the three generated jump tables still differ. AES tables and round constants remain byte-identical .rodata.
Data attempt: restored the genuine request-options pointer initializer shown in target .sdata; it completed .sdata but moved the response buffer before the thread in .bss and caused objdiff .bss 100 -> 83.33333 and a matched-data regression. Tried source declaration order, original thread name, and original section-aligned network buffer declaration; none passed the regression gate. Restored the pointer attempt and kept the existing BSS layout. No artificial padding, address symbols, or forced sections retained. .sdata and .sbss remain open.
Initial AOSS trial batch failed to compile because of a mistaken message-length field name in the packet dispatcher; corrected the field and reran all trials successfully. Failed batch not counted as attempts.
AOSS_Init_old initial 28.42298%
- full-width wait counters instead of narrowing every update: 28.546717%; src 0x1758 base 0x18c0 insns 1494/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b
- packet length conversion retains full width: 28.42298%; src 0x1794 base 0x18c0 insns 1509/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b
- poll arguments given semantic socket events structure: 28.42298%; src 0x1794 base 0x18c0 insns 1509/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b
Retained best candidate
AOSS_813FFD68 initial 96.981735%
- validation loops use signed char: 93.69406%; src 0x364 base 0x36c insns 217/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
- return failure immediately on invalid character: 82.05023%; src 0x2ec base 0x36c insns 187/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
- ascending validation cursor loop: 94.76712%; src 0x374 base 0x36c insns 221/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
Retained best candidate
AOSS_814001B4 initial 88.78481%
- converted packet length stays full width: 88.78481%; src 0x12c base 0x13c insns 75/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
- direct opcode return cases: 83.27848%; src 0x124 base 0x13c insns 73/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
- full-width validation and branch nesting: no source change; skipped
Retained best candidate
AOSS_814002F0 initial 79.525%
- read manufacturer only after state validation: 85.058334%; src 0x1c4 base 0x1e0 insns 113/120; --- replace mine 6:8 base 6:8; M 6 mr r30, r3; M 7 mr r26, r4
- packet sequence values remain full-width: 76.441666%; src 0x1c4 base 0x1e0 insns 113/120; --- replace mine 5:7 base 5:8; M 5 mr r30, r3; M 6 mr r26, r4
- direct address error branch: 79.525%; src 0x1c8 base 0x1e0 insns 114/120; --- replace mine 5:7 base 5:8; M 5 mr r30, r3; M 6 mr r26, r4
Retained best candidate
AOSS_81400830 initial 77.619934%
- single-byte RC4 generation loop instead of manual pairs: 65.65109%; src 0x3c0 base 0x504 insns 240/321; --- insert mine 6:6 base 6:7; B 6 addi r29, r3, 0x18; --- insert mine 7:7 base 8:9
- natural CRC byte loop: 60.13084%; src 0x3c4 base 0x504 insns 241/321; --- replace mine 5:6 base 5:7; M 5 mr r27, r3; B 5 mr r26, r3
- narrow RC4 state indices at assignment: 77.619934%; src 0x4b8 base 0x504 insns 302/321; --- insert mine 6:6 base 6:7; B 6 addi r29, r3, 0x18; --- insert mine 7:7 base 8:9
Retained best candidate
AOSS_81400E0C initial 77.52105%
- signed option lengths and iteration indices: 77.778946%; src 0x2bc base 0x2f8 insns 175/190; --- insert mine 5:5 base 5:6; B 5 mr r29, r4; --- replace mine 6:8 base 7:8
- natural integer byte decode for both address options: 44.963158%; src 0x188 base 0x2f8 insns 98/190; --- insert mine 5:5 base 5:6; B 5 mr r29, r4; --- replace mine 6:8 base 7:8
- address decode accumulation uses OR: 61.963158%; src 0x284 base 0x2f8 insns 161/190; --- replace mine 5:8 base 5:8; M 5 mr r29, r3; M 6 mr r30, r4
Retained best candidate
AOSS_814013AC initial 91.70175%
- signed option lengths: 91.70175%; src 0x1cc base 0x1c8 insns 115/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
- apply flags after successful parser call: 84.68421%; src 0x1ec base 0x1c8 insns 123/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
- bounded while loop over selected reply payload: 88.2807%; src 0x1d4 base 0x1c8 insns 117/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
Retained best candidate
AOSS_81401574 initial 92.558136%
- semantic payload extent expression: 92.558136%; src 0x1fc base 0x204 insns 127/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4
- request length remains full-width: 92.209305%; src 0x1f8 base 0x204 insns 126/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4
- initialize destination length before port conversion: 88.31783%; src 0x1fc base 0x204 insns 127/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4
Retained best candidate
AOSS_81401778 initial 71.93407%
- CRC checksum stays full width until header store: 71.93407%; src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0)
- signed RC4 byte loop index: 71.93407%; src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0)
- copy hello payload before manufacturer encoding: 71.91575%; src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0)
Retained best candidate
AOSS_81401C9C initial 71.9315%
- natural RC4 state initialization loop: 43.342464%; src 0x98 base 0x124 insns 38/73; --- replace mine 0:1 base 0:2; M 0 li r9, 0; B 0 stwu r1, -0x10(r1)
- schedule state reset before obtaining byte pointer: 71.9315%; src 0x12c base 0x124 insns 75/73; --- replace mine 0:6 base 0:2; M 0 stwu r1, -0x20(r1); M 1 mflr r0
- signed key and state indices: 71.9315%; src 0x12c base 0x124 insns 75/73; --- replace mine 0:6 base 0:2; M 0 stwu r1, -0x20(r1); M 1 mflr r0
Retained best candidate
AOSS_81401E80 initial 91.80272%
- natural XOR loop over half-packet: 56.455784%; src 0x168 base 0x24c insns 90/147; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x30(r1); B 0 stwu r1, -0x40(r1)
- half-length via signed division: 87.04082%; src 0x240 base 0x24c insns 144/147; --- replace mine 5:19 base 5:13; M 5 srawi r0, r4, 1; M 6 mr r28, r3
- count-down rounds: 88.734695%; src 0x244 base 0x24c insns 145/147; --- replace mine 6:7 base 6:7; M 6 mr r28, r3; B 6 mr r21, r3
Retained best candidate
AOSS_814020CC initial 76.066666%
- sleep tick product stays 64-bit: 67.51667%; src 0xfc base 0xf0 insns 63/60; --- replace mine 3:6 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
- tick duration via explicit multiply-high: 81.65%; src 0xe4 base 0xf0 insns 57/60; --- replace mine 3:5 base 3:6; M 3 addi r11, r1, 0x20; M 4 bl 0
- do-while host acquisition loop: 65.066666%; src 0xf8 base 0xf0 insns 62/60; --- replace mine 3:6 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0
Retained best candidate
AOSS_81401DC0 initial 99.375%
- CRC output accumulator reuses incoming seed value: 99.375%; src 0xc0 base 0xc0 insns 48/48; diffs 4: [39, 41, 42, 43]; 39 M srwi r0, r3, 1; B srwi r3, r3, 1
- last CRC bit combined with conditional polynomial: 80.916664%; src 0xc8 base 0xc0 insns 50/48; --- delete mine 0:1 base 0:0; M 0 lis r3, -0x1247; --- replace mine 2:4 base 1:2
- ordinary counted loop for eight CRC polynomial steps: 24.833334%; src 0x40 base 0xc0 insns 16/48; --- insert mine 0:0 base 0:1; B 0 li r0, 0x100; --- delete mine 1:3 base 2:2
Retained best candidate
AOSS_Init_old initial 28.546717%
- network settings alignment follows target 32-byte stack contract: 24.69697%; src 0x17f8 base 0x18c0 insns 1534/1584; --- replace mine 8:9 base 8:11; M 8 li r14, 0; B 8 lhz r4, 0(0)
- request records alignment follows target stack offset a0: 24.69697%; src 0x17f8 base 0x18c0 insns 1534/1584; --- replace mine 8:9 base 8:11; M 8 li r14, 0; B 8 lhz r4, 0(0)
- both network settings and request records use observed stack alignment: 24.69697%; src 0x17f8 base 0x18c0 insns 1534/1584; --- replace mine 8:9 base 8:11; M 8 li r14, 0; B 8 lhz r4, 0(0)
Retained best candidate
AOSS_814001B4 initial 88.78481%
- opcode uses full-width switch expression after conversion: 88.78481%; src 0x12c base 0x13c insns 75/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
- rejection increments written as explicit count stores: 88.78481%; src 0x12c base 0x13c insns 75/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
- validation represented by a named result before rejection: 88.78481%; src 0x12c base 0x13c insns 75/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0
Retained best candidate
AOSS_814013AC initial 91.70175%
- outer response stride evaluated once before cursor advancement: 91.70175%; src 0x1cc base 0x1c8 insns 115/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
- one option cursor serves outer and inner traversal: 91.70175%; src 0x1cc base 0x1c8 insns 115/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
- config flags initialization delayed until matching response is located: 89.60526%; src 0x1cc base 0x1c8 insns 115/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8
Retained best candidate
AOSS .sbss source-order reconstruction: moved real existing address/status declarations into original address order; 28.57143 -> 57.14286.
- explicit zero initialization of owned pointer globals: 42.857143%; original source restored if no improvement.
- explicit zero initialization of runtime status globals: 57.14286%; original source restored if no improvement.
- ordinary zero initialization of access-point address bytes: 28.57143%; original source restored if no improvement.
AOSS dispatch reconstruction: rejected empty/type/validation failures return immediately and opcode dispatch uses a switch; 41.518986 -> 88.78481%, 75/79 instructions. Remaining four instructions are prologue/epilogue save helpers versus individual register saves; three additional real source variations did not change them.
AOSS_Init_old has a body for every observed state path; six distinct attempts logged. Restored narrow wait counters despite a small fuzzy gain from widening, because the original performs signed 16-bit wrapping assignments. Observed 32-byte stack alignment trials all worsened codegen and were restored. Renamed existing decompiler labels to meaningful state/cleanup names.
AOSS .data/.bss/.sdata/.sdata2 remain 100%; ordinary source declaration reordering improves .sbss to 57.14286 but does not finish its symbol associations. Three normal initialization forms produced no further improvement and were restored. No forced sections, padding, address-pinning symbols, or table blobs added.
Current handoff: remaining functions and instruction evidence
ATERM_814021BC 92.77922%: src 0x274 base 0x268 insns 157/154; --- replace mine 5:8 base 5:8; M 5 lis r31, 0; M 6 li r28, 0; M 7 addi r3, r31, 0
ATERM_8140276C 94.04023%: src 0x2b0 base 0x2b8 insns 172/174; --- replace mine 5:11 base 5:13; M 5 mr r25, r3; M 6 mr r26, r4; M 7 mr r27, r5
ATERM_81402A24 76.20532%: src 0x3f4 base 0x41c insns 253/263; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x80(r1); B 0 stwu r1, -0x90(r1); --- replace mine 2:4 base 2:4
ATERM_81402E40 99.791664%: src 0x180 base 0x180 insns 96/96; diffs 4: [9, 10, 47, 52]; 9 M mr r29, r7; B mr r3, r27; 10 M mr r3, r27
ATERM_81402FC0 68.577774%: src 0x208 base 0x21c insns 130/135; --- insert mine 8:8 base 8:9; B 8 li r31, 0; --- delete mine 15:16 base 16:16; M 15 li r31, 0
ATERM_814031DC 85.90225%: src 0x1f4 base 0x214 insns 125/133; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x70(r1); B 0 stwu r1, -0x60(r1); --- replace mine 4:6 base 4:6
ATERM_814033F0 67.39416%: src 0x214 base 0x224 insns 133/137; --- replace mine 5:6 base 5:6; M 5 addi r30, r3, 8; B 5 addi r29, r3, 8; --- insert mine 7:7 base 7:8
ATERM_814036D8 87.0%: src 0x1e4 base 0x1f0 insns 121/124; --- replace mine 14:24 base 14:16; M 14 bne 36; M 15 addi r3, r25, 0; M 16 li r0, 4
ATERM_814038C8 41.043114%: src 0x9b4 base 0xedc insns 621/951; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x140(r1); B 0 stwu r1, -0x180(r1); --- replace mine 2:4 base 2:4
ATERMi_AutoConfigThread 94.75%: src 0xa0 base 0xa0 insns 40/40; diffs 3: [20, 22, 23]; 20 M nor r0, r3, r0; B nor r3, r3, r0; 22 M srawi r3, r0, 0x1f
ATERM_81404844 92.62393%: src 0x1bc base 0x1d4 insns 111/117; --- replace mine 8:13 base 8:13; M 8 mr r29, r3; M 9 mr r22, r4; M 10 mr r23, r5
ATERM_81404A18 75.82645%: src 0x1c0 base 0x1e4 insns 112/121; --- replace mine 8:13 base 8:14; M 8 mr r29, r3; M 9 mr r21, r4; M 10 mr r22, r5
ATERM_81404BFC 74.36194%: src 0x46c base 0x430 insns 283/268; --- replace mine 6:7 base 6:7; M 6 cmplwi r5, 0x80; B 6 cmpwi r5, 0x80; --- delete mine 38:40 base 38:38
ATERM_8140502C 42.355072%: src 0x280 base 0x228 insns 160/138; --- insert mine 5:5 base 5:8; B 5 stw r30, 8(r1); B 6 lis r30, 0; B 7 addi r30, r30, 0
ATERM_81405254 34.23247%: src 0x3c4 base 0x43c insns 241/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1); --- replace mine 2:4 base 2:4
ATERM_81405690 34.64945%: src 0x3d4 base 0x43c insns 245/271; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x40(r1); B 0 stwu r1, -0x50(r1); --- replace mine 2:4 base 2:4
ATERM_81405ACC 55.54861%: src 0x21c base 0x240 insns 135/144; --- insert mine 2:2 base 2:3; B 2 slwi r7, r5, 3; --- replace mine 3:7 base 4:10; M 3 addi r11, r1, 0x20
ATERM_81405D0C 53.851387%: src 0xa50 base 0xb40 insns 660/720; --- replace mine 0:1 base 0:1; M 0 stwu r1, -0x90(r1); B 0 stwu r1, -0xa0(r1); --- replace mine 2:4 base 2:4
ATERMi_ApConfigStart 93.718445%: src 0x1a0 base 0x19c insns 104/103; --- delete mine 4:5 base 4:4; M 4 mr r31, r3; --- replace mine 6:7 base 5:6; M 6 mr r30, r8
ATERMi_ApConfigEnd 87.54263%: src 0x1dc base 0x204 insns 119/129; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0xe0; M 4 bl 0; B 3 stw r31, 0xdc(r1)
ATERMi_ApConfigGetState 99.42857%: src 0x8c base 0x8c insns 35/35; diffs 3: [17, 18, 20]; 17 M lwz r6, 0xf8(r6); B lwz r0, 0xf8(r6); 18 M addi r0, r5, 0x4dd3
AOSS_Init_old 28.42298%: src 0x1794 base 0x18c0 insns 1509/1584; --- replace mine 0:1 base 0:4; M 0 stwu r1, -0x100(r1); B 0 clrlwi r11, r1, 0x1b; B 1 mr r12, r1
AOSS_813FFD68 96.981735%: src 0x364 base 0x36c insns 217/219; --- replace mine 3:5 base 3:7; M 3 addi r11, r1, 0x20; M 4 bl 0; B 3 stw r31, 0x1c(r1)
AOSS_814001B4 88.78481%: src 0x12c base 0x13c insns 75/79; --- replace mine 3:5 base 3:10; M 3 addi r11, r1, 0x20; M 4 bl 0; B 3 stw r31, 0x1c(r1)
AOSS_814002F0 85.058334%: src 0x1c4 base 0x1e0 insns 113/120; --- replace mine 6:8 base 6:8; M 6 mr r30, r3; M 7 mr r26, r4; B 6 mr r26, r3
AOSS_81400830 77.619934%: src 0x4b8 base 0x504 insns 302/321; --- insert mine 6:6 base 6:7; B 6 addi r29, r3, 0x18; --- insert mine 7:7 base 8:9; B 8 li r5, 8
AOSS_81400E0C 77.778946%: src 0x2bc base 0x2f8 insns 175/190; --- insert mine 5:5 base 5:6; B 5 mr r29, r4; --- replace mine 6:8 base 7:8; M 6 mr r29, r4
AOSS_814013AC 91.70175%: src 0x1cc base 0x1c8 insns 115/114; --- insert mine 6:6 base 6:7; B 6 mr r27, r3; --- delete mine 7:8 base 8:8; M 7 mr r27, r3
AOSS_81401574 92.558136%: src 0x1fc base 0x204 insns 127/129; --- replace mine 5:7 base 5:7; M 5 lwz r30, 0(0); M 6 mr r27, r4; B 5 lwz r27, 0(0)
AOSS_81401778 71.93407%: src 0x434 base 0x444 insns 269/273; --- replace mine 5:7 base 5:6; M 5 lis r31, 0; M 6 lwz r30, 0(0); B 5 lwz r28, 0(0)
AOSS_81401C9C 71.9315%: src 0x12c base 0x124 insns 75/73; --- replace mine 0:6 base 0:2; M 0 stwu r1, -0x20(r1); M 1 mflr r0; M 2 stw r0, 0x24(r1)
AOSS_81401DC0 99.375%: src 0xc0 base 0xc0 insns 48/48; diffs 4: [39, 41, 42, 43]; 39 M srwi r0, r3, 1; B srwi r3, r3, 1; 41 M xoris r0, r0, 0xedb8
AOSS_81401E80 91.80272%: src 0x244 base 0x24c insns 145/147; --- replace mine 6:7 base 6:7; M 6 mr r28, r3; B 6 mr r21, r3; --- replace mine 8:20 base 8:13
AOSS_814020CC 81.65%: src 0xe4 base 0xf0 insns 57/60; --- replace mine 3:5 base 3:6; M 3 addi r11, r1, 0x20; M 4 bl 0; B 3 stw r31, 0x1c(r1)
Supplemental native crypto validation: NIST AES-128/192/256 encrypt/decrypt vectors passed; MD5 lengths 0, 1, 3, 55, 56, 64, 130 and streaming chunks 1, 7, 55, 63, 64, 65, 127 over 512 bytes passed against hashlib. RFC3394 wrap/unwrap passed using a temporary native test copy that explicitly emulates Wii big-endian counter bytes; unchanged x86 union byte order does not emulate the target. Tests reside under /tmp; MWCC object and gate remain matching authority.

View File

@@ -11,23 +11,12 @@ splits: 'config/43U/splits.txt'
ldscript_template: 'config/ldscript_ipl2.lcf'
force_active:
- fprintf
- leap_days
- __msl_time2tm
- __tm2time
- clock
- mktime
- localtime
- emit
- __MSL_ISO8601NewYear
- __MSL_ISO8601Week
- strftime
- labs
- atol
- itoa
- strpbrk
- strspn
- strcspn
- atol
- padding__Q23ipl5scene
- lbl_81695063
- lbl_81695067

View File

@@ -1054,7 +1054,7 @@ src/keyboard/tiNw4rManager.cpp:
.data start:0x8165F818 end:0x8165F8F0
.sdata2 start:0x81694E10 end:0x81694E28
src/keyboard/tiKeyboard.cpp:
src/keyboard/tiManager.cpp:
.text start:0x81437558 end:0x81439608
.ctors start:0x8160D208 end:0x8160D20C
.data start:0x8165F8F0 end:0x81660378

View File

@@ -878,8 +878,8 @@ config.libs = [
Object(Matching, "scene/setting/iplAOSSThread.cpp"),
Object(NonMatching, "scene/setting/AOSSLink.c"),
Object(NonMatching, "scene/setting/iplRakuRakuThread.cpp"),
Object(NonMatching, "scene/setting/AOSS.c", extra_cflags=["-O4,p", "-inline off"]),
Object(NonMatching, "scene/setting/ATERM.c", extra_cflags=["-O4,p", "-inline off"]),
Object(NonMatching, "scene/setting/AOSS.c"),
Object(NonMatching, "scene/setting/ATERM.c"),
]
),
IPLSection("settingSelect", [
@@ -920,7 +920,7 @@ config.libs = [
Object(NonMatching, "keyboard/tiZiString.cpp", extra_cflags=["-O4,p"]), # for 4.3U and 4.3E
Object(NonMatching, "keyboard/tiTextDrawer.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiNw4rManager.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiKeyboard.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiManager.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiUtil.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiCpData.cpp", extra_cflags=["-O4,p"], shift_jis=False),
Object(Matching, "keyboard/tiSwData.cpp", extra_cflags=["-O4,p"], shift_jis=False),
@@ -1037,7 +1037,7 @@ config.libs = [
),
RevoEXLib("ncd", [
Object(Matching, "ncd/ncdsystem.c"),
Object(Matching, "ncd/ncdsleep.c"),
Object(NonMatching, "ncd/ncdsleep.c"),
]
),
RevoEXLib("net", [
@@ -1091,7 +1091,7 @@ config.libs = [
Object(Matching, "nwc24/NWC24Ipc.c"),
Object(Equivalent, "nwc24/NWC24Download.c"),
Object(Matching, "nwc24/NWC24CHJump.c"),
Object(Matching, "nwc24/NWC24System.c"),
Object(NonMatching, "nwc24/NWC24System.c"),
]
),
RevoEXLib("so", [
@@ -1389,8 +1389,8 @@ config.libs = [
),
RVLSDKLib("vi", [
Object(NonMatching, "vi/vi.c"),
Object(Matching, "vi/i2c.c"),
Object(Matching, "vi/vi3in1.c"),
Object(NonMatching, "vi/i2c.c"),
Object(NonMatching, "vi/vi3in1.c"),
]
),
RVLSDKLib("mtx", [
@@ -1448,10 +1448,10 @@ config.libs = [
Object(Matching, "axfx/AXFXReverbHi.c"),
Object(Matching, "axfx/AXFXReverbHiDpl2.c"),
Object(Matching, "axfx/AXFXReverbHiExp.c"),
Object(Matching, "axfx/AXFXReverbHiExpDpl2.c"),
Object(NonMatching, "axfx/AXFXReverbHiExpDpl2.c"),
Object(Matching, "axfx/AXFXDelay.c"),
Object(Matching, "axfx/AXFXReverbStd.c"),
Object(Matching, "axfx/AXFXReverbStdExp.c"),
Object(NonMatching, "axfx/AXFXReverbStdExp.c"),
Object(Matching, "axfx/AXFXChorus.c"),
Object(NonMatching, "axfx/AXFXChorusExp.c"),
Object(Matching, "axfx/AXFXLfoTable.c"),
@@ -1552,7 +1552,7 @@ config.libs = [
),
RVLSDKLib("wpad", [
Object(Matching, "wpad/WPAD.c"),
Object(Matching, "wpad/WPADHIDParser.c"),
Object(NonMatching, "wpad/WPADHIDParser.c"),
Object(Matching, "wpad/WPADMem.c"),
Object(Matching, "wpad/WPADEncrypt.c"),
Object(Matching, "wpad/debug_msg.c"),
@@ -1682,11 +1682,11 @@ config.libs = [
]
),
RVLSDKLib("fa", [
Object(Matching, "fa/pf_clib.c"),
Object(Matching, "fa/pf_code.c"),
Object(Matching, "fa/pf_service.c"),
Object(Matching, "fa/pf_str.c"),
Object(Matching, "fa/pf_driver.c"),
Object(NonMatching, "fa/pf_clib.c"),
Object(NonMatching, "fa/pf_code.c"),
Object(NonMatching, "fa/pf_service.c"),
Object(NonMatching, "fa/pf_str.c"),
Object(NonMatching, "fa/pf_driver.c"),
Object(NonMatching, "fa/pdm_api.c"),
Object(NonMatching, "fa/pdm_bpb.c"),
Object(NonMatching, "fa/pdm_disk.c"),
@@ -1694,7 +1694,7 @@ config.libs = [
Object(NonMatching, "fa/pf_cache.c"),
Object(NonMatching, "fa/pf_cluster.c"),
Object(NonMatching, "fa/pf_dir.c"),
Object(Matching, "fa/pf_entry.c"),
Object(NonMatching, "fa/pf_entry.c"),
Object(NonMatching, "fa/pf_entry_iterator.c"),
Object(NonMatching, "fa/pf_fat.c"),
Object(NonMatching, "fa/pf_fat12.c"),
@@ -1708,7 +1708,7 @@ config.libs = [
Object(NonMatching, "fa/pf_volume_apiadd.c"),
Object(NonMatching, "fa/pf_cp932.c"),
Object(Matching, "fa/pf_api_util.c"),
Object(Matching, "fa/pf_attach.c"),
Object(NonMatching, "fa/pf_attach.c"),
Object(NonMatching, "fa/pf_buffering.c"),
Object(NonMatching, "fa/pf_cdelete.c"),
Object(NonMatching, "fa/pf_chdir.c"),
@@ -1721,7 +1721,7 @@ config.libs = [
Object(NonMatching, "fa/pf_createdir.c"),
Object(NonMatching, "fa/pf_cut.c"),
Object(NonMatching, "fa/pf_derrnum.c"),
Object(Matching, "fa/pf_detach.c"),
Object(NonMatching, "fa/pf_detach.c"),
Object(NonMatching, "fa/pf_divide.c"),
Object(Matching, "fa/pf_errnum.c"),
Object(NonMatching, "fa/pf_fadjust.c"),
@@ -1733,15 +1733,15 @@ config.libs = [
Object(Matching, "fa/pf_ferror.c"),
Object(NonMatching, "fa/pf_finfo.c"),
Object(Matching, "fa/pf_flock.c"),
Object(Matching, "fa/pf_fopen.c"),
Object(NonMatching, "fa/pf_fopen.c"),
Object(NonMatching, "fa/pf_format.c"),
Object(Matching, "fa/pf_fread.c"),
Object(Matching, "fa/pf_fseek.c"),
Object(NonMatching, "fa/pf_fseek.c"),
Object(NonMatching, "fa/pf_fsetclstlink.c"),
Object(NonMatching, "fa/pf_fsexec.c"),
Object(Matching, "fa/pf_fsfirst.c"),
Object(Matching, "fa/pf_fsnext.c"),
Object(Matching, "fa/pf_fstat.c"),
Object(NonMatching, "fa/pf_fsfirst.c"),
Object(NonMatching, "fa/pf_fsnext.c"),
Object(NonMatching, "fa/pf_fstat.c"),
Object(Matching, "fa/pf_fsync.c"),
Object(Matching, "fa/pf_fwrite.c"),
Object(NonMatching, "fa/pf_getdev.c"),
@@ -1750,18 +1750,18 @@ config.libs = [
Object(NonMatching, "fa/pf_init_prfile2.c"),
Object(NonMatching, "fa/pf_insert.c"),
Object(NonMatching, "fa/pf_iswriteprotected.c"),
Object(Matching, "fa/pf_mkdir.c"),
Object(Matching, "fa/pf_mount.c"),
Object(NonMatching, "fa/pf_mkdir.c"),
Object(NonMatching, "fa/pf_mount.c"),
Object(NonMatching, "fa/pf_move.c"),
Object(Matching, "fa/pf_opendir.c"),
Object(Matching, "fa/pf_readdir.c"),
Object(NonMatching, "fa/pf_opendir.c"),
Object(NonMatching, "fa/pf_readdir.c"),
Object(NonMatching, "fa/pf_regctx.c"),
Object(Matching, "fa/pf_remove.c"),
Object(Matching, "fa/pf_rename.c"),
Object(Matching, "fa/pf_rewinddir.c"),
Object(Matching, "fa/pf_rmdir.c"),
Object(NonMatching, "fa/pf_remove.c"),
Object(NonMatching, "fa/pf_rename.c"),
Object(NonMatching, "fa/pf_rewinddir.c"),
Object(NonMatching, "fa/pf_rmdir.c"),
Object(NonMatching, "fa/pf_rmvvol.c"),
Object(Matching, "fa/pf_seekdir.c"),
Object(NonMatching, "fa/pf_seekdir.c"),
Object(NonMatching, "fa/pf_setclstlink.c"),
Object(NonMatching, "fa/pf_setcode.c"),
Object(NonMatching, "fa/pf_setencode.c"),
@@ -1770,8 +1770,8 @@ config.libs = [
Object(NonMatching, "fa/pf_setvol.c"),
Object(NonMatching, "fa/pf_setvolcfg.c"),
Object(NonMatching, "fa/pf_sync.c"),
Object(Matching, "fa/pf_telldir.c"),
Object(Matching, "fa/pf_unmount.c"),
Object(NonMatching, "fa/pf_telldir.c"),
Object(NonMatching, "fa/pf_unmount.c"),
Object(NonMatching, "fa/pf_unregctx.c"),
Object(NonMatching, "fa/pf_xdivide.c"),
Object(Matching, "fa/pf_w_api_util.c"),
@@ -1827,36 +1827,36 @@ config.libs = [
Object(NonMatching, "fa/pf_stub_unicode.c"),
Object(NonMatching, "fa/api/FAAttach.c"),
Object(Matching, "fa/api/FABuffering.c"),
Object(Matching, "fa/api/FACreate.c"),
Object(Matching, "fa/api/FACreatedir.c"),
Object(Matching, "fa/api/FADetach.c"),
Object(Matching, "fa/api/FAErrnum.c"),
Object(NonMatching, "fa/api/FABuffering.c"),
Object(NonMatching, "fa/api/FACreate.c"),
Object(NonMatching, "fa/api/FACreatedir.c"),
Object(NonMatching, "fa/api/FADetach.c"),
Object(NonMatching, "fa/api/FAErrnum.c"),
Object(Matching, "fa/api/FAFclose.c"),
Object(Matching, "fa/api/FAFinfo.c"),
Object(Matching, "fa/api/FAFopen.c"),
Object(Matching, "fa/api/FAFormat.c"),
Object(NonMatching, "fa/api/FAFopen.c"),
Object(NonMatching, "fa/api/FAFormat.c"),
Object(Matching, "fa/api/FAFread.c"),
Object(Matching, "fa/api/FAFseek.c"),
Object(Matching, "fa/api/FAFsfirst.c"),
Object(Matching, "fa/api/FAFsnext.c"),
Object(Matching, "fa/api/FAFstat.c"),
Object(NonMatching, "fa/api/FAFseek.c"),
Object(NonMatching, "fa/api/FAFsfirst.c"),
Object(NonMatching, "fa/api/FAFsnext.c"),
Object(NonMatching, "fa/api/FAFstat.c"),
Object(Matching, "fa/api/FAFwrite.c"),
Object(Matching, "fa/api/FAGetdev.c"),
Object(Matching, "fa/api/FAInit.c"),
Object(NonMatching, "fa/api/FAGetdev.c"),
Object(NonMatching, "fa/api/FAInit.c"),
Object(Matching, "fa/api/FAInitDiskManager.c"),
Object(Matching, "fa/api/FAMount.c"),
Object(Matching, "fa/api/FARegistCB.c"),
Object(Matching, "fa/api/FARemove.c"),
Object(Matching, "fa/api/FASetThreadPriority.c"),
Object(Matching, "fa/api/FAUnmount.c"),
Object(NonMatching, "fa/api/FAMount.c"),
Object(NonMatching, "fa/api/FARegistCB.c"),
Object(NonMatching, "fa/api/FARemove.c"),
Object(NonMatching, "fa/api/FASetThreadPriority.c"),
Object(NonMatching, "fa/api/FAUnmount.c"),
Object(NonMatching, "fa/kernel/pfk_api.c"),
Object(Matching, "fa/driver/nand_drv.c"),
Object(NonMatching, "fa/driver/nand_drv.c"),
Object(NonMatching, "fa/driver/sd_drv.c"),
Object(NonMatching, "fa/driver/pfd_cmn.c"),
Object(Matching, "fa/driver/msc_drv.c"),
Object(NonMatching, "fa/driver/msc_drv.c"),
Object(NonMatching, "fa/msc/puh_msc.c"),
Object(NonMatching, "fa/msc/puh_msc_cmd.c"),
@@ -1870,7 +1870,7 @@ config.libs = [
RVLSDKLib("nup", [
Object(NonMatching, "nup/nup.cpp"),
Object(NonMatching, "nup/nup_nhttp.cpp"),
Object(Matching, "nup/nup_mem.cpp"),
Object(NonMatching, "nup/nup_mem.cpp"),
]
),
RVLSDKLib("scutil", [
@@ -1944,33 +1944,33 @@ config.libs = [
Object(Matching, "MSL_Common/alloc.c"),
Object(Matching, "MSL_Common/errno.c"),
Object(Matching, "MSL_Common/ansi_files.c"),
Object(Matching, "MSL_Common_Embedded/ansi_fp.c", extra_cflags=["-Cpp_exceptions on"]),
Object(NonMatching, "MSL_Common_Embedded/ansi_fp.c"),
Object(Matching, "MSL_Common/ctype.c"),
Object(Matching, "MSL_Common/locale.c"),
Object(NonMatching, "MSL_Common/locale.c"),
Object(Matching, "MSL_Common/arith.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/bsearch.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/buffer_io.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/direct_io.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/file_io.c"),
Object(NonMatching, "MSL_Common/file_io.c"),
Object(Matching, "MSL_Common/FILE_POS.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/mbstring.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/mem.c"),
Object(Matching, "MSL_Common/mem_funcs.c"),
Object(Matching, "MSL_Common/math_api.c"),
Object(Matching, "MSL_Common/misc_io.c"),
Object(Matching, "MSL_Common/printf.c", extra_cflags=["-Cpp_exceptions on"]),
Object(NonMatching, "MSL_Common/printf.c"),
Object(Matching, "MSL_Common/qsort.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/rand.c"),
Object(Matching, "MSL_Common/scanf.c", extra_cflags=["-Cpp_exceptions on"]),
Object(NonMatching, "MSL_Common/scanf.c"),
Object(Matching, "MSL_Common/signal.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/string.c"),
Object(Matching, "MSL_Common/float.c"),
Object(Matching, "MSL_Common/strtold.c", extra_cflags=["-Cpp_exceptions on"]),
Object(NonMatching, "MSL_Common/strtold.c"),
Object(Matching, "MSL_Common/strtoul.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/time.c", extra_cflags=["-Cpp_exceptions on"]),
Object(NonMatching, "MSL_Common/time.c"),
Object(Matching, "MSL_Common/wctype.c"),
Object(Matching, "MSL_Common/wmem.c"),
Object(NonMatching, "MSL_Common/wprintf.c", extra_cflags=["-Cpp_exceptions on"]),
Object(NonMatching, "MSL_Common/wprintf.c"),
Object(Matching, "MSL_Common/wstring.c"),
Object(Matching, "MSL_Common/wchar_io.c"),
Object(Matching, "PPC_EABI/time.dolphin.c"),

View File

@@ -14,12 +14,7 @@ enum {
typedef struct BS2UpdateHeader {
char timestamp[16]; // 0x00
u32 wadCount; // 0x10
#ifdef BS2_UPDATE_SOURCE
u32 extraCount;
u32 reserved[2];
#else
u32 reserved[3]; // 0x14
#endif
} BS2UpdateHeader;
typedef struct BS2UpdateEntry {
@@ -34,12 +29,7 @@ typedef struct BS2UpdateEntry {
u64 titleId; // 0x50
u16 titleVersion; // 0x58
#ifdef BS2_UPDATE_SOURCE
u16 reservedTitle;
u32 inodes;
#else
u8 padding[6]; // 0x5A
#endif
// Update Data
char dataName[0x40]; // 0x60

View File

@@ -14,11 +14,15 @@ namespace textinput {
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
public:
LayoutByNW4R(nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* layoutBinName,
EventObserver* event)
: nw4rmanager::Layout(resAccessor, layoutBinName, event) {}
#ifdef MYTIMANAGER_IMPLEMENTATION
LayoutByNW4R(nw4r::lyt::MultiArcResourceAccessor* multiArc, const char* layoutName, EventObserver* event)
: nw4rmanager::Layout(multiArc, layoutName, event) {}
#endif
#ifdef MYTIMANAGER_IMPLEMENTATION
virtual ~LayoutByNW4R();
#else
virtual ~LayoutByNW4R() {}
#endif
virtual void create(MEMAllocator* allocator);
virtual void init();

View File

@@ -3,7 +3,6 @@
#include "tiInputForm.h"
#include "tiString.h"
#include "tiUtil.h"
#include <nw4r/lyt/pane.h>
@@ -21,7 +20,9 @@ namespace textinput {
virtual void moveNigaoeButton() {}
};
#ifdef MYTIINPUTFORM_IMPLEMENTATION
class ScrollButton;
#endif
class InputForm : public textinput::InputForm {
public:
@@ -33,24 +34,51 @@ namespace textinput {
EM_Last
} EditMode;
InputForm(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName,
EventObserver* observer, const char* subName)
: textinput::InputForm(manager, resAccessor, arcName, observer, subName),
mpMemoPane(NULL), mpMemoRootPane(NULL), mpBoundPane(NULL), mpDrawPane(NULL),
#ifdef MYTIMANAGER_IMPLEMENTATION
InputForm(textinput::Manager* manager, nw4r::lyt::MultiArcResourceAccessor* multiArc,
const char* layoutName, EventObserver* event, const char* fontName)
: textinput::InputForm(manager, multiArc, layoutName, event, fontName),
unk_0x308(NULL), unk_0x30C(NULL), unk_0x310(NULL), unk_0x314(NULL),
mfScroll(0.0f), mfScrollFrom(0.0f), mfScrollTo(0.0f), mnLine(0),
mDrawRect(0.0f, 0.0f, 0.0f, 0.0f), mDefaultDrawSize(0.0f, 0.0f), mDefaultBoundSize(0.0f, 0.0f),
mDrawRect(), mDefaultDrawSize(), mDefaultBoundSize(), mExScrollAnm(),
mpNigaoeObserver(NULL), mpDefaultNigaoe(NULL), mpSendString(NULL),
mbEdited(false), mbGoodBye(false), mbEditScrollUp(false), mbEditScrollDown(false), mbCloseWithSend(false),
mpScrollButton(NULL), mbScrollUp(false), mbScrollDown(false), meEditMode(EM_Disp) {}
mbEdited(false), mbGoodBye(false), mbEditScrollUp(false), mbEditScrollDown(false),
mbCloseWithSend(false), mpScrollButton(NULL), mbScrollUp(false), mbScrollDown(false),
meEditMode(EM_Disp) {}
#endif
~InputForm();
#ifdef MYTIINPUTFORM_IMPLEMENTATION
virtual void moveCursorUp();
virtual void moveCursorDown();
virtual void onCommand(INPUT_COMMAND command, void* data);
virtual void create(MEMAllocator* allocator, inputform::EditBuffer* editBuffer);
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
virtual bool updateInput(input::HKBManager& hkbManager);
virtual void init();
virtual void draw();
virtual void calc();
virtual void doScroll(Scroll* scroll);
virtual u32 calcCursorPos(f32 x, f32 y);
virtual void drawCursor(f32 x, f32 y);
virtual nw4r::math::VEC2 getScale() const;
virtual void preDraw(u32 pos);
virtual void doLineFeed();
virtual void finishDraw(u32 pos);
virtual bool isInScroll();
#endif
virtual void setScroll(f32 scroll);
virtual void setAddScroll(f32 scroll, bool up, bool down);
virtual f32 getScroll() { return mfScroll; }
virtual f32 getScroll() { return mfScroll; }
#ifdef MYTIMANAGER_IMPLEMENTATION
virtual f32 getScrollFrom();
virtual f32 getScrollTo();
#else
virtual f32 getScrollFrom() { return mfScrollFrom; }
virtual f32 getScrollTo() { return mfScrollTo; }
virtual f32 getScrollTo() { return mfScrollTo; }
#endif
virtual void open();
virtual void close();
@@ -72,7 +100,7 @@ namespace textinput {
virtual void onArrowRTrig();
virtual void onArrowLTrig();
virtual void setNigaoeEventObserver(NigaoeEventObserver* nigaoeObserver);
virtual void setNigaoeEventObserver(NigaoeEventObserver* nigaoeObserver) { mpNigaoeObserver = nigaoeObserver; }
virtual nw4r::lyt::Pane* getNigaoePane();
virtual nw4r::lyt::Material* getNigaoePaneMaterial();
@@ -94,33 +122,6 @@ namespace textinput {
virtual void onCommandOnEditMode(INPUT_COMMAND command, void* arg);
virtual void doAutoScroll();
#ifdef MYTIINPUTFORM_IMPLEMENTATION
virtual void pure_0() = 0;
virtual void pure_1() = 0;
virtual void pure_2() = 0;
virtual void pure_3() = 0;
virtual void pure_4() = 0;
virtual void pure_5() = 0;
#endif
virtual void create(MEMAllocator* allocator, inputform::EditBuffer* editBuffer);
virtual void moveCursorUp();
virtual void moveCursorDown();
virtual void onCommand(CommandReceiver::INPUT_COMMAND command, void* arg);
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
virtual bool updateInput(textinput::input::HKBManager& hkbManager);
virtual void init();
virtual void draw();
virtual void calc();
virtual void doScroll(CommandReceiver::Scroll* scroll);
virtual u32 calcCursorPos(f32 x, f32 y);
virtual void drawCursor(f32 x, f32 y);
virtual nw4r::math::VEC2 getScale() const;
virtual void preDraw(u32);
virtual void doLineFeed();
virtual void finishDraw(u32);
virtual bool isInScroll();
/* For letter writing */
@@ -130,7 +131,11 @@ namespace textinput {
void setEditScrollDown(bool editScrollDown) { mbEditScrollUp = editScrollDown; }
void setCloseWithSend(bool closeWithSend) { mbCloseWithSend = closeWithSend; }
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
void setEditMode(EditMode editMode);
#else
void setEditMode(EditMode editMode) { meEditMode = editMode; }
#endif
bool isEdited() { return mbEdited; }
bool isGoodBye() { return mbGoodBye; }
@@ -142,11 +147,20 @@ namespace textinput {
tistring::Decolated* getSendString() { return mpSendString; }
protected:
nw4r::lyt::Pane* mpMemoPane; // 0x308
nw4r::lyt::Pane* mpMemoRootPane; // 0x30C
nw4r::lyt::Pane* mpBoundPane; // 0x310
nw4r::lyt::Pane* mpDrawPane; // 0x314
private:
#ifdef MYTIINPUTFORM_IMPLEMENTATION
nw4r::lyt::Pane* mpMemoPane;
nw4r::lyt::Pane* mpMemoRootPane;
nw4r::lyt::Pane* mpBoundPane;
nw4r::lyt::Pane* mpDrawPane;
#else
#ifdef MYTIMANAGER_IMPLEMENTATION
undefined4* unk_0x308;
#endif
undefined4* unk_0x30C;
undefined4* unk_0x310;
undefined4* unk_0x314;
#endif
f32 mfScroll; // 0x318
f32 mfScrollFrom; // 0x31C
f32 mfScrollTo; // 0x320
@@ -158,7 +172,11 @@ namespace textinput {
nw4r::lyt::Size mDefaultBoundSize; // 0x358
Mtx mDrawMtx; // 0x360
Mtx mBoundMtx; // 0x390
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
util::Animation mExScrollAnm; // 0x3C0
#else
u8 /*todo*/ mExScrollAnm[32]; // 0x3C0
#endif
NigaoeEventObserver* mpNigaoeObserver; // 0x3E0
GXTexObj* mpDefaultNigaoe; // 0x3E4
tistring::Decolated* mpSendString; // 0x3E8
@@ -168,10 +186,13 @@ namespace textinput {
bool mbEditScrollDown; // 0x3EF
bool mbCloseWithSend; // 0x3F0
u8 padding[3]; // 0x3F1
ScrollButton* mpScrollButton; // 0x3F4
#ifdef MYTIINPUTFORM_IMPLEMENTATION
ScrollButton* mpScrollButton;
#else
undefined4* mpScrollButton;
#endif
bool mbScrollUp; // 0x3F8
bool mbScrollDown; // 0x3F9
u8 padding2[2]; // 0x3FA
EditMode meEditMode; // 0x3FC
};
}

View File

@@ -16,19 +16,12 @@ namespace textinput {
T_Last,
} Type;
InputForm(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName,
EventObserver* observer, const char* subName)
: MemoInputForm(manager, resAccessor, arcName, observer, subName),
mbPhotoScaledUp(false), mbPhotoDraw(false), meType(T_MailAddressSel) {}
~InputForm();
virtual void create(MEMAllocator* allocator, inputform::EditBuffer* editBuffer);
virtual void drawBody();
virtual void drawFooter();
virtual void open();
virtual void close();
virtual bool isWholePaneInAnimation();
#ifdef MYTIMANAGER_IMPLEMENTATION
InputForm(textinput::Manager* manager, nw4r::lyt::MultiArcResourceAccessor* multiArc,
const char* layoutName, EventObserver* event, const char* fontName)
: textinput::MemoInputForm(manager, multiArc, layoutName, event, fontName),
unk_0x400(0), mbPhotoDraw(false), meType(T_MailAddressSel) {}
#endif
virtual nw4r::lyt::Material* getPhotoPaneMaterial();
@@ -36,16 +29,16 @@ namespace textinput {
virtual void onPhotoPoint();
virtual void onPhotoLeft();
virtual bool isPhotoScaledUp();
virtual void setPhotoDraw(bool photoDraw);
virtual void setPhotoDraw(bool photoDraw) { mbPhotoDraw = photoDraw; }
virtual void setType(Type type);
virtual void setType(Type type) { meType = type; }
virtual void setSendOutMessage(const wchar_t* sendOutMessage);
void resizePhotoPane(f32 width, f32 height);
private:
bool mbPhotoScaledUp; // 0x400
u8 unk_0x400;
bool mbPhotoDraw; // 0x401
Type meType; // 0x404
};

View File

@@ -8,10 +8,6 @@
namespace textinput {
namespace extend {
namespace bg {
class LayoutByNW4R;
}
namespace memo {
class State;
@@ -32,7 +28,9 @@ namespace textinput {
CT_NumericWithSeparator,
CT_NormalWithoutLineFeedWithSign,
CT_PredictWithoutLineFeed,
#ifdef MYTIMANAGER_IMPLEMENTATION
CT_PredictBigText,
#endif
CT_Last
} ConfigType;
@@ -83,21 +81,35 @@ namespace textinput {
virtual void start();
virtual void end();
virtual textinput::InputForm* createInputForm();
#ifdef MYTIMANAGER_IMPLEMENTATION
virtual textinput::InputForm* createInputForm();
#else
virtual InputForm* createInputForm();
#endif
virtual void memoDraw();
virtual void setSaveData(savedata::MemoSetting memoSetting);
virtual savedata::MemoSetting getSaveData();
virtual void setSaveData(savedata::MemoSetting memoSetting) {
mMemoSetting = memoSetting;
}
virtual savedata::MemoSetting getSaveData() { return mMemoSetting; }
virtual void changeState(StateTimeLine stateTimeLine);
virtual State* getState();
virtual State* getState() { return mpCurrentState; }
virtual void setState(StateType stateType);
virtual ConfigType getConfigType();
virtual ConfigType getConfigType() { return meConfigType; }
#ifdef MYTIMANAGER_IMPLEMENTATION
virtual void setSaveData();
#else
virtual void setSaveData_();
#endif
virtual void reflectSaveData();
#ifdef MYTIMANAGER_IMPLEMENTATION
void reflectSaveDataRev1();
void reflectSaveDataDefault();
#endif
virtual void configDefault();
virtual void configLetter();
@@ -114,24 +126,21 @@ namespace textinput {
virtual void configNormalWithoutLineFeedWithSign();
virtual void configPredictWithoutLineFeed();
virtual void configPredictBigText();
virtual InputForm* createMemoInputForm();
virtual letter::InputForm* createLetterInputForm();
virtual textinput::InputForm* createBigTextInputForm();
virtual bg::LayoutByNW4R* createBG();
#ifdef MYTIMANAGER_IMPLEMENTATION
virtual textinput::MemoInputForm* createMemoInputForm();
virtual textinput::LetterInputForm* createLetterInputForm();
virtual textinput::InputForm* createBigTextInputForm();
virtual void* createBG();
#else
virtual void createMemoInputForm();
virtual void createLetterInputForm();
virtual void createBigTextInputForm();
virtual void createBG();
#endif
virtual void pure_0() {}
virtual void pure_1() {}
virtual void pure_2() {}
virtual void pure_3() {}
virtual void pure_4() {}
virtual void pure_5() {}
virtual void pure_6() {}
virtual void pure_7() {}
virtual void pure_8() {}
virtual void pure_9() {}
void reflectSaveDataRev1();
void reflectSaveDataDefault();
#ifdef MYTIMANAGER_IMPLEMENTATION
void* getBackGround() const { return mpBackGround; }
#endif
private:
State* mpCurrentState; // 0x40
@@ -140,133 +149,59 @@ namespace textinput {
MemoInputForm* mpMemoInputForm; // 0x50
LetterInputForm* mpLetterInputForm; // 0x54
textinput::InputForm* mpBigTextInputForm; // 0x58
keyboard::pctype::LayoutByNW4R* mpDefaultPCKeyboard; // 0x5C
keyboard::cellphonetype::LayoutByNW4R* mpDefaultCellPhoneKeyboard; // 0x60
void* mpDefaultPCKeyboard; // 0x5C
void* mpDefaultCellPhoneKeyboard; // 0x60
textinput::InputForm* mpDefaultInputForm; // 0x64
candidatebox::LayoutByNW4R* mpDefaultCandidateBox; // 0x68
toolbar::LayoutByNW4R* mpDefaultToolBar; // 0x6C
predictlang::LayoutByNW4R* mpDefaultPredictLanguageDialog; // 0x70
keyboard::signwindow::LayoutByNW4R* mpDefaultSignWindow; // 0x74
bg::LayoutByNW4R* mpBackGround; // 0x78
friend class State;
void* mpDefaultCandidateBox; // 0x68
void* mpDefaultToolBar; // 0x6C
void* mpDefaultPredictLanguageDialog; // 0x70
void* mpDefaultSignWindow; // 0x74
void* mpBackGround; // 0x78
};
class State {
public:
#ifdef MYTIMANAGER_IMPLEMENTATION
State() : mpManager(NULL) {}
Manager* getManager() const { return mpManager; }
void setManager(Manager* manager) { mpManager = manager; }
#endif
virtual ~State();
virtual Manager::StateType getStateType() = 0;
virtual Manager::StateType getStateType();
virtual void create() = 0;
virtual void create();
virtual void init() = 0;
virtual void init();
virtual void draw() = 0;
virtual void memoDraw() = 0;
virtual void draw();
virtual void memoDraw();
virtual void calc() = 0;
virtual void calc();
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release) = 0;
virtual bool updateInput(input::HKBManager& hkbManager) = 0;
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release);
virtual bool updateInput(input::HKBManager& hkbManager);
virtual void start() = 0;
virtual void end() = 0;
virtual void start();
virtual void end();
virtual InputForm* InputForm();
virtual keyboard::hwkey::HWKeyboard* HWKeyboard();
virtual keyboard::pctype::LayoutByNW4R* PCKeyboard();
#ifdef MYTIMANAGER_IMPLEMENTATION
virtual InputForm* InputForm();
virtual keyboard::hwkey::HWKeyboard* HWKeyboard();
virtual keyboard::pctype::LayoutByNW4R* PCKeyboard();
virtual keyboard::cellphonetype::LayoutByNW4R* CellPhoneKeyboard();
virtual keyboard::signwindow::LayoutByNW4R* SignKeyboard();
virtual candidatebox::LayoutByNW4R* CandidateBox();
virtual toolbar::LayoutByNW4R* ToolBar();
virtual predictlang::LayoutByNW4R* PredictLanguageSelectDialog();
virtual bg::LayoutByNW4R* BG();
virtual void* SignKeyboard();
virtual candidatebox::LayoutByNW4R* CandidateBox();
virtual toolbar::LayoutByNW4R* ToolBar();
virtual void* PredictLanguageSelectDialog();
virtual void* BG();
#endif
protected:
private:
Manager* mpManager; // 0x04
friend class Manager;
};
class DispMemoState : public State {
public:
virtual ~DispMemoState();
virtual Manager::StateType getStateType();
virtual void create();
virtual void init();
virtual void draw();
virtual void memoDraw();
virtual void calc();
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release);
virtual bool updateInput(input::HKBManager& hkbManager);
virtual void start();
virtual void end();
};
class AppearMemoState : public State {
public:
AppearMemoState() : mfAnim(0.0f) {}
virtual ~AppearMemoState();
virtual Manager::StateType getStateType();
virtual void create();
virtual void init();
virtual void draw();
virtual void memoDraw();
virtual void calc();
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release);
virtual bool updateInput(input::HKBManager& hkbManager);
virtual void start();
virtual void end();
protected:
f32 mfAnim; // 0x08
};
class EditMemoState : public State {
public:
virtual ~EditMemoState();
virtual Manager::StateType getStateType();
virtual void create();
virtual void init();
virtual void draw();
virtual void memoDraw();
virtual void calc();
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release);
virtual bool updateInput(input::HKBManager& hkbManager);
virtual void start();
virtual void end();
};
class DisappearMemoState : public AppearMemoState {
public:
virtual ~DisappearMemoState();
virtual Manager::StateType getStateType();
virtual void calc();
virtual void start();
};
}
}
typedef extend::memo::Manager MemoManager;
}
#include "MyTiBg.h"
#endif // TEXTINPUT_MY_MANAGER_H

View File

@@ -48,6 +48,9 @@ namespace textinput {
class CandidateBoxCaller {
public:
#ifdef TIINPUTFORM_IMPLEMENTATION
CandidateBoxCaller() : mpCandidateBox(NULL) {}
#endif
// This candidate thing is a bit different from the dwarf
class Candidates {
public:
@@ -74,11 +77,9 @@ namespace textinput {
class Base : public CommandSender {
public:
#ifdef TI_CANDIDATEBOX_SAMPLE_CLASS
Base(Manager* manager)
: mpCandidates(NULL), mpAllocator(NULL), mbOn(false), mbInvalid(true), meLanguage(USA), mpManager(manager) {}
#ifdef TIMANAGER_IMPLEMENTATION
Base(Manager* manager) : mpCandidates(NULL), mpAllocator(NULL), mbOn(false), mbInvalid(true), meLanguage(USA), mpManager(manager) {}
#endif
virtual ~Base();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override {}
@@ -113,8 +114,9 @@ namespace textinput {
class EventHandler : public nw4rmanager::TiEventHandler {
public:
#ifdef TIMANAGER_IMPLEMENTATION
EventHandler(LayoutByNW4R* layout) : mpLayoutByNW4R(layout) {}
#endif
virtual void onTiEvent(gui::PaneComponent* paneComponent, u32 event, Input* input) override; // 0x18
LayoutByNW4R* mpLayoutByNW4R; // 0xC
@@ -288,13 +290,13 @@ namespace textinput {
// TODO
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public UIObj::Listener {
public:
#ifdef TI_CANDIDATEBOX_SAMPLE_CLASS
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, arcName, observer), mEventHandler(this),
mpTiString(NULL), mTextArea(0, this, this), mLeftScroll(1, this, this), mRightScroll(2, this, this),
mOnOffButton(3, this, this), mTextWindow(4, this, this), mbActive(true) {}
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mEventHandler(this), mpTiString(NULL),
mTextArea(0, this, this), mLeftScroll(1, this, this), mRightScroll(2, this, this), mOnOffButton(3, this, this),
mTextWindow(4, this, this), mbActive(true) {}
const UIOnOffButton& getOnOffButton() const { return mOnOffButton; }
#endif
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override;
@@ -323,7 +325,11 @@ namespace textinput {
virtual u16 getScroll() { return mTextArea.GetDispOffset(); } // 0x100
virtual bool isInScroll(); // 0x104
virtual void setActive(bool active); // 0x108
virtual bool isActive() const; // 0x10C
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
virtual bool isActive() const { return mbActive; }
#else
virtual bool isActive() const;
#endif // 0x10C
virtual void setSelectedTextPane(int pane) { mTextArea.SetSelectedText(pane); } // 0x110
virtual void setFocusedTextPane(int pane) { mTextArea.SetFocusedText(pane); } // 0x114
virtual int getFocusedTextPane() { return mTextArea.GetFocusedText(); } // 0x118
@@ -333,13 +339,13 @@ namespace textinput {
virtual void cancelStateFocusIn(); // 0x128
virtual void onEvent(UIObj*, u32, void*) override; // 0x12C
#ifdef TIINPUTFORM_IMPLEMENTATION
UITextArea& getTextArea() { return mTextArea; }
#endif
void onPressedShift(bool shift);
void onReleasedShift();
void startTurnOn(bool);
UIOnOffButton& getOnOffButton() { return mOnOffButton; }
const UIOnOffButton& getOnOffButton() const { return mOnOffButton; }
private:
void createAnmPane_(MEMAllocator* allocator);
@@ -402,17 +408,6 @@ namespace textinput {
virtual void onAnmEvent(AnmPaneEvent paneEvent) override; // 0x10
};
#ifdef TI_CANDIDATEBOX_SAMPLE_CLASS
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, arcName, observer) {}
virtual ~Sample();
};
#else
class Sample {};
#endif
} // namespace candidatebox
} // namespace textinput

View File

@@ -1,227 +1,194 @@
#ifndef TEXTINPUT_CELL_PHONE_H
#define TEXTINPUT_CELL_PHONE_H
#include "tiKeyboard.h"
#include "tiNw4rManager.h"
#include <revolution/gx.h>
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#include "tiKeyboard.h"
#endif
namespace textinput {
class Manager;
namespace predictlang {
class LayoutByNW4R;
}
namespace keyboard {
namespace signwindow {
class LayoutByNW4R;
}
class KeyboardBase;
typedef enum VKeyCode {
VK_LF = 0,
VK_DELETE = 1,
VK_SPACE = 2,
VK_OTHERS = 9,
VK_PRDC = 0xA,
VK_TAG_02 = 0xB,
VK_TAG_03 = 0xD,
VK_UNKNOWN_11 = 0x11,
VK_TAG_00 = 0x12,
VK_TAG_01 = 0x13,
VK_SML_CPT = 0x17,
VK_NONE = 0x1B,
} VKeyCode;
namespace cellphonetype {
struct PaneNameToCharCode;
struct KeySet;
struct LanguageDependency;
class LayoutByNW4R;
class Base : public KeyboardBase {
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
class Base : public textinput::keyboard::KeyboardBase {
#else
class Base {
#endif
public:
typedef enum InputMode {
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
enum InputMode {
IM_00,
IM_01,
IM_02,
IM_03,
IM_04,
IM_05,
} InputMode;
};
#ifdef TI_CELLPHONE_SAMPLE_CLASS
virtual ~Base();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override;
virtual void updateFromReceiver(u32, void*) override;
virtual void onKey(u32, void*) override;
#ifdef TIMANAGER_IMPLEMENTATION
Base(Manager* manager) : mpManager(manager) {}
virtual int getType() override;
#else
virtual void getType() override;
#endif
virtual void onActive() override;
virtual void calc();
virtual void draw();
virtual InputMode getInputMode() const;
virtual bool isLocked() const;
virtual bool isNumeric() const;
virtual bool isNumericWithDot() const;
virtual bool isHoldingButton() const;
virtual void doNumericMode(bool);
virtual void changeInputMode(InputMode);
virtual bool isUpperCase();
virtual void setInputMode(InputMode);
virtual void setUpperCaseJP(bool);
virtual void setLangKeyActive(bool);
virtual bool onClose();
virtual void goSignInputMode();
virtual void changePredictLanguage();
virtual void setAbcMode(bool);
virtual bool isZiActive();
virtual bool isAtokActive();
virtual void doInput();
virtual void updateFixMode();
#else
virtual void vt_0x08();
virtual void vt_0x0C();
virtual void vt_0x10();
virtual void vt_0x14();
virtual void vt_0x18();
virtual void vt_0x1C();
virtual void vt_0x20();
virtual void vt_0x24();
virtual void vt_0x28();
virtual void vt_0x2C();
virtual void vt_0x30();
virtual void vt_0x34();
virtual void vt_0x38();
virtual void vt_0x3C();
virtual void vt_0x40();
virtual void vt_0x44();
virtual bool isNumeric() const;
virtual void vt_0x4C();
virtual void vt_0x50();
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual void doNumericMode(bool);
#else
virtual void vt_0x54();
#endif
virtual void vt_0x58();
virtual void vt_0x5C();
virtual void vt_0x60();
virtual void vt_0x64();
virtual void vt_0x68(bool);
virtual bool onClose();
#endif
virtual void create(MEMAllocator* allocator) override; // 0x0C
virtual void init() override; // 0x10
virtual void setCommandReceiver(CommandReceiver* receiver) override; // 0x14
virtual void sendCommand(u32, void*) override; // 0x18
virtual void updateFromReceiver(u32, void*) override; // 0x1C
virtual void onKey(u32, void*); // 0x20
virtual int getType(); // 0x24
virtual void setLanguage(Language language) override; // 0x28
virtual Language getLanguage() const override; // 0x2C
virtual void onActive() override; // 0x34
virtual void calc(); // 0x38
virtual void draw(); // 0x3C
virtual int getInputMode() const; // 0x40
virtual bool isLocked() const; // 0x44
virtual bool isNumeric() const; // 0x48
virtual bool isNumericWithDot() const; // 0x4C
virtual bool isHoldingButton() const; // 0x50
virtual void doNumericMode(bool); // 0x54
virtual void changeInputMode(InputMode mode); // 0x58
virtual bool isUpperCase(); // 0x5C
virtual void setInputMode(InputMode mode); // 0x60
virtual void setUpperCaseJP(bool); // 0x64
virtual void setLangKeyActive(bool); // 0x68
virtual void onClose(); // 0x6C
virtual void goSignInputMode(); // 0x70
virtual void changePredictLanguage(); // 0x74
virtual void setAbcMode(bool); // 0x78
virtual bool isZiActive(); // 0x7C
virtual bool isAtokActive(); // 0x80
virtual void doInput(); // 0x84
virtual void updateFixMode(); // 0x88
void onCtrlKey_(VKeyCode code);
wchar_t convertToZiCellphoneInput_(wchar_t wc);
// TODO enum?
int getInputType() const;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
void resetHoldingButton();
#endif
protected:
Manager* mgr() { return mpManager; }
s32 mTapIndex; // 0x14
s32 mInputMode; // 0x18
u8 mbLocked; // 0x1C
u8 mbNumeric; // 0x1D
u8 mbNumericWithDot; // 0x1E
u8 mbUpperCase; // 0x1F
u8 mbShiftHeld; // 0x20
u8 unk_0x21; // 0x21
const PaneNameToCharCode* mpHoldingPane; // 0x24
const LanguageDependency* mpLanguageDep; // 0x28
MEMAllocator* mpAllocator; // 0x2C
Manager* mpManager; // 0x30
u8 mbLangKeyActive; // 0x34
u8 unk_0x35[3]; // 0x35
};
class EventHandler : public nw4rmanager::TiEventHandler {
public:
EventHandler(LayoutByNW4R* layout) : mpLayout(layout) {}
virtual void onTiEvent(gui::PaneComponent* paneComponent, u32 event, TiEventHandler::Input* input); // 0x18
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
private:
LayoutByNW4R* mpLayout; // 0x0C
u32 mPreviousInputMode;
u32 mCurrentInputMode;
bool mbInputModeLocked;
bool mbNumericMode;
bool mbNumericWithDotMode;
bool mbUpperCaseMode;
bool mbAbcMode;
bool mbLanguageKeyMode;
u32 mHoldingButton;
void* mpInputModeTable;
MEMAllocator* mpAllocator;
#ifdef TIMANAGER_IMPLEMENTATION
Manager* mpManager;
#else
void* mpInputSettings;
#endif
u32 mInputState;
#endif
};
class CellPhoneAnmPane : public nw4rmanager::AnmPane {
public:
CellPhoneAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer, u32 keyType)
: nw4rmanager::AnmPane(pane, observer) {
mState = 0;
mKeyType = keyType;
init();
changeAnimation(mState);
}
virtual void init(); // 0x08
virtual void onAnmEvent(AnmPaneEvent paneEvent); // 0x10
virtual void changeAnimation(u32 id); // 0x14
virtual u32 getKeyType() const; // 0x24
protected:
s32 mState; // 0x2C
u32 mKeyType; // 0x30
};
class CellPhoneControlAnmPane : public CellPhoneAnmPane {
public:
CellPhoneControlAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer, u32 keyType)
: CellPhoneAnmPane(pane, observer, 0) {
mKeyType = keyType;
}
virtual void onAnmEvent(AnmPaneEvent paneEvent); // 0x10
};
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
public:
#ifdef TI_CELLPHONE_SAMPLE_CLASS
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, arcName, observer),
mpEventHandler(NULL) {}
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mpEventHandler(NULL) {}
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override;
virtual void setCommandReceiver(CommandReceiver* receiver) override;
virtual void updateFromReceiver(u32, void*) override;
virtual void onKey(u32, void*) override;
virtual void setLanguage(Language language) override;
virtual void update() override;
virtual void onActive() override;
virtual void calc() override;
virtual void draw() override;
virtual void doNumericMode(bool) override;
virtual void changeInputMode(InputMode mode) override;
virtual void setInputMode(InputMode mode) override;
virtual void setUpperCaseJP(bool) override;
virtual void setLangKeyActive(bool) override;
virtual void onClose() override;
virtual void goSignInputMode() override;
virtual void changePredictLanguage() override;
virtual void setAbcMode(bool) override;
virtual void setPredictLanguageDialog(predictlang::LayoutByNW4R*); // 0x104
virtual void setSignWindow(signwindow::LayoutByNW4R*); // 0x108
virtual void doNumericWithDotMode(bool); // 0x10C
virtual void setLineFeedButton(bool); // 0x110
virtual void setPredictLanguageButton(bool); // 0x114
virtual void setSignWindowButton(bool); // 0x118
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data); // 0x11C
virtual bool updateInput(textinput::input::HKBManager& hkbManager); // 0x120
virtual nw4rmanager::AnmPane* getAnmPane(InputMode mode); // 0x124
virtual void throwReleaseForAll(); // 0x128
virtual void changeAnimationAllToNormal(); // 0x12C
virtual void updatePredictLanguage(CommandReceiver::ChangePredictMode* mode); // 0x130
virtual void changeKeyTop(const PaneNameToCharCode* table); // 0x134
virtual void changeSpaceKeyTop(const PaneNameToCharCode* table); // 0x138
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual void setCommandReceiver(CommandReceiver* receiver);
virtual void updateFromReceiver(u32 command, void* data);
virtual void onKey(u32 event, void* data);
virtual void setLanguage(Language language);
virtual void update();
virtual void onActive();
virtual void calc();
virtual void draw();
virtual void changeInputMode(InputMode mode);
virtual void setInputMode(InputMode mode);
virtual void setUpperCaseJP(bool upper);
virtual void setLangKeyActive(bool active);
virtual void goSignInputMode();
virtual void changePredictLanguage();
virtual void setAbcMode(bool abc);
virtual void doNumericMode(bool);
virtual void setPredictLanguageDialog(predictlang::LayoutByNW4R* dialog);
virtual void setSignWindow(signwindow::LayoutByNW4R* window);
#else
virtual void doNumericMode(bool);
virtual void setPredictLanguageDialog(void*);
virtual void setSignWindow(void*);
#endif
virtual void doNumericWithDotMode(bool);
virtual void setLineFeedButton(bool);
virtual void setPredictLanguageButton(bool);
virtual void setSignWindowButton(bool);
#endif
virtual bool onClose();
void onPressedShift(bool shift);
void onReleasedShift();
void resetHoldingButton();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
bool hasLineFeedButton() const { return mbLineFeedButton; }
private:
bool mbLineFeed; // 0xE0
u8 unk_0xE1[3]; // 0xE1
GXTexObj mSpaceTexObjJP; // 0xE4
GXTexObj mSpaceTexObjCN; // 0x104
GXTexObj mSpaceTexObjKR; // 0x124
EventHandler* mpEventHandler; // 0x144
predictlang::LayoutByNW4R* mpPredictLanguageDialog; // 0x148
signwindow::LayoutByNW4R* mpSignWindow; // 0x14C
};
#ifdef TI_CELLPHONE_SAMPLE_CLASS
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, arcName, observer) {}
virtual ~Sample();
};
#else
class Sample {};
bool mbLineFeedButton;
#ifdef TIMANAGER_IMPLEMENTATION
GXTexObj mSpaceTexture;
GXTexObj mSpaceTextureCN;
GXTexObj mSpaceTextureKR;
nw4rmanager::TiEventHandler* mpEventHandler;
predictlang::LayoutByNW4R* mpPredictDialog;
signwindow::LayoutByNW4R* mpSignWindow;
#endif
public:
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) override;
virtual bool updateInput(input::HKBManager& hkbManager) override;
#endif
#ifdef TIMANAGER_IMPLEMENTATION
virtual nw4rmanager::AnmPane* getAnmPane(InputMode mode);
virtual void throwReleaseForAll();
virtual void changeAnimationAllToNormal();
virtual void updatePredictLanguage(CommandReceiver::ChangePredictMode* mode);
virtual void changeKeyTop(const struct PaneNameToCharCode* table);
virtual void changeSpaceKeyTop(const struct PaneNameToCharCode* table);
#endif
};
} // namespace cellphonetype
} // namespace keyboard

View File

@@ -1,126 +0,0 @@
#ifndef TEXTINPUT_CELL_PHONE_LAYOUT_H
#define TEXTINPUT_CELL_PHONE_LAYOUT_H
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
public:
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mpEventHandler(NULL) {}
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual void setCommandReceiver(CommandReceiver* receiver);
virtual void updateFromReceiver(u32 command, void* data);
virtual void onKey(u32 event, void* data);
virtual void setLanguage(Language language);
virtual void update();
virtual void onActive();
virtual void calc();
virtual void draw();
virtual void changeInputMode(InputMode mode);
virtual void setInputMode(InputMode mode);
virtual void setUpperCaseJP(bool upper);
virtual void setLangKeyActive(bool active);
virtual void goSignInputMode();
virtual void changePredictLanguage();
virtual void setAbcMode(bool abc);
virtual void doNumericMode(bool);
virtual void setPredictLanguageDialog(predictlang::LayoutByNW4R* dialog);
virtual void setSignWindow(signwindow::LayoutByNW4R* window);
#else
#if defined(MYTIMANAGER_IMPLEMENTATION) && defined(TI_CELLPHONE_SAMPLE_CLASS)
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, "fs_VK_cellPhone_a.brlyt", observer), mpSignWindow(NULL) {}
#endif
virtual void doNumericMode(bool);
#ifdef TI_CELLPHONE_IMPLEMENTATION
virtual void setPredictLanguageDialog(predictlang::LayoutByNW4R*);
virtual void setSignWindow(signwindow::LayoutByNW4R*);
#else
virtual void setPredictLanguageDialog(void*);
virtual void setSignWindow(void*);
#endif
#endif
virtual void doNumericWithDotMode(bool);
virtual void setLineFeedButton(bool);
virtual void setPredictLanguageButton(bool);
virtual void setSignWindowButton(bool);
#endif
virtual bool onClose();
void onPressedShift(bool shift);
void onReleasedShift();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
bool hasLineFeedButton() const { return mbLineFeedButton; }
private:
bool mbLineFeedButton;
#ifdef TIMANAGER_IMPLEMENTATION
GXTexObj mSpaceTexture;
GXTexObj mSpaceTextureCN;
GXTexObj mSpaceTextureKR;
nw4rmanager::TiEventHandler* mpEventHandler;
predictlang::LayoutByNW4R* mpPredictDialog;
signwindow::LayoutByNW4R* mpSignWindow;
#endif
public:
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) override;
virtual bool updateInput(input::HKBManager& hkbManager) override;
#endif
#ifdef TI_CELLPHONE_IMPLEMENTATION
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override;
virtual void draw() override;
virtual void calc() override;
virtual void update() override;
virtual void onKey(u32 key, void* data) override;
virtual void onActive() override;
virtual void updateFromReceiver(u32 command, void* data) override;
virtual void changeInputMode(InputMode mode) override;
virtual void changePredictLanguage() override;
virtual void setAbcMode(bool enabled) override;
virtual void goSignInputMode() override;
virtual void setInputMode(InputMode mode) override;
virtual void setLanguage(Language language) override;
virtual void setCommandReceiver(CommandReceiver* receiver) override;
virtual CellPhoneAnmPane* getAnmPane(InputMode mode);
virtual void throwReleaseForAll();
virtual void changeAnimationAllToNormal();
virtual void updatePredictLanguage(CommandReceiver::ChangePredictMode* mode);
virtual void changeKeyTop(const PaneNameToCharCode* keys);
virtual void changeSpaceKeyTop(const PaneNameToCharCode* keys);
void setUpperCaseJP(bool enabled);
void setLangKeyActive(bool enabled);
void resetHoldingButton();
private:
bool mbLineFeedButton;
GXTexObj mTextures[3];
EventHandler* mpEventHandler;
predictlang::LayoutByNW4R* mpPredictLanguageDialog;
signwindow::LayoutByNW4R* mpSignWindow;
#elif defined(TIMANAGER_IMPLEMENTATION)
virtual nw4rmanager::AnmPane* getAnmPane(InputMode mode);
virtual void throwReleaseForAll();
virtual void changeAnimationAllToNormal();
virtual void updatePredictLanguage(CommandReceiver::ChangePredictMode* mode);
virtual void changeKeyTop(const struct PaneNameToCharCode* table);
virtual void changeSpaceKeyTop(const struct PaneNameToCharCode* table);
#endif
};
#ifdef TI_CELLPHONE_SAMPLE_CLASS
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, observer) {}
virtual ~Sample() {}
};
#endif
#endif

View File

@@ -93,13 +93,8 @@ namespace textinput {
extern const KeySet csKeySetCNPinyin;
extern const KeySet csKeySetHangul;
#ifdef TI_CELLPHONE_MATCH_LAYOUT
extern const wchar_t* csSpaceZero;
extern const wchar_t* csSpace;
#else
extern const wchar_t csSpaceZero[3];
extern const wchar_t csSpace[3];
#endif
}
}
}

View File

@@ -72,10 +72,10 @@ namespace textinput {
virtual ~EventHandler() {} // 0x08
virtual void onEvent(GUIComponent& comp, u32 event, void* data); // 0x0C
virtual void onEvent(GUIComponent& comp, u32 event, void* data) {} // 0x0C
virtual void setLatestEventCtrlNo(int ctrlNo); // 0x10
virtual int getLatestEventCtrlNo(); // 0x14
virtual void setLatestEventCtrlNo(int ctrlNo) { muLatestEventCtrlNo = ctrlNo; } // 0x10
virtual int getLatestEventCtrlNo() { return muLatestEventCtrlNo; } // 0x14
protected:
int muLatestEventCtrlNo; // 0x04
@@ -92,6 +92,9 @@ namespace textinput {
EVENT_RELEASE
};
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual void init();
#else
virtual void init() { // 0x10
for (int i = 0; i < GUI_POINTS_MAX; i++) {
mbPointed[i] = false;
@@ -100,19 +103,20 @@ namespace textinput {
mFlightDuration[i] = 0;
}
}
#endif
GUIComponent(u32 id)
: GUIInterface(), mbInitialize(false), mDraggingButton(0xFFFF), mID(id), mbTriggerTarget(false), mpManager(NULL), mpListener(NULL) {
init();
}
virtual ~GUIComponent(); // 0x08
virtual ~GUIComponent() {} // 0x08
virtual u32 getID(); // 0x20
virtual u32 getID() { return mID; } // 0x20
virtual bool isPointed(int point); // 0x24
virtual bool isDragging(int point); // 0x28
virtual bool isPointed(int point) { return mbPointed[point]; } // 0x24
virtual bool isDragging(int point) { return mbDragging[point]; } // 0x28
virtual void setPointed(int point, bool bEnable); // 0x2C
virtual void setPointed(int point, bool bEnable) { mbPointed[point] = bEnable; } // 0x2C
void onEvent(u32 event, void* data) {
if (mpListener) {
@@ -120,30 +124,39 @@ namespace textinput {
}
}
virtual void onPointIn(int point); // 0x30
virtual void onPointOut(int point); // 0x34
virtual void onPointIn(int point) { mFlightDuration[point] = 0; } // 0x30
virtual void onPointOut(int point) { mFlightDuration[point] = 0; } // 0x34
virtual void onDrag(f32 x, f32 y);
virtual void onMove(int point, f32 x, f32 y); // 0x38
virtual void onTrig(int point, u32 trig, Vec& dragPos);
virtual void onDrag(f32 x, f32 y) {}
virtual void onMove(int point, f32 x, f32 y) { mFlightDuration[point]++; } // 0x38
virtual void onTrig(int point, u32 trig, Vec& dragPos) {
if (trig & mDraggingButton) {
mDraggingPos[point] = dragPos;
mbDragging[point] = true;
mFlightDuration[point] = 0;
}
}
virtual void setDraggingButton(u32 dragBtn); // 0x3C
virtual void setDraggingButton(u32 dragBtn) { mDraggingButton = dragBtn; } // 0x3C
virtual u32 updatePointer(const GUIPointer& pointer); // 0x48
virtual u32 updatePointer(int point, f32 x, f32 y, u32 trig, u32 hold, u32 release); // 0x4C
virtual u32 updatePointer(const GUIPointer& pointer) { return updatePointerImpl(pointer); } // 0x40
virtual u32 updatePointer(int point, f32 x, f32 y, u32 trig, u32 hold, u32 release) { // 0x44
GUIPointer pointer(point, x, y, hold, trig, release);
return updatePointerImpl(pointer);
}
virtual bool isTriggerTarget(); // 0x50
virtual void setTriggerTarget(bool bEnable); // 0x54
virtual bool isTriggerTarget() { return mbTriggerTarget; } // 0x48
virtual void setTriggerTarget(bool bEnable) { mbTriggerTarget = bEnable; } // 0x4C
void setParentManager(GUIManager* manager) { mpManager = manager; }
GUIManager* getParentManager() { return mpManager; }
virtual bool isVisible(); // 0x58
virtual bool isVisible() { return true; } // 0x50
virtual u16 getFlightDuration(int point); // 0x5C
virtual void setFlightDuration(int point, u16 flightDir); // 0x60
virtual u16 getFlightDuration(int point) { return mFlightDuration[point]; } // 0x54
virtual void setFlightDuration(int point, u16 flightDir) { mFlightDuration[point] = flightDir; } // 0x58
virtual bool contain(f32 x, f32 y) = 0; // 0x64
virtual bool contain(f32 x, f32 y) = 0; // 0x5C
void setListener(EventHandler* listener) { mpListener = listener; }
@@ -154,9 +167,9 @@ namespace textinput {
bool mbInitialize; // 0x04
bool mbPointed[GUI_POINTS_MAX]; // 0x05
bool mbPointed[GUI_POINTS_MAX]; // 0x08
bool mbDragging[GUI_POINTS_MAX]; // 0x0D
bool mbDragging[GUI_POINTS_MAX]; // 0x10
Vec mDraggingPos[GUI_POINTS_MAX]; // 0x18
int mDraggingButton; // 0x78
@@ -164,10 +177,10 @@ namespace textinput {
u16 mFlightDuration[GUI_POINTS_MAX]; // 0x80
bool mbTriggerTarget; // 0x90
bool mbTriggerTarget; // 0x8A
GUIManager* mpManager; // 0x94
EventHandler* mpListener; // 0x98
GUIManager* mpManager; // 0x8C
EventHandler* mpListener; // 0x90
};
class GUIManager : public GUIInterface {
@@ -187,15 +200,27 @@ namespace textinput {
virtual GUIComponent* getComponent(u32 id); // 0x24
virtual GUIComponent* getComponent(u32 id) const; // 0x28
virtual bool update(int point, const KPADStatus* kpad, f32, f32, void* data); // 0x2C
virtual bool update(int point, const KPADStatus* kpad, f32, f32, void* data) { return false; } // 0x2C
virtual bool update(int point, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data); // 0x30
virtual void onEvent(GUIComponent& comp, u32 event, int point, void* data); // 0x34
virtual void onEvent(GUIComponent& comp, u32 event, int point, void* data) { // 0x34
if (mpEventHandler) {
mpEventHandler->setLatestEventCtrlNo(point);
mpEventHandler->onEvent(comp, event, data);
}
comp.onEvent(event, data);
}
virtual void setAllComponentTriggerTarget(bool bEnable); // 0x38
virtual void setEventHandler(EventHandler* eventHandler); // 0x3C
virtual EventHandler* changeEventHandler(EventHandler* eventHandler); // 0x40
virtual void setEventHandler(EventHandler* eventHandler) { // 0x3C
mpEventHandler = eventHandler;
}
virtual EventHandler* changeEventHandler(EventHandler* eventHandler) { // 0x40
EventHandler* prevHandler = mpEventHandler;
mpEventHandler = eventHandler;
return prevHandler;
}
virtual void setDraggingButton(u32 dragBtn); // 0x44
@@ -234,7 +259,7 @@ namespace textinput {
virtual PaneComponent* getPaneComponentByPane(nw4r::lyt::Pane* pane); // 0x4C
virtual const nw4r::lyt::DrawInfo* getDrawInfo(); // 0x50
virtual const nw4r::lyt::DrawInfo* getDrawInfo() { return mpDrawInfo; } // 0x50
virtual void setDrawInfo(const nw4r::lyt::DrawInfo* drawInfo) { mpDrawInfo = drawInfo; } // 0x54
virtual void setAllBoundingBoxComponentTriggerTarget(bool bEnable); // 0x58
@@ -273,11 +298,11 @@ namespace textinput {
virtual void draw(); // 0x1C
virtual bool isVisible(); // 0x58
virtual bool isVisible(); // 0x50
virtual bool contain(f32 x, f32 y); // 0x64
virtual bool contain(f32 x, f32 y); // 0x5C
virtual void setPane(nw4r::lyt::Pane* pane); // 0x68
virtual void setPane(nw4r::lyt::Pane* pane) { mpPane = pane; } // 0x60
nw4r::lyt::Pane* getPane() { return mpPane; }
nw4r::lyt::TextBox* getTextPane() { return static_cast<nw4r::lyt::TextBox*>(mpPane); }

View File

@@ -4,158 +4,58 @@
#include <revolution/types.h>
#include <revolution/mem/allocator.h>
#include <revolution/os.h>
#include "keyboard/tiCpData.h"
typedef enum _KBDEc {
KBD_EC_0 = 0,
KBD_EC_1,
KBD_EC_2,
KBD_EC_3,
KBD_EC_4,
KBD_EC_5,
KBD_EC_6,
KBD_EC_OK,
} KBDEc;
typedef struct _KBDDevEvent {
u8 chan;
u8 unk_0x01[0x1F];
} KBDDevEvent;
typedef struct _KBDKeyEvent {
u8 chan;
u8 key;
u8 unk_0x02[2];
u32 mods;
} KBDKeyEvent;
extern "C" {
void KBDInitRegionUS(void);
void KBDInit(void);
void KBDSetAttachCallback(void (*cb)(KBDDevEvent*));
void KBDSetDetachCallback(void (*cb)(KBDDevEvent*));
void KBDSetKeyCallback(void (*cb)(KBDKeyEvent*));
int KBDSetLedsAsync(u8 chan, u8 leds, void (*cb)(KBDEc, void*), void* arg);
int KBDSetLeds(u8 chan, u8 leds);
int KBDSetModState(u8 chan, u32 mods);
int KBDSetCountry(u8 chan, u32 country);
int KBDSetLockProcessing(u8 chan, int lock);
u16 KBDTranslateHidCode(u8 key, u32 country);
}
namespace textinput {
namespace input {
class HKBManager {
public:
HKBManager();
~HKBManager();
#ifdef TIMANAGER_IMPLEMENTATION
void ClearState();
#endif
static HKBManager& getInstance() { return sInstance; }
void Initialize();
void Update();
u32 GetModifierState() const;
void SetModifierState(u32 state, u32 mask);
void SetForceModifierState(u32 state, u32 mask);
void SetCountry(u8 country);
void ClearState();
u32 GetModifierState() const;
void SetModifierState(u32, u32);
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
class KeySet {
public:
KeySet(const HKBManager* manager, u8 type) :
mpManager(manager), mType(type),
mIndex(-1), mSubIndex(0), mVCode(0) {}
u8 GetKey() const;
u8 GetKey() const;
wchar_t GetWChar() const;
wchar_t GetVCode() const;
bool IsValid() const;
KeySet GetNext() const;
const HKBManager* mpManager; // 0x00
u8 mType; // 0x04
s8 mIndex; // 0x05
u8 mSubIndex; // 0x06
mutable u16 mVCode; // 0x08
bool IsValid() const;
KeySet GetNext() const;
KeySet(const KeySet& other)
: mpManager(other.mpManager), mKind(other.mKind), mIndex(other.mIndex), mDevice(other.mDevice), mCharacter(other.mCharacter) {}
private:
const HKBManager* mpManager;
u8 mKind;
s8 mIndex;
u8 mDevice;
u16 mCharacter;
};
KeySet GetTriggeredKeySet() const;
KeySet GetReleasedKeySet() const;
KeySet GetRepeatedKeySet() const;
void SetForceModifierState(u32 mask, u32 state);
#else
class KeySet {
private:
keyboard::cellphonetype::PaneNameToCharCode* pPaneNameToCharCode; // 0x00
wchar_t szKeySetName[17]; // 0x04
u16 uNum; // 0x26
u16 uType; // 0x28
};
#endif
private:
class KeyState_ {
public:
void NotifyEvent(u8 type, u8 key);
void Update();
void UpdateModState_();
u8 mKbdChan; // 0x00
u8 pad_0x01[3];
u32 mMaskWork; // 0x04
u32 mTrigMask; // 0x08
u32 mRelMask; // 0x0C
u32 mRepMask; // 0x10
u32 mPrevMask; // 0x14
u32 mCurMask; // 0x18
u32 mInputMask; // 0x1C
u32 mModState; // 0x20
u32 mForceMod; // 0x24
u32 mForceMask; // 0x28
s32 mCountry; // 0x2C
u8 mLedOK; // 0x30
u8 mReleasedKeys[8]; // 0x31
u8 mPrevKeys[8]; // 0x39
u8 mCurKeys[8]; // 0x41
u8 pad_0x49[3];
u32 mRepeatCtr[8]; // 0x4C
};
class KBDListener {
public:
KBDListener() : unk_0x04(0), mpNext(NULL) {}
virtual ~KBDListener() {}
virtual void OnAttach(KBDDevEvent* event);
virtual void OnDetach(KBDDevEvent* event);
virtual void OnKeyEvent(KBDKeyEvent* event);
u32 unk_0x04;
KBDListener* mpNext;
};
class KBDListenerOwn : public KBDListener {
public:
KBDListenerOwn(HKBManager* manager) : mpManager(manager) {}
virtual void OnAttach(KBDDevEvent* event);
virtual void OnDetach(KBDDevEvent* event);
virtual void OnKeyEvent(KBDKeyEvent* event);
HKBManager* mpManager; // 0x0C
};
static void SetLedCB(KBDEc result, void* arg);
static void AttachCB(KBDDevEvent* event);
static void DetachCB(KBDDevEvent* event);
static void KeyEventCB(KBDKeyEvent* event);
u8 mInitialized; // 0x00
u8 mAttached[2]; // 0x01
u8 pad_0x03;
u32 mModState; // 0x04
u32 mPendingLeds; // 0x08
const wchar_t* mpKeyTable; // 0x0C
u32 mKeyTableNum; // 0x10
KeyState_ mKeyStates[2]; // 0x14
KBDListenerOwn mListener; // 0xEC
u8 unk_0x00[0xFC];
static HKBManager sInstance;
};
} // namespace input
} // namespace textinput

View File

@@ -8,39 +8,52 @@ namespace textinput {
class Manager;
namespace keyboard {
namespace hwkey {
#ifdef TIMANAGER_IMPLEMENTATION
class HWKeyboard : public CommandSender {
#else
class HWKeyboard : CommandSender {
#endif
public:
struct AnimationFile {
u32 mAnimationNo;
char mFileName[0x40];
};
static const AnimationFile csAninationFile[8];
HWKeyboard(Manager *);
#ifdef TIMANAGER_IMPLEMENTATION
inline ~HWKeyboard();
#else
~HWKeyboard();
#endif
#ifdef TIMANAGER_IMPLEMENTATION
void setLanguage(Destination destination, Language language);
#endif
virtual void init();
virtual ~HWKeyboard();
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
wchar_t convertWCCode(wchar_t code) const;
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
void updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
#else
virtual void updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
#endif
virtual bool updateInput(input::HKBManager& hkbManager);
#ifdef TIINPUTFORM_IMPLEMENTATION
void resetQuoteState() { mbSingleQuoteClosing = 0; mbDoubleQuoteClosing = 0; }
#endif
private:
void updateShift(input::HKBManager& hkbManager);
bool updateRepeatKey_(input::HKBManager& hkbManager);
bool updateTriggerKey_(input::HKBManager& hkbManager);
bool updateTappingShift_(input::HKBManager& hkbManager);
public:
u16 convertWCCode(wchar_t wc) const;
void setLanguage(Destination destination, Language language);
private:
void controlKeyTriggeredHandler(input::HKBManager);
Manager *mgr() { return mpManager; }
Manager* mpManager; // 0x10
u8 field_0x14; // 0x14
bool field_0x15; // 0x15
bool field_0x16; // 0x16
#ifdef TIINPUTFORM_IMPLEMENTATION
u8 mbSingleQuoteClosing;
u8 mbDoubleQuoteClosing;
#else
u8 field_0x15; // 0x15
u8 field_0x16; // 0x16
#endif
};

View File

@@ -13,17 +13,43 @@
#include "tiZiString.h"
#include "tiSEId.h"
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
extern "C" wchar_t KPRGetChar(KPRQueue* queue);
extern "C" void KPRPutChar(KPRQueue* queue, wchar_t character);
extern "C" void KPRClearQueue(KPRQueue* queue);
extern "C" void KPRInitRegionUS();
extern "C" u8 KPRLookAhead(KPRQueue* queue, wchar_t* character, wchar_t* combining);
#endif
namespace textinput {
#ifdef TIMANAGER_IMPLEMENTATION
class Manager;
#endif
namespace inputform {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
class Base;
class EventHandler;
class LayoutByNW4R;
#endif
class EditBuffer {
#ifdef TIMANAGER_IMPLEMENTATION
friend class textinput::Manager;
public:
EditBuffer() : mpString(NULL), mpUnfixString(NULL), mpZiString(NULL), mpAllocator(NULL) {}
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
friend class LayoutByNW4R;
friend class Base;
#endif
public:
EditBuffer() : mpString(NULL), mpUnfixString(NULL), mpZiString(NULL), mpAllocator(NULL) {}
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
void create(MEMAllocator* allocator);
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual ~EditBuffer();
virtual void create(MEMAllocator* allocator);
void* getString() const { return mpString; }
void* getZiString() const { return mpZiString; }
#else
~EditBuffer();
#endif
private:
void* mpString; // 0x04
@@ -33,10 +59,27 @@ namespace textinput {
};
class DeadKeyStream {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
public:
DeadKeyStream() { KPRInitRegionUS(); init(); }
static wchar_t ToCombineClass(Language language, wchar_t code);
static wchar_t ToIndependentClass(wchar_t code);
inline wchar_t getChar();
void init();
u8 lookAhead() { return KPRLookAhead(&mKPRQueue, NULL, NULL); }
void putChar(wchar_t character) { KPRPutChar(&mKPRQueue, character); }
bool isEmpty() const { return mKPRQueue.oCount == 0; }
void clear() { KPRClearQueue(&mKPRQueue); }
private:
#ifdef TIMANAGER_IMPLEMENTATION
friend class textinput::Manager;
#endif
static bool sbCompatibleFilterEnabled;
static wchar_t ToIndependentClass(wchar_t wc);
static inline bool isCompatible(wchar_t character);
#elif defined(TI_PC_KEYBOARD_IMPLEMENTATION)
public:
static wchar_t ToIndependentClass(wchar_t code);
#endif
private:
KPRQueue mKPRQueue; // 0x00
};
@@ -85,17 +128,52 @@ namespace textinput {
// TODO - location
class RowInfoManager {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
friend class LayoutByNW4R;
friend class Base;
public:
RowInfoManager(u16 maxLength) : mpInfo(NULL), mMaxLength(maxLength), mpAllocator(NULL) {}
void init();
~RowInfoManager();
#endif
private:
Info_* mpInfo; // 0x00
u16 mMaxLength; // 0x04
MEMAllocator* mpAllocator; // 0x08
};
#ifdef TISIGNWINDOW_IMPLEMENTATION
bool isAtokActive() const;
#endif
virtual ~Base();
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual void onCommand(INPUT_COMMAND command, void* data);
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
Base(Manager* manager);
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual void onCommand(INPUT_COMMAND command, void* data);
void setCursorPos(tistring::Decolated* string, u32 pos);
void calcCursorTimer();
bool isAtokActive() const;
bool isVacancy() const;
void dirtyCacheAll();
tistring::Decolated* getCurrentString(bool inputting);
void moveCandidateToIdx(s32 index);
void onPressDownHWKB();
void onPressLeftHWKB();
void onPressRightHWKB();
void toggleAtokMode_(u8 operation);
void onSpaceKeyHWKB(u32 modifiers);
void onHKBCtrlCode(HVKCode code, u32 modifiers);
void confirmInput_();
void confirmInputting_(wchar_t character, bool direct, u16 letterMode, bool confirmOnly, void* holdingKey);
void inputCharZi_(wchar_t character, u32 modifiers);
void inputCharDefault_(wchar_t character, u32 modifiers);
void inputInputting_(wchar_t character);
inline bool hasZiPredictions() const;
inline bool usesZiPrediction() const;
inline void resetPredictionContext();
inline void resetInputRelation();
#endif
virtual void create(MEMAllocator* allocator, EditBuffer* editBuffer);
@@ -134,7 +212,6 @@ namespace textinput {
virtual void setAtokDictionary(void* atokDict, int atokDictSize, void* apotDict, int apotDictSize, void* nintendoDict, int nintendoDictSize);
virtual void closeAtokDictionary();
virtual bool isAtokDictionaryOpened();
bool isAtokActive() const;
void setZiDictionary(void* ziOemDict, void* ziDict) {
mpZiString->openDictionary(ziDict, ziOemDict);
@@ -144,7 +221,6 @@ namespace textinput {
void initZiString();
void resetContextPredict_();
void dirtyCacheAll();
void notifyChangeMode();
@@ -153,9 +229,12 @@ namespace textinput {
virtual void enableSpaceByRight(bool rightWithSpace);
virtual void onClose();
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
tistring::WithAtok* getCurrentString(bool fixed);
virtual bool canConvert() { return getCurrentString(false) == mpUnfixString; }
#else
virtual bool canConvert();
void* getCurrentString(bool flag);
#endif
virtual void setString(const wchar_t* string);
@@ -185,6 +264,10 @@ namespace textinput {
virtual void onSE(sound::SE seId);
#ifdef MYTIMANAGER_IMPLEMENTATION
void dirtyCacheAll();
#endif
virtual void clear();
virtual u32 calcCursorPos(f32 x, f32 y);
@@ -201,15 +284,21 @@ namespace textinput {
virtual void makeUpCursorPos(CursorPos* cursorPos, u32 pos, s32 startLine, s32 endLine);
bool isVacancy() const;
bool isPredictOn() const { return mbPredictOn; }
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
protected:
#if !defined(TIINPUTFORM_IMPLEMENTATION) && !defined(TIMANAGER_IMPLEMENTATION)
void setCursorPos(tistring::Decolated* string, u32 pos);
void calcCursorTimer();
#endif
void resetRelation();
nw4r::ut::Rect mRect; // 0x120
#else
private:
#endif
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
nw4r::ut::Rect mRect;
#else
Rect mRect;
#endif
nw4r::math::MTX34 mMtx; // 0x130
Destination meDestination; // 0x160
tistring::Decolated* mpString; // 0x164
@@ -217,6 +306,9 @@ namespace textinput {
tistring::WithZi* mpZiString; // 0x16C
InputMode meInputMode; // 0x170
PredictMode mePredictMode; // 0x174
#ifdef TIMANAGER_IMPLEMENTATION
friend class textinput::Manager;
#endif
bool mbPredictOn; // 0x178
bool mbDoWordWrap; // 0x179
bool mbRightWithSpace; // 0x17A
@@ -252,14 +344,18 @@ namespace textinput {
};
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
friend class EventHandler;
inline const nw4r::lyt::Pane* getLanguageTextPane() const;
#endif
public:
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName,
EventObserver* observer, const char* subName);
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
LayoutByNW4R(textinput::Manager*, nw4r::lyt::MultiArcResourceAccessor*, const char*, EventObserver*, const char*);
#endif
~LayoutByNW4R();
virtual void init();
virtual void onCommand(INPUT_COMMAND command, void* data);
virtual void onSE(sound::SE seId);
virtual void create(MEMAllocator* allocator, EditBuffer* editBuffer);
@@ -270,6 +366,9 @@ namespace textinput {
virtual nw4r::math::VEC2 getScale() const;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
void updateRepeatInput(u32 trig, u32 hold);
#endif
virtual void updateInputCommon(int chan, u32 trig, u32 hold, u32 release, void* data);
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
virtual bool updateInput(textinput::input::HKBManager& hkbManager);
@@ -280,27 +379,38 @@ namespace textinput {
virtual void setRootPaneScaleFor16x9();
virtual void setRootPaneScaleFor4x3();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual void onSE(sound::SE seId);
#endif
virtual void visibleSeparator(bool flag);
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
protected:
u8 unk_0x2C0[0x0C];
bool mbAbleToUp; // 0x2CC
bool mbAbleToDown; // 0x2CD
bool mbSeparator; // 0x2CE
u8 unk_0x2CF;
nw4rmanager::TiEventHandler* mpInputEventHandler; // 0x2D0
u8 unk_0x2D4[0x34];
};
#ifdef TI_INPUTFORM_SAMPLE_CLASS
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName,
EventObserver* observer, const char* subName)
: LayoutByNW4R(manager, resAccessor, arcName, observer, subName) {}
virtual ~Sample();
};
const void* mpLayoutData;
const void* mpLanguageData;
const char* mpFontName;
bool mbUpVisible;
bool mbDownVisible;
bool mbRepeat;
nw4rmanager::TiEventHandler* mpInputEventHandler;
nw4r::ut::ResFont mFont;
int mUpRepeat;
int mDownRepeat;
int mLeftRepeat;
int mRightRepeat;
int mDeleteRepeat;
int mConfirmRepeat;
u32 mRepeatButtons;
#else
private:
#ifdef MYTIMANAGER_IMPLEMENTATION
u8 unk_0x2C0[0x48];
#else
u8 unk_0x2C0[0x4C];
#endif
#endif
};
}
typedef inputform::LayoutByNW4R InputForm;
typedef inputform::Base InputFormBase;

View File

@@ -8,16 +8,41 @@ namespace textinput {
class KeyboardBase : public CommandSender {
public:
#ifdef TIMANAGER_IMPLEMENTATION
KeyboardBase() : meLanguage(JP) {}
#endif
virtual ~KeyboardBase() {}
#if !defined(TI_PC_KEYBOARD_IMPLEMENTATION) && !defined(TIMANAGER_IMPLEMENTATION) && !defined(TISIGNWINDOW_IMPLEMENTATION)
virtual void create(MEMAllocator* alloc) override;
virtual void init() override;
virtual void setCommandReceiver(CommandReceiver* receiver) override;
virtual void sendCommand(u32 command, void*) override;
#endif
#if !defined(TIMANAGER_IMPLEMENTATION) && !defined(TISIGNWINDOW_IMPLEMENTATION)
virtual void updateFromReceiver(u32, void*) override;
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
virtual void onKey(u32, void*);
#else
virtual void onKey(u32);
#endif
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
virtual int getType();
#else
virtual void getType();
#endif
virtual void setLanguage(Language language);
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
#ifdef TISIGNWINDOW_IMPLEMENTATION
virtual Language getLanguage() const;
#else
virtual Language getLanguage() const { return meLanguage; }
#endif
virtual void update() {}
#else
virtual Language getLanguage() const;
virtual void update();
#endif
virtual void onActive();
protected:

View File

@@ -19,12 +19,13 @@ namespace textinput {
bool isHoldingShift() const {
return isHWPressedShift() || isPressedShiftB();
}
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
u8 isCapsLock() const { return mbCpasLock; }
void setPressedShiftB(bool pressed) { mbPressedShiftB = pressed; }
#endif
u8 isHWPressedShift() const { return mbPressedShift; }
u8 isPressedShiftB() const { return mbPressedShiftB; }
void setHWPressedShift(u8 arg) { mbPressedShift = arg; }
void setPressedShiftB(u8 arg) { mbPressedShiftB = arg; }
void clearPressedShift() { mbPressedShift = 0; mbPressedShiftB = 0; }
void setHWPressedShift(const u8& arg) { mbPressedShift = arg; }
class Singleton {
public:

View File

@@ -9,8 +9,6 @@
#include "tiToolBar.h"
#include "tiPcKeyboard.h"
#include "tiCellPhone.h"
#include "tiPredictLang.h"
#include "tiSignWindow.h"
#include <nw4r/lyt/pane.h>
#include <nw4r/lyt/arcResourceAccessor.h>
@@ -25,16 +23,25 @@
namespace textinput {
class EventObserver {
public:
virtual void onInput(CommandReceiver::INPUT_COMMAND command, void* data); // 0x08
virtual void onCommand(CommandReceiver::INPUT_COMMAND command, void* data); // 0x0C
virtual void onEvent(nw4r::lyt::Pane* pane, u32 event); // 0x10
virtual void onInput(CommandReceiver::INPUT_COMMAND command, void* data) {} // 0x08
virtual void onCommand(CommandReceiver::INPUT_COMMAND command, void* data) {} // 0x0C
virtual void onEvent(nw4r::lyt::Pane* pane, u32 event) {} // 0x10
virtual void onSE(sound::SE seId);
virtual void onOK();
virtual void onCancel();
virtual void onOutOfLength();
virtual void onSE(sound::SE seId) {}
#ifdef TIMANAGER_IMPLEMENTATION
virtual void onOK();
virtual void onCancel();
virtual void onOutOfLength();
#else
virtual void onOK() { printf("OK!\n"); }
virtual void onCancel() { printf("Cancel!\n"); }
virtual void onOutOfLength() { printf("OutOfLength\n"); }
#endif
};
#ifdef TIMANAGER_IMPLEMENTATION
namespace predictlang { class LayoutByNW4R; }
#endif
class Manager : public Base {
public:
Manager(MEMAllocator* allocator, nw4r::lyt::MultiArcResourceAccessor* multiArc, textinput::EventObserver* event);
@@ -57,7 +64,10 @@ namespace textinput {
virtual void setWCString(const wchar_t* string);
virtual void setLanguage(Language language);
virtual Language getLanguage() const;
virtual Language getLanguage() const { return meLanguage; }
#ifdef MYTIMANAGER_IMPLEMENTATION
Language getLanguageForMemo() const { return meLanguage; }
#endif
virtual void setDestination(Destination destination);
@@ -68,49 +78,71 @@ namespace textinput {
virtual void setAspectRatio(bool b4x3);
#ifdef MYTIMANAGER_IMPLEMENTATION
MEMAllocator* getAllocatorForMemo() const { return mpAllocator; }
inputform::EditBuffer* getEditBufferForMemo() const { return mpEditBuffer; }
void setEditBufferForMemo(inputform::EditBuffer* editBuffer) { mpEditBuffer = editBuffer; }
void setHWKeyboardForMemo(keyboard::hwkey::HWKeyboard* keyboard) { mpHWKeyboard = keyboard; }
nw4r::lyt::MultiArcResourceAccessor* getMultiArcForMemo() const { return mpMultiArcResourceAccessor; }
EventObserver* getEventObserverForMemo() const { return mpEventObserver; }
InputForm* getInputFormForMemo() const { return mpInputForm; }
void setInputFormForMemo(InputForm* inputForm) { mpInputForm = inputForm; }
toolbar::LayoutByNW4R* getToolBarForMemo() const { return mpToolBar; }
candidatebox::LayoutByNW4R* getCandidateBoxForMemo() const { return mpCandidateBox; }
void setPCKeyboardForMemo(keyboard::pctype::LayoutByNW4R* keyboard) { mpPCKeyboard = keyboard; }
void setCellPhoneKeyboardForMemo(keyboard::cellphonetype::LayoutByNW4R* keyboard) { mpCellPhoneKeyboard = keyboard; }
void setCandidateBoxForMemo(candidatebox::LayoutByNW4R* candidateBox) { mpCandidateBox = candidateBox; }
void setToolBarForMemo(toolbar::LayoutByNW4R* toolBar) { mpToolBar = toolBar; }
void setPredictLanguageDialogForMemo(void* dialog) { mpPredictLanguageDialog = dialog; }
void setSignWindowForMemo(void* signWindow) { mpSignWindow = signWindow; }
void* getSignWindowForMemo() const { return mpSignWindow; }
keyboard::pctype::LayoutByNW4R* getPCKeyboardForMemo() const { return mpPCKeyboard; }
keyboard::cellphonetype::LayoutByNW4R* getCellPhoneKeyboardForMemo() const { return mpCellPhoneKeyboard; }
Destination getDestinationForMemo() const { return meDestination; }
void initAspect();
#endif
virtual void setSecretInputMode(bool secretInputMode) { mpInputForm->setSecretModeOn(secretInputMode); }
#if defined(IPL_ADDRESS_EDIT_CPP) || defined(TIMANAGER_IMPLEMENTATION)
void enableKSXFilter(bool compatibleFilter);
#endif
virtual void setDefaultPredictionJP(int num, const char** predicts);
virtual void setFixedPredictionJP(int num, const char** predicts);
virtual void setTitleText(wchar_t* titleText);
#ifdef TIMANAGER_IMPLEMENTATION
virtual void setTitleText(wchar_t* titleText);
void initAspect();
#else
virtual void setTitleText(const wchar_t* titleText);
#endif
void setTitleText(const wchar_t* titleText) {
nw4r::lyt::Pane* pane = mpInputForm->getPane("T_title_text");
nw4r::lyt::TextBox* textBox = nw4r::ut::DynamicCast<nw4r::lyt::TextBox*>(pane);
if (textBox != NULL) {
textBox->SetString(titleText, 0);
}
}
virtual void start();
virtual void end();
virtual void start() {}
virtual void end() {}
virtual InputForm* getInputForm() { return mpInputForm; }
virtual const InputForm* getInputForm() const;
virtual const InputForm* getInputForm() const { return mpInputForm; }
virtual keyboard::hwkey::HWKeyboard* getHWKeyboard() { return mpHWKeyboard; }
virtual const keyboard::hwkey::HWKeyboard* getHWKeyboard() const;
virtual const keyboard::hwkey::HWKeyboard* getHWKeyboard() const { return mpHWKeyboard; }
virtual keyboard::pctype::LayoutByNW4R* getPCKeyboard();
virtual const keyboard::pctype::LayoutByNW4R* getPCKeyboard() const;
virtual keyboard::pctype::LayoutByNW4R* getPCKeyboard() { return mpPCKeyboard; }
virtual const keyboard::pctype::LayoutByNW4R* getPCKeyboard() const { return mpPCKeyboard; }
virtual keyboard::cellphonetype::LayoutByNW4R* getCellPhoneKeyboard() { return mpCellPhoneKeyboard; }
virtual const keyboard::cellphonetype::LayoutByNW4R* getCellPhoneKeyboard() const;
virtual const keyboard::cellphonetype::LayoutByNW4R* getCellPhoneKeyboard() const { return mpCellPhoneKeyboard; }
virtual void* getSignKeyboard();
virtual const void* getSignKeyboard() const;
virtual void* getSignKeyboard() { return mpSignWindow; }
virtual const void* getSignKeyboard() const { return mpSignWindow; }
virtual candidatebox::LayoutByNW4R* getCandidateBox();
virtual candidatebox::LayoutByNW4R* getCandidateBox() { return mpCandidateBox; }
virtual const candidatebox::LayoutByNW4R* getCandidateBox() const { return mpCandidateBox; }
virtual toolbar::LayoutByNW4R* getToolBar();
virtual const toolbar::LayoutByNW4R* getToolBar() const;
virtual toolbar::LayoutByNW4R* getToolBar() { return mpToolBar; }
virtual const toolbar::LayoutByNW4R* getToolBar() const { return mpToolBar; }
virtual void* getPredictLanguageSelectDialog();
virtual const void* getPredictLanguageSelectDialog() const;
EventObserver* getEventObserver() { return mpEventObserver; }
virtual void* getPredictLanguageSelectDialog() { return mpPredictLanguageDialog; }
virtual const void* getPredictLanguageSelectDialog() const { return mpPredictLanguageDialog; }
virtual inputform::EditBuffer* createEditBuffer();
virtual keyboard::hwkey::HWKeyboard* createHWKeyboard();
@@ -126,17 +158,14 @@ namespace textinput {
virtual void setLayoutScaleFor4x3();
void enableCompatibleFilter(bool compatibleFilter);
void enableKSXFilter(bool flag);
void startPredictTurnOn(bool flag);
bool isPredictTurning() const;
bool isVacancy() const;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
bool isPredictTurning() const;
void startPredictTurnOn(bool enabled);
#endif
protected:
void initAspect();
protected:
private:
MEMAllocator* mpAllocator; // 0x04
nw4r::lyt::MultiArcResourceAccessor* mpMultiArcResourceAccessor; // 0x08
@@ -148,9 +177,14 @@ namespace textinput {
InputForm* mpInputForm; // 0x1C
candidatebox::LayoutByNW4R* mpCandidateBox; // 0x20
toolbar::LayoutByNW4R* mpToolBar; // 0x24
predictlang::LayoutByNW4R* mpPredictLanguageDialog; // 0x28
keyboard::signwindow::LayoutByNW4R* mpSignWindow; // 0x2C
#ifdef TIMANAGER_IMPLEMENTATION
predictlang::LayoutByNW4R* mpPredictLanguageDialog;
keyboard::signwindow::LayoutByNW4R* mpSignWindow;
#else
void* mpPredictLanguageDialog; // 0x28
void* mpSignWindow; // 0x2C
#endif
EventObserver* mpEventObserver; // 0x30
Destination meDestination; // 0x34

View File

@@ -14,20 +14,29 @@ namespace textinput {
class TiEventHandler : public gui::EventHandler {
public:
typedef struct Input {
u32 field_0x00; // 0x00 chan
f32 mfX; // 0x04
f32 mfY; // 0x08
u32 field_0x0C; // 0x0C trigger
u32 field_0x10; // 0x10 hold
u32 field_0x14; // 0x14 release
u8 dummy[8]; // 0x18
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
u32 controller;
f32 x;
f32 y;
u32 trigger;
u32 hold;
u32 release;
u8 remaining[8];
#else
// todo
u32 field_0x00; // 0x00
u8 dummy[8];
u32 field_0x0C; // 0x0C
u32 field_0x10; // 0x10
u8 dummy2[12];
#endif
} Input;
virtual void onEvent(gui::GUIComponent& comp, u32 event, void* data); // 0x0C
virtual void onTiEvent(gui::PaneComponent* paneComponent, u32 event, Input* input) = 0; // 0x18
virtual void setEventObserver(EventObserver *event); // 0x1C
virtual void setEventObserver(EventObserver *event) { mpEventObserver = event; } // 0x1C
protected:
EventObserver* mpEventObserver; // 0x08
@@ -81,21 +90,35 @@ namespace textinput {
PE_5,
PE_6,
PE_7,
PE_8,
PE_9,
PE_10,
PE_11,
PE_Last,
} AnmPaneEvent;
virtual void init() {} // 0x08
virtual void calc(); // 0x0C
virtual void onAnmEvent(AnmPaneEvent paneEvent); // 0x10
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
virtual void onAnmEvent(AnmPaneEvent) {}
#else
virtual void onAnmEvent(AnmPaneEvent paneEvent);
#endif // 0x10
virtual void changeAnimation(u32 id); // 0x14
virtual bool isInAnimation(); // 0x18
virtual Anim* searchAnimation(u32 id); // 0x1C
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
virtual bool isInAnimation() { return mpCurrentAnim != NULL; }
#else
virtual bool isInAnimation();
#endif // 0x18
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
virtual Anim* searchAnimation(u32 id) {
for (Anim* animation = static_cast<Anim*>(nw4r::ut::List_GetNext(&mAnms, NULL)); animation != NULL;
animation = static_cast<Anim*>(nw4r::ut::List_GetNext(&mAnms, animation))) {
if (animation->muID == id) return animation;
}
return NULL;
}
#else
virtual Anim* searchAnimation(u32 id);
#endif // 0x1C
virtual ~AnmPane(); // 0x20
@@ -133,11 +156,11 @@ namespace textinput {
class AnimPaneGroup {
public:
AnimPaneGroup() {}
#ifdef MYTIINPUTFORM_IMPLEMENTATION
AnimPaneGroup(nw4r::lyt::Group* group) : mpGroup(group) {
nw4r::ut::List_Init(&mAnmPaneList, offsetof(AnmPane, mGroupLink));
}
#endif
virtual void create() {} // 0x08
virtual void init() {} // 0x0C
@@ -191,7 +214,11 @@ namespace textinput {
virtual nw4r::lyt::Pane* get(int i) { return mpaFifo[i]; } // 0x10
virtual nw4r::lyt::Pane* getLast() { // 0x14
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
for (int i = MAX_COUNT-1; i > -1; i--) {
#else
for (int i = MAX_COUNT-1; i > -1; i++) {
#endif
if (mpaFifo[i] != NULL) {
return mpaFifo[i];
}
@@ -220,14 +247,14 @@ namespace textinput {
virtual bool updateInput(int point, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data); // 0x20
virtual bool updateInput(input::HKBManager& hkbManager); // 0x24
virtual TiLayout* getLayout(); // 0x28
virtual TiLayout* getLayout() { return mpLayout; } // 0x28
virtual nw4r::lyt::Pane* getPane(const char* paneName); // 0x2C
virtual const nw4r::lyt::Pane* getPane(const char* paneName) const; // 0x30
virtual u32 getFlightDuration(int point, const char* paneName); // 0x34
virtual void setAnimOn(bool flag); // 0x38
virtual void setAnimOn(bool flag) { mbAnimOn = flag; } // 0x38
virtual void drawPane(const char* paneName); // 0x3C
@@ -236,8 +263,16 @@ namespace textinput {
virtual void setProjectionMtx(); // 0x48
virtual void setPaneLastDrawReceived(nw4r::lyt::Pane* paneLastDraw); // 0x4C
virtual void initPaneLastDrawReceived(); // 0x50
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
virtual void setPaneLastDrawReceived(nw4r::lyt::Pane* pane) { mAnmPaneFifo.push(pane); }
#else
virtual void setPaneLastDrawReceived(nw4r::lyt::Pane* paneLastDraw);
#endif // 0x4C
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
virtual void initPaneLastDrawReceived() { mAnmPaneFifo.init(); }
#else
virtual void initPaneLastDrawReceived();
#endif // 0x50
virtual void setVisible(const char* paneName, bool flag); // 0x54
virtual bool isVisible(const char* paneName, bool* result) const; // 0x58
@@ -247,8 +282,8 @@ namespace textinput {
virtual AnmPane* searchAnmPane(const char* paneName); // 0x60
virtual AnmPane* searchAnmPane(wchar_t ch); // 0x64
virtual nw4r::ut::List& getAnmPaneList(); // 0x68
virtual gui::PaneManager* getPaneManager(); // 0x6C
virtual nw4r::ut::List& getAnmPaneList() { return mAnmPanes; } // 0x68
virtual gui::PaneManager* getPaneManager() { return mpPaneManager; } // 0x6C
virtual void AdjustPaneMtx(Mtx& mtx, const nw4r::lyt::DrawInfo& drawInfo, const nw4r::math::MTX34& mGlobalMtx); // 0x70

View File

@@ -1,340 +1,206 @@
#ifndef TEXTINPUT_PC_KEYBOARD_H
#define TEXTINPUT_PC_KEYBOARD_H
#include "tiKeyboard.h"
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
#include "tiPcKeyboardImpl.h"
#else
#include "tiNw4rManager.h"
#include "tiGUIManager.h"
#include "tiTextInputBase.h"
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
#include "tiKeyboard.h"
#endif
namespace textinput {
class Manager;
namespace predictlang {
class LayoutByNW4R;
}
namespace keyboard {
namespace signwindow {
class LayoutByNW4R;
}
namespace pctype {
class LayoutByNW4R;
class AnmPane;
class UIObj : public gui::EventHandler {
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
class UIObj {
public:
class Listener {
public:
virtual void onEvent(UIObj* uiObj, u32, void*) = 0; // 0x08
virtual void onEvent(UIObj*, u32, void*);
};
};
#endif
// TODO
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
class Base : public textinput::keyboard::KeyboardBase {
#else
class Base : public CommandSender {
#endif
public:
enum TranslateMode {
TM_00,
#ifdef TIINPUTFORM_IMPLEMENTATION
TM_Kana,
TM_Roman,
#endif
};
UIObj(u32 ctrlNo, LayoutByNW4R* layout, Listener* listener) : mCtrlNo(ctrlNo), mpLayout(layout) {
mpListener = listener;
}
virtual ~UIObj(); // 0x08
virtual void onEvent(gui::GUIComponent& comp, u32 event, void* data); // 0x0C
virtual void onGUIEvent(gui::PaneComponent& pane, u32 event, nw4rmanager::TiEventHandler::Input* input); // 0x18
protected:
u32 mCtrlNo; // 0x08
LayoutByNW4R* mpLayout; // 0x0C
Listener* mpListener; // 0x10
};
class UIModifierButton : public UIObj {
friend class LayoutByNW4R;
public:
UIModifierButton(u32 ctrlNo, LayoutByNW4R* layout, Listener* listener);
virtual ~UIModifierButton();
virtual void onGUIEvent(gui::PaneComponent& pane, u32 event, nw4rmanager::TiEventHandler::Input* input);
private:
gui::PaneComponent* mpPaneComp1; // 0x14
gui::PaneComponent* mpPaneComp2; // 0x18
nw4rmanager::AnmPane* mpAnmPane; // 0x1C
u8 mbFocused; // 0x20
};
class UIModePanel : public UIObj {
friend class LayoutByNW4R;
public:
UIModePanel(u32 ctrlNo, LayoutByNW4R* layout, Listener* listener);
virtual ~UIModePanel();
virtual void onGUIEvent(gui::PaneComponent& pane, u32 event, nw4rmanager::TiEventHandler::Input* input);
void Create(nw4rmanager::Layout* layout);
private:
u32 unk_0x14; // 0x14
gui::PaneComponent* mpComps1[5]; // 0x18
gui::PaneComponent* mpComps2[5]; // 0x2C
nw4rmanager::AnmPane* mpAnmPanes[5]; // 0x40
nw4r::lyt::Pane* mExtraPanes[3]; // 0x54
GXTexObj mTexObjs[4]; // 0x60
};
class AnmPane : public nw4rmanager::AnmPane {
public:
AnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: nw4rmanager::AnmPane(pane, observer) {
mState = 0;
}
virtual void init(); // 0x08
virtual void changeAnimation(u32 id); // 0x14
virtual ~AnmPane(); // 0x20
virtual u32 getState() const { return mState; } // 0x24
virtual u32 getKeyType() const { return mKeyType; } // 0x28
protected:
s32 mState; // 0x2C
u32 mKeyType; // 0x30
};
class NormalButtonAnmPane : public AnmPane {
public:
NormalButtonAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) {
mKeyType = 0;
}
virtual void onAnmEvent(AnmPaneEvent paneEvent); // 0x10
virtual ~NormalButtonAnmPane();
};
class ShiftCapsAnmPane : public AnmPane {
public:
ShiftCapsAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) {
mKeyType = 1;
mbFocused = false;
}
virtual void onAnmEvent(AnmPaneEvent paneEvent); // 0x10
virtual ~ShiftCapsAnmPane();
virtual bool isFocused() const; // 0x2C
private:
u8 mbFocused; // 0x34
};
class ToggleButtonAnmPane : public AnmPane {
public:
ToggleButtonAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) {
mKeyType = 2;
}
virtual void onAnmEvent(AnmPaneEvent paneEvent); // 0x10
virtual ~ToggleButtonAnmPane();
};
class OnOffButtonAnmPane : public AnmPane {
public:
OnOffButtonAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) {
mKeyType = 3;
}
virtual void onAnmEvent(AnmPaneEvent paneEvent); // 0x10
virtual ~OnOffButtonAnmPane();
};
class EventHandler : public nw4rmanager::TiEventHandler {
public:
EventHandler(LayoutByNW4R* layout) : mpLayout(layout) {}
virtual ~EventHandler(); // 0x08
virtual void onTiEvent(gui::PaneComponent* paneComponent, u32 event, TiEventHandler::Input* input); // 0x18
private:
LayoutByNW4R* mpLayout; // 0x0C
};
class Base : public KeyboardBase {
public:
typedef enum TranslateMode {
TM_00,
TM_01,
TM_02,
TM_03,
} TranslateMode;
typedef enum InputMode {
IM_00,
IM_01,
IM_02,
IM_03,
IM_04,
IM_05,
IM_06,
IM_07,
IM_08,
} InputMode;
typedef enum InputType {
enum InputType {
IT_00,
IT_01,
IT_02,
IT_03,
IT_04,
} InputType;
struct KeyState {
#ifdef TI_PCTYPE_SAMPLE_CLASS
KeyState() : mFlags(0), mIsABC(0), mAIUFlags(0), mLanguage((Language)1) {}
#endif
void refresh_();
void refreshText(nw4r::lyt::Pane* pane);
void setABCFlag(u32 flag);
wchar_t getWCCode(u32 keyType);
wchar_t getWCCode(char* out);
u32 mFlags; // 0x00
u32 mIsABC; // 0x04
u32 mAIUFlags; // 0x08
Language mLanguage; // 0x0C
const void* mpLanguageDep; // 0x10
Base* mpBase; // 0x14
};
#ifdef TI_PCTYPE_SAMPLE_CLASS
Base(Manager* manager) {
mKeyState.mpLanguageDep = NULL;
mKeyState.mpBase = this;
mpAllocator = NULL;
mbOnlyQwerty = false;
mpManager = manager;
}
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
enum InputMode {
IM_00,
IM_01,
IM_02,
IM_03,
IM_04,
};
virtual ~Base();
virtual void create(MEMAllocator* allocator) override; // 0x0C
virtual void init() override; // 0x10
virtual void updateFromReceiver(u32, void*) override; // 0x1C
virtual void onKey(u32, void*); // 0x20
virtual int getType(); // 0x24
virtual void setLanguage(Language language) override; // 0x28
virtual void onActive() override; // 0x34
virtual void inputCharCode(wchar_t wc); // 0x38
virtual void* getState(); // 0x3C
virtual bool isShiftOn() const; // 0x40
virtual bool isCapsOn() const; // 0x44
virtual bool isABC(); // 0x48
virtual void setABC(bool); // 0x4C
virtual int getABCInputMode() const; // 0x50
virtual int getAIUInputMode() const; // 0x54
virtual TranslateMode getTranslateMode() const; // 0x58
virtual void setTranslateMode(TranslateMode mode); // 0x5C
virtual void onlyQwerty(bool); // 0x60
virtual void setLangKeyActive(bool); // 0x64
virtual void setInputModeJP(bool, u32, u32); // 0x68
virtual void setInputModeCK(u32); // 0x6C
virtual void refreshState(); // 0x70
virtual void changeABCInputMode(InputMode mode); // 0x74
virtual void changeAIUInputMode(InputMode mode); // 0x78
virtual void onClose(); // 0x7C
virtual wchar_t getWCCode(char* out); // 0x80
virtual u32 getControlKey(char* out); // 0x84
virtual void sendInputWChar(wchar_t wc, bool flag); // 0x88
virtual void goSignInputMode(); // 0x8C
virtual void changePredictLanguage(); // 0x90
virtual void updateFixMode(); // 0x94
protected:
Manager* mgr() { return mpManager; }
public:
u8 unk_0x14; // 0x14
u8 unk_0x15[3]; // 0x15
u32 unk_0x18; // 0x18
const void* mpLanguageDep; // 0x1C
KeyState mKeyState; // 0x20
MEMAllocator* mpAllocator; // 0x38
u8 mbOnlyQwerty; // 0x3C
u8 mbLangKeyActive; // 0x3D
u8 unk_0x3E[2]; // 0x3E
Manager* mpManager; // 0x40
};
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public UIObj::Listener {
public:
#ifdef TI_PCTYPE_SAMPLE_CLASS
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, arcName, observer), mpEventHandler(NULL),
mShiftButton(1, this, this), mCapsButton(0, this, this), mModePanel(2, this, this) {}
#endif
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override;
virtual void updateFromReceiver(u32, void*) override;
virtual void onKey(u32, void*) override;
virtual void setLanguage(Language language) override;
virtual void getType() override;
virtual void setLanguage(Language) override;
virtual void onActive() override;
virtual void inputCharCode(wchar_t wc) override;
virtual void setABC(bool) override;
virtual void setTranslateMode(TranslateMode mode) override;
virtual void onlyQwerty(bool) override;
virtual void setLangKeyActive(bool) override;
virtual void setInputModeJP(bool, u32, u32) override;
virtual void setInputModeCK(u32) override;
virtual void refreshState() override;
virtual void onClose() override;
virtual void sendInputWChar(wchar_t wc, bool flag) override;
virtual void goSignInputMode() override;
virtual void changePredictLanguage() override;
virtual void draw(); // 0x11C
virtual void calc(); // 0x120
virtual void setPredictLanguageDialog(predictlang::LayoutByNW4R* dialog); // 0x124
virtual void setSignWindow(signwindow::LayoutByNW4R* window); // 0x128
virtual void setLineFeedButton(bool); // 0x12C
virtual void setPredictLanguageButton(bool); // 0x130
virtual void setSignWindowButton(bool); // 0x134
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data); // 0x138
virtual bool updateInput(textinput::input::HKBManager& hkbManager); // 0x13C
virtual void changeAnimationAllToNormal(); // 0x140
virtual void throwReleaseForAll(); // 0x144
virtual void cancelStateFocusIn(); // 0x148
virtual void updatePredictLanguage(CommandReceiver::ChangePredictMode* mode); // 0x14C
virtual void updateDakuten(); // 0x150
virtual void initLayout(); // 0x154
virtual void onEvent(UIObj* uiObj, u32, void*); // 0x158
void createAnmPane_(MEMAllocator* allocator);
void onPressedCaps();
void onPressedShift(bool);
void onReleasedShift();
private:
EventHandler* mpEventHandler; // 0xF0
predictlang::LayoutByNW4R* mpPredictLanguageDialog; // 0xF4
signwindow::LayoutByNW4R* mpSignWindow; // 0xF8
bool mbLineFeed; // 0xFC
u8 unk_0xFD[3]; // 0xFD
UIModifierButton mShiftButton; // 0x100
UIModifierButton mCapsButton; // 0x124
UIModePanel mModePanel; // 0x148
};
#ifdef TI_PCTYPE_SAMPLE_CLASS
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, arcName, observer) {}
virtual ~Sample();
};
virtual void inputCharCode(u16);
virtual void getState();
virtual bool isShiftOn() const;
virtual bool isCapsOn() const;
virtual bool isABC();
virtual void setABC(bool);
virtual InputMode getABCInputMode() const;
virtual InputMode getAIUInputMode() const;
virtual TranslateMode getTranslateMode() const;
virtual void setTranslateMode(TranslateMode);
virtual void onlyQwerty(bool);
virtual void setLangKeyActive(bool);
virtual void setInputModeJP(bool, u32, u32);
virtual void setInputModeCK(u32);
virtual void refreshState();
virtual void changeABCInputMode(InputMode);
virtual void changeAIUInputMode(InputMode);
virtual void onClose();
virtual void getWCCode(char*);
virtual void getControlKey(char*);
virtual void sendInputWChar(u16, bool);
virtual void goSignInputMode();
virtual void changePredictLanguage();
virtual void updateFixMode();
#else
class Sample {};
virtual ~Base();
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual void setCommandReceiver(textinput::CommandReceiver*);
virtual void updateFromReceiver(u32, void*);
virtual void onKey();
virtual void getType();
virtual void setLanguage();
virtual void getLanguage();
virtual void update();
virtual void onActive();
virtual void inputCharCode();
virtual void getState();
virtual void isShiftOn();
virtual void isCapsOn();
virtual void isABC();
virtual void setABC();
virtual void getABCInputMode();
virtual void getAIUInputMode();
virtual TranslateMode getTranslateMode();
virtual void setTranslateMode(TranslateMode);
virtual void onlyQwerty();
virtual void setLangKeyActive(bool);
virtual void setInputModeJP();
virtual void setInputModeCK();
virtual void refreshState();
virtual void changeABCInputMode();
virtual void changeAIUInputMode();
virtual void onClose();
virtual void getWCCode();
virtual void getControlKey();
virtual void sendInputWChar();
virtual void goSignInputMode();
virtual void changePredictLanguage();
virtual void updateFixMode();
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
private:
u8 mKeyboardInputFlags[8];
const void* mpKeyStateTable;
u32 mTranslateMode;
u32 mABCInputMode;
u32 mAIUInputMode;
u32 mCurrentInputType;
u32 mInputState;
const void* mpLanguageData;
#ifdef TIINPUTFORM_IMPLEMENTATION
MEMAllocator* mpAllocator;
#endif
bool mbOnlyQwerty;
bool mbLanguageKeyActive;
u16 mKeyboardFlags;
void* mpInputSettings;
void* mpCurrentKeyState;
public:
#ifdef TIINPUTFORM_IMPLEMENTATION
bool isQwertyOnly() const { return mbOnlyQwerty; }
bool isLanguageKeyActive() const { return mbLanguageKeyActive; }
#endif
u32 getTranslateModeForMemo() const { return mTranslateMode; }
u32 getABCInputModeForMemo() const { return mABCInputMode; }
u32 getAIUInputModeForMemo() const { return mAIUInputMode; }
#endif
};
// TODO
class LayoutByNW4R : public Base, public nw4rmanager::Layout
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
, public UIObj::Listener
#endif
{
public:
// TODO - ...
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
virtual void draw();
virtual void calc();
virtual void setPredictLanguageDialog(void*);
virtual void setSignWindow(void*);
virtual void setLineFeedButton(bool);
virtual void setPredictLanguageButton(bool);
virtual void setSignWindowButton(bool);
#endif
virtual void onClose();
void onPressedShift(bool shift);
void onReleasedShift();
#ifdef TIINPUTFORM_IMPLEMENTATION
bool hasLineFeedButton() const { return mbLineFeedButton; }
private:
void* mpPredictLanguageDialog;
void* mpSignWindow;
bool mbLineFeedButton;
public:
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) override;
virtual bool updateInput(input::HKBManager& hkbManager) override;
#endif
};
} // namespace pctype
} // namespace keyboard
} // namespace textinput
#endif // TEXTINPUT_PC_KEYBOARD_H
#endif
#endif // TEXTINPUT_HW_KEYBOARD_H

View File

@@ -226,12 +226,6 @@ namespace textinput {
State mState;
const LanguageData* mpInitialLanguageData;
KeyState mKeyState;
#ifdef TIHWKEYBOARD_IMPLEMENTATION
public:
KeyState& hardwareKeyState() { return mKeyState; }
bool hardwareLanguageKeyActive() const { return mbLanguageKeyActive; }
protected:
#endif
MEMAllocator* mpAllocator;
bool mbOnlyQwerty;
bool mbLanguageKeyActive;

View File

@@ -14,13 +14,17 @@ namespace textinput {
class Base : public CommandSender {
public:
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
#if defined(TI_PREDICTLANG_SAMPLE_CLASS) || defined(TIMANAGER_IMPLEMENTATION)
Base(Manager* manager) : mePredictMode(inputform::Base::PM_USEn), mpAllocator(NULL), mpManager(manager) {}
#endif
virtual ~Base() {}
virtual void create(MEMAllocator* allocator) override { mpAllocator = allocator; }
#ifdef TIMANAGER_IMPLEMENTATION
virtual ~Base();
virtual void init();
virtual void create(MEMAllocator* allocator) override;
#else
virtual void create(MEMAllocator* allocator) override { mpAllocator = allocator; }
#endif
virtual void setPredictMode(inputform::Base::PredictMode mode) { mePredictMode = mode; }
protected:
@@ -34,16 +38,20 @@ namespace textinput {
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public nw4rmanager::AnmObserver {
public:
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, arcName, observer), mbActive(false), mbInput(false),
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(resAccessor, layoutName, observer), mbActive(false), mbInput(false),
mpEventHandler(NULL), meDestination(DST_US), mpCaller(NULL) {}
#elif defined(TI_PREDICTLANG_SAMPLE_CLASS)
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, "fs_prdicSelWidw_a.brlyt", observer), mbActive(false), mbInput(false),
mpEventHandler(NULL), meDestination(DST_US), mpCaller(NULL) {}
#endif
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator) override;
virtual void draw() override;
virtual void init() override;
virtual void draw() override;
virtual void open(inputform::Base::PredictMode predictMode, keyboard::KeyboardBase* keyboard);
virtual void endToOpen();
@@ -70,12 +78,21 @@ namespace textinput {
keyboard::KeyboardBase* mpCaller; // 0xD4
};
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
#if defined(TI_PREDICTLANG_SAMPLE_CLASS) || defined(TIMANAGER_IMPLEMENTATION)
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, arcName, observer) {}
#ifdef TIMANAGER_IMPLEMENTATION
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, resAccessor, observer, layoutName) {}
#else
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, observer) {}
#endif
#ifdef TIMANAGER_IMPLEMENTATION
virtual ~Sample();
#else
virtual ~Sample() {}
#endif
};
#endif

View File

@@ -7,13 +7,7 @@ namespace textinput {
namespace extend {
namespace savedata {
typedef struct MemoSetting {
union {
u8 uRevisionAndType; // 0x00
struct {
u8 uType : 4; // 0x00:11110000
u8 uRevision : 4; // 0x00:00001111
};
};
u8 uRevisionAndType; // 0x00
union {
struct {

View File

@@ -3,152 +3,132 @@
#include "tiKeyboard.h"
#include "tiNw4rManager.h"
#include "tiTextInputBase.h"
#include "tiSwData.h"
namespace textinput {
class Manager;
class Manager;
namespace keyboard {
namespace keyboard {
namespace signwindow {
struct LanguageDependency {
u8 count;
const PaneNameToCharCodeInSignMode* keys;
};
namespace signwindow {
struct LanguageDependency {
u8 count;
const PaneNameToCharCodeInSignMode* keys;
};
class Base : public KeyboardBase {
public:
virtual ~Base();
virtual void create(MEMAllocator*) override;
virtual void init() override;
virtual void onKey(u32, void*) override;
virtual bool isLocked();
virtual void setPage(u8);
virtual u8 getPage();
virtual void movePrevSignPage();
virtual void moveNextSignPage();
virtual void close();
virtual int getType() override;
virtual void setLanguage(Language) override;
protected:
u8 mInputFlags;
bool mbLocked;
bool mbRepeat;
u8 muPage;
const LanguageDependency* mpLanguageDependency;
MEMAllocator* mpAllocator;
Manager* mpManager;
};
class EventHandler;
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public nw4rmanager::AnmObserver {
public:
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator*) override;
virtual void init() override;
virtual void onKey(u32, void*) override;
virtual void movePrevSignPage() override;
virtual void moveNextSignPage() override;
virtual void close() override;
virtual void draw() override;
virtual void open(KeyboardBase*, bool);
virtual bool isActive();
virtual void onChangeAnmState(AnmEvent, nw4rmanager::AnmPane*, nw4rmanager::Anim*) override;
virtual bool updateInput(int, f32, f32, u32, u32, u32, void*) override;
virtual bool updateInput(input::HKBManager&) override;
virtual void throwReleaseForAll();
virtual void resetAnmSignWindow();
virtual void setSignKeyTop(u16, u16);
virtual void setPageNumber(u16);
virtual void endToClose();
virtual void startToInput();
virtual void movePrevSignWindow();
virtual void moveNextSignWindow();
bool mbActive;
bool mbInput;
EventHandler* mpEventHandler;
KeyboardBase* mpKeyboard;
};
class Sample : public LayoutByNW4R {
public:
virtual ~Sample();
};
class EventHandler : public nw4rmanager::TiEventHandler {
public:
explicit EventHandler(LayoutByNW4R* layout) : mpLayoutByNW4R(layout) {}
virtual ~EventHandler();
virtual void onTiEvent(gui::PaneComponent*, u32, Input*) override;
LayoutByNW4R* mpLayoutByNW4R;
};
class AnmPane : public nw4rmanager::AnmPane {
public:
AnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: nw4rmanager::AnmPane(pane, observer), muAnimation(0) {}
inline virtual ~AnmPane();
virtual void init() override;
virtual void changeAnimation(u32) override;
virtual u32 getKeyType() const;
protected:
s32 muAnimation;
u32 muKeyType;
};
class CellPhoneSignAllAnmPane : public AnmPane {
public:
CellPhoneSignAllAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: AnmPane(pane, observer) { muKeyType = 0; }
virtual ~CellPhoneSignAllAnmPane();
virtual void init() override;
virtual void onAnmEvent(AnmPaneEvent) override;
};
class CellPhoneSignScrollAnmPane : public AnmPane {
public:
CellPhoneSignScrollAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: AnmPane(pane, observer) { muKeyType = 1; }
virtual ~CellPhoneSignScrollAnmPane();
virtual void init() override;
virtual void onAnmEvent(AnmPaneEvent) override;
};
class CellPhoneSignButtonPane : public AnmPane {
public:
CellPhoneSignButtonPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: AnmPane(pane, observer) { muKeyType = 2; }
virtual ~CellPhoneSignButtonPane();
virtual void init() override;
virtual void onAnmEvent(AnmPaneEvent) override;
};
}
}
}
class Base : public KeyboardBase {
public:
#ifdef TI_SIGNWINDOW_SAMPLE_CLASS
Base(Manager* manager) : mpAllocator(NULL), mpManager(manager) {}
#endif
virtual ~Base();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override;
virtual void onKey(u32, void*);
virtual int getType();
virtual void setLanguage(Language language) override;
virtual bool isLocked(); // 0x38
virtual void setPage(u8 page); // 0x3C
virtual u8 getPage(); // 0x40
virtual void movePrevSignPage(); // 0x44
virtual void moveNextSignPage(); // 0x48
virtual void close(); // 0x4C
protected:
u8 mInputFlags; // 0x14
bool mbLocked; // 0x15
bool mbRepeat; // 0x16
u8 muPage; // 0x17
const LanguageDependency* mpLanguageDependency; // 0x18
MEMAllocator* mpAllocator; // 0x1C
Manager* mpManager; // 0x20
};
class AnmPane;
class EventHandler;
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public nw4rmanager::AnmObserver {
public:
#ifdef TI_SIGNWINDOW_SAMPLE_CLASS
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, arcName, observer), mbActive(false), mbInput(false),
mpEventHandler(NULL), mpKeyboard(NULL) {}
#endif
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override;
virtual void onKey(u32, void*) override;
virtual void movePrevSignPage() override; // 0x44
virtual void moveNextSignPage() override; // 0x48
virtual void close() override; // 0x4C
virtual void draw(); // 0xD4
virtual void open(KeyboardBase* keyboard, bool flag); // 0xD8
virtual bool isActive(); // 0xDC
virtual void onChangeAnmState(nw4rmanager::AnmObserver::AnmEvent anmEvent,
nw4rmanager::AnmPane* anmPane, nw4rmanager::Anim* anim); // 0xE0
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data); // 0xE4
virtual bool updateInput(textinput::input::HKBManager& hkbManager); // 0xE8
virtual void throwReleaseForAll(); // 0xEC
virtual void resetAnmSignWindow(); // 0xF0
virtual void setSignKeyTop(u16, u16); // 0xF4
virtual void setPageNumber(u16); // 0xF8
virtual void endToClose(); // 0xFC
virtual void startToInput(); // 0x100
virtual void movePrevSignWindow(); // 0x104
virtual void moveNextSignWindow(); // 0x108
private:
bool mbActive; // 0xD0
bool mbInput; // 0xD1
EventHandler* mpEventHandler; // 0xD4
KeyboardBase* mpKeyboard; // 0xD8
};
#ifdef TI_SIGNWINDOW_SAMPLE_CLASS
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, arcName, observer) {}
virtual ~Sample();
};
#else
class Sample {};
#endif
class EventHandler : public nw4rmanager::TiEventHandler {
public:
explicit EventHandler(LayoutByNW4R* layout) : mpLayoutByNW4R(layout) {}
virtual ~EventHandler();
virtual void onTiEvent(gui::PaneComponent*, u32, Input*) override;
LayoutByNW4R* mpLayoutByNW4R;
};
class AnmPane : public nw4rmanager::AnmPane {
public:
AnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: nw4rmanager::AnmPane(pane, observer), muAnimation(0) {}
inline virtual ~AnmPane();
virtual void init() override;
virtual void changeAnimation(u32) override;
virtual u32 getKeyType() const;
protected:
s32 muAnimation;
u32 muKeyType;
};
class CellPhoneSignAllAnmPane : public AnmPane {
public:
CellPhoneSignAllAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: AnmPane(pane, observer) { muKeyType = 0; }
virtual ~CellPhoneSignAllAnmPane();
virtual void init() override;
virtual void onAnmEvent(AnmPaneEvent) override;
};
class CellPhoneSignScrollAnmPane : public AnmPane {
public:
CellPhoneSignScrollAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: AnmPane(pane, observer) { muKeyType = 1; }
virtual ~CellPhoneSignScrollAnmPane();
virtual void init() override;
virtual void onAnmEvent(AnmPaneEvent) override;
};
class CellPhoneSignButtonPane : public AnmPane {
public:
CellPhoneSignButtonPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: AnmPane(pane, observer) { muKeyType = 2; }
virtual ~CellPhoneSignButtonPane();
virtual void init() override;
virtual void onAnmEvent(AnmPaneEvent) override;
};
} // namespace signwindow
} // namespace keyboard
} // namespace textinput
#endif // TEXTINPUT_SIGN_WINDOW_H

View File

@@ -3,7 +3,9 @@
#include <revolution/types.h>
#include <revolution/mem/allocator.h>
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#include <revolution/kpr.h>
#endif
namespace textinput {
namespace tistring {
@@ -34,15 +36,19 @@ namespace textinput {
virtual void setLength(u16);
virtual wchar_t* getWCString() const;
virtual wchar_t* getWCString() const { return mpszString; }
virtual void setCandidate(wchar_t candidate) { mwcCandidate = candidate; }
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual wchar_t getCandidate() const { return mwcCandidate; }
#else
virtual wchar_t getCandidate() { return mwcCandidate; }
#endif
virtual bool hasCandidate() const;
virtual wchar_t getLastWChar();
protected:
private:
u16 muMaxLength; // 0x04
u16 muLength; // 0x06
@@ -55,41 +61,56 @@ namespace textinput {
};
class KanaStream {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
public:
KPRQueue mQueue;
wchar_t mPending;
wchar_t mOutput[5];
#else
private:
u8 field_0x00[0x24];
#endif
};
class Decolated : public StringBase {
public:
enum TranslateMode { TM_Direct, TM_Kana, TM_Roman, TM_Hangul };
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
Decolated(u16 maxLen) : StringBase(maxLen), mCursorStart(0), mCursorEnd(0), mbSustain(false), mTranslateMode(0) { initKanaConverter(); }
virtual ~Decolated();
#else
Decolated(u16 maxLen) : StringBase(maxLen), field_0x18(0), field_0x1C(0), field_0x20(0), field_0x24(0) { initKanaConverter(); }
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual ~Decolated();
enum TranslateMode { TM_Direct, TM_Kana, TM_Roman, TM_Hangul };
virtual void clear();
virtual void set(const wchar_t* string);
virtual void setLength(u16);
virtual void inputChar(wchar_t);
virtual void inputString(const wchar_t*);
virtual void setLength(u16 length);
void setTranslateMode(TranslateMode mode);
TranslateMode getTranslateMode() const { return static_cast<TranslateMode>(mTranslateMode); }
void inputString(const wchar_t* string, TranslateMode mode);
virtual void inputChar(wchar_t ch);
virtual void inputString(const wchar_t* string);
virtual void deleteChar();
virtual void backSpace();
virtual void confirm(const wchar_t*);
virtual void confirm(const wchar_t* string);
virtual bool moveCursorRight();
virtual bool moveCursorLeft();
virtual void setCursorPos(u32);
virtual void setCursorPos(u32 pos);
virtual void onSustain();
virtual void offSustain();
virtual bool isOnSustain();
virtual u32 getCursorPos() const;
virtual void getCursorPos(u32*, u32*);
virtual void getCursorPos(u32* start, u32* end);
virtual bool canBackSpace();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual bool deleteForward();
virtual void getSelected(u32&, u32&);
#else
virtual void deleteForward();
#endif
virtual void getSelected(u32& start, u32& end);
virtual wchar_t getWCharAtCursor();
virtual void replaceAtCursor(wchar_t);
virtual void replaceAtCursor(wchar_t ch);
virtual bool isDakuten();
virtual void converDakuten();
virtual bool isHandaku();
@@ -99,68 +120,114 @@ namespace textinput {
virtual void converSmall();
virtual bool atTheBeginningOfASentence();
virtual void initKanaConverter();
virtual void* getKanaBuffer();
virtual wchar_t* getKanaBuffer();
virtual bool isKanaFix() const;
virtual void confirmKana();
virtual void clearKana();
virtual void EnableKSXFilter(bool);
virtual void EnableKSXFilter(bool enable);
#else
virtual void inputChar();
virtual void inputString();
virtual void deleteChar();
virtual void backSpace();
virtual void confirm();
virtual void moveCursorRight();
virtual void moveCursorLeft();
virtual void setCursorPos();
virtual void onSustain();
virtual void offSustain();
virtual void isOnSustain();
virtual void getCursorPos();
virtual void getCursorPos(u32*, u32*);
virtual void canBackSpace();
virtual void deleteForward();
virtual void getSelected();
virtual void getWCharAtCursor();
virtual void replaceAtCursor();
virtual void isDakuten();
virtual void converDakuten();
virtual void isHandaku();
virtual void converHandaku();
virtual void convertAll();
virtual void isSmall();
virtual void converSmall();
virtual bool atTheBeginningOfASentence();
virtual void initKanaConverter();
virtual void getKanaBuffer();
virtual void isKanaFix();
virtual void confirmKana();
virtual void clearKana();
virtual void EnableKSXFilter();
void setTranslateMode(TranslateMode mode);
TranslateMode getTranslateMode() const { return static_cast<TranslateMode>(mTranslateMode); }
void inputString(const wchar_t* string, TranslateMode mode);
#endif
private:
u32 mCursorStart; // 0x18
u32 mCursorEnd; // 0x1C
u8 mbSustain; // 0x20
s32 mTranslateMode; // 0x24
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
u32 mCursorStart;
u32 mCursorEnd;
bool mbSustain;
u32 mTranslateMode;
#else
u32 field_0x18; // 0x18
u32 field_0x1C; // 0x1C
u8 field_0x20; // 0x20
u32 field_0x24; // 0x24
#endif
KanaStream mKanaStream; // 0x28
};
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
class WithAtok : public Decolated {
public:
struct DrawInfo;
~WithAtok();
WithAtok(u16 maxLength) : Decolated(maxLength) {}
virtual ~WithAtok();
virtual void pushBack(wchar_t ch);
virtual void popBack();
virtual void inputChar(wchar_t);
virtual void inputChar(wchar_t ch);
virtual void backSpace();
virtual void confirm(const wchar_t*);
virtual void confirm(const wchar_t* string);
virtual bool moveCursorRight();
virtual bool moveCursorLeft();
virtual void getCursorPos(u32*, u32*);
virtual void getCursorPos(u32* start, u32* end);
struct DrawInfo {
const wchar_t* string;
u32 start;
u32 end;
u32 selectedStart;
u32 selectedEnd;
};
virtual bool isFix();
virtual void setFix(bool);
virtual void setFix(bool fix);
virtual void initConverting();
virtual bool isConverting();
virtual wchar_t* getConfirmedWCString() const;
virtual int getCurrentNumPredicted();
virtual bool getPredicted(int, wchar_t*);
virtual void commitPredicted(int);
virtual void setSelectedCandidate(long);
virtual void getPredicted(int index, wchar_t* string);
virtual void commitPredicted(int index);
virtual void setSelectedCandidate(s32 index);
virtual bool isCandidateSelected();
virtual int getSelectedCandidate();
virtual s32 getSelectedCandidate();
virtual void init();
virtual void setInputting(wchar_t);
virtual void getDrawString(DrawInfo&);
virtual void openDictionary(void*, int, void*, int, void*, int);
virtual void setInputting(wchar_t ch);
virtual void getDrawString(DrawInfo& info);
virtual void openDictionary(void* atok, int atokSize, void* apot, int apotSize, void* nintendo, int nintendoSize);
virtual void closeDictionary();
virtual bool hasConfirmedString();
virtual void enableConfirmedString(bool);
virtual void enableConfirmedString(bool enable);
virtual void startConverting();
virtual bool isDictionaryOpened();
virtual void changeKanaMode(bool);
virtual int getInputStringLength();
virtual void changeKanaMode(bool kana);
virtual wchar_t getInputStringLength();
virtual void resetRelation();
virtual void setFixMode(bool);
virtual void setFixPrediction(int, const char* const*);
virtual void setDefaultPrediction(int, const char* const*);
virtual int getSelectedConverting();
virtual int getFixedPredictionNum();
virtual void setFixMode(bool fixed);
virtual void setFixPrediction(int count, const char** predictions);
virtual void setDefaultPrediction(int count, const char** predictions);
virtual s16 getSelectedConverting();
virtual s32 getFixedPredictionNum();
};
#else
class WithAtok : public StringBase {};
#endif
}
}

View File

@@ -6,10 +6,17 @@
#include <nw4r/ut/CharWriter.h>
#include <nw4r/ut/Rect.h>
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#include <string.h>
#endif
namespace textinput {
namespace textdrawer {
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
class Base : public nw4r::ut::CharWriter {
#else
class Base : nw4r::ut::CharWriter {
#endif
public:
typedef struct ViewPort {
f32 xOrig; // 0x00
@@ -27,11 +34,23 @@ namespace textinput {
} CursorPos;
typedef struct DrawInfo {
nw4r::ut::Rect rect; // 0x00
wchar_t character; // 0x10
u8 unk_0x12[6]; // 0x12
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
nw4r::ut::Rect rect;
wchar_t character;
#else
u8 unk_0x00[32];
#endif
} DrawInfo;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
Base() : mpDrawAllocator(NULL), mfViewX(0.0f), mfViewY(0.0f), mfViewWidth(0.0f), mfViewHeight(0.0f),
mfVIWidth(640.0f), mbAspect4x3(false), mbDrawClipped(false), muLine(0), mfLineSpacing(0.0f),
mfCharacterSpacing(0.0f), mfFontWidth(0.0f), mfFontHeight(0.0f), mfModifyStartY(0.0f), mfMinScrollY(0.0f),
muDrawStartPos(0), muDrawEndPos(65535), mbSecretMode(false), muDrawModifyStartLine(0), muDrawModifyEndLine(0),
muDrawModifyStartPos(0), muDrawModifyEndPos(0), muCachedStartPos(0), muCachedEndPos(0), mbDrawCache(false),
mfCachedCursorX(0.0f), mfCachedCursorY(0.0f), mfDrawScrollY(0.0f), muCachedCursorPosition(0),
mbCursorCache(false), mbMaintainCursorCache(true) { memset(&mCachedCursor, 0, sizeof(mCachedCursor)); }
#endif
virtual void create(MEMAllocator* allocator);
virtual void draw(CursorPos* cursorPos);
virtual void draw();
@@ -53,7 +72,7 @@ namespace textinput {
virtual nw4r::math::VEC2 getScale() const = 0;
virtual void setSecretModeOn(bool secretMode);
virtual void setSecretModeOn(bool secretMode) { mbSecretMode = secretMode; }
virtual void doBeforeDrawProcess(const wchar_t*, u32, const DrawInfo& drawInfo);
virtual void doAfterDrawProcess(const wchar_t*, u32, const DrawInfo& drawInfo);
@@ -75,49 +94,80 @@ namespace textinput {
virtual u32 getEndPos() const;
// todo
virtual void setDrawModifyScopeLine(s32, s32);
virtual void setDrawCacheScopeLine(s32, s32);
virtual void modifyCursorCache(s32, u32, f32, f32, f32, f32);
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual void setDrawModifyScopeLine(s32 startLine, s32 endLine);
virtual void setDrawCacheScopeLine(s32 startLine, s32 endLine);
virtual void modifyCursorCache(s32 line, u32 position, f32 x, f32 y, f32 width, f32 height);
#else
virtual void setDrawModifyScopeLine();
virtual void setDrawCacheScopeLine();
virtual void modifyCursorCache();
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual bool isEnableCursorCache() const;
virtual s32 getDrawModifyStartLine() const;
virtual s32 getDrawModifyEndLine() const;
#else
virtual void isEnableCursorCache();
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual u32 getDrawModifyStartLine() const;
virtual u32 getDrawModifyEndLine() const;
#else
virtual void getDrawModifyStartLine();
virtual void getDrawModifyEndLine();
#endif
virtual u32 getDrawCacheStartPos() const;
virtual void dirtyDrawCache();
virtual void dirtyCursorCache();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
protected:
const wchar_t* mpDrawString; // 0x50
ViewPort mSavedViewport; // 0x54
f32 mSavedProjection[7]; // 0x6C
nw4r::ut::Rect mProjectionRect; // 0x88
f32 mfVIWidth; // 0x98
bool mbAspect4x3; // 0x9C
bool mbDrawClipped; // 0x9D
s32 muLine; // 0xA0
f32 mfLineSpacing; // 0xA4
f32 mfCharacterSpacing; // 0xA8
f32 mfFontWidth; // 0xAC
f32 mfFontHeight; // 0xB0
f32 mfModifyStartY; // 0xB4
f32 mfMinScrollY; // 0xB8
u32 muDrawStartPos; // 0xBC
u32 muDrawEndPos; // 0xC0
u32 muDrawCacheStartPos; // 0xC4
bool mbSecretMode; // 0xC8
s32 muDrawModifyStartLine; // 0xCC
s32 muDrawModifyEndLine; // 0xD0
s32 muDrawModifyStartPos; // 0xD4
s32 muDrawModifyEndPos; // 0xD8
u32 muCachedStartPos; // 0xDC
u32 muCachedEndPos; // 0xE0
bool mbDrawCache; // 0xE4
f32 mfCachedCursorX; // 0xE8
f32 mfCachedCursorY; // 0xEC
f32 mfDrawScrollY; // 0xF0
s32 mnCachedCursorLine; // 0xF4
CursorPos mCachedCursor; // 0xF8
bool mbCursorCache; // 0x104
bool mbMaintainCursorCache; // 0x105
MEMAllocator* mpDrawAllocator;
u8 mDrawConfiguration[0x34];
f32 mfViewX;
f32 mfViewY;
f32 mfViewWidth;
f32 mfViewHeight;
f32 mfVIWidth;
bool mbAspect4x3;
bool mbDrawClipped;
u32 muLine;
f32 mfLineSpacing;
f32 mfCharacterSpacing;
f32 mfFontWidth;
f32 mfFontHeight;
f32 mfModifyStartY;
f32 mfMinScrollY;
u32 muDrawStartPos;
u32 muDrawEndPos;
u32 muDrawCacheStartPos;
#else
private:
u8 unk_0x50[0x78];
#endif
bool mbSecretMode; // 0xC8
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
u32 muDrawModifyStartLine;
u32 muDrawModifyEndLine;
u32 muDrawModifyStartPos;
u32 muDrawModifyEndPos;
u32 muCachedStartPos;
u32 muCachedEndPos;
bool mbDrawCache;
f32 mfCachedCursorX;
f32 mfCachedCursorY;
f32 mfDrawScrollY;
u32 muCachedCursorPosition;
CursorPos mCachedCursor;
bool mbCursorCache;
bool mbMaintainCursorCache;
#elif defined(MYTIINPUTFORM_IMPLEMENTATION)
protected:
u8 mDrawState[0x27];
f32 mfDrawScrollY;
u8 mDrawCacheState[0x14];
#else
u8 unk_0xCC[0x3C];
#endif
};
}
}

View File

@@ -39,6 +39,10 @@ namespace textinput {
f32 y; // 0x08
} Scroll;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
enum HVKCode { HVK_None = 0 };
#endif
class Base {
public :
virtual ~Base() {}
@@ -50,23 +54,25 @@ namespace textinput {
class CommandSender;
class CommandReceiver : public Base {
public:
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
CommandReceiver() { clearSender(); }
virtual ~CommandReceiver();
#endif
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
struct Scroll {
bool absY;
f32 x;
f32 y;
};
#endif
typedef enum INPUT_COMMAND {
IC_TRANSLATE_MODE = 6,
INPUT_COMMAND_0 = 0,
INPUT_COMMAND_37 = 37,
} INPUT_COMMAND;
typedef struct Scroll {
bool absY; // 0x00
f32 x; // 0x04
f32 y; // 0x08
} Scroll;
typedef struct ChangePredictMode {
u32 muLanguage; // 0x00
u8 mbPredictOn; // 0x04
} ChangePredictMode;
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
struct ChangePredictMode { u32 mode; bool enabled; };
#endif
virtual void clearSender();
virtual void onCommand(INPUT_COMMAND command, void* data);
virtual void addSender(CommandSender* cmdSend);
@@ -80,7 +86,13 @@ namespace textinput {
CommandSender() : mpCommandReceiver(NULL) {}
virtual void setCommandReceiver(CommandReceiver* cmdRecv);
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual void sendCommand(u32 command, void* data) {
if (mpCommandReceiver != NULL) mpCommandReceiver->onCommand(static_cast<CommandReceiver::INPUT_COMMAND>(command), data);
}
#else
virtual void sendCommand(u32, void*);
#endif
virtual void updateFromReceiver(u32, void*) {}
nw4r::ut::Link mLink; // 0x00

View File

@@ -10,7 +10,7 @@ namespace textinput {
namespace toolbar {
class Base {
public:
#ifdef TI_TOOLBAR_SAMPLE_CLASS
#if defined(TI_TOOLBAR_SAMPLE_CLASS) || defined(TIMANAGER_IMPLEMENTATION)
Base(Manager* manager) : mQwerty(true), meLanguage(USA), mpAllocator(NULL), mpManager(manager) {}
#endif
@@ -35,16 +35,20 @@ namespace textinput {
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
public:
#ifdef TI_TOOLBAR_SAMPLE_CLASS
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, arcName, observer), mpEventHandler(NULL),
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(resAccessor, layoutName, observer), mpEventHandler(NULL),
mbIsEnableQwertyChg(false) {}
#elif defined(TI_TOOLBAR_SAMPLE_CLASS)
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, "fs_VK_toolbar_a.brlyt", observer), mpEventHandler(NULL),
mbIsEnableQwertyChg(false) {}
#endif
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator) override;
virtual void draw() override;
virtual void init() override;
virtual void draw() override;
virtual void setQwerty(bool qwerty) override;
virtual void setLanguage(Language language) override;
@@ -117,12 +121,21 @@ namespace textinput {
KeyType meKeyType; // 0x30
};
#ifdef TI_TOOLBAR_SAMPLE_CLASS
#if defined(TI_TOOLBAR_SAMPLE_CLASS) || defined(TIMANAGER_IMPLEMENTATION)
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, const char* arcName, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, arcName, observer) {}
#ifdef TIMANAGER_IMPLEMENTATION
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, resAccessor, observer, layoutName) {}
#else
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, observer) {}
#endif
#ifdef TIMANAGER_IMPLEMENTATION
virtual ~Sample();
#else
virtual ~Sample() {}
#endif
};
#else
class Sample {};

View File

@@ -7,6 +7,9 @@
namespace textinput {
namespace util {
#ifdef TIINPUTFORM_IMPLEMENTATION
wchar_t HankakuToZenkaku(wchar_t ch);
#endif
wchar_t toWLower(wchar_t ch);
wchar_t toWUpper(wchar_t ch);
@@ -46,10 +49,11 @@ namespace textinput {
public:
Animation() : mfAnimationTime(0.0f), mbInAnimation(false), mbSE(false), mpAnimObserver(NULL) {}
virtual void startAnm(f32, f32, f32, AnimObserver*, void*); // 0x08
void startAnm(AnimObserver* observer, f32 start, f32 end, f32 frame, void* arg) {
startAnm(start, end, frame, observer, arg);
}
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual void startAnm(f32 start, f32 end, f32 duration, AnimObserver* observer, void* data);
#else
virtual void startAnm(AnimObserver*, f32, f32, f32, void*);
#endif // 0x08
virtual void calc(); // 0x0C
virtual f32 getValue(); // 0x10
virtual bool isActive(); // 0x14

View File

@@ -1,102 +1,14 @@
#ifndef TEXTINPUT_ZI_STRING_H
#define TEXTINPUT_ZI_STRING_H
#if defined(TIZISTRING_IMPLEMENTATION)
#include "tiString.h"
extern "C" {
#include <eztx.h>
}
#elif defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#include "tiString.h"
#include <eztx.h>
#endif
namespace textinput {
namespace tistring {
#if defined(TIZISTRING_IMPLEMENTATION)
class WithZi : public Decolated {
public:
enum PredictLanguage {
PL_0,
PL_1,
PL_2,
PL_3,
PL_4,
PL_5,
PL_6,
PL_7,
PL_8,
PL_9,
PL_10,
PL_11
};
enum LetterMode {
LM_0,
LM_1,
LM_2,
LM_3
};
static u16 ElementBuffer[0x100];
static u16 CandidatesBuffer[0x300];
static u16 CandidatedWord[0xa00];
static u16 LatestWord[0x40];
virtual ~WithZi();
virtual void create(MEMAllocator*);
virtual void pushBack(wchar_t);
virtual void popBack();
virtual void clear();
virtual void inputChar(wchar_t);
virtual void backSpace();
virtual void confirm(const wchar_t*);
virtual bool moveCursorRight();
virtual bool moveCursorLeft();
virtual bool canBackSpace();
virtual void EnableKSXFilter(bool);
virtual void init();
virtual void setInputting(wchar_t);
virtual u32 getCurrentNumPredicted();
virtual void getPredicted(int, wchar_t*);
virtual wchar_t* getCurrentSelected();
virtual u16 getInputStringLength();
virtual void setSelectedCandidate(s32);
virtual bool isFix();
virtual void setPredictLaunguage(PredictLanguage);
virtual void changeLetterMode(LetterMode);
virtual void ChangeDictionaryLanguage(u8);
virtual void setCellPhoneHoldingkey(void*);
virtual u32 setElementBuffer();
virtual u8 getPredictLanguage();
void openDictionary(void*, void*);
void clearCandidates();
void partialConfirmForKR();
void update();
u32 complementsCandidates_(s32);
void setCurrentWord(const wchar_t*);
u32 getCurrentInput(wchar_t*, u32);
wchar_t* getCurrentInput();
private:
EZTXGetParam mSearch;
u32 mSearchState;
u8 mbDictionaryOpen;
u8 mbContextChanged;
u32 mCurrentWordLength;
EZTXLanguageEntry* mpDictionaries;
void* mpDictionaryWork;
u16 mInputLength;
u32 mCandidateCount;
u32 mOemDictionaryId;
u8 mDictionaryLanguage;
s32 mSelectedCandidate;
PredictLanguage mPredictLanguage;
LetterMode mLetterMode;
void* mpHoldingKey;
u8 mbKoreanPartialConfirm;
};
#elif defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
class WithZi : public Decolated {
public:
enum PredictLanguage { PL_Default };

View File

@@ -163,28 +163,6 @@ namespace ipl {
unkVal1 = param_6;
}
#ifdef IPL_SD_CHANNEL_SELECT_CPP
T get() const {
f32 frame = mFrame;
f32 inverseDuration = 1.0f / mMaxFrame;
T result =
(mStart * (1.0f + (inverseDuration * (inverseDuration *
(inverseDuration * (frame * (2.0f * frame * frame)))) -
inverseDuration * (inverseDuration * (3.0f * frame * frame))))) -
(mEnd * (inverseDuration * (inverseDuration *
(inverseDuration * (frame * (2.0f * frame * frame)))) -
inverseDuration * (inverseDuration * (3.0f * frame * frame))));
f32 frameSquared = frame * frame;
f32 cubic = inverseDuration * (inverseDuration * (frame * frameSquared));
f32 tangent = unkVal0 * (frame + (cubic -
inverseDuration * (2.0f * frame * frame))) +
unkVal1 * (cubic - inverseDuration * frameSquared);
result.x += tangent;
result.y += tangent;
result.z += tangent;
return result;
}
#else
T get() const {
f32 var_f27 = mFrame;
f32 var_f28 = 1.0f / mMaxFrame;
@@ -217,7 +195,6 @@ namespace ipl {
r = r + temp_f3;
return r;*/
}
#endif
protected:
f32 unkVal0;

View File

@@ -134,15 +134,7 @@ namespace ipl {
VEC3& operator/=(f32 val) { return operator*=(1.f / val); }
VEC3 operator+(const VEC3& rhs) const { return VEC3(x + rhs.x, y + rhs.y, z + rhs.z); }
VEC3 operator+(f32 v) const { return VEC3(x + v, y + v, z + v); }
#ifdef IPL_SD_CHANNEL_SELECT_CPP
nw4r::math::VEC3 operator-(const VEC3& rhs) const {
nw4r::math::VEC3 difference;
nw4r::math::VEC3Sub(&difference, this, &rhs);
return difference;
}
#else
VEC3 operator-(const VEC3& rhs) const { return VEC3(x - rhs.x, y - rhs.y, z - rhs.z); }
#endif
VEC3 operator*(f32 val) const { return VEC3(x * val, y * val, z * val); }
VEC3 operator*(f64 val) const {
nw4r::math::VEC3 vecOut;

View File

@@ -86,7 +86,6 @@ namespace ipl {
const utility::BScroller& getBInst() { return mBScroller; }
#ifdef IPL_SDMEMORY_SCROLLER_BINST_RESET
void initScroll() { mScroller.init(); }
void resetBInst() { mBScroller.reset(); }
#endif

View File

@@ -312,33 +312,6 @@ namespace ipl {
void setLayoutFrame(int state);
BOOL tellStartingZoomAnm();
void initPageAnimations(const math::VEC3& position, int direction);
#ifdef IPL_SD_CHANNEL_SELECT_CPP
void removeNandTitleInfo(ESTitleId titleId) {
u32 titleCount = mNandTitleCount;
u32 index = 0;
for (; index < titleCount; ++index) {
if (mpNandTitleInfo[index].curTitleId == titleId) {
break;
}
}
if (index < mNandTitleCount) {
for (; index < mNandTitleCount - 1; ++index) {
NandSDWorker::TitleUsage& nextTitle = mpNandTitleInfo[index + 1];
NandSDWorker::TitleUsage& currentTitle = mpNandTitleInfo[index];
currentTitle.curTitleId = nextTitle.curTitleId;
currentTitle.size = nextTitle.size;
currentTitle.inode = nextTitle.inode;
}
--mNandTitleCount;
}
}
nw4r::math::VEC3 getPageTransitionPosition(int index) const {
nw4r::math::VEC3 position(0.0f, 0.0f, 0.0f);
nw4r::lyt::Pane* pane = getCenterChannelPane(index);
PSMTXMultVec(pane->GetGlobalMtx(), position, position);
return position;
}
#endif
static BOOL isChannelReady(const SDChannelObj* channel);
nw4r::ut::List mChannelObjects;
nand::LayoutFile* mpLayoutFile;

View File

@@ -29,9 +29,6 @@ namespace ipl {
class Setting;
class APScanThread;
#ifdef IPL_SETTING_IMPLEMENTATION
class APEvent;
#else
class APEvent : public ::gui::EventHandler {
public:
APEvent(Setting* setting) : ::gui::EventHandler(), mpSetting(setting) {}
@@ -41,17 +38,16 @@ namespace ipl {
private:
Setting* mpSetting;
};
#endif
struct SettingAnimation {
u8 unknown[0x14];
int state;
};
struct SettingAPScanList {
u8 unknown[0x14];
union {
struct {
u16 count;
u8 entries[0x7fe];
};
u8 recordBuffer[0x800];
};
u16 count;
u8 entries[0x7fe];
union {
WDBssDesc_* currentDescriptor;
u16* currentDescriptorWords;
@@ -90,7 +86,7 @@ namespace ipl {
void initHTMLText();
void initMessage();
void initKeyboard(const char* text);
bool checkInputString(const wchar_t* text) NO_INLINE;
bool checkInputString(const wchar_t* text);
int checkIPString(const wchar_t* text);
void setDefaultBackString();
void calcKeyboard();
@@ -162,6 +158,7 @@ namespace ipl {
virtual void destroy();
virtual void prepare();
virtual void create();
virtual void calc();
virtual void draw();
virtual FaderSceneCommand calcFadein();
virtual FaderSceneCommand calcNormal();
@@ -211,8 +208,8 @@ namespace ipl {
layout::Object* mpChangeLayout;
layout::Object* mpMainLayout;
layout::Object* mpWaitLayout;
utility::FrameController* mpFirstAnimation;
utility::FrameController* mpSecondAnimation;
SettingAnimation* mpFirstAnimation;
SettingAnimation* mpSecondAnimation;
APEvent* mpEventHandler;
gui::PaneManager* mpPaneManager;
void* mpUSBAPThread;
@@ -265,17 +262,6 @@ 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

@@ -20,10 +20,6 @@ namespace ipl {
return mState == STATE_WAIT_CHILD;
}
#ifdef IPL_MEMORYCARD_BASE_IMPLEMENTATION
int getMemoryCardTransitionState() const { return mState; }
#endif
private:
enum {
// Base

View File

@@ -16,7 +16,7 @@ namespace ipl {
virtual void onSE(textinput::sound::SE seId);
virtual void onOK();
virtual void onCancel();
virtual void setManager(Manager* manager);
virtual void setManager(Manager* manager) { mpKeyboardMgr = manager; }
private:
Manager* mpKeyboardMgr; // 0x04
@@ -37,41 +37,23 @@ namespace ipl {
LETTER,
PHOTO_LETTER,
NUMERIC,
#ifdef IPL_SETTING_IMPLEMENTATION
NORMAL_WITHOUT_LINEFEED = 2,
NORMAL_WITHOUT_LINEFEED_WITH_SIGN = 4,
NORMAL_BIGTEXT_WITHOUT_LINEFEED = 6,
#else
NORMAL_WITHOUT_LINEFEED,
NORMAL_WITHOUT_LINEFEED_WITH_SIGN,
NORMAL_BIGTEXT_WITHOUT_LINEFEED,
#endif
ONLY_QWERTY_WITHOUT_LINEFEED_AND_SIGN,
ONLY_QWERTY_BIGTEXT_WITHOUT_LINEFEED_AND_SIGN,
#ifdef IPL_SETTING_IMPLEMENTATION
NUMERIC_WITH_DOT = 16,
NUMERIC_BIGTEXT_WITH_DOT = 10,
#else
NUMERIC_WITH_DOT,
NUMERIC_BIGTEXT_WITH_DOT,
#endif
NORMAL_BIGTEXT_WITHOUT_LINEFEED_WITH_SIGN,
NUMERIC_WITH_SEPERATOR,
PREDICT_WITHOUT_LINEFEED,
} KeyboardType;
typedef struct KeyboardSetting {
#ifdef IPL_SETTING_IMPLEMENTATION
u32 rowLimit;
const wchar_t* wcString;
u32 stringLimit;
KeyboardType type;
#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

@@ -6,9 +6,6 @@
#include "system/iplMessage.h"
namespace ipl {
#ifdef IPL_SETTING_IMPLEMENTATION
namespace scene { class Setting; }
#endif
namespace message {
class Manager {
public:
@@ -19,9 +16,6 @@ namespace ipl {
void setResource(u8* msgData) const { mpMessage->setResource(msgData); }
private:
#ifdef IPL_SETTING_IMPLEMENTATION
friend class scene::Setting;
#endif
void initMessage();
Message* mpMessage; // 0x00

View File

@@ -65,19 +65,6 @@ namespace ipl {
void setDidntGotoSDMenu(BOOL value) { mData.didntGotoSDMenu = value; }
#endif
#ifdef IPL_SDMEMORY_TITLE_CACHE_ACCESS
const ESTitleId* getTitleCache() const { return &mData.titleCache[0][0]; }
ESTitleId getTitleCacheEntry(int index) const { return (&mData.titleCache[0][0])[index]; }
#endif
#ifdef IPL_SD_CHANNEL_SELECT_CPP
ESTitleId getCachedTitle(int index) const {
if (index < 0 || index >= MAX_CHANNEL_TOTAL) {
return 0;
}
return (&mData.titleCache[0][0])[index];
}
#endif
bool hasPhotoMP3Dummy() { return mbPhotoMP3; }
bool hasPhoto2Title() { return mbPhoto2; }
bool hasPhoto2DummyCheck() { return mbPhoto2Check; }

View File

@@ -1,41 +0,0 @@
#ifndef MSL_FORMAT_RUNTIME_H
#define MSL_FORMAT_RUNTIME_H
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <errno.h>
#include <internal/locale.h>
#define SIGDIGLEN 36
#define LDBL_MANT_DIG 53
#define LDBL_MAX_EXP 1024
#define LDBL_MIN_EXP (-1021)
#define DBL_MAX 1.7976931348623157e308
#define DBL_MIN 2.2250738585072014e-308
#define DBL_EPSILON 2.2204460492503131e-16
#define EOF (-1)
typedef long ptrdiff_t;
typedef long long intmax_t;
typedef unsigned long long uintmax_t;
typedef struct {
char sign;
short exp;
struct { unsigned char length; unsigned char text[SIGDIGLEN]; } sig;
} decimal;
typedef struct { char style; short digits; } decform;
enum __ReadProcActions { __GetAChar, __UngetAChar, __TestForError };
typedef struct { char* CharStr; size_t MaxCharCount; size_t CharsWritten; } __OutStrCtrl;
typedef struct { char* NextChar; int NullCharDetected; } __InStrCtrl;
void __num2dec(const decform*, double, decimal*);
double __dec2num(const decimal*);
size_t __fwrite(const void*, size_t, size_t, FILE*);
int __StringRead(void*, int, int);
unsigned long __strtoul(int, int, int (*)(void*, int, int), void*, int*, int*, int*);
unsigned long long __strtoull(int, int, int (*)(void*, int, int), void*, int*, int*, int*);
long double __strtold(int, int (*)(void*, int, int), void*, int*, int*);
int wctomb(char*, wchar_t);
double nan(const char*);
#define signbit(x) __signbitd(x)
#endif

View File

@@ -1,88 +0,0 @@
MSL restoration, 43U, baseline 0 exact functions and 0 matched code/data in all six units.
Sources: zeldaret/tp MSL printf/wprintf; public Mario Strikers Charged MSL decimal/scanning/strtold references in /tmp/mscharged-new; time reference experiments in /tmp. All measurements were rebuilt locally.
printf long2str: corrected 32-bit minimum constant; 138/138 instructions, zero differences.
printf float2str: removed unnecessary short narrowing from exponent update; 500/500 instructions, zero differences.
printf double2hex:
1. Deferred output pointer initialization until after width validation: 242/242, 97 differences.
2. Moved output pointer declaration after decimal: 242/242, same 97 differences.
3. Copied incoming format into a local format: 244/242 and larger frame; rejected.
4. Reconstructed the actual zero-value path and ordinary literal 0x0p0 from target assembly.
5. Corrected unconditional exponent subtraction and explicit byte narrowing based on target assembly. Remaining struct argument copies use floating loads/stores instead of integer loads/stores; conversion-loop scheduling differs.
printf __pformatter:
1. Moved format declaration after buffers: 535/535, same 321 differences.
2. Initialized format to zero: 540/535, additional stores; rejected.
3. Copied parsed format before dispatch, with both locals declared at function entry: 515/535 after target semantic fixes, larger frame; rejected.
4. Removed hex-prefix zero-fill handling absent from this binary. Remaining mismatch is by-value struct copy code generation; target has 535 instructions, source 511.
wprintf double2hex:
1. Used the Charged reference implementation: 246/242, different frame/scheduling; rejected.
2. Deferred output pointer initialization: 243/242, register and copy differences remained.
3. Moved output pointer declaration after decimal: 243/242, unchanged differences.
4. Reconstructed zero-value output and unconditional exponent subtraction from target assembly. Explicit byte narrowing improved conversion instructions; struct-copy and loop scheduling remain open.
wprintf __wpformatter:
1. Initialized local format: 596/593, additional stores; rejected.
2. Moved format declaration after buffers: 591/593, changed scheduling; rejected.
3. Copied parsed format before dispatch: 595/593, larger frame; rejected.
4. Corrected the imported narrow Pascal-string branch to read and advance its actual input pointer, eliminating an uninitialized output-pointer read.
5. Removed hex-prefix zero-fill handling absent from the target. Remaining struct-copy code generation and register scheduling differ.
wprintf __wStringWrite: used the real callback result from wmemcpy; 27/27 instructions, zero differences.
ansi_fp: all ten functions have zero ctxdiff differences. Exception metadata enabled for this unit, using the same setting as matching MSL siblings. Code 6512/6512 and data 780/780.
time strftime:
1. Assigned default calendar fields individually: 906/913, scheduling differences; rejected.
2. Initialized the default calendar at declaration: 913/913, 34 remaining string-offset differences; retained.
3. Moved format-pointer declaration before locale: 913/913, 76 differences; rejected.
4. Replaced imported pooled-string address arithmetic with ordinary literals. Reconstructed real asctime/ctime formatting to account for the original literals, rather than retaining fake calls with missing format arguments.
5. With ordinary source-token order restored, strftime has 913/913 instructions and zero ctxdiff differences. Keeping the shared asctime result local to asctime restored the target BSS symbols; exception records for the additional real library functions still differ at unit level. No padding or forced placement was added.
scanf: all four functions have zero ctxdiff differences, code 5484/5484 and data 388/388. The formatter retains its actual secure-mode parameter.
strtold: __strtold has 1277/1277 instructions and strtod 44/44, both zero differences. Removed the imported inline qualifier from the public strtod wrapper so the real target symbol is emitted. Code 5284/5284 and data 112/112.
Exception metadata settings change only owned NonMatching units; configure.py status flags remain NonMatching. Clean gates require the original DOL SHA1 and zero baseline regressions. Raw instruction-exact counts can be lower than objdiff exact counts because the varargs conditional branch to an external register-save helper is compared without relocation normalization by gate.py. These counts are reported separately; they were not patched or hidden.
printf::double2hex: aggregate exponent format initialized at declaration: 238/242 instructions, 227 positional diffs; restored.
printf::double2hex: initialize exponent integer fields before byte flags: 241/242 instructions, 127 positional diffs; restored.
printf::double2hex: use integer nibble temporary with explicit final narrowing: 239/242 instructions, 123 positional diffs; restored.
printf::__pformatter: move parsed format declaration after output buffer: 511/535 instructions, 367 positional diffs; restored.
printf::__pformatter: initialize parsed format before first parse: 516/535 instructions, 505 positional diffs; restored.
printf::__pformatter: separate next-format pointer from parsed cursor: 511/535 instructions, 367 positional diffs; restored.
wprintf::double2hex: aggregate exponent format initialized at declaration: 238/242 instructions, 227 positional diffs; restored.
wprintf::double2hex: initialize exponent integer fields before byte flags: 241/242 instructions, 127 positional diffs; restored.
wprintf::double2hex: use integer nibble temporary with explicit final narrowing: 239/242 instructions, 123 positional diffs; restored.
wprintf::__wpformatter: move parsed format declaration after output buffer: 567/593 instructions, 519 positional diffs; restored.
wprintf::__wpformatter: initialize parsed format before first parse: 572/593 instructions, 562 positional diffs; restored.
wprintf::__wpformatter: separate next-format pointer from parsed cursor: 567/593 instructions, 519 positional diffs; restored.
printf::printf: finish varargs lifetime with va_end: compile rejected: ninja: build stopped: subcommand failed.; restored.
printf::printf: return through named result temporary: compile rejected: ninja: build stopped: subcommand failed.; restored.
printf::printf: move va_start to first actual formatting use: 50/50 instructions, 1 positional diffs; restored.
printf::fprintf: finish varargs lifetime with va_end: compile rejected: ninja: build stopped: subcommand failed.; restored.
printf::fprintf: return through named result temporary: compile rejected: ninja: build stopped: subcommand failed.; restored.
printf::fprintf: move va_start to first actual formatting use: 49/49 instructions, 1 positional diffs; restored.
printf::printf: finish varargs lifetime / initialize controller first: 50/50 instructions, 1 positional diffs; restored.
printf::printf: hoist argument list / named result: 50/50 instructions, 1 positional diffs; restored.
printf::printf: argument-list pointer / delay va_start: 50/50 instructions, 1 positional diffs; restored.
printf::fprintf: finish varargs lifetime / initialize controller first: 49/49 instructions, 1 positional diffs; restored.
printf::fprintf: hoist argument list / named result: 49/49 instructions, 1 positional diffs; restored.
printf::fprintf: argument-list pointer / delay va_start: 49/49 instructions, 1 positional diffs; restored.
printf::snprintf: finish varargs lifetime / initialize controller first: 54/54 instructions, 1 positional diffs; restored.
printf::snprintf: hoist argument list / named result: 54/54 instructions, 1 positional diffs; restored.
printf::snprintf: argument-list pointer / delay va_start: 54/54 instructions, 1 positional diffs; restored.
printf::sprintf: finish varargs lifetime / initialize controller first: 52/52 instructions, 1 positional diffs; restored.
printf::sprintf: hoist argument list / named result: 52/52 instructions, 1 positional diffs; restored.
printf::sprintf: argument-list pointer / delay va_start: 52/52 instructions, 1 positional diffs; restored.
wprintf::swprintf: finish varargs lifetime / initialize controller first: 55/55 instructions, 1 positional diffs; restored.
wprintf::swprintf: hoist argument list / named result: 55/55 instructions, 1 positional diffs; restored.
wprintf::swprintf: argument-list pointer / delay va_start: 55/55 instructions, 11 positional diffs; restored.
time::emit: finish varargs lifetime / initialize controller first: 43/43 instructions, 1 positional diffs; restored.
time::emit: hoist argument list / named result: 43/43 instructions, 1 positional diffs; restored.
time::emit: argument-list pointer / delay va_start: 42/43 instructions, 34 positional diffs; restored.
printf data: 139/148 relocation entries agree by target function and addend; dispatch-table entries in the unmatched formatter still differ. Generated jump-table data is retained, without manual entries or symbol mappings.
wprintf data: 139/148 relocation entries agree by target function and addend; dispatch-table entries in the unmatched formatter still differ. Generated jump-table data is retained, without manual entries or symbol mappings.
printf double2hex: moved exponent-format initialization after exponent extraction: 241/242 instructions; FP aggregate copies remained; restored.
wprintf double2hex: moved exponent-format initialization after exponent extraction: 241/242 instructions; FP aggregate copies remained; restored.
printf data: changed zero comparison literal to long double, matching the argument type and sharing its zero constant with float2str. .sdata2 now 8 bytes, 100%, versus 16 emitted bytes previously. Instruction scores unchanged.
time data: literal pool, calendar tables and BSS already agree. Target has nine exception-index records; source includes exception records for real public asctime/ctime functions absent in the extracted target. Retained the functions rather than suppressing output.
locale: restored the C locale components, collation table and ordinary literals in source order; all 792 data bytes exact. No target code functions exist.
file_io: implemented fclose, fflush, __msl_strnicmp and __msl_itoa in object order using FILE fields and named arithmetic temporaries; all four have zero ctxdiff differences, 928 code bytes and 60 metadata bytes exact.

View File

@@ -1,160 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
enum file_kinds { file_closed, file_disk, file_console, file_unavailable };
enum io_states { neutral, writing, reading, rereading };
enum io_modes { io_read = 1, io_write = 2, io_append = 4 };
extern int __flush_all(void);
extern int __flush_buffer(FILE*, size_t*);
#pragma exceptions on
int fclose(FILE* file)
{
int flush_result, close_result;
if (file == NULL)
return -1;
if (file->mode.file_kind == file_closed)
return 0;
flush_result = fflush(file);
close_result = (*file->close_proc)(file->handle);
file->mode.file_kind = file_closed;
file->handle = 0;
if (file->state.free_buffer)
free((FILE*)file->buffer);
return (flush_result || close_result) ? -1 : 0;
}
int fflush(FILE* file)
{
int pos;
if (file == NULL)
{
return __flush_all();
}
if (file->state.error != 0 || file->mode.file_kind == file_closed)
{
return -1;
}
if (file->mode.io_mode == io_read)
{
return 0;
}
if (file->state.io_state >= rereading)
{
file->state.io_state = reading;
}
if (file->state.io_state == reading)
{
file->buffer_len = 0;
}
if (file->state.io_state != writing)
{
file->state.io_state = neutral;
return 0;
}
if (file->mode.file_kind != file_disk)
{
pos = 0;
}
else
{
pos = ftell(file);
}
if (__flush_buffer(file, NULL) != 0)
{
file->state.error = 1;
file->buffer_len = 0;
return -1;
}
file->state.io_state = neutral;
file->pos = pos;
file->buffer_len = 0;
return 0;
}
int __msl_strnicmp(const char* str1, const char* str2, int n)
{
int i;
char c1, c2;
for (i = 0; i < n; i++)
{
c1 = tolower(*str1++);
c2 = tolower(*str2++);
if (c1 < c2)
return -1;
if (c1 > c2)
return 1;
if (c1 == '\0')
return 0;
}
return 0;
}
char* __msl_itoa(int value, char* str, unsigned int base)
{
int negative;
int length;
char c;
int start;
int end;
negative = 0;
length = 0;
if (value < 0)
{
value = -value;
negative = 1;
}
do
{
int digit = value % base;
if (digit > 9)
str[length++] = digit + 0x37;
else
str[length++] = digit + 0x30;
value /= base;
} while (value != 0);
if (negative != 0)
str[length++] = '-';
str[length++] = '\0';
start = 0;
end = strlen(str) - 1;
while (start < end)
{
c = str[start];
str[start++] = str[end];
str[end--] = c;
}
return str;
}

View File

@@ -1,123 +0,0 @@
#include <internal/locale.h>
#include <limits.h>
#include <stddef.h>
extern int __mbtowc_noconv(wchar_t*, const char*, size_t);
extern int __wctomb_noconv(char*, wchar_t);
struct lconv __lconv = {
".",
"",
"",
"",
"",
"",
"",
"",
"",
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
"",
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
};
extern const unsigned short __ctype_mapC[256];
extern const unsigned char __upper_mapC[256];
extern const unsigned char __lower_mapC[256];
extern const unsigned short __wctype_mapC[256];
extern const wchar_t __wupper_mapC[256];
extern const wchar_t __wlower_mapC[256];
struct _loc_ctype_cmpt _loc_ctyp_C = {
"C",
__ctype_mapC,
__upper_mapC,
__lower_mapC,
__wctype_mapC,
__wupper_mapC,
__wlower_mapC,
__mbtowc_noconv,
__wctomb_noconv
};
unsigned short char_coll_tableC[96] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 17, 18, 19, 20, 21, 22, 23, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71,
73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 24, 25, 26, 27, 28, 0, 44, 46, 48, 50, 52, 54, 56,
58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 29, 30, 31, 32, 0,
};
struct _loc_coll_cmpt _loc_coll_C = {
"C",
' ',
110,
0,
char_coll_tableC,
NULL
};
struct _loc_mon_cmpt _loc_mon_C = {
"C",
"",
"",
"",
"",
"",
"",
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
"",
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX
};
struct _loc_num_cmpt _loc_num_C = {
"C",
".",
"",
""
};
struct _loc_time_cmpt _loc_tim_C = {
"C",
"AM|PM",
"%a %b %e %T %Y",
"%I:%M:%S %p",
"%m/%d/%y",
"%T",
"Sun|Sunday|Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thu|Thursday|Fri|Friday|Sat|Saturday",
"Jan|January|Feb|February|Mar|March|Apr|April|May|May|Jun|June|Jul|July|Aug|August|Sep|September|Oct|October|Nov|"
"November|Dec|December",
""
};
struct __locale _current_locale = {
NULL,
"C",
&_loc_coll_C,
&_loc_ctyp_C,
&_loc_mon_C,
&_loc_num_C,
&_loc_tim_C
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,817 +0,0 @@
#include <internal/format_runtime.h>
typedef long long intmax_t;
enum argument_options {
normal_argument,
char_argument,
short_argument,
long_argument,
intmax_argument,
size_t_argument,
ptrdiff_argument,
long_long_argument,
double_argument,
long_double_argument,
wchar_argument
};
typedef unsigned char char_map[32];
typedef struct {
unsigned char suppress_assignment;
unsigned char field_width_specified;
unsigned char argument_options;
unsigned char conversion_char;
int field_width;
char_map char_set;
} scan_format;
#define set_char_map(map, ch) map[(unsigned char)ch >> 3] |= (1 << (ch & 7))
#define tst_char_map(map, ch) (map[(unsigned char)ch >> 3] & (1 << (ch & 7)))
static const char* parse_format(const char* format_string, scan_format* format) {
const char* s = format_string;
int c;
int flag_found, invert;
scan_format f = {0, 0, normal_argument, 0, 2147483647, {0}};
if (((c = *++s) == '%')) {
f.conversion_char = c;
*format = f;
return s + 1;
}
if (c == '*') {
f.suppress_assignment = 1;
c = *++s;
}
if (isdigit(c)) {
f.field_width = 0;
do {
f.field_width = (f.field_width * 10) + (c - '0');
c = *++s;
} while (isdigit(c));
if (f.field_width == 0) {
f.conversion_char = 0xFF;
*format = f;
return s + 1;
}
f.field_width_specified = 1;
}
flag_found = 1;
switch (c) {
case 'h':
f.argument_options = short_argument;
if (s[1] == 'h') {
f.argument_options = char_argument;
c = *++s;
}
break;
case 'l':
f.argument_options = long_argument;
if (s[1] == 'l') {
f.argument_options = long_long_argument;
c = *++s;
}
break;
case 'L':
f.argument_options = long_double_argument;
break;
case 'j':
f.argument_options = intmax_argument;
break;
case 'z':
f.argument_options = size_t_argument;
break;
case 't':
f.argument_options = ptrdiff_argument;
break;
default:
flag_found = 0;
}
if (flag_found) {
c = *++s;
}
f.conversion_char = c;
switch (c) {
case 'd':
case 'i':
case 'u':
case 'o':
case 'x':
case 'X':
if (f.argument_options == long_double_argument) {
f.conversion_char = 0xFF;
break;
}
break;
case 'a':
case 'A':
case 'f':
case 'F':
case 'e':
case 'E':
case 'g':
case 'G':
if (f.argument_options == char_argument || f.argument_options == short_argument ||
f.argument_options == intmax_argument || f.argument_options == size_t_argument ||
f.argument_options == ptrdiff_argument || f.argument_options == long_long_argument) {
f.conversion_char = 0xFF;
break;
}
if (f.argument_options == long_argument) {
f.argument_options = double_argument;
}
break;
case 'p':
f.argument_options = long_argument;
f.conversion_char = 'x';
break;
case 'c':
if (f.argument_options == long_argument) {
f.argument_options = wchar_argument;
} else {
if (f.argument_options != normal_argument) {
f.conversion_char = 0xFF;
}
}
break;
case 's':
if (f.argument_options == long_argument) {
f.argument_options = wchar_argument;
} else {
if (f.argument_options != normal_argument) {
f.conversion_char = 0xFF;
}
}
{
int i;
unsigned char* p;
for (i = sizeof(f.char_set), p = f.char_set; i; --i) {
*p++ = 0xFF;
}
f.char_set[1] = 0xC1;
f.char_set[4] = 0xFE;
}
break;
case 'n':
break;
case '[':
if (f.argument_options == long_argument) {
f.argument_options = wchar_argument;
} else {
if (f.argument_options != normal_argument) {
f.conversion_char = 0xFF;
}
}
c = *++s;
invert = 0;
if (c == '^') {
invert = 1;
c = *++s;
}
if (c == ']') {
set_char_map(f.char_set, ']');
c = *++s;
}
while (c && c != ']') {
int d;
set_char_map(f.char_set, c);
if (*(s + 1) == '-' && (d = *(s + 2)) != 0 && d != ']') {
while (++c <= d) {
set_char_map(f.char_set, c);
}
c = *(s += 3);
} else {
c = *++s;
}
}
if (!c) {
f.conversion_char = 0xFF;
break;
}
if (invert) {
int i;
unsigned char* p;
for (i = sizeof(f.char_set), p = f.char_set; i; --i, ++p) {
*p = ~*p;
}
break;
}
break;
default:
f.conversion_char = 0xFF;
break;
}
*format = f;
return s + 1;
}
int __sformatter(int (*ReadProc)(void*, int, int), void* ReadProcArg, const char* format_str, va_list arg,
int is_secure) {
int num_chars, chars_read, items_assigned, conversions;
int base, negative, overflow;
int rval;
const char* format_ptr;
char format_char;
char c;
scan_format format;
long long_num;
unsigned long u_long_num;
long long long_long_num = 0;
unsigned long long u_long_long_num;
long double long_double_num;
char* arg_ptr;
int elem_valid;
size_t elem_maxsize;
int match_failure = 0;
int terminate = 0;
format_ptr = format_str;
chars_read = 0;
items_assigned = 0;
conversions = 0;
while (!terminate && (format_char = *format_ptr) != 0) {
if (isspace(format_char)) {
do {
format_char = *++format_ptr;
} while (isspace(format_char));
if (!match_failure) {
while (isspace(c = (*ReadProc)(ReadProcArg, 0, __GetAChar))) {
++chars_read;
}
(*ReadProc)(ReadProcArg, c, __UngetAChar);
}
continue;
}
if ((format_char != '%') && (!match_failure)) {
if ((c = (*ReadProc)(ReadProcArg, 0, __GetAChar)) != (unsigned char)format_char) {
(*ReadProc)(ReadProcArg, c, __UngetAChar);
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
++format_ptr;
continue;
}
}
chars_read++;
format_ptr++;
continue;
}
format_ptr = parse_format(format_ptr, &format);
if (!format.suppress_assignment && format.conversion_char != '%') {
arg_ptr = va_arg(arg, char*);
} else {
arg_ptr = 0;
}
if ((format.conversion_char != 'n') && (!match_failure) && (*ReadProc)(ReadProcArg, 0, __TestForError)) {
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
}
}
switch (format.conversion_char) {
case 'd':
base = 10;
goto signed_int;
case 'i':
base = 0;
signed_int:
if (match_failure) {
long_num = 0;
long_long_num = 0;
} else {
if ((format.argument_options == long_long_argument) ||
(format.argument_options == intmax_argument)) {
u_long_long_num = __strtoull(base, format.field_width, ReadProc, ReadProcArg, &num_chars,
&negative, &overflow);
} else {
u_long_num = __strtoul(base, format.field_width, ReadProc, ReadProcArg, &num_chars, &negative,
&overflow);
}
if (!num_chars) {
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
long_num = 0;
long_long_num = 0;
goto signed_int_assign;
}
}
chars_read += num_chars;
if ((format.argument_options == long_long_argument) ||
(format.argument_options == intmax_argument)) {
long_long_num = (negative ? -u_long_long_num : u_long_long_num);
} else {
long_num = (negative ? -u_long_num : u_long_num);
}
}
signed_int_assign:
if (arg_ptr) {
switch (format.argument_options) {
case normal_argument:
*(int*)arg_ptr = long_num;
break;
case char_argument:
*(signed char*)arg_ptr = long_num;
break;
case short_argument:
*(short*)arg_ptr = long_num;
break;
case long_argument:
*(long*)arg_ptr = long_num;
break;
case intmax_argument:
*(intmax_t*)arg_ptr = long_long_num;
break;
case size_t_argument:
*(size_t*)arg_ptr = long_num;
break;
case ptrdiff_argument:
*(ptrdiff_t*)arg_ptr = long_num;
break;
case long_long_argument:
*(long long*)arg_ptr = long_long_num;
break;
}
if (!match_failure) {
items_assigned++;
}
}
conversions++;
break;
case 'o':
base = 8;
goto unsigned_int;
case 'u':
base = 10;
goto unsigned_int;
case 'x':
case 'X':
base = 16;
unsigned_int:
if (match_failure) {
u_long_num = 0;
u_long_long_num = 0;
} else {
if ((format.argument_options == long_long_argument) ||
(format.argument_options == intmax_argument)) {
u_long_long_num = __strtoull(base, format.field_width, ReadProc, ReadProcArg, &num_chars,
&negative, &overflow);
} else {
u_long_num = __strtoul(base, format.field_width, ReadProc, ReadProcArg, &num_chars, &negative,
&overflow);
}
if (!num_chars) {
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
u_long_num = 0;
u_long_long_num = 0;
goto unsigned_int_assign;
}
}
chars_read += num_chars;
if (negative) {
if (format.argument_options == long_long_argument) {
u_long_long_num = -u_long_long_num;
} else {
u_long_num = -u_long_num;
}
}
}
unsigned_int_assign:
if (arg_ptr) {
switch (format.argument_options) {
case normal_argument:
*(unsigned int*)arg_ptr = u_long_num;
break;
case char_argument:
*(unsigned char*)arg_ptr = u_long_num;
break;
case short_argument:
*(unsigned short*)arg_ptr = u_long_num;
break;
case long_argument:
*(unsigned long*)arg_ptr = u_long_num;
break;
case intmax_argument:
*(intmax_t*)arg_ptr = u_long_long_num;
break;
case size_t_argument:
*(size_t*)arg_ptr = u_long_num;
break;
case ptrdiff_argument:
*(ptrdiff_t*)arg_ptr = u_long_num;
break;
case long_long_argument:
*(unsigned long long*)arg_ptr = u_long_long_num;
break;
}
if (!match_failure) {
items_assigned++;
}
}
conversions++;
break;
case 'a':
case 'A':
case 'f':
case 'F':
case 'e':
case 'E':
case 'g':
case 'G':
flt:
if (match_failure) {
long_double_num = NAN;
} else {
long_double_num = __strtold(format.field_width, ReadProc, ReadProcArg, &num_chars, &overflow);
if (!num_chars) {
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
long_double_num = NAN;
goto assign_float;
}
}
chars_read += num_chars;
}
assign_float:
if (arg_ptr) {
switch (format.argument_options) {
case normal_argument:
*(float*)arg_ptr = long_double_num;
break;
case double_argument:
*(double*)arg_ptr = long_double_num;
break;
case long_double_argument:
*(long double*)arg_ptr = long_double_num;
break;
}
if (!match_failure) {
items_assigned++;
}
}
conversions++;
break;
case 'c':
if (!format.field_width_specified) {
format.field_width = 1;
}
if (arg_ptr) {
if (is_secure) {
elem_valid = 1;
elem_maxsize = va_arg(arg, size_t);
}
num_chars = 0;
if (match_failure) {
if (elem_maxsize > 0) {
*arg_ptr = 0;
}
continue;
} else {
char* arg_start = arg_ptr;
while (format.field_width-- &&
(!is_secure || ((elem_valid = (elem_maxsize > num_chars)) != 0)) &&
((rval = ((*ReadProc)(ReadProcArg, 0, __GetAChar))) != -1)) {
c = rval;
if (format.argument_options == wchar_argument) {
mbtowc(((wchar_t*)arg_ptr), (char*)(&c), 1);
arg_ptr += sizeof(char);
} else {
*arg_ptr++ = c;
}
num_chars++;
}
c = rval;
if (!num_chars || (is_secure && !elem_valid)) {
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
if (elem_maxsize > 0) {
*arg_start = 0;
}
continue;
}
}
chars_read += num_chars;
items_assigned++;
}
} else {
num_chars = 0;
while (format.field_width-- && ((rval = ((*ReadProc)(ReadProcArg, 0, __GetAChar))) != -1)) {
c = rval;
num_chars++;
}
c = rval;
if (!num_chars) {
goto exit;
}
}
conversions++;
break;
case '%':
if (match_failure) {
continue;
} else {
while (isspace(c = (*ReadProc)(ReadProcArg, 0, __GetAChar))) {
chars_read++;
}
if (c != '%') {
(*ReadProc)(ReadProcArg, c, __UngetAChar);
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
continue;
}
}
chars_read++;
}
break;
case 's':
if (!match_failure) {
c = (*ReadProc)(ReadProcArg, 0, __GetAChar);
while (isspace(c)) {
chars_read++;
c = (*ReadProc)(ReadProcArg, 0, __GetAChar);
}
(*ReadProc)(ReadProcArg, c, __UngetAChar);
}
case '[':
if (arg_ptr) {
if (is_secure) {
elem_valid = 1;
elem_maxsize = va_arg(arg, size_t) - 1;
}
num_chars = 0;
if (match_failure) {
if (elem_maxsize > 0) {
*arg_ptr = 0;
}
continue;
} else {
char* arg_start = arg_ptr;
while (format.field_width-- &&
(!is_secure || ((elem_valid = (elem_maxsize >= num_chars)) != 0)) &&
((rval = ((*ReadProc)(ReadProcArg, 0, __GetAChar))) != -1)) {
c = rval;
if (!tst_char_map(format.char_set, c)) {
break;
}
if (format.argument_options == wchar_argument) {
mbtowc(((wchar_t*)arg_ptr), (char*)&c, 1);
arg_ptr = (char*)((wchar_t*)arg_ptr + 1);
} else {
*arg_ptr++ = c;
}
num_chars++;
}
c = rval;
if (!num_chars || (is_secure && !elem_valid)) {
(*ReadProc)(ReadProcArg, c, __UngetAChar);
if (!is_secure) {
goto exit;
} else {
match_failure = 1;
if (elem_maxsize > 0) {
*arg_start = 0;
}
continue;
}
}
chars_read += num_chars;
if (format.argument_options == wchar_argument) {
*(wchar_t*)arg_ptr = L'\0';
} else {
*arg_ptr = 0;
}
items_assigned++;
}
} else {
num_chars = 0;
while (format.field_width-- && ((rval = ((*ReadProc)(ReadProcArg, 0, __GetAChar))) != -1)) {
c = rval;
if (!tst_char_map(format.char_set, c)) {
break;
}
num_chars++;
}
c = rval;
if (!num_chars) {
(*ReadProc)(ReadProcArg, c, __UngetAChar);
break;
}
chars_read += num_chars;
}
if (format.field_width >= 0) {
(*ReadProc)(ReadProcArg, c, __UngetAChar);
}
conversions++;
break;
case 'n':
if (arg_ptr) {
switch (format.argument_options) {
case normal_argument:
*(int*)arg_ptr = chars_read;
break;
case short_argument:
*(short*)arg_ptr = chars_read;
break;
case long_argument:
*(long*)arg_ptr = chars_read;
break;
case char_argument:
*(char*)arg_ptr = chars_read;
break;
case long_long_argument:
*(long long*)arg_ptr = chars_read;
break;
}
}
continue;
case 0xFF:
default:
goto exit;
}
}
exit:
if ((*ReadProc)(ReadProcArg, 0, __TestForError) && conversions == 0) {
return -1;
}
return items_assigned;
}
int __StringRead(void* pPtr, int ch, int act) {
char ret;
__InStrCtrl* Iscp = (__InStrCtrl*)pPtr;
switch (act) {
case __GetAChar:
ret = *(Iscp->NextChar);
if (ret == '\0') {
Iscp->NullCharDetected = 1;
return -1;
} else {
Iscp->NextChar++;
return (unsigned char)ret;
}
case __UngetAChar:
if (Iscp->NullCharDetected == 0) {
Iscp->NextChar--;
} else {
Iscp->NullCharDetected = 0;
}
return ch;
case __TestForError:
return Iscp->NullCharDetected;
}
return 0;
}
inline int vsscanf(const char* s, const char* format, va_list arg) {
__InStrCtrl isc;
isc.NextChar = (char*)s;
if ((s == 0) || (*isc.NextChar == '\0')) {
return -1;
}
isc.NullCharDetected = 0;
return __sformatter(&__StringRead, (void*)&isc, format, arg, 0);
}
int sscanf(const char* s, const char* pFormat, ...) {
va_list args;
va_start(args, pFormat);
return vsscanf(s, pFormat, args);
}

View File

@@ -1,659 +0,0 @@
#include <internal/format_runtime.h>
#define DBL_MAX_10_EXP 308
#define DBL_MIN_10_EXP (-307)
#define LDBL_MIN DBL_MIN
#define LDBL_MAX DBL_MAX
#define TARGET_FLOAT_BITS 64
#define TARGET_FLOAT_BYTES (TARGET_FLOAT_BITS / 8)
#define TARGET_FLOAT_MAX_EXP LDBL_MAX_EXP
#define TARGET_FLOAT_MANT_DIG LDBL_MANT_DIG
#define TARGET_FLOAT_IMPLICIT_J_BIT 1
#define TARGET_FLOAT_MANT_BITS (TARGET_FLOAT_MANT_DIG - TARGET_FLOAT_IMPLICIT_J_BIT)
#define TARGET_FLOAT_EXP_BITS (TARGET_FLOAT_BITS - TARGET_FLOAT_MANT_BITS - 1)
enum scan_states {
start = 0x0001,
sig_start = 0x0002,
leading_sig_zeroes = 0x0004,
int_digit_loop = 0x0008,
frac_start = 0x0010,
frac_digit_loop = 0x0020,
sig_end = 0x0040,
exp_start = 0x0080,
leading_exp_digit = 0x0100,
leading_exp_zeroes = 0x0200,
exp_digit_loop = 0x0400,
finished = 0x0800,
failure = 0x1000,
nan_state = 0x2000,
infin_state = 0x4000,
hex_state = 0x8000
};
enum hex_scan_states {
not_hex = 0x0000,
hex_start = 0x0001,
hex_leading_sig_zeroes = 0x0002,
hex_int_digit_loop = 0x0004,
hex_frac_digit_loop = 0x0008,
hex_sig_end = 0x0010,
hex_exp_start = 0x0020,
hex_leading_exp_digit = 0x0040,
hex_leading_exp_zeroes = 0x0080,
hex_exp_digit_loop = 0x0100
};
#define final_state(scan_state) (scan_state & (finished | failure))
#define success(scan_state) \
(scan_state & \
(leading_sig_zeroes | int_digit_loop | frac_digit_loop | leading_exp_zeroes | exp_digit_loop | finished))
#define hex_success(count, scan_state) \
(count - 1 > 2 && scan_state & (hex_leading_sig_zeroes | hex_int_digit_loop | hex_frac_digit_loop | \
hex_leading_exp_zeroes | hex_exp_digit_loop))
#define fetch() (count++, (*ReadProc)(ReadProcArg, 0, __GetAChar))
#define unfetch(c) (*ReadProc)(ReadProcArg, c, __UngetAChar)
long double __strtold(int max_width, int (*ReadProc)(void*, int, int), void* ReadProcArg, int* chars_scanned,
int* overflow) {
int scan_state = start;
int hex_scan_state = not_hex;
int count = 0;
int spaces = 0;
int c;
decimal d = {0, 0, {0, ""}};
int sig_negative = 0;
int exp_negative = 0;
long exp_value = 0;
int exp_adjust = 0;
long double result = 0.0;
int sign_detected = 0;
int radix_marker = *(unsigned char*)(__lconv).decimal_point;
unsigned char* chptr;
unsigned char mantissa[TARGET_FLOAT_BYTES];
unsigned mantissa_digits;
unsigned long exponent = 0;
int ui;
unsigned char uch, uch1;
int NibbleIndex;
int expsign = 0;
int exp_digits = 0;
unsigned intdigits = 0;
*overflow = 0;
c = fetch();
while (count <= max_width && c != -1 && !final_state(scan_state)) {
switch (scan_state) {
case start:
if (isspace(c)) {
c = fetch();
count--;
spaces++;
break;
}
switch (toupper(c)) {
case '-':
sig_negative = 1;
case '+':
c = fetch();
sign_detected = 1;
break;
case 'I':
c = fetch();
scan_state = infin_state;
break;
case 'N':
c = fetch();
scan_state = nan_state;
break;
default:
scan_state = sig_start;
break;
}
break;
case infin_state: {
int i = 1;
char model[] = "INFINITY";
while ((i < 8) && (toupper(c) == model[i])) {
i++;
c = fetch();
}
if ((i == 3) || (i == 8)) {
if (sig_negative) {
result = (float)-(double)INFINITY;
} else {
result = INFINITY;
}
*chars_scanned = spaces + i + sign_detected;
return result;
} else {
scan_state = failure;
}
break;
}
case nan_state: {
int i = 1, j = 0;
char model[] = "NAN(";
char nan_arg[32] = "";
while ((i < 4) && (toupper(c) == model[i])) {
i++;
c = fetch();
}
if ((i == 3) || (i == 4)) {
if (i == 4) {
while ((j < 32) && (isdigit(c) || isalpha(c) || (c == radix_marker))) {
nan_arg[j++] = (char)c;
c = fetch();
}
if (c != ')') {
scan_state = failure;
break;
} else {
j++;
}
}
nan_arg[j] = '\0';
if (sig_negative) {
result = -nan(nan_arg);
} else {
result = nan(nan_arg);
}
*chars_scanned = spaces + i + j + sign_detected;
return result;
} else {
scan_state = failure;
}
break;
}
case sig_start:
if (c == radix_marker) {
scan_state = frac_start;
c = fetch();
break;
}
if (!isdigit(c)) {
scan_state = failure;
break;
}
if (c == '0') {
c = fetch();
if (toupper(c) == 'X') {
scan_state = hex_state;
hex_scan_state = hex_start;
} else {
scan_state = leading_sig_zeroes;
}
break;
}
scan_state = int_digit_loop;
break;
case leading_sig_zeroes:
if (c == '0') {
c = fetch();
break;
}
scan_state = int_digit_loop;
break;
case int_digit_loop:
if (!isdigit(c)) {
if (c == radix_marker) {
scan_state = frac_digit_loop;
c = fetch();
} else {
scan_state = sig_end;
}
break;
}
if (d.sig.length < 20) {
d.sig.text[d.sig.length++] = (unsigned char)c;
} else {
exp_adjust++;
}
c = fetch();
break;
case frac_start:
if (!isdigit(c)) {
scan_state = failure;
break;
}
scan_state = frac_digit_loop;
break;
case frac_digit_loop:
if (!isdigit(c)) {
scan_state = sig_end;
break;
}
if (d.sig.length < 20) {
if (c != '0' || d.sig.length) {
d.sig.text[d.sig.length++] = (unsigned char)c;
}
exp_adjust--;
}
c = fetch();
break;
case sig_end:
if (toupper(c) == 'E') {
scan_state = exp_start;
c = fetch();
break;
}
scan_state = finished;
break;
case exp_start:
if (c == '+') {
c = fetch();
} else if (c == '-') {
c = fetch();
exp_negative = 1;
}
scan_state = leading_exp_digit;
break;
case leading_exp_digit:
if (!isdigit(c)) {
scan_state = failure;
break;
}
if (c == '0') {
scan_state = leading_exp_zeroes;
c = fetch();
break;
}
scan_state = exp_digit_loop;
break;
case leading_exp_zeroes:
if (c == '0') {
c = fetch();
break;
}
scan_state = exp_digit_loop;
break;
case exp_digit_loop:
if (!isdigit(c)) {
scan_state = finished;
break;
}
exp_value = exp_value * 10 + (c - '0');
if (exp_value > 0x7FFF) {
*overflow = 1;
}
c = fetch();
break;
case hex_state: {
switch (hex_scan_state) {
case hex_start:
memset(mantissa, 0, sizeof(mantissa));
chptr = mantissa;
mantissa_digits = (53 + 3) / 4;
intdigits = 0;
NibbleIndex = 0;
hex_scan_state = hex_leading_sig_zeroes;
c = fetch();
break;
case hex_leading_sig_zeroes:
if (c == '0') {
c = fetch();
break;
}
hex_scan_state = hex_int_digit_loop;
break;
case hex_int_digit_loop:
if (!isxdigit(c)) {
if (c == radix_marker) {
hex_scan_state = hex_frac_digit_loop;
c = fetch();
}
else {
hex_scan_state = hex_sig_end;
}
break;
}
if (intdigits < mantissa_digits) {
intdigits++;
uch = *(chptr + NibbleIndex / 2);
ui = toupper(c);
if (ui >= 'A') {
ui = ui - 'A' + 10;
} else {
ui -= '0';
}
uch1 = (unsigned char)ui;
if ((NibbleIndex % 2) != 0) {
uch |= uch1;
} else {
uch |= (unsigned char)(uch1 << 4);
}
*(chptr + NibbleIndex++ / 2) = uch;
c = fetch();
}
else {
c = fetch();
}
break;
case hex_frac_digit_loop:
if (!isxdigit(c)) {
hex_scan_state = hex_sig_end;
break;
}
if (intdigits < mantissa_digits) {
uch = *(chptr + NibbleIndex / 2);
ui = toupper(c);
if (ui >= 'A') {
ui = ui - 'A' + 10;
} else {
ui -= '0';
}
uch1 = (unsigned char)ui;
if ((NibbleIndex % 2) != 0) {
uch |= uch1;
} else {
uch |= (unsigned char)(uch1 << 4);
}
*(chptr + NibbleIndex++ / 2) = uch;
c = fetch();
} else {
c = fetch();
}
break;
case hex_sig_end:
if (toupper(c) == 'P') {
hex_scan_state = hex_exp_start;
exp_digits++;
c = fetch();
} else {
scan_state = finished;
}
break;
case hex_exp_start:
exp_digits++;
if (c == '-') {
expsign = 1;
} else if (c != '+') {
c = unfetch(c);
count--;
exp_digits--;
}
hex_scan_state = hex_leading_exp_digit;
c = fetch();
break;
case hex_leading_exp_digit:
if (!isdigit(c)) {
scan_state = failure;
break;
}
if (c == '0') {
exp_digits++;
hex_scan_state = hex_leading_exp_zeroes;
c = fetch();
break;
}
hex_scan_state = hex_exp_digit_loop;
break;
case hex_leading_exp_zeroes:
if (c == '0') {
c = fetch();
break;
}
hex_scan_state = hex_exp_digit_loop;
break;
case hex_exp_digit_loop:
if (!isdigit(c)) {
scan_state = finished;
break;
}
exponent = exponent * 10 + (c - '0');
if (exp_value > SHRT_MAX) {
*overflow = 1;
}
exp_digits++;
c = fetch();
break;
}
} break;
}
}
if (scan_state != 32768 ? !success(scan_state) : !hex_success(count, hex_scan_state)) {
count = 0;
*chars_scanned = 0;
} else {
count--;
*chars_scanned = count + spaces;
}
unfetch(c);
if (hex_scan_state == not_hex) {
if (exp_negative) {
exp_value = -exp_value;
}
{
int n = d.sig.length;
unsigned char* p = &d.sig.text[n];
while (n-- && *--p == '0') {
exp_adjust++;
}
d.sig.length = (unsigned char)(n + 1);
if (d.sig.length == 0) {
d.sig.text[d.sig.length++] = '0';
}
}
exp_value += exp_adjust;
if (exp_value < -0x8000 || exp_value > 0x7FFF) {
*overflow = 1;
}
if (*overflow) {
if (exp_negative) {
return 0.0;
} else {
return sig_negative ? -HUGE_VAL : HUGE_VAL;
}
}
d.exp = (short)exp_value;
result = __dec2num(&d);
if (result != 0.0 && result < LDBL_MIN) {
*overflow = 1;
} else if (result > LDBL_MAX) {
*overflow = 1;
result = HUGE_VAL;
}
if (sig_negative && success(scan_state)) {
result = -result;
}
return result;
} else {
unsigned mantissa_bit, dbl_bit;
unsigned one_bit;
long double dbl_bits_storage;
unsigned char* dbl_bits = (unsigned char*)&dbl_bits_storage;
if (expsign) {
exponent = -exponent;
}
exponent += intdigits * 4;
one_bit = 0;
while (one_bit < 4 && !(mantissa[0] & (0x80 >> one_bit))) {
one_bit++;
exponent--;
}
if (TARGET_FLOAT_IMPLICIT_J_BIT) {
one_bit++;
}
if (one_bit) {
unsigned char carry = 0;
for (chptr = mantissa + sizeof(mantissa) - 1; chptr >= mantissa; chptr--) {
unsigned char a = *chptr;
*chptr = (unsigned char)((a << one_bit) | carry);
carry = (unsigned char)(a >> (8 - one_bit));
}
}
memset(dbl_bits, 0, sizeof(dbl_bits_storage));
dbl_bit = (TARGET_FLOAT_BITS - TARGET_FLOAT_MANT_BITS);
for (mantissa_bit = 0; mantissa_bit < TARGET_FLOAT_MANT_BITS; mantissa_bit += 8) {
unsigned char ui = mantissa[mantissa_bit >> 3];
int halfbits;
if (mantissa_bit + 8 > TARGET_FLOAT_MANT_BITS) {
ui &= 0xff << (TARGET_FLOAT_MANT_BITS - mantissa_bit);
}
halfbits = (dbl_bit & 7);
dbl_bits[dbl_bit >> 3] |= (unsigned char)(ui >> halfbits);
dbl_bit += 8;
dbl_bits[dbl_bit >> 3] |= (unsigned char)(ui << (8 - halfbits));
}
exponent += TARGET_FLOAT_MAX_EXP - 2;
if ((exponent & ~(TARGET_FLOAT_MAX_EXP * 2 - 1))) {
*overflow = 1;
return 0.0;
}
exponent <<= 32 - TARGET_FLOAT_EXP_BITS;
dbl_bits[0] |= exponent >> 25;
if (TARGET_FLOAT_EXP_BITS > 7) {
dbl_bits[1] |= exponent >> 17;
}
if (TARGET_FLOAT_EXP_BITS > 15) {
dbl_bits[2] |= exponent >> 9;
}
if (TARGET_FLOAT_EXP_BITS > 23) {
dbl_bits[3] |= exponent >> 1;
}
if (sig_negative) {
dbl_bits[0] |= 0x80;
}
result = *(long double*)dbl_bits;
return result;
}
}
double strtod(const char* str, char** end) {
__InStrCtrl isc;
double value, abs_value;
int count, overflow;
isc.NextChar = (char*)str;
isc.NullCharDetected = 0;
value = __strtold(INT_MAX, &__StringRead, (void*)&isc, &count, &overflow);
if (end) {
*end = (char*)str + count;
}
abs_value = fabs(value);
if (overflow || (value != 0.0 && (abs_value < DBL_MIN || abs_value > DBL_MAX))) {
errno = ERANGE;
}
return value;
}

View File

@@ -1,727 +0,0 @@
#include <limits.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stddef.h>
#include <internal/locale.h>
#include <string.h>
typedef struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
} tm;
extern int __msl_mod(int, int);
extern div_t __msl_div(long, long);
extern int __msl_add(int*, int);
extern int __msl_ladd(long*, long);
extern int __msl_lmul(long*, long);
static int __leap_year(int year) {
return __msl_mod(year, 4) == 0 && (__msl_mod(year, 100) != 0 || __msl_mod(year, 400) == 100);
}
static int leap_days(int year, int month) {
int n;
div_t q;
q = div(year, 4);
n = q.quot;
q = div(year, 100);
n -= q.quot;
if (year < 100) {
q = __msl_div(year + 899, 1000);
n += q.quot;
} else {
q = __msl_div(year - 100, 1000);
n += q.quot + 1;
}
if (__leap_year(year)) {
if (year < 0) {
if (month > 1) {
n++;
}
} else if (month <= 1) {
n--;
}
}
return n;
}
#define seconds_per_minute (60L)
#define seconds_per_hour (60L * seconds_per_minute)
#define seconds_per_day (24L * seconds_per_hour)
#define seconds_1900_to_1970 (((365 * 70UL) + 17) * 24 * 60 * 60)
const short __msl_month_to_days[2][13] = {
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
{0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}
};
extern int __isdst(void);
extern time_t __get_time(void);
extern int __to_gm_time(time_t*);
void __msl_time2tm(time_t in_time, tm* tm) {
unsigned long years, months, days, seconds;
int is_leap_year;
unsigned long time = in_time + seconds_1900_to_1970;
if (!tm) {
return;
}
tm->tm_isdst = __isdst();
days = time / seconds_per_day;
seconds = time % seconds_per_day;
tm->tm_wday = (days + 1) % 7;
years = 0;
for (;;) {
unsigned long days_this_year = __leap_year(years) ? 366 : 365;
if (days < days_this_year) {
break;
}
days -= days_this_year;
years += 1;
}
tm->tm_year = years;
tm->tm_yday = days;
months = 0;
is_leap_year = __leap_year(years);
for (;;) {
unsigned long days_thru_this_month = __msl_month_to_days[is_leap_year][months + 1];
if (days < days_thru_this_month) {
days -= __msl_month_to_days[is_leap_year][months];
break;
}
++months;
}
tm->tm_mon = months;
tm->tm_mday = days + 1;
tm->tm_hour = seconds / seconds_per_hour;
seconds %= seconds_per_hour;
tm->tm_min = seconds / seconds_per_minute;
tm->tm_sec = seconds % seconds_per_minute;
}
static int adjust(int* x, int y, int* z) {
div_t q;
q = __msl_div(*x, y);
*x = q.rem;
return __msl_add(z, q.quot);
}
static int __tm2time(tm* tm, time_t* time) {
long days;
time_t seconds, day_secs;
if (!tm || !time) {
return 0;
}
--tm->tm_mday;
if (!adjust(&tm->tm_sec, 60, &tm->tm_min)) {
goto no_exit;
}
if (!adjust(&tm->tm_min, 60, &tm->tm_hour)) {
goto no_exit;
}
if (!adjust(&tm->tm_hour, 24, &tm->tm_mday)) {
goto no_exit;
}
if (!adjust(&tm->tm_mon, 12, &tm->tm_year)) {
goto no_exit;
}
days = tm->tm_year;
if (!__msl_lmul(&days, 365)) {
goto no_exit;
}
if (!__msl_ladd(&days, leap_days(tm->tm_year, tm->tm_mon))) {
goto no_exit;
}
if (!__msl_ladd(&days, __msl_month_to_days[0][tm->tm_mon])) {
goto no_exit;
}
if (!__msl_ladd(&days, tm->tm_mday)) {
goto no_exit;
}
if (days < 0 || days > (ULONG_MAX / seconds_per_day)) {
goto no_exit;
}
day_secs = days * seconds_per_day;
seconds = (tm->tm_hour * seconds_per_hour) + (tm->tm_min * seconds_per_minute) + tm->tm_sec;
if (seconds > ULONG_MAX - day_secs) {
goto no_exit;
}
seconds += day_secs;
seconds -= seconds_1900_to_1970;
*time = seconds;
__msl_time2tm(seconds, tm);
return 1;
no_exit:
return 0;
}
extern clock_t __get_clock(void);
clock_t clock(void) {
return __get_clock();
}
time_t mktime(tm* timeptr) {
struct tm tm = *timeptr;
time_t time;
if (!__tm2time(&tm, &time)) {
return (time_t)-1;
}
*timeptr = tm;
return time;
}
static void clear_tm(struct tm* tm) {
tm->tm_sec = 0;
tm->tm_min = 0;
tm->tm_hour = 0;
tm->tm_mday = 1;
tm->tm_mon = 0;
tm->tm_year = 0;
tm->tm_wday = 1;
tm->tm_yday = 0;
tm->tm_isdst = -1;
}
static char* find_name(const char* names, int index) {
static char extracted_name[32];
int i;
const char* start = names;
const char* end;
for (i = 0; i <= index; i++) {
end = strchr(start, '|');
if (i == index) {
if (end == NULL) {
strcpy(extracted_name, start);
} else {
strncpy(extracted_name, start, end - start);
extracted_name[end - start] = '\0';
}
break;
}
start = end + 1;
}
return extracted_name;
}
#pragma exceptions off
char* asctime(const struct tm* timeptr) {
static char asctime_result[26];
char* result = asctime_result;
if (!timeptr) {
strcpy(result, "xxx xxx xx xx:xx:xx xxxx\n");
} else {
char day[4];
char month[4];
strncpy(day, find_name(_current_locale.time_cmpt_ptr->Day_Names, timeptr->tm_wday * 2), 3);
day[3] = 0;
strncpy(month, find_name(_current_locale.time_cmpt_ptr->MonthNames, timeptr->tm_mon * 2), 3);
month[3] = 0;
sprintf(result, "%s %s%3d %.2d:%.2d:%.2d %d\n", day, month, timeptr->tm_mday,
timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec, timeptr->tm_year + 1900);
}
return result;
}
struct tm* localtime(const time_t* timer);
char* ctime(const time_t* timer) {
struct tm* calendar = localtime(timer);
char* result = asctime(calendar);
char day[4];
char month[4];
strncpy(day, find_name(_current_locale.time_cmpt_ptr->Day_Names, calendar->tm_wday * 2), 3);
day[3] = 0;
strncpy(month, find_name(_current_locale.time_cmpt_ptr->MonthNames, calendar->tm_mon * 2), 3);
month[3] = 0;
sprintf(result, "%.3s %.3s %2d %.2d:%.2d:%.2d %4d\n", day, month,
calendar->tm_mday, calendar->tm_hour, calendar->tm_min, calendar->tm_sec,
calendar->tm_year + 1900);
return result;
}
#pragma exceptions on
static time_t time(time_t* timer) {
time_t result = __get_time();
if (timer) {
*timer = result;
}
return result;
}
static struct tm* gmtime(const time_t* timer) {
static struct tm gmtime_tm;
time_t time;
if (!timer) {
clear_tm(&gmtime_tm);
return &gmtime_tm;
}
time = *timer;
if (!__to_gm_time(&time)) {
return NULL;
}
__msl_time2tm(time, &gmtime_tm);
gmtime_tm.tm_isdst = 0;
return &gmtime_tm;
}
#pragma exceptions on
struct tm* localtime(const time_t* timer) {
static struct tm localtime_tm;
if (!timer) {
clear_tm(&localtime_tm);
localtime_tm.tm_isdst = __isdst();
return &localtime_tm;
} else {
__msl_time2tm(*timer, &localtime_tm);
localtime_tm.tm_isdst = __isdst();
return &localtime_tm;
}
}
static int emit(char* str, size_t size, size_t* max_size, const char* format_str, ...) {
va_list args;
va_start(args, format_str);
if (size > *max_size) {
return 0;
}
*max_size -= size;
return vsprintf(str, format_str, args);
}
time_t __MSL_ISO8601NewYear(int year) {
struct tm ts0;
time_t timeval;
short StartMday[7] = {2, 3, 4, 29, 30, 31, 1};
ts0.tm_sec = 0;
ts0.tm_min = 0;
ts0.tm_hour = 0;
ts0.tm_mon = 0;
ts0.tm_isdst = -1;
ts0.tm_mday = 0;
ts0.tm_wday = 7;
ts0.tm_year = year;
while ((ts0.tm_wday != 0) && (ts0.tm_mday <= 7)) {
ts0.tm_mday++;
timeval = mktime(&ts0);
}
ts0.tm_mday = StartMday[ts0.tm_mday - 1];
if (ts0.tm_mday >= 29) {
ts0.tm_mon = 11;
ts0.tm_year--;
}
return mktime(&ts0);
}
static double difftime(time_t time1, time_t time0) {
time_t diff;
if (time1 >= time0) {
return time1 - time0;
}
diff = time0 - time1;
return -(double)diff;
}
extern const double msl_seconds_per_day;
extern const double msl_days_per_week;
extern const double msl_seconds_per_minute;
int __MSL_ISO8601Week(const struct tm* tmptr, int* WYear) {
struct WeekYear {
int Year;
time_t Start;
};
struct WeekYear LastYear, ThisYear, NextYear;
struct WeekYear* WyPtr;
struct tm Localtm = *tmptr;
double Days;
int WeekNo;
time_t GivenTimeVal;
LastYear.Year = tmptr->tm_year - 1;
LastYear.Start = __MSL_ISO8601NewYear(LastYear.Year);
ThisYear.Year = tmptr->tm_year;
ThisYear.Start = __MSL_ISO8601NewYear(ThisYear.Year);
NextYear.Year = tmptr->tm_year + 1;
NextYear.Start = __MSL_ISO8601NewYear(NextYear.Year);
GivenTimeVal = mktime(&Localtm);
if ((LastYear.Start <= GivenTimeVal) && (GivenTimeVal < ThisYear.Start)) {
WyPtr = &LastYear;
} else if ((ThisYear.Start <= GivenTimeVal) && (GivenTimeVal < NextYear.Start)) {
WyPtr = &ThisYear;
} else {
WyPtr = &NextYear;
}
*WYear = WyPtr->Year;
{
double diff;
if (GivenTimeVal >= WyPtr->Start) {
diff = (double)(GivenTimeVal - WyPtr->Start);
} else {
diff = -(double)(WyPtr->Start - GivenTimeVal);
}
Days = diff / msl_seconds_per_day;
}
WeekNo = (int)(Days / msl_days_per_week) + 1;
return WeekNo;
}
static int week_num(const struct tm* tm, int starting_day) {
int days = tm->tm_yday;
days -= __msl_mod(tm->tm_wday - starting_day, 7);
if (days < 0) {
return 0;
}
return (days / 7) + 1;
}
static int emit_string(char* str, size_t size, size_t* max_size, const char* value) {
return emit(str, size, max_size, "%s", value);
}
size_t strftime(char* str, size_t max_size, const char* format_str, const struct tm* timeptr) {
char name[32];
size_t num_chars, chars_written, space_remaining;
struct __locale* locale = &_current_locale;
const char* format_ptr;
const char* curr_format;
int n, ISO8601Year, ISO8601WeekNo;
struct tm tm;
struct tm defaults = {0, 0, 0, 1, 0, 0, 1, 0, -1};
if ((space_remaining = --max_size) <= 0) {
return 0;
}
tm = defaults;
if (timeptr) {
tm = *timeptr;
if (mktime(&tm) == (time_t)-1) {
tm = defaults;
}
}
format_ptr = format_str;
chars_written = 0;
while (*format_ptr) {
if (!(curr_format = strchr(format_ptr, '%'))) {
if ((num_chars = strlen(format_ptr)) != 0) {
if (num_chars <= space_remaining) {
memcpy(str, format_ptr, num_chars);
chars_written += num_chars;
str += num_chars;
space_remaining -= num_chars;
} else {
return 0;
}
}
break;
}
if ((num_chars = curr_format - format_ptr) != 0) {
if (num_chars <= space_remaining) {
memcpy(str, format_ptr, num_chars);
chars_written += num_chars;
str += num_chars;
space_remaining -= num_chars;
} else {
return 0;
}
}
format_ptr = curr_format;
if (format_ptr[1] == 'E' || format_ptr[1] == 'O') {
++format_ptr;
}
switch (*++format_ptr) {
case 'a':
strcpy(name, find_name(locale->time_cmpt_ptr->Day_Names, tm.tm_wday * 2));
num_chars = emit_string(str, strlen(name), &space_remaining, name);
break;
case 'A':
strcpy(name, find_name(locale->time_cmpt_ptr->Day_Names, tm.tm_wday * 2 + 1));
num_chars = emit_string(str, strlen(name), &space_remaining, name);
break;
case 'b':
case 'h': {
num_chars =
emit(str, 3, &space_remaining, "%.3s",
find_name(locale->time_cmpt_ptr->MonthNames, tm.tm_mon * 2));
break;
}
case 'B':
strcpy(name, find_name(locale->time_cmpt_ptr->MonthNames, tm.tm_mon * 2 + 1));
num_chars = emit_string(str, strlen(name), &space_remaining, name);
break;
case 'c':
num_chars = strftime(str, space_remaining + 1, locale->time_cmpt_ptr->DateTime_Format, &tm);
space_remaining -= num_chars;
break;
case 'd':
num_chars = emit(str, 2, &space_remaining, "%.2d", tm.tm_mday);
break;
case 'D':
num_chars = strftime(str, space_remaining + 1, "%m/%d/%y", &tm);
break;
case 'e':
num_chars = emit(str, 2, &space_remaining, "%2d", tm.tm_mday);
break;
case 'F':
num_chars =
emit(str, 10, &space_remaining, "%.4d-%.2d-%.2d", tm.tm_year + 1900, tm.tm_mon + 1,
tm.tm_mday);
break;
case 'g':
ISO8601WeekNo = __MSL_ISO8601Week(timeptr, &ISO8601Year);
num_chars = emit(str, 2, &space_remaining, "%.2d", ISO8601Year % 100);
break;
case 'G':
ISO8601WeekNo = __MSL_ISO8601Week(timeptr, &ISO8601Year);
num_chars = emit(str, 4, &space_remaining, "%.4d", ISO8601Year + 1900);
break;
case 'H':
num_chars = emit(str, 2, &space_remaining, "%.2d", tm.tm_hour);
break;
case 'I':
num_chars = emit(str, 2, &space_remaining, "%.2d",
(n = tm.tm_hour % 12) ? n : 12);
break;
case 'j':
num_chars = emit(str, 3, &space_remaining, "%.3d", tm.tm_yday + 1);
break;
case 'm':
num_chars = emit(str, 2, &space_remaining, "%.2d", tm.tm_mon + 1);
break;
case 'M':
num_chars = emit(str, 2, &space_remaining, "%.2d", tm.tm_min);
break;
case 'n':
num_chars = emit(str, 2, &space_remaining, "\n");
break;
case 'p': {
char* name;
name = find_name(locale->time_cmpt_ptr->am_pm, tm.tm_hour < 12 ? 0 : 1);
num_chars = emit_string(str, strlen(name), &space_remaining, name);
break;
}
case 'r':
num_chars = strftime(str, space_remaining + 1, locale->time_cmpt_ptr->Twelve_hr_format, &tm);
space_remaining -= num_chars;
break;
case 'R':
num_chars = strftime(str, space_remaining + 1, "%H:%M", &tm);
space_remaining -= num_chars;
break;
case 'S':
num_chars = emit(str, 2, &space_remaining, "%.2d", tm.tm_sec);
break;
case 't':
num_chars = emit(str, 2, &space_remaining, "\t");
break;
case 'T':
num_chars = strftime(str, space_remaining + 1, "%H:%M:%S", &tm);
space_remaining -= num_chars;
break;
case 'u':
if (tm.tm_wday == 0) {
num_chars = emit(str, 1, &space_remaining, "7");
} else {
num_chars = emit(str, 1, &space_remaining, "%.1d", tm.tm_wday);
}
break;
case 'U':
num_chars = emit(str, 2, &space_remaining, "%.2d", week_num(&tm, 0));
break;
case 'V':
ISO8601WeekNo = __MSL_ISO8601Week(timeptr, &ISO8601Year);
num_chars = emit(str, 2, &space_remaining, "%.2d", ISO8601WeekNo);
break;
case 'w':
num_chars = emit(str, 1, &space_remaining, "%.1d", tm.tm_wday);
break;
case 'W':
num_chars = emit(str, 2, &space_remaining, "%.2d", week_num(&tm, 1));
break;
case 'x':
num_chars = strftime(str, space_remaining + 1, locale->time_cmpt_ptr->Date_Format, &tm);
space_remaining -= num_chars;
break;
case 'X':
num_chars = strftime(str, space_remaining + 1, locale->time_cmpt_ptr->Time_Format, &tm);
space_remaining -= num_chars;
break;
case 'y':
case 'C':
num_chars = emit(str, 2, &space_remaining, "%.2d", tm.tm_year % 100);
break;
case 'Y':
num_chars = emit(str, 4, &space_remaining, "%.4d", tm.tm_year + 1900);
break;
case 'z': {
time_t local, utc, now;
struct tm localtm, *utctmptr;
double diff, diffmins, diffhours;
now = time(NULL);
utctmptr = gmtime(&now);
if (utctmptr == NULL) {
num_chars = emit(str, 4, &space_remaining, "0000");
} else {
localtm = *localtime(&now);
local = mktime(&localtm);
utc = mktime(utctmptr);
diff = difftime(local, utc);
diffhours = (int)diff / 3600;
diffmins = __abs(diff / msl_seconds_per_minute - msl_seconds_per_minute * diffhours);
num_chars = emit(str, 5, &space_remaining, "%+03.0f%02.0f", diffhours, diffmins);
}
break;
}
case 'Z': {
char* TimeZone = locale->time_cmpt_ptr->TimeZone;
if (*TimeZone == '\0') {
num_chars = 0;
*str = '\0';
} else {
num_chars = emit_string(str, strlen(TimeZone), &space_remaining, TimeZone);
}
break;
}
case '%':
num_chars = emit(str, 2, &space_remaining, "%%", *format_ptr);
break;
default:
num_chars = emit(str, 2, &space_remaining, "%%%c", *format_ptr);
break;
}
if (!num_chars) {
return 0;
}
chars_written += num_chars;
str += num_chars;
++format_ptr;
}
*str = 0;
if (max_size < chars_written) {
return 0;
} else {
return chars_written;
}
}
const double msl_seconds_per_day = 86400.0;
const double msl_days_per_week = 7.0;
const double msl_seconds_per_minute = 60.0;

File diff suppressed because it is too large Load Diff

View File

@@ -1,671 +0,0 @@
#include <internal/format_runtime.h>
#define LDBL_MAX DBL_MAX
typedef unsigned long long d_int;
static inline int __count_trailing_zerol(unsigned long x) { return 32 - __cntlzw(~x & (x - 1)); }
static int __count_trailing_zero(double n) {
unsigned long* array = (unsigned long*)&n;
unsigned long hi = array[0] | 0x100000;
unsigned long lo = array[1];
int zeros = __count_trailing_zerol(lo);
if (lo == 0) {
return 32 + __count_trailing_zerol(hi);
}
return zeros;
}
static int __must_round(const decimal* d, int digits) {
unsigned char const* i = d->sig.text + digits;
if (*i > 5) {
return 1;
}
if (*i < 5) {
return -1;
}
{
unsigned char const* e = d->sig.text + d->sig.length;
for (i++; i < e; i++) {
if (*i != 0) {
return 1;
}
}
}
if (d->sig.text[digits - 1] & 1) {
return 1;
}
return -1;
}
static void __dorounddecup(decimal* d, int digits) {
unsigned char* b = d->sig.text;
unsigned char* i = b + digits - 1;
while (1) {
if (*i < 9) {
*i += 1;
break;
}
if (i == b) {
*i = 1;
d->exp++;
break;
}
*i-- = 0;
}
}
static void __rounddec(decimal* d, int digits) {
if (digits > 0 && digits < d->sig.length) {
int unkBool = __must_round(d, digits);
d->sig.length = digits;
if (unkBool >= 0) {
__dorounddecup(d, digits);
}
}
}
static void __ull2dec(decimal* result, unsigned long long val) {
result->sign = 0;
result->sig.length = 0;
for (; val != 0; val /= 10) {
result->sig.text[result->sig.length++] = (unsigned char)(val % 10);
}
{
unsigned char* i = result->sig.text;
unsigned char* j = result->sig.text + result->sig.length;
for (; i < --j; ++i) {
unsigned char t = *i;
*i = *j;
*j = t;
}
}
result->exp = result->sig.length - 1;
}
static void __timesdec(decimal* result, const decimal* x, const decimal* y) {
unsigned long accumulator = 0;
unsigned char mantissa[SIGDIGLEN * 2];
int i = x->sig.length + y->sig.length - 1;
unsigned char* pDigit;
unsigned char* ip = mantissa + i + 1;
unsigned char* ep = ip;
result->sign = 0;
for (; i > 0; i--) {
int k = y->sig.length - 1;
int j = i - k - 1;
int l;
int t;
const unsigned char* jp;
const unsigned char* kp;
if (j < 0) {
j = 0;
k = i - 1;
}
jp = x->sig.text + j;
kp = y->sig.text + k;
l = k + 1;
t = x->sig.length - j;
if (l > t)
l = t;
for (; l > 0; l--, jp++, kp--) {
accumulator += *jp * *kp;
}
*--ip = (unsigned char)(accumulator % 10);
accumulator /= 10;
}
result->exp = (short)(x->exp + y->exp);
if (accumulator) {
*--ip = (unsigned char)(accumulator);
result->exp++;
}
for (i = 0; i < SIGDIGLEN && ip < ep; i++, ip++) {
result->sig.text[i] = *ip;
}
result->sig.length = (unsigned char)(i);
if (ip < ep && *ip >= 5) {
if (*ip == 5) {
unsigned char* jp = ip + 1;
for (; jp < ep; jp++) {
if (*jp != 0)
goto round;
}
if ((ip[-1] & 1) == 0)
return;
}
round:
__dorounddecup(result, result->sig.length);
}
}
static void __str2dec(decimal* d, const char* s, short exp) {
int i;
d->exp = exp;
d->sign = 0;
for (i = 0; i < SIGDIGLEN && *s;) {
d->sig.text[i++] = *s++ - '0';
}
d->sig.length = i;
if (*s != 0) {
if (*s < 5)
return;
if (*s > 5)
goto round;
{
const char* p = s + 1;
for (; *p != 0; p++) {
if (*p != '0')
goto round;
}
if ((d->sig.text[i - 1] & 1) == 0)
return;
}
round:
__dorounddecup(d, d->sig.length);
}
}
static void __two_exp(decimal* result, long exp) {
switch (exp) {
case -64:
__str2dec(result, "542101086242752217003726400434970855712890625", -20);
return;
case -53:
__str2dec(result, "11102230246251565404236316680908203125", -16);
return;
case -32:
__str2dec(result, "23283064365386962890625", -10);
return;
case -16:
__str2dec(result, "152587890625", -5);
return;
case -8:
__str2dec(result, "390625", -3);
return;
case -7:
__str2dec(result, "78125", -3);
return;
case -6:
__str2dec(result, "15625", -2);
return;
case -5:
__str2dec(result, "3125", -2);
return;
case -4:
__str2dec(result, "625", -2);
return;
case -3:
__str2dec(result, "125", -1);
return;
case -2:
__str2dec(result, "25", -1);
return;
case -1:
__str2dec(result, "5", -1);
return;
case 0:
__str2dec(result, "1", 0);
return;
case 1:
__str2dec(result, "2", 0);
return;
case 2:
__str2dec(result, "4", 0);
return;
case 3:
__str2dec(result, "8", 0);
return;
case 4:
__str2dec(result, "16", 1);
return;
case 5:
__str2dec(result, "32", 1);
return;
case 6:
__str2dec(result, "64", 1);
return;
case 7:
__str2dec(result, "128", 2);
return;
case 8:
__str2dec(result, "256", 2);
return;
}
{
decimal x2, temp;
__two_exp(&x2, exp / 2);
__timesdec(result, &x2, &x2);
if (exp & 1) {
temp = *result;
if (exp > 0) {
__str2dec(&x2, "2", 0);
} else {
__str2dec(&x2, "5", -1);
}
__timesdec(result, &temp, &x2);
}
}
}
static int __equals_dec(const decimal* x, const decimal* y) {
if (x->sig.text[0] == 0) {
return y->sig.text[0] == 0;
}
if (y->sig.text[0] == 0) {
return x->sig.text[0] == 0;
}
if (x->exp == y->exp) {
int i;
int l = x->sig.length;
if (l > y->sig.length) {
l = y->sig.length;
}
for (i = 0; i < l; i++) {
if (x->sig.text[i] != y->sig.text[i]) {
return 0;
}
}
if (l == x->sig.length) {
x = y;
}
for (; i < x->sig.length; i++) {
if (x->sig.text[i] != 0) {
return 0;
}
}
return 1;
}
return 0;
}
static int __less_dec(const decimal* x, const decimal* y) {
if (x->sig.text[0] == 0) {
unsigned char leading_digit = y->sig.text[0];
return ((unsigned long)(-leading_digit | leading_digit) >> 31);
}
if (y->sig.text[0] == 0) {
return 0;
}
if (x->exp == y->exp) {
int i;
int l = x->sig.length;
if (l > y->sig.length) {
l = y->sig.length;
}
for (i = 0; i < l; i++) {
if (x->sig.text[i] < y->sig.text[i]) {
return 1;
} else if (y->sig.text[i] < x->sig.text[i]) {
return 0;
}
}
if (l == x->sig.length) {
for (; i < y->sig.length; i++) {
if (y->sig.text[i] != 0) {
return 1;
}
}
}
return 0;
}
return x->exp < y->exp;
}
static void __minus_dec(decimal* z, const decimal* x, const decimal* y) {
int zlen, dexp;
unsigned char *ib, *i, *ie;
unsigned char const *jb, *j, *jn;
*z = *x;
if (y->sig.text[0] == 0)
return;
zlen = z->sig.length;
if (zlen < y->sig.length)
zlen = y->sig.length;
dexp = z->exp - y->exp;
zlen += dexp;
if (zlen > SIGDIGLEN)
zlen = SIGDIGLEN;
while (z->sig.length < zlen) {
z->sig.text[z->sig.length++] = 0;
}
ib = z->sig.text;
i = ib + zlen;
if (y->sig.length + dexp < zlen) {
i = ib + (y->sig.length + dexp);
}
jb = y->sig.text;
j = jb + (i - ib - dexp);
jn = j;
while (i > ib && j > jb) {
i--;
j--;
if (*i < *j) {
unsigned char* k = i - 1;
while (*k == 0)
k--;
while (k != i) {
--*k;
*++k += 10;
}
}
*i -= *j;
}
if (jn - jb < y->sig.length) {
int round_down = 0;
if (*jn < 5)
round_down = 1;
else if (*jn == 5) {
unsigned char const* ibPtr = y->sig.text + y->sig.length;
for (j = jn + 1; j < ibPtr; j++) {
if (*j != 0)
goto done;
}
i = ib + (jn - jb) + dexp - 1;
if (*i & 1)
round_down = 1;
}
if (round_down) {
if (*i < 1) {
unsigned char* k = i - 1;
while (*k == 0)
k--;
while (k != i) {
--*k;
*++k += 10;
}
}
*i -= 1;
}
}
done:
for (i = ib; *i == 0; ++i) {}
if (i > ib) {
unsigned char dl = (unsigned char)(i - ib);
z->exp -= dl;
ie = ib + z->sig.length;
for (; i < ie; ++i, ++ib)
*ib = *i;
z->sig.length -= dl;
}
ib = z->sig.text;
for (i = ib + z->sig.length; i > ib;) {
i--;
if (*i != 0)
break;
}
z->sig.length = (unsigned char)(i - ib + 1);
}
static void __num2dec_internal(decimal* d, double x) {
signed char sign = (signed char)(__signbitd(x) != 0);
if (x == 0) {
d->sign = sign;
d->exp = 0;
d->sig.length = 1;
d->sig.text[0] = 0;
return;
}
if (!isfinite(x)) {
d->sign = sign;
d->exp = 0;
d->sig.length = 1;
d->sig.text[0] = fpclassify(x) == 1 ? 'N' : 'I';
return;
}
if (sign != 0) {
x = -x;
}
{
int exp;
double frac = frexp(x, &exp);
int num_bits_extract = LDBL_MANT_DIG - __count_trailing_zero(frac);
decimal int_d, pow2_d;
__two_exp(&pow2_d, exp - num_bits_extract);
__ull2dec(&int_d, ldexp(frac, num_bits_extract));
__timesdec(d, &int_d, &pow2_d);
d->sign = sign;
}
}
void __num2dec(const decform* form, double x, decimal* d) {
short digits = form->digits;
int i;
__num2dec_internal(d, x);
if (d->sig.text[0] > 9) {
return;
}
if (digits > SIGDIGLEN) {
digits = SIGDIGLEN;
}
__rounddec(d, digits);
while (d->sig.length < digits) {
d->sig.text[d->sig.length++] = 0;
}
d->exp -= d->sig.length - 1;
for (i = 0; i < d->sig.length; i++) {
d->sig.text[i] += '0';
}
}
double __dec2num(const decimal* d) {
if (d->sig.length <= 0) {
return copysign(0.0, d->sign == 0 ? 1.0 : -1.0);
}
switch (d->sig.text[0]) {
case '0':
return copysign(0.0, d->sign == 0 ? 1.0 : -1.0);
case 'I':
return copysign((double)INFINITY, d->sign == 0 ? 1.0 : -1.0);
case 'N': {
double result;
d_int* ll = (d_int*)&result;
*ll = 0x7FF0000000000000;
if (d->sign)
*ll |= 0x8000000000000000;
*ll |= 0x8000000000000;
return result;
}
}
{
static double pow_10[8] = {1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8};
decimal dec = *d;
unsigned char* i = dec.sig.text;
unsigned char* e = i + dec.sig.length;
double first_guess;
int exponent;
for (; i < e; ++i)
*i -= '0';
dec.exp += dec.sig.length - 1;
exponent = dec.exp;
{
decimal max;
__str2dec(&max, "179769313486231580793728714053034151", 308);
if (__less_dec(&max, &dec)) {
return copysign((double)INFINITY, d->sign == 0 ? 1.0 : -1.0);
}
}
i = dec.sig.text;
first_guess = *i++;
while (i < e) {
unsigned long ival = 0;
int j;
double temp1, temp2;
int ndig = (int)(e - i) % 8;
if (ndig == 0)
ndig = 8;
for (j = 0; j < ndig; ++j, ++i) {
ival = ival * 10 + *i;
}
temp1 = first_guess * pow_10[ndig - 1];
temp2 = temp1 + ival;
if (ival != 0 && temp1 == temp2)
break;
first_guess = temp2;
exponent -= ndig;
}
if (exponent < 0) {
first_guess /= pow(5.0, -exponent);
} else {
first_guess *= pow(5.0, exponent);
}
first_guess = ldexp(first_guess, exponent);
if (fpclassify(first_guess) == 2) {
first_guess = LDBL_MAX;
}
{
decimal feedback1, feedback2, difflow, diffhigh;
double next_guess;
d_int* ull = (d_int*)&next_guess;
int guessed_low = 0;
__num2dec_internal(&feedback1, first_guess);
if (__equals_dec(&feedback1, &dec)) {
goto done;
}
if (__less_dec(&feedback1, &dec)) {
guessed_low = 1;
}
next_guess = first_guess;
while (1) {
if (guessed_low) {
++*ull;
if (fpclassify(next_guess) == 2) {
goto done;
}
} else {
--*ull;
}
__num2dec_internal(&feedback2, next_guess);
if (guessed_low && !__less_dec(&feedback2, &dec)) {
break;
} else if (!guessed_low && !__less_dec(&dec, &feedback2)) {
difflow = feedback1;
feedback1 = feedback2;
feedback2 = difflow;
{
double temp = first_guess;
first_guess = next_guess;
next_guess = temp;
}
break;
}
feedback1 = feedback2;
first_guess = next_guess;
}
__minus_dec(&difflow, &dec, &feedback1);
__minus_dec(&diffhigh, &feedback2, &dec);
if (__equals_dec(&difflow, &diffhigh)) {
if (*(unsigned long long*)&first_guess & 1) {
first_guess = next_guess;
}
} else if (!__less_dec(&difflow, &diffhigh)) {
first_guess = next_guess;
}
}
done:
if (dec.sign) {
first_guess = -first_guess;
}
return first_guess;
}
}

View File

@@ -17,7 +17,6 @@ namespace nw4r {
class FontRefLink {
public:
FontRefLink();
~FontRefLink();
void Set(const char* name, ut::Font* pFont);

View File

@@ -93,11 +93,7 @@ namespace nw4r {
#else
void SetTranslate(const math::VEC3& translate) { mTranslate = translate; }
#endif
#ifdef IPL_SDMEMORY_SET_TRANSLATE_OUT_OF_LINE
void SetTranslate(const math::VEC2& translate);
#else
void SetTranslate(const math::VEC2& translate) { SetTranslate(math::VEC3(translate.x, translate.y, 0.0f)); }
#endif
const math::VEC3& GetRotate() const { return mRotate; }
void SetRotate(const math::VEC3& rotate) { mRotate = rotate; }

View File

@@ -14,11 +14,7 @@ namespace nw4r {
#else
Rect() : left(), top(), right(), bottom() {}
#endif
#ifdef IPL_SETTING_RECT_OUT_OF_LINE
Rect(f32 l, f32 t, f32 r, f32 b);
#else
Rect(f32 l, f32 t, f32 r, f32 b) : left(l), top(t), right(r), bottom(b) {}
#endif
#ifndef IPL_CONTROLLER_TRIVIAL_RECT_DTOR
~Rect() {}

View File

@@ -106,15 +106,7 @@ typedef struct {
u16 outputHeight; // 0x2A
u32 convWidth; // 0x2C
u32 convHeight; // 0x30
#ifdef TMC_JPEG_PLANAR_OUTPUT
u32 chromaWidth;
u32 chromaHeight;
u8* pLumaBuffer;
u8* pCbBuffer;
u8* pCrBuffer;
#else
u8 unk_0x34[0x14]; // 0x34
#endif
void* pTexBuffer; // 0x48
u8 unk_0x4C[0x67C];
TMCCJPEGDecWork* pWorkBuf; // 0x6C8

View File

@@ -1,29 +1,13 @@
#include <string.h>
#include <tmc_jpeg_internal.h>
typedef struct {
u16 bitLength;
u16 symbol;
} TMCHuffmanEntry;
static TMCHuffmanEntry readHuffmanEntry(const TMCHuffmanEntry* entries, u32 index) {
return entries[index];
}
static TMCHuffmanEntry readHuffmanLimit(const TMCHuffmanEntry* entries) {
TMCHuffmanEntry limit;
limit.bitLength = entries->bitLength;
limit.symbol = entries->symbol;
return limit;
}
s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_ptr, TMCCJPEGDecWork* work) {
const TMCHuffmanEntry* ac_fast;
volatile u32 ac_comb;
u16* ac_fast;
u8* huff_sym;
u32* huff_tbl;
s32 bit_pos;
u32 bit_data;
const TMCHuffmanEntry* dc_fast;
u16* dc_fast;
s32 r;
s32 blk0;
s32 idx;
@@ -35,23 +19,29 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
const u8* zztbl;
bit_pos = work->bitCount;
dc_fast = (const TMCHuffmanEntry*)work->pDCFast;
dc_fast = work->pDCFast;
if (bit_pos <= 8) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
bit_pos = work->bitCount;
}
bit_pos = work->bitCount;
bit_data = work->bitBuf;
tmp = bit_pos - 8;
tmp = ((bit_data >> tmp) & 0xFF) << 2;
{
TMCHuffmanEntry dcEntry = readHuffmanEntry(dc_fast, tmp >> 2);
r = dcEntry.bitLength;
extra = dcEntry.symbol;
u16* dc_entry = (u16*)((u8*)dc_fast + tmp);
r = dc_entry[0];
extra = dc_entry[1];
}
{
volatile u32 dc_comb;
*(u16*)&dc_comb = r;
*((u16*)&dc_comb + 1) = extra;
}
if (r != 0) {
@@ -59,10 +49,9 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
work->bitCount = bit_pos;
r = extra;
} else {
s32 dcResult;
u32 code;
unsigned int i;
const TMCHuffmanEntry* entry;
u16* entry;
s32 thresh;
s32 offs;
@@ -70,9 +59,9 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
huff_tbl = work->pDCHuffTbl;
if (bit_pos <= 17) {
dcResult = TMCJPEGDEC_load_buff(work);
if (dcResult < 0) {
goto dc_end;
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
}
bit_pos = work->bitCount;
@@ -82,15 +71,15 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
work->bitCount = bit_pos;
i = 9;
entry = (const TMCHuffmanEntry*)huff_tbl + 9;
entry = (u16*)((u8*)huff_tbl + 0x24);
goto dc_entry;
while (1) {
i++;
entry++;
entry += 2;
if (i > 16) {
dcResult = TMCC_ERROR_OVERFLOW;
r = TMCC_ERROR_OVERFLOW;
goto dc_end;
}
@@ -102,25 +91,34 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
code |= (bit_data >> bit_pos) & 1;
dc_entry:
thresh = entry[0];
offs = entry[1];
{
TMCHuffmanEntry decoded = readHuffmanLimit(entry);
thresh = decoded.bitLength;
offs = entry->symbol;
volatile u16 p[2];
p[0] = thresh;
p[1] = offs;
tmp = *(u32*)p;
}
{
volatile u32 cw;
cw = tmp;
thresh = *(u16*)&cw;
}
if (code > (u32)thresh) {
continue;
}
code = code - entry->bitLength + offs;
dcResult = huff_sym[code & 0xFF];
code = code - entry[0] + offs;
r = huff_sym[code & 0xFF];
break;
}
dc_end:
r = dcResult;
if (dcResult < 0) {
return dcResult;
if (r < 0) {
return r;
}
}
@@ -140,167 +138,195 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
bit_pos -= r;
work->bitCount = bit_pos;
extra = extra & (bit_data >> bit_pos);
if (((s32)tmp >> 1) > extra) {
extra -= tmp - 1;
if ((s32)tmp >> 1 <= extra) {
extra = extra;
} else {
extra = extra - (tmp - 1);
}
dc_predict_row_ptr[0] += extra;
}
*block = dc_predict_row_ptr[0] * blk0;
ac_fast = work->pACFast;
huff_tbl = work->pACHuffTbl;
huff_sym = work->pACHuffSym;
memset((u8*)block + 4, 0, 0xFC);
bit_pos = work->bitCount;
idx = 1;
if (bit_pos <= 8) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0)
return r;
}
bit_pos = work->bitCount;
zztbl = TMCJPEGDEC_Zigzag_data;
bit_data = work->bitBuf;
t = bit_pos - 8;
{
TMCHuffmanEntry acEntry;
ac_fast = (const TMCHuffmanEntry*)work->pACFast;
huff_tbl = work->pACHuffTbl;
huff_sym = work->pACHuffSym;
u32 tbl_idx = ((bit_data >> t) & 0xFF) << 2;
s32 thresh_val = ac_fast[tbl_idx >> 1];
s32 offs_val = *(u16*)((u8*)ac_fast + tbl_idx + 2);
*(u16*)&ac_comb = thresh_val;
*((u16*)&ac_comb + 1) = offs_val;
}
memset(block + 1, 0, 0xFC);
while (idx < 64) {
s32 ac_thresh = *(u16*)&ac_comb;
if (ac_thresh != 0) {
bit_pos = work->bitCount;
bit_pos -= ac_thresh;
work->bitCount = bit_pos;
r = *((u16*)&ac_comb + 1);
} else {
u32 code;
unsigned int i;
u16* entry;
s32 thresh;
s32 offs;
bit_pos = work->bitCount;
idx = 1;
if (bit_pos <= 8) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0)
bit_pos = work->bitCount;
if (bit_pos <= 17) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
bit_pos = work->bitCount;
}
bit_data = work->bitBuf;
bit_pos -= 9;
code = (bit_data >> bit_pos) & 0x1FF;
work->bitCount = bit_pos;
i = 9;
entry = (u16*)((u8*)work->pACHuffTbl + 0x24);
goto ac_entry_huff;
while (1) {
i++;
entry += 2;
if (i > 16) {
r = TMCC_ERROR_OVERFLOW;
goto ac_end;
}
bit_pos = work->bitCount;
code <<= 1;
bit_data = work->bitBuf;
bit_pos--;
work->bitCount = bit_pos;
code |= (bit_data >> bit_pos) & 1;
ac_entry_huff:
thresh = entry[0];
offs = entry[1];
{
volatile u16 p[2];
p[0] = thresh;
p[1] = offs;
tmp = *(u32*)p;
}
{
volatile u32 cw;
cw = tmp;
thresh = *(u16*)&cw;
}
if (code > (u32)thresh) {
continue;
}
code = code - entry[0] + offs;
r = huff_sym[code & 0xFF];
break;
}
ac_end:
if (r < 0) {
return r;
}
}
bit_pos = work->bitCount;
zztbl = TMCJPEGDEC_Zigzag_data;
bit_data = work->bitBuf;
t = bit_pos - 8;
acEntry = readHuffmanEntry(ac_fast, (bit_data >> t) & 0xFF);
t = r & 0x0F;
if (t != 0) {
r >>= 4;
idx += r;
while (idx < 64) {
s32 ac_thresh = acEntry.bitLength;
if (ac_thresh != 0) {
if (idx >= 64) {
return TMCC_ERROR_OVERFLOW;
}
zz = zztbl[idx];
bit_pos = work->bitCount;
if (bit_pos <= t + 8) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
bit_pos = work->bitCount;
bit_pos -= ac_thresh;
work->bitCount = bit_pos;
r = acEntry.symbol;
}
tmp = 1 << t;
bit_data = work->bitBuf;
extra = tmp - 1;
bit_pos -= t;
work->bitCount = bit_pos;
t = bit_pos - 8;
{
u32 next_tbl = ((bit_data >> t) & 0xFF) << 2;
s32 next_th = ac_fast[next_tbl >> 1];
s32 next_of = *(u16*)((u8*)ac_fast + next_tbl + 2);
extra = extra & (bit_data >> bit_pos);
*(u16*)&ac_comb = next_th;
*((u16*)&ac_comb + 1) = next_of;
}
if ((s32)tmp >> 1 <= extra) {
extra = extra;
} else {
u32 code;
unsigned int i;
const TMCHuffmanEntry* entry;
s32 thresh;
s32 offs;
extra = extra - (tmp - 1);
}
bit_pos = work->bitCount;
if (bit_pos <= 17) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
bit_pos = work->bitCount;
}
bit_data = work->bitBuf;
bit_pos -= 9;
code = (bit_data >> bit_pos) & 0x1FF;
work->bitCount = bit_pos;
q = ((s32*)conv_row_ptr)[zz];
block[zz] = extra * q;
i = 9;
entry = (const TMCHuffmanEntry*)huff_tbl + 9;
goto ac_entry_huff;
while (1) {
i++;
entry++;
if (i > 16) {
r = TMCC_ERROR_OVERFLOW;
goto ac_end;
}
bit_pos = work->bitCount;
code <<= 1;
bit_data = work->bitBuf;
bit_pos--;
work->bitCount = bit_pos;
code |= (bit_data >> bit_pos) & 1;
ac_entry_huff:
{
TMCHuffmanEntry decoded = readHuffmanLimit(entry);
thresh = decoded.bitLength;
offs = entry->symbol;
}
if (code > (u32)thresh) {
continue;
}
code = code - entry->bitLength + offs;
r = huff_sym[code & 0xFF];
break;
}
ac_end:
idx++;
} else {
if (r == 0) {
break;
}
bit_pos = work->bitCount;
if (bit_pos <= 8) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
}
t = r & 0x0F;
if (t != 0) {
r >>= 4;
idx += r;
if (idx >= 64) {
return TMCC_ERROR_OVERFLOW;
}
zz = zztbl[idx];
bit_pos = work->bitCount;
if (bit_pos <= t + 8) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
bit_pos = work->bitCount;
}
tmp = 1 << t;
bit_data = work->bitBuf;
extra = tmp - 1;
bit_pos -= t;
work->bitCount = bit_pos;
t = bit_pos - 8;
extra = extra & (bit_data >> bit_pos);
acEntry = readHuffmanEntry(ac_fast, (bit_data >> t) & 0xFF);
if (((s32)tmp >> 1) > extra) {
extra -= tmp - 1;
}
q = ((s32*)conv_row_ptr)[zz];
block[zz] = extra * q;
idx++;
} else {
if (r == 0) {
break;
}
bit_pos = work->bitCount;
if (bit_pos <= 8) {
r = TMCJPEGDEC_load_buff(work);
if (r < 0) {
return r;
}
}
bit_data = work->bitBuf;
bit_pos = work->bitCount;
t = bit_pos - 8;
tmp = ((bit_data >> t) & 0xFF) << 2;
acEntry = readHuffmanEntry(ac_fast, tmp >> 2);
idx += 16;
bit_data = work->bitBuf;
bit_pos = work->bitCount;
t = bit_pos - 8;
tmp = ((bit_data >> t) & 0xFF) << 2;
{
s32 next_thresh = ac_fast[tmp >> 1];
s32 next_offs = *(u16*)((u8*)ac_fast + tmp + 2);
*(u16*)&ac_comb = next_thresh;
*((u16*)&ac_comb + 1) = next_offs;
}
}
if (idx > 64) {
return TMCC_ERROR_OVERFLOW;
idx += 16;
}
idx--;
return TMCJPEGDEC_Zigzag_loop[idx];
}
if (idx > 64) {
return TMCC_ERROR_OVERFLOW;
}
idx--;
return TMCJPEGDEC_Zigzag_loop[idx];
}

View File

@@ -7,21 +7,17 @@ static u8 clampU8(s32 v) {
if (v < 256 && v > -1) {
ok = 1;
}
return ok ? v : 255 & ~(v >> 31);
return (ok) ? v : ((v < 0) ? 0 : 255);
}
static s8 clampS8(s32 v) {
s32 inRange = 0;
if (v < 128 && v > -129) {
inRange = 1;
}
return inRange ? (s8)v : (v > 0) ? 127 : -128;
return (v < 128 && v > -129) ? (s8)v : (v > 0) ? 127 : -128;
}
static s32 scalingClampU8(s32 val) {
s32 result;
s32 result = 0;
if (val >> 19 != 0)
result = ~(val >> 31) & 0xFF;
result &= ~(val >> 31) & 0xFF;
else
result = (val >> 11);
return result;
@@ -42,8 +38,8 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
iter = (u32)(r + 7) >> 3;
dst = tmp;
done = 0;
{
for (; done < r; done += 8) {
if (r > 0) {
for (; iter > 0; iter--) {
u32 ac;
b4 = block[4];
b6 = block[6];
@@ -53,13 +49,7 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
b5 = block[5];
b3 = block[3];
ac = (u32)b4;
ac |= (u32)b6;
ac |= (u32)b2;
ac |= (u32)b1;
ac |= (u32)b7;
ac |= (u32)b5;
ac |= (u32)b3;
ac = (u32)b4 | (u32)b6 | (u32)b2 | (u32)b1 | (u32)b7 | (u32)b5 | (u32)b3;
if (ac == 0) {
s32 val = block[0];
dst[7] = val;
@@ -74,7 +64,7 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
t = (b2 - b6) * 0xB5 >> 8;
a = block[0] - b4;
d = block[0] + b4;
u = t + (b6 + b2);
u = t + b6 + b2;
v = a + t;
e = a - t;
w = d + u;
@@ -86,13 +76,10 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
x = x_factor * 0xB5 >> 8;
z = z_factor * 0x62 >> 8;
m = m_part - z;
n = (b1 + b7) + ((b5 + b3) + m);
n = b1 + b7 + b5 + b3 + m;
o = x + m;
p = z + p_part;
q = x + p;
dst[0] = w + n;
dst[7] = w - n;
dst[1] = v + o;
q = p + x;
dst[6] = v - o;
dst[2] = e + q;
dst[5] = e - q;
@@ -101,11 +88,12 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
}
block += 8;
dst += 8;
done += 8;
}
}
dst = tmp + done;
for (; done <= 0x38; done += 8) {
for (; done < 0x38; done += 8) {
memset(dst, 0, 0x20);
dst += 8;
}
@@ -126,13 +114,7 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
b5 = dst[0x28];
b3 = dst[0x18];
ac = (u32)b4;
ac |= (u32)b6;
ac |= (u32)b2;
ac |= (u32)b1;
ac |= (u32)b7;
ac |= (u32)b5;
ac |= (u32)b3;
ac = (u32)b4 | (u32)b6 | (u32)b2 | (u32)b1 | (u32)b7 | (u32)b5 | (u32)b3;
out = conv_row_ptr + i;
if (ac == 0) {
u8 val = clampU8((*dst >> 11) + 0x80);
@@ -146,23 +128,22 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
out[0] = val;
} else {
t = (b2 - b6) * 0xB5 >> 8;
a = (*dst + 0x40000) - b4;
d = (*dst + 0x40000) + b4;
u = t + (b6 + b2);
a = *dst - b4;
d = *dst + b4;
u = t + b6 + b2;
v = a + t;
e = a - t;
w = d + u;
x_factor = (b1 + b7) - (b5 + b3);
x = x_factor * 0xB5 >> 8;
x = ((b1 + b7) - (b5 + b3)) * 0xB5 >> 8;
y = d - u;
z_factor = ((b5 - b3) + (b1 - b7)) * 0x62 >> 8;
m_part = ((b1 - b7) * 0x14E >> 8) - z_factor;
n = (b1 + b7) + ((b5 + b3) + m_part);
n = b1 + b7 + b5 + b3 + m_part;
o = x + m_part;
p = ((b5 - b3) * 0x8B >> 8) + z_factor;
q = x + p;
p = z_factor + ((b5 - b3) * 0x8B >> 8);
q = p + x;
out[0] = scalingClampU8(w + n);
out[r] = scalingClampU8(w - n);
@@ -272,7 +253,7 @@ void TMCJPEGDEC_IdctBlock_Col(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigza
}
zero_fill:
dst = tmp + done;
for (; done <= 0x38; done += 8) {
for (; done < 0x39; done += 8) {
memset(dst, 0, 0x20);
dst += 8;
}
@@ -315,7 +296,7 @@ mode_gt_2:
t = (b2 - b6) * 0xB5 >> 8;
a = block[0] - b4;
d = block[0] + b4;
u = t + (b6 + b2);
u = t + b6 + b2;
v = a + t;
e = a - t;
w = d + u;
@@ -327,13 +308,10 @@ mode_gt_2:
x = x_factor * 0xB5 >> 8;
z = z_factor * 0x62 >> 8;
m = m_part - z;
n = (b1 + b7) + ((b5 + b3) + m);
n = b1 + b7 + b5 + b3 + m;
o = x + m;
p = z + p_part;
q = p + x;
dst[0] = w + n;
dst[7] = w - n;
dst[1] = v + o;
dst[6] = v - o;
dst[2] = e + q;
dst[5] = e - q;
@@ -347,7 +325,7 @@ mode_gt_2:
}
dst = tmp + done;
for (; done <= 0x38; done += 8) {
for (; done < 0x39; done += 8) {
memset(dst, 0, 0x20);
dst += 8;
}
@@ -387,17 +365,15 @@ epilogue:
t = (b2 - b6) * 0xB5 >> 8;
a = *dst - b4;
d = *dst + b4;
u = t + (b6 + b2);
u = t + b6 + b2;
v = a + t;
e = a - t;
w = d + u;
x_factor = (b1 + b7) - (b5 + b3);
x = x_factor * 0xB5 >> 8;
x = ((b1 + b7) - (b5 + b3)) * 0xB5 >> 8;
y = d - u;
z_factor = (b5 - b3) + (b1 - b7);
z = z_factor * 0x62 >> 8;
z = ((b5 - b3) + (b1 - b7)) * 0x62 >> 8;
m = ((b1 - b7) * 0x14E >> 8) - z;
n = (b1 + b7) + ((b5 + b3) + m);
n = b1 + b7 + b5 + b3 + m;
o = x + m;
p = z + ((b5 - b3) * 0x8B >> 8);

View File

@@ -15,16 +15,9 @@ static u16 readU16(const u8* p, u16 byteOrder) {
return (u16)(raw >> 8 & 0xFF | (raw & 0xFF) << 8);
}
static u16 readExifU16(const u8* data, u16 byteOrder) {
u32 value = data[0] | data[1] << 8;
if (byteOrder == 0x4949) {
return (u16)value;
}
return (u16)(value >> 8 & 255 | (value & 255) << 8);
}
static u32 readU32(const u8* p, u16 byteOrder) {
u32 raw = p[1] << 8 | p[0] | p[2] << 16 | p[3] << 24;
u32 raw = p[0] | p[1] << 8;
raw = raw | p[3] << 24 | p[2] << 16;
if (byteOrder == 0x4949) {
return raw;
}
@@ -33,9 +26,9 @@ static u32 readU32(const u8* p, u16 byteOrder) {
s32 TMCCJPEGDecGetOffsetEXIF(u32* pOffset, u32* pSize, TMCCJPEGDecInitParam* pParam) {
TMCCJPEGDecWork* work;
u16 segSize;
u32 dataSize;
u16 marker;
u32 dataSize;
u16 segSize;
s32 result;
u8 sig[4];
@@ -115,26 +108,62 @@ s32 TMCCJPEGDecGetOffsetEXIF(u32* pOffset, u32* pSize, TMCCJPEGDecInitParam* pPa
continue;
}
switch (marker) {
case 0xFFC0:
case 0xFFC2:
case 0xFFC4:
case 0xFFDB:
case 0xFFDC:
case 0xFFDD:
case 0xFFFE:
if (marker >= 0xFFD9) {
if (marker == 0xFFD9) {
return -2;
}
if (marker == 0xFFFE) {
result = TMCJPEGDEC_move_ptr(segSize, work);
if (result < 0) {
return result;
}
break;
case 0xFFDA:
return -2;
case 0xFFD9:
return -2;
default:
continue;
}
if (marker >= 0xFFDE)
return -0x2F;
if (marker >= 0xFFDB) {
result = TMCJPEGDEC_move_ptr(segSize, work);
if (result < 0) {
return result;
}
continue;
}
return -2;
}
if (marker >= 0xFFC2) {
if (marker == 0xFFC2) {
result = TMCJPEGDEC_move_ptr(segSize, work);
if (result < 0) {
return result;
}
continue;
}
if (marker == 0xFFC4) {
result = TMCJPEGDEC_move_ptr(segSize, work);
if (result < 0) {
return result;
}
continue;
}
return -0x2F;
}
if (marker == 0xFFC0) {
result = TMCJPEGDEC_move_ptr(segSize, work);
if (result < 0) {
return result;
}
continue;
}
return -0x2F;
}
}
@@ -242,103 +271,114 @@ _error:
}
static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData* pInfo) {
u32 ifd0Offset;
u32 ifd1Offset;
u32 exifIfdOffset;
u16 count;
u32 entriesSize;
u32 i;
const u8* p;
s32 sval;
u16 byteOrder;
u32 ifdOffset;
u32 raw;
pInfo->thumbnailData = (u8*)data;
pInfo->dataEnd = (u8*)data + size;
pInfo->nextIfdOffset = 0;
if (size < 8) {
return -161;
}
byteOrder = data[0] | data[1] << 8;
raw = data[0] | data[1] << 8;
byteOrder = raw;
if (byteOrder != 0x4D4D && byteOrder != 0x4949) {
return -161;
}
if (readExifU16(data + 2, byteOrder) != 42) {
if (readU16(data + 2, byteOrder) != 0x002A) {
return -161;
}
ifdOffset = readU32(data + 4, byteOrder);
if (size < ifdOffset) {
ifd0Offset = readU32(data + 4, byteOrder);
if (ifd0Offset > size) {
return -161;
}
{
const u8* entries = data + ifdOffset;
u16 remaining = size - (u16)ifdOffset;
u16 count;
s32 entriesSize;
u16 index;
if (remaining < 2) {
sval = size - (u16)ifd0Offset;
if (sval < 2) {
return -161;
}
p = data + (u16)ifd0Offset;
count = readU16(p, byteOrder);
entriesSize = count * 12;
sval = (u32)(sval - 2);
if (sval < entriesSize) {
return -161;
}
p += 2;
for (i = 0; i < count; i++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, p);
p += 12;
}
sval -= entriesSize;
if (sval < 4) {
return -161;
}
ifd1Offset = readU32(p, byteOrder);
if (ifd1Offset != 0) {
if (ifd1Offset > size) {
return -161;
}
count = readExifU16(entries, byteOrder);
sval = size - (u16)ifd1Offset;
if (sval < 2) {
return -161;
}
p = data + (u16)ifd1Offset;
count = readU16(p, byteOrder);
entriesSize = count * 12;
entries += 2;
remaining -= 2;
if (remaining < entriesSize) {
sval = (u32)(sval - 2);
if (sval < entriesSize) {
return -161;
}
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, entries);
entries += 12;
p += 2;
for (i = 0; i < count; i++) {
TMCJPEGDEC_IFD1_tag_parse(pInfo, byteOrder, p);
p += 12;
}
remaining -= entriesSize;
if (remaining < 4) {
return -161;
}
ifdOffset = readU32(entries, byteOrder);
}
if (ifdOffset == 0) {
return 0;
}
if (size < ifdOffset) {
exifIfdOffset = pInfo->nextIfdOffset;
if (exifIfdOffset == 0 || exifIfdOffset > size) {
return -161;
}
{
const u8* entries = data + ifdOffset;
u16 remaining = size - (u16)ifdOffset;
u16 count;
s32 entriesSize;
u16 index;
if (remaining < 2) {
return -161;
}
count = readExifU16(entries, byteOrder);
entriesSize = count * 12;
entries += 2;
remaining -= 2;
if (remaining < entriesSize) {
return -161;
}
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD1_tag_parse(pInfo, byteOrder, entries);
entries += 12;
}
}
ifdOffset = pInfo->nextIfdOffset;
if (size < ifdOffset) {
sval = size - (u16)exifIfdOffset;
if (sval < 2) {
return -161;
}
{
const u8* entries = data + ifdOffset;
u16 remaining = size - (u16)ifdOffset;
u16 count;
s32 entriesSize;
u16 index;
if (remaining < 2) {
return -161;
}
count = readExifU16(entries, byteOrder);
entriesSize = count * 12;
entries += 2;
remaining -= 2;
if (remaining < entriesSize) {
return -161;
}
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, entries);
entries += 12;
}
p = data + (u16)exifIfdOffset;
count = readU16(p, byteOrder);
entriesSize = count * 12;
sval = (u32)(sval - 2);
if (sval < entriesSize) {
return -161;
}
p += 2;
for (i = 0; i < count; i++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, p);
p += 12;
}
return 0;
}
@@ -351,9 +391,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
switch (tag) {
case 0x0103:
case 0x0111:
case 0x0201:
case 0x0202: {
case 0x0111: {
return;
}
case 0x0112: {
@@ -363,18 +401,18 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
case 0x011A: {
u32 offset = readU32(entry + 8, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
if (p < pInfo->thumbnailData) {
return;
}
if (p > pInfo->dataEnd - 4) {
if (p + 4 > pInfo->dataEnd) {
return;
}
pInfo->xResNum = readU32(p, byteOrder);
p = (const u8*)(pInfo->thumbnailData + offset + 4);
if (pInfo->thumbnailData > p) {
if (p < pInfo->thumbnailData) {
return;
}
if (p > pInfo->dataEnd - 4) {
if (p + 4 > pInfo->dataEnd) {
return;
}
pInfo->xResDen = readU32(p, byteOrder);
@@ -383,18 +421,18 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
case 0x011B: {
u32 offset = readU32(entry + 8, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
if (p < pInfo->thumbnailData) {
return;
}
if (p > pInfo->dataEnd - 4) {
if (p + 4 > pInfo->dataEnd) {
return;
}
pInfo->yResNum = readU32(p, byteOrder);
p = (const u8*)(pInfo->thumbnailData + offset + 4);
if (pInfo->thumbnailData > p) {
if (p < pInfo->thumbnailData) {
return;
}
if (p > pInfo->dataEnd - 4) {
if (p + 4 > pInfo->dataEnd) {
return;
}
pInfo->yResDen = readU32(p, byteOrder);
@@ -406,19 +444,19 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
}
case 0x012D: {
u32 offset = readU32(entry + 8, byteOrder);
u32 channel;
u32 index;
for (channel = 0; channel < 3; channel++) {
for (index = 0; index < 256; index++) {
const u8* p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
break;
const u8* p = pInfo->thumbnailData + offset;
u32 j;
u32 i;
for (j = 0; j < 3; j++) {
for (i = 0; i < 256; i++) {
if (p < pInfo->thumbnailData) {
return;
}
if (p > pInfo->dataEnd - 2) {
break;
if (p + 2 > pInfo->dataEnd) {
return;
}
pInfo->transferFunc[channel][index] = readU16(p, byteOrder);
offset += 2;
pInfo->transferFunc[j][i] = readU16(p, byteOrder);
p += 2;
}
}
return;
@@ -426,18 +464,17 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
case 0x0132: {
u32 offset = readU32(entry + 8, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
if (p < pInfo->thumbnailData) {
return;
}
if (p > pInfo->dataEnd - 20) {
if (p + 20 > pInfo->dataEnd) {
return;
}
{
u32 index;
for (index = 0; index < 20; index++) {
pInfo->dateTime[index] = p[index];
}
}
*(u32*)(pInfo->dateTime + 0) = *(u32*)(p + 0);
*(u32*)(pInfo->dateTime + 4) = *(u32*)(p + 4);
*(u32*)(pInfo->dateTime + 8) = *(u32*)(p + 8);
*(u32*)(pInfo->dateTime + 12) = *(u32*)(p + 12);
*(u32*)(pInfo->dateTime + 16) = *(u32*)(p + 16);
return;
}
case 0x0213: {
@@ -501,54 +538,52 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
switch (tag) {
case 0x0132:
case 0x0111:
case 0x0112:
case 0x012D:
case 0x0213:
case 0x8769:
case 0x9000:
case 0x9101:
case 0xA003: {
case 0x9101: {
return;
}
case 0x0103: {
pInfo->compressionIfd1 = readU16(entry + 8, byteOrder);
return;
}
case 0x011A: {
u32 offset;
const u8* p;
offset = readU32(entry + 8, byteOrder);
p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
u32 offset = readU32(entry + 8, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (p < pInfo->thumbnailData) {
return;
}
if (p > pInfo->dataEnd - 4) {
if (p + 4 > pInfo->dataEnd) {
return;
}
pInfo->xResNumIfd1 = readU32(p, byteOrder);
p = (const u8*)(pInfo->thumbnailData + offset + 4);
if (pInfo->thumbnailData > p) {
if (p < pInfo->thumbnailData) {
return;
}
if (p > pInfo->dataEnd - 4) {
if (p + 4 > pInfo->dataEnd) {
return;
}
pInfo->xResDenIfd1 = readU32(p, byteOrder);
return;
}
case 0x011B: {
u32 offset;
const u8* p;
offset = readU32(entry + 8, byteOrder);
p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
u32 offset = readU32(entry + 8, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (p < pInfo->thumbnailData) {
return;
}
if (p > pInfo->dataEnd - 4) {
if (p + 4 > pInfo->dataEnd) {
return;
}
pInfo->planarConfigIfd1 = readU32(p, byteOrder);
p = (const u8*)(pInfo->thumbnailData + offset + 4);
if (pInfo->thumbnailData > p) {
if (p < pInfo->thumbnailData) {
return;
}
if (p > pInfo->dataEnd - 4) {
if (p + 4 > pInfo->dataEnd) {
return;
}
pInfo->yResDenIfd1 = readU32(p, byteOrder);
@@ -558,10 +593,6 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
pInfo->resUnitIfd1 = readU16(entry + 8, byteOrder);
return;
}
case 0x0103: {
pInfo->compressionIfd1 = readU16(entry + 8, byteOrder);
return;
}
case 0x0201: {
pInfo->thumbnailOffset = readU32(entry + 8, byteOrder);
return;

View File

@@ -30,14 +30,14 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
u8* p2 = p1 + mode;
u8* p3 = p2 + mode;
work->pConverterFunc = TMCJPEGDEC_converterYUV411toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV411toRGB565edge;
work->pConvRowPtrs[0] = (void*)ptr;
work->pConvRowPtrs[1] = (void*)p1;
work->pConvRowPtrs[2] = (void*)p2;
work->pConvRowPtrs[3] = (void*)p3;
work->pConvRowPtrs[5] = (void*)(ob + 0x104);
work->pConvRowPtrs[6] = (void*)(ob + 0x144);
work->pConverterFunc = TMCJPEGDEC_converterYUV411toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV411toRGB565edge;
work->pitch = 0x20;
work->converterFlags = 0;
break;
@@ -45,12 +45,12 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
case 1: {
u8 mode = work->idctMode;
u8* ptr = ob + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV422toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV422toRGB565edge;
work->pConvRowPtrs[0] = (void*)ptr;
work->pConvRowPtrs[1] = (void*)(ptr + mode);
work->pConvRowPtrs[5] = (void*)(ob + 0x84);
work->pConvRowPtrs[6] = (void*)(ob + 0xc4);
work->pConverterFunc = TMCJPEGDEC_converterYUV422toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV422toRGB565edge;
work->pConvRowPtrs[6] = (void*)(ob + 0xC4);
work->pitch = 0x10;
work->converterFlags = 0;
break;
@@ -58,17 +58,14 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
case 2: {
u8 mode = work->idctMode;
u8* ptr = ob + 4;
u8* p1 = ptr + mode;
u8* p2 = ptr + mode * 16;
u8* p3 = p2 + mode;
work->pConvRowPtrs[0] = (void*)ptr;
work->pConvRowPtrs[1] = (void*)p1;
work->pConvRowPtrs[2] = (void*)p2;
work->pConvRowPtrs[3] = (void*)p3;
work->pConvRowPtrs[5] = (void*)(ob + 0x104);
work->pConvRowPtrs[6] = (void*)(ob + 0x144);
work->pConverterFunc = TMCJPEGDEC_converterYUV420toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV420toRGB565edge;
work->pConvRowPtrs[0] = (void*)ptr;
work->pConvRowPtrs[1] = (void*)(ptr + mode);
work->pConvRowPtrs[2] = (void*)(ptr + mode * 16);
work->pConvRowPtrs[3] = (void*)(ptr + mode * 16 + mode);
work->pConvRowPtrs[5] = (void*)(ob + 0x104);
work->pConvRowPtrs[6] = (void*)(ob + 0x144);
work->pitch = 0x10;
work->converterFlags = 0;
break;
@@ -76,30 +73,30 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
case 3: {
u8 mode = work->idctMode;
u8* ptr = ob + 4;
work->pConvRowPtrs[0] = (void*)ptr;
work->pConvRowPtrs[1] = (void*)(ptr + mode * 8);
work->pConvRowPtrs[5] = (void*)(ob + 0x84);
work->pConvRowPtrs[6] = (void*)(ob + 0xc4);
work->pConverterFunc = TMCJPEGDEC_converterYUV211toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV211toRGB565edge;
work->pConvRowPtrs[0] = (void*)ptr;
work->pConvRowPtrs[1] = (void*)(ptr + mode * 8);
work->pConvRowPtrs[5] = (void*)(ptr + 0x84);
work->pConvRowPtrs[6] = (void*)(ptr + 0xC4);
work->pitch = 0x08;
work->converterFlags = 0;
break;
}
case 4: {
work->pConvRowPtrs[0] = (void*)(ob + 0x4);
work->pConvRowPtrs[5] = (void*)(ob + 0x44);
work->pConvRowPtrs[6] = (void*)(ob + 0x84);
work->pConverterFunc = TMCJPEGDEC_converterYUV444toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV444toRGB565edge;
work->pConverterFunc = TMCJPEGDEC_converterYUV400toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV400toRGB565edge;
work->pConvRowPtrs[0] = (void*)(ob + 4);
work->pitch = 0x08;
work->converterFlags = 0;
break;
}
case 5: {
work->pConvRowPtrs[0] = (void*)(ob + 0x4);
work->pConverterFunc = TMCJPEGDEC_converterYUV400toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV400toRGB565edge;
work->pConverterFunc = TMCJPEGDEC_converterYUV444toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV444toRGB565edge;
work->pConvRowPtrs[0] = (void*)(ob + 4);
work->pConvRowPtrs[5] = (void*)(ob + 0x44);
work->pConvRowPtrs[6] = (void*)(ob + 0x84);
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -110,777 +107,18 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
}
{
s32 width = st->jpegWidth;
s32 height = st->jpegHeight;
st->convWidth = ((u32)width / 4 + (width % 4 != 0)) * 4;
st->convHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
u32 fw = st->jpegWidth;
u32 fh = st->jpegHeight;
s32 bw = (s32)(((fw << 30) - (fw >> 31)) * 4 + (fw >> 31));
s32 bh = (s32)(((fh << 30) - (fh >> 31)) * 4 + (fh >> 31));
{
s32 nb = -bw;
s32 nb2 = -bh;
bw = ((nb | bw) >> 31) + (fw >> 2);
bh = ((nb2 | bh) >> 31) + (fh >> 2);
}
st->convWidth = bw << 2;
st->convHeight = bh << 2;
}
return 0;
}
static void TMCJPEGDEC_converterYUV411toRGB565(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* luminance = work->convBuf + 4;
u8* cb = work->convBuf + 260;
u8* cr = work->convBuf + 324;
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 2;
u8* texture = state->pTexBuffer;
s32 width;
s32 height;
width = 32 / state->scaleFactor;
height = 8 / state->scaleFactor;
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 lumaSkip = 32 - width;
s32 chromaSkip = lumaSkip >> 2;
for (; y < yEnd; y++) {
s32 tileRow = (y >> 2) * tileWidth;
u16* output = (u16*)(texture + ((y & 3) << 3));
s32 column;
for (column = x; column < xEnd; column += 4) {
s32 redOffset, greenOffset, blueOffset;
{
s32 cbValue = (s8)*cb++;
s32 crValue = (s8)*cr++;
redOffset = (crValue * 359) >> 8;
greenOffset = -(crValue * 183 + cbValue * 88) >> 8;
blueOffset = (cbValue * 454) >> 8;
}
{
s32 value = luminance[0];
s32 red = value + redOffset;
s32 green = value + greenOffset;
s32 blue = value + blueOffset;
if ((red | blue | green) >> 8) {
blue = (blue > 255) ? 255 : blue & ~(blue >> 31);
green = (green > 255) ? 255 : green & ~(green >> 31);
red = (red > 255) ? 255 : red & ~(red >> 31);
}
output[(column & 3) + ((((column) >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
{
s32 value = luminance[1];
s32 red = value + redOffset;
s32 green = value + greenOffset;
s32 blue = value + blueOffset;
if ((red | blue | green) >> 8) {
blue = (blue > 255) ? 255 : blue & ~(blue >> 31);
green = (green > 255) ? 255 : green & ~(green >> 31);
red = (red > 255) ? 255 : red & ~(red >> 31);
}
output[(column + 1 & 3) + ((((column + 1) >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
{
s32 value = luminance[2];
s32 red = value + redOffset;
s32 green = value + greenOffset;
s32 blue = value + blueOffset;
if ((red | blue | green) >> 8) {
blue = (blue > 255) ? 255 : blue & ~(blue >> 31);
green = (green > 255) ? 255 : green & ~(green >> 31);
red = (red > 255) ? 255 : red & ~(red >> 31);
}
output[(column + 2 & 3) + ((((column + 2) >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
{
s32 value = luminance[3];
s32 red = value + redOffset;
s32 green = value + greenOffset;
s32 blue = value + blueOffset;
if ((red | blue | green) >> 8) {
blue = (blue > 255) ? 255 : blue & ~(blue >> 31);
green = (green > 255) ? 255 : green & ~(green >> 31);
red = (red > 255) ? 255 : red & ~(red >> 31);
}
output[(column + 3 & 3) + ((((column + 3) >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
luminance += 4;
}
luminance += lumaSkip;
cb += chromaSkip;
cr += chromaSkip;
}
}
}
static void TMCJPEGDEC_converterYUV411toRGB565edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 column;
u8* luminance = work->convBuf + 4;
u8* cb = work->convBuf + 260;
u8* cr = work->convBuf + 324;
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 2;
u8* texture = state->pTexBuffer;
s32 width;
s32 height;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 32 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 8 / state->scaleFactor;
}
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 lumaSkip = 32 - width;
s32 chromaSkip = lumaSkip >> 2;
s32 redOffset = 0, greenOffset = 0, blueOffset = 0;
for (; y < yEnd; y++) {
s32 tileRow = (y >> 2) * tileWidth;
u16* output = (u16*)(texture + ((y & 3) << 3));
for (column = x; column < xEnd; column += 1) {
if ((column & 3) == 0) {
s32 cbValue = (s8)*cb++;
s32 crValue = (s8)*cr++;
redOffset = (crValue * 359) >> 8;
greenOffset = -(cbValue * 88 + crValue * 183) >> 8;
blueOffset = (cbValue * 454) >> 8;
}
{
s32 value = luminance[0];
s32 green = value + greenOffset;
s32 red = value + redOffset;
s32 blue = value + blueOffset;
if ((blue | red | green) >> 8) {
blue = (blue > 255) ? 255 : blue & ~(blue >> 31);
green = (green > 255) ? 255 : green & ~(green >> 31);
red = (red > 255) ? 255 : red & ~(red >> 31);
}
output[(column & 3) + ((((column) >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
luminance += 1;
}
luminance += lumaSkip;
cb += chromaSkip;
cr += chromaSkip;
}
}
}
static void TMCJPEGDEC_converterYUV422toRGB565(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 column;
u8* luminance = work->convBuf + 4;
u8* cb = work->convBuf + 132;
u8* cr = work->convBuf + 196;
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 2;
u8* texture = state->pTexBuffer;
s32 width;
s32 height;
width = 16 / state->scaleFactor;
height = 8 / state->scaleFactor;
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 lumaSkip = 16 - width;
s32 chromaSkip = lumaSkip >> 1;
for (; y < yEnd; y++) {
s32 tileRow = (y >> 2) * tileWidth;
u16* output = (u16*)(texture + ((y & 3) << 3));
for (column = x; column < xEnd; column += 2) {
s32 redOffset, greenOffset, blueOffset;
{
s32 cbValue = (s8)*cb++;
s32 crValue = (s8)*cr++;
redOffset = (crValue * 359) >> 8;
greenOffset = -(cbValue * 88 + crValue * 183) >> 8;
blueOffset = (cbValue * 454) >> 8;
}
{
s32 value = luminance[0];
s32 red = value + redOffset;
s32 green = value + greenOffset;
s32 blue = value + blueOffset;
if ((blue | red | green) >> 8) {
blue = (blue > 255) ? 255 : blue & ~(blue >> 31);
green = (green > 255) ? 255 : green & ~(green >> 31);
red = (red > 255) ? 255 : red & ~(red >> 31);
}
output[(column & 3) + ((((column) >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
{
s32 value = luminance[1];
s32 red = value + redOffset;
s32 green = value + greenOffset;
s32 blue = value + blueOffset;
if ((blue | red | green) >> 8) {
blue = (blue > 255) ? 255 : blue & ~(blue >> 31);
green = (green > 255) ? 255 : green & ~(green >> 31);
red = (red > 255) ? 255 : red & ~(red >> 31);
}
output[(column + 1 & 3) + ((((column + 1) >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
luminance += 2;
}
luminance += lumaSkip;
cb += chromaSkip;
cr += chromaSkip;
}
}
}
static void TMCJPEGDEC_converterYUV422toRGB565edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 column;
u8* luminance = work->convBuf + 4;
s8* cb = (s8*) work->convBuf + 132;
s8* cr = (s8*) work->convBuf + 196;
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 2;
u8* texture = state->pTexBuffer;
s32 width;
s32 height;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 16 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 8 / state->scaleFactor;
}
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 lumaSkip = 16 - width;
s32 chromaSkip = lumaSkip >> 1;
s32 redOffset = 0, greenOffset = 0, blueOffset = 0;
for (; y < yEnd; y++) {
s32 tileRow = (y >> 2) * tileWidth;
u16* output = (u16*)(texture + ((y & 3) << 3));
for (column = x; column < xEnd; column += 1) {
if ((column & 1) == 0) {
s32 cbValue = (s8)*cb++;
s32 crValue = (s8)*cr++;
redOffset = (crValue * 359) >> 8;
greenOffset = -(cbValue * 88 + crValue * 183) >> 8;
blueOffset = (cbValue * 454) >> 8;
}
{
s32 value = luminance[0];
s32 red = value + redOffset;
s32 green = value + greenOffset;
s32 blue = value + blueOffset;
if ((blue | red | green) >> 8) {
blue = (blue > 255) ? 255 : blue & ~(blue >> 31);
green = (green > 255) ? 255 : green & ~(green >> 31);
red = (red > 255) ? 255 : red & ~(red >> 31);
}
output[(column & 3) + ((((column) >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
luminance += 1;
}
luminance += lumaSkip;
cb += chromaSkip;
cr += chromaSkip;
}
}
}
static void TMCJPEGDEC_converterYUV420toRGB565(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* luminance = work->convBuf + 4;
u8* cb = work->convBuf + 260;
u8* cr = work->convBuf + 324;
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 2;
u8* texture = state->pTexBuffer;
s32 width;
s32 height;
width = 16 / state->scaleFactor;
height = 16 / state->scaleFactor;
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 lumaSkip = 16 - width;
s32 chromaSkip = lumaSkip >> 1;
for (; y < yEnd; y++) {
s32 tileRow = (y >> 2) * tileWidth;
u16* output = (u16*)(texture + ((y & 3) << 3));
s32 column;
for (column = x; column < xEnd; column += 2) {
s32 redOffset, greenOffset, blueOffset;
{
s32 cbValue = (s8)*cb++;
s32 crValue = (s8)*cr++;
redOffset = (crValue * 359) >> 8;
greenOffset = -(cbValue * 88 + crValue * 183) >> 8;
blueOffset = (cbValue * 454) >> 8;
}
{
s32 value = luminance[0];
s32 red = value + redOffset;
s32 green = value + greenOffset;
s32 blue = value + blueOffset;
if ((blue | red | green) >> 8) {
blue = (blue > 255) ? 255 : blue & ~(blue >> 31);
green = (green > 255) ? 255 : green & ~(green >> 31);
red = (red > 255) ? 255 : red & ~(red >> 31);
}
output[(column & 3) + ((((column) >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
{
s32 value = luminance[1];
s32 red = value + redOffset;
s32 green = value + greenOffset;
s32 blue = value + blueOffset;
if ((blue | red | green) >> 8) {
blue = (blue > 255) ? 255 : blue & ~(blue >> 31);
green = (green > 255) ? 255 : green & ~(green >> 31);
red = (red > 255) ? 255 : red & ~(red >> 31);
}
output[(column + 1 & 3) + ((((column + 1) >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
luminance += 2;
}
luminance += lumaSkip;
if (y & 1) {
cb += chromaSkip;
cr += chromaSkip;
} else {
cb -= (width + 1) >> 1;
cr -= (width + 1) >> 1;
}
}
}
}
static void TMCJPEGDEC_converterYUV420toRGB565edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* luminance = work->convBuf + 4;
s8* cb = (s8*) work->convBuf + 260;
s8* cr = (s8*) work->convBuf + 324;
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 2;
u8* texture = state->pTexBuffer;
s32 width;
s32 height;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 16 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 16 / state->scaleFactor;
}
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 lumaSkip = 16 - width;
s32 chromaSkip = lumaSkip >> 1;
s32 redOffset = 0, greenOffset = 0, blueOffset = 0;
for (; y < yEnd; y++) {
s32 tileRow = (y >> 2) * tileWidth;
u16* output = (u16*)(texture + ((y & 3) << 3));
s32 column;
for (column = x; column < xEnd; column += 1) {
if ((column & 1) == 0) {
s32 cbValue = (s8)*cb++;
s32 crValue = (s8)*cr++;
redOffset = (crValue * 359) >> 8;
greenOffset = -(cbValue * 88 + crValue * 183) >> 8;
blueOffset = (cbValue * 454) >> 8;
}
{
s32 value = *luminance++;
s32 red = value + redOffset;
s32 green = value + greenOffset;
s32 blue = value + blueOffset;
if ((blue | red | green) >> 8) {
blue = (blue > 255) ? 255 : blue & ~(blue >> 31);
green = (green > 255) ? 255 : green & ~(green >> 31);
red = (red > 255) ? 255 : red & ~(red >> 31);
}
output[(column & 3) + ((((column) >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
}
luminance += lumaSkip;
if (y & 1) {
cb += chromaSkip;
cr += chromaSkip;
} else {
cb -= (width + 1) >> 1;
cr -= (width + 1) >> 1;
}
}
}
}
static void TMCJPEGDEC_converterYUV211toRGB565(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 column;
u8* luminance = work->convBuf + 4;
u8* cb = work->convBuf + 132;
u8* cr = work->convBuf + 196;
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 2;
u8* texture = state->pTexBuffer;
s32 width;
s32 height;
width = 8 / state->scaleFactor;
height = 16 / state->scaleFactor;
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 lumaSkip = 8 - width;
s32 chromaSkip = lumaSkip >> 0;
for (; y < yEnd; y++) {
s32 tileRow = (y >> 2) * tileWidth;
u16* output = (u16*)(texture + ((y & 3) << 3));
for (column = x; column < xEnd; column += 1) {
s32 redOffset, greenOffset, blueOffset;
{
s32 cbValue = (s8)*cb++;
s32 crValue = (s8)*cr++;
redOffset = (crValue * 359) >> 8;
greenOffset = -(cbValue * 88 + crValue * 183) >> 8;
blueOffset = (cbValue * 454) >> 8;
}
{
s32 value = luminance[0];
s32 green = value + greenOffset;
s32 red = value + redOffset;
s32 blue = value + blueOffset;
if ((blue | red | green) >> 8) {
blue = (blue > 255) ? 255 : blue & ~(blue >> 31);
green = (green > 255) ? 255 : green & ~(green >> 31);
red = (red > 255) ? 255 : red & ~(red >> 31);
}
output[(column & 3) + ((((column) >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
luminance += 1;
}
luminance += lumaSkip;
if (y & 1) {
cb += chromaSkip;
cr += chromaSkip;
} else {
cb -= (width + 0) >> 0;
cr -= (width + 0) >> 0;
}
}
}
}
static void TMCJPEGDEC_converterYUV211toRGB565edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 column;
u8* luminance = work->convBuf + 4;
u8* cb = work->convBuf + 132;
u8* cr = work->convBuf + 196;
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 2;
u8* texture = state->pTexBuffer;
s32 width;
s32 height;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 8 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 16 / state->scaleFactor;
}
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 lumaSkip = 8 - width;
s32 chromaSkip = lumaSkip >> 0;
for (; y < yEnd; y++) {
s32 tileRow = (y >> 2) * tileWidth;
u16* output = (u16*)(texture + ((y & 3) << 3));
for (column = x; column < xEnd; column += 1) {
s32 redOffset, greenOffset, blueOffset;
{
s32 cbValue = (s8)*cb++;
s32 crValue = (s8)*cr++;
redOffset = (crValue * 359) >> 8;
greenOffset = -(cbValue * 88 + crValue * 183) >> 8;
blueOffset = (cbValue * 454) >> 8;
}
{
s32 value = luminance[0];
s32 green = value + greenOffset;
s32 red = value + redOffset;
s32 blue = value + blueOffset;
if ((blue | red | green) >> 8) {
blue = (blue > 255) ? 255 : blue & ~(blue >> 31);
green = (green > 255) ? 255 : green & ~(green >> 31);
red = (red > 255) ? 255 : red & ~(red >> 31);
}
output[(column & 3) + ((((column) >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
luminance += 1;
}
luminance += lumaSkip;
if (y & 1) {
cb += chromaSkip;
cr += chromaSkip;
} else {
cb -= (width + 0) >> 0;
cr -= (width + 0) >> 0;
}
}
}
}
static void TMCJPEGDEC_converterYUV444toRGB565(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 crValue;
TMCCJPEGDecState* state;
s32 value;
u16* output;
s32 rowSkip;
u32 tileWidth;
s32 tileRow;
u8* luminance;
u8* cb;
u8* texture;
s32 column;
s32 xEnd;
s32 cbValue;
s32 blue;
s32 width;
s32 yEnd;
s32 height;
s32 green;
s32 red;
u8* cr;
luminance = work->convBuf + 4;
cb = work->convBuf + 68;
cr = work->convBuf + 132;
state = work->pState;
tileWidth = state->convWidth >> 2;
texture = state->pTexBuffer;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
xEnd = x + width;
yEnd = y + height;
rowSkip = 8 - width;
for (; y < yEnd; y++) {
output = (u16*)(texture + ((y & 3) << 3));
tileRow = (y >> 2) * tileWidth;
for (column = x; column < xEnd; column++) {
cbValue = (s8)*cb++;
crValue = (s8)*cr++;
value = *luminance++;
green = value + (-(cbValue * 88 + crValue * 183) >> 8);
red = value + ((crValue * 359) >> 8);
blue = value + ((cbValue * 454) >> 8);
if ((blue | red | green) >> 8) {
blue &= ~(blue >> 31);
if (blue > 255) {
blue = 255;
}
green &= ~(green >> 31);
if (green > 255) {
green = 255;
}
red &= ~(red >> 31);
if (red > 255) {
red = 255;
}
}
output[(column & 3) + (((column >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
luminance += rowSkip;
cb += rowSkip;
cr += rowSkip;
}
}
static void TMCJPEGDEC_converterYUV444toRGB565edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 column;
s32 tileRow;
u16* output;
u8* luminance;
u8* cb;
u8* cr;
TMCCJPEGDecState* state;
u32 tileWidth;
u8* texture;
s32 width;
s32 height;
s32 xEnd;
s32 yEnd;
s32 rowSkip;
s32 cbValue;
s32 crValue;
s32 value;
s32 green;
s32 red;
s32 blue;
luminance = work->convBuf + 4;
cb = work->convBuf + 68;
cr = work->convBuf + 132;
state = work->pState;
tileWidth = state->convWidth >> 2;
texture = state->pTexBuffer;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 8 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 8 / state->scaleFactor;
}
xEnd = x + width;
yEnd = y + height;
rowSkip = 8 - width;
for (; y < yEnd; y++) {
output = (u16*)(texture + ((y & 3) << 3));
tileRow = (y >> 2) * tileWidth;
for (column = x; column < xEnd; column++) {
cbValue = (s8)*cb++;
crValue = (s8)*cr++;
value = *luminance++;
green = value + (-(cbValue * 88 + crValue * 183) >> 8);
red = value + ((crValue * 359) >> 8);
blue = value + ((cbValue * 454) >> 8);
if ((blue | red | green) >> 8) {
blue &= ~(blue >> 31);
if (blue > 255) {
blue = 255;
}
green &= ~(green >> 31);
if (green > 255) {
green = 255;
}
red &= ~(red >> 31);
if (red > 255) {
red = 255;
}
}
output[(column & 3) + (((column >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
}
luminance += rowSkip;
cb += rowSkip;
cr += rowSkip;
}
}
static void TMCJPEGDEC_converterYUV400toRGB565(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 value;
u16* output;
s32 tileRow;
u8* texture;
u8* luminance;
s32 column;
s32 xEnd;
s32 green;
s32 blue;
TMCCJPEGDecState* state;
s32 row;
s32 yEnd;
s32 height;
s32 width;
u32 tileWidth;
state = work->pState;
texture = state->pTexBuffer;
luminance = work->convBuf + 4;
tileWidth = state->convWidth >> 2;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
{
xEnd = x + width;
yEnd = y + height;
width = 8 - width;
for (row = y; row < yEnd; row++) {
output = (u16*)(texture + ((row & 3) << 3));
tileRow = (row >> 2) * tileWidth;
for (column = x; column < xEnd; column += 1) {
value = *luminance++;
if (value >> 8) {
blue = value > 255 ? 255 : value < 0 ? 0 : value;
green = value > 255 ? 255 : value < 0 ? 0 : value;
value = value > 255 ? 255 : value < 0 ? 0 : value;
} else {
green = blue = value;
}
output[(column & 3) + (((column >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + (((value & 0xF8) << 8) + ((green & 0xFC) << 3));
}
luminance += width;
}
}
}
static void TMCJPEGDEC_converterYUV400toRGB565edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 value;
u16* output;
s32 tileRow;
u8* texture;
u8* luminance;
s32 column;
s32 xEnd;
s32 green;
s32 blue;
TMCCJPEGDecState* state;
s32 row;
s32 yEnd;
s32 height;
s32 width;
u32 tileWidth;
state = work->pState;
texture = state->pTexBuffer;
luminance = work->convBuf + 4;
tileWidth = state->convWidth >> 2;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 8 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 8 / state->scaleFactor;
}
{
xEnd = x + width;
yEnd = y + height;
width = 8 - width;
for (row = y; row < yEnd; row++) {
output = (u16*)(texture + ((row & 3) << 3));
tileRow = (row >> 2) * tileWidth;
for (column = x; column < xEnd; column += 1) {
value = *luminance++;
if (value >> 8) {
blue = value > 255 ? 255 : value < 0 ? 0 : value;
green = value > 255 ? 255 : value < 0 ? 0 : value;
value = value > 255 ? 255 : value < 0 ? 0 : value;
} else {
green = blue = value;
}
output[(column & 3) + (((column >> 2) + tileRow) << 4)] =
((blue & 0xF8) >> 3) + (((value & 0xF8) << 8) + ((green & 0xFC) << 3));
}
luminance += width;
}
}
}

View File

@@ -1,751 +1,5 @@
#define TMC_JPEG_PLANAR_OUTPUT
#include <tmc_jpeg_internal.h>
static void TMCJPEG_814EFEAC(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F043C(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F0A58(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F11C4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F17E0(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F1F48(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F2570(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F2B50(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F3158(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F32E4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F34A4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F372C(TMCCJPEGDecWork*, s32, s32);
s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
u8* ob;
s32 cc;
TMCCJPEGDecState* st;
ob = (u8*)&work->convBuf;
cc = work->componentCount;
st = work->pState;
switch (cc) {
case 0: {
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
u8 mode = work->idctMode;
u8* ptr = ob + 4;
u8* p1 = ptr + mode;
u8* p2 = p1 + mode;
u8* p3 = p2 + mode;
converter = TMCJPEG_814EFEAC;
edgeConverter = TMCJPEG_814F043C;
work->pConvRowPtrs[0] = (void*)ptr;
work->pConvRowPtrs[1] = (void*)p1;
work->pConvRowPtrs[2] = (void*)p2;
work->pConvRowPtrs[3] = (void*)p3;
work->pConvRowPtrs[5] = (void*)(ob + 0x104);
work->pConvRowPtrs[6] = (void*)(ob + 0x144);
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pitch = 0x20;
work->converterFlags = 0;
break;
}
case 1: {
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
u8 mode = work->idctMode;
u8* ptr = ob + 4;
converter = TMCJPEG_814F0A58;
edgeConverter = TMCJPEG_814F11C4;
work->pConvRowPtrs[0] = (void*)ptr;
work->pConvRowPtrs[1] = (void*)(ptr + mode);
work->pConvRowPtrs[5] = (void*)(ob + 0x84);
work->pConvRowPtrs[6] = (void*)(ob + 0xC4);
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pitch = 0x10;
work->converterFlags = 0;
break;
}
case 2: {
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
u8 mode = work->idctMode;
u8* ptr = ob + 4;
u8* p1 = ptr + mode;
u8* p2 = ptr + mode * 16;
u8* p3 = p2 + mode;
converter = TMCJPEG_814F17E0;
edgeConverter = TMCJPEG_814F1F48;
work->pConvRowPtrs[0] = (void*)ptr;
work->pConvRowPtrs[1] = (void*)p1;
work->pConvRowPtrs[2] = (void*)p2;
work->pConvRowPtrs[3] = (void*)p3;
work->pConvRowPtrs[5] = (void*)(ob + 0x104);
work->pConvRowPtrs[6] = (void*)(ob + 0x144);
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pitch = 0x10;
work->converterFlags = 0;
break;
}
case 3: {
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
u8 mode = work->idctMode;
u8* ptr = ob + 4;
converter = TMCJPEG_814F2570;
edgeConverter = TMCJPEG_814F2B50;
work->pConvRowPtrs[0] = (void*)ptr;
work->pConvRowPtrs[1] = (void*)(ptr + mode * 8);
work->pConvRowPtrs[5] = (void*)(ob + 0x84);
work->pConvRowPtrs[6] = (void*)(ob + 0xC4);
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pitch = 0x08;
work->converterFlags = 0;
break;
}
case 4: {
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
converter = TMCJPEG_814F3158;
edgeConverter = TMCJPEG_814F32E4;
work->pConvRowPtrs[0] = (void*)(ob + 4);
work->pConvRowPtrs[5] = (void*)(ob + 0x44);
work->pConvRowPtrs[6] = (void*)(ob + 0x84);
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pitch = 0x08;
work->converterFlags = 0;
break;
}
case 5: {
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
converter = TMCJPEG_814F34A4;
edgeConverter = TMCJPEG_814F372C;
work->pConvRowPtrs[0] = (void*)(ob + 4);
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pitch = 0x08;
work->converterFlags = 0;
break;
}
default: {
return TMCC_ERROR_FORMAT;
}
}
{
s32 width = st->jpegWidth;
s32 height = st->jpegHeight;
st->convWidth = ((u32)width / 8 + (width % 8 != 0)) * 8;
st->convHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
width = st->outputWidth;
height = st->outputHeight;
st->chromaWidth = ((u32)width / 8 + (width % 8 != 0)) * 8;
st->chromaHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
}
return 0;
}
static void TMCJPEG_814EFEAC(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 column;
u8* luminance = work->convBuf + 4;
s8* cb = (s8*)&work->convBuf[260];
s8* cr = (s8*)&work->convBuf[324];
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 3;
u8* lumaTexture = state->pLumaBuffer;
u8* cbTexture = state->pCbBuffer;
u8* crTexture = state->pCrBuffer;
s32 width, height;
width = 32 / state->scaleFactor;
height = 8 / state->scaleFactor;
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 row;
for (row = y; row < yEnd; row++) {
u32 tileRow = (row >> 2) * tileWidth;
u8* output = lumaTexture + ((row & 3) << 3);
for (column = x; column < xEnd; column += 4) {
output[((column) & 7) + ((((column) >> 3) + tileRow) << 5)] = luminance[0];
output[((column + 1) & 7) + ((((column + 1) >> 3) + tileRow) << 5)] = luminance[1];
output[((column + 2) & 7) + ((((column + 2) >> 3) + tileRow) << 5)] = luminance[2];
output[((column + 3) & 7) + ((((column + 3) >> 3) + tileRow) << 5)] = luminance[3];
luminance += 4;
}
luminance += 32 - width;
}
x = (u32)x >> 2;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
xEnd = x + width;
yEnd = y + height;
tileWidth = state->chromaWidth >> 3;
for (; y < yEnd; y++) {
for (column = x; column < xEnd; column++) {
u32 tileRow = (y >> 2) * tileWidth;
u8* cbOutput = cbTexture + ((y & 3) << 3);
u8* crOutput = crTexture + ((y & 3) << 3);
cbOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cb++ + 128;
crOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cr++ + 128;
}
cb += 8 - width;
cr += 8 - width;
}
}
}
static void TMCJPEG_814F043C(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 column;
u8* luminance = work->convBuf + 4;
s8* cb = (s8*)&work->convBuf[260];
s8* cr = (s8*)&work->convBuf[324];
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 3;
u8* lumaTexture = state->pLumaBuffer;
u8* cbTexture = state->pCbBuffer;
u8* crTexture = state->pCrBuffer;
s32 width, height;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 32 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 8 / state->scaleFactor;
}
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 row;
for (row = y; row < yEnd; row++) {
for (column = x; column < xEnd; column += 1) {
u32 tileRow = (row >> 2) * tileWidth;
u8* output = lumaTexture + ((row & 3) << 3);
output[((column) & 7) + ((((column) >> 3) + tileRow) << 5)] = luminance[0];
luminance += 1;
}
luminance += 32 - width;
}
x = (u32)x >> 2;
width = (width + 3) >> 2;
xEnd = x + width;
yEnd = y + height;
tileWidth = state->chromaWidth >> 3;
for (; y < yEnd; y++) {
for (column = x; column < xEnd; column++) {
u32 tileRow = (y >> 2) * tileWidth;
u8* cbOutput = cbTexture + ((y & 3) << 3);
u8* crOutput = crTexture + ((y & 3) << 3);
cbOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cb++ + 128;
crOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cr++ + 128;
}
cb += 8 - width;
cr += 8 - width;
}
}
}
static void TMCJPEG_814F0A58(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 column;
u8* luminance = work->convBuf + 4;
s8* cb = (s8*)&work->convBuf[132];
s8* cr = (s8*)&work->convBuf[196];
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 3;
u8* lumaTexture = state->pLumaBuffer;
u8* cbTexture = state->pCbBuffer;
u8* crTexture = state->pCrBuffer;
s32 width, height;
width = 16 / state->scaleFactor;
height = 8 / state->scaleFactor;
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 row;
for (row = y; row < yEnd; row++) {
u8* output = lumaTexture + ((row & 3) << 3);
u32 tileRow = (row >> 2) * tileWidth;
for (column = x; column < xEnd; column += 2) {
output[((column) & 7) + ((((column) >> 3) + tileRow) << 5)] = luminance[0];
output[((column + 1) & 7) + ((((column + 1) >> 3) + tileRow) << 5)] = luminance[1];
luminance += 2;
}
luminance += 16 - width;
}
x = (u32)x >> 1;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
xEnd = x + width;
yEnd = y + height;
tileWidth = state->chromaWidth >> 3;
for (; y < yEnd; y++) {
u8* cbOutput = cbTexture + ((y & 3) << 3);
u8* crOutput = crTexture + ((y & 3) << 3);
u32 tileRow = (y >> 2) * tileWidth;
for (column = x; column < xEnd; column++) {
cbOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cb++ + 128;
crOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cr++ + 128;
}
cb += 8 - width;
cr += 8 - width;
}
}
}
static void TMCJPEG_814F11C4(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 column;
u8* luminance = work->convBuf + 4;
s8* cb = (s8*)&work->convBuf[132];
s8* cr = (s8*)&work->convBuf[196];
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 3;
u8* lumaTexture = state->pLumaBuffer;
u8* cbTexture = state->pCbBuffer;
u8* crTexture = state->pCrBuffer;
s32 width, height;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 16 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 8 / state->scaleFactor;
}
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 row;
for (row = y; row < yEnd; row++) {
for (column = x; column < xEnd; column += 1) {
u32 tileRow = (row >> 2) * tileWidth;
u8* output = lumaTexture + ((row & 3) << 3);
output[((column) & 7) + ((((column) >> 3) + tileRow) << 5)] = luminance[0];
luminance += 1;
}
luminance += 16 - width;
}
x = (u32)x >> 1;
width = (width + 1) >> 1;
xEnd = x + width;
yEnd = y + height;
tileWidth = state->chromaWidth >> 3;
for (; y < yEnd; y++) {
for (column = x; column < xEnd; column++) {
u32 tileRow = (y >> 2) * tileWidth;
u8* cbOutput = cbTexture + ((y & 3) << 3);
u8* crOutput = crTexture + ((y & 3) << 3);
cbOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cb++ + 128;
crOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cr++ + 128;
}
cb += 8 - width;
cr += 8 - width;
}
}
}
static void TMCJPEG_814F17E0(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* luminance = work->convBuf + 4;
s8* cb = (s8*)&work->convBuf[260];
s8* cr = (s8*)&work->convBuf[324];
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 3;
u8* lumaTexture = state->pLumaBuffer;
u8* cbTexture = state->pCbBuffer;
u8* crTexture = state->pCrBuffer;
s32 width, height;
width = 16 / state->scaleFactor;
height = 16 / state->scaleFactor;
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 row;
for (row = y; row < yEnd; row++) {
u8* output = lumaTexture + ((row & 3) << 3);
u32 tileRow = (row >> 2) * tileWidth;
s32 column;
for (column = x; column < xEnd; column += 2) {
output[((column) & 7) + ((((column) >> 3) + tileRow) << 5)] = luminance[0];
output[((column + 1) & 7) + ((((column + 1) >> 3) + tileRow) << 5)] = luminance[1];
luminance += 2;
}
luminance += 16 - width;
}
x = (u32)x >> 1;
y = (u32)y >> 1;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
xEnd = x + width;
yEnd = y + height;
tileWidth = state->chromaWidth >> 3;
for (; y < yEnd; y++) {
u8* cbOutput = cbTexture + ((y & 3) << 3);
u8* crOutput = crTexture + ((y & 3) << 3);
u32 tileRow = (y >> 2) * tileWidth;
s32 column;
for (column = x; column < xEnd; column++) {
cbOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cb++ + 128;
crOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cr++ + 128;
}
cb += 8 - width;
cr += 8 - width;
}
}
}
static void TMCJPEG_814F1F48(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 column;
u8* luminance = work->convBuf + 4;
s8* cb = (s8*)&work->convBuf[260];
s8* cr = (s8*)&work->convBuf[324];
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 3;
u8* lumaTexture = state->pLumaBuffer;
u8* cbTexture = state->pCbBuffer;
u8* crTexture = state->pCrBuffer;
s32 width, height;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 16 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 16 / state->scaleFactor;
}
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 row;
for (row = y; row < yEnd; row++) {
for (column = x; column < xEnd; column += 1) {
u32 tileRow = (row >> 2) * tileWidth;
u8* output = lumaTexture + ((row & 3) << 3);
output[((column) & 7) + ((((column) >> 3) + tileRow) << 5)] = luminance[0];
luminance += 1;
}
luminance += 16 - width;
}
x = (u32)x >> 1;
y = (u32)y >> 1;
width = (width + 1) >> 1;
height = (height + 1) >> 1;
xEnd = x + width;
yEnd = y + height;
tileWidth = state->chromaWidth >> 3;
for (; y < yEnd; y++) {
for (column = x; column < xEnd; column++) {
u32 tileRow = (y >> 2) * tileWidth;
u8* cbOutput = cbTexture + ((y & 3) << 3);
u8* crOutput = crTexture + ((y & 3) << 3);
cbOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cb++ + 128;
crOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cr++ + 128;
}
cb += 8 - width;
cr += 8 - width;
}
}
}
static void TMCJPEG_814F2570(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 column;
u8* luminance = work->convBuf + 4;
s8* cb = (s8*)&work->convBuf[132];
s8* cr = (s8*)&work->convBuf[196];
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 3;
u8* lumaTexture = state->pLumaBuffer;
u8* cbTexture = state->pCbBuffer;
u8* crTexture = state->pCrBuffer;
s32 width, height;
width = 8 / state->scaleFactor;
height = 16 / state->scaleFactor;
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 row;
for (row = y; row < yEnd; row++) {
for (column = x; column < xEnd; column += 1) {
u32 tileRow = (row >> 2) * tileWidth;
u8* output = lumaTexture + ((row & 3) << 3);
output[((column) & 7) + ((((column) >> 3) + tileRow) << 5)] = luminance[0];
luminance += 1;
}
luminance += 8 - width;
}
y = (u32)y >> 1;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
xEnd = x + width;
yEnd = y + height;
tileWidth = state->chromaWidth >> 3;
for (; y < yEnd; y++) {
for (column = x; column < xEnd; column++) {
u32 tileRow = (y >> 2) * tileWidth;
u8* cbOutput = cbTexture + ((y & 3) << 3);
u8* crOutput = crTexture + ((y & 3) << 3);
cbOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cb++ + 128;
crOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cr++ + 128;
}
cb += 8 - width;
cr += 8 - width;
}
}
}
static void TMCJPEG_814F2B50(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 column;
u8* luminance = work->convBuf + 4;
s8* cb = (s8*)&work->convBuf[132];
s8* cr = (s8*)&work->convBuf[196];
TMCCJPEGDecState* state = work->pState;
u32 tileWidth = state->convWidth >> 3;
u8* lumaTexture = state->pLumaBuffer;
u8* cbTexture = state->pCbBuffer;
u8* crTexture = state->pCrBuffer;
s32 width, height;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 8 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 16 / state->scaleFactor;
}
{
s32 xEnd = x + width;
s32 yEnd = y + height;
s32 row;
for (row = y; row < yEnd; row++) {
for (column = x; column < xEnd; column += 1) {
u32 tileRow = (row >> 2) * tileWidth;
u8* output = lumaTexture + ((row & 3) << 3);
output[((column) & 7) + ((((column) >> 3) + tileRow) << 5)] = luminance[0];
luminance += 1;
}
luminance += 8 - width;
}
y = (u32)y >> 1;
height = (height + 1) >> 1;
xEnd = x + width;
yEnd = y + height;
tileWidth = state->chromaWidth >> 3;
for (; y < yEnd; y++) {
for (column = x; column < xEnd; column++) {
u32 tileRow = (y >> 2) * tileWidth;
u8* cbOutput = cbTexture + ((y & 3) << 3);
u8* crOutput = crTexture + ((y & 3) << 3);
cbOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cb++ + 128;
crOutput[(column & 7) + (((column >> 3) + tileRow) << 5)] = *cr++ + 128;
}
cb += 8 - width;
cr += 8 - width;
}
}
}
static void TMCJPEG_814F3158(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 rowSkip;
u8* output;
s32 height;
s32 tileRow;
u8* cbOutput;
TMCCJPEGDecState* state;
u8* crOutput;
s32 pixelOffset;
s32 tileOffset;
u8* lumaTexture;
s32 width;
u32 rowOffset;
u8* cbTexture;
u8* crTexture;
u8* luminance;
u8* cb;
u8* cr;
s32 column;
s32 xEnd;
s32 yEnd;
u32 tileWidth;
luminance = work->convBuf + 4;
cb = &work->convBuf[68];
cr = &work->convBuf[132];
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
cbTexture = state->pCbBuffer;
crTexture = state->pCrBuffer;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
xEnd = x + width;
yEnd = y + height;
rowSkip = 8 - width;
for (; y < yEnd; y++) {
tileRow = (y >> 2) * tileWidth;
rowOffset = (y & 3) << 3;
output = lumaTexture + rowOffset;
cbOutput = cbTexture + rowOffset;
crOutput = crTexture + rowOffset;
for (column = x; column < xEnd;) {
tileOffset = ((column >> 3) + tileRow) << 5;
pixelOffset = column++ & 7;
(output + pixelOffset)[tileOffset] = *luminance++;
(cbOutput + pixelOffset)[tileOffset] = *cb++ + 128;
(crOutput + pixelOffset)[tileOffset] = *cr++ + 128;
}
luminance += rowSkip;
cb += rowSkip;
cr += rowSkip;
}
}
static void TMCJPEG_814F32E4(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 rowSkip;
u8* output;
s32 height;
s32 tileRow;
u8* cbOutput;
TMCCJPEGDecState* state;
u8* crOutput;
s32 pixelOffset;
s32 tileOffset;
u8* lumaTexture;
s32 width;
u32 rowOffset;
u8* cbTexture;
u8* crTexture;
u8* luminance;
u8* cb;
u8* cr;
s32 column;
s32 xEnd;
s32 yEnd;
u32 tileWidth;
luminance = work->convBuf + 4;
cb = &work->convBuf[68];
cr = &work->convBuf[132];
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
cbTexture = state->pCbBuffer;
crTexture = state->pCrBuffer;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 8 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 8 / state->scaleFactor;
}
xEnd = x + width;
yEnd = y + height;
rowSkip = 8 - width;
for (; y < yEnd; y++) {
tileRow = (y >> 2) * tileWidth;
rowOffset = (y & 3) << 3;
output = lumaTexture + rowOffset;
cbOutput = cbTexture + rowOffset;
crOutput = crTexture + rowOffset;
for (column = x; column < xEnd;) {
tileOffset = ((column >> 3) + tileRow) << 5;
pixelOffset = column++ & 7;
(output + pixelOffset)[tileOffset] = *luminance++;
(cbOutput + pixelOffset)[tileOffset] = *cb++ + 128;
(crOutput + pixelOffset)[tileOffset] = *cr++ + 128;
}
luminance += rowSkip;
cb += rowSkip;
cr += rowSkip;
}
}
static void TMCJPEG_814F34A4(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 height;
u8* lumaTexture;
u8* luminance;
s32 column;
s32 xEnd;
s32 yEnd;
u8* output;
s32 width;
TMCCJPEGDecState* state;
u32 tileRow;
u32 tileWidth;
s32 tileOffset;
s32 row;
luminance = work->convBuf + 4;
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
{
xEnd = x + width;
yEnd = y + height;
for (row = y; row < yEnd; row++) {
for (column = x; column < xEnd; column += 1) {
tileRow = (row >> 2) * tileWidth;
tileOffset = ((column >> 3) + tileRow) << 5;
output = lumaTexture + ((row & 3) << 3) + (column & 7);
output[tileOffset] = *luminance++;
}
luminance += 8 - width;
}
}
}
static void TMCJPEG_814F372C(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 height;
u8* lumaTexture;
u8* luminance;
s32 column;
s32 xEnd;
s32 yEnd;
u8* output;
s32 width;
TMCCJPEGDecState* state;
u32 tileRow;
u32 tileWidth;
s32 tileOffset;
s32 row;
luminance = work->convBuf + 4;
state = work->pState;
tileWidth = state->convWidth >> 3;
lumaTexture = state->pLumaBuffer;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
} else {
width = 8 / state->scaleFactor;
}
if (state->dataSizeY == (u32)y) {
height = state->stepYExt;
} else {
height = 8 / state->scaleFactor;
}
{
xEnd = x + width;
yEnd = y + height;
for (row = y; row < yEnd; row++) {
for (column = x; column < xEnd; column += 1) {
tileRow = (row >> 2) * tileWidth;
tileOffset = ((column >> 3) + tileRow) << 5;
output = lumaTexture + ((row & 3) << 3) + (column & 7);
output[tileOffset] = *luminance++;
}
luminance += 8 - width;
}
}
}

View File

@@ -130,18 +130,11 @@ typedef struct EZTXGetParam {
wchar_t* candidates; // 0x18
u8 maxCandidates; // 0x1C
wchar_t firstCandidate; // 0x1E
#ifndef TIZISTRING_IMPLEMENTATION
u8 wordCandidates; // 0x1F
#endif
u8 count; // 0x20
u8 letters; // 0x21
#ifdef TIZISTRING_IMPLEMENTATION
u8 completion;
u8* scratch;
#else
u8* scratch; // 0x22
#endif
} EZTXGetParam;
u16 EZTXGetGlobalDataSize();

View File

@@ -1,177 +0,0 @@
#include <zi8clib/zconvert.h>
#include <zi8clib/zierror.h>
typedef struct ziConversionRange {
ziU16 first, last;
union { ziPtr table; ziU32 character; } result;
} ziConversionRange;
typedef struct ziConversionRangeTable {
ziU16 count, flags;
ziConversionRange* entries;
} ziConversionRangeTable;
typedef struct ziConversionTables {
ziU16 first, last;
ziWChar* unicode;
ziConversionRangeTable reverse, keys, cases;
} ziConversionTables;
typedef struct ziConversionEntry {
ziU8 first[2], last[2], flags[2], value[2];
} ziConversionEntry;
typedef struct ziConversionTable {
ziU8 count[2], flags[2], minimum[2], maximum[2];
ziConversionEntry entries[1];
} ziConversionTable;
const ziConversionTables Zi8CvrtTables = {0};
ziU16 Zi8GetTableCount(ziU8, ziU8 ZI_NEED_WORK);
ziPtr Zi8GetTableAddress(ziU8, ziU8 ZI_NEED_WORK);
ziWChar Zi8ConvertUC2UserKey(ziChar, ziU8 ZI_NEED_WORK);
ziWChar Zi8ConvertUC2WC(ziChar character, ziU8 language ZI_NEED_WORK) {
ziU8* table;
ziWChar* mapped;
ziU8* cursor;
ziU16 first, last;
const ziConversionTables* defaults;
if (character == 0) {
Zi8LogError(0x133, __zi8_work_data);
return 0;
}
if (Zi8GetTableCount(language, 6, __zi8_work_data) != 0) {
table = Zi8GetTableAddress(language, 6, __zi8_work_data);
if (table == 0) {
Zi8LogError(0x6A4, __zi8_work_data);
return 0;
}
cursor = table;
first = (ziU16)cursor[0] << 8 | cursor[1];
last = (ziU16)cursor[2] << 8 | cursor[3];
if (character < first || character > last) {
Zi8LogError(0x132, __zi8_work_data);
return 0;
}
cursor += (character - first) * 2 + 8;
Zi8LogError(100, __zi8_work_data);
return (ziU16)cursor[0] << 8 | cursor[1];
}
defaults = &Zi8CvrtTables;
if (defaults == 0) {
Zi8LogError(0x6A4, __zi8_work_data);
return 0;
}
if (character < defaults->first || character > defaults->last) {
Zi8LogError(0x132, __zi8_work_data);
return 0;
}
mapped = defaults->unicode;
Zi8LogError(100, __zi8_work_data);
return mapped[character - defaults->first];
}
ziChar Zi8ConvertWC2UC(ziWChar character, ziU8 language ZI_NEED_WORK) {
ziU16 index, count, first, last, value;
ziConversionTable* table;
const ziConversionRangeTable* defaults;
ziConversionRange* ranges;
ziConversionEntry* entry;
ziU8* cursor;
if (character == 0) {
Zi8LogError(0x133, __zi8_work_data);
return 0;
}
if (Zi8GetTableCount(language, 7, __zi8_work_data) != 0) {
table = Zi8GetTableAddress(language, 7, __zi8_work_data);
if (table == 0) {
Zi8LogError(0x6AE, __zi8_work_data);
return 0;
}
entry = table->entries;
count = (ziU16)table->count[0] << 8 | table->count[1];
for (index = 0; index < count; index++) {
first = ((ziU16)entry->first[0] << 8 | entry->first[1]);
last = (ziU16)entry->last[0] << 8 | entry->last[1];
if (first <= character && character <= last) {
value = ((ziU16)entry->value[0] << 8 | entry->value[1]);
if (first == last) {
Zi8LogError(100, __zi8_work_data);
return value & 0xFF;
}
Zi8LogError(100, __zi8_work_data);
return ((ziU8*)table->entries)[character + value - first];
}
entry++;
}
} else {
defaults = &Zi8CvrtTables.reverse;
if (defaults == 0) {
Zi8LogError(0x6AE, __zi8_work_data);
return 0;
}
ranges = defaults->entries;
for (index = 0; index < defaults->count; index++) {
if (ranges[index].first <= character && character <= ranges[index].last) {
Zi8LogError(100, __zi8_work_data);
if (ranges[index].first == ranges[index].last) return ranges[index].result.character & 0xFF;
return ((ziU8*)ranges[index].result.table)[character - ranges[index].first];
}
}
}
Zi8LogError(0x6C2, __zi8_work_data);
return 0;
}
ziWChar Zi8ConvertUC2Key(ziChar character, ziU8 language ZI_NEED_WORK) {
ziU16 count, index, first, last;
ziU32 key = 0;
ziConversionTable* table;
const ziConversionRangeTable* defaults;
ziConversionRange* ranges;
ziConversionEntry* entry;
ziU8* cursor;
if (character == 0) {
Zi8LogError(0x133, __zi8_work_data);
return 0;
}
if (ZI_WORK->userKeys[language] != 0) return Zi8ConvertUC2UserKey(character, language, __zi8_work_data);
if (Zi8GetTableCount(language, 8, __zi8_work_data) != 0) {
table = Zi8GetTableAddress(language, 8, __zi8_work_data);
if (table == 0) {
Zi8LogError(0x6B8, __zi8_work_data);
return 0;
}
entry = table->entries;
count = (ziU16)table->count[0] << 8 | table->count[1];
for (index = 0; index < count; index++) {
first = ((ziU16)entry->first[0] << 8 | entry->first[1]);
last = (ziU16)entry->last[0] << 8 | entry->last[1];
if (first <= character && character <= last) {
key = ((ziU16)entry->value[0] << 8 | entry->value[1]);
if (first != last) {
cursor = (ziU8*)table->entries + key + (character - first) * 2;
key = (ziU16)cursor[0] << 8 | cursor[1];
}
break;
}
entry++;
}
} else {
defaults = &Zi8CvrtTables.keys;
if (defaults == 0) {
Zi8LogError(0x6B8, __zi8_work_data);
return 0;
}
ranges = defaults->entries;
for (index = 0; index < defaults->count; index++) {
if (ranges[index].first <= character && character <= ranges[index].last) {
if (ranges[index].first == ranges[index].last) key = ranges[index].result.character & 0xFF;
else key = ((ziWChar*)ranges[index].result.table)[character - ranges[index].first];
break;
}
}
}
if (key == 0) {
Zi8LogError(0x6C2, __zi8_work_data);
key = 0xEFF1;
} else Zi8LogError(100, __zi8_work_data);
return key;
}
ziWChar Zi8ConvertWC2Key(ziWChar character, ziU8 language ZI_NEED_WORK) {
return Zi8ConvertUC2Key(Zi8ConvertWC2UC(character, language, __zi8_work_data), language, __zi8_work_data);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,386 +0,0 @@
#include <zi8clib/zitypes.h>
#include <zi8clib/zierror.h>
#include <zi8clib/zconvert.h>
ziU32 Zi8GetTableSize(ziU8 language, ziU8 table, ziPtr work);
ziU32 Zi8GetTableAddress(ziU8 language, ziU8 table, ziPtr work);
ziU16 Zi8GetTableCount(ziU8 language, ziU8 table, ziPtr work);
ziU8* ZiDAWGGetGraph(zi8DawgCtx* context);
ziU8* ZiDAWGGetGraphInfo(zi8DawgCtx* context, ziU8* table, ziS16* keys);
ziU32 ZiDAWGgetCHARattribute(zi8DawgCtx* context, ziU8* graph, ziPtr work);
ziU8 ZiDAWGgetEOWattribute(ziU8* graph);
ziU8* ZiDAWGGetChild(ziU8* graph);
ziU8* ZiDAWGGetSibling(ziU8* graph);
ziU32 Zi8MatchROMdata0(ziWChar* elements, ziU8 count, ziU8 language,
ziWChar* output, ziU16 capacity, ziU8 mode, ziU8 status,
ziU8 graphTable, ziU8 keyTable, ziU8 acceptPrefix,
ziU8* prefixLength, zi8DawgCtx* context, ziU8* search,
ziPtr __zi8_work_data) {
ziU8 result = 0;
ziU8* graphData;
ziU8* keyData;
ziS32 keyCount;
ziS32 convertedKey;
ziU16 searching;
ziU16 key;
ziU16 keys[3];
ziU16 index;
zi8DawgRec* current;
zi8DawgRec* records = context->recs;
if (language != context->lang || graphTable != context->key) records[0].key = 0;
if (count == 1 && mode != 0 && graphTable == 0xe) goto finish_graph;
if (status != 0) {
if (records[context->cnt - 1].node == (ziU8*)context->unk_0x338) goto finish_graph;
for (index = 0; index < count; index++) {
if (records[index].key != elements[index] &&
(ziU16)records[index].attr != elements[index]) goto finish_graph;
}
if (mode == 1) acceptPrefix = 0;
} else {
if (ZI_WORK->unk_0x141E != 0 && graphTable == 0xc &&
Zi8GetTableSize(language, ZI_WORK->unk_0x141E, ZI_WORK) != 0) {
graphData = (ziU8*)Zi8GetTableAddress(language, ZI_WORK->unk_0x141E, ZI_WORK);
keyTable = ZI_WORK->unk_0x141E + 1;
} else {
if (Zi8GetTableSize(language, graphTable, ZI_WORK) == 0) {
Zi8LogError(0x961, ZI_WORK);
goto finish_graph;
}
graphData = (ziU8*)Zi8GetTableAddress(language, graphTable, ZI_WORK);
}
context->table = graphData;
context->cap = (((ziU16)context->table[2] << 8) + context->table[3]) / 3;
context->p08 = context->table + 4;
context->p0C = context->table + context->cap * 2 + 4;
context->lang = language;
context->key = graphTable;
index = 0;
while (index < count && records[index].key == elements[index]) index++;
if (index >= 2) {
records[0].node = records[index - 1].back;
} else {
key = Zi8GetTableSize(language, keyTable, ZI_WORK);
if (key != 0 && ZI_WORK->userKeys[language] == 0) {
index = 0;
goto check_keys;
next_key:
{
keys[index] = Zi8ConvertWC2Key(elements[index], language, ZI_WORK);
if (keys[index] == 0) keys[index] = elements[index];
index++;
}
check_keys:
if (count < 2) keyCount = count;
else keyCount = 2;
if (index < keyCount) goto next_key;
keys[index] = 0;
keyData = (ziU8*)Zi8GetTableAddress(language, keyTable, ZI_WORK);
context->p14 = keyData + 2;
keyData += context->cap * 2 + 2;
records[0].node = ZiDAWGGetGraphInfo(context, keyData, (ziS16*)keys);
} else {
records[0].node = ZiDAWGGetGraph(context);
context->unk_0x338 = 0;
context->p14 = 0;
}
records[0].key = 0;
if (records[0].node == (ziU8*)0) goto finish_graph;
}
context->cnt = 1;
search[1] = count;
search[0] = 0;
if (mode == 1) {
search[0] = 1;
acceptPrefix = 0;
} else if (mode == 0 && acceptPrefix == 0) search[1]++;
}
searching = 1;
current = &records[context->cnt - 1];
while (searching && context->cnt != 0 && current->node != (ziU8*)context->unk_0x338) {
if (capacity < context->cnt) goto finish_graph;
current->attr = ZiDAWGgetCHARattribute(context, current->node, ZI_WORK);
if (context->cnt <= count) {
if (context->p14 == 0) {
convertedKey = Zi8ConvertWC2Key((ziU16)current->attr, language, ZI_WORK);
} else {
convertedKey = ((ziU16)context->p14[(current->attr >> 24) * 2] << 8) +
(context->p14 + (current->attr >> 24) * 2)[1];
}
key = convertedKey;
if (key != elements[context->cnt - 1] &&
(ziU16)current->attr != elements[context->cnt - 1]) goto next_sibling;
if (current->key != elements[context->cnt - 1]) {
current->key = elements[context->cnt - 1];
current->back = records[0].node;
records[context->cnt].key = 0;
}
if (prefixLength != 0 && *prefixLength < context->cnt &&
ZiDAWGgetEOWattribute(current->node) != 0) {
*prefixLength = context->cnt;
for (index = 0; index < context->cnt; index++) output[index] = (ziU16)records[index].attr;
}
if (context->cnt < count) goto descend;
}
if (context->cnt < search[1]) goto descend;
if (search[0] != 0 && context->cnt > search[1]) goto next_sibling;
if (acceptPrefix != 0 || ZiDAWGgetEOWattribute(current->node) != 0) {
for (index = 0; index < context->cnt; index++) output[index] = (ziU16)records[index].attr;
result = context->cnt;
searching = 0;
if (acceptPrefix != 0) goto next_sibling;
}
if (search[0] != 0 && context->cnt >= search[1]) goto next_sibling;
descend:
records[context->cnt].node = ZiDAWGGetChild(records[context->cnt - 1].node);
if (records[context->cnt].node == (ziU8*)0) goto next_sibling;
context->cnt++;
if (ZI_WORK->unk_0x141F < context->cnt) ZI_WORK->unk_0x141F = context->cnt;
goto update_current;
next_sibling:
while (context->cnt != 0) {
records[context->cnt - 1].node = ZiDAWGGetSibling(records[context->cnt - 1].node);
if (records[context->cnt - 1].node != (ziU8*)0) break;
context->cnt--;
}
update_current:
current = &records[context->cnt - 1];
}
finish_graph:
return result;
}
ziU8* NextDawgGroup(ziU8* group, ziU8 language, ziPtr __zi8_work_data)
{
if (Zi8GetTableSize(language,0x1c,ZI_WORK) != 0) {
if (group == 0) {
group = (ziU8*)Zi8GetTableAddress(language,0x1c,ZI_WORK);
if (group == 0) {
Zi8LogError(0x962,ZI_WORK);
return 0;
}
if (ZI_WORK->unk_0x141D == 0) {
return group;
}
}
while (group[0] != 0xff || group[1] != 0xff) {
group = group + 1;
}
group = group + 2;
if (group[0] == 0xff) {
Zi8LogError(0x963,ZI_WORK);
return 0;
}
return group;
}
Zi8LogError(0x961,ZI_WORK);
return 0;
}
unsigned int Zi8MatchROMdata1(ziWChar *elements, ziU8 count, ziU8 language, ziWChar *output, ziU16 capacity, ziU8 mode, ziU8 status, ziU32 groupIndex, char *group, ziU8 acceptPrefix, ziPtr __zi8_work_data)
{
unsigned int result;
ziU32 tableAddress;
result = 0;
if (status == 0) {
ZI_WORK->unk_0x1764 = (ziU8*)group;
if (ZI_WORK->unk_0x1764 == 0) {
if (Zi8GetTableSize(language & 0xff,0xb,ZI_WORK) != 0) {
tableAddress = Zi8GetTableAddress(language & 0xff,0xb,ZI_WORK);
ZI_WORK->unk_0x1764 = (ziU8*)tableAddress;
}
}
if (ZI_WORK->unk_0x1764 != 0) {
for (; (*ZI_WORK->unk_0x1764 != 0xff && ((groupIndex & 0xff) != 0));
groupIndex = groupIndex - 1) {
while (*ZI_WORK->unk_0x1764 != 0xff) {
ZI_WORK->unk_0x1764 += 2;
}
ZI_WORK->unk_0x1764++;
}
}
}
if (ZI_WORK->unk_0x1764 == 0) {
result = Zi8MatchROMdata0(elements,count,language & 0xff,output,capacity & 0xffff,
mode & 0xff,status & 0xff,0,1,acceptPrefix,0,&ZI_WORK->dawgCtx,
ZI_WORK->unk_0x1760,ZI_WORK);
}
else {
while (*ZI_WORK->unk_0x1764 != 0xff) {
result = Zi8MatchROMdata0(elements,count,language & 0xff,output,
capacity & 0xffff,mode & 0xff,status & 0xff,
*ZI_WORK->unk_0x1764,
ZI_WORK->unk_0x1764[1],acceptPrefix,0,
&ZI_WORK->dawgCtx,ZI_WORK->unk_0x1760,ZI_WORK);
if ((result & 0xff) != 0) break;
ZI_WORK->unk_0x1764 += 2;
status = 0;
}
}
return result;
}
unsigned int Zi8MatchROMdata2(ziWChar* elements, ziU8 count, ziU8 language,
ziWChar* output, ziU16 capacity, ziU8 mode,
ziU8 status, ziU8 reservedMode, ziU8* group,
ziU8 acceptPrefix, ziPtr __zi8_work_data) {
unsigned int result = 0;
ziU8 index;
if (reservedMode != 0) return 0;
if (status == 0) {
ZI_WORK->unk_0x1768 = 0;
ZI_WORK->unk_0x17EA = 0;
if (group != 0 && *group == 0xc && language == 10 && ZI_WORK->unk_0x141C != 0) {
ZI_WORK->unk_0x141E = 0x10;
} else {
ZI_WORK->unk_0x141E = 0;
}
}
search_segment:
ZI_WORK->unk_0x141F = 1;
result = Zi8MatchROMdata1(elements + ZI_WORK->unk_0x17EA,
count - ZI_WORK->unk_0x17EA, language,
&ZI_WORK->unk_0x17F4[ZI_WORK->unk_0x17EA], capacity,
mode, status, ZI_WORK->unk_0x1768, (char*)group,
acceptPrefix, ZI_WORK);
if ((ziU8)result != 0) {
for (index = (ziU8)(ZI_WORK->unk_0x17EA + result); index != 0; index--) {
output[index - 1] = ZI_WORK->unk_0x17F4[index - 1];
}
result = (ziU8)(result + ZI_WORK->unk_0x17EA);
} else {
if (status != 0 || count == 1) goto finish_segments;
if (mode == 1 && ZI_WORK->unk_0x1768 == 0 &&
(ziU8)Zi8MatchROMdata1(elements + ZI_WORK->unk_0x17EA,
count - ZI_WORK->unk_0x17EA, language,
&ZI_WORK->unk_0x17F4[ZI_WORK->unk_0x17EA], capacity,
0, status, ZI_WORK->unk_0x1768, (char*)group,
acceptPrefix, ZI_WORK) != 0) goto finish_segments;
if ((Zi8GetTableCount(language, 0x1f, ZI_WORK) & 4) == 0) {
for (index = 0; index < count; index++) {
if (elements[index] == 0xeff1) goto finish_segments;
}
}
if (ZI_WORK->unk_0x141F > capacity) goto finish_segments;
for (index = ZI_WORK->unk_0x141F; index != 0; index--) {
result = Zi8MatchROMdata1(elements + ZI_WORK->unk_0x17EA, index, language,
&ZI_WORK->unk_0x17F4[ZI_WORK->unk_0x17EA], capacity,
1, 0, ZI_WORK->unk_0x1768, (char*)group,
acceptPrefix, ZI_WORK);
if ((ziU8)result != 0) {
ZI_WORK->unk_0x17EA += (ziU8)result;
if (ZI_WORK->unk_0x17EA == count) return 0;
ZI_WORK->unk_0x1768++;
status = 0;
ZI_WORK->unk_0x141E = 0;
if (ZI_WORK->dawgCtx.key == 0 && language == 10) {
for (index = 0; index < ZI_WORK->unk_0x17EA; index++) {
switch (ZI_WORK->unk_0x17F4[index]) {
case 0x61:
case 0x6f:
case 0x75:
ZI_WORK->unk_0x141E = 0x10;
goto search_segment;
}
}
}
goto search_segment;
}
}
}
finish_segments:
return result;
}
ziU32 Zi8MatchROMdata(ziWChar* elements, ziU8 count, ziU8 language,
ziWChar* output, ziU16 capacity, ziU8 mode, ziU8 status,
ziU8 reservedMode, ziU8 acceptPrefix, ziPtr __zi8_work_data) {
ziU32 result = 0;
ziS32 tableSize = 0;
if (capacity < count) {
Zi8LogError(0x321, ZI_WORK);
} else if (status == 2) {
Zi8LogError(100, ZI_WORK);
} else {
if (status == 0) {
ZI_WORK->unk_0x17EC = 0;
ZI_WORK->unk_0x17F0 = NextDawgGroup(0, language, ZI_WORK);
} else if (ZI_WORK->unk_0x17EC != 0) {
Zi8LogError(100, ZI_WORK);
goto finish_match;
}
tableSize = Zi8GetTableSize(language, 0x1c, ZI_WORK);
if (tableSize == 0) {
result = Zi8MatchROMdata2(elements, count, language, output, capacity,
mode, status, reservedMode, 0, acceptPrefix, ZI_WORK);
} else {
while (ZI_WORK->unk_0x17F0 != 0) {
result = Zi8MatchROMdata2(elements, count, language, output, capacity,
mode, status, reservedMode, ZI_WORK->unk_0x17F0,
acceptPrefix, ZI_WORK);
if ((ziU8)result != 0) break;
status = 0;
if (count <= 1 && language == 0x36) break;
ZI_WORK->unk_0x17F0 = NextDawgGroup(ZI_WORK->unk_0x17F0, language, ZI_WORK);
}
}
if ((ziU8)result == 0 && status == 0 && mode == 1 && count == 1 && capacity >= 1) {
mode = 0;
ZI_WORK->unk_0x17EC = 1;
if (tableSize != 0) {
ZI_WORK->unk_0x17F0 = NextDawgGroup(0, language, ZI_WORK);
while (ZI_WORK->unk_0x17F0 != 0) {
if ((ziU8)Zi8MatchROMdata2(elements, count, language, output, capacity,
mode, status, reservedMode, ZI_WORK->unk_0x17F0,
acceptPrefix, ZI_WORK) != 0) {
*output = *elements;
result = 1;
break;
}
ZI_WORK->unk_0x17F0 = NextDawgGroup(ZI_WORK->unk_0x17F0, language, ZI_WORK);
}
} else {
if ((ziU8)Zi8MatchROMdata2(elements, count, language, output, capacity,
mode, status, reservedMode, 0, acceptPrefix, ZI_WORK) != 0) {
*output = *elements;
result = 1;
}
}
}
Zi8LogError(100, ZI_WORK);
}
finish_match:
return result;
}
void Zi8SyllablesROMdata(ziWChar *elements, ziU8 count, ziU8 language, ziWChar *output, ziU16 capacity, ziU8 status, ziU8* prefixLength, ziU8 reverseOrder, ziPtr __zi8_work_data)
{
ziU32 keyTable;
ziU8 graphTable;
graphTable = 0x1a;
keyTable = 0x1b;
if (prefixLength != 0) {
*prefixLength = 0;
}
if (reverseOrder != 0) {
graphTable = 0x18;
keyTable = 0x19;
}
if (Zi8GetTableSize(language & 0xff,graphTable,ZI_WORK) == 0) {
if (graphTable == 0x1a) {
graphTable = 0x18;
keyTable = 0x19;
}
else {
graphTable = 0x1a;
keyTable = 0x1b;
}
}
Zi8MatchROMdata0(elements,count,language & 0xff,output,capacity,1,status,graphTable,keyTable,0,(ziU8 *)prefixLength,
&ZI_WORK->dawgCtx,ZI_WORK->unk_0x1760,ZI_WORK);
return;
}

View File

@@ -1,716 +0,0 @@
#include <zi8clib/zitypes.h>
#include <zi8clib/zierror.h>
#include <zi8clib/zi8getc2.h>
typedef struct {
ziU8 countOnly;
ziU8 maxWordLength;
ziU8 lookupMode;
ziU8 suffixOnly;
ziU8 controls[8];
ziU32 maxCount;
ziU16 capacity;
ziU8 minWordLength;
ziU8 flags;
ziU16 candidateCapacity;
ziU8 checkOnly;
ziU8 reserved;
} ZiCandidateOptions;
const ziU8 Zi8SOdefaultArray[16] = {1, 4, 3, 2, 1, 8, 7, 6, 5, 0};
const ziFuzzyPYPairs Zi8PYdefaultFuzzyPairs = {0, 1, 1, 1, 1, 1, 1};
const ziFuzzyZYPairs Zi8ZYdefaultFuzzyPairs = {0};
ziU8 Zi8GetFormatVersion(ziU8 language, ziPtr work);
ziU32 Zi8GetTableAddress(ziU8 language, ziU8 table, ziPtr work);
ziU16 Zi8GetTableCount(ziU8 language, ziU8 table, ziPtr work);
ziU16 Zi8GetVersion(ziPtr work);
ziU16 Zi8GetOEMID(ziPtr work);
ziU16 Zi8GetBuildID(ziPtr work);
void Zi8Memcpy(ziU8* destination, ziU8* source, ziS32 count);
ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* options, ziPtr work);
ziBool Zi8ZHsetPYfuzzyPairs(ziFuzzyPYPairs pairs ZI_NEED_WORK) {
if (pairs.ziDefault) {
ZI_WORK->unk_0x1B28.word = *(const ziU32*)&Zi8PYdefaultFuzzyPairs;
} else {
ZI_WORK->unk_0x1B28.word = *(ziU32*)&pairs;
}
return 1;
}
ziBool Zi8ZHsetZYfuzzyPairs(ziFuzzyZYPairs pairs ZI_NEED_WORK) {
if (pairs.ziDefault) {
ZI_WORK->unk_0x1B2C.word = *(const ziU32*)&Zi8ZYdefaultFuzzyPairs;
} else {
ZI_WORK->unk_0x1B2C.word = *(ziU32*)&pairs;
}
return 1;
}
ziBool Zi8SetLatinSearchOrder(ziU8* searchArray, ziU8 searchSize ZI_NEED_WORK) {
if (searchArray == 0 || *searchArray == 0) {
ZI_WORK->unk_0x1410 = (ziU32)Zi8SOdefaultArray;
ZI_WORK->unk_0x1418 = 9;
} else {
ZI_WORK->unk_0x1410 = (ziU32)searchArray;
ZI_WORK->unk_0x1418 = searchSize;
}
return 1;
}
ziU16 Zi8GetGlobalDataSize(void) {
return sizeof(struct __zi8_work_data_s);
}
static ziU16 Zi8GetDataSignature(ziU8* destination, ziU16 capacity, ziU8 language, ziPtr work) {
ziU8* signature;
ziU16 length;
if (language == 1) {
if (Zi8GetFormatVersion(1, work) < 8) {
Zi8LogError(0x26f, work);
return 0;
}
length = 0x1e;
} else {
length = 3;
}
signature = (ziU8*)Zi8GetTableAddress(language, (ziU8)length, work);
length = Zi8GetTableCount(language, (ziU8)length, work);
if (length == 0 || length > capacity) {
Zi8LogError(0x961, work);
return 0;
}
Zi8Memcpy(destination, signature, length);
destination[length] = 0;
Zi8LogError(100, work);
return length;
}
static ziU16 Zi8GetEngineSignature(ziU8* destination, ziPtr work) {
ziU16 index = 0;
struct { ziU16 minor; } version;
ziU16 number;
destination[index++] = 'v';
number = (Zi8GetVersion(work) & 0xff00) >> 8;
version.minor = Zi8GetVersion(work) & 0xff;
destination[index++] = (ziU8)(number / 10 + '0');
destination[index++] = (ziU8)(number % 10 + '0');
destination[index++] = (ziU8)(version.minor / 10 + '0');
destination[index++] = (ziU8)(version.minor % 10 + '0');
destination[index++] = 'o';
number = Zi8GetOEMID(work);
destination[index++] = (ziU8)(number / 100 + '0');
destination[index++] = (ziU8)((number % 100) / 10 + '0');
destination[index++] = (ziU8)((number % 100) % 10 + '0');
destination[index++] = 'b';
number = Zi8GetBuildID(work);
destination[index++] = (ziU8)(number / 100 + '0');
destination[index++] = (ziU8)((number % 100) / 10 + '0');
destination[index++] = (ziU8)((number % 100) % 10 + '0');
destination[index] = 0;
return index;
}
static ziBool Zi8AlphaSignature(ziGetParam* parameters, ziBool countOnly ZI_NEED_WORK) {
ziU16 secondLength;
struct { ziU16 length; ziU8* second; ziU8* first; } signatures;
ziU8 dictionary[32];
ziU8 engine[32];
ziU16 length;
ziU8* current;
ziWChar* output = parameters->candidates;
signatures.first = 0;
signatures.second = 0;
signatures.length = 0;
secondLength = 0;
Zi8LogError(100, ZI_WORK);
parameters->letters = 0;
length = Zi8GetDataSignature(dictionary, 0x20, parameters->language, ZI_WORK);
if (length != 0 && parameters->elementCount <= length) {
signatures.first = dictionary;
signatures.second = engine;
signatures.length = length;
} else {
signatures.first = engine;
}
length = Zi8GetEngineSignature(engine, ZI_WORK);
if (length < parameters->elementCount) {
if (signatures.length != 0) {
signatures.second = 0;
length = 1;
} else {
Zi8ReplaceLastError(500, ZI_WORK);
return 0;
}
} else if (signatures.length != 0) {
secondLength = length;
length = 2;
} else {
signatures.length = length;
length = 1;
}
if (parameters->firstCandidate >= length) {
Zi8ReplaceLastError(501, ZI_WORK);
return 0;
}
length = length - parameters->firstCandidate;
if (countOnly != 0) {
parameters->letters = length;
ZI_WORK->unk_0x0A = 0xff;
return 1;
}
if (parameters->maxCandidates < length) length = parameters->maxCandidates;
parameters->letters = length;
if ((parameters->getOptions & 0x80) == 0) {
ZI_WORK->unk_0x538 = parameters->language;
parameters->candidates[0] = 0xfff0;
output = (ziWChar*)&ZI_WORK->unk_0x338;
}
if (parameters->firstCandidate != 0) {
current = signatures.second;
length = secondLength;
} else {
current = signatures.first;
length = signatures.length;
}
if (length > ZI_WORK->unk_0x0A) length = ZI_WORK->unk_0x0A;
if ((parameters->elementCount < ZI_WORK->unk_0x140C[0] ||
(parameters->getOptions & 0x7e) == 2) && length > parameters->elementCount) {
length = parameters->elementCount;
}
while (length-- != 0) *output++ = (ziU8)*current++;
*output++ = 0;
if (parameters->letters == 2) {
current = signatures.second;
length = secondLength;
if (length > ZI_WORK->unk_0x0A) length = ZI_WORK->unk_0x0A;
if ((parameters->elementCount < ZI_WORK->unk_0x140C[0] ||
(parameters->getOptions & 0x7e) == 2) && length > parameters->elementCount) {
length = parameters->elementCount;
}
while (length-- != 0) *output++ = (ziU8)*current++;
*output++ = 0;
}
*output++ = 0;
ZI_WORK->unk_0x0A = 0xff;
return 1;
}
static ziBool Zi8ZhSignature(ziGetParam* parameters, ziBool countOnly ZI_NEED_WORK) {
ziWChar* output = parameters->candidates;
ziU8* current = 0;
ziU16 copied;
ziU8 dictionary[32];
ziU8 engine[32];
ziU16 dataLength;
ziU16 engineLength;
ziU16 length;
Zi8LogError(100, ZI_WORK);
parameters->letters = 0;
dataLength = Zi8GetDataSignature(dictionary, 0x20, parameters->language, ZI_WORK);
engineLength = Zi8GetEngineSignature(engine, ZI_WORK);
if ((parameters->context & 0x10) != 0) {
length = 0;
if (dataLength != 0) length++;
if (engineLength != 0) length++;
} else {
length = dataLength + engineLength;
}
if (parameters->firstCandidate >= length) {
Zi8ReplaceLastError(502, ZI_WORK);
return 0;
}
length = length - parameters->firstCandidate;
if (countOnly != 0) {
parameters->letters = length;
ZI_WORK->unk_0x0A = 0xff;
return 1;
}
if (parameters->maxCandidates < length) length = parameters->maxCandidates;
parameters->letters = length;
if ((parameters->context & 0x10) != 0) {
if (parameters->firstCandidate != 0 || dataLength == 0) {
if (parameters->firstCandidate != 0 && dataLength == 0) {
Zi8ReplaceLastError(500, ZI_WORK);
return 0;
}
current = engine;
length = engineLength;
} else {
current = dictionary;
length = dataLength;
}
while (length-- != 0) *output++ = (ziU8)*current++;
*output++ = 0x20;
if (parameters->letters == 2) {
current = engine;
length = engineLength;
while (length-- != 0) *output++ = (ziU8)*current++;
*output++ = 0x20;
}
} else {
copied = 0;
if (dataLength != 0) {
if (parameters->firstCandidate >= dataLength) {
length = 0;
} else {
length = dataLength - parameters->firstCandidate;
current = dictionary + parameters->firstCandidate;
}
if (parameters->letters < length) length = parameters->letters;
copied = length;
while (length-- != 0) *output++ = (ziU8)*current++;
}
current = engine;
if (parameters->firstCandidate >= dataLength) {
length = dataLength + (engineLength - parameters->firstCandidate);
current += engineLength - length;
} else {
length = engineLength;
}
if (parameters->letters - copied < length) length = parameters->letters - copied;
while (length-- != 0) *output++ = (ziU8)*current++;
}
return 1;
}
ziU8 _Zi8GetCandidates(ziGetParam* parameters ZI_NEED_WORK) {
ZiCandidateOptions options = {0};
options.capacity = ZI_WORK->unk_0x141A;
return Zi8GetCandidatesOrCount(parameters, &options, ZI_WORK);
}
ziU8 _Zi8CheckCandidates(ziGetParam* parameters ZI_NEED_WORK) {
ZiCandidateOptions options = {0};
options.capacity = ZI_WORK->unk_0x141A;
options.flags = 1;
return Zi8GetCandidatesOrCount(parameters, &options, ZI_WORK);
}
ziU8 Zi8LangSupported(ziU8 language, ziPtr work);
ziBool Zi8IsCharacter(ziWChar character, ziPtr work);
ziU8 Zi8GetCharInfo(ziWChar character, ziWChar* output, ziU8 capacity, ziU8 type, ziPtr work);
ziU32 Zi8GetKOcandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8GetKoreanCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8Punctuation(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8GetChineseCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8Get1KeyPressCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8Get1KeyPressSpelling(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8GetSyllablesCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* options ZI_NEED_WORK) {
ziU16 characterInfo[16];
struct {
ziU8 savedGetMode;
ziU8 savedElementCount;
ziU8 convertedElementCount;
ziBool restoreCandidates;
ziU8 savedOptions;
ziU16 savedCharacter;
ziU16 lastInfoCharacter;
ziWChar* savedElements;
ziWChar* savedCandidates;
} saved;
ziU8 outputIndex;
ziU16 error;
unsigned int candidateCount;
error = 0;
saved.savedOptions = 0;
saved.savedCandidates = 0;
saved.restoreCandidates = 0;
if (options->lookupMode == '\0') {
if (((ZI_WORK->unk_0x00 == '\t') && (parameters->elementCount != 0)) &&
(((parameters->elements[parameters->elementCount - 1] == 0xEFF8 &&
((ziU8)Zi8AlphaSignature(parameters,options->countOnly,ZI_WORK) != 0)) ||
((parameters->elements[parameters->elementCount - 1] == 0xEF04 &&
((ziU8)Zi8ZhSignature(parameters,options->countOnly,ZI_WORK) != 0)))))) {
candidateCount = (unsigned int)parameters->letters;
if (options->countOnly != '\0') {
parameters->letters = 0;
}
Zi8LogError(100,ZI_WORK);
return candidateCount;
}
if ((parameters->elementCount == 1) && (parameters->firstCandidate == 0)) {
switch (parameters->language) {
case 1:
if ((ZI_WORK->unk_0x00 == '\0') || (ZI_WORK->unk_0x01 == options->countOnly)) {
switch(ZI_WORK->unk_0x00) {
case '\0':
if (parameters->elements[0] == 0xEF04) {
ZI_WORK->unk_0x01 = options->countOnly;
ZI_WORK->unk_0x00 = '\x01';
}
break;
case '\x02':
case '\x04':
case '\x06':
if (parameters->elements[0] == 0xEF04) {
++ZI_WORK->unk_0x00;
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\x01':
case '\x03':
case '\x05':
case '\a':
if (parameters->elements[0] == 0xEF01) {
++ZI_WORK->unk_0x00;
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\b':
case '\t':
if ((parameters->elements[0] == 0xEF04) &&
((ziU8)Zi8ZhSignature(parameters,options->countOnly,ZI_WORK) != 0)) {
ZI_WORK->unk_0x00 = '\t';
candidateCount = (unsigned int)parameters->letters;
if (options->countOnly != '\0') {
parameters->letters = 0;
}
Zi8LogError(100,ZI_WORK);
return candidateCount;
}
default:
ZI_WORK->unk_0x00 = '\0';
}
if ((ZI_WORK->unk_0x00 == '\0') && (parameters->elements[0] == 0xEF04)) {
ZI_WORK->unk_0x00 = '\x01';
}
}
break;
case 0x10:
case 0x12:
case 0x77:
case 0x78:
case 0x79:
case 0x7A:
case 0x7B:
case 0x7C:
case 0x7D:
break;
case 0x11:
default:
if ((ZI_WORK->unk_0x00 == '\0') || (ZI_WORK->unk_0x01 == options->countOnly)) {
switch(ZI_WORK->unk_0x00) {
case '\0':
if (parameters->elements[0] == 0xEFF2) {
ZI_WORK->unk_0x01 = options->countOnly;
ZI_WORK->unk_0x00 = '\x01';
}
break;
case '\x01':
if (parameters->elements[0] == 0xEFF3) {
ZI_WORK->unk_0x00 = '\x02';
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\x02':
if (parameters->elements[0] == 0xEFF5) {
ZI_WORK->unk_0x00 = '\x03';
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\x03':
if (parameters->elements[0] == 0xEFF7) {
ZI_WORK->unk_0x00 = '\x04';
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\x04':
if (parameters->elements[0] == 0xEFF8) {
ZI_WORK->unk_0x00 = '\x05';
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\x05':
if (parameters->elements[0] == 0xEFF9) {
ZI_WORK->unk_0x00 = '\x06';
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\x06':
if (parameters->elements[0] == 0xEFF2) {
ZI_WORK->unk_0x00 = '\a';
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\a':
if (parameters->elements[0] == 0xEFF5) {
ZI_WORK->unk_0x00 = '\b';
}
else {
ZI_WORK->unk_0x00 = '\0';
}
break;
case '\b':
case '\t':
if ((parameters->elements[0] == 0xEFF8) &&
((ziU8)Zi8AlphaSignature(parameters,options->countOnly,ZI_WORK) != 0)) {
ZI_WORK->unk_0x00 = '\t';
candidateCount = (unsigned int)parameters->letters;
if (options->countOnly != '\0') {
parameters->letters = 0;
}
Zi8LogError(100,ZI_WORK);
return candidateCount;
}
default:
ZI_WORK->unk_0x00 = '\0';
}
if ((ZI_WORK->unk_0x00 == '\0') && (parameters->elements[0] == 0xEFF2)) {
ZI_WORK->unk_0x00 = '\x01';
}
}
break;
}
}
else if (1 < parameters->elementCount) {
ZI_WORK->unk_0x00 = '\0';
}
}
ZI_WORK->unk_0x18 = parameters->subLanguage;
ZI_WORK->unk_0x16 = Zi8GetFormatVersion(1,ZI_WORK) & 2;
options->maxCount = ZI_WORK->unk_0x10;
options->maxWordLength = ZI_WORK->unk_0x0A;
ZI_WORK->unk_0x0A = -1;
if ((ziU8)Zi8LangSupported(parameters->language,ZI_WORK) == 0) {
Zi8LogError(0x163,ZI_WORK);
return 0;
}
else {
if (parameters->language == 0x10) {
error = 0x2c1;
candidateCount = 0;
}
else if (parameters->language == 0x12) {
if ((parameters->elementCount == 0) || (parameters->elements[0] >= 0xeff1)) {
candidateCount = Zi8GetKOcandidates(parameters,options,ZI_WORK);
}
else {
candidateCount = Zi8GetKoreanCandidates(parameters,options,ZI_WORK);
}
}
else if ((parameters->language == 1) && ((parameters->context & 8) != 0)) {
candidateCount = Zi8Punctuation(parameters,options,ZI_WORK);
error = 100;
}
else if ((parameters->language == 1) &&
((((parameters->getOptions & 0xbf) == 4 && (parameters->elementCount != 0)) &&
((ziU8)Zi8IsCharacter(parameters->elements[0],ZI_WORK) != 0)))) {
saved.convertedElementCount = Zi8GetCharInfo(parameters->elements[0],characterInfo,0x10,1,ZI_WORK);
if (saved.convertedElementCount == 0) {
parameters->letters = parameters->count = parameters->unk_0x20 = 0;
candidateCount = 0;
error = 900;
}
else {
saved.lastInfoCharacter = characterInfo[saved.convertedElementCount - 1];
if ((saved.lastInfoCharacter >= 0xf331) && (saved.lastInfoCharacter <= 0xf335)) {
characterInfo[saved.convertedElementCount - 1] = 0xf360;
}
saved.savedElements = parameters->elements;
parameters->elements = characterInfo;
saved.savedElementCount = parameters->elementCount;
parameters->elementCount = saved.convertedElementCount;
saved.savedGetMode = parameters->getMode;
parameters->getMode = 1;
candidateCount = Zi8GetChineseCandidates(parameters,options,ZI_WORK);
parameters->elements = saved.savedElements;
parameters->elementCount = saved.savedElementCount;
parameters->getMode = saved.savedGetMode;
parameters->count = 1;
}
}
else if ((parameters->language == 1) && (parameters->getMode == 0xf)) {
error = 0x2d0;
candidateCount = 0;
}
else if ((parameters->language == 1) && ((parameters->getMode == 3 || (parameters->getMode == 4)))) {
if ((parameters->getOptions & 0x80) != 0) {
candidateCount = Zi8Get1KeyPressSpelling(parameters,options,ZI_WORK);
} else if (parameters->elementCount == 0) {
candidateCount = Zi8GetChineseCandidates(parameters,options,ZI_WORK);
} else {
candidateCount = Zi8Get1KeyPressCandidates(parameters,options,ZI_WORK);
}
}
else if ((parameters->language == 1) &&
((((parameters->getMode == 7 || (parameters->getMode == 8)) || (parameters->getMode == 10)) || (parameters->getMode == 9)))) {
if (ZI_WORK->unk_0x16 != '\0') {
candidateCount = Zi8GetChineseCandidates(parameters,options,ZI_WORK);
} else {
error = 0x708;
candidateCount = 0;
}
}
else if ((parameters->language == 1) && ((parameters->getMode == 0xb || (parameters->getMode == 0xe)))) {
error = 0x2ee;
candidateCount = 0;
}
else if (parameters->language == 1) {
candidateCount = Zi8GetChineseCandidates(parameters,options,ZI_WORK);
if ((((candidateCount == 0) && ((parameters->getOptions & 0x20) == 0)) && ((parameters->getMode == 1 && (parameters->elementCount != 0))))
&& (((parameters->elements[parameters->elementCount - 1] == 0xF37A ||
(parameters->elements[parameters->elementCount - 1] == 0xF363)) ||
(parameters->elements[parameters->elementCount - 1] == 0xF373)))) {
saved.savedCharacter = parameters->elements[parameters->elementCount];
parameters->elements[parameters->elementCount++] = 0xf368;
candidateCount = Zi8GetChineseCandidates(parameters,options,ZI_WORK);
parameters->elements[--parameters->elementCount] = saved.savedCharacter;
}
}
else {
ZI_WORK->unk_0x538 = parameters->language;
if ((parameters->getOptions & 0x80) == 0) {
saved.restoreCandidates = 1;
saved.savedOptions = parameters->getOptions;
saved.savedCandidates = parameters->candidates;
parameters->getOptions |= 0x81;
parameters->candidates = (ziWChar*)&ZI_WORK->unk_0x338;
options->capacity = 0x100;
}
if (parameters->getMode == 2) {
if ((Zi8GetTableCount(parameters->language,0x1f,ZI_WORK) & 0x200) != 0) {
candidateCount = Zi8GetSyllablesCandidates(parameters,options,ZI_WORK);
} else {
error = 0x44c;
candidateCount = 0;
}
}
else {
candidateCount = Zi8AlphaGetCandidates(parameters,options,ZI_WORK);
}
}
if (saved.restoreCandidates) {
parameters->getOptions = saved.savedOptions;
parameters->candidates = saved.savedCandidates;
for (outputIndex = 0; outputIndex < parameters->letters; outputIndex++) {
parameters->candidates[outputIndex] = 0xFFF0 + outputIndex;
}
}
if (error != 0) {
Zi8LogError(error,ZI_WORK);
}
}
return candidateCount;
}
void Zi8InitDupWordBuf(ziPtr __zi8_work_data) {
ZI_WORK->unk_0x539 = 0;
}
ziBool Zi8IsDupWChar(ziWChar character ZI_NEED_WORK) {
ziBool duplicate;
ziU16* buffer;
unsigned int index;
duplicate = 0;
buffer = ZI_WORK->unk_0x57A;
if (ZI_WORK->unk_0x539 == 0) {
buffer[0] = 2;
buffer[1] = character;
ZI_WORK->unk_0x539 = 1;
Zi8LogError(0x8fd, ZI_WORK);
return 0;
}
for (index = ZI_WORK->unk_0x539; index != 0; index--) {
if (character == buffer[index]) {
duplicate = 1;
break;
}
}
ZI_WORK->unk_0x539++;
buffer[(*buffer)++] = character;
if (*buffer > 100) {
*buffer = 2;
buffer[1] = character;
ZI_WORK->unk_0x539 = 1;
}
Zi8LogError(100, ZI_WORK);
return duplicate;
}
ziBool Zi8IsDupWordW(ziWChar* word, ziU8 length ZI_NEED_WORK) {
unsigned int slot;
ziBool duplicate = 0;
int index;
int character;
if (word == 0 || length == 0) {
Zi8LogError(300, ZI_WORK);
return 0;
}
if (length > 20) {
word += length - 20;
length = 20;
}
for (index = 0; index < ZI_WORK->unk_0x539; index++) {
slot = ZI_WORK->unk_0x53A[index];
for (character = 0; character < length; character++) {
if (word[character] != ((ziWChar (*)[21])ZI_WORK->unk_0x57A)[slot][character]) break;
}
if (character >= length && ((ziWChar (*)[21])ZI_WORK->unk_0x57A)[slot][character] == 0) {
duplicate = 1;
break;
}
}
if (!duplicate) {
if (ZI_WORK->unk_0x539 < 64) {
slot = ZI_WORK->unk_0x53A[ZI_WORK->unk_0x539] = ZI_WORK->unk_0x539;
ZI_WORK->unk_0x539++;
} else {
slot = ZI_WORK->unk_0x53A[0];
for (index = 1; index < ZI_WORK->unk_0x539; index++) {
ZI_WORK->unk_0x53A[index - 1] = ZI_WORK->unk_0x53A[index];
}
ZI_WORK->unk_0x53A[index - 1] = slot;
}
} else {
slot = ZI_WORK->unk_0x53A[index];
for (; index < ZI_WORK->unk_0x539 - 1; index++) {
ZI_WORK->unk_0x53A[index] = ZI_WORK->unk_0x53A[index + 1];
}
ZI_WORK->unk_0x53A[index] = slot;
}
for (character = 0; character < length; character++) {
((ziWChar (*)[21])ZI_WORK->unk_0x57A)[slot][character] = word[character];
}
((ziWChar (*)[21])ZI_WORK->unk_0x57A)[slot][character] = 0;
Zi8LogError(100, ZI_WORK);
return duplicate;
}
void Zi8Memset(ziU8* destination, ziU32 value, ziS32 count) {
ziS32 index;
for (index = 0; index < count; index++) destination[index] = (ziU8)value;
}
void Zi8Memcpy(ziU8* destination, ziU8* source, ziS32 count) {
ziS32 index;
for (index = 0; index < count; index++) destination[index] = source[index];
}
ziBool Zi8SetMaxWordLength(ziU8 length ZI_NEED_WORK) {
ZI_WORK->unk_0x0A = length;
return 1;
}

View File

@@ -1,890 +0,0 @@
#include <zi8clib/zierror.h>
#include <zi8clib/zitypes.h>
extern ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
const ziU8 Zi8PinyinInitials[0x1C] = {
0x00, 0x3C, 0x98, 0x02, 0x00, 0x38, 0x34, 0x3B, 0x00, 0x06, 0x37, 0x2B,
0x0C, 0x26, 0x00, 0x3F, 0x09, 0x2C, 0x9A, 0x05, 0x00, 0x00, 0x11, 0x0A,
0x0D, 0x9C, 0x00, 0x00
};
const ziU8 Zi8BpmfInitials[0x24] = {
0x3C, 0x3F, 0x0C, 0x38, 0x02, 0x05, 0x26, 0x2B, 0x34, 0x37, 0x3B, 0x06,
0x09, 0x0A, 0x1D, 0x19, 0x1B, 0x2C, 0x1C, 0x18, 0x1A, 0x01, 0x02, 0x03,
0x05, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0E, 0x0D, 0x0F, 0x04, 0x00, 0x00
};
const ziU8 Zi8PinyinFinals[0x36][8] = {
{0x0F, 0xFF, 0x00, 0x00, 0x3C, 0x28, 0x00, 0x00},
{0x0F, 0x00, 0x00, 0x00, 0x3F, 0x2B, 0x00, 0x00},
{0x0F, 0x0E, 0xFF, 0x00, 0x3F, 0x28, 0x00, 0x00},
{0x0F, 0x0E, 0x07, 0x00, 0x3F, 0x28, 0x00, 0x00},
{0x0F, 0x15, 0x00, 0x00, 0x3F, 0x2A, 0x00, 0x00},
{0x09, 0xFF, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00},
{0x09, 0x00, 0x00, 0x00, 0x3F, 0x08, 0x00, 0x00},
{0x09, 0x01, 0xFF, 0x00, 0x38, 0x00, 0x00, 0x00},
{0x09, 0x01, 0x00, 0x00, 0x3F, 0x04, 0x00, 0x00},
{0x09, 0x01, 0x0F, 0x00, 0x3F, 0x01, 0x00, 0x00},
{0x09, 0x01, 0x0E, 0xFF, 0x3E, 0x02, 0x00, 0x00},
{0x09, 0x01, 0x0E, 0x00, 0x3F, 0x02, 0x00, 0x00},
{0x09, 0x01, 0x0E, 0x07, 0x3F, 0x03, 0x00, 0x00},
{0x09, 0x05, 0x00, 0x00, 0x3F, 0x09, 0x00, 0x00},
{0x09, 0x15, 0x00, 0x00, 0x3F, 0x0B, 0x00, 0x00},
{0x09, 0x0E, 0xFF, 0x00, 0x3E, 0x0C, 0x00, 0x00},
{0x09, 0x0E, 0x00, 0x00, 0x3F, 0x0C, 0x00, 0x00},
{0x09, 0x0E, 0x07, 0x00, 0x3F, 0x0D, 0x00, 0x00},
{0x09, 0x0F, 0xFF, 0x00, 0x3E, 0x0E, 0x00, 0x00},
{0x09, 0x0F, 0x15, 0x00, 0x3F, 0x0E, 0x00, 0x00},
{0x09, 0x0F, 0x0E, 0xFF, 0x3F, 0x0F, 0x00, 0x00},
{0x09, 0x0F, 0x0E, 0x07, 0x3F, 0x0F, 0x00, 0x00},
{0x15, 0xFF, 0x00, 0x00, 0x30, 0x10, 0x00, 0x00},
{0x15, 0x00, 0x00, 0x00, 0x3F, 0x18, 0x00, 0x00},
{0x15, 0x01, 0xFF, 0x00, 0x38, 0x10, 0x00, 0x00},
{0x15, 0x01, 0x00, 0x00, 0x3F, 0x17, 0x00, 0x00},
{0x15, 0x01, 0x0E, 0xFF, 0x3E, 0x10, 0x00, 0x00},
{0x15, 0x01, 0x0E, 0x00, 0x3F, 0x10, 0x00, 0x00},
{0x15, 0x01, 0x0E, 0x07, 0x3F, 0x11, 0x00, 0x00},
{0x15, 0x01, 0x09, 0x00, 0x3F, 0x13, 0x00, 0x00},
{0x15, 0x0E, 0x00, 0x00, 0x3F, 0x1C, 0x00, 0x00},
{0x15, 0x09, 0x00, 0x00, 0x3F, 0x1D, 0x00, 0x00},
{0x15, 0x0F, 0x00, 0x00, 0x3F, 0x1E, 0x00, 0x00},
{0x15, 0x05, 0x00, 0x00, 0x3F, 0x1F, 0x00, 0x00},
{0x01, 0xFF, 0x00, 0x00, 0x38, 0x20, 0x00, 0x00},
{0x01, 0x00, 0x00, 0x00, 0x3F, 0x23, 0x00, 0x00},
{0x01, 0x0E, 0xFF, 0x00, 0x3E, 0x20, 0x00, 0x00},
{0x01, 0x0E, 0x00, 0x00, 0x3F, 0x20, 0x00, 0x00},
{0x01, 0x0E, 0x07, 0x00, 0x3F, 0x21, 0x00, 0x00},
{0x01, 0x09, 0x00, 0x00, 0x3F, 0x25, 0x00, 0x00},
{0x01, 0x0F, 0x00, 0x00, 0x3F, 0x26, 0x00, 0x00},
{0x05, 0xFF, 0x00, 0x00, 0x38, 0x30, 0x00, 0x00},
{0x05, 0x00, 0x00, 0x00, 0x3F, 0x34, 0x00, 0x00},
{0x05, 0x0E, 0xFF, 0x00, 0x3E, 0x30, 0x00, 0x00},
{0x05, 0x0E, 0x00, 0x00, 0x3F, 0x30, 0x00, 0x00},
{0x05, 0x0E, 0x07, 0x00, 0x3F, 0x31, 0x00, 0x00},
{0x05, 0x09, 0x00, 0x00, 0x3F, 0x35, 0x00, 0x00},
{0x05, 0x12, 0x00, 0x00, 0x3F, 0x33, 0x00, 0x00},
{0x16, 0xFF, 0x00, 0x00, 0x3C, 0x38, 0x00, 0x00},
{0x16, 0x00, 0x00, 0x00, 0x3F, 0x38, 0x00, 0x00},
{0x16, 0x01, 0xFF, 0x00, 0x3F, 0x39, 0x00, 0x00},
{0x16, 0x01, 0x0E, 0x00, 0x3F, 0x39, 0x00, 0x00},
{0x16, 0x05, 0x00, 0x00, 0x3F, 0x1F, 0x00, 0x00},
{0x16, 0x0E, 0x00, 0x00, 0x3F, 0x3B, 0x00, 0x00}
};
const ziU8 nodeHeaderTable[0x20] = {
0x00, 0x10, 0x00, 0x01, 0x00, 0x03, 0x00, 0x14, 0x00, 0x05, 0x00, 0x07,
0x00, 0x1C, 0x00, 0x0D, 0x00, 0x0F, 0x00, 0x11, 0x00, 0x13, 0x00, 0x15,
0x00, 0x17, 0x00, 0x1D, 0x00, 0x1F, 0x00, 0x35
};
ziBool Zi8PriMatchNextChar(ziU8* node, ziU8 mask0, ziU8 value0, ziU8 mask1, ziU8 value1, ziU8 mask2, ziU8 value2, ziU8 mask3, ziU8 value3, ziU16* count, ziU8** result, ziU16* code ZI_NEED_WORK) {
ziU16 remaining = *count;
while (remaining-- != 0) {
if ((value0 == (node[0] & mask0)) && (value3 == (node[3] & mask3)) && (value2 == (node[2] & mask2)) && (value1 == (node[1] & mask1))) {
*result = node;
*code = ((ziU16)node[6] << 8) + (ziU16)node[7];
*count = remaining;
Zi8LogError(0x64, ZI_WORK);
return 1;
}
node += 0xC;
}
Zi8LogError(0x12E, ZI_WORK);
return 0;
}
ziBool Zi8ExactMatchNextChar(ziU8* node, ziU8 mask0, ziU8 value0, ziU8 mask1, ziU8 value1, ziU8 mask2, ziU8 value2, ziU8 mask3, ziU8 value3, ziU16* count, ziU8** result, ziU16* code ZI_NEED_WORK) {
ziU16 remaining = *count;
ziU8* current = node;
while (remaining-- != 0) {
if ((value0 == (current[0] & mask0)) && (value3 == (current[3] & mask3)) && (value2 == (current[2] & mask2)) && (value1 == (current[1] & mask1))) {
*result = current;
*code = ((ziU16)current[6] << 8) + (ziU16)current[7];
*count = remaining;
Zi8LogError(0x64, ZI_WORK);
return 1;
}
current += 0xC;
}
Zi8LogError(0x12E, ZI_WORK);
return 0;
}
ziU32 Zi8SecMatchChar(ziPtr nodeAddress, ziU8* dictionaryAddress, ziMatchParam* match, ziU16* code ZI_NEED_WORK) {
ziBool isPartial = 0;
ziU16 matchCode;
ziU8* data;
ziU8 value;
struct {
ziU8 remaining;
ziU8 dataIndex;
ziU16 targetCode;
} state;
if (match->field22 != 0) {
state.targetCode = match->field22;
matchCode = ((ziU16)(((ziU8*)nodeAddress)[4] & 3) << 8) | ((ziU8*)nodeAddress)[5];
value = 0;
while (value++ < 6) {
if (state.targetCode == matchCode) {
break;
}
matchCode = ((ziU16)(*(dictionaryAddress + matchCode * 8 + 6) & 3) << 8) | *(dictionaryAddress + matchCode * 8 + 7);
if (matchCode == 0) {
break;
}
}
if (state.targetCode != matchCode) {
return 0;
}
}
data = (ziU8*)Zi8GetTableAddress(1, 1, ZI_WORK);
data += ((ziU8*)nodeAddress)[0xB] + (((ziU8*)nodeAddress)[0xA] << 8) + ((((ziU8*)nodeAddress)[9] & 0xF) << 16);
if (ZI_WORK->unk_0x16 != 0) {
switch (data[0] & 7) {
case 2:
data += 2;
break;
case 3:
case 4:
data += 3;
break;
case 5:
data += 4;
break;
default:
data++;
break;
}
}
value = data[0];
value = (value >> 4) & 7;
if (value * 2 + 10 < match->length) {
return 0;
}
if (match->length < 9) {
if (match->length == 8) {
if ((data[0] & 0xF) == 0xF) {
isPartial = 1;
}
} else if ((match->length & 1) != 0) {
if ((((ziU8*)nodeAddress)[match->length >> 1] & 0xF) == 0xF) {
isPartial = 1;
}
} else {
if ((((ziU8*)nodeAddress)[match->length >> 1] & 0xF0) == 0xF0) {
isPartial = 1;
}
}
if (match->length > 2) {
if ((match->length & 1) != 0) {
if (((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF0) == 0) || ((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF0) == 0xF0)) {
return 0;
}
} else {
if (((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF) == 0) || ((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF) == 0xF)) {
return 0;
}
}
}
if (code != 0) {
*code = ((ziU16)((ziU8*)nodeAddress)[6] << 8) + (ziU16)((ziU8*)nodeAddress)[7];
}
if (isPartial) {
return 2;
}
return 1;
}
if ((match->length & 1) != 0) {
if (((data[((match->length - 1) >> 1) - 4] & 0xF0) == 0) || ((data[((match->length - 1) >> 1) - 4] & 0xF0) == 0xF0)) {
return 0;
}
} else {
if (((data[((match->length - 1) >> 1) - 4] & 0xF) == 0) || ((data[((match->length - 1) >> 1) - 4] & 0xF) == 0xF)) {
return 0;
}
}
state.dataIndex = 4;
state.remaining = ((match->length + 1) >> 1) - 4;
if (((ziU8)value + 1) < (int)state.remaining) {
return 0;
}
if ((match->length & 1) != 0) {
if ((data[(match->length >> 1) - 4] & 0xF) == 0xF) {
isPartial = 1;
}
} else {
if ((data[(match->length >> 1) - 4] & 0xF0) == 0xF0) {
isPartial = 1;
}
}
if (match->count == 0) {
while (state.remaining != 0) {
if ((data[0] & match->arr1[state.dataIndex]) != match->arrD[state.dataIndex]) {
return 0;
}
state.dataIndex++;
state.remaining--;
data++;
}
}
if (code != 0) {
*code = ((ziU16)((ziU8*)nodeAddress)[6] << 8) + (ziU16)((ziU8*)nodeAddress)[7];
}
if (isPartial) {
return 2;
}
return 1;
}
ziBool Zi8PriMatchNextComp(ziU8* node, ziU8 mask0, ziU8 value0, ziU8 mask1, ziU8 value1, ziU8 mask2, ziU8 value2, ziU8 mask3, ziU8 value3, ziU16* count, ziU8** result ZI_NEED_WORK) {
ziU16 remaining = *count;
while (remaining-- != 0) {
if ((value0 == (node[0] & mask0)) && (value1 == (node[1] & mask1)) && (value2 == (node[2] & mask2)) && (value3 == (node[3] & mask3))) {
*result = node;
*count = remaining;
Zi8LogError(0x64, ZI_WORK);
return 1;
}
node += 8;
}
Zi8LogError(0x12E, ZI_WORK);
return 0;
}
ziBool Zi8SecMatchComp(ziPtr nodeAddress, ziMatchParam* matchAddress, ziPtr dictionaryAddress) {
int chainIndex;
ziU16 matchCode;
ziU16 targetCode;
if (matchAddress->field22 != 0) {
targetCode = matchAddress->field22;
matchCode = ((ziU16)(((ziU8*)nodeAddress)[6] & 3) << 8) | ((ziU8*)nodeAddress)[7];
chainIndex = 0;
while (chainIndex++ < 6) {
if (targetCode == matchCode) {
break;
}
matchCode = ((ziU16)(*((ziU8*)dictionaryAddress + matchCode * 8 + 6) & 3) << 8) | *((ziU8*)dictionaryAddress + matchCode * 8 + 7);
if (matchCode == 0) {
break;
}
}
if (targetCode != matchCode) {
return 0;
}
}
if (matchAddress->length > 8) {
if ((int)((ziU8*)nodeAddress)[5] < (int)(matchAddress->length - 2)) {
return 0;
}
} else if ((int)((ziU8*)nodeAddress)[5] < (int)(matchAddress->length - 1)) {
return 0;
}
return 1;
}
extern ziU16 Zi8MatchAltSound(ziPtr soundTable, ziU16 soundCode, ziPtr pCodeTable, ziU16 index, ziU16 mask, ziU16 value, ziU8 flag ZI_NEED_WORK);
ziU16 Zi8GetPCode(ziU8* table, ziU8* node);
ziBool Zi8MatchPhonetic(ziPtr pCodeTable, ziU8* dictionary, ziPtr soundTable, ziU16 soundCode, ziU32 tableAddress, ziU8* node, ziU16* masks, ziU16* values, ziU16* count, ziU8** resultNode, ziU8** stringOffset, ziU8 partialMode, ziU8 strictMode, ziU8 numParts, ziU16 partMask, ziU16 partValue, ziU8 flag, ziU8 altMode, ziU16 initialCode, ziU16* resultCode, ziU8 lastMode ZI_NEED_WORK) {
struct {
ziBool hasString;
ziU8 partIndex;
ziU8 partCount;
ziU8 nextCode;
ziU8 matchedParts;
ziU16 dictionaryIndex;
ziU16 soundIndex;
ziU16 remaining;
ziU16 code;
} traversal;
ziU8* sound;
typedef struct {
ziU8 header;
ziU8 content[11];
} DictionaryNode;
if (*stringOffset != 0) {
traversal.hasString = 1;
} else {
traversal.hasString = 0;
}
if (*count != 0) {
traversal.remaining = *count;
} else {
traversal.remaining = 1;
}
traversal.matchedParts = 0;
if ((lastMode != 0) && (numParts > 1)) {
altMode = 1;
}
while (traversal.remaining-- != 0) {
if ((node[0] & flag) != 0) goto decode_node;
next_node:
node += 0xC;
continue;
decode_node:
traversal.code = Zi8GetPCode((ziU8*)pCodeTable, node);
if ((*values != (traversal.code & *masks)) && (altMode == 0) && ((node[0] & 0x80) != 0)) {
if (*count != 0) {
traversal.soundIndex = (initialCode - traversal.remaining) - 1;
} else {
traversal.soundIndex = initialCode;
}
traversal.code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, traversal.soundIndex, *masks, *values, flag, ZI_WORK);
}
goto check_code;
match_code:
if (partValue == (traversal.code & partMask)) goto next_node;
traversal.matchedParts = 1;
if (*count != 0) {
traversal.soundIndex = (initialCode - traversal.remaining) - 1;
} else {
traversal.soundIndex = initialCode;
}
sound = (ziU8*)(tableAddress + ((node[9] & 0xF) * 0x10000 + (node[0xB] + node[0xA] * 0x100)));
if (ZI_WORK->unk_0x16 != 0) {
switch (sound[0] & 7) {
case 2:
sound += 2;
break;
case 3:
case 4:
sound += 3;
break;
case 5:
sound += 4;
break;
default:
sound++;
break;
}
}
if ((sound[0] & 0x80) != 0) {
sound += ((sound[0] & 0x7F) >> 4) + 1;
} else if (numParts > 1) {
goto next_node;
}
if (((ziU8)traversal.matchedParts == numParts) || (numParts == 0)) {
*resultNode = node;
*resultCode = ((ziU16)node[6] << 8) + node[7];
*count = traversal.remaining;
return 1;
}
next_group:
{
traversal.nextCode = *sound++;
traversal.partCount = traversal.nextCode & 0xF;
if ((traversal.nextCode & flag) == 0) {
for (; traversal.partCount != 0; traversal.partCount--) {
for (sound++; (*sound & 0x80) == 0; sound += 2) {
}
sound++;
}
}
for (; traversal.partCount != 0; traversal.partCount--) {
traversal.partIndex = 1;
if (traversal.hasString && (sound > *stringOffset)) {
traversal.hasString = 0;
}
if (!traversal.hasString) {
*stringOffset = sound;
}
do {
traversal.dictionaryIndex = sound[0] | ((ziU16)sound[1] << 8);
sound += 2;
if (traversal.hasString) {
goto phonetic_skip;
}
traversal.code = Zi8GetPCode((ziU8*)pCodeTable, dictionary + (traversal.dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode));
if (((traversal.code & masks[traversal.partIndex]) != values[traversal.partIndex]) && (altMode == 0) && (dictionary[(traversal.dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode)] & 0x80) != 0) {
traversal.code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, traversal.dictionaryIndex & 0x7FFF, masks[traversal.partIndex], values[traversal.partIndex], flag, ZI_WORK);
}
if ((traversal.code & masks[traversal.partIndex]) == values[traversal.partIndex]) {
goto phonetic_matched;
}
phonetic_skip:
if ((traversal.dictionaryIndex & 0x8000) == 0) {
sound++;
while ((*sound & 0x80) == 0) {
sound += 2;
}
sound++;
}
break;
phonetic_matched:
if (++traversal.partIndex == numParts) {
if (partialMode != 0) {
if (strictMode == 0 && (traversal.dictionaryIndex & 0x8000) != 0) goto phonetic_skip;
if (strictMode != 0 && (traversal.dictionaryIndex & 0x8000) == 0) goto phonetic_skip;
}
*resultNode = node;
*resultCode = ((ziU16)node[6] << 8) + node[7];
*count = traversal.remaining;
return 1;
}
} while ((traversal.dictionaryIndex & 0x8000) == 0);
}
}
if ((traversal.nextCode & 0x80) != 0) goto next_node;
goto next_group;
check_code:
if (*values == (traversal.code & *masks)) goto match_code;
goto next_node;
}
return 0;
}
ziBool Zi8GetPyFinal(ziU8* pinyin, ziU8* initial, ziU8* final);
ziU8 Zi8GetPyPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final, ziU8* resultCount, ziU16* bestInitial, ziU16* bestFinal ZI_NEED_WORK) {
ziU8 pyInitial;
ziU8 pyFinal;
ziU8 convertedCount;
ziU8 result;
ziBool partial;
ziBool alternateInitial;
ziU8 outputIndex;
ziU8 index;
ziU16 value;
ziWChar converted[256];
ziU8 pinyin[12];
ziWChar* current;
current = converted;
alternateInitial = 0;
result = 0;
*resultCount = 0;
if (count == 0) {
Zi8LogError(0x135, ZI_WORK);
return 0;
}
index = 0;
convertedCount = index;
for (; index < count; index++) {
if (((text[index] >= 0xF341) && (text[index] <= 0xF35A)) || ((text[index] >= 0x41) && (text[index] <= 0x5A))) {
if ((convertedCount != 0) && (current[convertedCount - 1] != 0xF360) && (current[convertedCount - 1] != 0x27)) {
current[convertedCount++] = 0x27;
}
current[convertedCount++] = (text[index] & 0xFF) + 0x20;
} else {
current[convertedCount++] = text[index];
}
}
count = convertedCount;
outputIndex = 0;
*bestInitial = 0;
*bestFinal = 0;
while (count != 0) {
initial[outputIndex] = 0;
final[outputIndex] = 0;
value = *current;
if (value < 0x61) {
goto check_pinyin_extension;
}
if (value <= 0x7A) {
goto pinyin_ascii;
}
check_pinyin_extension:
if (value < 0xF361) {
goto invalid_pinyin;
}
if (value <= 0xF37A) goto pinyin_extension;
invalid_pinyin:
*bestInitial = *bestFinal = initial[0] = final[0] = 0xFFFF;
return 1;
pinyin_extension:
value -= 0xF361;
goto pinyin_initial;
pinyin_ascii:
value -= 0x61;
pinyin_initial:
convertedCount = Zi8PinyinInitials[value];
if (convertedCount != 0) {
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
result++;
initial[outputIndex] = 0x7E00;
final[outputIndex] = (ziU16)(convertedCount & 0x7f) << 9;
*bestInitial = initial[0];
*bestFinal = final[0];
count--;
if (count == 0) {
break;
}
current += 1;
if ((convertedCount & 0x80) != 0) {
if (alternateInitial) {
initial[outputIndex] &= 0xfdff;
final[outputIndex] &= 0xfdff;
}
value = *current;
if (value != 0x68 && value != 0xF368) goto scan_final;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
final[outputIndex] += 0x200;
*bestInitial = initial[0];
*bestFinal = final[0];
count--;
if (count == 0) {
break;
}
current += 1;
}
} else if ((*current == 0xF369) || (*current == 0x69)) {
goto invalid_pinyin;
}
scan_final:
partial = 0;
for (index = 0; index < 4; index++) {
pinyin[index] = 0;
}
index = 0;
while (index < 4) {
value = *current;
if ((value == 0x27) || (value == 0xF360) || (value == 0x20)) {
if (index != 0) {
partial = 1;
}
goto finish_final;
}
if ((value >= 0xF331) && (value < 0xF336)) {
if (index != 0) {
partial = 1;
}
goto finish_final;
}
if ((value < 0x61) || (value > 0x7A)) {
if (value < 0xF361) {
goto finish_final;
}
value -= 0xF361;
if (value > 0x19) {
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
goto finish_final;
}
} else {
value -= 0x61;
}
pinyin[index] = (ziU8)value + 1;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) == 0) goto try_final_extension;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
current++;
index++;
count--;
if (count == 0) {
goto finish_final;
}
continue;
try_final_extension:
if (index < 3) {
pinyin[index + 1] = 0xFF;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
pinyin[index + 1] = 0;
current++;
index++;
count--;
if (count == 0) break;
} else {
pinyin[index + 1] = 0;
pinyin[index] = 0;
partial = 1;
break;
}
} else {
pinyin[index] = 0;
partial = 1;
break;
}
}
finish_final:
if ((index > 3) && (count != 0) && (((value = *current) == 0x27) || (value == 0xF360) || (value == 0x20))) {
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
current++;
count--;
}
if (index > 3) {
partial = 1;
}
if (partial && alternateInitial == 0) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
final[outputIndex] = 0x200;
}
initial[outputIndex] |= (ziU16)pyInitial << 3;
final[outputIndex] |= (ziU16)pyFinal << 3;
*bestInitial = initial[0];
*bestFinal = final[0];
} else {
if ((index != 0) && (count != 0)) {
goto invalid_pinyin;
}
}
} else {
pinyin[index] = 0xFF;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
final[outputIndex] = 0x200;
}
initial[outputIndex] |= (ziU16)pyInitial << 3;
final[outputIndex] |= (ziU16)pyFinal << 3;
*bestInitial = initial[0];
*bestFinal = final[0];
if ((outputIndex == 0) && (count == 0)) {
pinyin[index] = 0;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
*bestInitial = 0x7E00;
*bestFinal = 0x200;
}
*bestInitial |= (ziU16)pyInitial << 3;
*bestFinal |= (ziU16)pyFinal << 3;
}
}
} else {
pinyin[index] = 0;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
final[outputIndex] = 0x200;
}
initial[outputIndex] |= (ziU16)pyInitial << 3;
final[outputIndex] |= (ziU16)pyFinal << 3;
*bestInitial = initial[0];
*bestFinal = final[0];
}
}
}
if (count != 0) {
value = *current;
if ((value == 0x27) || (value == 0xF360) || (value == 0x20)) {
current++;
count--;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
} else if ((value >= 0xF331) && ((value -= 0xF331) <= 4)) {
value++;
initial[outputIndex] |= 7;
final[outputIndex] |= value;
*bestInitial = initial[0];
*bestFinal = final[0];
count--;
current++;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
if ((count != 0) && (((value = *current) == 0x27) || (value == 0xF360) || (value == 0x20))) {
count--;
current++;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
}
}
}
outputIndex++;
if (outputIndex > 0xf) break;
}
if ((result > 1) && (text[*resultCount - 1] >= 0xF341) && (text[*resultCount - 1] <= 0xF35A)) {
*resultCount = *resultCount - 1;
}
return result;
}
ziBool Zi8GetPyFinal(ziU8* pinyin, ziU8* initial, ziU8* final) {
ziU8 index = 0;
ziU8 row;
row = 0;
goto check_row;
scan_row:
while (index < 4) {
if (pinyin[index] != Zi8PinyinFinals[row][index]) {
break;
}
index++;
}
if (index < 4) {
goto next_row;
}
*initial = Zi8PinyinFinals[row][4];
*final = Zi8PinyinFinals[row][5];
return 1;
next_row:
row++;
index = 0;
check_row:
if (row < 0x36) {
goto scan_row;
}
return 0;
}
ziS32 Zi8GetBpmfPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final, ziU16* bestInitial, ziU16* bestFinal ZI_NEED_WORK) {
ziU16 value;
ziU32 resultCount = 0;
Zi8LogError(0x64, ZI_WORK);
if (count == 0) {
Zi8ReplaceLastError(0x135, ZI_WORK);
return 0;
}
value = text[0];
if (value < 0xF305) {
Zi8ReplaceLastError(0x154, ZI_WORK);
return 0;
}
value -= 0xF305;
if (value >= 0x25) {
Zi8ReplaceLastError(0x154, ZI_WORK);
return 0;
}
if (value < 0x15) {
*initial = 0x7E00;
*final = ((ziU16)Zi8BpmfInitials[value] & 0x7F) << 9;
resultCount++;
count--;
if (count == 0) {
*bestInitial = *initial;
*bestFinal = *final;
if ((value >= 0xE) && (value <= 0x14)) {
*bestInitial |= 0x1F8;
*bestFinal |= 0x38;
}
return resultCount;
}
text++;
if (*text == 0xF360) {
resultCount++;
count--;
if (count == 0) {
return resultCount;
}
Zi8ReplaceLastError(0x156, ZI_WORK);
return 0;
}
} else {
*initial = 0x7E00;
*final = 0x200;
}
value = *text - 0xF305;
switch ((ziS32)value) {
case 0x22:
goto bpmf_value_22;
case 0x23:
goto bpmf_value_23;
case 0x24:
goto bpmf_value_24;
default:
goto set_bpmf_initial;
}
bpmf_value_22:
*final |= 0x80;
*initial |= 0x180;
resultCount++;
count--;
if (count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
goto after_bpmf_initial;
bpmf_value_23:
*final |= 0x100;
*initial |= 0x180;
resultCount++;
count--;
if (count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
goto after_bpmf_initial;
bpmf_value_24:
*final |= 0x180;
*initial |= 0x180;
resultCount++;
count--;
if (count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
goto after_bpmf_initial;
set_bpmf_initial:
if ((*text < 0xF331) || (*text > 0xF335)) {
*initial |= 0x180;
}
after_bpmf_initial:
value = *text - 0xF305;
if ((value > 0x14) && (value < 0x22)) {
*final |= (ziU16)Zi8BpmfInitials[value] << 3;
*initial |= 0x78;
resultCount++;
count--;
if (count == 0) {
*bestInitial = *initial;
*bestFinal = *final;
return resultCount;
}
text++;
} else if ((*text < 0xF331) || (*text > 0xF335) || ((*initial & 0x180) == 0x180)) {
*final |= 0x38;
*initial |= 0x78;
}
value = *text;
if (value < 0xF331) {
Zi8ReplaceLastError(0x155, ZI_WORK);
return 0;
}
value -= 0xF330;
if (value > 5) {
Zi8ReplaceLastError(0x155, ZI_WORK);
return 0;
}
*initial |= 7;
*final |= value;
*bestInitial = *initial;
*bestFinal = *final;
resultCount++;
count--;
if (count != 0) {
Zi8ReplaceLastError(0x157, ZI_WORK);
return 0;
}
return resultCount;
}
ziU16 Zi8GetPCode(ziU8* table, ziU8* node) {
ziU16 index = ((ziU16)node[8] << 2) | (((ziU16)node[9] & 0x80) >> 6);
return ((((ziU16)node[9] >> 4) & 7) | (ziU16)table[index] | ((ziU16)table[index + 1] << 8));
}

View File

@@ -1,180 +0,0 @@
#include <stddef.h>
#include <zi8clib/zitypes.h>
#include <zi8clib/zierror.h>
#include <zi8clib/zconvert.h>
#include <zi8clib/zmtkey.h>
typedef struct ziPudSection {
ziU8 flags;
ziU8 language;
ziU8 offset[2];
ziU8 count[2];
ziU8 reserved[2];
} ziPudSection;
typedef struct ziPudHeader {
ziU8 format[3];
ziU8 languageCount;
ziU8 options[4];
ziPudSection sections[1];
} ziPudHeader;
ziU32 Zi8_8147FD7C(ziWChar*, ziU8, ziU8, ziWChar*, ziU16, ziU8, ziU8 ZI_NEED_WORK);
ziU32 ZiIsPhoneticChar(ziWChar character) {
if ((character < 0xF305 || character > 0xF329) && (character < 0xF361 || character > 0xF37A)) return 0;
return 1;
}
int ZiGetZHWordSize(ziWChar* word, int size) {
int bytes;
ziWChar* cursor;
bytes = 0;
for (bytes = 0; bytes < size;) {
cursor = word;
if (ZiIsPhoneticChar(*cursor)) return bytes;
bytes += 2;
word++;
}
return bytes;
}
void Zi8CopyZHSpelling(ziU8* source, ziWChar* output, ziU16 capacity, int size, int start) {
int offset;
ziU8* cursor;
if (output != 0 && capacity != 0) {
*output = 0;
if (size > start) {
for (offset = 0; offset < size - start && offset < (int)((ziU32)capacity << 1); offset += 2) {
cursor = source + start + offset;
*output++ = *(ziWChar*)cursor;
}
*output = 0;
}
}
}
ziU8 ZADP_Zi8SetPDremoveOpt(ziU8 option ZI_NEED_WORK) {
ziU8 previous;
previous = ZI_WORK->pdRemoveOpt;
ZI_WORK->pdRemoveOpt = option;
Zi8LogError(100, __zi8_work_data);
return previous;
}
ziU32 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziWChar* spelling, ziU16 spellingCapacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
ziWChar folded;
ziU32 entrySize, wordSize, copied;
ziU8* entry;
ziU8* word;
int index;
int fallback = 0;
ziPudHeader* table;
ziPudSection* section;
if (!(ZI_WORK->pudCount <= 16 && ZI_WORK->pudCount != 0 && ZI_WORK->pudTable[ZI_WORK->pudCount - 1] != 0)) {
Zi8LogError(0x4B0, __zi8_work_data);
return 0;
}
if (language == 1) {
length &= 0x7F;
length *= 2;
}
if (continuation == 0) {
table = (ziPudHeader*)ZI_WORK->pudTable[ZI_WORK->pudCount - 1];
index = 0;
section = table->sections;
while (index < table->languageCount && section->language != language) {
index++;
section++;
}
if (table->languageCount <= index) {
Zi8LogError(0x4F6, __zi8_work_data);
return 0;
}
ZI_WORK->unk_0x314 = section->count[0] * 0x100 + section->count[1];
ZI_WORK->unk_0x310 = (ziU32)table + section->offset[0] * 0x100 + section->offset[1];
ZI_WORK->unk_0x318 = 0;
}
while ((entry = (ziU8*)ZI_WORK->unk_0x310) != 0) {
while ((ziS32)ZI_WORK->unk_0x318 < (ziS32)ZI_WORK->unk_0x314) {
word = entry + 1;
wordSize = *entry;
entrySize = wordSize;
if (language == 1) {
if (*word < ZI_WORK->unk_0x17) goto next;
entrySize = wordSize - 1;
word = entry + 2;
wordSize = ZiGetZHWordSize((ziWChar*)word, entrySize);
} else if (ZI_WORK->unk_0x31E != 0 && complete != 0 && wordSize > length && word[length] == 0x20) goto matchText;
if ((ziS32)length > (ziS32)wordSize || (complete != 0 && wordSize != length) || (complete == 0 && wordSize == length)) goto next;
if (language == 1) {
for (index = 0; index < length; index++) {
if (word[index] != ((ziU8*)pattern)[index]) goto next;
}
goto matched;
}
matchText:
for (index = 0; index < length; index++) {
if (pattern[index] < 0xEFF1 || pattern[index] > 0xF37F) {
folded = Zi8ConvertUC2WC(word[index], language, __zi8_work_data);
if (folded != pattern[index] && (!ZI_WORK->unk_0x1F || !Zi8ChangeCharCase(0, &folded, language, __zi8_work_data) || folded != pattern[index])) goto next;
} else if (pattern[index] != Zi8ConvertUC2Key(word[index], language, __zi8_work_data)) goto next;
}
matched:
if (fallback) {
ZI_WORK->unk_0x310 = 0;
ZI_WORK->unk_0x318 = 0;
ZI_WORK->unk_0x314 = 0;
if (*pattern < 0xEFF1) *output = Zi8ConvertWC2Key(*pattern, language, __zi8_work_data);
else *output = *pattern;
return 1;
}
if (language == 1) {
index = 0;
for (copied = 0; index < (ziS32)wordSize && copied < capacity; copied++) {
((ziU8*)output)[index] = word[index];
((ziU8*)output)[index + 1] = word[index + 1];
index += 2;
}
Zi8CopyZHSpelling(word, spelling, spellingCapacity, entrySize, wordSize);
} else {
for (copied = 0; copied < wordSize && copied < capacity; copied++) {
output[copied] = Zi8ConvertUC2WC(word[copied], language, __zi8_work_data);
if (ZI_WORK->unk_0x31E != 0 && copied >= length && output[copied] == 0x20) {
if (complete != 0 || copied >= length) break;
goto next;
}
}
}
ZI_WORK->unk_0x318++;
ZI_WORK->unk_0x310 = (ziU32)(word + entrySize);
Zi8LogError(100, __zi8_work_data);
return (ziU8)copied;
next:
ZI_WORK->unk_0x318++;
entry = word + entrySize;
}
if (length != 1 || complete == 0 || continuation != 0) {
ZI_WORK->unk_0x310 = 0;
ZI_WORK->unk_0x318 = 0;
ZI_WORK->unk_0x314 = 0;
return 0;
}
complete = 0;
fallback = 1;
ZI_WORK->unk_0x318 = 0;
}
Zi8LogError(0x4B3, __zi8_work_data);
return 0;
}
ziU32 Zi8MatchPUDdata(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
ziU32 result;
if (continuation == 0) ZI_WORK->pudCount = 1;
for (;;) {
result = Zi8_8147FD7C(pattern, length, language, output, capacity, complete, continuation, __zi8_work_data);
if ((ziU8)result != 0) break;
if ((ZI_WORK->pudCount = ZI_WORK->pudCount + 1) > 16) {
ZI_WORK->pudCount = 1;
break;
}
continuation = 0;
}
return result;
}
ziU32 Zi8_8147FD7C(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
return Zi8MatchPUDdata_ZHS(pattern, length, language, output, capacity, 0, 0, complete, continuation, __zi8_work_data);
}

View File

@@ -1,207 +0,0 @@
#include <zi8clib/zitypes.h>
#include <zi8clib/zierror.h>
#include <zi8clib/zconvert.h>
#include <zi8clib/zmtkey.h>
typedef struct ziUserWord {
ziU8 size, language, length, priority;
ziU8 text[1];
} ziUserWord;
typedef struct ziUserDictionary {
ziU16 flags, end, current, boundary;
ziU8 entries[1];
} ziUserDictionary;
void Zi8Memset(ziPtr, ziU32, ziU32);
ziBool Zi8_81480224(ziUserWord* word ZI_NEED_WORK) {
ziU8 length;
ziU8 position;
ziUwdNode* previous;
ziUwdNode* current;
ziUwdNode* added;
ziUserWord* candidate;
if (ZI_WORK->uwdCount >= 32) {
Zi8LogError(0x19D, __zi8_work_data);
return 0;
}
if (word == 0) {
Zi8LogError(0x19F, __zi8_work_data);
return 0;
}
length = word->length;
if (length == 0) {
Zi8LogError(0x193, __zi8_work_data);
return 0;
}
if (length > 63) {
Zi8LogError(0x194, __zi8_work_data);
return 0;
}
previous = 0;
current = ZI_WORK->uwdList;
while (current != 0) {
candidate = (ziUserWord*)current->word;
if (ZI_WORK->unk_0x12E == 1 && word->priority > candidate->priority) break;
if (candidate->length == length) {
position = 0;
while (position < length) {
if ((ziU8)candidate->text[position] != (ziU8)word->text[position]) break;
position++;
}
if (position == length) {
Zi8LogError(100, __zi8_work_data);
return 0;
}
}
previous = current;
current = current->next;
}
length = ZI_WORK->uwdCount;
ZI_WORK->uwdCount = length + 1;
added = &ZI_WORK->uwdNodes[length];
if (previous == 0) {
ZI_WORK->uwdList = added;
added->next = current;
} else {
previous->next = added;
added->next = current;
}
added->word = (ziU8*)word;
Zi8LogError(100, __zi8_work_data);
return 1;
}
ziUserWord* Zi8_814803F4(ziPtr __zi8_work_data) {
ziUserWord* word;
if (ZI_WORK->uwdCount != 0) {
ZI_WORK->uwdCount--;
word = (ziUserWord*)ZI_WORK->uwdList->word;
ZI_WORK->uwdList = ZI_WORK->uwdList->next;
Zi8LogError(100, __zi8_work_data);
return word;
}
Zi8LogError(0x19E, __zi8_work_data);
return 0;
}
void Zi8_8148047C(ziPtr __zi8_work_data) {
Zi8Memset(ZI_WORK->uwdNodes, 0, sizeof(ZI_WORK->uwdNodes));
ZI_WORK->uwdCount = 0;
ZI_WORK->uwdList = 0;
}
ziU8 Zi8MatchUWDdata(ziWChar* pattern, ziU8 length, ziWChar* currentWord, ziU16 currentLength, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
ziWChar folded;
int fallback = 0;
int visited = 0;
int position, prefixLength, previousOffset;
ziU32 size, entryLanguage, entryLength;
ziU8* cursor;
ziU8* begin;
ziU8* boundary;
ziU8* end;
ziUserWord* candidate;
ziUserWord* previous;
ziUserWord* result;
ziUserDictionary* dictionary;
int firstSegment;
Zi8LogError(100, __zi8_work_data);
if (!(ZI_WORK->unk_0x138 < 3 && ZI_WORK->unk_0x138 != 0 && ZI_WORK->unk_0x130[ZI_WORK->unk_0x138 - 1] != 0)) {
Zi8ReplaceLastError(0x19C, __zi8_work_data);
return 0;
}
dictionary = ZI_WORK->unk_0x130[ZI_WORK->unk_0x138 - 1];
if (continuation == 0) {
Zi8_8148047C(__zi8_work_data);
ZI_WORK->unk_0x13C = 0;
if (currentWord == 0 || currentLength == 0 || currentWord[currentLength - 1] != 0x20) ZI_WORK->unk_0x140 = 0;
else {
prefixLength = 0;
for (position = currentLength - 2; position >= 0 && currentWord[position] != 0x20; position--) prefixLength++;
if (prefixLength == 0 || prefixLength > 63) ZI_WORK->unk_0x140 = 0;
else {
ZI_WORK->unk_0x140 = 1;
ZI_WORK->unk_0x141[0] = prefixLength + 5;
ZI_WORK->unk_0x141[prefixLength + 4] = prefixLength + 5;
ZI_WORK->unk_0x141[1] = language;
ZI_WORK->unk_0x141[2] = prefixLength;
previousOffset = 4;
for (; ++position, prefixLength > 0; prefixLength--) {
folded = currentWord[position];
ZI_WORK->unk_0x141[previousOffset] = Zi8ConvertWC2UC(folded, language, __zi8_work_data);
ZI_WORK->unk_0x184[previousOffset] = 0;
if (ZI_WORK->unk_0x1F != 0) {
if (!Zi8ChangeCharCase(1, &folded, language, __zi8_work_data)) Zi8ChangeCharCase(0, &folded, language, __zi8_work_data);
ZI_WORK->unk_0x184[previousOffset] = Zi8ConvertWC2UC(folded, language, __zi8_work_data);
}
if (ZI_WORK->unk_0x141[previousOffset] == 0) {
ZI_WORK->unk_0x140 = 0;
previousOffset++;
break;
}
previousOffset++;
}
}
}
if (ZI_WORK->unk_0x140 == 0 && length == 0) return 0;
rescan:
begin = dictionary->entries + dictionary->current;
boundary = (ziU8*)dictionary + dictionary->boundary + 7;
end = (ziU8*)dictionary + dictionary->end + 7;
cursor = begin;
firstSegment = begin < boundary;
while (firstSegment ? cursor < boundary : cursor < end) {
size = *cursor;
candidate = (ziUserWord*)cursor;
position = visited++;
if ((ziS32)ZI_WORK->unk_0x13C <= position && (size & 0xC0) == 0) {
previous = (ziUserWord*)(cursor + size);
if ((ziU8*)previous > end) previous = (ziUserWord*)(cursor + ((ziU8*)dictionary - end) + 7);
entryLanguage = candidate->language;
entryLength = candidate->length;
if (entryLanguage == language && length <= entryLength && entryLength < capacity && (complete == 0 || entryLength == length) && (complete != 0 || entryLength != length)) {
for (position = 0; position < length; position++) {
if (pattern[position] < 0xEFF1 || pattern[position] > 0xF010) {
folded = Zi8ConvertUC2WC(candidate->text[position], language, __zi8_work_data);
if (folded != pattern[position] && (!ZI_WORK->unk_0x1F || !Zi8ChangeCharCase(0, &folded, language, __zi8_work_data) || folded != pattern[position])) goto next;
} else if (pattern[position] != Zi8ConvertUC2Key(candidate->text[position], language, __zi8_work_data)) goto next;
}
if (ZI_WORK->unk_0x140 != 0) {
if (ZI_WORK->unk_0x141[0] != previous->size || ZI_WORK->unk_0x141[1] != previous->language || ZI_WORK->unk_0x141[2] != previous->length) goto next;
for (position = 4; position < ZI_WORK->unk_0x141[2] + 4; position++) {
if (ZI_WORK->unk_0x141[position] != ((ziU8*)previous)[position] && ZI_WORK->unk_0x184[position] != ((ziU8*)previous)[position]) goto next;
}
}
Zi8_81480224(candidate, __zi8_work_data);
}
}
next:
cursor += size;
if (end < cursor) {
if (firstSegment) break;
firstSegment = 1;
cursor = dictionary->entries + (cursor - end - 1);
}
}
if (ZI_WORK->unk_0x140 != 0 && length != 0) {
ZI_WORK->unk_0x140 = 0;
visited = 0;
goto rescan;
}
if (complete != 0 && length == 1) {
complete = 0;
fallback = 1;
visited = 0;
goto rescan;
}
}
result = Zi8_814803F4(__zi8_work_data);
entryLength = 0;
if (result != 0) {
entryLanguage = result->language;
entryLength = result->length;
if (entryLength >= capacity) {
Zi8_8148047C(__zi8_work_data);
return 0;
}
for (position = 0; position < (ziS32)entryLength; position++) output[position] = Zi8ConvertUC2WC(result->text[position], entryLanguage, __zi8_work_data);
}
return entryLength;
}

View File

@@ -1,222 +0,0 @@
#include <zi8clib/zierror.h>
#include <zi8clib/zitypes.h>
extern ziU16 nodeHeaderTable[16];
ziU32 ZiDAWGGetChild(ziU32 node) {
ziU32 base;
ziU16 header;
ziS32 offset;
base = node;
header = nodeHeaderTable[*(ziU8*)node >> 4];
if (((ziU32)header & 1) == 0) {
node = 0;
} else {
if ((*(ziU8*)node & 0xf) == 0xf) {
offset = 2;
} else {
offset = 1;
}
node += offset;
if (((ziU32)header & 2) != 0) {
if ((*(ziU8*)node & 0x80) != 0) {
offset = *((ziU8*)node + 2) + ((*(ziU8*)node & 0x7f) * 0x10000 + ((ziU32)*((ziU8*)node + 1) & 0xffff) * 0x100 + 0x8000);
} else {
offset = ((ziU32)*(ziU8*)node & 0xffff) * 0x100;
offset += (ziU32)*((ziU8*)node + 1);
}
} else if (((ziU32)header & 8) != 0) {
if ((*(ziU8*)node & 0x80) != 0) {
offset += 3;
} else {
offset += 2;
}
}
node = base + offset;
}
return node;
}
ziU8* ZiDAWGGetSibling(ziU8* node) {
ziU16 header;
ziU8* cursor;
ziS32 depth;
ziS32 offset;
depth = 0;
offset = 0;
header = nodeHeaderTable[node[0] >> 4];
if ((header & 4) == 0) {
node = 0;
} else {
cursor = node;
if ((header & 8) != 0) {
if ((node[0] & 0xf) == 0xf) {
cursor = node + 2;
} else {
cursor = node + 1;
}
if ((header & 2) != 0) {
if ((*cursor & 0x80) == 0) {
cursor += 2;
} else {
cursor += 3;
}
}
if ((*cursor & 0x80) == 0) {
node += (ziU32)cursor[1] + (ziU32)*cursor * 0x100;
} else {
node += (*cursor & 0x7f) * 0x10000 + (ziU32)cursor[1] * 0x100 +
0x8000 + (ziU32)cursor[2];
}
} else {
do {
header = nodeHeaderTable[cursor[0] >> 4];
if ((cursor[0] & 0xf) == 0xf) {
cursor += 2;
offset += 2;
} else {
cursor++;
offset++;
}
if ((header & 1) != 0) {
if ((header & 2) == 0) {
depth++;
} else if ((*cursor & 0x80) == 0) {
cursor += 2;
offset += 2;
} else {
cursor += 3;
offset += 3;
}
}
if ((header & 4) == 0) {
depth--;
} else if ((header & 8) != 0) {
if ((*cursor & 0x80) == 0) {
cursor += 2;
offset += 2;
} else {
cursor += 3;
offset += 3;
}
depth--;
}
} while (0 < depth);
node += offset;
}
}
return node;
}
ziU8 ZiDAWGgetEOWattribute(ziU32 node) {
return (nodeHeaderTable[*(ziU8*)node >> 4] & 0x10) > 0;
}
ziU32 ZiDAWGgetCHARattribute(ziPtr context, ziU32 node, ziPtr __zi8_work_data) {
ziU8 key;
ziU32 attribute;
if ((*(ziU8*)node & 0xf) == 0xf) {
key = (ziU32)*((ziU8*)node + 1) + 0xf;
} else {
key = (ziU32)*(ziU8*)node & 0xf;
}
if (key > ((zi8DawgCtx*)context)->cap) {
Zi8LogError(0x138b, __zi8_work_data);
return 0;
}
attribute = key << 24;
attribute |= ((ziU8*)((zi8DawgCtx*)context)->p0C)[key] << 16;
attribute += ((ziU32)((ziU8*)((zi8DawgCtx*)context)->p08)[key * 2] & 0xFFFF) << 8;
attribute += ((ziU8*)((zi8DawgCtx*)context)->p08)[key * 2 + 1];
Zi8LogError(0x64, __zi8_work_data);
return attribute;
}
ziU32 ZiDAWGGetGraph(ziPtr context) {
return (((ziU32)((zi8DawgCtx*)context)->table[2] & 0xFFFF) << 8) +
((zi8DawgCtx*)context)->table[3] +
((ziU32)((zi8DawgCtx*)context)->table + 4);
}
ziU32 ZiDAWGGetGraphInfo(zi8DawgCtx* context, ziU8* entry, ziU16* keys) {
ziU32 graph;
ziS32 result;
ziU32 end;
ziU8 depth;
ziU32 pair;
graph = ZiDAWGGetGraph(context);
result = 0;
pair = (((ziU16)entry[0] << 8) + entry[1]);
if (pair != 0) {
goto graph_invalid;
}
pair = (((ziU16)entry[2] << 8) + entry[3]);
if (pair == 0) {
goto graph_valid;
}
graph_invalid:
result = 0;
goto graph_done;
graph_valid:
end = (ziU32)(entry + (((ziU16)entry[4] << 8) + entry[5] + 1) * 10);
entry += 10;
depth = 0;
while ((depth < 2) && (*keys != 0)) {
if ((*keys < 0xeff1) || (0xf010 < *keys)) {
break;
}
while (1) {
if (*keys == (ziU16)(entry[3] + ((ziU16)entry[2] << 8))) {
break;
}
entry += (entry[1] + ((ziU16)entry[0] << 8)) * 10 + 10;
if ((end <= (ziU32)entry) ||
(*keys == (ziU16)(entry[3] + ((ziU16)entry[2] << 8)))) {
break;
}
}
if (end <= (ziU32)entry) {
result = 0;
break;
}
result = graph + (ziU32)entry[4] * 0x10000 + ((ziU16)entry[5] << 8) +
entry[6];
((zi8DawgCtx*)context)->unk_0x338 =
graph + (ziU32)entry[7] * 0x10000 + ((ziU16)entry[8] << 8) +
entry[9];
if (((zi8DawgCtx*)context)->unk_0x338 == graph) {
((zi8DawgCtx*)context)->unk_0x338 = 0;
}
if ((entry[1] + ((ziU16)entry[0] << 8)) == 0) {
break;
}
end = (ziU32)(entry + (entry[1] + ((ziU16)entry[0] << 8)) * 10 + 10);
entry += 10;
depth++;
keys++;
}
graph_done:
return result;
}

View File

@@ -1,419 +0,0 @@
#include <zi8clib/zierror.h>
#include <zi8clib/zitypes.h>
ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx, ziPtr workData);
ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx, ziPtr workData);
ziU8 Zi8_814813FC(ziWChar character, ziU8* result, ziU16* index, ziPtr workData) {
ziU16 i;
ziU8* table;
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 5, workData);
i = 0;
while (table[i] != 0) {
if (character == table[i]) {
*index = i;
*result = table[i];
Zi8LogError(0x64, workData);
return 1;
}
i++;
}
Zi8LogError(0x2A8, workData);
return 0;
}
ziU8 Zi8_81481E6C(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, ziPtr workData);
ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
ziPtr workData) {
struct {
ziU8 characterIndex;
ziU8 matched;
ziU8 elementIndex;
ziU16 index;
ziU16 currentCandidate;
ziU16 inputIndex;
ziU16 nextIndex;
ziU16 tableCount31;
ziU16 tableCount6;
ziU16 tableCount3;
ziU16 tableCount0;
ziU8* table31;
ziU8* table2;
ziU8* table1;
} state;
ziU16 buffer[100];
ziU8 result;
ziU16 currentCharacter;
ziU8* selectedTable;
state.nextIndex = 0;
result = 0;
state.characterIndex = 0xFF;
state.currentCandidate = params->firstCandidate;
params->letters = params->count = params->unk_0x20 = 0;
if ((argument != 0) && (*argument != 0)) {
Zi8LogError(0x7D0, workData);
return 0;
}
if ((params->elementCount == 0) || (params->elementCount > 100)) {
Zi8LogError(0x64, workData);
return 0;
}
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 4, workData);
state.table1 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 1, workData);
state.table2 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 2, workData);
state.table31 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x31, workData);
state.tableCount0 = Zi8GetTableCount(ZI8_LANG_KO, 0, workData);
state.tableCount3 = Zi8GetTableCount(ZI8_LANG_KO, 3, workData);
state.tableCount6 = Zi8GetTableCount(ZI8_LANG_KO, 6, workData);
state.tableCount31 = Zi8GetTableCount(ZI8_LANG_KO, 0x31, workData);
for (state.elementIndex = 0; state.elementIndex < params->elementCount;
state.elementIndex++) {
currentCharacter = params->elements[state.elementIndex];
if ((currentCharacter >= 0x61) && (currentCharacter <= 0x7A)) {
buffer[state.elementIndex] = state.table1[(currentCharacter - 0x61) * 2];
} else if ((currentCharacter >= 0x41) && (currentCharacter <= 0x5A)) {
buffer[state.elementIndex] = (state.table1 + (currentCharacter - 0x41) * 2)[1];
} else {
state.matched = 0;
for (; state.table2[state.matched * 3] != 0; state.matched++) {
if (currentCharacter == state.table2[state.matched * 3]) break;
}
if (state.table2[state.matched * 3] != 0) {
buffer[state.elementIndex] =
((ziU16)(state.table2 + state.matched * 3)[1] << 8) |
(state.table2 + state.matched * 3)[2];
} else {
Zi8LogError(0x161, workData);
return 0;
}
}
}
result = 0;
for (currentCharacter = 0; currentCharacter < state.elementIndex; currentCharacter++) {
if (Zi8_814813FC(buffer[currentCharacter], &state.characterIndex,
&state.inputIndex, workData) != 0) {
state.matched = Zi8_81481E6C(&state.nextIndex,
buffer + currentCharacter + 1,
state.characterIndex,
(state.elementIndex - currentCharacter) - 1,
workData);
if ((((struct __zi8_work_data_s*)workData)->unk_0x1B30 == 1)) {
switch (state.characterIndex) {
case 1:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1E, workData);
break;
case 2:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1F, workData);
break;
case 4:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x20, workData);
break;
case 7:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x21, workData);
break;
case 8:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x22, workData);
break;
case 9:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x23, workData);
break;
case 0x11:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x24, workData);
break;
case 0x12:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x25, workData);
break;
case 0x13:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x26, workData);
break;
case 0x15:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x27, workData);
break;
case 0x16:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x28, workData);
break;
case 0x17:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x29, workData);
break;
case 0x18:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x2A, workData);
break;
case 0x19:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x2B, workData);
break;
case 0x1A:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x2C, workData);
break;
case 0x1B:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x2D, workData);
break;
case 0x1C:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x2E, workData);
break;
case 0x1D:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x2F, workData);
break;
case 0x1E:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x30, workData);
break;
default:
break;
}
}
} else {
state.matched = 0;
}
if (state.matched != 0) {
if (state.tableCount6 == 0) {
state.nextIndex += state.inputIndex * state.tableCount3;
}
if (state.currentCandidate != 0) {
state.currentCandidate--;
} else {
params->candidates[(ziU8)result] =
((ziU16)selectedTable[state.nextIndex * 2] << 8) | (selectedTable + state.nextIndex * 2)[1];
if ((state.tableCount6 != 0) && (((struct __zi8_work_data_s*)workData)->unk_0x1B30 == 0)) {
params->candidates[(ziU8)result] += state.inputIndex * state.tableCount3;
}
result++;
}
if (currentCharacter == 0) {
params->count = state.matched + 1;
}
currentCharacter += state.matched;
} else {
if (state.currentCandidate != 0) {
state.index = 0;
for (; state.index < state.tableCount31; state.index++) {
if (state.table31[state.index * 3] == buffer[currentCharacter] &&
(state.table31 + state.index * 3)[1] == buffer[currentCharacter + 1]) break;
}
if (state.index == state.tableCount31) {
state.currentCandidate--;
}
if (currentCharacter == 0) {
params->count = 1;
}
} else {
for (state.index = 0; state.index < state.tableCount31; state.index++) {
if ((state.table31[(state.index * 3)] == buffer[currentCharacter]) &&
((state.table31 + state.index * 3)[1] == buffer[currentCharacter + 1])) {
if (currentCharacter == 0) {
params->count = 1;
}
params->candidates[(ziU8)result] =
state.tableCount0 + (state.table31 + state.index * 3)[2];
result++;
currentCharacter++;
break;
}
}
if (state.index == state.tableCount31) {
if ((params->candidates[(ziU8)result] = buffer[currentCharacter]) < 0xFF) {
if (currentCharacter == 0) {
params->count = 1;
}
params->candidates[(ziU8)result] += state.tableCount0;
result++;
}
}
}
}
if (result >= params->maxCandidates) {
break;
}
}
params->letters = result;
Zi8LogError(0x64, workData);
return result;
}
ziU8 Zi8_81481E6C(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, ziPtr workData) {
ziU16 nestedScratch;
ziU16 nestedIndexStorage;
ziU16 index1;
ziU16 index2;
ziU16 index3;
ziU16 index4;
ziU16 firstCharacter;
ziU16 tableCount;
ziU8 mappedCharacter;
ziU8* table;
firstCharacter = input[0];
mappedCharacter = 0xFF;
if (((struct __zi8_work_data_s*)workData)->unk_0x1B30 == 0) {
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 3, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 3, workData);
} else {
switch (type) {
case 1:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0xB, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0xB, workData);
break;
case 2:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0xC, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0xC, workData);
break;
case 4:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0xD, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0xD, workData);
break;
case 7:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0xE, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0xE, workData);
break;
case 8:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0xF, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0xF, workData);
break;
case 9:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x10, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x10, workData);
break;
case 0x11:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x11, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x11, workData);
break;
case 0x12:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x12, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x12, workData);
break;
case 0x13:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x13, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x13, workData);
break;
case 0x15:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x14, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x14, workData);
break;
case 0x16:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x15, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x15, workData);
break;
case 0x17:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x16, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x16, workData);
break;
case 0x18:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x17, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x17, workData);
break;
case 0x19:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x18, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x18, workData);
break;
case 0x1A:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x19, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x19, workData);
break;
case 0x1B:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1A, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x1A, workData);
break;
case 0x1C:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1B, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x1B, workData);
break;
case 0x1D:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1C, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x1C, workData);
break;
case 0x1E:
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1D, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 0x1D, workData);
break;
}
}
*resultIndex = 0;
if ((count < 1) || (firstCharacter >= 0xFF)) {
return 0;
}
index1 = *resultIndex;
for (; index1 < tableCount; index1++) {
if (table[index1 * 4] >= firstCharacter) {
break;
}
}
if ((index1 >= tableCount) || (firstCharacter != table[index1 * 4])) {
return 0;
}
if ((count < 2) || ((firstCharacter = input[1]) >= 0xFF)) {
*resultIndex = index1;
return 1;
}
index2 = index1;
for (; index2 < tableCount; index2++) {
if ((table + index2 * 4)[1] >= firstCharacter) {
break;
}
}
if ((index2 >= tableCount) || (firstCharacter != (table + index2 * 4)[1]) ||
(input[0] != table[index2 * 4])) {
*resultIndex = index1;
return 1;
}
if ((count < 3) || ((firstCharacter = input[2]) >= 0xFF)) {
*resultIndex = index2;
return 2;
}
index3 = index2;
for (; index3 < tableCount; index3++) {
if ((table + index3 * 4)[2] >= firstCharacter) {
break;
}
}
if ((index3 >= tableCount) || (firstCharacter != (table + index3 * 4)[2]) ||
(input[1] != (table + index3 * 4)[1]) || (input[0] != table[index3 * 4])) {
if ((Zi8_814813FC(input[1], &mappedCharacter, &nestedScratch, workData) != 0) &&
(Zi8_81481E6C(&nestedIndexStorage, input + 2, mappedCharacter, 1, workData) != 0)) {
*resultIndex = index1;
return 1;
}
*resultIndex = index2;
return 2;
}
if ((count < 4) || ((firstCharacter = input[3]) >= 0xFF)) {
*resultIndex = index3;
return 3;
}
index4 = index3;
for (; index4 < tableCount; index4++) {
if ((table + index4 * 4)[3] >= firstCharacter) {
break;
}
}
if ((index4 >= tableCount) || (firstCharacter != (table + index4 * 4)[3]) ||
(input[2] != (table + index4 * 4)[2]) || (input[1] != (table + index4 * 4)[1]) ||
(input[0] != table[index4 * 4])) {
if ((Zi8_814813FC(input[2], &mappedCharacter, &nestedScratch, workData) != 0) &&
(Zi8_81481E6C(&nestedIndexStorage, input + 3, mappedCharacter, 1, workData) != 0)) {
*resultIndex = index2;
return 2;
}
*resultIndex = index3;
return 3;
}
if ((count < 5) || ((firstCharacter = input[4]) >= 0xFF)) {
*resultIndex = index4;
return 4;
}
if ((Zi8_814813FC(input[3], &mappedCharacter, &nestedScratch, workData) != 0) &&
(Zi8_81481E6C(&nestedIndexStorage, input + 4, mappedCharacter, 1, workData) != 0)) {
*resultIndex = index3;
return 3;
}
*resultIndex = index4;
return 4;
}

View File

@@ -1,165 +0,0 @@
#include <stddef.h>
#include <zi8clib/zitypes.h>
#include <zi8clib/zierror.h>
typedef struct ziSearchState {
ziU32 flags;
ziWChar* word;
ziU32 length;
ziU32 position;
ziU32 capacity;
ziU32 options;
} ziSearchState;
typedef struct ziUserKeys {
ziWChar* upper[32];
ziWChar* lower[32];
} ziUserKeys;
typedef struct ziChineseEntry {
ziU8 data[9];
ziU8 offsetHigh;
ziU16 offsetLow;
} ziChineseEntry;
ziU8 Zi8GetCandidatesOrCount(ziGetParam*, ziSearchState* ZI_NEED_WORK);
ziU8 Zi8GetFormatVersion(ziU8 ZI_NEED_WORK);
ziPtr Zi8GetTableAddress(ziU8, ziU8 ZI_NEED_WORK);
ziU16 Zi8Uni2Ord(ziWChar ZI_NEED_WORK);
ziBool Zi8IsWordW(ziWChar* word, ziU8 language ZI_NEED_WORK) {
ziU8 remaining, group;
ziU16 value = 0;
ziWChar* cursor;
ziU8 formats[8] = {1, 5, 0, 0, 0, 0, 0, 0};
ziSearchState search;
ziGetParam request;
ziWChar ordinals[65];
ziU32 savedFormats = ZI_WORK->unk_0x1410;
ziU8 savedCount = ZI_WORK->unk_0x1418;
int length, count, offset;
int unmatched;
ziChineseEntry* entry;
ziU8* data;
search.flags = 0;
search.word = 0;
search.length = 0;
search.position = 0;
search.capacity = 0;
search.options = 0;
Zi8LogError(100, __zi8_work_data);
if (word == 0 || *word == 0) {
Zi8ReplaceLastError(300, __zi8_work_data);
return 0;
}
if (language != 1) {
for (length = 0; word[length] != 0; length++) {
if (word[length] > 0xEFF0 || length == 64) return 0;
}
((ziU8*)&search.length)[0] = length;
((ziU8*)&search.flags)[2] = 1;
((ziU16*)&search.capacity)[0] = 64;
search.word = word;
request.language = language;
request.getMode = 0;
request.subLanguage = 7;
request.context = 1;
request.getOptions = 0x81;
request.elements = word;
request.elementCount = length;
request.currentWord = 0;
request.wordCharCount = 0;
request.candidates = ordinals;
request.maxCandidates = 1;
request.firstCandidate = 0;
ZI_WORK->unk_0x1410 = (ziU32)formats;
if (ZI_WORK->unk_0x1C[0] == 2) {
ZI_WORK->unk_0x1418 = 0;
if (ZI_WORK->unk_0x09 & 1) formats[ZI_WORK->unk_0x1418++] = 1;
if (ZI_WORK->unk_0x09 & 4) formats[ZI_WORK->unk_0x1418++] = 2;
if (ZI_WORK->unk_0x09 & 2) formats[ZI_WORK->unk_0x1418++] = 3;
if (ZI_WORK->unk_0x09 & 8) formats[ZI_WORK->unk_0x1418++] = 4;
if (ZI_WORK->unk_0x09 & 1) formats[ZI_WORK->unk_0x1418++] = 5;
if (ZI_WORK->unk_0x09 & 4) formats[ZI_WORK->unk_0x1418++] = 6;
if (ZI_WORK->unk_0x09 & 2) formats[ZI_WORK->unk_0x1418++] = 7;
if (ZI_WORK->unk_0x09 & 8) formats[ZI_WORK->unk_0x1418++] = 8;
} else if (ZI_WORK->unk_0x1C[0] == 0) ZI_WORK->unk_0x1418 = 1;
else ZI_WORK->unk_0x1418 = 2;
count = Zi8GetCandidatesOrCount(&request, &search, __zi8_work_data);
ZI_WORK->unk_0x1410 = savedFormats;
ZI_WORK->unk_0x1418 = savedCount;
if (count != 0) return 1;
}
if (language == 1) {
length = 0;
do {
if (word[length] == 0) {
count = length - 1;
if (length == 1) return 1;
ordinals[count] |= 0x8000;
ZI_WORK->unk_0x16 = Zi8GetFormatVersion(1, __zi8_work_data) & 2;
entry = (ziChineseEntry*)Zi8GetTableAddress(1, 0, __zi8_work_data) + ordinals[0];
data = (ziU8*)Zi8GetTableAddress(1, 1, __zi8_work_data) + ((entry->offsetHigh & 15) << 16 | entry->offsetLow);
if (ZI_WORK->unk_0x16 != 0) {
group = *data & 7;
if (group == 5) offset = 4;
else if (group < 5) {
if (group == 2) offset = 2;
else if (group < 2) offset = 1;
else offset = 3;
} else offset = 1;
data += offset;
}
if ((*data & 0x80) == 0) return 0;
group = 0;
data += ((*data & 0x7F) >> 4) + 1;
while ((group & 0x80) == 0) {
group = *data++;
for (remaining = group & 15; remaining != 0; remaining--) {
unmatched = count;
cursor = ordinals;
while (unmatched > 0) {
value = data[0] | (data[1] << 8);
data += 2;
cursor++;
if (value != *cursor) break;
unmatched--;
if (value & 0x8000) break;
}
if (unmatched == 0) return 1;
if (!(value & 0x8000)) {
data++;
while (!(*data & 0x80)) data += 2;
data++;
}
}
}
Zi8LogError(0x2BD, __zi8_work_data);
return 0;
}
ordinals[length] = Zi8Uni2Ord(word[length], __zi8_work_data);
if (ordinals[length] == 0xFFFF) return 0;
length++;
} while (length != 64);
} else Zi8ReplaceLastError(0x26C, __zi8_work_data);
return 0;
}
ziWChar Zi8ConvertUC2UserKey(ziChar character, ziU8 language ZI_NEED_WORK) {
ziUserKeys* keys;
ziU16 key;
ziWChar* cursor;
if (character == 0 || language > 0x82 || (keys = ZI_WORK->userKeys[language]) == 0) return 0;
for (key = 0; key < 32; key++) {
for (cursor = keys->lower[key]; cursor != 0 && *cursor != 0; cursor++) {
if ((ziU16)*cursor == (ziU16)character) goto found;
}
for (cursor = keys->upper[key]; cursor != 0 && *cursor != 0; cursor++) {
if ((ziU16)*cursor == (ziU16)character) goto found;
}
}
found:
if (key < 32) {
if (key == 0) return 0xEFFA;
if (key >= 1 && key <= 9) return key + 0xEFF0;
if (key <= 31) return key + 0xEFF1;
}
return 0;
}

View File

@@ -3,14 +3,6 @@
extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
typedef struct {
ziU8 keyBytes[5];
ziU8 childHigh;
ziU8 childLow;
ziU8 characterHigh;
ziU8 characterLow;
} ZiKoreanKeyEntry;
ziU32 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) {
ziU32 value;
ziU16 count;
@@ -20,7 +12,7 @@ ziU32 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) {
for (i = 0; (ziU16)i < count; i++) {
value = (ziU16)(((ziU16)table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 7] << 8) |
table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 8]);
if (value == key) {
if (key == value) {
Zi8LogError(0x64, ZI_WORK);
return i;
}
@@ -99,7 +91,7 @@ ziU32 Zi8_81483308(ziGetParam* param, ziU16 key, ziU8* count ZI_NEED_WORK) {
return 0;
}
ziU32 Zi8_814833F0(const ziGetParam* param, ziU16 key ZI_NEED_WORK) {
ziBool Zi8_814833F0(const ziGetParam* param, ziU16 key ZI_NEED_WORK) {
ziU8 i;
Zi8LogError(0x64, ZI_WORK);
@@ -119,28 +111,23 @@ ziU32 Zi8_814833F0(const ziGetParam* param, ziU16 key ZI_NEED_WORK) {
ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count,
ziU8* inserted ZI_NEED_WORK) {
struct {
ziBool matches;
ziU8 candidateIndex;
ziU16 tableCount;
ziS32 compactIndex;
ZiKoreanKeyEntry* entry;
ziU8* tableB;
ziU8* tableA;
union {
ziU32 firstWord;
ziU8 bytes[5];
} keys;
} filter;
ziBool matches;
ziS32 entry;
ziS32 tableA;
ziS32 tableB;
ziU16 tableCount;
ziU8 matched;
ziU32 j;
ziS32 i;
ziS32 candidate;
ziU8 matched;
ziU8 candidateIndex;
union {
ziU32 words[13];
ziU8 bytes[52];
} local;
j = 0;
filter.candidateIndex = 0;
matched = 0;
filter.keys.bytes[4] = filter.keys.firstWord = 0;
local.words[0] = 0;
local.bytes[4] = 0;
Zi8LogError(0x64, ZI_WORK);
if (param->elementCount == 0) {
if (*remaining >= *count) {
@@ -154,354 +141,394 @@ ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count,
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
for (i = 0; i < ((ziS32)*count - (ziS32)*remaining); i++) {
param->candidates[i] = param->candidates[*remaining + i];
param->candidates[i] = param->candidates[(ziU32)*remaining + i];
}
*count -= *remaining;
*count = *count - (ziU8)*remaining;
*remaining = 0;
}
return 1;
}
if (param->elementCount > 9) {
*count = 0;
return 0;
}
filter.tableA = (ziU8*)Zi8GetTableAddress(param->language, 9, ZI_WORK);
filter.tableB = (ziU8*)Zi8GetTableAddress(param->language, 10, ZI_WORK);
if (filter.tableA == 0) {
} else if (param->elementCount <= 9) {
tableA = Zi8GetTableAddress(param->language, 9, ZI_WORK);
tableB = Zi8GetTableAddress(param->language, 10, ZI_WORK);
if (tableA == 0) {
Zi8ReplaceLastError(0x76C, ZI_WORK);
return 0;
} else if (filter.tableB == 0) {
} else if (tableB == 0) {
Zi8ReplaceLastError(0x776, ZI_WORK);
return 0;
} else {
filter.tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, filter.keys.bytes);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, local.bytes);
i = 0;
while (i < filter.tableCount && matched < *count) {
filter.matches = ZI8_TRUE;
filter.entry = (ZiKoreanKeyEntry*)&filter.tableA[(i << 3) + i];
while (i < tableCount && matched < *count) {
matches = ZI8_TRUE;
entry = (i << 3) + tableA + i;
j = 0;
if (param->elementCount > 1) {
for (j = 0; (int)(j & 0xFF) < (int)param->elementCount / 2; j++) {
if (filter.keys.bytes[j & 0xFF] != filter.entry->keyBytes[j & 0xFF]) {
filter.matches = ZI8_FALSE;
for (j = 0; (j & 0xFF) < (ziU32)(param->elementCount >> 1); j++) {
if (local.bytes[j & 0xFF] != *((ziU8*)entry + (j & 0xFF))) {
matches = ZI8_FALSE;
break;
}
}
}
if (filter.matches && (param->elementCount % 2) != 0 &&
((filter.keys.bytes[j & 0xFF] & 0xF0) != (filter.entry->keyBytes[j & 0xFF] & 0xF0))) {
filter.matches = ZI8_FALSE;
if (matches && (param->elementCount & 1) != 0 &&
((local.bytes[j & 0xFF] & 0xF0) != (*((ziU8*)entry + (j & 0xFF)) & 0xF0))) {
matches = ZI8_FALSE;
}
if (filter.matches) {
for (filter.candidateIndex = 0; filter.candidateIndex < *count; filter.candidateIndex++) {
if (param->candidates[filter.candidateIndex] ==
(((ziU16)((ZiKoreanKeyEntry*)filter.tableA)[i].characterHigh << 8) | (ziU16)((ZiKoreanKeyEntry*)filter.tableA)[i].characterLow)) {
if (matches) {
for (candidateIndex = 0; candidateIndex < *count; candidateIndex++) {
if (param->candidates[candidateIndex] ==
(ziU16)((*((ziU8*)entry + 7) << 8) | *((ziU8*)entry + 8))) {
matched++;
param->candidates[filter.candidateIndex] &= 0x7FFF;
param->candidates[candidateIndex] =
param->candidates[candidateIndex] & 0x7FFF;
break;
}
}
}
i++;
}
if (matched >= *remaining) {
if ((ziU16)matched >= *remaining) {
matched = *count;
*count = 0;
for (candidate = 0; candidate < matched; candidate++) {
if ((param->candidates[candidate] & 0x8000) == 0) {
param->candidates[candidate] |= 0x8000;
if (*remaining != 0) {
--*remaining;
Zi8_81483308(param, param->candidates[candidate], inserted, ZI_WORK);
} else {
if (*count != candidate) {
param->candidates[*count] = param->candidates[candidate];
for (i = 0; i < matched; i++) {
if ((param->candidates[i] & 0x8000) == 0) {
param->candidates[i] = param->candidates[i] | 0x8000;
if (*remaining == 0) {
if (*count != i) {
param->candidates[*count] = param->candidates[i];
}
++*count;
*count = *count + 1;
} else {
*remaining = *remaining - 1;
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
}
}
*remaining = 0;
} else {
for (filter.compactIndex = 0; filter.compactIndex < *count; filter.compactIndex++) {
if ((param->candidates[filter.compactIndex] & 0x8000) == 0) {
param->candidates[filter.compactIndex] |= 0x8000;
Zi8_81483308(param, param->candidates[filter.compactIndex], inserted, ZI_WORK);
for (i = 0; i < *count; i++) {
if ((param->candidates[i] & 0x8000) == 0) {
param->candidates[i] = param->candidates[i] | 0x8000;
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
}
*remaining = *remaining - matched;
*remaining = *remaining - (ziU16)matched;
*count = 0;
}
}
} else {
*count = 0;
return 0;
}
return 0;
}
typedef struct {
ziU8 countOnly;
ziU8 maxWordLength;
ziU8 lookupMode;
ziU8 suffixOnly;
ziU8 controls[8];
ziU32 maxCount;
ziU16 capacity;
ziU8 minWordLength;
ziU8 flags;
ziU16 candidateCapacity;
ziU8 checkOnly;
ziU8 reserved;
} ZiKoreanCandidateOptions;
ziU32 Zi8GetKOcandidates(ziGetParam* param, ziU8* options ZI_NEED_WORK) {
ziBool bVar1;
ziU8 bVar2;
ziS32 iVar4;
ziU32 uVar6;
ziU8* pbVar7;
union {
ziU32 words[10];
ziU8 bytes[40];
} local_28;
ziU8 local_57;
ziU8 local_56;
ziU8 local_55;
ziU8 local_54;
ziU8 local_53;
ziS8 local_52;
ziU16 local_50;
ziU16 local_4E;
ziU16 local_4C;
ziU16 local_4A;
ziU16 local_48;
ziS32 local_44;
ziS32 local_2C;
ziS32 local_30;
ziU32 local_34;
ziU32 local_38;
ziU32 local_3C;
ziU32 local_40;
ziU32 Zi8GetKOcandidates(ziGetParam* param, ZiKoreanCandidateOptions* options ZI_NEED_WORK) {
struct {
ziBool matches;
ziU8 inserted;
ziU8 matchPass;
ziU8 keyByte;
ziU8 candidateCount;
ziU8 wordIndex;
ziU8 remainingLetters;
ziU16 remainingCandidates;
ziU16 previousIndex;
ziU16 character;
ziU16 tableCount;
ziU16 keyIndex;
ZiKoreanKeyEntry* entry;
ziS32 candidateIndex;
ziS32 prefixCount;
ziU32 wordOffset;
ziS32 resultCount;
ziS32 tableIndex;
ziU8* wordTable;
union {
ziU32 firstWord;
ziU8 bytes[5];
} packedKeys;
} search;
ziU8* keyTable;
ziU8* wordNode;
search.previousIndex = 0xFFFF;
search.resultCount = 0;
search.packedKeys.firstWord = 0;
search.packedKeys.bytes[4] = 0;
search.remainingLetters = 0;
search.wordIndex = 0;
search.candidateCount = 0;
search.keyByte = 0;
search.remainingCandidates = param->firstCandidate;
search.prefixCount = 0;
search.candidateIndex = 0;
search.inserted = 0;
local_4E = 0xFFFF;
local_34 = 0;
local_28.words[0] = 0;
local_28.bytes[4] = 0;
local_52 = 0;
local_53 = 0;
local_54 = 0;
local_55 = 0;
local_50 = param->firstCandidate;
local_3C = 0;
local_40 = 0;
local_57 = 0;
Zi8LogError(100, ZI_WORK);
Zi8_81483264(param, ZI_WORK);
keyTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 9, ZI_WORK);
search.wordTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 10, ZI_WORK);
if (keyTable == 0) {
iVar4 = Zi8GetTableAddress(ZI8_LANG_KO, 9, ZI_WORK);
local_2C = Zi8GetTableAddress(ZI8_LANG_KO, 10, ZI_WORK);
if (iVar4 == 0) {
Zi8ReplaceLastError(0x76C, ZI_WORK);
return 0;
uVar6 = 0;
} else {
if (search.wordTable == 0) {
if (local_2C == 0) {
Zi8ReplaceLastError(0x776, ZI_WORK);
return 0;
uVar6 = 0;
goto LAB_000114C4;
}
if (options->countOnly == 0) {
if (*options == 0) {
param->letters = 0;
param->unk_0x20 = 0;
param->count = 0;
param->candidates[0] = 0;
}
Zi8LogError(100, ZI_WORK);
if (param->wordCharCount != 0) {
if (((search.keyIndex = Zi8_8148302C(param->currentWord[0], keyTable, ZI_WORK)) != 0xFFFF) &&
((((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->keyBytes[4] & 8) != 0)) {
search.wordOffset = ((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childLow |
((((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->keyBytes[4] & 3) << 16 |
((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childHigh << 8);
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
wordNode = search.wordTable + search.wordOffset;
match_word:
while (search.remainingLetters != 0) {
search.keyIndex = Zi8_8148302C(param->currentWord[search.wordIndex], (ziU8*)keyTable, ZI_WORK);
if (search.keyIndex == (((ziU16)*wordNode & 0x1F) << 8 | (ziU16)wordNode[1])) {
--search.remainingLetters;
++search.wordIndex;
if ((*wordNode & 0x40) != 0) {
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
break;
local_48 = Zi8_8148302C(param->currentWord[0], (ziU8*)iVar4, ZI_WORK);
if ((local_48 != 0xFFFF) &&
((((ziU8*)iVar4)[((ziU32)local_48 * 9) + 4] & 8) != 0)) {
local_38 = (ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 6] |
((ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 4] & 3) << 16 |
(ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 5] << 8;
local_52 = param->wordCharCount - 1;
local_53 = 1;
pbVar7 = (ziU8*)(local_2C + local_38);
LAB_00010D44:
if (local_52 != 0) {
local_48 = Zi8_8148302C(param->currentWord[local_53], (ziU8*)iVar4, ZI_WORK);
if (local_48 == (ziU16)((*pbVar7 & 0x1F) << 8 | pbVar7[1])) {
local_52 = local_52 - 1;
local_53 = local_53 + 1;
if ((*pbVar7 & 0x40) == 0) {
pbVar7 = pbVar7 + 2;
goto LAB_00010D44;
}
wordNode += 2;
local_52 = param->wordCharCount - 1;
local_53 = 1;
} else {
search.wordIndex = 1;
search.remainingLetters = param->wordCharCount - 1;
break;
local_53 = 1;
local_52 = param->wordCharCount - 1;
}
}
if (search.remainingLetters == 0) {
search.keyIndex = ((ziU16)*wordNode & 0x1F) << 8 | (ziU16)wordNode[1];
search.character = (ziU16)((ziU16)((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->characterHigh << 8 |
((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->characterLow);
if (local_52 == 0) {
local_48 = (*pbVar7 & 0x1F) << 8 | pbVar7[1];
local_4C = (ziU16)(((ziU8*)((ziU32)local_48 * 9 + (ziU32)local_48 + (ziU32)iVar4))[7] << 8 |
((ziU8*)((ziU32)local_48 * 9 + (ziU32)local_48 + (ziU32)iVar4))[8]);
if (param->wordCharCount == 1) {
if (search.keyIndex == search.previousIndex) {
for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) {
if (local_48 == local_4E) {
for (; (*pbVar7 & 0x40) == 0; pbVar7 = pbVar7 + 2) {
}
wordNode += 2;
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
goto next_word;
local_52 = param->wordCharCount;
goto LAB_00011114;
}
search.previousIndex = search.keyIndex;
local_4E = local_48;
if (param->elementCount == 0) {
if (search.remainingCandidates != 0) {
--search.remainingCandidates;
} else {
if (options->countOnly != 0) {
if (++search.prefixCount < (ziS32)options->maxCount) {
goto skip_word;
if (local_50 == 0) {
if (*options != 0) {
local_3C = local_3C + 1;
if ((ziS32)local_3C < *(ziS32*)(options + 0xC)) {
goto LAB_000110E8;
}
return options->maxCount;
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->candidates[search.candidateCount++] = search.character;
++param->unk_0x20;
if (++param->letters >= param->maxCandidates) {
return param->letters;
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
uVar6 = param->letters;
goto LAB_000114C4;
}
} else {
local_50 = local_50 + -1;
}
} else {
param->candidates[search.candidateCount++] = search.character;
++param->unk_0x20;
if (++param->letters >= param->maxCandidates) {
Zi8_814834AC(param, &search.remainingCandidates, &search.candidateCount, &search.inserted, ZI_WORK);
param->unk_0x20 = search.candidateCount;
param->letters = search.candidateCount;
if (search.candidateCount < param->maxCandidates) goto skip_word;
if (options->countOnly != 0) {
if ((search.prefixCount += search.candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
param->unk_0x20 = 0;
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
param->count = local_54;
param->letters = local_54;
if (param->maxCandidates <= local_54) {
if (*options == 0) {
uVar6 = local_54;
goto LAB_000114C4;
}
local_3C = local_3C + local_54;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_3C) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->count = 0;
param->letters = 0;
search.candidateCount = 0;
} else {
return search.candidateCount;
local_54 = 0;
}
}
}
} else {
for (search.candidateIndex = 0; search.candidateIndex < search.candidateCount; search.candidateIndex++) {
if (search.character == param->candidates[search.candidateIndex]) break;
for (local_40 = 0;
(local_40 < local_54 &&
(local_4C != param->candidates[local_40]));
local_40 = local_40 + 1) {
}
if ((search.candidateIndex == search.candidateCount) &&
(Zi8_814833F0(param, search.character, ZI_WORK) == 0)) {
param->candidates[search.candidateCount++] = search.character;
++param->unk_0x20;
if (++param->letters < param->maxCandidates) {
goto skip_word;
if ((local_40 == local_54) &&
(Zi8_814833F0(param, local_4C, ZI_WORK) == 0)) {
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (bVar2 < param->maxCandidates) {
goto LAB_000110E8;
}
Zi8_814834AC(param, &search.remainingCandidates, &search.candidateCount, &search.inserted, ZI_WORK);
param->unk_0x20 = search.candidateCount;
param->letters = search.candidateCount;
if (search.candidateCount < param->maxCandidates) goto skip_word;
if (options->countOnly != 0) {
if ((search.prefixCount += search.candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
param->unk_0x20 = 0;
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
param->count = local_54;
param->letters = local_54;
if (param->maxCandidates <= local_54) {
if (*options == 0) {
uVar6 = local_54;
goto LAB_000114C4;
}
local_3C = local_3C + local_54;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_3C) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->count = 0;
param->letters = 0;
search.candidateCount = 0;
} else {
return search.candidateCount;
local_54 = 0;
}
}
}
}
skip_word:
for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) {
LAB_000110E8:
for (; (*pbVar7 & 0x40) == 0; pbVar7 = pbVar7 + 2) {
}
wordNode += 2;
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
next_word:
if ((*wordNode & 0x80) != 0) {
goto search_table;
local_52 = param->wordCharCount;
LAB_00011114:
local_52 = local_52 + -1;
local_53 = 1;
pbVar7 = pbVar7 + 2;
if ((*pbVar7 & 0x80) != 0) {
goto LAB_00011124;
}
goto match_word;
goto LAB_00010D44;
}
}
search_table:
search.resultCount = search.prefixCount;
if (search.candidateCount != 0) {
Zi8_814834AC(param, &search.remainingCandidates, &search.candidateCount, &search.inserted, ZI_WORK);
if (options->countOnly != 0) {
if ((search.prefixCount += search.candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
search.resultCount = search.prefixCount;
LAB_00011124:
local_34 = local_3C;
if (local_54 != 0) {
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
uVar6 = local_34;
if ((*options != 0) &&
(local_3C = local_3C + local_54, uVar6 = local_3C,
*(ziS32*)(options + 0xC) <= (ziS32)local_3C)) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->unk_0x20 = search.candidateCount;
param->letters = search.candidateCount;
local_34 = uVar6;
param->count = local_54;
param->letters = local_54;
}
if (param->elementCount > 9) {
param->letters = 0;
return 0;
}
{
if (param->elementCount != 0 && options->countOnly == 0) {
search.matchPass = 0;
if (param->elementCount < 10) {
if ((param->elementCount == 0) || (*options != 0)) {
local_56 = 1;
} else {
search.matchPass = 1;
local_56 = 0;
}
search.tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, search.packedKeys.bytes);
local_4A = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, local_28.bytes);
do {
for (search.tableIndex = 0; search.tableIndex < search.tableCount; search.tableIndex = search.tableIndex + 1) {
search.matches = ZI8_TRUE;
search.entry = (ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable);
search.keyByte = 0;
for (local_30 = 0; local_30 < (ziS32)(ziU32)local_4A; local_30 = local_30 + 1) {
bVar1 = ZI8_TRUE;
local_44 = iVar4 + local_30 * 9;
local_55 = 0;
if (1 < param->elementCount) {
for (search.keyByte = 0;
(ziS32)search.keyByte < (int)param->elementCount / 2;
search.keyByte++) {
if (search.packedKeys.bytes[search.keyByte] != search.entry->keyBytes[search.keyByte]) {
search.matches = ZI8_FALSE;
for (local_55 = 0;
(ziU32)local_55 < (ziU32)((ziS32)(ziU32)param->elementCount >> 1);
local_55 = local_55 + 1) {
if (local_28.bytes[local_55] != *(ziU8*)(local_44 + local_55)) {
bVar1 = ZI8_FALSE;
break;
}
}
}
if ((search.matches && ((param->elementCount % 2) != 0)) &&
((search.packedKeys.bytes[search.keyByte] & 0xF0) !=
(search.entry->keyBytes[search.keyByte] & 0xF0))) {
search.matches = ZI8_FALSE;
if ((bVar1 && ((param->elementCount & 1) != 0)) &&
((local_28.bytes[local_55] & 0xF0) !=
(*(ziU8*)(local_44 + local_55) & 0xF0))) {
bVar1 = ZI8_FALSE;
}
if (search.matches) {
if (param->elementCount % 2 != 0) {
if ((search.entry->keyBytes[search.keyByte] & 0xF) != 0) {
if (search.matchPass == 0) goto next_entry;
} else if (search.matchPass != 0 && options->countOnly == 0) {
goto next_entry;
if (bVar1) {
bVar2 = local_56;
if ((param->elementCount & 1) == 0) {
if ((*(ziU8*)(local_44 + local_55) & 0xF0) == 0) {
if (local_56 == 0) {
goto LAB_000113B0;
}
bVar2 = *options;
}
if (bVar2 == 0) {
goto LAB_00011478;
}
} else {
if ((search.entry->keyBytes[search.keyByte] & 0xF0) != 0) {
if (search.matchPass == 0) goto next_entry;
} else if (search.matchPass != 0 && options->countOnly == 0) {
goto next_entry;
if ((*(ziU8*)(local_44 + local_55) & 0xF) != 0) {
goto LAB_000113AC;
}
if (local_56 != 0) {
bVar2 = *options;
goto LAB_000113AC;
}
}
if (search.remainingCandidates != 0) {
--search.remainingCandidates;
} else if (options->countOnly != 0) {
if (++search.resultCount >= (ziS32)options->maxCount) return options->maxCount;
LAB_000113AC:
if (bVar2 == 0) {
goto LAB_00011478;
}
LAB_000113B0:
if (local_50 == 0) {
if (*options == 0) {
param->candidates[local_54] =
(ziU16)((*(ziU8*)(local_30 * 9 + iVar4 + 7) << 8) |
*(ziU8*)(local_30 * 9 + iVar4 + 8));
local_54 = local_54 + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
uVar6 = param->letters;
goto LAB_000114C4;
}
} else {
local_34 = local_34 + 1;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_34) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
}
} else {
param->candidates[search.candidateCount++] =
(ziU16)((ziU16)((ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable))->characterHigh << 8 |
((ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable))->characterLow);
if (++param->letters >= param->maxCandidates) return param->letters;
local_50 = local_50 + -1;
}
}
next_entry:
LAB_00011478:
;
}
} while (++search.matchPass < 2);
local_56 = local_56 + 1;
} while (local_56 < 2);
uVar6 = local_34;
if (*options == 0) {
uVar6 = param->letters;
}
} else {
param->letters = 0;
uVar6 = 0;
}
if (options->countOnly != 0) return search.resultCount;
return param->letters;
}
return 0;
LAB_000114C4:
return uVar6;
}

View File

@@ -1,215 +0,0 @@
#include <zi8clib/zconvert.h>
#include <zi8clib/zierror.h>
#include <zi8clib/zmtkey.h>
typedef struct ziUserKeyMap { ziWChar* upper[32]; ziWChar* lower[32]; } ziUserKeyMap;
ziU16 Zi8GetTableCount(ziU8 language, ziU8 tableIndex, ziPtr __zi8_work_data);
ziU32 Zi8GetTableAddress(ziU8 language, ziU8 tableIndex, ziPtr __zi8_work_data);
ziU8 Zi8getKeyLayout(ziU8 language, ziWChar key, ziWChar* chars, ziU8 mode, ziPtr __zi8_work_data);
ziBool Zi8_81484484(ziWChar character, ziWChar* output, ziPtr __zi8_work_data) {
if (character == 0xeffa) {
*output = 0;
} else if ((character >= 0xeff1) && (character <= 0xeff9)) {
*output = character - 0xeff0;
} else if ((character >= 0xeffb) && (character <= 0xf010)) {
*output = character - 0xeff1;
} else {
return 0;
}
return 1;
}
static ziU8 ziNumKeysWithChars(ziU8 language, ziPtr __zi8_work_data) {
ziU16 tableCount;
ziU8* table;
ziU32 totalCharacters;
ziU32 keyIndex;
tableCount = Zi8GetTableCount(language, 0x1e, __zi8_work_data);
table = (ziU8*)Zi8GetTableAddress(language, 0x1e, __zi8_work_data);
if (tableCount == 0) {
return 0x0c;
}
keyIndex = totalCharacters = 0;
for (; (ziU16)keyIndex < 0x20; keyIndex++) {
totalCharacters += table[(ziU16)keyIndex];
}
if ((ziS32)tableCount >= (((ziS32)(totalCharacters & 0xffff) * 4) + 0x20)) {
return 0x20;
}
return 0x0c;
}
ziBool Zi8getKeyLayout(ziU8 language, ziWChar key, ziWChar* chars, ziU8 mode, ziPtr __zi8_work_data) {
ziU8 numKeys;
ziU16 tableCount;
ziU8* dataAddress;
ziUserKeyMap* customTable;
ziU32 totalCharacters;
ziU16 charCount;
ziU32 keyIndex;
ziWChar* keyChars;
dataAddress = 0;
numKeys = ziNumKeysWithChars(language, __zi8_work_data);
Zi8LogError(0x64, __zi8_work_data);
*chars = 0;
if (ZI_WORK->userKeys[language] != 0) {
customTable = ZI_WORK->userKeys[language];
if (!Zi8_81484484(key, &key, __zi8_work_data)) {
return 0;
}
keyChars = customTable->lower[key];
for (keyIndex = 0; keyChars[(ziU16)keyIndex] != 0; keyIndex++) {
chars[(ziU16)keyIndex] = keyChars[(ziU16)keyIndex];
}
chars[(ziU16)keyIndex] = 0;
return 1;
} else {
if (mode == 1) {
goto table_1e;
}
if ((tableCount = Zi8GetTableCount(language, 0x1d, __zi8_work_data)) == 0) {
goto table_1e;
}
{
dataAddress = (ziU8*)Zi8GetTableAddress(language, 0x1d, __zi8_work_data);
goto tables_ready;
}
table_1e:
if ((tableCount = Zi8GetTableCount(language, 0x1e, __zi8_work_data)) != 0) {
dataAddress = (ziU8*)Zi8GetTableAddress(language, 0x1e, __zi8_work_data);
}
tables_ready:
if (dataAddress == 0) {
Zi8ReplaceLastError(0x962, __zi8_work_data);
return 0;
}
if (!Zi8_81484484(key, &key, __zi8_work_data) || (key >= numKeys)) {
Zi8ReplaceLastError(300, __zi8_work_data);
return 0;
}
totalCharacters = 0;
keyIndex = totalCharacters;
for (; (ziU16)keyIndex < key; keyIndex++) {
totalCharacters += dataAddress[(ziU16)keyIndex];
}
if ((charCount = (ziU8)dataAddress[key]) == 0) {
return 0;
}
dataAddress = dataAddress + numKeys + ((totalCharacters & 0xffff) * 2);
keyIndex = 0;
for (; (ziU16)keyIndex < charCount; keyIndex++) {
chars[(ziU16)keyIndex] = (ziU16)dataAddress[(ziU16)keyIndex * 2] |
((ziU16)dataAddress[((ziU16)keyIndex * 2) + 1] << 8);
}
chars[(ziU16)keyIndex] = 0;
return 1;
}
}
ziBool Zi8ChangeCharCase(ziBool upper, ziWChar* character, ziU8 language ZI_NEED_WORK) {
ziU8 changed;
ziU16 total;
ziU16 tableCount;
ziU8* dataAddress;
ziUserKeyMap* customTables;
ziU8 numKeys;
ziS16 direction;
ziU16 result;
ziS32 keyIndex;
ziPtr from;
ziPtr to;
ziS32 characterIndex;
customTables = 0;
dataAddress = 0;
changed = 0;
numKeys = 0x20;
Zi8LogError(0x64, ZI_WORK);
if (ZI_WORK->userKeys[language] != 0) {
customTables = (ziUserKeyMap*)ZI_WORK->userKeys[language];
} else if (ZI_WORK->unk_0x11FC != 0) {
customTables = (ziUserKeyMap*)ZI_WORK->unk_0x11FC;
} else {
tableCount = Zi8GetTableCount(language, 0x1e, ZI_WORK);
if (tableCount != 0) {
dataAddress = (ziU8*)Zi8GetTableAddress(language, 0x1e, ZI_WORK);
numKeys = ziNumKeysWithChars(language, ZI_WORK);
} else {
Zi8ReplaceLastError(0x138d, ZI_WORK);
return 0;
}
}
if (customTables != 0) {
for (keyIndex = 0; (changed == 0) && (keyIndex < (ziS32)(ziU32)numKeys); keyIndex++) {
if (upper != 0) {
from = (ziPtr)customTables->lower[keyIndex];
to = (ziPtr)customTables->upper[keyIndex];
} else {
from = (ziPtr)customTables->upper[keyIndex];
to = (ziPtr)customTables->lower[keyIndex];
}
if ((from != 0) && (to != 0)) {
for (characterIndex = 0; ((ziU16)((ziS16*)from)[characterIndex]) != 0; characterIndex++) {
if ((ziU16)((ziS16*)from)[characterIndex] == *character) {
*character = (ziU16)((ziWChar*)to)[characterIndex];
changed = 1;
break;
}
}
}
}
}
else if (dataAddress != 0) {
total = 0;
for (keyIndex = 0; keyIndex < (ziS32)(ziU32)numKeys; keyIndex++) {
total += dataAddress[keyIndex];
}
dataAddress = dataAddress + numKeys;
direction = 1;
if (upper == 0) {
dataAddress = dataAddress + ((ziU32)total * 2);
direction = -1;
}
for (keyIndex = 0; keyIndex < (ziS32)(ziU32)total; keyIndex++) {
tableCount = (ziU16)(dataAddress[(keyIndex * 2)] |
((ziU16)dataAddress[(keyIndex * 2) + 1] << 8));
if (tableCount == *character) {
dataAddress = dataAddress + ((ziS32)direction * ((ziU32)total * 2));
*character = (ziU16)(dataAddress[(keyIndex * 2)] |
((ziU16)dataAddress[(keyIndex * 2) + 1] << 8));
changed = 1;
break;
}
}
}
if (changed == 0) {
result = 0;
if (upper != 0) {
if (((*character >= 0x61) && (*character <= 0x7a)) || ((*character >= 0xf1) && (*character <= 0xf6)) ||
((*character >= 0xf8) && (*character <= 0xfe)) || ((*character >= 0xe0) && (*character <= 0xef))) {
result = *character - 0x20;
} else if (*character == 0xff) {
result = 0x178;
}
} else {
if (((*character >= 0x41) && (*character <= 0x5a)) || ((*character >= 0xd1) && (*character <= 0xd6)) ||
((*character >= 0xd8) && (*character <= 0xde)) || ((*character >= 0xc0) && (*character <= 0xcf))) {
result = *character + 0x20;
} else if (*character == 0x178) {
result = 0xff;
}
}
if ((result != 0) && Zi8ConvertWC2UC(result, language, ZI_WORK)) {
*character = result;
changed = 1;
}
}
return changed;
}

View File

@@ -1,70 +0,0 @@
#include <stddef.h>
#include <zi8clib/zitypes.h>
#include <zi8clib/zierror.h>
#include <zi8clib/zconvert.h>
#include <zi8clib/zmtkey.h>
ziU8 Zi8AttachOEMdata(ziU8 (*match)(ziU16, ziWChar*, ziU8, ziPtr), ziU16 count, ziPtr data ZI_NEED_WORK) {
ZI_WORK->oemMatch = match;
ZI_WORK->oemLen = count;
ZI_WORK->oemData = data;
Zi8LogError(100, __zi8_work_data);
return 1;
}
ziU8 Zi8DetachOEMdata(ziU8 id ZI_NEED_WORK) {
Zi8LogError(100, __zi8_work_data);
if (id != 1 || ZI_WORK->oemMatch == 0) return 0;
{
ZI_WORK->oemMatch = 0;
ZI_WORK->oemLen = 0;
return 1;
}
return 0;
}
ziU8 Zi8MatchOEMdata(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* word, ziU16 capacity, ziBool complete, ziBool continuation ZI_NEED_WORK) {
ziWChar folded;
ziU8 fallback = 0;
ziU32 index;
ziU32 position;
if (!continuation) ZI_WORK->oemIdx = 0;
index = ZI_WORK->oemIdx;
if ((ziS32)index >= ZI_WORK->oemLen || ZI_WORK->oemMatch == 0) goto noMatch;
capacity--;
if (length >= capacity) goto noMatch;
word[capacity] = 0;
word[length] = complete ? 1 : 0;
for (;;) {
if ((ziS32)index >= ZI_WORK->oemLen || !ZI_WORK->oemMatch(index, word, capacity, ZI_WORK->oemData)) {
if (length != 1 || !complete || continuation) goto noMatch;
complete = 0;
fallback = 1;
index = 0;
continue;
}
position = 0;
if ((complete && word[length] == 0) || (!complete && word[length] != 0)) {
for (; (ziS32)position < length; position++) {
if (pattern[position] < 0xEFF1 || pattern[position] > 0xF37F) {
if (word[position] != pattern[position]) {
if (!ZI_WORK->unk_0x1F || language == 1) break;
folded = pattern[position];
if (!Zi8ChangeCharCase(1, &folded, language, __zi8_work_data) || folded != word[position]) break;
}
} else if (pattern[position] != Zi8ConvertWC2Key(word[position], language, __zi8_work_data)) break;
}
}
if ((ziS32)position >= length) {
if (fallback) {
*word = *pattern;
return 1;
}
ZI_WORK->oemIdx = index + 1;
while (word[position] != 0) position++;
return position;
}
word[length] = complete ? 1 : 0;
index++;
}
noMatch:
return 0;
}

View File

@@ -1,336 +0,0 @@
#include <zi8clib/zitypes.h>
void Zi8Memset(ziPtr, ziU32, ziU32);
void Zi8Memcpy(ziPtr, ziPtr, ziU32);
ziBool Zi8IsComponent(ziWChar ZI_NEED_WORK);
ziU32 Zi8GetTableAddress(ziU8, ziU8 ZI_NEED_WORK);
ziU16 Zi8GetTableCount(ziU8, ziU8 ZI_NEED_WORK);
ziU8 Zi8GetPyPhonetic(ziWChar*, ziU8, ziWChar*, ziWChar*, ziU8*, ziWChar*, ziWChar* ZI_NEED_WORK);
ziU8 Zi8GetBpmfPhonetic(ziWChar*, ziU8, ziWChar*, ziWChar*, ziWChar*, ziWChar* ZI_NEED_WORK);
ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode ZI_NEED_WORK) {
ziU16 element;
ziU16 phoneticCount;
ziU16 phoneticInitial;
ziU16 phoneticMask;
ziU16 phoneticCode;
ziU16 phoneticLength;
ziWChar initial;
ziWChar final;
ziWChar bestInitial;
ziWChar bestFinal;
ziWChar previousInitial;
ziWChar previousFinal;
ziU8 elementCount;
ziU8 elementIndex;
ziU8 stroke;
ziU8 contextMask;
ziU8 mode;
ziU8 savedNibbles;
struct {
ziWChar* phoneticInput;
ziU8* phoneticTable;
ziU8 strokePrefix[4];
ziU8 maskPrefix[4];
ziU8* componentIndex;
ziU8* component;
ziU8 strokes[12];
ziU8 masks[12];
} buffers;
ziU8 nibbles;
ziU8 index;
stroke = 0;
contextMask = 0x20;
Zi8Memset(match,0,0x1ee);
nibbles = 0;
elementIndex = 0;
elementCount = request->elementCount;
while (elementCount != 0) {
if (request->elements[elementCount - 1] != 0xEF09) break;
elementCount--;
}
match->count = elementCount;
for (index = 0; index < elementCount; index++) {
if (request->elements[index] != 0xEF00) {
match->count = 0;
break;
}
}
if (elementCount != 0) {
match->comp = element = request->elements[0];
if (Zi8IsComponent(element,__zi8_work_data) != 0) {
elementIndex++;
buffers.component = (ziU8*)Zi8GetTableAddress(1,2,__zi8_work_data);
buffers.componentIndex = (ziU8*)Zi8GetTableAddress(1,6,__zi8_work_data);
buffers.componentIndex += (element - 0xef10) * 2;
match->field22 = (((ziU16)buffers.componentIndex[1] & 0x3f) << 8) + *buffers.componentIndex;
buffers.component += (ziU32)match->field22 * 8;
switch(*buffers.component & 0xf) {
case 0:
case 9:
case 10:
default:
break;
case 1:
match->comp = 0xEF00 + 4;
break;
case 2:
match->comp = 0xEF00 + 1;
break;
case 3:
case 0xb:
match->comp = 0xEF00 + 7;
break;
case 4:
match->comp = 0xEF00 + 6;
break;
case 5:
match->comp = 0xEF00 + 3;
break;
case 6:
match->comp = 0xEF00 + 5;
break;
case 7:
match->comp = 0xEF00 + 8;
break;
case 8:
match->comp = 0xEF00 + 2;
}
for (index = 0; index < (buffers.component[5] >> 1) + 1; index++) {
if (index < 4) {
match->arrD[index] = buffers.component[index];
match->arr1[index] = 0xff;
}
}
if ((index != 0) && ((buffers.component[5] & 1) == 0)) {
index--;
match->arrD[index] &= 0xf0;
match->arr1[index] &= 0xf0;
}
nibbles = (ziU8)(buffers.component[5] + 1);
if (8 < nibbles) {
nibbles++;
}
}
}
match->arr1[0] &= 0xf;
match->arrD[0] &= 0xf;
if (skipMode == '\0') {
mode = 0;
if ((request->subLanguage & 0x80) != 0 || (request->subLanguage & 0x40) != 0) {
mode = 1;
} else if ((request->subLanguage & 8) != 0) {
mode = 4;
} else if ((request->subLanguage & 0x20) != 0 || (request->subLanguage & 0x10) != 0) {
mode = 2;
}
if (mode == 0) {
mode = request->subLanguage;
}
switch (mode) {
case 1:
case 2:
case 4:
match->arr1[0] |= (ziU8)(mode << 4);
match->arrD[0] |= (ziU8)(mode << 4);
break;
}
}
if (nibbles == 0) {
nibbles = 1;
}
if (((request->getMode == '\0') || (request->getMode == '\x10')) ||
(request->getMode == '\x05')) {
Zi8Memcpy(buffers.masks,match->arr1,0xc);
Zi8Memcpy(buffers.strokes,match->arrD,0xc);
do {
while (elementIndex < elementCount) {
element = request->elements[elementIndex++];
switch (element) {
case 0xef02: stroke = 0; break;
case 0xef04: stroke = 1; break;
case 0xef01: stroke = 2; break;
case 0xef07: stroke = 3; break;
case 0xef06: stroke = 4; break;
case 0xef03: stroke = 5; break;
case 0xef05: stroke = 6; break;
case 0xef08: stroke = 7; break;
case 0xef0b: stroke = 8; break;
case 0xef0a: stroke = 4; break;
case 0xf360: stroke = 0xff; break;
default: stroke = 0; break;
}
if (stroke == 0xff) break;
if (0x17 < nibbles) {
match->length = 0x18;
return 0;
}
if (nibbles == 8) {
nibbles++;
}
if ((nibbles & 1) != 0) {
buffers.strokes[nibbles >> 1] |= stroke;
if (element == 0xef0b) {
buffers.masks[nibbles >> 1] |= 8;
}
else if (element == 0xef0a) {
buffers.masks[nibbles >> 1] |= 4;
}
else if (element != 0xef00) {
buffers.masks[nibbles >> 1] |= 7;
}
} else {
buffers.strokes[nibbles >> 1] |= stroke << 4;
if (element == 0xef0b) {
buffers.masks[nibbles >> 1] |= 0x80;
}
else if (element == 0xef0a) {
buffers.masks[nibbles >> 1] |= 0x40;
}
else if (element != 0xef00) {
buffers.masks[nibbles >> 1] |= 0x70;
}
}
nibbles++;
}
savedNibbles = nibbles;
for (index = 0; index < 4; index++) {
buffers.maskPrefix[index] = buffers.masks[index];
buffers.strokePrefix[index] = buffers.strokes[index];
}
if ((1 < nibbles) && (nibbles < 8)) {
index = nibbles >> 1;
if ((nibbles & 1) != 0) {
buffers.maskPrefix[index] = buffers.maskPrefix[index] | 0xf;
buffers.strokePrefix[index] = buffers.strokePrefix[index] | 0xf;
} else {
buffers.maskPrefix[index] = buffers.maskPrefix[index] | 0xf0;
buffers.strokePrefix[index] = buffers.strokePrefix[index] | 0xf0;
}
}
if (match->nSeg == 0) {
Zi8Memcpy(match->arr1,buffers.masks,0xc);
Zi8Memcpy(match->arrD,buffers.strokes,0xc);
Zi8Memcpy(match->arr19,buffers.maskPrefix,4);
Zi8Memcpy(match->arr1D,buffers.strokePrefix,4);
match->length = savedNibbles;
}
Zi8Memcpy((ziU8 (*)[12])match->segs1 + match->nSeg,buffers.masks,0xc);
Zi8Memcpy((ziU8 (*)[12])match->segsD + match->nSeg,buffers.strokes,0xc);
match->nSeg++;
if (stroke != 0xff || elementIndex >= elementCount || match->nSeg >= 0x10) goto complete;
Zi8Memset(buffers.masks,0,0xc);
Zi8Memset(buffers.strokes,0,0xc);
buffers.masks[0] = match->arr1[0] & 0xf0;
buffers.strokes[0] = match->arrD[0] & 0xf0;
nibbles = 1;
} while (1);
}
match->length = nibbles;
if (elementCount != 0) {
if ((request->getMode == '\x01') || (request->getMode == '\f')) {
buffers.phoneticTable = (ziU8*)Zi8GetTableAddress(1,3,__zi8_work_data);
phoneticCount = Zi8GetTableCount(1,3,__zi8_work_data);
}
else {
buffers.phoneticTable = (ziU8*)Zi8GetTableAddress(1,4,__zi8_work_data);
phoneticCount = Zi8GetTableCount(1,4,__zi8_work_data);
}
if ((request->getMode == '\x01') || (request->getMode == '\f')) {
match->nCand = Zi8GetPyPhonetic(request->elements,elementCount,match->phon,match->phon2,
&request->count,&match->first,&match->first2,__zi8_work_data);
}
else {
initial = 0;
final = 0;
bestInitial = 0;
bestFinal = 0;
previousInitial = 0;
previousFinal = 0;
buffers.phoneticInput = request->elements;
match->nCand = 0;
request->count = request->elementCount;
phoneticLength = 1;
for (index = 0; index < elementCount; index++) {
stroke = Zi8GetBpmfPhonetic(buffers.phoneticInput,phoneticLength,&initial,&final,&bestInitial,&bestFinal,
__zi8_work_data);
if (stroke != 0) {
previousInitial = bestInitial;
previousFinal = bestFinal;
savePhonetic:
match->phon[match->nCand] = initial;
match->phon2[match->nCand] = final;
if (match->nCand == 0) {
match->first = bestInitial;
match->first2 = bestFinal;
}
}
else {
if ((index == 0) ||
((((1 < phoneticLength && (buffers.phoneticInput[phoneticLength - 2] == 0xF360)) &&
(buffers.phoneticInput[phoneticLength - 1] == 0xF360)) ||
(++match->nCand == 0x10)))) {
initial = 0xffff;
final = 0xffff;
bestInitial = 0xffff;
bestFinal = 0xffff;
match->nCand = 0;
break;
}
if (buffers.phoneticInput[phoneticLength - 1] == 0xF360) {
match->nCand--;
bestInitial = previousInitial;
bestFinal = previousFinal;
final = bestFinal;
initial = bestInitial;
goto savePhonetic;
}
if (match->nCand == 1) {
request->count = phoneticLength - 1;
}
buffers.phoneticInput = buffers.phoneticInput + phoneticLength - 1;
phoneticLength = 0;
index--;
}
phoneticLength++;
}
if (elementCount != 0) {
match->phon[match->nCand] = initial;
match->phon2[match->nCand] = final;
if (match->nCand == 0) {
match->first = bestInitial;
match->first2 = bestFinal;
}
match->nCand++;
}
}
if (((request->context & contextMask) != 0) &&
((1 < match->nCand || (request->count != elementCount)))) {
match->phon[0] = 0xFFFF;
match->phon2[0] = 0xFFFF;
match->nCand = 0;
}
if (((request->getOptions & 0x20) == 0) &&
((match->phon[0] != 0xFFFF || (match->phon2[0] != 0xFFFF)))) {
if (match->nCand > 1) {
phoneticInitial = match->phon[match->nCand - 1] & 0xfff8;
phoneticMask = match->phon2[match->nCand - 1] & 0xfff8;
}
else {
phoneticInitial = match->phon[0] & 0xfff8;
phoneticMask = match->phon2[0] & 0xfff8;
}
for (phoneticLength = 0; phoneticLength < phoneticCount; phoneticLength++) {
phoneticCode = buffers.phoneticTable[phoneticLength * 2] | ((ziU16)buffers.phoneticTable[phoneticLength * 2 + 1] << 8);
if (phoneticMask == (phoneticCode & phoneticInitial)) break;
}
if (phoneticLength == phoneticCount) {
match->phon[0] = 0xFFFF;
match->phon2[0] = 0xFFFF;
}
}
}
complete:
return 1;
}

View File

@@ -1,53 +0,0 @@
#ifndef PF_FA_PDM_H
#define PF_FA_PDM_H
#include <private/vf/PrFILE2/dskmng/pdm_types.h>
typedef struct PDM_PARTITION PDM_PARTITION;
typedef struct PDM_CALLBACK {
void (*insert)(PDM_PARTITION*);
void (*eject)(PDM_PARTITION*);
} PDM_CALLBACK;
struct PDM_PARTITION {
pf_u32 status;
PDM_DISK* p_disk;
pf_u32 part_id;
pf_u32 start_sector;
pf_u32 total_sector;
pf_s32 driver_last_error;
pf_u32 lock_state[2];
PDM_CALLBACK callbacks;
};
struct PDM_DISK {
pf_u32 status;
PDM_DISK_TBL disk_tbl;
pf_s16 init_count;
pf_s16 mount_count;
PDM_DISK* lock_handle;
pf_u32 lock_count;
PDM_DISK_INFO disk_info;
PDM_PARTITION* p_cur_part;
};
typedef struct PDM_DISK_SET {
pf_u16 num_partition;
pf_u16 num_allocated_disk;
PDM_DISK disk[26];
PDM_PARTITION partition[26];
} PDM_DISK_SET;
extern PDM_DISK_SET pdm_disk_set;
extern PDM_DISK_TBL pdm_drv_tbl[26];
void pdm_part_set_driver_error_code(PDM_PARTITION*, pf_s32);
void pdm_part_set_change_media_state(PDM_DISK*, pf_bool);
pf_s32 pdm_disk_convert_sector_into_block(PDM_DISK*, pf_u32, pf_u32, pf_u32, pf_u32*, pf_u32*);
pf_s32 pdm_disk_convert_block_into_sector(PDM_DISK*, pf_u32, pf_u32, pf_u32, pf_u32*, pf_u32*);
pf_s32 pdm_disk_add_disk(PDM_INIT_DISK*, PDM_DISK**);
pf_s32 pdm_disk_del_disk(PDM_DISK*);
pf_s32 pdm_disk_set_disk(PDM_DISK*, PDM_PARTITION*);
pf_s32 pdm_disk_get_media_attribute(PDM_DISK*, PDM_DISK_INFO*);
pf_s32 pdm_disk_get_media_bps(PDM_DISK*, pf_u16*);
pf_s32 pdm_disk_init(PDM_DISK*);
pf_s32 pdm_disk_mount(PDM_DISK*);
pf_s32 pdm_disk_format(PDM_DISK*, const pf_u8*);
pf_s32 pdm_disk_physical_read(PDM_DISK*, pf_u8*, pf_u32, pf_u32, pf_u32, pf_u32*);
pf_s32 pdm_disk_physical_write(PDM_DISK*, const pf_u8*, pf_u32, pf_u32, pf_u32, pf_u32*);
pf_s32 pdm_disk_unmount(PDM_DISK*, pf_u32);
pf_s32 pdm_disk_finalize(PDM_DISK*);
#endif

View File

@@ -1,39 +0,0 @@
#ifndef FA_PF_KERNEL_H
#define FA_PF_KERNEL_H
#include <revolution/os.h>
typedef struct PFK_TASK_CONFIG {
void* (*entry)(void*);
void* argument;
u32 stack_size;
void* stack;
s32 priority;
OSThread* thread;
} PFK_TASK_CONFIG;
typedef struct PFK_MAILBOX_CONFIG {
OSMessageQueue* queue;
OSMessage* messages;
s32 count;
} PFK_MAILBOX_CONFIG;
typedef struct PFK_SEMAPHORE_CONFIG {
u32 initial_count;
u32 maximum_count;
OSSemaphore* semaphore;
} PFK_SEMAPHORE_CONFIG;
s32 pfk_create_task(PFK_TASK_CONFIG* config);
s32 pfk_start_task(s32 task_id);
s32 pfk_get_task_id(s32* task_id);
s32 pfk_set_task_priority(s32 task_id, s32 priority);
s32 pfk_create_mailbox(PFK_MAILBOX_CONFIG* config);
s32 pfk_receive_message(s32 mailbox, OSMessage* message);
s32 pfk_send_message(s32 mailbox, OSMessage message);
s32 pfk_create_semaphore(PFK_SEMAPHORE_CONFIG* config);
s32 pfk_delete_semaphore(s32 semaphore);
s32 pfk_get_semaphore(s32 semaphore);
s32 pfk_release_semaphore(s32 semaphore);
#endif

View File

@@ -1,17 +0,0 @@
#ifndef PF_FA_SYSTEM_LAYOUT_H
#define PF_FA_SYSTEM_LAYOUT_H
#include <revolution/os.h>
typedef struct PFSYS_SYSTEM_SET {
u32 initialized;
s32 task_id;
s32 mailbox_id;
u8 task_stack[0x2000];
OSThread task;
OSMessageQueue mailbox;
OSMessage messages[20];
u32 flock_count;
} PFSYS_SYSTEM_SET;
extern PFSYS_SYSTEM_SET pf_sys_set;
#endif

View File

@@ -1,96 +0,0 @@
#ifndef PF_FA_VOLUME_LAYOUT_H
#define PF_FA_VOLUME_LAYOUT_H
#define PRFILE2_VFMOD_PF_VOLUME_H
#include <private/vf/PrFILE2/fatfs/pf_entry.h>
#include <private/vf/PrFILE2/driver/pf_driver.h>
#include <private/vf/PrFILE2/fatfs/pf_devinf.h>
typedef struct PF_CHARCODE {
pf_s32 (*oem2unicode)(const pf_s8*, pf_u16*);
pf_s32 (*unicode2oem)(const pf_u16*, pf_s8*);
pf_s32 (*oem_char_width)(const pf_s8*);
pf_bool (*is_oem_mb_char)(const pf_s8, pf_bool);
pf_s32 (*unicode_char_width)(const pf_u16*);
pf_bool (*is_unicode_mb_char)(const pf_u16, pf_bool);
} PF_CHARCODE;
typedef struct PF_BPB {
pf_u16 bytes_per_sector;
pf_u16 num_reserved_sectors;
pf_u16 num_root_dir_entries;
pf_u8 sectors_per_cluster;
pf_u8 num_FATs;
pf_u32 total_sectors;
pf_u32 sectors_per_FAT;
pf_u32 root_dir_cluster;
pf_u16 fs_info_sector;
pf_u16 backup_boot_sector;
pf_u16 ext_flags;
pf_u8 media;
PF_FAT_TYPE fat_type;
pf_u8 log2_bytes_per_sector;
pf_u8 log2_sectors_per_cluster;
pf_u8 num_active_FATs;
pf_u16 num_root_dir_sectors;
pf_u32 active_FAT_sector;
pf_u32 first_root_dir_sector;
pf_u32 first_data_sector;
pf_u32 num_clusters;
} PF_BPB;
typedef struct PF_CUR_DIR {
pf_u32 stat;
pf_s32 context_id;
PF_DIR_ENT directory;
} PF_CUR_DIR;
typedef pf_s32 (*PF_VOLUME_CB)(pf_s32);
struct PF_VOLUME {
PF_BPB bpb;
pf_u32 num_free_clusters;
pf_u32 last_free_cluster;
pf_u8 file_and_directory_state[0x1624 - 0x40];
PF_SECTOR_CACHE cache;
pf_s8 label[12];
PF_CUR_DIR current_dir[4];
struct {
pf_u32 tracker_size;
pf_u32 tracker_max;
pf_u32* tracker_bits;
} tail_entry;
pf_s32 last_error;
pf_s32 last_driver_error;
pf_u32 file_config;
pf_u16 flags;
pf_s8 drv_char;
pf_u16 fsi_flag;
PF_CLUSTER_LINK_VOL cluster_link;
void* p_part;
void (*p_callback)();
const pf_u8* format_param;
};
typedef struct PF_FA_CUR_VOLUME {
pf_u32 stat;
pf_s32 context_id;
PF_VOLUME* p_vol;
} PF_FA_CUR_VOLUME;
typedef struct PF_VOLUME_SET {
pf_u32 flags;
pf_u32 reserved;
PF_VOLUME* current_volume;
PF_FA_CUR_VOLUME context_volumes[3];
pf_s32 num_attached_drives;
pf_s32 num_mounted_volumes;
pf_u32 config;
void* param;
pf_s32 last_error;
pf_s32 last_driver_error;
PF_CHARCODE codeset;
pf_u32 setting;
pf_s32 context_id;
pf_u32 context_state[2];
struct { pf_u32 stat; pf_s32 context_id; } contexts[3];
PF_VOLUME volumes[26];
} PF_VOLUME_SET;
extern PF_VOLUME_SET pf_vol_set;
#endif

View File

@@ -1,59 +0,0 @@
#ifndef FA_PUH_MSC_H
#define FA_PUH_MSC_H
#include <revolution/fa/types.h>
typedef struct UHF_MSC_DEVICE {
FADisk* disk;
u32 device_id;
u32 interface_id;
u32 endpoint_in;
u32 endpoint_out;
u32 total_blocks;
u32 block_size;
u32 tag;
u32 lun;
u32 flags;
u32 status;
u32 event;
} UHF_MSC_DEVICE;
typedef struct UHF_MSC_PARAMETERS {
UHF_MSC_DEVICE* device;
void* sense;
u32 timeout;
void* buffer;
u32 length;
u32 sector;
u16 transfer_flags;
u16 block_count;
u32 options;
u32 result_size;
FADisk* disk;
} UHF_MSC_PARAMETERS;
typedef struct UHF_MSC_MESSAGE {
u32 command;
s32 semaphore;
s32* result;
UHF_MSC_PARAMETERS parameters;
void (*callback)(void*);
void* context;
} UHF_MSC_MESSAGE;
extern UHF_MSC_DEVICE uhg_msc_blk_device_tbl[8];
extern s32 uhg_msc_memid_8169971C;
s32 uhf_ker_set_priority(s32 task_id, s32 priority);
void* uhf_ker_get_memory_block(s32 pool, u32 size, u32 alignment);
s32 uhf_ker_release_memory_block(s32 pool, void* block);
s32 uhf_ker_create_sem(u32 initial_count, u32 maximum_count);
s32 uhf_ker_delete_sem(s32 semaphore);
s32 uhf_ker_get_sem(s32 semaphore);
s32 uhf_ker_send_message(s32 mailbox, void* message, u32 flags);
s32 uhf_ker_check_cacheable(void* buffer);
s32 usbh_msc_read10(UHF_MSC_DEVICE* device, u32 sector, u16 count, void* buffer, void* sense);
s32 usbh_msc_write10(UHF_MSC_DEVICE* device, u32 sector, u16 count, void* buffer, void* sense);
s32 uhf_msc_get_message_id(void);
s32 __uhf_msc_cmd_check_sense(const void* sense);
#endif

View File

@@ -7,8 +7,6 @@
extern "C" {
#endif
#define AXFX_STEREO_CHANNEL_MAX 3
typedef struct AXFX_BUS {
s32* left; // 0x00
s32* right; // 0x04
@@ -21,13 +19,6 @@ typedef struct AXFX_BUFFERUPDATE {
s32* surround; // 0x08
} AXFX_BUFFERUPDATE;
typedef struct AXFX_BUS_DPL2 {
s32* left; // 0x00
s32* right; // 0x04
s32* left_surround; // 0x08
s32* right_surround; // 0x0C
} AXFX_BUS_DPL2;
typedef struct AXFX_BUFFERUPDATE_DPL2 {
s32* left; // 0x00
s32* right; // 0x04

View File

@@ -49,13 +49,13 @@ typedef struct AXFX_REVERBHI_EXP_DPL2 {
f32 crosstalk; // 0x15C
f32 earlyGain; // 0x160
f32 fusedGain; // 0x164
AXFX_BUS_DPL2* busIn; // 0x168
AXFX_BUS_DPL2* busOut; // 0x16C
AXFX_BUS* busIn; // 0x168
AXFX_BUS* busOut; // 0x16C
f32 outGain; // 0x170
f32 sendGain; // 0x174
} AXFX_REVERBHI_EXP_DPL2;
u32 AXFXReverbHiExpGetMemSizeDpl2(AXFX_REVERBHI_EXP_DPL2* fx);
u32 AXFXReverbHiExpGetMemSizeDpl2(const AXFX_REVERBHI_EXP_DPL2* fx);
BOOL AXFXReverbHiExpInitDpl2(AXFX_REVERBHI_EXP_DPL2* fx);
void AXFXReverbHiExpShutdownDpl2(AXFX_REVERBHI_EXP_DPL2* fx);
BOOL AXFXReverbHiExpSettingsDpl2(AXFX_REVERBHI_EXP_DPL2* fx);

View File

@@ -49,11 +49,11 @@ typedef struct AXFX_REVERBSTD_EXP {
f32 sendGain; // 0xE4
} AXFX_REVERBSTD_EXP;
u32 AXFXReverbStdExpGetMemSize(AXFX_REVERBSTD_EXP* fx);
u32 AXFXReverbStdExpGetMemSize(const AXFX_REVERBSTD_EXP* fx);
BOOL AXFXReverbStdExpInit(AXFX_REVERBSTD_EXP* fx);
void AXFXReverbStdExpShutdown(AXFX_REVERBSTD_EXP* fx);
BOOL AXFXReverbStdExpSettings(AXFX_REVERBSTD_EXP* fx);
void AXFXReverbStdExpCallback(AXFX_BUS* update, AXFX_REVERBSTD_EXP* fx);
void AXFXReverbStdExpCallback(void* chans, AXFX_REVERBSTD_EXP* context);
#ifdef __cplusplus
}

View File

@@ -1,33 +0,0 @@
#ifndef FA_PF_STUB_H
#define FA_PF_STUB_H
#include <revolution/fa.h>
typedef union PF_STUB_RESULT {
s32 status;
u32 count;
void* stream;
} PF_STUB_RESULT;
typedef struct PF_STUB_MESSAGE {
s32 task_id;
s32 operation;
s8 drive;
u32 value;
u32 count;
const void* object;
const void* data;
void* context;
u32 options;
s32 semaphore;
PF_STUB_RESULT* result_address;
FADisk* disk;
FAPartition* partition;
void (*callback)(s32, void*);
void* callback_context;
PF_STUB_RESULT result;
} PF_STUB_MESSAGE;
extern s32 pfstub_com_massage(PF_STUB_MESSAGE* message);
#endif

View File

@@ -30,21 +30,11 @@ typedef enum _KBDCountryCode {
} KBDCountryCode;
typedef struct _KBDKeyEvent {
#ifdef TIHKBMANAGER_IMPLEMENTATION
u8 device;
u8 key;
u32 flags;
#else
u8 unk_0x00[32];
#endif
} KBDKeyEvent;
typedef struct _KBDDevEvent {
#ifdef TIHKBMANAGER_IMPLEMENTATION
u8 device;
#else
u8 unk_0x00[32];
#endif
} KBDDevEvent;
#ifdef __cplusplus

View File

@@ -1,220 +0,0 @@
#include <private/axfx.h>
#include <revolution/axfx.h>
#include <revolution/os.h>
#include <string.h>
static BOOL __InitParams(AXFX_CHORUS_EXP* fx);
static void __CalcLFO(s32* output, AXFX_CHORUS_EXP_LFO* lfo);
static BOOL __AllocDelayLine(AXFX_CHORUS_EXP* fx) {
u32 channel;
for (channel = 0; channel < 3; channel++) {
fx->delay.line[channel] = __AXFXAlloc(fx->delay.size * sizeof(f32));
if (fx->delay.line[channel] == NULL) return FALSE;
}
return TRUE;
}
static BOOL __BzeroDelayLine(AXFX_CHORUS_EXP* fx) {
u32 channel;
for (channel = 0; channel < 3; channel++) {
if (fx->delay.line[channel] == NULL) return FALSE;
memset(fx->delay.line[channel], 0, fx->delay.size * sizeof(f32));
}
fx->delay.inPos = 0;
fx->delay.outPos = (fx->delay.size - (u32)(32.0f * fx->delayTime)) << 16;
fx->delay.lastPos = fx->delay.outPos;
fx->delay.sizeFP = fx->delay.size << 16;
return TRUE;
}
u32 AXFXChorusExpGetMemSize(const AXFX_CHORUS_EXP* fx) {
return 0x9600;
}
BOOL AXFXChorusExpInit(AXFX_CHORUS_EXP* fx) {
BOOL enabled = OSDisableInterrupts();
fx->active |= 1;
fx->delay.size = 3200;
if (!__AllocDelayLine(fx)) {
AXFXChorusExpShutdown(fx);
OSRestoreInterrupts(enabled);
return FALSE;
}
if (!__BzeroDelayLine(fx)) {
AXFXChorusExpShutdown(fx);
OSRestoreInterrupts(enabled);
return FALSE;
}
if (!__InitParams(fx)) {
AXFXChorusExpShutdown(fx);
OSRestoreInterrupts(enabled);
return FALSE;
}
fx->active &= ~1;
OSRestoreInterrupts(enabled);
return TRUE;
}
BOOL AXFXChorusExpSettings(AXFX_CHORUS_EXP* fx) {
BOOL result;
BOOL enabled = OSDisableInterrupts();
fx->active |= 1;
AXFXChorusExpShutdown(fx);
result = AXFXChorusExpInit(fx);
if (!result) {
AXFXChorusExpShutdown(fx);
OSRestoreInterrupts(enabled);
return FALSE;
}
fx->active = (fx->active | 2) & ~1;
OSRestoreInterrupts(enabled);
return result;
}
void AXFXChorusExpShutdown(AXFX_CHORUS_EXP* fx) {
BOOL enabled = OSDisableInterrupts();
u32 channel;
fx->active |= 1;
for (channel = 0; channel < 3; channel++) {
if (fx->delay.line[channel] != NULL) __AXFXFree(fx->delay.line[channel]);
fx->delay.line[channel] = NULL;
}
OSRestoreInterrupts(enabled);
}
void AXFXChorusExpCallback(AXFX_BUFFERUPDATE* update, AXFX_CHORUS_EXP* fx) {
s32* output[3];
s32* input[3];
s32* send[3];
s32 modulation[96];
u32 sample;
if (fx->active != 0) {
fx->active &= ~2;
return;
}
output[0] = update->left;
output[1] = update->right;
output[2] = update->surround;
if (fx->busIn != NULL) {
input[0] = fx->busIn->left;
input[1] = fx->busIn->right;
input[2] = fx->busIn->surround;
}
if (fx->busOut != NULL) {
send[0] = fx->busOut->left;
send[1] = fx->busOut->right;
send[2] = fx->busOut->surround;
}
__CalcLFO(modulation, &fx->lfo);
for (sample = 0; sample < 96; sample++) {
s32 position = fx->delay.outPos + modulation[sample];
u32 distance;
u32 whole, fraction, source, history, channel;
f32* coefficients;
if (position >= (s32)fx->delay.sizeFP) position -= fx->delay.sizeFP;
else if (position < 0) position += fx->delay.sizeFP;
distance = position - fx->delay.lastPos;
if ((s32)distance < 0) distance += fx->delay.sizeFP;
whole = (u32)distance >> 16;
fraction = distance & 0xFFFF;
source = fx->delay.lastPos >> 16;
history = fx->histIndex;
while (whole != 0) {
fx->history[0][history] = fx->delay.line[0][source];
fx->history[1][history] = fx->delay.line[1][source];
fx->history[2][history] = fx->delay.line[2][source];
history = (history + 1) & 3;
source++;
if (source >= fx->delay.size) source = 0;
whole--;
}
fx->delay.lastPos = position & 0xFFFF0000;
coefficients = __AXFXGetSrcCoef((fraction >> 9) & 0x7F);
for (channel = 0; channel < 3; channel++) {
f32 filtered = 0.0f;
f32 dry;
filtered += coefficients[0] * fx->history[channel][history];
history = (history + 1) & 3;
filtered += coefficients[1] * fx->history[channel][history];
history = (history + 1) & 3;
filtered += coefficients[2] * fx->history[channel][history];
history = (history + 1) & 3;
filtered += coefficients[3] * fx->history[channel][history];
history = (history + 1) & 3;
if (fx->busIn != NULL) dry = *input[channel]++ + *output[channel];
else dry = *output[channel];
fx->delay.line[channel][fx->delay.inPos] = dry + filtered * fx->feedback;
*output[channel]++ = filtered * fx->outGain;
if (fx->busOut != NULL) *send[channel]++ = filtered * fx->sendGain;
}
fx->histIndex = history;
fx->delay.inPos++;
if (fx->delay.inPos >= fx->delay.size) fx->delay.inPos = 0;
fx->delay.outPos += 0x10000;
if (fx->delay.outPos >= fx->delay.sizeFP) fx->delay.outPos = 0;
}
}
static BOOL __InitParams(AXFX_CHORUS_EXP* fx) {
f32 delay, depth, step;
if (fx->delayTime < 0.1f || fx->delayTime > 50.0f) return FALSE;
if (fx->depth < 0.0f || fx->depth > 1.0f) return FALSE;
if (fx->rate < 0.1f || fx->rate > 2.0f) return FALSE;
if (fx->feedback < 0.0f || fx->feedback >= 1.0f) return FALSE;
if (fx->outGain < 0.0f || fx->outGain > 1.0f) return FALSE;
if (fx->sendGain < 0.0f || fx->sendGain > 1.0f) return FALSE;
fx->lfo.table = __AXFXGetLfoSinTable();
delay = 32.0f * fx->delayTime;
depth = delay * fx->depth;
if (delay <= depth) {
depth -= 1.0f;
if (depth < 0.0f) depth = 0.0f;
}
fx->lfo.depthSamp = 65536.0f * depth;
fx->lfo.phaseAdd = 65536.0f * (256.0f * fx->rate / 32000.0f);
step = (32000.0f / fx->rate) * (1.0f / 256.0f);
fx->lfo.stepSamp = 65536.0f * step;
fx->lfo.gradFactor = 65536.0f * (depth / step);
fx->lfo.lastNum = -1;
fx->lfo.phase = 0;
fx->lfo.sign = 0;
fx->lfo.lastValue = 0;
fx->lfo.grad = 0;
fx->history[0][0] = 0.0f;
fx->history[0][1] = 0.0f;
fx->history[0][2] = 0.0f;
fx->history[0][3] = 0.0f;
fx->history[1][0] = 0.0f;
fx->history[1][1] = 0.0f;
fx->history[1][2] = 0.0f;
fx->history[1][3] = 0.0f;
fx->history[2][0] = 0.0f;
fx->history[2][1] = 0.0f;
fx->history[2][2] = 0.0f;
fx->history[2][3] = 0.0f;
fx->histIndex = 0;
return TRUE;
}
static void __CalcLFO(s32* output, AXFX_CHORUS_EXP_LFO* lfo) {
u32 remaining = 96;
do {
s32 value;
u32 phase = lfo->phase & 0xFFFF0000;
if (phase != lfo->lastNum) {
s32 start, difference;
s64 product;
lfo->lastNum = phase;
phase >>= 16;
start = lfo->table[phase];
difference = lfo->table[(phase + 1) & 0x7F] - start;
product = (s64)start * lfo->depthSamp;
value = ((u32)(product >> 32) << 8) | ((u32)product >> 24);
product = (s64)difference * lfo->gradFactor;
lfo->grad = ((u32)(product >> 32) << 8) | ((u32)product >> 24);
}
else value = lfo->lastValue + lfo->grad;
lfo->lastValue = value;
if (lfo->sign != 0) value = -value;
lfo->phase += lfo->phaseAdd;
if (lfo->phase & 0xFF800000) {
lfo->phase &= 0x7FFFFF;
lfo->sign ^= 1;
}
*output++ = value;
remaining--;
} while (remaining != 0);
}

View File

@@ -1,461 +0,0 @@
#include <private/axfx.h>
#include <revolution/AXFX.h>
#include <revolution/MEM.h>
#include <revolution/OS.h>
#include <revolution/ax.h>
#include <math.h>
#include <string.h>
static BOOL __AllocDelayLine(AXFX_REVERBHI_EXP_DPL2* fx);
static void __BzeroDelayLines(AXFX_REVERBHI_EXP_DPL2* fx);
static void __FreeDelayLine(AXFX_REVERBHI_EXP_DPL2* fx);
static BOOL __InitParams(AXFX_REVERBHI_EXP_DPL2* fx);
static u32 __EarlySizeTable[8][3] = {{157, 479, 829}, {317, 809, 1117}, {479, 941, 1487}, {641, 1259, 1949},
{797, 1667, 2579}, {967, 1901, 2903}, {1123, 2179, 3413}, {1279, 2477, 3889}};
static f32 __EarlyCoefTable[8][3] = {{0.4f, -1.0f, 0.3f}, {0.5f, -0.95f, 0.3f}, {0.6f, -0.9f, 0.3f}, {0.75f, -0.85f, 0.3f},
{-0.9f, 0.8f, 0.3f}, {-1.0f, 0.7f, 0.3f}, {-1.0f, 0.7f, 0.3f}, {-1.0f, 0.7f, 0.3f}};
static u32 __FilterSizeTable[7][9] = {{1789, 1999, 2333, 433, 149, 47, 73, 67, 71}, {149, 293, 449, 251, 103, 47, 73, 67, 71},
{947, 1361, 1531, 433, 137, 47, 73, 67, 71}, {1279, 1531, 1973, 509, 149, 47, 73, 67, 71},
{1531, 1847, 2297, 563, 179, 47, 73, 67, 71}, {1823, 2357, 2693, 571, 137, 47, 73, 67, 71},
{1823, 2357, 2693, 571, 179, 47, 73, 67, 71}};
u32 AXFXReverbHiExpGetMemSizeDpl2(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 sum = 0;
u32 i = 0;
sum += __EarlySizeTable[7][2];
sum += (int)(fx->preDelayTimeMax * 32000);
for (i = 0; i < 5; i++) {
sum += __FilterSizeTable[6][i];
}
sum *= 4;
for (i = 5; i < 9; i++) {
sum += __FilterSizeTable[6][i];
}
sum *= 4;
return sum;
}
BOOL AXFXReverbHiExpInitDpl2(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
BOOL result = TRUE;
BOOL mask = OSDisableInterrupts();
if (AXGetMode() != AX_OUTPUT_DPL2) {
OSRestoreInterrupts(mask);
return FALSE;
}
fx->active = 1;
if (fx->preDelayTimeMax < 0.0f) {
AXFXReverbHiExpShutdownDpl2(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
fx->earlyMaxLength = __EarlySizeTable[8 - 1][2];
fx->preDelayMaxLength = (u32)(fx->preDelayTimeMax * 32000);
for (i = 0; i < 3; i++) {
fx->combMaxLength[i] = __FilterSizeTable[6][i];
}
for (i = 0; i < 2; i++) {
fx->allpassMaxLength[i] = __FilterSizeTable[6][3 + i];
}
for (ch = 0; ch < 4; ch++) {
fx->lastAllpassMaxLength[ch] = __FilterSizeTable[6][5 + ch];
}
result = __AllocDelayLine(fx);
if (result == FALSE) {
AXFXReverbHiExpShutdownDpl2(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
__BzeroDelayLines(fx);
result = __InitParams(fx);
if (result == FALSE) {
AXFXReverbHiExpShutdownDpl2(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
fx->active &= ~1;
OSRestoreInterrupts(mask);
return TRUE;
}
BOOL AXFXReverbHiExpSettingsDpl2(AXFX_REVERBHI_EXP_DPL2* fx) {
BOOL mask = OSDisableInterrupts();
fx->active = fx->active | 1;
AXFXReverbHiExpShutdownDpl2(fx);
if (!AXFXReverbHiExpInitDpl2(fx)) {
AXFXReverbHiExpShutdownDpl2(fx);
OSRestoreInterrupts(mask);
return FALSE;
} else {
fx->active |= 2;
fx->active &= ~1;
OSRestoreInterrupts(mask);
return TRUE;
}
}
void AXFXReverbHiExpShutdownDpl2(AXFX_REVERBHI_EXP_DPL2* fx) {
BOOL mask = OSDisableInterrupts();
fx->active |= 1;
__FreeDelayLine(fx);
OSRestoreInterrupts(mask);
}
void AXFXReverbHiExpCallbackDpl2(AXFX_BUFFERUPDATE_DPL2* bufferUpdate, AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
u32 samp;
s32* input[4];
f32 data;
f32 output[4];
f32* earlyLine;
f32 earlyOut;
f32* preDelayLine;
f32 preDelayOut;
f32 filterOut;
f32* combLine;
f32 combOutOne;
f32* allpass;
f32 outTmp;
f32 allpassIn;
f32 allpassCoef;
f32 lpfOut;
f32 lpfCoef1;
f32 lpfCoef2;
f32 fusedOut[4];
f32 fusedGain;
f32 crosstalkGain;
f32 crosstalkL;
f32 crosstalkR;
f32 crosstalkLs;
f32 crosstalkRs;
s32* inBusData[4];
s32* outBusData[4];
if (fx->active != 0) {
fx->active &= ~2;
return;
}
input[0] = bufferUpdate->left;
input[1] = bufferUpdate->right;
input[2] = bufferUpdate->left_surround;
input[3] = bufferUpdate->right_surround;
if (fx->busIn != NULL) {
inBusData[0] = fx->busIn->left;
inBusData[1] = fx->busIn->right;
inBusData[2] = fx->busIn->left_surround;
inBusData[3] = fx->busIn->right_surround;
}
if (fx->busOut != NULL) {
outBusData[0] = fx->busOut->left;
outBusData[1] = fx->busOut->right;
outBusData[2] = fx->busOut->left_surround;
outBusData[3] = fx->busOut->right_surround;
}
lpfCoef1 = 1.0f - fx->lpfCoef;
lpfCoef2 = fx->lpfCoef;
allpassCoef = fx->allpassCoef;
fusedGain = fx->fusedGain * 0.6f;
crosstalkGain = fx->crosstalk * 0.333333f;
for (samp = 0; samp < 96; samp++) {
for (ch = 0; ch < 4; ch++) {
if (fx->busIn != NULL) {
data = (f32)(*(input[ch]) + *(inBusData[ch]++));
} else {
data = (f32)(*input[ch]);
}
earlyLine = fx->earlyLine[ch];
earlyOut = earlyLine[fx->earlyPos[0]] * fx->earlyCoef[0] + earlyLine[fx->earlyPos[1]] * fx->earlyCoef[1] +
earlyLine[fx->earlyPos[2]] * fx->earlyCoef[2];
earlyLine[fx->earlyPos[2]] = data;
if (fx->preDelayLength != 0) {
preDelayLine = fx->preDelayLine[ch];
preDelayOut = preDelayLine[fx->preDelayPos];
preDelayLine[fx->preDelayPos] = data;
} else {
preDelayOut = data;
}
filterOut = 0.0f;
for (i = 0; i < 3; i++) {
combLine = fx->combLine[ch][i];
combOutOne = combLine[fx->combPos[i]];
combLine[fx->combPos[i]] = preDelayOut + (combOutOne * fx->combCoef[i]);
filterOut += combOutOne;
}
for (i = 0; i < 2; i++) {
allpass = fx->allpassLine[ch][i];
outTmp = allpass[fx->allpassPos[i]];
allpassIn = filterOut + outTmp * allpassCoef;
allpass[fx->allpassPos[i]] = allpassIn;
filterOut = outTmp - allpassIn * allpassCoef;
}
lpfOut = lpfCoef1 * filterOut + lpfCoef2 * fx->lastLpfOut[ch];
fx->lastLpfOut[ch] = lpfOut;
allpass = fx->lastAllpassLine[ch];
outTmp = allpass[fx->lastAllpassPos[ch]];
allpassIn = lpfOut + outTmp * allpassCoef;
allpass[fx->lastAllpassPos[ch]] = allpassIn;
fusedOut[ch] = outTmp - allpassIn * allpassCoef;
if (++fx->lastAllpassPos[ch] >= fx->lastAllpassLength[ch]) {
fx->lastAllpassPos[ch] = 0;
}
fusedOut[ch] *= fusedGain;
fusedOut[ch] += earlyOut;
}
crosstalkL = fusedOut[1] + fusedOut[2] + fusedOut[3];
crosstalkR = fusedOut[0] + fusedOut[2] + fusedOut[3];
crosstalkLs = fusedOut[0] + fusedOut[1] + fusedOut[3];
crosstalkRs = fusedOut[0] + fusedOut[1] + fusedOut[2];
output[0] = fusedOut[0] + crosstalkL * crosstalkGain;
output[1] = fusedOut[1] + crosstalkR * crosstalkGain;
output[2] = fusedOut[2] + crosstalkLs * crosstalkGain;
output[3] = fusedOut[3] + crosstalkRs * crosstalkGain;
*(input[0]++) = (s32)(output[0] * fx->outGain);
*(input[1]++) = (s32)(output[1] * fx->outGain);
*(input[2]++) = (s32)(output[2] * fx->outGain);
*(input[3]++) = (s32)(output[3] * fx->outGain);
if (fx->busOut != NULL) {
*(outBusData[0]++) = (s32)(output[0] * fx->sendGain);
*(outBusData[1]++) = (s32)(output[1] * fx->sendGain);
*(outBusData[2]++) = (s32)(output[2] * fx->sendGain);
*(outBusData[3]++) = (s32)(output[3] * fx->sendGain);
}
for (i = 0; i < 3; i++) {
if (++fx->earlyPos[i] >= fx->earlyLength) {
fx->earlyPos[i] = 0;
}
}
if (fx->preDelayLength != 0) {
if (++fx->preDelayPos >= fx->preDelayLength) {
fx->preDelayPos = 0;
}
}
for (i = 0; i < 3; i++) {
if (++fx->combPos[i] >= fx->combLength[i]) {
fx->combPos[i] = 0;
}
}
for (i = 0; i < 2; i++) {
if (++fx->allpassPos[i] >= fx->allpassLength[i]) {
fx->allpassPos[i] = 0;
}
}
}
}
static BOOL __AllocDelayLine(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
for (ch = 0; ch < 4; ch++) {
fx->earlyLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->earlyMaxLength);
if (fx->earlyLine[ch] == NULL)
return FALSE;
if (fx->preDelayMaxLength != 0) {
fx->preDelayLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->preDelayMaxLength);
if (fx->preDelayLine[ch] == NULL)
return FALSE;
} else {
fx->preDelayLine[ch] = NULL;
}
for (i = 0; i < 3; i++) {
fx->combLine[ch][i] = (f32*)__AXFXAlloc(sizeof(f32) * fx->combMaxLength[i]);
if (fx->combLine[ch][i] == NULL)
return FALSE;
}
for (i = 0; i < 2; i++) {
fx->allpassLine[ch][i] = (f32*)__AXFXAlloc(sizeof(f32) * fx->allpassMaxLength[i]);
if (fx->allpassLine[ch][i] == NULL)
return FALSE;
}
fx->lastAllpassLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->lastAllpassMaxLength[ch]);
if (fx->lastAllpassLine[ch] == NULL)
return FALSE;
}
return TRUE;
}
static void __BzeroDelayLines(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
for (ch = 0; ch < 4; ch++) {
if (fx->earlyLine[ch] != NULL) {
memset(fx->earlyLine[ch], 0, sizeof(f32) * fx->earlyMaxLength);
}
if (fx->preDelayLine[ch] != NULL) {
memset(fx->preDelayLine[ch], 0, sizeof(f32) * fx->preDelayMaxLength);
}
for (i = 0; i < 3; i++) {
if (fx->combLine[ch][i] != NULL) {
memset(fx->combLine[ch][i], 0, sizeof(f32) * fx->combMaxLength[i]);
}
}
for (i = 0; i < 2; i++) {
if (fx->allpassLine[ch][i] != NULL) {
memset(fx->allpassLine[ch][i], 0, sizeof(f32) * fx->allpassMaxLength[i]);
}
}
if (fx->lastAllpassLine[ch] != NULL) {
memset(fx->lastAllpassLine[ch], 0, sizeof(f32) * fx->lastAllpassMaxLength[ch]);
}
}
}
static void __FreeDelayLine(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
for (ch = 0; ch < 4; ch++) {
if (fx->earlyLine[ch] != NULL) {
__AXFXFree(fx->earlyLine[ch]);
fx->earlyLine[ch] = NULL;
}
if (fx->preDelayLine[ch] != NULL) {
__AXFXFree(fx->preDelayLine[ch]);
fx->preDelayLine[ch] = NULL;
}
for (i = 0; i < 3; i++) {
if (fx->combLine[ch][i] != NULL) {
__AXFXFree(fx->combLine[ch][i]);
fx->combLine[ch][i] = NULL;
}
}
for (i = 0; i < 2; i++) {
if (fx->allpassLine[ch][i] != NULL) {
__AXFXFree(fx->allpassLine[ch][i]);
fx->allpassLine[ch][i] = NULL;
}
}
if (fx->lastAllpassLine[ch] != NULL) {
__AXFXFree(fx->lastAllpassLine[ch]);
fx->lastAllpassLine[ch] = NULL;
}
}
}
DECOMP_FORCE_LITERAL(AXFXReverbHiExpDpl2_c, -3.0f, 10.0);
static BOOL __InitParams(AXFX_REVERBHI_EXP_DPL2* reverb) {
u32 ch, i;
if (reverb->earlyMode >= 8)
return FALSE;
if (reverb->preDelayTime < 0.0f || reverb->preDelayTime > reverb->preDelayTimeMax)
return FALSE;
if (reverb->fusedMode >= 6)
return FALSE;
if (reverb->fusedTime < 0.0f)
return FALSE;
if (reverb->coloration < 0.0f || reverb->coloration > 1.0f)
return FALSE;
if (reverb->damping < 0.0f || reverb->damping > 1.0f)
return FALSE;
if (reverb->crosstalk < 0.0f || reverb->crosstalk > 1.0f)
return FALSE;
if (reverb->earlyGain < 0.0f || reverb->earlyGain > 1.0f)
return FALSE;
if (reverb->fusedGain < 0.0f || reverb->fusedGain > 1.0f)
return FALSE;
if (reverb->outGain < 0.0f || reverb->outGain > 1.0f)
return FALSE;
if (reverb->sendGain < 0.0f || reverb->sendGain > 1.0f)
return FALSE;
reverb->earlyLength = __EarlySizeTable[reverb->earlyMode][2];
for (i = 0; i < 3; i++) {
reverb->earlyPos[i] = reverb->earlyLength - __EarlySizeTable[reverb->earlyMode][i];
reverb->earlyCoef[i] = __EarlyCoefTable[reverb->earlyMode][i] * reverb->earlyGain * 0.6f;
}
reverb->preDelayPos = 0;
reverb->preDelayLength = (u32)(reverb->preDelayTime * (f32)32000);
for (i = 0; i < 3; i++) {
reverb->combPos[i] = 0;
reverb->combLength[i] = __FilterSizeTable[reverb->fusedMode][i];
reverb->combCoef[i] = pow(10.0f, (-3.0f * (f32)(reverb->combLength[i]) / (f32)(reverb->fusedTime * 32000)));
}
for (i = 0; i < 2; i++) {
reverb->allpassPos[i] = 0;
reverb->allpassLength[i] = __FilterSizeTable[reverb->fusedMode][3 + i];
}
for (ch = 0; ch < 4; ch++) {
reverb->lastAllpassPos[ch] = 0;
reverb->lastAllpassLength[ch] = __FilterSizeTable[reverb->fusedMode][5 + ch];
}
reverb->allpassCoef = reverb->coloration;
reverb->lpfCoef = 1.0f - reverb->damping;
if (reverb->lpfCoef > 0.95f)
reverb->lpfCoef = 0.95f;
for (ch = 0; ch < 4; ch++) {
reverb->lastLpfOut[ch] = 0.0f;
}
return TRUE;
}

View File

@@ -23,7 +23,7 @@ BOOL AXFXReverbStdSettings(AXFX_REVERBSTD* fx) {
}
void AXFXReverbStdCallback(void* chans, void* context) {
AXFXReverbStdExpCallback((AXFX_BUS*)chans, (AXFX_REVERBSTD_EXP*)context);
AXFXReverbStdExpCallback((AXFX_BUFFERUPDATE*)chans, (AXFX_REVERBSTD_EXP*)context);
}
static void __ParamConvert(AXFX_REVERBSTD* fx) {

View File

@@ -1,397 +0,0 @@
#include <private/axfx.h>
#include <revolution/AXFX.h>
#include <revolution/MEM.h>
#include <revolution/OS.h>
#include <revolution/ax.h>
#include <math.h>
#include <string.h>
static BOOL __AllocDelayLine(AXFX_REVERBSTD_EXP* fx);
static void __BzeroDelayLines(AXFX_REVERBSTD_EXP* fx);
static void __FreeDelayLine(AXFX_REVERBSTD_EXP* fx);
static BOOL __InitParams(AXFX_REVERBSTD_EXP* fx);
static u32 __EarlySizeTable[8] = {163, 317, 479, 641, 797, 967, 1123, 1283};
static u32 __FilterSizeTable[7][4] = {{1789, 1999, 433, 149}, {149, 293, 251, 103}, {947, 1361, 433, 137},
{1279, 1531, 509, 149}, {1531, 1847, 563, 179}, {1823, 2357, 571, 137},
{1823, 2357, 571, 179}};
u32 AXFXReverbStdExpGetMemSize(AXFX_REVERBSTD_EXP* fx) {
u32 sum = 0;
u32 i = 0;
sum += __EarlySizeTable[7];
sum += (int)(fx->preDelayTimeMax * 32000);
for (i = 0; i < 4; i++) {
sum += __FilterSizeTable[6][i];
}
sum *= 3;
sum *= 4;
return sum;
}
BOOL AXFXReverbStdExpInit(AXFX_REVERBSTD_EXP* fx) {
u32 ch, i;
BOOL result = TRUE;
BOOL mask = OSDisableInterrupts();
fx->active = 1;
if (fx->preDelayTimeMax < 0.0f) {
AXFXReverbStdExpShutdown(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
fx->earlyMaxLength = __EarlySizeTable[8 - 1];
fx->preDelayMaxLength = (u32)(fx->preDelayTimeMax * 32000);
for (i = 0; i < 2; i++) {
fx->combMaxLength[i] = __FilterSizeTable[6][i];
}
for (i = 0; i < 2; i++) {
fx->allpassMaxLength[i] = __FilterSizeTable[6][2 + i];
}
result = __AllocDelayLine(fx);
if (result == FALSE) {
AXFXReverbStdExpShutdown(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
__BzeroDelayLines(fx);
result = __InitParams(fx);
if (result == FALSE) {
AXFXReverbStdExpShutdown(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
fx->active &= ~1;
OSRestoreInterrupts(mask);
return TRUE;
}
BOOL AXFXReverbStdExpSettings(AXFX_REVERBSTD_EXP* fx) {
BOOL mask = OSDisableInterrupts();
fx->active = fx->active | 1;
AXFXReverbStdExpShutdown(fx);
if (!AXFXReverbStdExpInit(fx)) {
AXFXReverbStdExpShutdown(fx);
OSRestoreInterrupts(mask);
return FALSE;
} else {
fx->active |= 2;
fx->active &= ~1;
OSRestoreInterrupts(mask);
return TRUE;
}
}
void AXFXReverbStdExpShutdown(AXFX_REVERBSTD_EXP* fx) {
BOOL mask = OSDisableInterrupts();
fx->active |= 1;
__FreeDelayLine(fx);
OSRestoreInterrupts(mask);
}
void AXFXReverbStdExpCallback(AXFX_BUS* bus, AXFX_REVERBSTD_EXP* reverb) {
u32 i, j;
s32* busParam[AXFX_STEREO_CHANNEL_MAX];
s32* busIn[AXFX_STEREO_CHANNEL_MAX];
s32* busOut[AXFX_STEREO_CHANNEL_MAX];
u32 earlyPos;
u32 preDelayPos;
u32 combPos0;
u32 combPos1;
u32 allpassPos0;
u32 allpassPos1;
f32 sp64;
f32 sp60;
f32* earlyLine;
f32 sp58;
f32 earlyCoef;
f32* preDelayLine;
f32 sp4C;
f32* combLine0;
f32* combLine1;
f32 sp40;
f32 sp3C;
f32 sp38;
f32 combCoef0;
f32 combCoef1;
f32 sp2C;
f32 sp28;
f32 sp24;
f32 sp20;
f32 allpassCoef;
f32 sp18;
f32 sp14;
f32 lpfCoef;
f32 spC;
f32 sp8;
f32* allpassLine;
if (reverb->active != 0) {
reverb->active &= ~2;
return;
}
busParam[AX_STEREO_L] = bus->left;
busParam[AX_STEREO_R] = bus->right;
busParam[AX_STEREO_S] = bus->surround;
if (reverb->busIn) {
busIn[AX_STEREO_L] = reverb->busIn->left;
busIn[AX_STEREO_R] = reverb->busIn->right;
busIn[AX_STEREO_S] = reverb->busIn->surround;
}
if (reverb->busOut) {
busOut[AX_STEREO_L] = reverb->busOut->left;
busOut[AX_STEREO_R] = reverb->busOut->right;
busOut[AX_STEREO_S] = reverb->busOut->surround;
}
sp14 = 1.0f - reverb->lpfCoef;
lpfCoef = reverb->lpfCoef;
earlyCoef = reverb->earlyCoef;
combCoef0 = reverb->combCoef[0];
combCoef1 = reverb->combCoef[1];
allpassCoef = reverb->allpassCoef;
spC = 0.6f * reverb->earlyGain;
sp8 = 0.6f * reverb->fusedGain;
for (i = 0; i < 96; i++) {
earlyPos = reverb->earlyPos;
preDelayPos = reverb->preDelayPos;
combPos0 = reverb->combPos[0];
combPos1 = reverb->combPos[1];
allpassPos0 = reverb->allpassPos[0];
allpassPos1 = reverb->allpassPos[1];
for (j = 0; j < AXFX_STEREO_CHANNEL_MAX; j++) {
if (reverb->busIn) {
sp64 = *busParam[j] + *busIn[j]++;
} else {
sp64 = *busParam[j];
}
earlyLine = reverb->earlyLine[j];
sp58 = earlyLine[earlyPos];
earlyLine[earlyPos] = sp64 + (sp58 * earlyCoef);
if (reverb->preDelayLength != 0) {
preDelayLine = reverb->preDelayLine[j];
sp4C = preDelayLine[preDelayPos];
preDelayLine[preDelayPos] = sp64;
} else {
sp4C = sp64;
}
combLine0 = reverb->combLine[j][0];
sp40 = combLine0[combPos0];
combLine0[combPos0] = sp4C + (sp40 * combCoef0);
combLine1 = reverb->combLine[j][1];
sp3C = combLine1[combPos1];
combLine1[combPos1] = sp4C + (sp3C * combCoef1);
sp38 = sp40 + sp3C;
allpassLine = reverb->allpassLine[j][0];
sp2C = allpassLine[allpassPos0];
sp28 = sp38 + (sp2C * allpassCoef);
allpassLine[allpassPos0] = sp28;
sp24 = sp2C - (sp28 * allpassCoef);
sp18 = (sp14 * sp24) + (lpfCoef * reverb->lastLpfOut[j]);
reverb->lastLpfOut[j] = sp18;
allpassLine = reverb->allpassLine[j][1];
sp2C = allpassLine[allpassPos1];
sp28 = sp18 + (sp2C * allpassCoef);
allpassLine[allpassPos1] = sp28;
sp20 = sp2C - (sp28 * allpassCoef);
sp60 = (sp58 * spC) + (sp20 * sp8);
*busParam[j]++ = (sp60 * reverb->outGain);
if (reverb->busOut) {
*busOut[j]++ = (sp60 * reverb->sendGain);
}
}
if (++reverb->earlyPos >= reverb->earlyLength) {
reverb->earlyPos = 0;
}
if (reverb->preDelayLength != 0) {
if (++reverb->preDelayPos >= reverb->preDelayLength) {
reverb->preDelayPos = 0;
}
}
if (++reverb->combPos[0] >= reverb->combLength[0]) {
reverb->combPos[0] = 0;
}
if (++reverb->combPos[1] >= reverb->combLength[1]) {
reverb->combPos[1] = 0;
}
if (++reverb->allpassPos[0] >= reverb->allpassLength[0]) {
reverb->allpassPos[0] = 0;
}
if (++reverb->allpassPos[1] >= reverb->allpassLength[1]) {
reverb->allpassPos[1] = 0;
}
}
}
static BOOL __AllocDelayLine(AXFX_REVERBSTD_EXP* fx) {
u32 ch, i;
for (ch = 0; ch < 3; ch++) {
fx->earlyLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->earlyMaxLength);
if (fx->earlyLine[ch] == NULL)
return FALSE;
if (fx->preDelayMaxLength) {
fx->preDelayLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->preDelayMaxLength);
if (fx->preDelayLine[ch] == NULL)
return FALSE;
} else {
fx->preDelayLine[ch] = NULL;
}
for (i = 0; i < 2; i++) {
fx->combLine[ch][i] = (f32*)__AXFXAlloc(sizeof(f32) * fx->combMaxLength[i]);
if (fx->combLine[ch][i] == NULL)
return FALSE;
}
for (i = 0; i < 2; i++) {
fx->allpassLine[ch][i] = (f32*)__AXFXAlloc(sizeof(f32) * fx->allpassMaxLength[i]);
if (fx->allpassLine[ch][i] == NULL)
return FALSE;
}
}
return TRUE;
}
static void __BzeroDelayLines(AXFX_REVERBSTD_EXP* fx) {
u32 ch, i;
for (ch = 0; ch < 3; ch++) {
if (fx->earlyLine[ch])
memset(fx->earlyLine[ch], 0, sizeof(f32) * fx->earlyMaxLength);
if (fx->preDelayLine[ch])
memset(fx->preDelayLine[ch], 0, sizeof(f32) * fx->preDelayMaxLength);
for (i = 0; i < 2; i++) {
if (fx->combLine[ch][i])
memset(fx->combLine[ch][i], 0, sizeof(f32) * fx->combMaxLength[i]);
}
for (i = 0; i < 2; i++) {
if (fx->allpassLine[ch][i])
memset(fx->allpassLine[ch][i], 0, sizeof(f32) * fx->allpassMaxLength[i]);
}
}
}
static void __FreeDelayLine(AXFX_REVERBSTD_EXP* fx) {
u32 ch, i;
for (ch = 0; ch < 3; ch++) {
if (fx->earlyLine[ch]) {
__AXFXFree(fx->earlyLine[ch]);
fx->earlyLine[ch] = NULL;
}
if (fx->preDelayLine[ch]) {
__AXFXFree(fx->preDelayLine[ch]);
fx->preDelayLine[ch] = NULL;
}
for (i = 0; i < 2; i++) {
if (fx->combLine[ch][i]) {
__AXFXFree(fx->combLine[ch][i]);
fx->combLine[ch][i] = NULL;
}
}
for (i = 0; i < 2; i++) {
if (fx->allpassLine[ch][i]) {
__AXFXFree(fx->allpassLine[ch][i]);
fx->allpassLine[ch][i] = NULL;
}
}
}
}
static BOOL __InitParams(AXFX_REVERBSTD_EXP* fx) {
u32 i;
if (fx->earlyMode >= 8)
return FALSE;
if (fx->preDelayTime < 0.0f || fx->preDelayTime > fx->preDelayTimeMax)
return FALSE;
if (fx->fusedMode >= 6)
return FALSE;
if (fx->fusedTime < 0.0f)
return FALSE;
if (fx->coloration < 0.0f || fx->coloration > 1.0f)
return FALSE;
if (fx->damping < 0.0f || fx->damping > 1.0f)
return FALSE;
if (fx->earlyGain < 0.0f || fx->earlyGain > 1.0f)
return FALSE;
if (fx->fusedGain < 0.0f || fx->fusedGain > 1.0f)
return FALSE;
if (fx->outGain < 0.0f || fx->outGain > 1.0f)
return FALSE;
if (fx->sendGain < 0.0f || fx->sendGain > 1.0f)
return FALSE;
fx->earlyPos = 0;
fx->earlyLength = __EarlySizeTable[fx->earlyMode];
if (fx->earlyMode <= 3) {
fx->earlyCoef = -0.33f;
} else {
fx->earlyCoef = 0.33f;
}
fx->preDelayPos = 0;
fx->preDelayLength = (u32)(fx->preDelayTime * 32000);
for (i = 0; i < 2; i++) {
f32 t;
fx->combPos[i] = 0;
fx->combLength[i] = __FilterSizeTable[fx->fusedMode][i];
t = -3.0f * (f32)(fx->combLength[i]) / (f32)(fx->fusedTime * 32000);
fx->combCoef[i] = pow(10.0f, t);
}
fx->allpassPos[0] = 0;
fx->allpassLength[0] = __FilterSizeTable[fx->fusedMode][2];
fx->allpassPos[1] = 0;
fx->allpassLength[1] = __FilterSizeTable[fx->fusedMode][3];
fx->allpassCoef = fx->coloration;
fx->lpfCoef = 1.0f - fx->damping;
if (fx->lpfCoef > 0.95f) {
fx->lpfCoef = 0.95f;
}
fx->lastLpfOut[0] = 0.0f;
fx->lastLpfOut[1] = 0.0f;
fx->lastLpfOut[2] = 0.0f;
return TRUE;
}

View File

@@ -1,100 +0,0 @@
#include <revolution/fa/types.h>
#include <string.h>
typedef struct FA_NAND_ATTACH {
char path[80];
u32 size;
} FA_NAND_ATTACH;
typedef struct FA_ATTACH_REQUEST {
FADrvTbl* table;
u32 count;
} FA_ATTACH_REQUEST;
FADisk* gOpenDisk[26];
FAPartition* gOpenPartition[26];
typedef struct FA_DISK_INIT {
s32 (*initialize)(FADiskTbl*, u32);
u32 extension;
} FA_DISK_INIT;
extern s32 pfd_sddrv_init_drv_tbl(FADiskTbl* table, u32 extension);
extern s32 usbh_msc_blk_init_drv_tbl(FADiskTbl* table, u32 extension);
extern s32 fa_nanddrv_init_drv_tbl(FADiskTbl* table, u32 extension);
static FA_DISK_INIT diskInitTbl[] = {
{pfd_sddrv_init_drv_tbl, 0},
{usbh_msc_blk_init_drv_tbl, 0},
{fa_nanddrv_init_drv_tbl, 0},
};
static struct {
FA_DISK_INIT* entries;
u32 count;
} drvInitFunc = {diskInitTbl, 3};
extern s32 pdm_open_disk(FA_DISK_INIT* table, FADisk** disk);
extern s32 pdm_open_partition(FADisk* disk, u32 index, FAPartition** partition);
extern s32 pfstub_attach(FA_ATTACH_REQUEST* request, FA_NAND_ATTACH* nand);
extern s32 pfd_sddrv_is_media_insert(void);
extern s32 pfd_mscdrv_is_media_insert(void);
FAError FAAttach(u32 device, char* nand_path, u32 nand_size, FADrvTbl* table) {
FADisk* disk;
FA_ATTACH_REQUEST request;
FA_NAND_ATTACH nand;
s32 error;
s32 index;
if (device >= 4) {
return -2;
}
if (table == NULL) {
return -2;
}
if (device == 2 && nand_path == NULL) {
return -2;
}
if (device == 3 && table->pPart == NULL) {
return -2;
}
if (device <= 2) {
if (pdm_open_disk(&drvInitFunc.entries[(u8)device], &disk) != 0) {
return -1;
}
if (pdm_open_partition(disk, 0, &table->pPart) != 0) {
return -1;
}
}
request.table = table;
request.count = 0;
if (device == 2) {
memcpy(nand.path, nand_path, 78);
nand.size = nand_size;
}
if (device == 2) {
error = pfstub_attach(&request, &nand);
} else {
error = pfstub_attach(&request, NULL);
}
if (error != 0) {
return -1;
}
index = table->drive - 'A';
if (device <= 2) {
gOpenDisk[index] = disk;
gOpenPartition[index] = table->pPart;
if (device == 0) {
if (pfd_sddrv_is_media_insert()) {
request.table->stat |= 0x10;
}
} else if (device == 1) {
if (pfd_mscdrv_is_media_insert()) {
request.table->stat |= 0x10;
}
}
} else {
gOpenDisk[index] = NULL;
gOpenPartition[index] = NULL;
}
return 0;
}

View File

@@ -1,8 +0,0 @@
#include <revolution/fa.h>
extern s32 pfstub_buffering(s8 drive, s32 mode);
FAError FABuffering(s8 drive, s32 mode) {
s32 error = pfstub_buffering(drive, mode);
return (-error | error) >> 31;
}

View File

@@ -1,11 +0,0 @@
#include <revolution/fa.h>
extern FAFILE* pfstub_create(const char* fileName, int mode);
FAFILE* FACreate(const char* fileName, int mode) {
FAFILE* result = pfstub_create(fileName, mode);
if (result == NULL) {
result = NULL;
}
return result;
}

View File

@@ -1,8 +0,0 @@
#include <revolution/fa.h>
extern s32 pfstub_createdir(const char* dirName, s32 mode, FADta* dta);
s32 FACreatedir(const char* dirName, s32 mode, FADta* dta) {
s32 result = pfstub_createdir(dirName, mode, dta);
return (-result | result) >> 31;
}

View File

@@ -1,24 +0,0 @@
#include <revolution/fa.h>
extern FADisk* gOpenDisk[26];
extern FAPartition* gOpenPartition[26];
extern s32 pfstub_detach(s8 drive);
extern s32 pdm_close_partition(FAPartition* partition);
extern s32 pdm_close_disk(FADisk* disk);
FAError FADetach(s8 drive) {
FADisk* disk = gOpenDisk[drive - 'A'];
FAPartition* partition = gOpenPartition[drive - 'A'];
if (pfstub_detach(drive) != 0) {
return -1;
}
if (disk != NULL && partition != NULL) {
if (pdm_close_partition(partition) != 0) {
return -1;
}
if (pdm_close_disk(disk) != 0) {
return -1;
}
}
return 0;
}

View File

@@ -1,11 +0,0 @@
#include <revolution/fa.h>
extern s32 pfstub_errnum(void);
FAError FAErrnum(void) {
s32 error = pfstub_errnum();
if (error == 5) {
return 5;
}
return error == 0 ? 0 : error;
}

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