Compare commits

..

66 Commits

Author SHA1 Message Date
coah
65fcc26610 NWC24MsgCommit: 15/18 exact (worker fc42b29c) 2026-09-30 02:56:20 +00:00
coah
5875521928 NWC24MsgCommit: 11/18 exact (worker 93b2e6b0) (#321) 2026-09-29 21:37:52 -05:00
coah
0e4f2c726f fa/pf_entry_iterator: 14/16 functions (worker 9b46afc6) (#320) 2026-09-29 21:36:34 -05:00
coah
620a8a6814 tiSignWindow: 55/56 functions, data 100% (worker ba6ad09d) (#319) 2026-09-29 21:28:25 -05:00
coah
84972cb9f1 fa/pf_cache: 35/36 functions (worker 242b3d5c) (#318) 2026-09-29 21:16:08 -05:00
coah
54d865f151 tiManager: 61/62 functions (worker db16fa0c) (#317) 2026-09-29 21:08:29 -05:00
coah
0e31a5b37c NWC24MBoxCtrl: 23/25 functions (worker cdaba1ae) (#316) 2026-09-29 21:00:52 -05:00
coah
8b568557b0 iplSDChannelObj: 36/38 exact (worker 0b3375b0) (#315) 2026-09-29 20:55:45 -05:00
coah
19f6c82a98 iplCardSequence: 27/30 functions (worker da89d61f) (#314) 2026-09-29 20:41:01 -05:00
coah
3e81c24a0c tiInputForm: 207/221 exact, 9 asm bodies left (worker a5ca5fd2) (#313) 2026-09-29 20:39:33 -05:00
coah
5e0fbb88f0 NWC24MBoxCtrl: 20/25 functions (worker 1f47cc11) (#312) 2026-09-29 20:35:19 -05:00
coah
32da26fae0 iplCardSequence: 24/30 functions (worker 05134dbe) (#311) 2026-09-29 20:28:03 -05:00
coah
413e6c483b tiInputForm: convert 29 more asm bodies to C (12 left) (worker 99756b60) (#310) 2026-09-29 20:16:30 -05:00
coah
d76c36462f iplCardSequence: 23/30 functions, data 100% (worker 68c1c3b9) (#309) 2026-09-29 20:15:21 -05:00
coah
f1cc81a228 CHANSVm: interpreter case layout (98 of 108 table mismatches left) (worker ff01ec49) (#308) 2026-09-29 20:07:08 -05:00
coah
ca4339eece iplMemoryCard: 41/41 functions (worker 4d184a0a) (#307) 2026-09-29 19:59:56 -05:00
coah
0107230f11 iplGCWindow: 47/48 functions, pool identical (worker c44639cd) (#306) 2026-09-29 19:48:44 -05:00
coah
c77b866ed4 iplGCWindow: 46/48 functions (worker a046844b) (#305) 2026-09-29 19:28:12 -05:00
coah
550c5f19c1 tiInputForm: convert 11 asm bodies to C (worker 392d5810) (#304) 2026-09-29 19:25:34 -05:00
coah
e00d7aefd6 CHANSVm: 207/233 functions (worker 6abd3e30) (#303) 2026-09-29 19:16:21 -05:00
coah
92f10a65fa tiPcKeyboard: 135/141 functions (worker d836d531) (#302) 2026-09-29 19:13:54 -05:00
coah
e858a9362d tiInputForm: 208/221 functions (worker 66d51a87) (#301) 2026-09-29 19:02:36 -05:00
coah
bd1885f9be tiPcKeyboard: 131/141 functions (worker 9de5a728) (#300) 2026-09-29 18:53:51 -05:00
coah
42647c75c1 CHANSVm: 206/233 functions, rodata 100% (worker 9f9055e9) (#299) 2026-09-29 18:51:35 -05:00
coah
83a55a20a0 tiPcKeyboard: 129/141 functions (worker 13286b26) (#298) 2026-09-29 18:38:17 -05:00
coah
46f34f11f5 CHANSVm: 205/233 functions (worker 585bcf56) (#297) 2026-09-29 18:28:33 -05:00
coah
1bc8f49115 tiPcKeyboard: 123/141 functions (worker 51e4c318) (#296) 2026-09-29 18:14:49 -05:00
github-actions[bot]
f055c43c22 docs: update progress [skip ci] 2026-09-29 23:12:58 +00:00
coah
985bae5d42 ci: drop per-run timestamp from readme progress block (#295) 2026-09-29 18:12:24 -05:00
github-actions[bot]
d4696caeaf docs: update progress [skip ci] 2026-09-29 23:09:44 +00:00
coah
2b4ed18122 CHANSVm: 204/233 functions (worker 5e97a5b0) (#294) 2026-09-29 18:09:11 -05:00
github-actions[bot]
02e50d2dc2 docs: update progress [skip ci] 2026-09-29 23:00:27 +00:00
coah
46d7abf8c0 ci: self-hosted job that keeps readme progress numbers updated (#293) 2026-09-29 17:58:51 -05:00
coah
fddb035def Decompile tiPcKeyboard to 120/141 functions (gpt-6.1-sol medium) (worker 7ab3be61) (#292) 2026-09-29 17:46:52 -05:00
coah
e196e79bfd BS2Mach: 21/29 functions (gpt-6.1-sol low) (worker 115f25f2) (#291) 2026-09-29 17:37:35 -05:00
coah
a4854483dc iplSDChannelTitle: 64/69 functions (worker d788a5c0) (#290) 2026-09-29 17:11:49 -05:00
coah
5ed744554c Decompile MyTiInputForm: 84/84 functions, 100% code (gpt-6.1-sol medium) (worker 2013f10c) (#289) 2026-09-29 17:05:33 -05:00
coah
fcb5be85f7 Decompile iplSDChannelTitle to 63/69 functions (gpt-6.1-sol low) (worker b1c15e3d) (#288) 2026-09-29 17:02:20 -05:00
devin-ai-integration[bot]
1a697e61f9 zi8clib: link 8 matched clib units (alts,getc,getSW,initd,is,misc,punct,space) (#287)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-29 21:49:29 +00:00
coah
112e4e1a14 Decompile zi81key to 4/9 functions (gpt-6.1-sol medium) (worker d6b62eb7) (#286) 2026-09-29 16:44:51 -05:00
coah
0aca3c76ee Decompile zi8alpha to 10/12 functions (gpt-6.1-sol low) (worker 86690220) (#285) 2026-09-29 16:42:34 -05:00
coah
8882983861 Decompile zi8cinfo to 9/10 functions (gpt-6.1-sol medium) (worker 2c479148) (#284) 2026-09-29 16:25:13 -05:00
coah
7097003811 NHTTP_thread: 24/26 functions (gpt-6.1-sol low) (worker 15fd8451) (#283) 2026-09-29 16:15:02 -05:00
devin-ai-integration[bot]
e265d9664e setting: link iplAOSSThread (objdiff 100% code+data) (#282)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-29 21:13:55 +00:00
coah
a620eec6a4 Decompile NHTTP_thread to 23/26 functions (gpt-6.1-sol low) (worker 64796af8) (#281) 2026-09-29 16:07:10 -05:00
coah
5cdca2e8aa iplGCSaveData: replace hand-placed lbl_ strings with named data (worker e4de343a) (#280) 2026-09-29 15:51:33 -05:00
coah
3b286167ba Decompile NWC24Download to 7/30 functions (worker be3767b3) (#279) 2026-09-29 15:42:41 -05:00
devin-ai-integration[bot]
882a83064e memoryCard: link iplGCSaveData (objdiff 100% code+data) (#278)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-29 20:24:14 +00:00
coah
d9237cdbd3 Decompile RVL SDK nup to 11/23 functions (worker 626de3f9) (#277) 2026-09-29 14:31:27 -05:00
coah
a6ac8d34d0 Decompile PrFILE2 pf fat to 22/35 functions (worker 2abecd2b) (#276) 2026-09-29 14:30:40 -05:00
coah
58b5333a4e Decompile FA sd drv to 9/26 functions (worker 1602e65a) (#275) 2026-09-29 14:29:54 -05:00
coah
64f977ea3b Decompile MyTiManager to 84/91 functions (worker 8468d303) (#274) 2026-09-29 14:29:06 -05:00
coah
daf758ece1 Decompile AOSS to 7/21 functions (worker 5f0c95f9) (#273) 2026-09-29 10:34:38 -05:00
coah
6cdbe274bd pf_path: 25/27 functions (worker 7cc9ade3) (#272) 2026-09-29 10:27:18 -05:00
coah
2e63974b0c Decompile PrFILE2 pf_path to 24/27 functions (worker 7e56cc66) (#271) 2026-09-29 10:00:22 -05:00
coah
1c419b67a1 Decompile RVL SDK vi to 18/30 functions (worker 3a89b7c7) (#270) 2026-09-29 09:26:03 -05:00
devin-ai-integration[bot]
07459f685a nhttp: link 8 matched units (bgnend, control, list, os_RVL, request, response, d_nhttp, d_nhttp_common) (#269)
Co-authored-by: devin <devin@cognition.ai>
Co-authored-by: wch <usernamecole7@gmail.com>
2026-09-29 14:08:45 +00:00
coah
3b93fc8664 iplSDChannelSelect: 90/129 functions (worker 9a63deb2) (#268) 2026-09-29 08:54:49 -05:00
coah
7f627435b5 Decompile ATERM to 3/26 functions plus its data (worker af65e648) (#267) 2026-09-29 08:50:37 -05:00
coah
74f1719bfd iplSDChannelSelect: 89/129 functions (worker f62627b8) (#266) 2026-09-29 08:17:16 -05:00
coah
506535db40 pf_file: 32/45 functions (worker 99e93149) (#265) 2026-09-29 06:13:58 -05:00
coah
2a4e4f85ed iplSetting: 88/112 functions (worker 77873dae) (#264) 2026-09-29 05:57:26 -05:00
coah
4402bd99a8 pf_file: 31/45 functions (worker 44d9c236) (#263) 2026-09-29 05:38:18 -05:00
coah
44f42d98ed pf_volume: 7/37 functions (worker 5930b324) (#262) 2026-09-29 04:57:07 -05:00
coah
db27a09ea3 iplSDMemory: 49/66 functions (worker ba5a48eb) (#261) 2026-09-29 04:39:51 -05:00
coah
c21dcc3d31 iplSDMemory: 48/66 functions (#260)
* sdmemory: carry over worker delta (sd channel select header changes left out)

* add SDChannelSelect state/worker accessors used by iplSDMemory
2026-09-29 04:21:39 -05:00
136 changed files with 54327 additions and 4643 deletions

62
.github/workflows/readme-progress.yml vendored Normal file
View File

@@ -0,0 +1,62 @@
name: README progress
# runs on the self-hosted runner on cole's server so it doesn't use hosted minutes.
# only push/schedule/manual triggers, never pull_request, so fork PRs can't reach this machine.
on:
push:
branches: [main]
paths-ignore: [README.md]
schedule:
- cron: "*/30 * * * *"
workflow_dispatch:
concurrency:
group: readme-progress
cancel-in-progress: true
permissions:
contents: write
jobs:
progress:
runs-on: [self-hosted, wii-ipl-local]
timeout-minutes: 60
env:
ORIG_APP: /mnt/drive2/projects/wiichannels/wii-ipl/orig/43U/00000008.app
TOOL_CACHE: /mnt/drive2/projects/wiichannels/wii-ipl/build
NINJA: /home/cole/projects/tests/.venv/bin/ninja
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 1
- name: Prepare
run: |
mkdir -p build orig/43U
cp "$ORIG_APP" orig/43U/00000008.app
[ -d build/compilers ] || cp -a "$TOOL_CACHE/compilers" build/
[ -d build/tools ] || cp -a "$TOOL_CACHE/tools" build/
- name: Build
run: |
python3 configure.py --version 43U
"$NINJA"
"$NINJA" build/43U/ok
- name: Report
run: build/tools/objdiff-cli report generate -p . -o build/43U/report.json -f json
- name: Update README
run: python3 tools/update_readme_progress.py build/43U/report.json README.md "$GITHUB_SHA"
- name: Commit
run: |
if git diff --quiet README.md; then exit 0; fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add README.md
git commit -m "docs: update progress [skip ci]"
git pull --rebase origin main || { git rebase --abort; echo "main moved, next run will update"; exit 0; }
git push origin HEAD:main

View File

@@ -50,6 +50,16 @@ Supported versions:
Progress
========
<!-- progress:start -->
| Decompiled | Matched | Linked | Data |
|:---:|:---:|:---:|:---:|
| 84.90% | 75.26% | 56.76% | 86.70% |
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 -->
| Version | Progress |
|-----------------------|------------------------------------------------------------------------------|
| [Wii Menu 4.3U][V43U] | [![FuncBadgeV43U]][V43U] [![DecompBadgeV43U]][V43U] [![LinkBadgeV43U]][V43U] |

View File

@@ -4596,21 +4596,21 @@ updateChannelNotices__Q33ipl5scene15SDChannelSelectFii = .text:0x813DC7EC; // ty
processWorkerState__Q33ipl5scene15SDChannelSelectFv = .text:0x813DC938; // type:function size:0x18C
updateDialogAnimation__Q33ipl5scene15SDChannelSelectFv = .text:0x813DCAC4; // type:function size:0x42C
setDialogMessage__Q33ipl5scene15SDChannelSelectFUlUl = .text:0x813DCEF0; // type:function size:0x24
iplSDChannelSelect_813DCF14 = .text:0x813DCF14; // type:function size:0xCC
iplSDChannelSelect_813DCFE0 = .text:0x813DCFE0; // type:function size:0xCC
iplSDChannelSelect_813DD0AC = .text:0x813DD0AC; // type:function size:0x194
iplSDChannelSelect_813DD240 = .text:0x813DD240; // type:function size:0x198
iplSDChannelSelect_813DD3D8 = .text:0x813DD3D8; // type:function size:0x1F8
iplSDChannelSelect_813DD5D0 = .text:0x813DD5D0; // type:function size:0x5A4
iplSDChannelSelect_813DDB74 = .text:0x813DDB74; // type:function size:0x40
iplSDChannelSelect_813DDBB4 = .text:0x813DDBB4; // type:function size:0xB4
iplSDChannelSelect_813DDC68 = .text:0x813DDC68; // type:function size:0x18
iplSDChannelSelect_813DDC80 = .text:0x813DDC80; // type:function size:0x58
iplSDChannelSelect_813DDCD8 = .text:0x813DDCD8; // type:function size:0x8C
iplSDChannelSelect_813DDD64 = .text:0x813DDD64; // type:function size:0x58
iplSDChannelSelect_813DDDBC = .text:0x813DDDBC; // type:function size:0x5C
iplSDChannelSelect_813DDE18 = .text:0x813DDE18; // type:function size:0x2C
iplSDChannelSelect_813DDE44 = .text:0x813DDE44; // type:function size:0x24
isCurrentTitleUsageEnough__Q33ipl5scene15SDChannelSelectCFPCl = .text:0x813DCF14; // type:function size:0xCC
getCurrentTitleUsage__Q33ipl5scene15SDChannelSelectCFPlPl = .text:0x813DCFE0; // type:function size:0xCC
collectTitlesByUsage__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD0AC; // type:function size:0x194
collectTitlesFromNandUsage__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD240; // type:function size:0x198
collectTitlesByChannelOrder__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD3D8; // type:function size:0x1F8
collectTitlesBySpecialChannels__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD5D0; // type:function size:0x5A4
collectTitlesForMode__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUli = .text:0x813DDB74; // type:function size:0x40
findAdjacentChannel__Q33ipl5scene15SDChannelSelectCFiPiPi = .text:0x813DDBB4; // type:function size:0xB4
setCurrentPageAndRefresh__Q33ipl5scene15SDChannelSelectFiiPQ33ipl5scene12SDChannelObj = .text:0x813DDC68; // type:function size:0x18
handleFourPageDialog__Q33ipl5scene15SDChannelSelectFv = .text:0x813DDC80; // type:function size:0x58
flushSaveDataAndMountSD__Q33ipl5scene15SDChannelSelectFv = .text:0x813DDCD8; // type:function size:0x8C
handleThreePageDialog__Q33ipl5scene15SDChannelSelectFv = .text:0x813DDD64; // type:function size:0x58
finishCardDialog__Q33ipl5scene15SDChannelSelectFv = .text:0x813DDDBC; // type:function size:0x5C
finishDialogOperation__Q33ipl5scene15SDChannelSelectFv = .text:0x813DDE18; // type:function size:0x2C
finishDialogTransition__Q33ipl5scene15SDChannelSelectFv = .text:0x813DDE44; // type:function size:0x24
isResetProcessDone__Q33ipl5scene15SDChannelSelectFv = .text:0x813DDE68; // type:function size:0x28
calcCommon__Q33ipl5scene15SDChannelSelectFv = .text:0x813DDE90; // type:function size:0x1B0
calcFadein__Q33ipl5scene15SDChannelSelectFv = .text:0x813DE040; // type:function size:0x30
@@ -4623,60 +4623,60 @@ createBaseLayout__Q33ipl5scene15SDChannelSelectFv = .text:0x813DE9FC; // type:fu
updateChannelObjects__Q33ipl5scene15SDChannelSelectFv = .text:0x813DEE3C; // type:function size:0x5C
updateChannelObject__Q33ipl5scene15SDChannelSelectFPQ33ipl5scene12SDChannelObj = .text:0x813DEE98; // type:function size:0x78
calcChannelObjects__Q33ipl5scene15SDChannelSelectFv = .text:0x813DEF10; // type:function size:0x58
iplSDChannelSelect_813DEF68 = .text:0x813DEF68; // type:function size:0x27C
iplSDChannelSelect_813DF1E4 = .text:0x813DF1E4; // type:function size:0x14
drawChannelTransitionObjects__Q33ipl5scene15SDChannelSelectFv = .text:0x813DEF68; // type:function size:0x27C
isChannelReady__Q33ipl5scene15SDChannelSelectFPCQ33ipl5scene12SDChannelObj = .text:0x813DF1E4; // type:function size:0x14
drawChannelObjects__Q33ipl5scene15SDChannelSelectFv = .text:0x813DF1F8; // type:function size:0xB0
iplSDChannelSelect_813DF2A8 = .text:0x813DF2A8; // type:function size:0x138
iplSDChannelSelect_813DF3E0 = .text:0x813DF3E0; // type:function size:0x1C
iplSDChannelSelect_813DF3FC = .text:0x813DF3FC; // type:function size:0x110
iplSDChannelSelect_813DF50C = .text:0x813DF50C; // type:function size:0x4C
iplSDChannelSelect_813DF558 = .text:0x813DF558; // type:function size:0x178
iplSDChannelSelect_813DF6D0 = .text:0x813DF6D0; // type:function size:0x164
processNormalInput__Q33ipl5scene15SDChannelSelectFv = .text:0x813DF2A8; // type:function size:0x138
setPageActionFrame__Q33ipl5scene15SDChannelSelectFv = .text:0x813DF3E0; // type:function size:0x1C
finishPageScroll__Q33ipl5scene15SDChannelSelectFv = .text:0x813DF3FC; // type:function size:0x110
advancePageAnimation__Q33ipl5scene15SDChannelSelectFv = .text:0x813DF50C; // type:function size:0x4C
initializeNormalPage__Q33ipl5scene15SDChannelSelectFv = .text:0x813DF558; // type:function size:0x178
refreshPageObjects__Q33ipl5scene15SDChannelSelectFiPQ33ipl5scene12SDChannelObji = .text:0x813DF6D0; // type:function size:0x164
createChannelList__Q33ipl5scene15SDChannelSelectFib = .text:0x813DF834; // type:function size:0x110
createChannelObject__Q33ipl5scene15SDChannelSelectFii = .text:0x813DF944; // type:function size:0x84
destroyUnusedChannelObjects__Q33ipl5scene15SDChannelSelectFiPQ33ipl5scene12SDChannelObj = .text:0x813DF9C8; // type:function size:0xF8
refreshChannelList__Q33ipl5scene15SDChannelSelectFv = .text:0x813DFAC0; // type:function size:0xFC
refreshAfterSDTitleList__Q33ipl5scene15SDChannelSelectFv = .text:0x813DFBBC; // type:function size:0xE4
destroyChannelObject__Q33ipl5scene15SDChannelSelectFPQ33ipl5scene12SDChannelObj = .text:0x813DFCA0; // type:function size:0x50
iplSDChannelSelect_813DFCF0 = .text:0x813DFCF0; // type:function size:0x74
iplSDChannelSelect_813DFD64 = .text:0x813DFD64; // type:function size:0x154
updateChannelObjectOrder__Q33ipl5scene15SDChannelSelectFi = .text:0x813DFCF0; // type:function size:0x74
moveChannelObjectsToDrawOrder__Q33ipl5scene15SDChannelSelectFii = .text:0x813DFD64; // type:function size:0x154
findChannelObject__Q33ipl5scene15SDChannelSelectCFii = .text:0x813DFEB8; // type:function size:0x74
iplSDChannelSelect_813DFF2C = .text:0x813DFF2C; // type:function size:0x1C0
updateArrowVisibility__Q33ipl5scene15SDChannelSelectFv = .text:0x813DFF2C; // type:function size:0x1C0
hasChannelObject__Q33ipl5scene15SDChannelSelectCFii = .text:0x813E00EC; // type:function size:0x140
isChannelInCalc__Q33ipl5scene15SDChannelSelectCFiii = .text:0x813E022C; // type:function size:0x68
iplSDChannelSelect_813E0294 = .text:0x813E0294; // type:function size:0x104
iplSDChannelSelect_813E0398 = .text:0x813E0398; // type:function size:0x18
iplSDChannelSelect_813E03B0 = .text:0x813E03B0; // type:function size:0xA0
iplSDChannelSelect_813E0450 = .text:0x813E0450; // type:function size:0xEC
iplSDChannelSelect_813E053C = .text:0x813E053C; // type:function size:0x84
iplSDChannelSelect_813E05C0 = .text:0x813E05C0; // type:function size:0x64
iplSDChannelSelect_813E0624 = .text:0x813E0624; // type:function size:0xB4
isPageCreated__Q33ipl5scene15SDChannelSelectCFi = .text:0x813E0294; // type:function size:0x104
setStateAndPlaySelectSound__Q33ipl5scene15SDChannelSelectFi = .text:0x813E0398; // type:function size:0x18
setLayoutFrame__Q33ipl5scene15SDChannelSelectFi = .text:0x813E03B0; // type:function size:0xA0
selectChannel__Q33ipl5scene15SDChannelSelectFii = .text:0x813E0450; // type:function size:0xEC
tellStartingZoomAnm__Q33ipl5scene15SDChannelSelectFv = .text:0x813E053C; // type:function size:0x84
prepareRestarting__Q33ipl5scene15SDChannelSelectFi = .text:0x813E05C0; // type:function size:0x64
startPageTransition__Q33ipl5scene15SDChannelSelectFii = .text:0x813E0624; // type:function size:0xB4
getChannelBasePane__Q33ipl5scene15SDChannelSelectCFiii = .text:0x813E06D8; // type:function size:0xAC
getCenterChannelPane__Q33ipl5scene15SDChannelSelectCFi = .text:0x813E0784; // type:function size:0x30
getChannelPane__Q33ipl5scene15SDChannelSelectCFi = .text:0x813E07B4; // type:function size:0x30
getChannelPanePosition__Q33ipl5scene15SDChannelSelectFPQ33ipl5scene15SDChannelSelecti = .text:0x813E07E4; // type:function size:0x64
iplSDChannelSelect_813E0848 = .text:0x813E0848; // type:function size:0x3A4
iplSDChannelSelect_813E0BEC = .text:0x813E0BEC; // type:function size:0x294
setChannelScissor__Q33ipl5scene15SDChannelSelectCFPCQ33ipl5scene12SDChannelObj = .text:0x813E0848; // type:function size:0x3A4
initPageAnimations__Q33ipl5scene15SDChannelSelectFRCQ33ipl4math4VEC3i = .text:0x813E0BEC; // type:function size:0x294
calcPageAnimations__Q33ipl5scene15SDChannelSelectFv = .text:0x813E0E80; // type:function size:0x60
iplSDChannelSelect_813E0EE0 = .text:0x813E0EE0; // type:function size:0x26C
iplSDChannelSelect_813E114C = .text:0x813E114C; // type:function size:0x78
iplSDChannelSelect_813E11C4 = .text:0x813E11C4; // type:function size:0x3A4
iplSDChannelSelect_813E1568 = .text:0x813E1568; // type:function size:0x124
iplSDChannelSelect_813E168C = .text:0x813E168C; // type:function size:0x2D0
iplSDChannelSelect_813E195C = .text:0x813E195C; // type:function size:0x6C
iplSDChannelSelect_813E19C8 = .text:0x813E19C8; // type:function size:0x68
iplSDChannelSelect_813E1A30 = .text:0x813E1A30; // type:function size:0x208
iplSDChannelSelect_813E1C38 = .text:0x813E1C38; // type:function size:0x118
iplSDChannelSelect_813E1D50 = .text:0x813E1D50; // type:function size:0xFC
iplSDChannelSelect_813E1E4C = .text:0x813E1E4C; // type:function size:0x19C
iplSDChannelSelect_813E1FE8 = .text:0x813E1FE8; // type:function size:0x1A4
iplSDChannelSelect_813E218C = .text:0x813E218C; // type:function size:0x16C
iplSDChannelSelect_813E22F8 = .text:0x813E22F8; // type:function size:0x1E0
iplSDChannelSelect_813E24D8 = .text:0x813E24D8; // type:function size:0x204
iplSDChannelSelect_813E26DC = .text:0x813E26DC; // type:function size:0x74
iplSDChannelSelect_813E2750 = .text:0x813E2750; // type:function size:0x164
iplSDChannelSelect_813E28B4 = .text:0x813E28B4; // type:function size:0x2A0
iplSDChannelSelect_813E2B54 = .text:0x813E2B54; // type:function size:0x240
updatePageTransform__Q33ipl5scene15SDChannelSelectFv = .text:0x813E0EE0; // type:function size:0x26C
getCenterChannelIndex__Q33ipl5scene15SDChannelSelectCFPCc = .text:0x813E114C; // type:function size:0x78
createSceneLayouts__Q33ipl5scene15SDChannelSelectFv = .text:0x813E11C4; // type:function size:0x3A4
updateDragState__Q33ipl5scene15SDChannelSelectFv = .text:0x813E1568; // type:function size:0x124
updateDragPageTransition__Q33ipl5scene15SDChannelSelectFv = .text:0x813E168C; // type:function size:0x2D0
finishDragWait__Q33ipl5scene15SDChannelSelectFv = .text:0x813E195C; // type:function size:0x6C
finishDragPageTransition__Q33ipl5scene15SDChannelSelectFv = .text:0x813E19C8; // type:function size:0x68
applyChannelMove__Q33ipl5scene15SDChannelSelectFv = .text:0x813E1A30; // type:function size:0x208
finishChannelMove__Q33ipl5scene15SDChannelSelectFv = .text:0x813E1C38; // type:function size:0x118
resetDragPreview__Q33ipl5scene15SDChannelSelectFv = .text:0x813E1D50; // type:function size:0xFC
finishDragPageChange__Q33ipl5scene15SDChannelSelectFv = .text:0x813E1E4C; // type:function size:0x19C
onEventDerived__Q33ipl5scene15SDChannelSelectFPCcUlPQ33ipl10controller9Interface = .text:0x813E1FE8; // type:function size:0x1A4
onButtonEvent__Q33ipl5scene15SDChannelSelectFPCcUlPCQ33ipl10controller9Interface = .text:0x813E218C; // type:function size:0x16C
startDrag__Q33ipl5scene15SDChannelSelectFPCQ33ipl10controller9Interfaceii = .text:0x813E22F8; // type:function size:0x1E0
finishDrag__Q33ipl5scene15SDChannelSelectFv = .text:0x813E24D8; // type:function size:0x204
isChannelMoveTarget__Q33ipl5scene15SDChannelSelectCFii = .text:0x813E26DC; // type:function size:0x74
moveDrag__Q33ipl5scene15SDChannelSelectFv = .text:0x813E2750; // type:function size:0x164
onEvent__Q43ipl5scene32@unnamed@iplSDChannelSelect_cpp@27SDChannelSelectEventHandlerFUlUlPv = .text:0x813E28B4; // type:function size:0x2A0
onEventDerived__Q43ipl5scene32@unnamed@iplSDChannelSelect_cpp@33SDChannelSelectButtonEventHandlerFUlUlPCQ33ipl10controller9Interface = .text:0x813E2B54; // type:function size:0x240
startResetting__Q33ipl5scene15SDChannelSelectFv = .text:0x813E2D94; // type:function size:0x44
pop__Q33ipl5scene26SDChannelSelectNoticeQueueFv = .text:0x813E2DD8; // type:function size:0x4C
push__Q33ipl5scene27SDChannelSelectCommandQueueFRCQ33ipl5scene22SDChannelSelectCommand = .text:0x813E2E24; // type:function size:0x80
@@ -4694,7 +4694,7 @@ iplSDChannelObj_813E322C = .text:0x813E322C; // type:function size:0x9C
iplSDChannelObj_813E32C8 = .text:0x813E32C8; // type:function size:0x3C
iplSDChannelObj_813E3304 = .text:0x813E3304; // type:function size:0x8
iplSDChannelObj_813E330C = .text:0x813E330C; // type:function size:0x14
iplSDChannelObj_813E3320 = .text:0x813E3320; // type:function size:0x10
getTranslate__Q33ipl5scene12SDChannelObjCFv = .text:0x813E3320; // type:function size:0x10
iplSDChannelObj_813E3330 = .text:0x813E3330; // type:function size:0x24
iplSDChannelObj_813E3354 = .text:0x813E3354; // type:function size:0x98
iplSDChannelObj_813E33EC = .text:0x813E33EC; // type:function size:0x94
@@ -16752,73 +16752,73 @@ __vt__Q33ipl5scene14ParentalDialog = .data:0x81653ED8; // type:object size:0x68
@10007 = .data:0x81653FD8; // type:object size:0xE scope:local data:string
__vt__Q33ipl5scene6Reboot = .data:0x81653FE8; // type:object size:0x4C
__vt__Q33ipl5scene9RootScene = .data:0x81654038; // type:object size:0x4C
lbl_81654088 = .data:0x81654088; // type:object size:0x9 data:string
lbl_81654091 = .data:0x81654091; // type:object size:0x9 data:string
lbl_8165409A = .data:0x8165409A; // type:object size:0x9 data:string
lbl_816540A3 = .data:0x816540A3; // type:object size:0x9 data:string
lbl_816540AC = .data:0x816540AC; // type:object size:0x9 data:string
lbl_816540B5 = .data:0x816540B5; // type:object size:0x9 data:string
lbl_816540BE = .data:0x816540BE; // type:object size:0x9 data:string
lbl_816540C7 = .data:0x816540C7; // type:object size:0x9 data:string
lbl_816540D0 = .data:0x816540D0; // type:object size:0x9 data:string
lbl_816540D9 = .data:0x816540D9; // type:object size:0x9 data:string
lbl_816540E2 = .data:0x816540E2; // type:object size:0x9 data:string
lbl_816540EB = .data:0x816540EB; // type:object size:0x9 data:string
lbl_816540F4 = .data:0x816540F4; // type:object size:0x9 data:string
lbl_816540FD = .data:0x816540FD; // type:object size:0x9 data:string
lbl_81654106 = .data:0x81654106; // type:object size:0x9 data:string
lbl_8165410F = .data:0x8165410F; // type:object size:0x9 data:string
lbl_81654118 = .data:0x81654118; // type:object size:0x9 data:string
lbl_81654121 = .data:0x81654121; // type:object size:0x9 data:string
lbl_8165412A = .data:0x8165412A; // type:object size:0x9 data:string
lbl_81654133 = .data:0x81654133; // type:object size:0x9 data:string
lbl_8165413C = .data:0x8165413C; // type:object size:0x9 data:string
lbl_81654145 = .data:0x81654145; // type:object size:0x9 data:string
lbl_8165414E = .data:0x8165414E; // type:object size:0x9 data:string
lbl_81654157 = .data:0x81654157; // type:object size:0x9 data:string
lbl_81654160 = .data:0x81654160; // type:object size:0x9 data:string
lbl_81654169 = .data:0x81654169; // type:object size:0x9 data:string
lbl_81654172 = .data:0x81654172; // type:object size:0x9 data:string
lbl_8165417B = .data:0x8165417B; // type:object size:0x9 data:string
lbl_81654184 = .data:0x81654184; // type:object size:0x9 data:string
lbl_8165418D = .data:0x8165418D; // type:object size:0x9 data:string
lbl_81654196 = .data:0x81654196; // type:object size:0x9 data:string
lbl_8165419F = .data:0x8165419F; // type:object size:0x9 data:string
lbl_816541A8 = .data:0x816541A8; // type:object size:0x9 data:string
lbl_816541B1 = .data:0x816541B1; // type:object size:0x9 data:string
lbl_816541BA = .data:0x816541BA; // type:object size:0x9 data:string
lbl_816541C3 = .data:0x816541C3; // type:object size:0x9 data:string
lbl_816541CC = .data:0x816541CC; // type:object size:0x9 data:string
lbl_816541D5 = .data:0x816541D5; // type:object size:0x9 data:string
lbl_816541DE = .data:0x816541DE; // type:object size:0x9 data:string
lbl_816541E7 = .data:0x816541E7; // type:object size:0x9 data:string
lbl_816541F0 = .data:0x816541F0; // type:object size:0x9 data:string
lbl_816541F9 = .data:0x816541F9; // type:object size:0x9 data:string
@16632 = .data:0x81654088; // type:object size:0x9 scope:local data:string
@16633 = .data:0x81654091; // type:object size:0x9 scope:local data:string
@16634 = .data:0x8165409A; // type:object size:0x9 scope:local data:string
@16635 = .data:0x816540A3; // type:object size:0x9 scope:local data:string
@16636 = .data:0x816540AC; // type:object size:0x9 scope:local data:string
@16637 = .data:0x816540B5; // type:object size:0x9 scope:local data:string
@16638 = .data:0x816540BE; // type:object size:0x9 scope:local data:string
@16639 = .data:0x816540C7; // type:object size:0x9 scope:local data:string
@16640 = .data:0x816540D0; // type:object size:0x9 scope:local data:string
@16641 = .data:0x816540D9; // type:object size:0x9 scope:local data:string
@16642 = .data:0x816540E2; // type:object size:0x9 scope:local data:string
@16643 = .data:0x816540EB; // type:object size:0x9 scope:local data:string
@16644 = .data:0x816540F4; // type:object size:0x9 scope:local data:string
@16645 = .data:0x816540FD; // type:object size:0x9 scope:local data:string
@16646 = .data:0x81654106; // type:object size:0x9 scope:local data:string
@16647 = .data:0x8165410F; // type:object size:0x9 scope:local data:string
@16648 = .data:0x81654118; // type:object size:0x9 scope:local data:string
@16649 = .data:0x81654121; // type:object size:0x9 scope:local data:string
@16650 = .data:0x8165412A; // type:object size:0x9 scope:local data:string
@16651 = .data:0x81654133; // type:object size:0x9 scope:local data:string
@16652 = .data:0x8165413C; // type:object size:0x9 scope:local data:string
@16653 = .data:0x81654145; // type:object size:0x9 scope:local data:string
@16654 = .data:0x8165414E; // type:object size:0x9 scope:local data:string
@16655 = .data:0x81654157; // type:object size:0x9 scope:local data:string
@16656 = .data:0x81654160; // type:object size:0x9 scope:local data:string
@16657 = .data:0x81654169; // type:object size:0x9 scope:local data:string
@16658 = .data:0x81654172; // type:object size:0x9 scope:local data:string
@16659 = .data:0x8165417B; // type:object size:0x9 scope:local data:string
@16660 = .data:0x81654184; // type:object size:0x9 scope:local data:string
@16661 = .data:0x8165418D; // type:object size:0x9 scope:local data:string
@16662 = .data:0x81654196; // type:object size:0x9 scope:local data:string
@16663 = .data:0x8165419F; // type:object size:0x9 scope:local data:string
@16664 = .data:0x816541A8; // type:object size:0x9 scope:local data:string
@16665 = .data:0x816541B1; // type:object size:0x9 scope:local data:string
@16666 = .data:0x816541BA; // type:object size:0x9 scope:local data:string
@16667 = .data:0x816541C3; // type:object size:0x9 scope:local data:string
@16668 = .data:0x816541CC; // type:object size:0x9 scope:local data:string
@16669 = .data:0x816541D5; // type:object size:0x9 scope:local data:string
@16670 = .data:0x816541DE; // type:object size:0x9 scope:local data:string
@16671 = .data:0x816541E7; // type:object size:0x9 scope:local data:string
@16672 = .data:0x816541F0; // type:object size:0x9 scope:local data:string
@16673 = .data:0x816541F9; // type:object size:0x9 scope:local data:string
lbl_81654204 = .data:0x81654204; // type:object size:0xF0
lbl_816542F4 = .data:0x816542F4; // type:object size:0xA data:string
lbl_816542FE = .data:0x816542FE; // type:object size:0xA data:string
lbl_81654308 = .data:0x81654308; // type:object size:0xA data:string
lbl_81654312 = .data:0x81654312; // type:object size:0xA data:string
@16674 = .data:0x816542F4; // type:object size:0xA scope:local data:string
@16675 = .data:0x816542FE; // type:object size:0xA scope:local data:string
@16676 = .data:0x81654308; // type:object size:0xA scope:local data:string
@16677 = .data:0x81654312; // type:object size:0xA scope:local data:string
lbl_8165431C = .data:0x8165431C; // type:object size:0x20
lbl_8165433C = .data:0x8165433C; // type:object size:0xB data:string
lbl_81654347 = .data:0x81654347; // type:object size:0xB data:string
lbl_81654352 = .data:0x81654352; // type:object size:0xB data:string
lbl_8165435D = .data:0x8165435D; // type:object size:0xB data:string
@16679 = .data:0x8165433C; // type:object size:0xB scope:local data:string
@16680 = .data:0x81654347; // type:object size:0xB scope:local data:string
@16681 = .data:0x81654352; // type:object size:0xB scope:local data:string
@16682 = .data:0x8165435D; // type:object size:0xB scope:local data:string
lbl_81654368 = .data:0x81654368; // type:object size:0x20
lbl_81654388 = .data:0x81654388; // type:object size:0x14 data:4byte
lbl_8165439C = .data:0x8165439C; // type:object size:0x70
lbl_8165440C = .data:0x8165440C; // type:object size:0x54
lbl_81654460 = .data:0x81654460; // type:object size:0x9 data:string
lbl_81654469 = .data:0x81654469; // type:object size:0x9 data:string
sFourPageDialogPages__Q23ipl5scene = .data:0x8165439C; // type:object size:0x70
sThreePageDialogPages__Q23ipl5scene = .data:0x8165440C; // type:object size:0x54
@16689 = .data:0x81654460; // type:object size:0x9 scope:local data:string
@16690 = .data:0x81654469; // type:object size:0x9 scope:local data:string
lbl_81654472 = .data:0x81654472; // type:object size:0x16
lbl_81654488 = .data:0x81654488; // type:object size:0xE data:string
lbl_81654496 = .data:0x81654496; // type:object size:0x11 data:string
lbl_816544A7 = .data:0x816544A7; // type:object size:0x19 data:string
lbl_816544C0 = .data:0x816544C0; // type:object size:0x1B data:string
@24438 = .data:0x81654488; // type:object size:0xE scope:local data:string
@24439 = .data:0x81654496; // type:object size:0x11 scope:local data:string
@24489 = .data:0x816544A7; // type:object size:0x19 scope:local data:string
@24490 = .data:0x816544C0; // type:object size:0x1B scope:local data:string
jumptable_816544DC = .data:0x816544DC; // type:object size:0x38 scope:local
jumptable_81654514 = .data:0x81654514; // type:object size:0x40 scope:local
lbl_81654554 = .data:0x81654554; // type:object size:0xB data:string
lbl_8165455F = .data:0x8165455F; // type:object size:0xE data:string
@24961 = .data:0x81654554; // type:object size:0xB scope:local data:string
@24962 = .data:0x8165455F; // type:object size:0xE scope:local data:string
jumptable_81654570 = .data:0x81654570; // type:object size:0x3C scope:local
jumptable_816545AC = .data:0x816545AC; // type:object size:0x40 scope:local
jumptable_816545EC = .data:0x816545EC; // type:object size:0x40 scope:local
@@ -16826,16 +16826,16 @@ jumptable_8165462C = .data:0x8165462C; // type:object size:0x40 scope:local
jumptable_8165466C = .data:0x8165466C; // type:object size:0x28 scope:local
jumptable_81654694 = .data:0x81654694; // type:object size:0x78 scope:local
lbl_8165473B = .data:0x8165473B; // type:object size:0xD4
lbl_8165480F = .data:0x8165480F; // type:object size:0xE data:string
lbl_8165481D = .data:0x8165481D; // type:object size:0xB data:string
lbl_81654828 = .data:0x81654828; // type:object size:0x10 data:string
@26032 = .data:0x8165480F; // type:object size:0xE scope:local data:string
@26047 = .data:0x8165481D; // type:object size:0xB scope:local data:string
@26062 = .data:0x81654828; // type:object size:0x10 scope:local data:string
lbl_81654838 = .data:0x81654838; // type:object size:0x146
lbl_8165497E = .data:0x8165497E; // type:object size:0x16 data:string
lbl_81654994 = .data:0x81654994; // type:object size:0x10 data:string
lbl_816549A4 = .data:0x816549A4; // type:object size:0xF data:string
lbl_816549B3 = .data:0x816549B3; // type:object size:0x14 data:string
lbl_816549C7 = .data:0x816549C7; // type:object size:0x10 data:string
lbl_816549D7 = .data:0x816549D7; // type:object size:0xF data:string
@26231 = .data:0x8165497E; // type:object size:0x16 scope:local data:string
@26266 = .data:0x81654994; // type:object size:0x10 scope:local data:string
@26311 = .data:0x816549A4; // type:object size:0xF scope:local data:string
@26312 = .data:0x816549B3; // type:object size:0x14 scope:local data:string
@26336 = .data:0x816549C7; // type:object size:0x10 scope:local data:string
@26559 = .data:0x816549D7; // type:object size:0xF scope:local data:string
lbl_81654A08 = .data:0x81654A08; // type:object size:0x1C
lbl_81654A24 = .data:0x81654A24; // type:object size:0x18
lbl_81654A3C = .data:0x81654A3C; // type:object size:0xFC
@@ -22014,20 +22014,20 @@ natType = .sdata:0x81696D30; // type:object size:0x4 scope:local data:4byte
@11124 = .sdata:0x81696D69; // type:object size:0x7 scope:local data:string
@11125 = .sdata:0x81696D70; // type:object size:0x7 scope:local data:string
@11250 = .sdata:0x81696D78; // type:object size:0x2 scope:local
lbl_81696D80 = .sdata:0x81696D80; // type:object size:0x1
lbl_81696D81 = .sdata:0x81696D81; // type:object size:0x6 data:string
lbl_81696D87 = .sdata:0x81696D87; // type:object size:0x6 data:string
lbl_81696D8D = .sdata:0x81696D8D; // type:object size:0x6 data:string
lbl_81696D93 = .sdata:0x81696D93; // type:object size:0x6 data:string
lbl_81696D99 = .sdata:0x81696D99; // type:object size:0x6 data:string
lbl_81696D9F = .sdata:0x81696D9F; // type:object size:0x7 data:string
@16631 = .sdata:0x81696D80; // type:object size:0x1 scope:local
@16684 = .sdata:0x81696D81; // type:object size:0x6 scope:local data:string
@16685 = .sdata:0x81696D87; // type:object size:0x6 scope:local data:string
@16686 = .sdata:0x81696D8D; // type:object size:0x6 scope:local data:string
@16687 = .sdata:0x81696D93; // type:object size:0x6 scope:local data:string
@16688 = .sdata:0x81696D99; // type:object size:0x6 scope:local data:string
@16692 = .sdata:0x81696D9F; // type:object size:0x7 scope:local data:string
lbl_81696DA8 = .sdata:0x81696DA8; // type:object size:0x4 data:4byte
lbl_81696DAC = .sdata:0x81696DAC; // type:object size:0x6 data:wstring
lbl_81696DB2 = .sdata:0x81696DB2; // type:object size:0x4 data:string
lbl_81696DB6 = .sdata:0x81696DB6; // type:object size:0x7 data:string
lbl_81696DBD = .sdata:0x81696DBD; // type:object size:0x1
lbl_81696DBE = .sdata:0x81696DBE; // type:object size:0x4 data:string
lbl_81696DC2 = .sdata:0x81696DC2; // type:object size:0x5 data:string
@25675 = .sdata:0x81696DB2; // type:object size:0x4 scope:local data:string
@25689 = .sdata:0x81696DB6; // type:object size:0x7 scope:local data:string
@25710 = .sdata:0x81696DBD; // type:object size:0x1 scope:local
@26199 = .sdata:0x81696DBE; // type:object size:0x4 scope:local data:string
@26201 = .sdata:0x81696DC2; // type:object size:0x5 scope:local data:string
lbl_81696DC7 = .sdata:0x81696DC7; // type:object size:0x8 data:string
lbl_81696DD0 = .sdata:0x81696DD0; // type:object size:0x4 data:4byte
lbl_81696DD4 = .sdata:0x81696DD4; // type:object size:0x4 data:4byte

View File

@@ -815,7 +815,7 @@ config.libs = [
Object(NonMatching, "scene/memoryCard/iplMemoryCard.cpp"),
Object(NonMatching, "scene/memoryCard/iplMemoryCardBase.cpp"),
Object(NonMatching, "scene/memoryCard/iplMemoryCardManager.cpp"),
Object(NonMatching, "scene/memoryCard/iplGCSaveData.cpp"),
Object(Matching, "scene/memoryCard/iplGCSaveData.cpp"),
Object(NonMatching, "scene/memoryCard/iplGCWindow.cpp"),
]
),
@@ -875,7 +875,7 @@ config.libs = [
Object(Matching, "scene/setting/iplAPScanThread.cpp"),
Object(NonMatching, "scene/setting/iplUSBAP.cpp"),
Object(NonMatching, "scene/setting/iplUSBAPThread.cpp"),
Object(NonMatching, "scene/setting/iplAOSSThread.cpp"),
Object(Matching, "scene/setting/iplAOSSThread.cpp"),
Object(NonMatching, "scene/setting/AOSSLink.c"),
Object(NonMatching, "scene/setting/iplRakuRakuThread.cpp"),
Object(NonMatching, "scene/setting/AOSS.c"),
@@ -985,21 +985,21 @@ config.libs = [
Object(NonMatching, "clib/zconvert.c"),
Object(NonMatching, "clib/zi81key.c"),
Object(NonMatching, "clib/zi8alpha.c"),
Object(NonMatching, "clib/zi8alts.c"),
Object(Matching, "clib/zi8alts.c"),
Object(NonMatching, "clib/zi8cgetc.c"),
Object(NonMatching, "clib/zi8cinfo.c"),
Object(Matching, "clib/zi8copy.c"),
Object(NonMatching, "clib/zi8dawg.c"),
Object(NonMatching, "clib/zi8getc.c"),
Object(Matching, "clib/zi8getc.c"),
Object(NonMatching, "clib/zi8getc2.c"),
Object(NonMatching, "clib/zi8getSW.c"),
Object(NonMatching, "clib/zi8initd.c"),
Object(NonMatching, "clib/zi8is.c"),
Object(Matching, "clib/zi8getSW.c"),
Object(Matching, "clib/zi8initd.c"),
Object(Matching, "clib/zi8is.c"),
Object(NonMatching, "clib/zi8match.c"),
Object(NonMatching, "clib/zi8misc.c"),
Object(Matching, "clib/zi8misc.c"),
Object(NonMatching, "clib/zi8pud2.c"),
Object(NonMatching, "clib/Zi8punct.c"),
Object(NonMatching, "clib/zi8space.c"),
Object(Matching, "clib/Zi8punct.c"),
Object(Matching, "clib/zi8space.c"),
Object(NonMatching, "clib/zi8uwd.c"),
Object(Matching, "clib/zi8ver.c"),
Object(Matching, "clib/zi8ZHuwd.c"),
@@ -1053,19 +1053,19 @@ config.libs = [
]
),
RevoEXLib("nhttp", [
Object(NonMatching, "nhttp/NHTTP_bgnend.c"),
Object(NonMatching, "nhttp/NHTTP_control.c"),
Object(NonMatching, "nhttp/NHTTP_list.c"),
Object(NonMatching, "nhttp/NHTTP_os_RVL.c"),
Object(Matching, "nhttp/NHTTP_bgnend.c"),
Object(Matching, "nhttp/NHTTP_control.c"),
Object(Matching, "nhttp/NHTTP_list.c"),
Object(Matching, "nhttp/NHTTP_os_RVL.c"),
Object(NonMatching, "nhttp/NHTTP_recvbuf.c"),
Object(NonMatching, "nhttp/NHTTP_request.c"),
Object(NonMatching, "nhttp/NHTTP_response.c"),
Object(Matching, "nhttp/NHTTP_request.c"),
Object(Matching, "nhttp/NHTTP_response.c"),
Object(NonMatching, "nhttp/NHTTP_socket_RVL.c"),
Object(NonMatching, "nhttp/NHTTP_stdlib_RVL.c"),
Object(NonMatching, "nhttp/NHTTP_thread.c"),
Object(NonMatching, "nhttp/d_nhttp_private.c"),
Object(NonMatching, "nhttp/d_nhttp.c"),
Object(NonMatching, "nhttp/d_nhttp_common.c"),
Object(Matching, "nhttp/d_nhttp.c"),
Object(Matching, "nhttp/d_nhttp_common.c"),
]
),
RevoEXLib("nwc24", [
@@ -1089,7 +1089,7 @@ config.libs = [
Object(Matching, "nwc24/NWC24UserId.c"),
Object(Matching, "nwc24/NWC24Time.c"),
Object(Matching, "nwc24/NWC24Ipc.c"),
Object(NonMatching, "nwc24/NWC24Download.c"),
Object(Equivalent, "nwc24/NWC24Download.c"),
Object(Matching, "nwc24/NWC24CHJump.c"),
Object(NonMatching, "nwc24/NWC24System.c"),
]

View File

@@ -0,0 +1,72 @@
#ifndef IPL_MEMORY_CARD_LIB_H
#define IPL_MEMORY_CARD_LIB_H
#include <revolution/types.h>
namespace ipl {
namespace memorycard {
typedef struct FileInfo {
u16 fileNo; // 0x00
u16 size; // 0x02
u8 canCopy; // 0x04
u8 canMove; // 0x05
u16 unk_0x06; // 0x06
u32 key; // 0x08
} FileInfo; // 0x0C
typedef struct CardState {
vu8 unk_0x00; // 0x00
vu8 changed; // 0x01
vs16 state; // 0x02
vu16 unk_0x04; // 0x04
vu16 unk_0x06; // 0x06
vu32 key; // 0x08
vu16 unk_0x0C; // 0x0C
vu16 unk_0x0E; // 0x0E
vu16 freeBlocks; // 0x10
vu16 unk_0x12; // 0x12
} CardState; // 0x14
typedef struct IconState {
u8 bannerEnable; // 0x00
u8 unk_0x01; // 0x01
u8 unk_0x02; // 0x02
u8 bannerType; // 0x03
s8 anmDelta; // 0x04
u8 anmType; // 0x05
u8 unk_0x06; // 0x06
u8 unk_0x07; // 0x07
u8 iconFmt[8]; // 0x08
u16 anmFrameBits; // 0x10
s16 anmMax; // 0x12
u32 bannerOffset; // 0x14
u32 bannerTlutOffset; // 0x18
u32 iconOffset[8]; // 0x1C
u32 iconTlutOffset; // 0x3C
} IconState; // 0x40
void probeCard();
CardState* getCardSlotState();
FileInfo* getCardDirState();
IconState* getIconStateArray();
long getCardLastSendCmd();
long getCardLastSrcSlot();
long getCardLastCMDFCmdResult();
void sendCardFormatCmd(u8 slot);
void sendCardCopyCmd(u8 slot, s16 fileNo);
void sendCardMoveCmd(u8 slot, s16 fileNo);
void sendCardDeleteCmd(u8 slot, s16 fileNo);
const char* getIconComment(u8 slot, s16 fileNo);
void initCardThread();
#if defined(IPL_MEMORY_CARD_CPP) || defined(IPL_CARD_SEQUENCE_CPP)
BOOL shutdownCardThread();
#else
bool shutdownCardThread();
#endif
} // namespace memorycard
} // namespace ipl
#endif // IPL_MEMORY_CARD_LIB_H

View File

@@ -122,6 +122,14 @@ extern WWWProtocolFinalizeFn WWWProtocolFinished;
extern WWWProtocolFinalizeFn WWWProtocolFailed;
extern WWWAddProtocolFn WWWAddProtocol;
#ifdef IPL_SETTING_IMPLEMENTATION
namespace ipl {
namespace scene {
class Setting;
}
}
#endif
namespace www {
namespace arcreader {
class ArcContainer;
@@ -206,6 +214,9 @@ namespace ext_ead {
WWWHandle* GetHandle() { return mpBrowserHandle; }
private:
#ifdef IPL_SETTING_IMPLEMENTATION
friend class ::ipl::scene::Setting;
#endif
static BOOL SNotifyCallback_(WWWHandle* wwwBrowser, WWWHandlewindow* wwwWindow, WWWEvent event, WWWHandleEventData* eventData);
BOOL NotifyCallback_(WWWHandle* wwwBrowser, WWWHandlewindow* wwwWindow, WWWEvent event, WWWHandleEventData* eventData);

View File

@@ -14,7 +14,15 @@ namespace textinput {
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
public:
#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

@@ -20,6 +20,10 @@ namespace textinput {
virtual void moveNigaoeButton() {}
};
#ifdef MYTIINPUTFORM_IMPLEMENTATION
class ScrollButton;
#endif
class InputForm : public textinput::InputForm {
public:
typedef enum EditMode {
@@ -30,14 +34,51 @@ namespace textinput {
EM_Last
} EditMode;
#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(), 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) {}
#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; }
#ifdef MYTIMANAGER_IMPLEMENTATION
virtual f32 getScrollFrom();
virtual f32 getScrollTo();
#else
virtual f32 getScrollFrom() { return mfScrollFrom; }
virtual f32 getScrollTo() { return mfScrollTo; }
#endif
virtual void open();
virtual void close();
@@ -90,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; }
@@ -103,9 +148,19 @@ namespace textinput {
tistring::Decolated* getSendString() { return mpSendString; }
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
@@ -117,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
@@ -127,7 +186,11 @@ namespace textinput {
bool mbEditScrollDown; // 0x3EF
bool mbCloseWithSend; // 0x3F0
u8 padding[3]; // 0x3F1
undefined4* mpScrollButton; // 0x3F4
#ifdef MYTIINPUTFORM_IMPLEMENTATION
ScrollButton* mpScrollButton;
#else
undefined4* mpScrollButton;
#endif
bool mbScrollUp; // 0x3F8
bool mbScrollDown; // 0x3F9
EditMode meEditMode; // 0x3FC

View File

@@ -16,6 +16,13 @@ namespace textinput {
T_Last,
} Type;
#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();
virtual void onPhotoTrig();

View File

@@ -28,6 +28,9 @@ namespace textinput {
CT_NumericWithSeparator,
CT_NormalWithoutLineFeedWithSign,
CT_PredictWithoutLineFeed,
#ifdef MYTIMANAGER_IMPLEMENTATION
CT_PredictBigText,
#endif
CT_Last
} ConfigType;
@@ -78,7 +81,11 @@ namespace textinput {
virtual void start();
virtual void end();
#ifdef MYTIMANAGER_IMPLEMENTATION
virtual textinput::InputForm* createInputForm();
#else
virtual InputForm* createInputForm();
#endif
virtual void memoDraw();
@@ -93,8 +100,16 @@ namespace textinput {
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();
@@ -111,10 +126,21 @@ namespace textinput {
virtual void configNormalWithoutLineFeedWithSign();
virtual void configPredictWithoutLineFeed();
virtual void configPredictBigText();
#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
#ifdef MYTIMANAGER_IMPLEMENTATION
void* getBackGround() const { return mpBackGround; }
#endif
private:
State* mpCurrentState; // 0x40
@@ -135,6 +161,11 @@ namespace textinput {
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();
@@ -153,6 +184,18 @@ namespace textinput {
virtual void start();
virtual void end();
#ifdef MYTIMANAGER_IMPLEMENTATION
virtual InputForm* InputForm();
virtual keyboard::hwkey::HWKeyboard* HWKeyboard();
virtual keyboard::pctype::LayoutByNW4R* PCKeyboard();
virtual keyboard::cellphonetype::LayoutByNW4R* CellPhoneKeyboard();
virtual void* SignKeyboard();
virtual candidatebox::LayoutByNW4R* CandidateBox();
virtual toolbar::LayoutByNW4R* ToolBar();
virtual void* PredictLanguageSelectDialog();
virtual void* BG();
#endif
private:
Manager* mpManager; // 0x04
};

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,6 +77,9 @@ namespace textinput {
class Base : public CommandSender {
public:
#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 {}
@@ -108,6 +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
@@ -281,6 +290,13 @@ namespace textinput {
// TODO
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public UIObj::Listener {
public:
#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;
@@ -309,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
@@ -319,6 +339,9 @@ 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);

View File

@@ -2,13 +2,62 @@
#define TEXTINPUT_CELL_PHONE_H
#include "tiNw4rManager.h"
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#include "tiKeyboard.h"
#endif
namespace textinput {
namespace keyboard {
namespace cellphonetype {
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
class Base : public textinput::keyboard::KeyboardBase {
#else
class Base {
#endif
public:
// TODO
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
enum InputMode {
IM_00,
IM_01,
IM_02,
IM_03,
IM_04,
};
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();
@@ -30,7 +79,11 @@ namespace textinput {
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();
@@ -38,17 +91,103 @@ namespace textinput {
virtual void vt_0x68(bool);
virtual bool onClose();
#endif
// TODO enum?
int getInputType() const;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
void resetHoldingButton();
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
private:
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 LayoutByNW4R : public Base, public nw4rmanager::Layout {
public:
#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);
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();
#if defined(TIINPUTFORM_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(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

View File

@@ -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,6 +103,7 @@ namespace textinput {
mFlightDuration[i] = 0;
}
}
#endif
GUIComponent(u32 id)
: GUIInterface(), mbInitialize(false), mDraggingButton(0xFFFF), mID(id), mbTriggerTarget(false), mpManager(NULL), mpListener(NULL) {

View File

@@ -11,6 +11,9 @@ namespace textinput {
namespace input {
class HKBManager {
public:
#ifdef TIMANAGER_IMPLEMENTATION
void ClearState();
#endif
static HKBManager& getInstance() { return sInstance; }
void Initialize();
@@ -19,6 +22,26 @@ namespace textinput {
u32 GetModifierState() const;
void SetModifierState(u32, u32);
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
class KeySet {
public:
u8 GetKey() const;
wchar_t GetWChar() const;
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 GetRepeatedKeySet() const;
void SetForceModifierState(u32 mask, u32 state);
#else
class KeySet {
private:
keyboard::cellphonetype::PaneNameToCharCode* pPaneNameToCharCode; // 0x00
@@ -27,6 +50,7 @@ namespace textinput {
u16 uType; // 0x28
};
#endif
private:
u8 unk_0x00[0xFC];

View File

@@ -8,16 +8,37 @@ namespace textinput {
class Manager;
namespace keyboard {
namespace hwkey {
#ifdef TIMANAGER_IMPLEMENTATION
class HWKeyboard : public CommandSender {
#else
class HWKeyboard : CommandSender {
#endif
public:
HWKeyboard(Manager *);
#ifdef TIMANAGER_IMPLEMENTATION
inline ~HWKeyboard();
#else
~HWKeyboard();
#endif
#ifdef TIMANAGER_IMPLEMENTATION
void setLanguage(Destination destination, Language language);
#endif
virtual void init();
#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);
void controlKeyTriggeredHandler(input::HKBManager);
@@ -26,8 +47,13 @@ namespace textinput {
Manager* mpManager; // 0x10
u8 field_0x14; // 0x14
#ifdef TIINPUTFORM_IMPLEMENTATION
u8 mbSingleQuoteClosing;
u8 mbDoubleQuoteClosing;
#else
u8 field_0x15; // 0x15
u8 field_0x16; // 0x16
#endif
};

View File

@@ -13,11 +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:
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
void create(MEMAllocator* allocator);
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual ~EditBuffer();
#else
~EditBuffer();
#endif
private:
void* mpString; // 0x04
@@ -27,6 +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 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
};
@@ -75,13 +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();
#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);
@@ -137,7 +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();
#endif
virtual void setString(const wchar_t* string);
@@ -167,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);
@@ -183,8 +284,21 @@ namespace textinput {
virtual void makeUpCursorPos(CursorPos* cursorPos, u32 pos, s32 startLine, s32 endLine);
#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();
#else
private:
Rect mRect; // 0x120
#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
@@ -192,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
@@ -227,7 +344,14 @@ 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:
#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();
@@ -242,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);
@@ -252,10 +379,37 @@ 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:
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;

View File

@@ -8,17 +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,6 +19,10 @@ 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(const u8& arg) { mbPressedShift = arg; }

View File

@@ -28,11 +28,20 @@ namespace textinput {
virtual void onEvent(nw4r::lyt::Pane* pane, u32 event) {} // 0x10
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);
@@ -56,6 +65,9 @@ namespace textinput {
virtual void setLanguage(Language language);
virtual Language getLanguage() const { return meLanguage; }
#ifdef MYTIMANAGER_IMPLEMENTATION
Language getLanguageForMemo() const { return meLanguage; }
#endif
virtual void setDestination(Destination destination);
@@ -66,15 +78,44 @@ 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); }
#ifdef IPL_ADDRESS_EDIT_CPP
#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);
#ifdef TIMANAGER_IMPLEMENTATION
virtual void setTitleText(wchar_t* titleText);
void initAspect();
#else
virtual void setTitleText(const wchar_t* titleText);
#endif
virtual void start() {}
virtual void end() {}
@@ -119,6 +160,10 @@ namespace textinput {
void enableCompatibleFilter(bool compatibleFilter);
bool isVacancy() const;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
bool isPredictTurning() const;
void startPredictTurnOn(bool enabled);
#endif
private:
MEMAllocator* mpAllocator; // 0x04
@@ -132,9 +177,14 @@ namespace textinput {
InputForm* mpInputForm; // 0x1C
candidatebox::LayoutByNW4R* mpCandidateBox; // 0x20
toolbar::LayoutByNW4R* mpToolBar; // 0x24
#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,12 +14,22 @@ namespace textinput {
class TiEventHandler : public gui::EventHandler {
public:
typedef struct Input {
#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
@@ -86,11 +96,29 @@ namespace textinput {
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
@@ -128,6 +156,11 @@ namespace textinput {
class AnimPaneGroup {
public:
#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
@@ -181,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];
}
@@ -226,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

View File

@@ -1,8 +1,15 @@
#ifndef TEXTINPUT_PC_KEYBOARD_H
#define TEXTINPUT_PC_KEYBOARD_H
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
#include "tiPcKeyboardImpl.h"
#else
#include "tiNw4rManager.h"
#include "tiTextInputBase.h"
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
#include "tiKeyboard.h"
#endif
namespace textinput {
class Manager;
@@ -11,11 +18,29 @@ namespace textinput {
namespace pctype {
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
class UIObj {
public:
class Listener {
public:
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
};
enum InputType {
@@ -26,6 +51,48 @@ namespace textinput {
IT_04,
};
#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;
virtual void init() override;
virtual void updateFromReceiver(u32, void*) override;
virtual void onKey(u32, void*) override;
virtual void getType() override;
virtual void setLanguage(Language) override;
virtual void onActive() override;
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
virtual ~Base();
virtual void create(MEMAllocator* allocator);
virtual void init();
@@ -61,17 +128,72 @@ namespace textinput {
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 {
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
@@ -80,4 +202,5 @@ namespace textinput {
} // namespace textinput
#endif
#endif // TEXTINPUT_HW_KEYBOARD_H

View File

@@ -0,0 +1,394 @@
#ifndef TEXTINPUT_PC_KEYBOARD_IMPL_H
#define TEXTINPUT_PC_KEYBOARD_IMPL_H
#include "tiKeyboard.h"
#include "tiNw4rManager.h"
#include "tiPkData.h"
namespace textinput {
class Manager;
namespace predictlang {
class LayoutByNW4R;
}
namespace keyboard {
namespace signwindow {
class LayoutByNW4R;
}
}
namespace keyboard {
namespace signwindow {
#ifndef TISIGNWINDOW_IMPLEMENTATION
#ifdef TIMANAGER_IMPLEMENTATION
struct LanguageDependencyData;
class Base : public KeyboardBase {
public:
Base(Manager* manager) : mpAllocator(NULL), mpManager(manager) {}
virtual ~Base();
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual int getType();
virtual void setLanguage(Language language);
virtual bool isLocked();
virtual void setPage(u8 page);
virtual u8 getPage();
virtual void movePrevSignPage();
virtual void moveNextSignPage();
virtual void close();
private:
u32 mInputState;
const LanguageDependencyData* mpLanguageData;
MEMAllocator* mpAllocator;
Manager* mpManager;
};
class EventHandler;
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public nw4rmanager::AnmObserver {
public:
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mbActive(false), mbInput(false), mpEventHandler(NULL), mpCaller(NULL) {}
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual void onKey(u32 event, void* data);
virtual void movePrevSignPage();
virtual void moveNextSignPage();
virtual void close();
virtual void draw();
virtual void open(KeyboardBase* keyboard, bool repeat);
virtual bool isActive();
virtual void onChangeAnmState(AnmEvent event, nw4rmanager::AnmPane* pane, nw4rmanager::Anim* animation);
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
virtual bool updateInput(input::HKBManager& hkb);
virtual void throwReleaseForAll();
virtual void resetAnmSignWindow();
virtual void setSignKeyTop(u16 first, u16 count);
virtual void setPageNumber(u16 page);
virtual void endToClose();
virtual void startToInput();
virtual void movePrevSignWindow();
virtual void moveNextSignWindow();
private:
bool mbActive;
bool mbInput;
EventHandler* mpEventHandler;
KeyboardBase* mpCaller;
};
#else
class Base : public KeyboardBase {
public:
virtual bool isLocked();
virtual void setPage(u8 page);
virtual u8 getPage();
virtual void movePrevSignPage();
virtual void moveNextSignPage();
virtual void close();
};
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public nw4rmanager::AnmObserver {
public:
virtual void draw();
virtual void open(KeyboardBase* keyboard, bool repeat);
virtual bool isActive();
};
#endif
#endif
}
namespace pctype {
struct GridKey {
char paneName[18];
wchar_t codes[4];
};
struct ControlKey {
char paneName[20];
u32 key;
};
struct VisiblePanes {
u16 visibleCount;
u16 hiddenCount;
const char* visible[24];
const char* hidden[24];
};
struct Ablaut {
wchar_t code;
wchar_t alternatives[7];
};
struct LanguageData {
const PaneNameToCharCodeWithModeAscii* ascii;
const GridKey* grid;
const ControlKey* controls;
const VisiblePanes* panes;
const Ablaut* ablaut;
};
class Base : public KeyboardBase {
public:
enum TranslateMode {
TM_Direct,
TM_Roman,
TM_Kana
};
enum InputMode {
IM_Direct,
IM_01,
IM_02,
IM_03,
IM_04,
IM_05,
IM_Hiragana,
IM_Katakana
};
enum InputType {
IT_00,
IT_01,
IT_02,
IT_03,
IT_04
};
struct State {
bool rejected;
u8 inputFlags[7];
};
class KeyState {
public:
void refresh_();
void refreshText(nw4r::lyt::Pane* root);
void setABCFlag(u32 flags);
u32 getABCFlag() const { return abcFlags & ~15; }
u32 getABCMode() const { return abcFlags & 15; }
wchar_t getWCCode(u32 index);
wchar_t getWCCode(char* paneName) NO_INLINE;
void setABCMode(u32 mode) {
if ((abcFlags & 15) != mode) {
abcFlags = (abcFlags & ~15) | (mode & 15);
refresh_();
}
}
void setAIUMode(u32 mode) {
if ((aiuFlags & 15) != mode) {
aiuFlags = (aiuFlags & ~15) | (mode & 15);
refresh_();
}
}
u32 abcFlags;
u32 inputType;
u32 aiuFlags;
Language language;
const LanguageData* data;
Base* owner;
};
#ifdef TIMANAGER_IMPLEMENTATION
Base(Manager* manager) {
mKeyState.abcFlags = 0;
mKeyState.inputType = 0;
mKeyState.aiuFlags = 0;
mKeyState.language = USA;
mKeyState.data = NULL;
mKeyState.owner = this;
mpAllocator = NULL;
mbOnlyQwerty = false;
mpManager = manager;
}
#endif
virtual ~Base();
virtual void create(MEMAllocator* allocator);
virtual inline void init();
virtual void updateFromReceiver(u32 command, void* data);
virtual void onKey(u32 event, void* data);
virtual int getType();
virtual void setLanguage(Language language);
virtual void onActive();
virtual void inputCharCode(wchar_t code);
virtual State* getState();
virtual bool isShiftOn() const;
virtual bool isCapsOn() const;
virtual bool isABC();
virtual void setABC(bool abc);
virtual InputMode getABCInputMode() const;
virtual InputMode getAIUInputMode() const;
virtual TranslateMode getTranslateMode() const;
virtual void setTranslateMode(TranslateMode mode);
virtual void onlyQwerty(bool only);
virtual void setLangKeyActive(bool active);
virtual void setInputModeJP(bool, u32, u32);
virtual void setInputModeCK(u32);
virtual void refreshState();
virtual void changeABCInputMode(InputMode mode);
virtual void changeAIUInputMode(InputMode mode);
virtual void onClose();
virtual wchar_t getWCCode(char* paneName);
virtual u32 getControlKey(char* paneName);
virtual void sendInputWChar(wchar_t code, bool repeat);
virtual void goSignInputMode();
virtual void changePredictLanguage();
virtual void updateFixMode();
protected:
State mState;
const LanguageData* mpInitialLanguageData;
KeyState mKeyState;
MEMAllocator* mpAllocator;
bool mbOnlyQwerty;
bool mbLanguageKeyActive;
Manager* mpManager;
};
class LayoutByNW4R;
class AnmPane;
class EventHandler : public nw4rmanager::TiEventHandler {
public:
EventHandler(LayoutByNW4R* layout) : mpKeyboard(layout) {}
virtual ~EventHandler();
virtual void onTiEvent(gui::PaneComponent* component, u32 event, Input* input);
private:
LayoutByNW4R* mpKeyboard;
};
class UIObj : public gui::EventHandler {
public:
class Listener {
public:
virtual void onEvent(UIObj*, u32, void*) = 0;
};
UIObj(u32 id, LayoutByNW4R* layout, Listener* listener) : mId(id), mpLayout(layout), mpListener(listener) {}
virtual ~UIObj();
virtual void onEvent(gui::GUIComponent& component, u32 event, void* data);
virtual void onGUIEvent(gui::PaneComponent& component, u32 event, nw4rmanager::TiEventHandler::Input* input);
protected:
u32 mId;
LayoutByNW4R* mpLayout;
Listener* mpListener;
};
class UIModifierButton : public UIObj {
public:
UIModifierButton(u32 id, LayoutByNW4R* layout, Listener* listener);
inline void Create(nw4rmanager::Layout* layout, const char* pane, const char* bounding);
inline void SetState(bool enabled, u32 inactiveAnimation);
virtual ~UIModifierButton();
virtual void onGUIEvent(gui::PaneComponent& component, u32 event, nw4rmanager::TiEventHandler::Input* input);
gui::PaneComponent* mpPaneComponent;
gui::PaneComponent* mpBoundingComponent;
AnmPane* mpAnimation;
bool mbOn;
};
class UIModePanel : public UIObj {
public:
UIModePanel(u32 id, LayoutByNW4R* layout, Listener* listener);
virtual ~UIModePanel();
virtual void onGUIEvent(gui::PaneComponent& component, u32 event, nw4rmanager::TiEventHandler::Input* input);
void Create(nw4rmanager::Layout* layout);
u32 mMode;
gui::PaneComponent* mpPaneComponents[5];
gui::PaneComponent* mpBoundingComponents[5];
AnmPane* mpAnimations[5];
nw4r::lyt::Pane* mpEnglishText;
nw4r::lyt::Pane* mpHangulText;
nw4r::lyt::Pane* mpModeSelect;
GXTexObj mDirectTexture;
GXTexObj mPinyinTexture;
GXTexObj mEnglishTexture;
GXTexObj mHangulTexture;
};
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public UIObj::Listener {
public:
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mpKeyboardEventHandler(NULL),
mShiftButton(1, this, this), mCapsButton(0, this, this), mModePanel(2, this, this) {}
#endif
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual void updateFromReceiver(u32 command, void* data);
virtual void onKey(u32 event, void* data);
virtual void setLanguage(Language language);
virtual void onActive();
virtual void inputCharCode(wchar_t code);
virtual void setABC(bool abc);
virtual void setTranslateMode(TranslateMode mode);
virtual void onlyQwerty(bool only);
virtual void setLangKeyActive(bool active);
virtual void setInputModeJP(bool abc, u32 abcMode, u32 aiuMode);
virtual void setInputModeCK(u32 mode);
virtual void refreshState();
virtual void onClose();
virtual void sendInputWChar(wchar_t code, bool repeat);
virtual void goSignInputMode();
virtual void changePredictLanguage();
virtual void draw();
virtual void calc();
virtual void setPredictLanguageDialog(predictlang::LayoutByNW4R* dialog);
virtual void setSignWindow(signwindow::LayoutByNW4R* window);
virtual void setLineFeedButton(bool visible);
virtual void setPredictLanguageButton(bool visible);
virtual void setSignWindowButton(bool visible);
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
virtual bool updateInput(input::HKBManager& hkb);
virtual void changeAnimationAllToNormal();
virtual void throwReleaseForAll();
virtual void cancelStateFocusIn();
virtual void updatePredictLanguage(CommandReceiver::ChangePredictMode* mode);
virtual void updateDakuten();
virtual void initLayout();
virtual void onEvent(UIObj* object, u32 event, void* data);
void onPressedCaps();
void onPressedShift(bool shift);
void onReleasedShift();
void createAnmPane_(MEMAllocator* allocator);
private:
EventHandler* mpKeyboardEventHandler;
predictlang::LayoutByNW4R* mpPredictDialog;
signwindow::LayoutByNW4R* mpSignWindow;
bool mbLineFeed;
UIModifierButton mShiftButton;
UIModifierButton mCapsButton;
UIModePanel mModePanel;
};
class AnmPane : public nw4rmanager::AnmPane {
public:
AnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : nw4rmanager::AnmPane(pane, observer), mAnimation(0) {}
virtual void init();
virtual void changeAnimation(u32 animation);
virtual ~AnmPane();
virtual int getState() const { return mAnimation; }
virtual int getKeyType() const { return mKeyType; }
protected:
int mAnimation;
int mKeyType;
};
class NormalButtonAnmPane : public AnmPane {
public:
NormalButtonAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) { mKeyType = 0; }
virtual ~NormalButtonAnmPane();
virtual void onAnmEvent(AnmPaneEvent event);
};
class ShiftCapsAnmPane : public AnmPane {
public:
ShiftCapsAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer), mbOn(false) { mKeyType = 1; }
virtual ~ShiftCapsAnmPane();
virtual void onAnmEvent(AnmPaneEvent event);
bool isFocused() const;
private:
bool mbOn;
};
class ToggleButtonAnmPane : public AnmPane {
public:
ToggleButtonAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) { mKeyType = 2; }
virtual ~ToggleButtonAnmPane();
virtual void onAnmEvent(AnmPaneEvent event);
};
class OnOffButtonAnmPane : public AnmPane {
public:
OnOffButtonAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) { mKeyType = 3; }
virtual ~OnOffButtonAnmPane();
virtual void onAnmEvent(AnmPaneEvent event);
};
}
}
}
#endif

View File

@@ -14,11 +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
#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:
@@ -32,7 +38,11 @@ namespace textinput {
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public nw4rmanager::AnmObserver {
public:
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
#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) {}
@@ -68,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:
#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

@@ -0,0 +1,134 @@
#ifndef TEXTINPUT_SIGN_WINDOW_H
#define TEXTINPUT_SIGN_WINDOW_H
#include "tiKeyboard.h"
#include "tiNw4rManager.h"
#include "tiSwData.h"
namespace textinput {
class Manager;
namespace keyboard {
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;
};
}
}
}
#endif

View File

@@ -3,6 +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 {
@@ -36,7 +39,11 @@ namespace textinput {
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();
@@ -54,14 +61,71 @@ 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:
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
Decolated(u16 maxLen) : StringBase(maxLen), mCursorStart(0), mCursorEnd(0), mbSustain(false), mTranslateMode(0) { initKanaConverter(); }
#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 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* string);
virtual bool moveCursorRight();
virtual bool moveCursorLeft();
virtual void setCursorPos(u32 pos);
virtual void onSustain();
virtual void offSustain();
virtual bool isOnSustain();
virtual u32 getCursorPos() const;
virtual void getCursorPos(u32* start, u32* end);
virtual bool canBackSpace();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
virtual bool deleteForward();
#else
virtual void deleteForward();
#endif
virtual void getSelected(u32& start, u32& end);
virtual wchar_t getWCharAtCursor();
virtual void replaceAtCursor(wchar_t ch);
virtual bool isDakuten();
virtual void converDakuten();
virtual bool isHandaku();
virtual void converHandaku();
virtual void convertAll();
virtual bool isSmall();
virtual void converSmall();
virtual bool atTheBeginningOfASentence();
virtual void initKanaConverter();
virtual wchar_t* getKanaBuffer();
virtual bool isKanaFix() const;
virtual void confirmKana();
virtual void clearKana();
virtual void EnableKSXFilter(bool enable);
#else
virtual void inputChar();
virtual void inputString();
virtual void deleteChar();
@@ -95,15 +159,75 @@ namespace textinput {
virtual void clearKana();
virtual void EnableKSXFilter();
#endif
private:
#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:
WithAtok(u16 maxLength) : Decolated(maxLength) {}
virtual ~WithAtok();
virtual void pushBack(wchar_t ch);
virtual void popBack();
virtual void inputChar(wchar_t ch);
virtual void backSpace();
virtual void confirm(const wchar_t* string);
virtual bool moveCursorRight();
virtual bool moveCursorLeft();
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 fix);
virtual void initConverting();
virtual bool isConverting();
virtual wchar_t* getConfirmedWCString() const;
virtual int getCurrentNumPredicted();
virtual void getPredicted(int index, wchar_t* string);
virtual void commitPredicted(int index);
virtual void setSelectedCandidate(s32 index);
virtual bool isCandidateSelected();
virtual s32 getSelectedCandidate();
virtual void init();
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 enable);
virtual void startConverting();
virtual bool isDictionaryOpened();
virtual void changeKanaMode(bool kana);
virtual wchar_t getInputStringLength();
virtual void resetRelation();
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,9 +34,23 @@ namespace textinput {
} CursorPos;
typedef struct DrawInfo {
#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();
@@ -73,20 +94,80 @@ namespace textinput {
virtual u32 getEndPos() const;
// todo
#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;
#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:
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,11 +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 {
INPUT_COMMAND_0 = 0,
INPUT_COMMAND_37 = 37,
} INPUT_COMMAND;
#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);
@@ -68,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,7 +35,11 @@ namespace textinput {
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
public:
#ifdef TI_TOOLBAR_SAMPLE_CLASS
#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) {}
@@ -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:
#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,7 +49,11 @@ namespace textinput {
public:
Animation() : mfAnimationTime(0.0f), mbInAnimation(false), mbSE(false), mpAnimObserver(NULL) {}
virtual void startAnm(AnimObserver*, f32, f32, f32, void*); // 0x08
#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,14 +1,71 @@
#ifndef TEXTINPUT_ZI_STRING_H
#define TEXTINPUT_ZI_STRING_H
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#include "tiString.h"
#include <eztx.h>
#endif
namespace textinput {
namespace tistring {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
class WithZi : public Decolated {
public:
enum PredictLanguage { PL_Default };
enum LetterMode { LM_Lower, LM_Normal, LM_Upper };
WithZi(u16 maxLength) : Decolated(maxLength), mbDictionaryOpen(false), mbContextChanged(false),
mCurrentWordLength(0), mpDictionaries(NULL), mpDictionaryWork(NULL), mInputLength(0),
mCandidateCount(0), mOemDictionaryId(0), mDictionaryLanguage(0xff), mSelectedCandidate(0),
mPredictLanguage(0), mLetterMode(2), mpHoldingKey(NULL), mbKoreanPartialConfirm(false) {}
virtual ~WithZi();
virtual void init();
virtual void setInputting(wchar_t ch);
virtual int getCurrentNumPredicted();
virtual void getPredicted(int index, wchar_t* string);
virtual const wchar_t* getCurrentSelected();
virtual u16 getInputStringLength();
virtual void setSelectedCandidate(s32 index);
virtual bool isFix();
virtual void setPredictLaunguage(PredictLanguage language);
virtual void changeLetterMode(LetterMode mode);
virtual void ChangeDictionaryLanguage(u8 language);
virtual void setCellPhoneHoldingkey(void* key);
virtual void setElementBuffer();
virtual u8 getPredictLanguage();
s32 getSelectedCandidateIndex() const { return mSelectedCandidate; }
void openDictionary(void* ziDict, void* ziOemDict);
void setCurrentWord(const wchar_t* string);
void update();
const wchar_t* getCurrentInput();
s32 getCurrentInput(wchar_t* buffer, u32 length);
void clearCandidates();
void partialConfirmForKR();
private:
EZTXGetParam mSearch;
u32 mSearchState;
bool mbDictionaryOpen;
bool mbContextChanged;
u32 mCurrentWordLength;
EZTXLanguageEntry* mpDictionaries;
void* mpDictionaryWork;
u16 mInputLength;
s32 mCandidateCount;
u32 mOemDictionaryId;
u8 mDictionaryLanguage;
s32 mSelectedCandidate;
u32 mPredictLanguage;
u32 mLetterMode;
void* mpHoldingKey;
bool mbKoreanPartialConfirm;
};
#else
class WithZi {
public:
virtual ~WithZi();
void openDictionary(void* ziDict, void* ziOemDict);
};
#endif
}
}

View File

@@ -8,15 +8,21 @@
#include <cstring>
#include "global/decomp/utils.h"
namespace ipl {
namespace gui {
class PaneComponent : public ::gui::PaneComponent {};
class PaneManager : public ::gui::PaneManager {
public:
#ifdef IPL_GCW_PANEMANAGER_CTOR_OUT_OF_LINE
PaneManager(::gui::EventHandler* event, const nw4r::lyt::DrawInfo* drawInfo, EGG::Heap* heap, EGG::Allocator* allocator, bool bDisableCon = false) NO_INLINE;
#else
PaneManager(::gui::EventHandler* event, const nw4r::lyt::DrawInfo* drawInfo, EGG::Heap* heap, EGG::Allocator* allocator, bool bDisableCon = false) :
::gui::PaneManager(event, allocator, drawInfo),
mpHeap(heap),
mbDisableCon(bDisableCon) {}
#endif
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
virtual ~PaneManager();

View File

@@ -7,6 +7,10 @@
#include "utility/iplFrameController.h"
#ifdef IPL_GCW_INTP_CTOR_OUT_OF_LINE
#include "global/decomp/utils.h"
#endif
namespace ipl {
namespace math {
template <typename T>
@@ -37,9 +41,15 @@ namespace ipl {
template <typename T>
class LinearIntp : public Interporation<T> {
public:
#ifdef IPL_BOARD_OBJECT_INLINE_INTERPOLATION_DTORS
#ifdef IPL_GCW_INTP_CTOR_OUT_OF_LINE
LinearIntp() NO_INLINE;
#endif
#if defined(IPL_BOARD_OBJECT_INLINE_INTERPOLATION_DTORS) || defined(IPL_GC_WINDOW_CPP)
virtual ~LinearIntp();
#endif
#ifdef IPL_GC_WINDOW_CPP
T get() const;
#else
T get() const {
T r = mEnd * getCurrentFrame();
T b = mStart * (mMaxFrame - mFrame);
@@ -47,9 +57,11 @@ namespace ipl {
return b * (f64)(1.0f / getMaxFrame());
}
#endif
T get2() const { return (((mStart * (mMaxFrame - mFrame)) + (mEnd * mFrame)) / mMaxFrame); }
};
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
template <typename T>
class __declspec(novtable) HermiteIntp : public utility::FrameController {

View File

@@ -103,7 +103,7 @@ namespace ipl {
y = r.y;
z = 0.0f;
}
#if defined(IPL_ADDRESS_EDIT_CPP) || defined(IPL_SD_CHANNEL_SELECT_CPP)
#if defined(IPL_ADDRESS_EDIT_CPP) || defined(IPL_SD_CHANNEL_SELECT_CPP) || defined(IPL_GC_WINDOW_CPP)
VEC3(f32 fx, f32 fy, f32 fz);
#else
VEC3(f32 fx, f32 fy, f32 fz) {

View File

@@ -0,0 +1,44 @@
#ifndef IPL_SCENE_GC_SAVE_DATA_H
#define IPL_SCENE_GC_SAVE_DATA_H
#include <nw4r/ut.h>
#include "scene/memoryCard/iplMemoryCardBase.h"
#include "math/iplMathTypes.h"
namespace ipl {
namespace scene {
class GCSaveData : public MemoryBase {
friend class MemoryCard;
public:
GCSaveData(EGG::Heap* heap, nand::LayoutFile* layoutFile, const char* directory, const char* fileName,
math::VEC3 translate);
virtual ~GCSaveData();
virtual void onPoint(const char* paneName, controller::Interface* controller);
virtual void onLeft(const char* paneName);
virtual void onTrig(const char* paneName);
void calc();
void draw();
void update();
void init();
void setTranslate(const nw4r::math::VEC3& translate);
const nw4r::math::VEC3* getTranslate();
void setBalloon(TextBalloon* balloon);
private:
MemoryBaseEvent* mpEvent; // 0x34
TextBalloon* mpBalloon; // 0x38
u8 mSlot; // 0x3C
s16 mIndex; // 0x3E
nw4r::ut::Link mLink; // 0x40
};
} // namespace scene
} // namespace ipl
#endif // IPL_SCENE_GC_SAVE_DATA_H

View File

@@ -0,0 +1,99 @@
#ifndef IPL_SCENE_GC_WINDOW_H
#define IPL_SCENE_GC_WINDOW_H
#include "scene/memoryCard/iplMemoryCardBase.h"
#include "scene/memoryCard/iplMemoryCardManager.h"
#include "math/iplMathTypes.h"
#include "math/iplInterporation.h"
namespace ipl {
namespace scene {
class GCWindow : public MemoryBase, public MemCardEventHandler {
#ifdef IPL_MEMORY_CARD_CPP
friend class MemoryCard;
#endif
public:
GCWindow(EGG::Heap*, nand::LayoutFile*, const char*, const char*);
virtual ~GCWindow();
void init(const math::VEC3&, MemoryCardManager*, u8, short);
void calc();
void draw();
void destroy();
void onPoint(const char*, controller::Interface*);
void onLeft(const char*);
void onTrig(const char*);
private:
void on_wait();
void on_fadein();
void on_normal();
void on_fadeout1st();
void on_fadeout_yes1st();
void on_focus_move();
void on_focus_copy();
void on_focus_del();
void on_select_out();
void on_dialog();
void on_error_message();
void on_process();
void on_error_message1st();
void on_error_message2nd();
void on_error_message3rd();
void on_format1st();
void on_format2nd();
void on_format3rd();
void on_format4th();
void on_format_error();
void change_textbox_doing();
void change_textbox_done();
void set_texture(const char*, const GXTexObj&);
public:
virtual void onMemEvent(long, u8);
bool isProcess();
void stop_wait_anim();
private:
int mState;
MemoryBaseEvent* mpEvent;
MemoryCardManager* mpMemoryCardManager;
math::LinearIntp<math::VEC3> mLinearInterp;
math::VEC3 mTranslate;
u8 mCardState;
short mCardIndex;
int mOperation;
bool mActive;
bool mWaiting;
u8 mFlags0[2];
u8 mFlags1[2];
};
class SavedataEditWindow : public MemoryBase {
public:
SavedataEditWindow(EGG::Heap* heap, nand::LayoutFile* layoutFile, const char* directory, const char* fileName);
virtual void init();
virtual void calc();
virtual void draw();
virtual void destroy();
private:
void add_animation(const char* fileName, const char* groupName) {
AnmName animation = {fileName, groupName};
MemoryBase::add_animation(&animation, 1);
}
void on_normal();
void on_fadein();
void on_fadeout1st();
void on_focus_del();
void on_select_out();
void on_fadeout_yes1st();
int mState;
MemoryBaseEvent* mpEvent;
math::LinearIntp<math::VEC3> mLinearInterp;
math::VEC3 mTranslate;
bool mActive;
};
}
}
#endif

View File

@@ -3,14 +3,91 @@
#include "iplSceneHeader.h"
#include "scene/memoryCard/iplMemoryCardBase.h"
#include "scene/memoryCard/iplMemoryCardManager.h"
#include "math/iplMathTypes.h"
namespace ipl {
namespace scene {
SCENE_CLASS(MemoryCard) {
class GCSaveData;
class GCWindow;
class SavedataEditWindow;
class MemoryCard : public Base, public MemoryBase {
public:
MemoryCard(EGG::Heap * heap);
MemoryCard(EGG::Heap* heap);
virtual ~MemoryCard();
virtual BOOL isResetAcceptable() const;
virtual void prepare();
virtual void create();
virtual void calc();
virtual void draw();
virtual void onPoint(const char* paneName, controller::Interface* controller);
virtual void onLeft(const char* paneName);
virtual void onTrig(const char* paneName);
void onFocus(void* data);
void onRelease();
MemoryCardManager* getManager() { return mpManager; }
private:
u8 unk_0x54[0x7C];
enum {
SLOT_A = 0,
SLOT_B,
};
void on_fadein1st();
void on_fadein2nd();
void on_normal();
void on_scroll_r();
void on_scroll_l();
void on_change_tag1st();
void on_change_tag2nd();
void on_fadeout1st();
void on_fadeout2nd();
void on_error();
void on_insert_card();
void on_detach_card();
void start_savedata_fadein();
void start_savedata_fadeout();
void start_errormessage_fadein();
int update_slot();
#ifdef IPL_MEMORY_CARD_CPP
bool can_scroll_r() const { return mIconCount > 30 && mState == 2; }
bool can_scroll_l() const { return mIconIndex >= 0 && mState == 2; }
#endif
void show_arw();
void show_capacity(u8 slot);
void scroll_common();
void start_scroll_r();
void start_scroll_l();
private:
s32 mState; // 0x88
s32 mPrevState; // 0x8C
u8 mSlot; // 0x90
u8 unk_0x91[3]; // 0x91
s32 mSlotState[2]; // 0x94
s16 mIconIndex; // 0x9C
s16 mIconCount; // 0x9E
u8 mShowArwR; // 0xA0
u8 mShowArwL; // 0xA1
u8 unk_0xA2[2]; // 0xA2
MemoryCardManager* mpManager; // 0xA4
MemoryBaseEvent* mpEvent; // 0xA8
nw4r::ut::List mSaveDataList; // 0xAC
nand::LayoutFile* mBalloonLayoutFile; // 0xB8
nw4r::ut::List mBalloonList; // 0xBC
GCSaveData* mpFocusSaveData; // 0xC8
GCWindow* mpGCWindow; // 0xCC
};
} // namespace scene
} // namespace ipl

View File

@@ -0,0 +1,144 @@
#ifndef IPL_SCENE_MEMORY_CARD_BASE_H
#define IPL_SCENE_MEMORY_CARD_BASE_H
#include <nw4r/ut.h>
#include "layout/iplLayout.h"
#include "layout/iplGuiManager.h"
#include "system/iplController.h"
namespace ipl {
namespace scene {
class TextBalloon;
class SettingButton;
class MemoryBase;
}
namespace nand {
class LayoutFile;
}
namespace scene {
class MemoryBaseEvent : public ::gui::EventHandler {
public:
#ifdef IPL_MEMORYCARD_BASE_EVENT_OUT_OF_LINE
MemoryBaseEvent(MemoryBase* base);
#else
MemoryBaseEvent(MemoryBase* base) : mpBase(base) {}
#endif
virtual ~MemoryBaseEvent();
virtual void onEvent(u32 componentID, u32 event, void* data);
private:
MemoryBase* mpBase; // 0x0C
};
class MemoryBase {
public:
class Anm {
public:
Anm(layout::GroupAnimator* anim) : mAnim(anim) {}
virtual ~Anm();
layout::GroupAnimator* mAnim; // 0x04
nw4r::ut::Link mLink; // 0x08
};
class Button {
public:
Button(nw4r::lyt::Pane* pane) : unk_0x04(0), mPane(pane) {}
virtual ~Button();
u32 unk_0x04; // 0x04
nw4r::lyt::Pane* mPane; // 0x08
nw4r::ut::Link mLink; // 0x0C
};
class AnmButton {
public:
AnmButton(const char* name, Anm* anm1, Anm* anm2, Anm* anm3)
: unk_0x04(0), mName(name), mCurrentAnm(NULL), mAnm1(anm1), mAnm2(anm2), mAnm3(anm3),
unk_0x24(0), mLastCmd(0), mpBalloon(NULL) {}
virtual ~AnmButton();
void calc();
void onCmdRecv(int command);
void setBalloon(TextBalloon* balloon);
int unk_0x04; // 0x04
const char* mName; // 0x08
Anm* mCurrentAnm; // 0x0C
Anm* mAnm1; // 0x10
Anm* mAnm2; // 0x14
Anm* mAnm3; // 0x18
nw4r::ut::Link mLink; // 0x1C
u32 unk_0x24; // 0x24
int mLastCmd; // 0x28
TextBalloon* mpBalloon; // 0x2C
};
struct AnmName {
const char* anmFile;
const char* groupName;
};
#ifdef IPL_MEMORYCARD_BASE_CTOR_OUT_OF_LINE
MemoryBase();
#else
MemoryBase() : mpLayout(NULL), unk_0x08(NULL) {
nw4r::ut::List_Init(&mAnmList, offsetof(Anm, mLink));
nw4r::ut::List_Init(&mButtonList, offsetof(Button, mLink));
nw4r::ut::List_Init(&mAnmButtonList, offsetof(AnmButton, mLink));
}
#endif
#ifdef IPL_MEMORYCARD_BASE_OUT_OF_LINE
virtual ~MemoryBase();
#else
virtual ~MemoryBase() {}
#endif
virtual void onPoint(const char* paneName, controller::Interface* controller);
virtual void onLeft(const char* paneName);
virtual void onMove(const char* paneName);
virtual void onTrig(const char* paneName);
virtual void add_button(const char** paneNames, int count);
virtual void add_anmbutton(const char* paneName, Anm* anm1, Anm* anm2, Anm* anm3);
virtual Button* get_button(const char* paneName);
virtual AnmButton* get_anmbutton(const char* paneName);
virtual void clear_button(const char* paneName);
virtual void add_animation(const AnmName* anmNames, int count);
virtual Anm* get_animation(int index);
virtual void do_animation(int index);
virtual void do_animation(int index, bool flag);
virtual void stop_animation(int index);
virtual bool is_animation(int index);
virtual bool is_fadein_enable();
virtual void set_visible(const char* paneName, bool flag);
void set_textbox(const char* paneName, u32 message);
void set_textbox(const char* paneName, u32 message, int x, int y);
void set_textbox(const char* paneName, const wchar_t* text, f32 x, f32 y);
void set_textbox(const char* paneName, const wchar_t* text);
SettingButton* get_setting_button();
void change_button_text_close();
void change_button_text_return();
void change_button_text_ok();
void show_button_return();
void show_button_ok();
protected:
layout::Object* mpLayout; // 0x04
nand::LayoutFile* unk_0x08; // 0x08
gui::PaneManager* mpPaneManager; // 0x0C
nw4r::ut::List mAnmList; // 0x10
nw4r::ut::List mButtonList; // 0x1C
nw4r::ut::List mAnmButtonList; // 0x28
};
} // namespace scene
} // namespace ipl
#endif // IPL_SCENE_MEMORY_CARD_BASE_H

View File

@@ -0,0 +1,115 @@
#ifndef IPL_SCENE_MEMORY_CARD_MANAGER_H
#define IPL_SCENE_MEMORY_CARD_MANAGER_H
#include <revolution/types.h>
#include <revolution/gx.h>
#include <private/card.h>
#include <wchar.h>
#include "iplMemoryCardLib.h"
namespace ipl {
namespace scene {
class MemCardEventHandler {
public:
MemCardEventHandler() {}
virtual ~MemCardEventHandler();
virtual void onMemEvent(long event, u8 slot);
};
typedef struct MCFile {
u32 fileNo; // 0x00
u32 unk_0x04; // 0x04
u32 unk_0x08; // 0x08
s32 sortKey; // 0x0C
} MCFile; // 0x10
typedef struct MCFileCell {
wchar_t comment[2][0x40]; // 0x000
s16 iconAnmCounter; // 0x100
u16 unk_0x102; // 0x102
GXTexObj icon; // 0x104
GXTexObj banner; // 0x124
GXTlutObj iconTlut; // 0x144
GXTlutObj bannerTlut; // 0x150
} MCFileCell; // 0x15C
class MemoryCardManager {
public:
MemoryCardManager() {
MCFileCell* pCell = mFileCell[0];
do {
pCell->iconAnmCounter = 0;
wmemset(pCell->comment[0], 0, 0x40);
pCell++;
} while (pCell < mFileCell[2]);
mLastResult = 0;
mLastCmd = 0;
__CARDSetDiskID(NULL);
memorycard::initCardThread();
sort_file_array(0);
sort_file_array(1);
}
virtual ~MemoryCardManager();
void calc();
bool isSlotReady(u8 slot);
bool isSlotNoCard(u8 slot);
long isSlotWrongDevice(u8 slot);
void sort_file_array(u8 slot);
void sendCardCmdMove(u8 slot, s16 index);
void sendCardCmdCopy(u8 slot, s16 index);
void sendCardCmdDelete(u8 slot, s16 index);
void sendCardCmdFormat(u8 slot);
bool isDistSlot(u8 slot, long* pState);
bool isMoveEnable(u8 slot, u32 index, long* pCode);
bool isCopyEnable(u8 slot, u32 index, long* pCode);
bool isIconValidate(u8 slot, s16 index);
bool isBannerEnable(u8 slot, s16 index);
void update_icon_anm();
void update_file_array(u8 slot);
void update_change_cardstate(u8 slot);
GXTexObj* create_icon(u8 slot, s16 index);
GXTexObj* create_icon(u8 slot, s16 index, long start);
GXTexObj* _create_icon(u8 slot, s16 fileNo, long start);
const wchar_t* getComment(u8 slot, s16 index, int which);
GXTexObj* create_banner(u8 slot, s16 index);
#ifdef IPL_GC_WINDOW_CPP
u32 getBlocks(u8 slot, s16 index);
#else
u16 getBlocks(u8 slot, s16 index);
#endif
#ifdef IPL_MEMORY_CARD_CPP
u32 getFreeBlocks(u8 slot);
#else
u16 getFreeBlocks(u8 slot);
#endif
void setEventHandler(MemCardEventHandler* eventHandler) {
mpEventHandler = eventHandler;
}
private:
u32 unk_0x04; // 0x00004
MCFile mFile[2][0x7F]; // 0x00008
MCFileCell mFileCell[2][0x7F]; // 0x00FE8
s32 mLastResult; // 0x16930
s32 mLastCmd; // 0x16934
u32 unk_0x16938; // 0x16938
MemCardEventHandler* mpEventHandler; // 0x1693C
};
} // namespace scene
} // namespace ipl
#endif // IPL_SCENE_MEMORY_CARD_MANAGER_H

View File

@@ -11,6 +11,12 @@
namespace ipl {
namespace scene {
#ifdef IPL_SD_CHANNEL_SELECT_CPP
namespace {
class SDChannelSelectButtonEventHandler;
}
#endif
class SDButtonEventHandlerBase : public ::gui::EventHandler {
public:
virtual void onEvent(u32 compId, u32 event, void* data);
@@ -91,8 +97,17 @@ namespace ipl {
void startLeftEvent(const char* paneName);
bool isActive() const;
#ifdef IPL_SD_CHANNEL_TITLE_CPP
bool isLeftArrowVisible() const { return mbArrowVisible[ARROW_BTN_LEFT]; }
static const char* getButtonName(int button) { return smButtonName[button]; }
#endif
#ifdef IPL_SD_CHANNEL_SELECT_CPP
void setEventHandler(::gui::EventHandler * event,
::gui::EventHandler * optOutEvent = NULL);
#else
void setEventHandler(::gui::EventHandler * event, ::gui::EventHandler * optOutEvent);
#endif
void setText(const char* paneName, u32 msgId);
void setText(const char* paneName, const wchar_t* text);
@@ -156,6 +171,10 @@ namespace ipl {
friend class SDArrow;
friend class SDButtonEventHandlerBase;
#ifdef IPL_SD_CHANNEL_SELECT_CPP
friend class SDChannelSelect;
friend class SDChannelSelectButtonEventHandler;
#endif
};
} // namespace scene
} // namespace ipl

View File

@@ -39,7 +39,11 @@ namespace ipl {
void hideLeftArrow();
void hideRightArrow();
#ifdef IPL_SD_CHANNEL_TITLE_CPP
public:
#else
private:
#endif
s32 updateState();
void drawTransferTitles();
void onDialogState0();
@@ -149,8 +153,10 @@ namespace ipl {
scroller mScroller;
s32 mButtonState;
u8 mControllerFlags[4];
#ifndef IPL_SD_CHANNEL_TITLE_CPP
u32 mFinalState[3];
u8 mFinalFlags[4];
#endif
};
} // namespace scene
} // namespace ipl

View File

@@ -10,6 +10,14 @@
namespace ipl {
namespace scene {
#ifdef IPL_SD_CHANNEL_SELECT_CPP
class SDChannelSelect;
namespace {
class SDChannelSelectEventHandler;
class SDChannelSelectButtonEventHandler;
}
#endif
class SDChannelObj {
public:
SDChannelObj(EGG::Heap* heap, int page, int index);
@@ -18,20 +26,33 @@ namespace ipl {
EGG::Heap* getHeap() const { return mpHeap; }
int getPage() const { return mPage; }
int getIndex() const { return mIndex; }
nw4r::math::VEC3& getTranslate() const;
#if defined(IPL_SD_CHANNEL_TITLE_CPP) || defined(IPL_SD_CHANNEL_OBJ_CPP)
public:
#else
private:
#endif
friend class SDChannelSelect;
nw4r::ut::Link mListLink;
EGG::ExpHeap* mpDialogHeap;
EGG::ExpHeap* mpChannelHeap;
EGG::Heap* mpHeap;
#ifdef IPL_SD_CHANNEL_OBJ_CPP
int mState;
#else
u32 mState;
#endif
int mPage;
int mIndex;
nand::LayoutFile* mpLayoutFile;
nw4r::lyt::Pane* mpPane;
#ifdef IPL_SD_CHANNEL_OBJ_CPP
nand::File* mpPaneAnimator;
#else
layout::Animator* mpPaneAnimator;
#endif
layout::Object* mpBaseLayout;
layout::Animator* mpBaseAnimator;
layout::Object* mpPageLayout;
@@ -45,7 +66,11 @@ namespace ipl {
int mDialogTimer;
int mAnimationState;
nw4r::lyt::Group* mpNewMessageGroup;
#ifdef IPL_SD_CHANNEL_OBJ_CPP
layout::Animator* mpNewMessageAnimator;
#else
int mNewMessageCount;
#endif
u8 mbNewMessageGroupActive;
int mNewMessageState;
int mNewMessageFrame;
@@ -60,10 +85,16 @@ namespace ipl {
extern "C" void iplSDChannelObj_813E311C(SDChannelObj* channel, EGG::ExpHeap* firstHeap,
EGG::ExpHeap* secondHeap);
extern "C" void iplSDChannelObj_813E322C(SDChannelObj* channel);
extern "C" void iplSDChannelObj_813E32C8(SDChannelObj* channel);
extern "C" void iplSDChannelObj_813E34E0(SDChannelObj* channel);
extern "C" void iplSDChannelObj_813E3178(SDChannelObj* channel, nw4r::lyt::Pane* pane);
extern "C" void iplSDChannelObj_813E3180(SDChannelObj* channel, nand::LayoutFile* layoutFile);
extern "C" void iplSDChannelObj_813E3304(SDChannelObj* channel);
extern "C" void iplSDChannelObj_813E330C(SDChannelObj* channel);
extern "C" void iplSDChannelObj_813E3354(SDChannelObj* channel, int state);
extern "C" void iplSDChannelObj_813E33EC(SDChannelObj* channel, int state);
extern "C" void iplSDChannelObj_813E3480(SDChannelObj* channel, bool selected);
extern "C" void iplSDChannelObj_813E34E8(SDChannelObj* channel, int enabled);
extern "C" void* iplSDChannelObj_813E3128(SDChannelObj* channel);
extern "C" bool iplSDChannelObj_813E3330(SDChannelObj* channel);
@@ -142,6 +173,14 @@ namespace ipl {
virtual FaderSceneCommand calcNormal();
virtual FaderSceneCommand calcFadeout();
void onButtonEvent(const char* paneName, u32 event,
const controller::Interface* controller);
BOOL onEventDerived(const char* paneName, u32 event,
controller::Interface* controller);
bool collectTitlesByUsage(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
u32* titleCount);
static const char* mscChannelPaneNames[PAGE_COUNT][MAX_CHANNEL_INDEX];
static const char* mscBasePaneNames[PAGE_COUNT];
static const char* mscPicturePaneNames[PAGE_COUNT];
@@ -149,7 +188,15 @@ namespace ipl {
static const char* mscClockPaneNames[3];
static const char* mscMaskPaneName;
#if defined(IPL_SD_CHANNEL_TITLE_CPP) || defined(IPL_SD_CHANNEL_OBJ_CPP)
public:
#else
private:
#endif
#ifdef IPL_SD_CHANNEL_SELECT_CPP
friend class SDChannelSelectEventHandler;
friend class SDChannelSelectButtonEventHandler;
#endif
void enqueueStartNotice();
bool enqueueFinishNotice();
bool enqueueNotice(u32 highTitleId, u32 lowTitleId, u32 result);
@@ -167,16 +214,40 @@ namespace ipl {
void calcChannelObjects();
void updateChannelObjects();
void updateChannelObject(SDChannelObj* channel);
void drawChannelTransitionObjects();
void drawChannelObjects();
bool isChannelInCalc(int page, int index, int currentPage) const;
nw4r::lyt::Pane* getChannelBasePane(int page, int index, int currentPage) const;
int getCenterChannelIndex(const char* paneName) const;
nw4r::lyt::Pane* getCenterChannelPane(int index) const;
nw4r::lyt::Pane* getChannelPane(int index) const;
static math::VEC3 getChannelPanePosition(SDChannelSelect* scene, int index);
void calcPageAnimations();
void processNormalInput();
void updateArrowVisibility();
void processWorkerState();
void updateDialogAnimation();
void initializeNormalPage();
void updatePageTransform();
void setChannelScissor(const SDChannelObj* channel) const;
bool isCurrentTitleUsageEnough(const s32* usage) const;
void getCurrentTitleUsage(s32* bytes, s32* blocks) const;
bool collectTitlesByChannelOrder(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
u32* titleCount);
bool collectTitlesFromNandUsage(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
u32* titleCount);
bool collectTitlesBySpecialChannels(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
u32* titleCount);
bool collectTitlesForMode(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
u32* titleCount, int searchMode);
bool findAdjacentChannel(int direction, int* page, int* index) const;
void setStateAndPlaySelectSound(int state) NO_INLINE;
void finishDialogOperation();
void finishDialogTransition();
void processWorkerCommands();
void handleWorkerStartup();
void handleNandTitleCount();
@@ -210,9 +281,38 @@ namespace ipl {
SDChannelObj* findChannelObject(int page, int index) const;
void createChannelObject(int page, int index);
void createBaseLayout();
void updateNoCardLayouts();
void createChannelThumbnails();
void createSceneLayouts();
BOOL isChannelMoveTarget(int page, int index) const;
void selectChannel(int page, int index);
BOOL prepareRestarting(int page);
void startPageTransition(int page, int index);
void setCurrentPageAndRefresh(int page, int index, SDChannelObj* keepChannel);
void handleFourPageDialog();
void handleThreePageDialog();
void setPageActionFrame();
void advancePageAnimation();
void finishPageScroll();
void finishCardDialog();
void flushSaveDataAndMountSD();
void startDrag(const controller::Interface* controller, int page, int index);
void finishDrag();
void moveDrag();
void updateDragState();
void updateDragPageTransition();
void finishDragWait();
void finishDragPageTransition();
void applyChannelMove();
void finishChannelMove();
void resetDragPreview();
void finishDragPageChange();
BOOL isPageCreated(int page) const;
void refreshPageObjects(int page, SDChannelObj* keepChannel, int noticeIndex);
void updateChannelObjectOrder(int page);
void moveChannelObjectsToDrawOrder(int page, int mode);
void setLayoutFrame(int state);
BOOL tellStartingZoomAnm();
void initPageAnimations(const math::VEC3& position, int direction);
static BOOL isChannelReady(const SDChannelObj* channel);
nw4r::ut::List mChannelObjects;
nand::LayoutFile* mpLayoutFile;
layout::Object* mpLayout;
@@ -228,7 +328,7 @@ namespace ipl {
int mCurrentChannelIndex;
f32 mThumbOffsetX;
f32 mThumbOffsetY;
nw4r::math::VEC3 mPosition;
math::VEC3 mPosition;
math::VEC2 mScale;
f32 mAspectRatioScale;
bool mbLeftArrowVisible;
@@ -251,9 +351,9 @@ namespace ipl {
bool mbButtonEnabled;
bool mbDialogActive;
u16 mInputFlags;
SDChannelObj* mpCurrentChannel;
void* mpCurrentChannel;
layout::Object* mpStateLayout;
layout::Object* mpHelpLayout;
layout::Animator* mpHelpLayout;
EGG::ExpHeap* mpRsoHeap;
channel::RsoThread* mpRsoThread;
u32 mCommandQueueState;
@@ -269,8 +369,8 @@ namespace ipl {
ESTitleId32* mpSDTitleIds;
SDChannelSelectTitleInfo* mpSDTitleInfo;
NandSDWorker::TitleUsage* mpNandTitleInfo;
u32 mFirstTitleCount;
u32 mSecondTitleCount;
s32 mFirstTitleCount;
s32 mSecondTitleCount;
SDChannelObj* mpCurrentLoadedChannel;
u32 mSDTitleCount;
u32 mNandTitleCount;
@@ -284,8 +384,8 @@ namespace ipl {
u8 mbShowNoCardMessage;
u8 mbOperationActive;
u8 mbSDCardBroken;
u32 mOperationState;
u32 mDialogState;
int mOperationState;
int mDialogState;
nand::File* mpSaveDataFile;
u32 mAnimationState;
u32 mAnimationTarget;

View File

@@ -3,15 +3,104 @@
#include "iplSceneHeader.h"
#ifdef IPL_SD_CHANNEL_TITLE_CPP
#include "math/iplInterporation.h"
#include "scene/sdChannelMemory/iplSDMemory.h"
#include "system/iplChannelRsoThread.h"
#include "utility/iplCapture.h"
#include <private/es.h>
#include <nw4r/snd/SoundHandle.h>
#endif
namespace ipl {
namespace scene {
class SDChannelSelect;
class SDButtonEventHandlerBase;
FADER_SCENE_CLASS(SDChannelTitle) {
public:
SDChannelTitle(EGG::Heap * heap, SDChannelSelect * chanSel);
#ifdef IPL_SD_CHANNEL_TITLE_CPP
virtual ~SDChannelTitle();
virtual void prepare();
virtual void create();
virtual void calcCommon();
virtual FaderSceneCommand calcFadein();
virtual FaderSceneCommand calcNormal();
virtual void initCalcFadeout();
virtual FaderSceneCommand calcFadeout();
virtual void draw();
virtual void destroy();
BOOL isResetAcceptable();
virtual void startResetting();
using Base::reserveAllSceneDestruction;
using Base::createChildScene;
s32 mState;
EGG::ExpHeap* mpBannerHeap;
EGG::ExpHeap* mpCaptureHeap;
s32 mPage;
s32 mIndex;
s32 mPageCount;
s32 mNextScene;
s32 mParentalResult;
math::VEC3 mPosition;
u32 mLaunchFrame;
s32 mStartButtonState;
bool mbBannerStarting;
layout::Animator* mpButtonAnimations[7][6];
math::HermiteIntp<f32>* mpFade;
SDChannelSelect* mpChannelSelect;
nand::LayoutFile* mpLayoutFile;
layout::Object* mpLayout;
gui::PaneManager* mpPaneManager;
layout::Object* mpIconLayout;
EGG::ExpHeap* mpIconHeap;
layout::Object* mpProgressLayout;
s32 mLoadedIndex;
nand::LayoutFile* mpBannerFiles[2];
nand::File* mpSoundFiles[2];
layout::Object* mpBannerLayout;
layout::Animator* mpBannerAnimations[3];
nw4r::snd::SoundHandle* mpSoundHandle;
nand::File* mpSaveFile;
u32 mWpadStopTick;
s32 mHoverCounts[2];
SDButtonEventHandlerBase* mpButtonEventHandler;
utility::Capture* mpScreenCapture;
utility::Capture* mpBannerCapture;
ESTmdView* mpTmd;
u8 mbTmdReady;
u8 mTitleFlags;
u16 mMakerCode;
u8 mbStartAnimation;
s32 mScriptState;
s32 mScriptEnabled;
bool mbStopScript;
u32 mScriptFrame;
u32 mScriptDuration;
nand::File* mpScriptFile;
EGG::ExpHeap* mpScriptHeaps[2];
s32 mScriptHeapIndex;
channel::RsoThread* mpRsoThread;
EGG::ExpHeap* mpRsoHeap;
layout::Animator* mpScriptAnimations[16];
bool mbScriptFailed;
EGG::ExpHeap* mpScriptHeap;
ESTitleId mTitleId;
SDMemory::TitleRange mTitleRange;
u8 mUnknownTitleWork[0x800];
SDMemory mMemory;
u32 mErrorMessage;
s32 mChangeFrame;
u8 mbCopiedTitle;
u8 mbResetAcceptable;
nw4r::snd::SoundHandle* mpCopySound;
#else
private:
u8 unk_0x58[0x3460];
#endif
};
} // namespace scene
} // namespace ipl

View File

@@ -0,0 +1,32 @@
#ifndef IPL_SCENE_SETTING_AOSS_H
#define IPL_SCENE_SETTING_AOSS_H
#include <revolution/ncd/NCDTypes.h>
#include <revolution/types.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct AOSSInitInput {
u16 flags;
u8 mode;
u8 reserved;
u16 ssidLength;
u8 ssid[0x100];
s16 options[5];
u8 optionData[6];
u8 status;
u8 result[0x154];
} AOSSInitInput;
int AOSSi_Init(AOSSInitInput* input);
int AOSS_Init_old(AOSSInitInput* input);
void* AOSSi_Alloc(u32 size);
void AOSSi_Free(void* block);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -36,6 +36,11 @@
#define MAX_CHANNEL_INFO_SIZE CHANNEL_INFO_SIZE(MAX_CHANNEL_PAGE, MAX_CHANNEL_INDEX)
namespace ipl {
#ifdef IPL_SD_CHANNEL_SELECT_CPP
namespace scene {
class SDChannelSelect;
}
#endif
namespace channel {
enum {
PRIMARY_TYPE_NONE = 0,
@@ -368,6 +373,9 @@ namespace ipl {
char* getChJumpData() { return mChJumpData; }
private:
#ifdef IPL_SD_CHANNEL_SELECT_CPP
friend class ipl::scene::SDChannelSelect;
#endif
typedef struct MD5Head {
u8 magic[4]; // 0x00 (`IMD5`; "IPL MD5"?)
u32 length; // 0x04

View File

@@ -151,6 +151,10 @@ namespace ipl {
BOOL is_terminated();
BOOL is_working();
#ifdef IPL_SD_CHANNEL_SELECT_CPP
void requestCancel() { unk_0x04 = true; }
#endif
WIISaveBannerFile* get_cached_nand_save_banner(ESTitleId titleId);
void* get_cached_nand_app_thumbnail(ESTitleId titleId, u32*);
WIISaveBannerFile* get_cached_sd_save_banner(ESTitleId32 titleId);

View File

@@ -15,6 +15,11 @@
#define SAVEDATA_VERSION 3
namespace ipl {
#ifdef IPL_SD_CHANNEL_SELECT_ACCESS
namespace scene {
class SDChannelSelect;
}
#endif
namespace channel {
class Manager;
}
@@ -29,6 +34,9 @@ namespace ipl {
void initManager();
void setPrevPage(int prevPage);
#ifdef IPL_SD_CHANNEL_TITLE_CPP
int& getSDPrevPage() { return mData.prevSDPage; }
#endif
void setChanInfo(int page, int index, const channel::SInfo& chanInfo);
void setMemoSetting(const textinput::extend::savedata::MemoSetting& memoSetting);
@@ -54,6 +62,7 @@ namespace ipl {
int getLastSDPrevPage() { return mLastSDPrevPage; }
void setLastSDPrevPage(int page) { mLastSDPrevPage = page; }
BOOL didntGotoSDMenu() const { return mData.didntGotoSDMenu; }
void setDidntGotoSDMenu(BOOL value) { mData.didntGotoSDMenu = value; }
#endif
bool hasPhotoMP3Dummy() { return mbPhotoMP3; }
@@ -68,6 +77,9 @@ namespace ipl {
void iplSavedata_813596B8(ESTitleId titleId);
private:
#ifdef IPL_SD_CHANNEL_SELECT_ACCESS
friend class ipl::scene::SDChannelSelect;
#endif
BOOL checkValidApp(ESTitleId titleId);
static void initManagerTask(void* work);

View File

@@ -157,11 +157,15 @@ namespace nw4r {
y = pF[1];
z = pF[2];
}
#if defined(IPL_SD_CHANNEL_SELECT_CPP)
VEC3(f32 fx, f32 fy, f32 fz);
#else
VEC3(f32 fx, f32 fy, f32 fz) {
x = fx;
y = fy;
z = fz;
}
#endif
operator Vec*() { return reinterpret_cast<Vec*>(this); }
operator const Vec*() const { return reinterpret_cast<const Vec*>(this); }

View File

@@ -160,11 +160,12 @@ typedef struct _ziGetParam {
ziWChar* candidates; // 0x18
ziU8 maxCandidates; // 0x1C
ziWChar firstCandidate; // 0x1E
ziU8 wordCandidates; // 0x1F
ziU8 unk_0x20; // 0x20
ziU8 count; // 0x20
ziU8 letters; // 0x21
ziU8* scratch; // 0x22
ziU8 count; // 0x22
ziU8* scratch; // 0x24
ziU32 unk_0x28; // 0x28
} ziGetParam;
typedef struct _ziLanguageEntry {
@@ -172,20 +173,195 @@ typedef struct _ziLanguageEntry {
ziU8* tableData; // 0x04
} ziLanguageEntry;
typedef struct _zi8DawgRec {
ziU8* node;
ziU32 attr;
ziU16 key;
ziU8 unk_0x0A[2];
ziU8* back;
} zi8DawgRec;
typedef struct _zi8DawgCtx {
ziU8 lang; // 0x00
ziU8 key; // 0x01
ziU16 cnt; // 0x02
ziU16 cap; // 0x04
ziU8 unk_0x06[2];
ziU8* p08; // 0x08
ziU8* p0C; // 0x0C
ziU8* table; // 0x10
ziU8* p14; // 0x14
zi8DawgRec recs[0x32]; // 0x18
ziU32 unk_0x338; // 0x338
} zi8DawgCtx;
typedef struct _ziUwdNode {
struct _ziUwdNode* next;
ziU8* word;
} ziUwdNode;
struct __zi8_work_data_s {
ziU8 unk_0x00;
ziU8 unk_0x01;
ziU8 unk_0x02[2];
ziLanguageEntry* langEntries; // 0x04
ziU32 unk_0x08;
ziU8 unk_0x08;
ziU8 unk_0x09;
ziU8 unk_0x0A;
ziU8 unk_0x0B;
ziU32 unk_0x0C;
ziU32 unk_0x10;
ziU32 unk_0x14;
ziU16 unk_0x14;
ziU8 unk_0x16;
ziU8 unk_0x17;
ziU8 unk_0x18;
ziU8 unk_0x1C[0x108];
ziU8 unk_0x19;
ziU16 unk_0x1A;
ziU8 unk_0x1C[3];
ziU8 unk_0x1F;
ziU16 unk_0x20[0x40];
ziU16 unk_0xA0[0x42];
ziU16* unk_0x124[1];
ziU8* unk_0x128;
ziU8 unk_0x12C;
ziU8 unk_0x12D;
ziU8 unk_0x12E;
ziU8 unk_0x12F;
ziPtr unk_0x130[2];
ziU8 unk_0x138;
ziU8 unk_0x139[3];
ziU32 unk_0x13C;
ziU8 unk_0x140;
ziU8 unk_0x141[0x43];
ziU8 unk_0x184[0x43];
ziU8 uwdCount; // 0x1C7
ziUwdNode uwdNodes[0x20]; // 0x1C8
ziUwdNode* uwdList; // 0x2C8
ziU32 pudTable[0x10]; // 0x2CC
ziU8 pudCount; // 0x30C
ziU8 unk_0x30D[3];
ziU32 unk_0x310;
ziU32 unk_0x314;
ziU32 unk_0x318;
ziU8 pdRemoveOpt; // 0x31C
ziU8 unk_0x31D;
ziU8 unk_0x31E;
ziU8 unk_0x31F;
ziU8 (*oemMatch)(ziU16 idx, ziWChar* buf, ziU8 len, ziPtr data); //0x320
ziU16 oemLen; //0x324
ziU8 unk_0x326[2];
ziU32 oemIdx; //0x328
ziPtr oemData; //0x32C
ziU8 unk_0x330[8];
ziU32 unk_0x338;
ziU8 unk_0x33C[0x1FC];
ziU8 unk_0x538;
ziU8 unk_0x539;
ziU8 unk_0x53A[0x40];
ziWChar unk_0x57A[0x641];
ziPtr unk_0x11FC;
ziPtr userKeys[0x83]; // 0x1200
ziU8 unk_0x140C[4];
ziU32 unk_0x1410;
ziU8 unk_0x1414[4];
ziU8 unk_0x1418;
ziU8 unk_0x1419;
ziU16 unk_0x141A;
ziU8 unk_0x141C;
ziU8 unk_0x141D;
ziU8 unk_0x141E;
ziU8 unk_0x141F;
ziU8 unk_0x1420[4];
zi8DawgCtx dawgCtx; // 0x1424
ziU8 unk_0x1760[4]; // 0x1760
ziU8* unk_0x1764; // 0x1764
ziU8 unk_0x1768;
ziU8 unk_0x1769[0x81];
ziU16 unk_0x17EA;
ziU8 unk_0x17EC;
ziU8 unk_0x17ED[3];
ziU8* unk_0x17F0;
ziWChar unk_0x17F4[0x40]; // 0x17F4..0x1874
ziU16 unk_0x1874;
ziU8 unk_0x1876;
ziU8 unk_0x1877;
ziU8 unk_0x1878;
ziU8 unk_0x1879;
ziWChar unk_0x187A[0x41];
ziU8 unk_0x18FC;
ziU8 unk_0x18FD;
ziWChar unk_0x18FE[0x41];
ziU8 unk_0x1980;
ziU8 unk_0x1981;
ziU8 unk_0x1982;
ziU8 unk_0x1983;
ziU8 unk_0x1984;
ziU8 unk_0x1985;
ziU8 unk_0x1986;
ziU8 unk_0x1987;
ziWChar unk_0x1988[0x41];
ziU8 unk_0x1A0A;
ziU8 unk_0x1A0B[0x85];
ziWChar unk_0x1A90;
ziWChar unk_0x1A92[0x41];
ziU8 unk_0x1B14;
ziU8 unk_0x1B15[3];
ziU16* unk_0x1B18;
ziU16 unk_0x1B1C;
ziU16 unk_0x1B1E;
ziU16 unk_0x1B20;
ziU16 unk_0x1B22;
ziU8 unk_0x1B24;
ziU8 unk_0x1B25[3];
union {
ziU32 word;
struct {
ziU32 msb : 1;
} bits;
} unk_0x1B28;
union {
ziU32 word;
struct {
ziU32 msb : 1;
} bits;
} unk_0x1B2C;
ziU8 unk_0x1B30;
ziU8 unk_0x1B31;
ziU16 unk_0x1B32;
ziU16 unk_0x1B34;
ziU16 unk_0x1B36;
ziU16 unk_0x1B38;
ziU8 unk_0x1B3A;
ziU8 unk_0x1B3B;
ziU8 unk_0x1B3C;
ziU8 unk_0x1B3D;
ziU8 unk_0x1B3E;
ziU8 unk_0x1B3F;
ziU16 unk_0x1B40;
ziU8 unk_0x1B42[2];
};
typedef struct ziMatchParam {
ziU8 count; // 0x00
ziU8 arr1[0xC]; // 0x01
ziU8 arrD[0xC]; // 0x0D
ziU8 arr19[4]; // 0x19
ziU8 arr1D[4]; // 0x1D
ziU8 pad_0x21; // 0x21
ziU16 field22; // 0x22
ziU8 length; // 0x24
ziU8 nCand; // 0x25
ziWChar phon[0x10]; // 0x26
ziWChar phon2[0x10]; // 0x46
ziWChar first; // 0x66
ziWChar first2; // 0x68
ziWChar comp; // 0x6A
ziU8 nSeg; // 0x6C
ziU8 segs1[0xC0]; // 0x6D
ziU8 segsD[0xC0]; // 0x12D
ziU8 pad_0x1ED; // 0x1ED
} ziMatchParam;
#define ZI_WORK ((struct __zi8_work_data_s*)__zi8_work_data)
#define ZI_NEED_WORK , ziPtr __zi8_work_data

View File

@@ -0,0 +1,49 @@
#include <zi8clib/zitypes.h>
const ziWChar Zi8PunctTable[40] = {
0xFF0C, 0x3002, 0x3001, 0xFF1A, 0xFF1F, 0xFF01, 0x3005, 0x2026,
0x2015, 0xFF1B, 0xFF0E, 0x30FB, 0x201C, 0x201D, 0xFF08, 0xFF09,
0x300C, 0x300D, 0xFF10, 0xFF11, 0xFF12, 0xFF13, 0xFF14, 0xFF15,
0xFF16, 0xFF17, 0xFF18, 0xFF19, 0xFF0F, 0xFF05, 0xFFE5, 0xFF04,
0xFFE1, 0x20AC, 0x203B, 0xFF20, 0x0000,
};
ziS32 Zi8Punctuation(ziGetParam* param ZI_NEED_WORK) {
ziS32 limit = ((ziU16*)__zi8_work_data)[8] - 1;
ziS32 count = 0;
ziU8 i = 0;
ziU16 fc = param->firstCandidate;
ziU16 j = 0;
for (;;) {
if (Zi8PunctTable[j] == 0) {
break;
}
if (fc == 0) {
count++;
if (ZI_WORK->unk_0x00 == 0) {
param->candidates[i++] = Zi8PunctTable[j];
if ((param->context & 0x10) != 0) {
param->candidates[i++] = 0x20;
if ((ziU8)i >= limit) {
break;
}
}
if (count >= param->maxCandidates) {
break;
}
} else {
if (count >= (ziS32)ZI_WORK->unk_0x0C) {
return count;
}
}
} else {
fc--;
}
j++;
}
if (ZI_WORK->unk_0x00 == 0) {
param->letters = count;
}
return count;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,108 @@
#include <zi8clib/zitypes.h>
ziU16 Zi8MatchAltSound(ziU8* elements, ziU16 count, ziU8* table, ziU16 ch,
ziU32 mask, ziU16 target, ziU8 flags ZI_NEED_WORK) {
ziU8 hi;
ziU8 lo;
ziS32 i;
ziS32 j;
ziS32 mid;
ziU16 off;
ziU16 w;
hi = (ziU8)((ziU16)ch >> 8);
lo = (ziU8)ch;
flags = (ziU8)(flags >> 3);
if (count == 0) {
return 0;
}
j = 0;
i = count - 1;
if ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo) {
j = i;
goto up;
}
if ((elements + j * 4)[1] == hi && (elements + j * 4)[0] == lo) {
goto up;
}
goto search;
up:
i = j;
body:
if (((elements + i * 4)[3] & 0xE) == 0 ||
((elements + i * 4)[3] & flags) != 0) {
off = (ziU16)(((ziU16)(elements + i * 4)[2] |
(((ziU16)(elements + i * 4)[3] & 1) << 8)) << 1);
w = (ziU16)((((ziU16)(elements + i * 4)[3] & 0xF0) >> 4) |
(table[off] | ((ziU16)table[off + 1] << 8)));
if (target == (w & (ziU16)mask)) {
return w;
}
}
i++;
if (i >= count) {
goto down_start;
}
if ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo) {
goto body;
}
down_start:
i = j;
goto dec;
down_body:
if (((elements + i * 4)[3] & 0xE) == 0 ||
((elements + i * 4)[3] & flags) != 0) {
off = (ziU16)(((ziU16)(elements + i * 4)[2] |
(((ziU16)(elements + i * 4)[3] & 1) << 8)) << 1);
w = (ziU16)((((ziU16)(elements + i * 4)[3] & 0xF0) >> 4) |
(table[off] | ((ziU16)table[off + 1] << 8)));
if (target == (w & (ziU16)mask)) {
return w;
}
}
dec:
i--;
if (i < 0) {
goto fail;
}
if ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo) {
goto down_body;
}
fail:
return 0;
search:
if ((elements + j * 4)[1] == hi && (elements + j * 4)[0] == lo) {
goto up;
}
if ((((ziU16)(elements + j * 4)[1] << 8) | (ziU16)(elements + j * 4)[0]) > ch) {
return 0;
}
mid = (j + i) / 2;
if (mid == j) {
return 0;
}
if ((((ziU16)(elements + mid * 4)[1] << 8) | (ziU16)(elements + mid * 4)[0]) >= ch) {
i = mid;
goto hi_check;
}
j = mid;
goto search;
hi_check:
if ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo) {
j = i;
goto up;
}
if ((((ziU16)(elements + i * 4)[1] << 8) | (ziU16)(elements + i * 4)[0]) < ch) {
return 0;
}
mid = (j + i) / 2;
if (mid == j) {
return 0;
}
if ((((ziU16)(elements + mid * 4)[1] << 8) | (ziU16)(elements + mid * 4)[0]) >= ch) {
i = mid;
goto hi_check;
}
j = mid;
goto search;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,212 @@
#include <zi8clib/zierror.h>
extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU8 Zi8getKeyLayout(ziU8 lang, ziU16 key, ziWChar* layout, ziU8 mode ZI_NEED_WORK);
extern ziChar Zi8ConvertWC2UC(ziWChar ch, ziU8 language ZI_NEED_WORK);
extern ziU32 Zi8AlphaGetCandidates(ziGetParam* param, ziPtr sw ZI_NEED_WORK);
extern ziU8 Zi8SyllablesROMdata(ziWChar* keys, ziU8 count, ziU8 lang, ziWChar* out,
ziU16 a, ziU8 b, ziU8* cntOut, ziU8 c ZI_NEED_WORK);
typedef struct _ziSwParam {
ziU8 flag;
ziU8 unk_0x01[0xB];
ziS32 count;
ziU16 cap;
ziU8 unk_0x12[2];
} ziSwParam;
ziU32 Zi8GetSyllablesCandidates(ziGetParam* param, ziSwParam* sw ZI_NEED_WORK) {
ziWChar buf[0x40];
ziWChar buf2[0x32];
ziS32 rem;
ziS32 cur;
ziS32 firstCand;
ziS32 count;
ziWChar* pNext;
ziU16 err;
ziU8 flag14;
ziU8 flag13;
ziU8 flag12;
ziU8 flag11;
ziU8 sylCnt;
ziWChar* out;
ziU8* u28;
ziS32 i;
firstCand = param->firstCandidate;
count = 0;
u28 = 0;
pNext = 0;
flag14 = 1;
flag13 = 1;
flag12 = 0;
flag11 = 0;
sylCnt = 0;
err = 0x64;
if (param->currentWord != 0 && param->wordCharCount != 0 &&
param->currentWord[param->wordCharCount - 1] != 0x20) {
flag11 = 1;
}
if (param->elementCount == 0 || (param->elementCount == 1 && flag11 == 0)) {
count = Zi8AlphaGetCandidates(param, sw, ZI_WORK);
goto end;
}
if (sw->flag != 0 || (param->getOptions & 0xFD) != 0x81) {
out = buf;
rem = 0x40;
} else {
out = (ziWChar*)param->candidates;
rem = sw->cap - 1;
}
if ((param->getOptions & 0xFD) == 0x80) {
u28 = (ziU8*)param->candidates;
rem = sw->cap - 1;
}
if (rem <= param->elementCount) {
err = 0x168;
goto end;
}
if ((Zi8GetTableCount(param->language, 0x1F, ZI_WORK) & 8) != 0) {
flag14 = 0;
}
if (param->elements[0] == 0xEFF1 && param->elementCount > 1 && flag14 != 0) {
buf[0] = 0x2D;
} else {
Zi8getKeyLayout(param->language, param->elements[0], buf, 1, ZI_WORK);
}
out[0] = buf[0];
Zi8SyllablesROMdata(param->elements, param->elementCount, param->language, out,
(ziU16)rem, 0, &sylCnt, flag11, ZI_WORK);
if (sylCnt != 0) {
cur = sylCnt;
} else {
cur = 1;
}
if (cur == param->elementCount) goto L5dc;
if (firstCand != 0) {
firstCand--;
goto L5dc;
}
if (sw->flag != 0) {
if (++count >= sw->count) goto end;
goto L5dc;
}
for (i = cur; i < param->elementCount; i += sylCnt) {
if (param->elements[i] == 0xEFF1 && param->elementCount - i > 1 && flag14 != 0) {
buf2[0] = 0x2D;
} else {
Zi8getKeyLayout(param->language, param->elements[i], buf2, 1, ZI_WORK);
}
out[i] = buf2[0];
Zi8SyllablesROMdata(param->elements + i, param->elementCount - i, param->language,
out + i, (ziU16)rem, 0, &sylCnt, 1, ZI_WORK);
if (sylCnt == 0) {
sylCnt = 1;
}
}
if (u28 != 0) {
for (i = 0; i < param->elementCount; i++) {
u28[i] = Zi8ConvertWC2UC(out[i], param->language, ZI_WORK);
}
u28[i++] = 0;
u28[i] = 0;
u28 += i;
} else {
out[i++] = 0;
out[i] = 0;
out += i;
}
rem -= i;
if (++count >= param->maxCandidates) goto end;
if (rem > param->elementCount) goto L5dc;
goto end;
L5dc:
while (cur >= 1) {
flag12 = 0;
goto rom;
found:
flag12 = 1;
if (cur == 1) {
flag13 = 0;
}
L464:
if (out[0] >= 0xEFF1 && out[0] <= 0xF010) {
goto dec;
}
L464b:
if (firstCand != 0) {
firstCand--;
goto L560;
}
if (sw->flag != 0) {
if (++count >= sw->count) goto end;
goto L560;
}
if (u28 != 0) {
for (i = 0; i < cur; i++) {
u28[i] = Zi8ConvertWC2UC(out[i], param->language, ZI_WORK);
}
u28[i++] = 0;
u28[i] = 0;
u28 += i;
} else {
i = cur;
out[i++] = 0;
out[i] = 0;
out += i;
}
rem -= i;
if (++count >= param->maxCandidates) goto end;
if (rem <= cur) goto end;
L560:
if (pNext != 0) {
if (*pNext == 0) goto end;
out[0] = *pNext++;
goto L464b;
}
rom:
if (Zi8SyllablesROMdata(param->elements, (ziU8)cur, param->language, out,
(ziU16)rem, flag12, 0, flag11, ZI_WORK) != 0) {
goto found;
}
dec:
cur--;
}
if (flag13 == 0) goto end;
if (param->elements[0] == 0xEFF1 && param->elementCount > 1 && flag14 != 0) {
buf2[0] = 0x2D;
buf2[1] = 0;
Zi8getKeyLayout(param->language, param->elements[0], &buf2[1], 1, ZI_WORK);
for (i = 1; buf2[i] != 0; i++) {
if (buf2[i] == 0x2D) break;
}
while (buf2[i] != 0) {
buf2[i] = buf2[i + 1];
i++;
}
} else {
Zi8getKeyLayout(param->language, param->elements[0], buf2, 1, ZI_WORK);
}
cur = 1;
pNext = buf2;
goto L560;
end:
if (sw->flag != 0) {
param->letters = 0;
} else {
param->letters = (ziU8)count;
}
Zi8LogError(err, ZI_WORK);
return count;
}

View File

@@ -0,0 +1,15 @@
#include <zi8clib/zi8getc.h>
#include <zi8clib/zitypes.h>
extern ziU8 _Zi8GetCandidates(ziGetParam* getParam ZI_NEED_WORK);
ziU8 Zi8GetCandidates(ziGetParam* getParam ZI_NEED_WORK) {
ZI_WORK->unk_0x1B3A = 0;
ZI_WORK->unk_0x1B3C = 0;
ZI_WORK->unk_0x1B3B = 0;
ZI_WORK->unk_0x1B3D = 0;
ZI_WORK->unk_0x1B36 = 0;
ZI_WORK->unk_0x1B32 = 0;
ZI_WORK->unk_0x1B34 = 0;
return _Zi8GetCandidates(getParam, ZI_WORK);
}

View File

@@ -0,0 +1,75 @@
#include <zi8clib/zitypes.h>
#include <zi8clib/zierror.h>
extern void Zi8Memset(ziPtr p, ziU32 v, ziU32 len);
extern void Zi8SetLatinSearchOrder(ziU32 a, ziU8 b ZI_NEED_WORK);
extern void ZADP_Zi8SetPDremoveOpt(ziU8 a ZI_NEED_WORK);
extern ziU16 Zi8GetFormatVersion(ziU8 a ZI_NEED_WORK);
extern void Zi8ZHsetZYfuzzyPairs(ziU32* a ZI_NEED_WORK);
extern void Zi8ZHsetPYfuzzyPairs(ziU32* a ZI_NEED_WORK);
extern void Zi8SetParentalControls(ziU8 a ZI_NEED_WORK);
ziU8 Zi8InitializeDynamic(ziLanguageEntry* langEntries ZI_NEED_WORK) {
ziU32 zyFuzzy;
ziU32 pyFuzzy;
ziU32* pzyFuzzy;
ziU32* ppyFuzzy;
Zi8Memset(__zi8_work_data, 0, 0x1B44);
ZI_WORK->unk_0x08 = 1;
ZI_WORK->unk_0x09 = 1;
ZI_WORK->unk_0x0A = 0xFF;
ZI_WORK->unk_0x10 = 0x64;
*(ziU16*)&ZI_WORK->unk_0x0C = 0xFFFF;
ZI_WORK->unk_0x1A = 0x20;
ZI_WORK->unk_0x1C[2] = 0;
ZI_WORK->unk_0x1B30 = 0;
ZI_WORK->unk_0x1B3A = 0;
ZI_WORK->unk_0x1B36 = 0;
ZI_WORK->unk_0x1B32 = 0;
ZI_WORK->unk_0x1B34 = 0;
ZI_WORK->unk_0x1B3B = 0;
ZI_WORK->unk_0x1B3C = 0;
ZI_WORK->unk_0x1B40 = 0;
ZI_WORK->unk_0x1B38 = 0;
ZI_WORK->langEntries = langEntries;
if (ZI_WORK->langEntries == ZI8_NULL) {
Zi8LogError(0x578, ZI_WORK);
return 0;
}
if (ZI_WORK->langEntries->language == 0) {
Zi8LogError(0x582, ZI_WORK);
return 0;
}
ZI_WORK->unk_0x1874 = 0x2D;
ZI_WORK->unk_0x538 = 0;
ZI_WORK->unk_0x1C[3] = 0;
ZI_WORK->unk_0x141A = 0x100;
Zi8SetLatinSearchOrder(0, 0, ZI_WORK);
ZADP_Zi8SetPDremoveOpt(1, ZI_WORK);
ZI_WORK->unk_0x17 = 5;
ZI_WORK->unk_0x16 = Zi8GetFormatVersion(1, ZI_WORK) & 2;
ZI_WORK->unk_0x1B28.bits.msb = 1;
ZI_WORK->unk_0x1B2C.bits.msb = 1;
zyFuzzy = ZI_WORK->unk_0x1B2C.word;
pzyFuzzy = &zyFuzzy;
Zi8ZHsetZYfuzzyPairs(pzyFuzzy, ZI_WORK);
pyFuzzy = ZI_WORK->unk_0x1B28.word;
ppyFuzzy = &pyFuzzy;
Zi8ZHsetPYfuzzyPairs(ppyFuzzy, ZI_WORK);
Zi8SetParentalControls(2, ZI_WORK);
Zi8LogError(0x64, ZI_WORK);
return 1;
}
ziU8 Zi8IsZicorpSignature(ziU16* p, ziU16 len) {
if ((ziU16)len > 6 && p[0] == 0x7A && p[1] == 0x69 && p[2] == 0x63 &&
p[3] == 0x6F && p[4] == 0x72 && p[5] == 0x70) {
return 1;
}
if ((ziU16)len > 6 && p[0] == 0x39 && p[1] == 0x34 && p[2] == 0x32 &&
p[3] == 0x36 && p[4] == 0x37 && p[5] == 0x37) {
return 1;
}
return 0;
}

View File

@@ -0,0 +1,138 @@
#include <zi8clib/zi8is.h>
#include <zi8clib/zierror.h>
extern ziU8 Zi8LangSupported(ziU8 lang ZI_NEED_WORK);
extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU8 _Zi8GetCandidates(ziGetParam* getParam ZI_NEED_WORK);
extern void Zi8Memset(ziPtr p, ziU32 v, ziU32 len);
ziU8 Zi8GetZHCharSet(ziPtr workData) {
ziU8 charSet = 0;
ziU8 bak;
ziU16 v0;
ziU16 v1;
ziU16 v2;
ziU32 addr;
ziU8* p;
ziWChar candBuf[0x10];
ziGetParam getParam;
Zi8LogError(0x64, workData);
if (Zi8LangSupported(1, workData) == 0) {
Zi8ReplaceLastError(0x26C, workData);
return 0;
}
if (Zi8GetTableCount(1, 10, workData) != 0) {
bak = ((struct __zi8_work_data_s*)workData)->unk_0x18;
((struct __zi8_work_data_s*)workData)->unk_0x18 = 1;
addr = Zi8GetTableAddress(1, 10, workData);
p = (ziU8*)addr;
v0 = (ziU16)((ziU16)p[0] | ((ziU16)p[1] << 8));
((struct __zi8_work_data_s*)workData)->unk_0x18 = 0;
addr = Zi8GetTableAddress(1, 10, workData);
p = (ziU8*)addr;
v1 = (ziU16)((ziU16)p[2] | ((ziU16)p[3] << 8));
v2 = (ziU16)((ziU16)p[4] | ((ziU16)p[5] << 8));
((struct __zi8_work_data_s*)workData)->unk_0x18 = bak;
if (v0 != 0) {
if (v0 > 0x4E20) {
charSet |= 8;
} else {
charSet |= 1;
}
}
if (v1 != 0) {
if (v1 > 0x2710) {
charSet |= 2;
} else {
charSet |= 0x10;
}
}
if (v2 != 0) {
charSet |= 4;
}
return charSet;
}
Zi8Memset(&getParam, 0, 0x2C);
getParam.language = 1;
getParam.context = 1;
getParam.getOptions = 0;
getParam.candidates = candBuf;
getParam.maxCandidates = 1;
getParam.subLanguage = 1;
retry:
getParam.getMode = 0;
if (_Zi8GetCandidates(&getParam, workData) != 0) {
charSet |= getParam.subLanguage;
goto next;
}
getParam.getMode = 1;
if (_Zi8GetCandidates(&getParam, workData) != 0) {
charSet |= getParam.subLanguage;
goto next;
}
getParam.getMode = 2;
if (_Zi8GetCandidates(&getParam, workData) != 0) {
charSet |= getParam.subLanguage;
}
next:
if (getParam.subLanguage == 1) {
getParam.subLanguage = 4;
goto retry;
}
if (getParam.subLanguage == 4) {
getParam.subLanguage = 2;
goto retry;
}
return charSet;
}
ziBool Zi8IsComponent(ziWChar ch ZI_NEED_WORK) {
if (ch >= 0xEF10 && ch < 0xF305) {
return 1;
}
return 0;
}
ziBool Zi8IsCharacter(ziWChar ch ZI_NEED_WORK) {
ziU16 count;
ziU8 hi;
ziU8 lo;
ziU32 addr;
ziU8* table;
ziU16 i;
if (ch >= 0x3105 && ch <= 0x3129) {
return 1;
}
switch (ch) {
case 0x2C7:
case 0x2C9:
case 0x2CA:
case 0x2CB:
case 0x2D9:
return 1;
}
switch (ch) {
case 0x3002:
case 0xFF01:
case 0xFF0C:
case 0xFF1F:
return 1;
}
hi = (ziU8)(((ziU16)ch >> 8) & 0xFF);
lo = (ziU8)ch;
count = Zi8GetTableCount(1, 0, ZI_WORK);
addr = Zi8GetTableAddress(1, 0, ZI_WORK);
table = (ziU8*)addr;
for (i = 0; i < count; i++) {
if (table[6] == hi && table[7] == lo) {
return 1;
}
table += 0xC;
}
return 0;
}

View File

@@ -0,0 +1,144 @@
#include <zi8clib/zitypes.h>
#include <zi8clib/zierror.h>
extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
typedef struct { ziU8 b[0xC]; } ziE12;
#define WORKP ((struct __zi8_work_data_s*)__zi8_work_data)
ziU16 Zi8Uni2Ptr(ziU16 ch, ziE12* buf ZI_NEED_WORK) {
ziU8 hi;
ziU8 lo;
ziU16 count;
ziU32 table;
ziU32 table2;
ziU16 i;
ziU8* e;
ziU8* p;
hi = (ziU8)(((ziU16)ch >> 8) & 0xFF);
lo = (ziU8)ch;
count = Zi8GetTableCount(1, 0, __zi8_work_data);
table = Zi8GetTableAddress(1, 0, __zi8_work_data);
table2 = Zi8GetTableAddress(1, 1, __zi8_work_data);
if (buf == ZI8_NULL) {
for (i = 0; i < 0x40; i++) {
if (ch == WORKP->unk_0x20[i]) {
i = WORKP->unk_0xA0[i];
e = (ziU8*)table + i * 0xC;
if (i >= count) {
break;
}
if (hi != e[6] || lo != e[7]) {
break;
}
p = (ziU8*)(table2 +
(((e[9] & 0xF) << 16) |
(e[0xB] | (e[0xA] << 8))));
if (WORKP->unk_0x16 != 0) {
switch (p[0] & 7) {
case 2:
p += 2;
break;
case 3:
case 4:
p += 3;
break;
case 5:
p += 4;
break;
default:
p += 1;
break;
}
}
if ((p[0] & 0x80) == 0) {
break;
}
if (buf != ZI8_NULL) {
*buf = *(ziE12*)e;
}
return i;
}
}
}
e = (ziU8*)table;
if (WORKP->unk_0x1B18 != ZI8_NULL && WORKP->unk_0x1B24 == WORKP->unk_0x18) {
if ((ziU16)ch >= WORKP->unk_0x1B1C && (ziU16)ch <= WORKP->unk_0x1B1E) {
i = (ziU16)(ch - WORKP->unk_0x1B1C);
goto map;
}
if ((ziU16)ch >= WORKP->unk_0x1B20 && (ziU16)ch <= WORKP->unk_0x1B22) {
i = (ziU16)(WORKP->unk_0x1B1E + (ch - WORKP->unk_0x1B20) -
WORKP->unk_0x1B1C + 1);
goto map;
}
return 0xFFFF;
map:
i = WORKP->unk_0x1B18[i];
if (i != 0xFFFF) {
e = (ziU8*)table + i * 0xC;
if (hi == e[6] && lo == e[7]) {
if (buf != ZI8_NULL) {
*buf = *(ziE12*)e;
}
return i;
}
}
return 0xFFFF;
}
i = 0;
while (i < count) {
if (lo == e[7] && hi == e[6]) {
if (buf != ZI8_NULL) {
*buf = *(ziE12*)e;
}
return i;
}
e += 0xC;
i++;
}
return 0xFFFF;
}
ziU16 Zi8Uni2Ord(ziU16 ch ZI_NEED_WORK) {
return Zi8Uni2Ptr(ch, ZI8_NULL, __zi8_work_data);
}
ziU16 Zi8Ord2Uni(ziU16 ord ZI_NEED_WORK) {
ziU8* p;
if ((ziU16)ord >= Zi8GetTableCount(1, 0, __zi8_work_data)) {
Zi8LogError(0x132, __zi8_work_data);
return 0;
}
p = (ziU8*)Zi8GetTableAddress(1, 0, __zi8_work_data);
p += ord * 0xC;
Zi8LogError(0x64, __zi8_work_data);
return (ziU16)(((ziU16)p[6] << 8) + p[7]);
}
ziU16 Zi8Ord2Ord(ziU16 ord ZI_NEED_WORK) {
ziU32 table;
ziU16 count;
ziU8* p;
count = Zi8GetTableCount(1, 0, __zi8_work_data);
table = Zi8GetTableAddress(1, 0, __zi8_work_data);
if (ord == 0 || (ziU16)ord >= count) {
Zi8LogError(0x132, __zi8_work_data);
return ord;
}
p = (ziU8*)table + (ord - 1) * 0xC;
while (ord != 0) {
if (p[6] != p[0x12] || p[7] != p[0x13]) {
break;
}
p -= 0xC;
ord--;
}
Zi8LogError(0x64, __zi8_work_data);
return ord;
}

View File

@@ -0,0 +1,99 @@
#include <zi8clib/zi8space.h>
#include <zi8clib/zierror.h>
#include <zi8clib/zitypes.h>
extern ziU8 Zi8GetPyPhonetic(ziWChar* src, ziU8 i, ziWChar* a, ziWChar* b, ziU8* c,
ziU16* d, ziU16* e ZI_NEED_WORK);
extern ziU8 Zi8GetBpmfPhonetic(ziWChar* src, ziU8 i, ziWChar* a, ziWChar* b,
ziU16* d, ziU16* e ZI_NEED_WORK);
ziU8 Zi8ZHaddSpace(ziWChar* src, ziU8 count, ziWChar* dst,
ziU16 maxLen ZI_NEED_WORK) {
ziWChar candBuf[0x10];
ziWChar pyBuf[0x10];
ziU16 m;
ziU16 vE;
ziU16 vC;
ziU8 n;
ziU8 flag;
ziU8 v9;
ziU8 isPy;
int i;
int k;
ziWChar* psrc;
ziWChar* pdst;
psrc = src;
n = count;
pdst = dst;
m = maxLen;
if (n == 0) {
Zi8LogError(0x137, ZI_WORK);
return 0;
}
if ((psrc[0] >= 0xF361 && psrc[0] <= 0xF37A) ||
(psrc[0] >= 0xF341 && psrc[0] <= 0xF35A)) {
isPy = 1;
} else if (psrc[0] >= 0xF305 && psrc[0] <= 0xF329) {
isPy = 0;
} else {
goto fail;
}
i = 2;
while (i <= n) {
if (isPy) {
flag = Zi8GetPyPhonetic(psrc, i, candBuf, pyBuf, &v9, &vE, &vC, ZI_WORK);
if (i == v9) {
i++;
continue;
}
} else {
if ((psrc[i - 1] == 0xF360 && psrc[i - 2] != 0xF360) ||
Zi8GetBpmfPhonetic(psrc, i, candBuf, pyBuf, &vE, &vC, ZI_WORK) !=
0) {
i++;
continue;
}
}
if (i-- >= m - 1) {
goto fail;
}
m -= i + 1;
for (k = 0; k < i; k++) {
pdst[k] = psrc[k];
}
if (pdst[k - 1] != 0xF360 &&
(pdst[k - 1] < 0xF331 || pdst[k - 1] > 0xF335)) {
pdst[k++] = ZI_WORK->unk_0x1A;
}
psrc += i;
n -= i;
pdst += k;
i = 2;
}
if (i-- > m) {
goto fail;
}
for (k = 0; k < i; k++) {
pdst[k] = psrc[k];
}
pdst[k] = 0;
Zi8LogError(0x64, ZI_WORK);
return 1;
fail:
if ((ziU8)count >= (ziU16)maxLen) {
count = (ziU8)(maxLen - 1);
}
for (i = 0; i < count; i++) {
dst[i] = src[i];
}
dst[i] = 0;
Zi8LogError(0x64, ZI_WORK);
return 1;
}

View File

@@ -8,8 +8,13 @@ extern "C" {
#endif
void __VISetRGBModeImm();
#ifdef VI_MATCHING_SOURCE
BOOL __VIResetRFIdle();
BOOL __VIResetSIIdle();
#else
void __VIResetRFIdle();
void __VIResetSIIdle();
#endif
void __VIGetCurrentPosition(s16* x, s16* y);

View File

@@ -150,7 +150,11 @@ typedef struct DVDErrorInfo {
void DVDInit();
BOOL DVDReadAbsAsyncPrio(DVDCommandBlock* block, void* addr, s32 length, u32 offset, DVDCommandCallback callback, s32 prio);
#ifdef BS2_MACH_FIVE_ARG_READ
BOOL DVDReadAbsAsyncForBS(DVDCommandBlock* block, void* addr, s32 length, u32 offset, DVDCommandCallback callback);
#else
BOOL DVDReadAbsAsyncForBS(DVDCommandBlock* block, void* addr, s32 length, u32 offset, DVDCommandCallback callback, s32 prio);
#endif
BOOL DVDReadDiskID(DVDCommandBlock* block, DVDDiskID* diskID, DVDCommandCallback callback);
BOOL DVDCompareDiskID(const DVDDiskID* id1, const DVDDiskID* id2);

View File

@@ -27,8 +27,13 @@ void VISetNextFrameBuffer(void* fb);
void VISetBlack(BOOL setBlack);
void VISetTrapFilter(BOOL setTrap);
#ifdef VI_MATCHING_SOURCE
BOOL VIResetDimmingCount();
BOOL VIEnableDimming(BOOL enableDim);
#else
void VIResetDimmingCount();
void VIEnableDimming(BOOL enableDim);
#endif
u32 VIGetRetraceCount();
u32 VIGetDTVStatus();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,986 @@
#include <private/vf/PrFILE2/fatfs/pf_cache.h>
typedef struct PFCACHE_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_s32 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;
} PFCACHE_BPB;
struct PF_VOLUME {
PFCACHE_BPB bpb;
pf_u32 num_free_clusters;
pf_u32 last_free_cluster;
pf_u8 file_and_directory_state[0x1624 - 0x40];
PF_SECTOR_CACHE cache;
};
enum { FAT_32 = 2 };
extern void* pf_memcpy(void* dest, const void* src, pf_u32 size);
extern void* pf_memset(void* dest, pf_s32 value, pf_u32 size);
extern pf_s32 PFDRV_lread(PF_VOLUME* p_vol, pf_u8* buffer, pf_u32 sector, pf_u32 num_sector, pf_u32* p_num_success);
extern pf_s32 PFDRV_lwrite(PF_VOLUME* p_vol, const pf_u8* buffer, pf_u32 sector, pf_u32 num_sector, pf_u32* p_num_success);
pf_s32 PFCACHE_FlushAllCaches(PF_VOLUME* p_vol);
#pragma dont_inline on
pf_s32 PFCACHE_InitPageList(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, PF_CACHE_PAGE* pages, PF_CACHE_BUFFER* buffers, pf_u32 num,
pf_u32 size, pf_bool is_fat) {
pf_u32 i;
pf_u32 bps_per_buf;
*pp_head = pages;
bps_per_buf = (p_vol->bpb.bytes_per_sector >> 9) * size;
if ((num / bps_per_buf) == 0) {
return 30;
}
if ((num / bps_per_buf) == 1) {
pages->p_prev = pages;
pages->p_next = pages;
pages->buffer = *buffers;
pages->p_buf = *buffers;
pages->p_mod_sbuf = PF_NULL;
pages->p_mod_ebuf = PF_NULL;
pages->size = size;
pages->sector = 0xFFFFFFFF;
pages->option = 0;
pages->signature = PF_NULL;
pages->stat &= ~(0x01 | 0x02);
if (is_fat) {
pages->stat |= 0x04;
} else {
pages->stat &= ~0x04;
}
return 0;
}
pages->p_prev = &pages[(num - (num % bps_per_buf)) - bps_per_buf];
pages->p_next = &pages[bps_per_buf];
pages->buffer = *buffers;
pages->p_buf = *buffers;
pages->p_mod_sbuf = PF_NULL;
pages->p_mod_ebuf = PF_NULL;
pages->size = size;
pages->sector = 0xFFFFFFFF;
pages->option = 0;
pages->signature = PF_NULL;
pages->stat &= ~(0x01 | 0x02);
if (is_fat) {
pages->stat |= 0x04;
} else {
pages->stat &= ~0x04;
}
for (i = bps_per_buf; i < (num - (num % bps_per_buf) - bps_per_buf); i += bps_per_buf) {
pages[i].p_prev = &pages[i - bps_per_buf];
pages[i].p_next = &pages[i + bps_per_buf];
pages[i].buffer = buffers[i];
pages[i].p_buf = buffers[i];
pages[i].p_mod_sbuf = PF_NULL;
pages[i].p_mod_ebuf = PF_NULL;
pages[i].size = size;
pages[i].sector = 0xFFFFFFFF;
pages[i].option = 0;
pages[i].signature = PF_NULL;
pages[i].stat &= ~(0x01 | 0x02);
if (is_fat) {
pages[i].stat |= 0x04;
} else {
pages[i].stat &= ~0x04;
}
}
pages[(num - (num % bps_per_buf)) - bps_per_buf].p_prev = &pages[((num - (num % bps_per_buf)) - bps_per_buf) - bps_per_buf];
pages[(num - (num % bps_per_buf)) - bps_per_buf].p_next = pages;
pages[(num - (num % bps_per_buf)) - bps_per_buf].buffer = buffers[(num - (num % bps_per_buf)) - bps_per_buf];
pages[(num - (num % bps_per_buf)) - bps_per_buf].p_buf = buffers[(num - (num % bps_per_buf)) - bps_per_buf];
pages[(num - (num % bps_per_buf)) - bps_per_buf].p_mod_sbuf = PF_NULL;
pages[(num - (num % bps_per_buf)) - bps_per_buf].p_mod_ebuf = PF_NULL;
pages[(num - (num % bps_per_buf)) - bps_per_buf].size = size;
pages[(num - (num % bps_per_buf)) - bps_per_buf].sector = 0xFFFFFFFF;
pages[(num - (num % bps_per_buf)) - bps_per_buf].option = 0;
pages[(num - (num % bps_per_buf)) - bps_per_buf].signature = PF_NULL;
pages[(num - (num % bps_per_buf)) - bps_per_buf].stat &= ~(0x01 | 0x02);
if (is_fat) {
pages[(num - (num % bps_per_buf)) - bps_per_buf].stat |= 0x04;
} else {
pages[(num - (num % bps_per_buf)) - bps_per_buf].stat &= ~0x04;
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
PF_CACHE_PAGE* PFCACHE_SearchForPage(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_head, pf_u32 sector) {
PF_CACHE_PAGE* p_page;
if (sector == 0xFFFFFFFF) {
return PF_NULL;
}
if ((p_head->stat & 1) == 0) {
return PF_NULL;
}
if (p_head->sector <= sector && p_head->sector + p_head->size - 1 >= sector) {
p_head->p_buf = &p_head->buffer[(sector - p_head->sector) << p_vol->bpb.log2_bytes_per_sector];
return p_head;
}
for (p_page = p_head->p_next; p_page != p_head; p_page = p_page->p_next) {
if ((p_page->stat & 1) == 0) {
return PF_NULL;
}
if (p_page->sector <= sector && p_page->sector + p_page->size - 1 >= sector) {
p_page->p_buf = &p_page->buffer[(sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector];
return p_page;
}
}
return PF_NULL;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_bool PFCACHE_SearchForFreePage(PF_CACHE_PAGE* p_head, PF_CACHE_PAGE** pp_page) {
PF_CACHE_PAGE* p_page;
for (p_page = p_head->p_prev; p_page != p_head; p_page = p_page->p_prev) {
if ((p_page->stat & 1) == 0) {
*pp_page = p_page;
return PF_TRUE;
}
if (p_page->sector != 0xFFFFFFFF) {
*pp_page = p_page;
return PF_FALSE;
}
}
if ((p_page->stat & 1) == 0) {
*pp_page = p_page;
return PF_TRUE;
}
if (p_page->sector != 0xFFFFFFFF) {
*pp_page = p_page;
return PF_FALSE;
}
*pp_page = PF_NULL;
return PF_FALSE;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_FlushPageIfNeeded(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_page) {
pf_s32 err;
pf_u32 num_success;
pf_u32 size;
if (p_page != PF_NULL && (p_page->stat & 0x02) != 0 && p_page->sector != 0xFFFFFFFF) {
if (p_page->p_mod_sbuf == PF_NULL) {
size = p_page->size;
err = PFDRV_lwrite(p_vol, p_page->buffer, p_page->sector, size, &num_success);
} else {
size = (((pf_u32)p_page->p_mod_ebuf >> p_vol->bpb.log2_bytes_per_sector) -
((pf_u32)p_page->p_mod_sbuf >> p_vol->bpb.log2_bytes_per_sector)) + 1;
err = PFDRV_lwrite(p_vol, p_page->p_mod_sbuf,
p_page->sector + ((pf_u32)(p_page->p_mod_sbuf - p_page->buffer) >> p_vol->bpb.log2_bytes_per_sector),
size, &num_success);
}
if (err != 0) {
return err;
}
if (num_success != size) {
return 17;
}
p_page->p_mod_sbuf = NULL;
p_page->p_mod_ebuf = NULL;
p_page->stat &= ~2;
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoAllocatePage(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, pf_u32 sector, PF_CACHE_PAGE** pp_page, pf_bool* p_is_hit) {
pf_s32 err;
*pp_page = PFCACHE_SearchForPage(p_vol, *pp_head, sector);
if (*pp_page != PF_NULL) {
*p_is_hit = PF_TRUE;
} else {
*p_is_hit = PF_FALSE;
if (PFCACHE_SearchForFreePage(*pp_head, pp_page) == 0) {
if (*pp_page == 0) {
*pp_page = PF_NULL;
return 30;
}
err = PFCACHE_FlushPageIfNeeded(p_vol, *pp_page);
if (err != 0) {
*pp_page = PF_NULL;
return err;
}
(*pp_page)->p_mod_sbuf = NULL;
(*pp_page)->p_mod_ebuf = NULL;
}
if (sector != 0xFFFFFFFF) {
if (((*pp_page)->stat & 0x04) != 0) {
(*pp_page)->sector = sector - (sector % (*pp_page)->size);
(*pp_page)->p_buf = &(*pp_page)->buffer[(sector % (*pp_page)->size) << p_vol->bpb.log2_bytes_per_sector];
} else {
if (p_vol->bpb.fat_type == FAT_32 && (sector < p_vol->bpb.first_data_sector || sector >= p_vol->bpb.total_sectors)) {
if (sector == p_vol->bpb.fs_info_sector) {
(*pp_page)->size = 1;
}
}
(*pp_page)->sector = sector - (sector % (*pp_page)->size);
(*pp_page)->p_buf = &(*pp_page)->buffer[(sector % (*pp_page)->size) << p_vol->bpb.log2_bytes_per_sector];
}
} else {
(*pp_page)->sector = sector;
(*pp_page)->p_buf = (*pp_page)->buffer;
}
(*pp_page)->stat |= 0x01;
}
{
PF_CACHE_PAGE* p_page = *pp_page;
if (p_page != *pp_head) {
if (p_page == (*pp_head)->p_prev) {
*pp_head = p_page;
} else {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = *pp_head;
p_page->p_prev = (*pp_head)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
*pp_head = p_page;
}
}
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoReadPage(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, pf_u32 sector, PF_CACHE_PAGE** pp_page, pf_bool set_sig) {
pf_u32 num_success;
pf_bool is_hit;
pf_s32 err;
err = PFCACHE_DoAllocatePage(p_vol, pp_head, sector, pp_page, &is_hit);
if (err != 0) {
return err;
}
if (!is_hit) {
err = PFDRV_lread(p_vol, (*pp_page)->buffer, (*pp_page)->sector, (*pp_page)->size, &num_success);
if (err != 0) {
{
PF_CACHE_PAGE* p_page = *pp_page;
p_page->stat &= ~3;
p_page->p_mod_sbuf = NULL;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == *pp_head) {
*pp_head = p_page->p_next;
} else if (p_page != (*pp_head)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = *pp_head;
p_page->p_prev = (*pp_head)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
return err;
}
if (num_success != (*pp_page)->size && p_vol->bpb.total_sectors != ((*pp_page)->sector + num_success)) {
{
PF_CACHE_PAGE* p_page = *pp_page;
p_page->stat &= ~3;
p_page->p_mod_sbuf = NULL;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == *pp_head) {
*pp_head = p_page->p_next;
} else if (p_page != (*pp_head)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = *pp_head;
p_page->p_prev = (*pp_head)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
return 17;
}
(*pp_page)->stat &= ~2;
(*pp_page)->p_mod_sbuf = NULL;
(*pp_page)->p_mod_ebuf = NULL;
if (set_sig) {
(*pp_page)->signature = p_vol->cache.signature;
} else {
(*pp_page)->signature = PF_NULL;
}
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoReadPageAndFlushIfNeeded(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, pf_u32 sector, PF_CACHE_PAGE** pp_page,
pf_bool set_sig) {
pf_u32 num_success;
pf_bool is_hit;
pf_s32 err;
err = PFCACHE_DoAllocatePage(p_vol, pp_head, sector, pp_page, &is_hit);
if (err != 0) {
return err;
}
if (!is_hit) {
err = PFDRV_lread(p_vol, (*pp_page)->buffer, (*pp_page)->sector, (*pp_page)->size, &num_success);
if (err != 0) {
{
PF_CACHE_PAGE* p_page = *pp_page;
p_page->stat &= ~3;
p_page->p_mod_sbuf = NULL;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == *pp_head) {
*pp_head = p_page->p_next;
} else if (p_page != (*pp_head)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = *pp_head;
p_page->p_prev = (*pp_head)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
return err;
}
if (num_success != (*pp_page)->size && p_vol->bpb.total_sectors != ((*pp_page)->sector + num_success)) {
{
PF_CACHE_PAGE* p_page = *pp_page;
p_page->stat &= ~3;
p_page->p_mod_sbuf = NULL;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == *pp_head) {
*pp_head = p_page->p_next;
} else if (p_page != (*pp_head)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = *pp_head;
p_page->p_prev = (*pp_head)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
return 17;
}
(*pp_page)->stat &= ~2;
(*pp_page)->p_mod_sbuf = NULL;
(*pp_page)->p_mod_ebuf = NULL;
if (set_sig) {
(*pp_page)->signature = p_vol->cache.signature;
} else {
(*pp_page)->signature = PF_NULL;
}
} else if (set_sig && ((*pp_page)->stat & 0x02) != 0 && (p_vol->cache.mode & 0x02) != 0 && (*pp_page)->signature != p_vol->cache.signature) {
err = PFCACHE_FlushPageIfNeeded(p_vol, *pp_page);
if (err != 0) {
*pp_page = PF_NULL;
return err;
}
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoReadNumSector(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, pf_u8* p_buf, pf_u32 sector, pf_u32 num_sector,
pf_u32* p_num_success) {
PF_CACHE_PAGE* p_page;
pf_s32 err;
pf_u32 num_rest_sector;
pf_u32 num_success_sector;
*p_num_success = 0;
err = PFDRV_lread(p_vol, p_buf, sector, num_sector, p_num_success);
if (err != 0) {
return err;
}
p_page = PF_NULL;
num_rest_sector = *p_num_success;
num_success_sector = *p_num_success;
do {
if (p_page == PF_NULL) {
p_page = *pp_head;
} else {
p_page = p_page->p_next;
if (p_page == *pp_head) {
p_page = PF_NULL;
goto found_page;
}
}
for (; (p_page->stat & 1) != 0; p_page = p_page->p_next) {
if (p_page->sector != 0xFFFFFFFF) {
p_page->p_buf = p_page->buffer;
goto found_page;
}
}
p_page = PF_NULL;
found_page:
if (p_page != PF_NULL && p_page->sector != 0xFFFFFFFF) {
if (p_page->sector <= sector && p_page->sector + p_page->size >= sector + num_success_sector) {
pf_memcpy(p_buf, &p_page->buffer[(sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector],
num_success_sector << p_vol->bpb.log2_bytes_per_sector);
num_rest_sector -= num_success_sector;
} else if (p_page->sector >= sector && p_page->sector + p_page->size <= sector + num_success_sector) {
pf_memcpy(&p_buf[(p_page->sector - sector) << p_vol->bpb.log2_bytes_per_sector], p_page->buffer,
p_page->size << p_vol->bpb.log2_bytes_per_sector);
num_rest_sector -= p_page->size;
} else if (p_page->sector > sector && p_page->sector < sector + num_success_sector &&
p_page->sector + p_page->size >= sector + num_success_sector) {
pf_memcpy(&p_buf[(p_page->sector - sector) << p_vol->bpb.log2_bytes_per_sector], p_page->buffer,
(p_page->size - (p_page->sector + p_page->size - (sector + num_success_sector))) << p_vol->bpb.log2_bytes_per_sector);
num_rest_sector -= p_page->size - ((p_page->sector + p_page->size) - (sector + num_success_sector));
} else if (p_page->sector < sector && (p_page->sector + p_page->size) > sector &&
(p_page->sector + p_page->size) <= (sector + num_success_sector)) {
pf_memcpy(p_buf, &p_page->buffer[(sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector],
(p_page->size - (sector - p_page->sector)) << p_vol->bpb.log2_bytes_per_sector);
num_rest_sector -= p_page->size - (sector - p_page->sector);
}
}
} while (p_page != PF_NULL && num_rest_sector != 0);
if (*p_num_success != num_sector && p_vol->bpb.total_sectors != (sector + *p_num_success)) {
return 17;
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoWritePage(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, PF_CACHE_PAGE* p_page, pf_bool set_sig) {
pf_s32 err;
if (p_page != *pp_head) {
if (p_page == (*pp_head)->p_prev) {
*pp_head = p_page;
} else {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = *pp_head;
p_page->p_prev = (*pp_head)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
*pp_head = p_page;
}
}
p_page->stat |= 2;
if (p_page->p_mod_sbuf == PF_NULL) {
p_page->p_mod_sbuf = p_page->p_buf;
p_page->p_mod_ebuf = p_page->p_buf;
} else if (p_page->p_buf < p_page->p_mod_sbuf) {
p_page->p_mod_sbuf = p_page->p_buf;
} else if (p_page->p_buf > p_page->p_mod_ebuf) {
p_page->p_mod_ebuf = p_page->p_buf;
}
if (set_sig) {
p_page->signature = p_vol->cache.signature;
} else {
p_page->signature = PF_NULL;
}
if ((p_vol->cache.mode & 0x01) != 0 || ((p_vol->cache.mode & 0x04) != 0 && (p_page->stat & 0x04) != 0)) {
err = PFCACHE_FlushPageIfNeeded(p_vol, p_page);
if (err != 0) {
return err;
}
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoWriteSector(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, const pf_u8* p_buf, pf_u32 sector) {
PF_CACHE_PAGE* p_page;
pf_u32 num_success;
pf_s32 err;
p_page = PFCACHE_SearchForPage(p_vol, *pp_head, sector);
if (p_page != PF_NULL) {
pf_memcpy(p_page->p_buf, (pf_u8*)p_buf, p_vol->bpb.bytes_per_sector);
p_page->stat |= 2;
if (p_page->p_mod_sbuf == PF_NULL) {
p_page->p_mod_sbuf = p_page->p_buf;
p_page->p_mod_ebuf = p_page->p_buf;
} else if (p_page->p_buf < p_page->p_mod_sbuf) {
p_page->p_mod_sbuf = p_page->p_buf;
} else if (p_page->p_buf > p_page->p_mod_ebuf) {
p_page->p_mod_ebuf = p_page->p_buf;
}
err = PFCACHE_FlushPageIfNeeded(p_vol, p_page);
if (err != 0) {
return err;
}
} else {
err = PFDRV_lwrite(p_vol, p_buf, sector, 1, &num_success);
if (err != 0) {
return err;
}
if (num_success != 1) {
return 17;
}
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoWriteNumSectorAndFreeIfNeeded(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, const pf_u8* p_buf, pf_u32 sector,
pf_u32 num_sector, pf_u32* p_num_success) {
PF_CACHE_PAGE* p_page = PF_NULL;
pf_s32 err;
pf_u32 num_rest_sector = num_sector;
pf_u8* p_sbuf;
pf_u8* p_ebuf;
pf_u32 num_overlap;
pf_u32 last_sector;
*p_num_success = 0;
do {
if (p_page == PF_NULL) {
p_page = *pp_head;
} else {
p_page = p_page->p_next;
if (p_page == *pp_head) {
p_page = PF_NULL;
goto found_page;
}
}
for (; (p_page->stat & 1) != 0; p_page = p_page->p_next) {
if (p_page->sector != 0xFFFFFFFF) {
p_page->p_buf = p_page->buffer;
goto found_page;
}
}
p_page = PF_NULL;
found_page:
if (p_page != PF_NULL && p_page->sector != 0xFFFFFFFF) {
if (p_page->sector <= sector && (p_page->sector + p_page->size) >= (sector + num_sector)) {
pf_memcpy(&p_page->buffer[(sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector], (pf_u8*)p_buf,
num_sector << p_vol->bpb.log2_bytes_per_sector);
*p_num_success += num_rest_sector;
num_rest_sector = 0;
p_page->stat |= 2;
p_sbuf = &p_page->buffer[(sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector];
p_ebuf = &(&p_page->buffer[(sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector])[(num_sector - 1)
<< p_vol->bpb.log2_bytes_per_sector];
if (p_page->p_mod_sbuf == NULL) {
p_page->p_mod_sbuf = p_sbuf;
p_page->p_mod_ebuf = p_ebuf;
} else if (p_sbuf < p_page->p_mod_sbuf) {
p_page->p_mod_sbuf = p_sbuf;
} else if (p_page->p_mod_ebuf < p_ebuf) {
p_page->p_mod_ebuf = p_ebuf;
}
} else if (p_page->sector >= sector && (p_page->sector + p_page->size) <= (sector + num_sector)) {
pf_memcpy(p_page->buffer, (pf_u8*)&p_buf[(p_page->sector - sector) << p_vol->bpb.log2_bytes_per_sector],
p_page->size << p_vol->bpb.log2_bytes_per_sector);
num_rest_sector -= p_page->size;
*p_num_success += p_page->size;
p_page->stat |= 2;
p_page->p_mod_sbuf = p_page->buffer;
p_page->p_mod_ebuf = &p_page->buffer[(p_page->size - 1) << p_vol->bpb.log2_bytes_per_sector];
} else if (p_page->sector > sector && p_page->sector < (sector + num_sector) &&
(p_page->sector + p_page->size) >= (sector + num_sector)) {
pf_memcpy(p_page->buffer, (pf_u8*)&p_buf[(p_page->sector - sector) << p_vol->bpb.log2_bytes_per_sector],
(sector + num_sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector);
num_overlap = p_page->size - ((p_page->sector + p_page->size) - (num_sector + sector));
last_sector = p_page->sector + num_overlap - 1;
*p_num_success += num_overlap;
num_rest_sector -= num_overlap;
p_page->stat |= 2;
p_ebuf = &p_page->buffer[(last_sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector];
p_page->p_mod_sbuf = p_page->buffer;
if (p_page->p_mod_ebuf == NULL || p_page->p_mod_ebuf < p_ebuf) {
p_page->p_mod_ebuf = p_ebuf;
}
} else if (p_page->sector < sector && (p_page->sector + p_page->size) > sector &&
(p_page->sector + p_page->size) <= (sector + num_sector)) {
pf_memcpy(&p_page->buffer[(sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector], (pf_u8*)p_buf,
(p_page->size - (sector - p_page->sector)) << p_vol->bpb.log2_bytes_per_sector);
num_rest_sector -= p_page->size - (sector - p_page->sector);
*p_num_success += p_page->size - (sector - p_page->sector);
p_page->stat |= 2;
p_sbuf = &p_page->buffer[(p_page->size - (sector - p_page->sector) - 1) << p_vol->bpb.log2_bytes_per_sector];
if (p_page->p_mod_sbuf == NULL || p_sbuf < p_page->p_mod_sbuf) {
p_page->p_mod_sbuf = p_sbuf;
}
p_page->p_mod_ebuf = &p_page->buffer[(p_page->size - 1) << p_vol->bpb.log2_bytes_per_sector];
}
}
} while (p_page != PF_NULL && num_rest_sector != 0);
if (num_rest_sector != 0) {
err = PFDRV_lwrite(p_vol, p_buf, sector, num_sector, p_num_success);
if (err != 0) {
return err;
}
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoFlushCache(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_head) {
PF_CACHE_PAGE* p_page;
pf_s32 err;
pf_s32 first_err;
first_err = 0;
p_page = p_head;
if ((p_page->stat & 0x01) == 0) {
return 0;
}
if ((p_vol->cache.mode & 1) != 0 || ((p_vol->cache.mode & 4) != 0 && (p_page->stat & 4) != 0)) {
return 0;
}
do {
if ((p_page->stat & 0x01) == 0) {
break;
}
err = PFCACHE_FlushPageIfNeeded(p_vol, p_page);
if (err != 0 && first_err == 0) {
first_err = err;
}
p_page = p_page->p_next;
} while (p_page != p_head);
return first_err;
}
#pragma dont_inline reset
void PFCACHE_SetCache(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_cache_page, PF_CACHE_BUFFER* p_cache_buf, pf_u16 num_fat_pages, pf_u16 num_data_pages) {
p_vol->cache.pages = p_cache_page;
p_vol->cache.buffers = p_cache_buf;
p_vol->cache.num_fat_pages = num_fat_pages;
p_vol->cache.num_data_pages = num_data_pages;
}
void PFCACHE_SetFATBufferSize(PF_VOLUME* p_vol, pf_u32 size) {
if (size != 0) {
p_vol->cache.fat_buff_size = size;
}
}
void PFCACHE_SetDataBufferSize(PF_VOLUME* p_vol, pf_u32 size) {
if (size != 0) {
p_vol->cache.data_buff_size = size;
}
}
pf_s32 PFCACHE_InitCaches(PF_VOLUME* p_vol) {
pf_s32 err;
p_vol->cache.mode &= ~0x01;
p_vol->cache.mode |= 0x02;
p_vol->cache.mode &= ~0x04;
pf_memset(p_vol->cache.buffers, 0, (p_vol->cache.num_fat_pages + p_vol->cache.num_data_pages) << 9);
err = PFCACHE_InitPageList(p_vol, &p_vol->cache.p_current_fat, p_vol->cache.pages, p_vol->cache.buffers, p_vol->cache.num_fat_pages,
p_vol->cache.fat_buff_size, PF_TRUE);
if (err != 0) {
return err;
}
err = PFCACHE_InitPageList(p_vol, &p_vol->cache.p_current_data, &p_vol->cache.pages[p_vol->cache.num_fat_pages],
(PF_CACHE_BUFFER*)p_vol->cache.buffers[p_vol->cache.num_fat_pages], p_vol->cache.num_data_pages,
p_vol->cache.data_buff_size, PF_FALSE);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_SetWriteThroughMode(PF_VOLUME* p_vol) {
pf_s32 err = PFCACHE_FlushAllCaches(p_vol);
if (err != 0) {
return err;
}
p_vol->cache.mode |= 1;
return 0;
}
pf_s32 PFCACHE_SetWriteBackMode(PF_VOLUME* p_vol) {
p_vol->cache.mode &= ~1;
return 0;
}
pf_s32 PFCACHE_AllocateFATPage(PF_VOLUME* p_vol, pf_u32 sector, PF_CACHE_PAGE** pp_page, pf_bool* p_is_hit) {
pf_s32 err;
if (p_vol->cache.p_current_fat == 0) {
p_vol->cache.pages->buffer = *p_vol->cache.buffers;
p_vol->cache.pages->p_buf = *p_vol->cache.buffers;
*pp_page = p_vol->cache.pages;
return 0;
}
err = PFCACHE_DoAllocatePage(p_vol, &p_vol->cache.p_current_fat, sector, pp_page, p_is_hit);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_AllocateDataPage(PF_VOLUME* p_vol, pf_u32 sector, PF_CACHE_PAGE** pp_page, pf_bool* p_is_hit) {
pf_s32 err;
if (p_vol->cache.p_current_data == 0) {
p_vol->cache.pages->buffer = *p_vol->cache.buffers;
p_vol->cache.pages->p_buf = *p_vol->cache.buffers;
*pp_page = p_vol->cache.pages;
return 0;
}
err = PFCACHE_DoAllocatePage(p_vol, &p_vol->cache.p_current_data, sector, pp_page, p_is_hit);
if (err != 0) {
return err;
}
return 0;
}
void PFCACHE_FreeFATPage(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_page) {
if (p_vol->cache.p_current_fat != 0) {
p_page->p_mod_sbuf = NULL;
p_page->stat &= ~3;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == p_vol->cache.p_current_fat) {
p_vol->cache.p_current_fat = p_page->p_next;
} else if (p_page != (p_vol->cache.p_current_fat)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = p_vol->cache.p_current_fat;
p_page->p_prev = (p_vol->cache.p_current_fat)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
}
void PFCACHE_FreeDataPage(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_page) {
if (p_vol->cache.p_current_data != 0) {
p_page->p_mod_sbuf = NULL;
p_page->stat &= ~3;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == p_vol->cache.p_current_data) {
p_vol->cache.p_current_data = p_page->p_next;
} else if (p_page != (p_vol->cache.p_current_data)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = p_vol->cache.p_current_data;
p_page->p_prev = (p_vol->cache.p_current_data)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
}
pf_s32 PFCACHE_ReadFATPage(PF_VOLUME* p_vol, pf_u32 sector, PF_CACHE_PAGE** pp_page) {
pf_s32 err;
err = PFCACHE_DoReadPage(p_vol, &p_vol->cache.p_current_fat, sector, pp_page, 0U);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_ReadDataPage(PF_VOLUME* p_vol, pf_u32 sector, PF_CACHE_PAGE** pp_page, pf_bool set_sig) {
pf_s32 err;
err = PFCACHE_DoReadPage(p_vol, &p_vol->cache.p_current_data, sector, pp_page, set_sig);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_ReadDataPageAndFlushIfNeeded(PF_VOLUME* p_vol, pf_u32 sector, PF_CACHE_PAGE** pp_page, pf_bool set_sig) {
pf_s32 err;
err = PFCACHE_DoReadPageAndFlushIfNeeded(p_vol, &p_vol->cache.p_current_data, sector, pp_page, set_sig);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_ReadDataNumSector(PF_VOLUME* p_vol, pf_u8* p_buf, pf_u32 sector, pf_u32 num_sector, pf_u32* p_num_success) {
pf_s32 err;
if (sector >= p_vol->bpb.total_sectors) {
return 16;
}
err = PFCACHE_DoReadNumSector(p_vol, &p_vol->cache.p_current_data, p_buf, sector, num_sector, p_num_success);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_WriteFATPage(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_page) {
pf_s32 err;
err = PFCACHE_DoWritePage(p_vol, &p_vol->cache.p_current_fat, p_page, 0);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_WriteDataPage(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_page, pf_bool set_sig) {
pf_s32 err;
err = PFCACHE_DoWritePage(p_vol, &p_vol->cache.p_current_data, p_page, set_sig);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_WriteFATSectorAndFreeIfNeeded(PF_VOLUME* p_vol, const pf_u8* p_buf, pf_u32 sector) {
pf_s32 err;
if (sector >= p_vol->bpb.total_sectors) {
return 16;
}
err = PFCACHE_DoWriteSector(p_vol, &p_vol->cache.p_current_fat, p_buf, sector);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_WriteDataNumSectorAndFreeIfNeeded(PF_VOLUME* p_vol, const pf_u8* p_buf, pf_u32 sector, pf_u32 num_sector, pf_u32* p_num_success) {
pf_s32 err;
if (sector >= p_vol->bpb.total_sectors) {
return 16;
}
err = PFCACHE_DoWriteNumSectorAndFreeIfNeeded(p_vol, &p_vol->cache.p_current_data, p_buf, sector, num_sector, p_num_success);
if (err != 0) {
return err;
}
return 0;
}
PF_CACHE_PAGE* PFCACHE_SearchDataCache(PF_VOLUME* p_vol, pf_u32 sector) {
return PFCACHE_SearchForPage(p_vol, p_vol->cache.p_current_data, sector);
}
pf_s32 PFCACHE_FlushFATCache(PF_VOLUME* p_vol) {
pf_s32 err;
err = PFCACHE_DoFlushCache(p_vol, p_vol->cache.p_current_fat);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_FlushDataCache(PF_VOLUME* p_vol) {
pf_s32 err;
err = PFCACHE_DoFlushCache(p_vol, p_vol->cache.p_current_data);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_FlushDataCacheSpecific(PF_VOLUME* p_vol, void* signature) {
pf_s32 err = 0;
PF_CACHE_PAGE* p_head;
PF_CACHE_PAGE* p_page;
if ((p_vol->cache.mode & 7) != 0) {
p_head = p_vol->cache.p_current_data;
p_page = p_head;
if (p_page->signature == PF_NULL || p_page->signature == signature) {
err = PFCACHE_FlushPageIfNeeded(p_vol, p_page);
if (err != 0) {
return err;
}
}
for (p_page = p_page->p_next; p_page != p_head; p_page = p_page->p_next) {
if (p_page->signature == PF_NULL || p_page->signature == signature) {
err = PFCACHE_FlushPageIfNeeded(p_vol, p_page);
if (err != 0) {
return err;
}
continue;
}
}
}
return err;
}
pf_s32 PFCACHE_FlushAllCaches(PF_VOLUME* p_vol) {
pf_s32 err;
err = PFCACHE_DoFlushCache(p_vol, p_vol->cache.p_current_fat);
if (err != 0) {
return err;
}
err = PFCACHE_DoFlushCache(p_vol, p_vol->cache.p_current_data);
if (err != 0) {
return err;
}
return 0;
}
void PFCACHE_FreeAllCaches(PF_VOLUME* p_vol) {
while ((p_vol->cache.p_current_fat->stat & 0x01) != 0) {
{
PF_CACHE_PAGE* p_page = p_vol->cache.p_current_fat;
if (p_vol->cache.p_current_fat != 0) {
p_page->stat &= ~3;
p_page->p_mod_sbuf = NULL;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == p_vol->cache.p_current_fat) {
p_vol->cache.p_current_fat = p_page->p_next;
} else if (p_page != (p_vol->cache.p_current_fat)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = p_vol->cache.p_current_fat;
p_page->p_prev = (p_vol->cache.p_current_fat)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
}
}
while ((p_vol->cache.p_current_data->stat & 0x01) != 0) {
{
PF_CACHE_PAGE* p_page = p_vol->cache.p_current_data;
if (p_vol->cache.p_current_data != 0) {
p_page->stat &= ~3;
p_page->p_mod_sbuf = NULL;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == p_vol->cache.p_current_data) {
p_vol->cache.p_current_data = p_page->p_next;
} else if (p_page != (p_vol->cache.p_current_data)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = p_vol->cache.p_current_data;
p_page->p_prev = (p_vol->cache.p_current_data)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
}
}
}

View File

@@ -0,0 +1,747 @@
#include <private/vf/PrFILE2/fatfs/pf_entry.h>
typedef struct PFITER_FAT_HINT {
pf_u32 chain_index;
pf_u32 cluster;
pf_u32 previous_cluster;
} PFITER_FAT_HINT;
typedef struct PFITER_FFD {
pf_u32 start_cluster;
pf_u32 current_start_cluster;
pf_u32* p_start_cluster;
PF_LAST_CLUSTER last_cluster;
PF_FAT_LAST_ACCESS last_access_cluster;
PF_CLUSTER_LINK cluster_link;
PFITER_FAT_HINT* p_hint;
PF_VOLUME* p_vol;
} PFITER_FFD;
typedef struct PFITER_ENT_ITER {
pf_u32 index;
PF_VOLUME* p_vol;
PFITER_FFD ffd;
pf_u32 file_sector_index;
pf_u32 sector;
pf_u16 offset;
pf_u16 offset_mask;
pf_u8 buf[32];
pf_u8 log2_entries_per_sector;
} PFITER_ENT_ITER;
typedef struct PFITER_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_s32 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;
} PFITER_BPB;
struct PF_VOLUME {
PFITER_BPB bpb;
};
typedef struct PFITER_CONTEXT_VOLUME {
pf_u32 stat;
pf_s32 context_id;
PF_VOLUME* p_vol;
} PFITER_CONTEXT_VOLUME;
typedef struct PFITER_VOLUME_SET {
pf_u32 flags;
pf_u32 reserved;
PF_VOLUME* current_volume;
PFITER_CONTEXT_VOLUME context_volumes[3];
pf_s32 num_attached;
pf_s32 num_mounted;
pf_u32 config;
void* user_data;
pf_s32 last_error;
pf_s32 last_driver_error;
void (*code_callbacks[6])(void);
pf_u32 setting;
} PFITER_VOLUME_SET;
extern PFITER_VOLUME_SET pf_vol_set;
pf_s8* PFSTR_GetStrPos(PF_STR*, pf_u32);
pf_u32 PFSTR_GetCodeMode(PF_STR* p_str);
void PFSTR_MoveStrPos(PF_STR* p_str, pf_s16 num_char);
pf_u16 PFSTR_StrLen(PF_STR* p_str);
pf_u16 PFSTR_StrNumChar(PF_STR* p_str, pf_u32 target);
pf_s32 PFSTR_StrCmp(const PF_STR* p_str, const pf_s8* s);
pf_s32 PFSTR_StrNCmp(PF_STR* p_str, const pf_s8* s, pf_u32 target, pf_s16 offset, pf_u16 num);
void* pf_memcpy(void* dst, void* src, pf_u32 length);
void* pf_memset(void* dst, pf_s32 c, pf_u32 length);
pf_s32 pf_strncmp(const pf_s8* s1, const pf_s8* s2, pf_u32 length);
pf_u8 PFENT_CalcCheckSum(PF_DIR_ENT* p_ent);
void PFENT_LoadShortNameFromBuf(PF_DIR_ENT* p_ent, const pf_u8* buf);
void PFENT_loadEntryNumericFieldsFromBuf(PF_DIR_ENT* p_ent, const pf_u8* buf);
pf_s32 PFENT_LoadLFNEntryFieldsFromBuf(PF_DIR_ENT* p_ent, const pf_u8* buf);
pf_s32 PFENT_GetRootDir(PF_VOLUME* p_vol, PF_DIR_ENT* p_ent);
pf_s32 PFFAT_GetSectorSpecified(PFITER_FFD* p_ffd, pf_u32 file_sector_index, pf_u32 may_allocate, pf_u32* p_sector);
pf_s32 PFFAT_getBeforeChain(PF_VOLUME* p_vol, pf_u32 start_cluster, pf_u32 lActive, pf_u32* p_cluster);
pf_s32 PFFAT_ResetFFD(PFITER_FFD* p_ffd, pf_u32* p_start_cluster);
pf_s32 PFFAT_InitFFD(PFITER_FFD* p_ffd, PFITER_FAT_HINT* p_hint, PF_VOLUME* p_vol, pf_u32* p_start_cluster);
void PFPATH_InitTokenOfPath(PF_STR* p_str, pf_s8* path, pf_u32 code_mode);
pf_s32 PFPATH_GetNextTokenOfPath(PF_STR* p_str, pf_bool wildcard);
pf_bool PFPATH_MatchFileNameWithPattern(const pf_s8* file_name, PF_STR* p_pattern, pf_bool is_long_name);
void PFPATH_getLongNameformShortName(pf_s8* short_name, pf_s8* long_name, pf_u8 flag);
pf_u32 PFPATH_GetLengthFromShortname(const pf_s8* sSrc);
pf_u32 PFPATH_GetLengthFromUnicode(const pf_u16* sSrc);
pf_s32 PFPATH_transformInUnicode(pf_u16* sDestStr, const pf_s8* sSrcStr);
pf_bool PFPATH_GetExtShortNameIndex(PF_STR* p_str, pf_u32* p_index);
pf_s32 PFSEC_ReadData(PF_VOLUME* p_vol, pf_u8* p_buf, pf_u32 sector, pf_u16 offset, pf_u32 size, pf_u32* p_success_size, pf_bool set_sig);
pf_s32 PFSEC_WriteData(PF_VOLUME* p_vol, const pf_u8* p_buf, pf_u32 sector, pf_u16 offset, pf_u32 size, pf_u32* p_success_size, pf_bool set_sig);
pf_s32 PFVOL_GetCurrentDir(PF_VOLUME*, PF_DIR_ENT*);
pf_s32 PFCACHE_AllocateDataPage(PF_VOLUME*, pf_u32, PF_CACHE_PAGE**, pf_bool*);
pf_s32 PFCACHE_FreeDataPage(PF_VOLUME*, PF_CACHE_PAGE*);
pf_s32 PFENT_RecalcEntryIterator(PFITER_ENT_ITER*, pf_u32);
pf_s32 PFENT_ITER_IteratorInitialize(PFITER_ENT_ITER*, pf_u32);
pf_bool PFENT_ITER_IsAtLogicalEnd(PFITER_ENT_ITER*);
pf_s32 PFENT_ITER_MoveTo(PFITER_ENT_ITER*, pf_u32, pf_u32);
pf_s32 PFENT_ITER_Advance(PFITER_ENT_ITER*, pf_u32);
pf_s32 PFENT_ITER_Retreat(PFITER_ENT_ITER*, pf_u32);
pf_s32 PFENT_ITER_FindDirEntryFromCluster(PFITER_ENT_ITER*, PF_DIR_ENT*, pf_u32, pf_bool*);
#pragma dont_inline on
pf_s32 PFENT_RecalcEntryIterator(PFITER_ENT_ITER* p_iter, pf_u32 may_allocate) {
pf_u32 file_sector_index;
pf_u32 previous_fsindex;
pf_u32 sector_count;
pf_s32 err;
PF_CACHE_PAGE* page;
pf_u32 success_size;
pf_bool hit;
file_sector_index = p_iter->index >> p_iter->log2_entries_per_sector;
previous_fsindex = p_iter->file_sector_index;
if (file_sector_index != p_iter->file_sector_index) {
p_iter->file_sector_index = file_sector_index;
err = PFFAT_GetSectorSpecified(&p_iter->ffd, file_sector_index, 0, &p_iter->sector);
if (err != 0) return err;
if (p_iter->sector == -1U && may_allocate != 0) {
err = PFFAT_GetSectorSpecified(&p_iter->ffd, file_sector_index, 1, &p_iter->sector);
if (err != 0) return err;
if (p_iter->sector != -1U && previous_fsindex != -1U) {
err = PFCACHE_AllocateDataPage(p_iter->p_vol, -1U, &page, &hit);
if (err != 0) return err;
pf_memset(page->p_buf, 0, p_iter->p_vol->bpb.bytes_per_sector);
for (sector_count = 0; sector_count < p_iter->p_vol->bpb.sectors_per_cluster; ++sector_count) {
err = PFSEC_WriteData(p_iter->p_vol, page->p_buf, p_iter->sector + sector_count, 0,
p_iter->p_vol->bpb.bytes_per_sector, &success_size, 0);
if (err != 0) {
PFCACHE_FreeDataPage(p_iter->p_vol, page);
return err;
}
if (success_size != p_iter->p_vol->bpb.bytes_per_sector) {
PFCACHE_FreeDataPage(p_iter->p_vol, page);
return 17;
}
}
PFCACHE_FreeDataPage(p_iter->p_vol, page);
}
}
}
p_iter->offset = (p_iter->index & p_iter->offset_mask) * 32;
return 0;
}
#pragma dont_inline reset
static inline pf_s32 PFENT_ITER_LoadEntry(PFITER_ENT_ITER* p_iter) {
pf_u32 success_size;
pf_s32 err;
if (p_iter->sector == -1) {
return 16;
}
err = PFSEC_ReadData(p_iter->p_vol, p_iter->buf, p_iter->sector, p_iter->offset, 0x20U, &success_size, 0U);
if (success_size != 0x20) {
return 17;
}
return err;
}
static inline pf_s32 PFENT_ITER_DoMoveTo(PFITER_ENT_ITER* p_iter, pf_u32 index, pf_u32 may_allocate) {
pf_u32 prev_index = p_iter->index;
pf_s32 err;
p_iter->index = index;
err = PFENT_RecalcEntryIterator(p_iter, may_allocate);
if (err != 0) {
p_iter->index = prev_index;
PFENT_RecalcEntryIterator(p_iter, 0U);
return err;
}
err = PFENT_ITER_LoadEntry(p_iter);
if (err != 0) {
return err;
}
return 0;
}
static inline void PFENT_ITER_MakeLongFileName(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent) {
pf_s32 lengthName;
signed char filename[13];
lengthName = 0;
PFPATH_getLongNameformShortName(p_ent->short_name, filename, p_iter->buf[0xC]);
lengthName = PFPATH_transformInUnicode(p_ent->long_name, filename);
p_ent->num_entry_LFNs = ((lengthName % 13) ? 1 : 0) + (lengthName / 13);
p_ent->check_sum = PFENT_CalcCheckSum(p_ent);
p_ent->ordinal = 1;
}
static inline pf_s32 InitializeIterator(PFITER_ENT_ITER* p_iter, pf_u32 index) {
p_iter->p_vol = p_iter->ffd.p_vol;
p_iter->log2_entries_per_sector = p_iter->p_vol->bpb.log2_bytes_per_sector - 5;
p_iter->offset_mask = (1 << p_iter->log2_entries_per_sector) - 1;
p_iter->file_sector_index = -1U;
return PFENT_ITER_DoMoveTo(p_iter, index, 0);
}
static inline pf_s32 AdvanceIterator(PFITER_ENT_ITER* p_iter, pf_u32 may_allocate) {
pf_s32 err = PFENT_ITER_DoMoveTo(p_iter, p_iter->index + 1, may_allocate);
if (err != 0) return err;
return 0;
}
static inline void LoadNumericEntry(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent) {
PFENT_loadEntryNumericFieldsFromBuf(p_ent, p_iter->buf);
p_ent->entry_sector = p_iter->sector;
p_ent->entry_offset = p_iter->offset;
p_ent->p_vol = p_iter->ffd.p_vol;
if ((p_ent->attr & 0x10) && p_ent->start_cluster == 0) p_ent->start_cluster = 1;
}
pf_s32 PFENT_ITER_DoFindEntry(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_STR* p_pattern,
pf_u32 attr_required, pf_u32 attr_forbidden, pf_bool* p_is_found) {
pf_s32 err = 0;
pf_u32 index_search_from;
pf_u32 is_extsfn = 0;
*p_is_found = 0;
if (PFSTR_StrCmp(p_pattern, (pf_s8*)"..") == 0 && (p_ent->attr & 0x10) && p_ent->start_cluster == 1) return 2;
if (PFSTR_StrCmp(p_pattern, (pf_s8*)".") == 0) {
*p_is_found = 1;
return 0;
}
p_ent->num_entry_LFNs = 0;
p_ent->ordinal = 0;
p_ent->check_sum = 0;
p_ent->long_name[0] = 0;
if ((pf_vol_set.setting & 2) == 2) is_extsfn = PFPATH_GetExtShortNameIndex(p_pattern, &index_search_from);
if (is_extsfn == 1) {
for (err = InitializeIterator(p_iter, index_search_from - 1);; err = PFENT_ITER_Retreat(p_iter, 0)) {
pf_s32 attr;
if (err != 0) return err;
if ((p_iter->buf[11] & 15) == 15) {
if (PFENT_LoadLFNEntryFieldsFromBuf(p_ent, p_iter->buf) != 0) return 3;
if (!(p_iter->buf[0] & 0x40)) continue;
} else return 0;
err = InitializeIterator(p_iter, index_search_from);
if (err != 0) return err;
attr = p_iter->buf[11];
if (attr == 0) attr = 0x40;
if (attr_required & 0x80) {
attr_required &= 0x7f;
attr_forbidden &= 0x7f;
if ((attr_required && (pf_s32)(attr_required & attr) != (pf_s32)attr_required) ||
(attr_forbidden && (pf_s32)(attr_forbidden & attr) == (pf_s32)attr_forbidden)) err = -1;
} else if (attr_required != 0x7f && attr != attr_required &&
(!(attr & attr_required) || (attr & attr_forbidden))) err = -1;
if (err == -1) return 0;
if (attr & 8) return 3;
PFENT_LoadShortNameFromBuf(p_ent, p_iter->buf);
if (PFPATH_MatchFileNameWithPattern(p_ent->short_name, p_pattern, 0)) {
LoadNumericEntry(p_iter, p_ent);
*p_is_found = 1;
return 0;
}
goto finish;
}
}
for (; PFENT_ITER_IsAtLogicalEnd(p_iter) == PF_FALSE; err = AdvanceIterator(p_iter, 0)) {
pf_s32 attr;
if (err != 0) return err;
if (p_iter->buf[0] == 0) break;
if (p_iter->buf[0] == 0xe5) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
continue;
}
attr = p_iter->buf[11];
if ((attr & 15) == 15) {
if (PFENT_LoadLFNEntryFieldsFromBuf(p_ent, p_iter->buf) != 0) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
}
continue;
}
if (attr == 0) attr = 0x40;
if (attr_required & 0x80) {
attr_required &= 0x7f;
attr_forbidden &= 0x7f;
if ((attr_required && (pf_s32)(attr_required & attr) != (pf_s32)attr_required) ||
(attr_forbidden && (pf_s32)(attr_forbidden & attr) == (pf_s32)attr_forbidden)) err = -1;
} else if ((pf_u8)attr_required != 0x7f && (pf_u32)attr != (pf_u8)attr_required &&
(!(attr & (pf_u8)attr_required) || (attr & (pf_u8)attr_forbidden))) err = -1;
if (err == -1) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
continue;
}
if (attr & 8) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
}
PFENT_LoadShortNameFromBuf(p_ent, p_iter->buf);
if (p_ent->num_entry_LFNs && p_ent->ordinal == 1 && p_ent->check_sum == PFENT_CalcCheckSum(p_ent) &&
PFPATH_MatchFileNameWithPattern((pf_s8*)p_ent->long_name, p_pattern, 1)) {
LoadNumericEntry(p_iter, p_ent);
*p_is_found = 1;
return 0;
}
if (PFPATH_MatchFileNameWithPattern(p_ent->short_name, p_pattern, 0)) {
if (p_iter->buf[12] & 0x18) PFENT_ITER_MakeLongFileName(p_iter, p_ent);
LoadNumericEntry(p_iter, p_ent);
*p_is_found = 1;
return 0;
}
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
}
finish:
return 0;
}
pf_s32 PFENT_ITER_DoGetEntry(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_VOLUME* p_vol, PF_STR* p_path, pf_bool wildcard,
pf_bool no_look_last_token) {
pf_s8* p;
PF_STR token;
pf_bool is_found;
PFITER_FAT_HINT hint;
pf_u32 start_cluster;
PF_DIR_ENT current_ent;
pf_s32 err;
pf_u32 code_mode;
if (PFSTR_StrNCmp(p_path, (pf_s8*)":", 1, 1, 1) == 0) {
PFSTR_MoveStrPos(p_path, 2);
}
if ((PFSTR_StrNCmp(p_path, (pf_s8*)"\\", 1, 0, 1) == 0 || PFSTR_StrNCmp(p_path, (pf_s8*)"/", 1, 0, 1) == 0)) {
err = PFENT_GetRootDir(p_vol, p_ent);
if (err != 0) {
return err;
}
if (PFSTR_StrNumChar(p_path, 1) == 1 && (PFSTR_StrNCmp(p_path, (pf_s8*)"\0", 2, 0, 1) == 0)) {
return 0;
}
} else {
err = PFVOL_GetCurrentDir(p_vol, p_ent);
if (err != 0) {
return err;
}
}
p = PFSTR_GetStrPos(p_path, 1);
PFFAT_InitFFD(&p_iter->ffd, &hint, p_vol, &p_iter->ffd.current_start_cluster);
p_iter->ffd.current_start_cluster = p_ent->start_cluster;
code_mode = PFSTR_GetCodeMode(p_path);
PFPATH_InitTokenOfPath(&token, p, code_mode);
for (err = PFPATH_GetNextTokenOfPath(&token, wildcard); token.p_head != 0; err = PFPATH_GetNextTokenOfPath(&token, wildcard)) {
if (err != 0) {
return err;
}
if (no_look_last_token != 0 && (PFSTR_StrNCmp(&token, (pf_s8*)"\0", 2, 0, 1) == 0)) {
break;
}
if ((p_ent->attr & 0x10) == 0) {
return 2;
}
if (PFSTR_StrLen(&token) == 0) {
return 2;
}
p_iter->ffd.current_start_cluster = p_ent->start_cluster;
PFFAT_ResetFFD(&p_iter->ffd, &p_iter->ffd.current_start_cluster);
err = InitializeIterator(p_iter, 0);
if (err != 0) {
return err;
}
start_cluster = *p_iter->ffd.p_start_cluster;
err = PFENT_ITER_DoFindEntry(p_iter, p_ent, &token, 0x7F, 0, &is_found);
if (err != 0) {
return err;
}
if (!is_found) {
err = PFPATH_GetNextTokenOfPath(&token, wildcard);
if (err != 0) {
return err;
}
return (token.p_head == PF_NULL) + 2;
}
if (!wildcard) {
if ((p_ent->attr & 0x10) != 0 && p_ent->start_cluster == 1) {
p_ent->path_len = 3;
continue;
}
if ((p_ent->attr & 0x10) != 0 && p_ent->short_name[0] == '.' && p_ent->short_name[1] == '.') {
PFFAT_ResetFFD(&p_iter->ffd, &p_ent->start_cluster);
err = InitializeIterator(p_iter, 0);
if (err != 0) {
return err;
}
current_ent.attr = p_ent->attr;
current_ent.start_cluster = p_ent->start_cluster;
err = PFENT_ITER_FindDirEntryFromCluster(p_iter, &current_ent, start_cluster, &is_found);
if (err != 0) {
return err;
}
if (is_found == 0) {
return 2;
}
if (current_ent.num_entry_LFNs != 0) {
p_ent->path_len -= PFPATH_GetLengthFromUnicode(current_ent.long_name);
} else {
p_ent->path_len -= PFPATH_GetLengthFromShortname(&current_ent.short_name[0]);
}
p_ent->path_len--;
continue;
}
if ((p_ent->attr & 0x10) == 0 || p_ent->short_name[0] != '.') {
p_ent->path_len = (PFSTR_StrNumChar(&token, 1) + 1) + p_ent->path_len;
if ((PFSTR_StrNCmp(&token, (pf_s8*)"\0", 2, 0, 1) != 0)) {
p_ent->path_len -= PFSTR_StrNumChar(&token, 2);
}
}
continue;
}
}
return 0;
}
pf_s32 PFENT_ITER_IteratorInitialize(PFITER_ENT_ITER* p_iter, pf_u32 index_start_from) {
pf_s32 err;
p_iter->p_vol = p_iter->ffd.p_vol;
p_iter->log2_entries_per_sector = p_iter->p_vol->bpb.log2_bytes_per_sector - 5;
p_iter->offset_mask = (1 << p_iter->log2_entries_per_sector) - 1;
p_iter->file_sector_index = -1;
err = PFENT_ITER_DoMoveTo(p_iter, index_start_from, 0U);
return err;
}
pf_bool PFENT_ITER_IsAtLogicalEnd(PFITER_ENT_ITER* p_iter) {
pf_s32 err;
pf_u32 save_index;
pf_u32 save_fsindex;
if (p_iter->sector == -1U || p_iter->buf[0] == 0 || p_iter->index >= (1000000 - 1)) {
save_index = p_iter->index;
save_fsindex = p_iter->file_sector_index;
p_iter->index = (p_iter->file_sector_index + 1) << p_iter->log2_entries_per_sector;
err = PFENT_RecalcEntryIterator(p_iter, PF_FALSE);
if (err != 0) {
p_iter->index = save_index;
p_iter->file_sector_index = save_fsindex;
return PF_TRUE;
}
if (p_iter->sector != -1) {
err = PFENT_ITER_LoadEntry(p_iter);
if (err != 0) {
return PF_TRUE;
}
return PF_FALSE;
}
return PF_TRUE;
}
return PF_FALSE;
}
pf_s32 PFENT_ITER_MoveTo(PFITER_ENT_ITER* p_iter, pf_u32 index, pf_u32 may_allocate) {
pf_s32 err;
if (p_iter->index != index || p_iter->sector != -1U || may_allocate == PF_FALSE) {
err = PFENT_ITER_DoMoveTo(p_iter, index, may_allocate);
if (err != 0) {
return err;
}
}
return 0;
}
pf_s32 PFENT_ITER_Advance(PFITER_ENT_ITER* p_iter, pf_u32 may_allocate) {
return PFENT_ITER_MoveTo(p_iter, p_iter->index + 1, may_allocate);
}
pf_s32 PFENT_ITER_FindCluster(PF_DIR_ENT* p_ent, pf_u32 cluster, pf_bool* p_is_found) {
PFITER_FAT_HINT hint;
pf_u32 entries_per_sector;
pf_u32 current_cluster;
PFITER_ENT_ITER iter;
pf_u32 sector_index;
pf_s32 err;
*p_is_found = 0;
if (p_ent->entry_sector < p_ent->p_vol->bpb.first_data_sector) return 0;
current_cluster = (p_ent->entry_sector - p_ent->p_vol->bpb.first_data_sector) >> p_ent->p_vol->bpb.log2_sectors_per_cluster;
sector_index = (p_ent->p_vol->bpb.sectors_per_cluster - 1) & (p_ent->entry_sector - p_ent->p_vol->bpb.first_data_sector);
if (current_cluster == cluster) {
*p_is_found = 1;
return 0;
}
iter.ffd.p_start_cluster = &current_cluster;
iter.ffd.p_hint = &hint;
iter.ffd.p_vol = p_ent->p_vol;
iter.ffd.start_cluster = 1;
iter.ffd.cluster_link.buffer = PF_NULL;
iter.log2_entries_per_sector = p_ent->p_vol->bpb.log2_bytes_per_sector - 5;
iter.file_sector_index = sector_index;
entries_per_sector = 1 << iter.log2_entries_per_sector;
iter.offset_mask = entries_per_sector - 1;
iter.p_vol = p_ent->p_vol;
iter.sector = p_ent->entry_sector;
iter.offset = p_ent->entry_offset;
iter.index = ((pf_u32)p_ent->entry_offset >> 5) + sector_index * entries_per_sector;
hint.chain_index = 0;
hint.cluster = current_cluster;
hint.previous_cluster = 1;
if (iter.index < 2) {
hint.chain_index = 1;
iter.file_sector_index += p_ent->p_vol->bpb.sectors_per_cluster;
iter.index += entries_per_sector << p_ent->p_vol->bpb.log2_sectors_per_cluster;
}
while (iter.index != 0) {
err = PFENT_ITER_LoadEntry(&iter);
if (err != 0) return err;
if (pf_strncmp((pf_s8*)iter.buf, (pf_s8*)"..", 2) == 0) break;
err = PFENT_ITER_Retreat(&iter, 0);
if (err != 0) return err;
if (current_cluster == cluster) {
*p_is_found = 1;
return 0;
}
if (current_cluster <= 2) return 0;
if (iter.index < 1) {
++hint.chain_index;
iter.file_sector_index += p_ent->p_vol->bpb.sectors_per_cluster;
iter.index += (1 << iter.log2_entries_per_sector) << p_ent->p_vol->bpb.log2_sectors_per_cluster;
}
}
current_cluster = (PF_SWAP_16(*(pf_u16*)&iter.buf[20]) << 16) | PF_SWAP_16(*(pf_u16*)&iter.buf[26]);
hint.chain_index = 0;
iter.file_sector_index = 0;
hint.cluster = current_cluster;
iter.sector = p_ent->p_vol->bpb.first_data_sector + ((current_cluster - 2) << p_ent->p_vol->bpb.log2_sectors_per_cluster);
iter.offset = 32;
iter.index = 1;
while (current_cluster > 2) {
err = PFENT_ITER_LoadEntry(&iter);
if (err != 0) return err;
if (pf_strncmp((pf_s8*)iter.buf, (pf_s8*)"..", 2) == 0) {
if (current_cluster == cluster) {
*p_is_found = 1;
return 0;
}
current_cluster = (PF_SWAP_16(*(pf_u16*)&iter.buf[20]) << 16) | PF_SWAP_16(*(pf_u16*)&iter.buf[26]);
hint.cluster = current_cluster;
iter.sector = p_ent->p_vol->bpb.first_data_sector + ((current_cluster - 2) << p_ent->p_vol->bpb.log2_sectors_per_cluster);
} else return 0;
}
return 0;
}
pf_s32 PFENT_ITER_Retreat(PFITER_ENT_ITER* p_iter, pf_u32 may_allocate) {
pf_u32 before_cluster;
pf_u32 cur_cluster;
pf_s32 err;
if (p_iter->index == 0) {
return 0;
}
if (p_iter->file_sector_index != ((p_iter->index - 1) >> p_iter->log2_entries_per_sector)) {
cur_cluster = ((p_iter->sector - p_iter->p_vol->bpb.first_data_sector) >> p_iter->p_vol->bpb.log2_sectors_per_cluster) + 2;
if ((p_iter->file_sector_index % p_iter->p_vol->bpb.sectors_per_cluster) == 0 || p_iter->p_vol->bpb.sectors_per_cluster == 1) {
if (p_iter->p_vol->bpb.fat_type == FAT_32 ||
(*p_iter->ffd.p_start_cluster > 1 && p_iter->p_vol->bpb.first_data_sector <= p_iter->sector)) {
err = PFFAT_getBeforeChain(p_iter->p_vol, cur_cluster, cur_cluster, &before_cluster);
if (err != 0) {
return err;
}
if (before_cluster == -1) {
return 14;
}
} else {
before_cluster = *p_iter->ffd.p_start_cluster;
}
} else {
before_cluster = cur_cluster;
}
p_iter->index--;
p_iter->file_sector_index--;
if (p_iter->p_vol->bpb.fat_type == FAT_32 || *p_iter->ffd.p_start_cluster > 1 && p_iter->p_vol->bpb.first_data_sector <= p_iter->sector) {
p_iter->sector = (p_iter->p_vol->bpb.first_data_sector + ((before_cluster - 2) << p_iter->p_vol->bpb.log2_sectors_per_cluster)) +
(p_iter->file_sector_index & (p_iter->p_vol->bpb.sectors_per_cluster - 1));
} else {
p_iter->sector--;
}
p_iter->offset = (p_iter->index & p_iter->offset_mask) * 0x20;
return 0;
}
return PFENT_ITER_MoveTo(p_iter, p_iter->index - 1, may_allocate);
}
pf_s32 PFENT_ITER_FindDirEntryFromCluster(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, pf_u32 cluster, pf_bool* p_is_found) {
pf_u8 attr;
pf_s32 err = 0;
*p_is_found = PF_FALSE;
p_ent->num_entry_LFNs = 0;
p_ent->ordinal = 0;
p_ent->check_sum = 0;
if ((p_ent->attr & 0x10) && p_ent->start_cluster == 1) return 2;
for (; PFENT_ITER_IsAtLogicalEnd(p_iter) == PF_FALSE; err = AdvanceIterator(p_iter, PF_FALSE)) {
if (err != 0) {
return err;
}
if (p_iter->buf[0] == 0xE5) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
continue;
}
attr = p_iter->buf[0xB];
if ((attr & (0x01 | 0x02 | 0x04 | 0x08)) == (0x01 | 0x02 | 0x04 | 0x08)) {
err = PFENT_LoadLFNEntryFieldsFromBuf(p_ent, p_iter->buf);
if (err != 0) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
}
continue;
}
if ((attr & 0x08) != 0) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
continue;
}
if ((attr & 0x10) == 0) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
continue;
}
PFENT_LoadShortNameFromBuf(p_ent, p_iter->buf);
if (p_ent->num_entry_LFNs != 0 && p_ent->ordinal == 1 && p_ent->check_sum == PFENT_CalcCheckSum(p_ent)) {
PFENT_loadEntryNumericFieldsFromBuf(p_ent, p_iter->buf);
p_ent->entry_sector = p_iter->sector;
p_ent->entry_offset = p_iter->offset;
p_ent->p_vol = p_iter->ffd.p_vol;
if ((p_ent->attr & 0x10) != 0 && p_ent->start_cluster != cluster) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
continue;
}
if ((p_ent->attr & 0x10) != 0 && p_ent->start_cluster == 0) {
p_ent->start_cluster = 1;
}
*p_is_found = 1;
}
if ((p_iter->buf[0xC] & (0x10 | 0x08)) != 0) {
PFENT_ITER_MakeLongFileName(p_iter, p_ent);
}
PFENT_loadEntryNumericFieldsFromBuf(p_ent, p_iter->buf);
p_ent->entry_sector = p_iter->sector;
p_ent->entry_offset = p_iter->offset;
p_ent->p_vol = p_iter->ffd.p_vol;
if ((p_ent->attr & 0x10) && p_ent->start_cluster != cluster) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
*p_is_found = 0;
continue;
}
if ((p_ent->attr & 0x10) && p_ent->start_cluster == 0) p_ent->start_cluster = 1;
*p_is_found = 1;
return 0;
}
return 0;
}
pf_s32 PFENT_ITER_FindEntry(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_STR* p_pattern,
pf_u32 attr_required, pf_u32 attr_forbidden, pf_bool* p_is_found) {
pf_s32 err;
*p_is_found = 0;
if (attr_required & attr_forbidden) return 10;
if (PFSTR_StrNCmp(p_pattern, (pf_s8*)":", 1, 1, 1) == 0) PFSTR_MoveStrPos(p_pattern, 2);
if (PFSTR_StrNCmp(p_pattern, (pf_s8*)"\\", 1, 0, 1) == 0 || PFSTR_StrNCmp(p_pattern, (pf_s8*)"/", 1, 0, 1) == 0) {
err = PFENT_GetRootDir(p_iter->p_vol, p_ent);
if (err != 0) return err;
if (PFSTR_StrNumChar(p_pattern, 1) == 1 && PFSTR_StrNCmp(p_pattern, (pf_s8*)"\0", 2, 0, 1) == 0) return 0;
} else {
err = PFVOL_GetCurrentDir(p_iter->p_vol, p_ent);
if (err != 0) return err;
}
err = PFENT_ITER_DoFindEntry(p_iter, p_ent, p_pattern, attr_required, attr_forbidden, p_is_found);
if (err != 0) return err;
return 0;
}
pf_s32 PFENT_ITER_FindEntryNoPathCheck(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_STR* p_pattern,
pf_u32 attr_required, pf_u32 attr_forbidden, pf_bool* p_is_found) {
pf_s32 err;
*p_is_found = 0;
if (attr_required & attr_forbidden) return 10;
err = PFENT_ITER_DoFindEntry(p_iter, p_ent, p_pattern, attr_required, attr_forbidden, p_is_found);
if (err != 0) return err;
return 0;
}
pf_s32 PFENT_ITER_GetEntryOfPath(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_VOLUME* p_vol, PF_STR* p_path, pf_u32 no_look_last_token) {
return PFENT_ITER_DoGetEntry(p_iter, p_ent, p_vol, p_path, 0, no_look_last_token);
}
pf_s32 PFENT_ITER_GetEntryOfPattern(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_VOLUME* p_vol, PF_STR* p_path) {
return PFENT_ITER_DoGetEntry(p_iter, p_ent, p_vol, p_path, 1, 1);
}
pf_s32 PFENT_ITER_GetEntryOfIter(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent) {
PFENT_LoadShortNameFromBuf(p_ent, p_iter->buf);
PFENT_loadEntryNumericFieldsFromBuf(p_ent, p_iter->buf);
p_ent->entry_sector = p_iter->sector;
p_ent->entry_offset = p_iter->offset;
p_ent->p_vol = p_iter->p_vol;
return 0;
}
pf_s32 PFENT_ITER_GetLFNEntryName(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent) {
pf_u32 i;
pf_s32 err;
if (p_ent->num_entry_LFNs != 0 && !(p_ent->small_letter_flag & 0x18)) {
for (i = 0; i < p_ent->num_entry_LFNs; ++i) {
pf_u16* destination;
err = PFENT_ITER_Retreat(p_iter, 0);
if (err != 0) return err;
err = PFENT_ITER_LoadEntry(p_iter);
if (err != 0) return err;
destination = &p_ent->long_name[(i * 26U) / 2U];
pf_memcpy(destination, &p_iter->buf[1], 10);
pf_memcpy(destination + 5, &p_iter->buf[14], 12);
pf_memcpy(destination + 11, &p_iter->buf[28], 4);
}
p_ent->long_name[(p_ent->num_entry_LFNs * 26U) / 2U] = 0;
}
return 0;
}

2123
libs/RVL_SDK/src/fa/pf_fat.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -390,12 +390,12 @@ pf_s32 PFFILE_Cursor_Read(PFFILE_FILE* file, pf_u8* buffer, pf_u32 size, pf_u32*
if (error != 0) {
return error;
}
if (size <= part_size) {
if (part_size >= size) {
return 0;
}
size -= part_size;
volume = file == PF_NULL ? PF_NULL : file->p_sfd->dir_entry.p_vol;
while (volume->bpb.bytes_per_sector <= size) {
while (size >= volume->bpb.bytes_per_sector) {
error = PFFILE_Cursor_ReadBodySectors(file, buffer + *size_read, size, &part_size);
*size_read += part_size;
if (error != 0) {
@@ -408,10 +408,10 @@ pf_s32 PFFILE_Cursor_Read(PFFILE_FILE* file, pf_u8* buffer, pf_u32 size, pf_u32*
}
error = PFFILE_Cursor_ReadTailSector(file, buffer + *size_read, size, &part_size);
*size_read += part_size;
if (error == 0) {
error = 0;
if (error != 0) {
return error;
}
return error;
return 0;
}
pf_s32 PFFILE_Cursor_WriteHeadSector(PFFILE_FILE* file, const pf_u8* buffer, pf_u32 size,
@@ -419,6 +419,11 @@ pf_s32 PFFILE_Cursor_WriteHeadSector(PFFILE_FILE* file, const pf_u8* buffer, pf_
pf_s32 error;
pf_u32 success_size;
pf_u32 next_position;
pf_u32 new_position;
pf_u32 current_sector;
pf_u32 written_size;
pf_u32 sector_advance;
pf_u32 next_sector;
PF_VOLUME* volume;
*size_written = 0;
@@ -447,16 +452,21 @@ pf_s32 PFFILE_Cursor_WriteHeadSector(PFFILE_FILE* file, const pf_u8* buffer, pf_
return error;
}
*size_written = success_size;
current_sector = file->cursor.sector;
written_size = success_size;
volume = file == PF_NULL ? PF_NULL : file->p_sfd->dir_entry.p_vol;
next_position = file->cursor.offset_in_sector + success_size;
next_position = file->cursor.offset_in_sector + written_size;
sector_advance = next_position >> volume->bpb.log2_bytes_per_sector;
next_sector = current_sector + sector_advance;
if (((volume->bpb.bytes_per_sector - 1) & next_position) != 0) {
file->cursor.sector += next_position >> volume->bpb.log2_bytes_per_sector;
file->cursor.sector = next_sector;
} else {
file->cursor.sector = -1;
}
file->cursor.position += success_size;
if (file->cursor.position > file->p_sfd->dir_entry.file_size) {
file->p_sfd->dir_entry.file_size = file->cursor.position;
new_position = file->cursor.position + success_size;
file->cursor.position = new_position;
if (new_position > file->p_sfd->dir_entry.file_size) {
file->p_sfd->dir_entry.file_size = new_position;
}
PFFILE_Cursor_Recalc(file);
PFCLUSTER_UpdateLastAccessCluster(file);
@@ -519,6 +529,11 @@ pf_s32 PFFILE_Cursor_WriteTailSector(PFFILE_FILE* file, const pf_u8* buffer, pf_
pf_s32 error;
pf_u32 success_size;
pf_u32 next_position;
pf_u32 current_sector;
pf_u32 written_size;
pf_u32 sector_advance;
pf_u32 next_sector;
pf_u32 new_position;
PF_VOLUME* volume;
*size_written = 0;
@@ -548,16 +563,21 @@ pf_s32 PFFILE_Cursor_WriteTailSector(PFFILE_FILE* file, const pf_u8* buffer, pf_
return error;
}
*size_written = success_size;
current_sector = file->cursor.sector;
written_size = success_size;
volume = file == PF_NULL ? PF_NULL : file->p_sfd->dir_entry.p_vol;
next_position = file->cursor.offset_in_sector + success_size;
next_position = file->cursor.offset_in_sector + written_size;
sector_advance = next_position >> volume->bpb.log2_bytes_per_sector;
next_sector = current_sector + sector_advance;
if (((volume->bpb.bytes_per_sector - 1) & next_position) != 0) {
file->cursor.sector += next_position >> volume->bpb.log2_bytes_per_sector;
file->cursor.sector = next_sector;
} else {
file->cursor.sector = -1;
}
file->cursor.position += success_size;
if (file->cursor.position > file->p_sfd->dir_entry.file_size) {
file->p_sfd->dir_entry.file_size = file->cursor.position;
new_position = file->cursor.position + success_size;
file->cursor.position = new_position;
if (new_position > file->p_sfd->dir_entry.file_size) {
file->p_sfd->dir_entry.file_size = new_position;
}
PFFILE_Cursor_Recalc(file);
PFCLUSTER_UpdateLastAccessCluster(file);
@@ -576,7 +596,6 @@ pf_s32 PFFILE_Cursor_Write(PFFILE_FILE* file, const pf_u8* buffer, pf_u32 size,
pf_u32 append_needed;
pf_u32 allocated_end;
pf_u32 requested_end;
pf_u32 remaining;
PF_VOLUME* volume;
PFFILE_VOLUME_DIRS* volume_dirs;
@@ -598,9 +617,9 @@ pf_s32 PFFILE_Cursor_Write(PFFILE_FILE* file, const pf_u8* buffer, pf_u32 size,
if (part_size >= size) {
return 0;
}
remaining = size - part_size;
size -= part_size;
error = PFFAT_CountAllocatedClusters(&file->p_sfd->ffd,
file->cursor.position + remaining, &num_clusters);
file->cursor.position + size, &num_clusters);
if (file == PF_NULL) {
volume = PF_NULL;
} else {
@@ -608,17 +627,17 @@ pf_s32 PFFILE_Cursor_Write(PFFILE_FILE* file, const pf_u8* buffer, pf_u32 size,
}
allocated_end = num_clusters << (volume->bpb.log2_bytes_per_sector +
volume->bpb.log2_sectors_per_cluster);
requested_end = file->cursor.position + remaining;
requested_end = file->cursor.position + size;
if (allocated_end < requested_end) {
append_needed = requested_end - allocated_end;
} else {
append_needed = 0;
}
append_size = 0;
while (append_needed != 0 || remaining >= volume->bpb.bytes_per_sector) {
while (append_needed != 0 || size >= volume->bpb.bytes_per_sector) {
if (append_needed != 0) {
error = PFCLUSTER_AppendCluster(file, append_needed, &append_size);
if (error != 0 && remaining == append_needed) {
if (error != 0 && size == append_needed) {
return error;
}
if (append_size == 0) {
@@ -626,9 +645,9 @@ pf_s32 PFFILE_Cursor_Write(PFFILE_FILE* file, const pf_u8* buffer, pf_u32 size,
}
append_needed -= append_size;
}
while (remaining >= append_needed + append_size &&
remaining >= volume->bpb.bytes_per_sector) {
error = PFFILE_Cursor_WriteBodySectors(file, buffer + *size_written, remaining,
while (size >= append_needed + append_size &&
size >= volume->bpb.bytes_per_sector) {
error = PFFILE_Cursor_WriteBodySectors(file, buffer + *size_written, size,
&part_size);
*size_written += part_size;
if (error != 0) {
@@ -637,13 +656,13 @@ pf_s32 PFFILE_Cursor_Write(PFFILE_FILE* file, const pf_u8* buffer, pf_u32 size,
if (part_size == 0) {
return 0;
}
remaining -= part_size;
if (remaining == 0) {
size -= part_size;
if (size == 0) {
break;
}
}
}
error = PFFILE_Cursor_WriteTailSector(file, buffer + *size_written, remaining, &part_size);
error = PFFILE_Cursor_WriteTailSector(file, buffer + *size_written, size, &part_size);
*size_written += part_size;
error = error & ((-error | error) >> 31);
return error;
@@ -1072,8 +1091,6 @@ pf_s32 PFFILE_p_finfo(PFFILE_FILE* file, PF_INFO* info) {
pf_u32 cluster_size;
pf_u32 file_size_remainder;
pf_u32 file_size;
pf_u32 nonempty_bytes;
pf_s32 sign_bits;
pf_s32 error;
file->p_sfd->ffd.p_hint = &file->hint;
@@ -1088,9 +1105,10 @@ pf_s32 PFFILE_p_finfo(PFFILE_FILE* file, PF_INFO* info) {
}
file_size = file->p_sfd->dir_entry.file_size;
file_size_remainder = file_size % cluster_size;
nonempty_bytes = cluster_size - file_size_remainder;
sign_bits = -(pf_s32)file_size_remainder | (pf_s32)file_size_remainder;
info->empty_size = info->allocated_size + (nonempty_bytes & (sign_bits >> 31));
info->empty_size = info->allocated_size +
(file_size_remainder != 0
? cluster_size - file_size_remainder
: 0);
} else {
info->allocated_size = 0;
info->empty_size = 0;
@@ -1108,11 +1126,10 @@ pf_s32 PFFILE_p_combine(PF_VOLUME* volume, PF_STR* first_path, PF_STR* second_pa
PFFILE_ENT_ITER second_iter_copy;
PF_DIR_ENT first_entry;
PF_DIR_ENT second_entry;
PFFILE_FFD first_ffd;
PFFILE_FFD second_ffd;
PF_FAT_HINT first_hint;
PF_FAT_HINT second_hint;
pf_u32 index;
pf_s32 found;
pf_s32 error;
error = PFENT_ITER_GetEntryOfPath(&first_iter, &first_entry, volume, first_path, 0);
@@ -1129,24 +1146,36 @@ pf_s32 PFFILE_p_combine(PF_VOLUME* volume, PF_STR* first_path, PF_STR* second_pa
if ((first_entry.attr & 1) != 0 || (second_entry.attr & 1) != 0) {
return 0x18;
}
found = 0;
for (index = 0; index < 5; index++) {
PFFILE_SFD* sfd = &((PFFILE_VOLUME_DIRS*)first_entry.p_vol)->sfds[index];
if ((sfd->stat & 3) == 3 && first_entry.p_vol == sfd->dir_entry.p_vol &&
if ((sfd->stat & 1) != 0 && (sfd->stat & 2) != 0 &&
first_entry.p_vol == sfd->dir_entry.p_vol &&
first_entry.entry_sector == sfd->dir_entry.entry_sector &&
first_entry.entry_offset == sfd->dir_entry.entry_offset) {
return 0x13;
found = 1;
break;
}
}
if (found != 0) {
return 0x13;
}
found = 0;
for (index = 0; index < 5; index++) {
PFFILE_SFD* sfd = &((PFFILE_VOLUME_DIRS*)second_entry.p_vol)->sfds[index];
if ((sfd->stat & 3) == 3 && second_entry.p_vol == sfd->dir_entry.p_vol &&
if ((sfd->stat & 1) != 0 && (sfd->stat & 2) != 0 &&
second_entry.p_vol == sfd->dir_entry.p_vol &&
second_entry.entry_sector == sfd->dir_entry.entry_sector &&
second_entry.entry_offset == sfd->dir_entry.entry_offset) {
return 0x13;
found = 1;
break;
}
}
if (found != 0) {
return 0x13;
}
if (first_entry.entry_sector == second_entry.entry_sector &&
first_entry.entry_offset == second_entry.entry_offset) {
return 0xA;
@@ -1155,9 +1184,9 @@ pf_s32 PFFILE_p_combine(PF_VOLUME* volume, PF_STR* first_path, PF_STR* second_pa
return 0x25;
}
PFFAT_InitHint(&first_hint);
PFFAT_InitFFD(&first_ffd, &first_hint, volume, &first_entry.start_cluster);
PFFAT_InitFFD(&first_iter.ffd, &first_hint, volume, &first_entry.start_cluster);
PFFAT_InitHint(&second_hint);
PFFAT_InitFFD(&second_ffd, &second_hint, volume, &second_entry.start_cluster);
PFFAT_InitFFD(&second_iter.ffd, &second_hint, volume, &second_entry.start_cluster);
pf_memcpy(&second_iter_copy, &second_iter, sizeof(second_iter_copy));
error = PFENT_RemoveEntry(&second_entry, &second_iter);
if (error != 0) {
@@ -1485,18 +1514,19 @@ pf_s32 PFFILE_FsexecOpenFile(PF_DIR_ENT* entry, PFFILE_ENT_ITER* iter,
file->p_sfd = sfd;
file->stat = 1;
file->open_mode = mode;
file->last_access_data.state.last_error = 0;
file->lock_count = 0;
PFFAT_InitHint(&file->hint);
file->cursor.sector = 0xFFFFFFFF;
file->last_access_data.state.last_error = 0;
file->cursor.position = 0;
PFFILE_Cursor_Recalc(file);
if ((mode & 1) != 0) {
sfd->stat |= 4;
file->p_sfd->stat |= 4;
}
if ((mode & 4) != 0) {
if ((file->open_mode & 4) != 0) {
PFFILE_Cursor_MoveToEnd(file);
}
sfd->handler_count++;
data->p_file = (PF_FILE*)file;
return 0;
}
@@ -1600,12 +1630,13 @@ pf_s32 PFFILE_fopen(PF_STR* path, pf_s32 mode, PFFILE_FILE** result) {
}
pf_s32 PFFILE_fclose(PFFILE_FILE* file) {
pf_s32 close_error = 0;
PF_VOLUME* volume = file == PF_NULL ? PF_NULL : file->p_sfd->dir_entry.p_vol;
PFFILE_VOLUME_DIRS* volume_dirs;
pf_s32 error;
error = PFVOL_CheckForWrite(volume);
if (error != 0 && (error != 0x0B || file->open_mode != 2)) {
if (error != 0 && (error != 0x0B || (pf_s32)file->open_mode != 2)) {
pf_vol_set.last_error = error;
((PFFILE_VOLUME_DIRS*)volume)->last_error = error;
return error;
@@ -1617,12 +1648,11 @@ pf_s32 PFFILE_fclose(PFFILE_FILE* file) {
return 10;
}
volume_dirs->cache_signature = file;
if (file->p_sfd->handler_count <= 1 && (file->p_sfd->dir_entry.attr & 0x19) == 0 &&
PFVOL_CheckForWrite(volume) == 0 &&
if (((pf_s32)file->p_sfd->handler_count - 1) <= 0 &&
(file->p_sfd->dir_entry.attr & 0x19) == 0 &&
(error & 0x0B) == 0 &&
((file->p_sfd->stat & 4) != 0 || (volume_dirs->file_config & 1) != 1)) {
error = PFENT_updateEntry(&file->p_sfd->dir_entry, 1);
} else {
error = 0;
close_error = PFENT_updateEntry(&file->p_sfd->dir_entry, 1);
}
if (file->lock_count != 0) {
if ((file->p_sfd->lock.mode & 1) != 0) {
@@ -1633,7 +1663,7 @@ pf_s32 PFFILE_fclose(PFFILE_FILE* file) {
}
file->p_sfd->lock.mode &= ~3;
} else if (file->p_sfd->lock.owner != (PF_FILE*)file) {
error = 0x19;
close_error = 0x19;
} else {
file->p_sfd->lock.count = 0;
file->lock_count = 0;
@@ -1642,36 +1672,38 @@ pf_s32 PFFILE_fclose(PFFILE_FILE* file) {
file->p_sfd->lock.mode &= ~3;
}
}
if (error != 0) {
pf_vol_set.last_error = error;
((PFFILE_VOLUME_DIRS*)file->p_sfd->ffd.p_vol)->last_error = error;
file->last_access_data.state.last_error = error;
} else if ((volume_dirs->cache_control & 2) != 0) {
error = PFCACHE_FlushFATCache(volume);
if (error != 0) {
pf_vol_set.last_error = error;
((PFFILE_VOLUME_DIRS*)file->p_sfd->ffd.p_vol)->last_error = error;
file->last_access_data.state.last_error = error;
if (close_error != 0) {
pf_vol_set.last_error = close_error;
((PFFILE_VOLUME_DIRS*)file->p_sfd->ffd.p_vol)->last_error = close_error;
file->last_access_data.state.last_error = close_error;
goto close_file_complete;
}
if ((volume_dirs->cache_control & 2) != 0) {
close_error = PFCACHE_FlushFATCache(volume);
if (close_error != 0) {
pf_vol_set.last_error = close_error;
((PFFILE_VOLUME_DIRS*)file->p_sfd->ffd.p_vol)->last_error = close_error;
file->last_access_data.state.last_error = close_error;
} else {
error = PFCACHE_FlushDataCacheSpecific(volume, file);
if (error != 0) {
pf_vol_set.last_error = error;
((PFFILE_VOLUME_DIRS*)file->p_sfd->ffd.p_vol)->last_error = error;
file->last_access_data.state.last_error = error;
close_error = PFCACHE_FlushDataCacheSpecific(volume, file);
if (close_error != 0) {
pf_vol_set.last_error = close_error;
((PFFILE_VOLUME_DIRS*)file->p_sfd->ffd.p_vol)->last_error = close_error;
file->last_access_data.state.last_error = close_error;
}
}
}
if (error == 0) {
file->p_sfd->handler_count--;
if (file->p_sfd->handler_count == 0) {
if (close_error == 0) {
if (--file->p_sfd->handler_count == 0) {
file->p_sfd->stat &= ~1U;
file->p_sfd->ffd.cluster_link.buffer = PF_NULL;
}
file->stat &= ~1U;
volume_dirs->num_opened_files--;
}
close_file_complete:
volume_dirs->cache_signature = PF_NULL;
return error;
return close_error;
}
pf_s32 PFFILE_fread(pf_u8* buffer, pf_u32 size, pf_u32 count,
@@ -1704,11 +1736,12 @@ pf_s32 PFFILE_fread(pf_u8* buffer, pf_u32 size, pf_u32 count,
pf_s32 PFFILE_fwrite(const pf_u8* buffer, pf_u32 size, pf_u32 count,
PFFILE_FILE* file, pf_u32* count_written) {
PF_VOLUME* volume = file == PF_NULL ? PF_NULL : file->p_sfd->dir_entry.p_vol;
PF_VOLUME* volume;
pf_u32 bytes_written;
pf_s32 error;
*count_written = 0;
volume = file == PF_NULL ? PF_NULL : file->p_sfd->dir_entry.p_vol;
error = PFVOL_CheckForWrite(volume);
if (error != 0) {
pf_vol_set.last_error = error;
@@ -1753,10 +1786,10 @@ pf_s32 PFFILE_feof(PFFILE_FILE* file) {
((PFFILE_VOLUME_DIRS*)volume)->last_error = 0x26;
return 0x26;
}
if (file->cursor.position < file->p_sfd->dir_entry.file_size) {
return 0;
if (file->cursor.position >= file->p_sfd->dir_entry.file_size) {
error = 1;
}
return 1;
return error;
}
pf_s32 PFFILE_fseek(PFFILE_FILE* file, pf_s32 offset, pf_s32 origin) {
@@ -1841,10 +1874,9 @@ pf_s32 PFFILE_fsetclstlink(PFFILE_FILE* file, pf_u32 mode,
file->p_sfd->ffd.cluster_link.position++;
}
if (file->p_sfd->ffd.p_hint != PF_NULL) {
PFFILE_FAT_HINT* hint = (PFFILE_FAT_HINT*)file->p_sfd->ffd.p_hint;
hint->chain_index = 0;
hint->cluster = 0;
hint->previous_cluster = 0;
((PFFILE_FAT_HINT*)file->p_sfd->ffd.p_hint)->chain_index = 0;
((PFFILE_FAT_HINT*)file->p_sfd->ffd.p_hint)->cluster = 0;
((PFFILE_FAT_HINT*)file->p_sfd->ffd.p_hint)->previous_cluster = 0;
}
file->p_sfd->ffd.last_cluster.num_last_cluster = 0;
file->p_sfd->ffd.last_cluster.max_chain_index = 0;
@@ -1933,8 +1965,10 @@ pf_s32 PFFILE_fappend(PFFILE_FILE* file, pf_u32 size, pf_u32* size_appended) {
pf_s32 PFFILE_fadjust(PFFILE_FILE* file) {
PF_VOLUME* volume = file == PF_NULL ? PF_NULL : file->p_sfd->dir_entry.p_vol;
PFFILE_CURSOR saved_cursor;
PF_FAT_HINT saved_hint;
pf_u32 saved_last_access_chain_index;
struct {
PF_FAT_HINT hint;
pf_u32 last_access_chain_index;
} saved_hint;
pf_u16 access_time;
pf_s32 error;
@@ -1952,9 +1986,9 @@ pf_s32 PFFILE_fadjust(PFFILE_FILE* file) {
}
((PFFILE_VOLUME_DIRS*)volume)->cache_signature = file;
saved_cursor = file->cursor;
saved_hint = file->hint;
saved_last_access_chain_index = file->last_access_data.last_access.chain_index;
if ((file->open_mode & 8) == 0 && (file->open_mode & 4) != 0) {
saved_hint.hint = file->hint;
saved_hint.last_access_chain_index = file->last_access_data.last_access.chain_index;
if ((file->open_mode & 8) == 0 && (file->open_mode & 2) != 0) {
error = 0x0A;
} else if ((file->p_sfd->lock.mode & 3) != 0 &&
((file->p_sfd->lock.mode & 1) != 0 ||
@@ -1965,8 +1999,8 @@ pf_s32 PFFILE_fadjust(PFFILE_FILE* file) {
error &= (-error | error) >> 31;
}
file->cursor = saved_cursor;
file->hint = saved_hint;
file->last_access_data.last_access.chain_index = saved_last_access_chain_index;
file->hint = saved_hint.hint;
file->last_access_data.last_access.chain_index = saved_hint.last_access_chain_index;
((PFFILE_VOLUME_DIRS*)volume)->cache_signature = PF_NULL;
if (error != 0) {
pf_vol_set.last_error = error;
@@ -1981,8 +2015,10 @@ pf_s32 PFFILE_fadjust(PFFILE_FILE* file) {
pf_s32 PFFILE_finfo(PFFILE_FILE* file, PF_INFO* info) {
PF_VOLUME* volume = file == PF_NULL ? PF_NULL : file->p_sfd->dir_entry.p_vol;
PFFILE_CURSOR saved_cursor;
PF_FAT_HINT saved_hint;
pf_u32 saved_last_access_chain_index;
struct {
PF_FAT_HINT hint;
pf_u32 last_access_chain_index;
} saved_hint;
pf_s32 error;
error = PFVOL_CheckForRead(volume);
@@ -1999,12 +2035,12 @@ pf_s32 PFFILE_finfo(PFFILE_FILE* file, PF_INFO* info) {
}
((PFFILE_VOLUME_DIRS*)volume)->cache_signature = file;
saved_cursor = file->cursor;
saved_hint = file->hint;
saved_last_access_chain_index = file->last_access_data.last_access.chain_index;
saved_hint.hint = file->hint;
saved_hint.last_access_chain_index = file->last_access_data.last_access.chain_index;
error = PFFILE_p_finfo(file, info);
file->cursor = saved_cursor;
file->hint = saved_hint;
file->last_access_data.last_access.chain_index = saved_last_access_chain_index;
file->hint = saved_hint.hint;
file->last_access_data.last_access.chain_index = saved_hint.last_access_chain_index;
((PFFILE_VOLUME_DIRS*)volume)->cache_signature = PF_NULL;
if (error != 0) {
pf_vol_set.last_error = error;

File diff suppressed because it is too large Load Diff

View File

@@ -786,6 +786,7 @@ s32 PFVOL_CheckForWrite(PFVOL_VOLUME* volume) {
s32 PFVOL_CheckCurrentDir(PFVOL_VOLUME* volume, u32 start_cluster) {
s32 context_id;
u32 current_dir_index;
s32 result = 0;
if ((volume->flags & 8) == 0) {
return 9;
@@ -801,9 +802,9 @@ s32 PFVOL_CheckCurrentDir(PFVOL_VOLUME* volume, u32 start_cluster) {
current_dir_index = 0;
}
if (start_cluster == volume->current_dir[current_dir_index].directory.start_cluster) {
return -1;
result = -1;
}
return 0;
return result;
}
s32 PFVOL_SetCurrentDir(PFVOL_VOLUME* volume, PFVOL_DIR_ENTRY* directory) {
@@ -824,13 +825,15 @@ s32 PFVOL_SetCurrentDir(PFVOL_VOLUME* volume, PFVOL_DIR_ENTRY* directory) {
}
}
if (current_dir_index == 4) {
for (context_index = 0; context_index < 3; context_index++) {
pf_vol_set.context[context_index].stat &= 1;
if (pf_vol_set.context[context_index].stat != 0 &&
pf_vol_set.context[context_index].context_id == context_id) {
context_registered = 1;
break;
}
if (((pf_vol_set.context[0].stat &= 1) != 0 &&
context_id == pf_vol_set.context[0].context_id) ||
((pf_vol_set.context[1].stat &= 1) != 0 &&
context_id == pf_vol_set.context[1].context_id) ||
((pf_vol_set.context[2].stat &= 1) != 0 &&
context_id == pf_vol_set.context[2].context_id)) {
context_registered = 1;
} else {
context_registered = 0;
}
if (context_registered != 0) {
for (current_dir_index = 1; current_dir_index < 4; current_dir_index++) {
@@ -865,13 +868,15 @@ s32 PFVOL_GetCurrentDir(PFVOL_VOLUME* volume, PFVOL_DIR_ENTRY* directory) {
}
}
if (current_dir_index == 4) {
for (context_index = 0; context_index < 3; context_index++) {
pf_vol_set.context[context_index].stat &= 1;
if (pf_vol_set.context[context_index].stat != 0 &&
pf_vol_set.context[context_index].context_id == context_id) {
context_registered = 1;
break;
}
if (((pf_vol_set.context[0].stat &= 1) != 0 &&
context_id == pf_vol_set.context[0].context_id) ||
((pf_vol_set.context[1].stat &= 1) != 0 &&
context_id == pf_vol_set.context[1].context_id) ||
((pf_vol_set.context[2].stat &= 1) != 0 &&
context_id == pf_vol_set.context[2].context_id)) {
context_registered = 1;
} else {
context_registered = 0;
}
if (context_registered != 0) {
for (current_dir_index = 1; current_dir_index < 4; current_dir_index++) {

1476
libs/RVL_SDK/src/nup/nup.cpp Normal file

File diff suppressed because it is too large Load Diff

1473
libs/RVL_SDK/src/vi/vi.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,182 @@
#ifndef PRIVATE_NHTTP_H
#define PRIVATE_NHTTP_H
#include <revolution/nhttp.h>
#include <revolution/os.h>
#include <revolution/ssl.h>
#define STR_POSTBOUND "--t9Sf4yfjf1RtvDu3AA"
#define LEN_POSTBOUND 18
#define LEN_URLBUF 256
#define MIN(AA, BB) (((AA) > (BB)) ? (BB) : (AA))
typedef struct NHTTPBgnEndInfo NHTTPBgnEndInfo;
typedef struct NHTTPRequestInfo NHTTPRequestInfo;
#define NHTTP_CONN_RECVBUF_SIZE 0x8000
typedef struct NHTTPConnectionInfo NHTTPConnectionInfo;
typedef enum NHTTPConnectionEvent
{
NHTTP_EVENT_NONE,
NHTTP_EVENT_POST_SEND,
NHTTP_EVENT_BODY_RECV_FULL,
NHTTP_EVENT_BODY_RECV_DONE,
NHTTP_EVENT_COMPLETE,
NHTTP_CALLBACK_EVENT_MAX,
} NHTTPConnectionEvent;
typedef s32 (*NHTTPConnectionCallback)(NHTTPConnectionInfo* connection,
NHTTPConnectionEvent event, void* arg);
typedef struct NHTTPConnectionCallbackParam
{
void* value;
u32 _unk4;
u32 _unk8;
u32 _unkC;
} NHTTPConnectionCallbackParam;
typedef struct NHTTPPostSendArg
{
const char* label;
char* buf;
u32 size;
u32 offset;
} NHTTPPostSendArg;
typedef struct NHTTPBodyBufArg
{
char* buf;
u32 size;
u32 offset;
} NHTTPBodyBufArg;
typedef struct NHTTPHeader
{
struct NHTTPHeader* next;
struct NHTTPHeader* prev;
char* name;
char* value;
u32 length;
u32 _unk14;
} NHTTPHeader;
typedef struct NHTTPReqQueue
{
struct NHTTPReqQueue* next;
struct NHTTPReqQueue* prev;
s32 requestId;
NHTTPRequestInfo* volatile request;
s32 _unk10;
} NHTTPReqQueue;
typedef struct NHTTPListInfo
{
NHTTPReqQueue* reqQueue;
s32 nextRequestId;
} NHTTPListInfo;
typedef struct NHTTPReqInfo
{
NHTTPReqQueue* reqQueue;
} NHTTPReqInfo;
typedef struct NHTTPi_HDRBUFLIST
{
struct NHTTPi_HDRBUFLIST* next_p;
u8 block[NHTTP_HDRRECVBUF_BLOCKLEN];
} NHTTPi_HDRBUFLIST;
typedef struct NHTTPResponseInfo
{
volatile s32 headerLen;
volatile s32 bodyLen;
volatile s32 totalBodyLen;
volatile s32 contentLength;
s32 isSuccess;
s32 isHeaderParse;
s32 httpStatus;
u32 recvBufLen;
char* allHeader_p;
char* foundHeader_p;
char* recvBuf_p;
NHTTPResponseCallback bufFull;
NHTTPResponseCleanup freeBuf;
NHTTPi_HDRBUFLIST* hdrBufBlock_p;
u8 hdrBufFirst[NHTTP_HDRRECVBUF_INILEN];
void* param_p;
} NHTTPResponseInfo;
struct NHTTPRequestInfo
{
BOOL cancel;
s32 state;
BOOL secure;
BOOL proxyEnabled;
BOOL isRawData;
s32 hostEnd;
s32 pathStart;
s32 method;
u32 port;
char* url;
char* host;
NHTTPResponseInfo* response;
NHTTPHeader* headers;
NHTTPHeader* postData;
char multipartBoundary[LEN_POSTBOUND + 2];
char authorization[0x5C];
s32 authorizationLength;
SSLId sslId;
const char* clientCertData;
u32 clientCertSize;
const char* privateKeyData;
u32 privateKeySize;
const char* rootCAData;
u32 rootCASize;
BOOL clientCertDefault;
u32 verifyOption;
NHTTPEncodingType encodingType;
void* _unkD4;
u32 builtinRootCA;
u32 builtinClientCert;
char proxyServer[0x100];
u32 proxyPort;
char proxyAuthorization[0x5C];
s32 proxyAuthorizationLength;
u32 recvBufferSize;
const void* postBuffer;
u32 postBufferSize;
void* _unk250;
};
struct NHTTPConnectionInfo
{
BOOL started;
s32 state;
s32 sslError;
u32 _unkC;
NHTTPRequestInfo* request;
NHTTPResponseInfo* response;
s32 requestId;
NHTTPConnectionCallback callback;
NHTTPConnectionInfo* next;
u32 _unk24;
u32 _unk28;
u32 virtualContentLength;
NHTTPReqCallback requestCallback;
u32 _unk34;
u32 _unk38;
u32 _unk3C;
u8 recvBuf[0x8000];
u32 recvBufOffset;
u32 recvBufDataLen;
u32 _unk8048;
u32 _unk804C;
u32 _unk8050;
u32 _unk8054;
u32 _unk8058;
u32 _unk805C;
};
#endif // PRIVATE_NHTTP_H

View File

@@ -21,10 +21,27 @@ typedef struct NWC24MsgObjPrivate {
u32 type; // 0x04
u32 length; // 0x08
u32 appId; // 0x0C
#if defined(NWC24_MBOX_CTRL) || defined(NWC24_MSG_COMMIT)
u32 unk_0x10;
#else
u8 unk_0x10[0x4];
#endif
u32 tag; // 0x14
u32 ledPattern; // 0x18
#if defined(NWC24_MBOX_CTRL) || defined(NWC24_MSG_COMMIT)
u32 unk_0x1C;
#endif
#if defined(NWC24_MBOX_CTRL) || defined(NWC24_MSG_COMMIT)
union {
NWC24UserId fromId;
#ifdef NWC24_MSG_COMMIT
NWC24Data fromAddr;
#endif
struct { u32 fromIdHigh, fromIdLow; };
};
#else
NWC24UserId fromId; // 0x20
#endif
u32 unk_0x28;
u32 unk_0x2C;
NWC24Data unk_0x30;

View File

@@ -1,4 +1,3 @@
#ifndef REVOLUTION_NHTTP_H
#define REVOLUTION_NHTTP_H
@@ -6,49 +5,80 @@
#include <revolution/nhttp/nhttp_err.h>
#define NHTTP_HDRRECVBUF_INILEN 1024
#define NHTTP_HDRRECVBUF_BLOCKSHIFT 9
#define NHTTP_HDRRECVBUF_BLOCKLEN (1 << NHTTP_HDRRECVBUF_BLOCKSHIFT)
#define NHTTP_HDRRECVBUF_BLOCKMASK (NHTTP_HDRRECVBUF_BLOCKLEN - 1)
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct {
u8 dummy[1];
} NHTTPRequest;
typedef struct {
u8 dummy[1];
} NHTTPResponse;
typedef int NHTTPConnection;
typedef void* (*NHTTPAlloc)(u32 size, int align);
typedef void (*NHTTPFree)(void* buf);
typedef void (*NHTTPRequestCallback)(int, NHTTPResponse*);
typedef void (*NHTTPCleanupCallback)();
int NHTTPStartup(NHTTPAlloc alloc, NHTTPFree free, u32 priority);
int NHTTPCleanupAsync(NHTTPCleanupCallback);
int NHTTPGetError();
typedef struct NHTTPRequestInfo NHTTPRequest;
typedef struct NHTTPResponseInfo NHTTPResponse;
typedef s32 NHTTPConnection;
NHTTPRequest* NHTTPCreateRequest(char* url, undefined4, void* buf, u32 bufSize, NHTTPRequestCallback reqCallback, undefined4);
NHTTPRequest* NHTTPCreateRequestEx(char* url, undefined4, void* buf, u32 bufSize, NHTTPRequestCallback reqCallback, undefined4, undefined4,
undefined4);
int NHTTPDeleteRequest(NHTTPRequest* request);
typedef enum NHTTPReqMethod {
NHTTP_REQMETHOD_GET,
NHTTP_REQMETHOD_POST,
NHTTP_REQMETHOD_HEAD,
} NHTTPReqMethod;
typedef enum NHTTPEncodingType {
NHTTP_ENCODING_TYPE_AUTO,
NHTTP_ENCODING_TYPE_URL,
NHTTP_ENCODING_TYPE_MULTIPART,
NHTTP_ENCODING_TYPE_MAX,
} NHTTPEncodingType;
typedef void (*NHTTPReqCallback)();
typedef void* (*NHTTPResponseCallback)(void** buffer, void* data,
u32 contentLength, NHTTPAlloc alloc,
NHTTPFree free, void* userParam);
typedef void (*NHTTPResponseCleanup)(void* buffer, NHTTPFree free,
void* userParam);
s32 NHTTPStartup(NHTTPAlloc alloc, NHTTPFree free, u32 priority);
void NHTTPCleanupAsync(NHTTPCleanupCallback callback);
s32 NHTTPGetError(void);
NHTTPRequest* NHTTPCreateRequest(const char* url, NHTTPReqMethod method,
void* buffer, u32 bufferSize,
NHTTPReqCallback callback, void* userParam);
NHTTPRequest* NHTTPCreateRequestEx(const char* url, NHTTPReqMethod method,
void* buffer, u32 bufferSize,
NHTTPReqCallback callback, void* userParam,
NHTTPResponseCallback responseCallback,
NHTTPResponseCleanup cleanup);
s32 NHTTPAddHeaderField(NHTTPRequest* request, const char* name,
const char* value);
s32 NHTTPAddPostDataRaw(NHTTPRequest* request, const void* data,
u32 size, const char* label);
s32 NHTTPDeleteRequest(NHTTPRequest* request);
NHTTPConnection NHTTPSendRequestAsync(NHTTPRequest* request);
int NHTTPCancelRequestAsync(NHTTPConnection connection);
s32 NHTTPCancelRequestAsync(NHTTPConnection connection);
void NHTTPGetProgress(u32* complete, u32* total);
s32 NHTTPGetProgress(u32* complete, u32* total);
int NHTTPDestroyResponse(NHTTPResponse* response);
u32 NHTTPGetHeaderField(NHTTPResponse* response, const char* name, const char** value);
void NHTTPDestroyResponse(NHTTPResponse* response);
s32 NHTTPGetHeaderAll(NHTTPResponse* response, const char** header);
s32 NHTTPGetHeaderField(NHTTPResponse* response, const char* name,
const char** value);
int NHTTPGetResultCode(NHTTPResponse* res);
s32 NHTTPGetBodyAll(NHTTPResponse* response, void** buffer);
s32 NHTTPGetResultCode(NHTTPResponse* response);
int NHTTPSetVerifyOption(NHTTPRequest* request, u32 option);
int NHTTPSetProxyDefault(NHTTPRequest* request);
int NHTTPSetRootCADefault(NHTTPRequest* request);
int NHTTPSetClientCertDefault(NHTTPRequest* request);
s32 NHTTPSetVerifyOption(NHTTPRequest* request, u32 option);
s32 NHTTPSetProxy(NHTTPRequest* request, const char* server, u16 port,
const char* username, const char* password);
s32 NHTTPSetProxyDefault(NHTTPRequest* request);
s32 NHTTPSetClientCertDefault(NHTTPRequest* request);
s32 NHTTPSetRootCADefault(NHTTPRequest* request);
#ifdef __cplusplus
}

View File

@@ -102,13 +102,16 @@ struct SOAddrInfo {
SOAddrInfo* next; // 0x20
};
#define SO_ENOTCONN -56
int SOSocket(int pf, int type, int protocol);
int __SOCreateSocket(int pf, int type, int protocol);
int SOClose(int s);
int SOConnect(int s, void* sockAddr);
int SORecv(int s, void* buf, int len, int flags);
int SOSend(int s, void* buf, int len, int flags);
int SOSend(int s, const void* buf, int len, int flags);
int SOFcntl(int s, int cmd, ...);
int SOShutdown(int s, int how);

View File

@@ -14,6 +14,7 @@ typedef struct IPAddrEntry {
} IPAddrEntry;
int SOGetInterfaceOpt(void* unk, int level, int optname, void* optval, int* optlen);
int SOSetSockOpt(int s, int level, int optname, const void* optval, int optlen);
#ifdef __cplusplus
}

View File

@@ -0,0 +1,179 @@
#include <revolution/nhttp.h>
#include <revolution/ncd.h>
#include <revolution/os.h>
#include <stdio.h>
int SOClose(int s);
typedef struct NHTTPBgnEndInfo
{
NCDIpConfig ipConfig;
NHTTPAlloc alloc;
NHTTPFree free;
BOOL started;
s32 socket;
s32 sslError;
NHTTPErr error;
u32 _unk7DC;
void* threadStack;
u32 _unk7E4;
} NHTTPBgnEndInfo;
NHTTPBgnEndInfo* NHTTPi_GetSystemInfoP(void);
NHTTPBgnEndInfo* NHTTPi_GetBgnEndInfoP(void* systemInfo);
void* NHTTPi_GetListInfoP(void* systemInfo);
void* NHTTPi_GetReqInfoP(void* systemInfo);
void* NHTTPi_GetMutexInfoP(void* systemInfo);
void* NHTTPi_GetThreadInfoP(void* systemInfo);
void NHTTPi_InitListInfo(void* listInfo);
void NHTTPi_InitRequestInfo(void* reqInfo);
void NHTTPi_initLockReqList(void* mutexInfo);
void NHTTPi_exitLockReqList(void);
BOOL NHTTPi_createCommThread(void* threadInfo, u32 priority, void* stack);
void NHTTPi_destroyCommThread(void* threadInfo, NHTTPBgnEndInfo* bgnEndInfo);
void NHTTPi_CheckCurrentThread(void* threadInfo, BOOL allowCommThread);
void NHTTPi_cancelAllRequests(void* systemInfo);
int NHTTPi_GetConnectionListLength(void);
void NHTTPi_InitConnectionList(void);
void NHTTPi_InitBgnEndInfo(NHTTPBgnEndInfo* info)
{
info->sslError = 0;
info->error = NHTTP_ERROR_NONE;
info->alloc = NULL;
info->free = NULL;
info->started = FALSE;
info->socket = -1;
info->_unk7DC = 0;
info->threadStack = NULL;
info->_unk7E4 = 0;
}
void* NHTTPi_alloc(u32 size, int align)
{
NHTTPBgnEndInfo* info = NHTTPi_GetSystemInfoP();
if (info->alloc != NULL)
{
return info->alloc(size, align);
}
return NULL;
}
void NHTTPi_free(void* buf)
{
NHTTPBgnEndInfo* info = NHTTPi_GetSystemInfoP();
if (info->free != NULL)
{
info->free(buf);
}
}
void NHTTPi_SetError(NHTTPBgnEndInfo* info, NHTTPErr error)
{
info->error = error;
}
void NHTTPi_SetSSLError(NHTTPBgnEndInfo* info, s32 error)
{
info->sslError = error;
}
s32 NHTTPi_GetSSLError(NHTTPBgnEndInfo* info)
{
return info->sslError;
}
BOOL NHTTPi_Startup(void* systemInfo, NHTTPAlloc alloc, NHTTPFree free,
u32 priority)
{
NHTTPBgnEndInfo* bgnEndInfo = NHTTPi_GetBgnEndInfoP(systemInfo);
void* listInfo = NHTTPi_GetListInfoP(systemInfo);
void* reqInfo = NHTTPi_GetReqInfoP(systemInfo);
void* mutexInfo = NHTTPi_GetMutexInfoP(systemInfo);
void* threadInfo = NHTTPi_GetThreadInfoP(systemInfo);
void* stack;
NCDErr result;
bgnEndInfo->alloc = alloc;
bgnEndInfo->free = free;
bgnEndInfo->error = NHTTP_ERROR_NONE;
bgnEndInfo->sslError = 0;
bgnEndInfo->_unk7DC = 0;
NHTTPi_InitListInfo(listInfo);
NHTTPi_InitRequestInfo(reqInfo);
NHTTPi_initLockReqList(mutexInfo);
NHTTPi_InitConnectionList();
bgnEndInfo->socket = -1;
stack = NHTTPi_alloc(0x2000, 8);
bgnEndInfo->threadStack = stack;
if (stack == NULL)
{
bgnEndInfo->error = NHTTP_ERROR_ALLOC;
NHTTPi_exitLockReqList();
return FALSE;
}
if (!NHTTPi_createCommThread(threadInfo, priority, stack))
{
bgnEndInfo->error = NHTTP_ERROR_REVOLUTIONSDK;
NHTTPi_free(bgnEndInfo->threadStack);
bgnEndInfo->threadStack = NULL;
NHTTPi_exitLockReqList();
return FALSE;
}
result = NCDGetCurrentIpConfig(&bgnEndInfo->ipConfig);
if (result < 0)
{
OSReport("NCDGetCurrentIpConfig err = %d\n", result);
OSPanic("NHTTP_bgnend.c", 230, "NCDGetCurrentIpConfig");
}
bgnEndInfo->started = TRUE;
return TRUE;
}
void NHTTPi_CleanupAsync(void* systemInfo, NHTTPCleanupCallback callback)
{
NHTTPBgnEndInfo* bgnEndInfo = NHTTPi_GetBgnEndInfoP(systemInfo);
void* threadInfo = NHTTPi_GetThreadInfoP(systemInfo);
int connectionCount;
NHTTPi_CheckCurrentThread(threadInfo, TRUE);
NHTTPi_cancelAllRequests(systemInfo);
NHTTPi_destroyCommThread(threadInfo, bgnEndInfo);
NHTTPi_free(bgnEndInfo->threadStack);
bgnEndInfo->threadStack = NULL;
NHTTPi_exitLockReqList();
bgnEndInfo->started = FALSE;
if (callback != NULL)
{
callback();
}
connectionCount = NHTTPi_GetConnectionListLength();
if (connectionCount != 0)
{
printf("*warning: %d connections rests! Please free connections.\n",
connectionCount);
}
if (bgnEndInfo->socket >= 0)
{
SOClose(bgnEndInfo->socket);
bgnEndInfo->socket = -1;
}
}
s32 NHTTPi_GetError(NHTTPBgnEndInfo* info)
{
return info->error;
}

View File

@@ -0,0 +1,102 @@
#include <private/nhttp.h>
#include <stdio.h>
s32 NHTTPi_compareToken(const char* lhs, const char* rhs);
void* NHTTPi_alloc(u32 size, int align);
void NHTTPi_SetError(NHTTPBgnEndInfo* info, NHTTPErr error);
static BOOL addHdrList(NHTTPHeader** list, NHTTPBgnEndInfo* info, char* name,
char* value)
{
BOOL found = FALSE;
NHTTPHeader* header = *list;
if (header != NULL)
{
if (NHTTPi_compareToken(name, header->name) != 0)
{
header = header->prev;
while (header != *list)
{
if (NHTTPi_compareToken(name, header->name) == 0)
{
found = TRUE;
break;
}
header = header->prev;
}
}
else
{
found = TRUE;
}
}
if (found)
{
header->value = value;
}
else
{
header = NHTTPi_alloc(sizeof(NHTTPHeader), 4);
if (header == NULL)
{
printf("failed to allocate memory\n");
NHTTPi_SetError(info, NHTTP_ERROR_ALLOC);
return FALSE;
}
header->name = name;
header->value = value;
header->length = 0;
header->_unk14 = 0;
if (*list != NULL)
{
header->next = (*list)->next;
header->prev = *list;
(*list)->next->prev = header;
(*list)->next = header;
}
else
{
header->prev = header;
header->next = header;
*list = header;
}
}
return TRUE;
}
NHTTPHeader* NHTTPi_getHdrFromList(NHTTPHeader** list)
{
NHTTPHeader* header = *list;
if (header != NULL)
{
if (header != header->next)
{
header->next->prev = header->prev;
header->prev->next = header->next;
*list = header->prev;
}
else
{
*list = NULL;
}
}
return header;
}
BOOL NHTTP_AddHeaderField(NHTTPRequestInfo* request, NHTTPBgnEndInfo* info,
char* name, char* value)
{
if (request->state != 0)
{
return FALSE;
}
return addHdrList(&request->headers, info, name, value);
}

View File

@@ -0,0 +1,126 @@
#include <private/nhttp.h>
void* NHTTPi_alloc(u32 size, int align);
void NHTTPi_free(void* ptr);
NHTTPConnectionInfo* NHTTPi_Request2Connection(void* mutexInfo,
NHTTPRequestInfo* request);
void NHTTPi_destroyRequestObject(void* mutexInfo, NHTTPRequestInfo* request);
void NHTTPi_CompleteCallback(void* mutexInfo, NHTTPConnectionInfo* connection);
NHTTPHeader* NHTTPi_getHdrFromList(NHTTPHeader** list);
void NHTTPi_InitListInfo(NHTTPListInfo* info)
{
info->reqQueue = NULL;
info->nextRequestId = 0;
}
s32 NHTTPi_setReqQueue(NHTTPListInfo* info, NHTTPRequestInfo* request)
{
s32 requestId = -1;
NHTTPReqQueue* queue = NHTTPi_alloc(sizeof(NHTTPReqQueue), 4);
if (queue != NULL)
{
if (info->reqQueue != NULL)
{
queue->next = info->reqQueue->next;
queue->prev = info->reqQueue;
info->reqQueue->next->prev = queue;
info->reqQueue->next = queue;
}
else
{
queue->next = queue;
queue->prev = queue;
info->reqQueue = queue;
}
queue->requestId = info->nextRequestId++;
queue->request = request;
queue->_unk10 = -1;
requestId = queue->requestId;
if (info->nextRequestId < 0)
{
info->nextRequestId = 0;
}
}
return requestId;
}
BOOL NHTTPi_freeReqQueue(NHTTPListInfo* info, void* mutexInfo, s32 requestId)
{
NHTTPReqQueue* current;
NHTTPReqQueue* queue = info->reqQueue;
NHTTPReqQueue* found = NULL;
BOOL result = FALSE;
if (queue != NULL)
{
if (queue->requestId == requestId)
{
found = queue;
}
else
{
current = queue->prev;
while (current != queue)
{
if (current->requestId == requestId)
{
found = current;
break;
}
current = current->prev;
}
}
}
if (found != NULL)
{
NHTTPConnectionInfo* connection;
if (queue != queue->next)
{
found->next->prev = found->prev;
found->prev->next = found->next;
if (info->reqQueue == found)
{
info->reqQueue = found->prev;
}
}
else
{
info->reqQueue = NULL;
}
connection = NHTTPi_Request2Connection(mutexInfo, found->request);
NHTTPi_destroyRequestObject(mutexInfo, found->request);
NHTTPi_free(found);
if (connection != NULL)
{
connection->state = 8;
NHTTPi_CompleteCallback(mutexInfo, connection);
}
result = TRUE;
}
return result;
}
void NHTTPi_allFreeReqQueue(NHTTPListInfo* info, void* mutexInfo)
{
while (info->reqQueue != NULL)
{
NHTTPi_freeReqQueue(info, mutexInfo, info->reqQueue->requestId);
}
}
NHTTPReqQueue* NHTTPi_getReqFromReqQueue(NHTTPReqQueue** queue)
{
return (NHTTPReqQueue*)NHTTPi_getHdrFromList((NHTTPHeader**)queue);
}

View File

@@ -0,0 +1,120 @@
#include <revolution/nhttp.h>
#include <revolution/ncd.h>
#include <revolution/os.h>
typedef struct NHTTPMutexInfo
{
OSMutex mutex;
BOOL initialized;
} NHTTPMutexInfo;
typedef struct NHTTPBgnEndInfo
{
NCDIpConfig ipConfig;
NHTTPAlloc alloc;
NHTTPFree free;
BOOL started;
s32 socket;
s32 sslError;
NHTTPErr error;
u32 _unk7DC;
void* threadStack;
u32 _unk7E4;
} NHTTPBgnEndInfo;
typedef struct NHTTPThreadInfo
{
OSMessageQueue messageQueue;
OSMessage messages[3];
OSThread thread;
BOOL isCreateCommThreadMessageQueue;
u8 _unk34C[0x14];
char commBuf[0x100];
} NHTTPThreadInfo;
BOOL NHTTPi_IsCreateCommThreadMessageQueue(NHTTPThreadInfo* info);
void NHTTPi_IsCreateCommThreadMessageQueueOn(NHTTPThreadInfo* info);
void NHTTPi_CommThreadProcMain(void* argument);
void NHTTPi_InitMutexInfo(NHTTPMutexInfo* info)
{
info->initialized = FALSE;
}
void NHTTPi_initLockReqList(NHTTPMutexInfo* info)
{
if (!info->initialized)
{
OSInitMutex(&info->mutex);
info->initialized = TRUE;
}
}
void NHTTPi_exitLockReqList(void)
{
}
void NHTTPi_lockReqList(NHTTPMutexInfo* info)
{
OSLockMutex(&info->mutex);
}
void NHTTPi_unlockReqList(NHTTPMutexInfo* info)
{
OSUnlockMutex(&info->mutex);
}
void* NHTTPi_CommThreadProc(void* argument);
BOOL NHTTPi_createCommThread(NHTTPThreadInfo* info, s32 priority, void* stack)
{
if (!NHTTPi_IsCreateCommThreadMessageQueue(info))
{
OSInitMessageQueue(&info->messageQueue, info->messages, 3);
NHTTPi_IsCreateCommThreadMessageQueueOn(info);
}
OSCreateThread(&info->thread, NHTTPi_CommThreadProc, NULL, (u8*)stack + 0x2000, 0x2000, priority, 0);
OSResumeThread(&info->thread);
return TRUE;
}
void NHTTPi_destroyCommThread(NHTTPThreadInfo* info, NHTTPBgnEndInfo* bgnEndInfo)
{
bgnEndInfo->_unk7DC = 1;
OSSendMessage(&info->messageQueue, NULL, 0);
OSJoinThread(&info->thread, NULL);
}
void NHTTPi_idleCommThread(NHTTPThreadInfo* info)
{
OSMessage message;
OSReceiveMessage(&info->messageQueue, &message, OS_MESSAGE_BLOCK);
}
void NHTTPi_kickCommThread(NHTTPThreadInfo* info)
{
OSSendMessage(&info->messageQueue, NULL, 0);
}
void NHTTPi_CheckCurrentThread(NHTTPThreadInfo* info, BOOL notCommThread)
{
OSThread* current = OSGetCurrentThread();
OSThread* commThread = &info->thread;
if (current != NULL
&& ((!notCommThread && current != commThread)
|| (notCommThread && current == commThread)))
{
OSReport("%s:illegal thread\n", __FUNCTION__);
OSPanic(__FILE__, 223, "halt\n");
}
}
void* NHTTPi_CommThreadProc(void* argument)
{
NHTTPi_CommThreadProcMain(argument);
return NULL;
}

View File

@@ -0,0 +1,487 @@
#include <private/nhttp.h>
const char NHTTPi_strMultipartBound[] = STR_POSTBOUND;
void* NHTTPi_alloc(u32 size, int align);
void NHTTPi_free(void* ptr);
void NHTTPi_SetError(NHTTPBgnEndInfo* info, NHTTPErr error);
void* NHTTPi_memclr(void* destination, u32 size);
s32 NHTTPi_strlen(const char* string);
void* NHTTPi_memcpy(void* destination, const void* source, u32 size);
s32 NHTTPi_strnicmp(const char* left, const char* right, s32 size);
s32 NHTTPi_strToHex(const char* string, s32 length);
s32 NHTTPi_strtonum(const char* string, s32 length);
NHTTPBgnEndInfo* NHTTPi_GetBgnEndInfoP(void* systemInfo);
NHTTPListInfo* NHTTPi_GetListInfoP(void* systemInfo);
NHTTPReqInfo* NHTTPi_GetReqInfoP(void* systemInfo);
void* NHTTPi_GetMutexInfoP(void* systemInfo);
void* NHTTPi_GetThreadInfoP(void* systemInfo);
NHTTPConnectionInfo* NHTTPi_Request2Connection(void* mutexInfo,
NHTTPRequestInfo* request);
void NHTTPi_lockReqList(void* mutexInfo);
void NHTTPi_unlockReqList(void* mutexInfo);
s32 NHTTPi_setReqQueue(NHTTPListInfo* listInfo, NHTTPRequestInfo* request);
void NHTTPi_kickCommThread(void* threadInfo);
void NHTTPi_SocCancel(void* mutexInfo, NHTTPRequestInfo* request, s32 socket);
BOOL NHTTPi_freeReqQueue(NHTTPListInfo* listInfo, void* mutexInfo,
s32 requestId);
void NHTTPi_allFreeReqQueue(NHTTPListInfo* listInfo, void* mutexInfo);
void NHTTPi_InitRequestInfo(NHTTPReqInfo* info)
{
info->reqQueue = NULL;
}
NHTTPRequestInfo* NHTTP_CreateRequest(NHTTPBgnEndInfo* bgnEndInfo_p,
const char* url_p, s32 method, void* buf_p, u32 len, void* param_p,
NHTTPResponseCallback bufFull, NHTTPResponseCleanup freeBuf)
{
int i;
int suflen, urllen, prelen;
int nhostenc, deccount;
int declen, hostend;
int port;
int decode_urllen;
char a_url[LEN_URLBUF];
char* prefix_p;
NHTTPRequestInfo* req_p = NULL;
if (method >= 3 || method < 0)
{
NHTTPi_SetError(bgnEndInfo_p, NHTTP_ERROR_UNKNOWN);
goto errend;
}
req_p = NHTTPi_alloc(sizeof(NHTTPRequestInfo), 4);
if (!req_p)
{
NHTTPi_SetError(bgnEndInfo_p, NHTTP_ERROR_ALLOC);
goto errend;
}
NHTTPi_memclr(req_p, sizeof(NHTTPRequestInfo));
req_p->response = NHTTPi_alloc(sizeof(NHTTPResponseInfo), 4);
if (!req_p->response)
{
NHTTPi_SetError(bgnEndInfo_p, NHTTP_ERROR_ALLOC);
goto errend;
}
NHTTPi_memclr(req_p->response, sizeof(NHTTPResponseInfo));
req_p->response->recvBuf_p = buf_p;
req_p->response->recvBufLen = len;
req_p->response->bufFull = bufFull;
req_p->response->freeBuf = freeBuf;
urllen = NHTTPi_strlen(url_p);
if (urllen <= 7)
{
NHTTPi_SetError(bgnEndInfo_p, NHTTP_ERROR_DNS);
goto errend;
}
NHTTPi_memclr(a_url, urllen);
NHTTPi_memcpy(a_url, url_p, urllen);
req_p->port = 80;
suflen = 7;
if (NHTTPi_strnicmp(a_url, "http://", 7) != 0)
{
if (NHTTPi_strnicmp(a_url, "https://", 8) != 0)
{
NHTTPi_SetError(bgnEndInfo_p, NHTTP_ERROR_DNS);
goto errend;
}
req_p->secure = TRUE;
req_p->port = 443;
suflen = 8;
}
prefix_p = a_url + suflen;
prelen = urllen - suflen;
if (prelen <= 0)
{
NHTTPi_SetError(bgnEndInfo_p, NHTTP_ERROR_DNS);
goto errend;
}
for (i = 0, nhostenc = 0, deccount = 0;
(i < prelen) && (prefix_p[i] != '/'); i++)
{
if (deccount == 2)
{
deccount--;
}
else if (deccount == 1)
{
s8 c = (s8)NHTTPi_strToHex(&prefix_p[i - 1], 2);
deccount--;
if (c < 0)
{
NHTTPi_SetError(bgnEndInfo_p, NHTTP_ERROR_DNS);
goto errend;
}
if (c == '/')
{
nhostenc--;
break;
}
}
else if (prefix_p[i] == '%')
{
deccount = 2;
nhostenc++;
}
}
if (deccount)
{
NHTTPi_SetError(bgnEndInfo_p, NHTTP_ERROR_DNS);
goto errend;
}
decode_urllen = suflen + prelen - nhostenc * 2 + 1;
req_p->url = NHTTPi_alloc(decode_urllen, 4);
if (!req_p->url)
{
NHTTPi_SetError(bgnEndInfo_p, NHTTP_ERROR_ALLOC);
goto errend;
}
NHTTPi_memclr(req_p->url, decode_urllen);
NHTTPi_memcpy(req_p->url, a_url, suflen);
for (i = 0, declen = 0, deccount = 0, hostend = FALSE;
i < prelen; i++)
{
if (deccount == 2)
{
deccount--;
}
else if (deccount == 1)
{
char c = (char)NHTTPi_strToHex(&prefix_p[i - 1], 2);
deccount--;
req_p->url[suflen + declen - 1] = c;
if (c == '/')
{
hostend = TRUE;
}
}
else
{
if (prefix_p[i] == '/')
{
hostend = TRUE;
}
if (!hostend & (prefix_p[i] == '%'))
{
deccount = 2;
}
else
{
req_p->url[suflen + declen] = prefix_p[i];
}
declen++;
}
}
req_p->url[suflen + declen] = 0;
prefix_p = &req_p->url[suflen];
prelen = declen;
for (i = 0; i < prelen; i++)
{
if ((prefix_p[i] == '/') || (prefix_p[i] == ':'))
{
req_p->hostEnd = i + suflen;
break;
}
}
if (i == prelen)
{
req_p->pathStart = req_p->hostEnd = i + suflen;
}
else if (prefix_p[i] == '/')
{
req_p->pathStart = req_p->hostEnd;
}
else if (prefix_p[i] == ':')
{
for (; i < prelen; i++)
{
if (prefix_p[i] == '/')
{
req_p->pathStart = i + suflen;
break;
}
}
if (i == prelen)
{
req_p->pathStart = i + suflen;
}
else
{
port = NHTTPi_strtonum(&req_p->url[req_p->hostEnd + 1],
(int)(req_p->pathStart - (req_p->hostEnd + 1)));
if (port < 0)
{
port = req_p->port;
}
else if (port > 65535)
{
NHTTPi_SetError(bgnEndInfo_p, NHTTP_ERROR_DNS);
goto errend;
}
req_p->port = (u16)port;
}
}
{
u32 a_hostnameLen = (u32)(req_p->hostEnd - (req_p->secure ? 8 : 7));
req_p->host = NHTTPi_alloc(a_hostnameLen + 1, 4);
if (!req_p->host)
{
NHTTPi_SetError(bgnEndInfo_p, NHTTP_ERROR_ALLOC);
goto errend;
}
NHTTPi_memclr(req_p->host, (int)(a_hostnameLen + 1));
NHTTPi_memcpy(req_p->host,
req_p->url + (req_p->secure ? 8 : 7), (int)a_hostnameLen);
}
NHTTPi_memcpy(req_p->multipartBoundary, NHTTPi_strMultipartBound,
sizeof(req_p->multipartBoundary));
req_p->method = method;
req_p->sslId = 0;
req_p->clientCertData = NULL;
req_p->clientCertSize = 0;
req_p->privateKeyData = NULL;
req_p->privateKeySize = 0;
req_p->rootCAData = NULL;
req_p->rootCASize = 0;
req_p->clientCertDefault = FALSE;
req_p->verifyOption = 0;
req_p->_unkD4 = NULL;
req_p->response->param_p = param_p;
req_p->proxyEnabled = FALSE;
req_p->recvBufferSize = 0;
return req_p;
errend:
if (req_p)
{
if (req_p->url)
{
NHTTPi_free(req_p->url);
}
if (req_p->host)
{
NHTTPi_free(req_p->host);
}
if (req_p->response)
{
NHTTPi_free(req_p->response);
}
NHTTPi_free(req_p);
}
return NULL;
}
void NHTTP_DestroyRequest(void* systemInfo, NHTTPRequestInfo* request)
{
NHTTPConnectionInfo* connection;
NHTTPHeader* header;
NHTTPHeader* next;
NHTTPHeader* post;
NHTTPHeader* nextPost;
void* mutexInfo = NHTTPi_GetMutexInfoP(systemInfo);
connection = NHTTPi_Request2Connection(mutexInfo, request);
if (connection != NULL)
{
connection->response = NULL;
}
NHTTPi_free(request->response);
connection = NHTTPi_Request2Connection(mutexInfo, request);
if (connection != NULL)
{
connection->request = NULL;
}
header = request->headers;
while (header != NULL)
{
if (header != header->next)
{
next = header->next->next;
NHTTPi_free(header->next);
header->next = next;
}
else
{
NHTTPi_free(header);
header = NULL;
}
}
post = request->postData;
while (post != NULL)
{
if (post != post->next)
{
nextPost = post->next->next;
NHTTPi_free(post->next);
post->next = nextPost;
}
else
{
NHTTPi_free(post);
post = NULL;
}
}
NHTTPi_free(request->url);
NHTTPi_free(request->host);
NHTTPi_free(request);
}
BOOL NHTTPi_destroyRequestObject(void* mutexInfo, NHTTPRequestInfo* request)
{
NHTTPConnectionInfo* connection;
NHTTPHeader* header;
NHTTPHeader* next;
NHTTPHeader* post;
NHTTPHeader* nextPost;
connection = NHTTPi_Request2Connection(mutexInfo, request);
if (connection != NULL)
{
connection->request = NULL;
}
header = request->headers;
while (header != NULL)
{
if (header != header->next)
{
next = header->next->next;
NHTTPi_free(header->next);
header->next = next;
}
else
{
NHTTPi_free(header);
header = NULL;
}
}
post = request->postData;
while (post != NULL)
{
if (post != post->next)
{
nextPost = post->next->next;
NHTTPi_free(post->next);
post->next = nextPost;
}
else
{
NHTTPi_free(post);
post = NULL;
}
}
NHTTPi_free(request->url);
NHTTPi_free(request->host);
NHTTPi_free(request);
return TRUE;
}
s32 NHTTP_SendRequestAsync(void* systemInfo, NHTTPRequestInfo* request)
{
NHTTPBgnEndInfo* info = NHTTPi_GetBgnEndInfoP(systemInfo);
void* threadInfo = NHTTPi_GetThreadInfoP(systemInfo);
void* mutexInfo = NHTTPi_GetMutexInfoP(systemInfo);
s32 requestId;
if (request->state != 0)
{
NHTTPi_SetError(info, NHTTP_ERROR_UNKNOWN);
return -1;
}
NHTTPi_lockReqList(mutexInfo);
requestId = NHTTPi_setReqQueue(NHTTPi_GetListInfoP(systemInfo), request);
if (requestId >= 0)
{
request->state = 1;
NHTTPi_kickCommThread(threadInfo);
}
else
{
NHTTPi_SetError(info, NHTTP_ERROR_ALLOC);
}
NHTTPi_unlockReqList(mutexInfo);
return requestId;
}
BOOL NHTTP_CancelRequestAsync(void* sysInfo_p, s32 id)
{
BOOL rc = FALSE;
NHTTPReqInfo* reqInfo_p = NHTTPi_GetReqInfoP(sysInfo_p);
void* mutexInfo_p = NHTTPi_GetMutexInfoP(sysInfo_p);
volatile NHTTPReqQueue* reqCurrent_p = reqInfo_p->reqQueue;
NHTTPi_lockReqList(mutexInfo_p);
if (reqCurrent_p)
{
if (reqCurrent_p->requestId == id)
{
if (!reqCurrent_p->request->cancel)
{
reqCurrent_p->request->cancel = TRUE;
NHTTPi_SocCancel(mutexInfo_p, reqCurrent_p->request,
reqCurrent_p->_unk10);
rc = TRUE;
}
}
}
if (!rc)
{
NHTTPListInfo* listInfo_p = NHTTPi_GetListInfoP(sysInfo_p);
rc = NHTTPi_freeReqQueue(listInfo_p, mutexInfo_p, id);
}
NHTTPi_unlockReqList(mutexInfo_p);
return rc;
}
void NHTTPi_cancelAllRequests(void* sysInfo_p)
{
NHTTPReqInfo* reqInfo_p = NHTTPi_GetReqInfoP(sysInfo_p);
NHTTPListInfo* listInfo_p = NHTTPi_GetListInfoP(sysInfo_p);
void* mutexInfo_p = NHTTPi_GetMutexInfoP(sysInfo_p);
volatile NHTTPReqQueue* reqCurrent_p = reqInfo_p->reqQueue;
NHTTPi_lockReqList(mutexInfo_p);
if (reqCurrent_p)
{
if (!reqCurrent_p->request->cancel)
{
reqCurrent_p->request->cancel = TRUE;
NHTTPi_SocCancel(mutexInfo_p, reqCurrent_p->request,
reqCurrent_p->_unk10);
}
}
NHTTPi_allFreeReqQueue(listInfo_p, mutexInfo_p);
NHTTPi_unlockReqList(mutexInfo_p);
}

View File

@@ -0,0 +1,202 @@
#include <private/nhttp.h>
void* NHTTPi_alloc(u32 size, int align);
void NHTTPi_free(void* ptr);
void NHTTPi_SetError(NHTTPBgnEndInfo* info, NHTTPErr error);
s32 NHTTPi_loadFromHdrRecvBuf(NHTTPResponseInfo* res_p, char* dst, s32 pos,
s32 size);
s32 NHTTPi_strcmp(const char* lhs, const char* rhs);
s32 NHTTPi_getHeaderValue(const NHTTPResponseInfo* res_p, const char* label_p,
s32* pos_p);
NHTTPConnectionInfo* NHTTPi_Response2Connection(void* mutexInfo_p,
NHTTPResponseInfo* res_p);
s32 NHTTPi_findNextLineHdrRecvBuf(const NHTTPResponseInfo* res_p, s32 pos,
s32 limit, s32* colon_pos_p, s32* return_code_size_p);
s32 NHTTPi_compareTokenN_HdrRecvBuf(const NHTTPResponseInfo* res_p, s32 pos,
s32 limit, const char* str_p, s8 extdeli);
s32 NHTTPi_skipSpaceHdrRecvBuf(
const NHTTPResponseInfo* res_p, s32 pos, s32 limit);
void NHTTP_DestroyResponse(void* mutexInfo_p, NHTTPResponseInfo* res_p)
{
NHTTPi_HDRBUFLIST* list_p = NULL;
while (res_p->hdrBufBlock_p)
{
list_p = res_p->hdrBufBlock_p->next_p;
NHTTPi_free(res_p->hdrBufBlock_p);
res_p->hdrBufBlock_p = list_p;
}
if (res_p->allHeader_p)
{
NHTTPi_free(res_p->allHeader_p);
}
if (res_p->foundHeader_p)
{
NHTTPi_free(res_p->foundHeader_p);
}
if (res_p->freeBuf != NULL)
{
res_p->freeBuf(res_p->recvBuf_p, NHTTPi_free, res_p->param_p);
res_p->recvBuf_p = NULL;
res_p->recvBufLen = 0;
}
{
NHTTPConnectionInfo* connection_p =
NHTTPi_Response2Connection(mutexInfo_p, res_p);
if (connection_p != NULL)
{
connection_p->response = NULL;
}
}
NHTTPi_free(res_p);
}
s32 NHTTPi_getHeaderValue(const NHTTPResponseInfo* res_p, const char* label_p,
s32* pos_p)
{
s32 linetop, nextlinetop;
s32 labeltop, labelend;
s32 valuetop, valueend;
s32 return_code_size = 0;
linetop = NHTTPi_findNextLineHdrRecvBuf(
res_p, 12, res_p->headerLen, &labelend, &return_code_size);
while (linetop > 0)
{
nextlinetop = NHTTPi_findNextLineHdrRecvBuf(res_p, linetop,
res_p->headerLen, &labelend, &return_code_size);
if (labelend > 0)
{
labeltop = linetop;
if (NHTTPi_compareTokenN_HdrRecvBuf(
res_p, labeltop, labelend, label_p, 0)
== 0)
{
if (labelend + 1 < res_p->headerLen)
{
valueend = NHTTPi_findNextLineHdrRecvBuf(res_p,
labelend + 1, res_p->headerLen, NULL,
&return_code_size);
if (valueend <= 0)
{
valueend = res_p->headerLen;
}
else
{
if (valueend < return_code_size)
{
return -1;
}
valueend -= return_code_size;
}
valuetop = NHTTPi_skipSpaceHdrRecvBuf(
res_p, labelend + 1, valueend);
if (valuetop < 0)
{
valuetop = valueend;
}
*pos_p = valuetop;
return valueend - valuetop;
}
else
{
return 0;
}
}
}
linetop = nextlinetop;
}
return -1;
}
s32 NHTTP_GetHeaderField(NHTTPResponseInfo* res_p, const char* label_p,
const char** value_p)
{
s32 pos;
s32 length;
if (res_p->isHeaderParse == 0)
{
return -1;
}
if (res_p->foundHeader_p != NULL)
{
NHTTPi_free(res_p->foundHeader_p);
res_p->foundHeader_p = NULL;
}
length = NHTTPi_getHeaderValue(res_p, label_p, &pos);
if (length >= 0)
{
res_p->foundHeader_p = NHTTPi_alloc(length + 1, 4);
if (res_p->foundHeader_p == NULL)
{
return -1;
}
res_p->foundHeader_p[length] = 0;
NHTTPi_loadFromHdrRecvBuf(res_p, res_p->foundHeader_p, pos, length);
*value_p = res_p->foundHeader_p;
return length;
}
if (NHTTPi_strcmp("HTTPSTATUSCODE", label_p) == 0)
{
res_p->foundHeader_p = NHTTPi_alloc(4, 4);
if (res_p->foundHeader_p == NULL)
{
return -1;
}
res_p->foundHeader_p[3] = 0;
NHTTPi_loadFromHdrRecvBuf(res_p, res_p->foundHeader_p, 9, 3);
*value_p = res_p->foundHeader_p;
return 3;
}
return -1;
}
s32 NHTTP_GetHeaderAll(void* bgnEndInfo_p, NHTTPResponseInfo* res_p,
const char** header_p)
{
if (res_p->isHeaderParse == 0 || res_p->headerLen == 0)
{
return -1;
}
if (res_p->headerLen < NHTTP_HDRRECVBUF_INILEN)
{
*header_p = (const char*)res_p->hdrBufFirst;
}
else
{
if (res_p->allHeader_p == NULL)
{
res_p->allHeader_p = NHTTPi_alloc(res_p->headerLen, 4);
if (res_p->allHeader_p == NULL)
{
NHTTPi_SetError(bgnEndInfo_p, NHTTP_ERROR_ALLOC);
return -1;
}
NHTTPi_loadFromHdrRecvBuf(res_p, res_p->allHeader_p, 0,
res_p->headerLen);
}
*header_p = res_p->allHeader_p;
}
return res_p->headerLen;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,673 @@
#include <private/nhttp.h>
#include <revolution/ncd.h>
#include <string.h>
#include <stdio.h>
struct NHTTPBgnEndInfo
{
NCDIpConfig ipConfig;
};
typedef s32 (*NHTTPPostSend)(const char* label, char** value_p,
u32* length_p, s32 offset, void* userParam);
void* NHTTPi_GetSystemInfoP(void);
NHTTPBgnEndInfo* NHTTPi_GetBgnEndInfoP(void* systemInfo);
void* NHTTPi_GetMutexInfoP(void* systemInfo);
BOOL NHTTPi_Startup(void* systemInfo, NHTTPAlloc alloc, NHTTPFree free,
u32 priority);
void NHTTPi_CleanupAsync(void* systemInfo, NHTTPCleanupCallback callback);
s32 NHTTPi_GetError(NHTTPBgnEndInfo* info);
void* NHTTPi_alloc(u32 size, int align);
void NHTTPi_free(void* buffer);
s32 NHTTPi_strlen(const char* string);
void* NHTTPi_memcpy(void* destination, const void* source, u32 size);
void* NHTTPi_memclr(void* destination, u32 size);
s32 NHTTPi_Base64Encode(char* destination, const char* source);
NHTTPConnectionInfo* NHTTPCreateConnection(const char* url, s32 method,
void* buffer, u32 bufferSize, NHTTPConnectionCallback callback,
void* userParam);
s32 NHTTPStartConnection(NHTTPConnectionInfo* connection);
s32 NHTTPGetBodyBuffer(NHTTPConnectionInfo* connection, void** buffer,
u32* bufferSize);
void* NHTTPGetUserParam(NHTTPConnectionInfo* connection);
s32 NHTTPGetConnectionError(NHTTPConnectionInfo* connection);
NHTTPConnectionInfo* NHTTPi_GetConnection(void* mutexInfo,
NHTTPConnectionInfo* connection);
NHTTPRequestInfo* NHTTPi_Connection2Request(void* mutexInfo,
NHTTPConnectionInfo* connection);
NHTTPResponseInfo* NHTTPi_Connection2Response(void* mutexInfo,
NHTTPConnectionInfo* connection);
NHTTPConnectionInfo* NHTTPi_Request2Connection(void* mutexInfo,
NHTTPRequestInfo* request);
NHTTPConnectionInfo* NHTTPi_Response2Connection(void* mutexInfo,
NHTTPResponseInfo* response);
NHTTPRequestInfo* NHTTPi_GetRequest(void* mutexInfo,
NHTTPRequestInfo* request);
NHTTPResponseInfo* NHTTPi_GetResponse(void* mutexInfo,
NHTTPResponseInfo* response);
s32 NHTTPi_OmitConnectionList(void* mutexInfo,
NHTTPConnectionInfo* connection);
u32 NHTTPi_GetVirtualContentLength(NHTTPConnectionInfo* connection);
BOOL NHTTP_AddHeaderField(NHTTPRequestInfo* request, NHTTPBgnEndInfo* info,
const char* name, const char* value);
BOOL NHTTP_AddPostDataAscii(NHTTPRequestInfo* request, NHTTPBgnEndInfo* info,
const char* name, const char* value);
BOOL NHTTP_CancelRequestAsync(void* systemInfo, s32 requestId);
void NHTTP_DestroyRequest(void* systemInfo, NHTTPRequestInfo* request);
void NHTTP_DestroyResponse(void* mutexInfo, NHTTPResponseInfo* response);
static s32 nhttpRegistered = 0;
const char* __NHTTPVersion = "<< RVL_SDK - NHTTP \trelease build: Jun 27 2007 16:27:59 (0x4199_60726) >>";
char __NHTTPUnofficialVersion[] = "<< RVL_SDK - NHTTP \trelease build: Jun 27 2007 16:27:59 (0x4199_60726) UNOFFICIAL >>";
s32 NHTTPStartup(NHTTPAlloc alloc, NHTTPFree free, u32 priority)
{
void* system = NHTTPi_GetSystemInfoP();
if (nhttpRegistered == 0)
{
OSRegisterVersion(__NHTTPVersion);
nhttpRegistered = TRUE;
}
return NHTTPi_Startup(system, alloc, free, priority) ? 0 : -1;
}
void NHTTPCleanupAsync(NHTTPCleanupCallback callback)
{
NHTTPi_CleanupAsync(NHTTPi_GetSystemInfoP(), callback);
}
s32 NHTTPGetError(void)
{
return NHTTPi_GetError(NHTTPi_GetSystemInfoP());
}
static s32 NHTTPi_PostSendCallbackWrap(void* mutexInfo_p,
NHTTPConnectionInfo* connection_p, void* arg_p)
{
if (connection_p != NULL)
{
NHTTPRequestInfo* req_p =
NHTTPi_Connection2Request(mutexInfo_p, connection_p);
if (req_p != NULL)
{
NHTTPPostSend postSend = (NHTTPPostSend)req_p->_unk250;
if (postSend != NULL)
{
NHTTPPostSendArg* postSendArg_p = arg_p;
return postSend(postSendArg_p->label,
&postSendArg_p->buf, &postSendArg_p->size,
postSendArg_p->offset,
NHTTPGetUserParam(connection_p));
}
}
}
return -1;
}
static s32 NHTTPi_BufFullCallbackWrap(void* mutexInfo_p,
NHTTPConnectionInfo* connection_p, void* arg_p)
{
if (connection_p != NULL)
{
NHTTPResponseInfo* res_p =
NHTTPi_Connection2Response(mutexInfo_p, connection_p);
if (res_p != NULL)
{
NHTTPResponseCallback bufFull = res_p->bufFull;
if (bufFull != NULL)
{
NHTTPBodyBufArg* bodyBufArg_p = arg_p;
char* oldBuf_p = bodyBufArg_p->buf;
u32 contentLength =
NHTTPi_GetVirtualContentLength(connection_p);
bodyBufArg_p->buf = bufFull((void**)&oldBuf_p,
&bodyBufArg_p->size, contentLength, NHTTPi_alloc,
NHTTPi_free, NHTTPGetUserParam(connection_p));
if (bodyBufArg_p->buf != NULL && oldBuf_p != NULL)
{
bodyBufArg_p->offset = 0;
}
}
}
}
return 0;
}
static s32 NHTTPi_CompleteCallbackWrap(void* mutexInfo_p,
NHTTPConnectionInfo* connection_p)
{
if (connection_p != NULL)
{
NHTTPReqCallback reqCallback = connection_p->requestCallback;
if (reqCallback != NULL)
{
NHTTPResponseInfo* res_p =
NHTTPi_Connection2Response(mutexInfo_p, connection_p);
if (res_p != NULL)
{
NHTTPErr result = NHTTPGetConnectionError(connection_p);
reqCallback(
result, res_p, NHTTPGetUserParam(connection_p));
}
}
}
return 0;
}
s32 NHTTPi_TemplateConnectionCallback(NHTTPConnectionInfo* handle,
NHTTPConnectionEvent event, void* arg_p)
{
void* sysInfo_p = NHTTPi_GetSystemInfoP();
void* mutexInfo_p = NHTTPi_GetMutexInfoP(sysInfo_p);
NHTTPConnectionInfo* connection_p =
NHTTPi_GetConnection(mutexInfo_p, handle);
s32 ret = 0;
switch (event)
{
case NHTTP_EVENT_POST_SEND:
ret = NHTTPi_PostSendCallbackWrap(
mutexInfo_p, connection_p, arg_p);
break;
case NHTTP_EVENT_BODY_RECV_FULL:
ret = NHTTPi_BufFullCallbackWrap(
mutexInfo_p, connection_p, arg_p);
break;
case NHTTP_EVENT_BODY_RECV_DONE:
break;
case NHTTP_EVENT_COMPLETE:
ret = NHTTPi_CompleteCallbackWrap(mutexInfo_p, connection_p);
break;
default:
break;
}
return ret;
}
NHTTPRequest* NHTTPCreateRequest(const char* url, NHTTPReqMethod method,
void* buffer, u32 bufferSize, NHTTPReqCallback callback, void* userParam)
{
return NHTTPCreateRequestEx(url, method, buffer, bufferSize, callback, userParam, NULL, NULL);
}
NHTTPRequest* NHTTPCreateRequestEx(const char* url, NHTTPReqMethod method,
void* buffer, u32 bufferSize, NHTTPReqCallback callback, void* userParam,
NHTTPResponseCallback responseCallback, NHTTPResponseCleanup cleanup)
{
void* systemInfo;
void* mutexInfo;
NHTTPConnectionInfo* connection;
NHTTPRequestInfo* request;
connection = NHTTPCreateConnection(url, method, buffer, bufferSize, NHTTPi_TemplateConnectionCallback, userParam);
request = NULL;
if (connection != NULL)
{
systemInfo = NHTTPi_GetSystemInfoP();
mutexInfo = NHTTPi_GetMutexInfoP(systemInfo);
connection = NHTTPi_GetConnection(mutexInfo, connection);
request = NHTTPi_Connection2Request(mutexInfo, connection);
if (request != NULL)
{
if (request->response != NULL)
{
connection->requestCallback = callback;
request->response->bufFull = responseCallback;
request->response->freeBuf = cleanup;
return request;
}
else
{
NHTTP_DestroyRequest(systemInfo, request);
NHTTPi_OmitConnectionList(mutexInfo, connection);
NHTTPi_free(connection);
request = NULL;
}
}
}
return request;
}
s32 NHTTPDeleteRequest(NHTTPRequest* request)
{
NHTTPConnectionInfo* connection = NHTTPi_Request2Connection(
NHTTPi_GetMutexInfoP(NHTTPi_GetSystemInfoP()), request);
if (connection != NULL)
{
NHTTPDeleteConnection(connection);
}
}
s32 NHTTPAddHeaderField(NHTTPRequest* handle, const char* name,
const char* value)
{
void* systemInfo;
NHTTPRequestInfo* request;
void* bgnEndInfo;
systemInfo = NHTTPi_GetSystemInfoP();
request = NHTTPi_GetRequest(NHTTPi_GetMutexInfoP(systemInfo), handle);
bgnEndInfo = NHTTPi_GetBgnEndInfoP(systemInfo);
if (request == NULL)
{
return -1;
}
if (request->state != 0)
{
static char name[] = "NHTTPAddHeaderField";
printf("%s can be called before NHTTPStartConnection()\n", name);
return -1;
}
return NHTTP_AddHeaderField(request, bgnEndInfo, name, value) ? 0 : -1;
}
s32 NHTTPAddPostDataAscii(NHTTPRequest* handle, const char* name,
const char* value)
{
NHTTPRequestInfo* request;
void* bgnEndInfo;
bgnEndInfo = NHTTPi_GetBgnEndInfoP(NHTTPi_GetSystemInfoP());
request = NHTTPi_GetRequest(
NHTTPi_GetMutexInfoP(NHTTPi_GetSystemInfoP()), handle);
if (request == NULL)
{
return -1;
}
if (request->state != 0)
{
printf("%s can be called before NHTTPStartConnection()\n",
"NHTTPAddPostDataAscii");
return -1;
}
return NHTTP_AddPostDataAscii(request, bgnEndInfo, name, value)
? 0
: -1;
}
s32 NHTTPAddPostDataBinary(NHTTPRequest* handle, const char* name,
const char* value)
{
NHTTPRequestInfo* request;
void* bgnEndInfo;
bgnEndInfo = NHTTPi_GetBgnEndInfoP(NHTTPi_GetSystemInfoP());
request = NHTTPi_GetRequest(
NHTTPi_GetMutexInfoP(NHTTPi_GetSystemInfoP()), handle);
if (request == NULL)
{
return -1;
}
if (request->state != 0)
{
printf("%s can be called before NHTTPStartConnection()\n",
"NHTTPAddPostDataBinary");
return -1;
}
return NHTTP_AddPostDataAscii(request, bgnEndInfo, name, value)
? 0
: -1;
}
s32 NHTTPAddPostDataRaw(NHTTPRequest* handle, const void* data,
u32 size, const char* label)
{
NHTTPRequestInfo* request;
request = NHTTPi_GetRequest(
NHTTPi_GetMutexInfoP(NHTTPi_GetSystemInfoP()), handle);
if (request == NULL)
{
return -1;
}
if (request->state != 0)
{
printf("%s can be called before NHTTPStartConnection()\n",
"NHTTPAddPostDataRaw");
return -1;
}
if (request->postData != NULL)
{
printf("already called NHTTPAddPostDataAscii or NHTTPAddPostDataBinary (exclusive fucntion)\n");
return -1;
}
request->isRawData = TRUE;
request->postBuffer = data;
request->postBufferSize = size;
return 0;
}
s32 NHTTPSetPostDataEncoding(NHTTPRequest* handle, u32 encodingType)
{
NHTTPRequestInfo* request;
request = NHTTPi_GetRequest(
NHTTPi_GetMutexInfoP(NHTTPi_GetSystemInfoP()), handle);
if (request == NULL)
{
return -1;
}
if (request->state != 0)
{
printf("%s can be called before NHTTPStartConnection()\n",
"NHTTPSetPostDataEncoding");
return -1;
}
request->encodingType = encodingType;
return 0;
}
NHTTPConnection NHTTPSendRequestAsync(NHTTPRequest* request)
{
NHTTPConnectionInfo* connection;
s32 result;
connection = NHTTPi_Request2Connection(
NHTTPi_GetMutexInfoP(NHTTPi_GetSystemInfoP()), request);
if (connection != NULL && NHTTPStartConnection(connection) == 0)
{
result = connection->requestId;
}
else
{
result = -1;
}
return result;
}
s32 NHTTPCancelRequestAsync(NHTTPConnection connection)
{
return NHTTP_CancelRequestAsync(NHTTPi_GetSystemInfoP(), connection)
? 0
: -1;
}
s32 NHTTPGetProgress(u32* complete, u32* total)
{
s32 result;
result = NHTTP_GetProgress(NHTTPi_GetSystemInfoP(), complete, total)
== 0;
return -result;
}
void NHTTPDestroyResponse(NHTTPResponse* handle)
{
void* mutexInfo;
NHTTPConnectionInfo* connection;
mutexInfo = NHTTPi_GetMutexInfoP(NHTTPi_GetSystemInfoP());
connection = NHTTPi_Response2Connection(mutexInfo, handle);
if (connection != NULL)
{
if (NHTTPi_Connection2Response(mutexInfo, connection) != NULL)
{
NHTTP_DestroyResponse(mutexInfo, connection->response);
}
NHTTPi_OmitConnectionList(mutexInfo, connection);
NHTTPi_free(connection);
}
}
s32 NHTTPGetHeaderField(NHTTPResponse* response, const char* name,
const char** value)
{
void* mutexInfo;
NHTTPResponseInfo* res;
mutexInfo = NHTTPi_GetMutexInfoP(NHTTPi_GetSystemInfoP());
res = NHTTPi_GetResponse(mutexInfo, response);
if (res == NULL)
{
return -1;
}
return NHTTP_GetHeaderField(res, name, value);
}
s32 NHTTPGetHeaderAll(NHTTPResponse* response, const char** header)
{
void* systemInfo;
NHTTPBgnEndInfo* bgnEndInfo;
NHTTPResponseInfo* res;
systemInfo = NHTTPi_GetSystemInfoP();
bgnEndInfo = NHTTPi_GetBgnEndInfoP(systemInfo);
res = NHTTPi_GetResponse(NHTTPi_GetMutexInfoP(systemInfo), response);
if (res == NULL)
{
return -1;
}
return NHTTP_GetHeaderAll(bgnEndInfo, res, header);
}
s32 NHTTPGetBodyAll(NHTTPResponse* response, void** buffer)
{
NHTTPConnectionInfo* connection;
u32 bufferSize;
s32 result;
connection = NHTTPi_Response2Connection(
NHTTPi_GetMutexInfoP(NHTTPi_GetSystemInfoP()), response);
if (connection != NULL)
{
bufferSize = 0;
result = NHTTPGetBodyBuffer(connection, buffer, &bufferSize);
}
else
{
result = -1;
}
return result;
}
s32 NHTTPGetResultCode(NHTTPResponse* handle)
{
NHTTPResponseInfo* response;
response = NHTTPi_GetResponse(
NHTTPi_GetMutexInfoP(NHTTPi_GetSystemInfoP()), handle);
if (response == NULL)
return -1;
if (response->isHeaderParse != FALSE)
return response->httpStatus;
return -1;
}
s32 NHTTPSetVerifyOption(NHTTPRequest* handle, u32 option)
{
NHTTPRequestInfo* request;
s32 result;
request = NHTTPi_GetRequest(
NHTTPi_GetMutexInfoP(NHTTPi_GetSystemInfoP()), handle);
if (request == NULL)
{
result = -1;
}
else
{
request->verifyOption = option;
result = 0;
}
return result;
}
s32 NHTTPSetProxy(NHTTPRequest* handle, const char* proxy_p, u16 port,
const char* username_p, const char* password_p)
{
void* sysInfo_p = NHTTPi_GetSystemInfoP();
void* mutexInfo_p = NHTTPi_GetMutexInfoP(sysInfo_p);
NHTTPRequestInfo* req_p = NHTTPi_GetRequest(mutexInfo_p, handle);
s32 proxyLen = 0;
if (req_p == NULL || proxy_p == NULL)
{
return -1;
}
proxyLen = NHTTPi_strlen(proxy_p);
if (proxyLen > 0x100)
{
printf("proxy-address exceeded 256 characters\n");
return -1;
}
NHTTPi_memcpy(req_p->proxyServer, proxy_p, proxyLen);
req_p->proxyPort = port;
if (username_p != NULL && password_p != NULL)
{
s32 username_len;
s32 password_len;
char tmpbuf[0x41];
username_len = NHTTPi_strlen(username_p);
password_len = NHTTPi_strlen(password_p);
if (username_len > 0x20)
{
printf("username exceeded 32 characters\n");
return -1;
}
if (password_len > 0x20)
{
printf("password exceeded 32 characters\n");
return -1;
}
NHTTPi_memclr(tmpbuf, sizeof(tmpbuf));
NHTTPi_memcpy(tmpbuf, username_p, username_len);
NHTTPi_memcpy(&(tmpbuf[username_len]), ":", 1);
NHTTPi_memcpy(
&(tmpbuf[(username_len + 1)]), password_p, password_len);
req_p->proxyAuthorizationLength =
NHTTPi_Base64Encode(req_p->proxyAuthorization, tmpbuf);
}
req_p->proxyEnabled = TRUE;
return 0;
}
s32 NHTTPSetProxyDefault(NHTTPRequest* handle)
{
NCDProxyServerProfile* proxy;
void* systemInfo;
NHTTPBgnEndInfo* bgnEndInfo;
NHTTPRequestInfo* request;
const char* username;
const char* password;
s32 result;
systemInfo = NHTTPi_GetSystemInfoP();
request = NHTTPi_GetRequest(NHTTPi_GetMutexInfoP(systemInfo), handle);
bgnEndInfo = NHTTPi_GetBgnEndInfoP(systemInfo);
if (request->secure != FALSE)
{
proxy = &bgnEndInfo->ipConfig.proxy.ssl;
}
else
{
proxy = &bgnEndInfo->ipConfig.proxy.http;
}
if (proxy->mode == 1)
{
username = NULL;
password = NULL;
if (proxy->authType == 1)
{
username = proxy->username;
password = proxy->password;
}
OSReport("Using proxy server %s:%d (%s/%s).\n", proxy->server, proxy->port, username != NULL ? username : "[no-auth]", password != NULL ? password : "[no-auth]");
result = NHTTPSetProxy(request, proxy->server, proxy->port, username, password);
if (result < 0)
{
OSReport("NHTTPSetProxy failed.(%d)\n", result);
OSPanic("d_nhttp.c", 0x37d, "NHTTPSetProxy");
}
else
{
return 0;
}
}
else
{
printf("NCD proxy-settings are disabled\n");
}
return -1;
}
s32 NHTTPSetRootCADefault(NHTTPRequest* handle)
{
s32 result;
NHTTPRequestInfo* request;
request = NHTTPi_GetRequest(
NHTTPi_GetMutexInfoP(NHTTPi_GetSystemInfoP()), handle);
if (request == NULL)
{
result = -1;
}
else
{
request->builtinRootCA = FALSE;
request->rootCAData = NULL;
request->rootCASize = 0;
result = 0;
}
return result;
}
s32 NHTTPSetClientCertDefault(NHTTPRequest* handle)
{
s32 result;
NHTTPRequestInfo* request;
request = NHTTPi_GetRequest(
NHTTPi_GetMutexInfoP(NHTTPi_GetSystemInfoP()), handle);
if (request == NULL)
{
result = -1;
}
else
{
request->builtinClientCert = FALSE;
request->clientCertDefault = TRUE;
request->clientCertData = NULL;
request->clientCertSize = 0;
request->privateKeyData = NULL;
request->privateKeySize = 0;
result = 0;
}
return result;
}
s32 NHTTPDisableVerifyOptionForDebug(NHTTPRequest* handle, u32 option)
{
NHTTPRequestInfo* request;
request = NHTTPi_GetRequest(
NHTTPi_GetMutexInfoP(NHTTPi_GetSystemInfoP()), handle);
if (request == NULL)
{
return -1;
}
if (request->state != 0)
{
printf("%s can be called before NHTTPStartConnection()\n",
"NHTTPDisableVerifyOptionForDebug");
return -1;
}
{
static s32 debugSet;
if (debugSet == 0)
{
debugSet = 1;
}
}
request->verifyOption &= ~option;
return 0;
}

View File

@@ -0,0 +1,421 @@
#include <private/nhttp.h>
#include <stdio.h>
typedef struct NHTTPSysInfo
{
u8 bgnEndInfo[0x800];
NHTTPListInfo listInfo;
NHTTPReqInfo reqInfo;
u8 mutexInfo[0x34];
u8 threadInfo[0x460];
} NHTTPSysInfo;
typedef struct NHTTPStaticResource
{
BOOL initialized;
OSMutex mutex;
OSCond cond;
u32 _unk24;
u8 _unk28[0x18];
} NHTTPStaticResource;
static NHTTPSysInfo sysInfo;
static NHTTPSysInfo* sysInfo_p;
static NHTTPConnectionInfo* sConnectionList;
static NHTTPStaticResource NHTTPiStaticResource;
void NHTTPi_lockReqList(void* mutexInfo);
void NHTTPi_unlockReqList(void* mutexInfo);
void NHTTPi_InitBgnEndInfo(NHTTPBgnEndInfo* info);
void NHTTPi_InitListInfo(NHTTPListInfo* info);
void NHTTPi_InitRequestInfo(NHTTPReqInfo* info);
void NHTTPi_InitMutexInfo(void* info);
void NHTTPi_InitThreadInfo(void* info);
NHTTPBgnEndInfo* NHTTPi_GetBgnEndInfoP(NHTTPSysInfo* sysInfo_p);
NHTTPListInfo* NHTTPi_GetListInfoP(NHTTPSysInfo* sysInfo_p);
NHTTPReqInfo* NHTTPi_GetReqInfoP(NHTTPSysInfo* sysInfo_p);
void* NHTTPi_GetThreadInfoP(NHTTPSysInfo* sysInfo_p);
void* NHTTPi_GetMutexInfoP(NHTTPSysInfo* sysInfo_p);
void NHTTPi_WaitForCompletion(NHTTPConnectionInfo* connection)
{
NHTTPStaticResource* res_p = &NHTTPiStaticResource;
if (!res_p->initialized)
{
OSInitMutex(&res_p->mutex);
OSInitCond(&res_p->cond);
res_p->initialized = TRUE;
}
OSLockMutex(&res_p->mutex);
while (connection->_unkC != 0)
{
OSWaitCond(&res_p->cond, &res_p->mutex);
}
OSUnlockMutex(&res_p->mutex);
}
void NHTTPi_NotifyCompletion(NHTTPConnectionInfo* connection)
{
NHTTPStaticResource* res_p = &NHTTPiStaticResource;
if (!res_p->initialized)
{
OSInitMutex(&res_p->mutex);
OSInitCond(&res_p->cond);
res_p->initialized = TRUE;
}
OSLockMutex(&res_p->mutex);
connection->_unkC = 0;
OSSignalCond(&res_p->cond);
OSUnlockMutex(&res_p->mutex);
}
NHTTPConnectionInfo* NHTTPi_ControlConnectionList(void* mutexInfo,
void* handle, u32 mode)
{
NHTTPConnectionInfo* connection;
NHTTPConnectionInfo* result;
NHTTPConnectionInfo** current;
result = NULL;
NHTTPi_lockReqList(mutexInfo);
if (mode == 3)
{
connection = handle;
connection->next = sConnectionList;
sConnectionList = connection;
result = connection;
}
else
{
current = &sConnectionList;
while (*current != NULL)
{
connection = *current;
switch (mode)
{
case 0:
if (connection == handle)
{
result = connection;
}
break;
case 1:
if (connection->request == handle)
{
result = connection;
}
break;
case 2:
if (connection->response == handle)
{
result = connection;
}
break;
case 4:
if (connection == handle)
{
*current = connection->next;
result = connection;
}
break;
}
if (result != NULL)
{
break;
}
current = &(*current)->next;
}
}
NHTTPi_unlockReqList(mutexInfo);
return result;
}
s32 NHTTPi_CommitConnectionList(void* mutexInfo_p,
NHTTPConnectionInfo* connection_p)
{
return ((NHTTPi_ControlConnectionList(mutexInfo_p, connection_p, 3)
!= NULL)
? 0
: -1);
}
s32 NHTTPi_OmitConnectionList(void* mutexInfo_p,
NHTTPConnectionInfo* connection_p)
{
return ((NHTTPi_ControlConnectionList(mutexInfo_p, connection_p, 4)
!= NULL)
? 0
: -1);
}
NHTTPRequestInfo* NHTTPi_Connection2Request(void* mutexInfo,
NHTTPConnectionInfo* connection)
{
connection = NHTTPi_ControlConnectionList(mutexInfo, connection, 0);
return connection != NULL ? connection->request : NULL;
}
NHTTPResponseInfo* NHTTPi_Connection2Response(void* mutexInfo,
NHTTPConnectionInfo* connection)
{
connection = NHTTPi_ControlConnectionList(mutexInfo, connection, 0);
return connection != NULL ? connection->response : NULL;
}
NHTTPConnectionInfo* NHTTPi_Request2Connection(void* mutexInfo,
NHTTPRequestInfo* request)
{
return NHTTPi_ControlConnectionList(
mutexInfo, request, 1);
}
NHTTPConnectionInfo* NHTTPi_Response2Connection(void* mutexInfo,
NHTTPResponseInfo* response)
{
return NHTTPi_ControlConnectionList(
mutexInfo, response, 2);
}
NHTTPConnectionInfo* NHTTPi_GetConnection(void* mutexInfo,
NHTTPConnectionInfo* connection)
{
return NHTTPi_ControlConnectionList(mutexInfo, connection, 0);
}
NHTTPRequestInfo* NHTTPi_GetRequest(void* mutexInfo,
NHTTPRequestInfo* request)
{
NHTTPConnectionInfo* connection;
connection = NHTTPi_ControlConnectionList(
mutexInfo, request, 0);
return connection != NULL ? connection->request : request;
}
NHTTPResponseInfo* NHTTPi_GetResponse(void* mutexInfo,
NHTTPResponseInfo* response)
{
NHTTPConnectionInfo* connection;
connection = NHTTPi_ControlConnectionList(
mutexInfo, response, 0);
return connection != NULL ? connection->response : response;
}
s32 NHTTPi_GetConnectionListLength(void)
{
NHTTPConnectionInfo* connection;
s32 length;
connection = sConnectionList;
length = 0;
while (connection != NULL)
{
connection = connection->next;
length++;
}
return length;
}
s32 NHTTPi_PostSendCallback(void* mutexInfo,
NHTTPConnectionInfo* connection, void* value, u32 arg)
{
u32 callbackArg4;
u32 callbackArg8;
s32 result;
NHTTPResponseInfo* response;
NHTTPConnectionCallbackParam param;
result = -1;
if (NHTTPi_GetConnection(mutexInfo, connection) != NULL)
{
response = NHTTPi_Connection2Response(mutexInfo, connection);
if (response != NULL && connection->callback != NULL)
{
param.value = value;
param._unk4 = connection->_unk24;
param._unk8 = connection->_unk28;
param._unkC = arg;
result = connection->callback(connection, 1, &param);
callbackArg8 = param._unk8;
callbackArg4 = param._unk4;
connection = NHTTPi_GetConnection(mutexInfo, connection);
if (connection != NULL)
{
connection->_unk24 = callbackArg4;
connection->_unk28 = callbackArg8;
}
}
}
return result;
}
void NHTTPi_BufferFullCallback(void* mutexInfo,
NHTTPConnectionInfo* connection)
{
void* buffer;
u32 bufferSize;
s32 responseResult;
NHTTPResponseInfo* response;
NHTTPConnectionCallbackParam param;
if (NHTTPi_GetConnection(mutexInfo, connection) != NULL)
{
response = NHTTPi_Connection2Response(mutexInfo, connection);
if (response != NULL && connection->callback != NULL)
{
param.value = response->recvBuf_p;
param._unk4 = response->recvBufLen;
param._unk8 = response->bodyLen;
connection->callback(connection, 2, &param);
responseResult = param._unk8;
bufferSize = param._unk4;
buffer = param.value;
connection = NHTTPi_GetConnection(mutexInfo, connection);
if (connection != NULL)
{
response = NHTTPi_Connection2Response(mutexInfo, connection);
if (response != NULL)
{
response->recvBuf_p = buffer;
response->recvBufLen = bufferSize;
response->bodyLen = responseResult;
}
}
}
}
}
void NHTTPi_ReceivedCallback(void* mutexInfo,
NHTTPConnectionInfo* connection)
{
void* buffer;
u32 bufferSize;
s32 responseResult;
NHTTPResponseInfo* response;
NHTTPConnectionCallbackParam param;
if (NHTTPi_GetConnection(mutexInfo, connection) != NULL)
{
response = NHTTPi_Connection2Response(mutexInfo, connection);
if (response != NULL && connection->callback != NULL)
{
param.value = response->recvBuf_p;
param._unk4 = response->recvBufLen;
param._unk8 = response->bodyLen;
connection->callback(connection, 3, &param);
responseResult = param._unk8;
bufferSize = param._unk4;
buffer = param.value;
connection = NHTTPi_GetConnection(mutexInfo, connection);
if (connection != NULL)
{
response = NHTTPi_Connection2Response(mutexInfo, connection);
if (response != NULL)
{
response->recvBuf_p = buffer;
response->recvBufLen = bufferSize;
response->bodyLen = responseResult;
}
}
}
}
}
void NHTTPi_CompleteCallback(void* mutexInfo,
NHTTPConnectionInfo* connection)
{
if (NHTTPi_GetConnection(mutexInfo, connection) != NULL
&& connection->callback != NULL)
{
connection->callback(connection, 4, NULL);
}
}
static void NHTTPi_InitSystemInfo(NHTTPSysInfo* sysInfo_p)
{
NHTTPi_InitBgnEndInfo(NHTTPi_GetBgnEndInfoP(sysInfo_p));
NHTTPi_InitListInfo(NHTTPi_GetListInfoP(sysInfo_p));
NHTTPi_InitRequestInfo(NHTTPi_GetReqInfoP(sysInfo_p));
NHTTPi_InitMutexInfo(NHTTPi_GetMutexInfoP(sysInfo_p));
NHTTPi_InitThreadInfo(NHTTPi_GetThreadInfoP(sysInfo_p));
}
NHTTPSysInfo* NHTTPi_GetSystemInfoP(void)
{
if (sysInfo_p == NULL)
{
sysInfo_p = &sysInfo;
NHTTPi_InitSystemInfo(sysInfo_p);
}
return sysInfo_p;
}
NHTTPBgnEndInfo* NHTTPi_GetBgnEndInfoP(NHTTPSysInfo* sysInfo_p)
{
return (NHTTPBgnEndInfo*)sysInfo_p->bgnEndInfo;
}
NHTTPListInfo* NHTTPi_GetListInfoP(NHTTPSysInfo* sysInfo_p)
{
return &sysInfo_p->listInfo;
}
NHTTPReqInfo* NHTTPi_GetReqInfoP(NHTTPSysInfo* sysInfo_p)
{
return &sysInfo_p->reqInfo;
}
void* NHTTPi_GetThreadInfoP(NHTTPSysInfo* sysInfo_p)
{
return sysInfo_p->threadInfo;
}
void* NHTTPi_GetMutexInfoP(NHTTPSysInfo* sysInfo_p)
{
return sysInfo_p->mutexInfo;
}
void NHTTPi_SetVirtualContentLength(NHTTPConnectionInfo* connection,
u32 length)
{
if (connection != NULL)
{
connection->virtualContentLength = length;
}
}
u32 NHTTPi_GetVirtualContentLength(NHTTPConnectionInfo* connection)
{
return connection != NULL ? connection->virtualContentLength : 0;
}
void NHTTPi_InitConnectionList(void)
{
NHTTPConnectionInfo* connection;
s32 count;
connection = sConnectionList;
if (connection != NULL)
{
count = 0;
while (connection != NULL)
{
connection = connection->next;
count++;
}
if (count != 0)
{
printf("*warning: %d connections rests! Please free connections.\n",
count);
}
}
sConnectionList = NULL;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,924 @@
#define NWC24_MSG_COMMIT
#include <private/nwc24.h>
#include <revolution/net/NETMisc.h>
#include <revolution/nwc24.h>
static char MultiPartDivider[64];
BOOL LoopBackEnable = TRUE;
static NWC24File* m_pFile;
static NWC24Err NWC24CommitMsgInternal(NWC24MsgObjPrivate* msg, NWC24MBoxType type);
static NWC24Err CheckMsgObject(const NWC24MsgObjPrivate* msg);
static NWC24Err CheckMsgBoxSpace(const NWC24MsgObjPrivate* msg, NWC24MBoxType type);
static NWC24Err SynthesizeAddrStr(const NWC24Data* address, u32 type, char* dest, s32 capacity, u32* length);
static NWC24Err WriteSMTP_MAILFROM(NWC24MsgObjPrivate* msg);
static NWC24Err WriteSMTP_RCPTTO(NWC24MsgObjPrivate* msg);
static NWC24Err WriteFromField(NWC24MsgObjPrivate* msg);
static NWC24Err WriteToField(NWC24MsgObjPrivate* msg);
static NWC24Err WriteDateField(NWC24MsgObjPrivate* msg);
static NWC24Err WriteXWiiAppIdField(NWC24MsgObjPrivate* msg);
static NWC24Err WriteXWiiFaceField(NWC24MsgObjPrivate* msg);
static NWC24Err WriteXWiiAltNameField(NWC24MsgObjPrivate* msg);
static NWC24Err WriteMIMEAttachHeader(NWC24MsgObjPrivate* msg, u32 index);
static NWC24Err WriteContentTypeField(NWC24MsgObjPrivate* msg);
static NWC24Err WritePlainText(NWC24MsgObjPrivate* msg);
static NWC24Err WriteBase64Data(const u8* data, s32 size, u32* length);
static NWC24Err WriteQPData(const u8* data, s32 size, u32* length);
NWC24Err NWC24iMBoxOpenNewMsg(NWC24MBoxType type, NWC24File* file, u32* id);
NWC24Err NWC24iMBoxCloseMsg(NWC24File* file);
NWC24Err NWC24iMBoxAddMsgObj(NWC24MBoxType type, NWC24MsgObjPrivate* msg);
NWC24Err NWC24iMBoxCancelMsg(NWC24File* file, NWC24MBoxType type, u32 id);
NWC24Err NWC24iMBoxFlushHeader(NWC24MBoxType type);
NWC24Err NWC24iMBoxCheck(NWC24MBoxType type, u32 size);
NWC24Err NWC24iDateToMinutes(u32* minutes, const NWC24Date* date);
NWC24Err NWC24iMinutesToDate(NWC24Date* date, u32 minutes);
static inline NWC24Err WriteString(NWC24MsgObjPrivate* msg, char* buffer) {
NWC24Err err;
s32 length;
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
#define CHECK_WRITE(operation) \
do { \
err = (operation); \
if (err != NWC24_OK) { \
NWC24FClose(&file); \
result = err; \
goto finish; \
} \
} while (0)
static inline NWC24Err WriteSubjectField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
s32 length;
NWC24Err err;
if (msg->subject.size == 0)
return NWC24_ERR_NULL;
Mail_memset(buffer, 0, 1024);
Mail_strcpy(buffer, "Subject: ");
Mail_strncat(buffer, msg->subject.ptr, 1021);
Mail_strncat(buffer, "\r\n", 1024);
length = STD_strnlen(buffer, 1024);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static inline NWC24Err WriteSMTPData(NWC24MsgObjPrivate* msg, const char* text) {
char* buffer = NWC24WorkP->stringWork;
s32 length;
NWC24Err err;
Mail_strcpy(buffer, text);
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += 6;
return err;
}
static inline NWC24Err WriteCmdField(NWC24MsgObjPrivate* msg) {
char* buffer;
s32 length;
NWC24Err err;
if (msg->ledPattern == 0)
return NWC24_OK;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "X-Wii-Cmd: %08X\r\n", msg->ledPattern);
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static inline NWC24Err WriteTagField(NWC24MsgObjPrivate* msg) {
char* buffer;
s32 length;
NWC24Err err;
if (msg->tag == 0)
return NWC24_OK;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "X-Wii-Tag: %08X\r\n", msg->tag);
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static inline NWC24Err WriteDWCIdField(NWC24MsgObjPrivate* msg) {
char* buffer;
s32 length;
NWC24Err err;
if (!(msg->type & 0x2000))
return NWC24_OK;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "X-Wii-DWCId: %08X\r\n", msg->dwcId);
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static inline NWC24Err WriteIconNewField(NWC24MsgObjPrivate* msg) {
char* buffer;
s32 length;
NWC24Err err;
if (msg->iconNew == 0 || msg->iconNew == 0x80000000)
return NWC24_OK;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "X-Wii-IconNew: %08X\r\n", msg->iconNew);
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static inline NWC24Err WriteMessageIdField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
const char* domain;
NWC24UserId myId;
char idText[32];
NWC24Err err;
s32 length;
domain = NWC24GetAccountDomain();
NWC24GetMyUserId(&myId);
Mail_memset(buffer, 0, 1024);
Mail_strcpy(buffer, "Message-Id: <");
Mail_memset(idText, 0, 32);
Mail_sprintf(idText, "%05X%08X%08X%08X", msg->msgId, (u32)(myId >> 32), (u32)myId, msg->unk_0x28);
Mail_strcat(buffer, idText);
Mail_strcat(buffer, domain);
Mail_strcat(buffer, ">\r\n");
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
NWC24Err NWC24CommitMsg(NWC24MsgObj* object) {
BOOL loopback = FALSE;
NWC24MsgObjPrivate* msg = (NWC24MsgObjPrivate*)object;
NWC24UserId myId;
if (!NWC24IsMsgLibOpened() && !NWC24IsMsgLibOpenedByTool())
return NWC24_ERR_LIB_NOT_OPENED;
if (!(msg->type & 0x100) || (msg->type & 0x200))
return NWC24_ERR_PROTECTED;
if (LoopBackEnable && (msg->type & 1)) {
NWC24GetMyUserId(&myId);
if (msg->numTo == 1 && msg->toIds[0] == myId)
loopback = TRUE;
}
return NWC24CommitMsgInternal(msg, loopback);
}
static inline NWC24Err WriteMBNoReplyField(NWC24MsgObjPrivate* msg) {
u32 flags = msg->msgBoardFlags.raw & 0x80000000;
char* buffer;
s32 length;
NWC24Err err;
if (!flags)
return NWC24_OK;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_strcpy(buffer, "X-Wii-MB-NoReply: -\r\n");
length = 21;
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static inline NWC24Err WriteMBRegDateField(NWC24MsgObjPrivate* msg, u32 flags) {
NWC24Err err;
s32 length;
char* buffer;
if (!flags)
return NWC24_OK;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "X-Wii-MB-RegDate: %04X\r\n", flags);
length = STD_strnlen(buffer, 1024);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static inline NWC24Err WriteMBDelayField(NWC24MsgObjPrivate* msg, u32 flags) {
NWC24Err err;
s32 length;
char* buffer;
if (!flags)
return NWC24_OK;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "X-Wii-MB-Delay: %02X\r\n", flags >> 16);
length = STD_strnlen(buffer, 1024);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static inline NWC24Err WriteExtraFields(NWC24MsgObjPrivate* msg) {
NWC24Err err;
if (msg->unk_0xD0.size == 0)
return NWC24_OK;
err = NWC24FWrite(msg->unk_0xD0.ptr, msg->unk_0xD0.size, m_pFile);
if (err == NWC24_OK)
msg->length += msg->unk_0xD0.size;
return err;
}
static NWC24Err NWC24CommitMsgInternal(NWC24MsgObjPrivate* msg, NWC24MBoxType type) {
NWC24File file;
NWC24Data attached[2];
NWC24Data subject;
NWC24Data text;
u32 id, encodedLength;
s32 initIndex;
u32 index;
char* buffer;
NWC24Err result, err;
NWC24Data_Init(&subject);
NWC24Data_Init(&text);
for (initIndex = 0; initIndex < 2; ++initIndex)
NWC24Data_Init(&attached[initIndex]);
NWC24iSetErrorCode(0);
result = CheckMsgObject(msg);
if (result != NWC24_OK)
goto report;
result = CheckMsgBoxSpace(msg, type);
if (result != NWC24_OK)
goto report;
err = NWC24iMBoxOpenNewMsg(type, &file, &id);
if (err != NWC24_OK) {
result = err;
goto finish;
}
{
msg->msgId = id;
msg->length = 0;
m_pFile = &file;
if (type == NWC24_MBOX_TYPE_SEND) {
CHECK_WRITE(WriteSMTP_MAILFROM(msg));
CHECK_WRITE(WriteSMTP_RCPTTO(msg));
CHECK_WRITE(WriteSMTPData(msg, "DATA\r\n"));
}
CHECK_WRITE(WriteDateField(msg));
CHECK_WRITE(WriteFromField(msg));
CHECK_WRITE(WriteToField(msg));
CHECK_WRITE(WriteMessageIdField(msg));
subject.ptr = (const void*)(msg->length + 9);
err = WriteSubjectField(msg);
if (err == NWC24_OK)
subject.size = msg->length - (u32)subject.ptr - 2;
else if (err == NWC24_ERR_NULL) {
err = NWC24_OK;
subject.ptr = NULL;
}
if (err != NWC24_OK) {
NWC24FClose(&file);
result = err;
goto finish;
}
if (msg->type & 1) {
CHECK_WRITE(WriteXWiiAppIdField(msg));
CHECK_WRITE(WriteCmdField(msg));
CHECK_WRITE(WriteTagField(msg));
CHECK_WRITE(WriteDWCIdField(msg));
CHECK_WRITE(WriteXWiiAltNameField(msg));
CHECK_WRITE(WriteXWiiFaceField(msg));
CHECK_WRITE(WriteIconNewField(msg));
if (msg->msgBoardFlags.raw != 0) {
CHECK_WRITE(WriteMBNoReplyField(msg));
CHECK_WRITE(WriteMBRegDateField(msg, msg->msgBoardFlags.raw & 0xFFFF));
CHECK_WRITE(WriteMBDelayField(msg, msg->msgBoardFlags.raw & 0xFF0000));
}
}
CHECK_WRITE(WriteExtraFields(msg));
Mail_memset(MultiPartDivider, 0, 40);
Mail_sprintf(MultiPartDivider, "Boundary-NWC24-%08X%05X", msg->unk_0x28, msg->msgId);
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_strcpy(buffer, "MIME-Version: 1.0\r\n");
if (msg->type & 0x10000) {
Mail_strcat(buffer, "Content-Type: multipart/mixed;\r\n boundary=\"");
Mail_strcat(buffer, MultiPartDivider);
Mail_strcat(buffer, "\"\r\n");
}
CHECK_WRITE(WriteString(msg, buffer));
if (msg->type & 0x10000) {
msg->unk_0x10 = msg->length;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "\r\n--%s", MultiPartDivider);
Mail_strcat(buffer, "\r\n");
CHECK_WRITE(WriteString(msg, buffer));
}
CHECK_WRITE(WriteContentTypeField(msg));
if (!(msg->type & 0x10000))
msg->unk_0x10 = msg->length;
text.ptr = (const void*)msg->length;
err = WritePlainText(msg);
if (err == NWC24_ERR_NULL)
err = NWC24_OK;
if (err != NWC24_OK) {
NWC24FClose(&file);
result = err;
goto finish;
}
text.size = msg->length - (u32)text.ptr;
for (index = 0; index < msg->numAttached; ++index) {
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "\r\n--%s", MultiPartDivider);
Mail_strcat(buffer, "\r\n");
CHECK_WRITE(WriteString(msg, buffer));
CHECK_WRITE(WriteMIMEAttachHeader(msg, index));
attached[index].ptr = (const void*)msg->length;
err = WriteBase64Data(msg->attached[index].ptr, msg->attached[index].size, &encodedLength);
if (err == NWC24_OK)
msg->length += encodedLength;
if (err != NWC24_OK) {
NWC24FClose(&file);
result = err;
goto finish;
}
attached[index].size = msg->length - (u32)attached[index].ptr;
if ((s32)index == msg->numAttached - 1) {
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "\r\n--%s", MultiPartDivider);
Mail_strcat(buffer, "--\r\n");
CHECK_WRITE(WriteString(msg, buffer));
}
}
}
finish:
if (result == NWC24_OK) {
NWC24iMBoxCloseMsg(&file);
} else {
NWC24iMBoxCancelMsg(&file, type, id);
NWC24iMBoxFlushHeader(type);
goto report;
}
{
msg->subject = subject;
msg->text = text;
msg->attached[0] = attached[0];
msg->attached[1] = attached[1];
msg->type |= 0x200;
if (type == NWC24_MBOX_TYPE_RECV)
msg->type |= 0x20;
else if (type == NWC24_MBOX_TYPE_SEND)
msg->type |= 0x10;
err = NWC24iMBoxAddMsgObj(type, msg);
if (result != NWC24_OK)
err = result;
result = err;
if (type == NWC24_MBOX_TYPE_RECV) {
u32 flags = 1;
if (msg->type & 8)
flags |= 2;
NWC24iSetNewMsgArrived(flags);
}
}
report:
if (result == NWC24_ERR_FULL || (result <= -16 && result >= -21) || result == -38 || result == -41 || result == -43 || result == -46)
NWC24iSetErrorCode(result - 109300);
return result;
}
static NWC24Err CheckMsgObject(const NWC24MsgObjPrivate* msg) {
const char* subject;
if (msg->numTo == 0)
return NWC24_ERR_NULL;
if (msg->numTo > 8)
return NWC24_ERR_INVALID_VALUE;
subject = msg->subject.ptr;
if (subject != NULL) {
for (; *subject != '\0'; ++subject) {
if (*subject == '\r' && subject[1] != '\n')
return NWC24_ERR_FORMAT;
if (*subject == '\n' && subject[1] != ' ')
return NWC24_ERR_FORMAT;
}
}
if (msg->numAttached > 2)
return NWC24_ERR_INVALID_VALUE;
return NWC24_OK;
}
static NWC24Err CheckMsgBoxSpace(const NWC24MsgObjPrivate* msg, NWC24MBoxType type) {
u32 total = 0;
u32 textSize = 0;
s32 index;
NWC24Err err;
for (index = 0; index < msg->numAttached; ++index) {
u32 size = msg->attachedSize[index];
total += (size * 4 + 2) / 3 + size / 57 * 2 + 4;
}
switch (msg->encoding) {
case NWC24_ENC_7BIT:
case NWC24_ENC_8BIT:
textSize = msg->text.size;
break;
case NWC24_ENC_BASE64:
textSize = (msg->text.size * 4 + 2) / 3 + msg->text.size / 57 * 2 + 4;
break;
case NWC24_ENC_QUOTED_PRINTABLE:
textSize = msg->text.size * 4 / 3;
break;
default:
textSize = 0;
break;
}
total += textSize;
if (total >= 0x31C00)
return NWC24_ERR_OVERFLOW;
err = NWC24iMBoxCheck(type, total + 1024);
if (err != NWC24_OK)
return err;
return NWC24_OK;
}
static NWC24Err SynthesizeAddrStr(const NWC24Data* address, u32 type, char* dest, s32 capacity, u32* length) {
char id[32];
NWC24Err err = NWC24_OK;
const char* domain;
s32 domainLength, written;
if (type & 1) {
domain = NWC24GetAccountDomain();
domainLength = Mail_strlen(domain);
if (domainLength <= 0)
err = NWC24_ERR_CONFIG;
else if (domainLength + 18 >= capacity)
err = NWC24_ERR_NOMEM;
else {
NWC24iConvIdToStr(*(const NWC24UserId*)address, id);
written = Mail_sprintf(dest, "%c%s%s", 'w', id, domain);
if (written == 0)
err = NWC24_ERR_FATAL;
else
*length = written;
}
} else if (type & 2) {
if (address->size + 3 >= (u32)capacity)
err = NWC24_ERR_NOMEM;
else {
written = Mail_sprintf(dest, "%s", address->ptr);
if (written == 0)
err = NWC24_ERR_FATAL;
else
*length = written;
}
} else
err = NWC24_ERR_INVALID_VALUE;
return err;
}
static NWC24Err WriteSMTP_MAILFROM(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
char* address;
u32 length;
s32 total;
u32 type;
NWC24Err err;
Mail_memset(buffer, 0, 1024);
Mail_strncat(buffer, "MAIL FROM: ", 1022);
address = buffer + 11;
type = 1;
if (msg->type & 0x100000)
type = 2;
err = SynthesizeAddrStr(&msg->fromAddr, type, address, 1009, &length);
if (err != NWC24_OK)
return err;
{
address += length;
address[0] = '\r';
address[1] = '\n';
total = length + 13;
if ((s32)(1009 - length) <= 0)
return NWC24_ERR_NOMEM;
}
if (err == NWC24_OK) {
err = NWC24FWrite(NWC24WorkP->stringWork, total, m_pFile);
if (err == NWC24_OK)
msg->length += total;
}
return err;
}
static NWC24Err WriteSMTP_RCPTTO(NWC24MsgObjPrivate* msg) {
char* cursor = NWC24WorkP->stringWork;
u32 index;
s32 total = 0, remaining;
u32 length;
NWC24Err err = NWC24_OK;
Mail_memset(cursor, 0, 1024);
remaining = 1022;
for (index = 0; index < msg->numTo; ++index) {
Mail_strncat(cursor, "RCPT TO: ", remaining);
cursor += 9;
remaining -= 11;
err = SynthesizeAddrStr(&msg->toAddrs[index], msg->type, cursor, remaining, &length);
if (err != NWC24_OK)
break;
cursor += length;
cursor[0] = '\r';
cursor[1] = '\n';
cursor += 2;
remaining -= length;
total += length + 11;
if (remaining <= 0) {
err = NWC24_ERR_NOMEM;
break;
}
}
if (err == NWC24_OK) {
err = NWC24FWrite(NWC24WorkP->stringWork, total, m_pFile);
if (err == NWC24_OK)
msg->length += total;
}
return err;
}
static NWC24Err WriteFromField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
char* address;
u32 length;
s32 total;
u32 type;
NWC24Err err;
Mail_memset(buffer, 0, 1024);
Mail_strncat(buffer, "From: ", 1022);
address = buffer + 6;
msg->unk_0x30.ptr = (const void*)(msg->length + 6);
type = 1;
if (msg->type & 0x100000)
type = 2;
err = SynthesizeAddrStr(&msg->fromAddr, type, address, 1014, &length);
if (err != NWC24_OK)
return err;
{
address += length;
address[0] = '\r';
address[1] = '\n';
total = length + 8;
if ((s32)(1014 - length) <= 0)
return NWC24_ERR_NOMEM;
}
if (err == NWC24_OK) {
err = NWC24FWrite(NWC24WorkP->stringWork, total, m_pFile);
if (err == NWC24_OK) {
msg->length += total;
msg->unk_0x30.size = msg->length - (u32)msg->unk_0x30.ptr - 2;
}
}
return err;
}
static NWC24Err WriteToField(NWC24MsgObjPrivate* msg) {
char* cursor = NWC24WorkP->stringWork;
s32 index, total, remaining;
u32 length;
NWC24Err err = NWC24_OK;
Mail_memset(cursor, 0, 1024);
Mail_strncat(cursor, "To: ", 1022);
cursor += 4;
index = 0;
total = 4;
msg->unk_0x38.ptr = (const void*)(msg->length + 4);
remaining = 1018;
for (; index < msg->numTo; ++index) {
err = SynthesizeAddrStr(&msg->toAddrs[index], msg->type, cursor, remaining, &length);
if (err != NWC24_OK)
break;
remaining -= length;
cursor += length;
total += length;
if (remaining <= 4) {
err = NWC24_ERR_NOMEM;
break;
}
if (index < msg->numTo - 1) {
cursor[0] = ',';
cursor[1] = '\r';
cursor[2] = '\n';
cursor[3] = ' ';
total += 4;
remaining -= 4;
cursor += 4;
}
}
cursor[0] = '\r';
cursor[1] = '\n';
if (err == NWC24_OK) {
err = NWC24FWrite(NWC24WorkP->stringWork, total + 2, m_pFile);
if (err == NWC24_OK) {
msg->length += total + 2;
msg->unk_0x38.size = msg->length - (u32)msg->unk_0x38.ptr - 2;
}
}
return err;
}
static NWC24Err WriteDateField(NWC24MsgObjPrivate* msg) {
static const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
NWC24Date date;
OSCalendarTime calendar;
char* buffer;
s32 length;
NWC24Err err;
NWC24Date_Init(&date);
NETGetUniversalCalendar(&calendar);
date.year = calendar.year;
date.month = calendar.mon + 1;
date.day = calendar.mday;
date.hour = calendar.hour;
date.min = calendar.min;
date.sec = calendar.sec;
if (date.month > 12)
return NWC24_ERR_FORMAT;
NWC24iDateToMinutes(&msg->unk_0x28, &date);
if (msg->type & 0x1000000)
NWC24iMinutesToDate(&date, msg->unk_0x2C);
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "Date: %02d %s %d %02d:%02d:%02d -0000\r\n", date.day, months[date.month - 1], date.year, date.hour, date.min, date.sec);
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static NWC24Err WriteXWiiAppIdField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
char appIdText[16];
u32 type = 0;
s32 length;
NWC24Err err;
Mail_memset(buffer, 0, 1024);
Mail_strcpy(buffer, "X-Wii-AppId: ");
if (!NWC24IsMsgLibOpenedByTool() && NWC24GetAppId() != 0x48414541 && msg->appId != 0x48414341)
msg->appId = NWC24GetAppId();
if (msg->type & 4)
type |= 1;
if (msg->type & 8)
type |= 2;
Mail_memset(appIdText, 0, 16);
Mail_sprintf(appIdText, "%d-%08X-%04X\r\n", type, msg->appId, msg->groupId);
Mail_strcat(buffer, appIdText);
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static NWC24Err WriteXWiiFaceField(NWC24MsgObjPrivate* msg) {
char* buffer;
const u8* data;
s32 offset, remaining, chunk;
u32 length;
NWC24Err err;
if (msg->faceData.size == 0)
return NWC24_OK;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_strcpy(buffer, "X-WiiFace:");
data = msg->faceData.ptr;
offset = 10;
for (remaining = msg->faceData.size; remaining > 0; remaining -= chunk) {
buffer[offset++] = ' ';
chunk = remaining;
if (remaining > 42)
chunk = 42;
NWC24Base64Encode((u8*)data, chunk, (u8*)(buffer + offset), 76, &length);
data += chunk;
offset += length;
buffer[offset++] = '\r';
buffer[offset++] = '\n';
}
err = NWC24FWrite(buffer, offset, m_pFile);
if (err == NWC24_OK)
msg->length += offset;
return err;
}
static NWC24Err WriteXWiiAltNameField(NWC24MsgObjPrivate* msg) {
char* buffer;
const u8* data;
s32 offset, remaining, chunk;
u32 length;
NWC24Err err;
if (msg->altName.size == 0)
return NWC24_OK;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_strcpy(buffer, "X-Wii-AltName:");
data = msg->altName.ptr;
offset = 14;
for (remaining = msg->altName.size; remaining > 0; remaining -= chunk) {
buffer[offset++] = ' ';
chunk = remaining;
if (remaining > 42)
chunk = 42;
NWC24Base64Encode((u8*)data, chunk, (u8*)(buffer + offset), 76, &length);
data += chunk;
offset += length;
buffer[offset++] = '\r';
buffer[offset++] = '\n';
}
err = NWC24FWrite(buffer, offset, m_pFile);
if (err == NWC24_OK)
msg->length += offset;
return err;
}
const char* ContentTypeA = "Content-Type: %s;\r\n name=%c%07d.%s\r\n";
const char* ContentTxEncA = "Content-Transfer-Encoding: base64\r\n";
const char* ContentDispA = "Content-Disposition: attachment;\r\n filename=%c%07d.%s\r\n\r\n";
static NWC24Err WriteMIMEAttachHeader(NWC24MsgObjPrivate* msg, u32 index) {
char* buffer;
const char* mime;
const char* suffix;
s32 typeLength, encodingLength, dispositionLength, mimeLength;
s32 first, second, third, total;
NWC24Err err;
Mail_memset(NWC24WorkP->stringWork, 0, 1024);
buffer = NWC24WorkP->stringWork;
mime = NWC24GetMIMETypeStr(msg->attachedType[index]);
suffix = NWC24iGetMIMETypeSuffix(msg->attachedType[index]);
encodingLength = Mail_strlen(ContentTxEncA);
typeLength = Mail_strlen(ContentTypeA);
dispositionLength = Mail_strlen(ContentDispA);
typeLength += encodingLength;
mimeLength = Mail_strlen(mime);
mimeLength = (dispositionLength + typeLength) + mimeLength + 4;
if (mimeLength >= 1024)
return NWC24_ERR_NOMEM;
first = Mail_sprintf(buffer, (char*)ContentTypeA, mime, (char)('a' + index), msg->msgId, suffix);
if (first <= 0)
return NWC24_ERR_FAILED;
buffer += first;
second = Mail_sprintf(buffer, (char*)ContentTxEncA);
if (second <= 0)
return NWC24_ERR_FAILED;
buffer += second;
total = first + second;
third = Mail_sprintf(buffer, (char*)ContentDispA, (char)('a' + index), msg->msgId, suffix);
if (third <= 0)
return NWC24_ERR_FAILED;
total += third;
err = NWC24FWrite(NWC24WorkP->stringWork, total, m_pFile);
if (err == NWC24_OK)
msg->length += total;
return err;
}
const char* ContentTypeTP = "Content-Type: text/plain; charset=%s\r\n";
const char* ContentTxEncT = "Content-Transfer-Encoding: %s\r\n\r\n";
static NWC24Err WriteContentTypeField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
const char* name;
const char* encoding;
s32 total = 0;
NWC24Err err;
Mail_memset(buffer, 0, 1024);
name = NWC24GetCharsetStr(msg->charset);
if (name != NULL) {
Mail_sprintf(buffer, (char*)ContentTypeTP, name);
msg->unk_0x50.ptr = (const void*)(msg->length + 34);
msg->unk_0x50.size = Mail_strlen(name) + 1;
total = Mail_strlen(buffer);
buffer += total;
}
encoding = NWC24GetEncodingStr(msg->encoding);
if (encoding != NULL) {
Mail_sprintf(buffer, (char*)ContentTxEncT, encoding);
msg->unk_0x58.ptr = (const void*)(total + msg->length + 27);
msg->unk_0x58.size = Mail_strlen(encoding) + 1;
total += Mail_strlen(buffer);
}
if (total == 0)
return NWC24_OK;
err = NWC24FWrite(NWC24WorkP->stringWork, total, m_pFile);
if (err == NWC24_OK)
msg->length += total;
return err;
}
static NWC24Err WritePlainText(NWC24MsgObjPrivate* msg) {
u32 length;
NWC24Err err;
if (msg->text.size == 0)
return NWC24_ERR_NULL;
switch (msg->encoding) {
case NWC24_ENC_7BIT:
case NWC24_ENC_8BIT:
err = NWC24FWrite(msg->text.ptr, msg->text.size, m_pFile);
length = msg->text.size;
break;
case NWC24_ENC_BASE64:
err = WriteBase64Data(msg->text.ptr, msg->text.size, &length);
break;
case NWC24_ENC_QUOTED_PRINTABLE:
err = WriteQPData(msg->text.ptr, msg->text.size, &length);
break;
default:
err = NWC24_ERR_INVALID_VALUE;
break;
}
if (err == NWC24_OK) {
msg->textSize = msg->text.size;
msg->length += length;
}
return err;
}
static NWC24Err WriteBase64Data(const u8* data, s32 size, u32* totalLength) {
const u8* cursor = data;
char* buffer = NWC24WorkP->stringWork;
u32 length;
u32 total = 0;
NWC24Err err = NWC24_OK;
while (size >= 57) {
Mail_memset(buffer, 0, 1024);
err = NWC24Base64Encode((u8*)cursor, 57, (u8*)buffer, 76, &length);
if (err != NWC24_OK)
break;
buffer[length++] = '\r';
buffer[length++] = '\n';
buffer[length] = '\0';
err = NWC24FWrite(buffer, length, m_pFile);
if (err != NWC24_OK)
break;
cursor += 57;
size -= 57;
total += length;
}
if (err == NWC24_OK) {
Mail_memset(buffer, 0, 1024);
err = NWC24Base64Encode((u8*)cursor, size, (u8*)buffer, 76, &length);
if (err == NWC24_OK) {
buffer[length++] = '\r';
buffer[length++] = '\n';
buffer[length++] = '\r';
buffer[length++] = '\n';
buffer[length] = '\0';
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
total += length;
}
}
*totalLength = total;
return err;
}
static NWC24Err WriteQPData(const u8* data, s32 size, u32* totalLength) {
char* buffer = NWC24WorkP->stringWork;
const u8* cursor = data;
s32 remaining = size;
s32 total = 0;
u32 consumed, length;
NWC24Err err = NWC24_OK;
for (; remaining > 0; remaining -= consumed) {
if (total > 0) {
Mail_memcpy(buffer, "=\r\n", 3);
err = NWC24FWrite(buffer, 3, m_pFile);
if (err != NWC24_OK)
break;
total += 3;
}
Mail_memset(buffer, 0, 1024);
err = NWC24EncodeQuotedPrintable(buffer, 1024, &length, (u8*)cursor, remaining, &consumed);
if (err != NWC24_OK && err != NWC24_ERR_OVERFLOW)
break;
err = NWC24FWrite(buffer, length, m_pFile);
if (err != NWC24_OK)
break;
cursor += consumed;
total += length;
}
*totalLength = total;
return err;
}

File diff suppressed because it is too large Load Diff

View File

@@ -23,7 +23,7 @@ static const void* NETGetSHA1Interface(void);
static void NETHMACInit(NETHMACContext* ctx, const void* interface, const void* key, u32 keyLen);
static void NETHMACUpdate(NETHMACContext* ctx, const void* data, u32 len);
static void NETHMACGetDigest(NETHMACContext* ctx, void* digest);
extern char lbl_81697583[];
extern char VmReportFormat[];
#define CHANSVmDebugLength 1024
#define VM_FRAME_ARENA_SIZE 8192
@@ -66,7 +66,7 @@ void CHANSVmDebugPrintf(const vmString format, ...) {
str[CHANSVmDebugLength - 1] = str[CHANSVmDebugLength - 2] = 0;
OSReport(lbl_81697583, str);
OSReport(VmReportFormat, str);
}
#define CHANS_VM_PRINTF(line, msg, ...) \
@@ -92,8 +92,8 @@ vmU16 CHANSVmGetSourceLine(CHANSVm* vm) {
}
}
if ((u8*)curEntry + lineOffset + 1 < (u8*)ctx->pDbg + ctx->pDbg->regionSize) {
u8* lineData = (u8*)curEntry + lineOffset;
if ((u8*)ctx->pDbg->pLineTbl + lineOffset + 1 < (u8*)ctx->pDbg + ctx->pDbg->regionSize) {
u8* lineData = (u8*)ctx->pDbg->pLineTbl + lineOffset;
return VM_READ_BE_U16(lineData, 0);
}
}
@@ -347,7 +347,7 @@ vmPtr CHANSVmNewObjData(CHANSVm* vm, CHANSVmObjHdr* object, u32 length) {
if (chunk == vmNull) {
chunk = CHANSVmAlloc(vm, 0x4000);
if (chunk == vmNull) {
goto error;
goto no_entry;
}
pVm->pChunks[chunkIdx] = chunk;
}
@@ -365,6 +365,7 @@ vmPtr CHANSVmNewObjData(CHANSVm* vm, CHANSVmObjHdr* object, u32 length) {
chunkIdx++;
u.off += 4;
}
no_entry:
u.off = 0;
goto check_entry;
}
@@ -397,7 +398,7 @@ error:
return vmNull;
}
extern const char CHANSVmConstStringDataEmpty[16];
extern const CHANSVmObjHdr CHANSVmConstStringDataEmpty;
CHANSVmObjHdr* CHANSVmNewObject(CHANSVm* vm, vmBoolInt noAlloc, CHANSVmObjHdr* object, CHANSVmObjType type, vmSize len) {
CHANSVmObjHdr* header;
@@ -418,7 +419,7 @@ CHANSVmObjHdr* CHANSVmNewObject(CHANSVm* vm, vmBoolInt noAlloc, CHANSVmObjHdr* o
}
} else {
if (type == 3UL) {
object->value.ptr_v = (vmPtr)CHANSVmConstStringDataEmpty;
object->value.ptr_v = (vmPtr)&CHANSVmConstStringDataEmpty;
}
}
@@ -509,15 +510,14 @@ CHANSVmErr CHANSVmPopObject(CHANSVm* vm, CHANSVmObjHdr* object) {
void CHANSVmStrCpyToU16FromU8(vmWString output, vmString input, vmSize length) {
u8* src = (u8*)input + length;
u32 offset = VM_STR_LENGTH(length);
while (length > 0) {
u8 val;
offset -= 2;
u32 offset = VM_STR_LENGTH(--length);
u8* dest = (u8*)output + offset;
val = *--src;
((u8*)output)[offset + 1] = val;
((u8*)output)[offset] = 0;
length--;
dest[1] = val;
dest[0] = 0;
}
}
@@ -667,25 +667,25 @@ u8 lbl_81669094[19] = {0x00, '-', 0x00, 'I', 0x00, 'n', 0x00, 'f', 0x00, 'i', 0x
// clang-format off
const CHANSVmObjHdr CHANSVmConstStringObjectUndefined = {{(wchar_t*)lbl_81669070, 18}, {0}, vmNull};
const CHANSVmObjHdr lbl_81616C88 = {{L"NaN", 6}, {0}, vmNull};
const CHANSVmObjHdr lbl_81616C88 = {{(wchar_t*)"\0N\0a\0N", 6}, {0}, vmNull};
const CHANSVmObjHdr lbl_81616C98 = {{(wchar_t*)lbl_81669083, 16}, {0}, vmNull};
const CHANSVmObjHdr lbl_81616CA8 = {{(wchar_t*)lbl_81669094, 18}, {0}, vmNull};
const CHANSVmObjHdr lbl_81616CB8 = {{L",", 2}, {0}, vmNull};
const char CHANSVmConstStringDataEmpty[16] = "";
const CHANSVmObjHdr lbl_81616CB8 = {{(wchar_t*)"\0,", 2}, {0}, vmNull};
const CHANSVmObjHdr CHANSVmConstStringDataEmpty = {{(wchar_t*)"", 0}, {0}, vmNull};
const CHANSVmObjHdr CHANSVmConstStringObjectUndefined_[] = {{{(void*)&CHANSVmConstStringObjectUndefined, 0}, 0x03800100, vmNull},
{{(void*)&lbl_81616C88, 0}, 0x03800100, vmNull},
{{(void*)&lbl_81616C98, 0}, 0x03800100, vmNull},
{{(void*)&lbl_81616CA8, 0}, 0x03800100, vmNull},
{{(void*)&lbl_81616CB8, 0}, 0x00800000, vmNull}};
char lbl_81697583[] = "%s";
char lbl_8169758A[] = "%.16lg";
{{vmNull, 0}, 0x00800000, vmNull}};
char VmReportFormat[] = "%s";
const CHANSVmFloatConstantList lbl_81616D28[] = {
{ "Infinity", (double*)&VmInf },
{ "+Infinity", (double*)&VmInf },
{ "-Infinity", (double*)&VmMinusInf },
{ "Infinity", (double*)&VmNaN }
{ "NaN", (double*)&VmNaN }
};
char lbl_8169758A[] = "%.16lg";
// clang-format on
CHANSVmObjHdr* CHANSVm_8144B4D4(CHANSVm* vm, CHANSVmObjType type, CHANSVmObjHdr* object) {
@@ -764,10 +764,10 @@ s32 CHANSVm_8144B62C(vmWString buf, u32 len, vmFloat val) NO_INLINE {
return VM_STR_LENGTH(result);
}
char lbl_81697591[] = "%lld";
char VmIntegerFormat[] = "%lld";
static int VmToStrFromInt(vmWString output, vmSize length, vmInteger integer) {
vmS32 len = snprintf((vmString)output, length, lbl_81697591, integer);
vmS32 len = snprintf((vmString)output, length, VmIntegerFormat, integer);
CHANSVmStrCpyToU16FromU8(output, (vmString)output, len);
return len;
}
@@ -853,7 +853,7 @@ vmBoolInt CHANSVmGetEnumedType(CHANSVmObjType* eType, vmU32 iType) NO_INLINE {
type = 4;
break;
}
case CHANS_VM_TYPE_GLOBAL_REF:
case CHANS_VM_TYPE_OBJECT:
case CHANS_VM_TYPE_CLASS_REF:
case CHANS_VM_TYPE_METHOD_REF: {
type = 5;
@@ -876,12 +876,13 @@ char lbl_81669128[] = "VmGetResultType";
// clang-format off
const VmConvertEntry VmTypeConvertFuncTbl[] = {
{CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError},
{CHANSVm_8144B30C, CHANSVmConvertToIntFromStr, CHANSVmConvertToIntFromArray, CHANSVmConvertObjectTypeError, CHANSVm_8144B430, CHANSVm_8144B470},
{CHANSVm_8144B4D4, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertToStrFromUndefined, CHANSVmConvertToStrFromInt, CHANSVm_8144B734},
{CHANSVmConvertToStrFromArray, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError},
{CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError},
{CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError}};
{vmNull, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError},
{CHANSVmConvertObjectTypeError, vmNull, CHANSVm_8144B30C, CHANSVmConvertToIntFromStr, CHANSVmConvertToIntFromArray, CHANSVmConvertObjectTypeError},
{CHANSVm_8144B430, CHANSVm_8144B470, vmNull, CHANSVm_8144B4D4, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError},
{CHANSVmConvertToStrFromUndefined, CHANSVmConvertToStrFromInt, CHANSVm_8144B734, vmNull, CHANSVmConvertToStrFromArray, CHANSVmConvertObjectTypeError},
{CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, vmNull, CHANSVmConvertObjectTypeError},
{CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, CHANSVmConvertObjectTypeError, vmNull},
};
// clang-format on
// Each table is a 6x6 u8 matrix indexed [left_enumed][right_enumed].
@@ -1533,8 +1534,8 @@ const char* vmErrorList[] = {
"CHANS_VM_ERR_RESERVED_OPCODE", /* -923 */
};
const char* vmNoError = "CHANS_VM_OK";
const char* vmUnknownError = "(unknown)";
char vmNoError[] = "CHANS_VM_OK";
char vmUnknownError[] = "(unknown)";
CHANSVmNativeClass* CHANSVmFindNativeClass(CHANSVm* vm, const char* clsName) {
CHANSVmPrivate* pVm = (CHANSVmPrivate*)vm;
@@ -1920,15 +1921,15 @@ static CHANSVmErr VmArrayExpandCommon(CHANSVm* vm, CHANSVmObjHdr* obj, u32 start
chunk->pNext = current;
}
for (i = 0, allocSize = 0; i < total; i++, allocSize += sizeof(CHANSVmObjHdr)) {
for (i = 0; i < total; i++) {
if (fillFromArgs != 0 && i < ((CHANSVmPrivate*)vm)->pActiveCtx->argc && CHANSVmGetArg(vm, i) != vmNull) {
CHANSVmObjHdr* arg = CHANSVmGetArg(vm, i);
if (CHANSVmCopyObject(vm, (CHANSVmObjHdr*)((u8*)chunk + sizeof(ArrayChunk) + allocSize), arg) == vmNull) {
if (CHANSVmCopyObject(vm, &chunk->elements[i], arg) == vmNull) {
goto error;
}
continue;
}
memset((u8*)chunk + sizeof(ArrayChunk) + allocSize, 0, sizeof(CHANSVmObjHdr));
memset(&chunk->elements[i], 0, sizeof(CHANSVmObjHdr));
}
return vmTrue;
@@ -2146,7 +2147,7 @@ static u32 VmArrayJoinSub(CHANSVmObjHdr* obj, CHANSVmObjHdr* array, wchar_t* sep
goto error;
}
strBuf = (vmString)(*obj->value.ptr_v) + offset;
elemLen = snprintf(strBuf, 0x40, lbl_81697591, chunk->elements[countInChunk].value.int_v);
elemLen = snprintf(strBuf, 0x40, VmIntegerFormat, chunk->elements[countInChunk].value.int_v);
CHANSVmStrCpyToU16FromU8((vmWString)strBuf, strBuf, elemLen);
elemLen = elemLen << 1;
break;
@@ -2631,10 +2632,8 @@ VmMethodDefine(Date, GetRTC) {
u32 bias = SCGetCounterBias();
s64 ticks = OSCalendarTimeToTicks(cal);
u64 t = ticks / (__OSBusClock / 4 / 1000);
u32 val;
t = t / 1000;
val = (u32)(t - (unsigned int)bias);
return CHANSVmSetInteger(VmInst, VmReturnObj, val) == CHANS_VM_OK;
t /= 1000;
return CHANSVmSetInteger(VmInst, VmReturnObj, (t - bias) & 0xFFFFFFFFULL) == CHANS_VM_OK;
}
const CHANSVmMethodList VmDateMethodTbl[] = {
@@ -3167,13 +3166,13 @@ VmMethodDefine(String, Splice) {
length = VmParentObj->value.string_v->len;
if (arg0 != vmNull) {
s64 byteOffs0 = arg0->value.int_v * 2;
if (byteOffs0 > length) {
s64 startByteOffset = arg0->value.int_v * 2;
if (startByteOffset > length) {
start = length;
} else {
start = byteOffs0;
if (byteOffs0 < 0) {
s64 t0 = byteOffs0 + length;
start = startByteOffset;
if (startByteOffset < 0) {
s64 t0 = startByteOffset + length;
start = t0;
if (t0 < 0) {
start = 0;
@@ -3200,7 +3199,7 @@ VmMethodDefine(String, Splice) {
length = tempLen;
}
newLen = length - start & ~-(s32)(start >= length);
newLen = start >= length ? 0 : length - start;
if (CHANSVmNewObject(VmInst, vmFalse, VmReturnObj, CHANS_VM_OBJ_TYPE_STRING, newLen) != vmNull) {
if (newLen != 0) {
@@ -4163,23 +4162,21 @@ VmMethodDefine(Blob, CopyRangeFrom) {
if (CHANSVm_81450D14(destBlob, destOffObj->value.int_v, &destOff) != 0 && CHANSVm_81450D14(srcBlob, srcOffObj->value.int_v, &srcOff) != 0) {
count = CHANSVm_81451314(srcBlob, countObj, srcOff);
if ((s64)destBlob->size >= (s64)count) {
u32 available = destBlob->size - destOff;
if ((s64)count >= (s64)available) {
{
u32 destinationOffset = destOff;
if ((s64)count >= 0 && (s64)(destBlob->size - destinationOffset) >= (s64)count) {
okFlag = vmTrue;
}
}
if (okFlag) {
okFlag = vmFalse;
if ((s64)count >= 0) {
u32 available = srcBlob->size - srcOff;
if ((s64)count >= (s64)available) {
okFlag = vmTrue;
}
vmBoolInt sourceValid = vmFalse;
u32 sourceOffset = srcOff;
if ((s64)count >= 0 && (s64)(srcBlob->size - sourceOffset) >= (s64)count) {
sourceValid = vmTrue;
}
if (okFlag) {
if (sourceValid) {
memmove(destBlob->pData + destOff, srcBlob->pData + srcOff, count);
return CHANSVmSetInteger(VmInst, VmReturnObj, (vmInteger)(u64)count) == CHANS_VM_OK;
}
@@ -4383,14 +4380,14 @@ VmMethodDefine(Blob, CalcMD5Digest) {
}
VmMethodDefine(Blob, CalcRangeMD5Digest) {
u8* data;
u8* digest;
BlobHeader* blob = (BlobHeader*)VmGetStrFromObjHdr(VmParentObj);
CHANSVmObjHdr* arg0 = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_INTEGER, CHANSVmGetArg(VmInst, 0));
CHANSVmObjHdr* arg1 = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_INTEGER, CHANSVmGetArg(VmInst, 1));
u32 offset = 0;
u32 size;
u8* data;
NETMD5Context ctx;
u8* digest;
CHANSVmObjHdr* newObj;
if (blob == vmNull || arg0 == vmNull) {
@@ -4531,6 +4528,8 @@ VmMethodDefine(Blob, CalcHMAC) {
}
VmMethodDefine(Blob, CalcRangeHMAC) {
u8* blobData;
u8* digest;
BlobHeader* blob = (BlobHeader*)VmGetStrFromObjHdr(VmParentObj);
CHANSVmObjHdr* argKey = CHANSVmGetArg(VmInst, 0);
BlobHeader* keyBlob;
@@ -4557,9 +4556,7 @@ VmMethodDefine(Blob, CalcRangeHMAC) {
off = offset;
if (((s64)size >= 0LL && (s64)(blob->size - off) >= (s64)size) != vmFalse) {
NETHMACContext ctx;
u8* digest;
CHANSVmObjHdr* newObj;
u8* blobData;
newObj = VmBlobCreateDirect(VmInst, VmReturnObj, 20);
digest = VmBlobGetDataBufferDirect(newObj);
@@ -6107,7 +6104,7 @@ static vmBoolInt VmWinEmuWrite(CHANSVm* vm, CHANSVmObjHdr* parent, CHANSVmObjHdr
if (result == 0) {
buf[outLen] = 0;
buf[outLen + 1] = 0;
OSReport("%s", buf);
OSReport(VmReportFormat, buf);
} else {
OSReport("document.write(): conversion error (%d)\n", result);
break;
@@ -6983,7 +6980,7 @@ static CHANSVmErr VmCallMethod(CHANSVm* vm, u32 instructionSize, u32 callType, u
CHANSVmNativeClass* target;
u32 pushEnd, headerCount;
u32 newPc;
void* pConstObj;
const u8* instruction;
CHANSVmObjHdr localBuf;
u32 pushDepth;
CHANSVmFunction funcPtr;
@@ -7047,7 +7044,7 @@ static CHANSVmErr VmCallMethod(CHANSVm* vm, u32 instructionSize, u32 callType, u
u32 pc = pVm->pActiveCtx->pc;
newPc = pc + instructionSize;
pConstObj = (void*)(pVm->pActiveCtx->pDbg->pData + pc);
instruction = pVm->pActiveCtx->pDbg->pData + pc;
if (newPc < pc || newPc > pVm->pActiveCtx->pDbg->codeSize) {
return CHANS_VM_ERR_CODE_RANGE;
@@ -7063,8 +7060,7 @@ static CHANSVmErr VmCallMethod(CHANSVm* vm, u32 instructionSize, u32 callType, u
target = vmNull;
} else {
CHANSVmExecutionCtx* ec = pVm->pActiveCtx;
// TODO: what's the actual type of the object here? avoid raw ptr access
u32 methodId = *((u16*)pConstObj + 1);
u32 methodId = VM_READ_BE_U16(instruction, 1);
u32 methodCount;
if (ec->pDbg->pMethodTbl == vmNull) {
@@ -7115,7 +7111,7 @@ static CHANSVmErr VmCallMethod(CHANSVm* vm, u32 instructionSize, u32 callType, u
entry = entry->pNext;
}
} else {
pushDepth = *((u8*)pConstObj + instructionSize - 1);
pushDepth = instruction[instructionSize - 1];
if (retVal != 0) {
CHANSVmNativeMethod* node = target->pNativeMethods;
@@ -7411,7 +7407,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
break;
}
case VM_OPKIND_EQ: {
convTbl = (u8*)VmResultTypeTbl.arith;
convTbl = (u8*)VmResultTypeTbl.eq;
break;
}
case VM_OPKIND_BIT:
@@ -7727,7 +7723,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
return CHANS_VM_ERR_CODE_RANGE;
}
pAcc = &pVm->accumulator;
if (CHANSVmDeleteObject(vm, pAcc) == CHANS_VM_OK) {
result = CHANSVmDeleteObject(vm, pAcc);
if (result == CHANS_VM_OK) {
imm16Val = VM_READ_BE_U16(operandBuf, 0);
ctx = pVm->pActiveCtx;
dbg = ctx->pDbg;
@@ -7741,10 +7738,9 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
break;
load_str_ok:
// result is not initialized in this code path?
pAcc->type = CHANS_VM_OBJ_TYPE_STRING;
pAcc->hasData = vmTrue;
pAcc->value.wstring_v = (vmWStringObjVal*)&dbg->pStringTbl[imm16Val];
pAcc->value.wstring_v = (vmWStringObjVal*)&ctx->pDbg->pStringTbl[imm16Val];
break;
}
@@ -7852,7 +7848,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
CHANSVmObjHdr* hdr = CHANSVmNewObject(vm, vmFalse, &pVm->accumulator, CHANS_VM_OBJ_TYPE_STRING, VM_STRING_SIZE);
if (hdr != vmNull) {
char* s = pVm->accumulator.value.string_v->spData;
s32 snpLen = snprintf(s, 0x40, "%lld", (u64)arrayIdx);
s32 snpLen = snprintf(s, 0x40, VmIntegerFormat, (u64)arrayIdx);
CHANSVmStrCpyToU16FromU8((wchar_t*)s, s, snpLen);
pVm->accumulator.value.string_v->len = VM_STR_LENGTH(snpLen);
} else {
@@ -7889,37 +7885,30 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
}
case CHANS_VM_OP_NEW_ARRAY: {
CHANSVmObjHdr* accumulator;
CHANSVmErr arrayResult;
opSize = 3;
operandBuf = VmGetOperand(vm, 1, 3);
if (operandBuf == vmNull) {
return CHANS_VM_ERR_CODE_RANGE;
}
imm16Val = VM_READ_BE_U16(operandBuf, 0);
{
CHANSVmObjHdr* pAcc = &pVm->accumulator;
if (CHANSVmDeleteObject(vm, pAcc) != CHANS_VM_OK) {
// result not initialized in this code path
break;
}
if (VmPushFuncReturnInfo(vm, imm16Val, imm16Val, 0) != CHANS_VM_OK) {
// result not initialized in this code path
break;
}
pAcc->type = CHANS_VM_TYPE_ARRAY;
pAcc->parentCls = pVm->pArrayCls;
if (CHANSVmNewObjData(vm, pAcc, 0x18) != vmNull) {
if (imm16Val != 0) {
result = VmArrayExpandCommon(vm, pAcc, imm16Val, 0, vmTrue);
accumulator = &pVm->accumulator;
arrayResult = CHANSVmDeleteObject(vm, accumulator);
if (arrayResult == CHANS_VM_OK) {
arrayResult = VmPushFuncReturnInfo(vm, imm16Val, imm16Val, 0);
if (arrayResult == CHANS_VM_OK) {
accumulator->type = CHANS_VM_TYPE_ARRAY;
accumulator->parentCls = pVm->pArrayCls;
if (CHANSVmNewObjData(vm, accumulator, sizeof(ArrayChunk)) == vmNull ||
(imm16Val != 0 && VmArrayExpandCommon(vm, accumulator, imm16Val, 0, vmTrue) == 0)) {
arrayResult = CHANS_VM_ERR_CALL_NEW_ARRAY;
} else {
arrayResult = VmReturnWithValue(vm, 0);
}
} else {
result = CHANS_VM_ERR_CALL_NEW_ARRAY;
break;
}
result = VmReturnWithValue(vm, 0);
}
result = arrayResult;
break;
}
@@ -7982,12 +7971,12 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
}
imm16Val = (opcodeVal << 8 | operandBuf[1]) & 0x1FFF;
switch (opcodeVal & CHANS_VM_OP_SYMBOL_STORE) {
case CHANS_VM_OP_SYMBOL_STORE: {
case 0: {
foundObj = CHANSVm_81455654(vm, imm16Val);
result = VmStore(vm, &pVm->accumulator, foundObj);
break;
}
case 0: {
case CHANS_VM_OP_SYMBOL_STORE: {
foundObj = CHANSVm_81455654(vm, imm16Val);
result = VmStore(vm, foundObj, &pVm->accumulator);
break;
@@ -8011,10 +8000,6 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
isTypeMatch = 0;
if (pVm->accumulator.type == stackTop->type) {
switch (stackTop->type) {
case CHANS_VM_OBJ_TYPE_BLANK: {
isTypeMatch = 1;
goto end_branch_check;
}
case CHANS_VM_OBJ_TYPE_INTEGER: {
u32 low1 = *(u32*)stackTop;
u32 low2 = *(u32*)&pVm->accumulator;
@@ -8034,21 +8019,14 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
case CHANS_VM_OBJ_TYPE_STRING: {
u32 len1, len2;
CHANSVmObjHdr* stackObj = (CHANSVmObjHdr*)pVm->pObjStackTopBuf;
s32 cmpResult;
u32 strEqual;
isTypeMatch = 0;
len1 = stackObj->value.wstring_v->len;
len2 = pVm->accumulator.value.wstring_v->len;
if (len1 == len2) {
strEqual = 0;
if (len1 == 0) {
if (len1 == 0 || memcmp(stackObj->value.wstring_v->spData, pVm->accumulator.value.wstring_v->spData, len1) == 0) {
strEqual = 1;
goto end_branch_check;
} else {
cmpResult = 0;
cmpResult = memcmp(stackObj->value.wstring_v->spData, pVm->accumulator.value.wstring_v->spData, len1);
if (cmpResult == 0) {
strEqual = 1;
}
}
if (strEqual) {
isTypeMatch = 1;
@@ -8056,6 +8034,10 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
}
goto end_branch_check;
}
case CHANS_VM_OBJ_TYPE_BLANK: {
isTypeMatch = 1;
goto end_branch_check;
}
case CHANS_VM_TYPE_ARRAY:
case CHANS_VM_TYPE_CLASS_REF:
case CHANS_VM_TYPE_OBJECT:

View File

@@ -0,0 +1,796 @@
#define MYTIINPUTFORM_IMPLEMENTATION
#include "keyboard/MyTiInputForm.h"
#include "keyboard/tiUtil.h"
#include <nw4r/lyt/group.h>
#include <nw4r/lyt/material.h>
#include <nw4r/lyt/textbox.h>
#include <new>
namespace textinput {
namespace inputform {
class EventHandler : public nw4rmanager::TiEventHandler {
public:
EventHandler(textinput::InputForm* form) : mpInputForm(form) {}
virtual ~EventHandler() {}
virtual void onTiEvent(gui::PaneComponent*, u32, Input*);
protected:
textinput::InputForm* mpInputForm;
};
}
namespace extend {
namespace memo {
class AnmPane : public nw4rmanager::AnmPane {
protected:
AnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: nw4rmanager::AnmPane(pane, observer), meState(0) {}
public:
virtual ~AnmPane();
virtual void init();
virtual void changeAnimation(u32 id);
virtual u32 getState();
virtual u32 getKeyType() const;
protected:
u32 meState;
u32 meKeyType;
};
class WholePane : public AnmPane {
public:
WholePane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) { meKeyType = 0; }
virtual ~WholePane() {}
virtual void onAnmEvent(AnmPaneEvent event);
};
class NigaoePane : public AnmPane {
public:
NigaoePane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) { meKeyType = 1; }
virtual ~NigaoePane() {}
virtual void onAnmEvent(AnmPaneEvent event);
};
class SimpleAnmPane : public nw4rmanager::AnmPane {
public:
SimpleAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : nw4rmanager::AnmPane(pane, observer) {}
virtual ~SimpleAnmPane() {}
virtual void init();
virtual void changeAnimation(u32 id);
};
class ScrollButton {
public:
ScrollButton(TiLayout* layout) : muGroup(0), muAnimation(0), mpLayout(layout), mbLeftPressed(false), mbRightPressed(false) {}
virtual void create(MEMAllocator*, nw4r::lyt::MultiArcResourceAccessor*);
virtual void init();
virtual void calc();
virtual void changeAnimation(bool left, u32 id);
private:
u32 muGroup;
u32 muAnimation;
TiLayout* mpLayout;
nw4rmanager::AnimPaneGroup* mGroups[9];
bool mbGroupChanged[9];
bool mbLeftPressed;
bool mbRightPressed;
};
class EventHandler : public inputform::EventHandler {
public:
EventHandler(InputForm* form) : inputform::EventHandler(form), mpMemoForm(form) {}
virtual ~EventHandler() {}
virtual void onTiEvent(gui::PaneComponent*, u32, Input*);
private:
InputForm* mpMemoForm;
};
static const char* scPaneName[] = {
"N_Header", "N_Body", "B_Body", "N_Footer", "Nigaoe",
"T_Nigaoe", "B_Nigaoe", "T_Letter", "T_TouchLetter"
};
struct AnimationFile {
u32 id;
char name[64];
};
static const AnimationFile csAninationFile[] = {
{0, "my_Memo_a_normal.brlan"},
{1, "my_Memo_a_MailIn.brlan"},
{2, "my_Memo_a_MailOut.brlan"},
{3, "my_Memo_a_SendOut.brlan"},
{4, "my_Memo_a_NigaoeFoucusIn.brlan"},
{5, "my_Memo_a_NigaoeFoucusOut.brlan"}
};
struct PaneAnimations {
u32 type;
const char* paneName;
u32 count;
const AnimationFile* animations[12];
};
static const PaneAnimations csPaneToAnimation[] = {
{0, "N_Memo", 4, {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3]}},
{1, "Nigaoe", 2, {&csAninationFile[4], &csAninationFile[5]}}
};
static const AnimationFile csGroupAninationFile[] = {
{0, "my_Memo_a_Off.brlan"},
{1, "my_Memo_a_Appear.brlan"},
{2, "my_Memo_a_Lost.brlan"},
{3, "my_Memo_a_HDActionEnd.brlan"},
{4, "my_Memo_a_HDActionStart.brlan"},
{5, "my_Memo_a_Loop.brlan"},
{6, "my_Memo_a_Select.brlan"},
{7, "my_Memo_a_FocusOff.brlan"},
{8, "my_Memo_a_FocusOn.brlan"}
};
struct GroupAnimations {
u32 group;
u32 animations[3];
};
static const GroupAnimations csGroupToAnimation[] = {
{0, {5, 9, 9}}, {1, {8, 7, 9}}, {2, {8, 7, 9}},
{3, {6, 9, 9}}, {4, {6, 9, 9}}, {5, {2, 1, 9}},
{6, {2, 1, 9}}, {7, {4, 3, 9}}, {8, {4, 3, 9}}
};
InputForm::~InputForm() {
mpSendString->~Decolated();
MEMFreeToAllocator(mpAllocator, mpSendString);
MEMFreeToAllocator(mpAllocator, mpDefaultNigaoe);
}
void InputForm::setAddScroll(f32 scroll, bool up, bool down) {
setScroll(mfScroll + scroll);
if (up && !mbScrollUp) {
mpScrollButton->changeAnimation(false, 4);
} else if (down && !mbScrollDown) {
mpScrollButton->changeAnimation(true, 4);
}
if (!up && mbScrollUp) {
mpScrollButton->changeAnimation(false, 3);
} else if (!down && mbScrollDown) {
mpScrollButton->changeAnimation(true, 3);
}
mbScrollUp = up;
mbScrollDown = down;
}
void InputForm::moveCursorUp() {
f32 y = 1.0f + (mfCursorY - getLineHeight());
if (y <= 0.0f) {
u32 start, end;
mpString->getCursorPos(&start, &end);
if (start == 0 && end == 0) onSE(sound::SE_CHAR_CURSOR_FIX);
else onSE(sound::SE_CHAR_CURSOR);
setCursorPos(mpString, 0);
} else {
setCursorPos(mpString, calcCursorPos(mfCursorX, y - mfScroll));
onSE(sound::SE_CHAR_CURSOR);
}
meScrollFlag = SF_ScrollOn;
}
void InputForm::moveCursorDown() {
f32 y = 1.0f + (mfCursorY + getLineHeight());
if (y / getLineHeight() >= getLine()) {
u32 start, end;
mpString->getCursorPos(&start, &end);
if (start == mpString->getLength() && end == mpString->getLength()) onSE(sound::SE_CHAR_CURSOR_FIX);
else onSE(sound::SE_CHAR_CURSOR);
setCursorPos(mpString, mpString->getLength());
} else {
setCursorPos(mpString, calcCursorPos(mfCursorX, y - mfScroll));
onSE(sound::SE_CHAR_CURSOR);
}
meScrollFlag = SF_ScrollOn;
}
void InputForm::onCommand(INPUT_COMMAND command, void* data) {
if (meEditMode == EM_Edit) onCommandOnEditMode(command, data);
else if (meEditMode == EM_Disp) onCommandOnDispMode(command, data);
else {
switch (command) {
case 6: case 21: case 29: case 31:
textinput::InputForm::onCommand(command, data);
break;
case 7: case 8: case 9: case 10: case 11: case 12: case 13:
case 14: case 15: case 16: case 17: case 18: case 19: case 20:
case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 30:
break;
}
}
}
void InputForm::onCommandOnEditMode(INPUT_COMMAND command, void* data) {
switch (command) {
case 24:
if (!mExScrollAnm.isActive()) {
if (static_cast<Scroll*>(data)->y < 0.0f)
mExScrollAnm.startAnm(NULL, mfScroll, mfScroll + getLineHeight(), 15.0f, NULL);
else
mExScrollAnm.startAnm(NULL, mfScroll, mfScroll - getLineHeight(), 15.0f, NULL);
onSE(sound::SE_LINE_SCROLL);
}
break;
default:
textinput::InputForm::onCommand(command, data);
break;
}
}
void InputForm::onCommandOnDispMode(INPUT_COMMAND command, void* data) {
switch (command) {
case 14: {
nw4r::math::VEC2 position = getGlobalLeftTopPos();
nw4r::math::VEC2* point = static_cast<nw4r::math::VEC2*>(data);
int line = (point->y - position.y) / getLineHeight();
if (line > getLine() - 1) line = getLine() - 1;
if (getLine() > 1 && line >= getLine() - 1) line = getLine() - 2;
mfScrollFrom = mfScroll;
mfScrollTo = line * getLineHeight();
nw4r::math::VEC2 editPoint;
editPoint.x = point->x;
editPoint.y = point->y - mfScroll;
textinput::InputForm::onCommand(static_cast<INPUT_COMMAND>(14), &editPoint);
int relationLine = line;
struct Relation { int type; int* line; } relation = {0, &relationLine};
textinput::InputForm::onCommand(INPUT_COMMAND_37, &relation);
mbEdited = true;
candidatebox::CandidateBoxCaller::resetCandidate();
candidatebox::CandidateBoxCaller::makeEmptyCandidate();
break;
}
case 29: case 31: case 41:
textinput::InputForm::onCommand(command, data);
break;
}
}
void InputForm::create(MEMAllocator* allocator, inputform::EditBuffer* editBuffer) {
textinput::InputForm::create(allocator, editBuffer);
void* stringMemory = MEMAllocFromAllocator(allocator, sizeof(tistring::Decolated));
mpSendString = new (stringMemory) tistring::Decolated(1024);
mpSendString->create(allocator);
MEMFreeToAllocator(allocator, mpInputEventHandler);
void* handlerMemory = MEMAllocFromAllocator(allocator, sizeof(EventHandler));
mpInputEventHandler = new (handlerMemory) EventHandler(this);
mpInputEventHandler->setEventObserver(mpEventObserver);
mpPaneManager->changeEventHandler(mpInputEventHandler);
mpDefaultNigaoe = static_cast<GXTexObj*>(MEMAllocFromAllocator(allocator, sizeof(GXTexObj)));
getNigaoePaneMaterial()->GetTexture(mpDefaultNigaoe, 0);
setVisible("P_2l_TextBox", true);
mpBoundPane = mpLayout->GetRootPane()->FindPaneByName("T_2l_TextBox", true);
mDefaultBoundTrans = mpBoundPane->GetTranslate();
mDefaultBoundSize = mpBoundPane->GetSize();
mpDrawPane = mpLayout->GetRootPane()->FindPaneByName("B_2l_TextBox", true);
mpPaneManager->getPaneComponentByPane(mpDrawPane)->setTriggerTarget(false);
mDrawRect = mpDrawPane->GetPaneRect(mDrawInfo);
mDefaultDrawTrans = mpDrawPane->GetTranslate();
mDefaultDrawSize = mpDrawPane->GetSize();
mpMemoPane = mpLayout->GetRootPane()->FindPaneByName("N_Memo", true);
mpMemoRootPane = mpLayout->GetRootPane()->FindPaneByName("N_MemoRoot", true);
setScroll(0.0f);
mnLine = 1;
mfScrollFrom = 0.0f;
mfScrollTo = 0.0f;
PSMTXIdentity(mDrawMtx);
PSMTXIdentity(mBoundMtx);
createAnimation(allocator);
void* scrollMemory = MEMAllocFromAllocator(allocator, sizeof(ScrollButton));
mpScrollButton = new (scrollMemory) ScrollButton(mpLayout);
mpScrollButton->create(allocator, mpMultiArcResourceAccessor);
}
void InputForm::createAnimation(MEMAllocator* allocator) {
for (u16 i = 0; i < 2; i++) {
const PaneAnimations& entry = csPaneToAnimation[i];
AnmPane* pane = NULL;
switch (entry.type) {
case 0: {
void* memory = MEMAllocFromAllocator(allocator, sizeof(WholePane));
pane = new (memory) WholePane(getPane(entry.paneName), NULL);
break;
}
case 1: {
void* memory = MEMAllocFromAllocator(allocator, sizeof(NigaoePane));
pane = new (memory) NigaoePane(getPane(entry.paneName), NULL);
break;
}
}
nw4r::ut::List_Append(&mAnmPanes, pane);
for (u16 j = 0; j < entry.count; j++) {
const void* resource = mpMultiArcResourceAccessor->GetResource(0, entry.animations[j]->name, NULL);
AnimTransformPane* transform = static_cast<AnimTransformPane*>(getLayout()->CreateAnimTransform(resource, mpMultiArcResourceAccessor));
pane->addAnimation(allocator, entry.animations[j]->id, transform, false, true);
}
}
}
AnmPane::~AnmPane() {}
static const char* csGroupName[] = {
"G_ArwRoop", "G_ArwR_Focus", "G_ArwL_Focus", "G_ArwR_Ac", "G_ArwL_Ac",
"G_ArwL_End", "G_ArwR_End", "G_ArwL_HDAc", "G_ArwR_HDAc"
};
void ScrollButton::create(MEMAllocator* allocator, nw4r::lyt::MultiArcResourceAccessor* accessor) {
for (int i = 0; i < 9; i++) {
mbGroupChanged[i] = false;
nw4r::lyt::Group* group = mpLayout->GetGroupContainer()->FindGroupByName(csGroupName[i]);
void* groupMemory = MEMAllocFromAllocator(allocator, sizeof(nw4rmanager::AnimPaneGroup));
mGroups[i] = new (groupMemory) nw4rmanager::AnimPaneGroup(group);
nw4r::lyt::PaneLinkList& panes = group->GetPaneList();
for (nw4r::lyt::PaneLinkList::Iterator it = panes.GetBeginIter(); it != panes.GetEndIter(); ++it) {
void* memory = MEMAllocFromAllocator(allocator, sizeof(SimpleAnmPane));
SimpleAnmPane* pane = new (memory) SimpleAnmPane(it->mTarget, NULL);
for (u16 j = 0; j < 3; j++) {
int id = csGroupToAnimation[i].animations[j];
if (id != 9) {
const void* resource = accessor->GetResource(0, csGroupAninationFile[id].name, NULL);
AnimTransformPane* transform = static_cast<AnimTransformPane*>(mpLayout->CreateAnimTransform(resource, accessor));
bool loop = false;
if (id == 5) loop = true;
pane->addAnimation(allocator, id, transform, loop, false);
}
}
mGroups[i]->addAnimPane(pane);
}
}
changeAnimation(true, 5);
changeAnimation(false, 5);
changeAnimation(true, 2);
changeAnimation(false, 2);
for (int i = 0; i < 10; i++) calc();
}
void ScrollButton::calc() {
for (int i = 0; i < 9; i++) mGroups[i]->calc();
}
void ScrollButton::changeAnimation(bool left, u32 id) {
muAnimation = id;
if (left) {
switch (id) {
case 0: muGroup = 0; break;
case 1: muGroup = 5; break;
case 2: muGroup = 5; break;
case 3: if (!mbLeftPressed) return; muGroup = 8; mbLeftPressed = false; break;
case 4: if (mbLeftPressed) return; muGroup = 8; mbLeftPressed = true; break;
case 5: muGroup = 0; break;
case 6: muGroup = 4; break;
case 7: muGroup = 2; break;
case 8: muGroup = 2; break;
}
} else {
switch (id) {
case 0: muGroup = 0; break;
case 1: muGroup = 6; break;
case 2: muGroup = 6; break;
case 3: if (!mbRightPressed) return; muGroup = 7; mbRightPressed = false; break;
case 4: if (mbRightPressed) return; muGroup = 7; mbRightPressed = true; break;
case 5: muGroup = 0; break;
case 6: muGroup = 3; break;
case 7: muGroup = 1; break;
case 8: muGroup = 1; break;
}
}
mbGroupChanged[muGroup] = true;
mGroups[muGroup]->changeAnimation(id);
}
void InputForm::onArrowRPoint() {
if (meEditMode == EM_Disp) {
mpScrollButton->changeAnimation(false, 8);
onSE(sound::SE_BT_TARGETTING);
}
}
void InputForm::onArrowRLeft() {
if (meEditMode == EM_Disp) mpScrollButton->changeAnimation(false, 7);
}
void InputForm::onArrowLPoint() {
if (meEditMode == EM_Disp) {
mpScrollButton->changeAnimation(true, 8);
onSE(sound::SE_BT_TARGETTING);
}
}
void InputForm::onArrowLLeft() {
if (meEditMode == EM_Disp) mpScrollButton->changeAnimation(true, 7);
}
void InputForm::onArrowRTrig() {
if (meEditMode == EM_Disp && !mExScrollAnm.isActive()) {
mpScrollButton->changeAnimation(false, 6);
f32 scroll = mfScroll - 3.0f * getLineHeight();
if (scroll <= getScrollMin()) scroll = getScrollMin();
mExScrollAnm.startAnm(NULL, mfScroll, scroll, 15.0f, NULL);
onSE(sound::SE_LINE_SCROLL);
}
}
void InputForm::onArrowLTrig() {
if (meEditMode == EM_Disp && !mExScrollAnm.isActive()) {
mpScrollButton->changeAnimation(true, 6);
f32 scroll = mfScroll + 3.0f * getLineHeight();
if (scroll >= getScrollMax()) scroll = getScrollMax();
mExScrollAnm.startAnm(NULL, mfScroll, scroll, 15.0f, NULL);
onSE(sound::SE_LINE_SCROLL);
}
}
bool InputForm::updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) {
if (meEditMode == EM_Disp) {
if (hold & 0x400) return textinput::InputForm::updateInput(chan, 0.0f, 0.0f, 0, 0, 0, data);
if (trig & 8) mpScrollButton->changeAnimation(false, 4);
if (release & 8) mpScrollButton->changeAnimation(false, 3);
if (trig & 4) mpScrollButton->changeAnimation(true, 4);
if (release & 4) mpScrollButton->changeAnimation(true, 3);
if (hold & 8) {
if (getScrollMin() <= mfScroll) {
setScroll(mfScroll - 3.5f);
if (mfScroll <= getScrollMin()) setScroll(getScrollMin());
else onSE(sound::SE_MESSAGE_SCROLL);
}
mpScrollButton->changeAnimation(false, 4);
} else mpScrollButton->changeAnimation(false, 3);
if (hold & 4) {
if (getScrollMax() >= mfScroll) {
setScroll(3.5f + mfScroll);
if (mfScroll >= getScrollMax()) setScroll(getScrollMax());
else onSE(sound::SE_MESSAGE_SCROLL);
}
mpScrollButton->changeAnimation(true, 4);
} else mpScrollButton->changeAnimation(true, 3);
}
return textinput::InputForm::updateInput(chan, x, y, trig, hold, release, data);
}
bool InputForm::updateInput(input::HKBManager& hkbManager) {
return textinput::InputForm::updateInput(hkbManager);
}
void InputForm::init() {
if (mpBoundPane != NULL) mCharColor.Set(20, 20, 20, 255);
mbUpVisible = false;
mbDownVisible = false;
searchAnmPane("P_txtScrll_UP")->changeAnimation(7);
searchAnmPane("P_txtScrll_DOWN")->changeAnimation(7);
mbGoodBye = false;
mbEditScrollUp = false;
mbEditScrollDown = false;
setScroll(0.0f);
mfScrollFrom = 0.0f;
mfScrollTo = 0.0f;
resetRelation();
updateCandidateState_();
setLineDrawInfo(true, 10);
}
void InputForm::draw() {
setProjectionMtx();
drawHeader();
drawBody();
drawFooter();
if (meEditMode == EM_Edit) getPane("N_txt_scrl")->Draw(mDrawInfo);
inputform::Base::draw();
if (meEditMode == EM_Disp) {
setProjectionMtx();
getPane("N_TopBtn_00")->Animate(0);
getPane("N_TopBtn_00")->CalculateMtx(mDrawInfo);
getPane("N_TopBtn_00")->Draw(mDrawInfo);
}
mnLine = getLine();
if (mnLine <= 4) mnLine = 4;
}
void InputForm::setScroll(f32 scroll) {
mfScroll = scroll;
mfDrawScrollY = meEditMode == EM_Edit ? -mfScroll : 0.0f;
}
static nw4r::math::VEC2 transformedOrigin(const nw4r::ut::Rect& rect, const Mtx& matrix) {
nw4r::math::VEC3 position;
position.x = rect.left;
position.y = rect.bottom;
position.z = 0.0f;
PSMTXMultVec(matrix, reinterpret_cast<const Vec*>(&position), reinterpret_cast<Vec*>(&position));
return nw4r::math::VEC2(position.x, -position.y);
}
void InputForm::calc() {
nw4rmanager::Layout::calc();
muGlobalAlpha = getLayout()->GetRootPane()->GetAlpha();
mpLayout->Animate(0);
mpLayout->CalculateMtx(mDrawInfo);
mpLayout->GetRootPane()->FindPaneByName("N_Memo", true)->SetTranslate(nw4r::math::VEC2(0.0f, mfScroll));
f32 height = mnLine * getLineHeight();
f32 drawY = mDefaultDrawTrans.y - (height - mDefaultDrawSize.height) / 2.0f;
mpDrawPane->SetSize(nw4r::lyt::Size(mpDrawPane->GetSize().width, height));
mpDrawPane->SetTranslate(nw4r::math::VEC2(mDefaultDrawTrans.x, drawY));
mpDrawPane->CalculateMtx(mDrawInfo);
AdjustPaneMtx(mDrawMtx, mDrawInfo, mpDrawPane->GetGlobalMtx());
nw4r::ut::Rect rect;
rect = mpDrawPane->GetPaneRect(mDrawInfo);
nw4r::math::VEC2 scale(getScale().x, 1.0f);
nw4r::math::VEC2 position = transformedOrigin(rect, mDrawMtx);
mDrawRect.left = position.x;
mDrawRect.bottom = position.y;
mDrawRect.right = position.x + scale.x * (rect.right - rect.left);
mDrawRect.top = position.y + scale.y * (rect.top - rect.bottom);
height = mnLine * getLineHeight();
f32 halfHeight = height - mDefaultBoundSize.height;
halfHeight *= 0.5f;
f32 boundY = mDefaultBoundTrans.y - halfHeight;
if (meEditMode == EM_Edit) {
height = 2.0f * getLineHeight();
boundY = (mDefaultBoundTrans.y - (height - mDefaultBoundSize.height) / 2.0f) - mfScroll;
} else mfDrawScrollY = 0.0f;
mpBoundPane->SetSize(nw4r::lyt::Size(mpBoundPane->GetSize().width, height));
mpBoundPane->SetTranslate(nw4r::math::VEC2(mDefaultBoundTrans.x, boundY));
mpBoundPane->CalculateMtx(mDrawInfo);
AdjustPaneMtx(mBoundMtx, mDrawInfo, mpBoundPane->GetGlobalMtx());
AdjustPaneMtx(mMtx.m, mDrawInfo, mpBoundPane->GetGlobalMtx());
mRect = mpBoundPane->GetPaneRect(mDrawInfo);
muGlobalAlpha = mpBoundPane->GetAlpha();
mExScrollAnm.calc();
if (mExScrollAnm.isActive()) {
setScroll(mExScrollAnm.getValue());
} else if (meEditMode == EM_Edit) {
doAutoScroll();
if (!mExScrollAnm.isActive()) {
f32 halfLine = getLineHeight();
halfLine *= 0.5f;
if (mfScroll - halfLine > 0.0f) {
if (!mbUpVisible) {
searchAnmPane("P_txtScrll_UP")->changeAnimation(5);
mpPaneManager->getPaneComponentByPane(getPane("B_txtScrll_UP"))->init();
}
mbUpVisible = true;
} else {
if (mbUpVisible) searchAnmPane("P_txtScrll_UP")->changeAnimation(6);
mbUpVisible = false;
}
f32 textHeight = getLine() * getLineHeight();
f32 lowerHalfLine = getLineHeight();
lowerHalfLine *= 0.5f;
f32 lowerEdge = mfScroll + height;
lowerEdge += lowerHalfLine;
if (lowerEdge < textHeight) {
if (!mbDownVisible) {
searchAnmPane("P_txtScrll_DOWN")->changeAnimation(5);
mpPaneManager->getPaneComponentByPane(getPane("B_txtScrll_DOWN"))->init();
}
mbDownVisible = true;
} else {
if (mbDownVisible) searchAnmPane("P_txtScrll_DOWN")->changeAnimation(6);
mbDownVisible = false;
}
}
} else {
mbUpVisible = false;
mbDownVisible = false;
searchAnmPane("P_txtScrll_UP")->changeAnimation(7);
searchAnmPane("P_txtScrll_DOWN")->changeAnimation(7);
getPane("N_txt_scrl")->Animate(0);
getPane("N_txt_scrl")->CalculateMtx(mDrawInfo);
}
nw4r::lyt::Pane* scrollPane = getPane("N_txt_scrl");
scrollPane->SetTranslate(nw4r::math::VEC2(scrollPane->GetTranslate().x, 0.0f));
if (meEditMode == EM_Disp) {
mpScrollButton->calc();
if (!mbGoodBye) {
if (mbEditScrollUp && getScrollMin() >= mfScroll) {
mbEditScrollUp = false;
mpScrollButton->changeAnimation(false, 2);
} else if (!mbEditScrollUp && getScrollMin() < mfScroll) {
mbEditScrollUp = true;
mpScrollButton->changeAnimation(false, 1);
}
if (mbEditScrollDown && getScrollMax() <= mfScroll) {
mbEditScrollDown = false;
mpScrollButton->changeAnimation(true, 2);
}
if (!mbEditScrollDown && getScrollMax() > mfScroll) {
mbEditScrollDown = true;
mpScrollButton->changeAnimation(true, 1);
}
if (mpNigaoeObserver != NULL) mpNigaoeObserver->moveNigaoeButton();
}
}
calcCursorTimer();
}
void InputForm::doAutoScroll() {
if (!mExScrollAnm.isActive() && (meScrollFlag == SF_ScrollOn || meScrollFlag == SF_ScrollByBS)) {
if (meEditMode == EM_Edit) {
f32 lineHeight = getLineHeight();
lineHeight *= 0.5f;
f32 cursorBottom = mfCursorY + lineHeight;
if (mfScroll > cursorBottom) {
int lines = (mfScroll - mfCursorY) / getLineHeight();
mExScrollAnm.startAnm(NULL, mfScroll, mfScroll - lines * getLineHeight(), 15.0f, NULL);
onSE(sound::SE_LINE_SCROLL);
}
if (mfScroll + 2.0f * getLineHeight() < cursorBottom) {
f32 lineHeight = getLineHeight();
int lines = static_cast<int>((cursorBottom - (mfScroll + 2.0f * getLineHeight())) / lineHeight) + 1;
mExScrollAnm.startAnm(NULL, mfScroll, mfScroll + lines * getLineHeight(), 15.0f, NULL);
onSE(sound::SE_LINE_SCROLL);
}
}
meScrollFlag = SF_NoScroll;
}
}
void InputForm::beginDraw(const nw4r::ut::Rect&) {
if (mDrawRect.left == mDrawRect.right) mDrawRect.right += 0.1f;
if (mDrawRect.top == mDrawRect.bottom) mDrawRect.top += 0.1f;
textdrawer::Base::beginDraw(mDrawRect);
}
void InputForm::doScroll(Scroll*) {}
u32 InputForm::calcCursorPos(f32 x, f32 y) {
u32 lines = getLine();
if (lines > muLimitRowNum) lines = muLimitRowNum;
f32 lineHeight = getLineHeight();
f32 cursorY = y + mfScroll;
if (cursorY > lines * lineHeight) return inputform::Base::calcCursorPos(x, lines * getLineHeight());
return inputform::Base::calcCursorPos(x, cursorY);
}
void InputForm::drawCursor(f32 x, f32 y) {
if (meEditMode != EM_Disp) inputform::Base::drawCursor(x, y);
}
nw4r::math::VEC2 InputForm::getScale() const {
if (mpMemoRootPane == NULL) return nw4r::math::VEC2(1.0f, 1.0f);
return mpMemoRootPane->GetScale();
}
void InputForm::drawHeader() {
getPane(scPaneName[0])->Draw(mDrawInfo);
getPane("Nigaoe")->Draw(mDrawInfo);
getPane("T_Nigaoe")->Draw(mDrawInfo);
}
void InputForm::drawBody() {
nw4r::lyt::Pane* body = getPane(scPaneName[1]);
f32 y = 0.0f;
for (int i = 0; i < mnLine; i++) {
body->SetTranslate(nw4r::math::VEC2(0.0f, y));
body->CalculateMtx(mDrawInfo);
body->Draw(mDrawInfo);
y -= body->GetSize().height;
}
if (!mbEdited) getPane("T_TouchLetter")->Draw(mDrawInfo);
}
void InputForm::drawFooter() {
f32 y = (mnLine - 1) * (-1.0f * getPane(scPaneName[1])->GetSize().height);
nw4r::lyt::Pane* footer = getPane(scPaneName[3]);
footer->SetTranslate(nw4r::math::VEC2(0.0f, y));
footer->CalculateMtx(mDrawInfo);
footer->Draw(mDrawInfo);
}
void InputForm::open() {
setScroll(0.0f);
mfScrollFrom = 0.0f;
mfScrollTo = 0.0f;
mpLayout->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, 0.0f));
searchAnmPane("N_Memo")->changeAnimation(1);
searchAnmPane("P_txtScrll_UP")->changeAnimation(7);
searchAnmPane("P_txtScrll_DOWN")->changeAnimation(7);
}
void InputForm::close() {
if (!mbCloseWithSend) searchAnmPane("N_Memo")->changeAnimation(2);
else searchAnmPane("N_Memo")->changeAnimation(3);
if (mbEditScrollUp) {
mpScrollButton->changeAnimation(false, 2);
mbEditScrollUp = false;
}
if (mbEditScrollDown) {
mpScrollButton->changeAnimation(true, 2);
mbEditScrollDown = false;
}
mbGoodBye = true;
}
bool InputForm::isWholePaneInAnimation() {
return searchAnmPane("N_Memo")->isInAnimation();
}
void InputForm::setHeaderCaption(const wchar_t* caption) {
static_cast<nw4r::lyt::TextBox*>(mpLayout->GetRootPane()->FindPaneByName("T_Header", true))->SetString(caption, 0);
}
void InputForm::setMiiName(const wchar_t* name) {
static_cast<nw4r::lyt::TextBox*>(mpLayout->GetRootPane()->FindPaneByName("T_Nigaoe", true))->SetString(name, 0);
}
void InputForm::setTouchLetterCaption(const wchar_t* caption) {
static_cast<nw4r::lyt::TextBox*>(mpLayout->GetRootPane()->FindPaneByName("T_TouchLetter", true))->SetString(caption, 0);
mbEdited = false;
}
nw4r::lyt::Pane* InputForm::getNigaoePane() {
return getPane("Nigaoe");
}
nw4r::lyt::Material* InputForm::getNigaoePaneMaterial() {
return getPane("Nigaoe")->FindMaterialByName("Nigaoe", true);
}
f32 InputForm::getScrollMin() { return 0.0f; }
f32 InputForm::getScrollMax() { return getDrawBoxHeight() - 100.0f; }
f32 InputForm::getDrawBoxHeight() { return mnLine * getLineHeight(); }
void InputForm::onNigaoeButtonTrig() {
if (meEditMode == EM_Disp && mpNigaoeObserver != NULL && mpNigaoeObserver->onNigaoeButton()) onSE(sound::SE_DECIDE);
}
void InputForm::onNigaoeButtonPoint() {
if (meEditMode == EM_Disp) {
searchAnmPane("Nigaoe")->changeAnimation(4);
if (mpNigaoeObserver != NULL) mpNigaoeObserver->pointNigaoeButton();
onSE(sound::SE_BT_TARGETTING);
}
}
void InputForm::onNigaoeButtonLeft() {
if (meEditMode == EM_Disp) {
if (mpNigaoeObserver != NULL) mpNigaoeObserver->leftNigaoeButton();
searchAnmPane("Nigaoe")->changeAnimation(5);
}
}
void InputForm::setDefaultNigaoe() {
getNigaoePaneMaterial()->SetTexture(0, *mpDefaultNigaoe);
}
void InputForm::setEditMode(EditMode mode) {
meEditMode = mode;
switch (mode) {
case EM_Disp: getPane("N_txt_scrl")->SetVisible(false); break;
case EM_Edit: getPane("N_txt_scrl")->SetVisible(true); break;
case EM_Disappear:
onCommand(static_cast<INPUT_COMMAND>(6), NULL);
candidatebox::CandidateBoxCaller::resetCandidate();
candidatebox::CandidateBoxCaller::makeEmptyCandidate();
break;
}
}
void InputForm::preDraw(u32 pos) {
if (meEditMode == EM_Disp) mpSendString->clear();
inputform::Base::preDraw(pos);
}
void InputForm::doLineFeed() {
if (meEditMode == EM_Disp) mpSendString->pushBack(L'\n');
inputform::Base::doLineFeed();
}
void InputForm::put(wchar_t ch) {
if (meEditMode == EM_Disp) mpSendString->pushBack(ch);
textdrawer::Base::put(ch);
}
void InputForm::finishDraw(u32) {
if (meEditMode == EM_Disp) mpSendString->pushBack(0);
}
void WholePane::onAnmEvent(AnmPaneEvent) {}
void EventHandler::onTiEvent(gui::PaneComponent* component, u32 event, Input* input) {
inputform::EventHandler::onTiEvent(component, event, input);
const char* name = component->getPane()->GetName();
if (name[0] == 'B') {
if (event == 4 && (input->field_0x0C & 0x800)) {
if (util::strcmp("B_Nigaoe", name)) mpMemoForm->onNigaoeButtonTrig();
if (util::strcmp("B_ArwR", name)) mpMemoForm->onArrowRTrig();
if (util::strcmp("B_ArwL", name)) mpMemoForm->onArrowLTrig();
}
if (event == 0) {
if (util::strcmp("B_Nigaoe", name)) mpMemoForm->onNigaoeButtonPoint();
if (util::strcmp("B_ArwR", name)) mpMemoForm->onArrowRPoint();
if (util::strcmp("B_ArwL", name)) mpMemoForm->onArrowLPoint();
}
if (event == 1) {
if (util::strcmp("B_Nigaoe", name)) mpMemoForm->onNigaoeButtonLeft();
if (util::strcmp("B_ArwR", name)) mpMemoForm->onArrowRLeft();
if (util::strcmp("B_ArwL", name)) mpMemoForm->onArrowLLeft();
}
}
}
void SimpleAnmPane::changeAnimation(u32 id) { nw4rmanager::AnmPane::changeAnimation(id); }
void SimpleAnmPane::init() {}
void ScrollButton::init() {}
u32 AnmPane::getState() { return meState; }
void AnmPane::changeAnimation(u32 id) {
meState = id;
nw4rmanager::AnmPane::changeAnimation(id);
}
u32 AnmPane::getKeyType() const { return meKeyType; }
void AnmPane::init() { meState = 0; }
void NigaoePane::onAnmEvent(AnmPaneEvent) {}
bool InputForm::isInScroll() { return mExScrollAnm.isActive(); }
}
}
}

1130
src/keyboard/MyTiManager.cpp Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

327
src/keyboard/tiManager.cpp Normal file
View File

@@ -0,0 +1,327 @@
#define TIMANAGER_IMPLEMENTATION
#include "keyboard/tiPcKeyboard.h"
#include "keyboard/tiCellPhone.h"
#include "keyboard/tiInputForm.h"
#include <revolution/sc.h>
#include <new>
namespace textinput {
namespace keyboard {
namespace pctype {
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, accessor, observer, layoutName) {}
virtual ~Sample();
};
}
}
}
namespace textinput {
namespace keyboard {
namespace cellphonetype {
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, accessor, observer, layoutName) {}
virtual ~Sample();
};
}
}
}
namespace textinput {
namespace candidatebox {
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, accessor, observer, layoutName) {}
virtual ~Sample();
};
}
}
namespace textinput {
namespace inputform {
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, accessor, layoutName, observer, NULL) {}
virtual ~Sample();
};
}
}
#include "keyboard/tiToolBar.h"
#include "keyboard/tiPredictLang.h"
namespace textinput { namespace keyboard {
namespace signwindow {
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, accessor, observer, layoutName) {}
virtual ~Sample();
};
}
}}
#include "keyboard/tiManager.h"
namespace textinput {
static EventObserver defaultEventObserver;
Manager::Manager(MEMAllocator* allocator, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer)
: mpAllocator(allocator), mpMultiArcResourceAccessor(accessor), mpEditBuffer(NULL), mpHWKeyboard(NULL), mpPCKeyboard(NULL),
mpCellPhoneKeyboard(NULL), mpInputForm(NULL), mpCandidateBox(NULL), mpToolBar(NULL), mpPredictLanguageDialog(NULL),
mpSignWindow(NULL), mpEventObserver(observer), meDestination(DST_JP), meLanguage(JP), mbAspectRatio4x3(true) {
if (observer == NULL) mpEventObserver = &defaultEventObserver;
}
Manager::~Manager() {
if (mpPCKeyboard) { mpPCKeyboard->~LayoutByNW4R(); MEMFreeToAllocator(mpAllocator, mpPCKeyboard); }
if (mpCellPhoneKeyboard) { mpCellPhoneKeyboard->~LayoutByNW4R(); MEMFreeToAllocator(mpAllocator, mpCellPhoneKeyboard); }
if (mpInputForm) { mpInputForm->~LayoutByNW4R(); MEMFreeToAllocator(mpAllocator, mpInputForm); }
if (mpCandidateBox) { mpCandidateBox->~LayoutByNW4R(); MEMFreeToAllocator(mpAllocator, mpCandidateBox); }
if (mpToolBar) { mpToolBar->~LayoutByNW4R(); MEMFreeToAllocator(mpAllocator, mpToolBar); }
if (mpPredictLanguageDialog) { mpPredictLanguageDialog->~LayoutByNW4R(); MEMFreeToAllocator(mpAllocator, mpPredictLanguageDialog); }
if (mpSignWindow) { mpSignWindow->~LayoutByNW4R(); MEMFreeToAllocator(mpAllocator, mpSignWindow); }
if (mpHWKeyboard) { mpHWKeyboard->~HWKeyboard(); MEMFreeToAllocator(mpAllocator, mpHWKeyboard); }
if (mpEditBuffer) { mpEditBuffer->~EditBuffer(); MEMFreeToAllocator(mpAllocator, mpEditBuffer); }
}
keyboard::hwkey::HWKeyboard::~HWKeyboard() {}
void Manager::create(MEMAllocator*) {
mpEditBuffer = createEditBuffer();
mpEditBuffer->create(mpAllocator);
mpHWKeyboard = createHWKeyboard();
mpPCKeyboard = static_cast<keyboard::pctype::LayoutByNW4R*>(createPCTypeKeyboard());
mpPCKeyboard->create(mpAllocator);
mpCellPhoneKeyboard = static_cast<keyboard::cellphonetype::LayoutByNW4R*>(createCellPhoneTypeKeyboard());
mpCellPhoneKeyboard->create(mpAllocator);
mpInputForm = createInputForm();
mpInputForm->create(mpAllocator, mpEditBuffer);
mpCandidateBox = static_cast<candidatebox::LayoutByNW4R*>(createCandidateBox());
mpCandidateBox->create(mpAllocator);
mpToolBar = static_cast<toolbar::LayoutByNW4R*>(createToolBar());
mpToolBar->create(mpAllocator);
mpPredictLanguageDialog = static_cast<predictlang::LayoutByNW4R*>(createPredictLanguageDialog());
mpPredictLanguageDialog->create(mpAllocator);
mpSignWindow = static_cast<keyboard::signwindow::LayoutByNW4R*>(createSignWindow());
mpSignWindow->create(mpAllocator);
if (SCGetAspectRatio() == 1) { setLayoutScaleFor16x9(); mbAspectRatio4x3 = false; }
else { setLayoutScaleFor4x3(); mbAspectRatio4x3 = true; }
init();
}
void Manager::initAspect() {
if (SCGetAspectRatio() == 1) { setLayoutScaleFor16x9(); mbAspectRatio4x3 = false; }
else { setLayoutScaleFor4x3(); mbAspectRatio4x3 = true; }
}
void Manager::init() {
input::HKBManager::getInstance().ClearState();
mpInputForm->clearSender();
mpHWKeyboard->setCommandReceiver(mpInputForm);
mpPCKeyboard->setCommandReceiver(mpInputForm);
mpCellPhoneKeyboard->setCommandReceiver(mpInputForm);
mpCandidateBox->setCommandReceiver(mpInputForm);
mpPredictLanguageDialog->setCommandReceiver(mpInputForm);
mpSignWindow->setCommandReceiver(mpInputForm);
mpInputForm->setCandidateBox(mpCandidateBox);
mpPCKeyboard->setPredictLanguageDialog(mpPredictLanguageDialog);
mpPCKeyboard->setSignWindow(mpSignWindow);
mpCellPhoneKeyboard->setPredictLanguageDialog(mpPredictLanguageDialog);
mpCellPhoneKeyboard->setSignWindow(mpSignWindow);
if (mbAspectRatio4x3 == true) setLayoutScaleFor4x3();
else setLayoutScaleFor16x9();
mpPredictLanguageDialog->setDestination(meDestination);
mpInputForm->setDestination(meDestination);
mpInputForm->setLanguage(meLanguage);
mpPCKeyboard->setLanguage(meLanguage);
mpCellPhoneKeyboard->setLanguage(meLanguage);
mpSignWindow->setLanguage(meLanguage);
mpCandidateBox->setLanguage(meLanguage);
mpToolBar->setLanguage(meLanguage);
mpPredictLanguageDialog->setLanguage(meLanguage);
mpHWKeyboard->setLanguage(meDestination, meLanguage);
mpHWKeyboard->init();
mpPCKeyboard->init();
mpCellPhoneKeyboard->init();
mpInputForm->init();
mpCandidateBox->init();
mpToolBar->init();
mpPredictLanguageDialog->init();
mpSignWindow->init();
setFixedPredictionJP(0, NULL);
setSecretInputMode(false);
}
void Manager::setFixedPredictionJP(int count, const char** predictions) {
static_cast<tistring::WithAtok*>(getInputForm()->getAtokString())->setFixPrediction(count, predictions);
}
void Manager::calc() {
if (mpToolBar->isQwerty()) mpPCKeyboard->calc();
else mpCellPhoneKeyboard->calc();
static_cast<nw4rmanager::Layout&>(*mpToolBar).calc();
mpCandidateBox->calc();
mpInputForm->calc();
if (mpPredictLanguageDialog->isActive()) static_cast<nw4rmanager::Layout&>(*mpPredictLanguageDialog).calc();
if (mpSignWindow->isActive()) static_cast<nw4rmanager::Layout&>(*mpSignWindow).calc();
}
void Manager::draw() {
GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
mpToolBar->draw();
mpInputForm->draw();
if (mpToolBar->isQwerty()) mpPCKeyboard->draw();
else mpCellPhoneKeyboard->draw();
mpCandidateBox->draw();
if (mpPredictLanguageDialog->isActive()) mpPredictLanguageDialog->draw();
if (mpSignWindow->isActive()) mpSignWindow->draw();
}
bool Manager::updateInput(int channel, f32 x, f32 y, u32 trigger, u32 hold, u32 release) {
bool wasQwerty = mpToolBar->isQwerty();
nw4rmanager::TiEventHandler::Input input;
input.controller = channel;
input.x = x;
input.y = y;
input.trigger = trigger;
input.hold = hold;
input.release = release;
mpHWKeyboard->updateInput(channel, x, y, trigger, hold, release, &input);
bool handled;
if (mpPredictLanguageDialog->isActive()) {
return static_cast<nw4rmanager::Layout&>(*mpPredictLanguageDialog).updateInput(channel, x, y, trigger, hold, release, &input);
}
mpInputForm->updateInputCommon(channel, trigger, hold, release, &input);
if (mpSignWindow->isActive()) {
return mpSignWindow->updateInput(channel, x, y, trigger, hold, release, &input);
} else {
bool keyboardHandled;
if (wasQwerty) keyboardHandled = mpPCKeyboard->updateInput(channel, x, y, trigger, hold, release, &input);
else keyboardHandled = mpCellPhoneKeyboard->updateInput(channel, x, y, trigger, hold, release, &input);
bool toolbarHandled = static_cast<nw4rmanager::Layout&>(*mpToolBar).updateInput(channel, x, y, trigger, hold, release, &input);
bool candidateHandled = static_cast<nw4rmanager::Layout&>(*mpCandidateBox).updateInput(channel, x, y, trigger, hold, release, &input);
bool formHandled = mpInputForm->updateInput(channel, x, y, trigger, hold, release, &input);
handled = (keyboardHandled | candidateHandled) | (formHandled | toolbarHandled);
}
if (wasQwerty != mpToolBar->isQwerty()) {
getInputForm()->onCommand(static_cast<CommandReceiver::INPUT_COMMAND>(6), NULL);
mpCandidateBox->checkValidation();
if (mpToolBar->isQwerty()) mpPCKeyboard->onActive();
else mpCellPhoneKeyboard->onActive();
}
return handled;
}
bool Manager::updateInput(input::HKBManager& keyboard) {
bool wasQwerty = mpToolBar->isQwerty();
bool handled;
if (mpPredictLanguageDialog->isActive()) return static_cast<nw4rmanager::Layout&>(*mpPredictLanguageDialog).updateInput(keyboard);
else if (mpSignWindow->isActive()) return mpSignWindow->updateInput(keyboard);
else {
bool keyboardHandled;
if (wasQwerty) keyboardHandled = mpPCKeyboard->updateInput(keyboard);
else keyboardHandled = mpCellPhoneKeyboard->updateInput(keyboard);
bool toolbarHandled = static_cast<nw4rmanager::Layout&>(*mpToolBar).updateInput(keyboard);
bool candidateHandled = static_cast<nw4rmanager::Layout&>(*mpCandidateBox).updateInput(keyboard);
bool formHandled = mpInputForm->updateInput(keyboard);
handled = (keyboardHandled | candidateHandled) | (formHandled | toolbarHandled);
}
if (wasQwerty != mpToolBar->isQwerty()) {
getInputForm()->onCommand(static_cast<CommandReceiver::INPUT_COMMAND>(6), NULL);
mpCandidateBox->checkValidation();
if (mpToolBar->isQwerty()) mpPCKeyboard->onActive();
else mpCellPhoneKeyboard->onActive();
}
return handled;
}
wchar_t* Manager::getWCString() const { return mpInputForm->getWCString(); }
void Manager::setWCString(const wchar_t* string) { mpInputForm->inputform::Base::setString(string); }
void Manager::setLanguage(Language language) { meLanguage = language; }
void Manager::setDestination(Destination destination) { meDestination = destination; }
void Manager::limitStringLength(u32 length) { mpInputForm->limitStringLength(length); }
void Manager::limitRowNum(u32 rows) { mpInputForm->limitRowNum(rows); }
void Manager::setAnimationOn(bool enabled) {
static_cast<nw4rmanager::Layout&>(*mpPCKeyboard).setAnimOn(enabled);
static_cast<nw4rmanager::Layout&>(*mpCellPhoneKeyboard).setAnimOn(enabled);
static_cast<nw4rmanager::Layout&>(*mpInputForm).setAnimOn(enabled);
static_cast<nw4rmanager::Layout&>(*mpCandidateBox).setAnimOn(enabled);
static_cast<nw4rmanager::Layout&>(*mpToolBar).setAnimOn(enabled);
static_cast<nw4rmanager::Layout&>(*mpPredictLanguageDialog).setAnimOn(enabled);
static_cast<nw4rmanager::Layout&>(*mpSignWindow).setAnimOn(enabled);
}
void Manager::setAspectRatio(bool standard) {
mbAspectRatio4x3 = standard;
if (static_cast<u8>(standard) == true) setLayoutScaleFor4x3();
else setLayoutScaleFor16x9();
}
void Manager::setTitleText(wchar_t* title) {
nw4r::lyt::TextBox* text = nw4r::ut::DynamicCast<nw4r::lyt::TextBox*>(static_cast<nw4rmanager::Layout&>(*mpInputForm).getPane("T_title_text"));
if (text != NULL) text->SetString(title, 0);
}
void Manager::setLayoutScaleFor16x9() {
static_cast<nw4rmanager::Layout&>(*mpPCKeyboard).setRootPaneScaleFor16x9();
static_cast<nw4rmanager::Layout&>(*mpCellPhoneKeyboard).setRootPaneScaleFor16x9();
mpInputForm->setRootPaneScaleFor16x9();
mpCandidateBox->setRootPaneScaleFor16x9();
static_cast<nw4rmanager::Layout&>(*mpToolBar).setRootPaneScaleFor16x9();
static_cast<nw4rmanager::Layout&>(*mpPredictLanguageDialog).setRootPaneScaleFor16x9();
static_cast<nw4rmanager::Layout&>(*mpSignWindow).setRootPaneScaleFor16x9();
}
void Manager::setLayoutScaleFor4x3() {
static_cast<nw4rmanager::Layout&>(*mpPCKeyboard).setRootPaneScaleFor4x3();
static_cast<nw4rmanager::Layout&>(*mpCellPhoneKeyboard).setRootPaneScaleFor4x3();
mpInputForm->setRootPaneScaleFor4x3();
mpCandidateBox->setRootPaneScaleFor4x3();
static_cast<nw4rmanager::Layout&>(*mpToolBar).setRootPaneScaleFor4x3();
static_cast<nw4rmanager::Layout&>(*mpPredictLanguageDialog).setRootPaneScaleFor4x3();
static_cast<nw4rmanager::Layout&>(*mpSignWindow).setRootPaneScaleFor4x3();
}
inputform::EditBuffer* Manager::createEditBuffer() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(inputform::EditBuffer))) inputform::EditBuffer; }
keyboard::hwkey::HWKeyboard* Manager::createHWKeyboard() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(keyboard::hwkey::HWKeyboard))) keyboard::hwkey::HWKeyboard(this); }
void* Manager::createPCTypeKeyboard() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(keyboard::pctype::Sample))) keyboard::pctype::Sample(this, mpMultiArcResourceAccessor, mpEventObserver, "fs_VK_ascii_keytop_a.brlyt"); }
void* Manager::createCellPhoneTypeKeyboard() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(keyboard::cellphonetype::Sample))) keyboard::cellphonetype::Sample(this, mpMultiArcResourceAccessor, mpEventObserver, "fs_VK_cellPhone_a.brlyt"); }
InputForm* Manager::createInputForm() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(inputform::Sample))) inputform::Sample(this, mpMultiArcResourceAccessor, mpEventObserver, "fs_VK_textBox_a.brlyt"); }
void* Manager::createCandidateBox() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(candidatebox::Sample))) candidatebox::Sample(this, mpMultiArcResourceAccessor, mpEventObserver, "fs_VK_predictInput_a.brlyt"); }
void* Manager::createToolBar() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(toolbar::Sample))) toolbar::Sample(this, mpMultiArcResourceAccessor, mpEventObserver, "fs_VK_toolbar_a.brlyt"); }
void* Manager::createPredictLanguageDialog() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(predictlang::Sample))) predictlang::Sample(this, mpMultiArcResourceAccessor, mpEventObserver, "fs_prdicSelWidw_a.brlyt"); }
predictlang::Base::~Base() {}
void* Manager::createSignWindow() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(keyboard::signwindow::Sample))) keyboard::signwindow::Sample(this, mpMultiArcResourceAccessor, mpEventObserver, "fs_signWindow_a.brlyt"); }
void Manager::startPredictTurnOn(bool enabled) {
if (getInputForm()->mbPredictOn != enabled) getCandidateBox()->startTurnOn(enabled);
}
bool Manager::isPredictTurning() const { return getCandidateBox()->getOnOffButton().IsTurning(); }
void Manager::enableCompatibleFilter(bool enabled) { inputform::DeadKeyStream::sbCompatibleFilterEnabled = enabled; }
void Manager::enableKSXFilter(bool enabled) {
static_cast<tistring::Decolated*>(mpEditBuffer->mpString)->EnableKSXFilter(enabled);
static_cast<tistring::Decolated*>(mpEditBuffer->mpZiString)->EnableKSXFilter(enabled);
}
bool Manager::isVacancy() const {
if (!getInputForm() || !getToolBar()) return true;
if (!getToolBar()->isQwerty() && getCellPhoneKeyboard()->isHoldingButton()) return false;
return getInputForm()->inputform::Base::isVacancy();
}
void Manager::SetFont(nw4r::lyt::FontRefLink* link) {
nw4r::ut::Font* font = link->GetFont();
if (mpToolBar) static_cast<nw4rmanager::Layout&>(*mpToolBar).SetFontForce(font);
if (mpPCKeyboard) static_cast<nw4rmanager::Layout&>(*mpPCKeyboard).SetFontForce(font);
if (mpCandidateBox) static_cast<nw4rmanager::Layout&>(*mpCandidateBox).SetFontForce(font);
if (mpSignWindow) static_cast<nw4rmanager::Layout&>(*mpSignWindow).SetFontForce(font);
if (mpInputForm) mpInputForm->nw4r::ut::CharWriter::SetFont(*font);
if (mpCellPhoneKeyboard) static_cast<nw4rmanager::Layout&>(*mpCellPhoneKeyboard).SetFontForce(font);
}
void Manager::setDefaultPredictionJP(int count, const char** predictions) {
static_cast<tistring::WithAtok*>(getInputForm()->getAtokString())->setDefaultPrediction(count, predictions);
}
void predictlang::Base::init() {}
void predictlang::Base::create(MEMAllocator* allocator) { mpAllocator = allocator; }
keyboard::pctype::Sample::~Sample() {}
keyboard::cellphonetype::Sample::~Sample() {}
candidatebox::Sample::~Sample() {}
inputform::Sample::~Sample() {}
toolbar::Sample::~Sample() {}
predictlang::Sample::~Sample() {}
keyboard::signwindow::Sample::~Sample() {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,678 @@
#define TISIGNWINDOW_IMPLEMENTATION
#include "keyboard/tiSignWindow.h"
#include "keyboard/tiManager.h"
#include "keyboard/tiLanguageIndependentData.h"
#include "keyboard/tiUtil.h"
#include <new>
#include <string.h>
#include <wchar.h>
namespace textinput {
namespace keyboard {
namespace signwindow {
struct AnimationFile {
u32 id;
char name[64];
};
struct PaneAnimation {
s32 type;
char paneName[20];
u32 animationCount;
const char* forceName;
const AnimationFile* animations[8];
};
struct PaneControlKey {
char paneName[20];
u32 key;
};
const char* csSgnKeys[20] = {
"P_SGNkey_00", "P_SGNkey_01", "P_SGNkey_02", "P_SGNkey_03", "P_SGNkey_04",
"P_SGNkey_05", "P_SGNkey_06", "P_SGNkey_07", "P_SGNkey_08", "P_SGNkey_09",
"P_SGNkey_10", "P_SGNkey_11", "P_SGNkey_12", "P_SGNkey_13", "P_SGNkey_14",
"P_SGNkey_15", "P_SGNkey_16", "P_SGNkey_17", "P_SGNkey_18", "P_SGNkey_19",
};
static const char* csSgnKeyBase = "P_SGNkey_00";
static const char* csSgnKeyClose = "P_SGNkey_close";
const AnimationFile csAninationFileForSign[9] = {
{0, "fs_signWindow_a_SGN_normal.brlan"},
{1, "fs_signWindow_a_SGN_FADE-IN.brlan"},
{8, "fs_signWindow_a_Scroll_FADE-OUT.brlan"},
{2, "fs_signWindow_a_SGN_Focus-IN.brlan"},
{6, "fs_signWindow_a_SGN_Focus-OUT.brlan"},
{3, "fs_signWindow_a_SGN_Roll_over.brlan"},
{4, "fs_signWindow_a_SGN_Pushed.brlan"},
{7, "fs_signWindow_a_SGN_scroll_next.brlan"},
{5, "fs_signWindow_a_SGN_scroll_prev.brlan"},
};
static const PaneControlKey csPaneNameToControlKey[3] = {
{"B_SGNkey_close", 0x18},
{"B_SGNkey_prev", 0x1A},
{"B_SGNkey_next", 0x19},
};
static const LanguageDependency csLanguageDependencyData[10] = {
{4, csSignKeyJP}, {10, csSignKeyUS}, {10, csSignKeyUK}, {10, csSignKeyFR}, {10, csSignKeyDE},
{10, csSignKeyIT}, {10, csSignKeySP}, {10, csSignKeyNL}, {4, csSignKeyCN}, {4, csSignKeyKR},
};
struct InputCharacter {
wchar_t character;
u16 type;
bool repeat;
u32 value;
};
static const InputCharacter inputCharacterTemplate = {0, 3, false, 0};
static PaneAnimation csPaneToAnimationInSign[25] = {
{0, "N_SGNkeytop_all", 3, 0, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2]}},
{1, "N_SGNkeyall", 3, 0, {&csAninationFileForSign[0], &csAninationFileForSign[7], &csAninationFileForSign[8]}},
{2, "P_SGNkey_00", 7, 0, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_01", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_02", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_03", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_04", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_05", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_06", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_07", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_08", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_09", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_10", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_11", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_12", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_13", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_14", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_15", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_16", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_17", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_18", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_19", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_prev", 7, csSgnKeyClose, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_next", 7, csSgnKeyClose, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_close", 7, 0, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
};
static inline s32 findControlKey(const char* paneName) {
u32 index = 0;
do {
if (util::strcmp(csPaneNameToControlKey[index & 0xFFFF].paneName, paneName))
return csPaneNameToControlKey[index & 0xFFFF].key;
++index;
} while (index < 3);
return 0x1B;
}
static inline wchar_t findSignCharacter(const PaneNameToCharCodeInSignMode* keys, u16 page, const char* paneName) {
u32 index = 0;
do {
if (util::strcmp(keys[index & 0xFFFF].szPaneName, paneName))
return keys[index & 0xFFFF].wc[page];
++index;
} while (index < 20);
return 0;
}
void Base::create(MEMAllocator*) {
muPage = 0;
mbLocked = 0;
mbRepeat = 0;
mpLanguageDependency = &csLanguageDependencyData[getLanguage()];
}
void Base::init() {
muPage = 0;
mbLocked = 0;
mbRepeat = 0;
mpLanguageDependency = &csLanguageDependencyData[getLanguage()];
}
void Base::onKey(u32 command, void* data) {
s32 key;
if (command != 4) {
return;
}
key = findControlKey(static_cast<const char*>(data));
if (key != 0x1B) {
switch (key) {
case 0x18:
close();
break;
case 0x1A:
movePrevSignPage();
break;
case 0x19:
moveNextSignPage();
break;
}
return;
}
u16 code = findSignCharacter(mpLanguageDependency->keys, muPage, static_cast<const char*>(data));
if (code != 0) {
InputCharacter input = inputCharacterTemplate;
input.character = code;
input.repeat = mbRepeat;
if (mpManager->getInputForm()->isAtokActive()) {
input.repeat = true;
}
if (meLanguage - 8U <= 1U) {
input.repeat = 1;
}
sendCommand(5, &input);
}
}
void Base::close() {}
void Base::movePrevSignPage() {
if (muPage == 0) {
muPage = mpLanguageDependency->count - 1;
return;
}
muPage = muPage - 1;
return;
}
void Base::moveNextSignPage() {
u8 page = muPage + 1;
muPage = page;
if (page < mpLanguageDependency->count) {
return;
}
muPage = 0;
return;
}
LayoutByNW4R::~LayoutByNW4R() {
mpEventHandler->~EventHandler();
MEMFreeToAllocator(mpAllocator, mpEventHandler);
AnmPane* pane = static_cast<AnmPane*>(nw4r::ut::List_GetNext(&mAnmPanes, NULL));
while (pane != NULL) {
nw4r::ut::List_Remove(&mAnmPanes, pane);
pane->destroy(mpAllocator);
pane = static_cast<AnmPane*>(nw4r::ut::List_GetNext(&mAnmPanes, NULL));
}
}
Base::~Base() {}
EventHandler::~EventHandler() {}
void LayoutByNW4R::create(MEMAllocator* allocator) {
mpAllocator = allocator;
Base::create(allocator);
void* eventBuffer = MEMAllocFromAllocator(allocator, sizeof(EventHandler));
mpEventHandler = new (eventBuffer) EventHandler(this);
Layout::createWithEventHandler(allocator, mpEventHandler);
mpPaneManager->setAllComponentTriggerTarget(false);
mpPaneManager->setAllBoundingBoxComponentTriggerTarget(true);
const char* forceName;
u32 animationCount;
u32 paneIndex = 0;
do {
AnmPane* pane = NULL;
const PaneAnimation& paneInfo = csPaneToAnimationInSign[paneIndex & 0xFFFF];
switch (paneInfo.type) {
case 2: {
void* paneBuffer = MEMAllocFromAllocator(allocator, sizeof(CellPhoneSignButtonPane));
pane = new (paneBuffer) CellPhoneSignButtonPane(getPane(paneInfo.paneName), this);
break;
}
case 1: {
void* paneBuffer = MEMAllocFromAllocator(allocator, sizeof(CellPhoneSignScrollAnmPane));
pane = new (paneBuffer) CellPhoneSignScrollAnmPane(getPane(paneInfo.paneName), this);
break;
}
case 0: {
void* paneBuffer = MEMAllocFromAllocator(allocator, sizeof(CellPhoneSignAllAnmPane));
pane = new (paneBuffer) CellPhoneSignAllAnmPane(getPane(paneInfo.paneName), this);
break;
}
}
nw4r::ut::List_Append(&mAnmPanes, pane);
forceName = paneInfo.forceName;
animationCount = paneInfo.animationCount;
u16 animationIndex = 0;
while (animationIndex < animationCount) {
void* resource = mpMultiArcResourceAccessor->GetResource(0, paneInfo.animations[animationIndex]->name);
AnimTransformPane* transform = static_cast<AnimTransformPane*>(
getLayout()->CreateAnimTransform(resource, mpMultiArcResourceAccessor));
if (forceName != NULL) {
pane->forceAddAnimation(allocator, paneInfo.animations[animationIndex]->id, transform, forceName, false, true);
} else {
pane->addAnimation(allocator, paneInfo.animations[animationIndex]->id, transform, false, true);
}
++animationIndex;
}
++paneIndex;
} while (paneIndex < 25);
init();
}
AnmPane::~AnmPane() {}
void LayoutByNW4R::init() {
Base::init();
searchAnmPane("N_SGNkeytop_all")->changeAnimation(0);
setVisible("N_SGNkeytop_all", true);
searchAnmPane("P_SGNkey_prev")->changeAnimation(0);
searchAnmPane("P_SGNkey_next")->changeAnimation(0);
setSignKeyTop(muPage, muPage);
setPageNumber(muPage);
mpLayout->Animate(0);
mpLayout->CalculateMtx(mDrawInfo);
}
void LayoutByNW4R::onKey(u32 command, void* data) {
Base::onKey(command, data);
if (command == 4) {
s32 key;
const char* paneName = static_cast<const char*>(data);
key = findControlKey(paneName);
if (key == 0x1B) {
goto character;
}
switch (key) {
case 0x18:
mpEventObserver->onSE(sound::SE_CHAR_DECIDE);
break;
case 0x19:
case 0x1A:
break;
}
return;
character:
u16 code = findSignCharacter(mpLanguageDependency->keys, muPage, paneName);
if ((code != 0) && (mpKeyboard->getType() == 0)) {
sendCommand(0x27, NULL);
}
}
}
void LayoutByNW4R::open(KeyboardBase* keyboard, bool input) {
resetAnmSignWindow();
throwReleaseForAll();
getPaneManager()->init();
if (meLanguage - 8U <= 1U) {
sendCommand(6, NULL);
}
mbActive = 1;
mbInput = 0;
mpKeyboard = keyboard;
initPaneLastDrawReceived();
mbRepeat = input;
setSignKeyTop(muPage, muPage);
setPageNumber(muPage);
searchAnmPane("N_SGNkeytop_all")->onAnmEvent(nw4rmanager::AnmPane::PE_6);
mpEventObserver->onSE(sound::SE_SYMBOL_PAGE_OPEN);
}
void LayoutByNW4R::close() {
if (mpKeyboard->getType() == 0) {
keyboard::pctype::LayoutByNW4R* keyboard = static_cast<keyboard::pctype::LayoutByNW4R*>(mpKeyboard);
static_cast<nw4rmanager::Layout&>(*keyboard).getLayout()->GetRootPane()->SetVisible(true);
}
searchAnmPane("N_SGNkeytop_all")->onAnmEvent(nw4rmanager::AnmPane::PE_7);
mbInput = 0;
}
void LayoutByNW4R::endToClose() {
if (mpKeyboard != NULL) {
mpKeyboard->update();
}
mbActive = 0;
setVisible("N_SGNkeytop_all", false);
}
void LayoutByNW4R::startToInput() {
mbInput = 1;
if (mpKeyboard->getType() == 0) {
keyboard::pctype::LayoutByNW4R* keyboard = static_cast<keyboard::pctype::LayoutByNW4R*>(mpKeyboard);
static_cast<nw4rmanager::Layout&>(*keyboard).getLayout()->GetRootPane()->SetVisible(false);
}
}
void LayoutByNW4R::onChangeAnmState(AnmEvent event, nw4rmanager::AnmPane* pane, nw4rmanager::Anim* anim) {
if (util::strcmp("N_SGNkeyall", pane->getPane()->GetName()) &&
((anim->muID == 7 || anim->muID == 5) && event == nw4rmanager::AnmObserver::E_1)) {
setSignKeyTop(muPage, muPage);
}
if (util::strcmp("N_SGNkeytop_all", pane->getPane()->GetName())) {
if ((anim->muID == 8) && (event == nw4rmanager::AnmObserver::E_1)) {
endToClose();
}
if ((anim->muID == 1) && (event == nw4rmanager::AnmObserver::E_1)) {
startToInput();
}
}
if (anim->muID == 7 || anim->muID == 5) {
if (event == nw4rmanager::AnmObserver::E_0) {
mbLocked = 1;
}
if (event == nw4rmanager::AnmObserver::E_1) {
mbLocked = 0;
}
}
}
void LayoutByNW4R::throwReleaseForAll() {
nw4rmanager::AnmPane* pane = static_cast<nw4rmanager::AnmPane*>(nw4r::ut::List_GetNext(&mAnmPanes, NULL));
while (pane != NULL) {
s32 keyType = static_cast<AnmPane*>(pane)->getKeyType();
if (keyType == 2) {
pane->onAnmEvent(nw4rmanager::AnmPane::PE_2);
}
pane = static_cast<nw4rmanager::AnmPane*>(nw4r::ut::List_GetNext(&mAnmPanes, pane));
}
}
u32 AnmPane::getKeyType() const {
return muKeyType;
}
void LayoutByNW4R::resetAnmSignWindow() {
for (u16 i = 0; i < 25; i++) {
searchAnmPane(csPaneToAnimationInSign[i].paneName)->init();
}
}
void AnmPane::init() {
muAnimation = 0;
}
void LayoutByNW4R::setSignKeyTop(u16 oldPage, u16 newPage) {
char paneName[17];
wchar_t oldCharacter[2];
wchar_t newCharacter[2];
for (u16 i = 0; i < 20; i++) {
const char* sourcePaneName = mpLanguageDependency->keys[i].szPaneName;
memset(paneName, 0, 0x11);
strncpy(paneName, sourcePaneName, strlen(sourcePaneName));
paneName[0] = 'T';
oldCharacter[0] = mpLanguageDependency->keys[i].wc[oldPage];
oldCharacter[1] = 0;
const char* nextPaneName = mpLanguageDependency->keys[i].szNextPaneName;
newCharacter[0] = mpLanguageDependency->keys[i].wc[newPage];
newCharacter[1] = 0;
nw4r::lyt::TextBox* textBox = static_cast<nw4r::lyt::TextBox*>(getPane(paneName));
textBox->SetString(oldCharacter, 0);
textBox = static_cast<nw4r::lyt::TextBox*>(getPane(nextPaneName));
textBox->SetString(newCharacter, 0);
}
setString("T_SGNkey_prev", langindependent::cLanguageIndependentString[langindependent::LANG_STRID_PREV][getLanguage()]);
setString("T_SGNkey_next", langindependent::cLanguageIndependentString[langindependent::LANG_STRID_NEXT][getLanguage()]);
setString("T_SGNkey_close", langindependent::cLanguageIndependentString[langindependent::LANG_STRID_CLOSE][getLanguage()]);
}
void LayoutByNW4R::setPageNumber(u16 page) {
wchar_t text[17];
swprintf(text, 0x11, L"%d/%d", page + 1, mpLanguageDependency->count);
nw4r::lyt::TextBox* textBox = static_cast<nw4r::lyt::TextBox*>(getPane("T_SGN_pageNumber"));
textBox->SetString(text, 0);
}
void LayoutByNW4R::movePrevSignPage() {
u8 oldPage = muPage;
if (oldPage == 0) {
muPage = mpLanguageDependency->count - 1;
} else {
muPage = oldPage - 1;
}
u8 newPage = muPage;
setSignKeyTop(oldPage, newPage);
setPageNumber(newPage);
movePrevSignWindow();
mpEventObserver->onSE(sound::SE_15);
}
void LayoutByNW4R::moveNextSignPage() {
u8 oldPage = muPage;
u8 page = oldPage + 1;
muPage = page;
if (page >= mpLanguageDependency->count) {
muPage = 0;
}
u8 newPage = muPage;
setSignKeyTop(oldPage, newPage);
setPageNumber(newPage);
moveNextSignWindow();
mpEventObserver->onSE(sound::SE_15);
}
void LayoutByNW4R::movePrevSignWindow() {
searchAnmPane("N_SGNkeyall")->onAnmEvent(static_cast<nw4rmanager::AnmPane::AnmPaneEvent>(8));
}
void LayoutByNW4R::moveNextSignWindow() {
searchAnmPane("N_SGNkeyall")->onAnmEvent(static_cast<nw4rmanager::AnmPane::AnmPaneEvent>(9));
}
bool LayoutByNW4R::updateInput(int point, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) {
if (mbInput != 0) {
return nw4rmanager::Layout::updateInput(point, x, y, trig, hold, release, data);
}
return false;
}
bool LayoutByNW4R::updateInput(input::HKBManager& manager) {
if (mbInput == 0) {
return false;
}
input::HKBManager::KeySet keySet = manager.GetTriggeredKeySet();
if (keySet.IsValid()) {
throwReleaseForAll();
close();
mpEventObserver->onSE(sound::SE_CHAR_DECIDE);
return false;
}
return nw4rmanager::Layout::updateInput(manager);
}
void EventHandler::onTiEvent(gui::PaneComponent* paneComponent, u32 event, Input* input) {
s32 eventType = event;
const char* name = paneComponent->getPane()->GetName();
if (!mpLayoutByNW4R->isLocked() || event != 4) {
if (event == 4 && (input->trigger & 0x800) != 0) {
mpLayoutByNW4R->onKey(4, const_cast<char*>(name));
}
if (name[0] == 'B') {
char paneName[24];
memset(paneName, 0, 0x11);
strncpy(paneName, name, strlen(name));
paneName[0] = 'P';
AnmPane* pane = static_cast<AnmPane*>(mpLayoutByNW4R->searchAnmPane(paneName));
if (pane != NULL) {
switch (eventType) {
case 4:
if ((input->trigger & 0x800) != 0) {
pane->onAnmEvent(nw4rmanager::AnmPane::PE_0);
}
break;
case 1:
pane->onAnmEvent(nw4rmanager::AnmPane::PE_2);
break;
case 0:
mpEventObserver->onSE(sound::SE_SELECT);
mpLayoutByNW4R->setPaneLastDrawReceived(pane->getPane());
pane->onAnmEvent(nw4rmanager::AnmPane::PE_1);
break;
}
}
}
}
}
bool Base::isLocked() {
return mbLocked;
}
void CellPhoneSignAllAnmPane::onAnmEvent(AnmPaneEvent event) {
if (event == 6) {
getPane()->SetVisible(true);
changeAnimation(1);
return;
}
if (event == 7) {
changeAnimation(8);
return;
}
if (muAnimation != 8) {
if (muAnimation >= 8) {
return;
}
if (muAnimation != 1) {
return;
}
if (event != 4) {
return;
}
changeAnimation(0);
return;
}
if (event == 4) {
getPane()->SetVisible(false);
}
}
void AnmPane::changeAnimation(u32 animation) {
muAnimation = animation;
nw4rmanager::AnmPane::changeAnimation(animation);
}
void CellPhoneSignScrollAnmPane::onAnmEvent(AnmPaneEvent event) {
switch (muAnimation) {
case 0:
if (event == 9) {
changeAnimation(5);
}
if (event != 8) {
return;
}
changeAnimation(7);
return;
case 5:
case 7:
if (event != 4) {
return;
}
changeAnimation(0);
return;
default:
return;
}
}
void CellPhoneSignButtonPane::onAnmEvent(AnmPaneEvent event) {
if (event == 0) {
changeAnimation(4);
}
switch (muAnimation) {
case 0:
if (event == 1) {
changeAnimation(2);
}
break;
case 2:
if (event == 4) {
changeAnimation(3);
}
if (event == 2) {
changeAnimation(6);
}
break;
case 3:
if (event == 2) {
changeAnimation(6);
}
break;
case 6:
if (event == 4) {
changeAnimation(0);
}
if (event == 1) {
changeAnimation(2);
}
break;
case 4:
if (event == 4) {
changeAnimation(3);
}
if (event == 2) {
changeAnimation(6);
}
break;
}
}
void LayoutByNW4R::draw() {
nw4rmanager::Layout::draw();
}
}
void KeyboardBase::onActive() {}
namespace signwindow {
u8 Base::getPage() {
return muPage;
}
void Base::setPage(u8 page) {
muPage = page;
if (muPage < mpLanguageDependency->count) {
return;
}
muPage = 0;
}
void Base::setLanguage(Language language) {
meLanguage = language;
init();
}
int Base::getType() {
return 2;
}
bool LayoutByNW4R::isActive() {
return mbActive;
}
CellPhoneSignButtonPane::~CellPhoneSignButtonPane() {}
void CellPhoneSignButtonPane::init() {
muAnimation = 0;
}
void CellPhoneSignScrollAnmPane::init() {
muAnimation = 0;
}
CellPhoneSignAllAnmPane::~CellPhoneSignAllAnmPane() {}
void CellPhoneSignAllAnmPane::init() {
muAnimation = 0;
}
CellPhoneSignScrollAnmPane::~CellPhoneSignScrollAnmPane() {}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,147 @@
#define IPL_CHANNEL_TITLE_NOVTABLE
#include "scene/memoryCard/iplGCSaveData.h"
#include "scene/memoryCard/iplMemoryCard.h"
#include "scene/textBalloon/iplBalloon.h"
#include "iplSound.h"
#include "iplSystem.h"
#undef IPL_CHANNEL_TITLE_NOVTABLE
namespace ipl {
namespace scene {
static const MemoryBase::AnmName scAnmName[] = {
{"it_ObjCubeEdit_b_SaveDataIn.brlan", "G_Data"},
{"it_ObjCubeEdit_b_SaveDataOut.brlan", "G_Data"},
{"it_ObjCubeEdit_b_SaveDataFoucusIn.brlan", "G_Data"},
{"it_ObjCubeEdit_b_SaveDataFoucusOut.brlan", "G_Data"},
{"it_ObjCubeEdit_b_SaveDataFlash.brlan", "G_DataFlash"},
};
static const char* scDataPaneName = "B_Data_00";
GCSaveData::GCSaveData(EGG::Heap* heap, nand::LayoutFile* layoutFile, const char* directory, const char* fileName,
math::VEC3 translate) {
mpBalloon = NULL;
mpLayout = new layout::Object(heap, layoutFile, directory, fileName);
add_animation(scAnmName, 5);
mpLayout->finishBinding();
mpEvent = new MemoryBaseEvent(this);
mpPaneManager = new gui::PaneManager(mpEvent, mpLayout->getDrawInfo(), NULL, NULL, true);
mpPaneManager->setupScene(mpLayout);
mpPaneManager->setAllComponentTriggerTarget(false);
mpPaneManager->setTriggerTarget(mpLayout->FindPaneByName(scDataPaneName), true);
add_anmbutton(scDataPaneName, get_animation(2), get_animation(3), NULL);
setTranslate(translate);
}
void GCSaveData::calc() {
mpLayout->calc();
mpPaneManager->calc();
get_anmbutton(scDataPaneName)->calc();
}
void GCSaveData::draw() {
nw4r::lyt::Pane* pane = mpLayout->FindPaneByName("DataBanner_00");
nw4r::lyt::Material* material = pane->FindMaterialByName("DataBanner_00");
pane->SetVisible(true);
if (static_cast<MemoryCard*>(System::getScene(0xE))->getManager()->isIconValidate(mSlot, mIndex) &&
static_cast<MemoryCard*>(System::getScene(0xE))->getManager()->create_icon(mSlot, mIndex) != NULL) {
material->SetTexture(0, *static_cast<MemoryCard*>(System::getScene(0xE))
->getManager()
->create_icon(mSlot, mIndex));
} else {
pane->SetVisible(false);
}
if (mIndex >= 0 && mIndex < 0x7f) {
mpLayout->draw();
} else {
if (mpBalloon != NULL) {
mpBalloon->terminate();
}
}
}
void GCSaveData::update() {
if (mIndex < 0) {
return;
}
if (mIndex >= 0x7f) {
return;
}
mpPaneManager->update();
}
void GCSaveData::onPoint(const char* paneName, controller::Interface* controller) {
AnmButton* button = get_anmbutton(paneName);
if (button != NULL) {
if (button->unk_0x04 == 0) {
if (System::getScene(0xE) != NULL) {
if (static_cast<MemoryCard*>(System::getScene(0xE))
->getManager()
->isIconValidate(mSlot, mIndex)) {
mpBalloon->init(static_cast<MemoryCard*>(System::getScene(0xE))
->getManager()
->getComment(mSlot, mIndex, 0),
0);
get_anmbutton(scDataPaneName)->setBalloon(mpBalloon);
} else {
get_anmbutton(scDataPaneName)->setBalloon(NULL);
}
}
snd::getSystem()->startSE("WIPL_SE_BT_TARGETTING");
if (controller != NULL) {
controller->rumble(0);
}
button->onCmdRecv(1);
}
button->unk_0x04++;
}
}
void GCSaveData::onLeft(const char* paneName) {
AnmButton* button = get_anmbutton(paneName);
if (button != NULL) {
if (button->unk_0x04 == 1) {
button->onCmdRecv(2);
}
button->unk_0x04--;
}
}
void GCSaveData::onTrig(const char* paneName) {
if (static_cast<MemoryCard*>(System::getScene(0xE)) != NULL &&
static_cast<MemoryCard*>(System::getScene(0xE))->getManager()->isIconValidate(mSlot, mIndex) &&
get_anmbutton(paneName) != NULL) {
static_cast<MemoryCard*>(System::getScene(0xE))->onFocus(this);
}
}
void GCSaveData::setTranslate(const nw4r::math::VEC3& translate) {
mpLayout->FindPaneByName("N_Data_00")->SetTranslate(translate);
}
const nw4r::math::VEC3* GCSaveData::getTranslate() {
return &mpLayout->FindPaneByName("N_Data_00")->GetTranslate();
}
void GCSaveData::init() {
clear_button(scDataPaneName);
if (mpBalloon != NULL) {
mpBalloon->terminate();
}
}
void GCSaveData::setBalloon(TextBalloon* balloon) {
mpBalloon = balloon;
}
GCSaveData::~GCSaveData() {}
} // namespace scene
} // namespace ipl

View File

@@ -0,0 +1,912 @@
#define IPL_MEMORYCARD_BASE_CTOR_OUT_OF_LINE
#define IPL_MEMORYCARD_BASE_EVENT_OUT_OF_LINE
#define IPL_GCW_PANEMANAGER_CTOR_OUT_OF_LINE
#define IPL_GCW_INTP_CTOR_OUT_OF_LINE
#define IPL_GC_WINDOW_CPP
#include "scene/memoryCard/iplGCWindow.h"
#include "scene/memoryCard/iplMemoryCard.h"
#include "scene/settingSelect/iplSettingButton.h"
#include "iplSound.h"
#include "iplSystem.h"
#include "system/iplDialogWindow.h"
#include "system/iplHomeButton.h"
#include <wchar.h>
#include <cstring>
namespace ipl {
namespace math {
template <typename T>
LinearIntp<T>::LinearIntp() {}
}
namespace scene {
struct TextboxToMessageID {
const char* name;
u32 id;
};
static const MemoryBase::AnmName scAnmName[16] = {
{"it_CubeDetail_a_SeenIn.brlan", "G_Mask"},
{"it_CubeDetail_a_SeenOut.brlan", "G_Mask"},
{"it_CubeDetail_a_MoveFoucusIn.brlan", "G_Move"},
{"it_CubeDetail_a_MoveFoucusOut.brlan", "G_Move"},
{"it_CubeDetail_a_MoveFlash.brlan", "G_MoveFlash"},
{"it_CubeDetail_a_CopyFoucusIn.brlan", "G_Copy"},
{"it_CubeDetail_a_CopyFoucusOut.brlan", "G_Copy"},
{"it_CubeDetail_a_CopyFlash.brlan", "G_CopyFlash"},
{"it_CubeDetail_a_DelFoucusIn.brlan", "G_Del"},
{"it_CubeDetail_a_DelFoucusOut.brlan", "G_Del"},
{"it_CubeDetail_a_DelFlash.brlan", "G_DelFlash"},
{"it_CubeDetail_a_SelectOut.brlan", "G_Select"},
{"it_CubeDetail_a_SeenOutYes.brlan", "G_Mask"},
{"it_CubeDetail_a_SeenOutYesOk.brlan", "G_Mask"},
{"it_CubeDetail_a_SeenOutNo.brlan", "G_Mask"},
{"it_CubeDetail_a_Wait.brlan", "G_Wait"},
};
static const TextboxToMessageID scTextboxToMessageID[3] = {
{"T_Move_00", 0xA7},
{"T_Copy_00", 0xB2},
{"T_Del_00", 0xBD},
};
static const char* scButtonName[3] = {"B_Move_00", "B_Copy_00", "B_Del_00"};
GCWindow::GCWindow(EGG::Heap* heap, nand::LayoutFile* layoutFile, const char* directory, const char* fileName)
: MemoryBase(), MemCardEventHandler(), mState(0), mLinearInterp(), mCardState(0), mCardIndex(0), mOperation(0), mActive(false),
mWaiting(false) {
mpLayout = new layout::Object(heap, layoutFile, directory, fileName);
add_animation(scAnmName, 0x10);
mpLayout->finishBinding();
set_visible("N_Wait", false);
mpEvent = new MemoryBaseEvent(this);
mpPaneManager = new gui::PaneManager(mpEvent, mpLayout->getDrawInfo(), NULL, NULL, true);
mpPaneManager->createLayoutScene(*mpLayout->getNW4RLyt());
mpPaneManager->setAllComponentTriggerTarget(false);
for (int i = 0; i < 3; i++) {
mpPaneManager->setTriggerTarget(mpLayout->getNW4RLyt()->GetRootPane()->FindPaneByName(scButtonName[i], true), true);
}
add_anmbutton(scButtonName[0], get_animation(2), get_animation(3), get_animation(4));
add_anmbutton(scButtonName[1], get_animation(5), get_animation(6), get_animation(7));
add_anmbutton(scButtonName[2], get_animation(8), get_animation(9), get_animation(10));
for (int i = 0; i < 3; i++) {
set_textbox(scTextboxToMessageID[i].name, scTextboxToMessageID[i].id);
}
for (int i = 0; i < 2; i++) {
mFlags0[i] = 0;
mFlags1[i] = 0;
}
}
MemoryBase::MemoryBase() : mpLayout(NULL), unk_0x08(NULL) {
nw4r::ut::List_Init(&mAnmList, offsetof(Anm, mLink));
nw4r::ut::List_Init(&mButtonList, offsetof(Button, mLink));
nw4r::ut::List_Init(&mAnmButtonList, offsetof(AnmButton, mLink));
}
MemCardEventHandler::~MemCardEventHandler() {}
MemoryBaseEvent::MemoryBaseEvent(MemoryBase* memoryBase) : mpBase(memoryBase) {}
void GCWindow::init(const math::VEC3& translate, MemoryCardManager* manager, u8 cardState, short cardIndex) {
mActive = true;
mFlags1[cardState] = 0;
set_visible("N_Banner", true);
mpMemoryCardManager = manager;
mpMemoryCardManager->setEventHandler(this);
mCardState = cardState;
mCardIndex = cardIndex;
set_textbox("T_Title_00", mpMemoryCardManager->getComment(cardState, cardIndex, 0), 450.0f, 31.0f);
set_textbox("T_Title_01", mpMemoryCardManager->getComment(cardState, cardIndex, 1), 450.0f, 31.0f);
int i = 0;
for (i = 0; i < 3; i++) {
mpPaneManager->initPane(mpLayout->getNW4RLyt()->GetRootPane()->FindPaneByName(scButtonName[i], true));
}
int blocks = mpMemoryCardManager->getBlocks(cardState, cardIndex);
wchar_t digits[10] = {L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9'};
int blockCount = static_cast<u16>(blocks);
wchar_t decimal[5] = {0};
int skipCount = 0;
wchar_t blockText[5] = {0};
decimal[0] = digits[blockCount / 1000];
decimal[1] = digits[(blockCount / 100) % 10];
decimal[2] = digits[(blockCount / 10) % 10];
decimal[3] = digits[blockCount % 10];
for (i = 0; i < 3; i++) {
if (decimal[i] != L'0') {
break;
}
skipCount++;
}
wcscpy(blockText, decimal + skipCount);
set_textbox("T_Block_00", blockText);
mTranslate = translate;
math::VEC3 zero(0.0f, 0.0f, 0.0f);
mLinearInterp.init(ANIM_TYPE_FORWARD, 12.0f, 0.0f, mTranslate, zero, 1.0f);
mLinearInterp.initFrame();
mLinearInterp.restart();
math::VEC3 position = mLinearInterp.get();
mpLayout->FindPaneByName("N_Window")->SetTranslate(position);
do_animation(0);
mState = 1;
}
void GCWindow::calc() {
mpLayout->calc();
mpPaneManager->calc();
void* button = NULL;
while ((button = nw4r::ut::List_GetNext(&mAnmButtonList, button)) != NULL) {
((MemoryBase::AnmButton*)button)->calc();
}
switch (mState) {
case 0:
on_wait();
break;
case 1:
on_fadein();
break;
case 2:
on_normal();
break;
case 3:
on_fadeout1st();
break;
case 4:
if (!is_animation(1)) {
destroy();
}
break;
case 5:
on_fadeout_yes1st();
break;
case 6:
if (!is_animation(0xd)) {
destroy();
}
break;
case 7:
if (!is_animation(0xe)) {
destroy();
}
break;
case 8:
on_focus_move();
break;
case 9:
on_focus_copy();
break;
case 10:
on_focus_del();
break;
case 0xb:
on_select_out();
break;
case 0xc:
on_dialog();
break;
case 0xd:
on_error_message();
break;
case 0xe:
on_error_message1st();
break;
case 0xf:
on_error_message2nd();
break;
case 0x10:
on_error_message3rd();
break;
case 0x11:
on_process();
break;
case 0x12:
on_format1st();
break;
case 0x13:
on_format2nd();
break;
case 0x14:
on_format3rd();
break;
case 0x15:
on_format4th();
break;
case 0x16:
on_format_error();
break;
}
}
void GCWindow::draw() {
mpLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("Banner_00", true)->SetVisible(false);
mpLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("Banner_01", true)->SetVisible(false);
if (mpMemoryCardManager->isIconValidate(mCardState, mCardIndex)) {
if (mpMemoryCardManager->isBannerEnable(mCardState, mCardIndex)) {
const GXTexObj* banner = mpMemoryCardManager->create_banner(mCardState, mCardIndex);
if (banner != NULL) {
set_texture("Banner_00", *banner);
mpLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("Banner_00", true)->SetVisible(true);
}
} else {
const GXTexObj* icon = mpMemoryCardManager->create_icon(mCardState, mCardIndex, 0);
if (icon != NULL) {
set_texture("Banner_01", *icon);
mpLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("Banner_01", true)->SetVisible(true);
}
}
}
mpLayout->draw();
}
void GCWindow::destroy() {
((MemoryCard*)System::getScene(0xe))->onRelease();
for (int i = 0; i < 3; i++) {
clear_button(scButtonName[i]);
}
System::getHomeButtonMenu()->enable();
mWaiting = false;
show_button_return();
mActive = false;
mState = 0;
}
void GCWindow::onPoint(const char* name, controller::Interface* controller) {
MemoryBase::AnmButton* button = get_anmbutton(name);
if (button != NULL) {
if (button->unk_0x04 == 0) {
button->onCmdRecv(1);
snd::sSystem.startSE("WIPL_SE_BT_TARGETTING");
if (controller != NULL) {
controller->rumble(0);
}
}
button->unk_0x04++;
}
}
void GCWindow::onLeft(const char* name) {
MemoryBase::AnmButton* button = get_anmbutton(name);
if (button != NULL) {
if (button->unk_0x04 == 1) {
button->onCmdRecv(2);
}
button->unk_0x04--;
}
}
void GCWindow::onTrig(const char* name) {
MemoryBase::AnmButton* button = get_anmbutton(name);
if (button != NULL) {
if (strcmp(name, scButtonName[0]) == 0) {
do_animation(4);
mState = 8;
} else if (strcmp(name, scButtonName[1]) == 0) {
do_animation(7);
mState = 9;
} else if (strcmp(name, scButtonName[2]) == 0) {
do_animation(10);
set_textbox("T_Message_00", 0xf7);
mState = 10;
}
snd::sSystem.startSE("WIPL_SE_DECIDE");
}
}
void GCWindow::on_wait() {
for (int i = 0; i < 2; i++) {
if (mFlags0[i] != 0) {
((MemoryCard*)System::getScene(0xe))->onFocus(NULL);
System::getDialog()->callBtn2(i == 0 ? 0xec : 0xed, 0x142, 0x141, true);
mFlags0[i] = 0;
mCardState = i;
mState = 0x12;
break;
}
}
}
void GCWindow::on_fadein() {
mLinearInterp.calc();
mpLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("N_Window", true)->SetTranslate(mLinearInterp.get());
if (!is_animation(0)) {
mState = 2;
}
}
void GCWindow::on_normal() {
if (mActive) {
if (get_setting_button()->update()) {
change_button_text_return();
mState = 3;
} else {
mpPaneManager->update();
}
}
}
void GCWindow::on_fadeout1st() {
if (!get_setting_button()->isPlaying()) {
math::VEC3 zero(0.0f, 0.0f, 0.0f);
mLinearInterp.init(ANIM_TYPE_FORWARD, 20.0f, 0.0f, mTranslate, zero);
mLinearInterp.setAnmType(ANIM_TYPE_BACKWARD);
mLinearInterp.initFrame();
mLinearInterp.restart();
do_animation(1);
mState = 4;
}
}
void GCWindow::on_fadeout_yes1st() {
change_textbox_done();
if (!is_animation(0xc)) {
math::VEC3 zero(0.0f, 0.0f, 0.0f);
mLinearInterp.init(ANIM_TYPE_FORWARD, 20.0f, 0.0f, mTranslate, zero);
mLinearInterp.setAnmType(ANIM_TYPE_BACKWARD);
mLinearInterp.initFrame();
mLinearInterp.restart();
show_button_return();
do_animation(0xd);
mState = 6;
}
}
void GCWindow::on_focus_move() {
if (!is_animation(4)) {
do_animation(0xb, false);
long error;
if (mpMemoryCardManager->isMoveEnable(mCardState, mCardIndex, &error)) {
set_textbox("T_Message_00", mCardState == 0 ? 0xf5 : 0xf3);
mOperation = 2;
mState = 0xb;
} else {
switch (error) {
case -26:
set_textbox("T_Message_00", 0xcd);
break;
case -23:
set_textbox("T_Message_00", 0xce + (mCardState == 0));
break;
case -28:
case -22:
set_textbox("T_Message_00", 0xd0 + (mCardState == 0));
break;
case -27:
set_textbox("T_Message_00", 0xd4);
break;
case -24:
set_textbox("T_Message_00", 0xd5);
break;
case -25:
set_textbox("T_Message_00", 0xd6);
break;
}
change_button_text_ok();
mState = 0xf;
}
}
}
void GCWindow::on_focus_copy() {
if (!is_animation(7)) {
do_animation(0xb, false);
long error;
if (mpMemoryCardManager->isCopyEnable(mCardState, mCardIndex, &error)) {
set_textbox("T_Message_00", mCardState == 0 ? 0xf6 : 0xf4);
mOperation = 1;
mState = 0xb;
} else {
switch (error) {
case -26:
set_textbox("T_Message_00", 0xd9);
break;
case -23:
set_textbox("T_Message_00", 0xda + (mCardState == 0));
break;
case -28:
case -22:
set_textbox("T_Message_00", 0xdc + (mCardState == 0));
break;
case -27:
set_textbox("T_Message_00", 0xe0);
break;
case -24:
set_textbox("T_Message_00", 0xe1);
break;
case -25:
set_textbox("T_Message_00", 0xe2);
break;
}
change_button_text_ok();
mState = 0xf;
}
}
}
void GCWindow::on_focus_del() {
if (!is_animation(10)) {
mOperation = 3;
do_animation(0xb, false);
mState = 0xb;
}
}
void GCWindow::on_select_out() {
if (!is_animation(0xb)) {
System::getDialog()->callS2Btn2(0x142, 0x141, true);
get_setting_button()->hideBtn();
mState = 0xc;
}
}
void GCWindow::on_dialog() {
int result = System::getDialog()->getLastResult();
long error;
if (result != 2) {
if (result < 2) {
if (result < 1) {
return;
}
} else if (result != 6) {
return;
}
goto cancel_dialog;
}
{
switch (mOperation) {
case 1:
if (mpMemoryCardManager->isCopyEnable(mCardState, mCardIndex, &error)) {
set_visible("N_Wait", true);
do_animation(0xf);
snd::sSystem.startSE("WIPL_SE_COPYING");
mpMemoryCardManager->sendCardCmdCopy(mCardState, mCardIndex);
} else {
switch (error) {
case -26:
set_textbox("T_Message_00", 0xd9);
break;
case -23:
set_textbox("T_Message_00", 0xda + (mCardState == 0));
break;
case -28:
case -22:
set_textbox("T_Message_00", 0xdc + (mCardState == 0));
break;
case -27:
set_textbox("T_Message_00", 0xe0);
break;
case -24:
set_textbox("T_Message_00", 0xe1);
break;
case -25:
set_textbox("T_Message_00", 0xe2);
break;
}
change_button_text_ok();
mState = 0xf;
return;
}
break;
case 3:
set_visible("N_Banner", false);
mpMemoryCardManager->sendCardCmdDelete(mCardState, mCardIndex);
break;
case 2:
if (mpMemoryCardManager->isMoveEnable(mCardState, mCardIndex, &error)) {
set_visible("N_Banner", false);
set_visible("N_Wait", true);
do_animation(0xf);
snd::sSystem.startSE("WIPL_SE_COPYING");
mpMemoryCardManager->sendCardCmdMove(mCardState, mCardIndex);
} else {
switch (error) {
case -26:
set_textbox("T_Message_00", 0xcd);
break;
case -23:
set_textbox("T_Message_00", 0xce + (mCardState == 0));
break;
case -28:
case -22:
set_textbox("T_Message_00", 0xd0 + (mCardState == 0));
break;
case -27:
set_textbox("T_Message_00", 0xd4);
break;
case -24:
set_textbox("T_Message_00", 0xd5);
break;
case -25:
set_textbox("T_Message_00", 0xd6);
break;
}
change_button_text_ok();
mState = 0xf;
return;
}
break;
}
if ((u32)mOperation - 1 <= 1) {
do_animation(0xc);
}
System::getHomeButtonMenu()->disable();
mWaiting = true;
mState = 0x11;
return;
}
cancel_dialog:
do_animation(0xb, true);
mState = 2;
get_setting_button()->showBtn();
}
void GCWindow::on_error_message() {
if (System::getDialog()->getLastResult() >= 0) {
destroy();
}
}
void GCWindow::on_process() {
change_textbox_doing();
if (!is_animation(0xc) && !mWaiting) {
stop_wait_anim();
System::getHomeButtonMenu()->enable();
mWaiting = false;
do_animation(0xc);
mState = 5;
}
}
void GCWindow::on_error_message1st() {
if (!is_animation(0xb) && get_setting_button()->update()) {
for (int i = 0; i < 3; i++) {
clear_button(scButtonName[i]);
}
do_animation(0xb, true);
mState = 0x10;
change_button_text_close();
}
}
void GCWindow::on_error_message2nd() {
if (!is_animation(0xb) && get_setting_button()->update()) {
for (int i = 0; i < 3; i++) {
clear_button(scButtonName[i]);
}
do_animation(0xb, true);
mState = 0x10;
change_button_text_close();
}
}
void GCWindow::on_error_message3rd() {
if (mFlags1[mCardState] != 0) {
goto fadeout;
}
if (mOperation != 2) {
goto check_animation;
}
fadeout:
mState = 3;
return;
check_animation:
if (!is_animation(0xb)) {
mState = 2;
}
}
void GCWindow::on_format1st() {
int result = System::getDialog()->getLastResult();
switch (result) {
case 1:
case 6:
destroy();
break;
case 2:
System::getDialog()->callBtn2(0xee, 0x142, 0x141, true);
mState = 0x13;
break;
}
}
void GCWindow::on_format2nd() {
int result = System::getDialog()->getLastResult();
switch (result) {
case 1:
case 6:
destroy();
break;
case 2:
mOperation = 4;
mpMemoryCardManager->sendCardCmdFormat(mCardState);
System::getHomeButtonMenu()->disable();
mWaiting = true;
mState = 0x14;
break;
}
}
void GCWindow::on_format3rd() {
if (!mWaiting) {
System::getDialog()->callBtn0(0xf0, 0xb4, false);
mState = 0x15;
}
}
void GCWindow::on_format4th() {
if (System::getDialog()->getLastResult() >= 0) {
destroy();
}
}
void GCWindow::on_format_error() {
if (System::getDialog()->getLastResult() >= 0) {
destroy();
}
}
void GCWindow::change_textbox_doing() {
switch (mOperation) {
case 2:
set_textbox("T_Message_00", 0xfa, 0xc, 0x14);
break;
case 1:
set_textbox("T_Message_00", 0xf9, 0xc, 0x14);
break;
case 3:
set_textbox("T_Message_00", 0xfb, 0xc, 0x14);
break;
}
}
void GCWindow::change_textbox_done() {
switch (mOperation) {
case 2:
set_textbox("T_Message_00", 0x10d, 0xc, 0x14);
break;
case 1:
set_textbox("T_Message_00", 0x107, 0xc, 0x14);
break;
case 3:
set_textbox("T_Message_00", 0xf8, 0xc, 0x14);
break;
}
}
void GCWindow::set_texture(const char* name, const GXTexObj& texture) {
nw4r::lyt::Pane* pane = mpLayout->getNW4RLyt()->GetRootPane()->FindPaneByName(name, true);
nw4r::lyt::Material* material = pane->FindMaterialByName(name, true);
material->SetTexture(0, texture);
}
void GCWindow::onMemEvent(long event, u8 cardState) {
if (event - 1U <= 3) {
System::getHomeButtonMenu()->enable();
mWaiting = false;
} else if (event == 0) {
mFlags0[cardState] = 1;
} else if (event == 6) {
mFlags1[cardState] = 1;
mFlags0[cardState] = 0;
switch (mState) {
case 0xe:
case 0xf:
if (mCardState == cardState) {
set_visible("N_Banner", false);
}
break;
case 0x12:
case 0x13:
if (mCardState == cardState) {
System::getDialog()->terminate();
mState = 3;
}
break;
case 0xc:
if (mCardState == cardState) {
System::getDialog()->terminate();
mState = 3;
} else if (mState - 1U <= 1) {
System::getDialog()->terminate();
set_textbox("T_Message_00", 0xda + (mCardState == 0));
show_button_ok();
mState = 0xe;
}
break;
case 0x14:
if (mCardState == cardState) {
System::getDialog()->callBtn0(0xf1, 0xb4, false);
mState = 0x16;
}
break;
case 2:
case 8:
case 9:
case 10:
if (mCardState == cardState) {
mState = 3;
}
break;
case 0x11:
switch (mOperation) {
case 2:
stop_wait_anim();
set_textbox("T_Message_00", 0xd7);
break;
case 1:
stop_wait_anim();
set_textbox("T_Message_00", 0xe3);
break;
case 3:
if (mCardState != cardState) {
return;
}
set_textbox("T_Message_00", 0xe5);
break;
}
goto process_complete;
case 0x15:
return;
process_complete:
System::getHomeButtonMenu()->enable();
mWaiting = false;
show_button_ok();
mState = 0xe;
break;
}
}
}
bool GCWindow::isProcess() {
return mWaiting;
}
void GCWindow::stop_wait_anim() {
set_visible("N_Wait", false);
MemoryBase::Anm* animation = get_animation(0xf);
animation->mAnim->stop();
snd::sSystem.startSE("WIPL_SE_COPY_FINISH");
}
SavedataEditWindow::SavedataEditWindow(EGG::Heap* heap, nand::LayoutFile* layoutFile,
const char* directory, const char* fileName)
: mState(0), mActive(false) {
mpLayout = new layout::Object(heap, layoutFile, directory, fileName);
add_animation("it_DataDetail_a_SeenIn.brlan", scAnmName[0].groupName);
add_animation("it_DataDetail_a_SeenOut.brlan", scAnmName[0].groupName);
add_animation("it_DataDetail_a_DelFoucusIn.brlan", scAnmName[8].groupName);
add_animation("it_DataDetail_a_DelFoucusOut.brlan", scAnmName[8].groupName);
add_animation("it_DataDetail_a_DelFlash.brlan", scAnmName[10].groupName);
add_animation("it_DataDetail_a_SelectOut.brlan", scAnmName[11].groupName);
add_animation("it_DataDetail_a_SeenOutYes.brlan", scAnmName[0].groupName);
add_animation("it_DataDetail_a_SeenOutYesOk.brlan", scAnmName[0].groupName);
add_animation("it_DataDetail_a_SeenOutNo.brlan", scAnmName[0].groupName);
add_animation("it_DataDetail_a_Wait.brlan", scAnmName[15].groupName);
mpLayout->finishBinding();
set_visible("N_Wait", false);
set_visible("T_Block_01", false);
mpEvent = new MemoryBaseEvent(this);
mpPaneManager = new gui::PaneManager(mpEvent, mpLayout->getDrawInfo(), NULL, NULL, true);
mpPaneManager->setupScene(mpLayout);
mpPaneManager->setAllComponentTriggerTarget(false);
mpPaneManager->setTriggerTarget(mpLayout->FindPaneByName(scButtonName[2]), true);
add_anmbutton(scButtonName[2], get_animation(2), get_animation(3), get_animation(4));
set_textbox("T_Del_00", 0xbd);
}
void SavedataEditWindow::calc() {
mpLayout->calc();
mpPaneManager->calc();
void* button = NULL;
while ((button = nw4r::ut::List_GetNext(&mAnmButtonList, button)) != NULL) {
((MemoryBase::AnmButton*)button)->calc();
}
switch (mState) {
case 0:
on_normal();
break;
case 1:
on_fadein();
break;
case 2:
on_fadeout1st();
break;
case 3:
if (!is_animation(1)) {
destroy();
}
break;
case 4:
on_fadeout_yes1st();
break;
case 5:
if (!is_animation(7)) {
destroy();
}
break;
case 6:
if (!is_animation(8)) {
destroy();
}
break;
case 7:
on_focus_del();
break;
case 8:
on_select_out();
break;
case 9:
case 10:
case 11:
case 12:
break;
}
}
void SavedataEditWindow::on_normal() {
if (mActive) {
if (get_setting_button()->update()) {
change_button_text_return();
mState = 2;
} else {
mpPaneManager->update();
}
}
}
void SavedataEditWindow::on_fadein() {
mLinearInterp.calc();
mpLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("N_Window", true)->SetTranslate(mLinearInterp.get());
if (!is_animation(0)) {
mState = 0;
}
}
void SavedataEditWindow::on_fadeout1st() {
if (!get_setting_button()->isPlaying()) {
math::VEC3 zero(0.0f, 0.0f, 0.0f);
mLinearInterp.init(ANIM_TYPE_FORWARD, 20.0f, 0.0f, mTranslate, zero);
mLinearInterp.setAnmType(ANIM_TYPE_BACKWARD);
mLinearInterp.initFrame();
mLinearInterp.restart();
do_animation(1);
mState = 3;
}
}
void SavedataEditWindow::on_focus_del() {
if (!is_animation(4)) {
do_animation(5, false);
mState = 8;
}
}
void SavedataEditWindow::on_select_out() {
if (!is_animation(5)) {
System::getDialog()->callS2Btn2(0x142, 0x141, true);
get_setting_button()->hideBtn();
mState = 9;
}
}
void SavedataEditWindow::on_fadeout_yes1st() {
set_textbox("T_Message_00", 0xf8, 6, 0x14);
if (!is_animation(6)) {
math::VEC3 zero(0.0f, 0.0f, 0.0f);
mLinearInterp.init(ANIM_TYPE_FORWARD, 20.0f, 0.0f, mTranslate, zero);
mLinearInterp.setAnmType(ANIM_TYPE_BACKWARD);
mLinearInterp.initFrame();
mLinearInterp.restart();
get_setting_button()->setText(0x13b);
get_setting_button()->showBtn();
do_animation(7);
mState = 5;
}
}
GCWindow::~GCWindow() {}
}
}

View File

@@ -0,0 +1,706 @@
#define IPL_MEMORY_CARD_CPP
#define IPL_MEMORYCARD_BASE_OUT_OF_LINE
#define IPL_CHANNEL_TITLE_NOVTABLE
#include "scene/memoryCard/iplMemoryCard.h"
#undef IPL_CHANNEL_TITLE_NOVTABLE
#include "scene/memoryCard/iplGCWindow.h"
#include "scene/memoryCard/iplGCSaveData.h"
#include <cstring>
#include <cwchar>
#include "iplSystem.h"
#include "scene/iplSceneCreator.h"
#include "scene/settingSelect/iplSettingButton.h"
#include "scene/settingSelect/iplSettingSelect.h"
#include "scene/textBalloon/iplBalloon.h"
#include "private/card.h"
#include "sound/iplSound.h"
#include "system/iplController.h"
#include "system/iplNandManager.h"
#include "utility/iplGraphics.h"
namespace ipl {
namespace scene {
static const char* scSavedataPaneName[] = {
"N_Data_a_00", "N_Data_a_01", "N_Data_a_02", "N_Data_a_03", "N_Data_a_04",
"N_Data_a_05", "N_Data_a_06", "N_Data_a_07", "N_Data_a_08", "N_Data_a_09",
"N_Data_a_10", "N_Data_a_11", "N_Data_a_12", "N_Data_a_13", "N_Data_a_14",
"N_Data_b_00", "N_Data_b_01", "N_Data_b_02", "N_Data_b_03", "N_Data_b_04",
"N_Data_b_05", "N_Data_b_06", "N_Data_b_07", "N_Data_b_08", "N_Data_b_09",
"N_Data_b_10", "N_Data_b_11", "N_Data_b_12", "N_Data_b_13", "N_Data_b_14",
"N_Data_c_00", "N_Data_c_01", "N_Data_c_02", "N_Data_c_03", "N_Data_c_04",
"N_Data_c_05", "N_Data_c_06", "N_Data_c_07", "N_Data_c_08", "N_Data_c_09",
"N_Data_c_10", "N_Data_c_11", "N_Data_c_12", "N_Data_c_13", "N_Data_c_14",
};
static const MemoryBase::AnmName scAnmName[] = {
{"it_ObjCubeEdit_a_CubeSwitch.brlan", "G_Switch"},
{"it_ObjCubeEdit_a_DataIn.brlan", "G_DataAll"},
{"it_ObjCubeEdit_a_SelectIn.brlan", "G_SelectWii"},
{"it_ObjCubeEdit_a_SelectIn.brlan", "G_SelectSd"},
{"it_ObjCubeEdit_a_DataOut.brlan", "G_DataAll"},
{"it_ObjCubeEdit_a_SelectIn.brlan", "G_Select"},
{"it_ObjCubeEdit_a_SelectWiiFoucusIn.brlan", "G_SelectWii"},
{"it_ObjCubeEdit_a_SelectWiiFoucusOut.brlan", "G_SelectWii"},
{"it_ObjCubeEdit_a_SelectWiiFlash.brlan", "G_Select"},
{"it_ObjCubeEdit_a_SelectSdIn.brlan", "G_SelectSd"},
{"it_ObjCubeEdit_a_SelectSdOut.brlan", "G_SelectSd"},
{"it_ObjCubeEdit_a_SelectSdFlash.brlan", "G_Select"},
{"it_ObjCubeEdit_a_ArwL1.brlan", "G_Arw"},
{"it_ObjCubeEdit_a_AwrR1.brlan", "G_Arw"},
{"it_ObjCubeEdit_a_Select.brlan", "G_ArwR_Ac"},
{"it_ObjCubeEdit_a_Select.brlan", "G_ArwL_Ac"},
{"it_ObjCubeEdit_a_FocusOn.brlan", "G_ArwR_Focus"},
{"it_ObjCubeEdit_a_FocusOn.brlan", "G_ArwL_Focus"},
{"it_ObjCubeEdit_a_FocusOff.brlan", "G_ArwR_Focus"},
{"it_ObjCubeEdit_a_FocusOff.brlan", "G_ArwL_Focus"},
{"it_ObjCubeEdit_a_Loop.brlan", "G_ArwRoop"},
{"it_ObjCubeEdit_a_Appear.brlan", "G_ArwR_End"},
{"it_ObjCubeEdit_a_Appear.brlan", "G_ArwL_End"},
{"it_ObjCubeEdit_a_Lost.brlan", "G_ArwR_End"},
{"it_ObjCubeEdit_a_Lost.brlan", "G_ArwL_End"},
{"it_ObjCubeEdit_a_ErrorTxtIn.brlan", "G_ErrorTxt"},
{"it_ObjCubeEdit_a_ErrorTxtOut.brlan", "G_ErrorTxt"},
};
struct TextboxMessage {
const char* paneName;
u32 messageId;
};
static const TextboxMessage scTextboxToMessageID[] = {
{"T_SelectWii_00", 0x13F},
{"T_SelectWii_01", 0x13F},
{"T_SelectSd_00", 0x140},
{"T_SelectSd_01", 0x140},
{"T_Error_00", 0xE6},
};
static const char* scTriggerPaneName[] = {
"B_ArwR", "B_ArwL", "B_SelectWii_00", "B_SelectSd_00",
};
MemoryCard::MemoryCard(EGG::Heap* heap)
: Base(heap), MemoryBase(), mState(2), mPrevState(2), mSlot(0), mIconIndex(-15), mIconCount(0),
mShowArwR(0), mShowArwL(0), mpEvent(NULL), mpFocusSaveData(NULL) {
System::getMem2App()->dump();
nw4r::ut::List_Init(&mSaveDataList, offsetof(GCSaveData, mLink));
nw4r::ut::List_Init(&mBalloonList, 0);
}
MemoryBase::~MemoryBase() {}
void MemoryCard::prepare() {
System::getBS2Manager()->abort();
unk_0x08 = System::getNandManager()->readLayoutAsync(getSceneHeap(), "gcMem.ash");
mBalloonLayoutFile = System::getNandManager()->readLayoutAsync(getSceneHeap(), "balloon.ash");
}
void MemoryCard::create() {
u32 start = OSGetTick();
while (System::getBS2Manager()->getIPLState() != 8) {
System::getBS2Manager()->update();
OSReport(" ... wait for bs2 abord\n");
VIWaitForRetrace();
}
u32 end = OSGetTick();
OSReport("*** BS2 abort costs: %dms\n", OSTicksToMilliseconds(end - start));
ES_SetUid((u64(1) << 32) | 2);
mpLayout = new layout::Object(getSceneHeap(), unk_0x08, "arc", "it_ObjCubeEdit_a.brlyt");
add_animation(scAnmName, 0x1B);
get_animation(7)->mAnim->setAnmType(1);
get_animation(10)->mAnim->setAnmType(1);
mpLayout->finishBinding();
do_animation(0);
do_animation(1);
do_animation(0x14);
do_animation(0x17);
do_animation(0x18);
mPrevState = mState;
mState = 0;
mpLayout->FindPaneByName("N_ArwR")->SetVisible(false);
mpLayout->FindPaneByName("N_ArwL")->SetVisible(false);
mpEvent = new MemoryBaseEvent(this);
mpPaneManager = new gui::PaneManager(mpEvent, mpLayout->getDrawInfo(), NULL, NULL, true);
mpPaneManager->setupScene(mpLayout);
mpPaneManager->setAllComponentTriggerTarget(false);
for (int i = 0; i < 4; i++) {
nw4r::lyt::Pane* pane = mpLayout->FindPaneByName(scTriggerPaneName[i]);
mpPaneManager->setTriggerTarget(pane, true);
}
add_anmbutton(scTriggerPaneName[2], get_animation(6), get_animation(7), get_animation(8));
add_anmbutton(scTriggerPaneName[3], get_animation(9), get_animation(10), get_animation(11));
add_anmbutton(scTriggerPaneName[0], get_animation(16), get_animation(18), get_animation(12));
add_anmbutton(scTriggerPaneName[1], get_animation(17), get_animation(19), get_animation(13));
for (int i = 0; i < 5; i++) {
set_textbox(scTextboxToMessageID[i].paneName, scTextboxToMessageID[i].messageId);
}
mpGCWindow = new GCWindow(getSceneHeap(), unk_0x08, "arc", "it_CubeDetail_a.brlyt");
mpGCWindow->do_animation(0);
MemoryCardManager* manager = new MemoryCardManager();
mpManager = manager;
mpManager->setEventHandler(mpGCWindow);
mpGCWindow->mpMemoryCardManager = mpManager;
for (int i = 0; i < 0x2D; i++) {
nw4r::lyt::Pane* pane = mpLayout->FindPaneByName(scSavedataPaneName[i]);
nw4r::math::VEC3 position(0.0f, 0.0f, 0.0f);
PSMTXMultVec(pane->GetGlobalMtx(), reinterpret_cast<const Vec*>(&position), reinterpret_cast<Vec*>(&position));
GCSaveData* saveData =
new GCSaveData(getSceneHeap(), unk_0x08, "arc", "it_ObjCubeEdit_b.brlyt", position);
saveData->set_visible("N_Data_00", false);
nw4r::ut::List_Append(&mSaveDataList, saveData);
if (i >= 0xF && i < 0x1E) {
position.y -= 55.0f;
TextBalloon* balloon =
new TextBalloon(getSceneHeap(), mBalloonLayoutFile, "arc", "my_IplTopBalloon_a.brlyt",
math::VEC3(position), 90.0f, 60.0f);
nw4r::ut::List_Append(&mBalloonList, balloon);
saveData->setBalloon(balloon);
}
}
for (int i = 0; i < 2; i++) {
mSlotState[i] = 0;
}
set_visible("N_Capa_00", false);
set_visible("T_Error_00", false);
}
void MemoryCard::calc() {
mpManager->calc();
if (is_fadein_enable()) {
mpLayout->calc();
mpPaneManager->calc();
s16 index = mIconIndex;
mIconCount = 0;
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
if (mpManager->isIconValidate(mSlot, index) || index < 0) {
mIconCount++;
}
saveData->mSlot = mSlot;
saveData->mIndex = index;
saveData->calc();
index++;
}
MemoryBase::AnmButton* button = NULL;
while ((button = static_cast<MemoryBase::AnmButton*>(nw4r::ut::List_GetNext(&mAnmButtonList, button))) != NULL) {
button->calc();
}
TextBalloon* balloon = NULL;
while ((balloon = static_cast<TextBalloon*>(nw4r::ut::List_GetNext(&mBalloonList, balloon))) != NULL) {
balloon->calc();
}
switch (mState) {
case 0:
on_fadein1st();
break;
case 1:
on_fadein2nd();
break;
case 2:
on_normal();
break;
case 3:
on_scroll_r();
break;
case 4:
on_scroll_l();
break;
case 5:
on_change_tag1st();
break;
case 6:
on_change_tag2nd();
break;
case 7:
on_fadeout1st();
break;
case 8:
on_fadeout2nd();
break;
case 9:
mpGCWindow->calc();
show_capacity(mSlot);
break;
case 10:
on_error();
break;
case 11:
on_insert_card();
break;
case 12:
on_detach_card();
break;
}
}
}
void MemoryCard::on_fadein1st() {
if (!is_animation(1)) {
do_animation(5);
mpLayout->FindPaneByName("N_ArwR")->SetVisible(true);
mpLayout->FindPaneByName("N_ArwL")->SetVisible(true);
if (mpManager->isSlotReady(mSlot)) {
mSlotState[mSlot] = 1;
start_savedata_fadein();
mPrevState = mState;
mState = 1;
} else {
start_errormessage_fadein();
mPrevState = mState;
mState = 10;
}
}
}
void MemoryCard::on_fadein2nd() {
GCSaveData* saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, NULL));
if (!is_animation(5) && !saveData->is_animation(0)) {
mPrevState = mState;
mState = 2;
}
}
void MemoryCard::on_normal() {
if (get_setting_button()->update()) {
if (mPrevState == 10) {
do_animation(0x1A);
}
mPrevState = mState;
mState = 7;
return;
}
show_arw();
show_capacity(mSlot);
if (!update_slot()) {
mpPaneManager->update();
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
saveData->update();
}
mpGCWindow->calc();
if (mIconCount <= 15) {
bool canScroll = false;
if (mIconIndex >= 0 && mState == 2) {
canScroll = true;
}
if (canScroll) {
start_scroll_l();
return;
}
}
controller::Interface* controller = System::getYoungController();
if (controller != NULL) {
if (controller->down(0x30001000)) {
start_scroll_l();
} else if (controller->down(0x06000010)) {
start_scroll_r();
}
}
}
}
void MemoryCard::on_scroll_r() {
if (!is_animation(0xC)) {
get_animation(0xC)->mAnim->initAnmFrame();
mpLayout->calc();
mState = 2;
mIconIndex += 0xF;
}
scroll_common();
}
void MemoryCard::on_scroll_l() {
if (!is_animation(0xD)) {
get_animation(0xC)->mAnim->initAnmFrame();
mpLayout->calc();
mState = 2;
mIconIndex -= 0xF;
}
scroll_common();
}
void MemoryCard::on_change_tag1st() {
GCSaveData* first = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, NULL));
if (!first->is_animation(1)) {
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
saveData->set_visible("N_Data_00", false);
}
mSlot ^= 1;
mSlotState[mSlot] = 0;
mIconIndex = -15;
mPrevState = mState;
mState = 2;
}
}
void MemoryCard::on_change_tag2nd() {
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
if (!saveData->is_animation(0)) {
mState = 2;
break;
}
}
}
void MemoryCard::on_fadeout1st() {
if (!get_setting_button()->isPlaying()) {
do_animation(4);
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
saveData->do_animation(1);
}
mState = 8;
}
}
void MemoryCard::on_fadeout2nd() {
if (!is_animation(4)) {
bool shutdown = memorycard::shutdownCardThread();
if (shutdown) {
requestSceneDestruction();
System::getBS2Manager()->restart();
OSReport(" ... bs2 manager restarted\n");
}
}
}
void MemoryCard::on_error() {
if (!is_animation(0x19)) {
mPrevState = mState;
mState = 2;
}
}
void MemoryCard::on_insert_card() {
if (!is_animation(0x1A)) {
start_savedata_fadein();
mPrevState = mState;
mState = 1;
}
}
void MemoryCard::on_detach_card() {
GCSaveData* first = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, NULL));
if (!first->is_animation(1)) {
start_errormessage_fadein();
mPrevState = mState;
mState = 10;
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
saveData->set_visible("N_Data_00", false);
}
}
}
void MemoryCard::start_savedata_fadein() {
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
saveData->set_visible("N_Data_00", true);
saveData->do_animation(0);
}
}
void MemoryCard::start_savedata_fadeout() {
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
saveData->do_animation(1);
}
set_visible("N_Capa_00", false);
}
void MemoryCard::start_errormessage_fadein() {
if (mpManager->isSlotWrongDevice(mSlot) != 0) {
mSlotState[mSlot] = 3;
set_textbox("T_Error_00", mSlot == 0 ? 0xE8 : 0xE9);
} else {
mSlotState[mSlot] = 2;
set_textbox("T_Error_00", mSlot == 0 ? 0xE6 : 0xE7);
}
set_visible("T_Error_00", true);
do_animation(0x19);
}
int MemoryCard::update_slot() {
if (mSlotState[mSlot] != 1 && mpManager->isSlotReady(mSlot) != 0) {
for (u16 i = 0xF; i < 0x1E; i++) {
static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i))->init();
}
mSlotState[mSlot] = 1;
if (mPrevState == 10) {
do_animation(0x1A);
}
mPrevState = mState;
mState = 0xB;
return true;
}
if (mSlotState[mSlot] != 2 && mpManager->isSlotNoCard(mSlot) != 0) {
for (u16 i = 0xF; i < 0x1E; i++) {
static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i))->init();
}
mSlotState[mSlot] = 2;
mIconIndex = -15;
start_savedata_fadeout();
mPrevState = mState;
mState = 0xC;
return true;
}
if ((mSlotState[mSlot] != 3 && mpManager->isSlotWrongDevice(mSlot) != 0) || mSlotState[mSlot] == 0) {
for (u16 i = 0xF; i < 0x1E; i++) {
static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i))->init();
}
mSlotState[mSlot] = 3;
start_savedata_fadeout();
mPrevState = mState;
mState = 0xC;
return true;
}
return false;
}
void MemoryCard::show_arw() {
if (mShowArwR == 0 && can_scroll_r()) {
do_animation(0x15);
do_animation(0x12);
mShowArwR = 1;
} else if (mShowArwR != 0 && !can_scroll_r()) {
do_animation(0x17);
mShowArwR = 0;
}
if (mShowArwL == 0 && can_scroll_l()) {
do_animation(0x16);
do_animation(0x13);
mShowArwL = 1;
} else if (mShowArwL != 0 && !can_scroll_l()) {
do_animation(0x18);
mShowArwL = 0;
}
}
void MemoryCard::show_capacity(u8 slot) {
if (!mpManager->isSlotReady(slot)) {
set_visible("N_Capa_00", false);
return;
}
u32 freeBlocks = mpManager->getFreeBlocks(slot);
wchar_t digits[5];
wchar_t digitTable[10] = {L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9'};
digits[0] = L'\0';
digits[1] = L'\0';
digits[2] = L'\0';
digits[3] = L'\0';
digits[4] = L'\0';
wchar_t text[0x40] = L"";
int blocks = static_cast<u16>(freeBlocks);
digits[0] = digitTable[blocks / 1000];
digits[1] = digitTable[blocks / 100 % 10];
digits[2] = digitTable[blocks / 10 % 10];
digits[3] = digitTable[blocks % 10];
int zeroOffset;
for (zeroOffset = 0; zeroOffset < 3; zeroOffset++) {
if (digits[zeroOffset] != L'0') {
break;
}
}
int blockOpenOffset = 0;
const wchar_t* blockOpenMessage = System::getMessage(0x9C);
const wchar_t* blankMessage = System::getMessage(0xF2);
while (true) {
wchar_t chr = *blockOpenMessage++;
text[blockOpenOffset++] = chr;
if (chr == L'\0') {
break;
}
}
text[--blockOpenOffset] = L' ';
wcscpy(text + blockOpenOffset, digits + zeroOffset);
wcscat(text, blankMessage);
set_textbox("T_Capa_00", text);
set_visible("N_Capa_00", true);
}
void MemoryCard::scroll_common() {
for (u16 i = 0; i < 0x2D; i++) {
nw4r::lyt::Pane* pane = mpLayout->FindPaneByName(scSavedataPaneName[i]);
GCSaveData* saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i));
nw4r::math::VEC3 position(0.0f, 0.0f, 0.0f);
PSMTXMultVec(pane->GetGlobalMtx(), reinterpret_cast<const Vec*>(&position), reinterpret_cast<Vec*>(&position));
saveData->setTranslate(position);
saveData->init();
}
}
void MemoryCard::start_scroll_r() {
bool canScroll = false;
if (mIconCount > 0x1E && mState == 2) {
canScroll = true;
}
if (canScroll) {
do_animation(0xC);
mState = 3;
snd::getSystem()->startSE("WSD_SELECT");
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
saveData->init();
}
}
}
void MemoryCard::start_scroll_l() {
bool canScroll = false;
if (mIconIndex >= 0 && mState == 2) {
canScroll = true;
}
if (canScroll) {
do_animation(0xD);
mState = 4;
snd::getSystem()->startSE("WSD_SELECT");
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
saveData->init();
}
}
}
void MemoryCard::draw() {
if (System::onDefaultDrawLayer()) {
utility::Graphics::setOrtho(0);
mpLayout->draw();
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
saveData->draw();
}
mpLayout->draw("N_ArwR");
mpLayout->draw("N_ArwL");
if (mpFocusSaveData != NULL) {
mpGCWindow->draw();
}
if (mState == 2) {
TextBalloon* balloon = NULL;
while ((balloon = static_cast<TextBalloon*>(nw4r::ut::List_GetNext(&mBalloonList, balloon))) != NULL) {
balloon->draw();
}
}
}
}
void MemoryCard::onPoint(const char* paneName, controller::Interface* controller) {
MemoryBase::AnmButton* button = get_anmbutton(paneName);
if (button != NULL) {
if (button->unk_0x04 == 0 &&
(strcmp(paneName, scTriggerPaneName[2]) != 0 || mSlot != 0) &&
(strcmp(paneName, scTriggerPaneName[3]) != 0 || mSlot != 1)) {
button->onCmdRecv(1);
snd::getSystem()->startSE("WIPL_SE_BT_TARGETTING");
if (controller != NULL) {
controller->rumble(0);
}
}
button->unk_0x04++;
}
}
void MemoryCard::onLeft(const char* paneName) {
MemoryBase::AnmButton* button = get_anmbutton(paneName);
if (button != NULL) {
if (button->unk_0x04 == 1 &&
(strcmp(paneName, scTriggerPaneName[2]) != 0 || mSlot != 0) &&
(strcmp(paneName, scTriggerPaneName[3]) != 0 || mSlot != 1)) {
button->onCmdRecv(2);
}
button->unk_0x04--;
}
}
void MemoryCard::onTrig(const char* paneName) {
if (mpFocusSaveData == NULL && get_anmbutton(paneName) != NULL) {
if (strcmp(paneName, scTriggerPaneName[0]) == 0) {
do_animation(0xE);
start_scroll_r();
} else if (strcmp(paneName, scTriggerPaneName[1]) == 0) {
do_animation(0xF);
start_scroll_l();
} else if (strcmp(paneName, scTriggerPaneName[2]) == 0) {
if (mSlot == 1) {
do_animation(0xB);
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
saveData->do_animation(1);
}
if (mPrevState == 10) {
do_animation(0x1A);
}
snd::getSystem()->startSE("WIPL_SE_BT_PUSH");
mState = 5;
}
} else if (strcmp(paneName, scTriggerPaneName[3]) == 0) {
if (mSlot == 0) {
do_animation(8);
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
saveData->do_animation(1);
}
if (mPrevState == 10) {
do_animation(0x1A);
}
snd::getSystem()->startSE("WIPL_SE_BT_PUSH");
mState = 5;
}
}
}
}
void MemoryCard::onFocus(void* data) {
if (mState == 2) {
if (data != NULL) {
snd::getSystem()->startSE("WIPL_SE_DECIDE");
GCSaveData* saveData = static_cast<GCSaveData*>(data);
mpFocusSaveData = saveData;
mpGCWindow->init(math::VEC3(*saveData->getTranslate()), mpManager,
saveData->mSlot,
saveData->mIndex);
change_button_text_close();
}
mState = 9;
}
}
void MemoryCard::onRelease() {
if (mpFocusSaveData != NULL) {
TextBalloon* balloon = mpFocusSaveData->mpBalloon;
if (balloon != NULL) {
balloon->terminate();
}
}
mpFocusSaveData = NULL;
mState = 2;
}
BOOL MemoryCard::isResetAcceptable() const {
return !mpGCWindow->isProcess();
}
void MemoryBase::onMove(const char*) {}
MemoryCardManager::~MemoryCardManager() {}
MemoryCard::~MemoryCard() {}
}
}

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